[Libreoffice-commits] core.git: 18 commits - sw/Library_sw.mk sw/source
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Fri Jul 25 00:49:25 PDT 2014
sw/Library_sw.mk | 1
sw/source/core/doc/CntntIdxStore.cxx | 440 +++++++++++++
sw/source/core/doc/DocumentContentOperationsManager.cxx | 4
sw/source/core/doc/docbm.cxx | 531 ----------------
sw/source/core/inc/mvsave.hxx | 5
sw/source/core/txtnode/ndtxt.cxx | 4
6 files changed, 447 insertions(+), 538 deletions(-)
New commits:
commit 93d9abd966a875a9f5f188786f1baedeb390c4c9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 01:47:40 2014 +0200
remove unused params
Change-Id: I6e297a5972bf6d50f99e0533c6f8b15d552de970
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index d3c07bf..5f9b44a 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -156,8 +156,8 @@ namespace
RestoreBkmks(pDoc, aUpdater);
RestoreRedlines(pDoc, aUpdater);
RestoreFlys(pDoc, aUpdater, bAuto);
- RestoreUnoCrsrs(pDoc, aUpdater);
- RestoreShellCrsrs(pDoc, aUpdater);
+ RestoreUnoCrsrs(aUpdater);
+ RestoreShellCrsrs(aUpdater);
}
virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) SAL_OVERRIDE
{
@@ -167,8 +167,8 @@ namespace
RestoreBkmks(pDoc, aUpdater);
RestoreRedlines(pDoc, aUpdater);
RestoreFlys(pDoc, aUpdater, false);
- RestoreUnoCrsrs(pDoc, aUpdater);
- RestoreShellCrsrs(pDoc, aUpdater);
+ RestoreUnoCrsrs(aUpdater);
+ RestoreShellCrsrs(aUpdater);
}
virtual ~CntntIdxStoreImpl(){};
private:
@@ -179,9 +179,9 @@ namespace
inline void SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplit);
inline void RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto);
inline void SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater);
+ inline void RestoreUnoCrsrs(updater_t& rUpdater);
inline void SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreShellCrsrs(SwDoc* pDoc, updater_t& rUpdater);
+ inline void RestoreShellCrsrs(updater_t& rUpdater);
inline const SwPosition& GetRightMarkPos(::sw::mark::IMark* pMark, bool bOther)
{ return bOther ? pMark->GetOtherMarkPos() : pMark->GetMarkPos(); };
inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
@@ -392,7 +392,7 @@ void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn
}
}
-void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
+void CntntIdxStoreImpl::RestoreUnoCrsrs(updater_t& rUpdater)
{
BOOST_FOREACH(const PaMEntry& aEntry, m_aUnoCrsrEntries)
{
@@ -423,7 +423,7 @@ void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 n
} while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell );
}
-void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
+void CntntIdxStoreImpl::RestoreShellCrsrs(updater_t& rUpdater)
{
BOOST_FOREACH(const PaMEntry& aEntry, m_aShellCrsrEntries)
{
commit 9cb5358d2fd6d1a86b79134dfab17bbcd858e640
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 01:27:44 2014 +0200
kill SAVEFLY_SPLIT too
Change-Id: Iaeecdb35c0eaebea8e879f36a21237c98a2c7ed0
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index ed009b3..d3c07bf 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -141,11 +141,11 @@ namespace
{
return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aFlyEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty();
}
- virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplt=false) SAL_OVERRIDE
+ virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplit=false) SAL_OVERRIDE
{
SaveBkmks(pDoc, nNode, nCntnt);
SaveRedlines(pDoc, nNode, nCntnt);
- SaveFlys(pDoc, nNode, nCntnt, bSaveFlySplt ? SAVEFLY_SPLIT : 0);
+ SaveFlys(pDoc, nNode, nCntnt, bSaveFlySplit);
SaveUnoCrsrs(pDoc, nNode, nCntnt);
SaveShellCrsrs(pDoc, nNode, nCntnt);
}
@@ -176,7 +176,7 @@ namespace
inline void RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater);
inline void SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
inline void RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater);
- inline void SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly);
+ inline void SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplit);
inline void RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto);
inline void SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
inline void RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater);
@@ -301,7 +301,7 @@ void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
}
}
-void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly)
+void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplit)
{
SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
if( !pNode )
@@ -330,7 +330,7 @@ void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
{
if( nCntnt <= aSave.m_nCntnt )
{
- if( SAVEFLY_SPLIT == nSaveFly )
+ if( bSaveFlySplit )
aSave.m_bOther = true;
else
bSkip = true;
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 795cb89..fbcd83f 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1958,7 +1958,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
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 );
+ pCntntStore->Save( &m_rSwdoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), true );
pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos ));
@@ -2876,7 +2876,7 @@ bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool b
}
const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
- pCntntStore->Save( &m_rSwdoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), SAVEFLY_SPLIT );
+ pCntntStore->Save( &m_rSwdoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), true );
// FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
OSL_ENSURE(pNode->IsTxtNode(), "splitting non-text node?");
pNode = pNode->SplitCntntNode( rPos );
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index b988470..3b24951 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -85,8 +85,6 @@ namespace sw { namespace mark
};
}}
-#define SAVEFLY_SPLIT true
-
void _DelBookmarks(const SwNodeIndex& rStt,
const SwNodeIndex& rEnd,
::std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =0,
commit 823447222c85a5a091e56ee07d1ac233f6e4e52a
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 01:12:39 2014 +0200
SAVEFLY is a noop, just use a bool
Change-Id: I32255ca073d52616d3e5c9e80f32471e0a7df3fa
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 42ae979..ed009b3 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -141,11 +141,11 @@ namespace
{
return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aFlyEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty();
}
- virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) SAL_OVERRIDE
+ virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplt=false) SAL_OVERRIDE
{
SaveBkmks(pDoc, nNode, nCntnt);
SaveRedlines(pDoc, nNode, nCntnt);
- SaveFlys(pDoc, nNode, nCntnt, nSaveFly);
+ SaveFlys(pDoc, nNode, nCntnt, bSaveFlySplt ? SAVEFLY_SPLIT : 0);
SaveUnoCrsrs(pDoc, nNode, nCntnt);
SaveShellCrsrs(pDoc, nNode, nCntnt);
}
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 8ed06c9..b988470 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -77,7 +77,7 @@ namespace sw { namespace mark
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 Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, bool bSaveFlySplit=false) =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() {};
@@ -85,8 +85,7 @@ namespace sw { namespace mark
};
}}
-#define SAVEFLY 1
-#define SAVEFLY_SPLIT 2
+#define SAVEFLY_SPLIT true
void _DelBookmarks(const SwNodeIndex& rStt,
const SwNodeIndex& rEnd,
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 861ef64..b9c0821 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -630,7 +630,7 @@ SwCntntNode *SwTxtNode::JoinNext()
{
SwDoc* pDoc = rNds.GetDoc();
const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
- pCntntStore->Save(pDoc, aIdx.GetIndex(), SAL_MAX_INT32, SAVEFLY);
+ pCntntStore->Save(pDoc, aIdx.GetIndex(), SAL_MAX_INT32);
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
sal_Int32 nOldLen = m_Text.getLength();
@@ -724,7 +724,7 @@ SwCntntNode *SwTxtNode::JoinPrev()
{
SwDoc* pDoc = rNds.GetDoc();
const boost::shared_ptr<sw::mark::CntntIdxStore> pCntntStore(sw::mark::CntntIdxStore::Create());
- pCntntStore->Save( pDoc, aIdx.GetIndex(), SAL_MAX_INT32, SAVEFLY );
+ pCntntStore->Save( pDoc, aIdx.GetIndex(), SAL_MAX_INT32);
SwTxtNode *pTxtNode = aIdx.GetNode().GetTxtNode();
const sal_Int32 nLen = pTxtNode->Len();
commit 2af62a7469eb9bb8a3ad7807398f24e291fc08ee
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 01:03:51 2014 +0200
move into the loop and constify
Change-Id: I8544755a1b1a32fdf85823e50cf5db6c4909b485
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 03e33ef..42ae979 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -292,10 +292,9 @@ void CntntIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn
void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
{
const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
- SwPosition* pPos = NULL;
BOOST_FOREACH(const MarkEntry& aEntry, m_aRedlineEntries)
{
- pPos = (SwPosition*)( aEntry.m_bOther
+ SwPosition* const pPos = (SwPosition*)( aEntry.m_bOther
? rRedlTbl[ aEntry.m_nIdx ]->GetMark()
: rRedlTbl[ aEntry.m_nIdx ]->GetPoint());
rUpdater(*pPos, aEntry.m_nCntnt);
commit c28c6126dc96f57aec29a3fa25df5ba4ab5f28f8
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:59:05 2014 +0200
we can do this before the conditional
Change-Id: Iedd3404931e578c40726d663e5460e9e3af56832
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 52ded5f..03e33ef 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -110,14 +110,13 @@ namespace
: m_pNewCntntNode(pNewCntntNode), m_nLen(nLen), m_nCorrLen(nCorrLen) {};
void operator()(SwPosition& rPos, sal_Int32 nCntnt) const
{
+ rPos.nNode = *m_pNewCntntNode;
if( nCntnt < m_nCorrLen )
{
- rPos.nNode = *m_pNewCntntNode;
rPos.nContent.Assign(const_cast<SwCntntNode*>(m_pNewCntntNode), std::min( nCntnt, static_cast<sal_Int32>(m_nLen) ) );
}
else
{
- rPos.nNode = *m_pNewCntntNode;
rPos.nContent -= m_nCorrLen;
}
};
commit d6aaaf6960c16ef63bfa3f88e641c13f33b9c680
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:57:16 2014 +0200
remove unused headers
Change-Id: I6829e0780c051a67fbec7c33f6f45dedaf31d7f1
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 1a2754c..52ded5f 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -17,41 +17,27 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <MarkManager.hxx>
#include <bookmrk.hxx>
-#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/make_shared.hpp>
#include <cntfrm.hxx>
-#include <crossrefbookmark.hxx>
-#include <annotationmark.hxx>
-#include <dcontact.hxx>
#include <doc.hxx>
#include <docary.hxx>
-#include <xmloff/odffields.hxx>
#include <editsh.hxx>
#include <fmtanchr.hxx>
#include <frmfmt.hxx>
#include <functional>
-#include <hintids.hxx>
#include <mvsave.hxx>
#include <ndtxt.hxx>
#include <node.hxx>
#include <pam.hxx>
#include <redline.hxx>
-#include <rolbck.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
#include <sal/types.h>
-#include <sortedobjs.hxx>
-#include <sfx2/linkmgr.hxx>
-#include <swserv.hxx>
-#include <swundo.hxx>
#include <unocrsr.hxx>
-#include <viscrs.hxx>
#include <edimp.hxx>
-#include <stdio.h>
using namespace ::boost;
using namespace ::sw::mark;
commit b6fda1b67cac32c1799db5a6115004e6b682a680
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:46:05 2014 +0200
use make_shared here
Change-Id: I0535517f39508abb3e0b454081e4a64d375ecbc4
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
index 7b7ba3e..1a2754c 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -22,6 +22,7 @@
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/function.hpp>
+#include <boost/make_shared.hpp>
#include <cntfrm.hxx>
#include <crossrefbookmark.hxx>
#include <annotationmark.hxx>
@@ -449,7 +450,7 @@ void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater
namespace sw { namespace mark {
boost::shared_ptr<CntntIdxStore> CntntIdxStore::Create()
{
- return boost::shared_ptr<CntntIdxStore>(new CntntIdxStoreImpl());
+ return boost::make_shared<CntntIdxStoreImpl>();
}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit fec5892741df952ebf97ea745fce3d061c75de34
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:39:54 2014 +0200
move CntntIdxStore to own file
Change-Id: Ic8280478b154b9b132f74e260edea46911cb1803
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 0366a64..75f26b2 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -159,6 +159,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/crsr/overlayrangesoutline \
sw/source/core/doc/SwStyleNameMapper \
sw/source/core/doc/acmplwrd \
+ sw/source/core/doc/CntntIdxStore \
sw/source/core/doc/dbgoutsw \
sw/source/core/doc/doc \
sw/source/core/doc/docbasic \
diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx
new file mode 100644
index 0000000..7b7ba3e
--- /dev/null
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -0,0 +1,455 @@
+/* -*- 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 <MarkManager.hxx>
+#include <bookmrk.hxx>
+#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#include <boost/function.hpp>
+#include <cntfrm.hxx>
+#include <crossrefbookmark.hxx>
+#include <annotationmark.hxx>
+#include <dcontact.hxx>
+#include <doc.hxx>
+#include <docary.hxx>
+#include <xmloff/odffields.hxx>
+#include <editsh.hxx>
+#include <fmtanchr.hxx>
+#include <frmfmt.hxx>
+#include <functional>
+#include <hintids.hxx>
+#include <mvsave.hxx>
+#include <ndtxt.hxx>
+#include <node.hxx>
+#include <pam.hxx>
+#include <redline.hxx>
+#include <rolbck.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+#include <sortedobjs.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <swserv.hxx>
+#include <swundo.hxx>
+#include <unocrsr.hxx>
+#include <viscrs.hxx>
+#include <edimp.hxx>
+#include <stdio.h>
+
+using namespace ::boost;
+using namespace ::sw::mark;
+
+namespace
+{
+ // #i59534: If a paragraph will be splitted we have to restore some redline positions
+ // This help function checks a position compared with a node and an content index
+
+ static const int BEFORE_NODE = 0; // Position before the given node index
+ static const int BEFORE_SAME_NODE = 1; // Same node index but content index before given content index
+ static const int SAME_POSITION = 2; // Same node index and samecontent index
+ static const int BEHIND_SAME_NODE = 3; // Same node index but content index behind given content index
+ static const int BEHIND_NODE = 4; // Position behind the given node index
+
+ static int lcl_RelativePosition( const SwPosition& rPos, sal_uLong nNode, sal_Int32 nCntnt )
+ {
+ sal_uLong nIndex = rPos.nNode.GetIndex();
+ int nReturn = BEFORE_NODE;
+ if( nIndex == nNode )
+ {
+ const sal_Int32 nCntIdx = rPos.nContent.GetIndex();
+ if( nCntIdx < nCntnt )
+ nReturn = BEFORE_SAME_NODE;
+ else if( nCntIdx == nCntnt )
+ nReturn = SAME_POSITION;
+ else
+ nReturn = BEHIND_SAME_NODE;
+ }
+ else if( nIndex > nNode )
+ nReturn = BEHIND_NODE;
+ return nReturn;
+ }
+ struct MarkEntry
+ {
+ long int m_nIdx;
+ bool m_bOther;
+ sal_Int32 m_nCntnt;
+#if 0
+ void Dump()
+ {
+ SAL_INFO("sw.core", "Index: " << m_nIdx << "\tOther: " << m_bOther << "\tContent: " << m_nCntnt);
+ }
+#endif
+ };
+ struct PaMEntry
+ {
+ SwPaM* m_pPaM;
+ bool m_isMark;
+ sal_Int32 m_nCntnt;
+ };
+ struct OffsetUpdater
+ {
+ const SwCntntNode* m_pNewCntntNode;
+ const sal_Int32 m_nOffset;
+ OffsetUpdater(SwCntntNode* pNewCntntNode, sal_Int32 nOffset)
+ : m_pNewCntntNode(pNewCntntNode), m_nOffset(nOffset) {};
+ void operator()(SwPosition& rPos, sal_Int32 nCntnt) const
+ {
+ rPos.nNode = *m_pNewCntntNode;
+ rPos.nContent.Assign(const_cast<SwCntntNode*>(m_pNewCntntNode), nCntnt + m_nOffset);
+ };
+ };
+ struct LimitUpdater
+ {
+ const SwCntntNode* m_pNewCntntNode;
+ const sal_uLong m_nLen;
+ const sal_Int32 m_nCorrLen;
+ LimitUpdater(SwCntntNode* pNewCntntNode, sal_uLong nLen, sal_Int32 nCorrLen)
+ : m_pNewCntntNode(pNewCntntNode), m_nLen(nLen), m_nCorrLen(nCorrLen) {};
+ void operator()(SwPosition& rPos, sal_Int32 nCntnt) const
+ {
+ if( nCntnt < m_nCorrLen )
+ {
+ rPos.nNode = *m_pNewCntntNode;
+ rPos.nContent.Assign(const_cast<SwCntntNode*>(m_pNewCntntNode), std::min( nCntnt, static_cast<sal_Int32>(m_nLen) ) );
+ }
+ else
+ {
+ rPos.nNode = *m_pNewCntntNode;
+ rPos.nContent -= m_nCorrLen;
+ }
+ };
+ };
+ struct CntntIdxStoreImpl : sw::mark::CntntIdxStore
+ {
+ std::vector<MarkEntry> m_aBkmkEntries;
+ std::vector<MarkEntry> m_aRedlineEntries;
+ std::vector<MarkEntry> m_aFlyEntries;
+ std::vector<PaMEntry> m_aUnoCrsrEntries;
+ std::vector<PaMEntry> m_aShellCrsrEntries;
+ typedef boost::function<void (SwPosition& rPos, sal_Int32 nCntnt)> updater_t;
+ virtual void Clear() SAL_OVERRIDE
+ {
+ m_aBkmkEntries.clear();
+ m_aRedlineEntries.clear();
+ m_aFlyEntries.clear();
+ m_aUnoCrsrEntries.clear();
+ m_aShellCrsrEntries.clear();
+ }
+ virtual bool Empty() SAL_OVERRIDE
+ {
+ return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aFlyEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty();
+ }
+ virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) SAL_OVERRIDE
+ {
+ SaveBkmks(pDoc, nNode, nCntnt);
+ SaveRedlines(pDoc, nNode, nCntnt);
+ SaveFlys(pDoc, nNode, nCntnt, nSaveFly);
+ SaveUnoCrsrs(pDoc, nNode, nCntnt);
+ SaveShellCrsrs(pDoc, nNode, nCntnt);
+ }
+ virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) SAL_OVERRIDE
+ {
+ SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
+ updater_t aUpdater = OffsetUpdater(pCNd, nOffset);
+ RestoreBkmks(pDoc, aUpdater);
+ RestoreRedlines(pDoc, aUpdater);
+ RestoreFlys(pDoc, aUpdater, bAuto);
+ RestoreUnoCrsrs(pDoc, aUpdater);
+ RestoreShellCrsrs(pDoc, aUpdater);
+ }
+ virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) SAL_OVERRIDE
+ {
+ SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode();
+ SwDoc* pDoc = rNd.GetDoc();
+ updater_t aUpdater = LimitUpdater(pCNd, nLen, nCorrLen);
+ RestoreBkmks(pDoc, aUpdater);
+ RestoreRedlines(pDoc, aUpdater);
+ RestoreFlys(pDoc, aUpdater, false);
+ RestoreUnoCrsrs(pDoc, aUpdater);
+ RestoreShellCrsrs(pDoc, aUpdater);
+ }
+ virtual ~CntntIdxStoreImpl(){};
+ private:
+ inline void SaveBkmks(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
+ inline void RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater);
+ inline void SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
+ inline void RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater);
+ inline void SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly);
+ inline void RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto);
+ inline void SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
+ inline void RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater);
+ inline void SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
+ inline void RestoreShellCrsrs(SwDoc* pDoc, updater_t& rUpdater);
+ inline const SwPosition& GetRightMarkPos(::sw::mark::IMark* pMark, bool bOther)
+ { return bOther ? pMark->GetOtherMarkPos() : pMark->GetMarkPos(); };
+ inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
+ { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
+ };
+ static inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
+ {
+ const SwPosition* pPos = &rPaM.GetBound( bPoint );
+ if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
+ {
+ const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
+ rPaMEntries.push_back(aEntry);
+ }
+ }
+ static inline void lcl_ChkPaMBoth( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM)
+ {
+ lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, true);
+ lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, false);
+ }
+
+#if 0
+ static void DumpEntries(std::vector<MarkEntry>* pEntries)
+ {
+ BOOST_FOREACH(MarkEntry& aEntry, *pEntries)
+ aEntry.Dump();
+ }
+#endif
+}
+
+void CntntIdxStoreImpl::SaveBkmks(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
+{
+ IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
+ const IDocumentMarkAccess::const_iterator_t ppBkmkEnd = pMarkAccess->getAllMarksEnd();
+ for(
+ IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getAllMarksBegin();
+ ppBkmk != ppBkmkEnd;
+ ++ppBkmk)
+ {
+ const ::sw::mark::IMark* pBkmk = ppBkmk->get();
+ bool bMarkPosEqual = false;
+ if(pBkmk->GetMarkPos().nNode.GetIndex() == nNode
+ && pBkmk->GetMarkPos().nContent.GetIndex() <= nCntnt)
+ {
+ if(pBkmk->GetMarkPos().nContent.GetIndex() < nCntnt)
+ {
+ const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), false, pBkmk->GetMarkPos().nContent.GetIndex() };
+ m_aBkmkEntries.push_back(aEntry);
+ }
+ else // if a bookmark position is equal nCntnt, the other position
+ bMarkPosEqual = true; // has to decide if it is added to the array
+ }
+ if(pBkmk->IsExpanded()
+ && pBkmk->GetOtherMarkPos().nNode.GetIndex() == nNode
+ && pBkmk->GetOtherMarkPos().nContent.GetIndex() <= nCntnt)
+ {
+ if(bMarkPosEqual)
+ { // the other position is before, the (main) position is equal
+ const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), false, pBkmk->GetMarkPos().nContent.GetIndex() };
+ m_aBkmkEntries.push_back(aEntry);
+ }
+ const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), true, pBkmk->GetOtherMarkPos().nContent.GetIndex() };
+ m_aBkmkEntries.push_back(aEntry);
+ }
+ }
+}
+
+void CntntIdxStoreImpl::RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater)
+{
+ IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
+ BOOST_FOREACH(const MarkEntry& aEntry, m_aBkmkEntries)
+ {
+ if (MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aEntry.m_nIdx].get()))
+ {
+ SwPosition aNewPos(GetRightMarkPos(pMark, aEntry.m_bOther));
+ rUpdater(aNewPos, aEntry.m_nCntnt);
+ SetRightMarkPos(pMark, aEntry.m_bOther, &aNewPos);
+ }
+ }
+}
+
+void CntntIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
+{
+ const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
+ for( long int nIdx = 0 ; static_cast<unsigned long int>(nIdx) < rRedlTbl.size(); ++nIdx )
+ {
+ const SwRangeRedline* pRdl = rRedlTbl[ nIdx ];
+ int nPointPos = lcl_RelativePosition( *pRdl->GetPoint(), nNode, nCntnt );
+ int nMarkPos = pRdl->HasMark() ? lcl_RelativePosition( *pRdl->GetMark(), nNode, nCntnt ) :
+ nPointPos;
+ // #i59534: We have to store the positions inside the same node before the insert position
+ // and the one at the insert position if the corresponding Point/Mark position is before
+ // the insert position.
+ if( nPointPos == BEFORE_SAME_NODE ||
+ ( nPointPos == SAME_POSITION && nMarkPos < SAME_POSITION ) )
+ {
+ const MarkEntry aEntry = { nIdx, false, pRdl->GetPoint()->nContent.GetIndex() };
+ m_aRedlineEntries.push_back(aEntry);
+ }
+ if( pRdl->HasMark() && ( nMarkPos == BEFORE_SAME_NODE ||
+ ( nMarkPos == SAME_POSITION && nPointPos < SAME_POSITION ) ) )
+ {
+ const MarkEntry aEntry = { nIdx, true, pRdl->GetMark()->nContent.GetIndex() };
+ m_aRedlineEntries.push_back(aEntry);
+ }
+ }
+}
+
+void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
+{
+ const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
+ SwPosition* pPos = NULL;
+ BOOST_FOREACH(const MarkEntry& aEntry, m_aRedlineEntries)
+ {
+ pPos = (SwPosition*)( aEntry.m_bOther
+ ? rRedlTbl[ aEntry.m_nIdx ]->GetMark()
+ : rRedlTbl[ aEntry.m_nIdx ]->GetPoint());
+ rUpdater(*pPos, aEntry.m_nCntnt);
+ }
+}
+
+void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly)
+{
+ SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
+ if( !pNode )
+ return;
+ SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
+ if( pFrm )
+ {
+ if( !pFrm->GetDrawObjs() )
+ return; // if we have a layout and no DrawObjs, we can skip this
+ }
+ MarkEntry aSave;
+ BOOST_FOREACH(const SwFrmFmt* pFrmFmt, *pDoc->GetSpzFrmFmts())
+ {
+ if ( RES_FLYFRMFMT == pFrmFmt->Which() || RES_DRAWFRMFMT == pFrmFmt->Which() )
+ {
+ bool bSkip = false;
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
+ if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
+ ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
+ FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
+ {
+ aSave.m_bOther = false;
+ aSave.m_nCntnt = pAPos->nContent.GetIndex();
+ if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
+ {
+ if( nCntnt <= aSave.m_nCntnt )
+ {
+ if( SAVEFLY_SPLIT == nSaveFly )
+ aSave.m_bOther = true;
+ else
+ bSkip = true;
+ }
+ }
+ if(!bSkip)
+ m_aFlyEntries.push_back(aSave);
+ }
+ }
+ ++aSave.m_nIdx;
+ }
+}
+
+void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto)
+{
+ SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
+ BOOST_FOREACH(const MarkEntry& aEntry, m_aFlyEntries)
+ {
+ if(!aEntry.m_bOther)
+ {
+ SwFrmFmt *pFrmFmt = (*pSpz)[ aEntry.m_nIdx ];
+ const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
+ if( rFlyAnchor.GetCntntAnchor() )
+ {
+ SwFmtAnchor aNew( rFlyAnchor );
+ SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
+ rUpdater(aNewPos, aEntry.m_nCntnt);
+ if ( FLY_AT_CHAR != rFlyAnchor.GetAnchorId() )
+ {
+ aNewPos.nContent.Assign( 0, 0 );
+ }
+ aNew.SetAnchor( &aNewPos );
+ pFrmFmt->SetFmtAttr( aNew );
+ }
+ }
+ else if( bAuto )
+ {
+ SwFrmFmt *pFrmFmt = (*pSpz)[ aEntry.m_nIdx ];
+ SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
+ pFrmFmt->NotifyClients( pAnchor, pAnchor );
+ }
+ }
+}
+
+void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
+{
+ BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
+ {
+ FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
+ lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
+ FOREACHPAM_END()
+ const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
+ if( pUnoTblCrsr )
+ {
+ FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
+ lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
+ FOREACHPAM_END()
+ }
+ }
+}
+
+void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
+{
+ BOOST_FOREACH(const PaMEntry& aEntry, m_aUnoCrsrEntries)
+ {
+ rUpdater(aEntry.m_pPaM->GetBound(!aEntry.m_isMark), aEntry.m_nCntnt);
+ }
+}
+
+void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
+{
+ SwCrsrShell* pShell = pDoc->GetEditShell();
+ if( !pShell )
+ return;
+ SwViewShell *_pStartShell = pShell;
+ do {
+ if( _pStartShell->IsA( TYPE( SwCrsrShell )) )
+ {
+ SwPaM *_pStkCrsr = ((SwCrsrShell*)_pStartShell)->GetStkCrsr();
+ if( _pStkCrsr )
+ do {
+ lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr);
+ } while ( (_pStkCrsr != 0 ) &&
+ ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != ((SwCrsrShell*)_pStartShell)->GetStkCrsr()) );
+
+ FOREACHPAM_START( ((SwCrsrShell*)_pStartShell)->_GetCrsr() )
+ lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR);
+ FOREACHPAM_END()
+ }
+ } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell );
+}
+
+void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
+{
+ BOOST_FOREACH(const PaMEntry& aEntry, m_aShellCrsrEntries)
+ {
+ rUpdater(aEntry.m_pPaM->GetBound(aEntry.m_isMark), aEntry.m_nCntnt);
+ }
+}
+
+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/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 4fe7090..db2358c 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1113,34 +1113,6 @@ namespace sw { namespace mark
namespace
{
- // #i59534: If a paragraph will be splitted we have to restore some redline positions
- // This help function checks a position compared with a node and an content index
-
- static const int BEFORE_NODE = 0; // Position before the given node index
- static const int BEFORE_SAME_NODE = 1; // Same node index but content index before given content index
- static const int SAME_POSITION = 2; // Same node index and samecontent index
- static const int BEHIND_SAME_NODE = 3; // Same node index but content index behind given content index
- static const int BEHIND_NODE = 4; // Position behind the given node index
-
- static int lcl_RelativePosition( const SwPosition& rPos, sal_uLong nNode, sal_Int32 nCntnt )
- {
- sal_uLong nIndex = rPos.nNode.GetIndex();
- int nReturn = BEFORE_NODE;
- if( nIndex == nNode )
- {
- const sal_Int32 nCntIdx = rPos.nContent.GetIndex();
- if( nCntIdx < nCntnt )
- nReturn = BEFORE_SAME_NODE;
- else if( nCntIdx == nCntnt )
- nReturn = SAME_POSITION;
- else
- nReturn = BEHIND_SAME_NODE;
- }
- else if( nIndex > nNode )
- nReturn = BEHIND_NODE;
- return nReturn;
- }
-
static inline bool lcl_Greater( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
{
return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx && rPos.nContent > pIdx->GetIndex() );
@@ -1354,376 +1326,4 @@ void _DelBookmarks(
}
}
-
-
-namespace
-{
- struct MarkEntry
- {
- long int m_nIdx;
- bool m_bOther;
- sal_Int32 m_nCntnt;
-#if 0
- void Dump()
- {
- SAL_INFO("sw.core", "Index: " << m_nIdx << "\tOther: " << m_bOther << "\tContent: " << m_nCntnt);
- }
-#endif
- };
- struct PaMEntry
- {
- SwPaM* m_pPaM;
- bool m_isMark;
- sal_Int32 m_nCntnt;
- };
- struct OffsetUpdater
- {
- const SwCntntNode* m_pNewCntntNode;
- const sal_Int32 m_nOffset;
- OffsetUpdater(SwCntntNode* pNewCntntNode, sal_Int32 nOffset)
- : m_pNewCntntNode(pNewCntntNode), m_nOffset(nOffset) {};
- void operator()(SwPosition& rPos, sal_Int32 nCntnt) const
- {
- rPos.nNode = *m_pNewCntntNode;
- rPos.nContent.Assign(const_cast<SwCntntNode*>(m_pNewCntntNode), nCntnt + m_nOffset);
- };
- };
- struct LimitUpdater
- {
- const SwCntntNode* m_pNewCntntNode;
- const sal_uLong m_nLen;
- const sal_Int32 m_nCorrLen;
- LimitUpdater(SwCntntNode* pNewCntntNode, sal_uLong nLen, sal_Int32 nCorrLen)
- : m_pNewCntntNode(pNewCntntNode), m_nLen(nLen), m_nCorrLen(nCorrLen) {};
- void operator()(SwPosition& rPos, sal_Int32 nCntnt) const
- {
- if( nCntnt < m_nCorrLen )
- {
- rPos.nNode = *m_pNewCntntNode;
- rPos.nContent.Assign(const_cast<SwCntntNode*>(m_pNewCntntNode), std::min( nCntnt, static_cast<sal_Int32>(m_nLen) ) );
- }
- else
- {
- rPos.nNode = *m_pNewCntntNode;
- rPos.nContent -= m_nCorrLen;
- }
- };
- };
- struct CntntIdxStoreImpl : sw::mark::CntntIdxStore
- {
- std::vector<MarkEntry> m_aBkmkEntries;
- std::vector<MarkEntry> m_aRedlineEntries;
- std::vector<MarkEntry> m_aFlyEntries;
- std::vector<PaMEntry> m_aUnoCrsrEntries;
- std::vector<PaMEntry> m_aShellCrsrEntries;
- typedef boost::function<void (SwPosition& rPos, sal_Int32 nCntnt)> updater_t;
- virtual void Clear() SAL_OVERRIDE
- {
- m_aBkmkEntries.clear();
- m_aRedlineEntries.clear();
- m_aFlyEntries.clear();
- m_aUnoCrsrEntries.clear();
- m_aShellCrsrEntries.clear();
- }
- virtual bool Empty() SAL_OVERRIDE
- {
- return m_aBkmkEntries.empty() && m_aRedlineEntries.empty() && m_aFlyEntries.empty() && m_aUnoCrsrEntries.empty() && m_aShellCrsrEntries.empty();
- }
- virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly=0) SAL_OVERRIDE
- {
- SaveBkmks(pDoc, nNode, nCntnt);
- SaveRedlines(pDoc, nNode, nCntnt);
- SaveFlys(pDoc, nNode, nCntnt, nSaveFly);
- SaveUnoCrsrs(pDoc, nNode, nCntnt);
- SaveShellCrsrs(pDoc, nNode, nCntnt);
- }
- virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) SAL_OVERRIDE
- {
- SwCntntNode* pCNd = pDoc->GetNodes()[ nNode ]->GetCntntNode();
- updater_t aUpdater = OffsetUpdater(pCNd, nOffset);
- RestoreBkmks(pDoc, aUpdater);
- RestoreRedlines(pDoc, aUpdater);
- RestoreFlys(pDoc, aUpdater, bAuto);
- RestoreUnoCrsrs(pDoc, aUpdater);
- RestoreShellCrsrs(pDoc, aUpdater);
- }
- virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) SAL_OVERRIDE
- {
- SwCntntNode* pCNd = (SwCntntNode*)rNd.GetCntntNode();
- SwDoc* pDoc = rNd.GetDoc();
- updater_t aUpdater = LimitUpdater(pCNd, nLen, nCorrLen);
- RestoreBkmks(pDoc, aUpdater);
- RestoreRedlines(pDoc, aUpdater);
- RestoreFlys(pDoc, aUpdater, false);
- RestoreUnoCrsrs(pDoc, aUpdater);
- RestoreShellCrsrs(pDoc, aUpdater);
- }
- virtual ~CntntIdxStoreImpl(){};
- private:
- inline void SaveBkmks(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater);
- inline void SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater);
- inline void SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly);
- inline void RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto);
- inline void SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater);
- inline void SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt);
- inline void RestoreShellCrsrs(SwDoc* pDoc, updater_t& rUpdater);
- inline const SwPosition& GetRightMarkPos(::sw::mark::IMark* pMark, bool bOther)
- { return bOther ? pMark->GetOtherMarkPos() : pMark->GetMarkPos(); };
- inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
- { bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
- };
- static inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
- {
- const SwPosition* pPos = &rPaM.GetBound( bPoint );
- if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
- {
- const PaMEntry aEntry = { &rPaM, bPoint, pPos->nContent.GetIndex() };
- rPaMEntries.push_back(aEntry);
- }
- }
- static inline void lcl_ChkPaMBoth( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM)
- {
- lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, true);
- lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, false);
- }
-
-#if 0
- static void DumpEntries(std::vector<MarkEntry>* pEntries)
- {
- BOOST_FOREACH(MarkEntry& aEntry, *pEntries)
- aEntry.Dump();
- }
-#endif
-}
-
-void CntntIdxStoreImpl::SaveBkmks(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
-{
- IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
- const IDocumentMarkAccess::const_iterator_t ppBkmkEnd = pMarkAccess->getAllMarksEnd();
- for(
- IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->getAllMarksBegin();
- ppBkmk != ppBkmkEnd;
- ++ppBkmk)
- {
- const ::sw::mark::IMark* pBkmk = ppBkmk->get();
- bool bMarkPosEqual = false;
- if(pBkmk->GetMarkPos().nNode.GetIndex() == nNode
- && pBkmk->GetMarkPos().nContent.GetIndex() <= nCntnt)
- {
- if(pBkmk->GetMarkPos().nContent.GetIndex() < nCntnt)
- {
- const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), false, pBkmk->GetMarkPos().nContent.GetIndex() };
- m_aBkmkEntries.push_back(aEntry);
- }
- else // if a bookmark position is equal nCntnt, the other position
- bMarkPosEqual = true; // has to decide if it is added to the array
- }
- if(pBkmk->IsExpanded()
- && pBkmk->GetOtherMarkPos().nNode.GetIndex() == nNode
- && pBkmk->GetOtherMarkPos().nContent.GetIndex() <= nCntnt)
- {
- if(bMarkPosEqual)
- { // the other position is before, the (main) position is equal
- const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), false, pBkmk->GetMarkPos().nContent.GetIndex() };
- m_aBkmkEntries.push_back(aEntry);
- }
- const MarkEntry aEntry = { ppBkmk - pMarkAccess->getAllMarksBegin(), true, pBkmk->GetOtherMarkPos().nContent.GetIndex() };
- m_aBkmkEntries.push_back(aEntry);
- }
- }
-}
-
-void CntntIdxStoreImpl::RestoreBkmks(SwDoc* pDoc, updater_t& rUpdater)
-{
- IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
- BOOST_FOREACH(const MarkEntry& aEntry, m_aBkmkEntries)
- {
- if (MarkBase* pMark = dynamic_cast<MarkBase*>(pMarkAccess->getAllMarksBegin()[aEntry.m_nIdx].get()))
- {
- SwPosition aNewPos(GetRightMarkPos(pMark, aEntry.m_bOther));
- rUpdater(aNewPos, aEntry.m_nCntnt);
- SetRightMarkPos(pMark, aEntry.m_bOther, &aNewPos);
- }
- }
-}
-
-void CntntIdxStoreImpl::SaveRedlines(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
-{
- const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
- for( long int nIdx = 0 ; static_cast<unsigned long int>(nIdx) < rRedlTbl.size(); ++nIdx )
- {
- const SwRangeRedline* pRdl = rRedlTbl[ nIdx ];
- int nPointPos = lcl_RelativePosition( *pRdl->GetPoint(), nNode, nCntnt );
- int nMarkPos = pRdl->HasMark() ? lcl_RelativePosition( *pRdl->GetMark(), nNode, nCntnt ) :
- nPointPos;
- // #i59534: We have to store the positions inside the same node before the insert position
- // and the one at the insert position if the corresponding Point/Mark position is before
- // the insert position.
- if( nPointPos == BEFORE_SAME_NODE ||
- ( nPointPos == SAME_POSITION && nMarkPos < SAME_POSITION ) )
- {
- const MarkEntry aEntry = { nIdx, false, pRdl->GetPoint()->nContent.GetIndex() };
- m_aRedlineEntries.push_back(aEntry);
- }
- if( pRdl->HasMark() && ( nMarkPos == BEFORE_SAME_NODE ||
- ( nMarkPos == SAME_POSITION && nPointPos < SAME_POSITION ) ) )
- {
- const MarkEntry aEntry = { nIdx, true, pRdl->GetMark()->nContent.GetIndex() };
- m_aRedlineEntries.push_back(aEntry);
- }
- }
-}
-
-void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
-{
- const SwRedlineTbl& rRedlTbl = pDoc->GetRedlineTbl();
- SwPosition* pPos = NULL;
- BOOST_FOREACH(const MarkEntry& aEntry, m_aRedlineEntries)
- {
- pPos = (SwPosition*)( aEntry.m_bOther
- ? rRedlTbl[ aEntry.m_nIdx ]->GetMark()
- : rRedlTbl[ aEntry.m_nIdx ]->GetPoint());
- rUpdater(*pPos, aEntry.m_nCntnt);
- }
-}
-
-void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly)
-{
- SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
- if( !pNode )
- return;
- SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
- if( pFrm )
- {
- if( !pFrm->GetDrawObjs() )
- return; // if we have a layout and no DrawObjs, we can skip this
- }
- MarkEntry aSave;
- BOOST_FOREACH(const SwFrmFmt* pFrmFmt, *pDoc->GetSpzFrmFmts())
- {
- if ( RES_FLYFRMFMT == pFrmFmt->Which() || RES_DRAWFRMFMT == pFrmFmt->Which() )
- {
- bool bSkip = false;
- const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
- if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
- ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
- FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
- {
- aSave.m_bOther = false;
- aSave.m_nCntnt = pAPos->nContent.GetIndex();
- if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
- {
- if( nCntnt <= aSave.m_nCntnt )
- {
- if( SAVEFLY_SPLIT == nSaveFly )
- aSave.m_bOther = true;
- else
- bSkip = true;
- }
- }
- if(!bSkip)
- m_aFlyEntries.push_back(aSave);
- }
- }
- ++aSave.m_nIdx;
- }
-}
-
-void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto)
-{
- SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
- BOOST_FOREACH(const MarkEntry& aEntry, m_aFlyEntries)
- {
- if(!aEntry.m_bOther)
- {
- SwFrmFmt *pFrmFmt = (*pSpz)[ aEntry.m_nIdx ];
- const SwFmtAnchor& rFlyAnchor = pFrmFmt->GetAnchor();
- if( rFlyAnchor.GetCntntAnchor() )
- {
- SwFmtAnchor aNew( rFlyAnchor );
- SwPosition aNewPos( *rFlyAnchor.GetCntntAnchor() );
- rUpdater(aNewPos, aEntry.m_nCntnt);
- if ( FLY_AT_CHAR != rFlyAnchor.GetAnchorId() )
- {
- aNewPos.nContent.Assign( 0, 0 );
- }
- aNew.SetAnchor( &aNewPos );
- pFrmFmt->SetFmtAttr( aNew );
- }
- }
- else if( bAuto )
- {
- SwFrmFmt *pFrmFmt = (*pSpz)[ aEntry.m_nIdx ];
- SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
- pFrmFmt->NotifyClients( pAnchor, pAnchor );
- }
- }
-}
-
-void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
-{
- BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
- {
- FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
- FOREACHPAM_END()
- const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
- if( pUnoTblCrsr )
- {
- FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
- lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
- FOREACHPAM_END()
- }
- }
-}
-
-void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
-{
- BOOST_FOREACH(const PaMEntry& aEntry, m_aUnoCrsrEntries)
- {
- rUpdater(aEntry.m_pPaM->GetBound(!aEntry.m_isMark), aEntry.m_nCntnt);
- }
-}
-
-void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
-{
- SwCrsrShell* pShell = pDoc->GetEditShell();
- if( !pShell )
- return;
- SwViewShell *_pStartShell = pShell;
- do {
- if( _pStartShell->IsA( TYPE( SwCrsrShell )) )
- {
- SwPaM *_pStkCrsr = ((SwCrsrShell*)_pStartShell)->GetStkCrsr();
- if( _pStkCrsr )
- do {
- lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr);
- } while ( (_pStkCrsr != 0 ) &&
- ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != ((SwCrsrShell*)_pStartShell)->GetStkCrsr()) );
-
- FOREACHPAM_START( ((SwCrsrShell*)_pStartShell)->_GetCrsr() )
- lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR);
- FOREACHPAM_END()
- }
- } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell );
-}
-
-void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
-{
- BOOST_FOREACH(const PaMEntry& aEntry, m_aShellCrsrEntries)
- {
- rUpdater(aEntry.m_pPaM->GetBound(aEntry.m_isMark), aEntry.m_nCntnt);
- }
-}
-
-namespace sw { namespace mark {
- boost::shared_ptr<CntntIdxStore> CntntIdxStore::Create()
- {
- return boost::shared_ptr<CntntIdxStore>(new CntntIdxStoreImpl());
- }
-}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6c1f2ea2aa11b2c8fd42b455c7c452194ed2c1e7
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:25:11 2014 +0200
update comment
Change-Id: Ia1ab167fbfa497bff7e8687995e6df1e9e4bd3b5
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 1606d2a..4fe7090 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1274,7 +1274,7 @@ void SaveBookmark::SetInDoc(
}
}
-// _DelBookmarks, _{Save,Restore}CntntIdx
+// _DelBookmarks
void _DelBookmarks(
const SwNodeIndex& rStt,
commit f3974d020b8c066dcb08a54ad94740d5131c86f9
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Fri Jul 25 00:24:08 2014 +0200
simplify ChkPaM some more
Change-Id: I499f76252d145fc3a3afd2e3646ef81e8055e327
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 7b5137b..1606d2a 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1475,36 +1475,7 @@ namespace
inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
{ bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
};
- static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt,
- const SwPaM& rPam,
- bool bChkSelDirection )
- {
- // Respect direction of selection
- bool bBound1IsStart = !bChkSelDirection ||
- ( *rPam.GetPoint() < *rPam.GetMark()
- ? rPam.GetPoint() == &rPam.GetBound()
- : rPam.GetMark() == &rPam.GetBound());
-
- const SwPosition* pPos = &rPam.GetBound( true );
- if( pPos->nNode.GetIndex() == nNode &&
- ( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt
- : pPos->nContent.GetIndex() <= nCntnt ))
- {
- const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), false, pPos->nContent.GetIndex() };
- rMarkEntries.push_back(aEntry);
- }
-
- pPos = &rPam.GetBound( false );
- if( pPos->nNode.GetIndex() == nNode &&
- ( (bBound1IsStart && bChkSelDirection)
- ? pPos->nContent.GetIndex() <= nCntnt
- : pPos->nContent.GetIndex() < nCntnt ))
- {
- const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), true, pPos->nContent.GetIndex() };
- rMarkEntries.push_back(aEntry);
- }
- }
- static void lcl_ChkPaM( std::vector<PaMEntry> &rPaMEntries, sal_uLong nNode, sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
+ static inline void lcl_ChkPaM( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM, const bool bPoint)
{
const SwPosition* pPos = &rPaM.GetBound( bPoint );
if( pPos->nNode.GetIndex() == nNode && pPos->nContent.GetIndex() < nCntnt )
@@ -1513,6 +1484,11 @@ namespace
rPaMEntries.push_back(aEntry);
}
}
+ static inline void lcl_ChkPaMBoth( std::vector<PaMEntry>& rPaMEntries, const sal_uLong nNode, const sal_Int32 nCntnt, SwPaM& rPaM)
+ {
+ lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, true);
+ lcl_ChkPaM(rPaMEntries, nNode, nCntnt, rPaM, false);
+ }
#if 0
static void DumpEntries(std::vector<MarkEntry>* pEntries)
@@ -1693,13 +1669,13 @@ void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCn
BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
{
FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
- lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false );
+ lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
FOREACHPAM_END()
const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
if( pUnoTblCrsr )
{
FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
- lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false );
+ lcl_ChkPaMBoth( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR );
FOREACHPAM_END()
}
}
@@ -1725,14 +1701,12 @@ void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 n
SwPaM *_pStkCrsr = ((SwCrsrShell*)_pStartShell)->GetStkCrsr();
if( _pStkCrsr )
do {
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
+ lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr);
} while ( (_pStkCrsr != 0 ) &&
((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != ((SwCrsrShell*)_pStartShell)->GetStkCrsr()) );
FOREACHPAM_START( ((SwCrsrShell*)_pStartShell)->_GetCrsr() )
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
+ lcl_ChkPaMBoth( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR);
FOREACHPAM_END()
}
} while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell );
commit bb67dc2752cc37a636fc851ba5b29e6cf0236362
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 23:47:52 2014 +0200
Update UnoCrsrs by PaM, not by index
Change-Id: Ifcf7dd74e06453b9ac4d6a76ac671fd4c6735970
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 4665751..7b5137b 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1414,7 +1414,7 @@ namespace
std::vector<MarkEntry> m_aBkmkEntries;
std::vector<MarkEntry> m_aRedlineEntries;
std::vector<MarkEntry> m_aFlyEntries;
- std::vector<MarkEntry> m_aUnoCrsrEntries;
+ std::vector<PaMEntry> m_aUnoCrsrEntries;
std::vector<PaMEntry> m_aShellCrsrEntries;
typedef boost::function<void (SwPosition& rPos, sal_Int32 nCntnt)> updater_t;
virtual void Clear() SAL_OVERRIDE
@@ -1475,8 +1475,8 @@ namespace
inline void SetRightMarkPos(MarkBase* pMark, bool bOther, const SwPosition* const pPos)
{ bOther ? pMark->SetOtherMarkPos(*pPos) : pMark->SetMarkPos(*pPos); };
};
- static void lcl_ChkPaM( std::vector<MarkEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt,
- const SwPaM& rPam, const long int nIdx,
+ static void lcl_ChkUnoCrsrPaM( std::vector<PaMEntry>& rMarkEntries, sal_uLong nNode, sal_Int32 nCntnt,
+ const SwPaM& rPam,
bool bChkSelDirection )
{
// Respect direction of selection
@@ -1490,7 +1490,7 @@ namespace
( bBound1IsStart ? pPos->nContent.GetIndex() < nCntnt
: pPos->nContent.GetIndex() <= nCntnt ))
{
- const MarkEntry aEntry = { nIdx, false, pPos->nContent.GetIndex() };
+ const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), false, pPos->nContent.GetIndex() };
rMarkEntries.push_back(aEntry);
}
@@ -1500,7 +1500,7 @@ namespace
? pPos->nContent.GetIndex() <= nCntnt
: pPos->nContent.GetIndex() < nCntnt ))
{
- const MarkEntry aEntry = { nIdx, true, pPos->nContent.GetIndex() };
+ const PaMEntry aEntry = { const_cast<SwPaM*>(&rPam), true, pPos->nContent.GetIndex() };
rMarkEntries.push_back(aEntry);
}
}
@@ -1690,64 +1690,26 @@ void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto
void CntntIdxStoreImpl::SaveUnoCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
{
- long int nIdx = 0;
BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
{
FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
- lcl_ChkPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, nIdx++, false );
+ lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false );
FOREACHPAM_END()
const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
if( pUnoTblCrsr )
{
FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
- lcl_ChkPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, nIdx++, false );
+ lcl_ChkUnoCrsrPaM( m_aUnoCrsrEntries, nNode, nCntnt, *PCURCRSR, false );
FOREACHPAM_END()
}
}
}
-void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater)
+void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
{
- BOOST_FOREACH(const MarkEntry& aEntry, m_aUnoCrsrEntries)
+ BOOST_FOREACH(const PaMEntry& aEntry, m_aUnoCrsrEntries)
{
- sal_uInt16 nCnt = 0;
- BOOST_FOREACH(const SwUnoCrsr* pUnoCrsr, pDoc->GetUnoCrsrTbl())
- {
- SAL_INFO("sw.core", "Looking for Index " << aEntry.m_nIdx << " now at PaM Index" << nCnt << ": " << pUnoCrsr);
- SwPosition* pPos = NULL;
- FOREACHPAM_START( const_cast<SwUnoCrsr*>(pUnoCrsr) )
- if( aEntry.m_nIdx == nCnt )
- {
- SAL_INFO("sw.core", "Found PaM " << PCURCRSR << " for Index " << aEntry.m_nIdx);
- pPos = &PCURCRSR->GetBound( !aEntry.m_bOther );
- break;
- }
- else
- SAL_INFO("sw.core", "Skipping PaM " << PCURCRSR << " for Index " << aEntry.m_nIdx);
- ++nCnt;
- FOREACHPAM_END()
- const SwUnoTableCrsr* pUnoTblCrsr = dynamic_cast<const SwUnoTableCrsr*>(pUnoCrsr);
- if( !pPos && pUnoTblCrsr )
- {
- FOREACHPAM_START( &(const_cast<SwUnoTableCrsr*>(pUnoTblCrsr))->GetSelRing() )
- if( aEntry.m_nIdx == nCnt )
- {
- SAL_INFO("sw.core", "Found Table PaM " << PCURCRSR << " for Index " << aEntry.m_nIdx);
- pPos = &PCURCRSR->GetBound( !aEntry.m_bOther );
- break;
- }
- else
- SAL_INFO("sw.core", "Skipping Table PaM " << PCURCRSR << " for Index " << aEntry.m_nIdx);
- ++nCnt;
- FOREACHPAM_END()
- }
- if( pPos )
- {
- SAL_INFO("sw.core", "Would be setting " << pPos << " for Index " << aEntry.m_nIdx);
- rUpdater(*pPos, aEntry.m_nCntnt);
- break;
- }
- }
+ rUpdater(aEntry.m_pPaM->GetBound(!aEntry.m_isMark), aEntry.m_nCntnt);
}
}
commit 4a1a94dff6a76d70ee72c6c840a24953eca0a9f0
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 23:28:14 2014 +0200
remove dead code
Change-Id: I01ae59431b666ffb4bdfecb7b4256612a3bda8cf
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index b083854..4665751 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1662,7 +1662,6 @@ void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto
SwFrmFmts* pSpz = pDoc->GetSpzFrmFmts();
BOOST_FOREACH(const MarkEntry& aEntry, m_aFlyEntries)
{
- SwPosition* pPos = 0;
if(!aEntry.m_bOther)
{
SwFrmFmt *pFrmFmt = (*pSpz)[ aEntry.m_nIdx ];
@@ -1686,11 +1685,6 @@ void CntntIdxStoreImpl::RestoreFlys(SwDoc* pDoc, updater_t& rUpdater, bool bAuto
SfxPoolItem *pAnchor = (SfxPoolItem*)&pFrmFmt->GetAnchor();
pFrmFmt->NotifyClients( pAnchor, pAnchor );
}
- if( pPos )
- {
- SAL_INFO("sw.core", "setting " << pPos << " for Index " << aEntry.m_nIdx << " from " << pPos->nContent.GetIndex());
- rUpdater(*pPos, aEntry.m_nCntnt);
- }
}
}
commit d1e1aeecd143287b1abf7cfcabb230a0c59dc79c
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 23:24:59 2014 +0200
simplify conditionals
Change-Id: I979428a490e9a2a91fa736925f132ae8e1fc9a9f
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 2007d6f..b083854 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1628,34 +1628,30 @@ void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
MarkEntry aSave;
BOOST_FOREACH(const SwFrmFmt* pFrmFmt, *pDoc->GetSpzFrmFmts())
{
- if ( RES_FLYFRMFMT != pFrmFmt->Which() && RES_DRAWFRMFMT != pFrmFmt->Which() )
+ if ( RES_FLYFRMFMT == pFrmFmt->Which() || RES_DRAWFRMFMT == pFrmFmt->Which() )
{
- ++aSave.m_nIdx;
- continue;
- }
-
- const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
- if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
- ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
- FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
- {
- aSave.m_bOther = false;
- aSave.m_nCntnt = pAPos->nContent.GetIndex();
- if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
+ bool bSkip = false;
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
+ if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
+ ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
+ FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
{
- if( nCntnt <= aSave.m_nCntnt )
+ aSave.m_bOther = false;
+ aSave.m_nCntnt = pAPos->nContent.GetIndex();
+ if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
{
- if( SAVEFLY_SPLIT == nSaveFly )
- aSave.m_bOther = true;
- else
+ if( nCntnt <= aSave.m_nCntnt )
{
- ++aSave.m_nIdx;
- continue;
+ if( SAVEFLY_SPLIT == nSaveFly )
+ aSave.m_bOther = true;
+ else
+ bSkip = true;
}
}
+ if(!bSkip)
+ m_aFlyEntries.push_back(aSave);
}
- m_aFlyEntries.push_back(aSave);
}
++aSave.m_nIdx;
}
commit 41c5d4c4f83b09f2fedb53bb8e63caaf9a210986
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 23:00:23 2014 +0200
use a BOOST_FOREACH here
Change-Id: Ibea1bc9aba21916ad25f41463ddf4466a8fb5b33
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 38a6f24..2007d6f 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1626,11 +1626,13 @@ void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
return; // if we have a layout and no DrawObjs, we can skip this
}
MarkEntry aSave;
- for( aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size(); aSave.m_nIdx ; )
+ BOOST_FOREACH(const SwFrmFmt* pFrmFmt, *pDoc->GetSpzFrmFmts())
{
- SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ --aSave.m_nIdx ];
if ( RES_FLYFRMFMT != pFrmFmt->Which() && RES_DRAWFRMFMT != pFrmFmt->Which() )
+ {
+ ++aSave.m_nIdx;
continue;
+ }
const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
@@ -1647,11 +1649,15 @@ void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
if( SAVEFLY_SPLIT == nSaveFly )
aSave.m_bOther = true;
else
+ {
+ ++aSave.m_nIdx;
continue;
+ }
}
}
m_aFlyEntries.push_back(aSave);
}
+ ++aSave.m_nIdx;
}
}
commit 0a861cc83fad0e3bcae21b15d8ef04f416a8a262
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 22:39:04 2014 +0200
well, lets keep some sane optimization
Change-Id: Ia399dd7995fdbf4c1ce276c835a8812ce6e07184
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 839d8f9..38a6f24 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1616,7 +1616,15 @@ void CntntIdxStoreImpl::RestoreRedlines(SwDoc* pDoc, updater_t& rUpdater)
void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt, sal_uInt8 nSaveFly)
{
- // Paragraph anchored objects
+ SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
+ if( !pNode )
+ return;
+ SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
+ if( pFrm )
+ {
+ if( !pFrm->GetDrawObjs() )
+ return; // if we have a layout and no DrawObjs, we can skip this
+ }
MarkEntry aSave;
for( aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size(); aSave.m_nIdx ; )
{
commit e6d234aa9bd2871546b114d542f3a1bcd696a122
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 22:09:08 2014 +0200
this ancient 'optimization' doesnt seem to do any good
- shorttracking by iterating over DrawObjs instead of all SpzFrmFmts
sounds good ...
- ... until you realize this still iterates over SpzFrmFmts to find the
index. Actually it does this multiple times for each find.
Change-Id: I31eb85dffa0177256f50aa2ee98953df1b9efbc4
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 4e8b9b7..839d8f9 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1618,89 +1618,31 @@ void CntntIdxStoreImpl::SaveFlys(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt,
{
// Paragraph anchored objects
MarkEntry aSave;
- SwCntntNode *pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
- if( !pNode )
- return;
- SwFrm* pFrm = pNode->getLayoutFrm( pDoc->GetCurrentLayout() );
-#if OSL_DEBUG_LEVEL > 1
- static bool bViaDoc = false;
- if( bViaDoc )
- pFrm = NULL;
-#endif
- if( pFrm ) // Do we have a layout? Then it's a bit cheaper ...
+ for( aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size(); aSave.m_nIdx ; )
{
- if( !pFrm->GetDrawObjs() )
- return;
- const SwSortedObjs& rDObj = *pFrm->GetDrawObjs();
- for( sal_uInt32 n = rDObj.Count(); n; )
- {
- SwAnchoredObject* pObj = rDObj[ --n ];
- const SwFrmFmt& rFmt = pObj->GetFrmFmt();
- const SwFmtAnchor& rAnchor = rFmt.GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
- if ( pAPos &&
- ( ( nSaveFly &&
- FLY_AT_PARA == rAnchor.GetAnchorId() ) ||
- ( FLY_AT_CHAR == rAnchor.GetAnchorId() ) ) )
- {
- aSave.m_bOther = false;
- aSave.m_nCntnt = pAPos->nContent.GetIndex();
+ SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ --aSave.m_nIdx ];
+ if ( RES_FLYFRMFMT != pFrmFmt->Which() && RES_DRAWFRMFMT != pFrmFmt->Which() )
+ continue;
- OSL_ENSURE( nNode == pAPos->nNode.GetIndex(),
- "_SaveCntntIdx: Wrong Node-Index" );
- if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
- {
- if( nCntnt <= aSave.m_nCntnt )
- {
- if( SAVEFLY_SPLIT == nSaveFly )
- aSave.m_bOther = true;
- else
- continue;
- }
- }
- aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size();
- while( aSave.m_nIdx &&
- &rFmt != (*pDoc->GetSpzFrmFmts())[
- --aSave.m_nIdx ] )
- ; // nothing
- OSL_ENSURE( &rFmt == (*pDoc->GetSpzFrmFmts())[
- aSave.m_nIdx ],
- "_SaveCntntIdx: Lost FrameFormat" );
- m_aFlyEntries.push_back(aSave);
- }
- }
- }
- else // No layout, so it's a bit more expensive ...
- {
- for( aSave.m_nIdx = pDoc->GetSpzFrmFmts()->size();
- aSave.m_nIdx ; )
+ const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
+ SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
+ if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
+ ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
+ FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
{
- SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[
- --aSave.m_nIdx ];
- if ( RES_FLYFRMFMT != pFrmFmt->Which() &&
- RES_DRAWFRMFMT != pFrmFmt->Which() )
- continue;
-
- const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
- SwPosition const*const pAPos = rAnchor.GetCntntAnchor();
- if ( pAPos && ( nNode == pAPos->nNode.GetIndex() ) &&
- ( FLY_AT_PARA == rAnchor.GetAnchorId() ||
- FLY_AT_CHAR == rAnchor.GetAnchorId() ) )
+ aSave.m_bOther = false;
+ aSave.m_nCntnt = pAPos->nContent.GetIndex();
+ if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
{
- aSave.m_bOther = false;
- aSave.m_nCntnt = pAPos->nContent.GetIndex();
- if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
+ if( nCntnt <= aSave.m_nCntnt )
{
- if( nCntnt <= aSave.m_nCntnt )
- {
- if( SAVEFLY_SPLIT == nSaveFly )
- aSave.m_bOther = true;
- else
- continue;
- }
+ if( SAVEFLY_SPLIT == nSaveFly )
+ aSave.m_bOther = true;
+ else
+ continue;
}
- m_aFlyEntries.push_back(aSave);
}
+ m_aFlyEntries.push_back(aSave);
}
}
}
commit f009c21242dcb964af455e755b1511330f9bffaa
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 20:55:12 2014 +0200
expand and kill once-used macro
Change-Id: I5f02a821e7898e687f566970c2e12ce1a3788094
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 93be9f8..4e8b9b7 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1111,19 +1111,6 @@ namespace sw { namespace mark
}} // namespace ::sw::mark
-#define PCURSH ((SwCrsrShell*)_pStartShell)
-#define FOREACHSHELL_START( pEShell ) \
- {\
- SwViewShell *_pStartShell = pEShell; \
- do { \
- if( _pStartShell->IsA( TYPE( SwCrsrShell )) ) \
- {
-
-#define FOREACHSHELL_END( pEShell ) \
- } \
- } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pEShell ); \
- }
-
namespace
{
// #i59534: If a paragraph will be splitted we have to restore some redline positions
@@ -1823,21 +1810,24 @@ void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 n
SwCrsrShell* pShell = pDoc->GetEditShell();
if( !pShell )
return;
- FOREACHSHELL_START( pShell )
- SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
- if( _pStkCrsr )
- do {
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
- } while ( (_pStkCrsr != 0 ) &&
- ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-
- FOREACHPAM_START( PCURSH->_GetCrsr() )
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
- FOREACHPAM_END()
-
- FOREACHSHELL_END( pShell )
+ SwViewShell *_pStartShell = pShell;
+ do {
+ if( _pStartShell->IsA( TYPE( SwCrsrShell )) )
+ {
+ SwPaM *_pStkCrsr = ((SwCrsrShell*)_pStartShell)->GetStkCrsr();
+ if( _pStkCrsr )
+ do {
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
+ } while ( (_pStkCrsr != 0 ) &&
+ ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != ((SwCrsrShell*)_pStartShell)->GetStkCrsr()) );
+
+ FOREACHPAM_START( ((SwCrsrShell*)_pStartShell)->_GetCrsr() )
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
+ FOREACHPAM_END()
+ }
+ } while((_pStartShell=(SwViewShell*)_pStartShell->GetNext())!= pShell );
}
void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
commit e5de683032e8a4314925f070b4c58eb41b87a1da
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Thu Jul 24 20:42:10 2014 +0200
remove superfluous scope
Change-Id: Ib68b3d12871de035dbeab6cb963e90ca8b297c08
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index ea3ee52..93be9f8 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1821,24 +1821,23 @@ void CntntIdxStoreImpl::RestoreUnoCrsrs(SwDoc* pDoc, updater_t& rUpdater)
void CntntIdxStoreImpl::SaveShellCrsrs(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nCntnt)
{
SwCrsrShell* pShell = pDoc->GetEditShell();
- if( pShell )
- {
- FOREACHSHELL_START( pShell )
- SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
- if( _pStkCrsr )
- do {
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
- } while ( (_pStkCrsr != 0 ) &&
- ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
-
- FOREACHPAM_START( PCURSH->_GetCrsr() )
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
- lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
- FOREACHPAM_END()
+ if( !pShell )
+ return;
+ FOREACHSHELL_START( pShell )
+ SwPaM *_pStkCrsr = PCURSH->GetStkCrsr();
+ if( _pStkCrsr )
+ do {
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, true);
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *_pStkCrsr, false);
+ } while ( (_pStkCrsr != 0 ) &&
+ ((_pStkCrsr=(SwPaM *)_pStkCrsr->GetNext()) != PCURSH->GetStkCrsr()) );
+
+ FOREACHPAM_START( PCURSH->_GetCrsr() )
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, true);
+ lcl_ChkPaM( m_aShellCrsrEntries, nNode, nCntnt, *PCURCRSR, false);
+ FOREACHPAM_END()
- FOREACHSHELL_END( pShell )
- }
+ FOREACHSHELL_END( pShell )
}
void CntntIdxStoreImpl::RestoreShellCrsrs(SwDoc* /* pDoc */, updater_t& rUpdater)
More information about the Libreoffice-commits
mailing list