sw/inc/GrammarContact.hxx                 |    7 ++++---
 sw/source/core/doc/docnew.cxx             |   13 -------------
 sw/source/core/text/txtfrm.cxx            |    2 +-
 sw/source/core/txtnode/GrammarContact.cxx |   17 ++++++++++++++---
 sw/source/core/unocore/unoflatpara.cxx    |    2 +-
 sw/source/core/unocore/unotextmarkup.cxx  |    8 ++++----
 6 files changed, 24 insertions(+), 25 deletions(-)

New commits:
commit 8e2deed1457e3ab712df2820331136d531927522
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Oct 14 13:51:51 2022 +0200
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Mon Oct 24 20:04:57 2022 +0200

    sw: Move getGrammarContact function into GrammarContact and rename
    
    Change-Id: Id89d7eabb465f047188f8f74bd823cfb3b2f2aff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141433
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sw/inc/GrammarContact.hxx b/sw/inc/GrammarContact.hxx
index f2dc8ebe0ee2..9cc24121158b 100644
--- a/sw/inc/GrammarContact.hxx
+++ b/sw/inc/GrammarContact.hxx
@@ -82,12 +82,13 @@ public:
 /** getGrammarContact() delivers the grammar contact of the document (for a 
given textnode)
 @returns grammar contact
 */
-GrammarContact* getGrammarContact(const SwTextNode&);
+GrammarContact* getGrammarContactFor(const SwTextNode&);
 
 /** finishGrammarCheck() calls the same function of the grammar contact of the 
document (for a given textnode)
 @returns void
 */
-void finishGrammarCheck(SwTextNode&);
-}
+void finishGrammarCheckFor(SwTextNode&);
+
+} // end sw
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 01cd2062cc74..bd80ba17d261 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -808,19 +808,6 @@ void SwDoc::WriteLayoutCache( SvStream& rStream )
     SwLayoutCache::Write( rStream, *this );
 }
 
-namespace sw
-{
-
-sw::GrammarContact* getGrammarContact(const SwTextNode& rTextNode)
-{
-    const SwDoc& rDoc = rTextNode.GetDoc();
-    if (rDoc.IsInDtor())
-        return nullptr;
-    return rDoc.getGrammarContact().get();
-}
-
-} // end sw
-
 ::sfx2::IXmlIdRegistry&
 SwDoc::GetXmlIdRegistry()
 {
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 07640f318534..ddd2ef9c0acf 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -1801,7 +1801,7 @@ static void lcl_SetWrong( SwTextFrame& rFrame, SwTextNode 
const& rNode,
     if ( !rFrame.IsFollow() )
     {
         SwTextNode* pTextNode = const_cast<SwTextNode*>(&rNode);
-        sw::GrammarContact* pGrammarContact = getGrammarContact(*pTextNode);
+        sw::GrammarContact* pGrammarContact = 
sw::getGrammarContactFor(*pTextNode);
         SwGrammarMarkUp* pWrongGrammar = pGrammarContact ?
             pGrammarContact->getGrammarCheck( *pTextNode, false ) :
             pTextNode->GetGrammarCheck();
diff --git a/sw/source/core/txtnode/GrammarContact.cxx 
b/sw/source/core/txtnode/GrammarContact.cxx
index 233fe2ed3432..47e2fac264c0 100644
--- a/sw/source/core/txtnode/GrammarContact.cxx
+++ b/sw/source/core/txtnode/GrammarContact.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <GrammarContact.hxx>
+#include <doc.hxx>
 #include <pam.hxx>
 #include <ndtxt.hxx>
 #include <txtfrm.hxx>
@@ -143,11 +144,21 @@ void GrammarContact::finishGrammarCheck( SwTextNode& 
rTextNode )
     }
 }
 
-void finishGrammarCheck( SwTextNode& rTextNode )
+sw::GrammarContact* getGrammarContactFor(const SwTextNode& rTextNode)
 {
-    sw::GrammarContact* pGrammarContact = getGrammarContact( rTextNode );
+    const SwDoc& rDoc = rTextNode.GetDoc();
+    if (rDoc.IsInDtor())
+        return nullptr;
+    return rDoc.getGrammarContact().get();
+}
+
+void finishGrammarCheckFor(SwTextNode& rTextNode)
+{
+    sw::GrammarContact* pGrammarContact = getGrammarContactFor(rTextNode);
     if (pGrammarContact)
-        pGrammarContact->finishGrammarCheck( rTextNode );
+    {
+        pGrammarContact->finishGrammarCheck(rTextNode);
+    }
 }
 
 } // end sw
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index 84194fd63a7b..ea2343e8b18a 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -190,7 +190,7 @@ void SAL_CALL SwXFlatParagraph::setChecked( ::sal_Int32 
nType, sal_Bool bVal )
     {
         GetTextNode()->SetGrammarCheckDirty( !bVal );
         if( bVal )
-            sw::finishGrammarCheck( *GetTextNode() );
+            sw::finishGrammarCheckFor(*GetTextNode());
     }
 }
 
diff --git a/sw/source/core/unocore/unotextmarkup.cxx 
b/sw/source/core/unocore/unotextmarkup.cxx
index 26249cb7b1f6..eb31601dd64a 100644
--- a/sw/source/core/unocore/unotextmarkup.cxx
+++ b/sw/source/core/unocore/unotextmarkup.cxx
@@ -156,7 +156,7 @@ void SAL_CALL SwXTextMarkup::commitStringMarkup(
     }
     else if ( nType == text::TextMarkupType::PROOFREADING || nType == 
text::TextMarkupType::SENTENCE )
     {
-        sw::GrammarContact* pGrammarContact = 
getGrammarContact(*m_pImpl->m_pTextNode);
+        sw::GrammarContact* pGrammarContact = 
sw::getGrammarContactFor(*m_pImpl->m_pTextNode);
         if( pGrammarContact )
         {
             pWList = pGrammarContact->getGrammarCheck(*m_pImpl->m_pTextNode, 
true);
@@ -280,7 +280,7 @@ void SAL_CALL SwXTextMarkup::commitStringMarkup(
     }
 
     if( bRepaint )
-        finishGrammarCheck(*m_pImpl->m_pTextNode);
+        sw::finishGrammarCheckFor(*m_pImpl->m_pTextNode);
 }
 
 static void lcl_commitGrammarMarkUp(
@@ -410,7 +410,7 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
     // get appropriate list to use...
     SwGrammarMarkUp* pWList = nullptr;
     bool bRepaint = false;
-    sw::GrammarContact* pGrammarContact = 
getGrammarContact(*m_pImpl->m_pTextNode);
+    sw::GrammarContact* pGrammarContact = 
sw::getGrammarContactFor(*m_pImpl->m_pTextNode);
     if( pGrammarContact )
     {
         pWList = pGrammarContact->getGrammarCheck(*m_pImpl->m_pTextNode, true);
@@ -455,7 +455,7 @@ void SAL_CALL SwXTextMarkup::commitMultiTextMarkup(
     }
 
     if( bRepaint )
-        finishGrammarCheck(*m_pImpl->m_pTextNode);
+        sw::finishGrammarCheckFor(*m_pImpl->m_pTextNode);
 }
 
 void SwXTextMarkup::Impl::Notify(const SfxHint& rHint)

Reply via email to