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