Kaydet (Commit) 884d21f1 authored tarafından Thomas Benisch's avatar Thomas Benisch

#i12587# Inserting/editing arbitrary text objects in chart

üst ff021541
......@@ -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;
......
......@@ -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; }
......
......@@ -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 );
}
}
......
......@@ -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();
......
......@@ -43,6 +43,7 @@ namespace chart
FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
:CommandDispatch( rxContext )
,m_nFeatureId( 0 )
{
}
......
......@@ -106,6 +106,8 @@ protected:
mutable SupportedFeatures m_aSupportedFeatures;
sal_uInt16 m_nFeatureId;
private:
void fillSupportedFeatures();
};
......
......@@ -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"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment