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