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