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