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