1cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5cde9e8dcSAndrew Rist  * distributed with this work for additional information
6cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cde9e8dcSAndrew Rist  *
11cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cde9e8dcSAndrew Rist  *
13cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18cde9e8dcSAndrew Rist  * under the License.
19cde9e8dcSAndrew Rist  *
20cde9e8dcSAndrew Rist  *************************************************************/
21cde9e8dcSAndrew Rist 
22cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir #include "ChartController.hxx"
27cdf0e10cSrcweir #include "ChartWindow.hxx"
28cdf0e10cSrcweir #include "chartview/DrawModelWrapper.hxx"
29cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
30cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx"
31cdf0e10cSrcweir #include "macros.hxx"
32cdf0e10cSrcweir #include "dlg_ObjectProperties.hxx"
33cdf0e10cSrcweir #include "dlg_View3D.hxx"
34cdf0e10cSrcweir #include "dlg_InsertErrorBars.hxx"
35cdf0e10cSrcweir #include "ViewElementListProvider.hxx"
36cdf0e10cSrcweir #include "DataPointItemConverter.hxx"
37cdf0e10cSrcweir #include "AxisItemConverter.hxx"
38cdf0e10cSrcweir #include "MultipleChartConverters.hxx"
39cdf0e10cSrcweir #include "TitleItemConverter.hxx"
40cdf0e10cSrcweir #include "LegendItemConverter.hxx"
41cdf0e10cSrcweir #include "RegressionCurveItemConverter.hxx"
42cdf0e10cSrcweir #include "RegressionEquationItemConverter.hxx"
43cdf0e10cSrcweir #include "ErrorBarItemConverter.hxx"
44cdf0e10cSrcweir #include "ChartModelHelper.hxx"
45cdf0e10cSrcweir #include "AxisHelper.hxx"
46cdf0e10cSrcweir #include "TitleHelper.hxx"
47cdf0e10cSrcweir #include "LegendHelper.hxx"
48cdf0e10cSrcweir #include "ChartTypeHelper.hxx"
49cdf0e10cSrcweir #include "ColorPerPointHelper.hxx"
50cdf0e10cSrcweir #include "DiagramHelper.hxx"
51cdf0e10cSrcweir #include "servicenames_charttypes.hxx"
52cdf0e10cSrcweir #include "ControllerLockGuard.hxx"
53cdf0e10cSrcweir #include "UndoGuard.hxx"
54cdf0e10cSrcweir #include "ObjectNameProvider.hxx"
55cdf0e10cSrcweir #include "ResId.hxx"
56cdf0e10cSrcweir #include "Strings.hrc"
57cdf0e10cSrcweir #include "ReferenceSizeProvider.hxx"
58cdf0e10cSrcweir #include "RegressionCurveHelper.hxx"
59cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //for auto_ptr
62cdf0e10cSrcweir #include <memory>
63cdf0e10cSrcweir 
64cdf0e10cSrcweir // header for define RET_OK
65cdf0e10cSrcweir #include <vcl/msgbox.hxx>
66cdf0e10cSrcweir // for SolarMutex
67cdf0e10cSrcweir #include <vcl/svapp.hxx>
68cdf0e10cSrcweir #include <vos/mutex.hxx>
69cdf0e10cSrcweir #include <svx/ActionDescriptionProvider.hxx>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir //.............................................................................
72cdf0e10cSrcweir namespace chart
73cdf0e10cSrcweir {
74cdf0e10cSrcweir //.............................................................................
75cdf0e10cSrcweir using namespace ::com::sun::star;
76cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
77cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
78cdf0e10cSrcweir using ::rtl::OUString;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir namespace
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 
createItemConverter(const::rtl::OUString & aObjectCID,const uno::Reference<frame::XModel> & xChartModel,const uno::Reference<uno::XComponentContext> & xContext,SdrModel & rDrawModel,NumberFormatterWrapper * pNumberFormatterWrapper=NULL,ExplicitValueProvider * pExplicitValueProvider=NULL,::std::auto_ptr<ReferenceSizeProvider> pRefSizeProvider=::std::auto_ptr<ReferenceSizeProvider> ())83cdf0e10cSrcweir ::comphelper::ItemConverter* createItemConverter(
84cdf0e10cSrcweir     const ::rtl::OUString & aObjectCID
85cdf0e10cSrcweir     , const uno::Reference< frame::XModel > & xChartModel
86cdf0e10cSrcweir     , const uno::Reference< uno::XComponentContext > & xContext
87cdf0e10cSrcweir     , SdrModel & rDrawModel
88cdf0e10cSrcweir     , NumberFormatterWrapper * pNumberFormatterWrapper = NULL
89cdf0e10cSrcweir     , ExplicitValueProvider * pExplicitValueProvider = NULL
90cdf0e10cSrcweir     , ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProvider =
91cdf0e10cSrcweir           ::std::auto_ptr< ReferenceSizeProvider >()
92cdf0e10cSrcweir     )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     ::comphelper::ItemConverter* pItemConverter=NULL;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     //-------------------------------------------------------------
97cdf0e10cSrcweir     //get type of selected object
98cdf0e10cSrcweir     ObjectType eObjectType = ObjectIdentifier::getObjectType( aObjectCID );
99cdf0e10cSrcweir     if( OBJECTTYPE_UNKNOWN==eObjectType )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         DBG_ERROR("unknown ObjectType");
102cdf0e10cSrcweir         return NULL;
103cdf0e10cSrcweir     }
104cdf0e10cSrcweir     //--
105cdf0e10cSrcweir     rtl::OUString aParticleID = ObjectIdentifier::getParticleID( aObjectCID );
106cdf0e10cSrcweir     bool bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS"));
107cdf0e10cSrcweir     //-------------------------------------------------------------
108cdf0e10cSrcweir     if( !bAffectsMultipleObjects )
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir         uno::Reference< beans::XPropertySet > xObjectProperties =
111cdf0e10cSrcweir             ObjectIdentifier::getObjectPropertySet( aObjectCID, xChartModel );
112cdf0e10cSrcweir         if(!xObjectProperties.is())
113cdf0e10cSrcweir             return NULL;
114cdf0e10cSrcweir         //create itemconverter for a single object
115cdf0e10cSrcweir         switch(eObjectType)
116cdf0e10cSrcweir         {
117cdf0e10cSrcweir             case OBJECTTYPE_PAGE:
118cdf0e10cSrcweir                 pItemConverter =  new wrapper::GraphicPropertyItemConverter(
119cdf0e10cSrcweir                                         xObjectProperties, rDrawModel.GetItemPool(),
120cdf0e10cSrcweir                                         rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
121cdf0e10cSrcweir                                         wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
122cdf0e10cSrcweir                     break;
123cdf0e10cSrcweir             case OBJECTTYPE_TITLE:
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
126cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
127cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
128cdf0e10cSrcweir 
129cdf0e10cSrcweir                 pItemConverter = new wrapper::TitleItemConverter( xObjectProperties,
130cdf0e10cSrcweir                                                                   rDrawModel.GetItemPool(), rDrawModel,
131cdf0e10cSrcweir                                                                   uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
132cdf0e10cSrcweir                                                                   pRefSize );
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir             break;
135cdf0e10cSrcweir             case OBJECTTYPE_LEGEND:
136cdf0e10cSrcweir             {
137cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
138cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
139cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
140cdf0e10cSrcweir 
141cdf0e10cSrcweir                 pItemConverter = new wrapper::LegendItemConverter( xObjectProperties,
142cdf0e10cSrcweir                                                                    rDrawModel.GetItemPool(), rDrawModel,
143cdf0e10cSrcweir                                                                    uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
144cdf0e10cSrcweir                                                                    pRefSize );
145cdf0e10cSrcweir             }
146cdf0e10cSrcweir             break;
147cdf0e10cSrcweir             case OBJECTTYPE_LEGEND_ENTRY:
148cdf0e10cSrcweir                     break;
149cdf0e10cSrcweir             case OBJECTTYPE_DIAGRAM:
150cdf0e10cSrcweir                     break;
151cdf0e10cSrcweir             case OBJECTTYPE_DIAGRAM_WALL:
152cdf0e10cSrcweir             case OBJECTTYPE_DIAGRAM_FLOOR:
153cdf0e10cSrcweir                 pItemConverter =  new wrapper::GraphicPropertyItemConverter(
154cdf0e10cSrcweir                                         xObjectProperties, rDrawModel.GetItemPool(),
155cdf0e10cSrcweir                                         rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
156cdf0e10cSrcweir                                         wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
157cdf0e10cSrcweir                     break;
158cdf0e10cSrcweir             case OBJECTTYPE_AXIS:
159cdf0e10cSrcweir             {
160cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
161cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
162cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
163cdf0e10cSrcweir 
164cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xDiaProp;
165cdf0e10cSrcweir                 xDiaProp.set( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY );
166cdf0e10cSrcweir 
167cdf0e10cSrcweir                 // the second property set contains the property CoordinateOrigin
168cdf0e10cSrcweir                 // nOriginIndex is the index of the corresponding index of the
169cdf0e10cSrcweir                 // origin (x=0, y=1, z=2)
170cdf0e10cSrcweir 
171cdf0e10cSrcweir                 ExplicitScaleData aExplicitScale;
172cdf0e10cSrcweir                 ExplicitIncrementData aExplicitIncrement;
173cdf0e10cSrcweir                 if( pExplicitValueProvider )
174cdf0e10cSrcweir                     pExplicitValueProvider->getExplicitValuesForAxis(
175cdf0e10cSrcweir                         uno::Reference< XAxis >( xObjectProperties, uno::UNO_QUERY ),
176cdf0e10cSrcweir                         aExplicitScale, aExplicitIncrement );
177cdf0e10cSrcweir 
178cdf0e10cSrcweir                 pItemConverter =  new wrapper::AxisItemConverter(
179cdf0e10cSrcweir                     xObjectProperties, rDrawModel.GetItemPool(),
180cdf0e10cSrcweir                     rDrawModel,
181cdf0e10cSrcweir                     uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ),
182cdf0e10cSrcweir                     &aExplicitScale, &aExplicitIncrement,
183cdf0e10cSrcweir                     pRefSize );
184cdf0e10cSrcweir             }
185cdf0e10cSrcweir             break;
186cdf0e10cSrcweir             case OBJECTTYPE_AXIS_UNITLABEL:
187cdf0e10cSrcweir                     break;
188cdf0e10cSrcweir             case OBJECTTYPE_DATA_LABELS:
189cdf0e10cSrcweir             case OBJECTTYPE_DATA_SERIES:
190cdf0e10cSrcweir             case OBJECTTYPE_DATA_LABEL:
191cdf0e10cSrcweir             case OBJECTTYPE_DATA_POINT:
192cdf0e10cSrcweir             {
193cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
194cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
195cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
196cdf0e10cSrcweir 
197cdf0e10cSrcweir                 wrapper::GraphicPropertyItemConverter::eGraphicObjectType eMapTo =
198cdf0e10cSrcweir                     wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir                 uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel );
201cdf0e10cSrcweir 	            uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir                 uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
204cdf0e10cSrcweir                 sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram );
205cdf0e10cSrcweir                 if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ) )
206cdf0e10cSrcweir                     eMapTo = wrapper::GraphicPropertyItemConverter::LINE_DATA_POINT;
207cdf0e10cSrcweir                 /*
208cdf0e10cSrcweir                 FILLED_DATA_POINT,
209cdf0e10cSrcweir                 LINE_DATA_POINT,
210cdf0e10cSrcweir                 LINE_PROPERTIES,
211cdf0e10cSrcweir                 FILL_PROPERTIES,
212cdf0e10cSrcweir                 LINE_AND_FILL_PROPERTIES
213cdf0e10cSrcweir                 */
214cdf0e10cSrcweir                 bool bDataSeries = ( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_LABELS );
215cdf0e10cSrcweir 
216cdf0e10cSrcweir                 //special color for pie chart:
217cdf0e10cSrcweir                 bool bUseSpecialFillColor = false;
218cdf0e10cSrcweir                 sal_Int32 nSpecialFillColor =0;
219cdf0e10cSrcweir                 sal_Int32 nPointIndex = -1; /*-1 for whole series*/
220cdf0e10cSrcweir                 if(!bDataSeries)
221cdf0e10cSrcweir                 {
222cdf0e10cSrcweir                     nPointIndex = aParticleID.toInt32();
223cdf0e10cSrcweir                     uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY );
224cdf0e10cSrcweir                     bool bVaryColorsByPoint = false;
225cdf0e10cSrcweir                     if( xSeriesProp.is() &&
226cdf0e10cSrcweir                         (xSeriesProp->getPropertyValue(C2U("VaryColorsByPoint")) >>= bVaryColorsByPoint) &&
227cdf0e10cSrcweir                         bVaryColorsByPoint )
228cdf0e10cSrcweir                     {
229cdf0e10cSrcweir                         if( !ColorPerPointHelper::hasPointOwnColor( xSeriesProp, nPointIndex, xObjectProperties ) )
230cdf0e10cSrcweir                         {
231cdf0e10cSrcweir                             bUseSpecialFillColor = true;
232cdf0e10cSrcweir                             OSL_ASSERT( xDiagram.is());
233cdf0e10cSrcweir                             uno::Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() );
234cdf0e10cSrcweir                             if( xColorScheme.is())
235cdf0e10cSrcweir                                 nSpecialFillColor = xColorScheme->getColorByIndex( nPointIndex );
236cdf0e10cSrcweir                         }
237cdf0e10cSrcweir                     }
238cdf0e10cSrcweir                 }
239cdf0e10cSrcweir                 sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, xSeries, nPointIndex, xDiagram );
240cdf0e10cSrcweir                 sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel(
241cdf0e10cSrcweir                         xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY));
242cdf0e10cSrcweir 
243cdf0e10cSrcweir                 pItemConverter =  new wrapper::DataPointItemConverter( xChartModel, xContext,
244cdf0e10cSrcweir                                         xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel,
245cdf0e10cSrcweir                                         pNumberFormatterWrapper,
246cdf0e10cSrcweir                                         uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
247cdf0e10cSrcweir                                         eMapTo, pRefSize, bDataSeries, bUseSpecialFillColor, nSpecialFillColor, false,
248cdf0e10cSrcweir                                         nNumberFormat, nPercentNumberFormat );
249cdf0e10cSrcweir                     break;
250cdf0e10cSrcweir             }
251cdf0e10cSrcweir             case OBJECTTYPE_GRID:
252cdf0e10cSrcweir             case OBJECTTYPE_SUBGRID:
253cdf0e10cSrcweir             case OBJECTTYPE_DATA_AVERAGE_LINE:
254cdf0e10cSrcweir                 pItemConverter =  new wrapper::GraphicPropertyItemConverter(
255cdf0e10cSrcweir                                         xObjectProperties, rDrawModel.GetItemPool(),
256cdf0e10cSrcweir                                         rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
257cdf0e10cSrcweir                                         wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES );
258cdf0e10cSrcweir                     break;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir             case OBJECTTYPE_DATA_ERRORS:
261cdf0e10cSrcweir                 pItemConverter =  new wrapper::ErrorBarItemConverter(
262cdf0e10cSrcweir                     xChartModel, xObjectProperties, rDrawModel.GetItemPool(),
263cdf0e10cSrcweir                     rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ));
264cdf0e10cSrcweir                 break;
265cdf0e10cSrcweir 
266cdf0e10cSrcweir             case OBJECTTYPE_DATA_CURVE:
267cdf0e10cSrcweir                 pItemConverter =  new wrapper::RegressionCurveItemConverter(
268cdf0e10cSrcweir                     xObjectProperties, uno::Reference< chart2::XRegressionCurveContainer >(
269cdf0e10cSrcweir                         ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ), uno::UNO_QUERY ),
270cdf0e10cSrcweir                     rDrawModel.GetItemPool(), rDrawModel,
271cdf0e10cSrcweir                     uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ));
272cdf0e10cSrcweir                 break;
273cdf0e10cSrcweir             case OBJECTTYPE_DATA_CURVE_EQUATION:
274cdf0e10cSrcweir             {
275cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
276cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
277cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
278cdf0e10cSrcweir 
279cdf0e10cSrcweir                 pItemConverter =  new wrapper::RegressionEquationItemConverter(
280cdf0e10cSrcweir                                         xObjectProperties, rDrawModel.GetItemPool(), rDrawModel,
281cdf0e10cSrcweir                                         uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
282cdf0e10cSrcweir                                         pRefSize );
283cdf0e10cSrcweir                     break;
284cdf0e10cSrcweir             }
285cdf0e10cSrcweir             case OBJECTTYPE_DATA_ERRORS_X:
286cdf0e10cSrcweir                     break;
287cdf0e10cSrcweir             case OBJECTTYPE_DATA_ERRORS_Y:
288cdf0e10cSrcweir                     break;
289cdf0e10cSrcweir             case OBJECTTYPE_DATA_ERRORS_Z:
290cdf0e10cSrcweir                     break;
291cdf0e10cSrcweir             case OBJECTTYPE_DATA_STOCK_RANGE:
292cdf0e10cSrcweir                     break;
293cdf0e10cSrcweir             case OBJECTTYPE_DATA_STOCK_LOSS:
294cdf0e10cSrcweir             case OBJECTTYPE_DATA_STOCK_GAIN:
295cdf0e10cSrcweir                 pItemConverter =  new wrapper::GraphicPropertyItemConverter(
296cdf0e10cSrcweir                                         xObjectProperties, rDrawModel.GetItemPool(),
297cdf0e10cSrcweir                                         rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ),
298cdf0e10cSrcweir                                         wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
299cdf0e10cSrcweir                     break;
300cdf0e10cSrcweir             default: //OBJECTTYPE_UNKNOWN
301cdf0e10cSrcweir                     break;
302cdf0e10cSrcweir         }
303cdf0e10cSrcweir     }
304cdf0e10cSrcweir     else
305cdf0e10cSrcweir     {
306cdf0e10cSrcweir         //create itemconverter for a all objects of given type
307cdf0e10cSrcweir         switch(eObjectType)
308cdf0e10cSrcweir         {
309cdf0e10cSrcweir             case OBJECTTYPE_TITLE:
310cdf0e10cSrcweir                 pItemConverter =  new wrapper::AllTitleItemConverter( xChartModel, rDrawModel.GetItemPool(),
311cdf0e10cSrcweir                                                                      rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ));
312cdf0e10cSrcweir                 break;
313cdf0e10cSrcweir             case OBJECTTYPE_AXIS:
314cdf0e10cSrcweir             {
315cdf0e10cSrcweir                 ::std::auto_ptr< awt::Size > pRefSize;
316cdf0e10cSrcweir                 if( pRefSizeProvider.get() )
317cdf0e10cSrcweir                     pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize()));
318cdf0e10cSrcweir 
319cdf0e10cSrcweir                 pItemConverter =  new wrapper::AllAxisItemConverter( xChartModel, rDrawModel.GetItemPool(),
320cdf0e10cSrcweir                                                                      rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), pRefSize );
321cdf0e10cSrcweir             }
322cdf0e10cSrcweir             break;
323cdf0e10cSrcweir             case OBJECTTYPE_GRID:
324cdf0e10cSrcweir             case OBJECTTYPE_SUBGRID:
325cdf0e10cSrcweir                 pItemConverter =  new wrapper::AllGridItemConverter( xChartModel, rDrawModel.GetItemPool(),
326cdf0e10cSrcweir                                                                      rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ));
327cdf0e10cSrcweir                 break;
328cdf0e10cSrcweir             default: //for this type it is not supported to change all elements at once
329cdf0e10cSrcweir                 break;
330cdf0e10cSrcweir         }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     }
333cdf0e10cSrcweir     return pItemConverter;
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
lcl_getTitleCIDForCommand(const::rtl::OString & rDispatchCommand,const uno::Reference<frame::XModel> & xChartModel)336cdf0e10cSrcweir rtl::OUString lcl_getTitleCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel > & xChartModel )
337cdf0e10cSrcweir {
338cdf0e10cSrcweir     if( rDispatchCommand.equals("AllTitles"))
339cdf0e10cSrcweir         return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, C2U("ALLELEMENTS") );
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     TitleHelper::eTitleType nTitleType( TitleHelper::MAIN_TITLE );
342cdf0e10cSrcweir     if( rDispatchCommand.equals("SubTitle") )
343cdf0e10cSrcweir         nTitleType = TitleHelper::SUB_TITLE;
344cdf0e10cSrcweir     else if( rDispatchCommand.equals("XTitle") )
345cdf0e10cSrcweir         nTitleType = TitleHelper::X_AXIS_TITLE;
346cdf0e10cSrcweir     else if( rDispatchCommand.equals("YTitle") )
347cdf0e10cSrcweir         nTitleType = TitleHelper::Y_AXIS_TITLE;
348cdf0e10cSrcweir     else if( rDispatchCommand.equals("ZTitle") )
349cdf0e10cSrcweir         nTitleType = TitleHelper::Z_AXIS_TITLE;
350cdf0e10cSrcweir     else if( rDispatchCommand.equals("SecondaryXTitle") )
351cdf0e10cSrcweir         nTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE;
352cdf0e10cSrcweir     else if( rDispatchCommand.equals("SecondaryYTitle") )
353cdf0e10cSrcweir         nTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir     uno::Reference< XTitle > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) );
356cdf0e10cSrcweir     return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
lcl_getAxisCIDForCommand(const::rtl::OString & rDispatchCommand,const uno::Reference<frame::XModel> & xChartModel)359cdf0e10cSrcweir rtl::OUString lcl_getAxisCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir     if( rDispatchCommand.equals("DiagramAxisAll"))
362cdf0e10cSrcweir         return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS, C2U("ALLELEMENTS") );
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     sal_Int32   nDimensionIndex=0;
365cdf0e10cSrcweir     bool        bMainAxis=true;
366cdf0e10cSrcweir     if( rDispatchCommand.equals("DiagramAxisX"))
367cdf0e10cSrcweir     {
368cdf0e10cSrcweir         nDimensionIndex=0; bMainAxis=true;
369cdf0e10cSrcweir     }
370cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramAxisY"))
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         nDimensionIndex=1; bMainAxis=true;
373cdf0e10cSrcweir     }
374cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramAxisZ"))
375cdf0e10cSrcweir     {
376cdf0e10cSrcweir         nDimensionIndex=2; bMainAxis=true;
377cdf0e10cSrcweir     }
378cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramAxisA"))
379cdf0e10cSrcweir     {
380cdf0e10cSrcweir         nDimensionIndex=0; bMainAxis=false;
381cdf0e10cSrcweir     }
382cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramAxisB"))
383cdf0e10cSrcweir     {
384cdf0e10cSrcweir         nDimensionIndex=1; bMainAxis=false;
385cdf0e10cSrcweir     }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir     uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
388cdf0e10cSrcweir     uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) );
389cdf0e10cSrcweir     return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel );
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
lcl_getGridCIDForCommand(const::rtl::OString & rDispatchCommand,const uno::Reference<frame::XModel> & xChartModel)392cdf0e10cSrcweir rtl::OUString lcl_getGridCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir     if( rDispatchCommand.equals("DiagramGridAll"))
397cdf0e10cSrcweir         return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, C2U("ALLELEMENTS") );
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     sal_Int32   nDimensionIndex=0;
400cdf0e10cSrcweir     bool        bMainGrid=true;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir     //x and y is swapped in the commands
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     if( rDispatchCommand.equals("DiagramGridYMain"))
405cdf0e10cSrcweir     {
406cdf0e10cSrcweir         nDimensionIndex=0; bMainGrid=true;
407cdf0e10cSrcweir     }
408cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridXMain"))
409cdf0e10cSrcweir     {
410cdf0e10cSrcweir         nDimensionIndex=1; bMainGrid=true;
411cdf0e10cSrcweir     }
412cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridZMain"))
413cdf0e10cSrcweir     {
414cdf0e10cSrcweir         nDimensionIndex=2; bMainGrid=true;
415cdf0e10cSrcweir     }
416cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridYHelp"))
417cdf0e10cSrcweir     {
418cdf0e10cSrcweir         nDimensionIndex=0; bMainGrid=false;
419cdf0e10cSrcweir     }
420cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridXHelp"))
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         nDimensionIndex=1; bMainGrid=false;
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridZHelp"))
425cdf0e10cSrcweir     {
426cdf0e10cSrcweir         nDimensionIndex=2; bMainGrid=false;
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     bool bMainAxis = true;
430cdf0e10cSrcweir     uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     sal_Int32   nSubGridIndex= bMainGrid ? (-1) : 0;
433cdf0e10cSrcweir     rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGridIndex ) );
434cdf0e10cSrcweir     return aCID;
435cdf0e10cSrcweir }
lcl_getObjectCIDForCommand(const::rtl::OString & rDispatchCommand,const uno::Reference<XChartDocument> & xChartDocument,const rtl::OUString & rSelectedCID)436cdf0e10cSrcweir rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const rtl::OUString& rSelectedCID )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     ObjectType eObjectType = OBJECTTYPE_UNKNOWN;
439cdf0e10cSrcweir     rtl::OUString aParticleID;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     uno::Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY );
442cdf0e10cSrcweir     const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID );
443cdf0e10cSrcweir     uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel );
444cdf0e10cSrcweir     uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir     //-------------------------------------------------------------------------
447cdf0e10cSrcweir     //legend
448cdf0e10cSrcweir     if( rDispatchCommand.equals("Legend") || rDispatchCommand.equals("FormatLegend") )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         eObjectType = OBJECTTYPE_LEGEND;
451cdf0e10cSrcweir         //@todo set particular aParticleID if we have more than one legend
452cdf0e10cSrcweir     }
453cdf0e10cSrcweir     //-------------------------------------------------------------------------
454cdf0e10cSrcweir     //wall floor area
455cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramWall") || rDispatchCommand.equals("FormatWall") )
456cdf0e10cSrcweir     {
457cdf0e10cSrcweir         //OBJECTTYPE_DIAGRAM;
458cdf0e10cSrcweir         eObjectType = OBJECTTYPE_DIAGRAM_WALL;
459cdf0e10cSrcweir         //@todo set particular aParticleID if we have more than one diagram
460cdf0e10cSrcweir     }
461cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramFloor") || rDispatchCommand.equals("FormatFloor") )
462cdf0e10cSrcweir     {
463cdf0e10cSrcweir         eObjectType = OBJECTTYPE_DIAGRAM_FLOOR;
464cdf0e10cSrcweir         //@todo set particular aParticleID if we have more than one diagram
465cdf0e10cSrcweir     }
466cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramArea") || rDispatchCommand.equals("FormatChartArea") )
467cdf0e10cSrcweir     {
468cdf0e10cSrcweir         eObjectType = OBJECTTYPE_PAGE;
469cdf0e10cSrcweir     }
470cdf0e10cSrcweir     //-------------------------------------------------------------------------
471cdf0e10cSrcweir     //title
472cdf0e10cSrcweir     else if( rDispatchCommand.equals("MainTitle")
473cdf0e10cSrcweir         || rDispatchCommand.equals("SubTitle")
474cdf0e10cSrcweir         || rDispatchCommand.equals("XTitle")
475cdf0e10cSrcweir         || rDispatchCommand.equals("YTitle")
476cdf0e10cSrcweir         || rDispatchCommand.equals("ZTitle")
477cdf0e10cSrcweir         || rDispatchCommand.equals("SecondaryXTitle")
478cdf0e10cSrcweir         || rDispatchCommand.equals("SecondaryYTitle")
479cdf0e10cSrcweir         || rDispatchCommand.equals("AllTitles")
480cdf0e10cSrcweir         )
481cdf0e10cSrcweir     {
482cdf0e10cSrcweir         return lcl_getTitleCIDForCommand( rDispatchCommand, xChartModel );
483cdf0e10cSrcweir     }
484cdf0e10cSrcweir     //-------------------------------------------------------------------------
485cdf0e10cSrcweir     //axis
486cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramAxisX")
487cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramAxisY")
488cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramAxisZ")
489cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramAxisA")
490cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramAxisB")
491cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramAxisAll")
492cdf0e10cSrcweir         )
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir         return lcl_getAxisCIDForCommand( rDispatchCommand, xChartModel );
495cdf0e10cSrcweir     }
496cdf0e10cSrcweir     //-------------------------------------------------------------------------
497cdf0e10cSrcweir     //grid
498cdf0e10cSrcweir     else if( rDispatchCommand.equals("DiagramGridYMain")
499cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridXMain")
500cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridZMain")
501cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridYHelp")
502cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridXHelp")
503cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridZHelp")
504cdf0e10cSrcweir         || rDispatchCommand.equals("DiagramGridAll")
505cdf0e10cSrcweir         )
506cdf0e10cSrcweir     {
507cdf0e10cSrcweir         return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel );
508cdf0e10cSrcweir     }
509cdf0e10cSrcweir     //-------------------------------------------------------------------------
510cdf0e10cSrcweir     //data series
511cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatDataSeries") )
512cdf0e10cSrcweir     {
513cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_SERIES )
514cdf0e10cSrcweir             return rSelectedCID;
515cdf0e10cSrcweir         else
516cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifier(
517cdf0e10cSrcweir                 OBJECTTYPE_DATA_SERIES, ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ) );
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir     //-------------------------------------------------------------------------
520cdf0e10cSrcweir     //data point
521cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatDataPoint") )
522cdf0e10cSrcweir     {
523cdf0e10cSrcweir         return rSelectedCID;
524cdf0e10cSrcweir     }
525cdf0e10cSrcweir     //-------------------------------------------------------------------------
526cdf0e10cSrcweir     //data labels
527cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatDataLabels") )
528cdf0e10cSrcweir     {
529cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_LABELS )
530cdf0e10cSrcweir             return rSelectedCID;
531cdf0e10cSrcweir         else
532cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifierWithParent(
533cdf0e10cSrcweir                 OBJECTTYPE_DATA_LABELS, ::rtl::OUString(), rSelectedCID );
534cdf0e10cSrcweir     }
535cdf0e10cSrcweir     //-------------------------------------------------------------------------
536cdf0e10cSrcweir     //data labels
537cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatDataLabel") )
538cdf0e10cSrcweir     {
539cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_LABEL )
540cdf0e10cSrcweir             return rSelectedCID;
541cdf0e10cSrcweir         else
542cdf0e10cSrcweir         {
543cdf0e10cSrcweir             sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32();
544cdf0e10cSrcweir             if( nPointIndex>=0 )
545cdf0e10cSrcweir             {
546cdf0e10cSrcweir                 OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID );
547cdf0e10cSrcweir                 OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) );
548cdf0e10cSrcweir                 aChildParticle+=(C2U("="));
549cdf0e10cSrcweir                 OUString aLabelsCID = ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle );
550cdf0e10cSrcweir                 OUString aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifierWithParent(
551cdf0e10cSrcweir                     OBJECTTYPE_DATA_LABEL, ::rtl::OUString(), aLabelsCID );
552cdf0e10cSrcweir 
553cdf0e10cSrcweir                 return ObjectIdentifier::createPointCID( aLabelCID_Stub, nPointIndex );
554cdf0e10cSrcweir             }
555cdf0e10cSrcweir         }
556cdf0e10cSrcweir     }
557cdf0e10cSrcweir     //-------------------------------------------------------------------------
558cdf0e10cSrcweir     //mean value line
559cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatMeanValue") )
560cdf0e10cSrcweir     {
561cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_AVERAGE_LINE )
562cdf0e10cSrcweir             return rSelectedCID;
563cdf0e10cSrcweir         else
564cdf0e10cSrcweir             return ObjectIdentifier::createDataCurveCID(
565cdf0e10cSrcweir                 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ),
566cdf0e10cSrcweir                     RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt,
567cdf0e10cSrcweir                         RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) ), true );
568cdf0e10cSrcweir     }
569cdf0e10cSrcweir     //-------------------------------------------------------------------------
570cdf0e10cSrcweir     //trend line
571cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatTrendline") )
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_CURVE )
574cdf0e10cSrcweir             return rSelectedCID;
575cdf0e10cSrcweir         else
576cdf0e10cSrcweir             return ObjectIdentifier::createDataCurveCID(
577cdf0e10cSrcweir                 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ),
578cdf0e10cSrcweir                     RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt,
579cdf0e10cSrcweir                         RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ), false );
580cdf0e10cSrcweir     }
581cdf0e10cSrcweir     //-------------------------------------------------------------------------
582cdf0e10cSrcweir     //trend line equation
583cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatTrendlineEquation") )
584cdf0e10cSrcweir     {
585cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_CURVE_EQUATION )
586cdf0e10cSrcweir             return rSelectedCID;
587cdf0e10cSrcweir         else
588cdf0e10cSrcweir             return ObjectIdentifier::createDataCurveEquationCID(
589cdf0e10cSrcweir                 ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ),
590cdf0e10cSrcweir                     RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt,
591cdf0e10cSrcweir                         RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ) );
592cdf0e10cSrcweir     }
593cdf0e10cSrcweir     //-------------------------------------------------------------------------
594cdf0e10cSrcweir     // y error bars
595cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatYErrorBars") )
596cdf0e10cSrcweir     {
597cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_ERRORS )
598cdf0e10cSrcweir             return rSelectedCID;
599cdf0e10cSrcweir         else
600cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifierWithParent(
601cdf0e10cSrcweir                 OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), rSelectedCID );
602cdf0e10cSrcweir     }
603cdf0e10cSrcweir     //-------------------------------------------------------------------------
604cdf0e10cSrcweir     // axis
605cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatAxis") )
606cdf0e10cSrcweir     {
607cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_AXIS )
608cdf0e10cSrcweir             return rSelectedCID;
609cdf0e10cSrcweir         else
610cdf0e10cSrcweir         {
611cdf0e10cSrcweir             Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel );
612cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel );
613cdf0e10cSrcweir         }
614cdf0e10cSrcweir     }
615cdf0e10cSrcweir     //-------------------------------------------------------------------------
616cdf0e10cSrcweir     // major grid
617cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatMajorGrid") )
618cdf0e10cSrcweir     {
619cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_GRID )
620cdf0e10cSrcweir             return rSelectedCID;
621cdf0e10cSrcweir         else
622cdf0e10cSrcweir         {
623cdf0e10cSrcweir             Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel );
624cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel );
625cdf0e10cSrcweir         }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir     }
628cdf0e10cSrcweir     //-------------------------------------------------------------------------
629cdf0e10cSrcweir     // minor grid
630cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatMinorGrid") )
631cdf0e10cSrcweir     {
632cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_SUBGRID )
633cdf0e10cSrcweir             return rSelectedCID;
634cdf0e10cSrcweir         else
635cdf0e10cSrcweir         {
636cdf0e10cSrcweir             Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel );
637cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ );
638cdf0e10cSrcweir         }
639cdf0e10cSrcweir     }
640cdf0e10cSrcweir     //-------------------------------------------------------------------------
641cdf0e10cSrcweir     // title
642cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatTitle") )
643cdf0e10cSrcweir     {
644cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_TITLE )
645cdf0e10cSrcweir             return rSelectedCID;
646cdf0e10cSrcweir     }
647cdf0e10cSrcweir     //-------------------------------------------------------------------------
648cdf0e10cSrcweir     // stock loss
649cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatStockLoss") )
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_STOCK_LOSS )
652cdf0e10cSrcweir             return rSelectedCID;
653cdf0e10cSrcweir         else
654cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_LOSS, rtl::OUString());
655cdf0e10cSrcweir     }
656cdf0e10cSrcweir     //-------------------------------------------------------------------------
657cdf0e10cSrcweir     // stock gain
658cdf0e10cSrcweir     else if( rDispatchCommand.equals("FormatStockGain") )
659cdf0e10cSrcweir     {
660cdf0e10cSrcweir         if( eSelectedType == OBJECTTYPE_DATA_STOCK_GAIN )
661cdf0e10cSrcweir             return rSelectedCID;
662cdf0e10cSrcweir         else
663cdf0e10cSrcweir             return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_GAIN, rtl::OUString() );
664cdf0e10cSrcweir     }
665cdf0e10cSrcweir 
666cdf0e10cSrcweir     return ObjectIdentifier::createClassifiedIdentifier(
667cdf0e10cSrcweir         eObjectType, aParticleID );
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir }
671cdf0e10cSrcweir // anonymous namespace
672cdf0e10cSrcweir 
executeDispatch_FormatObject(const::rtl::OUString & rDispatchCommand)673cdf0e10cSrcweir void SAL_CALL ChartController::executeDispatch_FormatObject(const ::rtl::OUString& rDispatchCommand)
674cdf0e10cSrcweir {
675cdf0e10cSrcweir     uno::Reference< XChartDocument > xChartDocument( getModel(), uno::UNO_QUERY );
676cdf0e10cSrcweir     rtl::OString aCommand( rtl::OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) );
677cdf0e10cSrcweir     rtl::OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() );
678cdf0e10cSrcweir     executeDlg_ObjectProperties( rObjectCID );
679cdf0e10cSrcweir }
680cdf0e10cSrcweir 
executeDispatch_ObjectProperties()681cdf0e10cSrcweir void SAL_CALL ChartController::executeDispatch_ObjectProperties()
682cdf0e10cSrcweir {
683cdf0e10cSrcweir     executeDlg_ObjectProperties( m_aSelection.getSelectedCID() );
684cdf0e10cSrcweir }
685cdf0e10cSrcweir 
686cdf0e10cSrcweir namespace
687cdf0e10cSrcweir {
688cdf0e10cSrcweir 
lcl_getFormatCIDforSelectedCID(const::rtl::OUString & rSelectedCID)689cdf0e10cSrcweir rtl::OUString lcl_getFormatCIDforSelectedCID( const ::rtl::OUString& rSelectedCID )
690cdf0e10cSrcweir {
691cdf0e10cSrcweir     ::rtl::OUString aFormatCID(rSelectedCID);
692cdf0e10cSrcweir 
693cdf0e10cSrcweir     //get type of selected object
694cdf0e10cSrcweir     ObjectType eObjectType = ObjectIdentifier::getObjectType( aFormatCID );
695cdf0e10cSrcweir 
696cdf0e10cSrcweir     // some legend entries are handled as if they were data series
697cdf0e10cSrcweir 	if( OBJECTTYPE_LEGEND_ENTRY==eObjectType )
698cdf0e10cSrcweir 	{
699cdf0e10cSrcweir         rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) );
700cdf0e10cSrcweir 		aFormatCID  = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle );
701cdf0e10cSrcweir 	}
702cdf0e10cSrcweir 
703cdf0e10cSrcweir     // treat diagram as wall
704cdf0e10cSrcweir 	if( OBJECTTYPE_DIAGRAM==eObjectType )
705cdf0e10cSrcweir 		aFormatCID  = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() );
706cdf0e10cSrcweir 
707cdf0e10cSrcweir     return aFormatCID;
708cdf0e10cSrcweir }
709cdf0e10cSrcweir 
710cdf0e10cSrcweir }//end anonymous namespace
711cdf0e10cSrcweir 
executeDlg_ObjectProperties(const::rtl::OUString & rSelectedObjectCID)712cdf0e10cSrcweir void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rSelectedObjectCID )
713cdf0e10cSrcweir {
714cdf0e10cSrcweir     rtl::OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID );
715cdf0e10cSrcweir 
716cdf0e10cSrcweir     UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
717cdf0e10cSrcweir                 ActionDescriptionProvider::FORMAT,
718cdf0e10cSrcweir                 ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))),
719cdf0e10cSrcweir             m_xUndoManager );
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false );
722cdf0e10cSrcweir     if( bSuccess )
723cdf0e10cSrcweir         aUndoGuard.commit();
724cdf0e10cSrcweir }
725cdf0e10cSrcweir 
executeDlg_ObjectProperties_withoutUndoGuard(const::rtl::OUString & rObjectCID,bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso)726cdf0e10cSrcweir bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso )
727cdf0e10cSrcweir {
728cdf0e10cSrcweir     //return true if the properties were changed successfully
729cdf0e10cSrcweir     bool bRet = false;
730*9ec58d04SHerbert Dürr     if( rObjectCID.isEmpty() )
731cdf0e10cSrcweir     {
732cdf0e10cSrcweir         //DBG_ERROR("empty ObjectID");
733cdf0e10cSrcweir         return bRet;
734cdf0e10cSrcweir     }
735cdf0e10cSrcweir     try
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir 		NumberFormatterWrapper aNumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >(getModel(), uno::UNO_QUERY) );
738cdf0e10cSrcweir 
739cdf0e10cSrcweir         //-------------------------------------------------------------
740cdf0e10cSrcweir         //get type of object
741cdf0e10cSrcweir         ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID );
742cdf0e10cSrcweir         if( OBJECTTYPE_UNKNOWN==eObjectType )
743cdf0e10cSrcweir         {
744cdf0e10cSrcweir             //DBG_ERROR("unknown ObjectType");
745cdf0e10cSrcweir             return bRet;
746cdf0e10cSrcweir         }
747cdf0e10cSrcweir         if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType )
748cdf0e10cSrcweir         {
749cdf0e10cSrcweir             if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( getModel() ) ) )
750cdf0e10cSrcweir                 return bRet;
751cdf0e10cSrcweir         }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir         //-------------------------------------------------------------
754cdf0e10cSrcweir         //convert properties to ItemSet
755cdf0e10cSrcweir 
756cdf0e10cSrcweir         awt::Size aPageSize( ChartModelHelper::getPageSize(getModel()) );
757cdf0e10cSrcweir 
758cdf0e10cSrcweir         ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProv(
759cdf0e10cSrcweir             impl_createReferenceSizeProvider());
760cdf0e10cSrcweir         ::std::auto_ptr< ::comphelper::ItemConverter > apItemConverter(
761cdf0e10cSrcweir             createItemConverter( rObjectCID, getModel(), m_xCC,
762cdf0e10cSrcweir                                  m_pDrawModelWrapper->getSdrModel(),
763cdf0e10cSrcweir                                  &aNumberFormatterWrapper,
764cdf0e10cSrcweir                                  ExplicitValueProvider::getExplicitValueProvider(m_xChartView),
765cdf0e10cSrcweir                                  pRefSizeProv ));
766cdf0e10cSrcweir         if(!apItemConverter.get())
767cdf0e10cSrcweir             return bRet;
768cdf0e10cSrcweir 
769cdf0e10cSrcweir         SfxItemSet aItemSet = apItemConverter->CreateEmptyItemSet();
770cdf0e10cSrcweir         apItemConverter->FillItemSet( aItemSet );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir         //-------------------------------------------------------------
773cdf0e10cSrcweir         //prepare dialog
774cdf0e10cSrcweir         ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( rObjectCID );
775cdf0e10cSrcweir 		aDialogParameter.init( getModel() );
776cdf0e10cSrcweir         ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() );
777cdf0e10cSrcweir 
778cdf0e10cSrcweir         ::vos::OGuard aGuard( Application::GetSolarMutex());
779cdf0e10cSrcweir         SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider
780cdf0e10cSrcweir             , uno::Reference< util::XNumberFormatsSupplier >( getModel(), uno::UNO_QUERY ) );
781cdf0e10cSrcweir 
782cdf0e10cSrcweir         if(aDialogParameter.HasSymbolProperties())
783cdf0e10cSrcweir         {
784cdf0e10cSrcweir             SfxItemSet* pSymbolShapeProperties=NULL;
785cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xObjectProperties =
786cdf0e10cSrcweir                 ObjectIdentifier::getObjectPropertySet( rObjectCID, getModel() );
787cdf0e10cSrcweir             wrapper::DataPointItemConverter aSymbolItemConverter( getModel(), m_xCC
788cdf0e10cSrcweir                                         , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, getModel() )
789cdf0e10cSrcweir                                         , m_pDrawModelWrapper->getSdrModel().GetItemPool()
790cdf0e10cSrcweir                                         , m_pDrawModelWrapper->getSdrModel()
791cdf0e10cSrcweir                                         , &aNumberFormatterWrapper
792cdf0e10cSrcweir                                         , uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY )
793cdf0e10cSrcweir                                         , wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT );
794cdf0e10cSrcweir 
795cdf0e10cSrcweir             pSymbolShapeProperties = new SfxItemSet( aSymbolItemConverter.CreateEmptyItemSet() );
796cdf0e10cSrcweir             aSymbolItemConverter.FillItemSet( *pSymbolShapeProperties );
797cdf0e10cSrcweir 
798cdf0e10cSrcweir             sal_Int32   nStandardSymbol=0;//@todo get from somewhere
799cdf0e10cSrcweir             Graphic*    pAutoSymbolGraphic = new Graphic( aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, pSymbolShapeProperties ) );
800cdf0e10cSrcweir             // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic
801cdf0e10cSrcweir             aDlg.setSymbolInformation( pSymbolShapeProperties, pAutoSymbolGraphic );
802cdf0e10cSrcweir         }
803cdf0e10cSrcweir         if( aDialogParameter.HasStatisticProperties() )
804cdf0e10cSrcweir         {
805cdf0e10cSrcweir             aDlg.SetAxisMinorStepWidthForErrorBarDecimals(
806cdf0e10cSrcweir                 InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, rObjectCID ) );
807cdf0e10cSrcweir         }
808cdf0e10cSrcweir 
809cdf0e10cSrcweir         //-------------------------------------------------------------
810cdf0e10cSrcweir         //open the dialog
811cdf0e10cSrcweir         if( aDlg.Execute() == RET_OK || (bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso && aDlg.DialogWasClosedWithOK()) )
812cdf0e10cSrcweir         {
813cdf0e10cSrcweir             const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet();
814cdf0e10cSrcweir             if(pOutItemSet)
815cdf0e10cSrcweir             {
816cdf0e10cSrcweir                 ControllerLockGuard aCLGuard( getModel());
817cdf0e10cSrcweir                 apItemConverter->ApplyItemSet( *pOutItemSet );//model should be changed now
818cdf0e10cSrcweir                 bRet = true;
819cdf0e10cSrcweir             }
820cdf0e10cSrcweir         }
821cdf0e10cSrcweir     }
822cdf0e10cSrcweir     catch( util::CloseVetoException& )
823cdf0e10cSrcweir     {
824cdf0e10cSrcweir     }
825cdf0e10cSrcweir     catch( uno::RuntimeException& )
826cdf0e10cSrcweir     {
827cdf0e10cSrcweir     }
828cdf0e10cSrcweir     return bRet;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir 
executeDispatch_View3D()831cdf0e10cSrcweir void SAL_CALL ChartController::executeDispatch_View3D()
832cdf0e10cSrcweir {
833cdf0e10cSrcweir     try
834cdf0e10cSrcweir     {
835cdf0e10cSrcweir         // using assignment for broken gcc 3.3
836cdf0e10cSrcweir         UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard(
837cdf0e10cSrcweir             String( SchResId( STR_ACTION_EDIT_3D_VIEW )),
838cdf0e10cSrcweir             m_xUndoManager );
839cdf0e10cSrcweir 
840cdf0e10cSrcweir         // /--
841cdf0e10cSrcweir         //open dialog
842cdf0e10cSrcweir 		::vos::OGuard aSolarGuard( Application::GetSolarMutex());
843c7be74b1SArmin Le Grand         View3DDialog aDlg( m_pChartWindow, getModel(), m_pDrawModelWrapper->GetColorTableFromSdrModel() );
844cdf0e10cSrcweir         if( aDlg.Execute() == RET_OK )
845cdf0e10cSrcweir             aUndoGuard.commit();
846cdf0e10cSrcweir         // \--
847cdf0e10cSrcweir     }
848cdf0e10cSrcweir     catch( uno::RuntimeException& e)
849cdf0e10cSrcweir     {
850cdf0e10cSrcweir         ASSERT_EXCEPTION( e );
851cdf0e10cSrcweir     }
852cdf0e10cSrcweir }
853cdf0e10cSrcweir 
854cdf0e10cSrcweir //.............................................................................
855cdf0e10cSrcweir } //namespace chart
856cdf0e10cSrcweir //.............................................................................
857