summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Kettner <vakevk+libreoffice@gmail.com>2014-07-07 14:32:02 +0200
committerValentin Kettner <vakevk+libreoffice@gmail.com>2014-07-15 15:44:04 +0200
commitf634ec520fa9e8c3e7b1f0660c7a6561bdff2aaa (patch)
treeb44c2d2d6f3d6ed4a48f5e98a737008950d82050
parent3fed83524dc33453f3ec25baa4a170bac51ab1e0 (diff)
Refactored IDocumentContentOperations out of SwDoc.
Into the new class DocumentContentOperationsManager. Made SwNodes in sw/inc/ndarr.hxx friend class to DocumentContentOperationsManager so it can call DelNodes at end of DocumentContentOperationsManager::DeleteSection . Added DeleteAutoCorrExceptWord to SwDoc, its needed in the Manager. Added a non const version of SwDoc::GetDfltGrfFmtColl() to SwDoc because its needed in the Manager. Made SwDoc a friend class to DocumentContentOperationsManager so it can call SwDoc::checkRedlining and SwDocL::_MakeFlySection. Moved SwDoc::CopyImpl_ , SwDoc::CopyWithFlyInFly and SwDoc::CopyFlyInFlyImpl into the Manager. Moved "struct ParaRstFmt" and "lcl_RstTxtAttr" from docfmt.cxx in DocumentContentOperationsManager.hxx . Change-Id: Icaab57f4a8c158a85e549ecb4aacc752bc95bbc9
-rw-r--r--sw/Library_sw.mk1
-rw-r--r--sw/inc/IDocumentContentOperations.hxx2
-rw-r--r--sw/inc/doc.hxx87
-rw-r--r--sw/inc/ndarr.hxx3
-rw-r--r--sw/qa/core/uwriter.cxx148
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx8
-rw-r--r--sw/source/core/crsr/bookmrk.cxx8
-rw-r--r--sw/source/core/crsr/crstrvl.cxx10
-rw-r--r--sw/source/core/crsr/findattr.cxx6
-rw-r--r--sw/source/core/crsr/findtxt.cxx2
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx4461
-rw-r--r--sw/source/core/doc/doc.cxx421
-rw-r--r--sw/source/core/doc/doccomp.cxx7
-rw-r--r--sw/source/core/doc/docdesc.cxx5
-rw-r--r--sw/source/core/doc/docedt.cxx1913
-rw-r--r--sw/source/core/doc/docfmt.cxx730
-rw-r--r--sw/source/core/doc/docglbl.cxx3
-rw-r--r--sw/source/core/doc/docglos.cxx2
-rw-r--r--sw/source/core/doc/doclay.cxx121
-rw-r--r--sw/source/core/doc/docnew.cxx6
-rw-r--r--sw/source/core/doc/docnum.cxx14
-rw-r--r--sw/source/core/doc/docredln.cxx59
-rw-r--r--sw/source/core/doc/docruby.cxx9
-rw-r--r--sw/source/core/doc/docsort.cxx4
-rw-r--r--sw/source/core/doc/doctxm.cxx2
-rw-r--r--sw/source/core/doc/extinput.cxx10
-rw-r--r--sw/source/core/doc/tblcpy.cxx3
-rw-r--r--sw/source/core/doc/tblrwcl.cxx5
-rw-r--r--sw/source/core/doc/textboxhelper.cxx2
-rw-r--r--sw/source/core/docnode/ndcopy.cxx1317
-rw-r--r--sw/source/core/docnode/ndsect.cxx8
-rw-r--r--sw/source/core/docnode/ndtbl.cxx10
-rw-r--r--sw/source/core/docnode/node.cxx2
-rw-r--r--sw/source/core/docnode/nodes.cxx4
-rw-r--r--sw/source/core/docnode/section.cxx5
-rw-r--r--sw/source/core/edit/acorrect.cxx18
-rw-r--r--sw/source/core/edit/autofmt.cxx26
-rw-r--r--sw/source/core/edit/edatmisc.cxx8
-rw-r--r--sw/source/core/edit/eddel.cxx13
-rw-r--r--sw/source/core/edit/edfld.cxx3
-rw-r--r--sw/source/core/edit/edglbldc.cxx12
-rw-r--r--sw/source/core/edit/edglss.cxx6
-rw-r--r--sw/source/core/edit/editsh.cxx22
-rw-r--r--sw/source/core/edit/edlingu.cxx10
-rw-r--r--sw/source/core/edit/edsect.cxx3
-rw-r--r--sw/source/core/edit/edtab.cxx4
-rw-r--r--sw/source/core/edit/edtox.cxx4
-rw-r--r--sw/source/core/edit/edundo.cxx1
-rw-r--r--sw/source/core/frmedt/fecopy.cxx16
-rw-r--r--sw/source/core/frmedt/fedesc.cxx3
-rw-r--r--sw/source/core/frmedt/fefly1.cxx12
-rw-r--r--sw/source/core/frmedt/fews.cxx2
-rw-r--r--sw/source/core/frmedt/tblsel.cxx4
-rw-r--r--sw/source/core/inc/DocumentContentOperationsManager.hxx171
-rw-r--r--sw/source/core/inc/UndoInsert.hxx3
-rw-r--r--sw/source/core/layout/atrfrm.cxx4
-rw-r--r--sw/source/core/table/swnewtable.cxx5
-rw-r--r--sw/source/core/txtnode/atrfld.cxx6
-rw-r--r--sw/source/core/txtnode/atrftn.cxx5
-rw-r--r--sw/source/core/txtnode/txtedt.cxx2
-rw-r--r--sw/source/core/undo/unattr.cxx8
-rw-r--r--sw/source/core/undo/undel.cxx16
-rw-r--r--sw/source/core/undo/unins.cxx18
-rw-r--r--sw/source/core/undo/unmove.cxx8
-rw-r--r--sw/source/core/undo/unovwr.cxx6
-rw-r--r--sw/source/core/undo/unredln.cxx2
-rw-r--r--sw/source/core/undo/unsort.cxx4
-rw-r--r--sw/source/core/undo/unspnd.cxx4
-rw-r--r--sw/source/core/undo/untbl.cxx7
-rw-r--r--sw/source/core/undo/untblk.cxx2
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx8
-rw-r--r--sw/source/core/unocore/unodraw.cxx2
-rw-r--r--sw/source/core/unocore/unofield.cxx10
-rw-r--r--sw/source/core/unocore/unoframe.cxx14
-rw-r--r--sw/source/core/unocore/unoftn.cxx6
-rw-r--r--sw/source/core/unocore/unoidx.cxx4
-rw-r--r--sw/source/core/unocore/unoobj.cxx2
-rw-r--r--sw/source/core/unocore/unoobj2.cxx8
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx2
-rw-r--r--sw/source/core/unocore/unorefmk.cxx10
-rw-r--r--sw/source/core/unocore/unotbl.cxx5
-rw-r--r--sw/source/core/unocore/unotext.cxx56
-rw-r--r--sw/source/core/view/viewsh.cxx2
-rw-r--r--sw/source/filter/ascii/parasc.cxx14
-rw-r--r--sw/source/filter/html/htmldrawreader.cxx2
-rw-r--r--sw/source/filter/html/htmlfld.cxx4
-rw-r--r--sw/source/filter/html/htmlftn.cxx2
-rw-r--r--sw/source/filter/html/htmlgrin.cxx2
-rw-r--r--sw/source/filter/html/htmlplug.cxx8
-rw-r--r--sw/source/filter/html/htmlsect.cxx2
-rw-r--r--sw/source/filter/html/htmltab.cxx6
-rw-r--r--sw/source/filter/html/swhtml.cxx26
-rw-r--r--sw/source/filter/rtf/swparrtf.cxx4
-rw-r--r--sw/source/filter/ww1/fltshell.cxx28
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx2
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx8
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx8
-rw-r--r--sw/source/filter/ww8/ww8par.cxx42
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par3.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par4.cxx7
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx60
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.cxx5
-rw-r--r--sw/source/filter/xml/xmlimp.cxx4
-rw-r--r--sw/source/filter/xml/xmltbli.cxx4
-rw-r--r--sw/source/filter/xml/xmltexti.cxx13
-rw-r--r--sw/source/uibase/app/docsh.cxx12
-rw-r--r--sw/source/uibase/app/docshini.cxx2
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx5
-rw-r--r--sw/source/uibase/docvw/PageBreakWin.cxx3
-rw-r--r--sw/source/uibase/uno/unoatxt.cxx3
-rw-r--r--sw/source/uibase/wrtsh/wrtsh1.cxx2
112 files changed, 5231 insertions, 5020 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 89562acf3e9b..0366a642c72b 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -193,6 +193,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/DocumentListItemsManager \
sw/source/core/doc/DocumentListsManager \
sw/source/core/doc/DocumentOutlineNodesManager \
+ sw/source/core/doc/DocumentContentOperationsManager \
sw/source/core/doc/extinput \
sw/source/core/doc/fmtcol \
sw/source/core/doc/ftnidx \
diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx
index 57684605854a..522752817080 100644
--- a/sw/inc/IDocumentContentOperations.hxx
+++ b/sw/inc/IDocumentContentOperations.hxx
@@ -21,6 +21,8 @@
#define INCLUDED_SW_INC_IDOCUMENTCONTENTOPERATIONS_HXX
#include <sal/types.h>
+#include <rtl/ustring.hxx>
+using rtl::OUString;
class SwPaM;
struct SwPosition;
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 7b87e8fecff8..779df32d016a 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -24,7 +24,6 @@
#include <IDocumentMarkAccess.hxx>
#include <IDocumentRedlineAccess.hxx>
#include <IDocumentFieldsAccess.hxx>
-#include <IDocumentContentOperations.hxx>
#include <IDocumentStylePoolAccess.hxx>
#include <IDocumentLineNumberAccess.hxx>
#include <IDocumentStatistics.hxx>
@@ -193,6 +192,7 @@ class IDocumentLinksAdministration;
class IDocumentListItems;
class IDocumentListsAccess;
class IDocumentOutlineNodes;
+class IDocumentContentOperations;
class _SetGetExpFlds;
namespace sw { namespace mark {
@@ -211,6 +211,7 @@ namespace sw {
class DocumentListItemsManager;
class DocumentListsManager;
class DocumentOutlineNodesManager;
+ class DocumentContentOperationsManager;
}
namespace com { namespace sun { namespace star {
@@ -250,7 +251,6 @@ class SW_DLLPUBLIC SwDoc :
public IInterface,
public IDocumentRedlineAccess,
public IDocumentFieldsAccess,
- public IDocumentContentOperations,
public IDocumentStylePoolAccess,
public IDocumentLineNumberAccess,
public IDocumentStatistics,
@@ -258,6 +258,7 @@ class SW_DLLPUBLIC SwDoc :
public IDocumentLayoutAccess,
public IDocumentExternalData
{
+ friend class ::sw::DocumentContentOperationsManager;
friend void _InitCore();
friend void _FinitCore();
@@ -292,6 +293,7 @@ class SW_DLLPUBLIC SwDoc :
const ::boost::scoped_ptr< ::sw::DocumentListItemsManager > m_pDocumentListItemsManager;
const ::boost::scoped_ptr< ::sw::DocumentListsManager > m_pDocumentListsManager;
const ::boost::scoped_ptr< ::sw::DocumentOutlineNodesManager > m_pDocumentOutlineNodesManager;
+ const ::boost::scoped_ptr< ::sw::DocumentContentOperationsManager > m_pDocumentContentOperationsManager;
// Pointer
SwFrmFmt *mpDfltFrmFmt; //< Default formats.
@@ -427,26 +429,10 @@ private:
// private methods
void checkRedlining(RedlineMode_t& _rReadlineMode);
- /** Only for internal use and therefore private.
- Copy a range within the same or to another document.
- Position may not lie within range! */
- bool CopyImpl( SwPaM&, SwPosition&, const bool MakeNewFrms /*= true */,
- const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const;
-
SwFlyFrmFmt* _MakeFlySection( const SwPosition& rAnchPos,
const SwCntntNode& rNode, RndStdIds eRequestId,
const SfxItemSet* pFlyAttrSet,
SwFrmFmt* = 0 );
-
- SwFlyFrmFmt* _InsNoTxtNode( const SwPosition&rPos, SwNoTxtNode*,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* = 0 );
-
- void CopyFlyInFlyImpl( const SwNodeRange& rRg,
- const sal_Int32 nEndContentIndex,
- const SwNodeIndex& rStartIdx,
- const bool bCopyFlyAtFly = false ) const;
sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, bool bNewFrms );
typedef SwFmt* (SwDoc:: *FNCopyFmt)( const OUString&, SwFmt*, bool, bool );
@@ -507,11 +493,6 @@ private:
void InitTOXTypes();
void Paste( const SwDoc& );
- bool DeleteAndJoinImpl(SwPaM&, const bool);
- bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false);
- bool DeleteRangeImpl(SwPaM&, const bool unused = false);
- bool DeleteRangeImplImpl(SwPaM &);
- bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
public:
enum DocumentType {
@@ -645,52 +626,14 @@ public:
bool containsUpdatableFields();
// IDocumentContentOperations
- virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll) const SAL_OVERRIDE;
- virtual void DeleteSection(SwNode* pNode) SAL_OVERRIDE;
- virtual bool DeleteRange(SwPaM&) SAL_OVERRIDE;
- virtual bool DelFullPara(SwPaM&) SAL_OVERRIDE;
- // Add optional parameter <bForceJoinNext>, default value <false>
- // Needed for hiding of deletion redlines
- virtual bool DeleteAndJoin( SwPaM&,
- const bool bForceJoinNext = false ) SAL_OVERRIDE;
- virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) SAL_OVERRIDE;
- virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) SAL_OVERRIDE;
- virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags) SAL_OVERRIDE;
- virtual bool Overwrite(const SwPaM &rRg, const OUString& rStr) SAL_OVERRIDE;
- virtual bool InsertString(const SwPaM &rRg, const OUString&,
- const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ) SAL_OVERRIDE;
+ IDocumentContentOperations const & getIDocumentContentOperations() const;
+ IDocumentContentOperations & getIDocumentContentOperations();
+ ::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const;
+ ::sw::DocumentContentOperationsManager & GetDocumentContentOperationsManager();
+
+ virtual void SetModified(SwPaM &rPaM);
virtual bool UpdateParRsid( SwTxtNode *pTxtNode, sal_uInt32 nVal = 0 );
virtual bool UpdateRsid( const SwPaM &rRg, sal_Int32 nLen );
- virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
- const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
- virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
- virtual SwDrawFrmFmt* InsertDrawObj(
- const SwPaM &rRg,
- SdrObject& rDrawObj,
- const SfxItemSet& rFlyAttrSet ) SAL_OVERRIDE;
- virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
-
- // Add a para for the char attribute exp...
- virtual bool InsertPoolItem(
- const SwPaM &rRg,
- const SfxPoolItem&,
- const SetAttrMode nFlags,
- const bool bExpandCharToPara=false) SAL_OVERRIDE;
-
- virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
- const SetAttrMode nFlags) SAL_OVERRIDE;
- virtual void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj) SAL_OVERRIDE;
- virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) SAL_OVERRIDE;
- virtual SwFlyFrmFmt* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
- virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart) SAL_OVERRIDE;
- virtual bool AppendTxtNode(SwPosition& rPos) SAL_OVERRIDE;
- virtual void SetModified(SwPaM &rPaM);
- virtual bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
- const bool bRegExReplace) SAL_OVERRIDE;
- virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ) SAL_OVERRIDE;
// IDocumentStylePoolAccess
virtual SwTxtFmtColl* GetTxtCollFromPool( sal_uInt16 nId, bool bRegardLanguage = true ) SAL_OVERRIDE;
@@ -845,14 +788,6 @@ public:
const SwSelBoxes* pSelBoxes = 0,
SwFrmFmt *pParent = 0 );
- void CopyWithFlyInFly( const SwNodeRange& rRg,
- const sal_Int32 nEndContentIndex,
- const SwNodeIndex& rInsPos,
- const SwPaM* pCopiedPaM = NULL,
- bool bMakeNewFrms = true,
- bool bDelRedlines = true,
- bool bCopyFlyAtFly = false ) const;
-
//UUUU Helper that checks for unique items for DrawingLayer items of type NameOrIndex
// and evtl. corrects that items to ensure unique names for that type. This call may
// modify/correct entries inside of the given SfxItemSet, and it will apply a name to
@@ -1043,6 +978,7 @@ public:
void ChkCondColls();
const SwGrfFmtColl* GetDfltGrfFmtColl() const { return mpDfltGrfFmtColl; }
+ SwGrfFmtColl* GetDfltGrfFmtColl() { return mpDfltGrfFmtColl; }
const SwGrfFmtColls *GetGrfFmtColls() const { return mpGrfFmtCollTbl; }
SwGrfFmtColl *MakeGrfFmtColl(const OUString &rFmtName,
SwGrfFmtColl *pDerivedFrom);
@@ -1592,6 +1528,7 @@ public:
// Save current values for automatic registration of exceptions in Autocorrection.
void SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew );
SwAutoCorrExceptWord* GetAutoCorrExceptWord() { return mpACEWord; }
+ void DeleteAutoCorrExceptWord();
const SwFmtINetFmt* FindINetAttr( const OUString& rName ) const;
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx
index d8c71d6c4479..a004af367379 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -64,6 +64,8 @@ class SwUndoTblToTxt;
class SwUndoTxtToTbl;
struct SwPosition;
+namespace sw { class DocumentContentOperationsManager; }
+
// class SwNodes
typedef SwNode * SwNodePtr;
@@ -88,6 +90,7 @@ class SW_DLLPUBLIC SwNodes
friend class SwDoc;
friend class SwNode;
friend class SwNodeIndex;
+ friend class ::sw::DocumentContentOperationsManager;
SwNodeIndex* pRoot; ///< List of all indices on nodes.
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index c15ca72f0c21..75cbf77806bc 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -187,7 +187,7 @@ void SwDocTest::testDocStat()
SwPaM aPaM(aIdx);
OUString sText("Hello World");
- m_pDoc->InsertString(aPaM, sText);
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sText);
CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->GetDocStat().nChar == 0);
@@ -230,15 +230,15 @@ void SwDocTest::testModelToViewHelper()
SwFmtFtn aFtn;
aFtn.SetNumStr(OUString("foo"));
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("AAAAA BBBBB "));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("AAAAA BBBBB "));
SwTxtNode* pTxtNode = aPaM.GetNode().GetTxtNode();
sal_Int32 nPos = aPaM.GetPoint()->nContent.GetIndex();
pTxtNode->InsertItem(aFtn, nPos, nPos);
- m_pDoc->InsertString(aPaM, OUString(" CCCCC "));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(" CCCCC "));
nPos = aPaM.GetPoint()->nContent.GetIndex();
pTxtNode->InsertItem(aFtn, nPos, nPos);
- m_pDoc->InsertString(aPaM, OUString(" DDDDD"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(" DDDDD"));
CPPUNIT_ASSERT(pTxtNode->GetTxt().getLength() == (4*5) + 5 + 2);
//set start of selection to first B
@@ -248,7 +248,7 @@ void SwDocTest::testModelToViewHelper()
aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 14);
//set character attribute hidden on range
SvxCharHiddenItem aHidden(true, RES_CHRATR_HIDDEN);
- m_pDoc->InsertPoolItem(aPaM, aHidden, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, aHidden, 0 );
aPaM.DeleteMark();
//turn on red-lining and show changes
@@ -261,7 +261,7 @@ void SwDocTest::testModelToViewHelper()
aPaM.SetMark();
//set end of selection to second last B
aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 9);
- m_pDoc->DeleteAndJoin(aPaM); //redline-aware deletion api
+ m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPaM); //redline-aware deletion api
aPaM.DeleteMark();
{
@@ -400,8 +400,8 @@ void SwDocTest::testModelToViewHelper()
aModelToViewHelper.getFieldPositions().size());
}
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("AAAAA"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("AAAAA"));
IDocumentMarkAccess* pMarksAccess = m_pDoc->getIDocumentMarkAccess();
sw::mark::IFieldmark *pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(
pMarksAccess->makeNoTextFieldBookmark(aPaM, "test", ODF_FORMDROPDOWN));
@@ -410,7 +410,7 @@ void SwDocTest::testModelToViewHelper()
vListEntries[0] = "BBBBB";
(*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_LISTENTRY] = uno::makeAny(vListEntries);
(*pFieldmark->GetParameters())[ODF_FORMDROPDOWN_RESULT] = uno::makeAny(sal_Int32(0));
- m_pDoc->InsertString(aPaM, OUString("CCCCC"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("CCCCC"));
pTxtNode = aPaM.GetNode().GetTxtNode();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11),
pTxtNode->GetTxt().getLength());
@@ -473,13 +473,13 @@ void SwDocTest::testSwScanner()
{
const sal_Unicode IDEOGRAPHICFULLSTOP_D[] = { 0x3002, 'D' };
- m_pDoc->InsertString(aPaM, OUString(IDEOGRAPHICFULLSTOP_D,
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(IDEOGRAPHICFULLSTOP_D,
SAL_N_ELEMENTS(IDEOGRAPHICFULLSTOP_D)));
SvxLanguageItem aCJKLangItem( LANGUAGE_CHINESE_SIMPLIFIED, RES_CHRATR_CJK_LANGUAGE );
SvxLanguageItem aWestLangItem( LANGUAGE_ENGLISH_US, RES_CHRATR_LANGUAGE );
- m_pDoc->InsertPoolItem(aPaM, aCJKLangItem, 0 );
- m_pDoc->InsertPoolItem(aPaM, aWestLangItem, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, aCJKLangItem, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, aWestLangItem, 0 );
SwDocStat aDocStat;
pTxtNode = aPaM.GetNode().GetTxtNode();
@@ -508,14 +508,14 @@ void SwDocTest::testSwScanner()
0x0020, 0x0064, 0x006F, 0x0065, 0x0073, 0x0020, 0x0074, 0x0068,
0x0069, 0x0073, 0x0020, 0x0064, 0x006F, 0x003F, 0x0020, 0x0020
};
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString(test,
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(test,
SAL_N_ELEMENTS(test)));
SvxLanguageItem aCJKLangItem( LANGUAGE_JAPANESE, RES_CHRATR_CJK_LANGUAGE );
SvxLanguageItem aWestLangItem( LANGUAGE_ENGLISH_US, RES_CHRATR_LANGUAGE );
- m_pDoc->InsertPoolItem(aPaM, aCJKLangItem, 0 );
- m_pDoc->InsertPoolItem(aPaM, aWestLangItem, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, aCJKLangItem, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, aWestLangItem, 0 );
SwDocStat aDocStat;
pTxtNode = aPaM.GetNode().GetTxtNode();
@@ -537,8 +537,8 @@ void SwDocTest::testSwScanner()
0x0065, 0x0065, 0x2019
};
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString(aShouldBeThree, SAL_N_ELEMENTS(aShouldBeThree)));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(aShouldBeThree, SAL_N_ELEMENTS(aShouldBeThree)));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, SAL_N_ELEMENTS(aShouldBeThree));
CPPUNIT_ASSERT_MESSAGE("Should be 3", aDocStat.nWord == 3);
@@ -554,8 +554,8 @@ void SwDocTest::testSwScanner()
0x006C, 0x0065, 0x0072, 0x3000, 0x00BB
};
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString(aShouldBeFive, SAL_N_ELEMENTS(aShouldBeFive)));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(aShouldBeFive, SAL_N_ELEMENTS(aShouldBeFive)));
pTxtNode = aPaM.GetNode().GetTxtNode();
aDocStat.Reset();
pTxtNode->CountWords(aDocStat, 0, SAL_N_ELEMENTS(aShouldBeFive));
@@ -566,8 +566,8 @@ void SwDocTest::testSwScanner()
{
SwDocStat aDocStat;
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("Apple"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Apple"));
pTxtNode = aPaM.GetNode().GetTxtNode();
sal_Int32 nPos = aPaM.GetPoint()->nContent.GetIndex();
SwFmtFtn aFtn;
@@ -591,16 +591,16 @@ void SwDocTest::testSwScanner()
CPPUNIT_ASSERT(aDocStat.nWord == 1);
CPPUNIT_ASSERT_MESSAGE("refmark anchor should not be counted", aDocStat.nChar == 11);
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("Apple"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Apple"));
DateTime aDate(DateTime::SYSTEM);
SwPostItField aPostIt(
(SwPostItFieldType*)m_pDoc->GetSysFldType(RES_POSTITFLD), OUString("An Author"),
OUString("Some Text"), OUString("Initials"), OUString("Name"), aDate );
- m_pDoc->InsertPoolItem(aPaM, SwFmtFld(aPostIt), 0);
+ m_pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, SwFmtFld(aPostIt), 0);
- m_pDoc->InsertString(aPaM, OUString("Apple"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Apple"));
pTxtNode = aPaM.GetNode().GetTxtNode();
aDocStat.Reset();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
@@ -616,8 +616,8 @@ void SwDocTest::testSwScanner()
SwDocStat aDocStat;
const char aString[] = "Lorem ipsum";
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString(aString));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString(aString));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT_EQUAL(aDocStat.nWord, static_cast<sal_uLong>(2));
@@ -630,7 +630,7 @@ void SwDocTest::testSwScanner()
//delete everything except the first word
aPaM.SetMark(); //set start of selection to current pos
aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), 5); //set end of selection to fifth char of current node
- m_pDoc->DeleteAndJoin(aPaM); //redline-aware deletion api
+ m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPaM); //redline-aware deletion api
//"real underlying text should be the same"
CPPUNIT_ASSERT_EQUAL(pTxtNode->GetTxt(), OUString(aString));
@@ -679,8 +679,8 @@ void SwDocTest::testSwScanner()
OUString sTemplate("ThisXis a test.");
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', ' '));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', ' '));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 4 &&
@@ -688,8 +688,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 15);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" = ")));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" = ")));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -697,8 +697,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 17);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" _ ")));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" _ ")));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -706,8 +706,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 17);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" -- ")));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), OUString(" -- ")));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 5 &&
@@ -715,8 +715,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 18);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', '_'));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', '_'));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 3 &&
@@ -724,8 +724,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 15);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', '-'));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', '-'));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 3 &&
@@ -733,8 +733,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 15);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', 0x2012));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', 0x2012));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 3 &&
@@ -742,8 +742,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 15);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', 0x2015));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', 0x2015));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 3 &&
@@ -753,8 +753,8 @@ void SwDocTest::testSwScanner()
//But default configuration should, msword-alike treak emdash
//and endash as word separators for word-counting
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', 0x2013));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', 0x2013));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 4 &&
@@ -762,8 +762,8 @@ void SwDocTest::testSwScanner()
aDocStat.nChar == 15);
aDocStat.Reset();
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replace('X', 0x2014));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replace('X', 0x2014));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 4 &&
@@ -773,8 +773,8 @@ void SwDocTest::testSwScanner()
const sal_Unicode aChunk[] = {' ', 0x2013, ' '};
OUString sChunk(aChunk, SAL_N_ELEMENTS(aChunk));
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, sTemplate.replaceAll(OUString('X'), sChunk));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, sTemplate.replaceAll(OUString('X'), sChunk));
pTxtNode = aPaM.GetNode().GetTxtNode();
pTxtNode->CountWords(aDocStat, 0, pTxtNode->Len());
CPPUNIT_ASSERT(aDocStat.nWord == 4 &&
@@ -792,14 +792,14 @@ void SwDocTest::testGraphicAnchorDeletion()
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
- m_pDoc->InsertString(aPaM, OUString("Paragraph 1"));
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Paragraph 1"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("graphic anchor>><<graphic anchor"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("graphic anchor>><<graphic anchor"));
SwNodeIndex nPara2 = aPaM.GetPoint()->nNode;
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("Paragraph 3"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Paragraph 3"));
aPaM.GetPoint()->nNode = nPara2;
aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), RTL_CONSTASCII_LENGTH("graphic anchor>>"));
@@ -809,7 +809,7 @@ void SwDocTest::testGraphicAnchorDeletion()
SwFmtAnchor aAnchor(FLY_AS_CHAR);
aAnchor.SetAnchor(aPaM.GetPoint());
aFlySet.Put(aAnchor);
- SwFlyFrmFmt *pFrame = m_pDoc->Insert(aPaM, OUString(), OUString(), NULL, &aFlySet, NULL, NULL);
+ SwFlyFrmFmt *pFrame = m_pDoc->getIDocumentContentOperations().Insert(aPaM, OUString(), OUString(), NULL, &aFlySet, NULL, NULL);
CPPUNIT_ASSERT_MESSAGE("Expected frame", pFrame != NULL);
CPPUNIT_ASSERT_MESSAGE("Should be 1 graphic", m_pDoc->GetFlyCount(FLYCNTTYPE_GRF) == 1);
@@ -821,7 +821,7 @@ void SwDocTest::testGraphicAnchorDeletion()
aPaM.SetMark();
aPaM.GetPoint()->nNode = nPara2;
aPaM.GetPoint()->nContent.Assign(aPaM.GetCntntNode(), RTL_CONSTASCII_LENGTH("graphic anchor>"));
- m_pDoc->DeleteRange(aPaM);
+ m_pDoc->getIDocumentContentOperations().DeleteRange(aPaM);
#ifdef DEBUG_AS_HTML
{
@@ -908,7 +908,7 @@ void SwDocTest::randomTest()
switch (getRand (i < 50 ? 3 : 6)) {
// insert ops first
case 0: {
- if (!m_pDoc->InsertString(aCrs, getRandString())) {
+ if (!m_pDoc->getIDocumentContentOperations().InsertString(aCrs, getRandString())) {
// fprintf (stderr, "failed to insert string !\n");
}
break;
@@ -925,17 +925,17 @@ void SwDocTest::randomTest()
case 3: // deletion
switch (getRand(6)) {
case 0:
- m_pDoc->DelFullPara(aCrs);
+ m_pDoc->getIDocumentContentOperations().DelFullPara(aCrs);
break;
case 1:
- m_pDoc->DeleteRange(aCrs);
+ m_pDoc->getIDocumentContentOperations().DeleteRange(aCrs);
break;
case 2:
- m_pDoc->DeleteAndJoin(aCrs, !!getRand(1));
+ m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aCrs, !!getRand(1));
break;
case 3:
default:
- m_pDoc->Overwrite(aCrs, getRandString());
+ m_pDoc->getIDocumentContentOperations().Overwrite(aCrs, getRandString());
break;
}
break;
@@ -949,7 +949,7 @@ void SwDocTest::randomTest()
IDocumentContentOperations::DOC_MOVEREDLINES |
IDocumentContentOperations::DOC_NO_DELFRMS);
SwPosition aTo(getRandomPosition(m_pDoc, i/10));
- m_pDoc->MoveRange(aCrs, aTo, nFlags);
+ m_pDoc->getIDocumentContentOperations().MoveRange(aCrs, aTo, nFlags);
break;
}
@@ -983,7 +983,7 @@ translitTest(SwDoc & rDoc, SwPaM & rPaM, sal_uInt32 const nType)
{
utl::TransliterationWrapper aTrans(
::comphelper::getProcessComponentContext(), nType);
- rDoc.TransliterateText(rPaM, aTrans);
+ rDoc.getIDocumentContentOperations().TransliterateText(rPaM, aTrans);
return rPaM.GetTxt();
}
@@ -992,7 +992,7 @@ void SwDocTest::testTransliterate()
// just some simple test to see if it's totally broken
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
- m_pDoc->InsertString(aPaM, OUString("foobar"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("foobar"));
aPaM.SetMark();
aPaM.GetPoint()->nContent = 0;
CPPUNIT_ASSERT_EQUAL(OUString("foobar"), aPaM.GetTxt());
@@ -1024,19 +1024,19 @@ void SwDocTest::testMarkMove()
{
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
- m_pDoc->InsertString(aPaM, OUString("Paragraph 1"));
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Paragraph 1"));
aPaM.SetMark();
aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex();
pMarksAccess->makeMark(aPaM, OUString("Para1"), IDocumentMarkAccess::BOOKMARK);
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("Paragraph 2"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Paragraph 2"));
aPaM.SetMark();
aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex();
pMarksAccess->makeMark(aPaM, OUString("Para2"), IDocumentMarkAccess::BOOKMARK);
- m_pDoc->AppendTxtNode(*aPaM.GetPoint());
- m_pDoc->InsertString(aPaM, OUString("Paragraph 3"));
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode(*aPaM.GetPoint());
+ m_pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("Paragraph 3"));
aPaM.SetMark();
aPaM.GetMark()->nContent -= aPaM.GetMark()->nContent.GetIndex();
pMarksAccess->makeMark(aPaM, OUString("Para3"), IDocumentMarkAccess::BOOKMARK);
@@ -1083,7 +1083,7 @@ void SwDocTest::testMarkMove()
SwPaM aPaM(aIdx, aIdx, -1);
aPaM.GetPoint()->nContent += 5;
aPaM.GetMark()->nContent += 6;
- m_pDoc->DeleteAndJoin(aPaM);
+ m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPaM);
}
pBM1 = pMarksAccess->findMark("Para1")->get();
pBM2 = pMarksAccess->findMark("Para2")->get();
@@ -1119,7 +1119,7 @@ void SwDocTest::testMarkMove()
SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1);
SwPosition aPos(aIdx);
aPos.nContent += 8;
- m_pDoc->SplitNode(aPos, false);
+ m_pDoc->getIDocumentContentOperations().SplitNode(aPos, false);
}
pBM1 = pMarksAccess->findMark("Para1")->get();
pBM2 = pMarksAccess->findMark("Para2")->get();
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 47aba1ecad62..f13d1c7c8d7f 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -100,11 +100,11 @@ void SwUiWriterTest::testReplaceForward()
SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
- pDoc->InsertString(aPaM, ORIGINAL_REPLACE_CONTENT);
+ pDoc->getIDocumentContentOperations().InsertString(aPaM, ORIGINAL_REPLACE_CONTENT);
SwTxtNode* pTxtNode = aPaM.GetNode().GetTxtNode();
lcl_selectCharacters(aPaM, 5, 9);
- pDoc->ReplaceRange(aPaM, OUString("toto"), false);
+ pDoc->getIDocumentContentOperations().ReplaceRange(aPaM, OUString("toto"), false);
CPPUNIT_ASSERT_EQUAL(EXPECTED_REPLACE_CONTENT, pTxtNode->GetTxt());
@@ -150,11 +150,11 @@ void SwUiWriterTest::testReplaceBackward()
SwNodeIndex aIdx(pDoc->GetNodes().GetEndOfContent(), -1);
SwPaM aPaM(aIdx);
- pDoc->InsertString(aPaM, OUString("toto titi tutu"));
+ pDoc->getIDocumentContentOperations().InsertString(aPaM, OUString("toto titi tutu"));
SwTxtNode* pTxtNode = aPaM.GetNode().GetTxtNode();
lcl_selectCharacters(aPaM, 9, 5);
- pDoc->ReplaceRange(aPaM, OUString("toto"), false);
+ pDoc->getIDocumentContentOperations().ReplaceRange(aPaM, OUString("toto"), false);
CPPUNIT_ASSERT_EQUAL(EXPECTED_REPLACE_CONTENT, pTxtNode->GetTxt());
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 6452bdf849ba..0f533d197791 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -72,7 +72,7 @@ namespace
if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) )
{
SwPaM aStartPaM(rStart);
- io_pDoc->InsertString(aStartPaM, OUString(aStartMark));
+ io_pDoc->getIDocumentContentOperations().InsertString(aStartPaM, OUString(aStartMark));
rStart.nContent--;
pField->SetMarkStartPos( rStart );
}
@@ -85,7 +85,7 @@ namespace
if ( aEndMark && ( ch_end != aEndMark ) )
{
SwPaM aEndPaM(rEnd);
- io_pDoc->InsertString(aEndPaM, OUString(aEndMark));
+ io_pDoc->getIDocumentContentOperations().InsertString(aEndPaM, OUString(aEndMark));
rEnd.nContent++;
}
@@ -108,7 +108,7 @@ namespace
{
SwPaM aStart(rStart, rStart);
aStart.End()->nContent++;
- io_pDoc->DeleteRange(aStart);
+ io_pDoc->getIDocumentContentOperations().DeleteRange(aStart);
}
const SwPosition& rEnd = pField->GetMarkEnd();
@@ -121,7 +121,7 @@ namespace
{
SwPaM aEnd(rEnd, rEnd);
aEnd.Start()->nContent--;
- io_pDoc->DeleteRange(aEnd);
+ io_pDoc->getIDocumentContentOperations().DeleteRange(aEnd);
}
io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL);
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 8ff7f73720e0..6fcef4ac0344 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1850,7 +1850,7 @@ bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
for( sal_uInt16 n = 0; n < aFPos.nParaCnt + aFPos.nColumnCnt; ++n )
{
- GetDoc()->AppendTxtNode( aPos );
+ GetDoc()->getIDocumentContentOperations().AppendTxtNode( aPos );
if( !n && pNextFmt )
{
*m_pCurCrsr->GetPoint() = aPos;
@@ -1859,7 +1859,7 @@ bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
if( n < aFPos.nColumnCnt )
{
*m_pCurCrsr->GetPoint() = aPos;
- GetDoc()->InsertPoolItem( *m_pCurCrsr,
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem( *m_pCurCrsr,
SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0);
}
}
@@ -1885,7 +1885,7 @@ bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
if( SVX_ADJUST_LEFT != rAdj.GetAdjust() )
aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) );
- GetDoc()->InsertItemSet( *m_pCurCrsr, aSet, 0 );
+ GetDoc()->getIDocumentContentOperations().InsertItemSet( *m_pCurCrsr, aSet, 0 );
}
else {
OSL_ENSURE( !this, "No CntntNode" );
@@ -1901,7 +1901,7 @@ bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
if (aFPos.nSpaceCnt)
comphelper::string::padToLength(sInsert, sInsert.getLength() + aFPos.nSpaceCnt, ' ');
if (!sInsert.isEmpty())
- GetDoc()->InsertString( *m_pCurCrsr, sInsert.makeStringAndClear());
+ GetDoc()->getIDocumentContentOperations().InsertString( *m_pCurCrsr, sInsert.makeStringAndClear());
}
// no break - still need to set orientation
case FILL_MARGIN:
@@ -1919,7 +1919,7 @@ bool SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode )
default:
break;
}
- GetDoc()->InsertPoolItem( *m_pCurCrsr, aAdj, 0 );
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem( *m_pCurCrsr, aAdj, 0 );
}
break;
}
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index bc581a78b7f9..21aa5317d4fe 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1152,7 +1152,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
boost::scoped_ptr<OUString> pRepl( (bRegExp) ?
ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0 );
- rCursor.GetDoc()->ReplaceRange( *pCrsr,
+ rCursor.GetDoc()->getIDocumentContentOperations().ReplaceRange( *pCrsr,
(pRepl.get()) ? *pRepl : pSearchOpt->replaceString,
bRegExp );
rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() );
@@ -1177,7 +1177,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
// they are not in ReplaceSet
if( !pSet->Count() )
{
- pCrsr->GetDoc()->InsertItemSet( *pCrsr, *pReplSet, 0 );
+ pCrsr->GetDoc()->getIDocumentContentOperations().InsertItemSet( *pCrsr, *pReplSet, 0 );
}
else
{
@@ -1198,7 +1198,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
pItem = aIter.NextItem();
}
aSet.Put( *pReplSet );
- pCrsr->GetDoc()->InsertItemSet( *pCrsr, aSet, 0 );
+ pCrsr->GetDoc()->getIDocumentContentOperations().InsertItemSet( *pCrsr, aSet, 0 );
}
return FIND_NO_RING;
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index b8e2b470dfb3..e6af7316df28 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -582,7 +582,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
boost::scoped_ptr<OUString> pRepl( (bRegExp)
? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0 );
- rCursor.GetDoc()->ReplaceRange( *pCrsr,
+ rCursor.GetDoc()->getIDocumentContentOperations().ReplaceRange( *pCrsr,
(pRepl.get()) ? *pRepl : rSearchOpt.replaceString,
bRegExp );
rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() );
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
new file mode 100644
index 000000000000..5e0fa796fbec
--- /dev/null
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -0,0 +1,4461 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <DocumentContentOperationsManager.hxx>
+#include <doc.hxx>
+#include <IDocumentUndoRedo.hxx>
+#include <IDocumentMarkAccess.hxx>
+#include <UndoManager.hxx>
+#include <docary.hxx>
+#include <textboxhelper.hxx>
+#include <dcontact.hxx>
+#include <grfatr.hxx>
+#include <numrule.hxx>
+#include <charfmt.hxx>
+#include <ndgrf.hxx>
+#include <ndnotxt.hxx>
+#include <ndole.hxx>
+#include <fmtcol.hxx>
+#include <breakit.hxx>
+#include <frmfmt.hxx>
+#include <fmtanchr.hxx>
+#include <fmtcntnt.hxx>
+#include <fmtinfmt.hxx>
+#include <fmtpdsc.hxx>
+#include <fmtcnct.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <redline.hxx>
+#include <unocrsr.hxx>
+#include <mvsave.hxx>
+#include <ndtxt.hxx>
+#include <poolfmt.hxx>
+#include <paratr.hxx>
+#include <txatbase.hxx>
+#include <UndoRedline.hxx>
+#include <undobj.hxx>
+#include <UndoDelete.hxx>
+#include <UndoSplitMove.hxx>
+#include <UndoOverwrite.hxx>
+#include <UndoInsert.hxx>
+#include <UndoAttribute.hxx>
+#include <rolbck.hxx>
+#include <acorrect.hxx>
+#include <ftnidx.hxx>
+#include <txtftn.hxx>
+#include <hints.hxx>
+#include <crsrsh.hxx>
+#include <fmtflcnt.hxx>
+#include <unotools/charclass.hxx>
+#include <sfx2/Metadatable.hxx>
+#include <svl/stritem.hxx>
+#include <svl/itemiter.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdouno.hxx>
+#include <editeng/formatbreakitem.hxx>
+#include <com/sun/star/i18n/Boundary.hpp>
+
+using namespace ::com::sun::star::i18n;
+
+extern void sw_GetJoinFlags( SwPaM& rPam, bool& rJoinTxt, bool& rJoinPrev );
+extern void sw_JoinText( SwPaM& rPam, bool bJoinPrev );
+//local functions originally from sw/source/core/docnode/ndcopy.cxx
+namespace
+{
+ // Copy method from SwDoc
+ // Prevent copying in Flys that are anchored in the area
+ static bool lcl_ChkFlyFly( SwDoc* pDoc, sal_uLong nSttNd, sal_uLong nEndNd,
+ sal_uLong nInsNd )
+ {
+ const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
+
+ for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n )
+ {
+ SwFrmFmt const*const pFmt = rFrmFmtTbl[n];
+ SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
+ SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
+ if (pAPos &&
+ ((FLY_AS_CHAR == pAnchor->GetAnchorId()) ||
+ (FLY_AT_CHAR == pAnchor->GetAnchorId()) ||
+ (FLY_AT_FLY == pAnchor->GetAnchorId()) ||
+ (FLY_AT_PARA == pAnchor->GetAnchorId())) &&
+ nSttNd <= pAPos->nNode.GetIndex() &&
+ pAPos->nNode.GetIndex() < nEndNd )
+ {
+ const SwFmtCntnt& rCntnt = pFmt->GetCntnt();
+ SwStartNode* pSNd;
+ if( !rCntnt.GetCntntIdx() ||
+ 0 == ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ))
+ continue;
+
+ if( pSNd->GetIndex() < nInsNd &&
+ nInsNd < pSNd->EndOfSectionIndex() )
+ // Do not copy !
+ return true;
+
+ if( lcl_ChkFlyFly( pDoc, pSNd->GetIndex(),
+ pSNd->EndOfSectionIndex(), nInsNd ) )
+ // Do not copy !
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /*
+ The lcl_CopyBookmarks function has to copy bookmarks from the source to the destination nodes
+ array. It is called after a call of the _CopyNodes(..) function. But this function does not copy
+ every node (at least at the moment: 2/08/2006 ), section start and end nodes will not be copied if the corresponding end/start node is outside the copied pam.
+ The lcl_NonCopyCount function counts the number of these nodes, given the copied pam and a node
+ index inside the pam.
+ rPam is the original source pam, rLastIdx is the last calculated position, rDelCount the number
+ of "non-copy" nodes between rPam.Start() and rLastIdx.
+ nNewIdx is the new position of interest.
+ */
+
+ static void lcl_NonCopyCount( const SwPaM& rPam, SwNodeIndex& rLastIdx, const sal_uLong nNewIdx, sal_uLong& rDelCount )
+ {
+ sal_uLong nStart = rPam.Start()->nNode.GetIndex();
+ sal_uLong nEnd = rPam.End()->nNode.GetIndex();
+ if( rLastIdx.GetIndex() < nNewIdx ) // Moving forward?
+ {
+ do // count "non-copy" nodes
+ {
+ SwNode& rNode = rLastIdx.GetNode();
+ if( ( rNode.IsSectionNode() && rNode.EndOfSectionIndex() >= nEnd )
+ || ( rNode.IsEndNode() && rNode.StartOfSectionNode()->GetIndex() < nStart ) )
+ ++rDelCount;
+ ++rLastIdx;
+ }
+ while( rLastIdx.GetIndex() < nNewIdx );
+ }
+ else if( rDelCount ) // optimization: if there are no "non-copy" nodes until now,
+ // no move backward needed
+ {
+ while( rLastIdx.GetIndex() > nNewIdx )
+ {
+ SwNode& rNode = rLastIdx.GetNode();
+ if( ( rNode.IsSectionNode() && rNode.EndOfSectionIndex() >= nEnd )
+ || ( rNode.IsEndNode() && rNode.StartOfSectionNode()->GetIndex() < nStart ) )
+ --rDelCount;
+ rLastIdx--;
+ }
+ }
+ }
+
+ static void lcl_SetCpyPos( const SwPosition& rOrigPos,
+ const SwPosition& rOrigStt,
+ const SwPosition& rCpyStt,
+ SwPosition& rChgPos,
+ sal_uLong nDelCount )
+ {
+ sal_uLong nNdOff = rOrigPos.nNode.GetIndex();
+ nNdOff -= rOrigStt.nNode.GetIndex();
+ nNdOff -= nDelCount;
+ sal_Int32 nCntntPos = rOrigPos.nContent.GetIndex();
+
+ // Always adjust <nNode> at to be changed <SwPosition> instance <rChgPos>
+ rChgPos.nNode = nNdOff + rCpyStt.nNode.GetIndex();
+ if( !nNdOff )
+ {
+ // dann nur den Content anpassen
+ if( nCntntPos > rOrigStt.nContent.GetIndex() )
+ nCntntPos -= rOrigStt.nContent.GetIndex();
+ else
+ nCntntPos = 0;
+ nCntntPos += rCpyStt.nContent.GetIndex();
+ }
+ rChgPos.nContent.Assign( rChgPos.nNode.GetNode().GetCntntNode(), nCntntPos );
+ }
+
+ // TODO: use SaveBookmark (from _DelBookmarks)
+ static void lcl_CopyBookmarks(
+ const SwPaM& rPam,
+ SwPaM& rCpyPam )
+ {
+ const SwDoc* pSrcDoc = rPam.GetDoc();
+ SwDoc* pDestDoc = rCpyPam.GetDoc();
+ const IDocumentMarkAccess* const pSrcMarkAccess = pSrcDoc->getIDocumentMarkAccess();
+ ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
+
+ const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
+ SwPosition* pCpyStt = rCpyPam.Start();
+
+ typedef ::std::vector< const ::sw::mark::IMark* > mark_vector_t;
+ mark_vector_t vMarksToCopy;
+ for ( IDocumentMarkAccess::const_iterator_t ppMark = pSrcMarkAccess->getAllMarksBegin();
+ ppMark != pSrcMarkAccess->getAllMarksEnd();
+ ++ppMark )
+ {
+ const ::sw::mark::IMark* const pMark = ppMark->get();
+
+ const SwPosition& rMarkStart = pMark->GetMarkStart();
+ const SwPosition& rMarkEnd = pMark->GetMarkEnd();
+ // only include marks that are in the range and not touching both start and end
+ // - not for annotation marks.
+ const bool bIsNotOnBoundary =
+ pMark->IsExpanded()
+ ? (rMarkStart != rStt || rMarkEnd != rEnd) // rMarkStart != rMarkEnd
+ : (rMarkStart != rStt && rMarkEnd != rEnd); // rMarkStart == rMarkEnd
+ if ( rMarkStart >= rStt && rMarkEnd <= rEnd
+ && ( bIsNotOnBoundary
+ || IDocumentMarkAccess::GetType( *pMark ) == IDocumentMarkAccess::ANNOTATIONMARK ) )
+ {
+ vMarksToCopy.push_back(pMark);
+ }
+ }
+ // We have to count the "non-copied" nodes..
+ SwNodeIndex aCorrIdx(rStt.nNode);
+ sal_uLong nDelCount = 0;
+ for(mark_vector_t::const_iterator ppMark = vMarksToCopy.begin();
+ ppMark != vMarksToCopy.end();
+ ++ppMark)
+ {
+ const ::sw::mark::IMark* const pMark = *ppMark;
+ SwPaM aTmpPam(*pCpyStt);
+ lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetMarkPos().nNode.GetIndex(), nDelCount);
+ lcl_SetCpyPos( pMark->GetMarkPos(), rStt, *pCpyStt, *aTmpPam.GetPoint(), nDelCount);
+ if(pMark->IsExpanded())
+ {
+ aTmpPam.SetMark();
+ lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetOtherMarkPos().nNode.GetIndex(), nDelCount);
+ lcl_SetCpyPos(pMark->GetOtherMarkPos(), rStt, *pCpyStt, *aTmpPam.GetMark(), nDelCount);
+ }
+
+ ::sw::mark::IMark* const pNewMark = pDestDoc->getIDocumentMarkAccess()->makeMark(
+ aTmpPam,
+ pMark->GetName(),
+ IDocumentMarkAccess::GetType(*pMark));
+ // Explicitly try to get exactly the same name as in the source
+ // because NavigatorReminders, DdeBookmarks etc. ignore the proposed name
+ pDestDoc->getIDocumentMarkAccess()->renameMark(pNewMark, pMark->GetName());
+
+ // copying additional attributes for bookmarks or fieldmarks
+ ::sw::mark::IBookmark* const pNewBookmark =
+ dynamic_cast< ::sw::mark::IBookmark* const >(pNewMark);
+ const ::sw::mark::IBookmark* const pOldBookmark =
+ dynamic_cast< const ::sw::mark::IBookmark* >(pMark);
+ if (pNewBookmark && pOldBookmark)
+ {
+ pNewBookmark->SetKeyCode(pOldBookmark->GetKeyCode());
+ pNewBookmark->SetShortName(pOldBookmark->GetShortName());
+ }
+ ::sw::mark::IFieldmark* const pNewFieldmark =
+ dynamic_cast< ::sw::mark::IFieldmark* const >(pNewMark);
+ const ::sw::mark::IFieldmark* const pOldFieldmark =
+ dynamic_cast< const ::sw::mark::IFieldmark* >(pMark);
+ if (pNewFieldmark && pOldFieldmark)
+ {
+ pNewFieldmark->SetFieldname(pOldFieldmark->GetFieldname());
+ pNewFieldmark->SetFieldHelptext(pOldFieldmark->GetFieldHelptext());
+ ::sw::mark::IFieldmark::parameter_map_t* pNewParams = pNewFieldmark->GetParameters();
+ const ::sw::mark::IFieldmark::parameter_map_t* pOldParams = pOldFieldmark->GetParameters();
+ ::sw::mark::IFieldmark::parameter_map_t::const_iterator pIt = pOldParams->begin();
+ for (; pIt != pOldParams->end(); ++pIt )
+ {
+ pNewParams->insert( *pIt );
+ }
+ }
+
+ ::sfx2::Metadatable const*const pMetadatable(
+ dynamic_cast< ::sfx2::Metadatable const* >(pMark));
+ ::sfx2::Metadatable *const pNewMetadatable(
+ dynamic_cast< ::sfx2::Metadatable * >(pNewMark));
+ if (pMetadatable && pNewMetadatable)
+ {
+ pNewMetadatable->RegisterAsCopyOf(*pMetadatable);
+ }
+ }
+ }
+
+ static void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam )
+ {
+ const SwDoc* pSrcDoc = rPam.GetDoc();
+ const SwRedlineTbl& rTbl = pSrcDoc->GetRedlineTbl();
+ if( !rTbl.empty() )
+ {
+ SwDoc* pDestDoc = rCpyPam.GetDoc();
+ SwPosition* pCpyStt = rCpyPam.Start(), *pCpyEnd = rCpyPam.End();
+ SwPaM* pDelPam = 0;
+ const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
+ // We have to count the "non-copied" nodes
+ sal_uLong nDelCount = 0;
+ SwNodeIndex aCorrIdx( pStt->nNode );
+
+ sal_uInt16 n = 0;
+ pSrcDoc->GetRedline( *pStt, &n );
+ for( ; n < rTbl.size(); ++n )
+ {
+ const SwRangeRedline* pRedl = rTbl[ n ];
+ if( nsRedlineType_t::REDLINE_DELETE == pRedl->GetType() && pRedl->IsVisible() )
+ {
+ const SwPosition *pRStt = pRedl->Start(), *pREnd = pRedl->End();
+
+ SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
+ switch( eCmpPos )
+ {
+ case POS_COLLIDE_END:
+ case POS_BEFORE:
+ // Pos1 is before Pos2
+ break;
+
+ case POS_COLLIDE_START:
+ case POS_BEHIND:
+ // Pos1 is after Pos2
+ n = rTbl.size();
+ break;
+
+ default:
+ {
+ pDelPam = new SwPaM( *pCpyStt, pDelPam );
+ if( *pStt < *pRStt )
+ {
+ lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount );
+ lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
+ *pDelPam->GetPoint(), nDelCount );
+ }
+ pDelPam->SetMark();
+
+ if( *pEnd < *pREnd )
+ *pDelPam->GetPoint() = *pCpyEnd;
+ else
+ {
+ lcl_NonCopyCount( rPam, aCorrIdx, pREnd->nNode.GetIndex(), nDelCount );
+ lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
+ *pDelPam->GetPoint(), nDelCount );
+ }
+ }
+ }
+ }
+ }
+
+ if( pDelPam )
+ {
+ RedlineMode_t eOld = pDestDoc->GetRedlineMode();
+ pDestDoc->SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+
+ ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
+
+ do {
+ pDestDoc->getIDocumentContentOperations().DeleteAndJoin( *(SwPaM*)pDelPam->GetNext() );
+ if( pDelPam->GetNext() == pDelPam )
+ break;
+ delete pDelPam->GetNext();
+ } while( true );
+ delete pDelPam;
+
+ pDestDoc->SetRedlineMode_intern( eOld );
+ }
+ }
+ }
+
+ static void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg )
+ {
+ SwDoc* pSrcDoc = rRg.aStart.GetNode().GetDoc();
+ if( !pSrcDoc->GetRedlineTbl().empty() )
+ {
+ SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
+ SwPaM aCpyTmp( rCpyRg.aStart, rCpyRg.aEnd );
+ lcl_DeleteRedlines( aRgTmp, aCpyTmp );
+ }
+ }
+
+ static void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest )
+ {
+ SwFmtChain aSrc( pSrc->GetChain() );
+ if ( !aSrc.GetNext() )
+ {
+ aSrc.SetNext( pDest );
+ pSrc->SetFmtAttr( aSrc );
+ }
+ SwFmtChain aDest( pDest->GetChain() );
+ if ( !aDest.GetPrev() )
+ {
+ aDest.SetPrev( pSrc );
+ pDest->SetFmtAttr( aDest );
+ }
+ }
+
+ // #i86492#
+ static bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam )
+ {
+ bool bRet = false;
+
+ const SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode();
+ const SwTxtNode* pEndTxtNd = rPam.End()->nNode.GetNode().GetTxtNode();
+ if ( pTxtNd && pTxtNd->IsInList() &&
+ pEndTxtNd && pEndTxtNd->IsInList() )
+ {
+ bRet = true;
+ SwNodeIndex aIdx(rPam.Start()->nNode);
+
+ do
+ {
+ ++aIdx;
+ pTxtNd = aIdx.GetNode().GetTxtNode();
+
+ if ( !pTxtNd || !pTxtNd->IsInList() )
+ {
+ bRet = false;
+ break;
+ }
+ } while ( pTxtNd && pTxtNd != pEndTxtNd );
+ }
+
+ return bRet;
+ }
+
+ static bool lcl_MarksWholeNode(const SwPaM & rPam)
+ {
+ bool bResult = false;
+ const SwPosition* pStt = rPam.Start();
+ const SwPosition* pEnd = rPam.End();
+
+ if (NULL != pStt && NULL != pEnd)
+ {
+ const SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode();
+ const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode();
+
+ if (NULL != pSttNd && NULL != pEndNd &&
+ pStt->nContent.GetIndex() == 0 &&
+ pEnd->nContent.GetIndex() == pEndNd->Len())
+ {
+ bResult = true;
+ }
+ }
+
+ return bResult;
+ }
+}
+
+//local functions originally from sw/source/core/doc/docedt.cxx
+namespace
+{
+ static void
+ lcl_CalcBreaks( ::std::vector<sal_Int32> & rBreaks, SwPaM const & rPam )
+ {
+ SwTxtNode const * const pTxtNode(
+ rPam.End()->nNode.GetNode().GetTxtNode() );
+ if (!pTxtNode)
+ return; // left-overlap only possible at end of selection...
+
+ const sal_Int32 nStart(rPam.Start()->nContent.GetIndex());
+ const sal_Int32 nEnd (rPam.End ()->nContent.GetIndex());
+ if (nEnd == pTxtNode->Len())
+ return; // paragraph selected until the end
+
+ for (sal_Int32 i = nStart; i < nEnd; ++i)
+ {
+ const sal_Unicode c(pTxtNode->GetTxt()[i]);
+ if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c))
+ {
+ SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) );
+ if (pAttr && pAttr->End() && (*pAttr->End() > nEnd))
+ {
+ OSL_ENSURE(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?");
+ rBreaks.push_back(i);
+ }
+ }
+ }
+ }
+
+ static bool lcl_DoWithBreaks(::sw::DocumentContentOperationsManager & rDocumentContentOperations, SwPaM & rPam,
+ bool (::sw::DocumentContentOperationsManager::*pFunc)(SwPaM&, bool), const bool bForceJoinNext = false)
+ {
+ ::std::vector<sal_Int32> Breaks;
+
+ lcl_CalcBreaks(Breaks, rPam);
+
+ if (!Breaks.size())
+ {
+ return (rDocumentContentOperations.*pFunc)(rPam, bForceJoinNext);
+ }
+
+ // Deletion must be split into several parts if the text node
+ // contains a text attribute with end and with dummy character
+ // and the selection does not contain the text attribute completely,
+ // but overlaps its start (left), where the dummy character is.
+
+ SwPosition const & rSelectionEnd( *rPam.End() );
+
+ bool bRet( true );
+ // iterate from end to start, to avoid invalidating the offsets!
+ ::std::vector<sal_Int32>::reverse_iterator iter( Breaks.rbegin() );
+ SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node!
+ SwPosition & rEnd( *aPam.End() );
+ SwPosition & rStart( *aPam.Start() );
+
+ while (iter != Breaks.rend())
+ {
+ rStart.nContent = *iter + 1;
+ if (rEnd.nContent > rStart.nContent) // check if part is empty
+ {
+ bRet &= (rDocumentContentOperations.*pFunc)(aPam, bForceJoinNext);
+ }
+ rEnd.nContent = *iter;
+ ++iter;
+ }
+
+ rStart = *rPam.Start(); // set to original start
+ if (rEnd.nContent > rStart.nContent) // check if part is empty
+ {
+ bRet &= (rDocumentContentOperations.*pFunc)(aPam, bForceJoinNext);
+ }
+
+ return bRet;
+ }
+
+ static bool lcl_StrLenOverflow( const SwPaM& rPam )
+ {
+ // If we try to merge two paragraphs we have to test if afterwards
+ // the string doesn't exceed the allowed string length
+ if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode )
+ {
+ const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
+ const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode();
+ if( (0 != pEndNd) && pStt->nNode.GetNode().IsTxtNode() )
+ {
+ const sal_uInt64 nSum = pStt->nContent.GetIndex() +
+ pEndNd->GetTxt().getLength() - pEnd->nContent.GetIndex();
+ return nSum > static_cast<sal_uInt64>(SAL_MAX_INT32);
+ }
+ }
+ return false;
+ }
+
+ struct _SaveRedline
+ {
+ SwRangeRedline* pRedl;
+ sal_uInt32 nStt, nEnd;
+ sal_Int32 nSttCnt;
+ sal_Int32 nEndCnt;
+
+ _SaveRedline( SwRangeRedline* pR, const SwNodeIndex& rSttIdx )
+ : pRedl(pR)
+ , nEnd(0)
+ , nEndCnt(0)
+ {
+ const SwPosition* pStt = pR->Start(),
+ * pEnd = pR->GetMark() == pStt ? pR->GetPoint() : pR->GetMark();
+ sal_uInt32 nSttIdx = rSttIdx.GetIndex();
+ nStt = pStt->nNode.GetIndex() - nSttIdx;
+ nSttCnt = pStt->nContent.GetIndex();
+ if( pR->HasMark() )
+ {
+ nEnd = pEnd->nNode.GetIndex() - nSttIdx;
+ nEndCnt = pEnd->nContent.GetIndex();
+ }
+
+ pRedl->GetPoint()->nNode = 0;
+ pRedl->GetPoint()->nContent.Assign( 0, 0 );
+ pRedl->GetMark()->nNode = 0;
+ pRedl->GetMark()->nContent.Assign( 0, 0 );
+ }
+
+ _SaveRedline( SwRangeRedline* pR, const SwPosition& rPos )
+ : pRedl(pR)
+ , nEnd(0)
+ , nEndCnt(0)
+ {
+ const SwPosition* pStt = pR->Start(),
+ * pEnd = pR->GetMark() == pStt ? pR->GetPoint() : pR->GetMark();
+ sal_uInt32 nSttIdx = rPos.nNode.GetIndex();
+ nStt = pStt->nNode.GetIndex() - nSttIdx;
+ nSttCnt = pStt->nContent.GetIndex();
+ if( nStt == 0 )
+ nSttCnt = nSttCnt - rPos.nContent.GetIndex();
+ if( pR->HasMark() )
+ {
+ nEnd = pEnd->nNode.GetIndex() - nSttIdx;
+ nEndCnt = pEnd->nContent.GetIndex();
+ if( nEnd == 0 )
+ nEndCnt = nEndCnt - rPos.nContent.GetIndex();
+ }
+
+ pRedl->GetPoint()->nNode = 0;
+ pRedl->GetPoint()->nContent.Assign( 0, 0 );
+ pRedl->GetMark()->nNode = 0;
+ pRedl->GetMark()->nContent.Assign( 0, 0 );
+ }
+
+ void SetPos( sal_uInt32 nInsPos )
+ {
+ pRedl->GetPoint()->nNode = nInsPos + nStt;
+ pRedl->GetPoint()->nContent.Assign( pRedl->GetCntntNode(), nSttCnt );
+ if( pRedl->HasMark() )
+ {
+ pRedl->GetMark()->nNode = nInsPos + nEnd;
+ pRedl->GetMark()->nContent.Assign( pRedl->GetCntntNode(false), nEndCnt );
+ }
+ }
+
+ void SetPos( const SwPosition& aPos )
+ {
+ pRedl->GetPoint()->nNode = aPos.nNode.GetIndex() + nStt;
+ pRedl->GetPoint()->nContent.Assign( pRedl->GetCntntNode(), nSttCnt + ( nStt == 0 ? aPos.nContent.GetIndex() : 0 ) );
+ if( pRedl->HasMark() )
+ {
+ pRedl->GetMark()->nNode = aPos.nNode.GetIndex() + nEnd;
+ pRedl->GetMark()->nContent.Assign( pRedl->GetCntntNode(false), nEndCnt + ( nEnd == 0 ? aPos.nContent.GetIndex() : 0 ) );
+ }
+ }
+ };
+
+ typedef boost::ptr_vector< _SaveRedline > _SaveRedlines;
+
+ static void lcl_SaveRedlines( const SwPaM& aPam, _SaveRedlines& rArr )
+ {
+ SwDoc* pDoc = aPam.GetNode().GetDoc();
+
+ const SwPosition* pStart = aPam.Start();
+ const SwPosition* pEnd = aPam.End();
+
+ // get first relevant redline
+ sal_uInt16 nCurrentRedline;
+ pDoc->GetRedline( *pStart, &nCurrentRedline );
+ if( nCurrentRedline > 0)
+ nCurrentRedline--;
+
+ // redline mode REDLINE_IGNORE|REDLINE_ON; save old mode
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+ pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+
+ // iterate over relevant redlines and decide for each whether it should
+ // be saved, or split + saved
+ SwRedlineTbl& rRedlineTable = const_cast<SwRedlineTbl&>( pDoc->GetRedlineTbl() );
+ for( ; nCurrentRedline < rRedlineTable.size(); nCurrentRedline++ )
+ {
+ SwRangeRedline* pCurrent = rRedlineTable[ nCurrentRedline ];
+ SwComparePosition eCompare =
+ ComparePosition( *pCurrent->Start(), *pCurrent->End(),
+ *pStart, *pEnd);
+
+ // we must save this redline if it overlaps aPam
+ // (we may have to split it, too)
+ if( eCompare == POS_OVERLAP_BEHIND ||
+ eCompare == POS_OVERLAP_BEFORE ||
+ eCompare == POS_OUTSIDE ||
+ eCompare == POS_INSIDE ||
+ eCompare == POS_EQUAL )
+ {
+ rRedlineTable.Remove( nCurrentRedline-- );
+
+ // split beginning, if necessary
+ if( eCompare == POS_OVERLAP_BEFORE ||
+ eCompare == POS_OUTSIDE )
+ {
+ SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
+ *pNewRedline->End() = *pStart;
+ *pCurrent->Start() = *pStart;
+ pDoc->AppendRedline( pNewRedline, true );
+ }
+
+ // split end, if necessary
+ if( eCompare == POS_OVERLAP_BEHIND ||
+ eCompare == POS_OUTSIDE )
+ {
+ SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
+ *pNewRedline->Start() = *pEnd;
+ *pCurrent->End() = *pEnd;
+ pDoc->AppendRedline( pNewRedline, true );
+ }
+
+ // save the current redline
+ _SaveRedline* pSave = new _SaveRedline( pCurrent, *pStart );
+ rArr.push_back( pSave );
+ }
+ }
+
+ // restore old redline mode
+ pDoc->SetRedlineMode_intern( eOld );
+ }
+
+ static void lcl_RestoreRedlines( SwDoc* pDoc, const SwPosition& rPos, _SaveRedlines& rArr )
+ {
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+ pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+
+ for( size_t n = 0; n < rArr.size(); ++n )
+ {
+ rArr[ n ].SetPos( rPos );
+ pDoc->AppendRedline( rArr[ n ].pRedl, true );
+ }
+
+ pDoc->SetRedlineMode_intern( eOld );
+ }
+
+ static void lcl_SaveRedlines( const SwNodeRange& rRg, _SaveRedlines& rArr )
+ {
+ SwDoc* pDoc = rRg.aStart.GetNode().GetDoc();
+ sal_uInt16 nRedlPos;
+ SwPosition aSrchPos( rRg.aStart ); aSrchPos.nNode--;
+ aSrchPos.nContent.Assign( aSrchPos.nNode.GetNode().GetCntntNode(), 0 );
+ if( pDoc->GetRedline( aSrchPos, &nRedlPos ) && nRedlPos )
+ --nRedlPos;
+ else if( nRedlPos >= pDoc->GetRedlineTbl().size() )
+ return ;
+
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+ pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+ SwRedlineTbl& rRedlTbl = (SwRedlineTbl&)pDoc->GetRedlineTbl();
+
+ do {
+ SwRangeRedline* pTmp = rRedlTbl[ nRedlPos ];
+
+ const SwPosition* pRStt = pTmp->Start(),
+ * pREnd = pTmp->GetMark() == pRStt
+ ? pTmp->GetPoint() : pTmp->GetMark();
+
+ if( pRStt->nNode < rRg.aStart )
+ {
+ if( pREnd->nNode > rRg.aStart && pREnd->nNode < rRg.aEnd )
+ {
+ // Create a copy and set the end of the original to the end of the MoveArea.
+ // The copy is moved too.
+ SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp );
+ SwPosition* pTmpPos = pNewRedl->Start();
+ pTmpPos->nNode = rRg.aStart;
+ pTmpPos->nContent.Assign(
+ pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
+
+ _SaveRedline* pSave = new _SaveRedline( pNewRedl, rRg.aStart );
+ rArr.push_back( pSave );
+
+ pTmpPos = pTmp->End();
+ pTmpPos->nNode = rRg.aEnd;
+ pTmpPos->nContent.Assign(
+ pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
+ }
+ else if( pREnd->nNode == rRg.aStart )
+ {
+ SwPosition* pTmpPos = pTmp->End();
+ pTmpPos->nNode = rRg.aEnd;
+ pTmpPos->nContent.Assign(
+ pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
+ }
+ }
+ else if( pRStt->nNode < rRg.aEnd )
+ {
+ rRedlTbl.Remove( nRedlPos-- );
+ if( pREnd->nNode < rRg.aEnd ||
+ ( pREnd->nNode == rRg.aEnd && !pREnd->nContent.GetIndex()) )
+ {
+ // move everything
+ _SaveRedline* pSave = new _SaveRedline( pTmp, rRg.aStart );
+ rArr.push_back( pSave );
+ }
+ else
+ {
+ // split
+ SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp );
+ SwPosition* pTmpPos = pNewRedl->End();
+ pTmpPos->nNode = rRg.aEnd;
+ pTmpPos->nContent.Assign(
+ pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
+
+ _SaveRedline* pSave = new _SaveRedline( pNewRedl, rRg.aStart );
+ rArr.push_back( pSave );
+
+ pTmpPos = pTmp->Start();
+ pTmpPos->nNode = rRg.aEnd;
+ pTmpPos->nContent.Assign(
+ pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
+ pDoc->AppendRedline( pTmp, true );
+ }
+ }
+ else
+ break;
+
+ } while( ++nRedlPos < pDoc->GetRedlineTbl().size() );
+ pDoc->SetRedlineMode_intern( eOld );
+ }
+
+ static void lcl_RestoreRedlines( SwDoc* pDoc, sal_uInt32 nInsPos, _SaveRedlines& rArr )
+ {
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+ pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
+
+ for( size_t n = 0; n < rArr.size(); ++n )
+ {
+ rArr[ n ].SetPos( nInsPos );
+ pDoc->AppendRedline( rArr[ n ].pRedl, true );
+ }
+
+ pDoc->SetRedlineMode_intern( eOld );
+ }
+
+ static bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd,
+ const SwNodeIndex& rInsPos,
+ SwFtnIdxs& rFtnArr, SwFtnIdxs& rSaveArr,
+ const SwIndex* pSttCnt = 0, const SwIndex* pEndCnt = 0 )
+ {
+ bool bUpdateFtn = false;
+ const SwNodes& rNds = rInsPos.GetNodes();
+ const bool bDelFtn = rInsPos.GetIndex() < rNds.GetEndOfAutotext().GetIndex() &&
+ rSttNd.GetIndex() >= rNds.GetEndOfAutotext().GetIndex();
+ const bool bSaveFtn = !bDelFtn &&
+ rInsPos.GetIndex() >= rNds.GetEndOfExtras().GetIndex();
+ if( !rFtnArr.empty() )
+ {
+
+ sal_uInt16 nPos;
+ rFtnArr.SeekEntry( rSttNd, &nPos );
+ SwTxtFtn* pSrch;
+ const SwNode* pFtnNd;
+
+ // Delete/save all that come after it
+ while( nPos < rFtnArr.size() && ( pFtnNd =
+ &( pSrch = rFtnArr[ nPos ] )->GetTxtNode())->GetIndex()
+ <= rEndNd.GetIndex() )
+ {
+ const sal_Int32 nFtnSttIdx = pSrch->GetStart();
+ if( ( pEndCnt && pSttCnt )
+ ? (( &rSttNd.GetNode() == pFtnNd &&
+ pSttCnt->GetIndex() > nFtnSttIdx) ||
+ ( &rEndNd.GetNode() == pFtnNd &&
+ nFtnSttIdx >= pEndCnt->GetIndex() ))
+ : ( &rEndNd.GetNode() == pFtnNd ))
+ {
+ ++nPos; // continue searching
+ }
+ else
+ {
+ // delete it
+ if( bDelFtn )
+ {
+ SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode();
+ SwIndex aIdx( &rTxtNd, nFtnSttIdx );
+ rTxtNd.EraseText( aIdx, 1 );
+ }
+ else
+ {
+ pSrch->DelFrms(0);
+ rFtnArr.erase( rFtnArr.begin() + nPos );
+ if( bSaveFtn )
+ rSaveArr.insert( pSrch );
+ }
+ bUpdateFtn = true;
+ }
+ }
+
+ while( nPos-- && ( pFtnNd = &( pSrch = rFtnArr[ nPos ] )->
+ GetTxtNode())->GetIndex() >= rSttNd.GetIndex() )
+ {
+ const sal_Int32 nFtnSttIdx = pSrch->GetStart();
+ if( !pEndCnt || !pSttCnt ||
+ !( (( &rSttNd.GetNode() == pFtnNd &&
+ pSttCnt->GetIndex() > nFtnSttIdx ) ||
+ ( &rEndNd.GetNode() == pFtnNd &&
+ nFtnSttIdx >= pEndCnt->GetIndex() )) ))
+ {
+ if( bDelFtn )
+ {
+ // delete it
+ SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode();
+ SwIndex aIdx( &rTxtNd, nFtnSttIdx );
+ rTxtNd.EraseText( aIdx, 1 );
+ }
+ else
+ {
+ pSrch->DelFrms(0);
+ rFtnArr.erase( rFtnArr.begin() + nPos );
+ if( bSaveFtn )
+ rSaveArr.insert( pSrch );
+ }
+ bUpdateFtn = true;
+ }
+ }
+ }
+ // When moving from redline section into document content section, e.g.
+ // after loading a document with (delete-)redlines, the footnote array
+ // has to be adjusted... (#i70572)
+ if( bSaveFtn )
+ {
+ SwNodeIndex aIdx( rSttNd );
+ while( aIdx < rEndNd ) // Check the moved section
+ {
+ SwNode* pNode = &aIdx.GetNode();
+ if( pNode->IsTxtNode() ) // Looking for text nodes...
+ {
+ SwpHints *pHints =
+ static_cast<SwTxtNode*>(pNode)->GetpSwpHints();
+ if( pHints && pHints->HasFtn() ) //...with footnotes
+ {
+ bUpdateFtn = true; // Heureka
+ sal_uInt16 nCount = pHints->Count();
+ for( sal_uInt16 i = 0; i < nCount; ++i )
+ {
+ SwTxtAttr *pAttr = pHints->GetTextHint( i );
+ if ( pAttr->Which() == RES_TXTATR_FTN )
+ {
+ rSaveArr.insert( static_cast<SwTxtFtn*>(pAttr) );
+ }
+ }
+ }
+ }
+ ++aIdx;
+ }
+ }
+ return bUpdateFtn;
+ }
+
+ static bool lcl_MayOverwrite( const SwTxtNode *pNode, const sal_Int32 nPos )
+ {
+ sal_Unicode const cChr = pNode->GetTxt()[nPos];
+ switch (cChr)
+ {
+ case CH_TXTATR_BREAKWORD:
+ case CH_TXTATR_INWORD:
+ return !pNode->GetTxtAttrForCharAt(nPos);// how could there be none?
+ case CH_TXT_ATR_FIELDSTART:
+ case CH_TXT_ATR_FIELDEND:
+ case CH_TXT_ATR_FORMELEMENT:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ static void lcl_SkipAttr( const SwTxtNode *pNode, SwIndex &rIdx, sal_Int32 &rStart )
+ {
+ if( !lcl_MayOverwrite( pNode, rStart ) )
+ {
+ // skip all special attributes
+ do {
+ ++rIdx;
+ rStart = rIdx.GetIndex();
+ } while (rStart < pNode->GetTxt().getLength()
+ && !lcl_MayOverwrite(pNode, rStart) );
+ }
+ }
+
+ static bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet, bool bRegExpRplc )
+ {
+ if( bRegExpRplc )
+ {
+ sal_Int32 nPos = 0;
+ const OUString sPara("\\n");
+ for (;;)
+ {
+ nPos = rStr.indexOf( sPara, nPos );
+ if (nPos<0)
+ {
+ break;
+ }
+ // Has this been escaped?
+ if( nPos && '\\' == rStr[nPos-1])
+ {
+ ++nPos;
+ if( nPos >= rStr.getLength() )
+ {
+ break;
+ }
+ }
+ else
+ {
+ rRet = rStr.copy( 0, nPos );
+ rStr = rStr.copy( nPos + sPara.getLength() );
+ return true;
+ }
+ }
+ }
+ rRet = rStr;
+ rStr = OUString();
+ return false;
+ }
+}
+
+namespace //local functions originally from docfmt.cxx
+{
+ #define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
+
+ /// Insert Hints according to content types;
+ // Is used in SwDoc::Insert(..., SwFmtHint &rHt)
+
+ static bool lcl_InsAttr(
+ SwDoc *const pDoc,
+ const SwPaM &rRg,
+ const SfxItemSet& rChgSet,
+ const SetAttrMode nFlags,
+ SwUndoAttr *const pUndo,
+ const bool bExpandCharToPara=false)
+ {
+ // Divide the Sets (for selections in Nodes)
+ const SfxItemSet* pCharSet = 0;
+ const SfxItemSet* pOtherSet = 0;
+ bool bDelete = false;
+ bool bCharAttr = false;
+ bool bOtherAttr = false;
+
+ // Check, if we can work with rChgSet or if we have to create additional SfxItemSets
+ if ( 1 == rChgSet.Count() )
+ {
+ SfxItemIter aIter( rChgSet );
+ const SfxPoolItem* pItem = aIter.FirstItem();
+ if (!IsInvalidItem(pItem))
+ {
+ const sal_uInt16 nWhich = pItem->Which();
+
+ if ( isCHRATR(nWhich) ||
+ (RES_TXTATR_CHARFMT == nWhich) ||
+ (RES_TXTATR_INETFMT == nWhich) ||
+ (RES_TXTATR_AUTOFMT == nWhich) ||
+ (RES_TXTATR_UNKNOWN_CONTAINER == nWhich) )
+ {
+ pCharSet = &rChgSet;
+ bCharAttr = true;
+ }
+
+ if ( isPARATR(nWhich)
+ || isPARATR_LIST(nWhich)
+ || isFRMATR(nWhich)
+ || isGRFATR(nWhich)
+ || isUNKNOWNATR(nWhich)
+ || isDrawingLayerAttribute(nWhich) ) //UUUU
+ {
+ pOtherSet = &rChgSet;
+ bOtherAttr = true;
+ }
+ }
+ }
+
+ // Build new itemset if either
+ // - rChgSet.Count() > 1 or
+ // - The attribute in rChgSet does not belong to one of the above categories
+ if ( !bCharAttr && !bOtherAttr )
+ {
+ SfxItemSet* pTmpCharItemSet = new SfxItemSet( pDoc->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_TXTATR_AUTOFMT, RES_TXTATR_AUTOFMT,
+ RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
+ RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
+ RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
+ 0 );
+
+ SfxItemSet* pTmpOtherItemSet = new SfxItemSet( pDoc->GetAttrPool(),
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_GRFATR_BEGIN, RES_GRFATR_END-1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+
+ //UUUU FillAttribute support
+ XATTR_FILL_FIRST, XATTR_FILL_LAST,
+
+ 0 );
+
+ pTmpCharItemSet->Put( rChgSet );
+ pTmpOtherItemSet->Put( rChgSet );
+
+ pCharSet = pTmpCharItemSet;
+ pOtherSet = pTmpOtherItemSet;
+
+ bDelete = true;
+ }
+
+ SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
+ bool bRet = false;
+ const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
+ SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode();
+
+ if( pNode && pNode->IsTxtNode() )
+ {
+ // #i27615#
+ if (rRg.IsInFrontOfLabel())
+ {
+ SwTxtNode * pTxtNd = pNode->GetTxtNode();
+ SwNumRule * pNumRule = pTxtNd->GetNumRule();
+
+ if ( !pNumRule )
+ {
+ OSL_FAIL( "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." );
+ DELETECHARSETS
+ return false;
+ }
+
+ int nLevel = pTxtNd->GetActualListLevel();
+
+ if (nLevel < 0)
+ nLevel = 0;
+
+ if (nLevel >= MAXLEVEL)
+ nLevel = MAXLEVEL - 1;
+
+ SwNumFmt aNumFmt = pNumRule->Get(static_cast<sal_uInt16>(nLevel));
+ SwCharFmt * pCharFmt =
+ pDoc->FindCharFmtByName(aNumFmt.GetCharFmtName());
+
+ if (pCharFmt)
+ {
+ if (pHistory)
+ pHistory->Add(pCharFmt->GetAttrSet(), *pCharFmt);
+
+ if ( pCharSet )
+ pCharFmt->SetFmtAttr(*pCharSet);
+ }
+
+ DELETECHARSETS
+ return true;
+ }
+
+ const SwIndex& rSt = pStt->nContent;
+
+ // Attributes without an end do not have a range
+ if ( !bCharAttr && !bOtherAttr )
+ {
+ SfxItemSet aTxtSet( pDoc->GetAttrPool(),
+ RES_TXTATR_NOEND_BEGIN, RES_TXTATR_NOEND_END-1 );
+ aTxtSet.Put( rChgSet );
+ if( aTxtSet.Count() )
+ {
+ SwRegHistory history( pNode, *pNode, pHistory );
+ bRet = history.InsertItems(
+ aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet;
+
+ if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
+ && !pDoc->GetRedlineTbl().empty())))
+ {
+ SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
+ pStt->nNode, pStt->nContent.GetIndex() );
+
+ if( pUndo )
+ pUndo->SaveRedlineData( aPam, true );
+
+ if( pDoc->IsRedlineOn() )
+ pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+ else
+ pDoc->SplitRedline( aPam );
+ }
+ }
+ }
+
+ // TextAttributes with an end never expand their range
+ if ( !bCharAttr && !bOtherAttr )
+ {
+ // CharFmt and URL attributes are treated separately!
+ // TEST_TEMP ToDo: AutoFmt!
+ SfxItemSet aTxtSet( pDoc->GetAttrPool(),
+ RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK,
+ RES_TXTATR_META, RES_TXTATR_METAFIELD,
+ RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
+ RES_TXTATR_INPUTFIELD, RES_TXTATR_INPUTFIELD,
+ 0 );
+
+ aTxtSet.Put( rChgSet );
+ if( aTxtSet.Count() )
+ {
+ const sal_Int32 nInsCnt = rSt.GetIndex();
+ const sal_Int32 nEnd = pStt->nNode == pEnd->nNode
+ ? pEnd->nContent.GetIndex()
+ : pNode->Len();
+ SwRegHistory history( pNode, *pNode, pHistory );
+ bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
+ || bRet;
+
+ if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
+ && !pDoc->GetRedlineTbl().empty())))
+ {
+ // Was text content inserted? (RefMark/TOXMarks without an end)
+ bool bTxtIns = nInsCnt != rSt.GetIndex();
+ // Was content inserted or set over the selection?
+ SwPaM aPam( pStt->nNode, bTxtIns ? nInsCnt + 1 : nEnd,
+ pStt->nNode, nInsCnt );
+ if( pUndo )
+ pUndo->SaveRedlineData( aPam, bTxtIns );
+
+ if( pDoc->IsRedlineOn() )
+ pDoc->AppendRedline(
+ new SwRangeRedline(
+ bTxtIns ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ),
+ true);
+ else if( bTxtIns )
+ pDoc->SplitRedline( aPam );
+ }
+ }
+ }
+ }
+
+ // We always have to set the auto flag for PageDescs that are set at the Node!
+ if( pOtherSet && pOtherSet->Count() )
+ {
+ SwTableNode* pTblNd;
+ const SwFmtPageDesc* pDesc;
+ if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PAGEDESC,
+ false, (const SfxPoolItem**)&pDesc ))
+ {
+ if( pNode )
+ {
+ // Set auto flag. Only in the template it's without auto!
+ SwFmtPageDesc aNew( *pDesc );
+
+ // Tables now also know line breaks
+ if( 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
+ 0 != ( pTblNd = pNode->FindTableNode() ) )
+ {
+ SwTableNode* pCurTblNd = pTblNd;
+ while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
+ pTblNd = pCurTblNd;
+
+ // set the table format
+ SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
+ SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
+ pFmt->SetFmtAttr( aNew );
+ bRet = true;
+ }
+ else
+ {
+ SwRegHistory aRegH( pNode, *pNode, pHistory );
+ bRet = pNode->SetAttr( aNew ) || bRet;
+ }
+ }
+
+ // bOtherAttr = true means that pOtherSet == rChgSet. In this case
+ // we know, that there is only one attribute in pOtherSet. We cannot
+ // perform the following operations, instead we return:
+ if ( bOtherAttr )
+ return bRet;
+
+ const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC );
+ if( !pOtherSet->Count() )
+ {
+ DELETECHARSETS
+ return bRet;
+ }
+ }
+
+ // Tables now also know line breaks
+ const SvxFmtBreakItem* pBreak;
+ if( pNode && 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
+ 0 != (pTblNd = pNode->FindTableNode() ) &&
+ SFX_ITEM_SET == pOtherSet->GetItemState( RES_BREAK,
+ false, (const SfxPoolItem**)&pBreak ) )
+ {
+ SwTableNode* pCurTblNd = pTblNd;
+ while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
+ pTblNd = pCurTblNd;
+
+ // set the table format
+ SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
+ SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
+ pFmt->SetFmtAttr( *pBreak );
+ bRet = true;
+
+ // bOtherAttr = true means that pOtherSet == rChgSet. In this case
+ // we know, that there is only one attribute in pOtherSet. We cannot
+ // perform the following operations, instead we return:
+ if ( bOtherAttr )
+ return bRet;
+
+ const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK );
+ if( !pOtherSet->Count() )
+ {
+ DELETECHARSETS
+ return bRet;
+ }
+ }
+
+ {
+ // If we have a PoolNumRule, create it if needed
+ const SwNumRuleItem* pRule;
+ sal_uInt16 nPoolId=0;
+ if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE,
+ false, (const SfxPoolItem**)&pRule ) &&
+ !pDoc->FindNumRulePtr( pRule->GetValue() ) &&
+ USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(),
+ nsSwGetPoolIdFromName::GET_POOLID_NUMRULE )) )
+ pDoc->GetNumRuleFromPool( nPoolId );
+ }
+ }
+
+ if( !rRg.HasMark() ) // no range
+ {
+ if( !pNode )
+ {
+ DELETECHARSETS
+ return bRet;
+ }
+
+ if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
+ {
+ SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode);
+ const SwIndex& rSt = pStt->nContent;
+ sal_Int32 nMkPos, nPtPos = rSt.GetIndex();
+ const OUString& rStr = pTxtNd->GetTxt();
+
+ // Special case: if the Crsr is located within a URL attribute, we take over it's area
+ SwTxtAttr const*const pURLAttr(
+ pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
+ if (pURLAttr && !pURLAttr->GetINetFmt().GetValue().isEmpty())
+ {
+ nMkPos = pURLAttr->GetStart();
+ nPtPos = *pURLAttr->End();
+ }
+ else
+ {
+ Boundary aBndry;
+ if( g_pBreakIt->GetBreakIter().is() )
+ aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ pTxtNd->GetTxt(), nPtPos,
+ g_pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
+ WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
+ sal_True );
+
+ if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
+ {
+ nMkPos = aBndry.startPos;
+ nPtPos = aBndry.endPos;
+ }
+ else
+ nPtPos = nMkPos = rSt.GetIndex();
+ }
+
+ // Remove the overriding attributes from the SwpHintsArray,
+ // if the selection spans across the whole paragraph.
+ // These attributes are inserted as FormatAttributes and
+ // never override the TextAttributes!
+ if( !(nFlags & nsSetAttrMode::SETATTR_DONTREPLACE ) &&
+ pTxtNd->HasHints() && !nMkPos && nPtPos == rStr.getLength())
+ {
+ SwIndex aSt( pTxtNd );
+ if( pHistory )
+ {
+ // Save all attributes for the Undo.
+ SwRegHistory aRHst( *pTxtNd, pHistory );
+ pTxtNd->GetpSwpHints()->Register( &aRHst );
+ pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
+ if( pTxtNd->GetpSwpHints() )
+ pTxtNd->GetpSwpHints()->DeRegister();
+ }
+ else
+ pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
+ }
+
+ // the SwRegHistory inserts the attribute into the TxtNode!
+ SwRegHistory history( pNode, *pNode, pHistory );
+ bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags )
+ || bRet;
+
+ if( pDoc->IsRedlineOn() )
+ {
+ SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
+
+ if( pUndo )
+ pUndo->SaveRedlineData( aPam, false );
+ pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
+ }
+ }
+ if( pOtherSet && pOtherSet->Count() )
+ {
+ SwRegHistory aRegH( pNode, *pNode, pHistory );
+
+ //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
+ // and evtl. correct that item to ensure unique names for that type. This call may
+ // modify/correct entries inside of the given SfxItemSet
+ SfxItemSet aTempLocalCopy(*pOtherSet);
+
+ pDoc->CheckForUniqueItemForLineFillNameOrIndex(aTempLocalCopy);
+ bRet = pNode->SetAttr(aTempLocalCopy) || bRet;
+ }
+
+ DELETECHARSETS
+ return bRet;
+ }
+
+ if( pDoc->IsRedlineOn() && pCharSet && pCharSet->Count() )
+ {
+ if( pUndo )
+ pUndo->SaveRedlineData( rRg, false );
+ pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
+ }
+
+ /* now if range */
+ sal_uLong nNodes = 0;
+
+ SwNodeIndex aSt( pDoc->GetNodes() );
+ SwNodeIndex aEnd( pDoc->GetNodes() );
+ SwIndex aCntEnd( pEnd->nContent );
+
+ if( pNode )
+ {
+ const sal_Int32 nLen = pNode->Len();
+ if( pStt->nNode != pEnd->nNode )
+ aCntEnd.Assign( pNode, nLen );
+
+ if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen )
+ {
+ // the SwRegHistory inserts the attribute into the TxtNode!
+ if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
+ {
+ SwRegHistory history( pNode, *pNode, pHistory );
+ bRet = history.InsertItems(*pCharSet,
+ pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags)
+ || bRet;
+ }
+
+ if( pOtherSet && pOtherSet->Count() )
+ {
+ SwRegHistory aRegH( pNode, *pNode, pHistory );
+ bRet = pNode->SetAttr( *pOtherSet ) || bRet;
+ }
+
+ // Only selection in a Node.
+ if( pStt->nNode == pEnd->nNode )
+ {
+ //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
+ //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
+ //current setting attribute set is a character range properties set and comes from a MS word
+ //binary file, And the setting range include a paragraph end position (0X0D);
+ //More specifications, as such property inside the character range properties set recorded in
+ //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
+ //only dealing the scenario that the char properties set with 1 item inside;
+
+ if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1 )
+ {
+ SwTxtNode* pCurrentNd = pStt->nNode.GetNode().GetTxtNode();
+
+ if (pCurrentNd)
+ {
+ pCurrentNd->TryCharSetExpandToNum(*pCharSet);
+
+ }
+ }
+ DELETECHARSETS
+ return bRet;
+ }
+ ++nNodes;
+ aSt.Assign( pStt->nNode.GetNode(), +1 );
+ }
+ else
+ aSt = pStt->nNode;
+ aCntEnd = pEnd->nContent; // aEnd was changed!
+ }
+ else
+ aSt.Assign( pStt->nNode.GetNode(), +1 );
+
+ // aSt points to the first full Node now
+
+ /*
+ * The selection spans more than one Node.
+ */
+ if( pStt->nNode < pEnd->nNode )
+ {
+ pNode = pEnd->nNode.GetNode().GetCntntNode();
+ if(pNode)
+ {
+ if( aCntEnd.GetIndex() != pNode->Len() )
+ {
+ // the SwRegHistory inserts the attribute into the TxtNode!
+ if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
+ {
+ SwRegHistory history( pNode, *pNode, pHistory );
+ history.InsertItems(*pCharSet,
+ 0, aCntEnd.GetIndex(), nFlags);
+ }
+
+ if( pOtherSet && pOtherSet->Count() )
+ {
+ SwRegHistory aRegH( pNode, *pNode, pHistory );
+ pNode->SetAttr( *pOtherSet );
+ }
+
+ ++nNodes;
+ aEnd = pEnd->nNode;
+ }
+ else
+ aEnd.Assign( pEnd->nNode.GetNode(), +1 );
+ }
+ else
+ aEnd = pEnd->nNode;
+ }
+ else
+ aEnd.Assign( pEnd->nNode.GetNode(), +1 );
+
+ // aEnd points BEHIND the last full node now
+
+ /* Edit the fully selected Nodes. */
+ // Reset all attributes from the set!
+ if( pCharSet && pCharSet->Count() && !( nsSetAttrMode::SETATTR_DONTREPLACE & nFlags ) )
+ {
+ ::sw::DocumentContentOperationsManager::ParaRstFmt aPara( pStt, pEnd, pHistory, 0, pCharSet );
+ pDoc->GetNodes().ForEach( aSt, aEnd, ::sw::DocumentContentOperationsManager::lcl_RstTxtAttr, &aPara );
+ }
+
+ bool bCreateSwpHints = pCharSet && (
+ SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_CHARFMT, false ) ||
+ SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_INETFMT, false ) );
+
+ for(; aSt < aEnd; ++aSt )
+ {
+ pNode = aSt.GetNode().GetCntntNode();
+ if( !pNode )
+ continue;
+
+ SwTxtNode* pTNd = pNode->GetTxtNode();
+ if( pHistory )
+ {
+ SwRegHistory aRegH( pNode, *pNode, pHistory );
+ SwpHints *pSwpHints;
+
+ if( pTNd && pCharSet && pCharSet->Count() )
+ {
+ pSwpHints = bCreateSwpHints ? &pTNd->GetOrCreateSwpHints()
+ : pTNd->GetpSwpHints();
+ if( pSwpHints )
+ pSwpHints->Register( &aRegH );
+
+ pTNd->SetAttr(*pCharSet, 0, pTNd->GetTxt().getLength(), nFlags);
+ if( pSwpHints )
+ pSwpHints->DeRegister();
+ }
+ if( pOtherSet && pOtherSet->Count() )
+ pNode->SetAttr( *pOtherSet );
+ }
+ else
+ {
+ if( pTNd && pCharSet && pCharSet->Count() )
+ pTNd->SetAttr(*pCharSet, 0, pTNd->GetTxt().getLength(), nFlags);
+ if( pOtherSet && pOtherSet->Count() )
+ pNode->SetAttr( *pOtherSet );
+ }
+ ++nNodes;
+ }
+
+ //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
+ //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
+ //current setting attribute set is a character range properties set and comes from a MS word
+ //binary file, And the setting range include a paragraph end position (0X0D);
+ //More specifications, as such property inside the character range properties set recorded in
+ //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
+ //only dealing the scenario that the char properties set with 1 item inside;
+ if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1)
+ {
+ SwPosition aStartPos (*rRg.Start());
+ SwPosition aEndPos (*rRg.End());
+
+ if (aEndPos.nNode.GetNode().GetTxtNode() && aEndPos.nContent != aEndPos.nNode.GetNode().GetTxtNode()->Len())
+ aEndPos.nNode--;
+
+ sal_uLong nStart = aStartPos.nNode.GetIndex();
+ sal_uLong nEnd = aEndPos.nNode.GetIndex();
+ for(; nStart <= nEnd; ++nStart)
+ {
+ SwNode* pNd = pDoc->GetNodes()[ nStart ];
+ if (!pNd || !pNd->IsTxtNode())
+ continue;
+ SwTxtNode *pCurrentNd = (SwTxtNode*)pNd;
+ pCurrentNd->TryCharSetExpandToNum(*pCharSet);
+ }
+ }
+
+ DELETECHARSETS
+ return (nNodes != 0) || bRet;
+ }
+}
+
+namespace sw
+{
+
+DocumentContentOperationsManager::DocumentContentOperationsManager( SwDoc& i_rSwdoc ) : m_rSwdoc( i_rSwdoc )
+{
+}
+
+// Copy an area into this document or into another document
+bool
+DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const
+{
+ const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
+
+ SwDoc* pDoc = rPos.nNode.GetNode().GetDoc();
+ bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
+
+ // Catch if there's no copy to do
+ if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) )
+ return false;
+
+ // Prevent copying in Flys that are anchored in the area
+ if( pDoc == &m_rSwdoc )
+ {
+ // Correct the Start-/EndNode
+ sal_uLong nStt = pStt->nNode.GetIndex(),
+ nEnd = pEnd->nNode.GetIndex(),
+ nDiff = nEnd - nStt +1;
+ SwNode* pNd = m_rSwdoc.GetNodes()[ nStt ];
+ if( pNd->IsCntntNode() && pStt->nContent.GetIndex() )
+ ++nStt, --nDiff;
+ if( (pNd = m_rSwdoc.GetNodes()[ nEnd ])->IsCntntNode() &&
+ ((SwCntntNode*)pNd)->Len() != pEnd->nContent.GetIndex() )
+ --nEnd, --nDiff;
+ if( nDiff &&
+ lcl_ChkFlyFly( pDoc, nStt, nEnd, rPos.nNode.GetIndex() ) )
+ {
+ return false;
+ }
+ }
+
+ SwPaM* pRedlineRange = 0;
+ if( pDoc->IsRedlineOn() ||
+ (!pDoc->IsIgnoreRedline() && !pDoc->GetRedlineTbl().empty() ) )
+ pRedlineRange = new SwPaM( rPos );
+
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+
+ bool bRet = false;
+
+ if( pDoc != &m_rSwdoc )
+ { // ordinary copy
+ bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange );
+ }
+ else if( ! ( *pStt <= rPos && rPos < *pEnd &&
+ ( pStt->nNode != pEnd->nNode ||
+ !pStt->nNode.GetNode().IsTxtNode() )) )
+ {
+ // Copy to a position outside of the area, or copy a single TextNode
+ // Do an ordinary copy
+ bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange );
+ }
+ else
+ {
+ // Copy the area in itself
+ // Special case for handling an area with several nodes,
+ // or a single node that is not a TextNode
+ OSL_ENSURE( &m_rSwdoc == pDoc, " invalid copy branch!" );
+ OSL_FAIL("mst: i thought this could be dead code;"
+ "please tell me what you did to get here!");
+ pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+
+ // Then copy the area to the underlying document area
+ // (with start/end nodes clamped) and move them to
+ // the desired position.
+
+ SwUndoCpyDoc* pUndo = 0;
+ // Save the Undo area
+ SwPaM aPam( rPos );
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ pDoc->GetIDocumentUndoRedo().ClearRedo();
+ pUndo = new SwUndoCpyDoc( aPam );
+ }
+
+ {
+ ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
+ SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection(
+ SwNodeIndex( m_rSwdoc.GetNodes().GetEndOfAutotext() ));
+ aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode();
+ // copy without Frames
+ pDoc->GetDocumentContentOperationsManager().CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 );
+
+ aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext();
+ aPam.SetMark();
+ SwCntntNode* pNode =
+ pDoc->GetNodes().GoPrevious( &aPam.GetMark()->nNode );
+ pNode->MakeEndIndex( &aPam.GetMark()->nContent );
+
+ aPam.GetPoint()->nNode = *aPam.GetNode().StartOfSectionNode();
+ pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode );
+ pNode->MakeStartIndex( &aPam.GetPoint()->nContent );
+ // move to desired position
+ pDoc->getIDocumentContentOperations().MoveRange( aPam, rPos, DOC_MOVEDEFAULT );
+
+ pNode = aPam.GetCntntNode();
+ *aPam.GetPoint() = rPos; // Move the cursor for Undo
+ aPam.SetMark(); // also move the Mark
+ aPam.DeleteMark(); // But don't mark any area
+ pDoc->getIDocumentContentOperations().DeleteSection( pNode ); // Delete the area again
+ }
+
+ // if Undo is enabled, store the insertion range
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ pUndo->SetInsertRange( aPam );
+ pDoc->GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
+ if( pRedlineRange )
+ {
+ pRedlineRange->SetMark();
+ *pRedlineRange->GetPoint() = *aPam.GetPoint();
+ *pRedlineRange->GetMark() = *aPam.GetMark();
+ }
+
+ pDoc->SetModified();
+ bRet = true;
+ }
+
+ pDoc->SetRedlineMode_intern( eOld );
+ if( pRedlineRange )
+ {
+ if( pDoc->IsRedlineOn() )
+ pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pRedlineRange ), true);
+ else
+ pDoc->SplitRedline( *pRedlineRange );
+ delete pRedlineRange;
+ }
+
+ return bRet;
+}
+
+/// Delete a full Section of the NodeArray.
+/// The passed Node is located somewhere in the designated Section.
+void DocumentContentOperationsManager::DeleteSection( SwNode *pNode )
+{
+ assert(pNode && "Didn't pass a Node.");
+
+ SwStartNode* pSttNd = pNode->IsStartNode() ? (SwStartNode*)pNode
+ : pNode->StartOfSectionNode();
+ SwNodeIndex aSttIdx( *pSttNd ), aEndIdx( *pNode->EndOfSectionNode() );
+
+ // delete all Flys, Bookmarks, ...
+ DelFlyInRange( aSttIdx, aEndIdx );
+ m_rSwdoc.DeleteRedline( *pSttNd, true, USHRT_MAX );
+ _DelBookmarks(aSttIdx, aEndIdx);
+
+ {
+ // move all Crsr/StkCrsr/UnoCrsr out of the to-be-deleted area
+ SwNodeIndex aMvStt( aSttIdx, 1 );
+ m_rSwdoc.CorrAbs( aMvStt, aEndIdx, SwPosition( aSttIdx ), true );
+ }
+
+ m_rSwdoc.GetNodes().DelNodes( aSttIdx, aEndIdx.GetIndex() - aSttIdx.GetIndex() + 1 );
+}
+
+bool DocumentContentOperationsManager::DeleteRange( SwPaM & rPam )
+{
+ return lcl_DoWithBreaks( *this, rPam, &DocumentContentOperationsManager::DeleteRangeImpl );
+}
+
+bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam )
+{
+ const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
+ const SwNode* pNd = &rStt.nNode.GetNode();
+ sal_uInt32 nSectDiff = pNd->StartOfSectionNode()->EndOfSectionIndex() -
+ pNd->StartOfSectionIndex();
+ sal_uInt32 nNodeDiff = rEnd.nNode.GetIndex() - rStt.nNode.GetIndex();
+
+ if ( nSectDiff-2 <= nNodeDiff || m_rSwdoc.IsRedlineOn() ||
+ /* #i9185# Prevent getting the node after the end node (see below) */
+ rEnd.nNode.GetIndex() + 1 == m_rSwdoc.GetNodes().Count() )
+ {
+ return false;
+ }
+
+ // Move hard page brakes to the following Node.
+ bool bSavePageBreak = false, bSavePageDesc = false;
+
+ /* #i9185# This whould lead to a segmentation fault if not caught above. */
+ sal_uLong nNextNd = rEnd.nNode.GetIndex() + 1;
+ SwTableNode *const pTblNd = m_rSwdoc.GetNodes()[ nNextNd ]->GetTableNode();
+
+ if( pTblNd && pNd->IsCntntNode() )
+ {
+ SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
+
+ {
+ const SfxPoolItem *pItem;
+ const SfxItemSet* pSet = ((SwCntntNode*)pNd)->GetpSwAttrSet();
+ if( pSet && SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC,
+ false, &pItem ) )
+ {
+ pTableFmt->SetFmtAttr( *pItem );
+ bSavePageDesc = true;
+ }
+
+ if( pSet && SFX_ITEM_SET == pSet->GetItemState( RES_BREAK,
+ false, &pItem ) )
+ {
+ pTableFmt->SetFmtAttr( *pItem );
+ bSavePageBreak = true;
+ }
+ }
+ }
+
+ bool const bDoesUndo = m_rSwdoc.GetIDocumentUndoRedo().DoesUndo();
+ if( bDoesUndo )
+ {
+ if( !rPam.HasMark() )
+ rPam.SetMark();
+ else if( rPam.GetPoint() == &rStt )
+ rPam.Exchange();
+ rPam.GetPoint()->nNode++;
+
+ SwCntntNode *pTmpNode = rPam.GetPoint()->nNode.GetNode().GetCntntNode();
+ rPam.GetPoint()->nContent.Assign( pTmpNode, 0 );
+ bool bGoNext = (0 == pTmpNode);
+ pTmpNode = rPam.GetMark()->nNode.GetNode().GetCntntNode();
+ rPam.GetMark()->nContent.Assign( pTmpNode, 0 );
+
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+
+ SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
+ {
+ SwPosition aTmpPos( *aDelPam.GetPoint() );
+ if( bGoNext )
+ {
+ pTmpNode = m_rSwdoc.GetNodes().GoNext( &aTmpPos.nNode );
+ aTmpPos.nContent.Assign( pTmpNode, 0 );
+ }
+ ::PaMCorrAbs( aDelPam, aTmpPos );
+ }
+
+ SwUndoDelete* pUndo = new SwUndoDelete( aDelPam, true );
+
+ *rPam.GetPoint() = *aDelPam.GetPoint();
+ pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+ else
+ {
+ SwNodeRange aRg( rStt.nNode, rEnd.nNode );
+ if( rPam.GetPoint() != &rEnd )
+ rPam.Exchange();
+
+ // Try to move past the End
+ if( !rPam.Move( fnMoveForward, fnGoNode ) )
+ {
+ // Fair enough, at the Beginning then
+ rPam.Exchange();
+ if( !rPam.Move( fnMoveBackward, fnGoNode ))
+ {
+ OSL_FAIL( "no more Nodes" );
+ return false;
+ }
+ }
+ // move bookmarks, redlines etc.
+ if (aRg.aStart == aRg.aEnd) // only first CorrAbs variant handles this
+ {
+ m_rSwdoc.CorrAbs( aRg.aStart, *rPam.GetPoint(), 0, true );
+ }
+ else
+ {
+ m_rSwdoc.CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), true );
+ }
+
+ // What's with Flys?
+ {
+ // If there are FlyFrames left, delete these too
+ for( sal_uInt16 n = 0; n < m_rSwdoc.GetSpzFrmFmts()->size(); ++n )
+ {
+ SwFrmFmt* pFly = (*m_rSwdoc.GetSpzFrmFmts())[n];
+ const SwFmtAnchor* pAnchor = &pFly->GetAnchor();
+ SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
+ if (pAPos &&
+ ((FLY_AT_PARA == pAnchor->GetAnchorId()) ||
+ (FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
+ aRg.aStart <= pAPos->nNode && pAPos->nNode <= aRg.aEnd )
+ {
+ m_rSwdoc.DelLayoutFmt( pFly );
+ --n;
+ }
+ }
+ }
+
+ SwCntntNode *pTmpNode = rPam.GetBound( true ).nNode.GetNode().GetCntntNode();
+ rPam.GetBound( true ).nContent.Assign( pTmpNode, 0 );
+ pTmpNode = rPam.GetBound( false ).nNode.GetNode().GetCntntNode();
+ rPam.GetBound( false ).nContent.Assign( pTmpNode, 0 );
+ m_rSwdoc.GetNodes().Delete( aRg.aStart, nNodeDiff+1 );
+ }
+ rPam.DeleteMark();
+ m_rSwdoc.SetModified();
+
+ return true;
+}
+
+// #i100466# Add handling of new optional parameter <bForceJoinNext>
+bool DocumentContentOperationsManager::DeleteAndJoin( SwPaM & rPam,
+ const bool bForceJoinNext )
+{
+ if ( lcl_StrLenOverflow( rPam ) )
+ return false;
+
+ return lcl_DoWithBreaks( *this, rPam, (m_rSwdoc.IsRedlineOn())
+ ? &DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl
+ : &DocumentContentOperationsManager::DeleteAndJoinImpl,
+ bForceJoinNext );
+}
+
+// It seems that this is mostly used by SwDoc internals; the only
+// way to call this from the outside seems to be the special case in
+// SwDoc::CopyRange (but I have not managed to actually hit that case).
+bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
+{
+ // nothing moved: return
+ const SwPosition *pStt = rPaM.Start(), *pEnd = rPaM.End();
+ if( !rPaM.HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd))
+ return false;
+
+ // Save the paragraph anchored Flys, so that they can be moved.
+ _SaveFlyArr aSaveFlyArr;
+ _SaveFlyInRange( rPaM, rPos.nNode, aSaveFlyArr, 0 != ( DOC_MOVEALLFLYS & eMvFlags ) );
+
+ // save redlines (if DOC_MOVEREDLINES is used)
+ _SaveRedlines aSaveRedl;
+ if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.GetRedlineTbl().empty() )
+ {
+ lcl_SaveRedlines( rPaM, aSaveRedl );
+
+ // #i17764# unfortunately, code below relies on undos being
+ // in a particular order, and presence of bookmarks
+ // will change this order. Hence, we delete bookmarks
+ // here without undo.
+ ::sw::UndoGuard const undoGuard(m_rSwdoc.GetIDocumentUndoRedo());
+ _DelBookmarks(
+ pStt->nNode,
+ pEnd->nNode,
+ NULL,
+ &pStt->nContent,
+ &pEnd->nContent);
+ }
+
+ bool bUpdateFtn = false;
+ SwFtnIdxs aTmpFntIdx;
+
+ SwUndoMove * pUndoMove = 0;
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+ pUndoMove = new SwUndoMove( rPaM, rPos );
+ pUndoMove->SetMoveRedlines( eMvFlags == DOC_MOVEREDLINES );
+ }
+ else
+ {
+ bUpdateFtn = lcl_SaveFtn( pStt->nNode, pEnd->nNode, rPos.nNode,
+ m_rSwdoc.GetFtnIdxs(), aTmpFntIdx,
+ &pStt->nContent, &pEnd->nContent );
+ }
+
+ bool bSplit = false;
+ SwPaM aSavePam( rPos, rPos );
+
+ // Move the SPoint to the beginning of the range
+ if( rPaM.GetPoint() == pEnd )
+ rPaM.Exchange();
+
+ // If there is a TextNode before and after the Move, create a JoinNext in the EditShell.
+ SwTxtNode* pSrcNd = rPaM.GetPoint()->nNode.GetNode().GetTxtNode();
+ bool bCorrSavePam = pSrcNd && pStt->nNode != pEnd->nNode;
+
+ // If one ore more TextNodes are moved, SwNodes::Move will do a SplitNode.
+ // However, this does not update the cursor. So we create a TextNode to keep
+ // updating the indices. After the Move the Node is optionally deleted.
+ SwTxtNode * pTNd = rPos.nNode.GetNode().GetTxtNode();
+ if( pTNd && rPaM.GetPoint()->nNode != rPaM.GetMark()->nNode &&
+ ( rPos.nContent.GetIndex() || ( pTNd->Len() && bCorrSavePam )) )
+ {
+ bSplit = true;
+ const sal_Int32 nMkCntnt = rPaM.GetMark()->nContent.GetIndex();
+
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save( &m_rSwdoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), SAVEFLY_SPLIT );
+
+ pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos ));
+
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( &m_rSwdoc, rPos.nNode.GetIndex()-1, 0, true );
+
+ // correct the PaM!
+ if( rPos.nNode == rPaM.GetMark()->nNode )
+ {
+ rPaM.GetMark()->nNode = rPos.nNode.GetIndex()-1;
+ rPaM.GetMark()->nContent.Assign( pTNd, nMkCntnt );
+ }
+ }
+
+ // Put back the Pam by one "content"; so that it's always outside of
+ // the manipulated range.
+ // If there's no content anymore, set it to the StartNode (that's
+ // always there).
+ const bool bNullCntnt = !aSavePam.Move( fnMoveBackward, fnGoCntnt );
+ if( bNullCntnt )
+ {
+ aSavePam.GetPoint()->nNode--;
+ }
+
+ // Copy all Bookmarks that are within the Move range into an array,
+ // that saves the position as an offset.
+ ::std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
+ _DelBookmarks(
+ pStt->nNode,
+ pEnd->nNode,
+ &aSaveBkmks,
+ &pStt->nContent,
+ &pEnd->nContent);
+
+ // If there is no range anymore due to the above deletions (e.g. the
+ // footnotes got deleted), it's still a valid Move!
+ if( *rPaM.GetPoint() != *rPaM.GetMark() )
+ {
+ // now do the actual move
+ m_rSwdoc.GetNodes().MoveRange( rPaM, rPos, m_rSwdoc.GetNodes() );
+
+ // after a MoveRange() the Mark is deleted
+ if ( rPaM.HasMark() ) // => no Move occurred!
+ {
+ delete pUndoMove;
+ return false;
+ }
+ }
+ else
+ rPaM.DeleteMark();
+
+ OSL_ENSURE( *aSavePam.GetMark() == rPos ||
+ ( aSavePam.GetMark()->nNode.GetNode().GetCntntNode() == NULL ),
+ "PaM was not moved. Aren't there ContentNodes at the beginning/end?" );
+ *aSavePam.GetMark() = rPos;
+
+ rPaM.SetMark(); // create a Sel. around the new range
+ pTNd = aSavePam.GetNode().GetTxtNode();
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ // correct the SavePam's Content first
+ if( bNullCntnt )
+ {
+ aSavePam.GetPoint()->nContent = 0;
+ }
+
+ // The method SwEditShell::Move() merges the TextNode after the Move,
+ // where the rPaM is located.
+ // If the Content was moved to the back and the SavePam's SPoint is
+ // in the next Node, we have to deal with this when saving the Undo object!
+ SwTxtNode * pPamTxtNd = 0;
+
+ // Is passed to SwUndoMove, which happens when subsequently calling Undo JoinNext.
+ // If it's not possible to call Undo JoinNext here.
+ bool bJoin = bSplit && pTNd;
+ bCorrSavePam = bCorrSavePam &&
+ 0 != ( pPamTxtNd = rPaM.GetNode().GetTxtNode() )
+ && pPamTxtNd->CanJoinNext()
+ && (*rPaM.GetPoint() <= *aSavePam.GetPoint());
+
+ // Do two Nodes have to be joined at the SavePam?
+ if( bJoin && pTNd->CanJoinNext() )
+ {
+ pTNd->JoinNext();
+ // No temporary Index when using &&.
+ // We probably only want to compare the indices.
+ if( bCorrSavePam && rPaM.GetPoint()->nNode.GetIndex()+1 ==
+ aSavePam.GetPoint()->nNode.GetIndex() )
+ {
+ aSavePam.GetPoint()->nContent += pPamTxtNd->Len();
+ }
+ bJoin = false;
+ }
+ else if ( !aSavePam.Move( fnMoveForward, fnGoCntnt ) )
+ {
+ aSavePam.GetPoint()->nNode++;
+ }
+
+ // The newly inserted range is now inbetween SPoint and GetMark.
+ pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(),
+ bJoin, bCorrSavePam );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndoMove );
+ }
+ else
+ {
+ bool bRemove = true;
+ // Do two Nodes have to be joined at the SavePam?
+ if( bSplit && pTNd )
+ {
+ if( pTNd->CanJoinNext())
+ {
+ // Always join next, because <pTNd> has to stay as it is.
+ // A join previous from its next would more or less delete <pTNd>
+ pTNd->JoinNext();
+ bRemove = false;
+ }
+ }
+ if( bNullCntnt )
+ {
+ aSavePam.GetPoint()->nNode++;
+ aSavePam.GetPoint()->nContent.Assign( aSavePam.GetCntntNode(), 0 );
+ }
+ else if( bRemove ) // No move forward after joining with next paragraph
+ {
+ aSavePam.Move( fnMoveForward, fnGoCntnt );
+ }
+ }
+
+ // Insert the Bookmarks back into the Document.
+ *rPaM.GetMark() = *aSavePam.Start();
+ for(
+ ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin();
+ pBkmk != aSaveBkmks.end();
+ ++pBkmk)
+ pBkmk->SetInDoc(
+ &m_rSwdoc,
+ rPaM.GetMark()->nNode,
+ &rPaM.GetMark()->nContent);
+ *rPaM.GetPoint() = *aSavePam.End();
+
+ // Move the Flys to the new position.
+ _RestFlyInRange( aSaveFlyArr, rPaM.Start()->nNode, &(rPos.nNode) );
+
+ // restore redlines (if DOC_MOVEREDLINES is used)
+ if( !aSaveRedl.empty() )
+ {
+ lcl_RestoreRedlines( &m_rSwdoc, *aSavePam.Start(), aSaveRedl );
+ }
+
+ if( bUpdateFtn )
+ {
+ if( !aTmpFntIdx.empty() )
+ {
+ m_rSwdoc.GetFtnIdxs().insert( aTmpFntIdx );
+ aTmpFntIdx.clear();
+ }
+
+ m_rSwdoc.GetFtnIdxs().UpdateAllFtn();
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos,
+ SwMoveFlags eMvFlags )
+{
+ // Moves all Nodes to the new position.
+ // Bookmarks are moved too (currently without Undo support).
+
+ // If footnotes are being moved to the special section, remove them now.
+
+ // Or else delete the Frames for all footnotes that are being moved
+ // and have it rebuild after the Move (footnotes can change pages).
+ // Additionally we have to correct the FtnIdx array's sorting.
+ bool bUpdateFtn = false;
+ SwFtnIdxs aTmpFntIdx;
+
+ SwUndoMove* pUndo = 0;
+ if ((DOC_CREATEUNDOOBJ & eMvFlags ) && m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ pUndo = new SwUndoMove( &m_rSwdoc, rRange, rPos );
+ }
+ else
+ {
+ bUpdateFtn = lcl_SaveFtn( rRange.aStart, rRange.aEnd, rPos,
+ m_rSwdoc.GetFtnIdxs(), aTmpFntIdx );
+ }
+
+ _SaveRedlines aSaveRedl;
+ std::vector<SwRangeRedline*> aSavRedlInsPosArr;
+ if( DOC_MOVEREDLINES & eMvFlags && !m_rSwdoc.GetRedlineTbl().empty() )
+ {
+ lcl_SaveRedlines( rRange, aSaveRedl );
+
+ // Find all RedLines that end at the InsPos.
+ // These have to be moved back to the "old" position after the Move.
+ sal_uInt16 nRedlPos = m_rSwdoc.GetRedlinePos( rPos.GetNode(), USHRT_MAX );
+ if( USHRT_MAX != nRedlPos )
+ {
+ const SwPosition *pRStt, *pREnd;
+ do {
+ SwRangeRedline* pTmp = m_rSwdoc.GetRedlineTbl()[ nRedlPos ];
+ pRStt = pTmp->Start();
+ pREnd = pTmp->End();
+ if( pREnd->nNode == rPos && pRStt->nNode < rPos )
+ {
+ aSavRedlInsPosArr.push_back( pTmp );
+ }
+ } while( pRStt->nNode < rPos && ++nRedlPos < m_rSwdoc.GetRedlineTbl().size());
+ }
+ }
+
+ // Copy all Bookmarks that are within the Move range into an array
+ // that stores all references to positions as an offset.
+ // The final mapping happens after the Move.
+ ::std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
+ _DelBookmarks(rRange.aStart, rRange.aEnd, &aSaveBkmks);
+
+ // Save the paragraph-bound Flys, so that they can be moved.
+ _SaveFlyArr aSaveFlyArr;
+ if( !m_rSwdoc.GetSpzFrmFmts()->empty() )
+ _SaveFlyInRange( rRange, aSaveFlyArr );
+
+ // Set it to before the Position, so that it cannot be moved further.
+ SwNodeIndex aIdx( rPos, -1 );
+
+ SwNodeIndex* pSaveInsPos = 0;
+ if( pUndo )
+ pSaveInsPos = new SwNodeIndex( rRange.aStart, -1 );
+
+ // move the Nodes
+ bool bNoDelFrms = 0 != (DOC_NO_DELFRMS & eMvFlags);
+ if( m_rSwdoc.GetNodes()._MoveNodes( rRange, m_rSwdoc.GetNodes(), rPos, !bNoDelFrms ) )
+ {
+ ++aIdx; // again back to old position
+ if( pSaveInsPos )
+ ++(*pSaveInsPos);
+ }
+ else
+ {
+ aIdx = rRange.aStart;
+ delete pUndo, pUndo = 0;
+ }
+
+ // move the Flys to the new position
+ if( !aSaveFlyArr.empty() )
+ _RestFlyInRange( aSaveFlyArr, aIdx, NULL );
+
+ // Add the Bookmarks back to the Document
+ for(
+ ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin();
+ pBkmk != aSaveBkmks.end();
+ ++pBkmk)
+ pBkmk->SetInDoc(&m_rSwdoc, aIdx);
+
+ if( !aSavRedlInsPosArr.empty() )
+ {
+ SwNode* pNewNd = &aIdx.GetNode();
+ for( sal_uInt16 n = 0; n < aSavRedlInsPosArr.size(); ++n )
+ {
+ SwRangeRedline* pTmp = aSavRedlInsPosArr[ n ];
+ if( m_rSwdoc.GetRedlineTbl().Contains( pTmp ) )
+ {
+ SwPosition* pEnd = pTmp->End();
+ pEnd->nNode = aIdx;
+ pEnd->nContent.Assign( pNewNd->GetCntntNode(), 0 );
+ }
+ }
+ }
+
+ if( !aSaveRedl.empty() )
+ lcl_RestoreRedlines( &m_rSwdoc, aIdx.GetIndex(), aSaveRedl );
+
+ if( pUndo )
+ {
+ pUndo->SetDestRange( aIdx, rPos, *pSaveInsPos );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+
+ delete pSaveInsPos;
+
+ if( bUpdateFtn )
+ {
+ if( !aTmpFntIdx.empty() )
+ {
+ m_rSwdoc.GetFtnIdxs().insert( aTmpFntIdx );
+ aTmpFntIdx.clear();
+ }
+
+ m_rSwdoc.GetFtnIdxs().UpdateAllFtn();
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+bool DocumentContentOperationsManager::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
+{
+ SwNodeIndex aIdx( rPaM.Start()->nNode );
+ bool bJoinTxt = aIdx.GetNode().IsTxtNode();
+ bool bOneNode = rPaM.GetPoint()->nNode == rPaM.GetMark()->nNode;
+ aIdx--; // in front of the move area!
+
+ bool bRet = MoveRange( rPaM, rPos, eMvFlags );
+ if( bRet && !bOneNode )
+ {
+ if( bJoinTxt )
+ ++aIdx;
+ SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode();
+ SwNodeIndex aNxtIdx( aIdx );
+ if( pTxtNd && pTxtNd->CanJoinNext( &aNxtIdx ) )
+ {
+ { // Block so SwIndex into node is deleted before Join
+ m_rSwdoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTxtNd,
+ pTxtNd->GetTxt().getLength()) ), 0, true );
+ }
+ pTxtNd->JoinNext();
+ }
+ }
+ return bRet;
+}
+
+bool DocumentContentOperationsManager::Overwrite( const SwPaM &rRg, const OUString &rStr )
+{
+ SwPosition& rPt = *(SwPosition*)rRg.GetPoint();
+ if( m_rSwdoc.GetAutoCorrExceptWord() ) // Add to AutoCorrect
+ {
+ if( 1 == rStr.getLength() )
+ m_rSwdoc.GetAutoCorrExceptWord()->CheckChar( rPt, rStr[ 0 ] );
+ m_rSwdoc.DeleteAutoCorrExceptWord();
+ }
+
+ SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode();
+ if (!pNode || rStr.getLength() > pNode->GetSpaceLeft()) // worst case: no erase
+ {
+ return false;
+ }
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called
+ }
+
+ sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints()
+ ? pNode->GetpSwpHints()->Count() : 0;
+ SwDataChanged aTmp( rRg );
+ SwIndex& rIdx = rPt.nContent;
+ sal_Int32 nStart = 0;
+
+ bool bOldExpFlg = pNode->IsIgnoreDontExpand();
+ pNode->SetIgnoreDontExpand( true );
+
+ for( sal_Int32 nCnt = 0; nCnt < rStr.getLength(); ++nCnt )
+ {
+ // start behind the characters (to fix the attributes!)
+ nStart = rIdx.GetIndex();
+ if (nStart < pNode->GetTxt().getLength())
+ {
+ lcl_SkipAttr( pNode, rIdx, nStart );
+ }
+ sal_Unicode c = rStr[ nCnt ];
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ bool bMerged(false);
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesGroupUndo())
+ {
+ SwUndo *const pUndo = m_rSwdoc.GetUndoManager().GetLastUndo();
+ SwUndoOverwrite *const pUndoOW(
+ dynamic_cast<SwUndoOverwrite *>(pUndo) );
+ if (pUndoOW)
+ {
+ // if CanGrouping() returns true it's already merged
+ bMerged = pUndoOW->CanGrouping( &m_rSwdoc, rPt, c );
+ }
+ }
+ if (!bMerged)
+ {
+ SwUndo *const pUndoOW( new SwUndoOverwrite(&m_rSwdoc, rPt, c) );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndoOW);
+ }
+ }
+ else
+ {
+ // start behind the characters (to fix the attributes!)
+ if (nStart < pNode->GetTxt().getLength())
+ ++rIdx;
+ pNode->InsertText( OUString(c), rIdx, INS_EMPTYEXPAND );
+ if( nStart+1 < rIdx.GetIndex() )
+ {
+ rIdx = nStart;
+ pNode->EraseText( rIdx, 1 );
+ ++rIdx;
+ }
+ }
+ }
+ pNode->SetIgnoreDontExpand( bOldExpFlg );
+
+ sal_uInt16 nNewAttrCnt = pNode->GetpSwpHints()
+ ? pNode->GetpSwpHints()->Count() : 0;
+ if( nOldAttrCnt != nNewAttrCnt )
+ {
+ SwUpdateAttr aHint(
+ 0,
+ 0,
+ 0);
+
+ pNode->ModifyBroadcast( 0, &aHint, TYPE( SwCrsrShell ) );
+ }
+
+ if (!m_rSwdoc.GetIDocumentUndoRedo().DoesUndo() &&
+ !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty())
+ {
+ SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
+ m_rSwdoc.DeleteRedline( aPam, true, USHRT_MAX );
+ }
+ else if( m_rSwdoc.IsRedlineOn() )
+ {
+ // FIXME: this redline is WRONG: there is no DELETE, and the skipped
+ // characters are also included in aPam
+ SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
+ m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+bool DocumentContentOperationsManager::InsertString( const SwPaM &rRg, const OUString &rStr,
+ const enum InsertFlags nInsertMode )
+{
+ // fetching DoesUndo is surprisingly expensive
+ bool bDoesUndo = m_rSwdoc.GetIDocumentUndoRedo().DoesUndo();
+ if (bDoesUndo)
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called!
+
+ const SwPosition& rPos = *rRg.GetPoint();
+
+ if( m_rSwdoc.GetAutoCorrExceptWord() ) // add to auto correction
+ {
+ if( 1 == rStr.getLength() && m_rSwdoc.GetAutoCorrExceptWord()->IsDeleted() )
+ {
+ m_rSwdoc.GetAutoCorrExceptWord()->CheckChar( rPos, rStr[ 0 ] );
+ }
+ m_rSwdoc.DeleteAutoCorrExceptWord();
+ }
+
+ SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode();
+ if(!pNode)
+ return false;
+
+ SwDataChanged aTmp( rRg );
+
+ if (!bDoesUndo || !m_rSwdoc.GetIDocumentUndoRedo().DoesGroupUndo())
+ {
+ OUString const ins(pNode->InsertText(rStr, rPos.nContent, nInsertMode));
+ if (bDoesUndo)
+ {
+ SwUndoInsert * const pUndo( new SwUndoInsert(rPos.nNode,
+ rPos.nContent.GetIndex(), ins.getLength(), nInsertMode));
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+ }
+ else
+ { // if Undo and grouping is enabled, everything changes!
+ SwUndoInsert * pUndo = NULL;
+
+ // don't group the start if hints at the start should be expanded
+ if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND))
+ {
+ SwUndo *const pLastUndo = m_rSwdoc.GetUndoManager().GetLastUndo();
+ SwUndoInsert *const pUndoInsert(
+ dynamic_cast<SwUndoInsert *>(pLastUndo) );
+ if (pUndoInsert && pUndoInsert->CanGrouping(rPos))
+ {
+ pUndo = pUndoInsert;
+ }
+ }
+
+ CharClass const& rCC = GetAppCharClass();
+ sal_Int32 nInsPos = rPos.nContent.GetIndex();
+
+ if (!pUndo)
+ {
+ pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode,
+ !rCC.isLetterNumeric( rStr, 0 ) );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndo );
+ }
+
+ OUString const ins(pNode->InsertText(rStr, rPos.nContent, nInsertMode));
+
+ for (sal_Int32 i = 0; i < ins.getLength(); ++i)
+ {
+ nInsPos++;
+ // if CanGrouping() returns true, everything has already been done
+ if (!pUndo->CanGrouping(ins[i]))
+ {
+ pUndo = new SwUndoInsert(rPos.nNode, nInsPos, 1, nInsertMode,
+ !rCC.isLetterNumeric(ins, i));
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndo );
+ }
+ }
+ }
+
+ // To-Do - add 'SwExtraRedlineTbl' also ?
+ if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+ {
+ SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
+ rPos.nNode, rPos.nContent.GetIndex());
+ if( m_rSwdoc.IsRedlineOn() )
+ {
+ m_rSwdoc.AppendRedline(
+ new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+ }
+ else
+ {
+ m_rSwdoc.SplitRedline( aPam );
+ }
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+void DocumentContentOperationsManager::TransliterateText(
+ const SwPaM& rPaM,
+ utl::TransliterationWrapper& rTrans )
+{
+ SwUndoTransliterate *const pUndo = (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ ? new SwUndoTransliterate( rPaM, rTrans )
+ : 0;
+
+ const SwPosition* pStt = rPaM.Start(),
+ * pEnd = rPaM.End();
+ sal_uLong nSttNd = pStt->nNode.GetIndex(),
+ nEndNd = pEnd->nNode.GetIndex();
+ sal_Int32 nSttCnt = pStt->nContent.GetIndex();
+ sal_Int32 nEndCnt = pEnd->nContent.GetIndex();
+
+ SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
+ if( pStt == pEnd && pTNd ) // no selection?
+ {
+ // set current word as 'area of effect'
+
+ Boundary aBndry;
+ if( g_pBreakIt->GetBreakIter().is() )
+ aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
+ pTNd->GetTxt(), nSttCnt,
+ g_pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ),
+ WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
+ sal_True );
+
+ if( aBndry.startPos < nSttCnt && nSttCnt < aBndry.endPos )
+ {
+ nSttCnt = aBndry.startPos;
+ nEndCnt = aBndry.endPos;
+ }
+ }
+
+ if( nSttNd != nEndNd ) // is more than one text node involved?
+ {
+ // iterate over all effected text nodes, the first and the last one
+ // may be incomplete because the selection starts and/or ends there
+
+ SwNodeIndex aIdx( pStt->nNode );
+ if( nSttCnt )
+ {
+ ++aIdx;
+ if( pTNd )
+ pTNd->TransliterateText(
+ rTrans, nSttCnt, pTNd->GetTxt().getLength(), pUndo);
+ }
+
+ for( ; aIdx.GetIndex() < nEndNd; ++aIdx )
+ {
+ pTNd = aIdx.GetNode().GetTxtNode();
+ if (pTNd)
+ {
+ pTNd->TransliterateText(
+ rTrans, 0, pTNd->GetTxt().getLength(), pUndo);
+ }
+ }
+
+ if( nEndCnt && 0 != ( pTNd = pEnd->nNode.GetNode().GetTxtNode() ))
+ pTNd->TransliterateText( rTrans, 0, nEndCnt, pUndo );
+ }
+ else if( pTNd && nSttCnt < nEndCnt )
+ pTNd->TransliterateText( rTrans, nSttCnt, nEndCnt, pUndo );
+
+ if( pUndo )
+ {
+ if( pUndo->HasData() )
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+ else
+ delete pUndo;
+ }
+ m_rSwdoc.SetModified();
+}
+
+SwFlyFrmFmt* DocumentContentOperationsManager::Insert( const SwPaM &rRg,
+ const OUString& rGrfName,
+ const OUString& rFltName,
+ const Graphic* pGraphic,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* pFrmFmt )
+{
+ if( !pFrmFmt )
+ pFrmFmt = m_rSwdoc.GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
+ SwGrfNode* pSwGrfNode = m_rSwdoc.GetNodes().MakeGrfNode(
+ SwNodeIndex( m_rSwdoc.GetNodes().GetEndOfAutotext() ),
+ rGrfName, rFltName, pGraphic,
+ m_rSwdoc.GetDfltGrfFmtColl() );
+ SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
+ pFlyAttrSet, pGrfAttrSet, pFrmFmt );
+ return pSwFlyFrmFmt;
+}
+
+SwFlyFrmFmt* DocumentContentOperationsManager::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* pFrmFmt )
+{
+ if( !pFrmFmt )
+ pFrmFmt = m_rSwdoc.GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
+ SwGrfNode* pSwGrfNode = m_rSwdoc.GetNodes().MakeGrfNode(
+ SwNodeIndex( m_rSwdoc.GetNodes().GetEndOfAutotext() ),
+ rGrfObj, m_rSwdoc.GetDfltGrfFmtColl() );
+ SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
+ pFlyAttrSet, pGrfAttrSet, pFrmFmt );
+ return pSwFlyFrmFmt;
+}
+
+SwFlyFrmFmt* DocumentContentOperationsManager::Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* pFrmFmt )
+{
+ if( !pFrmFmt )
+ {
+ sal_uInt16 nId = RES_POOLFRM_OLE;
+ SvGlobalName aClassName( xObj->getClassID() );
+ if (SotExchange::IsMath(aClassName))
+ nId = RES_POOLFRM_FORMEL;
+
+ pFrmFmt = m_rSwdoc.GetFrmFmtFromPool( nId );
+ }
+ return _InsNoTxtNode( *rRg.GetPoint(), m_rSwdoc.GetNodes().MakeOLENode(
+ SwNodeIndex( m_rSwdoc.GetNodes().GetEndOfAutotext() ),
+ xObj,
+ m_rSwdoc.GetDfltGrfFmtColl() ),
+ pFlyAttrSet, pGrfAttrSet,
+ pFrmFmt );
+}
+
+SwFlyFrmFmt* DocumentContentOperationsManager::InsertOLE(const SwPaM &rRg, const OUString& rObjName,
+ sal_Int64 nAspect,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* pFrmFmt )
+{
+ if( !pFrmFmt )
+ pFrmFmt = m_rSwdoc.GetFrmFmtFromPool( RES_POOLFRM_OLE );
+
+ return _InsNoTxtNode( *rRg.GetPoint(),
+ m_rSwdoc.GetNodes().MakeOLENode(
+ SwNodeIndex( m_rSwdoc.GetNodes().GetEndOfAutotext() ),
+ rObjName,
+ nAspect,
+ m_rSwdoc.GetDfltGrfFmtColl(),
+ 0 ),
+ pFlyAttrSet, pGrfAttrSet,
+ pFrmFmt );
+}
+
+void DocumentContentOperationsManager::ReRead( SwPaM& rPam, const OUString& rGrfName,
+ const OUString& rFltName, const Graphic* pGraphic,
+ const GraphicObject* pGrafObj )
+{
+ SwGrfNode *pGrfNd;
+ if( ( !rPam.HasMark()
+ || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
+ && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
+ {
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd));
+ }
+
+ // Because we don't know if we can mirror the graphic, the mirror attribute is always reset
+ if( RES_MIRROR_GRAPH_DONT != pGrfNd->GetSwAttrSet().
+ GetMirrorGrf().GetValue() )
+ pGrfNd->SetAttr( SwMirrorGrf() );
+
+ pGrfNd->ReRead( rGrfName, rFltName, pGraphic, pGrafObj, true );
+ m_rSwdoc.SetModified();
+ }
+}
+
+// Insert drawing object, which has to be already inserted in the DrawModel
+SwDrawFrmFmt* DocumentContentOperationsManager::InsertDrawObj(
+ const SwPaM &rRg,
+ SdrObject& rDrawObj,
+ const SfxItemSet& rFlyAttrSet )
+{
+ SwDrawFrmFmt* pFmt = m_rSwdoc.MakeDrawFrmFmt( OUString(), m_rSwdoc.GetDfltFrmFmt() );
+
+ const SwFmtAnchor* pAnchor = 0;
+ rFlyAttrSet.GetItemState( RES_ANCHOR, false, (const SfxPoolItem**) &pAnchor );
+ pFmt->SetFmtAttr( rFlyAttrSet );
+
+ // Didn't set the Anchor yet?
+ // DrawObjecte must never end up in the Header/Footer!
+ RndStdIds eAnchorId = pAnchor != NULL ? pAnchor->GetAnchorId() : pFmt->GetAnchor().GetAnchorId();
+ const bool bIsAtCntnt = (FLY_AT_PAGE != eAnchorId);
+
+ const SwNodeIndex* pChkIdx = 0;
+ if ( pAnchor == NULL )
+ {
+ pChkIdx = &rRg.GetPoint()->nNode;
+ }
+ else if ( bIsAtCntnt )
+ {
+ pChkIdx =
+ pAnchor->GetCntntAnchor() ? &pAnchor->GetCntntAnchor()->nNode : &rRg.GetPoint()->nNode;
+ }
+
+ // allow drawing objects in header/footer, but control objects aren't allowed in header/footer.
+ if( pChkIdx != NULL
+ && ::CheckControlLayer( &rDrawObj )
+ && m_rSwdoc.IsInHeaderFooter( *pChkIdx ) )
+ {
+ // apply at-page anchor format
+ eAnchorId = FLY_AT_PAGE;
+ pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId ) );
+ }
+ else if( pAnchor == NULL
+ || ( bIsAtCntnt
+ && pAnchor->GetCntntAnchor() == NULL ) )
+ {
+ // apply anchor format
+ SwFmtAnchor aAnch( pAnchor != NULL ? *pAnchor : pFmt->GetAnchor() );
+ eAnchorId = aAnch.GetAnchorId();
+ if ( eAnchorId == FLY_AT_FLY )
+ {
+ SwPosition aPos( *rRg.GetNode().FindFlyStartNode() );
+ aAnch.SetAnchor( &aPos );
+ }
+ else
+ {
+ aAnch.SetAnchor( rRg.GetPoint() );
+ if ( eAnchorId == FLY_AT_PAGE )
+ {
+ eAnchorId = rDrawObj.ISA( SdrUnoObj ) ? FLY_AS_CHAR : FLY_AT_PARA;
+ aAnch.SetType( eAnchorId );
+ }
+ }
+ pFmt->SetFmtAttr( aAnch );
+ }
+
+ // insert text attribute for as-character anchored drawing object
+ if ( eAnchorId == FLY_AS_CHAR )
+ {
+ bool bAnchorAtPageAsFallback = true;
+ const SwFmtAnchor& rDrawObjAnchorFmt = pFmt->GetAnchor();
+ if ( rDrawObjAnchorFmt.GetCntntAnchor() != NULL )
+ {
+ SwTxtNode* pAnchorTxtNode =
+ rDrawObjAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
+ if ( pAnchorTxtNode != NULL )
+ {
+ const sal_Int32 nStt = rDrawObjAnchorFmt.GetCntntAnchor()->nContent.GetIndex();
+ SwFmtFlyCnt aFmt( pFmt );
+ pAnchorTxtNode->InsertItem( aFmt, nStt, nStt );
+ bAnchorAtPageAsFallback = false;
+ }
+ }
+
+ if ( bAnchorAtPageAsFallback )
+ {
+ OSL_ENSURE( false, "DocumentContentOperationsManager::InsertDrawObj(..) - missing content anchor for as-character anchored drawing object --> anchor at-page" );
+ pFmt->SetFmtAttr( SwFmtAnchor( FLY_AT_PAGE ) );
+ }
+ }
+
+ SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj );
+
+ // Create Frames if necessary
+ if( m_rSwdoc.GetCurrentViewShell() )
+ {
+ // create layout representation
+ pFmt->MakeFrms();
+ // #i42319# - follow-up of #i35635#
+ // move object to visible layer
+ // #i79391#
+ if ( pContact->GetAnchorFrm() )
+ {
+ pContact->MoveObjToVisibleLayer( &rDrawObj );
+ }
+ }
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( new SwUndoInsLayFmt(pFmt, 0, 0) );
+ }
+
+ m_rSwdoc.SetModified();
+ return pFmt;
+}
+
+bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool bChkTableStart )
+{
+ SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode();
+ if(0 == pNode)
+ return false;
+
+ {
+ // BUG 26675: Send DataChanged before deleting, so that we notice which objects are in scope.
+ // After that they can be before/after the position.
+ SwDataChanged aTmp( &m_rSwdoc, rPos );
+ }
+
+ SwUndoSplitNode* pUndo = 0;
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+ // insert the Undo object (currently only for TextNode)
+ if( pNode->IsTxtNode() )
+ {
+ pUndo = new SwUndoSplitNode( &m_rSwdoc, rPos, bChkTableStart );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndo);
+ }
+ }
+
+ // Update the rsid of the old and the new node unless
+ // the old node is split at the beginning or at the end
+ SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
+ const sal_Int32 nPos = rPos.nContent.GetIndex();
+ if( pTxtNode && nPos && nPos != pTxtNode->Len() )
+ {
+ m_rSwdoc.UpdateParRsid( pTxtNode );
+ }
+
+ //JP 28.01.97: Special case for SplitNode at table start:
+ // If it is at the beginning of a Doc/Fly/Footer/... or right at after a table
+ // then insert a paragraph before it.
+ if( bChkTableStart && !rPos.nContent.GetIndex() && pNode->IsTxtNode() )
+ {
+ sal_uLong nPrevPos = rPos.nNode.GetIndex() - 1;
+ const SwTableNode* pTblNd;
+ const SwNode* pNd = m_rSwdoc.GetNodes()[ nPrevPos ];
+ if( pNd->IsStartNode() &&
+ SwTableBoxStartNode == ((SwStartNode*)pNd)->GetStartNodeType() &&
+ 0 != ( pTblNd = m_rSwdoc.GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
+ ((( pNd = m_rSwdoc.GetNodes()[ --nPrevPos ])->IsStartNode() &&
+ SwTableBoxStartNode != ((SwStartNode*)pNd)->GetStartNodeType() )
+ || ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() )
+ || pNd->IsCntntNode() ))
+ {
+ if( pNd->IsCntntNode() )
+ {
+ //JP 30.04.99 Bug 65660:
+ // There are no page breaks outside of the normal body area,
+ // so this is not a valid condition to insert a paragraph.
+ if( nPrevPos < m_rSwdoc.GetNodes().GetEndOfExtras().GetIndex() )
+ pNd = 0;
+ else
+ {
+ // Only if the table has page breaks!
+ const SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
+ if( SFX_ITEM_SET != pFrmFmt->GetItemState(RES_PAGEDESC, false) &&
+ SFX_ITEM_SET != pFrmFmt->GetItemState( RES_BREAK, false ) )
+ pNd = 0;
+ }
+ }
+
+ if( pNd )
+ {
+ SwTxtNode* pTxtNd = m_rSwdoc.GetNodes().MakeTxtNode(
+ SwNodeIndex( *pTblNd ),
+ m_rSwdoc.GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
+ if( pTxtNd )
+ {
+ ((SwPosition&)rPos).nNode = pTblNd->GetIndex()-1;
+ ((SwPosition&)rPos).nContent.Assign( pTxtNd, 0 );
+
+ // only add page breaks/styles to the body area
+ if( nPrevPos > m_rSwdoc.GetNodes().GetEndOfExtras().GetIndex() )
+ {
+ SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
+ const SfxPoolItem *pItem;
+ if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_PAGEDESC,
+ false, &pItem ) )
+ {
+ pTxtNd->SetAttr( *pItem );
+ pFrmFmt->ResetFmtAttr( RES_PAGEDESC );
+ }
+ if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK,
+ false, &pItem ) )
+ {
+ pTxtNd->SetAttr( *pItem );
+ pFrmFmt->ResetFmtAttr( RES_BREAK );
+ }
+ }
+
+ if( pUndo )
+ pUndo->SetTblFlag();
+ m_rSwdoc.SetModified();
+ return true;
+ }
+ }
+ }
+ }
+
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save( &m_rSwdoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), SAVEFLY_SPLIT );
+ // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
+ OSL_ENSURE(pNode->IsTxtNode(), "splitting non-text node?");
+ pNode = pNode->SplitCntntNode( rPos );
+ if (pNode)
+ {
+ // move all bookmarks, TOXMarks, FlyAtCnt
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( &m_rSwdoc, rPos.nNode.GetIndex()-1, 0, true );
+
+ // To-Do - add 'SwExtraRedlineTbl' also ?
+ if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+ {
+ SwPaM aPam( rPos );
+ aPam.SetMark();
+ aPam.Move( fnMoveBackward );
+ if( m_rSwdoc.IsRedlineOn() )
+ m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+ else
+ m_rSwdoc.SplitRedline( aPam );
+ }
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+bool DocumentContentOperationsManager::AppendTxtNode( SwPosition& rPos )
+{
+ // create new node before EndOfContent
+ SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode();
+ if( !pCurNode )
+ {
+ // so then one can be created!
+ SwNodeIndex aIdx( rPos.nNode, 1 );
+ pCurNode = m_rSwdoc.GetNodes().MakeTxtNode( aIdx,
+ m_rSwdoc.GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
+ }
+ else
+ pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos );
+
+ rPos.nNode++;
+ rPos.nContent.Assign( pCurNode, 0 );
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) );
+ }
+
+ // To-Do - add 'SwExtraRedlineTbl' also ?
+ if( m_rSwdoc.IsRedlineOn() || (!m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() ))
+ {
+ SwPaM aPam( rPos );
+ aPam.SetMark();
+ aPam.Move( fnMoveBackward );
+ if( m_rSwdoc.IsRedlineOn() )
+ m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
+ else
+ m_rSwdoc.SplitRedline( aPam );
+ }
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+bool DocumentContentOperationsManager::ReplaceRange( SwPaM& rPam, const OUString& rStr,
+ const bool bRegExReplace )
+{
+ // unfortunately replace works slightly differently from delete,
+ // so we cannot use lcl_DoWithBreaks here...
+
+ ::std::vector<sal_Int32> Breaks;
+
+ SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
+ aPam.Normalize(false);
+ if (aPam.GetPoint()->nNode != aPam.GetMark()->nNode)
+ {
+ aPam.Move(fnMoveBackward);
+ }
+ OSL_ENSURE((aPam.GetPoint()->nNode == aPam.GetMark()->nNode), "invalid pam?");
+
+ lcl_CalcBreaks(Breaks, aPam);
+
+ while (!Breaks.empty() // skip over prefix of dummy chars
+ && (aPam.GetMark()->nContent.GetIndex() == *Breaks.begin()) )
+ {
+ // skip!
+ ++aPam.GetMark()->nContent; // always in bounds if Breaks valid
+ Breaks.erase(Breaks.begin());
+ }
+ *rPam.Start() = *aPam.GetMark(); // update start of original pam w/ prefix
+
+ if (!Breaks.size())
+ {
+ // park aPam somewhere so it does not point to node that is deleted
+ aPam.DeleteMark();
+ *aPam.GetPoint() = SwPosition(m_rSwdoc.GetNodes().GetEndOfContent());
+ return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam!
+ }
+
+ // Deletion must be split into several parts if the text node
+ // contains a text attribute with end and with dummy character
+ // and the selection does not contain the text attribute completely,
+ // but overlaps its start (left), where the dummy character is.
+
+ bool bRet( true );
+ // iterate from end to start, to avoid invalidating the offsets!
+ ::std::vector<sal_Int32>::reverse_iterator iter( Breaks.rbegin() );
+ OSL_ENSURE(aPam.GetPoint() == aPam.End(), "wrong!");
+ SwPosition & rEnd( *aPam.End() );
+ SwPosition & rStart( *aPam.Start() );
+
+ // set end of temp pam to original end (undo Move backward above)
+ rEnd = *rPam.End();
+ // after first deletion, rEnd will point into the original text node again!
+
+ while (iter != Breaks.rend())
+ {
+ rStart.nContent = *iter + 1;
+ if (rEnd.nContent != rStart.nContent) // check if part is empty
+ {
+ bRet &= (m_rSwdoc.IsRedlineOn())
+ ? DeleteAndJoinWithRedlineImpl(aPam)
+ : DeleteAndJoinImpl(aPam, false);
+ }
+ rEnd.nContent = *iter;
+ ++iter;
+ }
+
+ rStart = *rPam.Start(); // set to original start
+ OSL_ENSURE(rEnd.nContent > rStart.nContent, "replace part empty!");
+ if (rEnd.nContent > rStart.nContent) // check if part is empty
+ {
+ bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace);
+ }
+
+ rPam = aPam; // update original pam (is this required?)
+
+ return bRet;
+}
+
+///Add a para for the char attribute exp...
+bool DocumentContentOperationsManager::InsertPoolItem(
+ const SwPaM &rRg,
+ const SfxPoolItem &rHt,
+ const SetAttrMode nFlags,
+ const bool bExpandCharToPara)
+{
+ SwDataChanged aTmp( rRg );
+ SwUndoAttr* pUndoAttr = 0;
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+ pUndoAttr = new SwUndoAttr( rRg, rHt, nFlags );
+ }
+
+ SfxItemSet aSet( m_rSwdoc.GetAttrPool(), rHt.Which(), rHt.Which() );
+ aSet.Put( rHt );
+ const bool bRet = lcl_InsAttr( &m_rSwdoc, rRg, aSet, nFlags, pUndoAttr, bExpandCharToPara );
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
+ }
+
+ if( bRet )
+ {
+ m_rSwdoc.SetModified();
+ }
+ return bRet;
+}
+
+bool DocumentContentOperationsManager::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet,
+ const SetAttrMode nFlags )
+{
+ SwDataChanged aTmp( rRg );
+ SwUndoAttr* pUndoAttr = 0;
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+ pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags );
+ }
+
+ bool bRet = lcl_InsAttr( &m_rSwdoc, rRg, rSet, nFlags, pUndoAttr );
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
+ }
+
+ if( bRet )
+ m_rSwdoc.SetModified();
+ return bRet;
+}
+
+void DocumentContentOperationsManager::RemoveLeadingWhiteSpace(const SwPosition & rPos )
+{
+ const SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
+ if ( pTNd )
+ {
+ const OUString& rTxt = pTNd->GetTxt();
+ sal_Int32 nIdx = 0;
+ while (nIdx < rTxt.getLength())
+ {
+ sal_Unicode const cCh = rTxt[nIdx];
+ if (('\t' != cCh) && (' ' != cCh))
+ {
+ break;
+ }
+ ++nIdx;
+ }
+
+ if ( nIdx > 0 )
+ {
+ SwPaM aPam(rPos);
+ aPam.GetPoint()->nContent = 0;
+ aPam.SetMark();
+ aPam.GetMark()->nContent = nIdx;
+ DeleteRange( aPam );
+ }
+ }
+}
+
+// Copy method from SwDoc - "copy Flys in Flys"
+void DocumentContentOperationsManager::CopyWithFlyInFly(
+ const SwNodeRange& rRg,
+ const sal_Int32 nEndContentIndex,
+ const SwNodeIndex& rInsPos,
+ const SwPaM* pCopiedPaM,
+ const bool bMakeNewFrms,
+ const bool bDelRedlines,
+ const bool bCopyFlyAtFly ) const
+{
+ SwDoc* pDest = rInsPos.GetNode().GetDoc();
+
+ _SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 );
+
+ SwNodeIndex aSavePos( rInsPos, -1 );
+ bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
+ m_rSwdoc.GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, true );
+ ++aSavePos;
+ if( bEndIsEqualEndPos )
+ ((SwNodeIndex&)rRg.aEnd) = aSavePos;
+
+ aRedlRest.Restore();
+
+#if OSL_DEBUG_LEVEL > 0
+ {
+ //JP 17.06.99: Bug 66973 - check count only if the selection is in
+ // the same section or there's no section, because sections that are
+ // not fully selected are not copied.
+ const SwSectionNode* pSSectNd = rRg.aStart.GetNode().FindSectionNode();
+ SwNodeIndex aTmpI( rRg.aEnd, -1 );
+ const SwSectionNode* pESectNd = aTmpI.GetNode().FindSectionNode();
+ if( pSSectNd == pESectNd &&
+ !rRg.aStart.GetNode().IsSectionNode() &&
+ !aTmpI.GetNode().IsEndNode() )
+ {
+ OSL_ENSURE( rInsPos.GetIndex() - aSavePos.GetIndex() ==
+ rRg.aEnd.GetIndex() - rRg.aStart.GetIndex(),
+ "An insufficient number of nodes were copied!" );
+ }
+ }
+#endif
+
+ {
+ ::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo());
+ CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
+ }
+
+ SwNodeRange aCpyRange( aSavePos, rInsPos );
+
+ // Also copy all bookmarks
+ if( m_rSwdoc.getIDocumentMarkAccess()->getAllMarksCount() )
+ {
+ SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
+ SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd );
+
+ lcl_CopyBookmarks(
+ pCopiedPaM != NULL ? *pCopiedPaM : aRgTmp,
+ aCpyTmp );
+ }
+
+ if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() ))
+ lcl_DeleteRedlines( rRg, aCpyRange );
+
+ pDest->GetNodes()._DelDummyNodes( aCpyRange );
+}
+
+void DocumentContentOperationsManager::CopyFlyInFlyImpl(
+ const SwNodeRange& rRg,
+ const sal_Int32 nEndContentIndex,
+ const SwNodeIndex& rStartIdx,
+ const bool bCopyFlyAtFly ) const
+{
+ // First collect all Flys, sort them according to their ordering number,
+ // and then only copy them. This maintains the ordering numbers (which are only
+ // managed in the DrawModel).
+ SwDoc *const pDest = rStartIdx.GetNode().GetDoc();
+ ::std::set< _ZSortFly > aSet;
+ sal_uInt16 nArrLen = m_rSwdoc.GetSpzFrmFmts()->size();
+
+ SwTextBoxHelper::SavedLink aOldTextBoxes;
+ SwTextBoxHelper::saveLinks(*m_rSwdoc.GetSpzFrmFmts(), aOldTextBoxes);
+ SwTextBoxHelper::SavedContent aOldContent;
+
+ for ( sal_uInt16 n = 0; n < nArrLen; ++n )
+ {
+ SwFrmFmt* pFmt = (*m_rSwdoc.GetSpzFrmFmts())[n];
+ SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
+ SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
+ bool bAtCntnt = (pAnchor->GetAnchorId() == FLY_AT_PARA);
+ if ( pAPos &&
+ ( bAtCntnt ||
+ (pAnchor->GetAnchorId() == FLY_AT_FLY) ||
+ (pAnchor->GetAnchorId() == FLY_AT_CHAR)) &&
+ (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() )
+ ? rRg.aStart <= pAPos->nNode.GetIndex() + 1
+ : ( m_rSwdoc.IsRedlineMove()
+ ? rRg.aStart < pAPos->nNode
+ : rRg.aStart <= pAPos->nNode )) &&
+ pAPos->nNode <= rRg.aEnd )
+ {
+ //frames at the last source node are not always copied:
+ //- if the node is empty and is the last node of the document or a table cell
+ // or a text frame then tey have to be copied
+ //- if the content index in this node is > 0 then paragph and frame bound objects are copied
+ //- to-character bound objects are copied if their index is <= nEndContentIndex
+ bool bAdd = false;
+ if( pAPos->nNode < rRg.aEnd )
+ bAdd = true;
+ if (!bAdd && !m_rSwdoc.IsRedlineMove()) // fdo#40599: not for redline move
+ {
+ bool bEmptyNode = false;
+ bool bLastNode = false;
+ // is the node empty?
+ const SwNodes& rNodes = pAPos->nNode.GetNodes();
+ SwTxtNode* pTxtNode;
+ if( 0 != ( pTxtNode = pAPos->nNode.GetNode().GetTxtNode() ))
+ {
+ bEmptyNode = pTxtNode->GetTxt().isEmpty();
+ if( bEmptyNode )
+ {
+ //last node information is only necessary to know for the last TextNode
+ SwNodeIndex aTmp( pAPos->nNode );
+ ++aTmp;//goto next node
+ while (aTmp.GetNode().IsEndNode())
+ {
+ if( aTmp == rNodes.GetEndOfContent().GetIndex() )
+ {
+ bLastNode = true;
+ break;
+ }
+ ++aTmp;
+ }
+ }
+ }
+ bAdd = bLastNode && bEmptyNode;
+ if( !bAdd )
+ {
+ if( bAtCntnt )
+ bAdd = nEndContentIndex > 0;
+ else
+ bAdd = pAPos->nContent <= nEndContentIndex;
+ }
+ }
+ if( bAdd )
+ {
+ // Make sure draw formats don't refer to content, so that such
+ // content can be removed without problems.
+ SwTextBoxHelper::resetLink(pFmt, aOldContent);
+ aSet.insert( _ZSortFly( pFmt, pAnchor, nArrLen + aSet.size() ));
+ }
+ }
+ }
+
+ // Store all copied (and also the newly created) frames in another array.
+ // They are stored as matching the originals, so that we will be later
+ // able to build the chains accordingly.
+ ::std::vector< SwFrmFmt* > aVecSwFrmFmt;
+ ::std::set< _ZSortFly >::const_iterator it=aSet.begin();
+
+ while (it != aSet.end())
+ {
+ // #i59964#
+ // correct determination of new anchor position
+ SwFmtAnchor aAnchor( *(*it).GetAnchor() );
+ SwPosition* pNewPos = (SwPosition*)aAnchor.GetCntntAnchor();
+ // for at-paragraph and at-character anchored objects the new anchor
+ // position can *not* be determined by the difference of the current
+ // anchor position to the start of the copied range, because not
+ // complete selected sections in the copied range aren't copied - see
+ // method <SwNodes::_CopyNodes(..)>.
+ // Thus, the new anchor position in the destination document is found
+ // by counting the text nodes.
+ if ((aAnchor.GetAnchorId() == FLY_AT_PARA) ||
+ (aAnchor.GetAnchorId() == FLY_AT_CHAR) )
+ {
+ // First, determine number of anchor text node in the copied range.
+ // Note: The anchor text node *have* to be inside the copied range.
+ sal_uLong nAnchorTxtNdNumInRange( 0L );
+ bool bAnchorTxtNdFound( false );
+ SwNodeIndex aIdx( rRg.aStart );
+ while ( !bAnchorTxtNdFound && aIdx <= rRg.aEnd )
+ {
+ if ( aIdx.GetNode().IsTxtNode() )
+ {
+ ++nAnchorTxtNdNumInRange;
+ bAnchorTxtNdFound = aAnchor.GetCntntAnchor()->nNode == aIdx;
+ }
+
+ ++aIdx;
+ }
+ if ( !bAnchorTxtNdFound )
+ {
+ // This case can *not* happen, but to be robust take the first
+ // text node in the destination document.
+ OSL_FAIL( "<SwDoc::_CopyFlyInFly(..)> - anchor text node in copied range not found" );
+ nAnchorTxtNdNumInRange = 1;
+ }
+ // Second, search corresponding text node in destination document
+ // by counting forward from start insert position <rStartIdx> the
+ // determined number of text nodes.
+ aIdx = rStartIdx;
+ SwNodeIndex aAnchorNdIdx( rStartIdx );
+ const SwNode& aEndOfContentNd =
+ aIdx.GetNode().GetNodes().GetEndOfContent();
+ while ( nAnchorTxtNdNumInRange > 0 &&
+ &(aIdx.GetNode()) != &aEndOfContentNd )
+ {
+ if ( aIdx.GetNode().IsTxtNode() )
+ {
+ --nAnchorTxtNdNumInRange;
+ aAnchorNdIdx = aIdx;
+ }
+
+ ++aIdx;
+ }
+ if ( !aAnchorNdIdx.GetNode().IsTxtNode() )
+ {
+ // This case can *not* happen, but to be robust take the first
+ // text node in the destination document.
+ OSL_FAIL( "<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" );
+ aAnchorNdIdx = rStartIdx;
+ while ( !aAnchorNdIdx.GetNode().IsTxtNode() )
+ {
+ ++aAnchorNdIdx;
+ }
+ }
+ // apply found anchor text node as new anchor position
+ pNewPos->nNode = aAnchorNdIdx;
+ }
+ else
+ {
+ long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex();
+ SwNodeIndex aIdx( rStartIdx, nOffset );
+ pNewPos->nNode = aIdx;
+ }
+ // Set the character bound Flys back at the original character
+ if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) &&
+ pNewPos->nNode.GetNode().IsTxtNode() )
+ {
+ pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(),
+ pNewPos->nContent.GetIndex() );
+ }
+ else
+ {
+ pNewPos->nContent.Assign( 0, 0 );
+ }
+
+ // Check recursion: copy content in its own frame, then don't copy it.
+ bool bMakeCpy = true;
+ if( pDest == &m_rSwdoc )
+ {
+ const SwFmtCntnt& rCntnt = (*it).GetFmt()->GetCntnt();
+ const SwStartNode* pSNd;
+ if( rCntnt.GetCntntIdx() &&
+ 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) &&
+ pSNd->GetIndex() < rStartIdx.GetIndex() &&
+ rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() )
+ {
+ bMakeCpy = false;
+ aSet.erase (it++);
+ continue;
+ }
+ }
+
+ // Copy the format and set the new anchor
+ if( bMakeCpy )
+ aVecSwFrmFmt.push_back( pDest->CopyLayoutFmt( *(*it).GetFmt(),
+ aAnchor, false, true ) );
+ ++it;
+ }
+
+ // Rebuild as much as possible of all chains that are available in the original,
+ OSL_ENSURE( aSet.size() == aVecSwFrmFmt.size(), "Missing new Flys" );
+ if ( aSet.size() == aVecSwFrmFmt.size() )
+ {
+ size_t n = 0;
+ for (::std::set< _ZSortFly >::const_iterator nIt=aSet.begin() ; nIt != aSet.end(); ++nIt, ++n )
+ {
+ const SwFrmFmt *pFmtN = (*nIt).GetFmt();
+ const SwFmtChain &rChain = pFmtN->GetChain();
+ int nCnt = int(0 != rChain.GetPrev());
+ nCnt += rChain.GetNext() ? 1: 0;
+ size_t k = 0;
+ for (::std::set< _ZSortFly >::const_iterator kIt=aSet.begin() ; kIt != aSet.end(); ++kIt, ++k )
+ {
+ const SwFrmFmt *pFmtK = (*kIt).GetFmt();
+ if ( rChain.GetPrev() == pFmtK )
+ {
+ ::lcl_ChainFmts( static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]),
+ static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]) );
+ --nCnt;
+ }
+ else if ( rChain.GetNext() == pFmtK )
+ {
+ ::lcl_ChainFmts( static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]),
+ static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]) );
+ --nCnt;
+ }
+ }
+ }
+
+ // Re-create content property of draw formats, knowing how old shapes
+ // were paired with old fly formats (aOldTextBoxes) and that aSet is
+ // parallel with aVecSwFrmFmt.
+ SwTextBoxHelper::restoreLinks(aSet, aVecSwFrmFmt, aOldTextBoxes, aOldContent);
+ }
+}
+
+/*
+ * Reset the text's hard formatting
+ */
+/** @params pArgs contains the document's ChrFmtTable
+ * Is need for selections at the beginning/end and with no SSelection.
+ */
+bool DocumentContentOperationsManager::lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs )
+{
+ ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
+ SwTxtNode * pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
+ if( pTxtNode && pTxtNode->GetpSwpHints() )
+ {
+ SwIndex aSt( pTxtNode, 0 );
+ sal_Int32 nEnd = pTxtNode->Len();
+
+ if( &pPara->pSttNd->nNode.GetNode() == pTxtNode &&
+ pPara->pSttNd->nContent.GetIndex() )
+ aSt = pPara->pSttNd->nContent.GetIndex();
+
+ if( &pPara->pEndNd->nNode.GetNode() == rpNd )
+ nEnd = pPara->pEndNd->nContent.GetIndex();
+
+ if( pPara->pHistory )
+ {
+ // Save all attributes for the Undo.
+ SwRegHistory aRHst( *pTxtNode, pPara->pHistory );
+ pTxtNode->GetpSwpHints()->Register( &aRHst );
+ pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
+ pPara->pDelSet, pPara->bInclRefToxMark );
+ if( pTxtNode->GetpSwpHints() )
+ pTxtNode->GetpSwpHints()->DeRegister();
+ }
+ else
+ pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
+ pPara->pDelSet, pPara->bInclRefToxMark );
+ }
+ return true;
+}
+
+DocumentContentOperationsManager::~DocumentContentOperationsManager()
+{
+}
+//Private methods
+
+bool DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool )
+{
+ OSL_ENSURE( m_rSwdoc.IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" );
+
+ {
+ SwUndoRedlineDelete* pUndo = 0;
+ RedlineMode_t eOld = m_rSwdoc.GetRedlineMode();
+ m_rSwdoc.checkRedlining( eOld );
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+
+ /* please don't translate -- for cultural reasons this comment is protected
+ until the redline implementation is finally fixed some day */
+ //JP 06.01.98: MUSS noch optimiert werden!!!
+ m_rSwdoc.SetRedlineMode(
+ (RedlineMode_t) ( nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) );
+
+ m_rSwdoc.GetIDocumentUndoRedo().StartUndo( UNDO_DELETE, NULL );
+ pUndo = new SwUndoRedlineDelete( rPam, UNDO_DELETE );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( pUndo );
+ }
+
+ if ( *rPam.GetPoint() != *rPam.GetMark() )
+ m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, rPam ), true );
+ m_rSwdoc.SetModified();
+
+ if ( pUndo )
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().EndUndo( UNDO_EMPTY, NULL );
+ // ??? why the hell is the AppendUndo not below the
+ // CanGrouping, so this hideous cleanup wouldn't be necessary?
+ // bah, this is redlining, probably changing this would break it...
+ if ( m_rSwdoc.GetIDocumentUndoRedo().DoesGroupUndo() )
+ {
+ SwUndo * const pLastUndo( m_rSwdoc.GetUndoManager().GetLastUndo() );
+ SwUndoRedlineDelete * const pUndoRedlineDel( dynamic_cast< SwUndoRedlineDelete* >( pLastUndo ) );
+ if ( pUndoRedlineDel )
+ {
+ bool const bMerged = pUndoRedlineDel->CanGrouping( *pUndo );
+ if ( bMerged )
+ {
+ ::sw::UndoGuard const undoGuard( m_rSwdoc.GetIDocumentUndoRedo() );
+ SwUndo const* const pDeleted = m_rSwdoc.GetUndoManager().RemoveLastUndo();
+ OSL_ENSURE( pDeleted == pUndo, "DeleteAndJoinWithRedlineImpl: "
+ "undo removed is not undo inserted?" );
+ delete pDeleted;
+ }
+ }
+ }
+ //JP 06.01.98: MUSS noch optimiert werden!!!
+ m_rSwdoc.SetRedlineMode( eOld );
+ }
+ return true;
+ }
+}
+
+bool DocumentContentOperationsManager::DeleteAndJoinImpl( SwPaM & rPam,
+ const bool bForceJoinNext )
+{
+ bool bJoinTxt, bJoinPrev;
+ ::sw_GetJoinFlags( rPam, bJoinTxt, bJoinPrev );
+ // #i100466#
+ if ( bForceJoinNext )
+ {
+ bJoinPrev = false;
+ }
+
+ {
+ bool const bSuccess( DeleteRangeImpl( rPam ) );
+ if (!bSuccess)
+ return false;
+ }
+
+ if( bJoinTxt )
+ {
+ ::sw_JoinText( rPam, bJoinPrev );
+ }
+
+ return true;
+}
+
+bool DocumentContentOperationsManager::DeleteRangeImpl(SwPaM & rPam, const bool)
+{
+ // Move all cursors out of the deleted range, but first copy the
+ // passed PaM, because it could be a cursor that would be moved!
+ SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
+ ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() );
+
+ bool const bSuccess( DeleteRangeImplImpl( aDelPam ) );
+ if (bSuccess)
+ { // now copy position from temp copy to given PaM
+ *rPam.GetPoint() = *aDelPam.GetPoint();
+ }
+
+ return bSuccess;
+}
+
+bool DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam)
+{
+ SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End();
+
+ if( !rPam.HasMark() || *pStt >= *pEnd )
+ return false;
+
+ if( m_rSwdoc.GetAutoCorrExceptWord() )
+ {
+ // if necessary the saved Word for the exception
+ if( m_rSwdoc.GetAutoCorrExceptWord()->IsDeleted() || pStt->nNode != pEnd->nNode ||
+ pStt->nContent.GetIndex() + 1 != pEnd->nContent.GetIndex() ||
+ !m_rSwdoc.GetAutoCorrExceptWord()->CheckDelChar( *pStt ))
+ { m_rSwdoc.DeleteAutoCorrExceptWord(); }
+ }
+
+ {
+ // Delete all empty TextHints at the Mark's position
+ SwTxtNode* pTxtNd = rPam.GetMark()->nNode.GetNode().GetTxtNode();
+ SwpHints* pHts;
+ if( pTxtNd && 0 != ( pHts = pTxtNd->GetpSwpHints()) && pHts->Count() )
+ {
+ const sal_Int32 *pEndIdx;
+ const sal_Int32 nMkCntPos = rPam.GetMark()->nContent.GetIndex();
+ for( sal_uInt16 n = pHts->Count(); n; )
+ {
+ const SwTxtAttr* pAttr = (*pHts)[ --n ];
+ if( nMkCntPos > pAttr->GetStart() )
+ break;
+
+ if( nMkCntPos == pAttr->GetStart() &&
+ 0 != (pEndIdx = pAttr->End()) &&
+ *pEndIdx == pAttr->GetStart() )
+ pTxtNd->DestroyAttr( pHts->Cut( n ) );
+ }
+ }
+ }
+
+ {
+ // Send DataChanged before deletion, so that we still know
+ // which objects are in the range.
+ // Afterwards they could be before/after the Position.
+ SwDataChanged aTmp( rPam );
+ }
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().ClearRedo();
+ bool bMerged(false);
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesGroupUndo())
+ {
+ SwUndo *const pLastUndo( m_rSwdoc.GetUndoManager().GetLastUndo() );
+ SwUndoDelete *const pUndoDelete(
+ dynamic_cast<SwUndoDelete *>(pLastUndo) );
+ if (pUndoDelete)
+ {
+ bMerged = pUndoDelete->CanGrouping( &m_rSwdoc, rPam );
+ // if CanGrouping() returns true it's already merged
+ }
+ }
+ if (!bMerged)
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo( new SwUndoDelete( rPam ) );
+ }
+
+ m_rSwdoc.SetModified();
+
+ return true;
+ }
+
+ if( !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() )
+ m_rSwdoc.DeleteRedline( rPam, true, USHRT_MAX );
+
+ // Delete and move all "Flys at the paragraph", which are within the Selection
+ DelFlyInRange(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
+ _DelBookmarks(
+ pStt->nNode,
+ pEnd->nNode,
+ NULL,
+ &pStt->nContent,
+ &pEnd->nContent);
+
+ SwNodeIndex aSttIdx( pStt->nNode );
+ SwCntntNode * pCNd = aSttIdx.GetNode().GetCntntNode();
+
+ do { // middle checked loop!
+ if( pCNd )
+ {
+ SwTxtNode * pStartTxtNode( pCNd->GetTxtNode() );
+ if ( pStartTxtNode )
+ {
+ // now move the Content to the new Node
+ bool bOneNd = pStt->nNode == pEnd->nNode;
+ const sal_Int32 nLen = ( bOneNd ? pEnd->nContent.GetIndex()
+ : pCNd->Len() )
+ - pStt->nContent.GetIndex();
+
+ // Don't call again, if already empty
+ if( nLen )
+ {
+ pStartTxtNode->EraseText( pStt->nContent, nLen );
+
+ if( !pStartTxtNode->Len() )
+ {
+ // METADATA: remove reference if empty (consider node deleted)
+ pStartTxtNode->RemoveMetadataReference();
+ }
+ }
+
+ if( bOneNd ) // that's it
+ break;
+
+ ++aSttIdx;
+ }
+ else
+ {
+ // So that there are no indices left registered when deleted,
+ // we remove a SwPaM from the Content here.
+ pStt->nContent.Assign( 0, 0 );
+ }
+ }
+
+ pCNd = pEnd->nNode.GetNode().GetCntntNode();
+ if( pCNd )
+ {
+ SwTxtNode * pEndTxtNode( pCNd->GetTxtNode() );
+ if( pEndTxtNode )
+ {
+ // if already empty, don't call again
+ if( pEnd->nContent.GetIndex() )
+ {
+ SwIndex aIdx( pCNd, 0 );
+ pEndTxtNode->EraseText( aIdx, pEnd->nContent.GetIndex() );
+
+ if( !pEndTxtNode->Len() )
+ {
+ // METADATA: remove reference if empty (consider node deleted)
+ pEndTxtNode->RemoveMetadataReference();
+ }
+ }
+ }
+ else
+ {
+ // So that there are no indices left registered when deleted,
+ // we remove a SwPaM from the Content here.
+ pEnd->nContent.Assign( 0, 0 );
+ }
+ }
+
+ // if the end is not a content node, delete it as well
+ sal_uInt32 nEnde = pEnd->nNode.GetIndex();
+ if( pCNd == NULL )
+ nEnde++;
+
+ if( aSttIdx != nEnde )
+ {
+ // delete the Nodes into the NodesArary
+ m_rSwdoc.GetNodes().Delete( aSttIdx, nEnde - aSttIdx.GetIndex() );
+ }
+
+ // If the Node that contained the Cursor has been deleted,
+ // the Content has to be assigned to the current Content.
+ pStt->nContent.Assign( pStt->nNode.GetNode().GetCntntNode(),
+ pStt->nContent.GetIndex() );
+
+ // If we deleted across Node boundaries we have to correct the PaM,
+ // because they are in different Nodes now.
+ // Also, the Selection is revoked.
+ *pEnd = *pStt;
+ rPam.DeleteMark();
+
+ } while( false );
+
+ if( !m_rSwdoc.IsIgnoreRedline() && !m_rSwdoc.GetRedlineTbl().empty() )
+ m_rSwdoc.CompressRedlines();
+ m_rSwdoc.SetModified();
+
+ return true;
+}
+
+// It's possible to call Replace with a PaM that spans 2 paragraphs:
+// search with regex for "$", then replace _all_
+bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUString& rStr,
+ const bool bRegExReplace )
+{
+ if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() )
+ return false;
+
+ bool bJoinTxt, bJoinPrev;
+ ::sw_GetJoinFlags( rPam, bJoinTxt, bJoinPrev );
+
+ {
+ // Create a copy of the Cursor in order to move all Pams from
+ // the other views out of the deletion range.
+ // Except for itself!
+ SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
+ ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() );
+
+ SwPosition *pStt = (SwPosition*)aDelPam.Start(),
+ *pEnd = (SwPosition*)aDelPam.End();
+ OSL_ENSURE( pStt->nNode == pEnd->nNode ||
+ ( pStt->nNode.GetIndex() + 1 == pEnd->nNode.GetIndex() &&
+ !pEnd->nContent.GetIndex() ),
+ "invalid range: Point and Mark on different nodes" );
+ bool bOneNode = pStt->nNode == pEnd->nNode;
+
+ // Own Undo?
+ OUString sRepl( rStr );
+ SwTxtNode* pTxtNd = pStt->nNode.GetNode().GetTxtNode();
+ sal_Int32 nStt = pStt->nContent.GetIndex();
+ sal_Int32 nEnd = bOneNode ? pEnd->nContent.GetIndex()
+ : pTxtNd->GetTxt().getLength();
+
+ SwDataChanged aTmp( aDelPam );
+
+ if( m_rSwdoc.IsRedlineOn() )
+ {
+ RedlineMode_t eOld = m_rSwdoc.GetRedlineMode();
+ m_rSwdoc.checkRedlining(eOld);
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ m_rSwdoc.GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
+
+ // If any Redline will change (split!) the node
+ const ::sw::mark::IMark* pBkmk = m_rSwdoc.getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
+
+ //JP 06.01.98: MUSS noch optimiert werden!!!
+ m_rSwdoc.SetRedlineMode(
+ (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
+
+ *aDelPam.GetPoint() = pBkmk->GetMarkPos();
+ if(pBkmk->IsExpanded())
+ *aDelPam.GetMark() = pBkmk->GetOtherMarkPos();
+ m_rSwdoc.getIDocumentMarkAccess()->deleteMark(pBkmk);
+ pStt = aDelPam.Start();
+ pTxtNd = pStt->nNode.GetNode().GetTxtNode();
+ nStt = pStt->nContent.GetIndex();
+ }
+
+ if( !sRepl.isEmpty() )
+ {
+ // Apply the first character's attributes to the ReplaceText
+ SfxItemSet aSet( m_rSwdoc.GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1,
+ RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+ 0 );
+ pTxtNd->GetAttr( aSet, nStt+1, nStt+1 );
+
+ aSet.ClearItem( RES_TXTATR_REFMARK );
+ aSet.ClearItem( RES_TXTATR_TOXMARK );
+ aSet.ClearItem( RES_TXTATR_CJK_RUBY );
+ aSet.ClearItem( RES_TXTATR_INETFMT );
+ aSet.ClearItem( RES_TXTATR_META );
+ aSet.ClearItem( RES_TXTATR_METAFIELD );
+
+ if( aDelPam.GetPoint() != aDelPam.End() )
+ aDelPam.Exchange();
+
+ // Remember the End
+ SwNodeIndex aPtNd( aDelPam.GetPoint()->nNode, -1 );
+ const sal_Int32 nPtCnt = aDelPam.GetPoint()->nContent.GetIndex();
+
+ bool bFirst = true;
+ OUString sIns;
+ while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
+ {
+ InsertString( aDelPam, sIns );
+ if( bFirst )
+ {
+ SwNodeIndex aMkNd( aDelPam.GetMark()->nNode, -1 );
+ const sal_Int32 nMkCnt = aDelPam.GetMark()->nContent.GetIndex();
+
+ SplitNode( *aDelPam.GetPoint(), false );
+
+ ++aMkNd;
+ aDelPam.GetMark()->nNode = aMkNd;
+ aDelPam.GetMark()->nContent.Assign(
+ aMkNd.GetNode().GetCntntNode(), nMkCnt );
+ bFirst = false;
+ }
+ else
+ SplitNode( *aDelPam.GetPoint(), false );
+ }
+ if( !sIns.isEmpty() )
+ {
+ InsertString( aDelPam, sIns );
+ }
+
+ SwPaM aTmpRange( *aDelPam.GetPoint() );
+ aTmpRange.SetMark();
+
+ ++aPtNd;
+ aDelPam.GetPoint()->nNode = aPtNd;
+ aDelPam.GetPoint()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
+ nPtCnt);
+ *aTmpRange.GetMark() = *aDelPam.GetPoint();
+
+ m_rSwdoc.RstTxtAttrs( aTmpRange );
+ InsertItemSet( aTmpRange, aSet, 0 );
+ }
+
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwUndo *const pUndoRD =
+ new SwUndoRedlineDelete( aDelPam, UNDO_REPLACE );
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndoRD);
+ }
+ m_rSwdoc.AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, aDelPam ), true);
+
+ *rPam.GetMark() = *aDelPam.GetMark();
+ if (m_rSwdoc.GetIDocumentUndoRedo().DoesUndo())
+ {
+ *aDelPam.GetPoint() = *rPam.GetPoint();
+ m_rSwdoc.GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
+
+ // If any Redline will change (split!) the node
+ const ::sw::mark::IMark* pBkmk = m_rSwdoc.getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
+
+ SwIndex& rIdx = aDelPam.GetPoint()->nContent;
+ rIdx.Assign( 0, 0 );
+ aDelPam.GetMark()->nContent = rIdx;
+ rPam.GetPoint()->nNode = 0;
+ rPam.GetPoint()->nContent = rIdx;
+ *rPam.GetMark() = *rPam.GetPoint();
+ //JP 06.01.98: MUSS noch optimiert werden!!!
+ m_rSwdoc.SetRedlineMode( eOld );
+
+ *rPam.GetPoint() = pBkmk->GetMarkPos();
+ if(pBkmk->IsExpanded())
+ *rPam.GetMark() = pBkmk->GetOtherMarkPos();
+ m_rSwdoc.getIDocumentMarkAccess()->deleteMark(pBkmk);
+ }
+ bJoinTxt = false;
+ }
+ else
+ {
+ if( !m_rSwdoc.IsIgnoreRedline() && m_rSwdoc.GetRedlineTbl().size() )
+ m_rSwdoc.DeleteRedline( aDelPam, true, USHRT_MAX );
+
+ SwUndoReplace* pUndoRpl = 0;
+ bool const bDoesUndo = m_rSwdoc.GetIDocumentUndoRedo().DoesUndo();
+ if (bDoesUndo)
+ {
+ pUndoRpl = new SwUndoReplace(aDelPam, sRepl, bRegExReplace);
+ m_rSwdoc.GetIDocumentUndoRedo().AppendUndo(pUndoRpl);
+ }
+ ::sw::UndoGuard const undoGuard(m_rSwdoc.GetIDocumentUndoRedo());
+
+ if( aDelPam.GetPoint() != pStt )
+ aDelPam.Exchange();
+
+ SwNodeIndex aPtNd( pStt->nNode, -1 );
+ const sal_Int32 nPtCnt = pStt->nContent.GetIndex();
+
+ // Set the values again, if Frames or footnotes on the Text have been removed.
+ nStt = nPtCnt;
+ nEnd = bOneNode ? pEnd->nContent.GetIndex()
+ : pTxtNd->GetTxt().getLength();
+
+ bool bFirst = true;
+ OUString sIns;
+ while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
+ {
+ if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
+ {
+ InsertString( aDelPam, sIns );
+ }
+ else if( nStt < nEnd || !sIns.isEmpty() )
+ {
+ pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
+ }
+ SplitNode( *pStt, false);
+ bFirst = false;
+ }
+
+ if( bFirst || !sIns.isEmpty() )
+ {
+ if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
+ {
+ InsertString( aDelPam, sIns );
+ }
+ else if( nStt < nEnd || !sIns.isEmpty() )
+ {
+ pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
+ }
+ }
+
+ *rPam.GetPoint() = *aDelPam.GetMark();
+ ++aPtNd;
+ rPam.GetMark()->nNode = aPtNd;
+ rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
+ nPtCnt );
+
+ if (bJoinTxt)
+ {
+ assert(rPam.GetPoint() == rPam.End());
+ // move so that SetEnd remembers position after sw_JoinText
+ rPam.Move(fnMoveBackward);
+ }
+ else if (aDelPam.GetPoint() == pStt) // backward selection?
+ {
+ assert(*rPam.GetMark() <= *rPam.GetPoint());
+ rPam.Exchange(); // swap so that rPam is backwards
+ }
+
+ if( pUndoRpl )
+ {
+ pUndoRpl->SetEnd(rPam);
+ }
+ }
+ }
+
+ if( bJoinTxt )
+ ::sw_JoinText( rPam, bJoinPrev );
+
+ m_rSwdoc.SetModified();
+ return true;
+}
+
+SwFlyFrmFmt* DocumentContentOperationsManager::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* pFrmFmt)
+{
+ SwFlyFrmFmt *pFmt = 0;
+ if( pNode )
+ {
+ pFmt = m_rSwdoc._MakeFlySection( rPos, *pNode, FLY_AT_PARA,
+ pFlyAttrSet, pFrmFmt );
+ if( pGrfAttrSet )
+ pNode->SetAttr( *pGrfAttrSet );
+ }
+ return pFmt;
+}
+
+bool DocumentContentOperationsManager::CopyImpl( SwPaM& rPam, SwPosition& rPos,
+ const bool bMakeNewFrms, const bool bCopyAll,
+ SwPaM *const pCpyRange ) const
+{
+ SwDoc* pDoc = rPos.nNode.GetNode().GetDoc();
+ const bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
+
+ SwPosition* pStt = rPam.Start();
+ SwPosition* pEnd = rPam.End();
+
+ // Catch when there's no copy to do.
+ if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ||
+ //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end
+ //JP 15.11.2001: don't test inclusive the end, ever exclusive
+ ( pDoc == &m_rSwdoc && *pStt <= rPos && rPos < *pEnd ))
+ {
+ return false;
+ }
+
+ const bool bEndEqualIns = pDoc == &m_rSwdoc && rPos == *pEnd;
+
+ // If Undo is enabled, create the UndoCopy object
+ SwUndoCpyDoc* pUndo = 0;
+ // lcl_DeleteRedlines may delete the start or end node of the cursor when
+ // removing the redlines so use cursor that is corrected by PaMCorrAbs
+ ::boost::scoped_ptr<SwUnoCrsr> const pCopyPam(pDoc->CreateUnoCrsr(rPos));
+
+ SwTblNumFmtMerge aTNFM( m_rSwdoc, *pDoc );
+
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ pUndo = new SwUndoCpyDoc(*pCopyPam);
+ pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
+ }
+
+ RedlineMode_t eOld = pDoc->GetRedlineMode();
+ pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
+
+ // Move the PaM one node back from the insert position, so that
+ // the position doesn't get moved
+ pCopyPam->SetMark();
+ bool bCanMoveBack = pCopyPam->Move(fnMoveBackward, fnGoCntnt);
+ // If the position was shifted from more than one node, an end node has been skipped
+ bool bAfterTable = false;
+ if ((rPos.nNode.GetIndex() - pCopyPam->GetPoint()->nNode.GetIndex()) > 1)
+ {
+ // First go back to the original place
+ pCopyPam->GetPoint()->nNode = rPos.nNode;
+ pCopyPam->GetPoint()->nContent = rPos.nContent;
+
+ bCanMoveBack = false;
+ bAfterTable = true;
+ }
+ if( !bCanMoveBack )
+ pCopyPam->GetPoint()->nNode--;
+
+ SwNodeRange aRg( pStt->nNode, pEnd->nNode );
+ SwNodeIndex aInsPos( rPos.nNode );
+ const bool bOneNode = pStt->nNode == pEnd->nNode;
+ SwTxtNode* pSttTxtNd = pStt->nNode.GetNode().GetTxtNode();
+ SwTxtNode* pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
+ SwTxtNode* pDestTxtNd = aInsPos.GetNode().GetTxtNode();
+ bool bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() &&
+ ( (pDestTxtNd && !pDestTxtNd->GetTxt().getLength()) ||
+ ( !bOneNode && !rPos.nContent.GetIndex() ) );
+ bool bCopyBookmarks = true;
+ bool bStartIsTxtNode = 0 != pSttTxtNd;
+
+ // #i104585# copy outline num rule to clipboard (for ASCII filter)
+ if (pDoc->IsClipBoard() && m_rSwdoc.GetOutlineNumRule())
+ {
+ pDoc->SetOutlineNumRule(*m_rSwdoc.GetOutlineNumRule());
+ }
+
+ // #i86492#
+ // Correct the search for a previous list:
+ // First search for non-outline numbering list. Then search for non-outline
+ // bullet list.
+ // Keep also the <ListId> value for possible propagation.
+ OUString aListIdToPropagate;
+ const SwNumRule* pNumRuleToPropagate =
+ pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true );
+ if ( !pNumRuleToPropagate )
+ {
+ pNumRuleToPropagate =
+ pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, true );
+ }
+ // #i86492#
+ // Do not propagate previous found list, if
+ // - destination is an empty paragraph which is not in a list and
+ // - source contains at least one paragraph which is not in a list
+ if ( pNumRuleToPropagate &&
+ pDestTxtNd && !pDestTxtNd->GetTxt().getLength() &&
+ !pDestTxtNd->IsInList() &&
+ !lcl_ContainsOnlyParagraphsInList( rPam ) )
+ {
+ pNumRuleToPropagate = 0;
+ }
+
+ // This do/while block is only there so that we can break out of it!
+ do {
+ if( pSttTxtNd )
+ {
+ // Don't copy the beginning completely?
+ if( !bCopyCollFmt || bColumnSel || pStt->nContent.GetIndex() )
+ {
+ SwIndex aDestIdx( rPos.nContent );
+ bool bCopyOk = false;
+ if( !pDestTxtNd )
+ {
+ if( pStt->nContent.GetIndex() || bOneNode )
+ pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos,
+ pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
+ else
+ {
+ pDestTxtNd = static_cast<SwTxtNode*>(pSttTxtNd->MakeCopy( pDoc, aInsPos ));
+ bCopyOk = true;
+ }
+ aDestIdx.Assign( pDestTxtNd, 0 );
+ bCopyCollFmt = true;
+ }
+ else if( !bOneNode || bColumnSel )
+ {
+ const sal_Int32 nCntntEnd = pEnd->nContent.GetIndex();
+ {
+ ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
+ pDoc->getIDocumentContentOperations().SplitNode( rPos, false );
+ }
+
+ if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
+ {
+ // after the SplitNode, span the CpyPam correctly again
+ pCopyPam->Move( fnMoveBackward, fnGoCntnt );
+ pCopyPam->Move( fnMoveBackward, fnGoCntnt );
+ }
+
+ pDestTxtNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode();
+ aDestIdx.Assign(
+ pDestTxtNd, pDestTxtNd->GetTxt().getLength());
+
+ // Correct the area again
+ if( bEndEqualIns )
+ {
+ bool bChg = pEnd != rPam.GetPoint();
+ if( bChg )
+ rPam.Exchange();
+ rPam.Move( fnMoveBackward, fnGoCntnt );
+ if( bChg )
+ rPam.Exchange();
+
+ aRg.aEnd = pEnd->nNode;
+ pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
+ }
+ else if( rPos == *pEnd )
+ {
+ // The end was also moved
+ pEnd->nNode--;
+ pEnd->nContent.Assign( pDestTxtNd, nCntntEnd );
+ aRg.aEnd = pEnd->nNode;
+ pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
+ }
+ }
+
+ // Safe numrule item at destination.
+ // #i86492# - Safe also <ListId> item of destination.
+ int aNumRuleState = SFX_ITEM_UNKNOWN;
+ SwNumRuleItem aNumRuleItem;
+ int aListIdState = SFX_ITEM_UNKNOWN;
+ SfxStringItem aListIdItem( RES_PARATR_LIST_ID, OUString() );
+ {
+ const SfxItemSet * pAttrSet = pDestTxtNd->GetpSwAttrSet();
+ if (pAttrSet != NULL)
+ {
+ const SfxPoolItem * pItem = NULL;
+ aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
+ if (SFX_ITEM_SET == aNumRuleState)
+ aNumRuleItem = *((SwNumRuleItem *) pItem);
+
+ aListIdState =
+ pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
+ if (SFX_ITEM_SET == aListIdState)
+ {
+ aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ }
+ }
+ }
+
+ if( !bCopyOk )
+ {
+ const sal_Int32 nCpyLen = ( (bOneNode)
+ ? pEnd->nContent.GetIndex()
+ : pSttTxtNd->GetTxt().getLength())
+ - pStt->nContent.GetIndex();
+ pSttTxtNd->CopyText( pDestTxtNd, aDestIdx,
+ pStt->nContent, nCpyLen );
+ if( bEndEqualIns )
+ pEnd->nContent -= nCpyLen;
+ }
+
+ if( bOneNode )
+ {
+ if( bCopyCollFmt )
+ {
+ pSttTxtNd->CopyCollFmt( *pDestTxtNd );
+
+ /* If only a part of one paragraph is copied
+ restore the numrule at the destination. */
+ // #i86492# - restore also <ListId> item
+ if ( !lcl_MarksWholeNode(rPam) )
+ {
+ if (SFX_ITEM_SET == aNumRuleState)
+ {
+ pDestTxtNd->SetAttr(aNumRuleItem);
+ }
+ else
+ {
+ pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE);
+ }
+ if (SFX_ITEM_SET == aListIdState)
+ {
+ pDestTxtNd->SetAttr(aListIdItem);
+ }
+ else
+ {
+ pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID);
+ }
+ }
+ }
+
+ break;
+ }
+
+ aRg.aStart++;
+ }
+ }
+ else if( pDestTxtNd )
+ {
+ // Problems with insertion of table selections into "normal" text solved.
+ // We have to set the correct PaM for Undo, if this PaM starts in a textnode,
+ // the undo operation will try to merge this node after removing the table.
+ // If we didn't split a textnode, the PaM should start at the inserted table node
+ if( rPos.nContent.GetIndex() == pDestTxtNd->Len() )
+ { // Insertion at the last position of a textnode (empty or not)
+ ++aInsPos; // The table will be inserted behind the text node
+ }
+ else if( rPos.nContent.GetIndex() )
+ { // Insertion in the middle of a text node, it has to be split
+ // (and joined from undo)
+ bStartIsTxtNode = true;
+
+ const sal_Int32 nCntntEnd = pEnd->nContent.GetIndex();
+ {
+ ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
+ pDoc->getIDocumentContentOperations().SplitNode( rPos, false );
+ }
+
+ if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
+ {
+ // after the SplitNode, span the CpyPam correctly again
+ pCopyPam->Move( fnMoveBackward, fnGoCntnt );
+ pCopyPam->Move( fnMoveBackward, fnGoCntnt );
+ }
+
+ // Correct the area again
+ if( bEndEqualIns )
+ aRg.aEnd--;
+ // The end would also be moved
+ else if( rPos == *pEnd )
+ {
+ rPos.nNode-=2;
+ rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
+ nCntntEnd );
+ rPos.nNode++;
+ aRg.aEnd--;
+ }
+ }
+ else if( bCanMoveBack )
+ { //Insertion at the first position of a text node. It will not be splitted, the table
+ // will be inserted before the text node.
+ // See below, before the SetInsertRange funciton of the undo object will be called,
+ // the CpyPam would be moved to the next content position. This has to be avoided
+ // We want to be moved to the table node itself thus we have to set bCanMoveBack
+ // and to manipulate pCopyPam.
+ bCanMoveBack = false;
+ pCopyPam->GetPoint()->nNode--;
+ }
+ }
+
+ pDestTxtNd = aInsPos.GetNode().GetTxtNode();
+ if( pEndTxtNd )
+ {
+ SwIndex aDestIdx( rPos.nContent );
+ if( !pDestTxtNd )
+ {
+ pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos,
+ pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
+ aDestIdx.Assign( pDestTxtNd, 0 );
+ aInsPos--;
+
+ // if we have to insert an extra text node
+ // at the destination, this node will be our new destination
+ // (text) node, and thus we set bStartisTxtNode to true. This
+ // will ensure that this node will be deleted during Undo
+ // using JoinNext.
+ OSL_ENSURE( !bStartIsTxtNode, "Oops, undo may be instable now." );
+ bStartIsTxtNode = true;
+ }
+
+ // Save numrule at destination
+ // #i86492# - Safe also <ListId> item of destination.
+ int aNumRuleState = SFX_ITEM_UNKNOWN;
+ SwNumRuleItem aNumRuleItem;
+ int aListIdState = SFX_ITEM_UNKNOWN;
+ SfxStringItem aListIdItem( RES_PARATR_LIST_ID, OUString() );
+ {
+ const SfxItemSet* pAttrSet = pDestTxtNd->GetpSwAttrSet();
+ if (pAttrSet != NULL)
+ {
+ const SfxPoolItem * pItem = NULL;
+
+ aNumRuleState =
+ pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
+ if (SFX_ITEM_SET == aNumRuleState)
+ aNumRuleItem = *((SwNumRuleItem *) pItem);
+
+ aListIdState =
+ pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
+ if (SFX_ITEM_SET == aListIdState)
+ aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+ }
+ }
+
+ const bool bEmptyDestNd = pDestTxtNd->GetTxt().isEmpty();
+ pEndTxtNd->CopyText( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ),
+ pEnd->nContent.GetIndex() );
+
+ // Also copy all format templates
+ if( bCopyCollFmt && ( bOneNode || bEmptyDestNd ))
+ {
+ pEndTxtNd->CopyCollFmt( *pDestTxtNd );
+
+ if ( bOneNode )
+ {
+ /* If only a part of one paragraph is copied
+ restore the numrule at the destination. */
+ // #i86492# - restore also <ListId> item
+ if ( !lcl_MarksWholeNode(rPam) )
+ {
+ if (SFX_ITEM_SET == aNumRuleState)
+ {
+ pDestTxtNd->SetAttr(aNumRuleItem);
+ }
+ else
+ {
+ pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE);
+ }
+ if (SFX_ITEM_SET == aListIdState)
+ {
+ pDestTxtNd->SetAttr(aListIdItem);
+ }
+ else
+ {
+ pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID);
+ }
+ }
+ }
+ }
+ }
+
+ if( bCopyAll || aRg.aStart != aRg.aEnd )
+ {
+ SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
+ if( pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() )
+ {
+ aBrkSet.Put( *pDestTxtNd->GetpSwAttrSet() );
+ if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_BREAK, false ) )
+ pDestTxtNd->ResetAttr( RES_BREAK );
+ if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_PAGEDESC, false ) )
+ pDestTxtNd->ResetAttr( RES_PAGEDESC );
+ }
+
+ if( aInsPos == pEnd->nNode )
+ {
+ SwNodeIndex aSaveIdx( aInsPos, -1 );
+ CopyWithFlyInFly( aRg, 0,aInsPos, &rPam, bMakeNewFrms, false );
+ ++aSaveIdx;
+ pEnd->nNode = aSaveIdx;
+ pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 );
+ }
+ else
+ CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, false );
+
+ bCopyBookmarks = false;
+
+ // Put the breaks back into the first node
+ if( aBrkSet.Count() && 0 != ( pDestTxtNd = pDoc->GetNodes()[
+ pCopyPam->GetPoint()->nNode.GetIndex()+1 ]->GetTxtNode()))
+ {
+ pDestTxtNd->SetAttr( aBrkSet );
+ }
+ }
+ } while( false );
+
+ // Adjust position (in case it was moved / in another node)
+ rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
+ rPos.nContent.GetIndex() );
+
+ if( rPos.nNode != aInsPos )
+ {
+ pCopyPam->GetMark()->nNode = aInsPos;
+ pCopyPam->GetMark()->nContent.Assign(pCopyPam->GetCntntNode(false), 0);
+ rPos = *pCopyPam->GetMark();
+ }
+ else
+ *pCopyPam->GetMark() = rPos;
+
+ if ( !bAfterTable )
+ pCopyPam->Move( fnMoveForward, bCanMoveBack ? fnGoCntnt : fnGoNode );
+ else
+ {
+ // Reset the offset to 0 as it was before the insertion
+ pCopyPam->GetPoint()->nContent -= pCopyPam->GetPoint()->nContent;
+
+ pCopyPam->GetPoint()->nNode++;
+ // If the next node is a start node, then step back: the start node
+ // has been copied and needs to be in the selection for the undo
+ if (pCopyPam->GetPoint()->nNode.GetNode().IsStartNode())
+ pCopyPam->GetPoint()->nNode--;
+
+ }
+ pCopyPam->Exchange();
+
+ // Also copy all bookmarks
+ if( bCopyBookmarks && m_rSwdoc.getIDocumentMarkAccess()->getAllMarksCount() )
+ lcl_CopyBookmarks( rPam, *pCopyPam );
+
+ if( nsRedlineMode_t::REDLINE_DELETE_REDLINES & eOld )
+ {
+ assert(*pCopyPam->GetPoint() == rPos);
+ // the Node rPos points to may be deleted so unregister ...
+ rPos.nContent = SwIndex(0);
+ lcl_DeleteRedlines(rPam, *pCopyPam);
+ rPos = *pCopyPam->GetPoint(); // ... and restore.
+ }
+
+ // If Undo is enabled, store the inserted area
+ if (pDoc->GetIDocumentUndoRedo().DoesUndo())
+ {
+ pUndo->SetInsertRange( *pCopyPam, true, bStartIsTxtNode );
+ }
+
+ if( pCpyRange )
+ {
+ pCpyRange->SetMark();
+ *pCpyRange->GetPoint() = *pCopyPam->GetPoint();
+ *pCpyRange->GetMark() = *pCopyPam->GetMark();
+ }
+
+ if ( pNumRuleToPropagate != NULL )
+ {
+ // #i86492# - use <SwDoc::SetNumRule(..)>, because it also handles the <ListId>
+ pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false,
+ aListIdToPropagate, true, true );
+ }
+
+ pDoc->SetRedlineMode_intern( eOld );
+ pDoc->SetModified();
+
+ return true;
+}
+
+
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 9bcb632b90a1..c6d3fcd88c6d 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -27,6 +27,7 @@
#include <DocumentListItemsManager.hxx>
#include <DocumentListsManager.hxx>
#include <DocumentOutlineNodesManager.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <UndoManager.hxx>
#include <hintids.hxx>
#include <tools/shl.hxx>
@@ -340,6 +341,26 @@ IDocumentOutlineNodes & SwDoc::getIDocumentOutlineNodes()
return *m_pDocumentOutlineNodesManager;
}
+//IDocumentContentOperations
+IDocumentContentOperations const & SwDoc::getIDocumentContentOperations() const
+{
+ return *m_pDocumentContentOperationsManager;
+}
+
+IDocumentContentOperations & SwDoc::getIDocumentContentOperations()
+{
+ return *m_pDocumentContentOperationsManager;
+}
+
+::sw::DocumentContentOperationsManager const & SwDoc::GetDocumentContentOperationsManager() const
+{
+ return *m_pDocumentContentOperationsManager;
+}
+::sw::DocumentContentOperationsManager & SwDoc::GetDocumentContentOperationsManager()
+{
+ return *m_pDocumentContentOperationsManager;
+}
+
/* Implementations the next Interface here */
/*
@@ -356,363 +377,7 @@ void SwDoc::ChgDBData(const SwDBData& rNewData)
GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
}
-bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
-{
- SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode();
- if(0 == pNode)
- return false;
- {
- // BUG 26675: Send DataChanged before deleting, so that we notice which objects are in scope.
- // After that they can be before/after the position.
- SwDataChanged aTmp( this, rPos );
- }
-
- SwUndoSplitNode* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- // insert the Undo object (currently only for TextNode)
- if( pNode->IsTxtNode() )
- {
- pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- }
-
- // Update the rsid of the old and the new node unless
- // the old node is split at the beginning or at the end
- SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode();
- const sal_Int32 nPos = rPos.nContent.GetIndex();
- if( pTxtNode && nPos && nPos != pTxtNode->Len() )
- {
- UpdateParRsid( pTxtNode );
- }
-
- //JP 28.01.97: Special case for SplitNode at table start:
- // If it is at the beginning of a Doc/Fly/Footer/... or right at after a table
- // then insert a paragraph before it.
- if( bChkTableStart && !rPos.nContent.GetIndex() && pNode->IsTxtNode() )
- {
- sal_uLong nPrevPos = rPos.nNode.GetIndex() - 1;
- const SwTableNode* pTblNd;
- const SwNode* pNd = GetNodes()[ nPrevPos ];
- if( pNd->IsStartNode() &&
- SwTableBoxStartNode == ((SwStartNode*)pNd)->GetStartNodeType() &&
- 0 != ( pTblNd = GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
- ((( pNd = GetNodes()[ --nPrevPos ])->IsStartNode() &&
- SwTableBoxStartNode != ((SwStartNode*)pNd)->GetStartNodeType() )
- || ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() )
- || pNd->IsCntntNode() ))
- {
- if( pNd->IsCntntNode() )
- {
- //JP 30.04.99 Bug 65660:
- // There are no page breaks outside of the normal body area,
- // so this is not a valid condition to insert a paragraph.
- if( nPrevPos < GetNodes().GetEndOfExtras().GetIndex() )
- pNd = 0;
- else
- {
- // Only if the table has page breaks!
- const SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
- if( SFX_ITEM_SET != pFrmFmt->GetItemState(RES_PAGEDESC, false) &&
- SFX_ITEM_SET != pFrmFmt->GetItemState( RES_BREAK, false ) )
- pNd = 0;
- }
- }
-
- if( pNd )
- {
- SwTxtNode* pTxtNd = GetNodes().MakeTxtNode(
- SwNodeIndex( *pTblNd ),
- GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
- if( pTxtNd )
- {
- ((SwPosition&)rPos).nNode = pTblNd->GetIndex()-1;
- ((SwPosition&)rPos).nContent.Assign( pTxtNd, 0 );
-
- // only add page breaks/styles to the body area
- if( nPrevPos > GetNodes().GetEndOfExtras().GetIndex() )
- {
- SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
- const SfxPoolItem *pItem;
- if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_PAGEDESC,
- false, &pItem ) )
- {
- pTxtNd->SetAttr( *pItem );
- pFrmFmt->ResetFmtAttr( RES_PAGEDESC );
- }
- if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK,
- false, &pItem ) )
- {
- pTxtNd->SetAttr( *pItem );
- pFrmFmt->ResetFmtAttr( RES_BREAK );
- }
- }
-
- if( pUndo )
- pUndo->SetTblFlag();
- SetModified();
- return true;
- }
- }
- }
- }
-
- const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
- pCntntStore->Save( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), SAVEFLY_SPLIT );
- // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
- OSL_ENSURE(pNode->IsTxtNode(), "splitting non-text node?");
- pNode = pNode->SplitCntntNode( rPos );
- if (pNode)
- {
- // move all bookmarks, TOXMarks, FlyAtCnt
- if( !pCntntStore->Empty() )
- pCntntStore->Restore( this, rPos.nNode.GetIndex()-1, 0, true );
-
- // To-Do - add 'SwExtraRedlineTbl' also ?
- if( IsRedlineOn() || (!IsIgnoreRedline() && !mpRedlineTbl->empty() ))
- {
- SwPaM aPam( rPos );
- aPam.SetMark();
- aPam.Move( fnMoveBackward );
- if( IsRedlineOn() )
- AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
- else
- SplitRedline( aPam );
- }
- }
-
- SetModified();
- return true;
-}
-
-bool SwDoc::AppendTxtNode( SwPosition& rPos )
-{
- // create new node before EndOfContent
- SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode();
- if( !pCurNode )
- {
- // so then one can be created!
- SwNodeIndex aIdx( rPos.nNode, 1 );
- pCurNode = GetNodes().MakeTxtNode( aIdx,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
- }
- else
- pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos );
-
- rPos.nNode++;
- rPos.nContent.Assign( pCurNode, 0 );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) );
- }
-
- // To-Do - add 'SwExtraRedlineTbl' also ?
- if( IsRedlineOn() || (!IsIgnoreRedline() && !mpRedlineTbl->empty() ))
- {
- SwPaM aPam( rPos );
- aPam.SetMark();
- aPam.Move( fnMoveBackward );
- if( IsRedlineOn() )
- AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
- else
- SplitRedline( aPam );
- }
-
- SetModified();
- return true;
-}
-
-bool SwDoc::InsertString( const SwPaM &rRg, const OUString &rStr,
- const enum InsertFlags nInsertMode )
-{
- // fetching DoesUndo is surprisingly expensive
- bool bDoesUndo = GetIDocumentUndoRedo().DoesUndo();
- if (bDoesUndo)
- GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called!
-
- const SwPosition& rPos = *rRg.GetPoint();
-
- if( mpACEWord ) // add to auto correction
- {
- if( 1 == rStr.getLength() && mpACEWord->IsDeleted() )
- {
- mpACEWord->CheckChar( rPos, rStr[ 0 ] );
- }
- delete mpACEWord, mpACEWord = 0;
- }
-
- SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode();
- if(!pNode)
- return false;
-
- SwDataChanged aTmp( rRg );
-
- if (!bDoesUndo || !GetIDocumentUndoRedo().DoesGroupUndo())
- {
- OUString const ins(pNode->InsertText(rStr, rPos.nContent, nInsertMode));
- if (bDoesUndo)
- {
- SwUndoInsert * const pUndo( new SwUndoInsert(rPos.nNode,
- rPos.nContent.GetIndex(), ins.getLength(), nInsertMode));
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- }
- else
- { // if Undo and grouping is enabled, everything changes!
- SwUndoInsert * pUndo = NULL;
-
- // don't group the start if hints at the start should be expanded
- if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND))
- {
- SwUndo *const pLastUndo = GetUndoManager().GetLastUndo();
- SwUndoInsert *const pUndoInsert(
- dynamic_cast<SwUndoInsert *>(pLastUndo) );
- if (pUndoInsert && pUndoInsert->CanGrouping(rPos))
- {
- pUndo = pUndoInsert;
- }
- }
-
- CharClass const& rCC = GetAppCharClass();
- sal_Int32 nInsPos = rPos.nContent.GetIndex();
-
- if (!pUndo)
- {
- pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode,
- !rCC.isLetterNumeric( rStr, 0 ) );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
-
- OUString const ins(pNode->InsertText(rStr, rPos.nContent, nInsertMode));
-
- for (sal_Int32 i = 0; i < ins.getLength(); ++i)
- {
- nInsPos++;
- // if CanGrouping() returns true, everything has already been done
- if (!pUndo->CanGrouping(ins[i]))
- {
- pUndo = new SwUndoInsert(rPos.nNode, nInsPos, 1, nInsertMode,
- !rCC.isLetterNumeric(ins, i));
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- }
- }
-
- // To-Do - add 'SwExtraRedlineTbl' also ?
- if( IsRedlineOn() || (!IsIgnoreRedline() && !mpRedlineTbl->empty() ))
- {
- SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
- rPos.nNode, rPos.nContent.GetIndex());
- if( IsRedlineOn() )
- {
- AppendRedline(
- new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
- }
- else
- {
- SplitRedline( aPam );
- }
- }
-
- SetModified();
- return true;
-}
-
-SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* pFrmFmt)
-{
- SwFlyFrmFmt *pFmt = 0;
- if( pNode )
- {
- pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA,
- pFlyAttrSet, pFrmFmt );
- if( pGrfAttrSet )
- pNode->SetAttr( *pGrfAttrSet );
- }
- return pFmt;
-}
-
-SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg,
- const OUString& rGrfName,
- const OUString& rFltName,
- const Graphic* pGraphic,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* pFrmFmt )
-{
- if( !pFrmFmt )
- pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
- SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
- SwNodeIndex( GetNodes().GetEndOfAutotext() ),
- rGrfName, rFltName, pGraphic,
- mpDfltGrfFmtColl );
- SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
- pFlyAttrSet, pGrfAttrSet, pFrmFmt );
- return pSwFlyFrmFmt;
-}
-
-SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* pFrmFmt )
-{
- if( !pFrmFmt )
- pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
- SwGrfNode* pSwGrfNode = GetNodes().MakeGrfNode(
- SwNodeIndex( GetNodes().GetEndOfAutotext() ),
- rGrfObj, mpDfltGrfFmtColl );
- SwFlyFrmFmt* pSwFlyFrmFmt = _InsNoTxtNode( *rRg.GetPoint(), pSwGrfNode,
- pFlyAttrSet, pGrfAttrSet, pFrmFmt );
- return pSwFlyFrmFmt;
-}
-
-SwFlyFrmFmt* SwDoc::Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* pFrmFmt )
-{
- if( !pFrmFmt )
- {
- sal_uInt16 nId = RES_POOLFRM_OLE;
- SvGlobalName aClassName( xObj->getClassID() );
- if (SotExchange::IsMath(aClassName))
- nId = RES_POOLFRM_FORMEL;
-
- pFrmFmt = GetFrmFmtFromPool( nId );
- }
- return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeOLENode(
- SwNodeIndex( GetNodes().GetEndOfAutotext() ),
- xObj,
- mpDfltGrfFmtColl ),
- pFlyAttrSet, pGrfAttrSet,
- pFrmFmt );
-}
-
-SwFlyFrmFmt* SwDoc::InsertOLE(const SwPaM &rRg, const OUString& rObjName,
- sal_Int64 nAspect,
- const SfxItemSet* pFlyAttrSet,
- const SfxItemSet* pGrfAttrSet,
- SwFrmFmt* pFrmFmt )
-{
- if( !pFrmFmt )
- pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_OLE );
-
- return _InsNoTxtNode( *rRg.GetPoint(),
- GetNodes().MakeOLENode(
- SwNodeIndex( GetNodes().GetEndOfAutotext() ),
- rObjName,
- nAspect,
- mpDfltGrfFmtColl,
- 0 ),
- pFlyAttrSet, pGrfAttrSet,
- pFrmFmt );
-}
/// @returns the field type of the Doc
SwFieldType *SwDoc::GetSysFldType( const sal_uInt16 eWhich ) const
@@ -992,7 +657,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData(
aPam.Move( fnMoveBackward, fnGoDoc );
aPam.SetMark();
aPam.Move( fnMoveForward, fnGoDoc );
- rPostItDoc.DeleteRange( aPam );
+ rPostItDoc.getIDocumentContentOperations().DeleteRange( aPam );
const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
@@ -1022,7 +687,7 @@ void SwDoc::UpdatePagesForPrintingWithPostItData(
const bool bNewPage = nPostItMode == POSTITS_ENDPAGE &&
!bIsFirstPostIt && nPhyPageNum != nLastPageNum;
- lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam,
+ lcl_FormatPostIt( &rData.m_pPostItShell->GetDoc()->getIDocumentContentOperations(), aPam,
rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
bIsFirstPostIt = false;
@@ -1584,30 +1249,6 @@ void SwDoc::ResetModified()
}
}
-void SwDoc::ReRead( SwPaM& rPam, const OUString& rGrfName,
- const OUString& rFltName, const Graphic* pGraphic,
- const GraphicObject* pGrafObj )
-{
- SwGrfNode *pGrfNd;
- if( ( !rPam.HasMark()
- || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
- && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd));
- }
-
- // Because we don't know if we can mirror the graphic, the mirror attribute is always reset
- if( RES_MIRROR_GRAPH_DONT != pGrfNd->GetSwAttrSet().
- GetMirrorGrf().GetValue() )
- pGrfNd->SetAttr( SwMirrorGrf() );
-
- pGrfNd->ReRead( rGrfName, rFltName, pGraphic, pGrafObj, true );
- SetModified();
- }
-}
-
static bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs )
{
SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
@@ -1813,12 +1454,12 @@ bool SwDoc::RemoveInvisibleContent()
( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
!GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
{
- DeleteRange( aPam );
+ getIDocumentContentOperations().DeleteRange( aPam );
}
else
{
aPam.DeleteMark();
- DelFullPara( aPam );
+ getIDocumentContentOperations().DelFullPara( aPam );
}
}
}
@@ -1846,12 +1487,12 @@ bool SwDoc::RemoveInvisibleContent()
( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
!GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
{
- DeleteRange( aPam );
+ getIDocumentContentOperations().DeleteRange( aPam );
}
else
{
aPam.DeleteMark();
- DelFullPara( aPam );
+ getIDocumentContentOperations().DelFullPara( aPam );
}
}
else if ( pTxtNd->HasHiddenCharAttribute( false ) )
@@ -1931,14 +1572,14 @@ bool SwDoc::RemoveInvisibleContent()
&aPam.GetPoint()->nNode );
aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
- DeleteRange( aPam );
+ getIDocumentContentOperations().DeleteRange( aPam );
}
else
{
// delete the whole section
aPam.SetMark();
aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
- DelFullPara( aPam );
+ getIDocumentContentOperations().DelFullPara( aPam );
}
}
@@ -2069,11 +1710,11 @@ bool SwDoc::ConvertFieldsToText()
aPam1.Move();
//insert first to keep the field's attributes
if (!sText.isEmpty())
- InsertString( aPam1, sText );
+ getIDocumentContentOperations().InsertString( aPam1, sText );
SwPaM aPam2(*pTxtFld->GetpTxtNode(), pTxtFld->GetStart());
aPam2.SetMark();
aPam2.Move();
- DeleteAndJoin(aPam2);//remove the field
+ getIDocumentContentOperations().DeleteAndJoin(aPam2);//remove the field
bRet=true;
}
}
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 3a6e4f349c32..33ea33f5f44b 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -27,6 +27,7 @@
#include <swmodule.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <docary.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -1370,7 +1371,7 @@ bool SwCompareLine::ChangesInLine( const SwCompareLine& rLine,
SwPaM aCpyPam( rSrcNd, nSrcFrom );
aCpyPam.SetMark();
aCpyPam.GetPoint()->nContent = nSrcTo;
- aCpyPam.GetDoc()->CopyRange( aCpyPam, *aPam.GetPoint(),
+ aCpyPam.GetDoc()->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(),
false );
pDstDoc->GetIDocumentUndoRedo().DoUndo( bUndo );
@@ -1545,7 +1546,7 @@ void SwCompareData::ShowDelete(
SwNodeIndex aInsPos( *pLineNd, nOffset );
SwNodeIndex aSavePos( aInsPos, -1 );
- ((SwCompareData&)rData).rDoc.CopyWithFlyInFly( aRg, 0, aInsPos );
+ ((SwCompareData&)rData).rDoc.GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aInsPos );
rDoc.SetModified();
++aSavePos;
@@ -1887,7 +1888,7 @@ sal_uInt16 _SaveMergeRedlines::InsertRedline()
RedlineMode_t eOld = pDoc->GetRedlineMode();
pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
- pSrcRedl->GetDoc()->CopyRange(
+ pSrcRedl->GetDoc()->getIDocumentContentOperations().CopyRange(
*const_cast<SwPaM*>(static_cast<const SwPaM*>(pSrcRedl)),
*pDestRedl->GetPoint(), false );
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 0ab73e7512cb..96305436f079 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -34,6 +34,7 @@
#include <mdiexp.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <docary.hxx>
#include <rootfrm.hxx>
#include <frmtool.hxx>
@@ -273,7 +274,7 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead,
aTmp = *pSttNd->EndOfSectionNode();
GetNodes()._Copy( aRange, aTmp, false );
aTmp = *pSttNd;
- CopyFlyInFlyImpl(aRange, 0, aTmp);
+ GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRange, 0, aTmp);
pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
rDescFrmFmt.SetFmtAttr( SwFmtHeader( pFmt ) );
@@ -349,7 +350,7 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot,
aTmp = *pSttNd->EndOfSectionNode();
GetNodes()._Copy( aRange, aTmp, false );
aTmp = *pSttNd;
- CopyFlyInFlyImpl(aRange, 0, aTmp);
+ GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRange, 0, aTmp);
pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
rDescFrmFmt.SetFmtAttr( SwFmtFooter( pFmt ) );
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 19bc35a6141b..4e081598720d 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -32,11 +32,6 @@
#include <rootfrm.hxx>
#include <splargs.hxx>
#include <txtfrm.hxx>
-#include <UndoSplitMove.hxx>
-#include <UndoRedline.hxx>
-#include <UndoOverwrite.hxx>
-#include <UndoInsert.hxx>
-#include <UndoDelete.hxx>
#include <breakit.hxx>
#include <vcl/layout.hxx>
#include "comcore.hrc"
@@ -53,115 +48,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::linguistic2;
using namespace ::com::sun::star::i18n;
-struct _SaveRedline
-{
- SwRangeRedline* pRedl;
- sal_uInt32 nStt, nEnd;
- sal_Int32 nSttCnt;
- sal_Int32 nEndCnt;
-
- _SaveRedline( SwRangeRedline* pR, const SwNodeIndex& rSttIdx )
- : pRedl(pR)
- , nEnd(0)
- , nEndCnt(0)
- {
- const SwPosition* pStt = pR->Start(),
- * pEnd = pR->GetMark() == pStt ? pR->GetPoint() : pR->GetMark();
- sal_uInt32 nSttIdx = rSttIdx.GetIndex();
- nStt = pStt->nNode.GetIndex() - nSttIdx;
- nSttCnt = pStt->nContent.GetIndex();
- if( pR->HasMark() )
- {
- nEnd = pEnd->nNode.GetIndex() - nSttIdx;
- nEndCnt = pEnd->nContent.GetIndex();
- }
-
- pRedl->GetPoint()->nNode = 0;
- pRedl->GetPoint()->nContent.Assign( 0, 0 );
- pRedl->GetMark()->nNode = 0;
- pRedl->GetMark()->nContent.Assign( 0, 0 );
- }
-
- _SaveRedline( SwRangeRedline* pR, const SwPosition& rPos )
- : pRedl(pR)
- , nEnd(0)
- , nEndCnt(0)
- {
- const SwPosition* pStt = pR->Start(),
- * pEnd = pR->GetMark() == pStt ? pR->GetPoint() : pR->GetMark();
- sal_uInt32 nSttIdx = rPos.nNode.GetIndex();
- nStt = pStt->nNode.GetIndex() - nSttIdx;
- nSttCnt = pStt->nContent.GetIndex();
- if( nStt == 0 )
- nSttCnt = nSttCnt - rPos.nContent.GetIndex();
- if( pR->HasMark() )
- {
- nEnd = pEnd->nNode.GetIndex() - nSttIdx;
- nEndCnt = pEnd->nContent.GetIndex();
- if( nEnd == 0 )
- nEndCnt = nEndCnt - rPos.nContent.GetIndex();
- }
-
- pRedl->GetPoint()->nNode = 0;
- pRedl->GetPoint()->nContent.Assign( 0, 0 );
- pRedl->GetMark()->nNode = 0;
- pRedl->GetMark()->nContent.Assign( 0, 0 );
- }
-
- void SetPos( sal_uInt32 nInsPos )
- {
- pRedl->GetPoint()->nNode = nInsPos + nStt;
- pRedl->GetPoint()->nContent.Assign( pRedl->GetCntntNode(), nSttCnt );
- if( pRedl->HasMark() )
- {
- pRedl->GetMark()->nNode = nInsPos + nEnd;
- pRedl->GetMark()->nContent.Assign( pRedl->GetCntntNode(false), nEndCnt );
- }
- }
-
- void SetPos( const SwPosition& aPos )
- {
- pRedl->GetPoint()->nNode = aPos.nNode.GetIndex() + nStt;
- pRedl->GetPoint()->nContent.Assign( pRedl->GetCntntNode(), nSttCnt + ( nStt == 0 ? aPos.nContent.GetIndex() : 0 ) );
- if( pRedl->HasMark() )
- {
- pRedl->GetMark()->nNode = aPos.nNode.GetIndex() + nEnd;
- pRedl->GetMark()->nContent.Assign( pRedl->GetCntntNode(false), nEndCnt + ( nEnd == 0 ? aPos.nContent.GetIndex() : 0 ) );
- }
- }
-};
-
-typedef boost::ptr_vector< _SaveRedline > _SaveRedlines;
-
-static bool lcl_MayOverwrite( const SwTxtNode *pNode, const sal_Int32 nPos )
-{
- sal_Unicode const cChr = pNode->GetTxt()[nPos];
- switch (cChr)
- {
- case CH_TXTATR_BREAKWORD:
- case CH_TXTATR_INWORD:
- return !pNode->GetTxtAttrForCharAt(nPos);// how could there be none?
- case CH_TXT_ATR_FIELDSTART:
- case CH_TXT_ATR_FIELDEND:
- case CH_TXT_ATR_FORMELEMENT:
- return false;
- default:
- return true;
- }
-}
-
-static void lcl_SkipAttr( const SwTxtNode *pNode, SwIndex &rIdx, sal_Int32 &rStart )
-{
- if( !lcl_MayOverwrite( pNode, rStart ) )
- {
- // skip all special attributes
- do {
- ++rIdx;
- rStart = rIdx.GetIndex();
- } while (rStart < pNode->GetTxt().getLength()
- && !lcl_MayOverwrite(pNode, rStart) );
- }
-}
void _RestFlyInRange( _SaveFlyArr & rArr, const SwNodeIndex& rSttIdx,
const SwNodeIndex* pInsertPos )
@@ -333,302 +219,6 @@ void DelFlyInRange( const SwNodeIndex& rMkNdIdx,
}
}
-static bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd,
- const SwNodeIndex& rInsPos,
- SwFtnIdxs& rFtnArr, SwFtnIdxs& rSaveArr,
- const SwIndex* pSttCnt = 0, const SwIndex* pEndCnt = 0 )
-{
- bool bUpdateFtn = false;
- const SwNodes& rNds = rInsPos.GetNodes();
- const bool bDelFtn = rInsPos.GetIndex() < rNds.GetEndOfAutotext().GetIndex() &&
- rSttNd.GetIndex() >= rNds.GetEndOfAutotext().GetIndex();
- const bool bSaveFtn = !bDelFtn &&
- rInsPos.GetIndex() >= rNds.GetEndOfExtras().GetIndex();
- if( !rFtnArr.empty() )
- {
-
- sal_uInt16 nPos;
- rFtnArr.SeekEntry( rSttNd, &nPos );
- SwTxtFtn* pSrch;
- const SwNode* pFtnNd;
-
- // Delete/save all that come after it
- while( nPos < rFtnArr.size() && ( pFtnNd =
- &( pSrch = rFtnArr[ nPos ] )->GetTxtNode())->GetIndex()
- <= rEndNd.GetIndex() )
- {
- const sal_Int32 nFtnSttIdx = pSrch->GetStart();
- if( ( pEndCnt && pSttCnt )
- ? (( &rSttNd.GetNode() == pFtnNd &&
- pSttCnt->GetIndex() > nFtnSttIdx) ||
- ( &rEndNd.GetNode() == pFtnNd &&
- nFtnSttIdx >= pEndCnt->GetIndex() ))
- : ( &rEndNd.GetNode() == pFtnNd ))
- {
- ++nPos; // continue searching
- }
- else
- {
- // delete it
- if( bDelFtn )
- {
- SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode();
- SwIndex aIdx( &rTxtNd, nFtnSttIdx );
- rTxtNd.EraseText( aIdx, 1 );
- }
- else
- {
- pSrch->DelFrms(0);
- rFtnArr.erase( rFtnArr.begin() + nPos );
- if( bSaveFtn )
- rSaveArr.insert( pSrch );
- }
- bUpdateFtn = true;
- }
- }
-
- while( nPos-- && ( pFtnNd = &( pSrch = rFtnArr[ nPos ] )->
- GetTxtNode())->GetIndex() >= rSttNd.GetIndex() )
- {
- const sal_Int32 nFtnSttIdx = pSrch->GetStart();
- if( !pEndCnt || !pSttCnt ||
- !( (( &rSttNd.GetNode() == pFtnNd &&
- pSttCnt->GetIndex() > nFtnSttIdx ) ||
- ( &rEndNd.GetNode() == pFtnNd &&
- nFtnSttIdx >= pEndCnt->GetIndex() )) ))
- {
- if( bDelFtn )
- {
- // delete it
- SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode();
- SwIndex aIdx( &rTxtNd, nFtnSttIdx );
- rTxtNd.EraseText( aIdx, 1 );
- }
- else
- {
- pSrch->DelFrms(0);
- rFtnArr.erase( rFtnArr.begin() + nPos );
- if( bSaveFtn )
- rSaveArr.insert( pSrch );
- }
- bUpdateFtn = true;
- }
- }
- }
- // When moving from redline section into document content section, e.g.
- // after loading a document with (delete-)redlines, the footnote array
- // has to be adjusted... (#i70572)
- if( bSaveFtn )
- {
- SwNodeIndex aIdx( rSttNd );
- while( aIdx < rEndNd ) // Check the moved section
- {
- SwNode* pNode = &aIdx.GetNode();
- if( pNode->IsTxtNode() ) // Looking for text nodes...
- {
- SwpHints *pHints =
- static_cast<SwTxtNode*>(pNode)->GetpSwpHints();
- if( pHints && pHints->HasFtn() ) //...with footnotes
- {
- bUpdateFtn = true; // Heureka
- sal_uInt16 nCount = pHints->Count();
- for( sal_uInt16 i = 0; i < nCount; ++i )
- {
- SwTxtAttr *pAttr = pHints->GetTextHint( i );
- if ( pAttr->Which() == RES_TXTATR_FTN )
- {
- rSaveArr.insert( static_cast<SwTxtFtn*>(pAttr) );
- }
- }
- }
- }
- ++aIdx;
- }
- }
- return bUpdateFtn;
-}
-
-static void lcl_SaveRedlines( const SwPaM& aPam, _SaveRedlines& rArr )
-{
- SwDoc* pDoc = aPam.GetNode().GetDoc();
-
- const SwPosition* pStart = aPam.Start();
- const SwPosition* pEnd = aPam.End();
-
- // get first relevant redline
- sal_uInt16 nCurrentRedline;
- pDoc->GetRedline( *pStart, &nCurrentRedline );
- if( nCurrentRedline > 0)
- nCurrentRedline--;
-
- // redline mode REDLINE_IGNORE|REDLINE_ON; save old mode
- RedlineMode_t eOld = pDoc->GetRedlineMode();
- pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
-
- // iterate over relevant redlines and decide for each whether it should
- // be saved, or split + saved
- SwRedlineTbl& rRedlineTable = const_cast<SwRedlineTbl&>( pDoc->GetRedlineTbl() );
- for( ; nCurrentRedline < rRedlineTable.size(); nCurrentRedline++ )
- {
- SwRangeRedline* pCurrent = rRedlineTable[ nCurrentRedline ];
- SwComparePosition eCompare =
- ComparePosition( *pCurrent->Start(), *pCurrent->End(),
- *pStart, *pEnd);
-
- // we must save this redline if it overlaps aPam
- // (we may have to split it, too)
- if( eCompare == POS_OVERLAP_BEHIND ||
- eCompare == POS_OVERLAP_BEFORE ||
- eCompare == POS_OUTSIDE ||
- eCompare == POS_INSIDE ||
- eCompare == POS_EQUAL )
- {
- rRedlineTable.Remove( nCurrentRedline-- );
-
- // split beginning, if necessary
- if( eCompare == POS_OVERLAP_BEFORE ||
- eCompare == POS_OUTSIDE )
- {
- SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
- *pNewRedline->End() = *pStart;
- *pCurrent->Start() = *pStart;
- pDoc->AppendRedline( pNewRedline, true );
- }
-
- // split end, if necessary
- if( eCompare == POS_OVERLAP_BEHIND ||
- eCompare == POS_OUTSIDE )
- {
- SwRangeRedline* pNewRedline = new SwRangeRedline( *pCurrent );
- *pNewRedline->Start() = *pEnd;
- *pCurrent->End() = *pEnd;
- pDoc->AppendRedline( pNewRedline, true );
- }
-
- // save the current redline
- _SaveRedline* pSave = new _SaveRedline( pCurrent, *pStart );
- rArr.push_back( pSave );
- }
- }
-
- // restore old redline mode
- pDoc->SetRedlineMode_intern( eOld );
-}
-
-static void lcl_RestoreRedlines( SwDoc* pDoc, const SwPosition& rPos, _SaveRedlines& rArr )
-{
- RedlineMode_t eOld = pDoc->GetRedlineMode();
- pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
-
- for( size_t n = 0; n < rArr.size(); ++n )
- {
- rArr[ n ].SetPos( rPos );
- pDoc->AppendRedline( rArr[ n ].pRedl, true );
- }
-
- pDoc->SetRedlineMode_intern( eOld );
-}
-
-static void lcl_SaveRedlines( const SwNodeRange& rRg, _SaveRedlines& rArr )
-{
- SwDoc* pDoc = rRg.aStart.GetNode().GetDoc();
- sal_uInt16 nRedlPos;
- SwPosition aSrchPos( rRg.aStart ); aSrchPos.nNode--;
- aSrchPos.nContent.Assign( aSrchPos.nNode.GetNode().GetCntntNode(), 0 );
- if( pDoc->GetRedline( aSrchPos, &nRedlPos ) && nRedlPos )
- --nRedlPos;
- else if( nRedlPos >= pDoc->GetRedlineTbl().size() )
- return ;
-
- RedlineMode_t eOld = pDoc->GetRedlineMode();
- pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
- SwRedlineTbl& rRedlTbl = (SwRedlineTbl&)pDoc->GetRedlineTbl();
-
- do {
- SwRangeRedline* pTmp = rRedlTbl[ nRedlPos ];
-
- const SwPosition* pRStt = pTmp->Start(),
- * pREnd = pTmp->GetMark() == pRStt
- ? pTmp->GetPoint() : pTmp->GetMark();
-
- if( pRStt->nNode < rRg.aStart )
- {
- if( pREnd->nNode > rRg.aStart && pREnd->nNode < rRg.aEnd )
- {
- // Create a copy and set the end of the original to the end of the MoveArea.
- // The copy is moved too.
- SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp );
- SwPosition* pTmpPos = pNewRedl->Start();
- pTmpPos->nNode = rRg.aStart;
- pTmpPos->nContent.Assign(
- pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
-
- _SaveRedline* pSave = new _SaveRedline( pNewRedl, rRg.aStart );
- rArr.push_back( pSave );
-
- pTmpPos = pTmp->End();
- pTmpPos->nNode = rRg.aEnd;
- pTmpPos->nContent.Assign(
- pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
- }
- else if( pREnd->nNode == rRg.aStart )
- {
- SwPosition* pTmpPos = pTmp->End();
- pTmpPos->nNode = rRg.aEnd;
- pTmpPos->nContent.Assign(
- pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
- }
- }
- else if( pRStt->nNode < rRg.aEnd )
- {
- rRedlTbl.Remove( nRedlPos-- );
- if( pREnd->nNode < rRg.aEnd ||
- ( pREnd->nNode == rRg.aEnd && !pREnd->nContent.GetIndex()) )
- {
- // move everything
- _SaveRedline* pSave = new _SaveRedline( pTmp, rRg.aStart );
- rArr.push_back( pSave );
- }
- else
- {
- // split
- SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp );
- SwPosition* pTmpPos = pNewRedl->End();
- pTmpPos->nNode = rRg.aEnd;
- pTmpPos->nContent.Assign(
- pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
-
- _SaveRedline* pSave = new _SaveRedline( pNewRedl, rRg.aStart );
- rArr.push_back( pSave );
-
- pTmpPos = pTmp->Start();
- pTmpPos->nNode = rRg.aEnd;
- pTmpPos->nContent.Assign(
- pTmpPos->nNode.GetNode().GetCntntNode(), 0 );
- pDoc->AppendRedline( pTmp, true );
- }
- }
- else
- break;
-
- } while( ++nRedlPos < pDoc->GetRedlineTbl().size() );
- pDoc->SetRedlineMode_intern( eOld );
-}
-
-static void lcl_RestoreRedlines( SwDoc* pDoc, sal_uInt32 nInsPos, _SaveRedlines& rArr )
-{
- RedlineMode_t eOld = pDoc->GetRedlineMode();
- pDoc->SetRedlineMode_intern( (RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON ));
-
- for( size_t n = 0; n < rArr.size(); ++n )
- {
- rArr[ n ].SetPos( nInsPos );
- pDoc->AppendRedline( rArr[ n ].pRedl, true );
- }
-
- pDoc->SetRedlineMode_intern( eOld );
-}
-
// #i59534: Redo of insertion of multiple text nodes runs into trouble
// because of unnecessary expanded redlines
// From now on this class saves the redline positions of all redlines which ends exact at the
@@ -679,537 +269,12 @@ void _SaveRedlEndPosForRestore::_Restore()
}
}
-/// Delete a full Section of the NodeArray.
-/// The passed Node is located somewhere in the designated Section.
-void SwDoc::DeleteSection( SwNode *pNode )
-{
- assert(pNode && "Didn't pass a Node.");
-
- SwStartNode* pSttNd = pNode->IsStartNode() ? (SwStartNode*)pNode
- : pNode->StartOfSectionNode();
- SwNodeIndex aSttIdx( *pSttNd ), aEndIdx( *pNode->EndOfSectionNode() );
-
- // delete all Flys, Bookmarks, ...
- DelFlyInRange( aSttIdx, aEndIdx );
- DeleteRedline( *pSttNd, true, USHRT_MAX );
- _DelBookmarks(aSttIdx, aEndIdx);
-
- {
- // move all Crsr/StkCrsr/UnoCrsr out of the to-be-deleted area
- SwNodeIndex aMvStt( aSttIdx, 1 );
- CorrAbs( aMvStt, aEndIdx, SwPosition( aSttIdx ), true );
- }
-
- GetNodes().DelNodes( aSttIdx, aEndIdx.GetIndex() - aSttIdx.GetIndex() + 1 );
-}
-
void SwDoc::SetModified(SwPaM &rPaM)
{
SwDataChanged aTmp( rPaM );
SetModified();
}
-bool SwDoc::Overwrite( const SwPaM &rRg, const OUString &rStr )
-{
- SwPosition& rPt = *(SwPosition*)rRg.GetPoint();
- if( mpACEWord ) // Add to AutoCorrect
- {
- if( 1 == rStr.getLength() )
- mpACEWord->CheckChar( rPt, rStr[ 0 ] );
- delete mpACEWord, mpACEWord = 0;
- }
-
- SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode();
- if (!pNode || rStr.getLength() > pNode->GetSpaceLeft()) // worst case: no erase
- {
- return false;
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called
- }
-
- sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints()
- ? pNode->GetpSwpHints()->Count() : 0;
- SwDataChanged aTmp( rRg );
- SwIndex& rIdx = rPt.nContent;
- sal_Int32 nStart = 0;
-
- bool bOldExpFlg = pNode->IsIgnoreDontExpand();
- pNode->SetIgnoreDontExpand( true );
-
- for( sal_Int32 nCnt = 0; nCnt < rStr.getLength(); ++nCnt )
- {
- // start behind the characters (to fix the attributes!)
- nStart = rIdx.GetIndex();
- if (nStart < pNode->GetTxt().getLength())
- {
- lcl_SkipAttr( pNode, rIdx, nStart );
- }
- sal_Unicode c = rStr[ nCnt ];
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- bool bMerged(false);
- if (GetIDocumentUndoRedo().DoesGroupUndo())
- {
- SwUndo *const pUndo = GetUndoManager().GetLastUndo();
- SwUndoOverwrite *const pUndoOW(
- dynamic_cast<SwUndoOverwrite *>(pUndo) );
- if (pUndoOW)
- {
- // if CanGrouping() returns true it's already merged
- bMerged = pUndoOW->CanGrouping( this, rPt, c );
- }
- }
- if (!bMerged)
- {
- SwUndo *const pUndoOW( new SwUndoOverwrite(this, rPt, c) );
- GetIDocumentUndoRedo().AppendUndo(pUndoOW);
- }
- }
- else
- {
- // start behind the characters (to fix the attributes!)
- if (nStart < pNode->GetTxt().getLength())
- ++rIdx;
- pNode->InsertText( OUString(c), rIdx, INS_EMPTYEXPAND );
- if( nStart+1 < rIdx.GetIndex() )
- {
- rIdx = nStart;
- pNode->EraseText( rIdx, 1 );
- ++rIdx;
- }
- }
- }
- pNode->SetIgnoreDontExpand( bOldExpFlg );
-
- sal_uInt16 nNewAttrCnt = pNode->GetpSwpHints()
- ? pNode->GetpSwpHints()->Count() : 0;
- if( nOldAttrCnt != nNewAttrCnt )
- {
- SwUpdateAttr aHint(
- 0,
- 0,
- 0);
-
- pNode->ModifyBroadcast( 0, &aHint, TYPE( SwCrsrShell ) );
- }
-
- if (!GetIDocumentUndoRedo().DoesUndo() &&
- !IsIgnoreRedline() && !GetRedlineTbl().empty())
- {
- SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
- DeleteRedline( aPam, true, USHRT_MAX );
- }
- else if( IsRedlineOn() )
- {
- // FIXME: this redline is WRONG: there is no DELETE, and the skipped
- // characters are also included in aPam
- SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() );
- AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
- }
-
- SetModified();
- return true;
-}
-
-bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
-{
- SwNodeIndex aIdx( rPaM.Start()->nNode );
- bool bJoinTxt = aIdx.GetNode().IsTxtNode();
- bool bOneNode = rPaM.GetPoint()->nNode == rPaM.GetMark()->nNode;
- aIdx--; // in front of the move area!
-
- bool bRet = MoveRange( rPaM, rPos, eMvFlags );
- if( bRet && !bOneNode )
- {
- if( bJoinTxt )
- ++aIdx;
- SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode();
- SwNodeIndex aNxtIdx( aIdx );
- if( pTxtNd && pTxtNd->CanJoinNext( &aNxtIdx ) )
- {
- { // Block so SwIndex into node is deleted before Join
- CorrRel( aNxtIdx, SwPosition( aIdx, SwIndex(pTxtNd,
- pTxtNd->GetTxt().getLength()) ), 0, true );
- }
- pTxtNd->JoinNext();
- }
- }
- return bRet;
-}
-
-// It seems that this is mostly used by SwDoc internals; the only
-// way to call this from the outside seems to be the special case in
-// SwDoc::CopyRange (but I have not managed to actually hit that case).
-bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
-{
- // nothing moved: return
- const SwPosition *pStt = rPaM.Start(), *pEnd = rPaM.End();
- if( !rPaM.HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd))
- return false;
-
- // Save the paragraph anchored Flys, so that they can be moved.
- _SaveFlyArr aSaveFlyArr;
- _SaveFlyInRange( rPaM, rPos.nNode, aSaveFlyArr, 0 != ( DOC_MOVEALLFLYS & eMvFlags ) );
-
- // save redlines (if DOC_MOVEREDLINES is used)
- _SaveRedlines aSaveRedl;
- if( DOC_MOVEREDLINES & eMvFlags && !GetRedlineTbl().empty() )
- {
- lcl_SaveRedlines( rPaM, aSaveRedl );
-
- // #i17764# unfortunately, code below relies on undos being
- // in a particular order, and presence of bookmarks
- // will change this order. Hence, we delete bookmarks
- // here without undo.
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
- _DelBookmarks(
- pStt->nNode,
- pEnd->nNode,
- NULL,
- &pStt->nContent,
- &pEnd->nContent);
- }
-
- bool bUpdateFtn = false;
- SwFtnIdxs aTmpFntIdx;
-
- SwUndoMove * pUndoMove = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- pUndoMove = new SwUndoMove( rPaM, rPos );
- pUndoMove->SetMoveRedlines( eMvFlags == DOC_MOVEREDLINES );
- }
- else
- {
- bUpdateFtn = lcl_SaveFtn( pStt->nNode, pEnd->nNode, rPos.nNode,
- GetFtnIdxs(), aTmpFntIdx,
- &pStt->nContent, &pEnd->nContent );
- }
-
- bool bSplit = false;
- SwPaM aSavePam( rPos, rPos );
-
- // Move the SPoint to the beginning of the range
- if( rPaM.GetPoint() == pEnd )
- rPaM.Exchange();
-
- // If there is a TextNode before and after the Move, create a JoinNext in the EditShell.
- SwTxtNode* pSrcNd = rPaM.GetPoint()->nNode.GetNode().GetTxtNode();
- bool bCorrSavePam = pSrcNd && pStt->nNode != pEnd->nNode;
-
- // If one ore more TextNodes are moved, SwNodes::Move will do a SplitNode.
- // However, this does not update the cursor. So we create a TextNode to keep
- // updating the indices. After the Move the Node is optionally deleted.
- SwTxtNode * pTNd = rPos.nNode.GetNode().GetTxtNode();
- if( pTNd && rPaM.GetPoint()->nNode != rPaM.GetMark()->nNode &&
- ( rPos.nContent.GetIndex() || ( pTNd->Len() && bCorrSavePam )) )
- {
- bSplit = true;
- const sal_Int32 nMkCntnt = rPaM.GetMark()->nContent.GetIndex();
-
- const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
- pCntntStore->Save( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), SAVEFLY_SPLIT );
-
- pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos ));
-
- if( !pCntntStore->Empty() )
- pCntntStore->Restore( this, rPos.nNode.GetIndex()-1, 0, true );
-
- // correct the PaM!
- if( rPos.nNode == rPaM.GetMark()->nNode )
- {
- rPaM.GetMark()->nNode = rPos.nNode.GetIndex()-1;
- rPaM.GetMark()->nContent.Assign( pTNd, nMkCntnt );
- }
- }
-
- // Put back the Pam by one "content"; so that it's always outside of
- // the manipulated range.
- // If there's no content anymore, set it to the StartNode (that's
- // always there).
- const bool bNullCntnt = !aSavePam.Move( fnMoveBackward, fnGoCntnt );
- if( bNullCntnt )
- {
- aSavePam.GetPoint()->nNode--;
- }
-
- // Copy all Bookmarks that are within the Move range into an array,
- // that saves the position as an offset.
- ::std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
- _DelBookmarks(
- pStt->nNode,
- pEnd->nNode,
- &aSaveBkmks,
- &pStt->nContent,
- &pEnd->nContent);
-
- // If there is no range anymore due to the above deletions (e.g. the
- // footnotes got deleted), it's still a valid Move!
- if( *rPaM.GetPoint() != *rPaM.GetMark() )
- {
- // now do the actual move
- GetNodes().MoveRange( rPaM, rPos, GetNodes() );
-
- // after a MoveRange() the Mark is deleted
- if ( rPaM.HasMark() ) // => no Move occurred!
- {
- delete pUndoMove;
- return false;
- }
- }
- else
- rPaM.DeleteMark();
-
- OSL_ENSURE( *aSavePam.GetMark() == rPos ||
- ( aSavePam.GetMark()->nNode.GetNode().GetCntntNode() == NULL ),
- "PaM was not moved. Aren't there ContentNodes at the beginning/end?" );
- *aSavePam.GetMark() = rPos;
-
- rPaM.SetMark(); // create a Sel. around the new range
- pTNd = aSavePam.GetNode().GetTxtNode();
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- // correct the SavePam's Content first
- if( bNullCntnt )
- {
- aSavePam.GetPoint()->nContent = 0;
- }
-
- // The method SwEditShell::Move() merges the TextNode after the Move,
- // where the rPaM is located.
- // If the Content was moved to the back and the SavePam's SPoint is
- // in the next Node, we have to deal with this when saving the Undo object!
- SwTxtNode * pPamTxtNd = 0;
-
- // Is passed to SwUndoMove, which happens when subsequently calling Undo JoinNext.
- // If it's not possible to call Undo JoinNext here.
- bool bJoin = bSplit && pTNd;
- bCorrSavePam = bCorrSavePam &&
- 0 != ( pPamTxtNd = rPaM.GetNode().GetTxtNode() )
- && pPamTxtNd->CanJoinNext()
- && (*rPaM.GetPoint() <= *aSavePam.GetPoint());
-
- // Do two Nodes have to be joined at the SavePam?
- if( bJoin && pTNd->CanJoinNext() )
- {
- pTNd->JoinNext();
- // No temporary Index when using &&.
- // We probably only want to compare the indices.
- if( bCorrSavePam && rPaM.GetPoint()->nNode.GetIndex()+1 ==
- aSavePam.GetPoint()->nNode.GetIndex() )
- {
- aSavePam.GetPoint()->nContent += pPamTxtNd->Len();
- }
- bJoin = false;
- }
- else if ( !aSavePam.Move( fnMoveForward, fnGoCntnt ) )
- {
- aSavePam.GetPoint()->nNode++;
- }
-
- // The newly inserted range is now inbetween SPoint and GetMark.
- pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(),
- bJoin, bCorrSavePam );
- GetIDocumentUndoRedo().AppendUndo( pUndoMove );
- }
- else
- {
- bool bRemove = true;
- // Do two Nodes have to be joined at the SavePam?
- if( bSplit && pTNd )
- {
- if( pTNd->CanJoinNext())
- {
- // Always join next, because <pTNd> has to stay as it is.
- // A join previous from its next would more or less delete <pTNd>
- pTNd->JoinNext();
- bRemove = false;
- }
- }
- if( bNullCntnt )
- {
- aSavePam.GetPoint()->nNode++;
- aSavePam.GetPoint()->nContent.Assign( aSavePam.GetCntntNode(), 0 );
- }
- else if( bRemove ) // No move forward after joining with next paragraph
- {
- aSavePam.Move( fnMoveForward, fnGoCntnt );
- }
- }
-
- // Insert the Bookmarks back into the Document.
- *rPaM.GetMark() = *aSavePam.Start();
- for(
- ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin();
- pBkmk != aSaveBkmks.end();
- ++pBkmk)
- pBkmk->SetInDoc(
- this,
- rPaM.GetMark()->nNode,
- &rPaM.GetMark()->nContent);
- *rPaM.GetPoint() = *aSavePam.End();
-
- // Move the Flys to the new position.
- _RestFlyInRange( aSaveFlyArr, rPaM.Start()->nNode, &(rPos.nNode) );
-
- // restore redlines (if DOC_MOVEREDLINES is used)
- if( !aSaveRedl.empty() )
- {
- lcl_RestoreRedlines( this, *aSavePam.Start(), aSaveRedl );
- }
-
- if( bUpdateFtn )
- {
- if( !aTmpFntIdx.empty() )
- {
- GetFtnIdxs().insert( aTmpFntIdx );
- aTmpFntIdx.clear();
- }
-
- GetFtnIdxs().UpdateAllFtn();
- }
-
- SetModified();
- return true;
-}
-
-bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos,
- SwMoveFlags eMvFlags )
-{
- // Moves all Nodes to the new position.
- // Bookmarks are moved too (currently without Undo support).
-
- // If footnotes are being moved to the special section, remove them now.
-
- // Or else delete the Frames for all footnotes that are being moved
- // and have it rebuild after the Move (footnotes can change pages).
- // Additionally we have to correct the FtnIdx array's sorting.
- bool bUpdateFtn = false;
- SwFtnIdxs aTmpFntIdx;
-
- SwUndoMove* pUndo = 0;
- if ((DOC_CREATEUNDOOBJ & eMvFlags ) && GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoMove( this, rRange, rPos );
- }
- else
- {
- bUpdateFtn = lcl_SaveFtn( rRange.aStart, rRange.aEnd, rPos,
- GetFtnIdxs(), aTmpFntIdx );
- }
-
- _SaveRedlines aSaveRedl;
- std::vector<SwRangeRedline*> aSavRedlInsPosArr;
- if( DOC_MOVEREDLINES & eMvFlags && !GetRedlineTbl().empty() )
- {
- lcl_SaveRedlines( rRange, aSaveRedl );
-
- // Find all RedLines that end at the InsPos.
- // These have to be moved back to the "old" position after the Move.
- sal_uInt16 nRedlPos = GetRedlinePos( rPos.GetNode(), USHRT_MAX );
- if( USHRT_MAX != nRedlPos )
- {
- const SwPosition *pRStt, *pREnd;
- do {
- SwRangeRedline* pTmp = GetRedlineTbl()[ nRedlPos ];
- pRStt = pTmp->Start();
- pREnd = pTmp->End();
- if( pREnd->nNode == rPos && pRStt->nNode < rPos )
- {
- aSavRedlInsPosArr.push_back( pTmp );
- }
- } while( pRStt->nNode < rPos && ++nRedlPos < GetRedlineTbl().size());
- }
- }
-
- // Copy all Bookmarks that are within the Move range into an array
- // that stores all references to positions as an offset.
- // The final mapping happens after the Move.
- ::std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
- _DelBookmarks(rRange.aStart, rRange.aEnd, &aSaveBkmks);
-
- // Save the paragraph-bound Flys, so that they can be moved.
- _SaveFlyArr aSaveFlyArr;
- if( !GetSpzFrmFmts()->empty() )
- _SaveFlyInRange( rRange, aSaveFlyArr );
-
- // Set it to before the Position, so that it cannot be moved further.
- SwNodeIndex aIdx( rPos, -1 );
-
- SwNodeIndex* pSaveInsPos = 0;
- if( pUndo )
- pSaveInsPos = new SwNodeIndex( rRange.aStart, -1 );
-
- // move the Nodes
- bool bNoDelFrms = 0 != (DOC_NO_DELFRMS & eMvFlags);
- if( GetNodes()._MoveNodes( rRange, GetNodes(), rPos, !bNoDelFrms ) )
- {
- ++aIdx; // again back to old position
- if( pSaveInsPos )
- ++(*pSaveInsPos);
- }
- else
- {
- aIdx = rRange.aStart;
- delete pUndo, pUndo = 0;
- }
-
- // move the Flys to the new position
- if( !aSaveFlyArr.empty() )
- _RestFlyInRange( aSaveFlyArr, aIdx, NULL );
-
- // Add the Bookmarks back to the Document
- for(
- ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin();
- pBkmk != aSaveBkmks.end();
- ++pBkmk)
- pBkmk->SetInDoc(this, aIdx);
-
- if( !aSavRedlInsPosArr.empty() )
- {
- SwNode* pNewNd = &aIdx.GetNode();
- for( sal_uInt16 n = 0; n < aSavRedlInsPosArr.size(); ++n )
- {
- SwRangeRedline* pTmp = aSavRedlInsPosArr[ n ];
- if( GetRedlineTbl().Contains( pTmp ) )
- {
- SwPosition* pEnd = pTmp->End();
- pEnd->nNode = aIdx;
- pEnd->nContent.Assign( pNewNd->GetCntntNode(), 0 );
- }
- }
- }
-
- if( !aSaveRedl.empty() )
- lcl_RestoreRedlines( this, aIdx.GetIndex(), aSaveRedl );
-
- if( pUndo )
- {
- pUndo->SetDestRange( aIdx, rPos, *pSaveInsPos );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- delete pSaveInsPos;
-
- if( bUpdateFtn )
- {
- if( !aTmpFntIdx.empty() )
- {
- GetFtnIdxs().insert( aTmpFntIdx );
- aTmpFntIdx.clear();
- }
-
- GetFtnIdxs().UpdateAllFtn();
- }
-
- SetModified();
- return true;
-}
-
/// Convert list of ranges of whichIds to a corresponding list of whichIds
static std::vector<sal_uInt16> * lcl_RangesToVector(sal_uInt16 * pRanges)
{
@@ -1229,24 +294,6 @@ static std::vector<sal_uInt16> * lcl_RangesToVector(sal_uInt16 * pRanges)
return pResult;
}
-static bool lcl_StrLenOverflow( const SwPaM& rPam )
-{
- // If we try to merge two paragraphs we have to test if afterwards
- // the string doesn't exceed the allowed string length
- if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode )
- {
- const SwPosition* pStt = rPam.Start(), *pEnd = rPam.End();
- const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode();
- if( (0 != pEndNd) && pStt->nNode.GetNode().IsTxtNode() )
- {
- const sal_uInt64 nSum = pStt->nContent.GetIndex() +
- pEndNd->GetTxt().getLength() - pEnd->nContent.GetIndex();
- return nSum > static_cast<sal_uInt64>(SAL_MAX_INT32);
- }
- }
- return false;
-}
-
void sw_GetJoinFlags( SwPaM& rPam, bool& rJoinTxt, bool& rJoinPrev )
{
rJoinTxt = false;
@@ -1403,375 +450,6 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
}
}
-static void
-lcl_CalcBreaks( ::std::vector<sal_Int32> & rBreaks, SwPaM const & rPam )
-{
- SwTxtNode const * const pTxtNode(
- rPam.End()->nNode.GetNode().GetTxtNode() );
- if (!pTxtNode)
- return; // left-overlap only possible at end of selection...
-
- const sal_Int32 nStart(rPam.Start()->nContent.GetIndex());
- const sal_Int32 nEnd (rPam.End ()->nContent.GetIndex());
- if (nEnd == pTxtNode->Len())
- return; // paragraph selected until the end
-
- for (sal_Int32 i = nStart; i < nEnd; ++i)
- {
- const sal_Unicode c(pTxtNode->GetTxt()[i]);
- if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c))
- {
- SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) );
- if (pAttr && pAttr->End() && (*pAttr->End() > nEnd))
- {
- OSL_ENSURE(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?");
- rBreaks.push_back(i);
- }
- }
- }
-}
-
-static bool lcl_DoWithBreaks(SwDoc & rDoc, SwPaM & rPam,
- bool (SwDoc::*pFunc)(SwPaM&, bool), const bool bForceJoinNext = false)
-{
- ::std::vector<sal_Int32> Breaks;
-
- lcl_CalcBreaks(Breaks, rPam);
-
- if (!Breaks.size())
- {
- return (rDoc.*pFunc)(rPam, bForceJoinNext);
- }
-
- // Deletion must be split into several parts if the text node
- // contains a text attribute with end and with dummy character
- // and the selection does not contain the text attribute completely,
- // but overlaps its start (left), where the dummy character is.
-
- SwPosition const & rSelectionEnd( *rPam.End() );
-
- bool bRet( true );
- // iterate from end to start, to avoid invalidating the offsets!
- ::std::vector<sal_Int32>::reverse_iterator iter( Breaks.rbegin() );
- SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node!
- SwPosition & rEnd( *aPam.End() );
- SwPosition & rStart( *aPam.Start() );
-
- while (iter != Breaks.rend())
- {
- rStart.nContent = *iter + 1;
- if (rEnd.nContent > rStart.nContent) // check if part is empty
- {
- bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext);
- }
- rEnd.nContent = *iter;
- ++iter;
- }
-
- rStart = *rPam.Start(); // set to original start
- if (rEnd.nContent > rStart.nContent) // check if part is empty
- {
- bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext);
- }
-
- return bRet;
-}
-
-bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool )
-{
- OSL_ENSURE( IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" );
-
- {
- SwUndoRedlineDelete* pUndo = 0;
- RedlineMode_t eOld = GetRedlineMode();
- checkRedlining( eOld );
- if (GetIDocumentUndoRedo().DoesUndo())
- {
-
- /* please don't translate -- for cultural reasons this comment is protected
- until the redline implementation is finally fixed some day */
- //JP 06.01.98: MUSS noch optimiert werden!!!
- SetRedlineMode(
- (RedlineMode_t) ( nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ) );
-
- GetIDocumentUndoRedo().StartUndo( UNDO_DELETE, NULL );
- pUndo = new SwUndoRedlineDelete( rPam, UNDO_DELETE );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
-
- if ( *rPam.GetPoint() != *rPam.GetMark() )
- AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, rPam ), true );
- SetModified();
-
- if ( pUndo )
- {
- GetIDocumentUndoRedo().EndUndo( UNDO_EMPTY, NULL );
- // ??? why the hell is the AppendUndo not below the
- // CanGrouping, so this hideous cleanup wouldn't be necessary?
- // bah, this is redlining, probably changing this would break it...
- if ( GetIDocumentUndoRedo().DoesGroupUndo() )
- {
- SwUndo * const pLastUndo( GetUndoManager().GetLastUndo() );
- SwUndoRedlineDelete * const pUndoRedlineDel( dynamic_cast< SwUndoRedlineDelete* >( pLastUndo ) );
- if ( pUndoRedlineDel )
- {
- bool const bMerged = pUndoRedlineDel->CanGrouping( *pUndo );
- if ( bMerged )
- {
- ::sw::UndoGuard const undoGuard( GetIDocumentUndoRedo() );
- SwUndo const* const pDeleted = GetUndoManager().RemoveLastUndo();
- OSL_ENSURE( pDeleted == pUndo, "DeleteAndJoinWithRedlineImpl: "
- "undo removed is not undo inserted?" );
- delete pDeleted;
- }
- }
- }
- //JP 06.01.98: MUSS noch optimiert werden!!!
- SetRedlineMode( eOld );
- }
- return true;
- }
-}
-
-bool SwDoc::DeleteAndJoinImpl( SwPaM & rPam,
- const bool bForceJoinNext )
-{
- bool bJoinTxt, bJoinPrev;
- sw_GetJoinFlags( rPam, bJoinTxt, bJoinPrev );
- // #i100466#
- if ( bForceJoinNext )
- {
- bJoinPrev = false;
- }
-
- {
- bool const bSuccess( DeleteRangeImpl( rPam ) );
- if (!bSuccess)
- return false;
- }
-
- if( bJoinTxt )
- {
- sw_JoinText( rPam, bJoinPrev );
- }
-
- return true;
-}
-
-bool SwDoc::DeleteRangeImpl(SwPaM & rPam, const bool)
-{
- // Move all cursors out of the deleted range, but first copy the
- // passed PaM, because it could be a cursor that would be moved!
- SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
- ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() );
-
- bool const bSuccess( DeleteRangeImplImpl( aDelPam ) );
- if (bSuccess)
- { // now copy position from temp copy to given PaM
- *rPam.GetPoint() = *aDelPam.GetPoint();
- }
-
- return bSuccess;
-}
-
-bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam)
-{
- SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End();
-
- if( !rPam.HasMark() || *pStt >= *pEnd )
- return false;
-
- if( mpACEWord )
- {
- // if necessary the saved Word for the exception
- if( mpACEWord->IsDeleted() || pStt->nNode != pEnd->nNode ||
- pStt->nContent.GetIndex() + 1 != pEnd->nContent.GetIndex() ||
- !mpACEWord->CheckDelChar( *pStt ))
- delete mpACEWord, mpACEWord = 0;
- }
-
- {
- // Delete all empty TextHints at the Mark's position
- SwTxtNode* pTxtNd = rPam.GetMark()->nNode.GetNode().GetTxtNode();
- SwpHints* pHts;
- if( pTxtNd && 0 != ( pHts = pTxtNd->GetpSwpHints()) && pHts->Count() )
- {
- const sal_Int32 *pEndIdx;
- const sal_Int32 nMkCntPos = rPam.GetMark()->nContent.GetIndex();
- for( sal_uInt16 n = pHts->Count(); n; )
- {
- const SwTxtAttr* pAttr = (*pHts)[ --n ];
- if( nMkCntPos > pAttr->GetStart() )
- break;
-
- if( nMkCntPos == pAttr->GetStart() &&
- 0 != (pEndIdx = pAttr->End()) &&
- *pEndIdx == pAttr->GetStart() )
- pTxtNd->DestroyAttr( pHts->Cut( n ) );
- }
- }
- }
-
- {
- // Send DataChanged before deletion, so that we still know
- // which objects are in the range.
- // Afterwards they could be before/after the Position.
- SwDataChanged aTmp( rPam );
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- bool bMerged(false);
- if (GetIDocumentUndoRedo().DoesGroupUndo())
- {
- SwUndo *const pLastUndo( GetUndoManager().GetLastUndo() );
- SwUndoDelete *const pUndoDelete(
- dynamic_cast<SwUndoDelete *>(pLastUndo) );
- if (pUndoDelete)
- {
- bMerged = pUndoDelete->CanGrouping( this, rPam );
- // if CanGrouping() returns true it's already merged
- }
- }
- if (!bMerged)
- {
- GetIDocumentUndoRedo().AppendUndo( new SwUndoDelete( rPam ) );
- }
-
- SetModified();
-
- return true;
- }
-
- if( !IsIgnoreRedline() && !GetRedlineTbl().empty() )
- DeleteRedline( rPam, true, USHRT_MAX );
-
- // Delete and move all "Flys at the paragraph", which are within the Selection
- DelFlyInRange(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
- _DelBookmarks(
- pStt->nNode,
- pEnd->nNode,
- NULL,
- &pStt->nContent,
- &pEnd->nContent);
-
- SwNodeIndex aSttIdx( pStt->nNode );
- SwCntntNode * pCNd = aSttIdx.GetNode().GetCntntNode();
-
- do { // middle checked loop!
- if( pCNd )
- {
- SwTxtNode * pStartTxtNode( pCNd->GetTxtNode() );
- if ( pStartTxtNode )
- {
- // now move the Content to the new Node
- bool bOneNd = pStt->nNode == pEnd->nNode;
- const sal_Int32 nLen = ( bOneNd ? pEnd->nContent.GetIndex()
- : pCNd->Len() )
- - pStt->nContent.GetIndex();
-
- // Don't call again, if already empty
- if( nLen )
- {
- pStartTxtNode->EraseText( pStt->nContent, nLen );
-
- if( !pStartTxtNode->Len() )
- {
- // METADATA: remove reference if empty (consider node deleted)
- pStartTxtNode->RemoveMetadataReference();
- }
- }
-
- if( bOneNd ) // that's it
- break;
-
- ++aSttIdx;
- }
- else
- {
- // So that there are no indices left registered when deleted,
- // we remove a SwPaM from the Content here.
- pStt->nContent.Assign( 0, 0 );
- }
- }
-
- pCNd = pEnd->nNode.GetNode().GetCntntNode();
- if( pCNd )
- {
- SwTxtNode * pEndTxtNode( pCNd->GetTxtNode() );
- if( pEndTxtNode )
- {
- // if already empty, don't call again
- if( pEnd->nContent.GetIndex() )
- {
- SwIndex aIdx( pCNd, 0 );
- pEndTxtNode->EraseText( aIdx, pEnd->nContent.GetIndex() );
-
- if( !pEndTxtNode->Len() )
- {
- // METADATA: remove reference if empty (consider node deleted)
- pEndTxtNode->RemoveMetadataReference();
- }
- }
- }
- else
- {
- // So that there are no indices left registered when deleted,
- // we remove a SwPaM from the Content here.
- pEnd->nContent.Assign( 0, 0 );
- }
- }
-
- // if the end is not a content node, delete it as well
- sal_uInt32 nEnde = pEnd->nNode.GetIndex();
- if( pCNd == NULL )
- nEnde++;
-
- if( aSttIdx != nEnde )
- {
- // delete the Nodes into the NodesArary
- GetNodes().Delete( aSttIdx, nEnde - aSttIdx.GetIndex() );
- }
-
- // If the Node that contained the Cursor has been deleted,
- // the Content has to be assigned to the current Content.
- pStt->nContent.Assign( pStt->nNode.GetNode().GetCntntNode(),
- pStt->nContent.GetIndex() );
-
- // If we deleted across Node boundaries we have to correct the PaM,
- // because they are in different Nodes now.
- // Also, the Selection is revoked.
- *pEnd = *pStt;
- rPam.DeleteMark();
-
- } while( false );
-
- if( !IsIgnoreRedline() && !GetRedlineTbl().empty() )
- CompressRedlines();
- SetModified();
-
- return true;
-}
-
-// #i100466# Add handling of new optional parameter <bForceJoinNext>
-bool SwDoc::DeleteAndJoin( SwPaM & rPam,
- const bool bForceJoinNext )
-{
- if ( lcl_StrLenOverflow( rPam ) )
- return false;
-
- return lcl_DoWithBreaks( *this, rPam, (IsRedlineOn())
- ? &SwDoc::DeleteAndJoinWithRedlineImpl
- : &SwDoc::DeleteAndJoinImpl,
- bForceJoinNext );
-}
-
-bool SwDoc::DeleteRange( SwPaM & rPam )
-{
- return lcl_DoWithBreaks( *this, rPam, &SwDoc::DeleteRangeImpl );
-}
-
static void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& rResult,
const ModelToViewHelper &rConversionMap )
{
@@ -2106,356 +784,6 @@ uno::Reference< XHyphenatedWord > SwDoc::Hyphenate(
return aHyphArg.GetHyphWord(); // will be set by lcl_HyphenateNode
}
-static bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet, bool bRegExpRplc )
-{
- if( bRegExpRplc )
- {
- sal_Int32 nPos = 0;
- const OUString sPara("\\n");
- for (;;)
- {
- nPos = rStr.indexOf( sPara, nPos );
- if (nPos<0)
- {
- break;
- }
- // Has this been escaped?
- if( nPos && '\\' == rStr[nPos-1])
- {
- ++nPos;
- if( nPos >= rStr.getLength() )
- {
- break;
- }
- }
- else
- {
- rRet = rStr.copy( 0, nPos );
- rStr = rStr.copy( nPos + sPara.getLength() );
- return true;
- }
- }
- }
- rRet = rStr;
- rStr = OUString();
- return false;
-}
-
-bool SwDoc::ReplaceRange( SwPaM& rPam, const OUString& rStr,
- const bool bRegExReplace )
-{
- // unfortunately replace works slightly differently from delete,
- // so we cannot use lcl_DoWithBreaks here...
-
- ::std::vector<sal_Int32> Breaks;
-
- SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
- aPam.Normalize(false);
- if (aPam.GetPoint()->nNode != aPam.GetMark()->nNode)
- {
- aPam.Move(fnMoveBackward);
- }
- OSL_ENSURE((aPam.GetPoint()->nNode == aPam.GetMark()->nNode), "invalid pam?");
-
- lcl_CalcBreaks(Breaks, aPam);
-
- while (!Breaks.empty() // skip over prefix of dummy chars
- && (aPam.GetMark()->nContent.GetIndex() == *Breaks.begin()) )
- {
- // skip!
- ++aPam.GetMark()->nContent; // always in bounds if Breaks valid
- Breaks.erase(Breaks.begin());
- }
- *rPam.Start() = *aPam.GetMark(); // update start of original pam w/ prefix
-
- if (!Breaks.size())
- {
- // park aPam somewhere so it does not point to node that is deleted
- aPam.DeleteMark();
- *aPam.GetPoint() = SwPosition(GetNodes().GetEndOfContent());
- return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam!
- }
-
- // Deletion must be split into several parts if the text node
- // contains a text attribute with end and with dummy character
- // and the selection does not contain the text attribute completely,
- // but overlaps its start (left), where the dummy character is.
-
- bool bRet( true );
- // iterate from end to start, to avoid invalidating the offsets!
- ::std::vector<sal_Int32>::reverse_iterator iter( Breaks.rbegin() );
- OSL_ENSURE(aPam.GetPoint() == aPam.End(), "wrong!");
- SwPosition & rEnd( *aPam.End() );
- SwPosition & rStart( *aPam.Start() );
-
- // set end of temp pam to original end (undo Move backward above)
- rEnd = *rPam.End();
- // after first deletion, rEnd will point into the original text node again!
-
- while (iter != Breaks.rend())
- {
- rStart.nContent = *iter + 1;
- if (rEnd.nContent != rStart.nContent) // check if part is empty
- {
- bRet &= (IsRedlineOn())
- ? DeleteAndJoinWithRedlineImpl(aPam)
- : DeleteAndJoinImpl(aPam, false);
- }
- rEnd.nContent = *iter;
- ++iter;
- }
-
- rStart = *rPam.Start(); // set to original start
- OSL_ENSURE(rEnd.nContent > rStart.nContent, "replace part empty!");
- if (rEnd.nContent > rStart.nContent) // check if part is empty
- {
- bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace);
- }
-
- rPam = aPam; // update original pam (is this required?)
-
- return bRet;
-}
-
-// It's possible to call Replace with a PaM that spans 2 paragraphs:
-// search with regex for "$", then replace _all_
-bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const OUString& rStr,
- const bool bRegExReplace )
-{
- if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() )
- return false;
-
- bool bJoinTxt, bJoinPrev;
- sw_GetJoinFlags( rPam, bJoinTxt, bJoinPrev );
-
- {
- // Create a copy of the Cursor in order to move all Pams from
- // the other views out of the deletion range.
- // Except for itself!
- SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
- ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() );
-
- SwPosition *pStt = (SwPosition*)aDelPam.Start(),
- *pEnd = (SwPosition*)aDelPam.End();
- OSL_ENSURE( pStt->nNode == pEnd->nNode ||
- ( pStt->nNode.GetIndex() + 1 == pEnd->nNode.GetIndex() &&
- !pEnd->nContent.GetIndex() ),
- "invalid range: Point and Mark on different nodes" );
- bool bOneNode = pStt->nNode == pEnd->nNode;
-
- // Own Undo?
- OUString sRepl( rStr );
- SwTxtNode* pTxtNd = pStt->nNode.GetNode().GetTxtNode();
- sal_Int32 nStt = pStt->nContent.GetIndex();
- sal_Int32 nEnd = bOneNode ? pEnd->nContent.GetIndex()
- : pTxtNd->GetTxt().getLength();
-
- SwDataChanged aTmp( aDelPam );
-
- if( IsRedlineOn() )
- {
- RedlineMode_t eOld = GetRedlineMode();
- checkRedlining(eOld);
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
-
- // If any Redline will change (split!) the node
- const ::sw::mark::IMark* pBkmk = getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
-
- //JP 06.01.98: MUSS noch optimiert werden!!!
- SetRedlineMode(
- (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE ));
-
- *aDelPam.GetPoint() = pBkmk->GetMarkPos();
- if(pBkmk->IsExpanded())
- *aDelPam.GetMark() = pBkmk->GetOtherMarkPos();
- getIDocumentMarkAccess()->deleteMark(pBkmk);
- pStt = aDelPam.Start();
- pTxtNd = pStt->nNode.GetNode().GetTxtNode();
- nStt = pStt->nContent.GetIndex();
- }
-
- if( !sRepl.isEmpty() )
- {
- // Apply the first character's attributes to the ReplaceText
- SfxItemSet aSet( GetAttrPool(),
- RES_CHRATR_BEGIN, RES_TXTATR_WITHEND_END - 1,
- RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
- 0 );
- pTxtNd->GetAttr( aSet, nStt+1, nStt+1 );
-
- aSet.ClearItem( RES_TXTATR_REFMARK );
- aSet.ClearItem( RES_TXTATR_TOXMARK );
- aSet.ClearItem( RES_TXTATR_CJK_RUBY );
- aSet.ClearItem( RES_TXTATR_INETFMT );
- aSet.ClearItem( RES_TXTATR_META );
- aSet.ClearItem( RES_TXTATR_METAFIELD );
-
- if( aDelPam.GetPoint() != aDelPam.End() )
- aDelPam.Exchange();
-
- // Remember the End
- SwNodeIndex aPtNd( aDelPam.GetPoint()->nNode, -1 );
- const sal_Int32 nPtCnt = aDelPam.GetPoint()->nContent.GetIndex();
-
- bool bFirst = true;
- OUString sIns;
- while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
- {
- InsertString( aDelPam, sIns );
- if( bFirst )
- {
- SwNodeIndex aMkNd( aDelPam.GetMark()->nNode, -1 );
- const sal_Int32 nMkCnt = aDelPam.GetMark()->nContent.GetIndex();
-
- SplitNode( *aDelPam.GetPoint(), false );
-
- ++aMkNd;
- aDelPam.GetMark()->nNode = aMkNd;
- aDelPam.GetMark()->nContent.Assign(
- aMkNd.GetNode().GetCntntNode(), nMkCnt );
- bFirst = false;
- }
- else
- SplitNode( *aDelPam.GetPoint(), false );
- }
- if( !sIns.isEmpty() )
- {
- InsertString( aDelPam, sIns );
- }
-
- SwPaM aTmpRange( *aDelPam.GetPoint() );
- aTmpRange.SetMark();
-
- ++aPtNd;
- aDelPam.GetPoint()->nNode = aPtNd;
- aDelPam.GetPoint()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
- nPtCnt);
- *aTmpRange.GetMark() = *aDelPam.GetPoint();
-
- RstTxtAttrs( aTmpRange );
- InsertItemSet( aTmpRange, aSet, 0 );
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndo *const pUndoRD =
- new SwUndoRedlineDelete( aDelPam, UNDO_REPLACE );
- GetIDocumentUndoRedo().AppendUndo(pUndoRD);
- }
- AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_DELETE, aDelPam ), true);
-
- *rPam.GetMark() = *aDelPam.GetMark();
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- *aDelPam.GetPoint() = *rPam.GetPoint();
- GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
-
- // If any Redline will change (split!) the node
- const ::sw::mark::IMark* pBkmk = getIDocumentMarkAccess()->makeMark( aDelPam, OUString(), IDocumentMarkAccess::UNO_BOOKMARK );
-
- SwIndex& rIdx = aDelPam.GetPoint()->nContent;
- rIdx.Assign( 0, 0 );
- aDelPam.GetMark()->nContent = rIdx;
- rPam.GetPoint()->nNode = 0;
- rPam.GetPoint()->nContent = rIdx;
- *rPam.GetMark() = *rPam.GetPoint();
-//JP 06.01.98: MUSS noch optimiert werden!!!
-SetRedlineMode( eOld );
-
- *rPam.GetPoint() = pBkmk->GetMarkPos();
- if(pBkmk->IsExpanded())
- *rPam.GetMark() = pBkmk->GetOtherMarkPos();
- getIDocumentMarkAccess()->deleteMark(pBkmk);
- }
- bJoinTxt = false;
- }
- else
- {
- if( !IsIgnoreRedline() && GetRedlineTbl().size() )
- DeleteRedline( aDelPam, true, USHRT_MAX );
-
- SwUndoReplace* pUndoRpl = 0;
- bool const bDoesUndo = GetIDocumentUndoRedo().DoesUndo();
- if (bDoesUndo)
- {
- pUndoRpl = new SwUndoReplace(aDelPam, sRepl, bRegExReplace);
- GetIDocumentUndoRedo().AppendUndo(pUndoRpl);
- }
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- if( aDelPam.GetPoint() != pStt )
- aDelPam.Exchange();
-
- SwNodeIndex aPtNd( pStt->nNode, -1 );
- const sal_Int32 nPtCnt = pStt->nContent.GetIndex();
-
- // Set the values again, if Frames or footnotes on the Text have been removed.
- nStt = nPtCnt;
- nEnd = bOneNode ? pEnd->nContent.GetIndex()
- : pTxtNd->GetTxt().getLength();
-
- bool bFirst = true;
- OUString sIns;
- while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
- {
- if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
- {
- InsertString( aDelPam, sIns );
- }
- else if( nStt < nEnd || !sIns.isEmpty() )
- {
- pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
- }
- SplitNode( *pStt, false);
- bFirst = false;
- }
-
- if( bFirst || !sIns.isEmpty() )
- {
- if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
- {
- InsertString( aDelPam, sIns );
- }
- else if( nStt < nEnd || !sIns.isEmpty() )
- {
- pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
- }
- }
-
- *rPam.GetPoint() = *aDelPam.GetMark();
- ++aPtNd;
- rPam.GetMark()->nNode = aPtNd;
- rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(),
- nPtCnt );
-
- if (bJoinTxt)
- {
- assert(rPam.GetPoint() == rPam.End());
- // move so that SetEnd remembers position after sw_JoinText
- rPam.Move(fnMoveBackward);
- }
- else if (aDelPam.GetPoint() == pStt) // backward selection?
- {
- assert(*rPam.GetMark() <= *rPam.GetPoint());
- rPam.Exchange(); // swap so that rPam is backwards
- }
-
- if( pUndoRpl )
- {
- pUndoRpl->SetEnd(rPam);
- }
- }
- }
-
- if( bJoinTxt )
- sw_JoinText( rPam, bJoinPrev );
-
- SetModified();
- return true;
-}
-
// Save the current values to add them as automatic entries to to AutoCorrect.
void SwDoc::SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew )
{
@@ -2464,218 +792,10 @@ void SwDoc::SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew )
mpACEWord = pNew;
}
-bool SwDoc::DelFullPara( SwPaM& rPam )
-{
- const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
- const SwNode* pNd = &rStt.nNode.GetNode();
- sal_uInt32 nSectDiff = pNd->StartOfSectionNode()->EndOfSectionIndex() -
- pNd->StartOfSectionIndex();
- sal_uInt32 nNodeDiff = rEnd.nNode.GetIndex() - rStt.nNode.GetIndex();
-
- if ( nSectDiff-2 <= nNodeDiff || IsRedlineOn() ||
- /* #i9185# Prevent getting the node after the end node (see below) */
- rEnd.nNode.GetIndex() + 1 == GetNodes().Count() )
- {
- return false;
- }
-
- // Move hard page brakes to the following Node.
- bool bSavePageBreak = false, bSavePageDesc = false;
-
- /* #i9185# This whould lead to a segmentation fault if not caught above. */
- sal_uLong nNextNd = rEnd.nNode.GetIndex() + 1;
- SwTableNode *const pTblNd = GetNodes()[ nNextNd ]->GetTableNode();
-
- if( pTblNd && pNd->IsCntntNode() )
- {
- SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
-
- {
- const SfxPoolItem *pItem;
- const SfxItemSet* pSet = ((SwCntntNode*)pNd)->GetpSwAttrSet();
- if( pSet && SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC,
- false, &pItem ) )
- {
- pTableFmt->SetFmtAttr( *pItem );
- bSavePageDesc = true;
- }
-
- if( pSet && SFX_ITEM_SET == pSet->GetItemState( RES_BREAK,
- false, &pItem ) )
- {
- pTableFmt->SetFmtAttr( *pItem );
- bSavePageBreak = true;
- }
- }
- }
-
- bool const bDoesUndo = GetIDocumentUndoRedo().DoesUndo();
- if( bDoesUndo )
- {
- if( !rPam.HasMark() )
- rPam.SetMark();
- else if( rPam.GetPoint() == &rStt )
- rPam.Exchange();
- rPam.GetPoint()->nNode++;
-
- SwCntntNode *pTmpNode = rPam.GetPoint()->nNode.GetNode().GetCntntNode();
- rPam.GetPoint()->nContent.Assign( pTmpNode, 0 );
- bool bGoNext = (0 == pTmpNode);
- pTmpNode = rPam.GetMark()->nNode.GetNode().GetCntntNode();
- rPam.GetMark()->nContent.Assign( pTmpNode, 0 );
-
- GetIDocumentUndoRedo().ClearRedo();
-
- SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() );
- {
- SwPosition aTmpPos( *aDelPam.GetPoint() );
- if( bGoNext )
- {
- pTmpNode = GetNodes().GoNext( &aTmpPos.nNode );
- aTmpPos.nContent.Assign( pTmpNode, 0 );
- }
- ::PaMCorrAbs( aDelPam, aTmpPos );
- }
-
- SwUndoDelete* pUndo = new SwUndoDelete( aDelPam, true );
-
- *rPam.GetPoint() = *aDelPam.GetPoint();
- pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- else
- {
- SwNodeRange aRg( rStt.nNode, rEnd.nNode );
- if( rPam.GetPoint() != &rEnd )
- rPam.Exchange();
-
- // Try to move past the End
- if( !rPam.Move( fnMoveForward, fnGoNode ) )
- {
- // Fair enough, at the Beginning then
- rPam.Exchange();
- if( !rPam.Move( fnMoveBackward, fnGoNode ))
- {
- OSL_FAIL( "no more Nodes" );
- return false;
- }
- }
- // move bookmarks, redlines etc.
- if (aRg.aStart == aRg.aEnd) // only first CorrAbs variant handles this
- {
- CorrAbs( aRg.aStart, *rPam.GetPoint(), 0, true );
- }
- else
- {
- CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), true );
- }
-
- // What's with Flys?
- {
- // If there are FlyFrames left, delete these too
- for( sal_uInt16 n = 0; n < GetSpzFrmFmts()->size(); ++n )
- {
- SwFrmFmt* pFly = (*GetSpzFrmFmts())[n];
- const SwFmtAnchor* pAnchor = &pFly->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
- if (pAPos &&
- ((FLY_AT_PARA == pAnchor->GetAnchorId()) ||
- (FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
- aRg.aStart <= pAPos->nNode && pAPos->nNode <= aRg.aEnd )
- {
- DelLayoutFmt( pFly );
- --n;
- }
- }
- }
-
- SwCntntNode *pTmpNode = rPam.GetBound( true ).nNode.GetNode().GetCntntNode();
- rPam.GetBound( true ).nContent.Assign( pTmpNode, 0 );
- pTmpNode = rPam.GetBound( false ).nNode.GetNode().GetCntntNode();
- rPam.GetBound( false ).nContent.Assign( pTmpNode, 0 );
- GetNodes().Delete( aRg.aStart, nNodeDiff+1 );
- }
- rPam.DeleteMark();
- SetModified();
-
- return true;
-}
-
-void SwDoc::TransliterateText(
- const SwPaM& rPaM,
- utl::TransliterationWrapper& rTrans )
+void SwDoc::DeleteAutoCorrExceptWord()
{
- SwUndoTransliterate *const pUndo = (GetIDocumentUndoRedo().DoesUndo())
- ? new SwUndoTransliterate( rPaM, rTrans )
- : 0;
-
- const SwPosition* pStt = rPaM.Start(),
- * pEnd = rPaM.End();
- sal_uLong nSttNd = pStt->nNode.GetIndex(),
- nEndNd = pEnd->nNode.GetIndex();
- sal_Int32 nSttCnt = pStt->nContent.GetIndex();
- sal_Int32 nEndCnt = pEnd->nContent.GetIndex();
-
- SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
- if( pStt == pEnd && pTNd ) // no selection?
- {
- // set current word as 'area of effect'
-
- Boundary aBndry;
- if( g_pBreakIt->GetBreakIter().is() )
- aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
- pTNd->GetTxt(), nSttCnt,
- g_pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ),
- WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
- sal_True );
-
- if( aBndry.startPos < nSttCnt && nSttCnt < aBndry.endPos )
- {
- nSttCnt = aBndry.startPos;
- nEndCnt = aBndry.endPos;
- }
- }
-
- if( nSttNd != nEndNd ) // is more than one text node involved?
- {
- // iterate over all effected text nodes, the first and the last one
- // may be incomplete because the selection starts and/or ends there
-
- SwNodeIndex aIdx( pStt->nNode );
- if( nSttCnt )
- {
- ++aIdx;
- if( pTNd )
- pTNd->TransliterateText(
- rTrans, nSttCnt, pTNd->GetTxt().getLength(), pUndo);
- }
-
- for( ; aIdx.GetIndex() < nEndNd; ++aIdx )
- {
- pTNd = aIdx.GetNode().GetTxtNode();
- if (pTNd)
- {
- pTNd->TransliterateText(
- rTrans, 0, pTNd->GetTxt().getLength(), pUndo);
- }
- }
-
- if( nEndCnt && 0 != ( pTNd = pEnd->nNode.GetNode().GetTxtNode() ))
- pTNd->TransliterateText( rTrans, 0, nEndCnt, pUndo );
- }
- else if( pTNd && nSttCnt < nEndCnt )
- pTNd->TransliterateText( rTrans, nSttCnt, nEndCnt, pUndo );
-
- if( pUndo )
- {
- if( pUndo->HasData() )
- {
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- else
- delete pUndo;
- }
- SetModified();
+ delete mpACEWord;
+ mpACEWord = 0;
}
#define MAX_REDLINE_COUNT 250
@@ -2741,32 +861,5 @@ void SwDoc::CountWords( const SwPaM& rPaM, SwDocStat& rStat ) const
pTNd->CountWords( rStat, nSttCnt, nEndCnt );
}
-void SwDoc::RemoveLeadingWhiteSpace(const SwPosition & rPos )
-{
- const SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
- if ( pTNd )
- {
- const OUString& rTxt = pTNd->GetTxt();
- sal_Int32 nIdx = 0;
- while (nIdx < rTxt.getLength())
- {
- sal_Unicode const cCh = rTxt[nIdx];
- if (('\t' != cCh) && (' ' != cCh))
- {
- break;
- }
- ++nIdx;
- }
-
- if ( nIdx > 0 )
- {
- SwPaM aPam(rPos);
- aPam.GetPoint()->nContent = 0;
- aPam.SetMark();
- aPam.GetMark()->nContent = nIdx;
- DeleteRange( aPam );
- }
- }
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 4795e1e895ca..605349703348 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -37,6 +37,7 @@
#include <frmatr.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <hints.hxx>
@@ -84,78 +85,9 @@ static void SetTxtFmtCollNext( SwTxtFmtColl* pTxtColl, const SwTxtFmtColl* pDel
}
}
-/*
- * Reset the text's hard formatting
- */
-
-/// Parameters for _Rst and lcl_SetTxtFmtColl
-struct ParaRstFmt
-{
- SwFmtColl* pFmtColl;
- SwHistory* pHistory;
- const SwPosition *pSttNd, *pEndNd;
- const SfxItemSet* pDelSet;
- sal_uInt16 nWhich;
- bool bReset;
- bool bResetListAttrs; // #i62575#
- bool bResetAll;
- bool bInclRefToxMark;
-
- ParaRstFmt(const SwPosition* pStt, const SwPosition* pEnd,
- SwHistory* pHst, sal_uInt16 nWhch = 0, const SfxItemSet* pSet = 0)
- : pFmtColl(0)
- , pHistory(pHst)
- , pSttNd(pStt)
- , pEndNd(pEnd)
- , pDelSet(pSet)
- , nWhich(nWhch)
- , bReset(false) // #i62675#
- , bResetListAttrs(false)
- , bResetAll(true)
- , bInclRefToxMark(false)
- {
- }
-};
-
-/** @params pArgs contains the document's ChrFmtTable
- * Is need for selections at the beginning/end and with no SSelection.
- */
-static bool lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs )
-{
- ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
- SwTxtNode * pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
- if( pTxtNode && pTxtNode->GetpSwpHints() )
- {
- SwIndex aSt( pTxtNode, 0 );
- sal_Int32 nEnd = pTxtNode->Len();
-
- if( &pPara->pSttNd->nNode.GetNode() == pTxtNode &&
- pPara->pSttNd->nContent.GetIndex() )
- aSt = pPara->pSttNd->nContent.GetIndex();
-
- if( &pPara->pEndNd->nNode.GetNode() == rpNd )
- nEnd = pPara->pEndNd->nContent.GetIndex();
-
- if( pPara->pHistory )
- {
- // Save all attributes for the Undo.
- SwRegHistory aRHst( *pTxtNode, pPara->pHistory );
- pTxtNode->GetpSwpHints()->Register( &aRHst );
- pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
- pPara->pDelSet, pPara->bInclRefToxMark );
- if( pTxtNode->GetpSwpHints() )
- pTxtNode->GetpSwpHints()->DeRegister();
- }
- else
- pTxtNode->RstTxtAttr( aSt, nEnd - aSt.GetIndex(), pPara->nWhich,
- pPara->pDelSet, pPara->bInclRefToxMark );
- }
- return true;
-}
-
static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
{
- const ParaRstFmt* pPara = (ParaRstFmt*)pArgs;
+ const sw::DocumentContentOperationsManager::ParaRstFmt* pPara = (sw::DocumentContentOperationsManager::ParaRstFmt*)pArgs;
SwCntntNode* pNode = (SwCntntNode*)rpNd->GetCntntNode();
if( pNode && pNode->HasSwAttrSet() )
{
@@ -287,10 +219,10 @@ void SwDoc::RstTxtAttrs(const SwPaM &rRg, bool bInclRefToxMark )
GetIDocumentUndoRedo().AppendUndo(pUndo);
}
const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
- ParaRstFmt aPara( pStt, pEnd, pHst );
+ sw::DocumentContentOperationsManager::ParaRstFmt aPara( pStt, pEnd, pHst );
aPara.bInclRefToxMark = bInclRefToxMark;
GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
- lcl_RstTxtAttr, &aPara );
+ sw::DocumentContentOperationsManager::lcl_RstTxtAttr, &aPara );
SetModified();
}
@@ -370,7 +302,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
}
const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End();
- ParaRstFmt aPara( pStt, pEnd, pHst );
+ sw::DocumentContentOperationsManager::ParaRstFmt aPara( pStt, pEnd, pHst );
// mst: not including META here; it seems attrs with CH_TXTATR are omitted
sal_uInt16 aResetableSetRange[] = {
@@ -453,7 +385,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
{
if( bAdd )
++aTmpEnd;
- GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstTxtAttr, &aPara );
+ GetNodes().ForEach( pStt->nNode, aTmpEnd, sw::DocumentContentOperationsManager::lcl_RstTxtAttr, &aPara );
}
if( pPam != &rRg )
@@ -462,644 +394,6 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
SetModified();
}
-#define DELETECHARSETS if ( bDelete ) { delete pCharSet; delete pOtherSet; }
-
-/// Insert Hints according to content types;
-// Is used in SwDoc::Insert(..., SwFmtHint &rHt)
-
-static bool lcl_InsAttr(
- SwDoc *const pDoc,
- const SwPaM &rRg,
- const SfxItemSet& rChgSet,
- const SetAttrMode nFlags,
- SwUndoAttr *const pUndo,
- const bool bExpandCharToPara=false)
-{
- // Divide the Sets (for selections in Nodes)
- const SfxItemSet* pCharSet = 0;
- const SfxItemSet* pOtherSet = 0;
- bool bDelete = false;
- bool bCharAttr = false;
- bool bOtherAttr = false;
-
- // Check, if we can work with rChgSet or if we have to create additional SfxItemSets
- if ( 1 == rChgSet.Count() )
- {
- SfxItemIter aIter( rChgSet );
- const SfxPoolItem* pItem = aIter.FirstItem();
- if (!IsInvalidItem(pItem))
- {
- const sal_uInt16 nWhich = pItem->Which();
-
- if ( isCHRATR(nWhich) ||
- (RES_TXTATR_CHARFMT == nWhich) ||
- (RES_TXTATR_INETFMT == nWhich) ||
- (RES_TXTATR_AUTOFMT == nWhich) ||
- (RES_TXTATR_UNKNOWN_CONTAINER == nWhich) )
- {
- pCharSet = &rChgSet;
- bCharAttr = true;
- }
-
- if ( isPARATR(nWhich)
- || isPARATR_LIST(nWhich)
- || isFRMATR(nWhich)
- || isGRFATR(nWhich)
- || isUNKNOWNATR(nWhich)
- || isDrawingLayerAttribute(nWhich) ) //UUUU
- {
- pOtherSet = &rChgSet;
- bOtherAttr = true;
- }
- }
- }
-
- // Build new itemset if either
- // - rChgSet.Count() > 1 or
- // - The attribute in rChgSet does not belong to one of the above categories
- if ( !bCharAttr && !bOtherAttr )
- {
- SfxItemSet* pTmpCharItemSet = new SfxItemSet( pDoc->GetAttrPool(),
- RES_CHRATR_BEGIN, RES_CHRATR_END-1,
- RES_TXTATR_AUTOFMT, RES_TXTATR_AUTOFMT,
- RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
- RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT,
- RES_TXTATR_UNKNOWN_CONTAINER, RES_TXTATR_UNKNOWN_CONTAINER,
- 0 );
-
- SfxItemSet* pTmpOtherItemSet = new SfxItemSet( pDoc->GetAttrPool(),
- RES_PARATR_BEGIN, RES_PARATR_END-1,
- RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
- RES_FRMATR_BEGIN, RES_FRMATR_END-1,
- RES_GRFATR_BEGIN, RES_GRFATR_END-1,
- RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
-
- //UUUU FillAttribute support
- XATTR_FILL_FIRST, XATTR_FILL_LAST,
-
- 0 );
-
- pTmpCharItemSet->Put( rChgSet );
- pTmpOtherItemSet->Put( rChgSet );
-
- pCharSet = pTmpCharItemSet;
- pOtherSet = pTmpOtherItemSet;
-
- bDelete = true;
- }
-
- SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
- bool bRet = false;
- const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
- SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode();
-
- if( pNode && pNode->IsTxtNode() )
- {
- // #i27615#
- if (rRg.IsInFrontOfLabel())
- {
- SwTxtNode * pTxtNd = pNode->GetTxtNode();
- SwNumRule * pNumRule = pTxtNd->GetNumRule();
-
- if ( !pNumRule )
- {
- OSL_FAIL( "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." );
- DELETECHARSETS
- return false;
- }
-
- int nLevel = pTxtNd->GetActualListLevel();
-
- if (nLevel < 0)
- nLevel = 0;
-
- if (nLevel >= MAXLEVEL)
- nLevel = MAXLEVEL - 1;
-
- SwNumFmt aNumFmt = pNumRule->Get(static_cast<sal_uInt16>(nLevel));
- SwCharFmt * pCharFmt =
- pDoc->FindCharFmtByName(aNumFmt.GetCharFmtName());
-
- if (pCharFmt)
- {
- if (pHistory)
- pHistory->Add(pCharFmt->GetAttrSet(), *pCharFmt);
-
- if ( pCharSet )
- pCharFmt->SetFmtAttr(*pCharSet);
- }
-
- DELETECHARSETS
- return true;
- }
-
- const SwIndex& rSt = pStt->nContent;
-
- // Attributes without an end do not have a range
- if ( !bCharAttr && !bOtherAttr )
- {
- SfxItemSet aTxtSet( pDoc->GetAttrPool(),
- RES_TXTATR_NOEND_BEGIN, RES_TXTATR_NOEND_END-1 );
- aTxtSet.Put( rChgSet );
- if( aTxtSet.Count() )
- {
- SwRegHistory history( pNode, *pNode, pHistory );
- bRet = history.InsertItems(
- aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet;
-
- if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
- && !pDoc->GetRedlineTbl().empty())))
- {
- SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1,
- pStt->nNode, pStt->nContent.GetIndex() );
-
- if( pUndo )
- pUndo->SaveRedlineData( aPam, true );
-
- if( pDoc->IsRedlineOn() )
- pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
- else
- pDoc->SplitRedline( aPam );
- }
- }
- }
-
- // TextAttributes with an end never expand their range
- if ( !bCharAttr && !bOtherAttr )
- {
- // CharFmt and URL attributes are treated separately!
- // TEST_TEMP ToDo: AutoFmt!
- SfxItemSet aTxtSet( pDoc->GetAttrPool(),
- RES_TXTATR_REFMARK, RES_TXTATR_TOXMARK,
- RES_TXTATR_META, RES_TXTATR_METAFIELD,
- RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY,
- RES_TXTATR_INPUTFIELD, RES_TXTATR_INPUTFIELD,
- 0 );
-
- aTxtSet.Put( rChgSet );
- if( aTxtSet.Count() )
- {
- const sal_Int32 nInsCnt = rSt.GetIndex();
- const sal_Int32 nEnd = pStt->nNode == pEnd->nNode
- ? pEnd->nContent.GetIndex()
- : pNode->Len();
- SwRegHistory history( pNode, *pNode, pHistory );
- bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags )
- || bRet;
-
- if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline()
- && !pDoc->GetRedlineTbl().empty())))
- {
- // Was text content inserted? (RefMark/TOXMarks without an end)
- bool bTxtIns = nInsCnt != rSt.GetIndex();
- // Was content inserted or set over the selection?
- SwPaM aPam( pStt->nNode, bTxtIns ? nInsCnt + 1 : nEnd,
- pStt->nNode, nInsCnt );
- if( pUndo )
- pUndo->SaveRedlineData( aPam, bTxtIns );
-
- if( pDoc->IsRedlineOn() )
- pDoc->AppendRedline(
- new SwRangeRedline(
- bTxtIns ? nsRedlineType_t::REDLINE_INSERT : nsRedlineType_t::REDLINE_FORMAT, aPam ),
- true);
- else if( bTxtIns )
- pDoc->SplitRedline( aPam );
- }
- }
- }
- }
-
- // We always have to set the auto flag for PageDescs that are set at the Node!
- if( pOtherSet && pOtherSet->Count() )
- {
- SwTableNode* pTblNd;
- const SwFmtPageDesc* pDesc;
- if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PAGEDESC,
- false, (const SfxPoolItem**)&pDesc ))
- {
- if( pNode )
- {
- // Set auto flag. Only in the template it's without auto!
- SwFmtPageDesc aNew( *pDesc );
-
- // Tables now also know line breaks
- if( 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
- 0 != ( pTblNd = pNode->FindTableNode() ) )
- {
- SwTableNode* pCurTblNd = pTblNd;
- while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
- pTblNd = pCurTblNd;
-
- // set the table format
- SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
- SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
- pFmt->SetFmtAttr( aNew );
- bRet = true;
- }
- else
- {
- SwRegHistory aRegH( pNode, *pNode, pHistory );
- bRet = pNode->SetAttr( aNew ) || bRet;
- }
- }
-
- // bOtherAttr = true means that pOtherSet == rChgSet. In this case
- // we know, that there is only one attribute in pOtherSet. We cannot
- // perform the following operations, instead we return:
- if ( bOtherAttr )
- return bRet;
-
- const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC );
- if( !pOtherSet->Count() )
- {
- DELETECHARSETS
- return bRet;
- }
- }
-
- // Tables now also know line breaks
- const SvxFmtBreakItem* pBreak;
- if( pNode && 0 == (nFlags & nsSetAttrMode::SETATTR_APICALL) &&
- 0 != (pTblNd = pNode->FindTableNode() ) &&
- SFX_ITEM_SET == pOtherSet->GetItemState( RES_BREAK,
- false, (const SfxPoolItem**)&pBreak ) )
- {
- SwTableNode* pCurTblNd = pTblNd;
- while ( 0 != ( pCurTblNd = pCurTblNd->StartOfSectionNode()->FindTableNode() ) )
- pTblNd = pCurTblNd;
-
- // set the table format
- SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt();
- SwRegHistory aRegH( pFmt, *pTblNd, pHistory );
- pFmt->SetFmtAttr( *pBreak );
- bRet = true;
-
- // bOtherAttr = true means that pOtherSet == rChgSet. In this case
- // we know, that there is only one attribute in pOtherSet. We cannot
- // perform the following operations, instead we return:
- if ( bOtherAttr )
- return bRet;
-
- const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK );
- if( !pOtherSet->Count() )
- {
- DELETECHARSETS
- return bRet;
- }
- }
-
- {
- // If we have a PoolNumRule, create it if needed
- const SwNumRuleItem* pRule;
- sal_uInt16 nPoolId=0;
- if( SFX_ITEM_SET == pOtherSet->GetItemState( RES_PARATR_NUMRULE,
- false, (const SfxPoolItem**)&pRule ) &&
- !pDoc->FindNumRulePtr( pRule->GetValue() ) &&
- USHRT_MAX != (nPoolId = SwStyleNameMapper::GetPoolIdFromUIName ( pRule->GetValue(),
- nsSwGetPoolIdFromName::GET_POOLID_NUMRULE )) )
- pDoc->GetNumRuleFromPool( nPoolId );
- }
- }
-
- if( !rRg.HasMark() ) // no range
- {
- if( !pNode )
- {
- DELETECHARSETS
- return bRet;
- }
-
- if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
- {
- SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode);
- const SwIndex& rSt = pStt->nContent;
- sal_Int32 nMkPos, nPtPos = rSt.GetIndex();
- const OUString& rStr = pTxtNd->GetTxt();
-
- // Special case: if the Crsr is located within a URL attribute, we take over it's area
- SwTxtAttr const*const pURLAttr(
- pTxtNd->GetTxtAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
- if (pURLAttr && !pURLAttr->GetINetFmt().GetValue().isEmpty())
- {
- nMkPos = pURLAttr->GetStart();
- nPtPos = *pURLAttr->End();
- }
- else
- {
- Boundary aBndry;
- if( g_pBreakIt->GetBreakIter().is() )
- aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
- pTxtNd->GetTxt(), nPtPos,
- g_pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ),
- WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
- sal_True );
-
- if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
- {
- nMkPos = aBndry.startPos;
- nPtPos = aBndry.endPos;
- }
- else
- nPtPos = nMkPos = rSt.GetIndex();
- }
-
- // Remove the overriding attributes from the SwpHintsArray,
- // if the selection spans across the whole paragraph.
- // These attributes are inserted as FormatAttributes and
- // never override the TextAttributes!
- if( !(nFlags & nsSetAttrMode::SETATTR_DONTREPLACE ) &&
- pTxtNd->HasHints() && !nMkPos && nPtPos == rStr.getLength())
- {
- SwIndex aSt( pTxtNd );
- if( pHistory )
- {
- // Save all attributes for the Undo.
- SwRegHistory aRHst( *pTxtNd, pHistory );
- pTxtNd->GetpSwpHints()->Register( &aRHst );
- pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
- if( pTxtNd->GetpSwpHints() )
- pTxtNd->GetpSwpHints()->DeRegister();
- }
- else
- pTxtNd->RstTxtAttr( aSt, nPtPos, 0, pCharSet );
- }
-
- // the SwRegHistory inserts the attribute into the TxtNode!
- SwRegHistory history( pNode, *pNode, pHistory );
- bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags )
- || bRet;
-
- if( pDoc->IsRedlineOn() )
- {
- SwPaM aPam( *pNode, nMkPos, *pNode, nPtPos );
-
- if( pUndo )
- pUndo->SaveRedlineData( aPam, false );
- pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, aPam ), true);
- }
- }
- if( pOtherSet && pOtherSet->Count() )
- {
- SwRegHistory aRegH( pNode, *pNode, pHistory );
-
- //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
- // and evtl. correct that item to ensure unique names for that type. This call may
- // modify/correct entries inside of the given SfxItemSet
- SfxItemSet aTempLocalCopy(*pOtherSet);
-
- pDoc->CheckForUniqueItemForLineFillNameOrIndex(aTempLocalCopy);
- bRet = pNode->SetAttr(aTempLocalCopy) || bRet;
- }
-
- DELETECHARSETS
- return bRet;
- }
-
- if( pDoc->IsRedlineOn() && pCharSet && pCharSet->Count() )
- {
- if( pUndo )
- pUndo->SaveRedlineData( rRg, false );
- pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_FORMAT, rRg ), true);
- }
-
- /* now if range */
- sal_uLong nNodes = 0;
-
- SwNodeIndex aSt( pDoc->GetNodes() );
- SwNodeIndex aEnd( pDoc->GetNodes() );
- SwIndex aCntEnd( pEnd->nContent );
-
- if( pNode )
- {
- const sal_Int32 nLen = pNode->Len();
- if( pStt->nNode != pEnd->nNode )
- aCntEnd.Assign( pNode, nLen );
-
- if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen )
- {
- // the SwRegHistory inserts the attribute into the TxtNode!
- if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
- {
- SwRegHistory history( pNode, *pNode, pHistory );
- bRet = history.InsertItems(*pCharSet,
- pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags)
- || bRet;
- }
-
- if( pOtherSet && pOtherSet->Count() )
- {
- SwRegHistory aRegH( pNode, *pNode, pHistory );
- bRet = pNode->SetAttr( *pOtherSet ) || bRet;
- }
-
- // Only selection in a Node.
- if( pStt->nNode == pEnd->nNode )
- {
- //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
- //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
- //current setting attribute set is a character range properties set and comes from a MS word
- //binary file, And the setting range include a paragraph end position (0X0D);
- //More specifications, as such property inside the character range properties set recorded in
- //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
- //only dealing the scenario that the char properties set with 1 item inside;
-
- if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1 )
- {
- SwTxtNode* pCurrentNd = pStt->nNode.GetNode().GetTxtNode();
-
- if (pCurrentNd)
- {
- pCurrentNd->TryCharSetExpandToNum(*pCharSet);
-
- }
- }
- DELETECHARSETS
- return bRet;
- }
- ++nNodes;
- aSt.Assign( pStt->nNode.GetNode(), +1 );
- }
- else
- aSt = pStt->nNode;
- aCntEnd = pEnd->nContent; // aEnd was changed!
- }
- else
- aSt.Assign( pStt->nNode.GetNode(), +1 );
-
- // aSt points to the first full Node now
-
- /*
- * The selection spans more than one Node.
- */
- if( pStt->nNode < pEnd->nNode )
- {
- pNode = pEnd->nNode.GetNode().GetCntntNode();
- if(pNode)
- {
- if( aCntEnd.GetIndex() != pNode->Len() )
- {
- // the SwRegHistory inserts the attribute into the TxtNode!
- if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() )
- {
- SwRegHistory history( pNode, *pNode, pHistory );
- history.InsertItems(*pCharSet,
- 0, aCntEnd.GetIndex(), nFlags);
- }
-
- if( pOtherSet && pOtherSet->Count() )
- {
- SwRegHistory aRegH( pNode, *pNode, pHistory );
- pNode->SetAttr( *pOtherSet );
- }
-
- ++nNodes;
- aEnd = pEnd->nNode;
- }
- else
- aEnd.Assign( pEnd->nNode.GetNode(), +1 );
- }
- else
- aEnd = pEnd->nNode;
- }
- else
- aEnd.Assign( pEnd->nNode.GetNode(), +1 );
-
- // aEnd points BEHIND the last full node now
-
- /* Edit the fully selected Nodes. */
- // Reset all attributes from the set!
- if( pCharSet && pCharSet->Count() && !( nsSetAttrMode::SETATTR_DONTREPLACE & nFlags ) )
- {
- ParaRstFmt aPara( pStt, pEnd, pHistory, 0, pCharSet );
- pDoc->GetNodes().ForEach( aSt, aEnd, lcl_RstTxtAttr, &aPara );
- }
-
- bool bCreateSwpHints = pCharSet && (
- SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_CHARFMT, false ) ||
- SFX_ITEM_SET == pCharSet->GetItemState( RES_TXTATR_INETFMT, false ) );
-
- for(; aSt < aEnd; ++aSt )
- {
- pNode = aSt.GetNode().GetCntntNode();
- if( !pNode )
- continue;
-
- SwTxtNode* pTNd = pNode->GetTxtNode();
- if( pHistory )
- {
- SwRegHistory aRegH( pNode, *pNode, pHistory );
- SwpHints *pSwpHints;
-
- if( pTNd && pCharSet && pCharSet->Count() )
- {
- pSwpHints = bCreateSwpHints ? &pTNd->GetOrCreateSwpHints()
- : pTNd->GetpSwpHints();
- if( pSwpHints )
- pSwpHints->Register( &aRegH );
-
- pTNd->SetAttr(*pCharSet, 0, pTNd->GetTxt().getLength(), nFlags);
- if( pSwpHints )
- pSwpHints->DeRegister();
- }
- if( pOtherSet && pOtherSet->Count() )
- pNode->SetAttr( *pOtherSet );
- }
- else
- {
- if( pTNd && pCharSet && pCharSet->Count() )
- pTNd->SetAttr(*pCharSet, 0, pTNd->GetTxt().getLength(), nFlags);
- if( pOtherSet && pOtherSet->Count() )
- pNode->SetAttr( *pOtherSet );
- }
- ++nNodes;
- }
-
- //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc,
- //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that
- //current setting attribute set is a character range properties set and comes from a MS word
- //binary file, And the setting range include a paragraph end position (0X0D);
- //More specifications, as such property inside the character range properties set recorded in
- //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we
- //only dealing the scenario that the char properties set with 1 item inside;
- if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1)
- {
- SwPosition aStartPos (*rRg.Start());
- SwPosition aEndPos (*rRg.End());
-
- if (aEndPos.nNode.GetNode().GetTxtNode() && aEndPos.nContent != aEndPos.nNode.GetNode().GetTxtNode()->Len())
- aEndPos.nNode--;
-
- sal_uLong nStart = aStartPos.nNode.GetIndex();
- sal_uLong nEnd = aEndPos.nNode.GetIndex();
- for(; nStart <= nEnd; ++nStart)
- {
- SwNode* pNd = pDoc->GetNodes()[ nStart ];
- if (!pNd || !pNd->IsTxtNode())
- continue;
- SwTxtNode *pCurrentNd = (SwTxtNode*)pNd;
- pCurrentNd->TryCharSetExpandToNum(*pCharSet);
- }
- }
-
- DELETECHARSETS
- return (nNodes != 0) || bRet;
-}
-
-///Add a para for the char attribute exp...
-bool SwDoc::InsertPoolItem(
- const SwPaM &rRg,
- const SfxPoolItem &rHt,
- const SetAttrMode nFlags,
- const bool bExpandCharToPara)
-{
- SwDataChanged aTmp( rRg );
- SwUndoAttr* pUndoAttr = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- pUndoAttr = new SwUndoAttr( rRg, rHt, nFlags );
- }
-
- SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() );
- aSet.Put( rHt );
- const bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr, bExpandCharToPara );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
- }
-
- if( bRet )
- {
- SetModified();
- }
- return bRet;
-}
-
-bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet,
- const SetAttrMode nFlags )
-{
- SwDataChanged aTmp( rRg );
- SwUndoAttr* pUndoAttr = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags );
- }
-
- bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( pUndoAttr );
- }
-
- if( bRet )
- SetModified();
- return bRet;
-}
-
/// Set the rsid of the next nLen symbols of rRg to the current session number
bool SwDoc::UpdateRsid( const SwPaM &rRg, const sal_Int32 nLen )
{
@@ -1677,7 +971,7 @@ static bool lcl_SetTxtFmtColl( const SwNodePtr& rpNode, void* pArgs )
if( pCNd == NULL)
return true;
- ParaRstFmt* pPara = reinterpret_cast<ParaRstFmt*>(pArgs);
+ sw::DocumentContentOperationsManager::ParaRstFmt* pPara = reinterpret_cast<sw::DocumentContentOperationsManager::ParaRstFmt*>(pArgs);
SwTxtFmtColl* pFmt = static_cast<SwTxtFmtColl*>(pPara->pFmtColl);
if ( pPara->bReset )
@@ -1758,7 +1052,7 @@ bool SwDoc::SetTxtFmtColl(const SwPaM &rRg,
GetIDocumentUndoRedo().AppendUndo(pUndo);
}
- ParaRstFmt aPara( pStt, pEnd, pHst );
+ sw::DocumentContentOperationsManager::ParaRstFmt aPara( pStt, pEnd, pHst );
aPara.pFmtColl = pFmt;
aPara.bReset = bReset;
// #i62675#
@@ -2067,7 +1361,7 @@ void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader,
aTmpIdx = *pSttNd->EndOfSectionNode();
rSrcNds._Copy( aRg, aTmpIdx );
aTmpIdx = *pSttNd;
- rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx );
+ rSrcFmt.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl( aRg, 0, aTmpIdx );
pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd ));
}
else
@@ -2443,7 +1737,7 @@ void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, sal_uInt16 nPoolId,
{
aPam.SetMark();
aPam.GetMark()->nContent.Assign(pTNd, pTNd->GetTxt().getLength());
- InsertItemSet( aPam, *pSet, 0 );
+ getIDocumentContentOperations().InsertItemSet( aPam, *pSet, 0 );
}
}
@@ -2490,13 +1784,13 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet )
currentSet.Put(currentSet.Get(whichIds[i], true));
}
- InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND );
+ getIDocumentContentOperations().InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND );
// fdo#62536: DONTEXPAND does not work when there is already an AUTOFMT
// here, so insert the old attributes as an empty hint to stop expand
SwPaM endPam(*pTNd, nEnd);
endPam.SetMark();
- InsertItemSet(endPam, currentSet, nsSetAttrMode::SETATTR_DEFAULT);
+ getIDocumentContentOperations().InsertItemSet(endPam, currentSet, nsSetAttrMode::SETATTR_DEFAULT);
SetRedlineMode_intern( eOld );
}
diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx
index d727d89e32c1..5a94cc808cfa 100644
--- a/sw/source/core/doc/docglbl.cxx
+++ b/sw/source/core/doc/docglbl.cxx
@@ -33,6 +33,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <DocumentSettingManager.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <docary.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
@@ -312,7 +313,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline,
pDoc->GetNodes().Delete( aIdx, 1 );
// All Flys in the section
- CopyFlyInFlyImpl( aRg, 0, aIdx );
+ GetDocumentContentOperationsManager().CopyFlyInFlyImpl( aRg, 0, aIdx );
// And what's with all the Bookmarks?
// ?????
diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx
index c706208ec21b..79cfe2aeef70 100644
--- a/sw/source/core/doc/docglos.cxx
+++ b/sw/source/core/doc/docglos.cxx
@@ -163,7 +163,7 @@ bool SwDoc::InsertGlossary( SwTextBlocks& rBlock, const OUString& rEntry,
SwDontExpandItem aACD;
aACD.SaveDontExpandItems( rInsPos );
- pGDoc->CopyRange( aCpyPam, rInsPos, false );
+ pGDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, false );
aACD.RestoreDontExpandItems( rInsPos );
if( pShell )
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 1caf4e8c7efb..08173edb6467 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -64,6 +64,7 @@
#include <IDocumentUndoRedo.hxx>
#include <DocumentSettingManager.hxx>
#include <IDocumentDrawModelAccess.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <rootfrm.hxx>
#include <pagefrm.hxx>
#include <cntfrm.hxx>
@@ -299,7 +300,7 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt )
{
SwNode *pNode = &pCntIdx->GetNode();
((SwFmtCntnt&)pFmt->GetFmtAttr( RES_CNTNT )).SetNewCntntIdx( 0 );
- DeleteSection( pNode );
+ getIDocumentContentOperations().DeleteSection( pNode );
}
// Delete the character for FlyFrames anchored as char (if necessary)
@@ -450,7 +451,7 @@ SwFrmFmt *SwDoc::CopyLayoutFmt(
//contact object itself. They should be managed by SwUndoInsLayFmt.
const ::sw::DrawUndoGuard drawUndoGuard(GetIDocumentUndoRedo());
- pSrcDoc->CopyWithFlyInFly( aRg, 0, aIdx, NULL, false, true, true );
+ pSrcDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aIdx, NULL, false, true, true );
}
else
{
@@ -796,7 +797,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
GetNodes().MakeTxtNode( aRg.aStart,
(SwTxtFmtColl*)GetDfltTxtFmtColl() );
- MoveNodeRange( aRg, aPos.nNode, DOC_MOVEDEFAULT );
+ getIDocumentContentOperations().MoveNodeRange( aRg, aPos.nNode, IDocumentContentOperations::DOC_MOVEDEFAULT );
}
else
{
@@ -833,7 +834,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
if( pTmp->HasMark() &&
*pTmp->GetPoint() != *pTmp->GetMark() )
{
- CopyRange( *pTmp, aPos, false );
+ getIDocumentContentOperations().CopyRange( *pTmp, aPos, false );
}
pTmp = static_cast<SwPaM*>(pTmp->GetNext());
} while ( &rPam != pTmp );
@@ -846,7 +847,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
if( pTmp->HasMark() &&
*pTmp->GetPoint() != *pTmp->GetMark() )
{
- DeleteAndJoin( *pTmp );
+ getIDocumentContentOperations().DeleteAndJoin( *pTmp );
}
pTmp = static_cast<SwPaM*>(pTmp->GetNext());
} while ( &rPam != pTmp );
@@ -861,116 +862,6 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet,
return pFmt;
}
-// Insert drawing object, which has to be already inserted in the DrawModel
-SwDrawFrmFmt* SwDoc::InsertDrawObj(
- const SwPaM &rRg,
- SdrObject& rDrawObj,
- const SfxItemSet& rFlyAttrSet )
-{
- SwDrawFrmFmt* pFmt = MakeDrawFrmFmt( OUString(), GetDfltFrmFmt() );
-
- const SwFmtAnchor* pAnchor = 0;
- rFlyAttrSet.GetItemState( RES_ANCHOR, false, (const SfxPoolItem**) &pAnchor );
- pFmt->SetFmtAttr( rFlyAttrSet );
-
- // Didn't set the Anchor yet?
- // DrawObjecte must never end up in the Header/Footer!
- RndStdIds eAnchorId = pAnchor != NULL ? pAnchor->GetAnchorId() : pFmt->GetAnchor().GetAnchorId();
- const bool bIsAtCntnt = (FLY_AT_PAGE != eAnchorId);
-
- const SwNodeIndex* pChkIdx = 0;
- if ( pAnchor == NULL )
- {
- pChkIdx = &rRg.GetPoint()->nNode;
- }
- else if ( bIsAtCntnt )
- {
- pChkIdx =
- pAnchor->GetCntntAnchor() ? &pAnchor->GetCntntAnchor()->nNode : &rRg.GetPoint()->nNode;
- }
-
- // allow drawing objects in header/footer, but control objects aren't allowed in header/footer.
- if( pChkIdx != NULL
- && ::CheckControlLayer( &rDrawObj )
- && IsInHeaderFooter( *pChkIdx ) )
- {
- // apply at-page anchor format
- eAnchorId = FLY_AT_PAGE;
- pFmt->SetFmtAttr( SwFmtAnchor( eAnchorId ) );
- }
- else if( pAnchor == NULL
- || ( bIsAtCntnt
- && pAnchor->GetCntntAnchor() == NULL ) )
- {
- // apply anchor format
- SwFmtAnchor aAnch( pAnchor != NULL ? *pAnchor : pFmt->GetAnchor() );
- eAnchorId = aAnch.GetAnchorId();
- if ( eAnchorId == FLY_AT_FLY )
- {
- SwPosition aPos( *rRg.GetNode().FindFlyStartNode() );
- aAnch.SetAnchor( &aPos );
- }
- else
- {
- aAnch.SetAnchor( rRg.GetPoint() );
- if ( eAnchorId == FLY_AT_PAGE )
- {
- eAnchorId = rDrawObj.ISA( SdrUnoObj ) ? FLY_AS_CHAR : FLY_AT_PARA;
- aAnch.SetType( eAnchorId );
- }
- }
- pFmt->SetFmtAttr( aAnch );
- }
-
- // insert text attribute for as-character anchored drawing object
- if ( eAnchorId == FLY_AS_CHAR )
- {
- bool bAnchorAtPageAsFallback = true;
- const SwFmtAnchor& rDrawObjAnchorFmt = pFmt->GetAnchor();
- if ( rDrawObjAnchorFmt.GetCntntAnchor() != NULL )
- {
- SwTxtNode* pAnchorTxtNode =
- rDrawObjAnchorFmt.GetCntntAnchor()->nNode.GetNode().GetTxtNode();
- if ( pAnchorTxtNode != NULL )
- {
- const sal_Int32 nStt = rDrawObjAnchorFmt.GetCntntAnchor()->nContent.GetIndex();
- SwFmtFlyCnt aFmt( pFmt );
- pAnchorTxtNode->InsertItem( aFmt, nStt, nStt );
- bAnchorAtPageAsFallback = false;
- }
- }
-
- if ( bAnchorAtPageAsFallback )
- {
- OSL_ENSURE( false, "SwDoc::InsertDrawObj(..) - missing content anchor for as-character anchored drawing object --> anchor at-page" );
- pFmt->SetFmtAttr( SwFmtAnchor( FLY_AT_PAGE ) );
- }
- }
-
- SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj );
-
- // Create Frames if necessary
- if( GetCurrentViewShell() )
- {
- // create layout representation
- pFmt->MakeFrms();
- // #i42319# - follow-up of #i35635#
- // move object to visible layer
- // #i79391#
- if ( pContact->GetAnchorFrm() )
- {
- pContact->MoveObjToVisibleLayer( &rDrawObj );
- }
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( new SwUndoInsLayFmt(pFmt, 0, 0) );
- }
-
- SetModified();
- return pFmt;
-}
/*
* paragraph frames - o.k. if the PaM includes the paragraph from the beginning
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index b87afd210ef7..a7cdfe8bf6de 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -96,6 +96,7 @@
#include <DocumentListItemsManager.hxx>
#include <DocumentListsManager.hxx>
#include <DocumentOutlineNodesManager.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <unochart.hxx>
#include <fldbas.hxx>
@@ -207,6 +208,7 @@ SwDoc::SwDoc()
m_pDocumentListItemsManager( new ::sw::DocumentListItemsManager() ),
m_pDocumentListsManager( new ::sw::DocumentListsManager( *this ) ),
m_pDocumentOutlineNodesManager( new ::sw::DocumentOutlineNodesManager( *this ) ),
+ m_pDocumentContentOperationsManager( new ::sw::DocumentContentOperationsManager( *this ) ),
mpDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
mpEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, mpDfltFrmFmt ) ),
mpColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, mpDfltFrmFmt ) ),
@@ -963,7 +965,7 @@ void SwDoc::Paste( const SwDoc& rSource )
aIndexBefore--;
- rSource.CopyRange( aCpyPam, rInsPos, true );
+ rSource.getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, true );
// Note: aCpyPam is invalid now
++aIndexBefore;
@@ -980,7 +982,7 @@ void SwDoc::Paste( const SwDoc& rSource )
{
//remove the paragraph in front of the table
SwPaM aPara(aInsertPosition);
- this->DelFullPara(aPara);
+ this->getIDocumentContentOperations().DelFullPara(aPara);
}
//additionally copy page bound frames
if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->size() )
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index bc5880d220a2..b20c6ec2283c 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -887,7 +887,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam,
}
if (!sListId.isEmpty())
{
- InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 );
+ getIDocumentContentOperations().InsertPoolItem( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 );
}
}
@@ -927,7 +927,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam,
if ( bSetItem )
{
- InsertPoolItem( rPam, SwNumRuleItem( pNewOrChangedNumRule->GetName() ), 0 );
+ getIDocumentContentOperations().InsertPoolItem( rPam, SwNumRuleItem( pNewOrChangedNumRule->GetName() ), 0 );
}
if ( bResetIndentAttrs
@@ -953,7 +953,7 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted)
}
else
{
- InsertPoolItem( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, false ), 0 );
+ getIDocumentContentOperations().InsertPoolItem( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, false ), 0 );
}
}
@@ -1260,7 +1260,7 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM)
bool SwDoc::NoNum( const SwPaM& rPam )
{
- bool bRet = SplitNode( *rPam.GetPoint(), false );
+ bool bRet = getIDocumentContentOperations().SplitNode( *rPam.GetPoint(), false );
// Do we actually use Numbering at all?
if( bRet )
{
@@ -1913,12 +1913,12 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
found. The new position to insert the moved
paragraph at is before the inserted
paragraph. */
- AppendTxtNode(*aInsPam.GetPoint());
+ getIDocumentContentOperations().AppendTxtNode(*aInsPam.GetPoint());
aInsPos = *aInsPam.GetPoint();
}
}
- CopyRange( aPam, aInsPos, false );
+ getIDocumentContentOperations().CopyRange( aPam, aInsPos, false );
if( bDelLastPara )
{
// We need to remove the last empty Node again
@@ -2004,7 +2004,7 @@ bool SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, bool bIsOutlMv )
nMoved = rPam.End()->nNode.GetIndex() - rPam.Start()->nNode.GetIndex() + 1;
}
- MoveNodeRange( aMvRg, aIdx, DOC_MOVEREDLINES );
+ getIDocumentContentOperations().MoveNodeRange( aMvRg, aIdx, IDocumentContentOperations::DOC_MOVEREDLINES );
if( pUndo )
{
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index c5d118630ac5..39db61c584e6 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -28,6 +28,7 @@
#include <doc.hxx>
#include <docredln.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <docary.hxx>
#include <ndtxt.hxx>
#include <redline.hxx>
@@ -781,10 +782,10 @@ bool SwDoc::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
pEnd->nNode--;
pEnd->nContent.Assign(
pEnd->nNode.GetNode().GetTxtNode(), 0);
- DelFullPara( *pNewRedl );
+ getIDocumentContentOperations().DelFullPara( *pNewRedl );
}
else
- DeleteAndJoin( *pNewRedl );
+ getIDocumentContentOperations().DeleteAndJoin( *pNewRedl );
bCompress = true;
}
@@ -800,7 +801,7 @@ bool SwDoc::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
if( bCallDelete )
{
mpRedlineTbl->Insert( pNewRedl );
- DeleteAndJoin( *pRedl );
+ getIDocumentContentOperations().DeleteAndJoin( *pRedl );
if( !mpRedlineTbl->Remove( pNewRedl ) )
pNewRedl = 0;
}
@@ -827,7 +828,7 @@ bool SwDoc::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
// We insert temporarily so that pNew is
// also dealt with when moving the indices.
mpRedlineTbl->Insert( pNewRedl );
- DeleteAndJoin( aPam );
+ getIDocumentContentOperations().DeleteAndJoin( aPam );
if( !mpRedlineTbl->Remove( pNewRedl ) )
pNewRedl = 0;
n = 0; // re-initialize
@@ -853,7 +854,7 @@ bool SwDoc::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
// We insert temporarily so that pNew is
// also dealt with when moving the indices.
mpRedlineTbl->Insert( pNewRedl );
- DeleteAndJoin( aPam );
+ getIDocumentContentOperations().DeleteAndJoin( aPam );
if( !mpRedlineTbl->Remove( pNewRedl ) )
pNewRedl = 0;
n = 0; // re-initialize
@@ -1241,7 +1242,7 @@ bool SwDoc::AppendRedline( SwRangeRedline* pNewRedl, bool bCallDelete )
// Set to NONE, so that the Delete::Redo merges the Redline data correctly!
// The ShowMode needs to be retained!
meRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
- DeleteAndJoin( *pNewRedl );
+ getIDocumentContentOperations().DeleteAndJoin( *pNewRedl );
meRedlineMode = eOld;
}
delete pNewRedl, pNewRedl = 0;
@@ -1880,17 +1881,17 @@ static bool lcl_AcceptRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
rDoc.SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
if( pCSttNd && pCEndNd )
- rDoc.DeleteAndJoin( aPam );
+ rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
else
{
- rDoc.DeleteRange( aPam );
+ rDoc.getIDocumentContentOperations().DeleteRange( aPam );
if( pCSttNd && !pCEndNd )
{
aPam.GetBound( true ).nContent.Assign( 0, 0 );
aPam.GetBound( false ).nContent.Assign( 0, 0 );
aPam.DeleteMark();
- rDoc.DelFullPara( aPam );
+ rDoc.getIDocumentContentOperations().DelFullPara( aPam );
}
}
rDoc.SetRedlineMode_intern( eOld );
@@ -1990,17 +1991,17 @@ static bool lcl_RejectRedline( SwRedlineTbl& rArr, sal_uInt16& rPos,
rDoc.SetRedlineMode_intern( (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE)));
if( pCSttNd && pCEndNd )
- rDoc.DeleteAndJoin( aPam );
+ rDoc.getIDocumentContentOperations().DeleteAndJoin( aPam );
else
{
- rDoc.DeleteRange( aPam );
+ rDoc.getIDocumentContentOperations().DeleteRange( aPam );
if( pCSttNd && !pCEndNd )
{
aPam.GetBound( true ).nContent.Assign( 0, 0 );
aPam.GetBound( false ).nContent.Assign( 0, 0 );
aPam.DeleteMark();
- rDoc.DelFullPara( aPam );
+ rDoc.getIDocumentContentOperations().DelFullPara( aPam );
}
}
rDoc.SetRedlineMode_intern( eOld );
@@ -3103,11 +3104,11 @@ void SwRedlineExtraData_FmtColl::Reject( SwPaM& rPam ) const
// could have changed, but we don't touch these.
SfxItemSet aTmp( *pSet );
aTmp.Differentiate( *pTNd->GetpSwAttrSet() );
- pDoc->InsertItemSet( rPam, aTmp, 0 );
+ pDoc->getIDocumentContentOperations().InsertItemSet( rPam, aTmp, 0 );
}
else
{
- pDoc->InsertItemSet( rPam, *pSet, 0 );
+ pDoc->getIDocumentContentOperations().InsertItemSet( rPam, *pSet, 0 );
}
}
rPam.DeleteMark();
@@ -3171,7 +3172,7 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const
std::vector<sal_uInt16>::const_iterator it;
for( it = aWhichIds.begin(); it != aWhichIds.end(); ++it )
{
- pDoc->InsertPoolItem( rPam, *GetDfltAttr( *it ),
+ pDoc->getIDocumentContentOperations().InsertPoolItem( rPam, *GetDfltAttr( *it ),
nsSetAttrMode::SETATTR_DONTEXPAND );
}
@@ -3355,7 +3356,7 @@ SwRangeRedline::~SwRangeRedline()
{
// delete the ContentSection
if( !GetDoc()->IsInDtor() )
- GetDoc()->DeleteSection( &pCntntSect->GetNode() );
+ GetDoc()->getIDocumentContentOperations().DeleteSection( &pCntntSect->GetNode() );
delete pCntntSect;
}
delete pRedlineData;
@@ -3614,12 +3615,12 @@ void SwRangeRedline::MoveToSection()
SwNodeIndex aNdIdx( *pTxtNd );
SwPosition aPos( aNdIdx, SwIndex( pTxtNd ));
if( pCSttNd && pCEndNd )
- pDoc->MoveAndJoin( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT );
+ pDoc->getIDocumentContentOperations().MoveAndJoin( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT );
else
{
if( pCSttNd && !pCEndNd )
bDelLastPara = true;
- pDoc->MoveRange( aPam, aPos,
+ pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
IDocumentContentOperations::DOC_MOVEDEFAULT );
}
}
@@ -3629,7 +3630,7 @@ void SwRangeRedline::MoveToSection()
SwNormalStartNode );
SwPosition aPos( *pSttNd->EndOfSectionNode() );
- pDoc->MoveRange( aPam, aPos,
+ pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
IDocumentContentOperations::DOC_MOVEDEFAULT );
}
pCntntSect = new SwNodeIndex( *pSttNd );
@@ -3681,7 +3682,7 @@ void SwRangeRedline::CopyToSection()
SwNodeIndex aNdIdx( *pSttNd, 1 );
SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode();
SwPosition aPos( aNdIdx, SwIndex( pTxtNd ));
- pDoc->CopyRange( *this, aPos, false );
+ pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, false );
// Take over the style from the EndNode if needed
// We don't want this in Doc::Copy
@@ -3706,13 +3707,13 @@ void SwRangeRedline::CopyToSection()
if( pCEndNd )
{
SwPosition aPos( *pSttNd->EndOfSectionNode() );
- pDoc->CopyRange( *this, aPos, false );
+ pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, false );
}
else
{
SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() );
SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
- pDoc->CopyWithFlyInFly( aRg, 0, aInsPos );
+ pDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aInsPos );
}
}
pCntntSect = new SwNodeIndex( *pSttNd );
@@ -3752,13 +3753,13 @@ void SwRangeRedline::DelCopyOfSection()
if( pCSttNd && pCEndNd )
{
// #i100466# - force a <join next> on <delete and join> operation
- pDoc->DeleteAndJoin( aPam, true );
+ pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam, true );
}
else if( pCSttNd || pCEndNd )
{
if( pCSttNd && !pCEndNd )
bDelLastPara = true;
- pDoc->DeleteRange( aPam );
+ pDoc->getIDocumentContentOperations().DeleteRange( aPam );
if( bDelLastPara )
{
@@ -3795,12 +3796,12 @@ void SwRangeRedline::DelCopyOfSection()
aPam.GetBound( true ).nContent.Assign( 0, 0 );
aPam.GetBound( false ).nContent.Assign( 0, 0 );
aPam.DeleteMark();
- pDoc->DelFullPara( aPam );
+ pDoc->getIDocumentContentOperations().DelFullPara( aPam );
}
}
else
{
- pDoc->DeleteRange( aPam );
+ pDoc->getIDocumentContentOperations().DeleteRange( aPam );
}
if( pStt == GetPoint() )
@@ -3875,11 +3876,11 @@ void SwRangeRedline::MoveFromSection()
{
aPos.nNode--;
- pDoc->AppendTxtNode( aPos );
+ pDoc->getIDocumentContentOperations().AppendTxtNode( aPos );
}
else
{
- pDoc->MoveRange( aPam, aPos,
+ pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
IDocumentContentOperations::DOC_MOVEALLFLYS );
}
@@ -3911,7 +3912,7 @@ void SwRangeRedline::MoveFromSection()
// Note: Such condition is e.g. a "delete" change tracking only containing a table.
if ( &pCntntSect->GetNode() == pKeptCntntSectNode )
{
- pDoc->DeleteSection( &pCntntSect->GetNode() );
+ pDoc->getIDocumentContentOperations().DeleteSection( &pCntntSect->GetNode() );
}
delete pCntntSect, pCntntSect = 0;
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index b8f264a82da0..7d5c58069b68 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -27,6 +27,7 @@
#include <hintids.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <docary.hxx>
#include <mvsave.hxx>
#include <ndtxt.hxx>
@@ -126,7 +127,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
// set/reset the attribute
if( !pEntry->GetRubyAttr().GetText().isEmpty() )
{
- InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 );
+ getIDocumentContentOperations().InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 );
}
else
{
@@ -138,7 +139,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
aCheckEntry.GetText() != pEntry->GetText() )
{
// text is changed, so replace the original
- ReplaceRange( aPam, pEntry->GetText(), false );
+ getIDocumentContentOperations().ReplaceRange( aPam, pEntry->GetText(), false );
}
aPam.DeleteMark();
}
@@ -158,10 +159,10 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
if( !pEntry->GetRubyAttr().GetText().isEmpty() &&
!pEntry->GetText().isEmpty() )
{
- InsertString( aPam, pEntry->GetText() );
+ getIDocumentContentOperations().InsertString( aPam, pEntry->GetText() );
aPam.SetMark();
aPam.GetMark()->nContent -= pEntry->GetText().getLength();
- InsertPoolItem(
+ getIDocumentContentOperations().InsertPoolItem(
aPam, pEntry->GetRubyAttr(), nsSetAttrMode::SETATTR_DONTEXPAND );
}
else
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 71cf88a99e00..d53c7303747b 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -405,7 +405,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
aRg.aEnd = aRg.aStart.GetIndex() + 1;
// Move Nodes
- MoveNodeRange( aRg, aStart,
+ getIDocumentContentOperations().MoveNodeRange( aRg, aStart,
IDocumentContentOperations::DOC_MOVEDEFAULT );
// Insert Move in Undo
@@ -734,7 +734,7 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar,
// Insert the Source
SwNodeIndex aIns( *pTar->GetSttNd()->EndOfSectionNode() );
- pDoc->MoveNodeRange( aRg, aIns,
+ pDoc->getIDocumentContentOperations().MoveNodeRange( aRg, aIns,
IDocumentContentOperations::DOC_MOVEDEFAULT );
// If first Node is empty -> delete it
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index e6011536806c..10302c2de442 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -539,7 +539,7 @@ bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes )
TOX'. Append text node behind TOX' section. */
SwPosition aInsPos(*pMyNode->EndOfSectionNode());
- AppendTxtNode(aInsPos);
+ getIDocumentContentOperations().AppendTxtNode(aInsPos);
SwPaM aTmpPam1(aInsPos);
aSearchPam = aTmpPam1;
diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx
index 3d1efcc32b78..a4ea3a811b22 100644
--- a/sw/source/core/doc/extinput.cxx
+++ b/sw/source/core/doc/extinput.cxx
@@ -81,7 +81,7 @@ SwExtTextInput::~SwExtTextInput()
if ( bLang )
{
SvxLanguageItem aLangItem( eInputLanguage, nWhich );
- pDoc->InsertPoolItem(*this, aLangItem, 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem(*this, aLangItem, 0 );
}
}
rIdx = nSttCnt;
@@ -100,8 +100,8 @@ SwExtTextInput::~SwExtTextInput()
{
rIdx = nSttCnt;
pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_OVERWRITE, NULL );
- pDoc->Overwrite( *this, sTxt.copy( 0, nOWLen ) );
- pDoc->InsertString( *this, sTxt.copy( nOWLen ) );
+ pDoc->getIDocumentContentOperations().Overwrite( *this, sTxt.copy( 0, nOWLen ) );
+ pDoc->getIDocumentContentOperations().InsertString( *this, sTxt.copy( nOWLen ) );
pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_OVERWRITE, NULL );
}
}
@@ -111,7 +111,7 @@ SwExtTextInput::~SwExtTextInput()
if( bInsText )
{
rIdx = nSttCnt;
- pDoc->Overwrite( *this, sTxt );
+ pDoc->getIDocumentContentOperations().Overwrite( *this, sTxt );
}
}
}
@@ -121,7 +121,7 @@ SwExtTextInput::~SwExtTextInput()
if( bInsText )
{
- pDoc->InsertString( *this, sTxt );
+ pDoc->getIDocumentContentOperations().InsertString( *this, sTxt );
}
}
}
diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx
index 3abe33176bb6..27809b7b6a26 100644
--- a/sw/source/core/doc/tblcpy.cxx
+++ b/sw/source/core/doc/tblcpy.cxx
@@ -23,6 +23,7 @@
#include <frmfmt.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
#include <swtable.hxx>
@@ -533,7 +534,7 @@ static void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox,
SwNodeIndex aSavePos( aInsIdx, -1 );
if( pRg.get() )
- pCpyDoc->CopyWithFlyInFly( *pRg, 0, aInsIdx, NULL, false );
+ pCpyDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( *pRg, 0, aInsIdx, NULL, false );
else
pDoc->GetNodes().MakeTxtNode( aInsIdx, (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() );
++aSavePos;
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 951e6b110720..fb11fb9c3626 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -31,6 +31,7 @@
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentChartDataProviderAccess.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <cntfrm.hxx>
#include <tabfrm.hxx>
#include <frmtool.hxx>
@@ -768,7 +769,7 @@ void _DeleteBox( SwTable& rTbl, SwTableBox* pBox, SwUndo* pUndo,
if( pUndo && pUndo->IsDelBox() )
((SwUndoTblNdsChg*)pUndo)->SaveSection( pSttNd );
else
- pSttNd->GetDoc()->DeleteSection( pSttNd );
+ pSttNd->GetDoc()->getIDocumentContentOperations().DeleteSection( pSttNd );
}
// Also delete the Line?
@@ -1985,7 +1986,7 @@ static void lcl_CopyBoxToDoc(_FndBox const& rFndBox, _CpyPara *const pCpyPara)
*rFndBox.GetBox()->GetSttNd()->EndOfSectionNode() );
SwNodeIndex aInsIdx( *pBox->GetSttNd(), 1 );
- pFromDoc->CopyWithFlyInFly( aCpyRg, 0, aInsIdx, NULL, false );
+ pFromDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( aCpyRg, 0, aInsIdx, NULL, false );
// Delete the initial TextNode
pCpyPara->pDoc->GetNodes().Delete( aInsIdx, 1 );
}
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index cc044d7ecb36..b7ee2ec2c677 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -313,7 +313,7 @@ void SwTextBoxHelper::syncProperty(SwFrmFmt* pShape, const OUString& rPropertyNa
aPaM.GetMark()->nNode = *pMark;
aPaM.GetMark()->nContent.Assign(pMark, pMark->GetTxt().getLength());
SvxCharRotateItem aItem(900, false, RES_CHRATR_ROTATE);
- pFmt->GetDoc()->InsertPoolItem(aPaM, aItem, 0);
+ pFmt->GetDoc()->getIDocumentContentOperations().InsertPoolItem(aPaM, aItem, 0);
}
}
}
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 55759345356d..d403e16b7ee6 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -16,38 +16,20 @@
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
-#include <editeng/formatbreakitem.hxx>
-
-#include <hintids.hxx>
-#include <fmtpdsc.hxx>
-#include <fmtanchr.hxx>
-#include <fmtcntnt.hxx>
#include <doc.hxx>
-#include <IDocumentUndoRedo.hxx>
-#include <pam.hxx>
-#include <ndtxt.hxx>
-#include <fldbas.hxx>
+#include <node.hxx>
+#include <frmfmt.hxx>
#include <swtable.hxx>
-#include <ddefld.hxx>
-#include <unocrsr.hxx>
-#include <undobj.hxx>
-#include <IMark.hxx>
-#include <mvsave.hxx>
-#include <cellatr.hxx>
+#include <ndtxt.hxx>
#include <swtblfmt.hxx>
-#include <swddetbl.hxx>
+#include <cellatr.hxx>
#include <docary.hxx>
-#include <fmtcnct.hxx>
-#include <redline.hxx>
-#include <paratr.hxx>
-#include <pagedesc.hxx>
-#include <poolfmt.hxx>
-#include <SwNodeNum.hxx>
-#include <set>
-#include <vector>
-#include <textboxhelper.hxx>
+#include <ddefld.hxx>
+#include <swddetbl.hxx>
+#include <svtools/fmtfield.hxx>
#include <boost/foreach.hpp>
+#include <vector>
+
#ifdef DBG_UTIL
#define CHECK_TABLE(t) (t).CheckConsistency();
@@ -55,174 +37,7 @@
#define CHECK_TABLE(t)
#endif
-namespace
-{
- /*
- The lcl_CopyBookmarks function has to copy bookmarks from the source to the destination nodes
- array. It is called after a call of the _CopyNodes(..) function. But this function does not copy
- every node (at least at the moment: 2/08/2006 ), section start and end nodes will not be copied if the corresponding end/start node is outside the copied pam.
- The lcl_NonCopyCount function counts the number of these nodes, given the copied pam and a node
- index inside the pam.
- rPam is the original source pam, rLastIdx is the last calculated position, rDelCount the number
- of "non-copy" nodes between rPam.Start() and rLastIdx.
- nNewIdx is the new position of interest.
- */
-
- static void lcl_NonCopyCount( const SwPaM& rPam, SwNodeIndex& rLastIdx, const sal_uLong nNewIdx, sal_uLong& rDelCount )
- {
- sal_uLong nStart = rPam.Start()->nNode.GetIndex();
- sal_uLong nEnd = rPam.End()->nNode.GetIndex();
- if( rLastIdx.GetIndex() < nNewIdx ) // Moving forward?
- {
- do // count "non-copy" nodes
- {
- SwNode& rNode = rLastIdx.GetNode();
- if( ( rNode.IsSectionNode() && rNode.EndOfSectionIndex() >= nEnd )
- || ( rNode.IsEndNode() && rNode.StartOfSectionNode()->GetIndex() < nStart ) )
- ++rDelCount;
- ++rLastIdx;
- }
- while( rLastIdx.GetIndex() < nNewIdx );
- }
- else if( rDelCount ) // optimization: if there are no "non-copy" nodes until now,
- // no move backward needed
- {
- while( rLastIdx.GetIndex() > nNewIdx )
- {
- SwNode& rNode = rLastIdx.GetNode();
- if( ( rNode.IsSectionNode() && rNode.EndOfSectionIndex() >= nEnd )
- || ( rNode.IsEndNode() && rNode.StartOfSectionNode()->GetIndex() < nStart ) )
- --rDelCount;
- rLastIdx--;
- }
- }
- }
-
- static void lcl_SetCpyPos( const SwPosition& rOrigPos,
- const SwPosition& rOrigStt,
- const SwPosition& rCpyStt,
- SwPosition& rChgPos,
- sal_uLong nDelCount )
- {
- sal_uLong nNdOff = rOrigPos.nNode.GetIndex();
- nNdOff -= rOrigStt.nNode.GetIndex();
- nNdOff -= nDelCount;
- sal_Int32 nCntntPos = rOrigPos.nContent.GetIndex();
-
- // Always adjust <nNode> at to be changed <SwPosition> instance <rChgPos>
- rChgPos.nNode = nNdOff + rCpyStt.nNode.GetIndex();
- if( !nNdOff )
- {
- // dann nur den Content anpassen
- if( nCntntPos > rOrigStt.nContent.GetIndex() )
- nCntntPos -= rOrigStt.nContent.GetIndex();
- else
- nCntntPos = 0;
- nCntntPos += rCpyStt.nContent.GetIndex();
- }
- rChgPos.nContent.Assign( rChgPos.nNode.GetNode().GetCntntNode(), nCntntPos );
- }
-
- // TODO: use SaveBookmark (from _DelBookmarks)
- static void lcl_CopyBookmarks(
- const SwPaM& rPam,
- SwPaM& rCpyPam )
- {
- const SwDoc* pSrcDoc = rPam.GetDoc();
- SwDoc* pDestDoc = rCpyPam.GetDoc();
- const IDocumentMarkAccess* const pSrcMarkAccess = pSrcDoc->getIDocumentMarkAccess();
- ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
-
- const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
- SwPosition* pCpyStt = rCpyPam.Start();
-
- typedef ::std::vector< const ::sw::mark::IMark* > mark_vector_t;
- mark_vector_t vMarksToCopy;
- for ( IDocumentMarkAccess::const_iterator_t ppMark = pSrcMarkAccess->getAllMarksBegin();
- ppMark != pSrcMarkAccess->getAllMarksEnd();
- ++ppMark )
- {
- const ::sw::mark::IMark* const pMark = ppMark->get();
-
- const SwPosition& rMarkStart = pMark->GetMarkStart();
- const SwPosition& rMarkEnd = pMark->GetMarkEnd();
- // only include marks that are in the range and not touching both start and end
- // - not for annotation marks.
- const bool bIsNotOnBoundary =
- pMark->IsExpanded()
- ? (rMarkStart != rStt || rMarkEnd != rEnd) // rMarkStart != rMarkEnd
- : (rMarkStart != rStt && rMarkEnd != rEnd); // rMarkStart == rMarkEnd
- if ( rMarkStart >= rStt && rMarkEnd <= rEnd
- && ( bIsNotOnBoundary
- || IDocumentMarkAccess::GetType( *pMark ) == IDocumentMarkAccess::ANNOTATIONMARK ) )
- {
- vMarksToCopy.push_back(pMark);
- }
- }
- // We have to count the "non-copied" nodes..
- SwNodeIndex aCorrIdx(rStt.nNode);
- sal_uLong nDelCount = 0;
- for(mark_vector_t::const_iterator ppMark = vMarksToCopy.begin();
- ppMark != vMarksToCopy.end();
- ++ppMark)
- {
- const ::sw::mark::IMark* const pMark = *ppMark;
- SwPaM aTmpPam(*pCpyStt);
- lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetMarkPos().nNode.GetIndex(), nDelCount);
- lcl_SetCpyPos( pMark->GetMarkPos(), rStt, *pCpyStt, *aTmpPam.GetPoint(), nDelCount);
- if(pMark->IsExpanded())
- {
- aTmpPam.SetMark();
- lcl_NonCopyCount(rPam, aCorrIdx, pMark->GetOtherMarkPos().nNode.GetIndex(), nDelCount);
- lcl_SetCpyPos(pMark->GetOtherMarkPos(), rStt, *pCpyStt, *aTmpPam.GetMark(), nDelCount);
- }
-
- ::sw::mark::IMark* const pNewMark = pDestDoc->getIDocumentMarkAccess()->makeMark(
- aTmpPam,
- pMark->GetName(),
- IDocumentMarkAccess::GetType(*pMark));
- // Explicitly try to get exactly the same name as in the source
- // because NavigatorReminders, DdeBookmarks etc. ignore the proposed name
- pDestDoc->getIDocumentMarkAccess()->renameMark(pNewMark, pMark->GetName());
-
- // copying additional attributes for bookmarks or fieldmarks
- ::sw::mark::IBookmark* const pNewBookmark =
- dynamic_cast< ::sw::mark::IBookmark* const >(pNewMark);
- const ::sw::mark::IBookmark* const pOldBookmark =
- dynamic_cast< const ::sw::mark::IBookmark* >(pMark);
- if (pNewBookmark && pOldBookmark)
- {
- pNewBookmark->SetKeyCode(pOldBookmark->GetKeyCode());
- pNewBookmark->SetShortName(pOldBookmark->GetShortName());
- }
- ::sw::mark::IFieldmark* const pNewFieldmark =
- dynamic_cast< ::sw::mark::IFieldmark* const >(pNewMark);
- const ::sw::mark::IFieldmark* const pOldFieldmark =
- dynamic_cast< const ::sw::mark::IFieldmark* >(pMark);
- if (pNewFieldmark && pOldFieldmark)
- {
- pNewFieldmark->SetFieldname(pOldFieldmark->GetFieldname());
- pNewFieldmark->SetFieldHelptext(pOldFieldmark->GetFieldHelptext());
- ::sw::mark::IFieldmark::parameter_map_t* pNewParams = pNewFieldmark->GetParameters();
- const ::sw::mark::IFieldmark::parameter_map_t* pOldParams = pOldFieldmark->GetParameters();
- ::sw::mark::IFieldmark::parameter_map_t::const_iterator pIt = pOldParams->begin();
- for (; pIt != pOldParams->end(); ++pIt )
- {
- pNewParams->insert( *pIt );
- }
- }
- ::sfx2::Metadatable const*const pMetadatable(
- dynamic_cast< ::sfx2::Metadatable const* >(pMark));
- ::sfx2::Metadatable *const pNewMetadatable(
- dynamic_cast< ::sfx2::Metadatable * >(pNewMark));
- if (pMetadatable && pNewMetadatable)
- {
- pNewMetadatable->RegisterAsCopyOf(*pMetadatable);
- }
- }
- }
-}
// Structure for the mapping from old and new frame formats to the
// boxes and lines of a table
@@ -530,1118 +345,4 @@ void SwTxtNode::CopyCollFmt( SwTxtNode& rDestNd )
rDestNd.SetAttr( aPgBrkSet );
}
-// Copy method from SwDoc
-// Prevent copying in Flys that are anchored in the area
-static bool lcl_ChkFlyFly( SwDoc* pDoc, sal_uLong nSttNd, sal_uLong nEndNd,
- sal_uLong nInsNd )
-{
- const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
-
- for( sal_uInt16 n = 0; n < rFrmFmtTbl.size(); ++n )
- {
- SwFrmFmt const*const pFmt = rFrmFmtTbl[n];
- SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
- if (pAPos &&
- ((FLY_AS_CHAR == pAnchor->GetAnchorId()) ||
- (FLY_AT_CHAR == pAnchor->GetAnchorId()) ||
- (FLY_AT_FLY == pAnchor->GetAnchorId()) ||
- (FLY_AT_PARA == pAnchor->GetAnchorId())) &&
- nSttNd <= pAPos->nNode.GetIndex() &&
- pAPos->nNode.GetIndex() < nEndNd )
- {
- const SwFmtCntnt& rCntnt = pFmt->GetCntnt();
- SwStartNode* pSNd;
- if( !rCntnt.GetCntntIdx() ||
- 0 == ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ))
- continue;
-
- if( pSNd->GetIndex() < nInsNd &&
- nInsNd < pSNd->EndOfSectionIndex() )
- // Do not copy !
- return true;
-
- if( lcl_ChkFlyFly( pDoc, pSNd->GetIndex(),
- pSNd->EndOfSectionIndex(), nInsNd ) )
- // Do not copy !
- return true;
- }
- }
-
- return false;
-}
-
-static void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam )
-{
- const SwDoc* pSrcDoc = rPam.GetDoc();
- const SwRedlineTbl& rTbl = pSrcDoc->GetRedlineTbl();
- if( !rTbl.empty() )
- {
- SwDoc* pDestDoc = rCpyPam.GetDoc();
- SwPosition* pCpyStt = rCpyPam.Start(), *pCpyEnd = rCpyPam.End();
- SwPaM* pDelPam = 0;
- const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
- // We have to count the "non-copied" nodes
- sal_uLong nDelCount = 0;
- SwNodeIndex aCorrIdx( pStt->nNode );
-
- sal_uInt16 n = 0;
- pSrcDoc->GetRedline( *pStt, &n );
- for( ; n < rTbl.size(); ++n )
- {
- const SwRangeRedline* pRedl = rTbl[ n ];
- if( nsRedlineType_t::REDLINE_DELETE == pRedl->GetType() && pRedl->IsVisible() )
- {
- const SwPosition *pRStt = pRedl->Start(), *pREnd = pRedl->End();
-
- SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
- switch( eCmpPos )
- {
- case POS_COLLIDE_END:
- case POS_BEFORE:
- // Pos1 is before Pos2
- break;
-
- case POS_COLLIDE_START:
- case POS_BEHIND:
- // Pos1 is after Pos2
- n = rTbl.size();
- break;
-
- default:
- {
- pDelPam = new SwPaM( *pCpyStt, pDelPam );
- if( *pStt < *pRStt )
- {
- lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount );
- lcl_SetCpyPos( *pRStt, *pStt, *pCpyStt,
- *pDelPam->GetPoint(), nDelCount );
- }
- pDelPam->SetMark();
-
- if( *pEnd < *pREnd )
- *pDelPam->GetPoint() = *pCpyEnd;
- else
- {
- lcl_NonCopyCount( rPam, aCorrIdx, pREnd->nNode.GetIndex(), nDelCount );
- lcl_SetCpyPos( *pREnd, *pStt, *pCpyStt,
- *pDelPam->GetPoint(), nDelCount );
- }
- }
- }
- }
- }
-
- if( pDelPam )
- {
- RedlineMode_t eOld = pDestDoc->GetRedlineMode();
- pDestDoc->SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
-
- ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo());
-
- do {
- pDestDoc->DeleteAndJoin( *(SwPaM*)pDelPam->GetNext() );
- if( pDelPam->GetNext() == pDelPam )
- break;
- delete pDelPam->GetNext();
- } while( true );
- delete pDelPam;
-
- pDestDoc->SetRedlineMode_intern( eOld );
- }
- }
-}
-
-static void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg )
-{
- SwDoc* pSrcDoc = rRg.aStart.GetNode().GetDoc();
- if( !pSrcDoc->GetRedlineTbl().empty() )
- {
- SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
- SwPaM aCpyTmp( rCpyRg.aStart, rCpyRg.aEnd );
- lcl_DeleteRedlines( aRgTmp, aCpyTmp );
- }
-}
-
-// Copy an area into this document or into another document
-bool
-SwDoc::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const
-{
- const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
-
- SwDoc* pDoc = rPos.nNode.GetNode().GetDoc();
- bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
-
- // Catch if there's no copy to do
- if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) )
- return false;
-
- // Prevent copying in Flys that are anchored in the area
- if( pDoc == this )
- {
- // Correct the Start-/EndNode
- sal_uLong nStt = pStt->nNode.GetIndex(),
- nEnd = pEnd->nNode.GetIndex(),
- nDiff = nEnd - nStt +1;
- SwNode* pNd = GetNodes()[ nStt ];
- if( pNd->IsCntntNode() && pStt->nContent.GetIndex() )
- ++nStt, --nDiff;
- if( (pNd = GetNodes()[ nEnd ])->IsCntntNode() &&
- ((SwCntntNode*)pNd)->Len() != pEnd->nContent.GetIndex() )
- --nEnd, --nDiff;
- if( nDiff &&
- lcl_ChkFlyFly( pDoc, nStt, nEnd, rPos.nNode.GetIndex() ) )
- {
- return false;
- }
- }
-
- SwPaM* pRedlineRange = 0;
- if( pDoc->IsRedlineOn() ||
- (!pDoc->IsIgnoreRedline() && !pDoc->GetRedlineTbl().empty() ) )
- pRedlineRange = new SwPaM( rPos );
-
- RedlineMode_t eOld = pDoc->GetRedlineMode();
-
- bool bRet = false;
-
- if( pDoc != this )
- { // ordinary copy
- bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange );
- }
- else if( ! ( *pStt <= rPos && rPos < *pEnd &&
- ( pStt->nNode != pEnd->nNode ||
- !pStt->nNode.GetNode().IsTxtNode() )) )
- {
- // Copy to a position outside of the area, or copy a single TextNode
- // Do an ordinary copy
- bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange );
- }
- else
- {
- // Copy the area in itself
- // Special case for handling an area with several nodes,
- // or a single node that is not a TextNode
- OSL_ENSURE( this == pDoc, " invalid copy branch!" );
- OSL_FAIL("mst: i thought this could be dead code;"
- "please tell me what you did to get here!");
- pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
-
- // Then copy the area to the underlying document area
- // (with start/end nodes clamped) and move them to
- // the desired position.
-
- SwUndoCpyDoc* pUndo = 0;
- // Save the Undo area
- SwPaM aPam( rPos );
- if (pDoc->GetIDocumentUndoRedo().DoesUndo())
- {
- pDoc->GetIDocumentUndoRedo().ClearRedo();
- pUndo = new SwUndoCpyDoc( aPam );
- }
-
- {
- ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection(
- SwNodeIndex( GetNodes().GetEndOfAutotext() ));
- aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode();
- // copy without Frames
- pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 );
-
- aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext();
- aPam.SetMark();
- SwCntntNode* pNode =
- pDoc->GetNodes().GoPrevious( &aPam.GetMark()->nNode );
- pNode->MakeEndIndex( &aPam.GetMark()->nContent );
-
- aPam.GetPoint()->nNode = *aPam.GetNode().StartOfSectionNode();
- pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode );
- pNode->MakeStartIndex( &aPam.GetPoint()->nContent );
- // move to desired position
- pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT );
-
- pNode = aPam.GetCntntNode();
- *aPam.GetPoint() = rPos; // Move the cursor for Undo
- aPam.SetMark(); // also move the Mark
- aPam.DeleteMark(); // But don't mark any area
- pDoc->DeleteSection( pNode ); // Delete the area again
- }
-
- // if Undo is enabled, store the insertion range
- if (pDoc->GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo->SetInsertRange( aPam );
- pDoc->GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- if( pRedlineRange )
- {
- pRedlineRange->SetMark();
- *pRedlineRange->GetPoint() = *aPam.GetPoint();
- *pRedlineRange->GetMark() = *aPam.GetMark();
- }
-
- pDoc->SetModified();
- bRet = true;
- }
-
- pDoc->SetRedlineMode_intern( eOld );
- if( pRedlineRange )
- {
- if( pDoc->IsRedlineOn() )
- pDoc->AppendRedline( new SwRangeRedline( nsRedlineType_t::REDLINE_INSERT, *pRedlineRange ), true);
- else
- pDoc->SplitRedline( *pRedlineRange );
- delete pRedlineRange;
- }
-
- return bRet;
-}
-
-static bool lcl_MarksWholeNode(const SwPaM & rPam)
-{
- bool bResult = false;
- const SwPosition* pStt = rPam.Start();
- const SwPosition* pEnd = rPam.End();
-
- if (NULL != pStt && NULL != pEnd)
- {
- const SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode();
- const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode();
-
- if (NULL != pSttNd && NULL != pEndNd &&
- pStt->nContent.GetIndex() == 0 &&
- pEnd->nContent.GetIndex() == pEndNd->Len())
- {
- bResult = true;
- }
- }
-
- return bResult;
-}
-
-// #i86492#
-static bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam )
-{
- bool bRet = false;
-
- const SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode();
- const SwTxtNode* pEndTxtNd = rPam.End()->nNode.GetNode().GetTxtNode();
- if ( pTxtNd && pTxtNd->IsInList() &&
- pEndTxtNd && pEndTxtNd->IsInList() )
- {
- bRet = true;
- SwNodeIndex aIdx(rPam.Start()->nNode);
-
- do
- {
- ++aIdx;
- pTxtNd = aIdx.GetNode().GetTxtNode();
-
- if ( !pTxtNd || !pTxtNd->IsInList() )
- {
- bRet = false;
- break;
- }
- } while ( pTxtNd && pTxtNd != pEndTxtNd );
- }
-
- return bRet;
-}
-
-bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos,
- const bool bMakeNewFrms, const bool bCopyAll,
- SwPaM *const pCpyRange ) const
-{
- SwDoc* pDoc = rPos.nNode.GetNode().GetDoc();
- const bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
-
- SwPosition* pStt = rPam.Start();
- SwPosition* pEnd = rPam.End();
-
- // Catch when there's no copy to do.
- if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ||
- //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end
- //JP 15.11.2001: don't test inclusive the end, ever exclusive
- ( pDoc == this && *pStt <= rPos && rPos < *pEnd ))
- {
- return false;
- }
-
- const bool bEndEqualIns = pDoc == this && rPos == *pEnd;
-
- // If Undo is enabled, create the UndoCopy object
- SwUndoCpyDoc* pUndo = 0;
- // lcl_DeleteRedlines may delete the start or end node of the cursor when
- // removing the redlines so use cursor that is corrected by PaMCorrAbs
- ::boost::scoped_ptr<SwUnoCrsr> const pCopyPam(pDoc->CreateUnoCrsr(rPos));
-
- SwTblNumFmtMerge aTNFM( *this, *pDoc );
-
- if (pDoc->GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoCpyDoc(*pCopyPam);
- pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
-
- RedlineMode_t eOld = pDoc->GetRedlineMode();
- pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
-
- // Move the PaM one node back from the insert position, so that
- // the position doesn't get moved
- pCopyPam->SetMark();
- bool bCanMoveBack = pCopyPam->Move(fnMoveBackward, fnGoCntnt);
- // If the position was shifted from more than one node, an end node has been skipped
- bool bAfterTable = false;
- if ((rPos.nNode.GetIndex() - pCopyPam->GetPoint()->nNode.GetIndex()) > 1)
- {
- // First go back to the original place
- pCopyPam->GetPoint()->nNode = rPos.nNode;
- pCopyPam->GetPoint()->nContent = rPos.nContent;
-
- bCanMoveBack = false;
- bAfterTable = true;
- }
- if( !bCanMoveBack )
- pCopyPam->GetPoint()->nNode--;
-
- SwNodeRange aRg( pStt->nNode, pEnd->nNode );
- SwNodeIndex aInsPos( rPos.nNode );
- const bool bOneNode = pStt->nNode == pEnd->nNode;
- SwTxtNode* pSttTxtNd = pStt->nNode.GetNode().GetTxtNode();
- SwTxtNode* pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
- SwTxtNode* pDestTxtNd = aInsPos.GetNode().GetTxtNode();
- bool bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() &&
- ( (pDestTxtNd && !pDestTxtNd->GetTxt().getLength()) ||
- ( !bOneNode && !rPos.nContent.GetIndex() ) );
- bool bCopyBookmarks = true;
- bool bStartIsTxtNode = 0 != pSttTxtNd;
-
- // #i104585# copy outline num rule to clipboard (for ASCII filter)
- if (pDoc->IsClipBoard() && GetOutlineNumRule())
- {
- pDoc->SetOutlineNumRule(*GetOutlineNumRule());
- }
-
- // #i86492#
- // Correct the search for a previous list:
- // First search for non-outline numbering list. Then search for non-outline
- // bullet list.
- // Keep also the <ListId> value for possible propagation.
- OUString aListIdToPropagate;
- const SwNumRule* pNumRuleToPropagate =
- pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true );
- if ( !pNumRuleToPropagate )
- {
- pNumRuleToPropagate =
- pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, true );
- }
- // #i86492#
- // Do not propagate previous found list, if
- // - destination is an empty paragraph which is not in a list and
- // - source contains at least one paragraph which is not in a list
- if ( pNumRuleToPropagate &&
- pDestTxtNd && !pDestTxtNd->GetTxt().getLength() &&
- !pDestTxtNd->IsInList() &&
- !lcl_ContainsOnlyParagraphsInList( rPam ) )
- {
- pNumRuleToPropagate = 0;
- }
-
- // This do/while block is only there so that we can break out of it!
- do {
- if( pSttTxtNd )
- {
- // Don't copy the beginning completely?
- if( !bCopyCollFmt || bColumnSel || pStt->nContent.GetIndex() )
- {
- SwIndex aDestIdx( rPos.nContent );
- bool bCopyOk = false;
- if( !pDestTxtNd )
- {
- if( pStt->nContent.GetIndex() || bOneNode )
- pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos,
- pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
- else
- {
- pDestTxtNd = static_cast<SwTxtNode*>(pSttTxtNd->MakeCopy( pDoc, aInsPos ));
- bCopyOk = true;
- }
- aDestIdx.Assign( pDestTxtNd, 0 );
- bCopyCollFmt = true;
- }
- else if( !bOneNode || bColumnSel )
- {
- const sal_Int32 nCntntEnd = pEnd->nContent.GetIndex();
- {
- ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
- pDoc->SplitNode( rPos, false );
- }
-
- if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
- {
- // after the SplitNode, span the CpyPam correctly again
- pCopyPam->Move( fnMoveBackward, fnGoCntnt );
- pCopyPam->Move( fnMoveBackward, fnGoCntnt );
- }
-
- pDestTxtNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode();
- aDestIdx.Assign(
- pDestTxtNd, pDestTxtNd->GetTxt().getLength());
-
- // Correct the area again
- if( bEndEqualIns )
- {
- bool bChg = pEnd != rPam.GetPoint();
- if( bChg )
- rPam.Exchange();
- rPam.Move( fnMoveBackward, fnGoCntnt );
- if( bChg )
- rPam.Exchange();
-
- aRg.aEnd = pEnd->nNode;
- pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
- }
- else if( rPos == *pEnd )
- {
- // The end was also moved
- pEnd->nNode--;
- pEnd->nContent.Assign( pDestTxtNd, nCntntEnd );
- aRg.aEnd = pEnd->nNode;
- pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode();
- }
- }
-
- // Safe numrule item at destination.
- // #i86492# - Safe also <ListId> item of destination.
- int aNumRuleState = SFX_ITEM_UNKNOWN;
- SwNumRuleItem aNumRuleItem;
- int aListIdState = SFX_ITEM_UNKNOWN;
- SfxStringItem aListIdItem( RES_PARATR_LIST_ID, OUString() );
- {
- const SfxItemSet * pAttrSet = pDestTxtNd->GetpSwAttrSet();
- if (pAttrSet != NULL)
- {
- const SfxPoolItem * pItem = NULL;
- aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
- if (SFX_ITEM_SET == aNumRuleState)
- aNumRuleItem = *((SwNumRuleItem *) pItem);
-
- aListIdState =
- pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
- if (SFX_ITEM_SET == aListIdState)
- {
- aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() );
- }
- }
- }
-
- if( !bCopyOk )
- {
- const sal_Int32 nCpyLen = ( (bOneNode)
- ? pEnd->nContent.GetIndex()
- : pSttTxtNd->GetTxt().getLength())
- - pStt->nContent.GetIndex();
- pSttTxtNd->CopyText( pDestTxtNd, aDestIdx,
- pStt->nContent, nCpyLen );
- if( bEndEqualIns )
- pEnd->nContent -= nCpyLen;
- }
-
- if( bOneNode )
- {
- if( bCopyCollFmt )
- {
- pSttTxtNd->CopyCollFmt( *pDestTxtNd );
-
- /* If only a part of one paragraph is copied
- restore the numrule at the destination. */
- // #i86492# - restore also <ListId> item
- if ( !lcl_MarksWholeNode(rPam) )
- {
- if (SFX_ITEM_SET == aNumRuleState)
- {
- pDestTxtNd->SetAttr(aNumRuleItem);
- }
- else
- {
- pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE);
- }
- if (SFX_ITEM_SET == aListIdState)
- {
- pDestTxtNd->SetAttr(aListIdItem);
- }
- else
- {
- pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID);
- }
- }
- }
-
- break;
- }
-
- aRg.aStart++;
- }
- }
- else if( pDestTxtNd )
- {
- // Problems with insertion of table selections into "normal" text solved.
- // We have to set the correct PaM for Undo, if this PaM starts in a textnode,
- // the undo operation will try to merge this node after removing the table.
- // If we didn't split a textnode, the PaM should start at the inserted table node
- if( rPos.nContent.GetIndex() == pDestTxtNd->Len() )
- { // Insertion at the last position of a textnode (empty or not)
- ++aInsPos; // The table will be inserted behind the text node
- }
- else if( rPos.nContent.GetIndex() )
- { // Insertion in the middle of a text node, it has to be split
- // (and joined from undo)
- bStartIsTxtNode = true;
-
- const sal_Int32 nCntntEnd = pEnd->nContent.GetIndex();
- {
- ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
- pDoc->SplitNode( rPos, false );
- }
-
- if (bCanMoveBack && rPos == *pCopyPam->GetPoint())
- {
- // after the SplitNode, span the CpyPam correctly again
- pCopyPam->Move( fnMoveBackward, fnGoCntnt );
- pCopyPam->Move( fnMoveBackward, fnGoCntnt );
- }
-
- // Correct the area again
- if( bEndEqualIns )
- aRg.aEnd--;
- // The end would also be moved
- else if( rPos == *pEnd )
- {
- rPos.nNode-=2;
- rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
- nCntntEnd );
- rPos.nNode++;
- aRg.aEnd--;
- }
- }
- else if( bCanMoveBack )
- { //Insertion at the first position of a text node. It will not be splitted, the table
- // will be inserted before the text node.
- // See below, before the SetInsertRange funciton of the undo object will be called,
- // the CpyPam would be moved to the next content position. This has to be avoided
- // We want to be moved to the table node itself thus we have to set bCanMoveBack
- // and to manipulate pCopyPam.
- bCanMoveBack = false;
- pCopyPam->GetPoint()->nNode--;
- }
- }
-
- pDestTxtNd = aInsPos.GetNode().GetTxtNode();
- if( pEndTxtNd )
- {
- SwIndex aDestIdx( rPos.nContent );
- if( !pDestTxtNd )
- {
- pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos,
- pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD));
- aDestIdx.Assign( pDestTxtNd, 0 );
- aInsPos--;
-
- // if we have to insert an extra text node
- // at the destination, this node will be our new destination
- // (text) node, and thus we set bStartisTxtNode to true. This
- // will ensure that this node will be deleted during Undo
- // using JoinNext.
- OSL_ENSURE( !bStartIsTxtNode, "Oops, undo may be instable now." );
- bStartIsTxtNode = true;
- }
-
- // Save numrule at destination
- // #i86492# - Safe also <ListId> item of destination.
- int aNumRuleState = SFX_ITEM_UNKNOWN;
- SwNumRuleItem aNumRuleItem;
- int aListIdState = SFX_ITEM_UNKNOWN;
- SfxStringItem aListIdItem( RES_PARATR_LIST_ID, OUString() );
- {
- const SfxItemSet* pAttrSet = pDestTxtNd->GetpSwAttrSet();
- if (pAttrSet != NULL)
- {
- const SfxPoolItem * pItem = NULL;
-
- aNumRuleState =
- pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
- if (SFX_ITEM_SET == aNumRuleState)
- aNumRuleItem = *((SwNumRuleItem *) pItem);
-
- aListIdState =
- pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
- if (SFX_ITEM_SET == aListIdState)
- aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() );
- }
- }
-
- const bool bEmptyDestNd = pDestTxtNd->GetTxt().isEmpty();
- pEndTxtNd->CopyText( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ),
- pEnd->nContent.GetIndex() );
-
- // Also copy all format templates
- if( bCopyCollFmt && ( bOneNode || bEmptyDestNd ))
- {
- pEndTxtNd->CopyCollFmt( *pDestTxtNd );
-
- if ( bOneNode )
- {
- /* If only a part of one paragraph is copied
- restore the numrule at the destination. */
- // #i86492# - restore also <ListId> item
- if ( !lcl_MarksWholeNode(rPam) )
- {
- if (SFX_ITEM_SET == aNumRuleState)
- {
- pDestTxtNd->SetAttr(aNumRuleItem);
- }
- else
- {
- pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE);
- }
- if (SFX_ITEM_SET == aListIdState)
- {
- pDestTxtNd->SetAttr(aListIdItem);
- }
- else
- {
- pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID);
- }
- }
- }
- }
- }
-
- if( bCopyAll || aRg.aStart != aRg.aEnd )
- {
- SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
- if( pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() )
- {
- aBrkSet.Put( *pDestTxtNd->GetpSwAttrSet() );
- if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_BREAK, false ) )
- pDestTxtNd->ResetAttr( RES_BREAK );
- if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_PAGEDESC, false ) )
- pDestTxtNd->ResetAttr( RES_PAGEDESC );
- }
-
- if( aInsPos == pEnd->nNode )
- {
- SwNodeIndex aSaveIdx( aInsPos, -1 );
- CopyWithFlyInFly( aRg, 0,aInsPos, &rPam, bMakeNewFrms, false );
- ++aSaveIdx;
- pEnd->nNode = aSaveIdx;
- pEnd->nContent.Assign( aSaveIdx.GetNode().GetTxtNode(), 0 );
- }
- else
- CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, &rPam, bMakeNewFrms, false );
-
- bCopyBookmarks = false;
-
- // Put the breaks back into the first node
- if( aBrkSet.Count() && 0 != ( pDestTxtNd = pDoc->GetNodes()[
- pCopyPam->GetPoint()->nNode.GetIndex()+1 ]->GetTxtNode()))
- {
- pDestTxtNd->SetAttr( aBrkSet );
- }
- }
- } while( false );
-
- // Adjust position (in case it was moved / in another node)
- rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(),
- rPos.nContent.GetIndex() );
-
- if( rPos.nNode != aInsPos )
- {
- pCopyPam->GetMark()->nNode = aInsPos;
- pCopyPam->GetMark()->nContent.Assign(pCopyPam->GetCntntNode(false), 0);
- rPos = *pCopyPam->GetMark();
- }
- else
- *pCopyPam->GetMark() = rPos;
-
- if ( !bAfterTable )
- pCopyPam->Move( fnMoveForward, bCanMoveBack ? fnGoCntnt : fnGoNode );
- else
- {
- // Reset the offset to 0 as it was before the insertion
- pCopyPam->GetPoint()->nContent -= pCopyPam->GetPoint()->nContent;
-
- pCopyPam->GetPoint()->nNode++;
- // If the next node is a start node, then step back: the start node
- // has been copied and needs to be in the selection for the undo
- if (pCopyPam->GetPoint()->nNode.GetNode().IsStartNode())
- pCopyPam->GetPoint()->nNode--;
-
- }
- pCopyPam->Exchange();
-
- // Also copy all bookmarks
- if( bCopyBookmarks && getIDocumentMarkAccess()->getAllMarksCount() )
- lcl_CopyBookmarks( rPam, *pCopyPam );
-
- if( nsRedlineMode_t::REDLINE_DELETE_REDLINES & eOld )
- {
- assert(*pCopyPam->GetPoint() == rPos);
- // the Node rPos points to may be deleted so unregister ...
- rPos.nContent = SwIndex(0);
- lcl_DeleteRedlines(rPam, *pCopyPam);
- rPos = *pCopyPam->GetPoint(); // ... and restore.
- }
-
- // If Undo is enabled, store the inserted area
- if (pDoc->GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo->SetInsertRange( *pCopyPam, true, bStartIsTxtNode );
- }
-
- if( pCpyRange )
- {
- pCpyRange->SetMark();
- *pCpyRange->GetPoint() = *pCopyPam->GetPoint();
- *pCpyRange->GetMark() = *pCopyPam->GetMark();
- }
-
- if ( pNumRuleToPropagate != NULL )
- {
- // #i86492# - use <SwDoc::SetNumRule(..)>, because it also handles the <ListId>
- pDoc->SetNumRule( *pCopyPam, *pNumRuleToPropagate, false,
- aListIdToPropagate, true, true );
- }
-
- pDoc->SetRedlineMode_intern( eOld );
- pDoc->SetModified();
-
- return true;
-}
-
-// Copy method from SwDoc - "copy Flys in Flys"
-void SwDoc::CopyWithFlyInFly(
- const SwNodeRange& rRg,
- const sal_Int32 nEndContentIndex,
- const SwNodeIndex& rInsPos,
- const SwPaM* pCopiedPaM,
- const bool bMakeNewFrms,
- const bool bDelRedlines,
- const bool bCopyFlyAtFly ) const
-{
- SwDoc* pDest = rInsPos.GetNode().GetDoc();
-
- _SaveRedlEndPosForRestore aRedlRest( rInsPos, 0 );
-
- SwNodeIndex aSavePos( rInsPos, -1 );
- bool bEndIsEqualEndPos = rInsPos == rRg.aEnd;
- GetNodes()._CopyNodes( rRg, rInsPos, bMakeNewFrms, true );
- ++aSavePos;
- if( bEndIsEqualEndPos )
- ((SwNodeIndex&)rRg.aEnd) = aSavePos;
-
- aRedlRest.Restore();
-
-#if OSL_DEBUG_LEVEL > 0
- {
- //JP 17.06.99: Bug 66973 - check count only if the selection is in
- // the same section or there's no section, because sections that are
- // not fully selected are not copied.
- const SwSectionNode* pSSectNd = rRg.aStart.GetNode().FindSectionNode();
- SwNodeIndex aTmpI( rRg.aEnd, -1 );
- const SwSectionNode* pESectNd = aTmpI.GetNode().FindSectionNode();
- if( pSSectNd == pESectNd &&
- !rRg.aStart.GetNode().IsSectionNode() &&
- !aTmpI.GetNode().IsEndNode() )
- {
- OSL_ENSURE( rInsPos.GetIndex() - aSavePos.GetIndex() ==
- rRg.aEnd.GetIndex() - rRg.aStart.GetIndex(),
- "An insufficient number of nodes were copied!" );
- }
- }
-#endif
-
- {
- ::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo());
- CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly );
- }
-
- SwNodeRange aCpyRange( aSavePos, rInsPos );
-
- // Also copy all bookmarks
- if( getIDocumentMarkAccess()->getAllMarksCount() )
- {
- SwPaM aRgTmp( rRg.aStart, rRg.aEnd );
- SwPaM aCpyTmp( aCpyRange.aStart, aCpyRange.aEnd );
-
- lcl_CopyBookmarks(
- pCopiedPaM != NULL ? *pCopiedPaM : aRgTmp,
- aCpyTmp );
- }
-
- if( bDelRedlines && ( nsRedlineMode_t::REDLINE_DELETE_REDLINES & pDest->GetRedlineMode() ))
- lcl_DeleteRedlines( rRg, aCpyRange );
-
- pDest->GetNodes()._DelDummyNodes( aCpyRange );
-}
-
-static void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest )
-{
- SwFmtChain aSrc( pSrc->GetChain() );
- if ( !aSrc.GetNext() )
- {
- aSrc.SetNext( pDest );
- pSrc->SetFmtAttr( aSrc );
- }
- SwFmtChain aDest( pDest->GetChain() );
- if ( !aDest.GetPrev() )
- {
- aDest.SetPrev( pSrc );
- pDest->SetFmtAttr( aDest );
- }
-}
-
-void SwDoc::CopyFlyInFlyImpl(
- const SwNodeRange& rRg,
- const sal_Int32 nEndContentIndex,
- const SwNodeIndex& rStartIdx,
- const bool bCopyFlyAtFly ) const
-{
- // First collect all Flys, sort them according to their ordering number,
- // and then only copy them. This maintains the ordering numbers (which are only
- // managed in the DrawModel).
- SwDoc *const pDest = rStartIdx.GetNode().GetDoc();
- ::std::set< _ZSortFly > aSet;
- sal_uInt16 nArrLen = GetSpzFrmFmts()->size();
-
- SwTextBoxHelper::SavedLink aOldTextBoxes;
- SwTextBoxHelper::saveLinks(*GetSpzFrmFmts(), aOldTextBoxes);
- SwTextBoxHelper::SavedContent aOldContent;
-
- for ( sal_uInt16 n = 0; n < nArrLen; ++n )
- {
- SwFrmFmt* pFmt = (*GetSpzFrmFmts())[n];
- SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
- bool bAtCntnt = (pAnchor->GetAnchorId() == FLY_AT_PARA);
- if ( pAPos &&
- ( bAtCntnt ||
- (pAnchor->GetAnchorId() == FLY_AT_FLY) ||
- (pAnchor->GetAnchorId() == FLY_AT_CHAR)) &&
- (( bCopyFlyAtFly && FLY_AT_FLY == pAnchor->GetAnchorId() )
- ? rRg.aStart <= pAPos->nNode.GetIndex() + 1
- : ( IsRedlineMove()
- ? rRg.aStart < pAPos->nNode
- : rRg.aStart <= pAPos->nNode )) &&
- pAPos->nNode <= rRg.aEnd )
- {
- //frames at the last source node are not always copied:
- //- if the node is empty and is the last node of the document or a table cell
- // or a text frame then tey have to be copied
- //- if the content index in this node is > 0 then paragph and frame bound objects are copied
- //- to-character bound objects are copied if their index is <= nEndContentIndex
- bool bAdd = false;
- if( pAPos->nNode < rRg.aEnd )
- bAdd = true;
- if (!bAdd && !IsRedlineMove()) // fdo#40599: not for redline move
- {
- bool bEmptyNode = false;
- bool bLastNode = false;
- // is the node empty?
- const SwNodes& rNodes = pAPos->nNode.GetNodes();
- SwTxtNode* pTxtNode;
- if( 0 != ( pTxtNode = pAPos->nNode.GetNode().GetTxtNode() ))
- {
- bEmptyNode = pTxtNode->GetTxt().isEmpty();
- if( bEmptyNode )
- {
- //last node information is only necessary to know for the last TextNode
- SwNodeIndex aTmp( pAPos->nNode );
- ++aTmp;//goto next node
- while (aTmp.GetNode().IsEndNode())
- {
- if( aTmp == rNodes.GetEndOfContent().GetIndex() )
- {
- bLastNode = true;
- break;
- }
- ++aTmp;
- }
- }
- }
- bAdd = bLastNode && bEmptyNode;
- if( !bAdd )
- {
- if( bAtCntnt )
- bAdd = nEndContentIndex > 0;
- else
- bAdd = pAPos->nContent <= nEndContentIndex;
- }
- }
- if( bAdd )
- {
- // Make sure draw formats don't refer to content, so that such
- // content can be removed without problems.
- SwTextBoxHelper::resetLink(pFmt, aOldContent);
- aSet.insert( _ZSortFly( pFmt, pAnchor, nArrLen + aSet.size() ));
- }
- }
- }
-
- // Store all copied (and also the newly created) frames in another array.
- // They are stored as matching the originals, so that we will be later
- // able to build the chains accordingly.
- ::std::vector< SwFrmFmt* > aVecSwFrmFmt;
- ::std::set< _ZSortFly >::const_iterator it=aSet.begin();
-
- while (it != aSet.end())
- {
- // #i59964#
- // correct determination of new anchor position
- SwFmtAnchor aAnchor( *(*it).GetAnchor() );
- SwPosition* pNewPos = (SwPosition*)aAnchor.GetCntntAnchor();
- // for at-paragraph and at-character anchored objects the new anchor
- // position can *not* be determined by the difference of the current
- // anchor position to the start of the copied range, because not
- // complete selected sections in the copied range aren't copied - see
- // method <SwNodes::_CopyNodes(..)>.
- // Thus, the new anchor position in the destination document is found
- // by counting the text nodes.
- if ((aAnchor.GetAnchorId() == FLY_AT_PARA) ||
- (aAnchor.GetAnchorId() == FLY_AT_CHAR) )
- {
- // First, determine number of anchor text node in the copied range.
- // Note: The anchor text node *have* to be inside the copied range.
- sal_uLong nAnchorTxtNdNumInRange( 0L );
- bool bAnchorTxtNdFound( false );
- SwNodeIndex aIdx( rRg.aStart );
- while ( !bAnchorTxtNdFound && aIdx <= rRg.aEnd )
- {
- if ( aIdx.GetNode().IsTxtNode() )
- {
- ++nAnchorTxtNdNumInRange;
- bAnchorTxtNdFound = aAnchor.GetCntntAnchor()->nNode == aIdx;
- }
-
- ++aIdx;
- }
- if ( !bAnchorTxtNdFound )
- {
- // This case can *not* happen, but to be robust take the first
- // text node in the destination document.
- OSL_FAIL( "<SwDoc::_CopyFlyInFly(..)> - anchor text node in copied range not found" );
- nAnchorTxtNdNumInRange = 1;
- }
- // Second, search corresponding text node in destination document
- // by counting forward from start insert position <rStartIdx> the
- // determined number of text nodes.
- aIdx = rStartIdx;
- SwNodeIndex aAnchorNdIdx( rStartIdx );
- const SwNode& aEndOfContentNd =
- aIdx.GetNode().GetNodes().GetEndOfContent();
- while ( nAnchorTxtNdNumInRange > 0 &&
- &(aIdx.GetNode()) != &aEndOfContentNd )
- {
- if ( aIdx.GetNode().IsTxtNode() )
- {
- --nAnchorTxtNdNumInRange;
- aAnchorNdIdx = aIdx;
- }
-
- ++aIdx;
- }
- if ( !aAnchorNdIdx.GetNode().IsTxtNode() )
- {
- // This case can *not* happen, but to be robust take the first
- // text node in the destination document.
- OSL_FAIL( "<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" );
- aAnchorNdIdx = rStartIdx;
- while ( !aAnchorNdIdx.GetNode().IsTxtNode() )
- {
- ++aAnchorNdIdx;
- }
- }
- // apply found anchor text node as new anchor position
- pNewPos->nNode = aAnchorNdIdx;
- }
- else
- {
- long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex();
- SwNodeIndex aIdx( rStartIdx, nOffset );
- pNewPos->nNode = aIdx;
- }
- // Set the character bound Flys back at the original character
- if ((FLY_AT_CHAR == aAnchor.GetAnchorId()) &&
- pNewPos->nNode.GetNode().IsTxtNode() )
- {
- pNewPos->nContent.Assign( (SwTxtNode*)&pNewPos->nNode.GetNode(),
- pNewPos->nContent.GetIndex() );
- }
- else
- {
- pNewPos->nContent.Assign( 0, 0 );
- }
-
- // Check recursion: copy content in its own frame, then don't copy it.
- bool bMakeCpy = true;
- if( pDest == this )
- {
- const SwFmtCntnt& rCntnt = (*it).GetFmt()->GetCntnt();
- const SwStartNode* pSNd;
- if( rCntnt.GetCntntIdx() &&
- 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) &&
- pSNd->GetIndex() < rStartIdx.GetIndex() &&
- rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() )
- {
- bMakeCpy = false;
- aSet.erase (it++);
- continue;
- }
- }
-
- // Copy the format and set the new anchor
- if( bMakeCpy )
- aVecSwFrmFmt.push_back( pDest->CopyLayoutFmt( *(*it).GetFmt(),
- aAnchor, false, true ) );
- ++it;
- }
-
- // Rebuild as much as possible of all chains that are available in the original,
- OSL_ENSURE( aSet.size() == aVecSwFrmFmt.size(), "Missing new Flys" );
- if ( aSet.size() == aVecSwFrmFmt.size() )
- {
- size_t n = 0;
- for (::std::set< _ZSortFly >::const_iterator nIt=aSet.begin() ; nIt != aSet.end(); ++nIt, ++n )
- {
- const SwFrmFmt *pFmtN = (*nIt).GetFmt();
- const SwFmtChain &rChain = pFmtN->GetChain();
- int nCnt = int(0 != rChain.GetPrev());
- nCnt += rChain.GetNext() ? 1: 0;
- size_t k = 0;
- for (::std::set< _ZSortFly >::const_iterator kIt=aSet.begin() ; kIt != aSet.end(); ++kIt, ++k )
- {
- const SwFrmFmt *pFmtK = (*kIt).GetFmt();
- if ( rChain.GetPrev() == pFmtK )
- {
- ::lcl_ChainFmts( static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]),
- static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]) );
- --nCnt;
- }
- else if ( rChain.GetNext() == pFmtK )
- {
- ::lcl_ChainFmts( static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[n]),
- static_cast< SwFlyFrmFmt* >(aVecSwFrmFmt[k]) );
- --nCnt;
- }
- }
- }
-
- // Re-create content property of draw formats, knowing how old shapes
- // were paired with old fly formats (aOldTextBoxes) and that aSet is
- // parallel with aVecSwFrmFmt.
- SwTextBoxHelper::restoreLinks(aSet, aVecSwFrmFmt, aOldTextBoxes, aOldContent);
- }
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index 18aa82a2a8ae..067c7f5b4971 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -248,7 +248,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
}
else if( pSttPos->nContent.GetIndex() )
{
- SplitNode( *pSttPos, false );
+ getIDocumentContentOperations().SplitNode( *pSttPos, false );
}
if( pPrvNd && 2 == nRegionRet )
@@ -262,7 +262,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
if( pCNd && pCNd->Len() != pEndPos->nContent.GetIndex() )
{
sal_Int32 nCntnt = pSttPos->nContent.GetIndex();
- SplitNode( *pEndPos, false );
+ getIDocumentContentOperations().SplitNode( *pEndPos, false );
SwTxtNode* pTNd;
if( pEndPos->nNode.GetIndex() == pSttPos->nNode.GetIndex() )
@@ -306,7 +306,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData,
{
pUndoInsSect->SaveSplitNode( (SwTxtNode*)pCNd, true );
}
- SplitNode( *pPos, false );
+ getIDocumentContentOperations().SplitNode( *pPos, false );
pNewSectNode = GetNodes().InsertTextSection(
pPos->nNode, *pFmt, rNewData, pTOXBase, 0, true);
}
@@ -550,7 +550,7 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, bool bDelNodes )
0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
{
SwNodeIndex aUpdIdx( *pIdx );
- DeleteSection( (SwNode*)pSectNd );
+ getIDocumentContentOperations().DeleteSection( (SwNode*)pSectNd );
if( pFtnEndAtTxtEnd )
GetFtnIdxs().UpdateFtn( aUpdIdx );
SetModified();
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index ce9cb39904ca..0faff49b1687 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -653,7 +653,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
// Make sure that the range is on Node Edges
SwNodeRange aRg( pStt->nNode, pEnd->nNode );
if( pStt->nContent.GetIndex() )
- SplitNode( *pStt, false );
+ getIDocumentContentOperations().SplitNode( *pStt, false );
bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
@@ -663,7 +663,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
|| pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
{
- SplitNode( *pEnd, false );
+ getIDocumentContentOperations().SplitNode( *pEnd, false );
((SwNodeIndex&)pEnd->nNode)--;
((SwIndex&)pEnd->nContent).Assign(
pEnd->nNode.GetNode().GetCntntNode(), 0 );
@@ -1146,7 +1146,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
// make sure that the range is on Node Edges
SwNodeRange aRg( pStt->nNode, pEnd->nNode );
if( pStt->nContent.GetIndex() )
- SplitNode( *pStt, false );
+ getIDocumentContentOperations().SplitNode( *pStt, false );
bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
@@ -1156,7 +1156,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >
if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
|| pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
{
- SplitNode( *pEnd, false );
+ getIDocumentContentOperations().SplitNode( *pEnd, false );
((SwNodeIndex&)pEnd->nNode)--;
((SwIndex&)pEnd->nContent).Assign(
pEnd->nNode.GetNode().GetCntntNode(), 0 );
@@ -2072,7 +2072,7 @@ bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
}
pTblNd->DelFrms();
- DeleteSection( pTblNd );
+ getIDocumentContentOperations().DeleteSection( pTblNd );
}
SetModified();
SetFieldsDirty( true, NULL, 0 );
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index c2278295c0cb..399bfc47199e 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1932,7 +1932,7 @@ const IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() co
IDocumentLinksAdministration* SwNode::getIDocumentLinksAdministration() { return &GetDoc()->getIDocumentLinksAdministration(); }
const IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() const { return GetDoc(); }
IDocumentFieldsAccess* SwNode::getIDocumentFieldsAccess() { return GetDoc(); }
-IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return GetDoc(); }
+IDocumentContentOperations* SwNode::getIDocumentContentOperations() { return &GetDoc()->getIDocumentContentOperations(); }
IDocumentListItems& SwNode::getIDocumentListItems() { return GetDoc()->getIDocumentListItems(); } // #i83479#
const IDocumentMarkAccess* SwNode::getIDocumentMarkAccess() const { return GetDoc()->getIDocumentMarkAccess(); }
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 828270648914..7b5aa36fb93f 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -1514,7 +1514,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes )
{
SwDoc* const pInsDoc = pDestNd->GetDoc();
::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo());
- pInsDoc->SplitNode( rPos, false );
+ pInsDoc->getIDocumentContentOperations().SplitNode( rPos, false );
}
else
{
@@ -1579,7 +1579,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes )
{
SwDoc* const pInsDoc = pDestNd->GetDoc();
::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo());
- pInsDoc->SplitNode( rPos, false );
+ pInsDoc->getIDocumentContentOperations().SplitNode( rPos, false );
}
else
{
diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx
index 6b0515aff286..6ee567a791ce 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -34,6 +34,7 @@
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <DocumentLinksAdministrationManager.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <frmtool.hxx>
@@ -1312,7 +1313,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
pCpyPam->Start()->nNode > rInsPos ||
rInsPos >= pCpyPam->End()->nNode )
{
- pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(),
+ pSrcDoc->getIDocumentContentOperations().CopyRange( *pCpyPam, *pPam->GetPoint(),
false );
}
delete pCpyPam;
@@ -1343,7 +1344,7 @@ static void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc );
- pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, NULL, bCreateFrm );
+ pSrcDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( *pCpyRg, 0, rInsPos, NULL, bCreateFrm );
++aSave;
if( !bCreateFrm )
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 0c4346e24cbe..dfcf6be3c246 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -104,11 +104,11 @@ void SwAutoCorrDoc::DeleteSel( SwPaM& rDelPam )
// so that also the DelPam be moved, include it in the
// Shell-Cursr-Ring !!
_PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, rDelPam );
- pDoc->DeleteAndJoin( rDelPam );
+ pDoc->getIDocumentContentOperations().DeleteAndJoin( rDelPam );
}
else
{
- pDoc->DeleteRange( rDelPam );
+ pDoc->getIDocumentContentOperations().DeleteRange( rDelPam );
}
}
@@ -126,7 +126,7 @@ bool SwAutoCorrDoc::Delete( sal_Int32 nStt, sal_Int32 nEnd )
bool SwAutoCorrDoc::Insert( sal_Int32 nPos, const OUString& rTxt )
{
SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos );
- rEditSh.GetDoc()->InsertString( aPam, rTxt );
+ rEditSh.GetDoc()->getIDocumentContentOperations().InsertString( aPam, rTxt );
if( !bUndoIdInitialized )
{
bUndoIdInitialized = true;
@@ -181,7 +181,7 @@ bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const
{
if (nPos == pNd->GetTxt().getLength()) // at the End do an Insert
{
- pDoc->InsertString( *pPam, rTxt );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, rTxt );
}
else
{
@@ -190,7 +190,7 @@ bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const
pPam->SetMark();
pPam->GetPoint()->nContent = std::min<sal_Int32>(
pNd->GetTxt().getLength(), nPos + nSourceLength);
- pDoc->ReplaceRange( *pPam, rTxt, false );
+ pDoc->getIDocumentContentOperations().ReplaceRange( *pPam, rTxt, false );
pPam->Exchange();
pPam->DeleteMark();
}
@@ -202,12 +202,12 @@ bool SwAutoCorrDoc::ReplaceRange( sal_Int32 nPos, sal_Int32 nSourceLength, const
pPam->SetMark();
pPam->GetPoint()->nContent = std::min<sal_Int32>(
pNd->GetTxt().getLength(), nPos + nSourceLength);
- pDoc->ReplaceRange( *pPam, rTxt, false );
+ pDoc->getIDocumentContentOperations().ReplaceRange( *pPam, rTxt, false );
pPam->Exchange();
pPam->DeleteMark();
}
else
- pDoc->Overwrite( *pPam, rTxt );
+ pDoc->getIDocumentContentOperations().Overwrite( *pPam, rTxt );
}
if( bUndoIdInitialized )
@@ -334,7 +334,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
'.' != pFnd->GetLong()[ pFnd->GetLong().getLength() - 1 ] )
{
// replace the selection
- pDoc->ReplaceRange( aPam, pFnd->GetLong(), false);
+ pDoc->getIDocumentContentOperations().ReplaceRange( aPam, pFnd->GetLong(), false);
bRet = true;
}
}
@@ -375,7 +375,7 @@ bool SwAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos,
SwDontExpandItem aExpItem;
aExpItem.SaveDontExpandItems( *aPam.GetPoint() );
- pAutoDoc->CopyRange( aCpyPam, *aPam.GetPoint(), false );
+ pAutoDoc->getIDocumentContentOperations().CopyRange( aCpyPam, *aPam.GetPoint(), false );
aExpItem.RestoreDontExpandItems( *aPam.GetPoint() );
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index dafa0a939ade..4c40b2d51b54 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -573,7 +573,7 @@ bool SwAutoFormat::DoUnderline()
aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
aBox.SetDistance( 42 ); // ~0,75 mm
aSet.Put(aBox);
- m_pDoc->InsertItemSet( m_aDelPam, aSet, 0 );
+ m_pDoc->getIDocumentContentOperations().InsertItemSet( m_aDelPam, aSet, 0 );
m_aDelPam.DeleteMark();
}
@@ -1199,7 +1199,7 @@ void SwAutoFormat::DelMoreLinesBlanks( bool bWithLineBreaks )
DeleteSel( *pNxt );
if( !bHasBlnks )
{
- m_pDoc->InsertString( *pNxt, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( *pNxt, OUString(' ') );
}
}
@@ -1256,7 +1256,7 @@ void SwAutoFormat::BuildIndent()
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetTxt() ))
{
- m_pDoc->InsertString( m_aDelPam, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
if( bBreak )
break;
@@ -1296,7 +1296,7 @@ void SwAutoFormat::BuildTextIndent()
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetTxt() ) )
{
- m_pDoc->InsertString( m_aDelPam, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
if( bBreak )
break;
@@ -1330,7 +1330,7 @@ void SwAutoFormat::BuildText()
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetTxt() ) )
{
- m_pDoc->InsertString( m_aDelPam, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
if( bBreak )
break;
@@ -1602,7 +1602,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
OUString sChgStr('\t');
if( bChgBullet )
sChgStr = OUString( m_aFlags.cBullet ) + sChgStr;
- m_pDoc->InsertString( m_aDelPam, sChgStr );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, sChgStr );
SfxItemSet aSet( m_pDoc->GetAttrPool(), aTxtNodeSetRange );
if( bChgBullet )
@@ -1644,7 +1644,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetTxt() ) )
{
- m_pDoc->InsertString( m_aDelPam, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
if( bBreak )
break;
@@ -1711,7 +1711,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
DeleteSel( m_aDelPam );
if( bInsTab )
{
- m_pDoc->InsertString( m_aDelPam, OUString('\t') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString('\t') );
}
}
}
@@ -1731,7 +1731,7 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
IsSentenceAtEnd( *pNxtNd );
if( DeleteCurNxtPara( pNxtNd->GetTxt() ) )
{
- m_pDoc->InsertString( m_aDelPam, OUString(' ') );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(' ') );
}
if( bBreak )
break;
@@ -1843,7 +1843,7 @@ void SwAutoFormat::AutoCorrect( sal_Int32 nPos )
sReplace = sReplace.copy( 0, 1 );
bSetHardBlank = true;
}
- m_pDoc->ReplaceRange( m_aDelPam, sReplace, false );
+ m_pDoc->getIDocumentContentOperations().ReplaceRange( m_aDelPam, sReplace, false );
if( m_aFlags.bWithRedlining )
{
@@ -1858,7 +1858,7 @@ void SwAutoFormat::AutoCorrect( sal_Int32 nPos )
m_aDelPam.DeleteMark();
if( bSetHardBlank )
{
- m_pDoc->InsertString( m_aDelPam, OUString(CHAR_HARDBLANK) );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(CHAR_HARDBLANK) );
++nPos;
}
}
@@ -1894,7 +1894,7 @@ void SwAutoFormat::AutoCorrect( sal_Int32 nPos )
m_aDelPam.SetMark();
m_aDelPam.GetPoint()->nContent = nPos+1;
- m_pDoc->ReplaceRange( m_aDelPam, sReplace, false );
+ m_pDoc->getIDocumentContentOperations().ReplaceRange( m_aDelPam, sReplace, false );
if( m_aFlags.bWithRedlining )
{
@@ -1912,7 +1912,7 @@ void SwAutoFormat::AutoCorrect( sal_Int32 nPos )
if( bSetHardBlank )
{
m_aDelPam.GetPoint()->nContent = nPos;
- m_pDoc->InsertString( m_aDelPam, OUString(CHAR_HARDBLANK) );
+ m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, OUString(CHAR_HARDBLANK) );
m_aDelPam.GetPoint()->nContent = ++nPos;
}
}
diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx
index 6f37e417c408..1aa40b9be4a1 100644
--- a/sw/source/core/edit/edatmisc.cxx
+++ b/sw/source/core/edit/edatmisc.cxx
@@ -110,7 +110,7 @@ void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, sal_uInt16 nFlags )
if( PCURCRSR->HasMark() && ( bIsTblMode ||
*PCURCRSR->GetPoint() != *PCURCRSR->GetMark() ))
{
- GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags );
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem(*PCURCRSR, rHint, nFlags );
}
FOREACHPAM_END()
@@ -120,7 +120,7 @@ void SwEditShell::SetAttrItem( const SfxPoolItem& rHint, sal_uInt16 nFlags )
{
if( !HasSelection() )
UpdateAttr();
- GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags );
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem( *pCrsr, rHint, nFlags );
}
EndAllAction();
}
@@ -142,7 +142,7 @@ void SwEditShell::SetAttrSet( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM*
if( pTmpCrsr->HasMark() && ( bIsTblMode ||
*pTmpCrsr->GetPoint() != *pTmpCrsr->GetMark() ))
{
- GetDoc()->InsertItemSet(*pTmpCrsr, rSet, nFlags );
+ GetDoc()->getIDocumentContentOperations().InsertItemSet(*pTmpCrsr, rSet, nFlags );
}
} while ( ( pTmpCrsr = (SwPaM*)pTmpCrsr->GetNext() ) != pStartPaM );
@@ -152,7 +152,7 @@ void SwEditShell::SetAttrSet( const SfxItemSet& rSet, sal_uInt16 nFlags, SwPaM*
{
if( !HasSelection() )
UpdateAttr();
- GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags );
+ GetDoc()->getIDocumentContentOperations().InsertItemSet( *pCrsr, rSet, nFlags );
}
EndAllAction();
}
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 854d31357b34..e925ae1bbbbc 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -20,6 +20,7 @@
#include <hintids.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <editsh.hxx>
#include <cntfrm.hxx>
#include <pam.hxx>
@@ -77,7 +78,7 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
!rNd.IsInProtectSect() )
{
// delete everything
- GetDoc()->DeleteAndJoin( aDelPam );
+ GetDoc()->getIDocumentContentOperations().DeleteAndJoin( aDelPam );
SaveTblBoxCntnt( aDelPam.GetPoint() );
}
@@ -95,7 +96,7 @@ void SwEditShell::DeleteSel( SwPaM& rPam, bool* pUndo )
// want to delete the table node before the first cell as well.
aPam.Start()->nNode = aPam.Start()->nNode.GetNode().FindTableNode()->GetIndex();
// delete everything
- GetDoc()->DeleteAndJoin( aPam );
+ GetDoc()->getIDocumentContentOperations().DeleteAndJoin( aPam );
SaveTblBoxCntnt( aPam.GetPoint() );
}
@@ -220,7 +221,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell )
++pNextInsert;
}
else if( IsBlockMode() )
- GetDoc()->SplitNode( *pPos, false );
+ GetDoc()->getIDocumentContentOperations().SplitNode( *pPos, false );
}
// Only for a selection (non-text nodes have selection but Point/GetMark are equal)
@@ -235,7 +236,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell )
bFirstMove = false;
}
- const bool bSuccess( GetDoc()->CopyRange( *PCURCRSR, *pPos, false ) );
+ const bool bSuccess( GetDoc()->getIDocumentContentOperations().CopyRange( *PCURCRSR, *pPos, false ) );
if (!bSuccess)
continue;
@@ -304,7 +305,7 @@ bool SwEditShell::Replace( const OUString& rNewStr, bool bRegExpRplc )
FOREACHPAM_START(GetCrsr())
if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() )
{
- bRet = GetDoc()->ReplaceRange( *PCURCRSR, rNewStr, bRegExpRplc )
+ bRet = GetDoc()->getIDocumentContentOperations().ReplaceRange( *PCURCRSR, rNewStr, bRegExpRplc )
|| bRet;
SaveTblBoxCntnt( PCURCRSR->GetPoint() );
}
@@ -329,7 +330,7 @@ bool SwEditShell::DelFullPara()
{
SET_CURR_SHELL( this );
StartAllAction();
- bRet = GetDoc()->DelFullPara( *pCrsr );
+ bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( *pCrsr );
EndAllAction();
}
}
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index 3478c0dcd7f6..cf95961d7266 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -37,6 +37,7 @@
#include <switerator.hxx>
#include <fieldhint.hxx>
#include <DocumentSettingManager.hxx>
+#include <IDocumentContentOperations.hxx>
/// count field types with a ResId, if 0 count all
sal_uInt16 SwEditShell::GetFldTypeCount(sal_uInt16 nResId, bool bUsed ) const
@@ -202,7 +203,7 @@ void SwEditShell::Insert2(SwField& rFld, const bool bForceExpandHints)
: nsSetAttrMode::SETATTR_DEFAULT;
FOREACHPAM_START(GetCrsr()) // for each PaM
- const bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags));
+ const bool bSuccess(GetDoc()->getIDocumentContentOperations().InsertPoolItem(*PCURCRSR, aFld, nInsertFlags));
OSL_ENSURE( bSuccess, "Doc->Insert(Field) failed");
(void) bSuccess;
FOREACHPAM_END()
diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx
index a3eaeb20db28..30cafd3c047e 100644
--- a/sw/source/core/edit/edglbldc.cxx
+++ b/sw/source/core/edit/edglbldc.cxx
@@ -160,7 +160,7 @@ bool SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos,
bEndUndo = true;
pMyDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
rPos.nNode--;
- pMyDoc->AppendTxtNode( rPos );
+ pMyDoc->getIDocumentContentOperations().AppendTxtNode( rPos );
pCrsr->SetMark();
}
@@ -202,7 +202,7 @@ bool SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos,
bEndUndo = true;
pMyDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
rPos.nNode--;
- pMyDoc->AppendTxtNode( rPos );
+ pMyDoc->getIDocumentContentOperations().AppendTxtNode( rPos );
}
InsertTableOf( rTOX );
@@ -233,7 +233,7 @@ bool SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos )
rPos.nContent.Assign( 0, 0 );
SwDoc* pMyDoc = GetDoc();
- pMyDoc->AppendTxtNode( rPos );
+ pMyDoc->getIDocumentContentOperations().AppendTxtNode( rPos );
EndAllAction();
return true;
}
@@ -263,7 +263,7 @@ bool SwEditShell::DeleteGlobalDocContent( const SwGlblDocContents& rArr ,
rPos.nNode = nDelIdx - 1;
rPos.nContent.Assign( 0, 0 );
- pMyDoc->AppendTxtNode( rPos );
+ pMyDoc->getIDocumentContentOperations().AppendTxtNode( rPos );
++nDelIdx;
}
@@ -278,7 +278,7 @@ bool SwEditShell::DeleteGlobalDocContent( const SwGlblDocContents& rArr ,
else
rPos.nNode = pMyDoc->GetNodes().GetEndOfContent();
rPos.nNode--;
- if( !pMyDoc->DelFullPara( *pCrsr ) )
+ if( !pMyDoc->getIDocumentContentOperations().DelFullPara( *pCrsr ) )
Delete();
}
break;
@@ -333,7 +333,7 @@ bool SwEditShell::MoveGlobalDocContent( const SwGlblDocContents& rArr ,
else
aInsPos = pMyDoc->GetNodes().GetEndOfContent();
- bool bRet = pMyDoc->MoveNodeRange( aRg, aInsPos,
+ bool bRet = pMyDoc->getIDocumentContentOperations().MoveNodeRange( aRg, aInsPos,
static_cast<IDocumentContentOperations::SwMoveFlags>(
IDocumentContentOperations::DOC_MOVEALLFLYS
| IDocumentContentOperations::DOC_CREATEUNDOOBJ ));
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 7a17737e4b6c..a4f0d5feb84e 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -144,7 +144,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock,
aStt = pGDoc->GetNodes().GetEndOfExtras();
pCntntNd = pGDoc->GetNodes().GoNext( &aStt );
SwPosition aInsPos( aStt, SwIndex( pCntntNd ));
- pMyDoc->CopyRange( aCpyPam, aInsPos, false );
+ pMyDoc->getIDocumentContentOperations().CopyRange( aCpyPam, aInsPos, false );
nRet = rBlock.PutDoc();
}
@@ -224,7 +224,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
{
PCURCRSR->SetMark();
PCURCRSR->Move( fnMoveForward, fnGoCntnt );
- bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false )
+ bRet = GetDoc()->getIDocumentContentOperations().CopyRange( *PCURCRSR, aPos, false )
|| bRet;
PCURCRSR->Exchange();
PCURCRSR->DeleteMark();
@@ -241,7 +241,7 @@ bool SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd )
// but we want to copy the table and the start node before
// the first cell as well.
aPaM.Start()->nNode = aPaM.Start()->nNode.GetNode().FindTableNode()->GetIndex();
- bRet = GetDoc()->CopyRange( aPaM, aPos, false ) || bRet;
+ bRet = GetDoc()->getIDocumentContentOperations().CopyRange( aPaM, aPos, false ) || bRet;
}
FOREACHPAM_END()
diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx
index 93dbf5c5168c..4db32ab381e5 100644
--- a/sw/source/core/edit/editsh.cxx
+++ b/sw/source/core/edit/editsh.cxx
@@ -67,7 +67,7 @@ void SwEditShell::Insert( sal_Unicode c, bool bOnlyCurrCrsr )
StartAllAction();
FOREACHPAM_START(GetCrsr())
- const bool bSuccess = GetDoc()->InsertString(*PCURCRSR, OUString(c));
+ const bool bSuccess = GetDoc()->getIDocumentContentOperations().InsertString(*PCURCRSR, OUString(c));
OSL_ENSURE( bSuccess, "Doc->Insert() failed." );
(void) bSuccess;
@@ -95,7 +95,7 @@ void SwEditShell::Insert2(const OUString &rStr, const bool bForceExpandHints )
do {
//OPT: GetSystemCharSet
const bool bSuccess =
- GetDoc()->InsertString(*_pStartCrsr, rStr, nInsertFlags);
+ GetDoc()->getIDocumentContentOperations().InsertString(*_pStartCrsr, rStr, nInsertFlags);
OSL_ENSURE( bSuccess, "Doc->Insert() failed." );
if (bSuccess)
@@ -165,9 +165,9 @@ void SwEditShell::Overwrite(const OUString &rStr)
{
StartAllAction();
FOREACHPAM_START(GetCrsr())
- if( !GetDoc()->Overwrite(*PCURCRSR, rStr ) )
+ if( !GetDoc()->getIDocumentContentOperations().Overwrite(*PCURCRSR, rStr ) )
{
- OSL_FAIL( "Doc->Overwrite(Str) failed." );
+ OSL_FAIL( "Doc->getIDocumentContentOperations().Overwrite(Str) failed." );
}
SaveTblBoxCntnt( PCURCRSR->GetPoint() );
FOREACHPAM_END()
@@ -182,7 +182,7 @@ long SwEditShell::SplitNode( bool bAutoFormat, bool bCheckTableStart )
FOREACHPAM_START(GetCrsr())
// Here, a table cell becomes a normal text cell.
GetDoc()->ClearBoxNumAttrs( PCURCRSR->GetPoint()->nNode );
- GetDoc()->SplitNode( *PCURCRSR->GetPoint(), bCheckTableStart );
+ GetDoc()->getIDocumentContentOperations().SplitNode( *PCURCRSR->GetPoint(), bCheckTableStart );
FOREACHPAM_END()
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
@@ -204,7 +204,7 @@ bool SwEditShell::AppendTxtNode()
FOREACHPAM_START(GetCrsr())
GetDoc()->ClearBoxNumAttrs( PCURCRSR->GetPoint()->nNode );
- bRet = GetDoc()->AppendTxtNode( *PCURCRSR->GetPoint()) || bRet;
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( *PCURCRSR->GetPoint()) || bRet;
FOREACHPAM_END()
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
@@ -305,7 +305,7 @@ void SwEditShell::ReRead( const OUString& rGrfName, const OUString& rFltName,
const Graphic* pGraphic, const GraphicObject* pGrfObj )
{
StartAllAction();
- mpDoc->ReRead( *GetCrsr(), rGrfName, rFltName, pGraphic, pGrfObj );
+ mpDoc->getIDocumentContentOperations().ReRead( *GetCrsr(), rGrfName, rFltName, pGraphic, pGrfObj );
EndAllAction();
}
@@ -511,9 +511,9 @@ void SwEditShell::ReplaceDropTxt( const OUString &rStr, SwPaM* pPaM )
const SwNodeIndex& rNd = pCrsr->GetPoint()->nNode;
SwPaM aPam( rNd, rStr.getLength(), rNd, 0 );
- if( !GetDoc()->Overwrite( aPam, rStr ) )
+ if( !GetDoc()->getIDocumentContentOperations().Overwrite( aPam, rStr ) )
{
- OSL_FAIL( "Doc->Overwrite(Str) failed." );
+ OSL_FAIL( "Doc->getIDocumentContentOperations().Overwrite(Str) failed." );
}
EndAllAction();
@@ -1064,13 +1064,13 @@ void SwEditShell::TransliterateText( sal_uInt32 nType )
FOREACHPAM_START(GetCrsr())
if( PCURCRSR->HasMark() )
- GetDoc()->TransliterateText( *PCURCRSR, aTrans );
+ GetDoc()->getIDocumentContentOperations().TransliterateText( *PCURCRSR, aTrans );
FOREACHPAM_END()
GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
}
else
- GetDoc()->TransliterateText( *pCrsr, aTrans );
+ GetDoc()->getIDocumentContentOperations().TransliterateText( *pCrsr, aTrans );
EndAllAction();
}
diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx
index efa5650e5cbe..5b13e2828730 100644
--- a/sw/source/core/edit/edlingu.cxx
+++ b/sw/source/core/edit/edlingu.cxx
@@ -562,7 +562,7 @@ void SwHyphIter::InsertSoftHyph( const sal_Int32 nHyphPos )
DelSoftHyph( *pCrsr );
pSttPos->nContent += nHyphPos;
SwPaM aRg( *pSttPos );
- pDoc->InsertString( aRg, OUString(CHAR_SOFTHYPHEN) );
+ pDoc->getIDocumentContentOperations().InsertString( aRg, OUString(CHAR_SOFTHYPHEN) );
}
// revoke selection
pCrsr->DeleteMark();
@@ -1169,11 +1169,11 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions,
if(aCurrentNewPortion->sText != aCurrentOldPortion->sText)
{
// change text ...
- mpDoc->DeleteAndJoin(*pCrsr);
+ mpDoc->getIDocumentContentOperations().DeleteAndJoin(*pCrsr);
// ... and apply language if necessary
if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId );
- mpDoc->InsertString(*pCrsr, aCurrentNewPortion->sText);
+ mpDoc->getIDocumentContentOperations().InsertString(*pCrsr, aCurrentNewPortion->sText);
}
else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage)
{
@@ -1203,7 +1203,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions,
pCrsr->GetMark()->nContent = aCurrentEndPosition->nRight;
// delete the sentence completely
- mpDoc->DeleteAndJoin(*pCrsr);
+ mpDoc->getIDocumentContentOperations().DeleteAndJoin(*pCrsr);
svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.begin();
while(aCurrentNewPortion != rNewPortions.end())
{
@@ -1221,7 +1221,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions,
if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage)
SetAttrItem( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) );
// insert the new string
- mpDoc->InsertString(*pCrsr, aCurrentNewPortion->sText);
+ mpDoc->getIDocumentContentOperations().InsertString(*pCrsr, aCurrentNewPortion->sText);
// set the cursor to the end of the inserted string
*pCrsr->Start() = *pCrsr->End();
diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx
index 246fc351d61d..f401746614a2 100644
--- a/sw/source/core/edit/edsect.cxx
+++ b/sw/source/core/edit/edsect.cxx
@@ -20,6 +20,7 @@
#include <editsh.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <pam.hxx>
#include <docary.hxx>
#include <swundo.hxx>
@@ -415,7 +416,7 @@ bool SwEditShell::DoSpecialInsert()
SwPosition aInsertPos( aInsertIndex );
// insert a new text node, and set the cursor
- bRet = GetDoc()->AppendTxtNode( aInsertPos );
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aInsertPos );
*pCursorPos = aInsertPos;
// call AttrChangeNotify for the UI
diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx
index 8d1d1231c6a0..145d565565d3 100644
--- a/sw/source/core/edit/edtab.cxx
+++ b/sw/source/core/edit/edtab.cxx
@@ -100,7 +100,7 @@ const SwTable& SwEditShell::InsertTable( const SwInsertTableOptions& rInsTblOpts
if( bEndUndo )
{
StartUndo( UNDO_START );
- GetDoc()->SplitNode( *pPos, false );
+ GetDoc()->getIDocumentContentOperations().SplitNode( *pPos, false );
}
// If called from a shell the adjust item is propagated
@@ -221,7 +221,7 @@ void SwEditShell::InsertDDETable( const SwInsertTableOptions& rInsTblOpts,
if( bEndUndo )
{
StartUndo( UNDO_START );
- GetDoc()->SplitNode( *pPos, false );
+ GetDoc()->getIDocumentContentOperations().SplitNode( *pPos, false );
}
const SwInsertTableOptions aInsTblOpts( rInsTblOpts.mnInsMode | tabopts::DEFAULT_BORDER,
diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx
index 940e71352f26..18e24f8e98d4 100644
--- a/sw/source/core/edit/edtox.cxx
+++ b/sw/source/core/edit/edtox.cxx
@@ -67,11 +67,11 @@ void SwEditShell::Insert(const SwTOXMark& rMark)
if( bInsAtPos )
{
SwPaM aTmp( *pStt );
- GetDoc()->InsertPoolItem( aTmp, rMark, 0 );
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem( aTmp, rMark, 0 );
}
else if( *pEnd != *pStt )
{
- GetDoc()->InsertPoolItem(
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem(
*PCURCRSR, rMark, nsSetAttrMode::SETATTR_DONTEXPAND );
}
diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx
index 266828abf5ba..84539b5b6026 100644
--- a/sw/source/core/edit/edundo.cxx
+++ b/sw/source/core/edit/edundo.cxx
@@ -23,6 +23,7 @@
#include <fesh.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <pam.hxx>
#include <UndoCore.hxx>
#include <swundo.hxx>
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index be8058fb826e..c99453c904bc 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -191,7 +191,7 @@ bool SwFEShell::Copy( SwDoc* pClpDoc, const OUString* pNewClpTxt )
pClpDoc->CloneSdrObj( *pObj, false, true );
SwPaM aTemp(aPos);
- pClpDoc->InsertDrawObj(aTemp, *pNew, aSet );
+ pClpDoc->getIDocumentContentOperations().InsertDrawObj(aTemp, *pNew, aSet );
}
else
{
@@ -375,7 +375,7 @@ bool SwFEShell::CopyDrawSel( SwFEShell* pDestShell, const Point& rSttPt,
aSet.Put( aAnchor );
SdrObject* pNew = pDestDoc->CloneSdrObj( *pObj, bIsMove &&
GetDoc() == pDestDoc, true );
- pFmt = pDestDoc->InsertDrawObj( *pDestShell->GetCrsr(), *pNew, aSet );
+ pFmt = pDestDoc->getIDocumentContentOperations().InsertDrawObj( *pDestShell->GetCrsr(), *pNew, aSet );
}
else
pFmt = pDestDoc->CopyLayoutFmt( *pFmt, aAnchor, true, true );
@@ -797,7 +797,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
{
SwNodeIndex aIndexBefore(rInsPos.nNode);
aIndexBefore--;
- pClpDoc->CopyRange( rCopy, rInsPos, false );
+ pClpDoc->getIDocumentContentOperations().CopyRange( rCopy, rInsPos, false );
{
++aIndexBefore;
SwPaM aPaM(SwPosition(aIndexBefore),
@@ -1031,7 +1031,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
aIndexBefore--;
- pClpDoc->CopyRange( aCpyPam, rInsPos, false );
+ pClpDoc->getIDocumentContentOperations().CopyRange( aCpyPam, rInsPos, false );
// Note: aCpyPam is invalid now
++aIndexBefore;
@@ -1060,7 +1060,7 @@ bool SwFEShell::Paste( SwDoc* pClpDoc, bool bIncludingPageFrames )
{
//remove the paragraph in front of the table
SwPaM aPara(aInsertPosition);
- GetDoc()->DelFullPara(aPara);
+ GetDoc()->getIDocumentContentOperations().DelFullPara(aPara);
}
//additionally copy page bound frames
if( bIncludingPageFrames && pClpDoc->GetSpzFrmFmts()->size() )
@@ -1140,7 +1140,7 @@ bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
StartUndo(UNDO_INSERT);
SwNodeIndex aTblIdx( *pTableNode, -1 );
SwPosition aBefore(aTblIdx);
- if(GetDoc()->AppendTxtNode( aBefore ))
+ if(GetDoc()->getIDocumentContentOperations().AppendTxtNode( aBefore ))
{
SwPaM aTmp(aBefore);
aCpyPam = aTmp;
@@ -1167,7 +1167,7 @@ bool SwFEShell::PastePages( SwFEShell& rToFill, sal_uInt16 nStartPage, sal_uInt1
//remove the paragraph in the second doc, too
SwNodeIndex aIdx( rToFill.GetDoc()->GetNodes().GetEndOfExtras(), 2 );
SwPaM aPara( aIdx ); //DocStart
- rToFill.GetDoc()->DelFullPara(aPara);
+ rToFill.GetDoc()->getIDocumentContentOperations().DelFullPara(aPara);
}
// now the page bound objects
// additionally copy page bound frames
@@ -1432,7 +1432,7 @@ void SwFEShell::Paste( SvStream& rStrm, sal_uInt16 nAction, const Point* pPt )
DelSelectedObj();
- GetDoc()->InsertDrawObj( *GetCrsr(), *pNewObj, aFrmSet );
+ GetDoc()->getIDocumentContentOperations().InsertDrawObj( *GetCrsr(), *pNewObj, aFrmSet );
}
else
{
diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx
index c2b16d60ee23..d3a67d81491e 100644
--- a/sw/source/core/frmedt/fedesc.cxx
+++ b/sw/source/core/frmedt/fedesc.cxx
@@ -21,6 +21,7 @@
#include <fesh.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <pagefrm.hxx>
#include <rootfrm.hxx>
#include <cntfrm.hxx>
@@ -95,7 +96,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc )
else
{
SwPaM aPaM( *((SwCntntFrm*)pFlow)->GetNode() );
- GetDoc()->InsertPoolItem( aPaM, aNew, 0 );
+ GetDoc()->getIDocumentContentOperations().InsertPoolItem( aPaM, aNew, 0 );
}
EndAllActionAndCall();
}
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 36f15bf3a38a..4f4fcb12fdce 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -791,11 +791,11 @@ void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
}
}
}
- pFmt = GetDoc()->Insert(*pCursor, rGrfName,
+ pFmt = GetDoc()->getIDocumentContentOperations().Insert(*pCursor, rGrfName,
rFltName, pGraphic,
pFlyAttrSet,
pGrfAttrSet, pFrmFmt );
- OSL_ENSURE( pFmt, "Doc->Insert(notxt) failed." );
+ OSL_ENSURE( pFmt, "Doc->getIDocumentContentOperations().Insert(notxt) failed." );
pCursor = dynamic_cast<SwShellCrsr*>(pCursor->GetNext());
} while( pCursor != pStartCursor );
@@ -831,9 +831,9 @@ SwFlyFrmFmt* SwFEShell::InsertObject( const svt::EmbeddedObjectRef& xObj,
SET_CURR_SHELL( this );
StartAllAction();
FOREACHPAM_START(GetCrsr())
- pFmt = GetDoc()->Insert(*PCURCRSR, xObj,
+ pFmt = GetDoc()->getIDocumentContentOperations().Insert(*PCURCRSR, xObj,
pFlyAttrSet, pGrfAttrSet, pFrmFmt );
- OSL_ENSURE( pFmt, "Doc->Insert(notxt) failed." );
+ OSL_ENSURE( pFmt, "Doc->getIDocumentContentOperations().Insert(notxt) failed." );
FOREACHPAM_END()
EndAllAction();
@@ -876,7 +876,7 @@ void SwFEShell::InsertDrawObj( SdrObject& rDrawObj,
::lcl_FindAnchorPos( *this, *GetDoc(), rInsertPosition, *pFrm, rFlyAttrSet );
}
// insert drawing object into the document creating a new <SwDrawFrmFmt> instance
- SwDrawFrmFmt* pFmt = GetDoc()->InsertDrawObj( aPam, rDrawObj, rFlyAttrSet );
+ SwDrawFrmFmt* pFmt = GetDoc()->getIDocumentContentOperations().InsertDrawObj( aPam, rDrawObj, rFlyAttrSet );
// move object to visible layer
SwContact* pContact = static_cast<SwContact*>(rDrawObj.GetUserCall());
@@ -1783,7 +1783,7 @@ bool SwFEShell::ReplaceSdrObj( const OUString& rGrfName, const OUString& rFltNam
// delete "Sdr-Object", insert the graphic instead
DelSelectedObj();
- GetDoc()->Insert( *GetCrsr(), rGrfName, rFltName, pGrf, &aFrmSet, NULL, NULL );
+ GetDoc()->getIDocumentContentOperations().Insert( *GetCrsr(), rGrfName, rFltName, pGrf, &aFrmSet, NULL, NULL );
EndUndo();
EndAllAction();
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 40c6c98815fd..b5cd31a58682 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -329,7 +329,7 @@ static void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrm* pPage, SwFEShell*
pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() );
else
{
- pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 );
+ pThis->GetDoc()->getIDocumentContentOperations().InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 );
}
pThis->EndAllAction();
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 8aa024e81da6..ca20bd0584bf 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -1347,7 +1347,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes,
{
pDoc->GetIDocumentUndoRedo().DoUndo(false);
}
- pDoc->AppendTxtNode( *aPam.GetPoint() );
+ pDoc->getIDocumentContentOperations().AppendTxtNode( *aPam.GetPoint() );
if( pUndo )
{
pDoc->GetIDocumentUndoRedo().DoUndo(bUndo);
@@ -1358,7 +1358,7 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes,
pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd );
else
{
- pDoc->MoveNodeRange( aRg, rInsPosNd,
+ pDoc->getIDocumentContentOperations().MoveNodeRange( aRg, rInsPosNd,
IDocumentContentOperations::DOC_MOVEDEFAULT );
}
// where is now aInsPos ??
diff --git a/sw/source/core/inc/DocumentContentOperationsManager.hxx b/sw/source/core/inc/DocumentContentOperationsManager.hxx
new file mode 100644
index 000000000000..a61f8e07c1c1
--- /dev/null
+++ b/sw/source/core/inc/DocumentContentOperationsManager.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCONTENTOPERATIONSMANAGER_HXX
+#define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCONTENTOPERATIONSMANAGER_HXX
+
+#include <IDocumentContentOperations.hxx>
+#include <boost/utility.hpp>
+#include <ndarr.hxx> //Only for lcl_RstTxtAttr
+
+class SwDoc;
+class SwNoTxtNode;
+class SwFmtColl;
+class SwHistory;
+
+namespace sw
+{
+
+class DocumentContentOperationsManager : public IDocumentContentOperations,
+ public ::boost::noncopyable
+{
+public:
+ DocumentContentOperationsManager( SwDoc& i_rSwdoc );
+
+ //Interface methods:
+ bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll ) const SAL_OVERRIDE;
+
+ void DeleteSection(SwNode* pNode) SAL_OVERRIDE;
+
+ bool DeleteRange(SwPaM&) SAL_OVERRIDE;
+
+ bool DelFullPara(SwPaM&) SAL_OVERRIDE;
+
+ // Add optional parameter <bForceJoinNext>, default value <false>
+ // Needed for hiding of deletion redlines
+ bool DeleteAndJoin( SwPaM&,
+ const bool bForceJoinNext = false ) SAL_OVERRIDE;
+
+ bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) SAL_OVERRIDE;
+
+ bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) SAL_OVERRIDE;
+
+ bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags) SAL_OVERRIDE;
+
+ bool Overwrite(const SwPaM &rRg, const OUString& rStr) SAL_OVERRIDE;
+
+ bool InsertString(const SwPaM &rRg, const OUString&,
+ const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ) SAL_OVERRIDE;
+
+ void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&) SAL_OVERRIDE;
+
+ SwFlyFrmFmt* Insert(const SwPaM &rRg, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic,
+ const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
+
+ SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
+
+ void ReRead(SwPaM&, const OUString& rGrfName, const OUString& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj) SAL_OVERRIDE;
+
+ SwDrawFrmFmt* InsertDrawObj( const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet& rFlyAttrSet ) SAL_OVERRIDE;
+
+ SwFlyFrmFmt* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
+
+ SwFlyFrmFmt* InsertOLE(const SwPaM &rRg, const OUString& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet, SwFrmFmt*) SAL_OVERRIDE;
+
+ bool SplitNode(const SwPosition &rPos, bool bChkTableStart) SAL_OVERRIDE;
+
+ bool AppendTxtNode(SwPosition& rPos) SAL_OVERRIDE;
+
+ bool ReplaceRange(SwPaM& rPam, const OUString& rNewStr,
+ const bool bRegExReplace) SAL_OVERRIDE;
+
+ // Add a para for the char attribute exp...
+ bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&,
+ const sal_uInt16 nFlags,bool bExpandCharToPara=false) SAL_OVERRIDE;
+
+ bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&,
+ const sal_uInt16 nFlags) SAL_OVERRIDE;
+
+ void RemoveLeadingWhiteSpace(const SwPosition & rPos ) SAL_OVERRIDE;
+
+
+ //Non-Interface methods
+
+ void CopyWithFlyInFly( const SwNodeRange& rRg,
+ const sal_Int32 nEndContentIndex,
+ const SwNodeIndex& rInsPos,
+ const SwPaM* pCopiedPaM = NULL,
+ bool bMakeNewFrms = true,
+ bool bDelRedlines = true,
+ bool bCopyFlyAtFly = false ) const;
+ void CopyFlyInFlyImpl( const SwNodeRange& rRg,
+ const sal_Int32 nEndContentIndex,
+ const SwNodeIndex& rStartIdx,
+ const bool bCopyFlyAtFly = false ) const;
+
+ /// Parameters for _Rst and lcl_SetTxtFmtColl
+ //originallyfrom docfmt.cxx
+ struct ParaRstFmt
+ {
+ SwFmtColl* pFmtColl;
+ SwHistory* pHistory;
+ const SwPosition *pSttNd, *pEndNd;
+ const SfxItemSet* pDelSet;
+ sal_uInt16 nWhich;
+ bool bReset;
+ bool bResetListAttrs; // #i62575#
+ bool bResetAll;
+ bool bInclRefToxMark;
+
+ ParaRstFmt(const SwPosition* pStt, const SwPosition* pEnd,
+ SwHistory* pHst, sal_uInt16 nWhch = 0, const SfxItemSet* pSet = 0)
+ : pFmtColl(0)
+ , pHistory(pHst)
+ , pSttNd(pStt)
+ , pEndNd(pEnd)
+ , pDelSet(pSet)
+ , nWhich(nWhch)
+ , bReset(false) // #i62675#
+ , bResetListAttrs(false)
+ , bResetAll(true)
+ , bInclRefToxMark(false)
+ {
+ }
+ };
+ static bool lcl_RstTxtAttr( const SwNodePtr& rpNd, void* pArgs ); //originally from docfmt.cxx
+
+
+ virtual ~DocumentContentOperationsManager();
+
+private:
+ SwDoc& m_rSwdoc;
+
+ bool DeleteAndJoinImpl(SwPaM&, const bool);
+ bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false);
+ bool DeleteRangeImpl(SwPaM&, const bool unused = false);
+ bool DeleteRangeImplImpl(SwPaM &);
+ bool ReplaceRangeImpl(SwPaM&, OUString const&, const bool);
+ SwFlyFrmFmt* _InsNoTxtNode( const SwPosition&rPos, SwNoTxtNode*,
+ const SfxItemSet* pFlyAttrSet,
+ const SfxItemSet* pGrfAttrSet,
+ SwFrmFmt* = 0 );
+ /* Copy a range within the same or to another document.
+ Position may not lie within range! */
+ bool CopyImpl( SwPaM&, SwPosition&, const bool MakeNewFrms /*= true */,
+ const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const;
+};
+
+}
+
+#endif // INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTCONTENTOPERATIONSMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index 60ef7a986162..6d25acefa1a4 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -30,6 +30,7 @@ class Graphic;
class SwGrfNode;
class SwUndoDelete;
class SwUndoFmtAttr;
+namespace sw { class DocumentContentOperationsManager; }
class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
{
@@ -45,7 +46,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
const IDocumentContentOperations::InsertFlags m_nInsertFlags;
- friend class SwDoc; // actually only SwDoc::Insert( String )
+ friend class ::sw::DocumentContentOperationsManager; // actually only DocumentContentOperationsManager::InsertString, because it uses CanGrouping
bool CanGrouping( sal_Unicode cIns );
bool CanGrouping( const SwPosition& rPos );
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 0135ee88516d..26e65238ff82 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -137,7 +137,7 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt )
// #i92993#
// Begin with start node of page header/footer to assure that
// complete content is checked for cursors and the complete content
- // is deleted on below made method call <pDoc->DeleteSection(pNode)>
+ // is deleted on below made method call <pDoc->getIDocumentContentOperations().DeleteSection(pNode)>
SwNodeIndex aIdx( *rCnt.GetCntntIdx(), 0 );
// If there is a Crsr registered in one of the nodes, we need to call the
// ParkCrsr in an (arbitrary) shell.
@@ -166,7 +166,7 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt )
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
OSL_ENSURE( pNode, "A big problem." );
- pDoc->DeleteSection( pNode );
+ pDoc->getIDocumentContentOperations().DeleteSection( pNode );
}
delete pFmt;
}
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 4bcf1284b48d..76584b6fb24c 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -29,6 +29,7 @@
#include <fmtfsize.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <cstdlib>
#include <vector>
#include <set>
@@ -893,7 +894,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
{
pDoc->GetIDocumentUndoRedo().DoUndo(false);
}
- pDoc->AppendTxtNode( *aPam.GetPoint() );
+ pDoc->getIDocumentContentOperations().AppendTxtNode( *aPam.GetPoint() );
if( pUndo )
{
pDoc->GetIDocumentUndoRedo().DoUndo(bUndo);
@@ -903,7 +904,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd );
else
{
- pDoc->MoveNodeRange( aRg, rInsPosNd,
+ pDoc->getIDocumentContentOperations().MoveNodeRange( aRg, rInsPosNd,
IDocumentContentOperations::DOC_NO_DELFRMS );
}
}
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 2ea5d5800a89..76330ce10fa9 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -201,8 +201,8 @@ void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
OUString const aEntry( GetField()->ExpandField( pDoc->IsClipBoard() ) );
pPaM->SetMark();
pPaM->Move( fnMoveForward );
- pDoc->DeleteRange( *pPaM );
- pDoc->InsertString( *pPaM, aEntry );
+ pDoc->getIDocumentContentOperations().DeleteRange( *pPaM );
+ pDoc->getIDocumentContentOperations().InsertString( *pPaM, aEntry );
}
}
@@ -464,7 +464,7 @@ void SwTxtFld::DeleteTxtFld( const SwTxtFld& rTxtFld )
GetPamForTxtFld(rTxtFld, pPamForTxtFld);
if (pPamForTxtFld.get() != NULL)
{
- rTxtFld.GetTxtNode().GetDoc()->DeleteAndJoin(*pPamForTxtFld);
+ rTxtFld.GetTxtNode().GetDoc()->getIDocumentContentOperations().DeleteAndJoin(*pPamForTxtFld);
}
}
}
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 5176b30c2db4..5a93c7c789c2 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -18,6 +18,7 @@
*/
#include <doc.hxx>
+#include <DocumentContentOperationsManager.hxx>
#include <cntfrm.hxx>
#include <pagefrm.hxx>
#include <fmtftn.hxx>
@@ -281,7 +282,7 @@ void SwTxtFtn::SetStartNode( const SwNodeIndex *pNewNode, bool bDelNode )
{
// 1) Die Section fuer die Fussnote wird beseitigt
// Es kann sein, dass die Inserts schon geloescht wurden.
- pDoc->DeleteSection( &m_pStartNode->GetNode() );
+ pDoc->getIDocumentContentOperations().DeleteSection( &m_pStartNode->GetNode() );
}
else
// Werden die Nodes nicht geloescht mussen sie bei den Seiten
@@ -362,7 +363,7 @@ void SwTxtFtn::CopyFtn(
SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() );
sal_uLong nDestLen = aEnd.GetIndex() - aStart.GetIndex() - 1;
- m_pTxtNode->GetDoc()->CopyWithFlyInFly( aRg, 0, aEnd, NULL, true );
+ m_pTxtNode->GetDoc()->GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aEnd, NULL, true );
// in case the destination section was not empty, delete the old nodes
// before: Src: SxxxE, Dst: SnE
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 307830c89941..cec8047959f6 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1081,7 +1081,7 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM,
aSet.Put( aFontItem );
}
- GetDoc()->InsertItemSet( rPaM, aSet, 0 );
+ GetDoc()->getIDocumentContentOperations().InsertItemSet( rPaM, aSet, 0 );
// SetAttr( aSet ); <- Does not set language attribute of empty paragraphs correctly,
// <- because since there is no selection the flag to garbage
// <- collect all attributes is set, and therefore attributes spanned
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 3df0fc96f009..26e27b6617dd 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -842,14 +842,14 @@ void SwUndoAttr::RepeatImpl(::sw::RepeatContext & rContext)
// RefMarks are not repeat capable
if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, false ) )
{
- rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
+ rContext.GetDoc().getIDocumentContentOperations().InsertItemSet( rContext.GetRepeatPaM(),
m_AttrSet, m_nInsertFlags );
}
else if ( 1 < m_AttrSet.Count() )
{
SfxItemSet aTmpSet( m_AttrSet );
aTmpSet.ClearItem( RES_TXTATR_REFMARK );
- rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(),
+ rContext.GetDoc().getIDocumentContentOperations().InsertItemSet( rContext.GetRepeatPaM(),
aTmpSet, m_nInsertFlags );
}
}
@@ -865,7 +865,7 @@ void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
RedlineMode_t eOld = rDoc.GetRedlineMode();
rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>(
eOld & ~nsRedlineMode_t::REDLINE_IGNORE));
- rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
+ rDoc.getIDocumentContentOperations().InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
if ( ULONG_MAX != m_nNodeIndex )
{
@@ -886,7 +886,7 @@ void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
}
else
{
- rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
+ rDoc.getIDocumentContentOperations().InsertItemSet( rPam, m_AttrSet, m_nInsertFlags );
}
}
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 470dbf468e6a..353b3a9587bf 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -249,7 +249,7 @@ SwUndoDelete::SwUndoDelete(
SwNodeRange aMvRg( *pEndTxtNd, 0, *pEndTxtNd, 1 );
SwPosition aSplitPos( *pEndTxtNd );
::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
- pDoc->SplitNode( aSplitPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( aSplitPos, false );
rDocNds._MoveNodes( aMvRg, rDocNds, aRg.aEnd, true );
aRg.aEnd--;
}
@@ -273,7 +273,7 @@ SwUndoDelete::SwUndoDelete(
SwNodeRange aMvRg( *pSttTxtNd, 0, *pSttTxtNd, 1 );
SwPosition aSplitPos( *pSttTxtNd );
::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
- pDoc->SplitNode( aSplitPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( aSplitPos, false );
rDocNds._MoveNodes( aMvRg, rDocNds, aRg.aStart, true );
aRg.aStart--;
}
@@ -787,7 +787,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext)
if( pSttStr && !bFromTableCopy )
{
sal_uLong nOldIdx = aPos.nNode.GetIndex();
- pDoc->SplitNode( aPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( aPos, false );
// After the split all objects are anchored at the first
// paragraph, but the pHistory of the fly frame formats relies
// on anchoring at the start of the selection
@@ -814,7 +814,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext)
if (nSttCntnt < pNd->GetTxt().getLength())
{
sal_uLong nOldIdx = aPos.nNode.GetIndex();
- pDoc->SplitNode( aPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( aPos, false );
if( bBackSp )
lcl_ReAnchorAtCntntFlyFrames( *pDoc->GetSpzFrmFmts(), aPos, nOldIdx );
}
@@ -1062,10 +1062,10 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
rPam.End()->nNode--;
if( rPam.GetPoint()->nNode == rPam.GetMark()->nNode )
*rPam.GetMark() = *rPam.GetPoint();
- rDoc.DelFullPara( rPam );
+ rDoc.getIDocumentContentOperations().DelFullPara( rPam );
}
else
- rDoc.DeleteAndJoin( rPam );
+ rDoc.getIDocumentContentOperations().DeleteAndJoin( rPam );
}
void SwUndoDelete::RepeatImpl(::sw::RepeatContext & rContext)
@@ -1084,9 +1084,9 @@ void SwUndoDelete::RepeatImpl(::sw::RepeatContext & rContext)
rPam.Move( fnMoveForward, fnGoCntnt );
}
if( bDelFullPara )
- rDoc.DelFullPara( rPam );
+ rDoc.getIDocumentContentOperations().DelFullPara( rPam );
else
- rDoc.DeleteAndJoin( rPam );
+ rDoc.getIDocumentContentOperations().DeleteAndJoin( rPam );
rContext.m_bDeleteRepeated = true;
}
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 298a1e4a7c69..bf3d63d6fc0c 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -224,7 +224,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
pTmpDoc->DeleteRedline( *pPam, true, USHRT_MAX );
}
pPam->DeleteMark();
- pTmpDoc->DelFullPara( *pPam );
+ pTmpDoc->getIDocumentContentOperations().DelFullPara( *pPam );
pPam->GetPoint()->nContent.Assign( pPam->GetCntntNode(), 0 );
}
else
@@ -302,7 +302,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext)
if( bIsAppend )
{
pPam->GetPoint()->nNode = nNode - 1;
- pTmpDoc->AppendTxtNode( *pPam->GetPoint() );
+ pTmpDoc->getIDocumentContentOperations().AppendTxtNode( *pPam->GetPoint() );
pPam->SetMark();
pPam->Move( fnMoveBackward );
@@ -400,13 +400,13 @@ void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext)
case ND_TEXTNODE:
if( bIsAppend )
{
- rDoc.AppendTxtNode( *rContext.GetRepeatPaM().GetPoint() );
+ rDoc.getIDocumentContentOperations().AppendTxtNode( *rContext.GetRepeatPaM().GetPoint() );
}
else
{
OUString const aTxt( static_cast<SwTxtNode*>(pCNd)->GetTxt() );
::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
- rDoc.InsertString( rContext.GetRepeatPaM(),
+ rDoc.getIDocumentContentOperations().InsertString( rContext.GetRepeatPaM(),
aTxt.copy(nCntnt - nLen, nLen) );
}
break;
@@ -418,7 +418,7 @@ void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext)
if( pGrfNd->IsGrfLink() )
pGrfNd->GetFileFilterNms( &sFile, &sFilter );
- rDoc.Insert( rContext.GetRepeatPaM(), sFile, sFilter,
+ rDoc.getIDocumentContentOperations().Insert( rContext.GetRepeatPaM(), sFile, sFilter,
&pGrfNd->GetGrf(),
0/* Graphics collection*/, NULL, NULL );
}
@@ -438,7 +438,7 @@ void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext)
if (aCnt.StoreEmbeddedObject(rSwOLE.GetOleRef(), aName, true, OUString(), OUString()))
{
uno::Reference < embed::XEmbeddedObject > aNew = aCnt.GetEmbeddedObject( aName );
- rDoc.Insert( rContext.GetRepeatPaM(),
+ rDoc.getIDocumentContentOperations().Insert( rContext.GetRepeatPaM(),
svt::EmbeddedObjectRef( aNew,
static_cast<SwOLENode*>(pCNd)->GetAspect() ),
NULL, NULL, NULL );
@@ -678,7 +678,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
// move it out of the way so it is not registered at deleted node
aIdx.Assign(0, 0);
- pDoc->DeleteAndJoin( rPam );
+ pDoc->getIDocumentContentOperations().DeleteAndJoin( rPam );
rPam.DeleteMark();
pNd = rPam.GetNode().GetTxtNode();
OSL_ENSURE( pNd, "Dude, where's my TextNode?" );
@@ -688,7 +688,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
if( m_bSplitNext )
{
SwPosition aPos( *pNd, aIdx );
- pDoc->SplitNode( aPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( aPos, false );
pNd->RestoreMetadata(m_pMetadataUndoEnd);
pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode();
aIdx.Assign( pNd, m_nSttCnt );
@@ -770,7 +770,7 @@ void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext)
delete pHistory, pHistory = 0;
}
- rDoc.ReplaceRange( rPam, m_sIns, m_bRegExp );
+ rDoc.getIDocumentContentOperations().ReplaceRange( rPam, m_sIns, m_bRegExp );
rPam.DeleteMark();
}
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index 8b4812acb83e..536acd94b120 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -198,7 +198,7 @@ void SwUndoMove::UndoImpl(::sw::UndoRedoContext & rContext)
SwNodeRange aRg( aIdx, aIdx );
aRg.aEnd = nDestEndNode;
aIdx = nInsPosNode;
- bool bSuccess = pDoc->MoveNodeRange( aRg, aIdx,
+ bool bSuccess = pDoc->getIDocumentContentOperations().MoveNodeRange( aRg, aIdx,
IDocumentContentOperations::DOC_MOVEDEFAULT );
if (!bSuccess)
break;
@@ -224,7 +224,7 @@ void SwUndoMove::UndoImpl(::sw::UndoRedoContext & rContext)
((SwTxtNode*)pCNd)->ClearSwpHintsArr( false );
// first delete all attributes at InsertPos
- const bool bSuccess = pDoc->MoveRange( aPam, aPos, (bMoveRedlines)
+ const bool bSuccess = pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos, (bMoveRedlines)
? IDocumentContentOperations::DOC_MOVEREDLINES
: IDocumentContentOperations::DOC_MOVEDEFAULT );
if (!bSuccess)
@@ -288,7 +288,7 @@ void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext)
{
// only a move with SwRange
SwNodeRange aRg( rNds, nSttNode, rNds, nEndNode );
- rDoc.MoveNodeRange( aRg, aIdx, (bMoveRedlines)
+ rDoc.getIDocumentContentOperations().MoveNodeRange( aRg, aIdx, (bMoveRedlines)
? IDocumentContentOperations::DOC_MOVEREDLINES
: IDocumentContentOperations::DOC_MOVEDEFAULT );
}
@@ -306,7 +306,7 @@ void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext)
bool bJoinTxt = aIdx.GetNode().IsTxtNode();
aIdx--;
- rDoc.MoveRange( aPam, aMvPos,
+ rDoc.getIDocumentContentOperations().MoveRange( aPam, aMvPos,
IDocumentContentOperations::DOC_MOVEDEFAULT );
if( nSttNode != nEndNode && bJoinTxt )
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 03a6d7250fdd..a3520b88c1d9 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -246,10 +246,10 @@ void SwUndoOverwrite::RepeatImpl(::sw::RepeatContext & rContext)
{
::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
- rDoc.Overwrite(*pAktPam, OUString(aInsStr[0]));
+ rDoc.getIDocumentContentOperations().Overwrite(*pAktPam, OUString(aInsStr[0]));
}
for( sal_Int32 n = 1; n < aInsStr.getLength(); ++n )
- rDoc.Overwrite( *pAktPam, OUString(aInsStr[n]) );
+ rDoc.getIDocumentContentOperations().Overwrite( *pAktPam, OUString(aInsStr[n]) );
}
void SwUndoOverwrite::RedoImpl(::sw::UndoRedoContext & rContext)
@@ -377,7 +377,7 @@ void SwUndoTransliterate::RepeatImpl(::sw::RepeatContext & rContext)
void SwUndoTransliterate::DoTransliterate(SwDoc & rDoc, SwPaM & rPam)
{
utl::TransliterationWrapper aTrans( ::comphelper::getProcessComponentContext(), nType );
- rDoc.TransliterateText( rPam, aTrans );
+ rDoc.getIDocumentContentOperations().TransliterateText( rPam, aTrans );
}
void SwUndoTransliterate::AddChanges( SwTxtNode& rTNd,
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 75468c17c32a..7aaea3b38827 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -253,7 +253,7 @@ void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
rDoc.DeleteRedline( aTmp, true, USHRT_MAX );
}
- rDoc.DelFullPara(rPam);
+ rDoc.getIDocumentContentOperations().DelFullPara(rPam);
SwPaM *const pPam = & rPam;
pPam->DeleteMark();
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index fec148302353..b317a126d9d0 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -139,7 +139,7 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext)
{
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i );
SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
- rDoc.MoveNodeRange(aRg, aIdx,
+ rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx,
IDocumentContentOperations::DOC_MOVEDEFAULT);
}
// delete indices
@@ -214,7 +214,7 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i);
SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 );
- rDoc.MoveNodeRange(aRg, aIdx,
+ rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx,
IDocumentContentOperations::DOC_MOVEDEFAULT);
}
// delete indices
diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx
index 704673bd64c9..2e8aa3b23797 100644
--- a/sw/source/core/undo/unspnd.cxx
+++ b/sw/source/core/undo/unspnd.cxx
@@ -156,7 +156,7 @@ void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
rPam.GetPoint()->nContent.Assign( pTNd, nCntnt );
SwDoc* pDoc = rPam.GetDoc();
- pDoc->SplitNode( *rPam.GetPoint(), bChkTblStt );
+ pDoc->getIDocumentContentOperations().SplitNode( *rPam.GetPoint(), bChkTblStt );
if( pHistory )
pHistory->SetTmpEnd( pHistory->Count() );
@@ -186,7 +186,7 @@ void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext)
void SwUndoSplitNode::RepeatImpl(::sw::RepeatContext & rContext)
{
- rContext.GetDoc().SplitNode(
+ rContext.GetDoc().getIDocumentContentOperations().SplitNode(
*rContext.GetRepeatPaM().GetPoint(), bChkTblStt );
}
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 240ed4c0c80e..201f60841528 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1009,7 +1009,6 @@ void _SaveTable::CreateNew( SwTable& rTbl, bool bCreateFrms,
: nLineCount;
SwDoc *pDoc = rTbl.GetFrmFmt()->GetDoc();
-<<<<<<< HEAD
SwChartDataProvider *pPCD = pDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider();
size_t n = 0;
for( ; n < aParent.GetTabLines().size(); ++n )
@@ -1793,7 +1792,7 @@ void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext)
// first disconnect box from node, otherwise ~SwTableBox would
// access pBox->pSttNd, deleted by DeleteSection
aDelNodes[i].first->RemoveFromTable();
- rDoc.DeleteSection(rDoc.GetNodes()[ aDelNodes[i].second ]);
+ rDoc.getIDocumentContentOperations().DeleteSection(rDoc.GetNodes()[ aDelNodes[i].second ]);
}
// Remove boxes from table structure
@@ -2063,7 +2062,7 @@ CHECKTABLE(pTblNd->GetTable())
}
delete pBox;
- rDoc.DeleteSection( rDoc.GetNodes()[ nIdx ] );
+ rDoc.getIDocumentContentOperations().DeleteSection( rDoc.GetNodes()[ nIdx ] );
}
}
CHECKTABLE(pTblNd->GetTable())
@@ -2101,7 +2100,7 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r
SwNodeIndex aTmp( rRg.aStart, -1 ), aTmp2( rPos, -1 );
SwUndoMove* pUndo = new SwUndoMove( pDoc, rRg, rPos );
::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
- pDoc->MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ?
+ pDoc->getIDocumentContentOperations().MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ?
IDocumentContentOperations::DOC_NO_DELFRMS :
IDocumentContentOperations::DOC_MOVEDEFAULT );
++aTmp;
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 6a35fe2d9b4b..6ef58f56ad32 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -307,7 +307,7 @@ void SwUndoInserts::RepeatImpl(::sw::RepeatContext & rContext)
SwPaM aPam( rContext.GetDoc().GetNodes().GetEndOfContent() );
SetPaM( aPam );
SwPaM & rRepeatPaM( rContext.GetRepeatPaM() );
- aPam.GetDoc()->CopyRange( aPam, *rRepeatPaM.GetPoint(), false );
+ aPam.GetDoc()->getIDocumentContentOperations().CopyRange( aPam, *rRepeatPaM.GetPoint(), false );
}
SwUndoInsDoc::SwUndoInsDoc( const SwPaM& rPam )
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 8f34ce48994e..25234e086d21 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1063,7 +1063,7 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, const OUString& rURL,
UnoActionContext aContext(pDoc);
if(pUnoCrsr->HasMark())
- pDoc->DeleteAndJoin(*pUnoCrsr);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(*pUnoCrsr);
SwNodeIndex aSave( pUnoCrsr->GetPoint()->nNode, -1 );
sal_Int32 nCntnt = pUnoCrsr->GetPoint()->nContent.GetIndex();
@@ -1130,12 +1130,12 @@ bool DocInsertStringSplitCR(
OSL_ENSURE( nIdx - nStartIdx >= 0, "index negative!" );
aTxt = rText.copy( nStartIdx, nIdx - nStartIdx );
if (!aTxt.isEmpty() &&
- !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
+ !rDoc.getIDocumentContentOperations().InsertString( rNewCursor, aTxt, nInsertFlags ))
{
OSL_FAIL( "Doc->Insert(Str) failed." );
bOK = false;
}
- if (!rDoc.SplitNode( *rNewCursor.GetPoint(), false ) )
+ if (!rDoc.getIDocumentContentOperations().SplitNode( *rNewCursor.GetPoint(), false ) )
{
OSL_FAIL( "SplitNode failed" );
bOK = false;
@@ -1145,7 +1145,7 @@ bool DocInsertStringSplitCR(
}
aTxt = rText.copy( nStartIdx );
if (!aTxt.isEmpty() &&
- !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags ))
+ !rDoc.getIDocumentContentOperations().InsertString( rNewCursor, aTxt, nInsertFlags ))
{
OSL_FAIL( "Doc->Insert(Str) failed." );
bOK = false;
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index d72ddc83a455..09dd5cb57e10 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -725,7 +725,7 @@ void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
if ( !pTemp )
pTemp = pPam;
UnoActionContext aAction(pDoc);
- pDoc->InsertDrawObj( *pTemp, *pObj, aSet );
+ pDoc->getIDocumentContentOperations().InsertDrawObj( *pTemp, *pObj, aSet );
SwFrmFmt* pFmt = ::FindFrmFmt( pObj );
if(pFmt)
pFmt->Add(pShape);
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index b524eccea702..4396c2677548 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1905,7 +1905,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if (aPam.HasMark() &&
m_pImpl->m_nServiceId != SW_SERVICE_FIELDTYPE_ANNOTATION)
{
- pDoc->DeleteAndJoin(aPam);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
}
SwXTextCursor const*const pTextCursor(dynamic_cast<SwXTextCursor*>(pCursor));
@@ -1923,10 +1923,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
{
// Make sure we always insert the field at the end
SwPaM aEnd(*aPam.End(), *aPam.End());
- pDoc->InsertPoolItem(aEnd, aFmt, nInsertFlags);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aEnd, aFmt, nInsertFlags);
}
else
- pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aPam, aFmt, nInsertFlags);
SwTxtAttr* pTxtAttr = aPam.GetNode().GetTxtNode()->GetFldTxtAttrAt( aPam.GetPoint()->nContent.GetIndex()-1, true );
@@ -1981,7 +1981,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
SwFmtFld aFmtFld( *pPostItField );
delete pPostItField;
SwPaM aEnd( *aIntPam.End(), *aIntPam.End() );
- m_pImpl->m_pDoc->InsertPoolItem( aEnd, aFmtFld, nsSetAttrMode::SETATTR_DEFAULT );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().InsertPoolItem( aEnd, aFmtFld, nsSetAttrMode::SETATTR_DEFAULT );
// delete former annotation
{
const SwTxtFld* pTxtFld = m_pImpl->m_pFmtFld->GetTxtFld();
@@ -1989,7 +1989,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
SwPaM aPam( rTxtNode, pTxtFld->GetStart() );
aPam.SetMark();
aPam.Move();
- m_pImpl->m_pDoc->DeleteAndJoin(aPam);
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
}
// keep inserted annotation
{
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 90c5e0566a0a..85541ba9a7ca 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -1560,7 +1560,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
throw uno::RuntimeException();
}
SwPaM aGrfPaM(*pGrfNode);
- pFmt->GetDoc()->ReRead( aGrfPaM, sGrfName, sFltName, 0,
+ pFmt->GetDoc()->getIDocumentContentOperations().ReRead( aGrfPaM, sGrfName, sFltName, 0,
pGrfObj );
}
delete pGrfObj;
@@ -1582,7 +1582,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::
}
SwPaM aGrfPaM(*pGrfNode);
Graphic aGraphic( xGraphic );
- pFmt->GetDoc()->ReRead( aGrfPaM, OUString(), OUString(), &aGraphic, 0 );
+ pFmt->GetDoc()->getIDocumentContentOperations().ReRead( aGrfPaM, OUString(), OUString(), &aGraphic, 0 );
}
}
}
@@ -2815,9 +2815,9 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
}
pFmt =
- pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet,
+ pGrfObj ? pDoc->getIDocumentContentOperations().Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet,
pParentFrmFmt )
- : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic,
+ : pDoc->getIDocumentContentOperations().Insert( aPam, sGraphicURL, sFltName, &aGraphic,
&aFrmSet, &aGrSet, pParentFrmFmt );
delete pGrfObj;
if(pFmt)
@@ -2922,7 +2922,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
// TODO/LATER: Is it the only possible aspect here?
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect );
- pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL );
+ pFmt2 = pDoc->getIDocumentContentOperations().Insert(aPam, xObjRef, &aFrmSet, NULL, NULL );
assert(pFmt2 && "Doc->Insert(notxt) failed.");
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
@@ -2938,7 +2938,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
SwFlyFrmFmt* pFrmFmt = 0;
- pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL );
+ pFrmFmt = pDoc->getIDocumentContentOperations().InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL );
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
pFrmFmt->Add(this);
if(!m_sName.isEmpty())
@@ -2964,7 +2964,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
mrPers.GetEmbeddedObjectContainer().InsertEmbeddedObject( obj, rName );
SwFlyFrmFmt* pFrmFmt = 0;
- pFrmFmt = pDoc->Insert( aPam, xObj, &aFrmSet, NULL, NULL );
+ pFrmFmt = pDoc->getIDocumentContentOperations().Insert( aPam, xObj, &aFrmSet, NULL, NULL );
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL);
pFrmFmt->Add(this);
if(!m_sName.isEmpty())
diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx
index e082e5c0fe49..1aab582abc8a 100644
--- a/sw/source/core/unocore/unoftn.cxx
+++ b/sw/source/core/unocore/unoftn.cxx
@@ -310,7 +310,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
::sw::XTextRangeToSwPaM(aPam, xTextRange);
UnoActionContext aCont(pNewDoc);
- pNewDoc->DeleteAndJoin(aPam);
+ pNewDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
aPam.DeleteMark();
SwFmtFtn aFootNote(m_pImpl->m_bIsEndnote);
if (!m_pImpl->m_sLabel.isEmpty())
@@ -325,7 +325,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
? nsSetAttrMode::SETATTR_FORCEHINTEXPAND
: nsSetAttrMode::SETATTR_DEFAULT;
- pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags);
+ pNewDoc->getIDocumentContentOperations().InsertPoolItem(aPam, aFootNote, nInsertFlags);
SwTxtFtn *const pTxtAttr = static_cast<SwTxtFtn*>(
aPam.GetNode().GetTxtNode()->GetTxtAttrForCharAt(
@@ -378,7 +378,7 @@ void SAL_CALL SwXFootnote::dispose() throw (uno::RuntimeException, std::exceptio
SwTxtNode& rTxtNode = const_cast<SwTxtNode&>(pTxtFtn->GetTxtNode());
const sal_Int32 nPos = pTxtFtn->GetStart();
SwPaM aPam(rTxtNode, nPos, rTxtNode, nPos+1);
- GetDoc()->DeleteAndJoin( aPam );
+ GetDoc()->getIDocumentContentOperations().DeleteAndJoin( aPam );
}
void SAL_CALL
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index 411fdda9f8a4..99802a72a1cc 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -1344,7 +1344,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
UnoActionContext aAction(pDoc);
if (aPam.HasMark())
{
- pDoc->DeleteAndJoin(aPam);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
}
SwTOXBase & rTOXBase = m_pImpl->m_pProps->GetTOXBase();
@@ -1956,7 +1956,7 @@ void SwXDocumentIndexMark::Impl::InsertTOXMark(
rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_TOXMARK);
}
- pDoc->InsertPoolItem(rPam, rMark, nInsertFlags);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(rPam, rMark, nInsertFlags);
if (bMark && *rPam.GetPoint() > *rPam.GetMark())
{
rPam.Exchange();
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index be5ca9f6c7bf..595237813705 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -792,7 +792,7 @@ void SwXTextCursor::DeleteAndInsert(const OUString& rText,
{
if (pCurrent->HasMark())
{
- pDoc->DeleteAndJoin(*pCurrent);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(*pCurrent);
}
if(nTxtLen)
{
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 1c350b6d3c14..089e1d14bf61 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -317,7 +317,7 @@ void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam,
( (bTableMode) ||
(*pCurrent->GetPoint() != *pCurrent->GetMark()) ))
{
- pDoc->InsertItemSet(*pCurrent, rSet, nFlags);
+ pDoc->getIDocumentContentOperations().InsertItemSet(*pCurrent, rSet, nFlags);
}
pCurrent= static_cast<SwPaM *>(pCurrent->GetNext());
} while (pCurrent != &rPam);
@@ -326,7 +326,7 @@ void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam,
}
else
{
- pDoc->InsertItemSet( rPam, rSet, nFlags );
+ pDoc->getIDocumentContentOperations().InsertItemSet( rPam, rSet, nFlags );
}
if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE )
@@ -842,7 +842,7 @@ throw (uno::RuntimeException)
m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
if (aCursor.HasMark())
{
- m_pImpl->m_rDoc.DeleteAndJoin(aCursor);
+ m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor);
}
if (!rText.isEmpty())
@@ -1675,7 +1675,7 @@ void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL);
if (rCursor.HasMark())
{
- pDoc->DeleteAndJoin(rCursor);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(rCursor);
}
if (!rString.isEmpty())
{
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index bbc0474aad0d..ebb5733f0337 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1271,7 +1271,7 @@ void SAL_CALL SwXParagraph::dispose() throw (uno::RuntimeException, std::excepti
// select paragraph
{
SwParaSelection aParaSel( aCursor );
- pTxtNode->GetDoc()->DelFullPara(aCursor);
+ pTxtNode->GetDoc()->getIDocumentContentOperations().DelFullPara(aCursor);
}
lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
m_pImpl->m_EventListeners.disposeAndClear(ev);
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index aec2d1ff4be3..9a39778107fe 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -225,7 +225,7 @@ void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam,
rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_REFMARK);
}
- pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags );
+ pDoc2->getIDocumentContentOperations().InsertPoolItem( rPam, aRefMark, nInsertFlags );
if( bMark && *rPam.GetPoint() > *rPam.GetMark())
{
@@ -358,7 +358,7 @@ void SAL_CALL SwXReferenceMark::dispose() throw (uno::RuntimeException, std::exc
: nStt + 1;
SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd );
- m_pImpl->m_pDoc->DeleteAndJoin( aPam );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam );
}
}
}
@@ -432,7 +432,7 @@ throw (uno::RuntimeException, std::exception)
SwPaM aPam( rTxtNode, nStt, rTxtNode, nEnd );
// deletes the m_pImpl->m_pDoc member in the SwXReferenceMark!
- m_pImpl->m_pDoc->DeleteAndJoin( aPam );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam );
// The aPam will keep the correct and functional doc though
m_pImpl->m_sMarkName = rName;
@@ -958,7 +958,7 @@ SwXMeta::dispose() throw (uno::RuntimeException, std::exception)
// -1 because of CH_TXTATR
SwPaM aPam( *pTxtNode, nMetaStart - 1, *pTxtNode, nMetaEnd );
SwDoc * const pDoc( pTxtNode->GetDoc() );
- pDoc->DeleteAndJoin( aPam );
+ pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam );
// removal should call Modify and do the dispose
OSL_ENSURE(m_pImpl->m_bIsDisposed, "zombie meta");
@@ -1029,7 +1029,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
: ::boost::shared_ptr< ::sw::Meta>(
pDoc->GetMetaFieldManager().makeMetaField()) );
SwFmtMeta meta(pMeta, i_nWhich); // this is cloned by Insert!
- const bool bSuccess( pDoc->InsertPoolItem( aPam, meta, nInsertFlags ) );
+ const bool bSuccess( pDoc->getIDocumentContentOperations().InsertPoolItem( aPam, meta, nInsertFlags ) );
SwTxtAttr * const pTxtAttr( pMeta->GetTxtAttr() );
if (!bSuccess)
{
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index daf107632b57..00aae9721ceb 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -34,6 +34,7 @@
#include <swtblfmt.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <shellres.hxx>
#include <docary.hxx>
#include <ndole.hxx>
@@ -2353,12 +2354,12 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex
const SwTable *pTable = 0;
if( 0 != aPam.Start()->nContent.GetIndex() )
{
- pDoc->SplitNode(*aPam.Start(), false );
+ pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false );
}
//TODO: if it is the last paragraph than add another one!
if( aPam.HasMark() )
{
- pDoc->DeleteAndJoin(aPam);
+ pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
aPam.DeleteMark();
}
pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ),
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index adca8759989c..602835b28113 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -418,7 +418,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
SwPaM aTmp(*aPam.Start());
if (bAbsorb && aPam.HasMark())
{
- m_pImpl->m_pDoc->DeleteAndJoin(aPam);
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
}
sal_Unicode cIns = 0;
@@ -427,12 +427,12 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
case text::ControlCharacter::PARAGRAPH_BREAK :
// a table cell now becomes an ordinary text cell!
m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
- m_pImpl->m_pDoc->SplitNode( *aTmp.GetPoint(), false );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().SplitNode( *aTmp.GetPoint(), false );
break;
case text::ControlCharacter::APPEND_PARAGRAPH:
{
m_pImpl->m_pDoc->ClearBoxNumAttrs( aTmp.GetPoint()->nNode );
- m_pImpl->m_pDoc->AppendTxtNode( *aTmp.GetPoint() );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().AppendTxtNode( *aTmp.GetPoint() );
const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
xTextRange, uno::UNO_QUERY);
@@ -460,7 +460,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
}
if (cIns)
{
- m_pImpl->m_pDoc->InsertString( aTmp, OUString(cIns), nInsertFlags );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().InsertString( aTmp, OUString(cIns), nInsertFlags );
}
if (bAbsorb)
@@ -654,7 +654,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
const SwNodeIndex aTblIdx( *pTblNode, -1 );
SwPosition aBefore(aTblIdx);
- bRet = GetDoc()->AppendTxtNode( aBefore );
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aBefore );
pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
}
else if (pXSection && pXSection->GetFmt() &&
@@ -665,7 +665,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
const SwNodeIndex aSectIdx( *pSectNode, -1 );
SwPosition aBefore(aSectIdx);
- bRet = GetDoc()->AppendTxtNode( aBefore );
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aBefore );
pTxtNode = aBefore.nNode.GetNode().GetTxtNode();
}
if (!bRet || !pTxtNode)
@@ -713,7 +713,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
SwEndNode *const pTableEnd = pTblNode->EndOfSectionNode();
SwPosition aTableEnd(*pTableEnd);
- bRet = GetDoc()->AppendTxtNode( aTableEnd );
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aTableEnd );
pTxtNode = aTableEnd.nNode.GetNode().GetTxtNode();
}
else if (pXSection && pXSection->GetFmt() &&
@@ -723,7 +723,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
SwSectionNode *const pSectNode = pSectFmt->GetSectionNode();
SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
SwPosition aEnd(*pEnd);
- bRet = GetDoc()->AppendTxtNode( aEnd );
+ bRet = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aEnd );
pTxtNode = aEnd.nNode.GetNode().GetTxtNode();
}
if (!bRet || !pTxtNode)
@@ -764,7 +764,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if(aTblIdx.GetNode().IsTxtNode())
{
SwPaM aBefore(aTblIdx);
- bRet = GetDoc()->DelFullPara( aBefore );
+ bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aBefore );
}
}
else if (pXSection && pXSection->GetFmt() &&
@@ -777,7 +777,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if(aSectIdx.GetNode().IsTxtNode())
{
SwPaM aBefore(aSectIdx);
- bRet = GetDoc()->DelFullPara( aBefore );
+ bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aBefore );
}
}
if(!bRet)
@@ -818,7 +818,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if(aTblIdx.GetNode().IsTxtNode())
{
SwPaM aPaM(aTblIdx);
- bRet = GetDoc()->DelFullPara( aPaM );
+ bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aPaM );
}
}
else if (pXSection && pXSection->GetFmt() &&
@@ -831,7 +831,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception)
if(aSectIdx.GetNode().IsTxtNode())
{
SwPaM aAfter(aSectIdx);
- bRet = GetDoc()->DelFullPara( aAfter );
+ bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aAfter );
}
}
if(!bRet)
@@ -959,10 +959,10 @@ SwXText::setString(const OUString& rString) throw (uno::RuntimeException, std::e
while(aStartIdx < aEndIdx);
if(bInsertNodes)
{
- GetDoc()->AppendTxtNode( aStartPos );
+ GetDoc()->getIDocumentContentOperations().AppendTxtNode( aStartPos );
SwPosition aEndPos(aEndIdx.GetNode());
SwPaM aPam(aEndPos);
- GetDoc()->AppendTxtNode( *aPam.Start() );
+ GetDoc()->getIDocumentContentOperations().AppendTxtNode( *aPam.Start() );
}
}
@@ -1294,7 +1294,7 @@ SwXText::Impl::finishOrAppendParagraph(
aPam = aStartPam;
aPam.SetMark();
}
- m_pDoc->AppendTxtNode( *aPam.GetPoint() );
+ m_pDoc->getIDocumentContentOperations().AppendTxtNode( *aPam.GetPoint() );
// remove attributes from the previous paragraph
m_pDoc->ResetAttrs(aPam);
// in case of finishParagraph the PaM needs to be moved to the
@@ -1594,7 +1594,7 @@ SwXText::convertToTextFrame(
}
const SwNodeIndex aTblIdx( *pStartTableNode, -1 );
SwPosition aBefore(aTblIdx);
- bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore );
+ bParaBeforeInserted = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aBefore );
aStartPam.DeleteMark();
*aStartPam.GetPoint() = aBefore;
pStartStartNode = aStartPam.GetNode().StartOfSectionNode();
@@ -1604,7 +1604,7 @@ SwXText::convertToTextFrame(
SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode();
SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode();
SwPosition aTableEnd(*pTableEnd);
- bParaAfterInserted = GetDoc()->AppendTxtNode( aTableEnd );
+ bParaAfterInserted = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aTableEnd );
pEndPam->DeleteMark();
*pEndPam->GetPoint() = aTableEnd;
pEndStartNode = pEndPam->GetNode().StartOfSectionNode();
@@ -1622,7 +1622,7 @@ SwXText::convertToTextFrame(
aDelete.MovePara(fnParaCurr, fnParaStart);
aDelete.SetMark();
aDelete.MovePara(fnParaCurr, fnParaEnd);
- GetDoc()->DelFullPara(aDelete);
+ GetDoc()->getIDocumentContentOperations().DelFullPara(aDelete);
}
if (bParaAfterInserted)
{
@@ -1632,7 +1632,7 @@ SwXText::convertToTextFrame(
aDelete.MovePara(fnParaCurr, fnParaStart);
aDelete.SetMark();
aDelete.MovePara(fnParaCurr, fnParaEnd);
- GetDoc()->DelFullPara(aDelete);
+ GetDoc()->getIDocumentContentOperations().DelFullPara(aDelete);
}
throw lang::IllegalArgumentException();
}
@@ -1646,7 +1646,7 @@ SwXText::convertToTextFrame(
&& aStartPam.End()->nNode == pEndPam->End()->nNode )
{
SwPosition aEnd(*aStartPam.End());
- bParaAfterInserted = GetDoc()->AppendTxtNode( aEnd );
+ bParaAfterInserted = GetDoc()->getIDocumentContentOperations().AppendTxtNode( aEnd );
pEndPam->DeleteMark();
*pEndPam->GetPoint() = aEnd;
}
@@ -1716,7 +1716,7 @@ SwXText::convertToTextFrame(
}
}
}
- m_pImpl->m_pDoc->DelFullPara(aStartPam);
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(aStartPam);
}
}
catch (const lang::IllegalArgumentException& rIllegal)
@@ -1741,20 +1741,20 @@ SwXText::convertToTextFrame(
if (bParaBeforeInserted)
{
// todo: remove paragraph before frame
- m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pFrameCursor->GetPaM());
}
if (bParaAfterInserted)
{
xFrameTextCursor->gotoEnd(sal_False);
if (!bParaBeforeInserted)
- m_pImpl->m_pDoc->DelFullPara(*pFrameCursor->GetPaM());
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pFrameCursor->GetPaM());
else
{
// In case the frame has a table only, the cursor points to the end of the first cell of the table.
SwPaM aPaM(*pFrameCursor->GetPaM()->GetNode().FindSttNodeByType(SwFlyStartNode)->EndOfSectionNode());
// Now we have the end of the frame -- the node before that will be the paragraph we want to remove.
aPaM.GetPoint()->nNode--;
- m_pImpl->m_pDoc->DelFullPara(aPaM);
+ m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(aPaM);
}
}
}
@@ -1898,7 +1898,7 @@ void SwXText::Impl::ConvertCell(
// align the beginning - if necessary
if (aStartCellPam.Start()->nContent.GetIndex())
{
- m_pDoc->SplitNode(*aStartCellPam.Start(), false);
+ m_pDoc->getIDocumentContentOperations().SplitNode(*aStartCellPam.Start(), false);
}
}
else
@@ -1917,7 +1917,7 @@ void SwXText::Impl::ConvertCell(
}
else
{
- m_pDoc->SplitNode(*aStartCellPam.Start(), false);
+ m_pDoc->getIDocumentContentOperations().SplitNode(*aStartCellPam.Start(), false);
}
}
else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1))
@@ -1936,7 +1936,7 @@ void SwXText::Impl::ConvertCell(
if (aEndCellPam.End()->nContent.GetIndex() <
aEndCellPam.End()->nNode.GetNode().GetTxtNode()->Len())
{
- m_pDoc->SplitNode(*aEndCellPam.End(), false);
+ m_pDoc->getIDocumentContentOperations().SplitNode(*aEndCellPam.End(), false);
// take care that the new start/endcell is moved to the right position
// aStartCellPam has to point to the start of the new (previous) node
// aEndCellPam has to point to the end of the new (previous) node
@@ -2337,7 +2337,7 @@ throw (uno::RuntimeException, std::exception)
SwNodeIndex rNdIndex( *GetStartNode( ), 1 );
SwPosition rPos( rNdIndex );
- m_pImpl->m_pDoc->CopyRange( *pCursor->GetPaM(), rPos, false );
+ m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange( *pCursor->GetPaM(), rPos, false );
}
SwXBodyText::SwXBodyText(SwDoc *const pDoc)
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index c368c3077baf..6571a5f09af7 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -2529,7 +2529,7 @@ const IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() const { r
IDocumentRedlineAccess* SwViewShell::getIDocumentRedlineAccess() { return mpDoc; }
const IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() const { return mpDoc; }
IDocumentLayoutAccess* SwViewShell::getIDocumentLayoutAccess() { return mpDoc; }
-IDocumentContentOperations* SwViewShell::getIDocumentContentOperations() { return mpDoc; }
+IDocumentContentOperations* SwViewShell::getIDocumentContentOperations() { return &mpDoc->getIDocumentContentOperations(); }
IDocumentStylePoolAccess* SwViewShell::getIDocumentStylePoolAccess() { return mpDoc; }
const IDocumentStatistics* SwViewShell::getIDocumentStatistics() const { return mpDoc; }
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index 21b3c833733f..1047a6a9b554 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -230,7 +230,7 @@ sal_uLong SwASCIIParser::CallParser()
// !!!!!
OSL_ENSURE( !this, "Have to change - hard attr. to para. style" );
- pDoc->InsertItemSet( *pInsPam, *pItemSet, 0 );
+ pDoc->getIDocumentContentOperations().InsertItemSet( *pInsPam, *pItemSet, 0 );
}
}
delete pItemSet, pItemSet = 0;
@@ -371,7 +371,7 @@ sal_uLong SwASCIIParser::ReadChars()
// We skip the last one at the end
if( !rInput.IsEof() || !(pEnd == pStt ||
( !*pEnd && pEnd == pStt+1 ) ) )
- pDoc->SplitNode( *pPam->GetPoint(), false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
}
}
@@ -425,8 +425,8 @@ sal_uLong SwASCIIParser::ReadChars()
{
InsertText( OUString( pLastStt ));
}
- pDoc->SplitNode( *pPam->GetPoint(), false );
- pDoc->InsertPoolItem(
+ pDoc->getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
+ pDoc->getIDocumentContentOperations().InsertPoolItem(
*pPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0);
pLastStt = pStt;
nLineLen = 0;
@@ -458,7 +458,7 @@ sal_uLong SwASCIIParser::ReadChars()
sal_Unicode c = *pStt;
*pStt = 0;
InsertText( OUString( pLastStt ));
- pDoc->SplitNode( *pPam->GetPoint(), false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
pLastStt = pStt;
nLineLen = 0;
*pStt = c;
@@ -470,7 +470,7 @@ sal_uLong SwASCIIParser::ReadChars()
{
// We found a CR/LF, thus save the text
InsertText( OUString( pLastStt ));
- pDoc->SplitNode( *pPam->GetPoint(), false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPam->GetPoint(), false );
pLastStt = pStt;
nLineLen = 0;
}
@@ -486,7 +486,7 @@ sal_uLong SwASCIIParser::ReadChars()
void SwASCIIParser::InsertText( const OUString& rStr )
{
- pDoc->InsertString( *pPam, rStr );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, rStr );
pDoc->UpdateRsid( *pPam, rStr.getLength() );
pDoc->UpdateParRsid( pPam->GetPoint()->nNode.GetNode().GetTxtNode() );
diff --git a/sw/source/filter/html/htmldrawreader.cxx b/sw/source/filter/html/htmldrawreader.cxx
index 346c94dcf78d..11099f9dfa2e 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -200,7 +200,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
}
aFrmSet.Put( aAnchor );
- pDoc->InsertDrawObj( *pPam, *pNewDrawObj, aFrmSet );
+ pDoc->getIDocumentContentOperations().InsertDrawObj( *pPam, *pNewDrawObj, aFrmSet );
}
static void PutEEPoolItem( SfxItemSet &rEEItemSet,
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index bc8359cb5e71..36648def7d64 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -528,7 +528,7 @@ void SwHTMLParser::NewField()
}
else
{
- pDoc->InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 );
delete pFld;
}
bInField = true;
@@ -566,7 +566,7 @@ void SwHTMLParser::EndField()
break;
}
- pDoc->InsertPoolItem( *pPam, SwFmtFld(*pField), 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pPam, SwFmtFld(*pField), 0 );
delete pField;
pField = 0;
}
diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx
index c3c2b9061739..bc8a310e34a7 100644
--- a/sw/source/filter/html/htmlftn.cxx
+++ b/sw/source/filter/html/htmlftn.cxx
@@ -204,7 +204,7 @@ void SwHTMLParser::FinishFootEndNote()
if( pFootEndNoteImpl->bFixed )
aFtn.SetNumStr( pFootEndNoteImpl->sContent );
- pDoc->InsertPoolItem( *pPam, aFtn, 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pPam, aFtn, 0 );
SwTxtFtn * const pTxtFtn = static_cast<SwTxtFtn *>(
pPam->GetNode().GetTxtNode()->GetTxtAttrForCharAt(
pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) );
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 0eeea5eb6ced..1265dae7cbb5 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -713,7 +713,7 @@ IMAGE_SETEVENT:
{
aEmptyGrf.SetDefaultType();
}
- SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyOUStr, &aEmptyGrf,
+ SwFrmFmt *pFlyFmt = pDoc->getIDocumentContentOperations().Insert( *pPam, sGrfNm, aEmptyOUStr, &aEmptyGrf,
&aFrmSet, NULL, NULL );
SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
->GetIndex()+1 ]->GetGrfNode();
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 7d3c898fe202..b9ca200d6c73 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -461,7 +461,7 @@ void SwHTMLParser::InsertEmbed()
// und in das Dok einfuegen
SwFrmFmt* pFlyFmt =
- pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
+ pDoc->getIDocumentContentOperations().Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
// Namen am FrmFmt setzen
if( !aName.isEmpty() )
@@ -633,7 +633,7 @@ void SwHTMLParser::EndObject()
// und in das Dok einfuegen
SwFrmFmt* pFlyFmt =
- pDoc->Insert( *pPam,
+ pDoc->getIDocumentContentOperations().Insert( *pPam,
::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
&pAppletImpl->GetItemSet(),
NULL,
@@ -765,7 +765,7 @@ void SwHTMLParser::EndApplet()
// und in das Dok einfuegen
SwFrmFmt* pFlyFmt =
- pDoc->Insert( *pPam,
+ pDoc->getIDocumentContentOperations().Insert( *pPam,
::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
&pAppletImpl->GetItemSet(),
NULL,
@@ -935,7 +935,7 @@ void SwHTMLParser::InsertFloatingFrame()
// und in das Dok einfuegen
SwFrmFmt* pFlyFmt =
- pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
+ pDoc->getIDocumentContentOperations().Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
// den alternativen Namen setzen
SwNoTxtNode *pNoTxtNd =
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index 48fd9daee314..0da117949baf 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -199,7 +199,7 @@ void SwHTMLParser::NewDivision( int nToken )
(const SwStartNode *) &rCntntStIdx.GetNode();
aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex() - 1;
- pDoc->DelFullPara( aDelPam );
+ pDoc->getIDocumentContentOperations().DelFullPara( aDelPam );
// Die Seitenvorlage aktualisieren
for( sal_uInt16 i=0; i < pDoc->GetPageDescCnt(); i++ )
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 7faf745f1a6c..99f52a83d15d 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -5354,7 +5354,7 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust,
pNd = pTblStNd->EndOfSectionNode();
SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 );
- pDoc->MoveNodeRange( aSrcRg, aDstIdx,
+ pDoc->getIDocumentContentOperations().MoveNodeRange( aSrcRg, aDstIdx,
IDocumentContentOperations::DOC_MOVEDEFAULT );
// Wenn die Caption vor der Tabelle eingefuegt wurde muss
@@ -5372,7 +5372,7 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust,
// Die Section wird jetzt nicht mehr gebraucht.
pPam->SetMark();
pPam->DeleteMark();
- pDoc->DeleteSection( (SwStartNode *)pCapStNd );
+ pDoc->getIDocumentContentOperations().DeleteSection( (SwStartNode *)pCapStNd );
pTable->SetCaption( 0, false );
}
@@ -5422,7 +5422,7 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust,
{
pPam->SetMark();
pPam->DeleteMark();
- pDoc->DeleteSection( (SwStartNode *)pCapStNd );
+ pDoc->getIDocumentContentOperations().DeleteSection( (SwStartNode *)pCapStNd );
pCurTable->SetCaption( 0, false );
}
}
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index ea77049645e1..1595d23c8df6 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -197,7 +197,7 @@ sal_uLong HTMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPam,
// sonst ist sie schon gesetzt.
if( !rDoc.getIDocumentSettingAccess().get(IDocumentSettingAccess::HTML_MODE) )
{
- rDoc.InsertPoolItem( rPam, SwFmtPageDesc(
+ rDoc.getIDocumentContentOperations().InsertPoolItem( rPam, SwFmtPageDesc(
rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 );
}
}
@@ -508,10 +508,10 @@ SvParserState SwHTMLParser::CallParser()
{
const SwPosition* pPos = pPam->GetPoint();
- pDoc->SplitNode( *pPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
*pSttNdIdx = pPos->nNode.GetIndex()-1;
- pDoc->SplitNode( *pPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
SwPaM aInsertionRangePam( *pPos );
@@ -1213,7 +1213,7 @@ void SwHTMLParser::NextToken( int nToken )
{
if( !bDocInitalized )
DocumentDetected();
- pDoc->InsertString( *pPam, aToken );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, aToken );
// if there are temporary paragraph attributes and the
// paragraph isn't empty then the paragraph attributes
@@ -1268,7 +1268,7 @@ void SwHTMLParser::NextToken( int nToken )
if( pPageDesc )
{
- pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 );
}
}
break;
@@ -1424,11 +1424,11 @@ void SwHTMLParser::NextToken( int nToken )
break;
case HTML_NONBREAKSPACE:
- pDoc->InsertString( *pPam, OUString(CHAR_HARDBLANK) );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, OUString(CHAR_HARDBLANK) );
break;
case HTML_SOFTHYPH:
- pDoc->InsertString( *pPam, OUString(CHAR_SOFTHYPHEN) );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, OUString(CHAR_SOFTHYPHEN) );
break;
case HTML_LINEFEEDCHAR:
@@ -1468,7 +1468,7 @@ void SwHTMLParser::NextToken( int nToken )
{
if( !bDocInitalized )
DocumentDetected();
- pDoc->InsertString( *pPam, aToken );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, aToken );
// if there are temporary paragraph attributes and the
// paragraph isn't empty then the paragraph attributes
@@ -2128,7 +2128,7 @@ bool SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, bool bUpdateNum )
SwPosition aOldPos( *pPam->GetPoint() );
- bool bRet = pDoc->AppendTxtNode( *pPam->GetPoint() );
+ bool bRet = pDoc->getIDocumentContentOperations().AppendTxtNode( *pPam->GetPoint() );
// Zeichen-Attribute aufspalten und ggf keine setzen, die ueber den
// ganzen Absatz gesetzt sind
@@ -2882,7 +2882,7 @@ void SwHTMLParser::_SetAttr( bool bChkEnd, bool bBeforeTable,
eJumpTo = JUMPTO_NONE;
}
- pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE );
}
pAttrPam->DeleteMark();
@@ -2964,7 +2964,7 @@ void SwHTMLParser::_SetAttr( bool bChkEnd, bool bBeforeTable,
pAttrPam->Move( fnMoveBackward );
}
- pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 );
+ pDoc->getIDocumentContentOperations().InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 );
aFields.pop_front();
delete pAttr;
@@ -4985,7 +4985,7 @@ void SwHTMLParser::InsertSpacer()
{
NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize, RES_CHRATR_KERNING ) );
OUString aTmp( ' ' );
- pDoc->InsertString( *pPam, aTmp );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, aTmp );
EndAttr( aAttrTab.pKerning );
}
}
@@ -5184,7 +5184,7 @@ void SwHTMLParser::InsertLineBreak()
// wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird
// ein Zeilenumbruch eingef?gt
OUString sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-)
- pDoc->InsertString( *pPam, sTmp );
+ pDoc->getIDocumentContentOperations().InsertString( *pPam, sTmp );
}
else if( pPam->GetPoint()->nContent.GetIndex() )
{
diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx
index 2948833c6530..01cd541e9f7f 100644
--- a/sw/source/filter/rtf/swparrtf.cxx
+++ b/sw/source/filter/rtf/swparrtf.cxx
@@ -59,11 +59,11 @@ sal_uLong SwRTFReader::Read( SwDoc &rDoc, const OUString& /*rBaseURL*/, SwPaM& r
const SwPosition* pPos = rPam.GetPoint();
// Step 2: Split once and remember the node that has been split.
- rDoc.SplitNode( *pPos, false );
+ rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
*pSttNdIdx = pPos->nNode.GetIndex()-1;
// Step 3: Split again.
- rDoc.SplitNode( *pPos, false );
+ rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
// Step 4: Insert all content into the new node
rPam.Move( fnMoveBackward );
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 9d2cd5663a6f..a84907e1b83a 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -565,7 +565,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwSetExpField aFld((SwSetExpFieldType*)pFT, pB->GetValSys());
aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
MakePoint(rEntry, pDoc, aRegion);
- pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aRegion, SwFmtFld(aFld), 0);
MoveAttrs( *(aRegion.GetPoint()) );
}
if ( ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) &&
@@ -685,11 +685,11 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
nEnd = rEntry.GetEndCP();
if (rEntry.IsParaEnd())
{
- pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0, true);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr, 0, true);
}
else
{
- pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr, 0);
}
}
}
@@ -1030,10 +1030,10 @@ SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, const OUString& rBaseURL, bool
const SwTxtNode* pSttNd = pPos->nNode.GetNode().GetTxtNode();
if (pPos->nContent.GetIndex() && !pSttNd->GetTxt().isEmpty())
// insert position not in empty line
- pDoc->SplitNode( *pPos, false ); // make new line
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false ); // make new line
if (!pSttNd->GetTxt().isEmpty())
{ // InsertPos not on empty line
- pDoc->SplitNode( *pPos, false ); // new line
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false ); // new line
pPaM->Move( fnMoveBackward ); // go to empty line
}
@@ -1108,7 +1108,7 @@ SwFltShell::~SwFltShell()
SwFltShell& SwFltShell::operator << ( const OUString& rStr )
{
OSL_ENSURE(eSubMode != Style, "char insert while in style-mode");
- GetDoc().InsertString( *pPaM, rStr );
+ GetDoc().getIDocumentContentOperations().InsertString( *pPaM, rStr );
return *this;
}
@@ -1145,7 +1145,7 @@ OUString SwFltShell::QuoteStr( const OUString& rIn )
SwFltShell& SwFltShell::operator << ( const sal_Unicode c )
{
OSL_ENSURE( eSubMode != Style, "char insert while in style-mode");
- GetDoc().InsertString( *pPaM, OUString(c) );
+ GetDoc().getIDocumentContentOperations().InsertString( *pPaM, OUString(c) );
return *this;
}
@@ -1161,26 +1161,26 @@ SwFltShell& SwFltShell::AddError( const sal_Char* pErr )
SwSetExpField aFld( (SwSetExpFieldType*)pFT,
OUString::createFromAscii( pErr ));
//, VVF_INVISIBLE
- GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ GetDoc().getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return *this;
}
SwFltShell& SwFltShell::operator << (Graphic& rGraphic)
{
// embedded image !!
- GetDoc().Insert(*pPaM, OUString(), OUString(), &rGraphic, NULL, NULL, NULL);
+ GetDoc().getIDocumentContentOperations().Insert(*pPaM, OUString(), OUString(), &rGraphic, NULL, NULL, NULL);
return *this;
}
void SwFltShell::NextParagraph()
{
- GetDoc().AppendTxtNode(*pPaM->GetPoint());
+ GetDoc().getIDocumentContentOperations().AppendTxtNode(*pPaM->GetPoint());
}
void SwFltShell::NextPage()
{
NextParagraph();
- GetDoc().InsertPoolItem(*pPaM,
+ GetDoc().getIDocumentContentOperations().InsertPoolItem(*pPaM,
SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
}
@@ -1272,7 +1272,7 @@ SwFltShell& SwFltShell::EndItem( sal_uInt16 nAttrId )
SwFltShell& SwFltShell::operator << (const SwField& rField)
{
- GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0);
+ GetDoc().getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(rField), 0);
return *this;
}
@@ -1996,7 +1996,7 @@ void SwFltShell::BeginFootnote()
// be applied to PMW
SwFmtFtn aFtn;
- GetDoc().InsertPoolItem(*pPaM, aFtn, 0);
+ GetDoc().getIDocumentContentOperations().InsertPoolItem(*pPaM, aFtn, 0);
OSL_ENSURE(pSavedPos == NULL, "SwFltShell");
pSavedPos = new SwPosition(*pPaM->GetPoint());
pPaM->Move(fnMoveBackward, fnGoCntnt);
@@ -2093,7 +2093,7 @@ SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc)
}
else
{
- GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 );
+ GetDoc().getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 );
}
pNewPD->WriteUseOn( // all pages
(UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE));
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index f66573e4d66a..db1074806a25 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -168,7 +168,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks,
-1 );
pCNd = aIdx.GetNode().GetCntntNode();
SwPosition aPos(aIdx, SwIndex(pCNd, (pCNd) ? pCNd->Len() : 0));
- pD->CopyRange( aPam, aPos, false );
+ pD->getIDocumentContentOperations().CopyRange( aPam, aPos, false );
rBlocks.PutDoc();
}
}
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 6a235e780046..d757538e6b7f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1397,7 +1397,7 @@ void SwWW8ImplReader::ReadGrafLayer1( WW8PLCFspecial* pPF, long nGrafAnchorCp )
if (SdrObject *pObject = ReadGrafPrimitive( nLeft, &aDo, aSet ))
{
pWWZOrder->InsertDrawingObject(pObject, SVBT16ToShort(aDo.dhgt));
- SwFrmFmt *pFrm = rDoc.InsertDrawObj( *pPaM, *pObject, aSet );
+ SwFrmFmt *pFrm = rDoc.getIDocumentContentOperations().InsertDrawObj( *pPaM, *pObject, aSet );
pObject->SetMergedItemSet(aSet);
pAnchorStck->AddAnchor(*pPaM->GetPoint(), pFrm);
}
@@ -2659,7 +2659,7 @@ SwFrmFmt* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
pWWZOrder->InsertTextLayerObject(pObject);
}
- pRetFrmFmt = rDoc.InsertDrawObj(*pPaM, *pObject, aFlySet );
+ pRetFrmFmt = rDoc.getIDocumentContentOperations().InsertDrawObj(*pPaM, *pObject, aFlySet );
OSL_ENSURE(pRetFrmFmt->GetAnchor().GetAnchorId() ==
eAnchor, "Not the anchor type requested!");
@@ -2979,7 +2979,7 @@ SwFlyFrmFmt* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObject,
// as a linked graphic -
if (GRAPHIC_NONE == eType || CanUseRemoteLink(aGrfName))
{
- pRetFrmFmt = rDoc.Insert(*pPaM, aGrfName, OUString(), 0,
+ pRetFrmFmt = rDoc.getIDocumentContentOperations().Insert(*pPaM, aGrfName, OUString(), 0,
&rFlySet, &aGrSet, NULL);
bDone = true;
}
@@ -2987,7 +2987,7 @@ SwFlyFrmFmt* SwWW8ImplReader::ImportReplaceableDrawables( SdrObject* &rpObject,
if (!bDone)
{
const Graphic& rGraph = pGrf->GetGraphic();
- pRetFrmFmt = rDoc.Insert(*pPaM, OUString(), OUString(), &rGraph,
+ pRetFrmFmt = rDoc.getIDocumentContentOperations().Insert(*pPaM, OUString(), OUString(), &rGraph,
&rFlySet, &aGrSet, NULL);
}
}
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 359b33e5dff0..ee2eb137b2be 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -366,7 +366,7 @@ SwFlyFrmFmt* SwWW8ImplReader::MakeGrafNotInCntnt(const WW8PicDesc& rPD,
aFlySet.Put( SwFmtFrmSize( ATT_FIX_SIZE, nWidth, nHeight ) );
- SwFlyFrmFmt* pFlyFmt = rDoc.Insert(*pPaM, rFileName, OUString(), pGraph,
+ SwFlyFrmFmt* pFlyFmt = rDoc.getIDocumentContentOperations().Insert(*pPaM, rFileName, OUString(), pGraph,
&aFlySet, &rGrfSet, NULL);
// Damit die Frames bei Einfuegen in existierendes Doc erzeugt werden:
@@ -393,7 +393,7 @@ SwFrmFmt* SwWW8ImplReader::MakeGrafInCntnt(const WW8_PIC& rPic,
if( !pFlyFmt ) // dann eben als Graphic
{
- pFlyFmt = rDoc.Insert( *pPaM, rFileName, OUString(), pGraph, &aFlySet,
+ pFlyFmt = rDoc.getIDocumentContentOperations().Insert( *pPaM, rFileName, OUString(), pGraph, &aFlySet,
&rGrfSet, NULL);
}
@@ -655,12 +655,12 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj,
if (!pRet)
{
- pRet = rDoc.Insert(*pPaM, OUString(), OUString(),
+ pRet = rDoc.getIDocumentContentOperations().Insert(*pPaM, OUString(), OUString(),
&rGraph, &aAttrSet, &aGrSet, NULL );
}
}
else
- pRet = rDoc.InsertDrawObj(*pPaM, *pObject, aAttrSet );
+ pRet = rDoc.getIDocumentContentOperations().InsertDrawObj(*pPaM, *pObject, aAttrSet );
}
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 029cce82150a..56c184d366ea 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1480,7 +1480,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
else
{
- pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aRegion, *rEntry.pAttr, 0);
}
}
}
@@ -1637,7 +1637,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
}
- pDoc->InsertPoolItem(aPaM, *rEntry.pAttr, 0);
+ pDoc->getIDocumentContentOperations().InsertPoolItem(aPaM, *rEntry.pAttr, 0);
MoveAttrs(*aPaM.GetPoint());
}
break;
@@ -2258,7 +2258,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes)
SwPaM aEnd(*pPaM->End(), *pPaM->End());
pCtrlStck->NewAttr(*aEnd.GetPoint(), SvxCharHiddenItem(false, RES_CHRATR_HIDDEN));
- rDoc.InsertPoolItem(aEnd, SwFmtFld(aPostIt), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(aEnd, SwFmtFld(aPostIt), 0);
pCtrlStck->SetAttr(*aEnd.GetPoint(), RES_CHRATR_HIDDEN);
// If this is a range, create the associated fieldmark.
@@ -2551,7 +2551,7 @@ void SwWW8ImplReader::AppendTxtNode(SwPosition& rPos)
bFirstPara = false;
- rDoc.AppendTxtNode(rPos);
+ rDoc.getIDocumentContentOperations().AppendTxtNode(rPos);
// We can flush all anchored graphics at the end of a paragraph.
pAnchorStck->Flush();
@@ -3395,19 +3395,19 @@ void SwWW8ImplReader::simpleAddTextToParagraph(const OUString& rAddString)
{
if (rAddString.getLength() <= nCharsLeft)
{
- rDoc.InsertString(*pPaM, rAddString);
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, rAddString);
}
else
{
- rDoc.InsertString(*pPaM, rAddString.copy(0, nCharsLeft));
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, rAddString.copy(0, nCharsLeft));
AppendTxtNode(*pPaM->GetPoint());
- rDoc.InsertString(*pPaM, rAddString.copy(nCharsLeft));
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, rAddString.copy(nCharsLeft));
}
}
else
{
AppendTxtNode(*pPaM->GetPoint());
- rDoc.InsertString(*pPaM, rAddString);
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, rAddString);
}
bReadTable = false;
@@ -3427,7 +3427,7 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd,
{
for(sal_uInt16 nCh = 0; nCh < nEnd - rPos; ++nCh)
{
- rDoc.InsertString( *pPaM, OUString(cSymbol) );
+ rDoc.getIDocumentContentOperations().InsertString( *pPaM, OUString(cSymbol) );
}
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
}
@@ -3524,7 +3524,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
SwPageNumberField aFld(
(SwPageNumberFieldType*)rDoc.GetSysFldType(
RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
}
break;
case 0xe:
@@ -3537,7 +3537,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
SwCntntNode *pCntNd=pPaM->GetCntntNode();
if (pCntNd!=NULL && pCntNd->Len()>0) // if par is empty not break is needed
AppendTxtNode(*pPaM->GetPoint());
- rDoc.InsertPoolItem(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
}
break;
case 0x7:
@@ -3572,13 +3572,13 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
bRet = HandlePageBreakChar();
break;
case 0x1e: // Non-breaking hyphen
- rDoc.InsertString( *pPaM, OUString(CHAR_HARDHYPHEN) );
+ rDoc.getIDocumentContentOperations().InsertString( *pPaM, OUString(CHAR_HARDHYPHEN) );
break;
case 0x1f: // Non-required hyphens
- rDoc.InsertString( *pPaM, OUString(CHAR_SOFTHYPHEN) );
+ rDoc.getIDocumentContentOperations().InsertString( *pPaM, OUString(CHAR_SOFTHYPHEN) );
break;
case 0xa0: // Non-breaking spaces
- rDoc.InsertString( *pPaM, OUString(CHAR_HARDBLANK) );
+ rDoc.getIDocumentContentOperations().InsertString( *pPaM, OUString(CHAR_HARDBLANK) );
break;
case 0x1:
/*
@@ -4100,7 +4100,7 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType)
{
AppendTxtNode(*pPaM->GetPoint());
}
- rDoc.InsertPoolItem(*pPaM,
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM,
SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0);
bFirstParaOfPage = true;
bPgSecBreak = false;
@@ -4361,7 +4361,7 @@ void GiveNodePageDesc(SwNodeIndex &rIdx, const SwFmtPageDesc &rPgDesc,
rIdx.GetNode().GetCntntNode(), 0);
SwPaM aPage(aPamStart);
- rDoc.InsertPoolItem(aPage, rPgDesc, 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(aPage, rPgDesc, 0);
}
}
@@ -4426,7 +4426,7 @@ void wwSectionManager::InsertSegments()
if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
{
SwPaM start( aIter->maStart );
- mrReader.rDoc.InsertPoolItem( start, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
+ mrReader.rDoc.getIDocumentContentOperations().InsertPoolItem( start, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
continue;
}
@@ -4608,7 +4608,7 @@ void wwSectionManager::InsertSegments()
{
SwNodeIndex aIdx(*pTxtNd);
SwPaM aTest(aIdx);
- mrReader.rDoc.DelFullPara(aTest);
+ mrReader.rDoc.getIDocumentContentOperations().DelFullPara(aTest);
pTxtNd = 0;
}
}
@@ -4623,7 +4623,7 @@ void wwExtraneousParas::delete_all_from_doc()
SwTxtNode *pTxtNode = *aI;
SwNodeIndex aIdx(*pTxtNode);
SwPaM aTest(aIdx);
- m_rDoc.DelFullPara(aTest);
+ m_rDoc.getIDocumentContentOperations().DelFullPara(aTest);
}
m_aTxtNodes.clear();
}
@@ -5058,13 +5058,13 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
const SwPosition* pPos = pPaM->GetPoint();
// split current paragraph to get new paragraph for the insertion
- rDoc.SplitNode( *pPos, false );
+ rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
// another split, if insertion position was not at the end of the current paragraph.
SwTxtNode const*const pTxtNd = pPos->nNode.GetNode().GetTxtNode();
if ( pTxtNd->GetTxt().getLength() )
{
- rDoc.SplitNode( *pPos, false );
+ rDoc.getIDocumentContentOperations().SplitNode( *pPos, false );
// move PaM back to the newly empty paragraph
pPaM->Move( fnMoveBackward );
}
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index b91d83e0e8af..3b67391c0583 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -299,7 +299,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn()
sChar += OUString(pTxt->GetTxt()[--nPos]);
pPaM->SetMark();
pPaM->GetMark()->nContent--;
- rDoc.DeleteRange( *pPaM );
+ rDoc.getIDocumentContentOperations().DeleteRange( *pPaM );
pPaM->DeleteMark();
SwFmtFtn aFtn(rDesc.meType == MAN_EDN);
pFN = pTxt->InsertItem(aFtn, nPos, nPos);
@@ -354,7 +354,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn()
pPaM->GetMark()->nContent++;
pPaM->GetMark()->nContent++;
pReffingStck->Delete(*pPaM);
- rDoc.DeleteRange( *pPaM );
+ rDoc.getIDocumentContentOperations().DeleteRange( *pPaM );
pPaM->DeleteMark();
}
}
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 00837161c7e5..0937c1d250bd 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -133,7 +133,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr )
aFld.SetHelp(aFormula.sHelp);
aFld.SetToolTip(aFormula.sToolTip);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
else
@@ -253,7 +253,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr)
aFld.SetSelectedItem(aFormula.maListEntries[nIndex]);
}
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
else
diff --git a/sw/source/filter/ww8/ww8par4.cxx b/sw/source/filter/ww8/ww8par4.cxx
index a5e280511688..53075c9dcfeb 100644
--- a/sw/source/filter/ww8/ww8par4.cxx
+++ b/sw/source/filter/ww8/ww8par4.cxx
@@ -18,6 +18,7 @@
*/
#include <doc.hxx>
+#include <IDocumentContentOperations.hxx>
#include "writerhelper.hxx"
#include <com/sun/star/embed/XClassifiedObject.hpp>
#include <com/sun/star/embed/Aspects.hpp>
@@ -237,7 +238,7 @@ SwFlyFrmFmt* SwWW8ImplReader::InsertOle(SdrOle2Obj &rObject,
if (bSuccess)
{
const SfxItemSet *pFlySet = pMathFlySet ? pMathFlySet : &rFlySet;
- pRet = rDoc.InsertOLE(*pPaM, sNewName, rObject.GetAspect(), pFlySet, &rGrfSet, 0);
+ pRet = rDoc.getIDocumentContentOperations().InsertOLE(*pPaM, sNewName, rObject.GetAspect(), pFlySet, &rGrfSet, 0);
}
delete pMathFlySet;
return pRet;
@@ -294,14 +295,14 @@ SwFrmFmt* SwWW8ImplReader::ImportOle(const Graphic* pGrf,
SdrObject::Free( pRet ); // das brauchen wir nicht mehr
}
else
- pFmt = rDoc.InsertDrawObj(*pPaM, *pRet, *pFlySet );
+ pFmt = rDoc.getIDocumentContentOperations().InsertDrawObj(*pPaM, *pRet, *pFlySet );
}
else if (
GRAPHIC_GDIMETAFILE == aGraph.GetType() ||
GRAPHIC_BITMAP == aGraph.GetType()
)
{
- pFmt = rDoc.Insert(*pPaM, OUString(), OUString(), &aGraph, pFlySet,
+ pFmt = rDoc.getIDocumentContentOperations().Insert(*pPaM, OUString(), OUString(), &aGraph, pFlySet,
pGrfSet, NULL);
}
delete pTempSet;
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index a2e1eb983489..6a29b379d9d1 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -1027,7 +1027,7 @@ void SwWW8ImplReader::InsertTagField( const sal_uInt16 nId, const OUString& rTag
if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT))
{
aName += rTagText; // als Txt taggen
- rDoc.InsertString(*pPaM, aName,
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, aName,
IDocumentContentOperations::INS_NOHINTEXPAND);
}
else
@@ -1039,7 +1039,7 @@ void SwWW8ImplReader::InsertTagField( const sal_uInt16 nId, const OUString& rTag
sal_uInt16 nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE;
aFld.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING);
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
}
}
@@ -1096,7 +1096,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, OUString& rStr )
{
SwInputField aFld( static_cast<SwInputFieldType*>(rDoc.GetSysFldType( RES_INPUTFLD )),
aDef, aQ, INP_TXT, 0, false );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
}
return FLD_OK;
@@ -1294,7 +1294,7 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, OUString& rStr )
aFld.SetInputFlag(true);
aFld.SetPromptText( aQ );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo);
return FLD_OK;
@@ -1310,7 +1310,7 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, OUString& rStr )
SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, OUString(),
GetNumberPara( rStr ) );
aFld.SetValue( ++nFldNum );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -1387,7 +1387,7 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, OUString& rStr )
else if (!bCountOn)
aFld.SetFormula(aSequenceName);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
@@ -1508,7 +1508,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
{
SwDocInfoField aFld( (SwDocInfoFieldType*)
rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) );
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
@@ -1617,7 +1617,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr )
rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, aData, nFormat );
if (bDateTime)
ForceFieldLanguage(aFld, nLang);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
@@ -1629,7 +1629,7 @@ eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, OUString& )
SwDocInfoField aFld( (SwDocInfoFieldType*)
rDoc.GetSysFldType( RES_DOCINFOFLD ),
DI_CREATE|DI_SUB_AUTHOR, OUString() );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -1637,7 +1637,7 @@ eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, OUString& )
{
SwTemplNameField aFld( (SwTemplNameFieldType*)
rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -1693,14 +1693,14 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, OUString& rStr )
SwDateTimeField aFld((SwDateTimeFieldType*)
rDoc.GetSysFldType(RES_DATETIMEFLD ), DATEFLD, nFormat);
ForceFieldLanguage(aFld, nLang);
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
}
else if (nDT == NUMBERFORMAT_TIME)
{
SwDateTimeField aFld((SwDateTimeFieldType*)
rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat);
ForceFieldLanguage(aFld, nLang);
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
}
return FLD_OK;
@@ -1732,7 +1732,7 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, OUString &rStr)
SwFileNameField aFld(
(SwFileNameFieldType*)rDoc.GetSysFldType(RES_FILENAMEFLD), eType);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
return FLD_OK;
}
@@ -1746,7 +1746,7 @@ eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, OUString& rStr )
SwDocStatField aFld( (SwDocStatFieldType*)
rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub,
GetNumberPara( rStr ) );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -1757,7 +1757,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, OUString& rStr )
rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM,
GetNumberPara(rStr, true));
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -1813,7 +1813,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, OUString& rStr )
NewAttr(aSz);
}
- rDoc.InsertString(*pPaM, OUString(cChar));
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, OUString(cChar));
if (nSize > 0)
pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONTSIZE);
@@ -1822,7 +1822,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, OUString& rStr )
}
else
{
- rDoc.InsertString(*pPaM, OUString("###"));
+ rDoc.getIDocumentContentOperations().InsertString(*pPaM, OUString("###"));
}
return FLD_OK;
@@ -1886,7 +1886,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, OUString& rStr )
SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal, ULONG_MAX );
aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING);
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo);
@@ -1962,7 +1962,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, OUString& rStr )
}
else
{
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
}
return FLD_OK;
}
@@ -2086,7 +2086,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, OUString& rStr )
}
SwGetRefField aFld( (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ),
sPageRefBookmarkName, REF_BOOKMARK, 0, REF_PAGE );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
return FLD_OK;
}
@@ -2169,7 +2169,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
if( !bApplyWingdings )
{
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
WW8_CP nOldCp = pPlcxMan->Where();
WW8_CP nCp = nOldCp + nOffset;
@@ -2201,7 +2201,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, OUString& rStr)
{
SetNewFontAttr( i, true, RES_CHRATR_FONT );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT );
ResetCharSetVars();
}
@@ -2290,7 +2290,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludePicture( WW8FieldDesc*, OUString& rStr )
RES_FRMATR_END-1 );
aFlySet.Put( SwFmtAnchor( FLY_AS_CHAR ) );
aFlySet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::FRAME ));
- pFlyFmtOfJustInsertedGraphic = rDoc.Insert( *pPaM,
+ pFlyFmtOfJustInsertedGraphic = rDoc.getIDocumentContentOperations().Insert( *pPaM,
aGrfName,
OUString(),
0, // Graphic*
@@ -2413,7 +2413,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, OUString& rStr )
aFld.InitContent(aResult);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0);
#endif
return FLD_OK;
}
@@ -2426,7 +2426,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, OUString& )
SwFieldType* pFT = rDoc.InsertFldType( aN );
SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, OUString(), OUString(),
SwDBData() ); // Datenbank: Nichts
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
#endif
return FLD_OK;
}
@@ -2439,7 +2439,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, OUString& )
SwFieldType* pFT = rDoc.InsertFldType( aN );
SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT,
SwDBData() ); // Datenbank: Nichts
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 );
#endif
return FLD_OK;
}
@@ -2465,13 +2465,13 @@ eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, OUString& rStr )
{
SwInputField aFld( static_cast<SwInputFieldType*>(rDoc.GetSysFldType( RES_INPUTFLD )),
aResult.sResult, aResult.sResult, INP_TXT, 0 );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); // insert input field
+ rDoc.getIDocumentContentOperations().InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); // insert input field
}
else if (aResult.sType == "CombinedCharacters")
{
SwCombinedCharField aFld((SwCombinedCharFieldType*)
rDoc.GetSysFldType(RES_COMBINED_CHARS), aResult.sType);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
+ rDoc.getIDocumentContentOperations().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
}
}
else if ('*' == cChar)
@@ -2641,7 +2641,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
aRuby.SetAdjustment(nJustificationCode);
NewAttr(aRuby);
- rDoc.InsertString( *pPaM, sText );
+ rDoc.getIDocumentContentOperations().InsertString( *pPaM, sText );
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CJK_RUBY );
}
}
@@ -3500,7 +3500,7 @@ static void lcl_ImportTox(SwDoc &rDoc, SwPaM &rPaM, const OUString &rStr, bool b
if (!sFldTxt.isEmpty())
{
aM.SetAlternativeText( sFldTxt );
- rDoc.InsertPoolItem( rPaM, aM, 0 );
+ rDoc.getIDocumentContentOperations().InsertPoolItem( rPaM, aM, 0 );
}
}
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index 1043be94a2ce..dd34a4063f04 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -22,6 +22,7 @@
#include <unotextrange.hxx>
#include <unocrsr.hxx>
#include "doc.hxx"
+#include <IDocumentContentOperations.hxx>
#include <tools/datetime.hxx>
#include "poolfmt.hxx"
#include "unoredline.hxx"
@@ -637,7 +638,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
// delete 'deleted' redlines and forget about the whole thing
if (nsRedlineType_t::REDLINE_DELETE == pRedlineInfo->eType)
{
- pDoc->DeleteRange(aPaM);
+ pDoc->getIDocumentContentOperations().DeleteRange(aPaM);
// And what about the "deleted nodes"?
// They have to be deleted as well (#i80689)!
if( bIgnoreRedlines && pRedlineInfo->pContentIndex != NULL )
@@ -648,7 +649,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo)
{
SwNodeIndex aEnd( *pEnd, 1 );
SwPaM aDel( aIdx, aEnd );
- pDoc->DeleteRange(aDel);
+ pDoc->getIDocumentContentOperations().DeleteRange(aDel);
}
}
}
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 2fc0e6bf0bc2..5e22cea194cc 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -655,11 +655,11 @@ void SwXMLImport::startDocument()
const SwPosition* pPos = pPaM->GetPoint();
// Split once and remember the node that has been splitted.
- pDoc->SplitNode( *pPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
*pSttNdIdx = pPos->nNode.GetIndex()-1;
// Split again.
- pDoc->SplitNode( *pPos, false );
+ pDoc->getIDocumentContentOperations().SplitNode( *pPos, false );
// Insert all content into the new node
pPaM->Move( fnMoveBackward );
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 6e612528df7e..2022621ffdd1 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -705,7 +705,7 @@ void SwXMLTableCellContext_Impl::EndElement()
SwPaM aSrcPaM( *pSrcPaM->GetPoint(),
*pSrcPaM->GetMark() );
SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() );
- pDoc->CopyRange( aSrcPaM, aDstPos, false );
+ pDoc->getIDocumentContentOperations().CopyRange( aSrcPaM, aDstPos, false );
nColRepeat--;
}
@@ -2640,7 +2640,7 @@ void SwXMLTableContext::MakeTable()
if (!pRows || pRows->empty() || !GetColumnCount())
{
OSL_FAIL("invalid table: no cells; deleting...");
- pTableNode->GetDoc()->DeleteSection( pTableNode );
+ pTableNode->GetDoc()->getIDocumentContentOperations().DeleteSection( pTableNode );
pTableNode = 0;
pBox1 = 0;
pSttNd1 = 0;
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index b6209acc4fb7..d97338a96a9a 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -40,6 +40,7 @@
#include "unoframe.hxx"
#include "doc.hxx"
#include <IDocumentDrawModelAccess.hxx>
+#include <IDocumentContentOperations.hxx>
#include "unocoll.hxx"
#include <fmtfsize.hxx>
#include <fmtanchr.hxx>
@@ -285,7 +286,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
lcl_setObjectVisualArea( xObj, nAspect, aTwipSize, MAP_TWIP );
}
- pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(),
+ pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
&aItemSet,
NULL,
@@ -339,7 +340,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOLEObject(
// TODO/LATER: Actually it should be set here
if( pTxtCrsr )
{
- pFrmFmt = pDoc->InsertOLE( *pTxtCrsr->GetPaM(), aName, embed::Aspects::MSOLE_CONTENT, &aItemSet, NULL, NULL );
+ pFrmFmt = pDoc->getIDocumentContentOperations().InsertOLE( *pTxtCrsr->GetPaM(), aName, embed::Aspects::MSOLE_CONTENT, &aItemSet, NULL, NULL );
pOLENd = lcl_GetOLENode( pFrmFmt );
}
aObjName = aName;
@@ -586,7 +587,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertOOoLink(
uno::UNO_QUERY_THROW );
{
- SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(),
+ SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
&aItemSet,
NULL,
@@ -646,7 +647,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertApplet(
Size( nWidth, nHeight ),
MAP_100TH_MM );
- SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(),
+ SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
::svt::EmbeddedObjectRef( aAppletImpl.GetApplet(), embed::Aspects::MSOLE_CONTENT ),
&aAppletImpl.GetItemSet(),
NULL,
@@ -719,7 +720,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertPlugin(
makeAny( OUString( rMimeType ) ) );
}
- SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(),
+ SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
&aItemSet,
NULL,
@@ -870,7 +871,7 @@ uno::Reference< XPropertySet > SwXMLTextImportHelper::createAndInsertFloatingFra
makeAny( sal_Int32( aMargin.Height() ) ) );
}
- SwFrmFmt *pFrmFmt = pDoc->Insert( *pTxtCrsr->GetPaM(),
+ SwFrmFmt *pFrmFmt = pDoc->getIDocumentContentOperations().Insert( *pTxtCrsr->GetPaM(),
::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ),
&aItemSet,
NULL,
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 145c78722a35..b091254441d3 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -1104,11 +1104,7 @@ void SwDocShell::LoadingFinished()
// enables the document modification again.
// Thus, manuell modify the document, if its modified and its links are updated
// before <FinishedLoading(..)> is called.
-<<<<<<< HEAD
- const bool bHasDocToStayModified( mpDoc->IsModified() && mpDoc->LinksUpdated() );
-=======
- const bool bHasDocToStayModified( pDoc->IsModified() && pDoc->getIDocumentLinksAdministration().LinksUpdated() );
->>>>>>> Refactored IDocumentLinksAdministration out of SwDoc.
+ const bool bHasDocToStayModified( mpDoc->IsModified() && mpDoc->getIDocumentLinksAdministration().LinksUpdated() );
FinishedLoading( SFX_LOADED_ALL );
SfxViewFrame* pVFrame = SfxViewFrame::GetFirst(this);
@@ -1131,11 +1127,7 @@ void SwDocShell::CancelTransfers()
{
// Cancel all links from LinkManager
aFinishedTimer.Stop();
-<<<<<<< HEAD
- mpDoc->GetLinkManager().CancelTransfers();
-=======
- pDoc->getIDocumentLinksAdministration().GetLinkManager().CancelTransfers();
->>>>>>> Refactored IDocumentLinksAdministration out of SwDoc.
+ mpDoc->getIDocumentLinksAdministration().GetLinkManager().CancelTransfers();
SfxObjectShell::CancelTransfers();
}
diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx
index 20d8404c3d66..b22e9b9bdd33 100644
--- a/sw/source/uibase/app/docshini.cxx
+++ b/sw/source/uibase/app/docshini.cxx
@@ -368,7 +368,7 @@ SwDocShell::~SwDocShell()
if( mpDoc )
{
mpDoc->getIDocumentChartDataProviderAccess().GetChartControllerHelper().Disconnect();
- SwChartDataProvider *pPCD = mpDoc->getIDocumentChartDataProvdiderAccess().GetChartDataProvider();
+ SwChartDataProvider *pPCD = mpDoc->getIDocumentChartDataProviderAccess().GetChartDataProvider();
if (pPCD)
pPCD->dispose();
}
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 50a35123a3ec..0f5e35d86e0f 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -79,6 +79,7 @@
#include <doc.hxx>
#include <IDocumentSettingAccess.hxx>
#include <IDocumentLinksAdministration.hxx>
+#include <IDocumentContentOperations.hxx>
#include <swwait.hxx>
#include <swunohelper.hxx>
#include <dbui.hrc>
@@ -1093,7 +1094,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
- pWorkDoc->AppendTxtNode( aTestPos );
+ pWorkDoc->getIDocumentContentOperations().AppendTxtNode( aTestPos );
}
}
pTargetShell->Paste( rWorkShell.GetDoc(), true );
@@ -2901,7 +2902,7 @@ sal_Int32 SwDBManager::MergeDocuments( SwMailMergeConfigItem& rMMConfig,
if(!aTestCrsr.MovePara(fnParaNext, fnParaStart))
{
//append a paragraph
- pWorkDoc->AppendTxtNode( aTestPos );
+ pWorkDoc->getIDocumentContentOperations().AppendTxtNode( aTestPos );
}
}
diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx
index cba0d11cab24..5a1666b3a26f 100644
--- a/sw/source/uibase/docvw/PageBreakWin.cxx
+++ b/sw/source/uibase/docvw/PageBreakWin.cxx
@@ -18,6 +18,7 @@
#include <edtwin.hxx>
#include <fmtpdsc.hxx>
#include <IDocumentUndoRedo.hxx>
+#include <IDocumentContentOperations.hxx>
#include <PageBreakWin.hxx>
#include <pagefrm.hxx>
#include <PostItMgr.hxx>
@@ -277,7 +278,7 @@ void SwPageBreakWin::Select( )
aSet.Put( SwFmtPageDesc( NULL ) );
SwPaM aPaM( *pNd );
- pNd->GetDoc()->InsertItemSet( aPaM, aSet, nsSetAttrMode::SETATTR_DEFAULT );
+ pNd->GetDoc()->getIDocumentContentOperations().InsertItemSet( aPaM, aSet, nsSetAttrMode::SETATTR_DEFAULT );
pNd->GetDoc()->GetIDocumentUndoRedo( ).EndUndo( UNDO_UI_DELETE_PAGE_BREAK, NULL );
}
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index fae386b86208..53b13fa6277c 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -39,6 +39,7 @@
#include <doc.hxx>
#include <unocrsr.hxx>
#include <IMark.hxx>
+#include <IDocumentContentOperations.hxx>
#include <unoprnms.hxx>
#include <docsh.hxx>
#include <swmodule.hxx>
@@ -343,7 +344,7 @@ static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTe
}
}
if (!pPam) { return false; }
- bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet;
+ bRet = pDoc->getIDocumentContentOperations().CopyRange( *pPam, aPos, false ) || bRet;
}
pInsDoc->UnlockExpFlds();
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 7d751b30335d..92262cbd237a 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -1204,7 +1204,7 @@ void SwWrtShell::NumOrBulletOn(bool bNum)
const SwTwips nWidthOfTabs = pTxtNode
? pTxtNode->GetWidthOfLeadingTabs()
: 0;
- GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() );
+ GetDoc()->getIDocumentContentOperations().RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() );
const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
const bool bRightToLeft = IsInRightToLeftText();