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