summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2014-07-22 12:45:47 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2014-09-30 09:56:35 +0200
commit66fedbe557074d005101e732a5d39095c094844d (patch)
tree92796712ce597c829b1a99cff2a6255f74d539ef
parent04221432f265cace36f536bbe6cbfd25498b120f (diff)
Fix broken sorted vector usage
Fixes and optimizes a few places, which will fail in case of the sorted_vector conversation. This drops a simple optimization from the ww8 filter. I'm not sure it's worth to memorize and just update the new styles. (cherry picked from commit a5ff456973e97508f6c926ec889dea2f9b4fe666) Conflicts: sw/inc/fesh.hxx sw/source/core/frmedt/fedesc.cxx sw/source/filter/inc/fltshell.hxx sw/source/filter/ww1/fltshell.cxx sw/source/filter/ww8/rtfexport.cxx sw/source/uibase/app/appenv.cxx Change-Id: I7a444013f59e81c81049cd40b9d9cfa0e29623c0
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/inc/fesh.hxx6
-rw-r--r--sw/source/core/doc/docdesc.cxx10
-rw-r--r--sw/source/core/frmedt/fedesc.cxx35
-rw-r--r--sw/source/filter/html/htmlcss1.cxx6
-rw-r--r--sw/source/filter/inc/fltshell.hxx3
-rw-r--r--sw/source/filter/ww1/fltshell.cxx31
-rw-r--r--sw/source/filter/ww8/rtfexport.cxx8
-rw-r--r--sw/source/filter/ww8/ww8par.cxx7
-rw-r--r--sw/source/ui/app/appenv.cxx12
10 files changed, 56 insertions, 64 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index dbab8734ed59..e5addc17898a 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1355,6 +1355,8 @@ public:
SwPageDesc* FindPageDescByName( const OUString& rName, sal_uInt16* pPos = 0 ) const;
SwPageDesc* FindPageDescByName( const OUString& rName, sal_uInt16* pPos = 0 );
SwPageDesc* FindPageDescByPoolId( sal_uInt16 nPoolId );
+ bool ContainsPageDesc( const SwPageDesc* ) const;
+ bool ContainsPageDesc( const SwPageDesc& ) const;
/** Copy the complete PageDesc - beyond document and "deep"!
Optionally copying of PoolFmtId, -HlpId can be prevented. */
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index c68a6c055944..f46326faefe8 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -554,12 +554,12 @@ public:
sal_uInt16 GetCurPageDesc( const sal_Bool bCalcFrm = sal_True ) const;
sal_uInt16 GetMousePageDesc( const Point &rPt ) const;
sal_uInt16 GetPageDescCnt() const;
- SwPageDesc* FindPageDescByName( const String& rName,
- sal_Bool bGetFromPool = sal_False,
- sal_uInt16* pPos = 0 );
+ SwPageDesc* FindPageDescByName( const OUString& rName,
+ sal_Bool bGetFromPool = sal_False );
const SwPageDesc& GetPageDesc( sal_uInt16 i ) const;
void ChgPageDesc( sal_uInt16 i, const SwPageDesc& );
+ void ChgPageDescP( const SwPageDesc&, SwPageDesc* = NULL );
/** if inside all selection only one PageDesc, @return this.
Otherwise @return 0 pointer */
const SwPageDesc* GetSelectedPageDescs() const;
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 2ce87c4daf59..91fdce79bead 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -873,6 +873,16 @@ void SwDoc::ChgPageDesc( const String & rName, const SwPageDesc & rDesc)
ChgPageDescP(rDesc, pd);
}
+bool SwDoc::ContainsPageDesc( const SwPageDesc *pg ) const
+{
+ return maPageDescs.Contains( const_cast<SwPageDesc*>( pg ) );
+}
+
+bool SwDoc::ContainsPageDesc( const SwPageDesc &pg ) const
+{
+ return maPageDescs.Contains( const_cast<SwPageDesc*>( &pg ) );
+}
+
/*
* The HTML import cannot resist changing the page descriptions, I don't
* know why. This function is meant to check the page descriptors for invalid
diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx
index daadca30008f..75e5a5000bcf 100644
--- a/sw/source/core/frmedt/fedesc.cxx
+++ b/sw/source/core/frmedt/fedesc.cxx
@@ -54,11 +54,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc )
#if OSL_DEBUG_LEVEL > 0
// SS does not change PageDesc, but only sets the attibute.
// The Pagedesc should be available in the document
- bool bFound = false;
- for ( sal_uInt16 nTst = 0; nTst < GetPageDescCnt(); ++nTst )
- if ( &rDesc == &GetPageDesc( nTst ) )
- bFound = true;
- OSL_ENSURE( bFound, "ChgCurPageDesc with invalid descriptor." );
+ OSL_ENSURE( GetDoc()->ContainsPageDesc( rDesc ), "ChgCurPageDesc with invalid descriptor." );
#endif
StartAllAction();
@@ -134,6 +130,21 @@ void SwFEShell::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
EndAllActionAndCall();
}
+void SwFEShell::ChgPageDescP( const SwPageDesc &rChged, SwPageDesc *pd )
+{
+ StartAllAction();
+ SET_CURR_SHELL( this );
+ //Fix i64842: because Undo has a very special way to handle header/footer content
+ // we have to copy the page descriptor before calling ChgPageDesc.
+ SwPageDesc aDesc( rChged );
+ {
+ ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
+ GetDoc()->CopyPageDesc(rChged, aDesc);
+ }
+ GetDoc()->ChgPageDescP( aDesc, pd );
+ EndAllActionAndCall();
+}
+
/*************************************************************************
|*
|* SwFEShell::GetPageDesc(), GetCurPageDesc()
@@ -145,19 +156,15 @@ const SwPageDesc& SwFEShell::GetPageDesc( sal_uInt16 i ) const
return GetDoc()->GetPageDesc( i );
}
-SwPageDesc* SwFEShell::FindPageDescByName( const String& rName,
- sal_Bool bGetFromPool,
- sal_uInt16* pPos )
+SwPageDesc* SwFEShell::FindPageDescByName( const OUString& rName,
+ sal_Bool bGetFromPool )
{
- SwPageDesc* pDesc = GetDoc()->FindPageDescByName(rName, pPos);
+ SwPageDesc* pDesc = GetDoc()->FindPageDescByName( rName );
if( !pDesc && bGetFromPool )
{
sal_uInt16 nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( rName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC );
- if( USHRT_MAX != nPoolId &&
- 0 != (pDesc = GetDoc()->GetPageDescFromPool( nPoolId ))
- && pPos )
- // appended always
- *pPos = GetDoc()->GetPageDescCnt() - 1 ;
+ if( USHRT_MAX != nPoolId)
+ pDesc = GetDoc()->GetPageDescFromPool( nPoolId );
}
return pDesc;
}
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index c8a58ee7fb70..f64c473f1f74 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -89,9 +89,9 @@ static struct SwCSS1ItemIds
void SwCSS1Parser::ChgPageDesc( const SwPageDesc *pPageDesc,
const SwPageDesc& rNewPageDesc )
{
- const SwPageDesc *spd = pDoc->FindPageDescByName( pPageDesc->GetName() );
- OSL_ENSURE( pPageDesc != spd, "Seitenvorlage nicht gefunden" );
- if (pPageDesc == spd)
+ bool contains = pDoc->ContainsPageDesc( pPageDesc );
+ OSL_ENSURE( contains, "Seitenvorlage nicht gefunden" );
+ if( contains )
pDoc->ChgPageDescP( rNewPageDesc, const_cast<SwPageDesc*>( pPageDesc ) );
}
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index b5c30212ca38..8fe8a399d39f 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -527,7 +527,6 @@ class SwFltShell
SwPaM* pPaM;
//
String sBaseURL;
- sal_uInt16 nPageDescOffset; // fuers update der pagedescs
CharSet eSrcCharSet; // charset der quelle
friend class SwFltControlStack;
sal_Bool bNewDoc;
@@ -681,8 +680,6 @@ public:
const String& GetBaseURL() const { return sBaseURL; }
};
-SW_DLLPUBLIC void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset);
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx
index ecd6279b46c9..122bf9c61a1a 100644
--- a/sw/source/filter/ww1/fltshell.cxx
+++ b/sw/source/filter/ww1/fltshell.cxx
@@ -1010,7 +1010,6 @@ SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, const String& rBaseURL, sal_Boo
aEndStack(pDoc, nFieldFl),
pPaM(new SwPaM(*(rPaM.GetPoint()))),
sBaseURL(rBaseURL),
- nPageDescOffset(GetDoc().GetPageDescCnt()),
eSrcCharSet(RTL_TEXTENCODING_MS_1252),
bNewDoc(bNew),
bStdPD(sal_False),
@@ -1049,8 +1048,6 @@ SwFltShell::SwFltShell(SwDoc* pDoc, SwPaM& rPaM, const String& rBaseURL, sal_Boo
SwFltShell::~SwFltShell()
{
- sal_uInt16 i;
-
if (eSubMode == Style)
EndStyle();
if( pOutDoc->IsInTable() ) // falls nicht ordentlich abgeschlossen
@@ -1064,9 +1061,10 @@ SwFltShell::~SwFltShell()
aStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
aEndStack.SetAttr(*pPaM->GetPoint(), 0, sal_False);
+
+ SwDoc& rDoc = GetDoc();
if( bProtect ){ // Das ganze Doc soll geschuetzt sein
- SwDoc& rDoc = GetDoc();
// 1. SectionFmt und Section anlegen
SwSectionFmt* pSFmt = rDoc.MakeSectionFmt( 0 );
SwSectionData aSectionData(CONTENT_SECTION, OUString("PMW-Protect"));
@@ -1090,12 +1088,10 @@ SwFltShell::~SwFltShell()
// Pagedescriptoren am Dokument updaten (nur so werden auch die
// linken Seiten usw. eingestellt).
- GetDoc().ChgPageDesc( 0, GetDoc().GetPageDesc( 0 )); // PageDesc "Standard"
- for (i=nPageDescOffset;i<GetDoc().GetPageDescCnt();i++)
- {
- const SwPageDesc& rPD = GetDoc().GetPageDesc(i);
- GetDoc().ChgPageDesc(i, rPD);
- }
+ sal_uInt16 i;
+
+ for (i = 0 ; i < rDoc.GetPageDescCnt(); i++)
+ GetDoc().ChgPageDescP( rDoc.GetPageDesc(i) );
delete pPaM;
for (i=0; i<sizeof(pColls)/sizeof(*pColls); i++)
@@ -2151,19 +2147,4 @@ void SwFltShell::NextStyle(sal_uInt16 nWhich, sal_uInt16 nNext)
*pColls[nNext]->GetColl() );
}
-// UpdatePageDescs muss am Ende des Einlesevorganges aufgerufen werden, damit
-// der Writer den Inhalt der Pagedescs wirklich akzeptiert
-void UpdatePageDescs(SwDoc &rDoc, sal_uInt16 nInPageDescOffset)
-{
- // Pagedescriptoren am Dokument updaten (nur so werden auch die
- // linken Seiten usw. eingestellt).
-
- // PageDesc "Standard"
- rDoc.ChgPageDesc(0, rDoc.GetPageDesc(0));
-
- // PageDescs "Konvert..."
- for (sal_uInt16 i = nInPageDescOffset; i < rDoc.GetPageDescCnt(); ++i)
- rDoc.ChgPageDesc(i, rDoc.GetPageDesc(i));
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/rtfexport.cxx b/sw/source/filter/ww8/rtfexport.cxx
index c98b78020505..89045509d460 100644
--- a/sw/source/filter/ww8/rtfexport.cxx
+++ b/sw/source/filter/ww8/rtfexport.cxx
@@ -465,12 +465,10 @@ void RtfExport::WritePageDescTable()
OutPageDescription( rPageDesc, false, false );
// search for the next page description
- sal_uInt16 i = nSize;
- while( i )
- if( rPageDesc.GetFollow() == &pDoc->GetPageDesc( --i ) )
- break;
+ sal_uInt16 nPos;
+ pDoc->FindPageDescByName(rPageDesc.GetFollow()->GetName(), &nPos);
Strm() << OOO_STRING_SVTOOLS_RTF_PGDSCNXT;
- OutULong( i ) << ' ';
+ OutULong( nPos ) << ' ';
Strm() << msfilter::rtfutil::OutString( rPageDesc.GetName(), eDefaultEncoding).getStr() << ";}";
}
Strm() << '}' << sNewLine;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 5801a4baf8c3..bdf41cdeb70b 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4504,8 +4504,6 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
pAnchorStck = new SwWW8FltAnchorStack(&rDoc, nFieldFlags);
- sal_uInt16 nPageDescOffset = rDoc.GetPageDescCnt();
-
SwNodeIndex aSttNdIdx( rDoc.GetNodes() );
SwRelNumRuleSpaces aRelNumRule(rDoc, mbNewDoc);
@@ -4927,7 +4925,10 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos)
if (mbNewDoc)
rDoc.SetRedlineMode((RedlineMode_t)( eMode ));
- UpdatePageDescs(rDoc, nPageDescOffset);
+ // Update document page descriptors (only this way also left pages
+ // get adjusted)
+ for (sal_uInt16 i = 0; i < rDoc.GetPageDescCnt(); ++i)
+ rDoc.ChgPageDescP( rDoc.GetPageDesc(i) );
delete pPaM, pPaM = 0;
return nErrRet;
diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx
index af2bda429438..9a271ab6f2e9 100644
--- a/sw/source/ui/app/appenv.cxx
+++ b/sw/source/ui/app/appenv.cxx
@@ -399,14 +399,10 @@ void SwModule::InsertEnv( SfxRequest& rReq )
// Apply page description
- sal_uInt16 nPos;
- pSh->FindPageDescByName( pDesc->GetName(),
- sal_False,
- &nPos );
-
-
- pSh->ChgPageDesc( nPos, *pDesc);
- pSh->ChgCurPageDesc(*pDesc);
+ SwPageDesc *pd = pSh->FindPageDescByName( pDesc->GetName(),
+ sal_False );
+ pSh->ChgPageDescP( *pDesc, pd );
+ pSh->ChgCurPageDesc( *pDesc );
// Insert Frame
SwFlyFrmAttrMgr aMgr(sal_False, pSh, FRMMGR_TYPE_ENVELP);