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

Szymon Kłos szymon.klos at collabora.com
Sun Jun 4 12:39:00 UTC 2017


 include/oox/vml/vmlformatting.hxx                 |    1 +
 oox/source/vml/vmlformatting.cxx                  |   22 ++++++++++++++++++++++
 oox/source/vml/vmlshapecontext.cxx                |    1 +
 sw/qa/extras/ooxmlexport/data/watermark-font.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx         |   13 +++++++++++++
 sw/qa/extras/uiwriter/uiwriter.cxx                |    3 +--
 6 files changed, 38 insertions(+), 2 deletions(-)

New commits:
commit 7d723184dd7f77cb16d3073afa0f9ed47c6598ea
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Thu May 25 18:54:37 2017 +0200

    Watermark: VML font-family import for textpath
    
    Handle style attribute to get font-family:
    <v:textpath style="font-family:"DejaVu Sans Light";font-size:1pt" .../>
    
    Change-Id: I5fe530aecccc57e103b413ef494502f666f1005a
    Reviewed-on: https://gerrit.libreoffice.org/38039
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 46edac18b76d8e9cc74aed8a9712ca3bdadd0972)
    Reviewed-on: https://gerrit.libreoffice.org/38384
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/include/oox/vml/vmlformatting.hxx b/include/oox/vml/vmlformatting.hxx
index d7c3e92f0b9c..efb0e6606887 100644
--- a/include/oox/vml/vmlformatting.hxx
+++ b/include/oox/vml/vmlformatting.hxx
@@ -241,6 +241,7 @@ struct OOX_DLLPUBLIC ShadowModel
 struct OOX_DLLPUBLIC TextpathModel
 {
     OptValue<OUString> moString;                  ///< Specifies the string of the textpath.
+    OptValue<OUString> moStyle;                   ///< Specifies the style of the textpath.
 
     TextpathModel();
 
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index f8c8de8dae8d..c2e2d139c0d6 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -882,6 +882,28 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
         }
         rPropMap.setAnyProperty(PROP_CustomShapeGeometry, uno::makeAny(aGeomPropSeq));
     }
+    if (moStyle.has())
+    {
+        OUString aStyle = moStyle.get(OUString());
+
+        sal_Int32 nIndex = 0;
+        while( nIndex >= 0 )
+        {
+            OUString aName, aValue;
+            if (ConversionHelper::separatePair(aName, aValue, aStyle.getToken(0, ';', nIndex), ':'))
+            {
+                if (aName == "font-family")
+                {
+                    // remove " (first, and last character)
+                    if (aValue.getLength() > 2)
+                        aValue = aValue.copy(1, aValue.getLength() - 2);
+
+                    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+                    xPropertySet->setPropertyValue("CharFontName", uno::makeAny(aValue));
+                }
+            }
+        }
+    }
 }
 
 } // namespace vml
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index ed369ae1c7d9..02cf06e51429 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -383,6 +383,7 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A
         break;
         case VML_TOKEN( textpath ):
             mrTypeModel.maTextpathModel.moString.assignIfUsed(rAttribs.getString(XML_string));
+            mrTypeModel.maTextpathModel.moStyle.assignIfUsed(rAttribs.getString(XML_style));
         break;
     }
     return nullptr;
diff --git a/sw/qa/extras/ooxmlexport/data/watermark-font.docx b/sw/qa/extras/ooxmlexport/data/watermark-font.docx
new file mode 100644
index 000000000000..82d7ec8a83fc
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/watermark-font.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index 3b4445f8585e..9a13c5aaef21 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -691,6 +691,19 @@ DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
     CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testWatermarkFont, "watermark-font.docx")
+{
+    uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(OUString("TestFont"), xShape->getString());
+
+    uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
+    OUString aFont;
+
+    // Check font family
+    CPPUNIT_ASSERT(xPropertySet->getPropertyValue("CharFontName") >>= aFont);
+    CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Serif"), aFont);
+}
+
 DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx")
 {
     // The problem was that the alignment are not exchange when the paragraph are RTL.
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 7eccab668c7d..d18408c435c5 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -866,8 +866,7 @@ void SwUiWriterTest::testWatermarkDOCX()
 
     const SfxWatermarkItem* pWatermark = static_cast<const SfxWatermarkItem*>(pItem);
     CPPUNIT_ASSERT_EQUAL(OUString("CustomWatermark"), pWatermark->GetText());
-    //TODO: VML import textpath style
-    //CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Sans Light"), pWatermark->GetFont());
+    CPPUNIT_ASSERT_EQUAL(OUString("DejaVu Sans Light"), pWatermark->GetFont());
     CPPUNIT_ASSERT_EQUAL((sal_Int16)45, pWatermark->GetAngle());
     CPPUNIT_ASSERT_EQUAL((sal_uInt32)0x548dd4, pWatermark->GetColor());
     CPPUNIT_ASSERT_EQUAL((sal_Int16)50, pWatermark->GetTransparency());


More information about the Libreoffice-commits mailing list