LibreOffice Module scripting (master) 1
DialogModelProvider.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include "dlgprov.hxx"
22#include <com/sun/star/resource/XStringResourceManager.hpp>
23#include <com/sun/star/ucb/SimpleFileAccess.hpp>
24
26
28namespace dlgprov {
29
30using namespace ::com::sun::star;
31using namespace awt;
32using namespace lang;
33using namespace uno;
34using namespace script;
35using namespace beans;
36
37
39 m_xContext(context)
40{}
41
42// lang::XInitialization:
43void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any > & aArguments)
44{
45 if ( aArguments.getLength() != 1 )
46 return;
47
48 OUString sURL;
49 if ( !( aArguments[ 0 ] >>= sURL ))
50 throw css::lang::IllegalArgumentException();
51 // Try any other URL with SimpleFileAccess
52 Reference< ucb::XSimpleFileAccess3 > xSFI = ucb::SimpleFileAccess::create(m_xContext);
53
54 try
55 {
56 Reference< io::XInputStream > xInput = xSFI->openFileRead( sURL );
58 if ( xInput.is() )
59 {
60 xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL);
61 Any aDialogSourceURLAny;
62 aDialogSourceURLAny <<= sURL;
63
65 m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_SET_THROW);
66 m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW);
67 }
68 }
69 catch( Exception& )
70 {}
71 //m_sURL = sURL;
72}
73
74// container::XElementAccess:
76{
77 return m_xDialogModel->getElementType();
78}
79
81{
82 return m_xDialogModel->hasElements();
83}
84
85// container::XNameAccess:
86uno::Any SAL_CALL DialogModelProvider::getByName(const OUString & aName)
87{
88 return m_xDialogModel->getByName(aName);
89}
90
91css::uno::Sequence< OUString > SAL_CALL DialogModelProvider::getElementNames()
92{
93 return m_xDialogModel->getElementNames();
94}
95
96sal_Bool SAL_CALL DialogModelProvider::hasByName(const OUString & aName)
97{
98 return m_xDialogModel->hasByName(aName);
99}
100
101// container::XNameReplace:
102void SAL_CALL DialogModelProvider::replaceByName(const OUString & aName, const uno::Any & aElement)
103{
104 m_xDialogModel->replaceByName(aName,aElement);
105}
106
107// container::XNameContainer:
108void SAL_CALL DialogModelProvider::insertByName(const OUString & aName, const uno::Any & aElement)
109{
110 m_xDialogModel->insertByName(aName,aElement);
111}
112
113void SAL_CALL DialogModelProvider::removeByName(const OUString & aName)
114{
115 m_xDialogModel->removeByName(aName);
116}
118{
119 return m_xDialogModelProp->getPropertySetInfo();
120}
121void SAL_CALL DialogModelProvider::setPropertyValue( const OUString&, const uno::Any& )
122{
123}
124uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const OUString& PropertyName )
125{
126 return m_xDialogModelProp->getPropertyValue(PropertyName);
127}
129{
130}
132{
133}
135{
136}
138{
139}
140
141// com.sun.star.uno.XServiceInfo:
143{
144 return "com.sun.star.comp.scripting.DialogModelProvider";
145}
146
147sal_Bool SAL_CALL DialogModelProvider::supportsService(OUString const & serviceName)
148{
149 return cppu::supportsService(this, serviceName);
150}
151
152css::uno::Sequence< OUString > SAL_CALL DialogModelProvider::getSupportedServiceNames()
153{
154 return { "com.sun.star.awt.UnoControlDialogModelProvider" };
155}
156
157} // closing anonymous implementation namespace
158
159extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
161 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
162{
163 return cppu::acquire(new dlgprov::DialogModelProvider(context));
164}
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * scripting_DialogModelProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Reference< XComponentContext > m_xContext
sal_Int16 script
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual sal_Bool SAL_CALL hasElements() override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
css::uno::Reference< css::container::XNameContainer > m_xDialogModel
css::uno::Reference< css::beans::XPropertySet > m_xDialogModelProp
virtual void SAL_CALL removeByName(const OUString &Name) override
DialogModelProvider(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Sequence< PropertyValue > aArguments
OUString aName
@ Exception
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
anonymous implementation namespace
Reference< resource::XStringResourceManager > lcl_getStringResourceManager(const Reference< XComponentContext > &i_xContext, std::u16string_view i_sURL)
Definition: dlgprov.cxx:66
Reference< container::XNameContainer > lcl_createDialogModel(const Reference< XComponentContext > &i_xContext, const Reference< io::XInputStream > &xInput, const Reference< frame::XModel > &xModel, const Reference< resource::XStringResourceManager > &xStringResourceManager, const Any &aDialogSourceURL)
Definition: dlgprov.cxx:102
Reference< XModel > xModel
unsigned char sal_Bool