diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2010-03-23 11:58:14 +0100 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2010-03-23 11:58:14 +0100 |
commit | 19dcc11eb4ad63118ef1345cd2901763b126d34c (patch) | |
tree | 32a5f5f2b4cb0471021fafb0965a15d79318a640 /sfx2 | |
parent | 1dfffc435b365edf9d621373e85879df6a16222f (diff) | |
parent | 9cb7d012fccf37c491ffcfa83ce795534e6ed475 (diff) |
CWS-TOOLING: integrate CWS autorecovery
Diffstat (limited to 'sfx2')
89 files changed, 3949 insertions, 7394 deletions
diff --git a/sfx2/inc/frmload.hxx b/sfx2/inc/frmload.hxx index 7fc5ba91f8c7..b03bdd724c20 100644 --- a/sfx2/inc/frmload.hxx +++ b/sfx2/inc/frmload.hxx @@ -28,80 +28,126 @@ #ifndef _SFX_FRMLOAD_HXX #define _SFX_FRMLOAD_HXX +#include "sfx2/sfxuno.hxx" +#include "sfx2/objsh.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/frame/XLoadEventListener.hpp> -#include <rtl/ustring.hxx> -#include <tools/debug.hxx> #include <com/sun/star/frame/XSynchronousFrameLoader.hpp> +#include <com/sun/star/frame/XController2.hpp> +#include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/document/XExtendedFilterDetection.hpp> #include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +/** === end UNO includes === **/ + +#include <rtl/ustring.hxx> +#include <tools/debug.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase3.hxx> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <cppuhelper/factory.hxx> #include <tools/link.hxx> #include <tools/string.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> -class SfxObjectFactory; +class SfxFilter; class SfxFilterMatcher; -class LoadEnvironment_Impl; -class SfxMedium; -namespace com -{ - namespace sun - { - namespace star - { - namespace uno - { - class Any; - } - namespace lang - { - class XMultiServiceFactory; - } - namespace frame - { - class XFrame; - } - namespace beans - { - struct PropertyValue; - } - } - } -} - -#include <sfx2/sfxuno.hxx> - -#define REFERENCE ::com::sun::star::uno::Reference -#define SEQUENCE ::com::sun::star::uno::Sequence -#define RUNTIME_EXCEPTION ::com::sun::star::uno::RuntimeException - -class SfxFrameLoader_Impl : public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XSynchronousFrameLoader, ::com::sun::star::lang::XServiceInfo > -{ - REFERENCE < ::com::sun::star::frame::XFrame > xFrame; - REFERENCE < ::com::sun::star::frame::XLoadEventListener > xListener; - String aFilterName; - SfxMedium* pMedium; +class SfxFrameWeak; - DECL_LINK( LoadDone_Impl, void* ); +class SAL_DLLPRIVATE SfxFrameLoader_Impl : public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XSynchronousFrameLoader, ::com::sun::star::lang::XServiceInfo > +{ + ::comphelper::ComponentContext m_aContext; public: - SfxFrameLoader_Impl( const REFERENCE < ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); - virtual ~SfxFrameLoader_Impl(); + SfxFrameLoader_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory ); SFX_DECL_XSERVICEINFO //---------------------------------------------------------------------------------- // XSynchronousFrameLoader //---------------------------------------------------------------------------------- - virtual sal_Bool SAL_CALL load( const SEQUENCE< ::com::sun::star::beans::PropertyValue >& lDescriptor, const REFERENCE< ::com::sun::star::frame::XFrame >& xFrame ) throw( RUNTIME_EXCEPTION ); - virtual void SAL_CALL cancel() throw( RUNTIME_EXCEPTION ); + virtual sal_Bool SAL_CALL load( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL cancel() throw( ::com::sun::star::uno::RuntimeException ); + +protected: + virtual ~SfxFrameLoader_Impl(); + +private: + const SfxFilter* impl_getFilterFromServiceName_nothrow( + const ::rtl::OUString& i_rServiceName + ) const; + + ::rtl::OUString impl_askForFilter_nothrow( + const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& i_rxHandler, + const ::rtl::OUString& i_rDocumentURL + ) const; + + const SfxFilter* impl_detectFilterForURL( + const ::rtl::OUString& _rURL, + const ::comphelper::NamedValueCollection& i_rDescriptor, + const SfxFilterMatcher& rMatcher + ) const; + + sal_Bool impl_createNewDocWithSlotParam( + const USHORT _nSlotID, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rxFrame, + const bool i_bHidden + ); + + void impl_determineFilter( + ::comphelper::NamedValueCollection& io_rDescriptor + ) const; + + bool impl_determineTemplateDocument( + ::comphelper::NamedValueCollection& io_rDescriptor + ) const; + + USHORT impl_findSlotParam( + const ::rtl::OUString& i_rFactoryURL + ) const; + + SfxObjectShellLock impl_findObjectShell( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel2 >& i_rxDocument + ) const; + + void impl_lockHiddenDocument( + SfxObjectShell& i_rDocument, + const ::comphelper::NamedValueCollection& i_rDescriptor + ) const; + + void impl_handleCaughtError_nothrow( + const ::com::sun::star::uno::Any& i_rCaughtError, + const ::comphelper::NamedValueCollection& i_rDescriptor + ) const; + + void impl_removeLoaderArguments( + ::comphelper::NamedValueCollection& io_rDescriptor + ); + + sal_Int16 impl_determineEffectiveViewId_nothrow( + const SfxObjectShell& i_rDocument, + const ::comphelper::NamedValueCollection& i_rDescriptor + ); + + ::comphelper::NamedValueCollection + impl_extractViewCreationArgs( + ::comphelper::NamedValueCollection& io_rDescriptor + ); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 > + impl_createDocumentView( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel2 >& i_rModel, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const ::comphelper::NamedValueCollection& i_rViewFactoryArgs, + const ::rtl::OUString& i_rViewName + ); }; #endif diff --git a/sfx2/inc/inettbc.hxx b/sfx2/inc/inettbc.hxx index 401097c25fe9..fe8358bfe646 100644 --- a/sfx2/inc/inettbc.hxx +++ b/sfx2/inc/inettbc.hxx @@ -74,19 +74,6 @@ public: virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); }; -class SfxCancelToolBoxControl_Impl : public SfxToolBoxControl -{ -public: - - SFX_DECL_TOOLBOX_CONTROL(); - - SfxCancelToolBoxControl_Impl( USHORT nSlotId, USHORT nId, ToolBox& rBox ); - - virtual SfxPopupWindowType GetPopupWindowType() const; - virtual SfxPopupWindow* CreatePopupWindow(); - virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ); -}; - #endif #endif diff --git a/sfx2/inc/pch/precompiled_sfx2.hxx b/sfx2/inc/pch/precompiled_sfx2.hxx index 2bc592b686a7..8cd8f9d8561f 100644 --- a/sfx2/inc/pch/precompiled_sfx2.hxx +++ b/sfx2/inc/pch/precompiled_sfx2.hxx @@ -492,7 +492,6 @@ #include "svl/aeitem.hxx" #include "svtools/asynclink.hxx" #include "svl/brdcst.hxx" -#include "svl/cancel.hxx" #include "svl/cntwids.hrc" #include "svtools/controldims.hrc" #include "svl/ctypeitm.hxx" diff --git a/sfx2/inc/sfx2/app.hxx b/sfx2/inc/sfx2/app.hxx index 458ef15036b3..17b2dee417cd 100644 --- a/sfx2/inc/sfx2/app.hxx +++ b/sfx2/inc/sfx2/app.hxx @@ -58,7 +58,6 @@ class AppSettings; struct SfxChildWinContextFactory; class SfxAppData_Impl; class SfxBindings; -class SfxCancelManager; class SfxChildWinFactArr_Impl; class SfxChildWindow; class SfxDispatcher; @@ -218,7 +217,6 @@ public: // members SfxFilterMatcher& GetFilterMatcher(); - SfxCancelManager* GetCancelManager() const; SfxMacroConfig* GetMacroConfig() const; SfxProgress* GetProgress() const; const String& GetLastSaveDirectory() const; @@ -264,7 +262,6 @@ public: SAL_DLLPRIVATE SfxDispatcher* GetAppDispatcher_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl(); - SAL_DLLPRIVATE SfxObjectShellLock NewDoc_Impl( const String& rFactory, const SfxItemSet* pSet = NULL ); SAL_DLLPRIVATE BOOL QueryExit_Impl(); SAL_DLLPRIVATE void SetOptions_Impl(const SfxItemSet &); SAL_DLLPRIVATE FASTBOOL Initialize_Impl(); @@ -290,7 +287,6 @@ public: // TODO/CLEANUP: still needed? SAL_DLLPRIVATE void NewDocDirectExec_Impl(SfxRequest &); SAL_DLLPRIVATE void NewDocExec_Impl(SfxRequest &); - SAL_DLLPRIVATE const SfxPoolItem* NewDocDirectExec_ImplOld(SfxRequest &); // used by FrameLoader to work with the old behaviour ... SAL_DLLPRIVATE void OpenDocExec_Impl(SfxRequest &); SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); diff --git a/sfx2/inc/sfx2/bindings.hxx b/sfx2/inc/sfx2/bindings.hxx index 6f7660d71e40..e568fe7305f0 100644 --- a/sfx2/inc/sfx2/bindings.hxx +++ b/sfx2/inc/sfx2/bindings.hxx @@ -96,8 +96,7 @@ class SFX2_DLLPUBLIC SfxBindings: public SfxBroadcaster der Klasse SfxBindings. Sie wird von der SfxApplication automatisch angelegt und zerst"ort. Instanzen werden aber i.d.R. "uber das Makro <SFX_BINDINGS> oder den zugeh"origen <SfxViewFrame> besorgt - werden. Bestimmte SfxViewFrame Subklassen (z.B. <SfxInPlaceFrame>) - legen ihre eigene Instanz der SfxBindings an. + werden. Die SfxBindings verwalten alle in den an ihr angemeldeten Controllern gebundenen Slot-Ids und cachen die jeweiligen <Slot-Server> diff --git a/sfx2/inc/sfx2/docfac.hxx b/sfx2/inc/sfx2/docfac.hxx index be1d5b1d973a..3cc3eecc7ce7 100644 --- a/sfx2/inc/sfx2/docfac.hxx +++ b/sfx2/inc/sfx2/docfac.hxx @@ -82,6 +82,7 @@ public: const SvGlobalName& GetClassId() const; SfxObjectShellFlags GetFlags() { return nFlags; } const char* GetShortName() const { return pShortName; } + String GetFactoryURL() const; // shortcut for "private:factory/GetShortName()" String GetFactoryName() const { return String::CreateFromAscii( pShortName ); } String GetModuleName() const; void SetDocumentTypeNameResource( const ResId& rId ); @@ -93,6 +94,9 @@ public: USHORT GetViewFactoryCount() const; SfxViewFactory& GetViewFactory(USHORT i = 0) const; + /// returns the view factory whose GetViewName delivers the requested logical name + SfxViewFactory* GetViewFactoryByViewName( const String& i_rViewName ) const; + // Filter const SfxFilter* GetTemplateFilter() const; static String GetStandardTemplate( const String& rServiceName ); @@ -106,6 +110,7 @@ public: //#if 0 // _SOLAR__PRIVATE SAL_DLLPRIVATE void SetModule_Impl( SfxModule* ); SAL_DLLPRIVATE static void UpdateFilterContainers_Impl(); + SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const; //#endif private: diff --git a/sfx2/inc/sfx2/docfile.hxx b/sfx2/inc/sfx2/docfile.hxx index 03bcfec5818f..074f74cb0e72 100644 --- a/sfx2/inc/sfx2/docfile.hxx +++ b/sfx2/inc/sfx2/docfile.hxx @@ -48,7 +48,6 @@ #include <svl/lstner.hxx> #include <tools/globname.hxx> -#include <svl/cancel.hxx> #include <cppuhelper/weak.hxx> #include <ucbhelper/content.hxx> @@ -64,16 +63,6 @@ class SfxItemSet; class DateTime; class SvStringsDtor; class SvEaMgr; -class SfxPoolCancelManager_Impl; - -#define SFX_TFPRIO_SYNCHRON 0 -#define SFX_TFPRIO_DOC 10 -#define SFX_TFPRIO_VISIBLE_LOWRES_GRAPHIC 20 -#define SFX_TFPRIO_VISIBLE_HIGHRES_GRAPHIC 21 -#define SFX_TFPRIO_PLUGINS 40 -#define SFX_TFPRIO_INVISIBLE_LOWRES_GRAPHIC 50 -#define SFX_TFPRIO_INVISIBLE_HIGHRES_GRAPHIC 51 -#define SFX_TFPRIO_DOWNLOADS 60 #define S2BS(s) ByteString( s, RTL_TEXTENCODING_MS_1252 ) @@ -157,7 +146,6 @@ public: void SetLoadTargetFrame(SfxFrame* pFrame ); SfxFrame* GetLoadTargetFrame() const; - void CancelTransfers(); void SetReferer( const String& rRefer ); const String& GetReferer( ) const; @@ -235,7 +223,6 @@ public: void SetUsesCache( sal_Bool ); sal_Bool IsExpired() const; void SetName( const String& rName, sal_Bool bSetOrigURL = sal_False ); - void SetDontCreateCancellable(); sal_Bool IsAllowedForExternalBrowser() const; long GetFileVersion() const; @@ -273,8 +260,6 @@ public: SAL_DLLPRIVATE sal_Bool TransferVersionList_Impl( SfxMedium& rMedium ); SAL_DLLPRIVATE sal_Bool SaveVersionList_Impl( sal_Bool bUseXML ); SAL_DLLPRIVATE sal_Bool RemoveVersion_Impl( const ::rtl::OUString& rVersion ); - SAL_DLLPRIVATE SfxPoolCancelManager_Impl* GetCancelManager_Impl() const; - SAL_DLLPRIVATE void SetCancelManager_Impl( SfxPoolCancelManager_Impl* pMgr ); SAL_DLLPRIVATE void SetExpired_Impl( const DateTime& rDateTime ); SAL_DLLPRIVATE SvKeyValueIterator* GetHeaderAttributes_Impl(); diff --git a/sfx2/inc/sfx2/frame.hxx b/sfx2/inc/sfx2/frame.hxx index 77c578d6946f..b94e9038e8bb 100644 --- a/sfx2/inc/sfx2/frame.hxx +++ b/sfx2/inc/sfx2/frame.hxx @@ -68,6 +68,7 @@ namespace com #include <svl/brdcst.hxx> #include <tools/list.hxx> #include <svl/poolitem.hxx> +#include <comphelper/namedvaluecollection.hxx> class SvBorder; class SfxWorkWindow; @@ -83,31 +84,18 @@ class SfxMedium; class SfxFrameHistory_Impl; class SfxDispatcher; class SfxMedium; -class SfxCancellable; class Rectangle; class SfxRequest; class SfxUnoControllerItem; class SvCompatWeakHdl; +class SystemWindow; typedef SfxFrame* SfxFramePtr; class SfxFrameArr_Impl; DECLARE_LIST( TargetList, String* ) -#define SFXFRAME_INTERNAL 0x0001 -#define SFXFRAME_EXTERNAL 0x0002 -#define SFXFRAME_OWNSDOCUMENT 0x0004 -#define SFXFRAME_PLUGIN 0x0008 -#define SFXFRAME_HASTITLE 0x0010 -#define SFXFRAME_SERVER 0x0020 // Is es ein Frame, der in einem Container steckt ? -#define SFXFRAME_FRAMESET 0x0040 - -#define BROWSE_NORMAL 0 -#define BROWSE_FORWARD 1 -#define BROWSE_BACKWARD 2 -#define NO_BROWSE 3 -#define BROWSE_FRAME 4 -#define BROWSE_MAX_MODE 10 +#define SFXFRAME_HASTITLE 0x0001 //========================================================================== // Ein SfxFrame ist eine Verwaltungsklasse f"ur Fenster und deren Inhalte. @@ -123,82 +111,63 @@ DECLARE_LIST( TargetList, String* ) //========================================================================== class SfxFrameArr_Impl; -class SfxCancelManager; struct SfxFramePickEntry_Impl; -class SfxUnoFrame; class SFX2_DLLPUBLIC SfxFrame { friend class SfxFrameIterator; - friend struct SfxFramePickEntry_Impl; - friend class SfxUnoFrame; - friend class SfxViewFrame; /*HACK!*/ + friend class SfxFrameWindow_Impl; private: - String aName; SfxFrame* pParentFrame; SfxFrameArr_Impl* pChildArr; SfxFrame_Impl* pImp; - SfxUnoFrame* pUnoImp; - - SAL_DLLPRIVATE void UpdateUndoHistory_Impl( - SfxObjectShell *pDocSh, const String* pNew, const String *pTitle = 0 ); - SAL_DLLPRIVATE void UpdateCurrentHistory_Impl( - SfxObjectShell *pDocSh, const String* pNew ); + Window* pWindow; protected: - virtual sal_Bool Close() = 0; + sal_Bool Close(); virtual ~SfxFrame(); -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void SetCurrentDocument_Impl( SfxObjectShell* ); - SAL_DLLPRIVATE void InsertChildFrame_Impl( SfxFrame*, sal_uInt16 nPos = 0 ); - SAL_DLLPRIVATE void RemoveChildFrame_Impl( sal_uInt16 nPos ); SAL_DLLPRIVATE void RemoveChildFrame_Impl( SfxFrame* ); - SAL_DLLPRIVATE void SetIsTop_Impl( sal_Bool bIsTop = sal_True ); -//#endif + + SfxFrame( ); // not implemented + SAL_DLLPRIVATE SfxFrame( Window& i_rContainerWindow, bool bHidden ); public: TYPEINFO(); - SfxFrame(SfxFrame* pParent = 0); + + static SfxFrame* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame ); + static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > + CreateBlankFrame(); + static SfxFrame* Create( SfxObjectShell& rDoc, Window& rWindow, USHORT nViewId, bool bHidden ); SvCompatWeakHdl* GetHdl(); - virtual Window& GetWindow() const = 0; + Window& GetWindow() const; void CancelTransfers( sal_Bool bCancelLoadEnv = sal_True ); sal_Bool DoClose(); sal_uInt16 GetChildFrameCount() const; SfxFrame* GetChildFrame( sal_uInt16 nPos ) const; - void SetFrameName( const String& rName ); - const String& GetFrameName() const - { return aName; } SfxFrame* GetParentFrame() const { return pParentFrame; } - String GetContent() const; + + void SetPresentationMode( BOOL bSet ); + SystemWindow* GetSystemWindow() const; static SfxFrame* GetFirst(); static SfxFrame* GetNext( SfxFrame& ); - virtual sal_Bool InsertDocument( SfxObjectShell *pDoc ); - const SfxPoolItem* LoadDocumentSynchron( SfxItemSet& aSet ); - void DocumentInserted( SfxObjectShell* pDoc ); + static const SfxPoolItem* + OpenDocumentSynchron( SfxItemSet& aSet, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rTargetFrame ); SfxBroadcaster& GetBroadcaster() const; SfxObjectShell* GetCurrentDocument() const; SfxViewFrame* GetCurrentViewFrame() const; - SfxFrame* GetTopFrame() const; + SfxFrame& GetTopFrame() const; sal_Bool IsParent( SfxFrame* ) const; - SfxFrame* findFrame( const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags); - SfxFrame* SearchFrame( const String&, SfxMedium* pMedium = 0 ); sal_uInt32 GetFrameType() const; void GetTargetList( TargetList& ) const; - void ClearHistory(); SAL_DLLPRIVATE SfxFrame* GetContainingDocFrame_Impl( SfxFrame* pSelf ); sal_Bool IsTop() const; - sal_Bool CloseChildFrames(); - void UpdatePickEntries(); - void UpdatePickEntries( const ::com::sun::star::uno::Any& rValue ); - void UpdateHistory( const ::rtl::OUString& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs, const ::rtl::OUString& rTitle ); - void UpdateHistory(SfxObjectShell*, const String*pNew = 0 ); void UpdateDescriptor( SfxObjectShell *pDoc ); void Resize(); sal_Bool HasComponent() const; @@ -212,68 +181,30 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > GetController() const; - static sal_Bool LoadSfxComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > &, - const ::rtl::OUString&, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&, - const SfxObjectFactory* ); - sal_Bool IsInPlace() const; //#if 0 // _SOLAR__PRIVATE SAL_DLLPRIVATE sal_Bool DoClose_Impl(); - SAL_DLLPRIVATE void SetFrameInterface_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); + SAL_DLLPRIVATE void SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ); SAL_DLLPRIVATE void ReleasingComponent_Impl( sal_Bool bSet ); - SAL_DLLPRIVATE const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > - GetInterceptor_Impl(); - SAL_DLLPRIVATE void Clear_Impl(); - SAL_DLLPRIVATE sal_uInt16 LoadComponent_Impl( const ::rtl::OUString& rURL, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrameLoader > & rLoader, - SfxItemSet* pSet=0, sal_Bool bDontClose=sal_False ); - SAL_DLLPRIVATE void LoadFinished_Impl(); - DECL_DLLPRIVATE_STATIC_LINK( SfxFrame, BindingHasNewPart_Impl, void* ); - SAL_DLLPRIVATE SfxCancelManager* GetCancelManager() const; SAL_DLLPRIVATE void GetViewData_Impl(); - SAL_DLLPRIVATE sal_Bool CheckContentForLoad_Impl(); - SAL_DLLPRIVATE sal_Bool ExecuteHistoryMenu_Impl( sal_uInt16 nWnich, const Rectangle& rRect, sal_uInt16 nFlags=0 ); - SAL_DLLPRIVATE void ActivatePickEntry_Impl( SfxFramePickEntry_Impl*, sal_uInt16 nMode, SfxFrameDescriptor *pD = NULL ); - SAL_DLLPRIVATE void CopyHistory_Impl( SfxFrame *pFrame ) const; - SAL_DLLPRIVATE SfxFrame* SearchChildrenForName_Impl( const String&, sal_Bool bDeep = sal_True ) const; SAL_DLLPRIVATE void SetFrameType_Impl( sal_uInt32 ); - SAL_DLLPRIVATE void Activate_Impl( sal_Bool bBeamerOn ); - SAL_DLLPRIVATE void Deactivate_Impl(); SAL_DLLPRIVATE sal_uInt16 PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing=sal_False ); SAL_DLLPRIVATE sal_Bool DocIsModified_Impl(); SAL_DLLPRIVATE void SetCurrentViewFrame_Impl( SfxViewFrame* ); - SAL_DLLPRIVATE SfxFrame* SearchFrame_Impl( sal_uInt16, sal_Bool bDeep=sal_False ); - SAL_DLLPRIVATE SfxFrame* SearchFrame_Impl( const String&, sal_Bool bDeep=sal_False ); - SAL_DLLPRIVATE void SetFrameId_Impl( sal_uInt16 ); - SAL_DLLPRIVATE sal_uInt16 GetFrameId_Impl() const; - SAL_DLLPRIVATE void SetFrameIdName_Impl( const String& ); SAL_DLLPRIVATE sal_Bool IsClosing_Impl() const; SAL_DLLPRIVATE void SetIsClosing_Impl(); - SAL_DLLPRIVATE sal_Bool BrowseInFrame( int nDelta ); - SAL_DLLPRIVATE sal_Bool Browse( sal_Bool bForward, sal_uInt16 nDelta = 1, sal_Bool bNewFrame=sal_False ); - SAL_DLLPRIVATE sal_Bool CanBrowseForward() const; - SAL_DLLPRIVATE sal_Bool CanBrowseBackward() const; // Methoden f"ur den Zugriff auf das aktuelle Set SAL_DLLPRIVATE void SetDescriptor( SfxFrameDescriptor* ); SAL_DLLPRIVATE SfxFrameDescriptor* GetDescriptor() const; SAL_DLLPRIVATE void Lock_Impl( sal_Bool bLock ); - SAL_DLLPRIVATE sal_uInt16 GetLockCount_Impl() const; - //sal_Bool IsLocked_Impl() const - // { return GetLockCount_Impl() > 0; } - SAL_DLLPRIVATE void CloseOnUnlock_Impl(); - SAL_DLLPRIVATE SfxViewFrame* ActivateChildFrame_Impl(); SAL_DLLPRIVATE SfxDispatcher* GetDispatcher_Impl() const; SAL_DLLPRIVATE sal_Bool IsAutoLoadLocked_Impl() const; SAL_DLLPRIVATE static void InsertTopFrame_Impl( SfxFrame* pFrame ); SAL_DLLPRIVATE static void RemoveTopFrame_Impl( SfxFrame* pFrame ); - SAL_DLLPRIVATE void SetItemSet_Impl( const SfxItemSet* pSet ); - SAL_DLLPRIVATE const SfxItemSet* GetItemSet_Impl(); SAL_DLLPRIVATE void SetOwnsBindings_Impl( sal_Bool bSet ); SAL_DLLPRIVATE sal_Bool OwnsBindings_Impl() const; SAL_DLLPRIVATE void InvalidateUnoControllers_Impl(); @@ -284,15 +215,19 @@ public: SAL_DLLPRIVATE Rectangle GetTopOuterRectPixel_Impl() const; SAL_DLLPRIVATE void CreateWorkWindow_Impl(); SAL_DLLPRIVATE void SetWorkWindow_Impl( SfxWorkWindow* pWorkwin ); - SAL_DLLPRIVATE const SvBorder& GetBorder_Impl() const; SAL_DLLPRIVATE void GrabFocusOnComponent_Impl(); - SAL_DLLPRIVATE void ReFill_Impl( const SfxFrameSetDescriptor* pSet ); - SAL_DLLPRIVATE void LockFocus_Impl( sal_Bool bLock ); - SAL_DLLPRIVATE sal_Bool IsFocusLocked_Impl() const; - SAL_DLLPRIVATE void CloseDocument_Impl(); SAL_DLLPRIVATE void SetInPlace_Impl( sal_Bool ); -// sal_Bool IsPlugin_Impl() const; + + SAL_DLLPRIVATE void PrepareForDoc_Impl( SfxObjectShell& i_rDoc ); + SAL_DLLPRIVATE void LockResize_Impl( BOOL bLock ); + SAL_DLLPRIVATE void SetMenuBarOn_Impl( BOOL bOn ); + SAL_DLLPRIVATE BOOL IsMenuBarOn_Impl() const; + SAL_DLLPRIVATE SystemWindow* GetTopWindow_Impl() const; + SAL_DLLPRIVATE void PositionWindow_Impl( const Rectangle& rWinArea ) const; + SAL_DLLPRIVATE bool IsMarkedHidden_Impl() const; //#endif +private: + SAL_DLLPRIVATE void Construct_Impl(); }; SV_DECL_COMPAT_WEAK( SfxFrame ) @@ -350,7 +285,24 @@ public: ::com::sun::star::uno::Any GetValue() const { return aValue; } virtual int operator==( const SfxPoolItem& ) const; - virtual String GetValueText() const; + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const; + virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ); +}; + +class SFX2_DLLPUBLIC SfxUnoFrameItem : public SfxPoolItem +{ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > + m_xFrame; + +public: + TYPEINFO(); + SfxUnoFrameItem(); + SfxUnoFrameItem( sal_uInt16 nWhich, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame ); + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& + GetFrame() const + { return m_xFrame; } + virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const; virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ); diff --git a/sfx2/inc/sfx2/linkmgr.hxx b/sfx2/inc/sfx2/linkmgr.hxx index ee734dd69773..7dc779e2ba6e 100644 --- a/sfx2/inc/sfx2/linkmgr.hxx +++ b/sfx2/inc/sfx2/linkmgr.hxx @@ -131,8 +131,6 @@ public: // (ist zur Zeit nur fuer die FileLinks interressant!) void CancelTransfers(); - static void SetTransferPriority( sfx2::SvBaseLink& rLink, USHORT nPrio ); - // um Status Informationen aus dem FileObject an den BaseLink zu // senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat // dann die entsprechenden Informationen als String. diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index e0142e9ba140..5fc5a641fd44 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -92,7 +92,6 @@ class GDIMetaFile; class Bitmap; class INetURLObject; class IndexBitSet; -class SfxTopFrame; class JobSetup; class Size; class Point; @@ -217,17 +216,13 @@ private: SfxMedium * pMedium; // Beschreibung der Datei bzw. des Storage, in dem sich das Objekt befindet SfxStyleSheetBasePool* pStyleSheetPool; // StyleSheets SfxObjectCreateMode eCreateMode; // Zweck des Objekts - sal_uInt16 nViewNo; // Numerierung der MDIWins sal_Bool bHasName :1, // sal_True := bestehendes Objekt, sal_False := es ist ein neues Objekt bIsTmp :1; // temp. Storage private: //#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void Construct_Impl(); SAL_DLLPRIVATE void UpdateTime_Impl(const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties> & i_xDocProps); - SAL_DLLPRIVATE sal_Bool MakeBackup_Impl(const String &rName, - sal_Bool bCopyAllways = sal_False); SAL_DLLPRIVATE sal_Bool SaveTo_Impl(SfxMedium &rMedium, const SfxItemSet* pSet ); @@ -237,6 +232,7 @@ private: protected: SfxObjectShell(SfxObjectCreateMode); + SfxObjectShell( const sal_uInt64 i_nCreationFlags ); // see sfxmodelfactory.hxx virtual ~SfxObjectShell(); virtual void ModifyChanged(); @@ -246,10 +242,6 @@ protected: */ void SetHasNoBasic(); -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void StartLoading_Impl(); -//#endif - /// template method, called by FlushDocInfo; this implementation is empty virtual void DoFlushDocInfo(); @@ -501,11 +493,6 @@ public: void SetTitle( const String& rTitle ); String GetTitle( sal_uInt16 nMaxLen = 0 ) const; void InvalidateName(); // Zuruecksetzen auf unbenannt -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void SetLastMark_Impl( const String & ); - SAL_DLLPRIVATE const String& GetLastMark_Impl() const; - SAL_DLLPRIVATE sal_Bool DoInitNew_Impl( const ::rtl::OUString& rName ); -//#endif // DDE-Interface virtual long DdeExecute( const String& rCmd ); @@ -609,19 +596,15 @@ public: virtual SfxFrame* GetSmartSelf( SfxFrame* pSelf, SfxMedium& rMedium ); - void SetModel( SfxBaseModel* pModel ); - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetModel() const; // Nur uebergangsweise fuer die Applikationen !!! void SetBaseModel( SfxBaseModel* pModel ); - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetBaseModel(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > GetBaseModel() const; // Nur uebergangsweise fuer die Applikationen !!! virtual SEQUENCE< OUSTRING > GetEventNames(); -//REMOVE SotStorageStreamRef GetConfigurationStream( const String& rName, BOOL bCreate=FALSE ); -//REMOVE SvStorageRef GetConfigurationStorage( SotStorage* pStor=NULL ); - Window* GetDialogParent( SfxMedium* pMedium=0 ); String UpdateTitle( SfxMedium* pMed=NULL, USHORT nDocViewNo=0 ); static SfxObjectShell* CreateObject( const String& rServiceName, SfxObjectCreateMode = SFX_CREATE_MODE_STANDARD ); @@ -674,12 +657,10 @@ public: virtual Printer * GetDocumentPrinter(); virtual OutputDevice* GetDocumentRefDev(); virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ); - //virtual UINT32 GetViewAspect() const; virtual Rectangle GetVisArea( USHORT nAspect ) const; virtual void SetVisArea( const Rectangle & rVisArea ); const Rectangle & GetVisArea() const; void SetVisAreaSize( const Size & rVisSize ); -//REMOVE virtual ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > CreateTransferableSnapshot(); virtual ULONG GetMiscStatus() const; MapUnit GetMapUnit() const; @@ -723,9 +704,6 @@ public: SAL_DLLPRIVATE ::rtl::OUString CreateTempCopyOfStorage_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); - SAL_DLLPRIVATE static sal_Bool NoDependencyFromManifest_Impl( - const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); - SAL_DLLPRIVATE void InitOwnModel_Impl(); SAL_DLLPRIVATE void BreakMacroSign_Impl( sal_Bool bBreakMacroSing ); SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl(); @@ -734,7 +712,6 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation >& aInfos ); SAL_DLLPRIVATE void CheckEncryption_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler ); - SAL_DLLPRIVATE SEQUENCE< OUSTRING > GetEventNames_Impl(); SAL_DLLPRIVATE void InitBasicManager_Impl(); SAL_DLLPRIVATE SfxObjectShell_Impl* Get_Impl() { return pImp; } @@ -768,12 +745,10 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aMediaDescr ); SAL_DLLPRIVATE void PositionView_Impl(); SAL_DLLPRIVATE void UpdateFromTemplate_Impl(); - SAL_DLLPRIVATE void Reload_Impl(); SAL_DLLPRIVATE sal_Bool CanReload_Impl(); SAL_DLLPRIVATE void SetNamedVisibility_Impl(); SAL_DLLPRIVATE sal_Bool DoSave_Impl( const SfxItemSet* pSet=0 ); SAL_DLLPRIVATE sal_Bool Save_Impl( const SfxItemSet* pSet=0 ); - SAL_DLLPRIVATE void UpdatePickList_Impl(); SAL_DLLPRIVATE sal_Bool PreDoSaveAs_Impl(const String &rFileName, const String &rFiltName, SfxItemSet *); SAL_DLLPRIVATE sal_Bool APISaveAs_Impl ( const String& aFileName, SfxItemSet* aParams ); SAL_DLLPRIVATE sal_Bool CommonSaveAs_Impl ( const INetURLObject& aURL, const String& aFilterName, SfxItemSet* aParams ); @@ -781,15 +756,13 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, sal_Bool bTypeMustBeSetAlready ); SAL_DLLPRIVATE void PrepareSecondTryLoad_Impl(); + SAL_DLLPRIVATE void SetInitialized_Impl( const bool i_fromInitNew ); // public-internals SAL_DLLPRIVATE IndexBitSet& GetNoSet_Impl(); SAL_DLLPRIVATE void SetProgress_Impl( SfxProgress *pProgress ); - SAL_DLLPRIVATE sal_uInt16& GetAktViewNo() { return nViewNo; } SAL_DLLPRIVATE void PostActivateEvent_Impl( SfxViewFrame* ); SAL_DLLPRIVATE void SetActivateEvent_Impl(sal_uInt16 ); -//REMOVE FASTBOOL SaveWindows_Impl( SvStorage &rStor ) const; - SAL_DLLPRIVATE SfxViewFrame* LoadWindows_Impl( SfxTopFrame *pPrefered = 0 ); SAL_DLLPRIVATE SfxObjectShell* GetParentShellByModel_Impl(); // configuration items diff --git a/sfx2/inc/sfx2/sfxbasecontroller.hxx b/sfx2/inc/sfx2/sfxbasecontroller.hxx index 7a077f1dd56f..ca30d243bbac 100644 --- a/sfx2/inc/sfx2/sfxbasecontroller.hxx +++ b/sfx2/inc/sfx2/sfxbasecontroller.hxx @@ -35,7 +35,7 @@ #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/DispatchDescriptor.hpp> #include <com/sun/star/frame/XDispatchInformationProvider.hpp> -#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XController2.hpp> #include <com/sun/star/frame/XControllerBorder.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -43,7 +43,8 @@ #include <com/sun/star/frame/XTitleChangeBroadcaster.hpp> #include <com/sun/star/util/URL.hpp> #include <com/sun/star/lang/XTypeProvider.hpp> -#include <cppuhelper/weak.hxx> +#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/basemutex.hxx> #include <osl/mutex.hxx> #include <com/sun/star/task/XStatusIndicatorSupplier.hpp> #include <com/sun/star/ui/XContextMenuInterception.hpp> @@ -67,27 +68,16 @@ #define ANY ::com::sun::star::uno::Any #define SEQUENCE ::com::sun::star::uno::Sequence #define XDISPATCH ::com::sun::star::frame::XDispatch -#define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider #define DISPATCHDESCRIPTOR ::com::sun::star::frame::DispatchDescriptor #define XMODEL ::com::sun::star::frame::XModel #define XFRAME ::com::sun::star::frame::XFrame -#define XCONTROLLER ::com::sun::star::frame::XController -#define XCONTROLLERBORDER ::com::sun::star::frame::XControllerBorder #define XEVENTLISTENER ::com::sun::star::lang::XEventListener #define MUTEX ::osl::Mutex #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException #define UNOTYPE ::com::sun::star::uno::Type -#define OWEAKOBJECT ::cppu::OWeakObject -#define XTYPEPROVIDER ::com::sun::star::lang::XTypeProvider #define UNOURL ::com::sun::star::util::URL #define OUSTRING ::rtl::OUString -#define XSTATUSINDICATORSUPPLIER ::com::sun::star::task::XStatusIndicatorSupplier -#define XCONTEXTMENUINTERCEPTION ::com::sun::star::ui::XContextMenuInterception #define XCONTEXTMENUINTERCEPTOR ::com::sun::star::ui::XContextMenuInterceptor -#define XUSERINPUTINTERCEPTION ::com::sun::star::awt::XUserInputInterception -#define XDISPATCHINFORMATIONPROVIDER ::com::sun::star::frame::XDispatchInformationProvider -#define XTITLE ::com::sun::star::frame::XTitle -#define XTITLECHANGEBROADCASTER ::com::sun::star::frame::XTitleChangeBroadcaster //________________________________________________________________________________________________________ // forwards @@ -95,6 +85,8 @@ struct IMPL_SfxBaseController_DataContainer ; // impl. struct to hold member of class SfxBaseController +class SfxViewFrame; + sal_Int16 MapGroupIDToCommandGroup( sal_Int16 nGroupID ); sal_Bool SupportsCommandGroup( sal_Int16 nCommandGroup ); sal_Int16 MapCommandGroupToGroupID( sal_Int16 nCommandGroup ); @@ -103,36 +95,19 @@ sal_Int16 MapCommandGroupToGroupID( sal_Int16 nCommandGroup ); // class declarations //________________________________________________________________________________________________________ -struct IMPL_SfxBaseController_MutexContainer -{ - MUTEX m_aMutex ; -} ; - -/**_______________________________________________________________________________________________________ - @short - - - @descr - - - @implements - - - @base - -*/ - -// Forward to impl-baseclass! -//class IMPL_SfxBaseController ; - -class SFX2_DLLPUBLIC SfxBaseController : public XTYPEPROVIDER - , public XCONTROLLER - , public XCONTROLLERBORDER - , public XDISPATCHPROVIDER - , public XSTATUSINDICATORSUPPLIER - , public XCONTEXTMENUINTERCEPTION - , public XUSERINPUTINTERCEPTION - , public XDISPATCHINFORMATIONPROVIDER - , public XTITLE - , public XTITLECHANGEBROADCASTER - , public IMPL_SfxBaseController_MutexContainer - , public OWEAKOBJECT +typedef ::cppu::WeakImplHelper9 < ::com::sun::star::frame::XController2 + , ::com::sun::star::frame::XControllerBorder + , ::com::sun::star::frame::XDispatchProvider + , ::com::sun::star::task::XStatusIndicatorSupplier + , ::com::sun::star::ui::XContextMenuInterception + , ::com::sun::star::awt::XUserInputInterception + , ::com::sun::star::frame::XDispatchInformationProvider + , ::com::sun::star::frame::XTitle + , ::com::sun::star::frame::XTitleChangeBroadcaster + > SfxBaseController_Base; + +class SFX2_DLLPUBLIC SfxBaseController :public SfxBaseController_Base + ,public ::cppu::BaseMutex { //________________________________________________________________________________________________________ // public methods @@ -177,93 +152,14 @@ public: SAL_DLLPRIVATE void ReleaseShell_Impl(); SAL_DLLPRIVATE void BorderWidthsChanged_Impl(); - //____________________________________________________________________________________________________ - // XInterface - //____________________________________________________________________________________________________ - - /**___________________________________________________________________________________________________ - @short give answer, if interface is supported - @descr The interfaces are searched by type. - - @seealso XInterface - - @param "rType" is the type of searched interface. - - @return Any information about found interface - - @onerror A RuntimeException is thrown. - */ - - virtual ANY SAL_CALL queryInterface( const UNOTYPE& rType ) throw( RUNTIMEEXCEPTION ) ; - - /**___________________________________________________________________________________________________ - @short increment refcount - @descr - - - @seealso XInterface - @seealso release() - - @param - - - @return - - - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL acquire() throw() ; - - /**___________________________________________________________________________________________________ - @short decrement refcount - @descr - - - @seealso XInterface - @seealso acquire() - - @param - - - @return - - - @onerror A RuntimeException is thrown. - */ - - virtual void SAL_CALL release() throw() ; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > SAL_CALL getStatusIndicator( ) throw (::com::sun::star::uno::RuntimeException); //____________________________________________________________________________________________________ - // XTypeProvider + // XController2 //____________________________________________________________________________________________________ - - /**___________________________________________________________________________________________________ - @short get information about supported interfaces - @descr - - - @seealso XTypeProvider - - @param - - - @return Sequence of types of all supported interfaces - - @onerror A RuntimeException is thrown. - */ - - virtual SEQUENCE< UNOTYPE > SAL_CALL getTypes() throw( RUNTIMEEXCEPTION ) ; - - /**___________________________________________________________________________________________________ - @short get implementation id - @descr This ID is neccessary for UNO-caching. If there no ID, cache is disabled. - Another way, cache is enabled. - - @seealso XTypeProvider - - @param - - - @return ID as Sequence of byte - - @onerror A RuntimeException is thrown. - */ - - virtual SEQUENCE< sal_Int8 > SAL_CALL getImplementationId() throw( RUNTIMEEXCEPTION ) ; - - ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > SAL_CALL getStatusIndicator( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getComponentWindow() throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getViewControllerName() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL getCreationArguments() throw (::com::sun::star::uno::RuntimeException); //____________________________________________________________________________________________________ // XController @@ -496,23 +392,23 @@ public: SAL_DLLPRIVATE BOOL HandleEvent_Impl( NotifyEvent& rEvent ); SAL_DLLPRIVATE BOOL HasKeyListeners_Impl(); SAL_DLLPRIVATE BOOL HasMouseClickListeners_Impl(); + SAL_DLLPRIVATE void SetCreationArguments_Impl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rCreationArgs ); SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitle > impl_getTitleHelper (); //#endif +private: + enum ConnectSfxFrame + { + E_CONNECT, + E_DISCONNECT, + E_RECONNECT + }; + SAL_DLLPRIVATE void ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ); + SAL_DLLPRIVATE SfxViewFrame& GetViewFrame_Impl() const; //________________________________________________________________________________________________________ // private variables //________________________________________________________________________________________________________ - /** With this method you can set the flag that controlls whether the - frame is released together with a controller when the later one is - disposed. - @param bFlag - When passing <true/>, the default value of this flag, then - disposing the controller results in releasing the frame. - Passing <false/> leaves the frame unaffected. - */ - void FrameIsReleasedWithController (sal_Bool bFlag); - private: IMPL_SfxBaseController_DataContainer* m_pData ; diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 2bbf2caa9c22..578dd1fd33bb 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -43,6 +43,7 @@ #include <com/sun/star/document/XDocumentInfo.hpp> #include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XDocumentRecovery.hpp> #include <com/sun/star/rdf/XDocumentMetadataAccess.hpp> @@ -55,6 +56,8 @@ #include <com/sun/star/document/XStorageBasedDocument.hpp> #include <com/sun/star/document/XScriptInvocationContext.hpp> #include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/NotInitializedException.hpp> +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/frame/DoubleInitializationException.hpp> #include <com/sun/star/util/XModifiable2.hpp> @@ -82,6 +85,8 @@ #include <cppuhelper/typeprovider.hxx> #include <com/sun/star/script/XStarBasicAccess.hpp> #include <osl/mutex.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> #include <tools/link.hxx> @@ -91,9 +96,9 @@ #include <com/sun/star/task/XInteractionHandler.hpp> //________________________________________________________________________________________________________ -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_29) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_29 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 29 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_30) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_30 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 30 #include <comphelper/implbase_var.hxx> #endif @@ -196,8 +201,12 @@ class SfxPrinter; class SfxViewShell; class SfxObjectShell ; class SfxEventHint; +class SfxViewFrame; struct IMPL_SfxBaseModel_DataContainer ; // impl. struct to hold member of class SfxBaseModel +namespace sfx { namespace intern { + class ViewCreationGuard; +} } //________________________________________________________________________________________________________ // class declarations //________________________________________________________________________________________________________ @@ -228,10 +237,11 @@ struct IMPL_SfxBaseModel_DataContainer ; // impl. struct to hold member o SfxListener */ -typedef ::comphelper::WeakImplHelper29 < XCHILD +typedef ::comphelper::WeakImplHelper30 < XCHILD , XDOCUMENTINFOSUPPLIER , ::com::sun::star::document::XDocumentPropertiesSupplier , ::com::sun::star::rdf::XDocumentMetadataAccess + , ::com::sun::star::document::XDocumentRecovery , XEVENTBROADCASTER , XEVENTLISTENER , XEVENTSSUPPLIER @@ -1284,6 +1294,18 @@ public: virtual ::rtl::OUString SAL_CALL getUntitledPrefix() throw (css::uno::RuntimeException); + // css.document.XDocumentRecovery + virtual ::sal_Bool SAL_CALL wasModifiedSinceLastSave() + throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) + throw ( ::com::sun::star::uno::RuntimeException, + ::com::sun::star::io::IOException, + ::com::sun::star::lang::WrappedTargetException ); + virtual void SAL_CALL recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_MediaDescriptor ) + throw ( ::com::sun::star::uno::RuntimeException, + ::com::sun::star::io::IOException, + ::com::sun::star::lang::WrappedTargetException ); + //____________________________________________________________________________________________________ // ::com::sun::star::rdf::XNode: @@ -1463,6 +1485,7 @@ public: SAL_DLLPRIVATE sal_Bool impl_isDisposed() const ; sal_Bool IsDisposed() const ; + sal_Bool IsInitialized() const; ::com::sun::star::uno::Reference < ::com::sun::star::container::XIndexAccess > SAL_CALL getViewData() throw (::com::sun::star::uno::RuntimeException); void SAL_CALL setViewData( const ::com::sun::star::uno::Reference < ::com::sun::star::container::XIndexAccess >& aData ) throw (::com::sun::star::uno::RuntimeException); @@ -1473,7 +1496,6 @@ public: /** returns true if someone added a XEventListener to this XEventBroadcaster */ sal_Bool hasEventListeners() const; - protected: /* returns a unique id for the model that is valid as long as the document @@ -1517,6 +1539,13 @@ private: SAL_DLLPRIVATE css::uno::Reference< css::frame::XTitle > impl_getTitleHelper (); SAL_DLLPRIVATE css::uno::Reference< css::frame::XUntitledNumbers > impl_getUntitledHelper (); + SAL_DLLPRIVATE SfxViewFrame* FindOrCreateViewFrame_Impl( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + ::sfx::intern::ViewCreationGuard& i_rGuard + ) const; + + SAL_DLLPRIVATE void NotifyModifyListeners_Impl() const; + //________________________________________________________________________________________________________ // private variables and methods //________________________________________________________________________________________________________ @@ -1526,9 +1555,42 @@ private: IMPL_SfxBaseModel_DataContainer* m_pData ; // cannot be held in m_pData, since it needs to be accessed in non-threadsafe context const bool m_bSupportEmbeddedScripts; + const bool m_bSupportDocRecovery; } ; // class SfxBaseModel +class SFX2_DLLPUBLIC SfxModelGuard +{ +public: + enum AllowedModelState + { + // not yet initialized + E_INITIALIZING, + // fully alive, i.e. initialized, and not yet disposed + E_FULLY_ALIVE + }; + + SfxModelGuard( SfxBaseModel& i_rModel, const AllowedModelState i_eState = E_FULLY_ALIVE ) + :m_aGuard( Application::GetSolarMutex() ) + { + if ( i_rModel.IsDisposed() ) + throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *&i_rModel ); + if ( ( i_eState != E_INITIALIZING ) && !i_rModel.IsInitialized() ) + throw ::com::sun::star::lang::NotInitializedException( ::rtl::OUString(), *&i_rModel ); + } + ~SfxModelGuard() + { + } + + void clear() + { + m_aGuard.clear(); + } + +private: + ::vos::OClearableGuard m_aGuard; +}; + #undef css #endif // _SFX_SFXBASEMODEL_HXX_ diff --git a/sfx2/inc/sfx2/sfxmodelfactory.hxx b/sfx2/inc/sfx2/sfxmodelfactory.hxx index 83e046cf8f7b..416358cb60e2 100644 --- a/sfx2/inc/sfx2/sfxmodelfactory.hxx +++ b/sfx2/inc/sfx2/sfxmodelfactory.hxx @@ -40,8 +40,10 @@ namespace sfx2 { //........................................................................ + #define SFXMODEL_STANDARD (sal_uInt64)(0x0000) #define SFXMODEL_EMBEDDED_OBJECT (sal_uInt64)(0x0001) #define SFXMODEL_DISABLE_EMBEDDED_SCRIPTS (sal_uInt64)(0x0002) + #define SFXMODEL_DISABLE_DOCUMENT_RECOVERY (sal_uInt64)(0x0004) typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ( SAL_CALL * SfxModelFactoryFunc ) ( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 27e8b7b3fe65..bc4c11b53184 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -53,7 +53,6 @@ #define SID_NONE 0 #define SID_UNKNOWN SID_SFX_START -#define SID_SUBREQUEST (SID_SFX_START+90) //------------------------------------------------------------------------- @@ -83,79 +82,28 @@ #define SID_PRINTER_CHANGESTODOC (SID_SFX_START + 324) #define SID_PRINTPREVIEW (SID_SFX_START + 325) -#define SID_MAIL_DATE (SID_SFX_START + 326) -#define SID_MAIL_FROM (SID_SFX_START + 327) #define SID_MAIL_SUBJECT (SID_SFX_START + 328) -#define SID_MAIL_OPEN (SID_SFX_START + 329) #define SID_MAIL_NOTIFY (SID_SFX_START + 330) #define SID_MAIL_SENDDOC (SID_SFX_START + 331) #define SID_MAIL_SENDDOCASPDF (SID_SFX_START + 1672) - #define SID_MAIL_RECIPIENT (SID_SFX_START + 334) #define SID_MAIL_TEXT (SID_SFX_START + 335) #define SID_MAIL_ATTACH (SID_SFX_START + 336) #define SID_MAIL_PRIORITY (SID_SFX_START + 337) -#define SID_MAIL_DELETE (SID_SFX_START + 338) -#define SID_MAIL_NEW (SID_SFX_START + 339) - -#define SID_MAIL_NEWWITHSERVER (SID_SFX_START + 360) -#define SID_MAIL_REPLY (SID_SFX_START + 361) -#define SID_MAIL_FOLLOWUP (SID_SFX_START + 362) -#define SID_MAIL_FORWARD (SID_SFX_START + 363) -#define SID_MAIL_SEND (SID_SFX_START + 364) -#define SID_MAIL_FILE (SID_SFX_START + 365) -#define SID_MAIL_MARKASREAD (SID_SFX_START + 366) -#define SID_MAIL_MARKASUNREAD (SID_SFX_START + 367) -#define SID_MAIL_NEXT (SID_SFX_START + 368) -#define SID_MAIL_PREV (SID_SFX_START + 369) -#define SID_MAIL_NEXTDELETE (SID_SFX_START + 370) -#define SID_MAIL_PREVDELETE (SID_SFX_START + 371) -#define SID_MAIL_OPEN_NEWS (SID_SFX_START + 372) -#define SID_MAIL_THREAD_MARKASREAD (SID_SFX_START + 373) -#define SID_MAIL_THREAD_MARKASUNREAD (SID_SFX_START + 374) + #define SID_MAIL_ATTACH_FILE (SID_SFX_START + 375) -#define SID_MAIL_DETACH_FILE (SID_SFX_START + 376) -#define SID_MAIL_MARK (SID_SFX_START + 377) -#define SID_MAIL_TXTFORMAT (SID_SFX_START + 378) -#define SID_MAIL_UPDATETOOLBOX (SID_SFX_START + 379) - -#define SID_OPEN_ANCHOR (SID_SFX_START + 380) -#define SID_MAIL_ADDRESSBOOK (SID_SFX_START + 1644) -#define SID_MAIL_ALLNEWSGROUPS (SID_SFX_START + 382) -#define SID_MAIL_GROUPREPLY (SID_SFX_START + 383) -#define SID_MAIL_SIGNATURE (SID_SFX_START + 384) -#define SID_MAIL_PREPAREEXPORT (SID_SFX_START + 385) -#define SID_MAIL_NEXTUNREAD (SID_SFX_START + 386) -#define SID_MAIL_PREVUNREAD (SID_SFX_START + 387) + #define SID_MAIL_EXPORT_FINISHED (SID_SFX_START + 388) -#define SID_NEWSSERVER_NAME (SID_SFX_START + 389) -#define SID_NEWS_GROUP_CHANGED (SID_SFX_START + 390) -#define SID_MAILBROWSER_CTRL (SID_SFX_START + 391) -#define SID_NEWSGROUP_NAME (SID_SFX_START + 392) #define SID_WEBHTML (SID_SFX_START + 393) #define SID_MAIL_SCROLLBODY_PAGEDOWN (SID_SFX_START + 1588) -#define SID_MAIL_REPLY_FOLLOWUP (SID_SFX_START + 1635) -#define SID_PHONE_STATUSBAR_CONTROL (SID_SFX_START + 398) -#define SID_RECOGNIZER_STATUSBAR_CONTROL (SID_SFX_START + 399) #define SID_PROGRESS_STATUSBAR_CONTROL (SID_SFX_START + 1597) -#define SID_RESOURCE_WARNING (SID_SFX_START + 333) - #define SID_APPLICATION (SID_SFX_START + 340) #define SID_PROGNAME (SID_SFX_START + 341) #define SID_PROGFILENAME (SID_SFX_START + 342) -#define SID_PROGPATH (SID_SFX_START + 343) -#define SID_INTERACTIVEMODE (SID_SFX_START + 344) -#define SID_PARENTOBJECT (SID_SFX_START + 345) #define SID_SELECTION (SID_SFX_START + 346) -#define SID_CREATOR (SID_SFX_START + 347) - -#define SID_COLL_COUNT (SID_SFX_START + 350) -#define SID_COLL_ITEM (SID_SFX_START + 351) -#define SID_COLL_REMOVE (SID_SFX_START + 352) -#define SID_COLL_ADD (SID_SFX_START + 353) // 360-400 siehe SID_MAIL_... @@ -207,26 +155,14 @@ #define SID_RELOAD (SID_SFX_START + 508) #define SID_PRINTDOCDIRECT (SID_SFX_START + 509) #define SID_PICKLIST (SID_SFX_START + 510) -#define SID_EDIT_FRAMESET (SID_SFX_START + 646) -#define SID_SPLIT_HORIZONTAL (SID_SFX_START + 647) -#define SID_SPLIT_VERTICAL (SID_SFX_START + 648) -#define SID_SPLIT_PARENT_HORIZONTAL (SID_SFX_START + 649) -#define SID_SPLIT_PARENT_VERTICAL (SID_SFX_START + 650) -#define SID_MODIFY_FRAME (SID_SFX_START + 651) -#define SID_DELETE_FRAME (SID_SFX_START + 652) -#define SID_FRAME_NAME (SID_SFX_START + 825) -#define SID_FRAME_CONTENT (SID_SFX_START + 826) #define SID_PLUGIN_MODE (SID_SFX_START + 827) -#define SID_LOCKBYTES_FACTORY (SID_SFX_START + 828) #define SID_EXPORTDOC (SID_SFX_START + 829) #define SID_EXPORTDOCASPDF (SID_SFX_START + 1673) #define SID_DIRECTEXPORTDOCASPDF (SID_SFX_START + 1674) #define SID_UPDATEDOCMODE (SID_SFX_START + 1668) -#define SID_NOCACHE (SID_SFX_START + 653) #define SID_FORCERELOAD (SID_SFX_START + 1502) #define SID_FILE_DIALOG (SID_SFX_START + 304) -#define SID_GRAFIC_DIALOG (SID_SFX_START + 305) #define SID_PATH (SID_SFX_START + 308) #define SID_SAVEDOCS (SID_SFX_START + 309) #define SID_STANDARD_DIR (SID_SFX_START + 450) @@ -235,88 +171,20 @@ // browse-ids #define SID_BROWSE_FORWARD (SID_SFX_START + 1300) #define SID_BROWSE_BACKWARD (SID_SFX_START + 1301) -#define SID_BROWSE_STOP (SID_SFX_START + 1302) #define SID_BROWSE_HOME (SID_SFX_START + 1303) -#define SID_AUTOBROWSE (SID_SFX_START + 1304) -#define SID_AUTOMAIL (SID_SFX_START + 1305) -#define SID_BROWSING (SID_SFX_START + 1306) -#define SID_ADDR_BOOK (SID_SFX_START + 1307) -#define SID_EXPLORER (SID_SFX_START + 1308) #define SID_CREATELINK (SID_SFX_START + 1309) #define SID_BOOKMARK_TITLE (SID_SFX_START + 1310) #define SID_BOOKMARK_URL (SID_SFX_START + 1311) #define SID_EDITDOC (SID_SFX_START + 1312) #define SID_BROWSER_MODE (SID_SFX_START + 1313) #define SID_PLUGINS_ACTIVE (SID_SFX_START + 1314) -#define SID_SAVEDOCTOBOOKMARK (SID_SFX_START + 1315) -#define SID_CLEARMEMCACHE (SID_SFX_START + 1316) #define SID_BROWSER (SID_SFX_START + 1318) #define SID_MACROEXECMODE (SID_SFX_START + 1319) -#define SID_EXPLORERCONTENT_OPEN (SID_SFX_START + 1322) -#define SID_EXPLORERCONTENT_OPEN_DOCUMENT (SID_SFX_START + 1321) -#define SID_EXPLORERCONTENT_OPEN_TEMPLATE (SID_SFX_START + 1362) -#define SID_EXPLORERCONTENT_OPEN_FOLDER (SID_SFX_START + 1542) -#define SID_EXPLORERCONTENT_OPEN_OBJECT (SID_SFX_START + 1543) -#define SID_EXPLORERCONTENT_NEW (SID_SFX_START + 1323) -#define SID_EXPLORERCONTENT_DESTROY (SID_SFX_START + 1324) -#define SID_EXPLORERCONTENT_MAKEROOT (SID_SFX_START + 1325) -#define SID_EXPLORERCONTENT_RENAME (SID_SFX_START + 1326) -#define SID_EXPLORERCONTENT_COPY (SID_SFX_START + 1327) -#define SID_EXPLORERCONTENT_PASTE (SID_SFX_START + 1328) -#define SID_EXPLORERCONTENT_CREATELINK (SID_SFX_START + 1329) -#define SID_EXPLORERCONTENT_DEFAULTTEMPLATE (SID_SFX_START + 1330) -#define SID_EXPLORER_CREATEFOLDER (SID_SFX_START + 1331) -#define SID_EXPLORER_CREATEBOOKMARK (SID_SFX_START + 1332) -#define SID_EXPLORER_CREATEWORKPLACE (SID_SFX_START + 1333) -#define SID_EXPLORER_CREATELINK (SID_SFX_START + 1334) -#define SID_EXPLORER_CREATEMAILINTRAY (SID_SFX_START + 1335) -#define SID_EXPLORER_CREATENEWSSERVER (SID_SFX_START + 1336) -#define SID_EXPLORER_CREATEFTPSERVER (SID_SFX_START + 1337) -#define SID_EXPLORER_CREATEDATABASE (SID_SFX_START + 1338) -#define SID_EXPLORER_CREATEGALLERY (SID_SFX_START + 1339) -#define SID_PROPERTIES (SID_SFX_START + 1350) -#define SID_EXPLORER_MAKEROOT (SID_SFX_START + 1351) -#define SID_EXPLORER_MAKEBMKDIR (SID_SFX_START + 1352) -#define SID_EXPLORER_PREVLEVEL (SID_SFX_START + 1353) -#define SID_EXPLORER_IMPORTBOOKMARKS (SID_SFX_START + 1354) -#define SID_EXPLORER_SEARCHORIGINAL (SID_SFX_START + 1355) -#define SID_EXPLORER_DETAILS (SID_SFX_START + 1356) -#define SID_EXPLORER_ICONS (SID_SFX_START + 1357) -#define SID_VIEWTYPE_DETAILS (SID_SFX_START + 1358) -#define SID_EXPLORER_MSGROUP_FSYS (SID_SFX_START + 1359) -#define SID_EXPLORER_MSGROUP_NEWSARTICLE (SID_SFX_START + 1360) -#define SID_EXPLORER_MSGROUP_NEWSGROUP (SID_SFX_START + 1361) -#define SID_EXPLORER_RESETURL (SID_SFX_START + 1520) - -#define SID_EXPLORER_DOCINFO (SID_SFX_START + 1363) -#define SID_EXPLORER_PREVIEW (SID_SFX_START + 1364) -#define SID_EXPLORER_MSGROUP_FTPFILE (SID_SFX_START + 1365) -#define SID_SEARCHORIGINAL (SID_SFX_START + 1366) -#define SID_EXPLORER_MSGROUP_MAILS (SID_SFX_START + 1367) -#define SID_EXPLORER_MSGROUP_CHAOS (SID_SFX_START + 1368) // die Id steht mit diesem Wert in chaos/cntids.hrc!! //#define SID_INTERNET_ONLINE (SID_SFX_START + 1370) -#define SID_INTERNET_UPDATE (SID_SFX_START + 1371) -#define SID_INTERNET_1 (SID_SFX_START + 1372) -#define SID_INTERNET_2 (SID_SFX_START + 1373) -#define SID_INTERNET_3 (SID_SFX_START + 1374) - #define SID_FILTER_DATA (SID_SFX_START + 1375) -#define SID_EXPLORER_SEARCH_DLG (SID_SFX_START + 1380) -#define SID_EXPLORER_MULTIQUICKSEARCH (SID_SFX_START + 1522) -#define SID_EXPLORER_SHOWEXTENSION (SID_SFX_START + 1594) -#define SID_EXPLORER_MAIL_HEADER (SID_SFX_START + 1595) -#define SID_EXPLORER_MAIL_BODY (SID_SFX_START + 1596) - -#define SID_TABPAGE (SID_SFX_START + 1383) -//#define SID_EXPLORER_CREATESEARCHFOLDER (SID_SFX_START + 1384) -#define SID_EMPTY_TRASH (SID_SFX_START + 1385) -#define SID_AFTEROPENEVENT (SID_SFX_START + 1386) -#define SID_QUERYICON (SID_SFX_START + 1387) -#define SID_SYNCEXPLORER (SID_SFX_START + 1388) -#define SID_EXPLORER_PASTE_ASLINK (SID_SFX_START + 1389) #define SID_EXPLORER_FILEPROPS_START (SID_SFX_START + 1390) #define SID_EXPLORER_FILEPROPS_END (SID_SFX_START + 1399) @@ -324,73 +192,22 @@ #define ID_FILETP_START SID_EXPLORER_FILEPROPS_START #define ID_FILETP_READONLY (ID_FILETP_START + 0) #define ID_FILETP_TITLE (ID_FILETP_START + 1) -#define ID_FILETP_SIZE (ID_FILETP_START + 2) -#define ID_FILETP_TYPE (ID_FILETP_START + 3) -#define ID_FILETP_PATH (ID_FILETP_START + 4) -#define ID_FILETP_CREATED (ID_FILETP_START + 5) -#define ID_FILETP_CHANGED (ID_FILETP_START + 6) -#define ID_FILETP_EDIT (ID_FILETP_START + 7) -#define ID_FILETP_IMAGE (ID_FILETP_START + 8) -#define ID_FILETP_LINK (ID_FILETP_START + 9) -#define ID_FILETP_END (ID_FILETP_START + 9) - -#define SID_NEWFRAMESET (SID_SFX_START + 1400) #define SID_EXPLORER_PROPS_START (SID_SFX_START + 1410) #define SID_EXPLORER_PROPS_END (SID_SFX_START + 1499) - - -#define SID_TRASH_RECOVER (SID_SFX_START + 1502) -#define SID_TRASH_AUTOEMPTY (SID_SFX_START + 1503) -#define SID_TRASH_EMPTY (SID_SFX_START + 1504) -#define SID_EXPLORER_BOOKMARKDIR (SID_SFX_START + 1505) -#define SID_EXPLORER_SEARCHORIG (SID_SFX_START + 1506) -#define SID_FRAMESPACING (SID_SFX_START + 1507) -#define SID_LATEINIT_DONE (SID_SFX_START + 1508) #define SID_AUTOLOAD (SID_SFX_START + 1509) -#define SID_FRAMECOUNT (SID_SFX_START + 1510) -#define SID_ISTOP (SID_SFX_START + 1511) -#define SID_VIEW (SID_SFX_START + 1512) -#define SID_ORIG_PROPERTIES (SID_SFX_START + 1513) -#define SID_MAIL_NOTIFY_RESET (SID_SFX_START + 1514) #define SID_FILLFRAME (SID_SFX_START + 1516) -#define SID_LOAD_LIBRARY (SID_SFX_START + 1517) #define SID_BASEURL (SID_SFX_START + 1518) #define SID_TEMPLATE (SID_SFX_START + 1519) -#define SID_UNLOAD_LIBRARY (SID_SFX_START + 1523) -#define SID_ADD_LIBRARY (SID_SFX_START + 1524) -#define SID_REMOVE_LIBRARY (SID_SFX_START + 1525) -#define SID_CLASSNAME (SID_SFX_START + 1526) -#define SID_INTERCEPTOR (SID_SFX_START + 1527) -#define SID_TARGETPATH (SID_SFX_START + 1528) - -#define SID_START (SID_SFX_START + 1529) -#define SID_STOP (SID_SFX_START + 1530) -#define SID_VALUE (SID_SFX_START + 1531) -#define SID_SUSPEND (SID_SFX_START + 1532) -#define SID_RESUME (SID_SFX_START + 1533) -#define SID_LOCKALL (SID_SFX_START + 1534) -#define SID_WAITPOINTER (SID_SFX_START + 1535) - #define SID_ONLINE_REGISTRATION (SID_SFX_START + 1537) #define SID_ONLINE_REGISTRATION_DLG (SID_SFX_START + 1540) #define SID_CONTENTTYPE (SID_SFX_START + 1541) -#define SID_DOC_IGNOREINFORMATIONLOST (SID_SFX_START + 1544) -#define SID_EXPLORER_SELECTIONSIZE (SID_SFX_START + 1545) #define SID_SAVETO (SID_SFX_START + 1546) -#define SID_ADJUSTICONS (SID_SFX_START + 1547) -#define SID_AUTO_ADJUSTICONS (SID_SFX_START + 1548) -#define SID_ICONGRID (SID_SFX_START + 1549) -#define SID_BINDING (SID_SFX_START + 1550) - -#define SID_ISCHILDFRAMELOAD (SID_SFX_START + 1552) -#define SID_PARENTFRAME (SID_SFX_START + 1554) - #define SID_CREATE_BASICOBJECT (SID_SFX_START + 1555) #define SID_DELETE_BASICOBJECT (SID_SFX_START + 1556) @@ -399,27 +216,11 @@ #define SID_UPDATE_VERSION (SID_SFX_START + 1568) #define SID_BUILD_VERSION (SID_SFX_START + 1569) -#define SID_INSERT_TASKFRAME (SID_SFX_START + 1572) -#define SID_TASK (SID_SFX_START + 1573) -#define SID_ACTIVETASK (SID_SFX_START + 1574) -#define SID_EXPLORER_ISDESKTOP (SID_SFX_START + 1576) - -#define SID_CHAOSDOC_LAYOUT1 (SID_SFX_START + 1578) -#define SID_CHAOSDOC_LAYOUT2 (SID_SFX_START + 1579) -#define SID_CHAOSDOC_LAYOUT3 (SID_SFX_START + 1580) -#define SID_CHAOSDOC_LAYOUT4 (SID_SFX_START + 1581) - #define SID_VERSION (SID_SFX_START + 1583) -#define SID_UNO (SID_SFX_START + 1584) #define SID_DOCUMENT_COMPARE (SID_SFX_START + 1586) #define SID_DOCUMENT_MERGE (SID_SFX_START + 1587) -#define SID_EXECUTE (SID_SFX_START + 1593) -#define SID_OWNS_FRAME (SID_SFX_START + 1598) - -#define SID_OFFICE_VERSION_ID (SID_SFX_START + 1599) -#define SID_USE_FILTEROPTIONS (SID_SFX_START + 1600) #define SID_OFFICE_PLK (SID_SFX_START + 1601) #define SID_OFFICE_PALK (SID_SFX_START + 1604) #define SID_CHECK_KEY (SID_SFX_START + 1605) @@ -452,7 +253,7 @@ #define SID_LOGOUT (SID_SFX_START + 1652) #define SID_JUMPMARK (SID_SFX_START + 1654) #define SID_BROWSE (SID_SFX_START + 1658) -#define SID_BACKTOWEBTOP (SID_SFX_START + 1657) + // FREE (was: SID_BACKTOWEBTOP) #define SID_SEGMENTSIZE (SID_SFX_START + 1659) #define SID_VIEW_DATA_SOURCE_BROWSER (SID_SFX_START + 1660) #define SID_TOGGLE_MENUBAR (SID_SFX_START + 1661) @@ -509,10 +310,10 @@ #define SID_SFX_free_END (SID_SFX_START + 3999) #define SID_OPEN_NEW_VIEW (SID_SFX_START + 520) -#define SID_VIEW_ZOOM_MODE (SID_SFX_START + 521) -#define SID_VIEW_POS_SIZE (SID_SFX_START + 522) + // FREE, was SID_VIEW_ZOOM_MODE + // FREE, was SID_VIEW_POS_SIZE #define SID_VIEW_ID (SID_SFX_START + 523) -#define SID_USER_DATA (SID_SFX_START + 524) + // FREE, was SID_USER_DATA #define SID_VIEW_DATA (SID_SFX_START + 1582) #define SID_SILENT (SID_SFX_START + 528) #define SID_HIDDEN (SID_SFX_START + 534) @@ -663,7 +464,7 @@ #define SID_WIN_MINIMIZED (SID_SFX_START + 625) #define SID_WIN_MAXIMIZED (SID_SFX_START + 626) #define SID_WIN_FULLSCREEN (SID_SFX_START + 627) -#define SID_WIN_POSSIZE (SID_SFX_START + 628) + // FREE, was SID_WIN_POSSIZE #define SID_WIN_VISIBLE (SID_SFX_START + 629) #define SID_VIEWSHELL0 (SID_SFX_START + 630) @@ -932,7 +733,7 @@ #define SID_ATTR_AUTOSAVEMINUTE (SID_OPTIONS_START + 5) #define SID_ATTR_WORKINGSET (SID_OPTIONS_START + 13) #define SID_ATTR_UNDO_COUNT (SID_OPTIONS_START + 16) -#define SID_ATTR_SAVEDOCWINS (SID_OPTIONS_START + 17) + // unused #define SID_ATTR_SAVEDOCVIEW (SID_OPTIONS_START + 18) // GeneralTabPage diff --git a/sfx2/inc/sfx2/shell.hxx b/sfx2/inc/sfx2/shell.hxx index 766f192c071c..314c16fdbf1f 100644 --- a/sfx2/inc/sfx2/shell.hxx +++ b/sfx2/inc/sfx2/shell.hxx @@ -86,7 +86,6 @@ enum SfxInterfaceId SFX_INTERFACE_NONE, SFX_INTERFACE_SFXAPP, SFX_INTERFACE_SFXDOCSH, - SFX_INTERFACE_SFXTOPFRM, SFX_INTERFACE_SFXIPFRM, SFX_INTERFACE_SFXVIEWSH, SFX_INTERFACE_SFXVIEWFRM, diff --git a/sfx2/inc/sfx2/topfrm.hxx b/sfx2/inc/sfx2/topfrm.hxx deleted file mode 100644 index a84f90481cab..000000000000 --- a/sfx2/inc/sfx2/topfrm.hxx +++ /dev/null @@ -1,122 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SFX_TOPFRM_HXX -#define _SFX_TOPFRM_HXX - -#include "sal/config.h" -#include "sfx2/dllapi.h" -#include "sal/types.h" -#include <com/sun/star/uno/Reference.h> -#include <vcl/dockwin.hxx> -#include <vcl/wrkwin.hxx> - -#include <sfx2/frame.hxx> -#include <sfx2/viewfrm.hxx> - -class SfxViewShell; -class SfxTopFrame; -class SfxTopFrame_Impl; -namespace svtools { class AsynchronLink; } - -// class SfxTopFrame ----------------------------------------------------- - -class SFX2_DLLPUBLIC SfxTopFrame : public SfxFrame -{ -friend class SfxTopWindow_Impl; -friend class SfxTopFrameWindow_Impl; -friend class SfxTopFrame_Impl; - - SfxTopFrame_Impl* pImp; - Window* pWindow; - SAL_DLLPRIVATE SfxTopFrame( Window* pWindow=NULL, sal_Bool bHidden = sal_False ); - SAL_DLLPRIVATE virtual ~SfxTopFrame(); -public: - TYPEINFO(); - - static SfxTopFrame* Create( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame ); - static SfxTopFrame* Create( SfxObjectShell* pDoc=0, USHORT nViewId=0, BOOL bHidden=sal_False, const SfxItemSet* pSet=NULL ); - static SfxTopFrame* Create( SfxObjectShell* pDoc, Window* pWindow, USHORT nViewId=0, BOOL bHidden=sal_False, const SfxItemSet* pSet=NULL ); - - virtual Window& GetWindow() const; - virtual BOOL Close(); - virtual BOOL InsertDocument( SfxObjectShell *pDoc ); - String GetWindowData(); - - void SetPresentationMode( BOOL bSet ); - SystemWindow* GetSystemWindow() const; - -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void LockResize_Impl( BOOL bLock ); - SAL_DLLPRIVATE void SetMenuBarOn_Impl( BOOL bOn ); - SAL_DLLPRIVATE BOOL IsMenuBarOn_Impl() const; - SAL_DLLPRIVATE BOOL InsertDocument_Impl( SfxObjectShell *pDoc, USHORT nViewId=0 ); - SAL_DLLPRIVATE SystemWindow* GetTopWindow_Impl() const; - SAL_DLLPRIVATE void CheckMenuCloser_Impl( MenuBar* pMenubar ); -//#endif -}; - -// class SfxTopViewFrame ------------------------------------------------- - -class SfxTopViewFrame_Impl; -class SFX2_DLLPUBLIC SfxTopViewFrame : public SfxViewFrame -{ -friend class SfxTopWindow_Impl; -friend class SfxTopViewFrame_Impl; - - SfxTopViewFrame_Impl* pImp; - svtools::AsynchronLink* pCloser; - -protected: - - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - virtual void Activate( BOOL bUI ); - virtual void Deactivate( BOOL bUI ); - virtual BOOL Close(); - virtual ~SfxTopViewFrame(); - -public: - TYPEINFO(); - SFX_DECL_INTERFACE(SFX_INTERFACE_SFXTOPFRM) - - SfxTopViewFrame( SfxFrame* pFrame, SfxObjectShell *pDoc=NULL, USHORT nViewId=0 ); - - virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ); - SAL_DLLPRIVATE virtual BOOL SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder ); - virtual String UpdateTitle(); - -//#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE void Exec_Impl(SfxRequest &); - SAL_DLLPRIVATE void GetState_Impl(SfxItemSet &); - SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); - SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); - SAL_DLLPRIVATE SfxTopFrame* GetTopFrame_Impl() - { return (SfxTopFrame*) GetFrame(); } -//#endif -}; - -#endif // #ifndef _SFX_TOPFRM_HXX - diff --git a/sfx2/inc/sfx2/viewfrm.hxx b/sfx2/inc/sfx2/viewfrm.hxx index 4fb7a8e94abc..8350bc5f0f9d 100644 --- a/sfx2/inc/sfx2/viewfrm.hxx +++ b/sfx2/inc/sfx2/viewfrm.hxx @@ -38,6 +38,7 @@ #include <svl/poolitem.hxx> #include <com/sun/star/frame/status/Verb.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XController2.hpp> class SfxMacro; class SvBorder; @@ -48,7 +49,6 @@ class SfxProgress; class SvData; class SfxViewShell; class SvPseudoObject; -class SfxCancelManager; class SystemWindow; class Fraction; class Point; @@ -59,6 +59,10 @@ namespace sfx2 { class SvLinkSource; } +namespace svtools +{ + class AsynchronLink; +} #ifndef SFX_DECL_OBJECTSHELL_DEFINED #define SFX_DECL_OBJECTSHELL_DEFINED @@ -127,6 +131,7 @@ 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 { struct SfxViewFrame_Impl* pImp; @@ -144,39 +149,32 @@ private: protected: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - SAL_DLLPRIVATE void SetWindow_Impl( Window *pWin ); - #ifndef _SFX_HXX - SAL_DLLPRIVATE BOOL SwitchToViewShell_Impl( USHORT nNo, BOOL bIsIndex = FALSE ); SAL_DLLPRIVATE void KillDispatcher_Impl(); #endif virtual ~SfxViewFrame(); public: + SfxViewFrame( SfxFrame& rFrame, SfxObjectShell *pDoc = NULL ); + TYPEINFO(); SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWFRM) - SfxViewFrame( SfxBindings&, SfxFrame*, SfxObjectShell *pDoc=0, sal_uInt32 nType = 0 ); - SfxViewFrame(SfxObjectShell&, SfxBindings&, SfxFrame*p=0, sal_uInt32 nType = 0); - SfxViewFrame( - const SfxViewFrame &, SfxBindings &, SfxFrame *pFrame); - - static SfxViewFrame* SearchViewFrame( SfxViewFrame*, const String& ); static void SetViewFrame( SfxViewFrame* ); - static SfxViewFrame* CreateViewFrame( SfxObjectShell& rDoc, - USHORT nViewId=0, - BOOL bHidden=FALSE ); + + static SfxViewFrame* LoadHiddenDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ); + static SfxViewFrame* LoadDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ); + static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const USHORT i_nViewId = 0 ); + static SfxViewFrame* LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrameItem, const USHORT i_nViewId = 0 ); + static SfxViewFrame* DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const USHORT i_nViewId = 0 ); static SfxViewFrame* Current(); - static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = 0, - TypeId aType = 0, - BOOL bOnlyVisible = TRUE ); - static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, - const SfxObjectShell* pDoc = 0, - TypeId aType = 0 , - BOOL bOnlyVisible = TRUE ); - static USHORT Count(TypeId = 0); + static SfxViewFrame* GetFirst( const SfxObjectShell* pDoc = 0, BOOL bOnlyVisible = TRUE ); + static SfxViewFrame* GetNext( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc = 0, BOOL bOnlyVisible = TRUE ); + static USHORT Count(); + + static SfxViewFrame* Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController, const SfxObjectShell* i_pDoc = NULL ); void DoActivate(BOOL bMDI, SfxViewFrame *pOld=NULL); void DoDeactivate(BOOL bMDI, SfxViewFrame *pOld=NULL); @@ -188,8 +186,7 @@ public: SfxBindings& GetBindings() { return *pBindings; } const SfxBindings& GetBindings() const { return *pBindings; } Window& GetWindow() const; - virtual void SetZoomFactor( const Fraction &rZoomX, - const Fraction &rZoomY ) = 0; + virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ); SfxProgress* GetProgress() const; #ifdef ENABLE_INIMANAGER//MUSTINI @@ -213,6 +210,8 @@ public: void ToTop(); void Enable( BOOL bEnable ); virtual BOOL Close(); + virtual void Activate( BOOL bUI ); + virtual void Deactivate( BOOL bUI ); // DDE-Interface virtual long DdeExecute( const String& rCmd ); @@ -224,10 +223,10 @@ public: const ::com::sun::star::uno::Any & rValue ); virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem ); - virtual void ShowStatusText( const String& rText ); - virtual void HideStatusText(); + void ShowStatusText( const String& rText ); + void HideStatusText(); - virtual String UpdateTitle(); + String UpdateTitle(); // interne Handler SAL_DLLPRIVATE virtual BOOL SetBorderPixelImpl( const SfxViewShell *pSh, const SvBorder &rBorder ); @@ -236,21 +235,18 @@ public: virtual SfxObjectShell* GetObjectShell(); USHORT GetCurViewId() const; - SfxFrame* GetFrame() const; + SfxFrame& GetFrame() const; SfxViewFrame* GetTopViewFrame() const; BOOL DoClose(); ULONG GetFrameType() const - { return GetFrame()->GetFrameType(); } - SfxFrame* GetTopFrame() const - { return GetFrame()->GetTopFrame(); } - SfxFrame* SearchFrame( const String& rName, SfxMedium* pMedium = 0) - { return GetFrame()->SearchFrame( rName, pMedium ); } + { return GetFrame().GetFrameType(); } + SfxFrame& GetTopFrame() const + { return GetFrame().GetTopFrame(); } void GetTargetList( TargetList& rList ) const - { GetFrame()->GetTargetList( rList ); } + { GetFrame().GetTargetList( rList ); } void CancelTransfers() - { GetFrame()->CancelTransfers(); } - SfxCancelManager* GetCancelManager() const; + { GetFrame().CancelTransfers(); } void SetModalMode( BOOL ); BOOL IsInModalMode() const; @@ -267,19 +263,11 @@ public: void ChildWindowState(SfxItemSet&); //#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE SfxMacro* GetRecordingMacro_Impl(); - SAL_DLLPRIVATE void SetFrame_Impl( SfxFrame* ); SAL_DLLPRIVATE void SetDowning_Impl(); SAL_DLLPRIVATE void GetDocNumber_Impl(); SAL_DLLPRIVATE BOOL IsDowning_Impl() const; - SAL_DLLPRIVATE void SetSetViewFrameAllowed_Impl( BOOL bSet ); - SAL_DLLPRIVATE BOOL IsSetViewFrameAllowed_Impl() const; - SAL_DLLPRIVATE void SetImportingObjectShell_Impl( SfxObjectShell* pSH ); - SAL_DLLPRIVATE SfxObjectShell* GetImportingObjectShell_Impl( ) const; SAL_DLLPRIVATE void SetViewShell_Impl( SfxViewShell *pVSh ); - SAL_DLLPRIVATE void SetObjectShell_Impl( SfxObjectShell& rObjSh , - FASTBOOL bDefaultView = FALSE ); - SAL_DLLPRIVATE void ReleaseObjectShell_Impl( BOOL bStoreView = FALSE ); + SAL_DLLPRIVATE void ReleaseObjectShell_Impl(); SAL_DLLPRIVATE void GetState_Impl( SfxItemSet &rSet ); SAL_DLLPRIVATE void ExecReload_Impl( SfxRequest &rReq ); @@ -287,10 +275,8 @@ public: SAL_DLLPRIVATE void StateReload_Impl( SfxItemSet &rSet ); SAL_DLLPRIVATE void ExecView_Impl( SfxRequest &rReq ); SAL_DLLPRIVATE void StateView_Impl( SfxItemSet &rSet ); - SAL_DLLPRIVATE void PropState_Impl( SfxItemSet &rSet ); SAL_DLLPRIVATE void ExecHistory_Impl( SfxRequest &rReq ); SAL_DLLPRIVATE void StateHistory_Impl( SfxItemSet &rSet ); - SAL_DLLPRIVATE void SetParentViewFrame_Impl(SfxViewFrame *pParentFrame); SAL_DLLPRIVATE SfxViewFrame* GetParentViewFrame_Impl() const; SAL_DLLPRIVATE void ForceOuterResize_Impl(BOOL bOn=TRUE); SAL_DLLPRIVATE BOOL IsResizeInToOut_Impl() const; @@ -301,25 +287,75 @@ public: SAL_DLLPRIVATE void LockObjectShell_Impl(BOOL bLock=TRUE); - SAL_DLLPRIVATE SfxViewShell* CreateView_Impl( USHORT nViewId ); SAL_DLLPRIVATE void MakeActive_Impl( BOOL bActivate ); SAL_DLLPRIVATE void SetQuietMode_Impl( BOOL ); SAL_DLLPRIVATE const Size& GetMargin_Impl() const; - SAL_DLLPRIVATE void SetMargin_Impl( const Size& ); SAL_DLLPRIVATE void SetActiveChildFrame_Impl( SfxViewFrame* ); SAL_DLLPRIVATE SfxViewFrame* GetActiveChildFrame_Impl() const; - SAL_DLLPRIVATE BOOL IsRestoreView_Impl() const; - SAL_DLLPRIVATE void SetRestoreView_Impl( BOOL ); - SAL_DLLPRIVATE void SetViewData_Impl( USHORT, const String& ); - SAL_DLLPRIVATE String& GetViewData_Impl(); SAL_DLLPRIVATE String GetActualPresentationURL_Impl() const; SAL_DLLPRIVATE static void CloseHiddenFrames_Impl(); SAL_DLLPRIVATE void MiscExec_Impl(SfxRequest &); SAL_DLLPRIVATE void MiscState_Impl(SfxItemSet &); SAL_DLLPRIVATE SfxWorkWindow* GetWorkWindow_Impl( USHORT nId ); SAL_DLLPRIVATE void AddDispatchMacroToBasic_Impl(const ::rtl::OUString& sMacro); - SAL_DLLPRIVATE BOOL ClearEventFlag_Impl(); + + SAL_DLLPRIVATE void Exec_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetExecute_Impl(SfxRequest &); + SAL_DLLPRIVATE void INetState_Impl(SfxItemSet &); + + SAL_DLLPRIVATE void SetCurViewId_Impl( const USHORT i_nID ); + //#endif +private: + SAL_DLLPRIVATE BOOL SwitchToViewShell_Impl( USHORT nNo, BOOL bIsIndex = FALSE ); + SAL_DLLPRIVATE void PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into + @param i_rLoadArgs + the arguments to pass to the component loader. If this sequence is empty, then the current arguments of the + model will be obtained, and passed to the loader. This ensures that any arguments in the model will be preserved, + instead of being reset. + @param i_nViewId + the ID of the view to create + @throws Exception + if something goes wrong. The caller is responsible for handling this. + */ + SAL_DLLPRIVATE static SfxViewShell* LoadViewIntoFrame_Impl( + const SfxObjectShell& i_rDoc, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rLoadArgs, + const USHORT i_nViewId, + const bool i_bHidden + ); + + /** loads the given existing document into the given frame + + This is done using the XComponentLoader interface of the frame, so the SFX document loader is invoked. + + If no frame is given, a blank top level frame is created. + + If anything fails during the process, as much as possible is cleaned up. + + @param i_rDoc + the document to load + @param i_rFrame + the frame to load the document into. Might be <NULL/>, in which case a new frame is created. + @param i_nViewId + the ID of the view to create + */ + SAL_DLLPRIVATE static SfxViewFrame* LoadViewIntoFrame_Impl_NoThrow( + const SfxObjectShell& i_rDoc, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, + const USHORT i_nViewId, + const bool i_bHidden + ); }; //-------------------------------------------------------------------- diff --git a/sfx2/inc/sfx2/viewsh.hxx b/sfx2/inc/sfx2/viewsh.hxx index 7d6b1693d977..0109bbbf602d 100644 --- a/sfx2/inc/sfx2/viewsh.hxx +++ b/sfx2/inc/sfx2/viewsh.hxx @@ -96,24 +96,12 @@ enum SfxScrollingMode // @[SfxViewShell-Flags] -#define SFX_VIEW_MAXIMIZE_FIRST 0x0001 /* die erste View wird maximiert - dargestellt */ -#define SFX_VIEW_OPTIMIZE_EACH 0x0002 /* jede View wird in optimaler - Gr"o\se dargestellt */ -#define SFX_VIEW_DISABLE_ACCELS 0x0004 /* die Acceleratoren werden - disabled, solange diese - View den Focus hat */ -#define SFX_VIEW_OBJECTSIZE_EMBEDDED 0x0008 /* Views von embedded Objekten - werden in optimaler Gr"o\se - dargestellt */ #define SFX_VIEW_HAS_PRINTOPTIONS 0x0010 /* Options-Button und Options- Dialog im PrintDialog */ #define SFX_VIEW_CAN_PRINT 0x0020 /* enabled Printing ohne Printer erzeugen zu m"ussen */ #define SFX_VIEW_NO_SHOW 0x0040 /* Window der ViewShell darf nicht automatisch geshowed werden */ -#define SFX_VIEW_IMPLEMENTED_AS_FRAMESET 0x0080 /* Das Dokument ist als - Frameset implementiert*/ #define SFX_VIEW_NO_NEWWINDOW 0x0100 /* keine weitere View erlauben */ /* [Beschreibung] @@ -159,11 +147,7 @@ class SFX2_DLLPUBLIC SfxViewShell: public SfxShell, public SfxListener { #ifdef _SFXVIEWSH_HXX friend class SfxViewFrame; -friend class SfxTopViewFrame; friend class SfxPlugInFrame; -friend class SfxInternalFrame; -friend class SfxExternalTopViewFrame_Impl; -friend class SfxOfficeDocController; friend class SfxBaseController; #endif @@ -172,8 +156,6 @@ friend class SfxBaseController; SfxViewFrame* pFrame; SfxShell* pSubShell; Window* pWindow; - BOOL bMaximizeFirst; - BOOL bOptimizeEach; BOOL bNoNewWindow; protected: @@ -197,6 +179,8 @@ public: const TypeId* pType = 0, BOOL bOnlyVisible = TRUE ); static SfxViewShell* Current(); + static SfxViewShell* Get( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& i_rController ); + // Ctoren/Dtoren Initialisierung TYPEINFO(); SFX_DECL_INTERFACE(SFX_INTERFACE_SFXVIEWSH) @@ -224,9 +208,6 @@ public: void VisAreaChanged(const Rectangle& rRect); // Verhaltens-Flags - BOOL IsMaximizeFirst() const { return bMaximizeFirst; } - BOOL IsOptimizeEach() const { return bOptimizeEach; } - HACK(inline) BOOL UseObjectSize() const; SfxScrollingMode GetScrollingMode() const; void SetScrollingMode( SfxScrollingMode eMode ); @@ -319,7 +300,6 @@ public: SAL_DLLPRIVATE void AddContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor ); SAL_DLLPRIVATE void RemoveContextMenuInterceptor_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::ui::XContextMenuInterceptor >& xInterceptor ); SAL_DLLPRIVATE FASTBOOL GlobalKeyInput_Impl( const KeyEvent &rKeyEvent ); - SAL_DLLPRIVATE BOOL IsImplementedAsFrameset_Impl() const; SAL_DLLPRIVATE void NewIPClient_Impl( SfxInPlaceClient *pIPClient ) { GetIPClientList_Impl(TRUE)->Insert(pIPClient); } @@ -337,6 +317,8 @@ public: SAL_DLLPRIVATE BOOL HasKeyListeners_Impl(); SAL_DLLPRIVATE BOOL HasMouseClickListeners_Impl(); + SAL_DLLPRIVATE SfxBaseController* GetBaseController_Impl() const; + // Shell Interface SAL_DLLPRIVATE void ExecPrint_Impl(SfxRequest &); SAL_DLLPRIVATE void ExecMisc_Impl(SfxRequest &); @@ -345,11 +327,11 @@ public: SAL_DLLPRIVATE void SetFrameSet_Impl(SfxFrameSetDescriptor*); SAL_DLLPRIVATE void CheckIPClient_Impl( SfxInPlaceClient*, const Rectangle& ); SAL_DLLPRIVATE void PushSubShells_Impl( BOOL bPush=TRUE ); + SAL_DLLPRIVATE void PopSubShells_Impl() { PushSubShells_Impl( FALSE ); } SAL_DLLPRIVATE void TakeOwnerShip_Impl(); SAL_DLLPRIVATE void CheckOwnerShip_Impl(); SAL_DLLPRIVATE void TakeFrameOwnerShip_Impl(); SAL_DLLPRIVATE BOOL ExecKey_Impl(const KeyEvent& aKey); - #endif }; diff --git a/sfx2/inc/viewfac.hxx b/sfx2/inc/viewfac.hxx index d20ed788e739..6f9ae1d3cb37 100644 --- a/sfx2/inc/viewfac.hxx +++ b/sfx2/inc/viewfac.hxx @@ -56,6 +56,9 @@ public: { return String( aDescription ); } USHORT GetOrdinal() const { return nOrd; } + /// returns an API-compatible view name. For the moment, this is "view" with an appended ordinal/ID + String GetViewName() const; + private: SfxViewCtor fnCreate; SfxViewInit fnInit; diff --git a/sfx2/sdi/frmslots.sdi b/sfx2/sdi/frmslots.sdi index 3c6dae423b9f..c4210b801bf6 100644 --- a/sfx2/sdi/frmslots.sdi +++ b/sfx2/sdi/frmslots.sdi @@ -396,21 +396,11 @@ interface TopWindow : BrowseWindow [ StateMethod = StateView_Impl ; ] - SID_WIN_POSSIZE // ole(no) api(final/play/rec) - [ - ExecMethod = Exec_Impl ; - StateMethod = GetState_Impl ; - ] SID_CLOSEWIN // ole(no) api(final/play/rec) [ ExecMethod = Exec_Impl ; StateMethod = GetState_Impl ; ] - SID_BACKTOWEBTOP // ole(no) api(final/play/rec) - [ - ExecMethod = Exec_Impl ; - StateMethod = GetState_Impl ; - ] SID_BROWSE_FORWARD // ole(no) api() [ ExecMethod = INetExecute_Impl ; @@ -431,23 +421,29 @@ interface TopWindow : BrowseWindow ExecMethod = INetExecute_Impl ; StateMethod = INetState_Impl ; ] - SID_BROWSE_STOP // ole(no) api() - [ - ExecMethod = INetExecute_Impl ; - StateMethod = INetState_Impl ; - ] - } //========================================================================= shell SfxViewFrame { - import BrowseWindow [Automation]; + import TopWindow [Automation]; SID_FORMATMENUSTATE [ StateMethod = MiscState_Impl ; ] + + SID_ACTIVATE // ole(no) api(final/play/rec) + [ + ExecMethod = Exec_Impl ; + StateMethod = GetState_Impl ; + ] + + SID_SHOWPOPUPS + [ + ExecMethod = Exec_Impl ; + StateMethod = GetState_Impl ; + ] } diff --git a/sfx2/sdi/makefile.mk b/sfx2/sdi/makefile.mk index 800a48d7f608..c02e51eb6998 100644 --- a/sfx2/sdi/makefile.mk +++ b/sfx2/sdi/makefile.mk @@ -50,7 +50,6 @@ SVSDI1DEPEND= \ appslots.sdi \ sfxslots.sdi \ docslots.sdi \ - mdislots.sdi \ viwslots.sdi \ frmslots.sdi diff --git a/sfx2/sdi/mdislots.sdi b/sfx2/sdi/mdislots.sdi deleted file mode 100644 index 2759f6bcd4d8..000000000000 --- a/sfx2/sdi/mdislots.sdi +++ /dev/null @@ -1,44 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -shell SfxTopViewFrame : SfxViewFrame -{ - import TopWindow [Automation]; - - SID_ACTIVATE // ole(no) api(final/play/rec) - [ - ExecMethod = Exec_Impl ; - StateMethod = GetState_Impl ; - ] - - SID_SHOWPOPUPS - [ - ExecMethod = Exec_Impl ; - StateMethod = GetState_Impl ; - ] -} - diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index e13b26485ee2..10a920852848 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -396,33 +396,6 @@ SfxVoidItem AddWatch SID_BASICIDE_ADDWATCH ] //-------------------------------------------------------------------------- -SfxRectangleItem Area SID_WIN_POSSIZE - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - -//-------------------------------------------------------------------------- SfxStringItem Author SID_DOCINFO_AUTHOR [ @@ -558,31 +531,6 @@ SfxVoidItem Backspace SID_BACKSPACE ] //-------------------------------------------------------------------------- -SfxVoidItem BackToWebtop SID_BACKTOWEBTOP -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- SfxVoidItem BasicBreak SID_BASICBREAK () [ @@ -898,34 +846,6 @@ SfxUInt32Item BuildVersion SID_BUILD_VERSION ] //-------------------------------------------------------------------------- -SfxVoidItem Stop SID_BROWSE_STOP -() -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* status: */ - SlotType = SfxBoolItem - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_NAVIGATOR; -] - -//-------------------------------------------------------------------------- SfxStringItem Caption SID_CAPTION [ @@ -1057,31 +977,6 @@ SfxVoidItem ClearHistory SID_CLEARHISTORY ] //-------------------------------------------------------------------------- -SfxVoidItem ClearMemCache SID_CLEARMEMCACHE -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_OPTIONS; -] - -//-------------------------------------------------------------------------- SfxBoolItem CloseWins SID_CLOSEWINS () [ @@ -1676,31 +1571,6 @@ SfxVoidItem DeleteCurrent SID_BASICIDE_DELETECURRENT ] //-------------------------------------------------------------------------- -SfxVoidItem DeleteFrame SID_DELETE_FRAME -(SfxStringItem Frame SID_FRAMETITLE) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- SfxUInt16Item DeleteStyle SID_STYLE_DELETE (SfxStringItem Param SID_STYLE_DELETE,SfxUInt16Item Family SID_STYLE_FAMILY) [ @@ -1804,33 +1674,6 @@ SfxBoolItem EditDoc SID_EDITDOC ] //-------------------------------------------------------------------------- -SfxBoolItem EditFrameSet SID_EDIT_FRAMESET - -[ - /* 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_EDIT; -] - -//-------------------------------------------------------------------------- SfxVoidItem EditMacro SID_BASICIDE_EDITMACRO (SfxMacroInfoItem aMacroInfo SID_BASICIDE_ARG_MACROINFO) [ @@ -1934,31 +1777,6 @@ SfxBoolItem ExtendedHelp SID_EXTENDEDHELP ] //-------------------------------------------------------------------------- -SfxVoidItem FileDocument SID_SAVEDOCTOBOOKMARK -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_DOCUMENT; -] - -//-------------------------------------------------------------------------- SfxStringItem FileName SID_FILE_NAME [ @@ -2039,114 +1857,6 @@ SfxVoidItem FormatMenu SID_FORMATMENU ] //-------------------------------------------------------------------------- -SfxStringItem FrameContent SID_FRAME_CONTENT - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = TRUE, - RecordPerSet; - Synchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- -SfxUInt16Item FrameCount SID_FRAMECOUNT - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - -//-------------------------------------------------------------------------- -SfxStringItem FrameName SID_FRAME_NAME - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = TRUE, - RecordPerSet; - Synchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- -SfxUInt16Item FrameSpacing SID_FRAMESPACING - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- SfxTemplateItem FrameStyle SID_STYLE_FAMILY3 [ @@ -3301,33 +3011,6 @@ SfxVoidItem InsertObjectFloatingFrame SID_INSERT_FLOATINGFRAME ] //-------------------------------------------------------------------------- -SfxBoolItem Interactive SID_INTERACTIVEMODE - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - -//-------------------------------------------------------------------------- SfxBoolItem InternetOnline SID_INTERNET_ONLINE [ @@ -3380,31 +3063,6 @@ SfxVoidItem InternetSearch SID_INTERNET_SEARCH ] //-------------------------------------------------------------------------- -SfxVoidItem InternetUpdate SID_INTERNET_UPDATE -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = TRUE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_EXPLORER; -] - -//-------------------------------------------------------------------------- SfxBoolItem IsLoading SID_DOC_LOADING [ @@ -3487,33 +3145,6 @@ SfxBoolItem IsPrinting SID_PRINTOUT ] //-------------------------------------------------------------------------- -SfxBoolItem IsTopWindow SID_ISTOP - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - -//-------------------------------------------------------------------------- SfxVoidItem JumpToMark SID_JUMPTOMARK (SfxStringItem Bookmark SID_JUMPTOMARK) [ @@ -3566,33 +3197,6 @@ SfxStringItem Keywords SID_DOCINFO_KEYWORDS ] //-------------------------------------------------------------------------- -SfxBoolItem LateInitDone SID_LATEINIT_DONE - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_APPLICATION; -] - -//-------------------------------------------------------------------------- SfxStringItem LibLoaded SID_BASICIDE_LIBLOADED (SfxUsrAnyItem Document SID_BASICIDE_ARG_DOCUMENT_MODEL,SfxStringItem LibName SID_BASICIDE_ARG_LIBNAME) [ @@ -4040,32 +3644,6 @@ SfxVoidItem MacroDialog SID_BASICCHOOSER ] //-------------------------------------------------------------------------- -SfxVoidItem MailNotifyReset SID_MAIL_NOTIFY_RESET -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = TRUE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_EXPLORER; -] - - -//-------------------------------------------------------------------------- SfxUInt16Item MailReceipt SID_MAIL_NOTIFY [ @@ -4278,31 +3856,6 @@ SfxStringItem ModifiedStatus SID_DOC_MODIFIED ] //-------------------------------------------------------------------------- -SfxVoidItem ModifyFrame SID_MODIFY_FRAME -() -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = TRUE, - RecordPerItem; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- SfxVoidItem ModuleDialog SID_BASICIDE_MODULEDLG () [ @@ -4431,34 +3984,6 @@ SfxVoidItem NewDialog SID_BASICIDE_NEWDIALOG ] //-------------------------------------------------------------------------- -SfxObjectItem NewFrameSet SID_NEWFRAMESET -() -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - /* status: */ - SlotType = SfxStringItem - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_APPLICATION; -] - -//-------------------------------------------------------------------------- SfxVoidItem NewModule SID_BASICIDE_NEWMODULE () [ @@ -4611,33 +4136,6 @@ SfxStringItem ObjectMenue SID_OBJECT ] //-------------------------------------------------------------------------- -SfxStringItem OfficeVersionId SID_OFFICE_VERSION_ID - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = GID_SPECIAL; -] - -//-------------------------------------------------------------------------- SfxStringItem OldPALK SID_OLD_PALK [ @@ -5057,33 +4555,6 @@ SfxStringItem DocPath SID_DOCPATH ] //-------------------------------------------------------------------------- -SfxStringItem Path SID_PROGPATH - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = TRUE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - Readonly = TRUE, - - /* config: */ - AccelConfig = FALSE, - MenuConfig = FALSE, - StatusBarConfig = FALSE, - ToolBoxConfig = FALSE, - GroupId = ; -] - -//-------------------------------------------------------------------------- SfxVoidItem PickList SID_PICKLIST () [ @@ -6491,106 +5962,6 @@ SfxBoolItem SourceView SID_SOURCEVIEW ] //-------------------------------------------------------------------------- -SfxObjectItem SplitHorizontal SID_SPLIT_HORIZONTAL -(SfxStringItem Frame SID_FRAMETITLE) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- -SfxObjectItem SplitParentHorizontal SID_SPLIT_PARENT_HORIZONTAL -(SfxStringItem Frame SID_FRAMETITLE) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- -SfxObjectItem SplitParentVertical SID_SPLIT_PARENT_VERTICAL -(SfxStringItem Frame SID_FRAMETITLE) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- -SfxObjectItem SplitVertical SID_SPLIT_VERTICAL -(SfxStringItem Frame SID_FRAMETITLE) -[ - /* flags: */ - AutoUpdate = TRUE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = FALSE, - ReadOnlyDoc = FALSE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Synchron; - - /* config: */ - AccelConfig = FALSE, - MenuConfig = TRUE, - StatusBarConfig = FALSE, - ToolBoxConfig = TRUE, - GroupId = GID_EDIT; -] - -//-------------------------------------------------------------------------- SfxVoidItem StartRegistrationDialog SID_ONLINE_REGISTRATION_DLG () [ @@ -8114,7 +7485,7 @@ SfxVoidItem AutoPilotAddressDataSource SID_ADDRESS_DATA_SOURCE //-------------------------------------------------------------------------- SfxVoidItem InsertBusinessCard FN_BUSINESS_CARD -( SfxFrameItem Frame SID_DOCFRAME ) +( SfxUnoFrameItem Frame SID_FILLFRAME, SfxBoolItem Hidden SID_HIDDEN ) [ /* flags: */ AutoUpdate = FALSE, @@ -8139,7 +7510,7 @@ SfxVoidItem InsertBusinessCard FN_BUSINESS_CARD //-------------------------------------------------------------------------- SfxVoidItem InsertLabels FN_LABEL -( SfxFrameItem Frame SID_DOCFRAME ) +( SfxUnoFrameItem Frame SID_FILLFRAME, SfxBoolItem Hidden SID_HIDDEN ) [ /* flags: */ AutoUpdate = FALSE, @@ -8164,7 +7535,7 @@ SfxVoidItem InsertLabels FN_LABEL //-------------------------------------------------------------------------- SfxVoidItem NewXForms FN_XFORMS_INIT -( SfxFrameItem Frame SID_DOCFRAME ) +( SfxUnoFrameItem Frame SID_FILLFRAME, SfxBoolItem Hidden SID_HIDDEN ) [ /* flags: */ AutoUpdate = FALSE, @@ -8189,7 +7560,7 @@ SfxVoidItem NewXForms FN_XFORMS_INIT //-------------------------------------------------------------------------- SfxVoidItem AutoPilotPresentations SID_SD_AUTOPILOT -( SfxFrameItem Frame SID_DOCFRAME ) +( SfxUnoFrameItem Frame SID_FILLFRAME, SfxBoolItem Hidden SID_HIDDEN ) [ /* flags: */ AutoUpdate = FALSE, @@ -8214,7 +7585,7 @@ SfxVoidItem AutoPilotPresentations SID_SD_AUTOPILOT //-------------------------------------------------------------------------- SfxVoidItem NewPresentation SID_NEWSD -( SfxFrameItem Frame SID_DOCFRAME ) +( SfxUnoFrameItem Frame SID_FILLFRAME, SfxBoolItem Hidden SID_HIDDEN ) [ /* flags: */ AutoUpdate = FALSE, diff --git a/sfx2/sdi/sfxitems.sdi b/sfx2/sdi/sfxitems.sdi index d9be2f587eda..421c1cb29529 100644 --- a/sfx2/sdi/sfxitems.sdi +++ b/sfx2/sdi/sfxitems.sdi @@ -18,6 +18,7 @@ item String SfxFrameItem; //! Dummy item String SfxObjectShellItem //! Dummy item String SfxUsrAnyItem //! Dummy + item String SfxUnoFrameItem //! Dummy struct Point { diff --git a/sfx2/sdi/sfxslots.sdi b/sfx2/sdi/sfxslots.sdi index b69bd5df93f3..1479c4716efc 100644 --- a/sfx2/sdi/sfxslots.sdi +++ b/sfx2/sdi/sfxslots.sdi @@ -39,7 +39,6 @@ SlotIdFile( "sfx2/sfx.hrc" ) include "docslots.sdi" include "viwslots.sdi" include "frmslots.sdi" - include "mdislots.sdi" include "appslots.sdi" } diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index d5c26f0fb0be..d42d203e57f5 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -108,7 +108,7 @@ #include <sfx2/dispatch.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/genlink.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "appdata.hxx" #include "openflag.hxx" #include "app.hrc" @@ -472,9 +472,6 @@ SfxDispatcher* SfxApplication::GetDispatcher_Impl() //-------------------------------------------------------------------- void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame ) { - if( pFrame && !pFrame->IsSetViewFrameAllowed_Impl() ) - return; - if ( pFrame != pAppData_Impl->pViewFrame ) { // get the containerframes ( if one of the frames is an InPlaceFrame ) @@ -491,12 +488,6 @@ void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame ) // BOOL bDocWinActivate = pOldContainerFrame && pNewContainerFrame && // pOldContainerFrame->GetTopViewFrame() == pNewContainerFrame->GetTopViewFrame(); BOOL bTaskActivate = pOldContainerFrame != pNewContainerFrame; - if ( pAppData_Impl->pViewFrame ) - { - if ( bTaskActivate ) - // prepare UI for deacivation - pAppData_Impl->pViewFrame->GetFrame()->Deactivate_Impl(); - } if ( pOldContainerFrame ) { @@ -565,11 +556,11 @@ short SfxApplication::QuerySave_Impl( SfxObjectShell& rDoc, sal_Bool /*bAutoSave String aMsg( SfxResId( STR_ISMODIFIED ) ); aMsg.SearchAndReplaceAscii( "%1", rDoc.GetTitle() ); - SfxFrame *pFrame = SfxViewFrame::GetFirst(&rDoc)->GetFrame(); - pFrame->Appear(); + SfxFrame& rFrame = SfxViewFrame::GetFirst(&rDoc)->GetFrame(); + rFrame.Appear(); WinBits nBits = WB_YES_NO_CANCEL | WB_DEF_NO; - QueryBox aBox( &pFrame->GetWindow(), nBits, aMsg ); + QueryBox aBox( &rFrame.GetWindow(), nBits, aMsg ); return aBox.Execute(); } @@ -693,7 +684,7 @@ uno::Reference< task::XStatusIndicator > SfxApplication::GetStatusIndicator() co while ( pTop->GetParentViewFrame_Impl() ) pTop = pTop->GetParentViewFrame_Impl(); - return pTop->GetFrame()->GetWorkWindow_Impl()->GetStatusIndicator(); + return pTop->GetFrame().GetWorkWindow_Impl()->GetStatusIndicator(); } SfxTbxCtrlFactArr_Impl& SfxApplication::GetTbxCtrlFactories_Impl() const @@ -810,7 +801,7 @@ SfxApplication::ChooseScript() OSL_TRACE("create selector dialog"); const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - const SfxFrame* pFrame = pViewFrame ? pViewFrame->GetFrame() : NULL; + const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL; uno::Reference< frame::XFrame > xFrame( pFrame ? pFrame->GetFrameInterface() : uno::Reference< frame::XFrame >() ); AbstractScriptSelectorDialog* pDlg = diff --git a/sfx2/source/appl/app.src b/sfx2/source/appl/app.src index 9081cd79f6ee..0858e66e7347 100644 --- a/sfx2/source/appl/app.src +++ b/sfx2/source/appl/app.src @@ -652,11 +652,6 @@ ToolBox RID_ENVTOOLBOX }; ToolBoxItem { - Identifier = SID_BROWSE_STOP ; - Hide = TRUE; - }; - ToolBoxItem - { Type = TOOLBOXITEM_SEPARATOR ; }; ToolBoxItem diff --git a/sfx2/source/appl/appbas.cxx b/sfx2/source/appl/appbas.cxx index 3ace03605d5c..10c4a6bc6797 100644 --- a/sfx2/source/appl/appbas.cxx +++ b/sfx2/source/appl/appbas.cxx @@ -351,7 +351,7 @@ void SfxApplication::EnterBasicCall() } // die SbxObjects der SfxShells auf den Stacks der Frames erzeugen - for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(0,0,sal_False); + for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(0,sal_False); pFrame; pFrame = SfxViewFrame::GetNext(*pFrame,0,0,sal_False) ) { @@ -422,16 +422,6 @@ void SfxApplication::PropExec_Impl( SfxRequest &rReq ) break; } - case SID_WIN_POSSIZE: - { - break; - } - - case SID_INTERACTIVEMODE: - { - break; - } - case SID_ATTR_UNDO_COUNT: { SFX_REQUEST_ARG(rReq, pCountItem, SfxUInt16Item, nSID, sal_False); diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index 54e91df22f3d..6afa8c68ed83 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -268,14 +268,6 @@ BOOL SfxApplication::GetOptions( SfxItemSet& rSet ) bRet = FALSE; } break; - case SID_ATTR_SAVEDOCWINS : - { - bRet = TRUE; - if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEDOCWINS)) - if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_SAVEDOCWINS ), aSaveOptions.IsSaveDocWins()))) - bRet = FALSE; - } - break; case SID_ATTR_SAVEDOCVIEW : { bRet = TRUE; @@ -627,13 +619,6 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) aSaveOptions.SetSaveWorkingSet(((const SfxBoolItem *)pItem)->GetValue()); } - // offene Fenster speichern - if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_SAVEDOCWINS), TRUE, &pItem)) - { - DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected"); - aSaveOptions.SetSaveDocWins(((const SfxBoolItem *)pItem)->GetValue()); - } - // Fenster-Einstellung speichern if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_SAVEDOCVIEW), TRUE, &pItem)) { diff --git a/sfx2/source/appl/appchild.cxx b/sfx2/source/appl/appchild.cxx index e69be0caadc9..b18fc905abdc 100644 --- a/sfx2/source/appl/appchild.cxx +++ b/sfx2/source/appl/appchild.cxx @@ -167,9 +167,9 @@ SfxTemplateDialog* SfxApplication::GetTemplateDialog() SfxWorkWindow* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame *pFrame) const { if ( pFrame ) - return pFrame->GetFrame()->GetWorkWindow_Impl(); + return pFrame->GetFrame().GetWorkWindow_Impl(); else if ( pAppData_Impl->pViewFrame ) - return pAppData_Impl->pViewFrame->GetFrame()->GetWorkWindow_Impl(); + return pAppData_Impl->pViewFrame->GetFrame().GetWorkWindow_Impl(); else return NULL; } diff --git a/sfx2/source/appl/appdata.cxx b/sfx2/source/appl/appdata.cxx index f9abd921cbef..a07623df46b1 100644 --- a/sfx2/source/appl/appdata.cxx +++ b/sfx2/source/appl/appdata.cxx @@ -98,7 +98,6 @@ SfxAppData_Impl::SfxAppData_Impl( SfxApplication* pApp ) : pTopFrames( new SfxFrameArr_Impl ), pInitLinkList(0), pMatcher( 0 ), - pCancelMgr( 0 ), pLabelResMgr( 0 ), pAppDispatch(NULL), pTemplates( 0 ), @@ -148,7 +147,6 @@ SfxAppData_Impl::~SfxAppData_Impl() { DeInitDDE(); delete pTopFrames; - delete pCancelMgr; delete pSecureURLs; delete pBasicManager; diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx index 70e52e9a24f1..808731f8bba8 100644 --- a/sfx2/source/appl/appdde.cxx +++ b/sfx2/source/appl/appdde.cxx @@ -46,7 +46,7 @@ #include "appdata.hxx" #include <sfx2/objsh.hxx> #include <sfx2/viewfrm.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> #include "sfxtypes.hxx" #include <sfx2/sfxsids.hrc> @@ -593,17 +593,12 @@ BOOL ImplDdeService::MakeTopic( const String& rNm ) // dann versuche die Datei zu laden: SfxStringItem aName( SID_FILE_NAME, aFile.GetMainURL( INetURLObject::NO_DECODE ) ); SfxBoolItem aNewView(SID_OPEN_NEW_VIEW, TRUE); -// SfxBoolItem aHidden(SID_HIDDEN, TRUE); - // minimiert! - SfxUInt16Item aViewStat( SID_VIEW_ZOOM_MODE, 0 ); - SfxRectangleItem aRectItem( SID_VIEW_POS_SIZE, Rectangle() ); SfxBoolItem aSilent(SID_SILENT, TRUE); SfxDispatcher* pDispatcher = SFX_APP()->GetDispatcher_Impl(); const SfxPoolItem* pRet = pDispatcher->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, &aName, &aNewView, - &aViewStat,&aRectItem/*aHidden*/, &aSilent, 0L ); if( pRet && pRet->ISA( SfxViewFrameItem ) && @@ -629,7 +624,7 @@ String ImplDdeService::Topics() SfxObjectShell* pShell = SfxObjectShell::GetFirst( &aType ); while( pShell ) { - if( SfxViewFrame::GetFirst( pShell, TYPE(SfxTopViewFrame) )) + if( SfxViewFrame::GetFirst( pShell ) ) { if( sRet.Len() ) sRet += '\t'; diff --git a/sfx2/source/appl/appmisc.cxx b/sfx2/source/appl/appmisc.cxx index 5d8a03609c2a..70147e8d9146 100644 --- a/sfx2/source/appl/appmisc.cxx +++ b/sfx2/source/appl/appmisc.cxx @@ -86,7 +86,7 @@ #include <sfx2/templdlg.hxx> #include <sfx2/module.hxx> #include <sfx2/msgpool.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "openflag.hxx" #include <sfx2/viewsh.hxx> #include <sfx2/objface.hxx> @@ -326,13 +326,6 @@ ISfxTemplateCommon* SfxApplication::GetCurrentTemplateCommon( SfxBindings& rBind return 0; } -SfxCancelManager* SfxApplication::GetCancelManager() const -{ - if ( !pAppData_Impl->pCancelMgr ) - pAppData_Impl->pCancelMgr = new SfxCancelManager; - return pAppData_Impl->pCancelMgr; -} - SfxResourceManager& SfxApplication::GetResourceManager() const { return *pAppData_Impl->pResMgr; } BOOL SfxApplication::IsDowning() const { return pAppData_Impl->bDowning; } SfxDispatcher* SfxApplication::GetAppDispatcher_Impl() { return pAppData_Impl->pAppDispat; } diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 14f3162f0abf..89bb5f23f1de 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -101,7 +101,7 @@ #include "sfxresid.hxx" #include <sfx2/viewsh.hxx> #include "app.hrc" -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/sfxuno.hxx> #include <sfx2/objface.hxx> #include <sfx2/filedlghelper.hxx> @@ -193,7 +193,7 @@ SfxObjectShellRef SfxApplication::DocAlreadyLoaded // Vergleiche anhand der URLs INetURLObject aUrl( xDoc->GetMedium()->GetName() ); if ( !aUrl.HasError() && aUrl == aUrlToFind && - (!bForbidVisible || !SfxViewFrame::GetFirst( xDoc, 0, TRUE )) && + (!bForbidVisible || !SfxViewFrame::GetFirst( xDoc, TRUE )) && !xDoc->IsLoading()) { break; @@ -210,12 +210,10 @@ SfxObjectShellRef SfxApplication::DocAlreadyLoaded DBG_ASSERT( !bForbidVisible, "Unsichtbares kann nicht aktiviert werden" ); - SfxTopViewFrame *pFrame; - for( pFrame = (SfxTopViewFrame*) - SfxViewFrame::GetFirst( xDoc, TYPE(SfxTopViewFrame) ); + SfxViewFrame* pFrame; + for( pFrame = SfxViewFrame::GetFirst( xDoc ); pFrame && !pFrame->IsVisible(); - pFrame = (SfxTopViewFrame*) - SfxViewFrame::GetNext( *pFrame, xDoc, TYPE(SfxTopViewFrame) ) ) ; + pFrame = SfxViewFrame::GetNext( *pFrame, xDoc ) ) ; if ( pFrame ) { SfxViewFrame *pCur = SfxViewFrame::Current(); @@ -511,65 +509,6 @@ ULONG SfxApplication::LoadTemplate( SfxObjectShellLock& xDoc, const String &rFil //-------------------------------------------------------------------- -SfxObjectShellLock SfxApplication::NewDoc_Impl( const String& rFact, const SfxItemSet *pSet ) -{ - SfxObjectShellLock xDoc; - String aFact( rFact ); - String aPrefix = String::CreateFromAscii( "private:factory/" ); - if ( aPrefix.Len() == aFact.Match( aPrefix ) ) - aFact.Erase( 0, aPrefix.Len() ); - USHORT nPos = aFact.Search( '?' ); - String aParam; - if ( nPos != STRING_NOTFOUND ) - { - aParam = aFact.Copy( nPos, aFact.Len() ); - aFact.Erase( nPos, aFact.Len() ); - aParam.Erase(0,1); - } - - xDoc = SfxObjectShell::CreateObjectByFactoryName( aFact ); - aParam = INetURLObject::decode( aParam, '%', INetURLObject::DECODE_WITH_CHARSET ); - if( xDoc.Is() ) - xDoc->DoInitNew_Impl( aParam ); - - if ( xDoc.Is() ) - { - if ( pSet ) - { - // TODO/LATER: Should the other arguments be transfered as well? - SFX_ITEMSET_ARG( pSet, pDefaultPathItem, SfxStringItem, SID_DEFAULTFILEPATH, FALSE); - if ( pDefaultPathItem ) - xDoc->GetMedium()->GetItemSet()->Put( *pDefaultPathItem ); - SFX_ITEMSET_ARG( pSet, pDefaultNameItem, SfxStringItem, SID_DEFAULTFILENAME, FALSE); - if ( pDefaultNameItem ) - xDoc->GetMedium()->GetItemSet()->Put( *pDefaultNameItem ); - SFX_ITEMSET_ARG( pSet, pTitleItem, SfxStringItem, SID_DOCINFO_TITLE, FALSE ); - if ( pTitleItem ) - xDoc->GetMedium()->GetItemSet()->Put( *pTitleItem ); - } - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel ( xDoc->GetModel(), ::com::sun::star::uno::UNO_QUERY ); - if ( xModel.is() ) - { - SfxItemSet* pNew = xDoc->GetMedium()->GetItemSet()->Clone(); - pNew->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL ); - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs; - TransformItems( SID_OPENDOC, *pNew, aArgs ); - - sal_Int32 nLength = aArgs.getLength(); - aArgs.realloc( nLength + 1 ); - - aArgs[nLength].Name = DEFINE_CONST_UNICODE("Title"); - aArgs[nLength].Value <<= ::rtl::OUString( xDoc->GetTitle( SFX_TITLE_DETECT ) ); - - xModel->attachResource( ::rtl::OUString(), aArgs ); - delete pNew; - } - } - - return xDoc; -} - void SfxApplication::NewDocDirectExec_Impl( SfxRequest& rReq ) { DBG_MEMTEST(); @@ -603,131 +542,6 @@ void SfxApplication::NewDocDirectExec_Impl( SfxRequest& rReq ) rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) ); } -const SfxPoolItem* SfxApplication::NewDocDirectExec_ImplOld( SfxRequest& rReq ) -{ - DBG_MEMTEST(); -/* - SFX_REQUEST_ARG(rReq, pHidden, SfxBoolItem, SID_HIDDEN, FALSE); -//(mba)/task - - if ( !pHidden || !pHidden->GetValue() ) - Application::GetAppWindow()->EnterWait(); -*/ - SfxObjectShellLock xDoc; - - // Factory-RegNo kann per Parameter angegeben sein - SfxErrorContext aEc(ERRCTX_SFX_NEWDOCDIRECT); - rReq.GetArgs(); // -Wall required?? - String aFactory; - rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, TRUE ) ); - SFX_REQUEST_ARG( rReq, pFactoryName, SfxStringItem, SID_NEWDOCDIRECT, FALSE ); - if( pFactoryName ) - aFactory = pFactoryName->GetValue(); - else - aFactory = SvtModuleOptions().GetDefaultModuleName(); - - SFX_REQUEST_ARG( rReq, pFileFlagsItem, SfxStringItem, SID_OPTIONS, FALSE); - if ( pFileFlagsItem ) - { - // Werte auf einzelne Items verteilen - String aFileFlags = pFileFlagsItem->GetValue(); - aFileFlags.ToUpperAscii(); - if ( STRING_NOTFOUND != aFileFlags.Search( 0x0054 ) ) // T = 54h - rReq.AppendItem( SfxBoolItem( SID_TEMPLATE, TRUE ) ); - if ( STRING_NOTFOUND != aFileFlags.Search( 0x0048 ) ) // H = 48h - rReq.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) ); - if ( STRING_NOTFOUND != aFileFlags.Search( 0x0052 ) ) // R = 52h - rReq.AppendItem( SfxBoolItem( SID_DOC_READONLY, TRUE ) ); - if ( STRING_NOTFOUND != aFileFlags.Search( 0x0042 ) ) // B = 42h - rReq.AppendItem( SfxBoolItem( SID_PREVIEW, TRUE ) ); - if ( STRING_NOTFOUND != aFileFlags.Search( 0x0053 ) ) // S = 53h - rReq.AppendItem( SfxBoolItem( SID_SILENT, TRUE ) ); - } - - xDoc = NewDoc_Impl( aFactory, rReq.GetArgs() ); - if ( xDoc.Is() ) - { - SFX_REQUEST_ARG(rReq, pReadonly, SfxBoolItem, SID_DOC_READONLY, FALSE); - if ( pReadonly ) - xDoc->GetMedium()->GetItemSet()->Put( *pReadonly ); - - SFX_REQUEST_ARG(rReq, pPreview, SfxBoolItem, SID_PREVIEW, FALSE); - if ( pPreview ) - xDoc->GetMedium()->GetItemSet()->Put( *pPreview ); - - SFX_REQUEST_ARG(rReq, pSilent, SfxBoolItem, SID_SILENT, FALSE); - if ( pSilent ) - xDoc->GetMedium()->GetItemSet()->Put( *pSilent ); - - SFX_REQUEST_ARG(rReq, pFlags, SfxStringItem, SID_OPTIONS, FALSE); - if ( pFlags ) - xDoc->GetMedium()->GetItemSet()->Put( *pFlags ); - } - - // View erzeugen - if ( xDoc.Is() ) - { - SFX_REQUEST_ARG(rReq, pHidden, SfxBoolItem, SID_HIDDEN, FALSE); - BOOL bHidden = FALSE; - if ( pHidden ) - { - xDoc->GetMedium()->GetItemSet()->Put( *pHidden, SID_HIDDEN ); - bHidden = pHidden->GetValue(); - } - - SFX_REQUEST_ARG(rReq, pViewId, SfxUInt16Item, SID_VIEW_ID, FALSE); - USHORT nViewId = 0; - if ( pViewId ) - { - xDoc->GetMedium()->GetItemSet()->Put( *pViewId, SID_VIEW_ID ); - nViewId = pViewId->GetValue(); - } - - xDoc->SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); -// xDoc->Get_Impl()->nLoadedFlags = SFX_LOADED_ALL; - const SfxItemSet* pInternalArgs = rReq.GetInternalArgs_Impl(); - if( pInternalArgs ) - xDoc->GetMedium()->GetItemSet()->Put( *pInternalArgs ); - SFX_REQUEST_ARG(rReq, pFrameItem, SfxFrameItem, SID_DOCFRAME, FALSE); - - SfxFrame* pFrame = NULL; - if (pFrameItem) - pFrame = pFrameItem->GetFrame(); - else - pFrame = (SfxFrame*)SfxTopFrame::Create(xDoc, nViewId, bHidden, pInternalArgs); - if ( pFrame ) - { - if ( pFrame->GetCurrentDocument() == xDoc || pFrame->PrepareClose_Impl( TRUE, TRUE ) == TRUE ) - { - if ( bHidden ) - { - xDoc->RestoreNoDelete(); - xDoc->OwnerLock( TRUE ); - xDoc->Get_Impl()->bHiddenLockedByAPI = TRUE; - } - - if ( pFrame->GetCurrentDocument() != xDoc ) - { - if ( pFrame->InsertDocument( xDoc ) ) - rReq.SetReturnValue( SfxFrameItem( 0, pFrame ) ); - else - xDoc->DoClose(); - } - } - else - xDoc.Clear(); - } - } - - return rReq.GetReturnValue(); - -//(mba)/task -/* - if ( !pHidden || !pHidden->GetValue() ) - Application::GetAppWindow()->LeaveWait(); - */ -} - //-------------------------------------------------------------------- void SfxApplication::NewDocExec_Impl( SfxRequest& rReq ) @@ -1303,12 +1117,22 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) return; } - SFX_REQUEST_ARG(rReq, pFrmItem, SfxFrameItem, SID_DOCFRAME, FALSE); - SfxFrame *pFrame = NULL; - if ( pFrmItem ) - pFrame = pFrmItem->GetFrame(); - else if ( SfxViewFrame::Current() ) - pFrame = SfxViewFrame::Current()->GetFrame(); + SfxFrame* pTargetFrame = NULL; + Reference< XFrame > xTargetFrame; + + SFX_REQUEST_ARG(rReq, pFrameItem, SfxFrameItem, SID_DOCFRAME, FALSE); + if ( pFrameItem ) + pTargetFrame = pFrameItem->GetFrame(); + + if ( !pTargetFrame ) + { + SFX_REQUEST_ARG(rReq, pUnoFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE); + if ( pUnoFrameItem ) + xTargetFrame = pUnoFrameItem->GetFrame(); + } + + if ( !pTargetFrame && !xTargetFrame.is() && SfxViewFrame::Current() ) + pTargetFrame = &SfxViewFrame::Current()->GetFrame(); // check if caller has set a callback SFX_REQUEST_ARG(rReq, pLinkItem, SfxLinkItem, SID_DONELINK, FALSE ); @@ -1319,21 +1143,6 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) rReq.RemoveItem( SID_DONELINK ); - // check if caller wants to create a view - BOOL bCreateView = TRUE; - SFX_REQUEST_ARG( rReq, pCreateViewItem, SfxBoolItem, SID_VIEW, FALSE ); - if ( pCreateViewItem ) - { - if ( !pCreateViewItem->GetValue() ) - bCreateView = FALSE; - // this is an "SFX only" parameter - rReq.RemoveItem( SID_VIEW ); - } - - // we can't load without a view - switch to hidden view - if ( !bCreateView ) - rReq.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) ); - // check if the view must be hidden BOOL bHidden = FALSE; SFX_REQUEST_ARG(rReq, pHidItem, SfxBoolItem, SID_HIDDEN, FALSE); @@ -1385,18 +1194,24 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // { // if a frame is given, it must be used for the starting point of the targetting mechanism // this code is also used if asynchronous loading is possible, because loadComponent always is synchron - Reference < XFrame > xFrame; - if ( pFrame ) - xFrame = pFrame->GetFrameInterface(); - else - xFrame = Reference < XFrame >( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY ); + if ( !xTargetFrame.is() ) + { + if ( pTargetFrame ) + { + xTargetFrame = pTargetFrame->GetFrameInterface(); + } + else + { + xTargetFrame.set( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY ); + } + } // make URL ready SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_FILE_NAME, FALSE ); aFileName = pURLItem->GetValue(); if( aFileName.Len() && aFileName.GetChar(0) == '#' ) // Mark without URL { - SfxViewFrame *pView = pFrame ? pFrame->GetCurrentViewFrame() : 0; + SfxViewFrame *pView = pTargetFrame ? pTargetFrame->GetCurrentViewFrame() : 0; if ( !pView ) pView = SfxViewFrame::Current(); pView->GetViewShell()->JumpToMark( aFileName.Copy(1) ); @@ -1414,13 +1229,13 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) // if loading must be done synchron, we must wait for completion to get a return value // find frame by myself; I must konw the exact frame to get the controller for the return value from it //if( aTarget.getLength() ) - // xFrame = xFrame->findFrame( aTarget, FrameSearchFlag::ALL ); + // xTargetFrame = xTargetFrame->findFrame( aTarget, FrameSearchFlag::ALL ); Reference < XComponent > xComp; try { - xComp = ::comphelper::SynchronousDispatch::dispatch( xFrame, aFileName, aTarget, 0, aArgs ); -// Reference < XComponentLoader > xLoader( xFrame, UNO_QUERY ); + xComp = ::comphelper::SynchronousDispatch::dispatch( xTargetFrame, aFileName, aTarget, 0, aArgs ); +// Reference < XComponentLoader > xLoader( xTargetFrame, UNO_QUERY ); // xComp = xLoader->loadComponentFromURL( aFileName, aTarget, 0, aArgs ); } catch(const RuntimeException&) @@ -1445,7 +1260,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); xTrans->parseStrict( aURL ); - Reference < XDispatchProvider > xProv( xFrame, UNO_QUERY ); + Reference < XDispatchProvider > xProv( xTargetFrame, UNO_QUERY ); Reference < XDispatch > xDisp = xProv.is() ? xProv->queryDispatch( aURL, aTarget, FrameSearchFlag::ALL ) : Reference < XDispatch >();; RTL_LOGFILE_PRODUCT_CONTEXT( aLog2, "PERFORMANCE - SfxApplication::OpenDocExec_Impl" ); if ( xDisp.is() ) @@ -1491,7 +1306,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) { if ( pShell->GetController() == xController ) { - pCntrFrame = pShell->GetViewFrame()->GetFrame(); + pCntrFrame = &pShell->GetViewFrame()->GetFrame(); break; } } @@ -1501,12 +1316,9 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq ) SfxObjectShell* pSh = pCntrFrame->GetCurrentDocument(); DBG_ASSERT( pSh, "Controller without ObjectShell ?!" ); - if ( bCreateView ) - rReq.SetReturnValue( SfxViewFrameItem( 0, pCntrFrame->GetCurrentViewFrame() ) ); - else - rReq.SetReturnValue( SfxObjectItem( 0, pSh ) ); + rReq.SetReturnValue( SfxViewFrameItem( 0, pCntrFrame->GetCurrentViewFrame() ) ); - if( ( bHidden || !bCreateView ) ) + if ( bHidden ) pSh->RestoreNoDelete(); } } diff --git a/sfx2/source/appl/appquit.cxx b/sfx2/source/appl/appquit.cxx index c316a9847886..4da32cf9f566 100644 --- a/sfx2/source/appl/appquit.cxx +++ b/sfx2/source/appl/appquit.cxx @@ -116,9 +116,6 @@ BOOL SfxApplication::QueryExit_Impl() } } */ - // alles canceln was zu canceln ist - GetCancelManager()->Cancel(TRUE); - /* SfxObjectShell *pLastDocSh = SfxObjectShell::GetFirst(); if ( bQuit ) diff --git a/sfx2/source/appl/appreg.cxx b/sfx2/source/appl/appreg.cxx index a2f34b472732..47bf98292316 100644 --- a/sfx2/source/appl/appreg.cxx +++ b/sfx2/source/appl/appreg.cxx @@ -43,7 +43,7 @@ #include "stbitem.hxx" #include <sfx2/navigat.hxx> #include <sfx2/module.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "partwnd.hxx" #include <sfx2/sfxsids.hrc> #include "recfloat.hxx" @@ -59,7 +59,6 @@ void SfxApplication::Registrations_Impl() SfxApplication::RegisterInterface(); SfxModule::RegisterInterface(); SfxViewFrame::RegisterInterface(); - SfxTopViewFrame::RegisterInterface(); SfxObjectShell::RegisterInterface(); SfxViewShell::RegisterInterface(); @@ -73,7 +72,6 @@ void SfxApplication::Registrations_Impl() // Controller SfxToolBoxControl::RegisterControl(SID_REPEAT); SfxURLToolBoxControl_Impl::RegisterControl(SID_OPENURL); - SfxCancelToolBoxControl_Impl::RegisterControl(SID_BROWSE_STOP); SfxAppToolBoxControl_Impl::RegisterControl( SID_NEWDOCDIRECT ); SfxAppToolBoxControl_Impl::RegisterControl( SID_AUTOPILOTMENU ); }; diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 53cf115382e5..14789100bb24 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -68,7 +68,6 @@ #include <tools/config.hxx> #include <tools/diagnose_ex.h> #include <vcl/msgbox.hxx> -#include <svl/cancel.hxx> #include <svl/intitem.hxx> #include <svl/eitem.hxx> #include <svl/stritem.hxx> @@ -93,9 +92,11 @@ #include <cppuhelper/exc_hlp.hxx> #include <com/sun/star/script/provider/XScriptProviderFactory.hpp> +#include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include "about.hxx" +#include "frmload.hxx" #include "referers.hxx" #include <sfx2/app.hxx> #include <sfx2/request.hxx> @@ -129,7 +130,7 @@ #include "minfitem.hxx" #include <sfx2/event.hxx> #include <sfx2/module.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "sfxpicklist.hxx" #include "imestatuswindow.hxx" #include <sfx2/sfxdlg.hxx> @@ -262,9 +263,9 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) Reference< XFrame > xFrame; const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl(); - SFX_ITEMSET_ARG( pIntSet, pFrame, SfxUnoAnyItem, SID_FILLFRAME, FALSE ); - if (pFrame) - pFrame->GetValue() >>= xFrame; + SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE ); + if ( pFrameItem ) + xFrame = pFrameItem->GetFrame(); SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_SVXDLG_CUSTOMIZE, @@ -822,6 +823,60 @@ namespace } return _pFallback; } + + const ::rtl::OUString& lcl_getBasicIDEServiceName() + { + static const ::rtl::OUString s_sBasicName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.BasicIDE" ) ); + return s_sBasicName; + } + + SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE ) + { + SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE ); + while ( pView ) + { + if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() ) + break; + pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE ); + } + return pView; + } + Reference< XFrame > lcl_findStartModuleFrame( const ::comphelper::ComponentContext& i_rContext ) + { + try + { + Reference < XFramesSupplier > xSupplier( i_rContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); + Reference < XIndexAccess > xContainer( xSupplier->getFrames(), UNO_QUERY_THROW ); + + Reference< XModuleManager > xCheck( i_rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); + + sal_Int32 nCount = xContainer->getCount(); + for ( sal_Int32 i=0; i<nCount; ++i ) + { + try + { + Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW ); + ::rtl::OUString sModule = xCheck->identify( xFrame ); + if ( sModule.equalsAscii( "com.sun.star.frame.StartModule" ) ) + return xFrame; + } + catch( const UnknownModuleException& ) + { + // silence + } + catch(const Exception&) + { + // re-throw, caught below + throw; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return NULL; + } } void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) @@ -839,7 +894,10 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) const SfxPoolItem* pItem = NULL; Reference < XFrame > xFrame; if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET ) - ( (SfxUnoAnyItem*)pItem )->GetValue() >>= xFrame; + { + OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" ); + xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame(); + } SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); if ( pFact ) { @@ -902,26 +960,46 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) case SID_BASICIDE_APPEAR: { - SfxViewFrame* pView = SfxViewFrame::GetFirst(); - ::rtl::OUString aBasicName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.BasicIDE" ) ); - while ( pView ) - { - if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == aBasicName ) - break; - pView = SfxViewFrame::GetNext( *pView ); - } - + SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL ); if ( !pView ) { - SfxObjectShell* pDocShell = SfxObjectShell::CreateObject( aBasicName ); - pDocShell->DoInitNew( 0 ); - pDocShell->SetModified( FALSE ); - pView = SfxViewFrame::CreateViewFrame( *pDocShell, 0 ); - pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) ); + SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() ); + pBasicIDE->DoInitNew( 0 ); + pBasicIDE->SetModified( FALSE ); + try + { + // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL + // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE + // does not really play nice with the framework's concept. For instance, it is a "singleton document", + // which conflicts, at the latest, with the framework's concept of loading into _blank frames. + // So, since we know that our frame loader can handle it, we skip the generic framework loader + // mechanism, and the type detection (which doesn't know about the Basic IDE). + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XSynchronousFrameLoader > xLoader( aContext.createComponent( + SfxFrameLoader_Impl::impl_getStaticImplementationName() ), UNO_QUERY_THROW ); + ::comphelper::NamedValueCollection aLoadArgs; + aLoadArgs.put( "Model", pBasicIDE->GetModel() ); + aLoadArgs.put( "URL", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/sbasic" ) ) ); + + Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( aContext ) ); + if ( !xTargetFrame.is() ) + xTargetFrame = SfxFrame::CreateBlankFrame(); + ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" ); + + xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + pView = lcl_getBasicIDEViewFrame( pBasicIDE ); + if ( pView ) + pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) ); } if ( pView ) - pView->GetFrame()->Appear(); + pView->GetFrame().Appear(); const SfxItemSet* pArgs = rReq.GetArgs(); if ( pArgs && pView ) @@ -988,16 +1066,15 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq ) Reference< XFrame > xFrame; const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl(); - SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, FALSE ); + SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE ); if ( pFrameItem ) - pFrameItem->GetValue() >>= xFrame; + xFrame = pFrameItem->GetFrame(); if ( !xFrame.is() ) { const SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - const SfxFrame* pFrame = pViewFrame ? pViewFrame->GetFrame() : NULL; - if ( pFrame ) - xFrame = pFrame->GetFrameInterface(); + if ( pViewFrame ) + xFrame = pViewFrame->GetFrame().GetFrameInterface(); } do // artificial loop for flow control diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 05c23627a3b9..8b7e06c231cd 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -144,54 +144,53 @@ using namespace ::com::sun::star::io; #define FRAMELOADER_SERVICENAME "com.sun.star.frame.FrameLoader" #define PROTOCOLHANDLER_SERVICENAME "com.sun.star.frame.ProtocolHandler" -static const String sTemplateRegionName = String::CreateFromAscii( "TemplateRegionName" ); -static const String sTemplateName = String::CreateFromAscii( "TemplateName" ); -static const String sAsTemplate = String::CreateFromAscii( "AsTemplate" ); -static const String sOpenNewView = String::CreateFromAscii( "OpenNewView" ); -static const String sViewId = String::CreateFromAscii( "ViewId" ); -static const String sPluginMode = String::CreateFromAscii( "PluginMode" ); -static const String sReadOnly = String::CreateFromAscii( "ReadOnly" ); -static const String sStartPresentation = String::CreateFromAscii( "StartPresentation" ); -static const String sFrameName = String::CreateFromAscii( "FrameName" ); -static const String sMediaType = String::CreateFromAscii( "MediaType" ); -static const String sPostData = String::CreateFromAscii( "PostData" ); -static const String sCharacterSet = String::CreateFromAscii( "CharacterSet" ); -static const String sInputStream = String::CreateFromAscii( "InputStream" ); -static const String sStream = String::CreateFromAscii( "Stream" ); -static const String sOutputStream = String::CreateFromAscii( "OutputStream" ); -static const String sHidden = String::CreateFromAscii( "Hidden" ); -static const String sPreview = String::CreateFromAscii( "Preview" ); -static const String sViewOnly = String::CreateFromAscii( "ViewOnly" ); -static const String sDontEdit = String::CreateFromAscii( "DontEdit" ); -static const String sSilent = String::CreateFromAscii( "Silent" ); -static const String sJumpMark = String::CreateFromAscii( "JumpMark" ); -static const String sFileName = String::CreateFromAscii( "FileName" ); -static const String sSalvageURL = String::CreateFromAscii( "SalvagedFile" ); -static const String sStatusInd = String::CreateFromAscii( "StatusIndicator" ); -static const String sModel = String::CreateFromAscii( "Model" ); -static const String sFrame = String::CreateFromAscii( "Frame" ); -static const String sViewData = String::CreateFromAscii( "ViewData" ); -static const String sFilterData = String::CreateFromAscii( "FilterData" ); -static const String sSelectionOnly = String::CreateFromAscii( "SelectionOnly" ); -static const String sFilterFlags = String::CreateFromAscii( "FilterFlags" ); -static const String sMacroExecMode = String::CreateFromAscii( "MacroExecutionMode" ); -static const String sUpdateDocMode = String::CreateFromAscii( "UpdateDocMode" ); -static const String sMinimized = String::CreateFromAscii( "Minimized" ); -static const String sInteractionHdl = String::CreateFromAscii( "InteractionHandler" ); -static const String sWindowState = String::CreateFromAscii( "WindowState" ); -static const String sUCBContent = String::CreateFromAscii( "UCBContent" ); -static const String sRepairPackage = String::CreateFromAscii( "RepairPackage" ); -static const String sDocumentTitle = String::CreateFromAscii( "DocumentTitle" ); -static const String sComponentData = String::CreateFromAscii( "ComponentData" ); -static const String sComponentContext = String::CreateFromAscii( "ComponentContext" ); -static const String sDocumentBaseURL = String::CreateFromAscii( "DocumentBaseURL" ); -static const String sHierarchicalDocumentName = String::CreateFromAscii( "HierarchicalDocumentName" ); -static const String sCopyStreamIfPossible = String::CreateFromAscii( "CopyStreamIfPossible" ); -static const String sNoAutoSave = String::CreateFromAscii( "NoAutoSave" ); -static const String sFolderName = String::CreateFromAscii( "FolderName" ); -static const String sUseSystemDialog = String::CreateFromAscii( "UseSystemDialog" ); -static const String sStandardDir = String::CreateFromAscii( "StandardDir" ); -static const String sBlackList = String::CreateFromAscii( "BlackList" ); +static const String sTemplateRegionName = String::CreateFromAscii( "TemplateRegionName" ); +static const String sTemplateName = String::CreateFromAscii( "TemplateName" ); +static const String sAsTemplate = String::CreateFromAscii( "AsTemplate" ); +static const String sOpenNewView = String::CreateFromAscii( "OpenNewView" ); +static const String sViewId = String::CreateFromAscii( "ViewId" ); +static const String sPluginMode = String::CreateFromAscii( "PluginMode" ); +static const String sReadOnly = String::CreateFromAscii( "ReadOnly" ); +static const String sStartPresentation = String::CreateFromAscii( "StartPresentation" ); +static const String sFrameName = String::CreateFromAscii( "FrameName" ); +static const String sMediaType = String::CreateFromAscii( "MediaType" ); +static const String sPostData = String::CreateFromAscii( "PostData" ); +static const String sCharacterSet = String::CreateFromAscii( "CharacterSet" ); +static const String sInputStream = String::CreateFromAscii( "InputStream" ); +static const String sStream = String::CreateFromAscii( "Stream" ); +static const String sOutputStream = String::CreateFromAscii( "OutputStream" ); +static const String sHidden = String::CreateFromAscii( "Hidden" ); +static const String sPreview = String::CreateFromAscii( "Preview" ); +static const String sViewOnly = String::CreateFromAscii( "ViewOnly" ); +static const String sDontEdit = String::CreateFromAscii( "DontEdit" ); +static const String sSilent = String::CreateFromAscii( "Silent" ); +static const String sJumpMark = String::CreateFromAscii( "JumpMark" ); +static const String sFileName = String::CreateFromAscii( "FileName" ); +static const String sSalvageURL = String::CreateFromAscii( "SalvagedFile" ); +static const String sStatusInd = String::CreateFromAscii( "StatusIndicator" ); +static const String sModel = String::CreateFromAscii( "Model" ); +static const String sFrame = String::CreateFromAscii( "Frame" ); +static const String sViewData = String::CreateFromAscii( "ViewData" ); +static const String sFilterData = String::CreateFromAscii( "FilterData" ); +static const String sSelectionOnly = String::CreateFromAscii( "SelectionOnly" ); +static const String sFilterFlags = String::CreateFromAscii( "FilterFlags" ); +static const String sMacroExecMode = String::CreateFromAscii( "MacroExecutionMode" ); +static const String sUpdateDocMode = String::CreateFromAscii( "UpdateDocMode" ); +static const String sMinimized = String::CreateFromAscii( "Minimized" ); +static const String sInteractionHdl = String::CreateFromAscii( "InteractionHandler" ); +static const String sUCBContent = String::CreateFromAscii( "UCBContent" ); +static const String sRepairPackage = String::CreateFromAscii( "RepairPackage" ); +static const String sDocumentTitle = String::CreateFromAscii( "DocumentTitle" ); +static const String sComponentData = String::CreateFromAscii( "ComponentData" ); +static const String sComponentContext = String::CreateFromAscii( "ComponentContext" ); +static const String sDocumentBaseURL = String::CreateFromAscii( "DocumentBaseURL" ); +static const String sHierarchicalDocumentName = String::CreateFromAscii( "HierarchicalDocumentName" ); +static const String sCopyStreamIfPossible = String::CreateFromAscii( "CopyStreamIfPossible" ); +static const String sNoAutoSave = String::CreateFromAscii( "NoAutoSave" ); +static const String sFolderName = String::CreateFromAscii( "FolderName" ); +static const String sUseSystemDialog = String::CreateFromAscii( "UseSystemDialog" ); +static const String sStandardDir = String::CreateFromAscii( "StandardDir" ); +static const String sBlackList = String::CreateFromAscii( "BlackList" ); void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs, SfxAllItemSet& rSet, const SfxSlot* pSlot ) { @@ -468,7 +467,11 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque const ::com::sun::star::beans::PropertyValue& rProp = pPropsVal[n]; String aName = rProp.Name; if ( aName == sFrame ) - rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) ); + { + Reference< XFrame > xFrame; + OSL_VERIFY( rProp.Value >>= xFrame ); + rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) ); + } else if ( aName == sHidden ) { @@ -560,11 +563,11 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque } else if ( aName == sFrame ) { - Reference< XFrame > xVal; - sal_Bool bOK = (rProp.Value >>= xVal); + Reference< XFrame > xFrame; + sal_Bool bOK = (rProp.Value >>= xFrame); DBG_ASSERT( bOK, "invalid type for Frame" ); if (bOK) - rSet.Put( SfxUnoAnyItem( SID_FILLFRAME, rProp.Value ) ); + rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrame ) ); } else if ( aName == sAsTemplate ) { @@ -738,14 +741,6 @@ void TransformParameters( sal_uInt16 nSlotId, const ::com::sun::star::uno::Seque if (bOK) rSet.Put( SfxStringItem( SID_CONTENTTYPE, sVal ) ); } - else if ( aName == sWindowState ) - { - ::rtl::OUString sVal; - sal_Bool bOK = ((rProp.Value >>= sVal) && sVal.getLength()); - DBG_ASSERT( bOK, "invalid type or value for WindowState" ); - if (bOK) - rSet.Put( SfxStringItem( SID_WIN_POSSIZE, sVal ) ); - } else if ( aName == sTemplateName ) { ::rtl::OUString sVal; @@ -1015,10 +1010,6 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta nAdditional++; if ( rSet.GetItemState( SID_CONTENTTYPE ) == SFX_ITEM_SET ) nAdditional++; - if ( rSet.GetItemState( SID_WIN_POSSIZE ) == SFX_ITEM_SET ) - nAdditional++; - // if ( rSet.GetItemState( SID_VIEW_POS_SIZE ) == SFX_ITEM_SET ) - // nAdditional++; if ( rSet.GetItemState( SID_POSTDATA ) == SFX_ITEM_SET ) nAdditional++; if ( rSet.GetItemState( SID_FILLFRAME ) == SFX_ITEM_SET ) @@ -1174,8 +1165,6 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta continue; if ( nId == SID_CONTENTTYPE ) continue; - if ( nId == SID_WIN_POSSIZE ) - continue; if ( nId == SID_TEMPLATE_NAME ) continue; if ( nId == SID_TEMPLATE_REGIONNAME ) @@ -1392,7 +1381,15 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta if ( rSet.GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET ) { pValue[nActProp].Name = sFrame; - pValue[nActProp++].Value = ( ((SfxUnoAnyItem*)pItem)->GetValue() ); + if ( pItem->ISA( SfxUsrAnyItem ) ) + { + OSL_ENSURE( false, "TransformItems: transporting an XFrame via an SfxUsrAnyItem is not deprecated!" ); + pValue[nActProp++].Value = static_cast< const SfxUsrAnyItem* >( pItem )->GetValue(); + } + else if ( pItem->ISA( SfxUnoFrameItem ) ) + pValue[nActProp++].Value <<= static_cast< const SfxUnoFrameItem* >( pItem )->GetFrame(); + else + OSL_ENSURE( false, "TransformItems: invalid item type for SID_FILLFRAME!" ); } if ( rSet.GetItemState( SID_TEMPLATE, sal_False, &pItem ) == SFX_ITEM_SET ) { @@ -1497,11 +1494,6 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp].Name = sMediaType; pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) ); } - if ( rSet.GetItemState( SID_WIN_POSSIZE, sal_False, &pItem ) == SFX_ITEM_SET ) - { - pValue[nActProp].Name = sWindowState; - pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) ); - } if ( rSet.GetItemState( SID_TEMPLATE_NAME, sal_False, &pItem ) == SFX_ITEM_SET ) { pValue[nActProp].Name = sTemplateName; @@ -1518,12 +1510,6 @@ void TransformItems( sal_uInt16 nSlotId, const SfxItemSet& rSet, ::com::sun::sta pValue[nActProp++].Value <<= ( ::rtl::OUString(((SfxStringItem*)pItem)->GetValue()) ); } - SFX_ITEMSET_ARG( &rSet, pRectItem, SfxRectangleItem, SID_VIEW_POS_SIZE, sal_False ); - if ( pRectItem ) - { - DBG_ERROR("PosSizeItem not supported yet!"); - } - if ( rSet.GetItemState( SID_CHARSET, sal_False, &pItem ) == SFX_ITEM_SET ) { pValue[nActProp].Name = sCharacterSet; diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx index ecc457760392..294d6ef17da5 100644 --- a/sfx2/source/appl/fileobj.cxx +++ b/sfx2/source/appl/fileobj.cxx @@ -291,8 +291,6 @@ BOOL SvFileObject::LoadFile_Impl() aStreamToLoadFrom.m_xInputStreamToLoadFrom, aStreamToLoadFrom.m_bIsReadOnly); // setStreamToLoadFrom(0,0); - // Keinen Eintrag im Roter Button Menu - xMed->SetDontCreateCancellable(); if( sReferer.Len() ) xMed->SetReferer( sReferer ); @@ -682,9 +680,6 @@ BOOL SvFileObject::IsDataComplete() const void SvFileObject::CancelTransfers() { - if( xMed.Is() ) - xMed->CancelTransfers(); - // und aus dem Cache austragen, wenn man mitten im Laden ist if( !bDataReady ) { @@ -696,11 +691,6 @@ void SvFileObject::CancelTransfers() } -void SvFileObject::SetTransferPriority( USHORT ) -{ -} - - void SvFileObject::SendStateChg_Impl( sfx2::LinkManager::LinkState nState ) { if( !bStateChangeCalled && HasDataLinks() ) diff --git a/sfx2/source/appl/fileobj.hxx b/sfx2/source/appl/fileobj.hxx index 58a3c662b92c..50f934a75436 100644 --- a/sfx2/source/appl/fileobj.hxx +++ b/sfx2/source/appl/fileobj.hxx @@ -88,7 +88,6 @@ public: virtual BOOL IsDataComplete() const; void CancelTransfers(); - void SetTransferPriority( USHORT nPrio ); }; diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx index 3f5dcb78a677..ce69ba225157 100644 --- a/sfx2/source/appl/linkmgr2.cxx +++ b/sfx2/source/appl/linkmgr2.cxx @@ -430,16 +430,6 @@ void LinkManager::CancelTransfers() pFileObj->CancelTransfers(); } -void LinkManager::SetTransferPriority( sfx2::SvBaseLink& /*rLink*/, USHORT /*nPrio*/ ) -{ -// SvFileObject* pFileObj = -// (SvFileObject*)SvFileObject::ClassFactory()-> -// CastAndAddRef( rLink.GetObj() ); -// OBJECT_CLIENT_FILE == (OBJECT_CLIENT_FILE & rLink.GetObjType()) ? -// (SvFileObject*)rLink.GetObj() : 0; -} - - // um Status Informationen aus dem FileObject an den BaseLink zu // senden, gibt es eine eigene ClipBoardId. Das SvData-Object hat // dann die entsprechenden Informationen als String. diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx index 54add7271ae1..0074faac192f 100644 --- a/sfx2/source/appl/sfxpicklist.cxx +++ b/sfx2/source/appl/sfxpicklist.cxx @@ -446,7 +446,7 @@ void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint ) return; // ignore hidden documents - if ( !SfxViewFrame::GetFirst( pDocSh, 0, TRUE ) ) + if ( !SfxViewFrame::GetFirst( pDocSh, TRUE ) ) return; ::rtl::OUString aTitle = pDocSh->GetTitle(SFX_TITLE_PICKLIST); diff --git a/sfx2/source/appl/workwin.cxx b/sfx2/source/appl/workwin.cxx index dcc087767469..24cf7dab8095 100644 --- a/sfx2/source/appl/workwin.cxx +++ b/sfx2/source/appl/workwin.cxx @@ -38,7 +38,7 @@ #include <sfx2/objsh.hxx> #include <sfx2/app.hxx> #include "workwin.hxx" -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "arrdecl.hxx" #include <sfx2/viewfrm.hxx> #include <sfx2/module.hxx> @@ -1431,8 +1431,8 @@ sal_Bool SfxWorkWindow::IsPluginMode( SfxObjectShell* pObjShell ) if ( pDispatcher ) { SfxViewFrame* pFrame = pDispatcher->GetFrame(); - if ( pFrame && pFrame->GetFrame() ) - xFrame = pFrame->GetFrame()->GetFrameInterface(); + if ( pFrame ) + xFrame = pFrame->GetFrame().GetFrameInterface(); } return xFrame; diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx index b89494bee8d7..d11b8b5130ed 100644 --- a/sfx2/source/bastyp/fltfnc.cxx +++ b/sfx2/source/bastyp/fltfnc.cxx @@ -124,7 +124,7 @@ using namespace ::vos; #include <sfx2/doctempl.hxx> #include <sfx2/frame.hxx> #include <sfx2/dispatch.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "helper.hxx" #include "fltlst.hxx" #include <sfx2/request.hxx> diff --git a/sfx2/source/bastyp/progress.cxx b/sfx2/source/bastyp/progress.cxx index 99175a124afa..649ae121c274 100644 --- a/sfx2/source/bastyp/progress.cxx +++ b/sfx2/source/bastyp/progress.cxx @@ -77,7 +77,7 @@ void AddNumber_Impl( String& aNumber, sal_uInt32 nArg ) } } -struct SfxProgress_Impl : public SfxCancellable +struct SfxProgress_Impl { Reference < XStatusIndicator > xStatusInd; String aText, aStateText; @@ -141,11 +141,9 @@ void SfxProgress_Impl::Enable_Impl( BOOL bEnable ) // ----------------------------------------------------------------------- -SfxProgress_Impl::SfxProgress_Impl( const String &rTitle ) - : SfxCancellable( SFX_APP()->GetCancelManager(), rTitle ), - pActiveProgress( 0 ) +SfxProgress_Impl::SfxProgress_Impl( const String &/*rTitle*/ ) + : pActiveProgress( 0 ) { - SFX_APP()->GetCancelManager()->RemoveCancellable(this); } // ----------------------------------------------------------------------- @@ -183,21 +181,6 @@ SfxProgress::SfxProgress pImp->bRunning = TRUE; pImp->bAllowRescheduling = Application::IsInExecute();; - if ( pObjSh ) - { - for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pObjSh ) ) - { - pFrame->GetCancelManager()->InsertCancellable( pImp ); -/* - SfxBindings& rBindings = pFrame->GetBindings(); - rBindings.Invalidate( SID_BROWSE_STOP ); - if ( !rBindings.IsInRegistrations() ) - rBindings.Update( SID_BROWSE_STOP ); - rBindings.Invalidate( SID_BROWSE_STOP ); - */ - } - } - pImp->xObjSh = pObjSh; pImp->aText = rText; pImp->nMax = nRange; @@ -238,14 +221,6 @@ SfxProgress::~SfxProgress() if( pImp->bIsStatusText == TRUE ) GetpApp()->HideStatusText( ); - SfxObjectShell* pDoc = pImp->xObjSh; - if ( pDoc ) - { - for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDoc ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pDoc ) ) - pFrame->GetCancelManager()->RemoveCancellable( pImp );//Invalidate( SID_BROWSE_STOP ); - } - else - SFX_APP()->Invalidate( SID_BROWSE_STOP ); delete pImp; } @@ -387,8 +362,8 @@ BOOL SfxProgress::SetState { // wurde via Stop-Button angehalten? - if ( pImp->IsCancelled() ) - return FALSE; +// if ( pImp->IsCancelled() ) +// return FALSE; if( pImp->pActiveProgress ) return TRUE; diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index cef0af899a33..40f6346de8ee 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -68,7 +68,7 @@ #include <sfx2/unoctitm.hxx> #include <sfx2/sfx.hrc> #include <sfx2/sfxuno.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/objsh.hxx> #include <sfx2/msgpool.hxx> @@ -719,7 +719,7 @@ void SfxBindings::InvalidateAll pImp->pCaches->GetObject(n)->Invalidate(bWithMsg); /* ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame - ( pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY ); + ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); if ( bWithMsg && xFrame.is() ) xFrame->contextChanged(); @@ -1381,7 +1381,7 @@ void SfxBindings::UpdateSlotServer_Impl() if ( !nRegLevel ) { ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame - ( pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY ); + ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); //if ( xFrame.is() ) // xFrame->contextChanged(); pImp->bContextChanged = FALSE; @@ -1923,7 +1923,7 @@ void SfxBindings::LeaveRegistrations( sal_uInt16 nLevel, const char *pFile, int pImp->bContextChanged = FALSE; /* ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame - ( pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY ); + ( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); if ( xFrame.is() ) xFrame->contextChanged();*/ } @@ -2030,7 +2030,7 @@ void SfxBindings::SetDispatcher( SfxDispatcher *pDisp ) ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > xProv; if ( pDisp ) xProv = ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > - ( pDisp->GetFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY ); + ( pDisp->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY ); SetDispatchProvider_Impl( xProv ); InvalidateAll( sal_True ); @@ -2313,7 +2313,7 @@ void SfxBindings::SetActiveFrame( const ::com::sun::star::uno::Reference< ::com: SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > ( rFrame, ::com::sun::star::uno::UNO_QUERY ) ); else SetDispatchProvider_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > ( - pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ) ); + pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ) ); } const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxBindings::GetActiveFrame() const @@ -2322,7 +2322,7 @@ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxBin if ( xFrame.is() || !pDispatcher ) return xFrame; else - return pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(); + return pDispatcher->GetFrame()->GetFrame().GetFrameInterface(); } void SfxBindings::SetDispatchProvider_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > & rProv ) @@ -2349,8 +2349,8 @@ SystemWindow* SfxBindings::GetSystemWindow() const SfxViewFrame *pFrame = pDispatcher->GetFrame(); while ( pFrame->GetParentViewFrame_Impl() ) pFrame = pFrame->GetParentViewFrame_Impl(); - SfxTopViewFrame* pTop = PTR_CAST( SfxTopViewFrame, pFrame->GetTopViewFrame() ); - return pTop->GetTopFrame_Impl()->GetTopWindow_Impl(); + SfxViewFrame* pTop = pFrame->GetTopViewFrame(); + return pTop->GetFrame().GetTopWindow_Impl(); } BOOL SfxBindings::ExecuteCommand_Impl( const String& rCommand ) @@ -2374,7 +2374,7 @@ BOOL SfxBindings::ExecuteCommand_Impl( const String& rCommand ) xServiceManager->createInstance(our_aModuleManagerName) , ::com::sun::star::uno::UNO_QUERY_THROW); ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFrame > xFrame( - pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY_THROW); + pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), UNO_QUERY_THROW); sAppName = xModuleManager->identify(xFrame); } catch(::com::sun::star::uno::Exception&) {} Sequence<beans::PropertyValue> source; diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 7037edb00178..e66dd2c56eaf 100755..100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -76,7 +76,7 @@ #include <sfx2/docfac.hxx> #include <sfx2/msgpool.hxx> #include <sfx2/module.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include <sfx2/sfxuno.hxx> #include <sfx2/docfile.hxx> #include <sfx2/mnumgr.hxx> @@ -239,14 +239,13 @@ int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest SFX_STACK(SfxDispatcher::Call_Impl); // darf der Slot gerufen werden (i.S.v. enabled) - SfxApplication *pSfxApp = SFX_APP(); if ( rSlot.IsMode(SFX_SLOT_FASTCALL) || rShell.CanExecuteSlot_Impl(rSlot) ) { if ( GetFrame() ) { // ggf. Recording anwerfen com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( - GetFrame()->GetFrame()->GetFrameInterface(), + GetFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet( @@ -270,19 +269,6 @@ int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest // Alles holen, was gebraucht wird, da der Slot den Execute evtl. nicht // "uberlebt, falls es ein 'Pseudoslot' f"ur Macros oder Verben ist sal_Bool bAutoUpdate = rSlot.IsMode(SFX_SLOT_AUTOUPDATE); - SFX_REQUEST_ARG(rReq, pOrigItem, SfxExecuteItem, SID_SUBREQUEST, sal_False); - SfxExecuteItem *pExecuteItem = pOrigItem - ? (SfxExecuteItem*)pOrigItem->Clone() - : 0; - - // ggf. TabPage-ID setzen - SfxAppData_Impl *pAppData = pSfxApp->Get_Impl(); - SFX_REQUEST_ARG(rReq, pTabPageItem, SfxUInt16Item, SID_TABPAGE, sal_False); - if ( pTabPageItem ) - { - pAppData->nAutoTabPageId = pTabPageItem->GetValue(); - rReq.RemoveItem( SID_TABPAGE ); // sonst ArgCount > 0 => Seiteneff. - } // API-Call-Klammerung und Document-Lock w"ahrend des Calls { @@ -295,7 +281,7 @@ int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest if ( !pView ) pView = SfxViewFrame::Current(); if ( pView ) - SfxHelp::OpenHelpAgent( pView->GetFrame(), rReq.GetSlot() ); + SfxHelp::OpenHelpAgent( &pView->GetFrame(), rReq.GetSlot() ); SfxExecFunc pFunc = rSlot.GetExecFnc(); rShell.CallExec( pFunc, rReq ); @@ -316,16 +302,6 @@ int SfxDispatcher::Call_Impl( SfxShell& rShell, const SfxSlot &rSlot, SfxRequest } } - // TabPage-ID und Executing-SID zurueck setzen - if ( pTabPageItem ) - pAppData->nAutoTabPageId = 0; - - if( pExecuteItem ) - { - Execute( *pExecuteItem ); - delete pExecuteItem; - } - if ( rReq.IsDone() ) { SfxBindings *pBindings = GetBindings(); @@ -519,7 +495,7 @@ void SfxDispatcher::Pop SfxApplication *pSfxApp = SFX_APP(); #ifdef DBG_UTIL - ByteString aMsg( "SfxDispatcher(" ); + ByteString aMsg( "-SfxDispatcher(" ); aMsg += ByteString::CreateFromInt64( (sal_uIntPtr) this ); aMsg += bPush ? ")::Push(" : ")::Pop("; if ( rShell.GetInterface() ) @@ -527,6 +503,7 @@ void SfxDispatcher::Pop else aMsg += ByteString::CreateFromInt64( (sal_uIntPtr) &rShell ); aMsg += bDelete ? ") with delete" : ")"; + if ( bUntil ) aMsg += " (up to)"; DbgTrace( aMsg.GetBuffer() ); #endif @@ -797,7 +774,7 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ ) if ( pBindings ) { pBindings->SetDispatcher(this); - pBindings->SetActiveFrame( pImp->pFrame->GetFrame()->GetFrameInterface() ); + pBindings->SetActiveFrame( pImp->pFrame->GetFrame().GetFrameInterface() ); } } else @@ -817,7 +794,7 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ ) if ( bMDI && pImp->pFrame ) { - //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); SfxBindings *pBind = GetBindings(); while ( pBind ) { @@ -825,7 +802,7 @@ void SfxDispatcher::DoActivate_Impl( sal_Bool bMDI, SfxViewFrame* /* pOld */ ) pBind = pBind->GetSubBindings_Impl(); } - pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->HidePopups_Impl( FALSE, FALSE, 1 ); + pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( FALSE, FALSE, 1 ); } if ( pImp->aToDoStack.Count() ) @@ -883,7 +860,7 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) if ( pImp->pFrame && !(pImp->pFrame->GetObjectShell()->IsInPlaceActive() ) ) { - SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); if ( pWorkWin ) { for (sal_uInt16 n=0; n<pImp->aChildWins.Count();) @@ -911,10 +888,10 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) if ( pNew && pImp->pFrame ) { com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xOldFrame( - pNew->GetFrame()->GetFrameInterface()->getCreator(), com::sun::star::uno::UNO_QUERY ); + pNew->GetFrame().GetFrameInterface()->getCreator(), com::sun::star::uno::UNO_QUERY ); com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xMyFrame( - GetFrame()->GetFrame()->GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); + GetFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); if ( xOldFrame == xMyFrame ) bHidePopups = FALSE; @@ -922,7 +899,7 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) if ( bHidePopups ) { - //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + //SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); SfxBindings *pBind = GetBindings(); while ( pBind ) { @@ -930,7 +907,7 @@ void SfxDispatcher::DoDeactivate_Impl( sal_Bool bMDI, SfxViewFrame* pNew ) pBind = pBind->GetSubBindings_Impl(); } - pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->HidePopups_Impl( TRUE, FALSE, 1 ); + pImp->pFrame->GetFrame().GetWorkWindow_Impl()->HidePopups_Impl( TRUE, FALSE, 1 ); } Flush(); @@ -1673,13 +1650,13 @@ void SfxDispatcher::SetMenu_Impl() { if ( pImp->pFrame ) { - SfxTopViewFrame* pTop= PTR_CAST( SfxTopViewFrame, pImp->pFrame->GetTopViewFrame() ); + SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame(); if ( pTop && pTop->GetBindings().GetDispatcher() == this ) { - SfxTopFrame* pFrm = pTop->GetTopFrame_Impl(); - if ( pFrm->IsMenuBarOn_Impl() ) + SfxFrame& rFrame = pTop->GetFrame(); + if ( rFrame.IsMenuBarOn_Impl() ) { - com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( pFrm->GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); + com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); if ( xPropSet.is() ) { com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; @@ -1712,7 +1689,7 @@ long SfxDispatcher::Update_Impl( sal_Bool bForce ) sal_Bool bUpdate = bForce; while ( pDisp && pDisp->pImp->pFrame ) { - SfxWorkWindow *pWork = pDisp->pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWork = pDisp->pImp->pFrame->GetFrame().GetWorkWindow_Impl(); SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl(); if ( pAct == pDisp || pAct == this ) { @@ -1726,10 +1703,10 @@ long SfxDispatcher::Update_Impl( sal_Bool bForce ) pDisp = pDisp->pImp->pParent; } - if ( !bUpdate || pImp->pFrame->GetFrame()->IsClosing_Impl() ) + if ( !bUpdate || pImp->pFrame->GetFrame().IsClosing_Impl() ) return 0; - SfxTopViewFrame* pTop = pImp->pFrame ? PTR_CAST( SfxTopViewFrame, pImp->pFrame->GetTopViewFrame() ) : NULL; + SfxViewFrame* pTop = pImp->pFrame ? pImp->pFrame->GetTopViewFrame() : NULL; sal_Bool bUIActive = pTop && pTop->GetBindings().GetDispatcher() == this; if ( !bUIActive && pTop && GetBindings() == &pTop->GetBindings() ) @@ -1763,14 +1740,14 @@ long SfxDispatcher::Update_Impl( sal_Bool bForce ) if ( bUIActive && /* !bIsIPActive && */ ( !pClient || !pClient->IsObjectUIActive() ) ) SetMenu_Impl(); - SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); - SfxWorkWindow *pTaskWin = pImp->pFrame->GetTopFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); + SfxWorkWindow *pTaskWin = pImp->pFrame->GetTopFrame().GetWorkWindow_Impl(); pTaskWin->ResetStatusBar_Impl(); SfxDispatcher *pDispat = this; while ( pDispat ) { - SfxWorkWindow *pWork = pDispat->pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWork = pDispat->pImp->pFrame->GetFrame().GetWorkWindow_Impl(); SfxDispatcher *pAct = pWork->GetBindings().GetDispatcher_Impl(); if ( pAct == pDispat || pAct == this ) { @@ -1808,7 +1785,7 @@ sal_uInt32 SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, { sal_uInt32 nHelpId = 0; SFX_APP(); - SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWorkWin = pImp->pFrame->GetFrame().GetWorkWindow_Impl(); sal_Bool bIsActive = sal_False; sal_Bool bIsTaskActive = sal_False; SfxDispatcher *pActDispat = pWorkWin->GetBindings().GetDispatcher_Impl(); @@ -1970,7 +1947,7 @@ sal_uInt32 SfxDispatcher::_Update_Impl( sal_Bool bUIActive, sal_Bool bIsMDIApp, { // internal frames also may control statusbar SfxBindings& rBindings = pImp->pFrame->GetBindings(); - pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->SetStatusBar_Impl( nStatBarId, pStatusBarShell, rBindings ); + pImp->pFrame->GetFrame().GetWorkWindow_Impl()->SetStatusBar_Impl( nStatBarId, pStatusBarShell, rBindings ); } } @@ -2247,7 +2224,7 @@ sal_Bool SfxDispatcher::_TryIntercept_Impl sal_uInt16 nLevels = pImp->aStack.Count(); while ( pParent && pParent->pImp->pFrame ) { - if ( pParent->pImp->pFrame->GetFrame()->HasComponent() ) + if ( pParent->pImp->pFrame->GetFrame().HasComponent() ) { // Components d"urfen intercepten if ( pParent->_TryIntercept_Impl( nSlot, rServer, sal_True ) ) @@ -2321,7 +2298,7 @@ sal_Bool SfxDispatcher::_FindServer { SFX_STACK(SfxDispatcher::_FindServer); - // Dispatcher gelockt? (SID_BROWSE_STOP und SID_HELP_PI trotzdem durchlassen) + // Dispatcher gelockt? (SID_HELP_PI trotzdem durchlassen) SfxApplication *pSfxApp = SFX_APP(); if ( IsLocked(nSlot) ) { @@ -2741,7 +2718,7 @@ SfxPopupMenuManager* SfxDispatcher::Popup( sal_uInt16 nConfigId,Window *pWin, co nShLevel = rDisp.pImp->aStack.Count(); } - Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->GetWindow(); + Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow(); for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) ) { const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId(); @@ -2781,7 +2758,7 @@ void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Poin nShLevel = rDisp.pImp->aStack.Count(); } - Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->GetWindow(); + Window *pWindow = pWin ? pWin : rDisp.pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow(); for ( pSh = rDisp.GetShell(nShLevel); pSh; ++nShLevel, pSh = rDisp.GetShell(nShLevel) ) { const ResId& rResId = pSh->GetInterface()->GetPopupMenuResId(); @@ -2804,7 +2781,7 @@ void SfxDispatcher::ExecutePopup( sal_uInt16 nConfigId, Window *pWin, const Poin //---------------------------------------------------------------------- void SfxDispatcher::ExecutePopup( const ResId &rId, Window *pWin, const Point *pPos ) { - Window *pWindow = pWin ? pWin : pImp->pFrame->GetFrame()->GetWorkWindow_Impl()->GetWindow(); + Window *pWindow = pWin ? pWin : pImp->pFrame->GetFrame().GetWorkWindow_Impl()->GetWindow(); /* SfxPopupMenuManager aPop( rId, *GetBindings() ); aPop.AddClipboardFunctions(); @@ -2908,13 +2885,13 @@ void SfxDispatcher::HideUI( sal_Bool bHide ) pImp->bNoUI = bHide; if ( pImp->pFrame ) { - SfxTopViewFrame* pTop= PTR_CAST( SfxTopViewFrame, pImp->pFrame->GetTopViewFrame() ); + SfxViewFrame* pTop = pImp->pFrame->GetTopViewFrame(); if ( pTop && pTop->GetBindings().GetDispatcher() == this ) { - SfxTopFrame* pFrm = pTop->GetTopFrame_Impl(); - if ( pFrm->IsMenuBarOn_Impl() ) + SfxFrame& rFrame = pTop->GetFrame(); + if ( rFrame.IsMenuBarOn_Impl() ) { - com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( pFrm->GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); + com::sun::star::uno::Reference < com::sun::star::beans::XPropertySet > xPropSet( rFrame.GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); if ( xPropSet.is() ) { com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; @@ -3157,27 +3134,6 @@ void SfxDispatcher::InvalidateBindings_Impl( sal_Bool bModify ) pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) ) pFrame->GetBindings().InvalidateAll(bModify); -/* - // alle Bindings sind betroffen - for ( SfxInPlaceFrame *pIPFrame = (SfxInPlaceFrame*) - SfxViewFrame::GetFirst(0, TYPE(SfxInPlaceFrame)); - pIPFrame; - pIPFrame = (SfxInPlaceFrame*) - SfxViewFrame::GetNext(*pIPFrame, 0, TYPE(SfxInPlaceFrame)) ) - pIPFrame->GetBindings().InvalidateAll(bModify); - - for ( SfxPlugInFrame *pPIFrame = (SfxPlugInFrame*) - SfxViewFrame::GetFirst(0, TYPE(SfxPlugInFrame)); - pPIFrame; - pPIFrame = (SfxPlugInFrame*) - SfxViewFrame::GetNext(*pPIFrame, 0, TYPE(SfxPlugInFrame)) ) - pPIFrame->GetBindings().InvalidateAll(bModify); - - for ( SfxTask* pTask = SfxTask::GetFirst(); pTask; - pTask = SfxTask::GetNext( *pTask ) ) - if ( !pTask->IsExternal() ) - pTask->GetBindings()->InvalidateAll(bModify); -*/ } else { diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx index 9758f7e4d051..88a52d0ad0bf 100644 --- a/sfx2/source/control/request.cxx +++ b/sfx2/source/control/request.cxx @@ -866,7 +866,7 @@ com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > SfxRe com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder; com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet( - (pView ? pView : SfxViewFrame::Current())->GetFrame()->GetFrameInterface(), + (pView ? pView : SfxViewFrame::Current())->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); if(xSet.is()) diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx index baddd81ce4a1..3fdd14369856 100644 --- a/sfx2/source/control/statcach.cxx +++ b/sfx2/source/control/statcach.cxx @@ -342,7 +342,7 @@ const SfxSlotServer* SfxStateCache::GetSlotServer( SfxDispatcher &rDispat , cons else if ( rDispat.GetFrame() ) { ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > xFrameProv( - rDispat.GetFrame()->GetFrame()->GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); + rDispat.GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); if ( xFrameProv != xProv ) return GetSlotServer( rDispat, xFrameProv ); } diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 0e3209f6a05a..d2ad8c645eb7 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -217,8 +217,8 @@ void SfxUnoControllerItem::GetNewDispatch() if ( !pBindings->GetDispatcher_Impl() || !pBindings->GetDispatcher_Impl()->GetFrame() ) return; - SfxFrame *pFrame = pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(); - SfxFrame *pParent = pFrame->GetParentFrame(); + SfxFrame& rFrame = pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(); + SfxFrame *pParent = rFrame.GetParentFrame(); if ( pParent ) // parent may intercept xDispatch = TryGetDispatch( pParent ); @@ -226,7 +226,7 @@ void SfxUnoControllerItem::GetNewDispatch() if ( !xDispatch.is() ) { // no interception - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pFrame->GetFrameInterface(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = rFrame.GetFrameInterface(); ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY ); if ( xProv.is() ) xDispatch = xProv->queryDispatch( aCommand, ::rtl::OUString(), 0 ); @@ -250,7 +250,7 @@ void SfxUnoControllerItem::GetNewDispatch() if ( !xDisp.is() && pFrame->HasComponent() ) { // no interception - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pFrame->GetFrameInterface(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame = pFrame->GetFrameInterface(); ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY ); if ( xProv.is() ) xDisp = xProv->queryDispatch( aCommand, ::rtl::OUString(), 0 ); @@ -752,11 +752,11 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util { SfxViewFrame* pViewFrame = pDispatcher->GetFrame(); if (pViewFrame) - xFrameRef = pViewFrame->GetFrame()->GetFrameInterface(); + xFrameRef = pViewFrame->GetFrame().GetFrameInterface(); } SfxAllItemSet aInternalSet( SFX_APP()->GetPool() ); if (xFrameRef.is()) // an empty set is no problem ... but an empty frame reference can be a problem ! - aInternalSet.Put( SfxUnoAnyItem( SID_FILLFRAME, css::uno::makeAny(xFrameRef) ) ); + aInternalSet.Put( SfxUnoFrameItem( SID_FILLFRAME, xFrameRef ) ); sal_Bool bSuccess = sal_False; sal_Bool bFailure = sal_False; diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx index 1b15903392ba..2ea5ef5fe4b1 100644 --- a/sfx2/source/dialog/basedlgs.cxx +++ b/sfx2/source/dialog/basedlgs.cxx @@ -426,7 +426,7 @@ long SfxModelessDialog::Notify( NotifyEvent& rEvt ) } if ( nHelpId ) - SfxHelp::OpenHelpAgent( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); + SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); } else if ( rEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() ) { @@ -528,7 +528,7 @@ long SfxFloatingWindow::Notify( NotifyEvent& rEvt ) } if ( nHelpId ) - SfxHelp::OpenHelpAgent( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); + SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); } else if ( rEvt.GetType() == EVENT_LOSEFOCUS ) { diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 041b397d3c92..7b4e4289a49c 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -161,7 +161,7 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd , if (xFactoryMgr.is()) { SfxDispatcher* pDispatcher = pBindings->GetDispatcher(); - uno::Reference< frame::XFrame > xFrame( pDispatcher->GetFrame()->GetFrame()->GetFrameInterface(), uno::UNO_QUERY ); + uno::Reference< frame::XFrame > xFrame( pDispatcher->GetFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); uno::Sequence< uno::Any > aArgs(2); beans::PropertyValue aPropValue; aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); @@ -1852,7 +1852,7 @@ long SfxDockingWindow::Notify( NotifyEvent& rEvt ) } if ( nHelpId ) - SfxHelp::OpenHelpAgent( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); + SfxHelp::OpenHelpAgent( &pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame(), nHelpId ); // In VCL geht Notify zun"achst an das Fenster selbst, // also base class rufen, sonst erf"ahrt der parent nichts diff --git a/sfx2/source/dialog/mailmodelapi.cxx b/sfx2/source/dialog/mailmodelapi.cxx index eb6bd2774419..16d12f469205 100644 --- a/sfx2/source/dialog/mailmodelapi.cxx +++ b/sfx2/source/dialog/mailmodelapi.cxx @@ -328,14 +328,6 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocument( const ::rtl::OUString& _sAt // save the document if ( xMod.is() ) { - // save old settings -/* - BOOL bModified = xMod->isModified(); - // prepare for mail export - TODO - SfxDispatcher* pDisp = pTopViewFrm->GetDispatcher(); - pDisp->Execute( SID_MAIL_PREPAREEXPORT, SFX_CALLMODE_SYNCHRON ); -*/ // detect filter const SfxFilter* pFilter = SfxFilter::GetDefaultFilter(lcl_getFactoryName(_xModel)); // sal_Bool bHasFilter = pFilter != NULL; @@ -432,14 +424,6 @@ SfxMailModel::SaveResult SfxMailModel::SaveDocAsPDF( const ::rtl::OUString& _sAt // save the document if ( xMod.is() ) { - /* TODO - // save old settings - BOOL bModified = xMod->isModified(); - // prepare for mail export - SfxDispatcher* pDisp = pTopViewFrm->GetDispatcher(); - pDisp->Execute( SID_MAIL_PREPAREEXPORT, SFX_CALLMODE_SYNCHRON ); - */ - // Get PDF Filter from document ::rtl::OUString sPDFMediaType(RTL_CONSTASCII_USTRINGPARAM("application/pdf")); diff --git a/sfx2/source/dialog/partwnd.cxx b/sfx2/source/dialog/partwnd.cxx index d6a4c05baf69..cbbe20bfa203 100644 --- a/sfx2/source/dialog/partwnd.cxx +++ b/sfx2/source/dialog/partwnd.cxx @@ -178,7 +178,7 @@ SfxPartDockWnd_Impl::SfxPartDockWnd_Impl if ( pBind->GetDispatcher() ) { ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier > - xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame()->GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); + xSupp ( pBind->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); if ( xSupp.is() ) xSupp->getFrames()->append( xFrame ); } diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 6737e8c0ffa3..93c2e0e09595 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -1788,7 +1788,7 @@ long SfxTabDialog::Notify( NotifyEvent& rNEvt ) } if ( nHelpId ) - SfxHelp::OpenHelpAgent( pViewFrame->GetFrame(), nHelpId ); + SfxHelp::OpenHelpAgent( &pViewFrame->GetFrame(), nHelpId ); } } diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx index 1aac4ff97ec3..48c01a1ac3fe 100644 --- a/sfx2/source/doc/docfac.cxx +++ b/sfx2/source/doc/docfac.cxx @@ -284,6 +284,14 @@ const SvGlobalName& SfxObjectFactory::GetClassId() const return pImpl->aClassName; } +String SfxObjectFactory::GetFactoryURL() const +{ + ::rtl::OUStringBuffer aURLComposer; + aURLComposer.appendAscii( "private:factory/" ); + aURLComposer.appendAscii( GetShortName() ); + return aURLComposer.makeStringAndClear(); +} + String SfxObjectFactory::GetModuleName() const { static ::rtl::OUString SERVICENAME_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager"); @@ -302,10 +310,36 @@ String SfxObjectFactory::GetModuleName() const ::rtl::OUString sModuleName = aPropSet.getUnpackedValueOrDefault(PROP_MODULEUINAME, ::rtl::OUString()); return String(sModuleName); } - catch(const css::uno::RuntimeException& exRun) - { throw exRun; } + catch(const css::uno::RuntimeException&) + { throw; } catch(const css::uno::Exception&) {} return String(); } + + +sal_uInt16 SfxObjectFactory::GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const +{ + for ( sal_uInt16 curViewNo = 0; curViewNo < GetViewFactoryCount(); ++curViewNo ) + { + const sal_uInt16 curViewId = GetViewFactory( curViewNo ).GetOrdinal(); + if ( i_nViewId == curViewId ) + return curViewNo; + } + return i_nFallback; +} + +SfxViewFactory* SfxObjectFactory::GetViewFactoryByViewName( const String& i_rViewName ) const +{ + for ( USHORT nViewNo = 0; + nViewNo < GetViewFactoryCount(); + ++nViewNo + ) + { + SfxViewFactory& rViewFac( GetViewFactory( nViewNo ) ); + if ( rViewFac.GetViewName() == i_rViewName ) + return &rViewFac; + } + return NULL; +} diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 0b535088b0bd..6696b7670c63 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -260,79 +260,6 @@ void SAL_CALL SfxMediumHandler_Impl::handle( const com::sun::star::uno::Referenc } //---------------------------------------------------------------- -class SfxPoolCancelManager_Impl : public SfxCancelManager , - public SfxCancellable , - public SfxListener , - public SvRefBase -{ - SfxCancelManagerWeak wParent; - - ~SfxPoolCancelManager_Impl(); -public: - SfxPoolCancelManager_Impl( SfxCancelManager* pParent, const String& rName ); - - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - using SfxCancelManager::Cancel; - virtual void Cancel(); -}; - -//---------------------------------------------------------------- -SV_DECL_IMPL_REF( SfxPoolCancelManager_Impl ) - - -//---------------------------------------------------------------- -SfxPoolCancelManager_Impl::SfxPoolCancelManager_Impl( SfxCancelManager* pParent, const String& rName ) - : SfxCancelManager( pParent ), - SfxCancellable( pParent ? pParent : this, rName ), - wParent( pParent ) -{ - if( pParent ) - { - StartListening( *this ); - SetManager( 0 ); - } -} - -//---------------------------------------------------------------- -SfxPoolCancelManager_Impl::~SfxPoolCancelManager_Impl() -{ - for( sal_uInt16 nPos = GetCancellableCount(); nPos--; ) - { - // nicht an Parent uebernehmen! - SfxCancellable* pCbl = GetCancellable( nPos ); - if ( pCbl ) - pCbl->SetManager( 0 ); - } -} - - -//---------------------------------------------------------------- -void SfxPoolCancelManager_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/ ) -{ - if( !GetCancellableCount() ) SetManager( 0 ); - else if( !GetManager() ) - { - if( !wParent.Is() ) wParent = SFX_APP()->GetCancelManager(); - SetManager( wParent ); - } -} - -//---------------------------------------------------------------- -void SfxPoolCancelManager_Impl::Cancel() -{ - SfxPoolCancelManager_ImplRef xThis = this; - for( sal_uInt16 nPos = GetCancellableCount(); nPos--; ) - { - SfxCancellable* pCbl = GetCancellable( nPos ); - // Wenn wir nicht im Button stehen - if( pCbl && pCbl != this ) - pCbl->Cancel(); - if( GetCancellableCount() < nPos ) - nPos = GetCancellableCount(); - } -} - -//---------------------------------------------------------------- class SfxMedium_Impl : public SvCompatWeakBase { public: @@ -340,7 +267,6 @@ public: sal_Bool bUpdatePickList : 1; sal_Bool bIsTemp : 1; sal_Bool bForceSynchron : 1; - sal_Bool bDontCreateCancellable : 1; sal_Bool bDownloadDone : 1; sal_Bool bDontCallDoneLinkOnSharingError : 1; sal_Bool bIsStorage: 1; @@ -356,7 +282,6 @@ public: uno::Reference < embed::XStorage > xStorage; - SfxPoolCancelManager_ImplRef xCancelManager; SfxMedium* pAntiImpl; long nFileVersion; @@ -399,8 +324,6 @@ public: uno::Reference< logging::XSimpleLogRing > m_xLogRing; - SfxPoolCancelManager_Impl* GetCancelManager(); - SfxMedium_Impl( SfxMedium* pAntiImplP ); ~SfxMedium_Impl(); }; @@ -416,29 +339,12 @@ void SfxMedium::Cancel_Impl() SetError( ERRCODE_IO_GENERAL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); } -SfxPoolCancelManager_Impl* SfxMedium_Impl::GetCancelManager() -{ - if( !xCancelManager.Is() ) - { - if( !bDontCreateCancellable ) - xCancelManager = new SfxPoolCancelManager_Impl( - wLoadTargetFrame ? wLoadTargetFrame->GetCancelManager() : - SFX_APP()->GetCancelManager(), - pAntiImpl->GetURLObject().GetURLNoPass() ); - else - xCancelManager = new SfxPoolCancelManager_Impl( - 0, pAntiImpl->GetURLObject().GetURLNoPass() ); - } - return xCancelManager; -} - //------------------------------------------------------------------ SfxMedium_Impl::SfxMedium_Impl( SfxMedium* pAntiImplP ) : SvCompatWeakBase( pAntiImplP ), bUpdatePickList(sal_True), bIsTemp( sal_False ), bForceSynchron( sal_False ), - bDontCreateCancellable( sal_False ), bDownloadDone( sal_True ), bDontCallDoneLinkOnSharingError( sal_False ), bIsStorage( sal_False ), @@ -2439,25 +2345,7 @@ void SfxMedium::GetMedium_Impl() } } -//------------------------------------------------------------------ -SfxPoolCancelManager_Impl* SfxMedium::GetCancelManager_Impl() const -{ - return pImp->GetCancelManager(); -} - -//------------------------------------------------------------------ -void SfxMedium::SetCancelManager_Impl( SfxPoolCancelManager_Impl* pMgr ) -{ - pImp->xCancelManager = pMgr; -} - //---------------------------------------------------------------- -void SfxMedium::CancelTransfers() -{ - if( pImp->xCancelManager.Is() ) - pImp->xCancelManager->Cancel(); -} - sal_Bool SfxMedium::IsRemote() { return bRemote; @@ -3286,13 +3174,6 @@ sal_Bool SfxMedium::IsDownloadDone_Impl() return pImp->bDownloadDone; } -//---------------------------------------------------------------- - -void SfxMedium::SetDontCreateCancellable( ) -{ - pImp->bDontCreateCancellable = sal_True; -} - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SfxMedium::GetInputStream() { if ( !pImp->xInputStream.is() ) diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 75509e0b5323..e73594af1e10 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -47,8 +47,8 @@ #include <svl/eitem.hxx> #include <svl/urihelper.hxx> #include <svl/ctloptions.hxx> -#include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/processfactory.hxx> #include <unotools/securityoptions.hxx> #include <svtools/sfxecode.hxx> #include <svtools/ehdl.hxx> @@ -74,7 +74,7 @@ #include "sfxhelp.hxx" #include <sfx2/dispatch.hxx> #include <sfx2/printer.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "basmgr.hxx" #include <sfx2/doctempl.hxx> #include "doc.hrc" @@ -89,9 +89,6 @@ using namespace ::com::sun::star::uno; //==================================================================== -#define SFX_WINDOWS_STREAM "SfxWindows" -#define SFX_PREVIEW_STREAM "SfxPreview" - //==================================================================== static @@ -189,252 +186,6 @@ SfxObjectShell::CreatePreviewMetaFile_Impl( sal_Bool bFullContent, sal_Bool bHig return pFile; } -//REMOVE FASTBOOL SfxObjectShell::SaveWindows_Impl( SvStorage &rStor ) const -//REMOVE { -//REMOVE SvStorageStreamRef xStream = rStor.OpenStream( DEFINE_CONST_UNICODE( SFX_WINDOWS_STREAM ), -//REMOVE STREAM_TRUNC | STREAM_STD_READWRITE); -//REMOVE if ( !xStream ) -//REMOVE return FALSE; -//REMOVE -//REMOVE xStream->SetBufferSize(1024); -//REMOVE xStream->SetVersion( rStor.GetVersion() ); -//REMOVE -//REMOVE // "uber alle Fenster iterieren (aber aktives Window zuletzt) -//REMOVE SfxViewFrame *pActFrame = SfxViewFrame::Current(); -//REMOVE if ( !pActFrame || pActFrame->GetObjectShell() != this ) -//REMOVE pActFrame = SfxViewFrame::GetFirst(this); -//REMOVE -//REMOVE String aActWinData; -//REMOVE for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame) ); pFrame; -//REMOVE pFrame = SfxViewFrame::GetNext(*pFrame, this, TYPE(SfxTopViewFrame) ) ) -//REMOVE { -//REMOVE // Bei Dokumenten, die Outplace aktiv sind, kann beim Speichern auch schon die View weg sein! -//REMOVE if ( pFrame->GetViewShell() ) -//REMOVE { -//REMOVE SfxTopFrame* pTop = (SfxTopFrame*) pFrame->GetFrame(); -//REMOVE pTop->GetTopWindow_Impl(); -//REMOVE -//REMOVE char cToken = ','; -//REMOVE const BOOL bActWin = pActFrame == pFrame; -//REMOVE String aUserData; -//REMOVE pFrame->GetViewShell()->WriteUserData(aUserData); -//REMOVE -//REMOVE // assemble ini-data -//REMOVE String aWinData; -//REMOVE aWinData += String::CreateFromInt32( pFrame->GetCurViewId() ); -//REMOVE aWinData += cToken; -//REMOVE /* -//REMOVE if ( !pWin || pWin->IsMaximized() ) -//REMOVE aWinData += SFX_WINSIZE_MAX; -//REMOVE else if ( pWin->IsMinimized() ) -//REMOVE aWinData += SFX_WINSIZE_MIN; -//REMOVE else -//REMOVE */ -//REMOVE aWinData += cToken; -//REMOVE aWinData += aUserData; -//REMOVE -//REMOVE // aktives kennzeichnen -//REMOVE aWinData += cToken; -//REMOVE aWinData += bActWin ? '1' : '0'; -//REMOVE -//REMOVE // je nachdem merken oder abspeichern -//REMOVE if ( bActWin ) -//REMOVE aActWinData = aWinData; -//REMOVE else -//REMOVE xStream->WriteByteString( aWinData ); -//REMOVE } -//REMOVE } -//REMOVE -//REMOVE // aktives Window hinterher -//REMOVE xStream->WriteByteString( aActWinData ); -//REMOVE return !xStream->GetError(); -//REMOVE } - -//==================================================================== - -SfxViewFrame* SfxObjectShell::LoadWindows_Impl( SfxTopFrame *pPreferedFrame ) -{ - DBG_ASSERT( pPreferedFrame, "Call without preferred Frame is not supported anymore!" ); - if ( pImp->bLoadingWindows || !pPreferedFrame ) - return NULL; - - DBG_ASSERT( GetMedium(), "A Medium should exist here!"); - if( !GetMedium() ) - return 0; - - // get correct mode - SFX_APP(); - SfxViewFrame *pPrefered = pPreferedFrame ? pPreferedFrame->GetCurrentViewFrame() : 0; - SvtSaveOptions aOpt; - BOOL bLoadDocWins = aOpt.IsSaveDocWins() && !pPrefered; - - // try to get viewdata information for XML format - REFERENCE < XVIEWDATASUPPLIER > xViewDataSupplier( GetModel(), ::com::sun::star::uno::UNO_QUERY ); - REFERENCE < XINDEXACCESS > xViewData; - - if ( xViewDataSupplier.is() ) - { - xViewData = xViewDataSupplier->getViewData(); - if ( !xViewData.is() ) - return NULL; - } - else - return NULL; - - SfxViewFrame *pActiveFrame = 0; - String aWinData; - SfxItemSet *pSet = GetMedium()->GetItemSet(); - - pImp->bLoadingWindows = TRUE; - BOOL bLoaded = FALSE; - sal_Int32 nView = 0; - - // get saved information for all views - while ( TRUE ) - { - USHORT nViewId = 0; - FASTBOOL bMaximized=FALSE; - String aPosSize; - String aUserData; // used in the binary format - SEQUENCE < PROPERTYVALUE > aSeq; // used in the XML format - - // XML format - // active view is the first view in the container - FASTBOOL bActive = ( nView == 0 ); - - if ( nView == xViewData->getCount() ) - // finished - break; - - // get viewdata and look for the stored ViewId - ::com::sun::star::uno::Any aAny = xViewData->getByIndex( nView++ ); - if ( aAny >>= aSeq ) - { - for ( sal_Int32 n=0; n<aSeq.getLength(); n++ ) - { - const PROPERTYVALUE& rProp = aSeq[n]; - if ( rProp.Name.compareToAscii("ViewId") == COMPARE_EQUAL ) - { - ::rtl::OUString aId; - rProp.Value >>= aId; - String aTmp( aId ); - aTmp.Erase( 0, 4 ); // format is like in "view3" - nViewId = (USHORT) aTmp.ToInt32(); - break; - } - } - } - - // load only active view, but current item is not the active one ? - // in XML format the active view is the first one - if ( !bLoadDocWins && !bActive ) - break; - - // check for minimized/maximized/size - if ( aPosSize.EqualsAscii( "max" ) ) - bMaximized = TRUE; - else if ( aPosSize.EqualsAscii( "min" ) ) - { - bMaximized = TRUE; - bActive = FALSE; - } - else - bMaximized = FALSE; - - Point aPt; - Size aSz; - - pSet->ClearItem( SID_USER_DATA ); - SfxViewFrame *pFrame = 0; - if ( pPrefered ) - { - // use the frame from the arguments, but don't set a window size - pFrame = pPrefered; - if ( pFrame->GetViewShell() || !pFrame->GetObjectShell() ) - { - pSet->ClearItem( SID_VIEW_POS_SIZE ); - pSet->ClearItem( SID_WIN_POSSIZE ); - pSet->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) ); - - // avoid flickering controllers - SfxBindings &rBind = pFrame->GetBindings(); - rBind.ENTERREGISTRATIONS(); - - // set document into frame - pPreferedFrame->InsertDocument( this ); - - // restart controller updating - rBind.LEAVEREGISTRATIONS(); - } - else - { - // create new view - pFrame->CreateView_Impl( nViewId ); - } - } - else - { - if ( bLoadDocWins ) - { - // open in the background - pSet->Put( SfxUInt16Item( SID_VIEW_ZOOM_MODE, 0 ) ); - if ( !bMaximized ) - pSet->Put( SfxRectangleItem( SID_VIEW_POS_SIZE, Rectangle( aPt, aSz ) ) ); - } - - pSet->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) ); - - if ( pPreferedFrame ) - { - // Frame "ubergeben, allerdings ist der noch leer - pPreferedFrame->InsertDocument( this ); - pFrame = pPreferedFrame->GetCurrentViewFrame(); - } - else - { - pFrame = SfxTopFrame::Create( this, nViewId, FALSE, pSet )->GetCurrentViewFrame(); - } - - // only temporary data, don't hold it in the itemset - pSet->ClearItem( SID_VIEW_POS_SIZE ); - pSet->ClearItem( SID_WIN_POSSIZE ); - pSet->ClearItem( SID_VIEW_ZOOM_MODE ); - } - - bLoaded = TRUE; - - // UserData hier einlesen, da es ansonsten immer mit bBrowse=TRUE - // aufgerufen wird, beim Abspeichern wurde aber bBrowse=FALSE verwendet - if ( pFrame && pFrame->GetViewShell() ) - { - if ( aUserData.Len() ) - pFrame->GetViewShell()->ReadUserData( aUserData, !bLoadDocWins ); - else if ( aSeq.getLength() ) - pFrame->GetViewShell()->ReadUserDataSequence( aSeq, !bLoadDocWins ); - } - - // perhaps there are more windows to load - pPreferedFrame = NULL; - - if ( bActive ) - pActiveFrame = pFrame; - - if( pPrefered || !bLoadDocWins ) - // load only active window - break; - } - - if ( pActiveFrame ) - { - if ( !pPrefered ) - // activate frame - pActiveFrame->MakeActive_Impl( TRUE ); - } - - pImp->bLoadingWindows = FALSE; - return pPrefered && bLoaded ? pPrefered : pActiveFrame; -} - //==================================================================== void SfxObjectShell::UpdateDocInfoForSave() diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx index d88fdefdfa2a..1c2105c210b9 100644 --- a/sfx2/source/doc/objembed.cxx +++ b/sfx2/source/doc/objembed.cxx @@ -305,7 +305,7 @@ void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev, comphelper::EmbeddedObjectContainer& SfxObjectShell::GetEmbeddedObjectContainer() const { if ( !pImp->mpObjectContainer ) - pImp->mpObjectContainer = new comphelper::EmbeddedObjectContainer( ((SfxObjectShell*)this)->GetStorage(), pImp->xModel ); + pImp->mpObjectContainer = new comphelper::EmbeddedObjectContainer( ((SfxObjectShell*)this)->GetStorage(), GetModel() ); return *pImp->mpObjectContainer; } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 1cb88e98f59f..7d931cb6c640 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -84,7 +84,7 @@ #include <comphelper/configurationhelper.hxx> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> -#include <com/sun/star/task/DocumentMacroConfirmationRequest2.hpp> +#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp> #include <com/sun/star/task/InteractionClassification.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -405,17 +405,11 @@ void SfxObjectShell::ModifyChanged() return; {DBG_CHKTHIS(SfxObjectShell, 0);} - SfxObjectShell *pDoc; - for ( pDoc = SfxObjectShell::GetFirst(); pDoc; - pDoc = SfxObjectShell::GetNext(*pDoc) ) - if( pDoc->IsModified() ) - break; SfxViewFrame* pViewFrame = SfxViewFrame::Current(); if ( pViewFrame ) pViewFrame->GetBindings().Invalidate( SID_SAVEDOCS ); - Invalidate( SID_SIGNATURE ); Invalidate( SID_MACRO_SIGNATURE ); Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); // xmlsec05, signed state might change in title... @@ -1134,7 +1128,7 @@ void SfxObjectShell::SetProgress_Impl void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame* pFrame ) { SfxApplication* pSfxApp = SFX_APP(); - if ( !pSfxApp->IsDowning() && !IsLoading() && pFrame && !pFrame->GetFrame()->IsClosing_Impl() ) + if ( !pSfxApp->IsDowning() && !IsLoading() && pFrame && !pFrame->GetFrame().IsClosing_Impl() ) { SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False ); if ( !pHiddenItem || !pHiddenItem->GetValue() ) @@ -1165,7 +1159,6 @@ void SfxObjectShell::RegisterTransfer( SfxMedium& rMedium ) laden, muessen an der zugehoerigen SfxObjectShell angemeldet werden. So kann dokumentweise abgebrochen werden. */ { - rMedium.SetCancelManager_Impl( GetMedium()->GetCancelManager_Impl() ); rMedium.SetReferer( GetMedium()->GetName() ); } @@ -1437,8 +1430,7 @@ void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags ) } } - pImp->bInitialized = sal_True; - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); + SetInitialized_Impl( false ); // Title is not available until loading has finished Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); @@ -1557,7 +1549,7 @@ void SfxObjectShell::PositionView_Impl() sal_Bool SfxObjectShell::IsLoading() const /* [Beschreibung ] - Wurde bereits FinishedLoading aufgerufeb? */ + Has FinishedLoading been called? */ { return !( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ); } @@ -1569,7 +1561,6 @@ void SfxObjectShell::CancelTransfers() Hier koennen Transfers gecanceled werden, die nicht mit RegisterTransfer registiert wurden */ { - GetMedium()->CancelTransfers(); if( ( pImp->nLoadedFlags & SFX_LOADED_ALL ) != SFX_LOADED_ALL ) { AbortImport(); @@ -2028,12 +2019,6 @@ void SfxObjectShell::SetHeaderAttributesForSourceViewHack() ->SetAttributes(); } -void SfxObjectShell::StartLoading_Impl() -{ - pImp->nLoadedFlags = 0; - pImp->bModelInitialized = sal_False; -} - sal_Bool SfxObjectShell::IsPreview() const { if ( !pMedium ) @@ -2109,9 +2094,9 @@ void SfxObjectShell::SetWaitCursor( BOOL bSet ) const for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) ) { if ( bSet ) - pFrame->GetFrame()->GetWindow().EnterWait(); + pFrame->GetFrame().GetWindow().EnterWait(); else - pFrame->GetFrame()->GetWindow().LeaveWait(); + pFrame->GetFrame().GetWindow().LeaveWait(); } } @@ -2149,13 +2134,11 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium ) { Window* pWindow = 0; SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet(); - SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoAnyItem, SID_FILLFRAME, FALSE ); + SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE ); if ( pUnoItem ) { - uno::Reference < frame::XFrame > xFrame; - pUnoItem->GetValue() >>= xFrame; - if ( xFrame.is() ) - pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + uno::Reference < frame::XFrame > xFrame( pUnoItem->GetFrame() ); + pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); } if ( !pWindow ) @@ -2173,7 +2156,7 @@ Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium ) // get any visible frame pView = SfxViewFrame::GetFirst(this); if ( pView ) - pFrame = pView->GetFrame(); + pFrame = &pView->GetFrame(); } if ( pFrame ) @@ -2242,7 +2225,7 @@ BOOL SfxObjectShell::IsInPlaceActive() return FALSE; SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); - return pFrame && pFrame->GetFrame()->IsInPlace(); + return pFrame && pFrame->GetFrame().IsInPlace(); } BOOL SfxObjectShell::IsUIActive() @@ -2251,7 +2234,7 @@ BOOL SfxObjectShell::IsUIActive() return FALSE; SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); - return pFrame && pFrame->GetFrame()->IsInPlace() && pFrame->GetFrame()->GetWorkWindow_Impl()->IsVisible_Impl(); + return pFrame && pFrame->GetFrame().IsInPlace() && pFrame->GetFrame().GetWorkWindow_Impl()->IsVisible_Impl(); } void SfxObjectShell::UIActivate( BOOL ) @@ -2455,9 +2438,9 @@ sal_Bool SfxObjectShell_Impl::hasTrustedScriptingSignature( sal_Bool bAllowUIToA if ( xInteraction.is() ) { - task::DocumentMacroConfirmationRequest2 aRequest; + task::DocumentMacroConfirmationRequest aRequest; aRequest.DocumentURL = getDocumentLocation(); - aRequest.DocumentZipStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl(); + aRequest.DocumentStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl(); aRequest.DocumentSignatureInformation = aInfo; aRequest.DocumentVersion = aVersion; aRequest.Classification = task::InteractionClassification_QUERY; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index a3c20411d1fc..c063546da1c7 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -85,7 +85,7 @@ #include "sfxtypes.hxx" //#include "interno.hxx" #include <sfx2/module.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "versdlg.hxx" #include "doc.hrc" #include <sfx2/docfac.hxx> @@ -137,8 +137,6 @@ public: #define SfxObjectShell #include "sfxslots.hxx" -svtools::AsynchronLink* pPendingCloser = 0; - //========================================================================= @@ -280,7 +278,7 @@ void SfxObjectShell::PrintExec_Impl(SfxRequest &rReq) void SfxObjectShell::PrintState_Impl(SfxItemSet &rSet) { bool bPrinting = false; - SfxViewFrame *pFrame = SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame)); + SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); if ( pFrame ) { SfxPrinter *pPrinter = pFrame->GetViewShell()->GetPrinter(); @@ -388,7 +386,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if ( !pFrame ) return; - if ( pFrame->GetFrame()->GetParentFrame() ) + if ( pFrame->GetFrame().GetParentFrame() ) { pFrame->GetTopViewFrame()->GetObjectShell()->ExecuteSlot( rReq ); return; @@ -427,28 +425,15 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) // collect data for dialog String aURL, aTitle; - if ( HasName() && !pImp->aNewName.Len() ) + if ( HasName() ) { aURL = GetMedium()->GetName(); aTitle = GetTitle(); } else { - if ( !pImp->aNewName.Len() ) - { - aURL = DEFINE_CONST_UNICODE( "private:factory/" ); - aURL += String::CreateFromAscii( GetFactory().GetShortName() ); - // aTitle = String( SfxResId( STR_NONAME ) ); - } - else - { - aURL = DEFINE_CONST_UNICODE( "[private:factory/" ); - aURL += String::CreateFromAscii( GetFactory().GetShortName() ); - aURL += DEFINE_CONST_UNICODE( "]" ); - INetURLObject aURLObj( pImp->aNewName ); - aURL += String(aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI )); - // aTitle = aURLObj.GetBase(); - } + aURL = DEFINE_CONST_UNICODE( "private:factory/" ); + aURL += String::CreateFromAscii( GetFactory().GetShortName() ); aTitle = GetTitle(); } @@ -539,10 +524,10 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) // get statusindicator uno::Reference< task::XStatusIndicator > xStatusIndicator; SfxViewFrame *pFrame = GetFrame(); - if ( pFrame && pFrame->GetFrame() ) + if ( pFrame ) { uno::Reference< task::XStatusIndicatorFactory > xStatFactory( - pFrame->GetFrame()->GetFrameInterface(), + pFrame->GetFrame().GetFrameInterface(), uno::UNO_QUERY ); if( xStatFactory.is() ) xStatusIndicator = xStatFactory->createStatusIndicator(); @@ -662,9 +647,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) && pFilt->GetVersion() >= SOFFICE_FILEFORMAT_60 ) { SfxViewFrame* pDocViewFrame = SfxViewFrame::GetFirst( this ); - SfxFrame* pDocFrame = pDocViewFrame ? pDocViewFrame->GetFrame() : NULL; - if ( pDocFrame ) - SfxHelp::OpenHelpAgent( pDocFrame, HID_DID_SAVE_PACKED_XML ); + if ( pDocViewFrame ) + SfxHelp::OpenHelpAgent( &pDocViewFrame->GetFrame(), HID_DID_SAVE_PACKED_XML ); } // the StoreAsURL/StoreToURL method have called this method with false @@ -728,7 +712,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_CLOSEDOC: { SfxViewFrame *pFrame = GetFrame(); - if ( pFrame && pFrame->GetFrame()->GetParentFrame() ) + if ( pFrame && pFrame->GetFrame().GetParentFrame() ) { // Wenn SID_CLOSEDOC "uber Menue etc. ausgef"uhrt wird, das // aktuelle Dokument aber in einem Frame liegt, soll eigentlich @@ -743,7 +727,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) pFrame = SfxViewFrame::GetFirst( this ); while ( pFrame ) { - if ( pFrame->GetFrame()->GetParentFrame() ) + if ( pFrame->GetFrame().GetParentFrame() ) { // Auf dieses Dokument existiert noch eine Sicht, die // in einem FrameSet liegt; diese darf nat"urlich nicht @@ -762,8 +746,8 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) pFrame = SfxViewFrame::GetFirst( this ); while ( pFrame ) { - if ( !pFrame->GetFrame()->GetParentFrame() ) - pFrame->GetFrame()->DoClose(); + if ( !pFrame->GetFrame().GetParentFrame() ) + pFrame->GetFrame().DoClose(); pFrame = SfxViewFrame::GetNext( *pFrame, this ); } } @@ -937,7 +921,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) pFrame = SfxViewFrame::GetFirst( this ); if ( pFrame ) { - if ( pFrame->GetFrame()->GetParentFrame() ) + if ( pFrame->GetFrame().GetParentFrame() ) { pFrame = pFrame->GetTopViewFrame(); pDoc = pFrame->GetObjectShell(); @@ -970,7 +954,7 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { SfxObjectShell *pDoc = this; SfxViewFrame *pFrame = GetFrame(); - if ( pFrame && pFrame->GetFrame()->GetParentFrame() ) + if ( pFrame && pFrame->GetFrame().GetParentFrame() ) { // Wenn SID_CLOSEDOC "uber Menue etc. ausgef"uhrt wird, das // aktuelle Dokument aber in einem Frame liegt, soll eigentlich @@ -1190,7 +1174,7 @@ void SfxObjectShell::StateProps_Impl(SfxItemSet &rSet) case SID_CLOSING: { - rSet.Put( SfxBoolItem( SID_CLOSING, Get_Impl()->bInCloseEvent ) ); + rSet.Put( SfxBoolItem( SID_CLOSING, false ) ); break; } @@ -1215,10 +1199,9 @@ void SfxObjectShell::ExecView_Impl(SfxRequest &rReq) { case SID_ACTIVATE: { - SfxViewFrame *pFrame = - SfxViewFrame::GetFirst( this, TYPE(SfxTopViewFrame), TRUE ); + SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this, TRUE ); if ( pFrame ) - pFrame->GetFrame()->Appear(); + pFrame->GetFrame().Appear(); rReq.SetReturnValue( SfxObjectItem( 0, pFrame ) ); rReq.Done(); break; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 593de3d181f1..6d8deb85b687 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -208,31 +208,6 @@ sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, ::rtl::OUString& rPasswd ) } //------------------------------------------------------------------------- -sal_Bool SfxObjectShell::NoDependencyFromManifest_Impl( const uno::Reference< embed::XStorage >& xStorage ) -{ - uno::Sequence< ::rtl::OUString > aElements = xStorage->getElementNames(); - for ( sal_Int32 nInd = 0; nInd < aElements.getLength(); nInd++ ) - { - if ( xStorage->isStorageElement( aElements[nInd] ) ) - { - // if there are other standard elements that do not need manifest.xml the following - // list can be extended - if ( !aElements[nInd].equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Pictures" ) ) ) - && !aElements[nInd].equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Configurations" ) ) ) - && !aElements[nInd].equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Configurations2" ) ) ) - && !aElements[nInd].equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Thumbnails" ) ) ) - && !aElements[nInd].equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Basic" ) ) ) ) - { - // the substorage is not know as one that does not need manifest.xml - return sal_False; - } - } - } - - return sal_True; -} - -//------------------------------------------------------------------------- sal_Bool SfxObjectShell::PutURLContentsToVersionStream_Impl( ::rtl::OUString aURL, const uno::Reference< embed::XStorage >& xDocStorage, @@ -444,23 +419,6 @@ sal_Bool SfxObjectShell::Load( SfxMedium& rMedium ) return GeneralInit_Impl( rMedium.GetStorage(), sal_True ); } -//------------------------------------------------------------------------- -sal_Bool SfxObjectShell::DoInitNew_Impl( const ::rtl::OUString& rName ) - -/* [Beschreibung] -*/ - -{ - if ( rName.getLength() ) - { - DBG_ERROR( "This code is intended to be removed, the caller part must be checked!\n" ); - return DoInitNew(0); - } - else - return DoInitNew(0); -} - - sal_Bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) /* [Beschreibung] @@ -515,9 +473,7 @@ sal_Bool SfxObjectShell::DoInitNew( SfxMedium* pMed ) impl_addToModelCollection(xModel); } - pImp->bInitialized = sal_True; - SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); - SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) ); + SetInitialized_Impl( true ); return sal_True; } @@ -2815,7 +2771,6 @@ sal_Bool SfxObjectShell::CommonSaveAs_Impl pSet->ClearItem( SID_OPTIONS ); //pSet->ClearItem( SID_FILE_FILTEROPTIONS ); pSet->ClearItem( SID_VERSION ); - //pSet->ClearItem( SID_USE_FILTEROPTIONS ); pSet->ClearItem( SID_EDITDOC ); pSet->ClearItem( SID_OVERWRITE ); pSet->ClearItem( SID_DEFAULTFILEPATH ); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index e3e3a36505a5..6502eeaeb78c 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -62,6 +62,7 @@ #include <sfx2/objsh.hxx> #include <sfx2/signaturestate.hxx> +#include <sfx2/sfxmodelfactory.hxx> #ifndef _BASIC_SBUNO_HXX #include <basic/sbuno.hxx> @@ -131,7 +132,6 @@ DBG_NAME(SfxObjectShell) #define DocumentInfo #include "sfxslots.hxx" -extern svtools::AsynchronLink* pPendingCloser; static WeakReference< XInterface > s_xCurrentComponent; //========================================================================= @@ -186,8 +186,7 @@ TYPEINIT1(SfxObjectShell, SfxShell); //-------------------------------------------------------------------- SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) -:mpObjectContainer(0) - ,pCfgMgr( 0) + :mpObjectContainer(0) ,pBasicManager( new SfxBasicManagerHolder ) ,rDocShell( _rDocShell ) ,aMacroMode( *this ) @@ -196,10 +195,8 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,nVisualDocumentNumber( USHRT_MAX) ,nDocumentSignatureState( SIGNATURESTATE_UNKNOWN ) ,nScriptingSignatureState( SIGNATURESTATE_UNKNOWN ) - ,bTemplateConfig( sal_False) ,bInList( sal_False) ,bClosing( sal_False) - ,bSetInPlaceObj( sal_False) ,bIsSaving( sal_False) ,bPasswd( sal_False) ,bIsTmp( sal_False) @@ -209,15 +206,9 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,bImportDone ( sal_False) ,bInPrepareClose( sal_False ) ,bPreparedForClose( sal_False ) - ,bWaitingForPicklist( sal_False ) - ,bModuleSearched( sal_False ) - ,bIsHelpObjSh( sal_False ) - ,bForbidCaching( sal_False ) + ,bWaitingForPicklist( sal_True ) ,bForbidReload( sal_False ) - ,bSupportsEventMacros( sal_True ) - ,bLoadingWindows( sal_False ) ,bBasicInitialized( sal_False ) -// ,bHidden( sal_False ) ,bIsPrintJobCancelable( sal_True ) ,bOwnsStorage( sal_True ) ,bNoBaseURL( sal_False ) @@ -227,6 +218,7 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,bPreserveVersions( sal_True ) ,m_bMacroSignBroken( sal_False ) ,m_bNoBasicCapabilities( sal_False ) + ,m_bDocRecoverySupport( sal_True ) ,bQueryLoadTemplate( sal_True ) ,bLoadReadonly( sal_False ) ,bUseUserData( sal_True ) @@ -235,46 +227,62 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell ) ,m_bAllowShareControlFileClean( sal_True ) ,lErr(ERRCODE_NONE) ,nEventId ( 0) - ,bDoNotTouchDocInfo( sal_False ) ,pReloadTimer ( 0) ,pMarkData( 0 ) - ,nLoadedFlags ( SFX_LOADED_MAINDOCUMENT ) + ,nLoadedFlags ( SFX_LOADED_ALL ) ,nFlagsInProgress( 0 ) - ,bInFrame( sal_False ) ,bModalMode( sal_False ) ,bRunningMacro( sal_False ) ,bReloadAvailable( sal_False ) ,nAutoLoadLocks( 0 ) ,pModule( 0 ) - ,pFrame( 0 ) - ,pTbxConfig( 0 ) ,eFlags( SFXOBJECTSHELL_UNDEFINED ) - ,pCloser( 0 ) ,bReadOnlyUI( sal_False ) ,bHiddenLockedByAPI( sal_False ) - ,bInCloseEvent( sal_False ) ,nStyleFilter( 0 ) ,bDisposing( sal_False ) ,m_bEnableSetModified( sal_True ) ,m_bIsModified( sal_False ) ,m_nMapUnit( MAP_100TH_MM ) ,m_bCreateTempStor( sal_False ) - ,m_xDocInfoListener() ,m_bIsInit( sal_False ) ,m_bIncomplEncrWarnShown( sal_False ) { + SfxObjectShell* pDoc = &_rDocShell; + SfxObjectShellArr_Impl &rArr = SFX_APP()->GetObjectShells_Impl(); + rArr.C40_INSERT( SfxObjectShell, pDoc, rArr.Count() ); + bInList = sal_True; } //-------------------------------------------------------------------- SfxObjectShell_Impl::~SfxObjectShell_Impl() { - if ( pPendingCloser == pCloser ) - pPendingCloser = 0; - delete pCloser; delete pBasicManager; } +//-------------------------------------------------------------------- + +SfxObjectShell::SfxObjectShell( const sal_uInt64 i_nCreationFlags ) + : pImp( new SfxObjectShell_Impl( *this ) ) + , pMedium(0) + , pStyleSheetPool(0) + , eCreateMode( ( i_nCreationFlags & SFXMODEL_EMBEDDED_OBJECT ) ? SFX_CREATE_MODE_EMBEDDED : SFX_CREATE_MODE_STANDARD ) + , bHasName( sal_False ) +{ + DBG_CTOR(SfxObjectShell, 0); + + const bool bScriptSupport = ( i_nCreationFlags & SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) == 0; + if ( !bScriptSupport ) + SetHasNoBasic(); + + const bool bDocRecovery = ( i_nCreationFlags & SFXMODEL_DISABLE_DOCUMENT_RECOVERY ) == 0; + if ( !bDocRecovery ) + pImp->m_bDocRecoverySupport = sal_False; +} + +//-------------------------------------------------------------------- + // initializes a document from a file-description SfxObjectShell::SfxObjectShell @@ -308,24 +316,10 @@ SfxObjectShell::SfxObjectShell : pImp( new SfxObjectShell_Impl( *this ) ), pMedium(0), pStyleSheetPool(0), - eCreateMode(eMode) + eCreateMode(eMode), + bHasName( sal_False ) { DBG_CTOR(SfxObjectShell, 0); - - bHasName = sal_False; - nViewNo = 0; - - pImp->bWaitingForPicklist = sal_True; - - // Aggregation InPlaceObject+Automation -//(mba) AddInterface( SvDispatch::ClassFactory() ); - - SfxObjectShell *pThis = this; - SfxObjectShellArr_Impl &rArr = SFX_APP()->GetObjectShells_Impl(); - rArr.C40_INSERT( SfxObjectShell, pThis, rArr.Count() ); - pImp->bInList = sal_True; - pImp->nLoadedFlags = SFX_LOADED_ALL; -//REMOVE SetObjectShell( TRUE ); } //-------------------------------------------------------------------- @@ -343,12 +337,8 @@ SfxObjectShell::~SfxObjectShell() // Ableitungszweig SfxInternObject ist wegen eines Compiler Bugs nicht // erlaubt SfxObjectShell::Close(); - pImp->xModel = NULL; + pImp->pBaseModel.set( NULL ); -// DELETEX(pImp->pEventConfig); -// DELETEX(pImp->pTbxConfig); -// DELETEX(pImp->pAccMgr); -// DELETEX(pImp->pCfgMgr); DELETEX(pImp->pReloadTimer ); SfxApplication *pSfxApp = SFX_APP(); @@ -361,8 +351,7 @@ SfxObjectShell::~SfxObjectShell() if ( pSfxApp->GetDdeService() ) pSfxApp->RemoveDdeTopic( this ); - if ( pImp->xModel.is() ) - pImp->xModel = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > (); + pImp->pBaseModel.set( NULL ); // don't call GetStorage() here, in case of Load Failure it's possible that a storage was never assigned! if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( sal_False ) == pImp->m_xDocStorage ) @@ -488,7 +477,7 @@ SfxObjectShell* SfxObjectShell::GetFirst continue; if ( ( !pType || pSh->IsA(*pType) ) && - ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, 0, sal_True ))) + ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, sal_True ))) return pSh; } @@ -521,7 +510,7 @@ SfxObjectShell* SfxObjectShell::GetNext continue; if ( ( !pType || pSh->IsA(*pType) ) && - ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, 0, sal_True ))) + ( !bOnlyVisible || SfxViewFrame::GetFirst( pSh, sal_True ))) return pSh; } return 0; @@ -561,12 +550,11 @@ sal_uInt16 SfxObjectShell::PrepareClose return sal_False; SfxViewFrame* pFirst = SfxViewFrame::GetFirst( this ); - if( pFirst && !pFirst->GetFrame()->PrepareClose_Impl( bUI, bForBrowsing ) ) + if( pFirst && !pFirst->GetFrame().PrepareClose_Impl( bUI, bForBrowsing ) ) return sal_False; // prepare views for closing - for ( SfxViewFrame* pFrm = SfxViewFrame::GetFirst( - this, TYPE(SfxViewFrame)); + for ( SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this ); pFrm; pFrm = SfxViewFrame::GetNext( *pFrm, this ) ) { DBG_ASSERT(pFrm->GetViewShell(),"KeineShell"); @@ -591,83 +579,69 @@ sal_uInt16 SfxObjectShell::PrepareClose // nur fuer in sichtbaren Fenstern dargestellte Dokumente fragen SfxViewFrame *pFrame = SfxObjectShell::Current() == this ? SfxViewFrame::Current() : SfxViewFrame::GetFirst( this ); - while ( pFrame && (pFrame->GetFrameType() & SFXFRAME_SERVER ) ) - pFrame = SfxViewFrame::GetNext( *pFrame, this ); sal_Bool bClose = sal_False; - if ( bUI && IsModified() ) + if ( bUI && IsModified() && pFrame ) { - if ( pFrame ) + // minimierte restoren + SfxFrame& rTop = pFrame->GetTopFrame(); + SfxViewFrame::SetViewFrame( rTop.GetCurrentViewFrame() ); + pFrame->GetFrame().Appear(); + + // fragen, ob gespeichert werden soll + short nRet = RET_YES; + //TODO/CLEANUP + //brauchen wir UI=2 noch? + //if( SfxApplication::IsPlugin() == sal_False || bUI == 2 ) { - // minimierte restoren - SfxFrame* pTop = pFrame->GetTopFrame(); - SfxViewFrame::SetViewFrame( pTop->GetCurrentViewFrame() ); - pFrame->GetFrame()->Appear(); - - // fragen, ob gespeichert werden soll - short nRet = RET_YES; - //TODO/CLEANUP - //brauchen wir UI=2 noch? - //if( SfxApplication::IsPlugin() == sal_False || bUI == 2 ) + //initiate help agent to inform about "print modifies the document" + SvtPrintWarningOptions aPrintOptions; + if (aPrintOptions.IsModifyDocumentOnPrintingAllowed() && + HasName() && getDocProperties()->getPrintDate().Month > 0) { - //initiate help agent to inform about "print modifies the document" - SvtPrintWarningOptions aPrintOptions; - if (aPrintOptions.IsModifyDocumentOnPrintingAllowed() && - HasName() && getDocProperties()->getPrintDate().Month > 0) - { - SfxHelp::OpenHelpAgent(pFirst->GetFrame(), HID_CLOSE_WARNING); - } - const Reference< XTitle > xTitle(pImp->xModel, UNO_QUERY_THROW); - const ::rtl::OUString sTitle = xTitle->getTitle (); - nRet = ExecuteQuerySaveDocument(&pFrame->GetWindow(),sTitle); + SfxHelp::OpenHelpAgent( &pFirst->GetFrame(), HID_CLOSE_WARNING ); } - /*HACK for plugin::destroy()*/ + const Reference< XTitle > xTitle( *pImp->pBaseModel.get(), UNO_QUERY_THROW ); + const ::rtl::OUString sTitle = xTitle->getTitle (); + nRet = ExecuteQuerySaveDocument(&pFrame->GetWindow(),sTitle); + } + /*HACK for plugin::destroy()*/ - if ( RET_YES == nRet ) + if ( RET_YES == nRet ) + { + // per Dispatcher speichern + const SfxPoolItem *pPoolItem; + if ( IsSaveVersionOnClose() ) { - // per Dispatcher speichern - const SfxPoolItem *pPoolItem; - if ( IsSaveVersionOnClose() ) - { - SfxStringItem aItem( SID_DOCINFO_COMMENTS, String( SfxResId( STR_AUTOMATICVERSION ) ) ); - SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); - const SfxPoolItem* ppArgs[] = { &aItem, &aWarnItem, 0 }; - pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); - } - else - { - SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); - const SfxPoolItem* ppArgs[] = { &aWarnItem, 0 }; - pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); - } - - if ( !pPoolItem || pPoolItem->ISA(SfxVoidItem) || ( pPoolItem->ISA(SfxBoolItem) && !( (const SfxBoolItem*) pPoolItem )->GetValue() ) ) - return sal_False; - else - bClose = sal_True; + SfxStringItem aItem( SID_DOCINFO_COMMENTS, String( SfxResId( STR_AUTOMATICVERSION ) ) ); + SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); + const SfxPoolItem* ppArgs[] = { &aItem, &aWarnItem, 0 }; + pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); } - else if ( RET_CANCEL == nRet ) - // abgebrochen - return sal_False; - else if ( RET_NEWTASK == nRet ) + else { - return RET_NEWTASK; + SfxBoolItem aWarnItem( SID_FAIL_ON_WARNING, bUI ); + const SfxPoolItem* ppArgs[] = { &aWarnItem, 0 }; + pPoolItem = pFrame->GetBindings().ExecuteSynchron( SID_SAVEDOC, ppArgs ); } + + if ( !pPoolItem || pPoolItem->ISA(SfxVoidItem) || ( pPoolItem->ISA(SfxBoolItem) && !( (const SfxBoolItem*) pPoolItem )->GetValue() ) ) + return sal_False; else - { - // Bei Nein nicht noch Informationlost bClose = sal_True; - } } - } - - // ggf. hinweisen, da\s unter Fremdformat gespeichert - if( pMedium ) - { - SFX_ITEMSET_ARG( pMedium->GetItemSet(), pIgnoreInformationLost, - SfxBoolItem, SID_DOC_IGNOREINFORMATIONLOST, sal_False); - if( pIgnoreInformationLost && pIgnoreInformationLost->GetValue() ) - bUI = sal_False; + else if ( RET_CANCEL == nRet ) + // abgebrochen + return sal_False; + else if ( RET_NEWTASK == nRet ) + { + return RET_NEWTASK; + } + else + { + // Bei Nein nicht noch Informationlost + bClose = sal_True; + } } pImp->bPreparedForClose = sal_True; @@ -861,20 +835,6 @@ sal_Bool SfxObjectShell::DoClose() //-------------------------------------------------------------------- -void SfxObjectShell::SetLastMark_Impl( const String &rMark ) -{ - pImp->aMark = rMark; -} - -//-------------------------------------------------------------------- - -const String& SfxObjectShell::GetLastMark_Impl() const -{ - return pImp->aMark; -} - -//-------------------------------------------------------------------- - SfxObjectShell* SfxObjectShell::GetObjectShell() { return this; @@ -899,45 +859,28 @@ SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames() return *pEventNameContainer; } -SEQUENCE< OUSTRING > SfxObjectShell::GetEventNames_Impl() -{ - if (!pImp->xEventNames.getLength()) - pImp->xEventNames = GetEventNames(); - return pImp->xEventNames; -} - //-------------------------------------------------------------------- -void SfxObjectShell::SetModel( SfxBaseModel* pModel ) +::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SfxObjectShell::GetModel() const { - OSL_ENSURE( !pImp->xModel.is() || pModel == NULL, "Model already set!" ); - pImp->xModel = pModel; - if ( pModel ) { - pModel->addCloseListener( new SfxModelListener_Impl(this) ); - //pImp->m_xDocInfoListener = new SfxDocInfoListener_Impl(*this); - //uno::Reference<util::XModifyBroadcaster> xMB( - // pModel->getDocumentProperties(), uno::UNO_QUERY_THROW); - //xMB->addModifyListener(pImp->m_xDocInfoListener); - } -} - -//-------------------------------------------------------------------- - -const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& SfxObjectShell::GetModel() const -{ - return pImp->xModel; + return GetBaseModel(); } void SfxObjectShell::SetBaseModel( SfxBaseModel* pModel ) { - SetModel(pModel); + OSL_ENSURE( !pImp->pBaseModel.is() || pModel == NULL, "Model already set!" ); + pImp->pBaseModel.set( pModel ); + if ( pImp->pBaseModel.is() ) + { + pImp->pBaseModel->addCloseListener( new SfxModelListener_Impl(this) ); + } } //-------------------------------------------------------------------- -::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SfxObjectShell::GetBaseModel() +::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SfxObjectShell::GetBaseModel() const { - return pImp->xModel; + return pImp->pBaseModel.get(); } /* -----------------------------10.09.2001 15:56------------------------------ @@ -1118,3 +1061,16 @@ SfxObjectShell* SfxObjectShell::CreateAndLoadObject( const SfxItemSet& rSet, Sfx return NULL; } +void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew ) +{ + pImp->bInitialized = sal_True; + if ( i_fromInitNew ) + { + SetActivateEvent_Impl( SFX_EVENT_CREATEDOC ); + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) ); + } + else + { + SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) ); + } +} diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index 305344baddc6..459a142b9129 100755 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -268,7 +268,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SfxPrintHelper::getPrinter() thro // Printer beschaffen SfxViewFrame *pViewFrm = m_pData->m_pObjectShell.Is() ? - SfxViewFrame::GetFirst( m_pData->m_pObjectShell, 0, sal_False ) : 0; + SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False ) : 0; if ( !pViewFrm ) return uno::Sequence< beans::PropertyValue >(); @@ -319,7 +319,7 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue > { // alten Printer beschaffen SfxViewFrame *pViewFrm = m_pData->m_pObjectShell.Is() ? - SfxViewFrame::GetFirst( m_pData->m_pObjectShell, 0, sal_False ) : 0; + SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False ) : 0; if ( !pViewFrm ) return; @@ -582,7 +582,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // get view for sfx printing capabilities SfxViewFrame *pViewFrm = m_pData->m_pObjectShell.Is() ? - SfxViewFrame::GetFirst( m_pData->m_pObjectShell, 0, sal_False ) : 0; + SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False ) : 0; if ( !pViewFrm ) return; SfxViewShell* pView = pViewFrm->GetViewShell(); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 8aa0ae2a531c..e1b37c119f1a 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -70,6 +70,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <comphelper/processfactory.hxx> // can be removed when this is a "real" service #include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <svl/itemset.hxx> #include <svl/stritem.hxx> #include <svl/eitem.hxx> @@ -98,6 +99,9 @@ // includes of my own project //________________________________________________________________________________________________________ +#include <sfx2/sfxbasecontroller.hxx> +#include "viewfac.hxx" +#include "workwin.hxx" #include <sfx2/signaturestate.hxx> #include <sfx2/sfxuno.hxx> #include <objshimp.hxx> @@ -114,7 +118,7 @@ #include <sfx2/evntconf.hxx> #include <sfx2/sfx.hrc> #include <sfx2/app.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "appdata.hxx" #include <sfx2/docfac.hxx> #include <sfx2/fcontnr.hxx> @@ -137,11 +141,19 @@ static const ::rtl::OUString SERVICENAME_DESKTOP = ::rtl::OUString::createFromAs namespace css = ::com::sun::star; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::frame::XController; +using ::com::sun::star::frame::XController2; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::io::IOException; +using ::com::sun::star::lang::WrappedTargetException; +using ::com::sun::star::uno::Type; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::document::XDocumentRecovery; /** This Listener is used to get notified when the XDocumentProperties of the XModel change. - If several changes are done the "bQuiet" member can be used to - temporarily suppress notifications. */ class SfxDocInfoListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XModifyListener > @@ -149,12 +161,9 @@ class SfxDocInfoListener_Impl : public ::cppu::WeakImplHelper1< public: SfxObjectShell& m_rShell; - bool bQuiet; - bool bGotModified; SfxDocInfoListener_Impl( SfxObjectShell& i_rDoc ) : m_rShell(i_rDoc) - , bQuiet(false) { }; ~SfxDocInfoListener_Impl(); @@ -171,12 +180,9 @@ void SAL_CALL SfxDocInfoListener_Impl::modified( const lang::EventObject& ) throw ( uno::RuntimeException ) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); - bGotModified = true; // notify changes to the SfxObjectShell - if ( !bQuiet ) { - m_rShell.FlushDocInfo(); - } + m_rShell.FlushDocInfo(); } void SAL_CALL SfxDocInfoListener_Impl::disposing( const lang::EventObject& ) @@ -212,6 +218,8 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument sal_Bool m_bClosing ; sal_Bool m_bSaving ; sal_Bool m_bSuicide ; + sal_Bool m_bInitialized ; + sal_Bool m_bModifiedSinceLastSave; uno::Reference< com::sun::star::view::XPrintable> m_xPrintable ; uno::Reference< script::provider::XScriptProvider > m_xScriptProvider; uno::Reference< ui::XUIConfigurationManager > m_xUIConfigurationManager; @@ -230,6 +238,8 @@ struct IMPL_SfxBaseModel_DataContainer : public ::sfx2::IModifiableDocument , m_bClosing ( sal_False ) , m_bSaving ( sal_False ) , m_bSuicide ( sal_False ) + , m_bInitialized ( sal_False ) + , m_bModifiedSinceLastSave( sal_False ) , m_pStorageModifyListen ( NULL ) , m_xTitleHelper () , m_xNumberedControllers () @@ -357,41 +367,40 @@ SfxOwnFramesLocker::SfxOwnFramesLocker( SfxObjectShell* pObjectShell ) if ( !pObjectShell ) return; - for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(pObjectShell, TYPE(SfxTopViewFrame) ); pFrame; - pFrame = SfxViewFrame::GetNext(*pFrame, pObjectShell, TYPE(SfxTopViewFrame) ) ) + for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pObjectShell ); + pFrame; + pFrame = SfxViewFrame::GetNext( *pFrame, pObjectShell ) + ) { - SfxFrame* pSfxFrame = pFrame->GetFrame(); - if ( pSfxFrame ) + SfxFrame& rSfxFrame = pFrame->GetFrame(); + try { - try + // get vcl window related to the frame and lock it if it is still not locked + uno::Reference< frame::XFrame > xFrame = rSfxFrame.GetFrameInterface(); + Window* pWindow = GetVCLWindow( xFrame ); + if ( !pWindow ) + throw uno::RuntimeException(); + + if ( pWindow->IsEnabled() ) { - // get vcl window related to the frame and lock it if it is still not locked - uno::Reference< frame::XFrame > xFrame = pSfxFrame->GetFrameInterface(); - Window* pWindow = GetVCLWindow( xFrame ); - if ( !pWindow ) - throw uno::RuntimeException(); + pWindow->Disable(); - if ( pWindow->IsEnabled() ) + try { - pWindow->Disable(); - - try - { - sal_Int32 nLen = m_aLockedFrames.getLength(); - m_aLockedFrames.realloc( nLen + 1 ); - m_aLockedFrames[nLen] = xFrame; - } - catch( uno::Exception& ) - { - pWindow->Enable(); - throw; - } + sal_Int32 nLen = m_aLockedFrames.getLength(); + m_aLockedFrames.realloc( nLen + 1 ); + m_aLockedFrames[nLen] = xFrame; + } + catch( uno::Exception& ) + { + pWindow->Enable(); + throw; } } - catch( uno::Exception& ) - { - OSL_ENSURE( sal_False, "Not possible to lock the frame window!\n" ); - } + } + catch( uno::Exception& ) + { + OSL_ENSURE( sal_False, "Not possible to lock the frame window!\n" ); } } } @@ -522,6 +531,7 @@ SfxBaseModel::SfxBaseModel( SfxObjectShell *pObjectShell ) : BaseMutex() , m_pData( new IMPL_SfxBaseModel_DataContainer( m_aMutex, pObjectShell ) ) , m_bSupportEmbeddedScripts( pObjectShell && pObjectShell->Get_Impl() ? !pObjectShell->Get_Impl()->m_bNoBasicCapabilities : false ) +, m_bSupportDocRecovery( pObjectShell && pObjectShell->Get_Impl() ? pObjectShell->Get_Impl()->m_bDocRecoverySupport : false ) { DBG_CTOR(sfx2_SfxBaseModel,NULL); if ( pObjectShell != NULL ) @@ -545,7 +555,9 @@ SfxBaseModel::~SfxBaseModel() uno::Any SAL_CALL SfxBaseModel::queryInterface( const UNOTYPE& rType ) throw( uno::RuntimeException ) { - if ( !m_bSupportEmbeddedScripts && rType.equals( XEMBEDDEDSCRIPTS::static_type() ) ) + if ( ( !m_bSupportEmbeddedScripts && rType.equals( XEMBEDDEDSCRIPTS::static_type() ) ) + || ( !m_bSupportDocRecovery && rType.equals( XDocumentRecovery::static_type() ) ) + ) return Any(); return SfxBaseModel_Base::queryInterface( rType ); @@ -581,21 +593,31 @@ void SAL_CALL SfxBaseModel::release() throw( ) // XTypeProvider //________________________________________________________________________________________________________ -uno::Sequence< UNOTYPE > SAL_CALL SfxBaseModel::getTypes() throw( uno::RuntimeException ) +namespace { - uno::Sequence< UNOTYPE > aTypes( SfxBaseModel_Base::getTypes() ); - if ( !m_bSupportEmbeddedScripts ) + void lcl_stripType( Sequence< Type >& io_rTypes, const Type& i_rTypeToStrip ) { - // remove XEmbeddedScripts type from the sequence - Sequence< UNOTYPE > aStrippedTypes( aTypes.getLength() - 1 ); + Sequence< UNOTYPE > aStrippedTypes( io_rTypes.getLength() - 1 ); ::std::remove_copy_if( - aTypes.getConstArray(), - aTypes.getConstArray() + aTypes.getLength(), + io_rTypes.getConstArray(), + io_rTypes.getConstArray() + io_rTypes.getLength(), aStrippedTypes.getArray(), - ::std::bind2nd( ::std::equal_to< UNOTYPE >(), XEMBEDDEDSCRIPTS::static_type() ) + ::std::bind2nd( ::std::equal_to< Type >(), i_rTypeToStrip ) ); - aTypes = aStrippedTypes; + io_rTypes = aStrippedTypes; } +} + +uno::Sequence< UNOTYPE > SAL_CALL SfxBaseModel::getTypes() throw( uno::RuntimeException ) +{ + uno::Sequence< UNOTYPE > aTypes( SfxBaseModel_Base::getTypes() ); + + if ( !m_bSupportEmbeddedScripts ) + lcl_stripType( aTypes, XEMBEDDEDSCRIPTS::static_type() ); + + if ( !m_bSupportDocRecovery ) + lcl_stripType( aTypes, XDocumentRecovery::static_type() ); + return aTypes; } @@ -648,9 +670,7 @@ uno::Reference< script::XStarBasicAccess > implGetStarBasicAccess( SfxObjectShel uno::Reference< XNAMECONTAINER > SAL_CALL SfxBaseModel::getLibraryContainer() throw( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess; if( !rxAccess.is() && m_pData->m_pObjectShell.Is() ) @@ -669,9 +689,7 @@ void SAL_CALL SfxBaseModel::createLibrary( const ::rtl::OUString& LibName, const const ::rtl::OUString& ExternalSourceURL, const ::rtl::OUString& LinkTargetURL ) throw(ELEMENTEXISTEXCEPTION, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess; if( !rxAccess.is() && m_pData->m_pObjectShell.Is() ) @@ -688,9 +706,7 @@ void SAL_CALL SfxBaseModel::addModule( const ::rtl::OUString& LibraryName, const const ::rtl::OUString& Language, const ::rtl::OUString& Source ) throw( NOSUCHELEMENTEXCEPTION, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess; if( !rxAccess.is() && m_pData->m_pObjectShell.Is() ) @@ -707,9 +723,7 @@ void SAL_CALL SfxBaseModel::addDialog( const ::rtl::OUString& LibraryName, const const ::com::sun::star::uno::Sequence< sal_Int8 >& Data ) throw(NOSUCHELEMENTEXCEPTION, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStarBasicAccess >& rxAccess = m_pData->m_xStarBasicAccess; if( !rxAccess.is() && m_pData->m_pObjectShell.Is() ) @@ -726,9 +740,7 @@ void SAL_CALL SfxBaseModel::addDialog( const ::rtl::OUString& LibraryName, const uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getParent() throw( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); return m_pData->m_xParent; } @@ -739,7 +751,7 @@ uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getParent() throw( uno: void SAL_CALL SfxBaseModel::setParent(const uno::Reference< uno::XInterface >& Parent) throw(NOSUPPORTEXCEPTION, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_xParent = Parent; } @@ -749,11 +761,7 @@ void SAL_CALL SfxBaseModel::setParent(const uno::Reference< uno::XInterface >& P void SAL_CALL SfxBaseModel::dispose() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - // object already disposed? - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( !m_pData->m_bClosed ) { @@ -812,11 +820,7 @@ void SAL_CALL SfxBaseModel::dispose() throw(::com::sun::star::uno::RuntimeExcept void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XEVENTLISTENER >& aListener ) throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; - + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XEVENTLISTENER >*)0), aListener ); } @@ -827,11 +831,7 @@ void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XEVENTLISTEN void SAL_CALL SfxBaseModel::removeEventListener( const uno::Reference< XEVENTLISTENER >& aListener ) throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; - + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XEVENTLISTENER >*)0), aListener ); } @@ -841,11 +841,7 @@ void SAL_CALL SfxBaseModel::removeEventListener( const uno::Reference< XEVENTLIS uno::Reference< document::XDocumentInfo > SAL_CALL SfxBaseModel::getDocumentInfo() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); - + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( !m_pData->m_xDocumentInfo.is() ) { // WARNING: this will only work if (when loading a document) the @@ -891,11 +887,7 @@ uno::Reference< document::XDocumentProperties > SAL_CALL SfxBaseModel::getDocumentProperties() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); - + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( !m_pData->m_xDocumentProperties.is() ) { uno::Reference< lang::XInitialization > xDocProps( @@ -943,10 +935,7 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& const uno::Sequence< beans::PropertyValue >& rArgs ) throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); - + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( rURL.getLength() == 0 && rArgs.getLength() == 1 && rArgs[0].Name.equalsAscii( "SetEmbedded" ) ) { // allows to set a windowless document to EMBEDDED state @@ -964,53 +953,50 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& if ( m_pData->m_pObjectShell.Is() ) { m_pData->m_sURL = rURL; - uno::Sequence< beans::PropertyValue > aNewSeqArgs( rArgs.getLength() ); - sal_Int32 nNewLen = 0; - for ( sal_Int32 nInd = 0; nInd < rArgs.getLength(); nInd++ ) + SfxObjectShell* pObjectShell = m_pData->m_pObjectShell; + + ::comphelper::NamedValueCollection aArgs( rArgs ); + + Sequence< sal_Int32 > aWinExtent; + if ( ( aArgs.get( "WinExtent" ) >>= aWinExtent )&& ( aWinExtent.getLength() == 4 ) ) { - if ( rArgs[nInd].Name.equalsAscii( "WinExtent" ) ) - { - Sequence< sal_Int32 > aSize; - if ( ( rArgs[nInd].Value >>= aSize ) && aSize.getLength() == 4 ) - { - Rectangle aTmpRect( aSize[0], aSize[1], aSize[2], aSize[3] ); - aTmpRect = OutputDevice::LogicToLogic( aTmpRect, MAP_100TH_MM, m_pData->m_pObjectShell->GetMapUnit() ); - m_pData->m_pObjectShell->SetVisArea( aTmpRect ); - } - } - else if ( rArgs[nInd].Name.equalsAscii( "BreakMacroSignature" ) ) - { - sal_Bool bBreakMacroSign = sal_False; - rArgs[nInd].Value >>= bBreakMacroSign; - m_pData->m_pObjectShell->BreakMacroSign_Impl( bBreakMacroSign ); - } - else if ( !rArgs[nInd].Name.equalsAscii( "Stream" ) && !rArgs[nInd].Name.equalsAscii( "InputStream" ) ) - { - // TODO/LATER: all the parameters that are accepted by ItemSet of the DocShell must be ignored here - aNewSeqArgs[nNewLen++] = rArgs[nInd]; - } + Rectangle aVisArea( aWinExtent[0], aWinExtent[1], aWinExtent[2], aWinExtent[3] ); + aVisArea = OutputDevice::LogicToLogic( aVisArea, MAP_100TH_MM, pObjectShell->GetMapUnit() ); + pObjectShell->SetVisArea( aVisArea ); + } + + sal_Bool bBreakMacroSign = sal_False; + if ( aArgs.get( "BreakMacroSignature" ) >>= bBreakMacroSign ) + { + pObjectShell->BreakMacroSign_Impl( bBreakMacroSign ); } - aNewSeqArgs.realloc( nNewLen ); + aArgs.remove( "WinExtent" ); + aArgs.remove( "BreakMacroSignature" ); + aArgs.remove( "Stream" ); + aArgs.remove( "InputStream" ); - m_pData->m_seqArguments = aNewSeqArgs; + // TODO/LATER: all the parameters that are accepted by ItemSet of the DocShell must be removed here - if( m_pData->m_pObjectShell->GetMedium() ) + m_pData->m_seqArguments = aArgs.getPropertyValues(); + + SfxMedium* pMedium = pObjectShell->GetMedium(); + if ( pMedium ) { - SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() ); + SfxAllItemSet aSet( pObjectShell->GetPool() ); TransformParameters( SID_OPENDOC, rArgs, aSet ); - m_pData->m_pObjectShell->GetMedium()->GetItemSet()->Put( aSet ); + pMedium->GetItemSet()->Put( aSet ); SFX_ITEMSET_ARG( &aSet, pItem, SfxStringItem, SID_FILTER_NAME, sal_False ); if ( pItem ) - m_pData->m_pObjectShell->GetMedium()->SetFilter( - m_pData->m_pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( pItem->GetValue() ) ); + pMedium->SetFilter( + pObjectShell->GetFactory().GetFilterContainer()->GetFilter4FilterName( pItem->GetValue() ) ); SFX_ITEMSET_ARG( &aSet, pTitleItem, SfxStringItem, SID_DOCINFO_TITLE, sal_False ); if ( pTitleItem ) { - SfxViewFrame* pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell ); + SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjectShell ); if ( pFrame ) pFrame->UpdateTitle(); } @@ -1026,10 +1012,7 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& ::rtl::OUString SAL_CALL SfxBaseModel::getURL() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); - + SfxModelGuard aGuard( *this ); return m_pData->m_sURL ; } @@ -1039,10 +1022,7 @@ sal_Bool SAL_CALL SfxBaseModel::attachResource( const ::rtl::OUString& uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); - + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) { uno::Sequence< beans::PropertyValue > seqArgsNew; @@ -1142,9 +1122,10 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getArgs() throw(::c void SAL_CALL SfxBaseModel::connectController( const uno::Reference< frame::XController >& xController ) throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); + OSL_PRECOND( xController.is(), "SfxBaseModel::connectController: invalid controller!" ); + if ( !xController.is() ) + return; sal_uInt32 nOldCount = m_pData->m_seqControllers.getLength(); uno::Sequence< uno::Reference< frame::XController > > aNewSeq( nOldCount + 1 ); @@ -1152,6 +1133,16 @@ void SAL_CALL SfxBaseModel::connectController( const uno::Reference< frame::XCon aNewSeq.getArray()[n] = m_pData->m_seqControllers.getConstArray()[n]; aNewSeq.getArray()[nOldCount] = xController; m_pData->m_seqControllers = aNewSeq; + + if ( m_pData->m_seqControllers.getLength() == 1 ) + { + SfxViewFrame* pViewFrame = SfxViewFrame::Get( xController, GetObjectShell() ); + ENSURE_OR_THROW( pViewFrame, "SFX document without SFX view!?" ); + pViewFrame->UpdateDocument_Impl(); + const String sDocumentURL = GetObjectShell()->GetMedium()->GetName(); + if ( sDocumentURL.Len() ) + SFX_APP()->Broadcast( SfxStringHint( SID_OPENURL, sDocumentURL ) ); + } } //________________________________________________________________________________________________________ @@ -1160,9 +1151,7 @@ void SAL_CALL SfxBaseModel::connectController( const uno::Reference< frame::XCon void SAL_CALL SfxBaseModel::disconnectController( const uno::Reference< frame::XController >& xController ) throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); sal_uInt32 nOldCount = m_pData->m_seqControllers.getLength(); if ( !nOldCount ) @@ -1190,9 +1179,8 @@ void SAL_CALL SfxBaseModel::disconnectController( const uno::Reference< frame::X void SAL_CALL SfxBaseModel::lockControllers() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); + ++m_pData->m_nControllerLockCount ; } @@ -1202,9 +1190,8 @@ void SAL_CALL SfxBaseModel::lockControllers() throw(::com::sun::star::uno::Runti void SAL_CALL SfxBaseModel::unlockControllers() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); + --m_pData->m_nControllerLockCount ; } @@ -1214,9 +1201,7 @@ void SAL_CALL SfxBaseModel::unlockControllers() throw(::com::sun::star::uno::Run sal_Bool SAL_CALL SfxBaseModel::hasControllersLocked() throw(::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); return ( m_pData->m_nControllerLockCount != 0 ) ; } @@ -1226,10 +1211,7 @@ sal_Bool SAL_CALL SfxBaseModel::hasControllersLocked() throw(::com::sun::star::u uno::Reference< frame::XController > SAL_CALL SfxBaseModel::getCurrentController() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); // get the last active controller of this model if ( m_pData->m_xCurrent.is() ) @@ -1246,10 +1228,7 @@ uno::Reference< frame::XController > SAL_CALL SfxBaseModel::getCurrentController void SAL_CALL SfxBaseModel::setCurrentController( const uno::Reference< frame::XController >& xCurrentController ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); m_pData->m_xCurrent = xCurrentController; } @@ -1260,10 +1239,7 @@ void SAL_CALL SfxBaseModel::setCurrentController( const uno::Reference< frame::X uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getCurrentSelection() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< uno::XInterface > xReturn; uno::Reference< frame::XController > xController = getCurrentController() ; @@ -1287,9 +1263,7 @@ uno::Reference< uno::XInterface > SAL_CALL SfxBaseModel::getCurrentSelection() t sal_Bool SAL_CALL SfxBaseModel::disableSetModified() throw (::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw DISPOSEDEXCEPTION(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::RuntimeException(); @@ -1302,9 +1276,7 @@ sal_Bool SAL_CALL SfxBaseModel::disableSetModified() throw (::com::sun::star::un sal_Bool SAL_CALL SfxBaseModel::enableSetModified() throw (::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw DISPOSEDEXCEPTION(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::RuntimeException(); @@ -1317,9 +1289,7 @@ sal_Bool SAL_CALL SfxBaseModel::enableSetModified() throw (::com::sun::star::uno sal_Bool SAL_CALL SfxBaseModel::isSetModifiedEnabled() throw (::com::sun::star::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw DISPOSEDEXCEPTION(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::RuntimeException(); @@ -1333,10 +1303,7 @@ sal_Bool SAL_CALL SfxBaseModel::isSetModifiedEnabled() throw (::com::sun::star:: sal_Bool SAL_CALL SfxBaseModel::isModified() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->IsModified() : sal_False; } @@ -1348,10 +1315,7 @@ sal_Bool SAL_CALL SfxBaseModel::isModified() throw(::com::sun::star::uno::Runtim void SAL_CALL SfxBaseModel::setModified( sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) m_pData->m_pObjectShell->SetModified(bModified); @@ -1363,10 +1327,7 @@ void SAL_CALL SfxBaseModel::setModified( sal_Bool bModified ) void SAL_CALL SfxBaseModel::addModifyListener(const uno::Reference< XMODIFYLISTENER >& xListener) throw( uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0),xListener ); } @@ -1377,10 +1338,7 @@ void SAL_CALL SfxBaseModel::addModifyListener(const uno::Reference< XMODIFYLISTE void SAL_CALL SfxBaseModel::removeModifyListener(const uno::Reference< XMODIFYLISTENER >& xListener) throw( uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0), xListener ); } @@ -1394,7 +1352,7 @@ void SAL_CALL SfxBaseModel::close( sal_Bool bDeliverOwnership ) throw (util::Clo static ::rtl::OUString MSG_1 = ::rtl::OUString::createFromAscii("Cant close while saving."); ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( !m_pData || m_pData->m_bClosed || m_pData->m_bClosing ) + if ( impl_isDisposed() || m_pData->m_bClosed || m_pData->m_bClosing ) return; uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >(this) ); @@ -1456,10 +1414,7 @@ void SAL_CALL SfxBaseModel::close( sal_Bool bDeliverOwnership ) throw (util::Clo void SAL_CALL SfxBaseModel::addCloseListener( const uno::Reference< XCLOSELISTENER >& xListener ) throw (uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XCLOSELISTENER >*)0), xListener ); } @@ -1470,10 +1425,7 @@ void SAL_CALL SfxBaseModel::addCloseListener( const uno::Reference< XCLOSELISTEN void SAL_CALL SfxBaseModel::removeCloseListener( const uno::Reference< XCLOSELISTENER >& xListener ) throw (uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XCLOSELISTENER >*)0), xListener ); } @@ -1484,10 +1436,7 @@ void SAL_CALL SfxBaseModel::removeCloseListener( const uno::Reference< XCLOSELIS uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getPrinter() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( impl_getPrintHelper() ) return m_pData->m_xPrintable->getPrinter(); @@ -1498,10 +1447,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SfxBaseModel::getPrinter() throw( void SAL_CALL SfxBaseModel::setPrinter(const uno::Sequence< beans::PropertyValue >& rPrinter) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( impl_getPrintHelper() ) m_pData->m_xPrintable->setPrinter( rPrinter ); @@ -1510,10 +1456,7 @@ void SAL_CALL SfxBaseModel::setPrinter(const uno::Sequence< beans::PropertyValue void SAL_CALL SfxBaseModel::print(const uno::Sequence< beans::PropertyValue >& rOptions) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( impl_getPrintHelper() ) m_pData->m_xPrintable->print( rOptions ); @@ -1525,10 +1468,7 @@ void SAL_CALL SfxBaseModel::print(const uno::Sequence< beans::PropertyValue >& r sal_Bool SAL_CALL SfxBaseModel::hasLocation() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->HasName() : sal_False; } @@ -1539,10 +1479,7 @@ sal_Bool SAL_CALL SfxBaseModel::hasLocation() throw(::com::sun::star::uno::Runti ::rtl::OUString SAL_CALL SfxBaseModel::getLocation() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) { @@ -1562,10 +1499,7 @@ sal_Bool SAL_CALL SfxBaseModel::hasLocation() throw(::com::sun::star::uno::Runti sal_Bool SAL_CALL SfxBaseModel::isReadonly() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); return m_pData->m_pObjectShell.Is() ? m_pData->m_pObjectShell->IsReadOnly() : sal_True; } @@ -1581,10 +1515,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const uno::Sequence< beans::PropertyVa { RTL_LOGFILE_PRODUCT_CONTEXT( aPerfLog, "PERFORMANCE - SfxBaseModel::storeSelf" ); - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) { @@ -1682,10 +1613,7 @@ void SAL_CALL SfxBaseModel::storeAsURL( const ::rtl::OUString& { RTL_LOGFILE_PRODUCT_CONTEXT( aPerfLog, "PERFORMANCE - SfxBaseModel::storeAsURL" ); - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) { @@ -1708,10 +1636,7 @@ void SAL_CALL SfxBaseModel::storeToURL( const ::rtl::OUString& const uno::Sequence< beans::PropertyValue >& rArgs ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() ) { @@ -1721,6 +1646,51 @@ void SAL_CALL SfxBaseModel::storeToURL( const ::rtl::OUString& } } +::sal_Bool SAL_CALL SfxBaseModel::wasModifiedSinceLastSave() throw ( RuntimeException ) +{ + SfxModelGuard aGuard( *this ); + return m_pData->m_bModifiedSinceLastSave; +} + +void SAL_CALL SfxBaseModel::storeToRecoveryFile( const ::rtl::OUString& i_TargetLocation, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException ) +{ + SfxModelGuard aGuard( *this ); + + // delegate + SfxSaveGuard aSaveGuard( this, m_pData, sal_False ); + impl_store( i_TargetLocation, i_MediaDescriptor, sal_True ); + + // no need for subsequent calls to storeToRecoveryFile, unless we're modified, again + m_pData->m_bModifiedSinceLastSave = sal_False; +} + +void SAL_CALL SfxBaseModel::recoverFromFile( const ::rtl::OUString& i_SourceLocation, const ::rtl::OUString& i_SalvagedFile, const Sequence< PropertyValue >& i_MediaDescriptor ) throw ( RuntimeException, IOException, WrappedTargetException ) +{ + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); + + // delegate to our "load" method + ::comphelper::NamedValueCollection aMediaDescriptor( i_MediaDescriptor ); + + // our load implementation expects the SalvagedFile to be in the media descriptor + OSL_ENSURE( !aMediaDescriptor.has( "SalvagedFile" ) || ( aMediaDescriptor.getOrDefault( "SalvagedFile", ::rtl::OUString() ) == i_SalvagedFile ), + "SfxBaseModel::recoverFromFile: inconsistent information!" ); + aMediaDescriptor.put( "SalvagedFile", i_SalvagedFile ); + + // similar for the to-be-loaded file + OSL_ENSURE( !aMediaDescriptor.has( "URL" ) || ( aMediaDescriptor.getOrDefault( "URL", ::rtl::OUString() ) == i_SourceLocation ), + "SfxBaseModel::recoverFromFile: inconsistent information!" ); + aMediaDescriptor.put( "URL", i_SourceLocation ); + + load( aMediaDescriptor.getPropertyValues() ); + + // Note: The XDocumentRecovery interface specification requires us to do an attachResource after loading. + // However, we will not do this here, as we know that our load implementation (respectively some method + // called from there) already did so. + // In particular, the load process might already have modified some elements of the media + // descriptor, for instance the MacroExecMode (in case the user was involved to decide about it), and we do + // not want to overwrite it with the "old" elements passed to this method here. +} + //________________________________________________________________________________________________________ // XLoadable //________________________________________________________________________________________________________ @@ -1731,10 +1701,9 @@ void SAL_CALL SfxBaseModel::initNew() ::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); + if ( IsInitialized() ) + throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this ); // the object shell should exist always DBG_ASSERT( m_pData->m_pObjectShell.Is(), "Model is useless without an ObjectShell" ); @@ -1763,10 +1732,9 @@ void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& ::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); + if ( IsInitialized() ) + throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this ); // the object shell should exist always DBG_ASSERT( m_pData->m_pObjectShell.Is(), "Model is useless without an ObjectShell" ); @@ -1910,6 +1878,13 @@ void SAL_CALL SfxBaseModel::load( const uno::Sequence< beans::PropertyValue >& nError ? nError : ERRCODE_IO_CANTREAD ); } } + + BOOL bHidden = FALSE; + SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False); + if ( pHidItem ) + bHidden = pHidItem->GetValue(); + // !TODO: will be done by Framework! + pMedium->SetUpdatePickList( !bHidden ); } } @@ -1922,10 +1897,7 @@ uno::Any SAL_CALL SfxBaseModel::getTransferData( const DATAFLAVOR& aFlavor ) ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Any aAny; @@ -2164,10 +2136,7 @@ uno::Any SAL_CALL SfxBaseModel::getTransferData( const DATAFLAVOR& aFlavor ) uno::Sequence< DATAFLAVOR > SAL_CALL SfxBaseModel::getTransferDataFlavors() throw (::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); sal_Int32 nSuppFlavors = GraphicHelper::supportsMetaFileHandle_Impl() ? 10 : 8; uno::Sequence< DATAFLAVOR > aFlavorSeq( nSuppFlavors ); @@ -2236,10 +2205,7 @@ uno::Sequence< DATAFLAVOR > SAL_CALL SfxBaseModel::getTransferDataFlavors() sal_Bool SAL_CALL SfxBaseModel::isDataFlavorSupported( const DATAFLAVOR& aFlavor ) throw (::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( aFlavor.MimeType.equalsAscii( "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" ) ) { @@ -2298,10 +2264,7 @@ sal_Bool SAL_CALL SfxBaseModel::isDataFlavorSupported( const DATAFLAVOR& aFlavor uno::Reference< container::XNameReplace > SAL_CALL SfxBaseModel::getEvents() throw( uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( ! m_pData->m_xEvents.is() ) { @@ -2317,9 +2280,7 @@ uno::Reference< container::XNameReplace > SAL_CALL SfxBaseModel::getEvents() thr uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getBasicLibraries() throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStorageBasedLibraryContainer > xBasicLibraries; if ( m_pData->m_pObjectShell ) @@ -2329,9 +2290,7 @@ uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::g uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::getDialogLibraries() throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::XStorageBasedLibraryContainer > xDialogLibraries; if ( m_pData->m_pObjectShell ) @@ -2341,9 +2300,7 @@ uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::g ::sal_Bool SAL_CALL SfxBaseModel::getAllowMacroExecution() throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell ) return m_pData->m_pObjectShell->AdjustMacroMode( String(), false ); @@ -2356,9 +2313,7 @@ uno::Reference< script::XStorageBasedLibraryContainer > SAL_CALL SfxBaseModel::g Reference< document::XEmbeddedScripts > SAL_CALL SfxBaseModel::getScriptContainer() throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); Reference< document::XEmbeddedScripts > xDocumentScripts; @@ -2394,10 +2349,7 @@ Reference< document::XEmbeddedScripts > SAL_CALL SfxBaseModel::getScriptContaine void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XDOCEVENTLISTENER >& aListener ) throw( uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0), aListener ); } @@ -2408,10 +2360,7 @@ void SAL_CALL SfxBaseModel::addEventListener( const uno::Reference< XDOCEVENTLIS void SAL_CALL SfxBaseModel::removeEventListener( const uno::Reference< XDOCEVENTLISTENER >& aListener ) throw( uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< XDOCEVENTLISTENER >*)0), aListener ); } @@ -2489,7 +2438,9 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , if ( pNamedHint ) { - if ( SFX_EVENT_STORAGECHANGED == pNamedHint->GetEventId() ) + switch ( pNamedHint->GetEventId() ) + { + case SFX_EVENT_STORAGECHANGED: { // for now this event is sent only on creation of a new storage for new document // and in case of reload of medium without document reload @@ -2520,12 +2471,17 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); } - else if ( SFX_EVENT_LOADFINISHED == pNamedHint->GetEventId() ) + break; + + case SFX_EVENT_LOADFINISHED: { impl_getPrintHelper(); ListenForStorage_Impl( m_pData->m_pObjectShell->GetStorage() ); + m_pData->m_bModifiedSinceLastSave = sal_False; } - else if ( SFX_EVENT_SAVEASDOCDONE == pNamedHint->GetEventId() ) + break; + + case SFX_EVENT_SAVEASDOCDONE: { m_pData->m_sURL = m_pData->m_pObjectShell->GetMedium()->GetName(); @@ -2536,9 +2492,20 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , addTitle_Impl( aArgs, aTitle ); attachResource( m_pData->m_pObjectShell->GetMedium()->GetName(), aArgs ); } - else if ( SFX_EVENT_DOCCREATED == pNamedHint->GetEventId() ) + break; + + case SFX_EVENT_DOCCREATED: { impl_getPrintHelper(); + m_pData->m_bModifiedSinceLastSave = sal_False; + } + break; + + case SFX_EVENT_MODIFYCHANGED: + { + m_pData->m_bModifiedSinceLastSave = isModified(); + } + break; } postEvent_Impl( pNamedHint->GetEventName() ); @@ -2572,36 +2539,29 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC , // public impl. //________________________________________________________________________________________________________ +void SfxBaseModel::NotifyModifyListeners_Impl() const +{ + ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0) ); + if ( pIC ) + { + lang::EventObject aEvent( (frame::XModel *)this ); + pIC->notifyEach( &util::XModifyListener::modified, aEvent ); + } + + // this notification here is done too generously, we cannot simply assume that we're really modified + // now, but we need to check it ... + m_pData->m_bModifiedSinceLastSave = const_cast< SfxBaseModel* >( this )->isModified(); +} + void SfxBaseModel::changing() { - // object already disposed? - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); // the notification should not be sent if the document can not be modified if ( !m_pData->m_pObjectShell.Is() || !m_pData->m_pObjectShell->IsEnableSetModified() ) return; - ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0) ); - if( pIC ) - - { - lang::EventObject aEvent( (frame::XModel *)this ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - try - { - ((XMODIFYLISTENER *)aIt.next())->modified( aEvent ); - } - catch( uno::RuntimeException& ) - { - aIt.remove(); - } - } - } + NotifyModifyListeners_Impl(); } void SfxBaseModel::impl_change() @@ -2610,24 +2570,7 @@ void SfxBaseModel::impl_change() if ( impl_isDisposed() ) return; - ::cppu::OInterfaceContainerHelper* pIC = m_pData->m_aInterfaceContainer.getContainer( ::getCppuType((const uno::Reference< XMODIFYLISTENER >*)0) ); - if( pIC ) - - { - lang::EventObject aEvent( (frame::XModel *)this ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - try - { - ((XMODIFYLISTENER *)aIt.next())->modified( aEvent ); - } - catch( uno::RuntimeException& ) - { - aIt.remove(); - } - } - } + NotifyModifyListeners_Impl(); } //________________________________________________________________________________________________________ @@ -2653,6 +2596,17 @@ sal_Bool SfxBaseModel::IsDisposed() const return ( m_pData == NULL ) ; } +sal_Bool SfxBaseModel::IsInitialized() const +{ + if ( !m_pData || !m_pData->m_pObjectShell ) + { + OSL_ENSURE( false, "SfxBaseModel::IsInitialized: this should have been caught earlier!" ); + return sal_False; + } + + return m_pData->m_pObjectShell->GetMedium() != NULL; +} + sal_Bool SfxBaseModel::impl_isDisposed() const { return ( m_pData == NULL ) ; @@ -2920,16 +2874,13 @@ void SfxBaseModel::postEvent_Impl( ::rtl::OUString aName ) uno::Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( m_pData->m_pObjectShell.Is() && !m_pData->m_contViewData.is() ) { SfxViewFrame *pActFrame = SfxViewFrame::Current(); if ( !pActFrame || pActFrame->GetObjectShell() != m_pData->m_pObjectShell ) - pActFrame = SfxViewFrame::GetFirst(m_pData->m_pObjectShell, TYPE(SfxTopViewFrame)); + pActFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell ); if ( !pActFrame || !pActFrame->GetViewShell() ) // currently no frame for this document at all or View is under construction @@ -2950,8 +2901,8 @@ uno::Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() sal_Int32 nCount = 0; uno::Sequence < beans::PropertyValue > aSeq; ::com::sun::star::uno::Any aAny; - for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst(m_pData->m_pObjectShell, TYPE(SfxTopViewFrame) ); pFrame; - pFrame = SfxViewFrame::GetNext(*pFrame, m_pData->m_pObjectShell, TYPE(SfxTopViewFrame) ) ) + for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst( m_pData->m_pObjectShell ); pFrame; + pFrame = SfxViewFrame::GetNext( *pFrame, m_pData->m_pObjectShell ) ) { BOOL bIsActive = ( pFrame == pActFrame ); pFrame->GetViewShell()->WriteUserDataSequence( aSeq ); @@ -2966,10 +2917,7 @@ uno::Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() void SAL_CALL SfxBaseModel::setViewData( const uno::Reference < container::XIndexAccess >& aData ) throw(::com::sun::star::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); m_pData->m_contViewData = aData; } @@ -3009,10 +2957,7 @@ sal_Bool SfxBaseModel::hasEventListeners() const void SAL_CALL SfxBaseModel::addPrintJobListener( const uno::Reference< view::XPrintJobListener >& xListener ) throw (uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); if ( impl_getPrintHelper() ) { @@ -3026,10 +2971,7 @@ void SAL_CALL SfxBaseModel::addPrintJobListener( const uno::Reference< view::XPr void SAL_CALL SfxBaseModel::removePrintJobListener( const uno::Reference< view::XPrintJobListener >& xListener ) throw (uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); if ( impl_getPrintHelper() ) { @@ -3048,7 +2990,7 @@ class SvObject; sal_Int64 SAL_CALL SfxBaseModel::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( !impl_isDisposed() && GetObjectShell() ) + if ( GetObjectShell() ) { SvGlobalName aName( aIdentifier ); if ( aName == SvGlobalName( SO3_GLOBAL_CLASSID ) ) @@ -3082,9 +3024,7 @@ void SfxBaseModel::ListenForStorage_Impl( const uno::Reference< embed::XStorage uno::Reference< XSTORAGE > SAL_CALL SfxBaseModel::getDocumentSubStorage( const ::rtl::OUString& aStorageName, sal_Int32 nMode ) throw ( uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< XSTORAGE > xResult; if ( m_pData->m_pObjectShell.Is() ) @@ -3109,9 +3049,7 @@ Sequence< ::rtl::OUString > SAL_CALL SfxBaseModel::getDocumentSubStoragesNames() throw ( io::IOException, RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); Sequence< ::rtl::OUString > aResult; sal_Int32 nResultSize = 0; @@ -3150,9 +3088,7 @@ Sequence< ::rtl::OUString > SAL_CALL SfxBaseModel::getDocumentSubStoragesNames() uno::Reference< script::provider::XScriptProvider > SAL_CALL SfxBaseModel::getScriptProvider() throw ( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< script::provider::XScriptProvider > xScriptProvider; @@ -3258,9 +3194,7 @@ static void ConvertSlotsToCommands( SfxObjectShell* pDoc, uno::Reference< contai uno::Reference< ui::XUIConfigurationManager > SAL_CALL SfxBaseModel::getUIConfigurationManager() throw ( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_xUIConfigurationManager.is() ) { @@ -3376,17 +3310,15 @@ void SAL_CALL SfxBaseModel::setVisualAreaSize( sal_Int64 nAspect, const awt::Siz uno::Exception, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::Exception(); // TODO: error handling - SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst( m_pData->m_pObjectShell, 0, sal_False ); - if ( pViewFrm && m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !pViewFrm->GetFrame()->IsInPlace() ) + SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False ); + if ( pViewFrm && m_pData->m_pObjectShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !pViewFrm->GetFrame().IsInPlace() ) { - Window* pWindow = VCLUnoHelper::GetWindow( pViewFrm->GetFrame()->GetFrameInterface()->getContainerWindow() ); + Window* pWindow = VCLUnoHelper::GetWindow( pViewFrm->GetFrame().GetFrameInterface()->getContainerWindow() ); Size aWinSize = pWindow->GetSizePixel(); awt::Size aCurrent = getVisualAreaSize( nAspect ); Size aDiff( aSize.Width-aCurrent.Width, aSize.Height-aCurrent.Height ); @@ -3410,9 +3342,7 @@ awt::Size SAL_CALL SfxBaseModel::getVisualAreaSize( sal_Int64 /*nAspect*/ ) uno::Exception, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::Exception(); // TODO: error handling @@ -3441,9 +3371,7 @@ sal_Int32 SAL_CALL SfxBaseModel::getMapUnit( sal_Int64 /*nAspect*/ ) throw ( uno::Exception, uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); if ( !m_pData->m_pObjectShell.Is() ) throw uno::Exception(); // TODO: error handling @@ -3457,9 +3385,7 @@ embed::VisualRepresentation SAL_CALL SfxBaseModel::getPreferredVisualRepresentat uno::Exception, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); datatransfer::DataFlavor aDataFlavor( ::rtl::OUString::createFromAscii( "application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\"" ), @@ -3485,44 +3411,34 @@ void SAL_CALL SfxBaseModel::loadFromStorage( const uno::Reference< XSTORAGE >& x EXCEPTION, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); + if ( IsInitialized() ) + throw ::com::sun::star::frame::DoubleInitializationException( ::rtl::OUString(), *this ); - if ( !m_pData->m_pObjectShell.Is() ) - throw IOEXCEPTION(); // TODO: + // after i36090 is fixed the pool from object shell can be used + // SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() ); + SfxAllItemSet aSet( SFX_APP()->GetPool() ); - if ( m_pData->m_pObjectShell.Is() ) - { - if( m_pData->m_pObjectShell->GetMedium() ) - // if a Medium is present, the document is already initialized - throw DOUBLEINITIALIZATIONEXCEPTION(); + // the BaseURL is part of the ItemSet + SfxMedium* pMedium = new SfxMedium( xStorage, String() ); + TransformParameters( SID_OPENDOC, aMediaDescriptor, aSet ); + pMedium->GetItemSet()->Put( aSet ); - // after i36090 is fixed the pool from object shell can be used - // SfxAllItemSet aSet( m_pData->m_pObjectShell->GetPool() ); - SfxAllItemSet aSet( SFX_APP()->GetPool() ); + // allow to use an interactionhandler (if there is one) + pMedium->UseInteractionHandler( TRUE ); - // the BaseURL is part of the ItemSet - SfxMedium* pMedium = new SfxMedium( xStorage, String() ); - TransformParameters( SID_OPENDOC, aMediaDescriptor, aSet ); - pMedium->GetItemSet()->Put( aSet ); - - // allow to use an interactionhandler (if there is one) - pMedium->UseInteractionHandler( TRUE ); - - SFX_ITEMSET_ARG( &aSet, pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False); - BOOL bTemplate = pTemplateItem && pTemplateItem->GetValue(); - m_pData->m_pObjectShell->SetActivateEvent_Impl( bTemplate ? SFX_EVENT_CREATEDOC : SFX_EVENT_OPENDOC ); - m_pData->m_pObjectShell->Get_Impl()->bOwnsStorage = FALSE; + SFX_ITEMSET_ARG( &aSet, pTemplateItem, SfxBoolItem, SID_TEMPLATE, sal_False); + BOOL bTemplate = pTemplateItem && pTemplateItem->GetValue(); + m_pData->m_pObjectShell->SetActivateEvent_Impl( bTemplate ? SFX_EVENT_CREATEDOC : SFX_EVENT_OPENDOC ); + m_pData->m_pObjectShell->Get_Impl()->bOwnsStorage = FALSE; - // load document - if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) - { - sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode(); - throw task::ErrorCodeIOException( ::rtl::OUString(), - uno::Reference< uno::XInterface >(), - nError ? nError : ERRCODE_IO_CANTREAD ); - } + // load document + if ( !m_pData->m_pObjectShell->DoLoad(pMedium) ) + { + sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode(); + throw task::ErrorCodeIOException( ::rtl::OUString(), + uno::Reference< uno::XInterface >(), + nError ? nError : ERRCODE_IO_CANTREAD ); } } @@ -3533,9 +3449,7 @@ void SAL_CALL SfxBaseModel::storeToStorage( const uno::Reference< XSTORAGE >& xS EXCEPTION, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< XSTORAGE > xResult; if ( !m_pData->m_pObjectShell.Is() ) @@ -3596,9 +3510,7 @@ void SAL_CALL SfxBaseModel::switchToStorage( const uno::Reference< XSTORAGE >& x EXCEPTION, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< XSTORAGE > xResult; if ( !m_pData->m_pObjectShell.Is() ) @@ -3622,9 +3534,7 @@ uno::Reference< XSTORAGE > SAL_CALL SfxBaseModel::getDocumentStorage() EXCEPTION, uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); uno::Reference< XSTORAGE > xResult; if ( !m_pData->m_pObjectShell.Is() ) @@ -3637,9 +3547,7 @@ void SAL_CALL SfxBaseModel::addStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw ( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); m_pData->m_aInterfaceContainer.addInterface( ::getCppuType((const uno::Reference< document::XStorageChangeListener >*)0), xListener ); @@ -3649,9 +3557,7 @@ void SAL_CALL SfxBaseModel::removeStorageChangeListener( const uno::Reference< document::XStorageChangeListener >& xListener ) throw ( uno::RuntimeException ) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); m_pData->m_aInterfaceContainer.removeInterface( ::getCppuType((const uno::Reference< document::XStorageChangeListener >*)0), xListener ); @@ -3677,9 +3583,7 @@ bool SfxBaseModel::impl_getPrintHelper() void SAL_CALL SfxBaseModel::setIdentifier(const ::rtl::OUString& Identifier) throw (css::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); m_pData->m_sModuleIdentifier = Identifier; } @@ -3688,9 +3592,7 @@ bool SfxBaseModel::impl_getPrintHelper() ::rtl::OUString SAL_CALL SfxBaseModel::getIdentifier() throw (css::uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return ::rtl::OUString(); + SfxModelGuard aGuard( *this ); if (m_pData->m_sModuleIdentifier.getLength() > 0) return m_pData->m_sModuleIdentifier; if (m_pData->m_pObjectShell) @@ -3701,10 +3603,7 @@ bool SfxBaseModel::impl_getPrintHelper() //============================================================================= css::uno::Reference< css::frame::XTitle > SfxBaseModel::impl_getTitleHelper () { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return css::uno::Reference< css::frame::XTitle >(); + SfxModelGuard aGuard( *this ); if ( ! m_pData->m_xTitleHelper.is ()) { @@ -3724,10 +3623,7 @@ css::uno::Reference< css::frame::XTitle > SfxBaseModel::impl_getTitleHelper () //============================================================================= css::uno::Reference< css::frame::XUntitledNumbers > SfxBaseModel::impl_getUntitledHelper () { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return css::uno::Reference< css::frame::XUntitledNumbers >(); + SfxModelGuard aGuard( *this ); if ( ! m_pData->m_xNumberedControllers.is ()) { @@ -3749,10 +3645,7 @@ css::uno::Reference< css::frame::XUntitledNumbers > SfxBaseModel::impl_getUntitl throw (css::uno::RuntimeException) { // SYNCHRONIZED -> - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return ::rtl::OUString(); + SfxModelGuard aGuard( *this ); ::rtl::OUString aResult = impl_getTitleHelper()->getTitle (); if ( m_pData->m_pObjectShell ) @@ -3783,10 +3676,7 @@ void SAL_CALL SfxBaseModel::setTitle( const ::rtl::OUString& sTitle ) throw (css::uno::RuntimeException) { // SYNCHRONIZED -> - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); impl_getTitleHelper()->setTitle (sTitle); } @@ -3797,10 +3687,7 @@ void SAL_CALL SfxBaseModel::addTitleChangeListener( const css::uno::Reference< c throw (css::uno::RuntimeException) { // SYNCHRONIZED -> - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this, SfxModelGuard::E_INITIALIZING ); css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY); if (xBroadcaster.is ()) @@ -3813,10 +3700,7 @@ void SAL_CALL SfxBaseModel::removeTitleChangeListener( const css::uno::Reference throw (css::uno::RuntimeException) { // SYNCHRONIZED -> - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if ( impl_isDisposed() ) - return; + SfxModelGuard aGuard( *this ); css::uno::Reference< css::frame::XTitleChangeBroadcaster > xBroadcaster(impl_getTitleHelper(), css::uno::UNO_QUERY); if (xBroadcaster.is ()) @@ -3829,10 +3713,7 @@ void SAL_CALL SfxBaseModel::removeTitleChangeListener( const css::uno::Reference throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return css::frame::UntitledNumbersConst::INVALID_NUMBER; + SfxModelGuard aGuard( *this ); return impl_getUntitledHelper ()->leaseNumber (xComponent); } @@ -3843,11 +3724,7 @@ void SAL_CALL SfxBaseModel::releaseNumber( ::sal_Int32 nNumber ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; - + SfxModelGuard aGuard( *this ); impl_getUntitledHelper ()->releaseNumber (nNumber); } @@ -3857,11 +3734,7 @@ void SAL_CALL SfxBaseModel::releaseNumberForComponent( const css::uno::Reference throw (css::lang::IllegalArgumentException, css::uno::RuntimeException ) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return; - + SfxModelGuard aGuard( *this ); impl_getUntitledHelper ()->releaseNumberForComponent (xComponent); } @@ -3870,11 +3743,7 @@ void SAL_CALL SfxBaseModel::releaseNumberForComponent( const css::uno::Reference ::rtl::OUString SAL_CALL SfxBaseModel::getUntitledPrefix() throw (css::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return ::rtl::OUString (); - + SfxModelGuard aGuard( *this ); return impl_getUntitledHelper ()->getUntitledPrefix (); } @@ -3883,10 +3752,7 @@ void SAL_CALL SfxBaseModel::releaseNumberForComponent( const css::uno::Reference css::uno::Reference< css::container::XEnumeration > SAL_CALL SfxBaseModel::getControllers() throw (css::uno::RuntimeException) { - // object already disposed? - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - return css::uno::Reference< css::container::XEnumeration >(); + SfxModelGuard aGuard( *this ); sal_Int32 c = m_pData->m_seqControllers.getLength(); sal_Int32 i = 0; @@ -3904,29 +3770,217 @@ css::uno::Reference< css::container::XEnumeration > SAL_CALL SfxBaseModel::getCo css::uno::Sequence< ::rtl::OUString > SAL_CALL SfxBaseModel::getAvailableViewControllerNames() throw (css::uno::RuntimeException) { - return css::uno::Sequence< ::rtl::OUString >(); + SfxModelGuard aGuard( *this ); + + const SfxObjectFactory& rDocumentFactory = GetObjectShell()->GetFactory(); + const sal_Int32 nViewFactoryCount = rDocumentFactory.GetViewFactoryCount(); + + Sequence< ::rtl::OUString > aViewNames( nViewFactoryCount ); + for ( sal_Int32 nViewNo = 0; nViewNo < nViewFactoryCount; ++nViewNo ) + aViewNames[nViewNo] = rDocumentFactory.GetViewFactory( nViewNo ).GetViewName(); + return aViewNames; } //============================================================================= // css::frame::XModel2 -css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createDefaultViewController(const css::uno::Reference< css::frame::XFrame >& /*Frame*/) +css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createDefaultViewController( const css::uno::Reference< css::frame::XFrame >& i_rFrame ) throw (css::uno::RuntimeException , css::lang::IllegalArgumentException, css::uno::Exception ) { - return css::uno::Reference< css::frame::XController2 >(); + SfxModelGuard aGuard( *this ); + + const SfxObjectFactory& rDocumentFactory = GetObjectShell()->GetFactory(); + const ::rtl::OUString sDefaultViewName = rDocumentFactory.GetViewFactory( 0 ).GetViewName(); + + aGuard.clear(); + + return createViewController( sDefaultViewName, Sequence< PropertyValue >(), i_rFrame ); +} + +//============================================================================= +namespace sfx { namespace intern { + + /** a class which, in its dtor, cleans up variuos objects (well, at the moment only the frame) collected during + the creation of a document view, unless the creation was successful. + */ + class SAL_DLLPRIVATE ViewCreationGuard + { + public: + ViewCreationGuard() + :m_bSuccess( false ) + { + } + + ~ViewCreationGuard() + { + if ( !m_bSuccess ) + impl_closeAll(); + } + + void takeFrameOwnership( SfxFrame* i_pFrame ) + { + OSL_PRECOND( !m_aWeakFrame, "ViewCreationGuard::takeFrameOwnership: already have a frame!" ); + OSL_PRECOND( i_pFrame != NULL, "ViewCreationGuard::takeFrameOwnership: invalid frame!" ); + m_aWeakFrame = i_pFrame; + } + + void releaseAll() + { + m_bSuccess = true; + } + + private: + void impl_closeAll() + { + if ( m_aWeakFrame && !m_aWeakFrame->GetCurrentDocument() ) + { + m_aWeakFrame->SetFrameInterface_Impl( NULL ); + m_aWeakFrame->DoClose(); + } + } + + private: + bool m_bSuccess; + SfxFrameWeak m_aWeakFrame; + }; +} } + +//============================================================================= +SfxViewFrame* SfxBaseModel::FindOrCreateViewFrame_Impl( const Reference< XFrame >& i_rFrame, ::sfx::intern::ViewCreationGuard& i_rGuard ) const +{ + SfxViewFrame* pViewFrame = NULL; + for ( pViewFrame = SfxViewFrame::GetFirst( GetObjectShell(), FALSE ); + pViewFrame; + pViewFrame= SfxViewFrame::GetNext( *pViewFrame, GetObjectShell(), FALSE ) + ) + { + if ( pViewFrame->GetFrame().GetFrameInterface() == i_rFrame ) + break; + } + if ( !pViewFrame ) + { + #if OSL_DEBUG_LEVEL > 0 + for ( SfxFrame* pCheckFrame = SfxFrame::GetFirst(); + pCheckFrame; + pCheckFrame = SfxFrame::GetNext( *pCheckFrame ) + ) + { + if ( pCheckFrame->GetFrameInterface() == i_rFrame ) + { + if ( ( pCheckFrame->GetCurrentViewFrame() != NULL ) + || ( pCheckFrame->GetCurrentDocument() != NULL ) + ) + // Note that it is perfectly letgitimate that during loading into an XFrame which already contains + // a document, there exist two SfxFrame instances bound to this XFrame - the old one, which will be + // destroyed later, and the new one, which we're going to create + continue; + + OSL_ENSURE( false, "SfxBaseModel::FindOrCreateViewFrame_Impl: there already is an SfxFrame for the given XFrame, but no view in it!" ); + // nowadays, we're the only instance allowed to create an SfxFrame for an XFrame, so this case here should not happen + break; + } + } + #endif + + SfxFrame* pTargetFrame = SfxFrame::Create( i_rFrame ); + ENSURE_OR_THROW( pTargetFrame, "could not create an SfxFrame" ); + i_rGuard.takeFrameOwnership( pTargetFrame ); + + // prepare it + pTargetFrame->PrepareForDoc_Impl( *GetObjectShell() ); + + // create view frame + pViewFrame = new SfxViewFrame( *pTargetFrame, GetObjectShell() ); + } + return pViewFrame; } //============================================================================= // css::frame::XModel2 -css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createViewController(const ::rtl::OUString& /*ViewName*/, - const css::uno::Sequence< css::beans::PropertyValue >& /*Arguments*/, - const css::uno::Reference< css::frame::XFrame >& /*Frame */) +css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createViewController( + const ::rtl::OUString& i_rViewName, const Sequence< PropertyValue >& i_rArguments, const Reference< XFrame >& i_rFrame ) throw (css::uno::RuntimeException , css::lang::IllegalArgumentException, css::uno::Exception ) { - return css::uno::Reference< css::frame::XController2 >(); + SfxModelGuard aGuard( *this ); + + if ( !i_rFrame.is() ) + throw css::lang::IllegalArgumentException( ::rtl::OUString(), *this, 3 ); + + // find the proper SFX view factory + SfxViewFactory* pViewFactory = GetObjectShell()->GetFactory().GetViewFactoryByViewName( i_rViewName ); + if ( !pViewFactory ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + + // determine previous shell (used in some special cases) + Reference< XController > xPreviousController( i_rFrame->getController() ); + const Reference< XModel > xMe( this ); + if ( ( xPreviousController.is() ) + && ( xMe != xPreviousController->getModel() ) + ) + { + xPreviousController.clear(); + } + SfxViewShell* pOldViewShell = SfxViewShell::Get( xPreviousController ); + OSL_ENSURE( !xPreviousController.is() || ( pOldViewShell != NULL ), + "SfxBaseModel::createViewController: invalid old controller!" ); + + // a guard which will clean up in case of failure + ::sfx::intern::ViewCreationGuard aViewCreationGuard; + + // determine the ViewFrame belonging to the given XFrame + SfxViewFrame* pViewFrame = FindOrCreateViewFrame_Impl( i_rFrame, aViewCreationGuard ); + OSL_POSTCOND( pViewFrame, "SfxBaseModel::createViewController: no frame?" ); + + // delegate to SFX' view factory + pViewFrame->GetBindings().ENTERREGISTRATIONS(); + SfxViewShell* pViewShell = pViewFactory->CreateInstance( pViewFrame, pOldViewShell ); + pViewFrame->GetBindings().LEAVEREGISTRATIONS(); + ENSURE_OR_THROW( pViewShell, "invalid view shell provided by factory" ); + + // by setting the ViewShell it is prevented that disposing the Controller will destroy this ViewFrame also + pViewFrame->GetDispatcher()->SetDisableFlags( 0 ); + pViewFrame->SetViewShell_Impl( pViewShell ); + + // remember ViewID + pViewFrame->SetCurViewId_Impl( pViewFactory->GetOrdinal() ); + + // ensure a default controller, if the view shell did not provide an own implementation + if ( !pViewShell->GetController().is() ) + pViewShell->SetController( new SfxBaseController( pViewShell ) ); + + // pass the creation arguments to the controller + SfxBaseController* pBaseController = pViewShell->GetBaseController_Impl(); + ENSURE_OR_THROW( pBaseController, "invalid controller implementation!" ); + pBaseController->SetCreationArguments_Impl( i_rArguments ); + + // some initial view settings, coming from our most recent attachResource call + ::comphelper::NamedValueCollection aDocumentLoadArgs( getArgs() ); + if ( aDocumentLoadArgs.getOrDefault( "ViewOnly", false ) ) + pViewFrame->GetFrame().SetMenuBarOn_Impl( FALSE ); + + const sal_Int16 nPluginMode = aDocumentLoadArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) ); + if ( nPluginMode == 1 ) + { + pViewFrame->ForceOuterResize_Impl( FALSE ); + pViewFrame->GetBindings().HidePopups( TRUE ); + + SfxFrame& rFrame = pViewFrame->GetFrame(); + // MBA: layoutmanager of inplace frame starts locked and invisible + rFrame.GetWorkWindow_Impl()->MakeVisible_Impl( FALSE ); + rFrame.GetWorkWindow_Impl()->Lock_Impl( TRUE ); + + rFrame.GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); + pViewFrame->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); + } + + // tell the guard we were successful + aViewCreationGuard.releaseAll(); + + // outta gere + return pBaseController; } //============================================================================= @@ -3936,9 +3990,7 @@ css::uno::Reference< css::frame::XController2 > SAL_CALL SfxBaseModel::createVie uno::Reference< rdf::XRepository > SAL_CALL SfxBaseModel::getRDFRepository() throw (uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -3953,9 +4005,7 @@ SfxBaseModel::getRDFRepository() throw (uno::RuntimeException) ::rtl::OUString SAL_CALL SfxBaseModel::getStringValue() throw (uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -3970,9 +4020,7 @@ SfxBaseModel::getStringValue() throw (uno::RuntimeException) ::rtl::OUString SAL_CALL SfxBaseModel::getNamespace() throw (uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -3986,9 +4034,7 @@ SfxBaseModel::getNamespace() throw (uno::RuntimeException) ::rtl::OUString SAL_CALL SfxBaseModel::getLocalName() throw (uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4005,9 +4051,7 @@ SfxBaseModel::getElementByMetadataReference( const ::com::sun::star::beans::StringPair & i_rReference) throw (uno::RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4022,9 +4066,7 @@ uno::Reference< rdf::XMetadatable > SAL_CALL SfxBaseModel::getElementByURI(const uno::Reference< rdf::XURI > & i_xURI) throw (uno::RuntimeException, lang::IllegalArgumentException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4040,9 +4082,7 @@ SfxBaseModel::getMetadataGraphsWithType( const uno::Reference<rdf::XURI> & i_xType) throw (uno::RuntimeException, lang::IllegalArgumentException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4059,9 +4099,7 @@ SfxBaseModel::addMetadataFile(const ::rtl::OUString & i_rFileName, throw (uno::RuntimeException, lang::IllegalArgumentException, container::ElementExistException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4082,9 +4120,7 @@ throw (uno::RuntimeException, lang::IllegalArgumentException, datatransfer::UnsupportedFlavorException, container::ElementExistException, rdf::ParseException, io::IOException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4102,9 +4138,7 @@ SfxBaseModel::removeMetadataFile( throw (uno::RuntimeException, lang::IllegalArgumentException, container::NoSuchElementException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4120,9 +4154,7 @@ SfxBaseModel::addContentOrStylesFile(const ::rtl::OUString & i_rFileName) throw (uno::RuntimeException, lang::IllegalArgumentException, container::ElementExistException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4138,9 +4170,7 @@ SfxBaseModel::removeContentOrStylesFile(const ::rtl::OUString & i_rFileName) throw (uno::RuntimeException, lang::IllegalArgumentException, container::NoSuchElementException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4159,9 +4189,7 @@ SfxBaseModel::loadMetadataFromStorage( throw (uno::RuntimeException, lang::IllegalArgumentException, lang::WrappedTargetException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( m_pData->CreateDMAUninitialized()); @@ -4189,9 +4217,7 @@ SfxBaseModel::storeMetadataToStorage( throw (uno::RuntimeException, lang::IllegalArgumentException, lang::WrappedTargetException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { @@ -4208,9 +4234,7 @@ SfxBaseModel::loadMetadataFromMedium( throw (uno::RuntimeException, lang::IllegalArgumentException, lang::WrappedTargetException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( m_pData->CreateDMAUninitialized()); @@ -4237,9 +4261,7 @@ SfxBaseModel::storeMetadataToMedium( throw (uno::RuntimeException, lang::IllegalArgumentException, lang::WrappedTargetException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( impl_isDisposed() ) - throw lang::DisposedException(); + SfxModelGuard aGuard( *this ); const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(m_pData->GetDMA()); if (!xDMA.is()) { diff --git a/sfx2/source/doc/sfxmodelfactory.cxx b/sfx2/source/doc/sfxmodelfactory.cxx index 3cc9d022538f..714dfc2ea824 100644 --- a/sfx2/source/doc/sfxmodelfactory.cxx +++ b/sfx2/source/doc/sfxmodelfactory.cxx @@ -149,7 +149,8 @@ namespace sfx2 static bool isSpecialArgumentName( const ::rtl::OUString& _rValueName ) { return _rValueName.equalsAscii( "EmbeddedObject" ) - || _rValueName.equalsAscii( "EmbeddedScriptSupport" ); + || _rValueName.equalsAscii( "EmbeddedScriptSupport" ) + || _rValueName.equalsAscii( "DocumentRecoverySupport" ); } bool operator()( const Any& _rArgument ) const @@ -171,15 +172,17 @@ namespace sfx2 ::comphelper::NamedValueCollection aArgs( _rArguments ); const sal_Bool bEmbeddedObject = aArgs.getOrDefault( "EmbeddedObject", sal_False ); const sal_Bool bScriptSupport = aArgs.getOrDefault( "EmbeddedScriptSupport", sal_True ); + const sal_Bool bDocRecoverySupport = aArgs.getOrDefault( "DocumentRecoverySupport", sal_True ); sal_uInt64 nCreationFlags = ( bEmbeddedObject ? SFXMODEL_EMBEDDED_OBJECT : 0 ) - | ( bScriptSupport ? 0 : SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ); + | ( bScriptSupport ? 0 : SFXMODEL_DISABLE_EMBEDDED_SCRIPTS ) + | ( bDocRecoverySupport ? 0 : SFXMODEL_DISABLE_DOCUMENT_RECOVERY ); Reference< XInterface > xInstance( impl_createInstance( nCreationFlags ) ); // to mimic the bahaviour of the default factory's createInstanceWithArguments, we initialize - // the object with the given arguments, stripped by the two special ones + // the object with the given arguments, stripped by the three special ones Sequence< Any > aStrippedArguments( _rArguments.getLength() ); Any* pStrippedArgs = aStrippedArguments.getArray(); Any* pStrippedArgsEnd = ::std::remove_copy_if( diff --git a/sfx2/source/inc/appdata.hxx b/sfx2/source/inc/appdata.hxx index b43ec53a614a..91305eb95cce 100644 --- a/sfx2/source/inc/appdata.hxx +++ b/sfx2/source/inc/appdata.hxx @@ -52,7 +52,6 @@ class SfxFilterMatcher; class SvUShorts; class ISfxTemplateCommon; class SfxFilterMatcher; -class SfxCancelManager; class SfxStatusDispatcher; class SfxDdeTriggerTopic_Impl; class SfxDocumentTemplates; @@ -108,7 +107,6 @@ public: // application members SfxFilterMatcher* pMatcher; - SfxCancelManager* pCancelMgr; ResMgr* pLabelResMgr; SfxStatusDispatcher* pAppDispatch; SfxDocumentTemplates* pTemplates; diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx index e015058ae280..a882cfedd821 100644 --- a/sfx2/source/inc/objshimp.hxx +++ b/sfx2/source/inc/objshimp.hxx @@ -32,6 +32,7 @@ #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> #include <com/sun/star/logging/XSimpleLogRing.hpp> #include <tools/datetime.hxx> @@ -61,7 +62,6 @@ class SfxBasicManagerHolder; struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess { ::comphelper::EmbeddedObjectContainer* mpObjectContainer; - SfxConfigManager* pCfgMgr; SfxBasicManagerHolder* pBasicManager; SfxObjectShell& rDocShell; @@ -79,10 +79,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_uInt16 nVisualDocumentNumber; sal_Int16 nDocumentSignatureState; sal_Int16 nScriptingSignatureState; - sal_Bool bTemplateConfig:1, - bInList:1, // ob per First/Next erreichbar + sal_Bool bInList:1, // ob per First/Next erreichbar bClosing:1, // sal_True w"aehrend Close(), um Benachrichtigungs-Rekursionen zu verhindern - bSetInPlaceObj:1, // sal_True, falls bereits versucht wurde pInPlaceObject zu casten bIsSaving:1, bPasswd:1, bIsTmp:1, @@ -93,14 +91,8 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess bInPrepareClose : 1, bPreparedForClose : 1, bWaitingForPicklist : 1,// Muss noch in die Pickliste - bModuleSearched : 1, - bIsHelpObjSh : 1, - bForbidCaching : 1, bForbidReload : 1, - bSupportsEventMacros: 1, - bLoadingWindows: 1, bBasicInitialized :1, - //bHidden :1, // indicates a hidden view shell bIsPrintJobCancelable :1, // Stampit disable/enable cancel button for print jobs ... default = true = enable! bOwnsStorage:1, bNoBaseURL:1, @@ -110,6 +102,7 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess bPreserveVersions:1, m_bMacroSignBroken:1, // whether the macro signature was explicitly broken m_bNoBasicCapabilities:1, + m_bDocRecoverySupport:1, bQueryLoadTemplate:1, bLoadReadonly:1, bUseUserData:1, @@ -117,36 +110,25 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess m_bSharedXMLFlag:1, // whether the flag should be stored in xml file m_bAllowShareControlFileClean:1; // whether the flag should be stored in xml file - String aNewName; // Der Name, unter dem das Doc gespeichert - // werden soll IndexBitSet aBitSet; sal_uInt32 lErr; sal_uInt16 nEventId; // falls vor Activate noch ein // Open/Create gesendet werden mu/s - sal_Bool bDoNotTouchDocInfo; - AutoReloadTimer_Impl *pReloadTimer; MarkData_Impl* pMarkData; sal_uInt16 nLoadedFlags; sal_uInt16 nFlagsInProgress; - String aMark; - Size aViewSize; // wird leider vom Writer beim - sal_Bool bInFrame; // HTML-Import gebraucht sal_Bool bModalMode; sal_Bool bRunningMacro; sal_Bool bReloadAvailable; sal_uInt16 nAutoLoadLocks; SfxModule* pModule; - SfxFrame* pFrame; - SfxToolBoxConfig* pTbxConfig; SfxObjectShellFlags eFlags; - svtools::AsynchronLink* pCloser; - String aBaseURL; sal_Bool bReadOnlyUI; SvRefBaseRef xHeaderAttributes; sal_Bool bHiddenLockedByAPI; - sal_Bool bInCloseEvent; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > xModel; + ::rtl::Reference< SfxBaseModel > + pBaseModel; sal_uInt16 nStyleFilter; sal_Bool bDisposing; @@ -159,9 +141,6 @@ struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess sal_Bool m_bCreateTempStor; ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > m_xDocStorage; - ::com::sun::star::uno::Reference< - ::com::sun::star::util::XModifyListener > m_xDocInfoListener; - sal_Bool m_bIsInit; ::rtl::OUString m_aSharedFileURL; diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx index 0e4f28feb3fe..4ac85a7c98fe 100644 --- a/sfx2/source/inet/inettbc.cxx +++ b/sfx2/source/inet/inettbc.cxx @@ -39,7 +39,6 @@ #include <com/sun/star/task/XInteractionHandler.hpp> #include <svl/eitem.hxx> #include <svl/stritem.hxx> -#include <svl/cancel.hxx> #include <unotools/historyoptions.hxx> #include <svl/folderrestriction.hxx> #include <vcl/toolbox.hxx> @@ -302,102 +301,3 @@ void SfxURLToolBoxControl_Impl::StateChanged } } -//*************************************************************************** -// SfxCancelToolBoxControl_Impl -//*************************************************************************** - -SFX_IMPL_TOOLBOX_CONTROL(SfxCancelToolBoxControl_Impl,SfxBoolItem) - -//*************************************************************************** - -SfxCancelToolBoxControl_Impl::SfxCancelToolBoxControl_Impl( USHORT nSlotId, USHORT nId, ToolBox& rBox ) : - SfxToolBoxControl( nSlotId, nId, rBox ) -{ -} - -//*************************************************************************** - -SfxPopupWindowType SfxCancelToolBoxControl_Impl::GetPopupWindowType() const -{ - return SFX_POPUPWINDOW_ONTIMEOUT; -} - -//*************************************************************************** - -SfxPopupWindow* SfxCancelToolBoxControl_Impl::CreatePopupWindow() -{ - PopupMenu aMenu; - BOOL bExecute = FALSE, bSeparator = FALSE; - USHORT nIndex = 1; - for ( SfxCancelManager *pCancelMgr = SfxViewFrame::Current()->GetTopViewFrame()->GetCancelManager(); - pCancelMgr; - pCancelMgr = pCancelMgr->GetParent() ) - { - for ( USHORT n=0; n<pCancelMgr->GetCancellableCount(); ++n ) - { - if ( !n && bSeparator ) - { - aMenu.InsertSeparator(); - bSeparator = FALSE; - } - String aItemText = pCancelMgr->GetCancellable(n)->GetTitle(); - if ( aItemText.Len() > 50 ) - { - aItemText.Erase( 48 ); - aItemText += DEFINE_CONST_UNICODE("..."); - } - aMenu.InsertItem( nIndex++, aItemText ); - bExecute = TRUE; - bSeparator = TRUE; - } - } - - ToolBox& rToolBox = GetToolBox(); - USHORT nId = bExecute ? aMenu.Execute( &rToolBox, rToolBox.GetPointerPosPixel() ) : 0; - GetToolBox().EndSelection(); -// ClearCache(); -// UpdateSlot(); - if ( nId ) - { - String aSearchText = aMenu.GetItemText(nId); - for ( SfxCancelManager *pCancelMgr = SfxViewFrame::Current()->GetTopViewFrame()->GetCancelManager(); - pCancelMgr; - pCancelMgr = pCancelMgr->GetParent() ) - { - for ( USHORT n = 0; n < pCancelMgr->GetCancellableCount(); ++n ) - { - SfxCancellable *pCancel = pCancelMgr->GetCancellable(n); - String aItemText = pCancel->GetTitle(); - if ( aItemText.Len() > 50 ) - { - aItemText.Erase( 48 ); - aItemText += DEFINE_CONST_UNICODE("..."); - } - - if ( aItemText == aSearchText ) - { - pCancel->Cancel(); - return 0; - } - } - } - - } - - return 0; -} - -//*************************************************************************** - -void SfxCancelToolBoxControl_Impl::StateChanged -( - USHORT nSID, - SfxItemState eState, - const SfxPoolItem* pState -) -{ - SfxVoidItem aVoidItem( nSID ); - //SfxToolBoxControl::StateChanged( nSID, eState, pState ? &aVoidItem : 0 ); - SfxToolBoxControl::StateChanged( nSID, eState, pState ); -} - diff --git a/sfx2/source/menu/mnuitem.cxx b/sfx2/source/menu/mnuitem.cxx index 210e1e886969..281b451d8098 100644 --- a/sfx2/source/menu/mnuitem.cxx +++ b/sfx2/source/menu/mnuitem.cxx @@ -453,7 +453,7 @@ SfxAppMenuControl_Impl::SfxAppMenuControl_Impl( Reference<com::sun::star::lang::XMultiServiceFactory> aXMultiServiceFactory(::comphelper::getProcessServiceFactory()); ::framework::MenuConfiguration aConf( aXMultiServiceFactory ); - Reference<com::sun::star::frame::XFrame> aXFrame( GetBindings().GetDispatcher_Impl()->GetFrame()->GetFrame()->GetFrameInterface() ); + Reference<com::sun::star::frame::XFrame> aXFrame( GetBindings().GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() ); pMenu = aConf.CreateBookmarkMenu( aXFrame, GetId() == SID_NEWDOCDIRECT ? BOOKMARK_NEWMENU : BOOKMARK_WIZARDMENU ); if( pMenu ) { diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index 8a7901836149..13c84bc531e2 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -345,7 +345,7 @@ void SfxVirtualMenu::CreateFromSVMenu() DBG_CHKTHIS(SfxVirtualMenu, 0); // Merge Addon popup menus into the SV Menu - Reference< com::sun::star::frame::XFrame > xFrame( pBindings->GetDispatcher()->GetFrame()->GetFrame()->GetFrameInterface() ); + Reference< com::sun::star::frame::XFrame > xFrame( pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface() ); if ( pSVMenu->IsMenuBar() ) { @@ -610,7 +610,7 @@ IMPL_LINK( SfxVirtualMenu, SettingsChanged, void*, EMPTYARG ) SfxViewFrame *pViewFrame = pBindings->GetDispatcher()->GetFrame(); BOOL bIcons = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus(); BOOL bIsHiContrastMode = IsHiContrastMode(); - Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame()->GetFrameInterface() ); + Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame().GetFrameInterface() ); if ( !bIsAddonPopupMenu ) { @@ -682,7 +682,7 @@ void SfxVirtualMenu::UpdateImages() BOOL bIsHiContrastMode = IsHiContrastMode(); USHORT nItemCount = pSVMenu->GetItemCount(); SfxViewFrame * pViewFrame = pBindings->GetDispatcher()->GetFrame(); - Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame()->GetFrameInterface() ); + Reference<com::sun::star::frame::XFrame> xFrame( pViewFrame->GetFrame().GetFrameInterface() ); for ( USHORT nSVPos=0; nSVPos < nItemCount; ++nSVPos ) { @@ -731,7 +731,7 @@ void SfxVirtualMenu::UpdateImages( Menu* pMenu ) { BOOL bIsHiContrastMode = IsHiContrastMode(); USHORT nItemCount = pMenu->GetItemCount(); - Reference<com::sun::star::frame::XFrame> aXFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame()->GetFrameInterface() ); + Reference<com::sun::star::frame::XFrame> aXFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() ); for ( USHORT nPos=0; nPos < nItemCount; ++nPos ) { @@ -900,7 +900,7 @@ void SfxVirtualMenu::InsertAddOnsMenuItem( Menu* pMenu ) // Create special popup menu that is filled with the 3rd party components popup menu items Reference<com::sun::star::lang::XMultiServiceFactory> aXMultiServiceFactory(::comphelper::getProcessServiceFactory()); ::framework::MenuConfiguration aConf( aXMultiServiceFactory ); - Reference<com::sun::star::frame::XFrame> xFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame()->GetFrameInterface() ); + Reference<com::sun::star::frame::XFrame> xFrame( pBindings->GetDispatcher_Impl()->GetFrame()->GetFrame().GetFrameInterface() ); PopupMenu* pAddonMenu = NULL; try diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index 4564043a2b0d..32e6887f802c 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -266,7 +266,7 @@ static void Execute( ANY& aEventData, const css::document::DocumentEvent& aTrigg { xProv = ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatchProvider > ( - pView->GetFrame()->GetFrameInterface(), UNO_QUERY ); + pView->GetFrame().GetFrameInterface(), UNO_QUERY ); } else { diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx index 2f6c4bb59903..090e94ecb63f 100644 --- a/sfx2/source/view/frame.cxx +++ b/sfx2/source/view/frame.cxx @@ -77,7 +77,7 @@ #include <sfx2/fcontnr.hxx> #include "impframe.hxx" #include <sfx2/appuno.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "workwin.hxx" #include <sfx2/sfxuno.hxx> #include <sfx2/msgpool.hxx> @@ -100,41 +100,29 @@ using namespace ::com::sun::star::container; TYPEINIT1(SfxFrame, SfxListener); TYPEINIT1_AUTOFACTORY(SfxFrameItem, SfxPoolItem); TYPEINIT1(SfxUsrAnyItem, SfxPoolItem); - -SfxFrame::SfxFrame(SfxFrame* pParent): - pParentFrame( pParent ), - pChildArr(0), - pUnoImp(0) -{ - pImp = new SfxFrame_Impl( this ); - if ( pParent ) - pParent->InsertChildFrame_Impl( this ); - if ( !pFramesArr_Impl ) - pFramesArr_Impl = new SfxFrameArr_Impl; - pFramesArr_Impl->Insert( this, pFramesArr_Impl->Count() ); -} +TYPEINIT1_AUTOFACTORY(SfxUnoFrameItem, SfxPoolItem); SvCompatWeakHdl* SfxFrame::GetHdl() { return pImp->GetHdl(); } -SfxCancelManager* SfxFrame::GetCancelManager() const +//-------------------------------------------------------------------- +void SfxFrame::Construct_Impl() { - SfxFrame *pFrame = GetTopFrame(); - SfxCancelManager*& rpMgr = pFrame->pImp->pCancelMgr; - if ( !rpMgr ) - { - rpMgr = new SfxCancelManager( SFX_APP()->GetCancelManager() ); - pFrame->pImp->StartListening( *rpMgr ); - } - return rpMgr; + pImp = new SfxFrame_Impl( this ); + if ( !pFramesArr_Impl ) + pFramesArr_Impl = new SfxFrameArr_Impl; + pFramesArr_Impl->Insert( this, pFramesArr_Impl->Count() ); } //-------------------------------------------------------------------- SfxFrame::~SfxFrame() { + RemoveTopFrame_Impl( this ); + DELETEZ( pWindow ); + pFramesArr_Impl->Remove( pFramesArr_Impl->GetPos( this ) ); if ( pParentFrame ) @@ -214,53 +202,6 @@ sal_Bool SfxFrame::DoClose_Impl() return bRet; } -void SfxFrame::Clear_Impl() -{ - CancelTransfers(); - - // Bei FrameSets verhindern, da\s das Closen der Childs zu st"andigen - // ReCalcs im SplitWindow f"uhrt; SetUpdateMode am FrameWindow wirkt - // leider nicht auf dem MAC - Window *pWin = NULL; - SfxViewShell *pViewSh; - if ( pImp->pCurrentViewFrame && - 0 != ( pViewSh = pImp->pCurrentViewFrame->GetViewShell() ) ) - { - pWin = pViewSh->GetWindow(); - if ( pWin ) - pWin->Hide(); - } - - sal_Bool bRet = sal_True; - SfxBindings* pBindings = NULL; - if ( pImp->pCurrentViewFrame ) - { - pBindings = &pImp->pCurrentViewFrame->GetBindings(); - pImp->bClosing = sal_True; - bRet = pImp->pCurrentViewFrame->Close(); - pImp->bClosing = sal_False; - } - - if ( bRet ) - { - // Bei internen Tasks m"ussen Controller und Tools abger"aumt werden - if ( pImp->pWorkWin ) - { - pImp->pWorkWin->DeleteControllers_Impl(); - DELETEZ( pImp->pWorkWin ); - } - - if ( pImp->bOwnsBindings ) - delete pBindings; - } - else - { - if ( pWin ) - pWin->Show(); - } -} - - sal_Bool SfxFrame::DocIsModified_Impl() { if ( pImp->pCurrentViewFrame && pImp->pCurrentViewFrame->GetObjectShell() && @@ -290,7 +231,7 @@ sal_uInt16 SfxFrame::PrepareClose_Impl( sal_Bool bUI, sal_Bool bForBrowsing ) for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur ); !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) ) { - bOther = ( pFrame->GetFrame() != this ); + bOther = ( &pFrame->GetFrame() != this ); } SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur) ); @@ -333,164 +274,19 @@ SfxFrame* SfxFrame::GetChildFrame( sal_uInt16 nPos ) const return 0L; } -void SfxFrame::InsertChildFrame_Impl( SfxFrame* pFrame, sal_uInt16 nPos ) -{ - if ( !pChildArr ) - pChildArr = new SfxFrameArr_Impl; - pChildArr->Insert( pFrame, nPos ); - pFrame->pParentFrame = this; -} - -void SfxFrame::RemoveChildFrame_Impl( sal_uInt16 nPos ) -{ - DBG_ASSERT( pChildArr, "Unbekannter Frame!"); - pChildArr->Remove( nPos ); -}; - void SfxFrame::RemoveChildFrame_Impl( SfxFrame* pFrame ) { DBG_ASSERT( pChildArr, "Unbekannter Frame!"); sal_uInt16 nPos = pChildArr->GetPos(pFrame); - RemoveChildFrame_Impl( nPos ); + pChildArr->Remove( nPos ); }; -sal_Bool SfxFrame::CloseChildFrames() -{ - sal_Bool bRet = sal_True; - if ( pChildArr ) - { - // Childs closen - sal_uInt16 nCount = pChildArr->Count(); - for ( sal_uInt16 n=nCount; n>0; n--) - { - SfxFrame* pFrame = (*pChildArr)[n-1]; - // pFrame removed sich selbst - bRet = pFrame->DoClose(); - if ( !bRet ) - break; - } - } - - return bRet; -} - -SfxFrame* SfxFrame::SearchChildrenForName_Impl( const String& rName, sal_Bool bDeep ) const -{ - if ( pChildArr ) - { - sal_uInt16 nCount = pChildArr->Count(); - for ( sal_uInt16 n=nCount; n>0; n--) - { - SfxFrame* pFrame = (*pChildArr)[n-1]; - if ( rName.CompareIgnoreCaseToAscii( pFrame->GetFrameName() ) == COMPARE_EQUAL ) - return pFrame; - if( bDeep ) - { - pFrame = pFrame->SearchChildrenForName_Impl( rName ); - if ( pFrame ) - return pFrame; - } - } - } - - return NULL; -} - -SfxFrame* SfxFrame::GetTopFrame() const +SfxFrame& SfxFrame::GetTopFrame() const { - SfxFrame *pParent = (SfxFrame*) this; + const SfxFrame* pParent = this; while ( pParent->pParentFrame ) pParent = pParent->pParentFrame; - return pParent; -} - -SfxFrame* SfxFrame::SearchFrame( const String& rName, SfxMedium* /*pMedium*/ ) -{ - // Weil Netscape f"uhrende BLANKS "uberliest, m"ussen wir das wohl auch - // Sollte besser auch bei den FrameNames gemacht werden! - String aFrameName( rName ); - aFrameName.EraseLeadingChars(); - - SfxFrame *pFrame = this; - if( !aFrameName.Len() || aFrameName.CompareIgnoreCaseToAscii("_self") == COMPARE_EQUAL ) - { - return pFrame; - } - else if ( aFrameName.CompareIgnoreCaseToAscii("_smartself") == COMPARE_EQUAL ) - { - DBG_ERROR("Not supported!"); - return pFrame; - } - else if ( aFrameName.CompareIgnoreCaseToAscii( GetFrameName() ) == COMPARE_EQUAL) - { - // Eigener Name, kein Name oder Selbstbezug - return pFrame; - } - else if ( aFrameName.CompareIgnoreCaseToAscii("_parent") == COMPARE_EQUAL ) - { - // Gesucht ist das Parent Frameset - return pParentFrame ? pParentFrame : this; - } - else if ( aFrameName.CompareIgnoreCaseToAscii("_blank") == COMPARE_EQUAL ) - { - return NULL; - } - else if ( aFrameName.CompareIgnoreCaseToAscii("_top") == COMPARE_EQUAL ) - { - while ( pFrame->GetParentFrame() ) - pFrame = pFrame->GetParentFrame(); - return pFrame; - } - else - { - // Zuerst unterhalb dieses Frames absuchen - pFrame = SearchChildrenForName_Impl( aFrameName ); - } - - if ( !pFrame && GetParentFrame() ) - { - // Noch nichts gefunden, nach oben weitergehen - // Eigentlich m"u\sten Frames, die schon abgesucht wurden, aus - // Performance-Gr"unden markiert werden - SfxFrame *pParent = GetParentFrame(); - do - { - // Ist es der Parent ? - if ( aFrameName.CompareIgnoreCaseToAscii( pParent->GetFrameName() ) == COMPARE_EQUAL ) - return pParent; - - // Weiter nach oben - pParent = pParent->GetParentFrame(); - } - while ( pParent ); - } - - if( !pFrame ) - { - SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames; - // keinen Frame im MDI-Fenster gefunden. Jetzt die anderen - // Toplevel Frames checken. - SfxFrame *pTop = GetTopFrame(); - for( sal_uInt16 nPos = rArr.Count(); nPos--; ) - { - // Unser Topframe wurde bereits durchsucht - SfxFrame* pCurFrame = rArr[ nPos ]; - if( pCurFrame != pTop ) - { - if( aFrameName.CompareIgnoreCaseToAscii( pCurFrame->GetFrameName() ) == - COMPARE_EQUAL ) - return pCurFrame; - else - { - pFrame = pCurFrame->SearchChildrenForName_Impl( aFrameName ); - if( pFrame ) - return pFrame; - } - } - } - } - - return pFrame; + return *const_cast< SfxFrame* >( pParent ); } sal_Bool SfxFrame::IsClosing_Impl() const @@ -503,21 +299,11 @@ void SfxFrame::SetIsClosing_Impl() pImp->bClosing = TRUE; } -void SfxFrame::DocumentInserted( SfxObjectShell* /*pDoc*/ ) -{ -} - sal_uInt16 SfxFrame::GetChildFrameCount() const { return pChildArr ? pChildArr->Count() : 0; } -sal_Bool SfxFrame::InsertDocument( SfxObjectShell* pDoc ) -{ - DocumentInserted( pDoc ); - return sal_True; -} - void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ ) { if( !pImp->bInCancelTransfers ) @@ -528,7 +314,7 @@ void SfxFrame::CancelTransfers( sal_Bool /*bCancelLoadEnv*/ ) { SfxViewFrame* pFrm; for( pFrm = SfxViewFrame::GetFirst( pObj ); - pFrm && pFrm->GetFrame() == this; + pFrm && &pFrm->GetFrame() == this; pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ; // Keine anderer Frame mehr auf Doc -> Cancel if( !pFrm ) @@ -566,12 +352,7 @@ SfxObjectShell* SfxFrame::GetCurrentDocument() const { return pImp->pCurrentViewFrame ? pImp->pCurrentViewFrame->GetObjectShell() : - pImp->pCurrentObjectShell; -} - -void SfxFrame::SetCurrentDocument_Impl( SfxObjectShell *pDoc ) -{ - pImp->pCurrentObjectShell = pDoc; + NULL; } void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame ) @@ -589,56 +370,10 @@ void SfxFrame::SetFrameType_Impl( sal_uInt32 n ) pImp->nType = n; } -void SfxFrame::CopyHistory_Impl( SfxFrame* /*pFrame*/ ) const -{ -} - - -void SfxFrame::ClearHistory() -{ -} - -sal_Bool SfxFrame::ExecuteHistoryMenu_Impl( sal_uInt16 /*nWhich*/, const Rectangle& /*rRect*/, sal_uInt16 /*nFlags*/ ) -{ - return sal_True; -} - -sal_Bool SfxFrame::Browse( sal_Bool /*bForward*/, sal_uInt16 /*nSteps*/, sal_Bool /*bNewFrame*/ ) -{ - return FALSE; -} - -void SfxFrame::UpdatePickEntries() -{ -} - -void SfxFrame::UpdatePickEntries( const ::com::sun::star::uno::Any& /*rValue*/ ) -{ -} - -void SfxFrame::UpdateUndoHistory_Impl( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/, const String* /*pTitle*/ ) -{ -} - -void SfxFrame::UpdateCurrentHistory_Impl( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/ ) -{ -} - -void SfxFrame::UpdateHistory( SfxObjectShell* /*pDocSh*/, const String* /*pNew*/ ) -{ -} - -void SfxFrame::UpdateHistory( - const ::rtl::OUString& /*aURL*/, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*aArgs*/, - const ::rtl::OUString& /*rTitle*/ ) -{ -} - void SfxFrame::GetViewData_Impl() { // Alle zwischen Laden und Entfernen "anderbaren Daten aktualisieren; die - // festen Daten werden nur einmal ( nach InsertDocument in UpdateDescriptor ) + // festen Daten werden nur einmal ( nach PrepareForDoc_Impl in UpdateDescriptor ) // geholt, um Zeit zu sparen. SfxViewFrame* pViewFrame = GetCurrentViewFrame(); if( pViewFrame && pViewFrame->GetViewShell() ) @@ -647,10 +382,7 @@ void SfxFrame::GetViewData_Impl() sal_Bool bReadOnly = pMed->GetOpenMode() == SFX_STREAM_READONLY; GetDescriptor()->SetReadOnly( bReadOnly ); - String aUserData; - pViewFrame->GetViewShell()->WriteUserData( aUserData, sal_True ); SfxItemSet *pSet = GetDescriptor()->GetArgs(); - pSet->Put( SfxStringItem( SID_USER_DATA, aUserData )); sal_Bool bGetViewData = sal_False; if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SFX_ITEM_SET ) { @@ -678,9 +410,9 @@ void SfxFrame::GetViewData_Impl() void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc ) { - // Beim InsertDocument wird der Descriptor des Frames aktualisiert + // Beim PrepareForDoc_Impl wird der Descriptor des Frames aktualisiert // und sein ItemSet neu initialisiert. Alle Daten, die f"ur ein sp"ateres - // Restaurieren der ::com::sun::star::sdbcx::View n"otig sind, sind damit festgehalten. + // Restaurieren der View n"otig sind, sind damit festgehalten. // Soll das Dokument ersetzt werden, wird durch GetViewData_Impl (s.o.) // die neueste Information hinzugef"ugt. Alles zusammen wird dann in der // Browse-History gesichert. Beim Aktivieren eines solchen FramePickEntry @@ -732,20 +464,6 @@ void SfxFrame::UpdateDescriptor( SfxObjectShell *pDoc ) //------------------------------------------------------------------------- -sal_Bool SfxFrame::CanBrowseBackward() const -{ - return FALSE; -} - -//------------------------------------------------------------------------- - -sal_Bool SfxFrame::CanBrowseForward() const -{ - return FALSE; -} - -//------------------------------------------------------------------------- - void SfxFrame::SetDescriptor( SfxFrameDescriptor *pD ) { DBG_ASSERT( pD, "Kein Descriptor!" ); @@ -793,14 +511,12 @@ void SfxFrame::GetTargetList( TargetList& rList ) const } SfxViewFrame* pView = GetCurrentViewFrame(); - if( pView && pView->GetViewShell() && !pView->GetViewShell()->IsImplementedAsFrameset_Impl() && pChildArr ) + if( pView && pView->GetViewShell() && pChildArr ) { sal_uInt16 nCount = pChildArr->Count(); for ( sal_uInt16 n=0; n<nCount; n++) { SfxFrame* pFrame = (*pChildArr)[n]; - if ( pFrame->GetFrameName().Len() ) - rList.Insert( new String (pFrame->GetFrameName()) ); pFrame->GetTargetList( rList ); } } @@ -808,147 +524,11 @@ void SfxFrame::GetTargetList( TargetList& rList ) const //------------------------------------------------------------------------- -void SfxFrame::SetFrameId_Impl( sal_uInt16 nId ) -{ - pImp->nFrameId = nId; - if ( GetCurrentViewFrame() ) - GetCurrentViewFrame()->UpdateTitle(); -} - -sal_uInt16 SfxFrame::GetFrameId_Impl() const -{ - return pImp->nFrameId; -} - -void SfxFrame::SetFrameIdName_Impl( const String& rName ) -{ - pImp->aFrameIdName = rName; -} - -//------------------------------------------------------------------------- - -SfxFrame* SfxFrame::SearchFrame_Impl( sal_uInt16 nId, sal_Bool bDeep ) -{ - if ( pImp->nFrameId == nId ) - return this; - - if ( pChildArr ) - { - sal_uInt16 nCount = pChildArr->Count(); - for ( sal_uInt16 n=0; n<nCount; n++) - { - SfxFrame* pFrame = (*pChildArr)[n]; - if ( pFrame->pImp->nFrameId == nId ) - return pFrame; - if ( bDeep ) - { - pFrame = pFrame->SearchFrame_Impl( nId, sal_True ); - if ( pFrame ) - return pFrame; - } - } - } - - return NULL; -} - -SfxFrame* SfxFrame::SearchFrame_Impl( const String& rName, sal_Bool bDeep ) -{ - if ( pImp->aFrameIdName == rName ) - return this; - - if ( pChildArr ) - { - sal_uInt16 nCount = pChildArr->Count(); - for ( sal_uInt16 n=0; n<nCount; n++) - { - SfxFrame* pFrame = (*pChildArr)[n]; - if ( pFrame->pImp->aFrameIdName == rName ) - return pFrame; - if ( bDeep ) - { - pFrame = pFrame->SearchFrame_Impl( rName ); - if ( pFrame ) - return pFrame; - } - } - } - - return NULL; -} - -//------------------------------------------------------------------------- - -//------------------------------------------------------------------------- - -void SfxFrame::Activate_Impl( sal_Bool bBeamerOn ) - -/* [Description] - - Internal Activate-Handler, called from derived classes which supports - Activate-Handling. -*/ - -{ - if ( GetParentFrame() ) - GetParentFrame()->Activate_Impl( bBeamerOn ); -} - SfxBroadcaster& SfxFrame::GetBroadcaster() const { return *pImp; } -//------------------------------------------------------------------------- - -void SfxFrame::Deactivate_Impl() - -/* [Description] - - Internal Deactivate-Handler, called from derived classes which supports - Activate-Handling. -*/ - -{ - if( GetParentFrame() ) - GetParentFrame()->Deactivate_Impl(); -} - -String SfxFrame::GetContent() const -{ - SfxObjectShell *pObj = GetCurrentDocument(); - if ( !pObj || !pObj->GetMedium() ) - return String(); - else - return pObj->GetMedium()->GetName(); -} - -sal_Bool SfxFrame::CheckContentForLoad_Impl() -{ - if ( GetCurrentDocument() ) - { - SfxMedium* pMedium = GetCurrentDocument()->GetMedium(); -#ifdef DEBUG - SfxItemSet* pSet; - pSet = pMedium->GetItemSet(); -#endif - SfxItemSet* pNew = GetDescriptor()->GetArgs(); - - // Falls URLs nicht uebereinstimmen - if ( INetURLObject( GetDescriptor()->GetActualURL() ) != INetURLObject( pMedium->GetOrigURL() ) ) - return sal_True; - - // Falls die Filter nicht uebereinstimmen - SFX_ITEMSET_ARG( pNew, pFilterItem, SfxStringItem, SID_FILTER_NAME, sal_False ); - if( pMedium->GetOrigFilter() && pFilterItem && pFilterItem->GetValue() != pMedium->GetOrigFilter()->GetFilterName() ) - return sal_True; - - return sal_False; - } - - return (GetDescriptor()->GetActualURL().GetMainURL( INetURLObject::NO_DECODE ).getLength() != 0); -} - sal_Bool SfxFrame::IsParent( SfxFrame *pFrame ) const { SfxFrame *pParent = pParentFrame; @@ -975,7 +555,7 @@ void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame ) } SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame *p ) - : SfxPoolItem( nWhichId ), pFrame( p ? p->GetFrame() : NULL ) + : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : NULL ) { wFrame = pFrame; } @@ -1058,11 +638,6 @@ int SfxUsrAnyItem::operator==( const SfxPoolItem& /*rItem*/ ) const return sal_False; } -String SfxUsrAnyItem::GetValueText() const -{ - return String(); -} - SfxPoolItem* SfxUsrAnyItem::Clone( SfxItemPool *) const { return new SfxUsrAnyItem( Which(), aValue ); @@ -1080,9 +655,37 @@ sal_Bool SfxUsrAnyItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*n return sal_True; } -sal_Bool SfxFrame::BrowseInFrame( int /*nDelta*/ ) +SfxUnoFrameItem::SfxUnoFrameItem() + : SfxPoolItem() + , m_xFrame() +{ +} + +SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame ) + : SfxPoolItem( nWhichId ) + , m_xFrame( i_rFrame ) { - return sal_False; +} + +int SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const +{ + return i_rItem.ISA( SfxUnoFrameItem ) && static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame; +} + +SfxPoolItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const +{ + return new SfxUnoFrameItem( Which(), m_xFrame ); +} + +sal_Bool SfxUnoFrameItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const +{ + rVal <<= m_xFrame; + return sal_True; +} + +sal_Bool SfxUnoFrameItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) +{ + return ( rVal >>= m_xFrame ); } SfxFrameIterator::SfxFrameIterator( const SfxFrame& rFrame, sal_Bool bRecur ) @@ -1129,116 +732,6 @@ SfxFrame* SfxFrameIterator::NextSibling_Impl( SfxFrame& rPrev ) return pRet; } -void SfxFrame::SetFrameName( const String& rName ) -{ - if ( pImp->pDescr ) - pImp->pDescr->SetName( rName ); - aName = rName; - if ( pImp->pCurrentViewFrame ) - pImp->pCurrentViewFrame->UpdateTitle(); - if ( GetFrameInterface().is() ) - GetFrameInterface()->setName( rName ); -} - -void SfxFrame::LoadFinished_Impl() -{ -} - -SfxFrame* SfxFrame::findFrame(const ::rtl::OUString& aTargetframename, sal_Int32 nSearchFlags) -{ - // Weil Netscape f"uhrende BLANKS "uberliest, m"ussen wir das wohl auch - // Sollte besser auch bei den FrameNames gemacht werden! - String aTargetName( aTargetframename ); - aTargetName.EraseLeadingChars(); - - SfxFrame *pFrame = this; - - if ( !aTargetName.Len() && GetParentFrame() && GetParentFrame()->GetCurrentViewFrame()->GetViewShell()->IsImplementedAsFrameset_Impl() ) - return GetParentFrame(); - - if( !aTargetName.Len() || aTargetName.CompareIgnoreCaseToAscii("_self") == COMPARE_EQUAL ) - return pFrame; - - if ( aTargetName.CompareIgnoreCaseToAscii("_smartself") == COMPARE_EQUAL ) - { - DBG_ERROR("Not supported!"); - return pFrame; - } - - if ( aTargetName.CompareIgnoreCaseToAscii("_parent") == COMPARE_EQUAL ) - { - // Gesucht ist das Parent Frameset - return pFrame->GetParentFrame(); - } - else if ( aTargetName.CompareIgnoreCaseToAscii("_blank") == COMPARE_EQUAL ) - { - return NULL; - - } - else if ( aTargetName.CompareIgnoreCaseToAscii("_top") == COMPARE_EQUAL ) - { - while ( pFrame->GetParentFrame() ) - pFrame = pFrame->GetParentFrame(); - return pFrame; - } - - if ( ( nSearchFlags & FRAME_SEARCH_SELF ) && aTargetName.CompareIgnoreCaseToAscii( GetFrameName() ) == COMPARE_EQUAL ) - { - // Eigener Name - return pFrame; - } - - if ( nSearchFlags & FRAME_SEARCH_CHILDREN ) - { - // Zuerst unterhalb dieses Frames absuchen - pFrame = SearchChildrenForName_Impl( aTargetName ); - } - - if ( ( nSearchFlags & FRAME_SEARCH_CHILDREN ) && !pFrame && GetParentFrame() ) - { - // Noch nichts gefunden, nach oben weitergehen - // Eigentlich m"u\sten Frames, die schon abgesucht wurden, aus - // Performance-Gr"unden markiert werden - SfxFrame *pParent = GetParentFrame(); - do - { - // Ist es der Parent ? - if ( aTargetName.CompareIgnoreCaseToAscii( pParent->GetFrameName() ) == COMPARE_EQUAL ) - return pParent; - - // Weiter nach oben - pParent = pParent->GetParentFrame(); - } - while ( pParent ); - } - - if( !pFrame ) - { - SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames; - // keinen Frame im MDI-Fenster gefunden. Jetzt die anderen - // Toplevel Frames checken. - SfxFrame *pTop = GetTopFrame(); - for( sal_uInt16 nPos = rArr.Count(); nPos--; ) - { - // Unser Topframe wurde bereits durchsucht - SfxFrame* pCurFrame = rArr[ nPos ]; - if( pCurFrame != pTop ) - { - if( aTargetName.CompareIgnoreCaseToAscii( pCurFrame->GetFrameName() ) == COMPARE_EQUAL ) - return pCurFrame; - else - { - pFrame = pCurFrame->SearchChildrenForName_Impl( aTargetName ); - if( pFrame ) - return pFrame; - } - } - } - } - - return pFrame; -} - sal_Bool SfxFrame::IsTop() const { return GetFrameInterface().is() ? GetFrameInterface()->isTop() : sal_False; @@ -1262,7 +755,7 @@ sal_Bool SfxFrame::HasComponent() const return pImp->xFrame; } -void SfxFrame::SetFrameInterface_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ) +void SfxFrame::SetFrameInterface_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame ) { pImp->xFrame = rFrame; com::sun::star::uno::Reference< com::sun::star::frame::XDispatchRecorder > xRecorder; @@ -1270,16 +763,6 @@ void SfxFrame::SetFrameInterface_Impl( ::com::sun::star::uno::Reference< ::com:: GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder ); } -void SfxFrame::SetItemSet_Impl( const SfxItemSet* pSet ) -{ - pImp->pSet = pSet; -} - -const SfxItemSet* SfxFrame::GetItemSet_Impl() -{ - return pImp->pSet; -} - void SfxFrame::Appear() { if ( GetCurrentViewFrame() ) @@ -1407,11 +890,6 @@ void SfxFrame::CreateWorkWindow_Impl() pImp->pWorkWin = new SfxFrameWorkWin_Impl( &pFrame->GetWindow(), this, pFrame ); } -const SvBorder& SfxFrame::GetBorder_Impl() const -{ - return pImp->aBorder; -} - void SfxFrame::GrabFocusOnComponent_Impl() { if ( pImp->bReleasingComponent ) @@ -1420,18 +898,12 @@ void SfxFrame::GrabFocusOnComponent_Impl() return; } - Window* pWindow = &GetWindow(); + Window* pFocusWindow = &GetWindow(); if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() ) - pWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow(); - - if( !pWindow->HasChildPathFocus() ) - pWindow->GrabFocus(); -} + pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow(); -const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > SfxFrame::GetInterceptor_Impl() -{ -//(mba)/compview: hier fehlt der Zugriff auf den Interceptor !!!!! - return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > (); + if( !pFocusWindow->HasChildPathFocus() ) + pFocusWindow->GrabFocus(); } void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet ) @@ -1439,36 +911,6 @@ void SfxFrame::ReleasingComponent_Impl( sal_Bool bSet ) pImp->bReleasingComponent = bSet; } -sal_Bool SfxFrame::LoadSfxComponent( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & /*aFrame*/, - const ::rtl::OUString& /*aURL*/, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& /*aArgs*/, - const SfxObjectFactory* /*pFact*/ ) -{ - // get Implementation of xComponents ... - DBG_ERROR( "Should not be called anymore!" ); - return sal_False; -} - -void SfxFrame::LockFocus_Impl( sal_Bool bLock ) -{ - if ( pChildArr && pChildArr->Count() ) - { - sal_uInt16 nCount = pChildArr->Count(); - for ( sal_uInt16 n=0; n<nCount; n++ ) - { - SfxFrame* pFrame = (*pChildArr)[n]; - pFrame->pImp->bFocusLocked = bLock; - pFrame->LockFocus_Impl( bLock ); - } - } -} - -sal_Bool SfxFrame::IsFocusLocked_Impl() const -{ - return pImp->bFocusLocked; -} - sal_Bool SfxFrame::IsInPlace() const { return pImp->bInPlace; @@ -1503,7 +945,7 @@ void SfxFrame::Resize() if ( nHandle ) { SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); - pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame()->GetWorkWindow_Impl(); + pWork = SfxViewFrame::GetFirst( pDoc )->GetFrame().GetWorkWindow_Impl(); } } @@ -1543,10 +985,10 @@ SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame ) return NULL; } -const SfxPoolItem* SfxFrame::LoadDocumentSynchron( SfxItemSet& aSet ) +const SfxPoolItem* SfxFrame::OpenDocumentSynchron( SfxItemSet& i_rSet, const Reference< XFrame >& i_rTargetFrame ) { - aSet.Put( SfxFrameItem( SID_DOCFRAME, this ) ); - aSet.ClearItem( SID_TARGETNAME ); - return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, aSet ); + i_rSet.Put( SfxUnoFrameItem( SID_FILLFRAME, i_rTargetFrame ) ); + i_rSet.ClearItem( SID_TARGETNAME ); + return SFX_APP()->GetDispatcher_Impl()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, i_rSet ); } diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx new file mode 100644 index 000000000000..d99ad8733e03 --- /dev/null +++ b/sfx2/source/view/frame2.cxx @@ -0,0 +1,484 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "impframe.hxx" +#include "objshimp.hxx" +#include "sfxhelp.hxx" +#include "workwin.hxx" + +#include "sfx2/app.hxx" +#include "sfx2/bindings.hxx" +#include "sfx2/dispatch.hxx" +#include "sfx2/docfac.hxx" +#include "sfx2/docfile.hxx" +#include "sfx2/event.hxx" +#include "sfx2/objface.hxx" +#include "sfx2/request.hxx" + +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/frame/XLayoutManager.hpp> + +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/itemset.hxx> +#include <svl/rectitem.hxx> +#include <svl/stritem.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/diagnose_ex.h> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::lang::XComponent; +using ::com::sun::star::frame::XComponentLoader; + +//------------------------------------------------------------------------ + +class SfxFrameWindow_Impl : public Window +{ +public: + SfxFrame* pFrame; + + SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow ); + ~SfxFrameWindow_Impl( ); + + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual long Notify( NotifyEvent& rEvt ); + virtual void Resize(); + virtual void GetFocus(); + void DoResize(); + DECL_LINK( CloserHdl, void* ); +}; + +SfxFrameWindow_Impl::SfxFrameWindow_Impl( SfxFrame* pF, Window& i_rContainerWindow ) + : Window( &i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK ) + , pFrame( pF ) +{ +} + +SfxFrameWindow_Impl::~SfxFrameWindow_Impl( ) +{ +} + +void SfxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) +{ + Window::DataChanged( rDCEvt ); + SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); + if ( pWorkWin ) + pWorkWin->DataChanged_Impl( rDCEvt ); +} + +long SfxFrameWindow_Impl::Notify( NotifyEvent& rNEvt ) +{ + if ( pFrame->IsClosing_Impl() || !pFrame->GetFrameInterface().is() ) + return sal_False; + + SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); + if ( !pView || !pView->GetObjectShell() ) + return Window::Notify( rNEvt ); + + if ( rNEvt.GetType() == EVENT_GETFOCUS ) + { + if ( pView->GetViewShell() && !pView->GetViewShell()->GetUIActiveIPClient_Impl() && !pFrame->IsInPlace() ) + { + DBG_TRACE("SfxFrame: GotFocus"); + pView->MakeActive_Impl( FALSE ); + } + + // TODO/LATER: do we still need this code? + Window* pWindow = rNEvt.GetWindow(); + ULONG nHelpId = 0; + while ( !nHelpId && pWindow ) + { + nHelpId = pWindow->GetHelpId(); + pWindow = pWindow->GetParent(); + } + + if ( nHelpId ) + SfxHelp::OpenHelpAgent( pFrame, nHelpId ); + + // if focus was on an external window, the clipboard content might have been changed + pView->GetBindings().Invalidate( SID_PASTE ); + pView->GetBindings().Invalidate( SID_PASTE_SPECIAL ); + return sal_True; + } + else if( rNEvt.GetType() == EVENT_KEYINPUT ) + { + if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) ) + return TRUE; + } + else if ( rNEvt.GetType() == EVENT_EXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTDISABLE*/ ) + { + pView->SetModalMode( sal_True ); + return sal_True; + } + else if ( rNEvt.GetType() == EVENT_ENDEXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTENABLE*/ ) + { + //EnableInput( sal_True, sal_True ); + pView->SetModalMode( sal_False ); + return sal_True; + } + + return Window::Notify( rNEvt ); +} + +long SfxFrameWindow_Impl::PreNotify( NotifyEvent& rNEvt ) +{ + USHORT nType = rNEvt.GetType(); + if ( nType == EVENT_KEYINPUT || nType == EVENT_KEYUP ) + { + SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); + SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; + if ( pShell && pShell->HasKeyListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) + return sal_True; + } + else if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN ) + { + Window* pWindow = rNEvt.GetWindow(); + SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); + SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; + if ( pShell ) + if ( pWindow == pShell->GetWindow() || pShell->GetWindow()->IsChild( pWindow ) ) + if ( pShell->HasMouseClickListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) + return sal_True; + } + + if ( nType == EVENT_MOUSEBUTTONDOWN ) + { + Window* pWindow = rNEvt.GetWindow(); + const MouseEvent* pMEvent = rNEvt.GetMouseEvent(); + Point aPos = pWindow->OutputToScreenPixel( pMEvent->GetPosPixel() ); + SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); + if ( pWorkWin ) + pWorkWin->EndAutoShow_Impl( aPos ); + } + + return Window::PreNotify( rNEvt ); +} + +void SfxFrameWindow_Impl::GetFocus() +{ + if ( pFrame && !pFrame->IsClosing_Impl() && pFrame->GetCurrentViewFrame() && pFrame->GetFrameInterface().is() ) + pFrame->GetCurrentViewFrame()->MakeActive_Impl( TRUE ); +} + +void SfxFrameWindow_Impl::Resize() +{ + if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) + DoResize(); +} + +void SfxFrameWindow_Impl::StateChanged( StateChangedType nStateChange ) +{ + if ( nStateChange == STATE_CHANGE_INITSHOW ) + { + pFrame->pImp->bHidden = FALSE; + if ( pFrame->IsInPlace() ) + // TODO/MBA: workaround for bug in LayoutManager: the final resize does not get through because the + // LayoutManager works asynchronously and between resize and time execution the DockingAcceptor was exchanged so that + // the resize event never is sent to the component + SetSizePixel( GetParent()->GetOutputSizePixel() ); + + DoResize(); + SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); + if ( pView ) + pView->GetBindings().GetWorkWindow_Impl()->ShowChilds_Impl(); + } + + Window::StateChanged( nStateChange ); +} + +void SfxFrameWindow_Impl::DoResize() +{ + if ( !pFrame->pImp->bLockResize ) + pFrame->Resize(); +} + +Reference < XFrame > SfxFrame::CreateBlankFrame() +{ + Reference < XFrame > xFrame; + try + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); + xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xFrame; +} + +SfxFrame* SfxFrame::Create( SfxObjectShell& rDoc, Window& rWindow, USHORT nViewId, bool bHidden ) +{ + SfxFrame* pFrame = NULL; + try + { + // create and initialize new top level frame for this window + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference < XFramesSupplier > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); + Reference < XFrame > xFrame( aContext.createComponent( "com.sun.star.frame.Frame"), UNO_QUERY_THROW ); + + Reference< awt::XWindow2 > xWin( VCLUnoHelper::GetInterface ( &rWindow ), uno::UNO_QUERY_THROW ); + xFrame->initialize( xWin.get() ); + xDesktop->getFrames()->append( xFrame ); + + if ( xWin->isActive() ) + xFrame->activate(); + + // create load arguments + Sequence< PropertyValue > aLoadArgs; + TransformItems( SID_OPENDOC, *rDoc.GetMedium()->GetItemSet(), aLoadArgs ); + + ::comphelper::NamedValueCollection aArgs( aLoadArgs ); + aArgs.put( "Model", rDoc.GetModel() ); + aArgs.put( "Hidden", bHidden ); + if ( nViewId ) + aArgs.put( "ViewId", nViewId ); + + aLoadArgs = aArgs.getPropertyValues(); + + // load the doc into that frame + ::rtl::OUString sLoaderURL( rDoc.GetModel()->getURL() ); + if ( sLoaderURL.getLength() == 0 ) + sLoaderURL = rDoc.GetFactory().GetFactoryURL(); + + Reference< XComponentLoader > xLoader( xFrame, UNO_QUERY_THROW ); + xLoader->loadComponentFromURL( + sLoaderURL, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), + 0, + aLoadArgs + ); + + for ( pFrame = SfxFrame::GetFirst(); + pFrame; + pFrame = SfxFrame::GetNext( *pFrame ) + ) + { + if ( pFrame->GetFrameInterface() == xFrame ) + break; + } + + OSL_ENSURE( pFrame, "SfxFrame::Create: load succeeded, but no SfxFrame was created during this!" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return pFrame; +} + +SfxFrame* SfxFrame::Create( const Reference < XFrame >& i_rFrame ) +{ + // create a new TopFrame to an external XFrame object ( wrap controller ) + ENSURE_OR_THROW( i_rFrame.is(), "NULL frame not allowed" ); + Window* pWindow = VCLUnoHelper::GetWindow( i_rFrame->getContainerWindow() ); + ENSURE_OR_THROW( pWindow, "frame without container window not allowed" ); + + SfxFrame* pFrame = new SfxFrame( *pWindow, false ); + pFrame->SetFrameInterface_Impl( i_rFrame ); + return pFrame; +} + +SfxFrame::SfxFrame( Window& i_rContainerWindow, bool i_bHidden ) + :pParentFrame( NULL ) + ,pChildArr( NULL ) + ,pImp( NULL ) + ,pWindow( NULL ) +{ + Construct_Impl(); + + pImp->bHidden = i_bHidden; + InsertTopFrame_Impl( this ); + pImp->pExternalContainerWindow = &i_rContainerWindow; + + pWindow = new SfxFrameWindow_Impl( this, i_rContainerWindow ); + + // always show pWindow, which is the ComponentWindow of the XFrame we live in + // nowadays, since SfxFrames can be created with an XFrame only, hiding or showing the complete XFrame + // is not done at level of the container window, not at SFX level. Thus, the component window can + // always be visible. + pWindow->Show(); +} + +void SfxFrame::SetPresentationMode( BOOL bSet ) +{ + if ( GetCurrentViewFrame() ) + GetCurrentViewFrame()->GetWindow().SetBorderStyle( bSet ? WINDOW_BORDER_NOBORDER : WINDOW_BORDER_NORMAL ); + + Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); + Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + + if ( xPropSet.is() ) + { + Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); + aValue >>= xLayoutManager; + } + + if ( xLayoutManager.is() ) + xLayoutManager->setVisible( !bSet ); // we don't want to have ui in presentation mode + + SetMenuBarOn_Impl( !bSet ); + if ( GetWorkWindow_Impl() ) + GetWorkWindow_Impl()->SetDockingAllowed( !bSet ); + if ( GetCurrentViewFrame() ) + GetCurrentViewFrame()->GetDispatcher()->Update_Impl( TRUE ); +} + +SystemWindow* SfxFrame::GetSystemWindow() const +{ + return GetTopWindow_Impl(); +} + +SystemWindow* SfxFrame::GetTopWindow_Impl() const +{ + if ( pImp->pExternalContainerWindow->IsSystemWindow() ) + return (SystemWindow*) pImp->pExternalContainerWindow; + else + return NULL; +} + +Window& SfxFrame::GetWindow() const +{ + return *pWindow; +} + +sal_Bool SfxFrame::Close() +{ + delete this; + return sal_True; +} + +void SfxFrame::LockResize_Impl( BOOL bLock ) +{ + pImp->bLockResize = bLock; +} + +IMPL_LINK( SfxFrameWindow_Impl, CloserHdl, void*, EMPTYARG ) +{ + if ( pFrame && !pFrame->PrepareClose_Impl( TRUE ) ) + return 0L; + + if ( pFrame ) + pFrame->GetCurrentViewFrame()->GetBindings().Execute( SID_CLOSEWIN, 0, 0, SFX_CALLMODE_ASYNCHRON ); + return 0L; +} + +void SfxFrame::SetMenuBarOn_Impl( BOOL bOn ) +{ + pImp->bMenuBarOn = bOn; + + Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); + Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + + if ( xPropSet.is() ) + { + Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); + aValue >>= xLayoutManager; + } + + if ( xLayoutManager.is() ) + { + rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )); + + if ( bOn ) + xLayoutManager->showElement( aMenuBarURL ); + else + xLayoutManager->hideElement( aMenuBarURL ); + } +} + +BOOL SfxFrame::IsMenuBarOn_Impl() const +{ + return pImp->bMenuBarOn; +} + +void SfxFrame::PositionWindow_Impl( const Rectangle& rWinArea ) const +{ + Window *pWin = pImp->pExternalContainerWindow; + + // Groesse setzen + const Size aAppWindow( pImp->pExternalContainerWindow->GetDesktopRectPixel().GetSize() ); + Point aPos( rWinArea.TopLeft() ); + Size aSz( rWinArea.GetSize() ); + if ( aSz.Width() && aSz.Height() ) + { + aPos.X() = Min(aPos.X(), + long(aAppWindow.Width() - aSz.Width() + aSz.Width() / 2) ); + aPos.Y() = Min(aPos.Y(), + long( aAppWindow.Height() - aSz.Height() + aSz.Height() / 2) ); + if ( aPos.X() + aSz.Width() < + aAppWindow.Width() + aSz.Width() / 2 && + aPos.Y() + aSz.Height() < + aAppWindow.Height() + aSz.Height() / 2 ) + { + pWin->SetPosPixel( aPos ); + pWin->SetOutputSizePixel( aSz ); + } + } +} + +void SfxFrame::PrepareForDoc_Impl( SfxObjectShell& i_rDoc ) +{ + const ::comphelper::NamedValueCollection aDocumentArgs( i_rDoc.GetModel()->getArgs() ); + + // hidden? + OSL_ENSURE( !pImp->bHidden, "when does this happen?" ); + pImp->bHidden = aDocumentArgs.getOrDefault( "Hidden", pImp->bHidden ); + + // update our descriptor + UpdateDescriptor( &i_rDoc ); + + // plugin mode + sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) ); + if ( nPluginMode && ( nPluginMode != 2 ) ) + SetInPlace_Impl( TRUE ); +} + +bool SfxFrame::IsMarkedHidden_Impl() const +{ + return pImp->bHidden; +} diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index e1177e0a7b5f..ed158ce009e3 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -29,70 +29,85 @@ #include "precompiled_sfx2.hxx" #include "frmload.hxx" - -#include <framework/interaction.hxx> -#include <com/sun/star/frame/XLoadable.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include "objshimp.hxx" +#include "viewfac.hxx" +#include "sfx2/app.hxx" +#include "sfx2/dispatch.hxx" +#include "sfx2/docfac.hxx" +#include "sfx2/docfile.hxx" +#include "sfx2/docfilt.hxx" +#include "sfx2/doctempl.hxx" +#include "sfx2/fcontnr.hxx" +#include "sfx2/frame.hxx" +#include "sfx2/request.hxx" +#include "sfx2/sfx.hrc" +#include "sfx2/sfxsids.hrc" +#include "sfx2/sfxuno.hxx" +#include "sfx2/viewfrm.hxx" +#include "sfx2/viewsh.hxx" + +/** === begin UNO includes === **/ #include <com/sun/star/container/XContainerQuery.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include <comphelper/processfactory.hxx> -#endif -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/task/XInteractionHandler.hpp> -#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> -#include <com/sun/star/ucb/CommandAbortedException.hpp> -#include <com/sun/star/ucb/InteractiveAppException.hpp> -#include <com/sun/star/document/XTypeDetection.hpp> -#include <framework/interaction.hxx> - -#ifndef _TOOLKIT_UNOHLP_HXX -#include <toolkit/helper/vclunohelper.hxx> -#endif -#include <ucbhelper/simpleinteractionrequest.hxx> +#include <com/sun/star/task/XInteractionHandler2.hpp> +#include <com/sun/star/document/XViewDataSupplier.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +/** === end UNO includes === **/ -#include <rtl/ustring.h> +#include <comphelper/interaction.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <framework/interaction.hxx> #include <rtl/logfile.hxx> -#include <svl/itemset.hxx> -#include <vcl/window.hxx> +#include <rtl/ustring.h> +#include <sot/storinfo.hxx> +#include <svtools/ehdl.hxx> #include <svl/eitem.hxx> +#include <svl/itemset.hxx> +#include <unotools/moduleoptions.hxx> +#include <svtools/sfxecode.hxx> #include <svl/stritem.hxx> -#include <tools/urlobj.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <tools/diagnose_ex.h> +#include <ucbhelper/simpleinteractionrequest.hxx> #include <vos/mutex.hxx> -#include <svtools/sfxecode.hxx> -#include <svtools/ehdl.hxx> -#include <sot/storinfo.hxx> -#include <comphelper/sequenceashashmap.hxx> -#include <comphelper/mediadescriptor.hxx> -#include <unotools/moduleoptions.hxx> - -#ifndef css -namespace css = ::com::sun::star; -#endif - -#include <sfx2/doctempl.hxx> -#include <sfx2/app.hxx> -#include <sfx2/request.hxx> -#include <sfx2/sfxsids.hrc> -#include <sfx2/dispatch.hxx> -#include <sfx2/sfxuno.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/topfrm.hxx> -#include <sfx2/frame.hxx> -#include <sfx2/docfac.hxx> -#include <sfx2/fcontnr.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/docfilt.hxx> -#include "brokenpackageint.hxx" -#include "objshimp.hxx" -SfxFrameLoader_Impl::SfxFrameLoader_Impl( const css::uno::Reference< css::lang::XMultiServiceFactory >& /*xFactory*/ ) +/** === begin UNO using === **/ +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::container::XContainerQuery; +using ::com::sun::star::container::XEnumeration; +using ::com::sun::star::document::XTypeDetection; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::frame::XLoadable; +using ::com::sun::star::frame::XModel; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::task::XInteractionHandler; +using ::com::sun::star::task::XInteractionHandler2; +using ::com::sun::star::task::XInteractionRequest; +using ::com::sun::star::task::XStatusIndicator; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +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::makeAny; +using ::com::sun::star::util::XCloseable; +using ::com::sun::star::document::XViewDataSupplier; +using ::com::sun::star::container::XIndexAccess; +using ::com::sun::star::frame::XController2; +using ::com::sun::star::frame::XController; +using ::com::sun::star::frame::XModel2; +/** === end UNO using === **/ + +SfxFrameLoader_Impl::SfxFrameLoader_Impl( const Reference< XMultiServiceFactory >& _rxFactory ) + :m_aContext( _rxFactory ) { } @@ -100,54 +115,46 @@ SfxFrameLoader_Impl::~SfxFrameLoader_Impl() { } -const SfxFilter* impl_detectFilterForURL(const ::rtl::OUString& sURL , - const css::uno::Sequence< css::beans::PropertyValue >& rArgs , - const SfxFilterMatcher& rMatcher) +// -------------------------------------------------------------------------------------------------------------------- +const SfxFilter* SfxFrameLoader_Impl::impl_detectFilterForURL( const ::rtl::OUString& sURL, + const ::comphelper::NamedValueCollection& i_rDescriptor, const SfxFilterMatcher& rMatcher ) const { - static ::rtl::OUString SERVICENAME_TYPEDETECTION = ::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection"); - ::rtl::OUString sFilter; try { - if (!sURL.getLength()) + if ( !sURL.getLength() ) return 0; - css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); - if (!xSMGR.is()) - return 0; + Reference< XTypeDetection > xDetect( + m_aContext.createComponent( "com.sun.star.document.TypeDetection" ), + UNO_QUERY_THROW); + + ::comphelper::NamedValueCollection aNewArgs; + aNewArgs.put( "URL", sURL ); - css::uno::Reference< css::document::XTypeDetection > xDetect( - xSMGR->createInstance(SERVICENAME_TYPEDETECTION), - css::uno::UNO_QUERY_THROW); - - ::comphelper::MediaDescriptor lOrgArgs(rArgs); - css::uno::Reference< css::task::XInteractionHandler > xInteraction = lOrgArgs.getUnpackedValueOrDefault( - ::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER(), - css::uno::Reference< css::task::XInteractionHandler >()); - css::uno::Reference< css::task::XStatusIndicator > xProgress = lOrgArgs.getUnpackedValueOrDefault( - ::comphelper::MediaDescriptor::PROP_STATUSINDICATOR(), - css::uno::Reference< css::task::XStatusIndicator >()); - - ::comphelper::SequenceAsHashMap lNewArgs; - lNewArgs[::comphelper::MediaDescriptor::PROP_URL()] <<= sURL; - if (xInteraction.is()) - lNewArgs[::comphelper::MediaDescriptor::PROP_INTERACTIONHANDLER()] <<= xInteraction; - if (xProgress.is()) - lNewArgs[::comphelper::MediaDescriptor::PROP_STATUSINDICATOR()] <<= xProgress; - - css::uno::Sequence< css::beans::PropertyValue > lDescr = lNewArgs.getAsConstPropertyValueList(); - ::rtl::OUString sType = xDetect->queryTypeByDescriptor(lDescr, sal_True); - if (sType.getLength()) + if ( i_rDescriptor.has( "InteractionHandler" ) ) + aNewArgs.put( "InteractionHandler", i_rDescriptor.get( "InteractionHandler" ) ); + if ( i_rDescriptor.has( "StatusIndicator" ) ) + aNewArgs.put( "StatusIndicator", i_rDescriptor.get( "StatusIndicator" ) ); + + Sequence< PropertyValue > aQueryArgs( aNewArgs.getPropertyValues() ); + ::rtl::OUString sType = xDetect->queryTypeByDescriptor( aQueryArgs, sal_True ); + if ( sType.getLength() ) { - const SfxFilter* pFilter = rMatcher.GetFilter4EA(sType); - if (pFilter) + const SfxFilter* pFilter = rMatcher.GetFilter4EA( sType ); + if ( pFilter ) sFilter = pFilter->GetName(); } } - catch(const css::uno::RuntimeException& exRun) - { throw exRun; } - catch(const css::uno::Exception&) - { sFilter = ::rtl::OUString(); } + catch ( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + sFilter = ::rtl::OUString(); + } const SfxFilter* pFilter = 0; if (sFilter.getLength()) @@ -155,453 +162,548 @@ const SfxFilter* impl_detectFilterForURL(const ::rtl::OUString& return pFilter; } -sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const css::uno::Sequence< css::beans::PropertyValue >& rArgs , - const css::uno::Reference< css::frame::XFrame >& rFrame ) - throw( css::uno::RuntimeException ) +// -------------------------------------------------------------------------------------------------------------------- +const SfxFilter* SfxFrameLoader_Impl::impl_getFilterFromServiceName_nothrow( const ::rtl::OUString& i_rServiceName ) const { - static ::rtl::OUString PROP_URL = ::rtl::OUString::createFromAscii("URL" ); - static ::rtl::OUString PROP_FILENAME = ::rtl::OUString::createFromAscii("FileName" ); - static ::rtl::OUString PROP_TYPENAME = ::rtl::OUString::createFromAscii("TypeName" ); - static ::rtl::OUString PROP_FILTERNAME = ::rtl::OUString::createFromAscii("FilterName" ); - static ::rtl::OUString PROP_MODEL = ::rtl::OUString::createFromAscii("Model" ); - static ::rtl::OUString PROP_DOCUMENTSERVICE = ::rtl::OUString::createFromAscii("DocumentService" ); - static ::rtl::OUString PROP_READONLY = ::rtl::OUString::createFromAscii("ReadOnly" ); - static ::rtl::OUString PROP_ASTEMPLATE = ::rtl::OUString::createFromAscii("AsTemplate" ); - static ::rtl::OUString PROP_INTERACTIONHANDLER = ::rtl::OUString::createFromAscii("InteractionHandler"); - - sal_Bool bLoadState = sal_False; - - // this methods assumes that the filter is detected before, usually by calling the detect() method below - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + try + { + ::comphelper::NamedValueCollection aQuery; + aQuery.put( "DocumentService", i_rServiceName ); - RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxFrameLoader::load" ); + const Reference< XContainerQuery > xQuery( + m_aContext.createComponent( "com.sun.star.document.FilterFactory" ), + UNO_QUERY_THROW ); - if ( !rFrame.is() ) - return sal_False; + const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher(); + const SfxFilterFlags nMust = SFX_FILTER_IMPORT; + const SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED; - ::comphelper::SequenceAsHashMap lDescriptor(rArgs); - String rURL = lDescriptor.getUnpackedValueOrDefault(PROP_URL , ::rtl::OUString() ); - String aTypeName = lDescriptor.getUnpackedValueOrDefault(PROP_TYPENAME , ::rtl::OUString() ); - aFilterName = lDescriptor.getUnpackedValueOrDefault(PROP_FILTERNAME , ::rtl::OUString() ); - String aServiceName = lDescriptor.getUnpackedValueOrDefault(PROP_DOCUMENTSERVICE , ::rtl::OUString() ); - css::uno::Reference< css::task::XInteractionHandler > xInteraction = lDescriptor.getUnpackedValueOrDefault(PROP_INTERACTIONHANDLER, css::uno::Reference< css::task::XInteractionHandler >()); - css::uno::Reference< css::frame::XModel > xModel = lDescriptor.getUnpackedValueOrDefault(PROP_MODEL , css::uno::Reference< css::frame::XModel >() ); + Reference < XEnumeration > xEnum( xQuery->createSubSetEnumerationByProperties( + aQuery.getNamedValues() ), UNO_SET_THROW ); + while ( xEnum->hasMoreElements() ) + { + ::comphelper::NamedValueCollection aType( xEnum->nextElement() ); + ::rtl::OUString sFilterName = aType.getOrDefault( "Name", ::rtl::OUString() ); + if ( !sFilterName.getLength() ) + continue; + + const SfxFilter* pFilter = rMatcher.GetFilter4FilterName( sFilterName ); + if ( !pFilter ) + continue; + + SfxFilterFlags nFlags = pFilter->GetFilterFlags(); + if ( ( ( nFlags & nMust ) == nMust ) + && ( ( nFlags & nDont ) == 0 ) + ) + { + return pFilter; + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return NULL; +} - const SfxFilter* pFilter = NULL; - const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher(); +// -------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SfxFrameLoader_Impl::impl_askForFilter_nothrow( const Reference< XInteractionHandler >& i_rxHandler, + const ::rtl::OUString& i_rDocumentURL ) const +{ + ENSURE_OR_THROW( i_rxHandler.is(), "invalid interaction handler" ); - /* special mode: use already loaded model ... - In such case no filter name will be selected and no URL will be given! - Such informations are not neccessary. We have to create a new view only - and call setComponent() at the corresponding frame. */ - if( !xModel.is() ) + ::rtl::OUString sFilterName; + try { + ::framework::RequestFilterSelect* pRequest = new ::framework::RequestFilterSelect( i_rDocumentURL ); + Reference< XInteractionRequest > xRequest ( pRequest ); + i_rxHandler->handle( xRequest ); + if( !pRequest->isAbort() ) + sFilterName = pRequest->getFilter(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } - // get filter by its name directly ... - if( aFilterName.Len() ) - pFilter = rMatcher.GetFilter4FilterName( aFilterName ); + return sFilterName; +} - // or search the preferred filter for the detected type ... - if( !pFilter && aTypeName.Len() ) - pFilter = rMatcher.GetFilter4EA(aTypeName); +// -------------------------------------------------------------------------------------------------------------------- +namespace +{ + sal_Bool lcl_getDispatchResult( const SfxPoolItem* _pResult ) + { + if ( !_pResult ) + return sal_False; - // or use given document service for detection too! - if (!pFilter && aServiceName.Len()) - { - ::comphelper::SequenceAsHashMap lQuery; + // default must be set to true, because some return values + // cant be checked, but nonetheless indicate "success"! + sal_Bool bSuccess = sal_True; - if (aServiceName.Len()) - lQuery[::rtl::OUString::createFromAscii("DocumentService")] <<= ::rtl::OUString(aServiceName); + // On the other side some special slots return a boolean state, + // which can be set to FALSE. + SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, _pResult ); + if ( pItem ) + bSuccess = pItem->GetValue(); - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); - ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > xQuery ( xServiceManager->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.document.FilterFactory" ) ), ::com::sun::star::uno::UNO_QUERY ); + return bSuccess; + } +} - SfxFilterFlags nMust = SFX_FILTER_IMPORT; - SfxFilterFlags nDont = SFX_FILTER_NOTINSTALLED; +// -------------------------------------------------------------------------------------------------------------------- +sal_Bool SfxFrameLoader_Impl::impl_createNewDocWithSlotParam( const USHORT _nSlotID, const Reference< XFrame >& i_rxFrame, + const bool i_bHidden ) +{ + SfxRequest aRequest( _nSlotID, SFX_CALLMODE_SYNCHRON, SFX_APP()->GetPool() ); + aRequest.AppendItem( SfxUnoFrameItem( SID_FILLFRAME, i_rxFrame ) ); + if ( i_bHidden ) + aRequest.AppendItem( SfxBoolItem( SID_HIDDEN, TRUE ) ); + return lcl_getDispatchResult( SFX_APP()->ExecuteSlot( aRequest ) ); +} - ::com::sun::star::uno::Reference < com::sun::star::container::XEnumeration > xEnum = xQuery->createSubSetEnumerationByProperties(lQuery.getAsConstNamedValueList()); - while ( xEnum->hasMoreElements() ) - { - ::comphelper::SequenceAsHashMap aType( xEnum->nextElement() ); - aFilterName = aType.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("Name"), ::rtl::OUString()); - if (!aFilterName.Len()) - continue; - pFilter = rMatcher.GetFilter4FilterName(aFilterName); - if (!pFilter) - continue; - SfxFilterFlags nFlags = pFilter->GetFilterFlags(); - if ( - ((nFlags & nMust) == nMust) && - (!(nFlags & nDont )) - ) - { - break; - } - pFilter = 0; //! in case we reach end of enumeration we must have a valid value ... - } - } +// -------------------------------------------------------------------------------------------------------------------- +void SfxFrameLoader_Impl::impl_lockHiddenDocument( SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor ) const +{ + const sal_Bool bHidden = i_rDescriptor.getOrDefault( "Hidden", sal_False ); + if ( !bHidden ) + return; + + const SfxViewFrame* pExistingViewFrame = SfxViewFrame::GetFirst( &i_rDocument ); + if ( pExistingViewFrame ) + return; + + // the document is to be loaded hidden, and it is not yet displayed in any other frame + // To prevent it from being closed when the loader returns, increase its OwnerLock + // (the OwnerLock is normally increased by every frame in which the document is displayed, and by this loader) + i_rDocument.RestoreNoDelete(); + i_rDocument.OwnerLock( TRUE ); + i_rDocument.Get_Impl()->bHiddenLockedByAPI = TRUE; +} - // or use interaction to ask user for right filter. - if ( !pFilter && xInteraction.is() && rURL.Len() ) - { - ::framework::RequestFilterSelect* pRequest = new ::framework::RequestFilterSelect( rURL ); - css::uno::Reference< css::task::XInteractionRequest > xRequest ( pRequest ); - xInteraction->handle( xRequest ); - if( !pRequest->isAbort() ) - { - aFilterName = pRequest->getFilter(); - pFilter = rMatcher.GetFilter4FilterName( aFilterName ); - } - } +// -------------------------------------------------------------------------------------------------------------------- +void SfxFrameLoader_Impl::impl_determineFilter( ::comphelper::NamedValueCollection& io_rDescriptor ) const +{ + const ::rtl::OUString sURL = io_rDescriptor.getOrDefault( "URL", ::rtl::OUString() ); + const ::rtl::OUString sTypeName = io_rDescriptor.getOrDefault( "TypeName", ::rtl::OUString() ); + const ::rtl::OUString sFilterName = io_rDescriptor.getOrDefault( "FilterName", ::rtl::OUString() ); + const ::rtl::OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() ); + const Reference< XInteractionHandler > + xInteraction = io_rDescriptor.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ); - if( !pFilter ) - return sal_False; + const SfxFilterMatcher& rMatcher = SFX_APP()->GetFilterMatcher(); + const SfxFilter* pFilter = NULL; + + // get filter by its name directly ... + if ( sFilterName.getLength() ) + pFilter = rMatcher.GetFilter4FilterName( sFilterName ); + + // or search the preferred filter for the detected type ... + if ( !pFilter && sTypeName.getLength() ) + pFilter = rMatcher.GetFilter4EA( sTypeName ); - aTypeName = pFilter->GetTypeName(); - // use filter names without prefix - aFilterName = pFilter->GetFilterName(); + // or use given document service for detection, too + if ( !pFilter && sServiceName.getLength() ) + pFilter = impl_getFilterFromServiceName_nothrow( sServiceName ); + + // or use interaction to ask user for right filter. + if ( !pFilter && xInteraction.is() && sURL.getLength() ) + { + ::rtl::OUString sSelectedFilter = impl_askForFilter_nothrow( xInteraction, sURL ); + if ( sSelectedFilter.getLength() ) + pFilter = rMatcher.GetFilter4FilterName( sSelectedFilter ); + } + + if ( pFilter ) + { + io_rDescriptor.put( "FilterName", ::rtl::OUString( pFilter->GetFilterName() ) ); // If detected filter indicates using of an own template format - // add property "AsTemplate" to descriptor. But supress this step + // add property "AsTemplate" to descriptor. But suppress this step // if such property already exists. - if( pFilter->IsOwnTemplateFormat()) + if ( pFilter->IsOwnTemplateFormat() && !io_rDescriptor.has( "AsTemplate" ) ) + io_rDescriptor.put( "AsTemplate", sal_Bool( sal_True ) ); + + // The DocumentService property will finally be used to determine the document type to create, so + // override it with the service name as indicated by the found filter. + io_rDescriptor.put( "DocumentService", ::rtl::OUString( pFilter->GetServiceName() ) ); + } +} + +// -------------------------------------------------------------------------------------------------------------------- +SfxObjectShellLock SfxFrameLoader_Impl::impl_findObjectShell( const Reference< XModel2 >& i_rxDocument ) const +{ + for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) ) + { + if ( i_rxDocument == pDoc->GetModel() ) { - ::comphelper::SequenceAsHashMap::iterator pIt = lDescriptor.find(PROP_ASTEMPLATE); - if (pIt == lDescriptor.end()) - lDescriptor[PROP_ASTEMPLATE] <<= sal_True; + return pDoc; } } - xFrame = rFrame; + DBG_ERROR( "SfxFrameLoader_Impl::impl_findObjectShell: model is not based on SfxObjectShell - wrong frame loader usage!" ); + return NULL; +} - // Achtung: beim Abraeumen der Objekte kann die SfxApp destruiert werden, vorher noch Deinitialize_Impl rufen - SfxApplication* pApp = SFX_APP(); +// -------------------------------------------------------------------------------------------------------------------- +bool SfxFrameLoader_Impl::impl_determineTemplateDocument( ::comphelper::NamedValueCollection& io_rDescriptor ) const +{ + const ::rtl::OUString sTemplateRegioName = io_rDescriptor.getOrDefault( "TemplateRegionName", ::rtl::OUString() ); + const ::rtl::OUString sTemplateName = io_rDescriptor.getOrDefault( "TemplateName", ::rtl::OUString() ); + const ::rtl::OUString sServiceName = io_rDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() ); + const ::rtl::OUString sURL = io_rDescriptor.getOrDefault( "URL", ::rtl::OUString() ); + + // determine the full URL of the template to use, if any + String sTemplateURL; + if ( sTemplateRegioName.getLength() && sTemplateName.getLength() ) + { + SfxDocumentTemplates aTmpFac; + aTmpFac.GetFull( sTemplateRegioName, sTemplateName, sTemplateURL ); + } + else + { + if ( sServiceName.getLength() ) + sTemplateURL = SfxObjectFactory::GetStandardTemplate( sServiceName ); + else + sTemplateURL = SfxObjectFactory::GetStandardTemplate( SfxObjectShell::GetServiceNameFromFactory( sURL ) ); + } - // Attention! Because lDescriptor is a copy of rArgs - // and was might by changed (e.g. for AsTemplate) - // move all changes there back! - SfxAllItemSet aSet( pApp->GetPool() ); - TransformParameters( SID_OPENDOC, lDescriptor.getAsConstPropertyValueList(), aSet ); + if ( sTemplateURL.Len() > 0 ) + { + // detect the filter for the template. Might still be NULL (if the template is broken, or does not + // exist, or some such), but this is handled by our caller the same way as if no template/URL was present. + const SfxFilter* pTemplateFilter = impl_detectFilterForURL( sTemplateURL, io_rDescriptor, SFX_APP()->GetFilterMatcher() ); + if ( pTemplateFilter ) + { + // load the template document, but, well, "as template" + io_rDescriptor.put( "FilterName", ::rtl::OUString( pTemplateFilter->GetName() ) ); + io_rDescriptor.put( "FileName", ::rtl::OUString( sTemplateURL ) ); + io_rDescriptor.put( "AsTemplate", sal_True ); - SFX_ITEMSET_ARG( &aSet, pRefererItem, SfxStringItem, SID_REFERER, FALSE ); - if ( !pRefererItem ) - aSet.Put( SfxStringItem( SID_REFERER, String() ) ); + // #i21583# + // the DocumentService property will finally be used to create the document. Thus, override any possibly + // present value with the document service of the template. + io_rDescriptor.put( "DocumentService", ::rtl::OUString( pTemplateFilter->GetServiceName() ) ); + return true; + } + } + return false; +} - SfxFrame* pFrame=0; - for ( pFrame = SfxFrame::GetFirst(); pFrame; pFrame = SfxFrame::GetNext( *pFrame ) ) +// -------------------------------------------------------------------------------------------------------------------- +USHORT SfxFrameLoader_Impl::impl_findSlotParam( const ::rtl::OUString& i_rFactoryURL ) const +{ + ::rtl::OUString sSlotParam; + const sal_Int32 nParamPos = i_rFactoryURL.indexOf( '?' ); + if ( nParamPos >= 0 ) { - if ( pFrame->GetFrameInterface() == xFrame ) - break; + // currently only the "slot" parameter is supported + const sal_Int32 nSlotPos = i_rFactoryURL.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "slot=" ), nParamPos ); + if ( nSlotPos > 0 ) + sSlotParam = i_rFactoryURL.copy( nSlotPos + 5 ); } - BOOL bFrameCreated = FALSE; - if ( !pFrame ) + if ( sSlotParam.getLength() ) + return USHORT( sSlotParam.toInt32() ); + + return 0; +} + +// -------------------------------------------------------------------------------------------------------------------- +void SfxFrameLoader_Impl::impl_handleCaughtError_nothrow( const Any& i_rCaughtError, const ::comphelper::NamedValueCollection& i_rDescriptor ) const +{ + try + { + const Reference< XInteractionHandler > xInteraction = + i_rDescriptor.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ); + if ( !xInteraction.is() ) + return; + ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( i_rCaughtError ) ); + ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove ); + pRequest->addContinuation( pApprove.get() ); + + const Reference< XInteractionHandler2 > xHandler( xInteraction, UNO_QUERY ); + #if OSL_DEBUG_LEVEL > 0 + const sal_Bool bHandled = + #endif + xHandler.is() && xHandler->handleInteractionRequest( pRequest.get() ); + + #if OSL_DEBUG_LEVEL > 0 + if ( !bHandled ) + // the interaction handler couldn't deal with this error + // => report it as assertion, at least (done in the DBG_UNHANDLED_EXCEPTION below) + ::cppu::throwException( i_rCaughtError ); + #endif + } + catch( const Exception& ) { - pFrame = SfxTopFrame::Create( rFrame ); - bFrameCreated = TRUE; + DBG_UNHANDLED_EXCEPTION(); } +} + +// -------------------------------------------------------------------------------------------------------------------- +void SfxFrameLoader_Impl::impl_removeLoaderArguments( ::comphelper::NamedValueCollection& io_rDescriptor ) +{ + // remove the arguments which are for the loader only, and not for a call to attachResource + io_rDescriptor.remove( "StatusIndicator" ); + io_rDescriptor.remove( "Model" ); +} - if ( xModel.is() ) +// -------------------------------------------------------------------------------------------------------------------- +::comphelper::NamedValueCollection SfxFrameLoader_Impl::impl_extractViewCreationArgs( ::comphelper::NamedValueCollection& io_rDescriptor ) +{ + const sal_Char* pKnownViewArgs[] = { + "JumpMark" + }; + + ::comphelper::NamedValueCollection aViewArgs; + for ( size_t i=0; i < sizeof( pKnownViewArgs ) / sizeof( pKnownViewArgs[0] ); ++i ) { - // !TODO: replace by ViewFactory - if ( pFrame->GetFrameInterface()->getController().is() ) + if ( io_rDescriptor.has( pKnownViewArgs[i] ) ) { - // remove old component - // if a frame was created already, it can't be an SfxComponent! - pFrame->GetFrameInterface()->setComponent( 0, 0 ); - if ( !bFrameCreated ) - pFrame = SfxTopFrame::Create( rFrame ); + aViewArgs.put( pKnownViewArgs[i], io_rDescriptor.get( pKnownViewArgs[i] ) ); + io_rDescriptor.remove( pKnownViewArgs[i] ); } + } + return aViewArgs; +} - aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) ); - - for ( SfxObjectShell* pDoc = SfxObjectShell::GetFirst( NULL, FALSE ); pDoc; pDoc = SfxObjectShell::GetNext( *pDoc, NULL, FALSE ) ) +// -------------------------------------------------------------------------------------------------------------------- +sal_Int16 SfxFrameLoader_Impl::impl_determineEffectiveViewId_nothrow( const SfxObjectShell& i_rDocument, const ::comphelper::NamedValueCollection& i_rDescriptor ) +{ + sal_Int16 nViewId = i_rDescriptor.getOrDefault( "ViewId", sal_Int16( 0 ) ); + try + { + if ( nViewId == 0 ) do { - if ( xModel == pDoc->GetModel() ) - { - pFrame->SetItemSet_Impl( &aSet ); - ::comphelper::SequenceAsHashMap lUpdateDescr( lDescriptor ); - lUpdateDescr.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ) ); - lUpdateDescr.erase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) ); - - xModel->attachResource( rURL, lUpdateDescr.getAsConstPropertyValueList() ); - return pFrame->InsertDocument( pDoc ); - } + Reference< XViewDataSupplier > xViewDataSupplier( i_rDocument.GetModel(), UNO_QUERY ); + Reference< XIndexAccess > xViewData; + if ( xViewDataSupplier.is() ) + xViewData.set( xViewDataSupplier->getViewData() ); + + if ( !xViewData.is() || ( xViewData->getCount() == 0 ) ) + // no view data stored together with the model + break; + + // obtain the ViewID from the view data + Sequence< PropertyValue > aViewData; + if ( !( xViewData->getByIndex( 0 ) >>= aViewData ) ) + break; + + ::comphelper::NamedValueCollection aNamedViewData( aViewData ); + ::rtl::OUString sViewId = aNamedViewData.getOrDefault( "ViewId", ::rtl::OUString() ); + if ( !sViewId.getLength() ) + break; + + // somewhat weird convention here ... in the view data, the ViewId is a string, effectively describing + // a view name. In the document load descriptor, the ViewId is in fact the numeric ID. + + SfxViewFactory* pViewFactory = i_rDocument.GetFactory().GetViewFactoryByViewName( sViewId ); + if ( pViewFactory ) + nViewId = sal_Int16( pViewFactory->GetOrdinal() ); } - - DBG_ERROR("Model is not based on SfxObjectShell - wrong frame loader use!"); - return sal_False; + while ( false ); } - - // check for the URL pattern of our factory URLs - SfxFrameWeak wFrame = pFrame; - String aPrefix = String::CreateFromAscii( "private:factory/" ); - String aFact( rURL ); - if ( aPrefix.Len() == aFact.Match( aPrefix ) ) + catch( const Exception& ) { - if ( !aServiceName.Len() ) - aServiceName = SfxObjectShell::GetServiceNameFromFactory( rURL ); + DBG_UNHANDLED_EXCEPTION(); + } - // it's a factory URL - aFact.Erase( 0, aPrefix.Len() ); + if ( nViewId == 0 ) + nViewId = i_rDocument.GetFactory().GetViewFactory( 0 ).GetOrdinal(); + return nViewId; +} - // look for parameters - String aParam; - USHORT nPos = aFact.Search( '?' ); - if ( nPos != STRING_NOTFOUND ) - { - // currently only the "slot" parameter is supported - USHORT nParamPos = aFact.Search( String::CreateFromAscii("slot="), nPos ); - if ( nParamPos != STRING_NOTFOUND ) - aParam = aFact.Copy( nParamPos+5, aFact.Len() ); - aFact.Erase( nPos, aFact.Len() ); - } +// -------------------------------------------------------------------------------------------------------------------- +Reference< XController2 > SfxFrameLoader_Impl::impl_createDocumentView( const Reference< XModel2 >& i_rModel, + const Reference< XFrame >& i_rFrame, const ::comphelper::NamedValueCollection& i_rViewFactoryArgs, + const ::rtl::OUString& i_rViewName ) +{ + // let the model create a new controller + const Reference< XController2 > xController( i_rModel->createViewController( + i_rViewName, + i_rViewFactoryArgs.getPropertyValues(), + i_rFrame + ), UNO_SET_THROW ); + + // introduce model/view/controller to each other + xController->attachModel( i_rModel.get() ); + i_rModel->connectController( xController.get() ); + i_rFrame->setComponent( xController->getComponentWindow(), xController.get() ); + xController->attachFrame( i_rFrame ); + i_rModel->setCurrentController( xController.get() ); + + return xController; +} - WildCard aSearchedFac( aFact.EraseAllChars('4').ToUpperAscii() ); - SFX_ITEMSET_ARG( &aSet, pDocumentTitleItem, SfxStringItem, SID_DOCINFO_TITLE, FALSE ); - INetURLObject aObj( rURL ); +// -------------------------------------------------------------------------------------------------------------------- +sal_Bool SAL_CALL SfxFrameLoader_Impl::load( const Sequence< PropertyValue >& rArgs, + const Reference< XFrame >& _rTargetFrame ) + throw( RuntimeException ) +{ + ENSURE_OR_THROW( _rTargetFrame.is(), "illegal NULL frame" ); - if ( aParam.Len() ) - { - sal_uInt16 nSlotId = (sal_uInt16) aParam.ToInt32(); - SfxRequest aReq( nSlotId, SFX_CALLMODE_SYNCHRON, pApp->GetPool() ); - aReq.AppendItem( SfxFrameItem ( SID_DOCFRAME, pFrame ) ); - const SfxPoolItem* pRet = pApp->ExecuteSlot( aReq ); - if ( pRet ) - { - // default must be set to true, because some return values - // cant be checked ... but indicates "success"! - bLoadState = sal_True; - - // On the other side some special slots return a boolean state, - // which can be set to FALSE. - SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet ); - if (pItem) - bLoadState = pItem->GetValue(); - } - else - bLoadState = sal_False; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); - if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() ) - { - css::uno::Reference< css::frame::XFrame > axFrame; - wFrame->SetFrameInterface_Impl( axFrame ); - wFrame->DoClose(); - } + RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxFrameLoader::load" ); - xFrame.clear(); - xListener.clear(); - return bLoadState; - } + ::comphelper::NamedValueCollection aDescriptor( rArgs ); - String sTemplateURL; - SFX_ITEMSET_ARG( &aSet, pTemplateRegionItem, SfxStringItem, SID_TEMPLATE_REGIONNAME, FALSE ); - SFX_ITEMSET_ARG( &aSet, pTemplateNameItem, SfxStringItem, SID_TEMPLATE_NAME, FALSE ); - if ( pTemplateRegionItem && pTemplateNameItem ) - { - SfxDocumentTemplates aTmpFac; - aTmpFac.GetFull( pTemplateRegionItem->GetValue(), pTemplateNameItem->GetValue(), sTemplateURL ); - } - else + // ensure the descriptor contains a referrer + if ( !aDescriptor.has( "Referer" ) ) + aDescriptor.put( "Referer", ::rtl::OUString() ); + + // TODO: is this needed? finally, when loading is successfull, then there should be no need for this item, + // as the document can always obtain its frame. In particular, there might be situations where this frame + // is accessed, but already disposed: Imagine the user loading a document, opening a second view on it, and + // then closing the first view/frame. + aDescriptor.put( "Frame", _rTargetFrame ); + + // did the caller already pass a model? + Reference< XModel2 > xModel = aDescriptor.getOrDefault( "Model", Reference< XModel2 >() ); + const bool bExternalModel = xModel.is(); + + // check for factory URLs to create a new doc, instead of loading one + const ::rtl::OUString sURL = aDescriptor.getOrDefault( "URL", ::rtl::OUString() ); + const bool bIsFactoryURL = ( sURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "private:factory/" ) ) == 0 ); + bool bInitNewModel = bIsFactoryURL; + if ( bIsFactoryURL && !bExternalModel ) + { + const ::rtl::OUString sFactory = sURL.copy( sizeof( "private:factory/" ) -1 ); + // special handling for some weird factory URLs a la private:factory/swriter?slot=21053 + const USHORT nSlotParam = impl_findSlotParam( sFactory ); + if ( nSlotParam != 0 ) { - sTemplateURL = SfxObjectFactory::GetStandardTemplate( aServiceName ); + return impl_createNewDocWithSlotParam( nSlotParam, _rTargetFrame, aDescriptor.getOrDefault( "Hidden", false ) ); } - BOOL bUseTemplate = (sTemplateURL.Len()>0); - if( bUseTemplate ) + const bool bDescribesValidTemplate = impl_determineTemplateDocument( aDescriptor ); + if ( bDescribesValidTemplate ) { - // #i21583# - // Forget the filter, which was detected for the corresponding "private:factory/xxx" URL. - // We must use the right filter, matching to this document ... not to the private URL! - const SfxFilter* pTemplateFilter = impl_detectFilterForURL(sTemplateURL, rArgs, rMatcher); - if (pTemplateFilter) - { - pFilter = pTemplateFilter; - aFilterName = pTemplateFilter->GetName(); - // standard template set -> load it "AsTemplate" - aSet.Put( SfxStringItem ( SID_FILE_NAME, sTemplateURL ) ); - aSet.Put( SfxBoolItem( SID_TEMPLATE, sal_True ) ); - } - - // #119268# - // something is wrong with the set default template (e.g. unknown format, missing file etcpp) - // The we have to jump into the following special code, where "private:factory/ URL's are handled. - // We cant "load" such private/factory URL's! - else - bUseTemplate = FALSE; + // if the media descriptor allowed us to determine a template document to create the new document + // from, then do not init a new document model from scratch (below), but instead load the + // template document + bInitNewModel = false; } - - if ( !bUseTemplate ) + else { - // execute "NewDocument" request - /* Attention! - #107913# - Pointers can't be used to check if two objects are equals! - E.g. the memory manager can reuse freed memory ... - and then the holded copy of a pointer will point to another - (and different!) object - may using the same type then before. - In such case we compare one object with itself ... - */ - SfxRequest aReq( SID_NEWDOCDIRECT, SFX_CALLMODE_SYNCHRON, aSet ); - aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, pFrame ) ); - aReq.AppendItem( SfxStringItem( SID_NEWDOCDIRECT, aFact ) ); - - if ( pDocumentTitleItem ) - aReq.AppendItem( *pDocumentTitleItem ); - - const SfxPoolItem* pRet = pApp->NewDocDirectExec_ImplOld(aReq); - if (pRet) - { - // default must be set to true, because some return values - // cant be checked ... but indicates "success"! - bLoadState = sal_True; - - // On the other side some special slots return a boolean state, - // which can be set to FALSE. - SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, pRet ); - if (pItem) - bLoadState = pItem->GetValue(); - } - else - bLoadState = sal_False; - - if ( !bLoadState && bFrameCreated && wFrame && !wFrame->GetCurrentDocument() ) - { - css::uno::Reference< css::frame::XFrame > axFrame; - wFrame->SetFrameInterface_Impl( axFrame ); - wFrame->DoClose(); - } - - xFrame.clear(); - xListener.clear(); - return bLoadState; + const ::rtl::OUString sServiceName = SfxObjectShell::GetServiceNameFromFactory( sFactory ); + aDescriptor.put( "DocumentService", sServiceName ); } } else { - // load the desired file - aSet.Put( SfxStringItem ( SID_FILE_NAME, rURL ) ); + // compatibility + aDescriptor.put( "FileName", aDescriptor.get( "URL" ) ); } - aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) ); - aSet.Put( SfxUnoAnyItem( SID_FILLFRAME, css::uno::makeAny(xFrame) ) ); - aSet.Put( SfxStringItem( SID_FILTER_NAME, aFilterName ) ); - - // !TODO: replace by direct construction of model (needs view factory) - DBG_ASSERT( pFilter, "No filter set!" ); - if ( !pFilter ) - return sal_False; - - sal_Bool bDisaster = sal_False; - SfxObjectShell* pDoc = SfxObjectShell::CreateObject( pFilter->GetServiceName() ); - if ( pDoc ) + sal_Bool bLoadSuccess = sal_False; + try { - css::uno::Reference< css::frame::XLoadable > xLoadable = css::uno::Reference< css::frame::XLoadable >( pDoc->GetModel(), css::uno::UNO_QUERY ); - css::uno::Sequence < css::beans::PropertyValue > aLoadArgs; - TransformItems( SID_OPENDOC, aSet, aLoadArgs ); - try + // extract view releant arguments from the loader args + ::comphelper::NamedValueCollection aViewCreationArgs( impl_extractViewCreationArgs( aDescriptor ) ); + + // no model passed from outside? => create one from scratch + if ( !xModel.is() ) { - xLoadable->load( aLoadArgs ); - - SfxMedium* pDocMedium = pDoc->GetMedium(); - BOOL bHidden = FALSE; - SFX_ITEMSET_ARG( pDocMedium->GetItemSet(), pHidItem, SfxBoolItem, SID_HIDDEN, sal_False); - if ( pHidItem ) - bHidden = pHidItem->GetValue(); - - // !TODO: will be done by Framework! - pDocMedium->SetUpdatePickList( !bHidden ); - - /* - #121119# - We dont know why pFrame can be corrupt here. - But if it was deleted it shouldnt exists inside our global list. - May be we can use the damaged pointer to detect if it was removed from - this global list. - */ - SfxFrame* pTmp=0; - for ( pTmp = SfxFrame::GetFirst(); pTmp; pTmp = SfxFrame::GetNext( *pTmp ) ) + // beforehand, determine the filter to use, and update the descriptor with its information + if ( !bInitNewModel ) { - if ( pFrame == pTmp ) - break; + impl_determineFilter( aDescriptor ); } - if ( pTmp == pFrame ) + // create the new doc + const ::rtl::OUString sServiceName = aDescriptor.getOrDefault( "DocumentService", ::rtl::OUString() ); + xModel.set( m_aContext.createComponent( sServiceName ), UNO_QUERY_THROW ); + + // load resp. init it + const Reference< XLoadable > xLoadable( xModel, UNO_QUERY_THROW ); + if ( bInitNewModel ) { - // !TODO: replace by ViewFactory - if ( pFrame->GetFrameInterface()->getController().is() ) - { - // remove old component - // if a frame was created already, it can't be an SfxComponent! - // pFrame->GetFrameInterface()->setComponent( 0, 0 ); - if ( !bFrameCreated ) - pFrame = SfxTopFrame::Create( rFrame ); - } - - wFrame = pFrame; - aSet.Put( SfxFrameItem( SID_DOCFRAME, pFrame ) ); - if( pFrame->InsertDocument( pDoc ) ) - { - pFrame->GetCurrentViewFrame()->UpdateDocument_Impl(); - String aURL = pDoc->GetMedium()->GetName(); - SFX_APP()->Broadcast( SfxStringHint( SID_OPENURL, aURL ) ); - bLoadState = sal_True; - } - else - bDisaster = sal_True; + xLoadable->initNew(); + + impl_removeLoaderArguments( aDescriptor ); + xModel->attachResource( ::rtl::OUString(), aDescriptor.getPropertyValues() ); } else { - DBG_ERROR("#121119# You found the reason for a stacktrace! Frame destroyed while loading document."); - bLoadState = sal_False; + xLoadable->load( aDescriptor.getPropertyValues() ); } } - catch ( css::uno::Exception& ) + else { - bDisaster = sal_True; + // tell the doc its (current) load args. + impl_removeLoaderArguments( aDescriptor ); + xModel->attachResource( xModel->getURL(), aDescriptor.getPropertyValues() ); + // TODO: not sure this is correct. The original, pre-refactoring code did it this way. However, I could + // imagine scenarios where it is *not* correct to overrule the *existing* model args (XModel::getArgs) + // with the ones passed to the loader here. For instance, what about the MacroExecutionMode? The document + // might have a mode other than the one passed to the loader, and we always overwrite the former with + // the latter. } - if ( bDisaster ) - { - if ( wFrame && !wFrame->GetCurrentDocument() ) - { - // document loading was not successful; close SfxFrame (but not XFrame!) - css::uno::Reference< css::frame::XFrame > axFrame; - wFrame->SetFrameInterface_Impl( axFrame ); - wFrame->DoClose(); - aSet.ClearItem( SID_DOCFRAME ); - } + // get the SfxObjectShell (still needed at the moment) + const SfxObjectShellLock xDoc = impl_findObjectShell( xModel ); + ENSURE_OR_THROW( xDoc.Is(), "no SfxObjectShell for the given model" ); + + // ensure the ID of the to-be-created view is in the descriptor, if possible + const sal_Int16 nViewId = impl_determineEffectiveViewId_nothrow( *xDoc, aDescriptor ); + const sal_Int16 nViewNo = xDoc->GetFactory().GetViewNo_Impl( nViewId, 0 ); + const ::rtl::OUString sViewName( xDoc->GetFactory().GetViewFactory( nViewNo ).GetViewName() ); + + // if the document is created hidden, prevent it from being deleted until it is shown or disposed + impl_lockHiddenDocument( *xDoc, aDescriptor ); + // TODO; if we wouldn't use a SfxObjectShellLock instance for xDoc, but a simple SfxObjectShellRef, + // then this would not be necessary, /me thinks. That is, the *Lock classes inc/dec a "Lock" counter + // (additional to the ref counter) in their ctor/dtor, and if the lock counter goes to 0, the + // object is closed (DoClose). The impl_lockHiddenDocument is to prevent exactly that premature + // closing. However, a *Ref object wouldn't close, anyway. And in case of unsuccessfull loading, the + // code at the very end of this method cares for closing the XModel, which should also close the + // ObjectShell. + + // plug the document into the frame + impl_createDocumentView( xModel, _rTargetFrame, aViewCreationArgs, sViewName ); + bLoadSuccess = sal_True; + } + catch ( Exception& ) + { + const Any aError( ::cppu::getCaughtException() ); + if ( !aDescriptor.getOrDefault( "Silent", sal_False ) ) + impl_handleCaughtError_nothrow( aError, aDescriptor ); + } - css::uno::Reference< css::util::XCloseable > xCloseable( xLoadable, css::uno::UNO_QUERY ); - if ( xCloseable.is() ) - { - try { - xCloseable->close( sal_True ); - } catch ( css::uno::Exception& ) - {} - } + // if loading was not successful, close the document + if ( !bLoadSuccess && !bExternalModel ) + { + try + { + const Reference< XCloseable > xCloseable( xModel, UNO_QUERY_THROW ); + xCloseable->close( sal_True ); + } + catch ( Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } - xFrame.clear(); - xListener.clear(); - return bLoadState; + return bLoadSuccess; } -void SfxFrameLoader_Impl::cancel() throw( RUNTIME_EXCEPTION ) +void SfxFrameLoader_Impl::cancel() throw( RuntimeException ) { } SFX_IMPL_SINGLEFACTORY( SfxFrameLoader_Impl ) /* XServiceInfo */ -UNOOUSTRING SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( UNORUNTIMEEXCEPTION ) +UNOOUSTRING SAL_CALL SfxFrameLoader_Impl::getImplementationName() throw( RuntimeException ) { return impl_getStaticImplementationName(); } \ /* XServiceInfo */ -sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServiceName ) throw( UNORUNTIMEEXCEPTION ) +sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServiceName ) throw( RuntimeException ) { UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames(); const UNOOUSTRING* pArray = seqServiceNames.getConstArray(); @@ -616,7 +718,7 @@ sal_Bool SAL_CALL SfxFrameLoader_Impl::supportsService( const UNOOUSTRING& sServ } /* XServiceInfo */ -UNOSEQUENCE< UNOOUSTRING > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION ) +UNOSEQUENCE< UNOOUSTRING > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() throw( RuntimeException ) { return impl_getStaticSupportedServiceNames(); } diff --git a/sfx2/source/view/impframe.cxx b/sfx2/source/view/impframe.cxx deleted file mode 100644 index 997637b3a531..000000000000 --- a/sfx2/source/view/impframe.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sfx2.hxx" - -#ifndef GCC -#endif - -#include "impframe.hxx" - -#include <svl/smplhint.hxx> - -#include <sfx2/frame.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/viewfrm.hxx> - -void SfxFrame_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) -{ - SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint ); - if( pHint && pHint->GetId() == SFX_HINT_CANCELLABLE && pCurrentViewFrame ) - { - // vom Cancel-Manager - SfxBindings &rBind = pCurrentViewFrame->GetBindings(); - rBind.Invalidate( SID_BROWSE_STOP ); - if ( !rBind.IsInRegistrations() ) - rBind.Update( SID_BROWSE_STOP ); - rBind.Invalidate( SID_BROWSE_STOP ); - } -} - diff --git a/sfx2/source/view/impframe.hxx b/sfx2/source/view/impframe.hxx index 9098ffd8f842..72f322036efb 100644 --- a/sfx2/source/view/impframe.hxx +++ b/sfx2/source/view/impframe.hxx @@ -28,8 +28,6 @@ #ifndef _SFX_IMPFRAME_HXX #define _SFX_IMPFRAME_HXX -#include <svl/cancel.hxx> - #include <sfx2/frame.hxx> #include <sfx2/viewfrm.hxx> // SvBorder @@ -51,60 +49,51 @@ class SfxObjectShell; #define FRAME_SEARCH_CREATE 0x00000008 #endif -class SfxFrame_Impl : public SfxBroadcaster, public SvCompatWeakBase, public SfxListener +class SfxFrame_Impl : public SfxBroadcaster, public SvCompatWeakBase { -friend class SfxFrame; - +public: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame; - String aFrameIdName; sal_uInt32 nType; - sal_uInt32 nHistoryPos; SfxViewFrame* pCurrentViewFrame; - SfxObjectShell* pCurrentObjectShell; SfxFrameDescriptor* pDescr; - sal_uInt16 nFrameId; sal_uInt16 nLocks; - sal_Bool bCloseOnUnlock : 1; sal_Bool bClosing : 1; sal_Bool bPrepClosing : 1; sal_Bool bInCancelTransfers : 1; sal_Bool bOwnsBindings : 1; sal_Bool bReleasingComponent : 1; - sal_Bool bFocusLocked : 1; sal_Bool bInPlace : 1; - SfxCancelManager* pCancelMgr; - SfxCancellable* pLoadCancellable; SfxFrame* pFrame; - const SfxItemSet* pSet; SfxWorkWindow* pWorkWin; SvBorder aBorder; + // formerly SfxTopFrame + Window* pExternalContainerWindow; + bool bHidden; + bool bLockResize; + bool bMenuBarOn; - SfxFrame_Impl( SfxFrame* pAntiImplP ) : - SvCompatWeakBase( pAntiImplP ), - nType( 0L ), - nHistoryPos( 0 ), - pCurrentViewFrame( NULL ), - pCurrentObjectShell( NULL ), - pDescr( NULL ), - nFrameId( 0 ), - nLocks( 0 ), - bCloseOnUnlock( sal_False ), - bClosing(sal_False), - bPrepClosing(sal_False), - bInCancelTransfers( sal_False ), - bOwnsBindings( sal_False ), - bReleasingComponent( sal_False ), - bFocusLocked( sal_False ), - bInPlace( sal_False ), - pCancelMgr( 0 ), - pLoadCancellable( 0 ), - pFrame( pAntiImplP ), - pSet( 0 ), - pWorkWin( 0 ) - {} + SfxFrame_Impl( SfxFrame* pAntiImplP ) + :SvCompatWeakBase( pAntiImplP ) + ,nType( 0L ) + ,pCurrentViewFrame( NULL ) + ,pDescr( NULL ) + ,nLocks( 0 ) + ,bClosing(sal_False) + ,bPrepClosing(sal_False) + ,bInCancelTransfers( sal_False ) + ,bOwnsBindings( sal_False ) + ,bReleasingComponent( sal_False ) + ,bInPlace( sal_False ) + ,pFrame( pAntiImplP ) + ,pWorkWin( 0 ) + ,pExternalContainerWindow( NULL ) + ,bHidden( false ) + ,bLockResize( false ) + ,bMenuBarOn( true ) + { + } - virtual ~SfxFrame_Impl() { delete pCancelMgr; delete pLoadCancellable; } - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); + virtual ~SfxFrame_Impl() { } }; #endif diff --git a/sfx2/source/view/impviewframe.hxx b/sfx2/source/view/impviewframe.hxx new file mode 100644 index 000000000000..5460d613c7e8 --- /dev/null +++ b/sfx2/source/view/impviewframe.hxx @@ -0,0 +1,94 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 SFX2_IMPVIEWFRAME_HXX +#define SFX2_IMPVIEWFRAME_HXX + +#include "sfx2/viewfrm.hxx" + +#include <svtools/asynclink.hxx> +#include <vcl/window.hxx> + +struct SfxViewFrame_Impl +{ + SvBorder aBorder; + Size aMargin; + Size aSize; + String aFrameTitle; + TypeId aLastType; + String aActualURL; + SfxFrame& rFrame; + svtools::AsynchronLink* pReloader; + Window* pWindow; + SfxViewFrame* pActiveChild; + Window* pFocusWin; + sal_uInt16 nDocViewNo; + sal_uInt16 nCurViewId; + sal_Bool bResizeInToOut:1; + sal_Bool bDontOverwriteResizeInToOut:1; + sal_Bool bObjLocked:1; + sal_Bool bReloading:1; + sal_Bool bIsDowning:1; + sal_Bool bModal:1; + sal_Bool bEnabled:1; + sal_Bool bWindowWasEnabled:1; + sal_Bool bActive; + String aFactoryName; + + SfxViewFrame_Impl( SfxFrame& i_rFrame ) + : rFrame( i_rFrame ) + , pReloader(0 ) + , pWindow( 0 ) + , bWindowWasEnabled(sal_True) + , bActive( sal_False ) + { + } + + ~SfxViewFrame_Impl() + { + delete pReloader; + } +}; + +class SfxFrameViewWindow_Impl : public Window +{ + BOOL bActive; + SfxViewFrame* pFrame; + +public: + SfxFrameViewWindow_Impl( SfxViewFrame* p, Window& rParent, WinBits nBits=0 ) : + Window( &rParent, nBits | WB_BORDER | WB_CLIPCHILDREN ), + bActive( FALSE ), + pFrame( p ) + { + p->GetFrame().GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); + } + + virtual void Resize(); + virtual void StateChanged( StateChangedType nStateChange ); +}; + +#endif // SFX2_IMPVIEWFRAME_HXX + diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 56e14f43a08c..6d61f4182bbb 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -57,7 +57,7 @@ #include <sfx2/dispatch.hxx> #include "workwin.hxx" #include "guisaveas.hxx" -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include <cppuhelper/implbase5.hxx> #include <vcl/salbtype.hxx> #include <svtools/ehdl.hxx> @@ -201,7 +201,7 @@ throw (::com::sun::star::uno::RuntimeException) // currently needs SFX code SfxObjectShell* pDoc = reinterpret_cast< SfxObjectShell* >( sal::static_int_cast< sal_IntPtr >( nHandle )); SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDoc ); - SfxWorkWindow *pWorkWin = pFrame->GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow *pWorkWin = pFrame->GetFrame().GetWorkWindow_Impl(); pWorkWin->UpdateObjectBars_Impl(); } */ @@ -231,7 +231,7 @@ uno::Reference < frame::XFrame > SfxInPlaceClient_Impl::GetFrame() const { if ( !m_pClient ) throw uno::RuntimeException(); - return m_pClient->GetViewShell()->GetViewFrame()->GetFrame()->GetFrameInterface(); + return m_pClient->GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(); } void SAL_CALL SfxInPlaceClient_Impl::saveObject() @@ -733,7 +733,7 @@ void SfxInPlaceClient::SetObject( const uno::Reference < embed::XEmbeddedObject } } - if ( !m_pViewSh || m_pViewSh->GetViewFrame()->GetFrame()->IsClosing_Impl() ) + if ( !m_pViewSh || m_pViewSh->GetViewFrame()->GetFrame().IsClosing_Impl() ) // sometimes applications reconnect clients on shutting down because it happens in their Paint methods return; @@ -983,7 +983,7 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb ) { if ( m_pViewSh ) - ((SfxTopFrame*)m_pViewSh->GetViewFrame()->GetTopFrame())->LockResize_Impl(TRUE); + m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(TRUE); try { m_pImp->m_xObject->setClientSite( m_pImp->m_xClient ); @@ -1033,8 +1033,8 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb ) if ( m_pViewSh ) { SfxViewFrame* pFrame = m_pViewSh->GetViewFrame(); - ((SfxTopFrame*)pFrame->GetTopFrame())->LockResize_Impl(FALSE); - pFrame->GetTopFrame()->Resize(); + pFrame->GetTopFrame().LockResize_Impl(FALSE); + pFrame->GetTopFrame().Resize(); } } } @@ -1094,7 +1094,7 @@ void SfxInPlaceClient::DeactivateObject() } if ( m_pViewSh ) - ((SfxTopFrame*)m_pViewSh->GetViewFrame()->GetTopFrame())->LockResize_Impl(TRUE); + m_pViewSh->GetViewFrame()->GetTopFrame().LockResize_Impl(TRUE); if ( m_pImp->m_xObject->getStatus( m_pImp->m_nAspect ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE ) { @@ -1116,8 +1116,8 @@ void SfxInPlaceClient::DeactivateObject() { SfxViewFrame* pFrame = m_pViewSh->GetViewFrame(); SfxViewFrame::SetViewFrame( pFrame ); - ((SfxTopFrame*)pFrame->GetTopFrame())->LockResize_Impl(FALSE); - pFrame->GetTopFrame()->Resize(); + pFrame->GetTopFrame().LockResize_Impl(FALSE); + pFrame->GetTopFrame().Resize(); } } catch (com::sun::star::uno::Exception& ) diff --git a/sfx2/source/view/makefile.mk b/sfx2/source/view/makefile.mk index 758fd5ccb806..9c257f4c9f75 100644 --- a/sfx2/source/view/makefile.mk +++ b/sfx2/source/view/makefile.mk @@ -45,17 +45,17 @@ SRC1FILES = \ view.src SLOFILES = \ - $(SLO)$/ipclient.obj \ + $(SLO)$/ipclient.obj \ $(SLO)$/viewsh.obj \ $(SLO)$/frmload.obj \ $(SLO)$/frame.obj \ + $(SLO)$/frame2.obj \ $(SLO)$/printer.obj \ $(SLO)$/viewprn.obj \ $(SLO)$/viewfac.obj \ $(SLO)$/orgmgr.obj \ $(SLO)$/viewfrm.obj \ - $(SLO)$/impframe.obj \ - $(SLO)$/topfrm.obj \ + $(SLO)$/viewfrm2.obj \ $(SLO)$/sfxbasecontroller.obj \ $(SLO)$/userinputinterception.obj diff --git a/sfx2/source/view/prnmon.cxx b/sfx2/source/view/prnmon.cxx index 9f42f438cffa..a4e96ab1065e 100644 --- a/sfx2/source/view/prnmon.cxx +++ b/sfx2/source/view/prnmon.cxx @@ -319,7 +319,7 @@ SfxPrintProgress::~SfxPrintProgress() pImp->pViewShell->GetPrinter()->EnablePrintFile( pImp->bOldEnablePrintFile ); // EndPrint-Notification an Frame - //pImp->pViewShell->GetViewFrame()->GetFrame()->Lock_Impl(FALSE); + //pImp->pViewShell->GetViewFrame()->GetFrame().Lock_Impl(FALSE); pImp->EndListening( *(pImp->pViewShell->GetObjectShell()) ); // the following call might destroy the view or even the document diff --git a/sfx2/source/view/sfxbasecontroller.cxx b/sfx2/source/view/sfxbasecontroller.cxx index 88afc2796429..f5c24b195af7 100644 --- a/sfx2/source/view/sfxbasecontroller.cxx +++ b/sfx2/source/view/sfxbasecontroller.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/util/XCloseBroadcaster.hpp> #include <com/sun/star/util/XCloseListener.hpp> #include <com/sun/star/util/CloseVetoException.hpp> +#include <com/sun/star/document/XViewDataSupplier.hpp> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> #include <com/sun/star/frame/FrameActionEvent.hpp> @@ -53,15 +54,18 @@ #include <com/sun/star/frame/CommandGroup.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/XBorderResizeListener.hpp> +#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/EventObject.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> #include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/typeprovider.hxx> #include <cppuhelper/implbase1.hxx> #include <basic/sbstar.hxx> #include <uno/mapping.hxx> #include <sfx2/viewsh.hxx> +#include <sfx2/docfac.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/objsh.hxx> #include <sfx2/app.hxx> @@ -84,10 +88,12 @@ #include <toolkit/helper/convert.hxx> #include <framework/titlehelper.hxx> #include <comphelper/processfactory.hxx> +#include <tools/diagnose_ex.h> #include <hash_map> #include <sfx2/event.hxx> +#include "viewfac.hxx" #define OMULTITYPEINTERFACECONTAINERHELPER ::cppu::OMultiTypeInterfaceContainerHelper #define OINTERFACECONTAINERHELPER ::cppu::OInterfaceContainerHelper @@ -109,6 +115,24 @@ #define TIMEOUT_START_RESCHEDULE 10L /* 10th s */ using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::UNO_QUERY_THROW; +using ::com::sun::star::lang::DisposedException; +using ::com::sun::star::awt::XWindow; +using ::com::sun::star::frame::XController; +using ::com::sun::star::frame::XDispatchProvider; +using ::com::sun::star::document::XViewDataSupplier; +using ::com::sun::star::container::XIndexAccess; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::Exception; +using ::com::sun::star::frame::XFrame; +using ::com::sun::star::frame::XFrameActionListener; +using ::com::sun::star::util::XCloseListener; +using ::com::sun::star::task::XStatusIndicator; +using ::com::sun::star::frame::XTitle; namespace css = ::com::sun::star; struct GroupIDToCommandGroup @@ -220,7 +244,7 @@ void reschedule() class SfxStatusIndicator : public ::cppu::WeakImplHelper2< ::com::sun::star::task::XStatusIndicator, ::com::sun::star::lang::XEventListener > { friend class SfxBaseController; - ::com::sun::star::uno::Reference < XCONTROLLER > xOwner; + ::com::sun::star::uno::Reference < XController > xOwner; ::com::sun::star::uno::Reference < ::com::sun::star::task::XStatusIndicator > xProgress; SfxWorkWindow* pWorkWindow; sal_Int32 _nRange; @@ -427,29 +451,19 @@ void SAL_CALL IMPL_SfxBaseController_CloseListenerHelper::notifyClosing( const E struct IMPL_SfxBaseController_DataContainer { - REFERENCE < XFRAME > m_xFrame; - REFERENCE < XFRAMEACTIONLISTENER > m_xListener ; - REFERENCE < XCLOSELISTENER > m_xCloseListener ; + Reference< XFrame > m_xFrame ; + Reference< XFrameActionListener > m_xListener ; + Reference< XCloseListener > m_xCloseListener ; ::sfx2::UserInputInterception m_aUserInputInterception; OMULTITYPEINTERFACECONTAINERHELPER m_aListenerContainer ; - OINTERFACECONTAINERHELPER m_aInterceptorContainer ; - REFERENCE < ::com::sun::star::task::XStatusIndicator > m_xIndicator; + OINTERFACECONTAINERHELPER m_aInterceptorContainer ; + Reference< XStatusIndicator > m_xIndicator ; SfxViewShell* m_pViewShell ; SfxBaseController* m_pController ; sal_Bool m_bDisposing ; - sal_Bool m_bSuspendState; - /** When this flag is <true/> (the default) then in dispose() the frame - and with it the view shell are released together with the - controller. - A derived class can set the flag to <false/> when it wants to - exchange controllers that work on the same view shell. One - application is the Impress Multi Pane GUI that changes shells that - are stacked on one view shell. Controllers are associated with the - stacked shells and thus must not destroy the view shell which is not - affected by the switching. - */ - sal_Bool m_bIsFrameReleasedWithController; - css::uno::Reference< css::frame::XTitle > m_xTitleHelper; + sal_Bool m_bSuspendState ; + Reference< XTitle > m_xTitleHelper ; + Sequence< PropertyValue > m_aCreationArgs ; IMPL_SfxBaseController_DataContainer( MUTEX& aMutex , SfxViewShell* pViewShell , @@ -463,7 +477,6 @@ struct IMPL_SfxBaseController_DataContainer , m_pController ( pController ) , m_bDisposing ( sal_False ) , m_bSuspendState ( sal_False ) - , m_bIsFrameReleasedWithController( sal_True ) { } @@ -525,8 +538,7 @@ void SAL_CALL IMPL_SfxBaseController_ListenerHelper::disposing( const EVENTOBJEC //________________________________________________________________________________________________________ DBG_NAME(sfx2_SfxBaseController) SfxBaseController::SfxBaseController( SfxViewShell* pViewShell ) - : IMPL_SfxBaseController_MutexContainer ( ) - , m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this )) + : m_pData ( new IMPL_SfxBaseController_DataContainer( m_aMutex, pViewShell, this )) { DBG_CTOR(sfx2_SfxBaseController,NULL); m_pData->m_pViewShell->SetController( this ); @@ -543,138 +555,60 @@ SfxBaseController::~SfxBaseController() } //________________________________________________________________________________________________________ -// SfxBaseController -> XInterface -//________________________________________________________________________________________________________ -ANY SAL_CALL SfxBaseController::queryInterface( const UNOTYPE& rType ) throw( RUNTIMEEXCEPTION ) -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Ask for my own supported interfaces ... - ANY aReturn( ::cppu::queryInterface( rType , - static_cast< XTYPEPROVIDER* > ( this ) , - static_cast< XCOMPONENT* > ( this ) , - static_cast< XCONTROLLER* > ( this ) , - static_cast< XCONTROLLERBORDER* > ( this ) , - static_cast< XUSERINPUTINTERCEPTION* > ( this ) , - static_cast< XSTATUSINDICATORSUPPLIER* > ( this ) , - static_cast< XCONTEXTMENUINTERCEPTION* > ( this ) , - static_cast< XDISPATCHPROVIDER* > ( this ), - static_cast< XTITLE* > ( this ), - static_cast< XTITLECHANGEBROADCASTER* > ( this ), - static_cast< XDISPATCHINFORMATIONPROVIDER* > ( this ) ) ) ; - - // If searched interface supported by this class ... - if ( aReturn.hasValue() == sal_True ) - { - // ... return this information. - return aReturn ; - } - else - { - // Else; ... ask baseclass for interfaces! - return OWeakObject::queryInterface( rType ) ; - } -} - -//________________________________________________________________________________________________________ -// SfxBaseController -> XInterface -//________________________________________________________________________________________________________ - -void SAL_CALL SfxBaseController::acquire() throw() -{ - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. - - // Forward to baseclass - OWeakObject::acquire() ; -} - -//________________________________________________________________________________________________________ -// SfxBaseController -> XInterface +// SfxBaseController -> XController2 //________________________________________________________________________________________________________ -void SAL_CALL SfxBaseController::release() throw() +Reference< XWindow > SAL_CALL SfxBaseController::getComponentWindow() throw (RuntimeException) { - // Attention: - // Don't use mutex or guard in this method!!! Is a method of XInterface. + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( !m_pData->m_pViewShell ) + throw DisposedException(); - // Forward to baseclass - OWeakObject::release() ; + return Reference< XWindow >( GetViewFrame_Impl().GetFrame().GetWindow().GetComponentInterface(), UNO_QUERY_THROW ); } -//________________________________________________________________________________________________________ -// SfxBaseController -> XTypeProvider -//________________________________________________________________________________________________________ - -SEQUENCE< UNOTYPE > SAL_CALL SfxBaseController::getTypes() throw( RUNTIMEEXCEPTION ) +::rtl::OUString SAL_CALL SfxBaseController::getViewControllerName() throw (RuntimeException) { - // Optimize this method ! - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! - static OTYPECOLLECTION* pTypeCollection = NULL ; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() ) + throw DisposedException(); - if ( pTypeCollection == NULL ) - { - // Ready for multithreading; get global mutex for first call of this method only! see before - MUTEXGUARD aGuard( MUTEX::getGlobalMutex() ) ; + const SfxObjectFactory& rDocFac( m_pData->m_pViewShell->GetObjectShell()->GetFactory() ); + sal_uInt16 nViewNo = rDocFac.GetViewNo_Impl( GetViewFrame_Impl().GetCurViewId(), rDocFac.GetViewFactoryCount() ); + OSL_ENSURE( nViewNo < rDocFac.GetViewFactoryCount(), "SfxBaseController::getViewControllerName: view ID not found in view factories!" ); - // Control these pointer again ... it can be, that another instance will be faster then these! - if ( pTypeCollection == NULL ) - { - // Create a static typecollection ... - static OTYPECOLLECTION aTypeCollection( ::getCppuType(( const REFERENCE< XTYPEPROVIDER >*)NULL ) , - ::getCppuType(( const REFERENCE< XCONTROLLER >*)NULL ) , - ::getCppuType(( const REFERENCE< XCONTROLLERBORDER >*)NULL ) , - ::getCppuType(( const REFERENCE< XDISPATCHPROVIDER >*)NULL ) , - ::getCppuType(( const REFERENCE< XSTATUSINDICATORSUPPLIER >*)NULL ) , - ::getCppuType(( const REFERENCE< XCONTEXTMENUINTERCEPTION >*)NULL ) , - ::getCppuType(( const REFERENCE< XUSERINPUTINTERCEPTION >*)NULL ) , - ::getCppuType(( const REFERENCE< XTITLE >*)NULL ) , - ::getCppuType(( const REFERENCE< XTITLECHANGEBROADCASTER >*)NULL ) , - ::getCppuType(( const REFERENCE< XDISPATCHINFORMATIONPROVIDER >*)NULL ) ); - // ... and set his address to static pointer! - pTypeCollection = &aTypeCollection ; - } - } + ::rtl::OUString sViewName; + if ( nViewNo < rDocFac.GetViewFactoryCount() ) + sViewName = rDocFac.GetViewFactory( nViewNo ).GetViewName(); - return pTypeCollection->getTypes() ; + return sViewName; } -//________________________________________________________________________________________________________ -// SfxBaseController -> XTypeProvider -//________________________________________________________________________________________________________ - -SEQUENCE< sal_Int8 > SAL_CALL SfxBaseController::getImplementationId() throw( RUNTIMEEXCEPTION ) +Sequence< PropertyValue > SAL_CALL SfxBaseController::getCreationArguments() throw (RuntimeException) { - // Create one Id for all instances of this class. - // Use ethernet address to do this! (sal_True) - - // Optimize this method - // We initialize a static variable only one time. And we don't must use a mutex at every call! - // For the first call; pID is NULL - for the second call pID is different from NULL! - static OIMPLEMENTATIONID* pID = NULL ; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( !m_pData->m_pViewShell || !m_pData->m_pViewShell->GetObjectShell() ) + throw DisposedException(); - if ( pID == NULL ) - { - // Ready for multithreading; get global mutex for first call of this method only! see before - MUTEXGUARD aGuard( MUTEX::getGlobalMutex() ) ; + return m_pData->m_aCreationArgs; +} - // Control these pointer again ... it can be, that another instance will be faster then these! - if ( pID == NULL ) - { - // Create a new static ID ... - static OIMPLEMENTATIONID aID( sal_False ) ; - // ... and set his address to static pointer! - pID = &aID ; - } - } +void SfxBaseController::SetCreationArguments_Impl( const Sequence< PropertyValue >& i_rCreationArgs ) +{ + OSL_ENSURE( m_pData->m_aCreationArgs.getLength() == 0, "SfxBaseController::SetCreationArguments_Impl: not intended to be called twice!" ); + m_pData->m_aCreationArgs = i_rCreationArgs; +} - return pID->getImplementationId() ; +SfxViewFrame& SfxBaseController::GetViewFrame_Impl() const +{ + ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" ); + SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame(); + ENSURE_OR_THROW( pActFrame, "a view shell without a view frame is pretty pathological" ); + return *pActFrame; } //________________________________________________________________________________________________________ -// SfxBaseController -> XController +// SfxBaseController -> XController2 -> XController //________________________________________________________________________________________________________ void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame ) throw( ::com::sun::star::uno::RuntimeException ) @@ -701,32 +635,11 @@ void SAL_CALL SfxBaseController::attachFrame( const REFERENCE< XFRAME >& xFrame if ( m_pData->m_pViewShell ) { - SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ; - pActFrame->Enable( TRUE ); - pActFrame->GetDispatcher()->Lock( FALSE ); + ConnectSfxFrame_Impl( E_CONNECT ); - if ( ( m_pData->m_pViewShell->GetObjectShell() != NULL ) - && ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) - ) - { - SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame(); - if ( !pViewFrm->GetFrame()->IsInPlace() ) - { - // for outplace embedded objects, we want the layout manager to keep the content window - // size constant, if possible - try - { - uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xLayouterProps( - xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ), uno::UNO_QUERY_THROW ); - xLayouterProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreserveContentSize" ) ), uno::makeAny( sal_True ) ); - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } - } + // attaching the frame to the controller is the last step in the creation of a new view, so notify this + SfxEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell() ); + SFX_APP()->NotifyEvent( aHint ); } } } @@ -787,9 +700,7 @@ sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com:: BOOL bRet = bOther || pDocShell->PrepareClose(); if ( bRet ) { - // disable window and dispatcher until suspend call is withdrawn - pActFrame->Enable( FALSE ); - pActFrame->GetDispatcher()->Lock( TRUE ); + ConnectSfxFrame_Impl( E_DISCONNECT ); m_pData->m_bSuspendState = sal_True; } @@ -802,9 +713,7 @@ sal_Bool SAL_CALL SfxBaseController::suspend( sal_Bool bSuspend ) throw( ::com:: if ( m_pData->m_pViewShell ) { - SfxViewFrame* pActFrame = m_pData->m_pViewShell->GetFrame() ; - pActFrame->Enable( TRUE ); - pActFrame->GetDispatcher()->Lock( FALSE ); + ConnectSfxFrame_Impl( E_RECONNECT ); } m_pData->m_bSuspendState = sal_False; @@ -893,7 +802,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU if ( xFrame.is() ) xFrame->setName( sTargetFrameName ); - REFERENCE < XDISPATCHPROVIDER > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY ); + Reference< XDispatchProvider > xProv( xFrame, ::com::sun::star::uno::UNO_QUERY ); if ( xProv.is() ) return xProv->queryDispatch( aURL, sTargetFrameName, ::com::sun::star::frame::FrameSearchFlag::SELF ); } @@ -911,13 +820,13 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU pSlot = rSlotPool.GetUnoSlot( aMasterCommand ); else pSlot = rSlotPool.GetUnoSlot( aURL.Path ); - if ( pSlot && ( !pAct->GetFrame()->IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) ) + if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) ) return pAct->GetBindings().GetDispatch( pSlot, aURL, bMasterCommand ); else { // try to find parent SfxViewFrame uno::Reference< frame::XFrame > xParentFrame; - uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame()->GetFrameInterface(); + uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface(); if ( xOwnFrame.is() ) xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY ); @@ -932,7 +841,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) ) { - if ( pFrame->GetFrame()->GetFrameInterface() == xParentFrame ) + if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame ) { pParentFrame = pFrame; break; @@ -968,13 +877,13 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( pAct ); const SfxSlot* pSlot = rSlotPool.GetSlot( nId ); - if ( pSlot && ( !pAct->GetFrame()->IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) ) + if ( pSlot && ( !pAct->GetFrame().IsInPlace() || !pSlot->IsMode( SFX_SLOT_CONTAINER ) ) ) return pAct->GetBindings().GetDispatch( pSlot, aURL, sal_False ); else { // try to find parent SfxViewFrame uno::Reference< frame::XFrame > xParentFrame; - uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame()->GetFrameInterface(); + uno::Reference< frame::XFrame > xOwnFrame = pAct->GetFrame().GetFrameInterface(); if ( xOwnFrame.is() ) xParentFrame = uno::Reference< frame::XFrame >( xOwnFrame->getCreator(), uno::UNO_QUERY ); @@ -989,7 +898,7 @@ REFERENCE< XDISPATCH > SAL_CALL SfxBaseController::queryDispatch( const UNOU pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) ) { - if ( pFrame->GetFrame()->GetFrameInterface() == xParentFrame ) + if ( pFrame->GetFrame().GetFrameInterface() == xParentFrame ) { pParentFrame = pFrame; break; @@ -1123,19 +1032,14 @@ void SfxBaseController::BorderWidthsChanged_Impl() // SfxBaseController -> XComponent //________________________________________________________________________________________________________ -void SfxBaseController::FrameIsReleasedWithController (sal_Bool bFlag) -{ - m_pData->m_bIsFrameReleasedWithController = bFlag; -} - void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::RuntimeException ) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); - REFERENCE < XCONTROLLER > xTmp( this ); + Reference< XController > xTmp( this ); m_pData->m_bDisposing = sal_True ; EVENTOBJECT aEventObject; - aEventObject.Source = (XCONTROLLER*)this ; + aEventObject.Source = *this ; m_pData->m_aListenerContainer.disposeAndClear( aEventObject ) ; if ( m_pData->m_pController && m_pData->m_pController->getFrame().is() ) @@ -1144,18 +1048,15 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime if ( m_pData->m_pViewShell ) { SfxViewFrame* pFrame = m_pData->m_pViewShell->GetViewFrame() ; - if (m_pData->m_bIsFrameReleasedWithController) - { - if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell ) - pFrame->GetFrame()->SetIsClosing_Impl(); - m_pData->m_pViewShell->DiscardClients_Impl(); - m_pData->m_pViewShell->pImp->bControllerSet = sal_False ; - } + if ( pFrame && pFrame->GetViewShell() == m_pData->m_pViewShell ) + pFrame->GetFrame().SetIsClosing_Impl(); + m_pData->m_pViewShell->DiscardClients_Impl(); + m_pData->m_pViewShell->pImp->bControllerSet = sal_False ; if ( pFrame ) { EVENTOBJECT aObject; - aObject.Source = (OWEAKOBJECT*)this ; + aObject.Source = *this ; SfxObjectShell* pDoc = pFrame->GetObjectShell() ; SfxViewFrame *pView = SfxViewFrame::GetFirst(pDoc); @@ -1167,12 +1068,9 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime pView = SfxViewFrame::GetNext( *pView, pDoc ); } - if ( m_pData->m_bIsFrameReleasedWithController ) - { - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc ) ); - if ( !pView ) - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) ); - } + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc ) ); + if ( !pView ) + SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) ); REFERENCE< XMODEL > xModel = pDoc->GetModel(); REFERENCE < ::com::sun::star::util::XCloseable > xCloseable( xModel, com::sun::star::uno::UNO_QUERY ); @@ -1189,14 +1087,13 @@ void SAL_CALL SfxBaseController::dispose() throw( ::com::sun::star::uno::Runtime m_pData->m_xListener->disposing( aObject ); SfxViewShell *pShell = m_pData->m_pViewShell; m_pData->m_pViewShell = NULL; - if ( pFrame->GetViewShell() == pShell - && m_pData->m_bIsFrameReleasedWithController) + if ( pFrame->GetViewShell() == pShell ) { // Enter registrations only allowed if we are the owner! - if ( pFrame->GetFrame()->OwnsBindings_Impl() ) + if ( pFrame->GetFrame().OwnsBindings_Impl() ) pFrame->GetBindings().ENTERREGISTRATIONS(); - pFrame->GetFrame()->SetFrameInterface_Impl( aXFrame ); - pFrame->GetFrame()->DoClose_Impl(); + pFrame->GetFrame().SetFrameInterface_Impl( aXFrame ); + pFrame->GetFrame().DoClose_Impl(); } } } @@ -1250,7 +1147,7 @@ SfxViewShell* SfxBaseController::GetViewShell_Impl() const { ::vos::OGuard aGuard( Application::GetSolarMutex() ); if ( m_pData->m_pViewShell && !m_pData->m_xIndicator.is() ) - m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame()->GetWorkWindow_Impl() ); + m_pData->m_xIndicator = new SfxStatusIndicator( this, m_pData->m_pViewShell->GetViewFrame()->GetFrame().GetWorkWindow_Impl() ); return m_pData->m_xIndicator; } @@ -1395,6 +1292,165 @@ BOOL SfxBaseController::HasMouseClickListeners_Impl() return m_pData->m_aUserInputInterception.hasMouseClickListeners(); } +void SfxBaseController::ConnectSfxFrame_Impl( const ConnectSfxFrame i_eConnect ) +{ + ENSURE_OR_THROW( m_pData->m_pViewShell, "not to be called without a view shell" ); + SfxViewFrame* pViewFrame = m_pData->m_pViewShell->GetFrame(); + ENSURE_OR_THROW( pViewFrame, "a view shell without a view frame is pretty pathological" ); + + const bool bConnect = ( i_eConnect != E_DISCONNECT ); + + // disable window and dispatcher + pViewFrame->Enable( bConnect ); + pViewFrame->GetDispatcher()->Lock( !bConnect ); + + if ( bConnect ) + { + if ( i_eConnect == E_CONNECT ) + { + if ( ( m_pData->m_pViewShell->GetObjectShell() != NULL ) + && ( m_pData->m_pViewShell->GetObjectShell()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) + ) + { + SfxViewFrame* pViewFrm = m_pData->m_pViewShell->GetViewFrame(); + if ( !pViewFrm->GetFrame().IsInPlace() ) + { + // for outplace embedded objects, we want the layout manager to keep the content window + // size constant, if possible + try + { + uno::Reference< beans::XPropertySet > xFrameProps( m_pData->m_xFrame, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xLayouterProps( + xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ), uno::UNO_QUERY_THROW ); + xLayouterProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreserveContentSize" ) ), uno::makeAny( sal_True ) ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } + + // upon DISCONNECT, we did *not* pop the shells from the stack (this is done elsewhere), so upon + // RECONNECT, we're not allowed to push them + if ( i_eConnect != E_RECONNECT ) + { + pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell ); + if ( m_pData->m_pViewShell->GetSubShell() ) + pViewFrame->GetDispatcher()->Push( *m_pData->m_pViewShell->GetSubShell() ); + m_pData->m_pViewShell->PushSubShells_Impl(); + pViewFrame->GetDispatcher()->Flush(); + } + + Window* pEditWin = m_pData->m_pViewShell->GetWindow(); + if ( pEditWin && m_pData->m_pViewShell->IsShowView_Impl() ) + pEditWin->Show(); + + if ( SfxViewFrame::Current() == pViewFrame ) + pViewFrame->GetDispatcher()->Update_Impl( sal_True ); + + Window* pFrameWin = &pViewFrame->GetWindow(); + if ( pFrameWin != &pViewFrame->GetFrame().GetWindow() ) + pFrameWin->Show(); + + if ( i_eConnect == E_CONNECT ) + { + ::comphelper::NamedValueCollection aDocumentArgs( getModel()->getArgs() ); + + const sal_Int16 nPluginMode = aDocumentArgs.getOrDefault( "PluginMode", sal_Int16( 0 ) ); + const bool bHasPluginMode = ( nPluginMode != 0 ); + + SfxFrame& rFrame = pViewFrame->GetFrame(); + SfxObjectShell& rDoc = *m_pData->m_pViewShell->GetObjectShell(); + if ( !rFrame.IsMarkedHidden_Impl() ) + { + if ( rDoc.IsHelpDocument() || ( nPluginMode == 2 ) ) + pViewFrame->GetDispatcher()->HideUI( TRUE ); + else + pViewFrame->GetDispatcher()->HideUI( FALSE ); + + if ( rFrame.IsInPlace() ) + pViewFrame->LockAdjustPosSizePixel(); + + if ( nPluginMode == 3 ) + rFrame.GetWorkWindow_Impl()->SetInternalDockingAllowed( FALSE ); + + if ( !rFrame.IsInPlace() ) + pViewFrame->GetDispatcher()->Update_Impl(); + pViewFrame->Show(); + rFrame.GetWindow().Show(); + if ( !rFrame.IsInPlace() || ( nPluginMode == 3 ) ) + pViewFrame->MakeActive_Impl( rFrame.GetFrameInterface()->isActive() ); + + if ( rFrame.IsInPlace() ) + { + pViewFrame->UnlockAdjustPosSizePixel(); + // force resize for OLE server to fix layout problems of writer and math + // see i53651 + if ( nPluginMode == 3 ) + pViewFrame->Resize( TRUE ); + } + } + else + { + DBG_ASSERT( !rFrame.IsInPlace() && !bHasPluginMode, "Special modes not compatible with hidden mode!" ); + rFrame.GetWindow().Show(); + } + + // Jetzt UpdateTitle, hidden TopFrames haben sonst keinen Namen! + pViewFrame->UpdateTitle(); + + if ( !rFrame.IsInPlace() ) + pViewFrame->Resize( TRUE ); + + // if there's a JumpMark given, then, well, jump to it + ::comphelper::NamedValueCollection aViewArgs( getCreationArguments() ); + const ::rtl::OUString sJumpMark = aViewArgs.getOrDefault( "JumpMark", ::rtl::OUString() ); + const bool bHasJumpMark = ( sJumpMark.getLength() > 0 ); + OSL_ENSURE( ( !m_pData->m_pViewShell->GetObjectShell()->IsLoading() ) + || ( !sJumpMark.getLength() ), + "SfxBaseController::ConnectSfxFrame_Impl: so this code wasn't dead?" ); + // Before CWS autorecovery, there was code which postponed jumping to the Mark to a later time + // (SfxObjectShell::PositionView_Impl), but it seems this branch was never used, since this method + // here is never called before the load process finished. At least not with a non-empty jump mark + if ( sJumpMark.getLength() ) + m_pData->m_pViewShell->JumpToMark( sJumpMark ); + + // if no plugin mode and no jump mark was supplied, check whether the document itself can provide view data, and + // if so, forward it to the view/shell. + if ( !bHasPluginMode && !bHasJumpMark ) + { + try + { + Reference< XViewDataSupplier > xViewDataSupplier( getModel(), UNO_QUERY ); + Reference< XIndexAccess > xViewData; + if ( xViewDataSupplier.is() ) + xViewData = xViewDataSupplier->getViewData(); + if ( xViewData.is() && xViewData->getCount() > 0 ) + { + Sequence< PropertyValue > aViewData; + if ( ( xViewData->getByIndex( 0 ) >>= aViewData ) && ( aViewData.getLength() ) ) + { + m_pData->m_pViewShell->ReadUserDataSequence( aViewData, TRUE ); + } + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + } + + // invalidate slot corresponding to the view shell + const sal_uInt16 nViewNo = m_pData->m_pViewShell->GetObjectShell()->GetFactory().GetViewNo_Impl( pViewFrame->GetCurViewId(), USHRT_MAX ); + DBG_ASSERT( nViewNo != USHRT_MAX, "view shell id not found" ); + if ( nViewNo != USHRT_MAX ) + pViewFrame->GetBindings().Invalidate( nViewNo + SID_VIEWSHELL0 ); +} + //============================================================================= css::uno::Reference< css::frame::XTitle > SfxBaseController::impl_getTitleHelper () { diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx deleted file mode 100644 index 5af48806153f..000000000000 --- a/sfx2/source/view/topfrm.cxx +++ /dev/null @@ -1,1643 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sfx2.hxx" -#ifndef GCC -#endif - -#include <sfx2/topfrm.hxx> -#include <sfx2/signaturestate.hxx> -#include <com/sun/star/frame/XModuleManager.hpp> -#include <com/sun/star/util/XURLTransformer.hpp> -#include <com/sun/star/uno/Reference.h> -#include <com/sun/star/frame/XFrame.hpp> -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include <comphelper/processfactory.hxx> -#endif -#include <com/sun/star/frame/XFramesSupplier.hpp> -#include <com/sun/star/util/XCloseable.hpp> -#include <com/sun/star/util/CloseVetoException.hpp> -#ifndef _TOOLKIT_UNOHLP_HXX -#include <toolkit/helper/vclunohelper.hxx> -#endif -#ifndef _UNO_COM_SUN_STAR_AWT_POSSIZE_HPP_ -#include <com/sun/star/awt/PosSize.hpp> -#endif -#include <com/sun/star/container/XIndexAccess.hpp> -#ifndef _COM_SUN_STAR_CONTAINER_XPROPERTYSET_HPP_ -#include <com/sun/star/beans/XPropertySet.hpp> -#endif -#include <com/sun/star/frame/XLayoutManager.hpp> -#include <com/sun/star/beans/NamedValue.hpp> -#include <com/sun/star/beans/XMaterialHolder.hpp> -#include <com/sun/star/awt/XWindow2.hpp> -#include <vcl/menu.hxx> -#include <svl/rectitem.hxx> -#include <svl/intitem.hxx> -#include <svl/eitem.hxx> -#include <svl/stritem.hxx> -#include <svtools/asynclink.hxx> -#include <svtools/sfxecode.hxx> -#include <vcl/dialog.hxx> -#include <svl/urihelper.hxx> -#include <unotools/moduleoptions.hxx> -#include <unotools/configmgr.hxx> -#include <unotools/bootstrap.hxx> - -#include <sfxresid.hxx> - -// wg. pTopFrames -#include "appdata.hxx" -#include <sfx2/app.hxx> -#include <sfx2/sfx.hrc> -#include <sfx2/objsh.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/viewsh.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/request.hxx> -#include <sfx2/objitem.hxx> -#include <sfx2/objface.hxx> -#include <sfx2/msg.hxx> -#include "objshimp.hxx" -#include "workwin.hxx" -#include "sfxtypes.hxx" -#include "splitwin.hxx" -#include "arrdecl.hxx" -#include "sfxhelp.hxx" -#include <sfx2/fcontnr.hxx> -#include <sfx2/docfac.hxx> -#include "statcach.hxx" -#include <sfx2/event.hxx> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::beans; - -//------------------------------------------------------------------------ - -#define SfxTopViewFrame -#include "sfxslots.hxx" - -DBG_NAME(SfxTopViewFrame) - -#include <comphelper/sequenceashashmap.hxx> -static ::rtl::OUString GetModuleName_Impl( const ::rtl::OUString& sDocService ) -{ - uno::Reference< container::XNameAccess > xMM( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), uno::UNO_QUERY ); - ::rtl::OUString sVar; - if ( !xMM.is() ) - return sVar; - - try - { - ::comphelper::SequenceAsHashMap aAnalyzer( xMM->getByName(sDocService) ); - sVar = aAnalyzer.getUnpackedValueOrDefault( ::rtl::OUString::createFromAscii("ooSetupFactoryUIName"), ::rtl::OUString() ); - } - catch( uno::Exception& ) - { - sVar = ::rtl::OUString(); - } - - return sVar; -} - -class SfxTopFrame_Impl -{ -public: - Window* pWindow; // maybe external - BOOL bHidden; - BOOL bLockResize; - BOOL bMenuBarOn; -}; - -class SfxTopWindow_Impl : public Window -{ -public: - SfxTopFrame* pFrame; - - SfxTopWindow_Impl( SfxTopFrame* pF ); -// : Window( pF->pImp->pWindow, WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK ) -// , pFrame( pF ) -// { SetBackground(); } - ~SfxTopWindow_Impl( ); - - virtual void DataChanged( const DataChangedEvent& rDCEvt ); - virtual void StateChanged( StateChangedType nStateChange ); - virtual long PreNotify( NotifyEvent& rNEvt ); - virtual long Notify( NotifyEvent& rEvt ); - virtual void Resize(); - virtual void GetFocus(); - void DoResize(); - DECL_LINK( CloserHdl, void* ); -}; - -SfxTopWindow_Impl::SfxTopWindow_Impl( SfxTopFrame* pF ) - : Window( pF->pImp->pWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK ) - , pFrame( pF ) -{ -} - -SfxTopWindow_Impl::~SfxTopWindow_Impl( ) -{ -} - -void SfxTopWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt ) -{ - Window::DataChanged( rDCEvt ); - SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); - if ( pWorkWin ) - pWorkWin->DataChanged_Impl( rDCEvt ); -} - -long SfxTopWindow_Impl::Notify( NotifyEvent& rNEvt ) -{ - if ( pFrame->IsClosing_Impl() || !pFrame->GetFrameInterface().is() ) - return sal_False; - - SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); - if ( !pView || !pView->GetObjectShell() ) - return Window::Notify( rNEvt ); - - if ( rNEvt.GetType() == EVENT_GETFOCUS ) - { - if ( pView->GetViewShell() && !pView->GetViewShell()->GetUIActiveIPClient_Impl() && !pFrame->IsInPlace() ) - { - DBG_TRACE("SfxTopFrame: GotFocus"); - pView->MakeActive_Impl( FALSE ); - } - - // TODO/LATER: do we still need this code? - Window* pWindow = rNEvt.GetWindow(); - ULONG nHelpId = 0; - while ( !nHelpId && pWindow ) - { - nHelpId = pWindow->GetHelpId(); - pWindow = pWindow->GetParent(); - } - - if ( nHelpId ) - SfxHelp::OpenHelpAgent( pFrame, nHelpId ); - - // if focus was on an external window, the clipboard content might have been changed - pView->GetBindings().Invalidate( SID_PASTE ); - pView->GetBindings().Invalidate( SID_PASTE_SPECIAL ); - return sal_True; - } - else if( rNEvt.GetType() == EVENT_KEYINPUT ) - { - if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) ) - return TRUE; - } - else if ( rNEvt.GetType() == EVENT_EXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTDISABLE*/ ) - { - pView->SetModalMode( sal_True ); - return sal_True; - } - else if ( rNEvt.GetType() == EVENT_ENDEXECUTEDIALOG /*|| rNEvt.GetType() == EVENT_INPUTENABLE*/ ) - { - //EnableInput( sal_True, sal_True ); - pView->SetModalMode( sal_False ); - return sal_True; - } - - return Window::Notify( rNEvt ); -} - -long SfxTopWindow_Impl::PreNotify( NotifyEvent& rNEvt ) -{ - USHORT nType = rNEvt.GetType(); - if ( nType == EVENT_KEYINPUT || nType == EVENT_KEYUP ) - { - SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); - SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; - if ( pShell && pShell->HasKeyListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) - return sal_True; - } - else if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN ) - { - Window* pWindow = rNEvt.GetWindow(); - SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); - SfxViewShell* pShell = pView ? pView->GetViewShell() : NULL; - if ( pShell ) - if ( pWindow == pShell->GetWindow() || pShell->GetWindow()->IsChild( pWindow ) ) - if ( pShell->HasMouseClickListeners_Impl() && pShell->HandleNotifyEvent_Impl( rNEvt ) ) - return sal_True; - } - - if ( nType == EVENT_MOUSEBUTTONDOWN ) - { - Window* pWindow = rNEvt.GetWindow(); - const MouseEvent* pMEvent = rNEvt.GetMouseEvent(); - Point aPos = pWindow->OutputToScreenPixel( pMEvent->GetPosPixel() ); - SfxWorkWindow *pWorkWin = pFrame->GetWorkWindow_Impl(); - if ( pWorkWin ) - pWorkWin->EndAutoShow_Impl( aPos ); - } - - return Window::PreNotify( rNEvt ); -} - -void SfxTopWindow_Impl::GetFocus() -{ - if ( pFrame && !pFrame->IsClosing_Impl() && pFrame->GetCurrentViewFrame() && pFrame->GetFrameInterface().is() ) - pFrame->GetCurrentViewFrame()->MakeActive_Impl( TRUE ); -} - -void SfxTopWindow_Impl::Resize() -{ - if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) - DoResize(); -} - -void SfxTopWindow_Impl::StateChanged( StateChangedType nStateChange ) -{ - if ( nStateChange == STATE_CHANGE_INITSHOW ) - { - pFrame->pImp->bHidden = FALSE; - if ( pFrame->IsInPlace() ) - // TODO/MBA: workaround for bug in LayoutManager: the final resize does not get through because the - // LayoutManager works asynchronously and between resize and time execution the DockingAcceptor was exchanged so that - // the resize event never is sent to the component - SetSizePixel( GetParent()->GetOutputSizePixel() ); - - DoResize(); - SfxViewFrame* pView = pFrame->GetCurrentViewFrame(); - if ( pView ) - pView->GetBindings().GetWorkWindow_Impl()->ShowChilds_Impl(); - } - - Window::StateChanged( nStateChange ); -} - -void SfxTopWindow_Impl::DoResize() -{ - if ( !pFrame->pImp->bLockResize ) - pFrame->Resize(); -} - -class StopButtonTimer_Impl : public Timer -{ - BOOL bState; - SfxViewFrame* pFrame; -protected: - virtual void Timeout(); -public: - StopButtonTimer_Impl( SfxViewFrame*); - void SetButtonState( BOOL bStateP ); - BOOL GetButtonState() const { return bState; } -}; - -StopButtonTimer_Impl::StopButtonTimer_Impl( SfxViewFrame*p) - : bState( FALSE ) - , pFrame( p ) -{ - SetTimeout( 200 ); -} - -void StopButtonTimer_Impl::SetButtonState( BOOL bStateP ) -{ - if( bStateP ) - { - bState = TRUE; - Stop(); - } - else if( bState ) - Start(); -} - -void StopButtonTimer_Impl::Timeout() -{ - bState = FALSE; - pFrame->GetBindings().Invalidate( SID_BROWSE_STOP ); -} - -class SfxTopViewWin_Impl : public Window -{ -friend class SfxInternalFrame; - - BOOL bActive; - SfxTopViewFrame* pFrame; - -public: - SfxTopViewWin_Impl( SfxTopViewFrame* p, - Window *pParent, WinBits nBits=0 ) : - Window( pParent, nBits | WB_BORDER | WB_CLIPCHILDREN ), - bActive( FALSE ), - pFrame( p ) - { - p->GetFrame()->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); - } - - virtual void Resize(); - virtual void StateChanged( StateChangedType nStateChange ); -}; - -//-------------------------------------------------------------------- -void SfxTopViewWin_Impl::StateChanged( StateChangedType nStateChange ) -{ - if ( nStateChange == STATE_CHANGE_INITSHOW ) - { - SfxObjectShell* pDoc = pFrame->GetObjectShell(); - if ( pDoc && !pFrame->IsVisible() ) - pFrame->Show(); - - pFrame->Resize(); - } - else - Window::StateChanged( nStateChange ); -} - -void SfxTopViewWin_Impl::Resize() -{ - if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) - pFrame->Resize(); -} - -class SfxTopViewFrame_Impl -{ -public: - sal_Bool bActive; - Window* pWindow; - String aFactoryName; - StopButtonTimer_Impl* pStopButtonTimer; - - SfxTopViewFrame_Impl() - : bActive( sal_False ) - , pWindow( 0 ) - , pStopButtonTimer( 0 ) - {} -}; - -static svtools::AsynchronLink* pPendingCloser = 0; - -static String _getTabString() -{ - String result; - - Reference < XMaterialHolder > xHolder( - ::comphelper::getProcessServiceFactory()->createInstance( - DEFINE_CONST_UNICODE("com.sun.star.tab.tabreg") ), UNO_QUERY ); - if (xHolder.is()) - { - rtl::OUString aTabString; - Sequence< NamedValue > sMaterial; - if (xHolder->getMaterial() >>= sMaterial) { - for (int i=0; i < sMaterial.getLength(); i++) { - if ((sMaterial[i].Name.equalsAscii("title")) && - (sMaterial[i].Value >>= aTabString)) - { - result += ' '; - result += String(aTabString); - } - } - } - } - return result; -} - -SfxTopFrame* SfxTopFrame::Create( SfxObjectShell* pDoc, USHORT nViewId, BOOL bHidden, const SfxItemSet* pSet ) -{ - Reference < XFrame > xDesktop ( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); - SfxTopFrame *pFrame = NULL; - BOOL bNewView = FALSE; - if ( pSet ) - { - SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_OPEN_NEW_VIEW, sal_False ); - bNewView = pItem && pItem->GetValue(); - } - - if ( pDoc && !bHidden && !bNewView ) - { - URL aTargetURL; - aTargetURL.Complete = pDoc->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); - - BOOL bIsBasic = FALSE; - if ( !aTargetURL.Complete.getLength() ) - { - String sFactory = String::CreateFromAscii(pDoc->GetFactory().GetShortName()); - bIsBasic = (sFactory.CompareIgnoreCaseToAscii("sbasic")==COMPARE_EQUAL); - - if (!bIsBasic) - { - String aURL = String::CreateFromAscii("private:factory/"); - aURL += sFactory; - aTargetURL.Complete = aURL; - } - } - - if (bIsBasic) - { - Reference < XFramesSupplier > xSupplier( xDesktop, UNO_QUERY ); - if (xSupplier.is()) - { - Reference < XIndexAccess > xContainer(xSupplier->getFrames(), UNO_QUERY); - if (xContainer.is()) - { - Reference< ::com::sun::star::frame::XModuleManager > xCheck(::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" )), UNO_QUERY); - sal_Int32 nCount = xContainer->getCount(); - for (sal_Int32 i=0; i<nCount; ++i) - { - try - { - Reference < XFrame > xFrame; - if (!(xContainer->getByIndex(i) >>= xFrame) || !xFrame.is()) - continue; - ::rtl::OUString sModule = xCheck->identify(xFrame); - if (sModule.equalsAscii("com.sun.star.frame.StartModule")) - { - pFrame = Create(xFrame); - break; - } - } - catch(const Exception&) {} - } - } - } - } - else - { - Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), UNO_QUERY ); - xTrans->parseStrict( aTargetURL ); - - Reference < ::com::sun::star::frame::XDispatchProvider > xProv( xDesktop, UNO_QUERY ); - Reference < ::com::sun::star::frame::XDispatch > xDisp; - if ( xProv.is() ) - { - Sequence < ::com::sun::star::beans::PropertyValue > aSeq(1); - aSeq[0].Name = ::rtl::OUString::createFromAscii("Model"); - aSeq[0].Value <<= pDoc->GetModel(); - ::rtl::OUString aTargetFrame( ::rtl::OUString::createFromAscii("_default") ); - xDisp = xProv->queryDispatch( aTargetURL, aTargetFrame , 0 ); - if ( xDisp.is() ) - xDisp->dispatch( aTargetURL, aSeq ); - } - - SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames; - for( USHORT nPos = rArr.Count(); nPos--; ) - { - SfxTopFrame *pF = (SfxTopFrame*) rArr[ nPos ]; - if ( pF->GetCurrentDocument() == pDoc ) - { - pFrame = pF; - break; - } - } - } - } - - if ( !pFrame ) - { - Reference < XFrame > xFrame = xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ); - pFrame = Create( xFrame ); - } - - pFrame->pImp->bHidden = bHidden; - Window* pWindow = pFrame->GetTopWindow_Impl(); - if ( pWindow && pDoc ) - { - ::rtl::OUString aDocServiceName( pDoc->GetFactory().GetDocumentServiceName() ); - ::rtl::OUString aProductName; - ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName; - String aTitle = pDoc->GetTitle( SFX_TITLE_DETECT ); - aTitle += String::CreateFromAscii( " - " ); - aTitle += String(aProductName); - aTitle += ' '; - aTitle += String( GetModuleName_Impl( aDocServiceName ) ); -#ifdef DBG_UTIL - ::rtl::OUString aDefault; - aTitle += DEFINE_CONST_UNICODE(" ["); - String aVerId( utl::Bootstrap::getBuildIdData( aDefault )); - aTitle += aVerId; - aTitle += ']'; -#endif - - // append TAB string if available - aTitle += _getTabString(); - - /* AS_TITLE - pWindow->SetText( aTitle ); - */ - - /* AS_ICON - if( pWindow->GetType() == WINDOW_WORKWINDOW ) - { - SvtModuleOptions::EFactory eFactory; - if( SvtModuleOptions::ClassifyFactoryByName( aDocServiceName, eFactory ) ) - { - WorkWindow* pWorkWindow = (WorkWindow*)pWindow; - pWorkWindow->SetIcon( (sal_uInt16) SvtModuleOptions().GetFactoryIcon( eFactory ) ); - } - } - */ - } - - pFrame->SetItemSet_Impl( pSet ); - if ( pDoc && pDoc != pFrame->GetCurrentDocument() ) - { - if ( nViewId ) - pDoc->GetMedium()->GetItemSet()->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) ); - pFrame->InsertDocument( pDoc ); - if ( pWindow && !bHidden ) - pWindow->Show(); - } - - return pFrame; -} - -SfxTopFrame* SfxTopFrame::Create( SfxObjectShell* pDoc, Window* pWindow, USHORT nViewId, BOOL bHidden, const SfxItemSet* pSet ) -{ - Reference < ::com::sun::star::lang::XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() ); - Reference < XFramesSupplier > xDesktop ( xFact->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY ); - Reference < XFrame > xFrame( xFact->createInstance( DEFINE_CONST_UNICODE("com.sun.star.frame.Frame") ), UNO_QUERY ); - - xFrame->initialize( VCLUnoHelper::GetInterface ( pWindow ) ); - if ( xDesktop.is() ) - xDesktop->getFrames()->append( xFrame ); - - uno::Reference< awt::XWindow2 > xWin( VCLUnoHelper::GetInterface ( pWindow ), uno::UNO_QUERY ); - if ( xWin.is() && xWin->isActive() ) - xFrame->activate(); - - SfxTopFrame* pFrame = new SfxTopFrame( pWindow ); - pFrame->SetFrameInterface_Impl( xFrame ); - pFrame->pImp->bHidden = bHidden; - - pFrame->SetItemSet_Impl( pSet ); - if ( pDoc ) - { - if ( nViewId ) - pDoc->GetMedium()->GetItemSet()->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) ); - pFrame->InsertDocument( pDoc ); - } - - return pFrame; -} - -SfxTopFrame* SfxTopFrame::Create( Reference < XFrame > xFrame ) -{ - // create a new TopFrame to an external XFrame object ( wrap controller ) - DBG_ASSERT( xFrame.is(), "Wrong parameter!" ); - - Window* pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); - SfxTopFrame* pFrame = new SfxTopFrame( pWindow ); - pFrame->SetFrameInterface_Impl( xFrame ); - return pFrame; -} - -SfxTopFrame::SfxTopFrame( Window* pExternal, sal_Bool bHidden ) - : SfxFrame( NULL ) - , pWindow( NULL ) -{ - pImp = new SfxTopFrame_Impl; - pImp->bHidden = bHidden; - pImp->bLockResize = FALSE; - pImp->bMenuBarOn = TRUE; - InsertTopFrame_Impl( this ); - if ( pExternal ) - { - pImp->pWindow = pExternal; - } - else - { - DBG_ERROR( "TopFrame without window created!" ); -/* - pImp->pWindow = new SfxTopFrameWindow_Impl( this ); - pImp->pWindow->SetActivateMode( ACTIVATE_MODE_GRABFOCUS ); - pImp->pWindow->SetPosSizePixel( Point( 20,20 ), Size( 800,600 ) ); - if ( GetFrameInterface().is() ) - GetFrameInterface()->initialize( VCLUnoHelper::GetInterface( pImp->pWindow ) ); - pImp->pWindow->Show(); - */ - } - - pWindow = new SfxTopWindow_Impl( this ); -/** AS: - Hide this window till the component was realy loaded. Otherwhise it overpaint e.g. the old component hardly - and produce repaint errors. - pWindow->Show(); - */ -} - -SfxTopFrame::~SfxTopFrame() -{ - RemoveTopFrame_Impl( this ); - DELETEZ( pWindow ); - delete pImp; -} - -void SfxTopFrame::SetPresentationMode( BOOL bSet ) -{ - if ( GetCurrentViewFrame() ) - GetCurrentViewFrame()->GetWindow().SetBorderStyle( bSet ? WINDOW_BORDER_NOBORDER : WINDOW_BORDER_NORMAL ); - - Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); - Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; - - if ( xPropSet.is() ) - { - Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); - aValue >>= xLayoutManager; - } - - if ( xLayoutManager.is() ) - xLayoutManager->setVisible( !bSet ); // we don't want to have ui in presentation mode - - SetMenuBarOn_Impl( !bSet ); - if ( GetWorkWindow_Impl() ) - GetWorkWindow_Impl()->SetDockingAllowed( !bSet ); - if ( GetCurrentViewFrame() ) - GetCurrentViewFrame()->GetDispatcher()->Update_Impl( TRUE ); -} - -SystemWindow* -SfxTopFrame::GetSystemWindow() const -{ - return GetTopWindow_Impl(); -} - -SystemWindow* SfxTopFrame::GetTopWindow_Impl() const -{ - if ( pImp->pWindow->IsSystemWindow() ) - return (SystemWindow*) pImp->pWindow; - else - return NULL; -} - -Window& SfxTopFrame::GetWindow() const -{ - return *pWindow; -} - -sal_Bool SfxTopFrame::Close() -{ - delete this; - return sal_True; -} - -void SfxTopFrame::LockResize_Impl( BOOL bLock ) -{ - pImp->bLockResize = bLock; -} - -IMPL_LINK( SfxTopWindow_Impl, CloserHdl, void*, EMPTYARG ) -{ - if ( pFrame && !pFrame->PrepareClose_Impl( TRUE ) ) - return 0L; - - if ( pFrame ) - pFrame->GetCurrentViewFrame()->GetBindings().Execute( SID_CLOSEWIN, 0, 0, SFX_CALLMODE_ASYNCHRON ); - return 0L; -} - -void SfxTopFrame::SetMenuBarOn_Impl( BOOL bOn ) -{ - pImp->bMenuBarOn = bOn; - - Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY ); - Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; - - if ( xPropSet.is() ) - { - Any aValue = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ))); - aValue >>= xLayoutManager; - } - - if ( xLayoutManager.is() ) - { - rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )); - - if ( bOn ) - xLayoutManager->showElement( aMenuBarURL ); - else - xLayoutManager->hideElement( aMenuBarURL ); - } -} - -BOOL SfxTopFrame::IsMenuBarOn_Impl() const -{ - return pImp->bMenuBarOn; -} - -String SfxTopFrame::GetWindowData() -{ - String aActWinData; - char cToken = ','; - - SfxViewFrame *pActFrame = SfxViewFrame::Current(); - SfxViewFrame *pFrame = GetCurrentViewFrame(); - const sal_Bool bActWin = ( pActFrame->GetTopViewFrame() == pFrame ); - - // ::com::sun::star::sdbcx::User-Daten der ViewShell - String aUserData; - pFrame->GetViewShell()->WriteUserData(aUserData); - - // assemble ini-data - String aWinData; - aWinData += String::CreateFromInt32( pFrame->GetCurViewId() ); - aWinData += cToken; - - aWinData += '1'; // former attribute "isfloating" - aWinData += cToken; - - // aktives kennzeichnen - aWinData += cToken; - aWinData += bActWin ? '1' : '0'; - - aWinData += cToken; - aWinData += aUserData; - - return aWinData; -} - -sal_Bool SfxTopFrame::InsertDocument( SfxObjectShell* pDoc ) -/* [Beschreibung] - */ -{ - // Spezielle Bedingungen testen: nicht im ModalMode! - if ( !SfxFrame::InsertDocument( pDoc ) ) - return sal_False; - - SfxObjectShell *pOld = GetCurrentDocument(); - - // Position und Groesse testen - // Wenn diese schon gesetzt sind, soll offensichtlich nicht noch - // LoadWindows_Impl aufgerufen werden ( z.B. weil dieses ein CreateFrame() - // an einer Task aufgerufen hat! ) - const SfxItemSet* pSet = GetItemSet_Impl(); - if ( !pSet ) - pSet = pDoc->GetMedium()->GetItemSet(); - SetItemSet_Impl(0); - - // Position und Gr"o\se - SFX_ITEMSET_ARG( - pSet, pAreaItem, SfxRectangleItem, SID_VIEW_POS_SIZE, sal_False ); - // View-Id - SFX_ITEMSET_ARG( - pSet, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False ); - // Zoom - SFX_ITEMSET_ARG( - pSet, pModeItem, SfxUInt16Item, SID_VIEW_ZOOM_MODE, sal_False ); - // Hidden - SFX_ITEMSET_ARG( - pSet, pHidItem, SfxBoolItem, SID_HIDDEN, sal_False); - // ViewDaten - SFX_ITEMSET_ARG( - pSet, pViewDataItem, SfxStringItem, SID_USER_DATA, sal_False ); - // ViewOnly - SFX_ITEMSET_ARG( - pSet, pEditItem, SfxBoolItem, SID_VIEWONLY, sal_False); - // InPlace (Hack) - SFX_ITEMSET_ARG( - pSet, pPluginItem, SfxUInt16Item, SID_PLUGIN_MODE, sal_False ); - - // Plugin (external InPlace) - SFX_ITEMSET_ARG( - pSet, pPluginMode, SfxUInt16Item, SID_PLUGIN_MODE, sal_False); - // Jump (GotoBookmark) - SFX_ITEMSET_ARG( - pSet, pJumpItem, SfxStringItem, SID_JUMPMARK, sal_False); - - if ( pEditItem && pEditItem->GetValue() ) - SetMenuBarOn_Impl( FALSE ); - - if ( pHidItem ) - pImp->bHidden = pHidItem->GetValue(); - - if( !pImp->bHidden ) - pDoc->OwnerLock( sal_True ); - - // Wenn z.B. eine Fenstergr"o\se gesetzt wurde, soll keine Fensterinformation - // aus den Dokument geladen werden, z.B. weil InsertDocument seinerseits - // aus LoadWindows_Impl aufgerufen wurde! - if ( !pJumpItem && !pPluginMode && pDoc && !pAreaItem && !pViewIdItem && !pModeItem && - pDoc->LoadWindows_Impl( this ) ) - { - if ( GetCurrentDocument() != pDoc ) - // something went wrong during insertion - return sal_False; - pDoc->OwnerLock( sal_False ); - return sal_True; - } - - if ( pDoc ) - { - UpdateHistory( pDoc ); - UpdateDescriptor( pDoc ); - } - - SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET ); - sal_Bool bBrowsing = sal_True; - SfxViewFrame *pFrame = GetCurrentViewFrame(); - if ( pFrame ) - { - sal_Bool bChildActivated = sal_False; - if ( pFrame->GetActiveChildFrame_Impl() && pFrame->GetActiveChildFrame_Impl() == SfxViewFrame::Current() ) - { -// ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier > xFrames( GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); -// if ( xFrames.is() ) -// xFrames->setActiveFrame( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > () ); - pFrame->SetActiveChildFrame_Impl(0); - SfxViewFrame::SetViewFrame( pFrame ); - bChildActivated = sal_True; - } - - if ( pFrame->GetObjectShell() ) - { - pFrame->ReleaseObjectShell_Impl( sal_False ); - } - - if ( pViewIdItem ) - pFrame->SetViewData_Impl( pViewIdItem->GetValue(), String() ); - if ( pDoc ) - pFrame->SetObjectShell_Impl( *pDoc ); - } - else - { - // 1: internal embedded object - // 2: external embedded object - // 3: OLE server - if ( pPluginItem && pPluginItem->GetValue() != 2 ) - SetInPlace_Impl( TRUE ); - - bBrowsing = sal_False; - pFrame = new SfxTopViewFrame( this, pDoc, pViewIdItem ? pViewIdItem->GetValue() : 0 ); - if ( !pFrame->GetViewShell() ) - return sal_False; - - if ( pPluginItem && pPluginItem->GetValue() == 1 ) - { - pFrame->ForceOuterResize_Impl( FALSE ); - pFrame->GetBindings().HidePopups(TRUE); - - // MBA: layoutmanager of inplace frame starts locked and invisible - GetWorkWindow_Impl()->MakeVisible_Impl( FALSE ); - GetWorkWindow_Impl()->Lock_Impl( TRUE ); - - GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); - if ( GetCurrentViewFrame() ) - GetCurrentViewFrame()->GetWindow().SetBorderStyle( WINDOW_BORDER_NOBORDER ); - } - } - - String aMark; - SFX_ITEMSET_ARG( pSet, pMarkItem, SfxStringItem, SID_JUMPMARK, FALSE ); - if ( pMarkItem ) - aMark = pMarkItem->GetValue(); - - if ( pDoc->Get_Impl()->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) - { - if ( pViewDataItem ) - pFrame->GetViewShell()->ReadUserData( pViewDataItem->GetValue(), sal_True ); - else if( aMark.Len() ) - GetCurrentViewFrame()->GetViewShell()->JumpToMark( aMark ); - } - else - { - // Daten setzen, die in FinishedLoading ausgewertet werden - MarkData_Impl*& rpMark = pDoc->Get_Impl()->pMarkData; - if (!rpMark) - rpMark = new MarkData_Impl; - rpMark->pFrame = GetCurrentViewFrame(); - if ( pViewDataItem ) - rpMark->aUserData = pViewDataItem->GetValue(); - else - rpMark->aMark = aMark; - } - - // Position und Groesse setzen - //sal_uInt16 nWinMode = pModeItem ? pModeItem->GetValue() : 1; - if ( pAreaItem && !pOld ) - { - Window *pWin = pImp->pWindow; - - // Groesse setzen - const Rectangle aWinRect( pAreaItem->GetValue() ); - const Size aAppWindow( pImp->pWindow->GetDesktopRectPixel().GetSize() ); - Point aPos( aWinRect.TopLeft() ); - Size aSz(aWinRect.GetSize()); - if ( aSz.Width() && aSz.Height() ) - { - aPos.X() = Min(aPos.X(), - long(aAppWindow.Width() - aSz.Width() + aSz.Width() / 2) ); - aPos.Y() = Min(aPos.Y(), - long( aAppWindow.Height() - aSz.Height() + aSz.Height() / 2) ); - if ( aPos.X() + aSz.Width() < - aAppWindow.Width() + aSz.Width() / 2 && - aPos.Y() + aSz.Height() < - aAppWindow.Height() + aSz.Height() / 2 ) - { - pWin->SetPosPixel( aPos ); - pWin->SetOutputSizePixel( aSz ); - } - } - } - - if ( !pImp->bHidden ) - { - if ( pDoc->IsHelpDocument() || (pPluginItem && pPluginItem->GetValue() == 2) ) - pFrame->GetDispatcher()->HideUI( TRUE ); - else - pFrame->GetDispatcher()->HideUI( FALSE ); - - if ( IsInPlace() ) - pFrame->LockAdjustPosSizePixel(); - - if ( pPluginMode && pPluginMode->GetValue() == 3) - GetWorkWindow_Impl()->SetInternalDockingAllowed(FALSE); - - if ( !IsInPlace() ) - pFrame->GetDispatcher()->Update_Impl(); - pFrame->Show(); - GetWindow().Show(); - if ( !IsInPlace() || (pPluginItem && pPluginItem->GetValue() == 3) ) - pFrame->MakeActive_Impl( GetFrameInterface()->isActive() ); - pDoc->OwnerLock( sal_False ); - - // Dont show container window! Its done by framework or directly - // by SfxTopFrame::Create() or SfxViewFrame::ExecView_Impl() ... - - if ( IsInPlace() ) - { - pFrame->UnlockAdjustPosSizePixel(); - // force resize for OLE server to fix layout problems of writer and math - // see i53651 - if ( pPluginItem && pPluginItem->GetValue() == 3 ) - pFrame->Resize(TRUE); - } - } - else - { - DBG_ASSERT( !IsInPlace() && !pPluginMode && !pPluginItem, "Special modes not compatible with hidden mode!" ); - GetWindow().Show(); - } - - // Jetzt UpdateTitle, hidden TopFrames haben sonst keinen Namen! - pFrame->UpdateTitle(); - - if ( !IsInPlace() ) - { - if ( pFrame->GetViewShell()->UseObjectSize() ) - { - GetCurrentViewFrame()->UnlockAdjustPosSizePixel(); - GetCurrentViewFrame()->Resize(TRUE); - GetCurrentViewFrame()->ForceInnerResize_Impl( FALSE ); - GetCurrentViewFrame()->Resize(TRUE); - } - else - GetCurrentViewFrame()->Resize(TRUE); - } - - SFX_APP()->NotifyEvent( SfxEventHint(SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), pDoc ) ); - return sal_True; -} - - -//======================================================================== - -long SfxViewFrameClose_Impl( void* /*pObj*/, void* pArg ) -{ - ((SfxViewFrame*)pArg)->GetFrame()->DoClose(); - return 0; -} - -TYPEINIT1(SfxTopFrame, SfxFrame); -TYPEINIT1(SfxTopViewFrame, SfxViewFrame); - -//-------------------------------------------------------------------- -SFX_IMPL_INTERFACE(SfxTopViewFrame,SfxViewFrame,SfxResId(0)) -{ -} - -//-------------------------------------------------------------------- -String SfxTopViewFrame::UpdateTitle() - -/* [Beschreibung] - - Mit dieser Methode kann der SfxTopViewFrame gezwungen werden, sich sofort - den neuen Titel vom der <SfxObjectShell> zu besorgen. - - [Anmerkung] - - Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener - zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren - m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxTopViewFrames) - jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung - nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden. - - - [Beispiel] - - void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) - { - if ( rHint.IsA(TYPE(SfxSimpleHint)) ) - { - switch( ( (SfxSimpleHint&) rHint ).GetId() ) - { - case SFX_HINT_TITLECHANGED: - for ( SfxTopViewFrame *pTop = (SfxTopViewFrame*) - SfxViewFrame::GetFirst(this, TYPE(SfxTopViewFrame)); - pTop; - pTop = (SfxTopViewFrame*) - SfxViewFrame::GetNext(this, TYPE(SfxTopViewFrame)); - { - pTop->UpdateTitle(); - ... pTop->GetName() ... - } - break; - ... - } - } - } -*/ - -{ - DBG_CHKTHIS(SfxTopViewFrame, 0); - - const SfxObjectFactory &rFact = GetObjectShell()->GetFactory(); - pImp->aFactoryName = String::CreateFromAscii( rFact.GetShortName() ); - - String aTitle = SfxViewFrame::UpdateTitle(); - - ::rtl::OUString aProductName; - ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName; - - aTitle += String::CreateFromAscii( " - " ); - aTitle += String(aProductName); - aTitle += ' '; - ::rtl::OUString aDocServiceName( GetObjectShell()->GetFactory().GetDocumentServiceName() ); - aTitle += String( GetModuleName_Impl( aDocServiceName ) ); -#ifdef DBG_UTIL - ::rtl::OUString aDefault; - aTitle += DEFINE_CONST_UNICODE(" ["); - String aVerId( utl::Bootstrap::getBuildIdData( aDefault )); - aTitle += aVerId; - aTitle += ']'; -#endif - - // append TAB string if available - aTitle += _getTabString(); - - GetBindings().Invalidate( SID_NEWDOCDIRECT ); - - /* AS_TITLE - Window* pWindow = GetTopFrame_Impl()->GetTopWindow_Impl(); - if ( pWindow && pWindow->GetText() != aTitle ) - pWindow->SetText( aTitle ); - */ - return aTitle; -} - -//-------------------------------------------------------------------- -void SfxTopViewFrame::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) -{ - {DBG_CHKTHIS(SfxTopViewFrame, 0);} - - if( IsDowning_Impl()) - return; - - // we know only SimpleHints - if ( rHint.IsA(TYPE(SfxSimpleHint)) ) - { - switch( ( (SfxSimpleHint&) rHint ).GetId() ) - { - case SFX_HINT_MODECHANGED: - case SFX_HINT_TITLECHANGED: - // when the document changes its title, change views too - UpdateTitle(); - break; - - case SFX_HINT_DEINITIALIZING: - // on all other changes force repaint - GetFrame()->DoClose(); - return; - } - } - - SfxViewFrame::Notify( rBC, rHint ); -} - -//-------------------------------------------------------------------- -sal_Bool SfxTopViewFrame::Close() -{ - {DBG_CHKTHIS(SfxTopViewFrame, 0);} - - // Modaler Dialog oben ?? -// if ( pImp->GetModalDialog() ) -// return sal_False; - - // eigentliches Schlie\sen - if ( SfxViewFrame::Close() ) - { - if (SfxViewFrame::Current() == this) - SfxViewFrame::SetViewFrame(0); - - // Da der Dispatcher leer ger"aumt wird, kann man ihn auch nicht mehr - // vern"unftig verwenden - also besser still legen - GetDispatcher()->Lock(sal_True); - delete this; - - return sal_True; - } - - return sal_False; -} - -SfxTopViewFrame::SfxTopViewFrame -( - SfxFrame* pFrame, - SfxObjectShell* pObjShell, - sal_uInt16 nViewId -) - -/* [Beschreibung] - - Ctor des SfxTopViewFrame f"ur eine <SfxObjectShell> aus der Ressource. - Die 'nViewId' der zu erzeugenden <SfxViewShell> kann angegeben werden - (default ist die zuerst registrierte SfxViewShell-Subklasse). -*/ - - : SfxViewFrame( *(new SfxBindings), pFrame, pObjShell, SFXFRAME_HASTITLE ) -{ - DBG_CTOR(SfxTopViewFrame, 0); - - pCloser = 0; - pImp = new SfxTopViewFrame_Impl; - pImp->pStopButtonTimer = new StopButtonTimer_Impl(this); - -//(mba)/task if ( !pFrame->GetTask() ) - { - pImp->pWindow = new SfxTopViewWin_Impl( this, &pFrame->GetWindow() ); - pImp->pWindow->SetSizePixel( pFrame->GetWindow().GetOutputSizePixel() ); - SetWindow_Impl( pImp->pWindow ); - pFrame->SetOwnsBindings_Impl( sal_True ); - pFrame->CreateWorkWindow_Impl(); - } - - sal_uInt32 nType = SFXFRAME_OWNSDOCUMENT | SFXFRAME_HASTITLE; - if ( pObjShell && pObjShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) - nType |= SFXFRAME_EXTERNAL; - GetFrame()->SetFrameType_Impl( GetFrame()->GetFrameType() | nType ); - - if ( GetFrame()->IsInPlace() ) - { - LockAdjustPosSizePixel(); - } - - try - { - if ( pObjShell ) - SwitchToViewShell_Impl( nViewId ); - } - catch (com::sun::star::uno::Exception& ) - { - // make sure that the ctor is left regularly - ReleaseObjectShell_Impl(); - return; - } - - if ( GetFrame()->IsInPlace() ) - { - UnlockAdjustPosSizePixel(); - } - else if ( GetViewShell() && GetViewShell()->UseObjectSize() ) - { - // initiale Gr"o\se festlegen - // Zuerst die logischen Koordinaten von IP-Objekt und EditWindow - // ber"ucksichtigen - LockAdjustPosSizePixel(); - ForceInnerResize_Impl( TRUE ); - - Window *pWindow = GetViewShell()->GetWindow(); - - // Da in den Applikationen bei der R"ucktransformation immer die - // Eckpunkte tranformiert werden und nicht die Size (um die Ecken - // alignen zu k"onnen), transformieren wir hier auch die Punkte, um - // m"oglichst wenig Rundungsfehler zu erhalten. -/* - Rectangle aRect = pWindow->LogicToLogic( GetObjectShell()->GetVisArea(), - GetObjectShell()->GetMapUnit(), - pWindow->GetMapMode() ); -*/ - Rectangle aRect = pWindow->LogicToPixel( GetObjectShell()->GetVisArea() ); - Size aSize = aRect.GetSize(); - GetViewShell()->GetWindow()->SetSizePixel( aSize ); - DoAdjustPosSizePixel(GetViewShell(), Point(), aSize ); - } -} - -//------------------------------------------------------------------------ -SfxTopViewFrame::~SfxTopViewFrame() -{ - DBG_DTOR(SfxTopViewFrame, 0); - - SetDowning_Impl(); - - if ( SfxViewFrame::Current() == this ) - SfxViewFrame::SetViewFrame(NULL); - - ReleaseObjectShell_Impl(); - if ( pPendingCloser == pCloser ) - pPendingCloser = 0; - delete pCloser; - if ( GetFrame()->OwnsBindings_Impl() ) - // Die Bindings l"oscht der Frame! - KillDispatcher_Impl(); - - delete pImp->pWindow; - delete pImp->pStopButtonTimer; - delete pImp; -} - -//------------------------------------------------------------------------ -sal_Bool SfxTopViewFrame::SetBorderPixelImpl( const SfxViewShell *pVSh, const SvBorder &rBorder ) -{ - if( SfxViewFrame::SetBorderPixelImpl( GetViewShell(), rBorder ) ) - { - if ( IsResizeInToOut_Impl() && !GetFrame()->IsInPlace() ) - { - Size aSize = pVSh->GetWindow()->GetOutputSizePixel(); - if ( aSize.Width() && aSize.Height() ) - { - aSize.Width() += rBorder.Left() + rBorder.Right(); - aSize.Height() += rBorder.Top() + rBorder.Bottom(); - - Size aOldSize = GetWindow().GetOutputSizePixel(); - GetWindow().SetOutputSizePixel( aSize ); - Window* pParent = &GetWindow(); - while ( pParent->GetParent() ) - pParent = pParent->GetParent(); - Size aOuterSize = pParent->GetOutputSizePixel(); - aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() ); - aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() ); - pParent->SetOutputSizePixel( aOuterSize ); - } - } - else - { - Point aPoint; - Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() ); - aEditArea.Left() += rBorder.Left(); - aEditArea.Right() -= rBorder.Right(); - aEditArea.Top() += rBorder.Top(); - aEditArea.Bottom() -= rBorder.Bottom(); - pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() ); - } - return sal_True; - - } - return sal_False; -} - -void SfxTopViewFrame::Exec_Impl(SfxRequest &rReq ) -{ - // Wenn gerade die Shells ausgetauscht werden... - if ( !GetObjectShell() || !GetViewShell() ) - return; - - switch ( rReq.GetSlot() ) - { - case SID_SHOWPOPUPS : - { - SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, SID_SHOWPOPUPS, FALSE); - BOOL bShow = pShowItem ? pShowItem->GetValue() : TRUE; - SFX_REQUEST_ARG(rReq, pIdItem, SfxUInt16Item, SID_CONFIGITEMID, FALSE); - USHORT nId = pIdItem ? pIdItem->GetValue() : 0; - - // ausfuehren - SfxWorkWindow *pWorkWin = GetFrame()->GetWorkWindow_Impl(); - if ( bShow ) - { - // Zuerst die Floats auch anzeigbar machen - pWorkWin->MakeChildsVisible_Impl( bShow ); - GetDispatcher()->Update_Impl( TRUE ); - - // Dann anzeigen - GetBindings().HidePopups( !bShow ); - } - else - { - // Alles hiden - SfxBindings *pBind = &GetBindings(); - while ( pBind ) - { - pBind->HidePopupCtrls_Impl( !bShow ); - pBind = pBind->GetSubBindings_Impl(); - } - - pWorkWin->HidePopups_Impl( !bShow, TRUE, nId ); - pWorkWin->MakeChildsVisible_Impl( bShow ); - } - - Invalidate( rReq.GetSlot() ); - rReq.Done(); - break; - } - - case SID_ACTIVATE: - { - MakeActive_Impl( TRUE ); - rReq.SetReturnValue( SfxObjectItem( 0, this ) ); - break; - } - - case SID_WIN_POSSIZE: - break; - - case SID_NEWDOCDIRECT : - { - SFX_REQUEST_ARG( rReq, pFactoryItem, SfxStringItem, SID_NEWDOCDIRECT, FALSE); - String aFactName; - if ( pFactoryItem ) - aFactName = pFactoryItem->GetValue(); - else if ( pImp->aFactoryName.Len() ) - aFactName = pImp->aFactoryName; - else - { - DBG_ERROR("Missing argument!"); - break; - } - - SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() ); - String aFact = String::CreateFromAscii("private:factory/"); - aFact += aFactName; - aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); - aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, GetFrame() ) ); - aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_blank" ) ) ); - SFX_APP()->ExecuteSlot( aReq ); - const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() ); - if ( pItem ) - rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) ); - break; - } - - case SID_CLOSEWIN: - { - // disable CloseWin, if frame is not a task - Reference < XCloseable > xTask( GetFrame()->GetFrameInterface(), UNO_QUERY ); - if ( !xTask.is() ) - break; - - if ( GetViewShell()->PrepareClose() ) - { - // weitere Views auf dasselbe Doc? - SfxObjectShell *pDocSh = GetObjectShell(); - int bOther = sal_False; - for ( const SfxTopViewFrame *pFrame = - (SfxTopViewFrame *)SfxViewFrame::GetFirst( pDocSh, TYPE(SfxTopViewFrame) ); - !bOther && pFrame; - pFrame = (SfxTopViewFrame *)SfxViewFrame::GetNext( *pFrame, pDocSh, TYPE(SfxTopViewFrame) ) ) - bOther = (pFrame != this); - - // Doc braucht nur gefragt zu werden, wenn keine weitere View - sal_Bool bClosed = sal_False; - sal_Bool bUI = TRUE; - if ( ( bOther || pDocSh->PrepareClose( bUI ) ) ) - { - if ( !bOther ) - pDocSh->SetModified( FALSE ); - rReq.Done(); // unbedingt vor Close() rufen! - bClosed = sal_False; - try - { - xTask->close(sal_True); - bClosed = sal_True; - } - catch( CloseVetoException& ) - { - bClosed = sal_False; - } - } - - rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bClosed )); - } - return; - } - } - - rReq.Done(); -} - -void SfxTopViewFrame::GetState_Impl( SfxItemSet &rSet ) -{ - SfxObjectShell *pDocSh = GetObjectShell(); - - if ( !pDocSh ) - return; - - const sal_uInt16 *pRanges = rSet.GetRanges(); - DBG_ASSERT(pRanges, "Set ohne Bereich"); - while ( *pRanges ) - { - for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich ) - { - switch(nWhich) - { - case SID_NEWDOCDIRECT : - { - if ( pImp->aFactoryName.Len() ) - { - String aFact = String::CreateFromAscii("private:factory/"); - aFact += pImp->aFactoryName; - rSet.Put( SfxStringItem( nWhich, aFact ) ); - } - break; - } - - case SID_NEWWINDOW: - rSet.DisableItem(nWhich); - break; - - case SID_CLOSEWIN: - { - // disable CloseWin, if frame is not a task - Reference < XCloseable > xTask( GetFrame()->GetFrameInterface(), UNO_QUERY ); - if ( !xTask.is() ) - rSet.DisableItem(nWhich); - break; - } - - case SID_SHOWPOPUPS : - break; - - case SID_WIN_POSSIZE: - { - rSet.Put( SfxRectangleItem( nWhich, Rectangle( - GetWindow().GetPosPixel(), GetWindow().GetSizePixel() ) ) ); - break; - } - - default: - DBG_ERROR( "invalid message-id" ); - } - } - ++pRanges; - } -} - -void SfxTopViewFrame::INetExecute_Impl( SfxRequest &rRequest ) -{ - sal_uInt16 nSlotId = rRequest.GetSlot(); - switch( nSlotId ) - { - case SID_BROWSE_FORWARD: - case SID_BROWSE_BACKWARD: - { - // Anzeige der n"achsten oder vorherigen Seite aus der History - SFX_REQUEST_ARG( rRequest, pSteps, SfxUInt16Item, nSlotId, sal_False ); - GetFrame()->Browse( nSlotId == SID_BROWSE_FORWARD, pSteps ? pSteps->GetValue() : 1, - (rRequest.GetModifier() & KEY_MOD1) != 0 ); - break; - } - case SID_CREATELINK: - { -/*! (pb) we need new implementation to create a link -*/ - break; - } - case SID_BROWSE_STOP: - { - if ( GetCancelManager() ) - GetCancelManager()->Cancel( TRUE ); - - // cancel jobs in hidden tasks - SfxFrameArr_Impl& rArr = *SFX_APP()->Get_Impl()->pTopFrames; - for( USHORT nPos = rArr.Count(); nPos--; ) - { - SfxFrame *pFrame = rArr[ nPos ]; - if ( !pFrame->GetCurrentViewFrame() ) - pFrame->GetCancelManager()->Cancel( TRUE ); - } - - break; - } - case SID_FOCUSURLBOX: - { - SfxStateCache *pCache = GetBindings().GetAnyStateCache_Impl( SID_OPENURL ); - if( pCache ) - { - SfxControllerItem* pCtrl = pCache->GetItemLink(); - while( pCtrl ) - { - pCtrl->StateChanged( SID_FOCUSURLBOX, SFX_ITEM_UNKNOWN, 0 ); - pCtrl = pCtrl->GetItemLink(); - } - } - } - } - - // Recording - rRequest.Done(); -} - -void SfxTopViewFrame::INetState_Impl( SfxItemSet &rItemSet ) -{ - if ( !GetFrame()->CanBrowseForward() ) - rItemSet.DisableItem( SID_BROWSE_FORWARD ); - - if ( !GetFrame()->CanBrowseBackward() ) - rItemSet.DisableItem( SID_BROWSE_BACKWARD ); - - // Add/SaveToBookmark bei BASIC-IDE, QUERY-EDITOR etc. disablen - SfxObjectShell *pDocSh = GetObjectShell(); - sal_Bool bPseudo = pDocSh && !( pDocSh->GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC ); - sal_Bool bEmbedded = pDocSh && pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED; - if ( !pDocSh || bPseudo || bEmbedded || !pDocSh->HasName() ) - rItemSet.DisableItem( SID_CREATELINK ); - - pImp->pStopButtonTimer->SetButtonState( GetCancelManager()->CanCancel() ); - if ( !pImp->pStopButtonTimer->GetButtonState() ) - rItemSet.DisableItem( SID_BROWSE_STOP ); -} - -void SfxTopViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) -{ - GetViewShell()->SetZoomFactor( rZoomX, rZoomY ); -} - -void SfxTopViewFrame::Activate( sal_Bool bMDI ) -{ - DBG_ASSERT(GetViewShell(), "Keine Shell"); - if ( bMDI ) - pImp->bActive = sal_True; -//(mba): hier evtl. wie in Beanframe NotifyEvent ?! -} - -void SfxTopViewFrame::Deactivate( sal_Bool bMDI ) -{ - DBG_ASSERT(GetViewShell(), "Keine Shell"); - if ( bMDI ) - pImp->bActive = sal_False; -//(mba): hier evtl. wie in Beanframe NotifyEvent ?! -} - -void SfxTopFrame::CheckMenuCloser_Impl( MenuBar* pMenuBar ) -{ - Reference < ::com::sun::star::frame::XFrame > xFrame = GetFrameInterface(); - - // checks if there is more than one "real" (not help) task window - // in this case a close button is inserted into the menubar - - DBG_ASSERT( xFrame.is(), "Attention: this bug is very hard to reproduce. Please try to remember how you triggered it!"); - if ( !xFrame.is() || !xFrame->getController().is() ) - // dummy component - return; - - Reference < ::com::sun::star::frame::XFramesSupplier > xDesktop( xFrame->getCreator(), UNO_QUERY ); - if ( !xDesktop.is() ) - // test only for task windows - return; - - sal_Bool bLastTask = sal_False; - Reference < ::com::sun::star::container::XIndexAccess > - xList ( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY ); - sal_Int32 nCount = xList->getCount(); - if ( nCount<=1 ) - // only one task - bLastTask = sal_True; - else if ( nCount==2 ) - { - // if we have to tasks, one can be the help task, that should be ignored - for( sal_Int32 i=0; i<nCount; ++i ) - { - Reference < ::com::sun::star::frame::XFrame > xTask; - ::com::sun::star::uno::Any aVal = xList->getByIndex(i); - if ( (aVal>>=xTask) && xTask.is() && xTask->getName().compareToAscii("OFFICE_HELP_TASK") == COMPARE_EQUAL ) - { - // one of the two open tasks was the help task -> ignored - bLastTask = sal_True; - break; - } - } - } - - pMenuBar->ShowCloser(bLastTask); -} diff --git a/sfx2/source/view/viewfac.cxx b/sfx2/source/view/viewfac.cxx index e8052594f8c8..b58bbc2840da 100644 --- a/sfx2/source/view/viewfac.cxx +++ b/sfx2/source/view/viewfac.cxx @@ -29,10 +29,8 @@ #include "precompiled_sfx2.hxx" // INCLUDE --------------------------------------------------------------- -#ifndef GCC -#endif - #include <sfx2/app.hxx> +#include <rtl/ustrbuf.hxx> #include "viewfac.hxx" // STATIC DATA ----------------------------------------------------------- @@ -51,6 +49,14 @@ void SfxViewFactory::InitFactory() (*fnInit)(); } +String SfxViewFactory::GetViewName() const +{ + ::rtl::OUStringBuffer aViewName; + aViewName.appendAscii( "view" ); + aViewName.append( sal_Int32( GetOrdinal() ) ); + return aViewName.makeStringAndClear(); +} + // CTOR / DTOR ----------------------------------------------------------- SfxViewFactory::SfxViewFactory( SfxViewCtor fnC, SfxViewInit fnI, diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 2291e8079b3a..66af0d7ac8ba 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> @@ -53,6 +54,7 @@ #endif #include <svtools/sfxecode.hxx> #include <svtools/ehdl.hxx> +#include <tools/diagnose_ex.h> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -61,8 +63,9 @@ #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/frame/XController.hpp> -#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/frame/XDispatchRecorderSupplier.hpp> #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/document/UpdateDocMode.hpp> @@ -76,6 +79,8 @@ #include <unotools/localfilehelper.hxx> #include <unotools/ucbhelper.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/configurationhelper.hxx> #include <com/sun/star/uno/Reference.h> @@ -94,6 +99,8 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; +using ::com::sun::star::awt::XWindow; +using ::com::sun::star::beans::PropertyValue; namespace css = ::com::sun::star; #ifndef GCC @@ -123,7 +130,7 @@ namespace css = ::com::sun::star; #include <sfx2/docfile.hxx> #include <sfx2/module.hxx> #include <sfx2/msgpool.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "viewimp.hxx" #include <sfx2/sfxbasecontroller.hxx> #include <sfx2/sfx.hrc> @@ -136,11 +143,14 @@ namespace css = ::com::sun::star; #include "macro.hxx" #include "minfitem.hxx" #include "../appl/app.hrc" +#include "impviewframe.hxx" + //------------------------------------------------------------------------- DBG_NAME(SfxViewFrame) #define SfxViewFrame #include "sfxslots.hxx" +#undef SfxViewFrame //------------------------------------------------------------------------- @@ -158,54 +168,6 @@ TYPEINIT1(SfxViewFrameItem, SfxPoolItem); //========================================================================= -struct SfxViewFrame_Impl -{ - SvBorder aBorder; - Size aMargin; - Size aSize; - String aViewData; - String aFrameTitle; - TypeId aLastType; - String aActualURL; - String aActualPresentationURL; - SfxFrame* pFrame; - SfxCancelManager* pCancelMgr; - svtools::AsynchronLink* pReloader; - //SfxInPlaceFrame* pIPFrame; - Window* pWindow; - SfxViewFrame* pActiveChild; - SfxViewFrame* pParentViewFrame; - SfxObjectShell* pImportShell; - Window* pFocusWin; - SfxMacro* pMacro; - sal_uInt16 nDocViewNo; - sal_uInt16 nCurViewId; - sal_Bool bResizeInToOut:1; - sal_Bool bDontOverwriteResizeInToOut:1; - sal_Bool bObjLocked:1; - sal_Bool bRestoreView:1; - sal_Bool bSetViewFrameLocked:1; - sal_Bool bReloading:1; - sal_Bool bIsDowning:1; - sal_Bool bInCtor:1; - sal_Bool bModal:1; - sal_Bool bEnabled:1; - sal_Bool bEventFlag:1; - sal_Bool bWindowWasEnabled:1; - - SfxViewFrame_Impl() - : pReloader(0 ) - , pMacro( 0 ) - , bWindowWasEnabled(sal_True) - {} - - ~SfxViewFrame_Impl() - { - delete pReloader; - delete pCancelMgr; - } -}; - //------------------------------------------------------------------------- void SfxViewFrame::SetDowning_Impl() { @@ -219,31 +181,7 @@ sal_Bool SfxViewFrame::IsDowning_Impl() const } -//------------------------------------------------------------------------- -void SfxViewFrame::SetSetViewFrameAllowed_Impl( sal_Bool bSet ) -{ - pImp->bSetViewFrameLocked = !bSet; -}; - -//------------------------------------------------------------------------- -sal_Bool SfxViewFrame::IsSetViewFrameAllowed_Impl() const -{ - return !pImp->bSetViewFrameLocked; -} - -//------------------------------------------------------------------------- -void SfxViewFrame::SetImportingObjectShell_Impl( SfxObjectShell* pSh ) -{ - pImp->pImportShell = pSh; -} - //-------------------------------------------------------------------- -SfxObjectShell* SfxViewFrame::GetImportingObjectShell_Impl() const -{ - return pImp->pImportShell; -} - - class SfxViewNotificatedFrameList_Impl : public SfxListener, public SfxViewFrameArr_Impl { @@ -299,7 +237,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq, sal_Bool bAsync ) void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { - SfxFrame *pParent = GetFrame()->GetParentFrame(); + SfxFrame *pParent = GetFrame().GetParentFrame(); if ( rReq.GetSlot() == SID_RELOAD ) { // Bei CTRL-Reload den aktiven Frame reloaden @@ -319,11 +257,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // Wenn nur ein Reload der Graphiken eines oder mehrerer ChildFrames // gemacht werden soll - SfxFrame *pFrame = GetFrame(); - if ( pParent == pFrame && pFrame->GetChildFrameCount() ) + SfxFrame& rFrame = GetFrame(); + if ( pParent == &rFrame && rFrame.GetChildFrameCount() ) { sal_Bool bReloadAvailable = sal_False; - SfxFrameIterator aIter( *pFrame, sal_False ); + SfxFrameIterator aIter( rFrame, sal_False ); SfxFrame *pChild = aIter.FirstFrame(); while ( pChild ) { @@ -356,13 +294,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } SfxObjectShell* pSh = GetObjectShell(); - sal_Bool bWasReadonly = pSh->IsReadOnly(); - switch ( rReq.GetSlot() ) { case SID_EDITDOC: { - if ( GetFrame()->HasComponent() ) + if ( GetFrame().HasComponent() ) break; // Wg. Doppeltbelegung in Toolboxen (mit/ohne Ctrl) ist es auch @@ -498,12 +434,11 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // r/o-Doc kann nicht in Editmode geschaltet werden? rReq.Done( sal_False ); - SFX_REQUEST_ARG( rReq, pFSetItem, SfxBoolItem, SID_EDIT_FRAMESET, sal_False); if ( nOpenMode == SFX_STREAM_READWRITE && !rReq.IsAPI() ) { // dem ::com::sun::star::sdbcx::User anbieten, als Vorlage zu oeffnen QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_OPENASTEMPLATE) ); - if ( !pFSetItem && RET_YES == aBox.Execute() ) + if ( RET_YES == aBox.Execute() ) { SfxApplication* pApp = SFX_APP(); SfxAllItemSet aSet( pApp->GetPool() ); @@ -544,16 +479,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) rReq.Done( sal_True ); // if( nOpenMode == SFX_STREAM_READONLY ) // pMed->Close(); - - // ReloadForEdit bei Framesets schaltet auch FramesetEditmode - sal_Bool bIsReadonly = GetObjectShell()->IsReadOnly(); - if ( bIsReadonly != bWasReadonly && !GetFrame()->GetParentFrame() ) - { - SfxBoolItem aItem( SID_EDIT_FRAMESET, !bIsReadonly ); - GetDispatcher()->Execute( SID_EDIT_FRAMESET, - SFX_CALLMODE_RECORD, &aItem, 0L ); - pSh->Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); - } return; } } @@ -596,7 +521,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // AutoLoad ist ggf. verboten SFX_REQUEST_ARG(rReq, pAutoLoadItem, SfxBoolItem, SID_AUTOLOAD, sal_False); if ( pAutoLoadItem && pAutoLoadItem->GetValue() && - GetFrame()->IsAutoLoadLocked_Impl() ) + GetFrame().IsAutoLoadLocked_Impl() ) return; SfxObjectShellLock xOldObj( pSh ); @@ -611,7 +536,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // ggf. beim User nachfragen sal_Bool bDo = ( GetViewShell()->PrepareClose() != FALSE ); SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False); - if ( bDo && GetFrame()->DocIsModified_Impl() && + if ( bDo && GetFrame().DocIsModified_Impl() && !rReq.IsAPI() && ( !pSilentItem || !pSilentItem->GetValue() ) ) { QueryBox aBox( &GetWindow(), SfxResId(MSG_QUERY_LASTVERSION) ); @@ -631,25 +556,21 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // bestehende SfxMDIFrames f"ur dieses Doc leeren // eigenes Format oder R/O jetzt editierbar "offnen? - SfxViewNotificatedFrameList_Impl aFrames; SfxObjectShellLock xNewObj; - sal_Bool bRestoreView = ( pURLItem == NULL ); - TypeId aOldType = xOldObj->Type(); - SfxViewFrame *pView = GetFirst(xOldObj); - while(pView) + // collect the views of the document + // TODO: when UNO ViewFactories are available for SFX-based documents, the below code should + // be UNOized, too + typedef ::std::pair< Reference< XFrame >, USHORT > ViewDescriptor; + ::std::list< ViewDescriptor > aViewFrames; + SfxViewFrame *pView = GetFirst( xOldObj ); + while ( pView ) { - if( bHandsOff ) - pView->GetDispatcher()->LockUI_Impl(sal_True); - aFrames.InsertViewFrame( pView ); - pView->GetBindings().ENTERREGISTRATIONS(); - - // RestoreView nur wenn keine neue Datei geladen - // (Client-Pull-Reloading) - pView = /*bHandsOff ? (SfxTopViewFrame*) GetFirst( - xOldObj, TYPE(SfxTopViewFrame) ) :*/ - (SfxTopViewFrame*)GetNext( *pView, xOldObj, - TYPE( SfxTopViewFrame ) ); + Reference< XFrame > xFrame( pView->GetFrame().GetFrameInterface() ); + OSL_ENSURE( xFrame.is(), "SfxViewFrame::ExecReload_Impl: no XFrame?!" ); + aViewFrames.push_back( ViewDescriptor( xFrame, pView->GetCurViewId() ) ); + + pView = GetNext( *pView, xOldObj ); } DELETEZ( xOldObj->Get_Impl()->pReloadTimer ); @@ -672,7 +593,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { pNewSet = new SfxAllItemSet( *pMedium->GetItemSet() ); pNewSet->ClearItem( SID_VIEW_ID ); - pNewSet->ClearItem( SID_USER_DATA ); pNewSet->ClearItem( SID_STREAM ); pNewSet->ClearItem( SID_INPUTSTREAM ); pNewSet->Put( SfxStringItem( SID_FILTER_NAME, pMedium->GetFilter()->GetName() ) ); @@ -741,9 +661,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False); SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSavedReferer, SfxStringItem, SID_REFERER, sal_False); - if( !pURLItem || pURLItem->GetValue() == xOldObj->GetMedium()->GetName() ) - xOldObj->Get_Impl()->bForbidCaching = sal_True; - sal_Bool bHasStorage = pMedium->HasStorage_Impl(); if( bHandsOff ) { @@ -758,12 +675,12 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) } xNewObj = SfxObjectShell::CreateObject( pFilter->GetServiceName(), SFX_CREATE_MODE_STANDARD ); + uno::Sequence < beans::PropertyValue > aLoadArgs; + TransformItems( SID_OPENDOC, *pNewSet, aLoadArgs ); try { - uno::Sequence < beans::PropertyValue > aProps; - TransformItems( SID_OPENDOC, *pNewSet, aProps ); uno::Reference < frame::XLoadable > xLoad( xNewObj->GetModel(), uno::UNO_QUERY ); - xLoad->load( aProps ); + xLoad->load( aLoadArgs ); } catch ( uno::Exception& ) { @@ -815,54 +732,41 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) { if ( xNewObj->IsDocShared() ) { - // the file is shared but the closing can chang the sharing control file + // the file is shared but the closing can change the sharing control file xOldObj->DoNotCleanShareControlFile(); } + // the Reload and Silent items were only temporary, remove them xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_RELOAD ); xNewObj->GetMedium()->GetItemSet()->ClearItem( SID_SILENT ); - UpdateDocument_Impl(); - } + TransformItems( SID_OPENDOC, *xNewObj->GetMedium()->GetItemSet(), aLoadArgs ); - SfxViewFrame* pThis = (SfxViewFrame*)this; - sal_Bool bDeleted = aFrames.C40_GETPOS( SfxViewFrame, pThis ) == USHRT_MAX; - - if( !bDeleted ) - { - GetBindings().Invalidate( SID_RELOAD ); - pImp->bReloading = sal_False; + UpdateDocument_Impl(); } - // neues Doc in die bestehenden SfxMDIFrames einsetzen; wenn - // das Reload geklappt hat, mu\s in diesem Frame kein Dokument - // eingesetzt werden, weil das schon vom LoadEnvironment - // gemacht wurde - if ( xNewObj.Is() && xNewObj->Type() != aOldType ) - // RestoreView nur, wenn gleicher Dokumenttyp - bRestoreView = sal_False; - - const sal_uInt16 nCount = aFrames.Count(); - for(sal_uInt16 i = 0; i < nCount; ++i) + if ( xNewObj.Is() ) { - SfxViewFrame *pCurrView = aFrames.GetObject( i ); - if ( xNewObj.Is() ) + try { - //if( /*!bHandsOff &&*/ this != pView ) - pCurrView->ReleaseObjectShell_Impl( bRestoreView ); - pCurrView->SetRestoreView_Impl( bRestoreView ); - //if( pView != this || !xNewObj.Is() ) + while ( !aViewFrames.empty() ) { - SfxFrame *pFrame = pCurrView->GetFrame(); - pFrame->InsertDocument(xNewObj.Is() ? xNewObj : xOldObj ); + LoadViewIntoFrame_Impl( *xNewObj, aViewFrames.front().first, aLoadArgs, aViewFrames.front().second, false ); + aViewFrames.pop_front(); + } + } + catch( const Exception& ) + { + // close the remaining frames + // Don't catch exceptions herein, if this fails, then we're left in an indetermined state, and + // crashing is better than trying to proceed + while ( !aViewFrames.empty() ) + { + Reference< util::XCloseable > xClose( aViewFrames.front().first, UNO_QUERY_THROW ); + xClose->close( sal_True ); + aViewFrames.pop_front(); } } - pCurrView->GetBindings().LEAVEREGISTRATIONS(); - pCurrView->GetDispatcher()->LockUI_Impl( sal_False ); - } - - if ( xNewObj.Is() ) - { // Propagate document closure. SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) ); } @@ -870,11 +774,6 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq ) // als erledigt recorden rReq.Done( sal_True ); rReq.SetReturnValue(SfxBoolItem(rReq.GetSlot(), sal_True)); - if( !bDeleted ) - { - Notify( *GetObjectShell(), SfxSimpleHint( - SFX_HINT_TITLECHANGED )); - } return; } else @@ -897,11 +796,11 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet ) // Ich bin gerade am Reloaden und Yielde so vor mich hin ... return; - GetFrame()->GetParentFrame(); + GetFrame().GetParentFrame(); SfxWhichIter aIter( rSet ); for ( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich() ) { - if ( GetFrame()->HasComponent() ) + if ( GetFrame().HasComponent() ) { // Wenn die Komponente es nicht selbst dispatched, dann // macht es auch keinen Sinn! @@ -929,16 +828,7 @@ void SfxViewFrame::StateReload_Impl( SfxItemSet& rSet ) case SID_RELOAD: { - SfxFrame* pFrame = GetTopFrame(); - SfxViewFrame *pView = pFrame->GetCurrentViewFrame(); - if ( pView && pView->GetViewShell() && - pView->GetViewShell()->IsImplementedAsFrameset_Impl() && - pView->GetViewShell()->GetInterface()->GetSlot( nWhich ) ) - { - // Hack f"ur Explorer: Reload wird an der ViewShell ausgef"uhrt - pView->GetViewShell()->GetSlotState( nWhich, 0, &rSet ); - break; - } + SfxFrame* pFrame = &GetTopFrame(); if ( !pSh || !pSh->CanReload_Impl() || pSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) rSet.DisableItem(nWhich); @@ -1009,7 +899,7 @@ void SfxViewFrame::ExecHistory_Impl( SfxRequest &rReq ) } else if ( GetViewShell() ) { - // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View + // der SW hat eigenes Undo an der View const SfxPoolItem *pRet = GetViewShell()->ExecuteSlot( rReq ); if ( pRet ) bOK = ((SfxBoolItem*)pRet)->GetValue(); @@ -1031,7 +921,7 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet ) SfxUndoManager *pShUndoMgr = pSh->GetUndoManager(); if ( !pShUndoMgr ) { - // der SW hat eigenes Undo an der ::com::sun::star::sdbcx::View + // der SW hat eigenes Undo an der View SfxWhichIter aIter( rSet ); SfxViewShell *pViewSh = GetViewShell(); if( !pViewSh ) return; @@ -1075,86 +965,30 @@ void SfxViewFrame::StateHistory_Impl( SfxItemSet &rSet ) } //-------------------------------------------------------------------- -void SfxViewFrame::SetObjectShell_Impl -( - SfxObjectShell& rObjSh, // eine initialisierte SfxObjectShell, - FASTBOOL bDefaultView // sal_True: nicht restaurieren -) - -/* [Beschreibung] - - Diese Methode setzt eine <SfxObjectShell> in den SfxViewFrame ein. - - Zuvor mu\s die vorherige SfxObjectShell, insofern schein eine gesetzt - wurde, mit der Methode ReleaseObjectShell() entfernt worden sein. Somit - kann durch Aufruf von ReleaseObjectShell() und SetObjectShell() die - SfxObjectShell ausgetauscht werden. - - - [Querverweise] - - <SfxViewFrame::ReleaseObjectShell()> -*/ - +void SfxViewFrame::PopShellAndSubShells_Impl( SfxViewShell& i_rViewShell ) { - DBG_CHKTHIS(SfxViewFrame, 0); - DBG_ASSERT( !xObjSh.Is(), "old feature used: only one Object per View!" ); - - GetFrame()->ReleasingComponent_Impl( sal_False ); - - // Doc einsetzen - xObjSh = &rObjSh; - if ( xObjSh.Is() && xObjSh->IsPreview() ) - SetQuietMode_Impl( sal_True ); - - GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET ); - - // Modulshell einf"ugen - SfxModule* pModule = xObjSh->GetModule(); - if( pModule ) - pDispatcher->InsertShell_Impl( *pModule, 1 ); - - pDispatcher->Push( rObjSh ); - pDispatcher->Flush(); - StartListening( rObjSh ); - - rObjSh.ViewAssigned(); - pDispatcher->SetReadOnly_Impl( rObjSh.IsReadOnly() ); - - const SfxMedium *pMedium = GetObjectShell()->GetMedium(); - SFX_ITEMSET_ARG( - pMedium->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False ); - if ( !pHiddenItem || !pHiddenItem->GetValue() ) + i_rViewShell.PopSubShells_Impl(); + sal_uInt16 nLevel = pDispatcher->GetShellLevel( i_rViewShell ); + if ( nLevel != USHRT_MAX ) { - LockObjectShell_Impl(sal_True); - GetDocNumber_Impl(); + if ( nLevel ) + { + // more sub shells on the stack, which were not affected by PopSubShells_Impl + SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 ); + if ( pSubShell == i_rViewShell.GetSubShell() ) + // "real" sub shells will be deleted elsewhere + pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL ); + else + pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE ); + } + pDispatcher->Pop( i_rViewShell ); + pDispatcher->Flush(); } - // ::com::sun::star::sdbcx::View erzeugen - if ( bDefaultView ) - SetRestoreView_Impl( sal_False ); - -// So darf man es nicht machen, da LaodWindows hierueber laeuft. Kann meiner Meinung nach -// auch nur beim Reload mit Dokumenttypwechsel passieren. -/* if ( xObjSh->Type() != pImp->aLastType ) - SetRestoreView_Impl( sal_False ); */ - - SwitchToViewShell_Impl( !IsRestoreView_Impl() ? (sal_uInt16) 0 : GetCurViewId() ); - rObjSh.PostActivateEvent_Impl( this ); - if ( Current() == this ) - SFX_APP()->NotifyEvent(SfxEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), &rObjSh ) ); - - Notify( rObjSh, SfxSimpleHint(SFX_HINT_TITLECHANGED) ); - Notify( rObjSh, SfxSimpleHint(SFX_HINT_DOCCHANGED) ); - - // Zur Sicherheit, aber eigentlich sollte jetzt nichts mehr passieren - // ( kein erzwungenes Update ) - if ( SfxViewFrame::Current() == this ) - GetDispatcher()->Update_Impl(); } //-------------------------------------------------------------------- -void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView ) +void SfxViewFrame::ReleaseObjectShell_Impl() /* [Beschreibung] @@ -1166,7 +1000,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView ) die SfxObjectShell ausgetauscht werden. Zwischen RealeaseObjectShell() und SetObjectShell() darf die Kontrolle - nicht an das ::com::sun::star::chaos::System abgegeben werden. + nicht an das System abgegeben werden. [Querverweise] @@ -1177,7 +1011,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView ) DBG_CHKTHIS(SfxViewFrame, 0); DBG_ASSERT( xObjSh.Is(), "no SfxObjectShell to release!" ); - GetFrame()->ReleasingComponent_Impl( sal_True ); + GetFrame().ReleasingComponent_Impl( sal_True ); if ( GetWindow().HasChildPathFocus( sal_True ) ) { DBG_ASSERT( !GetActiveChildFrame_Impl(), "Wrong active child frame!" ); @@ -1187,25 +1021,7 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView ) SfxViewShell *pDyingViewSh = GetViewShell(); if ( pDyingViewSh ) { - SetRestoreView_Impl( bStoreView ); - if ( bStoreView ) - pDyingViewSh->WriteUserData( GetViewData_Impl(), sal_True ); - - // Jetzt alle SubShells wechhauen - pDyingViewSh->PushSubShells_Impl( sal_False ); - sal_uInt16 nLevel = pDispatcher->GetShellLevel( *pDyingViewSh ); - if ( nLevel && nLevel != USHRT_MAX ) - { - // Es gibt immer nocht SubShells - SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 ); - if ( pSubShell == pDyingViewSh->GetSubShell() ) - //"Echte" Subshells nicht deleten - pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL ); - else - pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE ); - } - pDispatcher->Pop( *pDyingViewSh ); - pDispatcher->Flush(); + PopShellAndSubShells_Impl( *pDyingViewSh ); pDyingViewSh->DisconnectAllClients(); SetViewShell_Impl(0); delete pDyingViewSh; @@ -1244,116 +1060,26 @@ void SfxViewFrame::ReleaseObjectShell_Impl( sal_Bool bStoreView ) GetDispatcher()->SetDisableFlags( 0 ); } -//------------------------------------------------------------------------- - -String SfxViewFrame::UpdateTitle() - -/* [Beschreibung] - - Mit dieser Methode kann der SfxMDIFrame gezwungen werden, sich sofort - den neuen Titel vom der <SfxObjectShell> zu besorgen. - - [Anmerkung] - - Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener - zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren - m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxMDIFrames) - jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung - nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden. - - - [Beispiel] - - void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) - { - if ( rHint.IsA(TYPE(SfxSimpleHint)) ) - { - switch( ( (SfxSimpleHint&) rHint ).GetId() ) - { - case SFX_HINT_TITLECHANGED: - for ( SfxMDIFrame *pMDI = (SfxMDIFrame*) - SfxViewFrame::GetFirst(this, TYPE(SfxMDIFrame)); - pMDI; - pMDI = (SfxMDIFrame*) - SfxViewFrame::GetNext(this, TYPE(SfxMDIFrame)); - { - pMDI->UpdateTitle(); - ... pMDI->GetName() ... - } - break; - ... - } - } - } -*/ - -{ - SfxObjectShell *pObjSh = GetObjectShell(); - if ( !pObjSh ) - return String(); - -// if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) -// // kein UpdateTitle mit Embedded-ObjectShell -// return String(); - - const SfxMedium *pMedium = pObjSh->GetMedium(); - String aURL; - GetFrame(); // -Wall required?? - if ( pObjSh->HasName() ) - { - INetURLObject aTmp( pMedium->GetName() ); - aURL = aTmp.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); - } - - if ( aURL != pImp->aActualURL ) - // URL hat sich ge"andert - pImp->aActualURL = aURL; - - // gibt es noch eine weitere View? - sal_uInt16 nViews=0; - for ( SfxViewFrame *pView= GetFirst(pObjSh); - pView && nViews<2; - pView = GetNext(*pView,pObjSh) ) - if ( ( pView->GetFrameType() & SFXFRAME_HASTITLE ) && - !IsDowning_Impl()) - nViews++; - - // Titel des Fensters - String aTitle; - if ( nViews == 2 || pImp->nDocViewNo > 1 ) - // dann die Nummer dranh"angen - aTitle = pObjSh->UpdateTitle( NULL, pImp->nDocViewNo ); - else - aTitle = pObjSh->UpdateTitle(); - - // Name des SbxObjects - String aSbxName = pObjSh->SfxShell::GetName(); - if ( IsVisible() ) - { - aSbxName += ':'; - aSbxName += String::CreateFromInt32(pImp->nDocViewNo); - } - - SetName( aSbxName ); - pImp->aFrameTitle = aTitle; - GetBindings().Invalidate( SID_FRAMETITLE ); - GetBindings().Invalidate( SID_CURRENT_URL ); - return aTitle; -} - - //-------------------------------------------------------------------- sal_Bool SfxViewFrame::Close() { DBG_CHKTHIS(SfxViewFrame, 0); - DBG_ASSERT( GetFrame()->IsClosing_Impl() || !GetFrame()->GetFrameInterface().is(), "ViewFrame closed too early!" ); + DBG_ASSERT( GetFrame().IsClosing_Impl() || !GetFrame().GetFrameInterface().is(), "ViewFrame closed too early!" ); // Wenn bis jetzt noch nicht gespeichert wurde, sollen eingebettete Objekte // auch nicht mehr automatisch gespeichert werden! if ( GetViewShell() ) GetViewShell()->DiscardClients_Impl(); - Broadcast( SfxSimpleHint(SFX_HINT_DYING) ); + Broadcast( SfxSimpleHint( SFX_HINT_DYING ) ); + + if (SfxViewFrame::Current() == this) + SfxViewFrame::SetViewFrame( NULL ); + + // Da der Dispatcher leer ger"aumt wird, kann man ihn auch nicht mehr + // vern"unftig verwenden - also besser still legen + GetDispatcher()->Lock(sal_True); + delete this; return sal_True; } @@ -1394,7 +1120,7 @@ void SfxViewFrame::DoActivate( sal_Bool bUI, SfxViewFrame* pOldFrame ) SfxViewFrame *pFrame = GetParentViewFrame(); while ( pFrame ) { - if ( !pOldFrame || !pOldFrame->GetFrame()->IsParent( pFrame->GetFrame() ) ) + if ( !pOldFrame || !pOldFrame->GetFrame().IsParent( &pFrame->GetFrame() ) ) pFrame->pDispatcher->DoParentActivate_Impl(); pFrame = pFrame->GetParentViewFrame(); } @@ -1412,8 +1138,8 @@ void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame ) // ViewFrames, erh"alt er ein ParentDeactivate if ( bUI ) { -// if ( GetFrame()->GetWorkWindow_Impl() ) -// GetFrame()->GetWorkWindow_Impl()->SaveStatus_Impl(); +// if ( GetFrame().GetWorkWindow_Impl() ) +// GetFrame().GetWorkWindow_Impl()->SaveStatus_Impl(); /* SfxMedium* pMed = GetObjectShell() ? GetObjectShell()->GetMedium() : NULL; if( pMed ) @@ -1428,7 +1154,7 @@ void SfxViewFrame::DoDeactivate(sal_Bool bUI, SfxViewFrame* pNewFrame ) SfxViewFrame *pFrame = GetParentViewFrame(); while ( pFrame ) { - if ( !pNewFrame || !pNewFrame->GetFrame()->IsParent( pFrame->GetFrame() ) ) + if ( !pNewFrame || !pNewFrame->GetFrame().IsParent( &pFrame->GetFrame() ) ) pFrame->pDispatcher->DoParentDeactivate_Impl(); pFrame = pFrame->GetParentViewFrame(); } @@ -1445,7 +1171,7 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh ) { if ( GetViewShell() && GetWindow().IsVisible() ) { - if ( GetFrame()->IsInPlace() ) + if ( GetFrame().IsInPlace() ) { /* Size aSize( GetViewShell()->GetWindow()->GetSizePixel() ); @@ -1457,24 +1183,8 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh ) return; } - if ( GetViewShell()->UseObjectSize() ) - { - // Zun"achst die Gr"o\se des MDI-Fensters berechnen - - DoAdjustPosSizePixel( GetViewShell(), Point(), - GetViewShell()->GetWindow()->GetSizePixel() ); - - // Da nach einem InnerResize die Position des EditFensters und - // damit auch der Tools nocht stimmt, mu\s nun noch einmal von - // au\sen resized werden ! - - ForceOuterResize_Impl(sal_True); - } - DoAdjustPosSizePixel( (SfxViewShell *) GetViewShell(), Point(), GetWindow().GetOutputSizePixel() ); - if ( GetViewShell()->UseObjectSize() ) - ForceOuterResize_Impl(sal_False); } } } @@ -1482,12 +1192,43 @@ void SfxViewFrame::InvalidateBorderImpl( const SfxViewShell* pSh ) //------------------------------------------------------------------------ sal_Bool SfxViewFrame::SetBorderPixelImpl ( - const SfxViewShell* /*pSh*/, + const SfxViewShell* pVSh, const SvBorder& rBorder ) { pImp->aBorder = rBorder; + + if ( IsResizeInToOut_Impl() && !GetFrame().IsInPlace() ) + { + Size aSize = pVSh->GetWindow()->GetOutputSizePixel(); + if ( aSize.Width() && aSize.Height() ) + { + aSize.Width() += rBorder.Left() + rBorder.Right(); + aSize.Height() += rBorder.Top() + rBorder.Bottom(); + + Size aOldSize = GetWindow().GetOutputSizePixel(); + GetWindow().SetOutputSizePixel( aSize ); + Window* pParent = &GetWindow(); + while ( pParent->GetParent() ) + pParent = pParent->GetParent(); + Size aOuterSize = pParent->GetOutputSizePixel(); + aOuterSize.Width() += ( aSize.Width() - aOldSize.Width() ); + aOuterSize.Height() += ( aSize.Height() - aOldSize.Height() ); + pParent->SetOutputSizePixel( aOuterSize ); + } + } + else + { + Point aPoint; + Rectangle aEditArea( aPoint, GetWindow().GetOutputSizePixel() ); + aEditArea.Left() += rBorder.Left(); + aEditArea.Right() -= rBorder.Right(); + aEditArea.Top() += rBorder.Top(); + aEditArea.Bottom() -= rBorder.Bottom(); + pVSh->GetWindow()->SetPosSizePixel( aEditArea.TopLeft(), aEditArea.GetSize() ); + } + return sal_True; } @@ -1505,15 +1246,22 @@ const SvBorder& SfxViewFrame::GetBorderPixelImpl void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { {DBG_CHKTHIS(SfxViewFrame, 0);} - if ( !xObjSh.Is() ) + + if( IsDowning_Impl()) return; + // we know only SimpleHints if ( rHint.IsA(TYPE(SfxSimpleHint)) ) { switch( ( (SfxSimpleHint&) rHint ).GetId() ) { case SFX_HINT_MODECHANGED: { + UpdateTitle(); + + if ( !xObjSh.Is() ) + break; + // r/o Umschaltung? SfxBindings& rBind = GetBindings(); rBind.Invalidate( SID_RELOAD ); @@ -1555,13 +1303,15 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) break; } - case SFX_HINT_DYING: case SFX_HINT_DEINITIALIZING: + GetFrame().DoClose(); + break; + case SFX_HINT_DYING: // when the Object is being deleted, destroy the view too if ( xObjSh.Is() ) ReleaseObjectShell_Impl(); else - GetFrame()->DoClose(); + GetFrame().DoClose(); break; } @@ -1586,6 +1336,9 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) case SFX_EVENT_OPENDOC: case SFX_EVENT_CREATEDOC: { + if ( !xObjSh.Is() ) + break; + SfxBindings& rBind = GetBindings(); rBind.Invalidate( SID_RELOAD ); rBind.Invalidate( SID_EDITDOC ); @@ -1609,7 +1362,7 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) case SFX_EVENT_TOGGLEFULLSCREENMODE: { - if ( GetFrame()->OwnsBindings_Impl() ) + if ( GetFrame().OwnsBindings_Impl() ) GetBindings().GetDispatcher_Impl()->Update_Impl( sal_True ); break; } @@ -1620,26 +1373,18 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) //------------------------------------------------------------------------ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) { - pImp->pFrame->DocumentInserted( pObjSh ); - pImp->bInCtor = sal_True; - pImp->pParentViewFrame = 0; pImp->bResizeInToOut = sal_True; pImp->bDontOverwriteResizeInToOut = sal_False; - pImp->pImportShell = 0; pImp->bObjLocked = sal_False; - pImp->bEventFlag = sal_True; pImp->pFocusWin = 0; pImp->pActiveChild = NULL; - pImp->bRestoreView = sal_False; pImp->nCurViewId = 0; - pImp->bSetViewFrameLocked = sal_False; pImp->bReloading = sal_False; pImp->bIsDowning = sal_False; pImp->bModal = sal_False; pImp->bEnabled = sal_True; pImp->nDocViewNo = 0; pImp->aMargin = Size( -1, -1 ); - pImp->pCancelMgr = 0; pImp->pWindow = 0; SetPool( &SFX_APP()->GetPool() ); @@ -1651,7 +1396,6 @@ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) if ( xObjSh.Is() && xObjSh->IsPreview() ) SetQuietMode_Impl( sal_True ); - GetFrame()->SetFrameType_Impl( GetFrameType() & ~SFXFRAME_FRAMESET ); if ( pObjSh ) { pDispatcher->Push( *SFX_APP() ); @@ -1677,56 +1421,36 @@ void SfxViewFrame::Construct_Impl( SfxObjectShell *pObjSh ) SfxViewFrame *pThis = this; // wegen der kranken Array-Syntax SfxViewFrameArr_Impl &rViewArr = SFX_APP()->GetViewFrames_Impl(); rViewArr.C40_INSERT(SfxViewFrame, pThis, rViewArr.Count() ); - pImp->bInCtor = sal_False; } -//------------------------------------------------------------------------ -SfxViewFrame::SfxViewFrame( SfxObjectShell &rObjShell, SfxBindings &rBindings, - SfxFrame* pParent, sal_uInt32 nType ) -: - pImp( new SfxViewFrame_Impl ), - pDispatcher(0), - pBindings(&rBindings), - nAdjustPosPixelLock( 0 ) -{ - DBG_CTOR(SfxViewFrame, 0); - - SetFrame_Impl( pParent ); - pImp->pFrame->SetCurrentViewFrame_Impl( this ); - GetFrame()->SetFrameType_Impl( GetFrameType() | nType ); - Construct_Impl( &rObjShell ); -} +SfxViewFrame::SfxViewFrame +( + SfxFrame& rFrame, + SfxObjectShell* pObjShell +) -//------------------------------------------------------------------------ -SfxViewFrame::SfxViewFrame(const SfxViewFrame &rCopy, SfxBindings &rBindings, - SfxFrame *pFrame ) -: - pImp( new SfxViewFrame_Impl ), - pDispatcher(0), - pBindings(&rBindings), - nAdjustPosPixelLock( 0 ) -{ - DBG_CTOR(SfxViewFrame, 0); +/* [Beschreibung] - SetFrame_Impl( pFrame ); - pImp->pFrame->SetCurrentViewFrame_Impl( this ); - GetFrame()->SetFrameType_Impl( rCopy.GetFrameType() ); - Construct_Impl( rCopy.GetObjectShell() ); -} + Ctor des SfxViewFrame f"ur eine <SfxObjectShell> aus der Ressource. + Die 'nViewId' der zu erzeugenden <SfxViewShell> kann angegeben werden + (default ist die zuerst registrierte SfxViewShell-Subklasse). +*/ -SfxViewFrame::SfxViewFrame( SfxBindings& rBindings, SfxFrame *pFrame, - SfxObjectShell *pDoc, sal_uInt32 nType ) - : pImp( new SfxViewFrame_Impl ) + : pImp( new SfxViewFrame_Impl( rFrame ) ) , pDispatcher(0) - , pBindings(&rBindings) + , pBindings( new SfxBindings ) , nAdjustPosPixelLock( 0 ) { - DBG_CTOR(SfxViewFrame, 0); + DBG_CTOR( SfxViewFrame, NULL ); + + rFrame.SetCurrentViewFrame_Impl( this ); + rFrame.SetFrameType_Impl( GetFrameType() | SFXFRAME_HASTITLE ); + Construct_Impl( pObjShell ); - SetFrame_Impl( pFrame ); - pImp->pFrame->SetCurrentViewFrame_Impl( this ); - GetFrame()->SetFrameType_Impl( GetFrameType() | nType ); - Construct_Impl( pDoc); + pImp->pWindow = new SfxFrameViewWindow_Impl( this, rFrame.GetWindow() ); + pImp->pWindow->SetSizePixel( rFrame.GetWindow().GetOutputSizePixel() ); + rFrame.SetOwnsBindings_Impl( sal_True ); + rFrame.CreateWorkWindow_Impl(); } //------------------------------------------------------------------------ @@ -1734,12 +1458,21 @@ SfxViewFrame::~SfxViewFrame() { DBG_DTOR(SfxViewFrame, 0); - if ( GetFrame() && GetFrame()->GetCurrentViewFrame() == this ) - GetFrame()->SetCurrentViewFrame_Impl( NULL ); + SetDowning_Impl(); - SfxObjectShell* pSh = pImp->pImportShell; - if( pSh ) - pSh->AbortImport(); + if ( SfxViewFrame::Current() == this ) + SfxViewFrame::SetViewFrame( NULL ); + + ReleaseObjectShell_Impl(); + + if ( GetFrame().OwnsBindings_Impl() ) + // Die Bindings l"oscht der Frame! + KillDispatcher_Impl(); + + delete pImp->pWindow; + + if ( GetFrame().GetCurrentViewFrame() == this ) + GetFrame().SetCurrentViewFrame_Impl( NULL ); // von Frame-Liste abmelden SfxApplication *pSfxApp = SFX_APP(); @@ -1781,12 +1514,11 @@ SfxViewFrame* SfxViewFrame::Current() } //-------------------------------------------------------------------- -sal_uInt16 SfxViewFrame::Count(TypeId aType) +sal_uInt16 SfxViewFrame::Count() /* [Beschreibung] - Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen vom Typ - 'aType' bzw. aller sichtbaren, falls 'aType==0' (default). + Liefert die Anzahl der sichtbaren <SfxViewFrame>-Instanzen. */ { @@ -1797,8 +1529,7 @@ sal_uInt16 SfxViewFrame::Count(TypeId aType) for ( sal_uInt16 i = 0; i < nCount; ++i ) { SfxViewFrame *pFrame = rFrames[i]; - if ( ( !aType || pFrame->IsA(aType) ) && - pFrame->IsVisible() ) + if ( pFrame->IsVisible() ) ++nFound; } return nFound; @@ -1809,7 +1540,6 @@ sal_uInt16 SfxViewFrame::Count(TypeId aType) SfxViewFrame* SfxViewFrame::GetFirst ( const SfxObjectShell* pDoc, - TypeId aType, sal_Bool bOnlyIfVisible ) { @@ -1820,9 +1550,9 @@ SfxViewFrame* SfxViewFrame::GetFirst for ( sal_uInt16 nPos = 0; nPos < rFrames.Count(); ++nPos ) { SfxViewFrame *pFrame = rFrames.GetObject(nPos); - if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && - ( !aType || pFrame->IsA(aType) ) && - ( !bOnlyIfVisible || pFrame->IsVisible()) ) + if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) + && ( !bOnlyIfVisible || pFrame->IsVisible() ) + ) return pFrame; } @@ -1835,7 +1565,6 @@ SfxViewFrame* SfxViewFrame::GetNext ( const SfxViewFrame& rPrev, const SfxObjectShell* pDoc, - TypeId aType, sal_Bool bOnlyIfVisible ) { @@ -1852,9 +1581,9 @@ SfxViewFrame* SfxViewFrame::GetNext for ( ++nPos; nPos < rFrames.Count(); ++nPos ) { SfxViewFrame *pFrame = rFrames.GetObject(nPos); - if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && - ( !aType || pFrame->IsA(aType) ) && - ( !bOnlyIfVisible || pFrame->IsVisible()) ) + if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) + && ( !bOnlyIfVisible || pFrame->IsVisible() ) + ) return pFrame; } return 0; @@ -1887,7 +1616,7 @@ void SfxViewFrame::ShowStatusText( const String& /*rText*/) /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx & framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be extended to support a new interface to support ShowStatusText/HideStatusText - SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl(); SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl(); if ( pMgr ) { @@ -1903,7 +1632,7 @@ void SfxViewFrame::HideStatusText() /* OBSOLETE: If this is used, framework/uielement/progressbarwrapper.[h|c]xx & framework/uielement/statusindicatorinterfacewrapper.[h|c]xx must be extended to support a new interface to support ShowStatusText/HideStatusText - SfxWorkWindow* pWorkWin = GetFrame()->GetWorkWindow_Impl(); + SfxWorkWindow* pWorkWin = GetFrame().GetWorkWindow_Impl(); SfxStatusBarManager *pMgr = pWorkWin->GetStatusBarManager_Impl(); if ( pMgr ) pMgr->GetStatusBar()->ShowItems(); @@ -1978,7 +1707,7 @@ void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh ) SfxShell::SetViewShell_Impl( pVSh ); // Hack: InPlaceMode - if ( pVSh && !pVSh->UseObjectSize() ) + if ( pVSh ) pImp->bResizeInToOut = sal_False; } @@ -1988,21 +1717,10 @@ void SfxViewFrame::SetViewShell_Impl( SfxViewShell *pVSh ) Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace */ -void SfxViewFrame::SetParentViewFrame_Impl(SfxViewFrame *pFrame) -{ - pImp->pParentViewFrame = pFrame; -} - -//-------------------------------------------------------------------- -/* - Beschreibung: - Der ParentViewFrame ist der ViewFrame des Containers bei internem InPlace -*/ - //TODO/LATER: is it still necessary? is there a replacement for GetParentViewFrame_Impl? SfxViewFrame* SfxViewFrame::GetParentViewFrame_Impl() const { - return pImp->pParentViewFrame; + return NULL; } //-------------------------------------------------------------------- @@ -2027,7 +1745,7 @@ void SfxViewFrame::DoAdjustPosSize( SfxViewShell *pSh, const Point rPos, const Size &rSize ) { DBG_CHKTHIS(SfxViewFrame, 0); - if( pSh && !nAdjustPosPixelLock && pSh->UseObjectSize()) + if( pSh && !nAdjustPosPixelLock ) { Window *pWindow = pSh->GetWindow(); Point aPos = pWindow->LogicToPixel(rPos); @@ -2060,7 +1778,7 @@ void SfxViewFrame::Enable( sal_Bool bEnable ) } else { - Window *pWindow = &GetFrame()->GetTopFrame()->GetWindow(); + Window *pWindow = &GetFrame().GetTopFrame().GetWindow(); if ( !bEnable ) pImp->bWindowWasEnabled = pWindow->IsInputEnabled(); if ( !bEnable || pImp->bWindowWasEnabled ) @@ -2110,7 +1828,7 @@ void SfxViewFrame::Show() LockObjectShell_Impl( sal_True ); // Doc-Shell Titel-Nummer anpassen, get unique view-no - if ( 0 == pImp->nDocViewNo && !(GetFrameType() & SFXFRAME_PLUGIN ) ) + if ( 0 == pImp->nDocViewNo ) { GetDocNumber_Impl(); UpdateTitle(); @@ -2121,12 +1839,12 @@ void SfxViewFrame::Show() // Frame-Window anzeigen, aber nur wenn der ViewFrame kein eigenes Window // hat oder wenn er keine Component enth"alt - if ( &GetWindow() == &GetFrame()->GetWindow() || !GetFrame()->HasComponent() ) + if ( &GetWindow() == &GetFrame().GetWindow() || !GetFrame().HasComponent() ) GetWindow().Show(); - GetFrame()->GetWindow().Show(); + GetFrame().GetWindow().Show(); /* SfxViewFrame* pCurrent = SfxViewFrame::Current(); - if ( GetFrame()->GetFrameInterface()->isActive() && + if ( GetFrame().GetFrameInterface()->isActive() && pCurrent != this && ( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) && !GetActiveChildFrame_Impl() ) @@ -2141,8 +1859,6 @@ void SfxViewFrame::Show() //-------------------------------------------------------------------- sal_Bool SfxViewFrame::IsVisible() const { - //Window *pWin = pImp->bInCtor ? 0 : &GetWindow(); - //return GetFrame()->HasComponent() || pImp->bObjLocked || ( pWin && pWin->IsVisible() ); return pImp->bObjLocked; } @@ -2167,7 +1883,7 @@ void SfxViewFrame::LockObjectShell_Impl( sal_Bool bLock ) //-------------------------------------------------------------------- void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus ) { - if ( GetViewShell() && !GetFrame()->IsClosing_Impl() ) + if ( GetViewShell() && !GetFrame().IsClosing_Impl() ) { if ( IsVisible() ) { @@ -2186,7 +1902,7 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus ) } SfxViewFrame* pCurrent = SfxViewFrame::Current(); - css::uno::Reference< css::frame::XFrame > xFrame = GetFrame()->GetFrameInterface(); + css::uno::Reference< css::frame::XFrame > xFrame = GetFrame().GetFrameInterface(); if ( !bPreview ) { SetViewFrame( this ); @@ -2202,7 +1918,7 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus ) SfxInPlaceClient *pCli = GetViewShell()->GetUIActiveClient(); if ( ( !pCli || !pCli->IsObjectUIActive() ) && ( !pCurrent || pCurrent->GetParentViewFrame_Impl() != this ) ) - GetFrame()->GrabFocusOnComponent_Impl(); + GetFrame().GrabFocusOnComponent_Impl(); } } else @@ -2216,89 +1932,6 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus ) } } -//-------------------------------------------------------------------- - -SfxViewShell* SfxViewFrame::CreateView_Impl( sal_uInt16 nViewId ) - -/* [Beschreibung] - - Erzeugt eine SfxViewShell f"ur diesen SfxViewFrame. Wird auch aus - <SfxObjectShell::LoadWindows_Impl()> - gerufen. -*/ - -{ - DBG_ASSERT( GetObjectShell(), "Kein Dokument!" ); - - LockAdjustPosSizePixel(); - - // passende ::com::sun::star::sdbcx::View-Factory suchen - SfxObjectFactory &rDocFact = GetObjectShell()->GetFactory(); - sal_uInt16 nNewNo = nViewId ? USHRT_MAX : 0; - for ( sal_uInt16 nNo = 0; - nNo < rDocFact.GetViewFactoryCount(); - ++nNo ) - { - sal_uInt16 nFoundId = rDocFact.GetViewFactory(nNo).GetOrdinal(); - if ( nNewNo == USHRT_MAX ) - { - if ( nViewId == nFoundId ) - nNewNo = nNo; - } - } - - // per Factory erzeugen - GetBindings().ENTERREGISTRATIONS(); - SfxViewFactory &rViewFactory = rDocFact.GetViewFactory( nNewNo ); - SfxViewShell *pViewShell = rViewFactory.CreateInstance(this, 0); - SetViewShell_Impl(pViewShell); - UnlockAdjustPosSizePixel(); - - if ( GetWindow().IsReallyVisible() ) - DoAdjustPosSizePixel(pViewShell, Point(), GetWindow().GetOutputSizePixel()); - - // erste jetzt anzeigen (ausser wenn MTs BASIC-IDE mal wieder keins hat) - Window *pViewWin = pViewShell->GetWindow(); - if ( pViewWin && pViewShell->IsShowView_Impl() ) - pViewWin->Show(); - - // Dispatcher - GetDispatcher()->Push( *pViewShell ); - if ( pViewShell->GetSubShell() ) - GetDispatcher()->Push( *pViewShell->GetSubShell() ); - pViewShell->PushSubShells_Impl(); - -#if defined SFX_HINT_VIEWCREATED - GetObjectShell()->Broadcast( SfxSimpleHint( SFX_HINT_VIEWCREATED ) ); -#endif - - GetBindings().LEAVEREGISTRATIONS(); - - DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" ); - return pViewShell; -} - -//------------------------------------------------------------------------- -SfxViewFrame* SfxViewFrame::SearchViewFrame( SfxViewFrame *pViewFrame, - const String& rName ) -{ - if ( !pViewFrame ) - pViewFrame = SfxViewFrame::Current(); - if ( !pViewFrame ) - return NULL; - SfxFrame *pFrame = pViewFrame->GetFrame()->SearchFrame( rName ); - if ( !pFrame ) - return NULL; - - // Der Frame ist selbst ein ViewFrame oder enth"alt einen -/* - pViewFrame = PTR_CAST( SfxViewFrame, pFrame ); - if ( !pViewFrame && pFrame->GetChildFrameCount() ) - pViewFrame = PTR_CAST( SfxViewFrame, pFrame->GetChildFrame(0) ); -*/ - return pFrame->GetCurrentViewFrame(); -} - //------------------------------------------------------------------------- void SfxViewFrame::SetQuietMode_Impl( sal_Bool bOn ) @@ -2313,11 +1946,6 @@ SfxObjectShell* SfxViewFrame::GetObjectShell() return xObjSh; } -void SfxViewFrame::SetMargin_Impl( const Size& rMargin ) -{ - pImp->aMargin = rMargin; -} - const Size& SfxViewFrame::GetMargin_Impl() const { return pImp->aMargin; @@ -2332,10 +1960,10 @@ void SfxViewFrame::SetActiveChildFrame_Impl( SfxViewFrame *pViewFrame ) pImp->pActiveChild = pViewFrame; - Reference< XFramesSupplier > xFrame( GetFrame()->GetFrameInterface(), UNO_QUERY ); + Reference< XFramesSupplier > xFrame( GetFrame().GetFrameInterface(), UNO_QUERY ); Reference< XFrame > xActive; if ( pViewFrame ) - xActive = pViewFrame->GetFrame()->GetFrameInterface(); + xActive = pViewFrame->GetFrame().GetFrameInterface(); if ( xFrame.is() ) // PB: #74432# xFrame cann be NULL xFrame->setActiveFrame( xActive ); @@ -2364,20 +1992,181 @@ SfxViewFrame* SfxViewFrame::GetActiveChildFrame_Impl() const } //-------------------------------------------------------------------- +SfxViewFrame* SfxViewFrame::LoadViewIntoFrame_Impl_NoThrow( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame, + const USHORT i_nViewId, const bool i_bHidden ) +{ + Reference< XFrame > xFrame( i_rFrame ); + bool bOwnFrame = false; + SfxViewShell* pSuccessView = NULL; + try + { + if ( !xFrame.is() ) + { + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference < XFrame > xDesktop( aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW ); + xFrame.set( xDesktop->findFrame( DEFINE_CONST_UNICODE("_blank"), 0 ), UNO_SET_THROW ); + bOwnFrame = true; + } + + pSuccessView = LoadViewIntoFrame_Impl( + i_rDoc, + xFrame, + Sequence< PropertyValue >(), // means "reuse existing model's args" + i_nViewId, + i_bHidden + ); + + if ( bOwnFrame && !i_bHidden ) + { + // ensure the frame/window is visible + Reference< XWindow > xContainerWindow( xFrame->getContainerWindow(), UNO_SET_THROW ); + xContainerWindow->setVisible( sal_True ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + if ( pSuccessView ) + return pSuccessView->GetViewFrame(); + + if ( bOwnFrame ) + { + try + { + xFrame->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + return NULL; +} + +//-------------------------------------------------------------------- +SfxViewShell* SfxViewFrame::LoadViewIntoFrame_Impl( const SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rFrame, + const Sequence< PropertyValue >& i_rLoadArgs, const USHORT i_nViewId, + const bool i_bHidden ) +{ + Reference< XModel > xDocument( i_rDoc.GetModel(), UNO_SET_THROW ); + + ::comphelper::NamedValueCollection aTransformLoadArgs( i_rLoadArgs.getLength() ? i_rLoadArgs : xDocument->getArgs() ); + aTransformLoadArgs.put( "Model", xDocument ); + if ( i_nViewId ) + aTransformLoadArgs.put( "ViewId", sal_Int16( i_nViewId ) ); + if ( i_bHidden ) + aTransformLoadArgs.put( "Hidden", i_bHidden ); + else + aTransformLoadArgs.remove( "Hidden" ); + + ::rtl::OUString sURL( xDocument->getURL() ); + if ( !sURL.getLength() ) + sURL = i_rDoc.GetFactory().GetFactoryURL(); + + Reference< XComponentLoader > xLoader( i_rFrame, UNO_QUERY_THROW ); + xLoader->loadComponentFromURL( sURL, ::rtl::OUString::createFromAscii( "_self" ), 0, + aTransformLoadArgs.getPropertyValues() ); + + SfxViewShell* pViewShell = SfxViewShell::Get( i_rFrame->getController() ); + ENSURE_OR_THROW( pViewShell, + "SfxViewFrame::LoadViewIntoFrame_Impl: loading an SFX doc into a frame resulted in a non-SFX view - quite impossible" ); + return pViewShell; +} + +//-------------------------------------------------------------------- + +SfxViewFrame* SfxViewFrame::LoadHiddenDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ) +{ + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, true ); +} + +//-------------------------------------------------------------------- + +SfxViewFrame* SfxViewFrame::LoadDocument( SfxObjectShell& i_rDoc, const USHORT i_nViewId ) +{ + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, Reference< XFrame >(), i_nViewId, false ); +} + +//-------------------------------------------------------------------- + +SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const Reference< XFrame >& i_rTargetFrame, const USHORT i_nViewId ) +{ + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_rTargetFrame, i_nViewId, false ); +} + +//-------------------------------------------------------------------- + +SfxViewFrame* SfxViewFrame::LoadDocumentIntoFrame( SfxObjectShell& i_rDoc, const SfxFrameItem* i_pFrameItem, const USHORT i_nViewId ) +{ + return LoadViewIntoFrame_Impl_NoThrow( i_rDoc, i_pFrameItem && i_pFrameItem->GetFrame() ? i_pFrameItem->GetFrame()->GetFrameInterface() : NULL, i_nViewId, false ); +} + +//-------------------------------------------------------------------- +SfxViewFrame* SfxViewFrame::DisplayNewDocument( SfxObjectShell& i_rDoc, const SfxRequest& i_rCreateDocRequest, const USHORT i_nViewId ) +{ + SFX_REQUEST_ARG( i_rCreateDocRequest, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, FALSE ); + SFX_REQUEST_ARG( i_rCreateDocRequest, pHiddenItem, SfxBoolItem, SID_HIDDEN, FALSE ); + + return LoadViewIntoFrame_Impl_NoThrow( + i_rDoc, + pFrameItem ? pFrameItem->GetFrame() : NULL, + i_nViewId, + pHiddenItem ? pHiddenItem->GetValue() : false + ); +} + +//-------------------------------------------------------------------- + +SfxViewFrame* SfxViewFrame::Get( const Reference< XController>& i_rController, const SfxObjectShell* i_pDoc ) +{ + if ( !i_rController.is() ) + return NULL; + + const SfxObjectShell* pDoc = i_pDoc; + if ( !pDoc ) + { + Reference< XModel > xDocument( i_rController->getModel() ); + for ( pDoc = SfxObjectShell::GetFirst( 0, false ); + pDoc; + pDoc = SfxObjectShell::GetNext( *pDoc, 0, false ) + ) + { + if ( pDoc->GetModel() == xDocument ) + break; + } + } + + SfxViewFrame* pViewFrame = NULL; + for ( pViewFrame = SfxViewFrame::GetFirst( pDoc, FALSE ); + pViewFrame; + pViewFrame = SfxViewFrame::GetNext( *pViewFrame, pDoc, FALSE ) + ) + { + if ( pViewFrame->GetViewShell()->GetController() == i_rController ) + break; + } + + return pViewFrame; +} + +//-------------------------------------------------------------------- sal_Bool SfxViewFrame::SwitchToViewShell_Impl ( - sal_uInt16 nViewId, /* > 0 - Registrierungs-Id der ::com::sun::star::sdbcx::View, auf die umge- + sal_uInt16 nViewIdOrNo, /* > 0 + Registrierungs-Id der View, auf die umge- schaltet werden soll, bzw. die erstmalig erzeugt werden soll. == 0 - Es soll die Default-::com::sun::star::sdbcx::View verwendet werden. */ + Es soll die Default-View verwendet werden. */ sal_Bool bIsIndex /* sal_True - 'nViewId' ist keine Registrations-Id sondern - ein ::com::sun::star::sdbcx::Index in die f"ur die in diesem + 'nViewIdOrNo' ist keine Registrations-Id sondern + ein Index in die f"ur die in diesem <SfxViewFrame> dargestellte <SfxObjectShell>. */ ) @@ -2403,174 +2192,64 @@ sal_Bool SfxViewFrame::SwitchToViewShell_Impl */ { - try{ - DBG_ASSERT( GetObjectShell(), "Kein Dokument!" ); - - SfxObjectFactory &rDocFact = GetObjectShell()->GetFactory(); - - // find index of old and new ViewShell - sal_uInt16 nOldNo = USHRT_MAX, nNewNo = USHRT_MAX; - bIsIndex |= 0 == nViewId; - for ( sal_uInt16 nNo = 0; nNo < rDocFact.GetViewFactoryCount(); ++nNo ) - { - sal_uInt16 nFoundId = rDocFact.GetViewFactory(nNo).GetOrdinal(); - if ( nNewNo == USHRT_MAX ) - { - if ( bIsIndex && nViewId == nNo ) - { - nNewNo = nNo; - nViewId = nFoundId; // for nViewId == 0 - } - else if ( !bIsIndex && nViewId == nFoundId ) - nNewNo = nNo; - } - if ( pImp->nCurViewId == nFoundId ) - nOldNo = nNo; - } - - if ( nNewNo == USHRT_MAX ) - { - // unknown ID -> fall back to default - sal_uInt16 nFoundId = rDocFact.GetViewFactory(0).GetOrdinal(); - nNewNo = 0; - nViewId = nFoundId; - if ( pImp->nCurViewId == nFoundId ) - nOldNo = 0; - } - - SfxViewShell *pSh = GetViewShell(); - - DBG_ASSERT( !pSh || nOldNo != USHRT_MAX, "old shell id not found" ); - - // does a ViewShell exist already? - SfxViewShell *pOldSh = pSh; - if ( pOldSh ) + try { - // ask wether it can be closed - if ( !pOldSh->PrepareClose() ) - return sal_False; + ENSURE_OR_THROW( GetObjectShell() != NULL, "not possible without a document" ); - // remove SubShells from Dispatcher before switching to new ViewShell - pOldSh->PushSubShells_Impl( sal_False ); - sal_uInt16 nLevel = pDispatcher->GetShellLevel( *pOldSh ); - if ( nLevel ) + // if we already have a view shell, remove it + SfxViewShell* pOldSh = GetViewShell(); + OSL_PRECOND( pOldSh, "SfxViewFrame::SwitchToViewShell_Impl: that's called *switch* (not for *initial-load*) for a reason" ); + if ( pOldSh ) { - SfxShell *pSubShell = pDispatcher->GetShell( nLevel-1 ); - if ( pSubShell == pOldSh->GetSubShell() ) - //"real" SubShells are not deleted - pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL ); - else - // SubShells only known to Dispatcher must be deleted - pDispatcher->Pop( *pSubShell, SFX_SHELL_POP_UNTIL | SFX_SHELL_POP_DELETE ); - } - - pDispatcher->Pop( *pOldSh ); - GetBindings().Invalidate( nOldNo + SID_VIEWSHELL0 ); - } - - // remember ViewID - pImp->nCurViewId = nViewId; - GetBindings().Invalidate( nNewNo + SID_VIEWSHELL0 ); - - // create new ViewShell - SfxViewFactory &rViewFactory = rDocFact.GetViewFactory( nNewNo ); - LockAdjustPosSizePixel(); - - GetBindings().ENTERREGISTRATIONS(); - pSh = rViewFactory.CreateInstance(this, pOldSh); - - Window *pEditWin = pSh->GetWindow(); - DBG_ASSERT( !pEditWin || !pEditWin->IsReallyVisible(), "don`t show your ViewShell`s Window by yourself!" ); + // ask wether it can be closed + if ( !pOldSh->PrepareClose( TRUE ) ) + return sal_False; - // by setting the ViewShell it is prevented that disposing the Controller will destroy this ViewFrame also - GetDispatcher()->SetDisableFlags( 0 ); - SetViewShell_Impl(pSh); - - Reference < ::com::sun::star::awt::XWindow > xWindow( - GetFrame()->GetWindow().GetComponentInterface(), UNO_QUERY ); - Reference < XFrame > xFrame( GetFrame()->GetFrameInterface() ); - if ( !pSh->GetController().is() ) - pSh->SetController( new SfxBaseController( pSh ) ); - Reference < XController > xController( pSh->GetController() ); - xFrame->setComponent( xWindow, xController ); - - xController->attachFrame( xFrame ); - Reference < XModel > xModel( GetObjectShell()->GetModel() ); - if ( xModel.is() ) - { - xController->attachModel( xModel ); - xModel->connectController( xController ); - xModel->setCurrentController( xController ); - } - - GetDispatcher()->Push( *pSh ); - if ( pSh->GetSubShell() ) - GetDispatcher()->Push( *pSh->GetSubShell() ); - pSh->PushSubShells_Impl(); - GetDispatcher()->Flush(); - - if ( pImp->bRestoreView && pImp->aViewData.Len() ) - { - // restore view data if required - pSh->ReadUserData( pImp->aViewData, sal_True ); - pImp->bRestoreView = sal_False; - } + // remove sub shells from Dispatcher before switching to new ViewShell + PopShellAndSubShells_Impl( *pOldSh ); + } - // create UI elements before size is set - if ( SfxViewFrame::Current() == this ) - GetDispatcher()->Update_Impl( sal_True ); + GetBindings().ENTERREGISTRATIONS(); + LockAdjustPosSizePixel(); - // allow resize events to be processed - UnlockAdjustPosSizePixel(); + // ID of the new view + SfxObjectFactory& rDocFact = GetObjectShell()->GetFactory(); + const USHORT nViewId = ( bIsIndex || !nViewIdOrNo ) ? rDocFact.GetViewFactory( nViewIdOrNo ).GetOrdinal() : nViewIdOrNo; - Window* pFrameWin = &GetWindow(); - if ( pFrameWin != &GetFrame()->GetWindow() ) - pFrameWin->Show(); + // create and load new ViewShell + SfxViewShell* pNewSh = LoadViewIntoFrame_Impl( + *GetObjectShell(), + GetFrame().GetFrameInterface(), + Sequence< PropertyValue >(), // means "reuse existing model's args" + nViewId, + false + ); - if ( GetWindow().IsReallyVisible() ) - DoAdjustPosSizePixel( pSh, Point(), GetWindow().GetOutputSizePixel() ); + // allow resize events to be processed + UnlockAdjustPosSizePixel(); - if ( pEditWin && pSh->IsShowView_Impl() ) - pEditWin->Show(); + if ( GetWindow().IsReallyVisible() ) + DoAdjustPosSizePixel( pNewSh, Point(), GetWindow().GetOutputSizePixel() ); - GetBindings().LEAVEREGISTRATIONS(); - delete pOldSh; + GetBindings().LEAVEREGISTRATIONS(); + delete pOldSh; } - catch ( com::sun::star::uno::Exception& ) + catch ( const com::sun::star::uno::Exception& ) { // the SfxCode is not able to cope with exceptions thrown while creating views // the code will crash in the stack unwinding procedure, so we shouldn't let exceptions go through here - DBG_ERROR("Exception in SwitchToViewShell_Impl - urgent issue. Please contact development!"); + DBG_UNHANDLED_EXCEPTION(); + return sal_False; } DBG_ASSERT( SFX_APP()->GetViewFrames_Impl().Count() == SFX_APP()->GetViewShells_Impl().Count(), "Inconsistent view arrays!" ); return sal_True; } -//-------------------------------------------------------------------- - -void SfxViewFrame::SetViewData_Impl( sal_uInt16 nViewId, const String &rViewData ) -{ - pImp->bRestoreView = sal_True; - pImp->nCurViewId = nViewId; - pImp->aViewData = rViewData; -} //------------------------------------------------------------------------- -String& SfxViewFrame::GetViewData_Impl() +void SfxViewFrame::SetCurViewId_Impl( const USHORT i_nID ) { - return pImp->aViewData; -} - -//------------------------------------------------------------------------- -sal_Bool SfxViewFrame::IsRestoreView_Impl() const -{ - return pImp->bRestoreView; -} - -//------------------------------------------------------------------------- -void SfxViewFrame::SetRestoreView_Impl( sal_Bool bOn ) -{ - pImp->bRestoreView = bOn; + pImp->nCurViewId = i_nID; } //------------------------------------------------------------------------- @@ -2608,58 +2287,17 @@ void SfxViewFrame::ExecView_Impl break; } - case SID_FILLFRAME: - { - // Bei Mail etc. k"onnen die Frames nicht angesprochen werden - SfxFrame *pParent = GetFrame()->GetParentFrame(); - if ( pParent && pParent->GetCurrentViewFrame()-> - GetViewShell()->IsImplementedAsFrameset_Impl() ) - break; - - SfxViewFrame *pRet = NULL; - SFX_REQUEST_ARG( - rReq, pItem, SfxStringItem, SID_FILLFRAME, sal_False ); - if ( pItem ) - { - String aName( pItem->GetValue() ); - sal_uInt16 nFrame = (sal_uInt16) aName.ToInt32(); - if ( nFrame == 0 ) - nFrame = USHRT_MAX; - - SfxFrameIterator aIter( *GetFrame(), sal_False ); - SfxFrame *pFrame = aIter.FirstFrame(); - sal_uInt16 nActFrame = 1; - while ( pFrame ) - { - SfxViewFrame *pView = pFrame->GetCurrentViewFrame(); - if ( - nActFrame == nFrame || - ( - pView && - aName.CompareIgnoreCaseToAscii( pView->SfxShell::GetName() ) == COMPARE_EQUAL - ) - ) - { - pRet = pView; - break; - } - - pFrame = aIter.NextFrame( *pFrame ); - nActFrame++; - } - } - - rReq.SetReturnValue( SfxObjectItem( SID_DOCFRAME, pRet ) ); - break; - } - case SID_VIEWSHELL: { const SfxPoolItem *pItem = 0; - if ( rReq.GetArgs() && - SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem ) ) - rReq.SetReturnValue( SfxBoolItem(0, SwitchToViewShell_Impl( - (sal_uInt16)((const SfxUInt16Item*) pItem)->GetValue()) )); + if ( rReq.GetArgs() + && SFX_ITEM_SET == rReq.GetArgs()->GetItemState( SID_VIEWSHELL, sal_False, &pItem ) + ) + { + const sal_uInt16 nViewId = static_cast< const SfxUInt16Item* >( pItem )->GetValue(); + BOOL bSuccess = SwitchToViewShell_Impl( nViewId ); + rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) ); + } break; } @@ -2669,86 +2307,40 @@ void SfxViewFrame::ExecView_Impl case SID_VIEWSHELL3: case SID_VIEWSHELL4: { - rReq.SetReturnValue( SfxBoolItem(0, - SwitchToViewShell_Impl( rReq.GetSlot() - SID_VIEWSHELL0, sal_True ) ) ); + const sal_uInt16 nViewNo = rReq.GetSlot() - SID_VIEWSHELL0; + BOOL bSuccess = SwitchToViewShell_Impl( nViewNo, sal_True ); + rReq.SetReturnValue( SfxBoolItem( 0, bSuccess ) ); break; } case SID_NEWWINDOW: { // Hack. demnaechst virtuelle Funktion - if ( !GetViewShell()->NewWindowAllowed() && !GetObjectShell()->HasName() ) - return; - - // ViewData bei FrameSets rekursiv holen - GetFrame()->GetViewData_Impl(); - SfxMedium *pMed = GetObjectShell()->GetMedium(); - String aUserData; - GetViewShell()->WriteUserData( aUserData, sal_True ); if ( !GetViewShell()->NewWindowAllowed() ) { - SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, sal_False ); - SfxFrame *pFrame = NULL; - Reference < XFrame > xFrame; - if ( pFrameItem ) - { - pFrameItem->GetValue() >>= xFrame; - pFrame = SfxTopFrame::Create( xFrame ); - } - else - pFrame = SfxTopFrame::Create(); - - SfxAllItemSet aSet( SFX_APP()->GetPool() ); - SFX_REQUEST_ARG( rReq, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False ); - if ( pHiddenItem ) - aSet.Put( *pHiddenItem ); - - SFX_ITEMSET_ARG( pMed->GetItemSet(), pRefererItem, SfxStringItem, SID_REFERER, sal_False ); - SfxStringItem aReferer( SID_REFERER, DEFINE_CONST_UNICODE( "private:user" ) ); - if ( !pRefererItem ) - pRefererItem = &aReferer; - - aSet.Put( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) ); - aSet.Put( SfxStringItem( SID_USER_DATA, aUserData ) ); - aSet.Put( SfxUInt16Item( SID_VIEW_ID, GetCurViewId() ) ); - aSet.Put( *pRefererItem ); - if( pMed->GetFilter() ) - aSet.Put( SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName()) ); - aSet.Put( SfxFrameItem ( SID_DOCFRAME, pFrame ) ); - if ( xFrame.is() ) - GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, aSet ); - else - GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, aSet ); - } - else - { - pMed->GetItemSet()->Put( SfxStringItem( SID_USER_DATA, aUserData ) ); - - BOOL bHidden = FALSE; - SFX_REQUEST_ARG( rReq, pHiddenItem, SfxBoolItem, SID_HIDDEN, sal_False ); - if ( pHiddenItem ) - bHidden = pHiddenItem->GetValue(); - SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoAnyItem, SID_FILLFRAME, sal_False ); - if ( pFrameItem ) - { - Reference < XFrame > xFrame; - pFrameItem->GetValue() >>= xFrame; - SfxFrame* pFrame = SfxTopFrame::Create( xFrame ); - pMed->GetItemSet()->ClearItem( SID_HIDDEN ); - pFrame->InsertDocument( GetObjectShell() ); - if ( !bHidden ) - xFrame->getContainerWindow()->setVisible( sal_True ); - } - else - { - SfxAllItemSet aSet( GetPool() ); - aSet.Put( SfxBoolItem( SID_OPEN_NEW_VIEW, TRUE ) ); - SfxFrame* pFrame = SfxTopFrame::Create( GetObjectShell(), GetCurViewId(), bHidden, &aSet ); - if ( bHidden ) - pFrame->GetCurrentViewFrame()->LockObjectShell_Impl( TRUE ); - } + OSL_ENSURE( false, "You should have disabled the 'Window/New Window' slot!" ); + return; } + // ViewData bei FrameSets rekursiv holen + GetFrame().GetViewData_Impl(); + SfxMedium* pMed = GetObjectShell()->GetMedium(); + + // do not open the new window hidden + pMed->GetItemSet()->ClearItem( SID_HIDDEN ); + + // the view ID (optional arg. TODO: this is currently not supported in the slot definition ...) + SFX_REQUEST_ARG( rReq, pViewIdItem, SfxUInt16Item, SID_VIEW_ID, sal_False ); + const USHORT nViewId = pViewIdItem ? pViewIdItem->GetValue() : GetCurViewId(); + + Reference < XFrame > xFrame; + // the frame (optional arg. TODO: this is currently not supported in the slot definition ...) + SFX_REQUEST_ARG( rReq, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False ); + if ( pFrameItem ) + xFrame = pFrameItem->GetFrame(); + + LoadViewIntoFrame_Impl_NoThrow( *GetObjectShell(), xFrame, nViewId, false ); + rReq.Done(); break; } @@ -2912,13 +2504,10 @@ void SfxViewFrame::StateView_Impl case SID_NEWWINDOW: { - if ( !GetViewShell()->NewWindowAllowed() /* && !pDocSh->HasName() */ ) - rSet.DisableItem( nWhich ); - else - { - if (impl_maxOpenDocCountReached()) - rSet.DisableItem( nWhich ); - } + if ( !GetViewShell()->NewWindowAllowed() + || impl_maxOpenDocCountReached() + ) + rSet.DisableItem( nWhich ); break; } } @@ -2927,22 +2516,9 @@ void SfxViewFrame::StateView_Impl } //------------------------------------------------------------------------- -void SfxViewFrame::GetState_Impl( SfxItemSet &rSet ) -{ - if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() ) - { - uno::Any aAny; - aAny <<= GetViewShell()->GetVerbs(); - rSet.Put( SfxUnoAnyItem( USHORT( SID_OBJECT ), aAny ) ); - } - else - rSet.DisableItem( SID_OBJECT ); -} - -//------------------------------------------------------------------------- void SfxViewFrame::ToTop() { - GetFrame()->Appear(); + GetFrame().Appear(); } //------------------------------------------------------------------------- @@ -2952,66 +2528,41 @@ SfxViewFrame* SfxViewFrame::GetParentViewFrame() const Der ParentViewFrame ist der ViewFrame des ParentFrames */ { - SfxFrame *pFrame = GetFrame()->GetParentFrame(); + SfxFrame *pFrame = GetFrame().GetParentFrame(); return pFrame ? pFrame->GetCurrentViewFrame() : NULL; } //------------------------------------------------------------------------- -SfxFrame* SfxViewFrame::GetFrame() const +SfxFrame& SfxViewFrame::GetFrame() const /* Beschreibung: GetFrame liefert den Frame, in dem sich der ViewFrame befindet */ { - return pImp->pFrame; -} - -//------------------------------------------------------------------------- -void SfxViewFrame::SetFrame_Impl( SfxFrame *pFrame ) -{ - pImp->pFrame = pFrame; + return pImp->rFrame; } //------------------------------------------------------------------------- SfxViewFrame* SfxViewFrame::GetTopViewFrame() const { - return GetFrame()->GetTopFrame()->GetCurrentViewFrame(); -} - -//------------------------------------------------------------------------- - -SfxCancelManager *SfxViewFrame::GetCancelManager() const - -/* <H3>Description</H3> - - Returns a pointer to the <SfxCancelManager> of the top-view-frame of - this view-frame. -*/ - -{ - return GetTopViewFrame()->GetFrame()->GetCancelManager(); -} - -void SfxViewFrame::SetWindow_Impl( Window *pWin ) -{ - pImp->pWindow = pWin; + return GetFrame().GetTopFrame().GetCurrentViewFrame(); } Window& SfxViewFrame::GetWindow() const { - return pImp->pWindow ? *pImp->pWindow : GetFrame()->GetWindow(); + return pImp->pWindow ? *pImp->pWindow : GetFrame().GetWindow(); } sal_Bool SfxViewFrame::DoClose() { - return GetFrame()->DoClose(); + return GetFrame().DoClose(); } String SfxViewFrame::GetActualPresentationURL_Impl() const { if ( xObjSh.Is() ) return xObjSh->GetMedium()->GetName(); - return pImp->aActualPresentationURL; + return String(); } void SfxViewFrame::SetModalMode( sal_Bool bModal ) @@ -3028,7 +2579,7 @@ void SfxViewFrame::SetModalMode( sal_Bool bModal ) BOOL SfxViewFrame::IsInModalMode() const { - return pImp->bModal || GetFrame()->GetWindow().IsInModalMode(); + return pImp->bModal || GetFrame().GetWindow().IsInModalMode(); } void SfxViewFrame::Resize( BOOL bForce ) @@ -3040,18 +2591,14 @@ void SfxViewFrame::Resize( BOOL bForce ) SfxViewShell *pShell = GetViewShell(); if ( pShell ) { - if ( GetFrame()->IsInPlace() ) + if ( GetFrame().IsInPlace() ) { Point aPoint = GetWindow().GetPosPixel(); DoAdjustPosSizePixel( pShell, aPoint, aSize ); } else { - if ( pShell->UseObjectSize() ) - ForceOuterResize_Impl(TRUE); DoAdjustPosSizePixel( pShell, Point(), aSize ); - if ( pShell->UseObjectSize() ) - ForceOuterResize_Impl(FALSE); } } } @@ -3324,7 +2871,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) // try to find any active recorder on this frame ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier"); com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet(xFrame,com::sun::star::uno::UNO_QUERY); @@ -3389,7 +2936,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) case SID_TOGGLESTATUSBAR: { com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); @@ -3436,14 +2983,14 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) case SID_WIN_FULLSCREEN: { SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), FALSE); - SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, GetTopViewFrame() ); + SfxViewFrame *pTop = GetTopViewFrame(); if ( pTop ) { - WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl(); + WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl(); if ( pWork ) { com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); Reference< ::com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); @@ -3478,7 +3025,7 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq ) } pWork->ShowFullScreenMode( bNewFullScreenMode ); pWork->SetMenuBarMode( bNewFullScreenMode ? MENUBAR_MODE_HIDE : MENUBAR_MODE_NORMAL ); - GetFrame()->GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode ); + GetFrame().GetWorkWindow_Impl()->SetFullScreen_Impl( bNewFullScreenMode ); if ( !pItem ) rReq.AppendItem( SfxBoolItem( SID_WIN_FULLSCREEN, bNewFullScreenMode ) ); rReq.Done(); @@ -3532,7 +3079,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier"); com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty); @@ -3555,7 +3102,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) ::rtl::OUString sProperty = rtl::OUString::createFromAscii("DispatchRecorderSupplier"); com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); com::sun::star::uno::Any aProp = xSet->getPropertyValue(sProperty); @@ -3569,7 +3116,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) { com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xSet( - GetFrame()->GetFrameInterface(), + GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); com::sun::star::uno::Any aProp = xSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )) ); @@ -3587,10 +3134,10 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet) case SID_WIN_FULLSCREEN: { - SfxTopViewFrame *pTop= PTR_CAST( SfxTopViewFrame, GetTopViewFrame() ); + SfxViewFrame* pTop = GetTopViewFrame(); if ( pTop ) { - WorkWindow* pWork = (WorkWindow*) pTop->GetTopFrame_Impl()->GetTopWindow_Impl(); + WorkWindow* pWork = (WorkWindow*) pTop->GetFrame().GetTopWindow_Impl(); if ( pWork ) { rSet.Put( SfxBoolItem( nWhich, pWork->IsFullScreenMode() ) ); @@ -3639,7 +3186,7 @@ void SfxViewFrame::ChildWindowExecute( SfxRequest &rReq ) { if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE)) return; - Reference < XFrame > xFrame = GetFrame()->GetTopFrame()->GetFrameInterface(); + Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface(); Reference < XFrame > xBeamer( xFrame->findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN ) ); BOOL bShow = FALSE; BOOL bHasChild = xBeamer.is(); @@ -3740,7 +3287,7 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState ) } else if ( nSID == SID_BROWSER ) { - Reference < XFrame > xFrame = GetFrame()->GetTopFrame()->GetFrameInterface()-> + Reference < XFrame > xFrame = GetFrame().GetTopFrame().GetFrameInterface()-> findFrame( DEFINE_CONST_UNICODE("_beamer"), FrameSearchFlag::CHILDREN ); if ( !xFrame.is() ) rState.DisableItem( nSID ); @@ -3758,7 +3305,7 @@ void SfxViewFrame::ChildWindowState( SfxItemSet& rState ) SfxWorkWindow* SfxViewFrame::GetWorkWindow_Impl( USHORT /*nId*/ ) { SfxWorkWindow* pWork = 0; - pWork = GetFrame()->GetWorkWindow_Impl(); + pWork = GetFrame().GetWorkWindow_Impl(); return pWork; } @@ -3820,11 +3367,6 @@ SfxChildWindow* SfxViewFrame::GetChildWindow(USHORT nId) return pWork ? pWork->GetChildWindow_Impl(nId) : NULL; } -SfxMacro* SfxViewFrame::GetRecordingMacro_Impl() -{ - return pImp->pMacro; -} - void SfxViewFrame::UpdateDocument_Impl() { SfxObjectShell* pDoc = GetObjectShell(); @@ -3835,29 +3377,6 @@ void SfxViewFrame::UpdateDocument_Impl() pDoc->UpdateFromTemplate_Impl(); } -BOOL SfxViewFrame::ClearEventFlag_Impl() -{ - if ( pImp->bEventFlag ) - { - pImp->bEventFlag = FALSE; - return TRUE; - } - else - return FALSE; -} - -SfxViewFrame* SfxViewFrame::CreateViewFrame( SfxObjectShell& rDoc, sal_uInt16 nViewId, sal_Bool bHidden ) -{ - SfxItemSet *pSet = rDoc.GetMedium()->GetItemSet(); - if ( nViewId ) - pSet->Put( SfxUInt16Item( SID_VIEW_ID, nViewId ) ); - if ( bHidden ) - pSet->Put( SfxBoolItem( SID_HIDDEN, sal_True ) ); - - SfxFrame *pFrame = SfxTopFrame::Create( &rDoc, 0, bHidden ); - return pFrame->GetCurrentViewFrame(); -} - void SfxViewFrame::SetViewFrame( SfxViewFrame* pFrame ) { SFX_APP()->SetViewFrame_Impl( pFrame ); diff --git a/sfx2/source/view/viewfrm2.cxx b/sfx2/source/view/viewfrm2.cxx new file mode 100644 index 000000000000..480b5307df2e --- /dev/null +++ b/sfx2/source/view/viewfrm2.cxx @@ -0,0 +1,523 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sfx2.hxx" + +#include "impviewframe.hxx" +#include "statcach.hxx" +#include "viewfac.hxx" +#include "workwin.hxx" + +#include "sfx2/app.hxx" +#include "sfx2/bindings.hxx" +#include "sfx2/ctrlitem.hxx" +#include "sfx2/dispatch.hxx" +#include "sfx2/docfac.hxx" +#include "sfx2/docfile.hxx" +#include "sfx2/objitem.hxx" +#include "sfx2/objsh.hxx" +#include "sfx2/request.hxx" +#include "sfx2/viewfrm.hxx" +#include "sfx2/viewsh.hxx" + +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/XMaterialHolder.hpp> +#include <com/sun/star/util/XCloseable.hpp> + +#include <comphelper/componentcontext.hxx> +#include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> +#include <svtools/asynclink.hxx> +#include <svl/eitem.hxx> +#include <svl/intitem.hxx> +#include <svl/rectitem.hxx> +#include <svl/stritem.hxx> +#include <tools/diagnose_ex.h> +#include <tools/urlobj.hxx> +#include <unotools/bootstrap.hxx> +#include <unotools/configmgr.hxx> +#include <vcl/window.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::beans; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::lang::XComponent; + +//------------------------------------------------------------------------ + +static ::rtl::OUString GetModuleName_Impl( const ::rtl::OUString& sDocService ) +{ + uno::Reference< container::XNameAccess > xMM( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager")), uno::UNO_QUERY ); + ::rtl::OUString sVar; + if ( !xMM.is() ) + return sVar; + + try + { + ::comphelper::NamedValueCollection aAnalyzer( xMM->getByName( sDocService ) ); + sVar = aAnalyzer.getOrDefault( "ooSetupFactoryUIName", ::rtl::OUString() ); + } + catch( uno::Exception& ) + { + sVar = ::rtl::OUString(); + } + + return sVar; +} + +//-------------------------------------------------------------------- +void SfxFrameViewWindow_Impl::StateChanged( StateChangedType nStateChange ) +{ + if ( nStateChange == STATE_CHANGE_INITSHOW ) + { + SfxObjectShell* pDoc = pFrame->GetObjectShell(); + if ( pDoc && !pFrame->IsVisible() ) + pFrame->Show(); + + pFrame->Resize(); + } + else + Window::StateChanged( nStateChange ); +} + +void SfxFrameViewWindow_Impl::Resize() +{ + if ( IsReallyVisible() || IsReallyShown() || GetOutputSizePixel().Width() ) + pFrame->Resize(); +} + +static String _getTabString() +{ + String result; + + Reference < XMaterialHolder > xHolder( + ::comphelper::getProcessServiceFactory()->createInstance( + DEFINE_CONST_UNICODE("com.sun.star.tab.tabreg") ), UNO_QUERY ); + if (xHolder.is()) + { + rtl::OUString aTabString; + Sequence< NamedValue > sMaterial; + if (xHolder->getMaterial() >>= sMaterial) { + for (int i=0; i < sMaterial.getLength(); i++) { + if ((sMaterial[i].Name.equalsAscii("title")) && + (sMaterial[i].Value >>= aTabString)) + { + result += ' '; + result += String(aTabString); + } + } + } + } + return result; +} + +//======================================================================== + +//-------------------------------------------------------------------- +String SfxViewFrame::UpdateTitle() + +/* [Beschreibung] + + Mit dieser Methode kann der SfxViewFrame gezwungen werden, sich sofort + den neuen Titel vom der <SfxObjectShell> zu besorgen. + + [Anmerkung] + + Dies ist z.B. dann notwendig, wenn man der SfxObjectShell als SfxListener + zuh"ort und dort auf den <SfxSimpleHint> SFX_HINT_TITLECHANGED reagieren + m"ochte, um dann die Titel seiner Views abzufragen. Diese Views (SfxTopViewFrames) + jedoch sind ebenfalls SfxListener und da die Reihenfolge der Benachrichtigung + nicht feststeht, mu\s deren Titel-Update vorab erzwungen werden. + + + [Beispiel] + + void SwDocShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) + { + if ( rHint.IsA(TYPE(SfxSimpleHint)) ) + { + switch( ( (SfxSimpleHint&) rHint ).GetId() ) + { + case SFX_HINT_TITLECHANGED: + for ( SfxViewFrame *pTop = SfxViewFrame::GetFirst( this ); + pTop; + pTop = SfxViewFrame::GetNext( this ); + { + pTop->UpdateTitle(); + ... pTop->GetName() ... + } + break; + ... + } + } + } +*/ + +{ + DBG_CHKTHIS(SfxViewFrame, 0); + + const SfxObjectFactory &rFact = GetObjectShell()->GetFactory(); + pImp->aFactoryName = String::CreateFromAscii( rFact.GetShortName() ); + + SfxObjectShell *pObjSh = GetObjectShell(); + if ( !pObjSh ) + return String(); + +// if ( pObjSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) +// // kein UpdateTitle mit Embedded-ObjectShell +// return String(); + + const SfxMedium *pMedium = pObjSh->GetMedium(); + String aURL; + GetFrame(); // -Wall required?? + if ( pObjSh->HasName() ) + { + INetURLObject aTmp( pMedium->GetName() ); + aURL = aTmp.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); + } + + if ( aURL != pImp->aActualURL ) + // URL hat sich ge"andert + pImp->aActualURL = aURL; + + // gibt es noch eine weitere View? + sal_uInt16 nViews=0; + for ( SfxViewFrame *pView= GetFirst(pObjSh); + pView && nViews<2; + pView = GetNext(*pView,pObjSh) ) + if ( ( pView->GetFrameType() & SFXFRAME_HASTITLE ) && + !IsDowning_Impl()) + nViews++; + + // Titel des Fensters + String aTitle; + if ( nViews == 2 || pImp->nDocViewNo > 1 ) + // dann die Nummer dranh"angen + aTitle = pObjSh->UpdateTitle( NULL, pImp->nDocViewNo ); + else + aTitle = pObjSh->UpdateTitle(); + + // Name des SbxObjects + String aSbxName = pObjSh->SfxShell::GetName(); + if ( IsVisible() ) + { + aSbxName += ':'; + aSbxName += String::CreateFromInt32(pImp->nDocViewNo); + } + + SetName( aSbxName ); + pImp->aFrameTitle = aTitle; + GetBindings().Invalidate( SID_FRAMETITLE ); + GetBindings().Invalidate( SID_CURRENT_URL ); + + ::rtl::OUString aProductName; + ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME) >>= aProductName; + + aTitle += String::CreateFromAscii( " - " ); + aTitle += String(aProductName); + aTitle += ' '; + ::rtl::OUString aDocServiceName( GetObjectShell()->GetFactory().GetDocumentServiceName() ); + aTitle += String( GetModuleName_Impl( aDocServiceName ) ); +#ifdef DBG_UTIL + ::rtl::OUString aDefault; + aTitle += DEFINE_CONST_UNICODE(" ["); + String aVerId( utl::Bootstrap::getBuildIdData( aDefault )); + aTitle += aVerId; + aTitle += ']'; +#endif + + // append TAB string if available + aTitle += _getTabString(); + + GetBindings().Invalidate( SID_NEWDOCDIRECT ); + + /* AS_TITLE + Window* pWindow = GetFrame()->GetTopWindow_Impl(); + if ( pWindow && pWindow->GetText() != aTitle ) + pWindow->SetText( aTitle ); + */ + return aTitle; +} + +void SfxViewFrame::Exec_Impl(SfxRequest &rReq ) +{ + // Wenn gerade die Shells ausgetauscht werden... + if ( !GetObjectShell() || !GetViewShell() ) + return; + + switch ( rReq.GetSlot() ) + { + case SID_SHOWPOPUPS : + { + SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, SID_SHOWPOPUPS, FALSE); + BOOL bShow = pShowItem ? pShowItem->GetValue() : TRUE; + SFX_REQUEST_ARG(rReq, pIdItem, SfxUInt16Item, SID_CONFIGITEMID, FALSE); + USHORT nId = pIdItem ? pIdItem->GetValue() : 0; + + // ausfuehren + SfxWorkWindow *pWorkWin = GetFrame().GetWorkWindow_Impl(); + if ( bShow ) + { + // Zuerst die Floats auch anzeigbar machen + pWorkWin->MakeChildsVisible_Impl( bShow ); + GetDispatcher()->Update_Impl( TRUE ); + + // Dann anzeigen + GetBindings().HidePopups( !bShow ); + } + else + { + // Alles hiden + SfxBindings *pBind = &GetBindings(); + while ( pBind ) + { + pBind->HidePopupCtrls_Impl( !bShow ); + pBind = pBind->GetSubBindings_Impl(); + } + + pWorkWin->HidePopups_Impl( !bShow, TRUE, nId ); + pWorkWin->MakeChildsVisible_Impl( bShow ); + } + + Invalidate( rReq.GetSlot() ); + rReq.Done(); + break; + } + + case SID_ACTIVATE: + { + MakeActive_Impl( TRUE ); + rReq.SetReturnValue( SfxObjectItem( 0, this ) ); + break; + } + + case SID_NEWDOCDIRECT : + { + SFX_REQUEST_ARG( rReq, pFactoryItem, SfxStringItem, SID_NEWDOCDIRECT, FALSE); + String aFactName; + if ( pFactoryItem ) + aFactName = pFactoryItem->GetValue(); + else if ( pImp->aFactoryName.Len() ) + aFactName = pImp->aFactoryName; + else + { + DBG_ERROR("Missing argument!"); + break; + } + + SfxRequest aReq( SID_OPENDOC, SFX_CALLMODE_SYNCHRON, GetPool() ); + String aFact = String::CreateFromAscii("private:factory/"); + aFact += aFactName; + aReq.AppendItem( SfxStringItem( SID_FILE_NAME, aFact ) ); + aReq.AppendItem( SfxFrameItem( SID_DOCFRAME, &GetFrame() ) ); + aReq.AppendItem( SfxStringItem( SID_TARGETNAME, String::CreateFromAscii( "_blank" ) ) ); + SFX_APP()->ExecuteSlot( aReq ); + const SfxViewFrameItem* pItem = PTR_CAST( SfxViewFrameItem, aReq.GetReturnValue() ); + if ( pItem ) + rReq.SetReturnValue( SfxFrameItem( 0, pItem->GetFrame() ) ); + break; + } + + case SID_CLOSEWIN: + { + // disable CloseWin, if frame is not a task + Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY ); + if ( !xTask.is() ) + break; + + if ( GetViewShell()->PrepareClose() ) + { + // weitere Views auf dasselbe Doc? + SfxObjectShell *pDocSh = GetObjectShell(); + int bOther = sal_False; + for ( const SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocSh ); + !bOther && pFrame; + pFrame = SfxViewFrame::GetNext( *pFrame, pDocSh ) ) + bOther = (pFrame != this); + + // Doc braucht nur gefragt zu werden, wenn keine weitere View + sal_Bool bClosed = sal_False; + sal_Bool bUI = TRUE; + if ( ( bOther || pDocSh->PrepareClose( bUI ) ) ) + { + if ( !bOther ) + pDocSh->SetModified( FALSE ); + rReq.Done(); // unbedingt vor Close() rufen! + bClosed = sal_False; + try + { + xTask->close(sal_True); + bClosed = sal_True; + } + catch( CloseVetoException& ) + { + bClosed = sal_False; + } + } + + rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bClosed )); + } + return; + } + } + + rReq.Done(); +} + +void SfxViewFrame::GetState_Impl( SfxItemSet &rSet ) +{ + SfxObjectShell *pDocSh = GetObjectShell(); + + if ( !pDocSh ) + return; + + const sal_uInt16 *pRanges = rSet.GetRanges(); + DBG_ASSERT(pRanges, "Set ohne Bereich"); + while ( *pRanges ) + { + for ( sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich ) + { + switch(nWhich) + { + case SID_NEWDOCDIRECT : + { + if ( pImp->aFactoryName.Len() ) + { + String aFact = String::CreateFromAscii("private:factory/"); + aFact += pImp->aFactoryName; + rSet.Put( SfxStringItem( nWhich, aFact ) ); + } + break; + } + + case SID_NEWWINDOW: + rSet.DisableItem(nWhich); + break; + + case SID_CLOSEWIN: + { + // disable CloseWin, if frame is not a task + Reference < XCloseable > xTask( GetFrame().GetFrameInterface(), UNO_QUERY ); + if ( !xTask.is() ) + rSet.DisableItem(nWhich); + break; + } + + case SID_SHOWPOPUPS : + break; + + case SID_OBJECT: + if ( GetViewShell() && GetViewShell()->GetVerbs().getLength() && !GetObjectShell()->IsInPlaceActive() ) + { + uno::Any aAny; + aAny <<= GetViewShell()->GetVerbs(); + rSet.Put( SfxUnoAnyItem( USHORT( SID_OBJECT ), aAny ) ); + } + else + rSet.DisableItem( SID_OBJECT ); + break; + + default: + DBG_ERROR( "invalid message-id" ); + } + } + ++pRanges; + } +} + +void SfxViewFrame::INetExecute_Impl( SfxRequest &rRequest ) +{ + sal_uInt16 nSlotId = rRequest.GetSlot(); + switch( nSlotId ) + { + case SID_BROWSE_FORWARD: + case SID_BROWSE_BACKWARD: + OSL_ENSURE( false, "SfxViewFrame::INetExecute_Impl: SID_BROWSE_FORWARD/BACKWARD are dead!" ); + break; + case SID_CREATELINK: + { +/*! (pb) we need new implementation to create a link +*/ + break; + } + case SID_FOCUSURLBOX: + { + SfxStateCache *pCache = GetBindings().GetAnyStateCache_Impl( SID_OPENURL ); + if( pCache ) + { + SfxControllerItem* pCtrl = pCache->GetItemLink(); + while( pCtrl ) + { + pCtrl->StateChanged( SID_FOCUSURLBOX, SFX_ITEM_UNKNOWN, 0 ); + pCtrl = pCtrl->GetItemLink(); + } + } + } + } + + // Recording + rRequest.Done(); +} + +void SfxViewFrame::INetState_Impl( SfxItemSet &rItemSet ) +{ + rItemSet.DisableItem( SID_BROWSE_FORWARD ); + rItemSet.DisableItem( SID_BROWSE_BACKWARD ); + + // Add/SaveToBookmark bei BASIC-IDE, QUERY-EDITOR etc. disablen + SfxObjectShell *pDocSh = GetObjectShell(); + sal_Bool bPseudo = pDocSh && !( pDocSh->GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC ); + sal_Bool bEmbedded = pDocSh && pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED; + if ( !pDocSh || bPseudo || bEmbedded || !pDocSh->HasName() ) + rItemSet.DisableItem( SID_CREATELINK ); +} + +void SfxViewFrame::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY ) +{ + GetViewShell()->SetZoomFactor( rZoomX, rZoomY ); +} + +void SfxViewFrame::Activate( sal_Bool bMDI ) +{ + DBG_ASSERT(GetViewShell(), "Keine Shell"); + if ( bMDI ) + pImp->bActive = sal_True; +//(mba): hier evtl. wie in Beanframe NotifyEvent ?! +} + +void SfxViewFrame::Deactivate( sal_Bool bMDI ) +{ + DBG_ASSERT(GetViewShell(), "Keine Shell"); + if ( bMDI ) + pImp->bActive = sal_False; +//(mba): hier evtl. wie in Beanframe NotifyEvent ?! +} diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 981d13cc0f9a..69ce837fb023 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -84,12 +84,10 @@ struct SfxViewShell_Impl Size aOptimalSize; Size aMargin; USHORT nPrinterLocks; - BOOL bUseObjectSize; BOOL bCanPrint; BOOL bHasPrintOptions; BOOL bPlugInsActive; BOOL bIsShowView; - BOOL bFrameSetImpl; BOOL bOwnsMenu; BOOL bGotOwnerShip; BOOL bGotFrameOwnerShip; diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 3224d1c18d5c..5c65c967434f 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -81,7 +81,7 @@ #include "view.hrc" #include "sfxlocal.hrc" #include <sfx2/sfxbasecontroller.hxx> -#include <sfx2/topfrm.hxx> +#include <sfx2/viewfrm.hxx> #include "mailmodelapi.hxx" #include <sfx2/event.hxx> #include <sfx2/fcontnr.hxx> @@ -389,7 +389,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) case SID_ACTIVATE_STYLE_APPLY: { com::sun::star::uno::Reference< com::sun::star::frame::XFrame > xFrame( - GetViewFrame()->GetFrame()->GetFrameInterface(), + GetViewFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY); Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY ); @@ -485,7 +485,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) if ( pMailDocType ) aDocType = pMailDocType->GetValue(); - uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() ); + uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_ERROR; if ( nId == SID_MAIL_SENDDOC ) @@ -529,7 +529,7 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) const sal_Int32 FILTERFLAG_EXPORT = 0x00000002; css::uno::Reference< lang::XMultiServiceFactory > xSMGR(::comphelper::getProcessServiceFactory(), css::uno::UNO_QUERY_THROW); - css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() ); + css::uno::Reference < css::frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); css::uno::Reference< css::frame::XModel > xModel; const rtl::OUString aModuleManager( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager" )); @@ -686,8 +686,8 @@ void SfxViewShell::ExecMisc_Impl( SfxRequest &rReq ) // ausfuehren if ( !pShowItem || bActive != pImp->bPlugInsActive ) { - SfxFrame* pTopFrame = GetFrame()->GetTopFrame(); - if ( pTopFrame != GetFrame()->GetFrame() ) + SfxFrame* pTopFrame = &GetFrame()->GetTopFrame(); + if ( pTopFrame != &GetFrame()->GetFrame() ) { // FramesetDocument SfxViewShell *pShell = pTopFrame->GetCurrentViewFrame()->GetViewShell(); @@ -773,7 +773,7 @@ void SfxViewShell::GetState_Impl( SfxItemSet &rSet ) aPrinterName = Printer::GetDefaultPrinterName(); if ( aPrinterName.getLength() > 0 ) { - uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame()->GetFrameInterface() ); + uno::Reference < frame::XFrame > xFrame( pFrame->GetFrame().GetFrameInterface() ); ::rtl::OUStringBuffer aBuffer( 60 ); aBuffer.append( RetrieveLabelFromCommand( @@ -871,7 +871,7 @@ ErrCode SfxViewShell::DoVerb(long /*nVerb*/) void SfxViewShell::OutplaceActivated( sal_Bool bActive, SfxInPlaceClient* /*pClient*/ ) { if ( !bActive ) - GetFrame()->GetFrame()->Appear(); + GetFrame()->GetFrame().Appear(); } //-------------------------------------------------------------------- @@ -893,7 +893,7 @@ void SfxViewShell::InplaceDeactivated( SfxInPlaceClient* /*pClient*/ ) void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ ) { - uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() ); + uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() ); uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY ); if ( xParentFrame.is() ) xParentFrame->setActiveFrame( xOwnFrame ); @@ -906,12 +906,12 @@ void SfxViewShell::UIActivating( SfxInPlaceClient* /*pClient*/ ) void SfxViewShell::UIDeactivated( SfxInPlaceClient* /*pClient*/ ) { - if ( !pFrame->GetFrame()->IsClosing_Impl() || + if ( !pFrame->GetFrame().IsClosing_Impl() || SfxViewFrame::Current() != pFrame ) pFrame->GetDispatcher()->Update_Impl( TRUE ); pFrame->GetBindings().HidePopups(FALSE); - // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame()->GetFrameInterface() ); + // uno::Reference < frame::XFrame > xOwnFrame( pFrame->GetFrame().GetFrameInterface() ); // uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY ); // if ( xParentFrame.is() ) // xParentFrame->setActiveFrame( uno::Reference < frame::XFrame >() ); @@ -992,7 +992,7 @@ void SfxViewShell::Activate( BOOL bMDI ) { SfxObjectShell *pSh = GetViewFrame()->GetObjectShell(); if ( pSh->GetModel().is() ) - pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame()->GetController() ); + pSh->GetModel()->setCurrentController( GetViewFrame()->GetFrame().GetController() ); SetCurrentDocument(); } @@ -1252,8 +1252,6 @@ SfxViewShell::SfxViewShell ,pFrame(pViewFrame) ,pSubShell(0) ,pWindow(0) - ,bMaximizeFirst( 0 != (nFlags & SFX_VIEW_MAXIMIZE_FIRST) ) - ,bOptimizeEach(0 != (nFlags & SFX_VIEW_OPTIMIZE_EACH)) ,bNoNewWindow( 0 != (nFlags & SFX_VIEW_NO_NEWWINDOW) ) { DBG_CTOR(SfxViewShell, 0); @@ -1263,11 +1261,7 @@ SfxViewShell::SfxViewShell pImp->bIsShowView = !(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW)); - pImp->bUseObjectSize = FALSE; -// SFX_CREATE_MODE_EMBEDDED==pFrame->GetObjectShell()->GetCreateMode() && -// SFX_VIEW_OBJECTSIZE_EMBEDDED == (nFlags & SFX_VIEW_OBJECTSIZE_EMBEDDED); pImp->bCanPrint = SFX_VIEW_CAN_PRINT == (nFlags & SFX_VIEW_CAN_PRINT); - pImp->bFrameSetImpl = (nFlags & SFX_VIEW_IMPLEMENTED_AS_FRAMESET) != 0; pImp->bHasPrintOptions = SFX_VIEW_HAS_PRINTOPTIONS == (nFlags & SFX_VIEW_HAS_PRINTOPTIONS); pImp->bPlugInsActive = TRUE; @@ -1363,6 +1357,24 @@ SfxViewShell* SfxViewShell::Current() //-------------------------------------------------------------------- +SfxViewShell* SfxViewShell::Get( const Reference< XController>& i_rController ) +{ + if ( !i_rController.is() ) + return NULL; + + for ( SfxViewShell* pViewShell = SfxViewShell::GetFirst( NULL, FALSE ); + pViewShell; + pViewShell = SfxViewShell::GetNext( *pViewShell, NULL, FALSE ) + ) + { + if ( pViewShell->GetController() == i_rController ) + return pViewShell; + } + return NULL; +} + +//-------------------------------------------------------------------- + SdrView* SfxViewShell::GetDrawView() const /* [Beschreibung] @@ -1514,16 +1526,12 @@ void SfxViewShell::PushSubShells_Impl( BOOL bPush ) { for ( USHORT n=0; n<nCount; n++ ) pDisp->Push( *pImp->aArr[n] ); - -// HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen) -// Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED4 ) ); } else if ( nCount ) { - pDisp->Pop( *pImp->aArr[0], SFX_SHELL_POP_UNTIL ); - -// HACK(evtl. PushSubShells fuer SW virtuell machen oder im SW umbauen) -// Notify( *this, SfxSimpleHint( SFX_HINT_RESERVED3 ) ); + SfxShell& rPopUntil = *pImp->aArr[0]; + if ( pDisp->GetShellLevel( rPopUntil ) != USHRT_MAX ) + pDisp->Pop( rPopUntil, SFX_SHELL_POP_UNTIL ); } pDisp->Flush(); @@ -1674,7 +1682,7 @@ BOOL SfxViewShell::ExecKey_Impl(const KeyEvent& aKey) if (!pImp->pAccExec) { pImp->pAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper(); - pImp->pAccExec->init(::comphelper::getProcessServiceFactory(), pFrame->GetFrame()->GetFrameInterface()); + pImp->pAccExec->init(::comphelper::getProcessServiceFactory(), pFrame->GetFrame().GetFrameInterface()); } return pImp->pAccExec->execute(aKey.GetKeyCode()); @@ -1779,13 +1787,6 @@ void SfxViewShell::DisconnectAllClients() //-------------------------------------------------------------------- -BOOL SfxViewShell::UseObjectSize() const -{ - return pImp->bUseObjectSize; -} - -//-------------------------------------------------------------------- - void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const { } @@ -1795,14 +1796,7 @@ void SfxViewShell::QueryObjAreaPixel( Rectangle& ) const void SfxViewShell::AdjustVisArea(const Rectangle& rRect) { DBG_ASSERT (pFrame, "Kein Frame?"); - if ( UseObjectSize() ) - { - Point aPos = rRect.TopLeft(); - Size aSize = GetObjectShell()->GetVisArea().GetSize(); - GetObjectShell()->SetVisArea( Rectangle(aPos, aSize) ); - } - else - GetObjectShell()->SetVisArea( rRect ); + GetObjectShell()->SetVisArea( rRect ); } //-------------------------------------------------------------------- @@ -1974,13 +1968,6 @@ SfxFrame* SfxViewShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ ) return pSelf; } -//-------------------------------------------------------------------- - -BOOL SfxViewShell::IsImplementedAsFrameset_Impl( ) const -{ - return pImp->bFrameSetImpl; -} - //------------------------------------------------------------------------ void SfxViewShell::JumpToMark( const String& rMark ) @@ -2020,6 +2007,11 @@ Reference < XController > SfxViewShell::GetController() return pImp->pController; } +SfxBaseController* SfxViewShell::GetBaseController_Impl() const +{ + return pImp->pController; +} + void SfxViewShell::AddContextMenuInterceptor_Impl( const REFERENCE< XCONTEXTMENUINTERCEPTOR >& xInterceptor ) { pImp->aInterceptorContainer.addInterface( xInterceptor ); @@ -2174,7 +2166,7 @@ void SfxViewShell::CheckOwnerShip_Impl() { // document couldn't be closed or it shouldn't, now try at least to close the frame com::sun::star::uno::Reference < com::sun::star::util::XCloseable > xFrame( - GetViewFrame()->GetFrame()->GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); + GetViewFrame()->GetFrame().GetFrameInterface(), com::sun::star::uno::UNO_QUERY ); if ( xFrame.is() ) { try @@ -2253,3 +2245,4 @@ void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransf { } } + diff --git a/sfx2/util/hidother.src b/sfx2/util/hidother.src index 238e93823e26..72b178b2d629 100644 --- a/sfx2/util/hidother.src +++ b/sfx2/util/hidother.src @@ -57,35 +57,12 @@ hidspecial SID_STYLE_FAMILY4 { HelpID = SID_STYLE_FAMILY4; }; hidspecial SID_STYLE_FAMILY5 { HelpID = SID_STYLE_FAMILY5; }; hidspecial SID_FILTER_NAME { HelpID = SID_FILTER_NAME; }; hidspecial HID_NAVIGATOR_WINDOW { HelpID = HID_NAVIGATOR_WINDOW; }; -hidspecial SID_EXPLORERCONTENT_OPEN { HelpId = SID_EXPLORERCONTENT_OPEN; }; -hidspecial SID_EXPLORERCONTENT_OPEN_FOLDER { HelpId = SID_EXPLORERCONTENT_OPEN_FOLDER; }; -hidspecial SID_EXPLORERCONTENT_OPEN_TEMPLATE { HelpId = SID_EXPLORERCONTENT_OPEN_TEMPLATE; }; -hidspecial SID_EXPLORERCONTENT_OPEN_DOCUMENT { HelpId = SID_EXPLORERCONTENT_OPEN_DOCUMENT; }; -hidspecial SID_EXPLORERCONTENT_OPEN_OBJECT { HelpId = SID_EXPLORERCONTENT_OPEN_OBJECT; }; hidspecial HID_HELPAGENT_TIP_BOX { HelpId = HID_HELPAGENT_TIP_BOX; }; -hidspecial SID_EXPLORER_SEARCH_DLG { HelpId = SID_EXPLORER_SEARCH_DLG; }; -hidspecial SID_TRASH_RECOVER { HelpId = SID_TRASH_RECOVER; }; -hidspecial SID_TRASH_AUTOEMPTY { HelpId = SID_TRASH_AUTOEMPTY; }; -hidspecial SID_TRASH_EMPTY { HelpId = SID_TRASH_EMPTY; }; -hidspecial SID_EXPLORERCONTENT_NEW { HelpId = SID_EXPLORERCONTENT_NEW; }; -hidspecial SID_EXPLORERCONTENT_DESTROY { HelpId = SID_EXPLORERCONTENT_DESTROY; }; -hidspecial SID_EXPLORERCONTENT_RENAME { HelpId = SID_EXPLORERCONTENT_RENAME; }; -hidspecial SID_EXPLORERCONTENT_COPY { HelpId = SID_EXPLORERCONTENT_COPY; }; -hidspecial SID_EXPLORERCONTENT_PASTE { HelpId = SID_EXPLORERCONTENT_PASTE; }; -hidspecial SID_EXPLORERCONTENT_CREATELINK { HelpId = SID_EXPLORERCONTENT_CREATELINK; }; -hidspecial SID_EXPLORERCONTENT_MAKEROOT { HelpId = SID_EXPLORERCONTENT_MAKEROOT; }; -hidspecial SID_EXPLORERCONTENT_DEFAULTTEMPLATE { HelpId = SID_EXPLORERCONTENT_DEFAULTTEMPLATE; }; -hidspecial SID_PROPERTIES { HelpId = SID_PROPERTIES; }; -hidspecial SID_EXPLORER_BOOKMARKDIR { HelpId = SID_EXPLORER_BOOKMARKDIR; }; -hidspecial SID_EXPLORER_SEARCHORIG { HelpId = SID_EXPLORER_SEARCHORIG; }; hidspecial HID_TEMPLDLG_TOOLBOX_LEFT { HelpId = HID_TEMPLDLG_TOOLBOX_LEFT;}; hidspecial HID_EXPLORER_SRCH_COUNT { HelpId = HID_EXPLORER_SRCH_COUNT;}; -hidspecial SID_EXPLORER_PASTE_ASLINK { HelpId = SID_EXPLORER_PASTE_ASLINK;}; hidspecial HID_INTERFACE_SFXPLUGINVIEW { HelpID = HID_INTERFACE_SFXPLUGINVIEW; }; hidspecial HID_TABDLG_RESET_BTN { HelpID = HID_TABDLG_RESET_BTN; }; hidspecial HID_TABDLG_STANDARD_BTN { HelpID = HID_TABDLG_STANDARD_BTN; }; -hidspecial SID_EXPLORER_RESETURL { HelpID = SID_EXPLORER_RESETURL; }; -hidspecial SID_ORIG_PROPERTIES { HelpID = SID_ORIG_PROPERTIES; }; hidspecial HID_CONFIG_EVENT_OFFICE_BASED { HelpID = HID_CONFIG_EVENT_OFFICE_BASED; }; hidspecial HID_CONFIG_EVENT_DOCUMENT_BASED { HelpID = HID_CONFIG_EVENT_DOCUMENT_BASED; }; hidspecial HID_EXPLORER_SRCH_LATEST_COUNT { HelpID = HID_EXPLORER_SRCH_LATEST_COUNT; }; @@ -97,10 +74,6 @@ hidspecial HID_CHAOSDOC_WIN { HelpID = HID_CHAOSDOC_WIN; }; hidspecial HID_CHAOSDOC_WIN_HEADER { HelpID = HID_CHAOSDOC_WIN_HEADER; }; hidspecial HID_CHAOSDOC_WIN_PARTS { HelpID = HID_CHAOSDOC_WIN_PARTS; }; hidspecial HID_CHAOSDOC_WIN_BODY { HelpID = HID_CHAOSDOC_WIN_BODY; }; -hidspecial SID_CHAOSDOC_LAYOUT1 { HelpID = SID_CHAOSDOC_LAYOUT1; }; -hidspecial SID_CHAOSDOC_LAYOUT2 { HelpID = SID_CHAOSDOC_LAYOUT2; }; -hidspecial SID_CHAOSDOC_LAYOUT3 { HelpID = SID_CHAOSDOC_LAYOUT3; }; -hidspecial SID_CHAOSDOC_LAYOUT4 { HelpID = SID_CHAOSDOC_LAYOUT4; }; hidspecial HID_BRWBOX_HEADERBAR { HelpID = HID_BRWBOX_HEADERBAR; }; hidspecial HID_TASKBAR { HelpID = HID_TASKBAR; }; hidspecial HID_TASKBUTTONBAR { HelpID = HID_TASKBUTTONBAR; }; @@ -126,9 +99,6 @@ hidspecial HID_CHAOS_NEW_SUBSCR_BOX { HelpID = HID_CHAOS_NEW_SUBSCR_ hidspecial HID_CHAOS_NEW_BOOKMARK { HelpID = HID_CHAOS_NEW_BOOKMARK; }; hidspecial HID_CHAOS_NEW_PUB_BOX { HelpID = HID_CHAOS_NEW_PUB_BOX; }; hidspecial HID_UUI_END { HelpID = HID_UUI_END; }; // aka HID_CHAOS_NEW_DATABASE -hidspecial SID_EXPLORER_SHOWEXTENSION { HelpID = SID_EXPLORER_SHOWEXTENSION; }; -hidspecial SID_EXPLORER_MAIL_HEADER { HelpID = SID_EXPLORER_MAIL_HEADER; }; -hidspecial SID_EXPLORER_MAIL_BODY { HelpID = SID_EXPLORER_MAIL_BODY; }; hidspecial HID_CNT_DLG_SEARCH_BT_SHOW { HelpID = HID_CNT_DLG_SEARCH_BT_SHOW; }; hidspecial HID_CNT_DLG_SEARCH_BT_UPDATE { HelpID = HID_CNT_DLG_SEARCH_BT_UPDATE; }; hidspecial HID_CNT_DLG_SEARCH_BT_SYNCHRONIZE { HelpID = HID_CNT_DLG_SEARCH_BT_SYNCHRONIZE; }; |