sw/inc/editsh.hxx                           |    7 +++++--
 sw/source/core/doc/DocumentTimerManager.cxx |    4 ++++
 sw/source/core/edit/edfcol.cxx              |    7 ++++---
 sw/source/core/edit/edws.cxx                |   11 ++++-------
 4 files changed, 17 insertions(+), 12 deletions(-)

New commits:
commit deaf934e3c62b554704d1d3548ac699ea6d308ab
Author:     Ashod Nakashian <[email protected]>
AuthorDate: Wed Oct 3 05:53:28 2018 -0400
Commit:     Ashod Nakashian <[email protected]>
CommitDate: Thu Dec 26 04:36:10 2019 +0100

    sw: paragraph-sign: process signatures in one pass on loading
    
    This combines the metadata field restoration logic with
    validation/update of said field in one pass upon loading docs.
    This cuts down overheads and makes the code more readable.
    
    In addition, now that paragraph signature validation is quite
    cheap (separate commits), esp. when no signatures exist, we
    validate and update signatures (where applicable) when fields
    are updated.
    
    Change-Id: I4adcea579c591f9be457ed742d2cf54fa308163d
    Reviewed-on: https://gerrit.libreoffice.org/63008
    Tested-by: Jenkins
    Reviewed-by: Ashod Nakashian <[email protected]>
    (cherry picked from commit ad9902f34dd0b5837ab518445ea9f3a24352738b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85809
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 74323492d538..32c0b8014f2f 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -375,8 +375,11 @@ public:
     /// Validate all paragraph signatures.
     void ValidateAllParagraphSignatures(bool updateDontRemove);
 
-    /// Restore the metadata fields, if missing, from the RDF metadata.
-    void RestoreMetadataFields();
+    /// Restore the metadata fields, if missing, from the RDF metadata
+    /// and validate the signatures and update the signature metadata fields.
+    /// Needed since deleting the metadata field doesn't remove the RDF
+    /// and editing docs using software that don't support paragraph signing.
+    void RestoreMetadataFieldsAndValidateParagraphSignatures();
 
     /// Ensure that the classification of the doc is never lower than
     /// the paragraph with the highest classification.
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx 
b/sw/source/core/doc/DocumentTimerManager.cxx
index d290e70942b8..86afcb9107fa 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -35,6 +35,7 @@
 #include <fldbas.hxx>
 #include <vcl/scheduler.hxx>
 #include <comphelper/lok.hxx>
+#include <editsh.hxx>
 
 namespace sw
 {
@@ -201,6 +202,9 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, 
void )
         m_rDoc.getIDocumentFieldsAccess().UpdateTableFields(nullptr);  // 
Tables
         m_rDoc.getIDocumentFieldsAccess().UpdateRefFields();  // References
 
+        // Validate and update the paragraph signatures.
+        m_rDoc.GetEditShell()->ValidateAllParagraphSignatures(true);
+
         pTmpRoot->EndAllAction();
 
         pShell->LockView( bOldLockView );
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index b97ce353a840..e2014a101966 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1902,7 +1902,7 @@ static uno::Reference<text::XTextField> 
lcl_GetParagraphMetadataFieldAtIndex(con
     return xTextField;
 }
 
-void SwEditShell::RestoreMetadataFields()
+void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures()
 {
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
     if (!pDocShell || !IsParagraphSignatureValidationEnabled())
@@ -2028,6 +2028,7 @@ void SwEditShell::RestoreMetadataFields()
                 }
             }
 
+            lcl_ValidateParagraphSignatures(GetDoc(), xParagraph, true); // 
Validate and Update signatures.
         }
         catch (const std::exception&)
         {
@@ -2118,7 +2119,7 @@ static OUString 
lcl_GetHighestClassificationParagraphClass(SwPaM* pCursor)
     while (xParagraphs->hasMoreElements())
     {
         uno::Reference<text::XTextContent> 
xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY);
-        OUString sCurrentClass = lcl_GetParagraphClassification(aHelper, 
aKeyCreator, xModel, xParagraph);
+        const OUString sCurrentClass = lcl_GetParagraphClassification(aHelper, 
aKeyCreator, xModel, xParagraph);
         sHighestClass = aHelper.GetHigherClass(sHighestClass, sCurrentClass);
     }
 
@@ -2131,7 +2132,7 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass()
     if (!pDocShell)
         return;
 
-    // bail out as early as possible if we don't have paragraph classification
+    // Bail out as early as possible if we don't have paragraph classification.
     if (!SwRDFHelper::hasMetadataGraph(pDocShell->GetBaseModel(), MetaNS))
         return;
 
diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx
index 9ed3970fc164..dd5381cbb9eb 100644
--- a/sw/source/core/edit/edws.cxx
+++ b/sw/source/core/edit/edws.cxx
@@ -17,11 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <editsh.hxx>
+
 #include <officecfg/Office/Common.hxx>
 #include <unotools/configmgr.hxx>
 #include <vcl/window.hxx>
 
-#include <editsh.hxx>
 #include <doc.hxx>
 #include <IDocumentUndoRedo.hxx>
 #include <IDocumentState.hxx>
@@ -52,12 +53,8 @@ SwEditShell::SwEditShell( SwDoc& rDoc, vcl::Window *pWindow, 
const SwViewOption
         GetDoc()->GetIDocumentUndoRedo().DoUndo(true);
     }
 
-    // Restore the tscp metadata fields
-    RestoreMetadataFields();
-
-    // Update the paragraph signatures.
-    // Since this ctor is called only on creating/loading the doc, we validate 
once only.
-    ValidateAllParagraphSignatures(true);
+    // Restore the paragraph metadata fields and validate signatures.
+    RestoreMetadataFieldsAndValidateParagraphSignatures();
 }
 
 SwEditShell::~SwEditShell() // USED
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to