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 SfxItemPropertySimpleEntry& 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  default:
254  pRet = nullptr;
255  }
256 
257  OUString sRet;
258  if( pRet )
259  sRet = OUString::createFromAscii( pRet );
260  rVal <<= sRet;
261  }
262  break;
263  case FN_UNO_CONTROL_CHARACTER: // obsolete!
264  break;
266  rVal <<= m_xTOXMark;
267  break;
269  rVal <<= m_xRefMark;
270  break;
271  case FN_UNO_BOOKMARK:
272  rVal <<= m_xBookmark;
273  break;
274  case FN_UNO_FOOTNOTE:
275  rVal <<= m_xFootnote;
276  break;
277  case FN_UNO_TEXT_FIELD:
278  rVal <<= m_xTextField;
279  break;
280  case FN_UNO_META:
281  rVal <<= m_xMeta;
282  break;
283  case FN_UNO_IS_COLLAPSED:
284  {
285  switch (m_ePortionType)
286  {
290  case PORTION_REFMARK_END:
291  case PORTION_TOXMARK_END:
292  case PORTION_BOOKMARK_END :
293  case PORTION_REDLINE_START :
294  case PORTION_REDLINE_END :
295  case PORTION_RUBY_START:
296  case PORTION_RUBY_END:
297  case PORTION_FIELD_START:
298  case PORTION_FIELD_SEP:
299  case PORTION_FIELD_END:
300  rVal <<= m_bIsCollapsed;
301  break;
302  default:
303  break;
304  }
305  }
306  break;
307  case FN_UNO_IS_START:
308  {
309  bool bStart = true, bPut = true;
310  switch (m_ePortionType)
311  {
316  case PORTION_RUBY_START:
317  case PORTION_FIELD_START:
318  break;
319 
320  case PORTION_REFMARK_END:
321  case PORTION_TOXMARK_END:
323  case PORTION_REDLINE_END:
324  case PORTION_RUBY_END:
325  case PORTION_FIELD_SEP:
326  case PORTION_FIELD_END:
327  bStart = false;
328  break;
329  default:
330  bPut = false;
331  }
332  if(bPut)
333  rVal <<= bStart;
334  }
335  break;
336  case RES_TXTATR_CJK_RUBY:
337  {
338  const uno::Any* pToSet = nullptr;
339  switch(rEntry.nMemberId)
340  {
341  case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break;
342  case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break;
343  case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break;
344  case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break;
345  case MID_RUBY_POSITION: pToSet = m_pRubyPosition.get();break;
346  }
347  if(pToSet)
348  rVal = *pToSet;
349  }
350  break;
351  default:
352  beans::PropertyState eTemp;
354  rEntry, *pUnoCursor, &rVal, eTemp );
355  if(!bDone)
356  {
357  if(!pSet)
358  {
359  pSet = std::make_unique<SfxItemSet>(
360  pUnoCursor->GetDoc().GetAttrPool(),
361  svl::Items<
364  RES_UNKNOWNATR_CONTAINER>{});
365  SwUnoCursorHelper::GetCursorAttr(*pUnoCursor, *pSet);
366  }
367  m_pPropSet->getPropertyValue(rEntry, *pSet, rVal);
368  }
369  }
370 }
371 
372 uno::Sequence< uno::Any > SwXTextPortion::GetPropertyValues_Impl(
373  const uno::Sequence< OUString >& rPropertyNames )
374 {
375  sal_Int32 nLength = rPropertyNames.getLength();
376  const OUString *pPropertyNames = rPropertyNames.getConstArray();
377  uno::Sequence< uno::Any > aValues(nLength);
378  uno::Any *pValues = aValues.getArray();
379  SwUnoCursor& rUnoCursor = GetCursor();
380 
381  {
382  std::unique_ptr<SfxItemSet> pSet;
383  // get starting point for the look-up, either the provided one or else
384  // from the beginning of the map
386  for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
387  {
388  const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
389  if(!pEntry)
390  throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
391  GetPropertyValue( pValues[nProp], *pEntry, &rUnoCursor, pSet );
392  }
393  }
394  return aValues;
395 }
396 
398  const OUString& rPropertyName)
399 {
400  SolarMutexGuard aGuard;
401  uno::Sequence< OUString > aPropertyNames { rPropertyName };
402  return GetPropertyValues_Impl(aPropertyNames).getConstArray()[0];
403 }
404 
406  const uno::Sequence< OUString >& rPropertyNames,
407  const uno::Sequence< uno::Any >& rValues )
408 {
409  SwUnoCursor& rUnoCursor = GetCursor();
410 
411  {
412  const OUString* pPropertyNames = rPropertyNames.getConstArray();
413  const uno::Any* pValues = rValues.getConstArray();
415  uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
416  for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
417  {
418  const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pPropertyNames[nProp]);
419  if (!pEntry)
420  throw beans::UnknownPropertyException( "Unknown property: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
421  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
422  throw beans::PropertyVetoException ("Property is read-only: " + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
423 
424  aValues[nProp].Name = pPropertyNames[nProp];
425  aValues[nProp].Value = pValues[nProp];
426  }
427  SwUnoCursorHelper::SetPropertyValues( rUnoCursor, *m_pPropSet, aValues );
428  }
429 }
430 
432  const uno::Sequence< OUString >& rPropertyNames,
433  const uno::Sequence< uno::Any >& rValues )
434 {
435  SolarMutexGuard aGuard;
436 
437  // workaround for bad designed API
438  try
439  {
440  SetPropertyValues_Impl( rPropertyNames, rValues );
441  }
442  catch (const beans::UnknownPropertyException &rException)
443  {
444  // wrap the original (here not allowed) exception in
445  // a lang::WrappedTargetException that gets thrown instead.
446  lang::WrappedTargetException aWExc;
447  aWExc.TargetException <<= rException;
448  throw aWExc;
449  }
450 }
451 
452 uno::Sequence< uno::Any > SwXTextPortion::getPropertyValues(
453  const uno::Sequence< OUString >& rPropertyNames )
454 {
455  SolarMutexGuard aGuard;
456  uno::Sequence< uno::Any > aValues;
457 
458  // workaround for bad designed API
459  try
460  {
461  aValues = GetPropertyValues_Impl( rPropertyNames );
462  }
463  catch (beans::UnknownPropertyException &)
464  {
465  css::uno::Any anyEx = cppu::getCaughtException();
466  throw lang::WrappedTargetRuntimeException("Unknown property exception caught",
467  static_cast < cppu::OWeakObject * > ( this ), anyEx );
468  }
469  catch (lang::WrappedTargetException &)
470  {
471  css::uno::Any anyEx = cppu::getCaughtException();
472  throw lang::WrappedTargetRuntimeException("WrappedTargetException caught",
473  static_cast < cppu::OWeakObject * > ( this ), anyEx );
474  }
475 
476  return aValues;
477 }
478 
479 /* disabled for #i46921# */
480 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPropertyValuesTolerant(
481  const uno::Sequence< OUString >& rPropertyNames,
482  const uno::Sequence< uno::Any >& rValues )
483 {
484  SolarMutexGuard aGuard;
485 
486  if (rPropertyNames.getLength() != rValues.getLength())
487  throw lang::IllegalArgumentException();
488  SwUnoCursor& rUnoCursor = GetCursor();
489 
490  sal_Int32 nProps = rPropertyNames.getLength();
491  const OUString *pProp = rPropertyNames.getConstArray();
492 
493  //sal_Int32 nVals = rValues.getLength();
494  const uno::Any *pValue = rValues.getConstArray();
495 
496  sal_Int32 nFailed = 0;
497  uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
498  beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
499 
500  const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
501 
502  for (sal_Int32 i = 0; i < nProps; ++i)
503  {
504  try
505  {
506  pFailed[ nFailed ].Name = pProp[i];
507 
508  const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( pProp[i] );
509  if (!pEntry)
510  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
511  else
512  {
513  // set property value
514  // (compare to SwXTextPortion::setPropertyValues)
515  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
516  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
517  else
518  {
520  rUnoCursor, *m_pPropSet, pProp[i], pValue[i] );
521  }
522  }
523  }
524  catch (beans::UnknownPropertyException &)
525  {
526  // should not occur because property was searched for before
527  TOOLS_WARN_EXCEPTION( "sw", "" );
528  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
529  }
530  catch (lang::IllegalArgumentException &)
531  {
532  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
533  }
534  catch (beans::PropertyVetoException &)
535  {
536  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
537  }
538  catch (lang::WrappedTargetException &)
539  {
540  pFailed[ nFailed++ ].Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
541  }
542  }
543 
544  aFailed.realloc( nFailed );
545  return aFailed;
546 }
547 
548 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL SwXTextPortion::getPropertyValuesTolerant(
549  const uno::Sequence< OUString >& rPropertyNames )
550 {
551  SolarMutexGuard aGuard;
552 
553  uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
554  GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
555 
556  // copy temporary result to final result type
557  sal_Int32 nLen = aTmpRes.getLength();
558  uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
559  std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.begin());
560  return aRes;
561 }
562 
563 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion::getDirectPropertyValuesTolerant(
564  const uno::Sequence< OUString >& rPropertyNames )
565 {
566  SolarMutexGuard aGuard;
567  return GetPropertyValuesTolerant_Impl( rPropertyNames, true );
568 }
569 
570 uno::Sequence< beans::GetDirectPropertyTolerantResult > SwXTextPortion::GetPropertyValuesTolerant_Impl(
571  const uno::Sequence< OUString >& rPropertyNames,
572  bool bDirectValuesOnly )
573 {
574  SolarMutexGuard aGuard;
575 
576  SwUnoCursor& rUnoCursor = GetCursor();
577 
578  std::vector< beans::GetDirectPropertyTolerantResult > aResultVector;
579 
580  try
581  {
582  sal_Int32 nProps = rPropertyNames.getLength();
583  const OUString *pProp = rPropertyNames.getConstArray();
584 
585  std::unique_ptr<SfxItemSet> pSet;
586 
587  const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
588 
589 
590  uno::Sequence< beans::PropertyState > aPropertyStates =
592  rUnoCursor, *m_pPropSet,
593  rPropertyNames,
595  const beans::PropertyState* pPropertyStates = aPropertyStates.getConstArray();
596 
597  for (sal_Int32 i = 0; i < nProps; ++i)
598  {
599  beans::GetDirectPropertyTolerantResult aResult;
600  try
601  {
602  aResult.Name = pProp[i];
603  if(pPropertyStates[i] == beans::PropertyState::PropertyState_MAKE_FIXED_SIZE) // property unknown?
604  {
605  if( bDirectValuesOnly )
606  continue;
607  else
608  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
609  }
610  else
611  {
612  const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( pProp[i] );
613  if (!pEntry)
614  throw beans::UnknownPropertyException( "Unknown property: " + pProp[i], static_cast < cppu::OWeakObject * > ( this ) );
615  aResult.State = pPropertyStates[i];
616 
617  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
618  //#i104499# ruby portion attributes need special handling:
619  if( pEntry->nWID == RES_TXTATR_CJK_RUBY &&
621  {
622  aResult.State = beans::PropertyState_DIRECT_VALUE;
623  }
624  if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State)
625  {
626  // get property value
627  // (compare to SwXTextPortion::getPropertyValue(s))
628  GetPropertyValue( aResult.Value, *pEntry, &rUnoCursor, pSet );
629  aResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
630  aResultVector.push_back( aResult );
631  }
632  }
633  }
634  catch (const beans::UnknownPropertyException &)
635  {
636  // should not occur because property was searched for before
637  TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
638  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
639  }
640  catch (const lang::IllegalArgumentException &)
641  {
642  aResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
643  }
644  catch (const beans::PropertyVetoException &)
645  {
646  aResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
647  }
648  catch (const lang::WrappedTargetException &)
649  {
650  aResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
651  }
652  }
653  }
654  catch (const uno::RuntimeException&)
655  {
656  throw;
657  }
658  catch (const uno::Exception& e)
659  {
660  css::uno::Any a(cppu::getCaughtException());
661  throw css::lang::WrappedTargetRuntimeException(
662  "wrapped Exception " + e.Message,
663  css::uno::Reference<css::uno::XInterface>(), a);
664  }
665 
666  return comphelper::containerToSequence(aResultVector);
667 }
668 
670  const uno::Sequence< OUString >& /*aPropertyNames*/,
671  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
672 {}
673 
675  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
676 {}
677 
679  const uno::Sequence< OUString >& /*aPropertyNames*/,
680  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
681 {}
682 
684  const OUString& /*PropertyName*/,
685  const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
686 {
687  OSL_FAIL("not implemented");
688 }
689 
690 void SwXTextPortion::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
691 {
692  OSL_FAIL("not implemented");
693 }
694 
695 void SwXTextPortion::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
696 {
697  OSL_FAIL("not implemented");
698 }
699 
700 void SwXTextPortion::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
701 {
702  OSL_FAIL("not implemented");
703 }
704 
705 beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyName)
706 {
707  SolarMutexGuard aGuard;
708  beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
709  SwUnoCursor& rUnoCursor = GetCursor();
710 
712  rPropertyName.startsWith("Ruby"))
713  {
714  eRet = beans::PropertyState_DIRECT_VALUE;
715  }
716  else
717  {
719  rPropertyName);
720  }
721  return eRet;
722 }
723 
724 uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates(
725  const uno::Sequence< OUString >& rPropertyNames)
726 {
727  SolarMutexGuard aGuard;
728  SwUnoCursor& rUnoCursor = GetCursor();
729 
730  uno::Sequence< beans::PropertyState > aRet =
733 
735  {
736  const OUString* pNames = rPropertyNames.getConstArray();
737  beans::PropertyState* pStates = aRet.getArray();
738  for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength();nProp++)
739  {
740  if (pNames[nProp].startsWith("Ruby"))
741  pStates[nProp] = beans::PropertyState_DIRECT_VALUE;
742  }
743  }
744  return aRet;
745 }
746 
747 void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
748 {
749  SolarMutexGuard aGuard;
750  SwUnoCursor& rUnoCursor = GetCursor();
751 
753  rUnoCursor, *m_pPropSet, rPropertyName);
754 }
755 
756 uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName)
757 {
758  SolarMutexGuard aGuard;
759  uno::Any aRet;
760  SwUnoCursor& rUnoCursor = GetCursor();
761 
763  rPropertyName);
764  return aRet;
765 }
766 
767 uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumeration(const OUString& /*aServiceName*/)
768 {
769  SolarMutexGuard aGuard;
770  SwUnoCursor& rUnoCursor = GetCursor();
771 
773 }
774 
775 namespace
776 {
777  class theSwXTextPortionUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextPortionUnoTunnelId > {};
778 }
779 
780 const uno::Sequence< sal_Int8 > & SwXTextPortion::getUnoTunnelId()
781 {
782  return theSwXTextPortionUnoTunnelId::get().getSeq();
783 }
784 
785 sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId )
786 {
787  if( isUnoTunnelId<SwXTextPortion>(rId) )
788  {
789  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
790  }
791  return 0;
792 }
793 
794 uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames()
795 {
796  return { "com.sun.star.text.TextContent" };
797 }
798 
800 {
801  return { "SwXTextPortion" };
802 }
803 
804 sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName)
805 {
806  return cppu::supportsService(this, rServiceName);
807 }
808 
809 uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames()
810 {
811  return { "com.sun.star.text.TextPortion",
812  "com.sun.star.style.CharacterProperties",
813  "com.sun.star.style.CharacterPropertiesAsian",
814  "com.sun.star.style.CharacterPropertiesComplex",
815  "com.sun.star.style.ParagraphProperties",
816  "com.sun.star.style.ParagraphPropertiesAsian",
817  "com.sun.star.style.ParagraphPropertiesComplex" };
818 }
819 
820 void SwXTextPortion::Notify(const SfxHint& rHint)
821 {
822  if(rHint.GetId() == SfxHintId::Dying)
823  m_pFrameFormat = nullptr;
824 }
825 
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
const SfxItemPropertySimpleEntry * getByName(std::u16string_view rName) const
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1779
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
std::unique_ptr< css::uno::Any > m_pRubyPosition
Definition: unoport.hxx:114
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
#define UNO_NAME_BOOKMARK
Definition: unoprnms.hxx:341
#define FN_UNO_DOCUMENT_INDEX_MARK
Definition: cmdid.h:525
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoport.cxx:794
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unoport.cxx:705
sw::UnoCursorPointer m_pUnoCursor
Definition: unoport.hxx:115
#define FN_UNO_TEXT_PORTION_TYPE
Definition: cmdid.h:573
#define FN_UNO_CONTROL_CHARACTER
Definition: cmdid.h:574
#define FN_UNO_META
Definition: cmdid.h:611
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:756
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1058
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:480
#define MID_RUBY_TEXT
Definition: unomid.h:113
std::unique_ptr< css::uno::Any > m_pRubyStyle
Definition: unoport.hxx:111
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:107
#define FN_UNO_BOOKMARK
Definition: cmdid.h:575
#define UNO_NAME_REFERENCE_MARK
Definition: unoprnms.hxx:347
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:2044
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:674
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:431
const SwTextPortionType m_ePortionType
Definition: unoport.hxx:118
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1648
css::uno::Reference< css::text::XTextContent > m_xRefMark
Definition: unoport.hxx:99
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: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:337
static SwXParaFrameEnumeration * Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1717
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:110
const css::uno::Reference< css::text::XText > m_xParentText
Definition: unoport.hxx:97
constexpr TypedWhichId< SwFormatRuby > RES_TXTATR_CJK_RUBY(53)
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unoport.cxx:747
css::uno::Reference< css::text::XTextContent > m_xTOXMark
Definition: unoport.hxx:101
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:570
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoport.cxx:785
void getPropertyValue(const SfxItemPropertySimpleEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
css::uno::Reference< css::text::XTextContent > m_xBookmark
Definition: unoport.hxx:103
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoport.cxx:148
#define FN_UNO_IS_COLLAPSED
Definition: cmdid.h:576
virtual void Notify(const SfxHint &rHint) override
Definition: unoport.cxx:820
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2005
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:136
Style of a layout element.
Definition: frmfmt.hxx:58
#define TOOLS_WARN_EXCEPTION(area, stream)
int i
uno_Any a
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:372
void SetPropertyValues_Impl(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues)
Definition: unoport.cxx:405
virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:548
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
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:690
bool StartListening(SvtBroadcaster &rBroadcaster)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoport.cxx:780
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unoport.cxx:397
const SwPosition * Start() const
Definition: pam.hxx:212
void init(const SwUnoCursor *pPortionCursor)
Definition: unoport.cxx:52
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:99
#define FN_UNO_TEXT_FIELD
Definition: cmdid.h:527
constexpr sal_uInt16 RES_FRMATR_END(131)
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:80
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:452
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:3344
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:724
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &aServiceName) override
Definition: unoport.cxx:767
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:109
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:577
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:700
#define FN_UNO_REFERENCE_MARK
Definition: cmdid.h:531
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:229
const SwPosition * End() const
Definition: pam.hxx:217
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:105
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: unoport.cxx:563
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:678
#define PROPERTY_MAP_REDLINE_PORTION
Definition: unomap.hxx:114
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoport.cxx:804
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
virtual ~SwXTextPortion() override
Definition: unoport.cxx:124
void GetPropertyValue(css::uno::Any &rVal, const SfxItemPropertySimpleEntry &rEntry, SwUnoCursor *pUnoCursor, std::unique_ptr< SfxItemSet > &pSet)
Definition: unoport.cxx:211
SwDoc & GetDoc() const
Definition: pam.hxx:243
sal_Int32 nLength
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
#define UNO_NAME_META
Definition: unoprnms.hxx:810
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:695
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1972
std::unique_ptr< css::uno::Any > m_pRubyAdjust
Definition: unoport.hxx:112
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoport.cxx:809
#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:683
const SfxItemPropertySet * m_pPropSet
Definition: unoport.hxx:95
#define FN_UNO_FOOTNOTE
Definition: cmdid.h:533
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:669
#define PROPERTY_MAP_TEXTPORTION_EXTENSIONS
Definition: unomap.hxx:59
SwTextPortionType GetTextPortionType() const
Definition: unoport.hxx:227
virtual OUString SAL_CALL getImplementationName() override
Definition: unoport.cxx:799
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unoport.cxx:177
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:846
#define MID_RUBY_POSITION
Definition: unomid.h:117
std::unique_ptr< css::uno::Any > m_pRubyIsAbove
Definition: unoport.hxx:113