LibreOffice Module sw (master)  1
unoobj.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 <com/sun/star/table/TableSortField.hpp>
21 #include <cppuhelper/exc_hlp.hxx>
23 #include <o3tl/any.hxx>
24 #include <osl/endian.h>
25 #include <rtl/ustrbuf.hxx>
27 #include <swtypes.hxx>
28 #include <hintids.hxx>
29 #include <cmdid.h>
30 #include <unomid.h>
31 #include <hints.hxx>
32 #include <IMark.hxx>
33 #include <frmfmt.hxx>
34 #include <doc.hxx>
35 #include <IDocumentUndoRedo.hxx>
36 #include <istyleaccess.hxx>
37 #include <ndtxt.hxx>
38 #include <ndnotxt.hxx>
39 #include <unocrsr.hxx>
40 #include <unocrsrhelper.hxx>
41 #include <swundo.hxx>
42 #include <rootfrm.hxx>
43 #include <flyfrm.hxx>
44 #include <ftnidx.hxx>
45 #include <sfx2/linkmgr.hxx>
46 #include <docary.hxx>
47 #include <paratr.hxx>
48 #include <pam.hxx>
49 #include <shellio.hxx>
50 #include <swerror.h>
51 #include <swtblfmt.hxx>
52 #include <fmtruby.hxx>
53 #include <docsh.hxx>
54 #include <docstyle.hxx>
55 #include <charfmt.hxx>
56 #include <txtfld.hxx>
57 #include <fmtfld.hxx>
58 #include <fmtpdsc.hxx>
59 #include <pagedesc.hxx>
60 #include <edimp.hxx>
61 #include <fchrfmt.hxx>
62 #include <fmtautofmt.hxx>
63 #include <cntfrm.hxx>
64 #include <pagefrm.hxx>
65 #include <doctxm.hxx>
66 #include <sfx2/docfilt.hxx>
67 #include <sfx2/docfile.hxx>
68 #include <sfx2/fcontnr.hxx>
69 #include <fmtrfmrk.hxx>
70 #include <txtrfmrk.hxx>
71 #include <unotextrange.hxx>
72 #include <unotextcursor.hxx>
73 #include <unomap.hxx>
74 #include <unosett.hxx>
75 #include <unoprnms.hxx>
76 #include <unodraw.hxx>
77 #include <unocoll.hxx>
78 #include <unostyle.hxx>
79 #include <unometa.hxx>
80 #include <fmtanchr.hxx>
81 #include <editeng/flstitem.hxx>
82 #include <svtools/ctrltool.hxx>
83 #include <flypos.hxx>
84 #include <txtftn.hxx>
85 #include <com/sun/star/text/WrapTextMode.hpp>
86 #include <com/sun/star/text/TextContentAnchorType.hpp>
87 #include <com/sun/star/text/TextMarkupType.hpp>
88 #include <com/sun/star/style/PageStyleLayout.hpp>
89 #include <com/sun/star/text/XTextDocument.hpp>
90 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
91 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
92 #include <unoframe.hxx>
93 #include <fmthdft.hxx>
94 #include <vcl/svapp.hxx>
95 #include <unotools/syslocale.hxx>
97 #include <fmtflcnt.hxx>
98 #include <editeng/brushitem.hxx>
99 #include <editeng/unolingu.hxx>
100 #include <fmtclds.hxx>
101 #include <dcontact.hxx>
102 #include <SwStyleNameMapper.hxx>
103 #include <sortopt.hxx>
104 #include <com/sun/star/beans/PropertyAttribute.hpp>
105 #include <com/sun/star/i18n/WordType.hpp>
106 #include <memory>
107 #include <unoparaframeenum.hxx>
108 #include <unoparagraph.hxx>
109 #include <iodetect.hxx>
112 
113 using namespace ::com::sun::star;
114 
115 // Helper classes
117  SwPaM(rDoc.GetNodes())
118 {
119 }
120 
122 {
123  while( GetNext() != this)
124  {
125  delete GetNext();
126  }
127 }
128 
130 {
131  const SwPaM* pTmp = &rPaM;
132  *GetPoint() = *rPaM.GetPoint();
133  if(rPaM.HasMark())
134  {
135  SetMark();
136  *GetMark() = *rPaM.GetMark();
137  }
138  else
139  DeleteMark();
140  while(&rPaM != (pTmp = pTmp->GetNext()))
141  {
142  if(pTmp->HasMark())
143  new SwPaM(*pTmp->GetMark(), *pTmp->GetPoint(), this);
144  else
145  new SwPaM(*pTmp->GetPoint(), this);
146  }
147  return *this;
148 }
149 
150 void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand)
151 {
152  if (bExpand)
153  {
154  if (!rPam.HasMark())
155  {
156  rPam.SetMark();
157  }
158  }
159  else if (rPam.HasMark())
160  {
161  rPam.DeleteMark();
162  }
163 }
164 
165 void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer,
166  SwRootFrame const*const pLayout)
167 {
168  if (!rPam.HasMark())
169  {
170  return;
171  }
172  SvMemoryStream aStream;
173 #ifdef OSL_BIGENDIAN
174  aStream.SetEndian( SvStreamEndian::BIG );
175 #else
176  aStream.SetEndian( SvStreamEndian::LITTLE );
177 #endif
178  WriterRef xWrt;
179  // TODO/MBA: looks like a BaseURL doesn't make sense here
180  SwReaderWriter::GetWriter( FILTER_TEXT_DLG, OUString(), xWrt );
181  if( !xWrt.is() )
182  return;
183 
184  SwWriter aWriter( aStream, rPam );
185  xWrt->m_bASCII_NoLastLineEnd = true;
186  xWrt->m_bExportPargraphNumbering = false;
187  SwAsciiOptions aOpt = xWrt->GetAsciiOptions();
188  aOpt.SetCharSet( RTL_TEXTENCODING_UNICODE );
189  xWrt->SetAsciiOptions( aOpt );
190  xWrt->m_bUCS2_WithStartChar = false;
191  // #i68522#
192  const bool bOldShowProgress = xWrt->m_bShowProgress;
193  xWrt->m_bShowProgress = false;
194  xWrt->m_bHideDeleteRedlines = pLayout && pLayout->IsHideRedlines();
195 
196  if( ! aWriter.Write( xWrt ).IsError() )
197  {
198  const sal_uInt64 lUniLen = aStream.GetSize()/sizeof( sal_Unicode );
199  if (lUniLen < static_cast<sal_uInt64>(SAL_MAX_INT32-1))
200  {
201  aStream.WriteUInt16( '\0' );
202 
203  aStream.Seek( 0 );
204  aStream.ResetError();
205 
206  rtl_uString *pStr = rtl_uString_alloc(lUniLen);
207  aStream.ReadBytes(pStr->buffer, lUniLen * sizeof(sal_Unicode));
208  rBuffer = OUString(pStr, SAL_NO_ACQUIRE);
209  }
210  }
211  xWrt->m_bShowProgress = bOldShowProgress;
212 
213 }
214 
217 static void
218 lcl_setCharStyle(SwDoc *const pDoc, const uno::Any & rValue, SfxItemSet & rSet)
219 {
220  SwDocShell *const pDocSh = pDoc->GetDocShell();
221  if(pDocSh)
222  {
223  OUString uStyle;
224  if (!(rValue >>= uStyle))
225  {
226  throw lang::IllegalArgumentException();
227  }
228  OUString sStyle;
229  SwStyleNameMapper::FillUIName(uStyle, sStyle,
231  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
232  pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
233  if (!pStyle)
234  {
235  throw lang::IllegalArgumentException();
236  }
237  const SwFormatCharFormat aFormat(pStyle->GetCharFormat());
238  rSet.Put(aFormat);
239  }
240 };
241 
243 static void
244 lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue,
245  SfxItemSet & rSet, const bool bPara)
246 {
247  OUString uStyle;
248  if (!(rValue >>= uStyle))
249  {
250  throw lang::IllegalArgumentException();
251  }
252  std::shared_ptr<SfxItemSet> pStyle = bPara ?
253  rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ):
254  rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR );
255  if(!pStyle.get())
256  {
257  throw lang::IllegalArgumentException();
258  }
259 
260  SwFormatAutoFormat aFormat( bPara
261  ? sal::static_int_cast< sal_uInt16 >(RES_AUTO_STYLE)
262  : sal::static_int_cast< sal_uInt16 >(RES_TXTATR_AUTOFMT) );
263  aFormat.SetStyleHandle( pStyle );
264  rSet.Put(aFormat);
265 };
266 
267 void
269 {
270  SwDoc *const pDoc = rPaM.GetDoc();
271  SwDocShell *const pDocSh = pDoc->GetDocShell();
272  if(!pDocSh)
273  return;
274  OUString uStyle;
275  rAny >>= uStyle;
276  OUString sStyle;
277  SwStyleNameMapper::FillUIName(uStyle, sStyle,
279  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
280  pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Para));
281  if (!pStyle)
282  {
283  throw lang::IllegalArgumentException();
284  }
285 
286  SwTextFormatColl *const pLocal = pStyle->GetCollection();
287  UnoActionContext aAction(pDoc);
288  pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
289  SwPaM *pTmpCursor = &rPaM;
290  do {
291  pDoc->SetTextFormatColl(*pTmpCursor, pLocal);
292  pTmpCursor = pTmpCursor->GetNext();
293  } while ( pTmpCursor != &rPaM );
294  pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
295 }
296 
297 bool
299  const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet)
300 {
301  OUString uDescName;
302  if (!(rValue >>= uDescName))
303  {
304  return false;
305  }
306  std::unique_ptr<SwFormatPageDesc> pNewDesc;
307  const SfxPoolItem* pItem;
308  if(SfxItemState::SET == rSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
309  {
310  pNewDesc.reset(new SwFormatPageDesc(
311  *static_cast<const SwFormatPageDesc*>(pItem)));
312  }
313  if (!pNewDesc)
314  {
315  pNewDesc.reset(new SwFormatPageDesc());
316  }
317  OUString sDescName;
318  SwStyleNameMapper::FillUIName(uDescName, sDescName,
320  if (!pNewDesc->GetPageDesc() ||
321  (pNewDesc->GetPageDesc()->GetName() != sDescName))
322  {
323  bool bPut = false;
324  if (!sDescName.isEmpty())
325  {
326  SwPageDesc *const pPageDesc = SwPageDesc::GetByName(rDoc, sDescName);
327  if (!pPageDesc)
328  {
329  throw lang::IllegalArgumentException();
330  }
331  pNewDesc->RegisterToPageDesc(*pPageDesc);
332  bPut = true;
333  }
334  if(!bPut)
335  {
336  rSet.ClearItem(RES_BREAK);
337  rSet.Put(SwFormatPageDesc());
338  }
339  else
340  {
341  rSet.Put(*pNewDesc);
342  }
343  }
344  return true;
345 }
346 
347 static void
348 lcl_SetNodeNumStart(SwPaM & rCursor, uno::Any const& rValue)
349 {
350  sal_Int16 nTmp = 1;
351  rValue >>= nTmp;
352  sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : static_cast<sal_uInt16>(nTmp));
353  SwDoc* pDoc = rCursor.GetDoc();
354  UnoActionContext aAction(pDoc);
355 
356  if( rCursor.GetNext() != &rCursor ) // MultiSelection?
357  {
358  pDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
359  SwPamRanges aRangeArr( rCursor );
360  SwPaM aPam( *rCursor.GetPoint() );
361  for( size_t n = 0; n < aRangeArr.Count(); ++n )
362  {
363  pDoc->SetNumRuleStart(*aRangeArr.SetPam( n, aPam ).GetPoint());
364  pDoc->SetNodeNumStart(*aRangeArr.SetPam( n, aPam ).GetPoint(),
365  nStt );
366  }
367  pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
368  }
369  else
370  {
371  pDoc->SetNumRuleStart( *rCursor.GetPoint());
372  pDoc->SetNodeNumStart( *rCursor.GetPoint(), nStt );
373  }
374 }
375 
376 static bool
378 {
379  uno::Sequence<OUString> aCharStyles;
380  if (!(rValue >>= aCharStyles))
381  {
382  return false;
383  }
384 
385  for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++)
386  {
387  uno::Any aStyle;
389  aStyle <<= aCharStyles.getConstArray()[nStyle];
390  // create a local set and apply each format directly
391  SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(),
393  lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet);
394  // the first style should replace the current attributes,
395  // all other have to be added
396  SwUnoCursorHelper::SetCursorAttr(rPam, aSet, nStyle
400  }
401  return true;
402 }
403 
404 static void
405 lcl_setDropcapCharStyle(SwPaM const & rPam, SfxItemSet & rItemSet,
406  uno::Any const& rValue)
407 {
408  OUString uStyle;
409  if (!(rValue >>= uStyle))
410  {
411  throw lang::IllegalArgumentException();
412  }
413  OUString sStyle;
414  SwStyleNameMapper::FillUIName(uStyle, sStyle,
416  SwDoc *const pDoc = rPam.GetDoc();
417  //default character style must not be set as default format
418  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
419  pDoc->GetDocShell()
420  ->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
421  if (!pStyle || pStyle->GetCharFormat() == pDoc->GetDfltCharFormat())
422  {
423  throw lang::IllegalArgumentException();
424  }
425  std::unique_ptr<SwFormatDrop> pDrop;
426  SfxPoolItem const* pItem(nullptr);
427  if (SfxItemState::SET ==
428  rItemSet.GetItemState(RES_PARATR_DROP, true, &pItem))
429  {
430  pDrop.reset(new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem)));
431  }
432  if (!pDrop)
433  {
434  pDrop.reset(new SwFormatDrop);
435  }
436  const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*pStyle));
437  pDrop->SetCharFormat(xStyle->GetCharFormat());
438  rItemSet.Put(*pDrop);
439 }
440 
441 static void
442 lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue)
443 {
444  OUString sTmp;
445  if (!(rValue >>= sTmp))
446  {
447  throw lang::IllegalArgumentException();
448  }
449 
450  std::unique_ptr<SwFormatRuby> pRuby;
451  const SfxPoolItem* pItem;
452  if (SfxItemState::SET ==
453  rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, true, &pItem))
454  {
455  pRuby.reset(new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem)));
456  }
457  if (!pRuby)
458  {
459  pRuby.reset(new SwFormatRuby(OUString()));
460  }
461  OUString sStyle;
462  SwStyleNameMapper::FillUIName(sTmp, sStyle,
464  pRuby->SetCharFormatName(sStyle);
465  pRuby->SetCharFormatId(0);
466  if (!sStyle.isEmpty())
467  {
468  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
470  pRuby->SetCharFormatId(nId);
471  }
472  rItemSet.Put(*pRuby);
473 }
474 
475 bool
477  SfxItemPropertySimpleEntry const& rEntry, const uno::Any& rValue,
478  SwPaM & rPam, SfxItemSet & rItemSet)
479 {
480  if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) &&
481  (rValue.getValueType() == cppu::UnoType<void>::get()))
482  {
483  return false;
484  }
485  bool bRet = true;
486  switch (rEntry.nWID)
487  {
488  case RES_TXTATR_CHARFMT:
489  lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet);
490  break;
491  case RES_TXTATR_AUTOFMT:
493  rValue, rItemSet, false);
494  break;
496  lcl_setCharFormatSequence(rPam, rValue);
497  break;
498  case FN_UNO_PARA_STYLE :
500  break;
501  case RES_AUTO_STYLE:
503  rValue, rItemSet, true);
504  break;
505  case FN_UNO_PAGE_STYLE:
506  //FIXME nothing here?
507  break;
509  lcl_SetNodeNumStart( rPam, rValue );
510  break;
511  case FN_UNO_NUM_LEVEL:
512  // #i91601#
513  case FN_UNO_LIST_ID:
514  case FN_UNO_IS_NUMBER:
515  {
516  // multi selection is not considered
517  SwTextNode *const pTextNd = rPam.GetNode().GetTextNode();
518  if (!pTextNd)
519  {
520  throw lang::IllegalArgumentException();
521  }
522  if (FN_UNO_NUM_LEVEL == rEntry.nWID)
523  {
524  sal_Int16 nLevel = 0;
525  if (rValue >>= nLevel)
526  {
527  if (nLevel < 0 || MAXLEVEL <= nLevel)
528  {
529  throw lang::IllegalArgumentException(
530  "invalid NumberingLevel", nullptr, 0);
531  }
532  pTextNd->SetAttrListLevel(nLevel);
533  }
534  }
535  // #i91601#
536  else if (FN_UNO_LIST_ID == rEntry.nWID)
537  {
538  OUString sListId;
539  if (rValue >>= sListId)
540  {
541  pTextNd->SetListId( sListId );
542  }
543  }
544  else if (FN_UNO_IS_NUMBER == rEntry.nWID)
545  {
546  bool bIsNumber(false);
547  if ((rValue >>= bIsNumber) && !bIsNumber)
548  {
549  pTextNd->SetCountedInList( false );
550  }
551  }
552  //PROPERTY_MAYBEVOID!
553  }
554  break;
555  case FN_NUMBER_NEWSTART:
556  {
557  bool bVal = false;
558  if (!(rValue >>= bVal))
559  {
560  throw lang::IllegalArgumentException();
561  }
562  rPam.GetDoc()->SetNumRuleStart(*rPam.GetPoint(), bVal);
563  }
564  break;
565  case FN_UNO_NUM_RULES:
567  break;
568  case RES_PARATR_DROP:
569  {
571  {
572  lcl_setDropcapCharStyle(rPam, rItemSet, rValue);
573  }
574  else
575  {
576  bRet = false;
577  }
578  }
579  break;
580  case RES_TXTATR_CJK_RUBY:
581  {
582  if (MID_RUBY_CHARSTYLE == rEntry.nMemberId)
583  {
584  lcl_setRubyCharstyle(rItemSet, rValue);
585  }
586  else
587  {
588  bRet = false;
589  }
590  }
591  break;
592  case RES_PAGEDESC:
593  {
594  if (MID_PAGEDESC_PAGEDESCNAME == rEntry.nMemberId)
595  {
597  rValue, *rPam.GetDoc(), rItemSet);
598  }
599  else
600  {
601  bRet = false;
602  }
603  }
604  break;
605  default:
606  bRet = false;
607  }
608  return bRet;
609 }
610 
611 SwFormatColl *
612 SwUnoCursorHelper::GetCurTextFormatColl(SwPaM & rPaM, const bool bConditional)
613 {
614  static const sal_uLong nMaxLookup = 1000;
615  SwFormatColl *pFormat = nullptr;
616  bool bError = false;
617  SwPaM *pTmpCursor = &rPaM;
618  do
619  {
620  const sal_uLong nSttNd = pTmpCursor->Start()->nNode.GetIndex();
621  const sal_uLong nEndNd = pTmpCursor->End()->nNode.GetIndex();
622 
623  if( nEndNd - nSttNd >= nMaxLookup )
624  {
625  pFormat = nullptr;
626  break;
627  }
628 
629  const SwNodes& rNds = rPaM.GetDoc()->GetNodes();
630  for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
631  {
632  SwTextNode const*const pNd = rNds[ n ]->GetTextNode();
633  if( pNd )
634  {
635  SwFormatColl *const pNdFormat = bConditional
636  ? pNd->GetFormatColl() : &pNd->GetAnyFormatColl();
637  if( !pFormat )
638  {
639  pFormat = pNdFormat;
640  }
641  else if( pFormat != pNdFormat )
642  {
643  bError = true;
644  break;
645  }
646  }
647  }
648 
649  pTmpCursor = pTmpCursor->GetNext();
650  } while ( pTmpCursor != &rPaM );
651  return bError ? nullptr : pFormat;
652 }
653 
655 {
656 
657 public:
660  const uno::Reference< text::XText > m_xParentText;
662 
663  Impl( SwDoc & rDoc,
664  const CursorType eType,
665  uno::Reference<text::XText> const & xParent,
666  SwPosition const& rPoint, SwPosition const*const pMark)
667  : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
668  , m_eType(eType)
669  , m_xParentText(xParent)
670  , m_pUnoCursor(rDoc.CreateUnoCursor(rPoint))
671  {
672  if (pMark)
673  {
674  m_pUnoCursor->SetMark();
675  *m_pUnoCursor->GetMark() = *pMark;
676  }
677  }
678 
680  if(!m_pUnoCursor)
681  throw uno::RuntimeException("SwXTextCursor: disposed or invalid", nullptr);
682  return *m_pUnoCursor;
683  }
684 };
685 
687  { return *m_pImpl->m_pUnoCursor; }
688 
690  { return m_pImpl->m_pUnoCursor.get(); }
691 
693  { return m_pImpl->m_pUnoCursor.get(); }
694 
696  { return m_pImpl->m_pUnoCursor ? m_pImpl->m_pUnoCursor->GetDoc() : nullptr; }
697 
699  { return m_pImpl->m_pUnoCursor ? m_pImpl->m_pUnoCursor->GetDoc() : nullptr; }
700 
702  SwDoc & rDoc,
703  uno::Reference< text::XText > const& xParent,
704  const CursorType eType,
705  const SwPosition& rPos,
706  SwPosition const*const pMark)
707  : m_pImpl( new Impl(rDoc, eType, xParent, rPos, pMark) )
708 {
709 }
710 
711 SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent,
712  SwPaM const& rSourceCursor, const CursorType eType)
713  : m_pImpl( new Impl(*rSourceCursor.GetDoc(), eType,
714  xParent, *rSourceCursor.GetPoint(),
715  rSourceCursor.HasMark() ? rSourceCursor.GetMark() : nullptr) )
716 {
717 }
718 
720 {
721 }
722 
723 void SwXTextCursor::DeleteAndInsert(const OUString& rText,
724  const bool bForceExpandHints)
725 {
726  auto pUnoCursor = static_cast<SwCursor*>(m_pImpl->m_pUnoCursor.get());
727  if (pUnoCursor)
728  {
729  // Start/EndAction
730  SwDoc* pDoc = pUnoCursor->GetDoc();
731  UnoActionContext aAction(pDoc);
732  const sal_Int32 nTextLen = rText.getLength();
734  auto pCurrent = pUnoCursor;
735  do
736  {
737  if (pCurrent->HasMark())
738  {
739  pDoc->getIDocumentContentOperations().DeleteAndJoin(*pCurrent);
740  }
741  if(nTextLen)
742  {
743  const bool bSuccess(
745  *pDoc, *pCurrent, rText, bForceExpandHints ) );
746  OSL_ENSURE( bSuccess, "Doc->Insert(Str) failed." );
747 
748  SwUnoCursorHelper::SelectPam(*pUnoCursor, true);
749  pCurrent->Left(rText.getLength());
750  }
751  pCurrent = pCurrent->GetNext();
752  } while (pCurrent != pUnoCursor);
754  }
755 }
756 
758 
759 static bool
761  uno::Reference<text::XText> const & xParentText,
762  const enum ForceIntoMetaMode eMode)
763 {
764  bool bRet( true ); // means not forced in META_CHECK_BOTH
765  SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) );
766  OSL_ENSURE(pXMeta, "no parent?");
767  if (!pXMeta)
768  throw uno::RuntimeException();
769  SwTextNode * pTextNode;
770  sal_Int32 nStart;
771  sal_Int32 nEnd;
772  const bool bSuccess( pXMeta->SetContentRange(pTextNode, nStart, nEnd) );
773  OSL_ENSURE(bSuccess, "no pam?");
774  if (!bSuccess)
775  throw uno::RuntimeException();
776  // force the cursor back into the meta if it has moved outside
777  SwPosition start(*pTextNode, nStart);
778  SwPosition end(*pTextNode, nEnd);
779  switch (eMode)
780  {
781  case META_INIT_START:
782  *rCursor.GetPoint() = start;
783  break;
784  case META_INIT_END:
785  *rCursor.GetPoint() = end;
786  break;
787  case META_CHECK_BOTH:
788  if (*rCursor.Start() < start)
789  {
790  *rCursor.Start() = start;
791  bRet = false;
792  }
793  if (*rCursor.End() > end)
794  {
795  *rCursor.End() = end;
796  bRet = false;
797  }
798  break;
799  }
800  return bRet;
801 }
802 
804 {
805  if (CursorType::Meta == m_pImpl->m_eType)
806  {
807  auto pCursor( m_pImpl->m_pUnoCursor );
808  SwXMeta const*const pXMeta(
809  dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get()) );
810  OSL_ENSURE(pXMeta, "no meta?");
811  if (pCursor && pXMeta)
812  {
813  SwTextNode * pTextNode;
814  sal_Int32 nStart;
815  sal_Int32 nEnd;
816  const bool bSuccess(
817  pXMeta->SetContentRange(pTextNode, nStart, nEnd) );
818  OSL_ENSURE(bSuccess, "no pam?");
819  if (bSuccess)
820  {
821  const SwPosition end(*pTextNode, nEnd);
822  if ( (*pCursor->GetPoint() == end)
823  || (*pCursor->GetMark() == end))
824  {
825  return true;
826  }
827  }
828  }
829  }
830  return false;
831 }
832 
834 {
835  return OUString("SwXTextCursor");
836 }
837 
838 sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName)
839 {
840  return cppu::supportsService(this, rServiceName);
841 }
842 
843 uno::Sequence< OUString > SAL_CALL
845 {
846  return {
847  "com.sun.star.text.TextCursor",
848  "com.sun.star.style.CharacterProperties",
849  "com.sun.star.style.CharacterPropertiesAsian",
850  "com.sun.star.style.CharacterPropertiesComplex",
851  "com.sun.star.style.ParagraphProperties",
852  "com.sun.star.style.ParagraphPropertiesAsian",
853  "com.sun.star.style.ParagraphPropertiesComplex",
854  "com.sun.star.text.TextSortable"
855  };
856 }
857 
858 namespace
859 {
860  class theSwXTextCursorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextCursorUnoTunnelId > {};
861 }
862 
863 const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId()
864 {
865  return theSwXTextCursorUnoTunnelId::get().getSeq();
866 }
867 
868 sal_Int64 SAL_CALL
869 SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId)
870 {
871  const sal_Int64 nRet( ::sw::UnoTunnelImpl<SwXTextCursor>(rId, this) );
872  return nRet ? nRet : OTextCursorHelper::getSomething(rId);
873 }
874 
876 {
877  SolarMutexGuard aGuard;
878 
879  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
880 
881  if (rUnoCursor.HasMark())
882  {
883  if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark())
884  {
885  rUnoCursor.Exchange();
886  }
887  rUnoCursor.DeleteMark();
888  }
889 }
890 
892 {
893  SolarMutexGuard aGuard;
894 
895  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
896 
897  if (rUnoCursor.HasMark())
898  {
899  if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark())
900  {
901  rUnoCursor.Exchange();
902  }
903  rUnoCursor.DeleteMark();
904  }
905 }
906 
908 {
909  SolarMutexGuard aGuard;
910 
911  bool bRet = true;
912  auto pUnoCursor(m_pImpl->m_pUnoCursor);
913  if(pUnoCursor && pUnoCursor->GetMark())
914  {
915  bRet = (*pUnoCursor->GetPoint() == *pUnoCursor->GetMark());
916  }
917  return bRet;
918 }
919 
920 sal_Bool SAL_CALL
921 SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand)
922 {
923  SolarMutexGuard aGuard;
924 
925  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
926 
927  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
928  bool bRet = rUnoCursor.Left( nCount);
929  if (CursorType::Meta == m_pImpl->m_eType)
930  {
931  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
933  && bRet;
934  }
935  return bRet;
936 }
937 
938 sal_Bool SAL_CALL
939 SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand)
940 {
941  SolarMutexGuard aGuard;
942 
943  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
944 
945  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
946  bool bRet = rUnoCursor.Right(nCount);
947  if (CursorType::Meta == m_pImpl->m_eType)
948  {
949  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
951  && bRet;
952  }
953  return bRet;
954 }
955 
956 void SAL_CALL
958 {
959  SolarMutexGuard aGuard;
960  comphelper::ProfileZone aZone("gotoStart");
961 
962  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
963 
964  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
965  if (CursorType::Body == m_pImpl->m_eType)
966  {
967  rUnoCursor.Move( fnMoveBackward, GoInDoc );
968  //check, that the cursor is not in a table
969  SwTableNode * pTableNode = rUnoCursor.GetNode().FindTableNode();
970  SwContentNode * pCNode = nullptr;
971  while (pTableNode)
972  {
973  rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode();
974  pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode);
975  pTableNode = pCNode ? pCNode->FindTableNode() : nullptr;
976  }
977  if (pCNode)
978  {
979  rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
980  }
981  SwStartNode const*const pTmp =
982  rUnoCursor.GetNode().StartOfSectionNode();
983  if (pTmp->IsSectionNode())
984  {
985  SwSectionNode const*const pSectionStartNode =
986  static_cast<SwSectionNode const*>(pTmp);
987  if (pSectionStartNode->GetSection().IsHiddenFlag())
988  {
989  pCNode = GetDoc()->GetNodes().GoNextSection(
990  &rUnoCursor.GetPoint()->nNode, true, false);
991  if (pCNode)
992  {
993  rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
994  }
995  }
996  }
997  }
998  else if ( (CursorType::Frame == m_pImpl->m_eType)
999  || (CursorType::TableText == m_pImpl->m_eType)
1000  || (CursorType::Header == m_pImpl->m_eType)
1001  || (CursorType::Footer == m_pImpl->m_eType)
1002  || (CursorType::Footnote== m_pImpl->m_eType)
1003  || (CursorType::Redline == m_pImpl->m_eType))
1004  {
1005  rUnoCursor.MoveSection(GoCurrSection, fnSectionStart);
1006  }
1007  else if (CursorType::Meta == m_pImpl->m_eType)
1008  {
1009  lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_START);
1010  }
1011 }
1012 
1013 void SAL_CALL
1015 {
1016  SolarMutexGuard aGuard;
1017  comphelper::ProfileZone aZone("gotoEnd");
1018 
1019  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1020 
1021  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1022  if (CursorType::Body == m_pImpl->m_eType)
1023  {
1024  rUnoCursor.Move( fnMoveForward, GoInDoc );
1025  }
1026  else if ( (CursorType::Frame == m_pImpl->m_eType)
1027  || (CursorType::TableText == m_pImpl->m_eType)
1028  || (CursorType::Header == m_pImpl->m_eType)
1029  || (CursorType::Footer == m_pImpl->m_eType)
1030  || (CursorType::Footnote== m_pImpl->m_eType)
1031  || (CursorType::Redline == m_pImpl->m_eType))
1032  {
1033  rUnoCursor.MoveSection( GoCurrSection, fnSectionEnd);
1034  }
1035  else if (CursorType::Meta == m_pImpl->m_eType)
1036  {
1037  lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText, META_INIT_END);
1038  }
1039 }
1040 
1041 void SAL_CALL
1043  const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand)
1044 {
1045  SolarMutexGuard aGuard;
1046 
1047  if (!xRange.is())
1048  {
1049  throw uno::RuntimeException();
1050  }
1051 
1052  SwUnoCursor & rOwnCursor( m_pImpl->GetCursorOrThrow() );
1053 
1054  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
1055  SwXTextRange* pRange = nullptr;
1056  OTextCursorHelper* pCursor = nullptr;
1057  if(xRangeTunnel.is())
1058  {
1059  pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
1060  pCursor =
1061  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
1062  }
1063 
1064  if (!pRange && !pCursor)
1065  {
1066  throw uno::RuntimeException();
1067  }
1068 
1069  SwPaM aPam(GetDoc()->GetNodes());
1070  const SwPaM * pPam(nullptr);
1071  if (pCursor)
1072  {
1073  pPam = pCursor->GetPaM();
1074  }
1075  else if (pRange)
1076  {
1077  if (pRange->GetPositions(aPam))
1078  {
1079  pPam = & aPam;
1080  }
1081  }
1082 
1083  if (!pPam)
1084  {
1085  throw uno::RuntimeException();
1086  }
1087 
1088  {
1089  SwStartNodeType eSearchNodeType = SwNormalStartNode;
1090  switch (m_pImpl->m_eType)
1091  {
1092  case CursorType::Frame: eSearchNodeType = SwFlyStartNode; break;
1093  case CursorType::TableText: eSearchNodeType = SwTableBoxStartNode; break;
1094  case CursorType::Footnote: eSearchNodeType = SwFootnoteStartNode; break;
1095  case CursorType::Header: eSearchNodeType = SwHeaderStartNode; break;
1096  case CursorType::Footer: eSearchNodeType = SwFooterStartNode; break;
1097  //case CURSOR_INVALID:
1098  //case CursorType::Body:
1099  default:
1100  ;
1101  }
1102 
1103  const SwStartNode* pOwnStartNode = rOwnCursor.GetNode().FindSttNodeByType(eSearchNodeType);
1104  while ( pOwnStartNode != nullptr
1105  && pOwnStartNode->IsSectionNode())
1106  {
1107  pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1108  }
1109 
1110  const SwStartNode* pTmp =
1111  pPam->GetNode().FindSttNodeByType(eSearchNodeType);
1112  while ( pTmp != nullptr
1113  && pTmp->IsSectionNode() )
1114  {
1115  pTmp = pTmp->StartOfSectionNode();
1116  }
1117 
1118  if ( eSearchNodeType == SwTableBoxStartNode )
1119  {
1120  if (!pOwnStartNode || !pTmp)
1121  {
1122  throw uno::RuntimeException();
1123  }
1124 
1125  if ( pOwnStartNode->FindTableNode() != pTmp->FindTableNode() )
1126  {
1127  throw uno::RuntimeException();
1128  }
1129  }
1130  else
1131  {
1132  if ( pOwnStartNode != pTmp )
1133  {
1134  throw uno::RuntimeException();
1135  }
1136  }
1137  }
1138 
1139  if (CursorType::Meta == m_pImpl->m_eType)
1140  {
1141  SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint());
1142  const bool bNotForced( lcl_ForceIntoMeta(
1143  CopyPam, m_pImpl->m_xParentText, META_CHECK_BOTH) );
1144  if (!bNotForced)
1145  {
1146  throw uno::RuntimeException(
1147  "gotoRange: parameter range not contained in nesting"
1148  " text content for which this cursor was created",
1149  static_cast<text::XWordCursor*>(this));
1150  }
1151  }
1152 
1153  // selection has to be expanded here
1154  if(bExpand)
1155  {
1156  // cursor should include its previous range plus the given range
1157  const SwPosition aOwnLeft(*rOwnCursor.Start());
1158  const SwPosition aOwnRight(*rOwnCursor.End());
1159  SwPosition const& rParamLeft = *pPam->Start();
1160  SwPosition const& rParamRight = *pPam->End();
1161 
1162  // now there are four SwPositions,
1163  // two of them are going to be used, but which ones?
1164  if (aOwnRight > rParamRight)
1165  *rOwnCursor.GetPoint() = aOwnRight;
1166  else
1167  *rOwnCursor.GetPoint() = rParamRight;
1168  rOwnCursor.SetMark();
1169  if (aOwnLeft < rParamLeft)
1170  *rOwnCursor.GetMark() = aOwnLeft;
1171  else
1172  *rOwnCursor.GetMark() = rParamLeft;
1173  }
1174  else
1175  {
1176  // cursor should be the given range
1177  *rOwnCursor.GetPoint() = *pPam->GetPoint();
1178  if (pPam->HasMark())
1179  {
1180  rOwnCursor.SetMark();
1181  *rOwnCursor.GetMark() = *pPam->GetMark();
1182  }
1183  else
1184  {
1185  rOwnCursor.DeleteMark();
1186  }
1187  }
1188 }
1189 
1191 {
1192  SolarMutexGuard aGuard;
1193 
1194  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1195 
1196  const bool bRet =
1197  rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD );
1198  return bRet;
1199 }
1200 
1202 {
1203  SolarMutexGuard aGuard;
1204 
1205  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1206 
1207  const bool bRet =
1208  rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD );
1209  return bRet;
1210 }
1211 
1212 sal_Bool SAL_CALL
1214 {
1215  SolarMutexGuard aGuard;
1216 
1217  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1218 
1219  // problems arise when a paragraph starts with something other than a word
1220  bool bRet = false;
1221  // remember old position to check if cursor has moved
1222  // since the called functions are sometimes a bit unreliable
1223  // in specific cases...
1224  SwPosition *const pPoint = rUnoCursor.GetPoint();
1225  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1226  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1227 
1228  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1229  // end of paragraph
1230  if (rUnoCursor.GetContentNode() &&
1231  (pPoint->nContent == rUnoCursor.GetContentNode()->Len()))
1232  {
1233  rUnoCursor.Right(1);
1234  }
1235  else
1236  {
1237  const bool bTmp =
1238  rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
1239  // if there is no next word within the current paragraph
1240  // try to go to the start of the next paragraph
1241  if (!bTmp)
1242  {
1243  rUnoCursor.MovePara(GoNextPara, fnParaStart);
1244  }
1245  }
1246 
1247  // return true if cursor has moved
1248  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1249  (pPoint->nContent.GetIndex() != nOldIndex);
1250  if (bRet && (CursorType::Meta == m_pImpl->m_eType))
1251  {
1252  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1253  META_CHECK_BOTH);
1254  }
1255 
1256  return bRet;
1257 }
1258 
1259 sal_Bool SAL_CALL
1261 {
1262  SolarMutexGuard aGuard;
1263 
1264  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1265 
1266  // white spaces create problems on the paragraph start
1267  bool bRet = false;
1268  SwPosition *const pPoint = rUnoCursor.GetPoint();
1269  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1270  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1271 
1272  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1273  // start of paragraph?
1274  if (pPoint->nContent == 0)
1275  {
1276  rUnoCursor.Left(1);
1277  }
1278  else
1279  {
1280  rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
1281  if (pPoint->nContent == 0)
1282  {
1283  rUnoCursor.Left(1);
1284  }
1285  }
1286 
1287  // return true if cursor has moved
1288  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1289  (pPoint->nContent.GetIndex() != nOldIndex);
1290  if (bRet && (CursorType::Meta == m_pImpl->m_eType))
1291  {
1292  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1293  META_CHECK_BOTH);
1294  }
1295 
1296  return bRet;
1297 }
1298 
1299 sal_Bool SAL_CALL
1301 {
1302  SolarMutexGuard aGuard;
1303 
1304  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1305 
1306  bool bRet = false;
1307  SwPosition *const pPoint = rUnoCursor.GetPoint();
1308  SwNode & rOldNode = pPoint->nNode.GetNode();
1309  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1310 
1311  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1312  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1313  if (!rUnoCursor.IsEndWordWT( nWordType ))
1314  {
1315  rUnoCursor.GoEndWordWT( nWordType );
1316  }
1317 
1318  // restore old cursor if we are not at the end of a word by now
1319  // otherwise use current one
1320  bRet = rUnoCursor.IsEndWordWT( nWordType );
1321  if (!bRet)
1322  {
1323  pPoint->nNode = rOldNode;
1324  pPoint->nContent = nOldIndex;
1325  }
1326  else if (CursorType::Meta == m_pImpl->m_eType)
1327  {
1328  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1329  META_CHECK_BOTH);
1330  }
1331 
1332  return bRet;
1333 }
1334 
1335 sal_Bool SAL_CALL
1337 {
1338  SolarMutexGuard aGuard;
1339 
1340  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1341 
1342  bool bRet = false;
1343  SwPosition *const pPoint = rUnoCursor.GetPoint();
1344  SwNode & rOldNode = pPoint->nNode.GetNode();
1345  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1346 
1347  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1348  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1349  if (!rUnoCursor.IsStartWordWT( nWordType ))
1350  {
1351  rUnoCursor.GoStartWordWT( nWordType );
1352  }
1353 
1354  // restore old cursor if we are not at the start of a word by now
1355  // otherwise use current one
1356  bRet = rUnoCursor.IsStartWordWT( nWordType );
1357  if (!bRet)
1358  {
1359  pPoint->nNode = rOldNode;
1360  pPoint->nContent = nOldIndex;
1361  }
1362  else if (CursorType::Meta == m_pImpl->m_eType)
1363  {
1364  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1365  META_CHECK_BOTH);
1366  }
1367 
1368  return bRet;
1369 }
1370 
1371 sal_Bool SAL_CALL
1373 {
1374  SolarMutexGuard aGuard;
1375 
1376  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1377 
1378  // start of paragraph?
1379  bool bRet = rUnoCursor.GetPoint()->nContent == 0;
1380  // with mark ->no sentence start
1381  // (check if cursor is no selection, i.e. it does not have
1382  // a mark or else point and mark are identical)
1383  if (!bRet && (!rUnoCursor.HasMark() ||
1384  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1385  {
1386  SwCursor aCursor(*rUnoCursor.GetPoint(),nullptr);
1387  SwPosition aOrigPos = *aCursor.GetPoint();
1388  aCursor.GoSentence(SwCursor::START_SENT );
1389  bRet = aOrigPos == *aCursor.GetPoint();
1390  }
1391  return bRet;
1392 }
1393 
1394 sal_Bool SAL_CALL
1396 {
1397  SolarMutexGuard aGuard;
1398 
1399  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1400 
1401  // end of paragraph?
1402  bool bRet = rUnoCursor.GetContentNode() &&
1403  (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetContentNode()->Len());
1404  // with mark->no sentence end
1405  // (check if cursor is no selection, i.e. it does not have
1406  // a mark or else point and mark are identical)
1407  if (!bRet && (!rUnoCursor.HasMark() ||
1408  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1409  {
1410  SwCursor aCursor(*rUnoCursor.GetPoint(), nullptr);
1411  SwPosition aOrigPos = *aCursor.GetPoint();
1412  aCursor.GoSentence(SwCursor::END_SENT);
1413  bRet = aOrigPos == *aCursor.GetPoint();
1414  }
1415  return bRet;
1416 }
1417 
1418 sal_Bool SAL_CALL
1420 {
1421  SolarMutexGuard aGuard;
1422 
1423  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1424 
1425  const bool bWasEOS = isEndOfSentence();
1426  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1427  bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT);
1428  if (!bRet)
1429  {
1430  bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1431  }
1432 
1433  // if at the end of the sentence (i.e. at the space after the '.')
1434  // advance to next word in order for GoSentence to work properly
1435  // next time and have isStartOfSentence return true after this call
1436  if (!rUnoCursor.IsStartWordWT(css::i18n::WordType::ANYWORD_IGNOREWHITESPACES))
1437  {
1438  const bool bNextWord = rUnoCursor.GoNextWordWT(i18n::WordType::ANYWORD_IGNOREWHITESPACES);
1439  if (bWasEOS && !bNextWord)
1440  {
1441  bRet = false;
1442  }
1443  }
1444  if (CursorType::Meta == m_pImpl->m_eType)
1445  {
1446  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1448  && bRet;
1449  }
1450  return bRet;
1451 }
1452 
1453 sal_Bool SAL_CALL
1455 {
1456  SolarMutexGuard aGuard;
1457 
1458  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1459 
1460  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1461  bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1462  if (!bRet)
1463  {
1464  bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1465  if (bRet)
1466  {
1467  rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1468  // at the end of a paragraph move to the sentence end again
1469  rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1470  }
1471  }
1472  if (CursorType::Meta == m_pImpl->m_eType)
1473  {
1474  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1476  && bRet;
1477  }
1478  return bRet;
1479 }
1480 
1481 sal_Bool SAL_CALL
1483 {
1484  SolarMutexGuard aGuard;
1485 
1486  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1487 
1488  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1489  // if we're at the para start then we won't move
1490  // but bRet is also true if GoSentence failed but
1491  // the start of the sentence is reached
1492  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor)
1493  || rUnoCursor.GoSentence(SwCursor::START_SENT)
1494  || SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1495  if (CursorType::Meta == m_pImpl->m_eType)
1496  {
1497  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1499  && bRet;
1500  }
1501  return bRet;
1502 }
1503 
1504 sal_Bool SAL_CALL
1506 {
1507  SolarMutexGuard aGuard;
1508 
1509  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1510 
1511  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1512  // bRet is true if GoSentence() succeeded or if the
1513  // MovePara() succeeded while the end of the para is
1514  // not reached already
1515  bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1516  bool bRet = !bAlreadyParaEnd
1517  && (rUnoCursor.GoSentence(SwCursor::END_SENT)
1518  || rUnoCursor.MovePara(GoCurrPara, fnParaEnd));
1519  if (CursorType::Meta == m_pImpl->m_eType)
1520  {
1521  bRet = lcl_ForceIntoMeta(rUnoCursor, m_pImpl->m_xParentText,
1523  && bRet;
1524  }
1525  return bRet;
1526 }
1527 
1528 sal_Bool SAL_CALL
1530 {
1531  SolarMutexGuard aGuard;
1532 
1533  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1534 
1535  const bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1536  return bRet;
1537 }
1538 
1539 sal_Bool SAL_CALL
1541 {
1542  SolarMutexGuard aGuard;
1543 
1544  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1545 
1546  const bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1547  return bRet;
1548 }
1549 
1550 sal_Bool SAL_CALL
1552 {
1553  SolarMutexGuard aGuard;
1554 
1555  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1556 
1557  if (CursorType::Meta == m_pImpl->m_eType)
1558  {
1559  return false;
1560  }
1561  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1562  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1563  if (!bRet)
1564  {
1565  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaStart);
1566  }
1567 
1568  // since MovePara(GoCurrPara, fnParaStart) only returns false
1569  // if we were already at the start of the paragraph this function
1570  // should always complete successfully.
1571  OSL_ENSURE( bRet, "gotoStartOfParagraph failed" );
1572  return bRet;
1573 }
1574 
1575 sal_Bool SAL_CALL
1577 {
1578  SolarMutexGuard aGuard;
1579 
1580  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1581 
1582  if (CursorType::Meta == m_pImpl->m_eType)
1583  {
1584  return false;
1585  }
1586  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1587  bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1588  if (!bRet)
1589  {
1590  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1591  }
1592 
1593  // since MovePara(GoCurrPara, fnParaEnd) only returns false
1594  // if we were already at the end of the paragraph this function
1595  // should always complete successfully.
1596  OSL_ENSURE( bRet, "gotoEndOfParagraph failed" );
1597  return bRet;
1598 }
1599 
1600 sal_Bool SAL_CALL
1602 {
1603  SolarMutexGuard aGuard;
1604 
1605  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1606 
1607  if (CursorType::Meta == m_pImpl->m_eType)
1608  {
1609  return false;
1610  }
1611  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1612  const bool bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1613  return bRet;
1614 }
1615 
1616 sal_Bool SAL_CALL
1618 {
1619  SolarMutexGuard aGuard;
1620 
1621  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1622 
1623  if (CursorType::Meta == m_pImpl->m_eType)
1624  {
1625  return false;
1626  }
1627  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1628  const bool bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1629  return bRet;
1630 }
1631 
1632 uno::Reference< text::XText > SAL_CALL
1634 {
1635  SolarMutexGuard g;
1636 
1637  return m_pImpl->m_xParentText;
1638 }
1639 
1640 uno::Reference< text::XTextRange > SAL_CALL
1642 {
1643  SolarMutexGuard aGuard;
1644 
1645  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1646 
1647  uno::Reference< text::XTextRange > xRet;
1648  SwPaM aPam(*rUnoCursor.Start());
1649  const uno::Reference< text::XText > xParent = getText();
1650  if (CursorType::Meta == m_pImpl->m_eType)
1651  {
1652  // return cursor to prevent modifying SwXTextRange for META
1653  SwXTextCursor * const pXCursor(
1654  new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1655  *rUnoCursor.GetPoint()) );
1656  pXCursor->gotoStart(false);
1657  xRet = static_cast<text::XWordCursor*>(pXCursor);
1658  }
1659  else
1660  {
1661  xRet = new SwXTextRange(aPam, xParent);
1662  }
1663  return xRet;
1664 }
1665 
1666 uno::Reference< text::XTextRange > SAL_CALL
1668 {
1669  SolarMutexGuard aGuard;
1670 
1671  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1672 
1673  uno::Reference< text::XTextRange > xRet;
1674  SwPaM aPam(*rUnoCursor.End());
1675  const uno::Reference< text::XText > xParent = getText();
1676  if (CursorType::Meta == m_pImpl->m_eType)
1677  {
1678  // return cursor to prevent modifying SwXTextRange for META
1679  SwXTextCursor * const pXCursor(
1680  new SwXTextCursor(*rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1681  *rUnoCursor.GetPoint()) );
1682  pXCursor->gotoEnd(false);
1683  xRet = static_cast<text::XWordCursor*>(pXCursor);
1684  }
1685  else
1686  {
1687  xRet = new SwXTextRange(aPam, xParent);
1688  }
1689  return xRet;
1690 }
1691 
1692 OUString SAL_CALL SwXTextCursor::getString()
1693 {
1694  SolarMutexGuard aGuard;
1695 
1696  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
1697 
1698  OUString aText;
1699  SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aText);
1700  return aText;
1701 }
1702 
1703 void SAL_CALL
1704 SwXTextCursor::setString(const OUString& aString)
1705 {
1706  SolarMutexGuard aGuard;
1707 
1708  m_pImpl->GetCursorOrThrow(); // just to check if valid
1709 
1710  const bool bForceExpandHints( (CursorType::Meta == m_pImpl->m_eType)
1711  && dynamic_cast<SwXMeta*>(m_pImpl->m_xParentText.get())
1712  ->CheckForOwnMemberMeta(*GetPaM(), true) );
1713  DeleteAndInsert(aString, bForceExpandHints);
1714 }
1715 
1717  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1718  const OUString& rPropertyName)
1719 {
1720  uno::Any aAny;
1721  SfxItemPropertySimpleEntry const*const pEntry =
1722  rPropSet.getPropertyMap().getByName(rPropertyName);
1723 
1724  if (!pEntry)
1725  {
1726  throw beans::UnknownPropertyException(
1727  "Unknown property: " + rPropertyName,
1728  static_cast<cppu::OWeakObject *>(nullptr));
1729  }
1730 
1731  beans::PropertyState eTemp;
1732  const bool bDone = SwUnoCursorHelper::getCursorPropertyValue(
1733  *pEntry, rPaM, &aAny, eTemp );
1734 
1735  if (!bDone)
1736  {
1737  SfxItemSet aSet(
1738  rPaM.GetDoc()->GetAttrPool(),
1739  svl::Items<
1741  RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER>{});
1743 
1744  rPropSet.getPropertyValue(*pEntry, aSet, aAny);
1745  }
1746 
1747  return aAny;
1748 }
1749 
1751  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1752  const OUString& rPropertyName,
1753  const uno::Any& rValue,
1754  const SetAttrMode nAttrMode)
1755 {
1756  uno::Sequence< beans::PropertyValue > aValues(1);
1757  aValues[0].Name = rPropertyName;
1758  aValues[0].Value = rValue;
1759  SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode);
1760 }
1761 
1762 // FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
1763 // SwUnoCursorHelper::SetTextFormatColl, instead of extending item set.
1764 // We need to get them from nodes in next call to GetCursorAttr.
1765 // The rest could cause similar problems in theory, so we just list them here.
1766 static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
1767 {
1768  return nWID == FN_UNO_PARA_STYLE ||
1769  nWID == FN_UNO_CHARFMT_SEQUENCE ||
1770  nWID == FN_UNO_NUM_START_VALUE ||
1771  nWID == FN_UNO_NUM_RULES;
1772 }
1773 
1775  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1776  const uno::Sequence< beans::PropertyValue > &rPropertyValues,
1777  const SetAttrMode nAttrMode)
1778 {
1779  if (!rPropertyValues.hasElements())
1780  return;
1781 
1782  SwDoc *const pDoc = rPaM.GetDoc();
1783  OUString aUnknownExMsg, aPropertyVetoExMsg;
1784 
1785  // Build set of attributes we want to fetch
1786  std::vector<sal_uInt16> aWhichPairs;
1787  std::vector<SfxItemPropertySimpleEntry const*> aEntries;
1788  aEntries.reserve(rPropertyValues.getLength());
1789  for (const auto& rPropVal : rPropertyValues)
1790  {
1791  const OUString &rPropertyName = rPropVal.Name;
1792 
1793  SfxItemPropertySimpleEntry const* pEntry =
1794  rPropSet.getPropertyMap().getByName(rPropertyName);
1795 
1796  // Queue up any exceptions until the end ...
1797  if (!pEntry)
1798  {
1799  aUnknownExMsg += "Unknown property: '" + rPropertyName + "' ";
1800  break;
1801  }
1802  else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1803  {
1804  aPropertyVetoExMsg += "Property is read-only: '" + rPropertyName + "' ";
1805  break;
1806  } else {
1807 // FIXME: we should have some nice way of merging ranges surely ?
1808  aWhichPairs.push_back(pEntry->nWID);
1809  aWhichPairs.push_back(pEntry->nWID);
1810  }
1811  aEntries.push_back(pEntry);
1812  }
1813 
1814  if (!aWhichPairs.empty())
1815  {
1816  aWhichPairs.push_back(0); // terminate
1817  SfxItemSet aItemSet(pDoc->GetAttrPool(), aWhichPairs.data());
1818 
1819  // Fetch, overwrite, and re-set the attributes from the core
1820 
1821  bool bPreviousPropertyCausesSideEffectsInNodes = false;
1822  for (size_t i = 0; i < aEntries.size(); ++i)
1823  {
1824  SfxItemPropertySimpleEntry const*const pEntry = aEntries[i];
1825  bool bPropertyCausesSideEffectsInNodes =
1827 
1828  // we need to get up-to-date item set from nodes
1829  if (i == 0 || bPreviousPropertyCausesSideEffectsInNodes)
1830  {
1831  aItemSet.ClearItem();
1832  SwUnoCursorHelper::GetCursorAttr(rPaM, aItemSet);
1833  }
1834 
1835  const uno::Any &rValue = rPropertyValues[i].Value;
1836  // this can set some attributes in nodes' mpAttrSet
1837  if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet))
1838  rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
1839 
1840  if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
1841  SwUnoCursorHelper::SetCursorAttr(rPaM, aItemSet, nAttrMode, false/*bTableMode*/);
1842 
1843  bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
1844  }
1845  }
1846 
1847  if (!aUnknownExMsg.isEmpty())
1848  throw beans::UnknownPropertyException(aUnknownExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1849  if (!aPropertyVetoExMsg.isEmpty())
1850  throw beans::PropertyVetoException(aPropertyVetoExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1851 }
1852 
1853 namespace
1854 {
1855  bool NotInRange(sal_uInt16 nWID, sal_uInt16 nStart, sal_uInt16 nEnd)
1856  {
1857  return nWID < nStart || nWID > nEnd;
1858  }
1859 }
1860 
1861 uno::Sequence< beans::PropertyState >
1863  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1864  const uno::Sequence< OUString >& rPropertyNames,
1865  const SwGetPropertyStatesCaller eCaller)
1866 {
1867  const OUString* pNames = rPropertyNames.getConstArray();
1868  uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
1869  beans::PropertyState* pStates = aRet.getArray();
1870  const SfxItemPropertyMap &rMap = rPropSet.getPropertyMap();
1871  std::unique_ptr<SfxItemSet> pSet;
1872  std::unique_ptr<SfxItemSet> pSetParent;
1873 
1874  for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++)
1875  {
1876  SfxItemPropertySimpleEntry const*const pEntry =
1877  rMap.getByName( pNames[i] );
1878  if(!pEntry)
1879  {
1880  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
1881  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
1882  {
1883  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1884  continue;
1885  }
1887  eCaller)
1888  {
1889  //this values marks the element as unknown property
1890  pStates[i] = beans::PropertyState::PropertyState_MAKE_FIXED_SIZE;
1891  continue;
1892  }
1893  else
1894  {
1895  throw beans::UnknownPropertyException(
1896  "Unknown property: " + pNames[i],
1897  static_cast<cppu::OWeakObject *>(nullptr));
1898  }
1899  }
1900  if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) ||
1902  NotInRange(pEntry->nWID, FN_UNO_RANGE_BEGIN, FN_UNO_RANGE_END) &&
1903  NotInRange(pEntry->nWID, RES_CHRATR_BEGIN, RES_TXTATR_END) )
1904  {
1905  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1906  }
1907  else
1908  {
1909  if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN &&
1910  pEntry->nWID <= FN_UNO_RANGE_END )
1911  {
1913  *pEntry, rPaM, nullptr, pStates[i] );
1914  }
1915  else
1916  {
1917  if (!pSet)
1918  {
1919  switch ( eCaller )
1920  {
1923  pSet.reset(
1924  new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
1926  break;
1928  pSet.reset(
1929  new SfxItemSet( rPaM.GetDoc()->GetAttrPool(),
1930  {{pEntry->nWID, pEntry->nWID}} ));
1931  break;
1932  default:
1933  pSet.reset( new SfxItemSet(
1934  rPaM.GetDoc()->GetAttrPool(),
1935  svl::Items<
1938  RES_UNKNOWNATR_CONTAINER>{}));
1939  }
1940  // #i63870#
1941  SwUnoCursorHelper::GetCursorAttr( rPaM, *pSet );
1942  }
1943 
1944  pStates[i] = ( pSet->Count() )
1945  ? rPropSet.getPropertyState( *pEntry, *pSet )
1946  : beans::PropertyState_DEFAULT_VALUE;
1947 
1948  //try again to find out if a value has been inherited
1949  if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
1950  {
1951  if (!pSetParent)
1952  {
1953  pSetParent = pSet->Clone( false );
1954  // #i63870#
1956  rPaM, *pSetParent, true, false );
1957  }
1958 
1959  pStates[i] = ( pSetParent->Count() )
1960  ? rPropSet.getPropertyState( *pEntry, *pSetParent )
1961  : beans::PropertyState_DEFAULT_VALUE;
1962  }
1963  }
1964  }
1965  }
1966  return aRet;
1967 }
1968 
1970  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1971  const OUString& rPropertyName)
1972 {
1973  uno::Sequence< OUString > aStrings { rPropertyName };
1974  uno::Sequence< beans::PropertyState > aSeq =
1975  GetPropertyStates(rPaM, rPropSet, aStrings,
1977  return aSeq[0];
1978 }
1979 
1980 static void
1982  std::set<sal_uInt16> const &rWhichIds )
1983 {
1984  // if we are resetting paragraph attributes, we need to select the full paragraph first
1985  SwPosition aStart = *rPaM.Start();
1986  SwPosition aEnd = *rPaM.End();
1987  auto pTemp ( rDoc.CreateUnoCursor(aStart) );
1989  {
1990  pTemp->MovePara(GoCurrPara, fnParaStart);
1991  }
1992  pTemp->SetMark();
1993  *pTemp->GetPoint() = aEnd;
1994  SwUnoCursorHelper::SelectPam(*pTemp, true);
1995  if(!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1996  {
1997  pTemp->MovePara(GoCurrPara, fnParaEnd);
1998  }
1999  rDoc.ResetAttrs(*pTemp, true, rWhichIds);
2000 }
2001 
2003  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
2004  const OUString& rPropertyName)
2005 {
2006  SwDoc & rDoc = *rPaM.GetDoc();
2007  SfxItemPropertySimpleEntry const*const pEntry =
2008  rPropSet.getPropertyMap().getByName(rPropertyName);
2009  if (!pEntry)
2010  {
2011  throw beans::UnknownPropertyException(
2012  "Unknown property: " + rPropertyName,
2013  static_cast<cppu::OWeakObject *>(nullptr));
2014  }
2015 
2016  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2017  {
2018  throw uno::RuntimeException(
2019  "setPropertyToDefault: property is read-only: "
2020  + rPropertyName, nullptr);
2021  }
2022 
2023  if (pEntry->nWID < RES_FRMATR_END)
2024  {
2025  std::set<sal_uInt16> aWhichIds;
2026  aWhichIds.insert( pEntry->nWID );
2027  if (pEntry->nWID < RES_PARATR_BEGIN)
2028  {
2029  rDoc.ResetAttrs(rPaM, true, aWhichIds);
2030  }
2031  else
2032  {
2033  lcl_SelectParaAndReset ( rPaM, rDoc, aWhichIds );
2034  }
2035  }
2036  else
2037  {
2039  }
2040 }
2041 
2043  SwPaM const & rPaM, const SfxItemPropertySet& rPropSet,
2044  const OUString& rPropertyName)
2045 {
2046  SfxItemPropertySimpleEntry const*const pEntry =
2047  rPropSet.getPropertyMap().getByName(rPropertyName);
2048  if (!pEntry)
2049  {
2050  throw beans::UnknownPropertyException(
2051  "Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject *>(nullptr));
2052  }
2053 
2054  uno::Any aRet;
2055  if (pEntry->nWID < RES_FRMATR_END)
2056  {
2057  SwDoc & rDoc = *rPaM.GetDoc();
2058  const SfxPoolItem& rDefItem =
2059  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2060  rDefItem.QueryValue(aRet, pEntry->nMemberId);
2061  }
2062  return aRet;
2063 }
2064 
2065 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2067 {
2068  SolarMutexGuard g;
2069 
2070  static uno::Reference< beans::XPropertySetInfo > xRef = [&]()
2071  {
2072  static SfxItemPropertyMapEntry const aCursorExtMap_Impl[] =
2073  {
2076  { OUString(), 0, css::uno::Type(), 0, 0 }
2077  };
2078  const uno::Reference< beans::XPropertySetInfo > xInfo =
2079  m_pImpl->m_rPropSet.getPropertySetInfo();
2080  // extend PropertySetInfo!
2081  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2082  return new SfxExtItemPropertySetInfo(
2083  aCursorExtMap_Impl,
2084  aPropSeq );
2085  }();
2086  return xRef;
2087 }
2088 
2089 void SAL_CALL
2091  const OUString& rPropertyName, const uno::Any& rValue)
2092 {
2093  SolarMutexGuard aGuard;
2094 
2095  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2096 
2097  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2098  {
2099  bool bSet(false);
2100  if (!(rValue >>= bSet))
2101  {
2102  throw lang::IllegalArgumentException();
2103  }
2104  rUnoCursor.SetSkipOverHiddenSections(bSet);
2105  }
2106  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2107  {
2108  bool bSet(false);
2109  if (!(rValue >>= bSet))
2110  {
2111  throw lang::IllegalArgumentException();
2112  }
2113  rUnoCursor.SetSkipOverProtectSections(bSet);
2114  }
2115  else
2116  {
2118  m_pImpl->m_rPropSet, rPropertyName, rValue);
2119  }
2120 }
2121 
2122 uno::Any SAL_CALL
2123 SwXTextCursor::getPropertyValue(const OUString& rPropertyName)
2124 {
2125  SolarMutexGuard aGuard;
2126 
2127  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2128 
2129  uno::Any aAny;
2130  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2131  {
2132  const bool bSet = rUnoCursor.IsSkipOverHiddenSections();
2133  aAny <<= bSet;
2134  }
2135  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2136  {
2137  const bool bSet = rUnoCursor.IsSkipOverProtectSections();
2138  aAny <<= bSet;
2139  }
2140  else
2141  {
2142  aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor,
2143  m_pImpl->m_rPropSet, rPropertyName);
2144  }
2145  return aAny;
2146 }
2147 
2148 void SAL_CALL
2150  const OUString& /*rPropertyName*/,
2151  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2152 {
2153  OSL_FAIL("SwXTextCursor::addPropertyChangeListener(): not implemented");
2154 }
2155 
2156 void SAL_CALL
2158  const OUString& /*rPropertyName*/,
2159  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2160 {
2161  OSL_FAIL("SwXTextCursor::removePropertyChangeListener(): not implemented");
2162 }
2163 
2164 void SAL_CALL
2166  const OUString& /*rPropertyName*/,
2167  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2168 {
2169  OSL_FAIL("SwXTextCursor::addVetoableChangeListener(): not implemented");
2170 }
2171 
2172 void SAL_CALL
2174  const OUString& /*rPropertyName*/,
2175  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2176 {
2177  OSL_FAIL("SwXTextCursor::removeVetoableChangeListener(): not implemented");
2178 }
2179 
2180 beans::PropertyState SAL_CALL
2181 SwXTextCursor::getPropertyState(const OUString& rPropertyName)
2182 {
2183  SolarMutexGuard aGuard;
2184 
2185  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2186 
2187  const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState(
2188  rUnoCursor, m_pImpl->m_rPropSet, rPropertyName);
2189  return eRet;
2190 }
2191 
2192 uno::Sequence< beans::PropertyState > SAL_CALL
2194  const uno::Sequence< OUString >& rPropertyNames)
2195 {
2196  SolarMutexGuard aGuard;
2197 
2198  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2199 
2201  rUnoCursor, m_pImpl->m_rPropSet, rPropertyNames);
2202 }
2203 
2204 void SAL_CALL
2205 SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName)
2206 {
2207  // forward: need no solar mutex here
2208  uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2209  setPropertiesToDefault ( aSequence );
2210 }
2211 
2212 uno::Any SAL_CALL
2213 SwXTextCursor::getPropertyDefault(const OUString& rPropertyName)
2214 {
2215  // forward: need no solar mutex here
2216  const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2217  return getPropertyDefaults ( aSequence ).getConstArray()[0];
2218 }
2219 
2221  const uno::Sequence< OUString >& aPropertyNames,
2222  const uno::Sequence< uno::Any >& aValues )
2223 {
2224  if( aValues.getLength() != aPropertyNames.getLength() )
2225  {
2226  OSL_FAIL( "mis-matched property value sequences" );
2227  throw lang::IllegalArgumentException();
2228  }
2229 
2230  SolarMutexGuard aGuard;
2231 
2232  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2233 
2234  // a little lame to have to copy into this.
2235  uno::Sequence< beans::PropertyValue > aPropertyValues( aValues.getLength() );
2236  for ( sal_Int32 i = 0; i < aPropertyNames.getLength(); i++ )
2237  {
2238  if ( aPropertyNames[ i ] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2239  aPropertyNames[ i ] == UNO_NAME_IS_SKIP_PROTECTED_TEXT )
2240  {
2241  // the behaviour of these is hard to model in a group
2242  OSL_FAIL("invalid property name for batch setting");
2243  throw lang::IllegalArgumentException();
2244  }
2245  aPropertyValues[ i ].Name = aPropertyNames[ i ];
2246  aPropertyValues[ i ].Value = aValues[ i ];
2247  }
2248  try
2249  {
2250  SwUnoCursorHelper::SetPropertyValues( rUnoCursor, m_pImpl->m_rPropSet, aPropertyValues );
2251  }
2252  catch (const css::beans::UnknownPropertyException& e)
2253  {
2255  throw lang::WrappedTargetException(
2256  "wrapped Exception " + e.Message,
2257  uno::Reference<uno::XInterface>(), a);
2258  }
2259 }
2260 
2261 uno::Sequence< uno::Any > SAL_CALL
2262 SwXTextCursor::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames )
2263 {
2264  // a banal implementation for now
2265  uno::Sequence< uno::Any > aValues( aPropertyNames.getLength() );
2266  std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.begin(),
2267  [this](const OUString& rName) -> uno::Any { return getPropertyValue( rName ); });
2268  return aValues;
2269 }
2270 
2272  const uno::Sequence< OUString >& /* aPropertyNames */,
2273  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2274 {
2275  OSL_FAIL("SwXTextCursor::addPropertiesChangeListener(): not implemented");
2276 }
2278  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2279 {
2280  OSL_FAIL("SwXTextCursor::removePropertiesChangeListener(): not implemented");
2281 }
2282 
2284  const uno::Sequence< OUString >& /* aPropertyNames */,
2285  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2286 {
2287  OSL_FAIL("SwXTextCursor::firePropertiesChangeEvent(): not implemented");
2288 }
2289 
2290 // para specific attribute ranges
2291 static sal_uInt16 g_ParaResetableSetRange[] = {
2296  0
2297 };
2298 
2299 // selection specific attribute ranges
2300 static sal_uInt16 g_ResetableSetRange[] = {
2306  0
2307 };
2308 
2309 static void
2310 lcl_EnumerateIds(sal_uInt16 const* pIdRange, std::set<sal_uInt16> &rWhichIds)
2311 {
2312  while (*pIdRange)
2313  {
2314  const sal_uInt16 nStart = *pIdRange++;
2315  const sal_uInt16 nEnd = *pIdRange++;
2316  for (sal_uInt16 nId = nStart + 1; nId <= nEnd; ++nId)
2317  {
2318  rWhichIds.insert( rWhichIds.end(), nId );
2319  }
2320  }
2321 }
2322 
2323 void SAL_CALL
2325 {
2326  SolarMutexGuard aGuard;
2327 
2328  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2329 
2330  std::set<sal_uInt16> aParaWhichIds;
2331  std::set<sal_uInt16> aWhichIds;
2332  lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds);
2333  lcl_EnumerateIds(g_ResetableSetRange, aWhichIds);
2334  if (!aParaWhichIds.empty())
2335  {
2336  lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(),
2337  aParaWhichIds);
2338  }
2339  if (!aWhichIds.empty())
2340  {
2341  rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, true, aWhichIds);
2342  }
2343 }
2344 
2345 void SAL_CALL
2347  const uno::Sequence< OUString >& rPropertyNames)
2348 {
2349  SolarMutexGuard aGuard;
2350 
2351  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2352 
2353  if ( rPropertyNames.hasElements() )
2354  {
2355  SwDoc & rDoc = *rUnoCursor.GetDoc();
2356  std::set<sal_uInt16> aWhichIds;
2357  std::set<sal_uInt16> aParaWhichIds;
2358  for (const OUString& rName : rPropertyNames)
2359  {
2360  SfxItemPropertySimpleEntry const*const pEntry =
2361  m_pImpl->m_rPropSet.getPropertyMap().getByName( rName );
2362  if (!pEntry)
2363  {
2364  if (rName == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2366  {
2367  continue;
2368  }
2369  throw beans::UnknownPropertyException(
2370  "Unknown property: " + rName,
2371  static_cast<cppu::OWeakObject *>(this));
2372  }
2373  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2374  {
2375  throw uno::RuntimeException(
2376  "setPropertiesToDefault: property is read-only: " + rName,
2377  static_cast<cppu::OWeakObject *>(this));
2378  }
2379 
2380  if (pEntry->nWID < RES_FRMATR_END)
2381  {
2382  if (pEntry->nWID < RES_PARATR_BEGIN)
2383  {
2384  aWhichIds.insert( pEntry->nWID );
2385  }
2386  else
2387  {
2388  aParaWhichIds.insert( pEntry->nWID );
2389  }
2390  }
2391  else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
2392  {
2393  SwUnoCursorHelper::resetCursorPropertyValue(*pEntry, rUnoCursor);
2394  }
2395  }
2396 
2397  if (!aParaWhichIds.empty())
2398  {
2399  lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
2400  }
2401  if (!aWhichIds.empty())
2402  {
2403  rDoc.ResetAttrs(rUnoCursor, true, aWhichIds);
2404  }
2405  }
2406 }
2407 
2408 uno::Sequence< uno::Any > SAL_CALL
2410  const uno::Sequence< OUString >& rPropertyNames)
2411 {
2412  SolarMutexGuard aGuard;
2413 
2414  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2415 
2416  const sal_Int32 nCount = rPropertyNames.getLength();
2417  uno::Sequence< uno::Any > aRet(nCount);
2418  if ( nCount )
2419  {
2420  SwDoc & rDoc = *rUnoCursor.GetDoc();
2421  const OUString *pNames = rPropertyNames.getConstArray();
2422  uno::Any *pAny = aRet.getArray();
2423  for (sal_Int32 i = 0; i < nCount; i++)
2424  {
2425  SfxItemPropertySimpleEntry const*const pEntry =
2426  m_pImpl->m_rPropSet.getPropertyMap().getByName( pNames[i] );
2427  if (!pEntry)
2428  {
2429  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2430  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2431  {
2432  continue;
2433  }
2434  throw beans::UnknownPropertyException(
2435  "Unknown property: " + pNames[i],
2436  static_cast<cppu::OWeakObject *>(nullptr));
2437  }
2438  if (pEntry->nWID < RES_FRMATR_END)
2439  {
2440  const SfxPoolItem& rDefItem =
2441  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2442  rDefItem.QueryValue(pAny[i], pEntry->nMemberId);
2443  }
2444  }
2445  }
2446  return aRet;
2447 }
2448 
2449 void SAL_CALL SwXTextCursor::invalidateMarkings(::sal_Int32 nType)
2450 {
2451  SolarMutexGuard aGuard;
2452 
2453  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2454 
2455  SwNode& node = rUnoCursor.GetNode();
2456 
2457  SwTextNode* txtNode = node.GetTextNode();
2458 
2459  if (txtNode == nullptr) return;
2460 
2461  if ( text::TextMarkupType::SPELLCHECK == nType )
2462  {
2464  txtNode->SetWrong(nullptr);
2465  }
2466  else if( text::TextMarkupType::PROOFREADING == nType )
2467  {
2468  txtNode->SetGrammarCheckDirty(true);
2469  txtNode->SetGrammarCheck(nullptr);
2470  }
2471  else if ( text::TextMarkupType::SMARTTAG == nType )
2472  {
2473  txtNode->SetSmartTagDirty(true);
2474  txtNode->SetSmartTags(nullptr);
2475  }
2476  else return;
2477 
2478  SwFormatColl* fmtColl=txtNode->GetFormatColl();
2479 
2480  if (fmtColl == nullptr) return;
2481 
2482  SwFormatChg aNew( fmtColl );
2483  txtNode->NotifyClients( nullptr, &aNew );
2484 }
2485 
2486 void SAL_CALL
2488  const OUString& rRedlineType,
2489  const uno::Sequence< beans::PropertyValue >& rRedlineProperties)
2490 {
2491  SolarMutexGuard aGuard;
2492 
2493  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2494 
2495  SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties);
2496 }
2497 
2498 void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL,
2499  const uno::Sequence< beans::PropertyValue >& rOptions)
2500 {
2501  SolarMutexGuard aGuard;
2502 
2503  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2504 
2505  SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions);
2506 }
2507 
2508 uno::Sequence< beans::PropertyValue >
2510 {
2511  uno::Sequence< beans::PropertyValue > aRet(5);
2512  beans::PropertyValue* pArray = aRet.getArray();
2513 
2514  uno::Any aVal;
2515  aVal <<= bFromTable;
2516  pArray[0] = beans::PropertyValue("IsSortInTable", -1, aVal,
2517  beans::PropertyState_DIRECT_VALUE);
2518 
2519  aVal <<= u' ';
2520  pArray[1] = beans::PropertyValue("Delimiter", -1, aVal,
2521  beans::PropertyState_DIRECT_VALUE);
2522 
2523  aVal <<= false;
2524  pArray[2] = beans::PropertyValue("IsSortColumns", -1, aVal,
2525  beans::PropertyState_DIRECT_VALUE);
2526 
2527  aVal <<= sal_Int32(3);
2528  pArray[3] = beans::PropertyValue("MaxSortFieldsCount", -1, aVal,
2529  beans::PropertyState_DIRECT_VALUE);
2530 
2531  uno::Sequence< table::TableSortField > aFields(3);
2532  table::TableSortField* pFields = aFields.getArray();
2533 
2534  lang::Locale aLang( SvtSysLocale().GetLanguageTag().getLocale());
2535  // get collator algorithm to be used for the locale
2536  uno::Sequence< OUString > aSeq(
2537  GetAppCollator().listCollatorAlgorithms( aLang ) );
2538  const bool bHasElements = aSeq.hasElements();
2539  OSL_ENSURE( bHasElements, "list of collator algorithms is empty!");
2540  OUString aCollAlg;
2541  if (bHasElements)
2542  {
2543  aCollAlg = aSeq.getConstArray()[0];
2544  }
2545 
2546  pFields[0].Field = 1;
2547  pFields[0].IsAscending = true;
2548  pFields[0].IsCaseSensitive = false;
2549  pFields[0].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2550  pFields[0].CollatorLocale = aLang;
2551  pFields[0].CollatorAlgorithm = aCollAlg;
2552 
2553  pFields[1].Field = 1;
2554  pFields[1].IsAscending = true;
2555  pFields[1].IsCaseSensitive = false;
2556  pFields[1].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2557  pFields[1].CollatorLocale = aLang;
2558  pFields[1].CollatorAlgorithm = aCollAlg;
2559 
2560  pFields[2].Field = 1;
2561  pFields[2].IsAscending = true;
2562  pFields[2].IsCaseSensitive = false;
2563  pFields[2].FieldType = table::TableSortFieldType_ALPHANUMERIC;
2564  pFields[2].CollatorLocale = aLang;
2565  pFields[2].CollatorAlgorithm = aCollAlg;
2566 
2567  aVal <<= aFields;
2568  pArray[4] = beans::PropertyValue("SortFields", -1, aVal,
2569  beans::PropertyState_DIRECT_VALUE);
2570 
2571  return aRet;
2572 }
2573 
2574 uno::Sequence< beans::PropertyValue > SAL_CALL
2576 {
2577  SolarMutexGuard aGuard;
2578 
2580 }
2581 
2583  const uno::Sequence< beans::PropertyValue >& rDescriptor,
2584  SwSortOptions& rSortOpt)
2585 {
2586  bool bRet = true;
2587 
2588  rSortOpt.bTable = false;
2589  rSortOpt.cDeli = ' ';
2590  rSortOpt.eDirection = SRT_COLUMNS;
2591 
2592  std::unique_ptr<SwSortKey> pKey1(new SwSortKey);
2593  pKey1->nColumnId = USHRT_MAX;
2594  pKey1->bIsNumeric = true;
2595  pKey1->eSortOrder = SRT_ASCENDING;
2596 
2597  std::unique_ptr<SwSortKey> pKey2(new SwSortKey);
2598  pKey2->nColumnId = USHRT_MAX;
2599  pKey2->bIsNumeric = true;
2600  pKey2->eSortOrder = SRT_ASCENDING;
2601 
2602  std::unique_ptr<SwSortKey> pKey3(new SwSortKey);
2603  pKey3->nColumnId = USHRT_MAX;
2604  pKey3->bIsNumeric = true;
2605  pKey3->eSortOrder = SRT_ASCENDING;
2606  SwSortKey* aKeys[3] = {pKey1.get(), pKey2.get(), pKey3.get()};
2607 
2608  bool bOldSortdescriptor(false);
2609  bool bNewSortdescriptor(false);
2610 
2611  for (const beans::PropertyValue& rProperty : rDescriptor)
2612  {
2613  uno::Any aValue( rProperty.Value );
2614  const OUString& rPropName = rProperty.Name;
2615 
2616  // old and new sortdescriptor
2617  if ( rPropName == "IsSortInTable" )
2618  {
2619  if (auto b = o3tl::tryAccess<bool>(aValue))
2620  {
2621  rSortOpt.bTable = *b;
2622  }
2623  else
2624  {
2625  bRet = false;
2626  }
2627  }
2628  else if ( rPropName == "Delimiter" )
2629  {
2630  sal_Unicode uChar;
2631  sal_uInt16 nChar;
2632  if (aValue >>= uChar)
2633  {
2634  rSortOpt.cDeli = uChar;
2635  }
2636  else if (aValue >>= nChar)
2637  {
2638  // For compatibility with BASIC, also accept an ANY containing
2639  // an UNSIGNED SHORT:
2640  rSortOpt.cDeli = nChar;
2641  }
2642  else
2643  {
2644  bRet = false;
2645  }
2646  }
2647  // old sortdescriptor
2648  else if ( rPropName == "SortColumns" )
2649  {
2650  bOldSortdescriptor = true;
2651  bool bTemp(false);
2652  if (aValue >>= bTemp)
2653  {
2654  rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS;
2655  }
2656  else
2657  {
2658  bRet = false;
2659  }
2660  }
2661  else if ( rPropName == "IsCaseSensitive" )
2662  {
2663  bOldSortdescriptor = true;
2664  bool bTemp(false);
2665  if (aValue >>= bTemp)
2666  {
2667  rSortOpt.bIgnoreCase = !bTemp;
2668  }
2669  else
2670  {
2671  bRet = false;
2672  }
2673  }
2674  else if ( rPropName == "CollatorLocale" )
2675  {
2676  bOldSortdescriptor = true;
2677  lang::Locale aLocale;
2678  if (aValue >>= aLocale)
2679  {
2680  rSortOpt.nLanguage = LanguageTag::convertToLanguageType( aLocale);
2681  }
2682  else
2683  {
2684  bRet = false;
2685  }
2686  }
2687  else if (rPropName.startsWith("CollatorAlgorithm") &&
2688  rPropName.getLength() == 18 &&
2689  (rPropName[17] >= '0' && rPropName[17] <= '9'))
2690  {
2691  bOldSortdescriptor = true;
2692  sal_uInt16 nIndex = rPropName[17];
2693  nIndex -= '0';
2694  OUString aText;
2695  if ((aValue >>= aText) && nIndex < 3)
2696  {
2697  aKeys[nIndex]->sSortType = aText;
2698  }
2699  else
2700  {
2701  bRet = false;
2702  }
2703  }
2704  else if (rPropName.startsWith("SortRowOrColumnNo") &&
2705  rPropName.getLength() == 18 &&
2706  (rPropName[17] >= '0' && rPropName[17] <= '9'))
2707  {
2708  bOldSortdescriptor = true;
2709  sal_uInt16 nIndex = rPropName[17];
2710  nIndex -= '0';
2711  sal_Int16 nCol = -1;
2712  if (aValue.getValueType() == ::cppu::UnoType<sal_Int16>::get()
2713  && nIndex < 3)
2714  {
2715  aValue >>= nCol;
2716  }
2717  if (nCol >= 0)
2718  {
2719  aKeys[nIndex]->nColumnId = nCol;
2720  }
2721  else
2722  {
2723  bRet = false;
2724  }
2725  }
2726  else if (rPropName.startsWith("IsSortNumeric") &&
2727  rPropName.getLength() == 14 &&
2728  (rPropName[13] >= '0' && rPropName[13] <= '9'))
2729  {
2730  bOldSortdescriptor = true;
2731  sal_uInt16 nIndex = rPropName[13];
2732  nIndex = nIndex - '0';
2733  auto bTemp = o3tl::tryAccess<bool>(aValue);
2734  if (bTemp && nIndex < 3)
2735  {
2736  aKeys[nIndex]->bIsNumeric = *bTemp;
2737  }
2738  else
2739  {
2740  bRet = false;
2741  }
2742  }
2743  else if (rPropName.startsWith("IsSortAscending") &&
2744  rPropName.getLength() == 16 &&
2745  (rPropName[15] >= '0' && rPropName[15] <= '9'))
2746  {
2747  bOldSortdescriptor = true;
2748  sal_uInt16 nIndex = rPropName[15];
2749  nIndex -= '0';
2750  auto bTemp = o3tl::tryAccess<bool>(aValue);
2751  if (bTemp && nIndex < 3)
2752  {
2753  aKeys[nIndex]->eSortOrder = (*bTemp)
2755  }
2756  else
2757  {
2758  bRet = false;
2759  }
2760  }
2761  // new sortdescriptor
2762  else if ( rPropName == "IsSortColumns" )
2763  {
2764  bNewSortdescriptor = true;
2765  if (auto bTemp = o3tl::tryAccess<bool>(aValue))
2766  {
2767  rSortOpt.eDirection = *bTemp ? SRT_COLUMNS : SRT_ROWS;
2768  }
2769  else
2770  {
2771  bRet = false;
2772  }
2773  }
2774  else if ( rPropName == "SortFields" )
2775  {
2776  bNewSortdescriptor = true;
2777  uno::Sequence < table::TableSortField > aFields;
2778  if (aValue >>= aFields)
2779  {
2780  sal_Int32 nCount(aFields.getLength());
2781  if (nCount <= 3)
2782  {
2783  table::TableSortField* pFields = aFields.getArray();
2784  for (sal_Int32 i = 0; i < nCount; ++i)
2785  {
2786  rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive;
2787  rSortOpt.nLanguage =
2788  LanguageTag::convertToLanguageType( pFields[i].CollatorLocale );
2789  aKeys[i]->sSortType = pFields[i].CollatorAlgorithm;
2790  aKeys[i]->nColumnId =
2791  static_cast<sal_uInt16>(pFields[i].Field);
2792  aKeys[i]->bIsNumeric = (pFields[i].FieldType ==
2793  table::TableSortFieldType_NUMERIC);
2794  aKeys[i]->eSortOrder = (pFields[i].IsAscending)
2796  }
2797  }
2798  else
2799  {
2800  bRet = false;
2801  }
2802  }
2803  else
2804  {
2805  bRet = false;
2806  }
2807  }
2808  }
2809 
2810  if (bNewSortdescriptor && bOldSortdescriptor)
2811  {
2812  OSL_FAIL("someone tried to set the old deprecated and "
2813  "the new sortdescriptor");
2814  bRet = false;
2815  }
2816 
2817  if (pKey1->nColumnId != USHRT_MAX)
2818  {
2819  rSortOpt.aKeys.push_back(std::move(pKey1));
2820  }
2821  if (pKey2->nColumnId != USHRT_MAX)
2822  {
2823  rSortOpt.aKeys.push_back(std::move(pKey2));
2824  }
2825  if (pKey3->nColumnId != USHRT_MAX)
2826  {
2827  rSortOpt.aKeys.push_back(std::move(pKey3));
2828  }
2829 
2830  return bRet && !rSortOpt.aKeys.empty();
2831 }
2832 
2833 void SAL_CALL
2834 SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2835 {
2836  SolarMutexGuard aGuard;
2837 
2838  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2839 
2840  if (!rUnoCursor.HasMark())
2841  return;
2842 
2843  SwSortOptions aSortOpt;
2844  if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
2845  {
2846  throw uno::RuntimeException("Bad sort properties");
2847  }
2848  UnoActionContext aContext( rUnoCursor.GetDoc() );
2849 
2850  SwPosition & rStart = *rUnoCursor.Start();
2851  SwPosition & rEnd = *rUnoCursor.End();
2852 
2853  SwNodeIndex aPrevIdx( rStart.nNode, -1 );
2854  const sal_uLong nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex();
2855  const sal_Int32 nCntStt = rStart.nContent.GetIndex();
2856 
2857  rUnoCursor.GetDoc()->SortText(rUnoCursor, aSortOpt);
2858 
2859  // update selection
2860  rUnoCursor.DeleteMark();
2861  rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
2862  SwContentNode *const pCNd = rUnoCursor.GetContentNode();
2863  sal_Int32 nLen = pCNd->Len();
2864  if (nLen > nCntStt)
2865  {
2866  nLen = nCntStt;
2867  }
2868  rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen );
2869  rUnoCursor.SetMark();
2870 
2871  rUnoCursor.GetPoint()->nNode += nOffset;
2872  SwContentNode *const pCNd2 = rUnoCursor.GetContentNode();
2873  rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() );
2874 
2875 }
2876 
2877 uno::Reference< container::XEnumeration > SAL_CALL
2878 SwXTextCursor::createContentEnumeration(const OUString& rServiceName)
2879 {
2880  SolarMutexGuard g;
2881  if (rServiceName != "com.sun.star.text.TextContent")
2882  throw uno::RuntimeException();
2883  SwUnoCursor& rUnoCursor( m_pImpl->GetCursorOrThrow() );
2885 }
2886 
2887 uno::Reference< container::XEnumeration > SAL_CALL
2889 {
2890  SolarMutexGuard g;
2891 
2892  SwUnoCursor & rUnoCursor( m_pImpl->GetCursorOrThrow() );
2893 
2894  const uno::Reference<lang::XUnoTunnel> xTunnel(
2895  m_pImpl->m_xParentText, uno::UNO_QUERY);
2896  SwXText* pParentText = nullptr;
2897  if (xTunnel.is())
2898  {
2899  pParentText = ::sw::UnoTunnelGetImplementation<SwXText>(xTunnel);
2900  }
2901  OSL_ENSURE(pParentText, "parent is not a SwXText");
2902  if (!pParentText)
2903  {
2904  throw uno::RuntimeException();
2905  }
2906 
2907  auto pNewCursor(rUnoCursor.GetDoc()->CreateUnoCursor(*rUnoCursor.GetPoint()) );
2908  if (rUnoCursor.HasMark())
2909  {
2910  pNewCursor->SetMark();
2911  *pNewCursor->GetMark() = *rUnoCursor.GetMark();
2912  }
2913  const CursorType eSetType = (CursorType::TableText == m_pImpl->m_eType)
2915  SwTableNode const*const pStartNode( (CursorType::TableText == m_pImpl->m_eType)
2916  ? rUnoCursor.GetPoint()->nNode.GetNode().FindTableNode()
2917  : nullptr);
2918  SwTable const*const pTable(
2919  pStartNode ? & pStartNode->GetTable() : nullptr );
2920  return SwXParagraphEnumeration::Create(pParentText, pNewCursor, eSetType, pStartNode, pTable);
2921 }
2922 
2923 uno::Type SAL_CALL
2925 {
2927 }
2928 
2930 {
2931  return true;
2932 }
2933 
2934 uno::Sequence< OUString > SAL_CALL
2936 {
2937  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
2938  return aRet;
2939 }
2940 
2942 
2943 uno::Any SAL_CALL
2944 SwXTextCursor::queryInterface(const uno::Type& rType)
2945 {
2946  return (rType == cppu::UnoType<lang::XUnoTunnel>::get())
2949 }
2950 
2951 /* 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
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2449
bool is() const
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
Type
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const std::set< sal_uInt16 > &rAttrs=std::set< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:256
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1807
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2283
virtual sal_Int32 Len() const
Definition: node.cxx:1183
void DeleteMark()
Definition: pam.hxx:177
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:921
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:833
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
::sw::UnoImplPtr< Impl > m_pImpl
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1505
static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
Definition: unoobj.cxx:1766
static sal_uInt16 g_ParaResetableSetRange[]
Definition: unoobj.cxx:2291
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
void makeRedline(SwPaM const &rPaM, const OUString &rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
bool IsSectionNode() const
Definition: node.hxx:644
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1551
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::beans::XPropertySet, css::beans::XPropertyState, css::beans::XMultiPropertySet, css::beans::XMultiPropertyStates, css::container::XEnumerationAccess, css::container::XContentEnumerationAccess, css::util::XSortable, css::document::XDocumentInsertable, css::text::XSentenceCursor, css::text::XWordCursor, css::text::XParagraphCursor, css::text::XRedline, css::text::XMarkingAccess > SwXTextCursor_Base
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:2924
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:29
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SwSortDirection eDirection
Definition: sortopt.hxx:51
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1529
virtual void ResetError() override
#define RES_TXTATR_CJK_RUBY
Definition: hintids.hxx:143
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:939
CursorType
SwDocShell * GetDocShell()
Definition: doc.hxx:1340
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:949
#define FN_UNO_RANGE_END
Definition: cmdid.h:57
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1201
SwNodeIndex nNode
Definition: pam.hxx:37
sal_Unicode cDeli
Definition: sortopt.hxx:52
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:695
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual ~SwUnoInternalPaM() override
Definition: unoobj.cxx:121
sal_uIntPtr sal_uLong
#define MID_RUBY_CHARSTYLE
Definition: unomid.h:115
const SwPosition * GetMark() const
Definition: pam.hxx:209
bool IsEndWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr) const
Definition: swcrsr.cxx:1199
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1260
void SetStyleHandle(const std::shared_ptr< SfxItemSet > &pHandle)
Definition: fmtautofmt.hxx:48
#define RES_FRMATR_END
Definition: hintids.hxx:236
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:185
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj.cxx:869
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2165
#define RES_TXTATR_UNKNOWN_CONTAINER
Definition: hintids.hxx:144
sal_Int16 nId
void resetCursorPropertyValue(const SfxItemPropertySimpleEntry &rEntry, SwPaM &rPam)
void DeleteAndInsert(OUString const &rText, const bool bForceExpandHints)
Definition: unoobj.cxx:723
sal_uInt64 Seek(sal_uInt64 nPos)
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:803
std::vector< std::unique_ptr< SwSortKey > > aKeys
Definition: sortopt.hxx:50
bool getCursorPropertyValue(const SfxItemPropertySimpleEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
SwNode & GetNode() const
Definition: ndindex.hxx:118
void SetNumRuleStart(const SwPosition &rPos, bool bFlag=true)
Definition: docnum.cxx:1009
#define RES_PARATR_LIST_END
Definition: hintids.hxx:190
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2066
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
Definition: shellio.cxx:743
void SetPropertyValues(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< css::beans::PropertyValue > &rPropertyValues, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:176
const uno::Reference< text::XText > m_xParentText
Definition: unoobj.cxx:660
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj.cxx:1633
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:142
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1454
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1641
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
bool ConvertSortProperties(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor, SwSortOptions &rSortOpt)
#define MID_PAGEDESC_PAGEDESCNAME
Definition: unomid.h:26
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:347
void SetSmartTags(SwWrongList *pNew, bool bDelete=true)
Definition: txtedt.cxx:2200
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2256
#define RES_TXTATR_END
Definition: hintids.hxx:158
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
static void lcl_setAutoStyle(IStyleAccess &rStyleAccess, const uno::Any &rValue, SfxItemSet &rSet, const bool bPara)
Definition: unoobj.cxx:244
#define MID_DROPCAP_CHAR_STYLE_NAME
Definition: unomid.h:65
#define RES_UNKNOWNATR_CONTAINER
Definition: hintids.hxx:267
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1213
SwUnoInternalPaM & operator=(const SwPaM &rPaM)
Definition: unoobj.cxx:129
const SwSection & GetSection() const
Definition: node.hxx:541
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2205
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2834
sal_uInt16 sal_Unicode
#define RES_CHRATR_END
Definition: hintids.hxx:114
#define PROPERTY_NONE
Definition: unomap.hxx:27
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:747
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1482
#define FN_UNO_LIST_ID
Definition: cmdid.h:583
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:875
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:357
SwIndex nContent
Definition: pam.hxx:38
Any SAL_CALL getCaughtException()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
Definition: docfmt.cxx:1096
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1300
#define UNO_NAME_IS_SKIP_PROTECTED_TEXT
Definition: unoprnms.hxx:508
static SwXParaFrameEnumeration * Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1610
sal_uLong GetIndex() const
Definition: ndindex.hxx:151
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1540
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
const CursorType m_eType
Definition: unoobj.cxx:659
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
static sal_uInt16 g_ResetableSetRange[]
Definition: unoobj.cxx:2300
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:165
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1667
#define RES_PARATR_BEGIN
Definition: hintids.hxx:160
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:2935
void SetCountedInList(bool bCounted)
Definition: ndtxt.cxx:4223
void getPropertyValue(const SfxItemPropertySimpleEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2042
void SetWrongDirty(WrongState eNew) const
Definition: txtedt.cxx:2238
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2151
bool SetCursorPropertyValue(SfxItemPropertySimpleEntry const &rEntry, css::uno::Any const &rValue, SwPaM &rPam, SfxItemSet &rItemSet)
bool bIgnoreCase
Definition: sortopt.hxx:55
SwPaM * GetNext()
Definition: pam.hxx:264
SwXTextCursor(SwDoc &rDoc, css::uno::Reference< css::text::XText > const &xParent, const CursorType eType, SwPosition const &rPos, SwPosition const *const pMark=nullptr)
SwPaM & SetPam(size_t nArrPos, SwPaM &rPam)
Definition: ednumber.cxx:99
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:150
#define FN_UNO_IS_NUMBER
Definition: cmdid.h:543
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:2929
SwFormatColl & GetAnyFormatColl() const
Definition: node.hxx:716
sal_uInt16 nColumnId
Definition: sortopt.hxx:38
const SfxItemPropertySet & m_rPropSet
Definition: unoobj.cxx:658
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1704
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1419
void SetNodeNumStart(const SwPosition &rPos, sal_uInt16 nStt)
Definition: docnum.cxx:1031
void SetListId(OUString const &rListId)
Definition: ndtxt.cxx:4358
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2575
bool GoPrevPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:935
void SetCharSet(rtl_TextEncoding nVal)
Definition: shellio.hxx:77
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:497
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2149
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
size_t Count() const
Definition: edimp.hxx:49
static void lcl_setRubyCharstyle(SfxItemSet &rItemSet, uno::Any const &rValue)
Definition: unoobj.cxx:442
SwPaM(SwPaM const &rPaM)=delete
bool IsEndOfPara(SwPaM &rUnoCursor)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2346
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1692
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
#define SAL_MAX_INT32
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj.cxx:2181
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2269
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const SwPosition * GetPoint() const
Definition: pam.hxx:207
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:719
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:689
ForceIntoMetaMode
Definition: unoobj.cxx:757
SetAttrMode
Definition: swtypes.hxx:143
void Exchange()
Definition: pam.cxx:471
int i
bool IsHiddenFlag() const
Definition: section.hxx:188
sal_uInt64 GetSize()
SwContentNode * GetContentNode()
Definition: node.hxx:615
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:957
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
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:907
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
void SetTextFormatColl(const css::uno::Any &rAny, SwPaM &rPaM)
static bool lcl_ForceIntoMeta(SwPaM &rCursor, uno::Reference< text::XText > const &xParentText, const enum ForceIntoMetaMode eMode)
Definition: unoobj.cxx:760
SwDoc * GetDoc() const
Definition: pam.hxx:243
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1159
bool IsStartOfPara(SwPaM &rUnoCursor)
float u
unsigned char sal_Bool
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:68
const SfxItemPropertyMap & getPropertyMap() const
Object Value
static void lcl_EnumerateIds(sal_uInt16 const *pIdRange, std::set< sal_uInt16 > &rWhichIds)
Definition: unoobj.cxx:2310
void setPropertyValue(const SfxItemPropertySimpleEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
css::beans::PropertyState getPropertyState(const OUString &rName, const SfxItemSet &rSet) const
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:991
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1372
Marks a node in the document model.
Definition: ndindex.hxx:31
static SwPageDesc * GetByName(SwDoc &rDoc, const OUString &rName)
Definition: pagedesc.cxx:403
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1042
css::uno::Type const & get()
static void lcl_setDropcapCharStyle(SwPaM const &rPam, SfxItemSet &rItemSet, uno::Any const &rValue)
Definition: unoobj.cxx:405
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:882
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2487
#define RES_UNKNOWNATR_BEGIN
Definition: hintids.hxx:266
#define FN_UNO_RANGE_BEGIN
Definition: cmdid.h:56
virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1617
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2193
#define FN_UNO_NUM_START_VALUE
Definition: cmdid.h:500
void InsertFile(SwUnoCursor *pUnoCursor, const OUString &rURL, const uno::Sequence< beans::PropertyValue > &rOptions)
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
#define RES_PARATR_LIST_BEGIN
Definition: hintids.hxx:184
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
#define RES_TXTATR_INETFMT
Definition: hintids.hxx:141
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2262
const SfxItemPropertySimpleEntry * getByName(const OUString &rName) const
SwSortOrder eSortOrder
Definition: sortopt.hxx:37
#define FN_SKIP_PROTECTED_TEXT
Definition: cmdid.h:547
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:2888
enumrange< T >::Iterator end(enumrange< T >)
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
#define FILTER_TEXT_DLG
text filter with encoding dialog
Definition: iodetect.hxx:34
const SwPosition * Start() const
Definition: pam.hxx:212
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
std::size_t ReadBytes(void *pData, std::size_t nSize)
void NotifyClients(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.cxx:167
#define UNO_NAME_IS_SKIP_HIDDEN_TEXT
Definition: unoprnms.hxx:507
void SetGrammarCheck(SwGrammarMarkUp *pNew, bool bDelete=true)
Definition: txtedt.cxx:2178
virtual std::shared_ptr< SfxItemSet > getByName(const OUString &rName, SwAutoStyleFamily eFamily)=0
It's slow to iterate through a stylepool looking for a special name, but if the style has been insert...
virtual const SwPaM * GetPaM() const =0
bool IsError() const
static bool lcl_setCharFormatSequence(SwPaM &rPam, uno::Any const &rValue)
Definition: unoobj.cxx:377
static void lcl_SelectParaAndReset(SwPaM &rPaM, SwDoc &rDoc, std::set< sal_uInt16 > const &rWhichIds)
Definition: unoobj.cxx:1981
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void SetAttrListLevel(int nLevel)
Sets the list level of this text node.
Definition: ndtxt.cxx:4065
OUString sSortType
Definition: sortopt.hxx:36
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:686
SwUnoInternalPaM(const SwUnoInternalPaM &)=delete
#define RES_TXTATR_AUTOFMT
Definition: hintids.hxx:140
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2158
#define FN_UNO_NUM_RULES
Definition: cmdid.h:502
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1336
#define FN_NUMBER_NEWSTART
Definition: cmdid.h:437
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj.cxx:2090
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2498
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2002
css::uno::Any GetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1716
bool GetPositions(SwPaM &rToFill) const
Definition: unoobj2.cxx:987
#define FN_UNO_CHARFMT_SEQUENCE
Definition: cmdid.h:567
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2271
css::uno::Sequence< css::beans::PropertyState > GetPropertyStates(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< OUString > &rPropertyNames, const SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
SwMoveFnCollection const & fnSectionEnd
Definition: paminit.cxx:50
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj.cxx:863
SwGetPropertyStatesCaller
void SetEndian(SvStreamEndian SvStreamEndian)
sal_Int32 GetIndex() const
Definition: index.hxx:95
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1576
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1395
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj.cxx:2878
SwNodes & GetNodes()
Definition: doc.hxx:403
Impl(SwDoc &rDoc, const CursorType eType, uno::Reference< text::XText > const &xParent, SwPosition const &rPoint, SwPosition const *const pMark)
Definition: unoobj.cxx:663
const SwPosition * End() const
Definition: pam.hxx:217
void SetWrong(SwWrongList *pNew, bool bDelete=true)
Definition: txtedt.cxx:2155
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:977
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:131
virtual void SAL_CALL collapseToEnd() override
Definition: unoobj.cxx:891
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2220
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2324
static void lcl_setCharStyle(SwDoc *const pDoc, const uno::Any &rValue, SfxItemSet &rSet)
Definition: unoobj.cxx:218
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2277
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:416
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1601
SwMoveFnCollection const & fnSectionStart
Definition: paminit.cxx:49
SwStartNodeType
Definition: ndtyp.hxx:50
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:351
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2173
LanguageType nLanguage
Definition: sortopt.hxx:53
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:612
void SetCursorAttr(SwPaM &rPam, const SfxItemSet &rSet, const SetAttrMode nAttrMode, const bool bTableMode=false)
Definition: unoobj2.cxx:315
void setNumberingProperty(const Any &rValue, SwPaM &rPam)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:838
ScXMLEditAttributeMap::Entry const aEntries[]
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
Definition: nodes.cxx:1923
static void lcl_SetNodeNumStart(SwPaM &rCursor, uno::Any const &rValue)
Definition: unoobj.cxx:348
bool SetPageDesc(const css::uno::Any &rValue, SwDoc &rDoc, SfxItemSet &rSet)
SwFormatColl * GetFormatColl() const
Definition: node.hxx:447
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2123
void GetWriter(const OUString &rFltName, const OUString &rBaseURL, WriterRef &xRet)
Return writer based on the name.
Definition: fltini.cxx:177
#define RES_PARATR_DROP
Definition: hintids.hxx:168
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, const OUString &rText, const bool bForceExpandHints)
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2157
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
#define FN_UNO_NUM_LEVEL
Definition: cmdid.h:501
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
#define RES_UNKNOWNATR_END
Definition: hintids.hxx:268
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1969
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:50
#define RES_AUTO_STYLE
Definition: hintids.hxx:231
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1190
#define RES_PAGEDESC
Definition: hintids.hxx:198
#define RES_BREAK
Definition: hintids.hxx:199
IStyleAccess & GetIStyleAccess()
Definition: doc.hxx:751
#define FN_SKIP_HIDDEN_TEXT
Definition: cmdid.h:546
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:844
#define RES_FRMATR_BEGIN
Definition: hintids.hxx:192
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2213
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2409
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1014
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1273
css::uno::Sequence< css::beans::PropertyValue > CreateSortDescriptor(const bool bFromTable)
Definition: unoobj.cxx:2509
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool SetContentRange(SwTextNode *&rpNode, sal_Int32 &rStart, sal_Int32 &rEnd) const
init params with position of the attribute content (w/out CH_TXTATR)
Definition: unorefmk.cxx:759
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:496
bool IsStartWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr) const
Definition: swcrsr.cxx:1181
bool bIsNumeric
Definition: sortopt.hxx:39
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1307
sw::UnoCursorPointer m_pUnoCursor
Definition: unoobj.cxx:661
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
#define RES_PARATR_END
Definition: hintids.hxx:180
CollatorWrapper & GetAppCollator()
Definition: init.cxx:783
SwUnoCursor & GetCursorOrThrow()
Definition: unoobj.cxx:679
Base class of the Writer document model elements.
Definition: node.hxx:79
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo