[Libreoffice-commits] .: 2 commits - sd/source

David Tardon dtardon at kemper.freedesktop.org
Tue Oct 19 00:07:31 PDT 2010


 sd/source/ui/toolpanel/controls/DocumentHelper.cxx          |   84 ++---
 sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx     |   79 ++--
 sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx |  196 +++++-------
 3 files changed, 169 insertions(+), 190 deletions(-)

New commits:
commit abf2dfbf66cfd91d13eb1695651846c76b2a43a2
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Oct 19 09:05:06 2010 +0200

    remove do {...} while (false) spanning whole func.

diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
index c8eb69b..c315dac 100644
--- a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
+++ b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
@@ -312,59 +312,55 @@ void DocumentHelper::AssignMasterPageToPageList (
     SdPage* pMasterPage,
     const ::boost::shared_ptr<std::vector<SdPage*> >& rpPageList)
 {
-    do
-    {
-        if (pMasterPage == NULL || !pMasterPage->IsMasterPage())
-            break;
+    if (pMasterPage == NULL || !pMasterPage->IsMasterPage())
+        return;
 
-        // Make the layout name by stripping ouf the layout postfix from the
-        // layout name of the given master page.
-        String sFullLayoutName (pMasterPage->GetLayoutName());
-        String sBaseLayoutName (sFullLayoutName);
-        sBaseLayoutName.Erase (sBaseLayoutName.SearchAscii (SD_LT_SEPARATOR));
+    // Make the layout name by stripping ouf the layout postfix from the
+    // layout name of the given master page.
+    String sFullLayoutName (pMasterPage->GetLayoutName());
+    String sBaseLayoutName (sFullLayoutName);
+    sBaseLayoutName.Erase (sBaseLayoutName.SearchAscii (SD_LT_SEPARATOR));
 
-        if (rpPageList->empty())
-            break;
+    if (rpPageList->empty())
+        return;
 
-        // Create a second list that contains only the valid pointers to
-        // pages for which an assignment is necessary.
-        ::std::vector<SdPage*>::const_iterator iPage;
-        ::std::vector<SdPage*> aCleanedList;
-        for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage)
+    // Create a second list that contains only the valid pointers to
+    // pages for which an assignment is necessary.
+    ::std::vector<SdPage*>::const_iterator iPage;
+    ::std::vector<SdPage*> aCleanedList;
+    for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage)
+    {
+        OSL_ASSERT(*iPage!=NULL && (*iPage)->GetModel() == &rTargetDocument);
+        if (*iPage != NULL
+            && (*iPage)->GetLayoutName().CompareTo(sFullLayoutName)!=0)
         {
-            OSL_ASSERT(*iPage!=NULL && (*iPage)->GetModel() == &rTargetDocument);
-            if (*iPage != NULL
-                && (*iPage)->GetLayoutName().CompareTo(sFullLayoutName)!=0)
-            {
-                aCleanedList.push_back(*iPage);
-            }
+            aCleanedList.push_back(*iPage);
         }
-        if (aCleanedList.size() == 0)
-            break;
+    }
+    if (aCleanedList.size() == 0)
+        return;
 
-        SfxUndoManager* pUndoMgr = rTargetDocument.GetDocSh()->GetUndoManager();
-        if( pUndoMgr )
-            pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
+    SfxUndoManager* pUndoMgr = rTargetDocument.GetDocSh()->GetUndoManager();
+    if( pUndoMgr )
+        pUndoMgr->EnterListAction(String(SdResId(STR_UNDO_SET_PRESLAYOUT)), String());
 
-        SdPage* pMasterPageInDocument = ProvideMasterPage(rTargetDocument,pMasterPage,rpPageList);
-        if (pMasterPageInDocument == NULL)
-            break;
-
-        // Assign the master pages to the given list of pages.
-        for (iPage=aCleanedList.begin(); 
-             iPage!=aCleanedList.end(); 
-             ++iPage)
-        {
-            AssignMasterPageToPage (
-                pMasterPageInDocument,
-                sBaseLayoutName,
-                *iPage);
-        }
+    SdPage* pMasterPageInDocument = ProvideMasterPage(rTargetDocument,pMasterPage,rpPageList);
+    if (pMasterPageInDocument == NULL)
+        return;
 
-        if( pUndoMgr )
-            pUndoMgr->LeaveListAction();
+    // Assign the master pages to the given list of pages.
+    for (iPage=aCleanedList.begin();
+            iPage!=aCleanedList.end();
+            ++iPage)
+    {
+        AssignMasterPageToPage (
+            pMasterPageInDocument,
+            sBaseLayoutName,
+            *iPage);
     }
-    while (false);
+
+    if( pUndoMgr )
+        pUndoMgr->LeaveListAction();
 }
 
 
diff --git a/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx b/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx
index 4392302..10db80a 100644
--- a/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx
+++ b/sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx
@@ -344,34 +344,30 @@ SdPage* MasterPagesSelector::GetSelectedMasterPage (void)
 */
 void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage)
 {
-    do
+    if (pMasterPage == NULL)
+        return;
+
+    USHORT nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
+    if (nPageCount == 0)
+        return;
+
+    // Get a list of all pages.  As a little optimization we only
+    // include pages that do not already have the given master page
+    // assigned.
+    String sFullLayoutName (pMasterPage->GetLayoutName());
+    ::sd::slidesorter::SharedPageSelection pPageList (
+        new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
+    for (USHORT nPageIndex=0; nPageIndex<nPageCount; nPageIndex++)
     {
-        if (pMasterPage == NULL)
-            break;
-
-        USHORT nPageCount = mrDocument.GetSdPageCount(PK_STANDARD);
-        if (nPageCount == 0)
-            break;
-
-        // Get a list of all pages.  As a little optimization we only
-        // include pages that do not already have the given master page
-        // assigned.
-        String sFullLayoutName (pMasterPage->GetLayoutName());
-        ::sd::slidesorter::SharedPageSelection pPageList (
-            new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
-        for (USHORT nPageIndex=0; nPageIndex<nPageCount; nPageIndex++)
+        SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD);
+        if (pPage != NULL
+            && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0)
         {
-            SdPage* pPage = mrDocument.GetSdPage (nPageIndex, PK_STANDARD);
-            if (pPage != NULL
-                && pPage->GetLayoutName().CompareTo(sFullLayoutName)!=0)
-            {
-                pPageList->push_back (pPage);
-            }
+            pPageList->push_back (pPage);
         }
-
-        AssignMasterPageToPageList(pMasterPage, pPageList);
     }
-    while (false);
+
+    AssignMasterPageToPageList(pMasterPage, pPageList);
 }
 
 
@@ -383,31 +379,26 @@ void MasterPagesSelector::AssignMasterPageToAllSlides (SdPage* pMasterPage)
 void MasterPagesSelector::AssignMasterPageToSelectedSlides (
     SdPage* pMasterPage)
 {
-    do
-    {
-        using namespace ::std;
-        using namespace ::sd::slidesorter;
-        using namespace ::sd::slidesorter::controller;
+    using namespace ::sd::slidesorter;
+    using namespace ::sd::slidesorter::controller;
 
-        if (pMasterPage == NULL)
-            break;
+    if (pMasterPage == NULL)
+        return;
 
-        // Find a visible slide sorter.
-        SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
-        if (pSlideSorter == NULL)
-            break;
+    // Find a visible slide sorter.
+    SlideSorterViewShell* pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
+    if (pSlideSorter == NULL)
+        return;
 
-        // Get a list of selected pages.
-        ::sd::slidesorter::SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection();
-        if (pPageSelection->empty())
-            break;
+    // Get a list of selected pages.
+    SharedPageSelection pPageSelection = pSlideSorter->GetPageSelection();
+    if (pPageSelection->empty())
+        return;
 
-        AssignMasterPageToPageList(pMasterPage, pPageSelection);
+    AssignMasterPageToPageList(pMasterPage, pPageSelection);
 
-        // Restore the previous selection.
-        pSlideSorter->SetPageSelection(pPageSelection);
-    }
-    while (false);
+    // Restore the previous selection.
+    pSlideSorter->SetPageSelection(pPageSelection);
 }
 
 
diff --git a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx b/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx
index 32a582c..1dd5109 100644
--- a/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx
+++ b/sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx
@@ -188,64 +188,60 @@ void RecentlyUsedMasterPages::LoadPersistentValues (void)
 {
     try
     {
-        do
+        tools::ConfigurationAccess aConfiguration (
+            GetPathToImpressConfigurationRoot(),
+            tools::ConfigurationAccess::READ_ONLY);
+        Reference<container::XNameAccess> xSet (
+            aConfiguration.GetConfigurationNode(GetPathToSetNode()),
+            UNO_QUERY);
+        if ( ! xSet.is())
+            return;
+
+        const String sURLMemberName (OUString::createFromAscii("URL"));
+        const String sNameMemberName (OUString::createFromAscii("Name"));
+        OUString sURL;
+        OUString sName;
+
+        // Read the names and URLs of the master pages.
+        Sequence<OUString> aKeys (xSet->getElementNames());
+        mpMasterPages->clear();
+        mpMasterPages->reserve(aKeys.getLength());
+        for (int i=0; i<aKeys.getLength(); i++)
         {
-            tools::ConfigurationAccess aConfiguration (
-                GetPathToImpressConfigurationRoot(),
-                tools::ConfigurationAccess::READ_ONLY);
-            Reference<container::XNameAccess> xSet (
-                aConfiguration.GetConfigurationNode(GetPathToSetNode()),
-                UNO_QUERY);
-            if ( ! xSet.is())
-                break;
-
-            const String sURLMemberName (OUString::createFromAscii("URL"));
-            const String sNameMemberName (OUString::createFromAscii("Name"));
-            OUString sURL;
-            OUString sName;
-
-            // Read the names and URLs of the master pages.
-            Sequence<OUString> aKeys (xSet->getElementNames());
-            mpMasterPages->clear();
-            mpMasterPages->reserve(aKeys.getLength());
-            for (int i=0; i<aKeys.getLength(); i++)
+            Reference<container::XNameAccess> xSetItem (
+                xSet->getByName(aKeys[i]), UNO_QUERY);
+            if (xSetItem.is())
             {
-                Reference<container::XNameAccess> xSetItem (
-                    xSet->getByName(aKeys[i]), UNO_QUERY);
-                if (xSetItem.is())
-                {
-                    Any aURL (xSetItem->getByName(sURLMemberName));
-                    Any aName (xSetItem->getByName(sNameMemberName));
-                    aURL >>= sURL;
-                    aName >>= sName;
-                    SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
-                        MasterPageContainer::TEMPLATE,
-                        -1,
-                        sURL,
-                        String(),
-                        sName,
-                        false,
-                        ::boost::shared_ptr<PageObjectProvider>(
-                            new TemplatePageObjectProvider(sURL)),
-                        ::boost::shared_ptr<PreviewProvider>(
-                            new TemplatePreviewProvider(sURL))));
-                    // For user supplied templates we use a different
-                    // preview provider: The preview in the document shows
-                    // not only shapes on the master page but also shapes on
-                    // the foreground.  This is misleading and therefore
-                    // these previews are discarded and created directly
-                    // from the page objects.
-                    if (pDescriptor->GetURLClassification() == MasterPageDescriptor::URLCLASS_USER)
-                        pDescriptor->mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>(
-                            new PagePreviewProvider());
-                    MasterPageContainer::Token aToken (mpContainer->PutMasterPage(pDescriptor));
-                    mpMasterPages->push_back(Descriptor(aToken,sURL,sName));
-                }
+                Any aURL (xSetItem->getByName(sURLMemberName));
+                Any aName (xSetItem->getByName(sNameMemberName));
+                aURL >>= sURL;
+                aName >>= sName;
+                SharedMasterPageDescriptor pDescriptor (new MasterPageDescriptor(
+                    MasterPageContainer::TEMPLATE,
+                    -1,
+                    sURL,
+                    String(),
+                    sName,
+                    false,
+                    ::boost::shared_ptr<PageObjectProvider>(
+                        new TemplatePageObjectProvider(sURL)),
+                    ::boost::shared_ptr<PreviewProvider>(
+                        new TemplatePreviewProvider(sURL))));
+                // For user supplied templates we use a different
+                // preview provider: The preview in the document shows
+                // not only shapes on the master page but also shapes on
+                // the foreground.  This is misleading and therefore
+                // these previews are discarded and created directly
+                // from the page objects.
+                if (pDescriptor->GetURLClassification() == MasterPageDescriptor::URLCLASS_USER)
+                    pDescriptor->mpPreviewProvider = ::boost::shared_ptr<PreviewProvider>(
+                        new PagePreviewProvider());
+                MasterPageContainer::Token aToken (mpContainer->PutMasterPage(pDescriptor));
+                mpMasterPages->push_back(Descriptor(aToken,sURL,sName));
             }
-
-            ResolveList();
         }
-        while (false);
+
+        ResolveList();
     }
     catch (Exception&)
     {
@@ -260,58 +256,54 @@ void RecentlyUsedMasterPages::SavePersistentValues (void)
 {
     try
     {
-        do
+        tools::ConfigurationAccess aConfiguration (
+            GetPathToImpressConfigurationRoot(),
+            tools::ConfigurationAccess::READ_WRITE);
+        Reference<container::XNameContainer> xSet (
+            aConfiguration.GetConfigurationNode(GetPathToSetNode()),
+            UNO_QUERY);
+        if ( ! xSet.is())
+            return;
+
+        // Clear the set.
+        Sequence<OUString> aKeys (xSet->getElementNames());
+        sal_Int32 i;
+        for (i=0; i<aKeys.getLength(); i++)
+            xSet->removeByName (aKeys[i]);
+
+        // Fill it with the URLs of this object.
+        const String sURLMemberName (OUString::createFromAscii("URL"));
+        const String sNameMemberName (OUString::createFromAscii("Name"));
+        Any aValue;
+        Reference<lang::XSingleServiceFactory> xChildFactory (
+            xSet, UNO_QUERY);
+        if ( ! xChildFactory.is())
+            return;
+        MasterPageList::const_iterator iDescriptor;
+        sal_Int32 nIndex(0);
+        for (iDescriptor=mpMasterPages->begin();
+                iDescriptor!=mpMasterPages->end();
+                ++iDescriptor,++nIndex)
         {
-            tools::ConfigurationAccess aConfiguration (
-                GetPathToImpressConfigurationRoot(),
-                tools::ConfigurationAccess::READ_WRITE);
-            Reference<container::XNameContainer> xSet (
-                aConfiguration.GetConfigurationNode(GetPathToSetNode()),
-                UNO_QUERY);
-            if ( ! xSet.is())
-                break;
-
-            // Clear the set.
-            Sequence<OUString> aKeys (xSet->getElementNames());
-            sal_Int32 i;
-            for (i=0; i<aKeys.getLength(); i++)
-                xSet->removeByName (aKeys[i]);
-
-            // Fill it with the URLs of this object.
-            const String sURLMemberName (OUString::createFromAscii("URL"));
-            const String sNameMemberName (OUString::createFromAscii("Name"));
-            Any aValue;
-            Reference<lang::XSingleServiceFactory> xChildFactory (
-                xSet, UNO_QUERY);
-            if ( ! xChildFactory.is())
-                break;
-            MasterPageList::const_iterator iDescriptor;
-            sal_Int32 nIndex(0);
-            for (iDescriptor=mpMasterPages->begin();
-                 iDescriptor!=mpMasterPages->end();
-                 ++iDescriptor,++nIndex)
+            // Create new child.
+            OUString sKey (OUString::createFromAscii("index_"));
+            sKey += OUString::valueOf(nIndex);
+            Reference<container::XNameReplace> xChild(
+                xChildFactory->createInstance(), UNO_QUERY);
+            if (xChild.is())
             {
-                // Create new child.
-                OUString sKey (OUString::createFromAscii("index_"));
-                sKey += OUString::valueOf(nIndex);
-                Reference<container::XNameReplace> xChild(
-                    xChildFactory->createInstance(), UNO_QUERY);
-                if (xChild.is())
-                {
-                    xSet->insertByName (sKey, makeAny(xChild));
-
-                    aValue <<= OUString(iDescriptor->msURL);
-                    xChild->replaceByName (sURLMemberName, aValue);
-
-                    aValue <<= OUString(iDescriptor->msName);
-                    xChild->replaceByName (sNameMemberName, aValue);
-                }
-            }
+                xSet->insertByName (sKey, makeAny(xChild));
 
-            // Write the data back to disk.
-            aConfiguration.CommitChanges();
+                aValue <<= OUString(iDescriptor->msURL);
+                xChild->replaceByName (sURLMemberName, aValue);
+
+                aValue <<= OUString(iDescriptor->msName);
+                xChild->replaceByName (sNameMemberName, aValue);
+            }
         }
-        while (false);
+
+        // Write the data back to disk.
+        aConfiguration.CommitChanges();
     }
     catch (Exception&)
     {
commit 0765504fad2bec9b95bfebd6272286beada9899b
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Oct 19 08:49:22 2010 +0200

    fix obviously incorrect condition

diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
index dd13c4d..c8eb69b 100644
--- a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
+++ b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
@@ -314,7 +314,7 @@ void DocumentHelper::AssignMasterPageToPageList (
 {
     do
     {
-        if (pMasterPage == NULL && pMasterPage->IsMasterPage())
+        if (pMasterPage == NULL || !pMasterPage->IsMasterPage())
             break;
 
         // Make the layout name by stripping ouf the layout postfix from the


More information about the Libreoffice-commits mailing list