summaryrefslogtreecommitdiff
path: root/chart2/source/controller/main/ChartController.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/main/ChartController.cxx')
-rw-r--r--chart2/source/controller/main/ChartController.cxx626
1 files changed, 312 insertions, 314 deletions
diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx
index 5a25f761e896..5f013d759351 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -22,22 +22,22 @@
#include <config_wasm_strip.h>
#include <ChartController.hxx>
+#include <ChartView.hxx>
#include <servicenames.hxx>
#include <ResId.hxx>
#include <dlg_DataSource.hxx>
#include <ChartModel.hxx>
-#include <ChartModelHelper.hxx>
-#include "ControllerCommandDispatch.hxx"
+#include <ChartType.hxx>
+#include <ControllerCommandDispatch.hxx>
+#include <DataSeries.hxx>
#include <Diagram.hxx>
#include <strings.hrc>
-#include <chartview/ExplicitValueProvider.hxx>
#include <ChartViewHelper.hxx>
#include <ChartWindow.hxx>
#include <chartview/DrawModelWrapper.hxx>
#include <DrawViewWrapper.hxx>
#include <ObjectIdentifier.hxx>
-#include <DiagramHelper.hxx>
#include <ControllerLockGuard.hxx>
#include "UndoGuard.hxx"
#include "ChartDropTargetHelper.hxx"
@@ -51,42 +51,39 @@
#include "UndoActions.hxx"
#include <ViewElementListProvider.hxx>
-#include <cppuhelper/supportsservice.hxx>
-#include <comphelper/servicehelper.hxx>
+#include <comphelper/dispatchcommand.hxx>
#include <BaseCoordinateSystem.hxx>
-#include <com/sun/star/awt/XWindowPeer.hpp>
-#include <com/sun/star/chart2/XChartDocument.hpp>
-#include <com/sun/star/chart2/data/XDataReceiver.hpp>
#include <com/sun/star/frame/XController2.hpp>
#include <com/sun/star/util/CloseVetoException.hpp>
-#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
-#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/frame/LayoutManagerEvents.hpp>
#include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
-#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#include <com/sun/star/ui/XSidebar.hpp>
-#include <com/sun/star/chart2/XChartTypeContainer.hpp>
-#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XDataProviderAccess.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <sal/log.hxx>
#include <tools/debug.hxx>
#include <svx/sidebar/SelectionChangeHandler.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <utility>
+#include <vcl/dndlistenercontainer.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
#include <osl/mutex.hxx>
+#include <comphelper/lok.hxx>
#include <sfx2/sidebar/SidebarController.hxx>
-
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
// this is needed to properly destroy the unique_ptr to the AcceleratorExecute
// object in the DTOR
#include <svtools/acceleratorexecute.hxx>
#include <svx/ActionDescriptionProvider.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
+
+#include <editeng/fontitem.hxx>
// enable the following define to let the controller listen to model changes and
// react on this by rebuilding the view
@@ -101,10 +98,10 @@ using namespace ::com::sun::star::chart2;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
-ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext) :
+ChartController::ChartController(uno::Reference<uno::XComponentContext> xContext) :
m_aLifeTimeManager( nullptr ),
m_bSuspended( false ),
- m_xCC(xContext),
+ m_xCC(std::move(xContext)),
m_aModel( nullptr, m_aModelMutex ),
m_eDragMode(SdrDragMode::Move),
m_aDoubleClickTimer("chart2 ChartController m_aDoubleClickTimer"),
@@ -127,8 +124,8 @@ ChartController::~ChartController()
stopDoubleClickWaiting();
}
-ChartController::TheModel::TheModel( const rtl::Reference<::chart::ChartModel> & xModel ) :
- m_xModel( xModel ),
+ChartController::TheModel::TheModel( rtl::Reference<::chart::ChartModel> xModel ) :
+ m_xModel(std::move( xModel )),
m_bOwnership( true )
{
}
@@ -231,20 +228,17 @@ bool ChartController::TheModelRef::is() const
namespace {
-css::uno::Reference<css::chart2::XChartType> getChartType(
- const rtl::Reference<ChartModel>& xChartDoc)
+rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& xChartDoc)
{
rtl::Reference<Diagram > xDiagram = xChartDoc->getFirstChartDiagram();
if (!xDiagram.is())
- return css::uno::Reference<css::chart2::XChartType>();
+ return nullptr;
const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems());
if (xCooSysSequence.empty())
- return css::uno::Reference<css::chart2::XChartType>();
-
- Sequence< Reference< chart2::XChartType > > xChartTypeSequence( xCooSysSequence[0]->getChartTypes() );
+ return nullptr;
- return xChartTypeSequence[0];
+ return xCooSysSequence[0]->getChartTypes2()[0];
}
}
@@ -256,42 +250,49 @@ OUString ChartController::GetContextName()
uno::Any aAny = getSelection();
if (!aAny.hasValue())
- return "Chart";
+ return u"Chart"_ustr;
OUString aCID;
aAny >>= aCID;
if (aCID.isEmpty())
- return "Chart";
+ return u"Chart"_ustr;
ObjectType eObjectID = ObjectIdentifier::getObjectType(aCID);
switch (eObjectID)
{
case OBJECTTYPE_DATA_SERIES:
- return "Series";
+ return u"Series"_ustr;
case OBJECTTYPE_DATA_ERRORS_X:
case OBJECTTYPE_DATA_ERRORS_Y:
case OBJECTTYPE_DATA_ERRORS_Z:
- return "ErrorBar";
+ return u"ErrorBar"_ustr;
case OBJECTTYPE_AXIS:
- return "Axis";
+ return u"Axis"_ustr;
case OBJECTTYPE_GRID:
- return "Grid";
+ return u"Grid"_ustr;
case OBJECTTYPE_DIAGRAM:
{
- css::uno::Reference<css::chart2::XChartType> xChartType = getChartType(getChartModel());
+ rtl::Reference<ChartType> xChartType = getChartType(getChartModel());
if (xChartType.is() && xChartType->getChartType() == "com.sun.star.chart2.PieChartType")
- return "ChartElements";
+ return u"ChartElements"_ustr;
break;
}
case OBJECTTYPE_DATA_CURVE:
case OBJECTTYPE_DATA_AVERAGE_LINE:
- return "Trendline";
+ return u"Trendline"_ustr;
+ case OBJECTTYPE_TITLE:
+ return u"ChartTitle"_ustr;
+ case OBJECTTYPE_LEGEND:
+ return u"ChartLegend"_ustr;
+ case OBJECTTYPE_DATA_LABEL:
+ case OBJECTTYPE_DATA_LABELS:
+ return u"ChartLabel"_ustr;
default:
break;
}
- return "Chart";
+ return u"Chart"_ustr;
}
// private methods
@@ -309,27 +310,6 @@ bool ChartController::impl_isDisposedOrSuspended() const
return false;
}
-// lang::XServiceInfo
-
-OUString SAL_CALL ChartController::getImplementationName()
-{
- return CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME;
-}
-
-sal_Bool SAL_CALL ChartController::supportsService( const OUString& rServiceName )
-{
- return cppu::supportsService(this, rServiceName);
-}
-
-css::uno::Sequence< OUString > SAL_CALL ChartController::getSupportedServiceNames()
-{
- return {
- CHART_CONTROLLER_SERVICE_NAME,
- "com.sun.star.frame.Controller"
- //// @todo : add additional services if you support any further
- };
-}
-
namespace {
uno::Reference<ui::XSidebar> getSidebarFromModel(const uno::Reference<frame::XModel>& xModel)
@@ -365,19 +345,6 @@ void SAL_CALL ChartController::attachFrame(
if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended?
return; //behave passive if already disposed or suspended
- mpSelectionChangeHandler->Connect();
-
- uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
- if (xSidebar.is())
- {
- auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
- assert(pSidebar);
- sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this);
- pSidebar->updateModel(getModel());
- css::lang::EventObject aEvent;
- mpSelectionChangeHandler->selectionChanged(aEvent);
- }
-
if(m_xFrame.is()) //what happens, if we do have a Frame already??
{
//@todo? throw exception?
@@ -388,6 +355,20 @@ void SAL_CALL ChartController::attachFrame(
//--attach frame
m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent
+ // Only notify after setting the frame, otherwise notification will fail
+ mpSelectionChangeHandler->Connect();
+
+ uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel());
+ if (xSidebar.is())
+ {
+ auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+ assert(pSidebar);
+ pSidebar->registerSidebarForFrame(this);
+ pSidebar->updateModel(getChartModel());
+ css::lang::EventObject aEvent;
+ mpSelectionChangeHandler->selectionChanged(aEvent);
+ }
+
//add as disposelistener to the frame (due to persistent reference) ??...:
//the frame is considered to be owner of this controller and will live longer than we do
@@ -429,23 +410,23 @@ void SAL_CALL ChartController::attachFrame(
try
{
uno::Reference< css::frame::XLayoutManager > xLayoutManager;
- xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager;
+ xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager;
if ( xLayoutManager.is() )
{
xLayoutManager->lock();
- xLayoutManager->requestElement( "private:resource/menubar/menubar" );
+ xLayoutManager->requestElement( u"private:resource/menubar/menubar"_ustr );
//@todo: createElement should become unnecessary, remove when #i79198# is fixed
- xLayoutManager->createElement( "private:resource/toolbar/standardbar" );
- xLayoutManager->requestElement( "private:resource/toolbar/standardbar" );
+ xLayoutManager->createElement( u"private:resource/toolbar/standardbar"_ustr );
+ xLayoutManager->requestElement( u"private:resource/toolbar/standardbar"_ustr );
//@todo: createElement should become unnecessary, remove when #i79198# is fixed
- xLayoutManager->createElement( "private:resource/toolbar/toolbar" );
- xLayoutManager->requestElement( "private:resource/toolbar/toolbar" );
+ xLayoutManager->createElement( u"private:resource/toolbar/toolbar"_ustr );
+ xLayoutManager->requestElement( u"private:resource/toolbar/toolbar"_ustr );
// #i12587# support for shapes in chart
- xLayoutManager->createElement( "private:resource/toolbar/drawbar" );
- xLayoutManager->requestElement( "private:resource/toolbar/drawbar" );
+ xLayoutManager->createElement( u"private:resource/toolbar/drawbar"_ustr );
+ xLayoutManager->requestElement( u"private:resource/toolbar/drawbar"_ustr );
- xLayoutManager->requestElement( "private:resource/statusbar/statusbar" );
+ xLayoutManager->requestElement( u"private:resource/statusbar/statusbar"_ustr );
xLayoutManager->unlock();
// add as listener to get notified when
@@ -499,23 +480,18 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent
GetDrawModelWrapper();
if(m_pDrawModelWrapper)
{
- {
- if( m_pDrawViewWrapper )
- m_pDrawViewWrapper->ReInit();
- }
+ if( m_pDrawViewWrapper )
+ m_pDrawViewWrapper->ReInit();
//reselect object
if( m_aSelection.hasSelection() )
this->impl_selectObjectAndNotiy();
else
- ChartModelHelper::triggerRangeHighlighting( getChartModel() );
+ getChartModel()->triggerRangeHighlighting();
impl_initializeAccessible();
- {
- if( pChartWindow )
- pChartWindow->Invalidate();
- }
+ pChartWindow->Invalidate();
}
m_bConnectingToView = false;
@@ -546,9 +522,8 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
//--handle relations to the old model if any
if( aOldModelRef.is() )
{
- uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
- if( xViewBroadcaster.is() )
- xViewBroadcaster->removeModeChangeListener(this);
+ if( m_xChartView.is() )
+ m_xChartView->removeModeChangeListener(this);
m_pDrawModelWrapper.reset();
aOldModelRef->removeListener( this );
@@ -568,9 +543,9 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
pDispatch->initialize();
// the dispatch container will return "this" for all commands returned by
- // impl_getAvailableCommands(). That means, for those commands dispatch()
- // is called here at the ChartController.
- m_aDispatchContainer.setChartDispatch( pDispatch, o3tl::sorted_vector(impl_getAvailableCommands()) );
+ // impl_getAvailableCommands(), and also for which ControllerCommandDispatch::commandHandled()
+ // gives true. That means, for those commands dispatch() is called here at the ChartController.
+ m_aDispatchContainer.setChartDispatch( pDispatch, impl_getAvailableCommands() );
rtl::Reference<DrawCommandDispatch> pDrawDispatch = new DrawCommandDispatch( m_xCC, this );
pDrawDispatch->initialize();
@@ -590,14 +565,12 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
// select chart area per default:
// select( uno::Any( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ) );
- uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
+ rtl::Reference< ChartModel > xFact = getChartModel();
if( xFact.is())
{
- m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME );
+ m_xChartView = xFact->createChartView();
GetDrawModelWrapper();
- uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
- if( xViewBroadcaster.is() )
- xViewBroadcaster->addModeChangeListener(this);
+ m_xChartView->addModeChangeListener(this);
}
//the frameloader is responsible to call xModel->connectController
@@ -608,8 +581,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo
pChartWindow->Invalidate();
}
- uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
- m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW );
+ m_xUndoManager.set( getChartModel()->getUndoManager(), uno::UNO_SET_THROW );
return true;
}
@@ -642,7 +614,7 @@ rtl::Reference<::chart::ChartModel> ChartController::getChartModel()
rtl::Reference<::chart::Diagram> ChartController::getFirstDiagram()
{
- return ChartModelHelper::findDiagram( getChartModel() );
+ return getChartModel()->getFirstChartDiagram();
}
uno::Any SAL_CALL ChartController::getViewData()
@@ -698,6 +670,24 @@ sal_Bool SAL_CALL ChartController::suspend( sal_Bool bSuspend )
return true;
}
+// css::frame::XController2
+
+css::uno::Reference<css::awt::XWindow> SAL_CALL ChartController::getComponentWindow()
+{
+ // it is a special characteristic of ChartController
+ // that it simultaneously provides the XWindow functionality
+ return this;
+}
+
+OUString SAL_CALL ChartController::getViewControllerName() { return {}; }
+
+css::uno::Sequence<css::beans::PropertyValue> SAL_CALL ChartController::getCreationArguments()
+{
+ return {};
+}
+
+css::uno::Reference<css::ui::XSidebarProvider> SAL_CALL ChartController::getSidebar() { return {}; }
+
void ChartController::impl_createDrawViewController()
{
SolarMutexGuard aGuard;
@@ -705,8 +695,21 @@ void ChartController::impl_createDrawViewController()
{
if( m_pDrawModelWrapper )
{
+ bool bLokCalcGlobalRTL = false;
+ if(comphelper::LibreOfficeKit::isActive() && AllSettings::GetLayoutRTL())
+ {
+ rtl::Reference< ChartModel > xChartModel = getChartModel();
+ if (xChartModel.is())
+ {
+ uno::Reference<css::sheet::XSpreadsheetDocument> xSSDoc(xChartModel->getParent(), uno::UNO_QUERY);
+ if (xSSDoc.is())
+ bLokCalcGlobalRTL = true;
+ }
+ }
+
m_pDrawViewWrapper.reset( new DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()->GetOutDev()) );
- m_pDrawViewWrapper->attachParentReferenceDevice( getModel() );
+ m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL);
+ m_pDrawViewWrapper->attachParentReferenceDevice( getChartModel() );
}
}
}
@@ -733,10 +736,10 @@ void SAL_CALL ChartController::dispose()
if (getModel().is())
{
- uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel());
+ uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel());
if (sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()))
{
- sfx2::sidebar::SidebarController::unregisterSidebarForFrame(pSidebar, this);
+ pSidebar->unregisterSidebarForFrame(this);
}
}
@@ -759,7 +762,7 @@ void SAL_CALL ChartController::dispose()
if( m_aModel.is())
{
uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener;
- uno::Reference< chart2::data::XDataReceiver > xDataReceiver( getModel(), uno::UNO_QUERY );
+ rtl::Reference< ChartModel > xDataReceiver = getChartModel();
if( xDataReceiver.is() )
xSelectionChangeListener.set( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY );
if( xSelectionChangeListener.is() )
@@ -772,9 +775,8 @@ void SAL_CALL ChartController::dispose()
//--release all resources and references
{
- uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY );
- if( xViewBroadcaster.is() )
- xViewBroadcaster->removeModeChangeListener(this);
+ if( m_xChartView.is() )
+ m_xChartView->removeModeChangeListener(this);
impl_invalidateAccessible();
SolarMutexGuard aSolarGuard;
@@ -793,7 +795,7 @@ void SAL_CALL ChartController::dispose()
if( m_xLayoutManagerEventBroadcaster.is())
{
m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this );
- m_xLayoutManagerEventBroadcaster.set( nullptr );
+ m_xLayoutManagerEventBroadcaster.clear();
}
m_xFrame.clear();
@@ -804,7 +806,7 @@ void SAL_CALL ChartController::dispose()
if( aModelRef.is())
{
- uno::Reference< frame::XModel > xModel( aModelRef->getModel() );
+ rtl::Reference< ChartModel > xModel( aModelRef->getModel() );
if(xModel.is())
xModel->disconnectController( uno::Reference< frame::XController >( this ));
@@ -839,12 +841,12 @@ void SAL_CALL ChartController::dispose()
void SAL_CALL ChartController::addEventListener(
const uno::Reference<lang::XEventListener>& xListener )
{
- SolarMutexGuard aGuard;
if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode?
return; //behave passive if already disposed or suspended
//--add listener
- m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.addInterface( aGuard2, xListener );
}
void SAL_CALL ChartController::removeEventListener(
@@ -855,7 +857,8 @@ void SAL_CALL ChartController::removeEventListener(
return; //behave passive if already disposed or suspended
//--remove listener
- m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener );
+ std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex);
+ m_aLifeTimeManager.m_aEventListeners.removeInterface( aGuard2, xListener );
}
// util::XCloseListener
@@ -936,7 +939,7 @@ void SAL_CALL ChartController::disposing(
if( !impl_releaseThisModel( rSource.Source ))
{
if( rSource.Source == m_xLayoutManagerEventBroadcaster )
- m_xLayoutManagerEventBroadcaster.set( nullptr );
+ m_xLayoutManagerEventBroadcaster.clear();
}
}
@@ -950,8 +953,8 @@ void SAL_CALL ChartController::layoutEvent(
Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY );
if( xLM.is())
{
- xLM->createElement( "private:resource/statusbar/statusbar" );
- xLM->requestElement( "private:resource/statusbar/statusbar" );
+ xLM->createElement( u"private:resource/statusbar/statusbar"_ustr );
+ xLM->requestElement( u"private:resource/statusbar/statusbar"_ustr );
}
}
}
@@ -1024,7 +1027,7 @@ uno::Reference<frame::XDispatch> SAL_CALL
if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() )
{
- if( !rTargetFrameName.isEmpty() && rTargetFrameName == "_self" )
+ if (rTargetFrameName.isEmpty() || rTargetFrameName == "_self")
return m_aDispatchContainer.getDispatchForURL( rURL );
}
return uno::Reference< frame::XDispatch > ();
@@ -1089,33 +1092,21 @@ void SAL_CALL ChartController::dispatch(
else if(aCommand == "FillColor")
{
if (rArgs.getLength() > 0)
- {
- sal_uInt32 nColor;
- if (rArgs[0].Value >>= nColor)
- this->executeDispatch_FillColor(nColor);
- }
+ executeDispatch_FillColor(rArgs[0].Value);
}
else if(aCommand == "XLineColor")
{
if (rArgs.getLength() > 0)
- {
- sal_Int32 nColor = -1;
- rArgs[0].Value >>= nColor;
- this->executeDispatch_LineColor(nColor);
- }
+ executeDispatch_LineColor(rArgs[0].Value);
}
else if(aCommand == "LineWidth")
{
if (rArgs.getLength() > 0)
- {
- sal_Int32 nWidth = -1;
- rArgs[0].Value >>= nWidth;
- this->executeDispatch_LineWidth(nWidth);
- }
+ executeDispatch_LineWidth(rArgs[0].Value);
}
else if(aCommand.startsWith("FillGradient"))
{
- this->executeDispatch_FillGradient(aCommand.copy(aCommand.indexOf('=') + 1));
+ this->executeDispatch_FillGradient(aCommand.subView(aCommand.indexOf('=') + 1));
}
else if(aCommand == "Paste")
this->executeDispatch_Paste();
@@ -1127,7 +1118,7 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_SourceData();
else if(aCommand == "Update" ) //Update Chart
{
- ChartViewHelper::setViewToDirtyState( getModel() );
+ ChartViewHelper::setViewToDirtyState( getChartModel() );
SolarMutexGuard aGuard;
auto pChartWindow(GetChartWindow());
if( pChartWindow )
@@ -1160,6 +1151,8 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_InsertErrorBars(false);
else if( aCommand == "InsertMenuYErrorBars" )
this->executeDispatch_InsertErrorBars(true);
+ else if( aCommand == "InsertMenuDataTable" )
+ this->executeDispatch_OpenInsertDataTableDialog();
else if( aCommand == "InsertSymbol" )
this->executeDispatch_InsertSpecialCharacter();
else if( aCommand == "InsertTrendline" )
@@ -1214,6 +1207,10 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_DeleteMajorGrid();
else if( aCommand == "DeleteMinorGrid" )
this->executeDispatch_DeleteMinorGrid();
+ else if( aCommand == "InsertDataTable" )
+ this->executeDispatch_InsertDataTable();
+ else if( aCommand == "DeleteDataTable" )
+ this->executeDispatch_DeleteDataTable();
//format objects
else if( aCommand == "FormatSelection" )
this->executeDispatch_ObjectProperties();
@@ -1228,7 +1225,9 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_PositionAndSize();
}
}
- else if( lcl_isFormatObjectCommand(aCommand) )
+ else if ( aCommand == "FontDialog" )
+ this->impl_ShapeControllerDispatch(rURL, rArgs);
+ else if (lcl_isFormatObjectCommand(aCommand))
this->executeDispatch_FormatObject(rURL.Path);
//more format
else if( aCommand == "DiagramType" )
@@ -1267,30 +1266,126 @@ void SAL_CALL ChartController::dispatch(
this->executeDispatch_ToggleGridVertical();
else if( aCommand == "ScaleText" )
this->executeDispatch_ScaleText();
- else if( aCommand == "StatusBarVisible" )
+ else if( aCommand == "Bold" || aCommand == "CharFontName" || aCommand == "FontHeight"
+ || aCommand == "Italic" || aCommand == "Underline" || aCommand == "Strikeout"
+ || aCommand == "Shadowed" || aCommand == "Color" || aCommand == "FontColor"
+ || aCommand == "Grow" || aCommand == "Shrink" || aCommand == "ResetAttributes"
+ || aCommand == "SuperScript" || aCommand == "SubScript"
+ || aCommand == "Spacing"
+ )
{
- // workaround: this should not be necessary.
- uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY );
- if( xPropSet.is() )
+ try
{
- uno::Reference< css::frame::XLayoutManager > xLayoutManager;
- xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager;
- if ( xLayoutManager.is() )
+ OUString aCID(m_aSelection.getSelectedCID());
+ rtl::Reference<::chart::ChartModel> xChartModel = getChartModel();
+ if (xChartModel.is())
{
- bool bIsVisible( xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" ));
- if( bIsVisible )
+ // if the selected is title... we should get the text properties instead...
+ // or the selected text properties
+ std::vector<Reference<beans::XPropertySet>> xProperties;
+ xProperties.emplace(xProperties.end(),
+ ObjectIdentifier::getObjectPropertySet(aCID, xChartModel));
+
+ if (ObjectIdentifier::getObjectType(aCID) == OBJECTTYPE_TITLE)
{
- xLayoutManager->hideElement( "private:resource/statusbar/statusbar" );
- xLayoutManager->destroyElement( "private:resource/statusbar/statusbar" );
+ Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY);
+ if (xTitle.is())
+ {
+ OutlinerView* pOutlinerView = nullptr;
+ if (m_pDrawViewWrapper)
+ {
+ pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView();
+ }
+ // if the Title is not in edit mode
+ if (!pOutlinerView)
+ {
+ const Sequence<Reference<chart2::XFormattedString>> aStrings(
+ xTitle->getText());
+ xProperties.pop_back();
+ for (int i = 0; i < aStrings.getLength(); i++)
+ {
+ Reference<beans::XPropertySet> xTitlePropSet(aStrings[i],
+ uno::UNO_QUERY);
+ xProperties.push_back(xTitlePropSet);
+ }
+ }
+ // Todo: implement the edit mode case here.
+ // the edited text attributes are a bit different from the properties
+ // SfxItemSet aItemSet = pOutlinerView->GetAttribs();
+ }
}
- else
+ bool bAllPropertiesExist = (xProperties.size() > 0);
+ for (std::size_t i = 0; i < xProperties.size(); i++)
{
- xLayoutManager->createElement( "private:resource/statusbar/statusbar" );
- xLayoutManager->showElement( "private:resource/statusbar/statusbar" );
+ if (!xProperties[i].is())
+ bAllPropertiesExist = false;
+ }
+ if (bAllPropertiesExist)
+ {
+ if (aCommand == "Bold")
+ {
+ executeDispatch_FontBold(xProperties);
+ }
+ else if (aCommand == "CharFontName")
+ {
+ executeDispatch_FontName(xProperties, rArgs);
+ }
+ else if (aCommand == "FontHeight")
+ {
+ executeDispatch_FontHeight(xProperties, rArgs);
+ }
+ else if (aCommand == "Italic")
+ {
+ executeDispatch_FontItalic(xProperties);
+ }
+ else if (aCommand == "Underline")
+ {
+ executeDispatch_FontUnderline(xProperties, rArgs);
+ }
+ else if (aCommand == "Strikeout")
+ {
+ executeDispatch_FontStrikeout(xProperties);
+ }
+ else if (aCommand == "Shadowed")
+ {
+ executeDispatch_FontShadowed(xProperties);
+ }
+ else if (aCommand == "Color" || aCommand == "FontColor")
+ {
+ executeDispatch_FontColor(xProperties, rArgs);
+ }
+ else if (aCommand == "Grow")
+ {
+ executeDispatch_FontGrow(xProperties);
+ }
+ else if (aCommand == "Shrink")
+ {
+ executeDispatch_FontShrink(xProperties);
+ }
+ else if (aCommand == "ResetAttributes")
+ {
+ executeDispatch_FontReset(xProperties);
+ }
+ else if (aCommand == "Spacing")
+ {
+ executeDispatch_FontSpacing(xProperties, rArgs);
+ }
+ else if (aCommand == "SuperScript")
+ {
+ executeDispatch_FontSuperScript(xProperties);
+ }
+ else if (aCommand == "SubScript")
+ {
+ executeDispatch_FontSubScript(xProperties);
+ }
}
- // @todo: update menu state (checkmark next to "Statusbar").
}
}
+ catch (const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("chart2");
+ }
+
}
}
@@ -1326,17 +1421,19 @@ void SAL_CALL ChartController::releaseContextMenuInterceptor(
void ChartController::executeDispatch_ChartType()
{
- UndoLiveUpdateGuard aUndoGuard(
- SchResId( STR_ACTION_EDIT_CHARTTYPE ), m_xUndoManager );
+ auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_CHARTTYPE),
+ m_xUndoManager);
SolarMutexGuard aSolarGuard;
//prepare and open dialog
- ChartTypeDialog aDlg(GetChartFrame(), getChartModel());
- if (aDlg.run() == RET_OK)
- {
- impl_adaptDataSeriesAutoResize();
- aUndoGuard.commit();
- }
+ auto aDlg = std::make_shared<ChartTypeDialog>(GetChartFrame(), getChartModel());
+ weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if (nResult == RET_OK)
+ {
+ impl_adaptDataSeriesAutoResize();
+ xUndoGuard->commit();
+ }
+ });
}
void ChartController::executeDispatch_SourceData()
@@ -1353,7 +1450,7 @@ void ChartController::executeDispatch_SourceData()
if ( rModel.hasInternalDataProvider() )
{
// Check if we will able to create data provider later
- css::uno::Reference< com::sun::star::chart2::XDataProviderAccess > xCreatorDoc(
+ css::uno::Reference< css::chart2::XDataProviderAccess > xCreatorDoc(
rModel.getParent(), uno::UNO_QUERY);
if (!xCreatorDoc.is())
return;
@@ -1378,17 +1475,17 @@ void ChartController::executeDispatch_SourceData()
rModel.attachDataProvider(xDataProvider);
}
}
-
- UndoLiveUpdateGuard aUndoGuard(
- SchResId(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager);
-
+ auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_DATA_RANGES),
+ m_xUndoManager);
SolarMutexGuard aSolarGuard;
- ::chart::DataSourceDialog aDlg(GetChartFrame(), xChartDoc, m_xCC);
- if (aDlg.run() == RET_OK)
- {
- impl_adaptDataSeriesAutoResize();
- aUndoGuard.commit();
- }
+ auto aDlg = std::make_shared<DataSourceDialog>(GetChartFrame(), xChartDoc);
+ weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) {
+ if (nResult == RET_OK)
+ {
+ impl_adaptDataSeriesAutoResize();
+ xUndoGuard->commit();
+ }
+ });
}
void ChartController::executeDispatch_MoveSeries( bool bForward )
@@ -1397,8 +1494,8 @@ void ChartController::executeDispatch_MoveSeries( bool bForward )
//get selected series
OUString aObjectCID(m_aSelection.getSelectedCID());
- uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels?
- aObjectCID, getChartModel() ) );
+ rtl::Reference< DataSeries > xGivenDataSeries = ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels?
+ aObjectCID, getChartModel() );
UndoGuardWithSelection aUndoGuard(
ActionDescriptionProvider::createDescription(
@@ -1406,7 +1503,7 @@ void ChartController::executeDispatch_MoveSeries( bool bForward )
SchResId(STR_OBJECT_DATASERIES)),
m_xUndoManager );
- bool bChanged = DiagramHelper::moveSeries( getFirstDiagram(), xGivenDataSeries, bForward );
+ bool bChanged = getFirstDiagram()->moveSeries( xGivenDataSeries, bForward );
if( bChanged )
{
m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) );
@@ -1414,38 +1511,6 @@ void ChartController::executeDispatch_MoveSeries( bool bForward )
}
}
-// ____ XMultiServiceFactory ____
-uno::Reference< uno::XInterface > SAL_CALL
- ChartController::createInstance( const OUString& aServiceSpecifier )
-{
- uno::Reference< uno::XInterface > xResult;
-
-#if !ENABLE_WASM_STRIP_ACCESSIBILITY
- if( aServiceSpecifier == CHART_ACCESSIBLE_TEXT_SERVICE_NAME )
- xResult.set( impl_createAccessibleTextContext());
-#else
- (void)aServiceSpecifier;
-#endif
-
- return xResult;
-}
-
-uno::Reference< uno::XInterface > SAL_CALL
- ChartController::createInstanceWithArguments(
- const OUString& ServiceSpecifier,
- const uno::Sequence< uno::Any >& /* Arguments */ )
-{
- // ignore Arguments
- return createInstance( ServiceSpecifier );
-}
-
-uno::Sequence< OUString > SAL_CALL
- ChartController::getAvailableServiceNames()
-{
- uno::Sequence< OUString > aServiceNames { CHART_ACCESSIBLE_TEXT_SERVICE_NAME };
- return aServiceNames;
-}
-
// ____ XModifyListener ____
void SAL_CALL ChartController::modified(
const lang::EventObject& /* aEvent */ )
@@ -1465,7 +1530,7 @@ void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoA
try
{
- const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW );
+ rtl::Reference< ChartModel > xSuppUndo = getChartModel();
const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW );
const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) );
xUndoManager->addUndoAction( xAction );
@@ -1480,9 +1545,8 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper()
{
if( !m_pDrawModelWrapper )
{
- ExplicitValueProvider* pProvider = comphelper::getFromUnoTunnel<ExplicitValueProvider>( m_xChartView );
- if( pProvider )
- m_pDrawModelWrapper = pProvider->getDrawModelWrapper();
+ if( m_xChartView )
+ m_pDrawModelWrapper = m_xChartView->getDrawModelWrapper();
if ( m_pDrawModelWrapper )
{
m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl(
@@ -1536,130 +1600,71 @@ void ChartController::SetAndApplySelection(const Reference<drawing::XShape>& rxS
}
}
-
-
-uno::Reference< XAccessible > ChartController::CreateAccessible()
+rtl::Reference<AccessibleChartView> ChartController::CreateAccessible()
{
#if !ENABLE_WASM_STRIP_ACCESSIBILITY
- uno::Reference< XAccessible > xResult = new AccessibleChartView( GetDrawViewWrapper() );
- impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) );
+ rtl::Reference< AccessibleChartView > xResult = new AccessibleChartView( GetDrawViewWrapper() );
+ impl_initializeAccessible( *xResult );
return xResult;
#else
- return uno::Reference< XAccessible >();
+ return {};
#endif
}
void ChartController::impl_invalidateAccessible()
{
+#if !ENABLE_WASM_STRIP_ACCESSIBILITY
SolarMutexGuard aGuard;
auto pChartWindow(GetChartWindow());
if( pChartWindow )
{
- Reference< lang::XInitialization > xInit( pChartWindow->GetAccessible(false), uno::UNO_QUERY );
- if(xInit.is())
+ rtl::Reference<comphelper::OAccessible> pAccessible = pChartWindow->GetAccessible(false);
+ if (pAccessible.is())
{
- uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible
- xInit->initialize(aArguments);
+ //empty arguments -> invalid accessible
+ dynamic_cast<AccessibleChartView&>(*pAccessible).initialize();
}
}
+#endif
}
void ChartController::impl_initializeAccessible()
{
+#if !ENABLE_WASM_STRIP_ACCESSIBILITY
SolarMutexGuard aGuard;
auto pChartWindow(GetChartWindow());
- if( pChartWindow )
- this->impl_initializeAccessible( Reference< lang::XInitialization >( pChartWindow->GetAccessible(false), uno::UNO_QUERY ) );
+ if( !pChartWindow )
+ return;
+ rtl::Reference<comphelper::OAccessible> pInit = pChartWindow->GetAccessible(false);
+ if (pInit.is())
+ impl_initializeAccessible(dynamic_cast<AccessibleChartView&>(*pInit));
+#endif
}
-void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit )
+#if !ENABLE_WASM_STRIP_ACCESSIBILITY
+void ChartController::impl_initializeAccessible( AccessibleChartView& rAccChartView )
{
- if(!xInit.is())
- return;
+ SolarMutexGuard aGuard;
uno::Reference< XAccessible > xParent;
- {
- SolarMutexGuard aGuard;
- auto pChartWindow(GetChartWindow());
- if( pChartWindow )
- {
- vcl::Window* pParentWin( pChartWindow->GetAccessibleParentWindow());
- if( pParentWin )
- xParent.set( pParentWin->GetAccessible());
- }
- }
- uno::Sequence< uno::Any > aArguments{ uno::Any(uno::Reference<view::XSelectionSupplier>(this)),
- uno::Any(getModel()),
- uno::Any(m_xChartView),
- uno::Any(xParent),
- uno::Any(m_xViewWindow) };
-
- xInit->initialize(aArguments);
-}
-
-const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommands()
-{
- static const o3tl::sorted_vector< OUString > s_AvailableCommands {
- // commands for container forward
- "AddDirect", "NewDoc", "Open",
- "Save", "SaveAs", "SendMail",
- "EditDoc", "ExportDirectToPDF", "PrintDefault",
-
- // own commands
- "Cut", "Copy", "Paste",
- "DataRanges", "DiagramData",
- // insert objects
- "InsertMenuTitles", "InsertTitles",
- "InsertMenuLegend", "InsertLegend", "DeleteLegend",
- "InsertMenuDataLabels",
- "InsertMenuAxes", "InsertRemoveAxes", "InsertMenuGrids",
- "InsertSymbol",
- "InsertTrendlineEquation", "InsertTrendlineEquationAndR2",
- "InsertR2Value", "DeleteR2Value",
- "InsertMenuTrendlines", "InsertTrendline",
- "InsertMenuMeanValues", "InsertMeanValue",
- "InsertMenuXErrorBars", "InsertXErrorBars",
- "InsertMenuYErrorBars", "InsertYErrorBars",
- "InsertDataLabels", "InsertDataLabel",
- "DeleteTrendline", "DeleteMeanValue", "DeleteTrendlineEquation",
- "DeleteXErrorBars", "DeleteYErrorBars",
- "DeleteDataLabels", "DeleteDataLabel",
- //format objects
- "FormatSelection", "TransformDialog",
- "DiagramType", "View3D",
- "Forward", "Backward",
- "MainTitle", "SubTitle",
- "XTitle", "YTitle", "ZTitle",
- "SecondaryXTitle", "SecondaryYTitle",
- "AllTitles", "Legend",
- "DiagramAxisX", "DiagramAxisY", "DiagramAxisZ",
- "DiagramAxisA", "DiagramAxisB", "DiagramAxisAll",
- "DiagramGridXMain", "DiagramGridYMain", "DiagramGridZMain",
- "DiagramGridXHelp", "DiagramGridYHelp", "DiagramGridZHelp",
- "DiagramGridAll",
- "DiagramWall", "DiagramFloor", "DiagramArea",
-
- //context menu - format objects entries
- "FormatWall", "FormatFloor", "FormatChartArea",
- "FormatLegend",
-
- "FormatAxis", "FormatTitle",
- "FormatDataSeries", "FormatDataPoint",
- "ResetAllDataPoints", "ResetDataPoint",
- "FormatDataLabels", "FormatDataLabel",
- "FormatMeanValue", "FormatTrendline", "FormatTrendlineEquation",
- "FormatXErrorBars", "FormatYErrorBars",
- "FormatStockLoss", "FormatStockGain",
-
- "FormatMajorGrid", "InsertMajorGrid", "DeleteMajorGrid",
- "FormatMinorGrid", "InsertMinorGrid", "DeleteMinorGrid",
- "InsertAxis", "DeleteAxis", "InsertAxisTitle",
+ ChartWindow* pChartWindow = GetChartWindow();
+ if( pChartWindow )
+ xParent.set(pChartWindow->GetAccessibleParent());
+
+ rAccChartView.initialize(*this, getChartModel(), m_xChartView, xParent, pChartWindow);
+}
+#else
+void ChartController::impl_initializeAccessible( AccessibleChartView& /* rAccChartView */) {}
+#endif
+
+const o3tl::sorted_vector< std::u16string_view >& ChartController::impl_getAvailableCommands()
+{
+ static const o3tl::sorted_vector< std::u16string_view > s_AvailableCommands {
// toolbar commands
- "ToggleGridHorizontal", "ToggleGridVertical", "ToggleLegend", "ScaleText",
- "NewArrangement", "Update",
- "DefaultColors", "BarWidth", "NumberOfLines",
- "ArrangeRow",
- "StatusBarVisible",
- "ChartElementSelector"};
+ u"ChartElementSelector",
+
+ // LOK commands
+ u"LOKSetTextSelection", u"LOKTransform",
+ };
return s_AvailableCommands;
}
@@ -1670,11 +1675,4 @@ ViewElementListProvider ChartController::getViewElementListProvider()
} //namespace chart
-extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
-com_sun_star_comp_chart2_ChartController_get_implementation(css::uno::XComponentContext *context,
- css::uno::Sequence<css::uno::Any> const &)
-{
- return cppu::acquire(new chart::ChartController(context));
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */