summaryrefslogtreecommitdiff
path: root/sfx2/source/appl/appserv.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-06-25 19:11:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-06-26 09:17:47 +0200
commit2dbe6a2d57956be392966c363d03f54cb68dd4fa (patch)
tree148065e98b7470331edaa83b95c85eae6e179ed2 /sfx2/source/appl/appserv.cxx
parentd416a5ff59b31dd7250d392278c43f66cdb81e35 (diff)
loplugin:oncevar in sfx2
Change-Id: I9aadcb9a12ef9b0c3f93ea255f2542e51d31fbf7 Reviewed-on: https://gerrit.libreoffice.org/39242 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/appl/appserv.cxx')
-rw-r--r--sfx2/source/appl/appserv.cxx149
1 files changed, 72 insertions, 77 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index 4ee7dc17a2fe..efdd469b424e 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -791,7 +791,6 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
css::uno::Sequence<OUString> aUserToolbars;
std::vector<OUString> aBackupList;
OUString aSidebarMode;
- bool bCorrectMode = true;
OUStringBuffer aPath = OUStringBuffer( "org.openoffice.Office.UI.ToolbarMode/Applications/" );
aPath.append( lcl_getAppName( eApp ) );
@@ -828,103 +827,100 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
}
}
- if ( bCorrectMode )
+ // Backup visible toolbar list and hide all toolbars
+ Sequence<Reference<XUIElement>> aUIElements = xLayoutManager->getElements();
+ for ( sal_Int32 i = 0; i < aUIElements.getLength(); i++ )
{
- // Backup visible toolbar list and hide all toolbars
- Sequence<Reference<XUIElement>> aUIElements = xLayoutManager->getElements();
- for ( sal_Int32 i = 0; i < aUIElements.getLength(); i++ )
+ Reference< XUIElement > xUIElement( aUIElements[i] );
+ Reference< XPropertySet > xPropertySet( aUIElements[i], UNO_QUERY );
+ if ( xPropertySet.is() && xUIElement.is() )
{
- Reference< XUIElement > xUIElement( aUIElements[i] );
- Reference< XPropertySet > xPropertySet( aUIElements[i], UNO_QUERY );
- if ( xPropertySet.is() && xUIElement.is() )
+ try
{
- try
- {
- OUString aResName;
- sal_Int16 nType( -1 );
- xPropertySet->getPropertyValue( "Type" ) >>= nType;
- xPropertySet->getPropertyValue( "ResourceURL" ) >>= aResName;
+ OUString aResName;
+ sal_Int16 nType( -1 );
+ xPropertySet->getPropertyValue( "Type" ) >>= nType;
+ xPropertySet->getPropertyValue( "ResourceURL" ) >>= aResName;
- if (( nType == css::ui::UIElementType::TOOLBAR ) &&
- !aResName.isEmpty() )
+ if (( nType == css::ui::UIElementType::TOOLBAR ) &&
+ !aResName.isEmpty() )
+ {
+ if ( xLayoutManager->isElementVisible( aResName ) )
{
- if ( xLayoutManager->isElementVisible( aResName ) )
- {
- aBackupList.push_back( aResName );
- }
- xLayoutManager->hideElement( aResName );
+ aBackupList.push_back( aResName );
}
- }
- catch ( const Exception& )
- {
+ xLayoutManager->hideElement( aResName );
}
}
+ catch ( const Exception& )
+ {
+ }
}
+ }
+
+ // Show toolbars
+ for ( OUString& rName : aMandatoryToolbars )
+ {
+ xLayoutManager->createElement( rName );
+ xLayoutManager->showElement( rName );
+ }
+
+ for ( OUString& rName : aUserToolbars )
+ {
+ xLayoutManager->createElement( rName );
+ xLayoutManager->showElement( rName );
+ }
+
+ // Sidebar
+ pViewFrame->ShowChildWindow( SID_SIDEBAR );
- // Show toolbars
- for ( OUString& rName : aMandatoryToolbars )
+ sfx2::sidebar::SidebarController* pSidebar =
+ sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame );
+ if ( pSidebar )
+ {
+ if ( aSidebarMode.compareTo( "Arrow" ) == 0 )
{
- xLayoutManager->createElement( rName );
- xLayoutManager->showElement( rName );
+ pSidebar->FadeOut();
}
-
- for ( OUString& rName : aUserToolbars )
+ else if ( aSidebarMode.compareTo( "Tabs" ) == 0 )
{
- xLayoutManager->createElement( rName );
- xLayoutManager->showElement( rName );
+ pSidebar->FadeIn();
+ pSidebar->RequestOpenDeck();
+ pSidebar->RequestCloseDeck();
}
-
- // Sidebar
- pViewFrame->ShowChildWindow( SID_SIDEBAR );
-
- sfx2::sidebar::SidebarController* pSidebar =
- sfx2::sidebar::SidebarController::GetSidebarControllerForFrame( xFrame );
- if ( pSidebar )
+ else if ( aSidebarMode.compareTo( "Opened" ) == 0 )
{
- if ( aSidebarMode.compareTo( "Arrow" ) == 0 )
- {
- pSidebar->FadeOut();
- }
- else if ( aSidebarMode.compareTo( "Tabs" ) == 0 )
- {
- pSidebar->FadeIn();
- pSidebar->RequestOpenDeck();
- pSidebar->RequestCloseDeck();
- }
- else if ( aSidebarMode.compareTo( "Opened" ) == 0 )
- {
- pSidebar->FadeIn();
- pSidebar->RequestOpenDeck();
- }
+ pSidebar->FadeIn();
+ pSidebar->RequestOpenDeck();
}
+ }
- // Show/Hide the Notebookbar
- const SfxPoolItem* pItem;
- pViewFrame->GetDispatcher()->QueryState( SID_NOTEBOOKBAR, pItem );
+ // Show/Hide the Notebookbar
+ const SfxPoolItem* pItem;
+ pViewFrame->GetDispatcher()->QueryState( SID_NOTEBOOKBAR, pItem );
- // Save settings
- if ( pViewFrame == SfxViewFrame::Current() )
- {
- css::uno::Sequence<OUString> aBackup( aBackupList.size() );
- for ( size_t i = 0; i < aBackupList.size(); ++i )
- aBackup[i] = aBackupList[i];
+ // Save settings
+ if ( pViewFrame == SfxViewFrame::Current() )
+ {
+ css::uno::Sequence<OUString> aBackup( aBackupList.size() );
+ for ( size_t i = 0; i < aBackupList.size(); ++i )
+ aBackup[i] = aBackupList[i];
- for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex )
- {
- const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) );
- if ( !aModeNode.isValid() )
- continue;
+ for ( sal_Int32 nReadIndex = 0; nReadIndex < nCount; ++nReadIndex )
+ {
+ const utl::OConfigurationNode aModeNode( aModesNode.openNode( aModeNodeNames[nReadIndex] ) );
+ if ( !aModeNode.isValid() )
+ continue;
- OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) );
+ OUString aCommandArg = comphelper::getString( aModeNode.getNodeValue( "CommandArg" ) );
- if ( aCommandArg.compareTo( aCurrentMode ) == 0 )
- {
- aModeNode.setNodeValue( "UserToolbars", makeAny( aBackup ) );
- break;
- }
+ if ( aCommandArg.compareTo( aCurrentMode ) == 0 )
+ {
+ aModeNode.setNodeValue( "UserToolbars", makeAny( aBackup ) );
+ break;
}
- aModesNode.commit();
}
+ aModesNode.commit();
}
}
@@ -963,8 +959,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
if ( xLayoutManager.is() )
{
- OUString aToolbarResName( "private:resource/toolbar/" );
- OUStringBuffer aBuf( aToolbarResName );
+ OUStringBuffer aBuf( "private:resource/toolbar/" );
aBuf.append( pToolbarName->GetValue() );
// Evaluate Parameter