summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-06-07 14:49:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-06-07 19:08:20 +0200
commit0129c2cd9dd95355412b194c595f4b986403ba1e (patch)
tree4c1b775057070f224ec7b1f5af5fb3089536c3d7 /oox
parent57bdb06703ecf233d12304d4e71e1f40d29da327 (diff)
Related: tdf#108269 DOCM filter: reuse oox code for VBA data preservation
Which means the DOCM-specific code to roundtrip VBA things (project, data) can be removed. The oox part has to be extended a bit, as at least for this DOCM bugdoc there is an XML relation of the binary data, while existing shared code assumed the full VBA project is just a single OLE blob. Change-Id: I4085e4dba24475e6fd555e5f34fe7ad0f305c57d Reviewed-on: https://gerrit.libreoffice.org/38504 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/filterdetect.cxx9
-rw-r--r--oox/source/ole/vbaproject.cxx14
2 files changed, 15 insertions, 8 deletions
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index ed94ca5a5770..991b3d86a585 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -163,14 +163,7 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType, const OUString& rFileName )
{
- bool bDocm = false;
- OUString aDocmExtension = ".docm";
- if (rFileName.getLength() >= aDocmExtension.getLength())
- {
- OUString aExtension = rFileName.copy(rFileName.getLength() - aDocmExtension.getLength());
- // The file name ends with .docm, ignoring case.
- bDocm = aExtension.equalsIgnoreAsciiCase(aDocmExtension);
- }
+ bool bDocm = rFileName.endsWithIgnoreAsciiCase(".docm");
if( rContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" && !bDocm )
return OUString( "writer_MS_Word_2007" );
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index e915ba78ea10..c38adc9c3777 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -32,6 +32,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <comphelper/configurationhelper.hxx>
#include <comphelper/string.hxx>
+#include <comphelper/storagehelper.hxx>
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <rtl/ustrbuf.h>
@@ -49,6 +50,7 @@
namespace oox {
namespace ole {
+using namespace ::com::sun::star;
using namespace ::com::sun::star::container;
using namespace ::com::sun::star::document;
using namespace ::com::sun::star::embed;
@@ -182,6 +184,18 @@ void VbaProject::importVbaProject( StorageBase& rVbaPrjStrg, const GraphicHelper
}
}
+void VbaProject::importVbaData(const uno::Reference<io::XInputStream>& xInputStream)
+{
+ uno::Reference<document::XStorageBasedDocument> xStorageBasedDoc(mxDocModel, uno::UNO_QUERY);
+ uno::Reference<embed::XStorage> xDocStorage(xStorageBasedDoc->getDocumentStorage(), uno::UNO_QUERY);
+ {
+ const sal_Int32 nOpenMode = ElementModes::SEEKABLE | ElementModes::WRITE | ElementModes::TRUNCATE;
+ uno::Reference<io::XOutputStream> xDocStream(xDocStorage->openStreamElement("_MS_VBA_Macros_XML", nOpenMode), uno::UNO_QUERY);
+ comphelper::OStorageHelper::CopyInputToOutput(xInputStream, xDocStream);
+ }
+ uno::Reference<embed::XTransactedObject>(xDocStorage, uno::UNO_QUERY)->commit();
+}
+
void VbaProject::registerMacroAttacher( const VbaMacroAttacherRef& rxAttacher )
{
OSL_ENSURE( rxAttacher.get(), "VbaProject::registerMacroAttacher - unexpected empty reference" );