summaryrefslogtreecommitdiffstats
path: root/chart2/source/controller/main/ShapeController.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/controller/main/ShapeController.cxx')
-rw-r--r--chart2/source/controller/main/ShapeController.cxx181
1 files changed, 98 insertions, 83 deletions
diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx
index acdcb78ce045..c440a7d97925 100644
--- a/chart2/source/controller/main/ShapeController.cxx
+++ b/chart2/source/controller/main/ShapeController.cxx
@@ -18,15 +18,14 @@
*/
#include "ShapeController.hxx"
-#include <ShapeController.h>
#include <ChartController.hxx>
#include <ViewElementListProvider.hxx>
#include <dlg_ShapeFont.hxx>
#include <dlg_ShapeParagraph.hxx>
+#include <ChartModel.hxx>
#include <chartview/DrawModelWrapper.hxx>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/frame/CommandGroup.hpp>
-#include <com/sun/star/frame/XStorable.hpp>
#include <vcl/svapp.hxx>
#include <editeng/formatbreakitem.hxx>
@@ -37,7 +36,7 @@
#include <editeng/spltitem.hxx>
#include <svx/svxdlg.hxx>
#include <editeng/widwitem.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::frame;
@@ -60,7 +59,7 @@ ShapeController::~ShapeController()
}
// WeakComponentImplHelperBase
-void ShapeController::disposing()
+void ShapeController::disposing(std::unique_lock<std::mutex>& /*rGuard*/)
{
}
@@ -78,7 +77,7 @@ FeatureState ShapeController::getState( const OUString& rCommand )
bool bWritable = false;
if ( m_pChartController )
{
- Reference< frame::XStorable > xStorable( m_pChartController->getModel(), uno::UNO_QUERY );
+ rtl::Reference< ChartModel > xStorable = m_pChartController->getChartModel();
if ( xStorable.is() )
{
bWritable = !xStorable->isReadonly();
@@ -88,37 +87,37 @@ FeatureState ShapeController::getState( const OUString& rCommand )
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand );
if ( aIter != m_aSupportedFeatures.end() )
{
- sal_uInt16 nFeatureId = aIter->second.nFeatureId;
+ ChartCommandID nFeatureId = aIter->second.nFeatureId;
switch ( nFeatureId )
{
- case COMMAND_ID_FORMAT_LINE:
- case COMMAND_ID_FORMAT_AREA:
- case COMMAND_ID_TEXT_ATTRIBUTES:
- case COMMAND_ID_TRANSFORM_DIALOG:
- case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
- case COMMAND_ID_RENAME_OBJECT:
+ case ChartCommandID::ShapeFormatLine:
+ case ChartCommandID::ShapeFormatArea:
+ case ChartCommandID::ShapeTextAttributes:
+ case ChartCommandID::ShapeTransformDialog:
+ case ChartCommandID::ShapeObjectTitleDescription:
+ case ChartCommandID::ShapeRenameObject:
{
aReturn.bEnabled = bWritable;
aReturn.aState <<= false;
}
break;
- case COMMAND_ID_BRING_TO_FRONT:
- case COMMAND_ID_FORWARD:
+ case ChartCommandID::ShapeBringToFront:
+ case ChartCommandID::ShapeForward:
{
aReturn.bEnabled = ( bWritable && isForwardPossible() );
aReturn.aState <<= false;
}
break;
- case COMMAND_ID_BACKWARD:
- case COMMAND_ID_SEND_TO_BACK:
+ case ChartCommandID::ShapeBackward:
+ case ChartCommandID::ShapeSendToBack:
{
aReturn.bEnabled = ( bWritable && isBackwardPossible() );
aReturn.aState <<= false;
}
break;
- case COMMAND_ID_FONT_DIALOG:
- case COMMAND_ID_PARAGRAPH_DIALOG:
+ case ChartCommandID::ShapeFontDialog:
+ case ChartCommandID::ShapeParagraphDialog:
{
aReturn.bEnabled = bWritable;
aReturn.aState <<= false;
@@ -142,53 +141,53 @@ void ShapeController::execute( const OUString& rCommand, const Sequence< beans::
if ( aIter == m_aSupportedFeatures.end() )
return;
- sal_uInt16 nFeatureId = aIter->second.nFeatureId;
+ ChartCommandID nFeatureId = aIter->second.nFeatureId;
switch ( nFeatureId )
{
- case COMMAND_ID_FORMAT_LINE:
+ case ChartCommandID::ShapeFormatLine:
{
executeDispatch_FormatLine();
}
break;
- case COMMAND_ID_FORMAT_AREA:
+ case ChartCommandID::ShapeFormatArea:
{
executeDispatch_FormatArea();
}
break;
- case COMMAND_ID_TEXT_ATTRIBUTES:
+ case ChartCommandID::ShapeTextAttributes:
{
executeDispatch_TextAttributes();
}
break;
- case COMMAND_ID_TRANSFORM_DIALOG:
+ case ChartCommandID::ShapeTransformDialog:
{
executeDispatch_TransformDialog();
}
break;
- case COMMAND_ID_OBJECT_TITLE_DESCRIPTION:
+ case ChartCommandID::ShapeObjectTitleDescription:
{
executeDispatch_ObjectTitleDescription();
}
break;
- case COMMAND_ID_RENAME_OBJECT:
+ case ChartCommandID::ShapeRenameObject:
{
executeDispatch_RenameObject();
}
break;
- case COMMAND_ID_BRING_TO_FRONT:
- case COMMAND_ID_FORWARD:
- case COMMAND_ID_BACKWARD:
- case COMMAND_ID_SEND_TO_BACK:
+ case ChartCommandID::ShapeBringToFront:
+ case ChartCommandID::ShapeForward:
+ case ChartCommandID::ShapeBackward:
+ case ChartCommandID::ShapeSendToBack:
{
executeDispatch_ChangeZOrder( nFeatureId );
}
break;
- case COMMAND_ID_FONT_DIALOG:
+ case ChartCommandID::ShapeFontDialog:
{
executeDispatch_FontDialog();
}
break;
- case COMMAND_ID_PARAGRAPH_DIALOG:
+ case ChartCommandID::ShapeParagraphDialog:
{
executeDispatch_ParagraphDialog();
}
@@ -202,24 +201,23 @@ void ShapeController::execute( const OUString& rCommand, const Sequence< beans::
void ShapeController::describeSupportedFeatures()
{
- implDescribeSupportedFeature( ".uno:FormatLine", COMMAND_ID_FORMAT_LINE, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:FormatArea", COMMAND_ID_FORMAT_AREA, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:TextAttributes", COMMAND_ID_TEXT_ATTRIBUTES, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:TransformDialog", COMMAND_ID_TRANSFORM_DIALOG, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:ObjectTitleDescription", COMMAND_ID_OBJECT_TITLE_DESCRIPTION, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:RenameObject", COMMAND_ID_RENAME_OBJECT, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:BringToFront", COMMAND_ID_BRING_TO_FRONT, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:Forward", COMMAND_ID_FORWARD, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:Backward", COMMAND_ID_BACKWARD, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:SendToBack", COMMAND_ID_SEND_TO_BACK, CommandGroup::FORMAT );
- implDescribeSupportedFeature( ".uno:FontDialog", COMMAND_ID_FONT_DIALOG, CommandGroup::EDIT );
- implDescribeSupportedFeature( ".uno:ParagraphDialog", COMMAND_ID_PARAGRAPH_DIALOG, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:FormatLine", ChartCommandID::ShapeFormatLine, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:FormatArea", ChartCommandID::ShapeFormatArea, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:TextAttributes", ChartCommandID::ShapeTextAttributes, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:TransformDialog", ChartCommandID::ShapeTransformDialog, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:ObjectTitleDescription", ChartCommandID::ShapeObjectTitleDescription, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:RenameObject", ChartCommandID::ShapeRenameObject, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:BringToFront", ChartCommandID::ShapeBringToFront, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:Forward", ChartCommandID::ShapeForward, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:Backward", ChartCommandID::ShapeBackward, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:SendToBack", ChartCommandID::ShapeSendToBack, CommandGroup::FORMAT );
+ implDescribeSupportedFeature( ".uno:FontDialog", ChartCommandID::ShapeFontDialog, CommandGroup::EDIT );
+ implDescribeSupportedFeature( ".uno:ParagraphDialog", ChartCommandID::ShapeParagraphDialog, CommandGroup::EDIT );
}
IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
{
- OUString aName;
- rDialog.GetName( aName );
+ OUString aName = rDialog.GetName();
if ( !aName.isEmpty() )
{
@@ -289,7 +287,7 @@ void ShapeController::executeDispatch_FormatArea()
}
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg(
- pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true));
+ pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true, false));
if ( pDlg->Execute() == RET_OK )
{
const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
@@ -322,20 +320,26 @@ void ShapeController::executeDispatch_TextAttributes()
pDrawViewWrapper->MergeAttrFromMarked( aAttr, false );
}
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- ScopedVclPtr< SfxAbstractTabDialog > pDlg(
+ VclPtr< SfxAbstractTabDialog > pDlg(
pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper));
- if ( pDlg->Execute() == RET_OK )
- {
- const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
- if ( bHasMarked )
- {
- pDrawViewWrapper->SetAttributes( *pOutAttr );
- }
- else
+ pDlg->StartExecuteAsync(
+ [pDlg, bHasMarked, pDrawViewWrapper] (sal_Int32 nResult)->void
{
- pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
+ if ( RET_OK == nResult )
+ {
+ const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet();
+ if ( bHasMarked )
+ {
+ pDrawViewWrapper->SetAttributes( *pOutAttr );
+ }
+ else
+ {
+ pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false );
+ }
+ }
+ pDlg->disposeOnce();
}
- }
+ );
}
void ShapeController::executeDispatch_TransformDialog()
@@ -353,7 +357,7 @@ void ShapeController::executeDispatch_TransformDialog()
if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == SdrObjKind::Caption )
{
// item set for caption
- SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
+ SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool());
pDrawViewWrapper->GetAttributes( aAttr );
// item set for position and size
SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() );
@@ -402,17 +406,23 @@ void ShapeController::executeDispatch_ObjectTitleDescription()
OUString aTitle( pSelectedObj->GetTitle() );
OUString aDescription( pSelectedObj->GetDescription() );
+ bool isDecorative(pSelectedObj->IsDecorative());
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
weld::Window* pChartWindow(m_pChartController->GetChartFrame());
- ScopedVclPtr< AbstractSvxObjectTitleDescDialog > pDlg(
- pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription));
- if ( pDlg->Execute() == RET_OK )
- {
- pDlg->GetTitle( aTitle );
- pDlg->GetDescription( aDescription );
- pSelectedObj->SetTitle( aTitle );
- pSelectedObj->SetDescription( aDescription );
- }
+ VclPtr< AbstractSvxObjectTitleDescDialog > pDlg(
+ pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription, isDecorative));
+ pDlg->StartExecuteAsync(
+ [pDlg, pSelectedObj] (sal_Int32 nResult)->void
+ {
+ if (nResult == RET_OK)
+ {
+ pSelectedObj->SetTitle( pDlg->GetTitle() );
+ pSelectedObj->SetDescription( pDlg->GetDescription() );
+ pSelectedObj->SetDecorative(pDlg->IsDecorative());
+ }
+ pDlg->disposeOnce();
+ }
+ );
}
void ShapeController::executeDispatch_RenameObject()
@@ -429,23 +439,28 @@ void ShapeController::executeDispatch_RenameObject()
if ( !pSelectedObj )
return;
- OUString aName = pSelectedObj->GetName();
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
weld::Window* pChartWindow(m_pChartController->GetChartFrame());
- ScopedVclPtr< AbstractSvxObjectNameDialog > pDlg(
- pFact->CreateSvxObjectNameDialog(pChartWindow, aName));
+ VclPtr< AbstractSvxObjectNameDialog > pDlg(
+ pFact->CreateSvxObjectNameDialog(pChartWindow, pSelectedObj->GetName()));
pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) );
- if ( pDlg->Execute() == RET_OK )
- {
- pDlg->GetName(aName);
- if (pSelectedObj->GetName() == aName)
+ pDlg->StartExecuteAsync(
+ [pDlg, pSelectedObj] (sal_Int32 nResult)->void
{
- pSelectedObj->SetName( aName );
+ if (nResult == RET_OK)
+ {
+ OUString aName = pDlg->GetName();
+ if (pSelectedObj->GetName() != aName)
+ {
+ pSelectedObj->SetName( aName );
+ }
+ }
+ pDlg->disposeOnce();
}
- }
+ );
}
-void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
+void ShapeController::executeDispatch_ChangeZOrder( ChartCommandID nId )
{
SolarMutexGuard aGuard;
DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr );
@@ -454,7 +469,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
switch ( nId )
{
- case COMMAND_ID_BRING_TO_FRONT:
+ case ChartCommandID::ShapeBringToFront:
{
if ( isForwardPossible() )
{
@@ -462,7 +477,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
}
}
break;
- case COMMAND_ID_FORWARD:
+ case ChartCommandID::ShapeForward:
{
if ( isForwardPossible() )
{
@@ -470,7 +485,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
}
}
break;
- case COMMAND_ID_BACKWARD:
+ case ChartCommandID::ShapeBackward:
{
if ( isBackwardPossible() )
{
@@ -478,7 +493,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId )
}
}
break;
- case COMMAND_ID_SEND_TO_BACK:
+ case ChartCommandID::ShapeSendToBack:
{
if ( isBackwardPossible() )
{
@@ -505,7 +520,7 @@ void ShapeController::executeDispatch_FontDialog()
DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper )
{
- SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() );
+ SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool());
pDrawViewWrapper->GetAttributes( aAttr );
ViewElementListProvider aViewElementListProvider( pDrawModelWrapper );
ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider);
@@ -528,7 +543,7 @@ void ShapeController::executeDispatch_ParagraphDialog()
if ( !(pChartWindow && pDrawViewWrapper) )
return;
- SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool();
+ SfxItemPool& rPool = pDrawViewWrapper->GetModel().GetItemPool();
SfxItemSet aAttr( rPool );
pDrawViewWrapper->GetAttributes( aAttr );