22#include <osl/diagnose.h>
24#include <rtl/ustrbuf.hxx>
28static bool CompareStart(
const std::unique_ptr<TextCharAttrib>& pFirst,
const std::unique_ptr<TextCharAttrib>& pSecond )
30 return pFirst->GetStart() < pSecond->GetStart();
34 : mpAttr(rAttr.
Clone())
41 : mpAttr(rTextCharAttrib.mpAttr->
Clone())
48 : mbHasEmptyAttribs(false)
64 if ( pAttrib->IsEmpty() )
67 const sal_Int32 nStart = pAttrib->GetStart();
68 bool bInserted =
false;
70 [nStart](std::unique_ptr<TextCharAttrib>& rAttrib) { return rAttrib->GetStart() > nStart; });
73 maAttribs.insert( it, std::move(pAttrib) );
77 maAttribs.push_back( std::move(pAttrib) );
87 for (std::vector<std::unique_ptr<TextCharAttrib> >::reverse_iterator it =
maAttribs.rbegin(); it !=
maAttribs.rend(); ++it)
89 if ( (*it)->GetEnd() <
nPos )
92 if ( ( (*it)->Which() == nWhich ) && (*it)->IsIn(
nPos) )
100 for (std::vector<std::unique_ptr<TextCharAttrib> >::reverse_iterator it =
maAttribs.rbegin(); it !=
maAttribs.rend(); ++it)
102 if ( (*it)->GetEnd() < nBound )
105 if ( ( (*it)->GetStart() == nBound ) || ( (*it)->GetEnd() == nBound ) )
118 if ( attrib->GetStart() >
nPos )
121 if ( ( attrib->GetStart() ==
nPos ) && ( attrib->GetEnd() ==
nPos ) && ( attrib->Which() == nWhich ) )
131 [] (
const std::unique_ptr<TextCharAttrib>& rAttrib) { return rAttrib->IsEmpty(); } ),
146 bool bResort =
false;
148 for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
210 bool bResort =
false;
211 const sal_Int32 nEndChanges =
nIndex+nDeleted;
216 bool bDelAttr =
false;
220 if ( rAttrib.
GetStart() >= nEndChanges )
237 if ( rAttrib.
GetEnd() <= nEndChanges )
252 SAL_WARN_IF( ( rAttrib.
GetEnd() >
maText.getLength()) && !bDelAttr,
"vcl",
"Collaps: attribute greater than paragraph!" );
293 std::unique_ptr<TextNode> pNew(
new TextNode( aNewText ));
307 if ( !pNew->maCharAttribs.FindAttrib( rAttrib.
Which(), 0 ) )
309 std::unique_ptr<TextCharAttrib> pNewAttrib(
new TextCharAttrib( rAttrib ));
310 pNewAttrib->SetStart(0);
311 pNewAttrib->SetEnd(0);
312 pNew->maCharAttribs.InsertAttrib( std::move(pNewAttrib) );
319 std::unique_ptr<TextCharAttrib> pNewAttrib(
new TextCharAttrib( rAttrib ));
320 pNewAttrib->SetStart(0);
322 pNew->maCharAttribs.InsertAttrib( std::move(pNewAttrib) );
342 sal_Int32 nOldLen =
maText.getLength();
347 for ( sal_uInt16 nAttr = 0; nAttr < nAttribs; nAttr++ )
350 bool bMelted =
false;
355 for ( sal_uInt16 nTmpAttr = 0; nTmpAttr < nTmpAttribs; nTmpAttr++ )
359 if ( rTmpAttrib.
GetEnd() == nOldLen )
361 if ( ( rTmpAttrib.
Which() == rAttrib.
Which() ) &&
374 std::unique_ptr<TextCharAttrib> pNewAttrib(
new TextCharAttrib( rAttrib ));
375 pNewAttrib->SetStart( pNewAttrib->GetStart() + nOldLen );
376 pNewAttrib->SetEnd( pNewAttrib->GetEnd() + nOldLen );
404 sal_uInt32 nNodes =
static_cast<sal_uInt32
>(
maTextNodes.size());
406 OUStringBuffer aASCIIText;
407 const sal_uInt32 nLastNode = nNodes-1;
408 for ( sal_uInt32 nNode = 0; nNode < nNodes; ++nNode )
411 aASCIIText.append(pNode->
GetText());
412 if ( pSep && ( nNode != nLastNode ) )
413 aASCIIText.append(pSep);
416 return aASCIIText.makeStringAndClear();
431 sal_uInt32 nNodes =
static_cast<sal_uInt32
>(
maTextNodes.size());
434 sal_uInt32 nStartNode = 0;
435 sal_uInt32 nEndNode = nNodes-1;
442 for ( sal_uInt32 nNode = nStartNode; nNode <= nEndNode; ++nNode )
447 sal_Int32 nE = pNode->
GetText().getLength();
457 nLen += (nEndNode-nStartNode) * rtl_ustr_getLength(pSep);
465 SAL_WARN_IF( c == 0x0A,
"vcl",
"TextDoc::InsertText: Line separator in paragraph not allowed!" );
466 SAL_WARN_IF( c == 0x0D,
"vcl",
"TextDoc::InsertText: Line separator in paragraph not allowed!" );
477 SAL_WARN_IF( rStr.find( 0x0A ) != std::u16string_view::npos,
"vcl",
"TextDoc::InsertText: Line separator in paragraph not allowed!" );
478 SAL_WARN_IF( rStr.find( 0x0D ) != std::u16string_view::npos,
"vcl",
"TextDoc::InsertText: Line separator in paragraph not allowed!" );
490 std::unique_ptr<TextNode> pNew = pNode->
Split( rPaM.
GetIndex() );
501 sal_Int32 nPrevLen = pLeft->
GetText().getLength();
506 [&] (std::unique_ptr<TextNode>
const &
p) { return p.get() == pRight; } ) );
509 [&] (std::unique_ptr<TextNode>
const &
p) { return p.get() == pLeft; } )
511 TextPaM aPaM( nLeft, nPrevLen );
525 OSL_FAIL(
"PaM: Para out of range" );
531 OSL_FAIL(
"PaM: Index out of range" );
TextCharAttrib * FindAttrib(sal_uInt16 nWhich, sal_Int32 nPos)
std::vector< std::unique_ptr< TextCharAttrib > > maAttribs
void InsertAttrib(std::unique_ptr< TextCharAttrib > pAttrib)
bool HasBoundingAttrib(sal_Int32 nBound)
const TextCharAttrib & GetAttrib(sal_uInt16 n) const
TextCharAttrib * FindEmptyAttrib(sal_uInt16 nWhich, sal_Int32 nPos)
std::unique_ptr< TextCharAttrib > RemoveAttrib(sal_uInt16 n)
void DeleteEmptyAttribs()
void Expand(sal_Int32 nDiff)
void MoveBackward(sal_Int32 nDiff)
void Collaps(sal_Int32 nDiff)
void SetStart(sal_Int32 n)
const TextAttrib & GetAttr() const
TextCharAttrib(const TextAttrib &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
void MoveForward(sal_Int32 nDiff)
sal_Int32 GetStart() const
bool IsInside(sal_Int32 nIndex) const
TextPaM InsertText(const TextPaM &rPaM, sal_Unicode c)
OUString GetText(const sal_Unicode *pSep) const
bool IsValidPaM(const TextPaM &rPaM)
TextPaM ConnectParagraphs(TextNode *pLeft, const TextNode *pRight)
void RemoveChars(const TextPaM &rPaM, sal_Int32 nChars)
std::vector< std::unique_ptr< TextNode > > maTextNodes
TextPaM InsertParaBreak(const TextPaM &rPaM)
sal_Int32 GetTextLen(const sal_Unicode *pSep, const TextSelection *pSel=nullptr) const
void CollapseAttribs(sal_Int32 nIndex, sal_Int32 nDelChars)
void ExpandAttribs(sal_Int32 nIndex, sal_Int32 nNewChars)
const TextCharAttribList & GetCharAttribs() const
void Append(const TextNode &rNode)
std::unique_ptr< TextNode > Split(sal_Int32 nPos)
void RemoveText(sal_Int32 nPos, sal_Int32 nChars)
TextCharAttribList maCharAttribs
const TextCharAttrib & GetCharAttrib(sal_uInt16 nPos) const
void InsertText(sal_Int32 nPos, std::u16string_view rText)
const OUString & GetText() const
sal_uInt32 GetPara() const
sal_Int32 GetIndex() const
const TextPaM & GetStart() const
const TextPaM & GetEnd() const
#define SAL_WARN_IF(condition, area, stream)
css::uno::Reference< css::animations::XAnimationNode > Clone(const css::uno::Reference< css::animations::XAnimationNode > &xSourceNode, const SdPage *pSource=nullptr, const SdPage *pTarget=nullptr)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static bool CompareStart(const std::unique_ptr< TextCharAttrib > &pFirst, const std::unique_ptr< TextCharAttrib > &pSecond)