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