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
353  lcl_setCharStyle(rPam.GetDoc(), aStyle, aSet);
354  // the first style should replace the current attributes,
355  // all other have to be added
356  SwUnoCursorHelper::SetCursorAttr(rPam, aSet, nStyle
360  }
361  return true;
362 }
363 
364 static void
365 lcl_setDropcapCharStyle(SwPaM const & rPam, SfxItemSet & rItemSet,
366  uno::Any const& rValue)
367 {
368  OUString uStyle;
369  if (!(rValue >>= uStyle))
370  {
371  throw lang::IllegalArgumentException();
372  }
373  OUString sStyle;
374  SwStyleNameMapper::FillUIName(uStyle, sStyle,
376  SwDoc& rDoc = rPam.GetDoc();
377  //default character style must not be set as default format
378  SwDocStyleSheet *const pStyle = static_cast<SwDocStyleSheet*>(
379  rDoc.GetDocShell()
380  ->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
381  if (!pStyle || pStyle->GetCharFormat() == rDoc.GetDfltCharFormat())
382  {
383  throw lang::IllegalArgumentException();
384  }
385  std::unique_ptr<SwFormatDrop> pDrop;
386  SfxPoolItem const* pItem(nullptr);
387  if (SfxItemState::SET ==
388  rItemSet.GetItemState(RES_PARATR_DROP, true, &pItem))
389  {
390  pDrop.reset(new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem)));
391  }
392  if (!pDrop)
393  {
394  pDrop.reset(new SwFormatDrop);
395  }
396  const rtl::Reference<SwDocStyleSheet> xStyle(new SwDocStyleSheet(*pStyle));
397  pDrop->SetCharFormat(xStyle->GetCharFormat());
398  rItemSet.Put(*pDrop);
399 }
400 
401 static void
402 lcl_setRubyCharstyle(SfxItemSet & rItemSet, uno::Any const& rValue)
403 {
404  OUString sTmp;
405  if (!(rValue >>= sTmp))
406  {
407  throw lang::IllegalArgumentException();
408  }
409 
410  std::unique_ptr<SwFormatRuby> pRuby;
411  const SfxPoolItem* pItem;
412  if (SfxItemState::SET ==
413  rItemSet.GetItemState(RES_TXTATR_CJK_RUBY, true, &pItem))
414  {
415  pRuby.reset(new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem)));
416  }
417  if (!pRuby)
418  {
419  pRuby.reset(new SwFormatRuby(OUString()));
420  }
421  OUString sStyle;
422  SwStyleNameMapper::FillUIName(sTmp, sStyle,
424  pRuby->SetCharFormatName(sStyle);
425  pRuby->SetCharFormatId(0);
426  if (!sStyle.isEmpty())
427  {
428  const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(
430  pRuby->SetCharFormatId(nId);
431  }
432  rItemSet.Put(*pRuby);
433 }
434 
435 bool
437  SfxItemPropertyMapEntry const& rEntry, const uno::Any& rValue,
438  SwPaM & rPam, SfxItemSet & rItemSet)
439 {
440  if (!(rEntry.nFlags & beans::PropertyAttribute::MAYBEVOID) &&
441  (rValue.getValueType() == cppu::UnoType<void>::get()))
442  {
443  return false;
444  }
445  bool bRet = true;
446  switch (rEntry.nWID)
447  {
448  case RES_TXTATR_CHARFMT:
449  lcl_setCharStyle(rPam.GetDoc(), rValue, rItemSet);
450  break;
451  case RES_TXTATR_AUTOFMT:
453  rValue, rItemSet, false);
454  break;
456  lcl_setCharFormatSequence(rPam, rValue);
457  break;
458  case FN_UNO_PARA_STYLE :
460  break;
461  case RES_AUTO_STYLE:
463  rValue, rItemSet, true);
464  break;
465  case FN_UNO_PAGE_STYLE:
466  //FIXME nothing here?
467  break;
469  lcl_SetNodeNumStart( rPam, rValue );
470  break;
471  case FN_UNO_NUM_LEVEL:
472  // #i91601#
473  case FN_UNO_LIST_ID:
474  case FN_UNO_IS_NUMBER:
476  {
477  // multi selection is not considered
478  SwTextNode *const pTextNd = rPam.GetNode().GetTextNode();
479  if (!pTextNd)
480  {
481  throw lang::IllegalArgumentException();
482  }
483  if (FN_UNO_NUM_LEVEL == rEntry.nWID)
484  {
485  sal_Int16 nLevel = 0;
486  if (rValue >>= nLevel)
487  {
488  if (nLevel < 0 || MAXLEVEL <= nLevel)
489  {
490  throw lang::IllegalArgumentException(
491  "invalid NumberingLevel", nullptr, 0);
492  }
493  pTextNd->SetAttrListLevel(nLevel);
494  }
495  }
496  // #i91601#
497  else if (FN_UNO_LIST_ID == rEntry.nWID)
498  {
499  OUString sListId;
500  if (rValue >>= sListId)
501  {
502  pTextNd->SetListId( sListId );
503  }
504  }
505  else if (FN_UNO_IS_NUMBER == rEntry.nWID)
506  {
507  bool bIsNumber(false);
508  if ((rValue >>= bIsNumber) && !bIsNumber)
509  {
510  pTextNd->SetCountedInList( false );
511  }
512  }
513  else if (FN_UNO_PARA_NUM_AUTO_FORMAT == rEntry.nWID)
514  {
515  uno::Sequence<beans::NamedValue> props;
516  if (rValue >>= props)
517  {
518  // 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?
520  SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
525  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 SwNodeOffset nSttNd = pTmpCursor->Start()->nNode.GetIndex();
625  const SwNodeOffset nEndNd = pTmpCursor->End()->nNode.GetIndex();
626 
627  if( nEndNd - nSttNd >= SwNodeOffset(nMaxLookup) )
628  {
629  pFormat = nullptr;
630  break;
631  }
632 
633  const SwNodes& rNds = rPaM.GetDoc().GetNodes();
634  for( SwNodeOffset 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 comphelper::UnoIdInit 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( comphelper::getSomethingImpl<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 = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1044  OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1045 
1046  if (!pRange && !pCursor)
1047  {
1048  throw uno::RuntimeException();
1049  }
1050 
1051  SwPaM aPam(GetDoc()->GetNodes());
1052  const SwPaM * pPam(nullptr);
1053  if (pCursor)
1054  {
1055  pPam = pCursor->GetPaM();
1056  }
1057  else if (pRange)
1058  {
1059  if (pRange->GetPositions(aPam))
1060  {
1061  pPam = & aPam;
1062  }
1063  }
1064 
1065  if (!pPam)
1066  {
1067  throw uno::RuntimeException();
1068  }
1069 
1070  {
1071  SwStartNodeType eSearchNodeType = SwNormalStartNode;
1072  switch (m_eType)
1073  {
1074  case CursorType::Frame: eSearchNodeType = SwFlyStartNode; break;
1075  case CursorType::TableText: eSearchNodeType = SwTableBoxStartNode; break;
1076  case CursorType::Footnote: eSearchNodeType = SwFootnoteStartNode; break;
1077  case CursorType::Header: eSearchNodeType = SwHeaderStartNode; break;
1078  case CursorType::Footer: eSearchNodeType = SwFooterStartNode; break;
1079  //case CURSOR_INVALID:
1080  //case CursorType::Body:
1081  default:
1082  ;
1083  }
1084 
1085  const SwStartNode* pOwnStartNode = rOwnCursor.GetNode().FindSttNodeByType(eSearchNodeType);
1086  while ( pOwnStartNode != nullptr
1087  && pOwnStartNode->IsSectionNode())
1088  {
1089  pOwnStartNode = pOwnStartNode->StartOfSectionNode();
1090  }
1091 
1092  const SwStartNode* pTmp =
1093  pPam->GetNode().FindSttNodeByType(eSearchNodeType);
1094  while ( pTmp != nullptr
1095  && pTmp->IsSectionNode() )
1096  {
1097  pTmp = pTmp->StartOfSectionNode();
1098  }
1099 
1100  if ( eSearchNodeType == SwTableBoxStartNode )
1101  {
1102  if (!pOwnStartNode || !pTmp)
1103  {
1104  throw uno::RuntimeException();
1105  }
1106 
1107  if ( pOwnStartNode->FindTableNode() != pTmp->FindTableNode() )
1108  {
1109  throw uno::RuntimeException();
1110  }
1111  }
1112  else
1113  {
1114  if ( pOwnStartNode != pTmp )
1115  {
1116  throw uno::RuntimeException();
1117  }
1118  }
1119  }
1120 
1121  if (CursorType::Meta == m_eType)
1122  {
1123  SwPaM CopyPam(*pPam->GetMark(), *pPam->GetPoint());
1124  const bool bNotForced( lcl_ForceIntoMeta(
1125  CopyPam, m_xParentText, META_CHECK_BOTH) );
1126  if (!bNotForced)
1127  {
1128  throw uno::RuntimeException(
1129  "gotoRange: parameter range not contained in nesting"
1130  " text content for which this cursor was created",
1131  static_cast<text::XWordCursor*>(this));
1132  }
1133  }
1134 
1135  // selection has to be expanded here
1136  if(bExpand)
1137  {
1138  // cursor should include its previous range plus the given range
1139  const SwPosition aOwnLeft(*rOwnCursor.Start());
1140  const SwPosition aOwnRight(*rOwnCursor.End());
1141  SwPosition const& rParamLeft = *pPam->Start();
1142  SwPosition const& rParamRight = *pPam->End();
1143 
1144  // now there are four SwPositions,
1145  // two of them are going to be used, but which ones?
1146  if (aOwnRight > rParamRight)
1147  *rOwnCursor.GetPoint() = aOwnRight;
1148  else
1149  *rOwnCursor.GetPoint() = rParamRight;
1150  rOwnCursor.SetMark();
1151  if (aOwnLeft < rParamLeft)
1152  *rOwnCursor.GetMark() = aOwnLeft;
1153  else
1154  *rOwnCursor.GetMark() = rParamLeft;
1155  }
1156  else
1157  {
1158  // cursor should be the given range
1159  *rOwnCursor.GetPoint() = *pPam->GetPoint();
1160  if (pPam->HasMark())
1161  {
1162  rOwnCursor.SetMark();
1163  *rOwnCursor.GetMark() = *pPam->GetMark();
1164  }
1165  else
1166  {
1167  rOwnCursor.DeleteMark();
1168  }
1169  }
1170 }
1171 
1173 {
1174  SolarMutexGuard aGuard;
1175 
1176  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1177 
1178  const bool bRet =
1179  rUnoCursor.IsStartWordWT( i18n::WordType::DICTIONARY_WORD );
1180  return bRet;
1181 }
1182 
1184 {
1185  SolarMutexGuard aGuard;
1186 
1187  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1188 
1189  const bool bRet =
1190  rUnoCursor.IsEndWordWT( i18n::WordType::DICTIONARY_WORD );
1191  return bRet;
1192 }
1193 
1194 sal_Bool SAL_CALL
1196 {
1197  SolarMutexGuard aGuard;
1198 
1199  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1200 
1201  // problems arise when a paragraph starts with something other than a word
1202  bool bRet = false;
1203  // remember old position to check if cursor has moved
1204  // since the called functions are sometimes a bit unreliable
1205  // in specific cases...
1206  SwPosition *const pPoint = rUnoCursor.GetPoint();
1207  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1208  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1209 
1210  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1211  // end of paragraph
1212  if (rUnoCursor.GetContentNode() &&
1213  (pPoint->nContent == rUnoCursor.GetContentNode()->Len()))
1214  {
1215  rUnoCursor.Right(1);
1216  }
1217  else
1218  {
1219  const bool bTmp =
1220  rUnoCursor.GoNextWordWT( i18n::WordType::DICTIONARY_WORD );
1221  // if there is no next word within the current paragraph
1222  // try to go to the start of the next paragraph
1223  if (!bTmp)
1224  {
1225  rUnoCursor.MovePara(GoNextPara, fnParaStart);
1226  }
1227  }
1228 
1229  // return true if cursor has moved
1230  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1231  (pPoint->nContent.GetIndex() != nOldIndex);
1232  if (bRet && (CursorType::Meta == m_eType))
1233  {
1234  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1235  META_CHECK_BOTH);
1236  }
1237 
1238  return bRet;
1239 }
1240 
1241 sal_Bool SAL_CALL
1243 {
1244  SolarMutexGuard aGuard;
1245 
1246  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1247 
1248  // white spaces create problems on the paragraph start
1249  bool bRet = false;
1250  SwPosition *const pPoint = rUnoCursor.GetPoint();
1251  SwNode *const pOldNode = &pPoint->nNode.GetNode();
1252  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1253 
1254  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1255  // start of paragraph?
1256  if (pPoint->nContent == 0)
1257  {
1258  rUnoCursor.Left(1);
1259  }
1260  else
1261  {
1262  rUnoCursor.GoPrevWordWT( i18n::WordType::DICTIONARY_WORD );
1263  if (pPoint->nContent == 0)
1264  {
1265  rUnoCursor.Left(1);
1266  }
1267  }
1268 
1269  // return true if cursor has moved
1270  bRet = (&pPoint->nNode.GetNode() != pOldNode) ||
1271  (pPoint->nContent.GetIndex() != nOldIndex);
1272  if (bRet && (CursorType::Meta == m_eType))
1273  {
1274  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1275  META_CHECK_BOTH);
1276  }
1277 
1278  return bRet;
1279 }
1280 
1281 sal_Bool SAL_CALL
1283 {
1284  SolarMutexGuard aGuard;
1285 
1286  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1287 
1288  bool bRet = false;
1289  SwPosition *const pPoint = rUnoCursor.GetPoint();
1290  SwNode & rOldNode = pPoint->nNode.GetNode();
1291  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1292 
1293  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1294  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1295  if (!rUnoCursor.IsEndWordWT( nWordType ))
1296  {
1297  rUnoCursor.GoEndWordWT( nWordType );
1298  }
1299 
1300  // restore old cursor if we are not at the end of a word by now
1301  // otherwise use current one
1302  bRet = rUnoCursor.IsEndWordWT( nWordType );
1303  if (!bRet)
1304  {
1305  pPoint->nNode = rOldNode;
1306  pPoint->nContent = nOldIndex;
1307  }
1308  else if (CursorType::Meta == m_eType)
1309  {
1310  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1311  META_CHECK_BOTH);
1312  }
1313 
1314  return bRet;
1315 }
1316 
1317 sal_Bool SAL_CALL
1319 {
1320  SolarMutexGuard aGuard;
1321 
1322  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1323 
1324  bool bRet = false;
1325  SwPosition *const pPoint = rUnoCursor.GetPoint();
1326  SwNode & rOldNode = pPoint->nNode.GetNode();
1327  sal_Int32 const nOldIndex = pPoint->nContent.GetIndex();
1328 
1329  const sal_Int16 nWordType = i18n::WordType::DICTIONARY_WORD;
1330  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1331  if (!rUnoCursor.IsStartWordWT( nWordType ))
1332  {
1333  rUnoCursor.GoStartWordWT( nWordType );
1334  }
1335 
1336  // restore old cursor if we are not at the start of a word by now
1337  // otherwise use current one
1338  bRet = rUnoCursor.IsStartWordWT( nWordType );
1339  if (!bRet)
1340  {
1341  pPoint->nNode = rOldNode;
1342  pPoint->nContent = nOldIndex;
1343  }
1344  else if (CursorType::Meta == m_eType)
1345  {
1346  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1347  META_CHECK_BOTH);
1348  }
1349 
1350  return bRet;
1351 }
1352 
1353 sal_Bool SAL_CALL
1355 {
1356  SolarMutexGuard aGuard;
1357 
1358  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1359 
1360  // start of paragraph?
1361  bool bRet = rUnoCursor.GetPoint()->nContent == 0;
1362  // with mark ->no sentence start
1363  // (check if cursor is no selection, i.e. it does not have
1364  // a mark or else point and mark are identical)
1365  if (!bRet && (!rUnoCursor.HasMark() ||
1366  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1367  {
1368  SwCursor aCursor(*rUnoCursor.GetPoint(),nullptr);
1369  SwPosition aOrigPos = *aCursor.GetPoint();
1370  aCursor.GoSentence(SwCursor::START_SENT );
1371  bRet = aOrigPos == *aCursor.GetPoint();
1372  }
1373  return bRet;
1374 }
1375 
1376 sal_Bool SAL_CALL
1378 {
1379  SolarMutexGuard aGuard;
1380 
1381  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1382 
1383  // end of paragraph?
1384  bool bRet = rUnoCursor.GetContentNode() &&
1385  (rUnoCursor.GetPoint()->nContent == rUnoCursor.GetContentNode()->Len());
1386  // with mark->no sentence end
1387  // (check if cursor is no selection, i.e. it does not have
1388  // a mark or else point and mark are identical)
1389  if (!bRet && (!rUnoCursor.HasMark() ||
1390  *rUnoCursor.GetPoint() == *rUnoCursor.GetMark()))
1391  {
1392  SwCursor aCursor(*rUnoCursor.GetPoint(), nullptr);
1393  SwPosition aOrigPos = *aCursor.GetPoint();
1394  aCursor.GoSentence(SwCursor::END_SENT);
1395  bRet = aOrigPos == *aCursor.GetPoint();
1396  }
1397  return bRet;
1398 }
1399 
1400 sal_Bool SAL_CALL
1402 {
1403  SolarMutexGuard aGuard;
1404 
1405  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1406 
1407  const bool bWasEOS = isEndOfSentence();
1408  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1409  bool bRet = rUnoCursor.GoSentence(SwCursor::NEXT_SENT);
1410  if (!bRet)
1411  {
1412  bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1413  }
1414 
1415  // if at the end of the sentence (i.e. at the space after the '.')
1416  // advance to next word in order for GoSentence to work properly
1417  // next time and have isStartOfSentence return true after this call
1418  if (!rUnoCursor.IsStartWordWT(css::i18n::WordType::ANYWORD_IGNOREWHITESPACES))
1419  {
1420  const bool bNextWord = rUnoCursor.GoNextWordWT(i18n::WordType::ANYWORD_IGNOREWHITESPACES);
1421  if (bWasEOS && !bNextWord)
1422  {
1423  bRet = false;
1424  }
1425  }
1426  if (CursorType::Meta == m_eType)
1427  {
1428  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1429  META_CHECK_BOTH)
1430  && bRet;
1431  }
1432  return bRet;
1433 }
1434 
1435 sal_Bool SAL_CALL
1437 {
1438  SolarMutexGuard aGuard;
1439 
1440  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1441 
1442  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1443  bool bRet = rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1444  if (!bRet)
1445  {
1446  bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1447  if (bRet)
1448  {
1449  rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1450  // at the end of a paragraph move to the sentence end again
1451  rUnoCursor.GoSentence(SwCursor::PREV_SENT);
1452  }
1453  }
1454  if (CursorType::Meta == m_eType)
1455  {
1456  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1457  META_CHECK_BOTH)
1458  && bRet;
1459  }
1460  return bRet;
1461 }
1462 
1463 sal_Bool SAL_CALL
1465 {
1466  SolarMutexGuard aGuard;
1467 
1468  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1469 
1470  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1471  // if we're at the para start then we won't move
1472  // but bRet is also true if GoSentence failed but
1473  // the start of the sentence is reached
1474  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor)
1475  || rUnoCursor.GoSentence(SwCursor::START_SENT)
1476  || SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1477  if (CursorType::Meta == m_eType)
1478  {
1479  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1480  META_CHECK_BOTH)
1481  && bRet;
1482  }
1483  return bRet;
1484 }
1485 
1486 sal_Bool SAL_CALL
1488 {
1489  SolarMutexGuard aGuard;
1490 
1491  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1492 
1493  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1494  // bRet is true if GoSentence() succeeded or if the
1495  // MovePara() succeeded while the end of the para is
1496  // not reached already
1497  bool bAlreadyParaEnd = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1498  bool bRet = !bAlreadyParaEnd
1499  && (rUnoCursor.GoSentence(SwCursor::END_SENT)
1500  || rUnoCursor.MovePara(GoCurrPara, fnParaEnd));
1501  if (CursorType::Meta == m_eType)
1502  {
1503  bRet = lcl_ForceIntoMeta(rUnoCursor, m_xParentText,
1504  META_CHECK_BOTH)
1505  && bRet;
1506  }
1507  return bRet;
1508 }
1509 
1510 sal_Bool SAL_CALL
1512 {
1513  SolarMutexGuard aGuard;
1514 
1515  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1516 
1517  const bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1518  return bRet;
1519 }
1520 
1521 sal_Bool SAL_CALL
1523 {
1524  SolarMutexGuard aGuard;
1525 
1526  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1527 
1528  const bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1529  return bRet;
1530 }
1531 
1532 sal_Bool SAL_CALL
1534 {
1535  SolarMutexGuard aGuard;
1536 
1537  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1538 
1539  if (CursorType::Meta == m_eType)
1540  {
1541  return false;
1542  }
1543  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1544  bool bRet = SwUnoCursorHelper::IsStartOfPara(rUnoCursor);
1545  if (!bRet)
1546  {
1547  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaStart);
1548  }
1549 
1550  // since MovePara(GoCurrPara, fnParaStart) only returns false
1551  // if we were already at the start of the paragraph this function
1552  // should always complete successfully.
1553  OSL_ENSURE( bRet, "gotoStartOfParagraph failed" );
1554  return bRet;
1555 }
1556 
1557 sal_Bool SAL_CALL
1559 {
1560  SolarMutexGuard aGuard;
1561 
1562  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1563 
1564  if (CursorType::Meta == m_eType)
1565  {
1566  return false;
1567  }
1568  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1569  bool bRet = SwUnoCursorHelper::IsEndOfPara(rUnoCursor);
1570  if (!bRet)
1571  {
1572  bRet = rUnoCursor.MovePara(GoCurrPara, fnParaEnd);
1573  }
1574 
1575  // since MovePara(GoCurrPara, fnParaEnd) only returns false
1576  // if we were already at the end of the paragraph this function
1577  // should always complete successfully.
1578  OSL_ENSURE( bRet, "gotoEndOfParagraph failed" );
1579  return bRet;
1580 }
1581 
1582 sal_Bool SAL_CALL
1584 {
1585  SolarMutexGuard aGuard;
1586 
1587  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1588 
1589  if (CursorType::Meta == m_eType)
1590  {
1591  return false;
1592  }
1593  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1594  const bool bRet = rUnoCursor.MovePara(GoNextPara, fnParaStart);
1595  return bRet;
1596 }
1597 
1598 sal_Bool SAL_CALL
1600 {
1601  SolarMutexGuard aGuard;
1602 
1603  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1604 
1605  if (CursorType::Meta == m_eType)
1606  {
1607  return false;
1608  }
1609  SwUnoCursorHelper::SelectPam(rUnoCursor, Expand);
1610  const bool bRet = rUnoCursor.MovePara(GoPrevPara, fnParaStart);
1611  return bRet;
1612 }
1613 
1614 uno::Reference< text::XText > SAL_CALL
1616 {
1617  SolarMutexGuard g;
1618 
1619  return m_xParentText;
1620 }
1621 
1622 uno::Reference< text::XTextRange > SAL_CALL
1624 {
1625  SolarMutexGuard aGuard;
1626 
1627  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1628 
1629  uno::Reference< text::XTextRange > xRet;
1630  SwPaM aPam(*rUnoCursor.Start());
1631  const uno::Reference< text::XText > xParent = getText();
1632  if (CursorType::Meta == m_eType)
1633  {
1634  // return cursor to prevent modifying SwXTextRange for META
1636  new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1637  *rUnoCursor.GetPoint()) );
1638  pXCursor->gotoStart(false);
1639  xRet = static_cast<text::XWordCursor*>(pXCursor.get());
1640  }
1641  else
1642  {
1643  xRet = new SwXTextRange(aPam, xParent);
1644  }
1645  return xRet;
1646 }
1647 
1648 uno::Reference< text::XTextRange > SAL_CALL
1650 {
1651  SolarMutexGuard aGuard;
1652 
1653  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1654 
1655  uno::Reference< text::XTextRange > xRet;
1656  SwPaM aPam(*rUnoCursor.End());
1657  const uno::Reference< text::XText > xParent = getText();
1658  if (CursorType::Meta == m_eType)
1659  {
1660  // return cursor to prevent modifying SwXTextRange for META
1662  new SwXTextCursor(rUnoCursor.GetDoc(), xParent, CursorType::Meta,
1663  *rUnoCursor.GetPoint()) );
1664  pXCursor->gotoEnd(false);
1665  xRet = static_cast<text::XWordCursor*>(pXCursor.get());
1666  }
1667  else
1668  {
1669  xRet = new SwXTextRange(aPam, xParent);
1670  }
1671  return xRet;
1672 }
1673 
1674 OUString SAL_CALL SwXTextCursor::getString()
1675 {
1676  SolarMutexGuard aGuard;
1677 
1678  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
1679 
1680  OUString aText;
1681  SwUnoCursorHelper::GetTextFromPam(rUnoCursor, aText);
1682  return aText;
1683 }
1684 
1685 void SAL_CALL
1686 SwXTextCursor::setString(const OUString& aString)
1687 {
1688  SolarMutexGuard aGuard;
1689 
1690  GetCursorOrThrow(); // just to check if valid
1691 
1692  const bool bForceExpandHints( (CursorType::Meta == m_eType)
1693  && dynamic_cast<SwXMeta&>(*m_xParentText)
1694  .CheckForOwnMemberMeta(*GetPaM(), true) );
1695  DeleteAndInsert(aString, bForceExpandHints);
1696 }
1697 
1699  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1700  std::u16string_view rPropertyName)
1701 {
1702  uno::Any aAny;
1703  SfxItemPropertyMapEntry const*const pEntry =
1704  rPropSet.getPropertyMap().getByName(rPropertyName);
1705 
1706  if (!pEntry)
1707  {
1708  throw beans::UnknownPropertyException(
1709  OUString::Concat("Unknown property: ") + rPropertyName,
1710  static_cast<cppu::OWeakObject *>(nullptr));
1711  }
1712 
1713  beans::PropertyState eTemp;
1714  const bool bDone = SwUnoCursorHelper::getCursorPropertyValue(
1715  *pEntry, rPaM, &aAny, eTemp );
1716 
1717  if (!bDone)
1718  {
1721  RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER>
1722  aSet(rPaM.GetDoc().GetAttrPool());
1723 
1725 
1726  rPropSet.getPropertyValue(*pEntry, aSet, aAny);
1727  }
1728 
1729  return aAny;
1730 }
1731 
1733  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1734  const OUString& rPropertyName,
1735  const uno::Any& rValue,
1736  const SetAttrMode nAttrMode)
1737 {
1738  uno::Sequence< beans::PropertyValue > aValues(1);
1739  aValues[0].Name = rPropertyName;
1740  aValues[0].Value = rValue;
1741  SetPropertyValues(rPaM, rPropSet, aValues, nAttrMode);
1742 }
1743 
1744 // FN_UNO_PARA_STYLE is known to set attributes for nodes, inside
1745 // SwUnoCursorHelper::SetTextFormatColl, instead of extending item set.
1746 // We need to get them from nodes in next call to GetCursorAttr.
1747 // The rest could cause similar problems in theory, so we just list them here.
1748 static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
1749 {
1750  return nWID == FN_UNO_PARA_STYLE ||
1751  nWID == FN_UNO_CHARFMT_SEQUENCE ||
1752  nWID == FN_UNO_NUM_START_VALUE ||
1753  nWID == FN_UNO_NUM_RULES;
1754 }
1755 
1757  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1758  const uno::Sequence< beans::PropertyValue > &rPropertyValues,
1759  const SetAttrMode nAttrMode)
1760 {
1761  if (!rPropertyValues.hasElements())
1762  return;
1763 
1764  SwDoc& rDoc = rPaM.GetDoc();
1765  OUString aUnknownExMsg, aPropertyVetoExMsg;
1766 
1767  // Build set of attributes we want to fetch
1768  WhichRangesContainer aRanges;
1769  std::vector<std::pair<const SfxItemPropertyMapEntry*, const uno::Any&>> aEntries;
1770  aEntries.reserve(rPropertyValues.getLength());
1771  for (const auto& rPropVal : rPropertyValues)
1772  {
1773  const OUString &rPropertyName = rPropVal.Name;
1774 
1775  SfxItemPropertyMapEntry const* pEntry =
1776  rPropSet.getPropertyMap().getByName(rPropertyName);
1777 
1778  // Queue up any exceptions until the end ...
1779  if (!pEntry)
1780  {
1781  aUnknownExMsg += "Unknown property: '" + rPropertyName + "' ";
1782  continue;
1783  }
1784  else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1785  {
1786  aPropertyVetoExMsg += "Property is read-only: '" + rPropertyName + "' ";
1787  continue;
1788  }
1789  aRanges = aRanges.MergeRange(pEntry->nWID, pEntry->nWID);
1790  aEntries.emplace_back(pEntry, rPropVal.Value);
1791  }
1792 
1793  if (!aEntries.empty())
1794  {
1795  // Fetch, overwrite, and re-set the attributes from the core
1796  SfxItemSet aItemSet(rDoc.GetAttrPool(), aRanges);
1797 
1798  bool bPreviousPropertyCausesSideEffectsInNodes = false;
1799  for (size_t i = 0; i < aEntries.size(); ++i)
1800  {
1801  SfxItemPropertyMapEntry const*const pEntry = aEntries[i].first;
1802  bool bPropertyCausesSideEffectsInNodes =
1804 
1805  // we need to get up-to-date item set from nodes
1806  if (i == 0 || bPreviousPropertyCausesSideEffectsInNodes)
1807  {
1808  aItemSet.ClearItem();
1809  SwUnoCursorHelper::GetCursorAttr(rPaM, aItemSet);
1810  }
1811 
1812  const uno::Any &rValue = aEntries[i].second;
1813  // this can set some attributes in nodes' mpAttrSet
1814  if (!SwUnoCursorHelper::SetCursorPropertyValue(*pEntry, rValue, rPaM, aItemSet))
1815  rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
1816 
1817  if (i + 1 == aEntries.size() || bPropertyCausesSideEffectsInNodes)
1818  SwUnoCursorHelper::SetCursorAttr(rPaM, aItemSet, nAttrMode, false/*bTableMode*/);
1819 
1820  bPreviousPropertyCausesSideEffectsInNodes = bPropertyCausesSideEffectsInNodes;
1821  }
1822  }
1823 
1824  if (!aUnknownExMsg.isEmpty())
1825  throw beans::UnknownPropertyException(aUnknownExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1826  if (!aPropertyVetoExMsg.isEmpty())
1827  throw beans::PropertyVetoException(aPropertyVetoExMsg, static_cast<cppu::OWeakObject *>(nullptr));
1828 }
1829 
1830 namespace
1831 {
1832  bool NotInRange(sal_uInt16 nWID, sal_uInt16 nStart, sal_uInt16 nEnd)
1833  {
1834  return nWID < nStart || nWID > nEnd;
1835  }
1836 }
1837 
1838 uno::Sequence< beans::PropertyState >
1840  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1841  const uno::Sequence< OUString >& rPropertyNames,
1842  const SwGetPropertyStatesCaller eCaller)
1843 {
1844  const OUString* pNames = rPropertyNames.getConstArray();
1845  uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
1846  beans::PropertyState* pStates = aRet.getArray();
1847  const SfxItemPropertyMap &rMap = rPropSet.getPropertyMap();
1848  std::optional<SfxItemSet> oSet;
1849  std::optional<SfxItemSet> oSetParent;
1850 
1851  for (sal_Int32 i = 0, nEnd = rPropertyNames.getLength(); i < nEnd; i++)
1852  {
1853  SfxItemPropertyMapEntry const*const pEntry =
1854  rMap.getByName( pNames[i] );
1855  if(!pEntry)
1856  {
1857  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
1858  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
1859  {
1860  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1861  continue;
1862  }
1864  eCaller)
1865  {
1866  //this values marks the element as unknown property
1867  pStates[i] = beans::PropertyState::PropertyState_MAKE_FIXED_SIZE;
1868  continue;
1869  }
1870  else
1871  {
1872  throw beans::UnknownPropertyException(
1873  "Unknown property: " + pNames[i],
1874  static_cast<cppu::OWeakObject *>(nullptr));
1875  }
1876  }
1877  if (((SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION == eCaller) ||
1879  NotInRange(pEntry->nWID, FN_UNO_RANGE_BEGIN, FN_UNO_RANGE_END) &&
1880  NotInRange(pEntry->nWID, RES_CHRATR_BEGIN, RES_TXTATR_END) )
1881  {
1882  pStates[i] = beans::PropertyState_DEFAULT_VALUE;
1883  }
1884  else
1885  {
1886  if ( pEntry->nWID >= FN_UNO_RANGE_BEGIN &&
1887  pEntry->nWID <= FN_UNO_RANGE_END )
1888  {
1890  *pEntry, rPaM, nullptr, pStates[i] );
1891  }
1892  else
1893  {
1894  if (!oSet)
1895  {
1896  switch ( eCaller )
1897  {
1900  oSet.emplace( rPaM.GetDoc().GetAttrPool(),
1901  svl::Items<RES_CHRATR_BEGIN, RES_TXTATR_END> );
1902  break;
1904  oSet.emplace( rPaM.GetDoc().GetAttrPool(),
1905  pEntry->nWID, pEntry->nWID );
1906  break;
1907  default:
1908  oSet.emplace(
1909  rPaM.GetDoc().GetAttrPool(),
1910  svl::Items<
1913  RES_UNKNOWNATR_CONTAINER>);
1914  }
1915  // #i63870#
1916  SwUnoCursorHelper::GetCursorAttr( rPaM, *oSet );
1917  }
1918 
1919  pStates[i] = ( oSet->Count() )
1920  ? rPropSet.getPropertyState( *pEntry, *oSet )
1921  : beans::PropertyState_DEFAULT_VALUE;
1922 
1923  //try again to find out if a value has been inherited
1924  if( beans::PropertyState_DIRECT_VALUE == pStates[i] )
1925  {
1926  if (!oSetParent)
1927  {
1928  oSetParent.emplace(oSet->CloneAsValue( false ));
1929  // #i63870#
1931  rPaM, *oSetParent, true, false );
1932  }
1933 
1934  pStates[i] = ( oSetParent->Count() )
1935  ? rPropSet.getPropertyState( *pEntry, *oSetParent )
1936  : beans::PropertyState_DEFAULT_VALUE;
1937  }
1938  }
1939  }
1940  }
1941  return aRet;
1942 }
1943 
1945  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1946  const OUString& rPropertyName)
1947 {
1948  uno::Sequence< OUString > aStrings { rPropertyName };
1949  uno::Sequence< beans::PropertyState > aSeq =
1950  GetPropertyStates(rPaM, rPropSet, aStrings,
1952  return aSeq[0];
1953 }
1954 
1955 static void
1957  o3tl::sorted_vector<sal_uInt16> const &rWhichIds )
1958 {
1959  // if we are resetting paragraph attributes, we need to select the full paragraph first
1960  SwPosition aStart = *rPaM.Start();
1961  SwPosition aEnd = *rPaM.End();
1962  auto pTemp ( rDoc.CreateUnoCursor(aStart) );
1964  {
1965  pTemp->MovePara(GoCurrPara, fnParaStart);
1966  }
1967  pTemp->SetMark();
1968  *pTemp->GetPoint() = aEnd;
1969  SwUnoCursorHelper::SelectPam(*pTemp, true);
1970  if(!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1971  {
1972  pTemp->MovePara(GoCurrPara, fnParaEnd);
1973  }
1974  rDoc.ResetAttrs(*pTemp, true, rWhichIds);
1975 }
1976 
1978  SwPaM& rPaM, const SfxItemPropertySet& rPropSet,
1979  std::u16string_view rPropertyName)
1980 {
1981  SwDoc& rDoc = rPaM.GetDoc();
1982  SfxItemPropertyMapEntry const*const pEntry =
1983  rPropSet.getPropertyMap().getByName(rPropertyName);
1984  if (!pEntry)
1985  {
1986  throw beans::UnknownPropertyException(
1987  OUString::Concat("Unknown property: ") + rPropertyName,
1988  static_cast<cppu::OWeakObject *>(nullptr));
1989  }
1990 
1991  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1992  {
1993  throw uno::RuntimeException(
1994  OUString::Concat("setPropertyToDefault: property is read-only: ")
1995  + rPropertyName, nullptr);
1996  }
1997 
1998  if (pEntry->nWID < RES_FRMATR_END)
1999  {
2000  const o3tl::sorted_vector<sal_uInt16> aWhichIds{ pEntry->nWID };
2001  if (pEntry->nWID < RES_PARATR_BEGIN)
2002  {
2003  rDoc.ResetAttrs(rPaM, true, aWhichIds);
2004  }
2005  else
2006  {
2007  lcl_SelectParaAndReset ( rPaM, rDoc, aWhichIds );
2008  }
2009  }
2010  else
2011  {
2013  }
2014 }
2015 
2017  SwPaM const & rPaM, const SfxItemPropertySet& rPropSet,
2018  std::u16string_view rPropertyName)
2019 {
2020  SfxItemPropertyMapEntry const*const pEntry =
2021  rPropSet.getPropertyMap().getByName(rPropertyName);
2022  if (!pEntry)
2023  {
2024  throw beans::UnknownPropertyException(
2025  OUString::Concat("Unknown property: ") + rPropertyName,
2026  static_cast<cppu::OWeakObject *>(nullptr));
2027  }
2028 
2029  uno::Any aRet;
2030  if (pEntry->nWID < RES_FRMATR_END)
2031  {
2032  SwDoc& rDoc = rPaM.GetDoc();
2033  const SfxPoolItem& rDefItem =
2034  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2035  rDefItem.QueryValue(aRet, pEntry->nMemberId);
2036  }
2037  return aRet;
2038 }
2039 
2040 uno::Reference< beans::XPropertySetInfo > SAL_CALL
2042 {
2043  SolarMutexGuard g;
2044 
2045  static uno::Reference< beans::XPropertySetInfo > xRef = [&]()
2046  {
2047  static SfxItemPropertyMapEntry const aCursorExtMap_Impl[] =
2048  {
2051  { u"", 0, css::uno::Type(), 0, 0 }
2052  };
2053  const uno::Reference< beans::XPropertySetInfo > xInfo =
2055  // extend PropertySetInfo!
2056  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
2058  aCursorExtMap_Impl,
2059  aPropSeq ));
2060  }();
2061  return xRef;
2062 }
2063 
2064 void SAL_CALL
2066  const OUString& rPropertyName, const uno::Any& rValue)
2067 {
2068  SolarMutexGuard aGuard;
2069 
2070  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2071 
2072  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2073  {
2074  bool bSet(false);
2075  if (!(rValue >>= bSet))
2076  {
2077  throw lang::IllegalArgumentException();
2078  }
2079  rUnoCursor.SetSkipOverHiddenSections(bSet);
2080  }
2081  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2082  {
2083  bool bSet(false);
2084  if (!(rValue >>= bSet))
2085  {
2086  throw lang::IllegalArgumentException();
2087  }
2088  rUnoCursor.SetSkipOverProtectSections(bSet);
2089  }
2090  else
2091  {
2093  m_rPropSet, rPropertyName, rValue);
2094  }
2095 }
2096 
2097 uno::Any SAL_CALL
2098 SwXTextCursor::getPropertyValue(const OUString& rPropertyName)
2099 {
2100  SolarMutexGuard aGuard;
2101 
2102  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2103 
2104  uno::Any aAny;
2105  if (rPropertyName == UNO_NAME_IS_SKIP_HIDDEN_TEXT)
2106  {
2107  const bool bSet = rUnoCursor.IsSkipOverHiddenSections();
2108  aAny <<= bSet;
2109  }
2110  else if (rPropertyName == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2111  {
2112  const bool bSet = rUnoCursor.IsSkipOverProtectSections();
2113  aAny <<= bSet;
2114  }
2115  else
2116  {
2117  aAny = SwUnoCursorHelper::GetPropertyValue(rUnoCursor,
2118  m_rPropSet, rPropertyName);
2119  }
2120  return aAny;
2121 }
2122 
2123 void SAL_CALL
2125  const OUString& /*rPropertyName*/,
2126  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2127 {
2128  OSL_FAIL("SwXTextCursor::addPropertyChangeListener(): not implemented");
2129 }
2130 
2131 void SAL_CALL
2133  const OUString& /*rPropertyName*/,
2134  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
2135 {
2136  OSL_FAIL("SwXTextCursor::removePropertyChangeListener(): not implemented");
2137 }
2138 
2139 void SAL_CALL
2141  const OUString& /*rPropertyName*/,
2142  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2143 {
2144  OSL_FAIL("SwXTextCursor::addVetoableChangeListener(): not implemented");
2145 }
2146 
2147 void SAL_CALL
2149  const OUString& /*rPropertyName*/,
2150  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
2151 {
2152  OSL_FAIL("SwXTextCursor::removeVetoableChangeListener(): not implemented");
2153 }
2154 
2155 beans::PropertyState SAL_CALL
2156 SwXTextCursor::getPropertyState(const OUString& rPropertyName)
2157 {
2158  SolarMutexGuard aGuard;
2159 
2160  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2161 
2162  const beans::PropertyState eRet = SwUnoCursorHelper::GetPropertyState(
2163  rUnoCursor, m_rPropSet, rPropertyName);
2164  return eRet;
2165 }
2166 
2167 uno::Sequence< beans::PropertyState > SAL_CALL
2169  const uno::Sequence< OUString >& rPropertyNames)
2170 {
2171  SolarMutexGuard aGuard;
2172 
2173  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2174 
2176  rUnoCursor, m_rPropSet, rPropertyNames);
2177 }
2178 
2179 void SAL_CALL
2180 SwXTextCursor::setPropertyToDefault(const OUString& rPropertyName)
2181 {
2182  // forward: need no solar mutex here
2183  uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2184  setPropertiesToDefault ( aSequence );
2185 }
2186 
2187 uno::Any SAL_CALL
2188 SwXTextCursor::getPropertyDefault(const OUString& rPropertyName)
2189 {
2190  // forward: need no solar mutex here
2191  const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2192  return getPropertyDefaults ( aSequence ).getConstArray()[0];
2193 }
2194 
2196  const uno::Sequence< OUString >& aPropertyNames,
2197  const uno::Sequence< uno::Any >& aValues )
2198 {
2199  if( aValues.getLength() != aPropertyNames.getLength() )
2200  {
2201  OSL_FAIL( "mis-matched property value sequences" );
2202  throw lang::IllegalArgumentException();
2203  }
2204 
2205  SolarMutexGuard aGuard;
2206 
2207  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2208 
2209  // a little lame to have to copy into this.
2210  uno::Sequence< beans::PropertyValue > aPropertyValues( aValues.getLength() );
2211  for ( sal_Int32 i = 0; i < aPropertyNames.getLength(); i++ )
2212  {
2213  if ( aPropertyNames[ i ] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2214  aPropertyNames[ i ] == UNO_NAME_IS_SKIP_PROTECTED_TEXT )
2215  {
2216  // the behaviour of these is hard to model in a group
2217  OSL_FAIL("invalid property name for batch setting");
2218  throw lang::IllegalArgumentException();
2219  }
2220  aPropertyValues[ i ].Name = aPropertyNames[ i ];
2221  aPropertyValues[ i ].Value = aValues[ i ];
2222  }
2223  try
2224  {
2226  }
2227  catch (const css::beans::UnknownPropertyException& e)
2228  {
2230  throw lang::WrappedTargetException(
2231  "wrapped Exception " + e.Message,
2232  uno::Reference<uno::XInterface>(), a);
2233  }
2234 }
2235 
2236 uno::Sequence< uno::Any > SAL_CALL
2237 SwXTextCursor::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames )
2238 {
2239  // a banal implementation for now
2240  uno::Sequence< uno::Any > aValues( aPropertyNames.getLength() );
2241  std::transform(aPropertyNames.begin(), aPropertyNames.end(), aValues.getArray(),
2242  [this](const OUString& rName) -> uno::Any { return getPropertyValue( rName ); });
2243  return aValues;
2244 }
2245 
2247  const uno::Sequence< OUString >& /* aPropertyNames */,
2248  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2249 {
2250  OSL_FAIL("SwXTextCursor::addPropertiesChangeListener(): not implemented");
2251 }
2253  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2254 {
2255  OSL_FAIL("SwXTextCursor::removePropertiesChangeListener(): not implemented");
2256 }
2257 
2259  const uno::Sequence< OUString >& /* aPropertyNames */,
2260  const uno::Reference< css::beans::XPropertiesChangeListener >& /* xListener */ )
2261 {
2262  OSL_FAIL("SwXTextCursor::firePropertiesChangeEvent(): not implemented");
2263 }
2264 
2265 // para specific attribute ranges
2266 static sal_uInt16 g_ParaResetableSetRange[] = {
2271  0
2272 };
2273 
2274 // selection specific attribute ranges
2275 static sal_uInt16 g_ResetableSetRange[] = {
2276  RES_CHRATR_BEGIN, RES_CHRATR_END-1,
2281  0
2282 };
2283 
2284 static void
2285 lcl_EnumerateIds(sal_uInt16 const* pIdRange, o3tl::sorted_vector<sal_uInt16> &rWhichIds)
2286 {
2287  while (*pIdRange)
2288  {
2289  const sal_uInt16 nStart = *pIdRange++;
2290  const sal_uInt16 nEnd = *pIdRange++;
2291  for (sal_uInt16 nId = nStart + 1; nId <= nEnd; ++nId)
2292  {
2293  rWhichIds.insert( nId );
2294  }
2295  }
2296 }
2297 
2298 void SAL_CALL
2300 {
2301  SolarMutexGuard aGuard;
2302 
2303  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2304 
2305  o3tl::sorted_vector<sal_uInt16> aParaWhichIds;
2307  lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds);
2308  lcl_EnumerateIds(g_ResetableSetRange, aWhichIds);
2309  if (!aParaWhichIds.empty())
2310  {
2311  lcl_SelectParaAndReset(rUnoCursor, rUnoCursor.GetDoc(),
2312  aParaWhichIds);
2313  }
2314  if (!aWhichIds.empty())
2315  {
2316  rUnoCursor.GetDoc().ResetAttrs(rUnoCursor, true, aWhichIds);
2317  }
2318 }
2319 
2320 void SAL_CALL
2322  const uno::Sequence< OUString >& rPropertyNames)
2323 {
2324  SolarMutexGuard aGuard;
2325 
2326  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2327 
2328  if ( !rPropertyNames.hasElements() )
2329  return;
2330 
2331  SwDoc& rDoc = rUnoCursor.GetDoc();
2333  o3tl::sorted_vector<sal_uInt16> aParaWhichIds;
2334  for (const OUString& rName : rPropertyNames)
2335  {
2336  SfxItemPropertyMapEntry const*const pEntry =
2337  m_rPropSet.getPropertyMap().getByName( rName );
2338  if (!pEntry)
2339  {
2340  if (rName == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2342  {
2343  continue;
2344  }
2345  throw beans::UnknownPropertyException(
2346  "Unknown property: " + rName,
2347  static_cast<cppu::OWeakObject *>(this));
2348  }
2349  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2350  {
2351  throw uno::RuntimeException(
2352  "setPropertiesToDefault: property is read-only: " + rName,
2353  static_cast<cppu::OWeakObject *>(this));
2354  }
2355 
2356  if (pEntry->nWID < RES_FRMATR_END)
2357  {
2358  if (pEntry->nWID < RES_PARATR_BEGIN)
2359  {
2360  aWhichIds.insert( pEntry->nWID );
2361  }
2362  else
2363  {
2364  aParaWhichIds.insert( pEntry->nWID );
2365  }
2366  }
2367  else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
2368  {
2369  SwUnoCursorHelper::resetCursorPropertyValue(*pEntry, rUnoCursor);
2370  }
2371  }
2372 
2373  if (!aParaWhichIds.empty())
2374  {
2375  lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
2376  }
2377  if (!aWhichIds.empty())
2378  {
2379  rDoc.ResetAttrs(rUnoCursor, true, aWhichIds);
2380  }
2381 }
2382 
2383 uno::Sequence< uno::Any > SAL_CALL
2385  const uno::Sequence< OUString >& rPropertyNames)
2386 {
2387  SolarMutexGuard aGuard;
2388 
2389  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2390 
2391  const sal_Int32 nCount = rPropertyNames.getLength();
2392  uno::Sequence< uno::Any > aRet(nCount);
2393  if ( nCount )
2394  {
2395  SwDoc& rDoc = rUnoCursor.GetDoc();
2396  const OUString *pNames = rPropertyNames.getConstArray();
2397  uno::Any *pAny = aRet.getArray();
2398  for (sal_Int32 i = 0; i < nCount; i++)
2399  {
2400  SfxItemPropertyMapEntry const*const pEntry =
2401  m_rPropSet.getPropertyMap().getByName( pNames[i] );
2402  if (!pEntry)
2403  {
2404  if (pNames[i] == UNO_NAME_IS_SKIP_HIDDEN_TEXT ||
2405  pNames[i] == UNO_NAME_IS_SKIP_PROTECTED_TEXT)
2406  {
2407  continue;
2408  }
2409  throw beans::UnknownPropertyException(
2410  "Unknown property: " + pNames[i],
2411  static_cast<cppu::OWeakObject *>(nullptr));
2412  }
2413  if (pEntry->nWID < RES_FRMATR_END)
2414  {
2415  const SfxPoolItem& rDefItem =
2416  rDoc.GetAttrPool().GetDefaultItem(pEntry->nWID);
2417  rDefItem.QueryValue(pAny[i], pEntry->nMemberId);
2418  }
2419  }
2420  }
2421  return aRet;
2422 }
2423 
2424 void SAL_CALL SwXTextCursor::invalidateMarkings(::sal_Int32 nType)
2425 {
2426  SolarMutexGuard aGuard;
2427 
2428  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2429 
2430  SwNode& node = rUnoCursor.GetNode();
2431 
2432  SwTextNode* txtNode = node.GetTextNode();
2433 
2434  if (txtNode == nullptr) return;
2435 
2436  if ( text::TextMarkupType::SPELLCHECK == nType )
2437  {
2439  txtNode->ClearWrong();
2440  }
2441  else if( text::TextMarkupType::PROOFREADING == nType )
2442  {
2443  txtNode->SetGrammarCheckDirty(true);
2444  txtNode->ClearGrammarCheck();
2445  }
2446  else if ( text::TextMarkupType::SMARTTAG == nType )
2447  {
2448  txtNode->SetSmartTagDirty(true);
2449  txtNode->ClearSmartTags();
2450  }
2451  else return;
2452 
2453  SwFormatColl* fmtColl=txtNode->GetFormatColl();
2454 
2455  if (fmtColl == nullptr) return;
2456 
2457  SwFormatChg aNew( fmtColl );
2458  txtNode->CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aNew));
2459 }
2460 
2461 void SAL_CALL
2463  const OUString& rRedlineType,
2464  const uno::Sequence< beans::PropertyValue >& rRedlineProperties)
2465 {
2466  SolarMutexGuard aGuard;
2467 
2468  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2469 
2470  SwUnoCursorHelper::makeRedline(rUnoCursor, rRedlineType, rRedlineProperties);
2471 }
2472 
2473 void SAL_CALL SwXTextCursor::insertDocumentFromURL(const OUString& rURL,
2474  const uno::Sequence< beans::PropertyValue >& rOptions)
2475 {
2476  SolarMutexGuard aGuard;
2477 
2478  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2479 
2480  SwUnoCursorHelper::InsertFile(&rUnoCursor, rURL, rOptions);
2481 }
2482 
2483 uno::Sequence< beans::PropertyValue >
2485 {
2486  uno::Sequence< beans::PropertyValue > aRet(5);
2487  beans::PropertyValue* pArray = aRet.getArray();
2488 
2489  uno::Any aVal;
2490  aVal <<= bFromTable;
2491  pArray[0] = beans::PropertyValue("IsSortInTable", -1, aVal,
2492  beans::PropertyState_DIRECT_VALUE);
2493 
2494  aVal <<= u' ';
2495  pArray[1] = beans::PropertyValue("Delimiter", -1, aVal,
2496  beans::PropertyState_DIRECT_VALUE);
2497 
2498  aVal <<= false;
2499  pArray[2] = beans::PropertyValue("IsSortColumns", -1, aVal,
2500  beans::PropertyState_DIRECT_VALUE);
2501 
2502  aVal <<= sal_Int32(3);
2503  pArray[3] = beans::PropertyValue("MaxSortFieldsCount", -1, aVal,
2504  beans::PropertyState_DIRECT_VALUE);
2505 
2506  lang::Locale aLang( SvtSysLocale().GetLanguageTag().getLocale());
2507  // get collator algorithm to be used for the locale
2508  uno::Sequence< OUString > aSeq(
2509  GetAppCollator().listCollatorAlgorithms( aLang ) );
2510  const bool bHasElements = aSeq.hasElements();
2511  OSL_ENSURE( bHasElements, "list of collator algorithms is empty!");
2512  OUString aCollAlg;
2513  if (bHasElements)
2514  {
2515  aCollAlg = aSeq.getConstArray()[0];
2516  }
2517 
2518  uno::Sequence< table::TableSortField > aFields
2519  {
2520  // Field, IsAscending, IsCaseSensitive, FieldType, CollatorLocale, CollatorAlgorithm
2521  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg },
2522  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg },
2523  { 1, true, false, table::TableSortFieldType_ALPHANUMERIC, aLang, aCollAlg }
2524  };
2525 
2526  aVal <<= aFields;
2527  pArray[4] = beans::PropertyValue("SortFields", -1, aVal,
2528  beans::PropertyState_DIRECT_VALUE);
2529 
2530  return aRet;
2531 }
2532 
2533 uno::Sequence< beans::PropertyValue > SAL_CALL
2535 {
2536  SolarMutexGuard aGuard;
2537 
2539 }
2540 
2542  const uno::Sequence< beans::PropertyValue >& rDescriptor,
2543  SwSortOptions& rSortOpt)
2544 {
2545  bool bRet = true;
2546 
2547  rSortOpt.bTable = false;
2548  rSortOpt.cDeli = ' ';
2550 
2551  SwSortKey aKey1;
2552  aKey1.nColumnId = USHRT_MAX;
2553  aKey1.bIsNumeric = true;
2555 
2556  SwSortKey aKey2;
2557  aKey2.nColumnId = USHRT_MAX;
2558  aKey2.bIsNumeric = true;
2560 
2561  SwSortKey aKey3;
2562  aKey3.nColumnId = USHRT_MAX;
2563  aKey3.bIsNumeric = true;
2565  SwSortKey* aKeys[3] = {&aKey1, &aKey2, &aKey3};
2566 
2567  bool bOldSortdescriptor(false);
2568  bool bNewSortdescriptor(false);
2569 
2570  for (const beans::PropertyValue& rProperty : rDescriptor)
2571  {
2572  uno::Any aValue( rProperty.Value );
2573  const OUString& rPropName = rProperty.Name;
2574 
2575  // old and new sortdescriptor
2576  if ( rPropName == "IsSortInTable" )
2577  {
2578  if (auto b = o3tl::tryAccess<bool>(aValue))
2579  {
2580  rSortOpt.bTable = *b;
2581  }
2582  else
2583  {
2584  bRet = false;
2585  }
2586  }
2587  else if ( rPropName == "Delimiter" )
2588  {
2589  sal_Unicode uChar;
2590  sal_uInt16 nChar;
2591  if (aValue >>= uChar)
2592  {
2593  rSortOpt.cDeli = uChar;
2594  }
2595  else if (aValue >>= nChar)
2596  {
2597  // For compatibility with BASIC, also accept an ANY containing
2598  // an UNSIGNED SHORT:
2599  rSortOpt.cDeli = nChar;
2600  }
2601  else
2602  {
2603  bRet = false;
2604  }
2605  }
2606  // old sortdescriptor
2607  else if ( rPropName == "SortColumns" )
2608  {
2609  bOldSortdescriptor = true;
2610  bool bTemp(false);
2611  if (aValue >>= bTemp)
2612  {
2614  }
2615  else
2616  {
2617  bRet = false;
2618  }
2619  }
2620  else if ( rPropName == "IsCaseSensitive" )
2621  {
2622  bOldSortdescriptor = true;
2623  bool bTemp(false);
2624  if (aValue >>= bTemp)
2625  {
2626  rSortOpt.bIgnoreCase = !bTemp;
2627  }
2628  else
2629  {
2630  bRet = false;
2631  }
2632  }
2633  else if ( rPropName == "CollatorLocale" )
2634  {
2635  bOldSortdescriptor = true;
2636  lang::Locale aLocale;
2637  if (aValue >>= aLocale)
2638  {
2639  rSortOpt.nLanguage = LanguageTag::convertToLanguageType( aLocale);
2640  }
2641  else
2642  {
2643  bRet = false;
2644  }
2645  }
2646  else if (rPropName.startsWith("CollatorAlgorithm") &&
2647  rPropName.getLength() == 18 &&
2648  (rPropName[17] >= '0' && rPropName[17] <= '9'))
2649  {
2650  bOldSortdescriptor = true;
2651  sal_uInt16 nIndex = rPropName[17];
2652  nIndex -= '0';
2653  OUString aText;
2654  if ((aValue >>= aText) && nIndex < 3)
2655  {
2656  aKeys[nIndex]->sSortType = aText;
2657  }
2658  else
2659  {
2660  bRet = false;
2661  }
2662  }
2663  else if (rPropName.startsWith("SortRowOrColumnNo") &&
2664  rPropName.getLength() == 18 &&
2665  (rPropName[17] >= '0' && rPropName[17] <= '9'))
2666  {
2667  bOldSortdescriptor = true;
2668  sal_uInt16 nIndex = rPropName[17];
2669  nIndex -= '0';
2670  sal_Int16 nCol = -1;
2671  if (aValue.getValueType() == ::cppu::UnoType<sal_Int16>::get()
2672  && nIndex < 3)
2673  {
2674  aValue >>= nCol;
2675  }
2676  if (nCol >= 0)
2677  {
2678  aKeys[nIndex]->nColumnId = nCol;
2679  }
2680  else
2681  {
2682  bRet = false;
2683  }
2684  }
2685  else if (rPropName.startsWith("IsSortNumeric") &&
2686  rPropName.getLength() == 14 &&
2687  (rPropName[13] >= '0' && rPropName[13] <= '9'))
2688  {
2689  bOldSortdescriptor = true;
2690  sal_uInt16 nIndex = rPropName[13];
2691  nIndex = nIndex - '0';
2692  auto bTemp = o3tl::tryAccess<bool>(aValue);
2693  if (bTemp && nIndex < 3)
2694  {
2695  aKeys[nIndex]->bIsNumeric = *bTemp;
2696  }
2697  else
2698  {
2699  bRet = false;
2700  }
2701  }
2702  else if (rPropName.startsWith("IsSortAscending") &&
2703  rPropName.getLength() == 16 &&
2704  (rPropName[15] >= '0' && rPropName[15] <= '9'))
2705  {
2706  bOldSortdescriptor = true;
2707  sal_uInt16 nIndex = rPropName[15];
2708  nIndex -= '0';
2709  auto bTemp = o3tl::tryAccess<bool>(aValue);
2710  if (bTemp && nIndex < 3)
2711  {
2712  aKeys[nIndex]->eSortOrder = (*bTemp)
2714  }
2715  else
2716  {
2717  bRet = false;
2718  }
2719  }
2720  // new sortdescriptor
2721  else if ( rPropName == "IsSortColumns" )
2722  {
2723  bNewSortdescriptor = true;
2724  if (auto bTemp = o3tl::tryAccess<bool>(aValue))
2725  {
2727  }
2728  else
2729  {
2730  bRet = false;
2731  }
2732  }
2733  else if ( rPropName == "SortFields" )
2734  {
2735  bNewSortdescriptor = true;
2736  uno::Sequence < table::TableSortField > aFields;
2737  if (aValue >>= aFields)
2738  {
2739  sal_Int32 nCount(aFields.getLength());
2740  if (nCount <= 3)
2741  {
2742  table::TableSortField* pFields = aFields.getArray();
2743  for (sal_Int32 i = 0; i < nCount; ++i)
2744  {
2745  rSortOpt.bIgnoreCase = !pFields[i].IsCaseSensitive;
2746  rSortOpt.nLanguage =
2747  LanguageTag::convertToLanguageType( pFields[i].CollatorLocale );
2748  aKeys[i]->sSortType = pFields[i].CollatorAlgorithm;
2749  aKeys[i]->nColumnId =
2750  o3tl::narrowing<sal_uInt16>(pFields[i].Field);
2751  aKeys[i]->bIsNumeric = (pFields[i].FieldType ==
2752  table::TableSortFieldType_NUMERIC);
2753  aKeys[i]->eSortOrder = (pFields[i].IsAscending)
2755  }
2756  }
2757  else
2758  {
2759  bRet = false;
2760  }
2761  }
2762  else
2763  {
2764  bRet = false;
2765  }
2766  }
2767  }
2768 
2769  if (bNewSortdescriptor && bOldSortdescriptor)
2770  {
2771  OSL_FAIL("someone tried to set the old deprecated and "
2772  "the new sortdescriptor");
2773  bRet = false;
2774  }
2775 
2776  if (aKey1.nColumnId != USHRT_MAX)
2777  {
2778  rSortOpt.aKeys.push_back(aKey1);
2779  }
2780  if (aKey2.nColumnId != USHRT_MAX)
2781  {
2782  rSortOpt.aKeys.push_back(aKey2);
2783  }
2784  if (aKey3.nColumnId != USHRT_MAX)
2785  {
2786  rSortOpt.aKeys.push_back(aKey3);
2787  }
2788 
2789  return bRet && !rSortOpt.aKeys.empty();
2790 }
2791 
2792 void SAL_CALL
2793 SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2794 {
2795  SolarMutexGuard aGuard;
2796 
2797  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2798 
2799  if (!rUnoCursor.HasMark())
2800  return;
2801 
2802  SwSortOptions aSortOpt;
2803  if (!SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
2804  {
2805  throw uno::RuntimeException("Bad sort properties");
2806  }
2807  UnoActionContext aContext( &rUnoCursor.GetDoc() );
2808 
2809  SwPosition & rStart = *rUnoCursor.Start();
2810  SwPosition & rEnd = *rUnoCursor.End();
2811 
2812  SwNodeIndex aPrevIdx( rStart.nNode, -1 );
2813  const SwNodeOffset nOffset = rEnd.nNode.GetIndex() - rStart.nNode.GetIndex();
2814  const sal_Int32 nCntStt = rStart.nContent.GetIndex();
2815 
2816  rUnoCursor.GetDoc().SortText(rUnoCursor, aSortOpt);
2817 
2818  // update selection
2819  rUnoCursor.DeleteMark();
2820  rUnoCursor.GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
2821  SwContentNode *const pCNd = rUnoCursor.GetContentNode();
2822  sal_Int32 nLen = pCNd->Len();
2823  if (nLen > nCntStt)
2824  {
2825  nLen = nCntStt;
2826  }
2827  rUnoCursor.GetPoint()->nContent.Assign(pCNd, nLen );
2828  rUnoCursor.SetMark();
2829 
2830  rUnoCursor.GetPoint()->nNode += nOffset;
2831  SwContentNode *const pCNd2 = rUnoCursor.GetContentNode();
2832  rUnoCursor.GetPoint()->nContent.Assign( pCNd2, pCNd2->Len() );
2833 
2834 }
2835 
2836 uno::Reference< container::XEnumeration > SAL_CALL
2837 SwXTextCursor::createContentEnumeration(const OUString& rServiceName)
2838 {
2839  SolarMutexGuard g;
2840  if (rServiceName != "com.sun.star.text.TextContent")
2841  throw uno::RuntimeException();
2842  SwUnoCursor& rUnoCursor( GetCursorOrThrow() );
2844 }
2845 
2846 uno::Reference< container::XEnumeration > SAL_CALL
2848 {
2849  SolarMutexGuard g;
2850 
2851  SwUnoCursor & rUnoCursor( GetCursorOrThrow() );
2852 
2853  SwXText* pParentText = comphelper::getFromUnoTunnel<SwXText>(m_xParentText);
2854  OSL_ENSURE(pParentText, "parent is not a SwXText");
2855  if (!pParentText)
2856  {
2857  throw uno::RuntimeException();
2858  }
2859 
2860  auto pNewCursor(rUnoCursor.GetDoc().CreateUnoCursor(*rUnoCursor.GetPoint()) );
2861  if (rUnoCursor.HasMark())
2862  {
2863  pNewCursor->SetMark();
2864  *pNewCursor->GetMark() = *rUnoCursor.GetMark();
2865  }
2866  const CursorType eSetType = (CursorType::TableText == m_eType)
2868  return SwXParagraphEnumeration::Create(pParentText, pNewCursor, eSetType);
2869 }
2870 
2871 uno::Type SAL_CALL
2873 {
2875 }
2876 
2878 {
2879  return true;
2880 }
2881 
2882 uno::Sequence< OUString > SAL_CALL
2884 {
2885  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
2886  return aRet;
2887 }
2888 
2890 
2891 uno::Any SAL_CALL
2892 SwXTextCursor::queryInterface(const uno::Type& rType)
2893 {
2894  return (rType == cppu::UnoType<lang::XUnoTunnel>::get())
2897 }
2898 
2899 /* 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:2424
bool GoSentence(SentenceMoveType eMoveType, SwRootFrame const *pLayout=nullptr)
Definition: swcrsr.cxx:1558
bool is() const
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:684
Starts a section of nodes in the document model.
Definition: node.hxx:313
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2295
sw::UnoCursorPointer m_pUnoCursor
Type
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2258
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:178
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:224
virtual sal_Bool SAL_CALL gotoEndOfSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1487
static bool propertyCausesSideEffectsInNodes(sal_uInt16 nWID)
Definition: unoobj.cxx:1748
sal_Int32 nIndex
static sal_uInt16 g_ParaResetableSetRange[]
Definition: unoobj.cxx:2266
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
Marks a position in the document model.
Definition: pam.hxx:36
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
bool IsSectionNode() const
Definition: node.hxx:646
virtual sal_Bool SAL_CALL gotoStartOfParagraph(sal_Bool Expand) override
Definition: unoobj.cxx:1533
::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:2872
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:1511
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:4832
static void lcl_EnumerateIds(sal_uInt16 const *pIdRange, o3tl::sorted_vector< sal_uInt16 > &rWhichIds)
Definition: unoobj.cxx:2285
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
virtual sal_Bool SAL_CALL isEndOfWord() override
Definition: unoobj.cxx:1183
SwNodeIndex nNode
Definition: pam.hxx:38
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:210
bool IsEndWordWT(sal_Int16 nWordType, SwRootFrame const *pLayout=nullptr) const
Definition: swcrsr.cxx:1230
virtual sal_Bool SAL_CALL gotoPreviousWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1242
void SetStyleHandle(const std::shared_ptr< SfxItemSet > &pHandle)
Definition: fmtautofmt.hxx:48
void ClearGrammarCheck()
Definition: txtedt.cxx:2221
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:1062
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:93
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj.cxx:2140
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:121
void SetNumRuleStart(const SwPosition &rPos, bool bFlag=true)
Definition: docnum.cxx:1015
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj.cxx:2041
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:1615
virtual sal_Bool SAL_CALL gotoPreviousSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1436
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj.cxx:1623
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:2016
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:2303
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:1195
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
SwUnoInternalPaM & operator=(const SwPaM &rPaM)
Definition: unoobj.cxx:90
const SwSection & GetSection() const
Definition: node.hxx:543
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:230
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj.cxx:2180
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unoobj.cxx:2793
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:1464
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
#define FN_UNO_LIST_ID
Definition: cmdid.h:605
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:1956
SwIndex nContent
Definition: pam.hxx:39
Any SAL_CALL getCaughtException()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const o3tl::sorted_vector< sal_uInt16 > &rAttrs=o3tl::sorted_vector< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:242
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
Definition: docfmt.cxx:1085
virtual sal_Bool SAL_CALL gotoEndOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1282
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
void getPropertyValue(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
virtual sal_Bool SAL_CALL isEndOfParagraph() override
Definition: unoobj.cxx:1522
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:2275
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:1649
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:154
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj.cxx:2883
void SetCountedInList(bool bCounted)
Definition: ndtxt.cxx:4186
constexpr TypedWhichId< SwFormatAutoFormat > RES_TXTATR_AUTOFMT(50)
void SetWrongDirty(WrongState eNew) const
Definition: txtedt.cxx:2285
SwCharFormat * GetCharFormat()
Definition: docstyle.cxx:2179
bool bIgnoreCase
Definition: sortopt.hxx:55
SwPaM * GetNext()
Definition: pam.hxx:265
SwXTextCursor(SwDoc &rDoc, css::uno::Reference< css::text::XText > const &xParent, const CursorType eType, SwPosition const &rPos, SwPosition const *const pMark=nullptr)
SwPaM & SetPam(size_t nArrPos, SwPaM &rPam)
Definition: ednumber.cxx: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:2877
SwFormatColl & GetAnyFormatColl() const
Definition: node.hxx:709
sal_uInt16 nColumnId
Definition: sortopt.hxx:38
const css::uno::Sequence< sal_Int8 > & getSeq() const
void SetSkipOverProtectSections(bool bFlag)
Definition: unocrsr.hxx:69
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:1977
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj.cxx:1686
virtual sal_Bool SAL_CALL gotoNextSentence(sal_Bool Expand) override
Definition: unoobj.cxx:1401
void SetNodeNumStart(const SwPosition &rPos, sal_uInt16 nStt)
Definition: docnum.cxx:1037
void SetListId(OUString const &rListId)
Definition: ndtxt.cxx:4321
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unoobj.cxx:2534
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:283
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:2124
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
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:402
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:2321
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset)
Definition: ndindex.hxx:274
virtual OUString SAL_CALL getString() override
Definition: unoobj.cxx:1674
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:2156
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
void SetSmartTagDirty(bool bNew) const
Definition: txtedt.cxx:2316
uno_Any a
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual ~SwXTextCursor() override
Definition: unoobj.cxx: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:133
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:206
void SetTextFormatColl(const css::uno::Any &rAny, SwPaM &rPaM)
static bool lcl_ForceIntoMeta(SwPaM &rCursor, uno::Reference< text::XText > const &xParentText, const enum ForceIntoMetaMode eMode)
Definition: unoobj.cxx:752
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1142
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:1354
Marks a node in the document model.
Definition: ndindex.hxx:32
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:365
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:2462
#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:1599
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2168
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:2237
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:2847
enumrange< T >::Iterator end(enumrange< T >)
#define FILTER_TEXT_DLG
text filter with encoding dialog
Definition: iodetect.hxx:36
const SwPosition * Start() const
Definition: pam.hxx:213
SAL_WARN_UNUSED_RESULT WhichRangesContainer MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo) const
#define IMPLEMENT_FORWARD_REFCOUNT(classname, refcountbase)
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
std::size_t ReadBytes(void *pData, std::size_t nSize)
#define UNO_NAME_IS_SKIP_HIDDEN_TEXT
Definition: unoprnms.hxx: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()
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:1698
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:4033
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:2186
#define FN_UNO_NUM_RULES
Definition: cmdid.h:523
virtual sal_Bool SAL_CALL gotoStartOfWord(sal_Bool bExpand) override
Definition: unoobj.cxx:1318
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:2065
#define PROPERTY_NONE
virtual void SAL_CALL insertDocumentFromURL(const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rOptions) override
Definition: unoobj.cxx:2473
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:589
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2246
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:2251
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:1558
virtual sal_Bool SAL_CALL isEndOfSentence() override
Definition: unoobj.cxx:1377
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:2837
constexpr sal_uInt16 RES_PARATR_LIST_BEGIN(RES_PARATR_END)
SwNodes & GetNodes()
Definition: doc.hxx:409
const SwPosition * End() const
Definition: pam.hxx:218
constexpr sal_uInt16 RES_PARATR_END(82)
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx: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:1726
Sequence< sal_Int8 > aSeq
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoobj.cxx:2195
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: unoobj.cxx:2299
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoobj.cxx:2252
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:1583
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:2148
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:2193
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:455
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj.cxx:2098
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:244
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, const OUString &rText, const bool bForceExpandHints)
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj.cxx:2132
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:1944
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:1172
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)
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:2188
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj.cxx:2384
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:2484
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:756
#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:856
CollatorWrapper & GetAppCollator()
Definition: init.cxx:735
Base class of the Writer document model elements.
Definition: node.hxx:81
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo