Kaydet (Commit) 108dabd5 authored tarafından Caolán McNamara's avatar Caolán McNamara

factor out code which sets the defaults for properties

üst 38596e65
...@@ -1270,9 +1270,12 @@ public: ...@@ -1270,9 +1270,12 @@ public:
SwTxtFmtColl* CopyTxtColl( const SwTxtFmtColl& rColl ); SwTxtFmtColl* CopyTxtColl( const SwTxtFmtColl& rColl );
SwGrfFmtColl* CopyGrfColl( const SwGrfFmtColl& 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 ); 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. // Query if style (paragraph- / character- / frame- / page-) is used.
sal_Bool IsUsed( const SwModify& ) const; sal_Bool IsUsed( const SwModify& ) const;
sal_Bool IsUsed( const SwNumRule& ) const; sal_Bool IsUsed( const SwNumRule& ) const;
......
...@@ -1046,12 +1046,11 @@ void SwDoc::InitTOXTypes() ...@@ -1046,12 +1046,11 @@ void SwDoc::InitTOXTypes()
pTOXTypes->Insert( pNew, pTOXTypes->Count() ); pTOXTypes->Insert( pNew, pTOXTypes->Count() );
} }
SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const void SwDoc::ReplaceDefaults(const SwDoc& rSource)
{ {
SwDoc* pRet = new SwDoc; //copy property defaults
const sal_uInt16 aRangeOfDefaults[] =
//copy settings {
sal_uInt16 aRangeOfDefaults[] = {
RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_FRMATR_BEGIN, RES_FRMATR_END-1,
RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_CHRATR_BEGIN, RES_CHRATR_END-1,
RES_PARATR_BEGIN, RES_PARATR_END-1, RES_PARATR_BEGIN, RES_PARATR_END-1,
...@@ -1060,25 +1059,32 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const ...@@ -1060,25 +1059,32 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
0 0
}; };
{ SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults);
SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults );
sal_uInt16 nWhich; sal_uInt16 nRange = 0;
sal_uInt16 nRange = 0; while (aRangeOfDefaults[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 =
{ rSource.mpAttrPool->GetDefaultItem(nWhich);
const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich ); if (rSourceAttr != mpAttrPool->GetDefaultItem(nWhich))
if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) ) aNewDefaults.Put(rSourceAttr);
aNewDefaults.Put( rSourceAttr );
}
nRange += 2;
} }
if( aNewDefaults.Count() ) nRange += 2;
pRet->SetDefault( aNewDefaults );
} }
if (aNewDefaults.Count())
SetDefault(aNewDefaults);
}
SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
{
SwDoc* pRet = new SwDoc;
pRet->ReplaceDefaults(*this);
pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1; pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1;
pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2; pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2;
pRet->mbParaSpaceMax = mbParaSpaceMax ; pRet->mbParaSpaceMax = mbParaSpaceMax ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment