Kaydet (Commit) 5d6102ce authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

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: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst dd2972d4
...@@ -375,8 +375,11 @@ public: ...@@ -375,8 +375,11 @@ public:
/// Validate all paragraph signatures. /// Validate all paragraph signatures.
void ValidateAllParagraphSignatures(bool updateDontRemove); void ValidateAllParagraphSignatures(bool updateDontRemove);
/// Restore the metadata fields, if missing, from the RDF metadata. /// Restore the metadata fields, if missing, from the RDF metadata
void RestoreMetadataFields(); /// 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 /// Ensure that the classification of the doc is never lower than
/// the paragraph with the highest classification. /// the paragraph with the highest classification.
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <fldbas.hxx> #include <fldbas.hxx>
#include <vcl/scheduler.hxx> #include <vcl/scheduler.hxx>
#include <comphelper/lok.hxx> #include <comphelper/lok.hxx>
#include <editsh.hxx>
namespace sw namespace sw
{ {
...@@ -199,6 +200,9 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void ) ...@@ -199,6 +200,9 @@ IMPL_LINK_NOARG( DocumentTimerManager, DoIdleJobs, Timer*, void )
m_rDoc.getIDocumentFieldsAccess().UpdateTableFields(nullptr); // Tables m_rDoc.getIDocumentFieldsAccess().UpdateTableFields(nullptr); // Tables
m_rDoc.getIDocumentFieldsAccess().UpdateRefFields(); // References m_rDoc.getIDocumentFieldsAccess().UpdateRefFields(); // References
// Validate and update the paragraph signatures.
m_rDoc.GetEditShell()->ValidateAllParagraphSignatures(true);
pTmpRoot->EndAllAction(); pTmpRoot->EndAllAction();
pShell->LockView( bOldLockView ); pShell->LockView( bOldLockView );
......
...@@ -1902,7 +1902,7 @@ static uno::Reference<text::XTextField> lcl_GetParagraphMetadataFieldAtIndex(con ...@@ -1902,7 +1902,7 @@ static uno::Reference<text::XTextField> lcl_GetParagraphMetadataFieldAtIndex(con
return xTextField; return xTextField;
} }
void SwEditShell::RestoreMetadataFields() void SwEditShell::RestoreMetadataFieldsAndValidateParagraphSignatures()
{ {
SwDocShell* pDocShell = GetDoc()->GetDocShell(); SwDocShell* pDocShell = GetDoc()->GetDocShell();
if (!pDocShell || !IsParagraphSignatureValidationEnabled()) if (!pDocShell || !IsParagraphSignatureValidationEnabled())
...@@ -2028,6 +2028,7 @@ void SwEditShell::RestoreMetadataFields() ...@@ -2028,6 +2028,7 @@ void SwEditShell::RestoreMetadataFields()
} }
} }
lcl_ValidateParagraphSignatures(GetDoc(), xParagraph, true); // Validate and Update signatures.
} }
catch (const std::exception&) catch (const std::exception&)
{ {
...@@ -2118,7 +2119,7 @@ static OUString lcl_GetHighestClassificationParagraphClass(SwPaM* pCursor) ...@@ -2118,7 +2119,7 @@ static OUString lcl_GetHighestClassificationParagraphClass(SwPaM* pCursor)
while (xParagraphs->hasMoreElements()) while (xParagraphs->hasMoreElements())
{ {
uno::Reference<text::XTextContent> xParagraph(xParagraphs->nextElement(), uno::UNO_QUERY); 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); sHighestClass = aHelper.GetHigherClass(sHighestClass, sCurrentClass);
} }
...@@ -2131,7 +2132,7 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass() ...@@ -2131,7 +2132,7 @@ void SwEditShell::ClassifyDocPerHighestParagraphClass()
if (!pDocShell) if (!pDocShell)
return; 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)) if (!SwRDFHelper::hasMetadataGraph(pDocShell->GetBaseModel(), MetaNS))
return; return;
......
...@@ -17,11 +17,12 @@ ...@@ -17,11 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <editsh.hxx>
#include <officecfg/Office/Common.hxx> #include <officecfg/Office/Common.hxx>
#include <unotools/configmgr.hxx> #include <unotools/configmgr.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <editsh.hxx>
#include <doc.hxx> #include <doc.hxx>
#include <IDocumentUndoRedo.hxx> #include <IDocumentUndoRedo.hxx>
#include <IDocumentState.hxx> #include <IDocumentState.hxx>
...@@ -52,12 +53,8 @@ SwEditShell::SwEditShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption ...@@ -52,12 +53,8 @@ SwEditShell::SwEditShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption
GetDoc()->GetIDocumentUndoRedo().DoUndo(true); GetDoc()->GetIDocumentUndoRedo().DoUndo(true);
} }
// Restore the tscp metadata fields // Restore the paragraph metadata fields and validate signatures.
RestoreMetadataFields(); RestoreMetadataFieldsAndValidateParagraphSignatures();
// Update the paragraph signatures.
// Since this ctor is called only on creating/loading the doc, we validate once only.
ValidateAllParagraphSignatures(true);
} }
SwEditShell::~SwEditShell() // USED SwEditShell::~SwEditShell() // USED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment