LibreOffice Module sw (master) 1
unoport.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 <unoport.hxx>
21
22#include <cmdid.h>
24#include <utility>
25#include <vcl/svapp.hxx>
26#include <svl/itemprop.hxx>
28
29#include <unocrsrhelper.hxx>
30#include <unoparaframeenum.hxx>
31#include <unotextrange.hxx>
32#include <unomap.hxx>
33#include <unoprnms.hxx>
34#include <unomid.h>
35#include <txtatr.hxx>
36#include <ndtxt.hxx>
37#include <doc.hxx>
38#include <frmfmt.hxx>
39
40#include <com/sun/star/beans/PropertyAttribute.hpp>
41#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
42#include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
43#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
44#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
45#include <com/sun/star/text/XFootnote.hpp>
46#include <com/sun/star/text/XTextField.hpp>
50
51using namespace ::com::sun::star;
52
53void SwXTextPortion::init(const SwUnoCursor* pPortionCursor)
54{
55 m_pUnoCursor = pPortionCursor->GetDoc().CreateUnoCursor(*pPortionCursor->GetPoint());
56 if (pPortionCursor->HasMark())
57 {
59 *m_pUnoCursor->GetMark() = *pPortionCursor->GetMark();
60 }
61}
62
64 const SwUnoCursor* pPortionCursor,
65 uno::Reference< text::XText > xParent,
67 : m_pPropSet(aSwMapProvider.GetPropertySet(
72 , m_xParentText(std::move(xParent))
73 , m_pFrameFormat(nullptr)
74 , m_ePortionType(eType != PORTION_LIST_AUTOFMT ? eType : PORTION_TEXT)
75 , m_bIsCollapsed(false)
76 , m_bIsListAutoFormat(false)
77{
78 if (eType == PORTION_LIST_AUTOFMT)
79 {
81 }
82 init( pPortionCursor);
83}
84
86 const SwUnoCursor* pPortionCursor,
87 uno::Reference< text::XText > xParent,
88 SwFrameFormat& rFormat )
89 : m_pPropSet(aSwMapProvider.GetPropertySet(
91 , m_xParentText(std::move(xParent))
92 , m_pFrameFormat(&rFormat)
93 , m_ePortionType(PORTION_FRAME)
94 , m_bIsCollapsed(false)
95 , m_bIsListAutoFormat(false)
96{
97 StartListening(rFormat.GetNotifier());
98 init( pPortionCursor);
99}
100
102 const SwUnoCursor* pPortionCursor,
103 SwTextRuby const& rAttr,
104 uno::Reference< text::XText > xParent,
105 bool bIsEnd )
106 : m_pPropSet(aSwMapProvider.GetPropertySet(
108 , m_xParentText(std::move(xParent))
109 , m_pFrameFormat(nullptr)
110 , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START )
111 , m_bIsCollapsed(false)
112 , m_bIsListAutoFormat(false)
113{
114 if (!bIsEnd)
115 {
116 m_oRubyText.emplace();
117 m_oRubyStyle.emplace();
118 m_oRubyAdjust.emplace();
119 m_oRubyIsAbove.emplace();
120 m_oRubyPosition.emplace();
121 }
122 init( pPortionCursor);
123
124 if (!bIsEnd)
125 {
126 const SfxPoolItem& rItem = rAttr.GetAttr();
127 rItem.QueryValue(*m_oRubyText);
132 }
133}
134
136{
137 SolarMutexGuard aGuard;
138 m_pUnoCursor.reset(nullptr);
140}
141
142uno::Reference< text::XText > SwXTextPortion::getText()
143{
144 return m_xParentText;
145}
147uno::Reference< text::XTextRange > SwXTextPortion::getStart()
148{
149 SolarMutexGuard aGuard;
150 uno::Reference< text::XTextRange > xRet;
151 SwUnoCursor& rUnoCursor = GetCursor();
152
153 SwPaM aPam(*rUnoCursor.Start());
154 uno::Reference< text::XText > xParent = getText();
155 xRet = new SwXTextRange(aPam, xParent);
156 return xRet;
157}
158
159uno::Reference< text::XTextRange > SwXTextPortion::getEnd()
160{
161 SolarMutexGuard aGuard;
162 uno::Reference< text::XTextRange > xRet;
163 SwUnoCursor& rUnoCursor = GetCursor();
164
165 SwPaM aPam(*rUnoCursor.End());
166 uno::Reference< text::XText > xParent = getText();
167 xRet = new SwXTextRange(aPam, xParent);
168 return xRet;
169}
170
172{
173 SolarMutexGuard aGuard;
174 OUString aText;
175 SwUnoCursor& rUnoCursor = GetCursor();
176
177 // TextPortions are always within a paragraph
178 SwTextNode* pTextNd = rUnoCursor.GetPointNode().GetTextNode();
179 if ( pTextNd )
180 {
181 const sal_Int32 nStt = rUnoCursor.Start()->GetContentIndex();
182 aText = pTextNd->GetExpandText(nullptr, nStt,
183 rUnoCursor.End()->GetContentIndex() - nStt,
184 false, false, false, ExpandMode::ExpandFootnote);
185 }
186 return aText;
187}
188
189void SwXTextPortion::setString(const OUString& aString)
190{
191 SolarMutexGuard aGuard;
192 SwUnoCursor& rUnoCursor = GetCursor();
193
194 SwUnoCursorHelper::SetString(rUnoCursor, aString);
195}
196
197uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo()
198{
199 SolarMutexGuard aGuard;
201 static uno::Reference< beans::XPropertySetInfo >
202 xTextPorExtRef = aSwMapProvider.GetPropertySet(
205 static uno::Reference< beans::XPropertySetInfo >
206 xRedlPorRef = aSwMapProvider.GetPropertySet(
208
210 PORTION_REDLINE_END == m_ePortionType) ? xRedlPorRef : xTextPorExtRef;
211}
212
213void SwXTextPortion::setPropertyValue(const OUString& rPropertyName,
214 const uno::Any& aValue)
215{
216 SolarMutexGuard aGuard;
217 SwUnoCursor& rUnoCursor = GetCursor();
218
220 rPropertyName, aValue);
221}
222
224 uno::Any &rVal,
225 const SfxItemPropertyMapEntry& rEntry,
226 SwUnoCursor *pUnoCursor,
227 std::unique_ptr<SfxItemSet> &pSet )
228{
229 static constexpr OUStringLiteral TEXT = u"Text";
230 static constexpr OUStringLiteral TEXTFIELD = u"TextField";
231 static constexpr OUStringLiteral FRAME = u"Frame";
232 static constexpr OUStringLiteral FOOTNOTE = u"Footnote";
233 static constexpr OUStringLiteral REDLINE = u"Redline";
234 static constexpr OUStringLiteral RUBY = u"Ruby";
235 static constexpr OUStringLiteral SOFTPAGEBREAK = u"SoftPageBreak";
236 static constexpr OUStringLiteral TEXTFIELDSTART = u"TextFieldStart";
237 static constexpr OUStringLiteral TEXTFIELDSEPARATOR = u"TextFieldSeparator";
238 static constexpr OUStringLiteral TEXTFIELDEND = u"TextFieldEnd";
239 static constexpr OUStringLiteral TEXTFIELDSTARTEND = u"TextFieldStartEnd";
240 static constexpr OUStringLiteral ANNOTATION = u"Annotation";
241 static constexpr OUStringLiteral ANNOTATIONEND = u"AnnotationEnd";
242 static constexpr OUStringLiteral LINEBREAK = u"LineBreak";
243
244 OSL_ENSURE( pUnoCursor, "UNO cursor missing" );
245 if (!pUnoCursor)
246 return;
247 switch(rEntry.nWID)
248 {
250 {
251 OUString sRet;
252 switch (m_ePortionType)
253 {
254 case PORTION_TEXT: sRet = TEXT; break;
255 case PORTION_FIELD: sRet = TEXTFIELD; break;
256 case PORTION_FRAME: sRet = FRAME; break;
257 case PORTION_FOOTNOTE: sRet = FOOTNOTE; break;
263 case PORTION_BOOKMARK_END : sRet = UNO_NAME_BOOKMARK; break;
265 case PORTION_REDLINE_END: sRet = REDLINE; break;
267 case PORTION_RUBY_END: sRet = RUBY; break;
268 case PORTION_SOFT_PAGEBREAK: sRet = SOFTPAGEBREAK; break;
269 case PORTION_META: sRet = UNO_NAME_META; break;
270 case PORTION_FIELD_START: sRet = TEXTFIELDSTART; break;
271 case PORTION_FIELD_SEP: sRet = TEXTFIELDSEPARATOR; break;
272 case PORTION_FIELD_END: sRet = TEXTFIELDEND; break;
273 case PORTION_FIELD_START_END:sRet = TEXTFIELDSTARTEND; break;
274 case PORTION_ANNOTATION: sRet = ANNOTATION; break;
275 case PORTION_ANNOTATION_END: sRet = ANNOTATIONEND; break;
276 case PORTION_LINEBREAK: sRet = LINEBREAK; break;
278 default: break;
279 }
280
281 rVal <<= sRet;
282 }
283 break;
284 case FN_UNO_CONTROL_CHARACTER: // obsolete!
285 break;
287 rVal <<= m_xTOXMark;
288 break;
290 rVal <<= m_xRefMark;
291 break;
292 case FN_UNO_BOOKMARK:
293 rVal <<= m_xBookmark;
294 break;
295 case FN_UNO_FOOTNOTE:
296 rVal <<= m_xFootnote;
297 break;
299 rVal <<= m_xTextField;
300 break;
301 case FN_UNO_META:
302 rVal <<= m_xMeta;
303 break;
304 case FN_UNO_LINEBREAK:
305 rVal <<= m_xLineBreak;
306 break;
308 rVal <<= m_xContentControl;
309 break;
311 {
312 switch (m_ePortionType)
313 {
323 case PORTION_RUBY_END:
327 rVal <<= m_bIsCollapsed;
328 break;
329 default:
330 break;
331 }
332 }
333 break;
334 case FN_UNO_IS_START:
335 {
336 bool bStart = true, bPut = true;
337 switch (m_ePortionType)
338 {
345 break;
346
351 case PORTION_RUBY_END:
354 bStart = false;
355 break;
356 default:
357 bPut = false;
358 }
359 if(bPut)
360 rVal <<= bStart;
361 }
362 break;
364 {
365 const std::optional<uno::Any>* pToSet = nullptr;
366 switch(rEntry.nMemberId)
367 {
368 case MID_RUBY_TEXT : pToSet = &m_oRubyText; break;
369 case MID_RUBY_ADJUST : pToSet = &m_oRubyAdjust; break;
370 case MID_RUBY_CHARSTYLE:pToSet = &m_oRubyStyle; break;
371 case MID_RUBY_ABOVE : pToSet = &m_oRubyIsAbove;break;
372 case MID_RUBY_POSITION: pToSet = &m_oRubyPosition;break;
373 }
374 if(pToSet && *pToSet)
375 rVal = **pToSet;
376 }
377 break;
378 default:
379 beans::PropertyState eTemp;
380 bool bDone = false;
382 {
383 SwTextNode* pTextNode = pUnoCursor->GetPointNode().GetTextNode();
384 std::shared_ptr<SfxItemSet> pListSet
385 = pTextNode->GetAttr(RES_PARATR_LIST_AUTOFMT).GetStyleHandle();
386 if (pListSet)
387 {
388 m_pPropSet->getPropertyValue(rEntry, *pListSet, rVal);
389 bDone = true;
390 }
391 }
392 if (!bDone)
393 {
395 rEntry, *pUnoCursor, &rVal, eTemp );
396 }
397 if(!bDone)
398 {
399 if(!pSet)
400 {
401 pSet = std::make_unique<SfxItemSetFixed<
405 SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet);
406 }
407 m_pPropSet->getPropertyValue(rEntry, *pSet, rVal);
408 }
409 }
410}
411
413 const uno::Sequence< OUString >& rPropertyNames )
414{
415 sal_Int32 nLength = rPropertyNames.getLength();
416 const OUString *pPropertyNames = rPropertyNames.getConstArray();
417 uno::Sequence< uno::Any > aValues(nLength);
418 uno::Any *pValues = aValues.getArray();
419 SwUnoCursor& rUnoCursor = GetCursor();
420
421 {
422 std::unique_ptr<SfxItemSet> pSet;
423 // get starting point for the look-up, either the provided one or else
424 // from the beginning of the map
426 for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
427 {
428 const SfxItemPropertyMapEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
429 if(!pEntry)
430 throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
431 GetPropertyValue( pValues[nProp], *pEntry, &rUnoCursor, pSet );
432 }
433 }
434 return aValues;
435}
436
438 const OUString& rPropertyName)
439{
440 SolarMutexGuard aGuard;
441 uno::Sequence< OUString > aPropertyNames { rPropertyName };
442 return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
443}
444
446 const uno::Sequence< OUString >& rPropertyNames,
447 const uno::Sequence< uno::Any >& rValues )
448{
449 if (rPropertyNames.getLength() != rValues.getLength())
450 throw lang::IllegalArgumentException("lengths do not match",
451 static_cast<cppu::OWeakObject*>(this), -1);
452
453 SwUnoCursor& rUnoCursor = GetCursor();
454
455 {
456 const OUString* pPropertyNames = rPropertyNames.getConstArray();
457 const uno::Any* pValues = rValues.getConstArray();
459 uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
460 auto aValuesRange = asNonConstRange(aValues);
461 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
462 {
463 const SfxItemPropertyMapEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
464 if (!pEntry)
465 throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
466 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
467 throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
468
469 aValuesRange[nProp].Name = pPropertyNames[nProp];
470 aValuesRange[nProp].Value = pValues[nProp];
471 }
472 SwUnoCursorHelper::SetPropertyValues( rUnoCursor, *m_pPropSet, aValues );
473 }
474}
475
477 const uno::Sequence< OUString >& rPropertyNames,
478 const uno::Sequence< uno::Any >& rValues )
479{
480 SolarMutexGuard aGuard;
481
482 // workaround for bad designed API
483 try
484 {
485 SetPropertyValues_Impl( rPropertyNames, rValues );
486 }
487 catch (const beans::UnknownPropertyException &rException)
488 {
489 // wrap the original (here not allowed) exception in
490 // a lang::WrappedTargetException that gets thrown instead.
491 lang::WrappedTargetException aWExc;
492 aWExc.TargetException <<= rException;
493 throw aWExc;
494 }
495}
496
497uno::Sequence< uno::Any > SwXTextPortion::getPropertyValues(
498 const uno::Sequence< OUString >& rPropertyNames )
499{
500 SolarMutexGuard aGuard;
501 uno::Sequence< uno::Any > aValues;
502
503 // workaround for bad designed API
504 try
505 {
506 aValues = GetPropertyValues_Impl( rPropertyNames );
507 }
508 catch (beans::UnknownPropertyException &)
509 {
510 css::uno::Any anyEx = cppu::getCaughtException();
511 throw lang::WrappedTargetRuntimeException("Unknown property exception caught",
512 static_cast < cppu::OWeakObject * > ( this ), anyEx );
513 }
514 catch (lang::WrappedTargetException &)
515 {
516 css::uno::Any anyEx = cppu::getCaughtException();
517 throw lang::WrappedTargetRuntimeException("WrappedTargetException caught",
518 static_cast < cppu::OWeakObject * > ( this ), anyEx );
519 }
520
521 return aValues;
522}
523
524/* disabled for #i46921# */
525uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPropertyValuesTolerant(
526 const uno::Sequence< OUString >& rPropertyNames,
527 const uno::Sequence< uno::Any >& rValues )
528{
529 SolarMutexGuard aGuard;
530
531 if (rPropertyNames.getLength() != rValues.getLength())
532 throw lang::IllegalArgumentException();
533 SwUnoCursor& rUnoCursor = GetCursor();
534
535 sal_Int32 nProps = rPropertyNames.getLength();
536 const OUString *pProp = rPropertyNames.getConstArray();
537
538 //sal_Int32 nVals = rValues.getLength();
539 const uno::Any *pValue = rValues.getConstArray();
540
541 sal_Int32 nFailed = 0;
542 uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
543 beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
544
545 const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
546
547 for (sal_Int32 i = 0; i < nProps; ++i)
548 {
549 try
550 {
551 pFailed[ nFailed ].Name = pProp[i];
552
553 const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( pProp[i] );
554 if (!pEntry)
555 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
556 else
557 {
558 // set property value
559 // (compare to SwXTextPortion::setPropertyValues)
560 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
561 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
562 else
563 {
565 rUnoCursor, *m_pPropSet, pProp[i], pValue[i] );
566 }
567 }
568 }
569 catch (beans::UnknownPropertyException &)
570 {
571 // should not occur because property was searched for before
572 TOOLS_WARN_EXCEPTION( "sw", "" );
573 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
574 }
575 catch (lang::IllegalArgumentException &)
576 {
577 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
578 }
579 catch (beans::PropertyVetoException &)
580 {
581 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
582 }
583 catch (lang::WrappedTargetException &)
584 {
585 pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
586 }
587 }
588
589 aFailed.realloc( nFailed );
590 return aFailed;
591}
592
593uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXTextPortion::getPropertyValuesTolerant(
594 const uno::Sequence< OUString >& rPropertyNames )
595{
596 SolarMutexGuard aGuard;
597
598 const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
599 GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
600
601 // copy temporary result to final result type
602 sal_Int32 nLen = aTmpRes.getLength();
603 uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
604 std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray());
605 return aRes;
606}
607
608uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion::getDirectPropertyValuesTolerant(
609 const uno::Sequence< OUString >& rPropertyNames )
610{
611 SolarMutexGuard aGuard;
612 return GetPropertyValuesTolerant_Impl( rPropertyNames, true );
613}
614
615uno::Sequence< beans::GetDirectPropertyTolerantResult > SwXTextPortion::GetPropertyValuesTolerant_Impl(
616 const uno::Sequence< OUString >& rPropertyNames,
617 bool bDirectValuesOnly )
618{
619 SolarMutexGuard aGuard;
620
621 SwUnoCursor& rUnoCursor = GetCursor();
622
623 std::vector< beans::GetDirectPropertyTolerantResult > aResultVector;
624
625 try
626 {
627 sal_Int32 nProps = rPropertyNames.getLength();
628 const OUString *pProp = rPropertyNames.getConstArray();
629
630 std::unique_ptr<SfxItemSet> pSet;
631
632 const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
633
634
635 uno::Sequence< beans::PropertyState > aPropertyStates;
637 {
638 SwTextNode* pTextNode = rUnoCursor.GetPointNode().GetTextNode();
639 std::shared_ptr<SfxItemSet> pListSet
640 = pTextNode->GetAttr(RES_PARATR_LIST_AUTOFMT).GetStyleHandle();
641 if (pListSet)
642 {
643 std::vector<beans::PropertyState> aStates;
644 for (const auto& rPropertyName : rPropertyNames)
645 {
646 aStates.push_back(m_pPropSet->getPropertyState(rPropertyName, *pListSet));
647 }
648 aPropertyStates = comphelper::containerToSequence(aStates);
649 }
650 }
651 if (!aPropertyStates.hasElements())
652 {
653 aPropertyStates =
655 rUnoCursor, *m_pPropSet,
656 rPropertyNames,
658 }
659 const beans::PropertyState* pPropertyStates = aPropertyStates.getConstArray();
660
661 for (sal_Int32 i = 0; i < nProps; ++i)
662 {
663 beans::GetDirectPropertyTolerantResult aResult;
664 try
665 {
666 aResult.Name = pProp[i];
667 if(pPropertyStates[i] == beans::PropertyState::PropertyState_MAKE_FIXED_SIZE) // property unknown?
668 {
669 if( bDirectValuesOnly )
670 continue;
671 else
672 aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
673 }
674 else
675 {
676 const SfxItemPropertyMapEntry* pEntry = rPropMap.getByName( pProp[i] );
677 if (!pEntry)
678 throw beans::UnknownPropertyException( "Unknown property: " + pProp[i], static_cast < cppu::OWeakObject * > ( this ) );
679 aResult.State = pPropertyStates[i];
680
681 aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
682 //#i104499# ruby portion attributes need special handling:
683 if( pEntry->nWID == RES_TXTATR_CJK_RUBY &&
685 {
686 aResult.State = beans::PropertyState_DIRECT_VALUE;
687 }
688 if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State)
689 {
690 // get property value
691 // (compare to SwXTextPortion::getPropertyValue(s))
692 GetPropertyValue( aResult.Value, *pEntry, &rUnoCursor, pSet );
693 aResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
694 aResultVector.push_back( aResult );
695 }
696 }
697 }
698 catch (const beans::UnknownPropertyException &)
699 {
700 // should not occur because property was searched for before
701 TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
702 aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
703 }
704 catch (const lang::IllegalArgumentException &)
705 {
706 aResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
707 }
708 catch (const beans::PropertyVetoException &)
709 {
710 aResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
711 }
712 catch (const lang::WrappedTargetException &)
713 {
714 aResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
715 }
716 }
717 }
718 catch (const uno::RuntimeException&)
719 {
720 throw;
721 }
722 catch (const uno::Exception& e)
723 {
724 css::uno::Any a(cppu::getCaughtException());
725 throw css::lang::WrappedTargetRuntimeException(
726 "wrapped Exception " + e.Message,
727 css::uno::Reference<css::uno::XInterface>(), a);
728 }
729
730 return comphelper::containerToSequence(aResultVector);
731}
732
734 const uno::Sequence< OUString >& /*aPropertyNames*/,
735 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
736{}
737
739 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
740{}
741
743 const uno::Sequence< OUString >& /*aPropertyNames*/,
744 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
745{}
746
748 const OUString& /*PropertyName*/,
749 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
750{
751 OSL_FAIL("not implemented");
752}
753
754void SwXTextPortion::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
755{
756 OSL_FAIL("not implemented");
757}
758
759void SwXTextPortion::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
760{
761 OSL_FAIL("not implemented");
762}
763
764void SwXTextPortion::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
765{
766 OSL_FAIL("not implemented");
767}
768
769beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyName)
770{
771 SolarMutexGuard aGuard;
772 beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
773 SwUnoCursor& rUnoCursor = GetCursor();
774
776 rPropertyName.startsWith("Ruby"))
777 {
778 eRet = beans::PropertyState_DIRECT_VALUE;
779 }
780 else
781 {
783 rPropertyName);
784 }
785 return eRet;
786}
787
788uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates(
789 const uno::Sequence< OUString >& rPropertyNames)
790{
791 SolarMutexGuard aGuard;
792 SwUnoCursor& rUnoCursor = GetCursor();
793
794 uno::Sequence< beans::PropertyState > aRet =
797
799 {
800 const OUString* pNames = rPropertyNames.getConstArray();
801 beans::PropertyState* pStates = aRet.getArray();
802 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength();nProp++)
803 {
804 if (pNames[nProp].startsWith("Ruby"))
805 pStates[nProp] = beans::PropertyState_DIRECT_VALUE;
806 }
807 }
808 return aRet;
809}
810
811void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
812{
813 SolarMutexGuard aGuard;
814 SwUnoCursor& rUnoCursor = GetCursor();
815
817 rUnoCursor, *m_pPropSet, rPropertyName);
818}
819
820uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName)
821{
822 SolarMutexGuard aGuard;
823 uno::Any aRet;
824 SwUnoCursor& rUnoCursor = GetCursor();
825
827 rPropertyName);
828 return aRet;
829}
830
831uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumeration(const OUString& /*aServiceName*/)
832{
833 SolarMutexGuard aGuard;
834 SwUnoCursor& rUnoCursor = GetCursor();
835
837}
838
840{
841 return { "com.sun.star.text.TextContent" };
842}
843
845{
846 return { "SwXTextPortion" };
847}
848
849sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName)
850{
851 return cppu::supportsService(this, rServiceName);
852}
853
855{
856 return { "com.sun.star.text.TextPortion",
857 "com.sun.star.style.CharacterProperties",
858 "com.sun.star.style.CharacterPropertiesAsian",
859 "com.sun.star.style.CharacterPropertiesComplex",
860 "com.sun.star.style.ParagraphProperties",
861 "com.sun.star.style.ParagraphPropertiesAsian",
862 "com.sun.star.style.ParagraphPropertiesComplex" };
863}
864
866{
867 if(rHint.GetId() == SfxHintId::Dying)
868 m_pFrameFormat = nullptr;
869}
870
871/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
SfxHintId GetId() const
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
css::beans::PropertyState getPropertyState(const OUString &rName, const 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
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
void EndListeningAll()
bool StartListening(SvtBroadcaster &rBroadcaster)
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1810
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1337
Style of a layout element.
Definition: frmfmt.hxx:72
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:901
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
const SwPosition * GetMark() const
Definition: pam.hxx:255
SwNode & GetPointNode() const
Definition: pam.hxx:275
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:643
const SwPosition * End() const
Definition: pam.hxx:263
SwDoc & GetDoc() const
Definition: pam.hxx:291
const SwPosition * GetPoint() const
Definition: pam.hxx:253
const SwPosition * Start() const
Definition: pam.hxx:258
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:251
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:167
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
Definition: ndtxt.cxx:3505
const SfxPoolItem & GetAttr(sal_uInt16 nWhich, bool bInParent=true) const
End: Data collected during idle time.
Definition: node.hxx:732
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1111
const SwTextPortionType m_ePortionType
Definition: unoport.hxx:121
virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:593
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:497
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoport.cxx:437
SwUnoCursor & GetCursor() const
Definition: unoport.hxx:242
SwTextPortionType GetTextPortionType() const
Definition: unoport.hxx:240
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unoport.cxx:788
css::uno::Reference< css::text::XTextContent > m_xRefMark
Definition: unoport.hxx:100
void init(const SwUnoCursor *pPortionCursor)
Definition: unoport.cxx:53
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoport.cxx:849
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoport.cxx:159
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:738
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unoport.cxx:754
SwFrameFormat * m_pFrameFormat
Definition: unoport.hxx:120
std::optional< css::uno::Any > m_oRubyPosition
Definition: unoport.hxx:117
css::uno::Reference< css::text::XTextContent > m_xBookmark
Definition: unoport.hxx:104
css::uno::Reference< css::text::XTextContent > m_xMeta
Definition: unoport.hxx:110
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoport.cxx:839
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:764
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:733
virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoport.cxx:525
css::uno::Reference< css::text::XTextContent > m_xTOXMark
Definition: unoport.hxx:102
bool m_bIsListAutoFormat
Expose the paragraph's RES_PARATR_LIST_AUTOFMT, not the char props of the underlying (empty) text.
Definition: unoport.hxx:127
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoport.cxx:854
SwXTextPortion(const SwUnoCursor *pPortionCursor, css::uno::Reference< css::text::XText > xParent, SwTextPortionType eType)
virtual OUString SAL_CALL getImplementationName() override
Definition: unoport.cxx:844
void GetPropertyValue(css::uno::Any &rVal, const SfxItemPropertyMapEntry &rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr< SfxItemSet > &pSet)
Definition: unoport.cxx:223
const css::uno::Reference< css::text::XText > m_xParentText
Definition: unoport.hxx:98
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:742
css::uno::Reference< css::text::XTextContent > m_xLineBreak
Definition: unoport.hxx:111
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: unoport.cxx:476
virtual OUString SAL_CALL getString() override
Definition: unoport.cxx:171
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unoport.cxx:820
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unoport.cxx:811
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoport.cxx:197
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoport.cxx:147
std::optional< css::uno::Any > m_oRubyAdjust
Definition: unoport.hxx:115
std::optional< css::uno::Any > m_oRubyIsAbove
Definition: unoport.hxx:116
css::uno::Reference< css::text::XFootnote > m_xFootnote
Definition: unoport.hxx:106
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoport.cxx:747
std::optional< css::uno::Any > m_oRubyStyle
Definition: unoport.hxx:114
css::uno::Reference< css::text::XTextField > m_xTextField
Definition: unoport.hxx:108
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoport.cxx:189
const SfxItemPropertySet * m_pPropSet
Definition: unoport.hxx:96
void SetPropertyValues_Impl(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues)
Definition: unoport.cxx:445
css::uno::Sequence< css::uno::Any > GetPropertyValues_Impl(const css::uno::Sequence< OUString > &aPropertyNames)
Definition: unoport.cxx:412
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unoport.cxx:213
css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl(const css::uno::Sequence< OUString > &rPropertyNames, bool bDirectValuesOnly)
Definition: unoport.cxx:615
bool m_bIsCollapsed
Definition: unoport.hxx:123
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:759
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:608
virtual void Notify(const SfxHint &rHint) override
Definition: unoport.cxx:865
virtual ~SwXTextPortion() override
Definition: unoport.cxx:135
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unoport.cxx:769
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoport.cxx:142
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &aServiceName) override
Definition: unoport.cxx:831
std::optional< css::uno::Any > m_oRubyText
Definition: unoport.hxx:113
css::uno::Reference< css::text::XTextContent > m_xContentControl
Definition: unoport.hxx:112
sw::UnoCursorPointer m_pUnoCursor
Definition: unoport.hxx:118
void reset(std::shared_ptr< SwUnoCursor > pNew)
Definition: unocrsr.hxx:158
#define FN_UNO_TEXT_PORTION_TYPE
Definition: cmdid.h:606
#define FN_UNO_IS_START
Definition: cmdid.h:610
#define FN_UNO_CONTROL_CHARACTER
Definition: cmdid.h:607
#define FN_UNO_CONTENT_CONTROL
Definition: cmdid.h:672
#define FN_UNO_BOOKMARK
Definition: cmdid.h:608
#define FN_UNO_REFERENCE_MARK
Definition: cmdid.h:563
#define FN_UNO_IS_COLLAPSED
Definition: cmdid.h:609
#define FN_UNO_DOCUMENT_INDEX_MARK
Definition: cmdid.h:557
#define FN_UNO_META
Definition: cmdid.h:645
#define FN_UNO_TEXT_FIELD
Definition: cmdid.h:559
#define FN_UNO_LINEBREAK
Definition: cmdid.h:671
#define FN_UNO_FOOTNOTE
Definition: cmdid.h:565
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
DocumentType eType
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr sal_uInt16 RES_CHRATR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SwFormatAutoFormat > RES_PARATR_LIST_AUTOFMT(87)
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
uno_Any a
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)
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2114
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:292
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2147
void SetString(SwCursor &rCursor, std::u16string_view aString)
Definition: unoobj2.cxx:1647
bool getCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
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)
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2186
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Any SAL_CALL getCaughtException()
int i
FRAME
FOOTNOTE
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
static rtl::Reference< SwXParaFrameEnumeration > Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1716
TEXT
unsigned char sal_Bool
@ SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION_TOLERANT
@ SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:88
#define PROPERTY_MAP_TEXTPORTION_EXTENSIONS
Definition: unomap.hxx:60
#define PROPERTY_MAP_REDLINE_PORTION
Definition: unomap.hxx:114
#define MID_RUBY_POSITION
Definition: unomid.h:117
#define MID_RUBY_ABOVE
Definition: unomid.h:116
#define MID_RUBY_TEXT
Definition: unomid.h:113
#define MID_RUBY_ADJUST
Definition: unomid.h:114
#define MID_RUBY_CHARSTYLE
Definition: unomid.h:115
@ PARAFRAME_PORTION_CHAR
SwTextPortionType
Definition: unoport.hxx:54
@ PORTION_TOXMARK_END
Definition: unoport.hxx:62
@ PORTION_TEXT
Definition: unoport.hxx:55
@ PORTION_RUBY_START
Definition: unoport.hxx:67
@ PORTION_FIELD_SEP
Definition: unoport.hxx:72
@ PORTION_ANNOTATION
Definition: unoport.hxx:75
@ PORTION_BOOKMARK_START
Definition: unoport.hxx:63
@ PORTION_CONTENT_CONTROL
Definition: unoport.hxx:78
@ PORTION_FIELD_END
Definition: unoport.hxx:73
@ PORTION_META
Definition: unoport.hxx:70
@ PORTION_REDLINE_END
Definition: unoport.hxx:66
@ PORTION_REFMARK_START
Definition: unoport.hxx:59
@ PORTION_REDLINE_START
Definition: unoport.hxx:65
@ PORTION_BOOKMARK_END
Definition: unoport.hxx:64
@ PORTION_LIST_AUTOFMT
Definition: unoport.hxx:79
@ PORTION_RUBY_END
Definition: unoport.hxx:68
@ PORTION_FIELD
Definition: unoport.hxx:56
@ PORTION_TOXMARK_START
Definition: unoport.hxx:61
@ PORTION_SOFT_PAGEBREAK
Definition: unoport.hxx:69
@ PORTION_FIELD_START_END
Definition: unoport.hxx:74
@ PORTION_ANNOTATION_END
Definition: unoport.hxx:76
@ PORTION_FRAME
Definition: unoport.hxx:57
@ PORTION_LINEBREAK
Definition: unoport.hxx:77
@ PORTION_FOOTNOTE
Definition: unoport.hxx:58
@ PORTION_REFMARK_END
Definition: unoport.hxx:60
@ PORTION_FIELD_START
Definition: unoport.hxx:71
constexpr OUStringLiteral UNO_NAME_REFERENCE_MARK
Definition: unoprnms.hxx:370
constexpr OUStringLiteral UNO_NAME_META
Definition: unoprnms.hxx:850
constexpr OUStringLiteral UNO_NAME_DOCUMENT_INDEX_MARK
Definition: unoprnms.hxx:360
constexpr OUStringLiteral UNO_NAME_CONTENT_CONTROL
Definition: unoprnms.hxx:917
constexpr OUStringLiteral UNO_NAME_BOOKMARK
Definition: unoprnms.hxx:364
sal_Int32 nLength