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