[Libreoffice-commits] core.git: oox/source sw/qa sw/source

Mark Hung (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 14 09:23:54 UTC 2020


 oox/source/export/drawingml.cxx             |    2 -
 oox/source/shape/WpsContext.cxx             |    8 ++++++-
 sw/qa/extras/ooxmlexport/data/tdf128304.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx  |   29 +++++++++++++++++++++++-----
 sw/source/filter/ww8/docxsdrexport.cxx      |    2 -
 5 files changed, 33 insertions(+), 8 deletions(-)

New commits:
commit b203b9c83d0000c8465dcd92fb6b029a2f28c724
Author:     Mark Hung <marklh9 at gmail.com>
AuthorDate: Fri Dec 13 07:23:35 2019 +0800
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jan 14 10:23:19 2020 +0100

    tdf#128304 export TB_RL writing mode as eaVirt
    
    and import eaVirt to TextWritingMode instead of TextPreRotateAngle
    (-90) degree of CustomShapeGeometry. CJK text in TB_RL writing mode
    are upright in Writer. It corresponds to eaVirt by its defintion.
    
    Change-Id: I2a8bc6676ad6af06b06e023adaa2f201a028d426
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86637
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 087c51da5541..8c9f641b5d4f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2692,7 +2692,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
 
         if( ( mAny >>= eMode ) && eMode == WritingMode_TB_RL )
         {
-            sWritingMode = "vert";
+            sWritingMode = "eaVert";
             bVertical = true;
         }
     }
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index cf637eae0606..863621b3931c 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/text/XTextCursor.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
 #include <svx/svdtrans.hxx>
 #include <oox/helper/attributelist.hxx>
 #include <oox/token/namespaces.hxx>
@@ -57,7 +58,12 @@ oox::core::ContextHandlerRef WpsContext::onCreateContext(sal_Int32 nElementToken
                 uno::Reference<lang::XServiceInfo> xServiceInfo(mxShape, uno::UNO_QUERY);
                 uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
                 sal_Int32 nVert = rAttribs.getToken(XML_vert, XML_horz);
-                if (nVert != XML_horz)
+                if (nVert == XML_eaVert)
+                {
+                    xPropertySet->setPropertyValue("TextWritingMode",
+                                                   uno::makeAny(text::WritingMode_TB_RL));
+                }
+                else if (nVert != XML_horz)
                 {
                     // Get the existing rotation of the shape.
                     drawing::HomogenMatrix3 aMatrix;
diff --git a/sw/qa/extras/ooxmlexport/data/tdf128304.odt b/sw/qa/extras/ooxmlexport/data/tdf128304.odt
new file mode 100644
index 000000000000..6c5cbd1200aa
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128304.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 18e957bbcb09..81687683ec63 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -11,6 +11,7 @@
 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
@@ -639,12 +640,10 @@ DECLARE_OOXMLEXPORT_TEST(testTbrlFrameVml, "tbrl-frame-vml.docx")
 
     if (mbExported)
     {
-        // DML import: creates a TextBox.
+        // DML import: creates a TextBox, eaVert read back as TB_RL in TextWritingMode
 
-        comphelper::SequenceAsHashMap aGeometry(xTextFrame->getPropertyValue("CustomShapeGeometry"));
-        // Without the accompanying fix in place, this test would have failed with 'Expected: -90;
-        // Actual: 0', i.e. the tblr writing mode was lost during DML export of a TextFrame.
-        CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-90), aGeometry["TextPreRotateAngle"].get<sal_Int32>());
+        auto eMode = getProperty<text::WritingMode>(xTextFrame, "TextWritingMode");
+        CPPUNIT_ASSERT_EQUAL(text::WritingMode::WritingMode_TB_RL, eMode);
     }
     else
     {
@@ -993,6 +992,26 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127579, "tdf127579.odt")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:hyperlink/w:r/w:rPr/w:rStyle", "val", "InternetLink");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf128304, "tdf128304.odt")
+{
+    css::text::WritingMode eMode;
+    uno::Reference<beans::XPropertySet> xProps1(getShape(1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+    CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+    uno::Reference<beans::XPropertySet> xProps2(getShape(2), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+    CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+    uno::Reference<beans::XPropertySet> xProps3(getShape(3), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+    CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+
+    uno::Reference<beans::XPropertySet> xProps4(getShape(4), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xProps1->getPropertyValue("TextWritingMode") >>= eMode);
+    CPPUNIT_ASSERT_EQUAL(css::text::WritingMode::WritingMode_TB_RL, eMode);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 005e50ba5634..8ab399a46fe3 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -1359,7 +1359,7 @@ void DocxSdrExport::writeDMLTextFrame(ww8::Frame const* pParentFrame, int nAncho
 
         const SvxFrameDirectionItem& rDirection = rFrameFormat.GetFrameDir();
         if (rDirection.GetValue() == SvxFrameDirection::Vertical_RL_TB)
-            m_pImpl->getBodyPrAttrList()->add(XML_vert, "vert");
+            m_pImpl->getBodyPrAttrList()->add(XML_vert, "eaVert");
         else if (rDirection.GetValue() == SvxFrameDirection::Vertical_LR_BT)
             m_pImpl->getBodyPrAttrList()->add(XML_vert, "vert270");
 


More information about the Libreoffice-commits mailing list