Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <comphelper/uno3.hxx>
31 : : #include <comphelper/stl_types.hxx>
32 : : #include <svtools/unoevent.hxx>
33 : : #include <svtools/unoimap.hxx>
34 : : #include <svx/svdobj.hxx>
35 : : #include <vcl/svapp.hxx>
36 : : #include <svx/unoshape.hxx>
37 : : #include <editeng/unofield.hxx>
38 : : #include <svx/shapepropertynotifier.hxx>
39 : : #include <toolkit/helper/convert.hxx>
40 : : #include <cppuhelper/implbase2.hxx>
41 : :
42 : : #include <com/sun/star/drawing/XShape.hpp>
43 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
44 : :
45 : : #include "shapeuno.hxx"
46 : : #include "miscuno.hxx"
47 : : #include "cellsuno.hxx"
48 : : #include "textuno.hxx"
49 : : #include "fielduno.hxx"
50 : : #include "docsh.hxx"
51 : : #include "drwlayer.hxx"
52 : : #include "userdat.hxx"
53 : : #include "unonames.hxx"
54 : :
55 : : using namespace ::com::sun::star;
56 : :
57 : : //------------------------------------------------------------------------
58 : :
59 : : DECLARE_STL_USTRINGACCESS_MAP( uno::Sequence< sal_Int8 > *, ScShapeImplementationIdMap );
60 : :
61 : 51 : static ScShapeImplementationIdMap aImplementationIdMap;
62 : :
63 : 79 : const SfxItemPropertyMapEntry* lcl_GetShapeMap()
64 : : {
65 : : static SfxItemPropertyMapEntry aShapeMap_Impl[] =
66 : : {
67 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_ANCHOR), 0, &getCppuType((uno::Reference<uno::XInterface>*)0), 0, 0 },
68 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_HORIPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
69 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_IMAGEMAP), 0, &getCppuType((uno::Reference<container::XIndexContainer>*)0), 0, 0 },
70 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_VERTPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
71 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_MOVEPROTECT), 0, &getCppuType((sal_Bool*)0), 0, 0 },
72 : : // #i66550 HLINK_FOR_SHAPES
73 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
74 [ + - ]: 9 : {MAP_CHAR_LEN(SC_UNONAME_URL), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
75 : :
76 : : {0,0,0,0,0,0}
77 [ + + ][ + - ]: 88 : };
[ # # ]
78 : 79 : return aShapeMap_Impl;
79 : : }
80 : :
81 : 3 : const SvEventDescription* ScShapeObj::GetSupportedMacroItems()
82 : : {
83 : : static const SvEventDescription aMacroDescriptionsImpl[] =
84 : : {
85 : : { 0, NULL }
86 : : };
87 : 3 : return aMacroDescriptionsImpl;
88 : : }
89 : : // #i66550 HLINK_FOR_SHAPES
90 : 0 : ScMacroInfo* lcl_getShapeHyperMacroInfo( ScShapeObj* pShape, sal_Bool bCreate = false )
91 : : {
92 [ # # ]: 0 : if( pShape )
93 [ # # ]: 0 : if( SdrObject* pObj = pShape->GetSdrObject() )
94 : 0 : return ScDrawLayer::GetMacroInfo( pObj, bCreate );
95 : 0 : return 0;
96 : : }
97 : :
98 : : //------------------------------------------------------------------------
99 : :
100 : : namespace
101 : : {
102 : 108 : void lcl_initializeNotifier( SdrObject& _rSdrObj, ::cppu::OWeakObject& _rShape )
103 : : {
104 [ + - ][ + - ]: 108 : ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "Anchor" ) );
[ + - ]
105 [ + - ][ + - ]: 108 : _rSdrObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eSpreadsheetAnchor, pProvider );
[ + - ][ + - ]
[ + - ]
106 : 108 : }
107 : : }
108 : :
109 : : //------------------------------------------------------------------------
110 : :
111 : 206 : ScShapeObj::ScShapeObj( uno::Reference<drawing::XShape>& xShape ) :
112 : : pShapePropertySet(NULL),
113 : : pShapePropertyState(NULL),
114 : : pImplementationId(NULL),
115 : : bIsTextShape(false),
116 : 206 : bInitializedNotifier(false)
117 : : {
118 [ + - ]: 206 : comphelper::increment( m_refCount );
119 : :
120 : : {
121 [ + - ][ + - ]: 206 : mxShapeAgg = uno::Reference<uno::XAggregation>( xShape, uno::UNO_QUERY );
122 : : // extra block to force deletion of the temporary before setDelegator
123 : : }
124 : :
125 [ + - ]: 206 : if (mxShapeAgg.is())
126 : : {
127 [ + - ]: 206 : xShape = NULL; // during setDelegator, mxShapeAgg must be the only ref
128 : :
129 [ + - ][ + - ]: 206 : mxShapeAgg->setDelegator( (cppu::OWeakObject*)this );
[ + - ]
130 : :
131 [ + - ][ + - ]: 206 : xShape.set(uno::Reference<drawing::XShape>( mxShapeAgg, uno::UNO_QUERY ));
132 : :
133 [ + - ]: 206 : bIsTextShape = ( SvxUnoTextBase::getImplementation( mxShapeAgg ) != NULL );
134 : : }
135 : :
136 : : {
137 : 206 : SdrObject* pObj = GetSdrObject();
138 [ + + ]: 206 : if ( pObj )
139 : : {
140 [ + - ]: 108 : lcl_initializeNotifier( *pObj, *this );
141 : 108 : bInitializedNotifier = true;
142 : : }
143 : : }
144 : :
145 [ + - ]: 206 : comphelper::decrement( m_refCount );
146 : 206 : }
147 : :
148 : 206 : ScShapeObj::~ScShapeObj()
149 : : {
150 : : // if (mxShapeAgg.is())
151 : : // mxShapeAgg->setDelegator(uno::Reference<uno::XInterface>());
152 [ - + ]: 412 : }
153 : :
154 : : // XInterface
155 : :
156 : 3052 : uno::Any SAL_CALL ScShapeObj::queryInterface( const uno::Type& rType )
157 : : throw(uno::RuntimeException)
158 : : {
159 : 3052 : uno::Any aRet = ScShapeObj_Base::queryInterface( rType );
160 : :
161 [ + + ][ + + ]: 3052 : if ( !aRet.hasValue() && bIsTextShape )
[ + + ]
162 [ + - ]: 1403 : aRet = ScShapeObj_TextBase::queryInterface( rType );
163 : :
164 [ + + ][ + - ]: 3052 : if ( !aRet.hasValue() && mxShapeAgg.is() )
[ + + ]
165 [ + - ][ + - ]: 1926 : aRet = mxShapeAgg->queryAggregation( rType );
166 : :
167 : 3052 : return aRet;
168 : : }
169 : :
170 : 42813 : void SAL_CALL ScShapeObj::acquire() throw()
171 : : {
172 : 42813 : OWeakObject::acquire();
173 : 42813 : }
174 : :
175 : 42813 : void SAL_CALL ScShapeObj::release() throw()
176 : : {
177 : 42813 : OWeakObject::release();
178 : 42813 : }
179 : :
180 : 763 : void ScShapeObj::GetShapePropertySet()
181 : : {
182 : : // #i61908# Store the result of queryAggregation in a member.
183 : : // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
184 : :
185 [ + + ]: 763 : if (!pShapePropertySet)
186 : : {
187 : 84 : uno::Reference<beans::XPropertySet> xProp;
188 [ + - ]: 84 : if ( mxShapeAgg.is() )
189 [ + - ][ + - ]: 84 : mxShapeAgg->queryAggregation( getCppuType((uno::Reference<beans::XPropertySet>*) 0) ) >>= xProp;
[ + - ][ + - ]
190 [ + - ]: 84 : pShapePropertySet = xProp.get();
191 : : }
192 : 763 : }
193 : :
194 : 0 : void ScShapeObj::GetShapePropertyState()
195 : : {
196 : : // #i61908# Store the result of queryAggregation in a member.
197 : : // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
198 : :
199 [ # # ]: 0 : if (!pShapePropertyState)
200 : : {
201 : 0 : uno::Reference<beans::XPropertyState> xState;
202 [ # # ]: 0 : if ( mxShapeAgg.is() )
203 [ # # ][ # # ]: 0 : mxShapeAgg->queryAggregation( getCppuType((uno::Reference<beans::XPropertyState>*) 0) ) >>= xState;
[ # # ][ # # ]
204 [ # # ]: 0 : pShapePropertyState = xState.get();
205 : : }
206 : 0 : }
207 : :
208 : 28 : uno::Reference<lang::XComponent> lcl_GetComponent( const uno::Reference<uno::XAggregation>& xAgg )
209 : : {
210 : 28 : uno::Reference<lang::XComponent> xRet;
211 [ + - ]: 28 : if ( xAgg.is() )
212 [ + - ][ + - ]: 28 : xAgg->queryAggregation( getCppuType((uno::Reference<lang::XComponent>*) 0) ) >>= xRet;
[ + - ][ + - ]
213 : 28 : return xRet;
214 : : }
215 : :
216 : 0 : uno::Reference<text::XText> lcl_GetText( const uno::Reference<uno::XAggregation>& xAgg )
217 : : {
218 : 0 : uno::Reference<text::XText> xRet;
219 [ # # ]: 0 : if ( xAgg.is() )
220 [ # # ][ # # ]: 0 : xAgg->queryAggregation( getCppuType((uno::Reference<text::XText>*) 0) ) >>= xRet;
[ # # ][ # # ]
221 : 0 : return xRet;
222 : : }
223 : :
224 : 24 : uno::Reference<text::XSimpleText> lcl_GetSimpleText( const uno::Reference<uno::XAggregation>& xAgg )
225 : : {
226 : 24 : uno::Reference<text::XSimpleText> xRet;
227 [ + - ]: 24 : if ( xAgg.is() )
228 [ + - ][ + - ]: 24 : xAgg->queryAggregation( getCppuType((uno::Reference<text::XSimpleText>*) 0) ) >>= xRet;
[ + - ][ + - ]
229 : 24 : return xRet;
230 : : }
231 : :
232 : 0 : uno::Reference<text::XTextRange> lcl_GetTextRange( const uno::Reference<uno::XAggregation>& xAgg )
233 : : {
234 : 0 : uno::Reference<text::XTextRange> xRet;
235 [ # # ]: 0 : if ( xAgg.is() )
236 [ # # ][ # # ]: 0 : xAgg->queryAggregation( getCppuType((uno::Reference<text::XTextRange>*) 0) ) >>= xRet;
[ # # ][ # # ]
237 : 0 : return xRet;
238 : : }
239 : :
240 : : // XPropertySet
241 : :
242 : 201 : uno::Reference<beans::XPropertySetInfo> SAL_CALL ScShapeObj::getPropertySetInfo()
243 : : throw(uno::RuntimeException)
244 : : {
245 [ + - ]: 201 : SolarMutexGuard aGuard;
246 : :
247 : : // #i61527# cache property set info for this object
248 [ + + ]: 201 : if ( !mxPropSetInfo.is() )
249 : : {
250 : : // mix own and aggregated properties:
251 [ + - ]: 79 : GetShapePropertySet();
252 [ + - ]: 79 : if (pShapePropertySet)
253 : : {
254 [ + - ]: 79 : uno::Reference<beans::XPropertySetInfo> xAggInfo(pShapePropertySet->getPropertySetInfo());
255 [ + - ][ + - ]: 79 : const uno::Sequence<beans::Property> aPropSeq(xAggInfo->getProperties());
256 [ + - ][ + - ]: 79 : mxPropSetInfo.set(new SfxExtItemPropertySetInfo( lcl_GetShapeMap(), aPropSeq ));
[ + - ][ + - ]
[ + - ]
257 : : }
258 : : }
259 [ + - ]: 201 : return mxPropSetInfo;
260 : : }
261 : :
262 : 36 : sal_Bool lcl_GetPageNum( SdrPage* pPage, SdrModel& rModel, SCTAB& rNum )
263 : : {
264 : 36 : sal_uInt16 nCount = rModel.GetPageCount();
265 [ + - ]: 36 : for (sal_uInt16 i=0; i<nCount; i++)
266 [ + - ]: 36 : if ( rModel.GetPage(i) == pPage )
267 : : {
268 : 36 : rNum = static_cast<SCTAB>(i);
269 : 36 : return sal_True;
270 : : }
271 : :
272 : 36 : return false;
273 : : }
274 : :
275 : 26 : sal_Bool lcl_GetCaptionPoint( uno::Reference< drawing::XShape >& xShape, awt::Point& rCaptionPoint )
276 : : {
277 : 26 : sal_Bool bReturn = false;
278 [ + - ][ + - ]: 26 : rtl::OUString sType(xShape->getShapeType());
279 : 26 : sal_Bool bCaptionShape( sType == "com.sun.star.drawing.CaptionShape" );
280 [ - + ]: 26 : if (bCaptionShape)
281 : : {
282 [ # # ]: 0 : uno::Reference < beans::XPropertySet > xShapeProp (xShape, uno::UNO_QUERY);
283 [ # # ]: 0 : if (xShapeProp.is())
284 : : {
285 [ # # ][ # # ]: 0 : xShapeProp->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )) ) >>= rCaptionPoint;
[ # # ][ # # ]
286 : 0 : bReturn = sal_True;
287 : 0 : }
288 : : }
289 : 26 : return bReturn;
290 : : }
291 : :
292 : 14 : ScRange lcl_GetAnchorCell( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab,
293 : : awt::Point& rUnoPoint, awt::Size& rUnoSize, awt::Point& rCaptionPoint )
294 : : {
295 : 14 : ScRange aReturn;
296 [ + - ][ + - ]: 14 : rUnoPoint = xShape->getPosition();
297 [ + - ][ + - ]: 14 : rtl::OUString sType(xShape->getShapeType());
298 [ + - ]: 14 : sal_Bool bCaptionShape(lcl_GetCaptionPoint(xShape, rCaptionPoint));
299 [ + - ][ - + ]: 14 : if (pDoc->IsNegativePage(nTab))
300 : : {
301 [ # # ][ # # ]: 0 : rUnoSize = xShape->getSize();
302 : 0 : rUnoPoint.X += rUnoSize.Width; // the right top point is base
303 [ # # ]: 0 : if (bCaptionShape)
304 : : {
305 [ # # ][ # # ]: 0 : if (rCaptionPoint.X > 0 && rCaptionPoint.X > rUnoSize.Width)
306 : 0 : rUnoPoint.X += rCaptionPoint.X - rUnoSize.Width;
307 [ # # ]: 0 : if (rCaptionPoint.Y < 0)
308 : 0 : rUnoPoint.Y += rCaptionPoint.Y;
309 : : }
310 [ # # ][ # # ]: 0 : aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
311 : : }
312 : : else
313 : : {
314 [ - + ]: 14 : if (bCaptionShape)
315 : : {
316 [ # # ]: 0 : if (rCaptionPoint.X < 0)
317 : 0 : rUnoPoint.X += rCaptionPoint.X;
318 [ # # ]: 0 : if (rCaptionPoint.Y < 0)
319 : 0 : rUnoPoint.Y += rCaptionPoint.Y;
320 : : }
321 [ + - ][ + - ]: 14 : aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
322 : : }
323 : :
324 : 14 : return aReturn;
325 : : }
326 : :
327 : 14 : awt::Point lcl_GetRelativePos( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab, ScRange& rRange,
328 : : awt::Size& rUnoSize, awt::Point& rCaptionPoint)
329 : : {
330 : 14 : awt::Point aUnoPoint;
331 [ + - ]: 14 : rRange = lcl_GetAnchorCell(xShape, pDoc, nTab, aUnoPoint, rUnoSize, rCaptionPoint);
332 [ + - ]: 14 : Rectangle aRect(pDoc->GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aStart.Tab() ));
333 [ + - ][ - + ]: 14 : Point aPoint = pDoc->IsNegativePage(nTab) ? aRect.TopRight() : aRect.TopLeft();
[ # # ]
334 : 14 : aUnoPoint.X -= aPoint.X();
335 : 14 : aUnoPoint.Y -= aPoint.Y();
336 : 14 : return aUnoPoint;
337 : : }
338 : :
339 : 685 : void SAL_CALL ScShapeObj::setPropertyValue(
340 : : const rtl::OUString& aPropertyName, const uno::Any& aValue )
341 : : throw(beans::UnknownPropertyException, beans::PropertyVetoException,
342 : : lang::IllegalArgumentException, lang::WrappedTargetException,
343 : : uno::RuntimeException)
344 : : {
345 [ + - ]: 685 : SolarMutexGuard aGuard;
346 [ + - ]: 685 : String aNameString(aPropertyName);
347 : :
348 [ + - ][ + + ]: 685 : if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
349 : : {
350 [ + - ]: 2 : uno::Reference<sheet::XCellRangeAddressable> xRangeAdd(aValue, uno::UNO_QUERY);
351 [ + - ]: 2 : if (xRangeAdd.is())
352 : : {
353 : 2 : SdrObject *pObj = GetSdrObject();
354 [ + - ]: 2 : if (pObj)
355 : : {
356 [ + - ]: 2 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
357 [ + - ]: 2 : SdrPage* pPage = pObj->GetPage();
358 [ + - ][ + - ]: 2 : if ( pModel && pPage )
359 : : {
360 : 2 : ScDocument* pDoc = pModel->GetDocument();
361 [ + - ]: 2 : if ( pDoc )
362 : : {
363 : 2 : SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
364 [ + - ][ + - ]: 2 : if ( pObjSh && pObjSh->ISA(ScDocShell) )
[ + - ][ + - ]
[ + - ]
365 : : {
366 : 2 : ScDocShell* pDocSh = (ScDocShell*)pObjSh;
367 : :
368 : 2 : SCTAB nTab = 0;
369 [ + - ][ + - ]: 2 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
370 : : {
371 [ + - ][ + - ]: 2 : table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
372 [ + - ]: 2 : if (nTab == aAddress.Sheet)
373 : : {
374 : : Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
375 [ + - ]: 2 : static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
376 : 2 : awt::Point aRelPoint;
377 [ + - ]: 2 : uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
378 [ + - ]: 2 : if (xShape.is())
379 : : {
380 : 2 : Point aPoint;
381 : 2 : Point aEndPoint;
382 [ - + ][ + - ]: 2 : if (pDoc->IsNegativePage(nTab))
383 : : {
384 [ # # ]: 0 : aPoint = aRect.TopRight();
385 [ # # ]: 0 : aEndPoint = aRect.BottomLeft();
386 : : }
387 : : else
388 : : {
389 : 2 : aPoint = aRect.TopLeft();
390 [ + - ]: 2 : aEndPoint = aRect.BottomRight();
391 : : }
392 : 2 : awt::Size aUnoSize;
393 : 2 : awt::Point aCaptionPoint;
394 : 2 : ScRange aRange;
395 [ + - ]: 2 : aRelPoint = lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint );
396 : 2 : awt::Point aUnoPoint(aRelPoint);
397 : :
398 : 2 : aUnoPoint.X += aPoint.X();
399 : 2 : aUnoPoint.Y += aPoint.Y();
400 : :
401 [ - + ]: 2 : if ( aUnoPoint.Y > aEndPoint.Y() )
402 : 0 : aUnoPoint.Y = aEndPoint.Y() - 2;
403 [ + - ][ - + ]: 2 : if (pDoc->IsNegativePage(nTab))
404 : : {
405 [ # # ]: 0 : if ( aUnoPoint.X < aEndPoint.X() )
406 : 0 : aUnoPoint.X = aEndPoint.X() + 2;
407 : 0 : aUnoPoint.X -= aUnoSize.Width;
408 : : // remove difference to caption point
409 [ # # ][ # # ]: 0 : if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
410 : 0 : aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
411 : : }
412 : : else
413 : : {
414 [ - + ]: 2 : if ( aUnoPoint.X > aEndPoint.X() )
415 : 0 : aUnoPoint.X = aEndPoint.X() - 2;
416 [ - + ]: 2 : if (aCaptionPoint.X < 0)
417 : 0 : aUnoPoint.X -= aCaptionPoint.X;
418 : : }
419 [ - + ]: 2 : if (aCaptionPoint.Y < 0)
420 : 0 : aUnoPoint.Y -= aCaptionPoint.Y;
421 : :
422 [ + - ][ + - ]: 2 : xShape->setPosition(aUnoPoint);
423 [ + - ]: 2 : pDocSh->SetModified();
424 : : }
425 : :
426 [ - + ]: 2 : if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
427 : : {
428 : : OSL_ENSURE(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
429 : : aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
430 [ # # ]: 0 : ScDrawLayer::SetPageAnchored(*pObj);
431 : : }
432 : : else
433 : : {
434 : : OSL_ENSURE(aAddress.StartRow == aAddress.EndRow &&
435 : : aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
436 [ + - ]: 2 : ScDrawObjData aAnchor;
437 : 2 : aAnchor.maStart = ScAddress(aAddress.StartColumn, aAddress.StartRow, aAddress.Sheet);
438 : 2 : aAnchor.maStartOffset = Point(aRelPoint.X, aRelPoint.Y);
439 [ + - ]: 2 : ScDrawLayer::SetCellAnchored(*pObj, aAnchor);
440 : : //Currently we've only got a start anchor, not an end-anchor, so generate that now
441 [ + - ][ + - ]: 2 : ScDrawLayer::UpdateCellAnchorFromPositionEnd(*pObj, *pDoc, aAddress.Sheet);
442 : 2 : }
443 : : }
444 : : }
445 : : }
446 : : }
447 : : }
448 : : }
449 : : }
450 : : else
451 [ # # ][ # # ]: 2 : throw lang::IllegalArgumentException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("only XCell or XSpreadsheet objects allowed")), static_cast<cppu::OWeakObject*>(this), 0);
[ # # ]
452 : : }
453 [ + - ][ - + ]: 683 : else if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
454 : : {
455 : 0 : SdrObject* pObj = GetSdrObject();
456 [ # # ]: 0 : if ( pObj )
457 : : {
458 [ # # ]: 0 : ImageMap aImageMap;
459 [ # # ]: 0 : uno::Reference< uno::XInterface > xImageMapInt(aValue, uno::UNO_QUERY);
460 : :
461 [ # # ][ # # ]: 0 : if( !xImageMapInt.is() || !SvUnoImageMap_fillImageMap( xImageMapInt, aImageMap ) )
[ # # ][ # # ]
[ # # # # ]
462 [ # # ]: 0 : throw lang::IllegalArgumentException();
463 : :
464 [ # # ]: 0 : ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
465 [ # # ]: 0 : if( pIMapInfo )
466 : : {
467 : : // replace existing image map
468 [ # # ]: 0 : pIMapInfo->SetImageMap( aImageMap );
469 : : }
470 : : else
471 : : {
472 : : // insert new user data with image map
473 [ # # ][ # # ]: 0 : pObj->AppendUserData(new ScIMapInfo(aImageMap) );
[ # # ]
474 [ # # ]: 0 : }
475 : : }
476 : : }
477 [ + - ][ + + ]: 683 : else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
478 : : {
479 : 2 : sal_Int32 nPos = 0;
480 [ + - ]: 2 : if (aValue >>= nPos)
481 : : {
482 : 2 : SdrObject *pObj = GetSdrObject();
483 [ + - ]: 2 : if (pObj)
484 : : {
485 [ + - ]: 2 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
486 [ + - ]: 2 : SdrPage* pPage = pObj->GetPage();
487 [ + - ][ + - ]: 2 : if ( pModel && pPage )
488 : : {
489 : 2 : SCTAB nTab = 0;
490 [ + - ][ + - ]: 2 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
491 : : {
492 : 2 : ScDocument* pDoc = pModel->GetDocument();
493 [ + - ]: 2 : if ( pDoc )
494 : : {
495 : 2 : SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
496 [ + - ][ + - ]: 2 : if ( pObjSh && pObjSh->ISA(ScDocShell) )
[ + - ][ + - ]
[ + - ]
497 : : {
498 : 2 : ScDocShell* pDocSh = (ScDocShell*)pObjSh;
499 [ + - ]: 2 : uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
500 [ + - ]: 2 : if (xShape.is())
501 : : {
502 [ + - ][ - + ]: 2 : if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
503 : : {
504 [ # # ][ # # ]: 0 : awt::Point aPoint(xShape->getPosition());
505 [ # # ][ # # ]: 0 : awt::Size aSize(xShape->getSize());
506 : 0 : awt::Point aCaptionPoint;
507 [ # # ][ # # ]: 0 : if (pDoc->IsNegativePage(nTab))
508 : : {
509 : 0 : nPos *= -1;
510 : 0 : nPos -= aSize.Width;
511 : : }
512 [ # # ][ # # ]: 0 : if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
513 : : {
514 [ # # ][ # # ]: 0 : if (pDoc->IsNegativePage(nTab))
515 : : {
516 [ # # ][ # # ]: 0 : if (aCaptionPoint.X > 0 && aCaptionPoint.X > aSize.Width)
517 : 0 : nPos -= aCaptionPoint.X - aSize.Width;
518 : : }
519 : : else
520 : : {
521 [ # # ]: 0 : if (aCaptionPoint.X < 0)
522 : 0 : nPos -= aCaptionPoint.X;
523 : : }
524 : : }
525 : 0 : aPoint.X = nPos;
526 [ # # ][ # # ]: 0 : xShape->setPosition(aPoint);
527 [ # # ]: 0 : pDocSh->SetModified();
528 : : }
529 [ + - ][ + - ]: 2 : else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
530 : : {
531 : 2 : awt::Size aUnoSize;
532 : 2 : awt::Point aCaptionPoint;
533 : 2 : ScRange aRange;
534 [ + - ]: 2 : awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
535 [ + - ]: 2 : Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
536 [ + - ][ - + ]: 2 : if (pDoc->IsNegativePage(nTab))
537 : : {
538 : 0 : aUnoPoint.X = -nPos;
539 [ # # ]: 0 : Point aPoint(aRect.TopRight());
540 [ # # ]: 0 : Point aEndPoint(aRect.BottomLeft());
541 : 0 : aUnoPoint.X += aPoint.X();
542 [ # # ]: 0 : if (aUnoPoint.X < aEndPoint.X())
543 : 0 : aUnoPoint.X = aEndPoint.X() + 2;
544 : 0 : aUnoPoint.X -= aUnoSize.Width;
545 [ # # ][ # # ]: 0 : if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
546 : 0 : aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
547 : : }
548 : : else
549 : : {
550 : 2 : aUnoPoint.X = nPos;
551 : 2 : Point aPoint(aRect.TopLeft());
552 [ + - ]: 2 : Point aEndPoint(aRect.BottomRight());
553 : 2 : aUnoPoint.X += aPoint.X();
554 [ - + ]: 2 : if (aUnoPoint.X > aEndPoint.X())
555 : 0 : aUnoPoint.X = aEndPoint.X() - 2;
556 [ - + ]: 2 : if (aCaptionPoint.X < 0)
557 : 2 : aUnoPoint.X -= aCaptionPoint.X;
558 : : }
559 [ + - ][ + - ]: 2 : aUnoPoint.Y = xShape->getPosition().Y;
560 [ + - ][ + - ]: 2 : xShape->setPosition(aUnoPoint);
561 [ + - ]: 2 : pDocSh->SetModified();
562 : : }
563 : : else
564 : : {
565 : : OSL_FAIL("unknown anchor type");
566 : : }
567 : 2 : }
568 : : }
569 : : }
570 : : }
571 : : }
572 : : }
573 : : }
574 : : }
575 [ + - ][ + + ]: 681 : else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
576 : : {
577 : 2 : sal_Int32 nPos = 0;
578 [ + - ]: 2 : if (aValue >>= nPos)
579 : : {
580 : 2 : SdrObject *pObj = GetSdrObject();
581 [ + - ]: 2 : if (pObj)
582 : : {
583 [ + - ]: 2 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
584 [ + - ]: 2 : SdrPage* pPage = pObj->GetPage();
585 [ + - ][ + - ]: 2 : if ( pModel && pPage )
586 : : {
587 : 2 : SCTAB nTab = 0;
588 [ + - ][ + - ]: 2 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
589 : : {
590 : 2 : ScDocument* pDoc = pModel->GetDocument();
591 [ + - ]: 2 : if ( pDoc )
592 : : {
593 : 2 : SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
594 [ + - ][ + - ]: 2 : if ( pObjSh && pObjSh->ISA(ScDocShell) )
[ + - ][ + - ]
[ + - ]
595 : : {
596 : 2 : ScDocShell* pDocSh = (ScDocShell*)pObjSh;
597 [ + - ]: 2 : uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
598 [ + - ]: 2 : if (xShape.is())
599 : : {
600 [ + - ][ - + ]: 2 : if (ScDrawLayer::GetAnchorType(*pObj) == SCA_PAGE)
601 : : {
602 [ # # ][ # # ]: 0 : awt::Point aPoint = xShape->getPosition();
603 : 0 : awt::Point aCaptionPoint;
604 [ # # ][ # # ]: 0 : if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
605 : : {
606 [ # # ]: 0 : if (aCaptionPoint.Y < 0)
607 : 0 : nPos -= aCaptionPoint.Y;
608 : : }
609 : 0 : aPoint.Y = nPos;
610 [ # # ][ # # ]: 0 : xShape->setPosition(aPoint);
611 [ # # ]: 0 : pDocSh->SetModified();
612 : : }
613 [ + - ][ + - ]: 2 : else if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
614 : : {
615 : 2 : awt::Size aUnoSize;
616 : 2 : awt::Point aCaptionPoint;
617 : 2 : ScRange aRange;
618 [ + - ]: 2 : awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
619 [ + - ]: 2 : Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
620 [ + - ]: 2 : Point aPoint(aRect.TopRight());
621 [ + - ]: 2 : Point aEndPoint(aRect.BottomLeft());
622 : 2 : aUnoPoint.Y = nPos;
623 : 2 : aUnoPoint.Y += aPoint.Y();
624 [ + - ]: 2 : if (aUnoPoint.Y > aEndPoint.Y())
625 : 2 : aUnoPoint.Y = aEndPoint.Y() - 2;
626 [ - + ]: 2 : if (aCaptionPoint.Y < 0)
627 : 0 : aUnoPoint.Y -= aCaptionPoint.Y;
628 [ + - ][ + - ]: 2 : aUnoPoint.X = xShape->getPosition().X;
629 [ + - ][ + - ]: 2 : xShape->setPosition(aUnoPoint);
630 [ + - ]: 2 : pDocSh->SetModified();
631 : : }
632 : : else
633 : : {
634 : : OSL_FAIL("unknown anchor type");
635 : : }
636 : 2 : }
637 : : }
638 : : }
639 : : }
640 : : }
641 : : }
642 : : }
643 : : }
644 [ + - ][ + - ]: 1358 : else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) ||
[ - + ][ - + ]
645 [ + - ]: 679 : aNameString.EqualsAscii( SC_UNONAME_URL) )
646 : : {
647 : 0 : rtl::OUString sHlink;
648 [ # # ]: 0 : ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this, true);
649 [ # # ][ # # ]: 0 : if ( ( aValue >>= sHlink ) && pInfo )
[ # # ]
650 : 0 : pInfo->SetHlink( sHlink );
651 : : }
652 [ + - ][ + + ]: 679 : else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
653 : : {
654 [ + - ]: 3 : if( SdrObject* pObj = this->GetSdrObject() )
655 : : {
656 : 3 : sal_Bool aProt = false;
657 [ + - ]: 3 : if( aValue >>= aProt )
658 [ + - ]: 3 : pObj->SetMoveProtect( aProt );
659 : : }
660 : : }
661 : : else
662 : : {
663 [ + - ]: 676 : GetShapePropertySet();
664 [ + - ]: 676 : if (pShapePropertySet)
665 [ + - ]: 676 : pShapePropertySet->setPropertyValue( aPropertyName, aValue );
666 [ + - ][ + - ]: 685 : }
667 : 685 : }
668 : :
669 : 38 : uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyName )
670 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
671 : : uno::RuntimeException)
672 : : {
673 [ + - ]: 38 : SolarMutexGuard aGuard;
674 [ + - ]: 38 : String aNameString = aPropertyName;
675 : :
676 : 38 : uno::Any aAny;
677 [ + + ][ + - ]: 38 : if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
678 : : {
679 : 10 : SdrObject *pObj = GetSdrObject();
680 [ + - ]: 10 : if (pObj)
681 : : {
682 [ + - ]: 10 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
683 [ + - ]: 10 : SdrPage* pPage = pObj->GetPage();
684 [ + - ][ + - ]: 10 : if ( pModel && pPage )
685 : : {
686 : 10 : ScDocument* pDoc = pModel->GetDocument();
687 [ + - ]: 10 : if ( pDoc )
688 : : {
689 : 10 : SCTAB nTab = 0;
690 [ + - ][ + - ]: 10 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
691 : : {
692 : 10 : SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
693 [ + - ][ + - ]: 10 : if ( pObjSh && pObjSh->ISA(ScDocShell) )
[ + - ][ + - ]
[ + - ]
694 : : {
695 : 10 : ScDocShell* pDocSh = (ScDocShell*)pObjSh;
696 : 10 : uno::Reference< uno::XInterface > xAnchor;
697 [ + + ][ + - ]: 10 : if (ScDrawObjData *pAnchor = ScDrawLayer::GetObjDataTab(pObj, nTab))
698 [ + - ][ + - ]: 2 : xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, pAnchor->maStart)));
[ + - ]
699 : : else
700 [ + - ][ + - ]: 8 : xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
[ + - ]
701 [ + - ]: 10 : aAny <<= xAnchor;
702 : : }
703 : : }
704 : : }
705 : : }
706 : : }
707 : : }
708 [ + - ][ - + ]: 28 : else if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
709 : : {
710 : 0 : uno::Reference< uno::XInterface > xImageMap;
711 : 0 : SdrObject* pObj = GetSdrObject();
712 [ # # ]: 0 : if ( pObj )
713 : : {
714 [ # # ]: 0 : ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(GetSdrObject());
715 [ # # ]: 0 : if( pIMapInfo )
716 : : {
717 : 0 : const ImageMap& rIMap = pIMapInfo->GetImageMap();
718 [ # # ][ # # ]: 0 : xImageMap.set(SvUnoImageMap_createInstance( rIMap, GetSupportedMacroItems() ));
719 : : }
720 : : else
721 [ # # ][ # # ]: 0 : xImageMap = SvUnoImageMap_createInstance( GetSupportedMacroItems() );
722 : : }
723 [ # # ][ # # ]: 0 : aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
724 : : }
725 [ + - ][ + + ]: 28 : else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
726 : : {
727 : 10 : SdrObject *pObj = GetSdrObject();
728 [ + - ]: 10 : if (pObj)
729 : : {
730 [ + - ]: 10 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
731 [ + - ]: 10 : SdrPage* pPage = pObj->GetPage();
732 [ + - ][ + - ]: 10 : if ( pModel && pPage )
733 : : {
734 : 10 : ScDocument* pDoc = pModel->GetDocument();
735 [ + - ]: 10 : if ( pDoc )
736 : : {
737 : 10 : SCTAB nTab = 0;
738 [ + - ][ + - ]: 10 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
739 : : {
740 [ + - ]: 10 : uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
741 [ + - ]: 10 : if (xShape.is())
742 : : {
743 [ + - ][ + + ]: 10 : if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
744 : : {
745 : 4 : awt::Size aUnoSize;
746 : 4 : awt::Point aCaptionPoint;
747 : 4 : ScRange aRange;
748 [ + - ]: 4 : awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
749 [ + - ][ - + ]: 4 : if (pDoc->IsNegativePage(nTab))
750 : 0 : aUnoPoint.X *= -1;
751 [ + - ]: 4 : aAny <<= aUnoPoint.X;
752 : : }
753 : : else
754 : : {
755 : 6 : awt::Point aCaptionPoint;
756 [ + - ][ + - ]: 6 : awt::Point aUnoPoint(xShape->getPosition());
757 [ + - ][ + - ]: 6 : awt::Size aUnoSize(xShape->getSize());
758 [ + - ][ + + ]: 6 : if (pDoc->IsNegativePage(nTab))
759 : : {
760 : 2 : aUnoPoint.X *= -1;
761 : 2 : aUnoPoint.X -= aUnoSize.Width;
762 : : }
763 [ + - ][ - + ]: 6 : if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
764 : : {
765 [ # # ][ # # ]: 0 : if (pDoc->IsNegativePage(nTab))
766 : : {
767 [ # # ][ # # ]: 0 : if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
768 : 0 : aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
769 : : }
770 : : else
771 : : {
772 [ # # ]: 0 : if (aCaptionPoint.X < 0)
773 : 0 : aUnoPoint.X += aCaptionPoint.X;
774 : : }
775 : : }
776 [ + - ]: 6 : aAny <<= aUnoPoint.X;
777 : : }
778 : 10 : }
779 : : }
780 : : }
781 : : }
782 : : }
783 : : }
784 [ + - ][ + + ]: 18 : else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
785 : : {
786 : 10 : SdrObject *pObj = GetSdrObject();
787 [ + - ]: 10 : if (pObj)
788 : : {
789 [ + - ]: 10 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
790 [ + - ]: 10 : SdrPage* pPage = pObj->GetPage();
791 [ + - ][ + - ]: 10 : if ( pModel && pPage )
792 : : {
793 : 10 : ScDocument* pDoc = pModel->GetDocument();
794 [ + - ]: 10 : if ( pDoc )
795 : : {
796 : 10 : SCTAB nTab = 0;
797 [ + - ][ + - ]: 10 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
798 : : {
799 [ + - ]: 10 : uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
800 [ + - ]: 10 : if (xShape.is())
801 : : {
802 : 10 : uno::Reference< uno::XInterface > xAnchor;
803 [ + + ][ + - ]: 10 : if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
804 : : {
805 : 4 : awt::Size aUnoSize;
806 : 4 : awt::Point aCaptionPoint;
807 : 4 : ScRange aRange;
808 [ + - ]: 4 : awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
809 : :
810 [ + - ]: 4 : aAny <<= aUnoPoint.Y;
811 : : }
812 : : else
813 : : {
814 [ + - ][ + - ]: 6 : awt::Point aUnoPoint(xShape->getPosition());
815 : 6 : awt::Point aCaptionPoint;
816 [ - + ][ + - ]: 6 : if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
817 : : {
818 [ # # ]: 0 : if (aCaptionPoint.Y < 0)
819 : 0 : aUnoPoint.Y += aCaptionPoint.Y;
820 : : }
821 [ + - ]: 6 : aAny <<= aUnoPoint.Y;
822 : 10 : }
823 : 10 : }
824 : : }
825 : : }
826 : : }
827 : : }
828 : : }
829 [ + - ][ + - ]: 16 : else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) ||
[ - + ][ - + ]
830 [ + - ]: 8 : aNameString.EqualsAscii( SC_UNONAME_URL ) )
831 : : {
832 : 0 : rtl::OUString sHlink;
833 [ # # ][ # # ]: 0 : if ( ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this) )
834 : 0 : sHlink = pInfo->GetHlink();
835 [ # # ]: 0 : aAny <<= sHlink;
836 : : }
837 [ + - ][ - + ]: 8 : else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
838 : : {
839 : 0 : sal_Bool aProt = false;
840 [ # # ]: 0 : if ( SdrObject* pObj = this->GetSdrObject() )
841 [ # # ]: 0 : aProt = pObj->IsMoveProtect();
842 [ # # ]: 0 : aAny <<= aProt;
843 : : }
844 : : else
845 : : {
846 [ + - ]: 8 : GetShapePropertySet();
847 [ + - ]: 8 : if (pShapePropertySet)
848 [ + - ]: 8 : aAny = pShapePropertySet->getPropertyValue( aPropertyName );
849 : : }
850 : :
851 [ + - ][ + - ]: 38 : return aAny;
852 : : }
853 : :
854 : 0 : void SAL_CALL ScShapeObj::addPropertyChangeListener( const rtl::OUString& aPropertyName,
855 : : const uno::Reference<beans::XPropertyChangeListener>& aListener)
856 : : throw(beans::UnknownPropertyException,
857 : : lang::WrappedTargetException, uno::RuntimeException)
858 : : {
859 [ # # ]: 0 : SolarMutexGuard aGuard;
860 : :
861 [ # # ]: 0 : GetShapePropertySet();
862 [ # # ]: 0 : if (pShapePropertySet)
863 [ # # ]: 0 : pShapePropertySet->addPropertyChangeListener( aPropertyName, aListener );
864 : :
865 [ # # ]: 0 : if ( !bInitializedNotifier )
866 : : {
867 : : // here's the latest chance to initialize the property notification at the SdrObject
868 : : // (in the ctor, where we also attempt to do this, we do not necessarily have
869 : : // and SdrObject, yet)
870 : 0 : SdrObject* pObj = GetSdrObject();
871 : : OSL_ENSURE( pObj, "ScShapeObj::addPropertyChangeListener: no SdrObject -> no property change notification!" );
872 [ # # ]: 0 : if ( pObj )
873 [ # # ]: 0 : lcl_initializeNotifier( *pObj, *this );
874 : 0 : bInitializedNotifier = true;
875 [ # # ]: 0 : }
876 : 0 : }
877 : :
878 : 0 : void SAL_CALL ScShapeObj::removePropertyChangeListener( const rtl::OUString& aPropertyName,
879 : : const uno::Reference<beans::XPropertyChangeListener>& aListener)
880 : : throw(beans::UnknownPropertyException,
881 : : lang::WrappedTargetException, uno::RuntimeException)
882 : : {
883 [ # # ]: 0 : SolarMutexGuard aGuard;
884 : :
885 [ # # ]: 0 : GetShapePropertySet();
886 [ # # ]: 0 : if (pShapePropertySet)
887 [ # # ][ # # ]: 0 : pShapePropertySet->removePropertyChangeListener( aPropertyName, aListener );
888 : 0 : }
889 : :
890 : 0 : void SAL_CALL ScShapeObj::addVetoableChangeListener( const rtl::OUString& aPropertyName,
891 : : const uno::Reference<beans::XVetoableChangeListener>& aListener)
892 : : throw(beans::UnknownPropertyException,
893 : : lang::WrappedTargetException, uno::RuntimeException)
894 : : {
895 [ # # ]: 0 : SolarMutexGuard aGuard;
896 : :
897 [ # # ]: 0 : GetShapePropertySet();
898 [ # # ]: 0 : if (pShapePropertySet)
899 [ # # ][ # # ]: 0 : pShapePropertySet->addVetoableChangeListener( aPropertyName, aListener );
900 : 0 : }
901 : :
902 : 0 : void SAL_CALL ScShapeObj::removeVetoableChangeListener( const rtl::OUString& aPropertyName,
903 : : const uno::Reference<beans::XVetoableChangeListener>& aListener)
904 : : throw(beans::UnknownPropertyException,
905 : : lang::WrappedTargetException, uno::RuntimeException)
906 : : {
907 [ # # ]: 0 : SolarMutexGuard aGuard;
908 : :
909 [ # # ]: 0 : GetShapePropertySet();
910 [ # # ]: 0 : if (pShapePropertySet)
911 [ # # ][ # # ]: 0 : pShapePropertySet->removeVetoableChangeListener( aPropertyName, aListener );
912 : 0 : }
913 : :
914 : : // XPropertyState
915 : :
916 : 0 : beans::PropertyState SAL_CALL ScShapeObj::getPropertyState( const rtl::OUString& aPropertyName )
917 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
918 : : {
919 [ # # ]: 0 : SolarMutexGuard aGuard;
920 [ # # ]: 0 : String aNameString(aPropertyName);
921 : :
922 : 0 : beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
923 [ # # ][ # # ]: 0 : if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
924 : : {
925 : : // ImageMap is always "direct"
926 : : }
927 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
928 : : {
929 : : // Anchor is always "direct"
930 : : }
931 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
932 : : {
933 : : // HoriPos is always "direct"
934 : : }
935 [ # # ][ # # ]: 0 : else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
936 : : {
937 : : // VertPos is always "direct"
938 : : }
939 : : else
940 : : {
941 [ # # ]: 0 : GetShapePropertyState();
942 [ # # ]: 0 : if (pShapePropertyState)
943 [ # # ]: 0 : eRet = pShapePropertyState->getPropertyState( aPropertyName );
944 : : }
945 : :
946 [ # # ][ # # ]: 0 : return eRet;
947 : : }
948 : :
949 : 0 : uno::Sequence<beans::PropertyState> SAL_CALL ScShapeObj::getPropertyStates(
950 : : const uno::Sequence<rtl::OUString>& aPropertyNames )
951 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
952 : : {
953 [ # # ]: 0 : SolarMutexGuard aGuard;
954 : :
955 : : // simple loop to get own and aggregated states
956 : :
957 : 0 : const rtl::OUString* pNames = aPropertyNames.getConstArray();
958 [ # # ]: 0 : uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
959 [ # # ]: 0 : beans::PropertyState* pStates = aRet.getArray();
960 [ # # ]: 0 : for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
961 [ # # ]: 0 : pStates[i] = getPropertyState(pNames[i]);
962 [ # # ]: 0 : return aRet;
963 : : }
964 : :
965 : 0 : void SAL_CALL ScShapeObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
966 : : throw(beans::UnknownPropertyException, uno::RuntimeException)
967 : : {
968 [ # # ]: 0 : SolarMutexGuard aGuard;
969 [ # # ]: 0 : String aNameString(aPropertyName);
970 : :
971 [ # # ][ # # ]: 0 : if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
972 : : {
973 : 0 : SdrObject* pObj = GetSdrObject();
974 [ # # ]: 0 : if ( pObj )
975 : : {
976 [ # # ]: 0 : ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
977 [ # # ]: 0 : if( pIMapInfo )
978 : : {
979 [ # # ]: 0 : ImageMap aEmpty;
980 [ # # ][ # # ]: 0 : pIMapInfo->SetImageMap( aEmpty ); // replace with empty image map
981 : : }
982 : : else
983 : : {
984 : : // nothing to do (no need to insert user data for an empty map)
985 : : }
986 : : }
987 : : }
988 : : else
989 : : {
990 [ # # ]: 0 : GetShapePropertyState();
991 [ # # ]: 0 : if (pShapePropertyState)
992 [ # # ]: 0 : pShapePropertyState->setPropertyToDefault( aPropertyName );
993 [ # # ][ # # ]: 0 : }
994 : 0 : }
995 : :
996 : 0 : uno::Any SAL_CALL ScShapeObj::getPropertyDefault( const rtl::OUString& aPropertyName )
997 : : throw(beans::UnknownPropertyException, lang::WrappedTargetException,
998 : : uno::RuntimeException)
999 : : {
1000 [ # # ]: 0 : SolarMutexGuard aGuard;
1001 [ # # ]: 0 : String aNameString = aPropertyName;
1002 : :
1003 : 0 : uno::Any aAny;
1004 [ # # ][ # # ]: 0 : if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
1005 : : {
1006 : : // default: empty ImageMap
1007 [ # # ]: 0 : uno::Reference< uno::XInterface > xImageMap(SvUnoImageMap_createInstance( GetSupportedMacroItems() ));
1008 [ # # ][ # # ]: 0 : aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
1009 : : }
1010 : : else
1011 : : {
1012 [ # # ]: 0 : GetShapePropertyState();
1013 [ # # ]: 0 : if (pShapePropertyState)
1014 [ # # ]: 0 : aAny = pShapePropertyState->getPropertyDefault( aPropertyName );
1015 : : }
1016 : :
1017 [ # # ][ # # ]: 0 : return aAny;
1018 : : }
1019 : :
1020 : : // XTextContent
1021 : :
1022 : 0 : void SAL_CALL ScShapeObj::attach( const uno::Reference<text::XTextRange>& /* xTextRange */ )
1023 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1024 : : {
1025 [ # # ]: 0 : SolarMutexGuard aGuard;
1026 : :
1027 [ # # ]: 0 : throw lang::IllegalArgumentException(); // anchor cannot be changed
1028 : : }
1029 : :
1030 : 0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getAnchor() throw(uno::RuntimeException)
1031 : : {
1032 [ # # ]: 0 : SolarMutexGuard aGuard;
1033 : :
1034 : 0 : uno::Reference<text::XTextRange> xRet;
1035 : :
1036 : 0 : SdrObject* pObj = GetSdrObject();
1037 [ # # ]: 0 : if( pObj )
1038 : : {
1039 [ # # ]: 0 : ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
1040 [ # # ]: 0 : SdrPage* pPage = pObj->GetPage();
1041 [ # # ]: 0 : if ( pModel )
1042 : : {
1043 : 0 : ScDocument* pDoc = pModel->GetDocument();
1044 [ # # ]: 0 : if ( pDoc )
1045 : : {
1046 : 0 : SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
1047 [ # # ][ # # ]: 0 : if ( pObjSh && pObjSh->ISA(ScDocShell) )
[ # # ][ # # ]
[ # # ]
1048 : : {
1049 : 0 : ScDocShell* pDocSh = (ScDocShell*)pObjSh;
1050 : :
1051 : 0 : SCTAB nTab = 0;
1052 [ # # ][ # # ]: 0 : if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
1053 : : {
1054 [ # # ]: 0 : Point aPos(pObj->GetCurrentBoundRect().TopLeft());
1055 [ # # ][ # # ]: 0 : ScRange aRange(pDoc->GetRange( nTab, Rectangle( aPos, aPos ) ));
1056 : :
1057 : : // anchor is always the cell
1058 : :
1059 [ # # ][ # # ]: 0 : xRet.set(new ScCellObj( pDocSh, aRange.aStart ));
[ # # ]
1060 : : }
1061 : : }
1062 : : }
1063 : : }
1064 : : }
1065 : :
1066 [ # # ]: 0 : return xRet;
1067 : : }
1068 : :
1069 : : // XComponent
1070 : :
1071 : 28 : void SAL_CALL ScShapeObj::dispose() throw(uno::RuntimeException)
1072 : : {
1073 [ + - ]: 28 : SolarMutexGuard aGuard;
1074 : :
1075 [ + - ]: 28 : uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
1076 [ + - ]: 28 : if ( xAggComp.is() )
1077 [ + - ][ + - ]: 28 : xAggComp->dispose();
[ + - ]
1078 : 28 : }
1079 : :
1080 : 0 : void SAL_CALL ScShapeObj::addEventListener(
1081 : : const uno::Reference<lang::XEventListener>& xListener )
1082 : : throw(uno::RuntimeException)
1083 : : {
1084 [ # # ]: 0 : SolarMutexGuard aGuard;
1085 : :
1086 [ # # ]: 0 : uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
1087 [ # # ]: 0 : if ( xAggComp.is() )
1088 [ # # ][ # # ]: 0 : xAggComp->addEventListener(xListener);
[ # # ]
1089 : 0 : }
1090 : :
1091 : 0 : void SAL_CALL ScShapeObj::removeEventListener(
1092 : : const uno::Reference<lang::XEventListener>& xListener )
1093 : : throw(uno::RuntimeException)
1094 : : {
1095 [ # # ]: 0 : SolarMutexGuard aGuard;
1096 : :
1097 [ # # ]: 0 : uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
1098 [ # # ]: 0 : if ( xAggComp.is() )
1099 [ # # ][ # # ]: 0 : xAggComp->removeEventListener(xListener);
[ # # ]
1100 : 0 : }
1101 : :
1102 : : // XText
1103 : : // (special handling for ScCellFieldObj)
1104 : :
1105 : 0 : void lcl_CopyOneProperty( beans::XPropertySet& rDest, beans::XPropertySet& rSource, const sal_Char* pName )
1106 : : {
1107 : 0 : rtl::OUString aNameStr(rtl::OUString::createFromAscii(pName));
1108 : : try
1109 : : {
1110 [ # # ][ # # ]: 0 : rDest.setPropertyValue( aNameStr, rSource.getPropertyValue( aNameStr ) );
[ # # ]
1111 : : }
1112 [ # # ]: 0 : catch (uno::Exception&)
1113 : : {
1114 : : OSL_FAIL("Exception in text field");
1115 : 0 : }
1116 : 0 : }
1117 : :
1118 : 0 : void SAL_CALL ScShapeObj::insertTextContent( const uno::Reference<text::XTextRange>& xRange,
1119 : : const uno::Reference<text::XTextContent>& xContent,
1120 : : sal_Bool bAbsorb )
1121 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1122 : : {
1123 [ # # ]: 0 : SolarMutexGuard aGuard;
1124 : :
1125 : 0 : uno::Reference<text::XTextContent> xEffContent;
1126 : :
1127 [ # # ]: 0 : ScEditFieldObj* pCellField = ScEditFieldObj::getImplementation( xContent );
1128 [ # # ]: 0 : if ( pCellField )
1129 : : {
1130 : : // createInstance("TextField.URL") from the document creates a ScCellFieldObj.
1131 : : // To insert it into drawing text, a SvxUnoTextField is needed instead.
1132 : : // The ScCellFieldObj object is left in non-inserted state.
1133 : :
1134 : 0 : SvxUnoTextField* pDrawField = new SvxUnoTextField( text::textfield::Type::URL );
1135 [ # # ][ # # ]: 0 : xEffContent.set(pDrawField);
1136 [ # # ]: 0 : lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_URL );
1137 [ # # ]: 0 : lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_REPR );
1138 [ # # ]: 0 : lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_TARGET );
1139 : : }
1140 : : else
1141 [ # # ]: 0 : xEffContent.set(xContent);
1142 : :
1143 [ # # ]: 0 : uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
1144 [ # # ]: 0 : if ( xAggText.is() )
1145 [ # # ][ # # ]: 0 : xAggText->insertTextContent( xRange, xEffContent, bAbsorb );
[ # # ]
1146 : 0 : }
1147 : :
1148 : 0 : void SAL_CALL ScShapeObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
1149 : : throw(container::NoSuchElementException, uno::RuntimeException)
1150 : : {
1151 [ # # ]: 0 : SolarMutexGuard aGuard;
1152 : :
1153 : : // ScCellFieldObj can't be used here.
1154 : :
1155 [ # # ]: 0 : uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
1156 [ # # ]: 0 : if ( xAggText.is() )
1157 [ # # ][ # # ]: 0 : xAggText->removeTextContent( xContent );
[ # # ]
1158 : 0 : }
1159 : :
1160 : : // XSimpleText (parent of XText)
1161 : : // Use own SvxUnoTextCursor subclass - everything is just passed to aggregated object
1162 : :
1163 : 16 : uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursor()
1164 : : throw(uno::RuntimeException)
1165 : : {
1166 [ + - ]: 16 : SolarMutexGuard aGuard;
1167 : :
1168 [ + - ]: 16 : if ( mxShapeAgg.is() )
1169 : : {
1170 : : // ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
1171 : :
1172 [ + - ]: 16 : SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
1173 [ + - ]: 16 : if (pText)
1174 [ + - ][ + - ]: 16 : return new ScDrawTextCursor( this, *pText );
[ + - ][ + - ]
1175 : : }
1176 : :
1177 [ + - ]: 16 : return uno::Reference<text::XTextCursor>();
1178 : : }
1179 : :
1180 : 16 : uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursorByRange(
1181 : : const uno::Reference<text::XTextRange>& aTextPosition )
1182 : : throw(uno::RuntimeException)
1183 : : {
1184 [ + - ]: 16 : SolarMutexGuard aGuard;
1185 : :
1186 [ + - ][ + - ]: 16 : if ( mxShapeAgg.is() && aTextPosition.is() )
[ + - ]
1187 : : {
1188 : : // ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
1189 : :
1190 [ + - ]: 16 : SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
1191 [ + - ]: 16 : SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
1192 [ + - ][ + - ]: 16 : if ( pText && pRange )
1193 : : {
1194 [ + - ][ + - ]: 16 : SvxUnoTextCursor* pCursor = new ScDrawTextCursor( this, *pText );
1195 [ + - ][ + - ]: 16 : uno::Reference<text::XTextCursor> xCursor( pCursor );
1196 : 16 : pCursor->SetSelection( pRange->GetSelection() );
1197 : 16 : return xCursor;
1198 : : }
1199 : : }
1200 : :
1201 [ + - ]: 16 : return uno::Reference<text::XTextCursor>();
1202 : : }
1203 : :
1204 : 8 : void SAL_CALL ScShapeObj::insertString( const uno::Reference<text::XTextRange>& xRange,
1205 : : const rtl::OUString& aString, sal_Bool bAbsorb )
1206 : : throw(uno::RuntimeException)
1207 : : {
1208 [ + - ]: 8 : SolarMutexGuard aGuard;
1209 : :
1210 [ + - ]: 8 : uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
1211 [ + - ]: 8 : if ( xAggSimpleText.is() )
1212 [ + - ][ + - ]: 8 : xAggSimpleText->insertString( xRange, aString, bAbsorb );
1213 : : else
1214 [ # # ][ + - ]: 8 : throw uno::RuntimeException();
1215 : 8 : }
1216 : :
1217 : 16 : void SAL_CALL ScShapeObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
1218 : : sal_Int16 nControlCharacter, sal_Bool bAbsorb )
1219 : : throw(lang::IllegalArgumentException, uno::RuntimeException)
1220 : : {
1221 [ + - ]: 16 : SolarMutexGuard aGuard;
1222 : :
1223 [ + - ]: 16 : uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
1224 [ + - ]: 16 : if ( xAggSimpleText.is() )
1225 [ + - ][ + - ]: 16 : xAggSimpleText->insertControlCharacter( xRange, nControlCharacter, bAbsorb );
1226 : : else
1227 [ # # ][ + - ]: 16 : throw uno::RuntimeException();
1228 : 16 : }
1229 : :
1230 : : // XTextRange
1231 : : // (parent of XSimpleText)
1232 : :
1233 : 0 : uno::Reference<text::XText> SAL_CALL ScShapeObj::getText() throw(uno::RuntimeException)
1234 : : {
1235 [ # # ]: 0 : SolarMutexGuard aGuard;
1236 [ # # ][ # # ]: 0 : return this;
1237 : : }
1238 : :
1239 : 0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getStart() throw(uno::RuntimeException)
1240 : : {
1241 [ # # ]: 0 : SolarMutexGuard aGuard;
1242 : :
1243 [ # # ]: 0 : uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
1244 [ # # ]: 0 : if ( xAggTextRange.is() )
1245 [ # # ][ # # ]: 0 : return xAggTextRange->getStart();
1246 : : else
1247 [ # # ][ # # ]: 0 : throw uno::RuntimeException();
1248 : :
1249 : : // return uno::Reference<text::XTextRange>();
1250 : : }
1251 : :
1252 : 0 : uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getEnd() throw(uno::RuntimeException)
1253 : : {
1254 [ # # ]: 0 : SolarMutexGuard aGuard;
1255 : :
1256 [ # # ]: 0 : uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
1257 [ # # ]: 0 : if ( xAggTextRange.is() )
1258 [ # # ][ # # ]: 0 : return xAggTextRange->getEnd();
1259 : : else
1260 [ # # ][ # # ]: 0 : throw uno::RuntimeException();
1261 : :
1262 : : // return uno::Reference<text::XTextRange>();
1263 : : }
1264 : :
1265 : 0 : rtl::OUString SAL_CALL ScShapeObj::getString() throw(uno::RuntimeException)
1266 : : {
1267 [ # # ]: 0 : SolarMutexGuard aGuard;
1268 : :
1269 [ # # ]: 0 : uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
1270 [ # # ]: 0 : if ( xAggTextRange.is() )
1271 [ # # ][ # # ]: 0 : return xAggTextRange->getString();
1272 : : else
1273 [ # # ][ # # ]: 0 : throw uno::RuntimeException();
1274 : :
1275 : : // return rtl::OUString();
1276 : : }
1277 : :
1278 : 0 : void SAL_CALL ScShapeObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
1279 : : {
1280 [ # # ]: 0 : SolarMutexGuard aGuard;
1281 : :
1282 [ # # ]: 0 : uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
1283 [ # # ]: 0 : if ( xAggTextRange.is() )
1284 [ # # ][ # # ]: 0 : xAggTextRange->setString( aText );
1285 : : else
1286 [ # # ][ # # ]: 0 : throw uno::RuntimeException();
1287 : 0 : }
1288 : :
1289 : : // XTypeProvider
1290 : :
1291 : 0 : uno::Sequence<uno::Type> SAL_CALL ScShapeObj::getTypes() throw(uno::RuntimeException)
1292 : : {
1293 [ # # ]: 0 : uno::Sequence< uno::Type > aBaseTypes( ScShapeObj_Base::getTypes() );
1294 : :
1295 [ # # ]: 0 : uno::Sequence< uno::Type > aTextTypes;
1296 [ # # ]: 0 : if ( bIsTextShape )
1297 [ # # ][ # # ]: 0 : aTextTypes = ScShapeObj_TextBase::getTypes();
[ # # ]
1298 : :
1299 : 0 : uno::Reference<lang::XTypeProvider> xBaseProvider;
1300 [ # # ]: 0 : if ( mxShapeAgg.is() )
1301 [ # # ][ # # ]: 0 : mxShapeAgg->queryAggregation( getCppuType((uno::Reference<lang::XTypeProvider>*) 0) ) >>= xBaseProvider;
[ # # ][ # # ]
1302 : : OSL_ENSURE( xBaseProvider.is(), "ScShapeObj: No XTypeProvider from aggregated shape!" );
1303 : :
1304 [ # # ]: 0 : uno::Sequence< uno::Type > aAggTypes;
1305 [ # # ]: 0 : if( xBaseProvider.is() )
1306 [ # # ][ # # ]: 0 : aAggTypes = xBaseProvider->getTypes();
[ # # ][ # # ]
1307 : :
1308 [ # # ][ # # ]: 0 : return ::comphelper::concatSequences( aBaseTypes, aTextTypes, aAggTypes );
[ # # ][ # # ]
1309 : : }
1310 : :
1311 : 0 : uno::Sequence<sal_Int8> SAL_CALL ScShapeObj::getImplementationId()
1312 : : throw(uno::RuntimeException)
1313 : : {
1314 [ # # ]: 0 : SolarMutexGuard aGuard;
1315 : : // do we need to compute the implementation id for this instance?
1316 [ # # ][ # # ]: 0 : if( !pImplementationId && mxShapeAgg.is())
[ # # ]
1317 : : {
1318 : 0 : uno::Reference< drawing::XShape > xAggShape;
1319 [ # # ][ # # ]: 0 : mxShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= xAggShape;
[ # # ][ # # ]
1320 : :
1321 [ # # ]: 0 : if( xAggShape.is() )
1322 : : {
1323 [ # # ][ # # ]: 0 : const rtl::OUString aShapeType( xAggShape->getShapeType() );
1324 : : // did we already compute an implementation id for the agregated shape type?
1325 [ # # ]: 0 : ScShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) );
1326 [ # # ]: 0 : if( aIter == aImplementationIdMap.end() )
1327 : : {
1328 : : // we need to create a new implementation id for this
1329 : : // note: this memory is not free'd until application exits
1330 : : // but since we have a fixed set of shapetypes and the
1331 : : // memory will be reused this is ok.
1332 [ # # ]: 0 : pImplementationId = new uno::Sequence< sal_Int8 >( 16 );
1333 [ # # ][ # # ]: 0 : rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True );
1334 [ # # ]: 0 : aImplementationIdMap[ aShapeType ] = pImplementationId;
1335 : : }
1336 : : else
1337 : : {
1338 : : // use the already computed implementation id
1339 : 0 : pImplementationId = (*aIter).second;
1340 : 0 : }
1341 : 0 : }
1342 : : }
1343 [ # # ]: 0 : if( NULL == pImplementationId )
1344 : : {
1345 : : OSL_FAIL( "Could not create an implementation id for a ScXShape!" );
1346 [ # # ]: 0 : return uno::Sequence< sal_Int8 > ();
1347 : : }
1348 : : else
1349 : : {
1350 [ # # ]: 0 : return *pImplementationId;
1351 [ # # ]: 0 : }
1352 : : }
1353 : :
1354 : 245 : SdrObject* ScShapeObj::GetSdrObject() const throw()
1355 : : {
1356 [ + - ]: 245 : if(mxShapeAgg.is())
1357 : : {
1358 : 245 : SvxShape* pShape = SvxShape::getImplementation( mxShapeAgg );
1359 [ + - ]: 245 : if(pShape)
1360 : 245 : return pShape->GetSdrObject();
1361 : : }
1362 : :
1363 : 245 : return NULL;
1364 : : }
1365 : :
1366 : : #define SC_EVENTACC_ONCLICK ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) )
1367 : : #define SC_EVENTACC_SCRIPT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) )
1368 : : #define SC_EVENTACC_EVENTTYPE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) )
1369 : :
1370 : : typedef ::cppu::WeakImplHelper1< container::XNameReplace > ShapeUnoEventAcess_BASE;
1371 [ # # ]: 0 : class ShapeUnoEventAccessImpl : public ShapeUnoEventAcess_BASE
1372 : : {
1373 : : private:
1374 : : ScShapeObj* mpShape;
1375 : :
1376 : 0 : ScMacroInfo* getInfo( sal_Bool bCreate = false )
1377 : : {
1378 : 0 : return lcl_getShapeHyperMacroInfo( mpShape, bCreate );
1379 : : }
1380 : :
1381 : : public:
1382 : 0 : ShapeUnoEventAccessImpl( ScShapeObj* pShape ): mpShape( pShape )
1383 : : {
1384 : 0 : }
1385 : :
1386 : : // XNameReplace
1387 : 0 : virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1388 : : {
1389 [ # # ][ # # ]: 0 : if ( !hasByName( aName ) )
1390 [ # # ]: 0 : throw container::NoSuchElementException();
1391 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aProperties;
1392 [ # # ]: 0 : aElement >>= aProperties;
1393 : 0 : const beans::PropertyValue* pProperties = aProperties.getConstArray();
1394 : 0 : const sal_Int32 nCount = aProperties.getLength();
1395 : : sal_Int32 nIndex;
1396 : 0 : bool isEventType = false;
1397 [ # # ]: 0 : for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ )
1398 : : {
1399 [ # # ][ # # ]: 0 : if ( pProperties->Name.equals( SC_EVENTACC_EVENTTYPE ) )
1400 : : {
1401 : 0 : isEventType = true;
1402 : 0 : continue;
1403 : : }
1404 [ # # ][ # # ]: 0 : if ( isEventType && (pProperties->Name == SC_EVENTACC_SCRIPT) )
[ # # ][ # # ]
[ # # # # ]
1405 : : {
1406 : 0 : rtl::OUString sValue;
1407 [ # # ]: 0 : if ( pProperties->Value >>= sValue )
1408 : : {
1409 [ # # ]: 0 : ScMacroInfo* pInfo = getInfo( sal_True );
1410 : : OSL_ENSURE( pInfo, "shape macro info could not be created!" );
1411 [ # # ]: 0 : if ( !pInfo )
1412 : : break;
1413 [ # # ][ # # ]: 0 : if ( pProperties->Name == SC_EVENTACC_SCRIPT )
1414 : 0 : pInfo->SetMacro( sValue );
1415 : : else
1416 : 0 : pInfo->SetHlink( sValue );
1417 [ # # ]: 0 : }
1418 : : }
1419 [ # # ]: 0 : }
1420 : 0 : }
1421 : :
1422 : : // XNameAccess
1423 : 0 : virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
1424 : : {
1425 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aProperties;
1426 [ # # ]: 0 : ScMacroInfo* pInfo = getInfo();
1427 : :
1428 [ # # ][ # # ]: 0 : if ( aName == SC_EVENTACC_ONCLICK )
1429 : : {
1430 [ # # ][ # # ]: 0 : if ( pInfo && !pInfo->GetMacro().isEmpty() )
[ # # ]
1431 : : {
1432 [ # # ]: 0 : aProperties.realloc( 2 );
1433 [ # # ][ # # ]: 0 : aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE;
1434 [ # # ][ # # ]: 0 : aProperties[ 0 ].Value <<= SC_EVENTACC_SCRIPT;
[ # # ]
1435 [ # # ][ # # ]: 0 : aProperties[ 1 ].Name = SC_EVENTACC_SCRIPT;
1436 [ # # ][ # # ]: 0 : aProperties[ 1 ].Value <<= pInfo->GetMacro();
1437 : : }
1438 : : }
1439 : : else
1440 : : {
1441 [ # # ]: 0 : throw container::NoSuchElementException();
1442 : : }
1443 : :
1444 [ # # ][ # # ]: 0 : return uno::Any( aProperties );
1445 : : }
1446 : :
1447 : 0 : virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames() throw(uno::RuntimeException)
1448 : : {
1449 : 0 : uno::Sequence< rtl::OUString > aSeq( 1 );
1450 [ # # ][ # # ]: 0 : aSeq[ 0 ] = SC_EVENTACC_ONCLICK;
1451 : 0 : return aSeq;
1452 : : }
1453 : :
1454 : 0 : virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
1455 : : {
1456 : 0 : return aName == SC_EVENTACC_ONCLICK;
1457 : : }
1458 : :
1459 : : // XElementAccess
1460 : 0 : virtual uno::Type SAL_CALL getElementType() throw(uno::RuntimeException)
1461 : : {
1462 : 0 : return *SEQTYPE(::getCppuType((const uno::Sequence< beans::PropertyValue >*)0));
1463 : : }
1464 : :
1465 : 0 : virtual sal_Bool SAL_CALL hasElements() throw(uno::RuntimeException)
1466 : : {
1467 : : // elements are always present (but contained property sequences may be empty)
1468 : 0 : return sal_True;
1469 : : }
1470 : : };
1471 : :
1472 : : ::uno::Reference< container::XNameReplace > SAL_CALL
1473 : 0 : ScShapeObj::getEvents( ) throw(uno::RuntimeException)
1474 : : {
1475 [ # # ][ # # ]: 0 : return new ShapeUnoEventAccessImpl( this );
1476 : : }
1477 : :
1478 : 0 : ::rtl::OUString SAL_CALL ScShapeObj::getImplementationName( ) throw (uno::RuntimeException)
1479 : : {
1480 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sc.ScShapeObj" ) );
1481 : : }
1482 : :
1483 : 0 : ::sal_Bool SAL_CALL ScShapeObj::supportsService( const ::rtl::OUString& _ServiceName ) throw (uno::RuntimeException)
1484 : : {
1485 [ # # ]: 0 : uno::Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
1486 [ # # ]: 0 : for ( const ::rtl::OUString* pSupported = aSupported.getConstArray();
1487 : 0 : pSupported != aSupported.getConstArray() + aSupported.getLength();
1488 : : ++pSupported
1489 : : )
1490 [ # # ]: 0 : if ( _ServiceName == *pSupported )
1491 : 0 : return sal_True;
1492 [ # # ]: 0 : return false;
1493 : : }
1494 : :
1495 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL ScShapeObj::getSupportedServiceNames( ) throw (uno::RuntimeException)
1496 : : {
1497 : 0 : uno::Reference<lang::XServiceInfo> xSI;
1498 [ # # ]: 0 : if ( mxShapeAgg.is() )
1499 [ # # ][ # # ]: 0 : mxShapeAgg->queryAggregation( lang::XServiceInfo::static_type() ) >>= xSI;
[ # # ][ # # ]
1500 : :
1501 [ # # ]: 0 : uno::Sequence< ::rtl::OUString > aSupported;
1502 [ # # ]: 0 : if ( xSI.is() )
1503 [ # # ][ # # ]: 0 : aSupported = xSI->getSupportedServiceNames();
[ # # ][ # # ]
1504 : :
1505 [ # # ]: 0 : aSupported.realloc( aSupported.getLength() + 1 );
1506 [ # # ][ # # ]: 0 : aSupported[ aSupported.getLength() - 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.Shape" ) );
1507 : 0 : return aSupported;
1508 [ + - ][ + - ]: 153 : }
1509 : :
1510 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|