diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-06-04 11:07:35 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-06-04 11:07:35 +0200 |
commit | 47b5ec4b0b48b7108715cb1e780ad3dca284cfa9 (patch) | |
tree | 5872a5bca35cf222dcc2a1c0d492a28c79d86c7f /sd/source/ui/toolpanel | |
parent | bdd37f7758920e43b556887b3cc2c70ea48e107d (diff) | |
parent | f884576207758a6fae1cd190c064f4e115938cc0 (diff) |
CWS-TOOLING: integrate CWS slidecopy
Notes
Notes:
split repo tag: impress_ooo/DEV300_m81
Diffstat (limited to 'sd/source/ui/toolpanel')
39 files changed, 1882 insertions, 1781 deletions
diff --git a/sd/source/ui/toolpanel/LayoutMenu.cxx b/sd/source/ui/toolpanel/LayoutMenu.cxx index 2fc995aa45f9..7e0fd41ffb89 100755 --- a/sd/source/ui/toolpanel/LayoutMenu.cxx +++ b/sd/source/ui/toolpanel/LayoutMenu.cxx @@ -47,6 +47,7 @@ #include "controller/SlideSorterController.hxx" #include "controller/SlsPageSelector.hxx" #include "taskpane/TaskPaneControlFactory.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "taskpane/ScrollPanel.hxx" #include "tools/SlotStateListener.hxx" #include "EventMultiplexer.hxx" @@ -84,40 +85,32 @@ using ::sd::framework::FrameworkHelper; namespace sd { namespace toolpanel { -/** This factory class stores references to ViewShellBase and DrawDocShell - and passes them to new LayoutMenu objects. -*/ -class LayoutMenuFactory +class LayoutMenuRootFactory : public ControlFactory { public: - LayoutMenuFactory (ViewShellBase& rBase, DrawDocShell& rDocShell) - : mrBase(rBase), - mrDocShell(rDocShell) - {} + LayoutMenuRootFactory (ToolPanelViewShell& i_rPanelViewShell) + :mrPanelViewShell(i_rPanelViewShell) + { + } protected: - virtual TreeNode* InternalCreateControl (TreeNode* pTreeNode) + virtual TreeNode* InternalCreateControl( ::Window& i_rParent ) { - ScrollPanel* pScrollPanel = new ScrollPanel (pTreeNode); + ScrollPanel* pScrollPanel = new ScrollPanel (i_rParent); ::std::auto_ptr<TreeNode> pMenu ( new LayoutMenu ( pScrollPanel, - mrDocShell, - mrBase, - false)); + mrPanelViewShell)); pScrollPanel->AddControl(pMenu); return pScrollPanel; } private: - ViewShellBase& mrBase; - DrawDocShell& mrDocShell; + ToolPanelViewShell& mrPanelViewShell; }; - - SFX_IMPL_INTERFACE(LayoutMenu, SfxShell, SdResId(STR_TASKPANELAYOUTMENU)) { @@ -182,22 +175,29 @@ static snewfoil_value_info standard[] = {0, 0, 0, WritingMode_LR_TB, AUTOLAYOUT_NONE} }; -LayoutMenu::LayoutMenu ( - TreeNode* pParent, - DrawDocShell& rDocumentShell, - ViewShellBase& rViewShellBase, - bool bUseOwnScrollBar) +LayoutMenu::LayoutMenu( TreeNode* pParent, ToolPanelViewShell& i_rPanelViewShell ) : ValueSet (pParent->GetWindow()), TreeNode(pParent), DragSourceHelper(this), DropTargetHelper(this), - mrBase (rViewShellBase), - mbUseOwnScrollBar (bUseOwnScrollBar), + mrBase( i_rPanelViewShell.GetViewShellBase() ), + mpShellManager (&i_rPanelViewShell.GetSubShellManager()), + mbUseOwnScrollBar( false ), mnPreferredColumnCount(3), mxListener(NULL), mbSelectionUpdatePending(true), mbIsMainViewChangePending(false) { + implConstruct( *mrBase.GetDocument()->GetDocSh() ); +} + + +void LayoutMenu::implConstruct( DrawDocShell& rDocumentShell ) +{ + OSL_ENSURE( mrBase.GetDocument()->GetDocSh() == &rDocumentShell, + "LayoutMenu::implConstruct: hmm?" ); + // if this fires, then my assumption that the rDocumentShell parameter to our first ctor is superfluous ... + SetStyle ( ( GetStyle() & ~(WB_ITEMBORDER) ) | WB_TABSTOP @@ -236,7 +236,6 @@ LayoutMenu::LayoutMenu ( - LayoutMenu::~LayoutMenu (void) { // Tell the shell factory that this object is no longer available. @@ -256,10 +255,9 @@ LayoutMenu::~LayoutMenu (void) ::std::auto_ptr<ControlFactory> LayoutMenu::CreateControlFactory ( - ViewShellBase& rBase, - DrawDocShell& rDocShell) + ToolPanelViewShell& i_rPanelViewShell ) { - return ::std::auto_ptr<ControlFactory>(new LayoutMenuFactory(rBase, rDocShell)); + return ::std::auto_ptr<ControlFactory>(new LayoutMenuRootFactory(i_rPanelViewShell)); } @@ -591,6 +589,13 @@ void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout) +TaskPaneShellManager* LayoutMenu::GetShellManager() +{ + if ( mpShellManager ) + return mpShellManager; + return TreeNode::GetShellManager(); +} + void LayoutMenu::InvalidateContent (void) { // The number of items may have changed. Request a resize so that the diff --git a/sd/source/ui/toolpanel/LayoutMenu.hxx b/sd/source/ui/toolpanel/LayoutMenu.hxx index bd121403c2d3..86e01e9f803b 100644..100755 --- a/sd/source/ui/toolpanel/LayoutMenu.hxx +++ b/sd/source/ui/toolpanel/LayoutMenu.hxx @@ -60,6 +60,7 @@ class EventMultiplexerEvent; namespace sd { namespace toolpanel { class ControlFactory; +class ToolPanelViewShell; class LayoutMenu @@ -76,28 +77,18 @@ public: /** Create a new layout menu. Depending on the given flag it displays its own scroll bar or lets a surrounding window handle that. - @param rDocumentShell - Used to determine writing direction. - @param rViewShellBase - Gives access to the view shell at whose active page the - layout will be set. - @param bUseOwnScrollBar - When <TRUE/> then we will show our own scroll bar when not - all icons can be displayed in the visible window area. - When <FALSE/> then rely on an outer scroll bar. In this - case we will set the height of the window so that all - icons are visible. + @param i_pParent + the parent node in the control tree + @param i_rPanelViewShell + the view shell of the task pane. */ LayoutMenu ( - TreeNode* pParent, - DrawDocShell& rDocumentShell, - ViewShellBase& rViewShellBase, - bool bUseOwnScrollBar); + TreeNode* i_pParent, + ToolPanelViewShell& i_rPanelViewShell); virtual ~LayoutMenu (void); static std::auto_ptr<ControlFactory> CreateControlFactory ( - ViewShellBase& rBase, - DrawDocShell& rDocShell); + ToolPanelViewShell& i_rPanelViewShell ); /** Return the name of the currently selected layout. */ @@ -140,6 +131,9 @@ public: enum MasterMode { MM_NORMAL, MM_MASTER, MM_UNKNOWN }; void UpdateEnabledState (const MasterMode eMode); + // TreeNode overridables + virtual TaskPaneShellManager* GetShellManager (void); + /** Call this method when the set of displayed layouts is not up-to-date anymore. It will re-assemple this set according to the current settings. @@ -168,6 +162,8 @@ public: private: ViewShellBase& mrBase; + TaskPaneShellManager* mpShellManager; + /** Do we use our own scroll bar or is viewport handling done by our parent? */ @@ -231,6 +227,9 @@ private: */ void UpdateSelection (void); + // internal ctor + void implConstruct( DrawDocShell& rDocumentShell ); + /** When clicked then set the current page of the view in the center pane. */ DECL_LINK(ClickHandler, ValueSet*); diff --git a/sd/source/ui/toolpanel/LayoutableWindow.hxx b/sd/source/ui/toolpanel/LayoutableWindow.hxx deleted file mode 100644 index ed4e1ec77959..000000000000 --- a/sd/source/ui/toolpanel/LayoutableWindow.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SD_TOOLPANEL_I_LAYOUTABLE_WINDOW_HXX -#define SD_TOOLPANEL_I_LAYOUTABLE_WINDOW_HXX - -#include <vcl/gen.hxx> - -class Window; - -namespace sd { namespace toolpanel { - - -/** This interface has to be implemented by windows that want to be - layouted by a ToolPanel, SubToolPanel, or ScrollablePanel object. -*/ -class LayoutableWindow -{ -public: - /** Return the preferred size without constraints on either the - height or the width. - The size the window will later be set to may but does not have - to be equal to this size. - */ - virtual Size GetPreferredSize (void) = 0; - - /** Return the preferred width with the constraint, that the - window will be set to the given height. - The width the window will later be set to may but does not have - to be equal to this width. - */ - virtual int GetPreferredWidth (int nHeight) = 0; - - /** Return the preferred height with the constraint, that the - window will be set to the given width. - The height the window will later be set to may but does not have - to be equal to this height. - */ - virtual int GetPreferredHeight (int nWidth) = 0; - - /** Return wether the window is generally resizable. When used by - a VerticalLayouter then the width will always be resized and - the return value of this method determines whether the height - may be modified as well. - */ - virtual bool IsResizable (void) = 0; - - /** Return the window so that its size and position can be set. - */ - virtual ::Window& GetWindow (void) = 0; -}; - -} } // end of namespace ::sd::toolpanel - -#endif diff --git a/sd/source/ui/toolpanel/MethodGuard.hxx b/sd/source/ui/toolpanel/MethodGuard.hxx new file mode 100644 index 000000000000..45b81367c8de --- /dev/null +++ b/sd/source/ui/toolpanel/MethodGuard.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_METHODGUARD_HXX +#define SD_METHODGUARD_HXX + +#include <osl/mutex.hxx> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + //================================================================================================================== + //= MethodGuard + //================================================================================================================== + template < class COMPONENT > + class MethodGuard + { + public: + MethodGuard( COMPONENT& i_rComponent ) + :m_aGuard( i_rComponent.getMutex() ) + { + i_rComponent.checkDisposed(); + } + + ~MethodGuard() + { + } + + inline void clear() + { + m_aGuard.clear(); + } + + private: + ::osl::ClearableMutexGuard m_aGuard; + }; + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... + +#endif // SD_METHODGUARD_HXX diff --git a/sd/source/ui/toolpanel/ScrollPanel.cxx b/sd/source/ui/toolpanel/ScrollPanel.cxx index cff065777235..cae08c76ca39 100644..100755 --- a/sd/source/ui/toolpanel/ScrollPanel.cxx +++ b/sd/source/ui/toolpanel/ScrollPanel.cxx @@ -56,6 +56,30 @@ ScrollPanel::ScrollPanel ( mnVerticalGap(3), mnHorizontalBorder(2) { + Construct(); +} + +ScrollPanel::ScrollPanel ( + ::Window& i_rParentWindow) + : Control (&i_rParentWindow, WB_DIALOGCONTROL), + TreeNode(NULL), + maScrollWindow(this, WB_DIALOGCONTROL), + maVerticalScrollBar(this, WB_VERT), + maHorizontalScrollBar(this, WB_HORZ), + maScrollBarFiller(this), + maScrollWindowFiller(&maScrollWindow), + mbIsRearrangePending(true), + mbIsLayoutPending(true), + mnChildrenWidth(0), + mnVerticalBorder(2), + mnVerticalGap(3), + mnHorizontalBorder(2) +{ + Construct(); +} + +void ScrollPanel::Construct() +{ SetAccessibleName ( ::rtl::OUString::createFromAscii("Sub Task Panel")); mpControlContainer->SetMultiSelection (true); @@ -95,7 +119,7 @@ ScrollPanel::~ScrollPanel (void) // control instead of pNode directly. TitledControl* pTitledControl = static_cast<TitledControl*>(pNode); if (pTitledControl != NULL) - pControl = pTitledControl->GetControl(false); + pControl = pTitledControl->GetControl(); // Remove this object as listener from the control. if (pControl != NULL && pControl->GetWindow()!=NULL) diff --git a/sd/source/ui/toolpanel/SlideSorterCacheDisplay.cxx b/sd/source/ui/toolpanel/SlideSorterCacheDisplay.cxx index 3cef1ca6ee88..a032b6ef02f0 100644..100755 --- a/sd/source/ui/toolpanel/SlideSorterCacheDisplay.cxx +++ b/sd/source/ui/toolpanel/SlideSorterCacheDisplay.cxx @@ -71,38 +71,6 @@ namespace sd { namespace toolpanel { ::std::map<const SdDrawDocument*, SlideSorterCacheDisplay*> SlideSorterCacheDisplay::maDisplays; -/** This factory class is used to create instances of TestPanel. It can be - extended so that its constructor stores arguments that later are passed - to new TestPanel objects. -*/ -class SlideSorterCacheDisplayFactory - : public ControlFactory -{ -public: - SlideSorterCacheDisplayFactory (const SdDrawDocument* pDocument) - : mpDocument(pDocument) - { - } - -protected: - virtual TreeNode* InternalCreateControl (TreeNode* pTreeNode) - { - SlideSorterCacheDisplay* pDisplay = SlideSorterCacheDisplay::Instance(mpDocument); - pDisplay->SetParentWindow(pTreeNode->GetWindow()); - pDisplay->SetParentNode(pTreeNode); - return pDisplay; - } - -private: - const SdDrawDocument* mpDocument; -}; - - - - - - - SlideSorterCacheDisplay::SlideSorterCacheDisplay (const SdDrawDocument* pDocument) : TreeNode(NULL), mpWindow(NULL), @@ -137,15 +105,6 @@ void SlideSorterCacheDisplay::SetParentWindow (::Window* pParentWindow) -std::auto_ptr<ControlFactory> SlideSorterCacheDisplay::CreateControlFactory ( - const SdDrawDocument* pDocument) -{ - return std::auto_ptr<ControlFactory>(new SlideSorterCacheDisplayFactory(pDocument)); -} - - - - void SlideSorterCacheDisplay::Paint (const Rectangle& rBoundingBox) { if (maCellSize.Width()>0 && maCellSize.Height()>0 && mpWindow!=NULL) diff --git a/sd/source/ui/toolpanel/SubToolPanel.cxx b/sd/source/ui/toolpanel/SubToolPanel.cxx index 31c29f4f1c08..f554d44e8f18 100644..100755 --- a/sd/source/ui/toolpanel/SubToolPanel.cxx +++ b/sd/source/ui/toolpanel/SubToolPanel.cxx @@ -70,6 +70,35 @@ SubToolPanel::SubToolPanel ( +SubToolPanel::SubToolPanel ( + Window& i_rParentWindow) + : Control (&i_rParentWindow, WB_DIALOGCONTROL), + TreeNode(NULL), + maWindowFiller(this), + mbIsRearrangePending(true), + mbIsLayoutPending(true), + mnChildrenWidth(0), + mnVerticalBorder(0), + mnVerticalGap(3), + mnHorizontalBorder(2) +{ + SetAccessibleName ( + ::rtl::OUString::createFromAscii("Sub Task Panel")); + mpControlContainer->SetMultiSelection (true); + + SetBorderStyle (WINDOW_BORDER_NORMAL); + SetMapMode (MapMode(MAP_PIXEL)); + + // To reduce flickering during repaints make the container windows + // transparent and rely on their children to paint the whole area. + SetBackground(Wallpaper()); + maWindowFiller.SetBackground( + Application::GetSettings().GetStyleSettings().GetWindowColor()); +} + + + + SubToolPanel::~SubToolPanel (void) { sal_uInt32 nCount = mpControlContainer->GetControlCount(); diff --git a/sd/source/ui/toolpanel/TaskPaneControlFactory.cxx b/sd/source/ui/toolpanel/TaskPaneControlFactory.cxx index c1651d62010b..4ad610df7f7f 100644..100755 --- a/sd/source/ui/toolpanel/TaskPaneControlFactory.cxx +++ b/sd/source/ui/toolpanel/TaskPaneControlFactory.cxx @@ -48,13 +48,10 @@ ControlFactory::~ControlFactory (void) -::std::auto_ptr<TreeNode> ControlFactory::CreateControl (TreeNode* pTreeNode) +::std::auto_ptr<TreeNode> ControlFactory::CreateControl( ::Window& i_rParent ) { - // Create a new control by using the protected virtual hook. - TreeNode* pNewNode = InternalCreateControl(pTreeNode); - - return ::std::auto_ptr<TreeNode>(pNewNode); + TreeNode* pNewNode = InternalCreateControl( i_rParent ); + return ::std::auto_ptr<TreeNode>( pNewNode ); } - } } // end of namespace ::sd::toolpanel diff --git a/sd/source/ui/toolpanel/TaskPaneShellManager.cxx b/sd/source/ui/toolpanel/TaskPaneShellManager.cxx index 5a4875340840..52054c43fe8b 100644..100755 --- a/sd/source/ui/toolpanel/TaskPaneShellManager.cxx +++ b/sd/source/ui/toolpanel/TaskPaneShellManager.cxx @@ -31,7 +31,7 @@ #include "TaskPaneShellManager.hxx" #include "ViewShellManager.hxx" -#include <osl/diagnose.h> +#include <tools/diagnose_ex.h> #include <vcl/window.hxx> #include <algorithm> @@ -111,6 +111,21 @@ void TaskPaneShellManager::AddSubShell ( +void TaskPaneShellManager::RemoveSubShell (const ShellId i_nShellId) +{ + SubShells::iterator pos = maSubShells.find( i_nShellId ); + ENSURE_OR_RETURN_VOID( pos != maSubShells.end(), "no shell for this ID" ); + if ( pos->second.mpWindow != NULL ) + { + pos->second.mpWindow->RemoveEventListener( LINK( this, TaskPaneShellManager, WindowCallback ) ); + } + mpViewShellManager->DeactivateSubShell( mrViewShell, pos->first ); + maSubShells.erase( pos ); +} + + + + void TaskPaneShellManager::RemoveSubShell (const SfxShell* pShell) { if (pShell != NULL) diff --git a/sd/source/ui/toolpanel/TaskPaneShellManager.hxx b/sd/source/ui/toolpanel/TaskPaneShellManager.hxx index 2c2e49b98c48..92e7b6b83b8d 100644..100755 --- a/sd/source/ui/toolpanel/TaskPaneShellManager.hxx +++ b/sd/source/ui/toolpanel/TaskPaneShellManager.hxx @@ -46,7 +46,7 @@ namespace sd { namespace toolpanel { /** The TaskPaneShellManager implements the ViewShellManager::ShellFactory interface. However, it does not create or delete shells. It only gives the ViewShellManager access to the sub shells of the - TaskPaneViewShell. Life time control of the sub shells is managed by + ToolPanelViewShell. Life time control of the sub shells is managed by the sub shells themselves. */ class TaskPaneShellManager @@ -86,6 +86,11 @@ public: NULL when this shell is requested. */ void RemoveSubShell (const SfxShell* pShell); + /** removes the shell given by its ID from the set of sub shells managed by the + TaskPaneShellManager. Subsequent calls to CreateShell() will return + NULL when this shell is requested. + */ + void RemoveSubShell (const ShellId i_nShellId); /** Move the given sub-shell to the top of the local shell stack. Furthermore move the view shell whose sub-shells this class manages diff --git a/sd/source/ui/toolpanel/TaskPaneTreeNode.cxx b/sd/source/ui/toolpanel/TaskPaneTreeNode.cxx index 152f576bd5bc..f70e643636d5 100644..100755 --- a/sd/source/ui/toolpanel/TaskPaneTreeNode.cxx +++ b/sd/source/ui/toolpanel/TaskPaneTreeNode.cxx @@ -122,17 +122,6 @@ sal_Int32 TreeNode::GetMinimumWidth (void) -ObjectBarManager* TreeNode::GetObjectBarManager (void) -{ - if (mpParent != NULL) - return mpParent->GetObjectBarManager(); - else - return NULL; -} - - - - bool TreeNode::IsResizable (void) { return false; diff --git a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx b/sd/source/ui/toolpanel/TaskPaneViewShell.cxx deleted file mode 100644 index d80beba7cd10..000000000000 --- a/sd/source/ui/toolpanel/TaskPaneViewShell.cxx +++ /dev/null @@ -1,889 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "TaskPaneViewShell.hxx" - -#include "TaskPaneShellManager.hxx" -#include "ToolPanelChildWindow.hrc" -#include "ToolPanelChildWindow.hxx" -#include "taskpane/SlideSorterCacheDisplay.hxx" -#include "taskpane/ToolPanel.hxx" -#include "taskpane/TitledControl.hxx" -#include "LayoutMenu.hxx" -#include "TaskPaneFocusManager.hxx" -#include "taskpane/SubToolPanel.hxx" -#include "taskpane/ScrollPanel.hxx" -#include "taskpane/TaskPaneControlFactory.hxx" -#include "controls/MasterPagesPanel.hxx" -#include "controls/MasterPagesSelector.hxx" -#include "controls/TableDesignPanel.hxx" -#include "controls/CustomAnimationPanel.hxx" -#include "controls/SlideTransitionPanel.hxx" -#include "controls/AnimationSchemesPanel.hxx" -#include "TitleToolBox.hxx" -#include "taskpane/ControlContainer.hxx" -#include "FrameView.hxx" -#include "Window.hxx" -#include "PaneDockingWindow.hxx" -#include "AccessibleTaskPane.hxx" -#include "DrawSubController.hxx" -#include "sdmod.hxx" -#include "app.hrc" -#include "glob.hrc" -#include "res_bmp.hrc" -#include "helpids.h" -#include "strings.hrc" -#include "sdresid.hxx" -#include "framework/FrameworkHelper.hxx" -#include <com/sun/star/drawing/framework/XResourceId.hpp> -#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> -#include <com/sun/star/drawing/XDrawSubController.hpp> - -#include <svx/dlgctrl.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/msg.hxx> -#include <sfx2/objface.hxx> -#include <svx/colrctrl.hxx> -#include <svx/xtable.hxx> -#include <vcl/dockwin.hxx> -#include "sdtreelb.hxx" -#include "DrawViewShell.hxx" -#include "drawdoc.hxx" -#include "ViewShellBase.hxx" -#include <svx/ruler.hxx> -#include <vcl/svapp.hxx> - -//#define SHOW_TEST_PANEL -#ifdef SHOW_TEST_PANEL -#include "TestPanel.hxx" -#endif -//#define SHOW_COLOR_MENU -#ifdef SHOW_COLOR_MENU -#include "TestMenu.hxx" -#endif - -#include <vector> -#include <boost/shared_ptr.hpp> - -using namespace ::sd::toolpanel; - -#define TaskPaneViewShell -#include "sdslots.hxx" - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using ::sd::framework::FrameworkHelper; - -namespace sd { namespace toolpanel { - -SFX_IMPL_INTERFACE(TaskPaneViewShell, SfxShell, SdResId(STR_TASKPANEVIEWSHELL)) -{ -} - - -TYPEINIT1(TaskPaneViewShell, ViewShell); - - -/** Inner implementation class of TaskPaneViewShell. -*/ -class TaskPaneViewShell::Implementation -{ -public: - static const sal_uInt32 mnInvalidId = 0xffffffff; - - Implementation (void); - ~Implementation (void); - - /** Here the panels are created that are shown in the task pane. - */ - void Setup (ToolPanel* pToolPanel, ViewShellBase& rBase); - - /** Make a new panel known to the translation table that translates - between internal indices as returned by - ControlContainer::AddControl() and public indices defined by - TaskPaneViewShell::PanelId. - */ - void AddPanel (sal_uInt32 nInternalId, PanelId nPublicId); - - /** Return the public id for the given internal one. - @return - When the given public id is not known then PID_UNKNOWN is - returned. - */ - PanelId GetPublicId (sal_uInt32 nInternalId) const; - - /** Return the internal id for the given public one. - @return - When the given public id is not known then mnInvalidId is - returned. - */ - sal_uInt32 GetInternalId (PanelId nPublicId) const; - -private: - /** This map translates between internal indices returned by - ControlContainer::AddControl() and public indices defined by - TaskPaneViewShell::PanelId. - */ - typedef ::std::vector<PanelId> InternalIdToPanelIdMap; - InternalIdToPanelIdMap maIndexMap; -}; - - - - -namespace { - -enum MenuId { - MID_UNLOCK_TASK_PANEL = 1, - MID_LOCK_TASK_PANEL = 2, - MID_CUSTOMIZE = 3, - MID_FIRST_CONTROL = 4 -}; - -/** This control is used for extracting the title string from the resource - of some dialogs that are displayed in the task pane. With this the - actual controls can be created on demand. This class only loads (a part - of) their resource. -*/ -class DummyControl : public Control -{ -public: - DummyControl (::Window* pParent, const ResId& rResId) - : Control(pParent,rResId) - { - FreeResource(); - } -}; - -class ResourceActivationClickHandler -{ -public: - ResourceActivationClickHandler ( - const ::boost::shared_ptr<FrameworkHelper>& rpFrameworkHelper, - const Reference<drawing::framework::XResourceId>& rxResourceId, - ControlContainer& rControlContainer); - void operator () (TitledControl& rTitledControl); - -private: - ::boost::shared_ptr<FrameworkHelper> mpFrameworkHelper; - Reference<drawing::framework::XResourceId> mxResourceId; - ControlContainer& mrControlContainer; -}; - -} // end of anonymouse namespace - - - - - -void TaskPaneViewShell::Implementation::Setup ( - ToolPanel* pToolPanel, - ViewShellBase& rBase) -{ - SdDrawDocument* pDocument = rBase.GetDocument(); - sal_uInt32 nId; - sal_uInt32 nIdOfControlToExpand; - - ::boost::shared_ptr<FrameworkHelper> pFrameworkHelper (FrameworkHelper::Instance(rBase)); - Reference<drawing::framework::XResourceId> xTaskPaneId (pFrameworkHelper->CreateResourceId( - FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL)); - - // The master page controls. - nId = pToolPanel->AddControl ( - controls::MasterPagesPanel::CreateControlFactory(rBase), - SdResId(STR_TASKPANEL_MASTER_PAGE_TITLE), - HID_SD_SLIDE_DESIGNS, - ResourceActivationClickHandler( - pFrameworkHelper, - pFrameworkHelper->CreateResourceId( - FrameworkHelper::msMasterPagesTaskPanelURL, xTaskPaneId), - pToolPanel->GetControlContainer())); - AddPanel (nId, PID_MASTER_PAGES); - - // Layout Menu. - nId = pToolPanel->AddControl ( - LayoutMenu::CreateControlFactory(rBase, *pDocument->GetDocSh()), - SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE), - HID_SD_SLIDE_LAYOUTS, - ResourceActivationClickHandler( - pFrameworkHelper, - pFrameworkHelper->CreateResourceId( - FrameworkHelper::msLayoutTaskPanelURL, xTaskPaneId), - pToolPanel->GetControlContainer())); - AddPanel (nId, PID_LAYOUT); - nIdOfControlToExpand = nId; - - { - DummyControl aControl (pToolPanel, SdResId(DLG_TABLEDESIGNPANE)); - - // TableDesignPanel - nId = pToolPanel->AddControl ( - controls::TableDesignPanel::CreateControlFactory(rBase), - aControl.GetText(), - HID_SD_TABLE_DESIGN, - ResourceActivationClickHandler( - pFrameworkHelper, - pFrameworkHelper->CreateResourceId( - FrameworkHelper::msTableDesignPanelURL, xTaskPaneId), - pToolPanel->GetControlContainer())); - AddPanel (nId, PID_TABLE_DESIGN); - } - - { - DummyControl aControl (pToolPanel, SdResId(RID_CUSTOMANIMATION_START+0)); - - // CustomAnimationPanel - nId = pToolPanel->AddControl ( - controls::CustomAnimationPanel::CreateControlFactory(rBase), - aControl.GetText(), - HID_SD_CUSTOM_ANIMATIONS, - ResourceActivationClickHandler( - pFrameworkHelper, - pFrameworkHelper->CreateResourceId( - FrameworkHelper::msCustomAnimationTaskPanelURL, xTaskPaneId), - pToolPanel->GetControlContainer())); - AddPanel (nId, PID_CUSTOM_ANIMATION); - } - - // SlideTransitionPanel - { - DummyControl aControl (pToolPanel, SdResId(RID_CUSTOMANIMATION_START+3)); - - nId = pToolPanel->AddControl ( - controls::SlideTransitionPanel::CreateControlFactory(rBase), - aControl.GetText(), - HID_SD_SLIDE_TRANSITIONS, - ResourceActivationClickHandler( - pFrameworkHelper, - pFrameworkHelper->CreateResourceId( - FrameworkHelper::msSlideTransitionTaskPanelURL, xTaskPaneId), - pToolPanel->GetControlContainer())); - AddPanel (nId, PID_SLIDE_TRANSITION); - } - -#ifdef SHOW_COLOR_MENU - // Test Menu. - pToolPanel->AddControl ( - ColorMenu::CreateControlFactory(), - String::CreateFromAscii ("Color Test Menu"), - 0); -#endif - -#ifdef SHOW_TEST_PANEL - // Test Panel. - pToolPanel->AddControl ( - TestPanel::CreateControlFactory(), - String::CreateFromAscii ("Test Panel"), - 0); -#endif - -#ifdef USE_SLIDE_SORTER_CACHE_DISPLAY - pToolPanel->AddControl ( - SlideSorterCacheDisplay::CreateControlFactory(pDocument), - String::CreateFromAscii("Slide Sorter Cache Status"), - 0); -#endif - - // Expand the layout menu. - pToolPanel->GetControlContainer().SetExpansionState ( - nIdOfControlToExpand, - ControlContainer::ES_EXPAND); - - pToolPanel->GetWindow()->Show(); -} - - - - -void TaskPaneViewShell::Initialize (void) -{ - if ( ! mbIsInitialized) - { - mbIsInitialized = true; - mpImpl->Setup (mpTaskPane.get(), GetViewShellBase()); - } -} - - - - -TaskPaneViewShell::TaskPaneViewShell ( - SfxViewFrame* pFrame, - ViewShellBase& rViewShellBase, - ::Window* pParentWindow, - FrameView* pFrameViewArgument) - : ViewShell (pFrame, pParentWindow, rViewShellBase), - mpImpl(NULL), - mpTaskPane(NULL), - mbIsInitialized(false), - mpSubShellManager(), - mnMenuId(0) -{ - meShellType = ST_TASK_PANE; - - mpImpl.reset (new Implementation()); - - mpContentWindow->SetCenterAllowed (false); - pParentWindow->SetStyle(pParentWindow->GetStyle() | WB_DIALOGCONTROL); - - mpTaskPane = ::std::auto_ptr<ToolPanel>(new ToolPanel ( - mpContentWindow.get(), *this)); - - GetParentWindow()->SetBackground(Wallpaper()); - mpContentWindow->SetBackground(Wallpaper()); - - GetParentWindow()->SetHelpId(HID_SD_TASK_PANE); - - PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(GetDockingWindow()); - if (pDockingWindow != NULL) - { - pDockingWindow->InitializeTitleToolBox(); - mnMenuId = pDockingWindow->AddMenu ( - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_TITLE)), - HID_SD_TASK_PANE_VIEW_MENU, - LINK(this, TaskPaneViewShell, ToolboxClickHandler)); - } - - // Tell the focus manager that we want to pass the focus to our - // child. - FocusManager::Instance().RegisterDownLink(pParentWindow, mpTaskPane.get()); - - SetPool (&GetDoc()->GetPool()); - - if (pFrameViewArgument != NULL) - mpFrameView = pFrameViewArgument; - else - mpFrameView = new FrameView(GetDoc()); - GetFrameView()->Connect(); - - // Hide or delete unused controls that we have inherited from the - // ViewShell base class. - mpHorizontalScrollBar.reset(); - mpVerticalScrollBar.reset(); - mpScrollBarBox.reset(); - mpHorizontalRuler.reset(); - mpVerticalRuler.reset(); - - SetName (String (RTL_CONSTASCII_USTRINGPARAM("TaskPaneViewShell"))); - - // For accessibility we have to shortly hide the content window. This - // triggers the construction of a new accessibility object for the new - // view shell. (One is created earlier while the construtor of the base - // class is executed. At that time the correct accessibility object can - // not be constructed.) - if (mpContentWindow.get() !=NULL) - { - mpContentWindow->Hide(); - mpContentWindow->Show(); - } - - // Register the shell manager as factory at the ViewShellManager. - mpSubShellManager.reset (new TaskPaneShellManager( - GetViewShellBase().GetViewShellManager(), - *this)); - GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this, mpSubShellManager); -} - - - - -TaskPaneViewShell::~TaskPaneViewShell (void) -{ - GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(this, mpSubShellManager); -} - - - -// static -void TaskPaneViewShell::RegisterControls (void) -{ - SfxModule* pModule = SD_MOD(); - controls::MasterPagesSelector::RegisterInterface (pModule); - LayoutMenu::RegisterInterface (pModule); -} - - - - -void TaskPaneViewShell::ArrangeGUIElements (void) -{ - ViewShell::ArrangeGUIElements(); - - Point aOrigin (maViewPos); - Size aSize (maViewSize); - - Initialize(); - - // Place the task pane. - if (mpTaskPane.get() != NULL) - mpTaskPane->SetPosSizePixel (Point(0,0), aSize); -} - - - - -void TaskPaneViewShell::GetFocus (void) -{ - Invalidate (); -} - - - - -void TaskPaneViewShell::LoseFocus (void) -{ - Invalidate (); -} - - - - -void TaskPaneViewShell::KeyInput (const KeyEvent& rEvent) -{ - KeyCode nCode = rEvent.GetKeyCode(); - if (nCode == KEY_RETURN) - { - mpTaskPane->GrabFocus(); - } - else - ViewShell::KeyInput (rEvent, NULL); -} - - - - -IMPL_LINK(TaskPaneViewShell, ToolboxClickHandler, ToolBox*, pToolBox) -{ - if (pToolBox->GetCurItemId() == mnMenuId) - { - pToolBox->EndSelection(); - - DockingWindow* pDockingWindow = GetDockingWindow(); - ::std::auto_ptr<PopupMenu> pMenu = CreatePopupMenu ( - pDockingWindow!=NULL && !pDockingWindow->IsFloatingMode()); - pMenu->SetSelectHdl ( - LINK(this, TaskPaneViewShell, MenuSelectHandler)); - - // pass toolbox button rect so the menu can stay open on button up - Rectangle aRect = pToolBox->GetItemRect(mnMenuId); - aRect.SetPos(pToolBox->GetPosPixel() ); - pMenu->Execute (pDockingWindow, aRect, POPUPMENU_EXECUTE_DOWN); - } - - return 0; -} - - - - -IMPL_LINK(TaskPaneViewShell, MenuSelectHandler, Menu*, pMenu) -{ - if (pMenu) - { - pMenu->Deactivate(); - switch (pMenu->GetCurItemId()) - { - case MID_UNLOCK_TASK_PANEL: - { - DockingWindow* pDockingWindow = GetDockingWindow(); - if (pDockingWindow != NULL) - pDockingWindow->SetFloatingMode (TRUE); - } - break; - - case MID_LOCK_TASK_PANEL: - { - DockingWindow* pDockingWindow = GetDockingWindow(); - if (pDockingWindow != NULL) - pDockingWindow->SetFloatingMode (FALSE); - } - break; - - case MID_CUSTOMIZE: - DBG_ASSERT (0, "Customization not yet implemented"); - break; - - default: - { - sal_uInt32 nIndex (pMenu->GetUserValue(pMenu->GetCurItemId())); - mpTaskPane->GetControlContainer().SetVisibilityState ( - nIndex, - ControlContainer::VS_TOGGLE); - // mpTaskPane->Resize(); - // mpTaskPane->Invalidate(); - } - break; - } - } - - return 0; -} - - - - -::std::auto_ptr<PopupMenu> TaskPaneViewShell::CreatePopupMenu ( - bool bIsDocking) -{ - ::std::auto_ptr<PopupMenu> pMenu (new PopupMenu ()); - FloatingWindow* pFloat = static_cast<FloatingWindow*>(pMenu->GetWindow()); - if (pFloat != NULL) - { - pFloat->SetPopupModeFlags ( - pFloat->GetPopupModeFlags() - | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE); - } - - // warning free code changes: - // FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE is 0x10000, so cast to USHORT is 0 - // so why was this used anyway? - pMenu->SetMenuFlags ( - pMenu->GetMenuFlags() /* | (USHORT)FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE */ ); - - // Add one entry for every tool panel element to individually make - // them visible or hide them. - USHORT nIndex = MID_FIRST_CONTROL; - sal_uInt32 nControlIndex; - ControlContainer& rContainer (mpTaskPane->GetControlContainer()); - for (nControlIndex=0; - nControlIndex<rContainer.GetControlCount(); - nControlIndex=rContainer.GetNextIndex(nControlIndex,true,false)) - { - TreeNode* pChild = rContainer.GetControl(nControlIndex); - TitledControl* pControl - = static_cast<TitledControl*>(pChild->GetWindow()); - pMenu->InsertItem (nIndex, - pControl->GetTitle(), - MIB_CHECKABLE); - pMenu->SetUserValue (nIndex, nControlIndex); - if (pControl->IsVisible()) - pMenu->CheckItem (nIndex, TRUE); - nIndex++; - } - - pMenu->InsertSeparator (); - - // Add entry for docking or un-docking the tool panel. - if (bIsDocking) - pMenu->InsertItem ( - MID_UNLOCK_TASK_PANEL, - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_UNLOCK))); - else - pMenu->InsertItem ( - MID_LOCK_TASK_PANEL, - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_LOCK))); - pMenu->RemoveDisabledEntries (FALSE, FALSE); - - return pMenu; -} - - - - -SdPage* TaskPaneViewShell::GetActualPage (void) -{ - return NULL; -} - -SdPage* TaskPaneViewShell::getCurrentPage(void) const -{ - return NULL; -} - - - -void TaskPaneViewShell::Execute (SfxRequest& ) -{ -} - - - - -void TaskPaneViewShell::GetState (SfxItemSet& rItemSet) -{ - (void)rItemSet; -} - - - - -TaskPaneShellManager& TaskPaneViewShell::GetSubShellManager (void) const -{ - return *mpSubShellManager.get(); -} - - - - -DockingWindow* TaskPaneViewShell::GetDockingWindow (void) -{ - ::Window* pParentWindow = GetParentWindow(); - DockingWindow* pDockingWindow = NULL; - while (pParentWindow!=NULL && pDockingWindow==NULL) - { - pDockingWindow = dynamic_cast<DockingWindow*>(pParentWindow); - pParentWindow = pParentWindow->GetParent(); - } - return pDockingWindow; -} - - - - -void TaskPaneViewShell::ShowPanel (const PanelId nPublicId) -{ - Initialize(); - sal_uInt32 nId (mpImpl->GetInternalId(nPublicId)); - if (nId != Implementation::mnInvalidId) - { - mpTaskPane->GetControlContainer().SetVisibilityState ( - nId, - ControlContainer::VS_SHOW); - } -} - - - - -void TaskPaneViewShell::HidePanel (const PanelId nPublicId) -{ - Initialize(); - sal_uInt32 nId (mpImpl->GetInternalId(nPublicId)); - if (nId != Implementation::mnInvalidId) - { - mpTaskPane->GetControlContainer().SetVisibilityState ( - nId, - ControlContainer::VS_HIDE); - } -} - - - - -void TaskPaneViewShell::ExpandPanel (const PanelId nPublicId) -{ - Initialize(); - sal_uInt32 nId (mpImpl->GetInternalId(nPublicId)); - if (nId != Implementation::mnInvalidId) - { - mpTaskPane->GetControlContainer().SetExpansionState ( - nId, - ControlContainer::ES_EXPAND); - } -} - - - - -void TaskPaneViewShell::CollapsePanel (const PanelId nPublicId) -{ - Initialize(); - sal_uInt32 nId (mpImpl->GetInternalId(nPublicId)); - if (nId != Implementation::mnInvalidId) - { - mpTaskPane->GetControlContainer().SetExpansionState ( - nId, - ControlContainer::ES_COLLAPSE); - } -} - - - - -::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> - TaskPaneViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow) -{ - ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> xAccessible; - - if (mpTaskPane.get()!=NULL && pWindow!=NULL) - { - // We have to call CreateAccessible directly so that we can specify - // the correct accessible parent. - ::Window* pParentWindow = pWindow->GetAccessibleParentWindow(); - if (pParentWindow != NULL) - xAccessible = mpTaskPane->CreateAccessibleObject( - pParentWindow->GetAccessible()); - } - - return xAccessible; -} - - - - -Reference<drawing::XDrawSubController> TaskPaneViewShell::CreateSubController (void) -{ - // This view shell is not designed to be the main view shell and thus - // does not support a UNO sub controller. - return Reference<drawing::XDrawSubController>(); -} - - - - -bool TaskPaneViewShell::RelocateToParentWindow (::Window* pParentWindow) -{ - ::Window* pOldParentWindow = GetParentWindow(); - FocusManager::Instance().RemoveLinks(pOldParentWindow, mpTaskPane.get()); - FocusManager::Instance().RemoveLinks(mpTaskPane.get(), pOldParentWindow); - - ViewShell::RelocateToParentWindow(pParentWindow); - - PaneDockingWindow* pDockingWindow = dynamic_cast<PaneDockingWindow*>(GetDockingWindow()); - if (pDockingWindow != NULL) - { - pDockingWindow->InitializeTitleToolBox(); - mnMenuId = pDockingWindow->AddMenu ( - String(SdResId(STR_TASKPANEL_MASTER_PAGE_MENU_TITLE)), - HID_SD_TASK_PANE_VIEW_MENU, - LINK(this, TaskPaneViewShell, ToolboxClickHandler)); - } - FocusManager::Instance().RegisterDownLink(pParentWindow, mpTaskPane.get()); - - Resize(); - - return true; -} - - - - -//===== TaskPaneViewShell::Implementation ===================================== - -TaskPaneViewShell::Implementation::Implementation (void) - : maIndexMap( - (InternalIdToPanelIdMap::size_type)PID__END, - PID_UNKNOWN) -{ -} - - - - -TaskPaneViewShell::Implementation::~Implementation (void) -{ -} - - - - -void TaskPaneViewShell::Implementation::AddPanel ( - sal_uInt32 nInternalId, - PanelId nPublicId) -{ - maIndexMap[nInternalId] = nPublicId; -} - - - - -TaskPaneViewShell::PanelId - TaskPaneViewShell::Implementation::GetPublicId ( - sal_uInt32 nInternalId) const -{ - if (nInternalId < maIndexMap.size()) - return maIndexMap[nInternalId]; - else - return PID_UNKNOWN; -} - - - - -sal_uInt32 - TaskPaneViewShell::Implementation::GetInternalId ( - TaskPaneViewShell::PanelId nPublicId) const -{ - sal_uInt32 nId = mnInvalidId; - for (sal_uInt32 nI=0; nI<maIndexMap.size(); nI++) - if (maIndexMap[nI] == nPublicId) - { - nId = nI; - break; - } - - return nId; -} - - - - -//===== PanelActivation ======================================================= - -PanelActivation::PanelActivation (ViewShellBase& rBase, TaskPaneViewShell::PanelId nPanelId) - : mrBase(rBase), - mnPanelId(nPanelId) -{ -} - -void PanelActivation::operator() (bool) -{ - toolpanel::TaskPaneViewShell* pTaskPane - = dynamic_cast<toolpanel::TaskPaneViewShell*>( - framework::FrameworkHelper::Instance(mrBase) - ->GetViewShell(framework::FrameworkHelper::msRightPaneURL).get()); - if (pTaskPane != NULL) - pTaskPane->ShowPanel(mnPanelId); -} - - - - -//===== ResourceActivationClickHandler ======================================== - -ResourceActivationClickHandler::ResourceActivationClickHandler ( - const ::boost::shared_ptr<FrameworkHelper>& rpFrameworkHelper, - const Reference<drawing::framework::XResourceId>& rxResourceId, - ControlContainer& rControlContainer) - : mpFrameworkHelper(rpFrameworkHelper), - mxResourceId(rxResourceId), - mrControlContainer(rControlContainer) -{ -} - - - - -void ResourceActivationClickHandler::operator () (TitledControl& rTitledControl) -{ - mrControlContainer.SetExpansionState ( - &rTitledControl, - ControlContainer::ES_EXPAND); - mpFrameworkHelper->GetConfigurationController()->requestResourceActivation( - mxResourceId, drawing::framework::ResourceActivationMode_REPLACE); -} - - -} } // end of namespace ::sd::toolpanel diff --git a/sd/source/ui/toolpanel/TestMenu.cxx b/sd/source/ui/toolpanel/TestMenu.cxx index 7bfb6adebe8d..54c865f12728 100644..100755 --- a/sd/source/ui/toolpanel/TestMenu.cxx +++ b/sd/source/ui/toolpanel/TestMenu.cxx @@ -45,16 +45,16 @@ class ColorMenuFactory : public ControlFactory { protected: - virtual TreeNode* InternalCreateControl (TreeNode* pTreeNode) + virtual TreeNode* InternalCreateControl( ::Window& i_rParent ) { - return new ColorMenu (pTreeNode); + return new ColorMenu (&i_rParent); } }; -ColorMenu::ColorMenu (TreeNode* pParent) - : Window (pParent->GetWindow()), - TreeNode(pParent), +ColorMenu::ColorMenu (::Window* i_pParent) + : Window (i_pParent), + TreeNode(NULL), maSet (this), mnPreferredColumnCount(2) { @@ -71,7 +71,7 @@ ColorMenu::ColorMenu (TreeNode* pParent) Fill (); maSet.Show(); - pParent->RequestResize(); + i_pParent->Resize(); } diff --git a/sd/source/ui/toolpanel/TestMenu.hxx b/sd/source/ui/toolpanel/TestMenu.hxx index 37ac6542970d..2b5dfe2e2e57 100644..100755 --- a/sd/source/ui/toolpanel/TestMenu.hxx +++ b/sd/source/ui/toolpanel/TestMenu.hxx @@ -47,7 +47,7 @@ class ColorMenu public TreeNode { public: - ColorMenu (TreeNode* pParent); + ColorMenu (::Window* i_pParent); virtual ~ColorMenu (void); static ::std::auto_ptr<ControlFactory> CreateControlFactory (void); diff --git a/sd/source/ui/toolpanel/TestPanel.cxx b/sd/source/ui/toolpanel/TestPanel.cxx index e2786e23a0c5..f0b6951cefc4 100644..100755 --- a/sd/source/ui/toolpanel/TestPanel.cxx +++ b/sd/source/ui/toolpanel/TestPanel.cxx @@ -45,9 +45,9 @@ class TestPanelFactory : public ControlFactory { protected: - virtual TreeNode* InternalCreateControl (TreeNode* pTreeNode) + virtual TreeNode* InternalCreateControl( ::Window& i_rParent ) { - return new TestPanel (pTreeNode); + return new TestPanel (i_rParent); } }; @@ -109,8 +109,8 @@ private: }; -TestPanel::TestPanel (TreeNode* pParent) - : SubToolPanel (pParent) +TestPanel::TestPanel (::Window& i_rParent) + : SubToolPanel (i_rParent) { // Create a scrollable panel with two list boxes. ScrollPanel* pScrollPanel = new ScrollPanel (this); diff --git a/sd/source/ui/toolpanel/TestPanel.hxx b/sd/source/ui/toolpanel/TestPanel.hxx index f883cc08c1e1..af1b97d0f885 100644..100755 --- a/sd/source/ui/toolpanel/TestPanel.hxx +++ b/sd/source/ui/toolpanel/TestPanel.hxx @@ -42,7 +42,7 @@ class TestPanel : public SubToolPanel { public: - TestPanel (TreeNode* pParent); + TestPanel (::Window& i_rParent); virtual ~TestPanel (void); static std::auto_ptr<ControlFactory> CreateControlFactory (void); diff --git a/sd/source/ui/toolpanel/TitleBar.cxx b/sd/source/ui/toolpanel/TitleBar.cxx index e0b48a6cf57b..de49b7a6abb5 100644..100755 --- a/sd/source/ui/toolpanel/TitleBar.cxx +++ b/sd/source/ui/toolpanel/TitleBar.cxx @@ -60,13 +60,12 @@ namespace sd { namespace toolpanel { const int TitleBar::snIndentationWidth = 16; TitleBar::TitleBar ( ::Window* pParent, const String& rsTitle, TitleBarType eType, bool bIsExpandable) -: ::Window (pParent) +: ::Window (pParent, WB_TABSTOP) , TreeNode(this) , meType(eType) , msTitle(rsTitle) , mbExpanded(false) , mbFocused(false) -, mbMouseOver(false) , mpDevice(new VirtualDevice (*this)) , mbIsExpandable (bIsExpandable) { @@ -77,10 +76,6 @@ TitleBar::TitleBar ( ::Window* pParent, const String& rsTitle, TitleBarType eTyp // Change the mouse pointer shape so that it acts as a mouse over effect. switch (meType) { - case TBT_WINDOW_TITLE: - break; - - case TBT_CONTROL_TITLE: case TBT_SUB_CONTROL_HEADLINE: if (mbIsExpandable) SetPointer (POINTER_REFHAND); @@ -170,14 +165,6 @@ void TitleBar::Paint (const Rectangle& rBoundingBox) switch (meType) { - case TBT_WINDOW_TITLE: - PaintWindowTitleBar (); - break; - - case TBT_CONTROL_TITLE: - PaintPanelControlTitle (); - break; - case TBT_SUB_CONTROL_HEADLINE: PaintSubPanelHeadLineBar (); break; @@ -223,22 +210,21 @@ void TitleBar::SetEnabledState(bool bFlag) } -void TitleBar::SetFocus (bool bFlag) + + +void TitleBar::GetFocus() { - mbFocused = bFlag; - Invalidate (); + mbFocused = true; + Invalidate(); } -void TitleBar::SetMouseOver (bool bFlag) +void TitleBar::LoseFocus() { - if (bFlag != mbMouseOver) - { - mbMouseOver = bFlag; - // Invalidate(); - } + mbFocused = false; + Invalidate(); } @@ -251,15 +237,9 @@ bool TitleBar::HasExpansionIndicator (void) const { switch (meType) { - case TBT_CONTROL_TITLE: case TBT_SUB_CONTROL_HEADLINE: bHasExpansionIndicator = true; break; - - default: - case TBT_WINDOW_TITLE: - // bHasExpansionIndicator remains false - break; } } return bHasExpansionIndicator; @@ -277,21 +257,6 @@ Image TitleBar::GetExpansionIndicator (void) const USHORT nResourceId = 0; switch (meType) { - case TBT_CONTROL_TITLE: - if (mbExpanded) - if (bHighContrastMode) - nResourceId = BMP_TRIANGLE_DOWN_H; - else - nResourceId = BMP_TRIANGLE_DOWN; - else - if (bHighContrastMode) - nResourceId = BMP_TRIANGLE_RIGHT_H; - else - nResourceId = BMP_TRIANGLE_RIGHT; - - aIndicator = IconCache::Instance().GetIcon(nResourceId); - break; - case TBT_SUB_CONTROL_HEADLINE: if (mbExpanded) if (bHighContrastMode) @@ -306,11 +271,6 @@ Image TitleBar::GetExpansionIndicator (void) const aIndicator = IconCache::Instance().GetIcon(nResourceId); break; - - default: - case TBT_WINDOW_TITLE: - // aIndicator remains empty Image. - break; } } @@ -320,35 +280,6 @@ Image TitleBar::GetExpansionIndicator (void) const -void TitleBar::PaintPanelControlTitle (void) -{ - int nWidth (GetOutputSizePixel().Width()); - Rectangle aTextBox (CalculateTextBoundingBox (nWidth, true)); - PaintBackground(CalculateTitleBarBox(aTextBox, nWidth)); - Rectangle aFocusBox (PaintExpansionIndicator (aTextBox)); - PaintText (aTextBox); - aFocusBox.Union (aTextBox); - aFocusBox.Left() += 2; - PaintFocusIndicator (aFocusBox); - PaintMouseOverIndicator (aTextBox); -} - - - - -void TitleBar::PaintWindowTitleBar (void) -{ - Rectangle aTextBox (CalculateTextBoundingBox ( - GetOutputSizePixel().Width(), - true)); - - PaintText (aTextBox); - PaintFocusIndicator (aTextBox); -} - - - - void TitleBar::PaintSubPanelHeadLineBar (void) { int nWidth (GetOutputSizePixel().Width()); @@ -369,7 +300,6 @@ void TitleBar::PaintSubPanelHeadLineBar (void) aFocusBox.Left() -= 2; aFocusBox.Right() += 1; PaintFocusIndicator (aFocusBox); - PaintMouseOverIndicator (aTextBox); } @@ -406,21 +336,6 @@ void TitleBar::PaintFocusIndicator (const Rectangle& rTextBox) -void TitleBar::PaintMouseOverIndicator (const Rectangle& rTextBox) -{ - if (mbMouseOver) - { - Rectangle aBox (rTextBox); - // Show the line below the focus rectangle (which is painted - // after and over the mouse over indicator.) - // aBox.Bottom() += 2; - // DrawLine (aBox.BottomLeft(), aBox.BottomRight()); - } -} - - - - Rectangle TitleBar::PaintExpansionIndicator (const Rectangle& rTextBox) { Rectangle aExpansionIndicatorArea; @@ -482,29 +397,6 @@ void TitleBar::PaintBackground (const Rectangle& rTitleBarBox) switch (meType) { - case TBT_CONTROL_TITLE: - { - mpDevice->SetFillColor ( - GetSettings().GetStyleSettings().GetDialogColor()); - mpDevice->DrawRect(rTitleBarBox); - - mpDevice->SetFillColor(); - mpDevice->SetLineColor ( - GetSettings().GetStyleSettings().GetLightColor()); - mpDevice->DrawLine( - rTitleBarBox.TopLeft(),rTitleBarBox.TopRight()); - mpDevice->DrawLine( - rTitleBarBox.TopLeft(),rTitleBarBox.BottomLeft()); - - mpDevice->SetLineColor ( - GetSettings().GetStyleSettings().GetShadowColor()); - mpDevice-> DrawLine( - rTitleBarBox.BottomLeft(), rTitleBarBox.BottomRight()); - mpDevice->DrawLine( - rTitleBarBox.TopRight(), rTitleBarBox.BottomRight()); - } - break; - case TBT_SUB_CONTROL_HEADLINE: { Color aColor (GetSettings().GetStyleSettings().GetDialogColor()); @@ -534,10 +426,6 @@ void TitleBar::PaintBackground (const Rectangle& rTitleBarBox) Point(rTitleBarBox.Right(), rTitleBarBox.Bottom())); } break; - - default: - case TBT_WINDOW_TITLE: - break; } } @@ -588,16 +476,6 @@ Rectangle TitleBar::CalculateTitleBarBox ( switch (meType) { - case TBT_WINDOW_TITLE: - aTitleBarBox.Bottom() += aTitleBarBox.Top(); - aTitleBarBox.Top() = 0; - break; - - case TBT_CONTROL_TITLE: - aTitleBarBox.Bottom() += aTitleBarBox.Top(); - aTitleBarBox.Top() = 0; - break; - case TBT_SUB_CONTROL_HEADLINE: aTitleBarBox.Top() -= 3; aTitleBarBox.Bottom() += 3; @@ -614,15 +492,8 @@ Rectangle TitleBar::CalculateTitleBarBox ( -void TitleBar::MouseMove (const MouseEvent& rEvent) +void TitleBar::MouseMove (const MouseEvent& ) { - Point aRelativePosition = rEvent.GetPosPixel() - GetPosPixel(); - Size aSize = GetSizePixel(); - SetMouseOver ( - aRelativePosition.X() >= 0 - && aRelativePosition.Y() >= 0 - && aRelativePosition.X() < aSize.Width() - && aRelativePosition.Y() < aSize.Height()); } diff --git a/sd/source/ui/toolpanel/TitleToolBox.cxx b/sd/source/ui/toolpanel/TitleToolBox.cxx index 57cbac3fe132..403e826ee27a 100644..100755 --- a/sd/source/ui/toolpanel/TitleToolBox.cxx +++ b/sd/source/ui/toolpanel/TitleToolBox.cxx @@ -42,18 +42,6 @@ namespace sd { namespace toolpanel { TitleToolBox::TitleToolBox (::Window* pParent, WinBits nStyle ) : ToolBox( pParent, nStyle ) { - lastSize = -1; - - Bitmap aBitmap (SdResId (BMP_CLOSE_DOC)); - Bitmap aBitmapHC (SdResId (BMP_CLOSE_DOC_H)); - Bitmap aTriangleRight (SdResId (BMP_TRIANGLE_RIGHT)); - Bitmap aTriangleDown (SdResId (BMP_TRIANGLE_DOWN)); - - maImage = Image (aBitmap, Color (COL_LIGHTMAGENTA)); - maImageHC = Image (aBitmapHC, Color (BMP_COLOR_HIGHCONTRAST)); - maTriangleRight = Image (aTriangleRight, Color (COL_LIGHTMAGENTA)); - maTriangleDown = Image (aTriangleDown, Color (COL_LIGHTMAGENTA)); - SetOutStyle (TOOLBOX_STYLE_FLAT); SetBackground (Wallpaper ( GetSettings().GetStyleSettings().GetDialogColor())); @@ -62,43 +50,6 @@ TitleToolBox::TitleToolBox (::Window* pParent, WinBits nStyle ) -void TitleToolBox::AddItem (ToolBoxId aId) -{ - switch (aId) - { - case TBID_PANEL_MENU: - InsertItem (TBID_PANEL_MENU, - String::CreateFromAscii ("Panel"), - TIB_DROPDOWN); - break; - - case TBID_DOCUMENT_CLOSE: - InsertItem (TBID_DOCUMENT_CLOSE, - GetSettings().GetStyleSettings().GetHighContrastMode() - ? maImageHC : maImage, 0 ); - break; - - case TBID_TRIANGLE_RIGHT: - InsertItem (TBID_TRIANGLE_RIGHT, - maTriangleRight, 0); - break; - - case TBID_TRIANGLE_DOWN: - InsertItem (TBID_TRIANGLE_DOWN, - maTriangleDown, 0); - break; - - case TBID_TEST: - InsertItem (TBID_TEST, - String::CreateFromAscii ("Test"), - TIB_DROPDOWN); - break; - } -} - - - - void TitleToolBox::DataChanged (const DataChangedEvent& rDCEvt) { Window::DataChanged (rDCEvt); diff --git a/sd/source/ui/toolpanel/TitleToolBox.hxx b/sd/source/ui/toolpanel/TitleToolBox.hxx index 9433706579df..db2c971c3539 100644..100755 --- a/sd/source/ui/toolpanel/TitleToolBox.hxx +++ b/sd/source/ui/toolpanel/TitleToolBox.hxx @@ -42,27 +42,9 @@ class TitleToolBox : public ToolBox { public: - enum ToolBoxId { - TBID_DOCUMENT_CLOSE = 1, - TBID_PANEL_MENU = 2, - TBID_TRIANGLE_RIGHT = 3, - TBID_TRIANGLE_DOWN = 4, - TBID_TEST - }; - TitleToolBox (::Window* pParent, WinBits nStyle = 0); - void AddItem (ToolBoxId aId); - void DataChanged (const DataChangedEvent& rDCEvt); - -private: - Image maImage; - Image maImageHC; - Image maTriangleRight; - Image maTriangleDown; - - long lastSize; }; } } // end of namespace ::sd::toolbox diff --git a/sd/source/ui/toolpanel/TitledControl.cxx b/sd/source/ui/toolpanel/TitledControl.cxx index 7930bb4cd7f1..4843102feb48 100644..100755 --- a/sd/source/ui/toolpanel/TitledControl.cxx +++ b/sd/source/ui/toolpanel/TitledControl.cxx @@ -52,53 +52,15 @@ TitledControl::TitledControl ( msTitle(rTitle), mbVisible(true), mpUserData(NULL), - mpControlFactory(NULL), - mpClickHandler(new ClickHandler(rClickHandler)), - mbExpansionModeIsToggle(eType!=TitleBar::TBT_CONTROL_TITLE) -{ - if (pControl.get() != NULL) - { - mpControlContainer->AddControl (::std::auto_ptr<TreeNode> ( - new TitleBar (this, rTitle, eType, pControl->IsExpandable()))); - pControl->SetParentNode (this); - } - mpControlContainer->AddControl (pControl); - - FocusManager::Instance().RegisterDownLink(this, GetControl()->GetWindow()); - FocusManager::Instance().RegisterUpLink(GetControl()->GetWindow(), this); - - SetBackground (Wallpaper()); - - GetTitleBar()->GetWindow()->Show (); - GetTitleBar()->GetWindow()->AddEventListener ( - LINK(this,TitledControl,WindowEventListener)); - - UpdateStates (); -} - - - - -TitledControl::TitledControl ( - TreeNode* pParent, - ::std::auto_ptr<ControlFactory> pControlFactory, - const String& rTitle, - const ClickHandler& rClickHandler, - TitleBar::TitleBarType eType) - : ::Window (pParent->GetWindow(), WB_TABSTOP), - TreeNode(pParent), - msTitle (rTitle), - mbVisible (true), - mpUserData (NULL), - mpControlFactory(pControlFactory), - mpClickHandler(new ClickHandler(rClickHandler)), - mbExpansionModeIsToggle(eType!=TitleBar::TBT_CONTROL_TITLE) + mpClickHandler(new ClickHandler(rClickHandler)) { mpControlContainer->AddControl (::std::auto_ptr<TreeNode> ( - new TitleBar (this, rTitle, eType, true))); + new TitleBar (this, rTitle, eType, pControl->IsExpandable()))); + pControl->SetParentNode (this); + mpControlContainer->AddControl (pControl); - // The second control is created on demand, i.e. when GetControl(true) - // is called the first time. + FocusManager::Instance().RegisterDownLink( GetTitleBar()->GetWindow(), GetControl()->GetWindow() ); + FocusManager::Instance().RegisterUpLink( GetControl()->GetWindow(), GetTitleBar()->GetWindow() ); SetBackground (Wallpaper()); @@ -124,7 +86,7 @@ TitledControl::~TitledControl (void) Size TitledControl::GetPreferredSize (void) { Size aPreferredSize; - if (GetControl(false) != NULL) + if (GetControl() != NULL) { aPreferredSize = GetControl()->GetPreferredSize(); if ( ! IsExpanded()) @@ -146,7 +108,7 @@ Size TitledControl::GetPreferredSize (void) sal_Int32 TitledControl::GetPreferredWidth (sal_Int32 nHeight) { int nPreferredWidth = 0; - if (GetControl(false) != NULL) + if (GetControl() != NULL) nPreferredWidth = GetControl()->GetPreferredWidth( nHeight - GetTitleBar()->GetWindow()->GetSizePixel().Height()); else @@ -163,7 +125,7 @@ sal_Int32 TitledControl::GetPreferredWidth (sal_Int32 nHeight) sal_Int32 TitledControl::GetPreferredHeight (sal_Int32 nWidth) { int nPreferredHeight = 0; - if (IsExpanded() && GetControl(false)!=NULL) + if (IsExpanded() && GetControl()!=NULL) nPreferredHeight = GetControl()->GetPreferredHeight(nWidth); nPreferredHeight += GetTitleBar()->GetPreferredHeight(nWidth); @@ -201,7 +163,7 @@ void TitledControl::Resize (void) Size (aWindowSize.Width(), nTitleBarHeight)); - TreeNode* pControl = GetControl(false); + TreeNode* pControl = GetControl(); if (pControl != NULL && pControl->GetWindow() != NULL && pControl->GetWindow()->IsVisible()) @@ -219,17 +181,7 @@ void TitledControl::GetFocus (void) { ::Window::GetFocus(); if (GetTitleBar() != NULL) - GetTitleBar()->SetFocus (true); -} - - - - -void TitledControl::LoseFocus (void) -{ - ::Window::LoseFocus(); - if (GetTitleBar() != NULL) - GetTitleBar()->SetFocus (false); + GetTitleBar()->GrabFocus(); } @@ -258,7 +210,7 @@ void TitledControl::KeyInput (const KeyEvent& rEvent) if ( ! FocusManager::Instance().TransferFocus(this,nCode)) { // When already expanded then put focus on first child. - TreeNode* pControl = GetControl(false); + TreeNode* pControl = GetControl(); if (pControl!=NULL && IsExpanded()) if (pControl->GetWindow() != NULL) pControl->GetWindow()->GrabFocus(); @@ -296,7 +248,7 @@ bool TitledControl::Expand (bool bExpanded) // Get the control. Use the bExpanded parameter as argument to // indicate that a control is created via its factory only when it // is to be expanded. When it is collapsed this is not necessary. - TreeNode* pControl = GetControl(bExpanded); + TreeNode* pControl = GetControl(); if (pControl != NULL && GetControl()->IsExpanded() != bExpanded) { @@ -314,7 +266,7 @@ bool TitledControl::Expand (bool bExpanded) bool TitledControl::IsExpandable (void) const { - const TreeNode* pControl = GetConstControl(false); + const TreeNode* pControl = GetConstControl(); if (pControl != NULL) return pControl->IsExpandable(); else @@ -328,7 +280,7 @@ bool TitledControl::IsExpandable (void) const bool TitledControl::IsExpanded (void) const { - const TreeNode* pControl = GetConstControl(false); + const TreeNode* pControl = GetConstControl(); if (pControl != NULL) return pControl->IsExpanded(); else @@ -402,7 +354,7 @@ void TitledControl::UpdateStates (void) else GetWindow()->Hide(); - TreeNode* pControl = GetControl(false); + TreeNode* pControl = GetControl(); if (pControl!=NULL && pControl->GetWindow() != NULL) { if (IsVisible() && IsExpanded()) @@ -435,33 +387,17 @@ IMPL_LINK(TitledControl, WindowEventListener, -TreeNode* TitledControl::GetControl (bool bCreate) +TreeNode* TitledControl::GetControl (void) { - TreeNode* pNode = mpControlContainer->GetControl(1); - if (pNode==NULL && mpControlFactory.get()!=NULL && bCreate) - { - // We have to create the control with the factory object. - ::std::auto_ptr<TreeNode> pControl (mpControlFactory->CreateControl(this));//GetParentNode())); - if (pControl.get() != NULL) - { - pControl->SetParentNode(this); - mpControlContainer->AddControl(pControl); - - pNode = mpControlContainer->GetControl(1); - FocusManager::Instance().RegisterDownLink(this, pNode->GetWindow()); - FocusManager::Instance().RegisterUpLink(pNode->GetWindow(), this); - } - } - - return pNode; + return mpControlContainer->GetControl(1); } -const TreeNode* TitledControl::GetConstControl (bool bCreate) const +const TreeNode* TitledControl::GetConstControl () const { - return const_cast<TitledControl*>(this)->GetControl(bCreate); + return const_cast<TitledControl*>(this)->GetControl(); } diff --git a/sd/source/ui/toolpanel/ToolPanel.cxx b/sd/source/ui/toolpanel/ToolPanel.cxx index c87b3cc63ef5..6dbcae52547a 100755 --- a/sd/source/ui/toolpanel/ToolPanel.cxx +++ b/sd/source/ui/toolpanel/ToolPanel.cxx @@ -1,5 +1,4 @@ /************************************************************************* - * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * Copyright 2000, 2010 Oracle and/or its affiliates. @@ -25,265 +24,90 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sd.hxx" -#include "taskpane/ToolPanel.hxx" - -#include "TaskPaneFocusManager.hxx" -#include "taskpane/TitleBar.hxx" -#include "taskpane/TitledControl.hxx" -#include "taskpane/ControlContainer.hxx" -#include "TaskPaneViewShell.hxx" -#include "taskpane/TaskPaneControlFactory.hxx" -#include "AccessibleTaskPane.hxx" - -#include "strings.hrc" -#include "sdresid.hxx" -#include <vcl/decoview.hxx> -#include <vcl/menu.hxx> -#include <vcl/svapp.hxx> - -namespace sd { namespace toolpanel { - - -/** Use WB_DIALOGCONTROL as argument for the Control constructor to - let VCL handle focus traveling. In addition the control - descriptors have to use WB_TABSTOP. -*/ -ToolPanel::ToolPanel ( - Window* pParentWindow, - TaskPaneViewShell& rViewShell) - : Control (pParentWindow, WB_DIALOGCONTROL), - TreeNode (NULL), - mrViewShell(rViewShell), - mbRearrangeActive(false) -{ - SetBackground (Wallpaper ()); -} - - - - -ToolPanel::~ToolPanel (void) -{ -} - +#include "ToolPanel.hxx" +#include "MethodGuard.hxx" +#include <taskpane/TaskPaneTreeNode.hxx> +/** === begin UNO includes === **/ +#include <com/sun/star/lang/DisposedException.hpp> +/** === end UNO includes === **/ +#include <vcl/window.hxx> -sal_uInt32 ToolPanel::AddControl ( - ::std::auto_ptr<ControlFactory> pControlFactory, - const String& rTitle, - ULONG nHelpId, - const TitledControl::ClickHandler& rClickHandler) +//...................................................................................................................... +namespace sd { namespace toolpanel { - TitledControl* pTitledControl = new TitledControl ( - this, - pControlFactory, - rTitle, - rClickHandler, - TitleBar::TBT_CONTROL_TITLE); - ::std::auto_ptr<TreeNode> pChild (pTitledControl); - - // Get the (grand) parent window which is focus-wise our parent. - Window* pParent = GetParent(); - if (pParent != NULL) - pParent = pParent->GetParent(); - - FocusManager& rFocusManager (FocusManager::Instance()); - int nControlCount (mpControlContainer->GetControlCount()); - - // Add a link up from every control to the parent. A down link is added - // only for the first control so that when entering the sub tool panel - // the focus is set to the first control. - if (pParent != NULL) +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::accessibility::XAccessible; + /** === end UNO using === **/ + + typedef MethodGuard< ToolPanel > ToolPanelGuard; + + //================================================================================================================== + //= ToolPanel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ToolPanel::ToolPanel( ::std::auto_ptr< TreeNode >& i_rControl ) + :ToolPanel_Base( m_aMutex ) + ,m_pControl( i_rControl ) { - if (nControlCount == 1) - rFocusManager.RegisterDownLink(pParent, pChild->GetWindow()); - rFocusManager.RegisterUpLink(pChild->GetWindow(), pParent); } - // Replace the old links for cycling between first and last child by - // current onems. - if (nControlCount > 0) + //------------------------------------------------------------------------------------------------------------------ + ToolPanel::~ToolPanel() { - ::Window* pFirst = mpControlContainer->GetControl(0)->GetWindow(); - ::Window* pLast = mpControlContainer->GetControl(nControlCount-1)->GetWindow(); - rFocusManager.RemoveLinks(pFirst,pLast); - rFocusManager.RemoveLinks(pLast,pFirst); - - rFocusManager.RegisterLink(pFirst,pChild->GetWindow(), KEY_UP); - rFocusManager.RegisterLink(pChild->GetWindow(),pFirst, KEY_DOWN); } - pTitledControl->GetWindow()->SetHelpId(nHelpId); - - return mpControlContainer->AddControl (pChild); -} - - - - -void ToolPanel::ListHasChanged (void) -{ - mpControlContainer->ListHasChanged (); - Rearrange (); -} - - - - -void ToolPanel::Resize (void) -{ - Control::Resize(); - Rearrange (); -} - - - - -void ToolPanel::RequestResize (void) -{ - Invalidate(); - Rearrange (); -} - - - - -/** Subtract the space for the title bars from the available space and - give the remaining space to the active control. -*/ -void ToolPanel::Rearrange (void) -{ - // Prevent recursive calls. - if ( ! mbRearrangeActive && mpControlContainer->GetVisibleControlCount()>0) + //------------------------------------------------------------------------------------------------------------------ + void ToolPanel::checkDisposed() { - mbRearrangeActive = true; - - SetBackground (Wallpaper ()); - - // Make the area that is covered by the children a little bit - // smaller so that a frame is visible arround them. - Rectangle aAvailableArea (Point(0,0), GetOutputSizePixel()); - - int nWidth = aAvailableArea.GetWidth(); - sal_uInt32 nControlCount (mpControlContainer->GetControlCount()); - sal_uInt32 nActiveControlIndex ( - mpControlContainer->GetActiveControlIndex()); + if ( m_pControl.get() == NULL ) + throw DisposedException( ::rtl::OUString(), *this ); + } - // Place title bars of controls above the active control and thereby - // determine the top of the active control. - sal_uInt32 nIndex; - for (nIndex=mpControlContainer->GetFirstIndex(); - nIndex<nActiveControlIndex; - nIndex=mpControlContainer->GetNextIndex(nIndex)) - { - TreeNode* pChild = mpControlContainer->GetControl(nIndex); - if (pChild != NULL) - { - sal_uInt32 nHeight = pChild->GetPreferredHeight (nWidth); - pChild->GetWindow()->SetPosSizePixel ( - aAvailableArea.TopLeft(), - Size(nWidth, nHeight)); - aAvailableArea.Top() += nHeight; - } - } + //------------------------------------------------------------------------------------------------------------------ + Reference< XWindow > SAL_CALL ToolPanel::getWindow() throw (RuntimeException) + { + ToolPanelGuard aGuard( *this ); + return Reference< XWindow >( m_pControl->GetWindow()->GetComponentInterface(), UNO_QUERY_THROW ); + } - // Place title bars of controls below the active control and thereby - // determine the bottom of the active control. - for (nIndex=mpControlContainer->GetLastIndex(); - nIndex<nControlCount && nIndex!=nActiveControlIndex; - nIndex=mpControlContainer->GetPreviousIndex(nIndex)) + //------------------------------------------------------------------------------------------------------------------ + Reference< XAccessible > SAL_CALL ToolPanel::createAccessible( const Reference< XAccessible >& i_rParentAccessible ) throw (RuntimeException) + { + ToolPanelGuard aGuard( *this ); + Reference< XAccessible > xAccessible( m_pControl->GetWindow()->GetAccessible( FALSE ) ); + if ( !xAccessible.is() ) { - TreeNode* pChild = mpControlContainer->GetControl(nIndex); - if (pChild != NULL) - { - sal_uInt32 nHeight = pChild->GetPreferredHeight (nWidth); - pChild->GetWindow()->SetPosSizePixel ( - Point(aAvailableArea.Left(), - aAvailableArea.Bottom()-nHeight+1), - Size(nWidth, nHeight)); - aAvailableArea.Bottom() -= nHeight; - } + xAccessible.set( m_pControl->CreateAccessibleObject( i_rParentAccessible ) ); + m_pControl->GetWindow()->SetAccessible( xAccessible ); } - - // Finally place the active control. - TreeNode* pChild = mpControlContainer->GetControl(nActiveControlIndex); - if (pChild != NULL) - pChild->GetWindow()->SetPosSizePixel ( - aAvailableArea.TopLeft(), - aAvailableArea.GetSize()); - - mbRearrangeActive = false; + return xAccessible; } - else - SetBackground ( - Application::GetSettings().GetStyleSettings().GetDialogColor()); -} - - - - -Size ToolPanel::GetPreferredSize (void) -{ - return Size(300,300); -} - - - - -sal_Int32 ToolPanel::GetPreferredWidth (sal_Int32 ) -{ - return 300; -} - - - - -sal_Int32 ToolPanel::GetPreferredHeight (sal_Int32 ) -{ - return 300; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanel::disposing() + { + m_pControl.reset(); + } - - -bool ToolPanel::IsResizable (void) -{ - return true; -} - - - - -::Window* ToolPanel::GetWindow (void) -{ - return this; -} - - - - -TaskPaneShellManager* ToolPanel::GetShellManager (void) -{ - return &mrViewShell.GetSubShellManager(); -} - - - - -::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible> ToolPanel::CreateAccessibleObject ( - const ::com::sun::star::uno::Reference< - ::com::sun::star::accessibility::XAccessible>& rxParent) -{ - return new ::accessibility::AccessibleTaskPane ( - rxParent, - String(SdResId(STR_RIGHT_PANE_TITLE)), - String(SdResId(STR_RIGHT_PANE_TITLE)), - *this); -} - -} } // end of namespace ::sd::toolpanel +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/ToolPanel.hxx b/sd/source/ui/toolpanel/ToolPanel.hxx new file mode 100644 index 000000000000..2fe4a64c71be --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanel.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_TOOLPANEL_HXX +#define SD_TOOLPANEL_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XToolPanel.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase1.hxx> + +#include <memory> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + class TreeNode; + + //================================================================================================================== + //= ToolPanel + //================================================================================================================== + typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XToolPanel + > ToolPanel_Base; + class ToolPanel :public ::cppu::BaseMutex + ,public ToolPanel_Base + { + public: + ToolPanel( + ::std::auto_ptr< TreeNode >& i_rControl + ); + + // XToolPanel + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getWindow() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL createAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& ParentAccessible ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + ::osl::Mutex& getMutex() { return m_aMutex; } + void checkDisposed(); + + protected: + ~ToolPanel(); + + private: + ::std::auto_ptr< TreeNode > m_pControl; + }; + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... + +#endif // SD_TOOLPANEL_HXX diff --git a/sd/source/ui/toolpanel/ToolPanelChildWindow.cxx b/sd/source/ui/toolpanel/ToolPanelChildWindow.cxx deleted file mode 100644 index 1db383091bff..000000000000 --- a/sd/source/ui/toolpanel/ToolPanelChildWindow.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sd.hxx" - -#include "ToolPanelChildWindow.hxx" -#include "ToolPanelDockingWindow.hxx" - -#include "sdresid.hxx" -#include "app.hrc" -#include "sfx2/app.hxx" - - -namespace sd { namespace toolpanel { - - - -ToolPanelChildWindow::ToolPanelChildWindow ( - ::Window* pParentWindow, - USHORT nId, - SfxBindings* pBindings, - SfxChildWinInfo* pInfo) - : SfxChildWindow (pParentWindow, nId) -{ - pWindow = new ToolPanelDockingWindow (pBindings, this, pParentWindow); - eChildAlignment = SFX_ALIGN_RIGHT; - static_cast<SfxDockingWindow*>(pWindow)->Initialize (pInfo); - // SetHideNotDelete (TRUE); -}; - - - - -ToolPanelChildWindow::~ToolPanelChildWindow() -{} - - -SFX_IMPL_DOCKINGWINDOW(ToolPanelChildWindow, SID_TOOLPANEL) - - - - -} } // end of namespace ::sd::toolpanel diff --git a/sd/source/ui/toolpanel/ToolPanelChildWindow.src b/sd/source/ui/toolpanel/ToolPanelChildWindow.src deleted file mode 100644 index 079f9608f616..000000000000 --- a/sd/source/ui/toolpanel/ToolPanelChildWindow.src +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "app.hrc" -#include "ToolPanelChildWindow.hrc" - -DockingWindow FLT_WIN_TOOLPANEL -{ - HelpID = SID_TOOLPANEL ; - Border = TRUE ; - Hide = FALSE ; - SVLook = TRUE ; - Sizeable = TRUE ; - Moveable = TRUE ; - Closeable = TRUE ; - Zoomable = TRUE ; - Dockable = TRUE ; - EnableResizing = TRUE ; - Size = MAP_APPFONT ( 140 , 120 ) ; - Text = "Tool Panel" ; - - Control TOOLPANEL - { - Pos = MAP_APPFONT ( 0 , 0 ) ; - Size = MAP_APPFONT ( 69, 150 ) ; - Border = FALSE; - }; -}; diff --git a/sd/source/ui/toolpanel/ToolPanelFactory.cxx b/sd/source/ui/toolpanel/ToolPanelFactory.cxx new file mode 100644 index 000000000000..db4602c991d0 --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanelFactory.cxx @@ -0,0 +1,255 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "taskpane/ToolPanelViewShell.hxx" +#include "framework/FrameworkHelper.hxx" +#include "PaneChildWindows.hxx" +#include "ViewShellBase.hxx" +#include "app.hrc" + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XUIElementFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/awt/XWindow.hpp> +/** === end UNO includes === **/ + +#include <sfx2/frame.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <sfx2/viewfrm.hxx> +#include <cppuhelper/implbase3.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <toolkit/helper/vclunohelper.hxx> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::uno::XComponentContext; + using ::com::sun::star::ui::XUIElementFactory; + using ::com::sun::star::ui::XUIElement; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::container::NoSuchElementException; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::lang::XServiceInfo; + using ::com::sun::star::lang::XInitialization; + using ::com::sun::star::frame::XFrame; + using ::com::sun::star::awt::XWindow; + /** === end UNO using === **/ + + //================================================================================================================== + //= ToolPanelFactory + //================================================================================================================== + typedef ::cppu::WeakImplHelper3 < XUIElementFactory + , XServiceInfo + , XInitialization + > ToolPanelFactory_Base; + class ToolPanelFactory : public ToolPanelFactory_Base + { + public: + ToolPanelFactory( const Reference< XComponentContext >& i_rContext ); + + // XUIElementFactory + virtual Reference< XUIElement > SAL_CALL createUIElement( const ::rtl::OUString& ResourceURL, const Sequence< PropertyValue >& Args ) throw (NoSuchElementException, IllegalArgumentException, RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException); + + protected: + virtual ~ToolPanelFactory(); + + private: + const Reference< XComponentContext > m_xContext; + }; + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL ToolPanelFactory_createInstance( const Reference< XComponentContext >& i_rContext ) + { + return Reference< XInterface >( *new ToolPanelFactory( i_rContext ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString ToolPanelFactory_getImplementationName() throw(RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.drawing.ToolPanelFactory" ) ); + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory_getSupportedServiceNames (void) + throw (RuntimeException) + { + const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DefaultToolPanelFactory" ) ); + return Sequence< ::rtl::OUString >( &sServiceName, 1 ); + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelFactory::ToolPanelFactory( const Reference< XComponentContext >& i_rContext ) + :m_xContext( i_rContext ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelFactory::~ToolPanelFactory() + { + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XUIElement > SAL_CALL ToolPanelFactory::createUIElement( const ::rtl::OUString& i_rResourceURL, const Sequence< PropertyValue >& i_rArgs ) throw (NoSuchElementException, IllegalArgumentException, RuntimeException) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + const PanelId ePanelId( toolpanel::GetStandardPanelId( i_rResourceURL ) ); + if ( ePanelId == PID_UNKNOWN ) + throw NoSuchElementException( i_rResourceURL, *this ); + + const ::comphelper::NamedValueCollection aArgs( i_rArgs ); + const Reference< XFrame > xDocFrame( aArgs.getOrDefault( "Frame", Reference< XFrame >() ) ); + const Reference< XWindow > xParentWindow( aArgs.getOrDefault( "ParentWindow", Reference< XWindow >() ) ); + if ( !xDocFrame.is() || !xParentWindow.is() ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "For creating a standard tool panel, a Frame and a Parent window are needed." ) ), + *this, + 2 + ); + + // look up the Sfx(View)Frame for the given XFrame + SfxViewFrame* pViewFrame = NULL; + for ( SfxFrame* pFrame = SfxFrame::GetFirst(); + pFrame != NULL; + pFrame = SfxFrame::GetNext( *pFrame ) + ) + { + if ( pFrame->GetFrameInterface() == xDocFrame ) + { + pViewFrame = pFrame->GetCurrentViewFrame(); + break; + } + } + + if ( !pViewFrame || !pViewFrame->HasChildWindow( SID_TASKPANE ) ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal frame." ) ), + *this, + 2 + ); + + // retrieve the task pane + ToolPanelChildWindow* pToolPanelWindow( dynamic_cast< ToolPanelChildWindow* >( pViewFrame->GetChildWindow( SID_TASKPANE ) ) ); + if ( !pToolPanelWindow ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No Impress document, or no Impress Task Pane." ) ), + *this, + 2 + ); + + // retrieve the ViewShellBase, and the view shell of the task pane + ViewShellBase* pViewShellBase = dynamic_cast< ViewShellBase* >( pViewFrame->GetViewShell() ); + ::boost::shared_ptr< framework::FrameworkHelper > pFrameworkHelper; + if ( pViewShellBase ) + pFrameworkHelper = framework::FrameworkHelper::Instance( *pViewShellBase ); + ::boost::shared_ptr< ViewShell > pViewShell; + if ( pFrameworkHelper.get() ) + pViewShell = pFrameworkHelper->GetViewShell( framework::FrameworkHelper::msRightPaneURL ); + ToolPanelViewShell* pToolPanelShell = dynamic_cast< ToolPanelViewShell* >( pViewShell.get() ); + + if ( !pToolPanelShell ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Wrong document type." ) ), + *this, + 2 + ); + + ::Window* pParentWindow = VCLUnoHelper::GetWindow( xParentWindow ); + if ( !pParentWindow || !pToolPanelShell->IsPanelAnchorWindow( *pParentWindow ) ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unsupported parent window." ) ), + *this, + 2 + ); + + return pToolPanelShell->CreatePanelUIElement( xDocFrame, i_rResourceURL ); + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName( ) throw (RuntimeException) + { + return ToolPanelFactory_getImplementationName(); + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Bool SAL_CALL ToolPanelFactory::supportsService( const ::rtl::OUString& i_rServiceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() ); + for ( const ::rtl::OUString* pSupported = aSupported.getConstArray(); + pSupported != aSupported.getConstArray() + aSupported.getLength(); + ++pSupported + ) + if ( *pSupported == i_rServiceName ) + return sal_True; + + return sal_False; + } + + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory::getSupportedServiceNames( ) throw (RuntimeException) + { + return ToolPanelFactory_getSupportedServiceNames(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanelFactory::initialize( const Sequence< Any >& i_rArguments ) throw (Exception, RuntimeException) + { + ::comphelper::NamedValueCollection aArgs( i_rArguments ); + (void)aArgs; + // TODO + } + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/ToolPanelUIElement.cxx b/sd/source/ui/toolpanel/ToolPanelUIElement.cxx new file mode 100644 index 000000000000..e81f683bcfa7 --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanelUIElement.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_sd.hxx" + +#include "ToolPanelUIElement.hxx" +#include "MethodGuard.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/UIElementType.hpp> +#include <com/sun/star/lang/XComponent.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XFrame; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::ui::XToolPanel; + using ::com::sun::star::lang::DisposedException; + /** === end UNO using === **/ + namespace UIElementType = ::com::sun::star::ui::UIElementType; + + typedef MethodGuard< ToolPanelUIElement > UIElementMethodGuard; + + //================================================================================================================== + //= ToolPanelUIElement + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + ToolPanelUIElement::ToolPanelUIElement( const Reference< XFrame >& i_rFrame, const ::rtl::OUString& i_rResourceURL, + const Reference< XToolPanel >& i_rToolPanel ) + :ToolPanelUIElement_Base( m_aMutex ) + ,m_xFrame( i_rFrame ) + ,m_sResourceURL( i_rResourceURL ) + ,m_xToolPanel( i_rToolPanel ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + ToolPanelUIElement::~ToolPanelUIElement() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void ToolPanelUIElement::checkDisposed() + { + if ( !m_xToolPanel.is() ) + throw DisposedException( ::rtl::OUString(), *this ); + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XFrame > SAL_CALL ToolPanelUIElement::getFrame() throw (RuntimeException) + { + UIElementMethodGuard aGuard( *this ); + return m_xFrame; + } + + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL ToolPanelUIElement::getResourceURL() throw (RuntimeException) + { + UIElementMethodGuard aGuard( *this ); + return m_sResourceURL; + } + + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int16 SAL_CALL ToolPanelUIElement::getType() throw (RuntimeException) + { + UIElementMethodGuard aGuard( *this ); + return UIElementType::TOOLPANEL; + } + + //------------------------------------------------------------------------------------------------------------------ + Reference< XInterface > SAL_CALL ToolPanelUIElement::getRealInterface( ) throw (RuntimeException) + { + UIElementMethodGuard aGuard( *this ); + return m_xToolPanel.get(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL ToolPanelUIElement::disposing() + { + try + { + Reference< XComponent > xPanelComponent( m_xToolPanel, UNO_QUERY_THROW ); + xPanelComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... diff --git a/sd/source/ui/toolpanel/ToolPanelUIElement.hxx b/sd/source/ui/toolpanel/ToolPanelUIElement.hxx new file mode 100644 index 000000000000..0a74b7bd449e --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanelUIElement.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SD_TOOLPANELUIELEMENT_HXX +#define SD_TOOLPANELUIELEMENT_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XUIElement.hpp> +#include <com/sun/star/ui/XToolPanel.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <memory> + +//...................................................................................................................... +namespace sd { namespace toolpanel +{ +//...................................................................................................................... + + class TreeNode; + + //================================================================================================================== + //= ToolPanelUIElement + //================================================================================================================== + typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XUIElement + > ToolPanelUIElement_Base; + class ToolPanelUIElement :public ::cppu::BaseMutex + ,public ToolPanelUIElement_Base + { + public: + ToolPanelUIElement( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const ::rtl::OUString& i_rResourceURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel >& i_rToolPanel + ); + + // XUIElement + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getResourceURL() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getType() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getRealInterface( ) throw (::com::sun::star::uno::RuntimeException); + + void checkDisposed(); + ::osl::Mutex& getMutex() { return m_aMutex; } + + protected: + virtual ~ToolPanelUIElement(); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + private: + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; + const ::rtl::OUString m_sResourceURL; + const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel > m_xToolPanel; + }; + +//...................................................................................................................... +} } // namespace sd::toolpanel +//...................................................................................................................... + +#endif // SD_TOOLPANELUIELEMENT_HXX diff --git a/sd/source/ui/toolpanel/ToolPanelViewShell.cxx b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx new file mode 100755 index 000000000000..c62faf29ca50 --- /dev/null +++ b/sd/source/ui/toolpanel/ToolPanelViewShell.cxx @@ -0,0 +1,900 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sd.hxx" + +#include "taskpane/ToolPanelViewShell.hxx" + +#include "TaskPaneShellManager.hxx" +#include "TaskPaneFocusManager.hxx" +#include "taskpane/TaskPaneControlFactory.hxx" +#include "controls/MasterPagesPanel.hxx" +#include "LayoutMenu.hxx" +#include "DrawDocShell.hxx" +#include "controls/TableDesignPanel.hxx" +#include "controls/CustomAnimationPanel.hxx" +#include "controls/SlideTransitionPanel.hxx" +#include "controls/MasterPagesSelector.hxx" +#include "ToolPanel.hxx" +#include "ToolPanelUIElement.hxx" +#include "PaneDockingWindow.hxx" +#include "FrameView.hxx" +#include "Window.hxx" +#include "sdmod.hxx" +#include "app.hrc" +#include "glob.hrc" +#include "res_bmp.hrc" +#include "helpids.h" +#include "strings.hrc" +#include "sdresid.hxx" +#include "framework/FrameworkHelper.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/drawing/framework/XResourceId.hpp> +#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> +#include <com/sun/star/drawing/framework/AnchorBindingMode.hpp> +#include <com/sun/star/drawing/framework/ResourceActivationMode.hpp> +#include <com/sun/star/drawing/XDrawSubController.hpp> +/** === end UNO includes === **/ + +#include <svtools/toolpanel/toolpanel.hxx> +#include <svtools/toolpanel/toolpaneldeck.hxx> +#include <svx/dlgctrl.hxx> +#include <sfx2/taskpane.hxx> +#include <sfx2/imagemgr.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/msg.hxx> +#include <sfx2/objface.hxx> +#include <svx/colrctrl.hxx> +#include <svx/xtable.hxx> +#include <vcl/dockwin.hxx> +#include "sdtreelb.hxx" +#include "DrawViewShell.hxx" +#include "drawdoc.hxx" +#include "ViewShellBase.hxx" +#include <svx/ruler.hxx> +#include <vcl/svapp.hxx> +#include <vcl/toolbox.hxx> +#include <tools/diagnose_ex.h> +#include <unotools/confignode.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <vector> + +using namespace ::sd::toolpanel; + +#define ToolPanelViewShell +#include "sdslots.hxx" + +/** === begin UNO using === **/ +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::XInterface; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::uno::UNO_SET_THROW; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::makeAny; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Type; +using ::com::sun::star::accessibility::XAccessible; +using ::com::sun::star::drawing::XDrawSubController; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::drawing::framework::XResourceId; +using ::com::sun::star::drawing::framework::XConfigurationChangeListener; +using ::com::sun::star::drawing::framework::ConfigurationChangeEvent; +using ::com::sun::star::lang::EventObject; +using ::com::sun::star::lang::DisposedException; +using ::com::sun::star::drawing::framework::XConfigurationControllerBroadcaster; +using ::com::sun::star::drawing::framework::XConfigurationController; +using ::com::sun::star::drawing::framework::XConfiguration; +using ::com::sun::star::drawing::framework::AnchorBindingMode_DIRECT; +using ::com::sun::star::ui::XUIElement; +using ::com::sun::star::ui::XToolPanel; +using ::com::sun::star::drawing::framework::ResourceActivationMode_REPLACE; +/** === end UNO using === **/ + +using ::sd::framework::FrameworkHelper; + +namespace sd { namespace toolpanel { + +// ===================================================================================================================== +// = misc helper +// ===================================================================================================================== +// --------------------------------------------------------------------------------------------------------------------- +PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL, const bool i_bIgnoreUnknown ) +{ + PanelId ePanelId( PID_UNKNOWN ); + + if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msMasterPagesTaskPanelURL ) ) + { + ePanelId = PID_MASTER_PAGES; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msLayoutTaskPanelURL ) ) + { + ePanelId = PID_LAYOUT; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msTableDesignPanelURL ) ) + { + ePanelId = PID_TABLE_DESIGN; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msCustomAnimationTaskPanelURL ) ) + { + ePanelId = PID_CUSTOM_ANIMATION; + } + else if ( i_rTaskPanelResourceURL.equals( FrameworkHelper::msSlideTransitionTaskPanelURL ) ) + { + ePanelId = PID_SLIDE_TRANSITION; + } + else + { + OSL_ENSURE( i_bIgnoreUnknown, "GetStandardPanelId: cannot translate the given resource URL!" ); + (void)i_bIgnoreUnknown; + } + + return ePanelId; +} + +// --------------------------------------------------------------------------------------------------------------------- +PanelId GetStandardPanelId( const ::rtl::OUString& i_rTaskPanelResourceURL ) +{ + return GetStandardPanelId( i_rTaskPanelResourceURL, false ); +} + +// ===================================================================================================================== +// = ConfigurationListener - declaration +// ===================================================================================================================== +typedef ::cppu::WeakImplHelper1 < XConfigurationChangeListener + > ConfigurationListener_Base; + +class ConfigurationListener :public ::cppu::BaseMutex + ,public ConfigurationListener_Base +{ +public: + ConfigurationListener( ToolPanelViewShell_Impl& i_rShellImpl ); + + // XConfigurationChangeListener + virtual void SAL_CALL notifyConfigurationChange( const ConfigurationChangeEvent& aEvent ) throw (RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException); + + // XComponent equivalents (not available per UNO interface) + void dispose(); + +protected: + ~ConfigurationListener(); + + void impl_checkDisposed_throw() + { + if ( !m_pShellImpl ) + throw DisposedException( ::rtl::OUString(), *this ); + } + +private: + ToolPanelViewShell_Impl* m_pShellImpl; +}; + +// ===================================================================================================================== +// = ToolPanelViewShell_Impl - declaration +// ===================================================================================================================== +/** Inner implementation class of ToolPanelViewShell. +*/ +class ToolPanelViewShell_Impl :public ::boost::noncopyable + ,public ::svt::IToolPanelDeckListener + ,public ::sfx2::IToolPanelCompare +{ +public: + static const size_t mnInvalidId = static_cast< size_t >( -1 ); + + ToolPanelViewShell_Impl( ToolPanelViewShell& i_rPanelViewShell, ::Window& i_rPanelDeckParent ); + ~ToolPanelViewShell_Impl(); + + ToolPanelViewShell& GetAntiImpl() { return m_rPanelViewShell; } + + /** Here the panels are created that are shown in the task pane. + */ + void Setup(); + + /** clean up the instance + */ + void Cleanup(); + + /** activates the panel which has the given resource URL + */ + void ActivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ); + + /** de-activates the panel given by its resource URL, bypassing the configuration controller + + If the panel is not active currently, nothing happens. + */ + void DeactivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ); + + /** provides access to the the VCL window of the panel deck + */ + ::sfx2::ModuleTaskPane& GetTaskPane() { return *m_pTaskPane; } + const ::sfx2::ModuleTaskPane& GetTaskPane() const { return *m_pTaskPane; } + + ::svt::ToolPanelDeck& GetToolPanelDeck() { return GetTaskPane().GetPanelDeck(); } + const ::svt::ToolPanelDeck& GetToolPanelDeck() const { return GetTaskPane().GetPanelDeck(); } + + Reference< XAccessible > + CreateAccessible( ::sd::Window& i_rWindow ); + + void ConnectToDockingWindow(); + +private: + // IToolPanelDeckListener overridables + virtual void PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ); + virtual void PanelRemoved( const size_t i_nPosition ); + virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); + virtual void LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ); + virtual void Dying(); + + // IToolPanelCompare overridables + virtual short compareToolPanelsURLs( const ::rtl::OUString& i_rLHS, const ::rtl::OUString& i_rRHS ) const; + +private: + struct InitialPanel + { + ::rtl::OUString sPanelResourceURL; + bool bActivateDirectly; + InitialPanel() + :sPanelResourceURL() + ,bActivateDirectly( true ) + { + } + }; + InitialPanel impl_determineInitialPanel(); + ::rtl::OUString impl_getPanelURL( const ::boost::optional< size_t >& i_rPanel ); + +private: + ToolPanelViewShell& m_rPanelViewShell; + ::boost::scoped_ptr< ::sfx2::ModuleTaskPane > m_pTaskPane; + ::std::auto_ptr< ::sfx2::TaskPaneController > m_pTaskPaneController; + ::rtl::Reference< ConfigurationListener > m_pConfigListener; + bool m_bInitialized; +}; + +// ===================================================================================================================== +// = ConfigurationListener - implementation +// ===================================================================================================================== +// --------------------------------------------------------------------------------------------------------------------- +ConfigurationListener::ConfigurationListener( ToolPanelViewShell_Impl& i_rShellImpl ) + :m_pShellImpl( &i_rShellImpl ) +{ + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( i_rShellImpl.GetAntiImpl().GetViewShellBase() ) ); + Reference< XConfigurationControllerBroadcaster > xBroadcaster; + if ( pFrameworkHelper.get() ) + xBroadcaster.set( pFrameworkHelper->GetConfigurationController().get() ); + ENSURE_OR_THROW( pFrameworkHelper.get(), "no access to the config controller" ); + + osl_incrementInterlockedCount( &m_refCount ); + { + xBroadcaster->addConfigurationChangeListener( this, ::rtl::OUString(), Any() ); + } + osl_decrementInterlockedCount( &m_refCount ); +} + +// --------------------------------------------------------------------------------------------------------------------- +ConfigurationListener::~ConfigurationListener() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ConfigurationListener::notifyConfigurationChange( const ConfigurationChangeEvent& i_rEvent ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + // is this an event we're interested in? + if ( i_rEvent.Type != FrameworkHelper::msResourceActivationEvent ) + return; + + // is this a resource we're interested in? Must be anchored in the task pane ... + Reference< XResourceId > xAnchorId; + if ( i_rEvent.ResourceId.is() ) + xAnchorId = i_rEvent.ResourceId->getAnchor(); + if ( !xAnchorId.is() ) + return; + const ::rtl::OUString sAnchorURL( xAnchorId->getResourceURL() ); + if ( sAnchorURL != FrameworkHelper::msTaskPaneURL ) + return; + + m_pShellImpl->ActivatePanelByResource( i_rEvent.ResourceId->getResourceURL() ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ConfigurationListener::disposing( const EventObject& i_rEvent ) throw (RuntimeException) +{ + (void)i_rEvent; + { + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + } + + dispose(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ConfigurationListener::dispose() +{ + ::osl::MutexGuard aGuard( m_aMutex ); + m_pShellImpl = NULL; +} + +// ===================================================================================================================== +// = ToolPanelViewShell +// ===================================================================================================================== +// --------------------------------------------------------------------------------------------------------------------- +SFX_IMPL_INTERFACE(ToolPanelViewShell, SfxShell, SdResId(STR_TASKPANEVIEWSHELL)) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +TYPEINIT1(ToolPanelViewShell, ViewShell); + +// --------------------------------------------------------------------------------------------------------------------- +ToolPanelViewShell_Impl::InitialPanel ToolPanelViewShell_Impl::impl_determineInitialPanel() +{ + InitialPanel aPanelToActivate; + if ( GetAntiImpl().GetViewShellBase().GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_DRAW ) + // for Draw, rely on SFX's default handling, which is to activate the previously active panel + return aPanelToActivate; + + // Default to Layout panel, but check whether the requested configuration already contains a tool panel, in this case, + // use that one. + aPanelToActivate.sPanelResourceURL = FrameworkHelper::msLayoutTaskPanelURL; + aPanelToActivate.bActivateDirectly = false; + try + { + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( m_rPanelViewShell.GetViewShellBase() ) ); + const Reference< XResourceId > xToolPanelId( pFrameworkHelper->CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ) ); + Reference< XConfigurationController > xCC( pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); + Reference< XConfiguration > xConfiguration( xCC->getRequestedConfiguration(), UNO_QUERY_THROW ); + Sequence< Reference< XResourceId > > aViewIds( xConfiguration->getResources( + FrameworkHelper::CreateResourceId( FrameworkHelper::msTaskPaneURL, FrameworkHelper::msRightPaneURL ), + FrameworkHelper::msTaskPanelURLPrefix, AnchorBindingMode_DIRECT ) ); + + if ( aViewIds.getLength() > 0 ) + { + const ::rtl::OUString sResourceURL( aViewIds[0]->getResourceURL() ); + PanelId nRequestedPanel = GetStandardPanelId( sResourceURL ); + if ( nRequestedPanel != PID_UNKNOWN ) + { + aPanelToActivate.sPanelResourceURL = sResourceURL; + aPanelToActivate.bActivateDirectly = true; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aPanelToActivate; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::Setup() +{ + if ( m_bInitialized ) + return; + m_bInitialized = true; + + // initially activate a panel + const InitialPanel aInitialPanel = impl_determineInitialPanel(); + if ( aInitialPanel.sPanelResourceURL.getLength() ) + { + if ( aInitialPanel.bActivateDirectly ) + { + ActivatePanelByResource( aInitialPanel.sPanelResourceURL ); + } + else + { + ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( GetAntiImpl().GetViewShellBase() ) ); + pFrameworkHelper->RequestTaskPanel( aInitialPanel.sPanelResourceURL ); + } + } + + // listen at the configuration + m_pConfigListener.set( new ConfigurationListener( *this ) ); + + m_pTaskPane->Show(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::Cleanup() +{ + if ( m_bInitialized ) + { + if ( m_pConfigListener.is() ) + m_pConfigListener->dispose(); + } + GetToolPanelDeck().RemoveListener( *this ); + m_pTaskPaneController.reset(); + m_pTaskPane.reset(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::ActivatePanelByResource( const ::rtl::OUString& i_rResourceURL ) +{ + // determine position of the requested panel + ::boost::optional< size_t > aPanelPos = GetTaskPane().GetPanelPos( i_rResourceURL ); + OSL_ENSURE( !!aPanelPos, "ToolPanelViewShell_Impl::ActivatePanelByResource: illegal panel resource, or illegal panel deck setup!" ); + if ( !!aPanelPos ) + GetToolPanelDeck().ActivatePanel( *aPanelPos ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::DeactivatePanelByResource( const ::rtl::OUString& i_rPanelResourceURL ) +{ + // determine position of the requested panel + ::boost::optional< size_t > aPanelPos = GetTaskPane().GetPanelPos( i_rPanelResourceURL ); + OSL_ENSURE( !!aPanelPos, "ToolPanelViewShell_Impl::DeactivatePanelByResource: illegal panel resource, or illegal panel deck setup!" ); + if ( !!aPanelPos ) + { + if ( GetToolPanelDeck().GetActivePanel() == *aPanelPos ) + GetToolPanelDeck().ActivatePanel( ::boost::optional< size_t >() ); + } +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::Initialize() +{ + mpImpl->Setup(); +} + +// --------------------------------------------------------------------------------------------------------------------- +ToolPanelViewShell::ToolPanelViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, + FrameView* pFrameViewArgument ) + :ViewShell(pFrame, pParentWindow, rViewShellBase) + ,mpImpl( new ToolPanelViewShell_Impl( *this, *mpContentWindow.get() ) ) + ,mpSubShellManager() + ,mnMenuId(0) +{ + meShellType = ST_TASK_PANE; + + mpContentWindow->SetCenterAllowed( false ); + pParentWindow->SetStyle( pParentWindow->GetStyle() | WB_DIALOGCONTROL ); + + GetParentWindow()->SetBackground( Wallpaper() ); + mpContentWindow->SetBackground( Wallpaper() ); + + GetParentWindow()->SetHelpId(HID_SD_TASK_PANE); + + mpImpl->ConnectToDockingWindow(); + + SetPool( &GetDoc()->GetPool() ); + + if ( pFrameViewArgument ) + mpFrameView = pFrameViewArgument; + else + mpFrameView = new FrameView( GetDoc() ); + GetFrameView()->Connect(); + + // Hide or delete unused controls that we have inherited from the + // ViewShell base class. + mpHorizontalScrollBar.reset(); + mpVerticalScrollBar.reset(); + mpScrollBarBox.reset(); + mpHorizontalRuler.reset(); + mpVerticalRuler.reset(); + + SetName( String( RTL_CONSTASCII_USTRINGPARAM( "ToolPanelViewShell" ) ) ); + + // For accessibility we have to shortly hide the content window. This + // triggers the construction of a new accessibility object for the new + // view shell. (One is created earlier while the construtor of the base + // class is executed. At that time the correct accessibility object can + // not be constructed.) + if ( mpContentWindow.get() ) + { + mpContentWindow->Hide(); + mpContentWindow->Show(); + } + + // Register the shell manager as factory at the ViewShellManager. + mpSubShellManager.reset( new TaskPaneShellManager( + GetViewShellBase().GetViewShellManager(), + *this + ) ); + GetViewShellBase().GetViewShellManager()->AddSubShellFactory( this, mpSubShellManager ); +} + +// --------------------------------------------------------------------------------------------------------------------- +ToolPanelViewShell::~ToolPanelViewShell() +{ + mpImpl->Cleanup(); + + // reset our impl before destroying the panel deck, to ensure the hidden panels are properly + // disposed/destroyed, too + mpImpl.reset(); + GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(this, mpSubShellManager); +} + +// --------------------------------------------------------------------------------------------------------------------- +// static +void ToolPanelViewShell::RegisterControls() +{ + SfxModule* pModule = SD_MOD(); + controls::MasterPagesSelector::RegisterInterface( pModule ); + LayoutMenu::RegisterInterface( pModule ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::ArrangeGUIElements() +{ + ViewShell::ArrangeGUIElements(); + + Initialize(); + + mpImpl->GetTaskPane().SetPosSizePixel( Point(), maViewSize ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::GetFocus() +{ + Invalidate(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::LoseFocus() +{ + Invalidate(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::KeyInput( const KeyEvent& i_rKeyEvent ) +{ + const KeyCode nCode = i_rKeyEvent.GetKeyCode(); + if ( nCode == KEY_RETURN ) + { + if ( !mpImpl->GetTaskPane().HasChildPathFocus() ) + mpImpl->GetTaskPane().GrabFocus(); + } + else + ViewShell::KeyInput( i_rKeyEvent, NULL ); +} + +// --------------------------------------------------------------------------------------------------------------------- +SdPage* ToolPanelViewShell::GetActualPage() +{ + return NULL; +} + +// --------------------------------------------------------------------------------------------------------------------- +SdPage* ToolPanelViewShell::getCurrentPage() const +{ + return NULL; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::Execute( SfxRequest& ) +{ + OSL_ENSURE( false, "ToolPanelViewShell::Execute: not to be called! (right?)" ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::GetState( SfxItemSet& ) +{ + OSL_ENSURE( false, "ToolPanelViewShell::GetState: not to be called! (right?)" ); +} + +// --------------------------------------------------------------------------------------------------------------------- +TaskPaneShellManager& ToolPanelViewShell::GetSubShellManager() const +{ + return *mpSubShellManager.get(); +} + +// --------------------------------------------------------------------------------------------------------------------- +DockingWindow* ToolPanelViewShell::GetDockingWindow() +{ + ::Window* pParentWindow = GetParentWindow(); + DockingWindow* pDockingWindow = NULL; + while (pParentWindow!=NULL && pDockingWindow==NULL) + { + pDockingWindow = dynamic_cast<DockingWindow*>(pParentWindow); + pParentWindow = pParentWindow->GetParent(); + } + return pDockingWindow; +} + +// --------------------------------------------------------------------------------------------------------------------- +Reference< XAccessible > ToolPanelViewShell::CreateAccessibleDocumentView( ::sd::Window* i_pWindow ) +{ + ENSURE_OR_RETURN( i_pWindow, "ToolPanelViewShell::CreateAccessibleDocumentView: illegal window!", NULL ); + return mpImpl->CreateAccessible( *i_pWindow ); +} + +// --------------------------------------------------------------------------------------------------------------------- +Reference< XDrawSubController > ToolPanelViewShell::CreateSubController() +{ + // This view shell is not designed to be the main view shell and thus + // does not support a UNO sub controller. + return Reference< XDrawSubController >(); +} + +// --------------------------------------------------------------------------------------------------------------------- +bool ToolPanelViewShell::RelocateToParentWindow( ::Window* pParentWindow ) +{ + ::Window* pOldParentWindow = GetParentWindow(); + FocusManager::Instance().RemoveLinks( pOldParentWindow, &mpImpl->GetTaskPane() ); + FocusManager::Instance().RemoveLinks( &mpImpl->GetTaskPane(), pOldParentWindow ); + + PaneDockingWindow* pDockingWindow = dynamic_cast< PaneDockingWindow* >( GetDockingWindow() ); + if ( pDockingWindow != NULL ) + { + pDockingWindow->SetEndDockingHdl( Link() ); + } + + ViewShell::RelocateToParentWindow(pParentWindow); + + mpImpl->ConnectToDockingWindow(); + + Resize(); + + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool ToolPanelViewShell::IsPanelAnchorWindow( const ::Window& i_rWindow ) const +{ + return &mpImpl->GetToolPanelDeck().GetPanelWindowAnchor() == &i_rWindow; +} + +//--------------------------------------------------------------------------------------------------------------------- +namespace +{ + typedef std::auto_ptr< ControlFactory > (*ControlFactoryFactory)( ToolPanelViewShell& i_rToolPanelShell ); + + struct PanelFactory + { + ControlFactoryFactory pFactory; + ULONG nHelpID; + PanelFactory( const ControlFactoryFactory i_pFactory, const ULONG i_nHelpID ) + :pFactory( i_pFactory ) + ,nHelpID( i_nHelpID ) + { + } + }; + + const PanelFactory lcl_describePanel( const PanelId i_ePanelId ) + { + switch ( i_ePanelId ) + { + case PID_MASTER_PAGES: + return PanelFactory( &controls::MasterPagesPanel::CreateControlFactory, HID_SD_SLIDE_DESIGNS ); + case PID_LAYOUT: + return PanelFactory( &LayoutMenu::CreateControlFactory, HID_SD_SLIDE_LAYOUTS ); + case PID_TABLE_DESIGN: + return PanelFactory( &controls::TableDesignPanel::CreateControlFactory, HID_SD_TABLE_DESIGN ); + case PID_CUSTOM_ANIMATION: + return PanelFactory( &controls::CustomAnimationPanel::CreateControlFactory, HID_SD_CUSTOM_ANIMATIONS ); + case PID_SLIDE_TRANSITION: + return PanelFactory( &controls::SlideTransitionPanel::CreateControlFactory, HID_SD_SLIDE_TRANSITIONS ); + default: + break; + } + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "illegal panel ID" ) ), NULL ); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +Reference< XUIElement > ToolPanelViewShell::CreatePanelUIElement( const Reference< XFrame >& i_rDocFrame, const ::rtl::OUString& i_rPanelResourceURL ) +{ + const PanelId ePanelId( GetStandardPanelId( i_rPanelResourceURL ) ); + ENSURE_OR_RETURN( ePanelId != PID_UNKNOWN, "ToolPanelViewShell::CreatePanelUIElement: illegal panel URL!", NULL ); + + // a TreeNode which will resemble the panel + const PanelFactory aPanelFactory( lcl_describePanel( ePanelId ) ); + ::std::auto_ptr< ControlFactory > pControlFactory( (*aPanelFactory.pFactory)( *this ) ); + ::std::auto_ptr< TreeNode > pNode( pControlFactory->CreateControl( mpImpl->GetToolPanelDeck().GetPanelWindowAnchor() ) ); + ENSURE_OR_THROW( ( pNode.get() != NULL ) && ( pNode->GetWindow() != NULL ), + "illegal node returned by the control factory" ); + pNode->GetWindow()->SetHelpId( aPanelFactory.nHelpID ); + + // create an XToolPanel + Reference< XToolPanel > xPanel( new ToolPanel( pNode ) ); + + // create an XUIElement providing this panel + const Reference< XUIElement > xUIElement( new ToolPanelUIElement( i_rDocFrame, i_rPanelResourceURL, xPanel ) ); + + return xUIElement; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::ActivatePanel( const ::rtl::OUString& i_rPanelResourceURL ) +{ + OSL_ENSURE( i_rPanelResourceURL.indexOf( FrameworkHelper::msTaskPanelURLPrefix ) < 0, + "ToolPanelViewShell::ActivatePanel: for drawing-framework-controller panels, please use FrameworkHelper::RequestTaskPanel!" ); + mpImpl->ActivatePanelByResource( i_rPanelResourceURL ); +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell::DeactivatePanel( const ::rtl::OUString& i_rPanelResourceURL ) +{ + mpImpl->DeactivatePanelByResource( i_rPanelResourceURL ); +} + +// ===================================================================================================================== +// = ToolPanelViewShell_Impl - implementation +// ===================================================================================================================== +// --------------------------------------------------------------------------------------------------------------------- +ToolPanelViewShell_Impl::ToolPanelViewShell_Impl( ToolPanelViewShell& i_rPanelViewShell, ::Window& i_rPanelDeckParent ) + :m_rPanelViewShell( i_rPanelViewShell ) + ,m_pTaskPane( new ::sfx2::ModuleTaskPane( i_rPanelDeckParent, i_rPanelViewShell.GetViewShellBase().GetViewFrame()->GetFrame().GetFrameInterface(), *this ) ) + ,m_bInitialized( false ) +{ + const String sPaneTitle( SdResId( STR_RIGHT_PANE_TITLE ) ); + GetToolPanelDeck().SetAccessibleName( sPaneTitle ); + GetToolPanelDeck().SetAccessibleDescription( sPaneTitle ); + + GetToolPanelDeck().AddListener( *this ); +} + +// --------------------------------------------------------------------------------------------------------------------- +ToolPanelViewShell_Impl::~ToolPanelViewShell_Impl() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition ) +{ + // not interested in + (void)i_pPanel; + (void)i_nPosition; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::PanelRemoved( const size_t i_nPosition ) +{ + // not interested in + (void)i_nPosition; +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString ToolPanelViewShell_Impl::impl_getPanelURL( const ::boost::optional< size_t >& i_rPanel ) +{ + ::rtl::OUString sPanelURL; + if ( !!i_rPanel ) + { + sPanelURL = GetTaskPane().GetPanelResourceURL( *i_rPanel ); + const PanelId ePanelId( GetStandardPanelId( sPanelURL, true ) ); + if ( ePanelId == PID_UNKNOWN ) + sPanelURL = ::rtl::OUString(); + } + return sPanelURL; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) +{ + // update the configuration controller, since this change in the active panel might have been triggered by means other + // than the drawing framework, so it does not yet know about it. + + const ::rtl::OUString sOldPanelURL( impl_getPanelURL( i_rOldActive ) ); + const ::rtl::OUString sNewPanelURL( impl_getPanelURL( i_rNewActive ) ); + + const ::boost::shared_ptr< FrameworkHelper > pFrameworkHelper( FrameworkHelper::Instance( GetAntiImpl().GetViewShellBase() ) ); + if ( sNewPanelURL.getLength() ) + { + // activate the resource belonging to the new panel. This will automatically de-activate the previously active + // panel resource (since ResourceActivationMode_REPLACE is used) + pFrameworkHelper->RequestTaskPanel( sNewPanelURL ); + } + else if ( sOldPanelURL.getLength() ) + { + // there is no new active panel, or it is not one of our standard panels, i.e. it is not covered by the + // resource framework. => Deactivate the old resource. + try + { + Reference< XConfigurationController > xConfigController( pFrameworkHelper->GetConfigurationController(), UNO_QUERY_THROW ); + xConfigController->requestResourceDeactivation( + pFrameworkHelper->CreateResourceId( + sOldPanelURL, + FrameworkHelper::msTaskPaneURL, + FrameworkHelper::msRightPaneURL + ) + ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter ) +{ + // not interested in + (void)i_rNewLayouter; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::Dying() +{ + // not interested in +} + +// --------------------------------------------------------------------------------------------------------------------- +short ToolPanelViewShell_Impl::compareToolPanelsURLs( const ::rtl::OUString& i_rLHS, const ::rtl::OUString& i_rRHS ) const +{ + const PanelId eLHS( GetStandardPanelId( i_rLHS, true ) ); + const PanelId eRHS( GetStandardPanelId( i_rRHS, true ) ); + if ( eLHS < eRHS ) + return -1; + if ( eLHS == eRHS ) + return 0; + return 1; +} + +// --------------------------------------------------------------------------------------------------------------------- +void ToolPanelViewShell_Impl::ConnectToDockingWindow() +{ + m_pTaskPaneController.reset(); + DockingWindow* pDockingWindow( GetAntiImpl().GetDockingWindow() ); + if ( pDockingWindow ) + { + PaneDockingWindow* pPaneDockingWindow = dynamic_cast< PaneDockingWindow* >( pDockingWindow ); + OSL_ENSURE( pPaneDockingWindow, "ToolPanelViewShell_Impl::ConnectToDockingWindow: unsupported docking window type!" ); + if ( pPaneDockingWindow != NULL ) + m_pTaskPaneController.reset( new ::sfx2::TaskPaneController( GetTaskPane(), *pPaneDockingWindow ) ); + } + + // Tell the focus manager that we want to pass the focus to our + // child. + FocusManager::Instance().RegisterDownLink( GetAntiImpl().GetParentWindow(), &GetTaskPane() ); +} + +// --------------------------------------------------------------------------------------------------------------------- +Reference< XAccessible > ToolPanelViewShell_Impl::CreateAccessible( ::sd::Window& i_rWindow ) +{ + Reference< XAccessible > xAccessible( GetToolPanelDeck().GetAccessible( FALSE ) ); + if ( !xAccessible.is() ) + { + // determine the XAccessible which is the parent of the to-be-created object + ::Window* pAccessibleParent = i_rWindow.GetAccessibleParentWindow(); + OSL_ENSURE( pAccessibleParent, "ToolPanelViewShell_Impl::CreateAccessible: illegal accessible parent provided by the sd::Window!" ); + GetToolPanelDeck().SetAccessibleParentWindow( pAccessibleParent ); + + xAccessible = GetToolPanelDeck().GetAccessible( TRUE ); + ENSURE_OR_RETURN( xAccessible.is(), "ToolPanelViewShell_Impl::CreateAccessible: illegal ToolPanelDeck accessible!", NULL ); + OSL_ENSURE( xAccessible->getAccessibleContext().is() + && xAccessible->getAccessibleContext()->getAccessibleParent() == pAccessibleParent->GetAccessible(), + "ToolPanelViewShell_Impl::CreateAccessible: illegal parenthood!" ); + } + return xAccessible; +} + +} } // end of namespace ::sd::toolpanel diff --git a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx index 9767efe87c48..e7edf109cffd 100644..100755 --- a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx +++ b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.cxx @@ -31,6 +31,7 @@ #include "CustomAnimationPanel.hxx" #include "taskpane/TaskPaneControlFactory.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "strings.hrc" #include "sdresid.hxx" @@ -44,10 +45,11 @@ namespace sd namespace toolpanel { namespace controls { -CustomAnimationPanel::CustomAnimationPanel(TreeNode* pParent, ViewShellBase& rBase) - : SubToolPanel (pParent) +CustomAnimationPanel::CustomAnimationPanel(Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell) + :SubToolPanel( i_rParentWindow ) + ,m_pPanelViewShell( &i_rPanelViewShell ) { - mpWrappedControl = createCustomAnimationPanel( pParent->GetWindow(), rBase ); + mpWrappedControl = createCustomAnimationPanel( &i_rParentWindow, i_rPanelViewShell.GetViewShellBase() ); mpWrappedControl->Show(); } @@ -56,10 +58,17 @@ CustomAnimationPanel::~CustomAnimationPanel() delete mpWrappedControl; } -std::auto_ptr<ControlFactory> CustomAnimationPanel::CreateControlFactory (ViewShellBase& rBase) +std::auto_ptr< ControlFactory > CustomAnimationPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) { - return std::auto_ptr<ControlFactory>( - new ControlFactoryWithArgs1<CustomAnimationPanel,ViewShellBase>(rBase)); + return std::auto_ptr< ControlFactory >( + new RootControlFactoryWithArg< CustomAnimationPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); +} + +TaskPaneShellManager* CustomAnimationPanel::GetShellManager() +{ + if ( m_pPanelViewShell ) + return &m_pPanelViewShell->GetSubShellManager(); + return SubToolPanel::GetShellManager(); } Size CustomAnimationPanel::GetPreferredSize() diff --git a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx index 734965e5264b..864ba637b94d 100644..100755 --- a/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx +++ b/sd/source/ui/toolpanel/controls/CustomAnimationPanel.hxx @@ -37,6 +37,7 @@ class ViewShellBase; namespace sd { namespace toolpanel { class TreeNode; class ControlFactory; +class ToolPanelViewShell; } } namespace sd { namespace toolpanel { namespace controls { @@ -46,12 +47,16 @@ class CustomAnimationPanel { public: CustomAnimationPanel ( - TreeNode* pParent, - ViewShellBase& rBase); + Window& i_rParentWindow, + ToolPanelViewShell& i_rPanelViewShell); virtual ~CustomAnimationPanel (void); - static std::auto_ptr<ControlFactory> CreateControlFactory (ViewShellBase& rBase); + static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rPanelViewShell); + // TreeNode overridables + virtual TaskPaneShellManager* GetShellManager(); + + // ILayoutableWindow overridables virtual Size GetPreferredSize (void); virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); @@ -68,6 +73,7 @@ public: private: Size maPreferredSize; ::Window* mpWrappedControl; + ToolPanelViewShell* m_pPanelViewShell; }; } } } // end of namespace ::sd::toolpanel::controls diff --git a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx index 2e121098194a..b9040e72283f 100644..100755 --- a/sd/source/ui/toolpanel/controls/DocumentHelper.cxx +++ b/sd/source/ui/toolpanel/controls/DocumentHelper.cxx @@ -44,6 +44,8 @@ #include <com/sun/star/container/XIndexAccess.hpp> #include "stlpool.hxx" #include <svx/xfillit0.hxx> +#include <tools/diagnose_ex.h> + using namespace ::com::sun::star; namespace sd { namespace toolpanel { namespace controls { @@ -245,9 +247,7 @@ SdPage* DocumentHelper::AddMasterPage ( catch (uno::Exception& rException) { pClonedMasterPage = NULL; - OSL_TRACE("caught exception while adding master page: %s", - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); + DBG_UNHANDLED_EXCEPTION(); } catch (::std::exception rException) { diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx index 6b9ff09bbed3..9a5eefb6d925 100644..100755 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx +++ b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx @@ -40,6 +40,7 @@ #include <vcl/image.hxx> #include <vcl/pngread.hxx> #include <com/sun/star/embed/ElementModes.hpp> +#include <tools/diagnose_ex.h> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -291,7 +292,7 @@ SdPage* TemplatePageObjectProvider::operator() (SdDrawDocument* pContainerDocume } catch (uno::RuntimeException) { - OSL_TRACE ("caught exception while loading page from template file"); + DBG_UNHANDLED_EXCEPTION(); pPage = NULL; } diff --git a/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx b/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx index b897e1514862..8dab51e93a58 100644..100755 --- a/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx +++ b/sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx @@ -33,6 +33,7 @@ #include "CurrentMasterPagesSelector.hxx" #include "RecentMasterPagesSelector.hxx" #include "AllMasterPagesSelector.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "taskpane/TaskPaneControlFactory.hxx" #include "taskpane/TitledControl.hxx" #include "../TaskPaneShellManager.hxx" @@ -48,8 +49,14 @@ namespace sd { namespace toolpanel { namespace controls { -MasterPagesPanel::MasterPagesPanel (TreeNode* pParent, ViewShellBase& rBase) - : ScrollPanel (pParent) +MasterPagesPanel::MasterPagesPanel (::Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell) + :ScrollPanel (i_rParentWindow) + ,m_pPanelViewShell( &i_rPanelViewShell ) +{ + impl_construct( m_pPanelViewShell->GetViewShellBase() ); +} + +void MasterPagesPanel::impl_construct( ViewShellBase& rBase ) { SdDrawDocument* pDocument = rBase.GetDocument(); ::std::auto_ptr<controls::MasterPagesSelector> pSelector; @@ -118,18 +125,33 @@ MasterPagesPanel::MasterPagesPanel (TreeNode* pParent, ViewShellBase& rBase) MasterPagesPanel::~MasterPagesPanel (void) { + TaskPaneShellManager* pShellManager( GetShellManager() ); + OSL_ENSURE( pShellManager, "MasterPagesPanel::~MasterPagesPanel: no shell manager anymore - cannot remove sub shells!" ); + if ( pShellManager ) + { + pShellManager->RemoveSubShell( HID_SD_TASK_PANE_PREVIEW_CURRENT ); + pShellManager->RemoveSubShell( HID_SD_TASK_PANE_PREVIEW_RECENT ); + pShellManager->RemoveSubShell( HID_SD_TASK_PANE_PREVIEW_ALL ); + } } -std::auto_ptr<ControlFactory> MasterPagesPanel::CreateControlFactory (ViewShellBase& rBase) +TaskPaneShellManager* MasterPagesPanel::GetShellManager() { - return std::auto_ptr<ControlFactory>( - new ControlFactoryWithArgs1<MasterPagesPanel,ViewShellBase>(rBase)); + if ( m_pPanelViewShell ) + return &m_pPanelViewShell->GetSubShellManager(); + return TreeNode::GetShellManager(); } +std::auto_ptr< ControlFactory > MasterPagesPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) +{ + return std::auto_ptr< ControlFactory >( + new RootControlFactoryWithArg< MasterPagesPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); +} + } } } // end of namespace ::sd::toolpanel::controls diff --git a/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx b/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx index 1c6d75ea8dcb..932007802ebf 100644..100755 --- a/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx +++ b/sd/source/ui/toolpanel/controls/MasterPagesPanel.hxx @@ -37,6 +37,7 @@ class ViewShellBase; namespace sd { namespace toolpanel { class ControlFactory; class TreeNode; +class ToolPanelViewShell; } } namespace sd { namespace toolpanel { namespace controls { @@ -50,11 +51,20 @@ class MasterPagesPanel { public: MasterPagesPanel ( - TreeNode* pParent, - ViewShellBase& rBase); + ::Window& i_rParentWindow, + ToolPanelViewShell& i_rPanelViewShell); virtual ~MasterPagesPanel (void); - static std::auto_ptr<ControlFactory> CreateControlFactory (ViewShellBase& rBase); + // TreeNode overridables + virtual TaskPaneShellManager* GetShellManager (void); + + static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); + +private: + void impl_construct( ViewShellBase& rBase ); + +private: + ToolPanelViewShell* m_pPanelViewShell; }; } } } // end of namespace ::sd::toolpanel::controls diff --git a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx index 2cb0f58a029b..4ad67b876983 100644..100755 --- a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx +++ b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.cxx @@ -30,6 +30,7 @@ #include "SlideTransitionPanel.hxx" #include "taskpane/TaskPaneControlFactory.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "strings.hrc" #include "sdresid.hxx" @@ -45,11 +46,12 @@ namespace toolpanel { namespace controls { -SlideTransitionPanel::SlideTransitionPanel(TreeNode* pParent, ViewShellBase& rBase) - : SubToolPanel (pParent), - maPreferredSize( 100, 200 ) +SlideTransitionPanel::SlideTransitionPanel(Window& i_rParentWindow, ToolPanelViewShell& i_rToolPanelShell) + :SubToolPanel( i_rParentWindow ) + ,maPreferredSize( 100, 200 ) + ,m_pPanelViewShell( &i_rToolPanelShell ) { - mpWrappedControl = createSlideTransitionPanel( pParent->GetWindow(), rBase ); + mpWrappedControl = createSlideTransitionPanel( &i_rParentWindow, i_rToolPanelShell.GetViewShellBase() ); mpWrappedControl->Show(); } @@ -58,10 +60,17 @@ SlideTransitionPanel::~SlideTransitionPanel() delete mpWrappedControl; } -std::auto_ptr<ControlFactory> SlideTransitionPanel::CreateControlFactory (ViewShellBase& rBase) +std::auto_ptr< ControlFactory > SlideTransitionPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) { - return std::auto_ptr<ControlFactory>( - new ControlFactoryWithArgs1<SlideTransitionPanel,ViewShellBase>(rBase)); + return std::auto_ptr< ControlFactory >( + new RootControlFactoryWithArg< SlideTransitionPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); +} + +TaskPaneShellManager* SlideTransitionPanel::GetShellManager() +{ + if ( m_pPanelViewShell ) + return &m_pPanelViewShell->GetSubShellManager(); + return SubToolPanel::GetShellManager(); } Size SlideTransitionPanel::GetPreferredSize() diff --git a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx index 478f69091f63..f62cb918806b 100644..100755 --- a/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx +++ b/sd/source/ui/toolpanel/controls/SlideTransitionPanel.hxx @@ -36,6 +36,7 @@ class ViewShellBase; namespace sd { namespace toolpanel { class ControlFactory; class TreeNode; +class ToolPanelViewShell; } } namespace sd { namespace toolpanel { namespace controls { @@ -45,12 +46,16 @@ class SlideTransitionPanel { public: SlideTransitionPanel ( - TreeNode* pParent, - ViewShellBase& rBase); + Window& i_rParentWindow, + ToolPanelViewShell& i_rToolPanelShell); virtual ~SlideTransitionPanel (void); - static std::auto_ptr<ControlFactory> CreateControlFactory (ViewShellBase& rBase); + static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); + // TreeNode overridables + virtual TaskPaneShellManager* GetShellManager(); + + // ILayoutableWindow overridables virtual Size GetPreferredSize (void); virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); @@ -68,6 +73,7 @@ public: private: Size maPreferredSize; ::Window* mpWrappedControl; + ToolPanelViewShell* m_pPanelViewShell; }; } } } // end of namespace ::sd::toolpanel::controls diff --git a/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx b/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx index ce242d557ee7..d6507a25c11f 100644..100755 --- a/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx +++ b/sd/source/ui/toolpanel/controls/TableDesignPanel.cxx @@ -31,6 +31,7 @@ #include "TableDesignPanel.hxx" #include "taskpane/TaskPaneControlFactory.hxx" +#include "taskpane/ToolPanelViewShell.hxx" #include "strings.hrc" #include "sdresid.hxx" @@ -44,10 +45,11 @@ namespace sd namespace toolpanel { namespace controls { -TableDesignPanel::TableDesignPanel(TreeNode* pParent, ViewShellBase& rBase) - : SubToolPanel (pParent) +TableDesignPanel::TableDesignPanel( ::Window& i_rParentWindow, ToolPanelViewShell& i_rPanelViewShell ) + :SubToolPanel( i_rParentWindow ) + ,m_pPanelViewShell( &i_rPanelViewShell ) { - mpWrappedControl = createTableDesignPanel( pParent->GetWindow(), rBase ); + mpWrappedControl = createTableDesignPanel( &i_rParentWindow, i_rPanelViewShell.GetViewShellBase() ); mpWrappedControl->Show(); } @@ -56,10 +58,17 @@ TableDesignPanel::~TableDesignPanel() delete mpWrappedControl; } -std::auto_ptr<ControlFactory> TableDesignPanel::CreateControlFactory (ViewShellBase& rBase) +std::auto_ptr< ControlFactory > TableDesignPanel::CreateControlFactory( ToolPanelViewShell& i_rToolPanelShell ) { - return std::auto_ptr<ControlFactory>( - new ControlFactoryWithArgs1<TableDesignPanel,ViewShellBase>(rBase)); + return std::auto_ptr< ControlFactory >( + new RootControlFactoryWithArg< TableDesignPanel, ToolPanelViewShell >( i_rToolPanelShell ) ); +} + +TaskPaneShellManager* TableDesignPanel::GetShellManager() +{ + if ( m_pPanelViewShell ) + return &m_pPanelViewShell->GetSubShellManager(); + return SubToolPanel::GetShellManager(); } Size TableDesignPanel::GetPreferredSize() diff --git a/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx b/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx index aae06e37ad14..a3620df2ef68 100644..100755 --- a/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx +++ b/sd/source/ui/toolpanel/controls/TableDesignPanel.hxx @@ -37,6 +37,7 @@ class ViewShellBase; namespace sd { namespace toolpanel { class TreeNode; class ControlFactory; +class ToolPanelViewShell; } } namespace sd { namespace toolpanel { namespace controls { @@ -46,12 +47,16 @@ class TableDesignPanel { public: TableDesignPanel ( - TreeNode* pParent, - ViewShellBase& rBase); + ::Window& i_rParentWindow, + ToolPanelViewShell& i_rPanelViewShell); virtual ~TableDesignPanel (void); - static std::auto_ptr<ControlFactory> CreateControlFactory (ViewShellBase& rBase); + static std::auto_ptr<ControlFactory> CreateControlFactory (ToolPanelViewShell& i_rToolPanelShell); + // TreeNode overridables + virtual TaskPaneShellManager* GetShellManager(); + + // ILayoutableWindow overridables virtual Size GetPreferredSize (void); virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeigh); virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth); @@ -68,6 +73,7 @@ public: private: Size maPreferredSize; ::Window* mpWrappedControl; + ToolPanelViewShell* m_pPanelViewShell; }; } } } // end of namespace ::sd::toolpanel::controls diff --git a/sd/source/ui/toolpanel/makefile.mk b/sd/source/ui/toolpanel/makefile.mk index 08a966fe4061..4d83b8a85a70 100644..100755 --- a/sd/source/ui/toolpanel/makefile.mk +++ b/sd/source/ui/toolpanel/makefile.mk @@ -50,12 +50,14 @@ SLOFILES = \ $(SLO)$/TitleBar.obj \ $(SLO)$/TitleToolBox.obj \ $(SLO)$/TitledControl.obj \ - $(SLO)$/ToolPanel.obj \ $(SLO)$/TaskPaneControlFactory.obj \ $(SLO)$/TaskPaneFocusManager.obj \ $(SLO)$/TaskPaneShellManager.obj \ $(SLO)$/TaskPaneTreeNode.obj \ - $(SLO)$/TaskPaneViewShell.obj \ + $(SLO)$/ToolPanel.obj \ + $(SLO)$/ToolPanelViewShell.obj \ + $(SLO)$/ToolPanelFactory.obj \ + $(SLO)$/ToolPanelUIElement.obj \ \ $(SLO)$/EmptyWindow.obj \ $(SLO)$/LayoutMenu.obj \ |