include/xmloff/xmltoken.hxx                                 |    1 
 sc/inc/dbdata.hxx                                           |    2 
 sc/qa/unit/data/ods/tdf162262_summarybelow.ods              |binary
 sc/qa/unit/subsequent_export_test4.cxx                      |   30 ++++++++++++
 sc/source/filter/xml/XMLExportDatabaseRanges.cxx            |    3 +
 sc/source/filter/xml/xmldrani.cxx                           |    5 ++
 sc/source/filter/xml/xmldrani.hxx                           |    2 
 schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng |    9 +++
 xmloff/source/core/xmltoken.cxx                             |    1 
 xmloff/source/token/tokens.txt                              |    1 
 10 files changed, 53 insertions(+), 1 deletion(-)

New commits:
commit dcf3a85e6e5d4c7761d73a9f018c0c09862351ce
Author:     Balazs Varga <balazs.varga.ext...@allotropia.de>
AuthorDate: Tue Nov 5 13:07:05 2024 +0100
Commit:     Balazs Varga <balazs.varga.ext...@allotropia.de>
CommitDate: Wed Nov 6 23:26:28 2024 +0100

    Related tdf#162262 - sc: odf import/export of "Summary below data"
    
    Add new LO_EXT "summary-below" attribute for table:subtotal-rules.
    
    Follow up commit: 26c08356d1b2a963efdca570979cb04388371400
    (tdf#162262 sc add "Summary below data" option for Subtotal dialog)
    
    Change-Id: Ie7f43d3c76479cd9468552b5939de5dbb2082a02
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176058
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <balazs.varga.ext...@allotropia.de>

diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 6c1eff448930..8dca0f669ed2 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -1928,6 +1928,7 @@ namespace xmloff::token {
         XML_SUB_VIEW_SIZE,
         XML_SUFFIX,
         XML_SUM,
+        XML_SUMMARY_BELOW,
         XML_SWISS,
         XML_SYMBOL,
         XML_SYMBOL_HEIGHT,
diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx
index c1164b064b17..532d71528e07 100644
--- a/sc/inc/dbdata.hxx
+++ b/sc/inc/dbdata.hxx
@@ -192,7 +192,7 @@ public:
     SC_DLLPUBLIC bool       GetAdvancedQuerySource(ScRange& rSource) const;
     SC_DLLPUBLIC void       SetAdvancedQuerySource(const ScRange* pSource);
 
-    void        GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const;
+    SC_DLLPUBLIC void       GetSubTotalParam(ScSubTotalParam& rSubTotalParam) 
const;
     void        SetSubTotalParam(const ScSubTotalParam& rSubTotalParam);
 
     void        GetImportParam(ScImportParam& rImportParam) const;
diff --git a/sc/qa/unit/data/ods/tdf162262_summarybelow.ods 
b/sc/qa/unit/data/ods/tdf162262_summarybelow.ods
new file mode 100644
index 000000000000..bd2eeba48d01
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf162262_summarybelow.ods 
differ
diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index f545e2bae160..ae856010b110 100644
--- a/sc/qa/unit/subsequent_export_test4.cxx
+++ b/sc/qa/unit/subsequent_export_test4.cxx
@@ -21,6 +21,8 @@
 #include <postit.hxx>
 #include <validat.hxx>
 #include <scresid.hxx>
+#include <dbdata.hxx>
+#include <subtotalparam.hxx>
 #include <globstr.hrc>
 
 #include <editeng/wghtitem.hxx>
@@ -410,6 +412,34 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf162262)
     assertXPath(pSheet, "/x:worksheet/x:sheetPr/x:outlinePr", "summaryBelow", 
u"0");
 }
 
+CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf162262_summarybelow)
+{
+    createScDoc("ods/tdf162262_summarybelow.ods");
+
+    ScDocument* pDoc = getScDoc();
+    ScDBCollection* pDBCollection = pDoc->GetDBCollection();
+    CPPUNIT_ASSERT(pDBCollection);
+    {
+        const ScDBData* pDBData = pDBCollection->GetDBAtArea(0, 0, 0, 1, 13);
+        CPPUNIT_ASSERT(pDBData);
+        ScSubTotalParam aParam;
+        pDBData->GetSubTotalParam(aParam);
+        CPPUNIT_ASSERT(!aParam.bSummaryBelow);
+    }
+
+    saveAndReload(u"calc8"_ustr);
+    pDoc = getScDoc();
+    pDBCollection = pDoc->GetDBCollection();
+    CPPUNIT_ASSERT(pDBCollection);
+    {
+        const ScDBData* pDBData = pDBCollection->GetDBAtArea(0, 0, 0, 1, 13);
+        CPPUNIT_ASSERT(pDBData);
+        ScSubTotalParam aParam;
+        pDBData->GetSubTotalParam(aParam);
+        CPPUNIT_ASSERT(!aParam.bSummaryBelow);
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf122331)
 {
     createScDoc("ods/tdf122331.ods");
diff --git a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx 
b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
index 9328b796a81b..d1817bc4ddc5 100644
--- a/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
+++ b/sc/source/filter/xml/XMLExportDatabaseRanges.cxx
@@ -658,6 +658,9 @@ private:
         if (aParam.bCaseSens)
             mrExport.AddAttribute(XML_NAMESPACE_TABLE, XML_CASE_SENSITIVE, 
XML_TRUE);
 
+        if (!aParam.bSummaryBelow)
+            mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_SUMMARY_BELOW, 
XML_FALSE);
+
         SvXMLElementExport aElemSTRs(mrExport, XML_NAMESPACE_TABLE, 
XML_SUBTOTAL_RULES, true, true);
 
         if (aParam.bDoSort)
diff --git a/sc/source/filter/xml/xmldrani.cxx 
b/sc/source/filter/xml/xmldrani.cxx
index 0e6c400c30bb..99a979319523 100644
--- a/sc/source/filter/xml/xmldrani.cxx
+++ b/sc/source/filter/xml/xmldrani.cxx
@@ -99,6 +99,7 @@ ScXMLDatabaseRangeContext::ScXMLDatabaseRangeContext( 
ScXMLImport& rImport,
     bSubTotalsBindFormatsToContent(false),
     bSubTotalsIsCaseSensitive(false),
     bSubTotalsInsertPageBreaks(false),
+    bSubTotalsSummaryBelow(true),
     bSubTotalsSortGroups(false),
     bSubTotalsEnabledUserList(false),
     bSubTotalsAscending(true),
@@ -333,6 +334,7 @@ std::unique_ptr<ScDBData> 
ScXMLDatabaseRangeContext::ConvertToDBData(const OUStr
         aParam.bUserDef = bSubTotalsEnabledUserList;
         aParam.nUserIndex = nSubTotalsUserListIndex;
         aParam.bPagebreak = bSubTotalsInsertPageBreaks;
+        aParam.bSummaryBelow = bSubTotalsSummaryBelow;
         aParam.bCaseSens = bSubTotalsIsCaseSensitive;
         aParam.bDoSort = bSubTotalsSortGroups;
         aParam.bAscending = bSubTotalsAscending;
@@ -642,6 +644,9 @@ ScXMLSubTotalRulesContext::ScXMLSubTotalRulesContext( 
ScXMLImport& rImport,
             case XML_ELEMENT( TABLE, XML_PAGE_BREAKS_ON_GROUP_CHANGE ):
                 
pDatabaseRangeContext->SetSubTotalsInsertPageBreaks(IsXMLToken(aIter, 
XML_TRUE));
                 break;
+            case XML_ELEMENT( LO_EXT, XML_SUMMARY_BELOW ):
+                
pDatabaseRangeContext->SetSubTotalsSummaryBelow(IsXMLToken(aIter, XML_TRUE));
+                break;
         }
     }
 }
diff --git a/sc/source/filter/xml/xmldrani.hxx 
b/sc/source/filter/xml/xmldrani.hxx
index 037d5710d52c..ebb6c8a37375 100644
--- a/sc/source/filter/xml/xmldrani.hxx
+++ b/sc/source/filter/xml/xmldrani.hxx
@@ -76,6 +76,7 @@ class ScXMLDatabaseRangeContext : public ScXMLImportContext
     bool            bSubTotalsBindFormatsToContent;
     bool            bSubTotalsIsCaseSensitive;
     bool            bSubTotalsInsertPageBreaks;
+    bool            bSubTotalsSummaryBelow;
     bool            bSubTotalsSortGroups;
     bool            bSubTotalsEnabledUserList;
     bool            bSubTotalsAscending;
@@ -107,6 +108,7 @@ public:
     void SetSubTotalsBindFormatsToContent(const bool bTemp ) { 
bSubTotalsBindFormatsToContent = bTemp; }
     void SetSubTotalsIsCaseSensitive(const bool bTemp) { 
bSubTotalsIsCaseSensitive = bTemp; }
     void SetSubTotalsInsertPageBreaks(const bool bTemp) { 
bSubTotalsInsertPageBreaks = bTemp; }
+    void SetSubTotalsSummaryBelow(const bool bTemp) { bSubTotalsSummaryBelow = 
bTemp; }
     void SetSubTotalsEnabledUserList(const bool bTemp) { 
bSubTotalsEnabledUserList = bTemp; }
     void SetSubTotalsUserListIndex(const sal_Int16 nTemp) { 
nSubTotalsUserListIndex = nTemp; }
     void SetSubTotalsAscending(const bool bTemp) { bSubTotalsAscending = 
bTemp; }
diff --git a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng 
b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng
index 5f53d50c8526..d24889bce097 100644
--- a/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng
+++ b/schema/libreoffice/OpenDocument-v1.4+libreoffice-schema.rng
@@ -2744,6 +2744,15 @@ 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.
     </rng:optional>
   </rng:define>
 
+    <!-- TODO no proposal, tdf#162262 -->
+  <rng:define name="table-subtotal-rules-attlist" combine="interleave">
+    <rng:optional>
+      <rng:attribute name="loext:summary-below">
+        <rng:ref name="boolean"/>
+      </rng:attribute>
+    </rng:optional>
+  </rng:define>
+
     <!-- TODO no proposal, 9009663d -->
   <rng:define name="chart-chart-attlist" combine="interleave">
     <rng:optional>
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 92440718d77e..70c1f0ec01c0 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1941,6 +1941,7 @@ namespace xmloff::token {
         TOKEN( "sub-view-size",                   XML_SUB_VIEW_SIZE ),
         TOKEN( "suffix",                          XML_SUFFIX ),
         TOKEN( "sum",                             XML_SUM ),
+        TOKEN( "summary-below",                   XML_SUMMARY_BELOW ),
         TOKEN( "swiss",                           XML_SWISS ),
         TOKEN( "symbol",                          XML_SYMBOL ),
         TOKEN( "symbol-height",                   XML_SYMBOL_HEIGHT ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 6eb3f7612766..2f7f867a84e3 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1841,6 +1841,7 @@ subtotal-rules
 sub-view-size
 suffix
 sum
+summary-below
 swiss
 symbol
 symbol-height

Reply via email to