include/xmloff/xmltoken.hxx                                 |    1 
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |    6 
 xmloff/CppunitTest_xmloff_text.mk                           |    1 
 xmloff/inc/xmlprop.hxx                                      |    1 
 xmloff/qa/unit/data/floattable-wrap-all-pages2.fodt         |   41 +++++
 xmloff/qa/unit/text/txtprmap.cxx                            |   87 ++++++++++++
 xmloff/source/core/xmltoken.cxx                             |    1 
 xmloff/source/text/txtprmap.cxx                             |    1 
 xmloff/source/token/tokens.txt                              |    1 
 9 files changed, 140 insertions(+)

New commits:
commit 7f58b57b47e6642cb9a7aeac48915b30148042d2
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Tue Nov 28 08:46:58 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Nov 28 09:53:13 2023 +0100

    sw floattable, per-frame wrap-on-all-pages mode: add ODT filter
    
    See <https://issues.oasis-open.org/browse/OFFICE-4150>, map
    SwFormatWrapTextAtFlyStart to
    
            <style:graphic-properties loext:wrap-text-at-frame-start="...">
    
    on export, and the opposite on import.
    
    Change-Id: I43ee4c014fbcef8e883ff08ea061cfd395399a98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160010
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index ba42fae4d035..b6fa0dc2acba 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3547,6 +3547,7 @@ namespace xmloff::token {
         XML_FILL_USE_SLIDE_BACKGROUND,
 
         XML_MAY_BREAK_BETWEEN_PAGES,
+        XML_WRAP_TEXT_AT_FRAME_START,
 
         XML_GRADIENT_STOP, // multi-color-gradient
         XML_OPACITY_STOP,
diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng 
b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
index 828b4b28c9fd..a68033d1954e 100644
--- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng
@@ -926,6 +926,12 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
             <rng:ref name="boolean"/>
           </rng:attribute>
         </rng:optional>
+    <!-- https://issues.oasis-open.org/browse/OFFICE-4150 multi-page floating 
tables, wrap on all pages -->
+        <rng:optional>
+          <rng:attribute name="loext:wrap-text-at-frame-start">
+            <rng:ref name="boolean"/>
+          </rng:attribute>
+        </rng:optional>
         <!-- TODO: no proposal for loext:glow* -->
         <rng:optional>
           <rng:attribute name="loext:glow-radius">
diff --git a/xmloff/CppunitTest_xmloff_text.mk 
b/xmloff/CppunitTest_xmloff_text.mk
index 7fc0fa394950..73e5dbb8eaaa 100644
--- a/xmloff/CppunitTest_xmloff_text.mk
+++ b/xmloff/CppunitTest_xmloff_text.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_CppunitTest_use_externals,xmloff_text,\
 
 $(eval $(call gb_CppunitTest_add_exception_objects,xmloff_text, \
     xmloff/qa/unit/text \
+    xmloff/qa/unit/text/txtprmap \
 ))
 
 $(eval $(call gb_CppunitTest_use_libraries,xmloff_text, \
diff --git a/xmloff/inc/xmlprop.hxx b/xmloff/inc/xmlprop.hxx
index 31b500335891..d93e0b89fbf5 100644
--- a/xmloff/inc/xmlprop.hxx
+++ b/xmloff/inc/xmlprop.hxx
@@ -660,6 +660,7 @@ inline constexpr OUString PROP_Weight = u"Weight"_ustr;
 inline constexpr OUString PROP_Width = u"Width"_ustr;
 inline constexpr OUString PROP_WidthType = u"WidthType"_ustr;
 inline constexpr OUString PROP_WrapInfluenceOnPosition = 
u"WrapInfluenceOnPosition"_ustr;
+inline constexpr OUString PROP_WrapTextAtFlyStart = u"WrapTextAtFlyStart"_ustr;
 inline constexpr OUString PROP_WritingMode = u"WritingMode"_ustr;
 inline constexpr OUString PROP_XName = u"XName"_ustr;
 inline constexpr OUString PROP_YName = u"YName"_ustr;
diff --git a/xmloff/qa/unit/data/floattable-wrap-all-pages2.fodt 
b/xmloff/qa/unit/data/floattable-wrap-all-pages2.fodt
new file mode 100644
index 000000000000..e8289d66536d
--- /dev/null
+++ b/xmloff/qa/unit/data/floattable-wrap-all-pages2.fodt
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+  <office:styles>
+    <style:style style:name="Standard" style:family="paragraph" 
style:class="text">
+      <style:paragraph-properties fo:margin-top="0cm" 
fo:margin-bottom="0.282cm" fo:line-height="108%"/>
+    </style:style>
+    <style:style style:name="Frame" style:family="graphic"/>
+  </office:styles>
+  <office:automatic-styles>
+    <style:style style:name="Table1" style:family="table">
+      <style:table-properties style:width="6.743cm" fo:margin-left="0cm" 
fo:margin-top="0cm" fo:margin-bottom="0cm" table:align="left" 
style:writing-mode="lr-tb"/>
+    </style:style>
+    <style:style style:name="Table1.A" style:family="table-column">
+      <style:table-column-properties style:column-width="6.743cm"/>
+    </style:style>
+    <style:style style:name="Table1.1" style:family="table-row">
+      <style:table-row-properties style:min-row-height="3.196cm" 
fo:keep-together="auto"/>
+    </style:style>
+    <style:style style:name="Table1.A1" style:family="table-cell">
+      <style:table-cell-properties fo:padding-left="0.191cm" 
fo:padding-right="0.191cm" fo:padding-top="0cm" fo:padding-bottom="0cm" 
fo:border="0.5pt solid #000000" style:writing-mode="lr-tb"/>
+    </style:style>
+    <style:style style:name="Table1.2" style:family="table-row">
+      <style:table-row-properties style:min-row-height="2.489cm" 
fo:keep-together="auto"/>
+    </style:style>
+    <style:style style:name="fr1" style:family="graphic" 
style:parent-style-name="Frame">
+      <style:graphic-properties fo:margin-left="0.318cm" 
fo:margin-right="0.318cm" fo:margin-top="0cm" fo:margin-bottom="0cm" 
style:vertical-pos="from-top" style:vertical-rel="paragraph" 
style:horizontal-pos="from-left" style:horizontal-rel="paragraph" 
loext:wrap-text-at-frame-start="true"/>
+    </style:style>
+    <style:page-layout style:name="pm1">
+      <style:page-layout-properties fo:page-width="21.59cm" 
fo:page-height="10.941cm" fo:margin-top="2.54cm" fo:margin-bottom="2.54cm" 
fo:margin-left="2.54cm" fo:margin-right="2.54cm"/>
+    </style:page-layout>
+  </office:automatic-styles>
+  <office:master-styles>
+    <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+  </office:master-styles>
+  <office:body>
+    <office:text text:use-soft-page-breaks="true">
+      <text:p text:style-name="Standard">First paragraph</text:p>
+      <text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" 
draw:name="Frame1" text:anchor-type="paragraph" svg:x="-0.009cm" 
svg:y="0.002cm" svg:width="6.743cm" draw:z-index="1" 
loext:may-break-between-pages="true"><draw:text-box 
fo:min-height="0cm"><table:table table:name="Table1" 
table:style-name="Table1"><table:table-column 
table:style-name="Table1.A"/><table:table-row 
table:style-name="Table1.1"><table:table-cell table:style-name="Table1.A1" 
office:value-type="string"><text:p>A1</text:p></table:table-cell></table:table-row><table:table-row
 table:style-name="Table1.2"><table:table-cell table:style-name="Table1.A1" 
office:value-type="string"><text:p>A2</text:p></table:table-cell></table:table-row></table:table></draw:text-box></draw:frame>He
 heard quiet steps behind him. That didn&apos;t bode well. Who could be 
following him this late at night and in this deadbeat part of town? And at this 
particular moment, just after he pulled off the big time and was making off w
 ith the greenbacks. Was there another crook who&apos;d had the same idea, and 
was now watching him and waiting for a chance to grab the fruit of his labor? 
Or did the steps behind him mean that one of many law officers in town was on 
to him and just waiting to pounce and snap those cuffs on his wrists? He 
nervously looked all around. Suddenly he saw the alley. Like lightning he 
darted off to the left and disappeared between the two warehouses almost 
falling over the trash can lying in the middle of the sidewalk.</text:p>
+    </office:text>
+  </office:body>
+</office:document>
diff --git a/xmloff/qa/unit/text/txtprmap.cxx b/xmloff/qa/unit/text/txtprmap.cxx
new file mode 100644
index 000000000000..f40b04b3fdd1
--- /dev/null
+++ b/xmloff/qa/unit/text/txtprmap.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/unoapixml_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
+
+#include <comphelper/propertyvalue.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Covers xmloff/source/text/txtprmap.cxx fixes.
+class Test : public UnoApiXmlTest
+{
+public:
+    Test();
+};
+}
+
+Test::Test()
+    : UnoApiXmlTest("/xmloff/qa/unit/data/")
+{
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFloatingTableWrapTextAtFlyStartExport)
+{
+    // Given a document with a floating table:
+    mxComponent = loadFromDesktop("private:factory/swriter");
+    // Insert a table:
+    uno::Sequence<beans::PropertyValue> aArgs = {
+        comphelper::makePropertyValue("Rows", static_cast<sal_Int32>(1)),
+        comphelper::makePropertyValue("Columns", static_cast<sal_Int32>(1)),
+    };
+    dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+    // Select it:
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    // Wrap in a fly:
+    aArgs = {
+        comphelper::makePropertyValue("AnchorType", 
static_cast<sal_uInt16>(0)),
+    };
+    dispatchCommand(mxComponent, ".uno:InsertFrame", aArgs);
+    // Mark it as a floating table that wraps on all pages:
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFrame(
+        xTextFramesSupplier->getTextFrames()->getByName("Frame1"), 
uno::UNO_QUERY);
+    xFrame->setPropertyValue("IsSplitAllowed", uno::Any(true));
+    xFrame->setPropertyValue("WrapTextAtFlyStart", uno::Any(true));
+
+    // When saving to ODT:
+    save("writer8");
+
+    // Then make sure we write a floating table, that wraps on all pages:
+    xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
+    // Without the accompanying fix in place, this test would have failed with:
+    // - XPath '//style:graphic-properties' no attribute 
'wrap-text-at-frame-start' exist
+    // i.e. no floating table was exported.
+    assertXPath(pXmlDoc, "//style:graphic-properties"_ostr, 
"wrap-text-at-frame-start"_ostr,
+                "true");
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testFloatingTableWrapTextAtFlyStartImport)
+{
+    // Given a document with a floating table + wrap on all pages
+    // (loext:may-break-between-pages="true" and 
loext:wrap-text-at-frame-start="true"), when
+    // importing that document:
+    loadFromURL(u"floattable-wrap-all-pages2.fodt");
+
+    // Then make sure that the matching text frame property is set:
+    uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xFrame(
+        xTextFramesSupplier->getTextFrames()->getByName("Frame1"), 
uno::UNO_QUERY);
+    bool bWrapTextAtFlyStart = false;
+    // Without the accompanying fix in place, this test would have failed, the 
property was false.
+    xFrame->getPropertyValue("WrapTextAtFlyStart") >>= bWrapTextAtFlyStart;
+    CPPUNIT_ASSERT(bWrapTextAtFlyStart);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index e11dc0d16111..78ac1500e07a 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3549,6 +3549,7 @@ namespace xmloff::token {
         TOKEN("fill-use-slide-background", XML_FILL_USE_SLIDE_BACKGROUND),
 
         TOKEN("may-break-between-pages", XML_MAY_BREAK_BETWEEN_PAGES),
+        TOKEN("wrap-text-at-frame-start", XML_WRAP_TEXT_AT_FRAME_START),
 
         TOKEN("gradient-stop", XML_GRADIENT_STOP),
         TOKEN("opacity-stop", XML_OPACITY_STOP),
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 418d4e396ff2..cf6adc9a1927 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -876,6 +876,7 @@ XMLPropertyMapEntry constexpr aXMLFramePropMap[] =
     // #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS
     MG_E( PROP_WrapInfluenceOnPosition, XML_NAMESPACE_DRAW,   
XML_WRAP_INFLUENCE_ON_POSITION, XML_TYPE_WRAP_INFLUENCE_ON_POSITION, 0 ),
     MAP_EXT( PROP_AllowOverlap,         XML_NAMESPACE_LO_EXT, 
XML_ALLOW_OVERLAP,              XML_TYPE_BOOL|XML_TYPE_PROP_GRAPHIC, 0 ),
+    MAP_EXT( PROP_WrapTextAtFlyStart,   XML_NAMESPACE_LO_EXT, 
XML_WRAP_TEXT_AT_FRAME_START,   XML_TYPE_BOOL|XML_TYPE_PROP_GRAPHIC, 0 ),
 
     // special entries for floating frames
     MG_E( PROP_, XML_NAMESPACE_DRAW, XML_FRAME_DISPLAY_SCROLLBAR, 
XML_TYPE_BOOL|MID_FLAG_NO_PROPERTY|MID_FLAG_MULTI_PROPERTY, 
CTF_FRAME_DISPLAY_SCROLLBAR ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 7eb09f6f2f9f..882ad0e5978d 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -3291,6 +3291,7 @@ alias
 tag
 fill-use-slide-background
 may-break-between-pages
+wrap-text-at-frame-start
 gradient-stop
 opacity-stop
 color-value

Reply via email to