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