sw/inc/tblafmt.hxx                              |    1 +
 sw/source/core/doc/tblafmt.cxx                  |    7 +++++++
 sw/source/core/text/EnhancedPDFExportHelper.cxx |   17 +++++++++++++++++
 3 files changed, 25 insertions(+)

New commits:
commit fff2b5d06c24bb36a498bdb869158ee09c487111
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Mon Mar 13 14:59:03 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Mon Mar 13 18:35:03 2023 +0000

    tdf#153935 sw: PDF/UA export: guess table headers based on autoformat
    
    This is a bit of a disaster area because in contrast to SdrTableObj
    (see commit 0bc96b8805f2cfa2278729a9f3e56a350ddd69ad)
    the SwTableAutoFormat application doesn't have flags which "special"
    formattings like "first-row" etc. should be applied to the table.
    
    So add a horrible heuristic to guess depending on the content of its
    formatting attributes.
    
    Change-Id: Ie09538d37de6118409b04a4cec6ab46b74c4194d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148793
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx
index c056810450be..2f6c8f788f11 100644
--- a/sw/inc/tblafmt.hxx
+++ b/sw/inc/tblafmt.hxx
@@ -238,6 +238,7 @@ public:
     bool FirstRowStartColumnIsRow();
     bool LastRowEndColumnIsRow();
     bool LastRowStartColumnIsRow();
+    bool HasHeaderRow() const;
 
     bool Load( SvStream& rStream, const SwAfVersions& );
     bool Save( SvStream& rStream, sal_uInt16 fileVersion ) const;
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index fdfe2702149b..d90760532a44 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -731,6 +731,13 @@ bool SwTableAutoFormat::LastRowStartColumnIsRow()
 {
     return GetBoxFormat(12) == GetBoxFormat(13);
 }
+bool SwTableAutoFormat::HasHeaderRow() const
+{   // Wild guessing for PDF export: is header different from odd or body?
+    // It would be vastly better to do like SdrTableObj and have flags that
+    // determine which "special" styles apply, instead of horrible guessing.
+    return !(GetBoxFormat(1) == GetBoxFormat(5))
+        || !(GetBoxFormat(1) == GetBoxFormat(10));
+}
 
 bool SwTableAutoFormat::Load( SvStream& rStream, const SwAfVersions& rVersions 
)
 {
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx 
b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 9939d0237cd1..fa5f05bc6854 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -80,6 +80,7 @@
 #include <frmtool.hxx>
 #include <strings.hrc>
 #include <frameformats.hxx>
+#include <tblafmt.hxx>
 #include <authfld.hxx>
 #include <dcontact.hxx>
 
@@ -190,6 +191,22 @@ bool lcl_IsHeadlineCell( const SwCellFrame& rCellFrame )
         bRet = sStyleName == aTableHeadingName;
     }
 
+    // tdf#153935 wild guessing for 1st row based on table autoformat
+    if (!bRet && !rCellFrame.GetUpper()->GetPrev())
+    {
+        SwTable const*const pTable(rCellFrame.FindTabFrame()->GetTable());
+        assert(pTable);
+        OUString const& rStyleName(pTable->GetTableStyleName());
+        if (!rStyleName.isEmpty())
+        {
+            if (SwTableAutoFormat const*const pTableAF =
+                
pTable->GetFrameFormat()->GetDoc()->GetTableStyles().FindAutoFormat(rStyleName))
+            {
+                bRet |= pTableAF->HasHeaderRow();
+            }
+        }
+    }
+
     return bRet;
 }
 

Reply via email to