sw clearing breaks: include this in the UNO API text portion enum
Which is how UNO API clients (e.g. ODT export) will be able to read RES_TXTATR_LINEBREAK. Change-Id: I44d2058fd8b4a4fefce3dacc49d3bb3da6060756 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130903 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
This commit is contained in:
@@ -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
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -21,8 +21,6 @@
|
||||
|
||||
#include "txatbase.hxx"
|
||||
|
||||
#include "ndindex.hxx"
|
||||
|
||||
class SwFormatLineBreak;
|
||||
|
||||
/**
|
||||
|
@@ -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: */
|
||||
|
@@ -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: */
|
||||
|
@@ -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;
|
||||
|
@@ -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; }
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 }
|
||||
};
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user