[Libreoffice-commits] core.git: include/oox oox/Library_oox.mk oox/source

Julien Nabet (via logerrit) logerrit at kemper.freedesktop.org
Sat Dec 28 16:58:40 UTC 2019


 include/oox/ole/vbaproject.hxx |    2 -
 oox/Library_oox.mk             |    5 ----
 oox/source/ole/vbaproject.cxx  |   42 +++++++++++++++++++++++++++++++++++------
 3 files changed, 38 insertions(+), 11 deletions(-)

New commits:
commit 0f01ea20251c397b0acc1690baa2dc543d1fd91a
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sat Dec 28 17:57:44 2019 +0100
Commit:     Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Sat Dec 28 17:58:05 2019 +0100

    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 at yahoo.fr>
    Tested-by: Julien Nabet <serval2412 at yahoo.fr>

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 ) :


More information about the Libreoffice-commits mailing list