summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-08-13 12:27:44 +0300
committerTor Lillqvist <tml@collabora.com>2014-08-13 12:40:47 +0300
commit09f5922baf2cb455553d08a96d0576f7f8a45d16 (patch)
tree409346266d2ee944c2e6aa31b92e393733308fa7 /desktop
parent0ea59fd0bb19dafabcfdacf16fcc27f46796df4c (diff)
Add code to test encryption and export to .docx on iOS
Conditional on the environment variable PTYL_TEST_ENCRYPTION_AND_EXPORT, eek. The document is written out using the name of the input document with .new.docx appended. I placed the function that handles it, somewhat arbitrarily, in sofficemain.cxx. The invocation of this function is, also somewhat arbitrarily, placed in TiledView's drawLayer:inContext: method. Quite possibly this test functionality occasionally causes solar mutex deadlocks or whatever, but at least in Xcode, when one has placed some breakpoints in it, it seems to work. Which is what matters, as this is code for manual testing, not invoked normally. Change-Id: I38bb4b406edf47f0f24857b6044e3bf4eaf17c34
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/sofficemain.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index baf6a1be1da1..ef7d1725098c 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -26,10 +26,19 @@
#include "cmdlineargs.hxx"
#include "cmdlinehelp.hxx"
+#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <tools/extendapplicationenvironment.hxx>
#include <vcl/svmain.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XStorable2.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <unotools/mediadescriptor.hxx>
+
#ifdef ANDROID
# include <jni.h>
@@ -114,6 +123,29 @@ touch_lo_runMain()
}
+extern "C" void PtylTestEncryptionAndExport(const char *pathname)
+{
+ OUString sUri(pathname, strlen(pathname), RTL_TEXTENCODING_UTF8);
+ sUri = "file://" + sUri;
+
+ css::uno::Reference<css::frame::XComponentLoader> loader(css::frame::Desktop::create(cppu::defaultBootstrap_InitialComponentContext()), css::uno::UNO_QUERY);
+ css::uno::Reference<css::lang::XComponent> component;
+ component.set(loader->loadComponentFromURL(sUri, "_default", 0, {}));
+
+ utl::MediaDescriptor media;
+ media[utl::MediaDescriptor::PROP_FILTERNAME()] <<= OUString("MS Word 2007 XML");
+ css::uno::Sequence<css::beans::NamedValue> encryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData("myPassword");
+ media[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= encryptionData;
+
+ css::uno::Reference<css::frame::XModel> model(component, css::uno::UNO_QUERY);
+ css::uno::Reference<css::frame::XStorable2> storable2(model, css::uno::UNO_QUERY);
+ OUString saveAsUri(sUri + ".new.docx");
+ SAL_INFO("desktop.app", "Trying to store as " << saveAsUri);
+ OUString testPathName;
+ osl::File::getSystemPathFromFileURL(saveAsUri+".txt", testPathName);
+ storable2->storeToURL(saveAsUri, media.getAsConstPropertyValueList());
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */