summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/cmdid.h1
-rw-r--r--sw/inc/formatlinebreak.hxx1
-rw-r--r--sw/inc/textlinebreak.hxx2
-rw-r--r--sw/inc/unoprnms.hxx1
-rw-r--r--sw/qa/core/unocore/unocore.cxx31
-rw-r--r--sw/source/core/inc/unolinebreak.hxx3
-rw-r--r--sw/source/core/inc/unoport.hxx9
-rw-r--r--sw/source/core/unocore/unocoll.cxx4
-rw-r--r--sw/source/core/unocore/unolinebreak.cxx26
-rw-r--r--sw/source/core/unocore/unomap1.cxx1
-rw-r--r--sw/source/core/unocore/unoport.cxx6
-rw-r--r--sw/source/core/unocore/unoportenum.cxx16
12 files changed, 86 insertions, 15 deletions
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 161102e91142..9d26cbe7197a 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -641,6 +641,7 @@ class SwUINumRuleItem;
#define FN_UNO_TRANSFORMED_GRAPHIC (FN_EXTRA2 + 129)
#define FN_UNO_GRAPHIC_PREVIEW (FN_EXTRA2 + 130)
+#define FN_UNO_LINEBREAK (FN_EXTRA2 + 131)
// Area: Help
// Region: Traveling & Selection
diff --git a/sw/inc/formatlinebreak.hxx b/sw/inc/formatlinebreak.hxx
index c3a2b0164f86..f20fa46f78c7 100644
--- a/sw/inc/formatlinebreak.hxx
+++ b/sw/inc/formatlinebreak.hxx
@@ -23,7 +23,6 @@
#include <svl/eitem.hxx>
#include "calbck.hxx"
-#include <rtl/ustring.hxx>
#include <cppuhelper/weakref.hxx>
#include <com/sun/star/text/XTextContent.hpp>
diff --git a/sw/inc/textlinebreak.hxx b/sw/inc/textlinebreak.hxx
index 33401972f60b..5b5e8c6854c3 100644
--- a/sw/inc/textlinebreak.hxx
+++ b/sw/inc/textlinebreak.hxx
@@ -21,8 +21,6 @@
#include "txatbase.hxx"
-#include "ndindex.hxx"
-
class SwFormatLineBreak;
/**
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index d82bb18a0023..db77b87481c3 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -868,6 +868,7 @@
#define UNO_NAME_RESOLVED "Resolved"
#define UNO_NAME_ALLOW_OVERLAP "AllowOverlap"
#define UNO_NAME_CLEAR "Clear"
+#define UNO_NAME_LINEBREAK "LineBreak"
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 315716a6da15..30839266a7fc 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -249,6 +249,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakInsert)
CPPUNIT_ASSERT_EQUAL(SwLineBreakClear::ALL, rFormatLineBreak.GetValue());
}
+CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testLineBreakTextPortionEnum)
+{
+ // Given a document with a clearing break:
+ createSwDoc();
+ uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextContent> xLineBreak(
+ xMSF->createInstance("com.sun.star.text.LineBreak"), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xLineBreakProps(xLineBreak, uno::UNO_QUERY);
+ auto eClear = static_cast<sal_Int16>(SwLineBreakClear::ALL);
+ xLineBreakProps->setPropertyValue("Clear", uno::makeAny(eClear));
+ uno::Reference<text::XText> xText = xTextDocument->getText();
+ uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
+ xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false);
+
+ // When enumerating the text portions of the only paragraph in the document:
+ uno::Reference<css::text::XTextRange> xTextPortion = getRun(getParagraph(1), 1);
+
+ // Then make sure that the text portion type is correct + the clear type can be read:
+ auto aPortionType = getProperty<OUString>(xTextPortion, "TextPortionType");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: LineBreak
+ // - Actual : Text
+ // i.e. a line break with properties was part of the normal Text portion, making it impossible
+ // to get those properties.
+ CPPUNIT_ASSERT_EQUAL(OUString("LineBreak"), aPortionType);
+ xLineBreak = getProperty<uno::Reference<text::XTextContent>>(xTextPortion, "LineBreak");
+ eClear = getProperty<sal_Int16>(xLineBreak, "Clear");
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(SwLineBreakClear::ALL), eClear);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/unolinebreak.hxx b/sw/source/core/inc/unolinebreak.hxx
index 1eb939e24b68..0a87753c5e34 100644
--- a/sw/source/core/inc/unolinebreak.hxx
+++ b/sw/source/core/inc/unolinebreak.hxx
@@ -44,7 +44,8 @@ class SwXLineBreak final
~SwXLineBreak() override;
public:
- static css::uno::Reference<css::text::XTextContent> CreateXLineBreak();
+ static css::uno::Reference<css::text::XTextContent>
+ CreateXLineBreak(SwFormatLineBreak* pLineBreakFormat);
// XPropertySet
css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
diff --git a/sw/source/core/inc/unoport.hxx b/sw/source/core/inc/unoport.hxx
index ee862925eb29..76cf877db70b 100644
--- a/sw/source/core/inc/unoport.hxx
+++ b/sw/source/core/inc/unoport.hxx
@@ -74,7 +74,8 @@ enum SwTextPortionType
PORTION_FIELD_END,
PORTION_FIELD_START_END,
PORTION_ANNOTATION,
- PORTION_ANNOTATION_END
+ PORTION_ANNOTATION_END,
+ PORTION_LINEBREAK
};
class SwXTextPortion : public cppu::WeakImplHelper
@@ -107,6 +108,7 @@ private:
m_xTextField;
css::uno::Reference< css::text::XTextContent >
m_xMeta;
+ css::uno::Reference<css::text::XTextContent> m_xLineBreak;
std::unique_ptr< css::uno::Any > m_pRubyText;
std::unique_ptr< css::uno::Any > m_pRubyStyle;
std::unique_ptr< css::uno::Any > m_pRubyAdjust;
@@ -222,6 +224,11 @@ public:
void SetMeta( css::uno::Reference< css::text::XTextContent > const & xMeta)
{ m_xMeta = xMeta; }
+ void SetLineBreak(css::uno::Reference<css::text::XTextContent> const& xLineBreak)
+ {
+ m_xLineBreak = xLineBreak;
+ }
+
void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;}
SwTextPortionType GetTextPortionType() const { return m_ePortionType; }
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index cb7a0bbb390f..fd10e33424f2 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -826,8 +826,8 @@ SwXServiceProvider::MakeInstance(SwServiceType nObjectType, SwDoc & rDoc)
xRet = SwXMeta::CreateXMeta(rDoc, true);
break;
case SwServiceType::LineBreak:
- xRet = SwXLineBreak::CreateXLineBreak();
- break;
+ xRet = SwXLineBreak::CreateXLineBreak(nullptr);
+ break;
default:
throw uno::RuntimeException();
}
diff --git a/sw/source/core/unocore/unolinebreak.cxx b/sw/source/core/unocore/unolinebreak.cxx
index 1c5aeba9152e..2e8ee454eccb 100644
--- a/sw/source/core/unocore/unolinebreak.cxx
+++ b/sw/source/core/unocore/unolinebreak.cxx
@@ -109,14 +109,25 @@ SwXLineBreak::SwXLineBreak()
SwXLineBreak::~SwXLineBreak() {}
-uno::Reference<text::XTextContent> SwXLineBreak::CreateXLineBreak()
+uno::Reference<text::XTextContent>
+SwXLineBreak::CreateXLineBreak(SwFormatLineBreak* pLineBreakFormat)
{
uno::Reference<text::XTextContent> xLineBreak;
-
- rtl::Reference<SwXLineBreak> pLineBreak(new SwXLineBreak);
- xLineBreak.set(pLineBreak);
- pLineBreak->m_pImpl->m_wThis = xLineBreak;
-
+ if (pLineBreakFormat)
+ {
+ xLineBreak = pLineBreakFormat->GetXTextContent();
+ }
+ if (!xLineBreak.is())
+ {
+ SwXLineBreak* const pLineBreak(pLineBreakFormat ? new SwXLineBreak(*pLineBreakFormat)
+ : new SwXLineBreak);
+ xLineBreak.set(pLineBreak);
+ if (pLineBreakFormat)
+ {
+ pLineBreakFormat->SetXLineBreak(xLineBreak);
+ }
+ pLineBreak->m_pImpl->m_wThis = xLineBreak;
+ }
return xLineBreak;
}
@@ -140,7 +151,6 @@ void SAL_CALL SwXLineBreak::attach(const uno::Reference<text::XTextRange>& xText
throw uno::RuntimeException();
}
- uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
auto pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
if (!pRange)
{
@@ -248,7 +258,7 @@ uno::Any SAL_CALL SwXLineBreak::getPropertyValue(const OUString& rPropertyName)
}
else
{
- m_pImpl->m_pFormatLineBreak->QueryValue(aRet, 0);
+ aRet <<= m_pImpl->m_pFormatLineBreak->GetEnumValue();
}
return aRet;
}
diff --git a/sw/source/core/unocore/unomap1.cxx b/sw/source/core/unocore/unomap1.cxx
index 77b0909faec6..4c2e43296529 100644
--- a/sw/source/core/unocore/unomap1.cxx
+++ b/sw/source/core/unocore/unomap1.cxx
@@ -989,6 +989,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetTextPortionExtensio
//REDLINE_PROPERTIES
{u"" UNO_NAME_TEXT_PORTION_TYPE, FN_UNO_TEXT_PORTION_TYPE, cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0},
{u"" UNO_NAME_META, FN_UNO_META, cppu::UnoType<css::text::XTextContent>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 },
+ { u"" UNO_NAME_LINEBREAK, FN_UNO_LINEBREAK, cppu::UnoType<css::text::XTextContent>::get(), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY ,0 },
{ u"", 0, css::uno::Type(), 0, 0 }
};
diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx
index 2342f5b6649a..fdc90023e41d 100644
--- a/sw/source/core/unocore/unoport.cxx
+++ b/sw/source/core/unocore/unoport.cxx
@@ -250,6 +250,9 @@ void SwXTextPortion::GetPropertyValue(
case PORTION_ANNOTATION_END:
pRet = "AnnotationEnd";
break;
+ case PORTION_LINEBREAK:
+ pRet = "LineBreak";
+ break;
default:
pRet = nullptr;
}
@@ -280,6 +283,9 @@ void SwXTextPortion::GetPropertyValue(
case FN_UNO_META:
rVal <<= m_xMeta;
break;
+ case FN_UNO_LINEBREAK:
+ rVal <<= m_xLineBreak;
+ break;
case FN_UNO_IS_COLLAPSED:
{
switch (m_ePortionType)
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index b53d1d79c520..a16ace3fa373 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -42,6 +42,7 @@
#include <unobookmark.hxx>
#include <unofield.hxx>
#include <unometa.hxx>
+#include <unolinebreak.hxx>
#include <fmtfld.hxx>
#include <fldbas.hxx>
#include <fmtmeta.hxx>
@@ -952,6 +953,21 @@ lcl_ExportHints(
}
}
break;
+ case RES_TXTATR_LINEBREAK:
+ if (!bRightMoveForbidden)
+ {
+ pUnoCursor->Right(1);
+ if (*pUnoCursor->GetMark() == *pUnoCursor->GetPoint())
+ break;
+ rtl::Reference<SwXTextPortion> pPortion
+ = new SwXTextPortion(pUnoCursor, xParent, PORTION_LINEBREAK);
+ xRef = pPortion;
+ uno::Reference<text::XTextContent> xLineBreak
+ = SwXLineBreak::CreateXLineBreak(
+ &const_cast<SwFormatLineBreak&>(pAttr->GetLineBreak()));
+ pPortion->SetLineBreak(xLineBreak);
+ }
+ break;
case RES_TXTATR_AUTOFMT:
case RES_TXTATR_INETFMT:
case RES_TXTATR_CHARFMT: