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