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