[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - oox/source sw/qa

2017-09-25 Thread Szymon Kłos
 oox/source/vml/vmlshape.cxx|8 
 sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx  |   13 +
 3 files changed, 21 insertions(+)

New commits:
commit 9778e5765ad26457da779493edde8a061266c7e3
Author: Szymon Kłos 
Date:   Mon Aug 21 16:06:43 2017 +0200

VML, Watermark: detect shapetype from other subdocuments

In some documents Watermark wasn't visible
because shapetype wasn't detected.
It was impossible to use shapetype defined in header1.xml
in shape placed in the header2.xml.

Change-Id: Ib406c8fc702968684ad46efd0857b768af2820f5
Reviewed-on: https://gerrit.libreoffice.org/41395
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 
(cherry picked from commit 87f1f7fdb34fe452ac540524224e1e808ce5d3a2)
Reviewed-on: https://gerrit.libreoffice.org/42349
Tested-by: Jenkins 

diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index c89b5ece1934..45e7e40ab831 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -284,6 +284,14 @@ void ShapeBase::finalizeFragmentImport()
 aType = aType.copy(1);
 if( const ShapeType* pShapeType = 
mrDrawing.getShapes().getShapeTypeById( aType, true ) )
 maTypeModel.assignUsed( pShapeType->getTypeModel() );
+else {
+// Temporary fix, shapetype not found if referenced from different 
substream
+// FIXME: extend scope of ShapeContainer to store all shapetypes 
from the document
+const OUString sShapeTypePrefix = "shapetype_";
+if (aType.startsWith(sShapeTypePrefix)) {
+maTypeModel.moShapeType = 
aType.copy(sShapeTypePrefix.getLength()).toInt32();
+}
+}
 }
 }
 
diff --git a/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx 
b/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx
new file mode 100755
index ..423f3cf7184f
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/watermark-shapetype.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index a22ab5d7e13f..c964aba9d43b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -655,6 +655,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(0xff), 
getProperty(xCell3, "BackColor"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark-shapetype.docx")
+{
+uno::Reference xShape1(getShape(1), uno::UNO_QUERY);
+uno::Reference xPropertySet1(xShape1, uno::UNO_QUERY);
+xShape1.is();
+
+uno::Reference xShape2(getShape(2), uno::UNO_QUERY);
+uno::Reference xPropertySet2(xShape2, uno::UNO_QUERY);
+xShape2.is();
+
+
CPPUNIT_ASSERT_EQUAL(xPropertySet1->getPropertyValue("TextAutoGrowHeight"), 
xPropertySet2->getPropertyValue("TextAutoGrowHeight"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - oox/source sw/qa sw/source

2017-06-04 Thread Szymon Kłos
 oox/source/export/vmlexport.cxx   |4 +++-
 oox/source/vml/vmlshapecontext.cxx|   11 +--
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx |4 
 sw/qa/extras/uiwriter/data/watermark.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   23 +++
 sw/source/core/edit/edfcol.cxx|   17 +++--
 6 files changed, 50 insertions(+), 9 deletions(-)

New commits:
commit a406d5c22793fd2d43a0876f897a16b11a367ec7
Author: Szymon Kłos 
Date:   Wed May 24 00:15:15 2017 +0200

Watermark: docx interoperability

Before patch:

Document created in MS Word:



Imported to LO and exported:



Then again imported to MS Word and exported:



In this moment LO after import had shape in the navigator but it wasn't 
visible.

Patch:
* vmshapecontext.cxx is changed to read ShapeType from id instead of o:spt
 when o:spid is present.
* vmlexport.cxx added o:spid for Word to identify inserted watermark
* edfxol.cxx changed name of shape to "PowerPlusWaterMarkObject" for Word
* tests

Change-Id: I25322628838a98c45cbeed64144d04977b2ea9ba
Reviewed-on: https://gerrit.libreoffice.org/37969
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 271094ad8f9e334d17176744b90b35e80528bcb2)
Reviewed-on: https://gerrit.libreoffice.org/38381
Reviewed-by: Szymon Kłos 

diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index ef400be64f7c..623beaaa88ec 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -190,8 +190,10 @@ void VMLExport::AddShape( sal_uInt32 nShapeType, 
sal_uInt32 nShapeFlags, sal_uIn
 }
 else
 {
-// A watermark object - store the optional shape ID also ('o:spid')
+// A watermark object - store the optional shape ID
 m_pShapeAttrList->add( XML_id, 
OUStringToOString(m_pSdrObject->GetName(), RTL_TEXTENCODING_UTF8) );
+// also ('o:spid')
+m_pShapeAttrList->addNS( XML_o, XML_spid, ShapeIdString( nShapeId ) );
 }
 }
 
diff --git a/oox/source/vml/vmlshapecontext.cxx 
b/oox/source/vml/vmlshapecontext.cxx
index dc654223aca6..ed369ae1c7d9 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -275,11 +275,18 @@ ShapeTypeContext::ShapeTypeContext( 
ContextHandler2Helper& rParent, ShapeType& r
 mrTypeModel.maShapeId = rAttribs.getXString( bHasOspid ? O_TOKEN( spid ) : 
XML_id, OUString() );
 mrTypeModel.maLegacyId = rAttribs.getString( XML_id, OUString() );
 OSL_ENSURE( !mrTypeModel.maShapeId.isEmpty(), 
"ShapeTypeContext::ShapeTypeContext - missing shape identifier" );
+// builtin shape type identifier
+mrTypeModel.moShapeType = rAttribs.getInteger( O_TOKEN( spt ) );
 // if the o:spid attribute exists, the id attribute contains the 
user-defined shape name
 if( bHasOspid )
+{
 mrTypeModel.maShapeName = rAttribs.getXString( XML_id, OUString() );
-// builtin shape type identifier
-mrTypeModel.moShapeType = rAttribs.getInteger( O_TOKEN( spt ) );
+// get ShapeType and ShapeId from name for compatibility
+mrTypeModel.maShapeId = mrTypeModel.maShapeName;
+static const OUString sShapeTypePrefix = "shapetype_";
+if( mrTypeModel.maShapeName.startsWith( sShapeTypePrefix ) )
+mrTypeModel.moShapeType = 
mrTypeModel.maShapeName.copy(sShapeTypePrefix.getLength()).toInt32();
+}
 
 // coordinate system position/size, CSS style
 mrTypeModel.moCoordPos = lclDecodeInt32Pair( rAttribs, XML_coordorigin );
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index b538e9f990da..e7f24005cd92 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -106,6 +106,10 @@ DECLARE_OOXMLEXPORT_TEST(testTextWatermark, 
"textWatermark.docx")
return;
 
 assertXPath(pXmlHeader1, 
"/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","id","PowerPlusWaterMarkObject93701316");
+
+//The second problem was that Word uses also "o:spid"
+const OUString& sSpid = getXPath(pXmlHeader1, 
"/w:hdr[1]/w:p[1]/w:r[1]/w:pict[1]/v:shape[1]","spid");
+CPPUNIT_ASSERT(!sSpid.isEmpty());
 }
 
 DECLARE_OOXMLEXPORT_TEST(testPictureWatermark, "pictureWatermark.docx")
diff --git a/sw/qa/extras/uiwriter/data/watermark.docx 
b/sw/qa/extras/uiwriter/data/watermark.docx
new file mode 100644
index ..0b26d4442e98
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/watermark.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 30ce2e4c442d..7eccab668c7d 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx