schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |    6 +
 xmloff/inc/xmlprop.hxx                                      |    1 
 xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp        |   19 +++++
 xmloff/qa/unit/text.cxx                                     |   41 ++++++++++++
 xmloff/source/text/txtprmap.cxx                             |    2 
 5 files changed, 69 insertions(+)

New commits:
commit fa5c01e67775c01b302fc08033a0eb78d3b87489
Author:     Sarper Akdemir <sarper.akde...@collabora.com>
AuthorDate: Fri Mar 3 18:04:46 2023 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Mar 24 07:18:54 2023 +0000

    related tdf#102261: xmloff: ODF import/export for ParaTabStopDefaultDistance
    
    Introduces ODF import/export for ParaTabStopDefaultDistance
    (loext:tab-stop-distance).
    
    Also adds a unit test that covers import & export of the
    property.
    
    Change-Id: I8a69a9e2b73e8f1172f92dc35fada901f4b887f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148540
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng 
b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index f0f84bd3fd40..fa38694f9cff 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -2615,6 +2615,12 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
       <rng:ref name="common-text-justify"/>
       <rng:ref name="style-vertical-justify"/>
     </rng:optional>
+    <!-- TODO no proposal to allow tab-stop-distance in arbitrary paragraph 
style properties -->
+    <rng:optional>
+      <rng:attribute name="loext:tab-stop-distance">
+        <rng:ref name="nonNegativeLength"/>
+      </rng:attribute>
+    </rng:optional>
   </rng:define>
   <rng:define name="style-table-cell-properties-attlist" combine="interleave">
     <rng:optional>
diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx
index ab7c53de01cf..3b2cd86816bc 100644
--- a/xmloff/inc/xmlprop.hxx
+++ b/xmloff/inc/xmlprop.hxx
@@ -513,6 +513,7 @@ inline constexpr OUStringLiteral 
PROP_ParaRightMarginRelative = u"ParaRightMargi
 inline constexpr OUStringLiteral PROP_ParaShadowFormat = u"ParaShadowFormat";
 inline constexpr OUStringLiteral PROP_ParaSplit = u"ParaSplit";
 inline constexpr OUStringLiteral PROP_ParaTabStops = u"ParaTabStops";
+inline constexpr OUStringLiteral PROP_ParaTabStopDefaultDistance = 
u"ParaTabStopDefaultDistance";
 inline constexpr OUStringLiteral PROP_ParaTopMargin = u"ParaTopMargin";
 inline constexpr OUStringLiteral PROP_ParaTopMarginRelative = 
u"ParaTopMarginRelative";
 inline constexpr OUStringLiteral PROP_ParaUserDefinedAttributes = 
u"ParaUserDefinedAttributes";
diff --git a/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp 
b/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp
new file mode 100644
index 000000000000..f51e75b79699
--- /dev/null
+++ b/xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.presentation">
+ <office:automatic-styles>
+  <style:style style:name="P1" style:family="paragraph">
+   <style:paragraph-properties loext:tab-stop-distance="10cm"/>
+  </style:style>
+ </office:automatic-styles>
+ <office:body>
+  <office:presentation>
+   <draw:page>
+    <draw:frame svg:width="25cm" svg:height="1cm" svg:x="1cm" svg:y="1cm">
+     <draw:text-box>
+      <text:p 
text:style-name="P1">start<text:tab/>tab1<text:tab/>tab2<text:tab/>tab4</text:p>
+     </draw:text-box>
+    </draw:frame>
+   </draw:page>
+  </office:presentation>
+ </office:body>
+</office:document>
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 7fe762580ac1..5d3a9cf4ac99 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -17,6 +17,7 @@
 #include <com/sun/star/text/TextContentAnchorType.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 
 #include <comphelper/propertysequence.hxx>
@@ -1047,6 +1048,46 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testFloatingTableImport)
     CPPUNIT_ASSERT(bIsSplitAllowed);
 }
 
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParagraphScopedTabDistance)
+{
+    // Given a document with paragraph scoped default tab stop distance 
(loext:tab-stop-distance="0.5cm")
+    loadFromURL(u"paragraph-tab-stop-distance.fodp");
+
+    uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> 
xPage(xDoc->getDrawPages()->getByIndex(0),
+                                             uno::UNO_QUERY_THROW);
+
+    uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), 
uno::UNO_QUERY);
+    uno::Reference<text::XText> xText
+        = uno::Reference<text::XTextRange>(xShape, 
uno::UNO_QUERY_THROW)->getText();
+
+    uno::Reference<container::XEnumerationAccess> paraEnumAccess(xText, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> 
paraEnum(paraEnumAccess->createEnumeration());
+    uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(), 
uno::UNO_QUERY_THROW);
+
+    uno::Reference<container::XEnumerationAccess> runEnumAccess(xParagraph, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> runEnum = 
runEnumAccess->createEnumeration();
+    uno::Reference<text::XTextRange> xRun(runEnum->nextElement(), 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+    // Make sure the tab stop default distance is imported correctly
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 10000
+    // - Actual  : 0
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(10000),
+                         
xPropSet->getPropertyValue("ParaTabStopDefaultDistance").get<sal_Int32>());
+
+    // Save the imported file to test the export too
+    save("impress8");
+
+    // Then make sure we write the tab-stop-distance
+    xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+    assertXPath(pXmlDoc, 
"//style:style[@style:name='P1']/style:paragraph-properties",
+                "tab-stop-distance", "10cm");
+
+    assertXPath(pXmlDoc, "//text:p[@text:style-name='P1']");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index c57c8c243540..c3b7403de1d7 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -446,6 +446,8 @@ XMLPropertyMapEntry const aXMLParaPropMap[] =
     MP_ED( PROP_ParaIsHangingPunctuation, STYLE, PUNCTUATION_WRAP, 
XML_TYPE_TEXT_PUNCTUATION_WRAP, 0 ),
     MP_ED( PROP_ParaIsForbiddenRules, STYLE, LINE_BREAK, 
XML_TYPE_TEXT_LINE_BREAK, 0 ),
     MP_E( PROP_TabStopDistance, STYLE, TAB_STOP_DISTANCE, XML_TYPE_MEASURE, 0 
),
+    MAP_EXT_I( PROP_ParaTabStopDefaultDistance, XML_NAMESPACE_STYLE, 
XML_TAB_STOP_DISTANCE, XML_TYPE_MEASURE|XML_TYPE_PROP_PARAGRAPH, 0 ),
+    MAP_EXT( PROP_ParaTabStopDefaultDistance, XML_NAMESPACE_LO_EXT, 
XML_TAB_STOP_DISTANCE, XML_TYPE_MEASURE|XML_TYPE_PROP_PARAGRAPH, 0 ),
 
     // RES_PARATR_VERTALIGN
     MP_E( PROP_ParaVertAlignment, STYLE, VERTICAL_ALIGN,   
XML_TYPE_TEXT_VERTICAL_ALIGN, 0 ),

Reply via email to