summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docnew.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-09-09 23:04:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-09-12 09:09:58 +0100
commit108dabd57649312c1f418b8349cbde26b7a15478 (patch)
tree32bb7d0df9b909b40de0de9a9b962eb2adeb7c4b /sw/source/core/doc/docnew.cxx
parent38596e653aa583f52ac0c84be5d0f909d66fe3c8 (diff)
factor out code which sets the defaults for properties
Diffstat (limited to 'sw/source/core/doc/docnew.cxx')
-rw-r--r--sw/source/core/doc/docnew.cxx44
1 files changed, 25 insertions, 19 deletions
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 ;