Branch data Line data Source code
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 : :
20 : : #include "DialogModelProvider.hxx"
21 : : #include "dlgprov.hxx"
22 : : #include <com/sun/star/resource/XStringResourceManager.hpp>
23 : : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
24 : : #include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
25 : :
26 : :
27 : : // component helper namespace
28 : : namespace comp_DialogModelProvider {
29 : :
30 : : namespace css = ::com::sun::star;
31 : : using namespace ::com::sun::star;
32 : : using namespace awt;
33 : : using namespace lang;
34 : : using namespace uno;
35 : : using namespace script;
36 : : using namespace beans;
37 : :
38 : :
39 : : // component and service helper functions:
40 : : ::rtl::OUString SAL_CALL _getImplementationName();
41 : : css::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
42 : : css::uno::Reference< css::uno::XInterface > SAL_CALL _create( css::uno::Reference< css::uno::XComponentContext > const & context );
43 : :
44 : : } // closing component helper namespace
45 : :
46 : :
47 : :
48 : : /// anonymous implementation namespace
49 : : namespace dlgprov {
50 : :
51 : : namespace css = ::com::sun::star;
52 : : using namespace ::com::sun::star;
53 : : using namespace awt;
54 : : using namespace lang;
55 : : using namespace uno;
56 : : using namespace script;
57 : : using namespace beans;
58 : :
59 : :
60 : 0 : DialogModelProvider::DialogModelProvider(Reference< XComponentContext > const & context) :
61 : 0 : m_xContext(context)
62 : 0 : {}
63 : :
64 : : // lang::XInitialization:
65 : 0 : void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any > & aArguments) throw (css::uno::RuntimeException, css::uno::Exception)
66 : : {
67 : 0 : if ( aArguments.getLength() == 1 )
68 : : {
69 : 0 : ::rtl::OUString sURL;
70 : 0 : if ( !( aArguments[ 0 ] >>= sURL ))
71 : 0 : throw css::lang::IllegalArgumentException();
72 : : // Try any other URL with SimpleFileAccess
73 : 0 : Reference< ucb::XSimpleFileAccess2 > xSFI = ucb::SimpleFileAccess::create(m_xContext);
74 : :
75 : : try
76 : : {
77 : 0 : Reference< io::XInputStream > xInput = xSFI->openFileRead( sURL );
78 : 0 : Reference< resource::XStringResourceManager > xStringResourceManager;
79 : 0 : if ( xInput.is() )
80 : : {
81 : 0 : xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL);
82 : 0 : Any aDialogSourceURLAny;
83 : 0 : aDialogSourceURLAny <<= sURL;
84 : :
85 : 0 : Reference< frame::XModel > xModel;
86 : 0 : m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_QUERY_THROW);
87 : 0 : m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW);
88 : 0 : }
89 : : }
90 : 0 : catch( Exception& )
91 : 0 : {}
92 : : //m_sURL = sURL;
93 : : }
94 : 0 : }
95 : :
96 : : // container::XElementAccess:
97 : 0 : uno::Type SAL_CALL DialogModelProvider::getElementType() throw (css::uno::RuntimeException)
98 : : {
99 : 0 : return m_xDialogModel->getElementType();
100 : : }
101 : :
102 : 0 : ::sal_Bool SAL_CALL DialogModelProvider::hasElements() throw (css::uno::RuntimeException)
103 : : {
104 : 0 : return m_xDialogModel->hasElements();
105 : : }
106 : :
107 : : // container::XNameAccess:
108 : 0 : uno::Any SAL_CALL DialogModelProvider::getByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException)
109 : : {
110 : 0 : return m_xDialogModel->getByName(aName);
111 : : }
112 : :
113 : 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getElementNames() throw (css::uno::RuntimeException)
114 : : {
115 : 0 : return m_xDialogModel->getElementNames();
116 : : }
117 : :
118 : 0 : ::sal_Bool SAL_CALL DialogModelProvider::hasByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException)
119 : : {
120 : 0 : return m_xDialogModel->hasByName(aName);
121 : : }
122 : :
123 : : // container::XNameReplace:
124 : 0 : void SAL_CALL DialogModelProvider::replaceByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException)
125 : : {
126 : 0 : m_xDialogModel->replaceByName(aName,aElement);
127 : 0 : }
128 : :
129 : : // container::XNameContainer:
130 : 0 : void SAL_CALL DialogModelProvider::insertByName(const ::rtl::OUString & aName, const uno::Any & aElement) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException)
131 : : {
132 : 0 : m_xDialogModel->insertByName(aName,aElement);
133 : 0 : }
134 : :
135 : 0 : void SAL_CALL DialogModelProvider::removeByName(const ::rtl::OUString & aName) throw (css::uno::RuntimeException, css::container::NoSuchElementException, css::lang::WrappedTargetException)
136 : : {
137 : 0 : m_xDialogModel->removeByName(aName);
138 : 0 : }
139 : 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException)
140 : : {
141 : 0 : return m_xDialogModelProp->getPropertySetInfo();
142 : : }
143 : 0 : void SAL_CALL DialogModelProvider::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
144 : : {
145 : 0 : }
146 : 0 : uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
147 : : {
148 : 0 : return m_xDialogModelProp->getPropertyValue(PropertyName);
149 : : }
150 : 0 : void SAL_CALL DialogModelProvider::addPropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
151 : : {
152 : 0 : }
153 : 0 : void SAL_CALL DialogModelProvider::removePropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
154 : : {
155 : 0 : }
156 : 0 : void SAL_CALL DialogModelProvider::addVetoableChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
157 : : {
158 : 0 : }
159 : 0 : void SAL_CALL DialogModelProvider::removeVetoableChangeListener( const ::rtl::OUString& ,const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
160 : : {
161 : 0 : }
162 : :
163 : : // com.sun.star.uno.XServiceInfo:
164 : 0 : ::rtl::OUString SAL_CALL DialogModelProvider::getImplementationName() throw (css::uno::RuntimeException)
165 : : {
166 : 0 : return comp_DialogModelProvider::_getImplementationName();
167 : : }
168 : :
169 : 0 : ::sal_Bool SAL_CALL DialogModelProvider::supportsService(::rtl::OUString const & serviceName) throw (css::uno::RuntimeException)
170 : : {
171 : 0 : css::uno::Sequence< ::rtl::OUString > serviceNames = comp_DialogModelProvider::_getSupportedServiceNames();
172 : 0 : for (::sal_Int32 i = 0; i < serviceNames.getLength(); ++i) {
173 : 0 : if (serviceNames[i] == serviceName)
174 : 0 : return sal_True;
175 : : }
176 : 0 : return sal_False;
177 : : }
178 : :
179 : 0 : css::uno::Sequence< ::rtl::OUString > SAL_CALL DialogModelProvider::getSupportedServiceNames() throw (css::uno::RuntimeException)
180 : : {
181 : 0 : return comp_DialogModelProvider::_getSupportedServiceNames();
182 : : }
183 : :
184 : : } // closing anonymous implementation namespace
185 : :
186 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|