LibreOffice Module editeng (master) 1
unotext.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 <vcl/svapp.hxx>
21#include <com/sun/star/text/ControlCharacter.hpp>
22#include <com/sun/star/text/XTextField.hpp>
23#include <com/sun/star/text/TextRangeSelection.hpp>
24#include <com/sun/star/lang/Locale.hpp>
25#include <com/sun/star/beans/PropertyAttribute.hpp>
26#include <com/sun/star/container/XNameContainer.hpp>
27
28#include <svl/itemset.hxx>
29#include <svl/itempool.hxx>
30#include <svl/eitem.hxx>
31#include <tools/debug.hxx>
32
33#include <editeng/unoprnms.hxx>
34#include <editeng/unotext.hxx>
35#include <editeng/unoedsrc.hxx>
36#include <editeng/unonrule.hxx>
37#include <editeng/unofdesc.hxx>
38#include <editeng/unofield.hxx>
39#include <editeng/flditem.hxx>
40#include <editeng/numitem.hxx>
41#include <editeng/editeng.hxx>
42#include <editeng/outliner.hxx>
43#include <editeng/unoipset.hxx>
44#include <editeng/colritem.hxx>
48
49#include <editeng/unonames.hxx>
50
51#include <initializer_list>
52#include <memory>
53#include <string_view>
54
55using namespace ::cppu;
56using namespace ::com::sun::star;
57
58namespace {
59
60ESelection toESelection(const text::TextRangeSelection& rSel)
61{
62 ESelection aESel;
63 aESel.nStartPara = rSel.Start.Paragraph;
64 aESel.nStartPos = rSel.Start.PositionInParagraph;
65 aESel.nEndPara = rSel.End.Paragraph;
66 aESel.nEndPos = rSel.End.PositionInParagraph;
67 return aESel;
68}
69
70}
71
72#define QUERYINT( xint ) \
73 if( rType == cppu::UnoType<xint>::get() ) \
74 return uno::Any(uno::Reference< xint >(this))
75
77{
79 return &aTextCursorSvxPropertySet;
80}
81
83{
84 // Propertymap for an Outliner Text
85 static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] =
86 {
91 { u"TextField", EE_FEATURE_FIELD, cppu::UnoType<text::XTextField>::get(), beans::PropertyAttribute::READONLY, 0 },
92 { u"TextPortionType", WID_PORTIONTYPE, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 },
93 { u"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
94 { u"ParaUserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
95 };
96 return aSvxTextPortionPropertyMap;
97}
99{
101 return &aSvxTextPortionPropertySet;
102}
103
105{
106 static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() );
107 return &aSvxTextPortionSfxPropertySet;
108}
109
111{
112 // Propertymap for an Outliner Text
113 static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] =
114 {
119 { u"TextUserDefinedAttributes", EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
120 { u"ParaUserDefinedAttributes", EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0},
121 };
122
123 return aSvxUnoOutlinerTextCursorPropertyMap;
124}
126{
127 static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() );
128 return &aTextCursorSfxPropertySet;
129}
130
131
132// helper for Item/Property conversion
133
134
135void GetSelection( struct ESelection& rSel, SvxTextForwarder const * pForwarder ) noexcept
136{
137 DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
138 if( pForwarder )
139 {
140 sal_Int32 nParaCount = pForwarder->GetParagraphCount();
141 if(nParaCount>0)
142 nParaCount--;
143
144 rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount ));
145 }
146}
147
148void CheckSelection( struct ESelection& rSel, SvxTextForwarder const * pForwarder ) noexcept
149{
150 DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" );
151 if( !pForwarder )
152 return;
153
154 if( rSel.nStartPara == EE_PARA_MAX_COUNT )
155 {
156 ::GetSelection( rSel, pForwarder );
157 }
158 else
159 {
160 ESelection aMaxSelection;
161 GetSelection( aMaxSelection, pForwarder );
162
163 // check start position
164 if( rSel.nStartPara < aMaxSelection.nStartPara )
165 {
166 rSel.nStartPara = aMaxSelection.nStartPara;
167 rSel.nStartPos = aMaxSelection.nStartPos;
168 }
169 else if( rSel.nStartPara > aMaxSelection.nEndPara )
170 {
171 rSel.nStartPara = aMaxSelection.nEndPara;
172 rSel.nStartPos = aMaxSelection.nEndPos;
173 }
174 else if( rSel.nStartPos > pForwarder->GetTextLen( rSel.nStartPara ) )
175 {
176 rSel.nStartPos = pForwarder->GetTextLen( rSel.nStartPara );
177 }
178
179 // check end position
180 if( rSel.nEndPara < aMaxSelection.nStartPara )
181 {
182 rSel.nEndPara = aMaxSelection.nStartPara;
183 rSel.nEndPos = aMaxSelection.nStartPos;
184 }
185 else if( rSel.nEndPara > aMaxSelection.nEndPara )
186 {
187 rSel.nEndPara = aMaxSelection.nEndPara;
188 rSel.nEndPos = aMaxSelection.nEndPos;
189 }
190 else if( rSel.nEndPos > pForwarder->GetTextLen( rSel.nEndPara ) )
191 {
192 rSel.nEndPos = pForwarder->GetTextLen( rSel.nEndPara );
193 }
194 }
195}
196
197static void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) noexcept
198{
199 if (!pEdit)
200 return;
201 CheckSelection( rSel, pEdit->GetTextForwarder() );
202}
203
204
205
206
207UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase );
208
209SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxItemPropertySet* _pSet)
210 : mpPropSet(_pSet)
211{
212}
213
214SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const SvxItemPropertySet* _pSet)
215: mpPropSet(_pSet)
216{
217 SolarMutexGuard aGuard;
218
219 DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
220
221 mpEditSource = pSource->Clone();
222 if (mpEditSource != nullptr)
223 {
224 ESelection aSelection;
225 ::GetSelection( aSelection, mpEditSource->GetTextForwarder() );
226 SetSelection( aSelection );
227
228 mpEditSource->addRange( this );
229 }
230}
231
232SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange)
233: text::XTextRange()
234, beans::XPropertySet()
235, beans::XMultiPropertySet()
236, beans::XMultiPropertyStates()
237, beans::XPropertyState()
238, lang::XServiceInfo()
239, text::XTextRangeCompare()
240, lang::XUnoTunnel()
241, osl::DebugBase<SvxUnoTextRangeBase>()
242, mpPropSet(rRange.getPropertySet())
243{
244 SolarMutexGuard aGuard;
245
246 if (rRange.mpEditSource)
247 mpEditSource = rRange.mpEditSource->Clone();
248
249 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
250 if( pForwarder )
251 {
252 maSelection = rRange.maSelection;
253 CheckSelection( maSelection, pForwarder );
254 }
255
256 if( mpEditSource )
257 mpEditSource->addRange( this );
258}
259
260SvxUnoTextRangeBase::~SvxUnoTextRangeBase() noexcept
261{
262 if( mpEditSource )
263 mpEditSource->removeRange( this );
264}
265
266void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) noexcept
267{
268 DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
269 DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
270
271 mpEditSource.reset( pSource );
272
273 maSelection.nStartPara = EE_PARA_MAX_COUNT;
274
275 if( mpEditSource )
276 mpEditSource->addRange( this );
277}
278
281void SvxUnoTextRangeBase::attachField( std::unique_ptr<SvxFieldData> pData ) noexcept
282{
283 SolarMutexGuard aGuard;
284
285 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
286 if( pForwarder )
287 {
288 SvxFieldItem aField( std::move(pData), EE_FEATURE_FIELD );
289 pForwarder->QuickInsertField( std::move(aField), maSelection );
290 }
291}
292
293void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) noexcept
294{
295 SolarMutexGuard aGuard;
296
297 maSelection = rSelection;
298 CheckSelection( maSelection, mpEditSource.get() );
299}
300
301// Interface XTextRange ( XText )
302
303uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart()
304{
305 SolarMutexGuard aGuard;
306
307 uno::Reference< text::XTextRange > xRange;
308
309 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
310 if( pForwarder )
311 {
312 CheckSelection( maSelection, pForwarder );
313
314 SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() );
315
316 if(pText == nullptr)
317 throw uno::RuntimeException();
318
320 xRange = pRange;
321
322 ESelection aNewSel = maSelection;
323 aNewSel.nEndPara = aNewSel.nStartPara;
324 aNewSel.nEndPos = aNewSel.nStartPos;
325 pRange->SetSelection( aNewSel );
326 }
327
328 return xRange;
329}
330
331uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd()
332{
333 SolarMutexGuard aGuard;
334
335 uno::Reference< text::XTextRange > xRet;
336
337 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
338 if( pForwarder )
339 {
340 CheckSelection( maSelection, pForwarder );
341
342 SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() );
343
344 if(pText == nullptr)
345 throw uno::RuntimeException();
346
348 xRet = pNew;
349
350 ESelection aNewSel = maSelection;
351 aNewSel.nStartPara = aNewSel.nEndPara;
352 aNewSel.nStartPos = aNewSel.nEndPos;
353 pNew->SetSelection( aNewSel );
354 }
355 return xRet;
356}
357
358OUString SAL_CALL SvxUnoTextRangeBase::getString()
359{
360 SolarMutexGuard aGuard;
361
362 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
363 if( pForwarder )
364 {
365 CheckSelection( maSelection, pForwarder );
366
367 return pForwarder->GetText( maSelection );
368 }
369 else
370 {
371 return OUString();
372 }
373}
374
375void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString)
376{
377 SolarMutexGuard aGuard;
378
379 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
380 if( !pForwarder )
381 return;
382
383 CheckSelection( maSelection, pForwarder );
384
385 OUString aConverted(convertLineEnd(aString, LINEEND_LF)); // Simply count the number of line endings
386
387 pForwarder->QuickInsertText( aConverted, maSelection );
388 mpEditSource->UpdateData();
389
390 // Adapt selection
393 CollapseToStart();
394
395 sal_Int32 nLen = aConverted.getLength();
396 if (nLen)
397 GoRight( nLen, true );
398}
399
400// Interface beans::XPropertySet
401uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo()
402{
403 return mpPropSet->getPropertySetInfo();
404}
405
406void SAL_CALL SvxUnoTextRangeBase::setPropertyValue(const OUString& PropertyName, const uno::Any& aValue)
407{
408 if (PropertyName == UNO_TR_PROP_SELECTION)
409 {
410 text::TextRangeSelection aSel = aValue.get<text::TextRangeSelection>();
411 SetSelection(toESelection(aSel));
412
413 return;
414 }
415
416 _setPropertyValue( PropertyName, aValue );
417}
418
419void SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyName, const uno::Any& aValue, sal_Int32 nPara )
420{
421 SolarMutexGuard aGuard;
422
423 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
424 if( pForwarder )
425 {
426 CheckSelection( maSelection, pForwarder );
427
428 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
429 if ( pMap )
430 {
431 ESelection aSel( GetSelection() );
432 bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
433
434 if (pMap->nWID == WID_PARASTYLENAME)
435 {
436 OUString aStyle = aValue.get<OUString>();
437
438 sal_Int32 nEndPara;
439
440 if( nPara == -1 )
441 {
442 nPara = aSel.nStartPara;
443 nEndPara = aSel.nEndPara;
444 }
445 else
446 {
447 // only one paragraph
448 nEndPara = nPara;
449 }
450
451 while( nPara <= nEndPara )
452 {
453 pForwarder->SetStyleSheet(nPara, aStyle);
454 nPara++;
455 }
456 }
457 else if ( nPara == -1 && !bParaAttrib )
458 {
459 SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) );
460 // we have a selection and no para attribute
461 SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() );
462
463 setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet );
464
465
466 pForwarder->QuickSetAttribs( aNewSet, GetSelection() );
467 }
468 else
469 {
470 sal_Int32 nEndPara;
471
472 if( nPara == -1 )
473 {
474 nPara = aSel.nStartPara;
475 nEndPara = aSel.nEndPara;
476 }
477 else
478 {
479 // only one paragraph
480 nEndPara = nPara;
481 }
482
483 while( nPara <= nEndPara )
484 {
485 // we have a paragraph
486 SfxItemSet aSet( pForwarder->GetParaAttribs( nPara ) );
487 setPropertyValue( pMap, aValue, maSelection, aSet, aSet );
488 pForwarder->SetParaAttribs( nPara, aSet );
489 nPara++;
490 }
491 }
492
493 GetEditSource()->UpdateData();
494 return;
495 }
496 }
497
498 throw beans::UnknownPropertyException(PropertyName);
499}
500
501void SvxUnoTextRangeBase::setPropertyValue( const SfxItemPropertyMapEntry* pMap, const uno::Any& rValue, const ESelection& rSelection, const SfxItemSet& rOldSet, SfxItemSet& rNewSet )
502{
503 if(!SetPropertyValueHelper( pMap, rValue, rNewSet, &rSelection, GetEditSource() ))
504 {
505 // For parts of composite items with multiple properties (eg background)
506 // must be taken from the document before the old item.
507 rNewSet.Put(rOldSet.Get(pMap->nWID)); // Old Item in new Set
508 SvxItemPropertySet::setPropertyValue(pMap, rValue, rNewSet, false );
509 }
510}
511
512bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertyMapEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ )
513{
514 switch( pMap->nWID )
515 {
516 case WID_FONTDESC:
517 {
518 awt::FontDescriptor aDesc;
519 if(aValue >>= aDesc)
520 {
521 SvxUnoFontDescriptor::FillItemSet( aDesc, rNewSet );
522 return true;
523 }
524 }
525 break;
526
528 {
529 uno::Reference< container::XIndexReplace > xRule;
530 return !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is());
531 }
532
534 {
535 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
536 if(pForwarder && pSelection)
537 {
538 sal_Int16 nLevel = sal_Int16();
539 if( aValue >>= nLevel )
540 {
541 // #101004# Call interface method instead of unsafe cast
542 if(! pForwarder->SetDepth( pSelection->nStartPara, nLevel ) )
543 throw lang::IllegalArgumentException();
544
545 // If valid, then not yet finished. Also needs to be added to paragraph props.
546 return nLevel < -1 || nLevel > 9;
547 }
548 }
549 }
550 break;
552 {
553 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
554 if(pForwarder && pSelection)
555 {
556 sal_Int16 nStartValue = -1;
557 if( aValue >>= nStartValue )
558 {
559 pForwarder->SetNumberingStartValue( pSelection->nStartPara, nStartValue );
560 return true;
561 }
562 }
563 }
564 break;
566 {
567 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
568 if(pForwarder && pSelection)
569 {
570 bool bParaIsNumberingRestart = false;
571 if( aValue >>= bParaIsNumberingRestart )
572 {
573 pForwarder->SetParaIsNumberingRestart( pSelection->nStartPara, bParaIsNumberingRestart );
574 return true;
575 }
576 }
577 }
578 break;
580 {
581 bool bBullet = true;
582 if( aValue >>= bBullet )
583 {
584 SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet );
585 rNewSet.Put(aItem);
586 return true;
587 }
588 }
589 break;
590
591 default:
592 return false;
593 }
594
595 throw lang::IllegalArgumentException();
596}
597
598uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName)
599{
600 if (PropertyName == UNO_TR_PROP_SELECTION)
601 {
602 const ESelection& rSel = GetSelection();
603 text::TextRangeSelection aSel;
604 aSel.Start.Paragraph = rSel.nStartPara;
605 aSel.Start.PositionInParagraph = rSel.nStartPos;
606 aSel.End.Paragraph = rSel.nEndPara;
607 aSel.End.PositionInParagraph = rSel.nEndPos;
608 return uno::Any(aSel);
609 }
610
611 return _getPropertyValue( PropertyName );
612}
613
614uno::Any SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara )
615{
616 SolarMutexGuard aGuard;
617
618 uno::Any aAny;
619
620 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
621 if( pForwarder )
622 {
623 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName );
624 if( pMap )
625 {
626 std::optional<SfxItemSet> oAttribs;
627 if( nPara != -1 )
628 oAttribs.emplace(pForwarder->GetParaAttribs( nPara ).CloneAsValue());
629 else
630 oAttribs.emplace(pForwarder->GetAttribs( GetSelection() ).CloneAsValue());
631
632 // Replace Dontcare with Default, so that one always has a mirror
633 oAttribs->ClearInvalidItems();
634
635 getPropertyValue( pMap, aAny, *oAttribs );
636
637 return aAny;
638 }
639 }
640
641 throw beans::UnknownPropertyException(PropertyName);
642}
643
644void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertyMapEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet )
645{
646 switch( pMap->nWID )
647 {
648 case EE_FEATURE_FIELD:
649 if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SfxItemState::SET )
650 {
652 const SvxFieldData* pData = pItem->GetField();
653 uno::Reference< text::XTextRange > xAnchor( this );
654
655 // get presentation string for field
656 std::optional<Color> pTColor;
657 std::optional<Color> pFColor;
658 std::optional<FontLineStyle> pFldLineStyle;
659
660 SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
661 OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.nStartPara, maSelection.nStartPos, pTColor, pFColor, pFldLineStyle ) );
662
663 uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) );
664 rAny <<= xField;
665 }
666 break;
667
668 case WID_PORTIONTYPE:
669 if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SfxItemState::SET )
670 {
671 rAny <<= OUString("TextField");
672 }
673 else
674 {
675 rAny <<= OUString("Text");
676 }
677 break;
678
680 {
681 rAny <<= GetEditSource()->GetTextForwarder()->GetStyleSheet(maSelection.nStartPara);
682 }
683 break;
684
685 default:
686 if(!GetPropertyValueHelper( *const_cast<SfxItemSet*>(&rSet), pMap, rAny, &maSelection, GetEditSource() ))
687 rAny = SvxItemPropertySet::getPropertyValue(pMap, rSet, true, false );
688 }
689}
690
691bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, const SfxItemPropertyMapEntry* pMap, uno::Any& aAny, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL */ )
692{
693 switch( pMap->nWID )
694 {
695 case WID_FONTDESC:
696 {
697 awt::FontDescriptor aDesc;
699 aAny <<= aDesc;
700 }
701 break;
702
704 {
706 if( eState != SfxItemState::SET && eState != SfxItemState::DEFAULT)
707 throw uno::RuntimeException();
708
709 const SvxNumBulletItem* pBulletItem = rSet.GetItem( EE_PARA_NUMBULLET );
710
711 if( pBulletItem == nullptr )
712 throw uno::RuntimeException();
713
714 aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() );
715 }
716 break;
717
719 {
720 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
721 if(pForwarder && pSelection)
722 {
723 sal_Int16 nLevel = pForwarder->GetDepth( pSelection->nStartPara );
724 if( nLevel >= 0 )
725 aAny <<= nLevel;
726 }
727 }
728 break;
730 {
731 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
732 if(pForwarder && pSelection)
733 aAny <<= pForwarder->GetNumberingStartValue( pSelection->nStartPara );
734 }
735 break;
737 {
738 SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr;
739 if(pForwarder && pSelection)
740 aAny <<= pForwarder->IsParaIsNumberingRestart( pSelection->nStartPara );
741 }
742 break;
743
745 {
746 bool bState = false;
748 if( eState == SfxItemState::SET || eState == SfxItemState::DEFAULT )
749 {
751 bState = pItem->GetValue();
752 }
753
754 aAny <<= bState;
755 }
756 break;
757 default:
758
759 return false;
760 }
761
762 return true;
763}
764
765// is not (yet) supported
766void SAL_CALL SvxUnoTextRangeBase::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {}
767void SAL_CALL SvxUnoTextRangeBase::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {}
768void SAL_CALL SvxUnoTextRangeBase::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {}
769void SAL_CALL SvxUnoTextRangeBase::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {}
770
771// XMultiPropertySet
772void SAL_CALL SvxUnoTextRangeBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues )
773{
774 _setPropertyValues( aPropertyNames, aValues );
775}
776
777void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues, sal_Int32 nPara )
778{
779 if (aPropertyNames.getLength() != aValues.getLength())
780 throw lang::IllegalArgumentException("lengths do not match",
781 static_cast<css::beans::XPropertySet*>(this), -1);
782
783 SolarMutexGuard aGuard;
784
785 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
786 if( !pForwarder )
787 return;
788
789 CheckSelection( maSelection, pForwarder );
790
791 ESelection aSel( GetSelection() );
792
793 const OUString* pPropertyNames = aPropertyNames.getConstArray();
794 const uno::Any* pValues = aValues.getConstArray();
795 sal_Int32 nCount = aPropertyNames.getLength();
796
797 sal_Int32 nEndPara = nPara;
798 sal_Int32 nTempPara = nPara;
799
800 if( nTempPara == -1 )
801 {
802 nTempPara = aSel.nStartPara;
803 nEndPara = aSel.nEndPara;
804 }
805
806 std::optional<SfxItemSet> pOldAttrSet;
807 std::optional<SfxItemSet> pNewAttrSet;
808
809 std::optional<SfxItemSet> pOldParaSet;
810 std::optional<SfxItemSet> pNewParaSet;
811
812 std::optional<OUString> aStyleName;
813
814 for( ; nCount; nCount--, pPropertyNames++, pValues++ )
815 {
816 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
817
818 if( pMap )
819 {
820 bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END );
821
822 if (pMap->nWID == WID_PARASTYLENAME)
823 {
824 aStyleName.emplace((*pValues).get<OUString>());
825 }
826 else if( (nPara == -1) && !bParaAttrib )
827 {
828 if( !pNewAttrSet )
829 {
830 pOldAttrSet.emplace( pForwarder->GetAttribs( aSel ) );
831 pNewAttrSet.emplace( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() );
832 }
833
834 setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet );
835
836 if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
837 {
838 const SfxPoolItem* pItem;
839 if( pNewAttrSet->GetItemState( pMap->nWID, true, &pItem ) == SfxItemState::SET )
840 {
841 pOldAttrSet->Put( *pItem );
842 }
843 }
844 }
845 else
846 {
847 if( !pNewParaSet )
848 {
849 const SfxItemSet & rSet = pForwarder->GetParaAttribs( nTempPara );
850 pOldParaSet.emplace( rSet );
851 pNewParaSet.emplace( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() );
852 }
853
854 setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet );
855
856 if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END )
857 {
858 const SfxPoolItem* pItem;
859 if( pNewParaSet->GetItemState( pMap->nWID, true, &pItem ) == SfxItemState::SET )
860 {
861 pOldParaSet->Put( *pItem );
862 }
863 }
864
865 }
866 }
867 }
868
869 bool bNeedsUpdate = false;
870
871 if( pNewParaSet || aStyleName )
872 {
873 if( pNewParaSet->Count() )
874 {
875 while( nTempPara <= nEndPara )
876 {
877 SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) );
878 aSet.Put( *pNewParaSet );
879 pForwarder->SetParaAttribs( nTempPara, aSet );
880 if (aStyleName)
881 pForwarder->SetStyleSheet(nTempPara, *aStyleName);
882 nTempPara++;
883 }
884 bNeedsUpdate = true;
885 }
886
887 pNewParaSet.reset();
888 pOldParaSet.reset();
889 }
890
891 if( pNewAttrSet )
892 {
893 if( pNewAttrSet->Count() )
894 {
895 pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() );
896 bNeedsUpdate = true;
897 }
898 pNewAttrSet.reset();
899 pOldAttrSet.reset();
900 }
901
902 if( bNeedsUpdate )
903 GetEditSource()->UpdateData();
904}
905
906uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames )
907{
908 return _getPropertyValues( aPropertyNames );
909}
910
911uno::Sequence< uno::Any > SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< OUString >& aPropertyNames, sal_Int32 nPara )
912{
913 SolarMutexGuard aGuard;
914
915 sal_Int32 nCount = aPropertyNames.getLength();
916
917
918 uno::Sequence< uno::Any > aValues( nCount );
919
920 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
921 if( pForwarder )
922 {
923 std::optional<SfxItemSet> oAttribs;
924 if( nPara != -1 )
925 oAttribs.emplace(pForwarder->GetParaAttribs( nPara ).CloneAsValue());
926 else
927 oAttribs.emplace(pForwarder->GetAttribs( GetSelection() ).CloneAsValue() );
928
929 oAttribs->ClearInvalidItems();
930
931 const OUString* pPropertyNames = aPropertyNames.getConstArray();
932 uno::Any* pValues = aValues.getArray();
933
934 for( ; nCount; nCount--, pPropertyNames++, pValues++ )
935 {
936 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames );
937 if( pMap )
938 {
939 getPropertyValue( pMap, *pValues, *oAttribs );
940 }
941 }
942 }
943
944 return aValues;
945}
946
947void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& )
948{
949}
950
951void SAL_CALL SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& )
952{
953}
954
955void SAL_CALL SvxUnoTextRangeBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& )
956{
957}
958
959// beans::XPropertyState
960beans::PropertyState SAL_CALL SvxUnoTextRangeBase::getPropertyState( const OUString& PropertyName )
961{
962 return _getPropertyState( PropertyName );
963}
964
967 EE_CHAR_WLM, 0 };
968
969beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertyMapEntry* pMap, sal_Int32 nPara)
970{
971 if ( pMap )
972 {
973 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
974 if( pForwarder )
975 {
976 SfxItemState eItemState(SfxItemState::DEFAULT);
977 bool bItemStateSet(false);
978
979 switch( pMap->nWID )
980 {
981 case WID_FONTDESC:
982 {
983 const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
984 while( *pWhichId )
985 {
986 const SfxItemState eTempItemState(nPara != -1
987 ? pForwarder->GetItemState( nPara, *pWhichId )
988 : pForwarder->GetItemState( GetSelection(), *pWhichId ));
989
990 switch( eTempItemState )
991 {
992 case SfxItemState::DISABLED:
993 case SfxItemState::DONTCARE:
994 eItemState = SfxItemState::DONTCARE;
995 bItemStateSet = true;
996 break;
997
998 case SfxItemState::DEFAULT:
999 if( !bItemStateSet )
1000 {
1001 eItemState = SfxItemState::DEFAULT;
1002 bItemStateSet = true;
1003 }
1004 break;
1005
1006 case SfxItemState::SET:
1007 if( !bItemStateSet )
1008 {
1009 eItemState = SfxItemState::SET;
1010 bItemStateSet = true;
1011 }
1012 break;
1013 default:
1014 throw beans::UnknownPropertyException();
1015 }
1016
1017 pWhichId++;
1018 }
1019 }
1020 break;
1021
1024 case WID_PARASTYLENAME:
1025 eItemState = SfxItemState::SET;
1026 bItemStateSet = true;
1027 break;
1028
1029 default:
1030 if(0 != pMap->nWID)
1031 {
1032 if( nPara != -1 )
1033 eItemState = pForwarder->GetItemState( nPara, pMap->nWID );
1034 else
1035 eItemState = pForwarder->GetItemState( GetSelection(), pMap->nWID );
1036
1037 bItemStateSet = true;
1038 }
1039 break;
1040 }
1041
1042 if(bItemStateSet)
1043 {
1044 switch( eItemState )
1045 {
1046 case SfxItemState::DONTCARE:
1047 case SfxItemState::DISABLED:
1048 return beans::PropertyState_AMBIGUOUS_VALUE;
1049 case SfxItemState::SET:
1050 return beans::PropertyState_DIRECT_VALUE;
1051 case SfxItemState::DEFAULT:
1052 return beans::PropertyState_DEFAULT_VALUE;
1053 default: break;
1054 }
1055 }
1056 }
1057 }
1058 throw beans::UnknownPropertyException();
1059}
1060
1061beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(std::u16string_view PropertyName, sal_Int32 nPara /* = -1 */)
1062{
1063 SolarMutexGuard aGuard;
1064
1065 return _getPropertyState( mpPropSet->getPropertyMapEntry( PropertyName ), nPara);
1066}
1067
1068uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
1069{
1070 return _getPropertyStates( aPropertyName );
1071}
1072
1073uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */)
1074{
1075 uno::Sequence< beans::PropertyState > aRet( PropertyName.getLength() );
1076
1077 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
1078 if( pForwarder )
1079 {
1080 std::optional<SfxItemSet> pSet;
1081 if( nPara != -1 )
1082 {
1083 pSet.emplace( pForwarder->GetParaAttribs( nPara ) );
1084 }
1085 else
1086 {
1087 ESelection aSel( GetSelection() );
1088 CheckSelection( aSel, pForwarder );
1089 pSet.emplace( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) );
1090 }
1091
1092 beans::PropertyState* pState = aRet.getArray();
1093 for( const OUString& rName : PropertyName )
1094 {
1095 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( rName );
1096 if( !_getOnePropertyStates(&*pSet, pMap, *pState++) )
1097 {
1098 throw beans::UnknownPropertyException(rName);
1099 }
1100 }
1101 }
1102
1103 return aRet;
1104}
1105
1106bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet* pSet, const SfxItemPropertyMapEntry* pMap, beans::PropertyState& rState)
1107{
1108 if(!pSet || !pMap)
1109 return true;
1110 SfxItemState eItemState = SfxItemState::DEFAULT;
1111 bool bItemStateSet(false);
1112
1113 bool bUnknownPropertyFound = false;
1114 switch( pMap->nWID )
1115 {
1116 case WID_FONTDESC:
1117 {
1118 const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap;
1119 while( *pWhichId )
1120 {
1121 const SfxItemState eTempItemState(pSet->GetItemState( *pWhichId ));
1122
1123 switch( eTempItemState )
1124 {
1125 case SfxItemState::DISABLED:
1126 case SfxItemState::DONTCARE:
1127 eItemState = SfxItemState::DONTCARE;
1128 bItemStateSet = true;
1129 break;
1130
1131 case SfxItemState::DEFAULT:
1132 if( !bItemStateSet )
1133 {
1134 eItemState = SfxItemState::DEFAULT;
1135 bItemStateSet = true;
1136 }
1137 break;
1138
1139 case SfxItemState::SET:
1140 if( !bItemStateSet )
1141 {
1142 eItemState = SfxItemState::SET;
1143 bItemStateSet = true;
1144 }
1145 break;
1146 default:
1147 bUnknownPropertyFound = true;
1148 break;
1149 }
1150
1151 pWhichId++;
1152 }
1153 }
1154 break;
1155
1158 case WID_PARASTYLENAME:
1159 eItemState = SfxItemState::SET;
1160 bItemStateSet = true;
1161 break;
1162
1163 default:
1164 if(0 != pMap->nWID)
1165 {
1166 eItemState = pSet->GetItemState( pMap->nWID, false );
1167 bItemStateSet = true;
1168 }
1169 break;
1170 }
1171
1172 if( bUnknownPropertyFound )
1173 return false;
1174
1175 if(bItemStateSet)
1176 {
1177 if (pMap->nWID == EE_CHAR_COLOR)
1178 {
1179 // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color
1180 // which is a DIRECT_VALUE.
1181 const SvxColorItem* pColor = pSet->GetItem<SvxColorItem>(EE_CHAR_COLOR);
1182 switch (pMap->nMemberId)
1183 {
1186 {
1187 eItemState = SfxItemState::DEFAULT;
1188 }
1189 break;
1190 case MID_COLOR_LUM_MOD:
1191 {
1192 sal_Int16 nLumMod = 10000;
1193 for (auto const& rTransform : pColor->getComplexColor().getTransformations())
1194 {
1195 if (rTransform.meType == model::TransformationType::LumMod)
1196 nLumMod = rTransform.mnValue;
1197 }
1198 if (nLumMod == 10000)
1199 {
1200 eItemState = SfxItemState::DEFAULT;
1201 }
1202 break;
1203 }
1204 case MID_COLOR_LUM_OFF:
1205 {
1206 sal_Int16 nLumOff = 0;
1207 for (auto const& rTransform : pColor->getComplexColor().getTransformations())
1208 {
1209 if (rTransform.meType == model::TransformationType::LumOff)
1210 nLumOff = rTransform.mnValue;
1211 }
1212 if (nLumOff == 0)
1213 {
1214 eItemState = SfxItemState::DEFAULT;
1215 }
1216 break;
1217 }
1218 case MID_COMPLEX_COLOR:
1220 {
1221 eItemState = SfxItemState::DEFAULT;
1222 }
1223 break;
1224 }
1225 }
1226
1227 switch( eItemState )
1228 {
1229 case SfxItemState::SET:
1230 rState = beans::PropertyState_DIRECT_VALUE;
1231 break;
1232 case SfxItemState::DEFAULT:
1233 rState = beans::PropertyState_DEFAULT_VALUE;
1234 break;
1235// case SfxItemState::DONTCARE:
1236// case SfxItemState::DISABLED:
1237 default:
1238 rState = beans::PropertyState_AMBIGUOUS_VALUE;
1239 }
1240 }
1241 else
1242 {
1243 rState = beans::PropertyState_AMBIGUOUS_VALUE;
1244 }
1245 return true;
1246}
1247
1248void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName )
1249{
1250 _setPropertyToDefault( PropertyName );
1251}
1252
1253void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString& PropertyName, sal_Int32 nPara /* = -1 */)
1254{
1255 SolarMutexGuard aGuard;
1256
1257 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
1258
1259 if( pForwarder )
1260 {
1261 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( PropertyName );
1262 if ( pMap )
1263 {
1264 CheckSelection( maSelection, mpEditSource->GetTextForwarder() );
1265 _setPropertyToDefault( pForwarder, pMap, nPara );
1266 return;
1267 }
1268 }
1269
1270 throw beans::UnknownPropertyException(PropertyName);
1271}
1272
1273void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, const SfxItemPropertyMapEntry* pMap, sal_Int32 nPara )
1274{
1275 do
1276 {
1277 SfxItemSet aSet(*pForwarder->GetPool());
1278
1279 if( pMap->nWID == WID_FONTDESC )
1280 {
1282 }
1283 else if( pMap->nWID == WID_NUMBERINGSTARTVALUE )
1284 {
1285 pForwarder->SetNumberingStartValue( maSelection.nStartPara, -1 );
1286 }
1287 else if( pMap->nWID == WID_PARAISNUMBERINGRESTART )
1288 {
1289 pForwarder->SetParaIsNumberingRestart( maSelection.nStartPara, false );
1290 }
1291 else
1292 {
1293 aSet.InvalidateItem( pMap->nWID );
1294 }
1295
1296 if(nPara != -1)
1297 pForwarder->SetParaAttribs( nPara, aSet );
1298 else
1299 pForwarder->QuickSetAttribs( aSet, GetSelection() );
1300
1301 GetEditSource()->UpdateData();
1302
1303 return;
1304 }
1305 while(false);
1306}
1307
1308uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aPropertyName )
1309{
1310 SolarMutexGuard aGuard;
1311
1312 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
1313 if( pForwarder )
1314 {
1315 const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( aPropertyName );
1316 if( pMap )
1317 {
1318 SfxItemPool* pPool = pForwarder->GetPool();
1319
1320 switch( pMap->nWID )
1321 {
1322 case WID_FONTDESC:
1324
1325 case EE_PARA_OUTLLEVEL:
1326 {
1327 uno::Any aAny;
1328 return aAny;
1329 }
1330
1332 return uno::Any( sal_Int16(-1) );
1333
1335 return uno::Any( false );
1336
1337 default:
1338 {
1339 // Get Default from ItemPool
1340 if(SfxItemPool::IsWhich(pMap->nWID))
1341 {
1342 SfxItemSet aSet( *pPool, pMap->nWID, pMap->nWID );
1343 aSet.Put(pPool->GetDefaultItem(pMap->nWID));
1344 return SvxItemPropertySet::getPropertyValue(pMap, aSet, true, false );
1345 }
1346 }
1347 }
1348 }
1349 }
1350 throw beans::UnknownPropertyException(aPropertyName);
1351}
1352
1353// beans::XMultiPropertyStates
1354void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault()
1355{
1356 SolarMutexGuard aGuard;
1357
1358 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
1359
1360 if( pForwarder )
1361 {
1362 for (const SfxItemPropertyMapEntry* entry : mpPropSet->getPropertyMap().getPropertyEntries())
1363 {
1364 _setPropertyToDefault( pForwarder, entry, -1 );
1365 }
1366 }
1367}
1368
1369void SAL_CALL SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
1370{
1371 for( const OUString& rName : aPropertyNames )
1372 {
1373 setPropertyToDefault( rName );
1374 }
1375}
1376
1377uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
1378{
1379 uno::Sequence< uno::Any > ret( aPropertyNames.getLength() );
1380 uno::Any* pDefaults = ret.getArray();
1381
1382 for( const OUString& rName : aPropertyNames )
1383 {
1384 *pDefaults++ = getPropertyDefault( rName );
1385 }
1386
1387 return ret;
1388}
1389
1390// internal
1391void SvxUnoTextRangeBase::CollapseToStart() noexcept
1392{
1393 CheckSelection( maSelection, mpEditSource.get() );
1394
1395 maSelection.nEndPara = maSelection.nStartPara;
1396 maSelection.nEndPos = maSelection.nStartPos;
1397}
1398
1399void SvxUnoTextRangeBase::CollapseToEnd() noexcept
1400{
1401 CheckSelection( maSelection, mpEditSource.get() );
1402
1403 maSelection.nStartPara = maSelection.nEndPara;
1404 maSelection.nStartPos = maSelection.nEndPos;
1405}
1406
1407bool SvxUnoTextRangeBase::IsCollapsed() noexcept
1408{
1409 CheckSelection( maSelection, mpEditSource.get() );
1410
1411 return ( maSelection.nStartPara == maSelection.nEndPara &&
1412 maSelection.nStartPos == maSelection.nEndPos );
1413}
1414
1415bool SvxUnoTextRangeBase::GoLeft(sal_Int32 nCount, bool Expand) noexcept
1416{
1417 CheckSelection( maSelection, mpEditSource.get() );
1418
1419 // #75098# use end position, as in Writer (start is anchor, end is cursor)
1420 sal_Int32 nNewPos = maSelection.nEndPos;
1421 sal_Int32 nNewPar = maSelection.nEndPara;
1422
1423 bool bOk = true;
1424 SvxTextForwarder* pForwarder = nullptr;
1425 while ( nCount > nNewPos && bOk )
1426 {
1427 if ( nNewPar == 0 )
1428 bOk = false;
1429 else
1430 {
1431 if ( !pForwarder )
1432 pForwarder = mpEditSource->GetTextForwarder(); // first here, it is necessary...
1433
1434 --nNewPar;
1435 nCount -= nNewPos + 1;
1436 nNewPos = pForwarder->GetTextLen( nNewPar );
1437 }
1438 }
1439
1440 if ( bOk )
1441 {
1442 nNewPos = nNewPos - nCount;
1443 maSelection.nStartPara = nNewPar;
1444 maSelection.nStartPos = nNewPos;
1445 }
1446
1447 if (!Expand)
1448 CollapseToStart();
1449
1450 return bOk;
1451}
1452
1453bool SvxUnoTextRangeBase::GoRight(sal_Int32 nCount, bool Expand) noexcept
1454{
1455 if (!mpEditSource)
1456 return false;
1457 SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder();
1458 if( !pForwarder )
1459 return false;
1460
1461 CheckSelection( maSelection, pForwarder );
1462
1463 sal_Int32 nNewPos = maSelection.nEndPos + nCount;
1464 sal_Int32 nNewPar = maSelection.nEndPara;
1465
1466 bool bOk = true;
1467 sal_Int32 nParCount = pForwarder->GetParagraphCount();
1468 sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar );
1469 while ( nNewPos > nThisLen && bOk )
1470 {
1471 if ( nNewPar + 1 >= nParCount )
1472 bOk = false;
1473 else
1474 {
1475 nNewPos -= nThisLen+1;
1476 ++nNewPar;
1477 nThisLen = pForwarder->GetTextLen( nNewPar );
1478 }
1479 }
1480
1481 if (bOk)
1482 {
1483 maSelection.nEndPara = nNewPar;
1484 maSelection.nEndPos = nNewPos;
1485 }
1486
1487 if (!Expand)
1488 CollapseToEnd();
1489
1490 return bOk;
1491}
1492
1493void SvxUnoTextRangeBase::GotoStart(bool Expand) noexcept
1494{
1495 maSelection.nStartPara = 0;
1496 maSelection.nStartPos = 0;
1497
1498 if (!Expand)
1499 CollapseToStart();
1500}
1501
1502void SvxUnoTextRangeBase::GotoEnd(bool Expand) noexcept
1503{
1504 CheckSelection( maSelection, mpEditSource.get() );
1505
1506 SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
1507 if( !pForwarder )
1508 return;
1509
1510 sal_Int32 nPar = pForwarder->GetParagraphCount();
1511 if (nPar)
1512 --nPar;
1513
1514 maSelection.nEndPara = nPar;
1515 maSelection.nEndPos = pForwarder->GetTextLen( nPar );
1516
1517 if (!Expand)
1518 CollapseToEnd();
1519}
1520
1521// lang::XServiceInfo
1522sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName )
1523{
1524 return cppu::supportsService( this, ServiceName );
1525}
1526
1527uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames()
1528{
1529 return getSupportedServiceNames_Static();
1530}
1531
1532uno::Sequence< OUString > SvxUnoTextRangeBase::getSupportedServiceNames_Static()
1533{
1534 return { "com.sun.star.style.CharacterProperties",
1535 "com.sun.star.style.CharacterPropertiesComplex",
1536 "com.sun.star.style.CharacterPropertiesAsian" };
1537}
1538
1539// XTextRangeCompare
1540sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 )
1541{
1542 SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 );
1543 SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 );
1544
1545 if( (pR1 == nullptr) || (pR2 == nullptr) )
1546 throw lang::IllegalArgumentException();
1547
1548 const ESelection& r1 = pR1->maSelection;
1549 const ESelection& r2 = pR2->maSelection;
1550
1551 if( r1.nStartPara == r2.nStartPara )
1552 {
1553 if( r1.nStartPos == r2.nStartPos )
1554 return 0;
1555 else
1556 return r1.nStartPos < r2.nStartPos ? 1 : -1;
1557 }
1558 else
1559 {
1560 return r1.nStartPara < r2.nStartPara ? 1 : -1;
1561 }
1562}
1563
1564sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 )
1565{
1566 SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 );
1567 SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 );
1568
1569 if( (pR1 == nullptr) || (pR2 == nullptr) )
1570 throw lang::IllegalArgumentException();
1571
1572 const ESelection& r1 = pR1->maSelection;
1573 const ESelection& r2 = pR2->maSelection;
1574
1575 if( r1.nEndPara == r2.nEndPara )
1576 {
1577 if( r1.nEndPos == r2.nEndPos )
1578 return 0;
1579 else
1580 return r1.nEndPos < r2.nEndPos ? 1 : -1;
1581 }
1582 else
1583 {
1584 return r1.nEndPara < r2.nEndPara ? 1 : -1;
1585 }
1586}
1587
1588SvxUnoTextRange::SvxUnoTextRange(const SvxUnoTextBase& rParent, bool bPortion /* = false */)
1589:SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ),
1590 mbPortion( bPortion )
1591{
1592 xParentText = static_cast<text::XText*>(const_cast<SvxUnoTextBase *>(&rParent));
1593}
1594
1596{
1597}
1598
1600{
1601 QUERYINT( text::XTextRange );
1603 return uno::Any(uno::Reference< beans::XMultiPropertyStates >(this));
1604 else if( rType == cppu::UnoType<beans::XPropertySet>::get())
1605 return uno::Any(uno::Reference< beans::XPropertySet >(this));
1606 else QUERYINT( beans::XPropertyState );
1607 else QUERYINT( text::XTextRangeCompare );
1609 return uno::Any(uno::Reference< beans::XMultiPropertySet >(this));
1610 else QUERYINT( lang::XServiceInfo );
1611 else QUERYINT( lang::XTypeProvider );
1612 else QUERYINT( lang::XUnoTunnel );
1613 else
1614 return OWeakAggObject::queryAggregation( rType );
1615}
1616
1618{
1619 return OWeakAggObject::queryInterface(rType);
1620}
1621
1623 noexcept
1624{
1625 OWeakAggObject::acquire();
1626}
1627
1629 noexcept
1630{
1631 OWeakAggObject::release();
1632}
1633
1634// XTypeProvider
1635
1636uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes()
1637{
1638 static const uno::Sequence< uno::Type > TYPES {
1648 return TYPES;
1649}
1650
1651uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId()
1652{
1653 return css::uno::Sequence<sal_Int8>();
1654}
1655
1656// XTextRange
1657uno::Reference< text::XText > SAL_CALL SvxUnoTextRange::getText()
1658{
1659 return xParentText;
1660}
1661
1662// lang::XServiceInfo
1664{
1665 return "SvxUnoTextRange";
1666}
1667
1668
1669
1670
1672 : SvxUnoTextRangeBase(_pSet)
1673{
1674}
1675
1676SvxUnoTextBase::SvxUnoTextBase(const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > const & xParent)
1677 : SvxUnoTextRangeBase(pSource, _pSet)
1678{
1679 xParentText = xParent;
1680 ESelection aSelection;
1681 ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
1682 SetSelection( aSelection );
1683}
1684
1686: SvxUnoTextRangeBase( rText )
1687, text::XTextAppend()
1688, text::XTextCopy()
1689, container::XEnumerationAccess()
1690, text::XTextRangeMover()
1691, lang::XTypeProvider()
1692{
1693 xParentText = rText.xParentText;
1694}
1695
1697{
1698}
1699
1700// XInterface
1702{
1703 QUERYINT( text::XText );
1704 QUERYINT( text::XSimpleText );
1706 return uno::Any(uno::Reference< text::XTextRange >(static_cast<text::XText*>(this)));
1707 QUERYINT(container::XEnumerationAccess );
1708 QUERYINT( container::XElementAccess );
1709 QUERYINT( beans::XMultiPropertyStates );
1710 QUERYINT( beans::XPropertySet );
1711 QUERYINT( beans::XMultiPropertySet );
1712 QUERYINT( beans::XPropertyState );
1713 QUERYINT( text::XTextRangeCompare );
1714 QUERYINT( lang::XServiceInfo );
1715 QUERYINT( text::XTextRangeMover );
1716 QUERYINT( text::XTextCopy );
1717 QUERYINT( text::XTextAppend );
1718 QUERYINT( text::XParagraphAppend );
1719 QUERYINT( text::XTextPortionAppend );
1720 QUERYINT( lang::XTypeProvider );
1721 QUERYINT( lang::XUnoTunnel );
1722
1723 return uno::Any();
1724}
1725
1726// XTypeProvider
1727
1728uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes()
1729{
1730 static const uno::Sequence< uno::Type > TYPES {
1746 return TYPES;
1747}
1748
1749uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextBase::getImplementationId()
1750{
1751 return css::uno::Sequence<sal_Int8>();
1752}
1753
1754uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel )
1755{
1757 pCursor->SetSelection( rSel );
1758 return pCursor;
1759}
1760
1761// XSimpleText
1762
1763uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor()
1764{
1765 SolarMutexGuard aGuard;
1766 return new SvxUnoTextCursor( *this );
1767}
1768
1769uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition )
1770{
1771 SolarMutexGuard aGuard;
1772
1773 uno::Reference< text::XTextCursor > xCursor;
1774
1775 if( aTextPosition.is() )
1776 {
1777 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( aTextPosition );
1778 if(pRange)
1779 xCursor = createTextCursorBySelection( pRange->GetSelection() );
1780 }
1781
1782 return xCursor;
1783}
1784
1785void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb )
1786{
1787 SolarMutexGuard aGuard;
1788
1789 if( !xRange.is() )
1790 return;
1791
1792 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange );
1793 if(!pRange)
1794 return;
1795
1796 // setString on SvxUnoTextRangeBase instead of itself QuickInsertText
1797 // and UpdateData, so that the selection will be adjusted to
1798 // SvxUnoTextRangeBase. Actually all cursor objects of this Text must
1799 // to be statement to be adapted!
1800
1801 if (!bAbsorb) // do not replace -> append on tail
1802 pRange->CollapseToEnd();
1803
1804 pRange->setString( aString );
1805
1806 pRange->CollapseToEnd();
1807
1808 if (GetEditSource())
1809 {
1810 ESelection aSelection;
1811 ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
1812 SetSelection( aSelection );
1813 }
1814}
1815
1816void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb )
1817{
1818 SolarMutexGuard aGuard;
1819
1820 SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : nullptr;
1821
1822 if( !pForwarder )
1823 return;
1824
1825 ESelection aSelection;
1826 ::GetSelection( aSelection, pForwarder );
1827 SetSelection( aSelection );
1828
1829 switch( nControlCharacter )
1830 {
1831 case text::ControlCharacter::PARAGRAPH_BREAK:
1832 {
1833 insertString( xRange, "\x0D", bAbsorb );
1834
1835 return;
1836 }
1837 case text::ControlCharacter::LINE_BREAK:
1838 {
1839 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange );
1840 if(pRange)
1841 {
1842 ESelection aRange = pRange->GetSelection();
1843
1844 if( bAbsorb )
1845 {
1846 pForwarder->QuickInsertText( "", aRange );
1847
1848 aRange.nEndPos = aRange.nStartPos;
1849 aRange.nEndPara = aRange.nStartPara;
1850 }
1851 else
1852 {
1853 aRange.nStartPara = aRange.nEndPara;
1854 aRange.nStartPos = aRange.nEndPos;
1855 }
1856
1857 pForwarder->QuickInsertLineBreak( aRange );
1858 GetEditSource()->UpdateData();
1859
1860 aRange.nEndPos += 1;
1861 if( !bAbsorb )
1862 aRange.nStartPos += 1;
1863
1864 pRange->SetSelection( aRange );
1865 }
1866 return;
1867 }
1868 case text::ControlCharacter::APPEND_PARAGRAPH:
1869 {
1870 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange );
1871 if(pRange)
1872 {
1873 ESelection aRange = pRange->GetSelection();
1874// ESelection aOldSelection = aRange;
1875
1876 aRange.nStartPos = pForwarder->GetTextLen( aRange.nStartPara );
1877
1878 aRange.nEndPara = aRange.nStartPara;
1879 aRange.nEndPos = aRange.nStartPos;
1880
1881 pRange->SetSelection( aRange );
1882 static constexpr OUStringLiteral CR = u"\x0D";
1883 pRange->setString( CR );
1884
1885 aRange.nStartPos = 0;
1886 aRange.nStartPara += 1;
1887 aRange.nEndPos = 0;
1888 aRange.nEndPara += 1;
1889
1890 pRange->SetSelection( aRange );
1891
1892 return;
1893 }
1894 [[fallthrough]];
1895 }
1896 default:
1897 throw lang::IllegalArgumentException();
1898 }
1899}
1900
1901// XText
1902void SAL_CALL SvxUnoTextBase::insertTextContent( const uno::Reference< text::XTextRange >& xRange, const uno::Reference< text::XTextContent >& xContent, sal_Bool bAbsorb )
1903{
1904 SolarMutexGuard aGuard;
1905
1906 SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : nullptr;
1907 if (!pForwarder)
1908 return;
1909
1910 uno::Reference<beans::XPropertySet> xPropSet(xRange, uno::UNO_QUERY);
1911 if (!xPropSet.is())
1912 throw lang::IllegalArgumentException();
1913
1914 uno::Any aAny = xPropSet->getPropertyValue(UNO_TR_PROP_SELECTION);
1915 text::TextRangeSelection aSel = aAny.get<text::TextRangeSelection>();
1916 if (!bAbsorb)
1917 aSel.Start = aSel.End;
1918
1919 std::unique_ptr<SvxFieldData> pFieldData(SvxFieldData::Create(xContent));
1920 if (!pFieldData)
1921 throw lang::IllegalArgumentException();
1922
1923 SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD );
1924 pForwarder->QuickInsertField(aField, toESelection(aSel));
1925 GetEditSource()->UpdateData();
1926
1927 uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY);
1928 if (!xPropSetContent.is())
1929 throw lang::IllegalArgumentException();
1930
1931 xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::Any(xRange));
1932
1933 aSel.End.PositionInParagraph += 1;
1934 aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph;
1935 xPropSet->setPropertyValue(UNO_TR_PROP_SELECTION, uno::Any(aSel));
1936}
1937
1938void SAL_CALL SvxUnoTextBase::removeTextContent( const uno::Reference< text::XTextContent >& )
1939{
1940}
1941
1942// XTextRange
1943
1944uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText()
1945{
1946 SolarMutexGuard aGuard;
1947
1948 if (GetEditSource())
1949 {
1950 ESelection aSelection;
1951 ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
1952 SetSelection( aSelection );
1953 }
1954
1955 return static_cast<text::XText*>(this);
1956}
1957
1958uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getStart()
1959{
1960 return SvxUnoTextRangeBase::getStart();
1961}
1962
1963uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd()
1964{
1965 return SvxUnoTextRangeBase::getEnd();
1966}
1967
1968OUString SAL_CALL SvxUnoTextBase::getString()
1969{
1970 return SvxUnoTextRangeBase::getString();
1971}
1972
1973void SAL_CALL SvxUnoTextBase::setString( const OUString& aString )
1974{
1975 SvxUnoTextRangeBase::setString(aString);
1976}
1977
1978
1979// XEnumerationAccess
1980uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration()
1981{
1982 SolarMutexGuard aGuard;
1983
1984 if (!GetEditSource())
1985 return uno::Reference< container::XEnumeration >();
1986
1987 if( maSelection == ESelection(0,0,0,0) || maSelection == ESelection(EE_PARA_MAX_COUNT,0,0,0) )
1988 {
1989 ESelection aSelection;
1990 ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() );
1991 return new SvxUnoTextContentEnumeration(*this, aSelection);
1992 }
1993 else
1994 {
1995 return new SvxUnoTextContentEnumeration(*this, maSelection);
1996 }
1997}
1998
1999// XElementAccess ( container::XEnumerationAccess )
2001{
2003}
2004
2006{
2007 SolarMutexGuard aGuard;
2008
2009 if(GetEditSource())
2010 {
2011 SvxTextForwarder* pForwarder = GetEditSource()->GetTextForwarder();
2012 if(pForwarder)
2013 return pForwarder->GetParagraphCount() != 0;
2014 }
2015
2016 return false;
2017}
2018
2019// text::XTextRangeMover
2020void SAL_CALL SvxUnoTextBase::moveTextRange( const uno::Reference< text::XTextRange >&, sal_Int16 )
2021{
2022}
2023
2028 SfxItemSet &rItemSet,
2029 const uno::Sequence< beans::PropertyValue >& rPropertyValues,
2030 const SfxItemPropertySet *pPropSet,
2031 SvxTextForwarder *pForwarder,
2032 sal_Int32 nPara)
2033{
2034 for (const beans::PropertyValue& rProp : rPropertyValues)
2035 {
2036 const SfxItemPropertyMapEntry *pEntry = pPropSet->getPropertyMap().getByName( rProp.Name );
2037 if (!pEntry)
2038 throw beans::UnknownPropertyException( "Unknown property: " + rProp.Name );
2039 // Note: there is no need to take special care of the properties
2040 // TextField (EE_FEATURE_FIELD) and
2041 // TextPortionType (WID_PORTIONTYPE)
2042 // since they are read-only and thus are already taken care of below.
2043
2044 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
2045 // should be PropertyVetoException which is not yet defined for the new import API's functions
2046 throw uno::RuntimeException("Property is read-only: " + rProp.Name );
2047 //throw PropertyVetoException ("Property is read-only: " + rProp.Name );
2048
2049 if (pEntry->nWID == WID_FONTDESC)
2050 {
2051 awt::FontDescriptor aDesc;
2052 if (rProp.Value >>= aDesc)
2053 SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
2054 }
2055 else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE )
2056 {
2057 if( pForwarder )
2058 {
2059 sal_Int16 nStartValue = -1;
2060 if( !(rProp.Value >>= nStartValue) )
2061 throw lang::IllegalArgumentException();
2062
2063 pForwarder->SetNumberingStartValue( nPara, nStartValue );
2064 }
2065 }
2066 else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART )
2067 {
2068 if( pForwarder )
2069 {
2070 bool bParaIsNumberingRestart = false;
2071 if( !(rProp.Value >>= bParaIsNumberingRestart) )
2072 throw lang::IllegalArgumentException();
2073
2074 pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
2075 }
2076 }
2077 else
2078 pPropSet->setPropertyValue( rProp.Name, rProp.Value, rItemSet );
2079 }
2080}
2081
2082uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraphInsert(
2083 const uno::Sequence< beans::PropertyValue >& /*rCharAndParaProps*/,
2084 const uno::Reference< text::XTextRange >& /*rTextRange*/ )
2085{
2086 uno::Reference< text::XTextRange > xRet;
2087 return xRet;
2088}
2089
2090uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraph(
2091 const uno::Sequence< beans::PropertyValue >& rCharAndParaProps )
2092{
2093 SolarMutexGuard aGuard;
2094
2095 uno::Reference< text::XTextRange > xRet;
2096 SvxEditSource *pEditSource = GetEditSource();
2097 SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr;
2098 if (pTextForwarder)
2099 {
2100 sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
2101 DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
2102 pTextForwarder->AppendParagraph();
2103
2104 // set properties for the previously last paragraph
2105 sal_Int32 nPara = nParaCount - 1;
2106 ESelection aSel( nPara, 0, nPara, 0 );
2107 SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
2108 SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
2109 ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, nPara );
2110 pTextForwarder->QuickSetAttribs( aItemSet, aSel );
2111 pEditSource->UpdateData();
2113 xRet = pRange;
2114 pRange->SetSelection( aSel );
2115 }
2116 return xRet;
2117}
2118
2119uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::insertTextPortion(
2120 const OUString& rText,
2121 const uno::Sequence< beans::PropertyValue >& rCharAndParaProps,
2122 const uno::Reference< text::XTextRange>& rTextRange )
2123{
2124 SolarMutexGuard aGuard;
2125
2126 uno::Reference< text::XTextRange > xRet;
2127
2128 if (!rTextRange.is())
2129 return xRet;
2130
2131 SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>(rTextRange);
2132 if (!pRange)
2133 return xRet;
2134
2135 SvxEditSource *pEditSource = GetEditSource();
2136 SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr;
2137
2138 if (pTextForwarder)
2139 {
2140 pRange->setString(rText);
2141
2142 ESelection aSelection(pRange->GetSelection());
2143
2144 pTextForwarder->RemoveAttribs(aSelection);
2145 pEditSource->UpdateData();
2146
2147 SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
2148 SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
2149 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, aSelection.nStartPara );
2150 pTextForwarder->QuickSetAttribs( aItemSet, aSelection);
2151 rtl::Reference<SvxUnoTextRange> pNewRange = new SvxUnoTextRange( *this );
2152 xRet = pNewRange;
2153 pNewRange->SetSelection(aSelection);
2154 for( const beans::PropertyValue& rProp : rCharAndParaProps )
2155 pNewRange->setPropertyValue( rProp.Name, rProp.Value );
2156 }
2157 return xRet;
2158}
2159
2160// css::text::XTextPortionAppend (new import API)
2161uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion(
2162 const OUString& rText,
2163 const uno::Sequence< beans::PropertyValue >& rCharAndParaProps )
2164{
2165 SolarMutexGuard aGuard;
2166
2167 SvxEditSource *pEditSource = GetEditSource();
2168 SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr;
2169 uno::Reference< text::XTextRange > xRet;
2170 if (pTextForwarder)
2171 {
2172 sal_Int32 nParaCount = pTextForwarder->GetParagraphCount();
2173 DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" );
2174 sal_Int32 nPara = nParaCount - 1;
2175 SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) );
2176 sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet );
2177 pEditSource->UpdateData();
2178 sal_Int32 nEnd = pTextForwarder->GetTextLen( nPara );
2179
2180 // set properties for the new text portion
2181 ESelection aSel( nPara, nStart, nPara, nEnd );
2182 pTextForwarder->RemoveAttribs( aSel );
2183 pEditSource->UpdateData();
2184
2185 SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() );
2186 SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps,
2187 ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara );
2188 pTextForwarder->QuickSetAttribs( aItemSet, aSel );
2190 xRet = pRange;
2191 pRange->SetSelection( aSel );
2192 for( const beans::PropertyValue& rProp : rCharAndParaProps )
2193 pRange->setPropertyValue( rProp.Name, rProp.Value );
2194 }
2195 return xRet;
2196}
2197
2199 const uno::Reference< text::XTextCopy >& xSource )
2200{
2201 SolarMutexGuard aGuard;
2202 uno::Reference< lang::XUnoTunnel > xUT( xSource, uno::UNO_QUERY );
2203 SvxEditSource *pEditSource = GetEditSource();
2204 SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr;
2205 if( !pTextForwarder )
2206 return;
2207 if (auto pSource = comphelper::getFromUnoTunnel<SvxUnoTextBase>(xUT))
2208 {
2209 SvxEditSource *pSourceEditSource = pSource->GetEditSource();
2210 SvxTextForwarder *pSourceTextForwarder = pSourceEditSource ? pSourceEditSource->GetTextForwarder() : nullptr;
2211 if( pSourceTextForwarder )
2212 {
2213 pTextForwarder->CopyText( *pSourceTextForwarder );
2214 pEditSource->UpdateData();
2215 }
2216 }
2217 else
2218 {
2219 uno::Reference< text::XText > xSourceText( xSource, uno::UNO_QUERY );
2220 if( xSourceText.is() )
2221 {
2222 setString( xSourceText->getString() );
2223 }
2224 }
2225}
2226
2227// lang::XServiceInfo
2229{
2230 return "SvxUnoTextBase";
2231}
2232
2233uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames( )
2234{
2236}
2237
2238uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static( )
2239{
2241 SvxUnoTextRangeBase::getSupportedServiceNames_Static(),
2242 std::initializer_list<std::u16string_view>{ u"com.sun.star.text.Text" });
2243}
2244
2245const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() noexcept
2246{
2247 static const comphelper::UnoIdInit theSvxUnoTextBaseUnoTunnelId;
2248 return theSvxUnoTextBaseUnoTunnelId.getSeq();
2249}
2250
2251sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId )
2252{
2255}
2256
2258: SvxUnoTextBase( _pSet )
2259{
2260}
2261
2262SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > const & xParent ) noexcept
2263: SvxUnoTextBase( pSource, _pSet, xParent )
2264{
2265}
2266
2267SvxUnoText::SvxUnoText( const SvxUnoText& rText ) noexcept
2268: SvxUnoTextBase( rText )
2270{
2271}
2272
2274{
2275}
2276
2277// uno::XInterface
2279{
2281 if( !aAny.hasValue() )
2282 aAny = OWeakAggObject::queryAggregation( rType );
2283
2284 return aAny;
2285}
2286
2288{
2289 return OWeakAggObject::queryInterface( rType );
2290}
2291
2292void SAL_CALL SvxUnoText::acquire() noexcept
2293{
2294 OWeakAggObject::acquire();
2295}
2296
2297void SAL_CALL SvxUnoText::release() noexcept
2298{
2299 OWeakAggObject::release();
2300}
2301
2302// lang::XTypeProvider
2303uno::Sequence< uno::Type > SAL_CALL SvxUnoText::getTypes( )
2304{
2305 return SvxUnoTextBase::getTypes();
2306}
2307
2308uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId( )
2309{
2310 return css::uno::Sequence<sal_Int8>();
2311}
2312
2313const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() noexcept
2314{
2315 static const comphelper::UnoIdInit theSvxUnoTextUnoTunnelId;
2316 return theSvxUnoTextUnoTunnelId.getSeq();
2317}
2318
2319sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId )
2320{
2321 return comphelper::getSomethingImpl(rId, this,
2323}
2324
2325
2327{
2328};
2329
2330std::unique_ptr<SvxEditSource> SvxDummyTextSource::Clone() const
2331{
2332 return std::unique_ptr<SvxEditSource>(new SvxDummyTextSource);
2333}
2334
2336{
2337 return this;
2338}
2339
2341{
2342}
2343
2345{
2346 return 0;
2347}
2348
2349sal_Int32 SvxDummyTextSource::GetTextLen( sal_Int32 ) const
2350{
2351 return 0;
2352}
2353
2355{
2356 return OUString();
2357}
2358
2360{
2361 // Very dangerous: The former implementation used a SfxItemPool created on the
2362 // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using
2363 // a deleted Pool by design.
2365}
2366
2368{
2369 return GetAttribs(ESelection());
2370}
2371
2373{
2374}
2375
2377{
2378}
2379
2380void SvxDummyTextSource::GetPortions( sal_Int32, std::vector<sal_Int32>& ) const
2381{
2382}
2383
2384OUString SvxDummyTextSource::GetStyleSheet(sal_Int32) const
2385{
2386 return OUString();
2387}
2388
2389void SvxDummyTextSource::SetStyleSheet(sal_Int32, const OUString&)
2390{
2391}
2392
2394{
2395 return SfxItemState::UNKNOWN;
2396}
2397
2399{
2400 return SfxItemState::UNKNOWN;
2401}
2402
2404{
2405 return nullptr;
2406}
2407
2409{
2410}
2411
2413{
2414}
2415
2417{
2418}
2419
2421{
2422};
2423
2424OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, std::optional<Color>&, std::optional<Color>&, std::optional<FontLineStyle>& )
2425{
2426 return OUString();
2427}
2428
2430{
2431}
2432
2434{
2435 return false;
2436}
2437
2439{
2440 return LANGUAGE_DONTKNOW;
2441}
2442
2443sal_Int32 SvxDummyTextSource::GetFieldCount( sal_Int32 ) const
2444{
2445 return 0;
2446}
2447
2448EFieldInfo SvxDummyTextSource::GetFieldInfo( sal_Int32, sal_uInt16 ) const
2449{
2450 return EFieldInfo();
2451}
2452
2454{
2455 return EBulletInfo();
2456}
2457
2459{
2460 return tools::Rectangle();
2461}
2462
2464{
2465 return tools::Rectangle();
2466}
2467
2469{
2470 return MapMode();
2471}
2472
2474{
2475 return nullptr;
2476}
2477
2478bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_Int32&, sal_Int32& ) const
2479{
2480 return false;
2481}
2482
2483bool SvxDummyTextSource::GetWordIndices( sal_Int32, sal_Int32, sal_Int32&, sal_Int32& ) const
2484{
2485 return false;
2486}
2487
2488bool SvxDummyTextSource::GetAttributeRun( sal_Int32&, sal_Int32&, sal_Int32, sal_Int32, bool ) const
2489{
2490 return false;
2491}
2492
2493sal_Int32 SvxDummyTextSource::GetLineCount( sal_Int32 ) const
2494{
2495 return 0;
2496}
2497
2498sal_Int32 SvxDummyTextSource::GetLineLen( sal_Int32, sal_Int32 ) const
2499{
2500 return 0;
2501}
2502
2503void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 /*nParagraph*/, sal_Int32 /*nLine*/ ) const
2504{
2505 rStart = rEnd = 0;
2506}
2507
2508sal_Int32 SvxDummyTextSource::GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/ ) const
2509{
2510 return 0;
2511}
2512
2514{
2515 return false;
2516}
2517
2518sal_Int16 SvxDummyTextSource::GetDepth( sal_Int32 ) const
2519{
2520 return -1;
2521}
2522
2523bool SvxDummyTextSource::SetDepth( sal_Int32, sal_Int16 nNewDepth )
2524{
2525 return nNewDepth == 0;
2526}
2527
2529{
2530 return false;
2531}
2532
2533bool SvxDummyTextSource::InsertText( const OUString&, const ESelection& )
2534{
2535 return false;
2536}
2537
2539{
2540 return nullptr;
2541}
2542
2544{
2545}
2546
2547sal_Int32 SvxDummyTextSource::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & )
2548{
2549 return 0;
2550}
2551
2553{
2554}
2555
2556/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
static SfxItemPool & GetGlobalItemPool()
Definition: editeng.cxx:2653
bool GetValue() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
const SfxItemPropertyMap & getPropertyMap() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
SfxItemSet CloneAsValue(bool bItems=true, SfxItemPool *pToPool=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SvxColorItem item describes a color.
Definition: colritem.hxx:32
model::ComplexColor const & getComplexColor() const
Definition: colritem.hxx:75
virtual tools::Rectangle GetCharBounds(sal_Int32 nPara, sal_Int32 nIndex) const override
Query the bounding rectangle of the given character.
Definition: unotext.cxx:2458
virtual void UpdateData() override
Write back data to model.
Definition: unotext.cxx:2340
virtual EBulletInfo GetBulletInfo(sal_Int32 nPara) const override
Query information regarding bullets for given paragraph on the underlying edit engine.
Definition: unotext.cxx:2453
virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth) override
Set the outline depth of given paragraph.
Definition: unotext.cxx:2523
virtual bool GetWordIndices(sal_Int32 nPara, sal_Int32 nIndex, sal_Int32 &nStart, sal_Int32 &nEnd) const override
Get the start and the end index of the word at the given index.
Definition: unotext.cxx:2483
virtual OUString GetText(const ESelection &rSel) const override
Definition: unotext.cxx:2354
virtual sal_Int32 GetFieldCount(sal_Int32 nPara) const override
Query number of fields in the underlying edit engine.
Definition: unotext.cxx:2443
virtual sal_Int32 GetLineCount(sal_Int32 nPara) const override
Query number of lines in the formatted paragraph.
Definition: unotext.cxx:2493
virtual MapMode GetMapMode() const override
Query the map mode of the underlying EditEngine/Outliner.
Definition: unotext.cxx:2468
virtual sal_Int32 AppendTextPortion(sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet) override
Definition: unotext.cxx:2547
virtual sal_Int16 GetDepth(sal_Int32 nPara) const override
Get the outline depth of given paragraph.
Definition: unotext.cxx:2518
virtual OutputDevice * GetRefDevice() const override
Query the reference output device of the underlying EditEngine/Outliner.
Definition: unotext.cxx:2473
virtual void AppendParagraph() override
Definition: unotext.cxx:2543
virtual void GetPortions(sal_Int32 nPara, std::vector< sal_Int32 > &rList) const override
Definition: unotext.cxx:2380
virtual void QuickInsertLineBreak(const ESelection &rSel) override
Definition: unotext.cxx:2420
virtual bool Delete(const ESelection &) override
Delete given text range and reformat text.
Definition: unotext.cxx:2528
virtual const SfxItemSet * GetEmptyItemSetPtr() override
Definition: unotext.cxx:2538
virtual ~SvxDummyTextSource() override
Definition: unotext.cxx:2326
SfxItemState GetItemState(const ESelection &rSel, sal_uInt16 nWhich) const override
Definition: unotext.cxx:2393
virtual sal_Int32 GetLineNumberAtIndex(sal_Int32 nPara, sal_Int32 nIndex) const override
Query the line number for an index in the paragraphs text.
Definition: unotext.cxx:2508
virtual OUString GetStyleSheet(sal_Int32 nPara) const override
Definition: unotext.cxx:2384
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet) override
Definition: unotext.cxx:2372
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const override
Definition: unotext.cxx:2349
virtual tools::Rectangle GetParaBounds(sal_Int32 nPara) const override
Query the bounding rectangle of the given paragraph.
Definition: unotext.cxx:2463
virtual SfxItemSet GetAttribs(const ESelection &rSel, EditEngineAttribs nOnlyHardAttrib=EditEngineAttribs::All) const override
Definition: unotext.cxx:2359
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rpTxtColor, std::optional< Color > &rpFldColor, std::optional< FontLineStyle > &rpFldLineStyle) override
Definition: unotext.cxx:2424
virtual void FieldClicked(const SvxFieldItem &rField) override
Definition: unotext.cxx:2429
virtual bool IsValid() const override
Query state of forwarder.
Definition: unotext.cxx:2433
virtual bool InsertText(const OUString &, const ESelection &) override
Insert/Replace given text in given range and reformat text.
Definition: unotext.cxx:2533
virtual void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel) override
Definition: unotext.cxx:2416
virtual sal_Int32 GetParagraphCount() const override
Definition: unotext.cxx:2344
virtual void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel) override
Definition: unotext.cxx:2412
virtual bool GetIndexAtPoint(const Point &, sal_Int32 &nPara, sal_Int32 &nIndex) const override
Query paragraph and character index of the character at the given point.
Definition: unotext.cxx:2478
virtual void GetLineBoundaries(sal_Int32 &rStart, sal_Int32 &rEnd, sal_Int32 nParagraph, sal_Int32 nLine) const override
Query bounds of line in paragraph.
Definition: unotext.cxx:2503
virtual bool GetAttributeRun(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell=false) const override
Query range of similar attributes.
Definition: unotext.cxx:2488
virtual std::unique_ptr< SvxEditSource > Clone() const override
Returns a new reference to the same object. This is a shallow copy.
Definition: unotext.cxx:2330
virtual void QuickInsertText(const OUString &rText, const ESelection &rSel) override
Definition: unotext.cxx:2408
virtual bool QuickFormatDoc(bool bFull=false) override
Updates the formatting.
Definition: unotext.cxx:2513
virtual void RemoveAttribs(const ESelection &rSelection) override
Definition: unotext.cxx:2376
virtual void SetStyleSheet(sal_Int32 nPara, const OUString &rStyleName) override
Definition: unotext.cxx:2389
virtual sal_Int32 GetLineLen(sal_Int32 nPara, sal_Int32 nLine) const override
Query line length.
Definition: unotext.cxx:2498
virtual void CopyText(const SvxTextForwarder &rSource) override
Definition: unotext.cxx:2552
virtual LanguageType GetLanguage(sal_Int32, sal_Int32) const override
Query language of character at given position on the underlying edit engine.
Definition: unotext.cxx:2438
virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const override
Definition: unotext.cxx:2367
virtual SfxItemPool * GetPool() const override
Definition: unotext.cxx:2403
virtual SvxTextForwarder * GetTextForwarder() override
Query the text forwarder.
Definition: unotext.cxx:2335
virtual EFieldInfo GetFieldInfo(sal_Int32 nPara, sal_uInt16 nField) const override
Query information for given field number in the underlying edit engine.
Definition: unotext.cxx:2448
Wrapper class for unified EditEngine/Outliner access.
Definition: unoedsrc.hxx:56
virtual SvxTextForwarder * GetTextForwarder()=0
Query the text forwarder.
virtual void UpdateData()=0
Write back data to model.
virtual std::unique_ptr< SvxEditSource > Clone() const =0
Returns a new reference to the same object. This is a shallow copy.
static SvxFieldData * Create(const css::uno::Reference< css::text::XTextContent > &xContent)
Definition: flditem.cxx:41
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
const SvxFieldData * GetField() const
Definition: flditem.hxx:81
static void setPropertyValue(const SfxItemPropertyMapEntry *pMap, const css::uno::Any &rVal, SfxItemSet &rSet, bool bDontConvertNegativeValues)
static css::uno::Any getPropertyValue(const SfxItemPropertyMapEntry *pMap, const SfxItemSet &rSet, bool bSearchInParent, bool bDontConvertNegativeValues)
Definition: unoipset.cxx:56
const SvxNumRule & GetNumRule() const
Definition: numitem.hxx:325
Contains an EditEngine or an Outliner and unifies access to them.
Definition: unoedsrc.hxx:142
virtual void QuickInsertText(const OUString &rText, const ESelection &rSel)=0
virtual void SetNumberingStartValue(sal_Int32 nPara, sal_Int32 nNumberingStartValue)
Definition: unoforou.cxx:568
virtual void QuickInsertLineBreak(const ESelection &rSel)=0
virtual void SetStyleSheet(sal_Int32 nPara, const OUString &rStyleName)=0
virtual void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)=0
virtual bool SetDepth(sal_Int32 nPara, sal_Int16 nNewDepth)=0
Set the outline depth of given paragraph.
virtual const SfxItemSet * GetEmptyItemSetPtr()=0
virtual SfxItemSet GetAttribs(const ESelection &rSel, EditEngineAttribs nOnlyHardAttrib=EditEngineAttribs::All) const =0
virtual sal_Int32 GetNumberingStartValue(sal_Int32 nPara)
Definition: unoforou.cxx:563
virtual void CopyText(const SvxTextForwarder &rSource)=0
virtual void RemoveAttribs(const ESelection &rSelection)=0
virtual sal_Int16 GetDepth(sal_Int32 nPara) const =0
Get the outline depth of given paragraph.
virtual SfxItemSet GetParaAttribs(sal_Int32 nPara) const =0
virtual void AppendParagraph()=0
virtual SfxItemPool * GetPool() const =0
virtual OUString CalcFieldValue(const SvxFieldItem &rField, sal_Int32 nPara, sal_Int32 nPos, std::optional< Color > &rpTxtColor, std::optional< Color > &rpFldColor, std::optional< FontLineStyle > &rpFldLineStyle)=0
virtual sal_Int32 AppendTextPortion(sal_Int32 nPara, const OUString &rText, const SfxItemSet &rSet)=0
virtual sal_Int32 GetTextLen(sal_Int32 nParagraph) const =0
virtual OUString GetText(const ESelection &rSel) const =0
virtual void SetParaAttribs(sal_Int32 nPara, const SfxItemSet &rSet)=0
virtual sal_Int32 GetParagraphCount() const =0
virtual bool IsParaIsNumberingRestart(sal_Int32 nPara)
Definition: unoforou.cxx:572
virtual void SetParaIsNumberingRestart(sal_Int32 nPara, bool bParaIsNumberingRestart)
Definition: unoforou.cxx:577
virtual void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)=0
virtual SfxItemState GetItemState(const ESelection &rSel, sal_uInt16 nWhich) const =0
static css::uno::Any getPropertyDefault(SfxItemPool *pPool)
Definition: unofdesc.cxx:193
static void FillItemSet(const css::awt::FontDescriptor &rDesc, SfxItemSet &rSet)
Definition: unofdesc.cxx:78
static void setPropertyToDefault(SfxItemSet &rSet)
Definition: unofdesc.cxx:182
static void FillFromItemSet(const SfxItemSet &rSet, css::awt::FontDescriptor &rDesc)
Definition: unofdesc.cxx:133
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unotext.cxx:1944
virtual OUString SAL_CALL getImplementationName() override
Definition: unotext.cxx:2228
css::uno::Reference< css::text::XText > xParentText
Definition: unotext.hxx:430
virtual void SAL_CALL copyText(const css::uno::Reference< css::text::XTextCopy > &xSource) override
Definition: unotext.cxx:2198
virtual void SAL_CALL removeTextContent(const css::uno::Reference< css::text::XTextContent > &xContent) override
Definition: unotext.cxx:1938
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotext.cxx:2233
virtual ~SvxUnoTextBase() noexcept override
Definition: unotext.cxx:1696
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotext.cxx:1749
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotext.cxx:1980
SvxUnoTextBase(const SvxItemPropertySet *_pSet)
Definition: unotext.cxx:1671
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotext.cxx:2005
static css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames_Static()
Definition: unotext.cxx:2238
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotext.cxx:1763
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:1728
virtual void SAL_CALL insertString(const css::uno::Reference< css::text::XTextRange > &xRange, const OUString &aString, sal_Bool bAbsorb) override
Definition: unotext.cxx:1785
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL finishParagraphInsert(const css::uno::Sequence< css::beans::PropertyValue > &CharacterAndParagraphProperties, const css::uno::Reference< css::text::XTextRange > &xInsertPosition) override
Definition: unotext.cxx:2082
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotext.cxx:2000
virtual void SAL_CALL insertTextContent(const css::uno::Reference< css::text::XTextRange > &xRange, const css::uno::Reference< css::text::XTextContent > &xContent, sal_Bool bAbsorb) override
Definition: unotext.cxx:1902
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unotext.cxx:1973
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL appendTextPortion(const OUString &Text, const css::uno::Sequence< css::beans::PropertyValue > &CharacterAndParagraphProperties) override
Definition: unotext.cxx:2161
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType)
Definition: unotext.cxx:1701
virtual void SAL_CALL insertControlCharacter(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb) override
Definition: unotext.cxx:1816
virtual OUString SAL_CALL getString() override
Definition: unotext.cxx:1968
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: unotext.cxx:1769
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL insertTextPortion(const OUString &Text, const css::uno::Sequence< css::beans::PropertyValue > &CharacterAndParagraphProperties, const css::uno::Reference< css::text::XTextRange > &rTextRange) override
Definition: unotext.cxx:2119
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unotext.cxx:1963
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unotext.cxx:1958
css::uno::Reference< css::text::XTextCursor > createTextCursorBySelection(const ESelection &rSel)
Definition: unotext.cxx:1754
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL finishParagraph(const css::uno::Sequence< css::beans::PropertyValue > &CharacterAndParagraphProperties) override
Definition: unotext.cxx:2090
virtual void SAL_CALL moveTextRange(const css::uno::Reference< css::text::XTextRange > &xRange, sal_Int16 nParagraphs) override
Definition: unotext.cxx:2020
virtual ~SvxUnoTextRange() noexcept override
Definition: unotext.cxx:1595
virtual void SAL_CALL acquire() noexcept override
Definition: unotext.cxx:1622
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unotext.cxx:1657
virtual OUString SAL_CALL getImplementationName() override
Definition: unotext.cxx:1663
virtual void SAL_CALL release() noexcept override
Definition: unotext.cxx:1628
css::uno::Reference< css::text::XText > xParentText
Definition: unotext.hxx:399
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:1636
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotext.cxx:1651
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:1617
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
Definition: unotext.cxx:1599
SvxUnoTextRange(const SvxUnoTextBase &rParent, bool bPortion=false)
Definition: unotext.cxx:1588
virtual ~SvxUnoText() noexcept override
Definition: unotext.cxx:2273
virtual void SAL_CALL acquire() noexcept override
Definition: unotext.cxx:2292
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotext.cxx:2319
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:2287
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &rType) override
Definition: unotext.cxx:2278
virtual void SAL_CALL release() noexcept override
Definition: unotext.cxx:2297
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:2303
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept
Definition: unotext.cxx:2313
SvxUnoText(const SvxItemPropertySet *_pSet) noexcept
Definition: unotext.cxx:2257
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotext.cxx:2308
const css::uno::Sequence< sal_Int8 > & getSeq() const
css::uno::Type const & get()
ThemeColorType meSchemeType
std::vector< Transformation > const & getTransformations() const
int nCount
#define DBG_ASSERT(sCon, aError)
float u
#define EE_PARA_MAX_COUNT
Definition: editdata.hxx:51
constexpr TypedWhichId< SvxFieldItem > EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_BULLETSTATE(EE_PARA_START+9)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr sal_uInt16 EE_PARA_START(EE_ITEMS_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_PARA_XMLATTRIBS(EE_PARA_START+1)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SfxInt16Item > EE_PARA_OUTLLEVEL(EE_PARA_START+11)
constexpr sal_uInt16 EE_PARA_END(EE_PARA_START+19)
constexpr TypedWhichId< SvxCaseMapItem > EE_CHAR_CASEMAP(EE_CHAR_START+30)
constexpr TypedWhichId< SvXMLAttrContainerItem > EE_CHAR_XMLATTRIBS(EE_CHAR_START+28)
constexpr TypedWhichId< SvxNumBulletItem > EE_PARA_NUMBULLET(EE_PARA_START+5)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
EditEngineAttribs
values for: SfxItemSet GetAttribs( const ESelection& rSel, EditEngineAttribs nOnlyHardAttrib = EditEn...
@ OnlyHard
returns all attributes even when they are not set
#define LANGUAGE_DONTKNOW
TOOLS_DLLPUBLIC OString convertLineEnd(const OString &rIn, LineEnd eLineEnd)
#define MID_COLOR_LUM_MOD
Definition: memberids.h:196
#define MID_COMPLEX_COLOR
Definition: memberids.h:199
#define MID_COLOR_THEME_INDEX
Definition: memberids.h:194
#define MID_COLOR_LUM_OFF
Definition: memberids.h:197
std::unique_ptr< sal_Int32[]> pData
def text(shape, orig_st)
class SAL_NO_VTABLE XPropertySet
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
const char CR
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
SfxItemState
static SfxItemSet & rSet
sal_Int32 nStartPara
Definition: editdata.hxx:113
sal_Int32 nEndPos
Definition: editdata.hxx:116
sal_Int32 nStartPos
Definition: editdata.hxx:114
sal_Int32 nEndPara
Definition: editdata.hxx:115
bool hasValue()
unsigned char sal_Bool
constexpr OUStringLiteral UNO_TC_PROP_ANCHOR
Definition: unonames.hxx:16
constexpr OUStringLiteral UNO_TR_PROP_SELECTION
Definition: unonames.hxx:48
css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(const SvxNumRule &rRule)
Definition: unonrule.cxx:481
const sal_uInt16 aSvxUnoFontDescriptorWhichMap[]
Definition: unotext.cxx:965
o3tl::span< const SfxItemPropertyMapEntry > ImplGetSvxTextPortionPropertyMap()
Definition: unotext.cxx:82
const SvxItemPropertySet * ImplGetSvxTextPortionSvxPropertySet()
Definition: unotext.cxx:98
UNO3_GETIMPLEMENTATION_IMPL(SvxUnoTextRangeBase)
void CheckSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
Definition: unotext.cxx:148
static void SvxPropertyValuesToItemSet(SfxItemSet &rItemSet, const uno::Sequence< beans::PropertyValue > &rPropertyValues, const SfxItemPropertySet *pPropSet, SvxTextForwarder *pForwarder, sal_Int32 nPara)
Definition: unotext.cxx:2027
static const SfxItemPropertySet * ImplGetSvxTextPortionSfxPropertySet()
Definition: unotext.cxx:104
static const SfxItemPropertySet * ImplGetSvxUnoOutlinerTextCursorSfxPropertySet()
Definition: unotext.cxx:125
#define QUERYINT(xint)
Definition: unotext.cxx:72
o3tl::span< const SfxItemPropertyMapEntry > ImplGetSvxUnoOutlinerTextCursorPropertyMap()
Definition: unotext.cxx:110
const SvxItemPropertySet * ImplGetSvxUnoOutlinerTextCursorSvxPropertySet()
Definition: unotext.cxx:76
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
Definition: unotext.cxx:135
#define WID_FONTDESC
Definition: unotext.hxx:63
#define SVX_UNOEDIT_OUTLINER_PROPERTIES
Definition: unotext.hxx:73
#define SVX_UNOEDIT_CHAR_PROPERTIES
Definition: unotext.hxx:79
#define WID_PARAISNUMBERINGRESTART
Definition: unotext.hxx:66
#define WID_PORTIONTYPE
Definition: unotext.hxx:64
#define SVX_UNOEDIT_PARA_PROPERTIES
Definition: unotext.hxx:142
#define WID_NUMBERINGSTARTVALUE
Definition: unotext.hxx:65
#define WID_PARASTYLENAME
Definition: unotext.hxx:67
#define SVX_UNOEDIT_FONT_PROPERTIES
Definition: unotext.hxx:139