tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / scripting / source / dlgprov / DialogModelProvider.cxx
blob7bd62f614fefb226b48a705a1730c50e0847a490
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
28 namespace dlgprov {
30 using namespace ::com::sun::star;
31 using namespace lang;
32 using namespace uno;
33 using namespace beans;
36 DialogModelProvider::DialogModelProvider(Reference< XComponentContext > const & context) :
37 m_xContext(context)
40 // lang::XInitialization:
41 void SAL_CALL DialogModelProvider::initialize(const css::uno::Sequence< uno::Any > & aArguments)
43 if ( aArguments.getLength() != 1 )
44 return;
46 OUString sURL;
47 if ( !( aArguments[ 0 ] >>= sURL ))
48 throw css::lang::IllegalArgumentException();
49 // Try any other URL with SimpleFileAccess
50 Reference< ucb::XSimpleFileAccess3 > xSFI = ucb::SimpleFileAccess::create(m_xContext);
52 try
54 Reference< io::XInputStream > xInput = xSFI->openFileRead( sURL );
55 Reference< resource::XStringResourceManager > xStringResourceManager;
56 if ( xInput.is() )
58 xStringResourceManager = dlgprov::lcl_getStringResourceManager(m_xContext,sURL);
59 Any aDialogSourceURLAny;
60 aDialogSourceURLAny <<= sURL;
62 Reference< frame::XModel > xModel;
63 m_xDialogModel.set( dlgprov::lcl_createDialogModel( m_xContext, xInput , xModel, xStringResourceManager, aDialogSourceURLAny ), UNO_SET_THROW);
64 m_xDialogModelProp.set(m_xDialogModel, UNO_QUERY_THROW);
67 catch( Exception& )
69 //m_sURL = sURL;
72 // container::XElementAccess:
73 uno::Type SAL_CALL DialogModelProvider::getElementType()
75 return m_xDialogModel->getElementType();
78 sal_Bool SAL_CALL DialogModelProvider::hasElements()
80 return m_xDialogModel->hasElements();
83 // container::XNameAccess:
84 uno::Any SAL_CALL DialogModelProvider::getByName(const OUString & aName)
86 return m_xDialogModel->getByName(aName);
89 css::uno::Sequence< OUString > SAL_CALL DialogModelProvider::getElementNames()
91 return m_xDialogModel->getElementNames();
94 sal_Bool SAL_CALL DialogModelProvider::hasByName(const OUString & aName)
96 return m_xDialogModel->hasByName(aName);
99 // container::XNameReplace:
100 void SAL_CALL DialogModelProvider::replaceByName(const OUString & aName, const uno::Any & aElement)
102 m_xDialogModel->replaceByName(aName,aElement);
105 // container::XNameContainer:
106 void SAL_CALL DialogModelProvider::insertByName(const OUString & aName, const uno::Any & aElement)
108 m_xDialogModel->insertByName(aName,aElement);
111 void SAL_CALL DialogModelProvider::removeByName(const OUString & aName)
113 m_xDialogModel->removeByName(aName);
115 uno::Reference< beans::XPropertySetInfo > SAL_CALL DialogModelProvider::getPropertySetInfo( )
117 return m_xDialogModelProp->getPropertySetInfo();
119 void SAL_CALL DialogModelProvider::setPropertyValue( const OUString&, const uno::Any& )
122 uno::Any SAL_CALL DialogModelProvider::getPropertyValue( const OUString& PropertyName )
124 return m_xDialogModelProp->getPropertyValue(PropertyName);
126 void SAL_CALL DialogModelProvider::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
129 void SAL_CALL DialogModelProvider::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& )
132 void SAL_CALL DialogModelProvider::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& )
135 void SAL_CALL DialogModelProvider::removeVetoableChangeListener( const OUString& ,const uno::Reference< beans::XVetoableChangeListener >& )
139 // com.sun.star.uno.XServiceInfo:
140 OUString SAL_CALL DialogModelProvider::getImplementationName()
142 return u"com.sun.star.comp.scripting.DialogModelProvider"_ustr;
145 sal_Bool SAL_CALL DialogModelProvider::supportsService(OUString const & serviceName)
147 return cppu::supportsService(this, serviceName);
150 css::uno::Sequence< OUString > SAL_CALL DialogModelProvider::getSupportedServiceNames()
152 return { u"com.sun.star.awt.UnoControlDialogModelProvider"_ustr };
155 } // closing anonymous implementation namespace
157 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
158 scripting_DialogModelProvider_get_implementation(
159 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
161 return cppu::acquire(new dlgprov::DialogModelProvider(context));
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */