summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--offapi/com/sun/star/text/TextRangeContentProperties.idl6
-rw-r--r--sw/inc/cmdid.h1
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/extras/uiwriter/data/paragraph-of-text-range.odtbin0 -> 8878 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx23
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx13
-rw-r--r--sw/source/core/unocore/unomapproperties.hxx1
7 files changed, 45 insertions, 0 deletions
diff --git a/offapi/com/sun/star/text/TextRangeContentProperties.idl b/offapi/com/sun/star/text/TextRangeContentProperties.idl
index 042b4d5b3736..9daad2e139dc 100644
--- a/offapi/com/sun/star/text/TextRangeContentProperties.idl
+++ b/offapi/com/sun/star/text/TextRangeContentProperties.idl
@@ -81,6 +81,12 @@ service TextRangeContentProperties
[optional, readonly, property] com::sun::star::text::XTextContent
NestedTextContent;
+ /** Paragraph for the start of this range.
+
+ @since LibreOffice 6.0
+ */
+ [optional, readonly, property] com::sun::star::text::XTextContent TextParagraph;
+
};
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 09cd1f48513c..6f1ec12ee124 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -544,6 +544,7 @@
#define FN_UNO_FOOTER (FN_EXTRA2 + 38)
#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_FOLLOW_STYLE (FN_EXTRA2 + 59)
#define FN_API_CALL (FN_EXTRA2 + 60)
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 63589f273ce5..1c1371222bc6 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -384,6 +384,7 @@
#define UNO_NAME_FOOTER_BODY_DISTANCE "FooterBodyDistance"
#define UNO_NAME_FOOTER_IS_DYNAMIC_HEIGHT "FooterIsDynamicHeight"
#define UNO_NAME_FOOTER_IS_SHARED "FooterIsShared"
+#define UNO_NAME_TEXT_PARAGRAPH "TextParagraph"
#define UNO_NAME_FOOTER_HEIGHT "FooterHeight"
#define UNO_NAME_FOOTER_IS_ON "FooterIsOn"
diff --git a/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt b/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt
new file mode 100644
index 000000000000..52cdb0be1ff2
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/paragraph-of-text-range.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 57d53fc8f4d0..0e37981b4b58 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -199,6 +199,7 @@ public:
void testTdf99004();
void testTdf84695();
void testTdf84695NormalChar();
+ void testParagraphOfTextRange();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -300,6 +301,7 @@ public:
CPPUNIT_TEST(testTdf99004);
CPPUNIT_TEST(testTdf84695);
CPPUNIT_TEST(testTdf84695NormalChar);
+ CPPUNIT_TEST(testParagraphOfTextRange);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3704,6 +3706,27 @@ void SwUiWriterTest::testTdf84695NormalChar()
CPPUNIT_ASSERT_EQUAL(OUString("a"), xShape->getString());
}
+void SwUiWriterTest::testParagraphOfTextRange()
+{
+ SwDoc* pDoc = createDoc("paragraph-of-text-range.odt");
+
+ // Enter the table.
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Down(/*bSelect=*/false);
+ CPPUNIT_ASSERT(pWrtShell->IsCursorInTable());
+ // Enter the section.
+ pWrtShell->Down(/*bSelect=*/false);
+ CPPUNIT_ASSERT(pWrtShell->IsDirectlyInSection());
+
+ // Assert that we get the right paragraph object.
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xController(xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xViewCursor(xController->getViewCursor(), uno::UNO_QUERY);
+ // This failed as there were no TextParagraph property.
+ auto xParagraph = getProperty< uno::Reference<text::XTextRange> >(xViewCursor->getStart(), "TextParagraph");
+ CPPUNIT_ASSERT_EQUAL(OUString("In section"), xParagraph->getString());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 22b41fed67fc..83646a892b97 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -85,6 +85,7 @@
#include <SwNodeNum.hxx>
#include <fmtmeta.hxx>
#include <txtfld.hxx>
+#include <unoparagraph.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -592,6 +593,18 @@ bool getCursorPropertyValue(const SfxItemPropertySimpleEntry& rEntry
eNewState = PropertyState_DEFAULT_VALUE;
}
break;
+ case FN_UNO_TEXT_PARAGRAPH:
+ {
+ SwTextNode* pTextNode = rPam.GetPoint()->nNode.GetNode().GetTextNode();
+ if (pTextNode)
+ {
+ uno::Reference<text::XTextContent> xParagraph = SwXParagraph::CreateXParagraph(*pTextNode->GetDoc(), pTextNode);
+ *pAny <<= xParagraph;
+ }
+ else
+ eNewState = PropertyState_DEFAULT_VALUE;
+ }
+ break;
case FN_UNO_ENDNOTE:
case FN_UNO_FOOTNOTE:
{
diff --git a/sw/source/core/unocore/unomapproperties.hxx b/sw/source/core/unocore/unomapproperties.hxx
index 1f528f0ba596..8580ba0c8805 100644
--- a/sw/source/core/unocore/unomapproperties.hxx
+++ b/sw/source/core/unocore/unomapproperties.hxx
@@ -87,6 +87,7 @@
{ OUString(UNO_NAME_CELL), FN_UNO_CELL, cppu::UnoType<css::table::XCell>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 }, \
{ OUString(UNO_NAME_TEXT_FRAME), FN_UNO_TEXT_FRAME, cppu::UnoType<css::text::XTextFrame>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 }, \
{ OUString(UNO_NAME_TEXT_SECTION), FN_UNO_TEXT_SECTION, cppu::UnoType<css::text::XTextSection>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 }, \
+ { OUString(UNO_NAME_TEXT_PARAGRAPH), FN_UNO_TEXT_PARAGRAPH, cppu::UnoType<css::text::XTextContent>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 }, \
{ OUString(UNO_NAME_PARA_CHAPTER_NUMBERING_LEVEL), FN_UNO_PARA_CHAPTER_NUMBERING_LEVEL,cppu::UnoType<sal_Int8>::get(), PROPERTY_NONE, 0}, \
{ OUString(UNO_NAME_PARA_CONDITIONAL_STYLE_NAME), FN_UNO_PARA_CONDITIONAL_STYLE_NAME, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0}, \
{ OUString(UNO_NAME_LIST_ID), FN_UNO_LIST_ID, cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0}, \