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