[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/source
Oliver-Rainer Wittmann
orw at apache.org
Thu May 30 05:07:13 PDT 2013
sw/source/core/doc/poolfmt.cxx | 112 +++++++++++++++++++++--------------------
1 file changed, 59 insertions(+), 53 deletions(-)
New commits:
commit 384aa00b12fbfd0d888858dc5677825637e1e98b
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Thu May 30 11:07:41 2013 +0000
122416: <SwDoc::GetPageDescFromPool(..)> - correction and refactoring
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index c22eba1..797ddcf 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -1440,7 +1440,7 @@ bool SwDoc::IsPoolFmtUsed( sal_uInt16 nId ) const
-void lcl_GetStdPgSize( SwDoc* pDoc, SfxItemSet& rSet )
+void lcl_PutStdPageSizeIntoItemSet( SwDoc* pDoc, SfxItemSet& rSet )
{
SwPageDesc* pStdPgDsc = pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
@@ -1458,52 +1458,58 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
ASSERT( RES_POOLPAGE_BEGIN <= nId && nId < RES_POOLPAGE_END,
"Falsche AutoFormat-Id" );
- SwPageDesc *pNewPgDsc;
- sal_uInt16 n;
-
- for( n = 0; n < aPageDescs.Count(); ++n )
- if( nId == ( pNewPgDsc = aPageDescs[ n ] )->GetPoolFmtId() )
+ for( sal_uInt16 n = 0; n < aPageDescs.Count(); ++n )
+ {
+ if ( nId == aPageDescs[ n ]->GetPoolFmtId() )
{
- return pNewPgDsc;
+ return aPageDescs[ n ];
}
+ }
- // Fehlerfall: unbekannte Poolvorlage
if( RES_POOLPAGE_BEGIN > nId || nId >= RES_POOLPAGE_END )
{
- ASSERT( !this, "ungueltige Id" );
+ // unknown page pool ID
+ ASSERT( !this, "<SwDoc::GetPageDescFromPool(..)> - unknown page pool ID" );
nId = RES_POOLPAGE_BEGIN;
}
- ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), *pSwResMgr );
- String aNm( aResId );
+ SwPageDesc* pNewPgDsc = 0;
{
- sal_Bool bIsModified = IsModified();
+ const ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), *pSwResMgr );
+ const String aNm( aResId );
+ const bool bIsModified = IsModified();
+ sal_uInt16 nPageDescIdx = 0;
{
::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
- n = MakePageDesc( aNm, 0, bRegardLanguage );
+ nPageDescIdx = MakePageDesc( aNm, 0, bRegardLanguage );
}
- pNewPgDsc = aPageDescs[ n ];
+ pNewPgDsc = aPageDescs[ nPageDescIdx ];
pNewPgDsc->SetPoolFmtId( nId );
- if( !bIsModified )
+ if ( !bIsModified )
+ {
ResetModified();
+ }
}
-
SvxLRSpaceItem aLR( RES_LR_SPACE );
- aLR.SetLeft( GetMetricVal( CM_1 ) * 2 );
- aLR.SetRight( aLR.GetLeft() );
+ {
+ aLR.SetLeft( GetMetricVal( CM_1 ) * 2 );
+ aLR.SetRight( aLR.GetLeft() );
+ }
SvxULSpaceItem aUL( RES_UL_SPACE );
- aUL.SetUpper( (sal_uInt16)aLR.GetLeft() );
- aUL.SetLower( (sal_uInt16)aLR.GetLeft() );
+ {
+ aUL.SetUpper( (sal_uInt16)aLR.GetLeft() );
+ aUL.SetLower( (sal_uInt16)aLR.GetLeft() );
+ }
SwAttrSet aSet( GetAttrPool(), aPgFrmFmtSetRange );
- sal_Bool bSetLeft = sal_True;
+ bool bSetLeft = true;
switch( nId )
{
- case RES_POOLPAGE_STANDARD: // Standard-Seite
+ case RES_POOLPAGE_STANDARD: // "Default"
{
aSet.Put( aLR );
aSet.Put( aUL );
@@ -1512,10 +1518,10 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
}
break;
- case RES_POOLPAGE_FIRST: // Erste Seite
- case RES_POOLPAGE_REGISTER: // Verzeichnis
+ case RES_POOLPAGE_FIRST: // "First Page"
+ case RES_POOLPAGE_REGISTER: // "Index"
{
- lcl_GetStdPgSize( this, aSet );
+ lcl_PutStdPageSizeIntoItemSet( this, aSet );
aSet.Put( aLR );
aSet.Put( aUL );
if( pNewPgDsc )
@@ -1527,34 +1533,34 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
}
break;
- case RES_POOLPAGE_LEFT: // Linke Seite
+ case RES_POOLPAGE_LEFT: // "Left Page"
{
- lcl_GetStdPgSize( this, aSet );
+ lcl_PutStdPageSizeIntoItemSet( this, aSet );
aSet.Put( aLR );
aSet.Put( aUL );
- bSetLeft = sal_False;
+ bSetLeft = false;
if( pNewPgDsc )
pNewPgDsc->SetUseOn( nsUseOnPage::PD_LEFT );
}
break;
- case RES_POOLPAGE_RIGHT: // Rechte Seite
+ case RES_POOLPAGE_RIGHT: // "Right Page"
{
- lcl_GetStdPgSize( this, aSet );
+ lcl_PutStdPageSizeIntoItemSet( this, aSet );
aSet.Put( aLR );
aSet.Put( aUL );
- bSetLeft = sal_False;
+ bSetLeft = false;
if( pNewPgDsc )
pNewPgDsc->SetUseOn( nsUseOnPage::PD_RIGHT );
}
break;
- case RES_POOLPAGE_JAKET: // Umschlag
+ case RES_POOLPAGE_JAKET: // "Envelope"
{
- aLR.SetLeft( 0 ); aLR.SetRight( 0 );
- aUL.SetUpper( 0 ); aUL.SetLower( 0 );
Size aPSize( SvxPaperInfo::GetPaperSize( PAPER_ENV_C65 ) );
LandscapeSwap( aPSize );
aSet.Put( SwFmtFrmSize( ATT_FIX_SIZE, aPSize.Width(), aPSize.Height() ));
+ aLR.SetLeft( 0 ); aLR.SetRight( 0 );
+ aUL.SetUpper( 0 ); aUL.SetLower( 0 );
aSet.Put( aLR );
aSet.Put( aUL );
@@ -1566,9 +1572,9 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
}
break;
- case RES_POOLPAGE_HTML: // HTML
+ case RES_POOLPAGE_HTML: // "HTML"
{
- lcl_GetStdPgSize( this, aSet );
+ lcl_PutStdPageSizeIntoItemSet( this, aSet );
aLR.SetRight( GetMetricVal( CM_1 ));
aUL.SetUpper( (sal_uInt16)aLR.GetRight() );
aUL.SetLower( (sal_uInt16)aLR.GetRight() );
@@ -1579,10 +1585,11 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
}
break;
- case RES_POOLPAGE_FOOTNOTE:
- case RES_POOLPAGE_ENDNOTE:
+
+ case RES_POOLPAGE_FOOTNOTE: // "Footnote"
+ case RES_POOLPAGE_ENDNOTE: // "Endnote"
{
- lcl_GetStdPgSize( this, aSet );
+ lcl_PutStdPageSizeIntoItemSet( this, aSet );
aSet.Put( aLR );
aSet.Put( aUL );
if( pNewPgDsc )
@@ -1594,13 +1601,17 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
pNewPgDsc->SetFtnInfo( aInf );
}
break;
- case RES_POOLPAGE_LANDSCAPE:
+
+ case RES_POOLPAGE_LANDSCAPE: // "Landscape"
{
SwPageDesc* pStdPgDsc = this->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
SwFmtFrmSize aFrmSz( pStdPgDsc->GetMaster().GetFrmSize() );
- SwTwips nTmp = aFrmSz.GetHeight();
- aFrmSz.SetHeight( aFrmSz.GetWidth() );
- aFrmSz.SetWidth( nTmp );
+ if ( !pStdPgDsc->GetLandscape() )
+ {
+ const SwTwips nTmp = aFrmSz.GetHeight();
+ aFrmSz.SetHeight( aFrmSz.GetWidth() );
+ aFrmSz.SetWidth( nTmp );
+ }
aSet.Put( aFrmSz );
aSet.Put( aLR );
aSet.Put( aUL );
@@ -1609,21 +1620,16 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage )
pNewPgDsc->SetUseOn( nsUseOnPage::PD_ALL );
pNewPgDsc->SetLandscape( sal_True );
}
- }
- break;
+ }
+ break;
}
if( aSet.Count() )
{
- {
- if( bSetLeft )
- pNewPgDsc->GetLeft().SetFmtAttr( aSet );
- pNewPgDsc->GetMaster().SetFmtAttr( aSet );
- // JP 31.08.95: erzeugen einer PoolVorlage ist keine Modifikation
- // (Bug: 18545)
- // SetModified();
- }
+ if( bSetLeft )
+ pNewPgDsc->GetLeft().SetFmtAttr( aSet );
+ pNewPgDsc->GetMaster().SetFmtAttr( aSet );
}
return pNewPgDsc;
}
More information about the Libreoffice-commits
mailing list