diff options
author | Thomas Benisch <tbe@openoffice.org> | 2009-05-29 09:10:08 +0000 |
---|---|---|
committer | Thomas Benisch <tbe@openoffice.org> | 2009-05-29 09:10:08 +0000 |
commit | bce20674745eaba6e2e68f09f5eac9a6a15a43a1 (patch) | |
tree | c3317b9fa2827478a9a3934d15427417ca0dd21a /chart2/source/controller | |
parent | aaaa0944f7ee56d1143e3529860c341f2e92e531 (diff) |
#i12587# Inserting/editing arbitrary text objects in chart
Diffstat (limited to 'chart2/source/controller')
25 files changed, 1102 insertions, 198 deletions
diff --git a/chart2/source/controller/dialogs/ResourceIds.hrc b/chart2/source/controller/dialogs/ResourceIds.hrc index 8674aba240da..522477d22c2d 100644 --- a/chart2/source/controller/dialogs/ResourceIds.hrc +++ b/chart2/source/controller/dialogs/ResourceIds.hrc @@ -51,6 +51,7 @@ #define DLG_SPLINE_PROPERTIES 904 #define DLG_DATA_TRENDLINE 841 #define DLG_DATA_YERRORBAR 842 +#define DLG_SHAPE_FONT 921 //----------------------------------------------------------------------------- //TabPage Ids: diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx new file mode 100644 index 000000000000..6d0fb0f647b2 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * 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: dlg_ShapeFont.cxx,v $ + * $Revision: 1.0 $ + * + * 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 "dlg_ShapeFont.hxx" +#include "ViewElementListProvider.hxx" +#include "ResId.hxx" +#include "ResourceIds.hrc" + +#include <svtools/intitem.hxx> +#include <sfx2/objsh.hxx> +#include <svx/dialogs.hrc> +#include <svx/flagsdef.hxx> +#include <svx/flstitem.hxx> + +using ::com::sun::star::uno::Reference; +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +ShapeFontDialog::ShapeFontDialog( Window* pParent, const SfxItemSet* pAttr, + const ViewElementListProvider* pViewElementListProvider ) + :SfxTabDialog( pParent, SchResId( DLG_SHAPE_FONT ), pAttr ) + ,m_pViewElementListProvider( pViewElementListProvider ) +{ + FreeResource(); + + AddTabPage( RID_SVXPAGE_CHAR_NAME ); + AddTabPage( RID_SVXPAGE_CHAR_EFFECTS ); + AddTabPage( RID_SVXPAGE_CHAR_POSITION ); +} + +ShapeFontDialog::~ShapeFontDialog() +{ +} + +void ShapeFontDialog::PageCreated( USHORT nId, SfxTabPage& rPage ) +{ + SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) ); + switch ( nId ) + { + case RID_SVXPAGE_CHAR_NAME: + { + aSet.Put( SvxFontListItem( m_pViewElementListProvider->getFontList(), SID_ATTR_CHAR_FONTLIST ) ); + rPage.PageCreated( aSet ); + } + break; + case RID_SVXPAGE_CHAR_EFFECTS: + { + aSet.Put( SfxUInt16Item( SID_DISABLE_CTL, DISABLE_CASEMAP ) ); + rPage.PageCreated( aSet ); + } + break; + default: + { + } + break; + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.src b/chart2/source/controller/dialogs/dlg_ShapeFont.src new file mode 100644 index 000000000000..febe31da7245 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ShapeFont.src @@ -0,0 +1,65 @@ +/************************************************************************* + * + * 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: dlg_ShapeFont.src,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#include "ResourceIds.hrc" +#include <svx/dialogs.hrc> + +TabDialog DLG_SHAPE_FONT +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 289 , 176 ) ; + Text [ en-US ] = "Character" ; + Moveable = TRUE ; + Closeable = TRUE ; + TabControl 1 + { + OutputSize = TRUE ; + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( 260 , 135 ) ; + PageList = + { + PageItem + { + Identifier = RID_SVXPAGE_CHAR_NAME ; + Text [ en-US ] = "Font"; + }; + PageItem + { + Identifier = RID_SVXPAGE_CHAR_EFFECTS ; + Text [ en-US ] = "Font Effects"; + }; + PageItem + { + Identifier = RID_SVXPAGE_CHAR_POSITION ; + Text [ en-US ] = "Font Position"; + }; + }; + }; +}; diff --git a/chart2/source/controller/dialogs/makefile.mk b/chart2/source/controller/dialogs/makefile.mk index 6b64f2cae8db..02344ec73d5b 100644 --- a/chart2/source/controller/dialogs/makefile.mk +++ b/chart2/source/controller/dialogs/makefile.mk @@ -102,6 +102,7 @@ SLOFILES= \ $(SLO)$/dlg_ChartType_UNO.obj \ $(SLO)$/dlg_ChartType.obj \ $(SLO)$/dlg_NumberFormat.obj \ + $(SLO)$/dlg_ShapeFont.obj \ $(SLO)$/RangeSelectionButton.obj \ $(SLO)$/RangeSelectionHelper.obj \ $(SLO)$/RangeSelectionListener.obj \ @@ -154,7 +155,8 @@ SRC1FILES= \ dlg_InsertErrorBars.src \ dlg_InsertTitle.src \ dlg_ChartType.src \ - dlg_CreationWizard.src + dlg_CreationWizard.src \ + dlg_ShapeFont.src SRS1NAME=$(TARGET) diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index 7ed9a93073bd..5d2c37b6fdfa 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -54,6 +54,7 @@ // header for class SvxShape #include <svx/unoshape.hxx> +#include <svx/fhgtitem.hxx> #include <com/sun/star/container/XChild.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> @@ -165,6 +166,14 @@ DrawViewWrapper::DrawViewWrapper( SdrModel* pSdrModel, OutputDevice* pOut, bool SetPagePaintingAllowed(bPaintPageForEditMode); + // #i12587# set font height without changing SdrEngineDefaults + SdrOutliner* pOutliner = getOutliner(); + SfxItemPool* pOutlinerPool = ( pOutliner ? pOutliner->GetEditTextObjectPool() : NULL ); + if ( pOutlinerPool ) + { + pOutlinerPool->SetPoolDefaultItem( SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT ) ); // 12pt + } + ReInit(); } diff --git a/chart2/source/controller/inc/MenuResids.hrc b/chart2/source/controller/inc/MenuResids.hrc new file mode 100644 index 000000000000..84eb42235e27 --- /dev/null +++ b/chart2/source/controller/inc/MenuResids.hrc @@ -0,0 +1,44 @@ +/************************************************************************* + * + * 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: MenuResIds.hrc,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#ifndef CHART_MENURESIDS_HRC +#define CHART_MENURESIDS_HRC + +#ifndef _SOLAR_HRC +#include <svtools/solar.hrc> +#endif + +//----------------------------------------------------------------------------- +// context menus + +#define RID_CONTEXTMENU_SHAPE (RID_APP_START + 1) +#define RID_CONTEXTMENU_SHAPEEDIT (RID_APP_START + 2) + +// CHART_MENURESIDS_HRC +#endif diff --git a/chart2/source/controller/inc/dlg_ShapeFont.hxx b/chart2/source/controller/inc/dlg_ShapeFont.hxx new file mode 100644 index 000000000000..f0ea9aa31b00 --- /dev/null +++ b/chart2/source/controller/inc/dlg_ShapeFont.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * 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: dlg_ShapeFont.hxx,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#ifndef CHART2_DLG_SHAPEFONT_HXX +#define CHART2_DLG_SHAPEFONT_HXX + +#include <sfx2/tabdlg.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ViewElementListProvider; + +/** dialog for font properties of shapes + */ +class ShapeFontDialog : public SfxTabDialog +{ +public: + ShapeFontDialog( Window* pParent, const SfxItemSet* pAttr, + const ViewElementListProvider* pViewElementListProvider ); + virtual ~ShapeFontDialog(); + +private: + virtual void PageCreated( USHORT nId, SfxTabPage& rPage ); + + const ViewElementListProvider* m_pViewElementListProvider; +}; + +//............................................................................. +} // namespace chart +//............................................................................. + +// CHART2_DLG_SHAPEFONT_HXX +#endif diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 98ce927708dc..397e7bc44342 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -54,6 +54,7 @@ #include "dlg_ChartType.hxx" //#include "svx/ActionDescriptionProvider.hxx" #include "DrawCommandDispatch.hxx" +#include "ShapeController.hxx" #include <comphelper/InlineContainer.hxx> @@ -574,7 +575,7 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent // 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.setFallbackDispatch( pDispatch, impl_getAvailableCommands() ); + m_aDispatchContainer.setChartDispatch( pDispatch, impl_getAvailableCommands() ); DrawCommandDispatch* pDrawDispatch = new DrawCommandDispatch( m_xCC, this ); if ( pDrawDispatch ) @@ -583,6 +584,13 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent m_aDispatchContainer.setDrawCommandDispatch( pDrawDispatch ); } + ShapeController* pShapeController = new ShapeController( m_xCC, this ); + if ( pShapeController ) + { + pShapeController->initialize(); + m_aDispatchContainer.setShapeController( pShapeController ); + } + #ifdef TEST_ENABLE_MODIFY_LISTENER uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); if( xMBroadcaster.is()) diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index 50516092742d..177fedf524f0 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -161,6 +161,7 @@ class ChartController : public ::cppu::WeakImplHelper12 < , public WindowController { friend class DrawCommandDispatch; + friend class ShapeController; public: //no default constructor diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 07d4c85d12da..bb5b3ac5e284 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -51,6 +51,7 @@ #include "chartview/ExplicitValueProvider.hxx" #include "RelativePositionHelper.hxx" #include "chartview/DrawModelWrapper.hxx" +#include "MenuResIds.hrc" #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> @@ -893,54 +894,71 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) impl_notifySelectionChangeListeners(); - // todo: the context menu should be specified by an xml file in uiconfig - uno::Reference< awt::XPopupMenu > xPopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); - uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY ); - if( xPopupMenu.is() && xMenuEx.is()) + if ( m_aSelection.isNonGraphicObjectShapeSelected() || + ( m_pDrawViewWrapper->AreObjectsMarked() && ( m_pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) ) ) { - sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramObjects")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow")); - uno::Reference< awt::XPopupMenu > xArrangePopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); - uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY ); - if( xArrangePopupMenu.is() && xArrangeMenuEx.is()) - { - sal_Int16 nSubId = nUniqueId + 1; - lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward")); - lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward")); - xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); - nUniqueId = nSubId; - } - ++nUniqueId; - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D")); - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData")); - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorbar")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorbar")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation")); - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy")); - lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste")); - + // #i12587# support for shapes in chart + PopupMenu aContextMenu( SchResId( m_pDrawViewWrapper->IsTextEdit() ? + RID_CONTEXTMENU_SHAPEEDIT : RID_CONTEXTMENU_SHAPE ) ); ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) + { aPos = m_pChartWindow->GetPointerState().maPos; - aContextMenuHelper.completeAndExecute( aPos, xPopupMenu ); + } + aContextMenuHelper.completeAndExecute( aPos, aContextMenu ); + } + else + { + // todo: the context menu should be specified by an xml file in uiconfig + uno::Reference< awt::XPopupMenu > xPopupMenu( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); + uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY ); + if( xPopupMenu.is() && xMenuEx.is()) + { + sal_Int16 nUniqueId = 1; + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramObjects")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow")); + uno::Reference< awt::XPopupMenu > xArrangePopupMenu( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); + uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY ); + if( xArrangePopupMenu.is() && xArrangeMenuEx.is()) + { + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward")); + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward")); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + } + ++nUniqueId; + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D")); + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData")); + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorbar")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorbar")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation")); + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste")); + + ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); + Point aPos( rCEvt.GetMousePosPixel() ); + if( !rCEvt.IsMouseEvent() ) + aPos = m_pChartWindow->GetPointerState().maPos; + aContextMenuHelper.completeAndExecute( aPos, xPopupMenu ); + } } } else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) || diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index fbd6dbc22f88..8c0f4f1f5c8e 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -37,6 +37,7 @@ #include "DisposeHelper.hxx" #include "macros.hxx" #include "DrawCommandDispatch.hxx" +#include "ShapeController.hxx" #include <comphelper/InlineContainer.hxx> @@ -55,6 +56,7 @@ CommandDispatchContainer::CommandDispatchContainer( const Reference< uno::XComponentContext > & xContext ) :m_xContext( xContext ) ,m_pDrawCommandDispatch( NULL ) + ,m_pShapeController( NULL ) { m_aContainerDocumentCommands = ::comphelper::MakeSet< OUString > @@ -80,14 +82,14 @@ void CommandDispatchContainer::setModel( // m_xUndoManager = xUndoManager; // } -void CommandDispatchContainer::setFallbackDispatch( - const Reference< frame::XDispatch > xFallbackDispatch, - const ::std::set< OUString > & rFallbackCommands ) +void CommandDispatchContainer::setChartDispatch( + const Reference< frame::XDispatch > xChartDispatch, + const ::std::set< OUString > & rChartCommands ) { - OSL_ENSURE(xFallbackDispatch.is(),"Invalid fall back dispatcher!"); - m_xFallbackDispatcher.set( xFallbackDispatch ); - m_aFallbackCommands = rFallbackCommands; - m_aToBeDisposedDispatches.push_back( m_xFallbackDispatcher ); + OSL_ENSURE(xChartDispatch.is(),"Invalid fall back dispatcher!"); + m_xChartDispatcher.set( xChartDispatch ); + m_aChartCommands = rChartCommands; + m_aToBeDisposedDispatches.push_back( m_xChartDispatcher ); } Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( @@ -132,15 +134,23 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( // ToDo: can those dispatches be cached? m_aCachedDispatches[ rURL.Complete ].set( xResult ); } + else if( m_xChartDispatcher.is() && + (m_aChartCommands.find( rURL.Path ) != m_aChartCommands.end()) ) + { + xResult.set( m_xChartDispatcher ); + m_aCachedDispatches[ rURL.Complete ].set( xResult ); + } + // #i12587# support for shapes in chart + // Note, that the chart dispatcher must be queried first, because + // the chart dispatcher handles all context sensitive commands. else if ( m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported( rURL ) ) { xResult.set( m_pDrawCommandDispatch ); m_aCachedDispatches[ rURL.Complete ].set( xResult ); } - else if( m_xFallbackDispatcher.is() && - (m_aFallbackCommands.find( rURL.Path ) != m_aFallbackCommands.end()) ) + else if ( m_pShapeController && m_pShapeController->isFeatureSupported( rURL ) ) { - xResult.set( m_xFallbackDispatcher ); + xResult.set( m_pShapeController ); m_aCachedDispatches[ rURL.Complete ].set( xResult ); } } @@ -167,9 +177,10 @@ void CommandDispatchContainer::DisposeAndClear() m_aCachedDispatches.clear(); DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); m_aToBeDisposedDispatches.clear(); - m_xFallbackDispatcher.clear(); - m_aFallbackCommands.clear(); + m_xChartDispatcher.clear(); + m_aChartCommands.clear(); m_pDrawCommandDispatch = NULL; + m_pShapeController = NULL; } Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForURL( @@ -196,4 +207,10 @@ void CommandDispatchContainer::setDrawCommandDispatch( DrawCommandDispatch* pDis m_aToBeDisposedDispatches.push_back( Reference< frame::XDispatch >( pDispatch ) ); } +void CommandDispatchContainer::setShapeController( ShapeController* pController ) +{ + m_pShapeController = pController; + m_aToBeDisposedDispatches.push_back( Reference< frame::XDispatch >( pController ) ); +} + } // namespace chart diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx index 8f310e34a833..d5828e9f1550 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.hxx +++ b/chart2/source/controller/main/CommandDispatchContainer.hxx @@ -45,6 +45,7 @@ namespace chart { class DrawCommandDispatch; +class ShapeController; /** @HTML @@ -58,9 +59,9 @@ class DrawCommandDispatch; <li>Check if the command is handled by this class, e.g. Undo. If so, return a corresponding <code>XDispatch</code> implementation, and cache this implementation for later use</li> - <li>Otherwise send the command to the fallback dispatch provider, if it + <li>Otherwise send the command to the chart dispatch provider, if it can handle this dispatch (determined by the list of commands given in - <code>setFallbackDispatch()</code>).</li> + <code>setChartDispatch()</code>).</li> </ul> <p>The <code>XDispatch</code>Provider is designed to return different @@ -70,13 +71,13 @@ class DrawCommandDispatch; <p>As most commands need much information of the controller and are implemented there, the controller handles most of the commands itself (it also implements <code>XDispatch</code>). Therefore it is set here as - fallback dispatch.</p> + chart dispatch.</p> */ class CommandDispatchContainer { public: - // note: the fallback dispatcher should be removed when all commands are - // handled by other dispatchers. (Fallback is currently the controller + // note: the chart dispatcher should be removed when all commands are + // handled by other dispatchers. (Chart is currently the controller // itself) explicit CommandDispatchContainer( const ::com::sun::star::uno::Reference< @@ -89,18 +90,18 @@ public: // const ::com::sun::star::uno::Reference< // ::com::sun::star::chart2::XUndoManager > & xUndoManager ); - /** Set a fallback dispatcher that is used for all commands contained in - rFallbackCommands + /** Set a chart dispatcher that is used for all commands contained in + rChartCommands */ - void setFallbackDispatch( + void setChartDispatch( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XDispatch > xFallbackDispatch, - const ::std::set< ::rtl::OUString > & rFallbackCommands ); + ::com::sun::star::frame::XDispatch > xChartDispatch, + const ::std::set< ::rtl::OUString > & rChartCommands ); /** Returns the dispatch that is able to do the command given in rURL, if implemented here. If the URL is not implemented here, it should be - checked whether the command is one of the commands given as fallback via - the setFallbackDispatch() method. If so, call the fallback dispatch. + checked whether the command is one of the commands given via + the setChartDispatch() method. If so, call the chart dispatch. <p>If all this fails, return an empty dispatch.</p> */ @@ -122,6 +123,7 @@ public: const ::com::sun::star::util::URL & rURL ); void setDrawCommandDispatch( DrawCommandDispatch* pDispatch ); + void setShapeController( ShapeController* pController ); private: typedef @@ -140,12 +142,13 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFallbackDispatcher; - ::std::set< ::rtl::OUString > m_aFallbackCommands; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher; + ::std::set< ::rtl::OUString > m_aChartCommands; ::std::set< ::rtl::OUString > m_aContainerDocumentCommands; DrawCommandDispatch* m_pDrawCommandDispatch; + ShapeController* m_pShapeController; }; } // namespace chart diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index 4ae9f06e2744..60458d81e8bd 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -43,16 +43,16 @@ using namespace ::com::sun::star::frame; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; +//............................................................................. namespace chart { - +//............................................................................. DrawCommandDispatch::DrawCommandDispatch( const Reference< uno::XComponentContext >& rxContext, ChartController* pController ) - :CommandDispatch( rxContext ) + :FeatureCommandDispatchBase( rxContext ) ,m_pChartController( pController ) { - fillSupportedFeatures(); } DrawCommandDispatch::~DrawCommandDispatch() @@ -61,53 +61,7 @@ DrawCommandDispatch::~DrawCommandDispatch() void DrawCommandDispatch::initialize() { -} - -bool DrawCommandDispatch::isFeatureSupported( const util::URL& rURL ) const -{ - SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rURL.Complete ); - if ( aIter != m_aSupportedFeatures.end() ) - { - return true; - } - return false; -} - -void DrawCommandDispatch::fireStatusEvent( const ::rtl::OUString& rURL, - const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ ) -{ - if ( rURL.getLength() == 0 ) - { - SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() ); - for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter ) - { - sal_uInt16 nId = aIter->second.nFeatureId; - FeatureState aFeatureState( getState( nId ) ); - fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); - } - } - else - { - sal_uInt16 nId = m_aSupportedFeatures[ rURL ].nFeatureId; - FeatureState aFeatureState( getState( nId ) ); - fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); - } -} - -// XDispatch -void DrawCommandDispatch::dispatch( const util::URL& URL, - const Sequence< beans::PropertyValue >& Arguments ) - throw (uno::RuntimeException) -{ - SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( URL.Complete ); - if ( aIter != m_aSupportedFeatures.end() ) - { - sal_uInt16 nFeatureId = aIter->second.nFeatureId; - if ( getState( nFeatureId ).bEnabled ) // ??? - { - execute( nFeatureId, Arguments ); - } - } + FeatureCommandDispatchBase::initialize(); } // WeakComponentImplHelperBase @@ -121,11 +75,14 @@ void DrawCommandDispatch::disposing( const lang::EventObject& /* Source */ ) { } -FeatureState DrawCommandDispatch::getState( sal_uInt16 nId ) const +FeatureState DrawCommandDispatch::getState( const ::rtl::OUString& rCommand ) const { FeatureState aReturn; + aReturn.bEnabled = false; + aReturn.aState <<= false; + sal_uInt16 nFeatureId = m_aSupportedFeatures[ rCommand ].nFeatureId; - switch ( nId ) + switch ( nFeatureId ) { case SID_OBJECT_SELECT: case SID_DRAW_LINE: @@ -147,15 +104,16 @@ FeatureState DrawCommandDispatch::getState( sal_uInt16 nId ) const return aReturn; } -void DrawCommandDispatch::execute( sal_uInt16 nId, const Sequence< beans::PropertyValue>& rArgs ) +void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs ) { (void)rArgs; ChartDrawMode eDrawMode = CHARTDRAW_SELECT; SdrObjKind eKind = OBJ_NONE; bool bCreate = false; + sal_uInt16 nFeatureId = m_aSupportedFeatures[ rCommand ].nFeatureId; - switch ( nId ) + switch ( nFeatureId ) { case SID_OBJECT_SELECT: { @@ -213,22 +171,6 @@ void DrawCommandDispatch::describeSupportedFeatures() implDescribeSupportedFeature( ".uno:DrawText", SID_DRAW_TEXT, CommandGroup::INSERT ); } -void DrawCommandDispatch::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, - sal_uInt16 nId, sal_Int16 nGroup ) -{ - ControllerFeature aFeature; - aFeature.Command = ::rtl::OUString::createFromAscii( pAsciiCommandURL ); - aFeature.nFeatureId = nId; - aFeature.GroupId = nGroup; - - m_aSupportedFeatures[ aFeature.Command ] = aFeature; -} - -void DrawCommandDispatch::fillSupportedFeatures() -{ - describeSupportedFeatures(); -} - void DrawCommandDispatch::setInsertObj( USHORT eObj, const ::rtl::OUString& rShapeType ) { (void)rShapeType; @@ -240,4 +182,6 @@ void DrawCommandDispatch::setInsertObj( USHORT eObj, const ::rtl::OUString& rSha } } +//............................................................................. } // namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx index 36e0ed879094..b26f8ffc0cdd 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.hxx +++ b/chart2/source/controller/main/DrawCommandDispatch.hxx @@ -30,40 +30,20 @@ #ifndef CHART2_DRAWCOMMANDDISPATCH_HXX #define CHART2_DRAWCOMMANDDISPATCH_HXX -#include "CommandDispatch.hxx" - -#include <com/sun/star/frame/CommandGroup.hpp> -#include <com/sun/star/frame/DispatchInformation.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/util/URL.hpp> +#include "FeatureCommandDispatchBase.hxx" #include <tools/solar.h> +//............................................................................. namespace chart { - -struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation -{ - sal_uInt16 nFeatureId; -}; - -typedef ::std::map< ::rtl::OUString, - ControllerFeature, - ::std::less< ::rtl::OUString > > SupportedFeatures; - -struct FeatureState -{ - bool bEnabled; - ::com::sun::star::uno::Any aState; - - FeatureState() : bEnabled( false ) { } -}; +//............................................................................. class ChartController; /** This is a CommandDispatch implementation for drawing objects. */ -class DrawCommandDispatch: public CommandDispatch +class DrawCommandDispatch: public FeatureCommandDispatchBase { public: DrawCommandDispatch( const ::com::sun::star::uno::Reference< @@ -73,14 +53,7 @@ public: // late initialisation, especially for adding as listener virtual void initialize(); - bool isFeatureSupported( const ::com::sun::star::util::URL& rURL ) const; - protected: - // XDispatch - virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) - throw (::com::sun::star::uno::RuntimeException); - // WeakComponentImplHelperBase virtual void SAL_CALL disposing(); @@ -88,45 +61,24 @@ protected: virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); - virtual void fireStatusEvent( const ::rtl::OUString& rURL, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener ); - // state of a feature - virtual FeatureState getState( sal_uInt16 nId ) const; + virtual FeatureState getState( const ::rtl::OUString& rCommand ) const; // execute a feature - virtual void execute( sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ); + virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ); // all the features which should be handled by this class virtual void describeSupportedFeatures(); - /** describes a feature supported by the controller - - Must not be called outside <member>describeSupportedFeatures</member>. - - @param pAsciiCommandURL - the URL of the feature command - @param nId - the id of the feature. Later references to this feature usually happen by id, not by - URL. - @param nGroup - the command group of the feature. This is important for configuring the controller UI - by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>. - */ - void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId, - sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL ); - - private: - void fillSupportedFeatures(); - void setInsertObj( USHORT eObj, const ::rtl::OUString& rShapeType = ::rtl::OUString() ); - mutable SupportedFeatures m_aSupportedFeatures; ChartController* m_pChartController; }; +//............................................................................. } // namespace chart +//............................................................................. // CHART2_DRAWCOMMANDDISPATCH_HXX #endif diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx new file mode 100644 index 000000000000..24146c1209c3 --- /dev/null +++ b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * 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: FeatureCommandDispatchBase.cxx,v $ + * $Revision: 1.0 $ + * + * 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 "FeatureCommandDispatchBase.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + +namespace chart +{ + +FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext ) + :CommandDispatch( rxContext ) +{ +} + +FeatureCommandDispatchBase::~FeatureCommandDispatchBase() +{ +} + +void FeatureCommandDispatchBase::initialize() +{ + CommandDispatch::initialize(); + fillSupportedFeatures(); +} + +bool FeatureCommandDispatchBase::isFeatureSupported( const util::URL& rURL ) const +{ + SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rURL.Complete ); + if ( aIter != m_aSupportedFeatures.end() ) + { + return true; + } + return false; +} + +void FeatureCommandDispatchBase::fireStatusEvent( const ::rtl::OUString& rURL, + const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ ) +{ + if ( rURL.getLength() == 0 ) + { + SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() ); + for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter ) + { + FeatureState aFeatureState( getState( aIter->first ) ); + fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); + } + } + else + { + FeatureState aFeatureState( getState( rURL ) ); + fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); + } +} + +// XDispatch +void FeatureCommandDispatchBase::dispatch( const util::URL& URL, + const Sequence< beans::PropertyValue >& Arguments ) + throw (uno::RuntimeException) +{ + ::rtl::OUString aCommand( URL.Complete ); + if ( getState( aCommand ).bEnabled ) + { + execute( aCommand, Arguments ); + } +} + +void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, + sal_uInt16 nId, sal_Int16 nGroup ) +{ + ControllerFeature aFeature; + aFeature.Command = ::rtl::OUString::createFromAscii( pAsciiCommandURL ); + aFeature.nFeatureId = nId; + aFeature.GroupId = nGroup; + + m_aSupportedFeatures[ aFeature.Command ] = aFeature; +} + +void FeatureCommandDispatchBase::fillSupportedFeatures() +{ + describeSupportedFeatures(); +} + +} // namespace chart diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx new file mode 100644 index 000000000000..3d043a6203cf --- /dev/null +++ b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * 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: FeatureCommandDispatchBase.hxx,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#ifndef CHART2_FEATURECOMMANDDISPATCHBASE_HXX +#define CHART2_FEATURECOMMANDDISPATCHBASE_HXX + +#include "CommandDispatch.hxx" + +#include <com/sun/star/frame/CommandGroup.hpp> +#include <com/sun/star/frame/DispatchInformation.hpp> +#include <com/sun/star/util/URL.hpp> + +namespace chart +{ + +struct ControllerFeature: public ::com::sun::star::frame::DispatchInformation +{ + sal_uInt16 nFeatureId; +}; + +typedef ::std::map< ::rtl::OUString, + ControllerFeature, + ::std::less< ::rtl::OUString > > SupportedFeatures; + +struct FeatureState +{ + bool bEnabled; + ::com::sun::star::uno::Any aState; + + FeatureState() : bEnabled( false ) { } +}; + +/** This is a base class for CommandDispatch implementations with feature support. + */ +class FeatureCommandDispatchBase: public CommandDispatch +{ +public: + FeatureCommandDispatchBase( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext ); + virtual ~FeatureCommandDispatchBase(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + + virtual bool isFeatureSupported( const ::com::sun::star::util::URL& rURL ) const; + +protected: + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void fireStatusEvent( const ::rtl::OUString& rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xSingleListener ); + + // state of a feature + virtual FeatureState getState( const ::rtl::OUString& rCommand ) const = 0; + + // execute a feature + virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ) = 0; + + // all the features which should be handled by this class + virtual void describeSupportedFeatures() = 0; + + /** describes a feature supported by the controller + + Must not be called outside <member>describeSupportedFeatures</member>. + + @param pAsciiCommandURL + the URL of the feature command + @param nId + the id of the feature. Later references to this feature usually happen by id, not by + URL. + @param nGroup + the command group of the feature. This is important for configuring the controller UI + by the user, see also <type scope="com::sun::star::frame">CommandGroup</type>. + */ + void implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL, sal_uInt16 nId, + sal_Int16 nGroup = ::com::sun::star::frame::CommandGroup::INTERNAL ); + + mutable SupportedFeatures m_aSupportedFeatures; + +private: + void fillSupportedFeatures(); +}; + +} // namespace chart + +// CHART2_FEATURECOMMANDDISPATCHBASE_HXX +#endif diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index 703d7b49e303..0393af45c90b 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -321,6 +321,23 @@ bool Selection::isDragableObjectSelected() return m_xSelectAdditionalShape.is(); } +bool Selection::isNonGraphicObjectShapeSelected() +{ + if ( m_xSelectAdditionalShape.is() ) + { + uno::Reference< drawing::XShapeDescriptor > xShapeDescriptor( m_xSelectAdditionalShape, uno::UNO_QUERY ); + if ( xShapeDescriptor.is() ) + { + ::rtl::OUString aShapeType = xShapeDescriptor->getShapeType(); + if ( !aShapeType.equals( C2U( "com.sun.star.drawing.GraphicObjectShape" ) ) ) + { + return true; + } + } + } + return false; +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/chart2/source/controller/main/SelectionHelper.hxx b/chart2/source/controller/main/SelectionHelper.hxx index 6e01ed005978..d24c91d25de4 100644 --- a/chart2/source/controller/main/SelectionHelper.hxx +++ b/chart2/source/controller/main/SelectionHelper.hxx @@ -59,6 +59,8 @@ public: //methods ::com::sun::star::frame::XModel >& xChartModel ); bool isDragableObjectSelected(); + bool isNonGraphicObjectShapeSelected(); + //returns true if selection has changed bool setSelection( const ::rtl::OUString& rCID ); bool setSelection( const ::com::sun::star::uno::Reference< diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx new file mode 100644 index 000000000000..25e8aede83cc --- /dev/null +++ b/chart2/source/controller/main/ShapeController.cxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * 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: ShapeController.cxx,v $ + * $Revision: 1.0 $ + * + * 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 "ShapeController.hxx" +#include "ChartController.hxx" +#include "ChartWindow.hxx" +#include "ViewElementListProvider.hxx" +#include "dlg_ShapeFont.hxx" + +#include <vos/mutex.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <svx/svxids.hrc> + +#include <boost/scoped_ptr.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::frame; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + +//............................................................................. +namespace chart +{ +//............................................................................. + +ShapeController::ShapeController( const Reference< uno::XComponentContext >& rxContext, + ChartController* pController ) + :FeatureCommandDispatchBase( rxContext ) + ,m_pChartController( pController ) +{ +} + +ShapeController::~ShapeController() +{ +} + +void ShapeController::initialize() +{ + FeatureCommandDispatchBase::initialize(); +} + +// WeakComponentImplHelperBase +void ShapeController::disposing() +{ +} + +// XEventListener +void ShapeController::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{ +} + +FeatureState ShapeController::getState( const ::rtl::OUString& rCommand ) const +{ + FeatureState aReturn; + aReturn.bEnabled = false; + aReturn.aState <<= false; + sal_uInt16 nFeatureId = m_aSupportedFeatures[ rCommand ].nFeatureId; + + switch ( nFeatureId ) + { + case SID_CHAR_DLG: + { + aReturn.bEnabled = true; + aReturn.aState <<= false; + } + break; + default: + { + aReturn.bEnabled = false; + aReturn.aState <<= false; + } + break; + } + + return aReturn; +} + +void ShapeController::execute( const ::rtl::OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs ) +{ + (void)rArgs; + + sal_uInt16 nFeatureId = m_aSupportedFeatures[ rCommand ].nFeatureId; + + switch ( nFeatureId ) + { + case SID_CHAR_DLG: + { + executeDispatch_FontDialog(); + } + break; + default: + { + } + break; + } +} + +void ShapeController::describeSupportedFeatures() +{ + implDescribeSupportedFeature( ".uno:FontDialog", SID_CHAR_DLG, CommandGroup::TEXT ); +} + +void ShapeController::executeDispatch_FontDialog() +{ + if ( m_pChartController ) + { + DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); + DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); + if ( pDrawModelWrapper && pDrawViewWrapper ) + { + Window* pParent = dynamic_cast< Window* >( m_pChartController->m_pChartWindow ); + SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() ); + pDrawViewWrapper->GetAttributes( aSet ); + ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + ::boost::scoped_ptr< ShapeFontDialog > pDlg( new ShapeFontDialog( pParent, &aSet, &aViewElementListProvider ) ); + if ( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); + pDrawViewWrapper->SetAttributes( *pOutSet ); + } + } + } +} + +//............................................................................. +} // namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ShapeController.hxx b/chart2/source/controller/main/ShapeController.hxx new file mode 100644 index 000000000000..afdcfd82f74e --- /dev/null +++ b/chart2/source/controller/main/ShapeController.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * 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: ShapeController.hxx,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#ifndef CHART2_SHAPECONTROLLER_HXX +#define CHART2_SHAPECONTROLLER_HXX + +#include "FeatureCommandDispatchBase.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ChartController; + +/** This is a CommandDispatch implementation for shapes. + */ +class ShapeController: public FeatureCommandDispatchBase +{ +public: + ShapeController( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& rxContext, ChartController* pController ); + virtual ~ShapeController(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + +protected: + // WeakComponentImplHelperBase + virtual void SAL_CALL disposing(); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + // state of a feature + virtual FeatureState getState( const ::rtl::OUString& rCommand ) const; + + // execute a feature + virtual void execute( const ::rtl::OUString& rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& rArgs ); + + // all the features which should be handled by this class + virtual void describeSupportedFeatures(); + +private: + void executeDispatch_FontDialog(); + + ChartController* m_pChartController; +}; + +//............................................................................. +} // namespace chart +//............................................................................. + +// CHART2_SHAPECONTROLLER_HXX +#endif diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index 6471911e3866..0ddc49661b3b 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -71,7 +71,9 @@ SLOFILES = \ $(SLO)$/ChartDropTargetHelper.obj \ $(SLO)$/StatusBarCommandDispatch.obj \ $(SLO)$/ChartTransferable.obj \ - $(SLO)$/DrawCommandDispatch.obj + $(SLO)$/FeatureCommandDispatchBase.obj \ + $(SLO)$/DrawCommandDispatch.obj \ + $(SLO)$/ShapeController.obj # $(SLO)$/CommonConverters.obj \ # $(SLO)$/Scaling.obj \ diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk index 38eaec110f74..7392ddf04b91 100644 --- a/chart2/source/controller/makefile.mk +++ b/chart2/source/controller/makefile.mk @@ -116,6 +116,7 @@ DEF1NAME= $(SHL1TARGET) # sfx.srs is needed for the strings for UNDO and REDO in the UndoCommandDispatch RESLIB1LIST=\ $(SRS)$/chcdialogs.srs \ + $(SRS)$/chcmenus.srs \ $(SOLARCOMMONRESDIR)$/sfx.srs RESLIB1NAME= $(TARGET) diff --git a/chart2/source/controller/menus/ShapeContextMenu.src b/chart2/source/controller/menus/ShapeContextMenu.src new file mode 100644 index 000000000000..722b92e5f768 --- /dev/null +++ b/chart2/source/controller/menus/ShapeContextMenu.src @@ -0,0 +1,56 @@ +/************************************************************************* + * + * 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: ShapeContextMenu.src,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#include "MenuResIds.hrc" + +#include <svx/globlmn.hrc> +#include <svx/svxids.hrc> + +Menu RID_CONTEXTMENU_SHAPE +{ + ItemList = + { + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + ITEM_EDIT_CUT + }; + MenuItem + { + ITEM_EDIT_COPY + }; + MenuItem + { + ITEM_EDIT_PASTE + }; + }; +}; diff --git a/chart2/source/controller/menus/ShapeEditContextMenu.src b/chart2/source/controller/menus/ShapeEditContextMenu.src new file mode 100644 index 000000000000..32dd66dc1337 --- /dev/null +++ b/chart2/source/controller/menus/ShapeEditContextMenu.src @@ -0,0 +1,62 @@ +/************************************************************************* + * + * 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: ShapeContextMenu.src,v $ + * $Revision: 1.0 $ + * + * 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. + * + ************************************************************************/ +#include "MenuResIds.hrc" + +#include <svx/globlmn.hrc> +#include <svx/svxids.hrc> + +Menu RID_CONTEXTMENU_SHAPEEDIT +{ + ItemList = + { + MenuItem + { + Identifier = SID_CHAR_DLG; + HelpId = SID_CHAR_DLG ; + Command = ".uno:FontDialog"; + }; + MenuItem + { + Separator = TRUE; + }; + MenuItem + { + ITEM_EDIT_CUT + }; + MenuItem + { + ITEM_EDIT_COPY + }; + MenuItem + { + ITEM_EDIT_PASTE + }; + }; +}; diff --git a/chart2/source/controller/menus/makefile.mk b/chart2/source/controller/menus/makefile.mk new file mode 100644 index 000000000000..cf40f961d1e1 --- /dev/null +++ b/chart2/source/controller/menus/makefile.mk @@ -0,0 +1,68 @@ +#************************************************************************* +# +# 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: makefile.mk,v $ +# +# $Revision: 1.0 $ +# +# 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. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcmenus + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE +GEN_HID_OTHER=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# i26518 the gcc-3.0.4 requires to enhance the template-depth +# this seems to be a compiler issue, so we recommend not to use 3.0.x anymore +.IF "$(COM)"=="GCC" + CFLAGS+=-ftemplate-depth-128 +.ENDIF + +# --- Resources --------------------------------------------------------------- + +SRC1FILES= \ + ShapeContextMenu.src \ + ShapeEditContextMenu.src + +SRS1NAME=$(TARGET) + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk + +#dependencies: + +$(SRS)$/chcmenus.srs: \ + ..$/inc$/MenuResIds.hrc + +#$(SRS)$/$(TARGET).srs: $(SOLARINCDIR)$/svx$/globlmn.hrc |