2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2008-03-18 12:46:13 +00:00
|
|
|
|
2014-06-04 10:55:43 +02:00
|
|
|
#include <sal/config.h>
|
2008-03-18 12:46:13 +00:00
|
|
|
|
2011-09-15 14:44:34 +02:00
|
|
|
#include "desktopdllapi.h"
|
|
|
|
|
2008-03-18 12:46:13 +00:00
|
|
|
#include "app.hxx"
|
2013-03-12 13:43:31 +02:00
|
|
|
#include "exithelper.h"
|
2011-01-18 16:46:26 -05:00
|
|
|
#include "cmdlineargs.hxx"
|
|
|
|
#include "cmdlinehelp.hxx"
|
2008-03-18 12:46:13 +00:00
|
|
|
|
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
2014-08-13 12:27:44 +03:00
|
|
|
#include <osl/file.hxx>
|
2012-01-21 21:55:53 +00:00
|
|
|
#include <rtl/bootstrap.hxx>
|
2015-04-22 09:42:28 +02:00
|
|
|
#include <sal/log.hxx>
|
2008-03-18 12:46:13 +00:00
|
|
|
#include <tools/extendapplicationenvironment.hxx>
|
2014-06-25 14:57:44 +02:00
|
|
|
#include <vcl/svmain.hxx>
|
2008-03-18 12:46:13 +00:00
|
|
|
|
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
2014-08-13 12:27:44 +03:00
|
|
|
#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>
|
|
|
|
|
2012-12-15 18:13:11 +00:00
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
# include <jni.h>
|
2013-02-28 10:22:25 +02:00
|
|
|
# include <android/log.h>
|
2012-12-15 18:13:11 +00:00
|
|
|
# include <salhelper/thread.hxx>
|
2013-02-28 10:22:25 +02:00
|
|
|
|
|
|
|
# define LOGTAG "LibreOffice/sofficemain"
|
|
|
|
# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOGTAG, __VA_ARGS__))
|
2012-12-15 18:13:11 +00:00
|
|
|
#endif
|
|
|
|
|
2011-09-15 14:44:34 +02:00
|
|
|
extern "C" int DESKTOP_DLLPUBLIC soffice_main()
|
2008-03-18 12:46:13 +00:00
|
|
|
{
|
2014-12-22 19:10:59 +01:00
|
|
|
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID && !defined(LIBO_HEADLESS)
|
2014-11-20 09:52:03 +01:00
|
|
|
/* Run test for OpenGL support in own process to avoid crash with broken
|
|
|
|
* OpenGL drivers. Start process as early as possible.
|
|
|
|
*/
|
|
|
|
bool bSuccess = fire_glxtest_process();
|
|
|
|
SAL_WARN_IF(!bSuccess, "desktop.opengl", "problems with glxtest");
|
|
|
|
#endif
|
|
|
|
|
2012-09-18 12:40:57 +02:00
|
|
|
#if defined ANDROID
|
2012-01-21 21:46:00 +00:00
|
|
|
try {
|
2012-12-30 11:21:11 +01:00
|
|
|
rtl::Bootstrap::setIniFilename("file:///assets/program/lofficerc");
|
2012-01-21 21:46:00 +00:00
|
|
|
#endif
|
2008-03-18 12:46:13 +00:00
|
|
|
tools::extendApplicationEnvironment();
|
|
|
|
|
|
|
|
desktop::Desktop aDesktop;
|
|
|
|
// This string is used during initialization of the Gtk+ VCL module
|
2014-06-13 17:49:37 +02:00
|
|
|
Application::SetAppName( OUString("soffice") );
|
2011-01-18 16:46:26 -05:00
|
|
|
#ifdef UNX
|
|
|
|
// handle --version and --help already here, otherwise they would be handled
|
|
|
|
// after VCL initialization that might fail if $DISPLAY is not set
|
2014-06-13 17:49:37 +02:00
|
|
|
const desktop::CommandLineArgs& rCmdLineArgs = desktop::Desktop::GetCommandLineArgs();
|
2012-09-25 10:15:15 +02:00
|
|
|
OUString aUnknown( rCmdLineArgs.GetUnknown() );
|
|
|
|
if ( !aUnknown.isEmpty() )
|
|
|
|
{
|
|
|
|
desktop::Desktop::InitApplicationServiceManager();
|
|
|
|
desktop::displayCmdlineHelp( aUnknown );
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2011-04-01 21:06:41 +01:00
|
|
|
if ( rCmdLineArgs.IsHelp() )
|
2011-01-18 16:46:26 -05:00
|
|
|
{
|
2012-09-24 17:41:51 +02:00
|
|
|
desktop::Desktop::InitApplicationServiceManager();
|
2012-09-25 10:15:15 +02:00
|
|
|
desktop::displayCmdlineHelp( OUString() );
|
2011-01-18 16:46:26 -05:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
2012-09-25 10:15:15 +02:00
|
|
|
if ( rCmdLineArgs.IsVersion() )
|
2011-01-18 16:46:26 -05:00
|
|
|
{
|
2012-09-24 17:41:51 +02:00
|
|
|
desktop::Desktop::InitApplicationServiceManager();
|
2011-01-18 16:46:26 -05:00
|
|
|
desktop::displayVersion();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
#endif
|
2010-12-10 16:12:01 +00:00
|
|
|
return SVMain();
|
2012-07-25 10:31:21 +02:00
|
|
|
#if defined ANDROID
|
2012-09-18 12:40:57 +02:00
|
|
|
} catch (const ::com::sun::star::uno::Exception &e) {
|
2013-02-28 10:22:25 +02:00
|
|
|
LOGI("Unhandled UNO exception: '%s'",
|
2013-04-07 12:06:47 +02:00
|
|
|
OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
|
2012-01-23 08:55:18 +00:00
|
|
|
throw; // to get exception type printed
|
2012-01-21 21:46:00 +00:00
|
|
|
}
|
2012-08-06 10:53:19 +02:00
|
|
|
#endif
|
2008-03-18 12:46:13 +00:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
2013-03-20 09:07:52 +02:00
|
|
|
#if defined(ANDROID) || defined(IOS)
|
2012-12-15 18:13:11 +00:00
|
|
|
|
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
2014-08-13 12:27:44 +03:00
|
|
|
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");
|
2014-08-18 18:29:20 +03:00
|
|
|
OUString password("myPassword");
|
|
|
|
css::uno::Sequence<css::beans::NamedValue> encryptionData(1);
|
|
|
|
encryptionData[0].Name = "OOXPassword";
|
|
|
|
encryptionData[0].Value = css::uno::makeAny(password);
|
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
2014-08-13 12:27:44 +03:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2012-12-15 18:13:11 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|