summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Benisch <tbe@openoffice.org>2009-10-02 16:06:50 +0000
committerThomas Benisch <tbe@openoffice.org>2009-10-02 16:06:50 +0000
commit7f626bd0cf5a9b0054ad5a51b70cb645f970275d (patch)
tree644c435c1362cf98a5940e7a571fb7bc4928f281
parent9cbd7552577fd95acec3969c9b701b642529c499 (diff)
#i12587# Inserting/editing arbitrary text objects in chart
-rw-r--r--chart2/source/controller/main/ChartController_Window.cxx9
-rw-r--r--chart2/source/controller/main/CommandDispatchContainer.hxx1
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.cxx82
-rw-r--r--chart2/source/controller/main/DrawCommandDispatch.hxx3
-rw-r--r--chart2/source/controller/main/FeatureCommandDispatchBase.cxx1
-rw-r--r--chart2/source/controller/main/FeatureCommandDispatchBase.hxx2
-rw-r--r--chart2/uiconfig/toolbar/drawbar.xml1
7 files changed, 94 insertions, 5 deletions
diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx
index 8763f1b30..9f5e364f3 100644
--- a/chart2/source/controller/main/ChartController_Window.cxx
+++ b/chart2/source/controller/main/ChartController_Window.cxx
@@ -52,6 +52,7 @@
#include "RelativePositionHelper.hxx"
#include "chartview/DrawModelWrapper.hxx"
#include "MenuResIds.hrc"
+#include "DrawCommandDispatch.hxx"
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
@@ -582,6 +583,14 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt )
if ( !pDrawViewWrapper->IsAction() )
{
pDrawViewWrapper->BegCreateObj( aMPos);
+ SdrObject* pObj = pDrawViewWrapper->GetCreateObj();
+ DrawCommandDispatch* pDrawCommandDispatch = m_aDispatchContainer.getDrawCommandDispatch();
+ if ( pObj && m_pDrawModelWrapper && pDrawCommandDispatch )
+ {
+ SfxItemSet aSet( m_pDrawModelWrapper->GetItemPool() );
+ pDrawCommandDispatch->setLineEnds( aSet );
+ pObj->SetMergedItemSet( aSet );
+ }
}
impl_SetMousePointer( rMEvt );
return;
diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx
index e6fd2aed0..33ca111ed 100644
--- a/chart2/source/controller/main/CommandDispatchContainer.hxx
+++ b/chart2/source/controller/main/CommandDispatchContainer.hxx
@@ -125,6 +125,7 @@ public:
const ::com::sun::star::util::URL & rURL );
void setDrawCommandDispatch( DrawCommandDispatch* pDispatch );
+ DrawCommandDispatch* getDrawCommandDispatch() { return m_pDrawCommandDispatch; }
void setShapeController( ShapeController* pController );
ShapeController* getShapeController() { return m_pShapeController; }
diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx
index 7bddfa81b..1ace2aa88 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.cxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.cxx
@@ -32,6 +32,7 @@
#include "precompiled_chart2.hxx"
#include "DrawCommandDispatch.hxx"
+#include "DrawCommandDispatch.hrc"
#include "ChartController.hxx"
#include "DrawViewWrapper.hxx"
#include "chartview/DrawModelWrapper.hxx"
@@ -39,10 +40,16 @@
#include <vos/mutex.hxx>
#include <vcl/svapp.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
#include <svx/svdopath.hxx>
#include <svx/svdpage.hxx>
#include <svx/svxids.hrc>
#include <svx/unoapi.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xtable.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <boost/bind.hpp>
@@ -98,6 +105,65 @@ void DrawCommandDispatch::initialize()
FeatureCommandDispatchBase::initialize();
}
+::basegfx::B2DPolyPolygon getPolygon( sal_uInt16 nResId, SdrModel& rModel )
+{
+ ::basegfx::B2DPolyPolygon aReturn;
+ XLineEndList* pLineEndList = rModel.GetLineEndList();
+ if ( pLineEndList )
+ {
+ String aName( SVX_RES( nResId ) );
+ long nCount = pLineEndList->Count();
+ for ( long nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nIndex );
+ if ( pEntry->GetName() == aName )
+ {
+ aReturn = pEntry->GetLineEnd();
+ break;
+ }
+ }
+ }
+ return aReturn;
+}
+
+void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr )
+{
+ if ( m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController )
+ {
+ DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper();
+ DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper();
+ if ( pDrawModelWrapper && pDrawViewWrapper )
+ {
+ ::basegfx::B2DPolyPolygon aArrow( getPolygon( RID_SVXSTR_ARROW, pDrawModelWrapper->getSdrModel() ) );
+ if ( !aArrow.count() )
+ {
+ ::basegfx::B2DPolygon aNewArrow;
+ aNewArrow.append( ::basegfx::B2DPoint( 10.0, 0.0 ) );
+ aNewArrow.append( ::basegfx::B2DPoint( 0.0, 30.0) );
+ aNewArrow.append( ::basegfx::B2DPoint( 20.0, 30.0 ) );
+ aNewArrow.setClosed( true );
+ aArrow.append( aNewArrow );
+ }
+
+ SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() );
+ pDrawViewWrapper->GetAttributes( aSet );
+
+ long nWidth = 300; // (1/100th mm)
+ if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SFX_ITEM_DONTCARE )
+ {
+ long nValue = ( ( const XLineWidthItem& ) aSet.Get( XATTR_LINEWIDTH ) ).GetValue();
+ if ( nValue > 0 )
+ {
+ nWidth = nValue * 3;
+ }
+ }
+
+ rAttr.Put( XLineEndItem( SVX_RESSTR( RID_SVXSTR_ARROW ), aArrow ) );
+ rAttr.Put( XLineEndWidthItem( nWidth ) );
+ }
+ }
+}
+
// WeakComponentImplHelperBase
void DrawCommandDispatch::disposing()
{
@@ -120,6 +186,7 @@ FeatureState DrawCommandDispatch::getState( const ::rtl::OUString& rCommand )
{
case SID_OBJECT_SELECT:
case SID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
case SID_DRAW_RECT:
case SID_DRAW_ELLIPSE:
case SID_DRAW_TEXT:
@@ -147,6 +214,7 @@ void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequen
SdrObjKind eKind = OBJ_NONE;
bool bCreate = false;
sal_uInt16 nFeatureId = m_aSupportedFeatures[ rCommand ].nFeatureId;
+ m_nFeatureId = nFeatureId;
switch ( nFeatureId )
{
@@ -157,6 +225,7 @@ void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequen
}
break;
case SID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
{
eDrawMode = CHARTDRAW_INSERT;
eKind = OBJ_LINE;
@@ -236,11 +305,12 @@ void DrawCommandDispatch::execute( const ::rtl::OUString& rCommand, const Sequen
void DrawCommandDispatch::describeSupportedFeatures()
{
- implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT );
- implDescribeSupportedFeature( ".uno:Line", SID_DRAW_LINE, CommandGroup::INSERT );
- implDescribeSupportedFeature( ".uno:Rect", SID_DRAW_RECT, CommandGroup::INSERT );
- implDescribeSupportedFeature( ".uno:Ellipse", SID_DRAW_ELLIPSE, CommandGroup::INSERT );
- implDescribeSupportedFeature( ".uno:DrawText", SID_DRAW_TEXT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:SelectObject", SID_OBJECT_SELECT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Line", SID_DRAW_LINE, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:LineArrowEnd", COMMAND_ID_LINE_ARROW_END, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Rect", SID_DRAW_RECT, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:Ellipse", SID_DRAW_ELLIPSE, CommandGroup::INSERT );
+ implDescribeSupportedFeature( ".uno:DrawText", SID_DRAW_TEXT, CommandGroup::INSERT );
}
void DrawCommandDispatch::setInsertObj( USHORT eObj, const ::rtl::OUString& rShapeType )
@@ -283,6 +353,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
switch ( nID )
{
case SID_DRAW_LINE:
+ case COMMAND_ID_LINE_ARROW_END:
{
if ( pObj->ISA( SdrPathObj ) )
{
@@ -294,6 +365,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID )
aPoly.append( basegfx::B2DPoint( aEnd.X(), nYMiddle ) );
( dynamic_cast< SdrPathObj* >( pObj ) )->SetPathPoly( basegfx::B2DPolyPolygon( aPoly ) );
SfxItemSet aSet( pDrawModelWrapper->GetItemPool() );
+ setLineEnds( aSet );
pObj->SetMergedItemSet( aSet );
}
}
diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx
index bd50abe5e..c3fdb25ba 100644
--- a/chart2/source/controller/main/DrawCommandDispatch.hxx
+++ b/chart2/source/controller/main/DrawCommandDispatch.hxx
@@ -34,6 +34,7 @@
#include <tools/solar.h>
+class SfxItemSet;
class SdrObject;
//.............................................................................
@@ -55,6 +56,8 @@ public:
// late initialisation, especially for adding as listener
virtual void initialize();
+ void setLineEnds( SfxItemSet& rAttr );
+
protected:
// WeakComponentImplHelperBase
virtual void SAL_CALL disposing();
diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
index c3fef5a96..51e20e407 100644
--- a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
+++ b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
@@ -43,6 +43,7 @@ namespace chart
FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
:CommandDispatch( rxContext )
+ ,m_nFeatureId( 0 )
{
}
diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
index ab862f222..96af3735c 100644
--- a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
+++ b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
@@ -106,6 +106,8 @@ protected:
mutable SupportedFeatures m_aSupportedFeatures;
+ sal_uInt16 m_nFeatureId;
+
private:
void fillSupportedFeatures();
};
diff --git a/chart2/uiconfig/toolbar/drawbar.xml b/chart2/uiconfig/toolbar/drawbar.xml
index 2407475a8..b18c4868f 100644
--- a/chart2/uiconfig/toolbar/drawbar.xml
+++ b/chart2/uiconfig/toolbar/drawbar.xml
@@ -4,6 +4,7 @@
<toolbar:toolbaritem xlink:href=".uno:SelectObject" toolbar:helpid="10128"/>
<toolbar:toolbarseparator/>
<toolbar:toolbaritem xlink:href=".uno:Line" toolbar:helpid="10102"/>
+ <toolbar:toolbaritem xlink:href=".uno:LineArrowEnd" toolbar:helpid="27173"/>
<toolbar:toolbaritem xlink:href=".uno:Rect" toolbar:helpid="10104"/>
<toolbar:toolbaritem xlink:href=".uno:Ellipse" toolbar:helpid="10110"/>
<toolbar:toolbaritem xlink:href=".uno:Polygon_Unfilled" toolbar:visible="false" toolbar:helpid="10395"/>