Files
loongoffice/chart2/source/controller/main/ChartController_Insert.cxx
Kurt Zenker 921ff4b99a CWS-TOOLING: integrate CWS chartuseability01
2009-09-07 17:26:44 +0200 iha  r275906 : CWS-TOOLING: rebase CWS chartuseability01 to trunk@275801 (milestone: DEV300:m57)
2009-08-27 13:48:16 +0200 iha  r275481 : #7049# listbox to select chart elements
2009-08-27 11:54:53 +0200 iha  r275464 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-26 16:49:58 +0200 iha  r275435 : #i102820# added missing case 'floor'
2009-08-26 15:33:51 +0200 iha  r275427 : #i102820# make 'insert legend' work properly
2009-08-25 16:35:00 +0200 ufi  r275369 : i104087
2009-08-25 15:12:17 +0200 iha  r275360 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 15:11:31 +0200 iha  r275359 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 15:11:15 +0200 iha  r275358 : #i104087# 'Object Properties' -> 'Format Selection'
2009-08-25 11:57:43 +0200 iha  r275344 : #i104087# changed behavior of insert menu
2009-08-18 12:53:54 +0200 oc  r275093 : #i104082,104086,104089# multiple changes because of changed chartUI
2009-08-10 16:46:17 +0200 ufi  r274824 : i104083 i104087 i104090
2009-08-07 14:04:34 +0200 iha  r274763 : #7049# listbox to select chart elements
2009-08-07 13:06:05 +0200 iha  r274760 : #7049# listbox to select chart elements
2009-08-07 13:05:06 +0200 iha  r274759 : #7049# listbox to select chart elements
2009-08-07 12:32:31 +0200 iha  r274756 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-07 12:31:54 +0200 iha  r274755 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-06 19:00:48 +0200 iha  r274742 : #i103593# make insert menu behavior selection dependent
2009-08-06 19:00:14 +0200 iha  r274741 : #i103593# make insert menu behavior selection dependent
2009-08-06 15:34:01 +0200 iha  r274731 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-06 14:39:20 +0200 iha  r274728 : #i86146# ease adding R-squared value with an equation
2009-08-06 14:37:02 +0200 iha  r274727 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:37:54 +0200 iha  r274724 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:37:15 +0200 iha  r274723 : #i86146# ease adding R-squared value with an equation
2009-08-06 13:04:27 +0200 iha  r274722 : #i103593# make insert menu behavior selection dependent
2009-08-06 13:03:35 +0200 iha  r274721 : #i103593# make insert menu behavior selection dependent
2009-08-05 18:26:31 +0200 iha  r274693 : #i104033# inconsistent wording 'error indicator' <-> 'error bar'
2009-08-05 16:51:45 +0200 iha  r274688 : #i104028# rename font tabpage 'Characters'->'Font'
2009-08-05 16:30:21 +0200 iha  r274685 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:34:11 +0200 iha  r274680 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:32:43 +0200 iha  r274679 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:31:26 +0200 iha  r274678 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:17:51 +0200 iha  r274676 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 15:16:22 +0200 iha  r274675 : #i58163# #i69422# #i102820# enhance chart context menu
2009-08-05 14:58:59 +0200 iha  r274674 : #7049# listbox to select chart elements
2009-08-05 14:33:54 +0200 iha  r274669 : #7049# listbox to select chart elements
2009-08-05 14:22:17 +0200 iha  r274665 : #7049# listbox to select chart elements
2009-08-05 13:21:05 +0200 iha  r274656 : #i102820# offer insertion of several elements in context menu also if nothing is selected
2009-08-05 11:56:06 +0200 iha  r274647 : #7049# listbox to select chart elements
2009-08-05 11:43:40 +0200 iha  r274645 : #7049# listbox to select chart elements
2009-07-24 19:46:50 +0200 iha  r274318 : #i58163# #i69422# #i102820# enhance chart context menu
2009-07-24 16:23:13 +0200 iha  r274313 : #i58163# #i69422# #i102820# enhance chart context menu
2009-07-24 16:13:22 +0200 iha  r274311 : #i58163# #i69422# #i102820# enhance chart context menu
2009-09-11 16:06:18 +00:00

950 lines
37 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: ChartController_Insert.cxx,v $
* $Revision: 1.16.44.1 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "ChartController.hxx"
#include "dlg_InsertAxis_Grid.hxx"
#include "dlg_InsertDataLabel.hxx"
#include "dlg_InsertLegend.hxx"
#include "dlg_InsertTrendline.hxx"
#include "dlg_InsertErrorBars.hxx"
#include "dlg_InsertTitle.hxx"
#include "dlg_ObjectProperties.hxx"
#include "ChartWindow.hxx"
#include "ChartModelHelper.hxx"
#include "AxisHelper.hxx"
#include "TitleHelper.hxx"
#include "DiagramHelper.hxx"
#include "macros.hxx"
#include "chartview/DrawModelWrapper.hxx"
#include "chartview/NumberFormatterWrapper.hxx"
#include "ViewElementListProvider.hxx"
#include "MultipleChartConverters.hxx"
#include "ControllerLockGuard.hxx"
#include "UndoGuard.hxx"
#include "ResId.hxx"
#include "Strings.hrc"
#include "ReferenceSizeProvider.hxx"
#include "ObjectIdentifier.hxx"
#include "RegressionCurveHelper.hxx"
#include "RegressionCurveItemConverter.hxx"
#include "StatisticsHelper.hxx"
#include "ErrorBarItemConverter.hxx"
#include "MultipleItemConverter.hxx"
#include "DataSeriesHelper.hxx"
#include "ObjectNameProvider.hxx"
#include "LegendHelper.hxx"
#include <com/sun/star/chart2/XRegressionCurve.hpp>
#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <svx/ActionDescriptionProvider.hxx>
//--------------------------------------
// header for define RET_OK
#include <vcl/msgbox.hxx>
// header for class OUStringBuffer
#include <rtl/ustrbuf.hxx>
// header for class Application
#include <vcl/svapp.hxx>
// header for class ::vos::OGuard
#include <vos/mutex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::rtl::OUString;
//.............................................................................
namespace
{
struct lcl_InsertMeanValueLine
{
public:
lcl_InsertMeanValueLine( const uno::Reference< uno::XComponentContext > & xContext ) :
m_xContext( xContext )
{}
void operator()( const uno::Reference< chart2::XDataSeries > & xSeries )
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
xSeries, uno::UNO_QUERY );
if( xRegCurveCnt.is())
{
::chart::RegressionCurveHelper::addMeanValueLine(
xRegCurveCnt, m_xContext, uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ));
}
}
private:
uno::Reference< uno::XComponentContext > m_xContext;
};
} // anonymous namespace
//.............................................................................
namespace chart
{
//.............................................................................
void ChartController::executeDispatch_InsertAxes()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))),
m_xUndoManager, m_aModel->getModel() );
try
{
InsertAxisOrGridDialogData aDialogInput;
uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(m_aModel->getModel());
AxisHelper::getAxisOrGridExcistence( aDialogInput.aExistenceList, xDiagram, sal_True );
AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, sal_True );
::vos::OGuard aGuard( Application::GetSolarMutex());
SchAxisDlg aDlg( m_pChartWindow, aDialogInput );
if( aDlg.Execute() == RET_OK )
{
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
InsertAxisOrGridDialogData aDialogOutput;
aDlg.getResult( aDialogOutput );
::std::auto_ptr< ReferenceSizeProvider > mpRefSizeProvider(
impl_createReferenceSizeProvider());
bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram
, aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC
, mpRefSizeProvider.get() );
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))),
m_xUndoManager, m_aModel->getModel() );
try
{
InsertAxisOrGridDialogData aDialogInput;
uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(m_aModel->getModel());
AxisHelper::getAxisOrGridExcistence( aDialogInput.aExistenceList, xDiagram, sal_False );
AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, sal_False );
::vos::OGuard aGuard( Application::GetSolarMutex());
SchGridDlg aDlg( m_pChartWindow, aDialogInput );//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY );
if( aDlg.Execute() == RET_OK )
{
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
InsertAxisOrGridDialogData aDialogOutput;
aDlg.getResult( aDialogOutput );
bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram
, aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC );
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void ChartController::executeDispatch_InsertTitles()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))),
m_xUndoManager, m_aModel->getModel() );
try
{
TitleDialogData aDialogInput;
aDialogInput.readFromModel( m_aModel->getModel() );
::vos::OGuard aGuard( Application::GetSolarMutex());
SchTitleDlg aDlg( m_pChartWindow, aDialogInput );
if( aDlg.Execute() == RET_OK )
{
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
TitleDialogData aDialogOutput( impl_createReferenceSizeProvider());
aDlg.getResult( aDialogOutput );
bool bChanged = aDialogOutput.writeDifferenceToModel( m_aModel->getModel(), m_xCC, &aDialogInput );
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_DeleteLegend()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
m_xUndoManager, m_aModel->getModel() );
LegendHelper::hideLegend( m_aModel->getModel() );
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_InsertLegend()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
m_xUndoManager, m_aModel->getModel() );
Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( m_aModel->getModel(), m_xCC );
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_OpenLegendDialog()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))),
m_xUndoManager, m_aModel->getModel() );
try
{
//prepare and open dialog
::vos::OGuard aGuard( Application::GetSolarMutex());
SchLegendDlg aDlg( m_pChartWindow, m_xCC );
aDlg.init( m_aModel->getModel() );
if( aDlg.Execute() == RET_OK )
{
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel() );
bool bChanged = aDlg.writeToModel( m_aModel->getModel() );
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void ChartController::executeDispatch_InsertMenu_DataLabels()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
m_xUndoManager, m_aModel->getModel() );
//if a series is selected insert labels for that series only:
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
{
// add labels
DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries );
rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) );
aChildParticle+=(C2U("="));
rtl::OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles(
ObjectIdentifier::getSeriesParticleFromCID(m_aSelection.getSelectedCID()), aChildParticle );
bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true );
if( bSuccess )
aUndoGuard.commitAction();
return;
}
try
{
wrapper::AllDataLabelItemConverter aItemConverter(
m_aModel->getModel(),
m_pDrawModelWrapper->GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY ));
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
//prepare and open dialog
::vos::OGuard aGuard( Application::GetSolarMutex());
//get number formatter
uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_aModel->getModel(), uno::UNO_QUERY );
NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier );
SvNumberFormatter* pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter();
DataLabelsDialog aDlg( m_pChartWindow, aItemSet, pNumberFormatter);
if( aDlg.Execute() == RET_OK )
{
SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet();
aDlg.FillItemSet( aOutItemSet );
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertMenu_YErrorBars()
{
//if a series is selected insert error bars for that series only:
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is())
{
executeDispatch_InsertYErrorBars();
return;
}
//if no series is selected insert error bars for all series
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ),
m_xUndoManager, m_aModel->getModel() );
try
{
wrapper::AllSeriesStatisticsConverter aItemConverter(
m_aModel->getModel(), m_pDrawModelWrapper->GetItemPool() );
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
//prepare and open dialog
::vos::OGuard aGuard( Application::GetSolarMutex());
InsertErrorBarsDialog aDlg(
m_pChartWindow, aItemSet,
uno::Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY ));
aDlg.SetAxisMinorStepWidthForErrorBarDecimals(
InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, rtl::OUString() ) );
if( aDlg.Execute() == RET_OK )
{
SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet();
aDlg.FillItemSet( aOutItemSet );
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertMeanValue()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
m_xUndoManager, m_aModel->getModel());
lcl_InsertMeanValueLine( m_xCC ).operator()(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()));
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_InsertMenu_MeanValues()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
m_xUndoManager, m_aModel->getModel() );
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
{
//if a series is selected insert mean value only for that series:
lcl_InsertMeanValueLine( m_xCC ).operator()(xSeries);
}
else
{
::std::vector< uno::Reference< chart2::XDataSeries > > aSeries(
DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( m_aModel->getModel())));
::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC ));
}
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_InsertMenu_Trendlines()
{
//if a series is selected insert only for that series:
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is())
{
executeDispatch_InsertTrendline();
return;
}
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ),
m_xUndoManager, m_aModel->getModel() );
try
{
wrapper::AllSeriesStatisticsConverter aItemConverter(
m_aModel->getModel(), m_pDrawModelWrapper->GetItemPool() );
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
//prepare and open dialog
::vos::OGuard aGuard( Application::GetSolarMutex());
InsertTrendlineDialog aDlg( m_pChartWindow, aItemSet );
aDlg.adjustSize();
if( aDlg.Execute() == RET_OK )
{
SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet();
aDlg.FillItemSet( aOutItemSet );
// lock controllers till end of block
ControllerLockGuard aCLGuard( m_aModel->getModel());
bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now
if( bChanged )
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertTrendline()
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xRegCurveCnt.is())
{
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
m_xUndoManager, m_aModel->getModel() );
// add a linear curve
RegressionCurveHelper::addRegressionCurve(
RegressionCurveHelper::REGRESSION_TYPE_LINEAR, xRegCurveCnt, m_xCC );
// get an appropriate item converter
uno::Reference< chart2::XRegressionCurve > xCurve(
RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ));
uno::Reference< beans::XPropertySet > xCurveProp( xCurve, uno::UNO_QUERY );
if( !xCurveProp.is())
return;
wrapper::RegressionCurveItemConverter aItemConverter(
xCurveProp, xRegCurveCnt, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY ));
// open dialog
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter(
ObjectIdentifier::createDataCurveCID(
ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()),
RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, xCurve ), false ));
aDialogParameter.init( m_aModel->getModel() );
ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
::vos::OGuard aGuard( Application::GetSolarMutex());
SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider,
uno::Reference< util::XNumberFormatsSupplier >( m_aModel->getModel(), uno::UNO_QUERY ));
// note: when a user pressed "OK" but didn't change any settings in the
// dialog, the SfxTabDialog returns "Cancel"
if( aDlg.Execute() == RET_OK || aDlg.DialogWasClosedWithOK())
{
const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet();
if( pOutItemSet )
{
ControllerLockGuard aCLGuard( m_aModel->getModel());
aItemConverter.ApplyItemSet( *pOutItemSet );
}
aUndoGuard.commitAction();
}
}
}
void ChartController::executeDispatch_InsertYErrorBars()
{
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is())
{
UndoLiveUpdateGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))),
m_xUndoManager, m_aModel->getModel() );
// add error bars with standard deviation
uno::Reference< beans::XPropertySet > xErrorBarProp(
StatisticsHelper::addErrorBars( xSeries, m_xCC, ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION ));
// get an appropriate item converter
wrapper::ErrorBarItemConverter aItemConverter(
m_aModel->getModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(),
m_pDrawModelWrapper->getSdrModel(),
uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY ));
// open dialog
SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet();
aItemConverter.FillItemSet( aItemSet );
ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter(
ObjectIdentifier::createClassifiedIdentifierWithParent(
OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), m_aSelection.getSelectedCID()));
aDialogParameter.init( m_aModel->getModel() );
ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get());
::vos::OGuard aGuard( Application::GetSolarMutex());
SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider,
uno::Reference< util::XNumberFormatsSupplier >( m_aModel->getModel(), uno::UNO_QUERY ));
aDlg.SetAxisMinorStepWidthForErrorBarDecimals(
InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, m_aSelection.getSelectedCID()));
// note: when a user pressed "OK" but didn't change any settings in the
// dialog, the SfxTabDialog returns "Cancel"
if( aDlg.Execute() == RET_OK || aDlg.DialogWasClosedWithOK())
{
const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet();
if( pOutItemSet )
{
ControllerLockGuard aCLGuard( m_aModel->getModel());
aItemConverter.ApplyItemSet( *pOutItemSet );
}
aUndoGuard.commitAction();
}
}
}
void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 )
{
uno::Reference< chart2::XRegressionCurve > xRegCurve(
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( !xRegCurve.is() )
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) );
}
if( xRegCurve.is())
{
uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties());
if( xEqProp.is())
{
// using assignment for broken gcc 3.3
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
m_xUndoManager, m_aModel->getModel() );
xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true ));
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 ));
aUndoGuard.commitAction();
}
}
}
void ChartController::executeDispatch_InsertR2Value()
{
uno::Reference< beans::XPropertySet > xEqProp(
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xEqProp.is())
{
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
m_xUndoManager, m_aModel->getModel() );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true ));
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteR2Value()
{
uno::Reference< beans::XPropertySet > xEqProp(
ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xEqProp.is())
{
UndoGuard aUndoGuard = UndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
m_xUndoManager, m_aModel->getModel() );
xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false ));
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteMeanValue()
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))),
m_xUndoManager, m_aModel->getModel());
RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteTrendline()
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
m_xUndoManager, m_aModel->getModel());
RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteTrendlineEquation()
{
uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xRegCurveCnt.is())
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))),
m_xUndoManager, m_aModel->getModel());
RegressionCurveHelper::removeEquations( xRegCurveCnt );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteYErrorBars()
{
uno::Reference< chart2::XDataSeries > xDataSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()));
if( xDataSeries.is())
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))),
m_xUndoManager, m_aModel->getModel());
StatisticsHelper::removeErrorBars( xDataSeries );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_InsertDataLabels()
{
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
m_xUndoManager, m_aModel->getModel() );
DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_InsertDataLabel()
{
UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT,
::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))),
m_xUndoManager, m_aModel->getModel() );
DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) );
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_DeleteDataLabels()
{
uno::Reference< chart2::XDataSeries > xSeries(
ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))),
m_xUndoManager, m_aModel->getModel());
DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries );
aUndoGuard.commitAction();
}
}
void ChartController::executeDispatch_DeleteDataLabel()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE,
::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))),
m_xUndoManager, m_aModel->getModel());
DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) );
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_ResetAllDataPoints()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT,
::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))),
m_xUndoManager, m_aModel->getModel());
uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
xSeries->resetAllDataPoints();
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_ResetDataPoint()
{
UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT,
::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))),
m_xUndoManager, m_aModel->getModel());
uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY );
if( xSeries.is() )
{
sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() );
xSeries->resetDataPoint( nPointIndex );
}
aUndoGuard.commitAction();
}
void ChartController::executeDispatch_InsertAxisTitle()
{
try
{
uno::Reference< XTitle > xTitle;
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))),
m_xUndoManager, m_aModel->getModel() );
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
sal_Int32 nDimensionIndex = -1;
sal_Int32 nCooSysIndex = -1;
sal_Int32 nAxisIndex = -1;
AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(m_aModel->getModel()), nCooSysIndex, nDimensionIndex, nAxisIndex );
TitleHelper::eTitleType eTitleType = TitleHelper::X_AXIS_TITLE;
if( nDimensionIndex==0 )
eTitleType = nAxisIndex==0 ? TitleHelper::X_AXIS_TITLE : TitleHelper::SECONDARY_X_AXIS_TITLE;
else if( nDimensionIndex==1 )
eTitleType = nAxisIndex==0 ? TitleHelper::Y_AXIS_TITLE : TitleHelper::SECONDARY_Y_AXIS_TITLE;
else
eTitleType = TitleHelper::Z_AXIS_TITLE;
::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider());
xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), m_aModel->getModel(), m_xCC, apRefSizeProvider.get() );
aUndoGuard.commitAction();
}
/*
if( xTitle.is() )
{
OUString aTitleCID = ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_aModel->getModel() );
select( uno::makeAny(aTitleCID) );
executeDispatch_EditText();
}
*/
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertAxis()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
AxisHelper::makeAxisVisible( xAxis );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_DeleteAxis()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
AxisHelper::makeAxisInvisible( xAxis );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertMajorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
AxisHelper::makeGridVisible( xAxis->getGridProperties() );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_DeleteMajorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
AxisHelper::makeGridInvisible( xAxis->getGridProperties() );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_InsertMinorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++)
AxisHelper::makeGridVisible( aSubGrids[nN] );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
void ChartController::executeDispatch_DeleteMinorGrid()
{
UndoGuard aUndoGuard(
ActionDescriptionProvider::createDescription(
ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))),
m_xUndoManager, m_aModel->getModel() );
try
{
Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() );
if( xAxis.is() )
{
Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );
for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++)
AxisHelper::makeGridInvisible( aSubGrids[nN] );
aUndoGuard.commitAction();
}
}
catch( uno::RuntimeException& e)
{
ASSERT_EXCEPTION( e );
}
}
//.............................................................................
} //namespace chart
//.............................................................................