Branch data Line data Source code
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 "ChartView.hxx"
21 : : #include "chartview/DrawModelWrapper.hxx"
22 : : #include "NumberFormatterWrapper.hxx"
23 : : #include "ViewDefines.hxx"
24 : : #include "VDiagram.hxx"
25 : : #include "VTitle.hxx"
26 : : #include "ShapeFactory.hxx"
27 : : #include "VCoordinateSystem.hxx"
28 : : #include "VSeriesPlotter.hxx"
29 : : #include "CommonConverters.hxx"
30 : : #include "macros.hxx"
31 : : #include "TitleHelper.hxx"
32 : : #include "LegendHelper.hxx"
33 : : #include "VLegend.hxx"
34 : : #include "PropertyMapper.hxx"
35 : : #include "ChartModelHelper.hxx"
36 : : #include "ChartTypeHelper.hxx"
37 : : #include "ScaleAutomatism.hxx"
38 : : #include "MinimumAndMaximumSupplier.hxx"
39 : : #include "ObjectIdentifier.hxx"
40 : : #include "DiagramHelper.hxx"
41 : : #include "RelativePositionHelper.hxx"
42 : : #include "servicenames.hxx"
43 : : #include "AxisHelper.hxx"
44 : : #include "AxisIndexDefines.hxx"
45 : : #include "ControllerLockGuard.hxx"
46 : : #include "BaseGFXHelper.hxx"
47 : : #include "DataSeriesHelper.hxx"
48 : : #include "DateHelper.hxx"
49 : :
50 : : #include <rtl/uuid.h>
51 : : #include <comphelper/scopeguard.hxx>
52 : : #include <comphelper/servicehelper.hxx>
53 : : #include <boost/bind.hpp>
54 : : #include <unotools/streamwrap.hxx>
55 : : // header for class LocaleDataWrapper
56 : : #include <unotools/localedatawrapper.hxx>
57 : : // header for class SdrPage
58 : : #include <svx/svdpage.hxx>
59 : : // header for class SvxDrawPage
60 : : #include <svx/unopage.hxx>
61 : : // header for class SvxShape
62 : : #include <svx/unoshape.hxx>
63 : : // header for class Application
64 : : #include <vcl/svapp.hxx>
65 : : #include <osl/mutex.hxx>
66 : : #include <svx/unofill.hxx>
67 : :
68 : : #include <drawinglayer/XShapeDumper.hxx>
69 : :
70 : : #include <time.h>
71 : :
72 : : #include <com/sun/star/chart/ChartAxisPosition.hpp>
73 : : #include <com/sun/star/chart/DataLabelPlacement.hpp>
74 : : #include <com/sun/star/chart/MissingValueTreatment.hpp>
75 : : #include <com/sun/star/chart2/StackingDirection.hpp>
76 : : #include <com/sun/star/chart2/XChartDocument.hpp>
77 : : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
78 : : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
79 : : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
80 : : #include <com/sun/star/chart2/XTitled.hpp>
81 : : #include <com/sun/star/chart2/RelativePosition.hpp>
82 : : #include <com/sun/star/chart2/RelativeSize.hpp>
83 : : #include <com/sun/star/drawing/FillStyle.hpp>
84 : : #include <com/sun/star/drawing/LineStyle.hpp>
85 : : #include <com/sun/star/drawing/XShapeGroup.hpp>
86 : : #include <com/sun/star/document/XExporter.hpp>
87 : : #include <com/sun/star/document/XFilter.hpp>
88 : : #include <com/sun/star/io/XSeekable.hpp>
89 : : #include <com/sun/star/util/XModifiable.hpp>
90 : : #include <com/sun/star/util/XRefreshable.hpp>
91 : : #include <com/sun/star/util/NumberFormat.hpp>
92 : : #include <com/sun/star/awt/Size.hpp>
93 : : #include <com/sun/star/awt/Point.hpp>
94 : : #include <com/sun/star/drawing/XShapeDescriptor.hpp>
95 : : #include <com/sun/star/text/XText.hpp>
96 : :
97 : : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
98 : : #include <com/sun/star/text/XTextDocument.hpp>
99 : : #include <com/sun/star/text/WritingMode2.hpp>
100 : : #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
101 : : #include <com/sun/star/view/XSelectionSupplier.hpp>
102 : : #include <svl/languageoptions.hxx>
103 : : #include <sot/clsids.hxx>
104 : :
105 : : #include <rtl/strbuf.hxx>
106 : : #include <rtl/oustringostreaminserter.hxx>
107 : :
108 : : //.............................................................................
109 : : namespace chart
110 : : {
111 : : //.............................................................................
112 : :
113 : : using namespace ::com::sun::star;
114 : : using namespace ::com::sun::star::chart2;
115 : : using ::com::sun::star::uno::Reference;
116 : : using ::com::sun::star::uno::Sequence;
117 : : using ::com::sun::star::uno::Any;
118 : : using rtl::OUString;
119 : :
120 : : namespace
121 : : {
122 : : class theExplicitValueProviderUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theExplicitValueProviderUnoTunnelId > {};
123 : : }
124 : :
125 : 1064 : const uno::Sequence<sal_Int8>& ExplicitValueProvider::getUnoTunnelId()
126 : : {
127 : 1064 : return theExplicitValueProviderUnoTunnelId::get().getSeq();
128 : : }
129 : :
130 : 34 : ExplicitValueProvider* ExplicitValueProvider::getExplicitValueProvider(
131 : : const Reference< uno::XInterface >& xChartView )
132 : : {
133 : 34 : ExplicitValueProvider* pExplicitValueProvider=0;
134 : :
135 [ + - ]: 34 : Reference< lang::XUnoTunnel > xTunnel( xChartView, uno::UNO_QUERY );
136 [ + - ]: 34 : if( xTunnel.is() )
137 : : {
138 [ + - ]: 34 : pExplicitValueProvider = reinterpret_cast<ExplicitValueProvider*>(xTunnel->getSomething(
139 [ + - ][ + - ]: 34 : ExplicitValueProvider::getUnoTunnelId() ));
140 : : }
141 : 34 : return pExplicitValueProvider;
142 : : }
143 : :
144 : 56 : ChartView::ChartView(
145 : : uno::Reference<uno::XComponentContext> const & xContext)
146 : : : m_aMutex()
147 : : , m_xCC(xContext)
148 : : , m_xChartModel()
149 : : , m_xShapeFactory()
150 : : , m_xDrawPage()
151 : : , m_pDrawModelWrapper()
152 : : , m_aListenerContainer( m_aMutex )
153 : : , m_bViewDirty(true)
154 : : , m_bInViewUpdate(false)
155 : : , m_bViewUpdatePending(false)
156 : : , m_bRefreshAddIn(true)
157 : : , m_aPageResolution(1000,1000)
158 : : , m_bPointsWereSkipped(false)
159 : : , m_nScaleXNumerator(1)
160 : : , m_nScaleXDenominator(1)
161 : : , m_nScaleYNumerator(1)
162 : : , m_nScaleYDenominator(1)
163 : : , m_bSdrViewIsInEditMode(sal_False)
164 [ + - ][ + - ]: 56 : , m_aResultingDiagramRectangleExcludingAxes(0,0,0,0)
[ + - ][ + - ]
[ + - ]
165 : : {
166 : 56 : }
167 : :
168 : 56 : void ChartView::impl_setChartModel( const uno::Reference< frame::XModel >& xChartModel )
169 : : {
170 [ + - ]: 56 : if( m_xChartModel != xChartModel )
171 : : {
172 : 56 : m_xChartModel = xChartModel;
173 : 56 : m_bViewDirty = true;
174 : : }
175 : 56 : }
176 : :
177 : 56 : void SAL_CALL ChartView::initialize( const uno::Sequence< uno::Any >& aArguments )
178 : : throw ( uno::Exception, uno::RuntimeException)
179 : : {
180 : : OSL_PRECOND(aArguments.getLength() >= 1,"need 1 argument to initialize the view: xModel");
181 [ + - ]: 56 : if( !(aArguments.getLength() >= 1) )
182 : 56 : return;
183 : :
184 : 56 : uno::Reference< frame::XModel > xNewChartModel;
185 [ + - ]: 56 : if( !(aArguments[0] >>= xNewChartModel) )
186 : : {
187 : : OSL_FAIL( "need a Reference to frame::XModel as first parameter for view initialization" );
188 : : }
189 [ + - ]: 56 : impl_setChartModel( xNewChartModel );
190 : :
191 [ + - ]: 56 : if( !m_pDrawModelWrapper.get() )
192 : : {
193 [ + - ]: 56 : SolarMutexGuard aSolarGuard;
194 [ + - ][ + - ]: 56 : m_pDrawModelWrapper = ::boost::shared_ptr< DrawModelWrapper >( new DrawModelWrapper( m_xCC ) );
[ + - ][ + - ]
[ + - ]
195 [ + - ][ + - ]: 56 : m_xShapeFactory = m_pDrawModelWrapper->getShapeFactory();
196 [ + - ][ + - ]: 56 : m_xDrawPage = m_pDrawModelWrapper->getMainDrawPage();
197 [ + - ][ + - ]: 56 : StartListening( m_pDrawModelWrapper->getSdrModel(), false /*bPreventDups*/ );
[ + - ]
198 : 56 : }
199 : : }
200 : :
201 [ + - ][ + - ]: 56 : ChartView::~ChartView()
[ + - ][ + - ]
202 : : {
203 [ + - ]: 56 : if( m_pDrawModelWrapper.get() )
204 : : {
205 [ + - ][ + - ]: 56 : EndListening( m_pDrawModelWrapper->getSdrModel(), false /*bAllDups*/ );
206 [ + - ]: 56 : SolarMutexGuard aSolarGuard;
207 [ + - ][ + - ]: 56 : m_pDrawModelWrapper.reset();
208 : : }
209 [ + - ]: 56 : m_xDrawPage = NULL;
210 [ + - ]: 56 : impl_deleteCoordinateSystems();
211 [ - + ]: 112 : }
212 : :
213 : 1127 : void ChartView::impl_deleteCoordinateSystems()
214 : : {
215 : : //delete all coordinate systems
216 [ + - ]: 1127 : ::std::vector< VCoordinateSystem* > aVectorToDeleteObjects;
217 : 1127 : ::std::swap( aVectorToDeleteObjects, m_aVCooSysList );//#i109770#
218 [ + - ]: 1127 : ::std::vector< VCoordinateSystem* >::const_iterator aIter = aVectorToDeleteObjects.begin();
219 [ + - ]: 1127 : const ::std::vector< VCoordinateSystem* >::const_iterator aEnd = aVectorToDeleteObjects.end();
220 [ + - ][ + + ]: 2109 : for( ; aIter != aEnd; ++aIter )
221 : : {
222 [ + - ][ + - ]: 982 : delete *aIter;
223 : : }
224 : 1127 : aVectorToDeleteObjects.clear();
225 : 1127 : }
226 : :
227 : :
228 : : //-----------------------------------------------------------------
229 : : // datatransfer::XTransferable
230 : : namespace
231 : : {
232 : 16 : const rtl::OUString lcl_aGDIMetaFileMIMEType(
233 : : RTL_CONSTASCII_USTRINGPARAM("application/x-openoffice-gdimetafile;windows_formatname=\"GDIMetaFile\""));
234 : 16 : const rtl::OUString lcl_aGDIMetaFileMIMETypeHighContrast(
235 : : RTL_CONSTASCII_USTRINGPARAM("application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\""));
236 : : } // anonymous namespace
237 : :
238 : 90 : void ChartView::getMetaFile( const uno::Reference< io::XOutputStream >& xOutStream
239 : : , bool bUseHighContrast )
240 : : {
241 [ + - ]: 90 : if( !m_xDrawPage.is() )
242 : : return;
243 : :
244 [ + - ][ + - ]: 90 : uno::Reference< lang::XMultiServiceFactory > xFactory( m_xCC->getServiceManager(), uno::UNO_QUERY );
[ + - ]
245 [ - + ]: 90 : if( !xFactory.is() )
246 : : return;
247 : :
248 : : // creating the graphic exporter
249 [ + - ]: 90 : uno::Reference< document::XExporter > xExporter( xFactory->createInstance(
250 [ + - ][ + - ]: 90 : C2U("com.sun.star.drawing.GraphicExportFilter")), uno::UNO_QUERY);
[ + - ]
251 [ + - ]: 90 : uno::Reference< document::XFilter > xFilter( xExporter, uno::UNO_QUERY );
252 : :
253 [ + - ][ - + ]: 90 : if( !xExporter.is() || !xFilter.is() )
[ - + ]
254 : : return;
255 : :
256 [ + - ]: 90 : uno::Sequence< beans::PropertyValue > aProps(3);
257 [ + - ][ + - ]: 90 : aProps[0].Name = C2U("FilterName");
258 [ + - ][ + - ]: 90 : aProps[0].Value <<= C2U("SVM");
[ + - ]
259 : :
260 [ + - ][ + - ]: 90 : aProps[1].Name = C2U("OutputStream");
261 [ + - ][ + - ]: 90 : aProps[1].Value <<= xOutStream;
262 : :
263 [ + - ]: 90 : uno::Sequence< beans::PropertyValue > aFilterData(4);
264 [ + - ][ + - ]: 90 : aFilterData[0].Name = C2U("ExportOnlyBackground");
265 [ + - ][ + - ]: 90 : aFilterData[0].Value <<= sal_False;
266 [ + - ][ + - ]: 90 : aFilterData[1].Name = C2U("HighContrast");
267 [ + - ][ + - ]: 90 : aFilterData[1].Value <<= bUseHighContrast;
268 : :
269 [ + - ][ + - ]: 90 : aFilterData[2].Name = C2U("Version");
270 : 90 : const sal_Int32 nVersion = SOFFICE_FILEFORMAT_50;
271 [ + - ][ + - ]: 90 : aFilterData[2].Value <<= nVersion;
272 : :
273 [ + - ][ + - ]: 90 : aFilterData[3].Name = C2U("CurrentPage");
274 [ + - ][ + - ]: 90 : aFilterData[3].Value <<= uno::Reference< uno::XInterface >( m_xDrawPage, uno::UNO_QUERY );
[ + - ]
275 : :
276 : : //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
277 : : {
278 [ + - ]: 90 : aFilterData.realloc( aFilterData.getLength()+4 );
279 [ + - ][ + - ]: 90 : aFilterData[4].Name = C2U("ScaleXNumerator");
280 [ + - ][ + - ]: 90 : aFilterData[4].Value = uno::makeAny( m_nScaleXNumerator );
281 [ + - ][ + - ]: 90 : aFilterData[5].Name = C2U("ScaleXDenominator");
282 [ + - ][ + - ]: 90 : aFilterData[5].Value = uno::makeAny( m_nScaleXDenominator );
283 [ + - ][ + - ]: 90 : aFilterData[6].Name = C2U("ScaleYNumerator");
284 [ + - ][ + - ]: 90 : aFilterData[6].Value = uno::makeAny( m_nScaleYNumerator );
285 [ + - ][ + - ]: 90 : aFilterData[7].Name = C2U("ScaleYDenominator");
286 [ + - ][ + - ]: 90 : aFilterData[7].Value = uno::makeAny( m_nScaleYDenominator );
287 : : }
288 : :
289 [ + - ][ + - ]: 90 : aProps[2].Name = C2U("FilterData");
290 [ + - ][ + - ]: 90 : aProps[2].Value <<= aFilterData;
291 : :
292 [ + - ][ + - ]: 90 : xExporter->setSourceDocument( uno::Reference< lang::XComponent >( m_xDrawPage, uno::UNO_QUERY) );
[ + - ]
293 [ + - ][ + - ]: 90 : if( xFilter->filter( aProps ) )
[ + - ]
294 : : {
295 [ + - ][ + - ]: 90 : xOutStream->flush();
296 [ + - ][ + - ]: 90 : xOutStream->closeOutput();
297 [ + - ]: 90 : uno::Reference< io::XSeekable > xSeekable( xOutStream, uno::UNO_QUERY );
298 [ + - ]: 90 : if( xSeekable.is() )
299 [ + - ][ + - ]: 90 : xSeekable->seek(0);
300 [ + - ][ + - ]: 90 : }
[ - + ][ - + ]
[ + - ]
301 : : }
302 : :
303 : 90 : uno::Any SAL_CALL ChartView::getTransferData( const datatransfer::DataFlavor& aFlavor )
304 : : throw (datatransfer::UnsupportedFlavorException, io::IOException, uno::RuntimeException)
305 : : {
306 : 90 : bool bHighContrastMetaFile( aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMETypeHighContrast));
307 : 90 : uno::Any aRet;
308 [ - + ][ + - ]: 90 : if( ! (bHighContrastMetaFile || aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType)) )
[ + - ]
309 : : return aRet;
310 : :
311 [ + - ]: 90 : update();
312 : :
313 [ + - ]: 90 : SvMemoryStream aStream( 1024, 1024 );
314 [ + - ]: 90 : utl::OStreamWrapper* pStreamWrapper = new utl::OStreamWrapper( aStream );
315 : :
316 [ + - ][ + - ]: 90 : uno::Reference< io::XOutputStream > xOutStream( pStreamWrapper );
317 [ + - ][ + - ]: 90 : uno::Reference< io::XInputStream > xInStream( pStreamWrapper );
318 [ + - ][ + - ]: 90 : uno::Reference< io::XSeekable > xSeekable( pStreamWrapper );
319 : :
320 [ + - ]: 90 : if( xOutStream.is() )
321 : : {
322 [ + - ]: 90 : this->getMetaFile( xOutStream, bHighContrastMetaFile );
323 : :
324 [ + - ][ + - ]: 90 : if( xInStream.is() && xSeekable.is() )
[ + - ]
325 : : {
326 [ + - ][ + - ]: 90 : xSeekable->seek(0);
327 [ + - ][ + - ]: 90 : sal_Int32 nBytesToRead = xInStream->available();
328 [ + - ]: 90 : uno::Sequence< sal_Int8 > aSeq( nBytesToRead );
329 [ + - ][ + - ]: 90 : xInStream->readBytes( aSeq, nBytesToRead);
330 [ + - ]: 90 : aRet <<= aSeq;
331 [ + - ][ + - ]: 90 : xInStream->closeInput();
[ + - ]
332 : : }
333 : : }
334 : :
335 [ + - ]: 90 : return aRet;
336 : : }
337 : 0 : uno::Sequence< datatransfer::DataFlavor > SAL_CALL ChartView::getTransferDataFlavors()
338 : : throw (uno::RuntimeException)
339 : : {
340 : 0 : uno::Sequence< datatransfer::DataFlavor > aRet(2);
341 : :
342 [ # # ]: 0 : aRet[0] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMEType,
343 : : C2U( "GDIMetaFile" ),
344 [ # # ][ # # ]: 0 : ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
345 [ # # ]: 0 : aRet[1] = datatransfer::DataFlavor( lcl_aGDIMetaFileMIMETypeHighContrast,
346 : : C2U( "GDIMetaFile" ),
347 [ # # ][ # # ]: 0 : ::getCppuType( (const uno::Sequence< sal_Int8 >*) NULL ) );
348 : :
349 : 0 : return aRet;
350 : : }
351 : 0 : ::sal_Bool SAL_CALL ChartView::isDataFlavorSupported( const datatransfer::DataFlavor& aFlavor )
352 : : throw (uno::RuntimeException)
353 : : {
354 : 0 : return ( aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMEType) ||
355 [ # # ][ # # ]: 0 : aFlavor.MimeType.equals(lcl_aGDIMetaFileMIMETypeHighContrast) );
356 : : }
357 : :
358 : : //-----------------------------------------------------------------
359 : : // ____ XUnoTunnel ___
360 : 532 : ::sal_Int64 SAL_CALL ChartView::getSomething( const uno::Sequence< ::sal_Int8 >& aIdentifier )
361 : : throw( uno::RuntimeException)
362 : : {
363 [ + - + - ]: 1596 : if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( ExplicitValueProvider::getUnoTunnelId().getConstArray(),
[ + - ]
364 : 1064 : aIdentifier.getConstArray(), 16 ) )
365 : : {
366 : 532 : ExplicitValueProvider* pProvider = this;
367 : 532 : return reinterpret_cast<sal_Int64>(pProvider);
368 : : }
369 : 532 : return 0;
370 : : }
371 : :
372 : : //-----------------------------------------------------------------
373 : : // lang::XServiceInfo
374 : :
375 [ # # ][ # # ]: 14 : APPHELPER_XSERVICEINFO_IMPL(ChartView,CHART_VIEW_SERVICE_IMPLEMENTATION_NAME)
[ # # ][ # # ]
[ # # ]
376 : :
377 : 14 : uno::Sequence< rtl::OUString > ChartView
378 : : ::getSupportedServiceNames_Static()
379 : : {
380 : 14 : uno::Sequence< rtl::OUString > aSNS( 1 );
381 [ + - ][ + - ]: 14 : aSNS.getArray()[ 0 ] = CHART_VIEW_SERVICE_NAME;
382 : 14 : return aSNS;
383 : : }
384 : :
385 : : //-----------------------------------------------------------------
386 : : //-----------------------------------------------------------------
387 : :
388 : 3538 : ::basegfx::B3DHomMatrix createTransformationSceneToScreen(
389 : : const ::basegfx::B2IRectangle& rDiagramRectangleWithoutAxes )
390 : : {
391 : 3538 : ::basegfx::B3DHomMatrix aM;
392 [ + - ]: 3538 : aM.scale(double(rDiagramRectangleWithoutAxes.getWidth())/FIXED_SIZE_FOR_3D_CHART_VOLUME
393 [ + - ][ + - ]: 7076 : , -double(rDiagramRectangleWithoutAxes.getHeight())/FIXED_SIZE_FOR_3D_CHART_VOLUME, 1.0 );
394 [ + - ]: 3538 : aM.translate(double(rDiagramRectangleWithoutAxes.getMinX())
395 [ + - ][ + - ]: 7076 : , double(rDiagramRectangleWithoutAxes.getMinY()+rDiagramRectangleWithoutAxes.getHeight()-1), 0);
[ + - ]
396 : 3538 : return aM;
397 : : }
398 : :
399 : 1364 : VCoordinateSystem* findInCooSysList( const std::vector< VCoordinateSystem* >& rVCooSysList
400 : : , const uno::Reference< XCoordinateSystem >& xCooSys )
401 : : {
402 [ + + ]: 1364 : for( size_t nC=0; nC < rVCooSysList.size(); nC++)
403 : : {
404 : 382 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
405 [ + - ][ + - ]: 382 : if(pVCooSys->getModel()==xCooSys)
406 : 382 : return pVCooSys;
407 : : }
408 : 1364 : return NULL;
409 : : }
410 : :
411 : 982 : VCoordinateSystem* addCooSysToList( std::vector< VCoordinateSystem* >& rVCooSysList
412 : : , const uno::Reference< XCoordinateSystem >& xCooSys
413 : : , const uno::Reference< frame::XModel >& xChartModel )
414 : : {
415 [ + - ]: 982 : VCoordinateSystem* pVCooSys = findInCooSysList( rVCooSysList, xCooSys );
416 [ + - ]: 982 : if( !pVCooSys )
417 : : {
418 [ + - ]: 982 : pVCooSys = VCoordinateSystem::createCoordinateSystem(xCooSys );
419 [ + - ]: 982 : if(pVCooSys)
420 : : {
421 [ + - ]: 982 : rtl::OUString aCooSysParticle( ObjectIdentifier::createParticleForCoordinateSystem( xCooSys, xChartModel ) );
422 [ + - ]: 982 : pVCooSys->setParticle(aCooSysParticle);
423 : :
424 [ + - ][ + - ]: 982 : pVCooSys->setExplicitCategoriesProvider( new ExplicitCategoriesProvider(xCooSys,xChartModel) );
[ + - ]
425 : :
426 [ + - ]: 982 : rVCooSysList.push_back( pVCooSys );
427 : : }
428 : : }
429 : 982 : return pVCooSys;
430 : : }
431 : :
432 : 3924 : VCoordinateSystem* lcl_getCooSysForPlotter( const std::vector< VCoordinateSystem* >& rVCooSysList, MinimumAndMaximumSupplier* pMinimumAndMaximumSupplier )
433 : : {
434 [ - + ]: 3924 : if(!pMinimumAndMaximumSupplier)
435 : 0 : return 0;
436 [ + - ]: 3924 : for( size_t nC=0; nC < rVCooSysList.size(); nC++)
437 : : {
438 : 3924 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
439 [ + - ]: 3924 : if(pVCooSys->hasMinimumAndMaximumSupplier( pMinimumAndMaximumSupplier ))
440 : 3924 : return pVCooSys;
441 : : }
442 : 3924 : return 0;
443 : : }
444 : :
445 : : typedef std::pair< sal_Int32, sal_Int32 > tFullAxisIndex; //first index is the dimension, second index is the axis index that indicates whether this is a main or secondary axis
446 : : typedef std::map< VCoordinateSystem*, tFullAxisIndex > tCoordinateSystemMap;
447 : :
448 [ + - ][ + - ]: 3984 : struct AxisUsage
449 : : {
450 : : AxisUsage();
451 : : ~AxisUsage();
452 : :
453 : : void addCoordinateSystem( VCoordinateSystem* pCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
454 : : ::std::vector< VCoordinateSystem* > getCoordinateSystems( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex );
455 : : sal_Int32 getMaxAxisIndexForDimension( sal_Int32 nDimensionIndex );
456 : :
457 : : ScaleAutomatism aScaleAutomatism;
458 : :
459 : : private:
460 : : tCoordinateSystemMap aCoordinateSystems;
461 : : std::map< sal_Int32, sal_Int32 > aMaxIndexPerDimension;
462 : : };
463 : :
464 : 1992 : AxisUsage::AxisUsage()
465 [ + - ][ + - ]: 1992 : : aScaleAutomatism(AxisHelper::createDefaultScale(),Date( Date::SYSTEM ))
[ + - ][ + - ]
[ + - ]
466 : : {
467 : 1992 : }
468 : :
469 : 5976 : AxisUsage::~AxisUsage()
470 : : {
471 : 5976 : aCoordinateSystems.clear();
472 : 5976 : }
473 : :
474 : 1992 : void AxisUsage::addCoordinateSystem( VCoordinateSystem* pCooSys, sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
475 : : {
476 [ + - ]: 1992 : if(!pCooSys)
477 : : return;
478 : :
479 [ + - ]: 1992 : tFullAxisIndex aFullAxisIndex( nDimensionIndex, nAxisIndex );
480 [ + - ]: 1992 : tCoordinateSystemMap::const_iterator aFound( aCoordinateSystems.find(pCooSys) );
481 : :
482 : : //use one scale only once for each coordinate system
483 : : //main axis are preferred over secondary axis
484 : : //value scales are preferred
485 [ - + ]: 1992 : if(aFound!=aCoordinateSystems.end())
486 : : {
487 : 0 : sal_Int32 nFoundAxisIndex = aFound->second.second;
488 [ # # ]: 0 : if( nFoundAxisIndex < nAxisIndex )
489 : : return;
490 : 0 : sal_Int32 nFoundDimension = aFound->second.first;
491 [ # # ]: 0 : if( nFoundDimension ==1 )
492 : : return;
493 [ # # ]: 0 : if( nFoundDimension < nDimensionIndex )
494 : : return;
495 : : }
496 [ + - ][ + - ]: 1992 : aCoordinateSystems[pCooSys] = aFullAxisIndex;
497 : :
498 : : //set maximum scale index
499 [ + - ][ + - ]: 1992 : std::map< sal_Int32, sal_Int32 >::const_iterator aIter = aMaxIndexPerDimension.find(nDimensionIndex);
500 [ + - ][ + - ]: 1992 : if( aIter != aMaxIndexPerDimension.end() )
[ - + ]
501 : : {
502 [ # # ]: 0 : sal_Int32 nCurrentMaxIndex = aIter->second;
503 [ # # ]: 0 : if( nCurrentMaxIndex < nAxisIndex )
504 [ # # ]: 0 : aMaxIndexPerDimension[nDimensionIndex]=nAxisIndex;
505 : : }
506 : : else
507 [ + - ]: 1992 : aMaxIndexPerDimension[nDimensionIndex]=nAxisIndex;
508 : : }
509 : 28028 : ::std::vector< VCoordinateSystem* > AxisUsage::getCoordinateSystems( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex )
510 : : {
511 [ + - ]: 28028 : ::std::vector< VCoordinateSystem* > aRet;
512 : :
513 : 28028 : tCoordinateSystemMap::const_iterator aIter;
514 [ + + ]: 56056 : for( aIter = aCoordinateSystems.begin(); aIter!=aCoordinateSystems.end();++aIter )
515 : : {
516 [ + + ]: 28028 : if( aIter->second.first != nDimensionIndex )
517 : 18042 : continue;
518 [ + + ]: 9986 : if( aIter->second.second != nAxisIndex )
519 : 154 : continue;
520 [ + - ]: 9832 : aRet.push_back( aIter->first );
521 : : }
522 : :
523 : 28028 : return aRet;
524 : : }
525 : 5976 : sal_Int32 AxisUsage::getMaxAxisIndexForDimension( sal_Int32 nDimensionIndex )
526 : : {
527 : 5976 : sal_Int32 nRet = -1;
528 [ + - ][ + - ]: 5976 : std::map< sal_Int32, sal_Int32 >::const_iterator aIter = aMaxIndexPerDimension.find(nDimensionIndex);
529 [ + - ][ + - ]: 5976 : if( aIter != aMaxIndexPerDimension.end() )
[ + + ]
530 [ + - ]: 1992 : nRet = aIter->second;
531 : 5976 : return nRet;
532 : : }
533 : :
534 : : //-----------------------------------------------------
535 : :
536 : : class SeriesPlotterContainer
537 : : {
538 : : public:
539 : : SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList );
540 : : ~SeriesPlotterContainer();
541 : :
542 : : void initializeCooSysAndSeriesPlotter( const uno::Reference< frame::XModel >& xChartModel );
543 : : void initAxisUsageList(const Date& rNullDate);
544 : : void doAutoScaling( const uno::Reference< frame::XModel >& xChartModel );
545 : : void updateScalesAndIncrementsOnAxes();
546 : : void setScalesFromCooSysToPlotter();
547 : : void setNumberFormatsFromAxes();
548 : : drawing::Direction3D getPreferredAspectRatio();
549 : :
550 : 993 : std::vector< VSeriesPlotter* >& getSeriesPlotterList() { return m_aSeriesPlotterList; }
551 : 993 : std::vector< VCoordinateSystem* >& getCooSysList() { return m_rVCooSysList; }
552 : : std::vector< LegendEntryProvider* > getLegendEntryProviderList();
553 : :
554 : : void AdaptScaleOfYAxisWithoutAttachedSeries( const uno::Reference< frame::XModel >& xChartModel );
555 : :
556 : : private:
557 : : std::vector< VSeriesPlotter* > m_aSeriesPlotterList;
558 : : std::vector< VCoordinateSystem* >& m_rVCooSysList;
559 : : ::std::map< uno::Reference< XAxis >, AxisUsage > m_aAxisUsageList;
560 : : sal_Int32 m_nMaxAxisIndex;
561 : : bool m_bChartTypeUsesShiftedCategoryPositionPerDefault;
562 : : sal_Int32 m_nDefaultDateNumberFormat;
563 : : };
564 : :
565 : 1003 : SeriesPlotterContainer::SeriesPlotterContainer( std::vector< VCoordinateSystem* >& rVCooSysList )
566 : : : m_rVCooSysList( rVCooSysList )
567 : : , m_nMaxAxisIndex(0)
568 : : , m_bChartTypeUsesShiftedCategoryPositionPerDefault(false)
569 [ + - ]: 1003 : , m_nDefaultDateNumberFormat(0)
570 : : {
571 : 1003 : }
572 : :
573 : 1003 : SeriesPlotterContainer::~SeriesPlotterContainer()
574 : : {
575 : : // - remove plotter from coordinatesystems
576 [ + + ]: 1985 : for( size_t nC=0; nC < m_rVCooSysList.size(); nC++)
577 [ + - ]: 982 : m_rVCooSysList[nC]->clearMinimumAndMaximumSupplierList();
578 : : // - delete all plotter
579 [ + - ]: 1003 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
580 [ + - ]: 1003 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
581 [ + - ][ + - ]: 1984 : for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
[ + + ]
582 [ + - ][ + - ]: 981 : delete *aPlotterIter;
583 : 1003 : m_aSeriesPlotterList.clear();
584 : 1003 : }
585 : :
586 : 1003 : std::vector< LegendEntryProvider* > SeriesPlotterContainer::getLegendEntryProviderList()
587 : : {
588 [ + - ]: 1003 : std::vector< LegendEntryProvider* > aRet( m_aSeriesPlotterList.size() );
589 [ + - ]: 1003 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
590 [ + - ]: 1003 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
591 : 1003 : sal_Int32 nN = 0;
592 [ + - ][ + - ]: 1984 : for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter, nN++ )
[ + + ]
593 [ + - ]: 981 : aRet[nN] = *aPlotterIter;
594 : 1003 : return aRet;
595 : : }
596 : :
597 : 1003 : void SeriesPlotterContainer::initializeCooSysAndSeriesPlotter(
598 : : const uno::Reference< frame::XModel >& xChartModel )
599 : : {
600 : : //------------ get model series from model
601 : 1003 : sal_Int32 nDiagramIndex = 0;//todo if more than one diagram is supported
602 [ + - ]: 1003 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
603 [ + + ]: 1003 : if( !xDiagram.is())
604 : : return;
605 : :
606 [ + - ]: 993 : uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY );
607 [ + - ]: 993 : uno::Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY );
608 [ + - ][ + - ]: 1894 : if( xChartDoc.is() && xChartDoc->hasInternalDataProvider()
[ + - ][ + + ]
[ + + ][ + + ]
609 [ + - ]: 901 : && DiagramHelper::isSupportingDateAxis( xDiagram ) )
610 [ + - ]: 882 : m_nDefaultDateNumberFormat=DiagramHelper::getDateNumberFormat( xNumberFormatsSupplier );
611 : :
612 [ + - ]: 993 : sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
613 [ - + ]: 993 : if(!nDimensionCount)
614 : : {
615 : : //@todo handle mixed dimension
616 : 0 : nDimensionCount = 2;
617 : : }
618 : :
619 : 993 : sal_Bool bSortByXValues = sal_False;
620 : 993 : sal_Bool bConnectBars = sal_False;
621 : 993 : sal_Bool bGroupBarsPerAxis = sal_True;
622 : 993 : sal_Bool bIncludeHiddenCells = sal_True;
623 : 993 : sal_Int32 nStartingAngle = 90;
624 : : try
625 : : {
626 [ + - ]: 993 : uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY_THROW );
627 [ + - ][ + - ]: 993 : xDiaProp->getPropertyValue( C2U( "SortByXValues" ) ) >>= bSortByXValues;
[ + - ]
628 [ + - ][ + - ]: 993 : xDiaProp->getPropertyValue( C2U( "ConnectBars" ) ) >>= bConnectBars;
[ + - ]
629 [ + - ][ + - ]: 993 : xDiaProp->getPropertyValue( C2U( "GroupBarsPerAxis" ) ) >>= bGroupBarsPerAxis;
[ + - ]
630 [ + - ][ + - ]: 993 : xDiaProp->getPropertyValue( C2U( "IncludeHiddenCells" ) ) >>= bIncludeHiddenCells;
[ + - ]
631 [ + - ][ + - ]: 993 : xDiaProp->getPropertyValue( C2U( "StartingAngle" ) ) >>= nStartingAngle;
[ # # ][ + - ]
632 : : }
633 [ # # ]: 0 : catch( const uno::Exception & ex )
634 : : {
635 : : ASSERT_EXCEPTION( ex );
636 : : }
637 : :
638 : : //---------------------------------------------------------------------
639 : : //prepare for autoscaling and shape creation
640 : : // - create plotter for charttypes (for each first scale group at each plotter, as they are independent)
641 : : // - add series to plotter (thus each charttype can provide minimum and maximum values for autoscaling)
642 : : // - add plotter to coordinate systems
643 : :
644 : : //iterate through all coordinate systems
645 [ + - ]: 993 : uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
646 : : OSL_ASSERT( xCooSysContainer.is());
647 [ - + ]: 993 : if( !xCooSysContainer.is())
648 : : return;
649 [ + - ][ + - ]: 993 : uno::Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme());
650 [ + - ][ + - ]: 993 : uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
651 : 993 : sal_Int32 nGlobalSeriesIndex = 0;//for automatic symbols
652 [ + + ]: 1975 : for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS )
653 : : {
654 [ + - ]: 982 : uno::Reference< XCoordinateSystem > xCooSys( aCooSysList[nCS] );
655 [ + - ]: 982 : VCoordinateSystem* pVCooSys = addCooSysToList(m_rVCooSysList,xCooSys,xChartModel);
656 : :
657 : : //iterate through all chart types in the current coordinate system
658 [ + - ]: 982 : uno::Reference< XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY );
659 : : OSL_ASSERT( xChartTypeContainer.is());
660 [ - + ]: 982 : if( !xChartTypeContainer.is() )
661 : 0 : continue;
662 [ + - ][ + - ]: 982 : uno::Sequence< uno::Reference< XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() );
663 [ + + ]: 1963 : for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT )
664 : : {
665 [ + - ]: 981 : uno::Reference< XChartType > xChartType( aChartTypeList[nT] );
666 : :
667 [ + - ]: 981 : if(nT==0)
668 [ + - ]: 981 : m_bChartTypeUsesShiftedCategoryPositionPerDefault = ChartTypeHelper::shiftCategoryPosAtXAxisPerDefault( xChartType );
669 : :
670 [ + - ]: 981 : bool bExcludingPositioning = DiagramPositioningMode_EXCLUDING == DiagramHelper::getDiagramPositioningMode( xDiagram );
671 [ + - ]: 981 : VSeriesPlotter* pPlotter = VSeriesPlotter::createSeriesPlotter( xChartType, nDimensionCount, bExcludingPositioning );
672 [ - + ]: 981 : if( !pPlotter )
673 : 0 : continue;
674 [ + - ]: 981 : m_aSeriesPlotterList.push_back( pPlotter );
675 [ + - ]: 981 : pPlotter->setNumberFormatsSupplier( xNumberFormatsSupplier );
676 [ + - ]: 981 : pPlotter->setColorScheme( xColorScheme );
677 [ + - ]: 981 : if(pVCooSys)
678 [ + - ][ + - ]: 981 : pPlotter->setExplicitCategoriesProvider( pVCooSys->getExplicitCategoriesProvider() );
679 [ + - ]: 981 : sal_Int32 nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment( xDiagram, xChartType );
680 : :
681 [ + - ]: 981 : if(pVCooSys)
682 [ + - ][ + - ]: 981 : pVCooSys->addMinimumAndMaximumSupplier(pPlotter);
683 : :
684 : : //------------ add series to plotter and thus prepare him(it) for providing minimum and maximum values
685 [ + - ]: 981 : uno::Reference< XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY );
686 : : OSL_ASSERT( xDataSeriesContainer.is());
687 [ - + ]: 981 : if( !xDataSeriesContainer.is() )
688 : 0 : continue;
689 : 981 : sal_Int32 zSlot=-1;
690 : 981 : sal_Int32 xSlot=-1;
691 : 981 : sal_Int32 ySlot=-1;
692 [ + - ][ + - ]: 981 : uno::Sequence< uno::Reference< XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() );
693 [ + + ]: 4187 : for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS )
694 : : {
695 [ + - ][ + - ]: 3206 : uno::Reference< XDataSeries > xDataSeries( aSeriesList[nS], uno::UNO_QUERY );
696 [ - + ]: 3206 : if(!xDataSeries.is())
697 : 0 : continue;
698 [ + + ][ + - ]: 3206 : if( !bIncludeHiddenCells && !DataSeriesHelper::hasUnhiddenData(xDataSeries) )
[ - + ][ - + ]
699 : 0 : continue;
700 : :
701 [ + - ][ + - ]: 3206 : VDataSeries* pSeries = new VDataSeries( xDataSeries );
702 : :
703 [ + - ]: 3206 : pSeries->setGlobalSeriesIndex(nGlobalSeriesIndex);
704 : 3206 : nGlobalSeriesIndex++;
705 : :
706 [ - + ]: 3206 : if( bSortByXValues )
707 [ # # ]: 0 : pSeries->doSortByXValues();
708 : :
709 [ + - ]: 3206 : pSeries->setConnectBars( bConnectBars );
710 [ + - ]: 3206 : pSeries->setGroupBarsPerAxis( bGroupBarsPerAxis );
711 [ + - ]: 3206 : pSeries->setStartingAngle( nStartingAngle );
712 : :
713 [ + - ]: 3206 : pSeries->setMissingValueTreatment( nMissingValueTreatment );
714 : :
715 [ + - ]: 3206 : rtl::OUString aSeriesParticle( ObjectIdentifier::createParticleForSeries( nDiagramIndex, nCS, nT, nS ) );
716 [ + - ]: 3206 : pSeries->setParticle(aSeriesParticle);
717 : :
718 [ + - ]: 3206 : OUString aRole( ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( xChartType ) );
719 [ + - ]: 3206 : pSeries->setRoleOfSequenceForDataLabelNumberFormatDetection(aRole);
720 : :
721 : : //ignore secondary axis for charttypes that do not suppoert them
722 [ + - ][ - + ]: 3206 : if( pSeries->getAttachedAxisIndex() != MAIN_AXIS_INDEX &&
[ # # ][ - + ]
723 [ # # ]: 0 : !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount, 1 ) )
724 : : {
725 [ # # ]: 0 : pSeries->setAttachedAxisIndex(MAIN_AXIS_INDEX);
726 : : }
727 : :
728 [ + - ]: 3206 : StackingDirection eDirection = pSeries->getStackingDirection();
729 [ + + + - ]: 3206 : switch(eDirection)
730 : : {
731 : : case StackingDirection_NO_STACKING:
732 : 3161 : xSlot++; ySlot=-1;
733 [ + + ]: 3161 : if(zSlot<0)
734 : 966 : zSlot=0;
735 : 3161 : break;
736 : : case StackingDirection_Y_STACKING:
737 : 18 : ySlot++;
738 [ + + ]: 18 : if(xSlot<0)
739 : 6 : xSlot=0;
740 [ + + ]: 18 : if(zSlot<0)
741 : 6 : zSlot=0;
742 : 18 : break;
743 : : case StackingDirection_Z_STACKING:
744 : 27 : zSlot++; xSlot=-1; ySlot=-1;
745 : 27 : break;
746 : : default:
747 : : // UNO enums have one additional auto-generated case
748 : 0 : break;
749 : : }
750 [ + - ]: 3206 : pPlotter->addSeries( pSeries, zSlot, xSlot, ySlot );
751 [ + - ]: 3206 : }
752 [ + - ][ - + ]: 981 : }
[ + - ]
753 [ + - ][ - + ]: 982 : }
[ + - ]
754 : :
755 : : //transport seriesnames to the coordinatesystems if needed
756 [ + + ]: 993 : if( !m_aSeriesPlotterList.empty() )
757 : : {
758 [ + - ]: 981 : uno::Sequence< rtl::OUString > aSeriesNames;
759 : 981 : bool bSeriesNamesInitialized = false;
760 [ + + ]: 1962 : for( size_t nC=0; nC < m_rVCooSysList.size(); nC++)
761 : : {
762 : 981 : VCoordinateSystem* pVCooSys = m_rVCooSysList[nC];
763 [ - + ]: 981 : if(!pVCooSys)
764 : 0 : continue;
765 [ + - ][ + + ]: 981 : if( pVCooSys->needSeriesNamesForAxis() )
766 : : {
767 [ + - ]: 14 : if(!bSeriesNamesInitialized)
768 : : {
769 : 14 : VSeriesPlotter* pSeriesPlotter = m_aSeriesPlotterList[0];
770 [ + - ]: 14 : if( pSeriesPlotter )
771 [ + - ][ + - ]: 14 : aSeriesNames = pSeriesPlotter->getSeriesNames();
[ + - ]
772 : 14 : bSeriesNamesInitialized = true;
773 : : }
774 [ + - ]: 14 : pVCooSys->setSeriesNamesForAxis( aSeriesNames );
775 : : }
776 [ + - ]: 981 : }
777 [ + - ][ - + ]: 1003 : }
[ - + ][ - + ]
[ + + ]
778 : : }
779 : :
780 : 993 : void SeriesPlotterContainer::initAxisUsageList(const Date& rNullDate)
781 : : {
782 : 993 : m_aAxisUsageList.clear();
783 : : size_t nC;
784 [ + + ]: 1975 : for( nC=0; nC < m_rVCooSysList.size(); nC++)
785 : : {
786 : 982 : VCoordinateSystem* pVCooSys = m_rVCooSysList[nC];
787 [ + + ]: 3928 : for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
788 : : {
789 [ + - ]: 2946 : uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel();
790 [ + - ][ + - ]: 2946 : sal_Int32 nDimensionCount = xCooSys->getDimension();
791 [ + + ]: 2946 : if( nDimensionIndex >= nDimensionCount )
792 : 968 : continue;
793 [ + - ][ + - ]: 1978 : bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionCount, nDimensionIndex );
794 [ + - ][ + - ]: 1978 : const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
795 [ + + ]: 3970 : for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
796 : : {
797 [ + - ][ + - ]: 1992 : uno::Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
798 : : OSL_ASSERT( xAxis.is());
799 [ + - ]: 1992 : if( xAxis.is())
800 : : {
801 [ + - ][ + - ]: 1992 : if(m_aAxisUsageList.find(xAxis)==m_aAxisUsageList.end())
802 : : {
803 [ + - ][ + - ]: 1992 : chart2::ScaleData aSourceScale = xAxis->getScaleData();
804 [ + - ]: 1992 : ExplicitCategoriesProvider* pExplicitCategoriesProvider = pVCooSys->getExplicitCategoriesProvider();
805 [ + + ]: 1992 : if( nDimensionIndex==0 )
806 [ + - ]: 989 : AxisHelper::checkDateAxis( aSourceScale, pExplicitCategoriesProvider, bChartTypeAllowsDateAxis );
807 [ + + ][ + + ]: 2091 : if( (aSourceScale.AxisType == AxisType::CATEGORY && m_bChartTypeUsesShiftedCategoryPositionPerDefault)
[ + + ][ + - ]
[ + - ][ + - ]
[ + + ][ + + ]
808 [ + - ]: 99 : || (aSourceScale.AxisType==AxisType::CATEGORY && pExplicitCategoriesProvider && pExplicitCategoriesProvider->hasComplexCategories() )
809 : : || aSourceScale.AxisType == AxisType::DATE
810 : : || aSourceScale.AxisType == AxisType::SERIES )
811 : 904 : aSourceScale.ShiftedCategoryPosition = true;
812 : : else
813 : 1088 : aSourceScale.ShiftedCategoryPosition = false;
814 [ + - ][ + - ]: 1992 : m_aAxisUsageList[xAxis].aScaleAutomatism = ScaleAutomatism(aSourceScale,rNullDate);
[ + - ][ + - ]
[ + - ]
815 : : }
816 [ + - ]: 1992 : AxisUsage& rAxisUsage = m_aAxisUsageList[xAxis];
817 [ + - ]: 1992 : rAxisUsage.addCoordinateSystem(pVCooSys,nDimensionIndex,nAxisIndex);
818 : : }
819 : 1992 : }
820 [ + + ]: 2946 : }
821 : : }
822 : :
823 : 993 : ::std::map< uno::Reference< XAxis >, AxisUsage >::iterator aAxisIter = m_aAxisUsageList.begin();
824 : 993 : const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
825 : :
826 : : //init m_nMaxAxisIndex
827 : 993 : m_nMaxAxisIndex = 0;
828 [ + + ]: 3972 : for(sal_Int32 nDimensionIndex=0; nDimensionIndex<3; nDimensionIndex++)
829 : : {
830 [ + + ]: 8955 : for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
831 : : {
832 [ + - ]: 5976 : sal_Int32 nLocalMax = aAxisIter->second.getMaxAxisIndexForDimension( nDimensionIndex );
833 [ + + ]: 5976 : if( m_nMaxAxisIndex < nLocalMax )
834 : 7 : m_nMaxAxisIndex = nLocalMax;
835 : : }
836 : : }
837 : 993 : }
838 : :
839 : 1955 : void SeriesPlotterContainer::setScalesFromCooSysToPlotter()
840 : : {
841 : : //set scales to plotter to enable them to provide the preferred scene AspectRatio
842 [ + - ]: 1955 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
843 [ + - ]: 1955 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
844 [ + - ][ + - ]: 3898 : for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
[ + + ]
845 : : {
846 : 1943 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
847 [ + - ][ + - ]: 1943 : VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter );
848 [ + - ]: 1943 : if(pVCooSys)
849 : : {
850 [ + - ][ + - ]: 1943 : pSeriesPlotter->setScales( pVCooSys->getExplicitScales(0,0), pVCooSys->getPropertySwapXAndYAxis() );
[ + - ]
851 [ + - ]: 1943 : sal_Int32 nMaxAxisIndex = pVCooSys->getMaximumAxisIndexByDimension(1);//only additional value axis are relevant for series plotter
852 [ + + ]: 1957 : for( sal_Int32 nI=1; nI<=nMaxAxisIndex; nI++ )
853 [ + - ][ + - ]: 14 : pSeriesPlotter->addSecondaryValueScale( pVCooSys->getExplicitScale(1,nI), nI );
[ + - ]
854 : : }
855 : : }
856 : 1955 : }
857 : :
858 : 993 : void SeriesPlotterContainer::setNumberFormatsFromAxes()
859 : : {
860 : : //set numberformats to plotter to enable them to display the data labels in the numberformat of the axis
861 : :
862 [ + - ]: 993 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
863 [ + - ]: 993 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
864 [ + - ][ + - ]: 1974 : for( aPlotterIter = m_aSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
[ + + ]
865 : : {
866 : 981 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
867 [ + - ][ + - ]: 981 : VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( m_rVCooSysList, pSeriesPlotter );
868 [ + - ]: 981 : if(pVCooSys)
869 : : {
870 [ + - ]: 981 : AxesNumberFormats aAxesNumberFormats;
871 [ + - ]: 981 : uno::Reference< XCoordinateSystem > xCooSys = pVCooSys->getModel();
872 [ + - ][ + - ]: 981 : sal_Int32 nDimensionCount = xCooSys->getDimension();
873 [ + + ]: 2957 : for(sal_Int32 nDimensionIndex=0; nDimensionIndex<nDimensionCount; ++nDimensionIndex)
874 : : {
875 [ + - ][ + - ]: 1976 : const sal_Int32 nMaximumAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nDimensionIndex);
876 [ + + ]: 3966 : for(sal_Int32 nAxisIndex=0; nAxisIndex<=nMaximumAxisIndex; ++nAxisIndex)
877 : : {
878 : : try
879 : : {
880 [ + - ][ + - ]: 1990 : Reference< beans::XPropertySet > xAxisProp( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ), uno::UNO_QUERY );
[ + - ]
881 [ + - ]: 1990 : if( xAxisProp.is())
882 : : {
883 : 1990 : sal_Int32 nNumberFormatKey(0);
884 [ + - ][ + - ]: 1990 : if( xAxisProp->getPropertyValue( C2U( "NumberFormat" ) ) >>= nNumberFormatKey )
[ + - ][ + + ]
885 : : {
886 [ + - ]: 459 : aAxesNumberFormats.setFormat( nNumberFormatKey, nDimensionIndex, nAxisIndex );
887 : : }
888 [ + + ]: 1531 : else if( nDimensionIndex==0 )
889 : : {
890 : : //provide a default date format for date axis with own data
891 [ + - ]: 1990 : aAxesNumberFormats.setFormat( m_nDefaultDateNumberFormat, nDimensionIndex, nAxisIndex );
892 : : }
893 [ # # ]: 1990 : }
894 : : }
895 [ # # ]: 0 : catch( const lang::IndexOutOfBoundsException& e )
896 : : {
897 : : ASSERT_EXCEPTION( e );
898 : : }
899 : : }
900 : : }
901 [ + - ]: 981 : pSeriesPlotter->setAxesNumberFormats( aAxesNumberFormats );
902 : : }
903 : : }
904 : 993 : }
905 : :
906 : 962 : void SeriesPlotterContainer::updateScalesAndIncrementsOnAxes()
907 : : {
908 [ + + ]: 1924 : for( size_t nC=0; nC < m_rVCooSysList.size(); nC++)
909 : 962 : m_rVCooSysList[nC]->updateScalesAndIncrementsOnAxes();
910 : 962 : }
911 : :
912 : 1955 : void SeriesPlotterContainer::doAutoScaling( const uno::Reference< frame::XModel >& xChartModel )
913 : : {
914 : : //precondition: need a initialized m_aSeriesPlotterList
915 : : //precondition: need a initialized m_aAxisUsageList
916 : :
917 : 1955 : ::std::map< uno::Reference< XAxis >, AxisUsage >::iterator aAxisIter = m_aAxisUsageList.begin();
918 : 1955 : const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
919 : :
920 : : //iterate over the main scales first than secondary axis
921 : : size_t nC;
922 : 1955 : sal_Int32 nAxisIndex=0;
923 [ + + ]: 3924 : for( nAxisIndex=0; nAxisIndex<=m_nMaxAxisIndex; nAxisIndex++ )
924 : : {
925 : :
926 : : // - first do autoscale for all x and z scales (because they are treated independent)
927 [ + + ]: 5983 : for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
928 : : {
929 : 4014 : AxisUsage& rAxisUsage = (*aAxisIter).second;
930 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_X = rAxisUsage.getCoordinateSystems(0,nAxisIndex);
931 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_Z = rAxisUsage.getCoordinateSystems(2,nAxisIndex);
932 : :
933 [ + + ]: 5972 : for( nC=0; nC < aVCooSysList_X.size(); nC++)
934 [ + - ]: 1958 : aVCooSysList_X[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,0,nAxisIndex);
935 [ + + ]: 4042 : for( nC=0; nC < aVCooSysList_Z.size(); nC++)
936 [ + - ]: 28 : aVCooSysList_Z[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,2,nAxisIndex);
937 : :
938 [ + - ]: 4014 : ExplicitScaleData aExplicitScale;
939 [ + - ]: 4014 : ExplicitIncrementData aExplicitIncrement;
940 [ + - ]: 4014 : rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
941 : :
942 [ + + ]: 5972 : for( nC=0; nC < aVCooSysList_X.size(); nC++)
943 [ + - ]: 1958 : aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement );
944 [ + + ]: 4042 : for( nC=0; nC < aVCooSysList_Z.size(); nC++)
945 [ + - ]: 28 : aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement );
946 [ + - ]: 4014 : }
947 : :
948 : : // - second do autoscale for the dependent y scales (the coordinate systems are prepared with x and z scales already )
949 [ + + ]: 5983 : for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
950 : : {
951 : 4014 : AxisUsage& rAxisUsage = (*aAxisIter).second;
952 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_X = rAxisUsage.getCoordinateSystems(0,nAxisIndex);
953 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_Y = rAxisUsage.getCoordinateSystems(1,nAxisIndex);
954 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_Z = rAxisUsage.getCoordinateSystems(2,nAxisIndex);
955 : :
956 [ + + ]: 4014 : if(!aVCooSysList_Y.size())
957 : 2056 : continue;
958 : :
959 [ + + ]: 3916 : for( nC=0; nC < aVCooSysList_Y.size(); nC++)
960 [ + - ]: 1958 : aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex(rAxisUsage.aScaleAutomatism,1,nAxisIndex);
961 : :
962 [ + - ]: 1958 : ExplicitScaleData aExplicitScale;
963 [ + - ]: 1958 : ExplicitIncrementData aExplicitIncrement;
964 [ + - ]: 1958 : rAxisUsage.aScaleAutomatism.calculateExplicitScaleAndIncrement( aExplicitScale, aExplicitIncrement );
965 : :
966 [ - + ]: 1958 : for( nC=0; nC < aVCooSysList_X.size(); nC++)
967 [ # # ]: 0 : aVCooSysList_X[nC]->setExplicitScaleAndIncrement( 0, nAxisIndex, aExplicitScale, aExplicitIncrement );
968 [ + + ]: 3916 : for( nC=0; nC < aVCooSysList_Y.size(); nC++)
969 [ + - ]: 1958 : aVCooSysList_Y[nC]->setExplicitScaleAndIncrement( 1, nAxisIndex, aExplicitScale, aExplicitIncrement );
970 [ - + ]: 1958 : for( nC=0; nC < aVCooSysList_Z.size(); nC++)
971 [ # # ]: 0 : aVCooSysList_Z[nC]->setExplicitScaleAndIncrement( 2, nAxisIndex, aExplicitScale, aExplicitIncrement );
972 [ + - ][ + + ]: 4014 : }
[ + + ][ + + ]
973 : : }
974 [ + - ]: 1955 : AdaptScaleOfYAxisWithoutAttachedSeries( xChartModel );
975 : 1955 : }
976 : :
977 : 1955 : void SeriesPlotterContainer::AdaptScaleOfYAxisWithoutAttachedSeries( const uno::Reference< frame::XModel >& xChartModel )
978 : : {
979 : : //issue #i80518#
980 : :
981 : 1955 : ::std::map< uno::Reference< XAxis >, AxisUsage >::iterator aAxisIter = m_aAxisUsageList.begin();
982 : 1955 : const ::std::map< uno::Reference< XAxis >, AxisUsage >::const_iterator aAxisEndIter = m_aAxisUsageList.end();
983 : :
984 [ + + ]: 3924 : for( sal_Int32 nAxisIndex=0; nAxisIndex<=m_nMaxAxisIndex; nAxisIndex++ )
985 : : {
986 [ + + ]: 5983 : for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
987 : : {
988 : 4014 : AxisUsage& rAxisUsage = (*aAxisIter).second;
989 [ + - ]: 4014 : ::std::vector< VCoordinateSystem* > aVCooSysList_Y = rAxisUsage.getCoordinateSystems( 1, nAxisIndex );
990 [ + + ]: 4014 : if( !aVCooSysList_Y.size() )
991 : 2056 : continue;
992 : :
993 [ + - ]: 1958 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
994 [ + - ]: 1958 : if( xDiagram.is() )
995 : : {
996 : 1958 : bool bSeriesAttachedToThisAxis = false;
997 : 1958 : sal_Int32 nAttachedAxisIndex = -1;
998 : : {
999 [ + - ]: 1958 : ::std::vector< Reference< XDataSeries > > aSeriesVector( DiagramHelper::getDataSeriesFromDiagram( xDiagram ) );
1000 [ + - ]: 1958 : ::std::vector< Reference< XDataSeries > >::const_iterator aIter = aSeriesVector.begin();
1001 [ + - ][ + + ]: 2000 : for( ; aIter != aSeriesVector.end(); ++aIter )
1002 : : {
1003 [ + - ]: 1982 : sal_Int32 nCurrentIndex = DataSeriesHelper::getAttachedAxisIndex( *aIter );
1004 [ + + ]: 1982 : if( nAxisIndex == nCurrentIndex )
1005 : : {
1006 : 1940 : bSeriesAttachedToThisAxis = true;
1007 : 1940 : break;
1008 : : }
1009 [ + + ][ - + ]: 42 : else if( nAttachedAxisIndex<0 || nAttachedAxisIndex>nCurrentIndex )
1010 : 14 : nAttachedAxisIndex=nCurrentIndex;
1011 : 1958 : }
1012 : : }
1013 : :
1014 [ + + ][ + + ]: 1958 : if( !bSeriesAttachedToThisAxis && nAttachedAxisIndex >= 0 )
1015 : : {
1016 [ + + ]: 28 : for( size_t nC = 0; nC < aVCooSysList_Y.size(); ++nC )
1017 : : {
1018 [ + - ]: 14 : aVCooSysList_Y[nC]->prepareScaleAutomatismForDimensionAndIndex( rAxisUsage.aScaleAutomatism, 1, nAttachedAxisIndex );
1019 : :
1020 [ + - ]: 14 : ExplicitScaleData aExplicitScaleSource = aVCooSysList_Y[nC]->getExplicitScale( 1,nAttachedAxisIndex );
1021 [ + - ]: 14 : ExplicitIncrementData aExplicitIncrementSource = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAttachedAxisIndex );
1022 : :
1023 [ + - ]: 14 : ExplicitScaleData aExplicitScaleDest = aVCooSysList_Y[nC]->getExplicitScale( 1,nAxisIndex );;
1024 [ + - ]: 14 : ExplicitIncrementData aExplicitIncrementDest = aVCooSysList_Y[nC]->getExplicitIncrement( 1,nAxisIndex );;
1025 : :
1026 : 14 : aExplicitScaleDest.Orientation = aExplicitScaleSource.Orientation;
1027 [ + - ]: 14 : aExplicitScaleDest.Scaling = aExplicitScaleSource.Scaling;
1028 : 14 : aExplicitScaleDest.AxisType = aExplicitScaleSource.AxisType;
1029 : :
1030 : 14 : aExplicitIncrementDest.BaseValue = aExplicitIncrementSource.BaseValue;
1031 : :
1032 [ + - ]: 14 : ScaleData aScale( rAxisUsage.aScaleAutomatism.getScale() );
1033 [ + - ]: 14 : if( !aScale.Minimum.hasValue() )
1034 : : {
1035 : 14 : bool bNewMinOK = true;
1036 : 14 : double fMax=0.0;
1037 [ - + ]: 14 : if( aScale.Maximum >>= fMax )
1038 : 0 : bNewMinOK = (aExplicitScaleSource.Minimum <= fMax);
1039 [ + - ]: 14 : if( bNewMinOK )
1040 : 14 : aExplicitScaleDest.Minimum = aExplicitScaleSource.Minimum;
1041 : : }
1042 : : else
1043 : 0 : aExplicitIncrementDest.BaseValue = aExplicitScaleDest.Minimum;
1044 : :
1045 [ + - ]: 14 : if( !aScale.Maximum.hasValue() )
1046 : : {
1047 : 14 : bool bNewMaxOK = true;
1048 : 14 : double fMin=0.0;
1049 [ - + ]: 14 : if( aScale.Minimum >>= fMin )
1050 : 0 : bNewMaxOK = (fMin <= aExplicitScaleSource.Maximum);
1051 [ + - ]: 14 : if( bNewMaxOK )
1052 : 14 : aExplicitScaleDest.Maximum = aExplicitScaleSource.Maximum;
1053 : : }
1054 [ + - ]: 14 : if( !aScale.Origin.hasValue() )
1055 : 14 : aExplicitScaleDest.Origin = aExplicitScaleSource.Origin;
1056 : :
1057 [ + - ]: 14 : if( !aScale.IncrementData.Distance.hasValue() )
1058 : 14 : aExplicitIncrementDest.Distance = aExplicitIncrementSource.Distance;
1059 : :
1060 : 14 : bool bAutoMinorInterval = true;
1061 [ + - ]: 14 : if( aScale.IncrementData.SubIncrements.getLength() )
1062 [ + - ]: 14 : bAutoMinorInterval = !( aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() );
1063 [ + - ]: 14 : if( bAutoMinorInterval )
1064 : : {
1065 [ + - ][ + - ]: 14 : if( !aExplicitIncrementDest.SubIncrements.empty() && !aExplicitIncrementSource.SubIncrements.empty() )
[ + - ]
1066 [ + - ]: 14 : aExplicitIncrementDest.SubIncrements[0].IntervalCount =
1067 [ + - ]: 14 : aExplicitIncrementSource.SubIncrements[0].IntervalCount;
1068 : : }
1069 : :
1070 [ + - ]: 14 : aVCooSysList_Y[nC]->setExplicitScaleAndIncrement( 1, nAxisIndex, aExplicitScaleDest, aExplicitIncrementDest );
1071 [ + - ][ + - ]: 14 : }
[ + - ]
1072 : : }
1073 : : }
1074 [ + + ]: 4014 : }
1075 : : }
1076 : :
1077 [ + - ][ + - ]: 1955 : if( AxisHelper::isAxisPositioningEnabled() )
1078 : : {
1079 : : //correct origin for y main axis (the origin is where the other main axis crosses)
1080 : 1955 : sal_Int32 nAxisIndex=0;
1081 : 1955 : sal_Int32 nDimensionIndex=1;
1082 [ + + ]: 5899 : for( aAxisIter = m_aAxisUsageList.begin(); aAxisIter != aAxisEndIter; ++aAxisIter )
1083 : : {
1084 : 3944 : AxisUsage& rAxisUsage = (*aAxisIter).second;
1085 [ + - ]: 3944 : ::std::vector< VCoordinateSystem* > aVCooSysList = rAxisUsage.getCoordinateSystems(nDimensionIndex,nAxisIndex);
1086 : : size_t nC;
1087 [ + + ]: 5888 : for( nC=0; nC < aVCooSysList.size(); nC++)
1088 : : {
1089 [ + - ]: 1944 : ExplicitScaleData aExplicitScale( aVCooSysList[nC]->getExplicitScale( nDimensionIndex, nAxisIndex ) );
1090 [ + - ]: 1944 : ExplicitIncrementData aExplicitIncrement( aVCooSysList[nC]->getExplicitIncrement( nDimensionIndex, nAxisIndex ) );
1091 : :
1092 [ + - ]: 1944 : Reference< chart2::XCoordinateSystem > xCooSys( aVCooSysList[nC]->getModel() );
1093 [ + - ][ + - ]: 1944 : Reference< XAxis > xAxis( xCooSys->getAxisByDimension( nDimensionIndex, nAxisIndex ) );
1094 [ + - ][ + - ]: 1944 : Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ), uno::UNO_QUERY );
1095 : :
1096 : 1944 : ::com::sun::star::chart::ChartAxisPosition eCrossingMainAxisPos( ::com::sun::star::chart::ChartAxisPosition_ZERO );
1097 [ + - ]: 1944 : if( xCrossingMainAxis.is() )
1098 : : {
1099 [ + - ][ + - ]: 1944 : xCrossingMainAxis->getPropertyValue(C2U( "CrossoverPosition" )) >>= eCrossingMainAxisPos;
[ + - ][ + - ]
1100 [ + + ]: 1944 : if( ::com::sun::star::chart::ChartAxisPosition_VALUE == eCrossingMainAxisPos )
1101 : : {
1102 : 206 : double fValue = 0.0;
1103 [ + - ][ + - ]: 206 : xCrossingMainAxis->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue;
[ + - ]
1104 : 206 : aExplicitScale.Origin = fValue;
1105 : : }
1106 [ + - ]: 1738 : else if( ::com::sun::star::chart::ChartAxisPosition_ZERO == eCrossingMainAxisPos )
1107 : 1738 : aExplicitScale.Origin = 0.0;
1108 [ # # ]: 0 : else if( ::com::sun::star::chart::ChartAxisPosition_START == eCrossingMainAxisPos )
1109 : 0 : aExplicitScale.Origin = aExplicitScale.Minimum;
1110 [ # # ]: 0 : else if( ::com::sun::star::chart::ChartAxisPosition_END == eCrossingMainAxisPos )
1111 : 0 : aExplicitScale.Origin = aExplicitScale.Maximum;
1112 : : }
1113 : :
1114 [ + - ]: 1944 : aVCooSysList[nC]->setExplicitScaleAndIncrement( nDimensionIndex, nAxisIndex, aExplicitScale, aExplicitIncrement );
1115 [ + - ]: 1944 : }
1116 : 3944 : }
1117 : : }
1118 : 1955 : }
1119 : :
1120 : 993 : drawing::Direction3D SeriesPlotterContainer::getPreferredAspectRatio()
1121 : : {
1122 : 993 : drawing::Direction3D aPreferredAspectRatio(1.0,1.0,1.0);
1123 : :
1124 : 993 : sal_Int32 nPlotterCount=0;
1125 : : //get a list of all preferred aspect ratios and combine them
1126 : : //first with special demands wins (less or equal zero <-> arbitrary)
1127 : : double fx, fy, fz;
1128 : 993 : fx = fy = fz = -1.0;
1129 [ + - ]: 993 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = m_aSeriesPlotterList.begin();
1130 [ + - ]: 993 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = m_aSeriesPlotterList.end();
1131 [ + - ][ + + ]: 1974 : for( aPlotterIter = m_aSeriesPlotterList.begin(), nPlotterCount=0
1132 [ + - ]: 993 : ; aPlotterIter != aPlotterEnd; ++aPlotterIter, ++nPlotterCount )
1133 : : {
1134 [ + - ]: 981 : drawing::Direction3D aSingleRatio( (*aPlotterIter)->getPreferredDiagramAspectRatio() );
1135 [ + - ][ + + ]: 981 : if( fx<0 && aSingleRatio.DirectionX>0 )
1136 : 33 : fx = aSingleRatio.DirectionX;
1137 : :
1138 [ + - ][ + + ]: 981 : if( fy<0 && aSingleRatio.DirectionY>0 )
1139 : : {
1140 [ + - ][ + - ]: 19 : if( fx>0 && aSingleRatio.DirectionX>0 )
1141 : 19 : fy = fx*aSingleRatio.DirectionY/aSingleRatio.DirectionX;
1142 [ # # ][ # # ]: 0 : else if( fz>0 && aSingleRatio.DirectionZ>0 )
1143 : 0 : fy = fz*aSingleRatio.DirectionY/aSingleRatio.DirectionZ;
1144 : : else
1145 : 19 : fy = aSingleRatio.DirectionY;
1146 : : }
1147 : :
1148 [ + - ][ + + ]: 981 : if( fz<0 && aSingleRatio.DirectionZ>0 )
1149 : : {
1150 [ + - ][ + - ]: 33 : if( fx>0 && aSingleRatio.DirectionX>0 )
1151 : 33 : fz = fx*aSingleRatio.DirectionZ/aSingleRatio.DirectionX;
1152 [ # # ][ # # ]: 0 : else if( fy>0 && aSingleRatio.DirectionY>0 )
1153 : 0 : fz = fy*aSingleRatio.DirectionZ/aSingleRatio.DirectionY;
1154 : : else
1155 : 33 : fz = aSingleRatio.DirectionZ;
1156 : : }
1157 : :
1158 [ + + ][ + + ]: 981 : if( fx>0 && fy>0 && fz>0 )
[ - + ]
1159 : : break;
1160 : : }
1161 : 993 : aPreferredAspectRatio = drawing::Direction3D(fx, fy, fz);
1162 : 993 : return aPreferredAspectRatio;
1163 : : }
1164 : :
1165 : : //-----------------------------------------------------
1166 : :
1167 : : namespace
1168 : : {
1169 : :
1170 : 993 : bool lcl_IsPieOrDonut( const uno::Reference< XDiagram >& xDiagram )
1171 : : {
1172 : : //special treatment for pie charts
1173 : : //the size is checked after complete creation to get the datalabels into the given space
1174 : :
1175 : : //todo: this is just a workaround at the moment for pie and donut labels
1176 : 993 : return DiagramHelper::isPieOrDonutChart( xDiagram );
1177 : : }
1178 : :
1179 : 1071 : void lcl_setDefaultWritingMode( ::boost::shared_ptr< DrawModelWrapper > pDrawModelWrapper, const Reference< frame::XModel >& xChartModel )
1180 : : {
1181 : : //get writing mode from parent document:
1182 [ + - ][ + + ]: 1071 : if( SvtLanguageOptions().IsCTLFontEnabled() )
1183 : : {
1184 : : try
1185 : : {
1186 [ + - ]: 3 : uno::Reference< container::XChild > xChild( xChartModel, uno::UNO_QUERY );
1187 : 3 : sal_Int16 nWritingMode=-1;
1188 [ + - ]: 3 : if ( xChild.is() )
1189 : : {
1190 [ + - ][ + - ]: 3 : uno::Reference< beans::XPropertySet > xParentProps( xChild->getParent(), uno::UNO_QUERY );
[ + - ]
1191 [ + - ]: 3 : uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSupplier( xParentProps, uno::UNO_QUERY );
1192 [ + - ]: 3 : if( xStyleFamiliesSupplier.is() )
1193 : : {
1194 [ + - ][ + - ]: 3 : uno::Reference< container::XNameAccess > xStylesFamilies( xStyleFamiliesSupplier->getStyleFamilies() );
1195 [ + - ]: 3 : if( xStylesFamilies.is() )
1196 : : {
1197 [ + - ][ + - ]: 3 : if( !xStylesFamilies->hasByName( C2U("PageStyles") ) )
[ + - ][ - + ]
1198 : : {
1199 : : //draw/impress is parent document
1200 [ # # ]: 0 : uno::Reference< lang::XMultiServiceFactory > xFatcory( xParentProps, uno::UNO_QUERY );
1201 [ # # ]: 0 : if( xFatcory.is() )
1202 : : {
1203 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xDrawDefaults( xFatcory->createInstance( C2U( "com.sun.star.drawing.Defaults" ) ), uno::UNO_QUERY );
[ # # ][ # # ]
1204 [ # # ]: 0 : if( xDrawDefaults.is() )
1205 [ # # ][ # # ]: 0 : xDrawDefaults->getPropertyValue( C2U("WritingMode") ) >>= nWritingMode;
[ # # ]
1206 : 0 : }
1207 : : }
1208 : : else
1209 : : {
1210 [ + - ][ + - ]: 3 : uno::Reference< container::XNameAccess > xPageStyles( xStylesFamilies->getByName( C2U("PageStyles") ), uno::UNO_QUERY );
[ + - ][ + - ]
1211 [ + - ]: 3 : if( xPageStyles.is() )
1212 : : {
1213 : 3 : rtl::OUString aPageStyle;
1214 : :
1215 [ + - ]: 3 : uno::Reference< text::XTextDocument > xTextDocument( xParentProps, uno::UNO_QUERY );
1216 [ - + ]: 3 : if( xTextDocument.is() )
1217 : : {
1218 : : //writer is parent document
1219 : : //retrieve the current page style from the text cursor property PageStyleName
1220 : :
1221 [ # # ]: 0 : uno::Reference< text::XTextEmbeddedObjectsSupplier > xTextEmbeddedObjectsSupplier( xTextDocument, uno::UNO_QUERY );
1222 [ # # ]: 0 : if( xTextEmbeddedObjectsSupplier.is() )
1223 : : {
1224 [ # # ][ # # ]: 0 : uno::Reference< container::XNameAccess > xEmbeddedObjects( xTextEmbeddedObjectsSupplier->getEmbeddedObjects() );
1225 [ # # ]: 0 : if( xEmbeddedObjects.is() )
1226 : : {
1227 [ # # ][ # # ]: 0 : uno::Sequence< rtl::OUString > aNames( xEmbeddedObjects->getElementNames() );
1228 : :
1229 : 0 : sal_Int32 nCount = aNames.getLength();
1230 [ # # ]: 0 : for( sal_Int32 nN=0; nN<nCount; nN++ )
1231 : : {
1232 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xEmbeddedProps( xEmbeddedObjects->getByName( aNames[nN] ), uno::UNO_QUERY );
[ # # ][ # # ]
1233 [ # # ]: 0 : if( xEmbeddedProps.is() )
1234 : : {
1235 [ # # ][ # # ]: 0 : static rtl::OUString aChartCLSID = rtl::OUString( SvGlobalName( SO3_SCH_CLASSID ).GetHexName());
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1236 : 0 : rtl::OUString aCLSID;
1237 [ # # ][ # # ]: 0 : xEmbeddedProps->getPropertyValue( C2U("CLSID") ) >>= aCLSID;
[ # # ]
1238 [ # # ]: 0 : if( aCLSID.equals(aChartCLSID) )
1239 : : {
1240 : 0 : uno::Reference< frame::XModel > xModel;
1241 [ # # ][ # # ]: 0 : xEmbeddedProps->getPropertyValue( C2U("Model") ) >>= xModel;
[ # # ][ # # ]
1242 [ # # ][ # # ]: 0 : if( xModel == xChartModel )
1243 : : {
1244 [ # # ]: 0 : uno::Reference< text::XTextContent > xEmbeddedObject( xEmbeddedProps, uno::UNO_QUERY );
1245 [ # # ]: 0 : if( xEmbeddedObject.is() )
1246 : : {
1247 [ # # ][ # # ]: 0 : uno::Reference< text::XTextRange > xAnchor( xEmbeddedObject->getAnchor() );
1248 [ # # ]: 0 : if( xAnchor.is() )
1249 : : {
1250 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xAnchorProps( xAnchor, uno::UNO_QUERY );
1251 [ # # ]: 0 : if( xAnchorProps.is() )
1252 : : {
1253 [ # # ][ # # ]: 0 : xAnchorProps->getPropertyValue( C2U("WritingMode") ) >>= nWritingMode;
[ # # ]
1254 : : }
1255 [ # # ][ # # ]: 0 : uno::Reference< text::XText > xText( xAnchor->getText() );
1256 [ # # ]: 0 : if( xText.is() )
1257 : : {
1258 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY );
[ # # ]
1259 [ # # ]: 0 : if( xTextCursorProps.is() )
1260 [ # # ][ # # ]: 0 : xTextCursorProps->getPropertyValue( C2U("PageStyleName") ) >>= aPageStyle;
[ # # ]
1261 : 0 : }
1262 : 0 : }
1263 : : }
1264 : 0 : break;
1265 [ # # ]: 0 : }
1266 [ # # ]: 0 : }
1267 : : }
1268 [ # # ][ # # ]: 0 : }
1269 : 0 : }
1270 : : }
1271 [ # # ]: 0 : if( aPageStyle.isEmpty() )
1272 : : {
1273 [ # # ][ # # ]: 0 : uno::Reference< text::XText > xText( xTextDocument->getText() );
1274 [ # # ]: 0 : if( xText.is() )
1275 : : {
1276 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xTextCursorProps( xText->createTextCursor(), uno::UNO_QUERY );
[ # # ]
1277 [ # # ]: 0 : if( xTextCursorProps.is() )
1278 [ # # ][ # # ]: 0 : xTextCursorProps->getPropertyValue( C2U("PageStyleName") ) >>= aPageStyle;
[ # # ]
1279 : 0 : }
1280 : 0 : }
1281 : : }
1282 : : else
1283 : : {
1284 : : //Calc is parent document
1285 [ + - ][ + - ]: 3 : xParentProps->getPropertyValue( C2U("PageStyle") ) >>= aPageStyle;
[ + - ]
1286 [ + - ]: 3 : if(aPageStyle.isEmpty())
1287 [ + - ]: 3 : aPageStyle = C2U("Default");
1288 : : }
1289 [ - + ][ # # ]: 3 : if( nWritingMode == -1 || nWritingMode == text::WritingMode2::PAGE )
1290 : : {
1291 [ + - ][ + - ]: 3 : uno::Reference< beans::XPropertySet > xPageStyle( xPageStyles->getByName( aPageStyle ), uno::UNO_QUERY );
[ + - ]
1292 [ + - ]: 3 : if( xPageStyle.is() )
1293 [ + - ][ + - ]: 3 : xPageStyle->getPropertyValue( C2U("WritingMode") ) >>= nWritingMode;
[ + - ]
1294 : 3 : }
1295 : 3 : }
1296 : : }
1297 : 3 : }
1298 : 3 : }
1299 : : }
1300 [ + - ][ + - ]: 3 : if( nWritingMode != -1 && nWritingMode != text::WritingMode2::PAGE )
1301 : : {
1302 [ + - ]: 3 : if( pDrawModelWrapper.get() )
1303 [ + - ][ + - ]: 3 : pDrawModelWrapper->GetItemPool().SetPoolDefaultItem(SfxInt32Item(EE_PARA_WRITINGDIR, nWritingMode) );
[ + - ][ + - ]
1304 [ # # ]: 3 : }
1305 : : }
1306 : 0 : catch( const uno::Exception& ex )
1307 : : {
1308 : : ASSERT_EXCEPTION( ex );
1309 : : }
1310 : : }
1311 : 1071 : }
1312 : :
1313 : 1003 : sal_Int16 lcl_getDefaultWritingModeFromPool( ::boost::shared_ptr< DrawModelWrapper > pDrawModelWrapper )
1314 : : {
1315 : 1003 : sal_Int16 nWritingMode = text::WritingMode2::LR_TB;
1316 [ + - ]: 1003 : if( pDrawModelWrapper.get() )
1317 : : {
1318 : 1003 : const SfxPoolItem* pItem = &(pDrawModelWrapper->GetItemPool().GetDefaultItem( EE_PARA_WRITINGDIR ));
1319 [ + - ]: 1003 : if( pItem )
1320 : 1003 : nWritingMode = static_cast< sal_Int16 >((static_cast< const SfxInt32Item * >( pItem ))->GetValue());
1321 : : }
1322 : 1003 : return nWritingMode;
1323 : : }
1324 : :
1325 : : } //end anonymous namespace
1326 : :
1327 : : //------------ create complete diagram shape (inclusive axis and series)
1328 : :
1329 : 1003 : awt::Rectangle ChartView::impl_createDiagramAndContent( SeriesPlotterContainer& rSeriesPlotterContainer
1330 : : , const uno::Reference< drawing::XShapes>& xDiagramPlusAxes_Shapes
1331 : : , const awt::Point& rAvailablePos
1332 : : , const awt::Size& rAvailableSize
1333 : : , const awt::Size& rPageSize
1334 : : , bool bUseFixedInnerSize
1335 : : , const uno::Reference< drawing::XShape>& xDiagram_MarkHandles /*needs to be resized to fit the result*/
1336 : : )
1337 : : {
1338 : : //return the used rectangle
1339 : 1003 : awt::Rectangle aUsedOuterRect( rAvailablePos.X, rAvailablePos.Y, 0, 0 );
1340 : :
1341 : : // sal_Int32 nDiagramIndex = 0;//todo if more than one diagam is supported
1342 [ + - ]: 1003 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
1343 [ + + ]: 1003 : if( !xDiagram.is())
1344 : : return aUsedOuterRect;
1345 : :
1346 [ + - ]: 993 : sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
1347 [ - + ]: 993 : if(!nDimensionCount)
1348 : : {
1349 : : //@todo handle mixed dimension
1350 : 0 : nDimensionCount = 2;
1351 : : }
1352 : :
1353 [ + - ]: 993 : ::basegfx::B2IRectangle aAvailableOuterRect( BaseGFXHelper::makeRectangle(rAvailablePos,rAvailableSize) );
1354 : :
1355 : 993 : const std::vector< VCoordinateSystem* >& rVCooSysList( rSeriesPlotterContainer.getCooSysList() );
1356 : 993 : const std::vector< VSeriesPlotter* >& rSeriesPlotterList( rSeriesPlotterContainer.getSeriesPlotterList() );
1357 : :
1358 : : //create VAxis, so they can give necessary information for automatic scaling
1359 [ + - ]: 993 : uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_xChartModel, uno::UNO_QUERY );
1360 : 993 : size_t nC = 0;
1361 [ + + ]: 1975 : for( nC=0; nC < rVCooSysList.size(); nC++)
1362 : : {
1363 : 982 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
1364 [ + + ]: 982 : if(3==nDimensionCount)
1365 : : {
1366 [ + - ]: 14 : uno::Reference<beans::XPropertySet> xSceneProperties( xDiagram, uno::UNO_QUERY );
1367 [ + - ]: 14 : CuboidPlanePosition eLeftWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardLeftWall( xSceneProperties ) );
1368 [ + - ]: 14 : CuboidPlanePosition eBackWallPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBackWall( xSceneProperties ) );
1369 [ + - ]: 14 : CuboidPlanePosition eBottomPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( xSceneProperties ) );
1370 [ + - ]: 14 : pVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos, eBottomPos );
1371 : : }
1372 : : pVCooSys->createVAxisList( xNumberFormatsSupplier
1373 : : , rPageSize //font reference size
1374 : : , BaseGFXHelper::B2IRectangleToAWTRectangle( aAvailableOuterRect ) //maximum space for labels
1375 [ + - ][ + - ]: 982 : );
1376 : : }
1377 : :
1378 : :
1379 : : // - prepare list of all axis and how they are used
1380 [ + - ][ + - ]: 993 : Date aNullDate = NumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >( m_xChartModel, uno::UNO_QUERY ) ).getNullDate();
[ + - ][ + - ]
1381 [ + - ]: 993 : rSeriesPlotterContainer.initAxisUsageList(aNullDate);
1382 [ + - ]: 993 : rSeriesPlotterContainer.doAutoScaling( m_xChartModel );
1383 [ + - ]: 993 : rSeriesPlotterContainer.setScalesFromCooSysToPlotter();
1384 [ + - ]: 993 : rSeriesPlotterContainer.setNumberFormatsFromAxes();
1385 : :
1386 : : //---------------------------------------------------------------------
1387 : : //create shapes
1388 : :
1389 : : //------------ create diagram shapes
1390 : : //aspect ratio
1391 : : drawing::Direction3D aPreferredAspectRatio(
1392 [ + - ]: 993 : rSeriesPlotterContainer.getPreferredAspectRatio() );
1393 : :
1394 [ + - ]: 993 : uno::Reference< drawing::XShapes > xSeriesTargetInFrontOfAxis(0);
1395 [ + - ]: 993 : uno::Reference< drawing::XShapes > xSeriesTargetBehindAxis(0);
1396 [ + - ]: 993 : VDiagram aVDiagram(xDiagram, aPreferredAspectRatio, nDimensionCount);
1397 : : {//create diagram
1398 [ + - ]: 993 : aVDiagram.init(xDiagramPlusAxes_Shapes,xDiagramPlusAxes_Shapes,m_xShapeFactory);
1399 [ + - ]: 993 : aVDiagram.createShapes(rAvailablePos,rAvailableSize);
1400 [ + - ][ + - ]: 993 : xSeriesTargetInFrontOfAxis = aVDiagram.getCoordinateRegion();
1401 [ + + ]: 993 : if( !bUseFixedInnerSize )
1402 [ + - ]: 617 : aVDiagram.reduceToMimimumSize();
1403 : : }
1404 : :
1405 [ + - ][ + - ]: 993 : uno::Reference< drawing::XShapes > xTextTargetShapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxes_Shapes) );
[ + - ]
1406 : :
1407 : : // - create axis and grids for all coordinate systems
1408 : :
1409 : : //init all coordinate systems
1410 [ + + ]: 1975 : for( nC=0; nC < rVCooSysList.size(); nC++)
1411 : : {
1412 : 982 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
1413 [ + - ]: 982 : pVCooSys->initPlottingTargets(xSeriesTargetInFrontOfAxis,xTextTargetShapes,m_xShapeFactory,xSeriesTargetBehindAxis);
1414 : :
1415 : : pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
1416 [ + - ][ + - ]: 982 : createTransformationSceneToScreen( aVDiagram.getCurrentRectangle() ) ));
[ + - ][ + - ]
[ + - ]
1417 : :
1418 [ + - ]: 982 : pVCooSys->initVAxisInList();
1419 : : }
1420 : :
1421 : : //calculate resulting size respecting axis label layout and fontscaling
1422 : :
1423 [ + - ]: 993 : uno::Reference< drawing::XShape > xBoundingShape( xDiagramPlusAxes_Shapes, uno::UNO_QUERY );
1424 [ + - ]: 993 : ::basegfx::B2IRectangle aConsumedOuterRect;
1425 : :
1426 : : //use first coosys only so far; todo: calculate for more than one coosys if we have more in future
1427 : : //todo: this is just a workaround at the moment for pie and donut labels
1428 [ + - ]: 993 : bool bIsPieOrDonut = lcl_IsPieOrDonut(xDiagram);
1429 [ + + ][ + + ]: 993 : if( !bIsPieOrDonut && (!rVCooSysList.empty()) )
[ + + ]
1430 : : {
1431 : 962 : VCoordinateSystem* pVCooSys = rVCooSysList[0];
1432 [ + - ]: 962 : pVCooSys->createMaximumAxesLabels();
1433 : :
1434 [ + - ]: 962 : aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) );
1435 [ + - ]: 962 : ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() );
1436 [ + + ]: 962 : if( !bUseFixedInnerSize )
1437 [ + - ]: 592 : aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect );
1438 : :
1439 : : pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
1440 [ + - ][ + - ]: 962 : createTransformationSceneToScreen( aNewInnerRect ) ));
[ + - ][ + - ]
1441 : :
1442 : : //redo autoscaling to get size and text dependent automatic main increment count
1443 [ + - ]: 962 : rSeriesPlotterContainer.doAutoScaling( m_xChartModel );
1444 [ + - ]: 962 : rSeriesPlotterContainer.updateScalesAndIncrementsOnAxes();
1445 [ + - ]: 962 : rSeriesPlotterContainer.setScalesFromCooSysToPlotter();
1446 : :
1447 [ + - ]: 962 : pVCooSys->createAxesLabels();
1448 : :
1449 : 962 : bool bLessSpaceConsumedThanExpected = false;
1450 : : {
1451 [ + - ]: 962 : aConsumedOuterRect = ShapeFactory::getRectangleOfShape(xBoundingShape);
1452 [ + - ][ + - ]: 3656 : if( aConsumedOuterRect.getMinX() > aAvailableOuterRect.getMinX()
[ + + ][ + + ]
[ + + ][ + - ]
[ + - ]
1453 [ + - ][ + - ]: 928 : || aConsumedOuterRect.getMaxX() < aAvailableOuterRect.getMaxX()
1454 [ + - ][ + - ]: 921 : || aConsumedOuterRect.getMinY() > aAvailableOuterRect.getMinY()
1455 [ + - ][ + - ]: 845 : || aConsumedOuterRect.getMinY() < aAvailableOuterRect.getMaxY() )
1456 : 962 : bLessSpaceConsumedThanExpected = true;
1457 : : }
1458 : :
1459 [ + - ][ + + ]: 962 : if( bLessSpaceConsumedThanExpected && !bUseFixedInnerSize )
1460 : : {
1461 [ + - ]: 592 : aVDiagram.adjustInnerSize( aConsumedOuterRect );
1462 : : pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
1463 [ + - ][ + - ]: 592 : createTransformationSceneToScreen( aVDiagram.getCurrentRectangle() ) ));
[ + - ][ + - ]
[ + - ]
1464 : : }
1465 [ + - ]: 962 : pVCooSys->updatePositions();//todo: logically this belongs to the condition above, but it seems also to be neccessary to give the axes group shapes the right bounding rects for hit test - probably caused by bug i106183 -> check again if fixed
1466 : : }
1467 : :
1468 : : //create axes and grids for the final size
1469 [ + + ]: 1975 : for( nC=0; nC < rVCooSysList.size(); nC++)
1470 : : {
1471 : 982 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
1472 : :
1473 : : pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
1474 [ + - ][ + - ]: 982 : createTransformationSceneToScreen( aVDiagram.getCurrentRectangle() ) ));
[ + - ][ + - ]
[ + - ]
1475 : :
1476 [ + - ]: 982 : pVCooSys->createAxesShapes();
1477 [ + - ]: 982 : pVCooSys->createGridShapes();
1478 : : }
1479 : :
1480 : : // - create data series for all charttypes
1481 : 993 : m_bPointsWereSkipped = false;
1482 : 993 : ::std::vector< VSeriesPlotter* >::const_iterator aPlotterIter = rSeriesPlotterList.begin();
1483 : 993 : const ::std::vector< VSeriesPlotter* >::const_iterator aPlotterEnd = rSeriesPlotterList.end();
1484 [ + - ][ + + ]: 1974 : for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
1485 : : {
1486 : : //------------ set transformation to plotter / create series
1487 : 981 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
1488 : 981 : rtl::OUString aCID; //III
1489 [ + - ]: 981 : uno::Reference< drawing::XShapes > xSeriesTarget(0);
1490 [ + - ][ + - ]: 981 : if( pSeriesPlotter->WantToPlotInFrontOfAxisLine() )
1491 [ + - ]: 981 : xSeriesTarget = xSeriesTargetInFrontOfAxis;
1492 : : else
1493 : : {
1494 [ # # ]: 0 : xSeriesTarget = xSeriesTargetBehindAxis;
1495 : : OSL_ENSURE( !bIsPieOrDonut, "not implemented yet! - during a complete recreation this shape is destroyed so no series can be created anymore" );
1496 : : }
1497 [ + - ]: 981 : pSeriesPlotter->initPlotter( xSeriesTarget,xTextTargetShapes,m_xShapeFactory,aCID );
1498 [ + - ]: 981 : pSeriesPlotter->setPageReferenceSize( rPageSize );
1499 [ + - ][ + - ]: 981 : VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( rVCooSysList, pSeriesPlotter );
1500 [ + + ]: 981 : if(2==nDimensionCount)
1501 [ + - ][ + - ]: 965 : pSeriesPlotter->setTransformationSceneToScreen( pVCooSys->getTransformationSceneToScreen() );
1502 : : //better performance for big data
1503 : 981 : awt::Size aCoordinateRegionResolution(1000,1000);
1504 : : {
1505 : : //calculate resolution for coordinate system
1506 [ + - ]: 981 : Sequence<sal_Int32> aCoordinateSystemResolution = pVCooSys->getCoordinateSystemResolution( rPageSize, m_aPageResolution );
1507 [ + - ][ + - ]: 981 : pSeriesPlotter->setCoordinateSystemResolution( aCoordinateSystemResolution );
1508 : : }
1509 : : //
1510 [ + - ]: 981 : pSeriesPlotter->createShapes();
1511 [ + - ][ + - ]: 981 : m_bPointsWereSkipped = m_bPointsWereSkipped || pSeriesPlotter->PointsWereSkipped();
[ - + ]
1512 : 981 : }
1513 : :
1514 : : //recreate all with corrected sizes if requested
1515 [ + + ]: 993 : if( bIsPieOrDonut )
1516 : : {
1517 : 20 : m_bPointsWereSkipped = false;
1518 : :
1519 [ + - ]: 20 : aConsumedOuterRect = ::basegfx::B2IRectangle( ShapeFactory::getRectangleOfShape(xBoundingShape) );
1520 [ + - ]: 20 : ::basegfx::B2IRectangle aNewInnerRect( aVDiagram.getCurrentRectangle() );
1521 [ + - ]: 20 : if( !bUseFixedInnerSize )
1522 [ + - ]: 20 : aNewInnerRect = aVDiagram.adjustInnerSize( aConsumedOuterRect );
1523 : :
1524 [ + - ][ + + ]: 39 : for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
1525 : : {
1526 : 19 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
1527 [ + - ]: 19 : pSeriesPlotter->releaseShapes();
1528 : : }
1529 : :
1530 : : //clear and recreate
1531 [ + - ]: 20 : ShapeFactory::removeSubShapes( xSeriesTargetInFrontOfAxis ); //xSeriesTargetBehindAxis is a sub shape of xSeriesTargetInFrontOfAxis and will be removed here
1532 : 20 : xSeriesTargetBehindAxis.clear();
1533 [ + - ]: 20 : ShapeFactory::removeSubShapes( xTextTargetShapes );
1534 : :
1535 : : //set new transformation
1536 [ + + ]: 40 : for( nC=0; nC < rVCooSysList.size(); nC++)
1537 : : {
1538 : 20 : VCoordinateSystem* pVCooSys = rVCooSysList[nC];
1539 : : pVCooSys->setTransformationSceneToScreen( B3DHomMatrixToHomogenMatrix(
1540 [ + - ][ + - ]: 20 : createTransformationSceneToScreen( aNewInnerRect ) ));
[ + - ][ + - ]
1541 : : }
1542 : :
1543 : : // - create data series for all charttypes
1544 [ + - ][ + + ]: 39 : for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
1545 : : {
1546 : : //------------ set transformation to plotter / create series
1547 : 19 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
1548 [ + - ][ + - ]: 19 : VCoordinateSystem* pVCooSys = lcl_getCooSysForPlotter( rVCooSysList, pSeriesPlotter );
1549 [ + - ]: 19 : if(2==nDimensionCount)
1550 [ + - ][ + - ]: 19 : pSeriesPlotter->setTransformationSceneToScreen( pVCooSys->getTransformationSceneToScreen() );
1551 [ + - ]: 19 : pSeriesPlotter->createShapes();
1552 [ + - ][ + - ]: 19 : m_bPointsWereSkipped = m_bPointsWereSkipped || pSeriesPlotter->PointsWereSkipped();
[ - + ]
1553 : : }
1554 : :
1555 [ + - ][ + + ]: 39 : for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
1556 : : {
1557 : 19 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
1558 [ + - ]: 19 : pSeriesPlotter->rearrangeLabelToAvoidOverlapIfRequested( rPageSize );
1559 : : }
1560 : : }
1561 : :
1562 [ + + ]: 993 : if( bUseFixedInnerSize )
1563 : : {
1564 [ + - ][ + - ]: 376 : aUsedOuterRect = awt::Rectangle( aConsumedOuterRect.getMinX(), aConsumedOuterRect.getMinY(), aConsumedOuterRect.getWidth(), aConsumedOuterRect.getHeight() );
[ + - ][ + - ]
1565 : : }
1566 : : else
1567 : 617 : aUsedOuterRect = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height );
1568 : :
1569 : 993 : bool bSnapRectToUsedArea = false;
1570 [ + - ][ + + ]: 1007 : for( aPlotterIter = rSeriesPlotterList.begin(); aPlotterIter != aPlotterEnd; ++aPlotterIter )
1571 : : {
1572 : 981 : VSeriesPlotter* pSeriesPlotter = *aPlotterIter;
1573 [ + - ]: 981 : bSnapRectToUsedArea = pSeriesPlotter->shouldSnapRectToUsedArea();
1574 [ + + ]: 981 : if(bSnapRectToUsedArea)
1575 : 967 : break;
1576 : : }
1577 [ + + ]: 993 : if(bSnapRectToUsedArea)
1578 : : {
1579 [ + + ]: 967 : if( bUseFixedInnerSize )
1580 [ + - ][ + - ]: 367 : m_aResultingDiagramRectangleExcludingAxes = getRectangleOfObject( C2U("PlotAreaExcludingAxes") );
1581 : : else
1582 : : {
1583 [ + - ]: 600 : ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle();
1584 [ + - ][ + - ]: 600 : m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
[ + - ][ + - ]
1585 : : }
1586 : : }
1587 : : else
1588 : : {
1589 [ + + ]: 26 : if( bUseFixedInnerSize )
1590 : 9 : m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( rAvailablePos.X, rAvailablePos.Y, rAvailableSize.Width, rAvailableSize.Height );
1591 : : else
1592 : : {
1593 [ + - ]: 17 : ::basegfx::B2IRectangle aConsumedInnerRect = aVDiagram.getCurrentRectangle();
1594 [ + - ][ + - ]: 17 : m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle( aConsumedInnerRect.getMinX(), aConsumedInnerRect.getMinY(), aConsumedInnerRect.getWidth(), aConsumedInnerRect.getHeight() );
[ + - ][ + - ]
1595 : : }
1596 : : }
1597 : :
1598 [ + - ]: 993 : if( xDiagram_MarkHandles.is() )
1599 : : {
1600 : 993 : awt::Point aPos(rAvailablePos);
1601 : 993 : awt::Size aSize(rAvailableSize);
1602 : 993 : bool bPosSizeExcludeAxesProperty = true;
1603 [ + - ]: 993 : uno::Reference< beans::XPropertySet > xDiaProps( xDiagram, uno::UNO_QUERY_THROW );
1604 [ + - ]: 993 : if( xDiaProps.is() )
1605 [ + - ][ + - ]: 993 : xDiaProps->getPropertyValue(C2U("PosSizeExcludeAxes")) >>= bPosSizeExcludeAxesProperty;
[ + - ]
1606 [ + + ][ + + ]: 993 : if( bUseFixedInnerSize || bPosSizeExcludeAxesProperty )
1607 : : {
1608 : 978 : aPos = awt::Point( m_aResultingDiagramRectangleExcludingAxes.X, m_aResultingDiagramRectangleExcludingAxes.Y );
1609 : 978 : aSize = awt::Size( m_aResultingDiagramRectangleExcludingAxes.Width, m_aResultingDiagramRectangleExcludingAxes.Height );
1610 : : }
1611 [ + - ][ + - ]: 993 : xDiagram_MarkHandles->setPosition( aPos );
1612 [ + - ][ + - ]: 993 : xDiagram_MarkHandles->setSize( aSize );
1613 : : }
1614 : :
1615 [ + - ]: 1003 : return aUsedOuterRect;
1616 : : }
1617 : :
1618 : : //-------------------------------------------------------------
1619 : : //-------------------------------------------------------------
1620 : : //-------------------------------------------------------------
1621 : :
1622 : 382 : sal_Bool ChartView::getExplicitValuesForAxis(
1623 : : uno::Reference< XAxis > xAxis
1624 : : , ExplicitScaleData& rExplicitScale
1625 : : , ExplicitIncrementData& rExplicitIncrement )
1626 : : {
1627 [ + - ]: 382 : impl_updateView();
1628 : :
1629 [ - + ]: 382 : if(!xAxis.is())
1630 : 0 : return sal_False;
1631 : :
1632 [ + - ][ + - ]: 382 : uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis(xAxis,ChartModelHelper::findDiagram( m_xChartModel ) ) );
1633 [ + - ]: 382 : const VCoordinateSystem* pVCooSys = findInCooSysList(m_aVCooSysList,xCooSys);
1634 [ - + ]: 382 : if(!pVCooSys)
1635 : 0 : return sal_False;
1636 : :
1637 : 382 : sal_Int32 nDimensionIndex=-1;
1638 : 382 : sal_Int32 nAxisIndex=-1;
1639 [ + - ][ + - ]: 382 : if( AxisHelper::getIndicesForAxis( xAxis, xCooSys, nDimensionIndex, nAxisIndex ) )
1640 : : {
1641 [ + - ][ + - ]: 382 : rExplicitScale = pVCooSys->getExplicitScale(nDimensionIndex,nAxisIndex);
[ + - ]
1642 [ + - ]: 382 : rExplicitIncrement = pVCooSys->getExplicitIncrement(nDimensionIndex,nAxisIndex);
1643 [ + + ]: 382 : if( rExplicitScale.ShiftedCategoryPosition )
1644 : : {
1645 : : //remove 'one' from max
1646 [ - + ]: 180 : if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::DATE )
1647 : : {
1648 [ # # ]: 0 : Date aMaxDate(rExplicitScale.NullDate); aMaxDate += static_cast<long>(::rtl::math::approxFloor(rExplicitScale.Maximum));
1649 : : //for explicit scales with shifted categories we need one interval more
1650 [ # # # # ]: 0 : switch( rExplicitScale.TimeResolution )
1651 : : {
1652 : : case ::com::sun::star::chart::TimeUnit::DAY:
1653 [ # # ]: 0 : aMaxDate--;break;
1654 : : case ::com::sun::star::chart::TimeUnit::MONTH:
1655 [ # # ]: 0 : aMaxDate = DateHelper::GetDateSomeMonthsAway(aMaxDate,-1);
1656 : 0 : break;
1657 : : case ::com::sun::star::chart::TimeUnit::YEAR:
1658 [ # # ]: 0 : aMaxDate = DateHelper::GetDateSomeYearsAway(aMaxDate,-1);
1659 : 0 : break;
1660 : : }
1661 [ # # ]: 0 : rExplicitScale.Maximum = aMaxDate - rExplicitScale.NullDate;
1662 : : }
1663 [ + - ]: 180 : else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::CATEGORY )
1664 : 180 : rExplicitScale.Maximum -= 1.0;
1665 [ # # ]: 0 : else if( rExplicitScale.AxisType == ::com::sun::star::chart2::AxisType::SERIES )
1666 : 0 : rExplicitScale.Maximum -= 1.0;
1667 : : }
1668 : 382 : return sal_True;
1669 : : }
1670 : 382 : return sal_False;
1671 : : }
1672 : :
1673 : 1474 : SdrPage* ChartView::getSdrPage()
1674 : : {
1675 : 1474 : SdrPage* pPage=0;
1676 [ + - ]: 1474 : Reference< lang::XUnoTunnel> xUnoTunnel(m_xDrawPage,uno::UNO_QUERY);
1677 [ + - ]: 1474 : if(xUnoTunnel.is())
1678 : : {
1679 [ + - ]: 1474 : SvxDrawPage* pSvxDrawPage = reinterpret_cast<SvxDrawPage*>(xUnoTunnel->getSomething(
1680 [ + - ]: 1474 : SvxDrawPage::getUnoTunnelId() ));
1681 [ + - ]: 1474 : if(pSvxDrawPage)
1682 : : {
1683 : 1474 : pPage = pSvxDrawPage->GetSdrPage();
1684 : : }
1685 : : }
1686 : 1474 : return pPage;
1687 : : }
1688 : :
1689 : 403 : uno::Reference< drawing::XShape > ChartView::getShapeForCID( const rtl::OUString& rObjectCID )
1690 : : {
1691 [ + - ]: 403 : SolarMutexGuard aSolarGuard;
1692 [ + - ][ + - ]: 403 : SdrObject* pObj = DrawModelWrapper::getNamedSdrObject( rObjectCID, this->getSdrPage() );
[ + - ][ + - ]
1693 [ + - ]: 403 : if( pObj )
1694 [ + - ][ + - ]: 403 : return uno::Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY);
1695 [ # # ][ + - ]: 403 : return 0;
1696 : : }
1697 : :
1698 : 17 : awt::Rectangle ChartView::getDiagramRectangleExcludingAxes()
1699 : : {
1700 : 17 : impl_updateView();
1701 : 17 : return m_aResultingDiagramRectangleExcludingAxes;
1702 : : }
1703 : :
1704 : 403 : awt::Rectangle ChartView::getRectangleOfObject( const rtl::OUString& rObjectCID, bool bSnapRect )
1705 : : {
1706 [ + - ]: 403 : impl_updateView();
1707 : :
1708 : 403 : awt::Rectangle aRet;
1709 [ + - ]: 403 : uno::Reference< drawing::XShape > xShape( getShapeForCID(rObjectCID) );
1710 [ + - ]: 403 : if(xShape.is())
1711 : : {
1712 : : //special handling for axis for old api:
1713 : : //same special handling for diagram
1714 [ + - ]: 403 : ObjectType eObjectType( ObjectIdentifier::getObjectType( rObjectCID ) );
1715 [ + - ][ - + ]: 403 : if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_DIAGRAM )
1716 : : {
1717 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
1718 [ # # ]: 0 : SvxShape* pRoot = SvxShape::getImplementation( xShape );
1719 [ # # ]: 0 : if( pRoot )
1720 : : {
1721 [ # # ]: 0 : SdrObject* pRootSdrObject = pRoot->GetSdrObject();
1722 [ # # ]: 0 : if( pRootSdrObject )
1723 : : {
1724 [ # # ]: 0 : SdrObjList* pRootList = pRootSdrObject->GetSubList();
1725 [ # # ]: 0 : if( pRootList )
1726 : : {
1727 [ # # ]: 0 : OUString aShapeName = C2U("MarkHandles");
1728 [ # # ]: 0 : if( eObjectType == OBJECTTYPE_DIAGRAM )
1729 [ # # ]: 0 : aShapeName = C2U("PlotAreaIncludingAxes");
1730 [ # # ][ # # ]: 0 : SdrObject* pShape = DrawModelWrapper::getNamedSdrObject( aShapeName, pRootList );
[ # # ]
1731 [ # # ]: 0 : if( pShape )
1732 [ # # ][ # # ]: 0 : xShape = uno::Reference< drawing::XShape >( pShape->getUnoShape(), uno::UNO_QUERY);
[ # # ]
1733 : : }
1734 : : }
1735 [ # # ]: 0 : }
1736 : : }
1737 : :
1738 [ + - ][ + - ]: 403 : awt::Size aSize( xShape->getSize() );
1739 [ + - ][ + - ]: 403 : awt::Point aPoint( xShape->getPosition() );
1740 : 403 : aRet = awt::Rectangle( aPoint.X, aPoint.Y, aSize.Width, aSize.Height );
1741 [ - + ]: 403 : if( bSnapRect )
1742 : : {
1743 : : //for rotated objects the shape size and position differs from the visible rectangle
1744 [ # # ]: 0 : SvxShape* pShape = SvxShape::getImplementation( xShape );
1745 [ # # ]: 0 : if( pShape )
1746 : : {
1747 [ # # ]: 0 : SdrObject* pSdrObject = pShape->GetSdrObject();
1748 [ # # ]: 0 : if( pSdrObject )
1749 : : {
1750 [ # # ]: 0 : Rectangle aSnapRect( pSdrObject->GetSnapRect() );
1751 [ # # ][ # # ]: 403 : aRet = awt::Rectangle(aSnapRect.Left(),aSnapRect.Top(),aSnapRect.GetWidth(),aSnapRect.GetHeight());
1752 : : }
1753 : : }
1754 : : }
1755 : : }
1756 : 403 : return aRet;
1757 : : }
1758 : :
1759 : 97 : ::boost::shared_ptr< DrawModelWrapper > ChartView::getDrawModelWrapper()
1760 : : {
1761 : 97 : return m_pDrawModelWrapper;
1762 : : }
1763 : :
1764 : : namespace
1765 : : {
1766 : 0 : sal_Int32 lcl_getDiagramTitleSpace()
1767 : : {
1768 : 0 : return 200; //=0,2 cm spacing
1769 : : }
1770 : 0 : bool lcl_getPropertySwapXAndYAxis( const uno::Reference< XDiagram >& xDiagram )
1771 : : {
1772 : 0 : bool bSwapXAndY = false;
1773 : :
1774 [ # # ]: 0 : uno::Reference< XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY );
1775 [ # # ]: 0 : if( xCooSysContainer.is() )
1776 : : {
1777 [ # # ][ # # ]: 0 : uno::Sequence< uno::Reference< XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() );
1778 [ # # ]: 0 : if( aCooSysList.getLength() )
1779 : : {
1780 [ # # ][ # # ]: 0 : uno::Reference<beans::XPropertySet> xProp(aCooSysList[0], uno::UNO_QUERY );
1781 [ # # ]: 0 : if( xProp.is()) try
1782 : : {
1783 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U( "SwapXAndYAxis" ) ) >>= bSwapXAndY;
[ # # ][ # # ]
1784 : : }
1785 [ # # ]: 0 : catch( const uno::Exception& e )
1786 : : {
1787 : : ASSERT_EXCEPTION( e );
1788 : 0 : }
1789 [ # # ]: 0 : }
1790 : : }
1791 : 0 : return bSwapXAndY;
1792 : : }
1793 : :
1794 : : }
1795 : :
1796 : 1855 : sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForAxis(
1797 : : const Reference< chart2::XAxis >& xAxis
1798 : : , const Reference< chart2::XCoordinateSystem > & xCorrespondingCoordinateSystem
1799 : : , const Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
1800 : : {
1801 : : return AxisHelper::getExplicitNumberFormatKeyForAxis( xAxis, xCorrespondingCoordinateSystem, xNumberFormatsSupplier
1802 : 1855 : , true /*bSearchForParallelAxisIfNothingIsFound*/ );
1803 : : }
1804 : :
1805 : 148 : sal_Int32 ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel(
1806 : : const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp,
1807 : : const uno::Reference< XDataSeries >& xSeries,
1808 : : sal_Int32 nPointIndex /*-1 for whole series*/,
1809 : : const uno::Reference< XDiagram >& xDiagram
1810 : : )
1811 : : {
1812 : 148 : sal_Int32 nFormat=0;
1813 [ - + ]: 148 : if( !xSeriesOrPointProp.is() )
1814 : 0 : return nFormat;
1815 : :
1816 [ + - ]: 148 : rtl::OUString aPropName( C2U( "NumberFormat" ) );
1817 [ + - ][ + - ]: 148 : if( !(xSeriesOrPointProp->getPropertyValue(aPropName) >>= nFormat) )
[ + - ]
1818 : : {
1819 [ + - ]: 148 : uno::Reference< chart2::XChartType > xChartType( DataSeriesHelper::getChartTypeOfSeries( xSeries, xDiagram ) );
1820 : :
1821 : 148 : bool bFormatFound = false;
1822 [ + - ][ + - ]: 148 : if( ChartTypeHelper::shouldLabelNumberFormatKeyBeDetectedFromYAxis( xChartType ) )
1823 : : {
1824 [ + - ][ + - ]: 148 : uno::Reference< beans::XPropertySet > xAttachedAxisProps( DiagramHelper::getAttachedAxis( xSeries, xDiagram ), uno::UNO_QUERY );
1825 [ + - ][ + - ]: 148 : if( xAttachedAxisProps.is() && ( xAttachedAxisProps->getPropertyValue( aPropName ) >>= nFormat ) )
[ - + ][ + - ]
[ - + # # ]
[ + - ]
1826 : 148 : bFormatFound = true;
1827 : : }
1828 [ + - ]: 148 : if( !bFormatFound )
1829 : : {
1830 [ + - ]: 148 : Reference< chart2::data::XDataSource > xSeriesSource( xSeries, uno::UNO_QUERY );
1831 [ + - ]: 148 : OUString aRole( ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( xChartType ) );
1832 : :
1833 : : Reference< data::XLabeledDataSequence > xLabeledSequence(
1834 [ + - ]: 148 : DataSeriesHelper::getDataSequenceByRole( xSeriesSource, aRole, false ));
1835 [ + - ]: 148 : if( xLabeledSequence.is() )
1836 : : {
1837 [ + - ][ + - ]: 148 : Reference< data::XDataSequence > xValues( xLabeledSequence->getValues() );
1838 [ + - ]: 148 : if( xValues.is() )
1839 [ + - ][ + - ]: 148 : nFormat = xValues->getNumberFormatKeyByIndex( nPointIndex );
1840 : 148 : }
1841 : 148 : }
1842 : : }
1843 [ - + ]: 148 : if(nFormat<0)
1844 : 0 : nFormat=0;
1845 : 148 : return nFormat;
1846 : : }
1847 : :
1848 : 0 : sal_Int32 ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
1849 : : const uno::Reference< beans::XPropertySet >& xSeriesOrPointProp,
1850 : : const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier )
1851 : : {
1852 : 0 : sal_Int32 nFormat=0;
1853 [ # # ]: 0 : if( !xSeriesOrPointProp.is() )
1854 : 0 : return nFormat;
1855 [ # # ][ # # ]: 0 : if( !(xSeriesOrPointProp->getPropertyValue(C2U( "PercentageNumberFormat" )) >>= nFormat) )
[ # # ][ # # ]
1856 : : {
1857 [ # # ]: 0 : nFormat = DiagramHelper::getPercentNumberFormat( xNumberFormatsSupplier );
1858 : : }
1859 [ # # ]: 0 : if(nFormat<0)
1860 : 0 : nFormat=0;
1861 : 0 : return nFormat;
1862 : : }
1863 : :
1864 : 0 : awt::Rectangle ExplicitValueProvider::addAxisTitleSizes(
1865 : : const Reference< frame::XModel >& xChartModel
1866 : : , const Reference< uno::XInterface >& xChartView
1867 : : , const awt::Rectangle& rExcludingPositionAndSize )
1868 : : {
1869 : 0 : awt::Rectangle aRet(rExcludingPositionAndSize);
1870 : :
1871 : : //add axis title sizes to the diagram size
1872 [ # # ]: 0 : uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) );
1873 [ # # ]: 0 : uno::Reference< chart2::XTitle > xTitle_Width( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xChartModel ) );
1874 [ # # ]: 0 : uno::Reference< chart2::XTitle > xSecondTitle_Height( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xChartModel ) );
1875 [ # # ]: 0 : uno::Reference< chart2::XTitle > xSecondTitle_Width( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xChartModel ) );
1876 [ # # ][ # # ]: 0 : if( xTitle_Height.is() || xTitle_Width.is() || xSecondTitle_Height.is() || xSecondTitle_Width.is() )
[ # # ][ # # ]
[ # # ]
1877 : : {
1878 [ # # ]: 0 : ExplicitValueProvider* pExplicitValueProvider = ExplicitValueProvider::getExplicitValueProvider(xChartView);
1879 [ # # ]: 0 : if( pExplicitValueProvider )
1880 : : {
1881 : : //detect whether x axis points into x direction or not
1882 [ # # ][ # # ]: 0 : if( lcl_getPropertySwapXAndYAxis( ChartModelHelper::findDiagram( xChartModel ) ) )
[ # # ]
1883 : : {
1884 [ # # ]: 0 : std::swap( xTitle_Height, xTitle_Width );
1885 [ # # ]: 0 : std::swap( xSecondTitle_Height, xSecondTitle_Width );
1886 : : }
1887 : :
1888 : 0 : sal_Int32 nTitleSpaceWidth = 0;
1889 : 0 : sal_Int32 nTitleSpaceHeight = 0;
1890 : 0 : sal_Int32 nSecondTitleSpaceWidth = 0;
1891 : 0 : sal_Int32 nSecondTitleSpaceHeight = 0;
1892 : :
1893 [ # # ]: 0 : if( xTitle_Height.is() )
1894 : : {
1895 [ # # ]: 0 : rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Height, xChartModel ) );
1896 [ # # ]: 0 : nTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
1897 [ # # ]: 0 : if( nTitleSpaceHeight )
1898 : 0 : nTitleSpaceHeight+=lcl_getDiagramTitleSpace();
1899 : : }
1900 [ # # ]: 0 : if( xTitle_Width.is() )
1901 : : {
1902 [ # # ]: 0 : rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Width, xChartModel ) );
1903 [ # # ]: 0 : nTitleSpaceWidth = pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
1904 [ # # ]: 0 : if(nTitleSpaceWidth)
1905 : 0 : nTitleSpaceWidth+=lcl_getDiagramTitleSpace();
1906 : : }
1907 [ # # ]: 0 : if( xSecondTitle_Height.is() )
1908 : : {
1909 [ # # ]: 0 : rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Height, xChartModel ) );
1910 [ # # ]: 0 : nSecondTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
1911 [ # # ]: 0 : if( nSecondTitleSpaceHeight )
1912 : 0 : nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace();
1913 : : }
1914 [ # # ]: 0 : if( xSecondTitle_Width.is() )
1915 : : {
1916 [ # # ]: 0 : rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Width, xChartModel ) );
1917 [ # # ]: 0 : nSecondTitleSpaceWidth += pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
1918 [ # # ]: 0 : if( nSecondTitleSpaceWidth )
1919 : 0 : nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace();
1920 : : }
1921 : :
1922 : 0 : aRet.X -= nTitleSpaceWidth;
1923 : 0 : aRet.Y -= nSecondTitleSpaceHeight;
1924 : 0 : aRet.Width += nTitleSpaceWidth + nSecondTitleSpaceWidth;
1925 : 0 : aRet.Height += nTitleSpaceHeight + nSecondTitleSpaceHeight;
1926 : : }
1927 : : }
1928 : 0 : return aRet;
1929 : : }
1930 : :
1931 : 0 : awt::Rectangle ExplicitValueProvider::substractAxisTitleSizes(
1932 : : const Reference< frame::XModel >& xChartModel
1933 : : , const Reference< uno::XInterface >& xChartView
1934 : : , const awt::Rectangle& rPositionAndSizeIncludingTitles )
1935 : : {
1936 : 0 : awt::Rectangle aRet(rPositionAndSizeIncludingTitles);
1937 : :
1938 : : //add axis title sizes to the diagram size
1939 [ # # ]: 0 : uno::Reference< chart2::XTitle > xTitle_Height( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xChartModel ) );
1940 [ # # ]: 0 : uno::Reference< chart2::XTitle > xTitle_Width( TitleHelper::getTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xChartModel ) );
1941 [ # # ]: 0 : uno::Reference< chart2::XTitle > xSecondTitle_Height( TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xChartModel ) );
1942 [ # # ]: 0 : uno::Reference< chart2::XTitle > xSecondTitle_Width( TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xChartModel ) );
1943 [ # # ][ # # ]: 0 : if( xTitle_Height.is() || xTitle_Width.is() || xSecondTitle_Height.is() || xSecondTitle_Width.is() )
[ # # ][ # # ]
[ # # ]
1944 : : {
1945 [ # # ]: 0 : ExplicitValueProvider* pExplicitValueProvider = ExplicitValueProvider::getExplicitValueProvider(xChartView);
1946 [ # # ]: 0 : if( pExplicitValueProvider )
1947 : : {
1948 : : //detect whether x axis points into x direction or not
1949 [ # # ][ # # ]: 0 : if( lcl_getPropertySwapXAndYAxis( ChartModelHelper::findDiagram( xChartModel ) ) )
[ # # ]
1950 : : {
1951 [ # # ]: 0 : std::swap( xTitle_Height, xTitle_Width );
1952 [ # # ]: 0 : std::swap( xSecondTitle_Height, xSecondTitle_Width );
1953 : : }
1954 : :
1955 : 0 : sal_Int32 nTitleSpaceWidth = 0;
1956 : 0 : sal_Int32 nTitleSpaceHeight = 0;
1957 : 0 : sal_Int32 nSecondTitleSpaceWidth = 0;
1958 : 0 : sal_Int32 nSecondTitleSpaceHeight = 0;
1959 : :
1960 [ # # ]: 0 : if( xTitle_Height.is() )
1961 : : {
1962 [ # # ]: 0 : rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Height, xChartModel ) );
1963 [ # # ]: 0 : nTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
1964 [ # # ]: 0 : if( nTitleSpaceHeight )
1965 : 0 : nTitleSpaceHeight+=lcl_getDiagramTitleSpace();
1966 : : }
1967 [ # # ]: 0 : if( xTitle_Width.is() )
1968 : : {
1969 [ # # ]: 0 : rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle_Width, xChartModel ) );
1970 [ # # ]: 0 : nTitleSpaceWidth = pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
1971 [ # # ]: 0 : if(nTitleSpaceWidth)
1972 : 0 : nTitleSpaceWidth+=lcl_getDiagramTitleSpace();
1973 : : }
1974 [ # # ]: 0 : if( xSecondTitle_Height.is() )
1975 : : {
1976 [ # # ]: 0 : rtl::OUString aCID_X( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Height, xChartModel ) );
1977 [ # # ]: 0 : nSecondTitleSpaceHeight = pExplicitValueProvider->getRectangleOfObject( aCID_X, true ).Height;
1978 [ # # ]: 0 : if( nSecondTitleSpaceHeight )
1979 : 0 : nSecondTitleSpaceHeight+=lcl_getDiagramTitleSpace();
1980 : : }
1981 [ # # ]: 0 : if( xSecondTitle_Width.is() )
1982 : : {
1983 [ # # ]: 0 : rtl::OUString aCID_Y( ObjectIdentifier::createClassifiedIdentifierForObject( xSecondTitle_Width, xChartModel ) );
1984 [ # # ]: 0 : nSecondTitleSpaceWidth += pExplicitValueProvider->getRectangleOfObject( aCID_Y, true ).Width;
1985 [ # # ]: 0 : if( nSecondTitleSpaceWidth )
1986 : 0 : nSecondTitleSpaceWidth+=lcl_getDiagramTitleSpace();
1987 : : }
1988 : :
1989 : 0 : aRet.X += nTitleSpaceWidth;
1990 : 0 : aRet.Y += nSecondTitleSpaceHeight;
1991 : 0 : aRet.Width -= (nTitleSpaceWidth + nSecondTitleSpaceWidth);
1992 : 0 : aRet.Height -= (nTitleSpaceHeight + nSecondTitleSpaceHeight);
1993 : : }
1994 : : }
1995 : 0 : return aRet;
1996 : : }
1997 : :
1998 : 8021 : double lcl_getPageLayoutDistancePercentage()
1999 : : {
2000 : 8021 : return 0.02;
2001 : : }
2002 : :
2003 : 1003 : bool getAvailablePosAndSizeForDiagram(
2004 : : awt::Point& rOutPos, awt::Size& rOutAvailableDiagramSize
2005 : : , const awt::Rectangle& rSpaceLeft
2006 : : , const awt::Size & rPageSize
2007 : : , const uno::Reference< XDiagram > & xDiagram
2008 : : , bool& bUseFixedInnerSize )
2009 : : {
2010 : 1003 : bUseFixedInnerSize = false;
2011 : :
2012 : : //@todo: we need a size dependent on the axis labels
2013 : 1003 : awt::Rectangle aRemainingSpace(rSpaceLeft);
2014 : : {
2015 : 1003 : sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage());
2016 : 1003 : sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage());
2017 : 1003 : aRemainingSpace.X+=nXDistance;
2018 : 1003 : aRemainingSpace.Width-=2*nXDistance;
2019 : 1003 : aRemainingSpace.Y+=nYDistance;
2020 : 1003 : aRemainingSpace.Height-=2*nYDistance;
2021 : : }
2022 [ - + ][ + - ]: 1003 : if(aRemainingSpace.Width <= 0 || aRemainingSpace.Height <= 0 )
2023 : 0 : return false;
2024 : :
2025 [ + - ]: 1003 : uno::Reference< beans::XPropertySet > xProp(xDiagram, uno::UNO_QUERY);
2026 : :
2027 : 1003 : bool bPosSizeExcludeAxes = false;
2028 [ + + ]: 1003 : if( xProp.is() )
2029 [ + - ][ + - ]: 993 : xProp->getPropertyValue( C2U( "PosSizeExcludeAxes" ) ) >>= bPosSizeExcludeAxes;
[ + - ]
2030 : :
2031 : : //size:
2032 : 1003 : ::com::sun::star::chart2::RelativeSize aRelativeSize;
2033 [ + - ][ + - ]: 1003 : if( xProp.is() && (xProp->getPropertyValue( C2U( "RelativeSize" ) )>>=aRelativeSize) )
[ + - ][ + - ]
[ + + ][ + + ]
[ + + ][ + +
# # # # ]
[ + + ]
2034 : : {
2035 : 389 : rOutAvailableDiagramSize.Height = static_cast<sal_Int32>(aRelativeSize.Secondary*rPageSize.Height);
2036 : 389 : rOutAvailableDiagramSize.Width = static_cast<sal_Int32>(aRelativeSize.Primary*rPageSize.Width);
2037 : 389 : bUseFixedInnerSize = bPosSizeExcludeAxes;
2038 : : }
2039 : : else
2040 : 614 : rOutAvailableDiagramSize = awt::Size(aRemainingSpace.Width,aRemainingSpace.Height);
2041 : :
2042 : : //position:
2043 : 1003 : chart2::RelativePosition aRelativePosition;
2044 [ + - ][ + - ]: 1003 : if( xProp.is() && (xProp->getPropertyValue( C2U( "RelativePosition" ) )>>=aRelativePosition) )
[ + - ][ + - ]
[ + + ][ + + ]
[ + + ][ + +
# # # # ]
[ + + ]
2045 : : {
2046 : : //@todo decide whether x is primary or secondary
2047 : :
2048 : : //the coordinates re relative to the page
2049 : 391 : double fX = aRelativePosition.Primary*rPageSize.Width;
2050 : 391 : double fY = aRelativePosition.Secondary*rPageSize.Height;
2051 : :
2052 : : rOutPos = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject(
2053 : : awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(fY))
2054 [ + - ]: 391 : , rOutAvailableDiagramSize, aRelativePosition.Anchor );
2055 : 391 : bUseFixedInnerSize = bPosSizeExcludeAxes;
2056 : : }
2057 : : else
2058 : 612 : rOutPos = awt::Point(aRemainingSpace.X,aRemainingSpace.Y);
2059 : :
2060 : : //ensure that the diagram does not lap out right side or out of bottom
2061 : : {
2062 [ - + ]: 1003 : if( rOutPos.Y + rOutAvailableDiagramSize.Height > rPageSize.Height )
2063 : 0 : rOutAvailableDiagramSize.Height = rPageSize.Height - rOutPos.Y;
2064 [ + + ]: 1003 : if( rOutPos.X + rOutAvailableDiagramSize.Width > rPageSize.Width )
2065 : 6 : rOutAvailableDiagramSize.Width = rPageSize.Width - rOutPos.X;
2066 : : }
2067 : :
2068 : 1003 : return true;
2069 : : }
2070 : :
2071 : : enum TitleAlignment { ALIGN_LEFT, ALIGN_TOP, ALIGN_RIGHT, ALIGN_BOTTOM, ALIGN_Z };
2072 : :
2073 : 5015 : void changePositionOfAxisTitle( VTitle* pVTitle, TitleAlignment eAlignment
2074 : : , awt::Rectangle& rDiagramPlusAxesRect, const awt::Size & rPageSize )
2075 : : {
2076 [ - + ]: 5015 : if(!pVTitle)
2077 : 5015 : return;
2078 : :
2079 : 0 : awt::Point aNewPosition(0,0);
2080 [ # # ]: 0 : awt::Size aTitleSize = pVTitle->getFinalSize();
2081 : 0 : sal_Int32 nYDistance = static_cast<sal_Int32>(rPageSize.Height*lcl_getPageLayoutDistancePercentage());
2082 : 0 : sal_Int32 nXDistance = static_cast<sal_Int32>(rPageSize.Width*lcl_getPageLayoutDistancePercentage());
2083 [ # # # # : 0 : switch( eAlignment )
# # ]
2084 : : {
2085 : : case ALIGN_TOP:
2086 : : aNewPosition = awt::Point( rDiagramPlusAxesRect.X + rDiagramPlusAxesRect.Width/2
2087 : 0 : , rDiagramPlusAxesRect.Y - aTitleSize.Height/2 - nYDistance );
2088 : 0 : break;
2089 : : case ALIGN_BOTTOM:
2090 : : aNewPosition = awt::Point( rDiagramPlusAxesRect.X + rDiagramPlusAxesRect.Width/2
2091 : 0 : , rDiagramPlusAxesRect.Y + rDiagramPlusAxesRect.Height + aTitleSize.Height/2 + nYDistance );
2092 : 0 : break;
2093 : : case ALIGN_LEFT:
2094 : : aNewPosition = awt::Point( rDiagramPlusAxesRect.X - aTitleSize.Width/2 - nXDistance
2095 : 0 : , rDiagramPlusAxesRect.Y + rDiagramPlusAxesRect.Height/2 );
2096 : 0 : break;
2097 : : case ALIGN_RIGHT:
2098 : : aNewPosition = awt::Point( rDiagramPlusAxesRect.X + rDiagramPlusAxesRect.Width + aTitleSize.Width/2 + nXDistance
2099 : 0 : , rDiagramPlusAxesRect.Y + rDiagramPlusAxesRect.Height/2 );
2100 : 0 : break;
2101 : : case ALIGN_Z:
2102 : : aNewPosition = awt::Point( rDiagramPlusAxesRect.X + rDiagramPlusAxesRect.Width + aTitleSize.Width/2 + nXDistance
2103 : 0 : , rDiagramPlusAxesRect.Y + rDiagramPlusAxesRect.Height - aTitleSize.Height/2 );
2104 : 0 : break;
2105 : : default:
2106 : 0 : break;
2107 : : }
2108 : :
2109 : 0 : sal_Int32 nMaxY = rPageSize.Height - aTitleSize.Height/2;
2110 : 0 : sal_Int32 nMaxX = rPageSize.Width - aTitleSize.Width/2;
2111 : 0 : sal_Int32 nMinX = aTitleSize.Width/2;
2112 : 0 : sal_Int32 nMinY = aTitleSize.Height/2;
2113 [ # # ]: 0 : if( aNewPosition.Y > nMaxY )
2114 : 0 : aNewPosition.Y = nMaxY;
2115 [ # # ]: 0 : if( aNewPosition.X > nMaxX )
2116 : 0 : aNewPosition.X = nMaxX;
2117 [ # # ]: 0 : if( aNewPosition.Y < nMinY )
2118 : 0 : aNewPosition.Y = nMinY;
2119 [ # # ]: 0 : if( aNewPosition.X < nMinX )
2120 : 0 : aNewPosition.X = nMinX;
2121 : :
2122 [ # # ]: 5015 : pVTitle->changePosition( aNewPosition );
2123 : : }
2124 : :
2125 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2126 : 6015 : std::auto_ptr<VTitle> lcl_createTitle( TitleHelper::eTitleType eType
2127 : : , const uno::Reference< drawing::XShapes>& xPageShapes
2128 : : , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory
2129 : : , const uno::Reference< frame::XModel >& xChartModel
2130 : : , awt::Rectangle& rRemainingSpace
2131 : : , const awt::Size & rPageSize
2132 : : , TitleAlignment eAlignment
2133 : : , bool& rbAutoPosition )
2134 : : {
2135 : 6015 : std::auto_ptr<VTitle> apVTitle;
2136 : :
2137 : : // #i109336# Improve auto positioning in chart
2138 : 6015 : double fPercentage = lcl_getPageLayoutDistancePercentage();
2139 : 6015 : sal_Int32 nXDistance = static_cast< sal_Int32 >( rPageSize.Width * fPercentage );
2140 : 6015 : sal_Int32 nYDistance = static_cast< sal_Int32 >( rPageSize.Height * fPercentage );
2141 [ + + ]: 6015 : if ( eType == TitleHelper::MAIN_TITLE )
2142 : : {
2143 : 1071 : sal_Int32 nYOffset = 135; // 1/100 mm
2144 : 1071 : nYDistance += nYOffset;
2145 : : }
2146 [ + + ]: 4944 : else if ( eType == TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION )
2147 : : {
2148 : 983 : sal_Int32 nYOffset = 420; // 1/100 mm
2149 : 983 : nYDistance = nYOffset;
2150 : : }
2151 [ + + ]: 3961 : else if ( eType == TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION )
2152 : : {
2153 : 983 : sal_Int32 nXOffset = 450; // 1/100 mm
2154 : 983 : nXDistance = nXOffset;
2155 : : }
2156 : :
2157 [ + - ]: 6015 : uno::Reference< XTitle > xTitle( TitleHelper::getTitle( eType, xChartModel ) );
2158 [ + - ]: 6015 : rtl::OUString aCompleteString( TitleHelper::getCompleteString( xTitle ) );
2159 [ + + ]: 6015 : if( !aCompleteString.isEmpty() )
2160 : : {
2161 : : //create title
2162 [ + - ][ + - ]: 916 : apVTitle = std::auto_ptr<VTitle>(new VTitle(xTitle));
[ + - ]
2163 [ + - ]: 916 : rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ) );
2164 [ + - ]: 916 : apVTitle->init(xPageShapes,xShapeFactory,aCID);
2165 [ + - ]: 916 : apVTitle->createShapes( awt::Point(0,0), rPageSize );
2166 [ + - ]: 916 : awt::Size aTitleUnrotatedSize = apVTitle->getUnrotatedSize();
2167 [ + - ]: 916 : awt::Size aTitleSize = apVTitle->getFinalSize();
2168 : :
2169 : : //position
2170 : 916 : rbAutoPosition=true;
2171 : 916 : awt::Point aNewPosition(0,0);
2172 : 916 : chart2::RelativePosition aRelativePosition;
2173 [ + - ]: 916 : uno::Reference< beans::XPropertySet > xProp(xTitle, uno::UNO_QUERY);
2174 [ + - ][ + - ]: 916 : if( xProp.is() && (xProp->getPropertyValue( C2U( "RelativePosition" ) )>>=aRelativePosition) )
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + + # #
# # ]
2175 : : {
2176 : 712 : rbAutoPosition = false;
2177 : :
2178 : : //@todo decide whether x is primary or secondary
2179 : 712 : double fX = aRelativePosition.Primary*rPageSize.Width;
2180 : 712 : double fY = aRelativePosition.Secondary*rPageSize.Height;
2181 : :
2182 [ + - ]: 712 : double fAnglePi = apVTitle->getRotationAnglePi();
2183 : : aNewPosition = RelativePositionHelper::getCenterOfAnchoredObject(
2184 : : awt::Point(static_cast<sal_Int32>(fX),static_cast<sal_Int32>(fY))
2185 [ + - ]: 712 : , aTitleUnrotatedSize, aRelativePosition.Anchor, fAnglePi );
2186 : : }
2187 : : else //auto position
2188 : : {
2189 [ + - - - : 204 : switch( eAlignment )
- ]
2190 : : {
2191 : : case ALIGN_TOP:
2192 : : aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2
2193 : 204 : , rRemainingSpace.Y + aTitleSize.Height/2 + nYDistance );
2194 : 204 : break;
2195 : : case ALIGN_BOTTOM:
2196 : : aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width/2
2197 : 0 : , rRemainingSpace.Y + rRemainingSpace.Height - aTitleSize.Height/2 - nYDistance );
2198 : 0 : break;
2199 : : case ALIGN_LEFT:
2200 : : aNewPosition = awt::Point( rRemainingSpace.X + aTitleSize.Width/2 + nXDistance
2201 : 0 : , rRemainingSpace.Y + rRemainingSpace.Height/2 );
2202 : 0 : break;
2203 : : case ALIGN_RIGHT:
2204 : : aNewPosition = awt::Point( rRemainingSpace.X + rRemainingSpace.Width - aTitleSize.Width/2 - nXDistance
2205 : 0 : , rRemainingSpace.Y + rRemainingSpace.Height/2 );
2206 : 0 : break;
2207 : : default:
2208 : 0 : break;
2209 : :
2210 : : }
2211 : : }
2212 [ + - ]: 916 : apVTitle->changePosition( aNewPosition );
2213 : :
2214 : : //remaining space
2215 [ + - - - : 916 : switch( eAlignment )
- ]
2216 : : {
2217 : : case ALIGN_TOP:
2218 : 916 : rRemainingSpace.Y += ( aTitleSize.Height + nYDistance );
2219 : 916 : rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance );
2220 : 916 : break;
2221 : : case ALIGN_BOTTOM:
2222 : 0 : rRemainingSpace.Height -= ( aTitleSize.Height + nYDistance );
2223 : 0 : break;
2224 : : case ALIGN_LEFT:
2225 : 0 : rRemainingSpace.X += ( aTitleSize.Width + nXDistance );
2226 : 0 : rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance );
2227 : 0 : break;
2228 : : case ALIGN_RIGHT:
2229 : 0 : rRemainingSpace.Width -= ( aTitleSize.Width + nXDistance );
2230 : 0 : break;
2231 : : default:
2232 : 0 : break;
2233 : 916 : }
2234 : : }
2235 : : else
2236 : : {
2237 : : // #i109336# Improve auto positioning in chart
2238 [ + + + + : 5099 : switch ( eAlignment )
- ]
2239 : : {
2240 : : case ALIGN_TOP:
2241 : : {
2242 : 2127 : rRemainingSpace.Y += nYDistance;
2243 : 2127 : rRemainingSpace.Height -= nYDistance;
2244 : : }
2245 : 2127 : break;
2246 : : case ALIGN_BOTTOM:
2247 : : {
2248 : 983 : rRemainingSpace.Height -= nYDistance;
2249 : : }
2250 : 983 : break;
2251 : : case ALIGN_LEFT:
2252 : : {
2253 : 983 : rRemainingSpace.X += nXDistance;
2254 : 983 : rRemainingSpace.Width -= nXDistance;
2255 : : }
2256 : 983 : break;
2257 : : case ALIGN_RIGHT:
2258 : : {
2259 : 1006 : rRemainingSpace.Width -= nXDistance;
2260 : : }
2261 : 1006 : break;
2262 : : default:
2263 : 0 : break;
2264 : : }
2265 : : }
2266 : 6015 : return apVTitle;
2267 : : }
2268 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2269 : :
2270 : 1003 : bool lcl_createLegend( const uno::Reference< XLegend > & xLegend
2271 : : , const uno::Reference< drawing::XShapes>& xPageShapes
2272 : : , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory
2273 : : , const uno::Reference< uno::XComponentContext > & xContext
2274 : : , awt::Rectangle & rRemainingSpace
2275 : : , const awt::Size & rPageSize
2276 : : , const uno::Reference< frame::XModel > & xModel
2277 : : , const std::vector< LegendEntryProvider* >& rLegendEntryProviderList
2278 : : , sal_Int16 nDefaultWritingMode )
2279 : : {
2280 [ + + ]: 1003 : if( VLegend::isVisible( xLegend ))
2281 : : {
2282 [ + - ]: 956 : VLegend aVLegend( xLegend, xContext, rLegendEntryProviderList );
2283 [ + - ]: 956 : aVLegend.init( xPageShapes, xShapeFactory, xModel );
2284 [ + - ]: 956 : aVLegend.setDefaultWritingMode( nDefaultWritingMode );
2285 : : aVLegend.createShapes( awt::Size( rRemainingSpace.Width, rRemainingSpace.Height ),
2286 [ + - ]: 956 : rPageSize );
2287 [ + - ]: 956 : aVLegend.changePosition( rRemainingSpace, rPageSize );
2288 [ + - ]: 956 : return true;
2289 : : }
2290 : 1003 : return false;
2291 : : }
2292 : :
2293 : 1071 : void formatPage(
2294 : : const uno::Reference< frame::XModel > & xModel
2295 : : , const awt::Size rPageSize
2296 : : , const uno::Reference< drawing::XShapes >& xTarget
2297 : : , const uno::Reference< lang::XMultiServiceFactory>& xShapeFactory
2298 : : )
2299 : : {
2300 : : try
2301 : : {
2302 [ + - ]: 1071 : uno::Reference< XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
2303 : : OSL_ASSERT( xChartDoc.is());
2304 [ - + ]: 1071 : if( ! xChartDoc.is())
2305 : : return;
2306 [ + - ][ + - ]: 1071 : uno::Reference< beans::XPropertySet > xModelPage( xChartDoc->getPageBackground());
2307 [ - + ]: 1071 : if( ! xModelPage.is())
2308 : : return;
2309 : :
2310 : :
2311 [ - + ]: 1071 : if( !xShapeFactory.is() )
2312 : : return;
2313 : :
2314 : 1071 : uno::Reference< beans::XPropertySet > xPageProp;
2315 : : // create a shape for the background
2316 : : {
2317 : : uno::Reference< drawing::XShape > xShape(
2318 [ + - ]: 1071 : xShapeFactory->createInstance(
2319 [ + - ][ + - ]: 1071 : C2U( "com.sun.star.drawing.RectangleShape" )), uno::UNO_QUERY );
[ + - ]
2320 [ + - ]: 2142 : if( xTarget.is() &&
[ + - + - ]
2321 : 1071 : xShape.is())
2322 : : {
2323 [ + - ][ + - ]: 1071 : xTarget->add( xShape );
2324 [ + - ][ + - ]: 1071 : xShape->setSize( rPageSize );
2325 [ + - ]: 1071 : xPageProp.set( xShape, uno::UNO_QUERY );
2326 [ + - ]: 1071 : if( xPageProp.is())
2327 : : {
2328 [ + - ][ + - ]: 1071 : xPageProp->setPropertyValue( C2U("LineStyle"), uno::makeAny( drawing::LineStyle_NONE ));
[ + - ][ + - ]
2329 : : }
2330 : 1071 : }
2331 : : }
2332 : :
2333 : : //format page
2334 [ + - ]: 1071 : if( xPageProp.is())
2335 : : {
2336 [ + - ]: 1071 : tPropertyNameValueMap aNameValueMap;
2337 [ + - ][ + - ]: 1071 : PropertyMapper::getValueMap( aNameValueMap, PropertyMapper::getPropertyNameMapForFillAndLineProperties(), xModelPage );
2338 : :
2339 [ + - ]: 1071 : rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );
2340 [ + - ][ + - ]: 1071 : aNameValueMap.insert( tPropertyNameValueMap::value_type( C2U("Name"), uno::makeAny( aCID ) ) ); //CID rtl::OUString
[ + - ]
2341 : :
2342 [ + - ]: 1071 : tNameSequence aNames;
2343 [ + - ]: 1071 : tAnySequence aValues;
2344 [ + - ]: 1071 : PropertyMapper::getMultiPropertyListsFromValueMap( aNames, aValues, aNameValueMap );
2345 [ + - ][ + - ]: 1071 : PropertyMapper::setMultiProperties( aNames, aValues, xPageProp );
[ + - ]
2346 [ - + ][ + - ]: 1071 : }
[ # # ]
2347 : : }
2348 : 0 : catch( const uno::Exception & ex )
2349 : : {
2350 : : ASSERT_EXCEPTION( ex );
2351 : : }
2352 : : }
2353 : :
2354 : 33863 : void lcl_removeEmptyGroupShapes( const Reference< drawing::XShapes>& xParent )
2355 : : {
2356 [ + - ]: 33863 : if(!xParent.is())
2357 : : return;
2358 [ + - ]: 33863 : Reference< drawing::XShapeGroup > xParentGroup( xParent, uno::UNO_QUERY );
2359 [ + + ]: 33863 : if( !xParentGroup.is() )
2360 : : {
2361 [ + - ]: 14 : Reference< drawing::XDrawPage > xPage( xParent, uno::UNO_QUERY );
2362 [ + - ]: 14 : if( !xPage.is() )
2363 [ - + ]: 14 : return;
2364 : : }
2365 : :
2366 : : //iterate from back!
2367 [ + - ][ + - ]: 110815 : for( sal_Int32 nN = xParent->getCount(); nN--; )
[ + + ]
2368 : : {
2369 [ + - ][ + - ]: 76966 : uno::Any aAny = xParent->getByIndex( nN );
2370 [ + - ]: 76966 : Reference< drawing::XShapes> xShapes(0);
2371 [ + - ][ + + ]: 76966 : if( aAny >>= xShapes )
2372 [ + - ]: 32860 : lcl_removeEmptyGroupShapes( xShapes );
2373 [ + + ][ + - ]: 76966 : if( xShapes.is() && xShapes->getCount()==0 )
[ + - ][ + + ]
[ + + ]
2374 : : {
2375 : : //remove empty group shape
2376 [ + - ]: 6320 : Reference< drawing::XShapeGroup > xGroup( xShapes, uno::UNO_QUERY );
2377 [ + - ]: 6320 : Reference< drawing::XShape > xShape( xShapes, uno::UNO_QUERY );
2378 [ + - ]: 6320 : if( xGroup.is() )
2379 [ + - ][ + - ]: 6320 : xParent->remove( xShape );
2380 : : }
2381 [ + + ]: 110829 : }
2382 : : }
2383 : :
2384 : 1071 : bool ChartView::impl_AddInDrawsAllByItself()
2385 : : {
2386 : 1071 : return false;
2387 : : }
2388 : :
2389 : 1071 : void ChartView::impl_refreshAddIn()
2390 : : {
2391 [ + + ]: 1071 : if( !m_bRefreshAddIn )
2392 : 1071 : return;
2393 : :
2394 [ + - ]: 843 : uno::Reference< beans::XPropertySet > xProp( m_xChartModel, uno::UNO_QUERY );
2395 [ + - ]: 843 : if( xProp.is()) try
2396 : : {
2397 : 843 : uno::Reference< util::XRefreshable > xAddIn;
2398 [ + - ][ + - ]: 843 : xProp->getPropertyValue( C2U( "AddIn" ) ) >>= xAddIn;
[ + - ][ + - ]
2399 [ - + ]: 843 : if( xAddIn.is() )
2400 : : {
2401 : 0 : sal_Bool bRefreshAddInAllowed = sal_True;
2402 [ # # ][ # # ]: 0 : xProp->getPropertyValue( C2U( "RefreshAddInAllowed" ) ) >>= bRefreshAddInAllowed;
[ # # ]
2403 [ # # ]: 0 : if( bRefreshAddInAllowed )
2404 [ # # ][ # # ]: 0 : xAddIn->refresh();
2405 [ # # ]: 843 : }
2406 : : }
2407 [ # # ]: 0 : catch( const uno::Exception& e )
2408 : : {
2409 : : ASSERT_EXCEPTION( e );
2410 : 1071 : }
2411 : : }
2412 : :
2413 : 1071 : void ChartView::createShapes()
2414 : : {
2415 : : #if OSL_DEBUG_LEVEL > 0
2416 : : clock_t nStart = clock();
2417 : : OSL_TRACE( "\nPPPPPPPPP>>>>>>>>>>>> chart view :: createShapes()" );
2418 : : #endif
2419 : :
2420 : : //make sure add-in is refreshed after creating the shapes
2421 [ + - ][ + - ]: 1071 : const ::comphelper::ScopeGuard aGuard( boost::bind( &ChartView::impl_refreshAddIn, this ) );
2422 [ - + ]: 1071 : if( impl_AddInDrawsAllByItself() )
2423 : : return;
2424 : :
2425 : 1071 : m_aResultingDiagramRectangleExcludingAxes = awt::Rectangle(0,0,0,0);
2426 [ + - ]: 1071 : impl_deleteCoordinateSystems();
2427 [ + - ]: 1071 : if( m_pDrawModelWrapper )
2428 : : {
2429 [ + - ]: 1071 : SolarMutexGuard aSolarGuard;
2430 : : // #i12587# support for shapes in chart
2431 [ + - ][ + - ]: 1071 : m_pDrawModelWrapper->getSdrModel().EnableUndo( sal_False );
2432 [ + - ][ + - ]: 1071 : m_pDrawModelWrapper->clearMainDrawPage();
2433 : : }
2434 : :
2435 [ + - ][ + - ]: 1071 : lcl_setDefaultWritingMode( m_pDrawModelWrapper, m_xChartModel );
[ + - ]
2436 : :
2437 [ + - ]: 1071 : awt::Size aPageSize = ChartModelHelper::getPageSize( m_xChartModel );
2438 : :
2439 : : uno::Reference<drawing::XShapes> xPageShapes( ShapeFactory(m_xShapeFactory)
2440 [ + - ][ + - ]: 1071 : .getOrCreateChartRootShape( m_xDrawPage ) );
[ + - ]
2441 : :
2442 [ + - ]: 1071 : SdrPage* pPage = ChartView::getSdrPage();
2443 [ + - ]: 1071 : if(pPage) //it is neccessary to use the implementation here as the uno page does not provide a propertyset
2444 [ + - ]: 1071 : pPage->SetSize(Size(aPageSize.Width,aPageSize.Height));
2445 : : else
2446 : : {
2447 : : OSL_FAIL("could not set page size correctly");
2448 : : }
2449 : :
2450 : : {
2451 [ + - ]: 1071 : SolarMutexGuard aSolarGuard;
2452 : :
2453 : : //------------ apply fill properties to page
2454 : : // todo: it would be nicer to just pass the page m_xDrawPage and format it,
2455 : : // but the draw page does not support XPropertySet
2456 [ + - ]: 1071 : formatPage( m_xChartModel, aPageSize, xPageShapes, m_xShapeFactory );
2457 : :
2458 : : //sal_Int32 nYDistance = static_cast<sal_Int32>(aPageSize.Height*lcl_getPageLayoutDistancePercentage());
2459 : 1071 : awt::Rectangle aRemainingSpace( 0, 0, aPageSize.Width, aPageSize.Height );
2460 : :
2461 : : //create the group shape for diagram and axes first to have title and legends on top of it
2462 [ + - ]: 1071 : uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) );
2463 [ + - ]: 1071 : rtl::OUString aDiagramCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ) );//todo: other index if more than one diagram is possible
2464 [ + - ][ + - ]: 1071 : uno::Reference< drawing::XShapes > xDiagramPlusAxesPlusMarkHandlesGroup_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xPageShapes,aDiagramCID) );
[ + - ]
2465 : :
2466 : : uno::Reference< drawing::XShape > xDiagram_MarkHandles( ShapeFactory(m_xShapeFactory).createInvisibleRectangle(
2467 [ + - ][ + - ]: 1071 : xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) );
[ + - ]
2468 [ + - ][ + - ]: 1071 : ShapeFactory::setShapeName( xDiagram_MarkHandles, C2U("MarkHandles") );
2469 : :
2470 : : uno::Reference< drawing::XShape > xDiagram_OuterRect( ShapeFactory(m_xShapeFactory).createInvisibleRectangle(
2471 [ + - ][ + - ]: 1071 : xDiagramPlusAxesPlusMarkHandlesGroup_Shapes, awt::Size(0,0) ) );
[ + - ]
2472 [ + - ][ + - ]: 1071 : ShapeFactory::setShapeName( xDiagram_OuterRect, C2U("PlotAreaIncludingAxes") );
2473 : :
2474 [ + - ][ + - ]: 1071 : uno::Reference< drawing::XShapes > xDiagramPlusAxes_Shapes( ShapeFactory(m_xShapeFactory).createGroup2D(xDiagramPlusAxesPlusMarkHandlesGroup_Shapes ) );
[ + - ]
2475 : :
2476 : : //------------ create some titles
2477 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2478 : 1071 : std::auto_ptr<VTitle> apVTitle(0);
2479 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2480 : 1071 : bool bAutoPositionDummy = true;
2481 : :
2482 : : //------------ create main title shape
2483 : : lcl_createTitle( TitleHelper::MAIN_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
2484 [ + - ][ + - ]: 1071 : , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy );
2485 [ + - ][ + + ]: 1071 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2486 : : return;
2487 : :
2488 : : //------------ create sub title shape
2489 : : lcl_createTitle( TitleHelper::SUB_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
2490 [ + - ][ + - ]: 1003 : , aRemainingSpace, aPageSize, ALIGN_TOP, bAutoPositionDummy );
2491 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2492 : : return;
2493 : :
2494 : :
2495 : : //------------ prepare series to give input to the legend (create categories and symbols etc.)
2496 [ + - ]: 1003 : SeriesPlotterContainer aSeriesPlotterContainer( m_aVCooSysList );
2497 [ + - ]: 1003 : aSeriesPlotterContainer.initializeCooSysAndSeriesPlotter( m_xChartModel );
2498 : :
2499 : : //------------ create legend
2500 : : lcl_createLegend( LegendHelper::getLegend( m_xChartModel ), xPageShapes, m_xShapeFactory, m_xCC
2501 : : , aRemainingSpace, aPageSize, m_xChartModel, aSeriesPlotterContainer.getLegendEntryProviderList()
2502 [ + - ][ + - ]: 1003 : , lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
2503 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2504 : : return;
2505 : :
2506 [ + - ]: 1003 : Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) );
2507 [ + - ]: 1003 : sal_Int32 nDimension = DiagramHelper::getDimension( xDiagram );
2508 : :
2509 : : //------------ create x axis title
2510 : 1003 : bool bAutoPosition_XTitle = true;
2511 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2512 : 1003 : std::auto_ptr<VTitle> apVTitle_X;
2513 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2514 [ + + ][ + - ]: 1003 : if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 0 ) )
2515 : : apVTitle_X = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_X_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel
2516 [ + - ][ + - ]: 983 : , aRemainingSpace, aPageSize, ALIGN_BOTTOM, bAutoPosition_XTitle );
2517 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2518 : : return;
2519 : :
2520 : : //------------ create y axis title
2521 : 1003 : bool bAutoPosition_YTitle = true;
2522 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2523 : 1003 : std::auto_ptr<VTitle> apVTitle_Y;
2524 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2525 [ + + ][ + - ]: 1003 : if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 1 ) )
2526 : : apVTitle_Y = lcl_createTitle( TitleHelper::TITLE_AT_STANDARD_Y_AXIS_POSITION, xPageShapes, m_xShapeFactory, m_xChartModel
2527 [ + - ][ + - ]: 983 : , aRemainingSpace, aPageSize, ALIGN_LEFT, bAutoPosition_YTitle );
2528 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2529 : : return;
2530 : :
2531 : : //------------ create z axis title
2532 : 1003 : bool bAutoPosition_ZTitle = true;
2533 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2534 : 1003 : std::auto_ptr<VTitle> apVTitle_Z;
2535 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2536 [ + + ][ + - ]: 1003 : if( ChartTypeHelper::isSupportingMainAxis( xChartType, nDimension, 2 ) )
2537 : : apVTitle_Z = lcl_createTitle( TitleHelper::Z_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
2538 [ + - ][ + - ]: 37 : , aRemainingSpace, aPageSize, ALIGN_RIGHT, bAutoPosition_ZTitle );
2539 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2540 : : return;
2541 : :
2542 : 1003 : bool bDummy = false;
2543 [ + - ]: 1003 : bool bIsVertical = DiagramHelper::getVertical( xDiagram, bDummy, bDummy );
2544 : :
2545 : : //------------ create secondary x axis title
2546 : 1003 : bool bAutoPosition_SecondXTitle = true;
2547 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2548 : 1003 : std::auto_ptr<VTitle> apVTitle_SecondX;
2549 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2550 [ + + ][ + - ]: 1003 : if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 0 ) )
2551 : : apVTitle_SecondX = lcl_createTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
2552 [ - + ][ + - ]: 969 : , aRemainingSpace, aPageSize, bIsVertical? ALIGN_RIGHT : ALIGN_TOP, bAutoPosition_SecondXTitle );
[ + - ]
2553 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2554 : : return;
2555 : :
2556 : : //------------ create secondary y axis title
2557 : 1003 : bool bAutoPosition_SecondYTitle = true;
2558 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
2559 : 1003 : std::auto_ptr<VTitle> apVTitle_SecondY;
2560 : : SAL_WNODEPRECATED_DECLARATIONS_POP
2561 [ + + ][ + - ]: 1003 : if( ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimension, 1 ) )
2562 : : apVTitle_SecondY = lcl_createTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xPageShapes, m_xShapeFactory, m_xChartModel
2563 [ - + ][ + - ]: 969 : , aRemainingSpace, aPageSize, bIsVertical? ALIGN_TOP : ALIGN_RIGHT, bAutoPosition_SecondYTitle );
[ + - ]
2564 [ + - ][ - + ]: 1003 : if(aRemainingSpace.Width<=0||aRemainingSpace.Height<=0)
2565 : : return;
2566 : :
2567 : : //------------ create complete diagram shape (inclusive axis and series)
2568 : 1003 : awt::Point aAvailablePosDia;
2569 : 1003 : awt::Size aAvailableSizeForDiagram;
2570 : 1003 : bool bUseFixedInnerSize = false;
2571 [ + - + - ]: 2006 : if( getAvailablePosAndSizeForDiagram( aAvailablePosDia, aAvailableSizeForDiagram, aRemainingSpace, aPageSize
2572 [ + - ]: 2006 : , ChartModelHelper::findDiagram( m_xChartModel ), bUseFixedInnerSize ) )
2573 : : {
2574 : : awt::Rectangle aUsedOuterRect = impl_createDiagramAndContent( aSeriesPlotterContainer
2575 : : , xDiagramPlusAxes_Shapes
2576 [ + - ]: 1003 : , aAvailablePosDia ,aAvailableSizeForDiagram, aPageSize, bUseFixedInnerSize, xDiagram_MarkHandles );
2577 : :
2578 [ + - ]: 1003 : if( xDiagram_OuterRect.is() )
2579 : : {
2580 [ + - ][ + - ]: 1003 : xDiagram_OuterRect->setPosition( awt::Point( aUsedOuterRect.X, aUsedOuterRect.Y ) );
2581 [ + - ][ + - ]: 1003 : xDiagram_OuterRect->setSize( awt::Size( aUsedOuterRect.Width, aUsedOuterRect.Height ) );
2582 : : }
2583 : :
2584 : : //correct axis title position
2585 : 1003 : awt::Rectangle aDiagramPlusAxesRect( aUsedOuterRect );
2586 [ + - ]: 1003 : if(bAutoPosition_XTitle)
2587 [ + - ]: 1003 : changePositionOfAxisTitle( apVTitle_X.get(), ALIGN_BOTTOM, aDiagramPlusAxesRect, aPageSize );
2588 [ + - ]: 1003 : if(bAutoPosition_YTitle)
2589 [ + - ]: 1003 : changePositionOfAxisTitle( apVTitle_Y.get(), ALIGN_LEFT, aDiagramPlusAxesRect, aPageSize );
2590 [ + - ]: 1003 : if(bAutoPosition_ZTitle)
2591 [ + - ]: 1003 : changePositionOfAxisTitle( apVTitle_Z.get(), ALIGN_Z, aDiagramPlusAxesRect, aPageSize );
2592 [ + - ]: 1003 : if(bAutoPosition_SecondXTitle)
2593 [ + + ][ + - ]: 1003 : changePositionOfAxisTitle( apVTitle_SecondX.get(), bIsVertical? ALIGN_RIGHT : ALIGN_TOP, aDiagramPlusAxesRect, aPageSize );
2594 [ + - ]: 1003 : if(bAutoPosition_SecondYTitle)
2595 [ + + ][ + - ]: 1003 : changePositionOfAxisTitle( apVTitle_SecondY.get(), bIsVertical? ALIGN_TOP : ALIGN_RIGHT, aDiagramPlusAxesRect, aPageSize );
2596 : : }
2597 : :
2598 : : //cleanup: remove all empty group shapes to avoid grey border lines:
2599 [ + - ][ + - ]: 1071 : lcl_removeEmptyGroupShapes( xPageShapes );
[ - + ][ + - ]
[ - + ][ + - ]
[ - + ][ + - ]
[ - + ][ + - ]
[ - + ][ - + ]
[ + - ][ - + ]
[ + - ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + - ][ + + ]
2600 : : }
2601 : :
2602 : : // #i12587# support for shapes in chart
2603 [ + - ]: 1071 : if ( m_pDrawModelWrapper )
2604 : : {
2605 [ + - ]: 1003 : SolarMutexGuard aSolarGuard;
2606 [ + - ][ + - ]: 1003 : m_pDrawModelWrapper->getSdrModel().EnableUndo( true );
[ + - ]
2607 [ + + ][ + - ]: 1071 : }
[ + + ]
2608 : :
2609 : : #if OSL_DEBUG_LEVEL > 0
2610 : : clock_t nEnd = clock();
2611 : : double fDuration =(double(nEnd-nStart)*1000.0)/double(CLOCKS_PER_SEC);
2612 : :
2613 : : OSL_TRACE( "\nPPPPPPPPP<<<<<<<<<<<< chart view :: createShapes():: needed %f msec", fDuration );
2614 : : #endif
2615 : : }
2616 : :
2617 : : //-----------------------------------------------------------------
2618 : : // util::XEventListener (base of XCloseListener)
2619 : : //-----------------------------------------------------------------
2620 : 0 : void SAL_CALL ChartView::disposing( const lang::EventObject& /* rSource */ )
2621 : : throw(uno::RuntimeException)
2622 : : {
2623 [ # # ]: 0 : impl_setChartModel( 0 );
2624 : 0 : }
2625 : :
2626 : 1808 : void ChartView::impl_updateView()
2627 : : {
2628 [ + - ][ - + ]: 1808 : if( !m_xChartModel.is() || !m_pDrawModelWrapper )
[ - + ]
2629 : 0 : return;
2630 : :
2631 : : // #i12587# support for shapes in chart
2632 [ - + ]: 1808 : if ( m_bSdrViewIsInEditMode )
2633 : : {
2634 : 0 : return;
2635 : : }
2636 : :
2637 [ + + ][ + + ]: 1808 : if( m_bViewDirty && !m_bInViewUpdate )
[ + + ]
2638 : : {
2639 : 843 : m_bInViewUpdate = true;
2640 : : //bool bOldRefreshAddIn = m_bRefreshAddIn;
2641 : : //m_bRefreshAddIn = false;
2642 : : try
2643 : : {
2644 [ + - ][ + - ]: 843 : impl_notifyModeChangeListener(C2U("invalid"));
2645 : :
2646 : : //prepare draw model
2647 : : {
2648 [ + - ]: 843 : SolarMutexGuard aSolarGuard;
2649 [ + - ]: 843 : m_pDrawModelWrapper->lockControllers();
[ + - # # ]
2650 : : }
2651 : :
2652 : : //create chart view
2653 : : {
2654 : 843 : m_bViewDirty = false;
2655 : 843 : m_bViewUpdatePending = false;
2656 [ + - ]: 843 : createShapes();
2657 : :
2658 [ + + ]: 843 : if( m_bViewDirty )
2659 : : {
2660 : : //avoid recursions due to add-in
2661 : 228 : m_bRefreshAddIn = false;
2662 : 228 : m_bViewDirty = false;
2663 : 228 : m_bViewUpdatePending = false;
2664 : : //delete old chart view
2665 [ + - ]: 228 : createShapes();
2666 : 228 : m_bRefreshAddIn = true;
2667 : : }
2668 : : }
2669 : :
2670 : 843 : m_bViewDirty = m_bViewUpdatePending;
2671 : 843 : m_bViewUpdatePending = false;
2672 : 843 : m_bInViewUpdate = false;
2673 : : }
2674 : 0 : catch( const uno::Exception& ex)
2675 : : {
2676 : 0 : m_bViewDirty = m_bViewUpdatePending;
2677 : 0 : m_bViewUpdatePending = false;
2678 : 0 : m_bInViewUpdate = false;
2679 : : ASSERT_EXCEPTION( ex );
2680 : : }
2681 : :
2682 : : {
2683 [ + - ]: 843 : SolarMutexGuard aSolarGuard;
2684 [ + - ][ + - ]: 843 : m_pDrawModelWrapper->unlockControllers();
2685 : : }
2686 : :
2687 [ + - ]: 1808 : impl_notifyModeChangeListener(C2U("valid"));
2688 : :
2689 : : //m_bRefreshAddIn = bOldRefreshAddIn;
2690 : : }
2691 : : }
2692 : :
2693 : : // ____ XModifyListener ____
2694 : 1860 : void SAL_CALL ChartView::modified( const lang::EventObject& /* aEvent */ )
2695 : : throw (uno::RuntimeException)
2696 : : {
2697 : 1860 : m_bViewDirty = sal_True;
2698 [ + + ]: 1860 : if( m_bInViewUpdate )
2699 : 239 : m_bViewUpdatePending = true;
2700 : :
2701 [ + - ]: 1860 : impl_notifyModeChangeListener(C2U("dirty"));
2702 : 1860 : }
2703 : :
2704 : : //SfxListener
2705 : 93963 : void ChartView::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
2706 : : {
2707 : : //#i77362 change notification for changes on additional shapes are missing
2708 [ - + ]: 93963 : if( m_bInViewUpdate )
2709 : : return;
2710 : :
2711 : : // #i12587# support for shapes in chart
2712 [ # # ][ # # ]: 0 : if ( m_bSdrViewIsInEditMode && m_xChartModel.is() )
[ # # ]
2713 : : {
2714 [ # # ][ # # ]: 0 : uno::Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartModel->getCurrentController(), uno::UNO_QUERY );
[ # # ]
2715 [ # # ]: 0 : if ( xSelectionSupplier.is() )
2716 : : {
2717 : 0 : ::rtl::OUString aSelObjCID;
2718 [ # # ][ # # ]: 0 : uno::Any aSelObj( xSelectionSupplier->getSelection() );
2719 : 0 : aSelObj >>= aSelObjCID;
2720 [ # # ]: 0 : if ( !aSelObjCID.isEmpty() )
2721 : : {
2722 : : return;
2723 [ # # ][ # # ]: 0 : }
2724 [ # # ]: 0 : }
2725 : : }
2726 : :
2727 [ # # ]: 0 : const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >(&rHint);
2728 [ # # ]: 0 : if( !pSdrHint )
2729 : : return;
2730 : :
2731 : 0 : bool bShapeChanged = false;
2732 [ # # ][ # # : 0 : switch( pSdrHint->GetKind() )
# # # # ]
2733 : : {
2734 : : case HINT_OBJCHG:
2735 : 0 : bShapeChanged = true;
2736 : 0 : break;
2737 : : case HINT_OBJINSERTED:
2738 : 0 : bShapeChanged = true;
2739 : 0 : break;
2740 : : case HINT_OBJREMOVED:
2741 : 0 : bShapeChanged = true;
2742 : 0 : break;
2743 : : case HINT_MODELCLEARED:
2744 : 0 : bShapeChanged = true;
2745 : 0 : break;
2746 : : case HINT_ENDEDIT:
2747 : 0 : bShapeChanged = true;
2748 : 0 : break;
2749 : : default:
2750 : 0 : break;
2751 : : }
2752 : :
2753 [ # # ]: 0 : if(bShapeChanged)
2754 : : {
2755 : : //#i76053# do not send view modified notifications for changes on the hidden page which contains e.g. the symbols for the dialogs
2756 [ # # ][ # # ]: 0 : if( ChartView::getSdrPage() != pSdrHint->GetPage() )
[ # # ]
2757 : 0 : bShapeChanged=false;
2758 : : }
2759 : :
2760 [ # # ]: 0 : if(!bShapeChanged)
2761 : : return;
2762 : :
2763 [ # # ]: 0 : Reference< util::XModifiable > xModifiable( m_xChartModel, uno::UNO_QUERY );
2764 [ # # ]: 0 : if( xModifiable.is() )
2765 [ # # ][ # # ]: 93963 : xModifiable->setModified( sal_True );
2766 : : }
2767 : :
2768 : 3546 : void ChartView::impl_notifyModeChangeListener( const rtl::OUString& rNewMode )
2769 : : {
2770 : : try
2771 : : {
2772 : : ::cppu::OInterfaceContainerHelper* pIC = m_aListenerContainer
2773 [ + - ][ + - ]: 3546 : .getContainer( ::getCppuType((const uno::Reference< util::XModeChangeListener >*)0) );
2774 [ + + ]: 3546 : if( pIC )
2775 : : {
2776 [ + - ][ + - ]: 3110 : util::ModeChangeEvent aEvent( static_cast< uno::XWeak* >( this ), rNewMode );
2777 [ + - ]: 3110 : ::cppu::OInterfaceIteratorHelper aIt( *pIC );
2778 [ + + ]: 6220 : while( aIt.hasMoreElements() )
2779 : : {
2780 [ + - ][ + - ]: 3110 : uno::Reference< util::XModeChangeListener > xListener( aIt.next(), uno::UNO_QUERY );
2781 [ + - ]: 3110 : if( xListener.is() )
2782 [ + - ][ + - ]: 3110 : xListener->modeChanged( aEvent );
2783 [ + - ][ + - ]: 6220 : }
[ # # ]
2784 : : }
2785 : : }
2786 : 0 : catch( const uno::Exception& ex)
2787 : : {
2788 : : ASSERT_EXCEPTION( ex );
2789 : : }
2790 : 3546 : }
2791 : :
2792 : : // ____ XModeChangeBroadcaster ____
2793 : :
2794 : 34 : void SAL_CALL ChartView::addModeChangeListener( const uno::Reference< util::XModeChangeListener >& xListener )
2795 : : throw (uno::RuntimeException)
2796 : : {
2797 : : m_aListenerContainer.addInterface(
2798 : 34 : ::getCppuType((const uno::Reference< util::XModeChangeListener >*)0), xListener );
2799 : 34 : }
2800 : 34 : void SAL_CALL ChartView::removeModeChangeListener( const uno::Reference< util::XModeChangeListener >& xListener )
2801 : : throw (uno::RuntimeException)
2802 : : {
2803 : : m_aListenerContainer.removeInterface(
2804 : 34 : ::getCppuType((const uno::Reference< util::XModeChangeListener >*)0), xListener );
2805 : 34 : }
2806 : 0 : void SAL_CALL ChartView::addModeChangeApproveListener( const uno::Reference< util::XModeChangeApproveListener >& /* _rxListener */ )
2807 : : throw (lang::NoSupportException, uno::RuntimeException)
2808 : : {
2809 : :
2810 : 0 : }
2811 : 0 : void SAL_CALL ChartView::removeModeChangeApproveListener( const uno::Reference< util::XModeChangeApproveListener >& /* _rxListener */ )
2812 : : throw (lang::NoSupportException, uno::RuntimeException)
2813 : : {
2814 : :
2815 : 0 : }
2816 : :
2817 : : // ____ XUpdatable ____
2818 : 998 : void SAL_CALL ChartView::update() throw (uno::RuntimeException)
2819 : : {
2820 : 998 : impl_updateView();
2821 : :
2822 : : //#i100778# migrate all imported or old documents to a plot area sizing exclusive axes (in case the save settings allow for this):
2823 : : //Although in general it is a bad idea to change the model from within the view this is exceptionally the best place to do this special conversion.
2824 : : //When a view update is requested (what happens for creating the metafile or displaying
2825 : : //the chart in edit mode or printing) it is most likely that all necessary informations are available - like the underlying spreadsheet data for example.
2826 : : //Those data is important for the correct axis lable sizes which are needed during conversion.
2827 [ + + ]: 998 : if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_xChartModel, true, false ) )
2828 : 8 : impl_updateView();
2829 : 998 : }
2830 : :
2831 : : // ____ XPropertySet ____
2832 : 0 : Reference< beans::XPropertySetInfo > SAL_CALL ChartView::getPropertySetInfo()
2833 : : throw (uno::RuntimeException)
2834 : : {
2835 : : OSL_FAIL("not implemented");
2836 : 0 : return 0;
2837 : : }
2838 : :
2839 : 944 : void SAL_CALL ChartView::setPropertyValue( const ::rtl::OUString& rPropertyName
2840 : : , const Any& rValue )
2841 : : throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException
2842 : : , lang::WrappedTargetException, uno::RuntimeException)
2843 : : {
2844 [ + + ]: 944 : if( rPropertyName.equals(C2U("Resolution")) )
2845 : : {
2846 : 908 : awt::Size aNewResolution;
2847 [ - + ][ + - ]: 908 : if( ! (rValue >>= aNewResolution) )
2848 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( C2U("Property 'Resolution' requires value of type awt::Size"), 0, 0 );
[ # # ]
2849 : :
2850 [ + + ][ - + ]: 908 : if( m_aPageResolution.Width!=aNewResolution.Width || m_aPageResolution.Height!=aNewResolution.Height )
2851 : : {
2852 : : //set modified only when the new resolution is higher and points were skipped before
2853 [ - + ][ # # ]: 34 : bool bSetModified = m_bPointsWereSkipped && (m_aPageResolution.Width<aNewResolution.Width || m_aPageResolution.Height<aNewResolution.Height);
[ # # ]
2854 : :
2855 : 34 : m_aPageResolution = aNewResolution;
2856 : :
2857 [ - + ]: 34 : if( bSetModified )
2858 [ # # ][ # # ]: 908 : this->modified( lang::EventObject( static_cast< uno::XWeak* >( this ) ) );
[ # # ][ # # ]
2859 : : }
2860 : : }
2861 [ + - ]: 36 : else if( rPropertyName.equals(C2U("ZoomFactors")) )
2862 : : {
2863 : : //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100%
2864 [ + - ]: 36 : uno::Sequence< beans::PropertyValue > aZoomFactors;
2865 [ + - ][ - + ]: 36 : if( ! (rValue >>= aZoomFactors) )
2866 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( C2U("Property 'ZoomFactors' requires value of type Sequence< PropertyValue >"), 0, 0 );
[ # # ]
2867 : :
2868 : 36 : sal_Int32 nFilterArgs = aZoomFactors.getLength();
2869 [ + - ]: 36 : beans::PropertyValue* pDataValues = aZoomFactors.getArray();
2870 [ + + ]: 180 : while( nFilterArgs-- )
2871 : : {
2872 [ + + ]: 144 : if ( pDataValues->Name == "ScaleXNumerator" )
2873 : 36 : pDataValues->Value >>= m_nScaleXNumerator;
2874 [ + + ]: 108 : else if ( pDataValues->Name == "ScaleXDenominator" )
2875 : 36 : pDataValues->Value >>= m_nScaleXDenominator;
2876 [ + + ]: 72 : else if ( pDataValues->Name == "ScaleYNumerator" )
2877 : 36 : pDataValues->Value >>= m_nScaleYNumerator;
2878 [ + - ]: 36 : else if ( pDataValues->Name == "ScaleYDenominator" )
2879 : 36 : pDataValues->Value >>= m_nScaleYDenominator;
2880 : :
2881 : 144 : pDataValues++;
2882 [ + - ]: 36 : }
2883 : : }
2884 [ # # ]: 0 : else if( rPropertyName.equals(C2U("SdrViewIsInEditMode")) )
2885 : : {
2886 : : //#i77362 change notification for changes on additional shapes are missing
2887 [ # # ]: 0 : if( ! (rValue >>= m_bSdrViewIsInEditMode) )
2888 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( C2U("Property 'SdrViewIsInEditMode' requires value of type sal_Bool"), 0, 0 );
[ # # ]
2889 : : }
2890 : : else
2891 [ # # ][ # # ]: 0 : throw beans::UnknownPropertyException( C2U("unknown property was tried to set to chart wizard"), 0 );
[ # # ]
2892 : 944 : }
2893 : :
2894 : 0 : Any SAL_CALL ChartView::getPropertyValue( const ::rtl::OUString& rPropertyName )
2895 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2896 : : {
2897 : 0 : Any aRet;
2898 [ # # ][ # # ]: 0 : if( rPropertyName.equals(C2U("Resolution")) )
2899 : : {
2900 [ # # ]: 0 : aRet = uno::makeAny( m_aPageResolution );
2901 : : }
2902 : : else
2903 [ # # ][ # # ]: 0 : throw beans::UnknownPropertyException( C2U("unknown property was tried to get from chart wizard"), 0 );
[ # # ]
2904 : 0 : return aRet;
2905 : : }
2906 : :
2907 : 0 : void SAL_CALL ChartView::addPropertyChangeListener(
2908 : : const ::rtl::OUString& /* aPropertyName */, const Reference< beans::XPropertyChangeListener >& /* xListener */ )
2909 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2910 : : {
2911 : : OSL_FAIL("not implemented");
2912 : 0 : }
2913 : 0 : void SAL_CALL ChartView::removePropertyChangeListener(
2914 : : const ::rtl::OUString& /* aPropertyName */, const Reference< beans::XPropertyChangeListener >& /* aListener */ )
2915 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2916 : : {
2917 : : OSL_FAIL("not implemented");
2918 : 0 : }
2919 : :
2920 : 0 : void SAL_CALL ChartView::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, const Reference< beans::XVetoableChangeListener >& /* aListener */ )
2921 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2922 : : {
2923 : : OSL_FAIL("not implemented");
2924 : 0 : }
2925 : :
2926 : 0 : void SAL_CALL ChartView::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, const Reference< beans::XVetoableChangeListener >& /* aListener */ )
2927 : : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
2928 : : {
2929 : : OSL_FAIL("not implemented");
2930 : 0 : }
2931 : :
2932 : : // ____ XMultiServiceFactory ____
2933 : :
2934 : 358 : Reference< uno::XInterface > ChartView::createInstance( const ::rtl::OUString& aServiceSpecifier )
2935 : : throw (uno::Exception, uno::RuntimeException)
2936 : : {
2937 [ + - ]: 358 : SdrModel* pModel = ( m_pDrawModelWrapper ? &m_pDrawModelWrapper->getSdrModel() : NULL );
2938 [ + - ]: 358 : if ( pModel )
2939 : : {
2940 [ + + ]: 358 : if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.DashTable" ) ) == 0 )
2941 : : {
2942 [ + + ]: 65 : if ( !m_xDashTable.is() )
2943 : : {
2944 [ + - ]: 56 : m_xDashTable = SvxUnoDashTable_createInstance( pModel );
2945 : : }
2946 : 65 : return m_xDashTable;
2947 : : }
2948 [ + + ]: 293 : else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.GradientTable" ) ) == 0 )
2949 : : {
2950 [ + + ]: 71 : if ( !m_xGradientTable.is() )
2951 : : {
2952 [ + - ]: 56 : m_xGradientTable = SvxUnoGradientTable_createInstance( pModel );
2953 : : }
2954 : 71 : return m_xGradientTable;
2955 : : }
2956 [ + + ]: 222 : else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.HatchTable" ) ) == 0 )
2957 : : {
2958 [ + + ]: 71 : if ( !m_xHatchTable.is() )
2959 : : {
2960 [ + - ]: 56 : m_xHatchTable = SvxUnoHatchTable_createInstance( pModel );
2961 : : }
2962 : 71 : return m_xHatchTable;
2963 : : }
2964 [ + + ]: 151 : else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.BitmapTable" ) ) == 0 )
2965 : : {
2966 [ + + ]: 71 : if ( !m_xBitmapTable.is() )
2967 : : {
2968 [ + - ]: 56 : m_xBitmapTable = SvxUnoBitmapTable_createInstance( pModel );
2969 : : }
2970 : 71 : return m_xBitmapTable;
2971 : : }
2972 [ + + ]: 80 : else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) ) == 0 )
2973 : : {
2974 [ + + ]: 71 : if ( !m_xTransGradientTable.is() )
2975 : : {
2976 [ + - ]: 56 : m_xTransGradientTable = SvxUnoTransGradientTable_createInstance( pModel );
2977 : : }
2978 : 71 : return m_xTransGradientTable;
2979 : : }
2980 [ + - ]: 9 : else if ( aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.MarkerTable" ) ) == 0 )
2981 : : {
2982 [ + + ]: 9 : if ( !m_xMarkerTable.is() )
2983 : : {
2984 [ + - ]: 7 : m_xMarkerTable = SvxUnoMarkerTable_createInstance( pModel );
2985 : : }
2986 : 9 : return m_xMarkerTable;
2987 : : }
2988 : : }
2989 : :
2990 : 358 : return 0;
2991 : : }
2992 : :
2993 : 0 : Reference< uno::XInterface > ChartView::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments )
2994 : : throw (uno::Exception, uno::RuntimeException)
2995 : : {
2996 : : OSL_ENSURE( Arguments.getLength(), "ChartView::createInstanceWithArguments: arguments are ignored" );
2997 : : (void) Arguments; // avoid warning
2998 : 0 : return createInstance( ServiceSpecifier );
2999 : : }
3000 : :
3001 : 0 : uno::Sequence< ::rtl::OUString > ChartView::getAvailableServiceNames() throw (uno::RuntimeException)
3002 : : {
3003 : 0 : uno::Sequence< ::rtl::OUString > aServiceNames( 6 );
3004 : :
3005 [ # # ][ # # ]: 0 : aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) );
3006 [ # # ][ # # ]: 0 : aServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) );
3007 [ # # ][ # # ]: 0 : aServiceNames[2] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) );
3008 [ # # ][ # # ]: 0 : aServiceNames[3] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) );
3009 [ # # ][ # # ]: 0 : aServiceNames[4] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TransparencyGradientTable" ) );
3010 [ # # ][ # # ]: 0 : aServiceNames[5] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MarkerTable" ) );
3011 : :
3012 : 0 : return aServiceNames;
3013 : : }
3014 : :
3015 : : /* ----------------------
3016 : : goes to drawinglayer/XShapeDumper.cxx
3017 : : ----------------------
3018 : : namespace {
3019 : :
3020 : : #define DEBUG_DUMPER 0
3021 : :
3022 : : int writeCallback(void* pContext, const char* sBuffer, int nLen)
3023 : : {
3024 : : rtl::OStringBuffer* pBuffer = static_cast<rtl::OStringBuffer*>(pContext);
3025 : : pBuffer->append(sBuffer);
3026 : : return nLen;
3027 : : }
3028 : :
3029 : : int closeCallback(void* )
3030 : : {
3031 : : return 0;
3032 : : }
3033 : :
3034 : : void dumpPositionAsAttribute(const awt::Point& rPoint, xmlTextWriterPtr xmlWriter)
3035 : : {
3036 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionX"), "%" SAL_PRIdINT32, rPoint.X);
3037 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionY"), "%" SAL_PRIdINT32, rPoint.Y);
3038 : : }
3039 : :
3040 : : void dumpSizeAsAttribute(const awt::Size& rSize, xmlTextWriterPtr xmlWriter)
3041 : : {
3042 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("sizeX"), "%" SAL_PRIdINT32, rSize.Width);
3043 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("sizeY"), "%" SAL_PRIdINT32, rSize.Height);
3044 : : }
3045 : :
3046 : : void dumpShapeDescriptorAsAttribute( uno::Reference< drawing::XShapeDescriptor > xDescr, xmlTextWriterPtr xmlWriter )
3047 : : {
3048 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("type"), "%s", rtl::OUStringToOString(xDescr->getShapeType(), RTL_TEXTENCODING_UTF8).getStr());
3049 : : }
3050 : :
3051 : : void dumpXShapes( uno::Reference< drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter );
3052 : :
3053 : : void dumpXShape( uno::Reference< drawing::XShape > xShape, xmlTextWriterPtr xmlWriter )
3054 : : {
3055 : : xmlTextWriterStartElement( xmlWriter, BAD_CAST( "XShape" ) );
3056 : :
3057 : : dumpPositionAsAttribute(xShape->getPosition(), xmlWriter);
3058 : : dumpSizeAsAttribute(xShape->getSize(), xmlWriter);
3059 : : uno::Reference< drawing::XShapeDescriptor > xDescr(xShape, uno::UNO_QUERY_THROW);
3060 : : dumpShapeDescriptorAsAttribute(xDescr, xmlWriter);
3061 : :
3062 : : uno::Reference< lang::XServiceInfo > xServiceInfo( xShape, uno::UNO_QUERY_THROW );
3063 : : uno::Sequence< rtl::OUString > aServiceNames = xServiceInfo->getSupportedServiceNames();
3064 : :
3065 : : uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY_THROW);
3066 : : uno::Any aAny = xPropSet->getPropertyValue("Name");
3067 : : rtl::OUString aName;
3068 : : if (aAny >>= aName)
3069 : : {
3070 : : if (!aName.isEmpty())
3071 : : xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("name"), "%s", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr());
3072 : : }
3073 : : if (xServiceInfo->supportsService("com.sun.star.drawing.Text"))
3074 : : {
3075 : : uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY_THROW);
3076 : : rtl::OUString aText = xText->getString();
3077 : : if(!aText.isEmpty())
3078 : : xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("text"), "%s", rtl::OUStringToOString(aText, RTL_TEXTENCODING_UTF8).getStr());
3079 : : }
3080 : : else if(xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"))
3081 : : {
3082 : : uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY_THROW);
3083 : : dumpXShapes(xShapes, xmlWriter);
3084 : : }
3085 : : #if DEBUG_DUMPER
3086 : : sal_Int32 nServices = aServiceNames.getLength();
3087 : : for (sal_Int32 i = 0; i < nServices; ++i)
3088 : : {
3089 : : xmlTextWriterStartElement(xmlWriter, BAD_CAST( "ServiceName" ));
3090 : : xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST( "name" ), "%s", rtl::OUStringToOString(aServiceNames[i], RTL_TEXTENCODING_UTF8).getStr());
3091 : : xmlTextWriterEndElement( xmlWriter );
3092 : : }
3093 : : #endif
3094 : :
3095 : : xmlTextWriterEndElement( xmlWriter );
3096 : : }
3097 : :
3098 : : void dumpXShapes( uno::Reference< drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter )
3099 : : {
3100 : : xmlTextWriterStartElement( xmlWriter, BAD_CAST( "XShapes" ) );
3101 : : uno::Reference< container::XIndexAccess > xIA( xShapes, uno::UNO_QUERY_THROW);
3102 : : sal_Int32 nLength = xIA->getCount();
3103 : : for (sal_Int32 i = 0; i < nLength; ++i)
3104 : : {
3105 : : uno::Reference< drawing::XShape > xShape( xIA->getByIndex( i ), uno::UNO_QUERY_THROW );
3106 : : dumpXShape( xShape, xmlWriter );
3107 : : }
3108 : :
3109 : : xmlTextWriterEndElement( xmlWriter );
3110 : : }
3111 : :
3112 : : }
3113 : : */
3114 : :
3115 : 0 : rtl::OUString ChartView::dump() throw (uno::RuntimeException)
3116 : : {
3117 [ # # ]: 0 : impl_updateView();
3118 : : uno::Reference<drawing::XShapes> xPageShapes( ShapeFactory(m_xShapeFactory)
3119 [ # # ][ # # ]: 0 : .getOrCreateChartRootShape( m_xDrawPage ) );
[ # # ]
3120 : :
3121 [ # # ]: 0 : if (!xPageShapes.is())
3122 : 0 : return rtl::OUString();
3123 : : else
3124 : : {
3125 [ # # ]: 0 : XShapeDumper dumper;
3126 [ # # ]: 0 : return dumper.dump(xPageShapes);
3127 : 0 : }
3128 : :
3129 : : }
3130 : :
3131 : : //.............................................................................
3132 [ + - ][ + - ]: 48 : } //namespace chart
3133 : : //.............................................................................
3134 : :
3135 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|