sw/inc/editsh.hxx                 |    2 +-
 sw/source/core/crsr/pam.cxx       |    2 +-
 sw/source/core/edit/edfcol.cxx    |   36 +++++++++++++++---------------------
 sw/source/uibase/app/docsh2.cxx   |    2 +-
 sw/source/uibase/fldui/fldmgr.cxx |    2 +-
 5 files changed, 19 insertions(+), 25 deletions(-)

New commits:
commit ebc378519cc66b2d55ae421fd362456e9b041766
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Sep 24 21:05:34 2017 -0400

    TSCP: cleanup constant strings
    
    Change-Id: I5c307db7ef1c5980c9ae7706ae95970b5705ab58
    Reviewed-on: https://gerrit.libreoffice.org/42740
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 488572415a2b..dc7314e4896e 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -734,7 +734,7 @@ bool SwPaM::HasReadonlySel( bool bFormView ) const
                         const css::uno::Reference<css::rdf::XResource> 
xSubject(pMeta->MakeUnoObject(), uno::UNO_QUERY);
                         uno::Reference<frame::XModel> xModel = 
pDocSh->GetBaseModel();
                         const std::map<OUString, OUString> aStatements = 
SwRDFHelper::getStatements(xModel, metaNS, xSubject);
-                        bRet = (aStatements.find("loext:signature:signature") 
!= aStatements.end());
+                        bRet = (aStatements.find("loext:paragraph:signature") 
!= aStatements.end());
                     }
                 }
             }
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 9b96fd2bd7c6..9ab83df7e36f 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -87,6 +87,10 @@
 
 namespace
 {
+static const OUString MetaFilename("bails.rdf");
+static const OUString MetaNS("urn:bails");
+static const OUString ParagraphSignatureRDFName = "loext:paragraph:signature";
+static const OUString MetadataFieldServiceName = 
"com.sun.star.text.textfield.MetadataField";
 
 /// Find all page styles which are currently used in the document.
 std::vector<OUString> lcl_getUsedPageStyles(SwViewShell const * pShell)
@@ -226,14 +230,12 @@ lcl_MakeParagraphSignatureFieldText(const 
uno::Reference<frame::XModel>& xModel,
                                     const 
uno::Reference<css::text::XTextField>& xField,
                                     const OString& utf8Text)
 {
-    static const OUString metaNS("urn:bails");
-
     OUString msg = SwResId(STR_INVALID_SIGNATURE);
     bool valid = false;
 
     const css::uno::Reference<css::rdf::XResource> xSubject(xField, 
uno::UNO_QUERY);
-    std::map<OUString, OUString> aStatements = 
SwRDFHelper::getStatements(xModel, metaNS, xSubject);
-    const auto it = aStatements.find("loext:signature:signature");
+    std::map<OUString, OUString> aStatements = 
SwRDFHelper::getStatements(xModel, MetaNS, xSubject);
+    const auto it = aStatements.find(ParagraphSignatureRDFName);
     if (it != aStatements.end())
     {
         const sal_Char* pData = utf8Text.getStr();
@@ -263,13 +265,8 @@ uno::Reference<text::XTextField> 
lcl_InsertParagraphSignature(const uno::Referen
                                                               const 
uno::Reference<text::XTextContent>& xParent,
                                                               const OUString& 
signature)
 {
-    static const OUString MetaFilename("bails.rdf");
-    static const OUString MetaNS("urn:bails");
-    static const OUString RDFName = "loext:signature:signature";
-    static const OUString ServiceName = 
"com.sun.star.text.textfield.MetadataField";
-
     uno::Reference<lang::XMultiServiceFactory> xMultiServiceFactory(xModel, 
uno::UNO_QUERY);
-    auto xField = 
uno::Reference<text::XTextField>(xMultiServiceFactory->createInstance(ServiceName),
 uno::UNO_QUERY);
+    auto xField = 
uno::Reference<text::XTextField>(xMultiServiceFactory->createInstance(MetadataFieldServiceName),
 uno::UNO_QUERY);
 
     // Add the signature at the end.
     // uno::Reference<text::XTextContent> xContent(xField, uno::UNO_QUERY);
@@ -277,7 +274,7 @@ uno::Reference<text::XTextField> 
lcl_InsertParagraphSignature(const uno::Referen
     xField->attach(xParent->getAnchor()->getEnd());
 
     const css::uno::Reference<css::rdf::XResource> xSubject(xField, 
uno::UNO_QUERY);
-    SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xSubject, RDFName, 
signature);
+    SwRDFHelper::addStatement(xModel, MetaNS, MetaFilename, xSubject, 
ParagraphSignatureRDFName, signature);
 
     return xField;
 }
@@ -307,7 +304,7 @@ bool lcl_UpdateParagraphSignatureField(SwDoc* pDoc,
     return false;
 }
 
-void lcl_RemoveParagraphSignatureField(const 
uno::Reference<css::text::XTextField>& xField)
+void lcl_RemoveParagraphMetadataField(const 
uno::Reference<css::text::XTextField>& xField)
 {
     uno::Reference<css::text::XTextContent> xFieldTextContent(xField, 
uno::UNO_QUERY);
     uno::Reference<css::text::XTextRange> 
xParagraph(xFieldTextContent->getAnchor());
@@ -969,11 +966,10 @@ SwUndoParagraphSigning::SwUndoParagraphSigning(const 
SwPosition& rPos,
     m_bRemove(bRemove)
 {
     // Save the metadata and field content to undo/redo.
-    static const OUString metaNS("urn:bails");
     uno::Reference<frame::XModel> xModel = 
m_pDoc->GetDocShell()->GetBaseModel();
     const css::uno::Reference<css::rdf::XResource> xSubject(m_xField, 
uno::UNO_QUERY);
-    std::map<OUString, OUString> aStatements = 
SwRDFHelper::getStatements(xModel, metaNS, xSubject);
-    const auto it = aStatements.find("loext:signature:signature");
+    std::map<OUString, OUString> aStatements = 
SwRDFHelper::getStatements(xModel, MetaNS, xSubject);
+    const auto it = aStatements.find(ParagraphSignatureRDFName);
     if (it != aStatements.end())
         m_signature = it->second;
 
@@ -1037,7 +1033,7 @@ void SwUndoParagraphSigning::Remove()
             m_pDoc->GetIDocumentUndoRedo().DoUndo(isUndoEnabled);
         });
 
-    lcl_RemoveParagraphSignatureField(m_xField);
+    lcl_RemoveParagraphMetadataField(m_xField);
 }
 
 void SwEditShell::SignParagraph()
@@ -1154,7 +1150,7 @@ void SwEditShell::ValidateParagraphSignatures(bool 
updateDontRemove)
             
GetDoc()->GetIDocumentUndoRedo().StartUndo(SwUndoId::PARA_SIGN_ADD, nullptr);
             SwUndoParagraphSigning* pUndo = new 
SwUndoParagraphSigning(SwPosition(*pNode), xContent, xParent, false);
             GetDoc()->GetIDocumentUndoRedo().AppendUndo(pUndo);
-            lcl_RemoveParagraphSignatureField(xContent);
+            lcl_RemoveParagraphMetadataField(xContent);
             GetDoc()->GetIDocumentUndoRedo().EndUndo(SwUndoId::PARA_SIGN_ADD, 
nullptr);
         }
     }
commit 2c5973410c034bdb8c36d118506b1d4230a83a9a
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Sep 24 19:54:31 2017 -0400

    TSCP: paragraph signing implicitly done at cursor
    
    Change-Id: I9fc01072373dac0cade7b30c3654827bd82d78cc
    Reviewed-on: https://gerrit.libreoffice.org/42739
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 9ca6bb683941..50c5bf75e44e 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -375,7 +375,7 @@ public:
     void SetWatermark(const SfxWatermarkItem& rText);
 
     /// Sign the paragraph at the cursor.
-    void SignParagraph(SwPaM* pPaM);
+    void SignParagraph();
 
     /// Validate paragraph signatures, if any, at the cursor.
     void ValidateParagraphSignatures(bool updateDontRemove);
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index bf724e02c936..9b96fd2bd7c6 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -1040,14 +1040,12 @@ void SwUndoParagraphSigning::Remove()
     lcl_RemoveParagraphSignatureField(m_xField);
 }
 
-void SwEditShell::SignParagraph(SwPaM* pPaM)
+void SwEditShell::SignParagraph()
 {
-    if (!pPaM)
-        return;
     SwDocShell* pDocShell = GetDoc()->GetDocShell();
     if (!pDocShell)
         return;
-    const SwPosition* pPosStart = pPaM->Start();
+    const SwPosition* pPosStart = GetCursor()->Start();
     if (!pPosStart)
         return;
     SwTextNode* pNode = pPosStart->nNode.GetNode().GetTextNode();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index a3708b58df91..3b2e5f8507ac 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -1183,7 +1183,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
             SwWrtShell* pShell = GetWrtShell();
             ScopedVclPtr<svx::ClassificationDialog> 
pDialog(VclPtr<svx::ClassificationDialog>::Create(nullptr, true, [pShell]()
             {
-                pShell->SignParagraph(pShell->GetCursor());
+                pShell->SignParagraph();
             }));
 
             std::vector<svx::ClassificationResult> aInput = 
pShell->CollectAdvancedClassification();
diff --git a/sw/source/uibase/fldui/fldmgr.cxx 
b/sw/source/uibase/fldui/fldmgr.cxx
index 875b923ffdc8..d04aa3c1c03b 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -1461,7 +1461,7 @@ bool SwFieldMgr::InsertField(
         // Insert Paragraph Signature field by signing the paragraph.
         // The resulting field is really a metadata field, created and added 
via signing.
         case TYP_PARAGRAPHSIGFLD:
-            pCurShell->SignParagraph(pCurShell->GetCursor());
+            pCurShell->SignParagraph();
             return true;
         break;
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to