[Libreoffice-commits] .: 4 commits - sd/inc sd/source

Lubos Lunak llunak at kemper.freedesktop.org
Fri Apr 13 08:02:38 PDT 2012


 sd/inc/drawdoc.hxx          |    6 
 sd/source/core/drawdoc3.cxx |  349 ++++++++++++++++++++++++--------------------
 2 files changed, 197 insertions(+), 158 deletions(-)

New commits:
commit f46debeed6778d65f3d00a5851ca1b9cf37b7d4c
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Mar 27 16:32:31 2012 -0430

    Overload lcl_IterateBookmarkPages to use vector instead of List.

diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 83fa3e7..6342aa8 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -197,6 +197,79 @@ void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDo
 
 /*************************************************************************
 |*
+|* Fuegt ein Bookmark als Seite ein
+|*
+\************************************************************************/
+
+void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDoc,
+                               std::vector<rtl::OUString> &rBookmarkList, sal_uInt16 nBMSdPageCount,
+                               InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator )
+{
+    //
+    // Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
+    //
+    int nPos, nEndPos;
+
+    if( rBookmarkList.empty() )
+    {
+        // no list? whole source document
+        nEndPos = nBMSdPageCount;
+    }
+    else
+    {
+        // bookmark list? number of entries
+        nEndPos = rBookmarkList.size();
+    }
+
+    SdPage* pBMPage;
+
+    // iterate over number of pages to insert
+    for (nPos = 0; nPos < nEndPos; ++nPos)
+    {
+        // the master page associated to the nPos'th page to insert
+        SdPage* pBMMPage = NULL;
+
+        if( rBookmarkList.empty() )
+        {
+            // simply take master page of nPos'th page in source document
+            pBMMPage = (SdPage*)(&(pBookmarkDoc->GetSdPage((sal_uInt16)nPos, PK_STANDARD)->TRG_GetMasterPage()));
+        }
+        else
+        {
+            // fetch nPos'th entry from bookmark list, and determine master page
+            String  aBMPgName(rBookmarkList[nPos]);
+            sal_Bool  bIsMasterPage;
+
+            sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage );
+
+            if (nBMPage != SDRPAGE_NOTFOUND)
+            {
+                pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage);
+            }
+            else
+            {
+                pBMPage = NULL;
+            }
+
+            // enforce that bookmarked page is a standard page and not already a master page
+            if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage())
+            {
+                const sal_uInt16 nBMSdPage = (nBMPage - 1) / 2;
+                pBMMPage = (SdPage*) (&(pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD)->TRG_GetMasterPage()));
+            }
+        }
+
+        // successfully determined valid (bookmarked) page?
+        if( pBMMPage )
+        {
+            // yes, call functor
+            rPageIterator( rDoc, pBMMPage );
+        }
+    }
+}
+
+/*************************************************************************
+|*
 |* Oeffnet ein Bookmark-Dokument
 |*
 \************************************************************************/
commit ad50ae4f3c48a82315f70fff1b9f221e5c74a2da
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Mar 27 14:55:18 2012 -0430

    Remove unneeded headers.

diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 33acf58..83fa3e7 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -34,8 +34,6 @@
 #include "comphelper/anytostring.hxx"
 #include "cppuhelper/exc_hlp.hxx"
 
-#include <utility>
-#include <algorithm>
 #include <vcl/wrkwin.hxx>
 #include <sfx2/docfile.hxx>
 #include <sot/storage.hxx>
@@ -54,9 +52,6 @@
 #include <vcl/msgbox.hxx>
 #include <sot/formats.hxx>
 
-#include <set>
-#include <boost/bind.hpp>
-
 #include "glob.hrc"
 #include "drawdoc.hxx"
 #include "sdpage.hxx"
commit 54388678f593010aa20125cf50c9d084afbdae58
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Mar 27 14:50:29 2012 -0430

    Refactor SdDrawDocument::IterateBookmarkPages.
    
    - Make the function a local function instead of a method.
    - Remove base functor class since we only use one type of functor.
    - Make lcl_IterateBookmarkPages only dependant on FindDuplicateLayout
    functor.

diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 8ff0d3d..b5dd3e2 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -214,8 +214,6 @@ protected:
 
 public:
 
-    class InsertBookmarkAsPage_PageFunctorBase;
-
                         TYPEINFO();
 
     SD_DLLPUBLIC        SdDrawDocument(DocumentType eType, SfxObjectShell* pDocSh);
@@ -331,9 +329,7 @@ public:
     sal_Bool                InsertBookmarkAsObject(List* pBookmarkList, List* pExchangeListL,
                                                 sal_Bool bLink, ::sd::DrawDocShell* pBookmarkDocSh,
                                                 Point* pObjPos);
-    void                IterateBookmarkPages( SdDrawDocument* pBookmarkDoc, List* pBookmarkList,
-                                              sal_uInt16 nBMSdPageCount,
-                                              InsertBookmarkAsPage_PageFunctorBase& rPageIterator );
+
     SD_DLLPUBLIC void   CloseBookmarkDoc();
 
     SdrObject*          GetObj(const String& rObjName) const;
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index d87d66b..33acf58 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -78,6 +78,128 @@
 
 using namespace ::com::sun::star;
 
+/** Concrete incarnations get called by lcl_IterateBookmarkPages, for
+    every page in the bookmark document/list
+ */
+
+class InsertBookmarkAsPage_FindDuplicateLayouts
+{
+public:
+    InsertBookmarkAsPage_FindDuplicateLayouts( std::vector<rtl::OUString> &rLayoutsToTransfer )
+        : mrLayoutsToTransfer(rLayoutsToTransfer) {}
+    void operator()( SdDrawDocument&, SdPage* );
+private:
+    std::vector<rtl::OUString> &mrLayoutsToTransfer;
+};
+
+void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage )
+{
+    // now check for duplicate masterpage and layout names
+    // ===================================================
+
+    String aFullNameLayout( pBMMPage->GetLayoutName() );
+    aFullNameLayout.Erase( aFullNameLayout.SearchAscii( SD_LT_SEPARATOR ));
+
+    rtl::OUString aLayout(aFullNameLayout);
+
+    std::vector<rtl::OUString>::const_iterator pIter =
+            find(mrLayoutsToTransfer.begin(),mrLayoutsToTransfer.end(),aLayout);
+
+    bool bFound = pIter != mrLayoutsToTransfer.end();
+
+    const sal_uInt16 nMPageCount = rDoc.GetMasterPageCount();
+    for (sal_uInt16 nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++)
+    {
+        /**************************************************************
+         * Gibt es die Layouts schon im Dokument?
+         **************************************************************/
+        SdPage* pTestPage = (SdPage*) rDoc.GetMasterPage(nMPage);
+        String aFullTest(pTestPage->GetLayoutName());
+        aFullTest.Erase( aFullTest.SearchAscii( SD_LT_SEPARATOR ));
+
+        rtl::OUString aTest(aFullTest);
+
+        if (aTest == aLayout)
+            bFound = true;
+    }
+
+    if (!bFound)
+        mrLayoutsToTransfer.push_back(aLayout);
+}
+
+/*************************************************************************
+|*
+|* Fuegt ein Bookmark als Seite ein
+|*
+\************************************************************************/
+
+void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDoc,
+                               List* pBookmarkList, sal_uInt16 nBMSdPageCount,
+                               InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator )
+{
+    //
+    // Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
+    //
+    int nPos, nEndPos;
+
+    if( !pBookmarkList )
+    {
+        // no list? whole source document
+        nEndPos = nBMSdPageCount;
+    }
+    else
+    {
+        // bookmark list? number of entries
+        nEndPos = pBookmarkList->Count();
+    }
+
+    SdPage* pBMPage;
+
+    // iterate over number of pages to insert
+    for (nPos = 0; nPos < nEndPos; ++nPos)
+    {
+        // the master page associated to the nPos'th page to insert
+        SdPage* pBMMPage = NULL;
+
+        if( !pBookmarkList )
+        {
+            // simply take master page of nPos'th page in source document
+            pBMMPage = (SdPage*)(&(pBookmarkDoc->GetSdPage((sal_uInt16)nPos, PK_STANDARD)->TRG_GetMasterPage()));
+        }
+        else
+        {
+            // fetch nPos'th entry from bookmark list, and determine master page
+            String  aBMPgName (*(String*) pBookmarkList->GetObject(nPos));
+            sal_Bool    bIsMasterPage;
+
+            sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage );
+
+            if (nBMPage != SDRPAGE_NOTFOUND)
+            {
+                pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage);
+            }
+            else
+            {
+                pBMPage = NULL;
+            }
+
+            // enforce that bookmarked page is a standard page and not already a master page
+            if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage())
+            {
+                const sal_uInt16 nBMSdPage = (nBMPage - 1) / 2;
+                pBMMPage = (SdPage*) (&(pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD)->TRG_GetMasterPage()));
+            }
+        }
+
+        // successfully determined valid (bookmarked) page?
+        if( pBMMPage )
+        {
+            // yes, call functor
+            rPageIterator( rDoc, pBMMPage );
+        }
+    }
+}
+
 /*************************************************************************
 |*
 |* Oeffnet ein Bookmark-Dokument
@@ -247,138 +369,6 @@ sal_Bool SdDrawDocument::InsertBookmark(
     return bOK;
 }
 
-/*************************************************************************
-|*
-|* Fuegt ein Bookmark als Seite ein
-|*
-\************************************************************************/
-
-/** Concrete incarnations get called by IterateBookmarkPages, for
-    every page in the bookmark document/list
- */
-class SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase
-{
-public:
-    virtual ~InsertBookmarkAsPage_PageFunctorBase() = 0;
-    virtual void operator()( SdDrawDocument&, SdPage* ) = 0;
-};
-
-SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase::~InsertBookmarkAsPage_PageFunctorBase()
-{
-}
-
-void SdDrawDocument::IterateBookmarkPages( SdDrawDocument* pBookmarkDoc, List* pBookmarkList, sal_uInt16 nBMSdPageCount,
-                                           SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase& rPageIterator )
-{
-    //
-    // Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
-    //
-    int nPos, nEndPos;
-
-    if( !pBookmarkList )
-    {
-        // no list? whole source document
-        nEndPos = nBMSdPageCount;
-    }
-    else
-    {
-        // bookmark list? number of entries
-        nEndPos = pBookmarkList->Count();
-    }
-
-    SdPage* pBMPage;
-
-    // iterate over number of pages to insert
-    for (nPos = 0; nPos < nEndPos; ++nPos)
-    {
-        // the master page associated to the nPos'th page to insert
-        SdPage* pBMMPage = NULL;
-
-        if( !pBookmarkList )
-        {
-            // simply take master page of nPos'th page in source document
-            pBMMPage = (SdPage*)(&(pBookmarkDoc->GetSdPage((sal_uInt16)nPos, PK_STANDARD)->TRG_GetMasterPage()));
-        }
-        else
-        {
-            // fetch nPos'th entry from bookmark list, and determine master page
-            String  aBMPgName (*(String*) pBookmarkList->GetObject(nPos));
-            sal_Bool    bIsMasterPage;
-
-            sal_uInt16 nBMPage = pBookmarkDoc->GetPageByName( aBMPgName, bIsMasterPage );
-
-            if (nBMPage != SDRPAGE_NOTFOUND)
-            {
-                pBMPage = (SdPage*) pBookmarkDoc->GetPage(nBMPage);
-            }
-            else
-            {
-                pBMPage = NULL;
-            }
-
-            // enforce that bookmarked page is a standard page and not already a master page
-            if (pBMPage && pBMPage->GetPageKind()==PK_STANDARD && !pBMPage->IsMasterPage())
-            {
-                const sal_uInt16 nBMSdPage = (nBMPage - 1) / 2;
-                pBMMPage = (SdPage*) (&(pBookmarkDoc->GetSdPage(nBMSdPage, PK_STANDARD)->TRG_GetMasterPage()));
-            }
-        }
-
-        // successfully determined valid (bookmarked) page?
-        if( pBMMPage )
-        {
-            // yes, call functor
-            rPageIterator( *this, pBMMPage );
-        }
-    }
-}
-
-class InsertBookmarkAsPage_FindDuplicateLayouts : public SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase
-{
-public:
-    InsertBookmarkAsPage_FindDuplicateLayouts( std::vector<rtl::OUString> &rLayoutsToTransfer )
-        : mrLayoutsToTransfer(rLayoutsToTransfer) {}
-    virtual ~InsertBookmarkAsPage_FindDuplicateLayouts() {};
-    virtual void operator()( SdDrawDocument&, SdPage* );
-private:
-    std::vector<rtl::OUString> &mrLayoutsToTransfer;
-};
-
-void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage )
-{
-    // now check for duplicate masterpage and layout names
-    // ===================================================
-
-    String aFullNameLayout( pBMMPage->GetLayoutName() );
-    aFullNameLayout.Erase( aFullNameLayout.SearchAscii( SD_LT_SEPARATOR ));
-
-    rtl::OUString aLayout(aFullNameLayout);
-
-    std::vector<rtl::OUString>::const_iterator pIter =
-            find(mrLayoutsToTransfer.begin(), mrLayoutsToTransfer.end(),aLayout);
-
-    bool bFound = pIter != mrLayoutsToTransfer.end();
-
-    const sal_uInt16 nMPageCount = rDoc.GetMasterPageCount();
-    for (sal_uInt16 nMPage = 0; nMPage < nMPageCount && !bFound; nMPage++)
-    {
-        /**************************************************************
-         * Gibt es die Layouts schon im Dokument?
-         **************************************************************/
-        SdPage* pTestPage = (SdPage*) rDoc.GetMasterPage(nMPage);
-        String aFullTest(pTestPage->GetLayoutName());
-        aFullTest.Erase( aFullTest.SearchAscii( SD_LT_SEPARATOR ));
-
-        rtl::OUString aTest(aFullTest);
-
-        if (aTest == aLayout)
-            bFound = true;
-    }
-
-    if (!bFound)
-        mrLayoutsToTransfer.push_back(aLayout);
-}
-
 sal_Bool SdDrawDocument::InsertBookmarkAsPage(
     List* pBookmarkList,
     List* pExchangeList,            // Liste der zu verwendenen Namen
@@ -500,7 +490,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
     //
     std::vector<rtl::OUString> aLayoutsToTransfer;
     InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( aLayoutsToTransfer );
-    IterateBookmarkPages( pBookmarkDoc, pBookmarkList, nBMSdPageCount, aSearchFunctor );
+    lcl_IterateBookmarkPages( *this, pBookmarkDoc, pBookmarkList, nBMSdPageCount, aSearchFunctor );
 
 
     /**************************************************************************
commit 8fffd99aba75ec517fc7d2d9a85c8a23fb58c986
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Tue Mar 27 12:43:56 2012 -0430

    Remove unused InsertBookmarkAsPage_AddBookmarkedPages functor.

diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 91a0570..d87d66b 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -379,21 +379,6 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
         mrLayoutsToTransfer.push_back(aLayout);
 }
 
-/** Just add one page to the container given to the constructor.
-*/
-class InsertBookmarkAsPage_AddBookmarkedPages
-    : public SdDrawDocument::InsertBookmarkAsPage_PageFunctorBase
-{
-public:
-    InsertBookmarkAsPage_AddBookmarkedPages(::std::vector<SdPage*>& rContainer)
-        : mrContainer(rContainer) {}
-    ~InsertBookmarkAsPage_AddBookmarkedPages(void) {}
-    void operator() (SdDrawDocument&, SdPage* pPage) { mrContainer.push_back(pPage); }
-private:
-    ::std::vector<SdPage*>& mrContainer;
-};
-
-
 sal_Bool SdDrawDocument::InsertBookmarkAsPage(
     List* pBookmarkList,
     List* pExchangeList,            // Liste der zu verwendenen Namen


More information about the Libreoffice-commits mailing list