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