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