diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/objsh.hxx | 7 | ||||
-rwxr-xr-x | sfx2/inc/sfx2/sfx.hrc | 6 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxbasemodel.hxx | 1 | ||||
-rw-r--r-- | sfx2/inc/sfx2/sfxsids.hrc | 1 | ||||
-rw-r--r-- | sfx2/source/appl/app.cxx | 2 | ||||
-rwxr-xr-x | sfx2/source/appl/appuno.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 84 | ||||
-rw-r--r-- | sfx2/source/doc/docinf.cxx | 24 | ||||
-rw-r--r-- | sfx2/source/doc/docmacromode.cxx | 56 | ||||
-rwxr-xr-x | sfx2/source/doc/objmisc.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/doc/objuno.cxx | 37 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 38 | ||||
-rwxr-xr-x | sfx2/source/doc/oleprops.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 32 | ||||
-rw-r--r-- | sfx2/source/inc/SfxDocumentMetaData.hxx | 11 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 8 |
17 files changed, 327 insertions, 36 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 9473ac126bd7..8d3639e00e6a 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -404,8 +404,8 @@ public: ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam, - bool bRaiseError = true - ); + bool bRaiseError = true, + const ::com::sun::star::uno::Any* aCaller = 0 ); static ErrCode CallXScript( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxScriptContext, @@ -414,7 +414,8 @@ public: ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam, - bool bRaiseError = true + bool bRaiseError = true, + const ::com::sun::star::uno::Any* aCaller = 0 ); /** adjusts the internal macro mode, according to the current security settings diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index 5daac0b91ae2..9dc9ac94e354 100755 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -399,8 +399,10 @@ #define MID_DOCINFO_ENCRYPTED 0x2c #define MID_DOCINFO_STATISTIC 0x33 #define MID_DOCINFO_CHARLOCALE 0x34 - -#define MID_LAST_USED_PROPID MID_DOCINFO_CHARLOCALE +#define MID_CATEGORY 0x35 +#define MID_COMPANY 0x36 +#define MID_MANAGER 0x37 +#define MID_LAST_USED_PROPID MID_MANAGER // Config-Ids ----------------------------------------------------------- diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index 578dd1fd33bb..5039f2deb3f4 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -1505,6 +1505,7 @@ protected: /* returns true if the document signatures are valid, otherwise false */ sal_Bool hasValidSignatures() const; + void setDocumentProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties >& ); //________________________________________________________________________________________________________ // private methods //________________________________________________________________________________________________________ diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 901717c63169..43a4b021efa5 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -75,6 +75,7 @@ #define SID_VERSION_VISIBLE (SID_SFX_START + 313) #define SID_PASTE_UNFORMATTED (SID_SFX_START + 314) +#define SID_DIALOG_RETURN (SID_SFX_START + 318) #define SID_PRINTER_NOTFOUND_WARN (SID_SFX_START + 320) #define SID_PRINTER_USETHREAD (SID_SFX_START + 321) #define SID_PRINTER_NAME (SID_SFX_START + 322) diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 6e13894feb49..2a1f66bca3b9 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -749,7 +749,7 @@ IMPL_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBasic ) basicide_handle_basic_error pSymbol = (basicide_handle_basic_error) osl_getFunctionSymbol( handleMod, aSymbol.pData ); // call basicide_handle_basic_error in basctl - long nRet = pSymbol( pStarBasic ); + long nRet = pSymbol ? pSymbol( pStarBasic ) : 0; return nRet; } diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index 6f9d3b258745..67f20835b16d 100755 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -2281,6 +2281,16 @@ SFX2_DLLPUBLIC sal_Bool SAL_CALL component_writeInfo( xNewKey = xKey->createKey( aTempStr ); xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.document.DocumentProperties") ); + + // writer compatable document properties + aImpl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); + aImpl += comp_CompatWriterDocProps::_getImplementationName(); + + aTempStr = aImpl; + aTempStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); + xNewKey = xKey->createKey( aTempStr ); + xNewKey->createKey( ::rtl::OUString::createFromAscii("com.sun.star.writer.DocumentProperties") ); + return sal_True; } @@ -2340,6 +2350,16 @@ SFX2_DLLPUBLIC void* SAL_CALL component_getFactory( ::comp_SfxDocumentMetaData::_getImplementationName(), ::comp_SfxDocumentMetaData::_getSupportedServiceNames()); } + if ( ::comp_CompatWriterDocProps::_getImplementationName().equals( + ::rtl::OUString::createFromAscii( pImplementationName ) ) ) + { + xFactory = ::cppu::createSingleComponentFactory( + ::comp_CompatWriterDocProps::_create, + ::comp_CompatWriterDocProps::_getImplementationName(), + ::comp_CompatWriterDocProps::_getSupportedServiceNames()); + } + + // Factory is valid - service was found. // Factory is valid - service was found. if ( xFactory.is() ) diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index e53f1766b7b9..6b4dac5cdb18 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -702,6 +702,7 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util // Filter arguments which shouldn't be part of the sequence property value sal_Bool bTemp = sal_Bool(); sal_uInt16 nModifier(0); + sal_Bool bVBARequest = sal_False; std::vector< ::com::sun::star::beans::PropertyValue > aAddArgs; for( sal_Int32 n=0; n<nCount; n++ ) { @@ -718,6 +719,10 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util } else if( rProp.Name.equalsAsciiL("KeyModifier",11)) rProp.Value >>= nModifier; + else if( rProp.Name.equalsAsciiL("VBADialogResultRequest",22) ) + { + rProp.Value >>= bVBARequest; + } else aAddArgs.push_back( aArgs[n] ); } @@ -801,6 +806,14 @@ void SAL_CALL SfxDispatchController_Impl::dispatch( const ::com::sun::star::util pItem = aReq.GetReturnValue(); bSuccess = aReq.IsDone() || pItem != NULL; bFailure = aReq.IsCancelled(); + if ( bVBARequest ) + { + SFX_REQUEST_ARG( aReq, pItem, SfxBoolItem, SID_DIALOG_RETURN, FALSE ); + if ( pItem ) + { + bSuccess = pItem->GetValue(); + } + } } } #ifdef DBG_UTIL diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 14474dd2904d..0b7944064482 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -87,6 +87,10 @@ #include <cstring> #include <limits> + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/document/XCompatWriterDocProperties.hpp> + /** * This file contains the implementation of the service * com.sun.star.document.DocumentProperties. @@ -292,12 +296,12 @@ public: const css::uno::Sequence< css::beans::StringPair >& i_rNamespaces) throw (css::uno::RuntimeException, css::xml::sax::SAXException); -private: +protected: SfxDocumentMetaData(SfxDocumentMetaData &); // not defined SfxDocumentMetaData& operator =(SfxDocumentMetaData &); // not defined virtual ~SfxDocumentMetaData() {} - + virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new SfxDocumentMetaData( context ); }; const css::uno::Reference< css::uno::XComponentContext > m_xContext; /// for notification @@ -372,6 +376,54 @@ private: void createUserDefined(); }; +typedef ::cppu::ImplInheritanceHelper1< SfxDocumentMetaData, css::document::XCompatWriterDocProperties > CompatWriterDocPropsImpl_BASE; + +class CompatWriterDocPropsImpl : public CompatWriterDocPropsImpl_BASE +{ + rtl::OUString msManager; + rtl::OUString msCategory; + rtl::OUString msCompany; +protected: + virtual SfxDocumentMetaData* createMe( css::uno::Reference< css::uno::XComponentContext > const & context ) { return new CompatWriterDocPropsImpl( context ); }; +public: + CompatWriterDocPropsImpl( css::uno::Reference< css::uno::XComponentContext > const & context) : CompatWriterDocPropsImpl_BASE( context ) {} +// XCompatWriterDocPropsImpl + virtual ::rtl::OUString SAL_CALL getManager() throw (::com::sun::star::uno::RuntimeException) { return msManager; } + virtual void SAL_CALL setManager( const ::rtl::OUString& _manager ) throw (::com::sun::star::uno::RuntimeException) { msManager = _manager; } + virtual ::rtl::OUString SAL_CALL getCategory() throw (::com::sun::star::uno::RuntimeException){ return msCategory; } + virtual void SAL_CALL setCategory( const ::rtl::OUString& _category ) throw (::com::sun::star::uno::RuntimeException){ msCategory = _category; } + virtual ::rtl::OUString SAL_CALL getCompany() throw (::com::sun::star::uno::RuntimeException){ return msCompany; } + virtual void SAL_CALL setCompany( const ::rtl::OUString& _company ) throw (::com::sun::star::uno::RuntimeException){ msCompany = _company; } + +// XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) + { + return comp_CompatWriterDocProps::_getImplementationName(); + } + + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException) + { + css::uno::Sequence< rtl::OUString > sServiceNames= getSupportedServiceNames(); + sal_Int32 nLen = sServiceNames.getLength(); + rtl::OUString* pIt = sServiceNames.getArray(); + rtl::OUString* pEnd = ( pIt + nLen ); + sal_Bool bRes = sal_False; + for ( ; pIt != pEnd; ++pIt ) + { + if ( pIt->equals( ServiceName ) ) + { + bRes = sal_True; + break; + } + } + return bRes; + } + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) + { + return comp_CompatWriterDocProps::_getSupportedServiceNames(); + } +}; //////////////////////////////////////////////////////////////////////////// bool operator== (const css::util::DateTime &i_rLeft, @@ -2156,7 +2208,7 @@ SfxDocumentMetaData::createClone() ::osl::MutexGuard g(m_aMutex); checkInit(); - SfxDocumentMetaData *pNew = new SfxDocumentMetaData(m_xContext); + SfxDocumentMetaData *pNew = createMe(m_xContext); // NB: do not copy the modification listeners, only DOM css::uno::Reference<css::xml::dom::XDocument> xDoc = createDOM(); @@ -2334,6 +2386,32 @@ void SfxDocumentMetaData::createUserDefined() // component helper namespace +namespace comp_CompatWriterDocProps { + + ::rtl::OUString SAL_CALL _getImplementationName() { + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "CompatWriterDocPropsImpl")); +} + + css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames() + { + static css::uno::Sequence< rtl::OUString > aServiceNames; + if ( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc( 1 ); + aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.writer.DocumentProperties" ) ); + } + return aServiceNames; + } + css::uno::Reference< css::uno::XInterface > SAL_CALL _create( + const css::uno::Reference< css::uno::XComponentContext > & context) + SAL_THROW((css::uno::Exception)) + { + return static_cast< ::cppu::OWeakObject * > + (new CompatWriterDocPropsImpl(context)); + } + +} namespace comp_SfxDocumentMetaData { ::rtl::OUString SAL_CALL _getImplementationName() { diff --git a/sfx2/source/doc/docinf.cxx b/sfx2/source/doc/docinf.cxx index d0f6678d8641..3c7db55d2e6a 100644 --- a/sfx2/source/doc/docinf.cxx +++ b/sfx2/source/doc/docinf.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyContainer.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/document/XCompatWriterDocProperties.hpp> #include <com/sun/star/uno/Exception.hpp> #include <rtl/ustring.hxx> @@ -43,7 +44,6 @@ #include <vcl/gdimtf.hxx> #include "oleprops.hxx" - // ============================================================================ // stream names @@ -172,6 +172,28 @@ sal_uInt32 SFX2_DLLPUBLIC LoadOlePropertySet( } } + uno::Reference< document::XCompatWriterDocProperties > xWriterProps( i_xDocProps, uno::UNO_QUERY ); + if ( xWriterProps.is() ) + { + SfxOleSectionRef xBuiltin = aDocSet.GetSection( SECTION_BUILTIN ); + if ( xBuiltin.get() ) + { + try + { + String aStrValue; + if ( xBuiltin->GetStringValue( aStrValue, PROPID_MANAGER ) ) + xWriterProps->setManager( aStrValue ); + if ( xBuiltin->GetStringValue( aStrValue, PROPID_CATEGORY ) ) + xWriterProps->setCategory( aStrValue ); + if ( xBuiltin->GetStringValue( aStrValue, PROPID_COMPANY ) ) + xWriterProps->setCompany( aStrValue ); + } + catch ( uno::Exception& ) + { + } + } + } + // return code return (nGlobError != ERRCODE_NONE) ? nGlobError : nDocError; } diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx index 249ebbaf02ab..e542377c477e 100644 --- a/sfx2/source/doc/docmacromode.cxx +++ b/sfx2/source/doc/docmacromode.cxx @@ -38,6 +38,8 @@ #include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp> #include <com/sun/star/task/InteractionClassification.hpp> #include <com/sun/star/security/XDocumentDigitalSignatures.hpp> +#include <com/sun/star/script/XLibraryQueryExecutable.hpp> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> /** === end UNO includes === **/ #include <comphelper/componentcontext.hxx> @@ -73,8 +75,11 @@ namespace sfx2 using ::com::sun::star::document::XEmbeddedScripts; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::script::XLibraryContainer; + using ::com::sun::star::script::XLibraryQueryExecutable; + using ::com::sun::star::script::vba::XVBACompatibility; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; /** === end UNO using === **/ namespace MacroExecMode = ::com::sun::star::document::MacroExecMode; @@ -336,6 +341,8 @@ namespace sfx2 if ( xScripts.is() ) xContainer.set( xScripts->getBasicLibraries(), UNO_QUERY_THROW ); + Reference< XVBACompatibility > xDocVBAMode( xContainer, UNO_QUERY ); + sal_Bool bIsVBAMode = ( xDocVBAMode.is() && xDocVBAMode->getVBACompatibilityMode() ); if ( xContainer.is() ) { // a library container exists; check if it's empty @@ -350,23 +357,46 @@ namespace sfx2 Sequence< ::rtl::OUString > aElements = xContainer->getElementNames(); if ( aElements.getLength() ) { - if ( aElements.getLength() > 1 || !aElements[0].equals( aStdLibName ) ) + // old check, if more than 1 library or the first library isn't the expected 'Standard' + // trigger the security 'nag' dialog + if ( !bIsVBAMode && ( aElements.getLength() > 1 || !aElements[0].equals( aStdLibName ) ) ) bHasMacroLib = sal_True; else { - // usually a "Standard" library is always present (design) - // for this reason we must check if it's empty - // - // Note: Since #i73229#, this is not true anymore. There's no default - // "Standard" lib anymore. Wouldn't it be time to get completely - // rid of the "Standard" thingie - this shouldn't be necessary - // anymore, should it? - // 2007-01-25 / frank.schoenheit@sun.com - Reference < XNameAccess > xLib; - Any aAny = xContainer->getByName( aStdLibName ); - aAny >>= xLib; + // other wise just check all libraries for executeable code + Reference< XLibraryQueryExecutable > xLib( xContainer, UNO_QUERY ); if ( xLib.is() ) - bHasMacroLib = xLib->hasElements(); + { + Sequence< ::rtl::OUString > aElements = xContainer->getElementNames(); + sal_Int32 nElementCount = aElements.getLength(); + const ::rtl::OUString* pElementName = aElements.getConstArray(); + for ( sal_Int32 index = 0; index < nElementCount; index++ ) + { + bHasMacroLib = xLib->HasExecutableCode( pElementName[index] ); + if ( bHasMacroLib ) + break; + } + } + } + } + } + } + if ( bIsVBAMode && !bHasMacroLib && xScripts.is() ) + { + Reference< XLibraryContainer > xDlgContainer( xScripts->getDialogLibraries(), UNO_QUERY ); + if ( xDlgContainer.is() && xDlgContainer->hasElements() ) + { + Sequence< ::rtl::OUString > aElements = xDlgContainer->getElementNames(); + sal_Int32 nElementCount = aElements.getLength(); + const ::rtl::OUString* pElementName = aElements.getConstArray(); + for ( sal_Int32 index = 0; index < nElementCount; index++ ) + { + Reference< XNameAccess > xNameAccess; + xDlgContainer->getByName( pElementName[index] ) >>= xNameAccess; + if ( xNameAccess.is() && xNameAccess->hasElements() ) + { + bHasMacroLib = sal_True; + break; } } } diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index e386b2382acf..8437c1426f5b 100755 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1710,7 +1710,7 @@ namespace } ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const ::rtl::OUString& _rScriptURL, - const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError ) + const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const ::com::sun::star::uno::Any* pCaller ) { OSL_TRACE( "in CallXScript" ); ErrCode nErr = ERRCODE_NONE; @@ -1741,7 +1741,16 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon // obtain the script, and execute it Reference< provider::XScript > xScript( xScriptProvider->getScript( _rScriptURL ), UNO_QUERY_THROW ); - + if ( pCaller && pCaller->hasValue() ) + { + Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); + if ( xProps.is() ) + { + Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] = *pCaller; + xProps->setPropertyValue( rtl::OUString::createFromAscii("Caller"), uno::makeAny( aArgs ) ); + } + } aRet = xScript->invoke( aParams, aOutParamIndex, aOutParam ); } catch ( const uno::Exception& ) @@ -1774,10 +1783,10 @@ ErrCode SfxObjectShell::CallXScript( const String& rScriptURL, aParams, ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam - , bool bRaiseError ) + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& + aOutParam, bool bRaiseError, const ::com::sun::star::uno::Any* pCaller ) { - return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError ); + return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError, pCaller ); } //------------------------------------------------------------------------- diff --git a/sfx2/source/doc/objuno.cxx b/sfx2/source/doc/objuno.cxx index 466f8dd43104..cb4f9f35fb77 100644 --- a/sfx2/source/doc/objuno.cxx +++ b/sfx2/source/doc/objuno.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/document/XCompatWriterDocProperties.hpp> #include <unotools/configmgr.hxx> #include <tools/inetdef.hxx> @@ -104,6 +105,9 @@ const SfxItemPropertyMapEntry* lcl_GetDocInfoPropertyMap() { "AutoloadEnabled" , 15, MID_DOCINFO_AUTOLOADENABLED, &::getBooleanCppuType(), PROPERTY_UNBOUND, 0 }, { "AutoloadSecs" , 12, MID_DOCINFO_AUTOLOADSECS, &::getCppuType((const sal_Int32*)0), PROPERTY_UNBOUND, 0 }, { "AutoloadURL" , 11, MID_DOCINFO_AUTOLOADURL, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, + { "Category" , 8 , MID_CATEGORY, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, + { "Company" , 7 , MID_COMPANY, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, + { "Manager" , 7 , MID_MANAGER, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, { "CreationDate" , 12, WID_DATE_CREATED, &::getCppuType((const ::com::sun::star::util::DateTime*)0),PROPERTY_MAYBEVOID, 0 }, { "DefaultTarget" , 13, MID_DOCINFO_DEFAULTTARGET, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, { "Description" , 11, MID_DOCINFO_DESCRIPTION, &::getCppuType((const ::rtl::OUString*)0), PROPERTY_UNBOUND, 0 }, @@ -807,6 +811,22 @@ void SAL_CALL SfxDocumentInfoObject::setFastPropertyValue(sal_Int32 nHandle, co _pImp->m_xDocProps->setDefaultTarget(sTemp); break; // case WID_CONTENT_TYPE : // this is readonly! + case MID_CATEGORY: + case MID_MANAGER: + case MID_COMPANY: + { + uno::Reference< document::XCompatWriterDocProperties > xWriterProps( _pImp->m_xDocProps, uno::UNO_QUERY ); + if ( xWriterProps.is() ) + { + if ( nHandle == MID_CATEGORY ) + xWriterProps->setCategory( sTemp ); + else if ( nHandle == MID_MANAGER ) + xWriterProps->setManager( sTemp ); + else + xWriterProps->setCompany( sTemp ); + break; + } + } default: break; } @@ -1024,6 +1044,23 @@ void SAL_CALL SfxDocumentInfoObject::setFastPropertyValue(sal_Int32 nHandle, co case MID_DOCINFO_CHARLOCALE: aValue <<= _pImp->m_xDocProps->getLanguage(); break; + case MID_CATEGORY: + case MID_MANAGER: + case MID_COMPANY: + { + uno::Reference< document::XCompatWriterDocProperties > xWriterProps( _pImp->m_xDocProps, uno::UNO_QUERY ); + if ( xWriterProps.is() ) + { + if ( nHandle == MID_CATEGORY ) + aValue <<= xWriterProps->getCategory(); + else if ( nHandle == MID_MANAGER ) + aValue <<= xWriterProps->getManager(); + else + aValue <<= xWriterProps->getCompany(); + break; + } + } + default: aValue <<= ::rtl::OUString(); break; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index b7567b89f02f..dc8be0c0e764 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -134,6 +134,40 @@ DBG_NAME(SfxObjectShell) static WeakReference< XInterface > s_xCurrentComponent; +void lcl_UpdateAppBasicDocVars( const Reference< XInterface >& _rxComponent, bool bClear = false ) +{ + BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); + if ( pAppMgr ) + { + uno::Reference< beans::XPropertySet > xProps( _rxComponent, uno::UNO_QUERY ); + if ( xProps.is() ) + { + try + { + // ThisVBADocObj contains a PropertyValue + // Name is ( the name of the VBA global to insert ) + // Value is the Object to insert. + // ( note: at the moment the Value is actually the model so + // it strictly is not necessary, however we do intend to store + // not the model in basic but a custom object, so we keep this + // level of indirection for future proofing ) + beans::PropertyValue aProp; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisVBADocObj") ) ) >>= aProp; + rtl::OString sTmp( rtl::OUStringToOString( aProp.Name, RTL_TEXTENCODING_UTF8 ) ); + const char* pAscii = sTmp.getStr(); + if ( bClear ) + pAppMgr->SetGlobalUNOConstant( pAscii, uno::makeAny( uno::Reference< uno::XInterface >() ) ); + else + pAppMgr->SetGlobalUNOConstant( pAscii, aProp.Value ); + + } + catch( uno::Exception& e ) + { + } + } + } +} + //========================================================================= @@ -168,6 +202,7 @@ void SAL_CALL SfxModelListener_Impl::disposing( const com::sun::star::lang::Even ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); if ( SfxObjectShell::GetCurrentComponent() == _rEvent.Source ) { + lcl_UpdateAppBasicDocVars( SfxObjectShell::GetCurrentComponent(), true ); // remove ThisComponent reference from AppBasic SfxObjectShell::SetCurrentComponent( Reference< XInterface >() ); } @@ -919,7 +954,10 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); s_xCurrentComponent = _rxComponent; if ( pAppMgr ) + { + lcl_UpdateAppBasicDocVars( _rxComponent ); pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) ); + } #if OSL_DEBUG_LEVEL > 0 const char* pComponentImplName = _rxComponent.get() ? typeid( *_rxComponent.get() ).name() : "void"; diff --git a/sfx2/source/doc/oleprops.hxx b/sfx2/source/doc/oleprops.hxx index 5bd586576ac8..b56aa6a563f9 100755 --- a/sfx2/source/doc/oleprops.hxx +++ b/sfx2/source/doc/oleprops.hxx @@ -80,6 +80,10 @@ const sal_Int32 PROPID_CREATED = 12; const sal_Int32 PROPID_LASTSAVED = 13; const sal_Int32 PROPID_THUMBNAIL = 17; +// some Builtin properties +const sal_Int32 PROPID_CATEGORY = 0x2; +const sal_Int32 PROPID_COMPANY = 0xf; +const sal_Int32 PROPID_MANAGER = 0xe; // predefined codepages const sal_uInt16 CODEPAGE_UNKNOWN = 0; const sal_uInt16 CODEPAGE_UNICODE = 1200; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index fe4ffa50f67d..8a0d81bc2fc5 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -883,7 +883,15 @@ uno::Reference< document::XDocumentInfo > SAL_CALL SfxBaseModel::getDocumentInfo return m_pData->m_xDocumentInfo; } - +void +SfxBaseModel::setDocumentProperties( const uno::Reference< document::XDocumentProperties >& rxNewDocProps ) +{ + // object already disposed? + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + if ( impl_isDisposed() ) + throw lang::DisposedException(); + m_pData->m_xDocumentProperties.set(rxNewDocProps, uno::UNO_QUERY_THROW); +} // document::XDocumentPropertiesSupplier: uno::Reference< document::XDocumentProperties > SAL_CALL SfxBaseModel::getDocumentProperties() @@ -3552,15 +3560,23 @@ void SAL_CALL SfxBaseModel::switchToStorage( const uno::Reference< XSTORAGE >& x throw IOEXCEPTION(); // TODO: // the persistence should be switched only if the storage is different - if ( xStorage != m_pData->m_pObjectShell->GetStorage() - && !m_pData->m_pObjectShell->SwitchPersistance( xStorage ) ) + if ( xStorage != m_pData->m_pObjectShell->GetStorage() ) { - sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode(); - throw task::ErrorCodeIOException( ::rtl::OUString(), - uno::Reference< uno::XInterface >(), - nError ? nError : ERRCODE_IO_GENERAL ); + if ( !m_pData->m_pObjectShell->SwitchPersistance( xStorage ) ) + { + sal_uInt32 nError = m_pData->m_pObjectShell->GetErrorCode(); + throw task::ErrorCodeIOException( ::rtl::OUString(), + uno::Reference< uno::XInterface >(), + nError ? nError : ERRCODE_IO_GENERAL ); + } + else + { + // UICfgMgr has a reference to the old storage, update it + uno::Reference< ui::XUIConfigurationStorage > xUICfgMgrStorage( getUIConfigurationManager(), uno::UNO_QUERY ); + if ( xUICfgMgrStorage.is() ) + xUICfgMgrStorage->setStorage( xStorage ); + } } - m_pData->m_pObjectShell->Get_Impl()->bOwnsStorage = FALSE; } diff --git a/sfx2/source/inc/SfxDocumentMetaData.hxx b/sfx2/source/inc/SfxDocumentMetaData.hxx index ec573cf007a7..a8e81bf42d28 100644 --- a/sfx2/source/inc/SfxDocumentMetaData.hxx +++ b/sfx2/source/inc/SfxDocumentMetaData.hxx @@ -45,5 +45,16 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL _create( } // closing component helper namespace +namespace comp_CompatWriterDocProps { + +namespace css = ::com::sun::star; + +// component and service helper functions: +::rtl::OUString SAL_CALL _getImplementationName(); +css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames(); +css::uno::Reference< css::uno::XInterface > SAL_CALL _create( + css::uno::Reference< css::uno::XComponentContext > const & context ); + +} #endif diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 4ed0173be8e1..10b8e0ada945 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -874,6 +874,10 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) aReq.AppendItem( SfxStringItem( SID_PRINTER_NAME, pDlgPrinter->GetName() ) ); aReq.Done(); } + if ( nId == SID_SETUPPRINTER ) + { + rReq.AppendItem( SfxBoolItem( SID_DIALOG_RETURN, TRUE ) ); + } // take the changes made in the dialog pPrinter = SetPrinter_Impl( pDlgPrinter ); @@ -894,6 +898,10 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) rReq.Ignore(); if ( SID_PRINTDOC == nId ) rReq.SetReturnValue(SfxBoolItem(0,FALSE)); + if ( nId == SID_SETUPPRINTER ) + { + rReq.AppendItem( SfxBoolItem( SID_DIALOG_RETURN, FALSE ) ); + } } } } |