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