sd/qa/unit/data/odp/tdf149551_btlr.odp   |binary
 sd/qa/unit/data/odp/tdf149551_tbrl90.odp |binary
 sd/qa/unit/export-tests-ooxml3.cxx       |   77 +++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+)

New commits:
commit 6c635fb11af389d88f36d4bf6b43421af062086a
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Fri Sep 16 13:11:33 2022 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Fri Sep 16 18:05:03 2022 +0200

    tdf#149551 unit test writing mode in shape in Impress
    
    Commit c70ee4a6b9071468255e5d4fdb893e9c9bdf4fad has among other things
    enabled, that a shape in Impress can use a writing mode corresponding to
    vert='vert' in a pptx file. It is new value text::WritingMode2::TB_RL90
    for property WritingMode. It is written with value 'tb-rl90' to attribute
    loext:writing-mode in ODF.
    
    The same commit has enabled, that the writing mode 'bt-rl' can be used
    not only for frames in Writer but for shapes in Impress too.
    
    The unit tests here test round-trip of these property values.
    
    Change-Id: I8dcf9e234d25c2769ed60edd0e435c3606f368bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140066
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>

diff --git a/sd/qa/unit/data/odp/tdf149551_btlr.odp 
b/sd/qa/unit/data/odp/tdf149551_btlr.odp
new file mode 100644
index 000000000000..41db04d782d1
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf149551_btlr.odp differ
diff --git a/sd/qa/unit/data/odp/tdf149551_tbrl90.odp 
b/sd/qa/unit/data/odp/tdf149551_tbrl90.odp
new file mode 100644
index 000000000000..486fcea58b78
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf149551_tbrl90.odp differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index d80518f2e844..dd79bb47f6a7 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/frame/XLoadable.hpp>
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/text/GraphicCrop.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
 
 #include <sdpage.hxx>
 
@@ -118,6 +119,8 @@ public:
     void testTdf109169_OctagonBevel();
     void testTdf109169_DiamondBevel();
     void testTdf144092_emptyShapeTextProps();
+    void testTdf149551_tbrl90();
+    void testTdf149551_btlr();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest3);
 
@@ -202,6 +205,8 @@ public:
     CPPUNIT_TEST(testTdf109169_OctagonBevel);
     CPPUNIT_TEST(testTdf109169_DiamondBevel);
     CPPUNIT_TEST(testTdf144092_emptyShapeTextProps);
+    CPPUNIT_TEST(testTdf149551_tbrl90);
+    CPPUNIT_TEST(testTdf149551_btlr);
     CPPUNIT_TEST_SUITE_END();
 
     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
@@ -2141,6 +2146,78 @@ void 
SdOOXMLExportTest3::testTdf144092_emptyShapeTextProps()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest3::testTdf149551_tbrl90()
+{
+    // The document contains a shape with writing mode TB_RL90. That is the 
same as vert="vert" in
+    // OOXML. Without the patch it was not possible to use this writing mode 
at all.
+    ::sd::DrawDocShellRef xDocShRef
+        = 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf149551_tbrl90.odp"),
 ODP);
+
+    // Test, that the shape has writing mode TB_RL90.
+    uno::Reference<beans::XPropertySet> xShapeProps(getShapeFromPage(0, 0, 
xDocShRef));
+    sal_Int16 eWritingMode;
+    xShapeProps->getPropertyValue("WritingMode") >>= eWritingMode;
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL90, eWritingMode);
+
+    // Test, that it is exported to vert="vert"
+    utl::TempFile aTempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &aTempFile);
+    xmlDocUniquePtr pXmlDoc = parseExport(aTempFile, "ppt/slides/slide1.xml");
+    assertXPath(pXmlDoc, "//a:bodyPr", "vert", "vert");
+
+    // Test, that the shape has writing mode TB_RL90 after read from pptx
+    uno::Reference<beans::XPropertySet> xShapeProps2(getShapeFromPage(0, 0, 
xDocShRef));
+    sal_Int16 eWritingMode2;
+    xShapeProps2->getPropertyValue("WritingMode") >>= eWritingMode2;
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL90, eWritingMode2);
+
+    // Test, that it is written to odp with loext:writing-mode="tb-rl90"
+    aTempFile.EnableKillingFile();
+    save(xDocShRef.get(), getFormat(ODP), aTempFile);
+    pXmlDoc = parseExport(aTempFile, "content.xml");
+    assertXPath(
+        pXmlDoc,
+        
"//style:style[@style:name='gr1']/style:graphic-properties[@loext:writing-mode='tb-rl90']");
+
+    xDocShRef->DoClose();
+}
+
+void SdOOXMLExportTest3::testTdf149551_btlr()
+{
+    // The document contains a shape with writing mode BT_LR. That is the same 
as vert="vert270" in
+    // OOXML. Without the patch it was not possible to use this writing mode 
at all for shapes.
+    ::sd::DrawDocShellRef xDocShRef
+        = 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf149551_btlr.odp"), 
ODP);
+
+    // Test, that the shape has writing mode BT_LR.
+    uno::Reference<beans::XPropertySet> xShapeProps(getShapeFromPage(0, 0, 
xDocShRef));
+    sal_Int16 eWritingMode;
+    xShapeProps->getPropertyValue("WritingMode") >>= eWritingMode;
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, eWritingMode);
+
+    // Test, that it is exported to vert="vert270"
+    utl::TempFile aTempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &aTempFile);
+    xmlDocUniquePtr pXmlDoc = parseExport(aTempFile, "ppt/slides/slide1.xml");
+    assertXPath(pXmlDoc, "//a:bodyPr", "vert", "vert270");
+
+    // Test, that the shape has writing mode BT_LR after read from pptx
+    uno::Reference<beans::XPropertySet> xShapeProps2(getShapeFromPage(0, 0, 
xDocShRef));
+    sal_Int16 eWritingMode2;
+    xShapeProps2->getPropertyValue("WritingMode") >>= eWritingMode2;
+    CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, eWritingMode2);
+
+    // Test, that it is written to odp with loext:writing-mode="bt-lr"
+    aTempFile.EnableKillingFile();
+    save(xDocShRef.get(), getFormat(ODP), aTempFile);
+    pXmlDoc = parseExport(aTempFile, "content.xml");
+    assertXPath(
+        pXmlDoc,
+        
"//style:style[@style:name='gr1']/style:graphic-properties[@loext:writing-mode='bt-lr']");
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest3);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to