diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-09-09 23:04:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-09-12 09:09:58 +0100 |
commit | 108dabd57649312c1f418b8349cbde26b7a15478 (patch) | |
tree | 32bb7d0df9b909b40de0de9a9b962eb2adeb7c4b /sw | |
parent | 38596e653aa583f52ac0c84be5d0f909d66fe3c8 (diff) |
factor out code which sets the defaults for properties
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 5 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 44 |
2 files changed, 29 insertions, 20 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 8566914d7bd3..c9eaca9b4e5b 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1270,9 +1270,12 @@ public: SwTxtFmtColl* CopyTxtColl( const SwTxtFmtColl& rColl ); SwGrfFmtColl* CopyGrfColl( const SwGrfFmtColl& rColl ); - // Replace all formats with those from rSource. + // Replace all styles with those from rSource. void ReplaceStyles( const SwDoc& rSource ); + // Replace all property defaults with those from rSource. + void ReplaceDefaults( const SwDoc& rSource ); + // Query if style (paragraph- / character- / frame- / page-) is used. sal_Bool IsUsed( const SwModify& ) const; sal_Bool IsUsed( const SwNumRule& ) const; diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 4360225782b4..1153bcc041cc 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -1046,12 +1046,11 @@ void SwDoc::InitTOXTypes() pTOXTypes->Insert( pNew, pTOXTypes->Count() ); } -SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const +void SwDoc::ReplaceDefaults(const SwDoc& rSource) { - SwDoc* pRet = new SwDoc; - - //copy settings - sal_uInt16 aRangeOfDefaults[] = { + //copy property defaults + const sal_uInt16 aRangeOfDefaults[] = + { RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1, @@ -1060,25 +1059,32 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const 0 }; - { - SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults ); + SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults); - sal_uInt16 nWhich; - sal_uInt16 nRange = 0; - while( aRangeOfDefaults[nRange] != 0) + sal_uInt16 nRange = 0; + while (aRangeOfDefaults[nRange] != 0) + { + for (sal_uInt16 nWhich = aRangeOfDefaults[nRange]; + nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich) { - for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich ) - { - const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); - if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) - aNewDefaults.Put( rSourceAttr ); - } - nRange += 2; + const SfxPoolItem& rSourceAttr = + rSource.mpAttrPool->GetDefaultItem(nWhich); + if (rSourceAttr != mpAttrPool->GetDefaultItem(nWhich)) + aNewDefaults.Put(rSourceAttr); } - if( aNewDefaults.Count() ) - pRet->SetDefault( aNewDefaults ); + nRange += 2; } + if (aNewDefaults.Count()) + SetDefault(aNewDefaults); +} + +SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const +{ + SwDoc* pRet = new SwDoc; + + pRet->ReplaceDefaults(*this); + pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; pRet->mbParaSpaceMax = mbParaSpaceMax ; |