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