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