summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-13 10:51:50 +0100
committerNoel Power <noel.power@novell.com>2010-10-13 10:51:50 +0100
commit606a57481911e111dfab950cd7fb90ae80aed014 (patch)
tree62e85311b32105e6d4e165d60c9d4bbdb80c03bc /sfx2
parenta4d7dbf897e41a1afda6c2b6f0e5cc35920a1cf3 (diff)
parented49568618442960781b63c3a47ddc65031b2fa0 (diff)
Merge branch 'vba' fix conflics, trailing ws & tab issues
also removed some old headers ( which I need to add new ones for ) Conflicts: basic/source/classes/sbunoobj.cxx basic/source/classes/sbxmod.cxx xmloff/inc/xmlnmspe.hxx xmloff/inc/xmloff/xmltoken.hxx xmlscript/inc/xmlscript/xmldlg_imexp.hxx
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/objsh.hxx7
-rwxr-xr-xsfx2/inc/sfx2/sfx.hrc10
-rw-r--r--sfx2/inc/sfx2/sfxbasemodel.hxx1
-rw-r--r--sfx2/inc/sfx2/sfxsids.hrc1
-rw-r--r--sfx2/source/appl/app.cxx2
-rw-r--r--sfx2/source/appl/appuno.cxx20
-rw-r--r--sfx2/source/control/unoctitm.cxx13
-rw-r--r--sfx2/source/doc/SfxDocumentMetaData.cxx86
-rw-r--r--sfx2/source/doc/docinf.cxx24
-rw-r--r--sfx2/source/doc/docmacromode.cxx58
-rw-r--r--sfx2/source/doc/objmisc.cxx27
-rw-r--r--sfx2/source/doc/objuno.cxx47
-rw-r--r--sfx2/source/doc/objxtor.cxx50
-rw-r--r--sfx2/source/doc/oleprops.hxx4
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx36
-rw-r--r--sfx2/source/inc/SfxDocumentMetaData.hxx11
-rw-r--r--sfx2/source/view/viewprn.cxx8
17 files changed, 348 insertions, 57 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx
index da9c46ff45..d1683998d7 100644
--- a/sfx2/inc/sfx2/objsh.hxx
+++ b/sfx2/inc/sfx2/objsh.hxx
@@ -414,8 +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 );
static ErrCode CallXScript(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxScriptContext,
@@ -424,7 +424,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 87cc2b6881..e6a900ed34 100755
--- a/sfx2/inc/sfx2/sfx.hrc
+++ b/sfx2/inc/sfx2/sfx.hrc
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -268,7 +268,7 @@
#define STR_ERRUNOEVENTBINDUNG (RID_SFX_START+119)
#define STR_SHARED (RID_SFX_START+120)
#define RID_XMLSEC_DOCUMENTSIGNED (RID_SFX_START+121)
-
+
//=========================================================================
// group ids
@@ -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 52fe2c14bf..8fe1468f20 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 695a47671a..ae27983663 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 5cb5ab2995..27cfa2015e 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -741,7 +741,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 f38aabd327..1d3994015e 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -2291,6 +2291,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;
}
@@ -2350,6 +2360,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 14b3fe06e9..0a51e21b1c 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 95fe000709..0b79440644 100644
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -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 15f231795e..94e92ee08d 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 613d90cb17..e542377c47 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -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 cdb13902c3..dce679dd85 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -462,7 +462,7 @@ void SfxObjectShell::SetReadOnlyUI( sal_Bool bReadOnly )
void SfxObjectShell::SetReadOnly()
{
- // Let the document be completely readonly, means that the
+ // Let the document be completely readonly, means that the
// medium open mode is adjusted accordingly, and the write lock
// on the file is removed.
@@ -471,13 +471,13 @@ void SfxObjectShell::SetReadOnly()
sal_Bool bWasROUI = IsReadOnly();
pMedium->UnlockFile( sal_False );
-
+
// the storage-based mediums are already based on the temporary file
// so UnlockFile has already closed the locking stream
if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() )
pMedium->CloseInStream();
- pMedium->SetOpenMode( SFX_STREAM_READONLY, pMedium->IsDirect(), sal_True );
+ pMedium->SetOpenMode( SFX_STREAM_READONLY, pMedium->IsDirect(), sal_True );
pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, sal_True ) );
if ( !bWasROUI )
@@ -1700,7 +1700,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;
@@ -1731,7 +1731,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& )
@@ -1764,10 +1773,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 ac45ef594d..aae9062e78 100644
--- a/sfx2/source/doc/objuno.cxx
+++ b/sfx2/source/doc/objuno.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -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>
@@ -96,7 +97,7 @@ using namespace ::com::sun::star;
#define PROPERTY_UNBOUND 0
#define PROPERTY_MAYBEVOID ::com::sun::star::beans::PropertyAttribute::MAYBEVOID
-const SfxItemPropertyMapEntry* lcl_GetDocInfoPropertyMap()
+const SfxItemPropertyMapEntry* lcl_GetDocInfoPropertyMap()
{
static SfxItemPropertyMapEntry aDocInfoPropertyMap_Impl[] =
{
@@ -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 },
@@ -262,7 +266,7 @@ MixedPropertySetInfo::~MixedPropertySetInfo()
::comphelper::SequenceAsVector< ::com::sun::star::beans::Property > lProps;
// copy "fix" props
- //todo: os: this ugly thing should be replaced
+ //todo: os: this ugly thing should be replaced
const SfxItemPropertyMapEntry* pFixProp = lcl_GetDocInfoPropertyMap();
while(pFixProp && pFixProp->pName)
@@ -303,7 +307,7 @@ MixedPropertySetInfo::~MixedPropertySetInfo()
//-----------------------------------------------------------------------------
-::com::sun::star::beans::Property SAL_CALL MixedPropertySetInfo::getPropertyByName(
+::com::sun::star::beans::Property SAL_CALL MixedPropertySetInfo::getPropertyByName(
const ::rtl::OUString& sName )
throw(::com::sun::star::beans::UnknownPropertyException,
::com::sun::star::uno::RuntimeException )
@@ -324,7 +328,7 @@ MixedPropertySetInfo::~MixedPropertySetInfo()
throw(::com::sun::star::uno::RuntimeException)
{
return _aPropertyMap.hasPropertyByName( sName ) ? // "fix" prop?
- sal_True :
+ sal_True :
_xUDProps->getPropertySetInfo()->hasPropertyByName(sName); // "dynamic" prop?
}
@@ -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 017b5873e5..d850fc03c7 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -124,6 +124,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 )
+ {
+ }
+ }
+ }
+}
+
//=========================================================================
@@ -158,6 +192,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 >() );
}
@@ -910,7 +945,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";
@@ -1100,7 +1138,7 @@ bool SfxObjectShell::IsChangeRecording() const
return false;
}
-
+
bool SfxObjectShell::HasChangeRecordProtection() const
{
// currently this function needs to be overwritten by Writer and Calc only
@@ -1108,20 +1146,20 @@ bool SfxObjectShell::HasChangeRecordProtection() const
return false;
}
-
+
void SfxObjectShell::SetChangeRecording( bool /*bActivate*/ )
{
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
}
-
+
bool SfxObjectShell::SetProtectionPassword( const String & /*rPassword*/ )
{
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
return false;
-}
+}
bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > & /*rPasswordHash*/ )
@@ -1129,5 +1167,5 @@ bool SfxObjectShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence<
// currently this function needs to be overwritten by Writer and Calc only
DBG_ASSERT( 0, "function not implemented" );
return false;
-}
+}
diff --git a/sfx2/source/doc/oleprops.hxx b/sfx2/source/doc/oleprops.hxx
index 0fddd50de0..c277ec5534 100644
--- 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 24a68de511..15814bee6e 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* 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
@@ -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()
@@ -2756,7 +2764,7 @@ void SfxBaseModel::impl_store( const ::rtl::OUString& sURL
m_pData->m_pObjectShell->SetModifyPasswordHash( nModifyPasswordHash );
uno::Sequence< beans::PropertyValue > aOldModifyPasswordInfo = m_pData->m_pObjectShell->GetModifyPasswordInfo();
m_pData->m_pObjectShell->SetModifyPasswordInfo( aModifyPasswordInfo );
-
+
// since saving a document modifies its DocumentInfo, the current
// DocumentInfo must be saved on "SaveTo", so it can be restored
// after saving
@@ -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 871ed19d5e..61143399a5 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 6780561600..ad5a07b6b7 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 ) );
+ }
}
}
}