[Libreoffice-commits] core.git: 3 commits - sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Tue Jun 10 01:15:58 PDT 2014
sw/source/core/doc/doc.cxx | 9 ++++-----
sw/source/core/doc/docbm.cxx | 36 ++++++++++++++++++++++++++++++++++++
sw/source/core/doc/docedt.cxx | 18 ++++++++----------
sw/source/core/docnode/ndtbl.cxx | 26 ++++++++++----------------
sw/source/core/inc/mvsave.hxx | 19 ++++++++++++-------
sw/source/core/txtnode/ndtxt.cxx | 16 ++++++++--------
sw/source/core/undo/untbl.cxx | 12 +++++-------
7 files changed, 83 insertions(+), 53 deletions(-)
New commits:
commit a72ea67d52bf083034756332bf5f7e5c1c416129
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Jun 10 10:14:22 2014 +0200
decouple CntntStore so it can be refactored
Change-Id: I26554a0e269d63830fd84b37a4323f40c80fc014
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index b6340d8..effc0bd 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -383,17 +383,16 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
}
}
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
- *aBkmkArr.get(), SAVEFLY_SPLIT );
+ 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( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( this, *aBkmkArr.get(), rPos.nNode.GetIndex()-1, 0, true );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( this, rPos.nNode.GetIndex()-1, 0, true );
// To-Do - add 'SwExtraRedlineTbl' also ?
if( IsRedlineOn() || (!IsIgnoreRedline() && !mpRedlineTbl->empty() ))
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index ea560b7..271096c 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1503,10 +1503,6 @@ void _DelBookmarks(
}
}
-boost::shared_ptr< ::sw::mark::CntntIdxStore> sw::mark::CreateCntntIdxStore()
-{
- return boost::shared_ptr< ::sw::mark::CntntIdxStore>(new sw::mark::CntntIdxStore());
-}
void _SaveCntntIdx(SwDoc* pDoc,
sal_uLong nNode,
@@ -2054,4 +2050,39 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr,
}
}
+namespace
+{
+ struct CntntIdxStoreImpl : sw::mark::CntntIdxStore
+ {
+ std::vector<sal_uLong> aSaveArr;
+ virtual void Clear()
+ {
+ aSaveArr.clear();
+ }
+ virtual bool Empty()
+ {
+ return aSaveArr.empty();
+ }
+ virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0)
+ {
+ return _SaveCntntIdx(pDoc, nNode, nCntnt, aSaveArr, nSaveFly);
+ }
+ virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false)
+ {
+ return _RestoreCntntIdx(pDoc, aSaveArr, nNode, nOffset, bAuto);
+ }
+ virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen)
+ {
+ return _RestoreCntntIdx(aSaveArr, rNd, nLen, nCorrLen);
+ }
+ virtual ~CntntIdxStoreImpl(){};
+ };
+}
+
+namespace sw { namespace mark {
+ boost::shared_ptr<CntntIdxStore> CntntIdxStore::Create()
+ {
+ return boost::shared_ptr<CntntIdxStore>(new CntntIdxStoreImpl());
+ }
+}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index c83aefa..2ce11ac 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -905,14 +905,13 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
bSplit = true;
const sal_Int32 nMkCntnt = rPaM.GetMark()->nContent.GetIndex();
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
- *aBkmkArr.get(), SAVEFLY_SPLIT );
+ 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( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( this, *aBkmkArr.get(), rPos.nNode.GetIndex()-1, 0, true );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( this, rPos.nNode.GetIndex()-1, 0, true );
// correct the PaM!
if( rPos.nNode == rPaM.GetMark()->nNode )
@@ -1328,9 +1327,8 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
}
pOldTxtNd->FmtToTxtAttr( pTxtNd );
- const boost::shared_ptr< sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- ::_SaveCntntIdx( pDoc, aOldIdx.GetIndex(),
- pOldTxtNd->Len(), *aBkmkArr.get() );
+ const boost::shared_ptr< sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save( pDoc, aOldIdx.GetIndex(), pOldTxtNd->Len() );
SwIndex aAlphaIdx(pTxtNd);
pOldTxtNd->CutText( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd),
@@ -1339,8 +1337,8 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
pDoc->CorrRel( rPam.GetPoint()->nNode, aAlphaPos, 0, true );
// move all Bookmarks/TOXMarks
- if( !aBkmkArr.get()->empty() )
- ::_RestoreCntntIdx( pDoc, *aBkmkArr.get(), aIdx.GetIndex() );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( pDoc, aIdx.GetIndex() );
// If the passed PaM is not in the Crsr ring,
// treat it separately (e.g. when it's being called from AutoFormat)
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index cd0943e..fad6ee0 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1048,9 +1048,8 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
SwStartNode* pSttNd;
SwPosition aCntPos( aSttIdx, SwIndex( pTxtNd ));
- const boost::shared_ptr< sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- _SaveCntntIdx( pDoc, aSttIdx.GetIndex(), pTxtNd->GetTxt().getLength(),
- *aBkmkArr.get() );
+ const boost::shared_ptr< sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save( pDoc, aSttIdx.GetIndex(), pTxtNd->GetTxt().getLength() );
if( T2T_PARA != cCh )
{
@@ -1061,9 +1060,8 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
aCntPos.nContent = nChPos;
SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( aCntPos );
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( *aBkmkArr.get(), *pNewNd, nChPos,
- nChPos + 1 );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( *pNewNd, nChPos, nChPos + 1 );
// Delete separator and correct search string
pTxtNd->EraseText( aCntPos.nContent, 1 );
@@ -1088,9 +1086,8 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
}
// Now for the last substring
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( *aBkmkArr.get(), *pTxtNd, pTxtNd->GetTxt().getLength(),
- pTxtNd->GetTxt().getLength()+1 );
+ if( !pCntntStore->Empty())
+ pCntntStore->Restore( *pTxtNd, pTxtNd->GetTxt().getLength(), pTxtNd->GetTxt().getLength()+1 );
pSttNd = new SwStartNode( aCntPos.nNode, ND_STARTNODE, SwTableBoxStartNode );
const SwNodeIndex aTmpIdx( aCntPos.nNode, 1 );
@@ -1519,17 +1516,14 @@ static void lcl_DelBox( SwTableBox* pBox, _DelTabPara* pDelPara )
pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(),
aCntIdx.GetIndex() );
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
const sal_Int32 nOldTxtLen = aCntIdx.GetIndex();
- _SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().getLength(),
- *aBkmkArr.get() );
+ pCntntStore->Save( pDoc, nNdIdx, pCurTxtNd->GetTxt().getLength() );
pDelPara->pLastNd->JoinNext();
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( pDoc, *aBkmkArr.get(),
- pDelPara->pLastNd->GetIndex(),
- nOldTxtLen );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( pDoc, pDelPara->pLastNd->GetIndex(), nOldTxtLen );
}
else if( pDelPara->pUndo )
{
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index c6e9295..f53f8a3 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -71,8 +71,17 @@ namespace sw { namespace mark
::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
};
- typedef std::vector<sal_uLong> CntntIdxStore;
- boost::shared_ptr<CntntIdxStore> CreateCntntIdxStore();
+ class CntntIdxStore
+ {
+ public:
+ virtual void Clear() =0;
+ virtual bool Empty() =0;
+ virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) =0;
+ virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) =0;
+ virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) =0;
+ virtual ~CntntIdxStore() {};
+ static boost::shared_ptr<CntntIdxStore> Create();
+ };
}}
#define SAVEFLY 1
@@ -84,14 +93,6 @@ void _DelBookmarks(const SwNodeIndex& rStt,
const SwIndex* pSttIdx =0,
const SwIndex* pEndIdx =0);
-void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
- sw::mark::CntntIdxStore& rSaveArr, sal_uInt8 nSaveFly = 0 );
-void _RestoreCntntIdx( SwDoc* pDoc, sw::mark::CntntIdxStore& rSaveArr,
- sal_uLong nNode, sal_Int32 nOffset = 0,
- bool bAuto = false );
-void _RestoreCntntIdx( sw::mark::CntntIdxStore& rSaveArr, const SwNode& rNd,
- sal_Int32 nLen, sal_Int32 nCorrLen );
-
/** data structure to temporarily hold fly anchor positions relative to some
* location. */
struct _SaveFly
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 152e468..d785c6a 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -619,8 +619,8 @@ SwCntntNode *SwTxtNode::JoinNext()
if( SwCntntNode::CanJoinNext( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, *aBkmkArr.get(), SAVEFLY );
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save(pDoc, aIdx.GetIndex(), SAL_MAX_INT32, SAVEFLY);
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
sal_Int32 nOldLen = m_Text.getLength();
@@ -685,8 +685,8 @@ SwCntntNode *SwTxtNode::JoinNext()
pTxtNode->CutText( this, SwIndex(pTxtNode), pTxtNode->Len() );
}
// verschiebe noch alle Bookmarks/TOXMarks
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( pDoc, *aBkmkArr.get(), GetIndex(), nOldLen );
+ if( !pCntntStore->Empty())
+ pCntntStore->Restore( pDoc, GetIndex(), nOldLen );
if( pTxtNode->HasAnyIndex() )
{
@@ -713,8 +713,8 @@ SwCntntNode *SwTxtNode::JoinPrev()
if( SwCntntNode::CanJoinPrev( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
- _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, *aBkmkArr.get(), SAVEFLY );
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
+ pCntntStore->Save( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, SAVEFLY );
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
const sal_Int32 nLen = pTxtNode->Len();
@@ -779,8 +779,8 @@ SwCntntNode *SwTxtNode::JoinPrev()
pTxtNode->CutText( this, SwIndex(this), SwIndex(pTxtNode), nLen );
}
// verschiebe noch alle Bookmarks/TOXMarks
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( pDoc, *aBkmkArr.get(), GetIndex() );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( pDoc, GetIndex() );
if( pTxtNode->HasAnyIndex() )
{
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 76ba22c..f40696f 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -540,7 +540,7 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
SwTableLine* pLine = new SwTableLine( pLineFmt, rSavedData.size(), 0 );
pTblNd->GetTable().GetTabLines().insert( pTblNd->GetTable().GetTabLines().begin(), pLine );
- const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
+ const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
for( sal_uInt16 n = rSavedData.size(); n; )
{
const SwTblToTxtSave* pSave = &rSavedData[ --n ];
@@ -558,16 +558,14 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
pTxtNd->EraseText( aCntPos, 1 );
SwCntntNode* pNewNd = pTxtNd->SplitCntntNode(
SwPosition( aSttIdx, aCntPos ));
- if( !aBkmkArr.get()->empty() )
- _RestoreCntntIdx( *aBkmkArr.get(), *pNewNd, pSave->m_nCntnt,
- pSave->m_nCntnt + 1 );
+ if( !pCntntStore->Empty() )
+ pCntntStore->Restore( *pNewNd, pSave->m_nCntnt, pSave->m_nCntnt + 1 );
}
else
{
- aBkmkArr.get()->clear();
+ pCntntStore->Clear();
if( pTxtNd )
- _SaveCntntIdx( GetDoc(), aSttIdx.GetIndex(),
- pTxtNd->GetTxt().getLength(), *aBkmkArr.get() );
+ pCntntStore->Save( GetDoc(), aSttIdx.GetIndex(), pTxtNd->GetTxt().getLength() );
}
if( pTxtNd )
commit e5fe5601a658532bd4fe18f08b668c1187827596
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Jun 9 15:02:19 2014 +0200
create factory function for encapsulation
Change-Id: I4cf6ca2855787102f6f9edd477e0d6e4c6a43503
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 270fe28..b6340d8 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -383,17 +383,17 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
}
}
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
_SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
- aBkmkArr, SAVEFLY_SPLIT );
+ *aBkmkArr.get(), 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( !aBkmkArr.empty() )
- _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, true );
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( this, *aBkmkArr.get(), rPos.nNode.GetIndex()-1, 0, true );
// To-Do - add 'SwExtraRedlineTbl' also ?
if( IsRedlineOn() || (!IsIgnoreRedline() && !mpRedlineTbl->empty() ))
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 0ef7fb7..ea560b7 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1503,6 +1503,11 @@ void _DelBookmarks(
}
}
+boost::shared_ptr< ::sw::mark::CntntIdxStore> sw::mark::CreateCntntIdxStore()
+{
+ return boost::shared_ptr< ::sw::mark::CntntIdxStore>(new sw::mark::CntntIdxStore());
+}
+
void _SaveCntntIdx(SwDoc* pDoc,
sal_uLong nNode,
sal_Int32 nCntnt,
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 5e40769..c83aefa 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -905,14 +905,14 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
bSplit = true;
const sal_Int32 nMkCntnt = rPaM.GetMark()->nContent.GetIndex();
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
_SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
- aBkmkArr, SAVEFLY_SPLIT );
+ *aBkmkArr.get(), SAVEFLY_SPLIT );
pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos ));
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, true );
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( this, *aBkmkArr.get(), rPos.nNode.GetIndex()-1, 0, true );
// correct the PaM!
if( rPos.nNode == rPaM.GetMark()->nNode )
@@ -1328,9 +1328,9 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
}
pOldTxtNd->FmtToTxtAttr( pTxtNd );
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr< sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
::_SaveCntntIdx( pDoc, aOldIdx.GetIndex(),
- pOldTxtNd->Len(), aBkmkArr );
+ pOldTxtNd->Len(), *aBkmkArr.get() );
SwIndex aAlphaIdx(pTxtNd);
pOldTxtNd->CutText( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd),
@@ -1339,8 +1339,8 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
pDoc->CorrRel( rPam.GetPoint()->nNode, aAlphaPos, 0, true );
// move all Bookmarks/TOXMarks
- if( !aBkmkArr.empty() )
- ::_RestoreCntntIdx( pDoc, aBkmkArr, aIdx.GetIndex() );
+ if( !aBkmkArr.get()->empty() )
+ ::_RestoreCntntIdx( pDoc, *aBkmkArr.get(), aIdx.GetIndex() );
// If the passed PaM is not in the Crsr ring,
// treat it separately (e.g. when it's being called from AutoFormat)
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c216488..cd0943e 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1048,9 +1048,9 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
SwStartNode* pSttNd;
SwPosition aCntPos( aSttIdx, SwIndex( pTxtNd ));
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr< sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
_SaveCntntIdx( pDoc, aSttIdx.GetIndex(), pTxtNd->GetTxt().getLength(),
- aBkmkArr );
+ *aBkmkArr.get() );
if( T2T_PARA != cCh )
{
@@ -1061,8 +1061,8 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
aCntPos.nContent = nChPos;
SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( aCntPos );
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( aBkmkArr, *pNewNd, nChPos,
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( *aBkmkArr.get(), *pNewNd, nChPos,
nChPos + 1 );
// Delete separator and correct search string
@@ -1088,8 +1088,8 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
}
// Now for the last substring
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( aBkmkArr, *pTxtNd, pTxtNd->GetTxt().getLength(),
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( *aBkmkArr.get(), *pTxtNd, pTxtNd->GetTxt().getLength(),
pTxtNd->GetTxt().getLength()+1 );
pSttNd = new SwStartNode( aCntPos.nNode, ND_STARTNODE, SwTableBoxStartNode );
@@ -1519,15 +1519,15 @@ static void lcl_DelBox( SwTableBox* pBox, _DelTabPara* pDelPara )
pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(),
aCntIdx.GetIndex() );
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
const sal_Int32 nOldTxtLen = aCntIdx.GetIndex();
_SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().getLength(),
- aBkmkArr );
+ *aBkmkArr.get() );
pDelPara->pLastNd->JoinNext();
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( pDoc, aBkmkArr,
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( pDoc, *aBkmkArr.get(),
pDelPara->pLastNd->GetIndex(),
nOldTxtLen );
}
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 588772d..c6e9295 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -72,6 +72,7 @@ namespace sw { namespace mark
};
typedef std::vector<sal_uLong> CntntIdxStore;
+ boost::shared_ptr<CntntIdxStore> CreateCntntIdxStore();
}}
#define SAVEFLY 1
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 78d98c4..152e468 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -619,8 +619,8 @@ SwCntntNode *SwTxtNode::JoinNext()
if( SwCntntNode::CanJoinNext( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- sw::mark::CntntIdxStore aBkmkArr;
- _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
+ _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, *aBkmkArr.get(), SAVEFLY );
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
sal_Int32 nOldLen = m_Text.getLength();
@@ -685,8 +685,8 @@ SwCntntNode *SwTxtNode::JoinNext()
pTxtNode->CutText( this, SwIndex(pTxtNode), pTxtNode->Len() );
}
// verschiebe noch alle Bookmarks/TOXMarks
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( pDoc, aBkmkArr, GetIndex(), nOldLen );
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( pDoc, *aBkmkArr.get(), GetIndex(), nOldLen );
if( pTxtNode->HasAnyIndex() )
{
@@ -713,8 +713,8 @@ SwCntntNode *SwTxtNode::JoinPrev()
if( SwCntntNode::CanJoinPrev( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- sw::mark::CntntIdxStore aBkmkArr;
- _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
+ _SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, *aBkmkArr.get(), SAVEFLY );
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
const sal_Int32 nLen = pTxtNode->Len();
@@ -779,8 +779,8 @@ SwCntntNode *SwTxtNode::JoinPrev()
pTxtNode->CutText( this, SwIndex(this), SwIndex(pTxtNode), nLen );
}
// verschiebe noch alle Bookmarks/TOXMarks
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( pDoc, aBkmkArr, GetIndex() );
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( pDoc, *aBkmkArr.get(), GetIndex() );
if( pTxtNode->HasAnyIndex() )
{
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index c350f76..76ba22c 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -540,7 +540,7 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
SwTableLine* pLine = new SwTableLine( pLineFmt, rSavedData.size(), 0 );
pTblNd->GetTable().GetTabLines().insert( pTblNd->GetTable().GetTabLines().begin(), pLine );
- sw::mark::CntntIdxStore aBkmkArr;
+ const boost::shared_ptr<sw::mark::CntntIdxStore> aBkmkArr(sw::mark::CreateCntntIdxStore());
for( sal_uInt16 n = rSavedData.size(); n; )
{
const SwTblToTxtSave* pSave = &rSavedData[ --n ];
@@ -558,16 +558,16 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
pTxtNd->EraseText( aCntPos, 1 );
SwCntntNode* pNewNd = pTxtNd->SplitCntntNode(
SwPosition( aSttIdx, aCntPos ));
- if( !aBkmkArr.empty() )
- _RestoreCntntIdx( aBkmkArr, *pNewNd, pSave->m_nCntnt,
+ if( !aBkmkArr.get()->empty() )
+ _RestoreCntntIdx( *aBkmkArr.get(), *pNewNd, pSave->m_nCntnt,
pSave->m_nCntnt + 1 );
}
else
{
- aBkmkArr.clear();
+ aBkmkArr.get()->clear();
if( pTxtNd )
_SaveCntntIdx( GetDoc(), aSttIdx.GetIndex(),
- pTxtNd->GetTxt().getLength(), aBkmkArr );
+ pTxtNd->GetTxt().getLength(), *aBkmkArr.get() );
}
if( pTxtNd )
commit bbcf8a2ea88c0e837db630a9087e1442aa2f9bd2
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Mon Jun 9 14:15:27 2014 +0200
typedef the internal type
Change-Id: I11e785427add72b56bc48cfac1640211dfba6cc6
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 39a2849..270fe28 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -383,7 +383,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
}
}
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
_SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
aBkmkArr, SAVEFLY_SPLIT );
// FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 546693b..5e40769 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -905,7 +905,7 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags )
bSplit = true;
const sal_Int32 nMkCntnt = rPaM.GetMark()->nContent.GetIndex();
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
_SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
aBkmkArr, SAVEFLY_SPLIT );
@@ -1328,7 +1328,7 @@ void sw_JoinText( SwPaM& rPam, bool bJoinPrev )
}
pOldTxtNd->FmtToTxtAttr( pTxtNd );
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
::_SaveCntntIdx( pDoc, aOldIdx.GetIndex(),
pOldTxtNd->Len(), aBkmkArr );
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 493d957..c216488 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1048,7 +1048,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
SwStartNode* pSttNd;
SwPosition aCntPos( aSttIdx, SwIndex( pTxtNd ));
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
_SaveCntntIdx( pDoc, aSttIdx.GetIndex(), pTxtNd->GetTxt().getLength(),
aBkmkArr );
@@ -1519,7 +1519,7 @@ static void lcl_DelBox( SwTableBox* pBox, _DelTabPara* pDelPara )
pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(),
aCntIdx.GetIndex() );
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
const sal_Int32 nOldTxtLen = aCntIdx.GetIndex();
_SaveCntntIdx( pDoc, nNdIdx, pCurTxtNd->GetTxt().getLength(),
aBkmkArr );
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index da49227..588772d 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -70,6 +70,8 @@ namespace sw { namespace mark
sal_Int32 m_nCntnt2;
::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo;
};
+
+ typedef std::vector<sal_uLong> CntntIdxStore;
}}
#define SAVEFLY 1
@@ -80,12 +82,13 @@ void _DelBookmarks(const SwNodeIndex& rStt,
::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
const SwIndex* pSttIdx =0,
const SwIndex* pEndIdx =0);
+
void _SaveCntntIdx( SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
- std::vector<sal_uLong>& rSaveArr, sal_uInt8 nSaveFly = 0 );
-void _RestoreCntntIdx( SwDoc* pDoc, std::vector<sal_uLong>& rSaveArr,
+ sw::mark::CntntIdxStore& rSaveArr, sal_uInt8 nSaveFly = 0 );
+void _RestoreCntntIdx( SwDoc* pDoc, sw::mark::CntntIdxStore& rSaveArr,
sal_uLong nNode, sal_Int32 nOffset = 0,
bool bAuto = false );
-void _RestoreCntntIdx( std::vector<sal_uLong>& rSaveArr, const SwNode& rNd,
+void _RestoreCntntIdx( sw::mark::CntntIdxStore& rSaveArr, const SwNode& rNd,
sal_Int32 nLen, sal_Int32 nCorrLen );
/** data structure to temporarily hold fly anchor positions relative to some
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 235e516..78d98c4 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -619,7 +619,7 @@ SwCntntNode *SwTxtNode::JoinNext()
if( SwCntntNode::CanJoinNext( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
_SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
sal_Int32 nOldLen = m_Text.getLength();
@@ -713,7 +713,7 @@ SwCntntNode *SwTxtNode::JoinPrev()
if( SwCntntNode::CanJoinPrev( &aIdx ) )
{
SwDoc* pDoc = rNds.GetDoc();
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
_SaveCntntIdx( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, aBkmkArr, SAVEFLY );
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
const sal_Int32 nLen = pTxtNode->Len();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index e1d4833..c350f76 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -540,7 +540,7 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
SwTableLine* pLine = new SwTableLine( pLineFmt, rSavedData.size(), 0 );
pTblNd->GetTable().GetTabLines().insert( pTblNd->GetTable().GetTabLines().begin(), pLine );
- std::vector<sal_uLong> aBkmkArr;
+ sw::mark::CntntIdxStore aBkmkArr;
for( sal_uInt16 n = rSavedData.size(); n; )
{
const SwTblToTxtSave* pSave = &rSavedData[ --n ];
More information about the Libreoffice-commits
mailing list