summaryrefslogtreecommitdiff
path: root/sfx2/source/doc
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/doc')
-rw-r--r--sfx2/source/doc/SfxDocumentMetaData.cxx17
-rw-r--r--sfx2/source/doc/commitlistener.cxx81
-rw-r--r--sfx2/source/doc/commitlistener.hxx57
-rw-r--r--sfx2/source/doc/docfac.cxx38
-rw-r--r--sfx2/source/doc/docfile.cxx120
-rw-r--r--sfx2/source/doc/makefile.mk1
-rw-r--r--sfx2/source/doc/objcont.cxx275
-rw-r--r--sfx2/source/doc/objembed.cxx2
-rw-r--r--sfx2/source/doc/objmisc.cxx45
-rw-r--r--sfx2/source/doc/objserv.cxx55
-rw-r--r--sfx2/source/doc/objstor.cxx49
-rw-r--r--sfx2/source/doc/objxtor.cxx266
-rw-r--r--sfx2/source/doc/opostponedtruncationstream.cxx491
-rw-r--r--sfx2/source/doc/opostponedtruncationstream.hxx122
-rwxr-xr-xsfx2/source/doc/printhelper.cxx26
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx1066
-rw-r--r--sfx2/source/doc/sfxmodelfactory.cxx9
17 files changed, 781 insertions, 1939 deletions
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index 2a6a582ca8..6f9c9d0bd5 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -585,7 +585,9 @@ sal_Int32 textToDuration(::rtl::OUString const& i_rText) throw ()
{
css::util::Duration d;
if (textToDuration(d, i_rText)) {
- return (d.Days * (24*3600))
+ // #i107372#: approximate years/months
+ const sal_Int32 days( (d.Years * 365) + (d.Months * 30) + d.Days );
+ return (days * (24*3600))
+ (d.Hours * 3600) + (d.Minutes * 60) + d.Seconds;
} else {
return 0; // default
@@ -608,7 +610,7 @@ sal_Int32 textToDuration(::rtl::OUString const& i_rText) throw ()
ud.Hours = static_cast<sal_Int16>((i_value % (24 * 3600)) / 3600);
ud.Minutes = static_cast<sal_Int16>((i_value % 3600) / 60);
ud.Seconds = static_cast<sal_Int16>(i_value % 60);
- ud.HundredthSeconds = 0;
+ ud.MilliSeconds = 0;
return durationToText(ud);
}
@@ -925,8 +927,13 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
values.push_back(s);
// #i90847# OOo 2.x does stupid things if value-type="string";
// fortunately string is default anyway, so we can just omit it
-// as.push_back(std::make_pair(vt,
-// ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("string"))));
+// #i107502#: however, OOo 2.x only reads 4 user-defined without @value-type
+// => best backward compatibility: first 4 without @value-type, rest with
+ if (4 <= i)
+ {
+ as.push_back(std::make_pair(vt,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("string"))));
+ }
} else if (type == ::cppu::UnoType<css::util::DateTime>::get()) {
css::util::DateTime dt;
any >>= dt;
@@ -948,7 +955,7 @@ propsToStrings(css::uno::Reference<css::beans::XPropertySet> const & i_xPropSet)
ud.Hours = ut.Hours;
ud.Minutes = ut.Minutes;
ud.Seconds = ut.Seconds;
- ud.HundredthSeconds = ut.HundredthSeconds;
+ ud.MilliSeconds = 10 * ut.HundredthSeconds;
values.push_back(durationToText(ud));
as.push_back(std::make_pair(vt,
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time"))));
diff --git a/sfx2/source/doc/commitlistener.cxx b/sfx2/source/doc/commitlistener.cxx
deleted file mode 100644
index 73e0d10683..0000000000
--- a/sfx2/source/doc/commitlistener.cxx
+++ /dev/null
@@ -1,81 +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"
-
-#include "commitlistener.hxx"
-
-using namespace ::com::sun::star;
-
-OChildCommitListen_Impl::OChildCommitListen_Impl( SfxBaseModel& aModel )
-: m_pModel( &aModel )
-{}
-
-OChildCommitListen_Impl::~OChildCommitListen_Impl()
-{}
-
-void OChildCommitListen_Impl::OwnerIsDisposed()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- m_pModel = NULL;
-}
-
-void SAL_CALL OChildCommitListen_Impl::preCommit( const ::com::sun::star::lang::EventObject& )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
-{
- // not interesting
-}
-
-void SAL_CALL OChildCommitListen_Impl::commited( const ::com::sun::star::lang::EventObject& /*aEvent*/ )
- throw (::com::sun::star::uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
- // StorageIsModified_Impl must not contain any locking!
- if ( m_pModel )
- m_pModel->StorageIsModified_Impl();
-}
-
-void SAL_CALL OChildCommitListen_Impl::preRevert( const ::com::sun::star::lang::EventObject& )
- throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
-{
- // not interesting
-}
-
-void SAL_CALL OChildCommitListen_Impl::reverted( const ::com::sun::star::lang::EventObject& )
- throw (::com::sun::star::uno::RuntimeException)
-{
- // not interesting
-}
-
-
-void SAL_CALL OChildCommitListen_Impl::disposing( const lang::EventObject& )
- throw ( uno::RuntimeException )
-{
- // not interesting
-}
-
diff --git a/sfx2/source/doc/commitlistener.hxx b/sfx2/source/doc/commitlistener.hxx
deleted file mode 100644
index bffcd508d4..0000000000
--- a/sfx2/source/doc/commitlistener.hxx
+++ /dev/null
@@ -1,57 +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 __COMMITLISTENER_HXX_
-#define __COMMITLISTENER_HXX_
-
-#include <com/sun/star/embed/XTransactionListener.hpp>
-#include <cppuhelper/implbase1.hxx>
-#include <osl/mutex.hxx>
-
-#include <sfx2/sfxbasemodel.hxx>
-
-class OChildCommitListen_Impl : public ::cppu::WeakImplHelper1 < ::com::sun::star::embed::XTransactionListener >
-{
- ::osl::Mutex m_aMutex;
- SfxBaseModel* m_pModel;
-
-public:
- OChildCommitListen_Impl( SfxBaseModel& aStorage );
- virtual ~OChildCommitListen_Impl();
-
- void OwnerIsDisposed();
-
- virtual void SAL_CALL preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL preRevert( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
-
- virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
-};
-
-#endif
-
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 93acc40a89..e0c75790d0 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 df9477c489..b5f0358d29 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -133,7 +133,6 @@ using namespace ::com::sun::star::io;
#include <unotools/saveopt.hxx>
#include <svl/documentlockfile.hxx>
-#include "opostponedtruncationstream.hxx"
#include "helper.hxx"
#include <sfx2/request.hxx> // SFX_ITEMSET_SET
#include <sfx2/app.hxx> // GetFilterMatcher
@@ -260,79 +259,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 +266,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 +281,6 @@ public:
uno::Reference < embed::XStorage > xStorage;
- SfxPoolCancelManager_ImplRef xCancelManager;
SfxMedium* pAntiImpl;
long nFileVersion;
@@ -399,8 +323,6 @@ public:
uno::Reference< logging::XSimpleLogRing > m_xLogRing;
- SfxPoolCancelManager_Impl* GetCancelManager();
-
SfxMedium_Impl( SfxMedium* pAntiImplP );
~SfxMedium_Impl();
};
@@ -416,29 +338,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 +2344,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 +3173,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/makefile.mk b/sfx2/source/doc/makefile.mk
index 7da456ebaa..b766921e34 100644
--- a/sfx2/source/doc/makefile.mk
+++ b/sfx2/source/doc/makefile.mk
@@ -75,7 +75,6 @@ SLOFILES = \
$(SLO)$/objembed.obj\
$(SLO)$/graphhelp.obj \
$(SLO)$/QuerySaveDocument.obj \
- $(SLO)$/opostponedtruncationstream.obj \
$(SLO)$/docinsert.obj \
$(SLO)$/docmacromode.obj \
$(SLO)$/SfxDocumentMetaData.obj \
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index c25b0d79b0..301a2546c2 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()
@@ -479,13 +230,24 @@ void SfxObjectShell::UpdateDocInfoForSave()
//--------------------------------------------------------------------
+static void
+lcl_add(util::Duration & rDur, Time const& rTime)
+{
+ // here we don't care about overflow: rDur is converted back to seconds
+ // anyway, and Time cannot store more than ~4000 hours
+ rDur.Hours += rTime.GetHour();
+ rDur.Minutes += rTime.GetMin();
+ rDur.Seconds += rTime.GetSec();
+}
+
// Bearbeitungszeit aktualisieren
void SfxObjectShell::UpdateTime_Impl(
const uno::Reference<document::XDocumentProperties> & i_xDocProps)
{
// Get old time from documentinfo
- sal_Int32 secs = i_xDocProps->getEditingDuration();
- Time aOldTime(secs/3600, (secs%3600)/60, secs%60);
+ const sal_Int32 secs = i_xDocProps->getEditingDuration();
+ util::Duration editDuration(sal_False, 0, 0, 0,
+ secs/3600, (secs%3600)/60, secs%60, 0);
// Initialize some local member! Its neccessary for wollow operations!
DateTime aNow ; // Date and time at current moment
@@ -522,13 +284,14 @@ void SfxObjectShell::UpdateTime_Impl(
nAddTime += aNow ;
}
- aOldTime += nAddTime;
+ lcl_add(editDuration, nAddTime);
}
pImp->nTime = aNow;
try {
- i_xDocProps->setEditingDuration(
- aOldTime.GetHour()*3600+aOldTime.GetMin()*60+aOldTime.GetSec());
+ const sal_Int32 newSecs( (editDuration.Hours*3600)
+ + (editDuration.Minutes*60) + editDuration.Seconds);
+ i_xDocProps->setEditingDuration(newSecs);
i_xDocProps->setEditingCycles(i_xDocProps->getEditingCycles() + 1);
}
catch (lang::IllegalArgumentException &)
diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx
index a2b7d47e7b..868f337102 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 9373cdef27..3cb2177833 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 ea268fe613..795f5a20ca 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 22fb955887..902793af73 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;
}
@@ -2592,6 +2548,7 @@ sal_Bool SfxObjectShell::DoSave_Impl( const SfxItemSet* pArgs )
// is a new medium "from scratch", so no version should be stored into it
SfxItemSet* pSet = new SfxAllItemSet(*pRetrMedium->GetItemSet());
pSet->ClearItem( SID_VERSION );
+ pSet->ClearItem( SID_DOC_BASEURL );
// create a medium as a copy; this medium is only for writingm, because it uses the same name as the original one
// writing is done through a copy, that will be transferred to the target ( of course after calling HandsOff )
@@ -2815,7 +2772,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 );
@@ -2878,6 +2834,7 @@ sal_Bool SfxObjectShell::PreDoSaveAs_Impl
pMergedParams->ClearItem( SID_STREAM );
pMergedParams->ClearItem( SID_CONTENT );
pMergedParams->ClearItem( SID_DOC_READONLY );
+ pMergedParams->ClearItem( SID_DOC_BASEURL );
pMergedParams->ClearItem( SID_REPAIRPACKAGE );
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index b114960b20..2298b93486 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/opostponedtruncationstream.cxx b/sfx2/source/doc/opostponedtruncationstream.cxx
deleted file mode 100644
index 364a4d5a65..0000000000
--- a/sfx2/source/doc/opostponedtruncationstream.cxx
+++ /dev/null
@@ -1,491 +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"
-#include <osl/diagnose.h>
-
-#include <opostponedtruncationstream.hxx>
-
-using namespace ::com::sun::star;
-
-// ========================================================================
-struct PTFStreamData_Impl
-{
- uno::Reference< ucb::XSimpleFileAccess > m_xFileAccess;
- sal_Bool m_bDelete;
- ::rtl::OUString m_aURL;
-
- // the streams below are not visible from outside so there is no need to remember position
-
- // original stream related members
- uno::Reference< io::XStream > m_xOrigStream;
- uno::Reference< io::XTruncate > m_xOrigTruncate;
- uno::Reference< io::XSeekable > m_xOrigSeekable;
- uno::Reference< io::XInputStream > m_xOrigInStream;
- uno::Reference< io::XOutputStream > m_xOrigOutStream;
-
- sal_Bool m_bInOpen;
- sal_Bool m_bOutOpen;
-
- sal_Bool m_bPostponedTruncate;
-
-
- PTFStreamData_Impl(
- const uno::Reference< ucb::XSimpleFileAccess >& xFileAccess,
- sal_Bool bDelete,
- const ::rtl::OUString& aURL,
- const uno::Reference< io::XStream >& xOrigStream,
- const uno::Reference< io::XTruncate >& xOrigTruncate,
- const uno::Reference< io::XSeekable >& xOrigSeekable,
- const uno::Reference< io::XInputStream >& xOrigInStream,
- const uno::Reference< io::XOutputStream >& xOrigOutStream )
- : m_xFileAccess( xFileAccess )
- , m_bDelete( bDelete )
- , m_aURL( aURL )
- , m_xOrigStream( xOrigStream )
- , m_xOrigTruncate( xOrigTruncate )
- , m_xOrigSeekable( xOrigSeekable )
- , m_xOrigInStream( xOrigInStream )
- , m_xOrigOutStream( xOrigOutStream )
- , m_bInOpen( sal_False )
- , m_bOutOpen( sal_False )
- , m_bPostponedTruncate( sal_True )
- {}
-
- void NoPostponing()
- {
- m_bDelete = sal_False;
- m_bPostponedTruncate = sal_False;
- }
-};
-
-// ========================================================================
-// ------------------------------------------------------------------------
-OPostponedTruncationFileStream::OPostponedTruncationFileStream(
- const ::rtl::OUString& aURL,
- const uno::Reference< lang::XMultiServiceFactory >& /*xFactory*/,
- const uno::Reference< ucb::XSimpleFileAccess >& xFileAccess,
- const uno::Reference< io::XStream >& xOrigStream,
- sal_Bool bDelete )
-: m_pStreamData( NULL )
-{
- if ( !xFileAccess.is() || !xOrigStream.is() )
- throw uno::RuntimeException();
-
- uno::Reference< io::XTruncate > xOrigTruncate( xOrigStream, uno::UNO_QUERY_THROW );
- uno::Reference< io::XSeekable > xOrigSeekable( xOrigStream, uno::UNO_QUERY_THROW );
- uno::Reference< io::XInputStream > xOrigInStream = xOrigStream->getInputStream();
- uno::Reference< io::XOutputStream > xOrigOutStream = xOrigStream->getOutputStream();
- if ( !xOrigInStream.is() || !xOrigOutStream.is() )
- throw uno::RuntimeException();
-
- m_pStreamData = new PTFStreamData_Impl( xFileAccess, bDelete, aURL,
- xOrigStream, xOrigTruncate, xOrigSeekable, xOrigInStream, xOrigOutStream );
-}
-
-// ------------------------------------------------------------------------
-OPostponedTruncationFileStream::~OPostponedTruncationFileStream()
-{
- CloseAll_Impl();
-}
-
-// ------------------------------------------------------------------------
-void OPostponedTruncationFileStream::CloseAll_Impl()
-{
- if ( m_pStreamData )
- {
- sal_Bool bDelete = m_pStreamData->m_bDelete;
- ::rtl::OUString aURL = m_pStreamData->m_aURL;
- uno::Reference< ucb::XSimpleFileAccess > xFileAccess = m_pStreamData->m_xFileAccess;
-
- delete m_pStreamData;
- m_pStreamData = NULL;
-
- if ( bDelete && xFileAccess.is() && aURL.getLength() )
- {
- // delete the file
- try
- {
- xFileAccess->kill( aURL );
- } catch( uno::Exception& )
- {
- OSL_ENSURE( sal_False, "Could not remove the file!" );
- }
- }
- }
-}
-
-// ------------------------------------------------------------------------
-void OPostponedTruncationFileStream::CheckScheduledTruncation_Impl()
-{
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigTruncate.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigTruncate->truncate();
- m_pStreamData->NoPostponing();
- }
-}
-
-// com::sun::star::io::XStream
-// ------------------------------------------------------------------------
-uno::Reference< io::XInputStream > SAL_CALL OPostponedTruncationFileStream::getInputStream( )
- throw (uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( m_pStreamData )
- m_pStreamData->m_bInOpen = sal_True;
- return static_cast< io::XInputStream* >( this );
-}
-
-
-// ------------------------------------------------------------------------
-uno::Reference< io::XOutputStream > SAL_CALL OPostponedTruncationFileStream::getOutputStream( )
- throw (uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( m_pStreamData )
- m_pStreamData->m_bOutOpen = sal_True;
- return static_cast< io::XOutputStream* >( this );
-}
-
-
-
-// com::sun::star::io::XInputStream
-// ------------------------------------------------------------------------
-::sal_Int32 SAL_CALL OPostponedTruncationFileStream::readBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the stream must behave as truncated one
- aData.realloc( 0 );
- return 0;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigInStream.is() )
- throw uno::RuntimeException();
-
- return m_pStreamData->m_xOrigInStream->readBytes( aData, nBytesToRead );
- }
-}
-
-
-// ------------------------------------------------------------------------
-::sal_Int32 SAL_CALL OPostponedTruncationFileStream::readSomeBytes( uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the stream must behave as truncated one
- aData.realloc( 0 );
- return 0;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigInStream.is() )
- throw uno::RuntimeException();
-
- return m_pStreamData->m_xOrigInStream->readBytes( aData, nMaxBytesToRead );
- }
-}
-
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::skipBytes( ::sal_Int32 nBytesToSkip )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the stream must behave as truncated one
- if ( nBytesToSkip > 0 )
- throw io::BufferSizeExceededException();
-
- return;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigInStream.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigInStream->skipBytes( nBytesToSkip );
- }
-}
-
-
-// ------------------------------------------------------------------------
-::sal_Int32 SAL_CALL OPostponedTruncationFileStream::available( )
- throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the stream must behave as truncated one
- return 0;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigInStream.is() )
- throw uno::RuntimeException();
-
- return m_pStreamData->m_xOrigInStream->available();
- }
-}
-
-
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::closeInput()
- throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- m_pStreamData->m_bInOpen = sal_False;
- if ( !m_pStreamData->m_bOutOpen )
- CloseAll_Impl();
-}
-
-
-
-// com::sun::star::io::XOutputStream
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::writeBytes( const uno::Sequence< ::sal_Int8 >& aData )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- // writing method must check the truncation
- CheckScheduledTruncation_Impl();
-
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigOutStream.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigOutStream->writeBytes( aData );
-}
-
-
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::flush( )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- {
- OSL_ENSURE( sal_False, "flush() call on closed stream!\n" );
- return;
- // in future throw exception, for now some code might call flush() on closed stream
- // since file ucp implementation allows it
- // throw io::NotConnectedException();
- }
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // it is no writing call, thus must be ignored
- return;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigOutStream.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigOutStream->flush();
- }
-}
-
-
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::closeOutput( )
- throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- m_pStreamData->m_bOutOpen = sal_False;
- if ( !m_pStreamData->m_bInOpen )
- CloseAll_Impl();
-}
-
-
-
-// com::sun::star::io::XTruncate
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::truncate( )
- throw (io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- // the truncation is already scheduled, ignore
- return;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigTruncate.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigTruncate->truncate();
- }
-}
-
-
-
-// com::sun::star::io::XSeekable
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::seek( ::sal_Int64 location )
- throw (lang::IllegalArgumentException, io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- if ( location > 0 )
- throw lang::IllegalArgumentException();
-
- return;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigSeekable.is() )
- throw uno::RuntimeException();
-
- m_pStreamData->m_xOrigSeekable->seek( location );
- }
-}
-
-
-// ------------------------------------------------------------------------
-::sal_Int64 SAL_CALL OPostponedTruncationFileStream::getPosition( )
- throw (io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- return 0;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigSeekable.is() )
- throw uno::RuntimeException();
-
- return m_pStreamData->m_xOrigSeekable->getPosition();
- }
-}
-
-
-// ------------------------------------------------------------------------
-::sal_Int64 SAL_CALL OPostponedTruncationFileStream::getLength( )
- throw (io::IOException, uno::RuntimeException)
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- {
- return 0;
- }
- else
- {
- // the original stream data should be provided
- if ( !m_pStreamData->m_xOrigSeekable.is() )
- throw uno::RuntimeException();
-
- return m_pStreamData->m_xOrigSeekable->getLength();
- }
-}
-
-// ------------------------------------------------------------------------
-void SAL_CALL OPostponedTruncationFileStream::waitForCompletion()
- throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
-{
- if ( !m_pStreamData )
- throw io::NotConnectedException();
-
- if ( m_pStreamData->m_bPostponedTruncate )
- return;
-
- uno::Reference< io::XAsyncOutputMonitor > asyncOutputMonitor( m_pStreamData->m_xOrigOutStream, uno::UNO_QUERY );
- if ( asyncOutputMonitor.is() )
- asyncOutputMonitor->waitForCompletion();
-}
-
diff --git a/sfx2/source/doc/opostponedtruncationstream.hxx b/sfx2/source/doc/opostponedtruncationstream.hxx
deleted file mode 100644
index ce60cdf2e0..0000000000
--- a/sfx2/source/doc/opostponedtruncationstream.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_OPOSTPONEDTRUNCATIONFILESTREAM_HXX
-#define _SFX_OPOSTPONEDTRUNCATIONFILESTREAM_HXX
-
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
-#include <com/sun/star/io/XSeekable.hpp>
-#include <com/sun/star/io/XTruncate.hpp>
-#include <com/sun/star/io/XStream.hpp>
-#include <com/sun/star/embed/XTransactedObject.hpp>
-#include <com/sun/star/beans/XPropertySetInfo.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
-#include <com/sun/star/io/XAsyncOutputMonitor.hpp>
-#include <osl/mutex.hxx>
-#include <cppuhelper/implbase6.hxx>
-#include "sfx2/dllapi.h"
-
-//==================================================================
-// OPostponedTruncationFileStream
-//
-// Allows to get stream access to a file, where the first truncation
-// of the file is postponed till the first writing. If no writing happens
-// after the first truncation/creation, it has no effect. ( The postponing of
-// the creation can be switched off during initialization. Here the postponing
-// of the creation means that the file will be created immediatelly, but
-// if nothing is written into it, it will be removed during destruction
-// of the object. )
-//
-// On creation of this object the target file is scheduled for
-// creation/truncation. But the action happens only during the first
-// write access. After the first write access the object behaves
-// itself as the original stream.
-//==================================================================
-
-struct PTFStreamData_Impl;
-class SFX2_DLLPUBLIC OPostponedTruncationFileStream
- : public ::cppu::WeakImplHelper6 <
- ::com::sun::star::io::XStream,
- ::com::sun::star::io::XInputStream,
- ::com::sun::star::io::XOutputStream,
- ::com::sun::star::io::XTruncate,
- ::com::sun::star::io::XSeekable,
- ::com::sun::star::io::XAsyncOutputMonitor >
-{
- ::osl::Mutex m_aMutex;
- PTFStreamData_Impl* m_pStreamData;
-
- void CloseAll_Impl();
-
- void CheckScheduledTruncation_Impl();
-
-public:
-
- OPostponedTruncationFileStream(
- const ::rtl::OUString& aURL,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory,
- const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xFileAccess,
- const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xStream,
- sal_Bool bDelete );
-
- ~OPostponedTruncationFileStream();
-
-// com::sun::star::io::XStream
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) throw (::com::sun::star::uno::RuntimeException);
-
-// com::sun::star::io::XInputStream
- virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
-// com::sun::star::io::XOutputStream
- virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL flush( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL closeOutput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
-// com::sun::star::io::XTruncate
- virtual void SAL_CALL truncate( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
-// com::sun::star::io::XSeekable
- virtual void SAL_CALL seek( ::sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
- virtual ::sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
-// ::com::sun::star::io::XAsyncOutputMonitor
- virtual void SAL_CALL waitForCompletion( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
-
-};
-
-#endif //_SFX_OPOSTPONEDTRUNCATIONFILESTREAM_HXX
-
-
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 3a0ce9b044..fee1e4df3c 100755
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -266,17 +266,23 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SfxPrintHelper::getPrinter() thro
// object already disposed?
::vos::OGuard aGuard( Application::GetSolarMutex() );
- // Printer beschaffen
- SfxViewFrame *pViewFrm = m_pData->m_pObjectShell.Is() ?
- SfxViewFrame::GetFirst( m_pData->m_pObjectShell, 0, sal_False ) : 0;
- if ( !pViewFrm )
- return uno::Sequence< beans::PropertyValue >();
-
- const SfxPrinter *pPrinter = pViewFrm->GetViewShell()->GetPrinter(sal_True);
+ // search for any view of this document that is currently printing
+ const Printer *pPrinter = NULL;
+ SfxViewFrame *pViewFrm = m_pData->m_pObjectShell.Is() ? SfxViewFrame::GetFirst( m_pData->m_pObjectShell, sal_False ) : 0;
+ SfxViewFrame* pFirst = pViewFrm;
+ while ( pViewFrm && !pPrinter )
+ {
+ pPrinter = pViewFrm->GetViewShell()->GetActivePrinter();
+ pViewFrm = SfxViewFrame::GetNext( *pViewFrm, m_pData->m_pObjectShell, sal_False );
+ }
+
+ // if no view is printing currently, use the permanent SfxPrinter instance
+ if ( !pPrinter && pFirst )
+ pPrinter = pFirst->GetViewShell()->GetPrinter(sal_True);
+
if ( !pPrinter )
return uno::Sequence< beans::PropertyValue >();
- // Printer Eigenschaften uebertragen
uno::Sequence< beans::PropertyValue > aPrinter(8);
aPrinter.getArray()[7].Name = DEFINE_CONST_UNICODE( "CanSetPaperSize" );
@@ -319,7 +325,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 +588,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 a502931ffd..7a5f630659 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 cd45e2b042..6f9545e244 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(