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 <vmiklos@collabora.com>
This commit is contained in:
parent
c586d7f1f8
commit
fa5c01e677
@ -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>
|
||||
|
@ -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";
|
||||
|
19
xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp
Normal file
19
xmloff/qa/unit/data/paragraph-tab-stop-distance.fodp
Normal file
@ -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>
|
@ -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: */
|
||||
|
@ -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 ),
|
||||
|
Loading…
x
Reference in New Issue
Block a user