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