diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-01-13 21:43:27 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-01-14 21:31:32 +0900 |
commit | 1049511c0c5d881df4ba8042744d63d37878296f (patch) | |
tree | b300e1edd156be3f6124313e462ce9ddc6aba3e8 /sfx2/source/view/viewfrm.cxx | |
parent | 1149232c70d3f0383984091df597f3419045ba19 (diff) |
infobar: add buttons one by one with addButton
Change-Id: I5c9da630fe800df8da8ff32d7bb3e6b19fc37a8d
Diffstat (limited to 'sfx2/source/view/viewfrm.cxx')
-rw-r--r-- | sfx2/source/view/viewfrm.cxx | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 3c9a9df554b4..5ba7ef13a3e2 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1379,11 +1379,11 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) } else { - std::vector< PushButton* > aButtons; + SfxInfoBarWindow* pInfoBar = AppendInfoBar("readonly", SfxResId(STR_READONLY_DOCUMENT)); + PushButton* pBtn = new PushButton( &GetWindow(), SfxResId(BT_READONLY_EDIT)); pBtn->SetClickHdl(LINK(this, SfxViewFrame, SwitchReadOnlyHandler)); - aButtons.push_back( pBtn ); - AppendInfoBar("readonly", SfxResId(STR_READONLY_DOCUMENT), aButtons); + pInfoBar->addButton(pBtn); } break; @@ -3357,28 +3357,23 @@ void SfxViewFrame::ActivateToolPanel_Impl( const OUString& i_rPanelURL ) pPanelAccess->ActivateToolPanel( i_rPanelURL ); } -void SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage, std::vector< PushButton* > aButtons ) +SfxInfoBarWindow* SfxViewFrame::AppendInfoBar( const OUString& sId, const OUString& sMessage ) { const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); // Make sure the InfoBar container is visible - if ( !HasChildWindow( nId ) ) - ToggleChildWindow( nId ); - SfxChildWindow* pChild = GetChildWindow( nId ); - if ( pChild ) - { - SfxInfoBarContainerWindow* pInfoBars = static_cast<SfxInfoBarContainerWindow*>( pChild->GetWindow() ); - pInfoBars->appendInfoBar( sId, sMessage, aButtons ); - ShowChildWindow( nId ); - } - else + if (!HasChildWindow(nId)) + ToggleChildWindow(nId); + + SfxChildWindow* pChild = GetChildWindow(nId); + if (pChild) { - SAL_WARN( "sfx.view", "No consumer for InfoBar buttons, so deleting them instead" ); - for (std::vector< PushButton* >::iterator it = aButtons.begin(); it != aButtons.end(); ++it) - { - delete *it; - } + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + SfxInfoBarWindow* pInfoBar = pInfoBarContainer->appendInfoBar(sId, sMessage); + ShowChildWindow(nId); + return pInfoBar; } + return NULL; } void SfxViewFrame::RemoveInfoBar( const OUString& sId ) @@ -3386,15 +3381,16 @@ void SfxViewFrame::RemoveInfoBar( const OUString& sId ) const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId(); // Make sure the InfoBar container is visible - if ( !HasChildWindow( nId ) ) - ToggleChildWindow( nId ); - SfxChildWindow* pChild = GetChildWindow( nId ); - if ( pChild ) - { - SfxInfoBarContainerWindow* pInfoBars = static_cast<SfxInfoBarContainerWindow*>( pChild->GetWindow() ); - SfxInfoBarWindow* pInfoBar = pInfoBars->getInfoBar( sId ); - pInfoBars->removeInfoBar( pInfoBar ); - ShowChildWindow( nId ); + if (!HasChildWindow(nId)) + ToggleChildWindow(nId); + + SfxChildWindow* pChild = GetChildWindow(nId); + if (pChild) + { + SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow()); + SfxInfoBarWindow* pInfoBar = pInfoBarContainer->getInfoBar(sId); + pInfoBarContainer->removeInfoBar(pInfoBar); + ShowChildWindow(nId); } } |