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