diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2013-08-17 02:06:19 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-08-18 13:59:35 +0000 |
commit | b0f4295fdc411eaacf32bd41139da8eb08fe575b (patch) | |
tree | debee7016c6ef1db0b52791f76d3545b92772d9c /sw | |
parent | b5e5ce956b463e90bb65ad99cefca33b9b0b13bf (diff) |
GetPageDescByName_Impl: move, rename and clean up
Change-Id: I1415f8b97fc197694bd52b1cf8e94c1ec2c7bdbe
Reviewed-on: https://gerrit.libreoffice.org/5467
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/pagedesc.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/pagedesc.cxx | 27 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 39 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 4 |
5 files changed, 33 insertions, 43 deletions
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index a132378ad349..e668dfd240ae 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -238,6 +238,8 @@ public: /// Given a SwNode return the pagedesc in use at that location. static const SwPageDesc* GetPageDescOfNode(const SwNode& rNd); + static SwPageDesc* GetByName(SwDoc& rDoc, const OUString& rName); + SwPageDesc& operator=( const SwPageDesc& ); SwPageDesc( const SwPageDesc& ); @@ -333,8 +335,6 @@ public: }; -SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const OUString& rName); - #endif //PAGEDESC_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 79410e753c18..fadd5274a995 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -30,6 +30,7 @@ #include <swtable.hxx> #include <frmtool.hxx> #include <doc.hxx> // for GetAttrPool +#include <poolfmt.hrc> #include <poolfmt.hxx> #include <switerator.hxx> @@ -372,6 +373,32 @@ void SwPageDesc::ChgFirstShare( sal_Bool bNew ) eUse = (UseOnPage) (eUse & nsUseOnPage::PD_NOFIRSTSHARE); } +SwPageDesc* SwPageDesc::GetByName(SwDoc& rDoc, const OUString& rName) +{ + const sal_uInt16 nDCount = rDoc.GetPageDescCnt(); + + for( sal_uInt16 i = 0; i < nDCount; i++ ) + { + SwPageDesc* pDsc = &rDoc.GetPageDesc( i ); + if(pDsc->GetName() == rName) + { + return pDsc; + } + } + + for( sal_Int32 i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i) + { + if (rName==SW_RESSTR(i)) + { + return rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >( + i - RC_POOLPAGEDESC_BEGIN + RES_POOLPAGE_BEGIN) ); + } + } + + return 0; +} + + /************************************************************************* |* |* SwPageFtnInfo::SwPageFtnInfo() diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index c049ddde014a..d1d338c30dde 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -54,8 +54,6 @@ #include <fmtfld.hxx> #include <fmtpdsc.hxx> #include <pagedesc.hxx> -#include <poolfmt.hrc> -#include <poolfmt.hxx> #include <edimp.hxx> #include <fchrfmt.hxx> #include <fmtautofmt.hxx> @@ -323,8 +321,7 @@ SwUnoCursorHelper::SetPageDesc( bool bPut = false; if (!sDescName.isEmpty()) { - SwPageDesc *const pPageDesc = - ::GetPageDescByName_Impl(rDoc, sDescName); + SwPageDesc *const pPageDesc = SwPageDesc::GetByName(rDoc, sDescName); if (!pPageDesc) { throw lang::IllegalArgumentException(); @@ -665,40 +662,6 @@ SwUnoCursorHelper::GetCurTxtFmtColl(SwPaM & rPaM, const bool bConditional) return (bError) ? 0 : pFmt; } -/* -------------------------------------------------- - * Hilfsfunktion fuer PageDesc - * --------------------------------------------------*/ -SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const OUString& rName) -{ - SwPageDesc* pRet = 0; - sal_uInt16 nDCount = rDoc.GetPageDescCnt(); - sal_uInt16 i; - - for( i = 0; i < nDCount; i++ ) - { - SwPageDesc* pDsc = &rDoc.GetPageDesc( i ); - if(pDsc->GetName() == rName) - { - pRet = pDsc; - break; - } - } - if(!pRet) - { - for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i) - { - if (rName==SW_RESSTR(i)) - { - pRet = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >( - RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) ); - break; - } - } - } - - return pRet; - } - /****************************************************************** * SwXTextCursor ******************************************************************/ diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a0331b0f3131..b39be8eb7414 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1835,7 +1835,7 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, sal_Bool bPut = sal_False; if (!sDescName.isEmpty()) { - SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName); + SwPageDesc* pPageDesc = SwPageDesc::GetByName(*pDoc, sDescName); if(pPageDesc) { pNewDesc->RegisterToPageDesc( *pPageDesc ); diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 4f4045cf0f78..99c14d6f0353 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -216,7 +216,7 @@ static void lcl_SetSpecialProperty(SwFrmFmt* pFmt, const SfxItemPropertySimpleEn if (!sPageStyle.isEmpty()) { SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true ); - pDesc = ::GetPageDescByName_Impl(*pFmt->GetDoc(), sPageStyle); + pDesc = SwPageDesc::GetByName(*pFmt->GetDoc(), sPageStyle); } SwFmtPageDesc aDesc( pDesc ); pFmt->GetDoc()->SetAttr(aDesc, *pFmt); @@ -2005,7 +2005,7 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) if (!sPageStyle.isEmpty()) { SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true ); - const SwPageDesc* pDesc = ::GetPageDescByName_Impl(rDoc, sPageStyle); + const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle); if(pDesc) { SwFmtPageDesc aDesc( pDesc ); |