diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-03-22 19:44:44 +0000 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:39:38 +0200 |
commit | 5bcb73a5942f3dee168100b5305e2398ca2c3652 (patch) | |
tree | 80bd166e19c18cd50583bbcd0db98bac5ed6cfe9 | |
parent | eac9aad0362a8d828ccd01e753ecf385096101ae (diff) |
tubes: re-use autorecovery to serialize to a file for exchange
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 38 | ||||
-rw-r--r-- | sc/source/ui/inc/docfunc.hxx | 3 |
2 files changed, 39 insertions, 2 deletions
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index f1aec1bf2492..9d9a10c37297 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -34,6 +34,14 @@ #include "docsh.hxx" #include "docfunc.hxx" +// new file send/recv fun ... +#include <unotools/tempfile.hxx> +#include <unotools/localfilehelper.hxx> +#include <comphelper/mediadescriptor.hxx> +#include <com/sun/star/document/XDocumentRecovery.hpp> + +namespace css = ::com::sun::star; + namespace { rtl::OUString cellToString( ScBaseCell *pCell ) @@ -282,6 +290,32 @@ class ScDocFuncSend : public ScDocFunc mpChain->RecvMessage( rOp.toString() ); } + void SendFile( const rtl::OUString &rURL ) + { + (void)rURL; + + String aTmpPath = utl::TempFile::CreateTempName(); + aTmpPath.Append( rtl::OUString( ".ods" ) ); + + rtl::OUString aFileURL; + ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aTmpPath, aFileURL ); + + ::comphelper::MediaDescriptor aDescriptor; + // some issue with hyperlinks: + aDescriptor[::comphelper::MediaDescriptor::PROP_DOCUMENTBASEURL()] <<= ::rtl::OUString(); + try { + css::uno::Reference< css::document::XDocumentRecovery > xDocRecovery( + rDocShell.GetBaseModel(), css::uno::UNO_QUERY_THROW); + + xDocRecovery->storeToRecoveryFile( aFileURL, aDescriptor.getAsConstPropertyValueList() ); + } catch (const css::uno::Exception &ex) { + fprintf( stderr, "exception foo !\n" ); + } + + fprintf( stderr, "Temp file is '%s'\n", + rtl::OUStringToOString( aFileURL, RTL_TEXTENCODING_UTF8 ).getStr() ); +} + public: // FIXME: really ScDocFunc should be an abstract base, so // we don't need the rDocSh hack/pointer @@ -314,6 +348,10 @@ public: aOp.appendString( rText ); aOp.appendBool( bApi ); SendMessage( aOp ); + + if ( rtl::OUString( rText ) == "saveme" ) + SendFile( rText ); + return true; // needs some code auditing action } diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx index a0dc639ea0ed..61524c711f85 100644 --- a/sc/source/ui/inc/docfunc.hxx +++ b/sc/source/ui/inc/docfunc.hxx @@ -58,7 +58,7 @@ class ScConditionalFormat; class ScDocFunc { -private: +protected: ScDocShell& rDocShell; sal_Bool AdjustRowHeight( const ScRange& rRange, sal_Bool bPaint = true ); @@ -68,7 +68,6 @@ private: sal_Bool& rCancel, sal_Bool bApi ); void NotifyInputHandler( const ScAddress& rPos ); -protected: ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {} public: virtual ~ScDocFunc() {} |