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
10cdf0e10cSrcweir *
11cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
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.
19cdf0e10cSrcweir *
20cde9e8dcSAndrew Rist *************************************************************/
21cde9e8dcSAndrew Rist
22cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "ChartController.hxx"
28cdf0e10cSrcweir #include "ChartWindow.hxx"
29cdf0e10cSrcweir #include "ChartModelHelper.hxx"
30cdf0e10cSrcweir #include "TitleHelper.hxx"
31cdf0e10cSrcweir #include "ThreeDHelper.hxx"
32cdf0e10cSrcweir #include "DataSeriesHelper.hxx"
33cdf0e10cSrcweir #include "UndoGuard.hxx"
34cdf0e10cSrcweir #include "ControllerLockGuard.hxx"
35cdf0e10cSrcweir #include "macros.hxx"
36cdf0e10cSrcweir #include "ResId.hxx"
37cdf0e10cSrcweir #include "Strings.hrc"
38cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
39cdf0e10cSrcweir #include "ReferenceSizeProvider.hxx"
40cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx"
41cdf0e10cSrcweir #include "chartview/DrawModelWrapper.hxx"
42cdf0e10cSrcweir #include "ChartTransferable.hxx"
43cdf0e10cSrcweir #include "DrawViewWrapper.hxx"
44cdf0e10cSrcweir #include "LegendHelper.hxx"
45cdf0e10cSrcweir #include "AxisHelper.hxx"
46cdf0e10cSrcweir #include "RegressionCurveHelper.hxx"
47cdf0e10cSrcweir #include "ShapeController.hxx"
48cdf0e10cSrcweir #include "DiagramHelper.hxx"
49cdf0e10cSrcweir #include "ObjectNameProvider.hxx"
50cdf0e10cSrcweir
51cdf0e10cSrcweir #include <com/sun/star/chart2/DataPointLabel.hpp>
52cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyState.hpp>
53cdf0e10cSrcweir #include <com/sun/star/drawing/CameraGeometry.hpp>
54cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
55cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
56cdf0e10cSrcweir #include <com/sun/star/text/XTextRange.hpp>
57cdf0e10cSrcweir #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
58cdf0e10cSrcweir #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
59cdf0e10cSrcweir #include <com/sun/star/chart/ErrorBarStyle.hpp>
60cdf0e10cSrcweir
61cdf0e10cSrcweir #include <svx/ActionDescriptionProvider.hxx>
62cdf0e10cSrcweir // for TransferableDataHelper/TransferableHelper
63cdf0e10cSrcweir #include <svtools/transfer.hxx>
64cdf0e10cSrcweir // for SotStorageStreamRef
65cdf0e10cSrcweir #include <sot/storage.hxx>
66cdf0e10cSrcweir // for Graphic
67cdf0e10cSrcweir #include <vcl/graph.hxx>
68cdf0e10cSrcweir // for SvxDrawingLayerImport/SvxUnoDrawingModel
69cdf0e10cSrcweir #include <svx/unomodel.hxx>
70cdf0e10cSrcweir // for SdrModel
71cdf0e10cSrcweir #include <svx/svdmodel.hxx>
72cdf0e10cSrcweir // for OInputStreamWrapper
73cdf0e10cSrcweir #include <unotools/streamwrap.hxx>
74cdf0e10cSrcweir // for SolarMutex
75cdf0e10cSrcweir #include <vcl/svapp.hxx>
76cdf0e10cSrcweir #include <vos/mutex.hxx>
77cdf0e10cSrcweir #include <svx/dialmgr.hxx>
78cdf0e10cSrcweir #include <svx/dialogs.hrc>
79cdf0e10cSrcweir // for OutlinerView
80cdf0e10cSrcweir #include <editeng/outliner.hxx>
81cdf0e10cSrcweir #include <svx/svditer.hxx>
82cdf0e10cSrcweir #include <svx/svdpage.hxx>
83cdf0e10cSrcweir #include <svx/svdundo.hxx>
84cdf0e10cSrcweir #include <svx/unoapi.hxx>
85cdf0e10cSrcweir #include <svx/unopage.hxx>
86cdf0e10cSrcweir
87cdf0e10cSrcweir #include <boost/scoped_ptr.hpp>
88cdf0e10cSrcweir
89cdf0e10cSrcweir using namespace ::com::sun::star;
90cdf0e10cSrcweir
91cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
92cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
93cdf0e10cSrcweir using ::rtl::OUString;
94cdf0e10cSrcweir
95cdf0e10cSrcweir namespace
96cdf0e10cSrcweir {
97cdf0e10cSrcweir
lcl_deleteDataSeries(const OUString & rCID,const Reference<frame::XModel> & xModel,const Reference<document::XUndoManager> & xUndoManager)98cdf0e10cSrcweir bool lcl_deleteDataSeries(
99cdf0e10cSrcweir const OUString & rCID,
100cdf0e10cSrcweir const Reference< frame::XModel > & xModel,
101cdf0e10cSrcweir const Reference< document::XUndoManager > & xUndoManager )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir bool bResult = false;
104cdf0e10cSrcweir uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel ));
105cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY );
106cdf0e10cSrcweir if( xSeries.is() && xChartDoc.is())
107cdf0e10cSrcweir {
108cdf0e10cSrcweir uno::Reference< chart2::XChartType > xChartType(
109cdf0e10cSrcweir ::chart::DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram()));
110cdf0e10cSrcweir if( xChartType.is())
111cdf0e10cSrcweir {
112cdf0e10cSrcweir ::chart::UndoGuard aUndoGuard(
113cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
114cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))),
115cdf0e10cSrcweir xUndoManager );
116cdf0e10cSrcweir
117cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) );
118cdf0e10cSrcweir uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) );
119cdf0e10cSrcweir
120cdf0e10cSrcweir ::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType );
121cdf0e10cSrcweir
122cdf0e10cSrcweir ::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram );
123cdf0e10cSrcweir
124cdf0e10cSrcweir bResult = true;
125cdf0e10cSrcweir aUndoGuard.commit();
126cdf0e10cSrcweir }
127cdf0e10cSrcweir }
128cdf0e10cSrcweir return bResult;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir
lcl_deleteDataCurve(const OUString & rCID,const Reference<frame::XModel> & xModel,const Reference<document::XUndoManager> & xUndoManager)131cdf0e10cSrcweir bool lcl_deleteDataCurve(
132cdf0e10cSrcweir const OUString & rCID,
133cdf0e10cSrcweir const Reference< frame::XModel > & xModel,
134cdf0e10cSrcweir const Reference< document::XUndoManager > & xUndoManager )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir bool bResult = false;
137cdf0e10cSrcweir uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
138cdf0e10cSrcweir ::chart::ObjectIdentifier::getObjectPropertySet(
139cdf0e10cSrcweir ::chart::ObjectIdentifier::getSeriesParticleFromCID( rCID ), xModel ), uno::UNO_QUERY );
140cdf0e10cSrcweir if( xRegCurveCnt.is())
141cdf0e10cSrcweir {
142cdf0e10cSrcweir ::chart::UndoGuard aUndoGuard(
143cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
144cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))),
145cdf0e10cSrcweir xUndoManager );
146cdf0e10cSrcweir ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
147cdf0e10cSrcweir bResult = true;
148cdf0e10cSrcweir aUndoGuard.commit();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir return bResult;
151cdf0e10cSrcweir }
152cdf0e10cSrcweir
153cdf0e10cSrcweir // void lcl_CopyPageContentToPage(
154cdf0e10cSrcweir // const Reference< drawing::XDrawPage > & xSourcePage,
155cdf0e10cSrcweir // const Reference< drawing::XDrawPage > & xDestPage )
156cdf0e10cSrcweir // {
157cdf0e10cSrcweir // try
158cdf0e10cSrcweir // {
159cdf0e10cSrcweir // Reference< container::XIndexAccess > xSourceIA( xSourcePage, uno::UNO_QUERY_THROW );
160cdf0e10cSrcweir // sal_Int32 nCount( xSourceIA->getCount());
161cdf0e10cSrcweir // for( sal_Int32 i=0; i<nCount; ++i )
162cdf0e10cSrcweir // {
163cdf0e10cSrcweir // Reference< drawing::XShape > xShape;
164cdf0e10cSrcweir // if( xSourceIA->getByIndex( i ) >>= xShape )
165cdf0e10cSrcweir // xDestPage->add( xShape );
166cdf0e10cSrcweir // }
167cdf0e10cSrcweir // }
168cdf0e10cSrcweir // catch( const uno::Exception & ex )
169cdf0e10cSrcweir // {
170cdf0e10cSrcweir // ASSERT_EXCEPTION( ex );
171cdf0e10cSrcweir // }
172cdf0e10cSrcweir // }
173cdf0e10cSrcweir
174cdf0e10cSrcweir // // copies all shapes on all pages of xSource to the only page of xDestination
175cdf0e10cSrcweir // void lcl_CopyShapesToChart(
176cdf0e10cSrcweir // const Reference< frame::XModel > & xSource, const Reference< frame::XModel > & xDestination )
177cdf0e10cSrcweir // {
178cdf0e10cSrcweir // try
179cdf0e10cSrcweir // {
180cdf0e10cSrcweir // Reference< drawing::XDrawPageSupplier > xDestPGSupp( xDestination, uno::UNO_QUERY_THROW );
181cdf0e10cSrcweir // Reference< drawing::XDrawPage > xDestPage( xDestPGSupp->getDrawPage());
182cdf0e10cSrcweir // Reference< drawing::XDrawPagesSupplier > xSourcePGsSupp( xSource, uno::UNO_QUERY_THROW );
183cdf0e10cSrcweir // Reference< drawing::XDrawPages > xSourcePages( xSourcePGsSupp->getDrawPages());
184cdf0e10cSrcweir
185cdf0e10cSrcweir // sal_Int32 nCount( xSourcePages->getCount());
186cdf0e10cSrcweir // for( sal_Int32 i=0; i<nCount; ++i )
187cdf0e10cSrcweir // {
188cdf0e10cSrcweir // Reference< drawing::XDrawPage > xSourcePage( xSourcePages->getByIndex( i ), uno::UNO_QUERY_THROW );
189cdf0e10cSrcweir // lcl_CopyPageContentToPage( xSourcePage, xDestPage );
190cdf0e10cSrcweir // }
191cdf0e10cSrcweir // }
192cdf0e10cSrcweir // catch( const uno::Exception & ex )
193cdf0e10cSrcweir // {
194cdf0e10cSrcweir // ASSERT_EXCEPTION( ex );
195cdf0e10cSrcweir // }
196cdf0e10cSrcweir // }
197cdf0e10cSrcweir
198cdf0e10cSrcweir } // anonymous namespace
199cdf0e10cSrcweir
200cdf0e10cSrcweir
201cdf0e10cSrcweir namespace chart
202cdf0e10cSrcweir {
203cdf0e10cSrcweir
impl_createReferenceSizeProvider()204cdf0e10cSrcweir ::std::auto_ptr< ReferenceSizeProvider > ChartController::impl_createReferenceSizeProvider()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) );
207cdf0e10cSrcweir
208cdf0e10cSrcweir return ::std::auto_ptr< ReferenceSizeProvider >(
209cdf0e10cSrcweir new ReferenceSizeProvider( aPageSize,
210cdf0e10cSrcweir Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY )));
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
impl_adaptDataSeriesAutoResize()213cdf0e10cSrcweir void ChartController::impl_adaptDataSeriesAutoResize()
214cdf0e10cSrcweir {
215cdf0e10cSrcweir ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider(
216cdf0e10cSrcweir impl_createReferenceSizeProvider());
217cdf0e10cSrcweir if( apRefSizeProvider.get())
218cdf0e10cSrcweir apRefSizeProvider->setValuesAtAllDataSeries();
219cdf0e10cSrcweir }
220cdf0e10cSrcweir
executeDispatch_NewArrangement()221cdf0e10cSrcweir void ChartController::executeDispatch_NewArrangement()
222cdf0e10cSrcweir {
223cdf0e10cSrcweir // remove manual positions at titles, legend and the diagram, remove manual
224cdf0e10cSrcweir // size at the diagram
225cdf0e10cSrcweir
226cdf0e10cSrcweir try
227cdf0e10cSrcweir {
228cdf0e10cSrcweir Reference< frame::XModel > xModel( getModel() );
229cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ));
230cdf0e10cSrcweir if( xDiagram.is())
231cdf0e10cSrcweir {
232cdf0e10cSrcweir // using assignment for broken gcc 3.3
233cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
234cdf0e10cSrcweir String( SchResId( STR_ACTION_REARRANGE_CHART )),
235cdf0e10cSrcweir m_xUndoManager );
236cdf0e10cSrcweir ControllerLockGuard aCtlLockGuard( xModel );
237cdf0e10cSrcweir
238cdf0e10cSrcweir // diagram
239cdf0e10cSrcweir Reference< beans::XPropertyState > xState( xDiagram, uno::UNO_QUERY_THROW );
240cdf0e10cSrcweir xState->setPropertyToDefault( C2U("RelativeSize"));
241cdf0e10cSrcweir xState->setPropertyToDefault( C2U("RelativePosition"));
242cdf0e10cSrcweir xState->setPropertyToDefault( C2U("PosSizeExcludeAxes"));
243cdf0e10cSrcweir
244cdf0e10cSrcweir // 3d rotation
245cdf0e10cSrcweir ThreeDHelper::set3DSettingsToDefault( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ) );
246cdf0e10cSrcweir
247cdf0e10cSrcweir // legend
248cdf0e10cSrcweir Reference< beans::XPropertyState > xLegendState( xDiagram->getLegend(), uno::UNO_QUERY );
249cdf0e10cSrcweir if( xLegendState.is())
250cdf0e10cSrcweir {
251cdf0e10cSrcweir xLegendState->setPropertyToDefault( C2U("RelativePosition"));
252cdf0e10cSrcweir xLegendState->setPropertyToDefault( C2U("RelativeSize"));
253cdf0e10cSrcweir xLegendState->setPropertyToDefault( C2U("AnchorPosition"));
254cdf0e10cSrcweir }
255cdf0e10cSrcweir
256cdf0e10cSrcweir // titles
257cdf0e10cSrcweir for( sal_Int32 eType = TitleHelper::TITLE_BEGIN;
258cdf0e10cSrcweir eType < TitleHelper::NORMAL_TITLE_END;
259cdf0e10cSrcweir ++eType )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir Reference< beans::XPropertyState > xTitleState(
262cdf0e10cSrcweir TitleHelper::getTitle(
263cdf0e10cSrcweir static_cast< TitleHelper::eTitleType >( eType ), xModel ), uno::UNO_QUERY );
264cdf0e10cSrcweir if( xTitleState.is())
265cdf0e10cSrcweir xTitleState->setPropertyToDefault( C2U("RelativePosition"));
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268cdf0e10cSrcweir // regression curve equations
269cdf0e10cSrcweir ::std::vector< Reference< chart2::XRegressionCurve > > aRegressionCurves(
270cdf0e10cSrcweir RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( xDiagram ));
271cdf0e10cSrcweir ::std::for_each( aRegressionCurves.begin(), aRegressionCurves.end(),
272cdf0e10cSrcweir RegressionCurveHelper::resetEquationPosition );
273cdf0e10cSrcweir
274cdf0e10cSrcweir aUndoGuard.commit();
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir catch( uno::RuntimeException & ex )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
280cdf0e10cSrcweir }
281cdf0e10cSrcweir }
282cdf0e10cSrcweir
executeDispatch_ScaleText()283cdf0e10cSrcweir void ChartController::executeDispatch_ScaleText()
284cdf0e10cSrcweir {
285cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex());
286cdf0e10cSrcweir // using assignment for broken gcc 3.3
287cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
288cdf0e10cSrcweir String( SchResId( STR_ACTION_SCALE_TEXT )),
289cdf0e10cSrcweir m_xUndoManager );
290cdf0e10cSrcweir ControllerLockGuard aCtlLockGuard( getModel() );
291cdf0e10cSrcweir ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider());
292cdf0e10cSrcweir OSL_ASSERT( apRefSizeProv.get());
293cdf0e10cSrcweir if( apRefSizeProv.get())
294cdf0e10cSrcweir apRefSizeProv->toggleAutoResizeState();
295cdf0e10cSrcweir aUndoGuard.commit();
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
executeDispatch_Paste()298cdf0e10cSrcweir void ChartController::executeDispatch_Paste()
299cdf0e10cSrcweir {
300cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() );
301cdf0e10cSrcweir if( m_pChartWindow )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir Graphic aGraphic;
304cdf0e10cSrcweir // paste location: center of window
305cdf0e10cSrcweir Point aPos;
306cdf0e10cSrcweir aPos = m_pChartWindow->PixelToLogic( Rectangle( aPos, m_pChartWindow->GetSizePixel()).Center());
307cdf0e10cSrcweir
308cdf0e10cSrcweir // handle different formats
309cdf0e10cSrcweir TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( m_pChartWindow ));
310cdf0e10cSrcweir if( aDataHelper.GetTransferable().is())
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir SotStorageStreamRef xStm;
315cdf0e10cSrcweir if ( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
316cdf0e10cSrcweir {
317cdf0e10cSrcweir xStm->Seek( 0 );
318cdf0e10cSrcweir Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
319cdf0e10cSrcweir ::boost::scoped_ptr< SdrModel > spModel( new SdrModel() );
320cdf0e10cSrcweir if ( SvxDrawingLayerImport( spModel.get(), xInputStream ) )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir impl_PasteShapes( spModel.get() );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir }
325cdf0e10cSrcweir }
326cdf0e10cSrcweir else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir // graphic exchange format (graphic manager bitmap format?)
329cdf0e10cSrcweir SotStorageStreamRef xStm;
330cdf0e10cSrcweir if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ))
331cdf0e10cSrcweir (*xStm) >> aGraphic;
332cdf0e10cSrcweir }
333cdf0e10cSrcweir else if( aDataHelper.HasFormat( FORMAT_GDIMETAFILE ))
334cdf0e10cSrcweir {
335cdf0e10cSrcweir // meta file
336cdf0e10cSrcweir GDIMetaFile aMetafile;
337cdf0e10cSrcweir if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMetafile ))
338cdf0e10cSrcweir aGraphic = Graphic( aMetafile );
339cdf0e10cSrcweir }
340cdf0e10cSrcweir else if( aDataHelper.HasFormat( FORMAT_BITMAP ))
341cdf0e10cSrcweir {
342cdf0e10cSrcweir // bitmap (non-graphic-manager)
34345fd3b9aSArmin Le Grand BitmapEx aBmpEx;
34445fd3b9aSArmin Le Grand if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ))
34545fd3b9aSArmin Le Grand aGraphic = Graphic( aBmpEx );
346cdf0e10cSrcweir }
347cdf0e10cSrcweir else if( aDataHelper.HasFormat( FORMAT_STRING ))
348cdf0e10cSrcweir {
349cdf0e10cSrcweir OUString aString;
350cdf0e10cSrcweir if( aDataHelper.GetString( FORMAT_STRING, aString ) && m_pDrawModelWrapper )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir if( m_pDrawViewWrapper )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
355cdf0e10cSrcweir if( pOutlinerView )//in case of edit mode insert into edited string
356cdf0e10cSrcweir pOutlinerView->InsertText( aString );
357cdf0e10cSrcweir else
358cdf0e10cSrcweir {
359cdf0e10cSrcweir impl_PasteStringAsTextShape( aString, awt::Point( 0, 0 ) );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir }
362cdf0e10cSrcweir }
363cdf0e10cSrcweir }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir
366cdf0e10cSrcweir if( aGraphic.GetType() != GRAPHIC_NONE )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic());
369cdf0e10cSrcweir if( xGraphic.is())
370cdf0e10cSrcweir impl_PasteGraphic( xGraphic, aPos );
371cdf0e10cSrcweir }
372cdf0e10cSrcweir }
373cdf0e10cSrcweir }
374cdf0e10cSrcweir
375cdf0e10cSrcweir // note: aPosition is ignored for now. The object is always pasted centered to
376cdf0e10cSrcweir // the page
impl_PasteGraphic(uno::Reference<graphic::XGraphic> & xGraphic,const::Point &)377cdf0e10cSrcweir void ChartController::impl_PasteGraphic(
378cdf0e10cSrcweir uno::Reference< graphic::XGraphic > & xGraphic,
379cdf0e10cSrcweir const ::Point & /* aPosition */ )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir // note: the XPropertySet of the model is the old API. Also the property
382cdf0e10cSrcweir // "AdditionalShapes" that is used there.
383cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY );
384cdf0e10cSrcweir DrawModelWrapper * pDrawModelWrapper( this->GetDrawModelWrapper());
385cdf0e10cSrcweir if( ! (xGraphic.is() && xModelProp.is()))
386cdf0e10cSrcweir return;
387cdf0e10cSrcweir uno::Reference< lang::XMultiServiceFactory > xFact( pDrawModelWrapper->getShapeFactory());
388cdf0e10cSrcweir uno::Reference< drawing::XShape > xGraphicShape(
389cdf0e10cSrcweir xFact->createInstance( C2U( "com.sun.star.drawing.GraphicObjectShape" )), uno::UNO_QUERY );
390cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xGraphicShapeProp( xGraphicShape, uno::UNO_QUERY );
391cdf0e10cSrcweir if( xGraphicShapeProp.is() && xGraphicShape.is())
392cdf0e10cSrcweir {
393cdf0e10cSrcweir uno::Reference< drawing::XShapes > xPage( pDrawModelWrapper->getMainDrawPage(), uno::UNO_QUERY );
394cdf0e10cSrcweir if( xPage.is())
395cdf0e10cSrcweir {
396cdf0e10cSrcweir xPage->add( xGraphicShape );
397cdf0e10cSrcweir //need to change the model state manually
398cdf0e10cSrcweir {
399cdf0e10cSrcweir uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY );
400cdf0e10cSrcweir if( xModifiable.is() )
401cdf0e10cSrcweir xModifiable->setModified( true );
402cdf0e10cSrcweir }
403cdf0e10cSrcweir //select new shape
404cdf0e10cSrcweir m_aSelection.setSelection( xGraphicShape );
405cdf0e10cSrcweir m_aSelection.applySelection( m_pDrawViewWrapper );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir xGraphicShapeProp->setPropertyValue( C2U("Graphic"), uno::makeAny( xGraphic ));
408cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY );
409cdf0e10cSrcweir
410cdf0e10cSrcweir awt::Size aGraphicSize( 1000, 1000 );
411cdf0e10cSrcweir // first try size in 100th mm, then pixel size
412cdf0e10cSrcweir if( ! ( xGraphicProp->getPropertyValue( C2U("Size100thMM")) >>= aGraphicSize ) &&
413cdf0e10cSrcweir ( ( xGraphicProp->getPropertyValue( C2U("SizePixel")) >>= aGraphicSize ) && m_pChartWindow ))
414cdf0e10cSrcweir {
415cdf0e10cSrcweir ::Size aVCLSize( m_pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height )));
416cdf0e10cSrcweir aGraphicSize.Width = aVCLSize.getWidth();
417cdf0e10cSrcweir aGraphicSize.Height = aVCLSize.getHeight();
418cdf0e10cSrcweir }
419cdf0e10cSrcweir xGraphicShape->setSize( aGraphicSize );
420cdf0e10cSrcweir xGraphicShape->setPosition( awt::Point( 0, 0 ) );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir }
423cdf0e10cSrcweir
impl_PasteShapes(SdrModel * pModel)424cdf0e10cSrcweir void ChartController::impl_PasteShapes( SdrModel* pModel )
425cdf0e10cSrcweir {
426cdf0e10cSrcweir DrawModelWrapper* pDrawModelWrapper( this->GetDrawModelWrapper() );
427cdf0e10cSrcweir if ( pDrawModelWrapper && m_pDrawViewWrapper )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir Reference< drawing::XDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() );
430cdf0e10cSrcweir SdrPage* pDestPage = GetSdrPageFromXDrawPage( xDestPage );
431cdf0e10cSrcweir if ( pDestPage )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir Reference< drawing::XShape > xSelShape;
434cdf0e10cSrcweir m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
435cdf0e10cSrcweir sal_uInt16 nCount = pModel->GetPageCount();
436cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < nCount; ++i )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir const SdrPage* pPage = pModel->GetPage( i );
439cdf0e10cSrcweir SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
440cdf0e10cSrcweir while ( aIter.IsMore() )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir SdrObject* pObj = aIter.Next();
443cdf0e10cSrcweir SdrObject* pNewObj = ( pObj ? pObj->Clone() : NULL );
444cdf0e10cSrcweir if ( pNewObj )
445cdf0e10cSrcweir {
446cdf0e10cSrcweir pNewObj->SetModel( &pDrawModelWrapper->getSdrModel() );
447cdf0e10cSrcweir pNewObj->SetPage( pDestPage );
448cdf0e10cSrcweir
449cdf0e10cSrcweir // set position
450cdf0e10cSrcweir Reference< drawing::XShape > xShape( pNewObj->getUnoShape(), uno::UNO_QUERY );
451cdf0e10cSrcweir if ( xShape.is() )
452cdf0e10cSrcweir {
453cdf0e10cSrcweir xShape->setPosition( awt::Point( 0, 0 ) );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir
456cdf0e10cSrcweir pDestPage->InsertObject( pNewObj );
457cdf0e10cSrcweir m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pNewObj ) );
458cdf0e10cSrcweir xSelShape = xShape;
459cdf0e10cSrcweir }
460cdf0e10cSrcweir }
461cdf0e10cSrcweir }
462cdf0e10cSrcweir
463cdf0e10cSrcweir Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY );
464cdf0e10cSrcweir if ( xModifiable.is() )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir xModifiable->setModified( true );
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir // select last inserted shape
470cdf0e10cSrcweir m_aSelection.setSelection( xSelShape );
471cdf0e10cSrcweir m_aSelection.applySelection( m_pDrawViewWrapper );
472cdf0e10cSrcweir
473cdf0e10cSrcweir m_pDrawViewWrapper->EndUndo();
474cdf0e10cSrcweir
475cdf0e10cSrcweir impl_switchDiagramPositioningToExcludingPositioning();
476cdf0e10cSrcweir }
477cdf0e10cSrcweir }
478cdf0e10cSrcweir }
479cdf0e10cSrcweir
impl_PasteStringAsTextShape(const OUString & rString,const awt::Point & rPosition)480cdf0e10cSrcweir void ChartController::impl_PasteStringAsTextShape( const OUString& rString, const awt::Point& rPosition )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir DrawModelWrapper* pDrawModelWrapper( this->GetDrawModelWrapper() );
483cdf0e10cSrcweir if ( pDrawModelWrapper && m_pDrawViewWrapper )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() );
486cdf0e10cSrcweir const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() );
487cdf0e10cSrcweir OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() );
488cdf0e10cSrcweir
489cdf0e10cSrcweir if ( xShapeFactory.is() && xDrawPage.is() )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir try
492cdf0e10cSrcweir {
493cdf0e10cSrcweir Reference< drawing::XShape > xTextShape(
494cdf0e10cSrcweir xShapeFactory->createInstance( C2U( "com.sun.star.drawing.TextShape" ) ), uno::UNO_QUERY_THROW );
495cdf0e10cSrcweir xDrawPage->add( xTextShape );
496cdf0e10cSrcweir
497cdf0e10cSrcweir Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW );
498cdf0e10cSrcweir xRange->setString( rString );
499cdf0e10cSrcweir
500cdf0e10cSrcweir float fCharHeight = 10.0;
501cdf0e10cSrcweir Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW );
502cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "TextAutoGrowHeight" ), uno::makeAny( true ) );
503cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "TextAutoGrowWidth" ), uno::makeAny( true ) );
504cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "CharHeight" ), uno::makeAny( fCharHeight ) );
505cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "CharHeightAsian" ), uno::makeAny( fCharHeight ) );
506cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "CharHeightComplex" ), uno::makeAny( fCharHeight ) );
507cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "TextVerticalAdjust" ), uno::makeAny( drawing::TextVerticalAdjust_CENTER ) );
508cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "TextHorizontalAdjust" ), uno::makeAny( drawing::TextHorizontalAdjust_CENTER ) );
509cdf0e10cSrcweir xProperties->setPropertyValue( C2U( "CharFontName" ), uno::makeAny( C2U( "Albany" ) ) );
510cdf0e10cSrcweir
511cdf0e10cSrcweir xTextShape->setPosition( rPosition );
512cdf0e10cSrcweir
513cdf0e10cSrcweir m_aSelection.setSelection( xTextShape );
514cdf0e10cSrcweir m_aSelection.applySelection( m_pDrawViewWrapper );
515cdf0e10cSrcweir
516cdf0e10cSrcweir SdrObject* pObj = DrawViewWrapper::getSdrObject( xTextShape );
517cdf0e10cSrcweir if ( pObj )
518cdf0e10cSrcweir {
519cdf0e10cSrcweir m_pDrawViewWrapper->BegUndo( SVX_RESSTR( RID_SVX_3D_UNDO_EXCHANGE_PASTE ) );
520cdf0e10cSrcweir m_pDrawViewWrapper->AddUndo( new SdrUndoInsertObj( *pObj ) );
521cdf0e10cSrcweir m_pDrawViewWrapper->EndUndo();
522cdf0e10cSrcweir
523cdf0e10cSrcweir impl_switchDiagramPositioningToExcludingPositioning();
524cdf0e10cSrcweir }
525cdf0e10cSrcweir }
526cdf0e10cSrcweir catch ( const uno::Exception& ex )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
529cdf0e10cSrcweir }
530cdf0e10cSrcweir }
531cdf0e10cSrcweir }
532cdf0e10cSrcweir }
533cdf0e10cSrcweir
executeDispatch_Copy()534cdf0e10cSrcweir void ChartController::executeDispatch_Copy()
535cdf0e10cSrcweir {
536cdf0e10cSrcweir if ( m_pDrawViewWrapper )
537cdf0e10cSrcweir {
538cdf0e10cSrcweir OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
539cdf0e10cSrcweir if ( pOutlinerView )
540cdf0e10cSrcweir {
541cdf0e10cSrcweir pOutlinerView->Copy();
542cdf0e10cSrcweir }
543cdf0e10cSrcweir else
544cdf0e10cSrcweir {
545cdf0e10cSrcweir Reference< datatransfer::XTransferable > xTransferable;
546cdf0e10cSrcweir {
547cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
548cdf0e10cSrcweir SdrObject* pSelectedObj = 0;
549cdf0e10cSrcweir if ( m_pDrawModelWrapper )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir ObjectIdentifier aSelOID( m_aSelection.getSelectedOID() );
552cdf0e10cSrcweir if ( aSelOID.isAutoGeneratedObject() )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir pSelectedObj = m_pDrawModelWrapper->getNamedSdrObject( aSelOID.getObjectCID() );
555cdf0e10cSrcweir }
556cdf0e10cSrcweir else if ( aSelOID.isAdditionalShape() )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir pSelectedObj = DrawViewWrapper::getSdrObject( aSelOID.getAdditionalShape() );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir if ( pSelectedObj )
561cdf0e10cSrcweir {
562cdf0e10cSrcweir xTransferable = Reference< datatransfer::XTransferable >( new ChartTransferable(
563cdf0e10cSrcweir &m_pDrawModelWrapper->getSdrModel(), pSelectedObj, aSelOID.isAdditionalShape() ) );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir }
566cdf0e10cSrcweir }
567cdf0e10cSrcweir if ( xTransferable.is() )
568cdf0e10cSrcweir {
569cdf0e10cSrcweir Reference< datatransfer::clipboard::XClipboard > xClipboard( TransferableHelper::GetSystemClipboard() );
570cdf0e10cSrcweir if ( xClipboard.is() )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir xClipboard->setContents( xTransferable, Reference< datatransfer::clipboard::XClipboardOwner >() );
573cdf0e10cSrcweir }
574cdf0e10cSrcweir }
575cdf0e10cSrcweir }
576cdf0e10cSrcweir }
577cdf0e10cSrcweir }
578cdf0e10cSrcweir
executeDispatch_Cut()579cdf0e10cSrcweir void ChartController::executeDispatch_Cut()
580cdf0e10cSrcweir {
581cdf0e10cSrcweir executeDispatch_Copy();
582cdf0e10cSrcweir executeDispatch_Delete();
583cdf0e10cSrcweir }
584cdf0e10cSrcweir
isObjectDeleteable(const uno::Any & rSelection)585cdf0e10cSrcweir bool ChartController::isObjectDeleteable( const uno::Any& rSelection )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir ObjectIdentifier aSelOID( rSelection );
588cdf0e10cSrcweir if ( aSelOID.isAutoGeneratedObject() )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir OUString aSelObjCID( aSelOID.getObjectCID() );
591cdf0e10cSrcweir ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID ));
592cdf0e10cSrcweir if( (OBJECTTYPE_TITLE == aObjectType) || (OBJECTTYPE_LEGEND == aObjectType) )
593cdf0e10cSrcweir return true;
594cdf0e10cSrcweir if( (OBJECTTYPE_DATA_SERIES == aObjectType) || (OBJECTTYPE_LEGEND_ENTRY == aObjectType) )
595cdf0e10cSrcweir return true;
596cdf0e10cSrcweir if( (OBJECTTYPE_DATA_CURVE_EQUATION == aObjectType) || (OBJECTTYPE_DATA_CURVE == aObjectType) ||
597cdf0e10cSrcweir (OBJECTTYPE_DATA_AVERAGE_LINE == aObjectType) || (OBJECTTYPE_DATA_ERRORS == aObjectType))
598cdf0e10cSrcweir return true;
599cdf0e10cSrcweir if( (OBJECTTYPE_DATA_LABELS == aObjectType) || (OBJECTTYPE_DATA_LABEL == aObjectType) )
600cdf0e10cSrcweir return true;
601cdf0e10cSrcweir if( (OBJECTTYPE_AXIS == aObjectType) || (OBJECTTYPE_GRID == aObjectType) || (OBJECTTYPE_SUBGRID == aObjectType) )
602cdf0e10cSrcweir return true;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir else if ( aSelOID.isAdditionalShape() )
605cdf0e10cSrcweir {
606cdf0e10cSrcweir return true;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir return false;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir
isShapeContext() const612cdf0e10cSrcweir bool ChartController::isShapeContext() const
613cdf0e10cSrcweir {
614cdf0e10cSrcweir if ( m_aSelection.isAdditionalShapeSelected() ||
615cdf0e10cSrcweir ( m_pDrawViewWrapper && m_pDrawViewWrapper->AreObjectsMarked() &&
616cdf0e10cSrcweir ( m_pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) ) )
617cdf0e10cSrcweir {
618cdf0e10cSrcweir return true;
619cdf0e10cSrcweir }
620cdf0e10cSrcweir
621cdf0e10cSrcweir return false;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir
impl_ClearSelection()624cdf0e10cSrcweir void ChartController::impl_ClearSelection()
625cdf0e10cSrcweir {
626cdf0e10cSrcweir if( m_aSelection.hasSelection())
627cdf0e10cSrcweir {
628cdf0e10cSrcweir m_aSelection.clearSelection();
629cdf0e10cSrcweir impl_notifySelectionChangeListeners();
630cdf0e10cSrcweir }
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
executeDispatch_Delete()633cdf0e10cSrcweir bool ChartController::executeDispatch_Delete()
634cdf0e10cSrcweir {
635cdf0e10cSrcweir bool bReturn = false;
636cdf0e10cSrcweir
637cdf0e10cSrcweir // remove the selected object
638cdf0e10cSrcweir //
639cdf0e10cSrcweir rtl::OUString aCID( m_aSelection.getSelectedCID() );
640*9ec58d04SHerbert Dürr if( !aCID.isEmpty() )
641cdf0e10cSrcweir {
642cdf0e10cSrcweir if( !isObjectDeleteable( uno::Any( aCID ) ) )
643cdf0e10cSrcweir return false;
644cdf0e10cSrcweir
645cdf0e10cSrcweir //remove chart object
646cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY );
647cdf0e10cSrcweir if( !xChartDoc.is() )
648cdf0e10cSrcweir return false;
649cdf0e10cSrcweir
650cdf0e10cSrcweir ObjectType aObjectType( ObjectIdentifier::getObjectType( aCID ));
651cdf0e10cSrcweir switch( aObjectType )
652cdf0e10cSrcweir {
653cdf0e10cSrcweir case OBJECTTYPE_TITLE:
654cdf0e10cSrcweir {
655cdf0e10cSrcweir // using assignment for broken gcc 3.3
656cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
657cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
658cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))),
659cdf0e10cSrcweir m_xUndoManager );
660cdf0e10cSrcweir TitleHelper::removeTitle(
661cdf0e10cSrcweir ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() );
662cdf0e10cSrcweir bReturn = true;
663cdf0e10cSrcweir aUndoGuard.commit();
664cdf0e10cSrcweir break;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir case OBJECTTYPE_LEGEND:
667cdf0e10cSrcweir {
668cdf0e10cSrcweir uno::Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram());
669cdf0e10cSrcweir if( xDiagram.is())
670cdf0e10cSrcweir {
671cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xLegendProp( xDiagram->getLegend(), uno::UNO_QUERY );
672cdf0e10cSrcweir if( xLegendProp.is())
673cdf0e10cSrcweir {
674cdf0e10cSrcweir // using assignment for broken gcc 3.3
675cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
676cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
677cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))),
678cdf0e10cSrcweir m_xUndoManager );
679cdf0e10cSrcweir xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false ));
680cdf0e10cSrcweir bReturn = true;
681cdf0e10cSrcweir aUndoGuard.commit();
682cdf0e10cSrcweir }
683cdf0e10cSrcweir }
684cdf0e10cSrcweir break;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir
687cdf0e10cSrcweir case OBJECTTYPE_DATA_SERIES:
688cdf0e10cSrcweir bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
689cdf0e10cSrcweir break;
690cdf0e10cSrcweir
691cdf0e10cSrcweir case OBJECTTYPE_LEGEND_ENTRY:
692cdf0e10cSrcweir {
693cdf0e10cSrcweir ObjectType eParentObjectType = ObjectIdentifier::getObjectType(
694cdf0e10cSrcweir ObjectIdentifier::getFullParentParticle( aCID ));
695cdf0e10cSrcweir if( eParentObjectType == OBJECTTYPE_DATA_SERIES )
696cdf0e10cSrcweir bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager );
697cdf0e10cSrcweir else if( eParentObjectType == OBJECTTYPE_DATA_CURVE )
698cdf0e10cSrcweir bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
699cdf0e10cSrcweir else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir executeDispatch_DeleteMeanValue();
702cdf0e10cSrcweir bReturn = true;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir break;
705cdf0e10cSrcweir }
706cdf0e10cSrcweir
707cdf0e10cSrcweir case OBJECTTYPE_DATA_AVERAGE_LINE:
708cdf0e10cSrcweir {
709cdf0e10cSrcweir uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
710cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet(
711cdf0e10cSrcweir ObjectIdentifier::getFullParentParticle( aCID ), getModel()), uno::UNO_QUERY );
712cdf0e10cSrcweir if( xRegCurveCnt.is())
713cdf0e10cSrcweir {
714cdf0e10cSrcweir // using assignment for broken gcc 3.3
715cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
716cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
717cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))),
718cdf0e10cSrcweir m_xUndoManager );
719cdf0e10cSrcweir RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
720cdf0e10cSrcweir bReturn = true;
721cdf0e10cSrcweir aUndoGuard.commit();
722cdf0e10cSrcweir }
723cdf0e10cSrcweir break;
724cdf0e10cSrcweir }
725cdf0e10cSrcweir
726cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE:
727cdf0e10cSrcweir bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager );
728cdf0e10cSrcweir break;
729cdf0e10cSrcweir
730cdf0e10cSrcweir case OBJECTTYPE_DATA_CURVE_EQUATION:
731cdf0e10cSrcweir {
732cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xEqProp(
733cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( aCID, getModel()));
734cdf0e10cSrcweir if( xEqProp.is())
735cdf0e10cSrcweir {
736cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( getModel() );
737cdf0e10cSrcweir // using assignment for broken gcc 3.3
738cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
739cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
740cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))),
741cdf0e10cSrcweir m_xUndoManager );
742cdf0e10cSrcweir {
743cdf0e10cSrcweir ControllerLockGuard aCtlLockGuard( xModel );
744cdf0e10cSrcweir xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false ));
745cdf0e10cSrcweir xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false ));
746cdf0e10cSrcweir }
747cdf0e10cSrcweir bReturn = true;
748cdf0e10cSrcweir aUndoGuard.commit();
749cdf0e10cSrcweir }
750cdf0e10cSrcweir break;
751cdf0e10cSrcweir }
752cdf0e10cSrcweir
753cdf0e10cSrcweir case OBJECTTYPE_DATA_ERRORS:
754cdf0e10cSrcweir {
755cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp(
756cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( aCID, getModel() ));
757cdf0e10cSrcweir if( xErrorBarProp.is())
758cdf0e10cSrcweir {
759cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( getModel() );
760cdf0e10cSrcweir // using assignment for broken gcc 3.3
761cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
762cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
763cdf0e10cSrcweir ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))),
764cdf0e10cSrcweir m_xUndoManager );
765cdf0e10cSrcweir {
766cdf0e10cSrcweir ControllerLockGuard aCtlLockGuard( xModel );
767cdf0e10cSrcweir xErrorBarProp->setPropertyValue(
768cdf0e10cSrcweir C2U("ErrorBarStyle"),
769cdf0e10cSrcweir uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE ));
770cdf0e10cSrcweir }
771cdf0e10cSrcweir bReturn = true;
772cdf0e10cSrcweir aUndoGuard.commit();
773cdf0e10cSrcweir }
774cdf0e10cSrcweir break;
775cdf0e10cSrcweir }
776cdf0e10cSrcweir
777cdf0e10cSrcweir case OBJECTTYPE_DATA_LABELS:
778cdf0e10cSrcweir case OBJECTTYPE_DATA_LABEL:
779cdf0e10cSrcweir {
780cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xObjectProperties =
781cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( aCID, getModel() );
782cdf0e10cSrcweir if( xObjectProperties.is() )
783cdf0e10cSrcweir {
784cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
785cdf0e10cSrcweir ActionDescriptionProvider::createDescription(
786cdf0e10cSrcweir ActionDescriptionProvider::DELETE, ::rtl::OUString( String(
787cdf0e10cSrcweir SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))),
788cdf0e10cSrcweir m_xUndoManager );
789cdf0e10cSrcweir chart2::DataPointLabel aLabel;
790cdf0e10cSrcweir xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel;
791cdf0e10cSrcweir aLabel.ShowNumber = false;
792cdf0e10cSrcweir aLabel.ShowNumberInPercent = false;
793cdf0e10cSrcweir aLabel.ShowCategoryName = false;
794cdf0e10cSrcweir aLabel.ShowLegendSymbol = false;
795cdf0e10cSrcweir if( aObjectType == OBJECTTYPE_DATA_LABELS )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getModel() ));
798cdf0e10cSrcweir ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny(aLabel) );
799cdf0e10cSrcweir }
800cdf0e10cSrcweir else
801cdf0e10cSrcweir xObjectProperties->setPropertyValue( C2U( "Label" ), uno::makeAny(aLabel) );
802cdf0e10cSrcweir bReturn = true;
803cdf0e10cSrcweir aUndoGuard.commit();
804cdf0e10cSrcweir }
805cdf0e10cSrcweir break;
806cdf0e10cSrcweir }
807cdf0e10cSrcweir case OBJECTTYPE_AXIS:
808cdf0e10cSrcweir {
809cdf0e10cSrcweir executeDispatch_DeleteAxis();
810cdf0e10cSrcweir bReturn = true;
811cdf0e10cSrcweir break;
812cdf0e10cSrcweir }
813cdf0e10cSrcweir case OBJECTTYPE_GRID:
814cdf0e10cSrcweir {
815cdf0e10cSrcweir executeDispatch_DeleteMajorGrid();
816cdf0e10cSrcweir bReturn = true;
817cdf0e10cSrcweir break;
818cdf0e10cSrcweir }
819cdf0e10cSrcweir case OBJECTTYPE_SUBGRID:
820cdf0e10cSrcweir {
821cdf0e10cSrcweir executeDispatch_DeleteMinorGrid();
822cdf0e10cSrcweir bReturn = true;
823cdf0e10cSrcweir break;
824cdf0e10cSrcweir }
825cdf0e10cSrcweir
826cdf0e10cSrcweir default:
827cdf0e10cSrcweir {
828cdf0e10cSrcweir break;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir }
831cdf0e10cSrcweir }
832cdf0e10cSrcweir else
833cdf0e10cSrcweir {
834cdf0e10cSrcweir //remove additional shape
835cdf0e10cSrcweir impl_ClearSelection();
836cdf0e10cSrcweir {
837cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
838cdf0e10cSrcweir if ( m_pDrawViewWrapper )
839cdf0e10cSrcweir {
840cdf0e10cSrcweir m_pDrawViewWrapper->DeleteMarked();
841cdf0e10cSrcweir bReturn = true;
842cdf0e10cSrcweir }
843cdf0e10cSrcweir }
844cdf0e10cSrcweir }
845cdf0e10cSrcweir return bReturn;
846cdf0e10cSrcweir }
847cdf0e10cSrcweir
executeDispatch_ToggleLegend()848cdf0e10cSrcweir void ChartController::executeDispatch_ToggleLegend()
849cdf0e10cSrcweir {
850cdf0e10cSrcweir Reference< frame::XModel > xModel( getModel() );
851cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
852cdf0e10cSrcweir String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager );
853cdf0e10cSrcweir Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY );
854cdf0e10cSrcweir bool bChanged = false;
855cdf0e10cSrcweir if( xLegendProp.is())
856cdf0e10cSrcweir {
857cdf0e10cSrcweir try
858cdf0e10cSrcweir {
859cdf0e10cSrcweir bool bShow = false;
860cdf0e10cSrcweir if( xLegendProp->getPropertyValue( C2U("Show")) >>= bShow )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( ! bShow ));
863cdf0e10cSrcweir bChanged = true;
864cdf0e10cSrcweir }
865cdf0e10cSrcweir }
866cdf0e10cSrcweir catch( const uno::Exception & ex )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir ASSERT_EXCEPTION( ex );
869cdf0e10cSrcweir }
870cdf0e10cSrcweir }
871cdf0e10cSrcweir else
872cdf0e10cSrcweir {
873cdf0e10cSrcweir xLegendProp.set( LegendHelper::getLegend( xModel, m_xCC, true ), uno::UNO_QUERY );
874cdf0e10cSrcweir if( xLegendProp.is())
875cdf0e10cSrcweir bChanged = true;
876cdf0e10cSrcweir }
877cdf0e10cSrcweir
878cdf0e10cSrcweir if( bChanged )
879cdf0e10cSrcweir aUndoGuard.commit();
880cdf0e10cSrcweir }
881cdf0e10cSrcweir
executeDispatch_ToggleGridHorizontal()882cdf0e10cSrcweir void ChartController::executeDispatch_ToggleGridHorizontal()
883cdf0e10cSrcweir {
884cdf0e10cSrcweir Reference< frame::XModel > xModel( getModel() );
885cdf0e10cSrcweir UndoGuard aUndoGuard = UndoGuard(
886cdf0e10cSrcweir String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager );
887cdf0e10cSrcweir Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() ));
888cdf0e10cSrcweir if( xDiagram.is())
889cdf0e10cSrcweir {
890cdf0e10cSrcweir sal_Int32 nDimensionIndex = 1;
891cdf0e10cSrcweir sal_Int32 nCooSysIndex = 0;
892cdf0e10cSrcweir bool bIsMainGrid = true;
893cdf0e10cSrcweir
894cdf0e10cSrcweir bool bHasMainYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram );
895cdf0e10cSrcweir
896cdf0e10cSrcweir if( bHasMainYGrid )
897cdf0e10cSrcweir AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram );
898cdf0e10cSrcweir else
899cdf0e10cSrcweir AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram, m_xCC );
900cdf0e10cSrcweir
901cdf0e10cSrcweir aUndoGuard.commit();
902cdf0e10cSrcweir }
903cdf0e10cSrcweir }
904cdf0e10cSrcweir
impl_ShapeControllerDispatch(const util::URL & rURL,const Sequence<beans::PropertyValue> & rArgs)905cdf0e10cSrcweir void ChartController::impl_ShapeControllerDispatch( const util::URL& rURL, const Sequence< beans::PropertyValue >& rArgs )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir Reference< frame::XDispatch > xDispatch( m_aDispatchContainer.getShapeController() );
908cdf0e10cSrcweir if ( xDispatch.is() )
909cdf0e10cSrcweir {
910cdf0e10cSrcweir xDispatch->dispatch( rURL, rArgs );
911cdf0e10cSrcweir }
912cdf0e10cSrcweir }
913cdf0e10cSrcweir
impl_switchDiagramPositioningToExcludingPositioning()914cdf0e10cSrcweir void ChartController::impl_switchDiagramPositioningToExcludingPositioning()
915cdf0e10cSrcweir {
916cdf0e10cSrcweir UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription(
917cdf0e10cSrcweir ActionDescriptionProvider::POS_SIZE,
918cdf0e10cSrcweir ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)),
919cdf0e10cSrcweir m_xUndoManager );
920cdf0e10cSrcweir if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) )
921cdf0e10cSrcweir aUndoGuard.commit();
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir } // namespace chart
925