[Libreoffice-commits] core.git: sw/inc sw/source

Matteo Casalin matteo.casalin at yahoo.com
Sun Aug 18 06:59:59 PDT 2013


 sw/inc/pagedesc.hxx                 |    4 +--
 sw/source/core/layout/pagedesc.cxx  |   27 ++++++++++++++++++++++++
 sw/source/core/unocore/unoobj.cxx   |   39 ------------------------------------
 sw/source/core/unocore/unostyle.cxx |    2 -
 sw/source/core/unocore/unotbl.cxx   |    4 +--
 5 files changed, 33 insertions(+), 43 deletions(-)

New commits:
commit b0f4295fdc411eaacf32bd41139da8eb08fe575b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Aug 17 02:06:19 2013 +0200

    GetPageDescByName_Impl: move, rename and clean up
    
    Change-Id: I1415f8b97fc197694bd52b1cf8e94c1ec2c7bdbe
    Reviewed-on: https://gerrit.libreoffice.org/5467
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index a132378..e668dfd 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 79410e7..fadd527 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 c049ddd..d1d338c 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 a0331b0..b39be8e 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 4f4045c..99c14d6 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 );


More information about the Libreoffice-commits mailing list