1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "sfx2/taskpane.hxx"
22 #include "imagemgr.hxx"
23 #include "sfx2/sfxsids.hrc"
24 #include "sfx2/bindings.hxx"
25 #include "sfx2/dispatch.hxx"
26 #include "sfxresid.hxx"
27 #include "sfxlocal.hrc"
30 #include <com/sun/star/frame/ModuleManager.hpp>
31 #include <com/sun/star/container/XNameAccess.hpp>
32 #include <com/sun/star/ui/XToolPanel.hpp>
33 #include <com/sun/star/ui/XUIElementFactory.hpp>
34 #include <com/sun/star/awt/XWindowPeer.hpp>
35 #include <com/sun/star/awt/PosSize.hpp>
36 #include <com/sun/star/graphic/GraphicProvider.hpp>
37 #include <com/sun/star/graphic/XGraphicProvider.hpp>
38 #include <com/sun/star/accessibility/XAccessible.hpp>
39 #include <com/sun/star/awt/XControl.hpp>
40 #include <com/sun/star/ui/UIElementFactoryManager.hpp>
42 #include <comphelper/componentcontext.hxx>
43 #include <comphelper/namedvaluecollection.hxx>
44 #include <comphelper/types.hxx>
45 #include <comphelper/processfactory.hxx>
46 #include <tools/diagnose_ex.h>
47 #include <svtools/miscopt.hxx>
48 #include <svtools/toolpanel/toolpaneldeck.hxx>
49 #include <svtools/toolpanel/tablayouter.hxx>
50 #include <svtools/toolpanel/drawerlayouter.hxx>
51 #include <unotools/confignode.hxx>
52 #include <vcl/menu.hxx>
53 #include <vcl/svapp.hxx>
54 #include <toolkit/helper/vclunohelper.hxx>
55 #include <tools/urlobj.hxx>
56 #include <boost/noncopyable.hpp>
58 //......................................................................................................................
61 //......................................................................................................................
63 using ::com::sun::star::uno::Reference
;
64 using ::com::sun::star::uno::XComponentContext
;
65 using ::com::sun::star::uno::XInterface
;
66 using ::com::sun::star::uno::UNO_QUERY
;
67 using ::com::sun::star::uno::UNO_QUERY_THROW
;
68 using ::com::sun::star::uno::UNO_SET_THROW
;
69 using ::com::sun::star::uno::Exception
;
70 using ::com::sun::star::uno::RuntimeException
;
71 using ::com::sun::star::uno::Any
;
72 using ::com::sun::star::uno::makeAny
;
73 using ::com::sun::star::uno::Sequence
;
74 using ::com::sun::star::uno::Type
;
75 using ::com::sun::star::frame::ModuleManager
;
76 using ::com::sun::star::frame::XModuleManager2
;
77 using ::com::sun::star::container::XNameAccess
;
78 using ::com::sun::star::ui::XToolPanel
;
79 using ::com::sun::star::ui::XUIElementFactory
;
80 using ::com::sun::star::ui::XUIElementFactoryManager
;
81 using ::com::sun::star::ui::UIElementFactoryManager
;
82 using ::com::sun::star::ui::XUIElement
;
83 using ::com::sun::star::awt::XWindow
;
84 using ::com::sun::star::frame::XFrame
;
85 using ::com::sun::star::lang::XComponent
;
86 using ::com::sun::star::graphic::XGraphicProvider
;
87 using ::com::sun::star::graphic::XGraphic
;
88 using ::com::sun::star::accessibility::XAccessible
;
89 using ::com::sun::star::awt::XControl
;
91 namespace PosSize
= ::com::sun::star::awt::PosSize
;
93 //==================================================================================================================
95 //==================================================================================================================
98 //--------------------------------------------------------------------------------------------------------------
99 ::utl::OConfigurationTreeRoot
lcl_getModuleUIElementStatesConfig( const OUString
& i_rModuleIdentifier
,
100 const OUString
& i_rResourceURL
= OUString() )
102 const Reference
<XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
103 OUStringBuffer aPathComposer
;
106 const Reference
< XModuleManager2
> xModuleAccess( ModuleManager::create(xContext
) );
107 const ::comphelper::NamedValueCollection
aModuleProps( xModuleAccess
->getByName( i_rModuleIdentifier
) );
109 const OUString
sWindowStateRef( aModuleProps
.getOrDefault( "ooSetupFactoryWindowStateConfigRef", OUString() ) );
111 aPathComposer
.appendAscii(RTL_CONSTASCII_STRINGPARAM(
112 "org.openoffice.Office.UI."));
113 aPathComposer
.append( sWindowStateRef
);
114 aPathComposer
.appendAscii(RTL_CONSTASCII_STRINGPARAM("/UIElements/States"));
115 if ( !i_rResourceURL
.isEmpty() )
117 aPathComposer
.append('/').append( i_rResourceURL
);
120 catch( const Exception
& )
122 DBG_UNHANDLED_EXCEPTION();
124 return ::utl::OConfigurationTreeRoot( xContext
, aPathComposer
.makeStringAndClear(), false );
127 //--------------------------------------------------------------------------------------------------------------
128 OUString
lcl_identifyModule( const Reference
< XFrame
>& i_rDocumentFrame
)
130 OUString sModuleName
;
133 const Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
134 const Reference
< XModuleManager2
> xModuleManager( ModuleManager::create(xContext
) );
135 sModuleName
= xModuleManager
->identify( i_rDocumentFrame
);
137 catch( const Exception
& )
139 DBG_UNHANDLED_EXCEPTION();
144 //--------------------------------------------------------------------------------------------------------------
145 Reference
< XFrame
> lcl_getFrame( const SfxBindings
* i_pBindings
)
147 const SfxViewFrame
* pViewFrame
= i_pBindings
->GetDispatcher()->GetFrame();
148 const SfxFrame
& rFrame
= pViewFrame
->GetFrame();
149 const Reference
< XFrame
> xFrame( rFrame
.GetFrameInterface() );
153 //--------------------------------------------------------------------------------------------------------------
154 OUString
lcl_getPanelHelpURL( const ::utl::OConfigurationNode
& i_rPanelConfigNode
)
156 const OUString
sHelpURL( ::comphelper::getString( i_rPanelConfigNode
.getNodeValue( "HelpURL" ) ) );
160 //--------------------------------------------------------------------------------------------------------------
161 Image
lcl_getPanelImage( const Reference
< XFrame
>& i_rDocFrame
, const ::utl::OConfigurationNode
& i_rPanelConfigNode
)
163 const OUString
sImageURL( ::comphelper::getString( i_rPanelConfigNode
.getNodeValue( "ImageURL" ) ) );
164 if ( !sImageURL
.isEmpty() )
168 ::comphelper::NamedValueCollection aMediaProperties
;
169 aMediaProperties
.put( "URL", sImageURL
);
171 // special handling: if the ImageURL denotes a CommandName, then retrieve the image for that command
172 static const sal_Char pCommandImagePrefix
[] = "private:commandimage/";
173 const sal_Int32 nCommandImagePrefixLen
= strlen( pCommandImagePrefix
);
174 if ( sImageURL
.startsWith( pCommandImagePrefix
) )
176 OUStringBuffer aCommandName
;
177 aCommandName
.appendAscii(RTL_CONSTASCII_STRINGPARAM(".uno:"));
178 aCommandName
.append( sImageURL
.copy( nCommandImagePrefixLen
) );
179 const OUString
sCommandName( aCommandName
.makeStringAndClear() );
181 const Image
aPanelImage( GetImage( i_rDocFrame
, sCommandName
, sal_False
) );
182 return aPanelImage
.GetXGraphic();
185 // otherwise, delegate to the GraphicProvider
186 const Reference
< XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
187 const Reference
< XGraphicProvider
> xGraphicProvider( com::sun::star::graphic::GraphicProvider::create(xContext
) );
189 const Reference
< XGraphic
> xGraphic( xGraphicProvider
->queryGraphic( aMediaProperties
.getPropertyValues() ), UNO_SET_THROW
);
190 return Image( xGraphic
);
192 catch( const Exception
& )
194 DBG_UNHANDLED_EXCEPTION();
201 //==================================================================================================================
202 //= TaskPaneDockingWindow
203 //==================================================================================================================
204 //------------------------------------------------------------------------------------------------------------------
205 TaskPaneDockingWindow::TaskPaneDockingWindow( SfxBindings
* i_pBindings
, TaskPaneWrapper
& i_rWrapper
, Window
* i_pParent
, WinBits i_nBits
)
206 :TitledDockingWindow( i_pBindings
, &i_rWrapper
, i_pParent
, i_nBits
)
207 ,m_aTaskPane( GetContentWindow(), lcl_getFrame( i_pBindings
) )
208 ,m_aPaneController( m_aTaskPane
, *this )
211 SetText( SfxResId( SID_TASKPANE
).toString() );
214 //------------------------------------------------------------------------------------------------------------------
215 void TaskPaneDockingWindow::ActivateToolPanel( const OUString
& i_rPanelURL
)
217 m_aPaneController
.ActivateToolPanel( i_rPanelURL
);
220 //------------------------------------------------------------------------------------------------------------------
221 void TaskPaneDockingWindow::GetFocus()
223 TitledDockingWindow::GetFocus();
224 m_aTaskPane
.GrabFocus();
227 //------------------------------------------------------------------------------------------------------------------
228 void TaskPaneDockingWindow::onLayoutDone()
230 m_aTaskPane
.SetPosSizePixel( Point(), GetContentWindow().GetOutputSizePixel() );
233 //==================================================================================================================
235 //==================================================================================================================
236 //------------------------------------------------------------------------------------------------------------------
237 SFX_IMPL_DOCKINGWINDOW( TaskPaneWrapper
, SID_TASKPANE
);
239 //------------------------------------------------------------------------------------------------------------------
240 TaskPaneWrapper::TaskPaneWrapper( Window
* i_pParent
, sal_uInt16 i_nId
, SfxBindings
* i_pBindings
, SfxChildWinInfo
* i_pInfo
)
241 :SfxChildWindow( i_pParent
, i_nId
)
243 pWindow
= new TaskPaneDockingWindow( i_pBindings
, *this, i_pParent
,
244 WB_STDDOCKWIN
| WB_CLIPCHILDREN
| WB_SIZEABLE
| WB_3DLOOK
| WB_ROLLABLE
);
245 eChildAlignment
= SFX_ALIGN_RIGHT
;
247 pWindow
->SetHelpId( HID_TASKPANE_WINDOW
);
248 pWindow
->SetOutputSizePixel( Size( 300, 450 ) );
250 dynamic_cast< SfxDockingWindow
* >( pWindow
)->Initialize( i_pInfo
);
251 SetHideNotDelete( sal_True
);
256 //------------------------------------------------------------------------------------------------------------------
257 void TaskPaneWrapper::ActivateToolPanel( const OUString
& i_rPanelURL
)
259 TaskPaneDockingWindow
* pDockingWindow
= dynamic_cast< TaskPaneDockingWindow
* >( GetWindow() );
260 ENSURE_OR_RETURN_VOID( pDockingWindow
, "TaskPaneWrapper::ActivateToolPanel: invalid docking window implementation!" );
261 pDockingWindow
->ActivateToolPanel( i_rPanelURL
);
264 //==================================================================================================================
265 //= CustomPanelUIElement
266 //==================================================================================================================
267 class CustomPanelUIElement
270 CustomPanelUIElement()
277 CustomPanelUIElement( const Reference
< XUIElement
>& i_rUIElement
)
278 :m_xUIElement( i_rUIElement
, UNO_SET_THROW
)
279 ,m_xToolPanel( i_rUIElement
->getRealInterface(), UNO_QUERY_THROW
)
280 ,m_xPanelWindow( m_xToolPanel
->getWindow(), UNO_SET_THROW
)
284 bool is() const { return m_xPanelWindow
.is(); }
286 const Reference
< XUIElement
>& getUIElement() const { return m_xUIElement
; }
287 const Reference
< XToolPanel
>& getToolPanel() const { return m_xToolPanel
; }
288 const Reference
< XWindow
>& getPanelWindow() const { return m_xPanelWindow
; }
291 Reference
< XUIElement
> m_xUIElement
;
292 Reference
< XToolPanel
> m_xToolPanel
;
293 Reference
< XWindow
> m_xPanelWindow
;
296 //==================================================================================================================
298 //==================================================================================================================
299 class CustomToolPanel
: public ::svt::ToolPanelBase
302 CustomToolPanel( const ::utl::OConfigurationNode
& i_rPanelWindowState
, const Reference
< XFrame
>& i_rFrame
);
304 virtual OUString
GetDisplayName() const;
305 virtual Image
GetImage() const;
306 virtual OString
GetHelpID() const;
307 virtual void Activate( Window
& i_rParentWindow
);
308 virtual void Deactivate();
309 virtual void SetSizePixel( const Size
& i_rPanelWindowSize
);
310 virtual void GrabFocus();
311 virtual void Dispose();
312 virtual Reference
< XAccessible
>
313 CreatePanelAccessible( const Reference
< XAccessible
>& i_rParentAccessible
);
316 GetResourceURL() const { return m_sResourceURL
; }
322 bool impl_ensureToolPanelWindow( Window
& i_rPanelParentWindow
);
323 void impl_updatePanelConfig( const bool i_bVisible
) const;
326 const OUString m_sUIName
;
327 const Image m_aPanelImage
;
328 const OUString m_aPanelHelpURL
;
329 const OUString m_sResourceURL
;
330 const OUString m_sPanelConfigPath
;
331 Reference
< XFrame
> m_xFrame
;
332 CustomPanelUIElement m_aCustomPanel
;
333 bool m_bAttemptedCreation
;
336 //------------------------------------------------------------------------------------------------------------------
337 CustomToolPanel::CustomToolPanel( const ::utl::OConfigurationNode
& i_rPanelWindowState
, const Reference
< XFrame
>& i_rFrame
)
338 :m_sUIName( ::comphelper::getString( i_rPanelWindowState
.getNodeValue( "UIName" ) ) )
339 ,m_aPanelImage( lcl_getPanelImage( i_rFrame
, i_rPanelWindowState
) )
340 ,m_aPanelHelpURL( lcl_getPanelHelpURL( i_rPanelWindowState
) )
341 ,m_sResourceURL( i_rPanelWindowState
.getLocalName() )
342 ,m_sPanelConfigPath( i_rPanelWindowState
.getNodePath() )
343 ,m_xFrame( i_rFrame
)
345 ,m_bAttemptedCreation( false )
349 //------------------------------------------------------------------------------------------------------------------
350 CustomToolPanel::~CustomToolPanel()
354 //------------------------------------------------------------------------------------------------------------------
355 bool CustomToolPanel::impl_ensureToolPanelWindow( Window
& i_rPanelParentWindow
)
357 if ( m_bAttemptedCreation
)
358 return m_aCustomPanel
.is();
360 m_bAttemptedCreation
= true;
363 const Reference
< XUIElementFactoryManager
> xFactory
= UIElementFactoryManager::create( ::comphelper::getProcessComponentContext() );
365 ::comphelper::NamedValueCollection aCreationArgs
;
366 aCreationArgs
.put( "Frame", makeAny( m_xFrame
) );
367 aCreationArgs
.put( "ParentWindow", makeAny( i_rPanelParentWindow
.GetComponentInterface() ) );
369 const Reference
< XUIElement
> xElement(
370 xFactory
->createUIElement( m_sResourceURL
, aCreationArgs
.getPropertyValues() ),
373 m_aCustomPanel
= CustomPanelUIElement( xElement
);
375 catch( const Exception
& )
377 DBG_UNHANDLED_EXCEPTION();
379 return m_aCustomPanel
.is();
382 //------------------------------------------------------------------------------------------------------------------
383 void CustomToolPanel::impl_updatePanelConfig( const bool i_bVisible
) const
385 ::utl::OConfigurationTreeRoot
aConfig( ::comphelper::getProcessComponentContext(), m_sPanelConfigPath
, true );
387 aConfig
.setNodeValue( "Visible", makeAny( i_bVisible
) );
391 //------------------------------------------------------------------------------------------------------------------
392 OUString
CustomToolPanel::GetDisplayName() const
397 //------------------------------------------------------------------------------------------------------------------
398 Image
CustomToolPanel::GetImage() const
400 return m_aPanelImage
;
403 static OString
lcl_getHelpId( const OUString
& _rHelpURL
)
405 INetURLObject
aHID( _rHelpURL
);
406 if ( aHID
.GetProtocol() == INET_PROT_HID
)
407 return OUStringToOString( aHID
.GetURLPath(), RTL_TEXTENCODING_UTF8
);
409 return OUStringToOString( _rHelpURL
, RTL_TEXTENCODING_UTF8
);
412 //------------------------------------------------------------------------------------------------------------------
413 OString
CustomToolPanel::GetHelpID() const
415 return lcl_getHelpId( m_aPanelHelpURL
);
418 //------------------------------------------------------------------------------------------------------------------
419 void CustomToolPanel::Activate( Window
& i_rParentWindow
)
421 ENSURE_OR_RETURN_VOID( impl_ensureToolPanelWindow( i_rParentWindow
), "no panel to activate!" );
423 // TODO: we might need a mechanism to decide whether the panel should be destroyed/re-created, or (as it is
424 // done now) hidden/shown
425 m_aCustomPanel
.getPanelWindow()->setVisible( sal_True
);
427 // update the panel's configuration
428 impl_updatePanelConfig( true );
431 //------------------------------------------------------------------------------------------------------------------
432 void CustomToolPanel::Deactivate()
434 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel to deactivate!" );
436 m_aCustomPanel
.getPanelWindow()->setVisible( sal_False
);
438 // update the panel's configuration
439 impl_updatePanelConfig( false );
442 //------------------------------------------------------------------------------------------------------------------
443 void CustomToolPanel::SetSizePixel( const Size
& i_rPanelWindowSize
)
445 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel/window to position!" );
449 m_aCustomPanel
.getPanelWindow()->setPosSize( 0, 0, i_rPanelWindowSize
.Width(), i_rPanelWindowSize
.Height(),
452 catch( const Exception
& )
454 DBG_UNHANDLED_EXCEPTION();
458 //------------------------------------------------------------------------------------------------------------------
459 void CustomToolPanel::GrabFocus()
461 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel/window to focus!" );
463 m_aCustomPanel
.getPanelWindow()->setFocus();
466 //------------------------------------------------------------------------------------------------------------------
467 void CustomToolPanel::Dispose()
469 if ( !m_bAttemptedCreation
)
470 // nothing to dispose
473 ENSURE_OR_RETURN_VOID( m_aCustomPanel
.is(), "no panel to destroy!" );
476 Reference
< XComponent
> xUIElementComponent( m_aCustomPanel
.getUIElement(), UNO_QUERY_THROW
);
477 xUIElementComponent
->dispose();
479 catch( const Exception
& )
481 DBG_UNHANDLED_EXCEPTION();
485 //------------------------------------------------------------------------------------------------------------------
486 Reference
< XAccessible
> CustomToolPanel::CreatePanelAccessible( const Reference
< XAccessible
>& i_rParentAccessible
)
488 ENSURE_OR_RETURN( m_aCustomPanel
.is(), "no panel to ask!", NULL
);
490 Reference
< XAccessible
> xPanelAccessible
;
493 xPanelAccessible
.set( m_aCustomPanel
.getToolPanel()->createAccessible( i_rParentAccessible
), UNO_SET_THROW
);
495 catch( const Exception
& )
497 DBG_UNHANDLED_EXCEPTION();
499 return xPanelAccessible
;
502 //==================================================================================================================
503 //= ModuleTaskPane_Impl
504 //==================================================================================================================
505 class ModuleTaskPane_Impl
: public ::boost::noncopyable
508 ModuleTaskPane_Impl( ModuleTaskPane
& i_rAntiImpl
, const Reference
< XFrame
>& i_rDocumentFrame
,
509 const IToolPanelCompare
* i_pPanelCompare
)
510 :m_rAntiImpl( i_rAntiImpl
)
511 ,m_sModuleIdentifier( lcl_identifyModule( i_rDocumentFrame
) )
512 ,m_xFrame( i_rDocumentFrame
)
513 ,m_aPanelDeck( i_rAntiImpl
)
517 impl_initFromConfiguration( i_pPanelCompare
);
520 ~ModuleTaskPane_Impl()
527 static bool ModuleHasToolPanels( const OUString
& i_rModuleIdentifier
);
529 ::svt::ToolPanelDeck
& GetPanelDeck() { return m_aPanelDeck
; }
530 const ::svt::ToolPanelDeck
& GetPanelDeck() const { return m_aPanelDeck
; }
532 ::boost::optional
< size_t >
533 GetPanelPos( const OUString
& i_rResourceURL
);
535 GetPanelResourceURL( const size_t i_nPanelPos
) const;
537 void SetDrawersLayout();
538 void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
);
541 void impl_initFromConfiguration( const IToolPanelCompare
* i_pPanelCompare
);
544 impl_isToolPanelResource( const OUString
& i_rResourceURL
);
546 DECL_LINK( OnActivatePanel
, void* );
549 ModuleTaskPane
& m_rAntiImpl
;
550 const OUString m_sModuleIdentifier
;
551 const Reference
< XFrame
> m_xFrame
;
552 ::svt::ToolPanelDeck m_aPanelDeck
;
555 //------------------------------------------------------------------------------------------------------------------
556 void ModuleTaskPane_Impl::OnResize()
558 m_aPanelDeck
.SetPosSizePixel( Point(), m_rAntiImpl
.GetOutputSizePixel() );
561 //------------------------------------------------------------------------------------------------------------------
562 void ModuleTaskPane_Impl::OnGetFocus()
564 m_aPanelDeck
.GrabFocus();
567 //------------------------------------------------------------------------------------------------------------------
568 IMPL_LINK( ModuleTaskPane_Impl
, OnActivatePanel
, void*, i_pArg
)
570 m_aPanelDeck
.ActivatePanel( reinterpret_cast< size_t >( i_pArg
) );
574 //------------------------------------------------------------------------------------------------------------------
575 bool ModuleTaskPane_Impl::impl_isToolPanelResource( const OUString
& i_rResourceURL
)
577 return i_rResourceURL
.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/" ) );
580 //------------------------------------------------------------------------------------------------------------------
581 void ModuleTaskPane_Impl::impl_initFromConfiguration( const IToolPanelCompare
* i_pPanelCompare
)
583 const ::utl::OConfigurationTreeRoot
aWindowStateConfig( lcl_getModuleUIElementStatesConfig( m_sModuleIdentifier
) );
584 if ( !aWindowStateConfig
.isValid() )
587 OUString sFirstVisiblePanelResource
;
588 OUString sFirstPanelResource
;
590 const Sequence
< OUString
> aUIElements( aWindowStateConfig
.getNodeNames() );
591 for ( const OUString
* resource
= aUIElements
.getConstArray();
592 resource
!= aUIElements
.getConstArray() + aUIElements
.getLength();
596 if ( !impl_isToolPanelResource( *resource
) )
599 sFirstPanelResource
= *resource
;
601 ::utl::OConfigurationNode
aResourceNode( aWindowStateConfig
.openNode( *resource
) );
602 ::svt::PToolPanel
pCustomPanel( new CustomToolPanel( aResourceNode
, m_xFrame
) );
604 size_t nPanelPos
= m_aPanelDeck
.GetPanelCount();
605 if ( i_pPanelCompare
)
607 // assuming that nobody will insert hundreths of panels, a simple O(n) search should suffice here ...
608 while ( nPanelPos
> 0 )
610 const short nCompare
= i_pPanelCompare
->compareToolPanelsURLs(
612 GetPanelResourceURL( --nPanelPos
)
621 nPanelPos
= m_aPanelDeck
.InsertPanel( pCustomPanel
, nPanelPos
);
623 if ( ::comphelper::getBOOL( aResourceNode
.getNodeValue( "Visible" ) ) )
624 sFirstVisiblePanelResource
= *resource
;
627 if ( sFirstVisiblePanelResource
.isEmpty() )
628 sFirstVisiblePanelResource
= sFirstPanelResource
;
630 if ( !sFirstVisiblePanelResource
.isEmpty() )
632 ::boost::optional
< size_t > aPanelPos( GetPanelPos( sFirstVisiblePanelResource
) );
633 OSL_ENSURE( !!aPanelPos
, "ModuleTaskPane_Impl::impl_isToolPanelResource: just inserted it, and it's not there?!" );
635 m_rAntiImpl
.PostUserEvent( LINK( this, ModuleTaskPane_Impl
, OnActivatePanel
), reinterpret_cast< void* >( *aPanelPos
) );
639 //------------------------------------------------------------------------------------------------------------------
640 bool ModuleTaskPane_Impl::ModuleHasToolPanels( const OUString
& i_rModuleIdentifier
)
642 const ::utl::OConfigurationTreeRoot
aWindowStateConfig( lcl_getModuleUIElementStatesConfig( i_rModuleIdentifier
) );
643 if ( !aWindowStateConfig
.isValid() )
646 const Sequence
< OUString
> aUIElements( aWindowStateConfig
.getNodeNames() );
647 for ( const OUString
* resource
= aUIElements
.getConstArray();
648 resource
!= aUIElements
.getConstArray() + aUIElements
.getLength();
652 if ( impl_isToolPanelResource( *resource
) )
658 //------------------------------------------------------------------------------------------------------------------
659 ::boost::optional
< size_t > ModuleTaskPane_Impl::GetPanelPos( const OUString
& i_rResourceURL
)
661 ::boost::optional
< size_t > aPanelPos
;
662 for ( size_t i
= 0; i
< m_aPanelDeck
.GetPanelCount(); ++i
)
664 const ::svt::PToolPanel
pPanel( m_aPanelDeck
.GetPanel( i
) );
665 const CustomToolPanel
* pCustomPanel
= dynamic_cast< const CustomToolPanel
* >( pPanel
.get() );
668 SAL_WARN( "sfx2.dialog", "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!" );
672 if ( pCustomPanel
->GetResourceURL() == i_rResourceURL
)
681 //------------------------------------------------------------------------------------------------------------------
682 OUString
ModuleTaskPane_Impl::GetPanelResourceURL( const size_t i_nPanelPos
) const
684 ENSURE_OR_RETURN( i_nPanelPos
< m_aPanelDeck
.GetPanelCount(), "ModuleTaskPane_Impl::GetPanelResourceURL: illegal panel position!", OUString() );
685 const ::svt::PToolPanel
pPanel( m_aPanelDeck
.GetPanel( i_nPanelPos
) );
686 const CustomToolPanel
* pCustomPanel
= dynamic_cast< const CustomToolPanel
* >( pPanel
.get() );
687 ENSURE_OR_RETURN( pCustomPanel
!= NULL
, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!", OUString() );
688 return pCustomPanel
->GetResourceURL();
691 //------------------------------------------------------------------------------------------------------------------
692 void ModuleTaskPane_Impl::SetDrawersLayout()
694 const ::svt::PDeckLayouter
pLayouter( m_aPanelDeck
.GetLayouter() );
695 const ::svt::DrawerDeckLayouter
* pDrawerLayouter
= dynamic_cast< const ::svt::DrawerDeckLayouter
* >( pLayouter
.get() );
696 if ( pDrawerLayouter
!= NULL
)
697 // already have the proper layout
699 m_aPanelDeck
.SetLayouter( new ::svt::DrawerDeckLayouter( m_aPanelDeck
, m_aPanelDeck
) );
702 //------------------------------------------------------------------------------------------------------------------
703 void ModuleTaskPane_Impl::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
)
705 ::svt::PDeckLayouter
pLayouter( m_aPanelDeck
.GetLayouter() );
706 ::svt::TabDeckLayouter
* pTabLayouter
= dynamic_cast< ::svt::TabDeckLayouter
* >( pLayouter
.get() );
707 if ( ( pTabLayouter
!= NULL
)
708 && ( pTabLayouter
->GetTabAlignment() == i_eTabAlignment
)
709 && ( pTabLayouter
->GetTabItemContent() == i_eTabContent
)
711 // already have the requested layout
714 if ( pTabLayouter
&& ( pTabLayouter
->GetTabAlignment() == i_eTabAlignment
) )
716 // changing only the item content does not require a new layouter instance
717 pTabLayouter
->SetTabItemContent( i_eTabContent
);
721 m_aPanelDeck
.SetLayouter( new ::svt::TabDeckLayouter( m_aPanelDeck
, m_aPanelDeck
, i_eTabAlignment
, i_eTabContent
) );
724 //==================================================================================================================
726 //==================================================================================================================
727 //------------------------------------------------------------------------------------------------------------------
728 ModuleTaskPane::ModuleTaskPane( Window
& i_rParentWindow
, const Reference
< XFrame
>& i_rDocumentFrame
)
729 :Window( &i_rParentWindow
, WB_DIALOGCONTROL
)
730 ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame
, NULL
) )
734 //------------------------------------------------------------------------------------------------------------------
735 ModuleTaskPane::ModuleTaskPane( Window
& i_rParentWindow
, const Reference
< XFrame
>& i_rDocumentFrame
,
736 const IToolPanelCompare
& i_rCompare
)
737 :Window( &i_rParentWindow
, WB_DIALOGCONTROL
)
738 ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame
, &i_rCompare
) )
742 //------------------------------------------------------------------------------------------------------------------
743 ModuleTaskPane::~ModuleTaskPane()
747 //------------------------------------------------------------------------------------------------------------------
748 bool ModuleTaskPane::ModuleHasToolPanels( const Reference
< XFrame
>& i_rDocumentFrame
)
750 return ModuleTaskPane_Impl::ModuleHasToolPanels( lcl_identifyModule( i_rDocumentFrame
) );
753 //------------------------------------------------------------------------------------------------------------------
754 void ModuleTaskPane::Resize()
760 //------------------------------------------------------------------------------------------------------------------
761 void ModuleTaskPane::GetFocus()
764 m_pImpl
->OnGetFocus();
767 //------------------------------------------------------------------------------------------------------------------
768 ::svt::ToolPanelDeck
& ModuleTaskPane::GetPanelDeck()
770 return m_pImpl
->GetPanelDeck();
773 //------------------------------------------------------------------------------------------------------------------
774 const ::svt::ToolPanelDeck
& ModuleTaskPane::GetPanelDeck() const
776 return m_pImpl
->GetPanelDeck();
779 //------------------------------------------------------------------------------------------------------------------
780 ::boost::optional
< size_t > ModuleTaskPane::GetPanelPos( const OUString
& i_rResourceURL
)
782 return m_pImpl
->GetPanelPos( i_rResourceURL
);
785 //------------------------------------------------------------------------------------------------------------------
786 OUString
ModuleTaskPane::GetPanelResourceURL( const size_t i_nPanelPos
) const
788 return m_pImpl
->GetPanelResourceURL( i_nPanelPos
);
791 //------------------------------------------------------------------------------------------------------------------
792 void ModuleTaskPane::SetDrawersLayout()
794 m_pImpl
->SetDrawersLayout();
797 //------------------------------------------------------------------------------------------------------------------
798 void ModuleTaskPane::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment
, const ::svt::TabItemContent i_eTabContent
)
800 m_pImpl
->SetTabsLayout( i_eTabAlignment
, i_eTabContent
);
803 // =====================================================================================================================
804 // = PanelSelectorLayout
805 // =====================================================================================================================
806 enum PanelSelectorLayout
815 //==================================================================================================================
817 //==================================================================================================================
820 PanelSelectorLayout
lcl_getTabLayoutFromAlignment( const SfxChildAlignment i_eAlignment
)
822 switch ( i_eAlignment
)
825 return LAYOUT_TABS_LEFT
;
827 return LAYOUT_TABS_TOP
;
828 case SFX_ALIGN_BOTTOM
:
829 return LAYOUT_TABS_BOTTOM
;
831 return LAYOUT_TABS_RIGHT
;
836 // =====================================================================================================================
838 // =====================================================================================================================
839 /** is a helper class for TaskPaneController_Impl, holding the details about a single panel which is not
840 contained in the IToolPanel implementation itself.
842 struct PanelDescriptor
844 ::svt::PToolPanel pPanel
;
853 PanelDescriptor( const ::svt::PToolPanel
& i_rPanel
)
860 //==================================================================================================================
861 //= TaskPaneController_Impl
862 //==================================================================================================================
863 class TaskPaneController_Impl
:public ::boost::noncopyable
864 ,public ::svt::IToolPanelDeckListener
867 TaskPaneController_Impl(
868 ModuleTaskPane
& i_rTaskPane
,
869 TitledDockingWindow
& i_rDockingWindow
871 virtual ~TaskPaneController_Impl();
873 void SetDefaultTitle( const String
& i_rTitle
);
874 void ActivateToolPanel( const OUString
& i_rPanelURL
);
877 // IToolPanelDeckListener overridables
878 virtual void PanelInserted( const ::svt::PToolPanel
& i_pPanel
, const size_t i_nPosition
);
879 virtual void PanelRemoved( const size_t i_nPosition
);
880 virtual void ActivePanelChanged( const ::boost::optional
< size_t >& i_rOldActive
, const ::boost::optional
< size_t >& i_rNewActive
);
881 virtual void LayouterChanged( const ::svt::PDeckLayouter
& i_rNewLayouter
);
882 virtual void Dying();
885 DECL_LINK( OnToolboxClicked
, ToolBox
* );
886 DECL_LINK( OnMenuItemSelected
, Menu
* );
887 DECL_LINK( DockingChanged
, TitledDockingWindow
* );
888 SAL_WNODEPRECATED_DECLARATIONS_PUSH
889 ::std::auto_ptr
< PopupMenu
> impl_createPopupMenu() const;
890 SAL_WNODEPRECATED_DECLARATIONS_POP
892 /// sets the given layout for the panel selector
893 void impl_setLayout( const PanelSelectorLayout i_eLayout
, const bool i_bForce
= false );
895 /// returns the current layout of the panel selector
897 impl_getLayout() const { return m_eCurrentLayout
; }
899 void impl_updateDockingWindowTitle();
900 void impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex
);
901 size_t impl_getLogicalPanelIndex( const size_t i_nVisibleIndex
);
906 MID_UNLOCK_TASK_PANEL
= 1,
907 MID_LOCK_TASK_PANEL
= 2,
909 MID_LAYOUT_DRAWERS
= 4,
914 typedef ::std::vector
< PanelDescriptor
> PanelDescriptors
;
916 ModuleTaskPane
& m_rTaskPane
;
917 TitledDockingWindow
& m_rDockingWindow
;
918 sal_uInt16 m_nViewMenuID
;
919 PanelSelectorLayout m_eCurrentLayout
;
920 PanelDescriptors m_aPanelRepository
;
921 bool m_bTogglingPanelVisibility
;
922 OUString m_sDefaultTitle
;
925 //------------------------------------------------------------------------------------------------------------------
926 TaskPaneController_Impl::TaskPaneController_Impl( ModuleTaskPane
& i_rTaskPane
, TitledDockingWindow
& i_rDockingWindow
)
927 :m_rTaskPane( i_rTaskPane
)
928 ,m_rDockingWindow( i_rDockingWindow
)
930 ,m_eCurrentLayout( LAYOUT_DRAWERS
)
931 ,m_aPanelRepository()
932 ,m_bTogglingPanelVisibility( false )
935 m_rDockingWindow
.ResetToolBox();
936 m_nViewMenuID
= m_rDockingWindow
.AddDropDownToolBoxItem(
937 SfxResId( STR_SFX_TASK_PANE_VIEW
).toString(),
938 HID_TASKPANE_VIEW_MENU
,
939 LINK( this, TaskPaneController_Impl
, OnToolboxClicked
)
941 m_rDockingWindow
.SetEndDockingHdl( LINK( this, TaskPaneController_Impl
, DockingChanged
) );
942 impl_setLayout(LAYOUT_DRAWERS
, true);
944 m_rTaskPane
.GetPanelDeck().AddListener( *this );
946 // initialize the panel repository
947 for ( size_t i
= 0; i
< m_rTaskPane
.GetPanelDeck().GetPanelCount(); ++i
)
949 ::svt::PToolPanel
pPanel( m_rTaskPane
.GetPanelDeck().GetPanel( i
) );
950 m_aPanelRepository
.push_back( PanelDescriptor( pPanel
) );
953 SetDefaultTitle( SfxResId( STR_SFX_TASKS
).toString() );
956 //------------------------------------------------------------------------------------------------------------------
957 TaskPaneController_Impl::~TaskPaneController_Impl()
959 m_rTaskPane
.GetPanelDeck().RemoveListener( *this );
962 // remove the panels which are not under the control of the panel deck currently
963 for ( PanelDescriptors::iterator panelPos
= m_aPanelRepository
.begin();
964 panelPos
!= m_aPanelRepository
.end();
968 if ( panelPos
->bHidden
)
969 impl_togglePanelVisibility( i
);
971 m_aPanelRepository
.clear();
974 // -----------------------------------------------------------------------------------------------------------------
975 void TaskPaneController_Impl::SetDefaultTitle( const String
& i_rTitle
)
977 m_sDefaultTitle
= i_rTitle
;
978 impl_updateDockingWindowTitle();
981 //------------------------------------------------------------------------------------------------------------------
982 void TaskPaneController_Impl::ActivateToolPanel( const OUString
& i_rPanelURL
)
984 ::boost::optional
< size_t > aPanelPos( m_rTaskPane
.GetPanelPos( i_rPanelURL
) );
985 ENSURE_OR_RETURN_VOID( !!aPanelPos
, "TaskPaneController_Impl::ActivateToolPanel: no such panel!" );
987 if ( aPanelPos
== m_rTaskPane
.GetPanelDeck().GetActivePanel() )
989 ::svt::PToolPanel
pPanel( m_rTaskPane
.GetPanelDeck().GetPanel( *aPanelPos
) );
994 m_rTaskPane
.GetPanelDeck().ActivatePanel( aPanelPos
);
998 // -----------------------------------------------------------------------------------------------------------------
999 IMPL_LINK( TaskPaneController_Impl
, DockingChanged
, TitledDockingWindow
*, i_pDockingWindow
)
1001 ENSURE_OR_RETURN( i_pDockingWindow
&& &m_rDockingWindow
, "TaskPaneController_Impl::DockingChanged: where does this come from?", 0L );
1003 if ( impl_getLayout() == LAYOUT_DRAWERS
)
1006 impl_setLayout( lcl_getTabLayoutFromAlignment( i_pDockingWindow
->GetAlignment() ) );
1010 // -----------------------------------------------------------------------------------------------------------------
1011 IMPL_LINK( TaskPaneController_Impl
, OnToolboxClicked
, ToolBox
*, i_pToolBox
)
1013 if ( i_pToolBox
->GetCurItemId() == m_nViewMenuID
)
1015 i_pToolBox
->EndSelection();
1017 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1018 ::std::auto_ptr
< PopupMenu
> pMenu
= impl_createPopupMenu();
1019 SAL_WNODEPRECATED_DECLARATIONS_POP
1020 pMenu
->SetSelectHdl( LINK( this, TaskPaneController_Impl
, OnMenuItemSelected
) );
1022 // pass toolbox button rect so the menu can stay open on button up
1023 Rectangle
aMenuRect( i_pToolBox
->GetItemRect( m_nViewMenuID
) );
1024 aMenuRect
.SetPos( i_pToolBox
->GetPosPixel() );
1025 pMenu
->Execute( &m_rDockingWindow
, aMenuRect
, POPUPMENU_EXECUTE_DOWN
);
1031 // ---------------------------------------------------------------------------------------------------------------------
1032 IMPL_LINK( TaskPaneController_Impl
, OnMenuItemSelected
, Menu
*, i_pMenu
)
1034 ENSURE_OR_RETURN( i_pMenu
, "TaskPaneController_Impl::OnMenuItemSelected: illegal menu!", 0L );
1036 i_pMenu
->Deactivate();
1037 switch ( i_pMenu
->GetCurItemId() )
1039 case MID_UNLOCK_TASK_PANEL
:
1040 m_rDockingWindow
.SetFloatingMode( sal_True
);
1043 case MID_LOCK_TASK_PANEL
:
1044 m_rDockingWindow
.SetFloatingMode( sal_False
);
1047 case MID_LAYOUT_DRAWERS
:
1048 impl_setLayout( LAYOUT_DRAWERS
);
1051 case MID_LAYOUT_TABS
:
1052 impl_setLayout( lcl_getTabLayoutFromAlignment( m_rDockingWindow
.GetAlignment() ) );
1057 size_t nPanelIndex
= size_t( i_pMenu
->GetCurItemId() - MID_FIRST_PANEL
);
1058 impl_togglePanelVisibility( nPanelIndex
);
1066 // ---------------------------------------------------------------------------------------------------------------------
1067 size_t TaskPaneController_Impl::impl_getLogicalPanelIndex( const size_t i_nVisibleIndex
)
1069 size_t nLogicalIndex
= 0;
1070 size_t nVisibleIndex( i_nVisibleIndex
);
1071 for ( size_t i
=0; i
< m_aPanelRepository
.size(); ++i
)
1073 if ( !m_aPanelRepository
[i
].bHidden
)
1075 if ( !nVisibleIndex
)
1081 return nLogicalIndex
;
1084 // ---------------------------------------------------------------------------------------------------------------------
1085 void TaskPaneController_Impl::PanelInserted( const ::svt::PToolPanel
& i_pPanel
, const size_t i_nPosition
)
1087 if ( m_bTogglingPanelVisibility
)
1090 const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition
) );
1091 m_aPanelRepository
.insert( m_aPanelRepository
.begin() + nLogicalIndex
, PanelDescriptor( i_pPanel
) );
1094 // ---------------------------------------------------------------------------------------------------------------------
1095 void TaskPaneController_Impl::PanelRemoved( const size_t i_nPosition
)
1097 if ( m_bTogglingPanelVisibility
)
1100 const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition
) );
1101 m_aPanelRepository
.erase( m_aPanelRepository
.begin() + nLogicalIndex
);
1104 // ---------------------------------------------------------------------------------------------------------------------
1105 void TaskPaneController_Impl::ActivePanelChanged( const ::boost::optional
< size_t >& i_rOldActive
, const ::boost::optional
< size_t >& i_rNewActive
)
1107 if ( impl_getLayout() == LAYOUT_DRAWERS
)
1108 // no adjustment of the title when we use the classical "drawers" layout
1111 impl_updateDockingWindowTitle( );
1116 // ---------------------------------------------------------------------------------------------------------------------
1117 void TaskPaneController_Impl::LayouterChanged( const ::svt::PDeckLayouter
& i_rNewLayouter
)
1119 // not interested in
1120 (void)i_rNewLayouter
;
1123 // ---------------------------------------------------------------------------------------------------------------------
1124 void TaskPaneController_Impl::Dying()
1126 OSL_FAIL( "TaskPaneController_Impl::Dying: unexpected call!" );
1127 // We are expected to live longer than the ToolPanelDeck we work with. Since we remove ourself, in our dtor,
1128 // as listener from the panel deck, this method here should never be called.
1131 // ---------------------------------------------------------------------------------------------------------------------
1132 void TaskPaneController_Impl::impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex
)
1134 ENSURE_OR_RETURN_VOID( i_nLogicalPanelIndex
< m_aPanelRepository
.size(), "illegal index" );
1136 // get the actual panel index, within the deck
1137 size_t nActualPanelIndex(0);
1138 for ( size_t i
=0; i
< i_nLogicalPanelIndex
; ++i
)
1140 if ( !m_aPanelRepository
[i
].bHidden
)
1141 ++nActualPanelIndex
;
1144 ::boost::optional
< size_t > aActivatePanel
;
1146 m_bTogglingPanelVisibility
= true;
1147 if ( m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
)
1149 OSL_VERIFY( m_rTaskPane
.GetPanelDeck().InsertPanel( m_aPanelRepository
[ i_nLogicalPanelIndex
].pPanel
, nActualPanelIndex
) == nActualPanelIndex
);
1150 // if there has not been an active panel before, activate the newly inserted one
1151 ::boost::optional
< size_t > aActivePanel( m_rTaskPane
.GetPanelDeck().GetActivePanel() );
1152 if ( !aActivePanel
)
1153 aActivatePanel
= nActualPanelIndex
;
1157 OSL_VERIFY( m_rTaskPane
.GetPanelDeck().RemovePanel( nActualPanelIndex
).get() == m_aPanelRepository
[ i_nLogicalPanelIndex
].pPanel
.get() );
1159 m_bTogglingPanelVisibility
= false;
1160 m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
= !m_aPanelRepository
[ i_nLogicalPanelIndex
].bHidden
;
1162 if ( !!aActivatePanel
)
1163 m_rTaskPane
.GetPanelDeck().ActivatePanel( *aActivatePanel
);
1166 // ---------------------------------------------------------------------------------------------------------------------
1167 void TaskPaneController_Impl::impl_setLayout( const PanelSelectorLayout i_eLayout
, const bool i_bForce
)
1169 if ( !i_bForce
&& ( m_eCurrentLayout
== i_eLayout
) )
1172 switch ( i_eLayout
)
1174 case LAYOUT_DRAWERS
:
1175 m_rTaskPane
.SetDrawersLayout();
1177 case LAYOUT_TABS_TOP
:
1178 m_rTaskPane
.SetTabsLayout( ::svt::TABS_TOP
, ::svt::TABITEM_IMAGE_ONLY
);
1180 case LAYOUT_TABS_BOTTOM
:
1181 m_rTaskPane
.SetTabsLayout( ::svt::TABS_BOTTOM
, ::svt::TABITEM_IMAGE_ONLY
);
1183 case LAYOUT_TABS_LEFT
:
1184 m_rTaskPane
.SetTabsLayout( ::svt::TABS_LEFT
, ::svt::TABITEM_IMAGE_ONLY
);
1186 case LAYOUT_TABS_RIGHT
:
1187 m_rTaskPane
.SetTabsLayout( ::svt::TABS_RIGHT
, ::svt::TABITEM_IMAGE_ONLY
);
1190 m_eCurrentLayout
= i_eLayout
;
1192 impl_updateDockingWindowTitle();
1195 // ---------------------------------------------------------------------------------------------------------------------
1196 void TaskPaneController_Impl::impl_updateDockingWindowTitle()
1198 ::boost::optional
< size_t > aActivePanel( m_rTaskPane
.GetPanelDeck().GetActivePanel() );
1199 if ( !aActivePanel
|| ( impl_getLayout() == LAYOUT_DRAWERS
) )
1200 m_rDockingWindow
.SetTitle( m_sDefaultTitle
);
1203 size_t nNewActive( *aActivePanel
);
1204 for ( size_t i
=0; i
< m_aPanelRepository
.size(); ++i
)
1206 if ( m_aPanelRepository
[i
].bHidden
)
1211 m_rDockingWindow
.SetTitle( m_aPanelRepository
[i
].pPanel
->GetDisplayName() );
1219 // ---------------------------------------------------------------------------------------------------------------------
1220 SAL_WNODEPRECATED_DECLARATIONS_PUSH
1221 ::std::auto_ptr
< PopupMenu
> TaskPaneController_Impl::impl_createPopupMenu() const
1223 ::std::auto_ptr
<PopupMenu
> pMenu( new PopupMenu
);
1224 FloatingWindow
* pMenuWindow
= static_cast< FloatingWindow
* >( pMenu
->GetWindow() );
1225 if ( pMenuWindow
!= NULL
)
1227 pMenuWindow
->SetPopupModeFlags ( pMenuWindow
->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE
);
1230 // Add one entry for every tool panel element to individually make
1231 // them visible or hide them.
1232 sal_uInt16 nIndex
= MID_FIRST_PANEL
;
1233 for ( size_t i
=0; i
<m_aPanelRepository
.size(); ++i
, ++nIndex
)
1235 const PanelDescriptor
& rPanelDesc( m_aPanelRepository
[i
] );
1236 pMenu
->InsertItem( nIndex
, rPanelDesc
.pPanel
->GetDisplayName(), MIB_CHECKABLE
);
1237 pMenu
->CheckItem( nIndex
, !rPanelDesc
.bHidden
);
1239 pMenu
->InsertSeparator();
1241 #if OSL_DEBUG_LEVEL > 0
1242 if (SvtMiscOptions().IsExperimentalMode())
1244 pMenu
->InsertItem( MID_LAYOUT_TABS
, OUString("Tab-Layout (exp.)"), MIB_CHECKABLE
);
1245 pMenu
->CheckItem( MID_LAYOUT_TABS
, impl_getLayout() != LAYOUT_DRAWERS
);
1246 pMenu
->InsertItem( MID_LAYOUT_DRAWERS
, OUString("Drawer-Layout"), MIB_CHECKABLE
);
1247 pMenu
->CheckItem( MID_LAYOUT_DRAWERS
, impl_getLayout() == LAYOUT_DRAWERS
);
1249 pMenu
->InsertSeparator();
1253 // Add entry for docking or un-docking the tool panel.
1254 if ( m_rDockingWindow
.IsFloatingMode() )
1256 MID_LOCK_TASK_PANEL
,
1257 SfxResId( STR_SFX_DOCK
).toString()
1261 MID_UNLOCK_TASK_PANEL
,
1262 SfxResId( STR_SFX_UNDOCK
).toString()
1265 pMenu
->RemoveDisabledEntries( sal_False
, sal_False
);
1269 SAL_WNODEPRECATED_DECLARATIONS_POP
1271 //==================================================================================================================
1272 //= TaskPaneController
1273 //==================================================================================================================
1274 //------------------------------------------------------------------------------------------------------------------
1275 TaskPaneController::TaskPaneController( ModuleTaskPane
& i_rTaskPane
, TitledDockingWindow
& i_rDockingWindow
)
1276 :m_pImpl( new TaskPaneController_Impl( i_rTaskPane
, i_rDockingWindow
) )
1280 //------------------------------------------------------------------------------------------------------------------
1281 TaskPaneController::~TaskPaneController()
1285 //------------------------------------------------------------------------------------------------------------------
1286 void TaskPaneController::ActivateToolPanel( const OUString
& i_rPanelURL
)
1288 m_pImpl
->ActivateToolPanel( i_rPanelURL
);
1291 //......................................................................................................................
1293 //......................................................................................................................
1295 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */