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