summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2019-12-28 17:57:44 +0100
committerJulien Nabet <serval2412@yahoo.fr>2019-12-28 17:58:05 +0100
commit0f01ea20251c397b0acc1690baa2dc543d1fd91a (patch)
tree84ae069bf46726aa7fde957cac5b6115e50cfdfa
parent8930a7d8b8e649336300d98f0a1f27114ad392ea (diff)
Revert "tdf#46037: remove configurationhelper in oox/vbaproject"
This reverts commit 276a90c6b3fb046df13ae85dcdec5f28f23ee527. Reason for revert: as requested here https://gerrit.libreoffice.org/c/core/+/85759 Change-Id: Ib6a1cedf758deadff4e8949e8ecf35d25565dcc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85927 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--include/oox/ole/vbaproject.hxx2
-rw-r--r--oox/Library_oox.mk5
-rw-r--r--oox/source/ole/vbaproject.cxx42
3 files changed, 38 insertions, 11 deletions
diff --git a/include/oox/ole/vbaproject.hxx b/include/oox/ole/vbaproject.hxx
index d158819a06ef..e72c356f1864 100644
--- a/include/oox/ole/vbaproject.hxx
+++ b/include/oox/ole/vbaproject.hxx
@@ -66,7 +66,7 @@ public:
bool isExportVba() const;
private:
- css::uno::Reference< css::uno::XComponentContext >
+ css::uno::Reference< css::uno::XInterface >
mxConfigAccess;
};
diff --git a/oox/Library_oox.mk b/oox/Library_oox.mk
index 543907996687..cc235b87e360 100644
--- a/oox/Library_oox.mk
+++ b/oox/Library_oox.mk
@@ -11,10 +11,7 @@ $(eval $(call gb_Library_Library,oox))
$(eval $(call gb_Library_set_precompiled_header,oox,oox/inc/pch/precompiled_oox))
-$(eval $(call gb_Library_use_custom_headers,oox,\
- oox/generated \
- officecfg/registry \
-))
+$(eval $(call gb_Library_use_custom_headers,oox,oox/generated))
$(eval $(call gb_Library_set_include,oox,\
$$(INCLUDE) \
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index afc787cba19d..bf31f2a2350f 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -30,13 +30,13 @@
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <com/sun/star/script/vba/XVBAMacroResolver.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/configurationhelper.hxx>
#include <comphelper/documentinfo.hxx>
#include <comphelper/storagehelper.hxx>
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <rtl/ustrbuf.h>
#include <sal/log.hxx>
-#include <officecfg/Office/Calc.hxx>
#include <oox/helper/binaryinputstream.hxx>
#include <oox/helper/containerhelper.hxx>
#include <oox/helper/propertyset.hxx>
@@ -62,9 +62,39 @@ using namespace ::com::sun::star::script;
using namespace ::com::sun::star::script::vba;
using namespace ::com::sun::star::uno;
-VbaFilterConfig::VbaFilterConfig( const Reference< XComponentContext >& rxContext, const OUString& /* rConfigCompName */)
- : mxConfigAccess(rxContext)
+using ::comphelper::ConfigurationHelper;
+
+namespace {
+
+bool lclReadConfigItem( const Reference< XInterface >& rxConfigAccess, const OUString& rItemName )
{
+ // some applications do not support all configuration items, assume 'false' in this case
+ try
+ {
+ Any aItem = ConfigurationHelper::readRelativeKey( rxConfigAccess, "Filter/Import/VBA", rItemName );
+ return aItem.has< bool >() && aItem.get< bool >();
+ }
+ catch(const Exception& )
+ {
+ }
+ return false;
+}
+
+} // namespace
+
+VbaFilterConfig::VbaFilterConfig( const Reference< XComponentContext >& rxContext, const OUString& rConfigCompName )
+{
+ OSL_ENSURE( rxContext.is(), "VbaFilterConfig::VbaFilterConfig - missing component context" );
+ if( rxContext.is() ) try
+ {
+ OSL_ENSURE( !rConfigCompName.isEmpty(), "VbaFilterConfig::VbaFilterConfig - invalid configuration component name" );
+ OUString aConfigPackage = "org.openoffice.Office." + rConfigCompName;
+ mxConfigAccess = ConfigurationHelper::openConfig( rxContext, aConfigPackage, comphelper::EConfigurationModes::ReadOnly );
+ }
+ catch(const Exception& )
+ {
+ }
+ OSL_ENSURE( mxConfigAccess.is(), "VbaFilterConfig::VbaFilterConfig - cannot open configuration" );
}
VbaFilterConfig::~VbaFilterConfig()
@@ -73,17 +103,17 @@ VbaFilterConfig::~VbaFilterConfig()
bool VbaFilterConfig::isImportVba() const
{
- return officecfg::Office::Calc::Filter::Import::VBA::Load::get(mxConfigAccess);
+ return lclReadConfigItem( mxConfigAccess, "Load" );
}
bool VbaFilterConfig::isImportVbaExecutable() const
{
- return officecfg::Office::Calc::Filter::Import::VBA::Executable::get(mxConfigAccess);
+ return lclReadConfigItem( mxConfigAccess, "Executable" );
}
bool VbaFilterConfig::isExportVba() const
{
- return officecfg::Office::Calc::Filter::Import::VBA::Save::get(mxConfigAccess);
+ return lclReadConfigItem( mxConfigAccess, "Save" );
}
VbaMacroAttacherBase::VbaMacroAttacherBase( const OUString& rMacroName ) :