framework/source/dispatch/popupmenudispatcher.cxx | 76 framework/source/fwe/classes/addonmenu.cxx | 138 - framework/source/fwe/helper/actiontriggerhelper.cxx | 214 +- framework/source/fwe/xml/menudocumenthandler.cxx | 98 - framework/source/fwe/xml/statusbardocumenthandler.cxx | 357 +-- framework/source/fwe/xml/toolboxdocumenthandler.cxx | 513 ++--- framework/source/fwi/helper/mischelper.cxx | 22 framework/source/fwi/jobs/configaccess.cxx | 71 framework/source/fwi/uielement/constitemcontainer.cxx | 62 framework/source/fwi/uielement/itemcontainer.cxx | 44 framework/source/fwi/uielement/rootitemcontainer.cxx | 44 framework/source/helper/dockingareadefaultacceptor.cxx | 46 framework/source/helper/ocomponentaccess.cxx | 28 framework/source/helper/statusindicatorfactory.cxx | 68 framework/source/helper/uiconfigelementwrapperbase.cxx | 90 framework/source/helper/uielementwrapperbase.cxx | 28 framework/source/jobs/job.cxx | 50 framework/source/jobs/jobdata.cxx | 52 framework/source/jobs/jobexecutor.cxx | 34 framework/source/jobs/joburl.cxx | 82 framework/source/layoutmanager/helpers.cxx | 58 framework/source/layoutmanager/layoutmanager.cxx | 546 +++--- framework/source/layoutmanager/toolbarlayoutmanager.cxx | 907 +++++----- framework/source/loadenv/loadenv.cxx | 26 framework/source/services/ContextChangeEventMultiplexer.cxx | 59 framework/source/services/autorecovery.cxx | 48 framework/source/services/frame.cxx | 380 ++-- framework/source/uiconfiguration/imagemanagerimpl.cxx | 514 ++--- framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx | 392 ++-- framework/source/uiconfiguration/uiconfigurationmanager.cxx | 276 +-- framework/source/uiconfiguration/windowstateconfiguration.cxx | 104 - framework/source/uielement/FixedImageToolbarController.cxx | 42 framework/source/uielement/FixedTextToolbarController.cxx | 24 framework/source/uielement/addonstoolbarwrapper.cxx | 90 framework/source/uielement/buttontoolbarcontroller.cxx | 56 framework/source/uielement/complextoolbarcontroller.cxx | 162 - framework/source/uielement/controlmenucontroller.cxx | 114 - framework/source/uielement/edittoolbarcontroller.cxx | 24 framework/source/uielement/fontmenucontroller.cxx | 91 - framework/source/uielement/fontsizemenucontroller.cxx | 152 - framework/source/uielement/generictoolbarcontroller.cxx | 212 +- framework/source/uielement/headermenucontroller.cxx | 156 - framework/source/uielement/imagebuttontoolbarcontroller.cxx | 46 framework/source/uielement/langselectionstatusbarcontroller.cxx | 182 +- framework/source/uielement/menubarmanager.cxx | 214 +- framework/source/uielement/menubarwrapper.cxx | 176 - framework/source/uielement/newmenucontroller.cxx | 396 ++-- framework/source/uielement/objectmenucontroller.cxx | 24 framework/source/uielement/popuptoolbarcontroller.cxx | 40 framework/source/uielement/progressbarwrapper.cxx | 70 framework/source/uielement/recentfilesmenucontroller.cxx | 282 +-- framework/source/uielement/statusbarmanager.cxx | 82 framework/source/uielement/statusbarwrapper.cxx | 90 framework/source/uielement/subtoolbarcontroller.cxx | 136 - framework/source/uielement/thesaurusmenucontroller.cxx | 82 framework/source/uielement/toolbarmanager.cxx | 148 - framework/source/uielement/toolbarmodemenucontroller.cxx | 150 - framework/source/uielement/toolbarsmenucontroller.cxx | 580 +++--- framework/source/uielement/toolbarwrapper.cxx | 198 +- framework/source/uielement/uicommanddescription.cxx | 128 - framework/source/uifactory/factoryconfiguration.cxx | 72 framework/source/uifactory/uielementfactorymanager.cxx | 44 framework/source/xml/imagesdocumenthandler.cxx | 146 - 63 files changed, 4915 insertions(+), 4921 deletions(-)
New commits: commit ff25a4a6f4b9763b09abbbd6a711fa4d18f40ade Author: Noel Grandin <[email protected]> AuthorDate: Tue Apr 7 20:32:26 2020 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Apr 8 11:01:31 2020 +0200 loplugin:flatten in framework Change-Id: I2a74a7543b5edd853396efa31a3e2568e6607778 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91848 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/framework/source/dispatch/popupmenudispatcher.cxx b/framework/source/dispatch/popupmenudispatcher.cxx index caa3170c53bd..24ce67dc70d2 100644 --- a/framework/source/dispatch/popupmenudispatcher.cxx +++ b/framework/source/dispatch/popupmenudispatcher.cxx @@ -250,58 +250,58 @@ void SAL_CALL PopupMenuDispatcher::disposing( const EventObject& ) // Safe impossible cases SAL_WARN_IF( m_bAlreadyDisposed, "fwk", "MenuDispatcher::disposing(): Object already disposed .. don't call it again!" ); - if( !m_bAlreadyDisposed ) - { - m_bAlreadyDisposed = true; + if( m_bAlreadyDisposed ) + return; + + m_bAlreadyDisposed = true; - if ( m_bActivateListener ) + if ( m_bActivateListener ) + { + uno::Reference< XFrame > xFrame( m_xWeakFrame.get(), UNO_QUERY ); + if ( xFrame.is() ) { - uno::Reference< XFrame > xFrame( m_xWeakFrame.get(), UNO_QUERY ); - if ( xFrame.is() ) - { - xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( static_cast<OWeakObject *>(this), UNO_QUERY )); - m_bActivateListener = false; - } + xFrame->removeFrameActionListener( uno::Reference< XFrameActionListener >( static_cast<OWeakObject *>(this), UNO_QUERY )); + m_bActivateListener = false; } - - // Forget our factory. - m_xContext.clear(); } + + // Forget our factory. + m_xContext.clear(); } void PopupMenuDispatcher::impl_RetrievePopupControllerQuery() { - if ( !m_xPopupCtrlQuery.is() ) + if ( m_xPopupCtrlQuery.is() ) + return; + + css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager; + css::uno::Reference< css::frame::XFrame > xFrame( m_xWeakFrame ); + + if ( !xFrame.is() ) + return; + + css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY ); + if ( !xPropSet.is() ) + return; + + try { - css::uno::Reference< css::frame::XLayoutManager2 > xLayoutManager; - css::uno::Reference< css::frame::XFrame > xFrame( m_xWeakFrame ); + xPropSet->getPropertyValue( FRAME_PROPNAME_ASCII_LAYOUTMANAGER ) >>= xLayoutManager; - if ( xFrame.is() ) + if ( xLayoutManager.is() ) { - css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY ); - if ( xPropSet.is() ) - { - try - { - xPropSet->getPropertyValue( FRAME_PROPNAME_ASCII_LAYOUTMANAGER ) >>= xLayoutManager; + css::uno::Reference< css::ui::XUIElement > xMenuBar = xLayoutManager->getElement( "private:resource/menubar/menubar" ); - if ( xLayoutManager.is() ) - { - css::uno::Reference< css::ui::XUIElement > xMenuBar = xLayoutManager->getElement( "private:resource/menubar/menubar" ); - - m_xPopupCtrlQuery.set( xMenuBar, css::uno::UNO_QUERY ); - } - } - catch ( const css::uno::RuntimeException& ) - { - throw; - } - catch ( const css::uno::Exception& ) - { - } - } + m_xPopupCtrlQuery.set( xMenuBar, css::uno::UNO_QUERY ); } } + catch ( const css::uno::RuntimeException& ) + { + throw; + } + catch ( const css::uno::Exception& ) + { + } } } // namespace framework diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx index 5a7ab9f5c544..0ce25ceca88f 100644 --- a/framework/source/fwe/classes/addonmenu.cxx +++ b/framework/source/fwe/classes/addonmenu.cxx @@ -89,44 +89,44 @@ static sal_uInt16 FindMenuId( Menu const * pMenu, const OUString& aCommand ) void AddonMenuManager::MergeAddonHelpMenu( const Reference< XFrame >& rFrame, MenuBar const * pMergeMenuBar ) { - if ( pMergeMenuBar ) - { - PopupMenu* pHelpMenu(nullptr); - sal_uInt16 nId = FindMenuId(pMergeMenuBar, ".uno:HelpMenu"); - if ( nId != USHRT_MAX ) - pHelpMenu = pMergeMenuBar->GetPopupMenu( nId ); + if ( !pMergeMenuBar ) + return; - if ( pHelpMenu ) - { - // Add-Ons help menu items should be inserted after the "registration" menu item - sal_uInt16 nItemCount = pHelpMenu->GetItemCount(); - sal_uInt16 nInsSepAfterPos = MENU_APPEND; - sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; - AddonsOptions aOptions; + PopupMenu* pHelpMenu(nullptr); + sal_uInt16 nId = FindMenuId(pMergeMenuBar, ".uno:HelpMenu"); + if ( nId != USHRT_MAX ) + pHelpMenu = pMergeMenuBar->GetPopupMenu( nId ); - // try to detect the about menu item with the command URL - nId = FindMenuId(pHelpMenu, ".uno:About"); - sal_uInt16 nInsPos = pHelpMenu->GetItemPos( nId ); + if ( !pHelpMenu ) + return; - const Sequence< Sequence< PropertyValue > >& rAddonHelpMenuEntries = aOptions.GetAddonsHelpMenu(); + // Add-Ons help menu items should be inserted after the "registration" menu item + sal_uInt16 nItemCount = pHelpMenu->GetItemCount(); + sal_uInt16 nInsSepAfterPos = MENU_APPEND; + sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; + AddonsOptions aOptions; - if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MenuItemType::SEPARATOR ) - nInsSepAfterPos = nInsPos; + // try to detect the about menu item with the command URL + nId = FindMenuId(pHelpMenu, ".uno:About"); + sal_uInt16 nInsPos = pHelpMenu->GetItemPos( nId ); - OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); - AddonMenuManager::BuildMenu( pHelpMenu, nInsPos, nUniqueMenuId, rAddonHelpMenuEntries, rFrame, aModuleIdentifier ); + const Sequence< Sequence< PropertyValue > >& rAddonHelpMenuEntries = aOptions.GetAddonsHelpMenu(); - if ( pHelpMenu->GetItemCount() > nItemCount ) - { - if ( nInsSepAfterPos < MENU_APPEND ) - { - nInsSepAfterPos += ( pHelpMenu->GetItemCount() - nItemCount ); - if ( pHelpMenu->GetItemType( nInsSepAfterPos ) != MenuItemType::SEPARATOR ) - pHelpMenu->InsertSeparator(OString(), nInsSepAfterPos); - } - pHelpMenu->InsertSeparator(OString(), nItemCount); - } + if ( nInsPos < nItemCount && pHelpMenu->GetItemType( nInsPos ) != MenuItemType::SEPARATOR ) + nInsSepAfterPos = nInsPos; + + OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); + AddonMenuManager::BuildMenu( pHelpMenu, nInsPos, nUniqueMenuId, rAddonHelpMenuEntries, rFrame, aModuleIdentifier ); + + if ( pHelpMenu->GetItemCount() > nItemCount ) + { + if ( nInsSepAfterPos < MENU_APPEND ) + { + nInsSepAfterPos += ( pHelpMenu->GetItemCount() - nItemCount ); + if ( pHelpMenu->GetItemType( nInsSepAfterPos ) != MenuItemType::SEPARATOR ) + pHelpMenu->InsertSeparator(OString(), nInsSepAfterPos); } + pHelpMenu->InsertSeparator(OString(), nItemCount); } } @@ -135,52 +135,52 @@ void AddonMenuManager::MergeAddonPopupMenus( const Reference< XFrame >& rFrame, sal_uInt16 nMergeAtPos, MenuBar* pMergeMenuBar ) { - if ( pMergeMenuBar ) - { - AddonsOptions aAddonsOptions; - sal_uInt16 nInsertPos = nMergeAtPos; + if ( !pMergeMenuBar ) + return; - OUString aTitle; - OUString aURL; - OUString aTarget; - OUString aImageId; - OUString aContext; - Sequence< Sequence< PropertyValue > > aAddonSubMenu; - sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; + AddonsOptions aAddonsOptions; + sal_uInt16 nInsertPos = nMergeAtPos; - OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); + OUString aTitle; + OUString aURL; + OUString aTarget; + OUString aImageId; + OUString aContext; + Sequence< Sequence< PropertyValue > > aAddonSubMenu; + sal_uInt16 nUniqueMenuId = ADDONMENU_ITEMID_START; - const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aAddonsOptions.GetAddonsMenuBarPart(); - for ( sal_Int32 i = 0; i < rAddonMenuEntries.getLength(); i++ ) + OUString aModuleIdentifier = vcl::CommandInfoProvider::GetModuleIdentifier(rFrame); + + const Sequence< Sequence< PropertyValue > >& rAddonMenuEntries = aAddonsOptions.GetAddonsMenuBarPart(); + for ( sal_Int32 i = 0; i < rAddonMenuEntries.getLength(); i++ ) + { + AddonMenuManager::GetMenuEntry( rAddonMenuEntries[i], + aTitle, + aURL, + aTarget, + aImageId, + aContext, + aAddonSubMenu ); + if ( !aTitle.isEmpty() && + !aURL.isEmpty() && + aAddonSubMenu.hasElements() && + AddonMenuManager::IsCorrectContext( aModuleIdentifier, aContext )) { - AddonMenuManager::GetMenuEntry( rAddonMenuEntries[i], - aTitle, - aURL, - aTarget, - aImageId, - aContext, - aAddonSubMenu ); - if ( !aTitle.isEmpty() && - !aURL.isEmpty() && - aAddonSubMenu.hasElements() && - AddonMenuManager::IsCorrectContext( aModuleIdentifier, aContext )) - { - sal_uInt16 nId = nUniqueMenuId++; - VclPtrInstance<PopupMenu> pAddonPopupMenu; + sal_uInt16 nId = nUniqueMenuId++; + VclPtrInstance<PopupMenu> pAddonPopupMenu; - AddonMenuManager::BuildMenu( pAddonPopupMenu, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, aModuleIdentifier ); + AddonMenuManager::BuildMenu( pAddonPopupMenu, MENU_APPEND, nUniqueMenuId, aAddonSubMenu, rFrame, aModuleIdentifier ); - if ( pAddonPopupMenu->GetItemCount() > 0 ) - { - pMergeMenuBar->InsertItem( nId, aTitle, MenuItemBits::NONE, OString(), nInsertPos++ ); - pMergeMenuBar->SetPopupMenu( nId, pAddonPopupMenu ); + if ( pAddonPopupMenu->GetItemCount() > 0 ) + { + pMergeMenuBar->InsertItem( nId, aTitle, MenuItemBits::NONE, OString(), nInsertPos++ ); + pMergeMenuBar->SetPopupMenu( nId, pAddonPopupMenu ); - // Store the command URL into the VCL menu bar for later identification - pMergeMenuBar->SetItemCommand( nId, aURL ); - } - else - pAddonPopupMenu.disposeAndClear(); + // Store the command URL into the VCL menu bar for later identification + pMergeMenuBar->SetItemCommand( nId, aURL ); } + else + pAddonPopupMenu.disposeAndClear(); } } } diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx index ed700fdced20..deb14f0e1e2e 100644 --- a/framework/source/fwe/helper/actiontriggerhelper.cxx +++ b/framework/source/fwe/helper/actiontriggerhelper.cxx @@ -96,139 +96,139 @@ static void GetMenuItemAttributes( const Reference< XPropertySet >& xActionTrigg static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Reference< XIndexContainer >& xActionTriggerContainer ) { - if ( xActionTriggerContainer.is() ) - { - AddonsOptions aAddonOptions; - OUString aSlotURL( "slot:" ); + if ( !xActionTriggerContainer.is() ) + return; + + AddonsOptions aAddonOptions; + OUString aSlotURL( "slot:" ); - for ( sal_Int32 i = 0; i < xActionTriggerContainer->getCount(); i++ ) + for ( sal_Int32 i = 0; i < xActionTriggerContainer->getCount(); i++ ) + { + try { - try + Reference< XPropertySet > xPropSet; + if (( xActionTriggerContainer->getByIndex( i ) >>= xPropSet ) && ( xPropSet.is() )) { - Reference< XPropertySet > xPropSet; - if (( xActionTriggerContainer->getByIndex( i ) >>= xPropSet ) && ( xPropSet.is() )) + if ( IsSeparator( xPropSet )) { - if ( IsSeparator( xPropSet )) - { - // Separator - SolarMutexGuard aGuard; - pSubMenu->InsertSeparator(); - } - else - { - // Menu item - OUString aLabel; - OUString aCommandURL; - OUString aHelpURL; - Reference< XBitmap > xBitmap; - Reference< XIndexContainer > xSubContainer; + // Separator + SolarMutexGuard aGuard; + pSubMenu->InsertSeparator(); + } + else + { + // Menu item + OUString aLabel; + OUString aCommandURL; + OUString aHelpURL; + Reference< XBitmap > xBitmap; + Reference< XIndexContainer > xSubContainer; + + sal_uInt16 nNewItemId = nItemId++; + GetMenuItemAttributes( xPropSet, aLabel, aCommandURL, aHelpURL, xBitmap, xSubContainer ); - sal_uInt16 nNewItemId = nItemId++; - GetMenuItemAttributes( xPropSet, aLabel, aCommandURL, aHelpURL, xBitmap, xSubContainer ); + SolarMutexGuard aGuard; + { + // insert new menu item + sal_Int32 nIndex = aCommandURL.indexOf( aSlotURL ); + if ( nIndex >= 0 ) + { + // Special code for our menu implementation: some menu items don't have a + // command url but uses the item id as a unique identifier. These entries + // got a special url during conversion from menu=>actiontriggercontainer. + // Now we have to extract this special url and set the correct item id!!! + nNewItemId = static_cast<sal_uInt16>(aCommandURL.copy( nIndex+aSlotURL.getLength() ).toInt32()); + pSubMenu->InsertItem( nNewItemId, aLabel ); + } + else + { + pSubMenu->InsertItem( nNewItemId, aLabel ); + pSubMenu->SetItemCommand( nNewItemId, aCommandURL ); + } - SolarMutexGuard aGuard; + // handle bitmap + if ( xBitmap.is() ) { - // insert new menu item - sal_Int32 nIndex = aCommandURL.indexOf( aSlotURL ); - if ( nIndex >= 0 ) - { - // Special code for our menu implementation: some menu items don't have a - // command url but uses the item id as a unique identifier. These entries - // got a special url during conversion from menu=>actiontriggercontainer. - // Now we have to extract this special url and set the correct item id!!! - nNewItemId = static_cast<sal_uInt16>(aCommandURL.copy( nIndex+aSlotURL.getLength() ).toInt32()); - pSubMenu->InsertItem( nNewItemId, aLabel ); - } - else + bool bImageSet = false; + + Reference< XUnoTunnel > xUnoTunnel( xBitmap, UNO_QUERY ); + if ( xUnoTunnel.is() ) { - pSubMenu->InsertItem( nNewItemId, aLabel ); - pSubMenu->SetItemCommand( nNewItemId, aCommandURL ); + // Try to get implementation pointer through XUnoTunnel + sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::GetUnoTunnelId() ); + if ( nPointer ) + { + // This is our own optimized implementation of menu images! + ImageWrapper* pImageWrapper = reinterpret_cast< ImageWrapper * >( nPointer ); + const Image& aMenuImage = pImageWrapper->GetImage(); + + if ( !!aMenuImage ) + pSubMenu->SetItemImage( nNewItemId, aMenuImage ); + + bImageSet = true; + } } - // handle bitmap - if ( xBitmap.is() ) + if ( !bImageSet ) { - bool bImageSet = false; + // This is an unknown implementation of a XBitmap interface. We have to + // use a more time consuming way to build an Image! + Image aImage; + BitmapEx aBitmap; - Reference< XUnoTunnel > xUnoTunnel( xBitmap, UNO_QUERY ); - if ( xUnoTunnel.is() ) + Sequence< sal_Int8 > aDIBSeq; { - // Try to get implementation pointer through XUnoTunnel - sal_Int64 nPointer = xUnoTunnel->getSomething( ImageWrapper::GetUnoTunnelId() ); - if ( nPointer ) - { - // This is our own optimized implementation of menu images! - ImageWrapper* pImageWrapper = reinterpret_cast< ImageWrapper * >( nPointer ); - const Image& aMenuImage = pImageWrapper->GetImage(); - - if ( !!aMenuImage ) - pSubMenu->SetItemImage( nNewItemId, aMenuImage ); - - bImageSet = true; - } + aDIBSeq = xBitmap->getDIB(); + SvMemoryStream aMem( const_cast<sal_Int8 *>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ ); + ReadDIBBitmapEx(aBitmap, aMem); } - if ( !bImageSet ) + aDIBSeq = xBitmap->getMaskDIB(); + if ( aDIBSeq.hasElements() ) { - // This is an unknown implementation of a XBitmap interface. We have to - // use a more time consuming way to build an Image! - Image aImage; - BitmapEx aBitmap; - - Sequence< sal_Int8 > aDIBSeq; - { - aDIBSeq = xBitmap->getDIB(); - SvMemoryStream aMem( const_cast<sal_Int8 *>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ ); - ReadDIBBitmapEx(aBitmap, aMem); - } - - aDIBSeq = xBitmap->getMaskDIB(); - if ( aDIBSeq.hasElements() ) - { - Bitmap aMaskBitmap; - SvMemoryStream aMem( const_cast<sal_Int8 *>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ ); - ReadDIB(aMaskBitmap, aMem, true); - aImage = Image(BitmapEx(aBitmap.GetBitmap(), aMaskBitmap)); - } - else - aImage = Image( aBitmap ); - - if ( !!aImage ) - pSubMenu->SetItemImage( nNewItemId, aImage ); + Bitmap aMaskBitmap; + SvMemoryStream aMem( const_cast<sal_Int8 *>(aDIBSeq.getConstArray()), aDIBSeq.getLength(), StreamMode::READ ); + ReadDIB(aMaskBitmap, aMem, true); + aImage = Image(BitmapEx(aBitmap.GetBitmap(), aMaskBitmap)); } - } - else - { - // Support add-on images for context menu interceptors - Image aImage = aAddonOptions.GetImageFromURL( aCommandURL, false, true ); + else + aImage = Image( aBitmap ); + if ( !!aImage ) pSubMenu->SetItemImage( nNewItemId, aImage ); } + } + else + { + // Support add-on images for context menu interceptors + Image aImage = aAddonOptions.GetImageFromURL( aCommandURL, false, true ); + if ( !!aImage ) + pSubMenu->SetItemImage( nNewItemId, aImage ); + } - if ( xSubContainer.is() ) - { - VclPtr<PopupMenu> pNewSubMenu = VclPtr<PopupMenu>::Create(); + if ( xSubContainer.is() ) + { + VclPtr<PopupMenu> pNewSubMenu = VclPtr<PopupMenu>::Create(); - // Sub menu (recursive call CreateSubMenu ) - InsertSubMenuItems( pNewSubMenu, nItemId, xSubContainer ); - pSubMenu->SetPopupMenu( nNewItemId, pNewSubMenu ); - } + // Sub menu (recursive call CreateSubMenu ) + InsertSubMenuItems( pNewSubMenu, nItemId, xSubContainer ); + pSubMenu->SetPopupMenu( nNewItemId, pNewSubMenu ); } } } } - catch (const IndexOutOfBoundsException&) - { - return; - } - catch (const WrappedTargetException&) - { - return; - } - catch (const RuntimeException&) - { - return; - } + } + catch (const IndexOutOfBoundsException&) + { + return; + } + catch (const WrappedTargetException&) + { + return; + } + catch (const RuntimeException&) + { + return; } } } diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index 144c6c600d22..a9bc60525af1 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -270,29 +270,29 @@ void SAL_CALL OReadMenuDocumentHandler::characters(const OUString&) void SAL_CALL OReadMenuDocumentHandler::endElement( const OUString& aName ) { - if ( m_eReaderMode != ReaderMode::None ) + if ( m_eReaderMode == ReaderMode::None ) + return; + + --m_nElementDepth; + m_xReader->endElement( aName ); + if ( 0 != m_nElementDepth ) + return; + + m_xReader->endDocument(); + m_xReader.clear(); + if ( m_eReaderMode == ReaderMode::MenuBar && aName != ELEMENT_MENUBAR ) { - --m_nElementDepth; - m_xReader->endElement( aName ); - if ( 0 == m_nElementDepth ) - { - m_xReader->endDocument(); - m_xReader.clear(); - if ( m_eReaderMode == ReaderMode::MenuBar && aName != ELEMENT_MENUBAR ) - { - OUString aErrorMessage = getErrorLineString() + - "closing element menubar expected!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - else if ( m_eReaderMode == ReaderMode::MenuPopup && aName != ELEMENT_MENUPOPUP ) - { - OUString aErrorMessage = getErrorLineString() + - "closing element menupopup expected!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - m_eReaderMode = ReaderMode::None; - } + OUString aErrorMessage = getErrorLineString() + + "closing element menubar expected!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } + else if ( m_eReaderMode == ReaderMode::MenuPopup && aName != ELEMENT_MENUPOPUP ) + { + OUString aErrorMessage = getErrorLineString() + + "closing element menupopup expected!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + m_eReaderMode = ReaderMode::None; } OReadMenuBarHandler::OReadMenuBarHandler( @@ -410,24 +410,24 @@ void SAL_CALL OReadMenuBarHandler::characters(const OUString&) void OReadMenuBarHandler::endElement( const OUString& aName ) { - if ( m_bMenuMode ) + if ( !m_bMenuMode ) + return; + + --m_nElementDepth; + if ( 0 == m_nElementDepth ) { - --m_nElementDepth; - if ( 0 == m_nElementDepth ) + m_xReader->endDocument(); + m_xReader.clear(); + m_bMenuMode = false; + if ( aName != ELEMENT_MENU ) { - m_xReader->endDocument(); - m_xReader.clear(); - m_bMenuMode = false; - if ( aName != ELEMENT_MENU ) - { - OUString aErrorMessage = getErrorLineString() + - "closing element menu expected!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + + "closing element menu expected!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - else - m_xReader->endElement( aName ); } + else + m_xReader->endElement( aName ); } OReadMenuHandler::OReadMenuHandler( @@ -481,24 +481,24 @@ void SAL_CALL OReadMenuHandler::characters(const OUString&) void SAL_CALL OReadMenuHandler::endElement( const OUString& aName ) { - if ( m_bMenuPopupMode ) + if ( !m_bMenuPopupMode ) + return; + + --m_nElementDepth; + if ( 0 == m_nElementDepth ) { - --m_nElementDepth; - if ( 0 == m_nElementDepth ) + m_xReader->endDocument(); + m_xReader.clear(); + m_bMenuPopupMode = false; + if ( aName != ELEMENT_MENUPOPUP ) { - m_xReader->endDocument(); - m_xReader.clear(); - m_bMenuPopupMode = false; - if ( aName != ELEMENT_MENUPOPUP ) - { - OUString aErrorMessage = getErrorLineString() + - "closing element menupopup expected!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + + "closing element menupopup expected!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - else - m_xReader->endElement( aName ); } + else + m_xReader->endElement( aName ); } OReadMenuPopupHandler::OReadMenuPopupHandler( diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx index 43d6cc12e811..e9e6d0038ea1 100644 --- a/framework/source/fwe/xml/statusbardocumenthandler.cxx +++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx @@ -202,202 +202,202 @@ void SAL_CALL OReadStatusBarDocumentHandler::startElement( SolarMutexGuard g; StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName ); - if ( pStatusBarEntry != m_aStatusBarMap.end() ) + if ( pStatusBarEntry == m_aStatusBarMap.end() ) + return; + + switch ( pStatusBarEntry->second ) { - switch ( pStatusBarEntry->second ) + case SB_ELEMENT_STATUSBAR: { - case SB_ELEMENT_STATUSBAR: + if ( m_bStatusBarStartFound ) { - if ( m_bStatusBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element 'statusbar:statusbar' cannot be embedded into 'statusbar:statusbar'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bStatusBarStartFound = true; + OUString aErrorMessage = getErrorLineString() + "Element 'statusbar:statusbar' cannot be embedded into 'statusbar:statusbar'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case SB_ELEMENT_STATUSBARITEM: + m_bStatusBarStartFound = true; + } + break; + + case SB_ELEMENT_STATUSBARITEM: + { + if ( !m_bStatusBarStartFound ) { - if ( !m_bStatusBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element 'statusbar:statusbaritem' must be embedded into element 'statusbar:statusbar'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Element 'statusbar:statusbaritem' must be embedded into element 'statusbar:statusbar'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - if ( m_bStatusBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element statusbar:statusbaritem is not a container!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + if ( m_bStatusBarItemStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "Element statusbar:statusbaritem is not a container!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - OUString aCommandURL; - OUString aHelpURL; - sal_Int16 nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D|ItemStyle::MANDATORY ); - sal_Int16 nWidth( 0 ); - sal_Int16 nOffset( STATUSBAR_OFFSET ); - bool bCommandURL( false ); + OUString aCommandURL; + OUString aHelpURL; + sal_Int16 nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D|ItemStyle::MANDATORY ); + sal_Int16 nWidth( 0 ); + sal_Int16 nOffset( STATUSBAR_OFFSET ); + bool bCommandURL( false ); - m_bStatusBarItemStartFound = true; - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + m_bStatusBarItemStartFound = true; + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + { + pStatusBarEntry = m_aStatusBarMap.find( xAttribs->getNameByIndex( n ) ); + if ( pStatusBarEntry != m_aStatusBarMap.end() ) { - pStatusBarEntry = m_aStatusBarMap.find( xAttribs->getNameByIndex( n ) ); - if ( pStatusBarEntry != m_aStatusBarMap.end() ) + switch ( pStatusBarEntry->second ) { - switch ( pStatusBarEntry->second ) + case SB_ATTRIBUTE_URL: { - case SB_ATTRIBUTE_URL: + bCommandURL = true; + aCommandURL = xAttribs->getValueByIndex( n ); + } + break; + + case SB_ATTRIBUTE_ALIGN: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_LEFT ) { - bCommandURL = true; - aCommandURL = xAttribs->getValueByIndex( n ); + nItemBits |= ItemStyle::ALIGN_LEFT; + nItemBits &= ~ItemStyle::ALIGN_CENTER; } - break; - - case SB_ATTRIBUTE_ALIGN: + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_CENTER ) { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_LEFT ) - { - nItemBits |= ItemStyle::ALIGN_LEFT; - nItemBits &= ~ItemStyle::ALIGN_CENTER; - } - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_CENTER ) - { - nItemBits |= ItemStyle::ALIGN_CENTER; - nItemBits &= ~ItemStyle::ALIGN_LEFT; - } - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_RIGHT ) - { - nItemBits |= ItemStyle::ALIGN_RIGHT; - } - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:align must have one value of 'left','right' or 'center'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + nItemBits |= ItemStyle::ALIGN_CENTER; + nItemBits &= ~ItemStyle::ALIGN_LEFT; } - break; - - case SB_ATTRIBUTE_STYLE: + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_ALIGN_RIGHT ) { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_IN ) - { - nItemBits |= ItemStyle::DRAW_IN3D; - nItemBits &= ~ItemStyle::DRAW_OUT3D; - } - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_OUT ) - { - nItemBits |= ItemStyle::DRAW_OUT3D; - nItemBits &= ~ItemStyle::DRAW_IN3D; - } - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_FLAT ) - { - nItemBits |= ItemStyle::DRAW_FLAT; - } - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:autosize must have value 'true' or 'false'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + nItemBits |= ItemStyle::ALIGN_RIGHT; } - break; - - case SB_ATTRIBUTE_AUTOSIZE: + else { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) - nItemBits |= ItemStyle::AUTO_SIZE; - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) - nItemBits &= ~ItemStyle::AUTO_SIZE; - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:autosize must have value 'true' or 'false'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:align must have one value of 'left','right' or 'center'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; + } + break; - case SB_ATTRIBUTE_OWNERDRAW: + case SB_ATTRIBUTE_STYLE: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_IN ) { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) - nItemBits |= ItemStyle::OWNER_DRAW; - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) - nItemBits &= ~ItemStyle::OWNER_DRAW; - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:ownerdraw must have value 'true' or 'false'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + nItemBits |= ItemStyle::DRAW_IN3D; + nItemBits &= ~ItemStyle::DRAW_OUT3D; } - break; - - case SB_ATTRIBUTE_WIDTH: + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_OUT ) { - nWidth = static_cast<sal_Int16>(xAttribs->getValueByIndex( n ).toInt32()); + nItemBits |= ItemStyle::DRAW_OUT3D; + nItemBits &= ~ItemStyle::DRAW_IN3D; } - break; - - case SB_ATTRIBUTE_OFFSET: + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_STYLE_FLAT ) { - nOffset = static_cast<sal_Int16>(xAttribs->getValueByIndex( n ).toInt32()); + nItemBits |= ItemStyle::DRAW_FLAT; } - break; + else + { + OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:autosize must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + } + break; - case SB_ATTRIBUTE_HELPURL: + case SB_ATTRIBUTE_AUTOSIZE: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) + nItemBits |= ItemStyle::AUTO_SIZE; + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) + nItemBits &= ~ItemStyle::AUTO_SIZE; + else { - aHelpURL = xAttribs->getValueByIndex( n ); + OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:autosize must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; + } + break; - case SB_ATTRIBUTE_MANDATORY: + case SB_ATTRIBUTE_OWNERDRAW: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) + nItemBits |= ItemStyle::OWNER_DRAW; + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) + nItemBits &= ~ItemStyle::OWNER_DRAW; + else { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) - nItemBits |= ItemStyle::MANDATORY; - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) - nItemBits &= ~ItemStyle::MANDATORY; - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:mandatory must have value 'true' or 'false'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:ownerdraw must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; + } + break; - default: - break; + case SB_ATTRIBUTE_WIDTH: + { + nWidth = static_cast<sal_Int16>(xAttribs->getValueByIndex( n ).toInt32()); } - } - } // for + break; - if ( !bCommandURL ) - { - OUString aErrorMessage = getErrorLineString() + "Required attribute statusbar:url must have a value!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + case SB_ATTRIBUTE_OFFSET: + { + nOffset = static_cast<sal_Int16>(xAttribs->getValueByIndex( n ).toInt32()); + } + break; + + case SB_ATTRIBUTE_HELPURL: + { + aHelpURL = xAttribs->getValueByIndex( n ); + } + break; + + case SB_ATTRIBUTE_MANDATORY: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) + nItemBits |= ItemStyle::MANDATORY; + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) + nItemBits &= ~ItemStyle::MANDATORY; + else + { + OUString aErrorMessage = getErrorLineString() + "Attribute statusbar:mandatory must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + } + break; + + default: + break; + } } - else - { - Sequence< PropertyValue > aStatusbarItemProp( 6 ); - aStatusbarItemProp[0].Name = ITEM_DESCRIPTOR_COMMANDURL; - aStatusbarItemProp[1].Name = ITEM_DESCRIPTOR_HELPURL; - aStatusbarItemProp[2].Name = ITEM_DESCRIPTOR_OFFSET; - aStatusbarItemProp[3].Name = ITEM_DESCRIPTOR_STYLE; - aStatusbarItemProp[4].Name = ITEM_DESCRIPTOR_WIDTH; - aStatusbarItemProp[5].Name = ITEM_DESCRIPTOR_TYPE; - - aStatusbarItemProp[0].Value <<= aCommandURL; - aStatusbarItemProp[1].Value <<= aHelpURL; - aStatusbarItemProp[2].Value <<= nOffset; - aStatusbarItemProp[3].Value <<= nItemBits; - aStatusbarItemProp[4].Value <<= nWidth; - aStatusbarItemProp[5].Value <<= css::ui::ItemType::DEFAULT; - - m_aStatusBarItems->insertByIndex( m_aStatusBarItems->getCount(), makeAny( aStatusbarItemProp ) ); - } - } - break; + } // for - default: - break; + if ( !bCommandURL ) + { + OUString aErrorMessage = getErrorLineString() + "Required attribute statusbar:url must have a value!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + else + { + Sequence< PropertyValue > aStatusbarItemProp( 6 ); + aStatusbarItemProp[0].Name = ITEM_DESCRIPTOR_COMMANDURL; + aStatusbarItemProp[1].Name = ITEM_DESCRIPTOR_HELPURL; + aStatusbarItemProp[2].Name = ITEM_DESCRIPTOR_OFFSET; + aStatusbarItemProp[3].Name = ITEM_DESCRIPTOR_STYLE; + aStatusbarItemProp[4].Name = ITEM_DESCRIPTOR_WIDTH; + aStatusbarItemProp[5].Name = ITEM_DESCRIPTOR_TYPE; + + aStatusbarItemProp[0].Value <<= aCommandURL; + aStatusbarItemProp[1].Value <<= aHelpURL; + aStatusbarItemProp[2].Value <<= nOffset; + aStatusbarItemProp[3].Value <<= nItemBits; + aStatusbarItemProp[4].Value <<= nWidth; + aStatusbarItemProp[5].Value <<= css::ui::ItemType::DEFAULT; + + m_aStatusBarItems->insertByIndex( m_aStatusBarItems->getCount(), makeAny( aStatusbarItemProp ) ); + } } + break; + + default: + break; } } @@ -406,37 +406,36 @@ void SAL_CALL OReadStatusBarDocumentHandler::endElement(const OUString& aName) SolarMutexGuard g; StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName ); - if ( pStatusBarEntry != m_aStatusBarMap.end() ) + if ( pStatusBarEntry == m_aStatusBarMap.end() ) + return; + + switch ( pStatusBarEntry->second ) { - switch ( pStatusBarEntry->second ) + case SB_ELEMENT_STATUSBAR: { - case SB_ELEMENT_STATUSBAR: + if ( !m_bStatusBarStartFound ) { - if ( !m_bStatusBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'statusbar' found, but no start element 'statusbar'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bStatusBarStartFound = false; + OUString aErrorMessage = getErrorLineString() + "End element 'statusbar' found, but no start element 'statusbar'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case SB_ELEMENT_STATUSBARITEM: - { - if ( !m_bStatusBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'statusbar:statusbaritem' found, but no start element 'statusbar:statusbaritem'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + m_bStatusBarStartFound = false; + } + break; - m_bStatusBarItemStartFound = false; + case SB_ELEMENT_STATUSBARITEM: + { + if ( !m_bStatusBarItemStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "End element 'statusbar:statusbaritem' found, but no start element 'statusbar:statusbaritem'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - default: - break; + m_bStatusBarItemStartFound = false; } + break; + + default: break; } } diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx index a01e0fc649cf..1027d18af4b8 100644 --- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx +++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx @@ -196,273 +196,273 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement( SolarMutexGuard g; ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName ); - if ( pToolBoxEntry != m_aToolBoxMap.end() ) + if ( pToolBoxEntry == m_aToolBoxMap.end() ) + return; + + switch ( pToolBoxEntry->second ) { - switch ( pToolBoxEntry->second ) + case TB_ELEMENT_TOOLBAR: { - case TB_ELEMENT_TOOLBAR: + if ( m_bToolBarStartFound ) { - if ( m_bToolBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element 'toolbar:toolbar' cannot be embedded into 'toolbar:toolbar'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - else + OUString aErrorMessage = getErrorLineString() + "Element 'toolbar:toolbar' cannot be embedded into 'toolbar:toolbar'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + else + { + // Check if we have a UI name set in our XML file + OUString aUIName; + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) { - // Check if we have a UI name set in our XML file - OUString aUIName; - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) ); + if ( pToolBoxEntry != m_aToolBoxMap.end() ) { - pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) ); - if ( pToolBoxEntry != m_aToolBoxMap.end() ) + switch ( pToolBoxEntry->second ) { - switch ( pToolBoxEntry->second ) - { - case TB_ATTRIBUTE_UINAME: - aUIName = xAttribs->getValueByIndex( n ); - break; - default: - break; - } + case TB_ATTRIBUTE_UINAME: + aUIName = xAttribs->getValueByIndex( n ); + break; + default: + break; } } - if ( !aUIName.isEmpty() ) + } + if ( !aUIName.isEmpty() ) + { + // Try to set UI name as a container property + Reference< XPropertySet > xPropSet( m_rItemContainer, UNO_QUERY ); + if ( xPropSet.is() ) { - // Try to set UI name as a container property - Reference< XPropertySet > xPropSet( m_rItemContainer, UNO_QUERY ); - if ( xPropSet.is() ) + try + { + xPropSet->setPropertyValue("UIName", makeAny( aUIName ) ); + } + catch ( const UnknownPropertyException& ) { - try - { - xPropSet->setPropertyValue("UIName", makeAny( aUIName ) ); - } - catch ( const UnknownPropertyException& ) - { - } } - } + } - m_bToolBarStartFound = true; } - break; + m_bToolBarStartFound = true; + } + break; - case TB_ELEMENT_TOOLBARITEM: + case TB_ELEMENT_TOOLBARITEM: + { + if ( !m_bToolBarStartFound ) { - if ( !m_bToolBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element 'toolbar:toolbaritem' must be embedded into element 'toolbar:toolbar'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Element 'toolbar:toolbaritem' must be embedded into element 'toolbar:toolbar'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - if ( m_bToolBarSeparatorStartFound || - m_bToolBarBreakStartFound || - m_bToolBarSpaceStartFound || - m_bToolBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbaritem is not a container!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + if ( m_bToolBarSeparatorStartFound || + m_bToolBarBreakStartFound || + m_bToolBarSpaceStartFound || + m_bToolBarItemStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbaritem is not a container!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - bool bAttributeURL = false; + bool bAttributeURL = false; - m_bToolBarItemStartFound = true; - OUString aLabel; - OUString aCommandURL; - sal_uInt16 nItemBits( 0 ); - bool bVisible( true ); + m_bToolBarItemStartFound = true; + OUString aLabel; + OUString aCommandURL; + sal_uInt16 nItemBits( 0 ); + bool bVisible( true ); - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + { + pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) ); + if ( pToolBoxEntry != m_aToolBoxMap.end() ) { - pToolBoxEntry = m_aToolBoxMap.find( xAttribs->getNameByIndex( n ) ); - if ( pToolBoxEntry != m_aToolBoxMap.end() ) + switch ( pToolBoxEntry->second ) { - switch ( pToolBoxEntry->second ) + case TB_ATTRIBUTE_TEXT: { - case TB_ATTRIBUTE_TEXT: - { - aLabel = xAttribs->getValueByIndex( n ); - } - break; + aLabel = xAttribs->getValueByIndex( n ); + } + break; - case TB_ATTRIBUTE_URL: - { - bAttributeURL = true; - aCommandURL = xAttribs->getValueByIndex( n ).intern(); - } - break; + case TB_ATTRIBUTE_URL: + { + bAttributeURL = true; + aCommandURL = xAttribs->getValueByIndex( n ).intern(); + } + break; - case TB_ATTRIBUTE_VISIBLE: + case TB_ATTRIBUTE_VISIBLE: + { + if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) + bVisible = true; + else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) + bVisible = false; + else { - if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_TRUE ) - bVisible = true; - else if ( xAttribs->getValueByIndex( n ) == ATTRIBUTE_BOOLEAN_FALSE ) - bVisible = false; - else - { - OUString aErrorMessage = getErrorLineString() + "Attribute toolbar:visible must have value 'true' or 'false'!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Attribute toolbar:visible must have value 'true' or 'false'!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; + } + break; - case TB_ATTRIBUTE_STYLE: - { - // read space separated item style list - OUString aTemp = xAttribs->getValueByIndex( n ); - sal_Int32 nIndex = 0; + case TB_ATTRIBUTE_STYLE: + { + // read space separated item style list + OUString aTemp = xAttribs->getValueByIndex( n ); + sal_Int32 nIndex = 0; - do + do + { + OUString aToken = aTemp.getToken( 0, ' ', nIndex ); + if ( !aToken.isEmpty() ) { - OUString aToken = aTemp.getToken( 0, ' ', nIndex ); - if ( !aToken.isEmpty() ) - { - sal_Int32 nHashCode = aToken.hashCode(); - if ( nHashCode == m_nHashCode_Style_Radio ) - nItemBits |= css::ui::ItemStyle::RADIO_CHECK; - else if ( nHashCode == m_nHashCode_Style_Left ) - nItemBits |= css::ui::ItemStyle::ALIGN_LEFT; - else if ( nHashCode == m_nHashCode_Style_AutoSize ) - nItemBits |= css::ui::ItemStyle::AUTO_SIZE; - else if ( nHashCode == m_nHashCode_Style_Repeat ) - nItemBits |= css::ui::ItemStyle::REPEAT; - else if ( nHashCode == m_nHashCode_Style_DropDownOnly ) - nItemBits |= css::ui::ItemStyle::DROPDOWN_ONLY; - else if ( nHashCode == m_nHashCode_Style_DropDown ) - nItemBits |= css::ui::ItemStyle::DROP_DOWN; - else if ( nHashCode == m_nHashCode_Style_Text ) - nItemBits |= css::ui::ItemStyle::TEXT; - else if ( nHashCode == m_nHashCode_Style_Image ) - nItemBits |= css::ui::ItemStyle::ICON; - } + sal_Int32 nHashCode = aToken.hashCode(); + if ( nHashCode == m_nHashCode_Style_Radio ) + nItemBits |= css::ui::ItemStyle::RADIO_CHECK; + else if ( nHashCode == m_nHashCode_Style_Left ) + nItemBits |= css::ui::ItemStyle::ALIGN_LEFT; + else if ( nHashCode == m_nHashCode_Style_AutoSize ) + nItemBits |= css::ui::ItemStyle::AUTO_SIZE; + else if ( nHashCode == m_nHashCode_Style_Repeat ) + nItemBits |= css::ui::ItemStyle::REPEAT; + else if ( nHashCode == m_nHashCode_Style_DropDownOnly ) + nItemBits |= css::ui::ItemStyle::DROPDOWN_ONLY; + else if ( nHashCode == m_nHashCode_Style_DropDown ) + nItemBits |= css::ui::ItemStyle::DROP_DOWN; + else if ( nHashCode == m_nHashCode_Style_Text ) + nItemBits |= css::ui::ItemStyle::TEXT; + else if ( nHashCode == m_nHashCode_Style_Image ) + nItemBits |= css::ui::ItemStyle::ICON; } - while ( nIndex >= 0 ); } - break; - - default: - break; + while ( nIndex >= 0 ); } - } - } // for + break; - if ( !bAttributeURL ) - { - OUString aErrorMessage = getErrorLineString() + "Required attribute toolbar:url must have a value!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( !aCommandURL.isEmpty() ) - { - //fix for fdo#39370 - /// check whether RTL interface or not - if(AllSettings::GetLayoutRTL()){ - if (aCommandURL == ".uno:ParaLeftToRight") - aCommandURL = ".uno:ParaRightToLeft"; - else if (aCommandURL == ".uno:ParaRightToLeft") - aCommandURL = ".uno:ParaLeftToRight"; - else if (aCommandURL == ".uno:LeftPara") - aCommandURL = ".uno:RightPara"; - else if (aCommandURL == ".uno:RightPara") - aCommandURL = ".uno:LeftPara"; - else if (aCommandURL == ".uno:AlignLeft") - aCommandURL = ".uno:AlignRight"; - else if (aCommandURL == ".uno:AlignRight") - aCommandURL = ".uno:AlignLeft"; - else if (aCommandURL == ".uno:WrapLeft") - aCommandURL = ".uno:WrapRight"; - else if (aCommandURL == ".uno:WrapRight") - aCommandURL = ".uno:WrapLeft"; + default: + break; } - - auto aToolbarItemProp( comphelper::InitPropertySequence( { - { m_aCommandURL, css::uno::makeAny( aCommandURL ) }, - { m_aLabel, css::uno::makeAny( aLabel ) }, - { m_aType, css::uno::makeAny( css::ui::ItemType::DEFAULT ) }, - { m_aStyle, css::uno::makeAny( nItemBits ) }, - { m_aIsVisible, css::uno::makeAny( bVisible ) }, - } ) ); - - m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); } + } // for + + if ( !bAttributeURL ) + { + OUString aErrorMessage = getErrorLineString() + "Required attribute toolbar:url must have a value!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case TB_ELEMENT_TOOLBARSPACE: + if ( !aCommandURL.isEmpty() ) { - if ( m_bToolBarSeparatorStartFound || - m_bToolBarBreakStartFound || - m_bToolBarSpaceStartFound || - m_bToolBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarspace is not a container!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + //fix for fdo#39370 + /// check whether RTL interface or not + if(AllSettings::GetLayoutRTL()){ + if (aCommandURL == ".uno:ParaLeftToRight") + aCommandURL = ".uno:ParaRightToLeft"; + else if (aCommandURL == ".uno:ParaRightToLeft") + aCommandURL = ".uno:ParaLeftToRight"; + else if (aCommandURL == ".uno:LeftPara") + aCommandURL = ".uno:RightPara"; + else if (aCommandURL == ".uno:RightPara") + aCommandURL = ".uno:LeftPara"; + else if (aCommandURL == ".uno:AlignLeft") + aCommandURL = ".uno:AlignRight"; + else if (aCommandURL == ".uno:AlignRight") + aCommandURL = ".uno:AlignLeft"; + else if (aCommandURL == ".uno:WrapLeft") + aCommandURL = ".uno:WrapRight"; + else if (aCommandURL == ".uno:WrapRight") + aCommandURL = ".uno:WrapLeft"; } - m_bToolBarSpaceStartFound = true; - - Sequence< PropertyValue > aToolbarItemProp( 2 ); - aToolbarItemProp[0].Name = m_aCommandURL; - aToolbarItemProp[1].Name = m_aType; - - aToolbarItemProp[0].Value <<= OUString(); - aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_SPACE; + auto aToolbarItemProp( comphelper::InitPropertySequence( { + { m_aCommandURL, css::uno::makeAny( aCommandURL ) }, + { m_aLabel, css::uno::makeAny( aLabel ) }, + { m_aType, css::uno::makeAny( css::ui::ItemType::DEFAULT ) }, + { m_aStyle, css::uno::makeAny( nItemBits ) }, + { m_aIsVisible, css::uno::makeAny( bVisible ) }, + } ) ); m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); } - break; + } + break; - case TB_ELEMENT_TOOLBARBREAK: + case TB_ELEMENT_TOOLBARSPACE: + { + if ( m_bToolBarSeparatorStartFound || + m_bToolBarBreakStartFound || + m_bToolBarSpaceStartFound || + m_bToolBarItemStartFound ) { - if ( m_bToolBarSeparatorStartFound || - m_bToolBarBreakStartFound || - m_bToolBarSpaceStartFound || - m_bToolBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarbreak is not a container!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarspace is not a container!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - m_bToolBarBreakStartFound = true; + m_bToolBarSpaceStartFound = true; - Sequence< PropertyValue > aToolbarItemProp( 2 ); - aToolbarItemProp[0].Name = m_aCommandURL; - aToolbarItemProp[1].Name = m_aType; + Sequence< PropertyValue > aToolbarItemProp( 2 ); + aToolbarItemProp[0].Name = m_aCommandURL; + aToolbarItemProp[1].Name = m_aType; - aToolbarItemProp[0].Value <<= OUString(); - aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINEBREAK; + aToolbarItemProp[0].Value <<= OUString(); + aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_SPACE; - m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); - } - break; + m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); + } + break; - case TB_ELEMENT_TOOLBARSEPARATOR: + case TB_ELEMENT_TOOLBARBREAK: + { + if ( m_bToolBarSeparatorStartFound || + m_bToolBarBreakStartFound || + m_bToolBarSpaceStartFound || + m_bToolBarItemStartFound ) { - if ( m_bToolBarSeparatorStartFound || - m_bToolBarBreakStartFound || - m_bToolBarSpaceStartFound || - m_bToolBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarseparator is not a container!"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarbreak is not a container!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } - m_bToolBarSeparatorStartFound = true; + m_bToolBarBreakStartFound = true; - Sequence< PropertyValue > aToolbarItemProp( 2 ); - aToolbarItemProp[0].Name = m_aCommandURL; - aToolbarItemProp[1].Name = m_aType; + Sequence< PropertyValue > aToolbarItemProp( 2 ); + aToolbarItemProp[0].Name = m_aCommandURL; + aToolbarItemProp[1].Name = m_aType; - aToolbarItemProp[0].Value <<= OUString(); - aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINE; + aToolbarItemProp[0].Value <<= OUString(); + aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINEBREAK; - m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); + m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); + } + break; + + case TB_ELEMENT_TOOLBARSEPARATOR: + { + if ( m_bToolBarSeparatorStartFound || + m_bToolBarBreakStartFound || + m_bToolBarSpaceStartFound || + m_bToolBarItemStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "Element toolbar:toolbarseparator is not a container!"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - default: - break; + m_bToolBarSeparatorStartFound = true; + + Sequence< PropertyValue > aToolbarItemProp( 2 ); + aToolbarItemProp[0].Name = m_aCommandURL; + aToolbarItemProp[1].Name = m_aType; + + aToolbarItemProp[0].Value <<= OUString(); + aToolbarItemProp[1].Value <<= css::ui::ItemType::SEPARATOR_LINE; + + m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); } + break; + + default: + break; } } @@ -471,73 +471,72 @@ void SAL_CALL OReadToolBoxDocumentHandler::endElement(const OUString& aName) SolarMutexGuard g; ToolBoxHashMap::const_iterator pToolBoxEntry = m_aToolBoxMap.find( aName ); - if ( pToolBoxEntry != m_aToolBoxMap.end() ) + if ( pToolBoxEntry == m_aToolBoxMap.end() ) + return; + + switch ( pToolBoxEntry->second ) { - switch ( pToolBoxEntry->second ) + case TB_ELEMENT_TOOLBAR: { - case TB_ELEMENT_TOOLBAR: + if ( !m_bToolBarStartFound ) { - if ( !m_bToolBarStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'toolbar' found, but no start element 'toolbar'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bToolBarStartFound = false; + OUString aErrorMessage = getErrorLineString() + "End element 'toolbar' found, but no start element 'toolbar'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case TB_ELEMENT_TOOLBARITEM: - { - if ( !m_bToolBarItemStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbaritem' found, but no start element 'toolbar:toolbaritem'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + m_bToolBarStartFound = false; + } + break; - m_bToolBarItemStartFound = false; + case TB_ELEMENT_TOOLBARITEM: + { + if ( !m_bToolBarItemStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbaritem' found, but no start element 'toolbar:toolbaritem'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case TB_ELEMENT_TOOLBARBREAK: - { - if ( !m_bToolBarBreakStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarbreak' found, but no start element 'toolbar:toolbarbreak'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + m_bToolBarItemStartFound = false; + } + break; - m_bToolBarBreakStartFound = false; + case TB_ELEMENT_TOOLBARBREAK: + { + if ( !m_bToolBarBreakStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarbreak' found, but no start element 'toolbar:toolbarbreak'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case TB_ELEMENT_TOOLBARSPACE: - { - if ( !m_bToolBarSpaceStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarspace' found, but no start element 'toolbar:toolbarspace'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + m_bToolBarBreakStartFound = false; + } + break; - m_bToolBarSpaceStartFound = false; + case TB_ELEMENT_TOOLBARSPACE: + { + if ( !m_bToolBarSpaceStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarspace' found, but no start element 'toolbar:toolbarspace'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - case TB_ELEMENT_TOOLBARSEPARATOR: - { - if ( !m_bToolBarSeparatorStartFound ) - { - OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarseparator' found, but no start element 'toolbar:toolbarseparator'"; - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } + m_bToolBarSpaceStartFound = false; + } + break; - m_bToolBarSeparatorStartFound = false; + case TB_ELEMENT_TOOLBARSEPARATOR: + { + if ( !m_bToolBarSeparatorStartFound ) + { + OUString aErrorMessage = getErrorLineString() + "End element 'toolbar:toolbarseparator' found, but no start element 'toolbar:toolbarseparator'"; + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } - break; - default: - break; + m_bToolBarSeparatorStartFound = false; } + break; + + default: break; } } diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx index a8a841295767..75e560e7a975 100644 --- a/framework/source/fwi/helper/mischelper.cxx +++ b/framework/source/fwi/helper/mischelper.cxx @@ -119,19 +119,19 @@ void FillLangItems( std::set< OUString > &rLangItems, COMPLEX: 0x004 */ const sal_Int16 nMaxCount = 7; - if ( xDocumentLanguages.is() ) + if ( !xDocumentLanguages.is() ) + return; + + Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount )); + if ( rLocales.hasElements() ) { - Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount )); - if ( rLocales.hasElements() ) + for ( sal_Int32 i = 0; i < rLocales.getLength(); ++i ) { - for ( sal_Int32 i = 0; i < rLocales.getLength(); ++i ) - { - if ( rLangItems.size() == static_cast< size_t >(nMaxCount) ) - break; - const Locale& rLocale=rLocales[i]; - if( IsScriptTypeMatchingToLanguage( nScriptType, SvtLanguageTable::GetLanguageType( rLocale.Language ))) - rLangItems.insert( rLocale.Language ); - } + if ( rLangItems.size() == static_cast< size_t >(nMaxCount) ) + break; + const Locale& rLocale=rLocales[i]; + if( IsScriptTypeMatchingToLanguage( nScriptType, SvtLanguageTable::GetLanguageType( rLocale.Language ))) + rLangItems.insert( rLocale.Language ); } } } diff --git a/framework/source/fwi/jobs/configaccess.cxx b/framework/source/fwi/jobs/configaccess.cxx index 2cb736d4bb65..bcb739c09cdb 100644 --- a/framework/source/fwi/jobs/configaccess.cxx +++ b/framework/source/fwi/jobs/configaccess.cxx @@ -91,45 +91,42 @@ void ConfigAccess::open( /*IN*/ EOpenMode eMode ) // check if configuration is already open in the right mode. // By the way: Don't allow closing by using this method! - if ( - (eMode !=E_CLOSED) && - (m_eMode!=eMode ) - ) + if ( eMode == E_CLOSED || m_eMode == eMode ) + return; + + // We have to close the old access point without any question here. + // It will be open again using the new mode. + // can be called without checks! It does the checks by itself ... + // e.g. for already closed or not opened configuration. + // Flushing of all made changes will be done here too. + close(); + + // create the configuration provider, which provides sub access points + css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = css::configuration::theDefaultProvider::get(m_xContext); + css::beans::PropertyValue aParam; + aParam.Name = "nodepath"; + aParam.Value <<= m_sRoot; + + css::uno::Sequence< css::uno::Any > lParams(1); + lParams[0] <<= aParam; + + // open it + try { - // We have to close the old access point without any question here. - // It will be open again using the new mode. - // can be called without checks! It does the checks by itself ... - // e.g. for already closed or not opened configuration. - // Flushing of all made changes will be done here too. - close(); - - // create the configuration provider, which provides sub access points - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider = css::configuration::theDefaultProvider::get(m_xContext); - css::beans::PropertyValue aParam; - aParam.Name = "nodepath"; - aParam.Value <<= m_sRoot; - - css::uno::Sequence< css::uno::Any > lParams(1); - lParams[0] <<= aParam; - - // open it - try - { - if (eMode==E_READONLY) - m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS , lParams); - else - if (eMode==E_READWRITE) - m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGUPDATEACCESS, lParams); - } - catch(const css::uno::Exception&) - { - TOOLS_INFO_EXCEPTION("fwk", "open config"); - } - - m_eMode = E_CLOSED; - if (m_xConfig.is()) - m_eMode = eMode; + if (eMode==E_READONLY) + m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGREADACCESS , lParams); + else + if (eMode==E_READWRITE) + m_xConfig = xConfigProvider->createInstanceWithArguments(SERVICENAME_CFGUPDATEACCESS, lParams); } + catch(const css::uno::Exception&) + { + TOOLS_INFO_EXCEPTION("fwk", "open config"); + } + + m_eMode = E_CLOSED; + if (m_xConfig.is()) + m_eMode = eMode; } /** diff --git a/framework/source/fwi/uielement/constitemcontainer.cxx b/framework/source/fwi/uielement/constitemcontainer.cxx index bb901da9226b..d0a621babcd5 100644 --- a/framework/source/fwi/uielement/constitemcontainer.cxx +++ b/framework/source/fwi/uielement/constitemcontainer.cxx @@ -63,51 +63,51 @@ ConstItemContainer::ConstItemContainer( const Reference< XIndexAccess >& rSource { } - if ( rSourceContainer.is() ) + if ( !rSourceContainer.is() ) + return; + + try { - try + sal_Int32 nCount = rSourceContainer->getCount(); + m_aItemVector.reserve(nCount); + if ( bFastCopy ) { - sal_Int32 nCount = rSourceContainer->getCount(); - m_aItemVector.reserve(nCount); - if ( bFastCopy ) + for ( sal_Int32 i = 0; i < nCount; i++ ) { - for ( sal_Int32 i = 0; i < nCount; i++ ) - { - Sequence< PropertyValue > aPropSeq; - if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) - m_aItemVector.push_back( aPropSeq ); - } + Sequence< PropertyValue > aPropSeq; + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) + m_aItemVector.push_back( aPropSeq ); } - else + } + else + { + for ( sal_Int32 i = 0; i < nCount; i++ ) { - for ( sal_Int32 i = 0; i < nCount; i++ ) + Sequence< PropertyValue > aPropSeq; + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { - Sequence< PropertyValue > aPropSeq; - if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) + sal_Int32 nContainerIndex = -1; + Reference< XIndexAccess > xIndexAccess; + for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) { - sal_Int32 nContainerIndex = -1; - Reference< XIndexAccess > xIndexAccess; - for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) + if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) { - if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) - { - aPropSeq[j].Value >>= xIndexAccess; - nContainerIndex = j; - break; - } + aPropSeq[j].Value >>= xIndexAccess; + nContainerIndex = j; + break; } + } - if ( xIndexAccess.is() && nContainerIndex >= 0 ) - aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess ); + if ( xIndexAccess.is() && nContainerIndex >= 0 ) + aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess ); - m_aItemVector.push_back( aPropSeq ); - } + m_aItemVector.push_back( aPropSeq ); } } } - catch ( const IndexOutOfBoundsException& ) - { - } + } + catch ( const IndexOutOfBoundsException& ) + { } } diff --git a/framework/source/fwi/uielement/itemcontainer.cxx b/framework/source/fwi/uielement/itemcontainer.cxx index 8401274534af..79e5104e933f 100644 --- a/framework/source/fwi/uielement/itemcontainer.cxx +++ b/framework/source/fwi/uielement/itemcontainer.cxx @@ -50,38 +50,38 @@ ItemContainer::ItemContainer( const ConstItemContainer& rConstItemContainer, con ItemContainer::ItemContainer( const Reference< XIndexAccess >& rSourceContainer, const ShareableMutex& rMutex ) : m_aShareMutex( rMutex ) { - if ( rSourceContainer.is() ) + if ( !rSourceContainer.is() ) + return; + + sal_Int32 nCount = rSourceContainer->getCount(); + try { - sal_Int32 nCount = rSourceContainer->getCount(); - try + for ( sal_Int32 i = 0; i < nCount; i++ ) { - for ( sal_Int32 i = 0; i < nCount; i++ ) + Sequence< PropertyValue > aPropSeq; + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { - Sequence< PropertyValue > aPropSeq; - if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) + sal_Int32 nContainerIndex = -1; + Reference< XIndexAccess > xIndexAccess; + for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) { - sal_Int32 nContainerIndex = -1; - Reference< XIndexAccess > xIndexAccess; - for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) + if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) { - if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) - { - aPropSeq[j].Value >>= xIndexAccess; - nContainerIndex = j; - break; - } + aPropSeq[j].Value >>= xIndexAccess; + nContainerIndex = j; + break; } + } - if ( xIndexAccess.is() && nContainerIndex >= 0 ) - aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex ); + if ( xIndexAccess.is() && nContainerIndex >= 0 ) + aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess, rMutex ); - m_aItemVector.push_back( aPropSeq ); - } + m_aItemVector.push_back( aPropSeq ); } } - catch ( const IndexOutOfBoundsException& ) - { - } + } + catch ( const IndexOutOfBoundsException& ) + { } } diff --git a/framework/source/fwi/uielement/rootitemcontainer.cxx b/framework/source/fwi/uielement/rootitemcontainer.cxx index 14a199891313..edf695135d1d 100644 --- a/framework/source/fwi/uielement/rootitemcontainer.cxx +++ b/framework/source/fwi/uielement/rootitemcontainer.cxx @@ -64,38 +64,38 @@ RootItemContainer::RootItemContainer( const Reference< XIndexAccess >& rSourceCo { } - if ( rSourceContainer.is() ) + if ( !rSourceContainer.is() ) + return; + + sal_Int32 nCount = rSourceContainer->getCount(); + try { - sal_Int32 nCount = rSourceContainer->getCount(); - try + for ( sal_Int32 i = 0; i < nCount; i++ ) { - for ( sal_Int32 i = 0; i < nCount; i++ ) + Sequence< PropertyValue > aPropSeq; + if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) { - Sequence< PropertyValue > aPropSeq; - if ( rSourceContainer->getByIndex( i ) >>= aPropSeq ) + sal_Int32 nContainerIndex = -1; + Reference< XIndexAccess > xIndexAccess; + for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) { - sal_Int32 nContainerIndex = -1; - Reference< XIndexAccess > xIndexAccess; - for ( sal_Int32 j = 0; j < aPropSeq.getLength(); j++ ) + if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) { - if ( aPropSeq[j].Name == "ItemDescriptorContainer" ) - { - aPropSeq[j].Value >>= xIndexAccess; - nContainerIndex = j; - break; - } + aPropSeq[j].Value >>= xIndexAccess; + nContainerIndex = j; + break; } + } - if ( xIndexAccess.is() && nContainerIndex >= 0 ) - aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess ); + if ( xIndexAccess.is() && nContainerIndex >= 0 ) + aPropSeq[nContainerIndex].Value <<= deepCopyContainer( xIndexAccess ); - m_aItemVector.push_back( aPropSeq ); - } + m_aItemVector.push_back( aPropSeq ); } } - catch ( const IndexOutOfBoundsException& ) - { - } + } + catch ( const IndexOutOfBoundsException& ) + { } } diff --git a/framework/source/helper/dockingareadefaultacceptor.cxx b/framework/source/helper/dockingareadefaultacceptor.cxx index 27d75723012a..9d51d2052516 100644 --- a/framework/source/helper/dockingareadefaultacceptor.cxx +++ b/framework/source/helper/dockingareadefaultacceptor.cxx @@ -98,31 +98,31 @@ void SAL_CALL DockingAreaDefaultAcceptor::setDockingAreaSpace( const css::awt::R // Try to "lock" the frame for access to taskscontainer. css::uno::Reference< XFrame > xFrame( m_xOwner ); - if ( xFrame.is() ) - { - css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() ); - css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() ); + if ( !xFrame.is() ) + return; - if ( xContainerWindow.is() && xComponentWindow.is() ) - { - css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY ); - // Convert relative size to output size. - css::awt::Rectangle aRectangle = xContainerWindow->getPosSize(); - css::awt::DeviceInfo aInfo = xDevice->getInfo(); - css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , - aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); - css::awt::Size aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize(); + css::uno::Reference< css::awt::XWindow > xContainerWindow( xFrame->getContainerWindow() ); + css::uno::Reference< css::awt::XWindow > xComponentWindow( xFrame->getComponentWindow() ); - // Check if request border space would decrease component window size below minimum size - sal_Int32 nWidth = aSize.Width - BorderSpace.X - BorderSpace.Width; - sal_Int32 nHeight = aSize.Height - BorderSpace.Y - BorderSpace.Height; - - if (( nWidth > aMinSize.Width ) && ( nHeight > aMinSize.Height )) - { - // Resize our component window. - xComponentWindow->setPosSize( BorderSpace.X, BorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE ); - } - } + if ( !(xContainerWindow.is() && xComponentWindow.is()) ) + return; + + css::uno::Reference< css::awt::XDevice > xDevice( xContainerWindow, css::uno::UNO_QUERY ); + // Convert relative size to output size. + css::awt::Rectangle aRectangle = xContainerWindow->getPosSize(); + css::awt::DeviceInfo aInfo = xDevice->getInfo(); + css::awt::Size aSize ( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset , + aRectangle.Height - aInfo.TopInset - aInfo.BottomInset ); + css::awt::Size aMinSize( 0, 0 );// = xLayoutContrains->getMinimumSize(); + + // Check if request border space would decrease component window size below minimum size + sal_Int32 nWidth = aSize.Width - BorderSpace.X - BorderSpace.Width; + sal_Int32 nHeight = aSize.Height - BorderSpace.Y - BorderSpace.Height; + + if (( nWidth > aMinSize.Width ) && ( nHeight > aMinSize.Height )) + { + // Resize our component window. + xComponentWindow->setPosSize( BorderSpace.X, BorderSpace.Y, nWidth, nHeight, css::awt::PosSize::POSSIZE ); } } diff --git a/framework/source/helper/ocomponentaccess.cxx b/framework/source/helper/ocomponentaccess.cxx index b170ae5258a0..b814fc49b83a 100644 --- a/framework/source/helper/ocomponentaccess.cxx +++ b/framework/source/helper/ocomponentaccess.cxx @@ -109,24 +109,24 @@ void OComponentAccess::impl_collectAllChildComponents( const css::uno::Referenc std::vector< css::uno::Reference< XComponent > >& seqComponents ) { // If valid node was given ... - if( xNode.is() ) - { - // ... continue collection at these. + if( !xNode.is() ) + return; + + // ... continue collection at these. - // Get the container of current node, collect the components of existing child frames - // and go down to next level in tree (recursive!). + // Get the container of current node, collect the components of existing child frames + // and go down to next level in tree (recursive!). - const css::uno::Reference< XFrames > xContainer = xNode->getFrames(); - const Sequence< css::uno::Reference< XFrame > > seqFrames = xContainer->queryFrames( FrameSearchFlag::CHILDREN ); + const css::uno::Reference< XFrames > xContainer = xNode->getFrames(); + const Sequence< css::uno::Reference< XFrame > > seqFrames = xContainer->queryFrames( FrameSearchFlag::CHILDREN ); - const sal_Int32 nFrameCount = seqFrames.getLength(); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
