summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-15 01:22:13 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-15 01:30:54 +0100
commitff98426745b76fef17e78d75f9b18b26ebc69a74 (patch)
tree9262b1f41e1493e2bd909ba56e9d57b6fed12f63 /sc
parentca4d16429ab0d060b8e894fc6363b75ba82c80b0 (diff)
initial work on an odc export
We can now export a chart to odc when we are in chart edit mode from Calc. I need to add support for it to Writer and Impress as well. We can already open these files but copy&paste from the opened file fails. The next step is then to add a new menu entry Insert->Object->Chart from file Change-Id: I14d1702e79517e7319a1929de2be5501d375885d
Diffstat (limited to 'sc')
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/xmlwrap.hxx13
-rw-r--r--sc/source/ui/app/drwtrans.cxx2
-rw-r--r--sc/source/ui/app/transobj.cxx2
-rw-r--r--sc/source/ui/docshell/docsh.cxx47
-rw-r--r--sc/source/ui/inc/docsh.hxx2
6 files changed, 63 insertions, 4 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 0295e74a6da4..066e0b6b87fe 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -298,6 +298,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/filter/xml/xmlsubti \
sc/source/filter/xml/xmltabi \
sc/source/filter/xml/xmlwrap \
+ sc/source/filter/chart/chart_imp \
sc/source/ui/Accessibility/AccessibilityHints \
sc/source/ui/Accessibility/AccessibleCell \
sc/source/ui/Accessibility/AccessibleCellBase \
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx
index 42ab215be02b..b4b505cb3bbb 100644
--- a/sc/inc/xmlwrap.hxx
+++ b/sc/inc/xmlwrap.hxx
@@ -23,6 +23,7 @@
#include <tools/solar.h>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/frame/XModel.hpp>
class ScDocument;
class SfxMedium;
@@ -71,6 +72,18 @@ public:
sal_Bool Export(sal_Bool bStylesOnly);
};
+class ScXMLChartExportWrapper
+{
+public:
+ ScXMLChartExportWrapper( com::sun::star::uno::Reference< com::sun::star::frame::XModel > xModel, SfxMedium& rMed );
+ bool Export();
+
+private:
+ com::sun::star::uno::Reference< com::sun::star::frame::XModel > mxModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > mxStorage;
+ SfxMedium& mrMedium;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index c0fb8ab73b68..1fdd9e3933db 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -578,7 +578,7 @@ sal_Bool ScDrawTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUse
::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
// write document storage
- pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
+ pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false, false );
// mba: no relative ULRs for clipboard!
SfxMedium aMedium( xWorkStore, String() );
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 103f64f8f281..5325fac83632 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -446,7 +446,7 @@ sal_Bool ScTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObj
::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
// write document storage
- pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false );
+ pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, false, false );
// mba: no relative ULRs for clipboard!
SfxMedium aMedium( xWorkStore, String() );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index c56d0100fc23..150c26993b5a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -47,6 +47,16 @@
#include <com/sun/star/task/XJob.hpp>
#include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/table/XTableChartsSupplier.hpp>
+#include <com/sun/star/table/XTableCharts.hpp>
+#include <com/sun/star/table/XTableChart.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+#include <com/sun/star/frame/XStorable2.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include "scabstdlg.hxx"
#include <sot/formats.hxx>
@@ -493,6 +503,29 @@ sal_Bool ScDocShell::SaveXML( SfxMedium* pSaveMedium, const ::com::sun::star::un
return bRet;
}
+bool ScDocShell::SaveCurrentChart( SfxMedium& rMedium )
+{
+ bool bRet = false;
+
+ try
+ {
+
+ uno::Reference< lang::XComponent > xCurrentComponent = frame::Desktop::create( comphelper::getProcessComponentContext() )->getCurrentComponent();
+
+ uno::Reference< frame::XStorable2 > xStorable( xCurrentComponent, uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XModel > xChartDoc ( xCurrentComponent, uno::UNO_QUERY_THROW );
+
+ ScXMLChartExportWrapper aExport( xChartDoc, rMedium );
+ bRet = aExport.Export();
+ }
+ catch(...)
+ {
+ SAL_WARN("sc", "exception thrown while saving chart. Bug!!!");
+ }
+ return bRet;
+}
+
sal_Bool ScDocShell::Load( SfxMedium& rMedium )
{
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Load" );
@@ -1584,10 +1617,20 @@ sal_Bool ScDocShell::SaveAs( SfxMedium& rMedium )
PrepareSaveGuard aPrepareGuard( *this);
+ OUString aFltName = rMedium.GetFilter()->GetFilterName();
+ bool bChartExport = aFltName.indexOf("chart8") != -1;
+
// wait cursor is handled with progress bar
- sal_Bool bRet = SfxObjectShell::SaveAs( rMedium );
- if( bRet )
+ sal_Bool bRet = false;
+ if(!bChartExport)
+ {
+ bRet = SfxObjectShell::SaveAs( rMedium );
bRet = SaveXML( &rMedium, NULL );
+ }
+ else
+ {
+ bRet = SaveCurrentChart( rMedium );
+ }
return bRet;
}
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 010ea826c362..55054f807909 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -139,6 +139,8 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
SC_DLLPRIVATE sal_Bool SaveXML( SfxMedium* pMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
SC_DLLPRIVATE SCTAB GetSaveTab();
+ SC_DLLPRIVATE bool SaveCurrentChart( SfxMedium& rMedium );
+
SC_DLLPRIVATE sal_uLong DBaseImport( const String& rFullFileName, CharSet eCharSet,
ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc );
SC_DLLPRIVATE sal_uLong DBaseExport(