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>
25 #include <cppuhelper/supportsservice.hxx>
27 /// anonymous implementation namespace
30 using namespace ::com::sun::star
;
34 using namespace script
;
35 using namespace beans
;
38 DialogModelProvider::DialogModelProvider(Reference
< XComponentContext
> const & context
) :
42 // lang::XInitialization:
43 void SAL_CALL
DialogModelProvider::initialize(const css::uno::Sequence
< uno::Any
> & aArguments
) throw (css::uno::RuntimeException
, css::uno::Exception
, std::exception
)
45 if ( aArguments
.getLength() == 1 )
48 if ( !( aArguments
[ 0 ] >>= sURL
))
49 throw css::lang::IllegalArgumentException();
50 // Try any other URL with SimpleFileAccess
51 Reference
< ucb::XSimpleFileAccess3
> xSFI
= ucb::SimpleFileAccess::create(m_xContext
);
55 Reference
< io::XInputStream
> xInput
= xSFI
->openFileRead( sURL
);
56 Reference
< resource::XStringResourceManager
> xStringResourceManager
;
59 xStringResourceManager
= dlgprov::lcl_getStringResourceManager(m_xContext
,sURL
);
60 Any aDialogSourceURLAny
;
61 aDialogSourceURLAny
<<= sURL
;
63 Reference
< frame::XModel
> xModel
;
64 m_xDialogModel
.set( dlgprov::lcl_createDialogModel( m_xContext
, xInput
, xModel
, xStringResourceManager
, aDialogSourceURLAny
), UNO_QUERY_THROW
);
65 m_xDialogModelProp
.set(m_xDialogModel
, UNO_QUERY_THROW
);
74 // container::XElementAccess:
75 uno::Type SAL_CALL
DialogModelProvider::getElementType() throw (css::uno::RuntimeException
, std::exception
)
77 return m_xDialogModel
->getElementType();
80 sal_Bool SAL_CALL
DialogModelProvider::hasElements() throw (css::uno::RuntimeException
, std::exception
)
82 return m_xDialogModel
->hasElements();
85 // container::XNameAccess:
86 uno::Any SAL_CALL
DialogModelProvider::getByName(const OUString
& aName
) throw (css::uno::RuntimeException
, css::container::NoSuchElementException
, css::lang::WrappedTargetException
, std::exception
)
88 return m_xDialogModel
->getByName(aName
);
91 css::uno::Sequence
< OUString
> SAL_CALL
DialogModelProvider::getElementNames() throw (css::uno::RuntimeException
, std::exception
)
93 return m_xDialogModel
->getElementNames();
96 sal_Bool SAL_CALL
DialogModelProvider::hasByName(const OUString
& aName
) throw (css::uno::RuntimeException
, std::exception
)
98 return m_xDialogModel
->hasByName(aName
);
101 // container::XNameReplace:
102 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
, std::exception
)
104 m_xDialogModel
->replaceByName(aName
,aElement
);
107 // container::XNameContainer:
108 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
, std::exception
)
110 m_xDialogModel
->insertByName(aName
,aElement
);
113 void SAL_CALL
DialogModelProvider::removeByName(const OUString
& aName
) throw (css::uno::RuntimeException
, css::container::NoSuchElementException
, css::lang::WrappedTargetException
, std::exception
)
115 m_xDialogModel
->removeByName(aName
);
117 uno::Reference
< beans::XPropertySetInfo
> SAL_CALL
DialogModelProvider::getPropertySetInfo( ) throw (uno::RuntimeException
, std::exception
)
119 return m_xDialogModelProp
->getPropertySetInfo();
121 void SAL_CALL
DialogModelProvider::setPropertyValue( const OUString
&, const uno::Any
& ) throw (beans::UnknownPropertyException
, beans::PropertyVetoException
, lang::IllegalArgumentException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
124 uno::Any SAL_CALL
DialogModelProvider::getPropertyValue( const OUString
& PropertyName
) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
126 return m_xDialogModelProp
->getPropertyValue(PropertyName
);
128 void SAL_CALL
DialogModelProvider::addPropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
131 void SAL_CALL
DialogModelProvider::removePropertyChangeListener( const OUString
& , const uno::Reference
< beans::XPropertyChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
134 void SAL_CALL
DialogModelProvider::addVetoableChangeListener( const OUString
& , const uno::Reference
< beans::XVetoableChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
137 void SAL_CALL
DialogModelProvider::removeVetoableChangeListener( const OUString
& ,const uno::Reference
< beans::XVetoableChangeListener
>& ) throw (beans::UnknownPropertyException
, lang::WrappedTargetException
, uno::RuntimeException
, std::exception
)
141 // com.sun.star.uno.XServiceInfo:
142 OUString SAL_CALL
DialogModelProvider::getImplementationName() throw (css::uno::RuntimeException
, std::exception
)
144 return comp_DialogModelProvider::_getImplementationName();
147 sal_Bool SAL_CALL
DialogModelProvider::supportsService(OUString
const & serviceName
) throw (css::uno::RuntimeException
, std::exception
)
149 return cppu::supportsService(this, serviceName
);
152 css::uno::Sequence
< OUString
> SAL_CALL
DialogModelProvider::getSupportedServiceNames() throw (css::uno::RuntimeException
, std::exception
)
154 return comp_DialogModelProvider::_getSupportedServiceNames();
157 } // closing anonymous implementation namespace
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */