summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-14 23:20:48 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-15 01:30:55 +0100
commit4517bb391afea870f856e030d8b1e5e8ee9364ac (patch)
tree4949d9d12301e4873b0cad8cb53c576fadea0d1a /sc
parentb327b0dc2724958acce6e1df1620c1a919ea6bf8 (diff)
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
Diffstat (limited to 'sc')
-rw-r--r--sc/sdi/tabvwsh.sdi1
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx55
-rw-r--r--sc/source/ui/inc/fuinsert.hxx2
-rw-r--r--sc/source/ui/view/tabvwshb.cxx16
-rw-r--r--sc/uiconfig/scalc/menubar/menubar.xml3
5 files changed, 75 insertions, 2 deletions
diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi
index 05459a036ac2..7bbdfca29166 100644
--- a/sc/sdi/tabvwsh.sdi
+++ b/sc/sdi/tabvwsh.sdi
@@ -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
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
index 30cdc7d2519b..f5a8aebb8167 100644
--- a/sc/source/ui/drawfunc/fuins2.cxx
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -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: */
diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx
index a4eb5842caa1..26e2a89322f5 100644
--- a/sc/source/ui/inc/fuinsert.hxx
+++ b/sc/source/ui/inc/fuinsert.hxx
@@ -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();
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 2765f71ca67f..b1fc8d378b0d 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -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
diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index 05442102ab02..de494d561607 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -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>