linguistic/source/gciterator.cxx                      |    2 ++
 offapi/com/sun/star/style/ParagraphProperties.idl     |    9 +++++++++
 sw/inc/cmdid.h                                        |    3 ++-
 sw/inc/unoprnms.hxx                                   |    1 +
 sw/source/core/unocore/unocrsrhelper.cxx              |   12 ++++++++++++
 sw/source/core/unocore/unoflatpara.cxx                |   18 ++++++++++++++++++
 sw/source/core/unocore/unomapproperties.hxx           |    1 +
 sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx |    1 +
 8 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 04f15c8a8c733f159f77bd58905e4136a32b1be9
Author:     Fred Kruse <fred.kr...@gmx.de>
AuthorDate: Sun Jan 15 19:09:36 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Tue Jan 17 10:17:19 2023 +0000

    Properties SortedTextId and DocumentElementsCount added for grammar check
    
    The LanguageTool extension (LT extension) runs not only a grammar check on 
the level of sentences and paragraphs, some rules work on the level of many 
paragraphs or full text. The LT extension uses a complex caching mechanism to 
support this feature. A mapping from a check request to the cached to the 
(flat)paragraphs is necessary. Until now, this is done by a time-consuming and 
error-prone mechanism.  The adding of the SortedTextId introduce a feature, a 
paragraph to be checked can be fast and easy identified. The flatparagraphs 
also can easily be mapped to cursors to get additional information of the 
paragraph, used for further features of LT extension.
    The added Property DocumentElementsCount to flatparagraphs and 
doProofreading gives the extension the hint to recreate the cache.
    
    Change-Id: I4b6b58bba4dfb3e870fe7b71fd8537ee9ffd6476
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142251
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 581f356f215e..1613b2dac36b 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -557,6 +557,8 @@ lcl_makeProperties(uno::Reference<text::XFlatParagraph> 
const& xFlatPara, sal_In
     return comphelper::InitPropertySequence({
         { "FieldPositions", xProps->getPropertyValue("FieldPositions") },
         { "FootnotePositions", xProps->getPropertyValue("FootnotePositions") },
+        { "SortedTextId", xProps->getPropertyValue("SortedTextId") },
+        { "DocumentElementsCount", 
xProps->getPropertyValue("DocumentElementsCount") },
         { "ProofInfo", a }
     });
 }
diff --git a/offapi/com/sun/star/style/ParagraphProperties.idl 
b/offapi/com/sun/star/style/ParagraphProperties.idl
index 9951703c8a3d..a7d6c059bd8a 100644
--- a/offapi/com/sun/star/style/ParagraphProperties.idl
+++ b/offapi/com/sun/star/style/ParagraphProperties.idl
@@ -419,6 +419,15 @@ published service ParagraphProperties
             @since LibreOffice 7.4
          */
         [optional, property] long ParaHyphenationZone;
+
+        /** contains a paragraph identifier within the actual text,
+            which also shows the position of the paragraph relative to the
+            other paragraphs of the same text, i.e. a paragraph with lower
+            identifier is there before the other ones with greater values.
+            This property depends on implementation details and is considered 
experimental.
+            @since LibreOffice 7.5
+         */
+        [optional, property, readonly] long SortedTextId;
 };
 
 
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index c44745a0e861..02d78f338851 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -577,7 +577,8 @@ class SwUINumRuleItem;
 #define FN_UNO_FOOTER_LEFT                  (FN_EXTRA2 + 39)
 #define FN_UNO_FOOTER_RIGHT                 (FN_EXTRA2 + 40)
 #define FN_UNO_TEXT_PARAGRAPH               (FN_EXTRA2 + 41)
-#define FN_UNO_PARENT_TEXT (FN_EXTRA2 + 42)
+#define FN_UNO_PARENT_TEXT                  (FN_EXTRA2 + 42)
+#define FN_UNO_SORTED_TEXT_ID               (FN_EXTRA2 + 43)
 #define FN_UNO_FOLLOW_STYLE                 (FN_EXTRA2 + 59)
 
 #define FN_API_CALL                         
TypedWhichId<SfxBoolItem>(FN_EXTRA2 + 60)
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 42a38fdef0aa..85a1938d61ce 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -412,6 +412,7 @@ inline constexpr OUStringLiteral 
UNO_NAME_FOOTER_IS_DYNAMIC_HEIGHT = u"FooterIsD
 inline constexpr OUStringLiteral UNO_NAME_FOOTER_IS_SHARED = u"FooterIsShared";
 inline constexpr OUStringLiteral UNO_NAME_TEXT_PARAGRAPH = u"TextParagraph";
 inline constexpr OUStringLiteral UNO_NAME_PARENT_TEXT = u"ParentText";
+inline constexpr OUStringLiteral UNO_NAME_SORTED_TEXT_ID = u"SortedTextId";
 
 inline constexpr OUStringLiteral UNO_NAME_FOOTER_HEIGHT = u"FooterHeight";
 inline constexpr OUStringLiteral UNO_NAME_FOOTER_IS_ON = u"FooterIsOn";
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index 04567219168f..3596e21cf00a 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -675,6 +675,18 @@ bool getCursorPropertyValue(const SfxItemPropertyMapEntry& 
rEntry
                 eNewState = PropertyState_DEFAULT_VALUE;
         }
         break;
+        case FN_UNO_SORTED_TEXT_ID:
+        {
+            if( pAny )
+            {
+                sal_Int32 nIndex = -1;
+                SwTextNode* pTextNode = 
rPam.GetPoint()->GetNode().GetTextNode();
+                if ( pTextNode )
+                    nIndex = pTextNode->GetIndex().get();
+                *pAny <<= nIndex;
+            }
+        }
+        break;
         case FN_UNO_ENDNOTE:
         case FN_UNO_FOOTNOTE:
         {
diff --git a/sw/source/core/unocore/unoflatpara.cxx 
b/sw/source/core/unocore/unoflatpara.cxx
index 3182812cecdb..ea86284fb4ab 100644
--- a/sw/source/core/unocore/unoflatpara.cxx
+++ b/sw/source/core/unocore/unoflatpara.cxx
@@ -83,6 +83,8 @@ SwXFlatParagraph::getPropertySetInfo()
     static const comphelper::PropertyMapEntry s_Entries[] = {
         { OUString("FieldPositions"), -1, 
::cppu::UnoType<uno::Sequence<sal_Int32>>::get(), 
beans::PropertyAttribute::READONLY, 0 },
         { OUString("FootnotePositions"), -1, 
::cppu::UnoType<uno::Sequence<sal_Int32>>::get(), 
beans::PropertyAttribute::READONLY, 0 },
+        { OUString("SortedTextId"), -1, ::cppu::UnoType<sal_Int32>::get(), 
beans::PropertyAttribute::READONLY, 0 },
+        { OUString("DocumentElementsCount"), -1, 
::cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 },
     };
     return new comphelper::PropertySetInfo(s_Entries);
 }
@@ -107,6 +109,22 @@ SwXFlatParagraph::getPropertyValue(const OUString& 
rPropertyName)
     {
         return uno::Any( comphelper::containerToSequence( 
GetConversionMap().getFootnotePositions() ) );
     }
+    else if (rPropertyName == "SortedTextId")
+    {
+        SwTextNode const*const pCurrentNode = GetTextNode();
+        sal_Int32 nIndex = -1;
+        if ( pCurrentNode )
+            nIndex = pCurrentNode->GetIndex().get();
+        return uno::Any( nIndex );
+    }
+    else if (rPropertyName == "DocumentElementsCount")
+    {
+        SwTextNode const*const pCurrentNode = GetTextNode();
+        sal_Int32 nCount = -1;
+        if ( pCurrentNode )
+            nCount = pCurrentNode->GetDoc().GetNodes().Count().get();
+        return uno::Any( nCount );
+    }
     return uno::Any();
 }
 
diff --git a/sw/source/core/unocore/unomapproperties.hxx 
b/sw/source/core/unocore/unomapproperties.hxx
index 583babbf2e3f..d849c4fcb36c 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -89,6 +89,7 @@
         { UNO_NAME_TEXT_FRAME, FN_UNO_TEXT_FRAME,     
cppu::UnoType<css::text::XTextFrame>::get(),        
PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 },                  
   \
         { UNO_NAME_TEXT_SECTION, FN_UNO_TEXT_SECTION, 
cppu::UnoType<css::text::XTextSection>::get(),  
PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 },                  
  \
         { UNO_NAME_TEXT_PARAGRAPH, FN_UNO_TEXT_PARAGRAPH, 
cppu::UnoType<css::text::XTextContent>::get(),  
PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 },                  
  \
+        { UNO_NAME_SORTED_TEXT_ID, FN_UNO_SORTED_TEXT_ID, 
cppu::UnoType<sal_Int32>::get(),  
PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 },                  
  \
         { UNO_NAME_PARA_CHAPTER_NUMBERING_LEVEL, 
FN_UNO_PARA_CHAPTER_NUMBERING_LEVEL,cppu::UnoType<sal_Int8>::get(), 
PropertyAttribute::MAYBEVOID, 0},                                               
      \
         { UNO_NAME_PARA_CONDITIONAL_STYLE_NAME, 
FN_UNO_PARA_CONDITIONAL_STYLE_NAME, cppu::UnoType<OUString>::get(),      
PropertyAttribute::READONLY, 0},                                                
     \
         { UNO_NAME_LIST_ID, FN_UNO_LIST_ID, cppu::UnoType<OUString>::get(), 
PropertyAttribute::MAYBEVOID, 0}, \
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx 
b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index b0fc9b82ce1d..313af767ba5d 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -562,6 +562,7 @@ static void UpdateTree(SwDocShell& rDocSh, SwEditShell& 
rEditSh,
                                                    
UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE,
                                                    UNO_NAME_CHAR_STYLE_NAME,
                                                    UNO_NAME_NUMBERING_LEVEL,
+                                                   UNO_NAME_SORTED_TEXT_ID,
                                                    UNO_NAME_PARRSID,
                                                    UNO_NAME_CHAR_COLOR_THEME,
                                                    
UNO_NAME_CHAR_COLOR_TINT_OR_SHADE };

Reply via email to