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