1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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
;
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";
29 com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN
;
30 args
[0].State
= com::sun::star::beans::PropertyState_DIRECT_VALUE
;
35 args
[1].Name
= "DocumentService";
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());
49 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */