[Libreoffice-commits] .: 4 commits - sw/inc sw/source writerfilter/source
Michael Stahl
mst at kemper.freedesktop.org
Wed Mar 21 04:15:15 PDT 2012
sw/inc/bparr.hxx | 8 ++++--
sw/source/core/bastyp/bparr.cxx | 16 +++++--------
sw/source/core/docnode/ndcopy.cxx | 2 -
sw/source/core/docnode/nodes.cxx | 34 ++++++++++++++--------------
sw/source/core/txtnode/ndtxt.cxx | 6 ++++
writerfilter/source/dmapper/PropertyMap.cxx | 23 ++++++++++++++++++
6 files changed, 59 insertions(+), 30 deletions(-)
New commits:
commit a4788b254268aa2d61b14678301f22cdbd27d2e7
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 21 10:42:02 2012 +0100
Revert "sw-outline-numbering-broken-fix.diff: outline numbering fix in master docs"
This reverts commit 9a11bd42af0db32fd06c84dd955ee563134665ce.
Removing attributes from the _source_ node in SwTxtNode::MakeCopy does
not make any sens at all, and the cited issue i#96092 was apparently
fixed independently in CWS sw31bf04 by the change to ndtxt.cxx in
1524aa18b9ddf7a4181e3f278155c48655084452.
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 2461505..4aabfba 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -266,7 +266,7 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
// kopiere Attribute/Text
if( !pCpyAttrNd->HasSwAttrSet() )
// wurde ein AttrSet fuer die Numerierung angelegt, so loesche diesen!
- pCpyAttrNd->ResetAllAttr();
+ pTxtNd->ResetAllAttr();
// if Copy-Textnode unequal to Copy-Attrnode, then copy first
// the attributes into the new Node.
commit cc99bb9f383a65912d004e227a5b6a88b401bbba
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 21 10:37:46 2012 +0100
writerfilter: PropertyMap: speed this up a bit
Using XMultiPropertySet reduces the number of SwTxtNodes created for the
bugdoc from rhbz#789022 from ~5k to ~3k.
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 575730f..ee3ba7f 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -32,6 +32,7 @@
#include <i18nutil/paper.hxx>
#include <rtl/oustringostreaminserter.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/container/XEnumeration.hpp>
@@ -986,6 +987,28 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
void SectionPropertyMap::_ApplyProperties( uno::Reference< beans::XPropertySet > xStyle )
{
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
+ uno::Reference<beans::XMultiPropertySet> const xMultiSet(xStyle,
+ uno::UNO_QUERY);
+ if (xMultiSet.is())
+ { // FIXME why is "this" a STL container???
+ uno::Sequence<rtl::OUString> names(this->size());
+ uno::Sequence<uno::Any> values(this->size());
+ PropertyMap::iterator it = this->begin();
+ for (size_t i = 0; it != this->end(); ++it, ++i)
+ {
+ names[i] = rPropNameSupplier.GetName(it->first.eId);
+ values[i] = it->second;
+ }
+ try
+ {
+ xMultiSet->setPropertyValues(names, values);
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_FAIL( "Exception in <PageStyle>::setPropertyValue");
+ }
+ return;
+ }
PropertyMap::iterator aMapIter = begin();
while( aMapIter != end())
{
commit 082906e1f4cf58fdfab1a4064e2b7955fcdaeb8a
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 21 10:25:45 2012 +0100
rhbz#789022: SwNodes: fix inconsistent outline check:
SwNodes::UpdateOutlineNode will add/remove the node from
SwNodes::pOutlineNds depending on IsOutline(), while various SwNodes
methods that move and delete nodes check GetAttrOutlineLevel() != 0,
which may be false even if IsOutline() is true.
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 518de82..ab12430 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -173,7 +173,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
pTxtNode->RemoveFromList();
- if ( pTxtNode->GetAttrOutlineLevel() != 0 )//<-end,zhaojianwei
+ if (pTxtNode->IsOutline())
{
const SwNodePtr pSrch = (SwNodePtr)&rNd;
pOutlineNds->Remove( pSrch );
@@ -188,8 +188,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
rTxtNd.AddToList();
- if( bInsOutlineIdx &&
- 0 != rTxtNd.GetAttrOutlineLevel() )//<-end,zhaojianwei
+ if (bInsOutlineIdx && rTxtNd.IsOutline())
{
const SwNodePtr pSrch = (SwNodePtr)&rNd;
pOutlineNds->Insert( pSrch );
@@ -232,9 +231,11 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
{
SwTxtNode* pTxtNd = (SwTxtNode*)pNd;
- // loesche die Gliederungs-Indizies aus dem alten Nodes-Array
- if( 0 != pTxtNd->GetAttrOutlineLevel() )//<-end,zhaojianwei
+ // remove outline index from old nodes array
+ if (pTxtNd->IsOutline())
+ {
pOutlineNds->Remove( pNd );
+ }
// muss die Rule kopiere werden?
if( pDestDoc )
@@ -269,8 +270,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
{
SwpHints * const pHts = pTxtNd->GetpSwpHints();
// OultineNodes set the new nodes in the array
- if( bInsOutlineIdx &&
- 0 != pTxtNd->GetAttrOutlineLevel() ) //#outline level,added by zhaojianwei
+ if (bInsOutlineIdx && pTxtNd->IsOutline())
{
rNds.pOutlineNds->Insert( pTxtNd );
}
@@ -537,12 +537,12 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
if( pTmpNd->IsTxtNode() )
((SwTxtNode*)pTmpNd)->RemoveFromList();
- // setze bei Start/EndNodes die richtigen Indizies
- // loesche die Gliederungs-Indizies aus
- // dem alten Nodes-Array
- if( pCNd->IsTxtNode() && 0 !=
- ((SwTxtNode*)pCNd)->GetAttrOutlineLevel() )//<-end,by zhaojianwei
+ // remove outline index from old nodes array
+ if (pCNd->IsTxtNode() &&
+ static_cast<SwTxtNode*>(pCNd)->IsOutline())
+ {
pOutlineNds->Remove( pCNd );
+ }
else
pCNd = 0;
}
@@ -572,7 +572,7 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
SwNode* pNd = &aMvIdx.GetNode();
const bool bOutlNd = pNd->IsTxtNode() &&
- 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel();//<-end,zhaojianwei
+ static_cast<SwTxtNode*>(pNd)->IsOutline();
// loesche die Gliederungs-Indizies aus
// dem alten Nodes-Array
if( bOutlNd )
@@ -1221,14 +1221,15 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes)
if( pNd->IsTxtNode() )
{
- if( 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() &&//<-end,zhaojianwei
+ SwTxtNode *const pTxtNode(static_cast<SwTxtNode*>(pNd));
+ if (pTxtNode->IsOutline() &&
pOutlineNds->Seek_Entry( pNd, &nIdxPos ))
{
// loesche die Gliederungs-Indizies.
pOutlineNds->Remove( nIdxPos );
bUpdateOutline = sal_True;
}
- ((SwTxtNode*)pNd)->InvalidateNumRule();
+ pTxtNode->InvalidateNumRule();
}
else if( pNd->IsEndNode() &&
pNd->pStartOfSection->IsTableNode() )
@@ -1522,8 +1523,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt )
{
SwNode* pNd = (*this)[ n ];
- if( pNd->IsTxtNode() &&
- 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() ) //<-end,zhaojianwei
+ if (pNd->IsTxtNode() && static_cast<SwTxtNode*>(pNd)->IsOutline())
{ // loesche die Gliederungs-Indizies.
sal_uInt16 nIdxPos;
if( pOutlineNds->Seek_Entry( pNd, &nIdxPos ))
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 2691f28..fa6f3b0 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -261,6 +261,12 @@ SwTxtNode::~SwTxtNode()
delete pTmpHints;
}
+ // must be removed from outline nodes by now
+#if OSL_DEBUG_LEVEL > 0
+ sal_uInt16 foo;
+ assert(!GetNodes().GetOutLineNds().Seek_Entry(this, &foo));
+#endif
+
RemoveFromList();
InitSwParaStatistics( false );
commit 176ba743c12ecbfdda71522062f6d1a5749f3756
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Mar 21 10:21:03 2012 +0100
BigPtrArray: deploy some asserts
diff --git a/sw/inc/bparr.hxx b/sw/inc/bparr.hxx
index cd95b1c..a2834d3 100644
--- a/sw/inc/bparr.hxx
+++ b/sw/inc/bparr.hxx
@@ -26,8 +26,10 @@
*
************************************************************************/
-#ifndef _BPARR_HXX
-#define _BPARR_HXX
+#ifndef SW_BPARR_HXX
+#define SW_BPARR_HXX
+
+#include <assert.h>
#include <tools/solar.h>
#include <osl/diagnose.h>
@@ -113,7 +115,7 @@ public:
inline sal_uLong BigPtrEntry::GetPos() const
{
- OSL_ENSURE( this == pBlock->pData[ nOffset ], "element not in the block" );
+ assert(this == pBlock->pData[ nOffset ]); // element not in the block
return pBlock->nStart + nOffset;
}
diff --git a/sw/source/core/bastyp/bparr.cxx b/sw/source/core/bastyp/bparr.cxx
index ef92103..561e334 100644
--- a/sw/source/core/bastyp/bparr.cxx
+++ b/sw/source/core/bastyp/bparr.cxx
@@ -43,18 +43,16 @@ const sal_uInt16 nBlockGrowSize = 20;
void CheckIdx( BlockInfo** ppInf, sal_uInt16 nBlock, sal_uLong nSize, sal_uInt16 nCur )
{
- OSL_ENSURE( !nSize || nCur < nBlock, "BigPtrArray: CurIndex steht falsch" );
+ assert(!nSize || nCur < nBlock); // BigPtrArray: CurIndex invalid
sal_uLong nIdx = 0;
for( sal_uInt16 nCnt = 0; nCnt < nBlock; ++nCnt, ++ppInf )
{
nIdx += (*ppInf)->nElem;
- // Array mit Luecken darf es nicht geben
- OSL_ENSURE( !nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart,
- "BigPtrArray: Luecke in der Verwaltung!" );
+ // Array with holes is not allowed
+ assert(!nCnt || (*(ppInf-1))->nEnd + 1 == (*ppInf)->nStart);
}
-
- OSL_ENSURE( nIdx == nSize, "BigPtrArray: Anzahl ungueltig" );
+ assert(nIdx == nSize); // invalid count in nSize
}
#else
@@ -137,8 +135,8 @@ void BigPtrArray::ForEach( sal_uLong nStart, sal_uLong nEnd,
ElementPtr BigPtrArray::operator[]( sal_uLong idx ) const
{
+ assert(idx < nSize); // operator[]: Index out of bounds
// weil die Funktion eben doch nicht const ist:
- OSL_ENSURE( idx < nSize, "operator[]: Index aussserhalb" );
BigPtrArray* pThis = (BigPtrArray*) this;
sal_uInt16 cur = Index2Block( idx );
BlockInfo* p = ppInf[ cur ];
@@ -349,7 +347,7 @@ void BigPtrArray::Insert( const ElementPtr& rElem, sal_uLong pos )
}
// Nun haben wir einen freien Block am Wickel: eintragen
pos -= p->nStart;
- OSL_ENSURE( pos < MAXENTRY, "falsche Pos" );
+ assert(pos < MAXENTRY);
if( pos != p->nElem )
{
int nCount = p->nElem - sal_uInt16(pos);
@@ -458,8 +456,8 @@ void BigPtrArray::Remove( sal_uLong pos, sal_uLong n )
void BigPtrArray::Replace( sal_uLong idx, const ElementPtr& rElem)
{
+ assert(idx < nSize); // Index out of bounds
// weil die Funktion eben doch nicht const ist:
- OSL_ENSURE( idx < nSize, "Set: Index aussserhalb" );
BigPtrArray* pThis = (BigPtrArray*) this;
sal_uInt16 cur = Index2Block( idx );
BlockInfo* p = ppInf[ cur ];
More information about the Libreoffice-commits
mailing list