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

Samuel Mehrbrodt Samuel.Mehrbrodt at cib.de
Wed Aug 2 08:31:50 UTC 2017


 include/oox/vml/vmltextbox.hxx                         |    2 ++
 oox/source/vml/vmltextbox.cxx                          |   14 ++++++++++++++
 oox/source/vml/vmltextboxcontext.cxx                   |    6 ++++++
 sw/qa/extras/ooxmlimport/data/groupshape-fontname.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx               |   11 +++++++++++
 5 files changed, 33 insertions(+)

New commits:
commit 1f4327764abdd8dca4f5678fadeaeb67a9c23c4c
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date:   Wed Jul 26 10:50:05 2017 +0200

    tdf#107723 Import font name from text portions in shapes
    
    Change-Id: Ib9b73b5c05ec2e6846ea3adc950ccab5d1c0a9b0
    Reviewed-on: https://gerrit.libreoffice.org/40439
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 178b361c6379bc963c8a48925f1807c583f2d09f)
    Reviewed-on: https://gerrit.libreoffice.org/40528
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx
index 0f0828c88797..8b32713c1dae 100644
--- a/include/oox/vml/vmltextbox.hxx
+++ b/include/oox/vml/vmltextbox.hxx
@@ -49,6 +49,8 @@ struct TextParagraphModel
 struct OOX_DLLPUBLIC TextFontModel
 {
     OptValue< OUString > moName;     ///< Font name.
+    OptValue< OUString > moNameAsian; ///< Asian font name.
+    OptValue< OUString > moNameComplex; ///< Complex font name.
     OptValue< OUString > moColor;    ///< Font color, HTML encoded, sort of.
     OptValue< sal_Int32 > monSize;          ///< Font size in twips.
     OptValue< sal_Int32 > monUnderline;     ///< Single or double underline.
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index ac8c51273d77..cfa07b0546db 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -82,6 +82,20 @@ void TextBox::convert(const uno::Reference<drawing::XShape>& xShape) const
         std::vector<beans::PropertyValue> aPropVec;
         const TextParagraphModel& rParagraph = aIt->maParagraph;
         const TextFontModel& rFont = aIt->maFont;
+        if (rFont.moName.has())
+        {
+            aPropertyValue.Name = "CharFontName";
+            aPropertyValue.Value <<= rFont.moName.get();
+            aPropVec.push_back(aPropertyValue);
+
+            aPropertyValue.Name = "CharFontNameAsian";
+            aPropertyValue.Value <<= rFont.moNameAsian.get();
+            aPropVec.push_back(aPropertyValue);
+
+            aPropertyValue.Name = "CharFontNameComplex";
+            aPropertyValue.Value <<= rFont.moNameComplex.get();
+            aPropVec.push_back(aPropertyValue);
+        }
         if (rFont.mobBold.has())
         {
             aPropertyValue.Name = "CharWeight";
diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx
index 239e53c3a655..c46ff71b98a5 100644
--- a/oox/source/vml/vmltextboxcontext.cxx
+++ b/oox/source/vml/vmltextboxcontext.cxx
@@ -139,6 +139,12 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs)
         case W_TOKEN(rPr):
         case W_TOKEN(t):
         break;
+        case W_TOKEN(rFonts):
+            // See https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.runfonts(v=office.14).aspx
+            maFont.moName = rAttribs.getString(W_TOKEN(ascii));
+            maFont.moNameAsian = rAttribs.getString(W_TOKEN(eastAsia));
+            maFont.moNameComplex = rAttribs.getString(W_TOKEN(cs));
+        break;
         default:
             SAL_INFO("oox", "unhandled: 0x" << std::hex<< getCurrentElement());
         break;
diff --git a/sw/qa/extras/ooxmlimport/data/groupshape-fontname.docx b/sw/qa/extras/ooxmlimport/data/groupshape-fontname.docx
new file mode 100644
index 000000000000..025f737e0556
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/groupshape-fontname.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 891ed7e2d61f..db3dc02027be 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1356,6 +1356,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
     CPPUNIT_ASSERT_EQUAL(getPages(), 2);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx")
+{
+    // Font names inside a group shape were not imported
+    uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText();
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameComplex"));
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraphOfText(1, xText), 1), "CharFontNameAsian"));
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list