Kaydet (Commit) 4517bb39 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

first step for Insert->Chart From File

This needs some tweaks but it looks like we are already able to choose
the chart and import it. There are some more tweaks needed to handle
internal vs. external data provider, errors, other components, ...

Change-Id: Ib3e7f8bbf7b7f49b071d85120930624e2add91a7
üst b327b0dc
......@@ -380,6 +380,11 @@
<value xml:lang="en-US">Ch~art...</value>
</prop>
</node>
<node oor:name=".uno:InsertObjectChartFromFile" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Load Chart From File</value>
</prop>
</node>
<node oor:name=".uno:StarChartDialog" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Ch~art...</value>
......
......@@ -2131,6 +2131,11 @@
<value>1</value>
</prop>
</node>
<node oor:name=".uno:InsertObjectChartFromFile" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Chart from File</value>
</prop>
</node>
<node oor:name=".uno:DefaultBullet" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Bullets On/Off</value>
......
......@@ -113,6 +113,7 @@ interface BaseSelection
SID_FM_CREATE_CONTROL [ ExecMethod = ExecDraw ; ]
SID_LINKS [ ExecMethod = ExecDrawIns; StateMethod = GetDrawInsState; ]
SID_DRAW_CHART [ ExecMethod = ExecDraw; StateMethod = GetDrawState; ]
SID_INSERT_DIAGRAM_FROM_FILE [ ExecMethod = ExecDrawIns; StateMethod = GetDrawState; ]
SID_FM_CREATE_FIELDCONTROL [ ExecMethod = ExecDrawIns ; ]
// } Einfuegen von Objekten
......
......@@ -61,6 +61,9 @@
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/embed/XEmbeddedObjectCreator.hpp>
#include <com/sun/star/embed/EmbeddedObjectCreator.hpp>
using namespace ::com::sun::star;
// BM/IHA --
......@@ -776,5 +779,57 @@ void FuInsertChart::Deactivate()
FuPoor::Deactivate();
}
FuInsertChartFromFile::FuInsertChartFromFile( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
SdrModel* pDoc, SfxRequest& rReq, const OUString& rURL):
FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
{
uno::Reference< io::XInputStream > xStorage = comphelper::OStorageHelper::GetInputStreamFromURL(
rURL, comphelper::getProcessComponentContext());
comphelper::EmbeddedObjectContainer& rObjContainer =
pViewShell->GetObjectShell()->GetEmbeddedObjectContainer();
OUString aName;
uno::Reference< embed::XEmbeddedObject > xObj = rObjContainer.InsertEmbeddedObject( xStorage, aName );
uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
if( xCompSupp.is())
xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
awt::Size aSz = xObj->getVisualAreaSize( nAspect );
Size aSize( aSz.Width, aSz.Height );
MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
ScRange aPositionRange = pViewSh->GetViewData()->GetCurPos();
Point aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
Rectangle aRect (aStart, aSize);
SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
pSkipPaintObj = pObj;
SdrPageView* pPV = pView->GetSdrPageView();
// use the page instead of the view to insert, so no undo action is created yet
SdrPage* pInsPage = pPV->GetPage();
pInsPage->InsertObject( pObj );
pView->UnmarkAllObj();
pView->MarkObj( pObj, pPV );
pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW );
}
void FuInsertChartFromFile::Activate()
{
FuPoor::Activate();
}
void FuInsertChartFromFile::Deactivate()
{
FuPoor::Deactivate();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -58,7 +58,7 @@ class FuInsertChartFromFile : public FuPoor
{
public:
FuInsertChartFromFile( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
SdrModel* pDoc, SfxRequest& rReq);
SdrModel* pDoc, SfxRequest& rReq, const OUString& rURL);
virtual void Activate();
virtual void Deactivate();
......
......@@ -59,6 +59,9 @@
#include "drawview.hxx"
#include "ChartRangeSelectionListener.hxx"
#include <tools/urlobj.hxx>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
using namespace com::sun::star;
// STATIC DATA -----------------------------------------------------------
......@@ -301,6 +304,19 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
FuInsertOLE(this, pWin, pView, pDrModel, rReq);
break;
case SID_INSERT_DIAGRAM_FROM_FILE:
{
sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
0, OUString("com.sun.star.chart2.ChartDocument"));
if(aDlg.Execute() == ERRCODE_NONE )
{
INetURLObject aURLObj( aDlg.GetPath() );
OUString aURL = aURLObj.GetURLNoPass();
FuInsertChartFromFile(this, pWin, pView, pDrModel, rReq, aURL);
}
}
break;
case SID_OBJECTRESIZE:
{
// Der Server moechte die Clientgrosse verandern
......
......@@ -214,9 +214,10 @@
<menu:menuitem menu:id=".uno:InsertSound"/>
<menu:menuitem menu:id=".uno:InsertVideo"/>
<menu:menuitem menu:id=".uno:InsertObjectStarMath"/>
<menu:menuitem menu:id=".uno:InsertObjectChart"/>
<menu:menuitem menu:id=".uno:InsertObjectChartFromFile"/>
</menu:menupopup>
</menu:menu>
<menu:menuitem menu:id=".uno:InsertObjectChart"/>
<menu:menuitem menu:id=".uno:InsertObjectFloatingFrame"/>
</menu:menupopup>
</menu:menu>
......
......@@ -333,6 +333,7 @@
#define SID_OBJECT_ALIGN_UP ( SID_SVX_START + 134 )
#define SID_OBJECT_ALIGN_MIDDLE ( SID_SVX_START + 135 )
#define SID_OBJECT_ALIGN_DOWN ( SID_SVX_START + 136 )
#define SID_INSERT_DIAGRAM_FROM_FILE ( SID_SVX_START + 139 )
#define SID_INSERT_DIAGRAM ( SID_SVX_START + 140 )
#define SID_DRAW_CHART SID_INSERT_DIAGRAM
#define SID_INSERT_TABLE ( SID_SVX_START + 141 )
......
......@@ -6448,6 +6448,31 @@ SfxVoidItem InsertObjectChart SID_INSERT_DIAGRAM
GroupId = GID_INSERT;
]
//--------------------------------------------------------------------------
SfxVoidItem InsertObjectChartFromFile SID_INSERT_DIAGRAM_FROM_FILE
()
[
/* flags: */
AutoUpdate = FALSE,
Cachable = Cachable,
FastCall = FALSE,
HasCoreId = FALSE,
HasDialog = FALSE,
ReadOnlyDoc = FALSE,
Toggle = FALSE,
Container = FALSE,
RecordAbsolute = FALSE,
RecordPerSet;
Asynchron;
/* config: */
AccelConfig = TRUE,
MenuConfig = TRUE,
StatusBarConfig = FALSE,
ToolBoxConfig = TRUE,
GroupId = GID_INSERT;
]
//--------------------------------------------------------------------------
SfxVoidItem InsertPlugin SID_INSERT_PLUGIN
(SfxStringItem ClassLocation FN_PARAM_2,
......
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