summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2000-12-18 18:30:26 +0000
committerNiklas Nebel <nn@openoffice.org>2000-12-18 18:30:26 +0000
commit4f4a8c8c5ec90d527c9f5f26771cd9a1de3d4fe4 (patch)
tree19254c1458d85cb013a93809b95db7995ada0d26
parent#80606# GetUnoText public (diff)
downloadcore-4f4a8c8c5ec90d527c9f5f26771cd9a1de3d4fe4.tar.gz
core-4f4a8c8c5ec90d527c9f5f26771cd9a1de3d4fe4.zip
#80606# TextCursor: use own objects for getText/getStart/getEnd
-rw-r--r--sc/inc/textuno.hxx36
-rw-r--r--sc/source/ui/unoobj/textuno.cxx135
2 files changed, 147 insertions, 24 deletions
diff --git a/sc/inc/textuno.hxx b/sc/inc/textuno.hxx
index 580eb7133276..ae734e6257f5 100644
--- a/sc/inc/textuno.hxx
+++ b/sc/inc/textuno.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: textuno.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 16:44:50 $
+ * last change: $Author: nn $ $Date: 2000-12-18 19:29:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,6 +91,7 @@ class EditEngine;
class EditTextObject;
class ScDocShell;
class ScAddress;
+class ScCellObj;
struct ScHeaderFieldData;
@@ -173,6 +174,8 @@ public:
USHORT nP );
virtual ~ScHeaderFooterTextObj();
+ const SvxUnoText& GetUnoText() const;
+
static void FillDummyFieldData( ScHeaderFieldData& rData );
// XText
@@ -247,18 +250,27 @@ public:
};
-// abgeleitete Cursor-Objekte nur, um per getImplementation unterscheiden zu koennen
+// derived cursor objects for getImplementation and getText/getStart/getEnd
//! uno3: SvxUnoTextCursor is not derived from XUnoTunnel, but should be (?)
class ScCellTextCursor : public SvxUnoTextCursor
{
+ ScCellObj& rTextObj;
+
public:
- ScCellTextCursor();
ScCellTextCursor(const ScCellTextCursor& rOther);
- ScCellTextCursor(const SvxUnoText& rText);
+ ScCellTextCursor(ScCellObj& rText);
virtual ~ScCellTextCursor();
+ // SvxUnoTextCursor methods reimplemented here:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
+ getText() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
+ getStart() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
+ getEnd() throw(::com::sun::star::uno::RuntimeException);
+
// XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
sal_Int8 >& aIdentifier )
@@ -271,12 +283,22 @@ public:
class ScHeaderFooterTextCursor : public SvxUnoTextCursor
{
+private:
+ ScHeaderFooterTextObj& rTextObj;
+
public:
- ScHeaderFooterTextCursor();
ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther);
- ScHeaderFooterTextCursor(const SvxUnoText& rText);
+ ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText);
virtual ~ScHeaderFooterTextCursor();
+ // SvxUnoTextCursor methods reimplemented here:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL
+ getText() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
+ getStart() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL
+ getEnd() throw(::com::sun::star::uno::RuntimeException);
+
// XUnoTunnel
virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence<
sal_Int8 >& aIdentifier )
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 98e77444dee5..ea20eb83a084 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: textuno.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: nn $ $Date: 2000-10-24 12:06:46 $
+ * last change: $Author: nn $ $Date: 2000-12-18 19:30:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -90,6 +90,7 @@
#include "editutil.hxx"
#include "unoguard.hxx"
#include "miscuno.hxx"
+#include "cellsuno.hxx"
using namespace com::sun::star;
@@ -270,13 +271,19 @@ ScHeaderFooterTextObj::~ScHeaderFooterTextObj()
pUnoText->release();
}
+const SvxUnoText& ScHeaderFooterTextObj::GetUnoText() const
+{
+ DBG_ASSERT(pUnoText, "GetUnoText: NULL");
+ return *pUnoText;
+}
+
// XText
uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursor()
throw(uno::RuntimeException)
{
ScUnoGuard aGuard;
- return new ScHeaderFooterTextCursor( *pUnoText );
+ return new ScHeaderFooterTextCursor( *this );
}
uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursorByRange(
@@ -380,6 +387,14 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
SvxEditSource* pEditSource = pTextRange->GetEditSource();
ESelection aSelection = pTextRange->GetSelection();
+ if (!bAbsorb)
+ {
+ // don't replace -> append at end
+ aSelection.Adjust();
+ aSelection.nStartPara = aSelection.nEndPara;
+ aSelection.nStartPos = aSelection.nEndPos;
+ }
+
SvxFieldItem aItem = pHeaderField->CreateFieldItem();
SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
@@ -392,6 +407,8 @@ void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
aSelection.nEndPos = aSelection.nStartPos + 1;
pHeaderField->InitDoc( &rContentObj, nPart, aSelection );
+ pTextRange->SetSelection( aSelection );
+
return;
}
}
@@ -487,23 +504,65 @@ sal_Bool SAL_CALL ScHeaderFooterTextObj::hasElements() throw(uno::RuntimeExcepti
//------------------------------------------------------------------------
-ScCellTextCursor::ScCellTextCursor() :
- SvxUnoTextCursor( SvxUnoText() )
+ScCellTextCursor::ScCellTextCursor(const ScCellTextCursor& rOther) :
+ SvxUnoTextCursor( rOther ),
+ rTextObj( rOther.rTextObj )
{
+ rTextObj.acquire();
}
-ScCellTextCursor::ScCellTextCursor(const ScCellTextCursor& rOther) :
- SvxUnoTextCursor( rOther )
+ScCellTextCursor::ScCellTextCursor(ScCellObj& rText) :
+ SvxUnoTextCursor( rText.GetUnoText() ),
+ rTextObj( rText )
{
+ rTextObj.acquire();
}
-ScCellTextCursor::ScCellTextCursor(const SvxUnoText& rText) :
- SvxUnoTextCursor( rText )
+ScCellTextCursor::~ScCellTextCursor()
{
+ rTextObj.release();
}
-ScCellTextCursor::~ScCellTextCursor()
+// SvxUnoTextCursor methods reimplemented here to return the right objects:
+
+uno::Reference<text::XText> SAL_CALL ScCellTextCursor::getText() throw(uno::RuntimeException)
{
+ ScUnoGuard aGuard;
+ return &rTextObj;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getStart() throw(uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScCellTextCursor* pNew = new ScCellTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel = GetSelection();
+ aNewSel.nEndPara = aNewSel.nStartPara;
+ aNewSel.nEndPos = aNewSel.nStartPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getEnd() throw(uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScCellTextCursor* pNew = new ScCellTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel = GetSelection();
+ aNewSel.nStartPara = aNewSel.nEndPara;
+ aNewSel.nStartPos = aNewSel.nEndPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
}
// XUnoTunnel
@@ -549,23 +608,65 @@ ScCellTextCursor* ScCellTextCursor::getImplementation( const uno::Reference<uno:
//------------------------------------------------------------------------
-ScHeaderFooterTextCursor::ScHeaderFooterTextCursor() :
- SvxUnoTextCursor( SvxUnoText() )
+ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther) :
+ SvxUnoTextCursor( rOther ),
+ rTextObj( rOther.rTextObj )
{
+ rTextObj.acquire();
}
-ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther) :
- SvxUnoTextCursor( rOther )
+ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText) :
+ SvxUnoTextCursor( rText.GetUnoText() ),
+ rTextObj( rText )
{
+ rTextObj.acquire();
}
-ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(const SvxUnoText& rText) :
- SvxUnoTextCursor( rText )
+ScHeaderFooterTextCursor::~ScHeaderFooterTextCursor()
{
+ rTextObj.release();
}
-ScHeaderFooterTextCursor::~ScHeaderFooterTextCursor()
+// SvxUnoTextCursor methods reimplemented here to return the right objects:
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterTextCursor::getText() throw(uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+ return &rTextObj;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getStart() throw(uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel = GetSelection();
+ aNewSel.nEndPara = aNewSel.nStartPara;
+ aNewSel.nEndPos = aNewSel.nStartPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getEnd() throw(uno::RuntimeException)
{
+ ScUnoGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel = GetSelection();
+ aNewSel.nStartPara = aNewSel.nEndPara;
+ aNewSel.nStartPos = aNewSel.nEndPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
}
// XUnoTunnel