[Libreoffice-commits] core.git: sw/source

Serge Krot Serge.Krot at cib.de
Fri Oct 6 17:15:26 UTC 2017


 sw/source/filter/ww8/docxexport.cxx |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

New commits:
commit 4054051cd5aee8cbc6cd2b3384b4ab3d6b6a6ace
Author: Serge Krot <Serge.Krot at cib.de>
Date:   Mon Oct 2 17:51:24 2017 +0200

    tdf#66398 Do not output document protection in docx twice
    
    Change-Id: I16a5f2d3b8ef59e6edfdecd9d2bd19a2c10c80ea
    Reviewed-on: https://gerrit.libreoffice.org/43158
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 8e6b8d5cce21..4ecd04f7d425 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -965,6 +965,7 @@ void DocxExport::WriteSettings()
     // Has themeFontLang information
     uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
 
+    bool hasProtectionProperties = false;
     uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
     const OUString aGrabBagName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
     if ( xPropSetInfo->hasPropertyByName( aGrabBagName ) )
@@ -1057,8 +1058,12 @@ void DocxExport::WriteSettings()
 
                 if (rAttributeList.getLength())
                 {
+                    // we have document protection from from input DOCX file
+
                     sax_fastparser::XFastAttributeListRef xAttributeList(pAttributeList);
                     pFS->singleElementNS(XML_w, XML_documentProtection, xAttributeList);
+
+                    hasProtectionProperties = true;
                 }
             }
         }
@@ -1066,13 +1071,18 @@ void DocxExport::WriteSettings()
 
     // Protect form
     // Section-specific write protection
-    if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM) ||
-        m_pSections->DocumentIsProtected())
+    if (! hasProtectionProperties)
     {
-        pFS->singleElementNS(XML_w, XML_documentProtection,
-            FSNS(XML_w, XML_edit), "forms",
-            FSNS(XML_w, XML_enforcement), "true",
-            FSEND);
+        if (m_pDoc->getIDocumentSettingAccess().get(DocumentSettingId::PROTECT_FORM) ||
+            m_pSections->DocumentIsProtected())
+        {
+            // we have form protection from Writer or from input ODT file
+
+            pFS->singleElementNS(XML_w, XML_documentProtection,
+                FSNS(XML_w, XML_edit), "forms",
+                FSNS(XML_w, XML_enforcement), "true",
+                FSEND);
+        }
     }
 
     // finish settings.xml


More information about the Libreoffice-commits mailing list