summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2010-06-18 13:09:52 +0200
committerThomas Lange [tl] <tl@openoffice.org>2010-06-18 13:09:52 +0200
commit86307827b3b671154a44b552e2f8a8bb94791442 (patch)
tree5a167a056ea2f040e7b2dd1ae1f6868a24f79561 /sfx2
parent9d31e5d3ca564c719f94810fd93825131a14699c (diff)
parent34dd33af79caf3a13ec3a4e7098616ac0b16cf50 (diff)
cws tl79: merge with DEV300_m83
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/imagemgr.hxx2
-rw-r--r--sfx2/inc/pch/precompiled_sfx2.hxx2
-rw-r--r--sfx2/inc/sfx2/childwin.hxx42
-rw-r--r--sfx2/inc/sfx2/docfac.hxx1
-rw-r--r--sfx2/inc/sfx2/filedlghelper.hxx24
-rw-r--r--sfx2/inc/sfx2/mnumgr.hxx22
-rw-r--r--sfx2/inc/sfx2/module.hxx2
-rw-r--r--sfx2/inc/sfx2/sfxsids.hrc4
-rw-r--r--sfx2/inc/sfx2/taskpane.hxx245
-rw-r--r--sfx2/inc/sfx2/tbxctrl.hxx1
-rw-r--r--sfx2/inc/sfx2/titledockwin.hxx162
-rw-r--r--sfx2/inc/sfx2/viewfrm.hxx66
-rw-r--r--sfx2/prj/build.lst5
-rw-r--r--sfx2/qa/cppunit/makefile.mk74
-rw-r--r--sfx2/qa/cppunit/test_metadatable.cxx280
-rw-r--r--sfx2/qa/cppunit/version.map34
-rw-r--r--sfx2/sdi/frmslots.sdi5
-rwxr-xr-xsfx2/sdi/sfx.sdi53
-rw-r--r--sfx2/source/appl/app.cxx1
-rw-r--r--sfx2/source/appl/appinit.cxx2
-rw-r--r--sfx2/source/appl/appreg.cxx1
-rw-r--r--sfx2/source/appl/imagemgr.cxx2
-rw-r--r--sfx2/source/appl/module.cxx13
-rw-r--r--sfx2/source/appl/workwin.cxx107
-rw-r--r--sfx2/source/dialog/dialog.hrc31
-rw-r--r--sfx2/source/dialog/dialog.src157
-rwxr-xr-xsfx2/source/dialog/dinfdlg.cxx10
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx64
-rw-r--r--sfx2/source/dialog/filedlgimpl.hxx2
-rwxr-xr-xsfx2/source/dialog/makefile.mk15
-rw-r--r--sfx2/source/dialog/taskpane.cxx1283
-rw-r--r--sfx2/source/dialog/taskpane.src (renamed from sfx2/source/dialog/sfxurl.cxx)32
-rw-r--r--sfx2/source/dialog/titledockwin.cxx364
-rw-r--r--sfx2/source/dialog/titledockwin.src39
-rw-r--r--sfx2/source/doc/Metadatable.cxx162
-rw-r--r--sfx2/source/doc/docfac.cxx129
-rw-r--r--sfx2/source/doc/makefile.mk7
-rwxr-xr-xsfx2/source/doc/syspath.cxx48
-rw-r--r--sfx2/source/doc/syspath.hxx44
-rw-r--r--sfx2/source/doc/syspathw32.cxx83
-rwxr-xr-xsfx2/source/inc/helpid.hrc3
-rw-r--r--sfx2/source/inc/sfxlocal.hrc12
-rw-r--r--sfx2/source/inc/workwin.hxx1
-rw-r--r--sfx2/source/menu/makefile.mk5
-rw-r--r--sfx2/source/menu/menu.hrc4
-rw-r--r--sfx2/source/menu/menu.src15
-rwxr-xr-x[-rw-r--r--]sfx2/source/menu/mnumgr.cxx120
-rwxr-xr-xsfx2/source/menu/thessubmenu.cxx274
-rw-r--r--sfx2/source/menu/thessubmenu.hxx107
-rw-r--r--sfx2/source/view/impviewframe.hxx4
-rw-r--r--sfx2/source/view/viewfrm.cxx67
-rw-r--r--sfx2/source/view/viewprn.cxx45
-rw-r--r--sfx2/util/hidother.src2
-rw-r--r--sfx2/win/res/expdesk.icobin4990 -> 0 bytes
-rw-r--r--sfx2/win/res/expexp.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/expfld.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/expftp.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/exptrash.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/expwork.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/frameset.icobin2758 -> 0 bytes
-rw-r--r--sfx2/win/res/search.icobin2758 -> 0 bytes
-rw-r--r--sfx2/workben/custompanel/CalcWindowState.xcu21
-rw-r--r--sfx2/workben/custompanel/DrawWindowState.xcu21
-rw-r--r--sfx2/workben/custompanel/Factories.xcu21
-rw-r--r--sfx2/workben/custompanel/ImpressWindowState.xcu21
-rw-r--r--sfx2/workben/custompanel/WriterWindowState.xcu35
-rw-r--r--sfx2/workben/custompanel/ctp_factory.cxx167
-rw-r--r--sfx2/workben/custompanel/ctp_factory.hxx83
-rw-r--r--sfx2/workben/custompanel/ctp_panel.cxx270
-rw-r--r--sfx2/workben/custompanel/ctp_panel.hxx124
-rw-r--r--sfx2/workben/custompanel/ctp_services.cxx92
-rw-r--r--sfx2/workben/custompanel/delzip0
-rw-r--r--sfx2/workben/custompanel/description.xml16
-rw-r--r--sfx2/workben/custompanel/makefile.mk120
-rw-r--r--sfx2/workben/custompanel/manifest.xml18
-rw-r--r--sfx2/workben/custompanel/panel.pngbin0 -> 202 bytes
76 files changed, 4711 insertions, 577 deletions
diff --git a/sfx2/inc/imagemgr.hxx b/sfx2/inc/imagemgr.hxx
index ead9b6988cea..79dc724210c4 100644
--- a/sfx2/inc/imagemgr.hxx
+++ b/sfx2/inc/imagemgr.hxx
@@ -33,4 +33,4 @@
#include <rtl/ustring.hxx>
#include <vcl/image.hxx>
-SFX2_DLLPUBLIC Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast );
+SFX2_DLLPUBLIC Image SAL_CALL GetImage( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast );
diff --git a/sfx2/inc/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx
index 8cd8f9d8561f..b43dba7d6673 100644
--- a/sfx2/inc/pch/precompiled_sfx2.hxx
+++ b/sfx2/inc/pch/precompiled_sfx2.hxx
@@ -566,7 +566,7 @@
#include "svl/svdde.hxx"
#include "svl/svstdarr.hxx"
#include "svtools/svtdata.hxx"
-#include "svl/svtools.hrc"
+#include "svtools/svtools.hrc"
#include "unotools/syslocale.hxx"
#include "unotools/syslocaleoptions.hxx"
#include "svl/szitem.hxx"
diff --git a/sfx2/inc/sfx2/childwin.hxx b/sfx2/inc/sfx2/childwin.hxx
index cac0b72f13cf..fd1eb65d54df 100644
--- a/sfx2/inc/sfx2/childwin.hxx
+++ b/sfx2/inc/sfx2/childwin.hxx
@@ -87,13 +87,13 @@ struct SfxChildWinInfo
};
// Factory-Methode eines ChildWindows
-typedef SfxChildWindow* (*SfxChildWinCtor)( Window *pParentWindow,
+typedef SfxChildWindow* (*SfxChildWinCtor)( ::Window *pParentWindow,
sal_uInt16 nId,
SfxBindings *pBindings,
SfxChildWinInfo *pInfo);
// Factory-Methode eines ChildWindowsContexts
-typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( Window *pParentWindow,
+typedef SfxChildWindowContext* (*SfxChildWinContextCtor)( ::Window *pParentWindow,
SfxBindings *pBindings,
SfxChildWinInfo *pInfo);
struct SfxChildWinContextFactory
@@ -143,8 +143,8 @@ struct SfxChildWindow_Impl;
class SFX2_DLLPUBLIC SfxChildWindowContext
{
friend class SfxChildWindow;
- Window* pWindow;
- sal_uInt16 nContextId;
+ ::Window* pWindow;
+ sal_uInt16 nContextId;
protected:
SfxChildWindowContext( sal_uInt16 nId );
@@ -152,9 +152,9 @@ protected:
public:
virtual ~SfxChildWindowContext();
- void SetWindow( Window* pWin )
+ void SetWindow( ::Window* pWin )
{ pWindow=pWin; }
- Window* GetWindow() const
+ ::Window* GetWindow() const
{ return pWindow; }
sal_uInt16 GetContextId() const
{ return nContextId; }
@@ -169,12 +169,12 @@ public:
class SFX2_DLLPUBLIC SfxChildWindow
{
- Window* pParent; // parent window ( Topwindow )
- sal_uInt16 nType; // ChildWindow-Id
+ ::Window* pParent; // parent window ( Topwindow )
+ sal_uInt16 nType; // ChildWindow-Id
protected:
SfxChildAlignment eChildAlignment;// aktuelles ::com::sun::star::drawing::Alignment
- Window* pWindow; // eigentlicher Inhalt
+ ::Window* pWindow; // eigentlicher Inhalt
SfxChildWindow_Impl* pImp; // Imp-Daten
private:
@@ -185,14 +185,14 @@ private:
{ return pContext; }
protected:
- SfxChildWindow(Window *pParentWindow, sal_uInt16 nId);
+ SfxChildWindow(::Window *pParentWindow, sal_uInt16 nId);
public:
virtual ~SfxChildWindow();
void Destroy();
- Window* GetWindow() const
+ ::Window* GetWindow() const
{ return pWindow; }
- Window* GetParent() const
+ ::Window* GetParent() const
{ return pParent; }
SfxChildAlignment GetAlignment() const
{ return eChildAlignment; }
@@ -217,17 +217,17 @@ public:
sal_uInt16 GetContextId() const
{ return pContext ? pContext->GetContextId(): 0; }
- Window* GetContextWindow() const
+ ::Window* GetContextWindow() const
{ return pContext ? pContext->GetWindow(): 0; }
- Window* GetContextWindow( SfxModule *pModule ) const;
+ ::Window* GetContextWindow( SfxModule *pModule ) const;
virtual SfxChildWinInfo GetInfo() const;
void SaveStatus(const SfxChildWinInfo& rInfo);
static void RegisterChildWindow(SfxModule*, SfxChildWinFactory*);
- static SfxChildWindow* CreateChildWindow( sal_uInt16, Window*, SfxBindings*, SfxChildWinInfo&);
+ static SfxChildWindow* CreateChildWindow( sal_uInt16, ::Window*, SfxBindings*, SfxChildWinInfo&);
void SetHideNotDelete( sal_Bool bOn );
sal_Bool IsHideNotDelete() const;
void SetHideAtToggle( sal_Bool bOn );
@@ -258,19 +258,19 @@ public:
//------------------------------------------------------------------
//! demn"achst hinf"allig !
#define SFX_DECL_CHILDWINDOW_CONTEXT(Class) \
- static SfxChildWindowContext* CreateImpl(Window *pParent, \
+ static SfxChildWindowContext* CreateImpl(::Window *pParent, \
SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
static void RegisterChildWindowContext(SfxModule *pMod=0); \
//! Das Macro der Zukunft ...
#define SFX_DECL_CHILDWINDOWCONTEXT(Class) \
- static SfxChildWindowContext* CreateImpl(Window *pParent, \
+ static SfxChildWindowContext* CreateImpl(::Window *pParent, \
SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
static void RegisterChildWindowContext(sal_uInt16, SfxModule *pMod=0); \
//! demn"achst hinf"allig !
#define SFX_IMPL_CHILDWINDOW_CONTEXT(Class, MyID, ShellClass) \
- SfxChildWindowContext* __EXPORT Class::CreateImpl( Window *pParent, \
+ SfxChildWindowContext* __EXPORT Class::CreateImpl( ::Window *pParent, \
SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
{ \
SfxChildWindowContext *pContext = new Class(pParent, \
@@ -290,7 +290,7 @@ public:
// CreateImpl mu\s noch als Parameter die Factory mitbekommen wg. ContextId
// Solange wird diese Id auf 0 gesetzt und in SfxChildWindow::CreateContext gepatched
#define SFX_IMPL_CHILDWINDOWCONTEXT(Class, MyID) \
- SfxChildWindowContext* __EXPORT Class::CreateImpl( Window *pParent, \
+ SfxChildWindowContext* __EXPORT Class::CreateImpl( ::Window *pParent, \
SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
{ \
SfxChildWindowContext *pContext = new Class(pParent,0,pBindings,pInfo);\
@@ -305,7 +305,7 @@ public:
#define SFX_DECL_CHILDWINDOW(Class) \
public : \
- static SfxChildWindow* CreateImpl(Window *pParent, sal_uInt16 nId, \
+ static SfxChildWindow* CreateImpl(::Window *pParent, sal_uInt16 nId, \
SfxBindings *pBindings, SfxChildWinInfo* pInfo ); \
static void RegisterChildWindow (sal_Bool bVisible=sal_False, SfxModule *pMod=NULL, sal_uInt16 nFlags=0); \
static sal_uInt16 GetChildWindowId ();\
@@ -315,7 +315,7 @@ public:
SFX_IMPL_POS_CHILDWINDOW(Class, MyID, CHILDWIN_NOPOS)
#define SFX_IMPL_POS_CHILDWINDOW(Class, MyID, Pos) \
- SfxChildWindow* __EXPORT Class::CreateImpl( Window *pParent, \
+ SfxChildWindow* __EXPORT Class::CreateImpl( ::Window *pParent, \
sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo* pInfo ) \
{ \
SfxChildWindow *pWin = new Class(pParent, nId, pBindings, pInfo);\
diff --git a/sfx2/inc/sfx2/docfac.hxx b/sfx2/inc/sfx2/docfac.hxx
index 3cc3eecc7ce7..7468394d2617 100644
--- a/sfx2/inc/sfx2/docfac.hxx
+++ b/sfx2/inc/sfx2/docfac.hxx
@@ -101,6 +101,7 @@ public:
const SfxFilter* GetTemplateFilter() const;
static String GetStandardTemplate( const String& rServiceName );
static void SetStandardTemplate( const String& rServiceName, const String& rTemplateName );
+ static void SetSystemTemplate( const String& rServiceName, const String& rTemplateName );
void SetDocumentServiceName( const rtl::OUString& rServiceName );
const rtl::OUString& GetDocumentServiceName() const;
diff --git a/sfx2/inc/sfx2/filedlghelper.hxx b/sfx2/inc/sfx2/filedlghelper.hxx
index d17553e2b2d0..9b775f8e827d 100644
--- a/sfx2/inc/sfx2/filedlghelper.hxx
+++ b/sfx2/inc/sfx2/filedlghelper.hxx
@@ -102,30 +102,6 @@ class Window;
#define FILE_OPEN_SERVICE_NAME_SYSTEM "com.sun.star.ui.dialogs.SystemFilePicker"
#define FILE_OPEN_SERVICE_NAME_OOO "com.sun.star.ui.dialogs.OfficeFilePicker"
-//*****************************************************************************
-// SfxUrlDialog
-//*****************************************************************************
-
-//#if 0 // _SOLAR__PRIVATE
-#ifndef DONT_USE_FILE_DIALOG_SERVICE
-
-class SfxUrlDialog : public ModalDialog
-{
-private:
- Edit aEdit;
- OKButton aOk;
- CancelButton aCancel;
-
-public:
- SfxUrlDialog( Window* pParent );
-
- String GetUrl() const { return aEdit.GetText(); }
- void SetUrl( const String& rUrl ) { aEdit.SetText( rUrl ); }
-};
-
-#endif
-//#endif
-
//-----------------------------------------------------------------------------
namespace sfx2 {
diff --git a/sfx2/inc/sfx2/mnumgr.hxx b/sfx2/inc/sfx2/mnumgr.hxx
index ee1c81daa603..9c9b566d9d9d 100644
--- a/sfx2/inc/sfx2/mnumgr.hxx
+++ b/sfx2/inc/sfx2/mnumgr.hxx
@@ -102,22 +102,34 @@ private:
DECL_LINK( SelectHdl, void * );
Menu* pSVMenu;
-private:
- // only declared, but not defined: don't allow copying
- SfxPopupMenuManager( const SfxPopupMenuManager& );
- SfxPopupMenuManager& operator=( const SfxPopupMenuManager& );
+ // when #i107205 gets fixed this one should be superfluous.
+ // But right now we want to avoid the memory leak that would otherwise occur,
+ // if we don't delete the pointer that got created in SfxPopupMenuManager::Popup
+ static PopupMenu * pStaticThesSubMenu;
+
+ // only declared, but not defined: don't allow copying
+ SfxPopupMenuManager( const SfxPopupMenuManager& );
+ SfxPopupMenuManager& operator=( const SfxPopupMenuManager& );
public:
SfxPopupMenuManager( const ResId&, SfxBindings& );
SfxPopupMenuManager( PopupMenu*, SfxBindings& );
~SfxPopupMenuManager();
static void ExecutePopup( const ResId&, SfxViewFrame* pViewFrame, const Point& rPoint, Window* pWindow );
+ // @deprecated!!
+ // Don't use this method any longer. The whole class will be removed in the future.
+ // Changing code which relies on Popup would need much more effort.
+ // Please contact cd@openoffice.org if you have questions or need help
static SfxPopupMenuManager* Popup( const ResId& rResId, SfxViewFrame* pFrame,const Point& rPoint, Window* pWindow );
USHORT Execute( const Point& rPos, Window *pWindow );
USHORT Execute( const Point& rPoint, Window* pWindow, va_list pArgs, const SfxPoolItem *pArg1 );
USHORT Execute( const Point& rPoint, Window* pWindow, const SfxPoolItem *pArg1 ... );
+ // @deprecated (start)!!
+ // Don't use these methods any longer. The whole class will be removed in the future.
+ // Changing code which relies on these methods would need much more effort!
+ // Please contact cd@openoffice.org if you have questions or need help
void StartInsert();
void EndInsert();
void CheckItem( USHORT, BOOL );
@@ -125,6 +137,8 @@ public:
void InsertItem( USHORT, const String&, MenuItemBits,
USHORT nPos = MENU_APPEND );
void InsertSeparator( USHORT nPos = MENU_APPEND );
+ // @deprecated (end)
+
void RemoveDisabledEntries();
void AddClipboardFunctions();
Menu* GetSVMenu();
diff --git a/sfx2/inc/sfx2/module.hxx b/sfx2/inc/sfx2/module.hxx
index 793dd8f76cab..ad83bb4a7418 100644
--- a/sfx2/inc/sfx2/module.hxx
+++ b/sfx2/inc/sfx2/module.hxx
@@ -93,6 +93,8 @@ public:
virtual void Invalidate(USHORT nId = 0);
BOOL IsActive() const;
+ /*virtual*/ bool IsChildWindowAvailable( const USHORT i_nId, const SfxViewFrame* i_pViewFrame ) const;
+
static SfxModule* GetActiveModule( SfxViewFrame* pFrame=NULL );
static FieldUnit GetCurrentFieldUnit();
FieldUnit GetFieldUnit() const;
diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc
index 74210ba680ef..13e72edd6d6b 100644
--- a/sfx2/inc/sfx2/sfxsids.hrc
+++ b/sfx2/inc/sfx2/sfxsids.hrc
@@ -478,6 +478,9 @@
#define SID_CAPTION (SID_SFX_START + 641)
#define SID_STATUSBARTEXT (SID_SFX_START + 642)
+// id for thesaurs entry in context menu
+#define SID_THES (SID_SFX_START + 698)
+
// default-ids for editing, cursor travellung and selection
#define SID_REDO (SID_SFX_START + 700)
#define SID_UNDO (SID_SFX_START + 701)
@@ -868,6 +871,7 @@
#define SID_HYPERLINK_GETLINK (SID_SVX_START + 361)
#define SID_HYPERLINK_SETLINK (SID_SVX_START + 362)
#define SID_NAVIGATOR (SID_SVX_START + 366)
+#define SID_TASKPANE (SID_SVX_START + 370)
#define SID_ZOOM_NEXT (SID_SVX_START + 402)
#define SID_ZOOM_PREV (SID_SVX_START + 403)
#define SID_INET_DLG (SID_SVX_START + 416)
diff --git a/sfx2/inc/sfx2/taskpane.hxx b/sfx2/inc/sfx2/taskpane.hxx
new file mode 100644
index 000000000000..69ebd866a50b
--- /dev/null
+++ b/sfx2/inc/sfx2/taskpane.hxx
@@ -0,0 +1,245 @@
+/*************************************************************************
+ * 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 SFX_TASKPANE_HXX
+#define SFX_TASKPANE_HXX
+
+#include "sfx2/dllapi.h"
+#include "sfx2/childwin.hxx"
+#include "sfx2/titledockwin.hxx"
+
+#include <svtools/toolpanel/tabalignment.hxx>
+#include <svtools/toolpanel/tabitemcontent.hxx>
+
+#include <boost/scoped_ptr.hpp>
+#include <boost/optional.hpp>
+
+namespace svt
+{
+ class ToolPanelDeck;
+}
+
+//......................................................................................................................
+namespace sfx2
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= ITaskPaneToolPanelAccess
+ //==================================================================================================================
+ class SAL_NO_VTABLE ITaskPaneToolPanelAccess
+ {
+ public:
+ virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL ) = 0;
+ };
+
+ //==================================================================================================================
+ //= TaskPaneWrapper
+ //==================================================================================================================
+ class SFX2_DLLPUBLIC TaskPaneWrapper :public SfxChildWindow
+ ,public ITaskPaneToolPanelAccess
+ {
+ public:
+ TaskPaneWrapper(
+ Window* i_pParent,
+ USHORT i_nId,
+ SfxBindings* i_pBindings,
+ SfxChildWinInfo* i_pInfo
+ );
+
+ SFX_DECL_CHILDWINDOW( TaskPaneWrapper );
+
+ // ITaskPaneToolPanelAccess
+ virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL );
+ };
+
+ //==================================================================================================================
+ //= IToolPanelCompare
+ //==================================================================================================================
+ class SFX2_DLLPUBLIC SAL_NO_VTABLE IToolPanelCompare
+ {
+ public:
+ /** compares to tool panel URLs
+ @return
+ <ul>
+ <li>-1 if the tool panel described by i_rLHS should precede the one described by i_rRHS</li>
+ <li>0 if the two panels have no particular relative order</li>
+ <li>1 if the tool panel described by i_rLHS should succeed the one described by i_rRHS</li>
+
+ */
+ virtual short compareToolPanelsURLs(
+ const ::rtl::OUString& i_rLHS,
+ const ::rtl::OUString& i_rRHS
+ ) const = 0;
+ };
+
+ //==================================================================================================================
+ //= ModuleTaskPane
+ //==================================================================================================================
+ class ModuleTaskPane_Impl;
+ /** SFX-less version of a module dependent task pane, filled with tool panels as specified in the respective
+ module's configuration
+ */
+ class SFX2_DLLPUBLIC ModuleTaskPane : public Window
+ {
+ public:
+ /** creates a new instance
+ @param i_rParentWindow
+ the parent window
+ @param i_rDocumentFrame
+ the frame to which the task pane belongs. Will be passed to any custom tool panels created
+ via an XUIElementFactory. Also, it is used to determine the module which the task pane is
+ responsible for, thus controlling which tool panels are actually available.
+ */
+ ModuleTaskPane(
+ Window& i_rParentWindow,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame
+ );
+ /** creates a new instance
+ @param i_rParentWindow
+ the parent window
+ @param i_rDocumentFrame
+ the frame to which the task pane belongs. Will be passed to any custom tool panels created
+ via an XUIElementFactory. Also, it is used to determine the module which the task pane is
+ responsible for, thus controlling which tool panels are actually available.
+ @param i_rCompare
+ a comparator for tool panel URLs, which allows controlling the order in which the panels are
+ added to the tool panel deck.
+ */
+ ModuleTaskPane(
+ Window& i_rParentWindow,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame,
+ const IToolPanelCompare& i_rCompare
+ );
+ ~ModuleTaskPane();
+
+ /** determines whether a given module has any registered tool panels
+ */
+ static bool ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier );
+ /** determines whether a given module has any registered tool panels
+ */
+ static bool ModuleHasToolPanels( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rDocumentFrame );
+
+ /** provides access to the Window aspect of the PanelDeck
+
+ Be careful with this method. For instance, you're not allowed to insert arbitrary IToolPanel implementations
+ into the deck, as the ModuleTaskPane has certain assumptions about the panel implementations. However,
+ you're allowed to remove and re-insert panels, which have originally been created by the ModuleTaskPane
+ itself.
+ */
+ ::svt::ToolPanelDeck& GetPanelDeck();
+ const ::svt::ToolPanelDeck& GetPanelDeck() const;
+
+ /** returns the position of the panel with the given resource URL
+ */
+ ::boost::optional< size_t >
+ GetPanelPos( const ::rtl::OUString& i_rResourceURL );
+
+ /** returns the resource URL of the panel at the specified position
+ */
+ ::rtl::OUString
+ GetPanelResourceURL( const size_t i_nPanelPos ) const;
+
+ /// sets the "classical" layout of the tool panel deck, using drawers
+ void SetDrawersLayout();
+ /// sets the new layout of the tool panel deck, using tabs
+ void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent );
+
+ protected:
+ // Window overridables
+ virtual void Resize();
+ virtual void GetFocus();
+
+ private:
+ ::boost::scoped_ptr< ModuleTaskPane_Impl > m_pImpl;
+ };
+
+ //==================================================================================================================
+ //= TaskPaneController
+ //==================================================================================================================
+ class TaskPaneController_Impl;
+ /** is a helper class for connecting a ModuleTaskPane and a TitledDockingWindow, for clients of the ModuleTaskPane
+ which do not use the TaskPaneDockingWindow
+
+ The controller will add a drop down menu to the docking window which contains one item for each panel in the
+ panel deck, and allows toggling their visibility.
+ */
+ class SFX2_DLLPUBLIC TaskPaneController
+ {
+ public:
+ TaskPaneController(
+ ModuleTaskPane& i_rTaskPane,
+ TitledDockingWindow& i_rDockingWindow
+ );
+ ~TaskPaneController();
+
+ /** sets the default title to be used for the TitledDockingWindow
+
+ When the controller switches the docking window to "tabbed" mode, then the title of the docking window
+ will contain the name of the currently active panel (since this name isn't to be seen elsewhere).
+ When the controller switches the docking window to "drawer" mode, then the title of the docking window
+ contains the default title as given here (since in this mode, the names of the panels are shown in
+ the drawers).
+ */
+ void SetDefaultTitle( const String& i_rTitle );
+
+ /// activates the panel with the given URL
+ void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL );
+
+ private:
+ ::boost::scoped_ptr< TaskPaneController_Impl > m_pImpl;
+ };
+
+ //==================================================================================================================
+ //= TaskPaneDockingWindow
+ //==================================================================================================================
+ class TaskPaneDockingWindow :public TitledDockingWindow
+ ,public ITaskPaneToolPanelAccess
+ {
+ public:
+ TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper,
+ Window* i_pParent, WinBits i_nBits );
+
+ // ITaskPaneToolPanelAccess
+ virtual void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL );
+
+ protected:
+ // Window overridables
+ virtual void GetFocus();
+
+ // TitledDockingWindow overridables
+ virtual void onLayoutDone();
+
+ private:
+ ModuleTaskPane m_aTaskPane;
+ TaskPaneController m_aPaneController;
+ };
+
+//......................................................................................................................
+} // namespace sfx2
+//......................................................................................................................
+
+#endif // SFX_TASKPANE_HXX
diff --git a/sfx2/inc/sfx2/tbxctrl.hxx b/sfx2/inc/sfx2/tbxctrl.hxx
index d618051e4063..30d82c854642 100644
--- a/sfx2/inc/sfx2/tbxctrl.hxx
+++ b/sfx2/inc/sfx2/tbxctrl.hxx
@@ -243,6 +243,7 @@ protected:
virtual void SAL_CALL release() throw();
// XEventListener
+ using ::cppu::OPropertySetHelper::disposing;
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
// XComponent
diff --git a/sfx2/inc/sfx2/titledockwin.hxx b/sfx2/inc/sfx2/titledockwin.hxx
new file mode 100644
index 000000000000..ebb4497a0ba2
--- /dev/null
+++ b/sfx2/inc/sfx2/titledockwin.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ * 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 SFX_TITLEDOCKWIN_HXX
+#define SFX_TITLEDOCKWIN_HXX
+
+#include "sfx2/dllapi.h"
+#include "sfx2/dockwin.hxx"
+
+#include <vcl/toolbox.hxx>
+#include <tools/svborder.hxx>
+
+//......................................................................................................................
+namespace sfx2
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= TitledDockingWindow
+ //==================================================================================================================
+ class SFX2_DLLPUBLIC TitledDockingWindow : public SfxDockingWindow
+ {
+ public:
+ TitledDockingWindow(
+ SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
+ Window* i_pParent, WinBits i_nStyle = 0
+ );
+
+ TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow,
+ Window* i_pParent, const ResId& i_rResId
+ );
+
+ virtual ~TitledDockingWindow();
+
+ /** sets a title to be displayed in the docking window
+ */
+ void SetTitle( const String& i_rTitle );
+ /** returns the current title displayed in the docking window
+
+ Note that if you never called SetTitle before, then this method will not return an empty string,
+ but the window text (Window::GetText), since this is what is displayed as title then.
+ */
+ String GetTitle() const;
+
+ /** adds a drop down item to the toolbox. Usually, this is used to add some kind of menu to the toolbox.
+
+ @param i_rItemText
+ the text to display for the item
+ @param i_nHelpId
+ the help ID for the new toolbox item
+ @param i_rCallback
+ the callback to invoke when the drop item has been clicked
+ @return
+ the ID of the newly created toolbox item
+ */
+ USHORT AddDropDownToolBoxItem( const String& i_rItemText, ULONG i_nHelpId, const Link& i_rCallback )
+ {
+ return impl_addDropDownToolBoxItem( i_rItemText, i_nHelpId, i_rCallback );
+ }
+
+ void SetEndDockingHdl( const Link& i_rEndDockingHdl ) { m_aEndDockingHdl = i_rEndDockingHdl; }
+ const Link& GetEndDockingHdl() const { return m_aEndDockingHdl; }
+
+ /** resets the toolbox. Upon return, the only item in the toolbox is the closer.
+ */
+ void ResetToolBox()
+ {
+ impl_resetToolBox();
+ }
+
+ /** returns the content window, which is to be used as parent window for any content to be displayed
+ in the docking window.
+ */
+ ::Window& GetContentWindow() { return m_aContentWindow; }
+ const ::Window& GetContentWindow() const { return m_aContentWindow; }
+
+ ToolBox& GetToolBox() { return m_aToolbox; }
+ const ToolBox& GetToolBox() const { return m_aToolbox; }
+
+ protected:
+ // Window overridables
+ virtual void Paint( const Rectangle& i_rArea );
+ virtual void Resize();
+ virtual void StateChanged( StateChangedType i_nType );
+ virtual void DataChanged( const DataChangedEvent& i_rDataChangedEvent );
+ virtual void SetText( const String& i_rText );
+
+ // DockingWindow overridables
+ void EndDocking( const Rectangle& rRect, BOOL bFloatMode );
+
+ // own overridables
+ virtual void onLayoutDone();
+
+ protected:
+ /** internal version of ResetToolBox
+ */
+ void impl_resetToolBox();
+
+ /** internal version of AddDropDownToolBoxItem
+ */
+ USHORT impl_addDropDownToolBoxItem( const String& i_rItemText, ULONG i_nHelpId, const Link& i_rCallback );
+
+ /** returns the current title.
+
+ If no title has been set via SetTitle, then the window text (Window::GetText) is returned.
+ */
+ String impl_getTitle() const;
+
+ private:
+ DECL_LINK( OnToolboxItemSelected, ToolBox* );
+
+ void impl_construct();
+ void impl_layout();
+ void impl_scheduleLayout();
+
+ private:
+ String m_sTitle;
+ ToolBox m_aToolbox;
+ Window m_aContentWindow;
+
+ Link m_aEndDockingHdl;
+
+ /** The border that is painted arround the inner window. The bevel
+ shadow lines are part of the border, so where the border is 0 no
+ such line is painted.
+ */
+ SvBorder m_aBorder;
+
+ /** Remember that a layout is pending, i.e. Resize() has been called
+ since the last Paint().
+ */
+ bool m_bLayoutPending;
+ };
+
+//......................................................................................................................
+} // namespace sfx2
+//......................................................................................................................
+
+#endif // SFX_TITLEDOCKWIN_HXX
diff --git a/sfx2/inc/sfx2/viewfrm.hxx b/sfx2/inc/sfx2/viewfrm.hxx
index 8350bc5f0f9d..d376236bf830 100644
--- a/sfx2/inc/sfx2/viewfrm.hxx
+++ b/sfx2/inc/sfx2/viewfrm.hxx
@@ -40,6 +40,8 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/frame/XController2.hpp>
+#include <tools/svborder.hxx>
+
class SfxMacro;
class SvBorder;
class SfxDispatcher;
@@ -70,67 +72,6 @@ SV_DECL_REF(SfxObjectShell)
#endif
//========================================================================
-#include <tools/gen.hxx>
-class SvBorder
-{
- long nTop, nRight, nBottom, nLeft;
-public:
- SvBorder()
- { nTop = nRight = nBottom = nLeft = 0; }
- SvBorder( const Size & rSz )
- { nTop = nBottom = rSz.Height(); nRight = nLeft = rSz.Width(); }
- SvBorder( const Rectangle & rOuter, const Rectangle & rInner );
- SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP )
- { nLeft = nLeftP; nTop = nTopP; nRight = nRightP; nBottom = nBottomP; }
- BOOL operator == ( const SvBorder & rObj ) const
- {
- return nTop == rObj.nTop && nRight == rObj.nRight &&
- nBottom == rObj.nBottom && nLeft == rObj.nLeft;
- }
- BOOL operator != ( const SvBorder & rObj ) const
- { return !(*this == rObj); }
- SvBorder & operator = ( const SvBorder & rBorder )
- {
- Left() = rBorder.Left();
- Top() = rBorder.Top();
- Right() = rBorder.Right();
- Bottom() = rBorder.Bottom();
- return *this;
- }
- SvBorder & operator += ( const SvBorder & rBorder )
- {
- Left() += rBorder.Left();
- Top() += rBorder.Top();
- Right() += rBorder.Right();
- Bottom() += rBorder.Bottom();
- return *this;
- }
- SvBorder & operator -= ( const SvBorder & rBorder )
- {
- Left() -= rBorder.Left();
- Top() -= rBorder.Top();
- Right() -= rBorder.Right();
- Bottom() -= rBorder.Bottom();
- return *this;
- }
- BOOL IsInside( const SvBorder & rInside )
- {
- return nTop >= rInside.nTop && nRight >= rInside.nRight &&
- nBottom >= rInside.nBottom && nLeft >= rInside.nLeft;
- }
- long & Top() { return nTop; }
- long & Right() { return nRight; }
- long & Bottom() { return nBottom; }
- long & Left() { return nLeft; }
- long Top() const { return nTop; }
- long Right() const { return nRight; }
- long Bottom() const { return nBottom; }
- long Left() const { return nLeft; }
-};
-Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder );
-Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder );
-
-
DBG_NAMEEX(SfxViewFrame)
class SFX2_DLLPUBLIC SfxViewFrame: public SfxShell, public SfxListener
{
@@ -228,6 +169,8 @@ public:
String UpdateTitle();
+ static void ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL );
+
// interne Handler
SAL_DLLPRIVATE virtual BOOL SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder );
SAL_DLLPRIVATE virtual const SvBorder& GetBorderPixelImpl( const SfxViewShell *pSh ) const;
@@ -304,6 +247,7 @@ public:
SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &);
SAL_DLLPRIVATE void SetCurViewId_Impl( const USHORT i_nID );
+ SAL_DLLPRIVATE void ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL );
//#endif
private:
diff --git a/sfx2/prj/build.lst b/sfx2/prj/build.lst
index 3e791fbc2000..96320614eaaf 100644
--- a/sfx2/prj/build.lst
+++ b/sfx2/prj/build.lst
@@ -1,8 +1,7 @@
-sf sfx2 : l10n idl basic xmlscript framework shell setup_native sax SYSTRAY_GTK:libegg LIBXML2:libxml2 NULL
+sf sfx2 : l10n idl basic xmlscript framework readlicense_oo shell setup_native sax SYSTRAY_GTK:libegg LIBXML2:libxml2 NULL
sf sfx2 usr1 - all sf_mkout NULL
sf sfx2\inc nmake - all sf_inc NULL
sf sfx2\prj get - all sf_prj NULL
-sf sfx2\win\res get - all sf_wres NULL
sf sfx2\mac\res get - all sf_mres NULL
sf sfx2\source\inc get - all sf_sinc NULL
sf sfx2\sdi nmake - all sf_sdi NULL
@@ -20,5 +19,7 @@ sf sfx2\source\statbar nmake - all sf_sbar sf_sdi sf_inc NULL
sf sfx2\source\toolbox nmake - all sf_tbox sf_sdi sf_inc NULL
sf sfx2\source\inet nmake - all sf_inet sf_sdi sf_inc NULL
sf sfx2\source\explorer nmake - all sf_expl sf_sdi sf_inc NULL
+sf sfx2\workben\custompanel nmake - all sf_wb_custompanel NULL
sf sfx2\util nmake - all sf_util sf_appl sf_bast sf_cnfg sf_ctrl sf_dlg sf_doc sf_expl sf_inet sf_menu sf_layout sf_noti sf_sbar sf_tbox sf_view NULL
sf sfx2\qa\unoapi nmake - all sf_qa_unoapi NULL
+sf sfx2\qa\cppunit nmake - all sf_qa_cppunit sf_util NULL
diff --git a/sfx2/qa/cppunit/makefile.mk b/sfx2/qa/cppunit/makefile.mk
new file mode 100644
index 000000000000..2794c2ae92bb
--- /dev/null
+++ b/sfx2/qa/cppunit/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=../..
+PRJNAME=sfx2
+TARGET=qa_cppunit
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+DLLPRE = # no leading "lib" on .so files
+
+# --- Libs ---------------------------------------------------------
+
+SHL1OBJS= \
+ $(SLO)/test_metadatable.obj \
+
+
+SHL1STDLIBS= \
+ $(CPPUNITLIB) \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VCLLIB) \
+ $(SFXLIB) \
+
+
+SHL1TARGET= test_metadatable
+SHL1RPATH = NONE
+SHL1IMPLIB= i$(SHL1TARGET)
+# SHL1DEF= $(MISC)/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+# DEF1EXPORTFILE= export.exp
+SHL1VERSIONMAP= version.map
+
+# --- All object files ---------------------------------------------
+
+SLOFILES= \
+ $(SHL1OBJS) \
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : _cppunit.mk
+
diff --git a/sfx2/qa/cppunit/test_metadatable.cxx b/sfx2/qa/cppunit/test_metadatable.cxx
new file mode 100644
index 000000000000..903be6920327
--- /dev/null
+++ b/sfx2/qa/cppunit/test_metadatable.cxx
@@ -0,0 +1,280 @@
+/*************************************************************************
+ *
+ * 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_sfx2.hxx"
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Duration.hpp>
+
+#include <sfx2/Metadatable.hxx>
+#include <sfx2/XmlIdRegistry.hxx>
+
+
+using namespace ::com::sun::star;
+
+
+namespace {
+
+class MetadatableTest
+ : public ::CppUnit::TestFixture
+{
+public:
+ virtual void setUp();
+ virtual void tearDown();
+
+ void test();
+
+ CPPUNIT_TEST_SUITE(MetadatableTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+
+private:
+};
+
+void MetadatableTest::setUp()
+{
+}
+
+void MetadatableTest::tearDown()
+{
+}
+
+
+class MockMetadatable
+ : public ::sfx2::Metadatable
+{
+private:
+ ::sfx2::IXmlIdRegistry & m_rRegistry;
+
+public:
+ MockMetadatable(::sfx2::IXmlIdRegistry & i_rReg,
+ bool const i_isInClip = false)
+ : m_rRegistry(i_rReg)
+ , m_bInClipboard(i_isInClip), m_bInUndo(false), m_bInContent(true) {}
+ bool m_bInClipboard;
+ bool m_bInUndo;
+ bool m_bInContent;
+ virtual bool IsInClipboard() const { return m_bInClipboard; }
+ virtual bool IsInUndo() const { return m_bInUndo; }
+ virtual bool IsInContent() const { return m_bInContent; }
+ virtual ::sfx2::IXmlIdRegistry& GetRegistry() { return m_rRegistry; }
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::rdf::XMetadatable > MakeUnoObject() { return 0; }
+};
+
+static bool operator==(beans::StringPair p1, beans::StringPair p2)
+{
+ return p1.First == p2.First && p1.Second == p2.Second;
+}
+
+void MetadatableTest::test()
+{
+ OSL_TRACE("SwMetadatable test(): start\n");
+ ::std::auto_ptr< ::sfx2::IXmlIdRegistry > const pReg(
+ ::sfx2::createXmlIdRegistry(false) );
+ ::std::auto_ptr< ::sfx2::IXmlIdRegistry > const pRegClip(
+ ::sfx2::createXmlIdRegistry(true) );
+
+ MockMetadatable m1(*pReg);
+ MockMetadatable m2(*pReg);
+ MockMetadatable m3(*pReg);
+ MockMetadatable m4(*pReg);
+ MockMetadatable m5(*pReg);
+ ::rtl::OUString empty;
+ ::rtl::OUString content( ::rtl::OUString::createFromAscii("content.xml") );
+ ::rtl::OUString styles ( ::rtl::OUString::createFromAscii("styles.xml") );
+ ::rtl::OUString sid1( ::rtl::OUString::createFromAscii("id1") );
+ ::rtl::OUString sid2( ::rtl::OUString::createFromAscii("id2") );
+ ::rtl::OUString sid3( ::rtl::OUString::createFromAscii("id3") );
+ ::rtl::OUString sid4( ::rtl::OUString::createFromAscii("id4") );
+ beans::StringPair id1(content, sid1);
+ beans::StringPair id2(content, sid2);
+ beans::StringPair id3(content, sid3);
+ beans::StringPair id4(styles, sid4);
+ beans::StringPair id3e(empty, sid3);
+ beans::StringPair id4e(empty, sid4);
+ m1.SetMetadataReference(id1);
+ CPPUNIT_ASSERT_MESSAGE("set failed", m1.GetMetadataReference() == id1);
+ try {
+ m2.SetMetadataReference(id1);
+ CPPUNIT_ASSERT_MESSAGE("set duplicate succeeded", false);
+ } catch (lang::IllegalArgumentException) { }
+ m1.SetMetadataReference(id1);
+ CPPUNIT_ASSERT_MESSAGE("set failed (existing)",
+ m1.GetMetadataReference() == id1);
+ m1.EnsureMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("ensure failed (existing)",
+ m1.GetMetadataReference() == id1);
+
+ m2.EnsureMetadataReference();
+ beans::StringPair m2id(m2.GetMetadataReference());
+ CPPUNIT_ASSERT_MESSAGE("ensure failed", m2id.Second.getLength());
+ m2.EnsureMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("ensure failed (idempotent)",
+ m2.GetMetadataReference() == m2id);
+
+ m1.m_bInUndo = true;
+ CPPUNIT_ASSERT_MESSAGE("move to undo failed",
+ !m1.GetMetadataReference().Second.getLength());
+
+ m1.m_bInUndo = false;
+ CPPUNIT_ASSERT_MESSAGE("move from undo failed",
+ m1.GetMetadataReference() == id1);
+
+ m1.m_bInUndo = true;
+ try {
+ m2.SetMetadataReference(id1); // steal!
+ } catch (lang::IllegalArgumentException &) {
+ CPPUNIT_FAIL("set duplicate to undo failed");
+ }
+ m1.m_bInUndo = false;
+ CPPUNIT_ASSERT_MESSAGE("move from undo: duplicate",
+ !m1.GetMetadataReference().Second.getLength());
+
+ m3.RegisterAsCopyOf(m2);
+ CPPUNIT_ASSERT_MESSAGE("copy: source", m2.GetMetadataReference() == id1);
+ CPPUNIT_ASSERT_MESSAGE("copy: duplicate",
+ !m3.GetMetadataReference().Second.getLength());
+ m4.RegisterAsCopyOf(m3);
+ CPPUNIT_ASSERT_MESSAGE("copy: source", m2.GetMetadataReference() == id1);
+ CPPUNIT_ASSERT_MESSAGE("copy: duplicate",
+ !m3.GetMetadataReference().Second.getLength());
+ CPPUNIT_ASSERT_MESSAGE("copy: duplicate",
+ !m4.GetMetadataReference().Second.getLength());
+ m2.m_bInUndo = true;
+ CPPUNIT_ASSERT_MESSAGE("duplicate to undo",
+ m3.GetMetadataReference() == id1);
+ CPPUNIT_ASSERT_MESSAGE("duplicate to undo",
+ !m2.GetMetadataReference().Second.getLength());
+ m2.m_bInUndo = false;
+ CPPUNIT_ASSERT_MESSAGE("duplicate from undo",
+ m2.GetMetadataReference() == id1);
+ CPPUNIT_ASSERT_MESSAGE("duplicate from undo",
+ !m3.GetMetadataReference().Second.getLength());
+
+ m4.EnsureMetadataReference(); // new!
+ beans::StringPair m4id(m4.GetMetadataReference());
+ CPPUNIT_ASSERT_MESSAGE("ensure on duplicate",
+ m4id.Second.getLength() && !(m4id == id1));
+
+ MockMetadatable mc1(*pRegClip, true); // in clipboard
+ MockMetadatable mc2(*pRegClip, true);
+ MockMetadatable mc3(*pRegClip, true);
+ MockMetadatable mc4(*pRegClip, true);
+ MockMetadatable m2p(*pReg);
+ MockMetadatable m3p(*pReg);
+
+ mc1.SetMetadataReference(id2);
+ CPPUNIT_ASSERT_MESSAGE("set failed", mc1.GetMetadataReference() == id2);
+ try {
+ mc2.SetMetadataReference(id2);
+ CPPUNIT_FAIL("set duplicate succeeded");
+ } catch (lang::IllegalArgumentException) { }
+ mc1.SetMetadataReference(id2);
+ CPPUNIT_ASSERT_MESSAGE("set failed (existing)",
+ mc1.GetMetadataReference() == id2);
+ mc1.EnsureMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("ensure failed (existing)",
+ mc1.GetMetadataReference() == id2);
+ mc2.EnsureMetadataReference();
+ beans::StringPair mc2id(mc2.GetMetadataReference());
+ CPPUNIT_ASSERT_MESSAGE("ensure failed", mc2id.Second.getLength());
+ mc2.EnsureMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("ensure failed (idempotent)",
+ mc2.GetMetadataReference() == mc2id);
+ mc2.RemoveMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("remove failed",
+ !mc2.GetMetadataReference().Second.getLength());
+
+ // set up mc2 as copy of m2 and mc3 as copy of m3
+ mc3.RegisterAsCopyOf(m3);
+ CPPUNIT_ASSERT_MESSAGE("copy to clipboard (latent)",
+ !mc3.GetMetadataReference().Second.getLength() );
+ mc2.RegisterAsCopyOf(m2);
+ CPPUNIT_ASSERT_MESSAGE("copy to clipboard (non-latent)",
+ mc2.GetMetadataReference() == id1);
+ // paste mc2 to m2p and mc3 to m3p
+ m2p.RegisterAsCopyOf(mc2);
+ CPPUNIT_ASSERT_MESSAGE("paste from clipboard (non-latent)",
+ !m2p.GetMetadataReference().Second.getLength() );
+ m3p.RegisterAsCopyOf(mc3);
+ CPPUNIT_ASSERT_MESSAGE("paste from clipboard (latent)",
+ !m3p.GetMetadataReference().Second.getLength() );
+ // delete m2, m2p, m3
+ m2.RemoveMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("remove failed",
+ !m2.GetMetadataReference().Second.getLength());
+ CPPUNIT_ASSERT_MESSAGE("paste-remove (non-latent)",
+ m2p.GetMetadataReference() == id1);
+ m2p.RemoveMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("remove failed",
+ !m2p.GetMetadataReference().Second.getLength());
+ CPPUNIT_ASSERT_MESSAGE("paste-remove2 (non-latent)",
+ m3.GetMetadataReference() == id1);
+ m3.RemoveMetadataReference();
+ CPPUNIT_ASSERT_MESSAGE("remove failed",
+ !m3.GetMetadataReference().Second.getLength());
+ CPPUNIT_ASSERT_MESSAGE("paste-remove (latent)",
+ m3p.GetMetadataReference() == id1);
+ // delete mc2
+ mc2.SetMetadataReference(beans::StringPair());
+ CPPUNIT_ASSERT_MESSAGE("in clipboard becomes non-latent",
+ !mc3.GetMetadataReference().Second.getLength() );
+ // paste mc2
+ m2p.RegisterAsCopyOf(mc2);
+ CPPUNIT_ASSERT_MESSAGE("remove-paste",
+ !m2p.GetMetadataReference().Second.getLength());
+ CPPUNIT_ASSERT_MESSAGE("remove-paste (stolen)",
+ m3p.GetMetadataReference() == id1);
+
+ // auto-detect stream
+ m5.SetMetadataReference(id3e);
+ CPPUNIT_ASSERT_MESSAGE("auto-detect (content)",
+ m5.GetMetadataReference() == id3);
+ m5.m_bInContent = false;
+ m5.SetMetadataReference(id4e);
+ CPPUNIT_ASSERT_MESSAGE("auto-detect (styles)",
+ m5.GetMetadataReference() == id4);
+
+ OSL_TRACE("sfx2::Metadatable test(): finished\n");
+}
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION(MetadatableTest);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
diff --git a/sfx2/qa/cppunit/version.map b/sfx2/qa/cppunit/version.map
new file mode 100644
index 000000000000..3308588ef6f8
--- /dev/null
+++ b/sfx2/qa/cppunit/version.map
@@ -0,0 +1,34 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+UDK_3_0_0 {
+ global:
+ cppunitTestPlugIn;
+
+ local:
+ *;
+};
diff --git a/sfx2/sdi/frmslots.sdi b/sfx2/sdi/frmslots.sdi
index c4210b801bf6..dbf9267448e1 100644
--- a/sfx2/sdi/frmslots.sdi
+++ b/sfx2/sdi/frmslots.sdi
@@ -50,6 +50,11 @@ interface Window
ExecMethod = ChildWindowExecute ;
StateMethod = ChildWindowState ;
]
+ SID_TASKPANE // status(final|play)
+ [
+ ExecMethod = ChildWindowExecute ;
+ StateMethod = ChildWindowState ;
+ ]
SID_SHOW_BROWSER // ole(no) api(final/play/rec)
[
ExecMethod = ChildWindowExecute ;
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 10a920852848..e4e43c51052f 100755
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -3931,6 +3931,33 @@ SfxBoolItem Navigator SID_NAVIGATOR
ToolBoxConfig = TRUE,
GroupId = GID_NAVIGATOR;
]
+
+//--------------------------------------------------------------------------
+SfxBoolItem TaskPane SID_TASKPANE
+[
+ /* flags: */
+ AutoUpdate = TRUE,
+ Cachable = Cachable,
+ FastCall = FALSE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+ Readonly = FALSE,
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_VIEW;
+]
+
//--------------------------------------------------------------------------
SfxVoidItem RestoreEditingView SID_RESTORE_EDITING_VIEW
@@ -8194,3 +8221,29 @@ SfxInt16Item PasteUnformatted SID_PASTE_UNFORMATTED
GroupId = GID_EDIT;
]
+//--------------------------------------------------------------------------
+// call thesaurus dialog from context menu
+SfxInt16Item ThesaurusFromContext SID_THES
+(SfxStringItem WordReplace SID_THES)
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE,
+ HasDialog = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = FALSE,
+ MenuConfig = FALSE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = FALSE,
+ GroupId = GID_TEXT;
+]
+
diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx
index d42d203e57f5..6e13894feb49 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -322,6 +322,7 @@ SfxApplication* SfxApplication::GetOrCreate()
::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory );
::framework::SetDockingWindowCreator( SfxDockingWindowFactory );
::framework::SetIsDockingWindowVisible( IsDockingWindowVisible );
+ ::framework::SetActivateToolPanel( &SfxViewFrame::ActivateToolPanel );
SfxHelp* pSfxHelp = new SfxHelp;
Application::SetHelp( pSfxHelp );
diff --git a/sfx2/source/appl/appinit.cxx b/sfx2/source/appl/appinit.cxx
index a34a2e0d6a32..08023c5414a6 100644
--- a/sfx2/source/appl/appinit.cxx
+++ b/sfx2/source/appl/appinit.cxx
@@ -35,7 +35,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <svtools/soerr.hxx>
-#include <svl/svtools.hrc>
+#include <svtools/svtools.hrc>
#include <unotools/saveopt.hxx>
#include <unotools/localisationoptions.hxx>
#include <tools/config.hxx>
diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx
index 47bf98292316..addace134362 100644
--- a/sfx2/source/appl/appreg.cxx
+++ b/sfx2/source/appl/appreg.cxx
@@ -42,6 +42,7 @@
#include "inettbc.hxx"
#include "stbitem.hxx"
#include <sfx2/navigat.hxx>
+#include <sfx2/taskpane.hxx>
#include <sfx2/module.hxx>
#include <sfx2/viewfrm.hxx>
#include "partwnd.hxx"
diff --git a/sfx2/source/appl/imagemgr.cxx b/sfx2/source/appl/imagemgr.cxx
index f7cccf2712b8..3b26eae1858d 100644
--- a/sfx2/source/appl/imagemgr.cxx
+++ b/sfx2/source/appl/imagemgr.cxx
@@ -71,7 +71,7 @@ static WeakReference< XModuleUIConfigurationManagerSupplier > m_xModuleCfgMgrSup
static WeakReference< XURLTransformer > m_xURLTransformer;
static ModuleIdToImagegMgr m_aModuleIdToImageMgrMap;
-Image SAL_CALL GetImage( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast )
+Image SAL_CALL GetImage( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast )
{
// TODO/LATeR: shouldn't this become a method at SfxViewFrame?! That would save the UnoTunnel
if ( !rFrame.is() )
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index c8a9742f49cf..895263ef4783 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -49,6 +49,8 @@
#include <sfx2/objface.hxx>
#include <sfx2/viewfrm.hxx>
#include <svl/intitem.hxx>
+#include "sfx2/taskpane.hxx"
+#include <tools/diagnose_ex.h>
#define SfxModule
#include "sfxslots.hxx"
@@ -400,6 +402,17 @@ BOOL SfxModule::IsActive() const
return FALSE;
}
+bool SfxModule::IsChildWindowAvailable( const USHORT i_nId, const SfxViewFrame* i_pViewFrame ) const
+{
+ if ( i_nId != SID_TASKPANE )
+ // by default, assume it is
+ return true;
+
+ const SfxViewFrame* pViewFrame = i_pViewFrame ? i_pViewFrame : GetFrame();
+ ENSURE_OR_RETURN( pViewFrame, "SfxModule::IsChildWindowAvailable: no frame to ask for the module identifier!", false );
+ return ::sfx2::ModuleTaskPane::ModuleHasToolPanels( pViewFrame->GetFrame().GetFrameInterface() );
+}
+
SfxModule* SfxModule::GetActiveModule( SfxViewFrame* pFrame )
{
if ( !pFrame )
diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx
index 24cf7dab8095..f9a388deee5c 100644
--- a/sfx2/source/appl/workwin.cxx
+++ b/sfx2/source/appl/workwin.cxx
@@ -53,6 +53,7 @@
#include <vcl/taskpanelist.hxx>
#include <vcl/toolbox.hxx>
#include <tools/rcid.h>
+#include <tools/diagnose_ex.h>
#include <toolkit/helper/vclunohelper.hxx>
#include <svl/itempool.hxx>
#include <svl/itemiter.hxx>
@@ -1538,6 +1539,16 @@ void SfxWorkWindow::UpdateObjectBars_Impl()
}
}
+bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const
+{
+ // or checking the availability of child windows, we need access to the module
+ const SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
+ const SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
+ const SfxModule* pModule = pShell ? pShell->GetModule() : NULL;
+ ENSURE_OR_RETURN( pModule, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
+ return pModule->IsChildWindowAvailable( i_rCW.nId, pViewFrame );
+}
+
void SfxWorkWindow::UpdateChildWindows_Impl()
{
// alle vorhandenen oder in den Kontext gekommenen ChildWindows
@@ -1550,7 +1561,7 @@ void SfxWorkWindow::UpdateChildWindows_Impl()
{
// Im Kontext ist ein geeignetes ChildWindow erlaubt;
// ist es auch eingeschaltet ?
- if ( pChildWin == 0 && pCW->bCreate )
+ if ( pChildWin == NULL && pCW->bCreate )
{
// Internal docking is only used for embedding into another
// container. We force the floating state of all floatable
@@ -1571,6 +1582,9 @@ void SfxWorkWindow::UpdateChildWindows_Impl()
else
bCreate = TRUE;
+ if ( bCreate )
+ bCreate = AllowChildWindowCreation_Impl( *pCW );
+
// Momentan kein Fenster da, aber es ist eingeschaltet; Fenster
// und ggf. Context erzeugen
if ( bCreate )
@@ -1588,19 +1602,25 @@ void SfxWorkWindow::UpdateChildWindows_Impl()
if ( ( !bIsFullScreen || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT ) && bAllChildsVisible )
{
// Updatemode ist kompatibel; auf jeden Fall wieder einschalten
- bCreate = TRUE;
- if ( pCW->pCli )
+ bCreate = AllowChildWindowCreation_Impl( *pCW );
+ if ( bCreate )
{
- // Fenster ist direktes Child
- if ( bAllChildsVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
- pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
+ if ( pCW->pCli )
+ {
+ // Fenster ist direktes Child
+ if ( bAllChildsVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
+ pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
+ }
+ else
+ {
+ if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
+ // Fenster liegt in einem SplitWindow
+ ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
+ }
+
+ if ( pCW->nInterfaceId != pChildWin->GetContextId() )
+ pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
}
- else if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
- // Fenster liegt in einem SplitWindow
- ((SfxDockingWindow*)pChildWin->GetWindow())->Reappear_Impl();
-
- if ( pCW->nInterfaceId != pChildWin->GetContextId() )
- pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
}
}
}
@@ -2225,7 +2245,7 @@ void SfxWorkWindow::ToggleChildWindow_Impl(USHORT nId, BOOL bSetFocus)
SfxChildWin_Impl *pCW = (*pChildWins)[n];
SfxChildWindow *pChild = pCW->pWin;
- bool bCreationAllowed( sal_True );
+ bool bCreationAllowed( true );
if ( !bInternalDockingAllowed )
{
// Special case for all non-floatable child windows. We have
@@ -2233,43 +2253,51 @@ void SfxWorkWindow::ToggleChildWindow_Impl(USHORT nId, BOOL bSetFocus)
bCreationAllowed = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
}
- if ( pChild && pCW->bCreate && bCreationAllowed )
+ if ( bCreationAllowed )
{
- if ( pChild->QueryClose() )
+ if ( pCW->bCreate )
{
- if ( pChild && pChild->IsHideAtToggle() )
+ if ( pChild )
{
- pCW->bCreate = !pCW->bCreate;
- ShowChildWindow_Impl( nId, pCW->bCreate, bSetFocus );
+ if ( pChild->QueryClose() )
+ {
+ pCW->bCreate = FALSE;
+ if ( pChild->IsHideAtToggle() )
+ {
+ ShowChildWindow_Impl( nId, FALSE, bSetFocus );
+ }
+ else
+ {
+ // Fenster soll ausgeschaltet werdem
+ pChild->SetVisible_Impl( FALSE );
+ RemoveChildWin_Impl( pCW );
+ }
+ }
}
else
{
- // Fenster soll ausgeschaltet werdem
+ // no actual Window exists, yet => just remember the "switched off" state
pCW->bCreate = FALSE;
- pChild->SetVisible_Impl( FALSE );
- RemoveChildWin_Impl( pCW );
}
}
- }
- else if ( pCW->bCreate && bCreationAllowed )
- {
- pCW->bCreate = FALSE;
- }
- else if ( bCreationAllowed )
- {
- pCW->bCreate = TRUE;
-
- if ( pChild )
- {
- ShowChildWindow_Impl( nId, pCW->bCreate, bSetFocus );
- }
else
{
- // Fenster erzeugen
- CreateChildWin_Impl( pCW, bSetFocus );
- if ( !pCW->pWin )
- // Erzeugung war erfolglos
- pCW->bCreate = FALSE;
+ pCW->bCreate = AllowChildWindowCreation_Impl( *pCW );
+ if ( pCW->bCreate )
+ {
+ if ( pChild )
+ {
+ ShowChildWindow_Impl( nId, TRUE, bSetFocus );
+ }
+ else
+ {
+ // create actual Window
+ CreateChildWin_Impl( pCW, bSetFocus );
+ if ( !pCW->pWin )
+ // no success
+ pCW->bCreate = FALSE;
+ }
+ }
}
}
@@ -2488,7 +2516,6 @@ void SfxWorkWindow::ShowChildWindow_Impl(USHORT nId, BOOL bVisible, BOOL bSetFoc
SfxChildWindow *pChildWin = pCW->pWin;
if ( pChildWin )
{
-// pCW->bCreate = bVisible;
if ( bVisible )
{
if ( pCW->pCli )
diff --git a/sfx2/source/dialog/dialog.hrc b/sfx2/source/dialog/dialog.hrc
index f1e100e17cf5..7f03bf416431 100644
--- a/sfx2/source/dialog/dialog.hrc
+++ b/sfx2/source/dialog/dialog.hrc
@@ -39,54 +39,24 @@
#define RID_DLG_ALIEN_WARNING ( RC_DIALOG_BEGIN + 0)
#define STR_RESET ( RC_DIALOG_BEGIN + 0)
-#define STR_BASEFMT ( RC_DIALOG_BEGIN + 1)
-#define CB_USE_PASSWD ( RC_DIALOG_BEGIN + 2)
-#define CB_READ_ONLY ( RC_DIALOG_BEGIN + 3)
-#define BTN_MANAGER ( RC_DIALOG_BEGIN + 4)
-#define BTN_STANDARD ( RC_DIALOG_BEGIN + 5)
#define DLG_PASSWD ( RC_DIALOG_BEGIN + 8)
-#define STR_FILEDLG_INSERT ( RC_DIALOG_BEGIN + 10)
#define STR_TABPAGE_MANAGESTYLES ( RC_DIALOG_BEGIN + 12)
#define MSG_TABPAGE_INVALIDNAME ( RC_DIALOG_BEGIN + 13)
#define MSG_TABPAGE_INVALIDSTYLE ( RC_DIALOG_BEGIN + 14)
#define DLG_NEW_STYLE_BY_EXAMPLE ( RC_DIALOG_BEGIN + 15)
#define MSG_POOL_STYLE_NAME ( RC_DIALOG_BEGIN + 16)
-#define MSG_OVERWRITE_STYLE ( RC_DIALOG_BEGIN + 17)
#define MSG_TABPAGE_INVALIDPARENT ( RC_DIALOG_BEGIN + 18)
#define STR_DELETE_STYLE ( RC_DIALOG_BEGIN + 18)
#define STR_DELETE_STYLE_USED ( RC_DIALOG_BEGIN + 20)
-#define LOGO_IMAGELIST ( RC_DIALOG_BEGIN + 45)
#define MN_CONTEXT_TEMPLDLG ( RC_DIALOG_BEGIN + 46)
-#define MSG_LAYOUT_NOT_LOADING ( RC_DIALOG_BEGIN + 49)
-#define ACC_LAYOUT_NOT_LOADING ( RC_DIALOG_BEGIN + 50)
-
-#define MSG_ERR_CANT_EDIT_OLD_FORMAT ( RC_DIALOG_BEGIN + 60 )
-#define MSG_ERR_CANT_EDIT_OPEN_DOCS ( RC_DIALOG_BEGIN + 61 )
-
-#define RID_URLOPEN ( RC_DIALOG_BEGIN + 62 )
-#define RID_URLOPEN_OK 1
-#define RID_URLOPEN_CANCEL 2
-#define RID_URLOPEN_URL 3
-
-#define CB_FILE ( RC_DIALOG_BEGIN + 63 )
-#define CB_URL ( RC_DIALOG_BEGIN + 64 )
-
-#define STR_INTERNET ( RC_DIALOG_BEGIN + 65 )
-#define RID_AUTOHIDE ( RC_DIALOG_BEGIN + 66 )
-
-#define DLG_ONLINE_REGISTER ( RC_DIALOG_BEGIN + 68 )
#define DLG_VERSIONS ( RC_DIALOG_BEGIN + 69 )
#define DLG_COMMENTS ( RC_DIALOG_BEGIN + 70 )
-#define RID_REGISTER_DLG ( RC_DIALOG_BEGIN + 73 )
-#define DLG_PHONE_CONFIGURATION ( RC_DIALOG_BEGIN + 74 )
-#define DLG_RECOGNIZER_ENGINEMODE ( RC_DIALOG_BEGIN + 75 )
#define MSG_ERROR_WRONG_CONFIRM ( RC_DIALOG_BEGIN + 76 )
-#define DLG_RECOGNIZER_SPEAKER ( RC_DIALOG_BEGIN + 77 )
#define STR_APPLY ( RC_DIALOG_BEGIN + 87 )
@@ -104,7 +74,6 @@
#define RID_DLG_SEARCH ( RC_DIALOG_BEGIN + 109 )
#define STR_PDF_EXPORT_SEND ( RC_DIALOG_BEGIN + 120 )
-#define STR_RECHECK_DOCUMENT ( RC_DIALOG_BEGIN + 121 )
#define IMG_INFO ( RC_DIALOG_BEGIN + 122 )
#define RID_EDIT_DURATIONS ( RC_DIALOG_BEGIN + 123 )
#define SFX_PB_EDIT ( RC_DIALOG_BEGIN + 124 )
diff --git a/sfx2/source/dialog/dialog.src b/sfx2/source/dialog/dialog.src
index a54d2c340d04..c39425510ae2 100644
--- a/sfx2/source/dialog/dialog.src
+++ b/sfx2/source/dialog/dialog.src
@@ -31,30 +31,6 @@
#include "helpid.hrc"
#include "sfxlocal.hrc"
- // Imageliste fuer die AboutBox
-ImageList LOGO_IMAGELIST
-{
- Prefix = "an";
- MaskColor = Color
- {
- Red = 0xFFFF ;
- Green = 0x0000 ;
- Blue = 0xFFFF ;
- };
- IdList =
- {
- 1 ;
- 2 ;
- 3 ;
- 4 ;
- 5 ;
- 6 ;
- };
- IdCount =
- {
- 6 ;
- };
-};
String STR_RESET
{
Text [ en-US ] = "~Reset" ;
@@ -63,48 +39,6 @@ String STR_APPLY
{
Text [ en-US ] = "Apply";
};
-String STR_INTERNET
-{
- Text [ en-US ] = "(Internet)" ;
-};
-String STR_BASEFMT
-{
- Text [ en-US ] = "Base format" ;
-};
-CheckBox CB_USE_PASSWD
-{
- HelpId = HID_FILEDLG_USE_PASSWD ;
- Text [ en-US ] = "~Password" ;
-};
-CheckBox CB_READ_ONLY
-{
- HelpId = HID_FILEDLG_READ_ONLY ;
- Text [ en-US ] = "~Read-only" ;
-};
-PushButton CB_FILE
-{
- HelpId = HID_FILEDLG_FILE ;
- Text [ en-US ] = "~File System" ;
-};
-PushButton CB_URL
-{
- HelpId = HID_FILEDLG_URL ;
- Text [ en-US ] = "Int~ernet" ;
-};
-PushButton BTN_MANAGER
-{
- HelpId = HID_FILEDLG_MANAGER ;
- Text [ en-US ] = "~Manager..." ;
-};
-PushButton BTN_STANDARD
-{
- HelpId = HID_FILEDLG_STANDARD ;
- Text [ en-US ] = "~Home" ;
-};
-String STR_FILEDLG_INSERT
-{
- Text [ en-US ] = "Insert File" ;
-};
String STR_TABPAGE_MANAGESTYLES
{
Text [ en-US ] = "Organizer" ;
@@ -131,12 +65,6 @@ InfoBox MSG_POOL_STYLE_NAME
{
Message [ en-US ] = "Name already exists as a default Style.\nPlease choose another name." ;
};
-QueryBox MSG_OVERWRITE_STYLE
-{
- Buttons = WB_YES_NO ;
- DefButton = WB_DEF_NO ;
- Message [ en-US ] = "Style already exists. Overwrite?" ;
-};
String STR_DELETE_STYLE
{
Text [ en-US ] = "Do you really want to delete Style $1?" ;
@@ -170,87 +98,15 @@ Menu MN_CONTEXT_TEMPLDLG
};
};
-InfoBox MSG_LAYOUT_NOT_LOADING
-{
- BUTTONS = WB_OK ;
- DEFBUTTON = WB_DEF_OK ;
- Message [ en-US ] = "Loading document without layout." ;
-};
-Accelerator ACC_LAYOUT_NOT_LOADING
-{
- ItemList =
- {
- AcceleratorItem
- {
- Key = KeyCode
- {
- Code = KEY_L ;
- Shift = FALSE ; Modifier1 = TRUE ; Modifier2 = TRUE ;
- };
- Identifier = 1 ;
- };
- };
-};
//------------------------------------------------------------------------
-ErrorBox MSG_ERR_CANT_EDIT_OLD_FORMAT
-{
- Message [ en-US ] = "Cannot edit document info for documents\n in this file format." ;
-};
- //------------------------------------------------------------------------
-ErrorBox MSG_ERR_CANT_EDIT_OPEN_DOCS
-{
- Message [ en-US ] = "Document info of documents\n being currently edited cannot be modified from within the document manager." ;
-};
-ModalDialog RID_URLOPEN
-{
- OutputSize = TRUE ;
- SVLook = TRUE ;
- Size = MAP_APPFONT ( 204 , 44 ) ;
- Moveable = TRUE ;
- Text [ en-US ] = "Enter URL" ;
- Moveable = TRUE ;
- OKButton RID_URLOPEN_OK
- {
- Pos = MAP_APPFONT ( 148 , 6 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- TabStop = TRUE ;
- DefButton = TRUE ;
- };
- CancelButton RID_URLOPEN_CANCEL
- {
- Pos = MAP_APPFONT ( 148 , 24 ) ;
- Size = MAP_APPFONT ( 50 , 14 ) ;
- TabStop = TRUE ;
- };
- Edit RID_URLOPEN_URL
- {
- Border = TRUE ;
- Pos = MAP_APPFONT ( 6 , 16 ) ;
- Size = MAP_APPFONT ( 138 , 12 ) ;
- TabStop = TRUE ;
- Left = TRUE ;
- };
-};
-Menu RID_AUTOHIDE
-{
- ItemList =
- {
- MenuItem
- {
- Identifier = SID_AUTOHIDE ;
- HelpID = SID_AUTOHIDE ;
- Text [ en-US ] = "Hide" ;
- };
- };
-};
-String RID_AUTOHIDE
-{
- Text [ en-US ] = "Don't Hide" ;
-};
String SID_NAVIGATOR
{
Text [ en-US ] = "Navigator";
};
+String SID_TASKPANE
+{
+ Text [ en-US ] = "Task Pane";
+};
ErrorBox MSG_ERROR_WRONG_CONFIRM
{
@@ -264,11 +120,6 @@ String STR_PDF_EXPORT_SEND
Text [ en-US ] = "Send" ;
};
-String STR_RECHECK_DOCUMENT
-{
- Text [ en-US ] = "Recheck Document" ;
-};
-
Image IMG_INFO
{
ImageBitmap = Bitmap
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index f8da760bc12d..0ad62ae1eec1 100755
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -34,6 +34,7 @@
#include <vcl/svapp.hxx>
#include <sfx2/filedlghelper.hxx>
#include <unotools/localedatawrapper.hxx>
+#include <unotools/cmdoptions.hxx>
#include <comphelper/processfactory.hxx>
#include <svl/urihelper.hxx>
#include <unotools/useroptions.hxx>
@@ -121,6 +122,8 @@ const USHORT HI_TYPE = 2;
const USHORT HI_VALUE = 3;
const USHORT HI_ACTION = 4;
+static const char DOCUMENT_SIGNATURE_MENU_CMD[] = "Signature";
+
//------------------------------------------------------------------------
String CreateSizeText( ULONG nSize, BOOL bExtraBytes = TRUE, BOOL bSmartExtraBytes = FALSE );
String CreateSizeText( ULONG nSize, BOOL bExtraBytes, BOOL bSmartExtraBytes )
@@ -860,6 +863,13 @@ SfxDocumentPage::SfxDocumentPage( Window* pParent, const SfxItemSet& rItemSet )
aNewSize.Width() -= nDelta;
aUseUserDataCB.SetSizePixel( aNewSize );
}
+ // See i96288
+ // Check if the document signature command is enabled
+ // on the main list enable/disable the pushbutton accordingly
+ SvtCommandOptions aCmdOptions;
+ if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( DOCUMENT_SIGNATURE_MENU_CMD ) ) ) )
+ aSignatureBtn.Disable();
}
//------------------------------------------------------------------------
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 5270eb5d4207..7d177d0bbfd8 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -57,6 +57,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/types.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/stillreadwriteinteraction.hxx>
#include <tools/urlobj.hxx>
#include <vcl/help.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -542,33 +543,13 @@ void FileDialogHelper_Impl::updateExportButton()
// ------------------------------------------------------------------------
void FileDialogHelper_Impl::updateSelectionBox()
{
- if ( !mbExport )
+ if ( !mbHasSelectionBox )
return;
- // Does the selection box exist?
- bool bSelectionBoxFound = false;
- uno::Reference< XControlInformation > xCtrlInfo( mxFileDlg, UNO_QUERY );
- if ( xCtrlInfo.is() )
- {
- Sequence< ::rtl::OUString > aCtrlList = xCtrlInfo->getSupportedControls();
- sal_uInt32 nCount = aCtrlList.getLength();
- for ( sal_uInt32 nCtrl = 0; nCtrl < nCount; ++nCtrl )
- if ( aCtrlList[ nCtrl ].equalsAscii("SelectionBox") )
- {
- bSelectionBoxFound = true;
- break;
- }
- }
-
- if ( bSelectionBoxFound )
- {
- const SfxFilter* pFilter = getCurentSfxFilter();
- updateExtendedControl(
- ExtendedFilePickerElementIds::CHECKBOX_SELECTION,
- ( mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_SUPPORTSSELECTION ) != 0 ) );
- uno::Reference< XFilePickerControlAccess > xCtrlAccess( mxFileDlg, UNO_QUERY );
- xCtrlAccess->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, makeAny( (sal_Bool)mbSelection ) );
- }
+ const SfxFilter* pFilter = getCurentSfxFilter();
+ mbSelectionFltrEnabled = updateExtendedControl(
+ ExtendedFilePickerElementIds::CHECKBOX_SELECTION,
+ ( mbSelectionEnabled && pFilter && ( pFilter->GetFilterFlags() & SFX_FILTER_SUPPORTSSELECTION ) != 0 ) );
}
// ------------------------------------------------------------------------
@@ -956,6 +937,8 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
mbPwdCheckBoxState = sal_False;
mbSelection = sal_False;
mbSelectionEnabled = sal_True;
+ mbHasSelectionBox = sal_False;
+ mbSelectionFltrEnabled = sal_False;
// default settings
m_nDontFlags = SFX_FILTER_INTERNAL | SFX_FILTER_NOTINFILEDLG | SFX_FILTER_NOTINSTALLED;
@@ -1025,6 +1008,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl(
nTemplateDescription = TemplateDescription::FILESAVE_AUTOEXTENSION_SELECTION;
mbHasAutoExt = sal_True;
mbIsSaveDlg = sal_True;
+ mbHasSelectionBox = sal_True;
if ( mbExport && !mxFilterCFG.is() && xFactory.is() )
{
mxFilterCFG = uno::Reference< XNameAccess >(
@@ -2073,6 +2057,21 @@ void FileDialogHelper_Impl::saveConfig()
}
}
+ if( mbHasSelectionBox && mbSelectionFltrEnabled )
+ {
+ try
+ {
+ aValue = xDlg->getValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0 );
+ sal_Bool bSelection = sal_True;
+ aValue >>= bSelection;
+ if ( aUserData.GetTokenCount(' ') < 3 )
+ aUserData.Append(' ');
+ aUserData.SetToken( 2, ' ', String::CreateFromInt32( (sal_Int32) bSelection ) );
+ bWriteConfig = sal_True;
+ }
+ catch( IllegalArgumentException ){}
+ }
+
if ( bWriteConfig )
aDlgOpt.SetUserItem( USERITEM_NAME, makeAny( OUString( aUserData ) ) );
}
@@ -2206,6 +2205,17 @@ void FileDialogHelper_Impl::loadConfig()
catch( IllegalArgumentException ){}
}
+ if( mbHasSelectionBox )
+ {
+ sal_Int32 nFlag = aUserData.GetToken( 2, ' ' ).ToInt32();
+ aValue <<= (sal_Bool) nFlag;
+ try
+ {
+ xDlg->setValue( ExtendedFilePickerElementIds::CHECKBOX_SELECTION, 0, aValue );
+ }
+ catch( IllegalArgumentException ){}
+ }
+
if ( !maPath.getLength() )
displayFolder( SvtPathOptions().GetWorkPath() );
}
@@ -2664,10 +2674,12 @@ static int impl_isFolder( const OUString& rPath )
{
}
+ ::rtl::Reference< ::comphelper::StillReadWriteInteraction > aHandler = new ::comphelper::StillReadWriteInteraction( xHandler );
+
try
{
::ucbhelper::Content aContent(
- rPath, new ::ucbhelper::CommandEnvironment( xHandler, uno::Reference< ucb::XProgressHandler >() ) );
+ rPath, new ::ucbhelper::CommandEnvironment( static_cast< task::XInteractionHandler* > ( aHandler.get() ), uno::Reference< ucb::XProgressHandler >() ) );
if ( aContent.isFolder() )
return 1;
diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx
index b023b8fb53a9..6965e14ae84d 100644
--- a/sfx2/source/dialog/filedlgimpl.hxx
+++ b/sfx2/source/dialog/filedlgimpl.hxx
@@ -107,6 +107,8 @@ namespace sfx2
sal_Bool mbPwdCheckBoxState : 1;
sal_Bool mbSelection : 1;
sal_Bool mbSelectionEnabled : 1;
+ sal_Bool mbHasSelectionBox : 1;
+ sal_Bool mbSelectionFltrEnabled : 1;
private:
void addFilters( sal_Int64 nFlags,
diff --git a/sfx2/source/dialog/makefile.mk b/sfx2/source/dialog/makefile.mk
index b344170fd39c..4c56cd683e34 100755
--- a/sfx2/source/dialog/makefile.mk
+++ b/sfx2/source/dialog/makefile.mk
@@ -45,7 +45,8 @@ EXCEPTIONSFILES=\
$(SLO)$/recfloat.obj \
$(SLO)$/templdlg.obj \
$(SLO)$/dinfdlg.obj \
- $(SLO)$/dockwin.obj
+ $(SLO)$/dockwin.obj \
+ $(SLO)$/taskpane.obj
SLOFILES =\
$(EXCEPTIONSFILES) \
@@ -60,7 +61,6 @@ SLOFILES =\
$(SLO)$/passwd.obj \
$(SLO)$/printopt.obj \
$(SLO)$/sfxdlg.obj \
- $(SLO)$/sfxurl.obj \
$(SLO)$/splitwin.obj \
$(SLO)$/srchdlg.obj \
$(SLO)$/styfitem.obj \
@@ -69,7 +69,8 @@ SLOFILES =\
$(SLO)$/tplcitem.obj \
$(SLO)$/tplpitem.obj \
$(SLO)$/versdlg.obj \
- $(SLO)$/securitypage.obj
+ $(SLO)$/securitypage.obj \
+ $(SLO)$/titledockwin.obj
SRS1NAME=$(TARGET)
SRC1FILES =\
@@ -87,7 +88,9 @@ SRC1FILES =\
versdlg.src \
printopt.src \
srchdlg.src \
- securitypage.src
+ securitypage.src \
+ titledockwin.src \
+ taskpane.src
.IF "$(BUILD_VER_STRING)"!=""
.IF "$(GUI)"=="UNX"
@@ -104,9 +107,9 @@ CFLAGS+=-DBUILD_VER_STRING="$(subst,",\" "$(BUILD_VER_STRING)")"
$(INCCOM)$/cuilib.hxx: makefile.mk
.IF "$(GUI)"=="UNX"
$(RM) $@
- echo \#define DLL_NAME \"libcui$(DLLPOSTFIX)$(DLLPOST)\" >$@
+ @echo \#define DLL_NAME \"libcui$(DLLPOSTFIX)$(DLLPOST)\" >$@
.ELSE
- echo $(EMQ)#define DLL_NAME $(EMQ)"cui$(DLLPOSTFIX)$(DLLPOST)$(EMQ)" >$@
+ @echo $(EMQ)#define DLL_NAME $(EMQ)"cui$(DLLPOSTFIX)$(DLLPOST)$(EMQ)" >$@
.ENDIF
$(SLO)$/sfxdlg.obj : $(INCCOM)$/cuilib.hxx
diff --git a/sfx2/source/dialog/taskpane.cxx b/sfx2/source/dialog/taskpane.cxx
new file mode 100644
index 000000000000..f25485a1401c
--- /dev/null
+++ b/sfx2/source/dialog/taskpane.cxx
@@ -0,0 +1,1283 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "sfx2/taskpane.hxx"
+#include "imagemgr.hxx"
+#include "sfx2/sfxsids.hrc"
+#include "sfx2/bindings.hxx"
+#include "sfx2/dispatch.hxx"
+#include "sfxresid.hxx"
+#include "sfxlocal.hrc"
+#include "helpid.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/ui/XToolPanel.hpp>
+#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/processfactory.hxx>
+#include <tools/diagnose_ex.h>
+#include <svtools/toolpanel/toolpaneldeck.hxx>
+#include <svtools/toolpanel/tablayouter.hxx>
+#include <svtools/toolpanel/drawerlayouter.hxx>
+#include <unotools/confignode.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <boost/noncopyable.hpp>
+
+//......................................................................................................................
+namespace sfx2
+{
+//......................................................................................................................
+
+ /** === 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::XModuleManager;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::ui::XToolPanel;
+ using ::com::sun::star::ui::XUIElementFactory;
+ using ::com::sun::star::ui::XUIElement;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::frame::XModuleManager;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::graphic::XGraphicProvider;
+ using ::com::sun::star::graphic::XGraphic;
+ using ::com::sun::star::accessibility::XAccessible;
+ using ::com::sun::star::awt::XControl;
+ /** === end UNO using === **/
+ namespace PosSize = ::com::sun::star::awt::PosSize;
+
+ //==================================================================================================================
+ //= helpers
+ //==================================================================================================================
+ namespace
+ {
+ //--------------------------------------------------------------------------------------------------------------
+ ::utl::OConfigurationTreeRoot lcl_getModuleUIElementStatesConfig( const ::rtl::OUString& i_rModuleIdentifier,
+ const ::rtl::OUString& i_rResourceURL = ::rtl::OUString() )
+ {
+ const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ ::rtl::OUStringBuffer aPathComposer;
+ try
+ {
+ const Reference< XNameAccess > xModuleAccess( aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+ const ::comphelper::NamedValueCollection aModuleProps( xModuleAccess->getByName( i_rModuleIdentifier ) );
+
+ const ::rtl::OUString sWindowStateRef( aModuleProps.getOrDefault( "ooSetupFactoryWindowStateConfigRef", ::rtl::OUString() ) );
+
+ aPathComposer.appendAscii( "org.openoffice.Office.UI." );
+ aPathComposer.append( sWindowStateRef );
+ aPathComposer.appendAscii( "/UIElements/States" );
+ if ( i_rResourceURL.getLength() )
+ {
+ aPathComposer.appendAscii( "/" );
+ aPathComposer.append( i_rResourceURL );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return ::utl::OConfigurationTreeRoot( aContext, aPathComposer.makeStringAndClear(), false );
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString lcl_identifyModule( const Reference< XFrame >& i_rDocumentFrame )
+ {
+ ::rtl::OUString sModuleName;
+ try
+ {
+ const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ const Reference< XModuleManager > xModuleManager( aContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW );
+ sModuleName = xModuleManager->identify( i_rDocumentFrame );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sModuleName;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ Reference< XFrame > lcl_getFrame( const SfxBindings* i_pBindings )
+ {
+ const SfxViewFrame* pViewFrame = i_pBindings->GetDispatcher()->GetFrame();
+ const SfxFrame& rFrame = pViewFrame->GetFrame();
+ const Reference< XFrame > xFrame( rFrame.GetFrameInterface() );
+ return xFrame;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString lcl_getPanelHelpURL( const ::utl::OConfigurationNode& i_rPanelConfigNode )
+ {
+ const ::rtl::OUString sHelpURL( ::comphelper::getString( i_rPanelConfigNode.getNodeValue( "HelpURL" ) ) );
+ return sHelpURL;
+ }
+
+ //--------------------------------------------------------------------------------------------------------------
+ Image lcl_getPanelImage( const Reference< XFrame >& i_rDocFrame, const ::utl::OConfigurationNode& i_rPanelConfigNode )
+ {
+ const ::rtl::OUString sImageURL( ::comphelper::getString( i_rPanelConfigNode.getNodeValue( "ImageURL" ) ) );
+ if ( sImageURL.getLength() )
+ {
+ try
+ {
+ ::comphelper::NamedValueCollection aMediaProperties;
+ aMediaProperties.put( "URL", sImageURL );
+
+ // special handling: if the ImageURL denotes a CommandName, then retrieve the image for that command
+ const sal_Char* pCommandImagePrefix = "private:commandimage/";
+ const sal_Int32 nCommandImagePrefixLen = strlen( pCommandImagePrefix );
+ if ( sImageURL.compareToAscii( pCommandImagePrefix, nCommandImagePrefixLen ) == 0 )
+ {
+ ::rtl::OUStringBuffer aCommandName;
+ aCommandName.appendAscii( ".uno:" );
+ aCommandName.append( sImageURL.copy( nCommandImagePrefixLen ) );
+ const ::rtl::OUString sCommandName( aCommandName.makeStringAndClear() );
+
+ const BOOL bHiContrast( Application::GetSettings().GetStyleSettings().GetHighContrastMode() );
+ const Image aPanelImage( GetImage( i_rDocFrame, sCommandName, FALSE, bHiContrast ) );
+ return aPanelImage.GetXGraphic();
+ }
+
+ // otherwise, delegate to the GraphicProvider
+ const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ const Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW );
+
+ const Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties.getPropertyValues() ), UNO_SET_THROW );
+ return Image( xGraphic );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return Image();
+ }
+ }
+
+ //==================================================================================================================
+ //= TaskPaneDockingWindow
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneDockingWindow::TaskPaneDockingWindow( SfxBindings* i_pBindings, TaskPaneWrapper& i_rWrapper, Window* i_pParent, WinBits i_nBits )
+ :TitledDockingWindow( i_pBindings, &i_rWrapper, i_pParent, i_nBits )
+ ,m_aTaskPane( GetContentWindow(), lcl_getFrame( i_pBindings ) )
+ ,m_aPaneController( m_aTaskPane, *this )
+ {
+ m_aTaskPane.Show();
+ SetText( String( SfxResId( SID_TASKPANE ) ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneDockingWindow::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
+ {
+ m_aPaneController.ActivateToolPanel( i_rPanelURL );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneDockingWindow::GetFocus()
+ {
+ TitledDockingWindow::GetFocus();
+ m_aTaskPane.GrabFocus();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneDockingWindow::onLayoutDone()
+ {
+ m_aTaskPane.SetPosSizePixel( Point(), GetContentWindow().GetOutputSizePixel() );
+ }
+
+ //==================================================================================================================
+ //= TaskPaneWrapper
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ SFX_IMPL_DOCKINGWINDOW( TaskPaneWrapper, SID_TASKPANE );
+
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneWrapper::TaskPaneWrapper( Window* i_pParent, USHORT i_nId, SfxBindings* i_pBindings, SfxChildWinInfo* i_pInfo )
+ :SfxChildWindow( i_pParent, i_nId )
+ {
+ pWindow = new TaskPaneDockingWindow( i_pBindings, *this, i_pParent,
+ WB_STDDOCKWIN | WB_CLIPCHILDREN | WB_SIZEABLE | WB_3DLOOK | WB_ROLLABLE);
+ eChildAlignment = SFX_ALIGN_RIGHT;
+
+ pWindow->SetHelpId( HID_TASKPANE_WINDOW );
+ pWindow->SetOutputSizePixel( Size( 300, 450 ) );
+ pWindow->Show();
+
+ dynamic_cast< SfxDockingWindow* >( pWindow )->Initialize( i_pInfo );
+ SetHideNotDelete( TRUE );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneWrapper::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
+ {
+ TaskPaneDockingWindow* pDockingWindow = dynamic_cast< TaskPaneDockingWindow* >( GetWindow() );
+ ENSURE_OR_RETURN_VOID( pDockingWindow, "TaskPaneWrapper::ActivateToolPanel: invalid docking window implementation!" );
+ pDockingWindow->ActivateToolPanel( i_rPanelURL );
+ }
+
+ //==================================================================================================================
+ //= CustomPanelUIElement
+ //==================================================================================================================
+ class CustomPanelUIElement
+ {
+ public:
+ CustomPanelUIElement()
+ :m_xUIElement()
+ ,m_xToolPanel()
+ ,m_xPanelWindow()
+ {
+ }
+
+ CustomPanelUIElement( const Reference< XUIElement >& i_rUIElement )
+ :m_xUIElement( i_rUIElement, UNO_SET_THROW )
+ ,m_xToolPanel( i_rUIElement->getRealInterface(), UNO_QUERY_THROW )
+ ,m_xPanelWindow( m_xToolPanel->getWindow(), UNO_SET_THROW )
+ {
+ }
+
+ bool is() const { return m_xPanelWindow.is(); }
+
+ const Reference< XUIElement >& getUIElement() const { return m_xUIElement; }
+ const Reference< XToolPanel >& getToolPanel() const { return m_xToolPanel; }
+ const Reference< XWindow >& getPanelWindow() const { return m_xPanelWindow; }
+
+ private:
+ Reference< XUIElement > m_xUIElement;
+ Reference< XToolPanel > m_xToolPanel;
+ Reference< XWindow > m_xPanelWindow;
+ };
+
+ //==================================================================================================================
+ //= CustomToolPanel
+ //==================================================================================================================
+ class CustomToolPanel : public ::svt::ToolPanelBase
+ {
+ public:
+ CustomToolPanel( const ::utl::OConfigurationNode& i_rPanelWindowState, const Reference< XFrame >& i_rFrame );
+
+ virtual ::rtl::OUString GetDisplayName() const;
+ virtual Image GetImage() const;
+ virtual SmartId GetHelpID() const;
+ virtual void Activate( Window& i_rParentWindow );
+ virtual void Deactivate();
+ virtual void SetSizePixel( const Size& i_rPanelWindowSize );
+ virtual void GrabFocus();
+ virtual void Dispose();
+ virtual Reference< XAccessible >
+ CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible );
+
+ const ::rtl::OUString&
+ GetResourceURL() const { return m_sResourceURL; }
+
+ protected:
+ ~CustomToolPanel();
+
+ private:
+ bool impl_ensureToolPanelWindow( Window& i_rPanelParentWindow );
+ void impl_updatePanelConfig( const bool i_bVisible ) const;
+
+ private:
+ const ::rtl::OUString m_sUIName;
+ const Image m_aPanelImage;
+ const ::rtl::OUString m_aPanelHelpURL;
+ const ::rtl::OUString m_sResourceURL;
+ const ::rtl::OUString m_sPanelConfigPath;
+ Reference< XFrame > m_xFrame;
+ CustomPanelUIElement m_aCustomPanel;
+ bool m_bAttemptedCreation;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ CustomToolPanel::CustomToolPanel( const ::utl::OConfigurationNode& i_rPanelWindowState, const Reference< XFrame >& i_rFrame )
+ :m_sUIName( ::comphelper::getString( i_rPanelWindowState.getNodeValue( "UIName" ) ) )
+ ,m_aPanelImage( lcl_getPanelImage( i_rFrame, i_rPanelWindowState ) )
+ ,m_aPanelHelpURL( lcl_getPanelHelpURL( i_rPanelWindowState ) )
+ ,m_sResourceURL( i_rPanelWindowState.getLocalName() )
+ ,m_sPanelConfigPath( i_rPanelWindowState.getNodePath() )
+ ,m_xFrame( i_rFrame )
+ ,m_aCustomPanel()
+ ,m_bAttemptedCreation( false )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ CustomToolPanel::~CustomToolPanel()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool CustomToolPanel::impl_ensureToolPanelWindow( Window& i_rPanelParentWindow )
+ {
+ if ( m_bAttemptedCreation )
+ return m_aCustomPanel.is();
+
+ m_bAttemptedCreation = true;
+ try
+ {
+ const ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ const Reference< XUIElementFactory > xFactory( aContext.createComponent( "com.sun.star.ui.UIElementFactoryManager" ), UNO_QUERY_THROW );
+
+ ::comphelper::NamedValueCollection aCreationArgs;
+ aCreationArgs.put( "Frame", makeAny( m_xFrame ) );
+ aCreationArgs.put( "ParentWindow", makeAny( i_rPanelParentWindow.GetComponentInterface() ) );
+
+ const Reference< XUIElement > xElement(
+ xFactory->createUIElement( m_sResourceURL, aCreationArgs.getPropertyValues() ),
+ UNO_SET_THROW );
+
+ m_aCustomPanel = CustomPanelUIElement( xElement );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return m_aCustomPanel.is();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::impl_updatePanelConfig( const bool i_bVisible ) const
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ ::utl::OConfigurationTreeRoot aConfig( aContext, m_sPanelConfigPath, true );
+
+ aConfig.setNodeValue( "Visible", makeAny( i_bVisible ) );
+ aConfig.commit();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString CustomToolPanel::GetDisplayName() const
+ {
+ return m_sUIName;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Image CustomToolPanel::GetImage() const
+ {
+ return m_aPanelImage;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ SmartId CustomToolPanel::GetHelpID() const
+ {
+ return SmartId( m_aPanelHelpURL );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::Activate( Window& i_rParentWindow )
+ {
+ ENSURE_OR_RETURN_VOID( impl_ensureToolPanelWindow( i_rParentWindow ), "no panel to activate!" );
+
+ // TODO: we might need a mechanism to decide whether the panel should be destroyed/re-created, or (as it is
+ // done now) hidden/shown
+ m_aCustomPanel.getPanelWindow()->setVisible( sal_True );
+
+ // update the panel's configuration
+ impl_updatePanelConfig( true );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::Deactivate()
+ {
+ ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel to deactivate!" );
+
+ m_aCustomPanel.getPanelWindow()->setVisible( sal_False );
+
+ // update the panel's configuration
+ impl_updatePanelConfig( false );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::SetSizePixel( const Size& i_rPanelWindowSize )
+ {
+ ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel/window to position!" );
+
+ try
+ {
+ m_aCustomPanel.getPanelWindow()->setPosSize( 0, 0, i_rPanelWindowSize.Width(), i_rPanelWindowSize.Height(),
+ PosSize::POSSIZE );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::GrabFocus()
+ {
+ ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel/window to focus!" );
+
+ m_aCustomPanel.getPanelWindow()->setFocus();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void CustomToolPanel::Dispose()
+ {
+ if ( !m_bAttemptedCreation )
+ // nothing to dispose
+ return;
+
+ ENSURE_OR_RETURN_VOID( m_aCustomPanel.is(), "no panel to destroy!" );
+ try
+ {
+ Reference< XComponent > xUIElementComponent( m_aCustomPanel.getUIElement(), UNO_QUERY_THROW );
+ xUIElementComponent->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XAccessible > CustomToolPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible )
+ {
+ ENSURE_OR_RETURN( m_aCustomPanel.is(), "no panel to ask!", NULL );
+
+ Reference< XAccessible > xPanelAccessible;
+ try
+ {
+ xPanelAccessible.set( m_aCustomPanel.getToolPanel()->createAccessible( i_rParentAccessible ), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xPanelAccessible;
+ }
+
+ //==================================================================================================================
+ //= ModuleTaskPane_Impl
+ //==================================================================================================================
+ class ModuleTaskPane_Impl : public ::boost::noncopyable
+ {
+ public:
+ ModuleTaskPane_Impl( ModuleTaskPane& i_rAntiImpl, const Reference< XFrame >& i_rDocumentFrame,
+ const IToolPanelCompare* i_pPanelCompare )
+ :m_rAntiImpl( i_rAntiImpl )
+ ,m_sModuleIdentifier( lcl_identifyModule( i_rDocumentFrame ) )
+ ,m_xFrame( i_rDocumentFrame )
+ ,m_aPanelDeck( i_rAntiImpl )
+ {
+ m_aPanelDeck.Show();
+ OnResize();
+ impl_initFromConfiguration( i_pPanelCompare );
+ }
+
+ ~ModuleTaskPane_Impl()
+ {
+ }
+
+ void OnResize();
+ void OnGetFocus();
+
+ static bool ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier );
+
+ ::svt::ToolPanelDeck& GetPanelDeck() { return m_aPanelDeck; }
+ const ::svt::ToolPanelDeck& GetPanelDeck() const { return m_aPanelDeck; }
+
+ ::boost::optional< size_t >
+ GetPanelPos( const ::rtl::OUString& i_rResourceURL );
+ ::rtl::OUString
+ GetPanelResourceURL( const size_t i_nPanelPos ) const;
+
+ void SetDrawersLayout();
+ void SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent );
+
+ private:
+ void impl_initFromConfiguration( const IToolPanelCompare* i_pPanelCompare );
+
+ static bool
+ impl_isToolPanelResource( const ::rtl::OUString& i_rResourceURL );
+
+ DECL_LINK( OnActivatePanel, void* );
+
+ private:
+ ModuleTaskPane& m_rAntiImpl;
+ const ::rtl::OUString m_sModuleIdentifier;
+ const Reference< XFrame > m_xFrame;
+ ::svt::ToolPanelDeck m_aPanelDeck;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane_Impl::OnResize()
+ {
+ m_aPanelDeck.SetPosSizePixel( Point(), m_rAntiImpl.GetOutputSizePixel() );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane_Impl::OnGetFocus()
+ {
+ m_aPanelDeck.GrabFocus();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( ModuleTaskPane_Impl, OnActivatePanel, void*, i_pArg )
+ {
+ m_aPanelDeck.ActivatePanel( reinterpret_cast< size_t >( i_pArg ) );
+ return 1L;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool ModuleTaskPane_Impl::impl_isToolPanelResource( const ::rtl::OUString& i_rResourceURL )
+ {
+ return i_rResourceURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/" ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane_Impl::impl_initFromConfiguration( const IToolPanelCompare* i_pPanelCompare )
+ {
+ const ::utl::OConfigurationTreeRoot aWindowStateConfig( lcl_getModuleUIElementStatesConfig( m_sModuleIdentifier ) );
+ if ( !aWindowStateConfig.isValid() )
+ return;
+
+ ::rtl::OUString sFirstVisiblePanelResource;
+
+ const Sequence< ::rtl::OUString > aUIElements( aWindowStateConfig.getNodeNames() );
+ for ( const ::rtl::OUString* resource = aUIElements.getConstArray();
+ resource != aUIElements.getConstArray() + aUIElements.getLength();
+ ++resource
+ )
+ {
+ if ( !impl_isToolPanelResource( *resource ) )
+ continue;
+
+ ::utl::OConfigurationNode aResourceNode( aWindowStateConfig.openNode( *resource ) );
+ ::svt::PToolPanel pCustomPanel( new CustomToolPanel( aResourceNode, m_xFrame ) );
+
+ size_t nPanelPos = m_aPanelDeck.GetPanelCount();
+ if ( i_pPanelCompare )
+ {
+ // assuming that nobody will insert hundreths of panels, a simple O(n) search should suffice here ...
+ while ( nPanelPos > 0 )
+ {
+ const short nCompare = i_pPanelCompare->compareToolPanelsURLs(
+ *resource,
+ GetPanelResourceURL( --nPanelPos )
+ );
+ if ( nCompare >= 0 )
+ {
+ ++nPanelPos;
+ break;
+ }
+ }
+ }
+ nPanelPos = m_aPanelDeck.InsertPanel( pCustomPanel, nPanelPos );
+
+ if ( ::comphelper::getBOOL( aResourceNode.getNodeValue( "Visible" ) ) )
+ sFirstVisiblePanelResource = *resource;
+ }
+
+ if ( sFirstVisiblePanelResource.getLength() )
+ {
+ ::boost::optional< size_t > aPanelPos( GetPanelPos( sFirstVisiblePanelResource ) );
+ OSL_ENSURE( !!aPanelPos, "ModuleTaskPane_Impl::impl_isToolPanelResource: just inserted it, and it's not there?!" );
+ if ( !!aPanelPos )
+ m_rAntiImpl.PostUserEvent( LINK( this, ModuleTaskPane_Impl, OnActivatePanel ), reinterpret_cast< void* >( *aPanelPos ) );
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool ModuleTaskPane_Impl::ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier )
+ {
+ const ::utl::OConfigurationTreeRoot aWindowStateConfig( lcl_getModuleUIElementStatesConfig( i_rModuleIdentifier ) );
+ if ( !aWindowStateConfig.isValid() )
+ return false;
+
+ const Sequence< ::rtl::OUString > aUIElements( aWindowStateConfig.getNodeNames() );
+ for ( const ::rtl::OUString* resource = aUIElements.getConstArray();
+ resource != aUIElements.getConstArray() + aUIElements.getLength();
+ ++resource
+ )
+ {
+ if ( impl_isToolPanelResource( *resource ) )
+ return true;
+ }
+ return false;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< size_t > ModuleTaskPane_Impl::GetPanelPos( const ::rtl::OUString& i_rResourceURL )
+ {
+ ::boost::optional< size_t > aPanelPos;
+ for ( size_t i = 0; i < m_aPanelDeck.GetPanelCount(); ++i )
+ {
+ const ::svt::PToolPanel pPanel( m_aPanelDeck.GetPanel( i ) );
+ const CustomToolPanel* pCustomPanel = dynamic_cast< const CustomToolPanel* >( pPanel.get() );
+ ENSURE_OR_CONTINUE( pCustomPanel != NULL, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!" );
+ if ( pCustomPanel->GetResourceURL() == i_rResourceURL )
+ {
+ aPanelPos = i;
+ break;
+ }
+ }
+ return aPanelPos;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString ModuleTaskPane_Impl::GetPanelResourceURL( const size_t i_nPanelPos ) const
+ {
+ ENSURE_OR_RETURN( i_nPanelPos < m_aPanelDeck.GetPanelCount(), "ModuleTaskPane_Impl::GetPanelResourceURL: illegal panel position!", ::rtl::OUString() );
+ const ::svt::PToolPanel pPanel( m_aPanelDeck.GetPanel( i_nPanelPos ) );
+ const CustomToolPanel* pCustomPanel = dynamic_cast< const CustomToolPanel* >( pPanel.get() );
+ ENSURE_OR_RETURN( pCustomPanel != NULL, "ModuleTaskPane_Impl::GetPanelPos: illegal panel implementation!", ::rtl::OUString() );
+ return pCustomPanel->GetResourceURL();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane_Impl::SetDrawersLayout()
+ {
+ const ::svt::PDeckLayouter pLayouter( m_aPanelDeck.GetLayouter() );
+ const ::svt::DrawerDeckLayouter* pDrawerLayouter = dynamic_cast< const ::svt::DrawerDeckLayouter* >( pLayouter.get() );
+ if ( pDrawerLayouter != NULL )
+ // already have the proper layout
+ return;
+ m_aPanelDeck.SetLayouter( new ::svt::DrawerDeckLayouter( m_aPanelDeck, m_aPanelDeck ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane_Impl::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent )
+ {
+ ::svt::PDeckLayouter pLayouter( m_aPanelDeck.GetLayouter() );
+ ::svt::TabDeckLayouter* pTabLayouter = dynamic_cast< ::svt::TabDeckLayouter* >( pLayouter.get() );
+ if ( ( pTabLayouter != NULL )
+ && ( pTabLayouter->GetTabAlignment() == i_eTabAlignment )
+ && ( pTabLayouter->GetTabItemContent() == i_eTabContent )
+ )
+ // already have the requested layout
+ return;
+
+ if ( pTabLayouter && ( pTabLayouter->GetTabAlignment() == i_eTabAlignment ) )
+ {
+ // changing only the item content does not require a new layouter instance
+ pTabLayouter->SetTabItemContent( i_eTabContent );
+ return;
+ }
+
+ m_aPanelDeck.SetLayouter( new ::svt::TabDeckLayouter( m_aPanelDeck, m_aPanelDeck, i_eTabAlignment, i_eTabContent ) );
+ }
+
+ //==================================================================================================================
+ //= ModuleTaskPane
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ ModuleTaskPane::ModuleTaskPane( Window& i_rParentWindow, const Reference< XFrame >& i_rDocumentFrame )
+ :Window( &i_rParentWindow, WB_DIALOGCONTROL )
+ ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame, NULL ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ModuleTaskPane::ModuleTaskPane( Window& i_rParentWindow, const Reference< XFrame >& i_rDocumentFrame,
+ const IToolPanelCompare& i_rCompare )
+ :Window( &i_rParentWindow, WB_DIALOGCONTROL )
+ ,m_pImpl( new ModuleTaskPane_Impl( *this, i_rDocumentFrame, &i_rCompare ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ModuleTaskPane::~ModuleTaskPane()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool ModuleTaskPane::ModuleHasToolPanels( const ::rtl::OUString& i_rModuleIdentifier )
+ {
+ return ModuleTaskPane_Impl::ModuleHasToolPanels( i_rModuleIdentifier );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ bool ModuleTaskPane::ModuleHasToolPanels( const Reference< XFrame >& i_rDocumentFrame )
+ {
+ return ModuleTaskPane_Impl::ModuleHasToolPanels( lcl_identifyModule( i_rDocumentFrame ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane::Resize()
+ {
+ Window::Resize();
+ m_pImpl->OnResize();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane::GetFocus()
+ {
+ Window::GetFocus();
+ m_pImpl->OnGetFocus();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::svt::ToolPanelDeck& ModuleTaskPane::GetPanelDeck()
+ {
+ return m_pImpl->GetPanelDeck();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ const ::svt::ToolPanelDeck& ModuleTaskPane::GetPanelDeck() const
+ {
+ return m_pImpl->GetPanelDeck();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::boost::optional< size_t > ModuleTaskPane::GetPanelPos( const ::rtl::OUString& i_rResourceURL )
+ {
+ return m_pImpl->GetPanelPos( i_rResourceURL );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString ModuleTaskPane::GetPanelResourceURL( const size_t i_nPanelPos ) const
+ {
+ return m_pImpl->GetPanelResourceURL( i_nPanelPos );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane::SetDrawersLayout()
+ {
+ m_pImpl->SetDrawersLayout();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void ModuleTaskPane::SetTabsLayout( const ::svt::TabAlignment i_eTabAlignment, const ::svt::TabItemContent i_eTabContent )
+ {
+ m_pImpl->SetTabsLayout( i_eTabAlignment, i_eTabContent );
+ }
+
+ // =====================================================================================================================
+ // = PanelSelectorLayout
+ // =====================================================================================================================
+ enum PanelSelectorLayout
+ {
+ LAYOUT_DRAWERS,
+ LAYOUT_TABS_RIGHT,
+ LAYOUT_TABS_LEFT,
+ LAYOUT_TABS_TOP,
+ LAYOUT_TABS_BOTTOM
+ };
+
+ //==================================================================================================================
+ //= helper
+ //==================================================================================================================
+ namespace
+ {
+ PanelSelectorLayout lcl_getTabLayoutFromAlignment( const SfxChildAlignment i_eAlignment )
+ {
+ switch ( i_eAlignment )
+ {
+ case SFX_ALIGN_LEFT:
+ return LAYOUT_TABS_LEFT;
+ case SFX_ALIGN_TOP:
+ return LAYOUT_TABS_TOP;
+ case SFX_ALIGN_BOTTOM:
+ return LAYOUT_TABS_BOTTOM;
+ default:
+ return LAYOUT_TABS_RIGHT;
+ }
+ }
+ }
+
+ // =====================================================================================================================
+ // = PanelDescriptor
+ // =====================================================================================================================
+ /** is a helper class for TaskPaneController_Impl, holding the details about a single panel which is not
+ contained in the IToolPanel implementation itself.
+ */
+ struct PanelDescriptor
+ {
+ ::svt::PToolPanel pPanel;
+ bool bHidden;
+
+ PanelDescriptor()
+ :pPanel()
+ ,bHidden( false )
+ {
+ }
+
+ PanelDescriptor( const ::svt::PToolPanel& i_rPanel )
+ :pPanel( i_rPanel )
+ ,bHidden( false )
+ {
+ }
+ };
+
+ //==================================================================================================================
+ //= TaskPaneController_Impl
+ //==================================================================================================================
+ class TaskPaneController_Impl :public ::boost::noncopyable
+ ,public ::svt::IToolPanelDeckListener
+ {
+ public:
+ TaskPaneController_Impl(
+ ModuleTaskPane& i_rTaskPane,
+ TitledDockingWindow& i_rDockingWindow
+ );
+ ~TaskPaneController_Impl();
+
+ void SetDefaultTitle( const String& i_rTitle );
+ void ActivateToolPanel( const ::rtl::OUString& i_rPanelURL );
+
+ protected:
+ // 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();
+
+ private:
+ DECL_LINK( OnToolboxClicked, ToolBox* );
+ DECL_LINK( OnMenuItemSelected, Menu* );
+ DECL_LINK( DockingChanged, TitledDockingWindow* );
+ ::std::auto_ptr< PopupMenu > impl_createPopupMenu() const;
+
+ /// sets the given layout for the panel selector
+ void impl_setLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce = false );
+
+ /// returns the current layout of the panel selector
+ PanelSelectorLayout
+ impl_getLayout() const { return m_eCurrentLayout; }
+
+ void impl_updateDockingWindowTitle();
+ void impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex );
+ size_t impl_getLogicalPanelIndex( const size_t i_nVisibleIndex );
+
+ private:
+ enum MenuId
+ {
+ MID_UNLOCK_TASK_PANEL = 1,
+ MID_LOCK_TASK_PANEL = 2,
+ MID_LAYOUT_TABS = 3,
+ MID_LAYOUT_DRAWERS = 4,
+ MID_FIRST_PANEL = 5
+ };
+
+ private:
+ typedef ::std::vector< PanelDescriptor > PanelDescriptors;
+
+ ModuleTaskPane& m_rTaskPane;
+ TitledDockingWindow& m_rDockingWindow;
+ USHORT m_nViewMenuID;
+ PanelSelectorLayout m_eCurrentLayout;
+ PanelDescriptors m_aPanelRepository;
+ bool m_bTogglingPanelVisibility;
+ ::rtl::OUString m_sDefaultTitle;
+ };
+
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneController_Impl::TaskPaneController_Impl( ModuleTaskPane& i_rTaskPane, TitledDockingWindow& i_rDockingWindow )
+ :m_rTaskPane( i_rTaskPane )
+ ,m_rDockingWindow( i_rDockingWindow )
+ ,m_nViewMenuID( 0 )
+ ,m_eCurrentLayout( LAYOUT_DRAWERS )
+ ,m_aPanelRepository()
+ ,m_bTogglingPanelVisibility( false )
+ ,m_sDefaultTitle()
+ {
+ m_rDockingWindow.ResetToolBox();
+ m_nViewMenuID = m_rDockingWindow.AddDropDownToolBoxItem(
+ String( SfxResId( STR_SFX_TASK_PANE_VIEW ) ),
+ HID_TASKPANE_VIEW_MENU,
+ LINK( this, TaskPaneController_Impl, OnToolboxClicked )
+ );
+ m_rDockingWindow.SetEndDockingHdl( LINK( this, TaskPaneController_Impl, DockingChanged ) );
+ impl_setLayout( LAYOUT_DRAWERS, true );
+
+ m_rTaskPane.GetPanelDeck().AddListener( *this );
+
+ // initialize the panel repository
+ for ( size_t i = 0; i < m_rTaskPane.GetPanelDeck().GetPanelCount(); ++i )
+ {
+ ::svt::PToolPanel pPanel( m_rTaskPane.GetPanelDeck().GetPanel( i ) );
+ m_aPanelRepository.push_back( PanelDescriptor( pPanel ) );
+ }
+
+ SetDefaultTitle( String( SfxResId( STR_SFX_TASKS ) ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneController_Impl::~TaskPaneController_Impl()
+ {
+ m_rTaskPane.GetPanelDeck().RemoveListener( *this );
+
+ // remove the panels which are not under the control of the panel deck currently
+ for ( PanelDescriptors::iterator panelPos = m_aPanelRepository.begin();
+ panelPos != m_aPanelRepository.end();
+ ++panelPos
+ )
+ {
+ if ( panelPos->bHidden )
+ panelPos->pPanel->Dispose();
+ }
+ m_aPanelRepository.clear();
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::SetDefaultTitle( const String& i_rTitle )
+ {
+ m_sDefaultTitle = i_rTitle;
+ impl_updateDockingWindowTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
+ {
+ ::boost::optional< size_t > aPanelPos( m_rTaskPane.GetPanelPos( i_rPanelURL ) );
+ ENSURE_OR_RETURN_VOID( !!aPanelPos, "TaskPaneController_Impl::ActivateToolPanel: no such panel!" );
+
+ if ( aPanelPos == m_rTaskPane.GetPanelDeck().GetActivePanel() )
+ {
+ ::svt::PToolPanel pPanel( m_rTaskPane.GetPanelDeck().GetPanel( *aPanelPos ) );
+ pPanel->GrabFocus();
+ }
+ else
+ {
+ m_rTaskPane.GetPanelDeck().ActivatePanel( aPanelPos );
+ }
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TaskPaneController_Impl, DockingChanged, TitledDockingWindow*, i_pDockingWindow )
+ {
+ ENSURE_OR_RETURN( i_pDockingWindow && &m_rDockingWindow, "TaskPaneController_Impl::DockingChanged: where does this come from?", 0L );
+
+ if ( impl_getLayout() == LAYOUT_DRAWERS )
+ return 0L;
+
+ impl_setLayout( lcl_getTabLayoutFromAlignment( i_pDockingWindow->GetAlignment() ) );
+ return 1L;
+ }
+
+ // -----------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TaskPaneController_Impl, OnToolboxClicked, ToolBox*, i_pToolBox )
+ {
+ if ( i_pToolBox->GetCurItemId() == m_nViewMenuID )
+ {
+ i_pToolBox->EndSelection();
+
+ ::std::auto_ptr< PopupMenu > pMenu = impl_createPopupMenu();
+ pMenu->SetSelectHdl( LINK( this, TaskPaneController_Impl, OnMenuItemSelected ) );
+
+ // pass toolbox button rect so the menu can stay open on button up
+ Rectangle aMenuRect( i_pToolBox->GetItemRect( m_nViewMenuID ) );
+ aMenuRect.SetPos( i_pToolBox->GetPosPixel() );
+ pMenu->Execute( &m_rDockingWindow, aMenuRect, POPUPMENU_EXECUTE_DOWN );
+ }
+
+ return 0;
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TaskPaneController_Impl, OnMenuItemSelected, Menu*, i_pMenu )
+ {
+ ENSURE_OR_RETURN( i_pMenu, "TaskPaneController_Impl::OnMenuItemSelected: illegal menu!", 0L );
+
+ i_pMenu->Deactivate();
+ switch ( i_pMenu->GetCurItemId() )
+ {
+ case MID_UNLOCK_TASK_PANEL:
+ m_rDockingWindow.SetFloatingMode( TRUE );
+ break;
+
+ case MID_LOCK_TASK_PANEL:
+ m_rDockingWindow.SetFloatingMode( FALSE );
+ break;
+
+ case MID_LAYOUT_DRAWERS:
+ impl_setLayout( LAYOUT_DRAWERS );
+ break;
+
+ case MID_LAYOUT_TABS:
+ impl_setLayout( lcl_getTabLayoutFromAlignment( m_rDockingWindow.GetAlignment() ) );
+ break;
+
+ default:
+ {
+ size_t nPanelIndex = size_t( i_pMenu->GetCurItemId() - MID_FIRST_PANEL );
+ impl_togglePanelVisibility( nPanelIndex );
+ }
+ break;
+ }
+
+ return 1L;
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ size_t TaskPaneController_Impl::impl_getLogicalPanelIndex( const size_t i_nVisibleIndex )
+ {
+ size_t nLogicalIndex = 0;
+ size_t nVisibleIndex( i_nVisibleIndex );
+ for ( size_t i=0; i < m_aPanelRepository.size(); ++i )
+ {
+ if ( !m_aPanelRepository[i].bHidden )
+ {
+ if ( !nVisibleIndex )
+ break;
+ --nVisibleIndex;
+ }
+ ++nLogicalIndex;
+ }
+ return nLogicalIndex;
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::PanelInserted( const ::svt::PToolPanel& i_pPanel, const size_t i_nPosition )
+ {
+ if ( m_bTogglingPanelVisibility )
+ return;
+
+ const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition ) );
+ m_aPanelRepository.insert( m_aPanelRepository.begin() + nLogicalIndex, PanelDescriptor( i_pPanel ) );
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::PanelRemoved( const size_t i_nPosition )
+ {
+ if ( m_bTogglingPanelVisibility )
+ return;
+
+ const size_t nLogicalIndex( impl_getLogicalPanelIndex( i_nPosition ) );
+ m_aPanelRepository.erase( m_aPanelRepository.begin() + nLogicalIndex );
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive )
+ {
+ if ( impl_getLayout() == LAYOUT_DRAWERS )
+ // no adjustment of the title when we use the classical "drawers" layout
+ return;
+
+ impl_updateDockingWindowTitle( );
+ (void)i_rOldActive;
+ (void)i_rNewActive;
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::LayouterChanged( const ::svt::PDeckLayouter& i_rNewLayouter )
+ {
+ // not interested in
+ (void)i_rNewLayouter;
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::Dying()
+ {
+ OSL_ENSURE( false, "TaskPaneController_Impl::Dying: unexpected call!" );
+ // We are expected to live longer than the ToolPanelDeck we work with. Since we remove ourself, in our dtor,
+ // as listener from the panel deck, this method here should never be called.
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::impl_togglePanelVisibility( const size_t i_nLogicalPanelIndex )
+ {
+ ENSURE_OR_RETURN_VOID( i_nLogicalPanelIndex < m_aPanelRepository.size(), "illegal index" );
+
+ // get the actual panel index, within the deck
+ size_t nActualPanelIndex(0);
+ for ( size_t i=0; i < i_nLogicalPanelIndex; ++i )
+ {
+ if ( !m_aPanelRepository[i].bHidden )
+ ++nActualPanelIndex;
+ }
+
+ ::boost::optional< size_t > aActivatePanel;
+
+ m_bTogglingPanelVisibility = true;
+ if ( m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden )
+ {
+ OSL_VERIFY( m_rTaskPane.GetPanelDeck().InsertPanel( m_aPanelRepository[ i_nLogicalPanelIndex ].pPanel, nActualPanelIndex ) == nActualPanelIndex );
+ // if there has not been an active panel before, activate the newly inserted one
+ ::boost::optional< size_t > aActivePanel( m_rTaskPane.GetPanelDeck().GetActivePanel() );
+ if ( !aActivePanel )
+ aActivatePanel = nActualPanelIndex;
+ }
+ else
+ {
+ OSL_VERIFY( m_rTaskPane.GetPanelDeck().RemovePanel( nActualPanelIndex ).get() == m_aPanelRepository[ i_nLogicalPanelIndex ].pPanel.get() );
+ }
+ m_bTogglingPanelVisibility = false;
+ m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden = !m_aPanelRepository[ i_nLogicalPanelIndex ].bHidden;
+
+ if ( !!aActivatePanel )
+ m_rTaskPane.GetPanelDeck().ActivatePanel( *aActivatePanel );
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::impl_setLayout( const PanelSelectorLayout i_eLayout, const bool i_bForce )
+ {
+ if ( !i_bForce && ( m_eCurrentLayout == i_eLayout ) )
+ return;
+
+ switch ( i_eLayout )
+ {
+ case LAYOUT_DRAWERS:
+ m_rTaskPane.SetDrawersLayout();
+ break;
+ case LAYOUT_TABS_TOP:
+ m_rTaskPane.SetTabsLayout( ::svt::TABS_TOP, ::svt::TABITEM_IMAGE_ONLY );
+ break;
+ case LAYOUT_TABS_BOTTOM:
+ m_rTaskPane.SetTabsLayout( ::svt::TABS_BOTTOM, ::svt::TABITEM_IMAGE_ONLY );
+ break;
+ case LAYOUT_TABS_LEFT:
+ m_rTaskPane.SetTabsLayout( ::svt::TABS_LEFT, ::svt::TABITEM_IMAGE_ONLY );
+ break;
+ case LAYOUT_TABS_RIGHT:
+ m_rTaskPane.SetTabsLayout( ::svt::TABS_RIGHT, ::svt::TABITEM_IMAGE_ONLY );
+ break;
+ }
+ m_eCurrentLayout = i_eLayout;
+
+ impl_updateDockingWindowTitle();
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController_Impl::impl_updateDockingWindowTitle()
+ {
+ ::boost::optional< size_t > aActivePanel( m_rTaskPane.GetPanelDeck().GetActivePanel() );
+ if ( !aActivePanel || ( impl_getLayout() == LAYOUT_DRAWERS ) )
+ m_rDockingWindow.SetTitle( m_sDefaultTitle );
+ else
+ {
+ size_t nNewActive( *aActivePanel );
+ for ( size_t i=0; i < m_aPanelRepository.size(); ++i )
+ {
+ if ( m_aPanelRepository[i].bHidden )
+ continue;
+
+ if ( !nNewActive )
+ {
+ m_rDockingWindow.SetTitle( m_aPanelRepository[i].pPanel->GetDisplayName() );
+ break;
+ }
+ --nNewActive;
+ }
+ }
+ }
+
+ // ---------------------------------------------------------------------------------------------------------------------
+ ::std::auto_ptr< PopupMenu > TaskPaneController_Impl::impl_createPopupMenu() const
+ {
+ ::std::auto_ptr<PopupMenu> pMenu( new PopupMenu );
+ FloatingWindow* pMenuWindow = static_cast< FloatingWindow* >( pMenu->GetWindow() );
+ if ( pMenuWindow != NULL )
+ {
+ pMenuWindow->SetPopupModeFlags ( pMenuWindow->GetPopupModeFlags() | FLOATWIN_POPUPMODE_NOMOUSEUPCLOSE );
+ }
+
+ // Add one entry for every tool panel element to individually make
+ // them visible or hide them.
+ USHORT nIndex = MID_FIRST_PANEL;
+ for ( size_t i=0; i<m_aPanelRepository.size(); ++i, ++nIndex )
+ {
+ const PanelDescriptor& rPanelDesc( m_aPanelRepository[i] );
+ pMenu->InsertItem( nIndex, rPanelDesc.pPanel->GetDisplayName(), MIB_CHECKABLE );
+ pMenu->CheckItem( nIndex, !rPanelDesc.bHidden );
+ }
+ pMenu->InsertSeparator();
+
+ #if OSL_DEBUG_LEVEL > 0
+ pMenu->InsertItem( MID_LAYOUT_TABS, String::CreateFromAscii( "Tab-Layout (exp.)" ), MIB_CHECKABLE );
+ pMenu->CheckItem( MID_LAYOUT_TABS, impl_getLayout() != LAYOUT_DRAWERS );
+ pMenu->InsertItem( MID_LAYOUT_DRAWERS, String::CreateFromAscii( "Drawer-Layout" ), MIB_CHECKABLE );
+ pMenu->CheckItem( MID_LAYOUT_DRAWERS, impl_getLayout() == LAYOUT_DRAWERS );
+
+ pMenu->InsertSeparator();
+ #endif
+
+ // Add entry for docking or un-docking the tool panel.
+ if ( m_rDockingWindow.IsFloatingMode() )
+ pMenu->InsertItem(
+ MID_LOCK_TASK_PANEL,
+ String( SfxResId( STR_SFX_DOCK ) )
+ );
+ else
+ pMenu->InsertItem(
+ MID_UNLOCK_TASK_PANEL,
+ String( SfxResId( STR_SFX_UNDOCK ) )
+ );
+
+ pMenu->RemoveDisabledEntries( FALSE, FALSE );
+
+ return pMenu;
+ }
+
+ //==================================================================================================================
+ //= TaskPaneController
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneController::TaskPaneController( ModuleTaskPane& i_rTaskPane, TitledDockingWindow& i_rDockingWindow )
+ :m_pImpl( new TaskPaneController_Impl( i_rTaskPane, i_rDockingWindow ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TaskPaneController::~TaskPaneController()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController::SetDefaultTitle( const String& i_rTitle )
+ {
+ m_pImpl->SetDefaultTitle( i_rTitle );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TaskPaneController::ActivateToolPanel( const ::rtl::OUString& i_rPanelURL )
+ {
+ m_pImpl->ActivateToolPanel( i_rPanelURL );
+ }
+
+//......................................................................................................................
+} // namespace sfx2
+//......................................................................................................................
diff --git a/sfx2/source/dialog/sfxurl.cxx b/sfx2/source/dialog/taskpane.src
index 47e4062ac350..5a955e8587d1 100644
--- a/sfx2/source/dialog/sfxurl.cxx
+++ b/sfx2/source/dialog/taskpane.src
@@ -1,5 +1,4 @@
/*************************************************************************
- *
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
@@ -25,17 +24,24 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sfx2.hxx"
-#include <sfx2/filedlghelper.hxx>
-#include <sfxresid.hxx>
-#include <dialog.hrc>
+#include <sfx2/sfx.hrc>
+#include "sfxlocal.hrc"
+
+String STR_SFX_DOCK
+{
+ Text [ en-US ] = "Dock";
+};
+
+String STR_SFX_UNDOCK
+{
+ Text [ en-US ] = "Undock";
+};
-SfxUrlDialog::SfxUrlDialog( Window *pParent )
- : ModalDialog( pParent, SfxResId( RID_URLOPEN ) ),
- aEdit( this, SfxResId(RID_URLOPEN_URL) ),
- aOk( this, SfxResId(RID_URLOPEN_OK) ),
- aCancel( this, SfxResId(RID_URLOPEN_CANCEL) )
+String STR_SFX_TASK_PANE_VIEW
+{
+ Text [ en-US ] = "View";
+};
+String STR_SFX_TASKS
{
- FreeResource();
-}
+ Text [ en-US ] = "Tasks";
+};
diff --git a/sfx2/source/dialog/titledockwin.cxx b/sfx2/source/dialog/titledockwin.cxx
new file mode 100644
index 000000000000..58a61d66ba8b
--- /dev/null
+++ b/sfx2/source/dialog/titledockwin.cxx
@@ -0,0 +1,364 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "sfx2/titledockwin.hxx"
+#include "sfx2/bindings.hxx"
+#include "sfx2/dispatch.hxx"
+#include "sfxlocal.hrc"
+#include "sfxresid.hxx"
+
+#include <svl/eitem.hxx>
+
+//......................................................................................................................
+namespace sfx2
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= TitledDockingWindow
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ TitledDockingWindow::TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, Window* i_pParent,
+ WinBits i_nStyle )
+ :SfxDockingWindow( i_pBindings, i_pChildWindow, i_pParent, i_nStyle )
+ ,m_sTitle()
+ ,m_aToolbox( this )
+ ,m_aContentWindow( this, WB_DIALOGCONTROL )
+ ,m_aBorder( 3, 1, 3, 3 )
+ ,m_bLayoutPending( false )
+ {
+ impl_construct();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TitledDockingWindow::TitledDockingWindow( SfxBindings* i_pBindings, SfxChildWindow* i_pChildWindow, Window* i_pParent,
+ const ResId& i_rResId )
+ :SfxDockingWindow( i_pBindings, i_pChildWindow, i_pParent, i_rResId )
+ ,m_sTitle()
+ ,m_aToolbox( this )
+ ,m_aContentWindow( this )
+ ,m_aBorder( 3, 1, 3, 3 )
+ ,m_bLayoutPending( false )
+ {
+ impl_construct();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::impl_construct()
+ {
+ SetBackground( Wallpaper() );
+
+ m_aToolbox.SetSelectHdl( LINK( this, TitledDockingWindow, OnToolboxItemSelected ) );
+ m_aToolbox.SetOutStyle( TOOLBOX_STYLE_FLAT );
+ m_aToolbox.SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetDialogColor() ) );
+ m_aToolbox.Show();
+ impl_resetToolBox();
+
+ m_aContentWindow.Show();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ TitledDockingWindow::~TitledDockingWindow()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::SetTitle( const String& i_rTitle )
+ {
+ m_sTitle = i_rTitle;
+ Invalidate();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ String TitledDockingWindow::GetTitle() const
+ {
+ return impl_getTitle();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::SetText( const String& i_rText )
+ {
+ SfxDockingWindow::SetText( i_rText );
+ if ( m_sTitle.Len() == 0 )
+ // our text is used as title, too => repaint
+ Invalidate();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::Resize()
+ {
+ SfxDockingWindow::Resize();
+ impl_scheduleLayout();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::onLayoutDone()
+ {
+ // not interested in
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::impl_scheduleLayout()
+ {
+ m_bLayoutPending = true;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::impl_layout()
+ {
+ m_bLayoutPending = false;
+
+ m_aToolbox.ShowItem( 1, !IsFloatingMode() );
+
+ const Size aToolBoxSize( m_aToolbox.CalcWindowSizePixel() );
+ Size aWindowSize( GetOutputSizePixel() );
+
+ // position the tool box
+ int nTitleBarHeight( GetSettings().GetStyleSettings().GetTitleHeight() );
+ if ( aToolBoxSize.Height() > nTitleBarHeight )
+ nTitleBarHeight = aToolBoxSize.Height();
+ m_aToolbox.SetPosSizePixel(
+ Point(
+ aWindowSize.Width() - aToolBoxSize.Width(),
+ ( nTitleBarHeight - aToolBoxSize.Height() ) / 2
+ ),
+ aToolBoxSize
+ );
+
+ // Place the content window.
+ if ( nTitleBarHeight < aToolBoxSize.Height() )
+ nTitleBarHeight = aToolBoxSize.Height();
+ aWindowSize.Height() -= nTitleBarHeight;
+ m_aContentWindow.SetPosSizePixel(
+ Point( m_aBorder.Left(), nTitleBarHeight + m_aBorder.Top() ),
+ Size(
+ aWindowSize.Width() - m_aBorder.Left() - m_aBorder.Right(),
+ aWindowSize.Height() - m_aBorder.Top() - m_aBorder.Bottom()
+ )
+ );
+
+ onLayoutDone();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::Paint( const Rectangle& i_rArea )
+ {
+ if ( m_bLayoutPending )
+ impl_layout();
+
+ SfxDockingWindow::Paint( i_rArea );
+
+ Push( PUSH_FONT | PUSH_FILLCOLOR | PUSH_LINECOLOR );
+
+ int nTitleBarHeight( GetSettings().GetStyleSettings().GetTitleHeight() );
+ const Size aToolBoxSize = m_aToolbox.CalcWindowSizePixel();
+ if ( aToolBoxSize.Height() > nTitleBarHeight )
+ nTitleBarHeight = aToolBoxSize.Height();
+
+ SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
+ SetLineColor();
+
+ // bold font
+ Font aFont( GetFont() );
+ aFont.SetWeight( WEIGHT_BOLD );
+ SetFont( aFont );
+
+ // Set border values.
+ Size aWindowSize( GetOutputSizePixel() );
+ int nOuterLeft = 0;
+ int nInnerLeft = nOuterLeft + m_aBorder.Left() - 1;
+ int nOuterRight = aWindowSize.Width() - 1;
+ int nInnerRight = nOuterRight - m_aBorder.Right() + 1;
+ int nInnerTop = nTitleBarHeight + m_aBorder.Top() - 1;
+ int nOuterBottom = aWindowSize.Height() - 1;
+ int nInnerBottom = nOuterBottom - m_aBorder.Bottom() + 1;
+
+ // Paint title bar background.
+ Rectangle aTitleBarBox( Rectangle(
+ nOuterLeft,
+ 0,
+ nOuterRight,
+ nInnerTop-1
+ ) );
+ DrawRect( aTitleBarBox );
+
+ if ( nInnerLeft > nOuterLeft )
+ DrawRect( Rectangle( nOuterLeft, nInnerTop, nInnerLeft, nInnerBottom ) );
+ if ( nOuterRight > nInnerRight )
+ DrawRect( Rectangle( nInnerRight, nInnerTop, nOuterRight, nInnerBottom ) );
+ if ( nInnerBottom < nOuterBottom )
+ DrawRect( Rectangle( nOuterLeft, nInnerBottom, nOuterRight, nOuterBottom ) );
+
+ // Paint bevel border.
+ SetFillColor();
+ SetLineColor( GetSettings().GetStyleSettings().GetShadowColor() );
+ if ( m_aBorder.Top() > 0 )
+ DrawLine( Point( nInnerLeft, nInnerTop ), Point( nInnerLeft, nInnerBottom ) );
+ if ( m_aBorder.Left() > 0 )
+ DrawLine( Point( nInnerLeft, nInnerTop ), Point( nInnerRight, nInnerTop ) );
+
+ SetLineColor( GetSettings().GetStyleSettings().GetLightColor() );
+ if ( m_aBorder.Bottom() > 0 )
+ DrawLine( Point( nInnerRight, nInnerBottom ), Point( nInnerLeft, nInnerBottom ) );
+ if ( m_aBorder.Right() > 0 )
+ DrawLine( Point( nInnerRight, nInnerBottom ), Point( nInnerRight, nInnerTop ) );
+
+ // Paint title bar text.
+ SetLineColor( GetSettings().GetStyleSettings().GetActiveTextColor() );
+ aTitleBarBox.Left() += 3;
+ DrawText( aTitleBarBox, impl_getTitle(), TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+
+ // Restore original values of the output device.
+ Pop();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ String TitledDockingWindow::impl_getTitle() const
+ {
+ return m_sTitle.Len() ? m_sTitle : GetText();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::impl_resetToolBox()
+ {
+ m_aToolbox.Clear();
+
+ // Get the closer bitmap and set it as right most button.
+ Image aImage( SfxResId( SFX_IMG_CLOSE_DOC ) );
+ Image aImageHC( SfxResId( SFX_IMG_CLOSE_DOC_HC ) );
+ m_aToolbox.InsertItem( 1,
+ GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? aImageHC
+ : aImage
+ );
+ m_aToolbox.ShowItem( 1 );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ USHORT TitledDockingWindow::impl_addDropDownToolBoxItem( const String& i_rItemText, ULONG i_nHelpId, const Link& i_rCallback )
+ {
+ // Add the menu before the closer button.
+ const USHORT nItemCount( m_aToolbox.GetItemCount() );
+ const USHORT nItemId( nItemCount + 1 );
+ m_aToolbox.InsertItem( nItemId, i_rItemText, TIB_DROPDOWNONLY, nItemCount > 0 ? nItemCount - 1 : TOOLBOX_APPEND );
+ m_aToolbox.SetHelpId( nItemId, i_nHelpId );
+ m_aToolbox.SetClickHdl( i_rCallback );
+ m_aToolbox.SetDropdownClickHdl( i_rCallback );
+
+ // The tool box has likely changed its size. The title bar has to be
+ // resized.
+ impl_scheduleLayout();
+ Invalidate();
+
+ return nItemId;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ IMPL_LINK( TitledDockingWindow, OnToolboxItemSelected, ToolBox*, pToolBox )
+ {
+ const USHORT nId = pToolBox->GetCurItemId();
+
+ if ( nId == 1 )
+ {
+ // the closer
+ EndTracking();
+ const sal_uInt16 nChildWindowId( GetChildWindow_Impl()->GetType() );
+ const SfxBoolItem aVisibility( nChildWindowId, FALSE );
+ GetBindings().GetDispatcher()->Execute(
+ nChildWindowId,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aVisibility,
+ NULL
+ );
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::StateChanged( StateChangedType i_nType )
+ {
+ switch ( i_nType )
+ {
+ case STATE_CHANGE_INITSHOW:
+ impl_scheduleLayout();
+ break;
+ }
+ SfxDockingWindow::StateChanged( i_nType );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::EndDocking( const Rectangle& i_rRect, BOOL i_bFloatMode )
+ {
+ SfxDockingWindow::EndDocking( i_rRect, i_bFloatMode );
+
+ if ( m_aEndDockingHdl.IsSet() )
+ m_aEndDockingHdl.Call( this );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void TitledDockingWindow::DataChanged( const DataChangedEvent& i_rDataChangedEvent )
+ {
+ SfxDockingWindow::DataChanged( i_rDataChangedEvent );
+
+ switch ( i_rDataChangedEvent.GetType() )
+ {
+ case DATACHANGED_SETTINGS:
+ if ( ( i_rDataChangedEvent.GetFlags() & SETTINGS_STYLE ) == 0)
+ break;
+ // else fall through.
+ case DATACHANGED_FONTS:
+ case DATACHANGED_FONTSUBSTITUTION:
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ // Font.
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetZoomedPointFont( aFont );
+
+ // Color.
+ Color aColor;
+ if ( IsControlForeground() )
+ aColor = GetControlForeground();
+ else
+ aColor = rStyleSettings.GetButtonTextColor();
+ SetTextColor( aColor );
+ SetTextFillColor();
+
+ impl_scheduleLayout();
+ Invalidate();
+ }
+ break;
+ }
+ }
+
+//......................................................................................................................
+} // namespace sfx2
+//......................................................................................................................
diff --git a/sfx2/source/dialog/titledockwin.src b/sfx2/source/dialog/titledockwin.src
new file mode 100644
index 000000000000..3f52e84ab75d
--- /dev/null
+++ b/sfx2/source/dialog/titledockwin.src
@@ -0,0 +1,39 @@
+/*************************************************************************
+ * 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 <sfx2/sfx.hrc>
+#include "sfxlocal.hrc"
+
+Image SFX_IMG_CLOSE_DOC
+{
+ ImageBitmap = Bitmap { File = "closedoc.png" ; };
+};
+
+Image SFX_IMG_CLOSE_DOC_HC
+{
+ ImageBitmap = Bitmap { File = "closedochc.png" ; };
+};
+
diff --git a/sfx2/source/doc/Metadatable.cxx b/sfx2/source/doc/Metadatable.cxx
index 1a51bee5024f..94c5826569f2 100644
--- a/sfx2/source/doc/Metadatable.cxx
+++ b/sfx2/source/doc/Metadatable.cxx
@@ -1682,168 +1682,6 @@ throw (uno::RuntimeException)
#if OSL_DEBUG_LEVEL > 1
-static ::sfx2::XmlIdRegistryDocument s_Reg;
-static ::sfx2::XmlIdRegistryClipboard s_RegClip;
-
-class MockMetadatable : public ::sfx2::Metadatable
-{
-public:
- MockMetadatable(bool i_isInClip = false) :
- m_bInClipboard(i_isInClip), m_bInUndo(false), m_bInContent(true) {}
- bool m_bInClipboard;
- bool m_bInUndo;
- bool m_bInContent;
- virtual bool IsInClipboard() const { return m_bInClipboard; }
- virtual bool IsInUndo() const { return m_bInUndo; }
- virtual bool IsInContent() const { return m_bInContent; }
- virtual ::sfx2::XmlIdRegistry& GetRegistry() { return m_bInClipboard ? static_cast< ::sfx2::XmlIdRegistry&>(s_RegClip) : static_cast< ::sfx2::XmlIdRegistry&>(s_Reg); }
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rdf::XMetadatable > MakeUnoObject() { return 0; }
-};
-
-bool operator==(beans::StringPair p1, beans::StringPair p2)
-{
- return p1.First == p2.First && p1.Second == p2.Second;
-}
-
-void test()
-{
- OSL_TRACE("SwMetadatable test(): start\n");
- MockMetadatable m1;
- MockMetadatable m2;
- MockMetadatable m3;
- MockMetadatable m4;
- MockMetadatable m5;
- ::rtl::OUString empty;
- ::rtl::OUString content( ::rtl::OUString::createFromAscii("content.xml") );
- ::rtl::OUString styles ( ::rtl::OUString::createFromAscii("styles.xml") );
- ::rtl::OUString sid1( ::rtl::OUString::createFromAscii("id1") );
- ::rtl::OUString sid2( ::rtl::OUString::createFromAscii("id2") );
- ::rtl::OUString sid3( ::rtl::OUString::createFromAscii("id3") );
- ::rtl::OUString sid4( ::rtl::OUString::createFromAscii("id4") );
- beans::StringPair id1(content, sid1);
- beans::StringPair id2(content, sid2);
- beans::StringPair id3(content, sid3);
- beans::StringPair id4(styles, sid4);
- beans::StringPair id3e(empty, sid3);
- beans::StringPair id4e(empty, sid4);
- m1.SetMetadataReference(id1);
- OSL_ENSURE(m1.GetMetadataReference() == id1, "set failed");
- try {
- m2.SetMetadataReference(id1);
- OSL_ENSURE(false, "set duplicate succeeded");
- } catch (lang::IllegalArgumentException) { }
- m1.SetMetadataReference(id1);
- OSL_ENSURE(m1.GetMetadataReference() == id1, "set failed (existing)");
- m1.EnsureMetadataReference();
- OSL_ENSURE(m1.GetMetadataReference() == id1, "ensure failed (existing)");
-
- m2.EnsureMetadataReference();
- beans::StringPair m2id(m2.GetMetadataReference());
- OSL_ENSURE(m2id.Second.getLength(), "ensure failed");
- m2.EnsureMetadataReference();
- OSL_ENSURE(m2.GetMetadataReference() == m2id, "ensure failed (idempotent)");
-
- m1.m_bInUndo = true;
- OSL_ENSURE(!m1.GetMetadataReference().Second.getLength(), "move to undo failed");
-
- m1.m_bInUndo = false;
- OSL_ENSURE(m1.GetMetadataReference() == id1, "move from undo failed");
-
- m1.m_bInUndo = true;
- try {
- m2.SetMetadataReference(id1); // steal!
- } catch (lang::IllegalArgumentException &) {
- OSL_ENSURE(false, "set duplicate to undo failed");
- }
- m1.m_bInUndo = false;
- OSL_ENSURE(!m1.GetMetadataReference().Second.getLength(), "move from undo: duplicate");
-
- m3.RegisterAsCopyOf(m2);
- OSL_ENSURE(m2.GetMetadataReference() == id1, "copy: source");
- OSL_ENSURE(!m3.GetMetadataReference().Second.getLength(), "copy: duplicate");
- m4.RegisterAsCopyOf(m3);
- OSL_ENSURE(m2.GetMetadataReference() == id1, "copy: source");
- OSL_ENSURE(!m3.GetMetadataReference().Second.getLength(), "copy: duplicate");
- OSL_ENSURE(!m4.GetMetadataReference().Second.getLength(), "copy: duplicate");
- m2.m_bInUndo = true;
- OSL_ENSURE(m3.GetMetadataReference() == id1, "duplicate to undo");
- OSL_ENSURE(!m2.GetMetadataReference().Second.getLength(), "duplicate to undo");
- m2.m_bInUndo = false;
- OSL_ENSURE(m2.GetMetadataReference() == id1, "duplicate from undo");
- OSL_ENSURE(!m3.GetMetadataReference().Second.getLength(), "duplicate from undo");
-
- m4.EnsureMetadataReference(); // new!
- beans::StringPair m4id(m4.GetMetadataReference());
- OSL_ENSURE(m4id.Second.getLength() && !(m4id == id1), "ensure on duplicate");
-
- MockMetadatable mc1(true); // in clipboard
- MockMetadatable mc2(true);
- MockMetadatable mc3(true);
- MockMetadatable mc4(true);
- MockMetadatable m2p;
- MockMetadatable m3p;
-
- mc1.SetMetadataReference(id2);
- OSL_ENSURE(mc1.GetMetadataReference() == id2, "set failed");
- try {
- mc2.SetMetadataReference(id2);
- OSL_ENSURE(false, "set duplicate succeeded");
- } catch (lang::IllegalArgumentException) { }
- mc1.SetMetadataReference(id2);
- OSL_ENSURE(mc1.GetMetadataReference() == id2, "set failed (existing)");
- mc1.EnsureMetadataReference();
- OSL_ENSURE(mc1.GetMetadataReference() == id2, "ensure failed (existing)");
- mc2.EnsureMetadataReference();
- beans::StringPair mc2id(mc2.GetMetadataReference());
- OSL_ENSURE(mc2id.Second.getLength(), "ensure failed");
- mc2.EnsureMetadataReference();
- OSL_ENSURE(mc2.GetMetadataReference() == mc2id, "ensure failed (idempotent)");
- mc2.RemoveMetadataReference();
- OSL_ENSURE(!mc2.GetMetadataReference().Second.getLength(), "remove failed");
-
- // set up mc2 as copy of m2 and mc3 as copy of m3
- mc3.RegisterAsCopyOf(m3);
- OSL_ENSURE(!mc3.GetMetadataReference().Second.getLength() , "copy to clipboard (latent)");
- mc2.RegisterAsCopyOf(m2);
- OSL_ENSURE(mc2.GetMetadataReference() == id1, "copy to clipboard (non-latent)");
- // paste mc2 to m2p and mc3 to m3p
- m2p.RegisterAsCopyOf(mc2);
- OSL_ENSURE(!m2p.GetMetadataReference().Second.getLength() , "paste from clipboard (non-latent)");
- m3p.RegisterAsCopyOf(mc3);
- OSL_ENSURE(!m3p.GetMetadataReference().Second.getLength() , "paste from clipboard (latent)");
- // delete m2, m2p, m3
- m2.RemoveMetadataReference();
- OSL_ENSURE(!m2.GetMetadataReference().Second.getLength(), "remove failed");
- OSL_ENSURE(m2p.GetMetadataReference() == id1, "paste-remove (non-latent)");
- m2p.RemoveMetadataReference();
- OSL_ENSURE(!m2p.GetMetadataReference().Second.getLength(), "remove failed");
- OSL_ENSURE(m3.GetMetadataReference() == id1, "paste-remove2 (non-latent)");
- m3.RemoveMetadataReference();
- OSL_ENSURE(!m3.GetMetadataReference().Second.getLength(), "remove failed");
- OSL_ENSURE(m3p.GetMetadataReference() == id1, "paste-remove (latent)");
- // delete mc2
- mc2.SetMetadataReference(beans::StringPair());
- OSL_ENSURE(!mc3.GetMetadataReference().Second.getLength() , "in clipboard becomes non-latent");
- // paste mc2
- m2p.RegisterAsCopyOf(mc2);
- OSL_ENSURE(!m2p.GetMetadataReference().Second.getLength(), "remove-paste");
- OSL_ENSURE(m3p.GetMetadataReference() == id1, "remove-paste (stolen)");
-
- // auto-detect stream
- m5.SetMetadataReference(id3e);
- OSL_ENSURE(m5.GetMetadataReference() == id3, "auto-detect (content)");
- m5.m_bInContent = false;
- m5.SetMetadataReference(id4e);
- OSL_ENSURE(m5.GetMetadataReference() == id4, "auto-detect (styles)");
-
- OSL_TRACE("sfx2::Metadatable test(): finished\n");
-}
-
-struct Test { Test() { test(); } };
-static Test s_test;
-
-
#include <stdio.h>
static void dump(sfx2::XmlIdList_t * pList)
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 48c01a1ac3fe..bfd67210ec44 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -30,13 +30,19 @@
#include <com/sun/star/registry/MergeConflictException.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
+#include <com/sun/star/frame/XLoadable.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
#include <comphelper/processfactory.hxx>
#include <tools/config.hxx>
#include <unotools/pathoptions.hxx>
#include <unotools/moduleoptions.hxx>
#include <tools/urlobj.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/configurationhelper.hxx>
#include <sfx2/sfx.hrc>
#include <sfx2/docfilt.hxx>
@@ -49,9 +55,15 @@
#include <sfx2/mnumgr.hxx>
#include "sfxresid.hxx"
#include <sfx2/sfxuno.hxx>
+#include "syspath.hxx"
+#include <osl/file.hxx>
+#include <osl/security.hxx>
#include "doc.hrc"
+#include <assert.h>
+
namespace css = ::com::sun::star;
+using namespace ::com::sun::star;
//========================================================================
@@ -182,13 +194,130 @@ void SfxObjectFactory::SetModule_Impl( SfxModule *pMod )
pImpl->pModule = pMod;
}
+void SfxObjectFactory::SetSystemTemplate( const String& rServiceName, const String& rTemplateName )
+{
+ static const int nMaxPathSize = 16000;
+ static ::rtl::OUString SERVICE_FILTER_FACTORY = ::rtl::OUString::createFromAscii( "com.sun.star.document.FilterFactory" );
+ static ::rtl::OUString SERVICE_TYPE_DECTECTION = ::rtl::OUString::createFromAscii( "com.sun.star.document.TypeDetection" );
+ static ::rtl::OUString SERVICE_SIMPLE_ACCESS = ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" );
+
+ static ::rtl::OUString CONF_ROOT = ::rtl::OUString::createFromAscii( "/org.openoffice.Setup");
+ static ::rtl::OUString CONF_PATH = ::rtl::OUString::createFromAscii( "Office/Factories/" ) + ::rtl::OUString( rServiceName );
+ static ::rtl::OUString PROP_DEF_TEMPL_CHANGED = ::rtl::OUString::createFromAscii( "ooSetupFactorySystemDefaultTemplateChanged" );
+ static ::rtl::OUString PROP_ACTUAL_FILTER = ::rtl::OUString::createFromAscii( "ooSetupFactoryActualFilter" );
+
+ static ::rtl::OUString DEF_TPL_STR = ::rtl::OUString::createFromAscii("/soffice.");
+
+ String sURL;
+ String sPath;
+ sal_Unicode aPathBuffer[nMaxPathSize];
+ if ( SystemPath::GetUserTemplateLocation( aPathBuffer, nMaxPathSize ))
+ sPath = String( aPathBuffer );
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sPath, sURL );
+
+ ::rtl::OUString aUserTemplateURL( sURL );
+ if ( aUserTemplateURL.getLength() != 0)
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ uno::Reference< uno::XInterface > xConfig = ::comphelper::ConfigurationHelper::openConfig(
+ xFactory, CONF_ROOT, ::comphelper::ConfigurationHelper::E_STANDARD );
+
+ ::rtl::OUString aActualFilter;
+ ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_ACTUAL_FILTER ) >>= aActualFilter;
+ sal_Bool bChanged(sal_False);
+ ::comphelper::ConfigurationHelper::readRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED ) >>= bChanged;
+
+ uno::Reference< container::XNameAccess > xFilterFactory(
+ xFactory->createInstance( SERVICE_FILTER_FACTORY ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xTypeDetection(
+ xFactory->createInstance( SERVICE_TYPE_DECTECTION ), uno::UNO_QUERY_THROW );
+
+ ::rtl::OUString aActualFilterTypeName;
+ uno::Sequence< beans::PropertyValue > aActuralFilterData;
+ xFilterFactory->getByName( aActualFilter ) >>= aActuralFilterData;
+ for ( sal_Int32 nInd = 0; nInd < aActuralFilterData.getLength(); nInd++ )
+ if ( aActuralFilterData[nInd].Name.equalsAscii( "Type" ) )
+ aActuralFilterData[nInd].Value >>= aActualFilterTypeName;
+ ::comphelper::SequenceAsHashMap aProps1( xTypeDetection->getByName( aActualFilterTypeName ) );
+ uno::Sequence< ::rtl::OUString > aAllExt =
+ aProps1.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii( "Extensions" ), uno::Sequence< ::rtl::OUString >() );
+ //To-do: check if aAllExt is empty first
+ ::rtl::OUString aExt = aAllExt[0];
+
+ aUserTemplateURL += DEF_TPL_STR;
+ aUserTemplateURL += aExt;
+
+ uno::Reference< ucb::XSimpleFileAccess > xSimpleFileAccess(
+ xFactory->createInstance( SERVICE_SIMPLE_ACCESS ), uno::UNO_QUERY_THROW );
+
+ ::rtl::OUString aBackupURL;
+ ::osl::Security().getConfigDir(aBackupURL);
+ aBackupURL += ::rtl::OUString::createFromAscii( "/temp" );
+
+ if ( !xSimpleFileAccess->exists( aBackupURL ) )
+ xSimpleFileAccess->createFolder( aBackupURL );
+
+ aBackupURL += DEF_TPL_STR;
+ aBackupURL += aExt;
+
+ if ( rTemplateName.Len() != 0 )
+ {
+ if ( xSimpleFileAccess->exists( aUserTemplateURL ) && !bChanged )
+ xSimpleFileAccess->copy( aUserTemplateURL, aBackupURL );
+
+ uno::Reference< document::XTypeDetection > xTypeDetector( xTypeDetection, uno::UNO_QUERY );
+ ::comphelper::SequenceAsHashMap aProps2( xTypeDetection->getByName( xTypeDetector->queryTypeByURL( rTemplateName ) ) );
+ ::rtl::OUString aFilterName =
+ aProps2.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("PreferredFilter"), ::rtl::OUString() );
+
+ uno::Sequence< beans::PropertyValue > aArgs( 3 );
+ aArgs[0].Name = ::rtl::OUString::createFromAscii( "FilterName" );
+ aArgs[0].Value <<= aFilterName;
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "AsTemplate" );
+ aArgs[1].Value <<= sal_True;
+ aArgs[2].Name = ::rtl::OUString::createFromAscii( "URL" );
+ aArgs[2].Value <<= ::rtl::OUString( rTemplateName );
+
+ uno::Reference< frame::XLoadable > xLoadable( xFactory->createInstance( ::rtl::OUString( rServiceName ) ), uno::UNO_QUERY );
+ xLoadable->load( aArgs );
+
+ aArgs.realloc( 2 );
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "Overwrite" );
+ aArgs[1].Value <<= sal_True;
+
+ uno::Reference< frame::XStorable > xStorable( xLoadable, uno::UNO_QUERY );
+ xStorable->storeToURL( aUserTemplateURL, aArgs );
+ ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_True ));
+ ::comphelper::ConfigurationHelper::flush( xConfig );
+ }
+ else
+ {
+ DBG_ASSERT( bChanged, "invalid ooSetupFactorySystemDefaultTemplateChanged value!" );
+
+ xSimpleFileAccess->copy( aBackupURL, aUserTemplateURL );
+ xSimpleFileAccess->kill( aBackupURL );
+ ::comphelper::ConfigurationHelper::writeRelativeKey( xConfig, CONF_PATH, PROP_DEF_TEMPL_CHANGED, uno::makeAny( sal_False ));
+ ::comphelper::ConfigurationHelper::flush( xConfig );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
void SfxObjectFactory::SetStandardTemplate( const String& rServiceName, const String& rTemplate )
{
SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(rServiceName);
if (eFac == SvtModuleOptions::E_UNKNOWN_FACTORY)
eFac = SvtModuleOptions::ClassifyFactoryByShortName(rServiceName);
if (eFac != SvtModuleOptions::E_UNKNOWN_FACTORY)
+ {
+ SetSystemTemplate( rServiceName, rTemplate );
SvtModuleOptions().SetFactoryStandardTemplate(eFac, rTemplate);
+ }
}
String SfxObjectFactory::GetStandardTemplate( const String& rServiceName )
diff --git a/sfx2/source/doc/makefile.mk b/sfx2/source/doc/makefile.mk
index b766921e346b..b1bddf82e428 100644
--- a/sfx2/source/doc/makefile.mk
+++ b/sfx2/source/doc/makefile.mk
@@ -83,7 +83,9 @@ SLOFILES = \
$(SLO)$/sfxmodelfactory.obj \
$(SLO)$/sfxacldetect.obj \
$(SLO)$/docstoragemodifylistener.obj \
- $(SLO)$/querytemplate.obj
+ $(SLO)$/querytemplate.obj \
+ $(SLO)$/syspath.obj \
+ $(SLO)$/syspathw32.obj
# $(SLO)$/applet.obj \
@@ -91,7 +93,8 @@ SLOFILES = \
#HACK TO DISABLE PCH
NOOPTFILES= \
- $(SLO)$/sfxacldetect.obj
+ $(SLO)$/sfxacldetect.obj \
+ $(SLO)$/syspathw32.obj
.ENDIF
diff --git a/sfx2/source/doc/syspath.cxx b/sfx2/source/doc/syspath.cxx
new file mode 100755
index 000000000000..a1025370ed24
--- /dev/null
+++ b/sfx2/source/doc/syspath.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: shutdowniconw32.cxx,v $
+* $Revision: 1.48 $
+*
+* 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
+// Comment out precompiled statement due to redefinition errors
+#include "precompiled_sfx2.hxx"
+
+#include "syspath.hxx"
+
+extern "C" bool GetUserTemplateLocation(sal_Unicode*, int nSize);
+
+bool SystemPath::GetUserTemplateLocation(sal_Unicode* pFolder, int nSize )
+{
+#ifdef WNT
+ return ::GetUserTemplateLocation( pFolder, nSize );
+#else
+ (void)pFolder;
+ (void)nSize;
+ return false;
+#endif
+}
diff --git a/sfx2/source/doc/syspath.hxx b/sfx2/source/doc/syspath.hxx
new file mode 100644
index 000000000000..015c16f18d26
--- /dev/null
+++ b/sfx2/source/doc/syspath.hxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: shutdowniconw32.cxx,v $
+* $Revision: 1.48 $
+*
+* 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 __SYSPATH_HXX__
+#define __SYSPATH_HXX__
+//#pragma warning(disable:4917)
+
+#include <sfx2/dllapi.h>
+
+class SFX2_DLLPUBLIC SystemPath
+{
+public:
+ static bool GetUserTemplateLocation(sal_Unicode*, int nSize);
+};
+
+#endif
+
diff --git a/sfx2/source/doc/syspathw32.cxx b/sfx2/source/doc/syspathw32.cxx
new file mode 100644
index 000000000000..73bd84f5249a
--- /dev/null
+++ b/sfx2/source/doc/syspathw32.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2008 by Sun Microsystems, Inc.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* $RCSfile: shutdowniconw32.cxx,v $
+* $Revision: 1.48 $
+*
+* 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.
+*
+************************************************************************/
+
+#ifdef WNT
+#ifdef _MSC_VER
+#pragma warning(disable:4917)
+#endif
+#include <shlobj.h>
+
+static bool _SHGetSpecialFolderW32( int nFolderID, WCHAR* pszFolder, int nSize )
+{
+ LPITEMIDLIST pidl;
+ HRESULT hHdl = SHGetSpecialFolderLocation( NULL, nFolderID, &pidl );
+
+ if( hHdl == NOERROR )
+ {
+ WCHAR *lpFolder = static_cast< WCHAR* >( HeapAlloc( GetProcessHeap(), 0, 16000 ));
+
+ SHGetPathFromIDListW( pidl, lpFolder );
+ wcsncpy( pszFolder, lpFolder, nSize );
+
+ HeapFree( GetProcessHeap(), 0, lpFolder );
+ IMalloc *pMalloc;
+ if( NOERROR == SHGetMalloc(&pMalloc) )
+ {
+ pMalloc->Free( pidl );
+ pMalloc->Release();
+ }
+ }
+ return true;
+}
+
+#endif
+
+// Copied from sal/types.h to circumvent problems with precompiled headers
+// and redefinitions of BOOL, INT32 and other types. Unfortunately tools
+// also define these type incompatible with Win32 types which leads from
+// time to time to very nasty compilation errors. If someone finds a better
+// way to solve these probs please remove this copied part!
+typedef unsigned short sal_uInt16;
+#if ( defined(WIN32) && !defined(__MINGW32__) )
+ typedef wchar_t sal_Unicode;
+#else
+ typedef sal_uInt16 sal_Unicode;
+#endif
+
+extern "C" bool GetUserTemplateLocation(sal_Unicode* pFolder, int nSize)
+{
+#ifdef WNT
+ return _SHGetSpecialFolderW32( CSIDL_TEMPLATES, pFolder, nSize );
+#else
+ (void)pFolder;
+ (void)nSize;
+ return false;
+#endif
+}
diff --git a/sfx2/source/inc/helpid.hrc b/sfx2/source/inc/helpid.hrc
index 4c9aa3fd7f63..79dba3208729 100755
--- a/sfx2/source/inc/helpid.hrc
+++ b/sfx2/source/inc/helpid.hrc
@@ -331,7 +331,8 @@
#define HID_CONFIG_SAVE (HID_SFX_START + 310)
#define HID_SEARCHDIALOG (HID_SFX_START + 311)
-
+#define HID_TASKPANE_WINDOW (HID_SFX_START + 312)
+#define HID_TASKPANE_VIEW_MENU (HID_SFX_START + 313)
#define HID_XMLSEC_WARNING_BROKENSIGNATURE (HID_SFX_START + 314)
#define HID_XMLSEC_QUERY_LOSINGSIGNATURE (HID_SFX_START + 315)
#define HID_XMLSEC_QUERY_SAVEBEFORESIGN (HID_SFX_START + 316)
diff --git a/sfx2/source/inc/sfxlocal.hrc b/sfx2/source/inc/sfxlocal.hrc
index fb21cb0ab13c..202ed6f6f00f 100644
--- a/sfx2/source/inc/sfxlocal.hrc
+++ b/sfx2/source/inc/sfxlocal.hrc
@@ -44,6 +44,10 @@
#define STR_SFX_EXPLORERFILE_BUTTONINSERT (RID_SFX_SFXLOCAL_START + 4)
#define STR_SFX_IMPORT_ALL (RID_SFX_SFXLOCAL_START + 5)
#define STR_SFX_EXPLORERFILE_EXPORT (RID_SFX_SFXLOCAL_START + 6)
+#define STR_SFX_DOCK (RID_SFX_SFXLOCAL_START + 7)
+#define STR_SFX_UNDOCK (RID_SFX_SFXLOCAL_START + 8)
+#define STR_SFX_TASK_PANE_VIEW (RID_SFX_SFXLOCAL_START + 9)
+#define STR_SFX_TASKS (RID_SFX_SFXLOCAL_START + 10)
// Controls --------------------------------------------------------------
@@ -55,13 +59,17 @@
#define SFX_PB_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 5)
#define SFX_WIN_PROPERTY_YESNO (RID_SFX_SFXLOCAL_START + 6)
#define SFX_QB_WRONG_TYPE (RID_SFX_SFXLOCAL_START + 7)
-#define SFX_IMG_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 8)
-#define SFX_IMG_PROPERTY_REMOVE_HC (RID_SFX_SFXLOCAL_START + 9)
#define SFX_FLD_DATE (RID_SFX_SFXLOCAL_START + 10)
#define SFX_FLD_TIME (RID_SFX_SFXLOCAL_START + 11)
#define SFX_FLD_DURATION (RID_SFX_SFXLOCAL_START + 12)
#define SFX_ST_DURATION_FORMAT (RID_SFX_SFXLOCAL_START + 13)
+// Images ----------------------------------------------------------------
+
+#define SFX_IMG_PROPERTY_REMOVE (RID_SFX_SFXLOCAL_START + 0)
+#define SFX_IMG_PROPERTY_REMOVE_HC (RID_SFX_SFXLOCAL_START + 1)
+#define SFX_IMG_CLOSE_DOC (RID_SFX_SFXLOCAL_START + 2)
+#define SFX_IMG_CLOSE_DOC_HC (RID_SFX_SFXLOCAL_START + 3)
#endif
diff --git a/sfx2/source/inc/workwin.hxx b/sfx2/source/inc/workwin.hxx
index ae005d1bad88..a82b72bc2947 100644
--- a/sfx2/source/inc/workwin.hxx
+++ b/sfx2/source/inc/workwin.hxx
@@ -365,6 +365,7 @@ public:
void SetActiveChild_Impl( Window *pChild );
Window* GetActiveChild_Impl();
virtual BOOL ActivateNextChild_Impl( BOOL bForward = TRUE );
+ bool AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const;
// Methoden f"ur StatusBar
void SetTempStatusBar_Impl( BOOL bSet );
diff --git a/sfx2/source/menu/makefile.mk b/sfx2/source/menu/makefile.mk
index d3b209fc4a45..8b55bd0840ea 100644
--- a/sfx2/source/menu/makefile.mk
+++ b/sfx2/source/menu/makefile.mk
@@ -43,10 +43,11 @@ SRS1NAME=$(TARGET)
SRC1FILES = menu.src
SLOFILES = \
+ $(SLO)$/mnuitem.obj \
$(SLO)$/mnumgr.obj \
- $(SLO)$/virtmenu.obj \
$(SLO)$/objmnctl.obj \
- $(SLO)$/mnuitem.obj
+ $(SLO)$/thessubmenu.obj \
+ $(SLO)$/virtmenu.obj
# --- Tagets -------------------------------------------------------
diff --git a/sfx2/source/menu/menu.hrc b/sfx2/source/menu/menu.hrc
index 5017f980872b..b437f797c26e 100644
--- a/sfx2/source/menu/menu.hrc
+++ b/sfx2/source/menu/menu.hrc
@@ -64,6 +64,10 @@
#define STR_MENU_ADDONS RID_SFX_MENU_START+2
#define STR_MENU_ADDONHELP RID_SFX_MENU_START+3
+#define STR_MENU_SYNONYMS (RID_SFX_MENU_START+11)
+#define STR_MENU_NO_SYNONYM_FOUND (RID_SFX_MENU_START+12)
+#define STR_MENU_THESAURUS (RID_SFX_MENU_START+13)
+
#define MN_CLIPBOARDFUNCS RID_SFX_MENU_START+1
#endif
diff --git a/sfx2/source/menu/menu.src b/sfx2/source/menu/menu.src
index 97c9c7f640fa..a2e07a3348b0 100644
--- a/sfx2/source/menu/menu.src
+++ b/sfx2/source/menu/menu.src
@@ -72,6 +72,21 @@ String STR_MENU_ADDONHELP
Text [ en-US ] = "Add-~On Help" ;
};
+String STR_MENU_SYNONYMS
+{
+ Text [ en-US ] = "Synonyms" ;
+};
+
+String STR_MENU_NO_SYNONYM_FOUND
+{
+ Text [ en-US ] = "(none)" ;
+};
+
+String STR_MENU_THESAURUS
+{
+ Text [ en-US ] = "~Thesaurus..." ;
+};
+
// ******************************************************************* EOF
diff --git a/sfx2/source/menu/mnumgr.cxx b/sfx2/source/menu/mnumgr.cxx
index ec803718f457..b264a5b47861 100644..100755
--- a/sfx2/source/menu/mnumgr.cxx
+++ b/sfx2/source/menu/mnumgr.cxx
@@ -27,8 +27,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sfx2.hxx"
+
#include <com/sun/star/embed/VerbDescriptor.hpp>
#include <com/sun/star/embed/VerbAttributes.hpp>
+#include <com/sun/star/container/XNamed.hpp>
#ifdef SOLARIS
// HACK: prevent conflict between STLPORT and Workshop headers on Solaris 8
@@ -50,9 +52,14 @@
#include <framework/addonmenu.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/lingucfg.hxx>
#include <tools/urlobj.hxx>
#include <unotools/pathoptions.hxx>
+#include <svl/stritem.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <osl/file.hxx>
+#include <vcl/graph.hxx>
+#include <svtools/filter.hxx>
#include <sfx2/mnumgr.hxx>
@@ -76,10 +83,15 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/objface.hxx>
+#include "thessubmenu.hxx"
+
static const USHORT nCompatVersion = 4;
static const USHORT nVersion = 5;
+// static member initialization
+PopupMenu * SfxPopupMenuManager::pStaticThesSubMenu = NULL;
+
using namespace com::sun::star;
//=========================================================================
@@ -166,6 +178,101 @@ void InsertVerbs_Impl( SfxBindings* pBindings, const com::sun::star::uno::Sequen
}
+//--------------------------------------------------------------------
+
+
+static Image lcl_GetImageFromPngUrl( const ::rtl::OUString &rFileUrl )
+{
+ Image aRes;
+
+ ::rtl::OUString aTmp;
+ osl::FileBase::getSystemPathFromFileURL( rFileUrl, aTmp );
+
+ Graphic aGraphic;
+ const String aFilterName( RTL_CONSTASCII_USTRINGPARAM( IMP_PNG ) );
+ if( GRFILTER_OK == GraphicFilter::LoadGraphic( aTmp, aFilterName, aGraphic ) )
+ {
+ aRes = Image( aGraphic.GetBitmapEx() );
+ }
+ return aRes;
+}
+
+
+PopupMenu* InsertThesaurusSubmenu_Impl( SfxBindings* pBindings, Menu* pSVMenu )
+{
+ //
+ // build thesaurus sub menu if look-up string is available
+ //
+ PopupMenu* pThesSubMenu = 0;
+ SfxPoolItem *pItem = 0;
+ pBindings->QueryState( SID_THES, pItem );
+ String aThesLookUpStr;
+ SfxStringItem *pStrItem = dynamic_cast< SfxStringItem * >(pItem);
+ xub_StrLen nDelimPos = STRING_LEN;
+ if (pStrItem)
+ {
+ aThesLookUpStr = pStrItem->GetValue();
+ nDelimPos = aThesLookUpStr.SearchBackward( '#' );
+ }
+ if (aThesLookUpStr.Len() > 0 && nDelimPos != STRING_NOTFOUND)
+ {
+ // get synonym list for sub menu
+ std::vector< ::rtl::OUString > aSynonyms;
+ SfxThesSubMenuHelper aHelper;
+ ::rtl::OUString aText( aHelper.GetText( aThesLookUpStr, nDelimPos ) );
+ lang::Locale aLocale;
+ aHelper.GetLocale( aLocale, aThesLookUpStr, nDelimPos );
+ const bool bHasMoreSynonyms = aHelper.GetMeanings( aSynonyms, aText, aLocale, 7 /*max number of synonyms to retrieve*/ );
+ (void) bHasMoreSynonyms;
+
+ pThesSubMenu = new PopupMenu;
+ pThesSubMenu->SetMenuFlags(MENU_FLAG_NOAUTOMNEMONICS);
+ const size_t nNumSynonyms = aSynonyms.size();
+ if (nNumSynonyms > 0)
+ {
+ SvtLinguConfig aCfg;
+ const bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ Image aImage;
+ String sThesImplName( aHelper.GetThesImplName( aLocale ) );
+ ::rtl::OUString aSynonymsImageUrl( aCfg.GetSynonymsContextImage( sThesImplName, bHC ) );
+ if (sThesImplName.Len() > 0 && aSynonymsImageUrl.getLength() > 0)
+ aImage = Image( lcl_GetImageFromPngUrl( aSynonymsImageUrl ) );
+
+ for (USHORT i = 0; (size_t)i < nNumSynonyms; ++i)
+ {
+ //! item ids should start with values > 0, since 0 has special meaning
+ const USHORT nId = i + 1;
+
+ String aItemText( GetThesaurusReplaceText_Impl( aSynonyms[i] ) );
+ pThesSubMenu->InsertItem( nId, aItemText );
+ ::rtl::OUString aCmd( ::rtl::OUString::createFromAscii( ".uno:ThesaurusFromContext?WordReplace:string=" ) );
+ aCmd += aItemText;
+ pThesSubMenu->SetItemCommand( nId, aCmd );
+
+ if (aSynonymsImageUrl.getLength() > 0)
+ pThesSubMenu->SetItemImage( nId, aImage );
+ }
+ }
+ else // nNumSynonyms == 0
+ {
+ const String aItemText( SfxResId( STR_MENU_NO_SYNONYM_FOUND ) );
+ pThesSubMenu->InsertItem( 1, aItemText, MIB_NOSELECT );
+ }
+ pThesSubMenu->InsertSeparator();
+ const String sThesaurus( SfxResId( STR_MENU_THESAURUS ) );
+ pThesSubMenu->InsertItem( 100, sThesaurus );
+ pThesSubMenu->SetItemCommand( 100, ::rtl::OUString::createFromAscii( ".uno:ThesaurusDialog" ) );
+
+ pSVMenu->InsertSeparator();
+ const String sSynonyms( SfxResId( STR_MENU_SYNONYMS ) );
+ pSVMenu->InsertItem( SID_THES, sSynonyms );
+ pSVMenu->SetPopupMenu( SID_THES, pThesSubMenu );
+ }
+
+ return pThesSubMenu;
+}
+
//--------------------------------------------------------------------
@@ -305,7 +412,9 @@ void SfxPopupMenuManager::RemoveDisabledEntries()
USHORT SfxPopupMenuManager::Execute( const Point& rPos, Window* pWindow )
{
DBG_MEMTEST();
- return ( (PopupMenu*) GetMenu()->GetSVMenu() )->Execute( pWindow, rPos );
+ USHORT nVal = ( (PopupMenu*) GetMenu()->GetSVMenu() )->Execute( pWindow, rPos );
+ delete pStaticThesSubMenu; pStaticThesSubMenu = NULL;
+ return nVal;
}
//--------------------------------------------------------------------
@@ -429,6 +538,10 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra
break;
}
+ PopupMenu* pThesSubMenu = InsertThesaurusSubmenu_Impl( &pFrame->GetBindings(), pSVMenu );
+ // #i107205# (see comment in header file)
+ pStaticThesSubMenu = pThesSubMenu;
+
if ( n == nCount )
{
PopupMenu aPop( SfxResId( MN_CLIPBOARDFUNCS ) );
@@ -461,6 +574,7 @@ SfxPopupMenuManager* SfxPopupMenuManager::Popup( const ResId& rResId, SfxViewFra
aMgr->RemoveDisabledEntries();
return aMgr;
}
+
return 0;
}
@@ -475,6 +589,8 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram
break;
}
+ PopupMenu* pThesSubMenu = InsertThesaurusSubmenu_Impl( &pFrame->GetBindings(), pSVMenu );
+
if ( n == nCount )
{
PopupMenu aPop( SfxResId( MN_CLIPBOARDFUNCS ) );
@@ -507,6 +623,8 @@ void SfxPopupMenuManager::ExecutePopup( const ResId& rResId, SfxViewFrame* pFram
aPop.RemoveDisabledEntries();
aPop.Execute( rPoint, pWindow );
}
+
+ delete pThesSubMenu;
}
Menu* SfxPopupMenuManager::GetSVMenu()
diff --git a/sfx2/source/menu/thessubmenu.cxx b/sfx2/source/menu/thessubmenu.cxx
new file mode 100755
index 000000000000..de1137bd6a74
--- /dev/null
+++ b/sfx2/source/menu/thessubmenu.cxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: thessubmenu.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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_sfx2.hxx"
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/XMeaning.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <svl/stritem.hxx>
+#include <tools/debug.hxx>
+#include <vcl/graph.hxx>
+#include <svtools/filter.hxx>
+
+
+#include <vector>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include "thessubmenu.hxx"
+
+
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+
+// STATIC DATA -----------------------------------------------------------
+
+SFX_IMPL_MENU_CONTROL(SfxThesSubMenuControl, SfxStringItem);
+
+////////////////////////////////////////////////////////////
+
+String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText )
+{
+ // The strings returned by the thesaurus sometimes have some
+ // explanation text put in between '(' and ')' or a trailing '*'.
+ // These parts should not be put in the ReplaceEdit Text that may get
+ // inserted into the document. Thus we strip them from the text.
+
+ String aText( rText );
+
+ xub_StrLen nPos = aText.Search( sal_Unicode('(') );
+ while (STRING_NOTFOUND != nPos)
+ {
+ xub_StrLen nEnd = aText.Search( sal_Unicode(')'), nPos );
+ if (STRING_NOTFOUND != nEnd)
+ aText.Erase( nPos, nEnd-nPos+1 );
+ else
+ break;
+ nPos = aText.Search( sal_Unicode('(') );
+ }
+
+ nPos = aText.Search( sal_Unicode('*') );
+ if (STRING_NOTFOUND != nPos)
+ aText.Erase( nPos );
+
+ // remove any possible remaining ' ' that may confuse the thesaurus
+ // when it gets called with the text
+ aText.EraseLeadingAndTrailingChars( sal_Unicode(' ') );
+
+ return aText;
+}
+
+////////////////////////////////////////////////////////////
+
+
+/*
+ Ctor; setzt Select-Handler am Menu und traegt Menu
+ in seinen Parent ein.
+ */
+SfxThesSubMenuControl::SfxThesSubMenuControl( USHORT nSlotId, Menu &rMenu, SfxBindings &rBindings )
+ : SfxMenuControl( nSlotId, rBindings ),
+ pMenu(new PopupMenu),
+ rParent(rMenu)
+{
+ rMenu.SetPopupMenu(nSlotId, pMenu);
+ pMenu->SetSelectHdl(LINK(this, SfxThesSubMenuControl, MenuSelect));
+ pMenu->Clear();
+ rParent.EnableItem( GetId(), FALSE );
+}
+
+
+SfxThesSubMenuControl::~SfxThesSubMenuControl()
+{
+ delete pMenu;
+}
+
+
+/*
+ Statusbenachrichtigung;
+ Ist die Funktionalit"at disabled, wird der entsprechende
+ Menueeintrag im Parentmenu disabled, andernfalls wird er enabled.
+ */
+void SfxThesSubMenuControl::StateChanged(
+ USHORT /*nSID*/,
+ SfxItemState eState,
+ const SfxPoolItem* /*pState*/ )
+{
+ rParent.EnableItem(GetId(), SFX_ITEM_AVAILABLE == eState );
+}
+
+
+/*
+ Select-Handler des Menus;
+ das selektierte Verb mit ausgef"uhrt,
+ */
+IMPL_LINK_INLINE_START( SfxThesSubMenuControl, MenuSelect, Menu *, pSelMenu )
+{
+ const USHORT nSlotId = pSelMenu->GetCurItemId();
+ if( nSlotId )
+ GetBindings().Execute(nSlotId);
+ return 1;
+}
+IMPL_LINK_INLINE_END( SfxThesSubMenuControl, MenuSelect, Menu *, pSelMenu )
+
+
+PopupMenu* SfxThesSubMenuControl::GetPopup() const
+{
+ return pMenu;
+}
+
+
+////////////////////////////////////////////////////////////
+
+OUString SfxThesSubMenuHelper::GetText(
+ const String &rLookUpString,
+ xub_StrLen nDelimPos )
+{
+ return OUString( rLookUpString.Copy( 0, nDelimPos ) );
+}
+
+
+void SfxThesSubMenuHelper::GetLocale(
+ lang::Locale /*out */ &rLocale,
+ const String &rLookUpString,
+ xub_StrLen nDelimPos )
+{
+ String aIsoLang( rLookUpString.Copy( nDelimPos + 1) );
+ const xub_StrLen nPos = aIsoLang.Search( '-' );
+ if (nPos != STRING_NOTFOUND)
+ {
+ rLocale.Language = aIsoLang.Copy( 0, nPos );
+ rLocale.Country = aIsoLang.Copy( nPos + 1 );
+ rLocale.Variant = String::EmptyString();
+ }
+}
+
+
+SfxThesSubMenuHelper::SfxThesSubMenuHelper()
+{
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ m_xLngMgr = uno::Reference< linguistic2::XLinguServiceManager >( xMSF->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.linguistic2.LinguServiceManager" ))), uno::UNO_QUERY_THROW );
+ m_xThesarus = m_xLngMgr->getThesaurus();
+ }
+ catch (uno::Exception &e)
+ {
+ (void) e;
+ DBG_ASSERT( 0, "failed to get thesaurus" );
+ }
+}
+
+
+SfxThesSubMenuHelper::~SfxThesSubMenuHelper()
+{
+}
+
+
+bool SfxThesSubMenuHelper::IsSupportedLocale( const lang::Locale & rLocale ) const
+{
+ return m_xThesarus.is() && m_xThesarus->hasLocale( rLocale );
+}
+
+
+bool SfxThesSubMenuHelper::GetMeanings(
+ std::vector< OUString > & rSynonyms,
+ const OUString & rWord,
+ const lang::Locale & rLocale,
+ sal_Int16 nMaxSynonms )
+{
+ bool bHasMoreSynonyms = false;
+ rSynonyms.clear();
+ if (IsSupportedLocale( rLocale ) && rWord.getLength() && nMaxSynonms > 0)
+ {
+ try
+ {
+ // get all meannings
+ const uno::Sequence< uno::Reference< linguistic2::XMeaning > > aMeaningSeq(
+ m_xThesarus->queryMeanings( rWord, rLocale, uno::Sequence< beans::PropertyValue >() ));
+ const uno::Reference< linguistic2::XMeaning > *pxMeaning = aMeaningSeq.getConstArray();
+ const sal_Int32 nMeanings = aMeaningSeq.getLength();
+
+ // iterate over all meanings until nMaxSynonms are found or all meanings are processed
+ sal_Int32 nCount = 0;
+ sal_Int32 i = 0;
+ for ( ; i < nMeanings && nCount < nMaxSynonms; ++i)
+ {
+ const uno::Sequence< OUString > aSynonymSeq( pxMeaning[i]->querySynonyms() );
+ const OUString *pSynonyms = aSynonymSeq.getConstArray();
+ const sal_Int32 nSynonyms = aSynonymSeq.getLength();
+ sal_Int32 k = 0;
+ for ( ; k < nSynonyms && nCount < nMaxSynonms; ++k)
+ {
+ rSynonyms.push_back( pSynonyms[k] );
+ ++nCount;
+ }
+ bHasMoreSynonyms = k < nSynonyms; // any synonym from this meaning skipped?
+ }
+
+ bHasMoreSynonyms |= i < nMeanings; // any meaning skipped?
+ }
+ catch (uno::Exception &e)
+ {
+ (void) e;
+ DBG_ASSERT( 0, "failed to get synonyms" );
+ }
+ }
+ return bHasMoreSynonyms;
+}
+
+
+String SfxThesSubMenuHelper::GetThesImplName( const lang::Locale &rLocale ) const
+{
+ String aRes;
+ DBG_ASSERT( m_xLngMgr.is(), "LinguServiceManager missing" );
+ if (m_xLngMgr.is())
+ {
+ uno::Sequence< OUString > aServiceNames = m_xLngMgr->getConfiguredServices(
+ OUString::createFromAscii("com.sun.star.linguistic2.Thesaurus"), rLocale );
+ // there should be at most one thesaurus configured for each language
+ DBG_ASSERT( aServiceNames.getLength() <= 1, "more than one thesaurus found. Should not be possible" );
+ if (aServiceNames.getLength() == 1)
+ aRes = aServiceNames[0];
+ }
+ return aRes;
+}
+
+////////////////////////////////////////////////////////////
+
+
diff --git a/sfx2/source/menu/thessubmenu.hxx b/sfx2/source/menu/thessubmenu.hxx
new file mode 100644
index 000000000000..14d7473cb7c0
--- /dev/null
+++ b/sfx2/source/menu/thessubmenu.hxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: thessubmenu.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * 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 _THESSUBMENU_HXX_
+#define _THESSUBMENU_HXX_
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+
+#include <vcl/menu.hxx>
+#include <sfx2/mnuitem.hxx>
+
+class SfxBindings;
+class PopupMenu;
+class Menu;
+
+namespace css = ::com::sun::star;
+
+////////////////////////////////////////////////////////////
+
+String GetThesaurusReplaceText_Impl( const ::rtl::OUString &rText );
+
+////////////////////////////////////////////////////////////
+
+class SfxThesSubMenuControl : public SfxMenuControl
+{
+ PopupMenu* pMenu;
+ Menu& rParent;
+
+private:
+ virtual void StateChanged( USHORT, SfxItemState, const SfxPoolItem* pState );
+ DECL_LINK( MenuSelect, Menu * );
+
+public:
+ SfxThesSubMenuControl(USHORT, Menu&, SfxBindings&);
+ ~SfxThesSubMenuControl();
+
+ virtual PopupMenu* GetPopup() const;
+
+ SFX_DECL_MENU_CONTROL();
+};
+
+////////////////////////////////////////////////////////////
+
+class SfxThesSubMenuHelper
+{
+ css::uno::Reference< css::linguistic2::XLinguServiceManager > m_xLngMgr;
+ css::uno::Reference< css::linguistic2::XThesaurus > m_xThesarus;
+
+private:
+
+ // don't use copy c-tor and assignment operator
+ SfxThesSubMenuHelper( const SfxThesSubMenuHelper & );
+ SfxThesSubMenuHelper & operator = ( const SfxThesSubMenuHelper & );
+
+public:
+ SfxThesSubMenuHelper();
+ ~SfxThesSubMenuHelper();
+
+ static ::rtl::OUString GetText( const String &rLookUpString, xub_StrLen nDelimPos );
+
+ // returns the Locale to be used for the selected text when the thesaurus is to be called
+ static void GetLocale( css::lang::Locale /*out */ &rLocale, const String &rLookUpString, xub_StrLen nDelimPos );
+
+ // returns true if the locale is upported by the theasaurus
+ bool IsSupportedLocale( const css::lang::Locale & rLocale ) const;
+
+ // get the first nMax Synonym entries, even if different meanings need to be evaluated
+ bool GetMeanings( std::vector< ::rtl::OUString > & rSynonyms, const ::rtl::OUString & rWord, const css::lang::Locale & rLocale, sal_Int16 nMaxSynonms );
+
+ String GetThesImplName( const css::lang::Locale &rLocale ) const;
+};
+
+////////////////////////////////////////////////////////////
+
+
+#endif
+
+
diff --git a/sfx2/source/view/impviewframe.hxx b/sfx2/source/view/impviewframe.hxx
index 5460d613c7e8..abe4cb6852d9 100644
--- a/sfx2/source/view/impviewframe.hxx
+++ b/sfx2/source/view/impviewframe.hxx
@@ -31,6 +31,8 @@
#include <svtools/asynclink.hxx>
#include <vcl/window.hxx>
+#include <boost/optional.hpp>
+
struct SfxViewFrame_Impl
{
SvBorder aBorder;
@@ -56,6 +58,8 @@ struct SfxViewFrame_Impl
sal_Bool bWindowWasEnabled:1;
sal_Bool bActive;
String aFactoryName;
+ ::boost::optional< bool >
+ aHasToolPanels;
SfxViewFrame_Impl( SfxFrame& i_rFrame )
: rFrame( i_rFrame )
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 66af0d7ac8ba..189c9a8aae0e 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -44,6 +44,7 @@
#endif
#include <unotools/moduleoptions.hxx>
#include <svl/intitem.hxx>
+#include <svl/visitem.hxx>
#include <svl/stritem.hxx>
#include <svl/eitem.hxx>
#include <svl/slstitm.hxx>
@@ -94,6 +95,8 @@
#include <svtools/asynclink.hxx>
#include <svl/sharecontrolfile.hxx>
+#include <boost/optional.hpp>
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
@@ -108,6 +111,7 @@ namespace css = ::com::sun::star;
// wg. ViewFrame::Current
#include "appdata.hxx"
+#include <sfx2/taskpane.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objface.hxx>
#include "openflag.hxx"
@@ -169,6 +173,19 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem);
//=========================================================================
//-------------------------------------------------------------------------
+namespace
+{
+ bool moduleHasToolPanels( SfxViewFrame_Impl& i_rViewFrameImpl )
+ {
+ if ( !i_rViewFrameImpl.aHasToolPanels )
+ {
+ i_rViewFrameImpl.aHasToolPanels.reset( ::sfx2::ModuleTaskPane::ModuleHasToolPanels(
+ i_rViewFrameImpl.rFrame.GetFrameInterface() ) );
+ }
+ return *i_rViewFrameImpl.aHasToolPanels;
+ }
+}
+//-------------------------------------------------------------------------
void SfxViewFrame::SetDowning_Impl()
{
pImp->bIsDowning = sal_True;
@@ -3294,6 +3311,22 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState )
else if ( KnowsChildWindow(nSID) )
rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
}
+ else if ( nSID == SID_TASKPANE )
+ {
+ if ( !KnowsChildWindow( nSID ) )
+ {
+ OSL_ENSURE( false, "SID_TASKPANE state requested, but no task pane child window exists for this ID!" );
+ rState.DisableItem( nSID );
+ }
+ else if ( !moduleHasToolPanels( *pImp ) )
+ {
+ rState.Put( SfxVisibilityItem( nSID, sal_False ) );
+ }
+ else
+ {
+ rState.Put( SfxBoolItem( nSID, HasChildWindow( nSID ) ) );
+ }
+ }
else if ( KnowsChildWindow(nSID) )
rState.Put( SfxBoolItem( nSID, HasChildWindow(nSID) ) );
else
@@ -3381,3 +3414,37 @@ void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame )
{
SFX_APP()->SetViewFrame_Impl( pFrame );
}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SfxViewFrame::ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL )
+{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+ // look up the SfxFrame for the given XFrame
+ SfxFrame* pFrame = NULL;
+ for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) )
+ {
+ if ( pFrame->GetFrameInterface() == i_rFrame )
+ break;
+ }
+ SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : NULL;
+ ENSURE_OR_RETURN_VOID( pViewFrame != NULL, "SfxViewFrame::ActivateToolPanel: did not find an SfxFrame for the given XFrame!" );
+
+ pViewFrame->ActivateToolPanel_Impl( i_rPanelURL );
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+void SfxViewFrame::ActivateToolPanel_Impl( const ::rtl::OUString& i_rPanelURL )
+{
+ // ensure the task pane is visible
+ ENSURE_OR_RETURN_VOID( KnowsChildWindow( SID_TASKPANE ), "SfxViewFrame::ActivateToolPanel: this frame/module does not allow for a task pane!" );
+ if ( !HasChildWindow( SID_TASKPANE ) )
+ ToggleChildWindow( SID_TASKPANE );
+
+ SfxChildWindow* pTaskPaneChildWindow = GetChildWindow( SID_TASKPANE );
+ ENSURE_OR_RETURN_VOID( pTaskPaneChildWindow, "SfxViewFrame::ActivateToolPanel_Impl: just switched it on, but it is not there!" );
+
+ ::sfx2::ITaskPaneToolPanelAccess* pPanelAccess = dynamic_cast< ::sfx2::ITaskPaneToolPanelAccess* >( pTaskPaneChildWindow );
+ ENSURE_OR_RETURN_VOID( pPanelAccess, "SfxViewFrame::ActivateToolPanel_Impl: task pane child window does not implement a required interface!" );
+ pPanelAccess->ActivateToolPanel( i_rPanelURL );
+}
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 4d9016d81f6b..f62ae4c1ddc7 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -129,28 +129,6 @@ SfxPrinterController::SfxPrinterController( const Any& i_rComplete,
StartListening( *mpViewShell );
mpObjectShell = mpViewShell->GetObjectShell();
StartListening( *mpObjectShell );
- m_bOrigStatus = mpObjectShell->IsEnableSetModified();
-
- // check configuration: shall update of printing information in DocInfo set the document to "modified"?
- if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
- {
- mpObjectShell->EnableSetModified( sal_False );
- m_bNeedsChange = sal_True;
- }
-
- // refresh document info
- uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties());
- m_aLastPrintedBy = xDocProps->getPrintedBy();
- m_aLastPrinted = xDocProps->getPrintDate();
-
- xDocProps->setPrintedBy( mpObjectShell->IsUseUserData()
- ? ::rtl::OUString( SvtUserOptions().GetFullName() )
- : ::rtl::OUString() );
- ::DateTime now;
-
- xDocProps->setPrintDate( util::DateTime(
- now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
- now.GetDay(), now.GetMonth(), now.GetYear() ) );
}
// initialize extra ui options
@@ -283,6 +261,29 @@ void SfxPrinterController::jobStarted()
{
if ( mpObjectShell )
{
+ m_bOrigStatus = mpObjectShell->IsEnableSetModified();
+
+ // check configuration: shall update of printing information in DocInfo set the document to "modified"?
+ if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
+ {
+ mpObjectShell->EnableSetModified( sal_False );
+ m_bNeedsChange = sal_True;
+ }
+
+ // refresh document info
+ uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties());
+ m_aLastPrintedBy = xDocProps->getPrintedBy();
+ m_aLastPrinted = xDocProps->getPrintDate();
+
+ xDocProps->setPrintedBy( mpObjectShell->IsUseUserData()
+ ? ::rtl::OUString( SvtUserOptions().GetFullName() )
+ : ::rtl::OUString() );
+ ::DateTime now;
+
+ xDocProps->setPrintDate( util::DateTime(
+ now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(),
+ now.GetDay(), now.GetMonth(), now.GetYear() ) );
+
// FIXME: how to get all print options incl. AdditionalOptions easily?
uno::Sequence < beans::PropertyValue > aOpts;
mpObjectShell->Broadcast( SfxPrintingHint( view::PrintableState_JOB_STARTED, aOpts ) );
diff --git a/sfx2/util/hidother.src b/sfx2/util/hidother.src
index 3ef31046bb00..38e5577a72be 100644
--- a/sfx2/util/hidother.src
+++ b/sfx2/util/hidother.src
@@ -166,3 +166,5 @@ hidspecial HID_HELP_ONHELP { HelpID = HID_HELP_ONHELP; };
hidspecial HID_HELP_TEXT_SELECTION_MODE { HelpID = HID_HELP_TEXT_SELECTION_MODE; };
hidspecial HID_DLG_CHECKFORONLINEUPDATE { HelpID = HID_DLG_CHECKFORONLINEUPDATE; };
hidspecial HID_DOCINFOSECURITY { HelpID = HID_DOCINFOSECURITY; };
+hidspecial HID_TASKPANE_VIEW_MENU { HelpID = HID_TASKPANE_VIEW_MENU; };
+
diff --git a/sfx2/win/res/expdesk.ico b/sfx2/win/res/expdesk.ico
deleted file mode 100644
index 06fb6e712e89..000000000000
--- a/sfx2/win/res/expdesk.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/expexp.ico b/sfx2/win/res/expexp.ico
deleted file mode 100644
index e0643765f605..000000000000
--- a/sfx2/win/res/expexp.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/expfld.ico b/sfx2/win/res/expfld.ico
deleted file mode 100644
index aeefecbdad51..000000000000
--- a/sfx2/win/res/expfld.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/expftp.ico b/sfx2/win/res/expftp.ico
deleted file mode 100644
index e1a442067d35..000000000000
--- a/sfx2/win/res/expftp.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/exptrash.ico b/sfx2/win/res/exptrash.ico
deleted file mode 100644
index 5c3e956863c3..000000000000
--- a/sfx2/win/res/exptrash.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/expwork.ico b/sfx2/win/res/expwork.ico
deleted file mode 100644
index 93fe39c7a492..000000000000
--- a/sfx2/win/res/expwork.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/frameset.ico b/sfx2/win/res/frameset.ico
deleted file mode 100644
index c9546f1e4d40..000000000000
--- a/sfx2/win/res/frameset.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/win/res/search.ico b/sfx2/win/res/search.ico
deleted file mode 100644
index 13e96131e3b8..000000000000
--- a/sfx2/win/res/search.ico
+++ /dev/null
Binary files differ
diff --git a/sfx2/workben/custompanel/CalcWindowState.xcu b/sfx2/workben/custompanel/CalcWindowState.xcu
new file mode 100644
index 000000000000..17629c0bf698
--- /dev/null
+++ b/sfx2/workben/custompanel/CalcWindowState.xcu
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="CalcWindowState" oor:package="org.openoffice.Office.UI" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.colorpanel/0000FF" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value>Soylent Blue</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ImageURL" oor:type="xs:string">
+ <value>vnd.sun.star.extension://UPDATED_IDENTIFIER/panel.png</value>
+ </prop>
+ <prop oor:name="HelpURL" oor:type="xs:string">
+ <value>vnd.sun.star.help://UPDATED_IDENTIFIER/colorpanel</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/DrawWindowState.xcu b/sfx2/workben/custompanel/DrawWindowState.xcu
new file mode 100644
index 000000000000..6037a3f5a083
--- /dev/null
+++ b/sfx2/workben/custompanel/DrawWindowState.xcu
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="DrawWindowState" oor:package="org.openoffice.Office.UI" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.colorpanel/FFFF00" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value>Soylent Yellow</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ImageURL" oor:type="xs:string">
+ <value>vnd.sun.star.extension://UPDATED_IDENTIFIER/panel.png</value>
+ </prop>
+ <prop oor:name="HelpURL" oor:type="xs:string">
+ <value>vnd.sun.star.help://UPDATED_IDENTIFIER/colorpanel</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/Factories.xcu b/sfx2/workben/custompanel/Factories.xcu
new file mode 100644
index 000000000000..f8df23e9f40a
--- /dev/null
+++ b/sfx2/workben/custompanel/Factories.xcu
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="Factories" oor:package="org.openoffice.Office.UI" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Registered">
+ <node oor:name="UIElementFactories">
+ <node oor:name="org.openoffice.example.CustomToolPanel" oor:op="replace">
+ <prop oor:name="Type">
+ <value>toolpanel</value>
+ </prop>
+ <prop oor:name="Name">
+ <value>org.openoffice.example.colorpanel</value>
+ </prop>
+ <prop oor:name="Module">
+ <value/>
+ </prop>
+ <prop oor:name="FactoryImplementation">
+ <value>org.openoffice.example.colorpanel.ToolPanelFactory</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/ImpressWindowState.xcu b/sfx2/workben/custompanel/ImpressWindowState.xcu
new file mode 100644
index 000000000000..a8fea859bbab
--- /dev/null
+++ b/sfx2/workben/custompanel/ImpressWindowState.xcu
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="ImpressWindowState" oor:package="org.openoffice.Office.UI" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.colorpanel/FFCC99" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value>Soylent Orange</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ImageURL" oor:type="xs:string">
+ <value>vnd.sun.star.extension://UPDATED_IDENTIFIER/panel.png</value>
+ </prop>
+ <prop oor:name="HelpURL" oor:type="xs:string">
+ <value>vnd.sun.star.help://UPDATED_IDENTIFIER/colorpanel</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/WriterWindowState.xcu b/sfx2/workben/custompanel/WriterWindowState.xcu
new file mode 100644
index 000000000000..248a2e14a3f4
--- /dev/null
+++ b/sfx2/workben/custompanel/WriterWindowState.xcu
@@ -0,0 +1,35 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="WriterWindowState" oor:package="org.openoffice.Office.UI" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="UIElements">
+ <node oor:name="States">
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.colorpanel/00FF00" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value>Soylent Green</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ImageURL" oor:type="xs:string">
+ <value>vnd.sun.star.extension://UPDATED_IDENTIFIER/panel.png</value>
+ </prop>
+ <prop oor:name="HelpURL" oor:type="xs:string">
+ <value>vnd.sun.star.help://UPDATED_IDENTIFIER/colorpanel</value>
+ </prop>
+ </node>
+ <node oor:name="private:resource/toolpanel/org.openoffice.example.colorpanel/FF0000" oor:op="replace">
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value>Soylent Red</value>
+ </prop>
+ <prop oor:name="Visible" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ <prop oor:name="ImageURL" oor:type="xs:string">
+ <value>vnd.sun.star.extension://UPDATED_IDENTIFIER/panel.png</value>
+ </prop>
+ <prop oor:name="HelpURL" oor:type="xs:string">
+ <value>vnd.sun.star.help://UPDATED_IDENTIFIER/colorpanel</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/sfx2/workben/custompanel/ctp_factory.cxx b/sfx2/workben/custompanel/ctp_factory.cxx
new file mode 100644
index 000000000000..54880cc5fcc7
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_factory.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "ctp_factory.hxx"
+#include "ctp_panel.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NotInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+/** === end UNO includes === **/
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ /** === 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::lang::NotInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::ui::XUIElement;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= ToolPanelFactory
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ 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)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !i_rResourceURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "private:resource/toolpanel/org.openoffice.example.colorpanel/" ) ) )
+ throw NoSuchElementException( i_rResourceURL, *this );
+
+ const ::rtl::OUString sColor( i_rResourceURL.copy( i_rResourceURL.lastIndexOf( '/' ) + 1 ) );
+ const sal_Int32 nPanelColor = sColor.toInt32( 16 );
+
+ // retrieve the parent window
+ Reference< XWindow > xParentWindow;
+ const PropertyValue* pArg = i_rArgs.getConstArray();
+ const PropertyValue* pArgEnd = i_rArgs.getConstArray() + i_rArgs.getLength();
+ for ( ; pArg != pArgEnd; ++pArg )
+ {
+ if ( pArg->Name.equalsAscii( "ParentWindow" ) )
+ {
+ xParentWindow.set( pArg->Value, UNO_QUERY );
+ break;
+ }
+ }
+ if ( !xParentWindow.is() )
+ {
+ OSL_ENSURE( false, "ToolPanelFactory::createUIElement: no parent window in the args!" );
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No parent window provided in the creation arguments. Cannot create tool panel." ) ),
+ *this,
+ 2
+ );
+ }
+
+ /// create the panel
+ Reference< XUIElement > xUIElement( new PanelUIElement( m_xContext, xParentWindow, i_rResourceURL, nPanelColor ) );
+ return xUIElement;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ToolPanelFactory::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.example.custompanel.ToolPanelFactory" ) );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ToolPanelFactory::supportsService( const ::rtl::OUString& i_rServiceName ) throw (RuntimeException)
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* serviceName = aServiceNames.getConstArray();
+ serviceName != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++serviceName
+ )
+ {
+ if ( i_rServiceName == *serviceName )
+ return sal_True;
+ }
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory::getSupportedServiceNames() throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ToolPanelFactory::getSupportedServiceNames_static() throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.example.colorpanel.ToolPanelFactory" ) );
+ return aServiceNames;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ToolPanelFactory::Create( const Reference< XComponentContext >& i_rContext ) throw (RuntimeException)
+ {
+ return *( new ToolPanelFactory( i_rContext ) );
+ }
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
diff --git a/sfx2/workben/custompanel/ctp_factory.hxx b/sfx2/workben/custompanel/ctp_factory.hxx
new file mode 100644
index 000000000000..8a359f59caaf
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_factory.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ * 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_WORKBENCH_CTP_FACTORY_HXX
+#define SD_WORKBENCH_CTP_FACTORY_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ class FactoryGuard;
+
+ //==================================================================================================================
+ //= ToolPanelFactory
+ //==================================================================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::ui::XUIElementFactory
+ , ::com::sun::star::lang::XServiceInfo
+ > ToolPanelFactory_Base;
+ class ToolPanelFactory :public ::cppu::BaseMutex
+ ,public ToolPanelFactory_Base
+ {
+ public:
+ ToolPanelFactory(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext
+ );
+ ~ToolPanelFactory();
+
+ // XUIElementFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const ::rtl::OUString& i_rResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rArgs ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+ };
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
+
+#endif // SD_WORKBENCH_CTP_FACTORY_HXX
diff --git a/sfx2/workben/custompanel/ctp_panel.cxx b/sfx2/workben/custompanel/ctp_panel.cxx
new file mode 100644
index 000000000000..ee94287bedbf
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_panel.cxx
@@ -0,0 +1,270 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "ctp_panel.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/XToolkit.hpp>
+#include <com/sun/star/awt/WindowClass.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/awt/XGraphics.hpp>
+#include <com/sun/star/ui/UIElementType.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ /** === 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::awt::XWindow;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::awt::XWindowPeer;
+ using ::com::sun::star::lang::XMultiComponentFactory;
+ using ::com::sun::star::awt::XToolkit;
+ using ::com::sun::star::awt::WindowDescriptor;
+ using ::com::sun::star::awt::WindowClass_SIMPLE;
+ using ::com::sun::star::awt::Rectangle;
+ using ::com::sun::star::awt::PaintEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::awt::XDevice;
+ using ::com::sun::star::awt::XGraphics;
+ using ::com::sun::star::accessibility::XAccessible;
+ using ::com::sun::star::frame::XFrame;
+ /** === end UNO using === **/
+ namespace WindowAttribute = ::com::sun::star::awt::WindowAttribute;
+ namespace PosSize = ::com::sun::star::awt::PosSize;
+ namespace UIElementType = ::com::sun::star::ui::UIElementType;
+
+ //==================================================================================================================
+ //= helpers
+ //==================================================================================================================
+ namespace
+ {
+ Reference< XWindow > lcl_createPlainWindow_nothrow( const Reference< XComponentContext >& i_rContext,
+ const Reference< XWindowPeer >& i_rParentWindow )
+ {
+ try
+ {
+ ENSURE_OR_THROW( i_rContext.is(), "illegal component context" );
+ Reference< XMultiComponentFactory > xFactory( i_rContext->getServiceManager(), UNO_SET_THROW );
+ Reference< XToolkit > xToolkit( xFactory->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.Toolkit" ) ),
+ i_rContext
+ ), UNO_QUERY_THROW );
+
+ WindowDescriptor aWindow;
+ aWindow.Type = WindowClass_SIMPLE;
+ aWindow.WindowServiceName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "window" ) );
+ aWindow.Parent = i_rParentWindow;
+ aWindow.WindowAttributes = WindowAttribute::BORDER;
+
+ Reference< XWindowPeer > xWindow( xToolkit->createWindow( aWindow ), UNO_SET_THROW );
+ return Reference< XWindow >( xWindow, UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+ }
+ }
+ //==================================================================================================================
+ //= class SingleColorPanel
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ SingleColorPanel::SingleColorPanel( const Reference< XComponentContext >& i_rContext, const Reference< XWindow >& i_rParentWindow, const ::sal_Int32 i_nPanelColor )
+ :SingleColorPanel_Base( m_aMutex )
+ ,m_xWindow()
+ ,m_nPanelColor( i_nPanelColor )
+ {
+ // retrieve the parent window for our to-be-created pane window
+ Reference< XWindowPeer > xParentPeer( i_rParentWindow, UNO_QUERY );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ if ( xParentPeer.is() )
+ {
+ m_xWindow = lcl_createPlainWindow_nothrow( i_rContext, xParentPeer );
+ m_xWindow->addPaintListener( this );
+ if ( m_xWindow.is() )
+ {
+ const Rectangle aPanelAnchorSize( i_rParentWindow->getPosSize() );
+ m_xWindow->setPosSize( 0, 0, aPanelAnchorSize.Width, aPanelAnchorSize.Height, PosSize::POSSIZE );
+ m_xWindow->setVisible( sal_True );
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ SingleColorPanel::~SingleColorPanel()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XWindow > SAL_CALL SingleColorPanel::getWindow() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xWindow.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+ return m_xWindow;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XAccessible > SAL_CALL SingleColorPanel::createAccessible( const Reference< XAccessible >& i_rParentAccessible ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xWindow.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ // TODO: the following is wrong, since it doesn't respect i_rParentAccessible. In a real extension, you should
+ // implement this correctly :)
+ (void)i_rParentAccessible;
+ return Reference< XAccessible >( getWindow(), UNO_QUERY );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL SingleColorPanel::windowPaint( const PaintEvent& i_rEvent ) throw (RuntimeException)
+ {
+ try
+ {
+ const Reference< XDevice > xDevice( i_rEvent.Source, UNO_QUERY_THROW );
+ const Reference< XGraphics > xGraphics( xDevice->createGraphics(), UNO_SET_THROW );
+ xGraphics->setFillColor( m_nPanelColor );
+ xGraphics->setLineColor( 0x00FFFFFF );
+
+ const Reference< XWindow > xWindow( i_rEvent.Source, UNO_QUERY_THROW );
+ const Rectangle aWindowRect( xWindow->getPosSize() );
+ xGraphics->drawRect( 0, 0, aWindowRect.Width - 1, aWindowRect.Height - 1 );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL SingleColorPanel::disposing( const EventObject& i_rSource ) throw (RuntimeException)
+ {
+ (void)i_rSource;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL SingleColorPanel::disposing()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xWindow.is() )
+ // already disposed
+ return;
+ m_xWindow->removePaintListener( this );
+ try
+ {
+ Reference< XComponent > xWindowComp( m_xWindow, UNO_QUERY_THROW );
+ xWindowComp->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xWindow.clear();
+ }
+
+ //==================================================================================================================
+ //= PanelUIElement
+ //==================================================================================================================
+ //------------------------------------------------------------------------------------------------------------------
+ PanelUIElement::PanelUIElement( const Reference< XComponentContext >& i_rContext, const Reference< XWindow >& i_rParentWindow,
+ const ::rtl::OUString& i_rResourceURL, const ::sal_Int32 i_nPanelColor )
+ :PanelUIElement_Base( m_aMutex )
+ ,m_sResourceURL( i_rResourceURL )
+ ,m_xToolPanel( new SingleColorPanel( i_rContext, i_rParentWindow, i_nPanelColor ) )
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ PanelUIElement::~PanelUIElement()
+ {
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XFrame > SAL_CALL PanelUIElement::getFrame() throw (RuntimeException)
+ {
+ // TODO
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PanelUIElement::getResourceURL() throw (RuntimeException)
+ {
+ return m_sResourceURL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL PanelUIElement::getType() throw (RuntimeException)
+ {
+ return UIElementType::TOOLPANEL;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL PanelUIElement::getRealInterface( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xToolPanel.is() )
+ throw DisposedException();
+ return m_xToolPanel;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL PanelUIElement::disposing()
+ {
+ Reference< XComponent > xPanelComponent( m_xToolPanel, UNO_QUERY_THROW );
+ m_xToolPanel.clear();
+ xPanelComponent->dispose();
+ }
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
diff --git a/sfx2/workben/custompanel/ctp_panel.hxx b/sfx2/workben/custompanel/ctp_panel.hxx
new file mode 100644
index 000000000000..39c46c9d93a5
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_panel.hxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ * 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_WORKBENCH_CTP_PANEL_HXX
+#define SD_WORKBENCH_CTP_PANEL_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/XToolPanel.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/awt/XPaintListener.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ //==================================================================================================================
+ //= SingleColorPanel
+ //==================================================================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::ui::XToolPanel
+ , ::com::sun::star::awt::XPaintListener
+ > SingleColorPanel_Base;
+ class SingleColorPanel :public ::cppu::BaseMutex
+ ,public SingleColorPanel_Base
+ {
+ public:
+ SingleColorPanel(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& i_rParentWindow,
+ const ::sal_Int32 i_nPanelColor
+ );
+
+ // 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 >& i_rParentAccessible ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPaintListener
+ virtual void SAL_CALL windowPaint( const ::com::sun::star::awt::PaintEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent equivalents
+ virtual void SAL_CALL disposing();
+
+ protected:
+ ~SingleColorPanel();
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xWindow;
+ const sal_Int32 m_nPanelColor;
+ };
+
+ //==================================================================================================================
+ //= PanelUIElement
+ //==================================================================================================================
+ typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::ui::XUIElement
+ > PanelUIElement_Base;
+ class PanelUIElement :public ::cppu::BaseMutex
+ ,public PanelUIElement_Base
+ {
+ public:
+ PanelUIElement(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& i_rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& i_rParentWindow,
+ const ::rtl::OUString& i_rResourceURL,
+ const ::sal_Int32 i_nPanelColor
+ );
+
+ // 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);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ protected:
+ ~PanelUIElement();
+
+ private:
+ const ::rtl::OUString m_sResourceURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::ui::XToolPanel >
+ m_xToolPanel;
+ };
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
+
+#endif // SD_WORKBENCH_CTP_PANEL_HXX
diff --git a/sfx2/workben/custompanel/ctp_services.cxx b/sfx2/workben/custompanel/ctp_services.cxx
new file mode 100644
index 000000000000..4164e8bc1629
--- /dev/null
+++ b/sfx2/workben/custompanel/ctp_services.cxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ * 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_sfx2.hxx"
+
+#include "ctp_factory.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <cppuhelper/implementationentry.hxx>
+
+//......................................................................................................................
+namespace sd { namespace colortoolpanel
+{
+//......................................................................................................................
+
+ /** === 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;
+ /** === end UNO using === **/
+
+ //==================================================================================================================
+ //= descriptors for the services implemented in this component
+ //==================================================================================================================
+ static struct ::cppu::ImplementationEntry s_aServiceEntries[] =
+ {
+ {
+ ToolPanelFactory::Create,
+ ToolPanelFactory::getImplementationName_static,
+ ToolPanelFactory::getSupportedServiceNames_static,
+ ::cppu::createSingleComponentFactory, NULL, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+ };
+
+//......................................................................................................................
+} } // namespace sd::colortoolpanel
+//......................................................................................................................
+
+extern "C"
+{
+ //------------------------------------------------------------------------------------------------------------------
+ void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** )
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey )
+ {
+ return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, ::sd::colortoolpanel::s_aServiceEntries );
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+ {
+ return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , ::sd::colortoolpanel::s_aServiceEntries );
+ }
+}
diff --git a/sfx2/workben/custompanel/delzip b/sfx2/workben/custompanel/delzip
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/sfx2/workben/custompanel/delzip
diff --git a/sfx2/workben/custompanel/description.xml b/sfx2/workben/custompanel/description.xml
new file mode 100644
index 000000000000..a90aa73a77f6
--- /dev/null
+++ b/sfx2/workben/custompanel/description.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description
+ xmlns="http://openoffice.org/extensions/description/2006"
+ xmlns:d="http://openoffice.org/extensions/description/2006"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+
+ <identifier value="UPDATED_IDENTIFIER"/>
+ <version value="0.1" />
+ <platform value="UPDATED_SUPPORTED_PLATFORM" />
+ <display-name>
+ <name>Custom Tool Panel Example</name>
+ </display-name>
+ <dependencies>
+ <OpenOffice.org-minimal-version value="3.3" d:name="OpenOffice.org 3.3"/>
+ </dependencies>
+</description>
diff --git a/sfx2/workben/custompanel/makefile.mk b/sfx2/workben/custompanel/makefile.mk
new file mode 100644
index 000000000000..1eb20ceed35d
--- /dev/null
+++ b/sfx2/workben/custompanel/makefile.mk
@@ -0,0 +1,120 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=../..
+PRJNAME=sfx2
+
+TARGET=custompanel
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+EXTENSIONNAME:=custom-tool-panel
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+#-------------------------------------------------------------------
+
+#---- extension version
+EXTENSION_VERSION_BASE=0.1
+.IF ( "$(CWS_WORK_STAMP)" == "" ) || ( "$(UPDATER)" == "YES" )
+ EXTENSION_VERSION=$(EXTENSION_VERSION_BASE)
+.ELSE
+ EXTENSION_VERSION=$(EXTENSION_VERSION_BASE).cws.$(CWS_WORK_STAMP)
+.ENDIF
+
+#---- extension title package name
+EXTENSION_TITLE=Custom Tool Panel Example
+EXTENSION_ZIPNAME=$(EXTENSIONNAME)-$(EXTENSION_VERSION_BASE)-$(RTL_OS:l)-$(RTL_ARCH:l)
+
+#--------------------------------------------------
+
+SHL1DLLPRE=
+SHL1TARGET=$(TARGET).uno
+LIB1TARGET=$(SLB)/$(SHL1TARGET).lib
+LIB1OBJFILES= \
+ $(SLO)/ctp_factory.obj \
+ $(SLO)/ctp_services.obj \
+ $(SLO)/ctp_panel.obj
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(SALHELPERLIB) \
+ $(CPPUHELPERLIB)
+
+SHL1VERSIONMAP=$(SOLARSRC)/solenv/src/component.map
+SHL1LIBS= $(LIB1TARGET)
+SHL1DEF= $(MISC)/$(SHL1TARGET).def
+SHL1RPATH= OXT
+DEF1NAME= $(SHL1TARGET)
+
+# create Extension -----------------------------
+
+COMPONENT_CONFIGDEST=.
+
+COMPONENT_XCU = \
+ $(EXTENSIONDIR)/WriterWindowState.xcu \
+ $(EXTENSIONDIR)/CalcWindowState.xcu \
+ $(EXTENSIONDIR)/DrawWindowState.xcu \
+ $(EXTENSIONDIR)/ImpressWindowState.xcu \
+ $(EXTENSIONDIR)/Factories.xcu
+
+COMPONENT_LIBRARIES = \
+ $(EXTENSIONDIR)/$(SHL1TARGET)$(DLLPOST)
+
+COMPONENT_IMAGES= \
+ $(EXTENSIONDIR)/panel.png
+
+# ........ dependencies for packaging the extension ........
+EXTENSION_PACKDEPS=makefile.mk $(COMPONENT_IMAGES)
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : extension_pre.mk
+.INCLUDE : target.mk
+.INCLUDE : extension_post.mk
+
+$(EXTENSIONDIR)/%.png : ./%.png
+ @@-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@ > $(NULLDEV)
+
+$(EXTENSIONDIR)/WriterWindowState.xcu: ./WriterWindowState.xcu
+ @@-$(MKDIRHIER) $(@:d)
+ $(COMMAND_ECHO)$(TYPE) ./WriterWindowState.xcu | sed s/UPDATED_IDENTIFIER/$(IMPLEMENTATION_IDENTIFIER)/ > $(EXTENSIONDIR)/WriterWindowState.xcu
+
+$(EXTENSIONDIR)/CalcWindowState.xcu: ./CalcWindowState.xcu
+ @@-$(MKDIRHIER) $(@:d)
+ $(COMMAND_ECHO)$(TYPE) ./CalcWindowState.xcu | sed s/UPDATED_IDENTIFIER/$(IMPLEMENTATION_IDENTIFIER)/ > $(EXTENSIONDIR)/CalcWindowState.xcu
+
+$(EXTENSIONDIR)/DrawWindowState.xcu: ./DrawWindowState.xcu
+ @@-$(MKDIRHIER) $(@:d)
+ $(COMMAND_ECHO)$(TYPE) ./DrawWindowState.xcu | sed s/UPDATED_IDENTIFIER/$(IMPLEMENTATION_IDENTIFIER)/ > $(EXTENSIONDIR)/DrawWindowState.xcu
+
+$(EXTENSIONDIR)/ImpressWindowState.xcu: ./ImpressWindowState.xcu
+ @@-$(MKDIRHIER) $(@:d)
+ $(COMMAND_ECHO)$(TYPE) ./ImpressWindowState.xcu | sed s/UPDATED_IDENTIFIER/$(IMPLEMENTATION_IDENTIFIER)/ > $(EXTENSIONDIR)/ImpressWindowState.xcu
+
diff --git a/sfx2/workben/custompanel/manifest.xml b/sfx2/workben/custompanel/manifest.xml
new file mode 100644
index 000000000000..9122d16a4189
--- /dev/null
+++ b/sfx2/workben/custompanel/manifest.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
+<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.uno-component;type=native"
+ manifest:full-path="custompanel.unoSHARED_EXTENSION"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="WriterWindowState.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="CalcWindowState.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="DrawWindowState.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="ImpressWindowState.xcu"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data"
+ manifest:full-path="Factories.xcu"/>
+ <!-- <manifest:file-entry manifest:media-type="image/png"
+ manifest:full-path="panel.png"/>-->
+</manifest:manifest>
diff --git a/sfx2/workben/custompanel/panel.png b/sfx2/workben/custompanel/panel.png
new file mode 100644
index 000000000000..2438714af8a6
--- /dev/null
+++ b/sfx2/workben/custompanel/panel.png
Binary files differ