LibreOffice Module sw (master)  1
unotext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <stdlib.h>
21 
22 #include <memory>
23 #include <set>
24 
25 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
26 #include <com/sun/star/text/ControlCharacter.hpp>
27 #include <com/sun/star/text/TableColumnSeparator.hpp>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
29 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
30 
31 #include <svl/listener.hxx>
32 #include <vcl/svapp.hxx>
34 #include <comphelper/sequence.hxx>
36 #include <cppuhelper/exc_hlp.hxx>
38 #include <sal/log.hxx>
39 
40 #include <cmdid.h>
41 #include <unotextbodyhf.hxx>
42 #include <unotext.hxx>
43 #include <unotextrange.hxx>
44 #include <unotextcursor.hxx>
45 #include <unosection.hxx>
46 #include <unobookmark.hxx>
47 #include <unorefmark.hxx>
48 #include <unoport.hxx>
49 #include <unotbl.hxx>
50 #include <unoidx.hxx>
51 #include <unocoll.hxx>
52 #include <unoframe.hxx>
53 #include <unofield.hxx>
54 #include <unometa.hxx>
55 #include <unomap.hxx>
56 #include <unoprnms.hxx>
57 #include <unoparagraph.hxx>
58 #include <unocrsrhelper.hxx>
59 #include <docary.hxx>
60 #include <doc.hxx>
61 #include <IDocumentUndoRedo.hxx>
62 #include <redline.hxx>
63 #include <swundo.hxx>
64 #include <section.hxx>
65 #include <fmtanchr.hxx>
66 #include <fmtcntnt.hxx>
67 #include <ndtxt.hxx>
68 #include <SwRewriter.hxx>
69 #include <strings.hrc>
70 #include <frameformats.hxx>
71 
72 using namespace ::com::sun::star;
73 
74 const char cInvalidObject[] = "this object is invalid";
75 
77 {
78 
79 public:
84  bool m_bIsValid;
85 
86  Impl( SwXText & rThis,
87  SwDoc *const pDoc, const CursorType eType)
88  : m_rThis(rThis)
89  , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT))
90  , m_eType(eType)
91  , m_pDoc(pDoc)
92  , m_bIsValid(nullptr != pDoc)
93  {
94  }
95 
98  uno::Reference< text::XTextRange >
100  const uno::Sequence< beans::PropertyValue >&
101  rCharacterAndParagraphProperties,
102  const uno::Reference< text::XTextRange >& xInsertPosition);
103 
106  sal_Int16 ComparePositions(
107  const uno::Reference<text::XTextRange>& xPos1,
108  const uno::Reference<text::XTextRange>& xPos2);
109 
112  bool CheckForOwnMember(const SwPaM & rPaM);
113 
114  void ConvertCell(
115  const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
116  std::vector<SwNodeRange> & rRowNodes,
117  SwNodeRange *const pLastCell);
118 
119 };
120 
121 SwXText::SwXText(SwDoc *const pDoc, const CursorType eType)
122  : m_pImpl( new SwXText::Impl(*this, pDoc, eType) )
123 {
124 }
125 
127 {
128 }
129 
130 const SwDoc * SwXText::GetDoc() const
131 {
132  return m_pImpl->m_pDoc;
133 }
135 {
136  return m_pImpl->m_pDoc;
137 }
138 
139 bool SwXText::IsValid() const
140 {
141  return m_pImpl->m_bIsValid;
142 }
143 
145 {
146  m_pImpl->m_bIsValid = false;
147 }
148 
149 void SwXText::SetDoc(SwDoc *const pDoc)
150 {
151  OSL_ENSURE(!m_pImpl->m_pDoc || !pDoc,
152  "SwXText::SetDoc: already have a doc?");
153  m_pImpl->m_pDoc = pDoc;
154  m_pImpl->m_bIsValid = (nullptr != pDoc);
155 }
156 
157 void
158 SwXText::PrepareForAttach(uno::Reference< text::XTextRange > &, const SwPaM &)
159 {
160 }
161 
162 bool SwXText::CheckForOwnMemberMeta(const SwPaM &, const bool)
163 {
164  OSL_ENSURE(CursorType::Meta != m_pImpl->m_eType, "should not be called!");
165  return false;
166 }
167 
169 {
171 }
172 
173 uno::Reference< text::XTextCursor >
175 {
176  uno::Reference< text::XTextCursor > xRet;
177  if(IsValid())
178  {
179  SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
180  SwPosition aPos(rNode);
181  xRet = static_cast<text::XWordCursor*>(
182  new SwXTextCursor(*GetDoc(), this, m_pImpl->m_eType, aPos));
183  xRet->gotoStart(false);
184  }
185  return xRet;
186 }
187 
188 uno::Any SAL_CALL
190 {
191  uno::Any aRet;
192  if (rType == cppu::UnoType<text::XText>::get())
193  {
194  aRet <<= uno::Reference< text::XText >(this);
195  }
196  else if (rType == cppu::UnoType<text::XSimpleText>::get())
197  {
198  aRet <<= uno::Reference< text::XSimpleText >(this);
199  }
200  else if (rType == cppu::UnoType<text::XTextRange>::get())
201  {
202  aRet <<= uno::Reference< text::XTextRange>(this);
203  }
205  {
206  aRet <<= uno::Reference< text::XTextRangeCompare >(this);
207  }
208  else if (rType == cppu::UnoType<lang::XTypeProvider>::get())
209  {
210  aRet <<= uno::Reference< lang::XTypeProvider >(this);
211  }
213  {
214  aRet <<= uno::Reference< text::XRelativeTextContentInsert >(this);
215  }
217  {
218  aRet <<= uno::Reference< text::XRelativeTextContentRemove >(this);
219  }
220  else if (rType == cppu::UnoType<beans::XPropertySet>::get())
221  {
222  aRet <<= uno::Reference< beans::XPropertySet >(this);
223  }
224  else if (rType == cppu::UnoType<lang::XUnoTunnel>::get())
225  {
226  aRet <<= uno::Reference< lang::XUnoTunnel >(this);
227  }
229  {
230  aRet <<= uno::Reference< text::XTextAppendAndConvert >(this);
231  }
232  else if (rType == cppu::UnoType<text::XTextAppend>::get())
233  {
234  aRet <<= uno::Reference< text::XTextAppend >(this);
235  }
237  {
238  aRet <<= uno::Reference< text::XTextPortionAppend >(this);
239  }
240  else if (rType == cppu::UnoType<text::XParagraphAppend>::get())
241  {
242  aRet <<= uno::Reference< text::XParagraphAppend >(this);
243  }
244  else if (rType == cppu::UnoType<text::XTextConvert>::get() )
245  {
246  aRet <<= uno::Reference< text::XTextConvert >(this);
247  }
249  {
250  aRet <<= uno::Reference< text::XTextContentAppend >(this);
251  }
252  else if(rType == cppu::UnoType<text::XTextCopy>::get())
253  {
254  aRet <<= uno::Reference< text::XTextCopy >( this );
255  }
256  return aRet;
257 }
258 
259 uno::Sequence< uno::Type > SAL_CALL
261 {
262  static const uno::Sequence< uno::Type > aTypes {
275  };
276  return aTypes;
277 }
278 
279 // belongs the range in the text ? insert it then.
280 void SAL_CALL
281 SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange,
282  const OUString& rString, sal_Bool bAbsorb)
283 {
284  SolarMutexGuard aGuard;
285  comphelper::ProfileZone aZone("SwXText::insertString");
286 
287  if (!xTextRange.is())
288  {
289  throw uno::RuntimeException();
290  }
291  if (!GetDoc())
292  {
293  throw uno::RuntimeException();
294  }
295  const uno::Reference<lang::XUnoTunnel> xRangeTunnel(xTextRange,
296  uno::UNO_QUERY);
297  SwXTextRange *const pRange =
298  ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
299  OTextCursorHelper *const pCursor =
300  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
301  if ((!pRange || &pRange ->GetDoc() != GetDoc()) &&
302  (!pCursor || pCursor->GetDoc() != GetDoc()))
303  {
304  throw uno::RuntimeException();
305  }
306 
307  const SwStartNode *const pOwnStartNode = GetStartNode();
308  SwPaM aPam(GetDoc()->GetNodes());
309  const SwPaM * pPam(nullptr);
310  if (pCursor)
311  {
312  pPam = pCursor->GetPaM();
313  }
314  else // pRange
315  {
316  if (pRange->GetPositions(aPam))
317  {
318  pPam = &aPam;
319  }
320  }
321  if (!pPam)
322  {
323  throw uno::RuntimeException();
324  }
325 
326  const SwStartNode* pTmp(pPam->GetNode().StartOfSectionNode());
327  while (pTmp && pTmp->IsSectionNode())
328  {
329  pTmp = pTmp->StartOfSectionNode();
330  }
331  if (!pOwnStartNode || (pOwnStartNode != pTmp))
332  {
333  throw uno::RuntimeException();
334  }
335 
336  bool bForceExpandHints( false );
337  if (CursorType::Meta == m_pImpl->m_eType)
338  {
339  try
340  {
341  bForceExpandHints = CheckForOwnMemberMeta(*pPam, bAbsorb);
342  }
343  catch (const lang::IllegalArgumentException& iae)
344  {
345  // stupid method not allowed to throw iae
346  css::uno::Any anyEx = cppu::getCaughtException();
347  throw lang::WrappedTargetRuntimeException( iae.Message,
348  uno::Reference< uno::XInterface >(), anyEx );
349  }
350  }
351  if (bAbsorb)
352  {
356  if (pCursor)
357  {
358  SwXTextCursor * const pTextCursor(
359  dynamic_cast<SwXTextCursor*>(pCursor) );
360  if (pTextCursor)
361  {
362  pTextCursor->DeleteAndInsert(rString, bForceExpandHints);
363  }
364  else
365  {
366  xTextRange->setString(rString);
367  }
368  }
369  else
370  {
371  pRange->DeleteAndInsert(rString, bForceExpandHints);
372  }
373  }
374  else
375  {
376  // create a PaM positioned before the parameter PaM,
377  // so the text is inserted before
378  UnoActionContext aContext(GetDoc());
379  SwPaM aInsertPam(*pPam->Start());
380  ::sw::GroupUndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
382  *GetDoc(), aInsertPam, rString, bForceExpandHints );
383  }
384 }
385 
386 void SAL_CALL
388  const uno::Reference< text::XTextRange > & xTextRange,
389  sal_Int16 nControlCharacter, sal_Bool bAbsorb)
390 {
391  SolarMutexGuard aGuard;
392 
393  if (!xTextRange.is())
394  {
395  throw lang::IllegalArgumentException();
396  }
397  if (!GetDoc())
398  {
399  throw uno::RuntimeException();
400  }
401 
402  SwUnoInternalPaM aPam(*GetDoc());
403  if (!::sw::XTextRangeToSwPaM(aPam, xTextRange))
404  {
405  throw uno::RuntimeException();
406  }
407  const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
408 
409  const SwInsertFlags nInsertFlags =
410  bForceExpandHints
413 
414  if (bAbsorb && aPam.HasMark())
415  {
416  m_pImpl->m_pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam);
417  aPam.DeleteMark();
418  }
419 
420  sal_Unicode cIns = 0;
421  switch (nControlCharacter)
422  {
423  case text::ControlCharacter::PARAGRAPH_BREAK :
424  // a table cell now becomes an ordinary text cell!
425  m_pImpl->m_pDoc->ClearBoxNumAttrs(aPam.GetPoint()->nNode);
426  m_pImpl->m_pDoc->getIDocumentContentOperations().SplitNode(*aPam.GetPoint(), false);
427  break;
428  case text::ControlCharacter::APPEND_PARAGRAPH:
429  {
430  m_pImpl->m_pDoc->ClearBoxNumAttrs(aPam.GetPoint()->nNode);
431  m_pImpl->m_pDoc->getIDocumentContentOperations().AppendTextNode(*aPam.GetPoint());
432 
433  const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
434  xTextRange, uno::UNO_QUERY);
435  SwXTextRange *const pRange =
436  ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
437  OTextCursorHelper *const pCursor =
438  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(
439  xRangeTunnel);
440  if (pRange)
441  {
442  pRange->SetPositions(aPam);
443  }
444  else if (pCursor)
445  {
446  SwPaM *const pCursorPam = pCursor->GetPaM();
447  *pCursorPam->GetPoint() = *aPam.GetPoint();
448  pCursorPam->DeleteMark();
449  }
450  }
451  break;
452  case text::ControlCharacter::LINE_BREAK: cIns = 10; break;
453  case text::ControlCharacter::SOFT_HYPHEN: cIns = CHAR_SOFTHYPHEN; break;
454  case text::ControlCharacter::HARD_HYPHEN: cIns = CHAR_HARDHYPHEN; break;
455  case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break;
456  }
457  if (cIns)
458  {
459  m_pImpl->m_pDoc->getIDocumentContentOperations().InsertString(
460  aPam, OUString(cIns), nInsertFlags);
461  }
462 
463  if (!bAbsorb)
464  return;
465 
466  const uno::Reference<lang::XUnoTunnel> xRangeTunnel(
467  xTextRange, uno::UNO_QUERY);
468  SwXTextRange *const pRange =
469  ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
470  OTextCursorHelper *const pCursor =
471  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
472 
473  SwCursor aCursor(*aPam.GetPoint(), nullptr);
474  SwUnoCursorHelper::SelectPam(aCursor, true);
475  aCursor.Left(1);
476  // here, the PaM needs to be moved:
477  if (pRange)
478  {
479  pRange->SetPositions(aCursor);
480  }
481  else
482  {
483  SwPaM *const pUnoCursor = pCursor->GetPaM();
484  *pUnoCursor->GetPoint() = *aCursor.GetPoint();
485  if (aCursor.HasMark())
486  {
487  pUnoCursor->SetMark();
488  *pUnoCursor->GetMark() = *aCursor.GetMark();
489  }
490  else
491  {
492  pUnoCursor->DeleteMark();
493  }
494  }
495 }
496 
497 void SAL_CALL
499  const uno::Reference< text::XTextRange > & xRange,
500  const uno::Reference< text::XTextContent > & xContent,
501  sal_Bool bAbsorb)
502 {
503  SolarMutexGuard aGuard;
504  comphelper::ProfileZone aZone("SwXText::insertTextContent");
505 
506  if (!xRange.is())
507  {
508  lang::IllegalArgumentException aIllegal;
509  aIllegal.Message = "first parameter invalid;";
510  throw aIllegal;
511  }
512  if (!xContent.is())
513  {
514  lang::IllegalArgumentException aIllegal;
515  aIllegal.Message = "second parameter invalid";
516  throw aIllegal;
517  }
518  if(!GetDoc())
519  {
520  uno::RuntimeException aRuntime;
521  aRuntime.Message = cInvalidObject;
522  throw aRuntime;
523  }
524 
525  SwUnoInternalPaM aPam(*GetDoc());
526  if (!::sw::XTextRangeToSwPaM(aPam, xRange))
527  {
528  lang::IllegalArgumentException aIllegal;
529  aIllegal.Message = "first parameter invalid";
530  throw aIllegal;
531  }
532 
533  // first test if the range is at the right position, then call
534  // xContent->attach
535  const SwStartNode* pOwnStartNode = GetStartNode();
536  SwStartNodeType eSearchNodeType = SwNormalStartNode;
537  switch (m_pImpl->m_eType)
538  {
539  case CursorType::Frame: eSearchNodeType = SwFlyStartNode; break;
540  case CursorType::TableText: eSearchNodeType = SwTableBoxStartNode; break;
541  case CursorType::Footnote: eSearchNodeType = SwFootnoteStartNode; break;
542  case CursorType::Header: eSearchNodeType = SwHeaderStartNode; break;
543  case CursorType::Footer: eSearchNodeType = SwFooterStartNode; break;
544  //case CURSOR_INVALID:
545  //case CursorType::Body:
546  default:
547  break;
548  }
549 
550  const SwStartNode* pTmp =
551  aPam.GetNode().FindSttNodeByType(eSearchNodeType);
552 
553  // ignore SectionNodes
554  while (pTmp && pTmp->IsSectionNode())
555  {
556  pTmp = pTmp->StartOfSectionNode();
557  }
558  // if the document starts with a section
559  while (pOwnStartNode && pOwnStartNode->IsSectionNode())
560  {
561  pOwnStartNode = pOwnStartNode->StartOfSectionNode();
562  }
563  // this checks if (this) and xRange are in the same text::XText interface
564  if (pOwnStartNode != pTmp)
565  {
566  uno::RuntimeException aRunException;
567  aRunException.Message = "text interface and cursor not related";
568  throw aRunException;
569  }
570 
571  const bool bForceExpandHints(CheckForOwnMemberMeta(aPam, bAbsorb));
572 
573  // special treatment for Contents that do not replace the range, but
574  // instead are "overlaid"
575  const uno::Reference<lang::XUnoTunnel> xContentTunnel(xContent,
576  uno::UNO_QUERY);
577  if (!xContentTunnel.is())
578  {
579  lang::IllegalArgumentException aArgException;
580  aArgException.Message = "text content does not support lang::XUnoTunnel";
581  throw aArgException;
582  }
583  SwXDocumentIndexMark *const pDocumentIndexMark =
584  ::sw::UnoTunnelGetImplementation<SwXDocumentIndexMark>(xContentTunnel);
585  SwXTextSection *const pSection =
586  ::sw::UnoTunnelGetImplementation<SwXTextSection>(xContentTunnel);
587  SwXBookmark *const pBookmark =
588  ::sw::UnoTunnelGetImplementation<SwXBookmark>(xContentTunnel);
589  SwXReferenceMark *const pReferenceMark =
590  ::sw::UnoTunnelGetImplementation<SwXReferenceMark>(xContentTunnel);
591  SwXMeta *const pMeta =
592  ::sw::UnoTunnelGetImplementation<SwXMeta>(xContentTunnel);
593  SwXTextField* pTextField =
594  ::sw::UnoTunnelGetImplementation<SwXTextField>(xContentTunnel);
595  if (pTextField && pTextField->GetServiceId() != SwServiceType::FieldTypeAnnotation)
596  pTextField = nullptr;
597 
598  const bool bAttribute = pBookmark || pDocumentIndexMark
599  || pSection || pReferenceMark || pMeta || pTextField;
600 
601  if (bAbsorb && !bAttribute)
602  {
603  xRange->setString(OUString());
604  }
605  uno::Reference< text::XTextRange > xTempRange =
606  (bAttribute && bAbsorb) ? xRange : xRange->getStart();
607  if (bForceExpandHints)
608  {
609  // if necessary, replace xTempRange with a new SwXTextCursor
610  PrepareForAttach(xTempRange, aPam);
611  }
612  xContent->attach(xTempRange);
613 }
614 
615 void SAL_CALL
617  const uno::Reference< text::XTextContent>& xNewContent,
618  const uno::Reference< text::XTextContent>& xSuccessor)
619 {
620  SolarMutexGuard aGuard;
621 
622  if(!GetDoc())
623  {
624  uno::RuntimeException aRuntime;
625  aRuntime.Message = cInvalidObject;
626  throw aRuntime;
627  }
628 
629  SwXParagraph *const pPara =
630  comphelper::getUnoTunnelImplementation<SwXParagraph>(xNewContent);
631  if (!pPara || !pPara->IsDescriptor() || !xSuccessor.is())
632  {
633  throw lang::IllegalArgumentException();
634  }
635 
636  bool bRet = false;
637  const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
638  uno::UNO_QUERY);
639  SwXTextSection *const pXSection =
640  ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
641  SwXTextTable *const pXTable =
642  ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
643  SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
644  SwTextNode * pTextNode = nullptr;
645  if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
646  {
647  SwTable *const pTable = SwTable::FindTable( pTableFormat );
648  SwTableNode *const pTableNode = pTable->GetTableNode();
649 
650  const SwNodeIndex aTableIdx( *pTableNode, -1 );
651  SwPosition aBefore(aTableIdx);
652  bRet = GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore );
653  pTextNode = aBefore.nNode.GetNode().GetTextNode();
654  }
655  else if (pXSection && pXSection->GetFormat() &&
656  pXSection->GetFormat()->GetDoc() == GetDoc())
657  {
658  SwSectionFormat *const pSectFormat = pXSection->GetFormat();
659  SwSectionNode *const pSectNode = pSectFormat->GetSectionNode();
660 
661  const SwNodeIndex aSectIdx( *pSectNode, -1 );
662  SwPosition aBefore(aSectIdx);
663  bRet = GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore );
664  pTextNode = aBefore.nNode.GetNode().GetTextNode();
665  }
666  if (!bRet || !pTextNode)
667  {
668  throw lang::IllegalArgumentException();
669  }
670  pPara->attachToText(*this, *pTextNode);
671 }
672 
673 void SAL_CALL
675  const uno::Reference< text::XTextContent>& xNewContent,
676  const uno::Reference< text::XTextContent>& xPredecessor)
677 {
678  SolarMutexGuard aGuard;
679 
680  if(!GetDoc())
681  {
682  throw uno::RuntimeException();
683  }
684 
685  SwXParagraph *const pPara =
686  comphelper::getUnoTunnelImplementation<SwXParagraph>(xNewContent);
687  if(!pPara || !pPara->IsDescriptor() || !xPredecessor.is())
688  {
689  throw lang::IllegalArgumentException();
690  }
691 
692  const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
693  uno::UNO_QUERY);
694  SwXTextSection *const pXSection =
695  ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
696  SwXTextTable *const pXTable =
697  ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
698  SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
699  bool bRet = false;
700  SwTextNode * pTextNode = nullptr;
701  if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
702  {
703  SwTable *const pTable = SwTable::FindTable( pTableFormat );
704  SwTableNode *const pTableNode = pTable->GetTableNode();
705 
706  SwEndNode *const pTableEnd = pTableNode->EndOfSectionNode();
707  SwPosition aTableEnd(*pTableEnd);
708  bRet = GetDoc()->getIDocumentContentOperations().AppendTextNode( aTableEnd );
709  pTextNode = aTableEnd.nNode.GetNode().GetTextNode();
710  }
711  else if (pXSection && pXSection->GetFormat() &&
712  pXSection->GetFormat()->GetDoc() == GetDoc())
713  {
714  SwSectionFormat *const pSectFormat = pXSection->GetFormat();
715  SwSectionNode *const pSectNode = pSectFormat->GetSectionNode();
716  SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
717  SwPosition aEnd(*pEnd);
719  pTextNode = aEnd.nNode.GetNode().GetTextNode();
720  }
721  if (!bRet || !pTextNode)
722  {
723  throw lang::IllegalArgumentException();
724  }
725  pPara->attachToText(*this, *pTextNode);
726 }
727 
728 void SAL_CALL
730  const uno::Reference< text::XTextContent>& xSuccessor)
731 {
732  SolarMutexGuard aGuard;
733 
734  if(!GetDoc())
735  {
736  uno::RuntimeException aRuntime;
737  aRuntime.Message = cInvalidObject;
738  throw aRuntime;
739  }
740 
741  bool bRet = false;
742  const uno::Reference<lang::XUnoTunnel> xSuccTunnel(xSuccessor,
743  uno::UNO_QUERY);
744  SwXTextSection *const pXSection =
745  ::sw::UnoTunnelGetImplementation<SwXTextSection>(xSuccTunnel);
746  SwXTextTable *const pXTable =
747  ::sw::UnoTunnelGetImplementation<SwXTextTable>(xSuccTunnel);
748  SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
749  if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
750  {
751  SwTable *const pTable = SwTable::FindTable( pTableFormat );
752  SwTableNode *const pTableNode = pTable->GetTableNode();
753 
754  const SwNodeIndex aTableIdx( *pTableNode, -1 );
755  if(aTableIdx.GetNode().IsTextNode())
756  {
757  SwPaM aBefore(aTableIdx);
758  bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aBefore );
759  }
760  }
761  else if (pXSection && pXSection->GetFormat() &&
762  pXSection->GetFormat()->GetDoc() == GetDoc())
763  {
764  SwSectionFormat *const pSectFormat = pXSection->GetFormat();
765  SwSectionNode *const pSectNode = pSectFormat->GetSectionNode();
766 
767  const SwNodeIndex aSectIdx( *pSectNode, -1 );
768  if(aSectIdx.GetNode().IsTextNode())
769  {
770  SwPaM aBefore(aSectIdx);
771  bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aBefore );
772  }
773  }
774  if(!bRet)
775  {
776  throw lang::IllegalArgumentException();
777  }
778 }
779 
780 void SAL_CALL
782  const uno::Reference< text::XTextContent>& xPredecessor)
783 {
784  SolarMutexGuard aGuard;
785 
786  if(!GetDoc())
787  {
788  uno::RuntimeException aRuntime;
789  aRuntime.Message = cInvalidObject;
790  throw aRuntime;
791  }
792 
793  bool bRet = false;
794  const uno::Reference<lang::XUnoTunnel> xPredTunnel(xPredecessor,
795  uno::UNO_QUERY);
796  SwXTextSection *const pXSection =
797  ::sw::UnoTunnelGetImplementation<SwXTextSection>(xPredTunnel);
798  SwXTextTable *const pXTable =
799  ::sw::UnoTunnelGetImplementation<SwXTextTable>(xPredTunnel);
800  SwFrameFormat *const pTableFormat = pXTable ? pXTable->GetFrameFormat() : nullptr;
801  if(pTableFormat && pTableFormat->GetDoc() == GetDoc())
802  {
803  SwTable *const pTable = SwTable::FindTable( pTableFormat );
804  SwTableNode *const pTableNode = pTable->GetTableNode();
805  SwEndNode *const pTableEnd = pTableNode->EndOfSectionNode();
806 
807  const SwNodeIndex aTableIdx( *pTableEnd, 1 );
808  if(aTableIdx.GetNode().IsTextNode())
809  {
810  SwPaM aPaM(aTableIdx);
812  }
813  }
814  else if (pXSection && pXSection->GetFormat() &&
815  pXSection->GetFormat()->GetDoc() == GetDoc())
816  {
817  SwSectionFormat *const pSectFormat = pXSection->GetFormat();
818  SwSectionNode *const pSectNode = pSectFormat->GetSectionNode();
819  SwEndNode *const pEnd = pSectNode->EndOfSectionNode();
820  const SwNodeIndex aSectIdx( *pEnd, 1 );
821  if(aSectIdx.GetNode().IsTextNode())
822  {
823  SwPaM aAfter(aSectIdx);
824  bRet = GetDoc()->getIDocumentContentOperations().DelFullPara( aAfter );
825  }
826  }
827  if(!bRet)
828  {
829  throw lang::IllegalArgumentException();
830  }
831 }
832 
833 void SAL_CALL
835  const uno::Reference< text::XTextContent > & xContent)
836 {
837  // forward: need no solar mutex here
838  if(!xContent.is())
839  {
840  uno::RuntimeException aRuntime;
841  aRuntime.Message = "first parameter invalid";
842  throw aRuntime;
843  }
844  xContent->dispose();
845 }
846 
847 uno::Reference< text::XText > SAL_CALL
849 {
850  SolarMutexGuard aGuard;
851  comphelper::ProfileZone aZone("SwXText::getText");
852 
853  const uno::Reference< text::XText > xRet(this);
854  return xRet;
855 }
856 
857 uno::Reference< text::XTextRange > SAL_CALL
859 {
860  SolarMutexGuard aGuard;
861 
862  const uno::Reference< text::XTextCursor > xRef = CreateCursor();
863  if(!xRef.is())
864  {
865  uno::RuntimeException aRuntime;
866  aRuntime.Message = cInvalidObject;
867  throw aRuntime;
868  }
869  xRef->gotoStart(false);
870  return xRef;
871 }
872 
873 uno::Reference< text::XTextRange > SAL_CALL
875 {
876  SolarMutexGuard aGuard;
877 
878  const uno::Reference< text::XTextCursor > xRef = CreateCursor();
879  if(!xRef.is())
880  {
881  uno::RuntimeException aRuntime;
882  aRuntime.Message = cInvalidObject;
883  throw aRuntime;
884  }
885  xRef->gotoEnd(false);
886  return xRef;
887 }
888 
889 OUString SAL_CALL SwXText::getString()
890 {
891  SolarMutexGuard aGuard;
892 
893  const uno::Reference< text::XTextCursor > xRet = CreateCursor();
894  if(!xRet.is())
895  {
896  SAL_WARN("sw.uno", "cursor was not created in getString() call. Returning empty string.");
897  return OUString();
898  }
899  xRet->gotoEnd(true);
900  return xRet->getString();
901 }
902 
903 void SAL_CALL
904 SwXText::setString(const OUString& rString)
905 {
906  SolarMutexGuard aGuard;
907 
908  if (!GetDoc())
909  {
910  uno::RuntimeException aRuntime;
911  aRuntime.Message = cInvalidObject;
912  throw aRuntime;
913  }
914 
915  const SwStartNode* pStartNode = GetStartNode();
916  if (!pStartNode)
917  {
918  throw uno::RuntimeException();
919  }
920 
922  //insert an empty paragraph at the start and at the end to ensure that
923  //all tables and sections can be removed by the selecting text::XTextCursor
924  if (CursorType::Meta != m_pImpl->m_eType)
925  {
926  SwPosition aStartPos(*pStartNode);
927  const SwEndNode* pEnd = pStartNode->EndOfSectionNode();
928  SwNodeIndex aEndIdx(*pEnd);
929  --aEndIdx;
930  //the inserting of nodes should only be done if really necessary
931  //to prevent #97924# (removes paragraph attributes when setting the text
932  //e.g. of a table cell
933  bool bInsertNodes = false;
934  SwNodeIndex aStartIdx(*pStartNode);
935  do
936  {
937  ++aStartIdx;
938  SwNode& rCurrentNode = aStartIdx.GetNode();
939  if(rCurrentNode.GetNodeType() == SwNodeType::Section
940  ||rCurrentNode.GetNodeType() == SwNodeType::Table)
941  {
942  bInsertNodes = true;
943  break;
944  }
945  }
946  while(aStartIdx < aEndIdx);
947  if(bInsertNodes)
948  {
950  SwPosition aEndPos(aEndIdx.GetNode());
951  SwPaM aPam(aEndPos);
953  }
954  }
955 
956  const uno::Reference< text::XTextCursor > xRet = CreateCursor();
957  if(!xRet.is())
958  {
960  uno::RuntimeException aRuntime;
961  aRuntime.Message = cInvalidObject;
962  throw aRuntime;
963  }
964  xRet->gotoEnd(true);
965  xRet->setString(rString);
967 }
968 
969 //FIXME why is CheckForOwnMember duplicated in some insert methods?
970 // Description: Checks if pRange/pCursor are member of the same text interface.
971 // Only one of the pointers has to be set!
973  const SwPaM & rPaM)
974 {
975  const uno::Reference<text::XTextCursor> xOwnCursor(m_rThis.CreateCursor());
976 
977  OTextCursorHelper *const pOwnCursor =
978  comphelper::getUnoTunnelImplementation<OTextCursorHelper>(xOwnCursor);
979  OSL_ENSURE(pOwnCursor, "OTextCursorHelper::getUnoTunnelId() ??? ");
980  const SwStartNode* pOwnStartNode =
981  pOwnCursor->GetPaM()->GetNode().StartOfSectionNode();
982  SwStartNodeType eSearchNodeType = SwNormalStartNode;
983  switch (m_eType)
984  {
985  case CursorType::Frame: eSearchNodeType = SwFlyStartNode; break;
986  case CursorType::TableText: eSearchNodeType = SwTableBoxStartNode; break;
987  case CursorType::Footnote: eSearchNodeType = SwFootnoteStartNode; break;
988  case CursorType::Header: eSearchNodeType = SwHeaderStartNode; break;
989  case CursorType::Footer: eSearchNodeType = SwFooterStartNode; break;
990  //case CURSOR_INVALID:
991  //case CursorType::Body:
992  default:
993  ;
994  }
995 
996  const SwNode& rSrcNode = rPaM.GetNode();
997  const SwStartNode* pTmp = rSrcNode.FindSttNodeByType(eSearchNodeType);
998 
999  // skip SectionNodes / TableNodes to be able to compare across table/section boundaries
1000  while (pTmp
1001  && (pTmp->IsSectionNode() || pTmp->IsTableNode()
1003  && pTmp->GetStartNodeType() == SwTableBoxStartNode)))
1004  {
1005  pTmp = pTmp->StartOfSectionNode();
1006  }
1007 
1008  while (pOwnStartNode->IsSectionNode() || pOwnStartNode->IsTableNode()
1010  && pOwnStartNode->GetStartNodeType() == SwTableBoxStartNode))
1011  {
1012  pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1013  }
1014 
1015  //this checks if (this) and xRange are in the same text::XText interface
1016  return (pOwnStartNode == pTmp);
1017 }
1018 
1019 sal_Int16
1021  const uno::Reference<text::XTextRange>& xPos1,
1022  const uno::Reference<text::XTextRange>& xPos2)
1023 {
1024  SwUnoInternalPaM aPam1(*m_pDoc);
1025  SwUnoInternalPaM aPam2(*m_pDoc);
1026 
1027  if (!::sw::XTextRangeToSwPaM(aPam1, xPos1) ||
1028  !::sw::XTextRangeToSwPaM(aPam2, xPos2))
1029  {
1030  throw lang::IllegalArgumentException();
1031  }
1032  if (!CheckForOwnMember(aPam1) || !CheckForOwnMember(aPam2))
1033  {
1034  throw lang::IllegalArgumentException();
1035  }
1036 
1037  sal_Int16 nCompare = 0;
1038  SwPosition const*const pStart1 = aPam1.Start();
1039  SwPosition const*const pStart2 = aPam2.Start();
1040  if (*pStart1 < *pStart2)
1041  {
1042  nCompare = 1;
1043  }
1044  else if (*pStart1 > *pStart2)
1045  {
1046  nCompare = -1;
1047  }
1048  else
1049  {
1050  OSL_ENSURE(*pStart1 == *pStart2,
1051  "SwPositions should be equal here");
1052  nCompare = 0;
1053  }
1054 
1055  return nCompare;
1056 }
1057 
1058 sal_Int16 SAL_CALL
1060  const uno::Reference<text::XTextRange>& xRange1,
1061  const uno::Reference<text::XTextRange>& xRange2)
1062 {
1063  SolarMutexGuard aGuard;
1064 
1065  if (!xRange1.is() || !xRange2.is())
1066  {
1067  throw lang::IllegalArgumentException();
1068  }
1069  const uno::Reference<text::XTextRange> xStart1 = xRange1->getStart();
1070  const uno::Reference<text::XTextRange> xStart2 = xRange2->getStart();
1071 
1072  return m_pImpl->ComparePositions(xStart1, xStart2);
1073 }
1074 
1075 sal_Int16 SAL_CALL
1077  const uno::Reference<text::XTextRange>& xRange1,
1078  const uno::Reference<text::XTextRange>& xRange2)
1079 {
1080  SolarMutexGuard aGuard;
1081 
1082  if (!xRange1.is() || !xRange2.is())
1083  {
1084  throw lang::IllegalArgumentException();
1085  }
1086  uno::Reference<text::XTextRange> xEnd1 = xRange1->getEnd();
1087  uno::Reference<text::XTextRange> xEnd2 = xRange2->getEnd();
1088 
1089  return m_pImpl->ComparePositions(xEnd1, xEnd2);
1090 }
1091 
1092 uno::Reference< beans::XPropertySetInfo > SAL_CALL
1094 {
1095  SolarMutexGuard g;
1096 
1097  static uno::Reference< beans::XPropertySetInfo > xInfo =
1098  m_pImpl->m_rPropSet.getPropertySetInfo();
1099  return xInfo;
1100 }
1101 
1102 void SAL_CALL
1103 SwXText::setPropertyValue(const OUString& /*aPropertyName*/,
1104  const uno::Any& /*aValue*/)
1105 {
1106  throw lang::IllegalArgumentException();
1107 }
1108 
1109 uno::Any SAL_CALL
1111  const OUString& rPropertyName)
1112 {
1113  SolarMutexGuard aGuard;
1114 
1115  if(!IsValid())
1116  {
1117  throw uno::RuntimeException();
1118  }
1119 
1120  SfxItemPropertySimpleEntry const*const pEntry =
1121  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1122  if (!pEntry)
1123  {
1124  beans::UnknownPropertyException aExcept;
1125  aExcept.Message = "Unknown property: " + rPropertyName;
1126  throw aExcept;
1127  }
1128 
1129  uno::Any aRet;
1130  switch (pEntry->nWID)
1131  {
1132 // no code necessary - the redline is always located at the end node
1133 // case FN_UNO_REDLINE_NODE_START:
1134 // break;
1136  {
1138  const size_t nRedTableCount = rRedTable.size();
1139  if (nRedTableCount > 0)
1140  {
1141  SwStartNode const*const pStartNode = GetStartNode();
1142  const sal_uLong nOwnIndex = pStartNode->EndOfSectionIndex();
1143  for (size_t nRed = 0; nRed < nRedTableCount; ++nRed)
1144  {
1145  SwRangeRedline const*const pRedline = rRedTable[nRed];
1146  SwPosition const*const pRedStart = pRedline->Start();
1147  const SwNodeIndex nRedNode = pRedStart->nNode;
1148  if (nOwnIndex == nRedNode.GetIndex())
1149  {
1151  *pRedline, true);
1152  break;
1153  }
1154  }
1155  }
1156  }
1157  break;
1158  }
1159  return aRet;
1160 }
1161 
1162 void SAL_CALL
1164  const OUString& /*rPropertyName*/,
1165  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1166 {
1167  OSL_FAIL("SwXText::addPropertyChangeListener(): not implemented");
1168 }
1169 
1170 void SAL_CALL
1172  const OUString& /*rPropertyName*/,
1173  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1174 {
1175  OSL_FAIL("SwXText::removePropertyChangeListener(): not implemented");
1176 }
1177 
1178 void SAL_CALL
1180  const OUString& /*rPropertyName*/,
1181  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1182 {
1183  OSL_FAIL("SwXText::addVetoableChangeListener(): not implemented");
1184 }
1185 
1186 void SAL_CALL
1188  const OUString& /*rPropertyName*/,
1189  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1190 {
1191  OSL_FAIL("SwXText::removeVetoableChangeListener(): not implemented");
1192 }
1193 
1194 namespace
1195 {
1196  class theSwXTextUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextUnoTunnelId > {};
1197 }
1198 
1199 const uno::Sequence< sal_Int8 > & SwXText::getUnoTunnelId()
1200 {
1201  return theSwXTextUnoTunnelId::get().getSeq();
1202 }
1203 
1204 sal_Int64 SAL_CALL
1205 SwXText::getSomething(const uno::Sequence< sal_Int8 >& rId)
1206 {
1207  return ::sw::UnoTunnelImpl<SwXText>(rId, this);
1208 }
1209 
1210 uno::Reference< text::XTextRange > SAL_CALL
1212  const uno::Sequence< beans::PropertyValue > & rProperties)
1213 {
1214  SolarMutexGuard g;
1215 
1216  return m_pImpl->finishOrAppendParagraph(rProperties, uno::Reference< text::XTextRange >());
1217 }
1218 
1219 uno::Reference< text::XTextRange > SAL_CALL
1221  const uno::Sequence< beans::PropertyValue > & rProperties,
1222  const uno::Reference< text::XTextRange >& xInsertPosition)
1223 {
1224  SolarMutexGuard g;
1225 
1226  return m_pImpl->finishOrAppendParagraph(rProperties, xInsertPosition);
1227 }
1228 
1229 uno::Reference< text::XTextRange >
1231  const uno::Sequence< beans::PropertyValue > & rProperties,
1232  const uno::Reference< text::XTextRange >& xInsertPosition)
1233 {
1234  if (!m_bIsValid)
1235  {
1236  throw uno::RuntimeException();
1237  }
1238 
1239  const SwStartNode* pStartNode = m_rThis.GetStartNode();
1240  if(!pStartNode)
1241  {
1242  throw uno::RuntimeException();
1243  }
1244 
1245  uno::Reference< text::XTextRange > xRet;
1246  bool bIllegalException = false;
1247  bool bRuntimeException = false;
1248  OUString sMessage;
1250  // find end node, go backward - don't skip tables because the new
1251  // paragraph has to be the last node
1252  //aPam.Move( fnMoveBackward, GoInNode );
1253  SwPosition aInsertPosition(
1254  SwNodeIndex( *pStartNode->EndOfSectionNode(), -1 ) );
1255  SwPaM aPam(aInsertPosition);
1256  // If we got a position reference, then the insert point is not the end of
1257  // the document.
1258  if (xInsertPosition.is())
1259  {
1260  SwUnoInternalPaM aStartPam(*m_rThis.GetDoc());
1261  ::sw::XTextRangeToSwPaM(aStartPam, xInsertPosition);
1262  aPam = aStartPam;
1263  aPam.SetMark();
1264  }
1266  // remove attributes from the previous paragraph
1267  m_pDoc->ResetAttrs(aPam);
1268  // in case of finishParagraph the PaM needs to be moved to the
1269  // previous paragraph
1270  aPam.Move( fnMoveBackward, GoInNode );
1271 
1272  try
1273  {
1274  SfxItemPropertySet const*const pParaPropSet =
1276 
1277  SwUnoCursorHelper::SetPropertyValues(aPam, *pParaPropSet, rProperties);
1278 
1279  // tdf#127616 keep direct character formatting of empty paragraphs,
1280  // if character style of the paragraph sets also the same attributes
1281  if (aPam.Start()->nNode.GetNode().GetTextNode()->Len() == 0)
1282  {
1283  auto itCharStyle = std::find_if(rProperties.begin(), rProperties.end(), [](const beans::PropertyValue& rValue)
1284  {
1285  return rValue.Name == "CharStyleName";
1286  });
1287  if ( itCharStyle != rProperties.end() )
1288  {
1289  for (const auto& rValue : rProperties)
1290  {
1291  if ( rValue != *itCharStyle && rValue.Name.startsWith("Char") )
1292  {
1293  SwUnoCursorHelper::SetPropertyValue(aPam, *pParaPropSet, rValue.Name, rValue.Value);
1294  }
1295  }
1296  }
1297  }
1298  }
1299  catch (const lang::IllegalArgumentException& rIllegal)
1300  {
1301  sMessage = rIllegal.Message;
1302  bIllegalException = true;
1303  }
1304  catch (const uno::RuntimeException& rRuntime)
1305  {
1306  sMessage = rRuntime.Message;
1307  bRuntimeException = true;
1308  }
1309  catch (const uno::Exception& rEx)
1310  {
1311  sMessage = rEx.Message;
1312  bRuntimeException = true;
1313  }
1314 
1316  if (bIllegalException || bRuntimeException)
1317  {
1319  if (bIllegalException)
1320  {
1321  lang::IllegalArgumentException aEx;
1322  aEx.Message = sMessage;
1323  throw aEx;
1324  }
1325  else
1326  {
1327  uno::RuntimeException aEx;
1328  aEx.Message = sMessage;
1329  throw aEx;
1330  }
1331  }
1332  SwTextNode *const pTextNode( aPam.Start()->nNode.GetNode().GetTextNode() );
1333  OSL_ENSURE(pTextNode, "no SwTextNode?");
1334  if (pTextNode)
1335  {
1336  xRet.set(SwXParagraph::CreateXParagraph(*m_pDoc, pTextNode, &m_rThis),
1337  uno::UNO_QUERY);
1338  }
1339 
1340  return xRet;
1341 }
1342 
1343 uno::Reference< text::XTextRange > SAL_CALL
1345  const OUString& rText,
1346  const uno::Sequence< beans::PropertyValue > &
1347  rCharacterAndParagraphProperties,
1348  const uno::Reference<text::XTextRange>& xInsertPosition)
1349 {
1350  SolarMutexGuard aGuard;
1351 
1352  if(!IsValid())
1353  {
1354  throw uno::RuntimeException();
1355  }
1356  uno::Reference< text::XTextRange > xRet;
1357  const uno::Reference<text::XTextCursor> xTextCursor = createTextCursorByRange(xInsertPosition);
1358 
1359  const uno::Reference< lang::XUnoTunnel > xRangeTunnel(
1360  xTextCursor, uno::UNO_QUERY_THROW );
1361  SwXTextCursor *const pTextCursor =
1362  ::sw::UnoTunnelGetImplementation<SwXTextCursor>(xRangeTunnel);
1363 
1364  bool bIllegalException = false;
1365  bool bRuntimeException = false;
1366  OUString sMessage;
1367  m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
1368 
1369  auto& rCursor(pTextCursor->GetCursor());
1370  m_pImpl->m_pDoc->DontExpandFormat( *rCursor.Start() );
1371 
1372  if (!rText.isEmpty())
1373  {
1374  SwNodeIndex const nodeIndex(rCursor.GetPoint()->nNode, -1);
1375  const sal_Int32 nContentPos = rCursor.GetPoint()->nContent.GetIndex();
1377  *m_pImpl->m_pDoc, rCursor, rText, false);
1378  SwUnoCursorHelper::SelectPam(rCursor, true);
1379  rCursor.GetPoint()->nNode.Assign(nodeIndex.GetNode(), +1);
1380  rCursor.GetPoint()->nContent = nContentPos;
1381  }
1382 
1383  try
1384  {
1385  SfxItemPropertySet const*const pCursorPropSet =
1387  SwUnoCursorHelper::SetPropertyValues(rCursor, *pCursorPropSet,
1388  rCharacterAndParagraphProperties,
1390  }
1391  catch (const lang::IllegalArgumentException& rIllegal)
1392  {
1393  sMessage = rIllegal.Message;
1394  bIllegalException = true;
1395  }
1396  catch (const uno::RuntimeException& rRuntime)
1397  {
1398  sMessage = rRuntime.Message;
1399  bRuntimeException = true;
1400  }
1401  m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
1402  if (bIllegalException || bRuntimeException)
1403  {
1404  m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
1405  if (bIllegalException)
1406  {
1407  lang::IllegalArgumentException aEx;
1408  aEx.Message = sMessage;
1409  throw aEx;
1410  }
1411  else
1412  {
1413  uno::RuntimeException aEx;
1414  aEx.Message = sMessage;
1415  throw aEx;
1416  }
1417  }
1418  xRet = new SwXTextRange(rCursor, this);
1419  return xRet;
1420 }
1421 
1422 // Append text portions at the end of the last paragraph of the text interface.
1423 // Support of import filters.
1424 uno::Reference< text::XTextRange > SAL_CALL
1426  const OUString& rText,
1427  const uno::Sequence< beans::PropertyValue > &
1428  rCharacterAndParagraphProperties)
1429 {
1430  // Right now this doesn't need a guard, as it's just calling the insert
1431  // version, that has it already.
1432  uno::Reference<text::XTextRange> xInsertPosition = getEnd();
1433  return insertTextPortion(rText, rCharacterAndParagraphProperties, xInsertPosition);
1434 }
1435 
1436 // enable inserting/appending text contents like graphic objects, shapes and so on to
1437 // support import filters
1438 uno::Reference< text::XTextRange > SAL_CALL
1440  const uno::Reference< text::XTextContent >& xTextContent,
1441  const uno::Sequence< beans::PropertyValue >&
1442  rCharacterAndParagraphProperties,
1443  const uno::Reference< text::XTextRange >& xInsertPosition)
1444 {
1445  SolarMutexGuard aGuard;
1446 
1447  if (!IsValid())
1448  {
1449  throw uno::RuntimeException();
1450  }
1451 
1452  SwUnoInternalPaM aPam(*GetDoc());
1453  if (!::sw::XTextRangeToSwPaM(aPam, xInsertPosition))
1454  {
1455  throw lang::IllegalArgumentException("invalid position", nullptr, 2);
1456  }
1457 
1458  SwRewriter aRewriter;
1459  aRewriter.AddRule(UndoArg1, SwResId(STR_UNDO_INSERT_TEXTBOX));
1460 
1461  m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, &aRewriter);
1462 
1463  // Any direct formatting ending at the insert position (xRange) should not
1464  // be expanded to cover the inserted content (xContent)
1465  // (insertTextContent() shouldn't do this, only ...WithProperties()!)
1466  GetDoc()->DontExpandFormat( *aPam.Start() );
1467 
1468  // now attach the text content here
1469  insertTextContent( xInsertPosition, xTextContent, false );
1470  // now apply the properties to the anchor
1471  if (rCharacterAndParagraphProperties.hasElements())
1472  {
1473  try
1474  {
1475  const uno::Reference< beans::XPropertySet > xAnchor(
1476  xTextContent->getAnchor(), uno::UNO_QUERY);
1477  if (xAnchor.is())
1478  {
1479  for (const auto& rProperty : rCharacterAndParagraphProperties)
1480  {
1481  xAnchor->setPropertyValue(rProperty.Name, rProperty.Value);
1482  }
1483  }
1484  }
1485  catch (const uno::Exception& e)
1486  {
1487  css::uno::Any anyEx = cppu::getCaughtException();
1488  m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
1489  throw lang::WrappedTargetRuntimeException( e.Message,
1490  uno::Reference< uno::XInterface >(), anyEx );
1491  }
1492  }
1493  m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, &aRewriter);
1494  return xInsertPosition;
1495 }
1496 
1497 uno::Reference< text::XTextRange > SAL_CALL
1499  const uno::Reference< text::XTextContent >& xTextContent,
1500  const uno::Sequence< beans::PropertyValue >& rCharacterAndParagraphProperties
1501  )
1502 {
1503  // Right now this doesn't need a guard, as it's just calling the insert
1504  // version, that has it already.
1505  uno::Reference<text::XTextRange> xInsertPosition = getEnd();
1506  return insertTextContentWithProperties(xTextContent, rCharacterAndParagraphProperties, xInsertPosition);
1507 }
1508 
1509 // determine whether SwFrameFormat is a graphic node
1510 static bool isGraphicNode(const SwFrameFormat* pFrameFormat)
1511 {
1512  // safety
1513  if( !pFrameFormat->GetContent().GetContentIdx() )
1514  {
1515  return false;
1516  }
1517  auto index = *pFrameFormat->GetContent().GetContentIdx();
1518  // consider the next node -> there is the graphic stored
1519  index++;
1520  return index.GetNode().IsGrfNode();
1521 }
1522 
1523 // move previously appended paragraphs into a text frames
1524 // to support import filters
1525 uno::Reference< text::XTextContent > SAL_CALL
1527  const uno::Reference< text::XTextRange >& xStart,
1528  const uno::Reference< text::XTextRange >& xEnd,
1529  const uno::Sequence< beans::PropertyValue >& rFrameProperties)
1530 {
1531  SolarMutexGuard aGuard;
1532 
1533  if(!IsValid())
1534  {
1535  throw uno::RuntimeException();
1536  }
1537  uno::Reference< text::XTextContent > xRet;
1538  std::unique_ptr<SwUnoInternalPaM> pTempStartPam(new SwUnoInternalPaM(*GetDoc()));
1539  std::unique_ptr< SwUnoInternalPaM > pEndPam(new SwUnoInternalPaM(*GetDoc()));
1540  if (!::sw::XTextRangeToSwPaM(*pTempStartPam, xStart) ||
1541  !::sw::XTextRangeToSwPaM(*pEndPam, xEnd))
1542  {
1543  throw lang::IllegalArgumentException();
1544  }
1545  auto pStartPam(GetDoc()->CreateUnoCursor(*pTempStartPam->GetPoint()));
1546  if (pTempStartPam->HasMark())
1547  {
1548  pStartPam->SetMark();
1549  *pStartPam->GetMark() = *pTempStartPam->GetMark();
1550  }
1551  pTempStartPam.reset();
1552 
1553  SwXTextRange *const pStartRange =
1554  comphelper::getUnoTunnelImplementation<SwXTextRange>(xStart);
1555  SwXTextRange *const pEndRange =
1556  comphelper::getUnoTunnelImplementation<SwXTextRange>(xEnd);
1557  // bookmarks have to be removed before the referenced text node
1558  // is deleted in DelFullPara
1559  if (pStartRange)
1560  {
1561  pStartRange->Invalidate();
1562  }
1563  if (pEndRange)
1564  {
1565  pEndRange->Invalidate();
1566  }
1567 
1568  m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
1569  bool bIllegalException = false;
1570  bool bRuntimeException = false;
1571  OUString sMessage;
1572  SwStartNode* pStartStartNode = pStartPam->GetNode().StartOfSectionNode();
1573  while (pStartStartNode && pStartStartNode->IsSectionNode())
1574  {
1575  pStartStartNode = pStartStartNode->StartOfSectionNode();
1576  }
1577  SwStartNode* pEndStartNode = pEndPam->GetNode().StartOfSectionNode();
1578  while (pEndStartNode && pEndStartNode->IsSectionNode())
1579  {
1580  pEndStartNode = pEndStartNode->StartOfSectionNode();
1581  }
1582  bool bParaAfterInserted = false;
1583  bool bParaBeforeInserted = false;
1584  if (
1585  pStartStartNode && pEndStartNode &&
1586  (pStartStartNode != pEndStartNode || pStartStartNode != GetStartNode())
1587  )
1588  {
1589  // todo: if the start/end is in a table then insert a paragraph
1590  // before/after, move the start/end nodes, then convert and
1591  // remove the additional paragraphs in the end
1592  SwTableNode * pStartTableNode(nullptr);
1593  if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode)
1594  {
1595  pStartTableNode = pStartStartNode->FindTableNode();
1596  // Is it the same table start node than the end?
1597  SwTableNode *const pEndStartTableNode(pEndStartNode->FindTableNode());
1598  while (pEndStartTableNode && pStartTableNode &&
1599  pEndStartTableNode->GetIndex() < pStartTableNode->GetIndex())
1600  {
1601  SwStartNode* pStartStartTableNode = pStartTableNode->StartOfSectionNode();
1602  pStartTableNode = pStartStartTableNode->FindTableNode();
1603  }
1604  }
1605  if (pStartTableNode)
1606  {
1607  const SwNodeIndex aTableIdx( *pStartTableNode, -1 );
1608  SwPosition aBefore(aTableIdx);
1609  bParaBeforeInserted = GetDoc()->getIDocumentContentOperations().AppendTextNode( aBefore );
1610  pStartPam->DeleteMark();
1611  *pStartPam->GetPoint() = aBefore;
1612  pStartStartNode = pStartPam->GetNode().StartOfSectionNode();
1613  }
1614  if (pEndStartNode->GetStartNodeType() == SwTableBoxStartNode)
1615  {
1616  SwTableNode *const pEndTableNode = pEndStartNode->FindTableNode();
1617  SwEndNode *const pTableEnd = pEndTableNode->EndOfSectionNode();
1618  SwPosition aTableEnd(*pTableEnd);
1619  bParaAfterInserted = GetDoc()->getIDocumentContentOperations().AppendTextNode( aTableEnd );
1620  pEndPam->DeleteMark();
1621  *pEndPam->GetPoint() = aTableEnd;
1622  pEndStartNode = pEndPam->GetNode().StartOfSectionNode();
1623  }
1624  // now we should have the positions in the same hierarchy
1625  if ((pStartStartNode != pEndStartNode) ||
1626  (pStartStartNode != GetStartNode()))
1627  {
1628  // if not - remove the additional paragraphs and throw
1629  if (bParaBeforeInserted)
1630  {
1631  SwCursor aDelete(*pStartPam->GetPoint(), nullptr);
1632  *pStartPam->GetPoint() = // park it because node is deleted
1633  SwPosition(GetDoc()->GetNodes().GetEndOfContent());
1634  aDelete.MovePara(GoCurrPara, fnParaStart);
1635  aDelete.SetMark();
1636  aDelete.MovePara(GoCurrPara, fnParaEnd);
1638  }
1639  if (bParaAfterInserted)
1640  {
1641  SwCursor aDelete(*pEndPam->GetPoint(), nullptr);
1642  *pEndPam->GetPoint() = // park it because node is deleted
1643  SwPosition(GetDoc()->GetNodes().GetEndOfContent());
1644  aDelete.MovePara(GoCurrPara, fnParaStart);
1645  aDelete.SetMark();
1646  aDelete.MovePara(GoCurrPara, fnParaEnd);
1648  }
1649  throw lang::IllegalArgumentException();
1650  }
1651  }
1652 
1653  // make a selection from pStartPam to pEndPam
1654  // If there is no content in the frame the shape is in
1655  // it gets deleted in the DelFullPara call below,
1656  // In this case insert a tmp text node ( we delete it later )
1657  if (pStartPam->Start()->nNode == pEndPam->Start()->nNode
1658  && pStartPam->End()->nNode == pEndPam->End()->nNode)
1659  {
1660  SwPosition aEnd(*pStartPam->End());
1661  bParaAfterInserted = GetDoc()->getIDocumentContentOperations().AppendTextNode( aEnd );
1662  pEndPam->DeleteMark();
1663  *pEndPam->GetPoint() = aEnd;
1664  }
1665  pStartPam->SetMark();
1666  *pStartPam->End() = *pEndPam->End();
1667  pEndPam.reset();
1668 
1669  // see if there are frames already anchored to this node
1670  // we have to work with the SdrObjects, as unique name is not guaranteed in their frame format
1671  // tdf#115094: do nothing if we have a graphic node
1672  o3tl::sorted_vector<const SdrObject*> aAnchoredObjectsByPtr;
1673  std::set<OUString> aAnchoredObjectsByName;
1674  for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i)
1675  {
1676  const SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i];
1677  const SwFormatAnchor& rAnchor = pFrameFormat->GetAnchor();
1678  if ( !isGraphicNode(pFrameFormat) &&
1679  (RndStdIds::FLY_AT_PARA == rAnchor.GetAnchorId() || RndStdIds::FLY_AT_CHAR == rAnchor.GetAnchorId()) &&
1680  pStartPam->Start()->nNode.GetIndex() <= rAnchor.GetContentAnchor()->nNode.GetIndex() &&
1681  pStartPam->End()->nNode.GetIndex() >= rAnchor.GetContentAnchor()->nNode.GetIndex())
1682  {
1683  if (pFrameFormat->GetName().isEmpty())
1684  {
1685  aAnchoredObjectsByPtr.insert(pFrameFormat->FindSdrObject());
1686  }
1687  else
1688  {
1689  aAnchoredObjectsByName.insert(pFrameFormat->GetName());
1690  }
1691  }
1692  }
1693 
1694  const uno::Reference<text::XTextFrame> xNewFrame(
1695  SwXTextFrame::CreateXTextFrame(*m_pImpl->m_pDoc, nullptr));
1696  SwXTextFrame& rNewFrame = dynamic_cast<SwXTextFrame&>(*xNewFrame);
1697  try
1698  {
1699  for (const beans::PropertyValue& rValue : rFrameProperties)
1700  {
1701  rNewFrame.SwXFrame::setPropertyValue(rValue.Name, rValue.Value);
1702  }
1703 
1704  { // has to be in a block to remove the SwIndexes before
1705  // DelFullPara is called
1706  const uno::Reference< text::XTextRange> xInsertTextRange =
1707  new SwXTextRange(*pStartPam, this);
1708  assert(rNewFrame.IsDescriptor());
1709  rNewFrame.attachToRange(xInsertTextRange, pStartPam.get());
1710  rNewFrame.setName(m_pImpl->m_pDoc->GetUniqueFrameName());
1711  }
1712 
1713  SwTextNode *const pTextNode(pStartPam->GetNode().GetTextNode());
1714  assert(pTextNode);
1715  if (!pTextNode || !pTextNode->Len()) // don't remove if it contains text!
1716  {
1717  { // has to be in a block to remove the SwIndexes before
1718  // DelFullPara is called
1719  SwPaM aMovePam( pStartPam->GetNode() );
1720  if (aMovePam.Move( fnMoveForward, GoInContent ))
1721  {
1722  // move the anchor to the next paragraph
1723  SwFormatAnchor aNewAnchor(rNewFrame.GetFrameFormat()->GetAnchor());
1724  aNewAnchor.SetAnchor( aMovePam.Start() );
1725  m_pImpl->m_pDoc->SetAttr(
1726  aNewAnchor, *rNewFrame.GetFrameFormat() );
1727 
1728  // also move frames anchored to us
1729  for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i)
1730  {
1731  SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i];
1732  if ((!pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByName.find(pFrameFormat->GetName()) != aAnchoredObjectsByName.end() ) ||
1733  ( pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByPtr.find(pFrameFormat->FindSdrObject()) != aAnchoredObjectsByPtr.end()) )
1734  {
1735  // copy the anchor to the next paragraph
1736  SwFormatAnchor aAnchor(pFrameFormat->GetAnchor());
1737  aAnchor.SetAnchor(aMovePam.Start());
1738  m_pImpl->m_pDoc->SetAttr(aAnchor, *pFrameFormat);
1739  }
1740  }
1741  }
1742  }
1743  m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pStartPam);
1744  }
1745  }
1746  catch (const lang::IllegalArgumentException& rIllegal)
1747  {
1748  sMessage = rIllegal.Message;
1749  bIllegalException = true;
1750  }
1751  catch (const uno::RuntimeException& rRuntime)
1752  {
1753  sMessage = rRuntime.Message;
1754  bRuntimeException = true;
1755  }
1756  xRet = xNewFrame;
1757  if (bParaBeforeInserted || bParaAfterInserted)
1758  {
1759  const uno::Reference<text::XTextCursor> xFrameTextCursor =
1760  rNewFrame.createTextCursor();
1761  SwXTextCursor *const pFrameCursor =
1762  comphelper::getUnoTunnelImplementation<SwXTextCursor>(xFrameTextCursor);
1763  if (bParaBeforeInserted)
1764  {
1765  // todo: remove paragraph before frame
1766  m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pFrameCursor->GetPaM());
1767  }
1768  if (bParaAfterInserted)
1769  {
1770  xFrameTextCursor->gotoEnd(false);
1771  if (!bParaBeforeInserted)
1772  m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pFrameCursor->GetPaM());
1773  else
1774  {
1775  // In case the frame has a table only, the cursor points to the end of the first cell of the table.
1776  SwPaM aPaM(*pFrameCursor->GetPaM()->GetNode().FindSttNodeByType(SwFlyStartNode)->EndOfSectionNode());
1777  // Now we have the end of the frame -- the node before that will be the paragraph we want to remove.
1778  --aPaM.GetPoint()->nNode;
1779  m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(aPaM);
1780  }
1781  }
1782  }
1783 
1784  m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
1785  if (bIllegalException || bRuntimeException)
1786  {
1787  m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo();
1788  if (bIllegalException)
1789  {
1790  lang::IllegalArgumentException aEx;
1791  aEx.Message = sMessage;
1792  throw aEx;
1793  }
1794  else
1795  {
1796  uno::RuntimeException aEx;
1797  aEx.Message = sMessage;
1798  throw aEx;
1799  }
1800  }
1801  return xRet;
1802 }
1803 
1804 namespace {
1805 
1806 // Move previously imported paragraphs into a new text table.
1807 struct VerticallyMergedCell
1808 {
1809  std::vector<uno::Reference< beans::XPropertySet > > aCells;
1810  sal_Int32 nLeftPosition;
1811  bool bOpen;
1812 
1813  VerticallyMergedCell(uno::Reference< beans::XPropertySet > const& rxCell,
1814  const sal_Int32 nLeft)
1815  : nLeftPosition( nLeft )
1816  , bOpen( true )
1817  {
1818  aCells.push_back( rxCell );
1819  }
1820 };
1821 
1822 }
1823 
1824 #define COL_POS_FUZZY 2
1825 
1826 static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 )
1827 {
1828  return abs( nPos1 - nPos2 ) < COL_POS_FUZZY;
1829 }
1830 
1832  const uno::Sequence< uno::Reference< text::XTextRange > > & rCell,
1833  std::vector<SwNodeRange> & rRowNodes,
1834  SwNodeRange *const pLastCell)
1835 {
1836  if (rCell.getLength() != 2)
1837  {
1838  throw lang::IllegalArgumentException(
1839  "rCell needs to contain 2 elements",
1840  uno::Reference< text::XTextCopy >( &m_rThis ), sal_Int16( 2 ) );
1841  }
1842  const uno::Reference<text::XTextRange> xStartRange = rCell[0];
1843  const uno::Reference<text::XTextRange> xEndRange = rCell[1];
1844  SwUnoInternalPaM aStartCellPam(*m_pDoc);
1845  SwUnoInternalPaM aEndCellPam(*m_pDoc);
1846 
1847  // !!! TODO - PaMs in tables and sections do not work here -
1848  // the same applies to PaMs in frames !!!
1849 
1850  if (!::sw::XTextRangeToSwPaM(aStartCellPam, xStartRange) ||
1851  !::sw::XTextRangeToSwPaM(aEndCellPam, xEndRange))
1852  {
1853  throw lang::IllegalArgumentException(
1854  "Start or End range cannot be resolved to a SwPaM",
1855  uno::Reference< text::XTextCopy >( &m_rThis ), sal_Int16( 2 ) );
1856  }
1857 
1858  SwNodeRange aTmpRange(aStartCellPam.Start()->nNode,
1859  aEndCellPam.End()->nNode);
1860  std::unique_ptr<SwNodeRange> pCorrectedRange =
1861  m_pDoc->GetNodes().ExpandRangeForTableBox(aTmpRange);
1862 
1863  if (pCorrectedRange)
1864  {
1865  SwPaM aNewStartPaM(pCorrectedRange->aStart, 0);
1866  aStartCellPam = aNewStartPaM;
1867 
1868  sal_Int32 nEndLen = 0;
1869  SwTextNode * pTextNode = pCorrectedRange->aEnd.GetNode().GetTextNode();
1870  if (pTextNode != nullptr)
1871  nEndLen = pTextNode->Len();
1872 
1873  SwPaM aNewEndPaM(pCorrectedRange->aEnd, nEndLen);
1874  aEndCellPam = aNewEndPaM;
1875 
1876  pCorrectedRange.reset();
1877  }
1878 
1882  if (aStartCellPam.Start()->nNode < aEndCellPam.End()->nNode)
1883  {
1884  // increment on each StartNode and decrement on each EndNode
1885  // we must reach zero at the end and must not go below zero
1886  long nOpenNodeBlock = 0;
1887  SwNodeIndex aCellIndex = aStartCellPam.Start()->nNode;
1888  while (aCellIndex < aEndCellPam.End()->nNode.GetIndex())
1889  {
1890  if (aCellIndex.GetNode().IsStartNode())
1891  {
1892  ++nOpenNodeBlock;
1893  }
1894  else if (aCellIndex.GetNode().IsEndNode())
1895  {
1896  --nOpenNodeBlock;
1897  }
1898  if (nOpenNodeBlock < 0)
1899  {
1900  throw lang::IllegalArgumentException();
1901  }
1902  ++aCellIndex;
1903  }
1904  if (nOpenNodeBlock != 0)
1905  {
1906  throw lang::IllegalArgumentException();
1907  }
1908  }
1909 
1916  if (!pLastCell) // first cell?
1917  {
1918  // align the beginning - if necessary
1919  if (aStartCellPam.Start()->nContent.GetIndex())
1920  {
1921  m_pDoc->getIDocumentContentOperations().SplitNode(*aStartCellPam.Start(), false);
1922  }
1923  }
1924  else
1925  {
1926  // check the predecessor
1927  const sal_uLong nStartCellNodeIndex =
1928  aStartCellPam.Start()->nNode.GetIndex();
1929  const sal_uLong nLastNodeEndIndex = pLastCell->aEnd.GetIndex();
1930  if (nLastNodeEndIndex == nStartCellNodeIndex)
1931  {
1932  // same node as predecessor then equal nContent?
1933  if (0 != aStartCellPam.Start()->nContent.GetIndex())
1934  {
1935  throw lang::IllegalArgumentException();
1936  }
1937 
1938  m_pDoc->getIDocumentContentOperations().SplitNode(*aStartCellPam.Start(), false);
1939  sal_uLong const nNewIndex(aStartCellPam.Start()->nNode.GetIndex());
1940  if (nNewIndex != nStartCellNodeIndex)
1941  {
1942  // aStartCellPam now points to the 2nd node
1943  // the last cell may *also* point to 2nd node now - fix it!
1944  assert(nNewIndex == nStartCellNodeIndex + 1);
1945  if (pLastCell->aEnd.GetIndex() == nNewIndex)
1946  {
1947  --pLastCell->aEnd;
1948  if (pLastCell->aStart.GetIndex() == nNewIndex)
1949  {
1950  --pLastCell->aStart;
1951  }
1952  }
1953  }
1954  }
1955  else if (nStartCellNodeIndex == (nLastNodeEndIndex + 1))
1956  {
1957  // next paragraph - now the content index of the new should be 0
1958  // and of the old one should be equal to the text length
1959  // but if it isn't we don't care - the cell is being inserted on
1960  // the node border anyway
1961  }
1962  else
1963  {
1964  throw lang::IllegalArgumentException();
1965  }
1966  }
1967  // now check if there's a need to insert another paragraph break
1968  if (aEndCellPam.End()->nContent.GetIndex() <
1969  aEndCellPam.End()->nNode.GetNode().GetTextNode()->Len())
1970  {
1971  m_pDoc->getIDocumentContentOperations().SplitNode(*aEndCellPam.End(), false);
1972  // take care that the new start/endcell is moved to the right position
1973  // aStartCellPam has to point to the start of the new (previous) node
1974  // aEndCellPam has to point to the end of the new (previous) node
1975  aStartCellPam.DeleteMark();
1976  aStartCellPam.Move(fnMoveBackward, GoInNode);
1977  aStartCellPam.GetPoint()->nContent = 0;
1978  aEndCellPam.DeleteMark();
1979  aEndCellPam.Move(fnMoveBackward, GoInNode);
1980  aEndCellPam.GetPoint()->nContent =
1981  aEndCellPam.GetNode().GetTextNode()->Len();
1982  }
1983 
1984  assert(aStartCellPam.Start()->nContent.GetIndex() == 0);
1985  assert(aEndCellPam.End()->nContent.GetIndex() == aEndCellPam.End()->nNode.GetNode().GetTextNode()->Len());
1986  SwNodeRange aCellRange(aStartCellPam.Start()->nNode,
1987  aEndCellPam.End()->nNode);
1988  rRowNodes.push_back(aCellRange); // note: invalidates pLastCell!
1989 }
1990 
1991 typedef uno::Sequence< text::TableColumnSeparator > TableColumnSeparators;
1992 
1993 static void
1995  uno::Sequence<beans::PropertyValue> const& rRowProperties,
1996  uno::Any const& rRow,
1997  TableColumnSeparators & rRowSeparators)
1998 {
1999  uno::Reference< beans::XPropertySet > xRow;
2000  rRow >>= xRow;
2001  for (const beans::PropertyValue& rProperty : rRowProperties)
2002  {
2003  if ( rProperty.Name == "TableColumnSeparators" )
2004  {
2005  // add the separators to access the cell's positions
2006  // for vertical merging later
2007  TableColumnSeparators aSeparators;
2008  rProperty.Value >>= aSeparators;
2009  rRowSeparators = aSeparators;
2010  }
2011  xRow->setPropertyValue(rProperty.Name, rProperty.Value);
2012  }
2013 }
2014 
2015 static sal_Int32 lcl_GetLeftPos(sal_Int32 nCell, TableColumnSeparators const& rRowSeparators)
2016 {
2017  if(!nCell)
2018  return 0;
2019  if (rRowSeparators.getLength() < nCell)
2020  return -1;
2021  return rRowSeparators[nCell - 1].Position;
2022 }
2023 
2024 static void
2026  const sal_Int32 nLeftPos,
2027  const uno::Sequence< beans::PropertyValue >& rCellProperties,
2028  const uno::Reference< uno::XInterface >& xCell,
2029  std::vector<VerticallyMergedCell> & rMergedCells)
2030 {
2031  const uno::Reference< beans::XPropertySet > xCellPS(xCell, uno::UNO_QUERY);
2032  for (const auto& rCellProperty : rCellProperties)
2033  {
2034  const OUString & rName = rCellProperty.Name;
2035  const uno::Any & rValue = rCellProperty.Value;
2036  if ( rName == "VerticalMerge" )
2037  {
2038  // determine left border position
2039  // add the cell to a queue of merged cells
2040  bool bMerge = false;
2041  rValue >>= bMerge;
2042  if (bMerge)
2043  {
2044  // 'close' all the cell with the same left position
2045  // if separate vertical merges in the same column exist
2046  for(auto& aMergedCell : rMergedCells)
2047  {
2048  if(lcl_SimilarPosition(aMergedCell.nLeftPosition, nLeftPos))
2049  {
2050  aMergedCell.bOpen = false;
2051  }
2052  }
2053  // add the new group of merged cells
2054  rMergedCells.emplace_back(xCellPS, nLeftPos);
2055  }
2056  else
2057  {
2058  bool bFound = false;
2059  SAL_WARN_IF(rMergedCells.empty(), "sw.uno", "the first merged cell is missing");
2060  for(auto& aMergedCell : rMergedCells)
2061  {
2062  if (aMergedCell.bOpen && lcl_SimilarPosition(aMergedCell.nLeftPosition, nLeftPos))
2063  {
2064  aMergedCell.aCells.push_back( xCellPS );
2065  bFound = true;
2066  }
2067  }
2068  SAL_WARN_IF(!bFound, "sw.uno", "couldn't find first vertically merged cell" );
2069  }
2070  }
2071  else
2072  {
2073  try
2074  {
2075  xCellPS->setPropertyValue(rName, rValue);
2076  }
2077  catch (const uno::Exception& e)
2078  {
2079  SAL_WARN( "sw.uno", "Exception when getting PropertyState: "
2080  + rName + ". Message: " + e.Message );
2081  }
2082  }
2083  }
2084 }
2085 
2086 static void
2087 lcl_MergeCells(std::vector<VerticallyMergedCell> & rMergedCells)
2088 {
2089  for(auto& aMergedCell : rMergedCells)
2090  {
2091  // the first of the cells gets the number of cells set as RowSpan
2092  // the others get the inverted number of remaining merged cells
2093  // (3,-2,-1)
2094  sal_Int32 nCellCount = static_cast<sal_Int32>(aMergedCell.aCells.size());
2095  if(nCellCount<2)
2096  {
2097  SAL_WARN("sw.uno", "incomplete vertical cell merge");
2098  continue;
2099  }
2100  aMergedCell.aCells.front()->setPropertyValue(UNO_NAME_ROW_SPAN, uno::makeAny(nCellCount--));
2101  nCellCount*=-1;
2102  for(auto pxPSet = aMergedCell.aCells.begin()+1; nCellCount<0; ++pxPSet, ++nCellCount)
2103  (*pxPSet)->setPropertyValue(UNO_NAME_ROW_SPAN, uno::makeAny(nCellCount));
2104  }
2105 }
2106 
2107 uno::Reference< text::XTextTable > SAL_CALL
2109  const uno::Sequence< uno::Sequence< uno::Sequence<
2110  uno::Reference< text::XTextRange > > > >& rTableRanges,
2111  const uno::Sequence< uno::Sequence< uno::Sequence<
2112  beans::PropertyValue > > >& rCellProperties,
2113  const uno::Sequence< uno::Sequence< beans::PropertyValue > >&
2114  rRowProperties,
2115  const uno::Sequence< beans::PropertyValue >& rTableProperties)
2116 {
2117  SolarMutexGuard aGuard;
2118 
2119  if(!IsValid())
2120  {
2121  throw uno::RuntimeException();
2122  }
2123 
2124  IDocumentRedlineAccess & rIDRA(m_pImpl->m_pDoc->getIDocumentRedlineAccess());
2125  if (!IDocumentRedlineAccess::IsShowChanges(rIDRA.GetRedlineFlags()))
2126  {
2127  throw uno::RuntimeException(
2128  "cannot convertToTable if tracked changes are hidden!");
2129  }
2130 
2131  //at first collect the text ranges as SwPaMs
2132  const uno::Sequence< uno::Sequence< uno::Reference< text::XTextRange > > >*
2133  pTableRanges = rTableRanges.getConstArray();
2134  std::vector< std::vector<SwNodeRange> > aTableNodes;
2135  for (sal_Int32 nRow = 0; nRow < rTableRanges.getLength(); ++nRow)
2136  {
2137  std::vector<SwNodeRange> aRowNodes;
2138  const uno::Sequence< uno::Reference< text::XTextRange > >* pRow =
2139  pTableRanges[nRow].getConstArray();
2140  const sal_Int32 nCells(pTableRanges[nRow].getLength());
2141 
2142  if (0 == nCells) // this would lead to no pLastCell below
2143  { // and make it impossible to detect node gaps
2144  throw lang::IllegalArgumentException();
2145  }
2146 
2147  for (sal_Int32 nCell = 0; nCell < nCells; ++nCell)
2148  {
2149  SwNodeRange *const pLastCell(
2150  (nCell == 0)
2151  ? ((nRow == 0)
2152  ? nullptr
2153  : &*aTableNodes.rbegin()->rbegin())
2154  : &*aRowNodes.rbegin());
2155  m_pImpl->ConvertCell(pRow[nCell], aRowNodes, pLastCell);
2156  }
2157  assert(!aRowNodes.empty());
2158  aTableNodes.push_back(aRowNodes);
2159  }
2160 
2161  std::vector< TableColumnSeparators >
2162  aRowSeparators(rRowProperties.getLength());
2163  std::vector<VerticallyMergedCell> aMergedCells;
2164 
2165  SwTable const*const pTable = m_pImpl->m_pDoc->TextToTable( aTableNodes );
2166 
2167  if (!pTable)
2168  return uno::Reference< text::XTextTable >();
2169 
2170  uno::Reference<text::XTextTable> const xRet =
2172  uno::Reference<beans::XPropertySet> const xPrSet(xRet, uno::UNO_QUERY);
2173  // set properties to the table
2174  // catch lang::WrappedTargetException and lang::IndexOutOfBoundsException
2175  try
2176  {
2177  //apply table properties
2178  for(const auto& rTableProperty : rTableProperties)
2179  {
2180  try
2181  {
2182  xPrSet->setPropertyValue(rTableProperty.Name, rTableProperty.Value);
2183  }
2184  catch (const uno::Exception& e)
2185  {
2186  SAL_WARN( "sw.uno", "Exception when setting property: "
2187  + rTableProperty.Name + ". Message: " + e.Message );
2188  }
2189  }
2190 
2191  //apply row properties
2192  const auto xRows = xRet->getRows();
2193  const sal_Int32 nLast = std::min(xRows->getCount(), rRowProperties.getLength());
2194  SAL_WARN_IF(nLast != rRowProperties.getLength(), "sw.uno", "not enough rows for properties");
2195  for(sal_Int32 nCnt = 0; nCnt < nLast; ++nCnt)
2196  lcl_ApplyRowProperties(rRowProperties[nCnt], xRows->getByIndex(nCnt), aRowSeparators[nCnt]);
2197 
2198  uno::Reference<table::XCellRange> const xCR(xRet, uno::UNO_QUERY_THROW);
2199  //apply cell properties
2200  sal_Int32 nRow = 0;
2201  for(const auto& rCellPropertiesForRow : rCellProperties)
2202  {
2203  sal_Int32 nCell = 0;
2204  for(const auto& rCellProps : rCellPropertiesForRow)
2205  {
2206  lcl_ApplyCellProperties(lcl_GetLeftPos(nCell, aRowSeparators[nRow]),
2207  rCellProps,
2208  xCR->getCellByPosition(nCell, nRow),
2209  aMergedCells);
2210  ++nCell;
2211  }
2212  ++nRow;
2213  }
2214 
2215  // now that the cell properties are set the vertical merge values
2216  // have to be applied
2217  lcl_MergeCells(aMergedCells);
2218  }
2219  catch (const lang::WrappedTargetException&)
2220  {
2221  }
2222  catch (const lang::IndexOutOfBoundsException&)
2223  {
2224  }
2225 
2226  assert(SwTable::FindTable(pTable->GetFrameFormat()) == pTable);
2227  assert(pTable->GetFrameFormat() ==
2228  dynamic_cast<SwXTextTable&>(*xRet).GetFrameFormat());
2229  return xRet;
2230 }
2231 
2232 void SAL_CALL
2234  const uno::Reference< text::XTextCopy >& xSource )
2235 {
2236  SolarMutexGuard aGuard;
2237 
2238  uno::Reference<lang::XUnoTunnel> const xSourceTunnel(xSource,
2239  uno::UNO_QUERY);
2240  SwXText const*const pSource( xSourceTunnel.is()
2241  ? ::sw::UnoTunnelGetImplementation<SwXText>(xSourceTunnel)
2242  : nullptr);
2243 
2244  uno::Reference< text::XText > const xText(xSource, uno::UNO_QUERY_THROW);
2245  uno::Reference< text::XTextCursor > const xCursor =
2246  xText->createTextCursor();
2247  xCursor->gotoEnd( true );
2248 
2249  uno::Reference< lang::XUnoTunnel > const xCursorTunnel(xCursor,
2250  uno::UNO_QUERY_THROW);
2251 
2252  OTextCursorHelper *const pCursor =
2253  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel);
2254  if (!pCursor)
2255  {
2256  throw uno::RuntimeException();
2257  }
2258 
2259  SwNodeIndex rNdIndex( *GetStartNode( ), 1 );
2260  SwPosition rPos( rNdIndex );
2261  // tdf#112202 need SwXText because cursor cannot select table at the start
2262  if (pSource)
2263  {
2264  SwTextNode * pFirstNode;
2265  {
2266  SwPaM temp(*pSource->GetStartNode(), *pSource->GetStartNode()->EndOfSectionNode(), +1, -1);
2267  pFirstNode = temp.GetMark()->nNode.GetNode().GetTextNode();
2268  if (pFirstNode)
2269  {
2270  pFirstNode->MakeStartIndex(&temp.GetMark()->nContent);
2271  }
2272  if (SwTextNode *const pNode = temp.GetPoint()->nNode.GetNode().GetTextNode())
2273  {
2274  pNode->MakeEndIndex(&temp.GetPoint()->nContent);
2275  }
2276  // Explicitly request copy text mode, so
2277  // sw::DocumentContentOperationsManager::CopyFlyInFlyImpl() will copy shapes anchored to
2278  // us, even if we have only a single paragraph.
2279  m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange(temp, rPos, SwCopyFlags::CheckPosInFly);
2280  }
2281  if (!pFirstNode)
2282  { // the node at rPos was split; get rid of the first empty one so
2283  // that the pasted table is first
2284  auto pDelCursor(m_pImpl->m_pDoc->CreateUnoCursor(SwPosition(SwNodeIndex(*GetStartNode(), 1))));
2285  m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pDelCursor);
2286  }
2287  }
2288  else
2289  {
2290  m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange(*pCursor->GetPaM(), rPos, SwCopyFlags::CheckPosInFly);
2291  }
2292 
2293 }
2294 
2296  : SwXText(pDoc, CursorType::Body)
2297 {
2298 }
2299 
2301 {
2302 }
2303 
2304 OUString SAL_CALL
2306 {
2307  return "SwXBodyText";
2308 }
2309 
2310 sal_Bool SAL_CALL SwXBodyText::supportsService(const OUString& rServiceName)
2311 {
2312  return cppu::supportsService(this, rServiceName);
2313 }
2314 
2315 uno::Sequence< OUString > SAL_CALL
2317 {
2318  return { "com.sun.star.text.Text" };
2319 }
2320 
2321 uno::Any SAL_CALL
2323 {
2324  uno::Any aRet;
2326  {
2327  aRet <<= uno::Reference< container::XEnumerationAccess >(this);
2328  }
2330  {
2331  aRet <<= uno::Reference< container::XElementAccess >(this);
2332  }
2333  else if (rType == cppu::UnoType<lang::XServiceInfo>::get())
2334  {
2335  aRet <<= uno::Reference< lang::XServiceInfo >(this);
2336  }
2337  else
2338  {
2339  aRet = SwXText::queryInterface( rType );
2340  }
2341  if(aRet.getValueType() == cppu::UnoType<void>::get())
2342  {
2343  aRet = OWeakAggObject::queryAggregation( rType );
2344  }
2345  return aRet;
2346 }
2347 
2348 uno::Sequence< uno::Type > SAL_CALL
2350 {
2351  const uno::Sequence< uno::Type > aTypes = SwXBodyText_Base::getTypes();
2352  const uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes();
2353  return ::comphelper::concatSequences(aTypes, aTextTypes);
2354 }
2355 
2356 uno::Sequence< sal_Int8 > SAL_CALL
2358 {
2359  return css::uno::Sequence<sal_Int8>();
2360 }
2361 
2362 uno::Any SAL_CALL
2364 {
2365  const uno::Any ret = SwXText::queryInterface(rType);
2366  return (ret.getValueType() == cppu::UnoType<void>::get())
2368  : ret;
2369 }
2370 
2372 {
2373  if(!IsValid())
2374  {
2375  return nullptr;
2376  }
2377 
2378  // the cursor has to skip tables contained in this text
2379  SwPaM aPam(GetDoc()->GetNodes().GetEndOfContent());
2380  aPam.Move( fnMoveBackward, GoInDoc );
2381  if (!bIgnoreTables)
2382  {
2383  SwTableNode * pTableNode = aPam.GetNode().FindTableNode();
2384  SwContentNode * pCont = nullptr;
2385  while (pTableNode)
2386  {
2387  aPam.GetPoint()->nNode = *pTableNode->EndOfSectionNode();
2388  pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode);
2389  pTableNode = pCont->FindTableNode();
2390  }
2391  if (pCont)
2392  {
2393  aPam.GetPoint()->nContent.Assign(pCont, 0);
2394  }
2395  }
2396  return new SwXTextCursor(*GetDoc(), this, CursorType::Body, *aPam.GetPoint());
2397 }
2398 
2399 uno::Reference< text::XTextCursor > SAL_CALL
2401 {
2402  SolarMutexGuard aGuard;
2403 
2404  const uno::Reference< text::XTextCursor > xRef(
2405  static_cast<text::XWordCursor*>(CreateTextCursor()) );
2406  if (!xRef.is())
2407  {
2408  uno::RuntimeException aRuntime;
2409  aRuntime.Message = cInvalidObject;
2410  throw aRuntime;
2411  }
2412  return xRef;
2413 }
2414 
2415 uno::Reference< text::XTextCursor > SAL_CALL
2417  const uno::Reference< text::XTextRange > & xTextPosition)
2418 {
2419  SolarMutexGuard aGuard;
2420 
2421  if(!IsValid())
2422  {
2423  uno::RuntimeException aRuntime;
2424  aRuntime.Message = cInvalidObject;
2425  throw aRuntime;
2426  }
2427 
2428  uno::Reference< text::XTextCursor > aRef;
2429  SwUnoInternalPaM aPam(*GetDoc());
2430  if (::sw::XTextRangeToSwPaM(aPam, xTextPosition))
2431  {
2432  if ( !aPam.GetNode().GetTextNode() )
2433  throw uno::RuntimeException("Invalid text range" );
2434 
2435  SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
2436 
2437  SwStartNode* p1 = aPam.GetNode().StartOfSectionNode();
2438  //document starts with a section?
2439  while(p1->IsSectionNode())
2440  {
2441  p1 = p1->StartOfSectionNode();
2442  }
2443  SwStartNode *const p2 = rNode.StartOfSectionNode();
2444 
2445  if(p1 == p2)
2446  {
2447  aRef = static_cast<text::XWordCursor*>(
2448  new SwXTextCursor(*GetDoc(), this, CursorType::Body,
2449  *aPam.GetPoint(), aPam.GetMark()));
2450  }
2451  }
2452  if(!aRef.is())
2453  {
2454  throw uno::RuntimeException( "End of content node doesn't have the proper start node",
2455  uno::Reference< uno::XInterface >( *this ) );
2456  }
2457  return aRef;
2458 }
2459 
2460 uno::Reference< container::XEnumeration > SAL_CALL
2462 {
2463  SolarMutexGuard aGuard;
2464 
2465  if (!IsValid())
2466  {
2467  uno::RuntimeException aRuntime;
2468  aRuntime.Message = cInvalidObject;
2469  throw aRuntime;
2470  }
2471 
2472  SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent();
2473  SwPosition aPos(rNode);
2474  auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
2475  pUnoCursor->Move(fnMoveBackward, GoInDoc);
2476  return SwXParagraphEnumeration::Create(this, pUnoCursor, CursorType::Body);
2477 }
2478 
2479 uno::Type SAL_CALL
2481 {
2483 }
2484 
2485 sal_Bool SAL_CALL
2487 {
2488  SolarMutexGuard aGuard;
2489 
2490  if (!IsValid())
2491  {
2492  uno::RuntimeException aRuntime;
2493  aRuntime.Message = cInvalidObject;
2494  throw aRuntime;
2495  }
2496 
2497  return true;
2498 }
2499 
2501  : public SvtListener
2502 {
2503  public:
2506 
2507  Impl(SwFrameFormat& rHeadFootFormat, const bool bIsHeader)
2508  : m_pHeadFootFormat(&rHeadFootFormat)
2509  , m_bIsHeader(bIsHeader)
2510  {
2511  StartListening(m_pHeadFootFormat->GetNotifier());
2512  }
2513 
2515  return m_pHeadFootFormat;
2516  }
2517 
2519  if (!m_pHeadFootFormat) {
2520  throw uno::RuntimeException("SwXHeadFootText: disposed or invalid", nullptr);
2521  }
2522  return *m_pHeadFootFormat;
2523  }
2524  protected:
2525  virtual void Notify(const SfxHint& rHint) override
2526  {
2527  if(rHint.GetId() == SfxHintId::Dying)
2528  m_pHeadFootFormat = nullptr;
2529  }
2530 };
2531 
2532 uno::Reference<text::XText> SwXHeadFootText::CreateXHeadFootText(
2533  SwFrameFormat& rHeadFootFormat,
2534  const bool bIsHeader)
2535 {
2536  // re-use existing SwXHeadFootText
2537  // #i105557#: do not iterate over the registered clients: race condition
2538  uno::Reference<text::XText> xText(rHeadFootFormat.GetXObject(), uno::UNO_QUERY);
2539  if(!xText.is())
2540  {
2541  const auto pXHFT(new SwXHeadFootText(rHeadFootFormat, bIsHeader));
2542  xText.set(pXHFT);
2543  rHeadFootFormat.SetXObject(xText);
2544  }
2545  return xText;
2546 }
2547 
2548 SwXHeadFootText::SwXHeadFootText(SwFrameFormat& rHeadFootFormat, const bool bIsHeader)
2549  : SwXText(
2550  rHeadFootFormat.GetDoc(),
2551  bIsHeader ? CursorType::Header : CursorType::Footer)
2552  , m_pImpl(new SwXHeadFootText::Impl(rHeadFootFormat, bIsHeader))
2553 {
2554 }
2555 
2557 { }
2558 
2559 OUString SAL_CALL
2561 {
2562  return {"SwXHeadFootText"};
2563 }
2564 
2565 sal_Bool SAL_CALL SwXHeadFootText::supportsService(const OUString& rServiceName)
2566 {
2567  return cppu::supportsService(this, rServiceName);
2568 }
2569 
2570 uno::Sequence<OUString> SAL_CALL
2572 {
2573  return {"com.sun.star.text.Text"};
2574 }
2575 
2577 {
2578  const SwStartNode* pSttNd = nullptr;
2579  SwFrameFormat* const pHeadFootFormat = m_pImpl->GetHeadFootFormat();
2580  if(pHeadFootFormat)
2581  {
2582  const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
2583  if(rFlyContent.GetContentIdx())
2584  {
2585  pSttNd = rFlyContent.GetContentIdx()->GetNode().GetStartNode();
2586  }
2587  }
2588  return pSttNd;
2589 }
2590 
2591 uno::Reference<text::XTextCursor> SwXHeadFootText::CreateCursor()
2592 {
2593  return createTextCursor();
2594 }
2595 
2596 uno::Sequence<uno::Type> SAL_CALL SwXHeadFootText::getTypes()
2597 {
2598  return ::comphelper::concatSequences(
2599  SwXHeadFootText_Base::getTypes(),
2600  SwXText::getTypes());
2601 }
2602 
2603 uno::Sequence<sal_Int8> SAL_CALL SwXHeadFootText::getImplementationId()
2604 {
2605  return css::uno::Sequence<sal_Int8>();
2606 }
2607 
2609 {
2610  const uno::Any ret = SwXHeadFootText_Base::queryInterface(rType);
2611  return (ret.getValueType() == cppu::UnoType<void>::get())
2612  ? SwXText::queryInterface(rType)
2613  : ret;
2614 }
2615 
2616 uno::Reference<text::XTextCursor> SAL_CALL
2618 {
2619  SolarMutexGuard aGuard;
2620 
2621  SwFrameFormat & rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
2622 
2623  const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
2624  const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
2625  SwPosition aPos(rNode);
2626  SwXTextCursor *const pXCursor = new SwXTextCursor(*GetDoc(), this,
2627  (m_pImpl->m_bIsHeader) ? CursorType::Header : CursorType::Footer, aPos);
2628  auto& rUnoCursor(pXCursor->GetCursor());
2629  rUnoCursor.Move(fnMoveForward, GoInNode);
2630 
2631  // save current start node to be able to check if there is content
2632  // after the table - otherwise the cursor would be in the body text!
2633  SwStartNode const*const pOwnStartNode = rNode.FindSttNodeByType(
2634  (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2635  // is there a table here?
2636  SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode();
2637  SwContentNode* pCont = nullptr;
2638  while (pTableNode)
2639  {
2640  rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode();
2641  pCont = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode);
2642  pTableNode = pCont->FindTableNode();
2643  }
2644  if (pCont)
2645  {
2646  rUnoCursor.GetPoint()->nContent.Assign(pCont, 0);
2647  }
2648  SwStartNode const*const pNewStartNode = rUnoCursor.GetNode().FindSttNodeByType(
2649  (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2650  if (!pNewStartNode || (pNewStartNode != pOwnStartNode))
2651  {
2652  uno::RuntimeException aExcept;
2653  aExcept.Message = "no text available";
2654  throw aExcept;
2655  }
2656  return static_cast<text::XWordCursor*>(pXCursor);
2657 }
2658 
2659 uno::Reference<text::XTextCursor> SAL_CALL SwXHeadFootText::createTextCursorByRange(
2660  const uno::Reference<text::XTextRange>& xTextPosition)
2661 {
2662  SolarMutexGuard aGuard;
2663  SwFrameFormat& rHeadFootFormat( m_pImpl->GetHeadFootFormatOrThrow() );
2664 
2665  SwUnoInternalPaM aPam(*GetDoc());
2666  if (!sw::XTextRangeToSwPaM(aPam, xTextPosition))
2667  {
2668  uno::RuntimeException aRuntime;
2669  aRuntime.Message = cInvalidObject;
2670  throw aRuntime;
2671  }
2672 
2673  SwNode& rNode = rHeadFootFormat.GetContent().GetContentIdx()->GetNode();
2674  SwPosition aPos(rNode);
2675  SwPaM aHFPam(aPos);
2676  aHFPam.Move(fnMoveForward, GoInNode);
2677  SwStartNode* const pOwnStartNode = aHFPam.GetNode().FindSttNodeByType(
2678  (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2679  SwStartNode* const p1 = aPam.GetNode().FindSttNodeByType(
2680  (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode);
2681  if (p1 == pOwnStartNode)
2682  {
2683  return static_cast<text::XWordCursor*>(
2684  new SwXTextCursor(
2685  *GetDoc(),
2686  this,
2687  (m_pImpl->m_bIsHeader) ? CursorType::Header : CursorType::Footer,
2688  *aPam.GetPoint(), aPam.GetMark()));
2689  }
2690  return nullptr;
2691 }
2692 
2693 uno::Reference<container::XEnumeration> SAL_CALL SwXHeadFootText::createEnumeration()
2694 {
2695  SolarMutexGuard aGuard;
2696  SwFrameFormat& rHeadFootFormat(m_pImpl->GetHeadFootFormatOrThrow());
2697 
2698  const SwFormatContent& rFlyContent = rHeadFootFormat.GetContent();
2699  const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
2700  SwPosition aPos(rNode);
2701  auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
2702  pUnoCursor->Move(fnMoveForward, GoInNode);
2704  this,
2705  pUnoCursor,
2706  (m_pImpl->m_bIsHeader)
2708  : CursorType::Footer);
2709 }
2710 
2713 
2715  { return true; }
2716 
2717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SwStartNode * FindSttNodeByType(SwStartNodeType eTyp)
Definition: node.cxx:759
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const std::set< sal_uInt16 > &rAttrs=std::set< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:241
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unotext.cxx:848
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotext.cxx:2571
static void lcl_ApplyRowProperties(uno::Sequence< beans::PropertyValue > const &rRowProperties, uno::Any const &rRow, TableColumnSeparators &rRowSeparators)
Definition: unotext.cxx:1994
void DeleteMark()
Definition: pam.hxx:177
SwXHeadFootText(SwFrameFormat &rHeadFootFormat, const bool bIsHeader)
Definition: unotext.cxx:2548
const CursorType m_eType
Definition: unotext.cxx:82
void SetDoc(SwDoc *const pDoc)
Definition: unotext.cxx:149
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
static css::uno::Reference< css::text::XTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:2017
sal_uLong GetIndex() const
Definition: node.hxx:282
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
OUString sMessage
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:963
virtual ~SwXText()
Definition: unotext.cxx:126
virtual void SAL_CALL setName(const OUString &Name_) override
Definition: unoframe.cxx:1311
virtual void Notify(const SfxHint &rHint) override
Definition: unotext.cxx:2525
Marks a position in the document model.
Definition: pam.hxx:35
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:2363
bool IsSectionNode() const
Definition: node.hxx:644
SwFrameFormat * GetHeadFootFormat() const
Definition: unotext.cxx:2514
void attachToText(SwXText &rParent, SwTextNode &rTextNode)
for SwXText
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:27
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotext.cxx:2357
CursorType
static css::uno::Reference< css::text::XText > CreateXHeadFootText(SwFrameFormat &rHeadFootFormat, const bool bIsHeader)
Definition: unotext.cxx:2532
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1009
SwNodeIndex nNode
Definition: pam.hxx:37
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:167
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotext.cxx:2400
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:275
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotext.cxx:1093
sal_uIntPtr sal_uLong
const SwFrameFormat * GetFrameFormat() const
Definition: unoframe.hxx:152
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor() override
Definition: unotext.cxx:2591
static css::uno::Reference< css::text::XTextContent > CreateXParagraph(SwDoc &rDoc, SwTextNode *pTextNode, css::uno::Reference< css::text::XText > const &xParentText=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)
void Invalidate()
Definition: unoobj2.cxx:743
const SwPosition * GetMark() const
Definition: pam.hxx:209
void Invalidate()
Definition: unotext.cxx:144
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1060
void attachToRange(css::uno::Reference< css::text::XTextRange > const &xTextRange, SwPaM const *pCopySource=nullptr)
Definition: unoframe.cxx:2670
Definition: doc.hxx:184
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
SwSectionNode is derived from SwStartNode.
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL finishParagraphInsert(const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties, const css::uno::Reference< css::text::XTextRange > &xInsertPosition) override
Definition: unotext.cxx:1220
void DeleteAndInsert(OUString const &rText, const bool bForceExpandHints)
Definition: unoobj.cxx:727
#define CHAR_HARDBLANK
Definition: swtypes.hxx:164
Impl(SwFrameFormat &rHeadFootFormat, const bool bIsHeader)
Definition: unotext.cxx:2507
const_iterator find(const Value &x) const
sal_Int16 SAL_CALL compareRegionEnds(const css::uno::Reference< css::text::XTextRange > &xR1, const css::uno::Reference< css::text::XTextRange > &xR2) override
Definition: unotext.cxx:1076
SwNode & GetNode() const
Definition: ndindex.hxx:119
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
void SetPropertyValues(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< css::beans::PropertyValue > &rPropertyValues, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &xTextPosition) override
Definition: unotext.cxx:2659
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
static bool isGraphicNode(const SwFrameFormat *pFrameFormat)
Definition: unotext.cxx:1510
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:2596
#define UNO_NAME_ROW_SPAN
Definition: unoprnms.hxx:787
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
bool IsValid() const
Definition: unotext.cxx:139
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unotext.cxx:874
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unotext.cxx:1199
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
virtual ~SwXHeadFootText() override
Definition: unotext.cxx:2556
SfxHintId GetId() const
SwXTextCursor * CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2371
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:260
virtual OUString SAL_CALL getImplementationName() override
Definition: unotext.cxx:2305
static bool IsShowChanges(const RedlineFlags eM)
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotext.cxx:2711
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unoframe.cxx:3243
css::uno::Reference< css::i18n::XExtendedTransliteration > Body
#define CHAR_SOFTHYPHEN
Definition: swtypes.hxx:166
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unotext.cxx:1179
size_type size() const
Definition: docary.hxx:266
virtual OUString SAL_CALL getImplementationName() override
Definition: unotext.cxx:2560
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotext.hxx:57
sal_Int16 SAL_CALL compareRegionStarts(const css::uno::Reference< css::text::XTextRange > &xR1, const css::uno::Reference< css::text::XTextRange > &xR2) override
Definition: unotext.cxx:1059
SwDoc * m_pDoc
Definition: docbm.cxx:1190
css::uno::Any const & rValue
sal_uInt16 sal_Unicode
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unotext.cxx:1187
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unotext.cxx:2310
virtual css::uno::Reference< css::text::XTextTable > SAL_CALL convertToTable(css::uno::Sequence< css::uno::Sequence< css::uno::Sequence< css::uno::Reference< css::text::XTextRange > > > > const &rTableRanges, css::uno::Sequence< css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > > const &rCellProperties, css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > const &rRowProperties, css::uno::Sequence< css::beans::PropertyValue > const &rTableProperties) override
Definition: unotext.cxx:2108
virtual const SwStartNode * GetStartNode() const override
Definition: unotext.cxx:2576
SwNodeType GetNodeType() const
Definition: node.hxx:144
SwIndex nContent
Definition: pam.hxx:38
Any SAL_CALL getCaughtException()
SwNodeIndex aStart
Definition: ndindex.hxx:132
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
SwSectionNode * GetSectionNode()
Definition: section.cxx:1004
check if target position is in fly anchored at source range
const OUString & GetName() const
Definition: format.hxx:111
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SwFrameFormat * m_pHeadFootFormat
Definition: unotext.cxx:2504
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: unotext.cxx:387
virtual const SwStartNode * GetStartNode() const
Definition: unotext.cxx:168
bool IsStartNode() const
Definition: node.hxx:624
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:169
uno::Reference< sdbc::XRow > xRow
virtual bool Undo()=0
Execute Undo.
uno::Sequence< text::TableColumnSeparator > TableColumnSeparators
Definition: unotext.cxx:1991
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:952
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotext.cxx:2714
static void lcl_ApplyCellProperties(const sal_Int32 nLeftPos, const uno::Sequence< beans::PropertyValue > &rCellProperties, const uno::Reference< uno::XInterface > &xCell, std::vector< VerticallyMergedCell > &rMergedCells)
Definition: unotext.cxx:2025
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:111
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL appendTextContent(const css::uno::Reference< css::text::XTextContent > &xTextContent, const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties) override
Definition: unotext.cxx:1498
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotext.cxx:2603
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void DeleteAndInsert(const OUString &rText, const bool bForceExpandHints)
Definition: unoobj2.cxx:756
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:501
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotext.cxx:2316
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1922
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unotext.cxx:2565
Style of a layout element.
Definition: frmfmt.hxx:57
virtual OUString SAL_CALL getString() override
Definition: unotext.cxx:889
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
virtual void SAL_CALL copyText(const css::uno::Reference< css::text::XTextCopy > &xSource) override
Definition: unotext.cxx:2233
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotext.cxx:2693
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
static bool lcl_SimilarPosition(const sal_Int32 nPos1, const sal_Int32 nPos2)
Definition: unotext.cxx:1826
int i
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:954
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
virtual void SAL_CALL insertTextContentAfter(const css::uno::Reference< css::text::XTextContent > &xNewContent, const css::uno::Reference< css::text::XTextContent > &xPredecessor) override
Definition: unotext.cxx:674
const SwPosition * GetPoint() const
Definition: pam.hxx:207
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unotext.cxx:1205
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:693
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void ConvertCell(const uno::Sequence< uno::Reference< text::XTextRange > > &rCell, std::vector< SwNodeRange > &rRowNodes, SwNodeRange *const pLastCell)
Definition: unotext.cxx:1831
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:2608
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
static sal_Int32 lcl_GetLeftPos(sal_Int32 nCell, TableColumnSeparators const &rRowSeparators)
Definition: unotext.cxx:2015
bool CheckForOwnMember(const SwPaM &rPaM)
Definition: unotext.cxx:972
uno::Reference< text::XTextRange > finishOrAppendParagraph(const uno::Sequence< beans::PropertyValue > &rCharacterAndParagraphProperties, const uno::Reference< text::XTextRange > &xInsertPosition)
Definition: unotext.cxx:1230
std::unique_ptr< SwNodeRange > ExpandRangeForTableBox(const SwNodeRange &rRange)
Definition: ndtbl.cxx:1284
FlyAnchors.
Definition: fmtanchr.hxx:34
static SwXParagraphEnumeration * Create(css::uno::Reference< css::text::XText > const &xParent, const std::shared_ptr< SwUnoCursor > &pCursor, const CursorType eType, SwStartNode const *const pStartNode=nullptr, SwTable const *const pTable=nullptr)
Definition: unoobj2.cxx:451
void MakeStartIndex(SwIndex *pIdx)
Definition: node.hxx:391
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
virtual void PrepareForAttach(css::uno::Reference< css::text::XTextRange > &xRange, SwPaM const &rPam)
Definition: unotext.cxx:158
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:189
unsigned char sal_Bool
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor()
Definition: unotext.cxx:174
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotext.cxx:2480
Object Value
#define COL_POS_FUZZY
Definition: unotext.cxx:1824
virtual void SAL_CALL removeTextContentAfter(const css::uno::Reference< css::text::XTextContent > &xPredecessor) override
Definition: unotext.cxx:781
Marks a node in the document model.
Definition: ndindex.hxx:31
static void lcl_MergeCells(std::vector< VerticallyMergedCell > &rMergedCells)
Definition: unotext.cxx:2087
bool IsEndNode() const
Definition: node.hxx:632
css::uno::Type const & get()
SfxItemPropertySet const & m_rPropSet
Definition: unotext.cxx:81
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:942
const_iterator end() const
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
tuple index
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:320
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
bool StartListening(SvtBroadcaster &rBroadcaster)
SwStartNode * GetStartNode()
Definition: node.hxx:591
SwDoc * m_pDoc
Definition: unotext.cxx:83
const char cInvalidObject[]
Definition: unotext.cxx:74
const SvXMLTokenMapEntry aTypes[]
Footer
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
const SwPosition * Start() const
Definition: pam.hxx:212
virtual ~SwXBodyText() override
Definition: unotext.cxx:2300
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &xTextPosition) override
Definition: unotext.cxx:2416
SwXText & m_rThis
Definition: unotext.cxx:80
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
virtual const SwPaM * GetPaM() const =0
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotext.cxx:1171
virtual bool CheckForOwnMemberMeta(const SwPaM &rPam, const bool bAbsorb)
Definition: unotext.cxx:162
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL appendTextPortion(const OUString &rText, const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties) override
Definition: unotext.cxx:1425
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
Definition: unotext.cxx:2322
const SwDoc * GetDoc() const
Definition: unotext.cxx:130
bool IsDescriptor() const
Definition: unoframe.hxx:159
sal_Int16 ComparePositions(const uno::Reference< text::XTextRange > &xPos1, const uno::Reference< text::XTextRange > &xPos2)
Definition: unotext.cxx:1020
#define CHAR_HARDHYPHEN
Definition: swtypes.hxx:165
#define PROPERTY_MAP_PARAGRAPH
Definition: unomap.hxx:62
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(SwRangeRedline const &rRedline, bool const bIsStart)
Definition: unoredline.cxx:289
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:690
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL finishParagraph(const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties) override
Definition: unotext.cxx:1211
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unotext.cxx:858
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: unotext.cxx:834
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: unotext.cxx:281
#define SAL_WARN_IF(condition, area, stream)
bool GetPositions(SwPaM &rToFill) const
Definition: unoobj2.cxx:930
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unotext.cxx:1103
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
SwXBodyText(SwDoc *const pDoc)
Definition: unotext.cxx:2295
bool DontExpandFormat(const SwPosition &rPos, bool bFlag=true)
Definition: docfmt.cxx:1690
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotext.cxx:2461
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotext.cxx:1163
Header
Impl(SwXText &rThis, SwDoc *const pDoc, const CursorType eType)
Definition: unotext.cxx:86
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
SwXText(SwDoc *const pDoc, const CursorType eType)
Definition: unotext.cxx:121
SwNodes & GetNodes()
Definition: doc.hxx:403
SwSectionFormat * GetFormat() const
Definition: unosect.cxx:190
const SwPosition * End() const
Definition: pam.hxx:217
SwNodeIndex aEnd
Definition: ndindex.hxx:133
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3178
bool IsDescriptor() const
SwTableNode is derived from SwStartNode.
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:89
double getLength(const B2DPolygon &rCandidate)
virtual bool AppendTextNode(SwPosition &rPos)=0
SwStartNodeType
Definition: ndtyp.hxx:50
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:352
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual void SAL_CALL removeTextContentBefore(const css::uno::Reference< css::text::XTextContent > &xSuccessor) override
Definition: unotext.cxx:729
bool m_bIsValid
Definition: unotext.cxx:84
virtual css::uno::Reference< css::text::XTextContent > SAL_CALL convertToTextFrame(const css::uno::Reference< css::text::XTextRange > &xStart, const css::uno::Reference< css::text::XTextRange > &xEnd, const css::uno::Sequence< css::beans::PropertyValue > &xFrameProperties) override
Definition: unotext.cxx:1526
#define SAL_WARN(area, stream)
bool IsTableNode() const
Definition: node.hxx:640
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, const OUString &rText, const bool bForceExpandHints)
Ends a section of nodes in the document model.
Definition: node.hxx:333
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:475
virtual const SwRedlineTable & GetRedlineTable() const =0
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
std::pair< const_iterator, bool > insert(Value &&x)
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unotext.cxx:904
#define FN_UNO_REDLINE_NODE_END
Definition: cmdid.h:569
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL insertTextContentWithProperties(const css::uno::Reference< css::text::XTextContent > &xTextContent, const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties, const css::uno::Reference< css::text::XTextRange > &xInsertPosition) override
Definition: unotext.cxx:1439
virtual void SAL_CALL insertTextContentBefore(const css::uno::Reference< css::text::XTextContent > &xNewContent, const css::uno::Reference< css::text::XTextContent > &xSuccessor) override
Definition: unotext.cxx:616
virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
Definition: unotext.cxx:498
::sw::UnoImplPtr< Impl > m_pImpl
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unotext.cxx:1110
bool IsTextNode() const
Definition: node.hxx:636
void SetPositions(SwPaM const &rPam)
Definition: unoobj2.cxx:748
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotext.cxx:2617
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1288
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL insertTextPortion(const OUString &rText, const css::uno::Sequence< css::beans::PropertyValue > &rCharacterAndParagraphProperties, const css::uno::Reference< css::text::XTextRange > &rTextRange) override
Definition: unotext.cxx:1344
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:844
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotext.cxx:2486
SwFrameFormat & GetHeadFootFormatOrThrow()
Definition: unotext.cxx:2518
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1516
#define PROPERTY_MAP_TEXT
Definition: unomap.hxx:113
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:2349
SwTableNode * GetTableNode() const
Definition: swtable.cxx:1929
Base class of the Writer document model elements.
Definition: node.hxx:79
SW_DLLPUBLIC SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:2033