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