summaryrefslogtreecommitdiff
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
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
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu5
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu5
-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
-rw-r--r--svx/inc/svx/svxids.hrc1
-rw-r--r--svx/sdi/svx.sdi25
9 files changed, 111 insertions, 2 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
index bad0084c29a7..b03d7d4eddb7 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu
@@ -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>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index be306966b30f..74b99f1e6ca2 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -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>
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>
diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc
index 43411c808214..e92b3da33ff6 100644
--- a/svx/inc/svx/svxids.hrc
+++ b/svx/inc/svx/svxids.hrc
@@ -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 )
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index a0b4f8546d1f..c432a52017a7 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -6449,6 +6449,31 @@ SfxVoidItem InsertObjectChart SID_INSERT_DIAGRAM
]
//--------------------------------------------------------------------------
+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,
SfxStringItem Commands FN_PARAM_3)