LibreOffice Module sw (master)  1
unodraw.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 <sal/config.h>
21 
22 #include <initializer_list>
23 #include <memory>
24 #include <sal/log.hxx>
25 
26 #include <cmdid.h>
27 #include <unomid.h>
28 
29 #include <drawdoc.hxx>
30 #include <unodraw.hxx>
31 #include <unoframe.hxx>
32 #include <unoparagraph.hxx>
33 #include <unotextrange.hxx>
34 #include <svx/svditer.hxx>
35 #include <swunohelper.hxx>
36 #include <textboxhelper.hxx>
37 #include <doc.hxx>
38 #include <IDocumentUndoRedo.hxx>
41 #include <fmtcntnt.hxx>
42 #include <fmtflcnt.hxx>
43 #include <txatbase.hxx>
44 #include <docsh.hxx>
45 #include <unomap.hxx>
46 #include <unoport.hxx>
47 #include <TextCursorHelper.hxx>
48 #include <dflyobj.hxx>
49 #include <ndtxt.hxx>
50 #include <svx/svdview.hxx>
51 #include <svx/unoshape.hxx>
52 #include <dcontact.hxx>
53 #include <fmtornt.hxx>
54 #include <fmtsrnd.hxx>
55 #include <fmtfollowtextflow.hxx>
56 #include <rootfrm.hxx>
57 #include <editeng/lrspitem.hxx>
58 #include <editeng/ulspitem.hxx>
59 #include <o3tl/any.hxx>
60 #include <o3tl/safeint.hxx>
62 #include <crstate.hxx>
63 #include <comphelper/extract.hxx>
65 #include <comphelper/sequence.hxx>
67 #include <svx/scene3d.hxx>
68 #include <com/sun/star/beans/PropertyAttribute.hpp>
69 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
70 #include <com/sun/star/frame/XModel.hpp>
72 #include <com/sun/star/text/TextContentAnchorType.hpp>
74 #include <com/sun/star/drawing/PointSequence.hpp>
75 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
76 
77 using namespace ::com::sun::star;
78 
80 {
82  std::unique_ptr<SwFormatHoriOrient> m_pHOrient;
83  std::unique_ptr<SwFormatVertOrient> m_pVOrient;
84  std::unique_ptr<SwFormatAnchor> m_pAnchor;
85  std::unique_ptr<SwFormatSurround> m_pSurround;
86  std::unique_ptr<SvxULSpaceItem> m_pULSpace;
87  std::unique_ptr<SvxLRSpaceItem> m_pLRSpace;
88  bool bOpaque;
89  uno::Reference< text::XTextRange > xTextRange;
90  // #i26791#
91  std::unique_ptr<SwFormatFollowTextFlow> m_pFollowTextFlow;
92  // #i28701#
93  std::unique_ptr<SwFormatWrapInfluenceOnObjPos> m_pWrapInfluenceOnObjPos;
94  // #i28749#
96 
99 
100 public:
102 
103 public:
104  SwShapeDescriptor_Impl(SwDoc const*const pDoc)
105  : m_isInReading(pDoc && pDoc->IsInReading())
106  // #i32349# - no defaults, in order to determine on
107  // adding a shape, if positioning attributes are set or not.
108  , bOpaque(false)
109  // #i26791#
110  , m_pFollowTextFlow( new SwFormatFollowTextFlow(false) )
111  // #i28701# #i35017#
112  , m_pWrapInfluenceOnObjPos( new SwFormatWrapInfluenceOnObjPos(
113  text::WrapInfluenceOnPosition::ONCE_CONCURRENT) )
114  // #i28749#
115  , mnPositionLayoutDir(text::PositionLayoutDir::PositionInLayoutDirOfAnchor)
116  , bInitializedPropertyNotifier(false)
117  {}
118 
119  SwFormatAnchor* GetAnchor(bool bCreate = false)
120  {
121  if (bCreate && !m_pAnchor)
122  {
123  m_pAnchor.reset(new SwFormatAnchor(RndStdIds::FLY_AS_CHAR));
124  }
125  return m_pAnchor.get();
126  }
127  SwFormatHoriOrient* GetHOrient(bool bCreate = false)
128  {
129  if (bCreate && !m_pHOrient)
130  {
131  // #i26791#
132  m_pHOrient.reset(new SwFormatHoriOrient(0, text::HoriOrientation::NONE, text::RelOrientation::FRAME));
133  }
134  return m_pHOrient.get();
135  }
136  SwFormatVertOrient* GetVOrient(bool bCreate = false)
137  {
138  if (bCreate && !m_pVOrient)
139  {
140  if (m_isInReading && // tdf#113938 extensions might rely on old default
141  (!GetAnchor(true) || m_pAnchor->GetAnchorId() == RndStdIds::FLY_AS_CHAR))
142  { // for as-char, NONE ("from-top") is not a good default
143  m_pVOrient.reset(new SwFormatVertOrient(0, text::VertOrientation::TOP, text::RelOrientation::FRAME));
144  }
145  else
146  { // #i26791#
147  m_pVOrient.reset(new SwFormatVertOrient(0, text::VertOrientation::NONE, text::RelOrientation::FRAME));
148  }
149  }
150  return m_pVOrient.get();
151  }
152 
153  SwFormatSurround* GetSurround(bool bCreate = false)
154  {
155  if (bCreate && !m_pSurround)
156  {
157  m_pSurround.reset(new SwFormatSurround());
158  }
159  return m_pSurround.get();
160  }
161  SvxLRSpaceItem* GetLRSpace(bool bCreate = false)
162  {
163  if (bCreate && !m_pLRSpace)
164  {
165  m_pLRSpace.reset(new SvxLRSpaceItem(RES_LR_SPACE));
166  }
167  return m_pLRSpace.get();
168  }
169  SvxULSpaceItem* GetULSpace(bool bCreate = false)
170  {
171  if (bCreate && !m_pULSpace)
172  {
173  m_pULSpace.reset(new SvxULSpaceItem(RES_UL_SPACE));
174  }
175  return m_pULSpace.get();
176  }
177  uno::Reference< text::XTextRange > & GetTextRange()
178  {
179  return xTextRange;
180  }
181  bool IsOpaque() const
182  {
183  return bOpaque;
184  }
185  const bool& GetOpaque() const
186  {
187  return bOpaque;
188  }
189  void RemoveHOrient() { m_pHOrient.reset(); }
190  void RemoveVOrient() { m_pVOrient.reset(); }
191  void RemoveAnchor() { m_pAnchor.reset(); }
192  void RemoveSurround() { m_pSurround.reset(); }
193  void RemoveULSpace() { m_pULSpace.reset(); }
194  void RemoveLRSpace() { m_pLRSpace.reset(); }
195  void SetOpaque(bool bSet){bOpaque = bSet;}
196 
197  // #i26791#
198  SwFormatFollowTextFlow* GetFollowTextFlow( bool _bCreate = false )
199  {
200  if (_bCreate && !m_pFollowTextFlow)
201  {
202  m_pFollowTextFlow.reset(new SwFormatFollowTextFlow(false));
203  }
204  return m_pFollowTextFlow.get();
205  }
207  {
208  m_pFollowTextFlow.reset();
209  }
210 
211  // #i28749#
212  sal_Int16 GetPositionLayoutDir() const
213  {
214  return mnPositionLayoutDir;
215  }
216  void SetPositionLayoutDir( sal_Int16 _nPositionLayoutDir )
217  {
218  switch ( _nPositionLayoutDir )
219  {
220  case text::PositionLayoutDir::PositionInHoriL2R:
221  case text::PositionLayoutDir::PositionInLayoutDirOfAnchor:
222  {
223  mnPositionLayoutDir = _nPositionLayoutDir;
224  }
225  break;
226  default:
227  {
228  OSL_FAIL( "<SwShapeDescriptor_Impl::SetPositionLayoutDir(..)> - invalid attribute value." );
229  }
230  }
231  }
232 
233  // #i28701#
235  const bool _bCreate = false )
236  {
237  if (_bCreate && !m_pWrapInfluenceOnObjPos)
238  {
239  m_pWrapInfluenceOnObjPos.reset(new SwFormatWrapInfluenceOnObjPos(
240  // #i35017#
241  text::WrapInfluenceOnPosition::ONCE_CONCURRENT));
242  }
243  return m_pWrapInfluenceOnObjPos.get();
244  }
246  {
247  m_pWrapInfluenceOnObjPos.reset();
248  }
249 };
250 
252  SvxFmDrawPage( pPage ), pPageView(nullptr)
253 {
254 }
255 
257 {
258  while (!m_vShapes.empty())
259  m_vShapes.back()->dispose();
260  RemovePageView();
261 }
262 
263 const SdrMarkList& SwFmDrawPage::PreGroup(const uno::Reference< drawing::XShapes > & xShapes)
264 {
265  SelectObjectsInView( xShapes, GetPageView() );
266  const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
267  return rMarkList;
268 }
269 
270 void SwFmDrawPage::PreUnGroup(const uno::Reference< drawing::XShapeGroup >& rShapeGroup)
271 {
272  SelectObjectInView( rShapeGroup, GetPageView() );
273 }
274 
276 {
277  if(!pPageView)
278  pPageView = mpView->ShowSdrPage( mpPage );
279  return pPageView;
280 }
281 
283 {
284  if(pPageView && mpView)
285  mpView->HideSdrPage();
286  pPageView = nullptr;
287 }
288 
289 uno::Reference<drawing::XShape> SwFmDrawPage::GetShape(SdrObject* pObj)
290 {
291  if(!pObj)
292  return nullptr;
293  SwFrameFormat* pFormat = ::FindFrameFormat( pObj );
294  SwFmDrawPage* pPage = dynamic_cast<SwFmDrawPage*>(pFormat);
295  if(!pPage || pPage->m_vShapes.empty())
296  return uno::Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY);
297  for(auto pShape : pPage->m_vShapes)
298  {
299  SvxShape* pSvxShape = pShape->GetSvxShape();
300  if (pSvxShape && pSvxShape->GetSdrObject() == pObj)
301  return uno::Reference<drawing::XShape>(static_cast<::cppu::OWeakObject*>(pShape), uno::UNO_QUERY);
302  }
303  return nullptr;
304 }
305 
306 uno::Reference<drawing::XShapeGroup> SwFmDrawPage::GetShapeGroup(SdrObject* pObj)
307 {
308  return uno::Reference<drawing::XShapeGroup>(GetShape(pObj), uno::UNO_QUERY);
309 }
310 
311 uno::Reference< drawing::XShape > SwFmDrawPage::CreateShape( SdrObject *pObj ) const
312 {
313  uno::Reference< drawing::XShape > xRet;
314  if(dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr || pObj->GetObjInventor() == SdrInventor::Swg)
315  {
316  SwFlyDrawContact* pFlyContact = static_cast<SwFlyDrawContact*>(pObj->GetUserCall());
317  if(pFlyContact)
318  {
319  SwFrameFormat* pFlyFormat = pFlyContact->GetFormat();
320  SwDoc* pDoc = pFlyFormat->GetDoc();
321  const SwNodeIndex* pIdx;
322  if( RES_FLYFRMFMT == pFlyFormat->Which()
323  && nullptr != ( pIdx = pFlyFormat->GetContent().GetContentIdx() )
324  && pIdx->GetNodes().IsDocNodes()
325  )
326  {
327  const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ];
328  if(!pNd->IsNoTextNode())
329  {
330  xRet.set(SwXTextFrame::CreateXTextFrame(*pDoc, pFlyFormat),
331  uno::UNO_QUERY);
332  }
333  else if( pNd->IsGrfNode() )
334  {
336  *pDoc, pFlyFormat), uno::UNO_QUERY);
337  }
338  else if( pNd->IsOLENode() )
339  {
341  *pDoc, pFlyFormat), uno::UNO_QUERY);
342  }
343  }
344  else
345  {
346  OSL_FAIL( "<SwFmDrawPage::CreateShape(..)> - could not retrieve type. Thus, no shape created." );
347  return xRet;
348  }
349  }
350  }
351  else
352  {
353  // own block - temporary object has to be destroyed before
354  // the delegator is set #81670#
355  {
356  xRet = SvxFmDrawPage::CreateShape( pObj );
357  }
358  uno::Reference< XUnoTunnel > xShapeTunnel(xRet, uno::UNO_QUERY);
359  //don't create an SwXShape if it already exists
360  SwXShape* pShape = nullptr;
361  if(xShapeTunnel.is())
362  pShape = reinterpret_cast< SwXShape * >(
363  sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
364  if(!pShape)
365  {
366  xShapeTunnel = nullptr;
367  uno::Reference< uno::XInterface > xCreate(xRet, uno::UNO_QUERY);
368  xRet = nullptr;
369  if ( pObj->IsGroupObject() && (!pObj->Is3DObj() || (dynamic_cast<const E3dScene*>( pObj) != nullptr)) )
370  pShape = new SwXGroupShape(xCreate, nullptr);
371  else
372  pShape = new SwXShape(xCreate, nullptr);
373  uno::Reference<beans::XPropertySet> xPrSet = pShape;
374  xRet.set(xPrSet, uno::UNO_QUERY);
375  }
376  const_cast<std::vector<SwXShape*>*>(&m_vShapes)->push_back(pShape);
377  pShape->m_pPage = this;
378  }
379  return xRet;
380 }
381 
382 namespace
383 {
384  class SwXShapesEnumeration
385  : public SwSimpleEnumeration_Base
386  {
387  private:
388  std::vector< css::uno::Any > m_aShapes;
389  protected:
390  virtual ~SwXShapesEnumeration() override {};
391  public:
392  explicit SwXShapesEnumeration(SwXDrawPage* const pDrawPage);
393 
394  //XEnumeration
395  virtual sal_Bool SAL_CALL hasMoreElements() override;
396  virtual uno::Any SAL_CALL nextElement() override;
397 
398  //XServiceInfo
399  virtual OUString SAL_CALL getImplementationName() override;
400  virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
401  virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
402  };
403 }
404 
405 SwXShapesEnumeration::SwXShapesEnumeration(SwXDrawPage* const pDrawPage)
406  : m_aShapes()
407 {
408  SolarMutexGuard aGuard;
409  sal_Int32 nCount = pDrawPage->getCount();
410  m_aShapes.reserve(nCount);
411  for(sal_Int32 nIdx = 0; nIdx < nCount; nIdx++)
412  {
413  uno::Reference<drawing::XShape> xShape(pDrawPage->getByIndex(nIdx), uno::UNO_QUERY);
414  m_aShapes.push_back(uno::makeAny(xShape));
415  }
416 }
417 
418 sal_Bool SwXShapesEnumeration::hasMoreElements()
419 {
420  SolarMutexGuard aGuard;
421  return !m_aShapes.empty();
422 }
423 
424 uno::Any SwXShapesEnumeration::nextElement()
425 {
426  SolarMutexGuard aGuard;
427  if(m_aShapes.empty())
428  throw container::NoSuchElementException();
429  uno::Any aResult = m_aShapes.back();
430  m_aShapes.pop_back();
431  return aResult;
432 }
433 
434 OUString SwXShapesEnumeration::getImplementationName()
435 {
436  return "SwXShapeEnumeration";
437 }
438 
439 sal_Bool SwXShapesEnumeration::supportsService(const OUString& ServiceName)
440 {
441  return cppu::supportsService(this, ServiceName);
442 }
443 
444 uno::Sequence< OUString > SwXShapesEnumeration::getSupportedServiceNames()
445 {
446  return { OUString("com.sun.star.container.XEnumeration") };
447 }
448 
449 uno::Reference< container::XEnumeration > SwXDrawPage::createEnumeration()
450 {
451  SolarMutexGuard aGuard;
452  return uno::Reference< container::XEnumeration >(
453  new SwXShapesEnumeration(this));
454 }
455 
457 {
458  return "SwXDrawPage";
459 }
460 
461 sal_Bool SwXDrawPage::supportsService(const OUString& rServiceName)
462 {
463  return cppu::supportsService(this, rServiceName);
464 }
465 
466 uno::Sequence< OUString > SwXDrawPage::getSupportedServiceNames()
467 {
468  return { "com.sun.star.drawing.GenericDrawPage" };
469 }
470 
472  pDoc(pDc),
473  pDrawPage(nullptr)
474 {
475 }
476 
478 {
479  if(xPageAgg.is())
480  {
481  uno::Reference< uno::XInterface > xInt;
482  xPageAgg->setDelegator(xInt);
483  }
484 }
485 
487 {
489  if(!aRet.hasValue())
490  {
491  // secure with checking if page exists. This may not be the case
492  // either for new SW docs with no yet graphics usage or when
493  // the doc is closed and someone else still holds a UNO reference
494  // to the XDrawPage (in that case, pDoc is set to 0)
495  SwFmDrawPage* pPage = GetSvxPage();
496 
497  if(pPage)
498  {
499  aRet = pPage->queryAggregation(aType);
500  }
501  }
502  return aRet;
503 }
504 
505 uno::Sequence< uno::Type > SwXDrawPage::getTypes()
506 {
509  GetSvxPage()->getTypes(),
510  uno::Sequence { cppu::UnoType<form::XFormsSupplier2>::get() });
511 }
512 
514 {
515  SolarMutexGuard aGuard;
516  if(!pDoc)
517  throw uno::RuntimeException();
519  return 0;
520  else
521  {
522  GetSvxPage();
523  return SwTextBoxHelper::getCount(pDrawPage->GetSdrPage());
524  }
525 }
526 
528 {
529  SolarMutexGuard aGuard;
530  if(!pDoc)
531  throw uno::RuntimeException();
533  throw lang::IndexOutOfBoundsException();
534 
535  GetSvxPage();
536  return SwTextBoxHelper::getByIndex(pDrawPage->GetSdrPage(), nIndex);
537 }
538 
540 {
542 }
543 
545 {
546  SolarMutexGuard aGuard;
547  if(!pDoc)
548  throw uno::RuntimeException();
550  return false;
551  else
552  return GetSvxPage()->hasElements();
553 }
554 
555 void SwXDrawPage::add(const uno::Reference< drawing::XShape > & xShape)
556 {
557  SolarMutexGuard aGuard;
558  if(!pDoc)
559  throw uno::RuntimeException();
560  uno::Reference< lang::XUnoTunnel > xShapeTunnel(xShape, uno::UNO_QUERY);
561  SwXShape* pShape = nullptr;
562  SvxShape* pSvxShape = nullptr;
563  if(xShapeTunnel.is())
564  {
565  pShape = reinterpret_cast< SwXShape * >(
566  sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
567  pSvxShape = reinterpret_cast< SvxShape * >(
568  sal::static_int_cast< sal_IntPtr >( xShapeTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
569  }
570 
571  // this is not a writer shape
572  if(!pShape)
573  throw uno::RuntimeException("illegal object",
574  static_cast< cppu::OWeakObject * > ( this ) );
575 
576  // we're already registered in the model / SwXDrawPage::add() already called
577  if(pShape->m_pPage || pShape->m_pFormat || !pShape->m_bDescriptor )
578  return;
579 
580  // we're inserted elsewhere already
581  if ( pSvxShape->GetSdrObject() )
582  {
583  if ( pSvxShape->GetSdrObject()->IsInserted() )
584  {
585  return;
586  }
587  }
588  GetSvxPage()->add(xShape);
589 
590  OSL_ENSURE(pSvxShape, "Why is here no SvxShape?");
591  // this position is definitely in 1/100 mm
592  awt::Point aMM100Pos(pSvxShape->getPosition());
593 
594  // now evaluate the properties of SwShapeDescriptor_Impl
596 
598  RES_FRMATR_END-1>{} );
599  SwFormatAnchor aAnchor( RndStdIds::FLY_AS_CHAR );
600  bool bOpaque = false;
601  if( pDesc )
602  {
603  if(pDesc->GetSurround())
604  aSet.Put( *pDesc->GetSurround());
605  // all items are already in Twip
606  if(pDesc->GetLRSpace())
607  {
608  aSet.Put(*pDesc->GetLRSpace());
609  }
610  if(pDesc->GetULSpace())
611  {
612  aSet.Put(*pDesc->GetULSpace());
613  }
614  if(pDesc->GetAnchor())
615  aAnchor = *pDesc->GetAnchor();
616 
617  // #i32349# - if no horizontal position exists, create one
618  if ( !pDesc->GetHOrient() )
619  {
620  SwFormatHoriOrient* pHori = pDesc->GetHOrient( true );
621  SwTwips nHoriPos = convertMm100ToTwip(aMM100Pos.X);
622  pHori->SetPos( nHoriPos );
623  }
624  {
625  if(pDesc->GetHOrient()->GetHoriOrient() == text::HoriOrientation::NONE)
626  aMM100Pos.X = convertTwipToMm100(pDesc->GetHOrient()->GetPos());
627  aSet.Put( *pDesc->GetHOrient() );
628  }
629  // #i32349# - if no vertical position exists, create one
630  if ( !pDesc->GetVOrient() )
631  {
632  SwFormatVertOrient* pVert = pDesc->GetVOrient( true );
633  SwTwips nVertPos = convertMm100ToTwip(aMM100Pos.Y);
634  pVert->SetPos( nVertPos );
635  }
636  {
637  if(pDesc->GetVOrient()->GetVertOrient() == text::VertOrientation::NONE)
638  aMM100Pos.Y = convertTwipToMm100(pDesc->GetVOrient()->GetPos());
639  aSet.Put( *pDesc->GetVOrient() );
640  }
641 
642  if(pDesc->GetSurround())
643  aSet.Put( *pDesc->GetSurround());
644  bOpaque = pDesc->IsOpaque();
645 
646  // #i26791#
647  if ( pDesc->GetFollowTextFlow() )
648  {
649  aSet.Put( *pDesc->GetFollowTextFlow() );
650  }
651 
652  // #i28701#
653  if ( pDesc->GetWrapInfluenceOnObjPos() )
654  {
655  aSet.Put( *pDesc->GetWrapInfluenceOnObjPos() );
656  }
657  }
658 
659  pSvxShape->setPosition(aMM100Pos);
660  SdrObject* pObj = pSvxShape->GetSdrObject();
661  // #108784# - set layer of new drawing object to corresponding
662  // invisible layer.
663  if(SdrInventor::FmForm != pObj->GetObjInventor())
665  else
667 
668  std::unique_ptr<SwPaM> pPam(new SwPaM(pDoc->GetNodes().GetEndOfContent()));
669  std::unique_ptr<SwUnoInternalPaM> pInternalPam;
670  uno::Reference< text::XTextRange > xRg;
671  if( pDesc && (xRg = pDesc->GetTextRange()).is() )
672  {
673  pInternalPam.reset(new SwUnoInternalPaM(*pDoc));
674  if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg))
675  throw uno::RuntimeException();
676 
677  if(RndStdIds::FLY_AT_FLY == aAnchor.GetAnchorId() &&
678  !pInternalPam->GetNode().FindFlyStartNode())
679  {
680  aAnchor.SetType(RndStdIds::FLY_AS_CHAR);
681  }
682  else if (RndStdIds::FLY_AT_PAGE == aAnchor.GetAnchorId())
683  {
684  aAnchor.SetAnchor(pInternalPam->Start());
685  }
686 
687  }
688  else if ((aAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) && pDoc->getIDocumentLayoutAccess().GetCurrentLayout())
689  {
691  Point aTmp(convertMm100ToTwip(aMM100Pos.X), convertMm100ToTwip(aMM100Pos.Y));
692  pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( pPam->GetPoint(), aTmp, &aState );
693  aAnchor.SetAnchor( pPam->GetPoint() );
694 
695  // #i32349# - adjustment of vertical positioning
696  // attributes no longer needed, because it's already got a default.
697  }
698  else
699  {
700  aAnchor.SetType(RndStdIds::FLY_AT_PAGE);
701 
702  // #i32349# - adjustment of vertical positioning
703  // attributes no longer needed, because it's already got a default.
704  }
705  aSet.Put(aAnchor);
706  SwPaM* pTemp = pInternalPam.get();
707  if ( !pTemp )
708  pTemp = pPam.get();
709  UnoActionContext aAction(pDoc);
710  pDoc->getIDocumentContentOperations().InsertDrawObj( *pTemp, *pObj, aSet );
711  SwFrameFormat* pFormat = ::FindFrameFormat( pObj );
712  if (pFormat)
713  {
714  if (pFormat->GetName().isEmpty())
715  {
716  if (pSvxShape->GetSdrObject()->GetName().isEmpty())
717  {
718  pFormat->SetName(pDoc->GetUniqueShapeName(), false);
719  }
720  else
721  {
722  pFormat->SetName(pSvxShape->GetSdrObject()->GetName(), false);
723  }
724  }
725  pShape->SetFrameFormat(pFormat);
726  }
727  pShape->m_bDescriptor = false;
728 
729  pPam.reset();
730  pInternalPam.reset();
731 }
732 
733 void SwXDrawPage::remove(const uno::Reference< drawing::XShape > & xShape)
734 {
735  SolarMutexGuard aGuard;
736  if(!pDoc)
737  throw uno::RuntimeException();
738  uno::Reference<lang::XComponent> xComp(xShape, uno::UNO_QUERY);
739  xComp->dispose();
740 }
741 
742 uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< drawing::XShapes > & xShapes)
743 {
744  SolarMutexGuard aGuard;
745  if(!pDoc || !xShapes.is())
746  throw uno::RuntimeException();
747  uno::Reference< drawing::XShapeGroup > xRet;
748  if(xPageAgg.is())
749  {
750 
751  SwFmDrawPage* pPage = GetSvxPage();
752  if(pPage) //TODO: can this be Null?
753  {
754  // mark and return MarkList
755  const SdrMarkList& rMarkList = pPage->PreGroup(xShapes);
756  if ( rMarkList.GetMarkCount() > 1 )
757  {
758  for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i)
759  {
760  const SdrObject *pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
761  if (RndStdIds::FLY_AS_CHAR == ::FindFrameFormat(const_cast<SdrObject*>(
762  pObj))->GetAnchor().GetAnchorId())
763  {
764  throw uno::RuntimeException(); // FlyInCnt!
765  }
766  }
767 
768  UnoActionContext aContext(pDoc);
770 
771  SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() );
772  pDoc->ChgAnchor(
773  pPage->GetDrawView()->GetMarkedObjectList(),
774  RndStdIds::FLY_AT_PARA,
775  true, false );
776 
777  pPage->GetDrawView()->UnmarkAll();
778  if(pContact)
779  xRet = SwFmDrawPage::GetShapeGroup( pContact->GetMaster() );
781  }
782  pPage->RemovePageView();
783  }
784  }
785  return xRet;
786 }
787 
788 void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & rShapeGroup)
789 {
790  SolarMutexGuard aGuard;
791  if(!pDoc)
792  throw uno::RuntimeException();
793  if(xPageAgg.is())
794  {
795  SwFmDrawPage* pPage = GetSvxPage();
796  if(pPage) //TODO: can this be Null?
797  {
798  pPage->PreUnGroup(rShapeGroup);
799  UnoActionContext aContext(pDoc);
801 
802  pDoc->UnGroupSelection( *pPage->GetDrawView() );
804  RndStdIds::FLY_AT_PARA,
805  true, false );
807  pPage->RemovePageView();
808  }
809  }
810 }
811 
813 {
814  if(!xPageAgg.is() && pDoc)
815  {
816  SolarMutexGuard aGuard;
817  // #i52858#
819  SdrPage* pPage = pModel->GetPage( 0 );
820 
821  {
822  // We need a Ref to the object during queryInterface or else
823  // it will be deleted
824  pDrawPage = new SwFmDrawPage(pPage);
825  uno::Reference< drawing::XDrawPage > xPage = pDrawPage;
826  uno::Any aAgg = xPage->queryInterface(cppu::UnoType<uno::XAggregation>::get());
827  aAgg >>= xPageAgg;
828  }
829  if( xPageAgg.is() )
830  xPageAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
831  }
832  return pDrawPage;
833 }
834 
839 {
840  pDoc = nullptr;
841 }
842 
843 namespace
844 {
845  class theSwXShapeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXShapeUnoTunnelId > {};
846 }
847 
848 const uno::Sequence< sal_Int8 > & SwXShape::getUnoTunnelId()
849 {
850  return theSwXShapeUnoTunnelId::get().getSeq();
851 }
852 
853 sal_Int64 SAL_CALL SwXShape::getSomething( const uno::Sequence< sal_Int8 >& rId )
854 {
855  if( isUnoTunnelId<SwXShape>(rId) )
856  {
857  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
858  }
859 
860  if( xShapeAgg.is() )
861  {
862  const uno::Type& rTunnelType = cppu::UnoType<lang::XUnoTunnel>::get();
863  uno::Any aAgg = xShapeAgg->queryAggregation( rTunnelType );
864  if(auto xAggTunnel = o3tl::tryAccess<uno::Reference<lang::XUnoTunnel>>(
865  aAgg))
866  {
867  if(xAggTunnel->is())
868  return (*xAggTunnel)->getSomething(rId);
869  }
870  }
871  return 0;
872 }
873 namespace
874 {
875  void lcl_addShapePropertyEventFactories( SdrObject& _rObj, SwXShape& _rShape )
876  {
877  auto pProvider = std::make_shared<svx::PropertyValueProvider>( _rShape, "AnchorType" );
879  }
880 }
881 
883  uno::Reference<uno::XInterface> & xShape,
884  SwDoc const*const pDoc)
885  : m_pPage(nullptr)
886  , m_pFormat(nullptr)
887  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_SHAPE))
888  , m_pPropertyMapEntries(aSwMapProvider.GetPropertyMapEntries(PROPERTY_MAP_TEXT_SHAPE))
889  , pImpl(new SwShapeDescriptor_Impl(pDoc))
890  , m_bDescriptor(true)
891 {
892  if(!xShape.is()) // default Ctor
893  return;
894 
896  //aAgg contains a reference of the SvxShape!
897  {
898  uno::Any aAgg = xShape->queryInterface(rAggType);
899  aAgg >>= xShapeAgg;
900  // #i31698#
901  if ( xShapeAgg.is() )
902  {
903  xShapeAgg->queryAggregation( cppu::UnoType<drawing::XShape>::get()) >>= mxShape;
904  OSL_ENSURE( mxShape.is(),
905  "<SwXShape::SwXShape(..)> - no XShape found at <xShapeAgg>" );
906  }
907  }
908  xShape = nullptr;
909  osl_atomic_increment(&m_refCount);
910  if( xShapeAgg.is() )
911  xShapeAgg->setDelegator( static_cast<cppu::OWeakObject*>(this) );
912  osl_atomic_decrement(&m_refCount);
913 
914  SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>(xShapeAgg);
915 
916  SdrObject* pObj = pShape ? pShape->GetSdrObject() : nullptr;
917  if(pObj)
918  {
919  auto pFormat = ::FindFrameFormat( pObj );
920  if(pFormat)
921  SetFrameFormat(pFormat);
922 
923  lcl_addShapePropertyEventFactories( *pObj, *this );
924  pImpl->bInitializedPropertyNotifier = true;
925  }
926 
927 }
928 
930 {
931  SdrObjListIter aIter( _rObj, SdrIterMode::DeepNoGroups );
932  while ( aIter.IsMore() )
933  {
934  SdrObject* pCurrent = aIter.Next();
935  OSL_ENSURE( pCurrent, "SwXShape::AddExistingShapeToFormat: invalid object list element!" );
936  if ( !pCurrent )
937  continue;
938 
939  auto pSwShape = comphelper::getUnoTunnelImplementation<SwXShape>(pCurrent->getWeakUnoShape());
940  if ( pSwShape )
941  {
942  if ( pSwShape->m_bDescriptor )
943  {
944  auto pFormat = ::FindFrameFormat( pCurrent );
945  if ( pFormat )
946  pSwShape->SetFrameFormat(pFormat);
947  pSwShape->m_bDescriptor = false;
948  }
949 
950  if ( !pSwShape->pImpl->bInitializedPropertyNotifier )
951  {
952  lcl_addShapePropertyEventFactories( *pCurrent, *pSwShape );
953  pSwShape->pImpl->bInitializedPropertyNotifier = true;
954  }
955  }
956  }
957 }
958 
960 {
961  SolarMutexGuard aGuard;
962  if (xShapeAgg.is())
963  {
964  uno::Reference< uno::XInterface > xRef;
965  xShapeAgg->setDelegator(xRef);
966  }
967  pImpl.reset();
968  EndListeningAll();
969  if(m_pPage)
970  const_cast<SwFmDrawPage*>(m_pPage)->RemoveShape(this);
971  m_pPage = nullptr;
972 }
973 
975 {
977  if (aRet.hasValue())
978  return aRet;
979 
980  aRet = SwXShapeBaseClass::queryInterface(aType);
981  // #i53320# - follow-up of #i31698#
982  // interface drawing::XShape is overloaded. Thus, provide
983  // correct object instance.
984  if(!aRet.hasValue() && xShapeAgg.is())
985  {
986  if(aType == cppu::UnoType<XShape>::get())
987  aRet <<= uno::Reference<XShape>(this);
988  else
989  aRet = xShapeAgg->queryAggregation(aType);
990  }
991  return aRet;
992 }
993 
994 uno::Sequence< uno::Type > SwXShape::getTypes( )
995 {
996  uno::Sequence< uno::Type > aRet = SwXShapeBaseClass::getTypes();
997  if(xShapeAgg.is())
998  {
999  uno::Any aProv = xShapeAgg->queryAggregation(cppu::UnoType<XTypeProvider>::get());
1000  if(aProv.hasValue())
1001  {
1002  uno::Reference< XTypeProvider > xAggProv;
1003  aProv >>= xAggProv;
1004  return comphelper::concatSequences(aRet, xAggProv->getTypes());
1005  }
1006  }
1007  return aRet;
1008 }
1009 
1010 uno::Sequence< sal_Int8 > SwXShape::getImplementationId( )
1011 {
1012  return css::uno::Sequence<sal_Int8>();
1013 }
1014 
1015 uno::Reference< beans::XPropertySetInfo > SwXShape::getPropertySetInfo()
1016 {
1017  SolarMutexGuard aGuard;
1018  uno::Reference< beans::XPropertySetInfo > aRet;
1019  if(xShapeAgg.is())
1020  {
1021  const uno::Type& rPropSetType = cppu::UnoType<beans::XPropertySet>::get();
1022  uno::Any aPSet = xShapeAgg->queryAggregation( rPropSetType );
1023  if(auto xPrSet = o3tl::tryAccess<uno::Reference<beans::XPropertySet>>(
1024  aPSet))
1025  {
1026  uno::Reference< beans::XPropertySetInfo > xInfo = (*xPrSet)->getPropertySetInfo();
1027  // Expand PropertySetInfo!
1028  const uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
1029  aRet = new SfxExtItemPropertySetInfo( m_pPropertyMapEntries, aPropSeq );
1030  }
1031  }
1032  if(!aRet.is())
1033  aRet = m_pPropSet->getPropertySetInfo();
1034  return aRet;
1035 }
1036 
1037 void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1038 {
1039  SolarMutexGuard aGuard;
1040  SwFrameFormat* pFormat = GetFrameFormat();
1041  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1042  if(xShapeAgg.is())
1043  {
1044  if(pEntry)
1045  {
1046  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1047  throw beans::PropertyVetoException ("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1048  // with the layout it is possible to move the anchor without changing the position
1049  if(pFormat)
1050  {
1051  SwAttrSet aSet(pFormat->GetAttrSet());
1052  SwDoc* pDoc = pFormat->GetDoc();
1053  if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId)
1054  {
1055  bool bDone = false;
1056  uno::Reference<text::XTextFrame> xFrame;
1057  if(aValue >>= xFrame)
1058  {
1059  SwXFrame* pFrame = comphelper::getUnoTunnelImplementation<SwXFrame>(xFrame);
1060  if(pFrame && pFrame->GetFrameFormat() &&
1061  pFrame->GetFrameFormat()->GetDoc() == pDoc)
1062  {
1063  UnoActionContext aCtx(pDoc);
1064  SfxItemSet aItemSet( pDoc->GetAttrPool(),
1066  aItemSet.SetParent(&pFormat->GetAttrSet());
1067  SwFormatAnchor aAnchor = static_cast<const SwFormatAnchor&>(aItemSet.Get(pEntry->nWID));
1068  SwPosition aPos(*pFrame->GetFrameFormat()->GetContent().GetContentIdx());
1069  aAnchor.SetAnchor(&aPos);
1070  aAnchor.SetType(RndStdIds::FLY_AT_FLY);
1071  aItemSet.Put(aAnchor);
1072  pFormat->SetFormatAttr(aItemSet);
1073  bDone = true;
1074  }
1075  }
1076  if(!bDone)
1077  throw lang::IllegalArgumentException();
1078  }
1079  else if(RES_OPAQUE == pEntry->nWID)
1080  {
1081  SvxShape* pSvxShape = GetSvxShape();
1082  SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
1083  if(pSvxShape)
1084  {
1085  SdrObject* pObj = pSvxShape->GetSdrObject();
1086  // set layer of new drawing
1087  // object to corresponding invisible layer.
1088  bool bIsVisible = pDoc->getIDocumentDrawModelAccess().IsVisibleLayerId( pObj->GetLayer() );
1089  if(SdrInventor::FmForm != pObj->GetObjInventor())
1090  {
1091  pObj->SetLayer( *o3tl::doAccess<bool>(aValue)
1092  ? ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHeavenId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() )
1093  : ( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetHellId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleHellId() ));
1094  }
1095  else
1096  {
1097  pObj->SetLayer( bIsVisible ? pDoc->getIDocumentDrawModelAccess().GetControlsId() : pDoc->getIDocumentDrawModelAccess().GetInvisibleControlsId());
1098  }
1099 
1100  }
1101 
1102  }
1103  // #i26791# - special handling for property FN_TEXT_RANGE
1104  else if ( FN_TEXT_RANGE == pEntry->nWID )
1105  {
1106  SwFormatAnchor aAnchor( aSet.Get( RES_ANCHOR ) );
1107  if (aAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
1108  {
1109  // set property <TextRange> not valid for to-page anchored shapes
1110  throw lang::IllegalArgumentException();
1111  }
1112 
1113  std::unique_ptr<SwUnoInternalPaM> pInternalPam(
1114  new SwUnoInternalPaM( *(pFormat->GetDoc()) ));
1115  uno::Reference< text::XTextRange > xRg;
1116  aValue >>= xRg;
1117  if (!::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
1118  {
1119  throw uno::RuntimeException();
1120  }
1121 
1122  if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR)
1123  {
1124  //delete old SwFormatFlyCnt
1125  //With AnchorAsCharacter the current TextAttribute has to be deleted.
1126  //Tbis removes the frame format too.
1127  //To prevent this the connection between format and attribute has to be broken before.
1128  const SwPosition *pPos = aAnchor.GetContentAnchor();
1129  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
1130  SAL_WARN_IF( !pTextNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
1131  const sal_Int32 nIdx = pPos->nContent.GetIndex();
1132  SwTextAttr * const pHint =
1133  pTextNode->GetTextAttrForCharAt(
1134  nIdx, RES_TXTATR_FLYCNT );
1135  assert(pHint && "Missing Hint.");
1136  SAL_WARN_IF( pHint->Which() != RES_TXTATR_FLYCNT,
1137  "sw.uno", "Missing FlyInCnt-Hint." );
1138  SAL_WARN_IF( pHint->GetFlyCnt().GetFrameFormat() != pFormat,
1139  "sw.uno", "Wrong TextFlyCnt-Hint." );
1140  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt())
1141  .SetFlyFormat();
1142 
1143  //The connection is removed now the attribute can be deleted.
1144  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
1145  //create a new one
1146  SwTextNode *pNd = pInternalPam->GetNode().GetTextNode();
1147  SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TextNode." );
1148  SwFormatFlyCnt aFormat( pFormat );
1149  pNd->InsertItem(aFormat, pInternalPam->GetPoint()
1150  ->nContent.GetIndex(), 0 );
1151  }
1152  else
1153  {
1154  aAnchor.SetAnchor( pInternalPam->GetPoint() );
1155  aSet.Put(aAnchor);
1156  pFormat->SetFormatAttr(aSet);
1157  }
1158  }
1159  else if (pEntry->nWID == FN_TEXT_BOX)
1160  {
1161  bool bValue(false);
1162  aValue >>= bValue;
1163  if (bValue)
1164  SwTextBoxHelper::create(pFormat);
1165  else
1166  SwTextBoxHelper::destroy(pFormat);
1167 
1168  }
1169  else if (pEntry->nWID == RES_CHAIN)
1170  {
1171  if (pEntry->nMemberId == MID_CHAIN_NEXTNAME || pEntry->nMemberId == MID_CHAIN_PREVNAME)
1172  SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
1173  }
1174  // #i28749#
1175  else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1176  {
1177  sal_Int16 nPositionLayoutDir = 0;
1178  aValue >>= nPositionLayoutDir;
1179  pFormat->SetPositionLayoutDir( nPositionLayoutDir );
1180  }
1181  else if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())
1182  {
1183  UnoActionContext aCtx(pDoc);
1184  if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1185  {
1186  SdrObject* pObj = pFormat->FindSdrObject();
1187  SdrMarkList aList;
1188  SdrMark aMark(pObj);
1189  aList.InsertEntry(aMark);
1190  sal_Int32 nAnchor = 0;
1191  cppu::enum2int( nAnchor, aValue );
1192  pDoc->ChgAnchor( aList, static_cast<RndStdIds>(nAnchor),
1193  false, true );
1194  }
1195  else
1196  {
1197  m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1198  pFormat->SetFormatAttr(aSet);
1199  }
1200  }
1201  else if( RES_FRM_SIZE == pEntry->nWID &&
1204  || pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH_RELATION ) )
1205  {
1206  SvxShape* pSvxShape = GetSvxShape();
1207  SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
1208  if(pSvxShape)
1209  {
1210  SdrObject* pObj = pSvxShape->GetSdrObject();
1211  sal_Int16 nPercent(100);
1212  aValue >>= nPercent;
1213  switch (pEntry->nMemberId)
1214  {
1215  case MID_FRMSIZE_REL_WIDTH:
1216  pObj->SetRelativeWidth( nPercent / 100.0 );
1217  break;
1219  pObj->SetRelativeHeight( nPercent / 100.0 );
1220  break;
1222  pObj->SetRelativeWidthRelation(nPercent);
1223  break;
1225  pObj->SetRelativeHeightRelation(nPercent);
1226  break;
1227  }
1228  }
1229  }
1230  else
1231  {
1232  m_pPropSet->setPropertyValue( *pEntry, aValue, aSet );
1233 
1234  if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId)
1235  {
1236  bool bSetAttr = true;
1237  text::TextContentAnchorType eNewAnchor = static_cast<text::TextContentAnchorType>(SWUnoHelper::GetEnumAsInt32( aValue ));
1238 
1239  //if old anchor was in_cntnt the related text attribute has to be removed
1240  const SwFormatAnchor& rOldAnchor = pFormat->GetAnchor();
1241  RndStdIds eOldAnchorId = rOldAnchor.GetAnchorId();
1242  SdrObject* pObj = pFormat->FindSdrObject();
1243  SwFrameFormat *pFlyFormat = FindFrameFormat( pObj );
1244  pFlyFormat->DelFrames();
1245  if( text::TextContentAnchorType_AS_CHARACTER != eNewAnchor &&
1246  (RndStdIds::FLY_AS_CHAR == eOldAnchorId))
1247  {
1248  //With AnchorAsCharacter the current TextAttribute has to be deleted.
1249  //Tbis removes the frame format too.
1250  //To prevent this the connection between format and attribute has to be broken before.
1251  const SwPosition *pPos = rOldAnchor.GetContentAnchor();
1252  SwTextNode *pTextNode = pPos->nNode.GetNode().GetTextNode();
1253  SAL_WARN_IF( !pTextNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." );
1254  const sal_Int32 nIdx = pPos->nContent.GetIndex();
1255  SwTextAttr * const pHint =
1256  pTextNode->GetTextAttrForCharAt(
1257  nIdx, RES_TXTATR_FLYCNT );
1258  assert(pHint && "Missing Hint.");
1259  SAL_WARN_IF( pHint->Which() != RES_TXTATR_FLYCNT,
1260  "sw.uno", "Missing FlyInCnt-Hint." );
1261  SAL_WARN_IF( pHint->GetFlyCnt().GetFrameFormat() != pFlyFormat,
1262  "sw.uno", "Wrong TextFlyCnt-Hint." );
1263  const_cast<SwFormatFlyCnt&>(pHint->GetFlyCnt())
1264  .SetFlyFormat();
1265 
1266  //The connection is removed now the attribute can be deleted.
1267  pTextNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx);
1268  }
1269  else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor &&
1270  (RndStdIds::FLY_AT_PAGE == eOldAnchorId))
1271  {
1272  SwFormatAnchor aNewAnchor( dynamic_cast< const SwFormatAnchor& >( aSet.Get( RES_ANCHOR ) ) );
1273  //if the fly has been anchored at page then it needs to be connected
1274  //to the content position
1275  SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
1276  if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
1277  {
1279  Point aTmp( pObj->GetSnapRect().TopLeft() );
1280  pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
1281  }
1282  else
1283  {
1284  //without access to the layout the last node of the body will be used as anchor position
1285  aPam.Move( fnMoveBackward, GoInDoc );
1286  }
1287  //anchor position has to be inserted after the text attribute has been inserted
1288  aNewAnchor.SetAnchor( aPam.GetPoint() );
1289  aSet.Put( aNewAnchor );
1290  pFormat->SetFormatAttr(aSet);
1291  bSetAttr = false;
1292  }
1293  if( text::TextContentAnchorType_AS_CHARACTER == eNewAnchor &&
1294  (RndStdIds::FLY_AS_CHAR != eOldAnchorId))
1295  {
1296  SwPaM aPam(pDoc->GetNodes().GetEndOfContent());
1297  if( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() )
1298  {
1300  Point aTmp( pObj->GetSnapRect().TopLeft() );
1301  pDoc->getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmp, &aState );
1302  }
1303  else
1304  {
1305  //without access to the layout the last node of the body will be used as anchor position
1306  aPam.Move( fnMoveBackward, GoInDoc );
1307  }
1308  //the RES_TXTATR_FLYCNT needs to be added now
1309  SwTextNode *pNd = aPam.GetNode().GetTextNode();
1310  SAL_WARN_IF( !pNd, "sw.uno", "Cursor is not in a TextNode." );
1311  SwFormatFlyCnt aFormat( pFlyFormat );
1312  pNd->InsertItem(aFormat,
1313  aPam.GetPoint()->nContent.GetIndex(), 0 );
1314  --aPam.GetPoint()->nContent; // InsertItem moved it
1315  SwFormatAnchor aNewAnchor(
1316  dynamic_cast<const SwFormatAnchor&>(
1317  aSet.Get(RES_ANCHOR)));
1318  aNewAnchor.SetAnchor( aPam.GetPoint() );
1319  aSet.Put( aNewAnchor );
1320  }
1321  if( bSetAttr )
1322  pFormat->SetFormatAttr(aSet);
1323  }
1324  else
1325  pFormat->SetFormatAttr(aSet);
1326  }
1327  // We have a pFormat and a pEntry as well: try to sync TextBox property.
1328  SwTextBoxHelper::syncProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aValue);
1329  }
1330  else
1331  {
1332  SfxPoolItem* pItem = nullptr;
1333  switch(pEntry->nWID)
1334  {
1335  case RES_ANCHOR:
1336  pItem = pImpl->GetAnchor(true);
1337  break;
1338  case RES_HORI_ORIENT:
1339  pItem = pImpl->GetHOrient(true);
1340  break;
1341  case RES_VERT_ORIENT:
1342  pItem = pImpl->GetVOrient(true);
1343  break;
1344  case RES_LR_SPACE:
1345  pItem = pImpl->GetLRSpace(true);
1346  break;
1347  case RES_UL_SPACE:
1348  pItem = pImpl->GetULSpace(true);
1349  break;
1350  case RES_SURROUND:
1351  pItem = pImpl->GetSurround(true);
1352  break;
1353  case FN_TEXT_RANGE:
1354  if(auto tr = o3tl::tryAccess<
1355  uno::Reference<text::XTextRange>>(aValue))
1356  {
1357  uno::Reference< text::XTextRange > & rRange = pImpl->GetTextRange();
1358  rRange = *tr;
1359  }
1360  break;
1361  case RES_OPAQUE :
1362  pImpl->SetOpaque(*o3tl::doAccess<bool>(aValue));
1363  break;
1364  // #i26791#
1365  case RES_FOLLOW_TEXT_FLOW:
1366  {
1367  pItem = pImpl->GetFollowTextFlow( true );
1368  }
1369  break;
1370  // #i28701#
1372  {
1373  pItem = pImpl->GetWrapInfluenceOnObjPos( true );
1374  }
1375  break;
1376  // #i28749#
1378  {
1379  sal_Int16 nPositionLayoutDir = 0;
1380  aValue >>= nPositionLayoutDir;
1381  pImpl->SetPositionLayoutDir( nPositionLayoutDir );
1382  }
1383  break;
1384  }
1385  if(pItem)
1386  pItem->PutValue(aValue, pEntry->nMemberId);
1387  }
1388  }
1389  else
1390  {
1391  const uno::Type& rPSetType =
1393  uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1394  auto xPrSet = o3tl::tryAccess<uno::Reference<beans::XPropertySet>>(
1395  aPSet);
1396  if(!xPrSet)
1397  throw uno::RuntimeException();
1398  // #i31698# - setting the caption point of a
1399  // caption object doesn't have to change the object position.
1400  // Thus, keep the position, before the caption point is set and
1401  // restore it afterwards.
1402  awt::Point aKeepedPosition( 0, 0 );
1403  if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
1404  {
1405  aKeepedPosition = getPosition();
1406  }
1407  if( pFormat && pFormat->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
1408  {
1409  UnoActionContext aCtx(pFormat->GetDoc());
1410  (*xPrSet)->setPropertyValue(rPropertyName, aValue);
1411  }
1412  else
1413  (*xPrSet)->setPropertyValue(rPropertyName, aValue);
1414 
1415  if (pFormat)
1416  {
1417  // We have a pFormat (but no pEntry): try to sync TextBox property.
1418  SwTextBoxHelper::syncProperty(pFormat, rPropertyName, aValue);
1419  }
1420 
1421  // #i31698# - restore object position, if caption point is set.
1422  if ( rPropertyName == "CaptionPoint" && getShapeType() == "com.sun.star.drawing.CaptionShape" )
1423  {
1424  setPosition( aKeepedPosition );
1425  }
1426  }
1427  }
1428 }
1429 
1430 uno::Any SwXShape::getPropertyValue(const OUString& rPropertyName)
1431 {
1432  SolarMutexGuard aGuard;
1433  uno::Any aRet;
1434  SwFrameFormat* pFormat = GetFrameFormat();
1435  if(xShapeAgg.is())
1436  {
1437  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1438  if(pEntry)
1439  {
1440  if(pFormat)
1441  {
1442  if(RES_OPAQUE == pEntry->nWID)
1443  {
1444  SvxShape* pSvxShape = GetSvxShape();
1445  OSL_ENSURE(pSvxShape, "No SvxShape found!");
1446  if(pSvxShape)
1447  {
1448  SdrObject* pObj = pSvxShape->GetSdrObject();
1449  // consider invisible layers
1450  aRet <<=
1451  ( pObj->GetLayer() != pFormat->GetDoc()->getIDocumentDrawModelAccess().GetHellId() &&
1452  pObj->GetLayer() != pFormat->GetDoc()->getIDocumentDrawModelAccess().GetInvisibleHellId() );
1453  }
1454  }
1455  else if(FN_ANCHOR_POSITION == pEntry->nWID)
1456  {
1457  SvxShape* pSvxShape = GetSvxShape();
1458  OSL_ENSURE(pSvxShape, "No SvxShape found!");
1459  if(pSvxShape)
1460  {
1461  SdrObject* pObj = pSvxShape->GetSdrObject();
1462  Point aPt = pObj->GetAnchorPos();
1463  awt::Point aPoint( convertTwipToMm100( aPt.X() ),
1464  convertTwipToMm100( aPt.Y() ) );
1465  aRet <<= aPoint;
1466  }
1467  }
1468  // #i26791# - special handling for FN_TEXT_RANGE
1469  else if ( FN_TEXT_RANGE == pEntry->nWID )
1470  {
1471  const SwFormatAnchor aAnchor = pFormat->GetAnchor();
1472  if (aAnchor.GetAnchorId() == RndStdIds::FLY_AT_PAGE)
1473  {
1474  // return nothing, because property <TextRange> isn't
1475  // valid for to-page anchored shapes
1476  uno::Any aAny;
1477  aRet = aAny;
1478  }
1479  else
1480  {
1481  if ( aAnchor.GetContentAnchor() )
1482  {
1483  const uno::Reference< text::XTextRange > xTextRange
1485  *pFormat->GetDoc(),
1486  *aAnchor.GetContentAnchor(),
1487  nullptr );
1488  aRet <<= xTextRange;
1489  }
1490  else
1491  {
1492  // return nothing
1493  uno::Any aAny;
1494  aRet = aAny;
1495  }
1496  }
1497  }
1498  else if (pEntry->nWID == FN_TEXT_BOX)
1499  {
1500  bool bValue = SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT);
1501  aRet <<= bValue;
1502  }
1503  else if (pEntry->nWID == RES_CHAIN)
1504  {
1505  switch (pEntry->nMemberId)
1506  {
1507  case MID_CHAIN_PREVNAME:
1508  case MID_CHAIN_NEXTNAME:
1509  case MID_CHAIN_NAME:
1510  SwTextBoxHelper::getProperty(pFormat, pEntry->nWID, pEntry->nMemberId, aRet);
1511  break;
1512  }
1513  }
1514  // #i28749#
1515  else if ( FN_SHAPE_TRANSFORMATION_IN_HORI_L2R == pEntry->nWID )
1516  {
1517  // get property <::drawing::Shape::Transformation>
1518  // without conversion to layout direction as below
1519  aRet = _getPropAtAggrObj( "Transformation" );
1520  }
1521  else if ( FN_SHAPE_POSITION_LAYOUT_DIR == pEntry->nWID )
1522  {
1523  aRet <<= pFormat->GetPositionLayoutDir();
1524  }
1525  // #i36248#
1526  else if ( FN_SHAPE_STARTPOSITION_IN_HORI_L2R == pEntry->nWID )
1527  {
1528  // get property <::drawing::Shape::StartPosition>
1529  // without conversion to layout direction as below
1530  aRet = _getPropAtAggrObj( "StartPosition" );
1531  }
1532  else if ( FN_SHAPE_ENDPOSITION_IN_HORI_L2R == pEntry->nWID )
1533  {
1534  // get property <::drawing::Shape::EndPosition>
1535  // without conversion to layout direction as below
1536  aRet = _getPropAtAggrObj( "EndPosition" );
1537  }
1538  else if (pEntry->nWID == RES_FRM_SIZE &&
1539  (pEntry->nMemberId == MID_FRMSIZE_REL_HEIGHT ||
1540  pEntry->nMemberId == MID_FRMSIZE_REL_WIDTH ||
1543  {
1544  SvxShape* pSvxShape = GetSvxShape();
1545  SAL_WARN_IF(!pSvxShape, "sw.uno", "No SvxShape found!");
1546  sal_Int16 nRet = 0;
1547  if (pSvxShape)
1548  {
1549  SdrObject* pObj = pSvxShape->GetSdrObject();
1550  switch (pEntry->nMemberId)
1551  {
1552  case MID_FRMSIZE_REL_WIDTH:
1553  if (pObj->GetRelativeWidth())
1554  nRet = *pObj->GetRelativeWidth() * 100;
1555  break;
1557  if (pObj->GetRelativeHeight())
1558  nRet = *pObj->GetRelativeHeight() * 100;
1559  break;
1561  nRet = pObj->GetRelativeWidthRelation();
1562  break;
1564  nRet = pObj->GetRelativeHeightRelation();
1565  break;
1566  }
1567  }
1568  aRet <<= nRet;
1569  }
1570  else
1571  {
1572  const SwAttrSet& rSet = pFormat->GetAttrSet();
1573  m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1574  }
1575  }
1576  else
1577  {
1578  SfxPoolItem* pItem = nullptr;
1579  switch(pEntry->nWID)
1580  {
1581  case RES_ANCHOR:
1582  pItem = pImpl->GetAnchor();
1583  break;
1584  case RES_HORI_ORIENT:
1585  pItem = pImpl->GetHOrient();
1586  break;
1587  case RES_VERT_ORIENT:
1588  pItem = pImpl->GetVOrient();
1589  break;
1590  case RES_LR_SPACE:
1591  pItem = pImpl->GetLRSpace();
1592  break;
1593  case RES_UL_SPACE:
1594  pItem = pImpl->GetULSpace();
1595  break;
1596  case RES_SURROUND:
1597  pItem = pImpl->GetSurround();
1598  break;
1599  case FN_TEXT_RANGE :
1600  aRet <<= pImpl->GetTextRange();
1601  break;
1602  case RES_OPAQUE :
1603  aRet <<= pImpl->GetOpaque();
1604  break;
1605  case FN_ANCHOR_POSITION :
1606  {
1607  aRet <<= awt::Point();
1608  }
1609  break;
1610  // #i26791#
1611  case RES_FOLLOW_TEXT_FLOW :
1612  {
1613  pItem = pImpl->GetFollowTextFlow();
1614  }
1615  break;
1616  // #i28701#
1618  {
1619  pItem = pImpl->GetWrapInfluenceOnObjPos();
1620  }
1621  break;
1622  // #i28749#
1624  {
1625  // get property <::drawing::Shape::Transformation>
1626  // without conversion to layout direction as below
1627  aRet = _getPropAtAggrObj( "Transformation" );
1628  }
1629  break;
1631  {
1632  aRet <<= pImpl->GetPositionLayoutDir();
1633  }
1634  break;
1635  // #i36248#
1637  {
1638  // get property <::drawing::Shape::StartPosition>
1639  // without conversion to layout direction as below
1640  aRet = _getPropAtAggrObj( "StartPosition" );
1641  }
1642  break;
1644  {
1645  // get property <::drawing::Shape::StartPosition>
1646  // without conversion to layout direction as below
1647  aRet = _getPropAtAggrObj( "EndPosition" );
1648  }
1649  break;
1650  }
1651  if(pItem)
1652  pItem->QueryValue(aRet, pEntry->nMemberId);
1653  }
1654  }
1655  else
1656  {
1657  aRet = _getPropAtAggrObj( rPropertyName );
1658 
1659  // #i31698# - convert the position (translation)
1660  // of the drawing object in the transformation
1661  if ( rPropertyName == "Transformation" )
1662  {
1663  drawing::HomogenMatrix3 aMatrix;
1664  aRet >>= aMatrix;
1665  aRet <<= ConvertTransformationToLayoutDir( aMatrix );
1666  }
1667  // #i36248#
1668  else if ( rPropertyName == "StartPosition" )
1669  {
1670  awt::Point aStartPos;
1671  aRet >>= aStartPos;
1672  // #i59051#
1673  aRet <<= ConvertStartOrEndPosToLayoutDir( aStartPos );
1674  }
1675  else if ( rPropertyName == "EndPosition" )
1676  {
1677  awt::Point aEndPos;
1678  aRet >>= aEndPos;
1679  // #i59051#
1680  aRet <<= ConvertStartOrEndPosToLayoutDir( aEndPos );
1681  }
1682  // #i59051#
1683  else if ( rPropertyName == "PolyPolygonBezier" )
1684  {
1685  drawing::PolyPolygonBezierCoords aPath;
1686  aRet >>= aPath;
1687  aRet <<= ConvertPolyPolygonBezierToLayoutDir( aPath );
1688  }
1689  else if (rPropertyName == "ZOrder")
1690  {
1691  // Convert the real draw page position to the logical one that ignores textboxes.
1692  if (pFormat)
1693  {
1694  const SdrObject* pObj = pFormat->FindRealSdrObject();
1695  if (pObj)
1696  {
1697  bool bConvert = true;
1698  if (SvxShape* pSvxShape = GetSvxShape())
1699  // In case of group shapes, pSvxShape points to the child shape, while pObj points to the outermost group shape.
1700  if (pSvxShape->GetSdrObject() != pObj)
1701  // Textboxes are not expected inside group shapes, so no conversion is necessary there.
1702  bConvert = false;
1703  if (bConvert)
1704  {
1705  aRet <<= SwTextBoxHelper::getOrdNum(pObj);
1706  }
1707  }
1708  }
1709  }
1710  }
1711  }
1712  return aRet;
1713 }
1714 
1715 uno::Any SwXShape::_getPropAtAggrObj( const OUString& _rPropertyName )
1716 {
1717  uno::Any aRet;
1718 
1719  const uno::Type& rPSetType =
1721  uno::Any aPSet = xShapeAgg->queryAggregation(rPSetType);
1722  auto xPrSet = o3tl::tryAccess<uno::Reference<beans::XPropertySet>>(aPSet);
1723  if ( !xPrSet )
1724  {
1725  throw uno::RuntimeException();
1726  }
1727  aRet = (*xPrSet)->getPropertyValue( _rPropertyName );
1728 
1729  return aRet;
1730 }
1731 
1732 beans::PropertyState SwXShape::getPropertyState( const OUString& rPropertyName )
1733 {
1734  SolarMutexGuard aGuard;
1735  uno::Sequence< OUString > aNames { rPropertyName };
1736  uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
1737  return aStates.getConstArray()[0];
1738 }
1739 
1740 uno::Sequence< beans::PropertyState > SwXShape::getPropertyStates(
1741  const uno::Sequence< OUString >& aPropertyNames )
1742 {
1743  SolarMutexGuard aGuard;
1744  SwFrameFormat* pFormat = GetFrameFormat();
1745  uno::Sequence< beans::PropertyState > aRet(aPropertyNames.getLength());
1746  if(!xShapeAgg.is())
1747  throw uno::RuntimeException();
1748 
1749  SvxShape* pSvxShape = GetSvxShape();
1750  bool bGroupMember = false;
1751  bool bFormControl = false;
1752  SdrObject* pObject = pSvxShape ? pSvxShape->GetSdrObject() : nullptr;
1753  if(pObject)
1754  {
1755  bGroupMember = pObject->getParentSdrObjectFromSdrObject() != nullptr;
1756  bFormControl = pObject->GetObjInventor() == SdrInventor::FmForm;
1757  }
1758  const OUString* pNames = aPropertyNames.getConstArray();
1759  beans::PropertyState* pRet = aRet.getArray();
1760  uno::Reference< XPropertyState > xShapePrState;
1761  for(sal_Int32 nProperty = 0; nProperty < aPropertyNames.getLength(); nProperty++)
1762  {
1763  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( pNames[nProperty] );
1764  if(pEntry)
1765  {
1766  if(RES_OPAQUE == pEntry->nWID)
1767  pRet[nProperty] = bFormControl ?
1768  beans::PropertyState_DEFAULT_VALUE : beans::PropertyState_DIRECT_VALUE;
1769  else if(FN_ANCHOR_POSITION == pEntry->nWID)
1770  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1771  else if(FN_TEXT_RANGE == pEntry->nWID)
1772  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1773  else if(bGroupMember)
1774  pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1775  else if (pEntry->nWID == RES_FRM_SIZE &&
1778  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1779  else if (pEntry->nWID == FN_TEXT_BOX)
1780  {
1781  // The TextBox property is set, if we can find a textbox for this shape.
1782  if (pFormat && SwTextBoxHelper::isTextBox(pFormat, RES_DRAWFRMFMT))
1783  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1784  else
1785  pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1786  }
1787  else if(pFormat)
1788  {
1789  const SwAttrSet& rSet = pFormat->GetAttrSet();
1790  SfxItemState eItemState = rSet.GetItemState(pEntry->nWID, false);
1791 
1792  if(SfxItemState::SET == eItemState)
1793  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1794  else if(SfxItemState::DEFAULT == eItemState)
1795  pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1796  else
1797  pRet[nProperty] = beans::PropertyState_AMBIGUOUS_VALUE;
1798  }
1799  else
1800  {
1801  SfxPoolItem* pItem = nullptr;
1802  switch(pEntry->nWID)
1803  {
1804  case RES_ANCHOR:
1805  pItem = pImpl->GetAnchor();
1806  break;
1807  case RES_HORI_ORIENT:
1808  pItem = pImpl->GetHOrient();
1809  break;
1810  case RES_VERT_ORIENT:
1811  pItem = pImpl->GetVOrient();
1812  break;
1813  case RES_LR_SPACE:
1814  pItem = pImpl->GetLRSpace();
1815  break;
1816  case RES_UL_SPACE:
1817  pItem = pImpl->GetULSpace();
1818  break;
1819  case RES_SURROUND:
1820  pItem = pImpl->GetSurround();
1821  break;
1822  // #i28701#
1824  {
1825  pItem = pImpl->GetWrapInfluenceOnObjPos();
1826  }
1827  break;
1828  }
1829  if(pItem)
1830  pRet[nProperty] = beans::PropertyState_DIRECT_VALUE;
1831  else
1832  pRet[nProperty] = beans::PropertyState_DEFAULT_VALUE;
1833  }
1834  }
1835  else
1836  {
1837  if(!xShapePrState.is())
1838  {
1839  const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get();
1840  uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1841  auto ps = o3tl::tryAccess<uno::Reference<XPropertyState>>(
1842  aPState);
1843  if(!ps)
1844  throw uno::RuntimeException();
1845  xShapePrState = *ps;
1846  }
1847  pRet[nProperty] = xShapePrState->getPropertyState(pNames[nProperty]);
1848  }
1849  }
1850 
1851  return aRet;
1852 }
1853 
1854 void SwXShape::setPropertyToDefault( const OUString& rPropertyName )
1855 {
1856  SolarMutexGuard aGuard;
1857  SwFrameFormat* pFormat = GetFrameFormat();
1858  if(!xShapeAgg.is())
1859  throw uno::RuntimeException();
1860 
1861  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1862  if(pEntry)
1863  {
1864  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1865  throw uno::RuntimeException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1866  if(pFormat)
1867  {
1868  const SfxItemSet& rSet = pFormat->GetAttrSet();
1869  SfxItemSet aSet(pFormat->GetDoc()->GetAttrPool(), {{pEntry->nWID, pEntry->nWID}});
1870  aSet.SetParent(&rSet);
1871  aSet.ClearItem(pEntry->nWID);
1872  pFormat->GetDoc()->SetAttr(aSet, *pFormat);
1873  }
1874  else
1875  {
1876  switch(pEntry->nWID)
1877  {
1878  case RES_ANCHOR: pImpl->RemoveAnchor(); break;
1879  case RES_HORI_ORIENT: pImpl->RemoveHOrient(); break;
1880  case RES_VERT_ORIENT: pImpl->RemoveVOrient(); break;
1881  case RES_LR_SPACE: pImpl->RemoveLRSpace(); break;
1882  case RES_UL_SPACE: pImpl->RemoveULSpace(); break;
1883  case RES_SURROUND: pImpl->RemoveSurround();break;
1884  case RES_OPAQUE : pImpl->SetOpaque(false); break;
1885  case FN_TEXT_RANGE :
1886  break;
1887  // #i26791#
1888  case RES_FOLLOW_TEXT_FLOW:
1889  {
1890  pImpl->RemoveFollowTextFlow();
1891  }
1892  break;
1893  // #i28701#
1895  {
1896  pImpl->RemoveWrapInfluenceOnObjPos();
1897  }
1898  break;
1899  }
1900  }
1901  }
1902  else
1903  {
1904  const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get();
1905  uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1906  auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>(
1907  aPState);
1908  if(!xShapePrState)
1909  throw uno::RuntimeException();
1910  (*xShapePrState)->setPropertyToDefault( rPropertyName );
1911  }
1912 
1913 }
1914 
1915 uno::Any SwXShape::getPropertyDefault( const OUString& rPropertyName )
1916 {
1917  SolarMutexGuard aGuard;
1918  SwFrameFormat* pFormat = GetFrameFormat();
1919  uno::Any aRet;
1920  if(!xShapeAgg.is())
1921  throw uno::RuntimeException();
1922 
1923  const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap().getByName( rPropertyName );
1924  if(pEntry)
1925  {
1926  if(!(pEntry->nWID < RES_FRMATR_END && pFormat))
1927  throw uno::RuntimeException();
1928 
1929  const SfxPoolItem& rDefItem =
1930  pFormat->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
1931  rDefItem.QueryValue(aRet, pEntry->nMemberId);
1932 
1933  }
1934  else
1935  {
1936  const uno::Type& rPStateType = cppu::UnoType<XPropertyState>::get();
1937  uno::Any aPState = xShapeAgg->queryAggregation(rPStateType);
1938  auto xShapePrState = o3tl::tryAccess<uno::Reference<XPropertyState>>(
1939  aPState);
1940  if(!xShapePrState)
1941  throw uno::RuntimeException();
1942  (*xShapePrState)->getPropertyDefault( rPropertyName );
1943  }
1944 
1945  return aRet;
1946 }
1947 
1949  const OUString& _propertyName,
1950  const uno::Reference< beans::XPropertyChangeListener > & _listener )
1951 {
1952  if ( !xShapeAgg.is() )
1953  throw uno::RuntimeException("no shape aggregate", *this );
1954 
1955  // must be handled by the aggregate
1956  uno::Reference< beans::XPropertySet > xShapeProps;
1957  if ( xShapeAgg->queryAggregation( cppu::UnoType<beans::XPropertySet>::get() ) >>= xShapeProps )
1958  xShapeProps->addPropertyChangeListener( _propertyName, _listener );
1959 }
1960 
1962  const OUString& _propertyName,
1963  const uno::Reference< beans::XPropertyChangeListener > & _listener)
1964 {
1965  if ( !xShapeAgg.is() )
1966  throw uno::RuntimeException("no shape aggregate", *this );
1967 
1968  // must be handled by the aggregate
1969  uno::Reference< beans::XPropertySet > xShapeProps;
1970  if ( xShapeAgg->queryAggregation( cppu::UnoType<beans::XPropertySet>::get() ) >>= xShapeProps )
1971  xShapeProps->removePropertyChangeListener( _propertyName, _listener );
1972 }
1973 
1975  const OUString& /*PropertyName*/,
1976  const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/ )
1977 {
1978  OSL_FAIL("not implemented");
1979 }
1980 
1982  const OUString& /*PropertyName*/,
1983  const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
1984 {
1985  OSL_FAIL("not implemented");
1986 }
1987 
1988 void SwXShape::Notify(const SfxHint& rHint)
1989 {
1990  if(rHint.GetId() == SfxHintId::Dying)
1991  {
1992  m_pFormat = nullptr;
1993  EndListeningAll();
1994  }
1995 }
1996 
1997 void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange)
1998 {
1999  SolarMutexGuard aGuard;
2000 
2001  // get access to SwDoc
2002  // (see also SwXTextRange::XTextRangeToSwPaM)
2003  const SwDoc* pDoc = nullptr;
2004  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
2005  if(xRangeTunnel.is())
2006  {
2007  SwXTextRange* pRange = nullptr;
2008  OTextCursorHelper* pCursor = nullptr;
2009  SwXTextPortion* pPortion = nullptr;
2010  SwXText* pText = nullptr;
2011  SwXParagraph* pParagraph = nullptr;
2012 
2013  pRange = reinterpret_cast< SwXTextRange * >(
2014  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) ));
2015  pText = reinterpret_cast< SwXText * >(
2016  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXText::getUnoTunnelId()) ));
2017  pCursor = reinterpret_cast< OTextCursorHelper * >(
2018  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) ));
2019  pPortion = reinterpret_cast< SwXTextPortion * >(
2020  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextPortion::getUnoTunnelId()) ));
2021  pParagraph = reinterpret_cast< SwXParagraph * >(
2022  sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXParagraph::getUnoTunnelId( ) ) ) );
2023 
2024  if (pRange)
2025  pDoc = &pRange->GetDoc();
2026  else if (pText)
2027  pDoc = pText->GetDoc();
2028  else if (pCursor)
2029  pDoc = pCursor->GetDoc();
2030  else if (pPortion)
2031  pDoc = pPortion->GetCursor().GetDoc();
2032  else if (pParagraph && pParagraph->GetTextNode())
2033  pDoc = pParagraph->GetTextNode()->GetDoc();
2034 
2035  }
2036 
2037  if(!pDoc)
2038  throw uno::RuntimeException();
2039  if (const SwDocShell* pDocSh = pDoc->GetDocShell())
2040  {
2041  uno::Reference<frame::XModel> xModel = pDocSh->GetModel();
2042  uno::Reference< drawing::XDrawPageSupplier > xDPS(xModel, uno::UNO_QUERY);
2043  if (xDPS.is())
2044  {
2045  uno::Reference< drawing::XDrawPage > xDP( xDPS->getDrawPage() );
2046  if (xDP.is())
2047  {
2048  uno::Any aPos;
2049  aPos <<= xTextRange;
2050  setPropertyValue("TextRange", aPos);
2051  uno::Reference< drawing::XShape > xTemp( static_cast<cppu::OWeakObject*>(this), uno::UNO_QUERY );
2052  xDP->add( xTemp );
2053  }
2054  }
2055  }
2056 }
2057 
2058 uno::Reference< text::XTextRange > SwXShape::getAnchor()
2059 {
2060  SolarMutexGuard aGuard;
2061  uno::Reference< text::XTextRange > aRef;
2062  SwFrameFormat* pFormat = GetFrameFormat();
2063  if(pFormat)
2064  {
2065  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
2066  // return an anchor for non-page bound frames
2067  // and for page bound frames that have a page no == NULL and a content position
2068  if ((rAnchor.GetAnchorId() != RndStdIds::FLY_AT_PAGE) ||
2069  (rAnchor.GetContentAnchor() && !rAnchor.GetPageNum()))
2070  {
2071  const SwPosition &rPos = *(pFormat->GetAnchor().GetContentAnchor());
2072  aRef = SwXTextRange::CreateXTextRange(*pFormat->GetDoc(), rPos, nullptr);
2073  }
2074  }
2075  else
2076  aRef = pImpl->GetTextRange();
2077  return aRef;
2078 }
2079 
2081 {
2082  SolarMutexGuard aGuard;
2083  SwFrameFormat* pFormat = GetFrameFormat();
2084  if(pFormat)
2085  {
2086  // determine correct <SdrObject>
2087  SvxShape* pSvxShape = GetSvxShape();
2088  SdrObject* pObj = pSvxShape ? pSvxShape->GetSdrObject() : nullptr;
2089  // safety assertion:
2090  // <pObj> must be the same as <pFormat->FindSdrObject()>, if <pObj> isn't
2091  // a 'virtual' drawing object.
2092  // correct assertion and refine it for safety reason.
2093  OSL_ENSURE( !pObj ||
2094  dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr ||
2096  pObj == pFormat->FindSdrObject(),
2097  "<SwXShape::dispose(..) - different 'master' drawing objects!!" );
2098  // perform delete of draw frame format *not*
2099  // for 'virtual' drawing objects.
2100  // no delete of draw format for members
2101  // of a group
2102  if ( pObj &&
2103  dynamic_cast<const SwDrawVirtObj*>( pObj) == nullptr &&
2105  pObj->IsInserted() )
2106  {
2107  if (pFormat->GetAnchor().GetAnchorId() == RndStdIds::FLY_AS_CHAR)
2108  {
2109  const SwPosition &rPos = *(pFormat->GetAnchor().GetContentAnchor());
2110  SwTextNode *pTextNode = rPos.nNode.GetNode().GetTextNode();
2111  const sal_Int32 nIdx = rPos.nContent.GetIndex();
2112  pTextNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx );
2113  }
2114  else
2115  pFormat->GetDoc()->getIDocumentLayoutAccess().DelLayoutFormat( pFormat );
2116  }
2117  }
2118  if(xShapeAgg.is())
2119  {
2120  uno::Any aAgg(xShapeAgg->queryAggregation( cppu::UnoType<XComponent>::get()));
2121  uno::Reference<XComponent> xComp;
2122  aAgg >>= xComp;
2123  if(xComp.is())
2124  xComp->dispose();
2125  }
2126  if(m_pPage)
2127  const_cast<SwFmDrawPage*>(m_pPage)->RemoveShape(this);
2128  m_pPage = nullptr;
2129 }
2130 
2132  const uno::Reference< lang::XEventListener > & aListener)
2133 {
2134  SvxShape* pSvxShape = GetSvxShape();
2135  if(pSvxShape)
2136  pSvxShape->addEventListener(aListener);
2137 }
2138 
2140  const uno::Reference< lang::XEventListener > & aListener)
2141 {
2142  SvxShape* pSvxShape = GetSvxShape();
2143  if(pSvxShape)
2144  pSvxShape->removeEventListener(aListener);
2145 }
2146 
2148 {
2149  return "SwXShape";
2150 }
2151 
2152 sal_Bool SwXShape::supportsService(const OUString& rServiceName)
2153 {
2154  return cppu::supportsService(this, rServiceName);
2155 }
2156 
2157 uno::Sequence< OUString > SwXShape::getSupportedServiceNames()
2158 {
2159  uno::Sequence< OUString > aSeq;
2160  if (SvxShape* pSvxShape = GetSvxShape())
2161  aSeq = pSvxShape->getSupportedServiceNames();
2163  aSeq, std::initializer_list<OUStringLiteral>{ "com.sun.star.drawing.Shape" });
2164 }
2165 
2167 {
2168  if(xShapeAgg.is())
2169  return comphelper::getUnoTunnelImplementation<SvxShape>(xShapeAgg);
2170  return nullptr;
2171 }
2172 
2173 // #i31698#
2174 // implementation of virtual methods from drawing::XShape
2175 awt::Point SAL_CALL SwXShape::getPosition()
2176 {
2177  awt::Point aPos( GetAttrPosition() );
2178 
2179  // handle group members
2180  SvxShape* pSvxShape = GetSvxShape();
2181  if ( pSvxShape )
2182  {
2183  SdrObject* pTopGroupObj = GetTopGroupObj( pSvxShape );
2184  if ( pTopGroupObj )
2185  {
2186  // #i34750# - get attribute position of top group
2187  // shape and add offset between top group object and group member
2188  uno::Reference< drawing::XShape > xGroupShape( pTopGroupObj->getUnoShape(), uno::UNO_QUERY );
2189  aPos = xGroupShape->getPosition();
2190  // add offset between top group object and group member
2191  // to the determined attribute position
2192  // #i34750#:
2193  // consider the layout direction
2194  const tools::Rectangle aMemberObjRect = GetSvxShape()->GetSdrObject()->GetSnapRect();
2195  const tools::Rectangle aGroupObjRect = pTopGroupObj->GetSnapRect();
2196  // #i53320# - relative position of group member and
2197  // top group object is always given in horizontal left-to-right layout.
2198  awt::Point aOffset( 0, 0 );
2199  {
2200  aOffset.X = ( aMemberObjRect.Left() - aGroupObjRect.Left() );
2201  aOffset.Y = ( aMemberObjRect.Top() - aGroupObjRect.Top() );
2202  }
2203  aOffset.X = convertTwipToMm100(aOffset.X);
2204  aOffset.Y = convertTwipToMm100(aOffset.Y);
2205  aPos.X += aOffset.X;
2206  aPos.Y += aOffset.Y;
2207  }
2208  }
2209 
2210  return aPos;
2211 }
2212 
2213 void SAL_CALL SwXShape::setPosition( const awt::Point& aPosition )
2214 {
2215  SdrObject* pTopGroupObj = GetTopGroupObj();
2216  if ( !pTopGroupObj )
2217  {
2218  // #i37877# - no adjustment of position attributes,
2219  // if the position also has to be applied at the drawing object and
2220  // a contact object is already registered at the drawing object.
2221  bool bApplyPosAtDrawObj(false);
2222  bool bNoAdjustOfPosProp(false);
2223  // #i35798# - apply position also to drawing object,
2224  // if drawing object has no anchor position set.
2225  if ( mxShape.is() )
2226  {
2227  SvxShape* pSvxShape = GetSvxShape();
2228  if ( pSvxShape )
2229  {
2230  const SdrObject* pObj = pSvxShape->GetSdrObject();
2231  if ( pObj &&
2232  pObj->GetAnchorPos().X() == 0 &&
2233  pObj->GetAnchorPos().Y() == 0 )
2234  {
2235  bApplyPosAtDrawObj = true;
2236  if ( pObj->GetUserCall() &&
2237  dynamic_cast<const SwDrawContact*>( pObj->GetUserCall()) != nullptr )
2238  {
2239  bNoAdjustOfPosProp = true;
2240  }
2241  }
2242  }
2243  }
2244  // shape isn't a group member. Thus, set positioning attributes
2245  if ( !bNoAdjustOfPosProp )
2246  {
2247  AdjustPositionProperties( aPosition );
2248  }
2249  if ( bApplyPosAtDrawObj )
2250  {
2251  mxShape->setPosition( aPosition );
2252  }
2253  }
2254  else if ( mxShape.is() )
2255  {
2256  // shape is a member of a group. Thus, set its position.
2257  awt::Point aNewPos( aPosition );
2258  // The given position is given in the according layout direction. Thus,
2259  // it has to be converted to a position in horizontal left-to-right
2260  // layout.
2261  // convert given absolute attribute position in layout direction into
2262  // position in horizontal left-to-right layout.
2263  {
2264  aNewPos = ConvertPositionToHoriL2R( aNewPos, getSize() );
2265  }
2266  // Convert given absolute position in horizontal left-to-right
2267  // layout into relative position in horizontal left-to-right layout.
2268  uno::Reference< drawing::XShape > xGroupShape( pTopGroupObj->getUnoShape(), uno::UNO_QUERY );
2269  {
2270  // #i34750#
2271  // use method <xGroupShape->getPosition()> to get the correct
2272  // position of the top group object.
2273  awt::Point aAttrPosInHoriL2R(
2274  ConvertPositionToHoriL2R( xGroupShape->getPosition(),
2275  xGroupShape->getSize() ) );
2276  aNewPos.X = o3tl::saturating_sub(aNewPos.X, aAttrPosInHoriL2R.X);
2277  aNewPos.Y = o3tl::saturating_sub(aNewPos.Y, aAttrPosInHoriL2R.Y);
2278  }
2279  // convert relative position in horizontal left-to-right layout into
2280  // absolute position in horizontal left-to-right layout
2281  {
2282  // #i34750#
2283  // use method <SvxShape->getPosition()> to get the correct
2284  // 'Drawing layer' position of the top group shape.
2285  auto pSvxGroupShape = comphelper::getUnoTunnelImplementation<SvxShape>(pTopGroupObj->getUnoShape());
2286  const awt::Point aGroupPos = pSvxGroupShape->getPosition();
2287  aNewPos.X = o3tl::saturating_add(aNewPos.X, aGroupPos.X);
2288  aNewPos.Y = o3tl::saturating_add(aNewPos.Y, aGroupPos.Y);
2289  }
2290  // set position
2291  mxShape->setPosition( aNewPos );
2292  }
2293 }
2294 
2295 awt::Size SAL_CALL SwXShape::getSize()
2296 {
2297  awt::Size aSize;
2298  if ( mxShape.is() )
2299  {
2300  aSize = mxShape->getSize();
2301  }
2302  return aSize;
2303 }
2304 
2305 void SAL_CALL SwXShape::setSize( const awt::Size& aSize )
2306 {
2307  comphelper::ProfileZone aZone("SwXShape::setSize");
2308 
2309  if ( mxShape.is() )
2310  {
2311  mxShape->setSize( aSize );
2312  }
2314 }
2315 // #i31698#
2316 // implementation of virtual methods from drawing::XShapeDescriptor
2317 OUString SAL_CALL SwXShape::getShapeType()
2318 {
2319  if ( mxShape.is() )
2320  {
2321  return mxShape->getShapeType();
2322  }
2323  return OUString();
2324 }
2329 {
2330  SdrObject* pTopGroupObj( nullptr );
2331 
2332  SvxShape* pSvxShape = _pSvxShape ? _pSvxShape : GetSvxShape();
2333  if ( pSvxShape )
2334  {
2335  SdrObject* pSdrObj = pSvxShape->GetSdrObject();
2336  if ( pSdrObj && pSdrObj->getParentSdrObjectFromSdrObject() )
2337  {
2338  pTopGroupObj = pSdrObj->getParentSdrObjectFromSdrObject();
2339  while ( pTopGroupObj->getParentSdrObjectFromSdrObject() )
2340  {
2341  pTopGroupObj = pTopGroupObj->getParentSdrObjectFromSdrObject();
2342  }
2343  }
2344  }
2345 
2346  return pTopGroupObj;
2347 }
2348 
2353 {
2354  awt::Point aAttrPos;
2355 
2356  uno::Any aHoriPos( getPropertyValue("HoriOrientPosition") );
2357  aHoriPos >>= aAttrPos.X;
2358  uno::Any aVertPos( getPropertyValue("VertOrientPosition") );
2359  aVertPos >>= aAttrPos.Y;
2360  // #i35798# - fallback, if attribute position is (0,0)
2361  // and no anchor position is applied to the drawing object
2362  SvxShape* pSvxShape = GetSvxShape();
2363  if ( pSvxShape )
2364  {
2365  const SdrObject* pObj = pSvxShape->GetSdrObject();
2366  if ( pObj &&
2367  pObj->GetAnchorPos().X() == 0 &&
2368  pObj->GetAnchorPos().Y() == 0 &&
2369  aAttrPos.X == 0 && aAttrPos.Y == 0 )
2370  {
2371  const tools::Rectangle aObjRect = pObj->GetSnapRect();
2372  aAttrPos.X = convertTwipToMm100(aObjRect.Left());
2373  aAttrPos.Y = convertTwipToMm100(aObjRect.Top());
2374  }
2375  }
2376  // #i35007# - If drawing object is anchored as-character,
2377  // it's x-position isn't sensible. Thus, return the x-position as zero in this case.
2378  text::TextContentAnchorType eTextAnchorType =
2379  text::TextContentAnchorType_AT_PARAGRAPH;
2380  {
2381  uno::Any aAny = getPropertyValue( "AnchorType" );
2382  aAny >>= eTextAnchorType;
2383  }
2384  if ( eTextAnchorType == text::TextContentAnchorType_AS_CHARACTER )
2385  {
2386  aAttrPos.X = 0;
2387  }
2388 
2389  return aAttrPos;
2390 }
2391 
2396 awt::Point SwXShape::ConvertPositionToHoriL2R( const awt::Point& rObjPos,
2397  const awt::Size& rObjSize )
2398 {
2399  awt::Point aObjPosInHoriL2R( rObjPos );
2400 
2401  SwFrameFormat* pFrameFormat = GetFrameFormat();
2402  if ( pFrameFormat )
2403  {
2404  SwFrameFormat::tLayoutDir eLayoutDir = pFrameFormat->GetLayoutDir();
2405  switch ( eLayoutDir )
2406  {
2408  {
2409  // nothing to do
2410  }
2411  break;
2413  {
2414  aObjPosInHoriL2R.X = -rObjPos.X - rObjSize.Width;
2415  }
2416  break;
2418  {
2419  aObjPosInHoriL2R.X = -rObjPos.Y - rObjSize.Width;
2420  aObjPosInHoriL2R.Y = rObjPos.X;
2421  }
2422  break;
2423  default:
2424  {
2425  OSL_FAIL( "<SwXShape::ConvertPositionToHoriL2R(..)> - unsupported layout direction" );
2426  }
2427  }
2428  }
2429 
2430  return aObjPosInHoriL2R;
2431 }
2432 
2438  const drawing::HomogenMatrix3& rMatrixInHoriL2R )
2439 {
2440  drawing::HomogenMatrix3 aMatrix(rMatrixInHoriL2R);
2441 
2442  // #i44334#, #i44681# - direct manipulation of the
2443  // transformation structure isn't valid, if it contains rotation.
2444  SvxShape* pSvxShape = GetSvxShape();
2445  OSL_ENSURE( pSvxShape,
2446  "<SwXShape::ConvertTransformationToLayoutDir(..)> - no SvxShape found!");
2447  if ( pSvxShape )
2448  {
2449  const SdrObject* pObj = pSvxShape->GetSdrObject();
2450  OSL_ENSURE( pObj,
2451  "<SwXShape::ConvertTransformationToLayoutDir(..)> - no SdrObject found!");
2452  if ( pObj )
2453  {
2454  // get position of object in Writer coordinate system.
2455  awt::Point aPos( getPosition() );
2456  // get position of object in Drawing layer coordinate system
2457  const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2458  const awt::Point aObjPos(
2459  convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2460  convertTwipToMm100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2461  // determine difference between these positions according to the
2462  // Writer coordinate system
2463  const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2464  aPos.Y - aObjPos.Y );
2465  // apply translation difference to transformation matrix.
2466  if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2467  {
2468  // #i73079# - use correct matrix type
2469  ::basegfx::B2DHomMatrix aTempMatrix;
2470 
2471  aTempMatrix.set(0, 0, aMatrix.Line1.Column1 );
2472  aTempMatrix.set(0, 1, aMatrix.Line1.Column2 );
2473  aTempMatrix.set(0, 2, aMatrix.Line1.Column3 );
2474  aTempMatrix.set(1, 0, aMatrix.Line2.Column1 );
2475  aTempMatrix.set(1, 1, aMatrix.Line2.Column2 );
2476  aTempMatrix.set(1, 2, aMatrix.Line2.Column3 );
2477  aTempMatrix.set(2, 0, aMatrix.Line3.Column1 );
2478  aTempMatrix.set(2, 1, aMatrix.Line3.Column2 );
2479  aTempMatrix.set(2, 2, aMatrix.Line3.Column3 );
2480  // #i73079#
2481  aTempMatrix.translate( aTranslateDiff.X, aTranslateDiff.Y );
2482  aMatrix.Line1.Column1 = aTempMatrix.get(0, 0);
2483  aMatrix.Line1.Column2 = aTempMatrix.get(0, 1);
2484  aMatrix.Line1.Column3 = aTempMatrix.get(0, 2);
2485  aMatrix.Line2.Column1 = aTempMatrix.get(1, 0);
2486  aMatrix.Line2.Column2 = aTempMatrix.get(1, 1);
2487  aMatrix.Line2.Column3 = aTempMatrix.get(1, 2);
2488  aMatrix.Line3.Column1 = aTempMatrix.get(2, 0);
2489  aMatrix.Line3.Column2 = aTempMatrix.get(2, 1);
2490  aMatrix.Line3.Column3 = aTempMatrix.get(2, 2);
2491  }
2492  }
2493  }
2494 
2495  return aMatrix;
2496 }
2497 
2501 void SwXShape::AdjustPositionProperties( const awt::Point& rPosition )
2502 {
2503  // handle x-position
2504  // #i35007# - no handling of x-position, if drawing
2505  // object is anchored as-character, because it doesn't make sense.
2506  text::TextContentAnchorType eTextAnchorType =
2507  text::TextContentAnchorType_AT_PARAGRAPH;
2508  {
2509  uno::Any aAny = getPropertyValue( "AnchorType" );
2510  aAny >>= eTextAnchorType;
2511  }
2512  if ( eTextAnchorType != text::TextContentAnchorType_AS_CHARACTER )
2513  {
2514  // determine current x-position
2515  const OUString aHoriPosPropStr("HoriOrientPosition");
2516  uno::Any aHoriPos( getPropertyValue( aHoriPosPropStr ) );
2517  sal_Int32 dCurrX = 0;
2518  aHoriPos >>= dCurrX;
2519  // change x-position attribute, if needed
2520  if ( dCurrX != rPosition.X )
2521  {
2522  // adjust x-position orientation to text::HoriOrientation::NONE, if needed
2523  // Note: has to be done before setting x-position attribute
2524  const OUString aHoriOrientPropStr("HoriOrient");
2525  uno::Any aHoriOrient( getPropertyValue( aHoriOrientPropStr ) );
2526  sal_Int16 eHoriOrient;
2527  if (aHoriOrient >>= eHoriOrient) // may be void
2528  {
2529  if ( eHoriOrient != text::HoriOrientation::NONE )
2530  {
2531  eHoriOrient = text::HoriOrientation::NONE;
2532  aHoriOrient <<= eHoriOrient;
2533  setPropertyValue( aHoriOrientPropStr, aHoriOrient );
2534  }
2535  }
2536  // set x-position attribute
2537  aHoriPos <<= rPosition.X;
2538  setPropertyValue( aHoriPosPropStr, aHoriPos );
2539  }
2540  }
2541 
2542  // handle y-position
2543  {
2544  // determine current y-position
2545  const OUString aVertPosPropStr("VertOrientPosition");
2546  uno::Any aVertPos( getPropertyValue( aVertPosPropStr ) );
2547  sal_Int32 dCurrY = 0;
2548  aVertPos >>= dCurrY;
2549  // change y-position attribute, if needed
2550  if ( dCurrY != rPosition.Y )
2551  {
2552  // adjust y-position orientation to text::VertOrientation::NONE, if needed
2553  // Note: has to be done before setting y-position attribute
2554  const OUString aVertOrientPropStr("VertOrient");
2555  uno::Any aVertOrient( getPropertyValue( aVertOrientPropStr ) );
2556  sal_Int16 eVertOrient;
2557  if (aVertOrient >>= eVertOrient) // may be void
2558  {
2559  if ( eVertOrient != text::VertOrientation::NONE )
2560  {
2561  eVertOrient = text::VertOrientation::NONE;
2562  aVertOrient <<= eVertOrient;
2563  setPropertyValue( aVertOrientPropStr, aVertOrient );
2564  }
2565  }
2566  // set y-position attribute
2567  aVertPos <<= rPosition.Y;
2568  setPropertyValue( aVertPosPropStr, aVertPos );
2569  }
2570  }
2571 }
2572 
2578  const css::awt::Point& aStartOrEndPos )
2579 {
2580  awt::Point aConvertedPos( aStartOrEndPos );
2581 
2582  SvxShape* pSvxShape = GetSvxShape();
2583  OSL_ENSURE( pSvxShape,
2584  "<SwXShape::ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
2585  if ( pSvxShape )
2586  {
2587  const SdrObject* pObj = pSvxShape->GetSdrObject();
2588  OSL_ENSURE( pObj,
2589  "<SwXShape::ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
2590  if ( pObj )
2591  {
2592  // get position of object in Writer coordinate system.
2593  awt::Point aPos( getPosition() );
2594  // get position of object in Drawing layer coordinate system
2595  const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2596  const awt::Point aObjPos(
2597  convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2598  convertTwipToMm100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2599  // determine difference between these positions according to the
2600  // Writer coordinate system
2601  const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2602  aPos.Y - aObjPos.Y );
2603  // apply translation difference to transformation matrix.
2604  if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2605  {
2606  aConvertedPos.X = aConvertedPos.X + aTranslateDiff.X;
2607  aConvertedPos.Y = aConvertedPos.Y + aTranslateDiff.Y;
2608  }
2609  }
2610  }
2611 
2612  return aConvertedPos;
2613 }
2614 
2615 css::drawing::PolyPolygonBezierCoords SwXShape::ConvertPolyPolygonBezierToLayoutDir(
2616  const css::drawing::PolyPolygonBezierCoords& aPath )
2617 {
2618  drawing::PolyPolygonBezierCoords aConvertedPath( aPath );
2619 
2620  SvxShape* pSvxShape = GetSvxShape();
2621  OSL_ENSURE( pSvxShape,
2622  "<SwXShape::ConvertStartOrEndPosToLayoutDir(..)> - no SvxShape found!");
2623  if ( pSvxShape )
2624  {
2625  const SdrObject* pObj = pSvxShape->GetSdrObject();
2626  OSL_ENSURE( pObj,
2627  "<SwXShape::ConvertStartOrEndPosToLayoutDir(..)> - no SdrObject found!");
2628  if ( pObj )
2629  {
2630  // get position of object in Writer coordinate system.
2631  awt::Point aPos( getPosition() );
2632  // get position of object in Drawing layer coordinate system
2633  const Point aTmpObjPos( pObj->GetSnapRect().TopLeft() );
2634  const awt::Point aObjPos(
2635  convertTwipToMm100( aTmpObjPos.X() - pObj->GetAnchorPos().X() ),
2636  convertTwipToMm100( aTmpObjPos.Y() - pObj->GetAnchorPos().Y() ) );
2637  // determine difference between these positions according to the
2638  // Writer coordinate system
2639  const awt::Point aTranslateDiff( aPos.X - aObjPos.X,
2640  aPos.Y - aObjPos.Y );
2641  // apply translation difference to PolyPolygonBezier.
2642  if ( aTranslateDiff.X != 0 || aTranslateDiff.Y != 0 )
2643  {
2645  aTranslateDiff.X, aTranslateDiff.Y));
2646 
2647  for(drawing::PointSequence& rInnerSequence : aConvertedPath.Coordinates)
2648  {
2649  for(awt::Point& rPoint : rInnerSequence)
2650  {
2651  basegfx::B2DPoint aNewCoordinatePair(rPoint.X, rPoint.Y);
2652  aNewCoordinatePair *= aMatrix;
2653  rPoint.X = basegfx::fround(aNewCoordinatePair.getX());
2654  rPoint.Y = basegfx::fround(aNewCoordinatePair.getY());
2655  }
2656  }
2657  }
2658  }
2659  }
2660 
2661  return aConvertedPath;
2662 }
2663 
2664 SwXGroupShape::SwXGroupShape(uno::Reference<XInterface> & xShape,
2665  SwDoc const*const pDoc)
2666  : SwXShape(xShape, pDoc)
2667 {
2668 #if OSL_DEBUG_LEVEL > 0
2669  uno::Reference<XShapes> xShapes(xShapeAgg, uno::UNO_QUERY);
2670  OSL_ENSURE(xShapes.is(), "no SvxShape found or shape is not a group shape");
2671 #endif
2672 }
2673 
2675 {
2676 }
2677 
2679 {
2680  uno::Any aRet;
2681  if(rType == cppu::UnoType<XShapes>::get())
2682  aRet <<= uno::Reference<XShapes>(this);
2683  else
2684  aRet = SwXShape::queryInterface(rType);
2685  return aRet;
2686 }
2687 
2688 void SwXGroupShape::acquire( ) throw()
2689 {
2691 }
2692 
2693 void SwXGroupShape::release( ) throw()
2694 {
2696 }
2697 
2698 void SwXGroupShape::add( const uno::Reference< XShape >& xShape )
2699 {
2700  SolarMutexGuard aGuard;
2701  SvxShape* pSvxShape = GetSvxShape();
2702  SwFrameFormat* pFormat = GetFrameFormat();
2703  if(!(pSvxShape && pFormat))
2704  throw uno::RuntimeException();
2705 
2706  uno::Reference<XShapes> xShapes;
2707  if( xShapeAgg.is() )
2708  {
2709  const uno::Type& rType = cppu::UnoType<XShapes>::get();
2710  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2711  aAgg >>= xShapes;
2712  }
2713  if(!xShapes.is())
2714  throw uno::RuntimeException();
2715 
2716  xShapes->add(xShape);
2717 
2718 
2719  uno::Reference<lang::XUnoTunnel> xTunnel(xShape, uno::UNO_QUERY);
2720  SwXShape* pSwShape = nullptr;
2721  if(xShape.is())
2722  pSwShape = reinterpret_cast< SwXShape * >(
2723  sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXShape::getUnoTunnelId()) ));
2724  if(pSwShape && pSwShape->m_bDescriptor)
2725  {
2726  SvxShape* pAddShape = reinterpret_cast< SvxShape * >(
2727  sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SvxShape::getUnoTunnelId()) ));
2728  if(pAddShape)
2729  {
2730  SdrObject* pObj = pAddShape->GetSdrObject();
2731  if(pObj)
2732  {
2733  SwDoc* pDoc = pFormat->GetDoc();
2734  // set layer of new drawing
2735  // object to corresponding invisible layer.
2736  if( SdrInventor::FmForm != pObj->GetObjInventor())
2737  {
2738  pObj->SetLayer( pSwShape->pImpl->GetOpaque()
2741  }
2742  else
2743  {
2745  }
2746  }
2747  }
2748  pSwShape->m_bDescriptor = false;
2749  //add the group member to the format of the group
2750  SwFrameFormat* pShapeFormat = ::FindFrameFormat( pSvxShape->GetSdrObject() );
2751 
2752  if(pShapeFormat)
2753  pSwShape->SetFrameFormat(pShapeFormat);
2754  }
2755 
2756 }
2757 
2758 void SwXGroupShape::remove( const uno::Reference< XShape >& xShape )
2759 {
2760  SolarMutexGuard aGuard;
2761  uno::Reference<XShapes> xShapes;
2762  if( xShapeAgg.is() )
2763  {
2764  const uno::Type& rType = cppu::UnoType<XShapes>::get();
2765  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2766  aAgg >>= xShapes;
2767  }
2768  if(!xShapes.is())
2769  throw uno::RuntimeException();
2770  xShapes->remove(xShape);
2771 }
2772 
2774 {
2775  SolarMutexGuard aGuard;
2776  uno::Reference<XIndexAccess> xAcc;
2777  if( xShapeAgg.is() )
2778  {
2780  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2781  aAgg >>= xAcc;
2782  }
2783  if(!xAcc.is())
2784  throw uno::RuntimeException();
2785  return xAcc->getCount();
2786 }
2787 
2789 {
2790  SolarMutexGuard aGuard;
2791  uno::Reference<XIndexAccess> xAcc;
2792  if( xShapeAgg.is() )
2793  {
2795  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2796  aAgg >>= xAcc;
2797  }
2798  if(!xAcc.is())
2799  throw uno::RuntimeException();
2800  return xAcc->getByIndex(nIndex);
2801 }
2802 
2804 {
2805  SolarMutexGuard aGuard;
2806  uno::Reference<XIndexAccess> xAcc;
2807  if( xShapeAgg.is() )
2808  {
2810  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2811  aAgg >>= xAcc;
2812  }
2813  if(!xAcc.is())
2814  throw uno::RuntimeException();
2815  return xAcc->getElementType();
2816 }
2817 
2819 {
2820  SolarMutexGuard aGuard;
2821  uno::Reference<XIndexAccess> xAcc;
2822  if( xShapeAgg.is() )
2823  {
2825  uno::Any aAgg = xShapeAgg->queryAggregation( rType );
2826  aAgg >>= xAcc;
2827  }
2828  if(!xAcc.is())
2829  throw uno::RuntimeException();
2830  return xAcc->hasElements();
2831 }
2832 
2833 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Point TopLeft() const
static css::uno::Reference< css::drawing::XShapeGroup > GetShapeGroup(SdrObject *pObj)
Definition: unodraw.cxx:306
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: unodraw.cxx:1740
std::unique_ptr< SwFormatFollowTextFlow > m_pFollowTextFlow
Definition: unodraw.cxx:91
void SetRelativeWidthRelation(sal_Int16 eValue)
#define MID_CHAIN_NAME
Definition: unomid.h:58
void SelectObjectsInView(const css::uno::Reference< css::drawing::XShapes > &aShapes, SdrPageView *pPageView)
const css::uno::WeakReference< css::uno::XInterface > & getWeakUnoShape() const
SwXGroupShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *pDoc)
Definition: unodraw.cxx:2664
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:2773
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unodraw.cxx:1948
SvxULSpaceItem * GetULSpace(bool bCreate=false)
Definition: unodraw.cxx:169
bool hasValue()
virtual const SwDoc * GetDoc() const =0
svx::PropertyChangeNotifier & getShapePropertyChangeNotifier()
static css::uno::Any getByIndex(SdrPage const *pPage, sal_Int32 nIndex)
Get a shape by index, excluding TextBoxes.
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:35
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
bool IsGrfNode() const
Definition: node.hxx:656
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
SwShapeDescriptor_Impl(const SwShapeDescriptor_Impl &)=delete
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
std::unique_ptr< SwFormatWrapInfluenceOnObjPos > m_pWrapInfluenceOnObjPos
Definition: unodraw.cxx:93
virtual const SwRootFrame * GetCurrentLayout() const =0
std::unique_ptr< SwShapeDescriptor_Impl > pImpl
Definition: unodraw.hxx:150
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
const bool & GetOpaque() const
Definition: unodraw.cxx:185
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:527
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unodraw.cxx:1037
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:2803
SwNodeIndex nNode
Definition: pam.hxx:37
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &aType) override
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unodraw.cxx:1010
sal_uInt16 char char * pDesc
bool IsOpaque() const
Definition: unodraw.cxx:181
static void destroy(SwFrameFormat *pShape)
Destroy a TextBox for a shape.
virtual SdrLayerID GetInvisibleControlsId() const =0
SwFormatSurround * GetSurround(bool bCreate=false)
Definition: unodraw.cxx:153
std::enable_if< std::is_signed< T >::value, T >::type saturating_sub(T a, T b)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:2152
#define MID_FRMSIZE_REL_WIDTH
Definition: unomid.h:72
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
SwFormatWrapInfluenceOnObjPos * GetWrapInfluenceOnObjPos(const bool _bCreate=false)
Definition: unodraw.cxx:234
const SwFrameFormat * GetFrameFormat() const
Definition: unoframe.hxx:152
Reference< XFrame > xFrame
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:466
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unodraw.cxx:1961
static sal_Int32 getOrdNum(const SdrObject *pObject)
Get the order of the shape, excluding TextBoxes.
double getX() const
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
bool IsInserted() const
Definition: doc.hxx:184
SdrObject * GetTopGroupObj(SvxShape *_pSvxShape=nullptr)
method to determine top group object
Definition: unodraw.cxx:2328
void SetRelativeHeightRelation(sal_Int16 eValue)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
OUString getImplementationName()
SvxLRSpaceItem * GetLRSpace(bool bCreate=false)
Definition: unodraw.cxx:161
double getY() const
SwNode & GetNode() const
Definition: ndindex.hxx:119
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
Definition: unodraw.cxx:311
long SwTwips
Definition: swtypes.hxx:49
virtual void SAL_CALL dispose() override
Definition: unodraw.cxx:2080
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:994
sal_Int16 GetPositionLayoutDir() const
Definition: unodraw.cxx:212
SdrMark * GetMark(size_t nNum) const
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
SwFormatHoriOrient * GetHOrient(bool bCreate=false)
Definition: unodraw.cxx:127
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
const SwFmDrawPage * m_pPage
Definition: unodraw.hxx:139
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:2818
sal_uInt16 Which() const
Definition: txatbase.hxx:110
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
virtual void SAL_CALL acquire() SAL_OVERRIDE
EmbeddedObjectRef * pObject
void PreUnGroup(const css::uno::Reference< css::drawing::XShapeGroup > &rShapeGroup)
Definition: unodraw.cxx:270
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unotext.cxx:1199
virtual css::uno::Reference< css::drawing::XShapeGroup > SAL_CALL group(const css::uno::Reference< css::drawing::XShapes > &xShapes) override
Definition: unodraw.cxx:742
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
SfxHintId GetId() const
SwShapeDescriptor_Impl * GetDescImpl()
Definition: unodraw.hxx:258
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
SwFrameFormat * m_pFormat
Definition: unodraw.hxx:140
static css::uno::Any queryInterface(const SwFrameFormat *pShape, const css::uno::Type &rType)
Get interface of a shape's TextBox, if there is any.
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:154
virtual const tools::Rectangle & GetSnapRect() const
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3051
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
virtual void SAL_CALL acquire() override
Definition: unodraw.cxx:2688
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:423
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:733
SwXDrawPage(SwDoc *pDoc)
Definition: unodraw.cxx:471
virtual css::uno::Reference< css::uno::XInterface > getUnoShape()
#define MID_FRMSIZE_SIZE
Definition: unomid.h:70
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
bool IsMore() const
SwIndex nContent
Definition: pam.hxx:38
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual css::awt::Point SAL_CALL getPosition() override
Definition: unodraw.cxx:2175
virtual ~SwXGroupShape() override
Definition: unodraw.cxx:2674
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:450
const OUString & GetName() const
Definition: format.hxx:111
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
int nCount
void RemovePageView()
Definition: unodraw.cxx:282
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2131
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2460
SdrPageView * GetPageView()
Definition: unodraw.cxx:275
void SetRelativeHeight(double nValue)
bool enum2int(sal_Int32 &rnEnum, const css::uno::Any &rAny)
std::enable_if< !(detail::IsDerivedReference< T >::value||detail::IsUnoSequenceType< T >::value||std::is_base_of< css::uno::XInterface, T >::value), typename detail::Optional< T >::type >::type tryAccess(css::uno::Any const &any)
const SfxItemPropertyMapEntry * m_pPropertyMapEntries
Definition: unodraw.hxx:148
bool bInitializedPropertyNotifier
Definition: unodraw.cxx:101
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
Definition: thints.cxx:1255
long Top() const
void getPropertyValue(const SfxItemPropertySimpleEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
void SetRelativeWidth(double nValue)
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:456
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
#define FN_ANCHOR_POSITION
Definition: cmdid.h:808
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1981
void UnmarkAll()
SdrPage * mpPage
#define FN_TEXT_RANGE
Definition: cmdid.h:800
virtual css::uno::Reference< css::drawing::XShape > CreateShape(SdrObject *pObj) const override
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:952
constexpr TypedWhichId< SwFormatWrapInfluenceOnObjPos > RES_WRAP_INFLUENCE_ON_OBJPOS(125)
SdrPageView * pPageView
Definition: unodraw.hxx:46
B2IRange fround(const B2DRange &rRange)
void SetPositionLayoutDir(sal_Int16 _nPositionLayoutDir)
Definition: unodraw.cxx:216
std::unique_ptr< SwFormatSurround > m_pSurround
Definition: unodraw.cxx:85
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: unodraw.cxx:1732
bool IsOLENode() const
Definition: node.hxx:652
void registerProvider(const ShapeProperty _eProperty, const std::shared_ptr< IPropertyValueProvider > &_rProvider)
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual SdrLayerID GetInvisibleHellId() const =0
SwDrawContact * GroupSelection(SdrView &)
Definition: docdraw.cxx:181
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
ContactObject for connection between frames (or their formats respectively) in SwClient and the drawo...
Definition: dcontact.hxx:175
exports com.sun.star. text
virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const &rType) SAL_OVERRIDE
css::awt::Point GetAttrPosition()
method to determine position according to the positioning attributes
Definition: unodraw.cxx:2352
sal_Int16 mnPositionLayoutDir
Definition: unodraw.cxx:95
SdrObject * GetMarkedSdrObj() const
SwShapeDescriptor_Impl & operator=(const SwShapeDescriptor_Impl &)=delete
#define MID_CHAIN_NEXTNAME
Definition: unomid.h:57
void EndListeningAll()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unodraw.cxx:2157
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
css::drawing::HomogenMatrix3 ConvertTransformationToLayoutDir(const css::drawing::HomogenMatrix3 &rMatrixInHoriL2R)
method to convert the transformation of the drawing object to the layout direction, the drawing object is in
Definition: unodraw.cxx:2437
virtual void SetLayer(SdrLayerID nLayer)
virtual sal_Bool SAL_CALL hasElements() override
Definition: unodraw.cxx:544
#define MID_ANCHOR_ANCHORTYPE
Definition: unomid.h:43
Style of a layout element.
Definition: frmfmt.hxx:57
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unodraw.cxx:1015
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
css::uno::Sequence< OUString > getSupportedServiceNames()
#define FN_SHAPE_POSITION_LAYOUT_DIR
Definition: cmdid.h:815
uno::Reference< text::XTextRange > xTextRange
Definition: unodraw.cxx:89
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
virtual void SAL_CALL setPosition(const css::awt::Point &aPosition) override
#define FN_SHAPE_TRANSFORMATION_IN_HORI_L2R
Definition: cmdid.h:814
std::unique_ptr< SvxULSpaceItem > m_pULSpace
Definition: unodraw.cxx:86
virtual SwFrameFormat::tLayoutDir GetLayoutDir() const
Definition: atrfrm.cxx:2774
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
void SelectObjectInView(const css::uno::Reference< css::drawing::XShape > &xShape, SdrPageView *pPageView)
#define FN_SHAPE_STARTPOSITION_IN_HORI_L2R
Definition: cmdid.h:816
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SvxShape * GetSvxShape()
Definition: unodraw.cxx:2166
uno::Reference< text::XTextRange > & GetTextRange()
Definition: unodraw.cxx:177
css::awt::Point ConvertStartOrEndPosToLayoutDir(const css::awt::Point &aStartOrEndPos)
method to convert start or end position of the drawing object to the Writer specific position...
Definition: unodraw.cxx:2577
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
std::enable_if< std::is_signed< T >::value, T >::type saturating_add(T a, T b)
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
std::unique_ptr< SdrView > mpView
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unodraw.cxx:848
SwDoc * GetDoc()
Definition: node.hxx:702
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SwDoc * GetDoc() const
Definition: pam.hxx:243
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2637
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:486
unsigned char sal_Bool
virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2758
void UnGroupSelection(SdrView &)
Definition: docdraw.cxx:286
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::container::XEnumeration > SwSimpleEnumeration_Base
const SfxItemPropertyMap & getPropertyMap() const
static void getProperty(SwFrameFormat const *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, css::uno::Any &rValue)
Get a property of the underlying TextFrame.
virtual const SdrObject * GetMaster() const override
Definition: dcontact.hxx:349
bool IsNoTextNode() const
Definition: node.hxx:648
bool IsGroupObject() const
SwFmDrawPage * GetSvxPage()
Definition: unodraw.cxx:812
void setPropertyValue(const SfxItemPropertySimpleEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
SdrView * GetDrawView()
Definition: unodraw.hxx:55
css::uno::Reference< css::drawing::XShape > mxShape
Definition: unodraw.hxx:145
Marks a node in the document model.
Definition: ndindex.hxx:31
css::uno::Type const & get()
std::vector< SwXShape * > m_vShapes
Definition: unodraw.hxx:47
bool GoInDoc(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:942
SwFormatAnchor * GetAnchor(bool bCreate=false)
Definition: unodraw.cxx:119
SwXShape(css::uno::Reference< css::uno::XInterface > &xShape, SwDoc const *const pDoc)
Definition: unodraw.cxx:882
void RemoveWrapInfluenceOnObjPos()
Definition: unodraw.cxx:245
std::unique_ptr< SvxLRSpaceItem > m_pLRSpace
Definition: unodraw.cxx:87
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
SwShapeDescriptor_Impl(SwDoc const *const pDoc)
Definition: unodraw.cxx:104
virtual sal_Int32 SAL_CALL getCount() override
Definition: unodraw.cxx:513
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoport.cxx:779
static css::uno::Reference< css::drawing::XShape > GetShape(SdrObject *pObj)
Definition: unodraw.cxx:289
const SfxItemPropertySimpleEntry * getByName(const OUString &rName) const
const double * GetRelativeWidth() const
stay with the cursor inside text
sal_Int16 GetRelativeWidthRelation() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
OUString GetName() const
virtual SdrInventor GetObjInventor() const
virtual SdrLayerID GetHellId() const =0
virtual SdrLayerID GetLayer() const
virtual ~SwXDrawPage() override
Definition: unodraw.cxx:477
std::unique_ptr< SwFormatAnchor > m_pAnchor
Definition: unodraw.cxx:84
void SetFrameFormat(SwFrameFormat *pFormat)
Definition: unodraw.hxx:202
OUString GetUniqueShapeName() const
Definition: doclay.cxx:1383
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
#define FN_TEXT_BOX
Definition: cmdid.h:819
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
static void AddExistingShapeToFormat(SdrObject const &_rObj)
Definition: unodraw.cxx:929
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:794
SwFormatVertOrient * GetVOrient(bool bCreate=false)
Definition: unodraw.cxx:136
css::drawing::PolyPolygonBezierCoords ConvertPolyPolygonBezierToLayoutDir(const css::drawing::PolyPolygonBezierCoords &aPath)
method to convert PolyPolygonBezier of the drawing object to the Writer specific position, which is the attribute position in layout direction
Definition: unodraw.cxx:2615
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:555
constexpr sal_uInt16 RES_FRMATR_END(131)
SdrObject * Next()
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
void DeleteAttributes(const sal_uInt16 nWhich, const sal_Int32 nStart, const sal_Int32 nEnd=0)
delete all attributes of type nWhich at nStart (opt. end nEnd)
Definition: thints.cxx:1704
#define MID_FRMSIZE_REL_HEIGHT_RELATION
Definition: unomid.h:88
const SwDoc * GetDoc() const
Definition: unotext.cxx:130
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
#define FN_SHAPE_ENDPOSITION_IN_HORI_L2R
Definition: cmdid.h:817
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unodraw.cxx:449
virtual void SAL_CALL add(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:2698
SwFormatFollowTextFlow * GetFollowTextFlow(bool _bCreate=false)
Definition: unodraw.cxx:198
virtual OUString SAL_CALL getImplementationName() override
Definition: unodraw.cxx:2147
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
#define MID_ANCHOR_ANCHORFRAME
Definition: unomid.h:45
constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unodraw.cxx:1430
#define MID_CHAIN_PREVNAME
Definition: unomid.h:56
SfxItemState
virtual css::awt::Point SAL_CALL getPosition() override
virtual sal_Bool SAL_CALL hasElements() override
SwFmDrawPage(SdrPage *pPage)
Definition: unodraw.cxx:251
oslInterlockedCount m_refCount
#define SAL_WARN_IF(condition, area, stream)
virtual SdrLayerID GetInvisibleHeavenId() const =0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
static void create(SwFrameFormat *pShape)
Create a TextBox for a shape.
virtual ~SwXShape() override
Definition: unodraw.cxx:959
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
css::uno::Reference< css::uno::XAggregation > xShapeAgg
Definition: unodraw.hxx:142
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:2678
#define PROPERTY_MAP_TEXT_SHAPE
Definition: unomap.hxx:40
css::uno::Reference< css::uno::XAggregation > xPageAgg
Definition: unodraw.hxx:84
#define MID_FRMSIZE_REL_WIDTH_RELATION
Definition: unomid.h:87
virtual sal_Int16 GetPositionLayoutDir() const
Definition: atrfrm.cxx:2785
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unodraw.cxx:505
sal_Int32 GetIndex() const
Definition: index.hxx:95
virtual void SAL_CALL setPosition(const css::awt::Point &aPosition) override
Definition: unodraw.cxx:2213
virtual SwDrawModel * GetOrCreateDrawModel()=0
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
SwNodes & GetNodes()
Definition: doc.hxx:403
SwUnoCursor & GetCursor() const
Definition: unoport.hxx:229
SdrObject * GetSdrObject() const
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3153
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unodraw.cxx:853
std::unique_ptr< SwFormatHoriOrient > m_pHOrient
Definition: unodraw.cxx:82
const SwTextNode * GetTextNode() const
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:89
SwDoc * pDoc
Definition: unodraw.hxx:83
Sequence< sal_Int8 > aSeq
virtual void SAL_CALL remove(const css::uno::Reference< css::drawing::XShape > &xShape) override
Definition: unodraw.cxx:733
static sal_Int32 getCount(const SwDoc *pDoc)
Count number of shapes in the document, excluding TextBoxes.
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
void AdjustPositionProperties(const css::awt::Point &rPosition)
method to adjust the positioning properties
Definition: unodraw.cxx:2501
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
std::unique_ptr< SwFormatVertOrient > m_pVOrient
Definition: unodraw.cxx:83
long Left() const
void translate(double fX, double fY)
css::uno::Any _getPropAtAggrObj(const OUString &_rPropertyName)
method to get property from aggregation object
Definition: unodraw.cxx:1715
const Point & GetAnchorPos() const
void InvalidateSwDoc()
Renamed and outlined to detect where it's called.
Definition: unodraw.cxx:838
Format of a fly content.
Definition: fmtflcnt.hxx:32
constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SdrObject * getParentSdrObjectFromSdrObject() const
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:93
virtual void SAL_CALL release() SAL_OVERRIDE
virtual css::awt::Size SAL_CALL getSize() override
Definition: unodraw.cxx:2295
css::awt::Point ConvertPositionToHoriL2R(const css::awt::Point &rObjPos, const css::awt::Size &rObjSize)
method to convert the position (translation) of the drawing object to the layout direction horizontal...
Definition: unodraw.cxx:2396
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
#define MID_FRMSIZE_REL_HEIGHT
Definition: unomid.h:71
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unodraw.cxx:974
virtual void SAL_CALL ungroup(const css::uno::Reference< css::drawing::XShapeGroup > &aGroup) override
Definition: unodraw.cxx:788
sal_Int16 GetRelativeHeightRelation() const
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
static void syncProperty(SwFrameFormat *pShape, sal_uInt16 nWID, sal_uInt8 nMemberID, const css::uno::Any &rValue)
Sync property of TextBox with the one of the shape.
Reference< XModel > xModel
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2317
RndStdIds
const SfxItemPropertySet * m_pPropSet
Definition: unodraw.hxx:147
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unodraw.cxx:461
static css::uno::Reference< css::text::XTextContent > CreateXTextEmbeddedObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3445
static css::uno::Reference< css::text::XTextContent > CreateXTextGraphicObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3398
virtual void SAL_CALL release() override
Definition: unodraw.cxx:2693
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unodraw.cxx:2139
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1054
B2DHomMatrix createTranslateB2DHomMatrix(double fTranslateX, double fTranslateY)
virtual void Notify(const SfxHint &) override
Definition: unodraw.cxx:1988
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: unodraw.cxx:1915
constexpr TypedWhichId< SwFormatFollowTextFlow > RES_FOLLOW_TEXT_FLOW(123)
virtual ~SwFmDrawPage() override
Definition: unodraw.cxx:256
const SdrMarkList & PreGroup(const css::uno::Reference< css::drawing::XShapes > &rShapes)
Definition: unodraw.cxx:263
void InsertEntry(const SdrMark &rMark, bool bChkSort=true)
void SetOpaque(bool bSet)
Definition: unodraw.cxx:195
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unodraw.cxx:2788
bool m_bDescriptor
Definition: unodraw.hxx:152
SwFrameFormat * GetFrameFormat() const
Definition: unodraw.hxx:259
SdrObjUserCall * GetUserCall() const
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: unodraw.cxx:1854
bool Is3DObj() const
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
virtual OUString SAL_CALL getShapeType() override
Definition: unodraw.cxx:2317
virtual void SetPositionLayoutDir(const sal_Int16 _nPositionLayoutDir)
Definition: atrfrm.cxx:2789
SdrObject * FindSdrObject()
Definition: frmfmt.hxx:137
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2706
sal_Int32 GetEnumAsInt32(const css::uno::Any &rVal)
Definition: swunohelper.cxx:49
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unodraw.cxx:539
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unodraw.cxx:1997
SwFmDrawPage * pDrawPage
Definition: unodraw.hxx:85
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
Definition: docfly.cxx:711
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1315
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
Definition: unodraw.cxx:2058
virtual void SAL_CALL setSize(const css::awt::Size &aSize) override
Definition: unodraw.cxx:2305
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
bool HasHints() const
Definition: ndtxt.hxx:221
const double * GetRelativeHeight() const
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1483
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unodraw.cxx:1974
const SwFormatFlyCnt & GetFlyCnt() const
Definition: txatbase.hxx:206
Base class of the Writer document model elements.
Definition: node.hxx:79