cid#1607171 Data race condition
[LibreOffice.git] / reportdesign / source / ui / inspection / ReportComponentHandler.cxx
blobe3eb0d454825287236878e85787713d5aaaf1cef
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 .
19 #include <ReportComponentHandler.hxx>
20 #include <com/sun/star/beans/XPropertySet.hpp>
21 #include <com/sun/star/lang/NullPointerException.hpp>
22 #include <comphelper/types.hxx>
23 #include <cppuhelper/supportsservice.hxx>
24 #include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
25 #include <com/sun/star/container/XNameContainer.hpp>
26 #include <metadata.hxx>
27 #include <utility>
30 namespace rptui
33 using namespace ::com::sun::star;
35 ReportComponentHandler::ReportComponentHandler(uno::Reference< uno::XComponentContext > context)
36 :ReportComponentHandler_Base(m_aMutex)
37 ,m_xContext(std::move(context))
39 try
41 m_xFormComponentHandler = form::inspection::FormComponentPropertyHandler::create(m_xContext);
43 }catch(const uno::Exception &)
48 OUString SAL_CALL ReportComponentHandler::getImplementationName( )
50 return u"com.sun.star.comp.report.ReportComponentHandler"_ustr;
53 sal_Bool SAL_CALL ReportComponentHandler::supportsService( const OUString& ServiceName )
55 return cppu::supportsService(this, ServiceName);
58 uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getSupportedServiceNames( )
60 return { u"com.sun.star.report.inspection.ReportComponentHandler"_ustr };
63 // override WeakComponentImplHelperBase::disposing()
64 // This function is called upon disposing the component,
65 // if your component needs special work when it becomes
66 // disposed, do it here.
67 void SAL_CALL ReportComponentHandler::disposing()
69 ::comphelper::disposeComponent(m_xFormComponentHandler);
71 void SAL_CALL ReportComponentHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener)
73 m_xFormComponentHandler->addEventListener(xListener);
76 void SAL_CALL ReportComponentHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener)
78 m_xFormComponentHandler->removeEventListener(aListener);
81 // inspection::XPropertyHandler:
83 /********************************************************************************/
84 void SAL_CALL ReportComponentHandler::inspect(const uno::Reference< uno::XInterface > & Component)
86 try
88 uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
89 static constexpr OUString sFormComponent(u"FormComponent"_ustr);
90 if ( xNameCont->hasByName(sFormComponent) )
91 xNameCont->getByName(sFormComponent) >>= m_xFormComponent;
92 static constexpr OUString sRowSet(u"RowSet"_ustr);
93 if ( xNameCont->hasByName(sRowSet) )
95 uno::Reference<beans::XPropertySet> xProp(m_xFormComponentHandler,uno::UNO_QUERY);
96 xProp->setPropertyValue(sRowSet,xNameCont->getByName(sRowSet));
99 catch(const uno::Exception &)
101 throw lang::NullPointerException();
103 if ( m_xFormComponent.is() )
105 m_xFormComponentHandler->inspect(m_xFormComponent);
109 uno::Any SAL_CALL ReportComponentHandler::getPropertyValue(const OUString & PropertyName)
111 return m_xFormComponentHandler->getPropertyValue(PropertyName);
114 void SAL_CALL ReportComponentHandler::setPropertyValue(const OUString & PropertyName, const uno::Any & Value)
116 m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
119 beans::PropertyState SAL_CALL ReportComponentHandler::getPropertyState(const OUString & PropertyName)
121 return m_xFormComponentHandler->getPropertyState(PropertyName);
124 inspection::LineDescriptor SAL_CALL ReportComponentHandler::describePropertyLine(const OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & ControlFactory)
126 return m_xFormComponentHandler->describePropertyLine(PropertyName, ControlFactory);
129 uno::Any SAL_CALL ReportComponentHandler::convertToPropertyValue(const OUString & PropertyName, const uno::Any & ControlValue)
131 return m_xFormComponentHandler->convertToPropertyValue(PropertyName, ControlValue);
134 uno::Any SAL_CALL ReportComponentHandler::convertToControlValue(const OUString & PropertyName, const uno::Any & PropertyValue, const uno::Type & ControlValueType)
136 return m_xFormComponentHandler->convertToControlValue(PropertyName, PropertyValue, ControlValueType);
139 void SAL_CALL ReportComponentHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener)
141 m_xFormComponentHandler->addPropertyChangeListener(Listener);
144 void SAL_CALL ReportComponentHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener)
146 m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
149 uno::Sequence< beans::Property > SAL_CALL ReportComponentHandler::getSupportedProperties()
151 ::std::vector< beans::Property > aNewProps;
152 rptui::OPropertyInfoService::getExcludeProperties( aNewProps, m_xFormComponentHandler );
154 return uno::Sequence< beans::Property >(aNewProps.data(), aNewProps.size());
157 uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getSupersededProperties()
159 uno::Sequence< OUString > aRet;
160 return aRet;
163 uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getActuatingProperties()
165 return m_xFormComponentHandler->getActuatingProperties();
168 sal_Bool SAL_CALL ReportComponentHandler::isComposable( const OUString& _rPropertyName )
170 return OPropertyInfoService::isComposable( _rPropertyName, m_xFormComponentHandler );
173 inspection::InteractiveSelectionResult SAL_CALL ReportComponentHandler::onInteractivePropertySelection(const OUString & PropertyName, sal_Bool Primary, uno::Any & out_Data, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI)
175 return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, InspectorUI);
178 void SAL_CALL ReportComponentHandler::actuatingPropertyChanged(const OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI, sal_Bool FirstTimeInit)
180 m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
183 sal_Bool SAL_CALL ReportComponentHandler::suspend(sal_Bool Suspend)
185 return m_xFormComponentHandler->suspend(Suspend);
189 } // namespace rptui
192 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
193 reportdesign_ReportComponentHandler_get_implementation(
194 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
196 return cppu::acquire(new rptui::ReportComponentHandler(context));
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */