bump product version to 4.1.6.2
[LibreOffice.git] / unotest / source / cpp / macros_test.cxx
blob8a5c1ec3cb7a84f2354d91a774e005a4983ead67
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "unotest/macros_test.hxx"
12 #include <com/sun/star/frame/XComponentLoader.hpp>
13 #include <com/sun/star/document/MacroExecMode.hpp>
15 #include "cppunit/TestAssert.h"
16 #include <rtl/ustrbuf.hxx>
18 using namespace com::sun::star;
20 namespace unotest {
22 uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const OUString& rURL, const char* pDocService)
24 uno::Reference< com::sun::star::frame::XComponentLoader> xLoader = uno::Reference< com::sun::star::frame::XComponentLoader >( mxDesktop, uno::UNO_QUERY );
25 com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > args(1);
26 args[0].Name = "MacroExecutionMode";
27 args[0].Handle = -1;
28 args[0].Value <<=
29 com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
30 args[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
32 if (pDocService)
34 args.realloc(2);
35 args[1].Name = "DocumentService";
36 args[1].Handle = -1;
37 args[1].Value <<= OUString::createFromAscii(pDocService);
38 args[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
41 uno::Reference< com::sun::star::lang::XComponent> xComponent= xLoader->loadComponentFromURL(rURL, OUString("_default"), 0, args);
42 OUString sMessage = OUString( "loading failed: " ) + rURL;
43 CPPUNIT_ASSERT_MESSAGE(OUStringToOString( sMessage, RTL_TEXTENCODING_UTF8 ).getStr( ), xComponent.is());
44 return xComponent;
49 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */