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