[Libreoffice-commits] core.git: sw/qa sw/source
Attila Bakos (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 2 06:42:50 UTC 2020
sw/qa/extras/ooxmlexport/data/tdf135655.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport15.cxx | 7 +++
sw/source/filter/ww8/docxattributeoutput.cxx | 52 ++++++++++++++++++---------
3 files changed, 42 insertions(+), 17 deletions(-)
New commits:
commit 6bdf4ee8368fdc0bb20a82c250038b371b37f27d
Author: Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Wed Aug 12 13:36:22 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Wed Sep 2 08:42:10 2020 +0200
tdf#135655 OOXML export: Fix OLE background color
Follow-up of commit 636d16efe45a55c1a5a7a451c46fbb8618bf0393
(tdf#135653 OOXML import: fix OLE background color).
Co-authored-by: Daniel Arato (NISZ)
Change-Id: Iee927898884e229108b489d6d26a83ef7ad2f9a6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100924
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf135655.odt b/sw/qa/extras/ooxmlexport/data/tdf135655.odt
new file mode 100644
index 000000000000..06933eb3fa36
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf135655.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 65004941acc6..1eff36be4eb6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -404,6 +404,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf131561_necessaryBorder, "tdf131561_necessaryBord
CPPUNIT_ASSERT_MESSAGE("Border between A3 and B3", (aBorderR.LineWidth + aBorderL.LineWidth) > 0);
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf135655, "tdf135655.odt")
+{
+ const xmlDocUniquePtr pExpDoc = parseExport();
+ const OUString sXFillColVal = getXPath(pExpDoc, "/w:document/w:body/w:p/w:r/w:object/v:shape", "fillcolor");
+ CPPUNIT_ASSERT_EQUAL(OUString("#00A933"), sXFillColVal);
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf134609_gridAfter, "tdf134609_gridAfter.docx")
{
uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 6a1593d265e4..094589dd3454 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -88,9 +88,11 @@
#include <editeng/charhiddenitem.hxx>
#include <editeng/editobj.hxx>
#include <editeng/keepitem.hxx>
+#include <svx/xdef.hxx>
#include <svx/xfillit0.hxx>
#include <svx/xflclit.hxx>
#include <svx/xflgrit.hxx>
+#include <svx/xflclit.hxx>
#include <svx/svdouno.hxx>
#include <svx/unobrushitemhelper.hxx>
#include <svl/grabbagitem.hxx>
@@ -5521,8 +5523,10 @@ void DocxAttributeOutput::WritePostponedOLE()
m_pPostponedOLEs.reset();
}
-void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* rFlyFrameFormat )
+void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const SwFlyFrameFormat* pFlyFrameFormat )
{
+ OSL_ASSERT(pFlyFrameFormat);
+
// get interoperability information about embedded objects
uno::Reference< beans::XPropertySet > xPropSet( m_rExport.m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
uno::Sequence< beans::PropertyValue > aGrabBag, aObjectsInteropList,aObjectInteropAttributes;
@@ -5563,7 +5567,7 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
{
// the embedded file could not be saved
// fallback: save as an image
- FlyFrameGraphic( nullptr, rSize, rFlyFrameFormat, &rNode );
+ FlyFrameGraphic( nullptr, rSize, pFlyFrameFormat, &rNode );
return;
}
@@ -5603,18 +5607,18 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
//This string will store the relative position for aPos
OString aAnch;
- if (rFlyFrameFormat && rFlyFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
+ if (pFlyFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
{
//Get the horizontal alignment of the OLE via the frame format, to aHAlign
- OString aHAlign = convertToOOXMLHoriOrient(rFlyFrameFormat->GetHoriOrient().GetHoriOrient(),
- rFlyFrameFormat->GetHoriOrient().IsPosToggle());
+ OString aHAlign = convertToOOXMLHoriOrient(pFlyFrameFormat->GetHoriOrient().GetHoriOrient(),
+ pFlyFrameFormat->GetHoriOrient().IsPosToggle());
//Get the vertical alignment of the OLE via the frame format to aVAlign
- OString aVAlign = convertToOOXMLVertOrient(rFlyFrameFormat->GetVertOrient().GetVertOrient());
+ OString aVAlign = convertToOOXMLVertOrient(pFlyFrameFormat->GetVertOrient().GetVertOrient());
//Get the relative horizontal positions for the anchors
- OString aHAnch = convertToOOXMLHoriOrientRel(rFlyFrameFormat->GetHoriOrient().GetRelationOrient());
+ OString aHAnch = convertToOOXMLHoriOrientRel(pFlyFrameFormat->GetHoriOrient().GetRelationOrient());
//Get the relative vertical positions for the anchors
- OString aVAnch = convertToOOXMLVertOrientRel(rFlyFrameFormat->GetVertOrient().GetRelationOrient());
+ OString aVAnch = convertToOOXMLVertOrientRel(pFlyFrameFormat->GetVertOrient().GetRelationOrient());
//Choice that the horizontal position is relative or not
if (!aHAlign.isEmpty())
@@ -5631,8 +5635,8 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
//Query the positions to aPos from frameformat
aPos =
- "position:absolute;margin-left:" + OString::number(double(rFlyFrameFormat->GetHoriOrient().GetPos()) / 20) +
- "pt;margin-top:" + OString::number(double(rFlyFrameFormat->GetVertOrient().GetPos()) / 20) + "pt;";
+ "position:absolute;margin-left:" + OString::number(double(pFlyFrameFormat->GetHoriOrient().GetPos()) / 20) +
+ "pt;margin-top:" + OString::number(double(pFlyFrameFormat->GetVertOrient().GetPos()) / 20) + "pt;";
}
OString sShapeStyle = "width:" + OString::number( double( rSize.Width() ) / 20 ) +
@@ -5645,10 +5649,24 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
sShapeStyle = aPos + sShapeStyle + aAnch;
// shape definition
- m_pSerializer->startElementNS( XML_v, XML_shape,
- XML_id, sShapeId.getStr(),
- XML_style, sShapeStyle.getStr(),
- FSNS( XML_o, XML_ole ), ""); //compulsory, even if it's empty
+ const bool bFilled = pFlyFrameFormat->GetAttrSet().Get(XATTR_FILLSTYLE).GetValue() != FillStyle::FillStyle_NONE;
+ const Color rShapeColor = pFlyFrameFormat->GetAttrSet().Get(XATTR_FILLCOLOR).GetColorValue();
+ if (bFilled)
+ {
+ m_pSerializer->startElementNS( XML_v, XML_shape,
+ XML_id, sShapeId.getStr(),
+ XML_style, sShapeStyle.getStr(),
+ XML_fillcolor, "#" + msfilter::util::ConvertColor( rShapeColor ),
+ FSNS( XML_o, XML_ole ), ""); //compulsory, even if it's empty
+ }
+ else
+ {
+ m_pSerializer->startElementNS( XML_v, XML_shape,
+ XML_id, sShapeId.getStr(),
+ XML_style, sShapeStyle.getStr(),
+ XML_filled, "f",
+ FSNS( XML_o, XML_ole ), ""); //compulsory, even if it's empty
+ }
// shape filled with the preview image
m_pSerializer->singleElementNS( XML_v, XML_imagedata,
@@ -5656,10 +5674,10 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S
FSNS( XML_o, XML_title ), "" );
//export wrap settings
- if(rFlyFrameFormat && rFlyFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
+ if(pFlyFrameFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR)
{
- const SwFormatSurround aWrap = rFlyFrameFormat->GetSurround();
- bool bIsCountur = aWrap.IsContour();
+ const SwFormatSurround aWrap = pFlyFrameFormat->GetSurround();
+ const bool bIsCountur = aWrap.IsContour();
if (aWrap.GetSurround() == text::WrapTextMode::WrapTextMode_NONE)
m_pSerializer->singleElementNS(XML_w10, XML_wrap, XML_type, "topAndBottom");
More information about the Libreoffice-commits
mailing list