From 9b40796fd3e8f724d69a343e0444220b69a6d6ab Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Wed, 23 Aug 2017 17:46:30 +0200 Subject: tdf#50097: DOCX: export form controls as MSO ActiveX controls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use the same structure for export what MSO uses ** Position and size information are exported as VML shape properties ** Different handling of inline and floating controls (pict or object) ** Do some changes on VML shape export to match how MSO exports these controls ** Write out activeX.xml and activeX.bin to store control properties ** Use persistStorage storage type defined in activeX.xml * Drop grabbaging of activex.XML and activeX.bin * Cleanup control related test code Signed-off-by: Tamás Zolnai Reviewed-on: https://gerrit.libreoffice.org/41256 Tested-by: Jenkins (cherry picked from commit c0cc02e2934aeb12dda44818955e5964496c186a) Change-Id: I38bb2b2ffd2676c5459b61ec2549c31348bab41c This test intended to be an export test Change-Id: Ib233bd603185efdb85ed30f3d00c28512d57a0ac Reviewed-on: https://gerrit.libreoffice.org/41355 Tested-by: Jenkins Reviewed-by: Tamás Zolnai (cherry picked from commit a7e8c5304b740cb4e03e25b7217ce6071c29c09b) Fix two issues in ActiveX DOCX import / export code * Inline anchored VML shape had wrong vertical position ** In MSO inline shapes are positioned to the top of the baseline * During export all shape ids were the same (shape_0) ** VML shapes used to be exported only as fallback, I guess that's why it did not cause any issue before. ** Override the shapeid generator with a new one, which actually generates unique shapeids. Reviewed-on: https://gerrit.libreoffice.org/41319 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai (cherry picked from commit 2d1fe7fb67ec1ff1b96912c0945d17d54aecb12e) Change-Id: I752f39d092d0b61d91824141655dae662dbeafbc DOCX: Fix an other test case of ActiveX control export When LO control is anchored to the end of the run, it is exported into a new run. Reviewed-on: https://gerrit.libreoffice.org/41472 Tested-by: Jenkins Reviewed-by: Tamás Zolnai (cherry picked from commit b129421764ae78a1422812169fce8eb4914a6b22) Change-Id: I9269fd1b34924780aad61c452d1e2094dc8e4aad Reviewed-on: https://gerrit.libreoffice.org/41484 Reviewed-by: Andras Timar Tested-by: Andras Timar --- writerfilter/source/filter/WriterFilter.cxx | 4 -- writerfilter/source/ooxml/OOXMLDocumentImpl.cxx | 79 ------------------------- writerfilter/source/ooxml/OOXMLDocumentImpl.hxx | 6 -- writerfilter/source/ooxml/OOXMLStreamImpl.cxx | 15 +---- 4 files changed, 2 insertions(+), 102 deletions(-) (limited to 'writerfilter/source') diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index 4a1ce7762e3c..206640bda607 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -225,10 +225,6 @@ sal_Bool WriterFilter::filter(const uno::Sequence< beans::PropertyValue >& aDesc aGrabBagProperties["OOXCustomXml"] = uno::makeAny(pDocument->getCustomXmlDomList()); aGrabBagProperties["OOXCustomXmlProps"] = uno::makeAny(pDocument->getCustomXmlDomPropsList()); - // Adding the saved ActiveX DOM - aGrabBagProperties["OOXActiveX"] = uno::makeAny(pDocument->getActiveXDomList()); - aGrabBagProperties["OOXActiveXBin"] = uno::makeAny(pDocument->getActiveXBinList()); - // Adding the saved Glossary Documnet DOM to the document's grab bag aGrabBagProperties["OOXGlossary"] = uno::makeAny(pDocument->getGlossaryDocDom()); aGrabBagProperties["OOXGlossaryDom"] = uno::makeAny(pDocument->getGlossaryDomList()); diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx index d313078f22a6..0f0e11bd7fb7 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx @@ -167,10 +167,6 @@ uno::Reference OOXMLDocumentImpl::importSubStream(OOXMLStre { importSubStreamRelations(pStream, OOXMLStream::CUSTOMXMLPROPS); } - if(OOXMLStream::ACTIVEX == nType) - { - importSubStreamRelations(pStream, OOXMLStream::ACTIVEXBIN); - } if(OOXMLStream::CHARTS == nType) { importSubStreamRelations(pStream, OOXMLStream::EMBEDDINGS); @@ -221,14 +217,8 @@ void OOXMLDocumentImpl::importSubStreamRelations(const OOXMLStream::Pointer_t& p mxCustomXmlProsDom = xRelation; } } - else if(OOXMLStream::ACTIVEXBIN == nType) - { - // imporing activex.bin files for activex.xml from activeX folder. - mxActiveXBin = xcpInputStream; - } else if(OOXMLStream::EMBEDDINGS == nType) { - // imporing activex.bin files for activex.xml from activeX folder. mxEmbeddings = xcpInputStream; } else if(OOXMLStream::CHARTS == nType) @@ -493,8 +483,6 @@ void OOXMLDocumentImpl::resolve(Stream & rStream) // Custom xml's are handled as part of grab bag. resolveCustomXmlStream(rStream); - resolveActiveXStream(rStream); - resolveFastSubStream(rStream, OOXMLStream::FONTTABLE); resolveFastSubStream(rStream, OOXMLStream::STYLES); resolveFastSubStream(rStream, OOXMLStream::NUMBERING); @@ -804,63 +792,6 @@ void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pS mxEmbeddingsList = comphelper::containerToSequence(aEmbeddings); } -void OOXMLDocumentImpl::resolveActiveXStream(Stream & rStream) -{ - // Resolving all ActiveX[n].xml files from ActiveX folder. - uno::Reference xRelationshipAccess; - xRelationshipAccess.set((dynamic_cast(*mpStream.get())).accessDocumentStream(), uno::UNO_QUERY); - if (xRelationshipAccess.is()) - { - static const char sCustomType[] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/control"; - static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/control"; - OUString sTarget("Target"); - bool bFound = false; - sal_Int32 counter = 0; - uno::Sequence< uno::Sequence< beans::StringPair > > aSeqs = xRelationshipAccess->getAllRelationships(); - uno::Sequence > xActiveXDomListTemp(aSeqs.getLength()); - uno::Sequence > xActiveXBinListTemp(aSeqs.getLength()); - for (sal_Int32 j = 0; j < aSeqs.getLength(); j++) - { - uno::Sequence< beans::StringPair > aSeq = aSeqs[j]; - for (sal_Int32 i = 0; i < aSeq.getLength(); i++) - { - beans::StringPair aPair = aSeq[i]; - // Need to resolve only ActiveX files from document relationships. - // Skipping other files. - if (aPair.Second == sCustomType || - aPair.Second == sCustomTypeStrict) - bFound = true; - else if(aPair.First == sTarget && bFound) - { - // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl - // to ensure ActiveX.xml target is visited in lcl_getTarget. - customTarget = aPair.Second; - } - } - if(bFound) - { - uno::Reference activeXTemp = importSubStream(OOXMLStream::ACTIVEX); - // This will add all ActiveX[n].xml to grabbag list. - if(activeXTemp.is()) - { - xActiveXDomListTemp[counter] = activeXTemp; - if(mxActiveXBin.is()) - { - xActiveXBinListTemp[counter] = mxActiveXBin; - } - counter++; - resolveFastSubStream(rStream, OOXMLStream::ACTIVEX); - } - bFound = false; - } - } - xActiveXDomListTemp.realloc(counter); - xActiveXBinListTemp.realloc(counter); - mxActiveXDomList = xActiveXDomListTemp; - mxActiveXBinList = xActiveXBinListTemp; - } -} - uno::Reference OOXMLDocumentImpl::getGlossaryDocDom( ) { return mxGlossaryDocDom; @@ -928,16 +859,6 @@ uno::Sequence > OOXMLDocumentImpl::getCustom return mxCustomXmlDomPropsList; } -uno::Sequence > OOXMLDocumentImpl::getActiveXDomList( ) -{ - return mxActiveXDomList; -} - -uno::Sequence > OOXMLDocumentImpl::getActiveXBinList( ) -{ - return mxActiveXBinList; -} - uno::Sequence OOXMLDocumentImpl::getEmbeddingsList( ) { return mxEmbeddingsList; diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx index 43bdeb651d78..5c9bd0b1bff5 100644 --- a/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx +++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.hxx @@ -48,9 +48,6 @@ class OOXMLDocumentImpl : public OOXMLDocument css::uno::Sequence > mxCustomXmlDomList; css::uno::Sequence > mxCustomXmlDomPropsList; css::uno::Reference mxCustomXmlProsDom; - css::uno::Sequence > mxActiveXDomList; - css::uno::Sequence > mxActiveXBinList; - css::uno::Reference mxActiveXBin; css::uno::Reference mxEmbeddings; css::uno::Sequence < css::beans::PropertyValue > mxEmbeddingsList; bool mbIsSubstream; @@ -88,7 +85,6 @@ protected: const sal_Int32 nNoteId); void resolveCustomXmlStream(Stream & rStream); - void resolveActiveXStream(Stream & rStream); void resolveGlossaryStream(Stream & rStream); void resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pStream); public: @@ -131,8 +127,6 @@ public: virtual css::uno::Reference getThemeDom() override; virtual css::uno::Sequence > getCustomXmlDomList() override; virtual css::uno::Sequence > getCustomXmlDomPropsList() override; - virtual css::uno::Sequence > getActiveXDomList() override; - virtual css::uno::Sequence > getActiveXBinList() override; virtual css::uno::Reference getGlossaryDocDom() override; virtual css::uno::Sequence > getGlossaryDomList() override; virtual css::uno::Sequence getEmbeddingsList() override; diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx index fe26b58cbe93..3d3a6a0b268e 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx @@ -141,8 +141,6 @@ bool OOXMLStreamImpl::lcl_getTarget(const uno::Reference