summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorFred Kruse <fred.kruse@gmx.de>2023-01-15 19:09:36 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2023-01-17 10:17:19 +0000
commit04f15c8a8c733f159f77bd58905e4136a32b1be9 (patch)
treeb3adec0cb51eb52c348740865b99186e62c79739 /sw
parent79541a4808561fbe400cb4e0d33c8ddc23cf9d84 (diff)
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.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/cmdid.h3
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx12
-rw-r--r--sw/source/core/unocore/unoflatpara.cxx18
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx1
-rw-r--r--sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx1
6 files changed, 35 insertions, 1 deletions
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 };