include/oox/ole/oleobjecthelper.hxx | 2 +- oox/source/ole/oleobjecthelper.cxx | 10 +++------- sw/qa/extras/ooxmlexport/data/tdf131537.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 9 ++++++++- sw/source/filter/ww8/docxattributeoutput.cxx | 16 +++++++++++----- writerfilter/source/dmapper/OLEHandler.cxx | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-)
New commits: commit 8d80c1ae18844e96a7ba0ac5fc1cc608dad1ef07 Author: Daniel Arato (NISZ) <arato.dan...@nisz.hu> AuthorDate: Mon Aug 31 12:48:07 2020 +0200 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Fri Sep 18 09:33:30 2020 +0200 tdf#131537 DOCX export: fix OLE "Display as icon" for example to avoid converting OLE icons of an ODF document to an icon-size embedded spreadsheet. When creating a new OLE object in Writer the user has an option called "Display as icon" which causes the actual contents of the OLE to be hidden when rendered in the document. This setting, referred to internally as the DrawAspect of the object, was imported fine, but when exported to a .docx it always had the value "Content" (corresponding to "Display as icon" being unchecked). Now OLE objects with "Display as icon" checked are saved with DrawAspect="Icon". A grab bag entry was previously used to let the DrawAspect setting flow through Writer from OOXML import to export. Now this workaround is no longer needed and is removed by the present commit. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101711 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 07dcb0dab759d4ab535d99c0e6d326959906b87e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102652 Reviewed-by: Dániel Arató <arato.dan...@nisz.hu> Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Tested-by: Jenkins (cherry picked from commit 10184fcab1f314e0861ad152b320ed1ee31ccdd5) Change-Id: I46ea4fc95a26bcd1f85e19a506c0965f73d4257a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102937 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/include/oox/ole/oleobjecthelper.hxx b/include/oox/ole/oleobjecthelper.hxx index 604785f305b6..0d76019318d8 100644 --- a/include/oox/ole/oleobjecthelper.hxx +++ b/include/oox/ole/oleobjecthelper.hxx @@ -77,7 +77,7 @@ private: OOX_DLLPUBLIC void SaveInteropProperties( css::uno::Reference<css::frame::XModel> const& xModel, OUString const& rObjectName, OUString const* pOldObjectName, - OUString const& rProgId, OUString const& rDrawAspect); + OUString const& rProgId); } // namespace ole diff --git a/oox/source/ole/oleobjecthelper.cxx b/oox/source/ole/oleobjecthelper.cxx index cb909592f9b2..9d909faa2307 100644 --- a/oox/source/ole/oleobjecthelper.cxx +++ b/oox/source/ole/oleobjecthelper.cxx @@ -87,7 +87,7 @@ OleObjectHelper::~OleObjectHelper() // just "application/vnd.sun.star.oleobject" void SaveInteropProperties(uno::Reference<frame::XModel> const& xModel, OUString const& rObjectName, OUString const*const pOldObjectName, - OUString const& rProgId, OUString const& rDrawAspect) + OUString const& rProgId) { static const char sEmbeddingsPropName[] = "EmbeddedObjects"; @@ -100,11 +100,9 @@ void SaveInteropProperties(uno::Reference<frame::XModel> const& xModel, if (aGrabBag.find(sEmbeddingsPropName) != aGrabBag.end()) objectsList << aGrabBag[sEmbeddingsPropName]; - uno::Sequence< beans::PropertyValue > aGrabBagAttribute(2); + uno::Sequence< beans::PropertyValue > aGrabBagAttribute(1); aGrabBagAttribute[0].Name = "ProgID"; aGrabBagAttribute[0].Value <<= rProgId; - aGrabBagAttribute[1].Name = "DrawAspect"; - aGrabBagAttribute[1].Value <<= rDrawAspect; // If we got an "old name", erase that first. if (pOldObjectName) @@ -148,9 +146,7 @@ bool OleObjectHelper::importOleObject( PropertyMap& rPropMap, const OleObjectInf xOutStrm->writeBytes( rOleObject.maEmbeddedData ); xOutStrm->closeOutput(); - SaveInteropProperties(m_xModel, aObjectId, nullptr, - rOleObject.maProgId, - rOleObject.mbShowAsIcon ? OUString("Icon") : OUString("Content")); + SaveInteropProperties(m_xModel, aObjectId, nullptr, rOleObject.maProgId); OUString aUrl = mxResolver->resolveEmbeddedObjectURL( aObjectId ); OSL_ENSURE( aUrl.match( g_aEmbeddedObjScheme ), "OleObjectHelper::importOleObject - unexpected URL scheme" ); diff --git a/sw/qa/extras/ooxmlexport/data/tdf131537.odt b/sw/qa/extras/ooxmlexport/data/tdf131537.odt new file mode 100644 index 000000000000..21f396368917 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131537.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index c5441fae765a..ad97c9be23fd 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -887,7 +887,14 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80898, "fdo80898.docx") "Word.Document.8"); } -DECLARE_OOXMLEXPORT_TEST(testTableCellWithDirectFormatting, "fdo80800.docx") +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testOleIconDrawAspect, "tdf131537.odt") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject", + "DrawAspect", "Icon"); +} + +DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTableCellWithDirectFormatting, "fdo80800.docx") { // Issue was Direct Formatting for non-first Table cells was not getting preserved. diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a6020b2568a1..4b8ffce6cb84 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -146,6 +146,7 @@ #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/embed/EmbedStates.hpp> +#include <com/sun/star/embed/Aspects.hpp> #include <algorithm> #include <stdarg.h> @@ -5468,7 +5469,16 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S OUString sObjectName = aContainer->GetEmbeddedObjectName( xObj ); // set some attributes according to the type of the embedded object - OUString sProgID, sDrawAspect = "Content"; + OUString sProgID, sDrawAspect; + switch (rNode.GetAspect()) + { + case embed::Aspects::MSOLE_CONTENT: sDrawAspect = "Content"; break; + case embed::Aspects::MSOLE_DOCPRINT: sDrawAspect = "DocPrint"; break; + case embed::Aspects::MSOLE_ICON: sDrawAspect = "Icon"; break; + case embed::Aspects::MSOLE_THUMBNAIL: sDrawAspect = "Thumbnail"; break; + default: + SAL_WARN("sw.ww8", "DocxAttributeOutput::WriteOLE: invalid aspect value"); + } auto pObjectsInterop = std::find_if(aObjectsInteropList.begin(), aObjectsInteropList.end(), [&sObjectName](const beans::PropertyValue& rProp) { return rProp.Name == sObjectName; }); if (pObjectsInterop != aObjectsInteropList.end()) @@ -5480,10 +5490,6 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S { rObjectInteropAttribute.Value >>= sProgID; } - else if ( rObjectInteropAttribute.Name == "DrawAspect" ) - { - rObjectInteropAttribute.Value >>= sDrawAspect; - } } // write embedded file diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx index 3750398c0800..877d060b8f8e 100644 --- a/writerfilter/source/dmapper/OLEHandler.cxx +++ b/writerfilter/source/dmapper/OLEHandler.cxx @@ -226,7 +226,7 @@ void OLEHandler::importStream(const uno::Reference<uno::XComponentContext>& xCom uno::Reference<beans::XPropertySet> xPropertySet(xOLE, uno::UNO_QUERY); ::oox::ole::SaveInteropProperties(xTextDocument, xPropertySet->getPropertyValue("StreamName").get<OUString>(), &m_aURL, - m_sProgId, m_sDrawAspect); + m_sProgId); } OUString OLEHandler::getCLSID(const uno::Reference<uno::XComponentContext>& xComponentContext) const @@ -302,7 +302,7 @@ OUString OLEHandler::copyOLEOStream( } } - ::oox::ole::SaveInteropProperties(xTextDocument, aURL, nullptr, m_sProgId, m_sDrawAspect); + ::oox::ole::SaveInteropProperties(xTextDocument, aURL, nullptr, m_sProgId); OUString aPersistName( xEmbeddedResolver->resolveEmbeddedObjectURL( aURL ) ); sRet = aPersistName.copy( strlen("vnd.sun.star.EmbeddedObject:") ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits