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 <svl/itemprop.hxx>
24 #include <o3tl/any.hxx>
25 #include <o3tl/safeint.hxx>
26 #include <osl/endian.h>
28 #include <swtypes.hxx>
29 #include <hintids.hxx>
30 #include <cmdid.h>
31 #include <unomid.h>
32 #include <hints.hxx>
33 #include <doc.hxx>
34 #include <IDocumentUndoRedo.hxx>
35 #include <istyleaccess.hxx>
36 #include <ndtxt.hxx>
37 #include <unocrsr.hxx>
38 #include <unocrsrhelper.hxx>
39 #include <swundo.hxx>
40 #include <rootfrm.hxx>
41 #include <paratr.hxx>
42 #include <pam.hxx>
43 #include <shellio.hxx>
44 #include <fmtruby.hxx>
45 #include <docsh.hxx>
46 #include <docstyle.hxx>
47 #include <fmtpdsc.hxx>
48 #include <pagedesc.hxx>
49 #include <edimp.hxx>
50 #include <fchrfmt.hxx>
51 #include <fmtautofmt.hxx>
52 #include <unotextrange.hxx>
53 #include <unotextcursor.hxx>
54 #include <unomap.hxx>
55 #include <unoprnms.hxx>
56 #include <unometa.hxx>
57 #include <unocontentcontrol.hxx>
58 #include <unotext.hxx>
59 #include <com/sun/star/text/TextMarkupType.hpp>
60 #include <vcl/svapp.hxx>
61 #include <unotools/syslocale.hxx>
63 #include <SwStyleNameMapper.hxx>
64 #include <sortopt.hxx>
65 #include <com/sun/star/beans/PropertyAttribute.hpp>
66 #include <com/sun/star/beans/NamedValue.hpp>
67 #include <com/sun/star/i18n/WordType.hpp>
68 #include <memory>
69 #include <unoparaframeenum.hxx>
70 #include <unoparagraph.hxx>
71 #include <iodetect.hxx>
75 
76 using namespace ::com::sun::star;
77 
78 // Helper classes
80  SwPaM(rDoc.GetNodes())
81 {
82 }
83 
85 {
86  while( GetNext() != this)
87  {
88  delete GetNext();
89  }
90 }
91 
93 {
94  const SwPaM* pTmp = &rPaM;
95  *GetPoint() = *rPaM.GetPoint();
96  if(rPaM.HasMark())
97  {
98  SetMark();
99  *GetMark() = *rPaM.GetMark();
100  }
101  else
102  DeleteMark();
103  while(&rPaM != (pTmp = pTmp->GetNext()))
104  {
105  if(pTmp->HasMark())
106  new SwPaM(*pTmp->GetMark(), *pTmp->GetPoint(), this);
107  else
108  new SwPaM(*pTmp->GetPoint(), this);
109  }
110  return *this;
111 }
112 
113 void SwUnoCursorHelper::SelectPam(SwPaM & rPam, const bool bExpand)
114 {
115  if (bExpand)
116  {
117  if (!rPam.HasMark())
118  {
119  rPam.SetMark();
120  }
121  }
122  else if (rPam.HasMark())
123  {
124  rPam.DeleteMark();
125  }
126 }
127 
128 void SwUnoCursorHelper::GetTextFromPam(SwPaM & rPam, OUString & rBuffer,
129  SwRootFrame const*const pLayout)
130 {
131  if (!rPam.HasMark())
132  {
133  return;
134  }
135  SvMemoryStream aStream;
136 #ifdef OSL_BIGENDIAN
137  aStream.SetEndian( SvStreamEndian::BIG );
138 #else
139  aStream.SetEndian( SvStreamEndian::LITTLE );
140 #endif
141  WriterRef xWrt;
142  // TODO/MBA: looks like a BaseURL doesn't make sense here
143  SwReaderWriter::GetWriter( FILTER_TEXT_DLG, OUString(), xWrt );
144  if( !xWrt.is() )
145  return;
146 
147  SwWriter aWriter( aStream, rPam );
148  xWrt->m_bASCII_NoLastLineEnd = true;
149  xWrt->m_bExportParagraphNumbering = false;
150  SwAsciiOptions aOpt = xWrt->GetAsciiOptions();
151  aOpt.SetCharSet( RTL_TEXTENCODING_UNICODE );
152  xWrt->SetAsciiOptions( aOpt );
153  xWrt->m_bUCS2_WithStartChar = false;
154  // #i68522#
155  const bool bOldShowProgress = xWrt->m_bShowProgress;
156  xWrt->m_bShowProgress = false;
157  xWrt->m_bHideDeleteRedlines = pLayout && pLayout->IsHideRedlines();
158 
159  if( ! aWriter.Write( xWrt ).IsError() )
160  {
161  const sal_uInt64 lUniLen = aStream.GetSize()/sizeof( sal_Unicode );
162  if (lUniLen < o3tl::make_unsigned(SAL_MAX_INT32-1))
163  {
164  aStream.WriteUInt16( '\0' );
165 
166  aStream.Seek( 0 );
167  aStream.ResetError();
168 
169  rtl_uString *pStr = rtl_uString_alloc(lUniLen);
170  aStream.ReadBytes(pStr->buffer, lUniLen * sizeof(sal_Unicode));
171  rBuffer = OUString(pStr, SAL_NO_ACQUIRE);
172  }
173  }
174  xWrt->m_bShowProgress = bOldShowProgress;
175 
176 }
177 
180 static void
181 lcl_setCharStyle(SwDoc& rDoc, const uno::Any & rValue, SfxItemSet & rSet)
182 {
183  SwDocShell *const pDocSh = rDoc.GetDocShell();
184  if(!pDocSh)
185  return;
186 
187  OUString uStyle;
188  if (!(rValue >>= uStyle))
189  {
190  throw lang::IllegalArgumentException();
191  }
192  OUString sStyle;
193  SwStyleNameMapper::FillUIName(uStyle, sStyle,
195  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
196  pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
197  if (!pStyle)
198  {
199  throw lang::IllegalArgumentException();
200  }
201  const SwFormatCharFormat aFormat(pStyle->GetCharFormat());
202  rSet.Put(aFormat);
203 };
204 
206 static void
207 lcl_setAutoStyle(IStyleAccess & rStyleAccess, const uno::Any & rValue,
208  SfxItemSet & rSet, const bool bPara)
209 {
210  OUString uStyle;
211  if (!(rValue >>= uStyle))
212  {
213  throw lang::IllegalArgumentException();
214  }
215  std::shared_ptr<SfxItemSet> pStyle = bPara ?
216  rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_PARA ):
217  rStyleAccess.getByName(uStyle, IStyleAccess::AUTO_STYLE_CHAR );
218  if(!pStyle)
219  {
220  throw lang::IllegalArgumentException();
221  }
222 
223  SwFormatAutoFormat aFormat( bPara
224  ? sal::static_int_cast< sal_uInt16 >(RES_AUTO_STYLE)
225  : sal::static_int_cast< sal_uInt16 >(RES_TXTATR_AUTOFMT) );
226  aFormat.SetStyleHandle( pStyle );
227  rSet.Put(aFormat);
228 };
229 
230 void
232 {
233  SwDoc& rDoc = rPaM.GetDoc();
234  SwDocShell *const pDocSh = rDoc.GetDocShell();
235  if(!pDocSh)
236  return;
237  OUString uStyle;
238  rAny >>= uStyle;
239  OUString sStyle;
240  SwStyleNameMapper::FillUIName(uStyle, sStyle,
242  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
243  pDocSh->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Para));
244  if (!pStyle)
245  {
246  throw lang::IllegalArgumentException();
247  }
248 
249  SwTextFormatColl *const pLocal = pStyle->GetCollection();
250  UnoActionContext aAction(&rDoc);
252  SwPaM *pTmpCursor = &rPaM;
253  do {
254  rDoc.SetTextFormatColl(*pTmpCursor, pLocal);
255  pTmpCursor = pTmpCursor->GetNext();
256  } while ( pTmpCursor != &rPaM );
257  rDoc.GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
258 }
259 
260 bool
262  const uno::Any& rValue, SwDoc & rDoc, SfxItemSet & rSet)
263 {
264  OUString uDescName;
265  if (!(rValue >>= uDescName))
266  {
267  return false;
268  }
269  std::unique_ptr<SwFormatPageDesc> pNewDesc;
270  if(const SwFormatPageDesc* pItem = rSet.GetItemIfSet( RES_PAGEDESC ))
271  {
272  pNewDesc.reset(new SwFormatPageDesc(*pItem));
273  }
274  if (!pNewDesc)
275  {
276  pNewDesc.reset(new SwFormatPageDesc());
277  }
278  OUString sDescName;
279  SwStyleNameMapper::FillUIName(uDescName, sDescName,
281  if (!pNewDesc->GetPageDesc() ||
282  (pNewDesc->GetPageDesc()->GetName() != sDescName))
283  {
284  bool bPut = false;
285  if (!sDescName.isEmpty())
286  {
287  SwPageDesc *const pPageDesc = SwPageDesc::GetByName(rDoc, sDescName);
288  if (!pPageDesc)
289  {
290  throw lang::IllegalArgumentException();
291  }
292  pNewDesc->RegisterToPageDesc(*pPageDesc);
293  bPut = true;
294  }
295  if(!bPut)
296  {
297  rSet.ClearItem(RES_BREAK);
298  rSet.Put(SwFormatPageDesc());
299  }
300  else
301  {
302  rSet.Put(*pNewDesc);
303  }
304  }
305  return true;
306 }
307 
308 static void
309 lcl_SetNodeNumStart(SwPaM & rCursor, uno::Any const& rValue)
310 {
311  sal_Int16 nTmp = 1;
312  rValue >>= nTmp;
313  sal_uInt16 nStt = (nTmp < 0 ? USHRT_MAX : o3tl::narrowing<sal_uInt16>(nTmp));
314  SwDoc& rDoc = rCursor.GetDoc();
315  UnoActionContext aAction(&rDoc);
316 
317  if( rCursor.GetNext() != &rCursor ) // MultiSelection?
318  {
320  SwPamRanges aRangeArr( rCursor );
321  SwPaM aPam( *rCursor.GetPoint() );
322  for( size_t n = 0; n < aRangeArr.Count(); ++n )
323  {
324  rDoc.SetNumRuleStart(*aRangeArr.SetPam( n, aPam ).GetPoint());
325  rDoc.SetNodeNumStart(*aRangeArr.SetPam( n, aPam ).GetPoint(),
326  nStt );
327  }
328  rDoc.GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
329  }
330  else
331  {
332  rDoc.SetNumRuleStart( *rCursor.GetPoint());
333  rDoc.SetNodeNumStart( *rCursor.GetPoint(), nStt );
334  }
335 }
336 
337 static bool
339 {
340  uno::Sequence<OUString> aCharStyles;
341  if (!(rValue >>= aCharStyles))
342  {
343  return false;
344  }
345 
346  for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++)
347  {
348  uno::Any aStyle;
350  aStyle <<= aCharStyles.getConstArray()[nStyle];
351  // create a local set and apply each format directly
353  lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet);
354  // the first style should replace the current attributes,
355  // all other have to be added
356  SwUnoCursorHelper::SetCursorAttr(rPam, aSet, nStyle
360  }
361  return true;
362 }
363 
364 static void
365 lcl_setDropcapCharStyle(SwPaM const & rPam, SfxItemSet & rItemSet,
366  uno::Any const& rValue)
367 {
368  OUString uStyle;
369  if (!(rValue >>= uStyle))
370  {
371  throw lang::IllegalArgumentException();
372  }
373  OUString sStyle;
374  SwStyleNameMapper::FillUIName(uStyle, sStyle,
376  SwDoc& rDoc = rPam.GetDoc();
377  //default character style must not be set as default format
378  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
379  rDoc.GetDocShell()
380  ->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
381  if (!pStyle || pStyle->GetCharFormat() == rDoc.GetDfltCharFormat())
382  {
383  throw lang::IllegalArgumentException();
384  }
385  std::unique_ptr<SwFormatDrop> pDrop;
386  if (const SwFormatDrop* pItem = rItemSet.GetItemIfSet(RES_PARATR_DROP))
387  {
388  pDrop.reset(new SwFormatDrop(*pItem));
389  }
390  if (!pDrop)
391  {
392  pDrop.reset(new SwFormatDrop);
393  }
394  const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*pStyle));
395  pDrop->SetCharFormat(xStyle->GetCharFormat());
396  rItemSet.Put(*pDrop);
397 }
398 
399 static void
400 lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue)
401 {
402  OUString sTmp;
403  if (!(rValue >>= sTmp))
404  {
405  throw lang::IllegalArgumentException();
406  }
407 
408  std::unique_ptr<SwFormatRuby> pRuby;
409  if (const SwFormatRuby* pItem = rItemSet.GetItemIfSet(RES_TXTATR_CJK_RUBY))
410  {
411  pRuby.reset(new SwFormatRuby(*pItem));
412  }
413  if (!pRuby)
414  {
415  pRuby.reset(new SwFormatRuby(OUString()));
416  }
417  OUString sStyle;
418  SwStyleNameMapper::FillUIName(sTmp, sStyle,
420  pRuby->SetCharFormatName(sStyle);
421  pRuby->SetCharFormatId(0);
422  if (!sStyle.isEmpty())
423  {
424  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
426  pRuby->SetCharFormatId(nId);
427  }
428  rItemSet.Put(*pRuby);
429 }
430 
431 bool
433  SfxItemPropertyMapEntry const& rEntry, const uno::Any& rValue,
434  SwPaM & rPam, SfxItemSet & rItemSet)
435 {
436  if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) &&
437  (rValue.getValueType() == cppu::UnoType<void>::get()))
438  {
439  return false;
440  }
441  bool bRet = true;
442  switch (rEntry.nWID)
443  {
444  case RES_TXTATR_CHARFMT:
445  lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet);
446  break;
447  case RES_TXTATR_AUTOFMT:
449  rValue, rItemSet, false);
450  break;
452  lcl_setCharFormatSequence(rPam, rValue);
453  break;
454  case FN_UNO_PARA_STYLE :
456  break;
457  case RES_AUTO_STYLE:
459  rValue, rItemSet, true);
460  break;
461  case FN_UNO_PAGE_STYLE:
462  //FIXME nothing here?
463  break;
465  lcl_SetNodeNumStart( rPam, rValue );
466  break;
467  case FN_UNO_NUM_LEVEL:
468  // #i91601#
469  case FN_UNO_LIST_ID:
470  case FN_UNO_IS_NUMBER:
472  {
473  // multi selection is not considered
474  SwTextNode *const pTextNd = rPam.GetNode().GetTextNode();
475  if (!pTextNd)
476  {
477  throw lang::IllegalArgumentException();
478  }
479  if (FN_UNO_NUM_LEVEL == rEntry.nWID)
480  {
481  sal_Int16 nLevel = 0;
482  if (rValue >>= nLevel)
483  {
484  if (nLevel < 0 || MAXLEVEL <= nLevel)
485  {
486  throw lang::IllegalArgumentException(
487  "invalid NumberingLevel", nullptr, 0);
488  }
489  pTextNd->SetAttrListLevel(nLevel);
490  }
491  }
492  // #i91601#
493  else if (FN_UNO_LIST_ID == rEntry.nWID)
494  {
495  OUString sListId;
496  if (rValue >>= sListId)
497  {
498  pTextNd->SetListId( sListId );
499  }
500  }
501  else if (FN_UNO_IS_NUMBER == rEntry.nWID)
502  {
503  bool bIsNumber(false);
504  if ((rValue >>= bIsNumber) && !bIsNumber)
505  {
506  pTextNd->SetCountedInList( false );
507  }
508  }
509  else if (FN_UNO_PARA_NUM_AUTO_FORMAT == rEntry.nWID)
510  {
511  uno::Sequence<beans::NamedValue> props;
512  if (rValue >>= props)
513  {
514  // TODO create own map for this, it contains UNO_NAME_DISPLAY_NAME? or make property readable so ODF export can map it to a automatic style?
516  SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
521  items( rPam.GetDoc().GetAttrPool() );
522 
523  for (beans::NamedValue const & prop : std::as_const(props))
524  {
525  SfxItemPropertyMapEntry const*const pEntry =
526  rMap.getByName(prop.Name);
527  if (!pEntry)
528  {
529  if (prop.Name == "CharStyleName")
530  {
531  lcl_setCharStyle(rPam.GetDoc(), prop.Value, items);
532  continue;
533  }
534  throw beans::UnknownPropertyException(
535  "Unknown property: " + prop.Name);
536  }
537  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
538  {
539  throw beans::PropertyVetoException(
540  "Property is read-only: " + prop.Name);
541  }
542  rPropSet.setPropertyValue(*pEntry, prop.Value, items);
543  }
544 
546  // TODO: for ODF export we'd need to add it to the autostyle pool
547  // note: paragraph auto styles have ParaStyleName property for the parent style; character auto styles currently do not because there's a separate hint, but for this it would be a good way to add it in order to export it as style:parent-style-name, see XMLTextParagraphExport::Add()
548  item.SetStyleHandle(std::make_shared<SfxItemSet>(items));
549  pTextNd->SetAttr(item);
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 SwNodeOffset nSttNd = pTmpCursor->Start()->nNode.GetIndex();
621  const SwNodeOffset nEndNd = pTmpCursor->End()->nNode.GetIndex();
622 
623  if( nEndNd - nSttNd >= SwNodeOffset(nMaxLookup) )
624  {
625  pFormat = nullptr;
626  break;
627  }
628 
629  const SwNodes& rNds = rPaM.GetDoc().GetNodes();
630  for( SwNodeOffset 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  { return *m_pUnoCursor; }
656 
658  { return m_pUnoCursor.get(); }
659 
661  { return m_pUnoCursor.get(); }
662 
664  { return m_pUnoCursor ? &m_pUnoCursor->GetDoc() : nullptr; }
665 
667  { return m_pUnoCursor ? &m_pUnoCursor->GetDoc() : nullptr; }
668 
670  SwDoc & rDoc,
671  uno::Reference< text::XText > const& xParent,
672  const CursorType eType,
673  const SwPosition& rPos,
674  SwPosition const*const pMark)
675  : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
676  , m_eType(eType)
677  , m_xParentText(xParent)
678  , m_pUnoCursor(rDoc.CreateUnoCursor(rPos))
679 {
680  if (pMark)
681  {
683  *m_pUnoCursor->GetMark() = *pMark;
684  }
685 }
686 
687 SwXTextCursor::SwXTextCursor(uno::Reference< text::XText > const& xParent,
688  SwPaM const& rSourceCursor, const CursorType eType)
689  : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
690  , m_eType(eType)
691  , m_xParentText(xParent)
692  , m_pUnoCursor(rSourceCursor.GetDoc().CreateUnoCursor(*rSourceCursor.GetPoint()))
693 {
694  if (rSourceCursor.HasMark())
695  {
697  *m_pUnoCursor->GetMark() = *rSourceCursor.GetMark();
698  }
699 }
700 
702 {
703  SolarMutexGuard g; // #i105557#: call dtor with locked solar mutex
704  m_pUnoCursor.reset(nullptr); // need to delete this with SolarMutex held
705 }
706 
707 void SwXTextCursor::DeleteAndInsert(const OUString& rText,
708  const bool bForceExpandHints)
709 {
710  auto pUnoCursor = static_cast<SwCursor*>(m_pUnoCursor.get());
711  if (!pUnoCursor)
712  return;
713 
714  // Start/EndAction
715  SwDoc& rDoc = pUnoCursor->GetDoc();
716  UnoActionContext aAction(&rDoc);
717  const sal_Int32 nTextLen = rText.getLength();
719  auto pCurrent = pUnoCursor;
720  do
721  {
722  if (pCurrent->HasMark())
723  {
725  }
726  if(nTextLen)
727  {
728  const bool bSuccess(
730  rDoc, *pCurrent, rText, bForceExpandHints ) );
731  OSL_ENSURE( bSuccess, "Doc->Insert(Str) failed." );
732 
733  SwUnoCursorHelper::SelectPam(*pUnoCursor, true);
734  pCurrent->Left(rText.getLength());
735  }
736  pCurrent = pCurrent->GetNext();
737  } while (pCurrent != pUnoCursor);
739 }
740 
741 namespace {
742 
743 enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END };
744 
745 }
746 
747 static bool
749  uno::Reference<text::XText> const & xParentText,
750  const enum ForceIntoMetaMode eMode)
751 {
752  bool bRet( true ); // means not forced in META_CHECK_BOTH
753  SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) );
754  OSL_ENSURE(pXMeta, "no parent?");
755  if (!pXMeta)
756  throw uno::RuntimeException();
757  SwTextNode * pTextNode;
758  sal_Int32 nStart;
759  sal_Int32 nEnd;
760  const bool bSuccess( pXMeta->SetContentRange(pTextNode, nStart, nEnd) );
761  OSL_ENSURE(bSuccess, "no pam?");
762  if (!bSuccess)
763  throw uno::RuntimeException();
764  // force the cursor back into the meta if it has moved outside
765  SwPosition start(*pTextNode, nStart);
766  SwPosition end(*pTextNode, nEnd);
767  switch (eMode)
768  {
769  case META_INIT_START:
770  *rCursor.GetPoint() = start;
771  break;
772  case META_INIT_END:
773  *rCursor.GetPoint() = end;
774  break;
775  case META_CHECK_BOTH:
776  if (*rCursor.Start() < start)
777  {
778  *rCursor.Start() = start;
779  bRet = false;
780  }
781  if (*rCursor.End() > end)
782  {
783  *rCursor.End() = end;
784  bRet = false;
785  }
786  break;
787  }
788  return bRet;
789 }
790 
792 {
793  if (CursorType::Meta == m_eType)
794  {
795  auto pCursor( m_pUnoCursor );
796  SwXMeta const*const pXMeta(
797  dynamic_cast<SwXMeta*>(m_xParentText.get()) );
798  OSL_ENSURE(pXMeta, "no meta?");
799  if (pCursor && pXMeta)
800  {
801  SwTextNode * pTextNode;
802  sal_Int32 nStart;
803  sal_Int32 nEnd;
804  const bool bSuccess(
805  pXMeta->SetContentRange(pTextNode, nStart, nEnd) );
806  OSL_ENSURE(bSuccess, "no pam?");
807  if (bSuccess)
808  {
809  const SwPosition end(*pTextNode, nEnd);
810  if ( (*pCursor->GetPoint() == end)
811  || (*pCursor->GetMark() == end))
812  {
813  return true;
814  }
815  }
816  }
817  }
818  return false;
819 }
820 
822 {
824  {
825  auto pCursor( m_pUnoCursor );
826  auto pXContentControl(
827  dynamic_cast<SwXContentControl*>(m_xParentText.get()) );
828  if (!pXContentControl)
829  {
830  SAL_WARN("sw.core", "SwXTextCursor::IsAtEndOfContentControl: no content control");
831  }
832  if (pCursor && pXContentControl)
833  {
834  SwTextNode * pTextNode;
835  sal_Int32 nStart;
836  sal_Int32 nEnd;
837  const bool bSuccess(
838  pXContentControl->SetContentRange(pTextNode, nStart, nEnd) );
839  if (!bSuccess)
840  {
841  SAL_WARN("sw.core", "SwXTextCursor::IsAtEndOfContentControl: no pam");
842  }
843  else
844  {
845  const SwPosition end(*pTextNode, nEnd);
846  if ( (*pCursor->GetPoint() == end)
847  || (*pCursor->GetMark() == end))
848  {
849  return true;
850  }
851  }
852  }
853  }
854  return false;
855 }
856 
858 {
859  return "SwXTextCursor";
860 }
861 
862 sal_Bool SAL_CALL SwXTextCursor::supportsService(const OUString& rServiceName)
863 {
864  return cppu::supportsService(this, rServiceName);
865 }
866 
867 uno::Sequence< OUString > SAL_CALL
869 {
870  return {
871  "com.sun.star.text.TextCursor",
872  "com.sun.star.style.CharacterProperties",
873  "com.sun.star.style.CharacterPropertiesAsian",
874  "com.sun.star.style.CharacterPropertiesComplex",
875  "com.sun.star.style.ParagraphProperties",
876  "com.sun.star.style.ParagraphPropertiesAsian",
877  "com.sun.star.style.ParagraphPropertiesComplex",
878  "com.sun.star.text.TextSortable"
879  };
880 }
881 
882 const uno::Sequence< sal_Int8 > & SwXTextCursor::getUnoTunnelId()
883 {
884  static const comphelper::UnoIdInit theSwXTextCursorUnoTunnelId;
885  return theSwXTextCursorUnoTunnelId.getSeq();
886 }
887 
888 sal_Int64 SAL_CALL
889 SwXTextCursor::getSomething(const uno::Sequence< sal_Int8 >& rId)
890 {
891  const sal_Int64 nRet( comphelper::getSomethingImpl<SwXTextCursor>(rId, this) );
892  return nRet ? nRet : OTextCursorHelper::getSomething(rId);
893 }
894 
896 {
897  SolarMutexGuard aGuard;
898 
899  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
900 
901  if (rUnoCursor.HasMark())
902  {
903  if (*rUnoCursor.GetPoint() > *rUnoCursor.GetMark())
904  {
905  rUnoCursor.Exchange();
906  }
907  rUnoCursor.DeleteMark();
908  }
909 }
910 
912 {
913  SolarMutexGuard aGuard;
914 
915  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
916 
917  if (rUnoCursor.HasMark())
918  {
919  if (*rUnoCursor.GetPoint() < *rUnoCursor.GetMark())
920  {
921  rUnoCursor.Exchange();
922  }
923  rUnoCursor.DeleteMark();
924  }
925 }
926 
928 {
929  SolarMutexGuard aGuard;
930 
931  bool bRet = true;
932  auto pUnoCursor(m_pUnoCursor);
933  if(pUnoCursor && pUnoCursor->GetMark())
934  {
935  bRet = (*pUnoCursor->GetPoint() == *pUnoCursor->GetMark());
936  }
937  return bRet;
938 }
939 
940 sal_Bool SAL_CALL
941 SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand)
942 {
943  SolarMutexGuard aGuard;
944 
945  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
946 
947  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
948  bool bRet = rUnoCursor.Left( nCount);
949  if (CursorType::Meta == m_eType)
950  {
951  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
952  META_CHECK_BOTH)
953  && bRet;
954  }
955  return bRet;
956 }
957 
958 sal_Bool SAL_CALL
959 SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand)
960 {
961  SolarMutexGuard aGuard;
962 
963  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
964 
965  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
966  bool bRet = rUnoCursor.Right(nCount);
967  if (CursorType::Meta == m_eType)
968  {
969  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
970  META_CHECK_BOTH)
971  && bRet;
972  }
973  return bRet;
974 }
975 
976 void SAL_CALL
978 {
979  SolarMutexGuard aGuard;
980  comphelper::ProfileZone aZone("gotoStart");
981 
982  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
983 
984  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
985  if (CursorType::Body == m_eType)
986  {
987  rUnoCursor.Move( fnMoveBackward, GoInDoc );
988  //check, that the cursor is not in a table
989  SwTableNode * pTableNode = rUnoCursor.GetNode().FindTableNode();
990  SwContentNode * pCNode = nullptr;
991  while (pTableNode)
992  {
993  rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode();
994  pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode);
995  pTableNode = pCNode ? pCNode->FindTableNode() : nullptr;
996  }
997  if (pCNode)
998  {
999  rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
1000  }
1001  SwStartNode const*const pTmp =
1002  rUnoCursor.GetNode().StartOfSectionNode();
1003  if (pTmp->IsSectionNode())
1004  {
1005  SwSectionNode const*const pSectionStartNode =
1006  static_cast<SwSectionNode const*>(pTmp);
1007  if (pSectionStartNode->GetSection().IsHiddenFlag())
1008  {
1009  pCNode = GetDoc()->GetNodes().GoNextSection(
1010  &rUnoCursor.GetPoint()->nNode, true, false);
1011  if (pCNode)
1012  {
1013  rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0);
1014  }
1015  }
1016  }
1017  }
1018  else if ( (CursorType::Frame == m_eType)
1020  || (CursorType::Header == m_eType)
1021  || (CursorType::Footer == m_eType)
1023  || (CursorType::Redline == m_eType))
1024  {
1026  }
1027  else if (CursorType::Meta == m_eType)
1028  {
1029  lcl_ForceIntoMeta(rUnoCursor, m_xParentText, META_INIT_START);
1030  }
1031 }
1032 
1033 void SAL_CALL
1035 {
1036  SolarMutexGuard aGuard;
1037  comphelper::ProfileZone aZone("gotoEnd");
1038 
1039  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1040 
1041  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1042  if (CursorType::Body == m_eType)
1043  {
1044  rUnoCursor.Move( fnMoveForward, GoInDoc );
1045  }
1046  else if ( (CursorType::Frame == m_eType)
1048  || (CursorType::Header == m_eType)
1049  || (CursorType::Footer == m_eType)
1051  || (CursorType::Redline == m_eType))
1052  {
1053  rUnoCursor.MoveSection( GoCurrSection, fnSectionEnd);
1054  }
1055  else if (CursorType::Meta == m_eType)
1056  {
1057  lcl_ForceIntoMeta(rUnoCursor, m_xParentText, META_INIT_END);
1058  }
1059 }
1060 
1061 void SAL_CALL
1063  const uno::Reference< text::XTextRange > & xRange, sal_Bool bExpand)
1064 {
1065  SolarMutexGuard aGuard;
1066 
1067  if (!xRange.is())
1068  {
1069  throw uno::RuntimeException();
1070  }
1071 
1072  SwUnoCursor & rOwnCursor( GetCursorOrThrow() );
1073 
1074  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
1075  SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1076  OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1077 
1078  if (!pRange && !pCursor)
1079  {
1080  throw uno::RuntimeException();
1081  }
1082 
1083  SwPaM aPam(GetDoc()->GetNodes());
1084  const SwPaM * pPam(nullptr);
1085  if (pCursor)
1086  {
1087  pPam = pCursor->GetPaM();
1088  }
1089  else if (pRange)
1090  {
1091  if (pRange->GetPositions(aPam))
1092  {
1093  pPam = & aPam;
1094  }
1095  }
1096 
1097  if (!pPam)
1098  {
1099  throw uno::RuntimeException();
1100  }
1101 
1102  {
1103  SwStartNodeType eSearchNodeType = SwNormalStartNode;
1104  switch (m_eType)
1105  {
1106  case CursorType::Frame: eSearchNodeType = SwFlyStartNode; break;
1107  case CursorType::TableText: eSearchNodeType = SwTableBoxStartNode; break;
1108  case CursorType::Footnote: eSearchNodeType = SwFootnoteStartNode; break;
1109  case CursorType::Header: eSearchNodeType = SwHeaderStartNode; break;
1110  case CursorType::Footer: eSearchNodeType = SwFooterStartNode; break;
1111  //case CURSOR_INVALID:
1112  //case CursorType::Body:
1113  default:
1114  ;
1115  }
1116 
1117  const SwStartNode* pOwnStartNode = rOwnCursor.GetNode().FindSttNodeByType(eSearchNodeType);
1118  while ( pOwnStartNode != nullptr
1119  && pOwnStartNode->IsSectionNode())
1120  {
1121  pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1122  }
1123 
1124  const SwStartNode* pTmp =
1125  pPam->GetNode().FindSttNodeByType(eSearchNodeType);
1126  while ( pTmp != nullptr
1127  && pTmp->IsSectionNode() )
1128  {
1129  pTmp = pTmp->StartOfSectionNode();
1130  }
1131 
1132  if ( eSearchNodeType == SwTableBoxStartNode )
1133  {
1134  if (!pOwnStartNode || !pTmp)
1135  {
1136  throw uno::RuntimeException();
1137  }
1138 
1139  if ( pOwnStartNode->FindTableNode() != pTmp->FindTableNode() )
1140  {
1141  throw uno::RuntimeException();
1142  }
1143  }
1144  else
1145  {
1146  if ( pOwnStartNode != pTmp )
1147  {
1148  throw uno::RuntimeException();
1149  }
1150  }
1151  }
1152 
1153  if (CursorType::Meta == m_eType)
1154  {
1155  SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint());
1156  const bool bNotForced( lcl_ForceIntoMeta(
1157  CopyPam, m_xParentText, META_CHECK_BOTH) );
1158  if (!bNotForced)
1159  {
1160  throw uno::RuntimeException(
1161  "gotoRange: parameter range not contained in nesting"
1162  " text content for which this cursor was created",
1163  static_cast<text::XWordCursor*>(this));
1164  }
1165  }
1166 
1167  // selection has to be expanded here
1168  if(bExpand)
1169  {
1170  // cursor should include its previous range plus the given range
1171  const SwPosition aOwnLeft(*rOwnCursor.Start());
1172  const SwPosition aOwnRight(*rOwnCursor.End());
1173  SwPosition const& rParamLeft = *pPam->Start();
1174  SwPosition const& rParamRight = *pPam->End();
1175 
1176  // now there are four SwPositions,
1177  // two of them are going to be used, but which ones?
1178  if (aOwnRight > rParamRight)
1179  *rOwnCursor.GetPoint() = aOwnRight;
1180  else
1181  *rOwnCursor.GetPoint() = rParamRight;
1182  rOwnCursor.SetMark();
1183  if (aOwnLeft < rParamLeft)
1184  *rOwnCursor.GetMark() = aOwnLeft;
1185  else
1186  *rOwnCursor.GetMark() = rParamLeft;
1187  }
1188  else
1189  {
1190  // cursor should be the given range
1191  *rOwnCursor.GetPoint() = *pPam->GetPoint();
1192  if (pPam->HasMark())
1193  {
1194  rOwnCursor.SetMark();
1195  *rOwnCursor.GetMark() = *pPam->GetMark();
1196  }
1197  else
1198  {
1199  rOwnCursor.DeleteMark();
1200  }
1201  }
1202 }
1203 
1205 {
1206  SolarMutexGuard aGuard;
1207 
1208  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1209 
1210  const bool bRet =
1211  rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD );
1212  return bRet;
1213 }
1214 
1216 {
1217  SolarMutexGuard aGuard;
1218 
1219  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1220 
1221  const bool bRet =
1222  rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD );
1223  return bRet;
1224 }
1225 
1226 sal_Bool SAL_CALL
1228 {
1229  SolarMutexGuard aGuard;
1230 
1231  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1232 
1233  // problems arise when a paragraph starts with something other than a word
1234  bool bRet = false;
1235  // remember old position to check if cursor has moved
1236  // since the called functions are sometimes a bit unreliable
1237  // in specific cases...
1238  SwPosition *const pPoint = rUnoCursor.GetPoint();
1239  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1240  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1241 
1242  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1243  // end of paragraph
1244  if (rUnoCursor.GetContentNode() &&
1245  (pPoint->nContent == rUnoCursor.GetContentNode()->Len()))
1246  {
1247  rUnoCursor.Right(1);
1248  }
1249  else
1250  {
1251  const bool bTmp =
1252  rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
1253  // if there is no next word within the current paragraph
1254  // try to go to the start of the next paragraph
1255  if (!bTmp)
1256  {
1257  rUnoCursor.MovePara(GoNextPara, fnParaStart);
1258  }
1259  }
1260 
1261  // return true if cursor has moved
1262  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1263  (pPoint->nContent.GetIndex() != nOldIndex);
1264  if (bRet && (CursorType::Meta == m_eType))
1265  {
1266  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1267  META_CHECK_BOTH);
1268  }
1269 
1270  return bRet;
1271 }
1272 
1273 sal_Bool SAL_CALL
1275 {
1276  SolarMutexGuard aGuard;
1277 
1278  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1279 
1280  // white spaces create problems on the paragraph start
1281  bool bRet = false;
1282  SwPosition *const pPoint = rUnoCursor.GetPoint();
1283  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1284  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1285 
1286  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1287  // start of paragraph?
1288  if (pPoint->nContent == 0)
1289  {
1290  rUnoCursor.Left(1);
1291  }
1292  else
1293  {
1294  rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
1295  if (pPoint->nContent == 0)
1296  {
1297  rUnoCursor.Left(1);
1298  }
1299  }
1300 
1301  // return true if cursor has moved
1302  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1303  (pPoint->nContent.GetIndex() != nOldIndex);
1304  if (bRet && (CursorType::Meta == m_eType))
1305  {
1306  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1307  META_CHECK_BOTH);
1308  }
1309 
1310  return bRet;
1311 }
1312 
1313 sal_Bool SAL_CALL
1315 {
1316  SolarMutexGuard aGuard;
1317 
1318  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1319 
1320  bool bRet = false;
1321  SwPosition *const pPoint = rUnoCursor.GetPoint();
1322  SwNode & rOldNode = pPoint->nNode.GetNode();
1323  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1324 
1325  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1326  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1327  if (!rUnoCursor.IsEndWordWT( nWordType ))
1328  {
1329  rUnoCursor.GoEndWordWT( nWordType );
1330  }
1331 
1332  // restore old cursor if we are not at the end of a word by now
1333  // otherwise use current one
1334  bRet = rUnoCursor.IsEndWordWT( nWordType );
1335  if (!bRet)
1336  {
1337  pPoint->nNode = rOldNode;
1338  pPoint->nContent = nOldIndex;
1339  }
1340  else if (CursorType::Meta == m_eType)
1341  {
1342  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1343  META_CHECK_BOTH);
1344  }
1345 
1346  return bRet;
1347 }
1348 
1349 sal_Bool SAL_CALL
1351 {
1352  SolarMutexGuard aGuard;
1353 
1354  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1355 
1356  bool bRet = false;
1357  SwPosition *const pPoint = rUnoCursor.GetPoint();
1358  SwNode & rOldNode = pPoint->nNode.GetNode();
1359  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1360 
1361  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1362  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1363  if (!rUnoCursor.IsStartWordWT( nWordType ))
1364  {
1365  rUnoCursor.GoStartWordWT( nWordType );
1366  }
1367 
1368  // restore old cursor if we are not at the start of a word by now
1369  // otherwise use current one
1370  bRet = rUnoCursor.IsStartWordWT( nWordType );
1371  if (!bRet)
1372  {
1373  pPoint->nNode = rOldNode;
1374  pPoint->nContent = nOldIndex;
1375  }
1376  else if (CursorType::Meta == m_eType)
1377  {
1378  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1379  META_CHECK_BOTH);
1380  }
1381 
1382  return bRet;
1383 }
1384 
1385 sal_Bool SAL_CALL
1387 {
1388  SolarMutexGuard aGuard;
1389 
1390  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1391 
1392  // start of paragraph?
1393  bool bRet = rUnoCursor.GetPoint()->nContent == 0;
1394  // with mark ->no sentence start
1395  // (check if cursor is no selection, i.e. it does not have
1396  // a mark or else point and mark are identical)
1397  if (!bRet && (!rUnoCursor.HasMark() ||
1398  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1399  {
1400  SwCursor aCursor(*rUnoCursor.GetPoint(),nullptr);
1401  SwPosition aOrigPos = *aCursor.GetPoint();
1402  aCursor.GoSentence(SwCursor::START_SENT );
1403  bRet = aOrigPos == *aCursor.GetPoint();
1404  }
1405  return bRet;
1406 }
1407 
1408 sal_Bool SAL_CALL
1410 {
1411  SolarMutexGuard aGuard;
1412 
1413  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1414 
1415  // end of paragraph?
1416  bool bRet = rUnoCursor.GetContentNode() &&
1417  (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetContentNode()->Len());
1418  // with mark->no sentence end
1419  // (check if cursor is no selection, i.e. it does not have
1420  // a mark or else point and mark are identical)
1421  if (!bRet && (!rUnoCursor.HasMark() ||
1422  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1423  {
1424  SwCursor aCursor(*rUnoCursor.GetPoint(), nullptr);
1425  SwPosition aOrigPos = *aCursor.GetPoint();
1426  aCursor.GoSentence(SwCursor::END_SENT);
1427  bRet = aOrigPos == *aCursor.GetPoint();
1428  }
1429  return bRet;
1430 }
1431 
1432 sal_Bool SAL_CALL
1434 {
1435  SolarMutexGuard aGuard;
1436 
1437  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1438 
1439  const bool bWasEOS = isEndOfSentence();
1440  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1441  bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT);
1442  if (!bRet)
1443  {
1444  bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1445  }
1446 
1447  // if at the end of the sentence (i.e. at the space after the '.')
1448  // advance to next word in order for GoSentence to work properly
1449  // next time and have isStartOfSentence return true after this call
1450  if (!rUnoCursor.IsStartWordWT(css::i18n::WordType::ANYWORD_IGNOREWHITESPACES))
1451  {
1452  const bool bNextWord = rUnoCursor.GoNextWordWT(i18n::WordType::ANYWORD_IGNOREWHITESPACES);
1453  if (bWasEOS && !bNextWord)
1454  {
1455  bRet = false;
1456  }
1457  }
1458  if (CursorType::Meta == m_eType)
1459  {
1460  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1461  META_CHECK_BOTH)
1462  && bRet;
1463  }
1464  return bRet;
1465 }
1466 
1467 sal_Bool SAL_CALL
1469 {
1470  SolarMutexGuard aGuard;
1471 
1472  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1473 
1474  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1475  bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1476  if (!bRet)
1477  {
1478  bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1479  if (bRet)
1480  {
1481  rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1482  // at the end of a paragraph move to the sentence end again
1483  rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1484  }
1485  }
1486  if (CursorType::Meta == m_eType)
1487  {
1488  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1489  META_CHECK_BOTH)
1490  && bRet;
1491  }
1492  return bRet;
1493 }
1494 
1495 sal_Bool SAL_CALL
1497 {
1498  SolarMutexGuard aGuard;
1499 
1500  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1501 
1502  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1503  // if we're at the para start then we won't move
1504  // but bRet is also true if GoSentence failed but
1505  // the start of the sentence is reached
1506  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor)
1507  || rUnoCursor.GoSentence(SwCursor::START_SENT)
1508  || SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1509  if (CursorType::Meta == m_eType)
1510  {
1511  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1512  META_CHECK_BOTH)
1513  && bRet;
1514  }
1515  return bRet;
1516 }
1517 
1518 sal_Bool SAL_CALL
1520 {
1521  SolarMutexGuard aGuard;
1522 
1523  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1524 
1525  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1526  // bRet is true if GoSentence() succeeded or if the
1527  // MovePara() succeeded while the end of the para is
1528  // not reached already
1529  bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1530  bool bRet = !bAlreadyParaEnd
1531  && (rUnoCursor.GoSentence(SwCursor::END_SENT)
1532  || rUnoCursor.MovePara(GoCurrPara, fnParaEnd));
1533  if (CursorType::Meta == m_eType)
1534  {
1535  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1536  META_CHECK_BOTH)
1537  && bRet;
1538  }
1539  return bRet;
1540 }
1541 
1542 sal_Bool SAL_CALL
1544 {
1545  SolarMutexGuard aGuard;
1546 
1547  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1548 
1549  const bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1550  return bRet;
1551 }
1552 
1553 sal_Bool SAL_CALL
1555 {
1556  SolarMutexGuard aGuard;
1557 
1558  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1559 
1560  const bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1561  return bRet;
1562 }
1563 
1564 sal_Bool SAL_CALL
1566 {
1567  SolarMutexGuard aGuard;
1568 
1569  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1570 
1571  if (CursorType::Meta == m_eType)
1572  {
1573  return false;
1574  }
1575  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1576  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1577  if (!bRet)
1578  {
1579  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaStart);
1580  }
1581 
1582  // since MovePara(GoCurrPara, fnParaStart) only returns false
1583  // if we were already at the start of the paragraph this function
1584  // should always complete successfully.
1585  OSL_ENSURE( bRet, "gotoStartOfParagraph failed" );
1586  return bRet;
1587 }
1588 
1589 sal_Bool SAL_CALL
1591 {
1592  SolarMutexGuard aGuard;
1593 
1594  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1595 
1596  if (CursorType::Meta == m_eType)
1597  {
1598  return false;
1599  }
1600  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1601  bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1602  if (!bRet)
1603  {
1604  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1605  }
1606 
1607  // since MovePara(GoCurrPara, fnParaEnd) only returns false
1608  // if we were already at the end of the paragraph this function
1609  // should always complete successfully.
1610  OSL_ENSURE( bRet, "gotoEndOfParagraph failed" );
1611  return bRet;
1612 }
1613 
1614 sal_Bool SAL_CALL
1616 {
1617  SolarMutexGuard aGuard;
1618 
1619  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1620 
1621  if (CursorType::Meta == m_eType)
1622  {
1623  return false;
1624  }
1625  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1626  const bool bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1627  return bRet;
1628 }
1629 
1630 sal_Bool SAL_CALL
1632 {
1633  SolarMutexGuard aGuard;
1634 
1635  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1636 
1637  if (CursorType::Meta == m_eType)
1638  {
1639  return false;
1640  }
1641  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1642  const bool bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1643  return bRet;
1644 }
1645 
1646 uno::Reference< text::XText > SAL_CALL
1648 {
1649  SolarMutexGuard g;
1650 
1651  return m_xParentText;
1652 }
1653 
1654 uno::Reference< text::XTextRange > SAL_CALL
1656 {
1657  SolarMutexGuard aGuard;
1658 
1659  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1660 
1661  uno::Reference< text::XTextRange > xRet;
1662  SwPaM aPam(*rUnoCursor.Start());
1663  const uno::Reference< text::XText > xParent = getText();
1664  if (CursorType::Meta == m_eType)
1665  {
1666  // return cursor to prevent modifying SwXTextRange for META
1668  new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1669  *rUnoCursor.GetPoint()) );
1670  pXCursor->gotoStart(false);
1671  xRet = static_cast<text::XWordCursor*>(pXCursor.get());
1672  }
1673  else
1674  {
1675  xRet = new SwXTextRange(aPam, xParent);
1676  }
1677  return xRet;
1678 }
1679 
1680 uno::Reference< text::XTextRange > SAL_CALL
1682 {
1683  SolarMutexGuard aGuard;
1684 
1685  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1686 
1687  uno::Reference< text::XTextRange > xRet;
1688  SwPaM aPam(*rUnoCursor.End());
1689  const uno::Reference< text::XText > xParent = getText();
1690  if (CursorType::Meta == m_eType)
1691  {
1692  // return cursor to prevent modifying SwXTextRange for META
1694  new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1695  *rUnoCursor.GetPoint()) );
1696  pXCursor->gotoEnd(false);
1697  xRet = static_cast<text::XWordCursor*>(pXCursor.get());
1698  }
1699  else
1700  {
1701  xRet = new SwXTextRange(aPam, xParent);
1702  }
1703  return xRet;
1704 }
1705 
1706 OUString SAL_CALL SwXTextCursor::getString()
1707 {
1708  SolarMutexGuard aGuard;
1709 
1710  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1711 
1712  OUString aText;
1713  SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aText);
1714  return aText;
1715 }
1716 
1717 void SAL_CALL
1718 SwXTextCursor::setString(const OUString& aString)
1719 {
1720  SolarMutexGuard aGuard;
1721 
1722  GetCursorOrThrow(); // just to check if valid
1723 
1724  const bool bForceExpandHints( (CursorType::Meta == m_eType)
1725  && dynamic_cast<SwXMeta&>(*m_xParentText)
1726  .CheckForOwnMemberMeta(*GetPaM(), true) );
1727  DeleteAndInsert(aString, bForceExpandHints);
1728 }
1729 
1731  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1732  std::u16string_view rPropertyName)
1733 {
1734  uno::Any aAny;
1735  SfxItemPropertyMapEntry const*const pEntry =
1736  rPropSet.getPropertyMap().getByName(rPropertyName);
1737 
1738  if (!pEntry)
1739  {
1740  throw beans::UnknownPropertyException(
1741  OUString::Concat("Unknown property: ") + rPropertyName,
1742  static_cast<cppu::OWeakObject *>(nullptr));
1743  }
1744 
1745  beans::PropertyState eTemp;
1746  const bool bDone = SwUnoCursorHelper::getCursorPropertyValue(
1747  *pEntry, rPaM, &aAny, eTemp );
1748 
1749  if (!bDone)
1750  {
1753  RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER>
1754  aSet(rPaM.GetDoc().GetAttrPool());
1755 
1757 
1758  rPropSet.getPropertyValue(*pEntry, aSet, aAny);
1759  }
1760 
1761  return aAny;
1762 }
1763 
1765  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1766  const OUString& rPropertyName,
1767  const uno::Any& rValue,
1768  const SetAttrMode nAttrMode)
1769 {
1770  uno::Sequence< beans::PropertyValue > aValues{ comphelper::makePropertyValue(rPropertyName,
1771  rValue)};
1772  SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode);
1773 }
1774 
1775 // FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
1776 // SwUnoCursorHelper::SetTextFormatColl, instead of extending item set.
1777 // We need to get them from nodes in next call to GetCursorAttr.
1778 // The rest could cause similar problems in theory, so we just list them here.
1779 static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
1780 {
1781  return nWID == FN_UNO_PARA_STYLE ||
1782  nWID == FN_UNO_CHARFMT_SEQUENCE ||
1783  nWID == FN_UNO_NUM_START_VALUE ||
1784  nWID == FN_UNO_NUM_RULES;
1785 }
1786 
1788  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1789  const uno::Sequence< beans::PropertyValue > &rPropertyValues,
1790  const SetAttrMode nAttrMode)
1791 {
1792  if (!rPropertyValues.hasElements())
1793  return;
1794 
1795  SwDoc& rDoc = rPaM.GetDoc();
1796  OUString aUnknownExMsg, aPropertyVetoExMsg;
1797 
1798  // Build set of attributes we want to fetch
1799  WhichRangesContainer aRanges;
1800  std::vector<std::pair<const SfxItemPropertyMapEntry*, const uno::Any&>> aEntries;
1801  aEntries.reserve(rPropertyValues.getLength());
1802  for (const auto& rPropVal : rPropertyValues)
1803  {
1804  const OUString &rPropertyName = rPropVal.Name;
1805 
1806  SfxItemPropertyMapEntry const* pEntry =
1807  rPropSet.getPropertyMap().getByName(rPropertyName);
1808 
1809  // Queue up any exceptions until the end ...
1810  if (!pEntry)
1811  {
1812  aUnknownExMsg += "Unknown property: '" + rPropertyName + "' ";
1813  continue;
1814  }
1815  else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1816  {
1817  aPropertyVetoExMsg += "Property is read-only: '" + rPropertyName + "' ";
1818  continue;
1819  }
1820  aRanges = aRanges.MergeRange(pEntry->nWID, pEntry->nWID);
1821  aEntries.emplace_back(pEntry, rPropVal.Value);
1822  }
1823 
1824  if (!aEntries.empty())
1825  {
1826  // Fetch, overwrite, and re-set the attributes from the core
1827  SfxItemSet aItemSet(rDoc.GetAttrPool(), aRanges);
1828 
1829  bool bPreviousPropertyCausesSideEffectsInNodes = false;
1830  for (size_t i = 0; i < aEntries.size(); ++i)
1831  {
1832  SfxItemPropertyMapEntry const*const pEntry = aEntries[i].first;
1833  bool bPropertyCausesSideEffectsInNodes =
1835 
1836  // we need to get up-to-date item set from nodes
1837  if (i == 0 || bPreviousPropertyCausesSideEffectsInNodes)
1838  {
1839  aItemSet.ClearItem();
1840  SwUnoCursorHelper::GetCursorAttr(rPaM, aItemSet);
1841  }
1842 
1843  const uno::Any &rValue = aEntries[i].second;
1844  // this can set some attributes in nodes' mpAttrSet
1845  if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet))
1846  rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
1847 
1848  if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
1849  SwUnoCursorHelper::SetCursorAttr(rPaM, aItemSet, nAttrMode, false/*bTableMode*/);
1850 
1851  bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
1852  }
1853  }
1854 
1855  if (!aUnknownExMsg.isEmpty())
1856  throw beans::UnknownPropertyException(aUnknownExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1857  if (!aPropertyVetoExMsg.isEmpty())
1858  throw beans::PropertyVetoException(aPropertyVetoExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1859 }
1860 
1861 namespace
1862 {
1863  bool NotInRange(sal_uInt16 nWID, sal_uInt16 nStart, sal_uInt16 nEnd)
1864  {
1865  return nWID < nStart || nWID > nEnd;
1866  }
1867 }
1868 
1869 uno::Sequence< beans::PropertyState >
1871  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1872  const uno::Sequence< OUString >& rPropertyNames,
1873  const SwGetPropertyStatesCaller eCaller)
1874 {
1875  const OUString* pNames = rPropertyNames.getConstArray();
1876  uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
1877  beans::PropertyState* pStates = aRet.getArray();
1878  const SfxItemPropertyMap &rMap = rPropSet.getPropertyMap();
1879  std::optional<SfxItemSet> oSet;
1880  std::optional<SfxItemSet> oSetParent;
1881 
1882  for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++)
1883  {
1884  SfxItemPropertyMapEntry const*const pEntry =
1885  rMap.getByName( pNames[i] );
1886  if(!pEntry)
1887  {
1888  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
1889  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
1890  {
1891  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1892  continue;
1893  }
1895  eCaller)
1896  {
1897  //this values marks the element as unknown property
1898  pStates[i] = beans::PropertyState::PropertyState_MAKE_FIXED_SIZE;
1899  continue;
1900  }
1901  else
1902  {
1903  throw beans::UnknownPropertyException(
1904  "Unknown property: " + pNames[i],
1905  static_cast<cppu::OWeakObject *>(nullptr));
1906  }
1907  }
1908  if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) ||
1910  NotInRange(pEntry->nWID, FN_UNO_RANGE_BEGIN, FN_UNO_RANGE_END) &&
1911  NotInRange(pEntry->nWID, RES_CHRATR_BEGIN, RES_TXTATR_END) )
1912  {
1913  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1914  }
1915  else
1916  {
1917  if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN &&
1918  pEntry->nWID <= FN_UNO_RANGE_END )
1919  {
1921  *pEntry, rPaM, nullptr, pStates[i] );
1922  }
1923  else
1924  {
1925  if (!oSet)
1926  {
1927  switch ( eCaller )
1928  {
1931  oSet.emplace( rPaM.GetDoc().GetAttrPool(),
1932  svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END> );
1933  break;
1935  oSet.emplace( rPaM.GetDoc().GetAttrPool(),
1936  pEntry->nWID, pEntry->nWID );
1937  break;
1938  default:
1939  oSet.emplace(
1940  rPaM.GetDoc().GetAttrPool(),
1941  svl::Items<
1944  RES_UNKNOWNATR_CONTAINER>);
1945  }
1946  // #i63870#
1947  SwUnoCursorHelper::GetCursorAttr( rPaM, *oSet );
1948  }
1949 
1950  pStates[i] = ( oSet->Count() )
1951  ? rPropSet.getPropertyState( *pEntry, *oSet )
1952  : beans::PropertyState_DEFAULT_VALUE;
1953 
1954  //try again to find out if a value has been inherited
1955  if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
1956  {
1957  if (!oSetParent)
1958  {
1959  oSetParent.emplace(oSet->CloneAsValue( false ));
1960  // #i63870#
1962  rPaM, *oSetParent, true, false );
1963  }
1964 
1965  pStates[i] = ( oSetParent->Count() )
1966  ? rPropSet.getPropertyState( *pEntry, *oSetParent )
1967  : beans::PropertyState_DEFAULT_VALUE;
1968  }
1969  }
1970  }
1971  }
1972  return aRet;
1973 }
1974 
1976  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1977  const OUString& rPropertyName)
1978 {
1979  uno::Sequence< OUString > aStrings { rPropertyName };
1980  uno::Sequence< beans::PropertyState > aSeq =
1981  GetPropertyStates(rPaM, rPropSet, aStrings,
1983  return aSeq[0];
1984 }
1985 
1986 static void
1988  o3tl::sorted_vector<sal_uInt16> const &rWhichIds )
1989 {
1990  // if we are resetting paragraph attributes, we need to select the full paragraph first
1991  SwPosition aStart = *rPaM.Start();
1992  SwPosition aEnd = *rPaM.End();
1993  auto pTemp ( rDoc.CreateUnoCursor(aStart) );
1995  {
1996  pTemp->MovePara(GoCurrPara, fnParaStart);
1997  }
1998  pTemp->SetMark();
1999  *pTemp->GetPoint() = aEnd;
2000  SwUnoCursorHelper::SelectPam(*pTemp, true);
2001  if(!SwUnoCursorHelper::IsEndOfPara(*pTemp))
2002  {
2003  pTemp->MovePara(GoCurrPara, fnParaEnd);
2004  }
2005  rDoc.ResetAttrs(*pTemp, true, rWhichIds);
2006 }
2007 
2009  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
2010  std::u16string_view rPropertyName)
2011 {
2012  SwDoc& rDoc = rPaM.GetDoc();
2013  SfxItemPropertyMapEntry const*const pEntry =
2014  rPropSet.getPropertyMap().getByName(rPropertyName);
2015  if (!pEntry)
2016  {
2017  throw beans::UnknownPropertyException(
2018  OUString::Concat("Unknown property: ") + rPropertyName,
2019  static_cast<cppu::OWeakObject *>(nullptr));
2020  }
2021 
2022  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2023  {
2024  throw uno::RuntimeException(
2025  OUString::Concat("setPropertyToDefault: property is read-only: ")
2026  + rPropertyName, nullptr);
2027  }
2028 
2029  if (pEntry->nWID < RES_FRMATR_END)
2030  {
2031  const o3tl::sorted_vector<sal_uInt16> aWhichIds{ pEntry->nWID };
2032  if (pEntry->nWID < RES_PARATR_BEGIN)
2033  {
2034  rDoc.ResetAttrs(rPaM, true, aWhichIds);
2035  }
2036  else
2037  {
2038  lcl_SelectParaAndReset ( rPaM, rDoc, aWhichIds );
2039  }
2040  }
2041  else
2042  {
2044  }
2045 }
2046 
2048  SwPaM const & rPaM, const SfxItemPropertySet& rPropSet,
2049  std::u16string_view rPropertyName)
2050 {
2051  SfxItemPropertyMapEntry const*const pEntry =
2052  rPropSet.getPropertyMap().getByName(rPropertyName);
2053  if (!pEntry)
2054  {
2055  throw beans::UnknownPropertyException(
2056  OUString::Concat("Unknown property: ") + rPropertyName,
2057  static_cast<cppu::OWeakObject *>(nullptr));
2058  }
2059 
2060  uno::Any aRet;
2061  if (pEntry->nWID < RES_FRMATR_END)
2062  {
2063  SwDoc& rDoc = rPaM.GetDoc();
2064  const SfxPoolItem& rDefItem =
2065  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2066  rDefItem.QueryValue(aRet, pEntry->nMemberId);
2067  }
2068  return aRet;
2069 }
2070 
2071 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2073 {
2074  SolarMutexGuard g;
2075 
2076  static uno::Reference< beans::XPropertySetInfo > xRef = [&]()
2077  {
2078  static SfxItemPropertyMapEntry const aCursorExtMap_Impl[] =
2079  {
2082  { u"", 0, css::uno::Type(), 0, 0 }
2083  };
2084  const uno::Reference< beans::XPropertySetInfo > xInfo =
2086  // extend PropertySetInfo!
2087  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2089  aCursorExtMap_Impl,
2090  aPropSeq ));
2091  }();
2092  return xRef;
2093 }
2094 
2095 void SAL_CALL
2097  const OUString& rPropertyName, const uno::Any& rValue)
2098 {
2099  SolarMutexGuard aGuard;
2100 
2101  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2102 
2103  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2104  {
2105  bool bSet(false);
2106  if (!(rValue >>= bSet))
2107  {
2108  throw lang::IllegalArgumentException();
2109  }
2110  rUnoCursor.SetSkipOverHiddenSections(bSet);
2111  }
2112  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2113  {
2114  bool bSet(false);
2115  if (!(rValue >>= bSet))
2116  {
2117  throw lang::IllegalArgumentException();
2118  }
2119  rUnoCursor.SetSkipOverProtectSections(bSet);
2120  }
2121  else if (rPropertyName == UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES)
2122  {
2123  SwTextNode* pTextNode= GetPaM()->GetNode().GetTextNode();
2124 
2125  if(pTextNode)
2126  {
2128  }
2129  }
2130  else
2131  {
2133  m_rPropSet, rPropertyName, rValue);
2134  }
2135 }
2136 
2137 uno::Any SAL_CALL
2138 SwXTextCursor::getPropertyValue(const OUString& rPropertyName)
2139 {
2140  SolarMutexGuard aGuard;
2141 
2142  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2143 
2144  uno::Any aAny;
2145  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2146  {
2147  const bool bSet = rUnoCursor.IsSkipOverHiddenSections();
2148  aAny <<= bSet;
2149  }
2150  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2151  {
2152  const bool bSet = rUnoCursor.IsSkipOverProtectSections();
2153  aAny <<= bSet;
2154  }
2155  else
2156  {
2157  aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor,
2158  m_rPropSet, rPropertyName);
2159  }
2160  return aAny;
2161 }
2162 
2163 void SAL_CALL
2165  const OUString& /*rPropertyName*/,
2166  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2167 {
2168  OSL_FAIL("SwXTextCursor::addPropertyChangeListener(): not implemented");
2169 }
2170 
2171 void SAL_CALL
2173  const OUString& /*rPropertyName*/,
2174  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2175 {
2176  OSL_FAIL("SwXTextCursor::removePropertyChangeListener(): not implemented");
2177 }
2178 
2179 void SAL_CALL
2181  const OUString& /*rPropertyName*/,
2182  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2183 {
2184  OSL_FAIL("SwXTextCursor::addVetoableChangeListener(): not implemented");
2185 }
2186 
2187 void SAL_CALL
2189  const OUString& /*rPropertyName*/,
2190  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2191 {
2192  OSL_FAIL("SwXTextCursor::removeVetoableChangeListener(): not implemented");
2193 }
2194 
2195 beans::PropertyState SAL_CALL
2196 SwXTextCursor::getPropertyState(const OUString& rPropertyName)
2197 {
2198  SolarMutexGuard aGuard;
2199 
2200  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2201 
2202  const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState(
2203  rUnoCursor, m_rPropSet, rPropertyName);
2204  return eRet;
2205 }
2206 
2207 uno::Sequence< beans::PropertyState > SAL_CALL
2209  const uno::Sequence< OUString >& rPropertyNames)
2210 {
2211  SolarMutexGuard aGuard;
2212 
2213  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2214 
2216  rUnoCursor, m_rPropSet, rPropertyNames);
2217 }
2218 
2219 void SAL_CALL
2220 SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName)
2221 {
2222  // forward: need no solar mutex here
2223  uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2224  setPropertiesToDefault ( aSequence );
2225 }
2226 
2227 uno::Any SAL_CALL
2228 SwXTextCursor::getPropertyDefault(const OUString& rPropertyName)
2229 {
2230  // forward: need no solar mutex here
2231  const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2232  return getPropertyDefaults ( aSequence ).getConstArray()[0];
2233 }
2234 
2236  const uno::Sequence< OUString >& aPropertyNames,
2237  const uno::Sequence< uno::Any >& aValues )
2238 {
2239  if( aValues.getLength() != aPropertyNames.getLength() )
2240  {
2241  OSL_FAIL( "mis-matched property value sequences" );
2242  throw lang::IllegalArgumentException();
2243  }
2244 
2245  SolarMutexGuard aGuard;
2246 
2247  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2248 
2249  // a little lame to have to copy into this.
2250  uno::Sequence< beans::PropertyValue > aPropertyValues( aValues.getLength() );
2251  auto aPropertyValuesRange = asNonConstRange(aPropertyValues);
2252  for ( sal_Int32 i = 0; i < aPropertyNames.getLength(); i++ )
2253  {
2254  if ( aPropertyNames[ i ] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2255  aPropertyNames[ i ] == UNO_NAME_IS_SKIP_PROTECTED_TEXT )
2256  {
2257  // the behaviour of these is hard to model in a group
2258  OSL_FAIL("invalid property name for batch setting");
2259  throw lang::IllegalArgumentException();
2260  }
2261  aPropertyValuesRange[ i ].Name = aPropertyNames[ i ];
2262  aPropertyValuesRange[ i ].Value = aValues[ i ];
2263  }
2264  try
2265  {
2267  }
2268  catch (const css::beans::UnknownPropertyException& e)
2269  {
2271  throw lang::WrappedTargetException(
2272  "wrapped Exception " + e.Message,
2273  uno::Reference<uno::XInterface>(), a);
2274  }
2275 }
2276 
2277 uno::Sequence< uno::Any > SAL_CALL
2278 SwXTextCursor::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames )
2279 {
2280  // a banal implementation for now
2281  uno::Sequence< uno::Any > aValues( aPropertyNames.getLength() );
2282  std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.getArray(),
2283  [this](const OUString& rName) -> uno::Any { return getPropertyValue( rName ); });
2284  return aValues;
2285 }
2286 
2288  const uno::Sequence< OUString >& /* aPropertyNames */,
2289  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2290 {
2291  OSL_FAIL("SwXTextCursor::addPropertiesChangeListener(): not implemented");
2292 }
2294  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2295 {
2296  OSL_FAIL("SwXTextCursor::removePropertiesChangeListener(): not implemented");
2297 }
2298 
2300  const uno::Sequence< OUString >& /* aPropertyNames */,
2301  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2302 {
2303  OSL_FAIL("SwXTextCursor::firePropertiesChangeEvent(): not implemented");
2304 }
2305 
2306 // para specific attribute ranges
2307 static sal_uInt16 g_ParaResetableSetRange[] = {
2312  0
2313 };
2314 
2315 // selection specific attribute ranges
2316 static sal_uInt16 g_ResetableSetRange[] = {
2317  RES_CHRATR_BEGIN, RES_CHRATR_END-1,
2322  0
2323 };
2324 
2325 static void
2326 lcl_EnumerateIds(sal_uInt16 const* pIdRange, o3tl::sorted_vector<sal_uInt16> &rWhichIds)
2327 {
2328  while (*pIdRange)
2329  {
2330  const sal_uInt16 nStart = *pIdRange++;
2331  const sal_uInt16 nEnd = *pIdRange++;
2332  for (sal_uInt16 nId = nStart + 1; nId <= nEnd; ++nId)
2333  {
2334  rWhichIds.insert( nId );
2335  }
2336  }
2337 }
2338 
2339 void SAL_CALL
2341 {
2342  SolarMutexGuard aGuard;
2343 
2344  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2345 
2346  o3tl::sorted_vector<sal_uInt16> aParaWhichIds;
2348  lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds);
2349  lcl_EnumerateIds(g_ResetableSetRange, aWhichIds);
2350  if (!aParaWhichIds.empty())
2351  {
2352  lcl_SelectParaAndReset(rUnoCursor, rUnoCursor.GetDoc(),
2353  aParaWhichIds);
2354  }
2355  if (!aWhichIds.empty())
2356  {
2357  rUnoCursor.GetDoc().ResetAttrs(rUnoCursor, true, aWhichIds);
2358  }
2359 }
2360 
2361 void SAL_CALL
2363  const uno::Sequence< OUString >& rPropertyNames)
2364 {
2365  SolarMutexGuard aGuard;
2366 
2367  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2368 
2369  if ( !rPropertyNames.hasElements() )
2370  return;
2371 
2372  SwDoc& rDoc = rUnoCursor.GetDoc();
2374  o3tl::sorted_vector<sal_uInt16> aParaWhichIds;
2375  for (const OUString& rName : rPropertyNames)
2376  {
2377  SfxItemPropertyMapEntry const*const pEntry =
2378  m_rPropSet.getPropertyMap().getByName( rName );
2379  if (!pEntry)
2380  {
2381  if (rName == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2383  {
2384  continue;
2385  }
2386  throw beans::UnknownPropertyException(
2387  "Unknown property: " + rName,
2388  static_cast<cppu::OWeakObject *>(this));
2389  }
2390  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2391  {
2392  throw uno::RuntimeException(
2393  "setPropertiesToDefault: property is read-only: " + rName,
2394  static_cast<cppu::OWeakObject *>(this));
2395  }
2396 
2397  if (pEntry->nWID < RES_FRMATR_END)
2398  {
2399  if (pEntry->nWID < RES_PARATR_BEGIN)
2400  {
2401  aWhichIds.insert( pEntry->nWID );
2402  }
2403  else
2404  {
2405  aParaWhichIds.insert( pEntry->nWID );
2406  }
2407  }
2408  else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
2409  {
2410  SwUnoCursorHelper::resetCursorPropertyValue(*pEntry, rUnoCursor);
2411  }
2412  }
2413 
2414  if (!aParaWhichIds.empty())
2415  {
2416  lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
2417  }
2418  if (!aWhichIds.empty())
2419  {
2420  rDoc.ResetAttrs(rUnoCursor, true, aWhichIds);
2421  }
2422 }
2423 
2424 uno::Sequence< uno::Any > SAL_CALL
2426  const uno::Sequence< OUString >& rPropertyNames)
2427 {
2428  SolarMutexGuard aGuard;
2429 
2430  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2431 
2432  const sal_Int32 nCount = rPropertyNames.getLength();
2433  uno::Sequence< uno::Any > aRet(nCount);
2434  if ( nCount )
2435  {
2436  SwDoc& rDoc = rUnoCursor.GetDoc();
2437  const OUString *pNames = rPropertyNames.getConstArray();
2438  uno::Any *pAny = aRet.getArray();
2439  for (sal_Int32 i = 0; i < nCount; i++)
2440  {
2441  SfxItemPropertyMapEntry const*const pEntry =
2442  m_rPropSet.getPropertyMap().getByName( pNames[i] );
2443  if (!pEntry)
2444  {
2445  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2446  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2447  {
2448  continue;
2449  }
2450  throw beans::UnknownPropertyException(
2451  "Unknown property: " + pNames[i],
2452  static_cast<cppu::OWeakObject *>(nullptr));
2453  }
2454  if (pEntry->nWID < RES_FRMATR_END)
2455  {
2456  const SfxPoolItem& rDefItem =
2457  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2458  rDefItem.QueryValue(pAny[i], pEntry->nMemberId);
2459  }
2460  }
2461  }
2462  return aRet;
2463 }
2464 
2465 void SAL_CALL SwXTextCursor::invalidateMarkings(::sal_Int32 nType)
2466 {
2467  SolarMutexGuard aGuard;
2468 
2469  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2470 
2471  SwNode& node = rUnoCursor.GetNode();
2472 
2473  SwTextNode* txtNode = node.GetTextNode();
2474 
2475  if (txtNode == nullptr) return;
2476 
2477  if ( text::TextMarkupType::SPELLCHECK == nType )
2478  {
2480  txtNode->ClearWrong();
2481  }
2482  else if( text::TextMarkupType::PROOFREADING == nType )
2483  {
2484  txtNode->SetGrammarCheckDirty(true);
2485  txtNode->ClearGrammarCheck();
2486  }
2487  else if ( text::TextMarkupType::SMARTTAG == nType )
2488  {
2489  txtNode->SetSmartTagDirty(true);
2490  txtNode->ClearSmartTags();
2491  }
2492  else return;
2493 
2494  SwFormatColl* fmtColl=txtNode->GetFormatColl();
2495 
2496  if (fmtColl == nullptr) return;
2497 
2498  SwFormatChg aNew( fmtColl );
2499  txtNode->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aNew));
2500 }
2501 
2502 void SAL_CALL
2504  const OUString& rRedlineType,
2505  const uno::Sequence< beans::PropertyValue >& rRedlineProperties)
2506 {
2507  SolarMutexGuard aGuard;
2508 
2509  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2510 
2511  SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties);
2512 }
2513 
2514 void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL,
2515  const uno::Sequence< beans::PropertyValue >& rOptions)
2516 {
2517  SolarMutexGuard aGuard;
2518 
2519  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2520 
2521  SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions);
2522 }
2523 
2524 uno::Sequence< beans::PropertyValue >
2526 {
2527  uno::Sequence< beans::PropertyValue > aRet(5);
2528  beans::PropertyValue* pArray = aRet.getArray();
2529 
2530  uno::Any aVal;
2531  aVal <<= bFromTable;
2532  pArray[0] = beans::PropertyValue("IsSortInTable", -1, aVal,
2533  beans::PropertyState_DIRECT_VALUE);
2534 
2535  aVal <<= u' ';
2536  pArray[1] = beans::PropertyValue("Delimiter", -1, aVal,
2537  beans::PropertyState_DIRECT_VALUE);
2538 
2539  aVal <<= false;
2540  pArray[2] = beans::PropertyValue("IsSortColumns", -1, aVal,
2541  beans::PropertyState_DIRECT_VALUE);
2542 
2543  aVal <<= sal_Int32(3);
2544  pArray[3] = beans::PropertyValue("MaxSortFieldsCount", -1, aVal,
2545  beans::PropertyState_DIRECT_VALUE);
2546 
2547  lang::Locale aLang( SvtSysLocale().GetLanguageTag().getLocale());
2548  // get collator algorithm to be used for the locale
2549  uno::Sequence< OUString > aSeq(
2550  GetAppCollator().listCollatorAlgorithms( aLang ) );
2551  const bool bHasElements = aSeq.hasElements();
2552  OSL_ENSURE( bHasElements, "list of collator algorithms is empty!");
2553  OUString aCollAlg;
2554  if (bHasElements)
2555  {
2556  aCollAlg = aSeq.getConstArray()[0];
2557  }
2558 
2559  uno::Sequence< table::TableSortField > aFields
2560  {
2561  // Field, IsAscending, IsCaseSensitive, FieldType, CollatorLocale, CollatorAlgorithm
2562  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg },
2563  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg },
2564  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg }
2565  };
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 = ' ';
2591 
2592  SwSortKey aKey1;
2593  aKey1.nColumnId = USHRT_MAX;
2594  aKey1.bIsNumeric = true;
2596 
2597  SwSortKey aKey2;
2598  aKey2.nColumnId = USHRT_MAX;
2599  aKey2.bIsNumeric = true;
2601 
2602  SwSortKey aKey3;
2603  aKey3.nColumnId = USHRT_MAX;
2604  aKey3.bIsNumeric = true;
2606  SwSortKey* aKeys[3] = {&aKey1, &aKey2, &aKey3};
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  {
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  {
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  o3tl::narrowing<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 (aKey1.nColumnId != USHRT_MAX)
2818  {
2819  rSortOpt.aKeys.push_back(aKey1);
2820  }
2821  if (aKey2.nColumnId != USHRT_MAX)
2822  {
2823  rSortOpt.aKeys.push_back(aKey2);
2824  }
2825  if (aKey3.nColumnId != USHRT_MAX)
2826  {
2827  rSortOpt.aKeys.push_back(aKey3);
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( 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 SwNodeOffset 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( GetCursorOrThrow() );
2885 }
2886 
2887 uno::Reference< container::XEnumeration > SAL_CALL
2889 {
2890  SolarMutexGuard g;
2891 
2892  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2893 
2894  SwXText* pParentText = comphelper::getFromUnoTunnel<SwXText>(m_xParentText);
2895  OSL_ENSURE(pParentText, "parent is not a SwXText");
2896  if (!pParentText)
2897  {
2898  throw uno::RuntimeException();
2899  }
2900 
2901  auto pNewCursor(rUnoCursor.GetDoc().CreateUnoCursor(*rUnoCursor.GetPoint()) );
2902  if (rUnoCursor.HasMark())
2903  {
2904  pNewCursor->SetMark();
2905  *pNewCursor->GetMark() = *rUnoCursor.GetMark();
2906  }
2907  const CursorType eSetType = (CursorType::TableText == m_eType)
2909  return SwXParagraphEnumeration::Create(pParentText, pNewCursor, eSetType);
2910 }
2911 
2912 uno::Type SAL_CALL
2914 {
2916 }
2917 
2919 {
2920  return true;
2921 }
2922 
2923 uno::Sequence< OUString > SAL_CALL
2925 {
2926  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
2927  return aRet;
2928 }
2929 
2931 
2932 uno::Any SAL_CALL
2933 SwXTextCursor::queryInterface(const uno::Type& rType)
2934 {
2935  return (rType == cppu::UnoType<lang::XUnoTunnel>::get())
2938 }
2939 
2940 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwStartNode * FindSttNodeByType(SwStartNodeType eTyp)
Definition: node.cxx:764
virtual void SAL_CALL invalidateMarkings(::sal_Int32 nType) override
Definition: unoobj.cxx:2465
bool GoSentence(SentenceMoveType eMoveType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1558
bool is() const
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:692
Starts a section of nodes in the document model.
Definition: node.hxx:313
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2295
sw::UnoCursorPointer m_pUnoCursor
Type
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2299
virtual sal_Int32 Len() const
Definition: node.cxx:1243
virtual bool IsSkipOverProtectSections() const override
Definition: unocrsr.hxx:67
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
void DeleteMark()
Definition: pam.hxx:178
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:941
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj.cxx:857
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
SwUnoCursor * get() const
Definition: unocrsr.hxx:138
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:224
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1519
static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
Definition: unoobj.cxx:1779
sal_Int32 nIndex
static sal_uInt16 g_ParaResetableSetRange[]
Definition: unoobj.cxx:2307
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
Marks a position in the document model.
Definition: pam.hxx:36
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
bool IsSectionNode() const
Definition: node.hxx:654
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1565
::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
constexpr OUStringLiteral FILTER_TEXT_DLG
text filter with encoding dialog
Definition: iodetect.hxx:36
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj.cxx:2913
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
bool getCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:27
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SwSortDirection eDirection
Definition: sortopt.hxx:50
bool GoEndWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1325
virtual sal_Bool SAL_CALL isStartOfParagraph() override
Definition: unoobj.cxx:1543
virtual void ResetError() override
virtual sal_Bool SAL_CALL goRight(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unoobj.cxx:959
CursorType
static constexpr auto Items
bool MoveSection(SwWhichSection, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2334
SwDocShell * GetDocShell()
Definition: doc.hxx:1351
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1014
#define FN_UNO_RANGE_END
Definition: cmdid.h:65
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
Definition: ndtxt.cxx:4885
static void lcl_EnumerateIds(sal_uInt16 const *pIdRange, o3tl::sorted_vector< sal_uInt16 > &rWhichIds)
Definition: unoobj.cxx:2326
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1215
SwNodeIndex nNode
Definition: pam.hxx:38
sal_Unicode cDeli
Definition: sortopt.hxx:51
virtual const SwDoc * GetDoc() const override
Definition: unoobj.cxx:663
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
virtual ~SwUnoInternalPaM() override
Definition: unoobj.cxx:84
sal_uIntPtr sal_uLong
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
#define MID_RUBY_CHARSTYLE
Definition: unomid.h:115
const SwPosition * GetMark() const
Definition: pam.hxx:210
bool IsEndWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr) const
Definition: swcrsr.cxx:1230
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1274
void SetStyleHandle(const std::shared_ptr< SfxItemSet > &pHandle)
Definition: fmtautofmt.hxx:48
void ClearGrammarCheck()
Definition: txtedt.cxx:2246
sal_Int64 n
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1090
bool Left(sal_uInt16 nCnt)
Definition: swcrsr.hxx:172
Definition: doc.hxx:187
constexpr sal_uInt16 RES_FRMATR_END(133)
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj.cxx:889
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2180
constexpr TypedWhichId< SwFormatAutoFormat > RES_AUTO_STYLE(126)
sal_Int16 nId
void DeleteAndInsert(OUString const &rText, const bool bForceExpandHints)
Definition: unoobj.cxx:707
sal_uInt64 Seek(sal_uInt64 nPos)
bool IsAtEndOfMeta() const
Definition: unoobj.cxx:791
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
SwNode & GetNode() const
Definition: ndindex.hxx:119
void SetNumRuleStart(const SwPosition &rPos, bool bFlag=true)
Definition: docnum.cxx:1016
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2072
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
Definition: shellio.cxx:731
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:144
void resetCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam)
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj.cxx:1647
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1468
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1655
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2047
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:315
void SetGrammarCheckDirty(bool bNew) const
Definition: txtedt.cxx:2328
The root element of a Writer document layout.
Definition: rootfrm.hxx:81
static void lcl_setAutoStyle(IStyleAccess &rStyleAccess, const uno::Any &rValue, SfxItemSet &rSet, const bool bPara)
Definition: unoobj.cxx:207
#define MID_DROPCAP_CHAR_STYLE_NAME
Definition: unomid.h:65
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
virtual sal_Bool SAL_CALL gotoNextWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1227
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
SwUnoInternalPaM & operator=(const SwPaM &rPaM)
Definition: unoobj.cxx:92
const SwSection & GetSection() const
Definition: node.hxx:549
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:230
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2220
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2834
sal_uInt16 sal_Unicode
#define PROPERTY_MAP_CHAR_AUTO_STYLE
Definition: unomap.hxx:119
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:752
#define FN_UNO_PARA_NUM_AUTO_FORMAT
Definition: cmdid.h:530
virtual sal_Bool SAL_CALL gotoStartOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1496
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
#define FN_UNO_LIST_ID
Definition: cmdid.h:616
static SwPageDesc * GetByName(SwDoc &rDoc, std::u16string_view rName)
Definition: pagedesc.cxx:574
static void lcl_setCharStyle(SwDoc &rDoc, const uno::Any &rValue, SfxItemSet &rSet)
Definition: unoobj.cxx:181
virtual void SAL_CALL collapseToStart() override
Definition: unoobj.cxx:895
void SetSkipOverHiddenSections(bool bFlag)
Definition: unocrsr.hxx:74
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:296
static void lcl_SelectParaAndReset(SwPaM &rPaM, SwDoc &rDoc, o3tl::sorted_vector< sal_uInt16 > const &rWhichIds)
Definition: unoobj.cxx:1987
SwIndex nContent
Definition: pam.hxx:39
Any SAL_CALL getCaughtException()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const o3tl::sorted_vector< sal_uInt16 > &rAttrs=o3tl::sorted_vector< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:242
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:1083
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1314
const CursorType m_eType
void GetWriter(std::u16string_view rFltName, const OUString &rBaseURL, WriterRef &xRet)
Return writer based on the name.
Definition: fltini.cxx:159
#define UNO_NAME_IS_SKIP_PROTECTED_TEXT
Definition: unoprnms.hxx:504
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
bool GoPrevWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1383
bool GetPositions(SwPaM &rToFill,::sw::TextRangeMode eMode=::sw::TextRangeMode::RequireTextNode) const
Definition: unoobj2.cxx:1066
int nCount
void getPropertyValue(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1554
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
SwUnoCursor & GetCursorOrThrow()
const SfxItemPropertySet & m_rPropSet
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
static sal_uInt16 g_ResetableSetRange[]
Definition: unoobj.cxx:2316
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:128
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj.cxx:1681
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:152
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:2924
void SetCountedInList(bool bCounted)
Definition: ndtxt.cxx:4261
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
void SetWrongDirty(WrongState eNew) const
Definition: txtedt.cxx:2310
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2173
bool bIgnoreCase
Definition: sortopt.hxx:54
SwPaM * GetNext()
Definition: pam.hxx:265
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:98
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
bool IsAtEndOfContentControl() const
Definition: unoobj.cxx:821
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:113
#define FN_UNO_IS_NUMBER
Definition: cmdid.h:575
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj.cxx:2918
SwFormatColl & GetAnyFormatColl() const
Definition: node.hxx:717
sal_uInt16 nColumnId
Definition: sortopt.hxx:37
const css::uno::Sequence< sal_Int8 > & getSeq() const
void SetSkipOverProtectSections(bool bFlag)
Definition: unocrsr.hxx:69
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2008
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1718
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1433
void SetNodeNumStart(const SwPosition &rPos, sal_uInt16 nStt)
Definition: docnum.cxx:1038
void SetListId(OUString const &rListId)
Definition: ndtxt.cxx:4395
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:1000
bool SortText(const SwPaM &, const SwSortOptions &)
Sort Text in the Document.
Definition: docsort.cxx:283
void SetCharSet(rtl_TextEncoding nVal)
Definition: shellio.hxx:73
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:528
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2164
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
size_t Count() const
Definition: edimp.hxx:50
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:502
static void lcl_setRubyCharstyle(SfxItemSet &rItemSet, uno::Any const &rValue)
Definition: unoobj.cxx:400
SwPaM(SwPaM const &rPaM)=delete
bool IsEndOfPara(SwPaM &rUnoCursor)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
std::vector< SwSortKey > aKeys
Definition: sortopt.hxx:49
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2362
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset)
Definition: ndindex.hxx:272
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1706
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:2196
int i
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2341
uno_Any a
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual ~SwXTextCursor() override
Definition: unoobj.cxx:701
virtual const SwPaM * GetPaM() const override
Definition: unoobj.cxx:657
constexpr sal_uInt16 RES_PARATR_LIST_END(88)
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
bool GoNextWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1355
ForceIntoMetaMode
Definition: unoobj.cxx:743
SetAttrMode
Definition: swtypes.hxx:132
void Exchange()
Definition: pam.cxx:490
bool IsHiddenFlag() const
Definition: section.hxx:186
sal_uInt64 GetSize()
virtual void SAL_CALL gotoStart(sal_Bool bExpand) override
Definition: unoobj.cxx:977
virtual sal_Bool SAL_CALL isCollapsed() override
Definition: unoobj.cxx:927
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
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:748
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1154
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
bool IsStartOfPara(SwPaM &rUnoCursor)
float u
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
dictionary props
css::beans::PropertyState getPropertyState(const OUString &rName, const SfxItemSet &rSet) const
bool GoCurrSection(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1056
virtual sal_Bool SAL_CALL isStartOfSentence() override
Definition: unoobj.cxx:1386
Marks a node in the document model.
Definition: ndindex.hxx:30
constexpr sal_uInt16 RES_UNKNOWNATR_END(154)
virtual void SAL_CALL gotoRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Bool bExpand) override
Definition: unoobj.cxx:1062
css::uno::Type const & get()
static void lcl_setDropcapCharStyle(SwPaM const &rPam, SfxItemSet &rItemSet, uno::Any const &rValue)
Definition: unoobj.cxx:365
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:947
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj.cxx:2503
#define FN_UNO_RANGE_BEGIN
Definition: cmdid.h:64
PropertyValueVector_t aPropertyValues
bool empty() const
virtual sal_Bool SAL_CALL gotoPreviousParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1631
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2208
virtual bool IsSkipOverHiddenSections() const override
Definition: unocrsr.hxx:72
#define FN_UNO_NUM_START_VALUE
Definition: cmdid.h:532
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
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoobj.cxx:2278
SwSortOrder eSortOrder
Definition: sortopt.hxx:36
#define FN_SKIP_PROTECTED_TEXT
Definition: cmdid.h:579
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj.cxx:2888
enumrange< T >::Iterator end(enumrange< T >)
const SwPosition * Start() const
Definition: pam.hxx:213
SAL_WARN_UNUSED_RESULT WhichRangesContainer MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo) const
#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)
#define UNO_NAME_IS_SKIP_HIDDEN_TEXT
Definition: unoprnms.hxx:503
constexpr sal_uInt16 RES_UNKNOWNATR_BEGIN(RES_BOXATR_END)
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...
const LanguageTag & getLocale()
#define UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES
Definition: unoprnms.hxx:505
bool IsError() const
static bool lcl_setCharFormatSequence(SwPaM &rPam, uno::Any const &rValue)
Definition: unoobj.cxx:338
css::uno::Any GetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:1730
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:4109
OUString sSortType
Definition: sortopt.hxx:35
SwUnoCursor & GetCursor()
Definition: unoobj.cxx:654
SwUnoInternalPaM(const SwUnoInternalPaM &)=delete
constexpr sal_uInt16 RES_TXTATR_END(RES_TXTATR_NOEND_END)
SwTextFormatColl * GetCollection()
Definition: docstyle.cxx:2180
#define FN_UNO_NUM_RULES
Definition: cmdid.h:534
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1350
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
#define FN_NUMBER_NEWSTART
Definition: cmdid.h:467
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj.cxx:2096
#define PROPERTY_NONE
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2514
void reset(std::shared_ptr< SwUnoCursor > pNew)
Definition: unocrsr.hxx:157
bool Right(sal_uInt16 nCnt)
Definition: swcrsr.hxx:173
#define FN_UNO_CHARFMT_SEQUENCE
Definition: cmdid.h:600
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2287
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)
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:882
SwGetPropertyStatesCaller
void ClearSmartTags()
Definition: txtedt.cxx:2276
void SetEndian(SvStreamEndian SvStreamEndian)
sal_Int32 GetIndex() const
Definition: index.hxx:91
virtual sal_Bool SAL_CALL gotoEndOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1590
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1409
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
constexpr sal_uInt16 RES_PARATR_LIST_BEGIN(RES_PARATR_END)
SwNodes & GetNodes()
Definition: doc.hxx:408
const SwPosition * End() const
Definition: pam.hxx:218
constexpr sal_uInt16 RES_PARATR_END(82)
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1042
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
virtual void SAL_CALL collapseToEnd() override
Definition: unoobj.cxx:911
static rtl::Reference< SwXParaFrameEnumeration > Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1726
Sequence< sal_Int8 > aSeq
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2235
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2340
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2293
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:421
virtual sal_Bool SAL_CALL gotoNextParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1615
SwMoveFnCollection const & fnSectionStart
Definition: paminit.cxx:49
constexpr sal_uInt16 RES_CHRATR_END(46)
SwStartNodeType
Definition: ndtyp.hxx:50
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2188
LanguageType nLanguage
Definition: sortopt.hxx:52
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:254
void setNumberingProperty(const Any &rValue, SwPaM &rPam)
const css::uno::Reference< css::text::XText > m_xParentText
void ClearWrong()
Definition: txtedt.cxx:2218
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj.cxx:862
ScXMLEditAttributeMap::Entry const aEntries[]
constexpr TypedWhichId< SwFormatAutoFormat > RES_PARATR_LIST_AUTOFMT(87)
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:1919
static void lcl_SetNodeNumStart(SwPaM &rCursor, uno::Any const &rValue)
Definition: unoobj.cxx:309
#define SAL_WARN(area, stream)
bool SetPageDesc(const css::uno::Any &rValue, SwDoc &rDoc, SfxItemSet &rSet)
SwFormatColl * GetFormatColl() const
Definition: node.hxx:461
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2138
SwDoc & GetDoc() const
Definition: pam.hxx:244
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:2172
detail::Optional< bool >::type tryAccess< bool >(css::uno::Any const &any)
const EnumerationType m_eType
#define FN_UNO_NUM_LEVEL
Definition: cmdid.h:533
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:476
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1975
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps...
Definition: paratr.hxx:62
virtual sal_Bool SAL_CALL isStartOfWord() override
Definition: unoobj.cxx:1204
static rtl::Reference< SwXParagraphEnumeration > Create(css::uno::Reference< css::text::XText > const &xParent, const std::shared_ptr< SwUnoCursor > &pCursor, const CursorType eType, SwTableBox const *const pTableBox=nullptr)
Definition: unoobj2.cxx:449
bool SetCursorPropertyValue(SfxItemPropertyMapEntry const &rEntry, css::uno::Any const &rValue, SwPaM &rPam, SfxItemSet &rItemSet)
std::pair< const_iterator, bool > insert(Value &&x)
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
Definition: ndtxt.cxx:5119
IStyleAccess & GetIStyleAccess()
Definition: doc.hxx:756
#define FN_SKIP_HIDDEN_TEXT
Definition: cmdid.h:578
virtual bool DeleteAndJoin(SwPaM &)=0
complete delete of a given PaM
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj.cxx:868
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2228
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2425
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unoobj.cxx:1034
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1300
css::uno::Sequence< css::beans::PropertyValue > CreateSortDescriptor(const bool bFromTable)
Definition: unoobj.cxx:2525
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:757
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:527
bool IsStartWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr) const
Definition: swcrsr.cxx:1212
bool bIsNumeric
Definition: sortopt.hxx:38
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_TXTATR_UNKNOWN_CONTAINER(54)
bool GoStartWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1296
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1318
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:864
CollatorWrapper & GetAppCollator()
Definition: init.cxx:737
Base class of the Writer document model elements.
Definition: node.hxx:81
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo