[Libreoffice-commits] .: 12 commits - sw/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Jun 27 07:28:05 PDT 2011
sw/source/filter/inc/fltshell.hxx | 81 +++++--
sw/source/filter/inc/msfilter.hxx | 22 --
sw/source/filter/ww1/fltshell.cxx | 363 +++++++++++++++++++---------------
sw/source/filter/ww8/writerhelper.cxx | 9
sw/source/filter/ww8/ww8graf.cxx | 26 +-
sw/source/filter/ww8/ww8par.cxx | 72 +++---
sw/source/filter/ww8/ww8par.hxx | 8
sw/source/filter/ww8/ww8par5.cxx | 8
sw/source/filter/ww8/ww8par6.cxx | 24 +-
9 files changed, 354 insertions(+), 259 deletions(-)
New commits:
commit 6e9d8106589954e2b251686ab92b8e5d8c6f1e1d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 15:14:09 2011 +0100
rename CloseIfOpen -> SetEndIfOpen which is what it does
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 2e1efba..68ab860 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -401,12 +401,12 @@ namespace sw
@author
<a href="mailto:mmaher at openoffice.org">Martin Maher</a>
*/
- class CloseIfOpen //Subclass from something ?
+ class SetEndIfOpen //Subclass from something ?
{
private:
const SwPosition &mrPos;
public:
- explicit CloseIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
+ explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
void operator()(SwFltStackEntry *pEntry) const
{
if (pEntry->bOpen)
@@ -414,7 +414,7 @@ namespace sw
}
private:
//No assignment
- CloseIfOpen& operator=(const CloseIfOpen&);
+ SetEndIfOpen& operator=(const SetEndIfOpen&);
};
/**
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 28dbb6c..a4edabc 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -696,14 +696,11 @@ namespace sw
return false;
}
-
-
void RedlineStack::closeall(const SwPosition& rPos)
{
- std::for_each(maStack.begin(), maStack.end(), CloseIfOpen(rPos));
+ std::for_each(maStack.begin(), maStack.end(), SetEndIfOpen(rPos));
}
-
void SetInDocAndDelete::operator()(SwFltStackEntry *pEntry)
{
SwPaM aRegion(pEntry->m_aMkPos.m_nNode);
commit d5b005b7023d8f32d6e7000349fc7604569ed3cd
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 15:10:32 2011 +0100
use public boost::noncopyable instead
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 8be0e0e..2e1efba 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -43,6 +43,8 @@
#include <shellio.hxx>
#include <svl/zforlist.hxx>
+#include <boost/noncopyable.hpp>
+
#define CREATE_CONST_ASC(s) String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(s))
class SwDoc;
@@ -363,7 +365,7 @@ namespace sw
@author
<a href="mailto:mmaher at openoffice.org">Martin Maher</a>
*/
- class RedlineStack
+ class RedlineStack : public boost::noncopyable
{
private:
std::vector<SwFltStackEntry *> maStack;
@@ -377,10 +379,6 @@ namespace sw
WW8TabDesc* pTabDesc );
void closeall(const SwPosition& rPos);
~RedlineStack();
- private:
- //No copying
- RedlineStack(const RedlineStack&);
- RedlineStack& operator=(const RedlineStack&);
};
/**
@@ -432,16 +430,12 @@ namespace sw
const;
};
- class WrtRedlineAuthor
+ class WrtRedlineAuthor : public boost::noncopyable
{
protected:
std::vector<String> maAuthors; // Array of Sw - Bookmarknames
sal_uInt16 GetPos( const String& rNm );
-
- //No copying
- WrtRedlineAuthor(const WrtRedlineAuthor&);
- WrtRedlineAuthor& operator=(const WrtRedlineAuthor&);
public:
WrtRedlineAuthor() {}
virtual ~WrtRedlineAuthor() {}
commit 1d09d865e0468e7a8c3170ba5081bc9bd525b24f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 15:03:37 2011 +0100
rename bLocked to bOpen to be meaningful
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index ac056e8..bd8ddb1 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -117,7 +117,7 @@ public:
SfxPoolItem * pAttr;// Format Attribute
sal_Bool bOld; // to mark Attributes *before* skipping field results
- sal_Bool bLocked;
+ sal_Bool bOpen; //Entry open, awaiting being closed
sal_Bool bConsumedByField;
SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt );
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 62239f4..8be0e0e 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -411,7 +411,7 @@ namespace sw
explicit CloseIfOpen(const SwPosition &rPos) : mrPos(rPos) {}
void operator()(SwFltStackEntry *pEntry) const
{
- if (pEntry->bLocked)
+ if (pEntry->bOpen)
pEntry->SetEndPos(mrPos);
}
private:
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 4ca2ca9..c511b3a 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -97,7 +97,7 @@ SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
{
pAttr = pHt; // speicher eine Kopie vom Attribut
bOld = sal_False; // used for marking Attributes *before* skipping field results
- bLocked = sal_True; // locke das Attribut --> darf erst
+ bOpen = sal_True; // locke das Attribut --> darf erst
bConsumedByField = sal_False;
}
@@ -115,7 +115,7 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
// Cursor-Position auch der Bereich vom Attribut weiter
// verschoben wird.
// Das ist aber nicht das gewollte!
- bLocked = sal_False; // freigeben und das ENDE merken
+ bOpen = sal_False; // freigeben und das ENDE merken
m_aPtPos.SetPos(rEndPos);
}
@@ -251,7 +251,7 @@ void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr
//from. If so we merge it with this one and elide adding another
//to the stack
pExtendCandidate->SetEndPos(rPos);
- pExtendCandidate->bLocked=true;
+ pExtendCandidate->bOpen=true;
}
else
maEntries.push_back(new SwFltStackEntry(rPos, rAttr.Clone()));
@@ -303,7 +303,7 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
nCnt --;
SwFltStackEntry& rEntry = maEntries[nCnt];
if( !rEntry.bOld
- && !rEntry.bLocked
+ && !rEntry.bOpen
&& (rEntry.m_aMkPos == aFltPos)
&& (rEntry.m_aPtPos == aFltPos))
{
@@ -333,7 +333,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
while (aI != maEntries.end())
{
SwFltStackEntry& rEntry = *aI;
- if (rEntry.bLocked)
+ if (rEntry.bOpen)
{
// setze das Ende vom Attribut
bool bF = false;
@@ -664,7 +664,7 @@ SfxPoolItem* SwFltControlStack::GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 *
// ist es das gesuchte Attribut ? (gueltig sind nur gelockte,
// also akt. gesetzte Attribute!!)
SwFltStackEntry &rEntry = maEntries[--nSize];
- if (rEntry.bLocked && rEntry.pAttr->Which() == nWhich)
+ if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich)
{
if (pPos)
*pPos = nSize;
@@ -719,7 +719,7 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
bool bEntryEndAfterSelStart = false;
bool bEntryEndBeforeSelEnd = false;
- if (!rEntry.bLocked)
+ if (!rEntry.bOpen)
{
bEntryEndAfterSelStart =
(rEntry.m_aPtPos.m_nNode == aStartNode &&
@@ -768,8 +768,8 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
rEntry.m_aPtPos.m_nCntnt -= nCntntDiff;
}
- //That's what locked is, end equal to start, and nPtCntnt is invalid
- if (rEntry.bLocked)
+ //That's what Open is, end equal to start, and nPtCntnt is invalid
+ if (rEntry.bOpen)
rEntry.m_aPtPos = rEntry.m_aMkPos;
}
}
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 5f705e1..28dbb6c 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -679,7 +679,7 @@ namespace sw
{
const SwFltRedline *pTest = static_cast<const SwFltRedline *>
(pEntry->pAttr);
- return (pEntry->bLocked && (pTest->eType == meType));
+ return (pEntry->bOpen && (pTest->eType == meType));
}
};
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 445017d..0073f23 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1243,13 +1243,13 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
const SwFltStackEntry& rEntry = (*this)[ --nSize ];
if (rEntry.pAttr->Which() == nWhich)
{
- if ( (rEntry.bLocked) ||
+ if ( (rEntry.bOpen) ||
(
(rEntry.m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
(rEntry.m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
(rEntry.m_aMkPos.m_nCntnt <= aFltPos.m_nCntnt) &&
(rEntry.m_aPtPos.m_nCntnt > aFltPos.m_nCntnt)
- )
+ )
)
/*
* e.g. half-open range [0-3) so asking for properties at 3
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index e3d23f7..4272710 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2187,7 +2187,7 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk)
for (size_t i=0; i < nCnt; ++i)
{
const SwFltStackEntry& rEntry = (*pCtrlStck)[ i ];
- if (rEntry.bLocked)
+ if (rEntry.bOpen)
{
if (isCHRATR(rEntry.pAttr->Which()))
{
commit fedefc2a281edae1b75530bfd2b1639417a2fedc
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 14:52:41 2011 +0100
Related: #i76955# make this 4+ times faster
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 2be2cdd..ac056e8 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -169,7 +169,7 @@ public:
void NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr );
- virtual void SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand = LONG_MAX, sal_Bool consumedByField=sal_False);
+ virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand = LONG_MAX, sal_Bool consumedByField=sal_False);
void StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId = 0);
void MarkAllAttrsOld();
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 5169992..4ca2ca9 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -222,14 +222,39 @@ void SwFltControlStack::MarkAllAttrsOld()
maEntries[i].bOld = sal_True;
}
-void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr )
+namespace
{
- SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
- sal_uInt16 nWhich = pTmp->pAttr->Which();
- SetAttr(rPos, nWhich);// Ende von evtl. gleichen Attributen auf dem Stack
- // Setzen, damit sich die Attribute nicht auf
- // dem Stack haeufen
- maEntries.push_back(pTmp);
+ bool couldExtendEntry(const SwFltStackEntry *pExtendCandidate,
+ const SfxPoolItem& rAttr)
+ {
+ return (pExtendCandidate &&
+ !pExtendCandidate->bConsumedByField &&
+ //potentially more, but lets keep it simple
+ (isPARATR_LIST(rAttr.Which()) || isCHRATR(rAttr.Which())) &&
+ *(pExtendCandidate->pAttr) == rAttr);
+ }
+}
+
+void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr)
+{
+ sal_uInt16 nWhich = rAttr.Which();
+ // Ende von evtl. gleichen Attributen auf dem Stack Setzen, damit sich die
+ // Attribute nicht auf dem Stack haeufen
+ SwFltStackEntry *pExtendCandidate = SetAttr(rPos, nWhich);
+ if (couldExtendEntry(pExtendCandidate, rAttr))
+ {
+ //Here we optimize by seeing if there is an attribute uncommited
+ //to the document which
+ //
+ //a) has the same value as this attribute
+ //b) is already open, or ends at the same place as where we're starting
+ //from. If so we merge it with this one and elide adding another
+ //to the stack
+ pExtendCandidate->SetEndPos(rPos);
+ pExtendCandidate->bLocked=true;
+ }
+ else
+ maEntries.push_back(new SwFltStackEntry(rPos, rAttr.Clone()));
}
void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
@@ -291,28 +316,39 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
// alle anderen im Document setzen und wieder aus dem Stack loeschen
// Returned, ob das gesuchte Attribut / die gesuchten Attribute
// ueberhaupt auf dem Stack standen
-void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
- sal_Bool bTstEnde, long nHand, sal_Bool consumedByField )
+SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
+ sal_uInt16 nAttrId, sal_Bool bTstEnde, long nHand,
+ sal_Bool consumedByField)
{
+ SwFltStackEntry *pRet = NULL;
+
+ SwFltPosition aFltPos(rPos);
+
OSL_ENSURE(!nAttrId ||
(POOLATTR_BEGIN <= nAttrId && POOLATTR_END > nAttrId) ||
(RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
"Falsche Id fuers Attribut");
- size_t nCnt = maEntries.size();
- for (size_t i=0; i < nCnt; ++i)
+ myEIter aI = maEntries.begin();
+ while (aI != maEntries.end())
{
- SwFltStackEntry& rEntry = maEntries[i];
+ SwFltStackEntry& rEntry = *aI;
if (rEntry.bLocked)
{
// setze das Ende vom Attribut
bool bF = false;
- if (!nAttrId ){
+ if (!nAttrId )
+ {
bF = true;
- }else if( nAttrId == rEntry.pAttr->Which()){
- if( nAttrId != RES_FLTR_BOOKMARK ){ // Handle abfragen
+ }
+ else if (nAttrId == rEntry.pAttr->Which())
+ {
+ if( nAttrId != RES_FLTR_BOOKMARK )
+ {
+ // Handle abfragen
bF = true;
- }else if( nHand == ((SwFltBookmark*)(rEntry.pAttr))->GetHandle() )
+ }
+ else if (nHand == ((SwFltBookmark*)(rEntry.pAttr))->GetHandle())
{
bF = true;
}
@@ -321,7 +357,14 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
{
rEntry.bConsumedByField = consumedByField;
rEntry.SetEndPos(rPos);
+ if (nAttrId == rEntry.pAttr->Which())
+ {
+ //potential candidate for merging with an identical
+ //property beginning at rPos
+ pRet = &rEntry;
+ }
}
+ ++aI;
continue;
}
@@ -331,14 +374,33 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
// Beim Ende-Stack niemals ausser am DocEnde reinsetzen
if (bTstEnde)
{
- if (bIsEndStack || rEntry.m_aPtPos.m_nNode.GetIndex()+1 ==
- rPos.nNode.GetIndex())
- continue;
+ if (bIsEndStack)
+ {
+ ++aI;
+ continue;
+ }
+
+ //defer inserting this attribute into the document until
+ //we advance to the next node, or finish processing the document
+ if (rEntry.m_aPtPos.m_nNode.GetIndex() == aFltPos.m_nNode.GetIndex())
+ {
+ if (nAttrId == rEntry.pAttr->Which() &&
+ rEntry.m_aPtPos.m_nCntnt == aFltPos.m_nCntnt)
+ {
+ //potential candidate for merging with an identical
+ //property beginning at rPos
+ pRet = &rEntry;
+ }
+
+ ++aI;
+ continue;
+ }
}
SetAttrInDoc(rPos, rEntry);
- DeleteAndDestroy(i); // loesche aus dem Stack
- i--; nCnt--; // Danach rutschen alle folgenden nach unten
+ aI = maEntries.erase(aI);
}
+
+ return pRet;
}
static void MakePoint(const SwFltStackEntry& rEntry, SwDoc* pDoc,
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index c2e417b..445017d 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -982,9 +982,10 @@ void SwWW8FltControlStack::NewAttr(const SwPosition& rPos,
SwFltControlStack::NewAttr(rPos, rAttr);
}
-void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
+SwFltStackEntry* SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
sal_Bool bTstEnde, long nHand, sal_Bool )
{
+ SwFltStackEntry *pRet = NULL;
//Doing a textbox, and using the control stack only as a temporary
//collection point for properties which will are not to be set into
//the real document
@@ -1002,7 +1003,8 @@ void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
}
}
else //Normal case, set the attribute into the document
- SwFltControlStack::SetAttr(rPos, nAttrId, bTstEnde, nHand);
+ pRet = SwFltControlStack::SetAttr(rPos, nAttrId, bTstEnde, nHand);
+ return pRet;
}
long GetListFirstLineIndent(const SwNumFmt &rFmt)
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 5cce4d0..42a2cf6 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -377,7 +377,7 @@ public:
void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
- virtual void SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand=LONG_MAX, sal_Bool consumedByField=sal_False);
+ virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand=LONG_MAX, sal_Bool consumedByField=sal_False);
void SetToggleAttr(sal_uInt8 nId, bool bOn)
{
commit 76687d6b0119c9addb108eefe98e77353c72569c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 10:41:58 2011 +0100
git rid of bCopied remnent
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index be362d9..2be2cdd 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -118,7 +118,6 @@ public:
sal_Bool bOld; // to mark Attributes *before* skipping field results
sal_Bool bLocked;
- sal_Bool bCopied;
sal_Bool bConsumedByField;
SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt );
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 91ae1d6..5169992 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -98,7 +98,6 @@ SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
pAttr = pHt; // speicher eine Kopie vom Attribut
bOld = sal_False; // used for marking Attributes *before* skipping field results
bLocked = sal_True; // locke das Attribut --> darf erst
- bCopied = sal_False; // gesetzt werden, wenn es wieder geunlocked ist
bConsumedByField = sal_False;
}
commit 70e2aabc9453bcd1f9fb78e0ad84de896b25b6d4
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 27 00:46:00 2011 +0100
std::deque -> boost::ptr_deque
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index f04b289..be362d9 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -28,8 +28,6 @@
#ifndef _FLTSHELL_HXX
#define _FLTSHELL_HXX
-#include <deque>
-
#include <com/sun/star/text/HoriOrientation.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/RelOrientation.hpp>
@@ -44,6 +42,7 @@
#include <IDocumentRedlineAccess.hxx>
#include <boost/noncopyable.hpp>
+#include <boost/ptr_container/ptr_deque.hpp>
class SwTOXBase;
class SwFltShell;
@@ -135,7 +134,7 @@ public:
class SW_DLLPUBLIC SwFltControlStack
{
- typedef std::deque<SwFltStackEntry*> Entries;
+ typedef boost::ptr_deque<SwFltStackEntry> Entries;
typedef Entries::iterator myEIter;
Entries maEntries;
friend class SwFltShell;
@@ -148,7 +147,7 @@ protected:
sal_Bool bIsEndStack;
void MoveAttrs( const SwPosition& rPos );
- virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry);
+ virtual void SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry& rEntry);
public:
enum Flags
@@ -182,7 +181,7 @@ public:
bool empty() const { return maEntries.empty(); }
Entries::size_type size() const { return maEntries.size(); }
- SwFltStackEntry* operator[](Entries::size_type nIndex)
+ SwFltStackEntry& operator[](Entries::size_type nIndex)
{ return maEntries[nIndex]; }
void DeleteAndDestroy(Entries::size_type nCnt);
};
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 0a2a91a..91ae1d6 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -192,24 +192,24 @@ void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
for (size_t i=0; i < nCnt; ++i)
{
- SwFltStackEntry* pEntry = (*this)[ i ];
+ SwFltStackEntry& rEntry = maEntries[i];
if (
- (pEntry->m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
- (pEntry->m_aMkPos.m_nCntnt >= nPosCt)
+ (rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (rEntry.m_aMkPos.m_nCntnt >= nPosCt)
)
{
- pEntry->m_aMkPos.m_nCntnt++;
- OSL_ENSURE( pEntry->m_aMkPos.m_nCntnt
+ rEntry.m_aMkPos.m_nCntnt++;
+ OSL_ENSURE( rEntry.m_aMkPos.m_nCntnt
<= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
"Attribut-Anfang hinter Zeilenende" );
}
if (
- (pEntry->m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
- (pEntry->m_aPtPos.m_nCntnt >= nPosCt)
+ (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (rEntry.m_aPtPos.m_nCntnt >= nPosCt)
)
{
- pEntry->m_aPtPos.m_nCntnt++;
- OSL_ENSURE( pEntry->m_aPtPos.nCntnt
+ rEntry.m_aPtPos.m_nCntnt++;
+ OSL_ENSURE( rEntry.m_aPtPos.nCntnt
<= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
"Attribut-Ende hinter Zeilenende" );
}
@@ -220,7 +220,7 @@ void SwFltControlStack::MarkAllAttrsOld()
{
size_t nCnt = maEntries.size();
for (sal_uInt16 i=0; i < nCnt; ++i)
- (*this)[ i ]->bOld = sal_True;
+ maEntries[i].bOld = sal_True;
}
void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem & rAttr )
@@ -239,7 +239,6 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
if (nCnt < maEntries.size())
{
myEIter aElement = maEntries.begin() + nCnt;
- delete *aElement;
maEntries.erase(aElement);
}
}
@@ -256,9 +255,9 @@ void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId)
while (nCnt)
{
nCnt --;
- SwFltStackEntry* pEntry = (*this)[ nCnt ];
- if (pEntry->m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
- (!nAttrId || nAttrId == pEntry->pAttr->Which()))
+ SwFltStackEntry& rEntry = maEntries[nCnt];
+ if (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
+ (!nAttrId || nAttrId == rEntry.pAttr->Which()))
{
DeleteAndDestroy(nCnt); // loesche aus dem Stack
}
@@ -278,11 +277,11 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
while( nCnt )
{
nCnt --;
- SwFltStackEntry* pEntry = (*this)[ nCnt ];
- if( !pEntry->bOld
- && !pEntry->bLocked
- && (pEntry->m_aMkPos == aFltPos)
- && (pEntry->m_aPtPos == aFltPos))
+ SwFltStackEntry& rEntry = maEntries[nCnt];
+ if( !rEntry.bOld
+ && !rEntry.bLocked
+ && (rEntry.m_aMkPos == aFltPos)
+ && (rEntry.m_aPtPos == aFltPos))
{
DeleteAndDestroy( nCnt ); // loesche aus dem Stack
}
@@ -304,24 +303,25 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
size_t nCnt = maEntries.size();
for (size_t i=0; i < nCnt; ++i)
{
- SwFltStackEntry* pEntry = (*this)[i];
- if (pEntry->bLocked)
+ SwFltStackEntry& rEntry = maEntries[i];
+ if (rEntry.bLocked)
{
// setze das Ende vom Attribut
bool bF = false;
if (!nAttrId ){
bF = true;
- }else if( nAttrId == pEntry->pAttr->Which()){
+ }else if( nAttrId == rEntry.pAttr->Which()){
if( nAttrId != RES_FLTR_BOOKMARK ){ // Handle abfragen
bF = true;
- }else if( nHand == ((SwFltBookmark*)(pEntry->pAttr))->GetHandle() )
+ }else if( nHand == ((SwFltBookmark*)(rEntry.pAttr))->GetHandle() )
{
bF = true;
}
}
- if (bF) {
- pEntry->bConsumedByField = consumedByField;
- pEntry->SetEndPos(rPos);
+ if (bF)
+ {
+ rEntry.bConsumedByField = consumedByField;
+ rEntry.SetEndPos(rPos);
}
continue;
}
@@ -332,34 +332,35 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
// Beim Ende-Stack niemals ausser am DocEnde reinsetzen
if (bTstEnde)
{
- if (bIsEndStack || pEntry->m_aPtPos.m_nNode.GetIndex()+1 ==
+ if (bIsEndStack || rEntry.m_aPtPos.m_nNode.GetIndex()+1 ==
rPos.nNode.GetIndex())
continue;
}
- SetAttrInDoc(rPos, pEntry);
+ SetAttrInDoc(rPos, rEntry);
DeleteAndDestroy(i); // loesche aus dem Stack
i--; nCnt--; // Danach rutschen alle folgenden nach unten
}
}
-static void MakePoint(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPaM& rRegion)
+static void MakePoint(const SwFltStackEntry& rEntry, SwDoc* pDoc,
+ SwPaM& rRegion)
{
// der Anker ist der Point vom Pam. Dieser wird beim Einfugen von Text usw.
// veraendert; darum wird er auf dem Stack gespeichert. Das Attribut muss
// nur noch im Format gesetzt werden.
rRegion.DeleteMark();
- rRegion.GetPoint()->nNode = pEntry->m_aMkPos.m_nNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = rEntry.m_aMkPos.m_nNode.GetIndex() + 1;
SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
- rRegion.GetPoint()->nContent.Assign(pCNd, pEntry->m_aMkPos.m_nCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, rEntry.m_aMkPos.m_nCntnt);
}
// MakeBookRegionOrPoint() ist wie MakeRegionOrPoint, aber die besonderen
// Beschraenkungen von Bookmarks in Tabellen werden beachtet.
// ( Anfang und Ende muessen in selber Zelle sein )
-static void MakeBookRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc,
+static void MakeBookRegionOrPoint(const SwFltStackEntry& rEntry, SwDoc* pDoc,
SwPaM& rRegion, sal_Bool bCheck )
{
- if (pEntry->MakeRegion(pDoc, rRegion, bCheck )){
+ if (rEntry.MakeRegion(pDoc, rRegion, bCheck )){
// sal_Bool b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0;
if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode()
!= rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode())
@@ -368,7 +369,7 @@ static void MakeBookRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc,
rRegion.DeleteMark(); // -> beide auf Mark
}
}else{
- MakePoint(pEntry, pDoc, rRegion);
+ MakePoint(rEntry, pDoc, rRegion);
}
}
@@ -403,18 +404,19 @@ static sal_Bool IterateNumrulePiece( const SwNodeIndex& rEnd,
return rTmpStart <= rTmpEnd; // gueltig ?
}
-void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pEntry)
+void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
+ SwFltStackEntry& rEntry)
{
SwPaM aRegion( rTmpPos );
- switch(pEntry->pAttr->Which())
+ switch(rEntry.pAttr->Which())
{
case RES_FLTR_ANCHOR:
{
- SwFrmFmt* pFmt = ((SwFltAnchor*)pEntry->pAttr)->GetFrmFmt();
+ SwFrmFmt* pFmt = ((SwFltAnchor*)rEntry.pAttr)->GetFrmFmt();
if (pFmt != NULL)
{
- MakePoint(pEntry, pDoc, aRegion);
+ MakePoint(rEntry, pDoc, aRegion);
SwFmtAnchor aAnchor(pFmt->GetAnchor());
aAnchor.SetAnchor(aRegion.GetPoint());
pFmt->SetFmtAttr(aAnchor);
@@ -436,11 +438,11 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
break;
case RES_FLTR_NUMRULE: // Numrule 'reinsetzen
{
- const String& rNumNm = ((SfxStringItem*)pEntry->pAttr)->GetValue();
+ const String& rNumNm = ((SfxStringItem*)rEntry.pAttr)->GetValue();
SwNumRule* pRul = pDoc->FindNumRulePtr( rNumNm );
if( pRul )
{
- if( pEntry->MakeRegion(pDoc, aRegion, sal_True))
+ if( rEntry.MakeRegion(pDoc, aRegion, sal_True))
{
SwNodeIndex aTmpStart( aRegion.Start()->nNode );
SwNodeIndex aTmpEnd( aTmpStart );
@@ -465,15 +467,15 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
break;
case RES_FLTR_BOOKMARK: // eigentlich nur fuer den Ende-Stack
{
- SwFltBookmark* pB = (SwFltBookmark*)pEntry->pAttr;
- const String& rName = ((SwFltBookmark*)pEntry->pAttr)->GetName();
+ SwFltBookmark* pB = (SwFltBookmark*)rEntry.pAttr;
+ const String& rName = ((SwFltBookmark*)rEntry.pAttr)->GetName();
if (IsFlagSet(BOOK_TO_VAR_REF))
{
if (pB->IsPgRef() && !pB->IsRef())
{
// XRefs und Bookmarks sind bereits geUpcased
- MakeBookRegionOrPoint(pEntry, pDoc, aRegion, sal_True);
+ MakeBookRegionOrPoint(rEntry, pDoc, aRegion, sal_True);
pDoc->InsertPoolItem(aRegion, SwFmtRefMark(rName), 0);
}
else if( !pB->IsOnlyRef() )
@@ -487,26 +489,26 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
SwSetExpField aFld((SwSetExpFieldType*)pFT,
pB->GetValSys());
aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE );
- MakePoint(pEntry, pDoc, aRegion);
+ MakePoint(rEntry, pDoc, aRegion);
pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0);
MoveAttrs( *(aRegion.GetPoint()) );
}
}
if( !pB->IsOnlyRef() &&
- ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) && !pEntry->bConsumedByField)
+ ( !IsFlagSet(HYPO) || IsFlagSet(BOOK_AND_REF) ) && !rEntry.bConsumedByField)
{
- MakeBookRegionOrPoint(pEntry, pDoc, aRegion, sal_True);
+ MakeBookRegionOrPoint(rEntry, pDoc, aRegion, sal_True);
pDoc->getIDocumentMarkAccess()->makeMark( aRegion, rName, IDocumentMarkAccess::BOOKMARK);
}
}
break;
case RES_FLTR_TOX:
{
- MakePoint(pEntry, pDoc, aRegion);
+ MakePoint(rEntry, pDoc, aRegion);
SwPosition* pPoint = aRegion.GetPoint();
- SwFltTOX* pTOXAttr = (SwFltTOX*)pEntry->pAttr;
+ SwFltTOX* pTOXAttr = (SwFltTOX*)rEntry.pAttr;
// test if on this node there had been a pagebreak BEFORE the
// tox attribut was put on the stack
@@ -545,20 +547,20 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
}
break;
case RES_FLTR_SECTION:
- MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark
+ MakePoint(rEntry, pDoc, aRegion); // bislang immer Point==Mark
pDoc->InsertSwSection(aRegion,
- *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSectionData(),
+ *(static_cast<SwFltSection*>(rEntry.pAttr))->GetSectionData(),
0, 0, false);
- delete (((SwFltSection*)pEntry->pAttr)->GetSectionData());
+ delete (((SwFltSection*)rEntry.pAttr)->GetSectionData());
break;
case RES_FLTR_REDLINE:
{
- if (pEntry->MakeRegion(pDoc, aRegion, sal_True))
+ if (rEntry.MakeRegion(pDoc, aRegion, sal_True))
{
pDoc->SetRedlineMode((RedlineMode_t)( nsRedlineMode_t::REDLINE_ON
| nsRedlineMode_t::REDLINE_SHOW_INSERT
| nsRedlineMode_t::REDLINE_SHOW_DELETE ));
- SwFltRedline& rFltRedline = *((SwFltRedline*)pEntry->pAttr);
+ SwFltRedline& rFltRedline = *((SwFltRedline*)rEntry.pAttr);
if( USHRT_MAX != rFltRedline.nAutorNoPrev )
{
@@ -584,9 +586,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
}
break;
default:
- if (pEntry->MakeRegion(pDoc, aRegion, sal_False))
+ if (rEntry.MakeRegion(pDoc, aRegion, sal_False))
{
- pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0);
+ pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
}
break;
}
@@ -594,19 +596,18 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
SfxPoolItem* SwFltControlStack::GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
{
- SwFltStackEntry* pEntry;
size_t nSize = maEntries.size();
while (nSize)
{
// ist es das gesuchte Attribut ? (gueltig sind nur gelockte,
// also akt. gesetzte Attribute!!)
- if ((pEntry = (*this)[ --nSize ])->bLocked &&
- pEntry->pAttr->Which() == nWhich)
+ SwFltStackEntry &rEntry = maEntries[--nSize];
+ if (rEntry.bLocked && rEntry.pAttr->Which() == nWhich)
{
if (pPos)
*pPos = nSize;
- return (SfxPoolItem*)pEntry->pAttr; // Ok, dann Ende
+ return (SfxPoolItem*)rEntry.pAttr; // Ok, dann Ende
}
}
return 0;
@@ -645,27 +646,27 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
for (size_t nSize = maEntries.size(); nSize > 0;)
{
- SwFltStackEntry* pEntry = (*this)[--nSize];
+ SwFltStackEntry& rEntry = maEntries[--nSize];
bool bEntryStartAfterSelStart =
- (pEntry->m_aMkPos.m_nNode == aStartNode &&
- pEntry->m_aMkPos.m_nCntnt >= nStartIdx);
+ (rEntry.m_aMkPos.m_nNode == aStartNode &&
+ rEntry.m_aMkPos.m_nCntnt >= nStartIdx);
bool bEntryStartBeforeSelEnd =
- (pEntry->m_aMkPos.m_nNode == aEndNode &&
- pEntry->m_aMkPos.m_nCntnt <= nEndIdx);
+ (rEntry.m_aMkPos.m_nNode == aEndNode &&
+ rEntry.m_aMkPos.m_nCntnt <= nEndIdx);
bool bEntryEndAfterSelStart = false;
bool bEntryEndBeforeSelEnd = false;
- if (!pEntry->bLocked)
+ if (!rEntry.bLocked)
{
bEntryEndAfterSelStart =
- (pEntry->m_aPtPos.m_nNode == aStartNode &&
- pEntry->m_aPtPos.m_nCntnt >= nStartIdx);
+ (rEntry.m_aPtPos.m_nNode == aStartNode &&
+ rEntry.m_aPtPos.m_nCntnt >= nStartIdx);
bEntryEndBeforeSelEnd =
- (pEntry->m_aPtPos.m_nNode == aEndNode &&
- pEntry->m_aPtPos.m_nCntnt <= nEndIdx);
+ (rEntry.m_aPtPos.m_nNode == aEndNode &&
+ rEntry.m_aPtPos.m_nCntnt <= nEndIdx);
}
bool bTotallyContained = false;
@@ -692,23 +693,23 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
if (bEntryStartBeforeSelEnd)
{
//move start to new start
- pEntry->m_aMkPos.SetPos(aStartNode, nStartIdx);
+ rEntry.m_aMkPos.SetPos(aStartNode, nStartIdx);
}
else
- pEntry->m_aMkPos.m_nCntnt -= nCntntDiff;
+ rEntry.m_aMkPos.m_nCntnt -= nCntntDiff;
}
if (bEntryEndAfterSelStart)
{
if (bEntryEndBeforeSelEnd)
- pEntry->m_aPtPos.SetPos(aStartNode, nStartIdx);
+ rEntry.m_aPtPos.SetPos(aStartNode, nStartIdx);
else
- pEntry->m_aPtPos.m_nCntnt -= nCntntDiff;
+ rEntry.m_aPtPos.m_nCntnt -= nCntntDiff;
}
//That's what locked is, end equal to start, and nPtCntnt is invalid
- if (pEntry->bLocked)
- pEntry->m_aPtPos = pEntry->m_aMkPos;
+ if (rEntry.bLocked)
+ rEntry.m_aPtPos = rEntry.m_aMkPos;
}
}
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 0925c1d..7963f0e 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -691,7 +691,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
String sURL;
for (size_t nI = pCtrlStck->size(); nI > nCount; --nI)
{
- const SfxPoolItem *pItem = ((*pCtrlStck)[nI-1])->pAttr;
+ const SfxPoolItem *pItem = ((*pCtrlStck)[nI-1]).pAttr;
sal_uInt16 nWhich = pItem->Which();
if (nWhich == RES_TXTATR_INETFMT)
{
@@ -727,7 +727,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
{
for (size_t i = nCurrentCount; i < pCtrlStck->size(); ++i)
{
- const SfxPoolItem *pItem = ((*pCtrlStck)[i])->pAttr;
+ const SfxPoolItem *pItem = ((*pCtrlStck)[i]).pAttr;
sal_uInt16 nWhich = pItem->Which();
if( nWhich < RES_FLTRATTR_BEGIN ||
nWhich >= RES_FLTRATTR_END )
@@ -3060,9 +3060,9 @@ void SwWW8FltAnchorStack::Flush()
size_t nCnt = size();
for (size_t i=0; i < nCnt; ++i)
{
- SwFltStackEntry *pEntry = (*this)[i];
- SwPosition aDummy(pEntry->m_aMkPos.m_nNode);
- SetAttrInDoc(aDummy, pEntry);
+ SwFltStackEntry &rEntry = (*this)[i];
+ SwPosition aDummy(rEntry.m_aMkPos.m_nNode);
+ SetAttrInDoc(aDummy, rEntry);
DeleteAndDestroy(i--);
--nCnt;
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index efb9726..c2e417b 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -993,8 +993,8 @@ void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
size_t nCnt = size();
for (size_t i=0; i < nCnt; ++i)
{
- SwFltStackEntry* pEntry = (*this)[i];
- if (nAttrId == pEntry->pAttr->Which())
+ SwFltStackEntry& rEntry = (*this)[i];
+ if (nAttrId == rEntry.pAttr->Which())
{
DeleteAndDestroy(i--);
--nCnt;
@@ -1086,9 +1086,9 @@ const SwNumFmt* SwWW8FltControlStack::GetNumFmtFromStack(const SwPosition &rPos,
}
void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
- SwFltStackEntry* pEntry)
+ SwFltStackEntry& rEntry)
{
- switch( pEntry->pAttr->Which() )
+ switch (rEntry.pAttr->Which())
{
case RES_LR_SPACE:
{
@@ -1101,9 +1101,9 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
*/
using namespace sw::util;
SwPaM aRegion(rTmpPos);
- if (pEntry->MakeRegion(pDoc, aRegion, false))
+ if (rEntry.MakeRegion(pDoc, aRegion, false))
{
- SvxLRSpaceItem aNewLR( *(SvxLRSpaceItem*)pEntry->pAttr );
+ SvxLRSpaceItem aNewLR( *(SvxLRSpaceItem*)rEntry.pAttr );
sal_uLong nStart = aRegion.Start()->nNode.GetIndex();
sal_uLong nEnd = aRegion.End()->nNode.GetIndex();
for(; nStart <= nEnd; ++nStart)
@@ -1157,7 +1157,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_TXTATR_INETFMT:
{
SwPaM aRegion(rTmpPos);
- if (pEntry->MakeRegion(pDoc, aRegion, false))
+ if (rEntry.MakeRegion(pDoc, aRegion, false))
{
SwFrmFmt *pFrm;
//If we have just one single inline graphic then
@@ -1166,7 +1166,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
if (0 != (pFrm = rReader.ContainsSingleInlineGraphic(aRegion)))
{
const SwFmtINetFmt *pAttr = (const SwFmtINetFmt *)
- pEntry->pAttr;
+ rEntry.pAttr;
SwFmtURL aURL;
aURL.SetURL(pAttr->GetValue(), false);
aURL.SetTargetFrameName(pAttr->GetTargetFrame());
@@ -1174,13 +1174,13 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
else
{
- pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0);
+ pDoc->InsertPoolItem(aRegion, *rEntry.pAttr, 0);
}
}
}
break;
default:
- SwFltControlStack::SetAttrInDoc(rTmpPos, pEntry);
+ SwFltControlStack::SetAttrInDoc(rTmpPos, rEntry);
break;
}
}
@@ -1238,15 +1238,15 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
size_t nSize = size();
while (nSize)
{
- const SwFltStackEntry* pEntry = (*this)[ --nSize ];
- if (pEntry->pAttr->Which() == nWhich)
+ const SwFltStackEntry& rEntry = (*this)[ --nSize ];
+ if (rEntry.pAttr->Which() == nWhich)
{
- if ( (pEntry->bLocked) ||
+ if ( (rEntry.bLocked) ||
(
- (pEntry->m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
- (pEntry->m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
- (pEntry->m_aMkPos.m_nCntnt <= aFltPos.m_nCntnt) &&
- (pEntry->m_aPtPos.m_nCntnt > aFltPos.m_nCntnt)
+ (rEntry.m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
+ (rEntry.m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
+ (rEntry.m_aMkPos.m_nCntnt <= aFltPos.m_nCntnt) &&
+ (rEntry.m_aPtPos.m_nCntnt > aFltPos.m_nCntnt)
)
)
/*
@@ -1254,7 +1254,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
* means props that end at 3 are not included
*/
{
- return pEntry->pAttr;
+ return rEntry.pAttr;
}
}
}
@@ -1283,9 +1283,9 @@ bool SwWW8FltRefStack::IsFtnEdnBkmField(const SwFmtFld& rFmtFld, sal_uInt16& rBk
}
void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
- SwFltStackEntry* pEntry)
+ SwFltStackEntry& rEntry)
{
- switch( pEntry->pAttr->Which() )
+ switch (rEntry.pAttr->Which())
{
/*
Look up these in our lists of bookmarks that were changed to
@@ -1294,14 +1294,14 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
*/
case RES_TXTATR_FIELD:
{
- SwNodeIndex aIdx(pEntry->m_aMkPos.m_nNode, 1);
- SwPaM aPaM(aIdx, pEntry->m_aMkPos.m_nCntnt);
+ SwNodeIndex aIdx(rEntry.m_aMkPos.m_nNode, 1);
+ SwPaM aPaM(aIdx, rEntry.m_aMkPos.m_nCntnt);
- SwFmtFld& rFmtFld = *(SwFmtFld*)pEntry->pAttr;
+ SwFmtFld& rFmtFld = *(SwFmtFld*)rEntry.pAttr;
SwField* pFld = rFmtFld.GetFld();
// <NOT> got lost from revision 1.128 to 1.129
- if (!RefToVar(pFld,pEntry))
+ if (!RefToVar(pFld, rEntry))
{
sal_uInt16 nBkmNo;
if( IsFtnEdnBkmField(rFmtFld, nBkmNo) )
@@ -1328,17 +1328,17 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
}
}
- pDoc->InsertPoolItem(aPaM, *pEntry->pAttr, 0);
+ pDoc->InsertPoolItem(aPaM, *rEntry.pAttr, 0);
MoveAttrs(*aPaM.GetPoint());
}
break;
case RES_FLTR_TOX:
- SwFltEndStack::SetAttrInDoc(rTmpPos, pEntry);
+ SwFltEndStack::SetAttrInDoc(rTmpPos, rEntry);
break;
default:
case RES_FLTR_BOOKMARK:
OSL_ENSURE(!this, "EndStck used with non field, not what we want");
- SwFltEndStack::SetAttrInDoc(rTmpPos, pEntry);
+ SwFltEndStack::SetAttrInDoc(rTmpPos, rEntry);
break;
}
}
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 2cbdc92..5cce4d0 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -367,7 +367,7 @@ private:
const SwTxtNode &rTxtNode);
protected:
virtual void SetAttrInDoc(const SwPosition& rTmpPos,
- SwFltStackEntry* pEntry);
+ SwFltStackEntry& rEntry);
public:
SwWW8FltControlStack(SwDoc* pDo, sal_uLong nFieldFl, SwWW8ImplReader& rReader_ )
@@ -457,9 +457,9 @@ public:
//an additional pseudo bookmark
std::map<String, String, ltstr> aFieldVarNames;
protected:
- SwFltStackEntry *RefToVar(const SwField* pFld,SwFltStackEntry *pEntry);
+ SwFltStackEntry *RefToVar(const SwField* pFld,SwFltStackEntry& rEntry);
virtual void SetAttrInDoc(const SwPosition& rTmpPos,
- SwFltStackEntry* pEntry);
+ SwFltStackEntry& rEntry);
private:
//No copying
SwWW8FltRefStack(const SwWW8FltRefStack&);
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 462f82b..759293d 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -1419,7 +1419,7 @@ of a set or ask field, either by word, or in some special cases by the import
filter itself.
*/
SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pFld,
- SwFltStackEntry *pEntry)
+ SwFltStackEntry &rEntry)
{
SwFltStackEntry *pRet=0;
if (pFld && RES_GETREFFLD == pFld->Which())
@@ -1433,10 +1433,10 @@ SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pFld,
{
SwGetExpField aFld( (SwGetExpFieldType*)
pDoc->GetSysFldType(RES_GETEXPFLD), rName, nsSwGetSetExpType::GSE_STRING, 0);
- delete pEntry->pAttr;
+ delete rEntry.pAttr;
SwFmtFld aTmp(aFld);
- pEntry->pAttr = aTmp.Clone();
- pRet = pEntry;
+ rEntry.pAttr = aTmp.Clone();
+ pRet = &rEntry;
}
}
return pRet;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 50a94ef..e3d23f7 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2186,17 +2186,17 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk)
size_t nCnt = pCtrlStck->size();
for (size_t i=0; i < nCnt; ++i)
{
- const SwFltStackEntry* pEntry = (*pCtrlStck)[ i ];
- if(pEntry->bLocked)
+ const SwFltStackEntry& rEntry = (*pCtrlStck)[ i ];
+ if (rEntry.bLocked)
{
- if (isCHRATR(pEntry->pAttr->Which()))
+ if (isCHRATR(rEntry.pAttr->Which()))
{
- aChrSet.Put( *pEntry->pAttr );
+ aChrSet.Put( *rEntry.pAttr );
}
- else if (isPARATR(pEntry->pAttr->Which()))
+ else if (isPARATR(rEntry.pAttr->Which()))
{
- aParSet.Put( *pEntry->pAttr );
+ aParSet.Put( *rEntry.pAttr );
}
}
}
@@ -3171,7 +3171,7 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement()
{
SwPaM aRegion(*pPaM->GetPoint());
- SwFltPosition aMkPos((*pCtrlStck)[nPos]->m_aMkPos);
+ SwFltPosition aMkPos((*pCtrlStck)[nPos].m_aMkPos);
SwFltPosition aPtPos(*pPaM->GetPoint());
SwFrmFmt *pFlyFmt = 0;
commit 1f63081939a2a6abe5c6c91f93fdf4b3e01e3efc
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jun 26 22:55:54 2011 +0100
drop dubious copy ctor and use boost::noncopyable
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 3cd951e..f04b289 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -43,6 +43,8 @@
#include <pam.hxx>
#include <IDocumentRedlineAccess.hxx>
+#include <boost/noncopyable.hpp>
+
class SwTOXBase;
class SwFltShell;
class SwField;
@@ -107,7 +109,7 @@ public:
};
// Stack-Eintrag fuer die Attribute Es werden immer Pointer auf neue Attribute uebergeben.
-class SwFltStackEntry
+class SwFltStackEntry : private ::boost::noncopyable
{
public:
SwFltPosition m_aMkPos;
@@ -121,7 +123,6 @@ public:
sal_Bool bConsumedByField;
SW_DLLPUBLIC SwFltStackEntry(const SwPosition & rStartPos, SfxPoolItem* pHt );
- SW_DLLPUBLIC SwFltStackEntry(const SwFltStackEntry& rEntry);
SW_DLLPUBLIC ~SwFltStackEntry();
void SetStartPos(const SwPosition & rStartPos);
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 3c4ac40..0a2a91a 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -102,17 +102,6 @@ SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
bConsumedByField = sal_False;
}
-SwFltStackEntry::SwFltStackEntry(const SwFltStackEntry& rEntry)
- : m_aMkPos(rEntry.m_aMkPos)
- , m_aPtPos(rEntry.m_aPtPos)
-{
- pAttr = rEntry.pAttr->Clone();
- bOld = rEntry.bOld;
- bLocked = bCopied = sal_True; // when rEntry were NOT bLocked we would never have been called
- bConsumedByField = rEntry.bConsumedByField;
-}
-
-
SwFltStackEntry::~SwFltStackEntry()
{
// Attribut kam zwar als Pointer, wird aber hier geloescht
commit 836aab886dfa5c611d58aca37dbe529ff2b5d8e6
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jun 26 22:50:46 2011 +0100
refactor MakeRegion so we can avoid dubious copy ctor
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index fb7e6e1..3cd951e 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -127,6 +127,9 @@ public:
void SetStartPos(const SwPosition & rStartPos);
SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
SW_DLLPUBLIC bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const;
+ SW_DLLPUBLIC static bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion,
+ bool bCheck, const SwFltPosition &rMkPos, const SwFltPosition &rPtPos,
+ sal_uInt16 nWhich=0);
};
class SW_DLLPUBLIC SwFltControlStack
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 0f045fa..3c4ac40 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -131,31 +131,33 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
m_aPtPos.SetPos(rEndPos);
}
-bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
+bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck,
+ const SwFltPosition &rMkPos, const SwFltPosition &rPtPos,
+ sal_uInt16 nWhich)
{
// does this range actually contain something?
// empty range is allowed if at start of empty paragraph
// fields are special: never have range, so leave them
SwCntntNode *const pCntntNode(
- SwNodeIndex(m_aMkPos.m_nNode, +1).GetNode().GetCntntNode());
- if (m_aMkPos == m_aPtPos &&
- ((0 != m_aPtPos.m_nCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
- && (RES_TXTATR_FIELD != pAttr->Which()))
+ SwNodeIndex(rMkPos.m_nNode, +1).GetNode().GetCntntNode());
+ if (rMkPos == rPtPos &&
+ ((0 != rPtPos.m_nCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
+ && (RES_TXTATR_FIELD != nWhich))
{
return false;
}
// !!! Die Content-Indizies beziehen sich immer auf den Node !!!
- rRegion.GetPoint()->nNode = m_aMkPos.m_nNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = rMkPos.m_nNode.GetIndex() + 1;
SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
- rRegion.GetPoint()->nContent.Assign(pCNd, m_aMkPos.m_nCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, rMkPos.m_nCntnt);
rRegion.SetMark();
- if (m_aMkPos.m_nNode != m_aPtPos.m_nNode)
+ if (rMkPos.m_nNode != rPtPos.m_nNode)
{
- rRegion.GetPoint()->nNode = m_aPtPos.m_nNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = rPtPos.m_nNode.GetIndex() + 1;
pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_False);
}
- rRegion.GetPoint()->nContent.Assign(pCNd, m_aPtPos.m_nCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, rPtPos.m_nCntnt);
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( CheckNodesRange( rRegion.Start()->nNode,
rRegion.End()->nNode, sal_True ),
@@ -168,6 +170,12 @@ bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
return true;
}
+bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
+{
+ return MakeRegion(pDoc, rRegion, bCheck, m_aMkPos, m_aPtPos,
+ pAttr->Which());
+}
+
SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
: nFieldFlags(nFieldFl), pDoc(pDo), bIsEndStack(false)
{
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 3109298..50a94ef 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3171,12 +3171,12 @@ bool SwWW8ImplReader::ConvertSubToGraphicPlacement()
{
SwPaM aRegion(*pPaM->GetPoint());
- SwFltStackEntry aEntry = *((*pCtrlStck)[nPos]);
- aEntry.SetEndPos(*pPaM->GetPoint());
+ SwFltPosition aMkPos((*pCtrlStck)[nPos]->m_aMkPos);
+ SwFltPosition aPtPos(*pPaM->GetPoint());
SwFrmFmt *pFlyFmt = 0;
if (
- aEntry.MakeRegion(&rDoc,aRegion,false) &&
+ SwFltStackEntry::MakeRegion(&rDoc,aRegion,false,aMkPos,aPtPos) &&
0 != (pFlyFmt = ContainsSingleInlineGraphic(aRegion))
)
{
commit a21c96d1acc048817c8a9212fb7f205f942a47d1
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jun 26 22:35:41 2011 +0100
refactor part of SwFltStackEntry into SwFltPosition
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index e17a5f5..fb7e6e1 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -40,6 +40,7 @@
#include <poolfmt.hxx>
#include <fmtornt.hxx>
#include <ndindex.hxx>
+#include <pam.hxx>
#include <IDocumentRedlineAccess.hxx>
class SwTOXBase;
@@ -62,15 +63,57 @@ inline void SwFltSetFlag(sal_uLong& rFieldFlags, int no)
inline sal_Bool SwFltGetFlag(sal_uLong nFieldFlags, int no)
{ return (nFieldFlags & (1L << no)) != 0; }
+//Subvert the Node/Content system to get positions which don't update as
+//content is appended to them
+struct SW_DLLPUBLIC SwFltPosition
+{
+public:
+ SwNodeIndex m_nNode;
+ xub_StrLen m_nCntnt;
+public:
+ SwFltPosition(const SwFltPosition &rOther)
+ : m_nNode(rOther.m_nNode)
+ , m_nCntnt(rOther.m_nCntnt)
+ {
+ }
+ SwFltPosition &operator=(const SwFltPosition &rOther)
+ {
+ m_nNode = rOther.m_nNode;
+ m_nCntnt = rOther.m_nCntnt;
+ return *this;
+ }
+ bool operator==(const SwFltPosition &rOther) const
+ {
+ return (m_nCntnt == rOther.m_nCntnt &&
+ m_nNode == rOther.m_nNode);
+ }
+ void SetPos(SwNodeIndex &rNode, sal_uInt16 nIdx)
+ {
+ m_nNode = rNode;
+ m_nCntnt = nIdx;
+ }
+ //operators with SwPosition, where the node is hacked to the previous one,
+ //and the offset to content is de-dynamic-ified
+ SwFltPosition(const SwPosition &rPos)
+ : m_nNode(rPos.nNode, -1)
+ , m_nCntnt(rPos.nContent.GetIndex())
+ {
+ }
+ void SetPos(const SwPosition &rPos)
+ {
+ m_nNode = rPos.nNode.GetIndex()-1;
+ m_nCntnt = rPos.nContent.GetIndex();
+ }
+};
+
// Stack-Eintrag fuer die Attribute Es werden immer Pointer auf neue Attribute uebergeben.
class SwFltStackEntry
{
public:
- SwNodeIndex nMkNode;
- SwNodeIndex nPtNode;
+ SwFltPosition m_aMkPos;
+ SwFltPosition m_aPtPos;
+
SfxPoolItem * pAttr;// Format Attribute
- xub_StrLen nMkCntnt;// Nachbildung von Mark()
- xub_StrLen nPtCntnt;// Nachbildung von GetPoint()
sal_Bool bOld; // to mark Attributes *before* skipping field results
sal_Bool bLocked;
@@ -126,7 +169,7 @@ public:
virtual void SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId=0, sal_Bool bTstEnde=sal_True, long nHand = LONG_MAX, sal_Bool consumedByField=sal_False);
- void StealAttr(const SwPosition* pPos, sal_uInt16 nAttrId = 0);
+ void StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId = 0);
void MarkAllAttrsOld();
void KillUnlockedAttrs(const SwPosition& pPos);
SfxPoolItem* GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos = 0);
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 9981c86..0f045fa 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -91,12 +91,10 @@ static SwCntntNode* GetCntntNode(SwDoc* pDoc, SwNodeIndex& rIdx, sal_Bool bNext)
}
// ------ Stack-Eintrag fuer die gesamten - Attribute vom Text -----------
-SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt ) :
- nMkNode(rStartPos.nNode, -1),
- nPtNode(nMkNode)
+SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
+ : m_aMkPos(rStartPos)
+ , m_aPtPos(rStartPos)
{
- // Anfang vom Bereich merken
- nMkCntnt = rStartPos.nContent.GetIndex();
pAttr = pHt; // speicher eine Kopie vom Attribut
bOld = sal_False; // used for marking Attributes *before* skipping field results
bLocked = sal_True; // locke das Attribut --> darf erst
@@ -104,12 +102,11 @@ SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt )
bConsumedByField = sal_False;
}
-SwFltStackEntry::SwFltStackEntry(const SwFltStackEntry& rEntry) :
- nMkNode(rEntry.nMkNode),
- nPtNode(rEntry.nPtNode)
+SwFltStackEntry::SwFltStackEntry(const SwFltStackEntry& rEntry)
+ : m_aMkPos(rEntry.m_aMkPos)
+ , m_aPtPos(rEntry.m_aPtPos)
{
- pAttr = rEntry.pAttr->Clone();
- nMkCntnt= rEntry.nMkCntnt;
+ pAttr = rEntry.pAttr->Clone();
bOld = rEntry.bOld;
bLocked = bCopied = sal_True; // when rEntry were NOT bLocked we would never have been called
bConsumedByField = rEntry.bConsumedByField;
@@ -131,8 +128,7 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
// verschoben wird.
// Das ist aber nicht das gewollte!
bLocked = sal_False; // freigeben und das ENDE merken
- nPtNode = rEndPos.nNode.GetIndex()-1;
- nPtCntnt = rEndPos.nContent.GetIndex();
+ m_aPtPos.SetPos(rEndPos);
}
bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
@@ -141,25 +137,25 @@ bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
// empty range is allowed if at start of empty paragraph
// fields are special: never have range, so leave them
SwCntntNode *const pCntntNode(
- SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode());
- if ((nMkNode.GetIndex() == nPtNode.GetIndex()) && (nMkCntnt == nPtCntnt)
- && ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
+ SwNodeIndex(m_aMkPos.m_nNode, +1).GetNode().GetCntntNode());
+ if (m_aMkPos == m_aPtPos &&
+ ((0 != m_aPtPos.m_nCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
&& (RES_TXTATR_FIELD != pAttr->Which()))
{
return false;
}
// !!! Die Content-Indizies beziehen sich immer auf den Node !!!
- rRegion.GetPoint()->nNode = nMkNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = m_aMkPos.m_nNode.GetIndex() + 1;
SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
- rRegion.GetPoint()->nContent.Assign(pCNd, nMkCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, m_aMkPos.m_nCntnt);
rRegion.SetMark();
- if( nMkNode != nPtNode )
+ if (m_aMkPos.m_nNode != m_aPtPos.m_nNode)
{
- rRegion.GetPoint()->nNode = nPtNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = m_aPtPos.m_nNode.GetIndex() + 1;
pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_False);
}
- rRegion.GetPoint()->nContent.Assign(pCNd, nPtCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, m_aPtPos.m_nCntnt);
#if OSL_DEBUG_LEVEL > 1
OSL_ENSURE( CheckNodesRange( rRegion.Start()->nNode,
rRegion.End()->nNode, sal_True ),
@@ -194,24 +190,29 @@ SwFltControlStack::~SwFltControlStack()
void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
{
size_t nCnt = maEntries.size();
- SwFltStackEntry* pEntry;
sal_uLong nPosNd = rPos.nNode.GetIndex();
sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
for (size_t i=0; i < nCnt; ++i)
{
- pEntry = (*this)[ i ];
- if(( pEntry->nMkNode.GetIndex() + 1 == nPosNd )
- &&( pEntry->nMkCntnt >= nPosCt )){
- pEntry->nMkCntnt++;
- OSL_ENSURE( pEntry->nMkCntnt
+ SwFltStackEntry* pEntry = (*this)[ i ];
+ if (
+ (pEntry->m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (pEntry->m_aMkPos.m_nCntnt >= nPosCt)
+ )
+ {
+ pEntry->m_aMkPos.m_nCntnt++;
+ OSL_ENSURE( pEntry->m_aMkPos.m_nCntnt
<= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
"Attribut-Anfang hinter Zeilenende" );
}
- if(( pEntry->nPtNode.GetIndex() + 1 == nPosNd )
- &&( pEntry->nPtCntnt >= nPosCt )){
- pEntry->nPtCntnt++;
- OSL_ENSURE( pEntry->nPtCntnt
+ if (
+ (pEntry->m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
+ (pEntry->m_aPtPos.m_nCntnt >= nPosCt)
+ )
+ {
+ pEntry->m_aPtPos.m_nCntnt++;
+ OSL_ENSURE( pEntry->m_aPtPos.nCntnt
<= pDoc->GetNodes()[nPosNd]->GetCntntNode()->Len(),
"Attribut-Ende hinter Zeilenende" );
}
@@ -249,9 +250,9 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
// SwFltControlStack::StealAttr() loescht Attribute des angegebenen Typs vom Stack.
// Als nAttrId sind erlaubt: 0 fuer alle, oder ein spezieller Typ.
// Damit erscheinen sie nicht in der Doc-Struktur. Dabei werden nur die
-// Attribute entfernt, die im selben Absatz wie pPos stehen.
+// Attribute entfernt, die im selben Absatz wie rPos stehen.
// Wird fuer Grafik-Apos -> Grafiken benutzt.
-void SwFltControlStack::StealAttr(const SwPosition* pPos, sal_uInt16 nAttrId /* = 0 */)
+void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId)
{
size_t nCnt = maEntries.size();
@@ -259,21 +260,22 @@ void SwFltControlStack::StealAttr(const SwPosition* pPos, sal_uInt16 nAttrId /*
{
nCnt --;
SwFltStackEntry* pEntry = (*this)[ nCnt ];
- if (pEntry->nPtNode.GetIndex()+1 == pPos->nNode.GetIndex() &&
+ if (pEntry->m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
(!nAttrId || nAttrId == pEntry->pAttr->Which()))
+ {
DeleteAndDestroy(nCnt); // loesche aus dem Stack
+ }
}
}
// SwFltControlStack::KillUnlockedAttr() loescht alle Attribute vom Stack,
-// welche punktuell auf pPos aufgespannt sind.
+// welche punktuell auf rPos aufgespannt sind.
// Damit erscheinen sie nicht in der Doc-Struktur.
// Wird im WW Import benoetigt zum ignorieren der auf dem 0x0c Section-
// Break-Symbol gesetzten Attribute.
-void SwFltControlStack::KillUnlockedAttrs(const SwPosition& pPos)
+void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
{
- SwNodeIndex aAktNode( pPos.nNode, -1 );
- sal_uInt16 nAktIdx = pPos.nContent.GetIndex();
+ SwFltPosition aFltPos(rPos);
size_t nCnt = maEntries.size();
while( nCnt )
@@ -282,10 +284,8 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& pPos)
SwFltStackEntry* pEntry = (*this)[ nCnt ];
if( !pEntry->bOld
&& !pEntry->bLocked
- && (pEntry->nMkNode == aAktNode)
- && (pEntry->nMkCntnt == nAktIdx )
- && (pEntry->nPtNode == aAktNode)
- && (pEntry->nPtCntnt == nAktIdx ))
+ && (pEntry->m_aMkPos == aFltPos)
+ && (pEntry->m_aPtPos == aFltPos))
{
DeleteAndDestroy( nCnt ); // loesche aus dem Stack
}
@@ -335,7 +335,7 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
// Beim Ende-Stack niemals ausser am DocEnde reinsetzen
if (bTstEnde)
{
- if (bIsEndStack || pEntry->nPtNode.GetIndex()+1 ==
+ if (bIsEndStack || pEntry->m_aPtPos.m_nNode.GetIndex()+1 ==
rPos.nNode.GetIndex())
continue;
}
@@ -347,14 +347,13 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
static void MakePoint(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPaM& rRegion)
{
- // der Anker ist der Point vom Pam. Dieser wird beim Einfugen
- // von Text usw. veraendert; darum wird er auf dem Stack
- // gespeichert. Das Attribut muss nur noch im Format
- // gesetzt werden.
+ // der Anker ist der Point vom Pam. Dieser wird beim Einfugen von Text usw.
+ // veraendert; darum wird er auf dem Stack gespeichert. Das Attribut muss
+ // nur noch im Format gesetzt werden.
rRegion.DeleteMark();
- rRegion.GetPoint()->nNode = pEntry->nMkNode.GetIndex() + 1;
+ rRegion.GetPoint()->nNode = pEntry->m_aMkPos.m_nNode.GetIndex() + 1;
SwCntntNode* pCNd = GetCntntNode(pDoc, rRegion.GetPoint()->nNode, sal_True);
- rRegion.GetPoint()->nContent.Assign(pCNd, pEntry->nMkCntnt);
+ rRegion.GetPoint()->nContent.Assign(pCNd, pEntry->m_aMkPos.m_nCntnt);
}
// MakeBookRegionOrPoint() ist wie MakeRegionOrPoint, aber die besonderen
@@ -652,20 +651,24 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
SwFltStackEntry* pEntry = (*this)[--nSize];
bool bEntryStartAfterSelStart =
- (pEntry->nMkNode == aStartNode && pEntry->nMkCntnt >= nStartIdx);
+ (pEntry->m_aMkPos.m_nNode == aStartNode &&
+ pEntry->m_aMkPos.m_nCntnt >= nStartIdx);
bool bEntryStartBeforeSelEnd =
- (pEntry->nMkNode == aEndNode && pEntry->nMkCntnt <= nEndIdx);
+ (pEntry->m_aMkPos.m_nNode == aEndNode &&
+ pEntry->m_aMkPos.m_nCntnt <= nEndIdx);
bool bEntryEndAfterSelStart = false;
bool bEntryEndBeforeSelEnd = false;
if (!pEntry->bLocked)
{
bEntryEndAfterSelStart =
- (pEntry->nPtNode == aStartNode && pEntry->nPtCntnt >= nStartIdx);
+ (pEntry->m_aPtPos.m_nNode == aStartNode &&
+ pEntry->m_aPtPos.m_nCntnt >= nStartIdx);
bEntryEndBeforeSelEnd =
- (pEntry->nPtNode == aEndNode && pEntry->nPtCntnt <= nEndIdx);
+ (pEntry->m_aPtPos.m_nNode == aEndNode &&
+ pEntry->m_aPtPos.m_nCntnt <= nEndIdx);
}
bool bTotallyContained = false;
@@ -692,27 +695,23 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
if (bEntryStartBeforeSelEnd)
{
//move start to new start
- pEntry->nMkNode = aStartNode;
- pEntry->nMkCntnt = nStartIdx;
+ pEntry->m_aMkPos.SetPos(aStartNode, nStartIdx);
}
else
- pEntry->nMkCntnt = pEntry->nMkCntnt - nCntntDiff;
+ pEntry->m_aMkPos.m_nCntnt -= nCntntDiff;
}
if (bEntryEndAfterSelStart)
{
if (bEntryEndBeforeSelEnd)
- {
- pEntry->nPtNode = aStartNode;
- pEntry->nPtCntnt = nStartIdx;
- }
+ pEntry->m_aPtPos.SetPos(aStartNode, nStartIdx);
else
- pEntry->nPtCntnt = pEntry->nPtCntnt - nCntntDiff;
+ pEntry->m_aPtPos.m_nCntnt -= nCntntDiff;
}
//That's what locked is, end equal to start, and nPtCntnt is invalid
if (pEntry->bLocked)
- pEntry->nPtNode = pEntry->nMkNode;
+ pEntry->m_aPtPos = pEntry->m_aMkPos;
}
}
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 8060bb6..5f705e1 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -706,7 +706,7 @@ namespace sw
void SetInDocAndDelete::operator()(SwFltStackEntry *pEntry)
{
- SwPaM aRegion(pEntry->nMkNode);
+ SwPaM aRegion(pEntry->m_aMkPos.m_nNode);
if (
pEntry->MakeRegion(&mrDoc, aRegion, true) &&
(*aRegion.GetPoint() != *aRegion.GetMark())
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 3ba892c..0925c1d 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -3061,8 +3061,8 @@ void SwWW8FltAnchorStack::Flush()
for (size_t i=0; i < nCnt; ++i)
{
SwFltStackEntry *pEntry = (*this)[i];
- SwPosition aDummy(pEntry->nMkNode);
- SetAttrInDoc(aDummy,pEntry);
+ SwPosition aDummy(pEntry->m_aMkPos.m_nNode);
+ SetAttrInDoc(aDummy, pEntry);
DeleteAndDestroy(i--);
--nCnt;
}
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 5d82f00..efb9726 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1233,8 +1233,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetFmtAttr(const SwPosition& rPos,
const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
sal_uInt16 nWhich)
{
- SwNodeIndex aNode( rPos.nNode, -1 );
- sal_uInt16 nIdx = rPos.nContent.GetIndex();
+ SwFltPosition aFltPos(rPos);
size_t nSize = size();
while (nSize)
@@ -1242,15 +1241,20 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
const SwFltStackEntry* pEntry = (*this)[ --nSize ];
if (pEntry->pAttr->Which() == nWhich)
{
- if ( (pEntry->bLocked) || (
- (pEntry->nMkNode <= aNode) && (pEntry->nPtNode >= aNode) &&
- (pEntry->nMkCntnt <= nIdx) && (pEntry->nPtCntnt > nIdx) ) )
+ if ( (pEntry->bLocked) ||
+ (
+ (pEntry->m_aMkPos.m_nNode <= aFltPos.m_nNode) &&
+ (pEntry->m_aPtPos.m_nNode >= aFltPos.m_nNode) &&
+ (pEntry->m_aMkPos.m_nCntnt <= aFltPos.m_nCntnt) &&
+ (pEntry->m_aPtPos.m_nCntnt > aFltPos.m_nCntnt)
+ )
+ )
/*
* e.g. half-open range [0-3) so asking for properties at 3
* means props that end at 3 are not included
*/
{
- return (const SfxPoolItem*)pEntry->pAttr;
+ return pEntry->pAttr;
}
}
}
@@ -1290,8 +1294,8 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
*/
case RES_TXTATR_FIELD:
{
- SwNodeIndex aIdx(pEntry->nMkNode, 1);
- SwPaM aPaM(aIdx, pEntry->nMkCntnt);
+ SwNodeIndex aIdx(pEntry->m_aMkPos.m_nNode, 1);
+ SwPaM aPaM(aIdx, pEntry->m_aMkPos.m_nCntnt);
SwFmtFld& rFmtFld = *(SwFmtFld*)pEntry->pAttr;
SwField* pFld = rFmtFld.GetFld();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 89ee0bf..3109298 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2440,7 +2440,7 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr)
rPam.GetPoint()->nNode = aPref;
rPam.GetPoint()->nContent.Assign(pNode, pNode->GetTxt().Len());
if (bStealAttr)
- pCtrlStck->StealAttr(rPam.GetPoint());
+ pCtrlStck->StealAttr(rPam.GetPoint()->nNode);
pNode->JoinNext();
commit e2e3ef2c18588408a9be7cf275087d45b44f9970
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jun 26 21:07:35 2011 +0100
nHandle unused
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 061a98e..e17a5f5 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -69,7 +69,6 @@ public:
SwNodeIndex nMkNode;
SwNodeIndex nPtNode;
SfxPoolItem * pAttr;// Format Attribute
- long nHandle; // fuer verschachtelte Attrs, z.B. Bookmarks
xub_StrLen nMkCntnt;// Nachbildung von Mark()
xub_StrLen nPtCntnt;// Nachbildung von GetPoint()
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 8be6e3c..5d82f00 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2868,9 +2868,6 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const rtl::OUString& rAddS
simpleAddTextToParagraph(sChunk);
- fprintf(stderr, "adding %s to document\n",
- rtl::OUStringToOString(sChunk, RTL_TEXTENCODING_UTF8).getStr());
-
for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i)
{
if (aForced[i])
commit 36a715dd31af7cf2249c3f8ccca974c783c297b8
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun Jun 26 20:51:48 2011 +0100
this can be const
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 26e6a66..061a98e 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -84,7 +84,7 @@ public:
void SetStartPos(const SwPosition & rStartPos);
SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos);
- SW_DLLPUBLIC sal_Bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bCheck );
+ SW_DLLPUBLIC bool MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const;
};
class SW_DLLPUBLIC SwFltControlStack
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index fdf498d..9981c86 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -135,7 +135,7 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
nPtCntnt = rEndPos.nContent.GetIndex();
}
-sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bCheck )
+bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, bool bCheck) const
{
// does this range actually contain something?
// empty range is allowed if at start of empty paragraph
@@ -146,7 +146,7 @@ sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bChec
&& ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len())))
&& (RES_TXTATR_FIELD != pAttr->Which()))
{
- return sal_False;
+ return false;
}
// !!! Die Content-Indizies beziehen sich immer auf den Node !!!
@@ -169,7 +169,7 @@ sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bChec
return CheckNodesRange( rRegion.Start()->nNode,
rRegion.End()->nNode, sal_True );
else
- return sal_True;
+ return true;
}
SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
commit 3cef24ce41723ba95dbf92b99b4eb9c511f35355
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jun 24 22:29:42 2011 +0100
make this more readable
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 0ed84da..26e6a66 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -134,7 +134,8 @@ public:
const SfxPoolItem* GetFmtAttr(const SwPosition& rPos, sal_uInt16 nWhich);
void Delete(const SwPaM &rPam);
- Entries::size_type Count() { return maEntries.size(); }
+ bool empty() const { return maEntries.empty(); }
+ Entries::size_type size() const { return maEntries.size(); }
SwFltStackEntry* operator[](Entries::size_type nIndex)
{ return maEntries[nIndex]; }
void DeleteAndDestroy(Entries::size_type nCnt);
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index 59a0304..fdf498d 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -180,7 +180,7 @@ SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
SwFltControlStack::~SwFltControlStack()
{
- OSL_ENSURE(!Count(), "noch Attribute auf dem Stack");
+ OSL_ENSURE(maEntries.empty(), "There are still Attributes on the stack");
}
// MoveAttrs() ist fuer folgendes Problem:
@@ -193,12 +193,13 @@ SwFltControlStack::~SwFltControlStack()
// nach rechts verschoben werden.
void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
{
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
+ size_t nCnt = maEntries.size();
SwFltStackEntry* pEntry;
sal_uLong nPosNd = rPos.nNode.GetIndex();
sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
- for (sal_uInt16 i=0; i < nCnt; i++){
+ for (size_t i=0; i < nCnt; ++i)
+ {
pEntry = (*this)[ i ];
if(( pEntry->nMkNode.GetIndex() + 1 == nPosNd )
&&( pEntry->nMkCntnt >= nPosCt )){
@@ -219,8 +220,8 @@ void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
void SwFltControlStack::MarkAllAttrsOld()
{
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
- for (sal_uInt16 i=0; i < nCnt; i++)
+ size_t nCnt = maEntries.size();
+ for (sal_uInt16 i=0; i < nCnt; ++i)
(*this)[ i ]->bOld = sal_True;
}
@@ -252,14 +253,12 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
// Wird fuer Grafik-Apos -> Grafiken benutzt.
void SwFltControlStack::StealAttr(const SwPosition* pPos, sal_uInt16 nAttrId /* = 0 */)
{
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
-
- SwFltStackEntry* pEntry;
+ size_t nCnt = maEntries.size();
while (nCnt)
{
nCnt --;
- pEntry = (*this)[ nCnt ];
+ SwFltStackEntry* pEntry = (*this)[ nCnt ];
if (pEntry->nPtNode.GetIndex()+1 == pPos->nNode.GetIndex() &&
(!nAttrId || nAttrId == pEntry->pAttr->Which()))
DeleteAndDestroy(nCnt); // loesche aus dem Stack
@@ -276,12 +275,11 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& pPos)
SwNodeIndex aAktNode( pPos.nNode, -1 );
sal_uInt16 nAktIdx = pPos.nContent.GetIndex();
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
- SwFltStackEntry* pEntry;
+ size_t nCnt = maEntries.size();
while( nCnt )
{
nCnt --;
- pEntry = (*this)[ nCnt ];
+ SwFltStackEntry* pEntry = (*this)[ nCnt ];
if( !pEntry->bOld
&& !pEntry->bLocked
&& (pEntry->nMkNode == aAktNode)
@@ -306,13 +304,10 @@ void SwFltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
(RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
"Falsche Id fuers Attribut");
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
-
- SwFltStackEntry* pEntry;
-
- for (sal_uInt16 i=0; i < nCnt; i++)
+ size_t nCnt = maEntries.size();
+ for (size_t i=0; i < nCnt; ++i)
{
- pEntry = (*this)[ i ];
+ SwFltStackEntry* pEntry = (*this)[i];
if (pEntry->bLocked)
{
// setze das Ende vom Attribut
@@ -604,7 +599,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry*
SfxPoolItem* SwFltControlStack::GetFmtStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
{
SwFltStackEntry* pEntry;
- sal_uInt16 nSize = static_cast< sal_uInt16 >(Count());
+ size_t nSize = maEntries.size();
while (nSize)
{
@@ -652,7 +647,7 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
if (aEndNode != aStartNode)
return;
- for (sal_uInt16 nSize = static_cast< sal_uInt16 >(Count()); nSize > 0;)
+ for (size_t nSize = maEntries.size(); nSize > 0;)
{
SwFltStackEntry* pEntry = (*this)[--nSize];
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 83cdba3..3ba892c 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -627,7 +627,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
std::deque<Chunk> aChunks;
//Here store stack location
- sal_uInt16 nCurrentCount = static_cast< sal_uInt16 >(pCtrlStck->Count());
+ size_t nCurrentCount = pCtrlStck->size();
while (nStart < nEndCp)
{
//nStart is the beginning of the attributes for this range, and
@@ -685,11 +685,11 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
{
if (bStartAttr)
{
- sal_uInt16 nCount = static_cast< sal_uInt16 >(pCtrlStck->Count());
+ size_t nCount = pCtrlStck->size();
if (maFieldStack.empty() && Read_Field(&aRes))
{
String sURL;
- for (sal_uInt16 nI = static_cast< sal_uInt16 >(pCtrlStck->Count()); nI > nCount; --nI)
+ for (size_t nI = pCtrlStck->size(); nI > nCount; --nI)
{
const SfxPoolItem *pItem = ((*pCtrlStck)[nI-1])->pAttr;
sal_uInt16 nWhich = pItem->Which();
@@ -723,9 +723,9 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
//Here read current properties and convert them into pS
//and put those attrs into the draw box if they can be converted
//to draw attributes
- if (pCtrlStck->Count() - nCurrentCount)
+ if (pCtrlStck->size() - nCurrentCount)
{
- for (sal_uInt16 i = nCurrentCount; i < pCtrlStck->Count(); i++)
+ for (size_t i = nCurrentCount; i < pCtrlStck->size(); ++i)
{
const SfxPoolItem *pItem = ((*pCtrlStck)[i])->pAttr;
sal_uInt16 nWhich = pItem->Which();
@@ -764,7 +764,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
//pop off as far as recorded location just in case there were some left
//unclosed
- for (sal_uInt16 nI = static_cast< sal_uInt16 >(pCtrlStck->Count()); nI > nCurrentCount; --nI)
+ for (size_t nI = pCtrlStck->size(); nI > nCurrentCount; --nI)
pCtrlStck->DeleteAndDestroy(nI-1);
typedef std::deque<Chunk>::iterator myIter;
@@ -3057,8 +3057,8 @@ void SwWW8FltAnchorStack::AddAnchor(const SwPosition& rPos, SwFrmFmt *pFmt)
void SwWW8FltAnchorStack::Flush()
{
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
- for (sal_uInt16 i=0; i < nCnt; ++i)
+ size_t nCnt = size();
+ for (size_t i=0; i < nCnt; ++i)
{
SwFltStackEntry *pEntry = (*this)[i];
SwPosition aDummy(pEntry->nMkNode);
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 47606ff..8be6e3c 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -990,8 +990,8 @@ void SwWW8FltControlStack::SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId,
//the real document
if (rReader.pPlcxMan && rReader.pPlcxMan->GetDoingDrawTextBox())
{
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(Count());
- for (sal_uInt16 i=0; i < nCnt; ++i)
+ size_t nCnt = size();
+ for (size_t i=0; i < nCnt; ++i)
{
SwFltStackEntry* pEntry = (*this)[i];
if (nAttrId == pEntry->pAttr->Which())
@@ -1236,7 +1236,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
SwNodeIndex aNode( rPos.nNode, -1 );
sal_uInt16 nIdx = rPos.nContent.GetIndex();
- sal_uInt16 nSize = static_cast< sal_uInt16 >(Count());
+ size_t nSize = size();
while (nSize)
{
const SwFltStackEntry* pEntry = (*this)[ --nSize ];
@@ -2868,6 +2868,9 @@ void SwWW8ImplReader::emulateMSWordAddTextToParagraph(const rtl::OUString& rAddS
simpleAddTextToParagraph(sChunk);
+ fprintf(stderr, "adding %s to document\n",
+ rtl::OUStringToOString(sChunk, RTL_TEXTENCODING_UTF8).getStr());
+
for (size_t i = 0; i < SAL_N_ELEMENTS(aIds); ++i)
{
if (aForced[i])
@@ -3542,7 +3545,7 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType)
// #i43118# - refine condition: the anchor
// control stack has to have entries, otherwise it's not needed
// to insert a text node.
- if ( !bStartLine && pAnchorStck->Count() > 0 )
+ if (!bStartLine && !pAnchorStck->empty())
{
AppendTxtNode(*pPaM->GetPoint());
}
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index df3f163..89ee0bf 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2183,8 +2183,8 @@ WW8DupProperties::WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStk)
{
//Close any open character properties and duplicate them inside the
//first table cell
- sal_uInt16 nCnt = static_cast< sal_uInt16 >(pCtrlStck->Count());
- for (sal_uInt16 i=0; i < nCnt; i++)
+ size_t nCnt = pCtrlStck->size();
+ for (size_t i=0; i < nCnt; ++i)
{
const SwFltStackEntry* pEntry = (*pCtrlStck)[ i ];
if(pEntry->bLocked)
More information about the Libreoffice-commits
mailing list