LibreOffice Module sw (master)  1
unoparagraph.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 <unoparagraph.hxx>
21 
23 #include <cppuhelper/exc_hlp.hxx>
25 #include <osl/diagnose.h>
26 #include <tools/diagnose_ex.h>
27 
28 #include <cmdid.h>
29 #include <unomid.h>
30 #include <unoparaframeenum.hxx>
31 #include <unotext.hxx>
32 #include <unotextrange.hxx>
33 #include <unoport.hxx>
34 #include <unomap.hxx>
35 #include <unocrsr.hxx>
36 #include <unoprnms.hxx>
37 #include <unocrsrhelper.hxx>
38 #include <doc.hxx>
39 #include <ndtxt.hxx>
40 #include <vcl/svapp.hxx>
41 #include <docsh.hxx>
42 #include <swunohelper.hxx>
43 
44 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
45 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
46 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
49 #include <com/sun/star/text/WrapTextMode.hpp>
50 #include <com/sun/star/text/TextContentAnchorType.hpp>
51 
52 #include <com/sun/star/drawing/BitmapMode.hpp>
54 #include <editeng/unoipset.hxx>
55 #include <svl/listener.hxx>
57 #include <svx/xflbmtit.hxx>
58 #include <svx/xflbstit.hxx>
59 
60 using namespace ::com::sun::star;
61 
62 namespace {
63 
64 class SwParaSelection
65 {
66  SwCursor & m_rCursor;
67 public:
68  explicit SwParaSelection(SwCursor & rCursor);
69  ~SwParaSelection();
70 };
71 
72 }
73 
74 SwParaSelection::SwParaSelection(SwCursor & rCursor)
75  : m_rCursor(rCursor)
76 {
77  if (m_rCursor.HasMark())
78  {
79  m_rCursor.DeleteMark();
80  }
81  // is it at the start?
82  if (m_rCursor.GetPoint()->nContent != 0)
83  {
84  m_rCursor.MovePara(GoCurrPara, fnParaStart);
85  }
86  // or at the end already?
87  if (m_rCursor.GetPoint()->nContent != m_rCursor.GetContentNode()->Len())
88  {
89  m_rCursor.SetMark();
90  m_rCursor.MovePara(GoCurrPara, fnParaEnd);
91  }
92 }
93 
94 SwParaSelection::~SwParaSelection()
95 {
96  if (m_rCursor.GetPoint()->nContent != 0)
97  {
98  m_rCursor.DeleteMark();
99  m_rCursor.MovePara(GoCurrPara, fnParaStart);
100  }
101 }
102 
105 static beans::PropertyState lcl_SwXParagraph_getPropertyState(
106  const SwTextNode& rTextNode,
107  const SwAttrSet** ppSet,
108  const SfxItemPropertyMapEntry& rEntry,
109  bool &rAttrSetFetched );
110 
112  : public SvtListener
113 {
114 public:
116  uno::WeakReference<uno::XInterface> m_wThis;
117  std::mutex m_Mutex; // just for OInterfaceContainerHelper4
123  OUString m_sText;
124  uno::Reference<text::XText> m_xParentText;
126 
128  SwTextNode* const pTextNode = nullptr, uno::Reference<text::XText> const& xParent = nullptr,
129  const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
130  : m_rThis(rThis)
131  , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
132  , m_bIsDescriptor(nullptr == pTextNode)
133  , m_nSelectionStartPos(nSelStart)
134  , m_nSelectionEndPos(nSelEnd)
135  , m_xParentText(xParent)
136  , m_pTextNode(pTextNode)
137  {
138  m_pTextNode && StartListening(m_pTextNode->GetNotifier());
139  }
140 
142  return m_pTextNode;
143  }
144 
146  if (!m_pTextNode) {
147  throw uno::RuntimeException("SwXParagraph: disposed or invalid", nullptr);
148  }
149  return *m_pTextNode;
150  }
151 
152  bool IsDescriptor() const { return m_bIsDescriptor; }
153 
160  const uno::Sequence< OUString >& rPropertyNames,
161  const uno::Sequence< uno::Any >& rValues);
162 
166  uno::Sequence< uno::Any >
168  const uno::Sequence< OUString >& rPropertyNames);
169 
172  const SfxItemPropertyMapEntry& rEntry,
173  const SfxItemSet& rSet,
174  uno::Any& rAny ) const;
175 
177  uno::Sequence< beans::GetDirectPropertyTolerantResult >
179  const uno::Sequence< OUString >& rPropertyNames,
180  bool bDirectValuesOnly);
181 protected:
182  virtual void Notify(const SfxHint& rHint) override;
183 
184 };
185 
187 {
188  if(rHint.GetId() == SfxHintId::Dying)
189  {
190  m_pTextNode = nullptr;
191  uno::Reference<uno::XInterface> const xThis(m_wThis);
192  if (!xThis.is())
193  { // fdo#72695: if UNO object is already dead, don't revive it with event
194  return;
195  }
196  lang::EventObject const ev(xThis);
197  std::unique_lock aGuard(m_Mutex);
198  m_EventListeners.disposeAndClear(aGuard, ev);
199  }
200 }
201 
203  : m_pImpl( new SwXParagraph::Impl(*this) )
204 {
205 }
206 
208  uno::Reference< text::XText > const & xParent,
209  SwTextNode & rTextNode,
210  const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
211  : m_pImpl(
212  new SwXParagraph::Impl(*this, &rTextNode, xParent, nSelStart, nSelEnd))
213 {
214 }
215 
217 {
218 }
219 
221 {
222  return m_pImpl->GetTextNode();
223 }
224 
226 {
227  return m_pImpl->IsDescriptor();
228 }
229 
230 uno::Reference<text::XTextContent>
232  uno::Reference< text::XText> const& i_xParent,
233  const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
234 {
235  // re-use existing SwXParagraph
236  // #i105557#: do not iterate over the registered clients: race condition
237  uno::Reference<text::XTextContent> xParagraph;
238  if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
239  { // only use cache if no selection!
240  xParagraph.set(pTextNode->GetXParagraph());
241  }
242  if (xParagraph.is())
243  {
244  return xParagraph;
245  }
246 
247  // create new SwXParagraph
248  uno::Reference<text::XText> xParentText(i_xParent);
249  if (!xParentText.is() && pTextNode)
250  {
251  SwPosition Pos(*pTextNode);
252  xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
253  }
254  SwXParagraph *const pXPara( pTextNode
255  ? new SwXParagraph(xParentText, *pTextNode, nSelStart, nSelEnd)
256  : new SwXParagraph);
257  // this is why the constructor is private: need to acquire pXPara here
258  xParagraph.set(pXPara);
259  // in order to initialize the weak pointer cache in the core object
260  if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
261  {
262  pTextNode->SetXParagraph(xParagraph);
263  }
264  // need a permanent Reference to initialize m_wThis
265  pXPara->m_pImpl->m_wThis = xParagraph;
266  return xParagraph;
267 }
268 
270 {
271  SwTextNode const*const pTextNode( GetTextNode() );
272 
273  if (!pTextNode)
274  {
275  return false;
276  }
277 
278  *rPaM.GetPoint() = SwPosition( *pTextNode );
279  // set selection to the whole paragraph
280  rPaM.SetMark();
281  rPaM.GetMark()->nContent = pTextNode->GetText().getLength();
282  return true;
283 }
284 
285 const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
286 {
287  static const comphelper::UnoIdInit theSwXParagraphUnoTunnelId;
288  return theSwXParagraphUnoTunnelId.getSeq();
289 }
290 
291 sal_Int64 SAL_CALL
292 SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
293 {
294  return comphelper::getSomethingImpl<SwXParagraph>(rId, this);
295 }
296 
297 OUString SAL_CALL
299 {
300  return "SwXParagraph";
301 }
302 
303 sal_Bool SAL_CALL
304 SwXParagraph::supportsService(const OUString& rServiceName)
305 {
306  return cppu::supportsService(this, rServiceName);
307 }
308 
309 uno::Sequence< OUString > SAL_CALL
311 {
312  return {
313  "com.sun.star.text.TextContent",
314  "com.sun.star.text.Paragraph",
315  "com.sun.star.style.CharacterProperties",
316  "com.sun.star.style.CharacterPropertiesAsian",
317  "com.sun.star.style.CharacterPropertiesComplex",
318  "com.sun.star.style.ParagraphProperties",
319  "com.sun.star.style.ParagraphPropertiesAsian",
320  "com.sun.star.style.ParagraphPropertiesComplex"
321  };
322 }
323 
324 void
326 {
327  OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
328  if (!m_pImpl->m_bIsDescriptor)
329  return;
330 
331  m_pImpl->m_bIsDescriptor = false;
332  m_pImpl->EndListeningAll();
333  m_pImpl->StartListening(rTextNode.GetNotifier());
334  rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
335  m_pImpl->m_xParentText = &rParent;
336  if (!m_pImpl->m_sText.isEmpty())
337  {
338  try { setString(m_pImpl->m_sText); }
339  catch(...){}
340  m_pImpl->m_sText.clear();
341  }
342 }
343 
344 uno::Reference< beans::XPropertySetInfo > SAL_CALL
346 {
347  SolarMutexGuard g;
348 
349  static uno::Reference< beans::XPropertySetInfo > xRef =
350  m_pImpl->m_rPropSet.getPropertySetInfo();
351  return xRef;
352 }
353 
354 void SAL_CALL
355 SwXParagraph::setPropertyValue(const OUString& rPropertyName,
356  const uno::Any& rValue)
357 {
358  SolarMutexGuard aGuard;
359  m_pImpl->SetPropertyValues_Impl( { rPropertyName }, { rValue } );
360 }
361 
362 uno::Any
363 SwXParagraph::getPropertyValue(const OUString& rPropertyName)
364 {
365  SolarMutexGuard aGuard;
366  uno::Sequence<OUString> aPropertyNames { rPropertyName };
367  const uno::Sequence< uno::Any > aRet =
368  m_pImpl->GetPropertyValues_Impl(aPropertyNames);
369  return aRet.getConstArray()[0];
370 }
371 
373  const uno::Sequence< OUString >& rPropertyNames,
374  const uno::Sequence< uno::Any >& rValues )
375 {
376  SwTextNode & rTextNode(GetTextNodeOrThrow());
377 
378  SwPosition aPos( rTextNode );
379  SwCursor aCursor( aPos, nullptr );
380  const OUString* pPropertyNames = rPropertyNames.getConstArray();
381  const uno::Any* pValues = rValues.getConstArray();
383  SwParaSelection aParaSel( aCursor );
384 
385  uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
386  auto aValuesRange = asNonConstRange(aValues);
387  for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
388  {
389  SfxItemPropertyMapEntry const*const pEntry =
390  rMap.getByName( pPropertyNames[nProp] );
391  if (!pEntry)
392  {
393  throw beans::UnknownPropertyException(
394  "Unknown property: " + pPropertyNames[nProp],
395  static_cast< cppu::OWeakObject * >(&m_rThis));
396  }
397  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
398  {
399  throw beans::PropertyVetoException(
400  "Property is read-only: " + pPropertyNames[nProp],
401  static_cast< cppu::OWeakObject * >(&m_rThis));
402  }
403  aValuesRange[nProp].Name = pPropertyNames[nProp];
404  aValuesRange[nProp].Value = pValues[nProp];
405  }
407 }
408 
410  const uno::Sequence< OUString >& rPropertyNames,
411  const uno::Sequence< uno::Any >& rValues )
412 {
413  SolarMutexGuard aGuard;
414 
415  // workaround for bad designed API
416  try
417  {
418  m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
419  }
420  catch (const beans::UnknownPropertyException &rException)
421  {
422  // wrap the original (here not allowed) exception in
423  // a lang::WrappedTargetException that gets thrown instead.
424  lang::WrappedTargetException aWExc;
425  aWExc.TargetException <<= rException;
426  throw aWExc;
427  }
428 }
429 
430 // Support for DrawingLayer FillStyles for GetPropertyValue() usages
432  const SfxItemPropertyMapEntry& rEntry,
433  const SfxItemSet& rSet,
434  uno::Any& rAny ) const
435 {
436  bool bDone(false);
437 
438  switch(rEntry.nWID)
439  {
440  case RES_BACKGROUND:
441  {
442  const std::unique_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
443 
444  if(!aOriginalBrushItem->QueryValue(rAny, rEntry.nMemberId))
445  {
446  OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
447  }
448 
449  bDone = true;
450  break;
451  }
453  {
454  if (rSet.Get(XATTR_FILLBMP_TILE).GetValue())
455  {
456  rAny <<= drawing::BitmapMode_REPEAT;
457  }
458  else if (rSet.Get(XATTR_FILLBMP_STRETCH).GetValue())
459  {
460  rAny <<= drawing::BitmapMode_STRETCH;
461  }
462  else
463  {
464  rAny <<= drawing::BitmapMode_NO_REPEAT;
465  }
466 
467  bDone = true;
468  break;
469  }
470  default: break;
471  }
472 
473  if(bDone)
474  return;
475 
476  // fallback to standard get value implementation used before this helper was created
477  m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
478 
479  if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
480  {
481  // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
482  sal_Int32 nValue(0);
483 
484  if (rAny >>= nValue)
485  {
486  rAny <<= static_cast<sal_Int16>(nValue);
487  }
488  }
489 
490  // check for needed metric translation
491  if(!(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
492  return;
493 
494  bool bDoIt(true);
495 
496  if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
497  {
498  // exception: If these ItemTypes are used, do not convert when these are negative
499  // since this means they are intended as percent values
500  sal_Int32 nValue = 0;
501 
502  if(rAny >>= nValue)
503  {
504  bDoIt = nValue > 0;
505  }
506  }
507 
508  if(bDoIt)
509  {
510  const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
511 
512  if(eMapUnit != MapUnit::Map100thMM)
513  {
514  SvxUnoConvertToMM(eMapUnit, rAny);
515  }
516  }
517 }
518 
520  const uno::Sequence< OUString > & rPropertyNames )
521 {
522  SwTextNode & rTextNode(GetTextNodeOrThrow());
523 
524  uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
525  SwPosition aPos( rTextNode );
526  SwPaM aPam( aPos );
527  uno::Any* pValues = aValues.getArray();
528  const OUString* pPropertyNames = rPropertyNames.getConstArray();
529  const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
530  const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
531  for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
532  {
533  SfxItemPropertyMapEntry const*const pEntry =
534  rMap.getByName( pPropertyNames[nProp] );
535  if (!pEntry)
536  {
537  throw beans::UnknownPropertyException(
538  "Unknown property: " + pPropertyNames[nProp],
539  static_cast< cppu::OWeakObject * >(&m_rThis));
540  }
542  pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
543  {
544  beans::PropertyState eTemp;
546  *pEntry, aPam, &(pValues[nProp]), eTemp, &rTextNode );
547  if (!bDone)
548  {
549  GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
550  }
551  }
552  }
553  return aValues;
554 }
555 
556 uno::Sequence< uno::Any > SAL_CALL
557 SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
558 {
559  SolarMutexGuard aGuard;
560  uno::Sequence< uno::Any > aValues;
561 
562  // workaround for bad designed API
563  try
564  {
565  aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
566  }
567  catch (beans::UnknownPropertyException &)
568  {
569  css::uno::Any anyEx = cppu::getCaughtException();
570  throw css::lang::WrappedTargetRuntimeException("Unknown property exception caught",
571  static_cast < cppu::OWeakObject * > ( this ), anyEx );
572  }
573  catch (lang::WrappedTargetException &)
574  {
575  css::uno::Any anyEx = cppu::getCaughtException();
576  throw css::lang::WrappedTargetRuntimeException("WrappedTargetException caught",
577  static_cast < cppu::OWeakObject * > ( this ), anyEx );
578  }
579 
580  return aValues;
581 }
582 
584  const uno::Sequence< OUString >& /*aPropertyNames*/,
585  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
586 {
587  OSL_FAIL("SwXParagraph::addPropertiesChangeListener(): not implemented");
588 }
589 
591  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
592 {
593  OSL_FAIL("SwXParagraph::removePropertiesChangeListener(): not implemented");
594 }
595 
597  const uno::Sequence< OUString >& /*aPropertyNames*/,
598  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
599 {
600  OSL_FAIL("SwXParagraph::firePropertiesChangeEvent(): not implemented");
601 }
602 
603 /* disabled for #i46921# */
604 
605 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
607  const uno::Sequence< OUString >& rPropertyNames,
608  const uno::Sequence< uno::Any >& rValues )
609 {
610  SolarMutexGuard aGuard;
611 
612  if (rPropertyNames.getLength() != rValues.getLength())
613  {
614  throw lang::IllegalArgumentException();
615  }
616 
617  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
618 
619  //SwNode& rTextNode = pUnoCursor->GetPoint()->nNode.GetNode();
620  //const SwAttrSet& rAttrSet = static_cast<SwTextNode&>(rTextNode).GetSwAttrSet();
621  //sal_uInt16 nAttrCount = rAttrSet.Count();
622 
623  const sal_Int32 nProps = rPropertyNames.getLength();
624  const OUString *pProp = rPropertyNames.getConstArray();
625 
626  //sal_Int32 nVals = rValues.getLength();
627  const uno::Any *pValue = rValues.getConstArray();
628 
629  sal_Int32 nFailed = 0;
630  uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
631  beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
632 
633  // get entry to start with
634  const SfxItemPropertyMap &rPropMap =
635  m_pImpl->m_rPropSet.getPropertyMap();
636 
637  SwPosition aPos( rTextNode );
638  SwCursor aCursor( aPos, nullptr );
639  SwParaSelection aParaSel( aCursor );
640  for (sal_Int32 i = 0; i < nProps; ++i)
641  {
642  try
643  {
644  pFailed[ nFailed ].Name = pProp[i];
645 
646  SfxItemPropertyMapEntry const*const pEntry =
647  rPropMap.getByName( pProp[i] );
648  if (!pEntry)
649  {
650  pFailed[ nFailed++ ].Result =
651  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
652  }
653  else
654  {
655  // set property value
656  // (compare to SwXParagraph::setPropertyValues)
657  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
658  {
659  pFailed[ nFailed++ ].Result =
660  beans::TolerantPropertySetResultType::PROPERTY_VETO;
661  }
662  else
663  {
665  aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
666  }
667  }
668  }
669  catch (beans::UnknownPropertyException &)
670  {
671  // should not occur because property was searched for before
672  TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
673  pFailed[ nFailed++ ].Result =
674  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
675  }
676  catch (lang::IllegalArgumentException &)
677  {
678  pFailed[ nFailed++ ].Result =
679  beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
680  }
681  catch (beans::PropertyVetoException &)
682  {
683  pFailed[ nFailed++ ].Result =
684  beans::TolerantPropertySetResultType::PROPERTY_VETO;
685  }
686  catch (lang::WrappedTargetException &)
687  {
688  pFailed[ nFailed++ ].Result =
689  beans::TolerantPropertySetResultType::WRAPPED_TARGET;
690  }
691  }
692 
693  aFailed.realloc( nFailed );
694  return aFailed;
695 }
696 
697 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
699  const uno::Sequence< OUString >& rPropertyNames )
700 {
701  SolarMutexGuard aGuard;
702 
703  const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
704  m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
705 
706  // copy temporary result to final result type
707  const sal_Int32 nLen = aTmpRes.getLength();
708  uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
709  std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray());
710  return aRes;
711 }
712 
713 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
715  const uno::Sequence< OUString >& rPropertyNames )
716 {
717  SolarMutexGuard aGuard;
718 
719  return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
720 }
721 
722 uno::Sequence< beans::GetDirectPropertyTolerantResult >
724  const uno::Sequence< OUString >& rPropertyNames,
725  bool bDirectValuesOnly )
726 {
727  SolarMutexGuard aGuard;
728 
729  SwTextNode & rTextNode(GetTextNodeOrThrow());
730 
731  // #i46786# Use SwAttrSet pointer for determining the state.
732  // Use the value SwAttrSet (from the paragraph OR the style)
733  // for determining the actual value(s).
734  const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet();
735  const SwAttrSet& rValueAttrSet = rTextNode.GetSwAttrSet();
736 
737  sal_Int32 nProps = rPropertyNames.getLength();
738 
739  uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
740  beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
741  sal_Int32 nIdx = 0;
742 
743  // get entry to start with
744  const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
745 
746  for (const OUString& rProp : rPropertyNames)
747  {
748  OSL_ENSURE( nIdx < nProps, "index out of bounds" );
749  beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
750 
751  try
752  {
753  rResult.Name = rProp;
754 
755  SfxItemPropertyMapEntry const*const pEntry =
756  rPropMap.getByName( rProp );
757  if (!pEntry) // property available?
758  {
759  rResult.Result =
760  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
761  }
762  else
763  {
764  // get property state
765  // (compare to SwXParagraph::getPropertyState)
766  bool bAttrSetFetched = true;
767  beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
768  rTextNode, &pAttrSet, *pEntry, bAttrSetFetched );
769  rResult.State = eState;
770 
771  rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
772  if (!bDirectValuesOnly ||
773  (beans::PropertyState_DIRECT_VALUE == eState))
774  {
775  // get property value
776  // (compare to SwXParagraph::getPropertyValue(s))
777  uno::Any aValue;
779  aValue, rProp, pEntry->nWID ) )
780  {
781  SwPosition aPos( rTextNode );
782  SwPaM aPam( aPos );
783  // handle properties that are not part of the attribute
784  // and thus only pretended to be paragraph attributes
785  beans::PropertyState eTemp;
786  const bool bDone =
788  *pEntry, aPam, &aValue, eTemp, &rTextNode );
789 
790  // if not found try the real paragraph attributes...
791  if (!bDone)
792  {
793  GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
794  }
795  }
796 
797  rResult.Value = aValue;
798  rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
799 
800  nIdx++;
801  }
802  // this assertion should never occur!
803  OSL_ENSURE( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
804  "unknown failure while retrieving property" );
805 
806  }
807  }
808  catch (beans::UnknownPropertyException &)
809  {
810  // should not occur because property was searched for before
811  TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
812  rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
813  }
814  catch (lang::IllegalArgumentException &)
815  {
816  rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
817  }
818  catch (beans::PropertyVetoException &)
819  {
820  rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
821  }
822  catch (lang::WrappedTargetException &)
823  {
824  rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
825  }
826  }
827 
828  // resize to actually used size
829  aResult.realloc( nIdx );
830 
831  return aResult;
832 }
833 
835  uno::Any& rAny, std::u16string_view rPropertyName, sal_uInt16 nWID)
836 {
837  if(!nWID)
838  {
839  if(rPropertyName == u"" UNO_NAME_ANCHOR_TYPE)
840  nWID = FN_UNO_ANCHOR_TYPE;
841  else if(rPropertyName == u"" UNO_NAME_ANCHOR_TYPES)
842  nWID = FN_UNO_ANCHOR_TYPES;
843  else if(rPropertyName == u"" UNO_NAME_TEXT_WRAP)
844  nWID = FN_UNO_TEXT_WRAP;
845  else
846  return false;
847  }
848 
849  switch(nWID)
850  {
851  case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break;
852  case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
853  case FN_UNO_ANCHOR_TYPES:
854  { uno::Sequence<text::TextContentAnchorType> aTypes { text::TextContentAnchorType_AT_PARAGRAPH };
855  rAny <<= aTypes;
856  }
857  break;
858  default:
859  return false;
860  }
861  return true;
862 }
863 
864 void SAL_CALL
866  const OUString& /*rPropertyName*/,
867  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
868 {
869  OSL_FAIL("SwXParagraph::addPropertyChangeListener(): not implemented");
870 }
871 
872 void SAL_CALL
874  const OUString& /*rPropertyName*/,
875  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
876 {
877  OSL_FAIL("SwXParagraph::removePropertyChangeListener(): not implemented");
878 }
879 
880 void SAL_CALL
882  const OUString& /*rPropertyName*/,
883  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
884 {
885  OSL_FAIL("SwXParagraph::addVetoableChangeListener(): not implemented");
886 }
887 
888 void SAL_CALL
890  const OUString& /*rPropertyName*/,
891  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
892 {
893  OSL_FAIL("SwXParagraph::removeVetoableChangeListener(): not implemented");
894 }
895 
896 static beans::PropertyState lcl_SwXParagraph_getPropertyState(
897  const SwTextNode& rTextNode,
898  const SwAttrSet** ppSet,
899  const SfxItemPropertyMapEntry& rEntry,
900  bool &rAttrSetFetched)
901 {
902  beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
903 
904  if(!(*ppSet) && !rAttrSetFetched)
905  {
906  (*ppSet) = rTextNode.GetpSwAttrSet();
907  rAttrSetFetched = true;
908  }
909 
910  SwPosition aPos(rTextNode);
911  SwPaM aPam(aPos);
912  bool bDone(false);
913 
914  switch(rEntry.nWID)
915  {
916  case FN_UNO_NUM_RULES:
917  {
918  // if numbering is set, return it; else do nothing
919  SwUnoCursorHelper::getNumberingProperty(aPam,eRet,nullptr);
920  bDone = true;
921  break;
922  }
923  case FN_UNO_LIST_ID:
924  {
925  if (*ppSet)
926  {
927  if ((*ppSet)->GetItemState(RES_PARATR_LIST_ID, false) == SfxItemState::SET)
928  {
929  SwNumRule* pNumRule = rTextNode.GetNumRule();
930  if (!pNumRule || pNumRule->HasContinueList())
931  {
932  eRet = beans::PropertyState_DIRECT_VALUE;
933  }
934  }
935  bDone = true;
936  }
937  break;
938  }
939  case FN_UNO_ANCHOR_TYPES:
940  {
941  bDone = true;
942  break;
943  }
944  case RES_ANCHOR:
945  {
946  bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId);
947  break;
948  }
949  case RES_SURROUND:
950  {
951  bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId);
952  break;
953  }
954  case FN_UNO_PARA_STYLE:
956  {
958  eRet = pFormat ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
959  bDone = true;
960  break;
961  }
962  case FN_UNO_PAGE_STYLE:
963  {
964  OUString sVal;
966  eRet = !sVal.isEmpty() ? beans::PropertyState_DIRECT_VALUE
967  : beans::PropertyState_AMBIGUOUS_VALUE;
968  bDone = true;
969  break;
970  }
971 
972  // DrawingLayer PropertyStyle support
974  {
975  if(*ppSet)
976  {
977  if(SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
978  || SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
979  {
980  eRet = beans::PropertyState_DIRECT_VALUE;
981  }
982  else
983  {
984  eRet = beans::PropertyState_AMBIGUOUS_VALUE;
985  }
986 
987  bDone = true;
988  }
989  break;
990  }
991  case RES_BACKGROUND:
992  {
993  if(*ppSet)
994  {
996  rEntry.nMemberId))
997  {
998  eRet = beans::PropertyState_DIRECT_VALUE;
999  }
1000  bDone = true;
1001  }
1002  break;
1003  }
1004  }
1005 
1006  if(!bDone)
1007  {
1008  if((*ppSet) && SfxItemState::SET == (*ppSet)->GetItemState(rEntry.nWID, false))
1009  {
1010  eRet = beans::PropertyState_DIRECT_VALUE;
1011  }
1012  }
1013 
1014  return eRet;
1015 }
1016 
1017 beans::PropertyState SAL_CALL
1018 SwXParagraph::getPropertyState(const OUString& rPropertyName)
1019 {
1020  SolarMutexGuard aGuard;
1021 
1022  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1023 
1024  const SwAttrSet* pSet = nullptr;
1025  SfxItemPropertyMapEntry const*const pEntry =
1026  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1027  if (!pEntry)
1028  {
1029  throw beans::UnknownPropertyException(
1030  "Unknown property: " + rPropertyName,
1031  static_cast<cppu::OWeakObject *>(this));
1032  }
1033  bool bDummy = false;
1034  const beans::PropertyState eRet =
1035  lcl_SwXParagraph_getPropertyState(rTextNode, &pSet, *pEntry, bDummy);
1036  return eRet;
1037 }
1038 
1039 uno::Sequence< beans::PropertyState > SAL_CALL
1041  const uno::Sequence< OUString >& PropertyNames)
1042 {
1043  SolarMutexGuard aGuard;
1044 
1045  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1046 
1047  const OUString* pNames = PropertyNames.getConstArray();
1048  uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
1049  beans::PropertyState* pStates = aRet.getArray();
1050  const SfxItemPropertyMap &rMap = m_pImpl->m_rPropSet.getPropertyMap();
1051  const SwAttrSet* pSet = nullptr;
1052  bool bAttrSetFetched = false;
1053 
1054  for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
1055  ++i, ++pStates, ++pNames)
1056  {
1057  SfxItemPropertyMapEntry const*const pEntry =
1058  rMap.getByName( *pNames );
1059  if (!pEntry)
1060  {
1061  throw beans::UnknownPropertyException(
1062  "Unknown property: " + *pNames,
1063  static_cast<cppu::OWeakObject *>(this));
1064  }
1065 
1066  if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
1067  {
1068  *pStates = beans::PropertyState_DEFAULT_VALUE;
1069  }
1070  else
1071  {
1073  rTextNode, &pSet, *pEntry, bAttrSetFetched );
1074  }
1075  }
1076 
1077  return aRet;
1078 }
1079 
1080 void SAL_CALL
1081 SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
1082 {
1083  SolarMutexGuard aGuard;
1084 
1085  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1086 
1087  SwPosition aPos( rTextNode );
1088  SwCursor aCursor( aPos, nullptr );
1089  if (rPropertyName == UNO_NAME_ANCHOR_TYPE ||
1090  rPropertyName == UNO_NAME_ANCHOR_TYPES ||
1091  rPropertyName == UNO_NAME_TEXT_WRAP)
1092  {
1093  return;
1094  }
1095 
1096  // select paragraph
1097  SwParaSelection aParaSel( aCursor );
1098  SfxItemPropertyMapEntry const*const pEntry =
1099  m_pImpl->m_rPropSet.getPropertyMap().getByName( rPropertyName );
1100  if (!pEntry)
1101  {
1102  throw beans::UnknownPropertyException(
1103  "Unknown property: " + rPropertyName,
1104  static_cast<cppu::OWeakObject *>(this));
1105  }
1106 
1107  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1108  {
1109  throw uno::RuntimeException(
1110  "Property is read-only: " + rPropertyName,
1111  static_cast<cppu::OWeakObject *>(this));
1112  }
1113 
1114  const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1115  const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1116 
1117  if(bBelowFrameAtrEnd || bDrawingLayerRange)
1118  {
1120 
1121  // For FillBitmapMode two IDs have to be reset (!)
1122  if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
1123  {
1124  aWhichIds.insert(XATTR_FILLBMP_STRETCH);
1125  aWhichIds.insert(XATTR_FILLBMP_TILE);
1126  }
1127  else
1128  {
1129  aWhichIds.insert(pEntry->nWID);
1130  }
1131 
1132  if (pEntry->nWID < RES_PARATR_BEGIN)
1133  {
1134  aCursor.GetDoc().ResetAttrs(aCursor, true, aWhichIds);
1135  }
1136  else
1137  {
1138  // for paragraph attributes the selection must be extended
1139  // to paragraph boundaries
1140  SwPosition aStart( *aCursor.Start() );
1141  SwPosition aEnd ( *aCursor.End() );
1142  auto pTemp( aCursor.GetDoc().CreateUnoCursor(aStart) );
1144  {
1145  pTemp->MovePara(GoCurrPara, fnParaStart);
1146  }
1147 
1148  pTemp->SetMark();
1149  *pTemp->GetPoint() = aEnd;
1150 
1151  SwUnoCursorHelper::SelectPam(*pTemp, true);
1152 
1153  if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1154  {
1155  pTemp->MovePara(GoCurrPara, fnParaEnd);
1156  }
1157 
1158 
1159  pTemp->GetDoc().ResetAttrs(*pTemp, true, aWhichIds);
1160  }
1161  }
1162  else
1163  {
1165  }
1166 }
1167 
1168 uno::Any SAL_CALL
1169 SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
1170 {
1171  SolarMutexGuard g;
1172 
1173  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1174 
1175  uno::Any aRet;
1176  if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
1177  {
1178  return aRet;
1179  }
1180 
1181  SfxItemPropertyMapEntry const*const pEntry =
1182  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1183  if (!pEntry)
1184  {
1185  throw beans::UnknownPropertyException(
1186  "Unknown property: " + rPropertyName,
1187  static_cast<cppu::OWeakObject *>(this));
1188  }
1189 
1190  const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1191  const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1192 
1193  if(bBelowFrameAtrEnd || bDrawingLayerRange)
1194  {
1195  const SfxPoolItem& rDefItem = rTextNode.GetDoc().GetAttrPool().GetDefaultItem(pEntry->nWID);
1196 
1197  rDefItem.QueryValue(aRet, pEntry->nMemberId);
1198  }
1199 
1200  return aRet;
1201 }
1202 
1203 void SAL_CALL
1204 SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
1205 {
1206  SolarMutexGuard aGuard;
1207  // SwXParagraph will only created in order to be inserted by
1208  // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
1209  // they cannot be attached
1210  throw uno::RuntimeException();
1211 }
1212 
1213 uno::Reference< text::XTextRange > SAL_CALL
1215 {
1216  SolarMutexGuard aGuard;
1217 
1218  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1219 
1220  SwPosition aPos( rTextNode );
1221  SwCursor aCursor( aPos, nullptr );
1222  // select paragraph
1223  SwParaSelection aParaSel( aCursor );
1224  const uno::Reference< text::XTextRange > xRet =
1225  new SwXTextRange(aCursor, m_pImpl->m_xParentText);
1226  return xRet;
1227 }
1228 
1229 void SAL_CALL SwXParagraph::dispose()
1230 {
1231  SolarMutexGuard aGuard;
1232 
1233  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1234  if (pTextNode)
1235  {
1236  SwCursor aCursor( SwPosition( *pTextNode ), nullptr );
1237  pTextNode->GetDoc().getIDocumentContentOperations().DelFullPara(aCursor);
1238  lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
1239  std::unique_lock aGuard2(m_pImpl->m_Mutex);
1240  m_pImpl->m_EventListeners.disposeAndClear(aGuard2, ev);
1241  }
1242 }
1243 
1245  const uno::Reference< lang::XEventListener > & xListener)
1246 {
1247  // no need to lock here as m_pImpl is const and container threadsafe
1248  std::unique_lock aGuard(m_pImpl->m_Mutex);
1249  m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
1250 }
1251 
1253  const uno::Reference< lang::XEventListener > & xListener)
1254 {
1255  // no need to lock here as m_pImpl is const and container threadsafe
1256  std::unique_lock aGuard(m_pImpl->m_Mutex);
1257  m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
1258 }
1259 
1260 uno::Reference< container::XEnumeration > SAL_CALL
1262 {
1263  SolarMutexGuard aGuard;
1264 
1265  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1266 
1267  SwPosition aPos( rTextNode );
1268  SwPaM aPam ( aPos );
1269  const uno::Reference< container::XEnumeration > xRef =
1270  new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
1271  m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
1272  return xRef;
1273 }
1274 
1276 {
1278 }
1279 
1281 {
1282  SolarMutexGuard aGuard;
1283  return GetTextNode() != nullptr;
1284 }
1285 
1286 uno::Reference< text::XText > SAL_CALL
1288 {
1289  SolarMutexGuard g;
1290 
1291  return m_pImpl->m_xParentText;
1292 }
1293 
1294 uno::Reference< text::XTextRange > SAL_CALL
1296 {
1297  SolarMutexGuard aGuard;
1298 
1299  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1300 
1301  SwPosition aPos( rTextNode );
1302  SwCursor aCursor( aPos, nullptr );
1303  SwParaSelection aParaSel( aCursor );
1304  SwPaM aPam( *aCursor.Start() );
1305  uno::Reference< text::XText > xParent = getText();
1306  const uno::Reference< text::XTextRange > xRet =
1307  new SwXTextRange(aPam, xParent);
1308  return xRet;
1309 }
1310 
1311 uno::Reference< text::XTextRange > SAL_CALL
1313 {
1314  SolarMutexGuard aGuard;
1315 
1316  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1317 
1318  SwPosition aPos( rTextNode );
1319  SwCursor aCursor( aPos, nullptr );
1320  SwParaSelection aParaSel( aCursor );
1321  SwPaM aPam( *aCursor.End() );
1322  uno::Reference< text::XText > xParent = getText();
1323  const uno::Reference< text::XTextRange > xRet =
1324  new SwXTextRange(aPam, xParent);
1325  return xRet;
1326 }
1327 
1328 OUString SAL_CALL SwXParagraph::getString()
1329 {
1330  SolarMutexGuard aGuard;
1331  OUString aRet;
1332  SwTextNode const*const pTextNode( GetTextNode() );
1333  if (pTextNode)
1334  {
1335  SwPosition aPos( *pTextNode );
1336  SwCursor aCursor( aPos, nullptr );
1337  SwParaSelection aParaSel( aCursor );
1338  SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
1339  }
1340  else if (m_pImpl->IsDescriptor())
1341  {
1342  aRet = m_pImpl->m_sText;
1343  }
1344  else
1345  {
1346  // Seems object is being disposed or some other problem occurs.
1347  // Anyway from user point of view object still exist, so on that level this is not an error
1348  SAL_WARN("sw.uno", "getString() for invalid paragraph called. Returning empty string.");
1349  }
1350  return aRet;
1351 }
1352 
1353 void SAL_CALL SwXParagraph::setString(const OUString& aString)
1354 {
1355  SolarMutexGuard aGuard;
1356 
1357  SwTextNode const*const pTextNode( GetTextNode() );
1358  if (pTextNode)
1359  {
1360  SwPosition aPos( *pTextNode );
1361  SwCursor aCursor( aPos, nullptr );
1362  if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
1363  aCursor.MovePara(GoCurrPara, fnParaStart);
1364  }
1365  SwUnoCursorHelper::SelectPam(aCursor, true);
1366  if (pTextNode->GetText().getLength()) {
1367  aCursor.MovePara(GoCurrPara, fnParaEnd);
1368  }
1369  SwUnoCursorHelper::SetString(aCursor, aString);
1370  SwUnoCursorHelper::SelectPam(aCursor, false);
1371  }
1372  else if (m_pImpl->IsDescriptor())
1373  {
1374  m_pImpl->m_sText = aString;
1375  }
1376  else
1377  {
1378  throw uno::RuntimeException();
1379  }
1380 }
1381 
1382 uno::Reference< container::XEnumeration > SAL_CALL
1383 SwXParagraph::createContentEnumeration(const OUString& rServiceName)
1384 {
1385  SolarMutexGuard g;
1386 
1387  if ( rServiceName != "com.sun.star.text.TextContent" )
1388  {
1389  throw uno::RuntimeException();
1390  }
1391 
1392  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1393 
1394  SwPosition aPos( rTextNode );
1395  SwPaM aPam( aPos );
1396  uno::Reference< container::XEnumeration > xRet =
1398  return xRet;
1399 }
1400 
1401 uno::Sequence< OUString > SAL_CALL
1403 {
1404  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1405  return aRet;
1406 }
1407 
1408 // MetadatableMixin
1410 {
1411  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1412  return pTextNode;
1413 }
1414 
1415 uno::Reference<frame::XModel> SwXParagraph::GetModel()
1416 {
1417  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1418  if (pTextNode)
1419  {
1420  SwDocShell const*const pShell( pTextNode->GetDoc().GetDocShell() );
1421  return pShell ? pShell->GetModel() : nullptr;
1422  }
1423  return nullptr;
1424 }
1425 
1426 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2295
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
void GetSinglePropertyValue_Impl(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, uno::Any &rAny) const
#define MID_SURROUND_SURROUNDTYPE
Definition: unomid.h:29
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames) override
Marks a position in the document model.
Definition: pam.hxx:36
Result
void attachToText(SwXText &rParent, SwTextNode &rTextNode)
for SwXText
bool getCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
const OUString & GetText() const
Definition: ndtxt.hxx:218
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1014
Impl(SwXParagraph &rThis, SwTextNode *const pTextNode=nullptr, uno::Reference< text::XText > const &xParent=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)
std::unique_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack)
constexpr TypedWhichId< SfxMetricItem > XATTR_FILLBMP_SIZEX(XATTR_FILL_FIRST+9)
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
static css::uno::Reference< css::text::XTextContent > CreateXParagraph(SwDoc &rDoc, SwTextNode *pTextNode, css::uno::Reference< css::text::XText > const &xParentText=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)
virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
const SwPosition * GetMark() const
Definition: pam.hxx:210
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
uno::WeakReference< uno::XInterface > m_wThis
bool HasContinueList() const
Is it possible that this numbering has multiple lists?
Definition: number.cxx:1152
void getNumberingProperty(SwPaM &rPam, PropertyState &eState, Any *pAny)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::frame::XModel3 > GetModel() const
bool isATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:475
Definition: doc.hxx:187
constexpr sal_uInt16 RES_FRMATR_END(133)
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_EventListeners
virtual sal_Bool SAL_CALL hasElements() override
void SetPropertyValues(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< css::beans::PropertyValue > &rPropertyValues, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XTextContent > const & GetXParagraph() const
Definition: ndtxt.hxx:796
void resetCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam)
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
bool SelectPaM(SwPaM &rPaM)
make rPaM select the paragraph
SfxHintId GetId() const
#define UNO_NAME_TEXT_WRAP
Definition: unoprnms.hxx:316
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1657
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
virtual css::uno::Reference< css::frame::XModel > GetModel() override
sal_Int32 m_nSelectionEndPos
virtual OUString SAL_CALL getString() override
SwTextNode * m_pTextNode
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
#define FN_UNO_LIST_ID
Definition: cmdid.h:616
SwIndex nContent
Definition: pam.hxx:39
Any SAL_CALL getCaughtException()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const o3tl::sorted_vector< sal_uInt16 > &rAttrs=o3tl::sorted_vector< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:242
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:576
SwXParagraph & m_rThis
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual ::sfx2::Metadatable * GetCoreObject() override
::sw::UnoImplPtr< Impl > m_pImpl
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:128
#define FN_UNO_PARA_CONDITIONAL_STYLE_NAME
Definition: cmdid.h:572
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rValues) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:113
const css::uno::Sequence< sal_Int8 > & getSeq() const
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
uno::Sequence< uno::Any > GetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames)
css::uno::Type aType
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:528
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:457
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
bool IsEndOfPara(SwPaM &rUnoCursor)
#define MID_ANCHOR_ANCHORTYPE
Definition: unomid.h:43
#define TOOLS_WARN_EXCEPTION(area, stream)
int i
virtual void Notify(const SfxHint &rHint) override
const SwPosition * GetPoint() const
Definition: pam.hxx:208
virtual void SAL_CALL setString(const OUString &rString) override
SwTextNode * GetTextNode()
bool IsDescriptor() const
bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet &rSet, sal_uInt16 const nMID)
helper to check if fill style is set to color or bitmap and thus formerly used SvxBrushItem parts nee...
virtual ~SwXParagraph() override
bool IsStartOfPara(SwPaM &rUnoCursor)
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2833
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rValues) override
PropertyMoreFlags nMoreFlags
virtual OUString SAL_CALL getImplementationName() override
css::uno::Type const & get()
bool StartListening(SvtBroadcaster &rBroadcaster)
SfxItemPool * GetPool() const
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL dispose() override
const SwPosition * Start() const
Definition: pam.hxx:213
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
SwXParagraph()
descriptor
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:101
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
uno::Sequence< beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl(const uno::Sequence< OUString > &rPropertyNames, bool bDirectValuesOnly)
const PropertyValue * pValues
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
#define PROPERTY_MAP_PARAGRAPH
Definition: unomap.hxx:61
#define OWN_ATTR_FILLBMP_MODE
Definition: unomap.hxx:314
void SetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames, const uno::Sequence< uno::Any > &rValues)
#define FN_UNO_NUM_RULES
Definition: cmdid.h:534
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define UNO_NAME_ANCHOR_TYPE
Definition: unoprnms.hxx:228
constexpr TypedWhichId< XFillBmpStretchItem > XATTR_FILLBMP_STRETCH(XATTR_FILL_FIRST+16)
virtual css::uno::Type SAL_CALL getElementType() override
void SvxUnoConvertToMM(const MapUnit eSourceMapUnit, uno::Any &rMetric) noexcept
#define FN_UNO_ANCHOR_TYPE
Definition: cmdid.h:577
SwTextNode & GetTextNodeOrThrow()
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
const SwPosition * End() const
Definition: pam.hxx:218
bool IsDescriptor() const
constexpr TypedWhichId< XFillBmpTileItem > XATTR_FILLBMP_TILE(XATTR_FILL_FIRST+7)
const SwTextNode * GetTextNode() const
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
static rtl::Reference< SwXParaFrameEnumeration > Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1726
#define FN_UNO_ANCHOR_TYPES
Definition: cmdid.h:570
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:724
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:612
void GetCurPageStyle(SwPaM const &rPaM, OUString &rString)
SfxItemPropertySet const & m_rPropSet
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
#define UNO_NAME_ANCHOR_TYPES
Definition: unoprnms.hxx:229
MapUnit
#define SAL_WARN(area, stream)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
SwDoc & GetDoc() const
Definition: pam.hxx:244
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:476
sal_Int32 m_nSelectionStartPos
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
std::pair< const_iterator, bool > insert(Value &&x)
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
static beans::PropertyState lcl_SwXParagraph_getPropertyState(const SwTextNode &rTextNode, const SwAttrSet **ppSet, const SfxItemPropertyMapEntry &rEntry, bool &rAttrSetFetched)
SAL_DLLPRIVATE void SetXParagraph(css::uno::Reference< css::text::XTextContent > const &xParagraph)
Definition: ndtxt.hxx:798
constexpr TypedWhichId< XFillBmpSizeYItem > XATTR_FILLBMP_SIZEY(XATTR_FILL_FIRST+10)
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1235
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:527
uno::Reference< text::XText > m_xParentText
constexpr TypedWhichId< SfxStringItem > RES_PARATR_LIST_ID(RES_PARATR_LIST_BEGIN)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
sal_Int16 nValue