22#include <initializer_list>
32using namespace ::
cppu;
35#define QUERYINT( xint ) \
36 if( rType == cppu::UnoType<xint>::get() ) \
37 return uno::Any(uno::Reference< xint >(this))
46 if( rText.GetEditSource() )
47 mpEditSource = rText.GetEditSource()->Clone();
53 const SvxTextForwarder* pTextForwarder = rText.GetEditSource()->GetTextForwarder();
54 const sal_Int32 maxParaIndex = std::min( rSel.nEndPara + 1, pTextForwarder->
GetParagraphCount() );
56 for( sal_Int32 currentPara = rSel.nStartPara; currentPara < maxParaIndex; currentPara++ )
60 sal_Int32 nStartPos = 0;
61 sal_Int32 nEndPos = pTextForwarder->
GetTextLen( currentPara );
62 if( currentPara == rSel.nStartPara )
63 nStartPos = std::max(nStartPos, rSel.nStartPos);
64 if( currentPara == rSel.nEndPara )
65 nEndPos = std::min(nEndPos, rSel.nEndPos);
66 ESelection aCurrentParaSel( currentPara, nStartPos, currentPara, nEndPos );
67 for (
auto const& elemRange : rRanges)
72 if( pIterContent && (pIterContent->
mnParagraph == currentPara) )
74 ESelection aIterSel = pIterContent->GetSelection();
75 if( aIterSel == aCurrentParaSel )
77 pContent = pIterContent;
78 maContents.emplace_back(pContent );
82 if( pContent ==
nullptr )
85 pContent->SetSelection( aCurrentParaSel );
86 maContents.emplace_back(pContent );
110 throw container::NoSuchElementException();
121: SvxUnoTextRangeBase(rText)
124, mbDisposing(
false )
130: SvxUnoTextRangeBase(rContent)
131, text::XTextContent()
132, container::XEnumerationAccess()
133, lang::XTypeProvider()
135, mrParentText(rContent.mrParentText)
136, mbDisposing(
false )
138 mxParentText = rContent.mxParentText;
139 mnParagraph = rContent.mnParagraph;
140 SetSelection( rContent.GetSelection() );
151 else QUERYINT( beans::XMultiPropertyStates );
152 else QUERYINT( beans::XPropertySet );
153 else QUERYINT( beans::XMultiPropertySet );
154 else QUERYINT( beans::XPropertyState );
155 else QUERYINT( text::XTextContent );
156 else QUERYINT( text::XTextRangeCompare );
158 else QUERYINT( container::XEnumerationAccess );
159 else QUERYINT( container::XElementAccess );
160 else QUERYINT( lang::XServiceInfo );
161 else QUERYINT( lang::XTypeProvider );
164 return OWeakAggObject::queryAggregation( rType );
169 return OWeakAggObject::queryInterface(rType);
174 OWeakAggObject::acquire();
179 OWeakAggObject::release();
186 static const uno::Sequence< uno::Type > TYPES {
203 return css::uno::Sequence<sal_Int8>();
234 lang::EventObject aEvt;
277 SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() :
nullptr;
280 std::vector<sal_Int32> aPortions;
282 return !aPortions.empty();
294 _setPropertyValue( aPropertyName, aValue,
mnParagraph );
299 return _getPropertyValue( PropertyName,
mnParagraph );
305 _setPropertyValues( aPropertyNames, aValues,
mnParagraph );
310 return _getPropertyValues( aPropertyNames,
mnParagraph );
333 return _getPropertyState( PropertyName,
mnParagraph );
338 return _getPropertyStates( aPropertyName,
mnParagraph );
343 _setPropertyToDefault( PropertyName,
mnParagraph );
350 return "SvxUnoTextContent";
356 SvxUnoTextRangeBase::getSupportedServiceNames(),
357 std::initializer_list<std::u16string_view>{
u"com.sun.star.style.ParagraphProperties",
358 u"com.sun.star.style.ParagraphPropertiesComplex",
359 u"com.sun.star.style.ParagraphPropertiesAsian",
360 u"com.sun.star.text.TextContent",
361 u"com.sun.star.text.Paragraph" });
371 if (rParentText.GetEditSource())
377 std::vector<sal_Int32> aPortions;
378 mpEditSource->GetTextForwarder()->GetPortions( nParagraph, aPortions );
379 for(
size_t aPortionIndex = 0; aPortionIndex < aPortions.size(); aPortionIndex++ )
381 sal_uInt16 nStartPos = 0;
382 if ( aPortionIndex > 0 )
383 nStartPos = aPortions.at( aPortionIndex - 1 );
386 sal_uInt16 nEndPos = aPortions.at( aPortionIndex );
390 nStartPos = std::max<int>(nStartPos, rSel.
nStartPos);
391 nEndPos = std::min<sal_uInt16>(nEndPos, rSel.
nEndPos);
392 ESelection aSel( nParagraph, nStartPos, nParagraph, nEndPos );
396 for (
auto const& elemRange : rRanges)
401 if( pIterRange && pIterRange->
mbPortion && (aSel == pIterRange->maSelection) )
404 if( pRange ==
nullptr )
407 pRange->SetSelection( aSel );
431 throw container::NoSuchElementException();
439: SvxUnoTextRangeBase(rText),
445: SvxUnoTextRangeBase(rCursor)
447, lang::XTypeProvider()
449, mxParentText(rCursor.mxParentText)
463 return uno::Any(uno::Reference< text::XTextRange >(
static_cast<SvxUnoTextRangeBase *
>(
this)));
465 else QUERYINT( beans::XMultiPropertyStates );
466 else QUERYINT( beans::XPropertySet );
467 else QUERYINT( beans::XMultiPropertySet );
468 else QUERYINT( beans::XPropertyState );
469 else QUERYINT( text::XTextRangeCompare );
470 else QUERYINT( lang::XServiceInfo );
471 else QUERYINT( lang::XTypeProvider );
474 return OWeakAggObject::queryAggregation( rType );
479 return OWeakAggObject::queryInterface(rType);
484 OWeakAggObject::acquire();
489 OWeakAggObject::release();
495 static const uno::Sequence< uno::Type > TYPES {
511 return css::uno::Sequence<sal_Int8>();
530 return IsCollapsed();
536 return GoLeft(
nCount, bExpand );
542 return GoRight(
nCount, bExpand );
548 GotoStart( bExpand );
562 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xRange );
576 SetSelection( aNewSel );
587 return SvxUnoTextRangeBase::getStart();
592 return SvxUnoTextRangeBase::getEnd();
597 return SvxUnoTextRangeBase::getString();
602 SvxUnoTextRangeBase::setString(aString);
607 return "SvxUnoTextCursor";
618 SvxUnoTextRangeBase::getSupportedServiceNames(),
619 std::initializer_list<std::u16string_view>{
u"com.sun.star.style.ParagraphProperties",
620 u"com.sun.star.style.ParagraphPropertiesComplex",
621 u"com.sun.star.style.ParagraphPropertiesAsian",
622 u"com.sun.star.text.TextCursor" });
Contains an EditEngine or an Outliner and unifies access to them.
virtual void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList) const =0
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const =0
virtual sal_Int32 GetParagraphCount() const =0
SvxUnoTextContentEnumeration(const SvxUnoTextBase &_rText, const ESelection &rSel) noexcept
std::vector< rtl::Reference< SvxUnoTextContent > > maContents
std::unique_ptr< SvxEditSource > mpEditSource
virtual css::uno::Any SAL_CALL nextElement() override
virtual sal_Bool SAL_CALL hasMoreElements() override
virtual ~SvxUnoTextContentEnumeration() noexcept override
sal_Int32 mnNextParagraph
const SvxUnoTextBase & mrParentText
virtual void SAL_CALL dispose() override
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
SvxUnoTextContent(const SvxUnoTextBase &rText, sal_Int32 nPara) noexcept
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL hasElements() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > maDisposeListeners
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
virtual ~SvxUnoTextContent() noexcept override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
css::uno::Reference< css::text::XText > mxParentText
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
std::mutex maDisposeContainerMutex
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
SvxUnoTextCursor(const SvxUnoTextBase &rText) noexcept
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
virtual void SAL_CALL collapseToStart() override
virtual ~SvxUnoTextCursor() noexcept override
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
virtual void SAL_CALL collapseToEnd() override
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
css::uno::Reference< css::text::XText > mxParentText
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL setString(const OUString &aString) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
virtual sal_Bool SAL_CALL isCollapsed() override
virtual OUString SAL_CALL getString() override
sal_Int32 addInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(std::unique_lock< std::mutex > &rGuard, const css::uno::Reference< ListenerT > &rxIFace)
css::uno::Type const & get()
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
std::vector< SvxUnoTextRangeBase * > SvxUnoTextRangeBaseVec
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept