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