officecfg/registry/schema/org/openoffice/Office/Writer.xcs |   11 ++++++
 sw/source/filter/html/wrthtml.cxx                          |   21 +++++++++----
 2 files changed, 26 insertions(+), 6 deletions(-)

New commits:
commit c3549e7857d53af25857ae50ea881cd22737d907
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Oct 20 23:35:52 2022 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Mon Nov 7 08:32:05 2022 +0100

    tdf#151605 Don't include hidden text by default in HTML filter
    
    Exclude hidden text from HTML filter (and add an option to change the 
behavior).
    
    Change-Id: I232fda1a283090229b8716532c646bcc6824a7f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141606
    Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>

diff --git a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
index 520737ab7e24..012ca4073fe3 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Writer.xcs
@@ -6492,6 +6492,17 @@
           <value>0</value>
         </prop>
       </group>
+      <group oor:name="HTML">
+        <info>
+          <desc>Contains settings for the HTML filter.</desc>
+        </info>
+        <prop oor:name="IncludeHiddenText" oor:type="xs:boolean" 
oor:nillable="false">
+            <info>
+              <desc>Whether hidden text (sections, etc) is included in the 
output.</desc>
+            </info>
+            <value>false</value>
+          </prop>
+      </group>
     </group>
     <group oor:name="Wizards">
       <info>
diff --git a/sw/source/filter/html/wrthtml.cxx 
b/sw/source/filter/html/wrthtml.cxx
index 7134d787b8ca..a3b900b6a222 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -83,6 +83,7 @@
 #include <unotools/tempfile.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <officecfg/Office/Common.hxx>
+#include <officecfg/Office/Writer.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/sequence.hxx>
 
@@ -881,6 +882,7 @@ static Writer& OutHTML_Section( Writer& rWrt, const 
SwSectionNode& rSectNd )
 void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
 {
     bool bSaveWriteAll = m_bWriteAll;     // save
+    bool bIncludeHidden = 
officecfg::Office::Writer::FilterFlags::HTML::IncludeHiddenText::get();
 
     // search next text::Bookmark position from text::Bookmark table
     m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( *m_pCurrentPam->GetPoint() ) : 
-1;
@@ -901,14 +903,17 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
 
             OSL_ENSURE( !(rNd.IsGrfNode() || rNd.IsOLENode()),
                     "Unexpected Grf- or OLE-Node here" );
+
             if( rNd.IsTextNode() )
             {
                 SwTextNode* pTextNd = rNd.GetTextNode();
+                if (!pTextNd->IsHidden() || bIncludeHidden)
+                {
+                    if (!m_bFirstLine)
+                        m_pCurrentPam->GetPoint()->Assign(*pTextNd, 0);
 
-                if( !m_bFirstLine )
-                    m_pCurrentPam->GetPoint()->Assign( *pTextNd, 0 );
-
-                OutHTML_SwTextNode( *this, *pTextNd );
+                    OutHTML_SwTextNode(*this, *pTextNd);
+                }
             }
             else if( rNd.IsTableNode() )
             {
@@ -917,8 +922,12 @@ void SwHTMLWriter::Out_SwDoc( SwPaM* pPam )
             }
             else if( rNd.IsSectionNode() )
             {
-                OutHTML_Section( *this, *rNd.GetSectionNode() );
-                m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( 
*m_pCurrentPam->GetPoint() ) : -1;
+                SwSectionNode* pSectionNode = rNd.GetSectionNode();
+                if (!pSectionNode->GetSection().IsHiddenFlag() || 
bIncludeHidden)
+                {
+                    OutHTML_Section( *this, *pSectionNode );
+                    m_nBkmkTabPos = m_bWriteAll ? FindPos_Bkmk( 
*m_pCurrentPam->GetPoint() ) : -1;
+                }
             }
             else if( &rNd == &m_pDoc->GetNodes().GetEndOfContent() )
                 break;

Reply via email to