summaryrefslogtreecommitdiff
path: root/sd/source/ui/toolpanel
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2010-10-19 09:05:06 +0200
committerDavid Tardon <dtardon@redhat.com>2010-10-19 09:07:19 +0200
commit2f20e05065b41975647c6399d3b2165bf812975d (patch)
tree62fcdf2227c146ddf0a1ca90dc717def3690ae53 /sd/source/ui/toolpanel
parentd59cf6fc6be6edf0dec082c7da98b4ca91839120 (diff)
remove do {...} while (false) spanning whole func.
Diffstat (limited to 'sd/source/ui/toolpanel')
-rw-r--r--sd/source/ui/toolpanel/controls/DocumentHelper.cxx84
-rw-r--r--sd/source/ui/toolpanel/controls/MasterPagesSelector.cxx79
-rw-r--r--sd/source/ui/toolpanel/controls/RecentlyUsedMasterPages.cxx196
3 files changed, 169 insertions, 190 deletions
diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx
index 72c723a1831a..c8f3cde1253f 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 923d3911c2b0..d178ffb06760 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 5e65205bfc34..7a685ca76cd7 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&)
{