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