summaryrefslogtreecommitdiff
path: root/vbahelper/source
diff options
context:
space:
mode:
Diffstat (limited to 'vbahelper/source')
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx13
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx13
-rw-r--r--vbahelper/source/vbahelper/vbadocumentsbase.cxx61
3 files changed, 66 insertions, 21 deletions
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index bddd756f6836..54d280094f2c 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -50,6 +50,7 @@
#include <basic/sbuno.hxx>
#include <basic/sbmeth.hxx>
#include <basic/sbmod.hxx>
+#include <basic/vbahelper.hxx>
#include "vbacommandbars.hxx"
@@ -200,10 +201,8 @@ void SAL_CALL
VbaApplicationBase::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
- if (bUpdate)
- xModel->unlockControllers();
- else
- xModel->lockControllers();
+ // #163808# use helper from module "basic" to lock all documents of this application
+ ::basic::vba::lockControllersOfAllDocuments( xModel, !bUpdate );
}
sal_Bool SAL_CALL
@@ -262,10 +261,8 @@ void SAL_CALL VbaApplicationBase::setInteractive( ::sal_Bool bInteractive )
throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
- uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
- uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
-
- xWindow->setEnable( bInteractive );
+ // #163808# use helper from module "basic" to enable/disable all container windows of all documents of this application
+ ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, bInteractive );
}
sal_Bool SAL_CALL VbaApplicationBase::getVisible() throw (uno::RuntimeException)
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 0df38b003556..087e7188c8f6 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -86,11 +86,14 @@ VbaDocumentBase::getName() throw (uno::RuntimeException)
::rtl::OUString
VbaDocumentBase::getPath() throw (uno::RuntimeException)
{
- INetURLObject aURL( getModel()->getURL() );
- rtl::OUString sURL( aURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
- sURL = sURL.copy( 0, sURL.getLength() - aURL.GetLastName().getLength() - 1 );
- rtl::OUString sPath;
- ::osl::File::getSystemPathFromFileURL( sURL, sPath );
+ INetURLObject aURL( getModel()->getURL() );
+ rtl::OUString sURL = aURL.GetMainURL( INetURLObject::DECODE_TO_IURI );
+ rtl::OUString sPath;
+ if( sURL.getLength() > 0 )
+ {
+ sURL = sURL.copy( 0, sURL.getLength() - aURL.GetLastName().getLength() - 1 );
+ ::osl::File::getSystemPathFromFileURL( sURL, sPath );
+ }
return sPath;
}
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index f2b70ab231c7..b65a58542b92 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -24,7 +24,9 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-#include <vbahelper/vbadocumentsbase.hxx>
+
+#include "vbahelper/vbadocumentsbase.hxx"
+
#include <comphelper/mediadescriptor.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/implbase1.hxx>
@@ -49,10 +51,12 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <sfx2/objsh.hxx>
#include <tools/urlobj.hxx>
-#include <vbahelper/vbahelper.hxx>
#include <hash_map>
#include <osl/file.hxx>
+#include "vbahelper/vbahelper.hxx"
+#include "vbahelper/vbaapplicationbase.hxx"
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -213,8 +217,39 @@ VbaDocumentsBase::VbaDocumentsBase( const uno::Reference< XHelperInterface >& xP
{
}
+namespace {
+
+void lclSetupComponent( const uno::Reference< lang::XComponent >& rxComponent, sal_Bool bScreenUpdating, sal_Bool bInteractive )
+{
+ if( !bScreenUpdating ) try
+ {
+ uno::Reference< frame::XModel >( rxComponent, uno::UNO_QUERY_THROW )->lockControllers();
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ if( !bInteractive ) try
+ {
+ uno::Reference< frame::XModel > xModel( rxComponent, uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow >( xFrame->getContainerWindow(), uno::UNO_SET_THROW )->setEnable( sal_False );
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+} // namespace
+
uno::Any VbaDocumentsBase::createDocument() throw (uno::RuntimeException)
{
+ // #163808# determine state of Application.ScreenUpdating and Application.Interactive symbols (before new document is opened)
+ uno::Reference< XApplicationBase > xApplication( Application(), uno::UNO_QUERY );
+ sal_Bool bScreenUpdating = !xApplication.is() || xApplication->getScreenUpdating();
+ sal_Bool bInteractive = !xApplication.is() || xApplication->getInteractive();
+
uno::Reference< lang::XMultiComponentFactory > xSMgr(
mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
@@ -240,6 +275,10 @@ uno::Any VbaDocumentsBase::createDocument() throw (uno::RuntimeException)
sURL ,
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0,
aMediaDesc.getAsConstPropertyValueList() );
+
+ // #163808# lock document controllers and container window if specified by application
+ lclSetupComponent( xComponent, bScreenUpdating, bInteractive );
+
return uno::makeAny( xComponent );
}
@@ -259,6 +298,11 @@ void VbaDocumentsBase::closeDocuments() throw (uno::RuntimeException)
// #TODO# #FIXME# can any of the unused params below be used?
uno::Any VbaDocumentsBase::openDocument( const rtl::OUString& rFileName, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (uno::RuntimeException)
{
+ // #163808# determine state of Application.ScreenUpdating and Application.Interactive symbols (before new document is opened)
+ uno::Reference< XApplicationBase > xApplication( Application(), uno::UNO_QUERY );
+ sal_Bool bScreenUpdating = !xApplication.is() || xApplication->getScreenUpdating();
+ sal_Bool bInteractive = !xApplication.is() || xApplication->getInteractive();
+
// we need to detect if this is a URL, if not then assume its a file path
rtl::OUString aURL;
INetURLObject aObj;
@@ -282,19 +326,16 @@ uno::Any VbaDocumentsBase::openDocument( const rtl::OUString& rFileName, const u
uno::Sequence< beans::PropertyValue > sProps( rProps );
sProps.realloc( sProps.getLength() + 1 );
sProps[ sProps.getLength() - 1 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode") );
- sProps[ sProps.getLength() - 1 ].Value <<= uno::makeAny( document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN );
-
- sal_Int32 nIndex = sProps.getLength() - 1;
+ sProps[ sProps.getLength() - 1 ].Value <<= document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
if ( ReadOnly.hasValue() )
{
sal_Bool bIsReadOnly = sal_False; ReadOnly >>= bIsReadOnly;
if ( bIsReadOnly )
{
- static const rtl::OUString sReadOnly( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
sProps.realloc( sProps.getLength() + 1 );
- sProps[ nIndex ].Name = sReadOnly;
- sProps[ nIndex++ ].Value = uno::makeAny( (sal_Bool)sal_True );
+ sProps[ sProps.getLength() - 1 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
+ sProps[ sProps.getLength() - 1 ].Value <<= true;
}
}
@@ -302,6 +343,10 @@ uno::Any VbaDocumentsBase::openDocument( const rtl::OUString& rFileName, const u
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_default") ),
frame::FrameSearchFlag::CREATE,
sProps);
+
+ // #163808# lock document controllers and container window if specified by application
+ lclSetupComponent( xComponent, bScreenUpdating, bInteractive );
+
return uno::makeAny( xComponent );
}