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 "charthelper.hxx"
31 : : #include "document.hxx"
32 : : #include "drwlayer.hxx"
33 : : #include "rangelst.hxx"
34 : : #include "chartlis.hxx"
35 : : #include "docuno.hxx"
36 : :
37 : : #include <svx/svditer.hxx>
38 : : #include <svx/svdoole2.hxx>
39 : : #include <svx/svdpage.hxx>
40 : :
41 : : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
42 : :
43 : : using namespace com::sun::star;
44 : : using ::com::sun::star::uno::Reference;
45 : :
46 : :
47 : : // ====================================================================
48 : :
49 : : namespace
50 : : {
51 : :
52 : :
53 : 0 : sal_uInt16 lcl_DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, bool bAllCharts )
54 : : {
55 : 0 : ScDrawLayer* pModel = pDoc->GetDrawLayer();
56 [ # # ]: 0 : if (!pModel)
57 : 0 : return 0;
58 : :
59 : 0 : sal_uInt16 nFound = 0;
60 : :
61 : 0 : sal_uInt16 nPageCount = pModel->GetPageCount();
62 [ # # ]: 0 : for (sal_uInt16 nPageNo=0; nPageNo<nPageCount; nPageNo++)
63 : : {
64 [ # # ]: 0 : SdrPage* pPage = pModel->GetPage(nPageNo);
65 : : OSL_ENSURE(pPage,"Page ?");
66 : :
67 [ # # ]: 0 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
68 [ # # ]: 0 : SdrObject* pObject = aIter.Next();
69 [ # # ]: 0 : while (pObject)
70 : : {
71 [ # # ][ # # ]: 0 : if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart( pObject ) )
[ # # ][ # # ]
[ # # ]
72 : : {
73 [ # # ]: 0 : String aName = ((SdrOle2Obj*)pObject)->GetPersistName();
74 : 0 : bool bHit = true;
75 [ # # ]: 0 : if ( !bAllCharts )
76 : : {
77 [ # # ]: 0 : ScRangeList aRanges;
78 : 0 : bool bColHeaders = false;
79 : 0 : bool bRowHeaders = false;
80 [ # # ][ # # ]: 0 : pDoc->GetOldChartParameters( aName, aRanges, bColHeaders, bRowHeaders );
81 [ # # ][ # # ]: 0 : bHit = aRanges.In( rPos );
82 : : }
83 [ # # ]: 0 : if ( bHit )
84 : : {
85 [ # # ][ # # ]: 0 : pDoc->UpdateChart( aName );
86 : 0 : ++nFound;
87 [ # # ]: 0 : }
88 : : }
89 [ # # ]: 0 : pObject = aIter.Next();
90 : : }
91 : 0 : }
92 : 0 : return nFound;
93 : : }
94 : :
95 : 0 : bool lcl_AdjustRanges( ScRangeList& rRanges, SCTAB nSourceTab, SCTAB nDestTab, SCTAB nTabCount )
96 : : {
97 : : //! if multiple sheets are copied, update references into the other copied sheets?
98 : :
99 : 0 : bool bChanged = false;
100 : :
101 [ # # ]: 0 : for ( size_t i=0, nCount = rRanges.size(); i < nCount; i++ )
102 : : {
103 : 0 : ScRange* pRange = rRanges[ i ];
104 [ # # ][ # # ]: 0 : if ( pRange->aStart.Tab() == nSourceTab && pRange->aEnd.Tab() == nSourceTab )
[ # # ]
105 : : {
106 : 0 : pRange->aStart.SetTab( nDestTab );
107 : 0 : pRange->aEnd.SetTab( nDestTab );
108 : 0 : bChanged = true;
109 : : }
110 [ # # ]: 0 : if ( pRange->aStart.Tab() >= nTabCount )
111 : : {
112 [ # # ]: 0 : pRange->aStart.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
113 : 0 : bChanged = true;
114 : : }
115 [ # # ]: 0 : if ( pRange->aEnd.Tab() >= nTabCount )
116 : : {
117 [ # # ]: 0 : pRange->aEnd.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 );
118 : 0 : bChanged = true;
119 : : }
120 : : }
121 : :
122 : 0 : return bChanged;
123 : : }
124 : :
125 : : }//end anonymous namespace
126 : :
127 : : // === ScChartHelper ======================================
128 : :
129 : : //static
130 : 0 : sal_uInt16 ScChartHelper::DoUpdateAllCharts( ScDocument* pDoc )
131 : : {
132 [ # # ]: 0 : return lcl_DoUpdateCharts( ScAddress(), pDoc, sal_True );
133 : : }
134 : :
135 : 4 : void ScChartHelper::AdjustRangesOfChartsOnDestinationPage( ScDocument* pSrcDoc, ScDocument* pDestDoc, const SCTAB nSrcTab, const SCTAB nDestTab )
136 : : {
137 [ + - ][ - + ]: 4 : if( !pSrcDoc || !pDestDoc )
138 : 0 : return;
139 : 4 : ScDrawLayer* pDrawLayer = pDestDoc->GetDrawLayer();
140 [ + + ]: 4 : if( !pDrawLayer )
141 : 2 : return;
142 : :
143 : 2 : SdrPage* pDestPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nDestTab));
144 [ + - ]: 2 : if( pDestPage )
145 : : {
146 [ + - ]: 2 : SdrObjListIter aIter( *pDestPage, IM_FLAT );
147 [ + - ]: 2 : SdrObject* pObject = aIter.Next();
148 [ - + ]: 2 : while( pObject )
149 : : {
150 [ # # ][ # # ]: 0 : if( pObject->GetObjIdentifier() == OBJ_OLE2 && ((SdrOle2Obj*)pObject)->IsChart() )
[ # # ][ # # ]
[ # # ]
151 : : {
152 [ # # ]: 0 : String aChartName = ((SdrOle2Obj*)pObject)->GetPersistName();
153 : :
154 [ # # ][ # # ]: 0 : Reference< chart2::XChartDocument > xChartDoc( pDestDoc->GetChartByName( aChartName ) );
155 [ # # ]: 0 : Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
156 [ # # ][ # # ]: 0 : if( xChartDoc.is() && xReceiver.is() && !xChartDoc->hasInternalDataProvider() )
[ # # ][ # # ]
[ # # ][ # # ]
157 : : {
158 [ # # ]: 0 : ::std::vector< ScRangeList > aRangesVector;
159 [ # # ][ # # ]: 0 : pDestDoc->GetChartRanges( aChartName, aRangesVector, pSrcDoc );
160 : :
161 : 0 : ::std::vector< ScRangeList >::iterator aIt( aRangesVector.begin() );
162 [ # # ][ # # ]: 0 : for( ; aIt!=aRangesVector.end(); ++aIt )
[ # # ]
163 : : {
164 [ # # ]: 0 : ScRangeList& rScRangeList( *aIt );
165 [ # # ][ # # ]: 0 : lcl_AdjustRanges( rScRangeList, nSrcTab, nDestTab, pDestDoc->GetTableCount() );
166 : : }
167 [ # # ][ # # ]: 0 : pDestDoc->SetChartRanges( aChartName, aRangesVector );
168 [ # # ]: 0 : }
169 : : }
170 [ # # ]: 0 : pObject = aIter.Next();
171 : 4 : }
172 : : }
173 : : }
174 : :
175 : 25 : uno::Reference< chart2::XChartDocument > ScChartHelper::GetChartFromSdrObject( SdrObject* pObject )
176 : : {
177 : 25 : uno::Reference< chart2::XChartDocument > xReturn;
178 [ + - ]: 25 : if( pObject )
179 : : {
180 [ + - ][ + - ]: 25 : if( pObject->GetObjIdentifier() == OBJ_OLE2 && ((SdrOle2Obj*)pObject)->IsChart() )
[ + - ][ + - ]
[ + - ]
181 : : {
182 [ + - ]: 25 : uno::Reference< embed::XEmbeddedObject > xIPObj = ((SdrOle2Obj*)pObject)->GetObjRef();
183 [ + - ]: 25 : if( xIPObj.is() )
184 : : {
185 [ + - ]: 25 : svt::EmbeddedObjectRef::TryRunningState( xIPObj );
186 [ + - ][ + - ]: 25 : uno::Reference< util::XCloseable > xComponent = xIPObj->getComponent();
187 [ + - ][ + - ]: 25 : xReturn.set( uno::Reference< chart2::XChartDocument >( xComponent, uno::UNO_QUERY ) );
188 : 25 : }
189 : : }
190 : : }
191 : 25 : return xReturn;
192 : : }
193 : :
194 : 0 : void ScChartHelper::GetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
195 : : uno::Sequence< rtl::OUString >& rRanges )
196 : : {
197 [ # # ]: 0 : rRanges.realloc(0);
198 [ # # ]: 0 : uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
199 [ # # ]: 0 : if( !xDataSource.is() )
200 : 0 : return;
201 : :
202 [ # # ][ # # ]: 0 : uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
203 [ # # ]: 0 : rRanges.realloc(2*aLabeledDataSequences.getLength());
204 : 0 : sal_Int32 nRealCount=0;
205 [ # # ]: 0 : for( sal_Int32 nN=0;nN<aLabeledDataSequences.getLength();nN++)
206 : : {
207 [ # # ]: 0 : uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
208 [ # # ]: 0 : if(!xLabeledSequence.is())
209 : 0 : continue;
210 [ # # ][ # # ]: 0 : uno::Reference< chart2::data::XDataSequence > xLabel( xLabeledSequence->getLabel());
211 [ # # ][ # # ]: 0 : uno::Reference< chart2::data::XDataSequence > xValues( xLabeledSequence->getValues());
212 : :
213 [ # # ]: 0 : if( xLabel.is())
214 [ # # ][ # # ]: 0 : rRanges[nRealCount++] = xLabel->getSourceRangeRepresentation();
[ # # ]
215 [ # # ]: 0 : if( xValues.is())
216 [ # # ][ # # ]: 0 : rRanges[nRealCount++] = xValues->getSourceRangeRepresentation();
[ # # ]
217 [ # # ]: 0 : }
218 [ # # ][ # # ]: 0 : rRanges.realloc(nRealCount);
[ # # ]
219 : : }
220 : :
221 : 0 : void ScChartHelper::SetChartRanges( const uno::Reference< chart2::XChartDocument >& xChartDoc,
222 : : const uno::Sequence< rtl::OUString >& rRanges )
223 : : {
224 [ # # ]: 0 : uno::Reference< chart2::data::XDataSource > xDataSource( xChartDoc, uno::UNO_QUERY );
225 [ # # ]: 0 : if( !xDataSource.is() )
226 : : return;
227 [ # # ][ # # ]: 0 : uno::Reference< chart2::data::XDataProvider > xDataProvider = xChartDoc->getDataProvider();
228 [ # # ]: 0 : if( !xDataProvider.is() )
229 : : return;
230 : :
231 [ # # ]: 0 : uno::Reference< frame::XModel > xModel( xChartDoc, uno::UNO_QUERY );
232 [ # # ]: 0 : if( xModel.is() )
233 [ # # ][ # # ]: 0 : xModel->lockControllers();
234 : :
235 : : try
236 : : {
237 [ # # ]: 0 : rtl::OUString aPropertyNameRole( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role")) );
238 : :
239 [ # # ][ # # ]: 0 : uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledDataSequences( xDataSource->getDataSequences() );
240 : 0 : sal_Int32 nRange=0;
241 [ # # ][ # # ]: 0 : for( sal_Int32 nN=0; (nN<aLabeledDataSequences.getLength()) && (nRange<rRanges.getLength()); nN++ )
[ # # ]
242 : : {
243 [ # # ]: 0 : uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSequence( aLabeledDataSequences[nN] );
244 [ # # ]: 0 : if(!xLabeledSequence.is())
245 : 0 : continue;
246 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xLabel( xLabeledSequence->getLabel(), uno::UNO_QUERY );
[ # # ]
247 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xValues( xLabeledSequence->getValues(), uno::UNO_QUERY );
[ # # ]
248 : :
249 [ # # ]: 0 : if( xLabel.is())
250 : : {
251 : : uno::Reference< chart2::data::XDataSequence > xNewSeq(
252 [ # # ][ # # ]: 0 : xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
253 : :
254 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
255 [ # # ]: 0 : if( xNewProps.is() )
256 [ # # ][ # # ]: 0 : xNewProps->setPropertyValue( aPropertyNameRole, xLabel->getPropertyValue( aPropertyNameRole ) );
[ # # ][ # # ]
257 : :
258 [ # # ][ # # ]: 0 : xLabeledSequence->setLabel( xNewSeq );
259 : : }
260 : :
261 [ # # ]: 0 : if( !(nRange<rRanges.getLength()) )
262 : : break;
263 : :
264 [ # # ]: 0 : if( xValues.is())
265 : : {
266 : : uno::Reference< chart2::data::XDataSequence > xNewSeq(
267 [ # # ][ # # ]: 0 : xDataProvider->createDataSequenceByRangeRepresentation( rRanges[nRange++] ));
268 : :
269 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xNewProps( xNewSeq, uno::UNO_QUERY );
270 [ # # ]: 0 : if( xNewProps.is() )
271 [ # # ][ # # ]: 0 : xNewProps->setPropertyValue( aPropertyNameRole, xValues->getPropertyValue( aPropertyNameRole ) );
[ # # ][ # # ]
272 : :
273 [ # # ][ # # ]: 0 : xLabeledSequence->setValues( xNewSeq );
274 : : }
275 [ # # ][ # # ]: 0 : }
[ # # # ]
[ # # ][ # # ]
276 : : }
277 [ # # ]: 0 : catch (const uno::Exception&)
278 : : {
279 : : OSL_FAIL("Exception in ScChartHelper::SetChartRanges - invalid range string?");
280 : : }
281 : :
282 [ # # ]: 0 : if( xModel.is() )
283 [ # # ][ # # ]: 0 : xModel->unlockControllers();
[ # # ][ # # ]
284 : : }
285 : :
286 : 0 : void ScChartHelper::AddRangesIfProtectedChart( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrObject* pObject )
287 : : {
288 [ # # ][ # # ]: 0 : if ( pDocument && pObject && ( pObject->GetObjIdentifier() == OBJ_OLE2 ) )
[ # # ][ # # ]
289 : : {
290 [ # # ]: 0 : SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject );
291 [ # # ][ # # ]: 0 : if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() )
[ # # ]
292 : : {
293 [ # # ]: 0 : uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = pSdrOle2Obj->GetObjRef();
294 [ # # ]: 0 : if ( xEmbeddedObj.is() )
295 : : {
296 : 0 : bool bDisableDataTableDialog = false;
297 [ # # ][ # # ]: 0 : sal_Int32 nOldState = xEmbeddedObj->getCurrentState();
298 [ # # ]: 0 : svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj );
299 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
[ # # ]
300 [ # # ][ # # ]: 0 : if ( xProps.is() &&
[ # # # # ]
301 [ # # ][ # # ]: 0 : ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
[ # # ][ # # ]
[ # # ]
[ # # # # ]
302 : : bDisableDataTableDialog )
303 : : {
304 [ # # ]: 0 : ScChartListenerCollection* pCollection = pDocument->GetChartListenerCollection();
305 [ # # ]: 0 : if (pCollection)
306 : : {
307 [ # # ][ # # ]: 0 : ::rtl::OUString aChartName = pSdrOle2Obj->GetPersistName();
[ # # ]
308 [ # # ]: 0 : const ScChartListener* pListener = pCollection->findByName(aChartName);
309 [ # # ]: 0 : if (pListener)
310 : : {
311 [ # # ]: 0 : const ScRangeListRef& rRangeList = pListener->GetRangeList();
312 [ # # ]: 0 : if ( rRangeList.Is() )
313 : : {
314 [ # # ]: 0 : rRangesVector.push_back( *rRangeList );
315 [ # # ]: 0 : }
316 : 0 : }
317 : : }
318 : : }
319 [ # # ][ # # ]: 0 : if ( xEmbeddedObj->getCurrentState() != nOldState )
[ # # ]
320 : : {
321 [ # # ][ # # ]: 0 : xEmbeddedObj->changeState( nOldState );
322 : 0 : }
323 : 0 : }
324 : : }
325 : : }
326 : 0 : }
327 : :
328 : 0 : void ScChartHelper::FillProtectedChartRangesVector( ScRangeListVector& rRangesVector, ScDocument* pDocument, SdrPage* pPage )
329 : : {
330 [ # # ][ # # ]: 0 : if ( pDocument && pPage )
331 : : {
332 [ # # ]: 0 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
333 [ # # ]: 0 : SdrObject* pObject = aIter.Next();
334 [ # # ]: 0 : while ( pObject )
335 : : {
336 [ # # ]: 0 : AddRangesIfProtectedChart( rRangesVector, pDocument, pObject );
337 [ # # ]: 0 : pObject = aIter.Next();
338 : 0 : }
339 : : }
340 : 0 : }
341 : :
342 : 16 : void ScChartHelper::GetChartNames( ::std::vector< ::rtl::OUString >& rChartNames, SdrPage* pPage )
343 : : {
344 [ + - ]: 16 : if ( pPage )
345 : : {
346 [ + - ]: 16 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
347 [ + - ]: 16 : SdrObject* pObject = aIter.Next();
348 [ - + ]: 16 : while ( pObject )
349 : : {
350 [ # # ][ # # ]: 0 : if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
351 : : {
352 [ # # ]: 0 : SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject );
353 [ # # ][ # # ]: 0 : if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() )
[ # # ][ # # ]
354 : : {
355 [ # # ][ # # ]: 0 : rChartNames.push_back( pSdrOle2Obj->GetPersistName() );
[ # # ][ # # ]
356 : : }
357 : : }
358 [ # # ]: 0 : pObject = aIter.Next();
359 : 16 : }
360 : : }
361 : 16 : }
362 : :
363 : 16 : void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, SdrPage* pPage, ScModelObj* pModelObj, SCTAB nTab,
364 : : const ScRangeListVector& rRangesVector, const ::std::vector< ::rtl::OUString >& rExcludedChartNames, bool bSameDoc )
365 : : {
366 [ + - ][ + - ]: 16 : if ( pDoc && pPage && pModelObj )
[ + - ]
367 : : {
368 : 16 : size_t nRangeListCount = rRangesVector.size();
369 : 16 : size_t nRangeList = 0;
370 [ + - ]: 16 : SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
371 [ + - ]: 16 : SdrObject* pObject = aIter.Next();
372 [ - + ]: 16 : while ( pObject )
373 : : {
374 [ # # ][ # # ]: 0 : if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
375 : : {
376 [ # # ]: 0 : SdrOle2Obj* pSdrOle2Obj = dynamic_cast< SdrOle2Obj* >( pObject );
377 [ # # ][ # # ]: 0 : if ( pSdrOle2Obj && pSdrOle2Obj->IsChart() )
[ # # ][ # # ]
378 : : {
379 [ # # ][ # # ]: 0 : ::rtl::OUString aChartName = pSdrOle2Obj->GetPersistName();
[ # # ]
380 : 0 : ::std::vector< ::rtl::OUString >::const_iterator aEnd = rExcludedChartNames.end();
381 [ # # ]: 0 : ::std::vector< ::rtl::OUString >::const_iterator aFound = ::std::find( rExcludedChartNames.begin(), aEnd, aChartName );
382 [ # # ][ # # ]: 0 : if ( aFound == aEnd )
383 : : {
384 [ # # ]: 0 : uno::Reference< embed::XEmbeddedObject > xEmbeddedObj = pSdrOle2Obj->GetObjRef();
385 [ # # ][ # # ]: 0 : if ( xEmbeddedObj.is() && ( nRangeList < nRangeListCount ) )
[ # # ]
386 : : {
387 : 0 : bool bDisableDataTableDialog = false;
388 [ # # ]: 0 : svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj );
389 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY );
[ # # ]
390 [ # # ][ # # ]: 0 : if ( xProps.is() &&
[ # # # # ]
391 [ # # ][ # # ]: 0 : ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
[ # # ][ # # ]
[ # # ]
[ # # # # ]
392 : : bDisableDataTableDialog )
393 : : {
394 [ # # ]: 0 : if ( bSameDoc )
395 : : {
396 [ # # ]: 0 : ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
397 [ # # ][ # # ]: 0 : if (pCollection && !pCollection->findByName(aChartName))
[ # # ][ # # ]
398 : : {
399 [ # # ][ # # ]: 0 : ScRangeList aRangeList( rRangesVector[ nRangeList++ ] );
400 [ # # ][ # # ]: 0 : ScRangeListRef rRangeList( new ScRangeList( aRangeList ) );
401 [ # # ][ # # ]: 0 : ScChartListener* pChartListener = new ScChartListener( aChartName, pDoc, rRangeList );
402 [ # # ]: 0 : pCollection->insert( pChartListener );
403 [ # # ][ # # ]: 0 : pChartListener->StartListeningTo();
[ # # ]
404 : : }
405 : : }
406 : : else
407 : : {
408 [ # # ]: 0 : xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
409 [ # # ][ # # ]: 0 : uno::makeAny( sal_False ) );
[ # # ]
410 [ # # ]: 0 : xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
411 [ # # ][ # # ]: 0 : uno::makeAny( sal_False ) );
[ # # ]
412 : : }
413 : 0 : }
414 : : }
415 : :
416 [ # # ][ # # ]: 0 : if ( pModelObj && pModelObj->HasChangesListeners() )
[ # # ][ # # ]
417 : : {
418 [ # # ]: 0 : Rectangle aRectangle = pSdrOle2Obj->GetSnapRect();
419 [ # # ]: 0 : ScRange aRange( pDoc->GetRange( nTab, aRectangle ) );
420 [ # # ]: 0 : ScRangeList aChangeRanges;
421 [ # # ]: 0 : aChangeRanges.Append( aRange );
422 : :
423 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aProperties( 1 );
424 [ # # ][ # # ]: 0 : aProperties[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
425 [ # # ][ # # ]: 0 : aProperties[ 0 ].Value <<= aChartName;
426 : :
427 [ # # ][ # # ]: 0 : pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-chart" ) ), aChangeRanges, aProperties );
[ # # ][ # # ]
428 : 0 : }
429 : 0 : }
430 : : }
431 : : }
432 [ # # ]: 0 : pObject = aIter.Next();
433 : 16 : }
434 : : }
435 : 16 : }
436 : :
437 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|