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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 7 07:05:45 UTC 2019


 sw/ooxmlexport_setup.mk                         |    1 
 sw/qa/extras/ooxmlexport/data/btlr-textbox.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx      |   18 ++++++++++++++++
 sw/source/core/doc/textboxhelper.cxx            |   26 ++----------------------
 4 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit 9c945cdbe170104cbacafa2c37babec5210b9ca2
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jun 6 21:32:07 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jun 7 09:05:08 2019 +0200

    sw btlr writing mode: DOCX drawingML import for fly frames
    
    By using the now working btlr direction of the underlying fly frame,
    instead of the character-level workaround.
    
    Change-Id: I3024e3348a30c72f461032b03b88c210f25eb75a
    Reviewed-on: https://gerrit.libreoffice.org/73628
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/ooxmlexport_setup.mk b/sw/ooxmlexport_setup.mk
index 9d3c13325098..c482ef40ce6f 100644
--- a/sw/ooxmlexport_setup.mk
+++ b/sw/ooxmlexport_setup.mk
@@ -16,6 +16,7 @@ define sw_ooxmlexport_libraries
 	editeng \
 	sal \
 	sfx \
+	svl \
 	sw \
 	test \
 	tl \
diff --git a/sw/qa/extras/ooxmlexport/data/btlr-textbox.docx b/sw/qa/extras/ooxmlexport/data/btlr-textbox.docx
new file mode 100644
index 000000000000..181d305eac95
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/btlr-textbox.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index e392644f0de3..c754acafc9ed 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -13,9 +13,11 @@
 #include <com/sun/star/text/WritingMode2.hpp>
 #include <com/sun/star/drawing/XControlShape.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <editeng/frmdiritem.hxx>
 #include <IDocumentSettingAccess.hxx>
 
 #include <editsh.hxx>
+#include <frmatr.hxx>
 
 class Test : public SwModelTestBase
 {
@@ -75,6 +77,22 @@ DECLARE_OOXMLEXPORT_TEST(testTbrlTextbox, "tbrl-textbox.docx")
                          aGeometry["TextPreRotateAngle"].get<sal_Int32>());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testBtlrShape, "btlr-textbox.docx")
+{
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_DRAWFRMFMT), rFormats[0]->Which());
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(RES_FLYFRMFMT), rFormats[1]->Which());
+    // Without the accompanying fix in place, this test would have failed with 'Expected: 5, Actual:
+    // 4', i.e. the textbox inherited its writing direction instead of having an explicit btlr
+    // value.
+    CPPUNIT_ASSERT_EQUAL(SvxFrameDirection::Vertical_LR_BT,
+                         rFormats[1]->GetAttrSet().GetFrameDir().GetValue());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf124637_sectionMargin, "tdf124637_sectionMargin.docx")
 {
     uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx
index 532f1ea9f00f..f729e4e44afd 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -359,35 +359,15 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, const OUString& rPrope
         if (it != aCustomShapeGeometry.end())
         {
             auto nTextPreRotateAngle = it->second.get<sal_Int32>();
-            if (nTextPreRotateAngle == -270)
-            {
-                // That would be the btLr text direction which we don't support at a frame level, so
-                // do it at a character level.
-                const SwNodeIndex* pNodeIndex = pFormat->GetContent().GetContentIdx();
-                if (!pNodeIndex)
-                    return;
-
-                SwPaM aPaM(*pFormat->GetDoc()->GetNodes()[pNodeIndex->GetIndex() + 1], 0);
-                aPaM.SetMark();
-                if (SwTextNode* pMark
-                    = pFormat->GetDoc()
-                          ->GetNodes()[pNodeIndex->GetNode().EndOfSectionIndex() - 1]
-                          ->GetTextNode())
-                {
-                    aPaM.GetMark()->nNode = *pMark;
-                    aPaM.GetMark()->nContent.Assign(pMark, pMark->GetText().getLength());
-                    SvxCharRotateItem aItem(900, false, RES_CHRATR_ROTATE);
-                    pFormat->GetDoc()->getIDocumentContentOperations().InsertPoolItem(aPaM, aItem);
-                }
-                return;
-            }
-
             sal_Int16 nDirection = 0;
             switch (nTextPreRotateAngle)
             {
                 case -90:
                     nDirection = text::WritingMode2::TB_RL;
                     break;
+                case -270:
+                    nDirection = text::WritingMode2::BT_LR;
+                    break;
             }
 
             if (nDirection)


More information about the Libreoffice-commits mailing list