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(nLength);
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 
559  // copy temporary result to final result type
560  sal_Int32 nLen = aTmpRes.getLength();
561  uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
562  std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.begin());
563  return aRes;
564 }
565 
566 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion::getDirectPropertyValuesTolerant(
567  const uno::Sequence< OUString >& rPropertyNames )
568 {
569  SolarMutexGuard aGuard;
570  return GetPropertyValuesTolerant_Impl( rPropertyNames, true );
571 }
572 
573 uno::Sequence< beans::GetDirectPropertyTolerantResult > SwXTextPortion::GetPropertyValuesTolerant_Impl(
574  const uno::Sequence< OUString >& rPropertyNames,
575  bool bDirectValuesOnly )
576 {
577  SolarMutexGuard aGuard;
578 
579  SwUnoCursor& rUnoCursor = GetCursor();
580 
581  std::vector< beans::GetDirectPropertyTolerantResult > aResultVector;
582 
583  try
584  {
585  sal_Int32 nProps = rPropertyNames.getLength();
586  const OUString *pProp = rPropertyNames.getConstArray();
587 
588  std::unique_ptr<SfxItemSet> pSet;
589 
590  const SfxItemPropertyMap& rPropMap = m_pPropSet->getPropertyMap();
591 
592 
593  uno::Sequence< beans::PropertyState > aPropertyStates =
595  rUnoCursor, *m_pPropSet,
596  rPropertyNames,
598  const beans::PropertyState* pPropertyStates = aPropertyStates.getConstArray();
599 
600  for (sal_Int32 i = 0; i < nProps; ++i)
601  {
602  beans::GetDirectPropertyTolerantResult aResult;
603  try
604  {
605  aResult.Name = pProp[i];
606  if(pPropertyStates[i] == beans::PropertyState::PropertyState_MAKE_FIXED_SIZE) // property unknown?
607  {
608  if( bDirectValuesOnly )
609  continue;
610  else
611  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
612  }
613  else
614  {
615  const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( pProp[i] );
616  if (!pEntry)
617  throw beans::UnknownPropertyException( "Unknown property: " + pProp[i], static_cast < cppu::OWeakObject * > ( this ) );
618  aResult.State = pPropertyStates[i];
619 
620  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
621  //#i104499# ruby portion attributes need special handling:
622  if( pEntry->nWID == RES_TXTATR_CJK_RUBY &&
624  {
625  aResult.State = beans::PropertyState_DIRECT_VALUE;
626  }
627  if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State)
628  {
629  // get property value
630  // (compare to SwXTextPortion::getPropertyValue(s))
631  GetPropertyValue( aResult.Value, *pEntry, &rUnoCursor, pSet );
632  aResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
633  aResultVector.push_back( aResult );
634  }
635  }
636  }
637  catch (const beans::UnknownPropertyException &)
638  {
639  // should not occur because property was searched for before
640  OSL_FAIL( "unexpected exception caught" );
641  aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
642  }
643  catch (const lang::IllegalArgumentException &)
644  {
645  aResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
646  }
647  catch (const beans::PropertyVetoException &)
648  {
649  aResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
650  }
651  catch (const lang::WrappedTargetException &)
652  {
653  aResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
654  }
655  }
656  }
657  catch (const uno::RuntimeException&)
658  {
659  throw;
660  }
661  catch (const uno::Exception& e)
662  {
663  css::uno::Any a(cppu::getCaughtException());
664  throw css::lang::WrappedTargetRuntimeException(
665  "wrapped Exception " + e.Message,
666  css::uno::Reference<css::uno::XInterface>(), a);
667  }
668 
669  return comphelper::containerToSequence(aResultVector);
670 }
671 
673  const uno::Sequence< OUString >& /*aPropertyNames*/,
674  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
675 {}
676 
678  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
679 {}
680 
682  const uno::Sequence< OUString >& /*aPropertyNames*/,
683  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
684 {}
685 
687  const OUString& /*PropertyName*/,
688  const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
689 {
690  OSL_FAIL("not implemented");
691 }
692 
693 void SwXTextPortion::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
694 {
695  OSL_FAIL("not implemented");
696 }
697 
698 void SwXTextPortion::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
699 {
700  OSL_FAIL("not implemented");
701 }
702 
703 void SwXTextPortion::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
704 {
705  OSL_FAIL("not implemented");
706 }
707 
708 beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyName)
709 {
710  SolarMutexGuard aGuard;
711  beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
712  SwUnoCursor& rUnoCursor = GetCursor();
713 
715  rPropertyName.startsWith("Ruby"))
716  {
717  eRet = beans::PropertyState_DIRECT_VALUE;
718  }
719  else
720  {
722  rPropertyName);
723  }
724  return eRet;
725 }
726 
727 uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates(
728  const uno::Sequence< OUString >& rPropertyNames)
729 {
730  SolarMutexGuard aGuard;
731  SwUnoCursor& rUnoCursor = GetCursor();
732 
733  uno::Sequence< beans::PropertyState > aRet =
736 
738  {
739  const OUString* pNames = rPropertyNames.getConstArray();
740  beans::PropertyState* pStates = aRet.getArray();
741  for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength();nProp++)
742  {
743  if (pNames[nProp].startsWith("Ruby"))
744  pStates[nProp] = beans::PropertyState_DIRECT_VALUE;
745  }
746  }
747  return aRet;
748 }
749 
750 void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName)
751 {
752  SolarMutexGuard aGuard;
753  SwUnoCursor& rUnoCursor = GetCursor();
754 
756  rUnoCursor, *m_pPropSet, rPropertyName);
757 }
758 
759 uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName)
760 {
761  SolarMutexGuard aGuard;
762  uno::Any aRet;
763  SwUnoCursor& rUnoCursor = GetCursor();
764 
766  rPropertyName);
767  return aRet;
768 }
769 
770 uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumeration(const OUString& /*aServiceName*/)
771 {
772  SolarMutexGuard aGuard;
773  SwUnoCursor& rUnoCursor = GetCursor();
774 
776 }
777 
778 namespace
779 {
780  class theSwXTextPortionUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextPortionUnoTunnelId > {};
781 }
782 
783 const uno::Sequence< sal_Int8 > & SwXTextPortion::getUnoTunnelId()
784 {
785  return theSwXTextPortionUnoTunnelId::get().getSeq();
786 }
787 
788 sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId )
789 {
790  if( rId.getLength() == 16
791  && 0 == memcmp( getUnoTunnelId().getConstArray(),
792  rId.getConstArray(), 16 ) )
793  {
794  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
795  }
796  return 0;
797 }
798 
799 uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames()
800 {
801  return { "com.sun.star.text.TextContent" };
802 }
803 
805 {
806  return { "SwXTextPortion" };
807 }
808 
809 sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName)
810 {
811  return cppu::supportsService(this, rServiceName);
812 }
813 
814 uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames()
815 {
816  return { "com.sun.star.text.TextPortion",
817  "com.sun.star.style.CharacterProperties",
818  "com.sun.star.style.CharacterPropertiesAsian",
819  "com.sun.star.style.CharacterPropertiesComplex",
820  "com.sun.star.style.ParagraphProperties",
821  "com.sun.star.style.ParagraphPropertiesAsian",
822  "com.sun.star.style.ParagraphPropertiesComplex" };
823 }
824 
826 {
827  if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
828  {
829  ClientModify(this, pLegacyHint->m_pOld, pLegacyHint->m_pNew);
831  m_pFrameFormat = nullptr;
832  }
833 }
834 
835 /* 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:1807
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:503
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoport.cxx:799
#define RES_TXTATR_CJK_RUBY
Definition: hintids.hxx:143
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unoport.cxx:708
sw::UnoCursorPointer m_pUnoCursor
Definition: unoport.hxx:114
#define FN_UNO_TEXT_PORTION_TYPE
Definition: cmdid.h:551
#define FN_UNO_CONTROL_CHARACTER
Definition: cmdid.h:552
#define FN_UNO_META
Definition: cmdid.h:589
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:759
#define RES_FRMATR_END
Definition: hintids.hxx:236
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1098
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:553
#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:296
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:677
#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:1544
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:357
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:1610
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:750
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:573
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unoport.cxx:788
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:2042
#define FN_UNO_IS_COLLAPSED
Definition: cmdid.h:554
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: unoport.cxx:825
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:693
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoport.cxx:783
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:505
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:3382
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2002
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unoport.cxx:727
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &aServiceName) override
Definition: unoport.cxx:770
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:555
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:703
#define FN_UNO_REFERENCE_MARK
Definition: cmdid.h:509
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:131
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:566
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:681
#define PROPERTY_MAP_REDLINE_PORTION
Definition: unomap.hxx:116
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unoport.cxx:809
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
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:816
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unoport.cxx:698
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1969
std::unique_ptr< css::uno::Any > m_pRubyAdjust
Definition: unoport.hxx:111
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoport.cxx:814
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:686
const SfxItemPropertySet * m_pPropSet
Definition: unoport.hxx:94
#define FN_UNO_FOOTNOTE
Definition: cmdid.h:511
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: unoport.cxx:672
#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:804
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:843
#define MID_RUBY_POSITION
Definition: unomid.h:117
std::unique_ptr< css::uno::Any > m_pRubyIsAbove
Definition: unoport.hxx:112