diff options
author | David Tardon <dtardon@redhat.com> | 2010-10-19 09:41:43 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2010-10-19 09:41:43 +0200 |
commit | 9167a2bb957b398f35808d3585e9426f7383a885 (patch) | |
tree | 621169bfc60d0b09814441c2d50d2621e8e2013a /sd/source | |
parent | 2f20e05065b41975647c6399d3b2165bf812975d (diff) |
remove do {...} while (false) spanning whole func.
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx | 84 | ||||
-rw-r--r-- | sd/source/ui/slidesorter/controller/SlideSorterController.cxx | 66 | ||||
-rw-r--r-- | sd/source/ui/unoidl/SdUnoDrawView.cxx | 28 | ||||
-rw-r--r-- | sd/source/ui/view/FormShellManager.cxx | 96 | ||||
-rw-r--r-- | sd/source/ui/view/ViewClipboard.cxx | 92 | ||||
-rw-r--r-- | sd/source/ui/view/ViewShellManager.cxx | 92 |
6 files changed, 213 insertions, 245 deletions
diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx index 39c41dd0756b..517e973896b3 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx @@ -89,50 +89,46 @@ CacheConfiguration::CacheConfiguration (void) try { - do - { - // Obtain access to the configuration. - Reference<lang::XMultiServiceFactory> xProvider ( - ::comphelper::getProcessServiceFactory()->createInstance( - sConfigurationProviderServiceName), - UNO_QUERY); - if ( ! xProvider.is()) - break; - - // Obtain access to Impress configuration. - Sequence<Any> aCreationArguments(3); - aCreationArguments[0] = makeAny(beans::PropertyValue( - ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("nodepath")), - 0, - makeAny(sPathToImpressConfigurationRoot), - beans::PropertyState_DIRECT_VALUE)); - aCreationArguments[1] = makeAny(beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), - 0, - makeAny((sal_Int32)-1), - beans::PropertyState_DIRECT_VALUE)); - aCreationArguments[2] = makeAny(beans::PropertyValue( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), - 0, - makeAny(true), - beans::PropertyState_DIRECT_VALUE)); - ::rtl::OUString sAccessService (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationAccess"))); - Reference<XInterface> xRoot (xProvider->createInstanceWithArguments( - sAccessService, aCreationArguments)); - if ( ! xRoot.is()) - break; - Reference<container::XHierarchicalNameAccess> xHierarchy (xRoot, UNO_QUERY); - if ( ! xHierarchy.is()) - break; - - // Get the node for the slide sorter preview cache. - mxCacheNode = Reference<container::XNameAccess>( - xHierarchy->getByHierarchicalName(sPathToNode), - UNO_QUERY); - } - while (false); + // Obtain access to the configuration. + Reference<lang::XMultiServiceFactory> xProvider ( + ::comphelper::getProcessServiceFactory()->createInstance( + sConfigurationProviderServiceName), + UNO_QUERY); + if ( ! xProvider.is()) + return; + + // Obtain access to Impress configuration. + Sequence<Any> aCreationArguments(3); + aCreationArguments[0] = makeAny(beans::PropertyValue( + ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("nodepath")), + 0, + makeAny(sPathToImpressConfigurationRoot), + beans::PropertyState_DIRECT_VALUE)); + aCreationArguments[1] = makeAny(beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), + 0, + makeAny((sal_Int32)-1), + beans::PropertyState_DIRECT_VALUE)); + aCreationArguments[2] = makeAny(beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), + 0, + makeAny(true), + beans::PropertyState_DIRECT_VALUE)); + ::rtl::OUString sAccessService (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess"))); + Reference<XInterface> xRoot (xProvider->createInstanceWithArguments( + sAccessService, aCreationArguments)); + if ( ! xRoot.is()) + return; + Reference<container::XHierarchicalNameAccess> xHierarchy (xRoot, UNO_QUERY); + if ( ! xHierarchy.is()) + return; + + // Get the node for the slide sorter preview cache. + mxCacheNode = Reference<container::XNameAccess>( + xHierarchy->getByHierarchicalName(sPathToNode), + UNO_QUERY); } catch (RuntimeException aException) { diff --git a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx index 2d10ddb97fb7..baccbfd51a1e 100644 --- a/sd/source/ui/slidesorter/controller/SlideSorterController.cxx +++ b/sd/source/ui/slidesorter/controller/SlideSorterController.cxx @@ -886,45 +886,41 @@ void SlideSorterController::PageNameHasChanged (int nPageIndex, const String& rs // Get a pointer to the corresponding accessible object and notify // that of the name change. - do - { - ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); - if (pWindow == NULL) - break; + ::sd::Window* pWindow = mrSlideSorter.GetActiveWindow(); + if (pWindow == NULL) + return; - ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > - xAccessible (pWindow->GetAccessible(FALSE)); - if ( ! xAccessible.is()) - break; + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > + xAccessible (pWindow->GetAccessible(FALSE)); + if ( ! xAccessible.is()) + return; - // Now comes a small hack. We assume that the accessible object is - // an instantiation of AccessibleSlideSorterView and cast it to that - // class. The cleaner alternative to this cast would be a new member - // in which we would store the last AccessibleSlideSorterView object - // created by SlideSorterViewShell::CreateAccessibleDocumentView(). - // But then there is no guaranty that the accessible object obtained - // from the window really is that instance last created by - // CreateAccessibleDocumentView(). - // However, the dynamic cast together with the check of the result - // being NULL should be safe enough. - ::accessibility::AccessibleSlideSorterView* pAccessibleView - = dynamic_cast< ::accessibility::AccessibleSlideSorterView*>(xAccessible.get()); - if (pAccessibleView == NULL) - break; + // Now comes a small hack. We assume that the accessible object is + // an instantiation of AccessibleSlideSorterView and cast it to that + // class. The cleaner alternative to this cast would be a new member + // in which we would store the last AccessibleSlideSorterView object + // created by SlideSorterViewShell::CreateAccessibleDocumentView(). + // But then there is no guaranty that the accessible object obtained + // from the window really is that instance last created by + // CreateAccessibleDocumentView(). + // However, the dynamic cast together with the check of the result + // being NULL should be safe enough. + ::accessibility::AccessibleSlideSorterView* pAccessibleView + = dynamic_cast< ::accessibility::AccessibleSlideSorterView*>(xAccessible.get()); + if (pAccessibleView == NULL) + return; - ::accessibility::AccessibleSlideSorterObject* pChild - = pAccessibleView->GetAccessibleChildImplementation(nPageIndex); - if (pChild == NULL || pChild->GetPage() == NULL) - break; + ::accessibility::AccessibleSlideSorterObject* pChild + = pAccessibleView->GetAccessibleChildImplementation(nPageIndex); + if (pChild == NULL || pChild->GetPage() == NULL) + return; - ::rtl::OUString sOldName (rsOldName); - ::rtl::OUString sNewName (pChild->GetPage()->GetName()); - pChild->FireAccessibleEvent( - ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED, - makeAny(sOldName), - makeAny(sNewName)); - } - while (false); + ::rtl::OUString sOldName (rsOldName); + ::rtl::OUString sNewName (pChild->GetPage()->GetName()); + pChild->FireAccessibleEvent( + ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED, + makeAny(sOldName), + makeAny(sNewName)); } diff --git a/sd/source/ui/unoidl/SdUnoDrawView.cxx b/sd/source/ui/unoidl/SdUnoDrawView.cxx index a4df6184cab7..d711b5a497aa 100644 --- a/sd/source/ui/unoidl/SdUnoDrawView.cxx +++ b/sd/source/ui/unoidl/SdUnoDrawView.cxx @@ -165,25 +165,21 @@ Reference<drawing::XLayer> SdUnoDrawView::getActiveLayer (void) throw () void SdUnoDrawView::setActiveLayer (const Reference<drawing::XLayer>& rxLayer) throw () { - do - { - // Get the SdrLayer object corresponding to the given reference. - if ( ! rxLayer.is()) - break; + // Get the SdrLayer object corresponding to the given reference. + if ( ! rxLayer.is()) + return; - SdLayer* pLayer = SdLayer::getImplementation (rxLayer); - if (pLayer == NULL) - break; + SdLayer* pLayer = SdLayer::getImplementation (rxLayer); + if (pLayer == NULL) + return; - SdrLayer* pSdrLayer = pLayer->GetSdrLayer(); - if (pSdrLayer == NULL) - break; + SdrLayer* pSdrLayer = pLayer->GetSdrLayer(); + if (pSdrLayer == NULL) + return; - // Set the new active layer and make the change visible. - mrView.SetActiveLayer (pSdrLayer->GetName()); - mrDrawViewShell.ResetActualLayer (); - } - while (false); + // Set the new active layer and make the change visible. + mrView.SetActiveLayer (pSdrLayer->GetName()); + mrDrawViewShell.ResetActualLayer (); } diff --git a/sd/source/ui/view/FormShellManager.cxx b/sd/source/ui/view/FormShellManager.cxx index 3ad684162ed0..f5890b14fffd 100644 --- a/sd/source/ui/view/FormShellManager.cxx +++ b/sd/source/ui/view/FormShellManager.cxx @@ -158,70 +158,62 @@ FmFormShell* FormShellManager::GetFormShell (void) void FormShellManager::RegisterAtCenterPane (void) { - do - { - ViewShell* pShell = mrBase.GetMainViewShell().get(); - if (pShell == NULL) - break; + ViewShell* pShell = mrBase.GetMainViewShell().get(); + if (pShell == NULL) + return; + + // No form shell for the slide sorter. Besides that it is not + // necessary, using both together results in crashes. + if (pShell->GetShellType() == ViewShell::ST_SLIDE_SORTER) + return; + + mpMainViewShellWindow = pShell->GetActiveWindow(); + if (mpMainViewShellWindow == NULL) + return; + + // Register at the window to get informed when to move the form + // shell to the bottom of the shell stack. + mpMainViewShellWindow->AddEventListener( + LINK( + this, + FormShellManager, + WindowEventHandler)); + + // Create a shell factory and with it activate the form shell. + OSL_ASSERT(mpSubShellFactory.get()==NULL); + mpSubShellFactory.reset(new FormShellManagerFactory(*pShell, *this)); + mrBase.GetViewShellManager()->AddSubShellFactory(pShell,mpSubShellFactory); + mrBase.GetViewShellManager()->ActivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX); +} - // No form shell for the slide sorter. Besides that it is not - // necessary, using both together results in crashes. - if (pShell->GetShellType() == ViewShell::ST_SLIDE_SORTER) - break; - mpMainViewShellWindow = pShell->GetActiveWindow(); - if (mpMainViewShellWindow == NULL) - break; - // Register at the window to get informed when to move the form - // shell to the bottom of the shell stack. - mpMainViewShellWindow->AddEventListener( + +void FormShellManager::UnregisterAtCenterPane (void) +{ + if (mpMainViewShellWindow != NULL) + { + // Unregister from the window. + mpMainViewShellWindow->RemoveEventListener( LINK( this, FormShellManager, WindowEventHandler)); - - // Create a shell factory and with it activate the form shell. - OSL_ASSERT(mpSubShellFactory.get()==NULL); - mpSubShellFactory.reset(new FormShellManagerFactory(*pShell, *this)); - mrBase.GetViewShellManager()->AddSubShellFactory(pShell,mpSubShellFactory); - mrBase.GetViewShellManager()->ActivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX); + mpMainViewShellWindow = NULL; } - while (false); -} - - + // Unregister form at the form shell. + SetFormShell(NULL); -void FormShellManager::UnregisterAtCenterPane (void) -{ - do + // Deactivate the form shell and destroy the shell factory. + ViewShell* pShell = mrBase.GetMainViewShell().get(); + if (pShell != NULL) { - if (mpMainViewShellWindow != NULL) - { - // Unregister from the window. - mpMainViewShellWindow->RemoveEventListener( - LINK( - this, - FormShellManager, - WindowEventHandler)); - mpMainViewShellWindow = NULL; - } - - // Unregister form at the form shell. - SetFormShell(NULL); - - // Deactivate the form shell and destroy the shell factory. - ViewShell* pShell = mrBase.GetMainViewShell().get(); - if (pShell != NULL) - { - mrBase.GetViewShellManager()->DeactivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX); - mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell, mpSubShellFactory); - } - - mpSubShellFactory.reset(); + mrBase.GetViewShellManager()->DeactivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX); + mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell, mpSubShellFactory); } - while (false); + + mpSubShellFactory.reset(); } diff --git a/sd/source/ui/view/ViewClipboard.cxx b/sd/source/ui/view/ViewClipboard.cxx index e26b41e6f460..7e2fb0f6cb89 100644 --- a/sd/source/ui/view/ViewClipboard.cxx +++ b/sd/source/ui/view/ViewClipboard.cxx @@ -140,54 +140,50 @@ void ViewClipboard::AssignMasterPage ( const SdTransferable& rTransferable, SdPage* pMasterPage) { - do - { - if (pMasterPage == NULL) - return; - - // Get the target page to which the master page is assigned. - SdrPageView* pPageView = mrView.GetSdrPageView(); - if (pPageView == NULL) - break; - - SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage()); - if (pPage == NULL) - break; - - SdDrawDocument* pDocument = mrView.GetDoc(); - if (pDocument == NULL) - break; - - if ( ! rTransferable.HasPageBookmarks()) - break; - - DrawDocShell* pDataDocShell = rTransferable.GetPageDocShell(); - if (pDataDocShell == NULL) - break; - - SdDrawDocument* pSourceDocument = pDataDocShell->GetDoc(); - if (pSourceDocument == NULL) - break; - - // We have to remove the layout suffix from the layout name which is - // appended again by SetMasterPage() to the given name. Don't ask. - String sLayoutSuffix (RTL_CONSTASCII_STRINGPARAM(SD_LT_SEPARATOR)); - sLayoutSuffix.Append (SdResId(STR_LAYOUT_OUTLINE)); - USHORT nLength = sLayoutSuffix.Len(); - String sLayoutName (pMasterPage->GetLayoutName()); - if (String(sLayoutName, sLayoutName.Len()-nLength, nLength).Equals ( - sLayoutSuffix)) - sLayoutName = String(sLayoutName, 0, sLayoutName.Len()-nLength); - - pDocument->SetMasterPage ( - pPage->GetPageNum() / 2, - sLayoutName, - pSourceDocument, - FALSE, // Exchange the master page of only the target page. - FALSE // Keep unused master pages. - ); - } - while (false); + if (pMasterPage == NULL) + return; + + // Get the target page to which the master page is assigned. + SdrPageView* pPageView = mrView.GetSdrPageView(); + if (pPageView == NULL) + return; + + SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage()); + if (pPage == NULL) + return; + + SdDrawDocument* pDocument = mrView.GetDoc(); + if (pDocument == NULL) + return; + + if ( ! rTransferable.HasPageBookmarks()) + return; + + DrawDocShell* pDataDocShell = rTransferable.GetPageDocShell(); + if (pDataDocShell == NULL) + return; + + SdDrawDocument* pSourceDocument = pDataDocShell->GetDoc(); + if (pSourceDocument == NULL) + return; + + // We have to remove the layout suffix from the layout name which is + // appended again by SetMasterPage() to the given name. Don't ask. + String sLayoutSuffix (RTL_CONSTASCII_STRINGPARAM(SD_LT_SEPARATOR)); + sLayoutSuffix.Append (SdResId(STR_LAYOUT_OUTLINE)); + USHORT nLength = sLayoutSuffix.Len(); + String sLayoutName (pMasterPage->GetLayoutName()); + if (String(sLayoutName, sLayoutName.Len()-nLength, nLength).Equals ( + sLayoutSuffix)) + sLayoutName = String(sLayoutName, 0, sLayoutName.Len()-nLength); + + pDocument->SetMasterPage ( + pPage->GetPageNum() / 2, + sLayoutName, + pSourceDocument, + FALSE, // Exchange the master page of only the target page. + FALSE // Keep unused master pages. + ); } diff --git a/sd/source/ui/view/ViewShellManager.cxx b/sd/source/ui/view/ViewShellManager.cxx index b38b5f5a4e2f..fa7c63077280 100644 --- a/sd/source/ui/view/ViewShellManager.cxx +++ b/sd/source/ui/view/ViewShellManager.cxx @@ -651,34 +651,30 @@ void ViewShellManager::Implementation::ActivateSubShell ( { ::osl::MutexGuard aGuard (maMutex); - do - { - // Check that the given view shell is active. - ActiveShellList::iterator iShell (::std::find_if ( - maActiveViewShells.begin(), - maActiveViewShells.end(), - IsShell(&rParentShell))); - if (iShell == maActiveViewShells.end()) - break; - - // Create the sub shell list if it does not yet exist. - SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); - if (iList == maActiveSubShells.end()) - iList = maActiveSubShells.insert( - SubShellList::value_type(&rParentShell,SubShellSubList())).first; + // Check that the given view shell is active. + ActiveShellList::iterator iShell (::std::find_if ( + maActiveViewShells.begin(), + maActiveViewShells.end(), + IsShell(&rParentShell))); + if (iShell == maActiveViewShells.end()) + return; - // Do not activate an object bar that is already active. Requesting - // this is not exactly an error but may be an indication of one. - SubShellSubList& rList (iList->second); - if (::std::find_if(rList.begin(),rList.end(), IsId(nId)) != rList.end()) - break; + // Create the sub shell list if it does not yet exist. + SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); + if (iList == maActiveSubShells.end()) + iList = maActiveSubShells.insert( + SubShellList::value_type(&rParentShell,SubShellSubList())).first; + + // Do not activate an object bar that is already active. Requesting + // this is not exactly an error but may be an indication of one. + SubShellSubList& rList (iList->second); + if (::std::find_if(rList.begin(),rList.end(), IsId(nId)) != rList.end()) + return; - // Add just the id of the sub shell. The actual shell is created - // later in CreateShells(). - UpdateLock aLock (*this); - rList.push_back(ShellDescriptor(NULL, nId)); - } - while (false); + // Add just the id of the sub shell. The actual shell is created + // later in CreateShells(). + UpdateLock aLock (*this); + rList.push_back(ShellDescriptor(NULL, nId)); } @@ -690,34 +686,30 @@ void ViewShellManager::Implementation::DeactivateSubShell ( { ::osl::MutexGuard aGuard (maMutex); - do - { - // Check that the given view shell is active. - SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); - if (iList == maActiveSubShells.end()) - break; + // Check that the given view shell is active. + SubShellList::iterator iList (maActiveSubShells.find(&rParentShell)); + if (iList == maActiveSubShells.end()) + return; - // Look up the sub shell. - SubShellSubList& rList (iList->second); - SubShellSubList::iterator iShell ( - ::std::find_if(rList.begin(),rList.end(), IsId(nId))); - if (iShell == rList.end()) - break; - SfxShell* pShell = iShell->mpShell; - if (pShell == NULL) - break; + // Look up the sub shell. + SubShellSubList& rList (iList->second); + SubShellSubList::iterator iShell ( + ::std::find_if(rList.begin(),rList.end(), IsId(nId))); + if (iShell == rList.end()) + return; + SfxShell* pShell = iShell->mpShell; + if (pShell == NULL) + return; - UpdateLock aLock (*this); + UpdateLock aLock (*this); - ShellDescriptor aDescriptor(*iShell); - // Remove the sub shell from both the internal structure as well as the - // SFX shell stack above and including the sub shell. - rList.erase(iShell); - TakeShellsFromStack(pShell); + ShellDescriptor aDescriptor(*iShell); + // Remove the sub shell from both the internal structure as well as the + // SFX shell stack above and including the sub shell. + rList.erase(iShell); + TakeShellsFromStack(pShell); - DestroySubShell(rParentShell, aDescriptor); - } - while (false); + DestroySubShell(rParentShell, aDescriptor); } |