1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
29 #include "sfx2/taskpane.hxx"
30 #include "imagemgr.hxx"
31 #include "sfx2/sfxsids.hrc"
32 #include "sfx2/bindings.hxx"
33 #include "sfx2/dispatch.hxx"
34 #include "sfxresid.hxx"
35 #include "sfxlocal.hrc"
38 /** === begin UNO includes === **/
39 #include <com/sun/star/frame/XModuleManager.hpp>
40 #include <com/sun/star/container/XNameAccess.hpp>
41 #include <com/sun/star/ui/XToolPanel.hpp>
42 #include <com/sun/star/ui/XUIElementFactory.hpp>
43 #include <com/sun/star/awt/XWindowPeer.hpp>
44 #include <com/sun/star/awt/PosSize.hpp>
45 #include <com/sun/star/graphic/GraphicProvider.hpp>
46 #include <com/sun/star/graphic/XGraphicProvider.hpp>
47 #include <com/sun/star/accessibility/XAccessible.hpp>
48 #include <com/sun/star/awt/XControl.hpp>
49 /** === end UNO includes === **/
51 #include <comphelper/componentcontext.hxx>
52 #include <comphelper/namedvaluecollection.hxx>
53 #include <comphelper/types.hxx>
54 #include <comphelper/processfactory.hxx>
55 #include <tools/diagnose_ex.h>
56 #include <svtools/toolpanel/toolpaneldeck.hxx>
57 #include <svtools/toolpanel/tablayouter.hxx>
58 #include <svtools/toolpanel/drawerlayouter.hxx>
59 #include <unotools/confignode.hxx>
60 #include <vcl/menu.hxx>
61 #include <vcl/svapp.hxx>
62 #include <toolkit/helper/vclunohelper.hxx>
63 #include <tools/urlobj.hxx>
64 #include <boost/noncopyable.hpp>
66 //......................................................................................................................
69 //......................................................................................................................
71 /** === begin UNO using === **/
72 using ::com::sun::star::uno::Reference
;
73 using ::com::sun::star::uno::XComponentContext
;
74 using ::com::sun::star::uno::XInterface
;
75 using ::com::sun::star::uno::UNO_QUERY
;
76 using ::com::sun::star::uno::UNO_QUERY_THROW
;
77 using ::com::sun::star::uno::UNO_SET_THROW
;
78 using ::com::sun::star::uno::Exception
;
79 using ::com::sun::star::uno::RuntimeException
;
80 using ::com::sun::star::uno::Any
;
81 using ::com::sun::star::uno::makeAny
;
82 using ::com::sun::star::uno::Sequence
;
83 using ::com::sun::star::uno::Type
;
84 using ::com::sun::star::frame::XModuleManager
;
85 using ::com::sun::star::container::XNameAccess
;
86 using ::com::sun::star::ui::XToolPanel
;
87 using ::com::sun::star::ui::XUIElementFactory
;
88 using ::com::sun::star::ui::XUIElement
;
89 using ::com::sun::star::awt::XWindow
;
90 using ::com::sun::star::frame::XModuleManager
;
91 using ::com::sun::star::frame::XFrame
;
92 using ::com::sun::star::lang::XComponent
;
93 using ::com::sun::star::graphic::XGraphicProvider
;
94 using ::com::sun::star::graphic::XGraphic
;
95 using ::com::sun::star::accessibility::XAccessible
;
96 using ::com::sun::star::awt::XControl
;
97 /** === end UNO using === **/
98 namespace PosSize
= ::com::sun::star::awt::PosSize
;
100 //==================================================================================================================
102 //==================================================================================================================
105 //--------------------------------------------------------------------------------------------------------------
106 ::utl::OConfigurationTreeRoot
lcl_getModuleUIElementStatesConfig( const ::rtl::OUString
& i_rModuleIdentifier
,
107 const ::rtl::OUString
& i_rResourceURL
= ::rtl::OUString() )
109 const ::comphelper::ComponentContext
aContext( ::comphelper::getProcessServiceFactory() );
110 ::rtl::OUStringBuffer aPathComposer
;
113 const Reference
< XNameAccess
> xModuleAccess( aContext
.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW
);
114 const ::comphelper::NamedValueCollection
aModuleProps( xModuleAccess
->getByName( i_rModuleIdentifier
) );
116 const ::rtl::OUString
sWindowStateRef( aModuleProps
.getOrDefault( "ooSetupFactoryWindowStateConfigRef", ::rtl::OUString() ) );
118 aPathComposer
.appendAscii(RTL_CONSTASCII_STRINGPARAM(
119 "org.openoffice.Office.UI."));
120 aPathComposer
.append( sWindowStateRef
);
121 aPathComposer
.appendAscii(RTL_CONSTASCII_STRINGPARAM("/UIElements/States"));
122 if ( !i_rResourceURL
.isEmpty() )
124 aPathComposer
.append('/').append( i_rResourceURL
);
127 catch( const Exception
& )
129 DBG_UNHANDLED_EXCEPTION();
131 return ::utl::OConfigurationTreeRoot( aContext
, aPathComposer
.makeStringAndClear(), false );
134 //--------------------------------------------------------------------------------------------------------------
135 ::rtl::OUString
lcl_identifyModule( const Reference
< XFrame
>& i_rDocumentFrame
)
137 ::rtl::OUString sModuleName
;
140 const ::comphelper::ComponentContext
aContext( ::comphelper::getProcessServiceFactory() );
141 const Reference
< XModuleManager
> xModuleManager( aContext
.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW
);
142 sModuleName
= xModuleManager
->identify( i_rDocumentFrame
);
144 catch( const Exception
& )
146 DBG_UNHANDLED_EXCEPTION();
151 //--------------------------------------------------------------------------------------------------------------
152 Reference
< XFrame
> lcl_getFrame( const SfxBindings
* i_pBindings
)
154 const SfxViewFrame
* pViewFrame
= i_pBindings
->GetDispatcher()->GetFrame();
155 const SfxFrame
& rFrame
= pViewFrame
->GetFrame();
156 const Reference
< XFrame
> xFrame( rFrame
.GetFrameInterface() );
160 //--------------------------------------------------------------------------------------------------------------
161 ::rtl::OUString
lcl_getPanelHelpURL( const ::utl::OConfigurationNode
& i_rPanelConfigNode
)
163 const ::rtl::OUString
sHelpURL( ::comphelper::getString( i_rPanelConfigNode
.getNodeValue( "HelpURL" ) ) );
167 //--------------------------------------------------------------------------------------------------------------
168 Image
lcl_getPanelImage( const Reference
< XFrame
>& i_rDocFrame
, const ::utl::OConfigurationNode
& i_rPanelConfigNode
)
170 const ::rtl::OUString
sImageURL( ::comphelper::getString( i_rPanelConfigNode
.getNodeValue( "ImageURL" ) ) );
171 if ( !sImageURL
.isEmpty() )
175 ::comphelper::NamedValueCollection aMediaProperties
;
176 aMediaProperties
.put( "URL", sImageURL
);
178 // special handling: if the ImageURL denotes a CommandName, then retrieve the image for that command
179 const sal_Char
* pCommandImagePrefix
= "private:commandimage/";
180 const sal_Int32 nCommandImagePrefixLen
= strlen( pCommandImagePrefix
);
181 if ( sImageURL
.compareToAscii( pCommandImagePrefix
, nCommandImagePrefixLen
) == 0 )
183 ::rtl::OUStringBuffer aCommandName
;
184 aCommandName
.appendAscii(RTL_CONSTASCII_STRINGPARAM(".uno:"));
185 aCommandName
.append( sImageURL
.copy( nCommandImagePrefixLen
) );
186 const ::rtl::OUString
sCommandName( aCommandName
.makeStringAndClear() );
188 const Image
aPanelImage( GetImage( i_rDocFrame
, sCommandName
, sal_False
) );
189 return aPanelImage
.GetXGraphic();
192 // otherwise, delegate to the GraphicProvider
193 const Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
194 const Reference
< XGraphicProvider
> xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(xContext
) );
196 const Reference
< XGraphic
> xGraphic( xGraphicProvider
->queryGraphic( aMediaProperties
.getPropertyValues() ), UNO_SET_THROW
);
197 return Image( xGraphic
);
199 catch( const Exception
& )
201 DBG_UNHANDLED_EXCEPTION();
208 //==================================================================================================================
209 //= TaskPaneDockingWindow
210 //==================================================================================================================
211 //------------------------------------------------------------------------------------------------------------------
212 TaskPaneDockingWindow::TaskPaneDockingWindow( SfxBindings
* i_pBindings
, TaskPaneWrapper
& i_rWrapper
, Window
* i_pParent
, WinBits i_nBits
)
213 :TitledDockingWindow( i_pBindings
, &i_rWrapper
, i_pParent
, i_nBits
)
214 ,m_aTaskPane( GetContentWindow(), lcl_getFrame( i_pBindings
) )
215 ,m_aPaneController( m_aTaskPane
, *this )
218 SetText( String( SfxResId( SID_TASKPANE
) ) );
221 //------------------------------------------------------------------------------------------------------------------
222 void TaskPaneDockingWindow::ActivateToolPanel( const ::rtl::OUString
& i_rPanelURL
)
224 m_aPaneController
.ActivateToolPanel( i_rPanelURL
);
227 //------------------------------------------------------------------------------------------------------------------
228 void TaskPaneDockingWindow::GetFocus()
230 TitledDockingWindow::GetFocus();
231 m_aTaskPane
.GrabFocus();
234 //------------------------------------------------------------------------------------------------------------------
235 void TaskPaneDockingWindow::onLayoutDone()
237 m_aTaskPane
.SetPosSizePixel( Point(), GetContentWindow().GetOutputSizePixel() );
240 //==================================================================================================================
242 //==================================================================================================================
243 //------------------------------------------------------------------------------------------------------------------
244 SFX_IMPL_DOCKINGWINDOW( TaskPaneWrapper
, SID_TASKPANE
);
246 //------------------------------------------------------------------------------------------------------------------
247 TaskPaneWrapper::TaskPaneWrapper( Window
* i_pParent
, sal_uInt16 i_nId
, SfxBindings
* i_pBindings
, SfxChildWinInfo
* i_pInfo
)
248 :SfxChildWindow( i_pParent
, i_nId
)
250 pWindow
= new TaskPaneDockingWindow( i_pBindings
, *this, i_pParent
,
251 WB_STDDOCKWIN
| WB_CLIPCHILDREN
| WB_SIZEABLE
| WB_3DLOOK
| WB_ROLLABLE
);
252 eChildAlignment
= SFX_ALIGN_RIGHT
;
254 pWindow
->SetHelpId( HID_TASKPANE_WINDOW
);
255 pWindow
->SetOutputSizePixel( Size( 300, 450 ) );
257 dynamic_cast< SfxDockingWindow
* >( pWindow
)->Initialize( i_pInfo
);
258 SetHideNotDelete( sal_True
);
263 //------------------------------------------------------------------------------------------------------------------
264 void TaskPaneWrapper::ActivateToolPanel( const ::rtl::OUString
& i_rPanelURL
)
266 TaskPaneDockingWindow
* pDockingWindow
= dynamic_cast< TaskPaneDockingWindow
* >( GetWindow() );
267 ENSURE_OR_RETURN_VOID( pDockingWindow
, "TaskPaneWrapper::ActivateToolPanel: invalid docking window implementation!" );
268 pDockingWindow
->ActivateToolPanel( i_rPanelURL
);
271 //==================================================================================================================
272 //= CustomPanelUIElement
273 //==================================================================================================================
274 class CustomPanelUIElement
277 CustomPanelUIElement()
284 CustomPanelUIElement( const Reference
< XUIElement
>& i_rUIElement
)
285 :m_xUIElement( i_rUIElement
, UNO_SET_THROW
)
286 ,m_xToolPanel( i_rUIElement
->getRealInterface(), UNO_QUERY_THROW
)
287 ,m_xPanelWindow( m_xToolPanel
->getWindow(), UNO_SET_THROW
)
291 bool is() const { return m_xPanelWindow
.is(); }
293 const Reference
< XUIElement
>& getUIElement() const { return m_xUIElement
; }
294 const Reference
< XToolPanel
>& getToolPanel() const { return m_xToolPanel
; }
295 const Reference
< XWindow
>& getPanelWindow() const { return m_xPanelWindow
; }
298 Reference
< XUIElement
> m_xUIElement
;
299 Reference
< XToolPanel
> m_xToolPanel
;
300 Reference
< XWindow
> m_xPanelWindow
;
303 //==================================================================================================================
305 //==================================================================================================================
306 class CustomToolPanel
: public ::svt::ToolPanelBase
309 CustomToolPanel( const ::utl::OConfigurationNode
& i_rPanelWindowState
, const Reference
< XFrame
>& i_rFrame
);
311 virtual ::rtl::OUString
GetDisplayName() const;
312 virtual Image
GetImage() const;
313 virtual rtl::OString
GetHelpID() const;
314 virtual void Activate( Window
& i_rParentWindow
);
315 virtual void Deactivate();
316 virtual void SetSizePixel( const Size
& i_rPanelWindowSize
);
317 virtual void GrabFocus();
318 virtual void Dispose();
319 virtual Reference
< XAccessible
>
320 CreatePanelAccessible( const Reference
< XAccessible
>& i_rParentAccessible
);
322 const ::rtl::OUString
&
323 GetResourceURL() const { return m_sResourceURL
; }
329 bool impl_ensureToolPanelWindow( Window
& i_rPanelParentWindow
);
330 void impl_updatePanelConfig( const bool i_bVisible
) const;
333 const ::rtl::OUString m_sUIName
;
334 const Image m_aPanelImage
;
335 const ::rtl::OUString m_aPanelHelpURL
;
336 const ::rtl::OUString m_sResourceURL
;
337 const ::rtl::OUString m_sPanelConfigPath
;
338 Reference
< XFrame
> m_xFrame
;
339 CustomPanelUIElement m_aCustomPanel
;
340 bool m_bAttemptedCreation
;
343 //------------------------------------------------------------------------------------------------------------------
344 CustomToolPanel::CustomToolPanel( const ::utl::OConfigurationNode
& i_rPanelWindowState
, const Reference
< XFrame
>& i_rFrame
)
345 :m_sUIName( ::comphelper::getString( i_rPanelWindowState
.getNodeValue( "UIName" ) ) )
346 ,m_aPanelImage( lcl_getPanelImage( i_rFrame
, i_rPanelWindowState
) )
347 ,m_aPanelHelpURL( lcl_getPanelHelpURL( i_rPanelWindowState
) )
348 ,m_sResourceURL( i_rPanelWindowState
.getLocalName() )
349 ,m_sPanelConfigPath( i_rPanelWindowState
.getNodePath() )
350 ,m_xFrame( i_rFrame
)
352 ,m_bAttemptedCreation( false )
356 //------------------------------------------------------------------------------------------------------------------
357 CustomToolPanel::~CustomToolPanel()
361 //------------------------------------------------------------------------------------------------------------------
362 bool CustomToolPanel::impl_ensureToolPanelWindow( Window
& i_rPanelParentWindow
)
364 if ( m_bAttemptedCreation
)
365 return m_aCustomPanel
.is();
367 m_bAttemptedCreation
= true;
370 const ::comphelper::ComponentContext
aContext( ::comphelper::getProcessServiceFactory() );
371 const Reference
< XUIElementFactory
> xFactory( aContext
.createComponent( "com.sun.star.ui.UIElementFactoryManager" ), UNO_QUERY_THROW
);
373 ::comphelper::NamedValueCollection aCreationArgs
;
374 aCreationArgs
.put( "Frame", makeAny( m_xFrame
) );
375 aCreationArgs
.put( "ParentWindow", makeAny( i_rPanelParentWindow
.GetComponentInterface() ) );
377 const Reference
< XUIElement
> xElement(
378 xFactory
->createUIElement( m_sResourceURL
, aCreationArgs
.getPropertyValues() ),
381 m_aCustomPanel
= CustomPanelUIElement( xElement
);
383 catch( const Exception
& )
385 DBG_UNHANDLED_EXCEPTION();
387 return m_aCustomPanel
.is();
390 //------------------------------------------------------------------------------------------------------------------
391 void CustomToolPanel::impl_updatePanelConfig( const bool i_bVisible
) const
393 ::comphelper::ComponentContext
aContext( ::comphelper::getProcessServiceFactory() );
394 ::utl::OConfigurationTreeRoot
aConfig( aContext
, m_sPanelConfigPath
, true );
396 aConfig
.setNodeValue( "Visible", makeAny( i_bVisible
) );
400 //------------------------------------------------------------------------------------------------------------------
401 ::rtl::OUString
CustomToolPanel::GetDisplayName() const
406 //------------------------------------------------------------------------------------------------------------------
407 Image
CustomToolPanel::GetImage() const
409 return m_aPanelImage
;
412 static rtl::OString
lcl_getHelpId( const ::rtl::OUString
& _rHelpURL
)
414 INetURLObject
aHID( _rHelpURL
);
415 if ( aHID
.GetProtocol() == INET_PROT_HID
)
416 return rtl::OUStringToOString( aHID
.GetURLPath(), RTL_TEXTENCODING_UTF8
);
418 return rtl::OUStringToOString( _rHelpURL
, RTL_TEXTENCODING_UTF8
);
421 //------------------------------------------------------------------------------------------------------------------
422 rtl::OString
CustomToolPanel::GetHelpID() const
424 return lcl_getHelpId( m_aPanelHelpURL
);
427 //------------------------------------------------------------------------------------------------------------------
428 void CustomToolPanel::Activate( Window
& i_rParentWindow
)
430 ENSURE_OR_RETURN_VOID( impl_ensureToolPanelWindow( i_rParentWindow
), "no panel to activate!" );
432 // TODO: we might need a mechanism to decide whether the panel should be destroyed/re-created, or (as it is
433 // done now) hidden/shown
434 m_aCustomPanel
.getPanelWindow()->setVisible( sal_True
);
436 // update the panel's configuration
437 impl_updatePanelConfig( true );
440 //------------------------------------------------------------------------------------------------------------------
441 void CustomToolPanel::Deactivate()
443 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel to deactivate!" );
445 m_aCustomPanel
.getPanelWindow()->setVisible( sal_False
);
447 // update the panel's configuration
448 impl_updatePanelConfig( false );
451 //------------------------------------------------------------------------------------------------------------------
452 void CustomToolPanel::SetSizePixel( const Size
& i_rPanelWindowSize
)
454 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel/window to position!" );
458 m_aCustomPanel
.getPanelWindow()->setPosSize( 0, 0, i_rPanelWindowSize
.Width(), i_rPanelWindowSize
.Height(),
461 catch( const Exception
& )
463 DBG_UNHANDLED_EXCEPTION();
467 //------------------------------------------------------------------------------------------------------------------
468 void CustomToolPanel::GrabFocus()
470 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel/window to focus!" );
472 m_aCustomPanel
.getPanelWindow()->setFocus();
475 //------------------------------------------------------------------------------------------------------------------
476 void CustomToolPanel::Dispose()
478 if ( !m_bAttemptedCreation
)
479 // nothing to dispose
482 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel to destroy!" );
485 Reference
< XComponent
> xUIElementComponent( m_aCustomPanel
.getUIElement(), UNO_QUERY_THROW
);
486 xUIElementComponent
->dispose();
488 catch( const Exception
& )
490 DBG_UNHANDLED_EXCEPTION();
494 //------------------------------------------------------------------------------------------------------------------
495 Reference
< XAccessible
> CustomToolPanel::CreatePanelAccessible( const Reference
< XAccessible
>& i_rParentAccessible
)
497 ENSURE_OR_RETURN( m_aCustomPanel
.is(), "no panel to ask!", NULL
);
499 Reference
< XAccessible
> xPanelAccessible
;
502 xPanelAccessible
.set( m_aCustomPanel
.getToolPanel()->createAccessible( i_rParentAccessible
), UNO_SET_THROW
);
504 catch( const Exception
& )
506 DBG_UNHANDLED_EXCEPTION();
508 return xPanelAccessible
;
511 //==================================================================================================================
512 //= ModuleTaskPane_Impl
513 //==================================================================================================================
514 class ModuleTaskPane_Impl
: public ::boost::noncopyable
517 ModuleTaskPane_Impl( ModuleTaskPane
& i_rAntiImpl
, const Reference
< XFrame
>& i_rDocumentFrame
,
518 const IToolPanelCompare
* i_pPanelCompare
)
519 :m_rAntiImpl( i_rAntiImpl
)
520 ,m_sModuleIdentifier( lcl_identifyModule( i_rDocumentFrame
) )
521 ,m_xFrame( i_rDocumentFrame
)
522 ,m_aPanelDeck( i_rAntiImpl
)
526 impl_initFromConfiguration( i_pPanelCompare
);
529 ~ModuleTaskPane_Impl()
536 static bool ModuleHasToolPanels( const ::rtl::OUString
& i_rModuleIdentifier
);
538 ::svt::ToolPanelDeck
& GetPanelDeck() { return m_aPanelDeck
; }
539 const ::svt::ToolPanelDeck
& GetPanelDeck() const { return m_aPanelDeck
; }
541 ::boost::optional
< size_t >
542 GetPanelPos( const ::rtl::OUString
& i_rResourceURL
);
544 GetPanelResourceURL( const size_t i_nPanelPos
) const;
546 void SetDrawersLayout();
547 void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
);
550 void impl_initFromConfiguration( const IToolPanelCompare
* i_pPanelCompare
);
553 impl_isToolPanelResource( const ::rtl::OUString
& i_rResourceURL
);
555 DECL_LINK( OnActivatePanel
, void* );
558 ModuleTaskPane
& m_rAntiImpl
;
559 const ::rtl::OUString m_sModuleIdentifier
;
560 const Reference
< XFrame
> m_xFrame
;
561 ::svt::ToolPanelDeck m_aPanelDeck
;
564 //------------------------------------------------------------------------------------------------------------------
565 void ModuleTaskPane_Impl::OnResize()
567 m_aPanelDeck
.SetPosSizePixel( Point(), m_rAntiImpl
.GetOutputSizePixel() );
570 //------------------------------------------------------------------------------------------------------------------
571 void ModuleTaskPane_Impl::OnGetFocus()
573 m_aPanelDeck
.GrabFocus();
576 //------------------------------------------------------------------------------------------------------------------
577 IMPL_LINK( ModuleTaskPane_Impl
, OnActivatePanel
, void*, i_pArg
)
579 m_aPanelDeck
.ActivatePanel( reinterpret_cast< size_t >( i_pArg
) );
583 //------------------------------------------------------------------------------------------------------------------
584 bool ModuleTaskPane_Impl::impl_isToolPanelResource( const ::rtl::OUString
& i_rResourceURL
)
586 return i_rResourceURL
.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/" ) );
589 //------------------------------------------------------------------------------------------------------------------
590 void ModuleTaskPane_Impl::impl_initFromConfiguration( const IToolPanelCompare
* i_pPanelCompare
)
592 const ::utl::OConfigurationTreeRoot
aWindowStateConfig( lcl_getModuleUIElementStatesConfig( m_sModuleIdentifier
) );
593 if ( !aWindowStateConfig
.isValid() )
596 ::rtl::OUString sFirstVisiblePanelResource
;
597 ::rtl::OUString sFirstPanelResource
;
599 const Sequence
< ::rtl::OUString
> aUIElements( aWindowStateConfig
.getNodeNames() );
600 for ( const ::rtl::OUString
* resource
= aUIElements
.getConstArray();
601 resource
!= aUIElements
.getConstArray() + aUIElements
.getLength();
605 if ( !impl_isToolPanelResource( *resource
) )
608 sFirstPanelResource
= *resource
;
610 ::utl::OConfigurationNode
aResourceNode( aWindowStateConfig
.openNode( *resource
) );
611 ::svt::PToolPanel
pCustomPanel( new CustomToolPanel( aResourceNode
, m_xFrame
) );
613 size_t nPanelPos
= m_aPanelDeck
.GetPanelCount();
614 if ( i_pPanelCompare
)
616 // assuming that nobody will insert hundreths of panels, a simple O(n) search should suffice here ...
617 while ( nPanelPos
> 0 )
619 const short nCompare
= i_pPanelCompare
->compareToolPanelsURLs(
621 GetPanelResourceURL( --nPanelPos
)
630 nPanelPos
= m_aPanelDeck
.InsertPanel( pCustomPanel
, nPanelPos
);
632 if ( ::comphelper::getBOOL( aResourceNode
.getNodeValue( "Visible" ) ) )
633 sFirstVisiblePanelResource
= *resource
;
636 if ( sFirstVisiblePanelResource
.isEmpty() )
637 sFirstVisiblePanelResource
= sFirstPanelResource
;
639 if ( !sFirstVisiblePanelResource
.isEmpty() )
641 ::boost::optional
< size_t > aPanelPos( GetPanelPos( sFirstVisiblePanelResource
) );
642 OSL_ENSURE( !!aPanelPos
, "ModuleTaskPane_Impl::impl_isToolPanelResource: just inserted it, and it's not there?!" );
644 m_rAntiImpl
.PostUserEvent( LINK( this, ModuleTaskPane_Impl
, OnActivatePanel
), reinterpret_cast< void* >( *aPanelPos
) );
648 //------------------------------------------------------------------------------------------------------------------
649 bool ModuleTaskPane_Impl::ModuleHasToolPanels( const ::rtl::OUString
& i_rModuleIdentifier
)
651 const ::utl::OConfigurationTreeRoot
aWindowStateConfig( lcl_getModuleUIElementStatesConfig( i_rModuleIdentifier
) );
652 if ( !aWindowStateConfig
.isValid() )
655 const Sequence
< ::rtl::OUString
> aUIElements( aWindowStateConfig
.getNodeNames() );
656 for ( const ::rtl::OUString
* resource
= aUIElements
.getConstArray();
657 resource
!= aUIElements
.getConstArray() + aUIElements
.getLength();
661 if ( impl_isToolPanelResource( *resource
) )
667 //------------------------------------------------------------------------------------------------------------------
668 ::boost::optional
< size_t > ModuleTaskPane_Impl::GetPanelPos( const ::rtl::OUString
& i_rResourceURL
)
670 ::boost::optional
< size_t > aPanelPos
;
671 for ( size_t i
= 0; i
< m_aPanelDeck
.GetPanelCount(); ++i
)
673 const ::svt::PToolPanel
pPanel( m_aPanelDeck
.GetPanel( i
) );
674 const CustomToolPanel
* pCustomPanel
= dynamic_cast< const CustomToolPanel
* >( pPanel
.get() );
677 SAL_WARN( "sfx2.dialog", "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!" );
681 if ( pCustomPanel
->GetResourceURL() == i_rResourceURL
)
690 //------------------------------------------------------------------------------------------------------------------
691 ::rtl::OUString
ModuleTaskPane_Impl::GetPanelResourceURL( const size_t i_nPanelPos
) const
693 ENSURE_OR_RETURN( i_nPanelPos
< m_aPanelDeck
.GetPanelCount(), "ModuleTaskPane_Impl::GetPanelResourceURL: illegal panel position!", ::rtl::OUString() );
694 const ::svt::PToolPanel
pPanel( m_aPanelDeck
.GetPanel( i_nPanelPos
) );
695 const CustomToolPanel
* pCustomPanel
= dynamic_cast< const CustomToolPanel
* >( pPanel
.get() );
696 ENSURE_OR_RETURN( pCustomPanel
!= NULL
, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!", ::rtl::OUString() );
697 return pCustomPanel
->GetResourceURL();
700 //------------------------------------------------------------------------------------------------------------------
701 void ModuleTaskPane_Impl::SetDrawersLayout()
703 const ::svt::PDeckLayouter
pLayouter( m_aPanelDeck
.GetLayouter() );
704 const ::svt::DrawerDeckLayouter
* pDrawerLayouter
= dynamic_cast< const ::svt::DrawerDeckLayouter
* >( pLayouter
.get() );
705 if ( pDrawerLayouter
!= NULL
)
706 // already have the proper layout
708 m_aPanelDeck
.SetLayouter( new ::svt::DrawerDeckLayouter( m_aPanelDeck
, m_aPanelDeck
) );
711 //------------------------------------------------------------------------------------------------------------------
712 void ModuleTaskPane_Impl::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
)
714 ::svt::PDeckLayouter
pLayouter( m_aPanelDeck
.GetLayouter() );
715 ::svt::TabDeckLayouter
* pTabLayouter
= dynamic_cast< ::svt::TabDeckLayouter
* >( pLayouter
.get() );
716 if ( ( pTabLayouter
!= NULL
)
717 && ( pTabLayouter
->GetTabAlignment() == i_eTabAlignment
)
718 && ( pTabLayouter
->GetTabItemContent() == i_eTabContent
)
720 // already have the requested layout
723 if ( pTabLayouter
&& ( pTabLayouter
->GetTabAlignment() == i_eTabAlignment
) )
725 // changing only the item content does not require a new layouter instance
726 pTabLayouter
->SetTabItemContent( i_eTabContent
);
730 m_aPanelDeck
.SetLayouter( new ::svt::TabDeckLayouter( m_aPanelDeck
, m_aPanelDeck
, i_eTabAlignment
, i_eTabContent
) );
733 //==================================================================================================================
735 //==================================================================================================================
736 //------------------------------------------------------------------------------------------------------------------
737 ModuleTaskPane::ModuleTaskPane( Window
& i_rParentWindow
, const Reference
< XFrame
>& i_rDocumentFrame
)
738 :Window( &i_rParentWindow
, WB_DIALOGCONTROL
)
739 ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame
, NULL
) )
743 //------------------------------------------------------------------------------------------------------------------
744 ModuleTaskPane::ModuleTaskPane( Window
& i_rParentWindow
, const Reference
< XFrame
>& i_rDocumentFrame
,
745 const IToolPanelCompare
& i_rCompare
)
746 :Window( &i_rParentWindow
, WB_DIALOGCONTROL
)
747 ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame
, &i_rCompare
) )
751 //------------------------------------------------------------------------------------------------------------------
752 ModuleTaskPane::~ModuleTaskPane()
756 //------------------------------------------------------------------------------------------------------------------
757 bool ModuleTaskPane::ModuleHasToolPanels( const Reference
< XFrame
>& i_rDocumentFrame
)
759 return ModuleTaskPane_Impl::ModuleHasToolPanels( lcl_identifyModule( i_rDocumentFrame
) );
762 //------------------------------------------------------------------------------------------------------------------
763 void ModuleTaskPane::Resize()
769 //------------------------------------------------------------------------------------------------------------------
770 void ModuleTaskPane::GetFocus()
773 m_pImpl
->OnGetFocus();
776 //------------------------------------------------------------------------------------------------------------------
777 ::svt::ToolPanelDeck
& ModuleTaskPane::GetPanelDeck()
779 return m_pImpl
->GetPanelDeck();
782 //------------------------------------------------------------------------------------------------------------------
783 const ::svt::ToolPanelDeck
& ModuleTaskPane::GetPanelDeck() const
785 return m_pImpl
->GetPanelDeck();
788 //------------------------------------------------------------------------------------------------------------------
789 ::boost::optional
< size_t > ModuleTaskPane::GetPanelPos( const ::rtl::OUString
& i_rResourceURL
)
791 return m_pImpl
->GetPanelPos( i_rResourceURL
);
794 //------------------------------------------------------------------------------------------------------------------
795 ::rtl::OUString
ModuleTaskPane::GetPanelResourceURL( const size_t i_nPanelPos
) const
797 return m_pImpl
->GetPanelResourceURL( i_nPanelPos
);
800 //------------------------------------------------------------------------------------------------------------------
801 void ModuleTaskPane::SetDrawersLayout()
803 m_pImpl
->SetDrawersLayout();
806 //------------------------------------------------------------------------------------------------------------------
807 void ModuleTaskPane::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
)
809 m_pImpl
->SetTabsLayout( i_eTabAlignment
, i_eTabContent
);
812 // =====================================================================================================================
813 // = PanelSelectorLayout
814 // =====================================================================================================================
815 enum PanelSelectorLayout
824 //==================================================================================================================
826 //==================================================================================================================
829 PanelSelectorLayout
lcl_getTabLayoutFromAlignment( const SfxChildAlignment i_eAlignment
)
831 switch ( i_eAlignment
)
834 return LAYOUT_TABS_LEFT
;
836 return LAYOUT_TABS_TOP
;
837 case SFX_ALIGN_BOTTOM
:
838 return LAYOUT_TABS_BOTTOM
;
840 return LAYOUT_TABS_RIGHT
;
845 // =====================================================================================================================
847 // =====================================================================================================================
848 /** is a helper class for TaskPaneController_Impl, holding the details about a single panel which is not
849 contained in the IToolPanel implementation itself.
851 struct PanelDescriptor
853 ::svt::PToolPanel pPanel
;
862 PanelDescriptor( const ::svt::PToolPanel
& i_rPanel
)
869 //==================================================================================================================
870 //= TaskPaneController_Impl
871 //==================================================================================================================
872 class TaskPaneController_Impl
:public ::boost::noncopyable
873 ,public ::svt::IToolPanelDeckListener
876 TaskPaneController_Impl(
877 ModuleTaskPane
& i_rTaskPane
,
878 TitledDockingWindow
& i_rDockingWindow
880 virtual ~TaskPaneController_Impl();
882 void SetDefaultTitle( const String
& i_rTitle
);
883 void ActivateToolPanel( const ::rtl::OUString
& i_rPanelURL
);
886 // IToolPanelDeckListener overridables
887 virtual void PanelInserted( const ::svt::PToolPanel
& i_pPanel
, const size_t i_nPosition
);
888 virtual void PanelRemoved( const size_t i_nPosition
);
889 virtual void ActivePanelChanged( const ::boost::optional
< size_t >& i_rOldActive
, const ::boost::optional
< size_t >& i_rNewActive
);
890 virtual void LayouterChanged( const ::svt::PDeckLayouter
& i_rNewLayouter
);
891 virtual void Dying();
894 DECL_LINK( OnToolboxClicked
, ToolBox
* );
895 DECL_LINK( OnMenuItemSelected
, Menu
* );
896 DECL_LINK( DockingChanged
, TitledDockingWindow
* );
897 SAL_WNODEPRECATED_DECLARATIONS_PUSH
898 ::std::auto_ptr
< PopupMenu
> impl_createPopupMenu() const;
899 SAL_WNODEPRECATED_DECLARATIONS_POP
901 /// sets the given layout for the panel selector
902 void impl_setLayout( const PanelSelectorLayout i_eLayout
, const bool i_bForce
= false );
904 /// returns the current layout of the panel selector
906 impl_getLayout() const { return m_eCurrentLayout
; }
908 void impl_updateDockingWindowTitle();
909 void impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex
);
910 size_t impl_getLogicalPanelIndex( const size_t i_nVisibleIndex
);
915 MID_UNLOCK_TASK_PANEL
= 1,
916 MID_LOCK_TASK_PANEL
= 2,
918 MID_LAYOUT_DRAWERS
= 4,
923 typedef ::std::vector
< PanelDescriptor
> PanelDescriptors
;
925 ModuleTaskPane
& m_rTaskPane
;
926 TitledDockingWindow
& m_rDockingWindow
;
927 sal_uInt16 m_nViewMenuID
;
928 PanelSelectorLayout m_eCurrentLayout
;
929 PanelDescriptors m_aPanelRepository
;
930 bool m_bTogglingPanelVisibility
;
931 ::rtl::OUString m_sDefaultTitle
;
934 //------------------------------------------------------------------------------------------------------------------
935 TaskPaneController_Impl::TaskPaneController_Impl( ModuleTaskPane
& i_rTaskPane
, TitledDockingWindow
& i_rDockingWindow
)
936 :m_rTaskPane( i_rTaskPane
)
937 ,m_rDockingWindow( i_rDockingWindow
)
939 ,m_eCurrentLayout( LAYOUT_DRAWERS
)
940 ,m_aPanelRepository()
941 ,m_bTogglingPanelVisibility( false )
944 m_rDockingWindow
.ResetToolBox();
945 m_nViewMenuID
= m_rDockingWindow
.AddDropDownToolBoxItem(
946 String( SfxResId( STR_SFX_TASK_PANE_VIEW
) ),
947 HID_TASKPANE_VIEW_MENU
,
948 LINK( this, TaskPaneController_Impl
, OnToolboxClicked
)
950 m_rDockingWindow
.SetEndDockingHdl( LINK( this, TaskPaneController_Impl
, DockingChanged
) );
951 impl_setLayout( LAYOUT_DRAWERS
, true );
953 m_rTaskPane
.GetPanelDeck().AddListener( *this );
955 // initialize the panel repository
956 for ( size_t i
= 0; i
< m_rTaskPane
.GetPanelDeck().GetPanelCount(); ++i
)
958 ::svt::PToolPanel
pPanel( m_rTaskPane
.GetPanelDeck().GetPanel( i
) );
959 m_aPanelRepository
.push_back( PanelDescriptor( pPanel
) );
962 SetDefaultTitle( String( SfxResId( STR_SFX_TASKS
) ) );
965 //------------------------------------------------------------------------------------------------------------------
966 TaskPaneController_Impl::~TaskPaneController_Impl()
968 m_rTaskPane
.GetPanelDeck().RemoveListener( *this );
970 // remove the panels which are not under the control of the panel deck currently
971 for ( PanelDescriptors::iterator panelPos
= m_aPanelRepository
.begin();
972 panelPos
!= m_aPanelRepository
.end();
976 if ( panelPos
->bHidden
)
977 panelPos
->pPanel
->Dispose();
979 m_aPanelRepository
.clear();
982 // -----------------------------------------------------------------------------------------------------------------
983 void TaskPaneController_Impl::SetDefaultTitle( const String
& i_rTitle
)
985 m_sDefaultTitle
= i_rTitle
;
986 impl_updateDockingWindowTitle();
989 //------------------------------------------------------------------------------------------------------------------
990 void TaskPaneController_Impl::ActivateToolPanel( const ::rtl::OUString
& i_rPanelURL
)
992 ::boost::optional
< size_t > aPanelPos( m_rTaskPane
.GetPanelPos( i_rPanelURL
) );
993 ENSURE_OR_RETURN_VOID( !!aPanelPos
, "TaskPaneController_Impl::ActivateToolPanel: no such panel!" );
995 if ( aPanelPos
== m_rTaskPane
.GetPanelDeck().GetActivePanel() )
997 ::svt::PToolPanel
pPanel( m_rTaskPane
.GetPanelDeck().GetPanel( *aPanelPos
) );
1002 m_rTaskPane
.GetPanelDeck().ActivatePanel( aPanelPos
);
1006 // -----------------------------------------------------------------------------------------------------------------
1007 IMPL_LINK( TaskPaneController_Impl
, DockingChanged
, TitledDockingWindow
*, i_pDockingWindow
)
1009 ENSURE_OR_RETURN( i_pDockingWindow
&& &m_rDockingWindow
, "TaskPaneController_Impl::DockingChanged: where does this come from?", 0L );
1011 if ( impl_getLayout() == LAYOUT_DRAWERS
)
1014 impl_setLayout( lcl_getTabLayoutFromAlignment( i_pDockingWindow
->GetAlignment() ) );
1018 // -----------------------------------------------------------------------------------------------------------------
1019 IMPL_LINK( TaskPaneController_Impl
, OnToolboxClicked
, ToolBox
*, i_pToolBox
)
1021 if ( i_pToolBox
->GetCurItemId() == m_nViewMenuID
)
1023 i_pToolBox
->EndSelection();
1025 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1026 ::std::auto_ptr
< PopupMenu
> pMenu
= impl_createPopupMenu();
1027 SAL_WNODEPRECATED_DECLARATIONS_POP
1028 pMenu
->SetSelectHdl( LINK( this, TaskPaneController_Impl
, OnMenuItemSelected
) );
1030 // pass toolbox button rect so the menu can stay open on button up
1031 Rectangle
aMenuRect( i_pToolBox
->GetItemRect( m_nViewMenuID
) );
1032 aMenuRect
.SetPos( i_pToolBox
->GetPosPixel() );
1033 pMenu
->Execute( &m_rDockingWindow
, aMenuRect
, POPUPMENU_EXECUTE_DOWN
);
1039 // ---------------------------------------------------------------------------------------------------------------------
1040 IMPL_LINK( TaskPaneController_Impl
, OnMenuItemSelected
, Menu
*, i_pMenu
)
1042 ENSURE_OR_RETURN( i_pMenu
, "TaskPaneController_Impl::OnMenuItemSelected: illegal menu!", 0L );
1044 i_pMenu
->Deactivate();
1045 switch ( i_pMenu
->GetCurItemId() )
1047 case MID_UNLOCK_TASK_PANEL
:
1048 m_rDockingWindow
.SetFloatingMode( sal_True
);
1051 case MID_LOCK_TASK_PANEL
:
1052 m_rDockingWindow
.SetFloatingMode( sal_False
);
1055 case MID_LAYOUT_DRAWERS
:
1056 impl_setLayout( LAYOUT_DRAWERS
);
1059 case MID_LAYOUT_TABS
:
1060 impl_setLayout( lcl_getTabLayoutFromAlignment( m_rDockingWindow
.GetAlignment() ) );
1065 size_t nPanelIndex
= size_t( i_pMenu
->GetCurItemId() - MID_FIRST_PANEL
);
1066 impl_togglePanelVisibility( nPanelIndex
);
1074 // ---------------------------------------------------------------------------------------------------------------------
1075 size_t TaskPaneController_Impl::impl_getLogicalPanelIndex( const size_t i_nVisibleIndex
)
1077 size_t nLogicalIndex
= 0;
1078 size_t nVisibleIndex( i_nVisibleIndex
);
1079 for ( size_t i
=0; i
< m_aPanelRepository
.size(); ++i
)
1081 if ( !m_aPanelRepository
[i
].bHidden
)
1083 if ( !nVisibleIndex
)
1089 return nLogicalIndex
;
1092 // ---------------------------------------------------------------------------------------------------------------------
1093 void TaskPaneController_Impl::PanelInserted( const ::svt::PToolPanel
& i_pPanel
, const size_t i_nPosition
)
1095 if ( m_bTogglingPanelVisibility
)
1098 const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition
) );
1099 m_aPanelRepository
.insert( m_aPanelRepository
.begin() + nLogicalIndex
, PanelDescriptor( i_pPanel
) );
1102 // ---------------------------------------------------------------------------------------------------------------------
1103 void TaskPaneController_Impl::PanelRemoved( const size_t i_nPosition
)
1105 if ( m_bTogglingPanelVisibility
)
1108 const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition
) );
1109 m_aPanelRepository
.erase( m_aPanelRepository
.begin() + nLogicalIndex
);
1112 // ---------------------------------------------------------------------------------------------------------------------
1113 void TaskPaneController_Impl::ActivePanelChanged( const ::boost::optional
< size_t >& i_rOldActive
, const ::boost::optional
< size_t >& i_rNewActive
)
1115 if ( impl_getLayout() == LAYOUT_DRAWERS
)
1116 // no adjustment of the title when we use the classical "drawers" layout
1119 impl_updateDockingWindowTitle( );
1124 // ---------------------------------------------------------------------------------------------------------------------
1125 void TaskPaneController_Impl::LayouterChanged( const ::svt::PDeckLayouter
& i_rNewLayouter
)
1127 // not interested in
1128 (void)i_rNewLayouter
;
1131 // ---------------------------------------------------------------------------------------------------------------------
1132 void TaskPaneController_Impl::Dying()
1134 OSL_FAIL( "TaskPaneController_Impl::Dying: unexpected call!" );
1135 // We are expected to live longer than the ToolPanelDeck we work with. Since we remove ourself, in our dtor,
1136 // as listener from the panel deck, this method here should never be called.
1139 // ---------------------------------------------------------------------------------------------------------------------
1140 void TaskPaneController_Impl::impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex
)
1142 ENSURE_OR_RETURN_VOID( i_nLogicalPanelIndex
< m_aPanelRepository
.size(), "illegal index" );
1144 // get the actual panel index, within the deck
1145 size_t nActualPanelIndex(0);
1146 for ( size_t i
=0; i
< i_nLogicalPanelIndex
; ++i
)
1148 if ( !m_aPanelRepository
[i
].bHidden
)
1149 ++nActualPanelIndex
;
1152 ::boost::optional
< size_t > aActivatePanel
;
1154 m_bTogglingPanelVisibility
= true;
1155 if ( m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
)
1157 OSL_VERIFY( m_rTaskPane
.GetPanelDeck().InsertPanel( m_aPanelRepository
[ i_nLogicalPanelIndex
].pPanel
, nActualPanelIndex
) == nActualPanelIndex
);
1158 // if there has not been an active panel before, activate the newly inserted one
1159 ::boost::optional
< size_t > aActivePanel( m_rTaskPane
.GetPanelDeck().GetActivePanel() );
1160 if ( !aActivePanel
)
1161 aActivatePanel
= nActualPanelIndex
;
1165 OSL_VERIFY( m_rTaskPane
.GetPanelDeck().RemovePanel( nActualPanelIndex
).get() == m_aPanelRepository
[ i_nLogicalPanelIndex
].pPanel
.get() );
1167 m_bTogglingPanelVisibility
= false;
1168 m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
= !m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
;
1170 if ( !!aActivatePanel
)
1171 m_rTaskPane
.GetPanelDeck().ActivatePanel( *aActivatePanel
);
1174 // ---------------------------------------------------------------------------------------------------------------------
1175 void TaskPaneController_Impl::impl_setLayout( const PanelSelectorLayout i_eLayout
, const bool i_bForce
)
1177 if ( !i_bForce
&& ( m_eCurrentLayout
== i_eLayout
) )
1180 switch ( i_eLayout
)
1182 case LAYOUT_DRAWERS
:
1183 m_rTaskPane
.SetDrawersLayout();
1185 case LAYOUT_TABS_TOP
:
1186 m_rTaskPane
.SetTabsLayout( ::svt::TABS_TOP
, ::svt::TABITEM_IMAGE_ONLY
);
1188 case LAYOUT_TABS_BOTTOM
:
1189 m_rTaskPane
.SetTabsLayout( ::svt::TABS_BOTTOM
, ::svt::TABITEM_IMAGE_ONLY
);
1191 case LAYOUT_TABS_LEFT
:
1192 m_rTaskPane
.SetTabsLayout( ::svt::TABS_LEFT
, ::svt::TABITEM_IMAGE_ONLY
);
1194 case LAYOUT_TABS_RIGHT
:
1195 m_rTaskPane
.SetTabsLayout( ::svt::TABS_RIGHT
, ::svt::TABITEM_IMAGE_ONLY
);
1198 m_eCurrentLayout
= i_eLayout
;
1200 impl_updateDockingWindowTitle();
1203 // ---------------------------------------------------------------------------------------------------------------------
1204 void TaskPaneController_Impl::impl_updateDockingWindowTitle()
1206 ::boost::optional
< size_t > aActivePanel( m_rTaskPane
.GetPanelDeck().GetActivePanel() );
1207 if ( !aActivePanel
|| ( impl_getLayout() == LAYOUT_DRAWERS
) )
1208 m_rDockingWindow
.SetTitle( m_sDefaultTitle
);
1211 size_t nNewActive( *aActivePanel
);
1212 for ( size_t i
=0; i
< m_aPanelRepository
.size(); ++i
)
1214 if ( m_aPanelRepository
[i
].bHidden
)
1219 m_rDockingWindow
.SetTitle( m_aPanelRepository
[i
].pPanel
->GetDisplayName() );
1227 // ---------------------------------------------------------------------------------------------------------------------
1228 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1229 ::std::auto_ptr
< PopupMenu
> TaskPaneController_Impl::impl_createPopupMenu() const
1231 ::std::auto_ptr
<PopupMenu
> pMenu( new PopupMenu
);
1232 FloatingWindow
* pMenuWindow
= static_cast< FloatingWindow
* >( pMenu
->GetWindow() );
1233 if ( pMenuWindow
!= NULL
)
1235 pMenuWindow
->SetPopupModeFlags ( pMenuWindow
->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE
);
1238 // Add one entry for every tool panel element to individually make
1239 // them visible or hide them.
1240 sal_uInt16 nIndex
= MID_FIRST_PANEL
;
1241 for ( size_t i
=0; i
<m_aPanelRepository
.size(); ++i
, ++nIndex
)
1243 const PanelDescriptor
& rPanelDesc( m_aPanelRepository
[i
] );
1244 pMenu
->InsertItem( nIndex
, rPanelDesc
.pPanel
->GetDisplayName(), MIB_CHECKABLE
);
1245 pMenu
->CheckItem( nIndex
, !rPanelDesc
.bHidden
);
1247 pMenu
->InsertSeparator();
1249 #if OSL_DEBUG_LEVEL > 0
1250 pMenu
->InsertItem( MID_LAYOUT_TABS
, String::CreateFromAscii( "Tab-Layout (exp.)" ), MIB_CHECKABLE
);
1251 pMenu
->CheckItem( MID_LAYOUT_TABS
, impl_getLayout() != LAYOUT_DRAWERS
);
1252 pMenu
->InsertItem( MID_LAYOUT_DRAWERS
, String::CreateFromAscii( "Drawer-Layout" ), MIB_CHECKABLE
);
1253 pMenu
->CheckItem( MID_LAYOUT_DRAWERS
, impl_getLayout() == LAYOUT_DRAWERS
);
1255 pMenu
->InsertSeparator();
1258 // Add entry for docking or un-docking the tool panel.
1259 if ( m_rDockingWindow
.IsFloatingMode() )
1261 MID_LOCK_TASK_PANEL
,
1262 String( SfxResId( STR_SFX_DOCK
) )
1266 MID_UNLOCK_TASK_PANEL
,
1267 String( SfxResId( STR_SFX_UNDOCK
) )
1270 pMenu
->RemoveDisabledEntries( sal_False
, sal_False
);
1274 SAL_WNODEPRECATED_DECLARATIONS_POP
1276 //==================================================================================================================
1277 //= TaskPaneController
1278 //==================================================================================================================
1279 //------------------------------------------------------------------------------------------------------------------
1280 TaskPaneController::TaskPaneController( ModuleTaskPane
& i_rTaskPane
, TitledDockingWindow
& i_rDockingWindow
)
1281 :m_pImpl( new TaskPaneController_Impl( i_rTaskPane
, i_rDockingWindow
) )
1285 //------------------------------------------------------------------------------------------------------------------
1286 TaskPaneController::~TaskPaneController()
1290 //------------------------------------------------------------------------------------------------------------------
1291 void TaskPaneController::ActivateToolPanel( const ::rtl::OUString
& i_rPanelURL
)
1293 m_pImpl
->ActivateToolPanel( i_rPanelURL
);
1296 //......................................................................................................................
1298 //......................................................................................................................
1300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */