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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "DialogModelProvider.hxx"
21 #include "dlgprov.hxx"
22 #include <com/sun/star/resource/XStringResourceManager.hpp>
23 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
26 // component helper namespace
27 namespace comp_DialogModelProvider
{
29 using namespace ::com::sun::star
;
33 using namespace script
;
34 using namespace beans
;
37 // component and service helper functions:
38 OUString SAL_CALL
_getImplementationName();
39 css::uno::Sequence
< OUString
> SAL_CALL
_getSupportedServiceNames();
40 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
_create( css::uno::Reference
< css::uno::XComponentContext
> const & context
);
42 } // closing component helper namespace
46 /// anonymous implementation namespace
49 using namespace ::com::sun::star
;
53 using namespace script
;
54 using namespace beans
;
57 DialogModelProvider::DialogModelProvider(Reference
< XComponentContext
> const & context
) :
61 // lang::XInitialization:
62 void SAL_CALL
DialogModelProvider::initialize(const css::uno::Sequence
< uno::Any
> & aArguments
) throw (css::uno::RuntimeException
, css::uno::Exception
)
64 if ( aArguments
.getLength() == 1 )
67 if ( !( aArguments
[ 0 ] >>= sURL
))
68 throw css::lang::IllegalArgumentException();
69 // Try any other URL with SimpleFileAccess
70 Reference
< ucb::XSimpleFileAccess3
> xSFI
= ucb::SimpleFileAccess::create(m_xContext
);
74 Reference
< io::XInputStream
> xInput
= xSFI
->openFileRead( sURL
);
75 Reference
< resource::XStringResourceManager
> xStringResourceManager
;
78 xStringResourceManager
= dlgprov::lcl_getStringResourceManager(m_xContext
,sURL
);
79 Any aDialogSourceURLAny
;
80 aDialogSourceURLAny
<<= sURL
;
82 Reference
< frame::XModel
> xModel
;
83 m_xDialogModel
.set( dlgprov::lcl_createDialogModel( m_xContext
, xInput
, xModel
, xStringResourceManager
, aDialogSourceURLAny
), UNO_QUERY_THROW
);
84 m_xDialogModelProp
.set(m_xDialogModel
, UNO_QUERY_THROW
);
93 // container::XElementAccess:
94 uno::Type SAL_CALL
DialogModelProvider::getElementType() throw (css::uno::RuntimeException
)
96 return m_xDialogModel
->getElementType();
99 ::sal_Bool SAL_CALL
DialogModelProvider::hasElements() throw (css::uno::RuntimeException
)
101 return m_xDialogModel
->hasElements();
104 // container::XNameAccess:
105 uno::Any SAL_CALL
DialogModelProvider::getByName(const OUString
& aName
) throw (css::uno::RuntimeException
, css::container::NoSuchElementException
, css::lang::WrappedTargetException
)
107 return m_xDialogModel
->getByName(aName
);
110 css::uno::Sequence
< OUString
> SAL_CALL
DialogModelProvider::getElementNames() throw (css::uno::RuntimeException
)
112 return m_xDialogModel
->getElementNames();
115 ::sal_Bool SAL_CALL
DialogModelProvider::hasByName(const OUString
& aName
) throw (css::uno::RuntimeException
)
117 return m_xDialogModel
->hasByName(aName
);
120 // container::XNameReplace:
121 void SAL_CALL
DialogModelProvider::replaceByName(const OUString
& aName
, const uno::Any
& aElement
) throw (css::uno::RuntimeException
, css::lang::IllegalArgumentException
, css::container::NoSuchElementException
, css::lang::WrappedTargetException
)
123 m_xDialogModel
->replaceByName(aName
,aElement
);
126 // container::XNameContainer:
127 void SAL_CALL
DialogModelProvider::insertByName(const OUString
& aName
, const uno::Any
& aElement
) throw (css::uno::RuntimeException
, css::lang::IllegalArgumentException
, css::container::ElementExistException
, css::lang::WrappedTargetException
)
129 m_xDialogModel
->insertByName(aName
,aElement
);
132 void SAL_CALL
DialogModelProvider::removeByName(const OUString
& aName
) throw (css::uno::RuntimeException
, css::container::NoSuchElementException
, css::lang::WrappedTargetException
)
134 m_xDialogModel
->removeByName(aName
);
136 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException
)
138 return m_xDialogModelProp
->getPropertySetInfo();
140 void SAL_CALL
DialogModelProvider::setPropertyValue( const OUString
&, const uno::Any
& ) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
)
143 uno::Any SAL_CALL
DialogModelProvider::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
145 return m_xDialogModelProp
->getPropertyValue(PropertyName
);
147 void SAL_CALL
DialogModelProvider::addPropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
150 void SAL_CALL
DialogModelProvider::removePropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
153 void SAL_CALL
DialogModelProvider::addVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
156 void SAL_CALL
DialogModelProvider::removeVetoableChangeListener( const OUString
& ,const uno::Reference
< beans::XVetoableChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
)
160 // com.sun.star.uno.XServiceInfo:
161 OUString SAL_CALL
DialogModelProvider::getImplementationName() throw (css::uno::RuntimeException
)
163 return comp_DialogModelProvider::_getImplementationName();
166 ::sal_Bool SAL_CALL
DialogModelProvider::supportsService(OUString
const & serviceName
) throw (css::uno::RuntimeException
)
168 css::uno::Sequence
< OUString
> serviceNames
= comp_DialogModelProvider::_getSupportedServiceNames();
169 for (::sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
170 if (serviceNames
[i
] == serviceName
)
176 css::uno::Sequence
< OUString
> SAL_CALL
DialogModelProvider::getSupportedServiceNames() throw (css::uno::RuntimeException
)
178 return comp_DialogModelProvider::_getSupportedServiceNames();
181 } // closing anonymous implementation namespace
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */