xref: /AOO41X/main/reportdesign/source/ui/inspection/ReportComponentHandler.cxx (revision 9e0e41911c53968aad5ad356e2b2126da667034f)
1*9e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9e0e4191SAndrew Rist  * distributed with this work for additional information
6*9e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
9*9e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9e0e4191SAndrew Rist  * software distributed under the License is distributed on an
15*9e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9e0e4191SAndrew Rist  * specific language governing permissions and limitations
18*9e0e4191SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9e0e4191SAndrew Rist  *************************************************************/
21*9e0e4191SAndrew Rist 
22*9e0e4191SAndrew Rist 
23cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
24cdf0e10cSrcweir #include "ReportComponentHandler.hxx"
25cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
26cdf0e10cSrcweir #include <comphelper/sequence.hxx>
27cdf0e10cSrcweir #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
28cdf0e10cSrcweir #include "uistrings.hrc"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <comphelper/types.hxx>
31cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
32cdf0e10cSrcweir #include <unotools/syslocale.hxx>
33cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
34cdf0e10cSrcweir #include <com/sun/star/report/XReportDefinition.hpp>
35cdf0e10cSrcweir #include <com/sun/star/report/XSection.hpp>
36cdf0e10cSrcweir #include <com/sun/star/inspection/XNumericControl.hpp>
37cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
38cdf0e10cSrcweir #include <com/sun/star/util/MeasureUnit.hpp>
39cdf0e10cSrcweir #include <tools/fldunit.hxx>
40cdf0e10cSrcweir #include "metadata.hxx"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir //........................................................................
43cdf0e10cSrcweir namespace rptui
44cdf0e10cSrcweir {
45cdf0e10cSrcweir //........................................................................
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir // using namespace comphelper;
48cdf0e10cSrcweir 
ReportComponentHandler(uno::Reference<uno::XComponentContext> const & context)49cdf0e10cSrcweir ReportComponentHandler::ReportComponentHandler(uno::Reference< uno::XComponentContext > const & context)
50cdf0e10cSrcweir     :ReportComponentHandler_Base(m_aMutex)
51cdf0e10cSrcweir     ,m_xContext(context)
52cdf0e10cSrcweir     ,m_pInfoService( new OPropertyInfoService() )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir     try
55cdf0e10cSrcweir     {
56cdf0e10cSrcweir         m_xFormComponentHandler.set(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     }catch(uno::Exception)
59cdf0e10cSrcweir     {
60cdf0e10cSrcweir     }
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //------------------------------------------------------------------------
getImplementationName()64cdf0e10cSrcweir ::rtl::OUString SAL_CALL ReportComponentHandler::getImplementationName(  ) throw(uno::RuntimeException)
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	return getImplementationName_Static();
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)70cdf0e10cSrcweir sal_Bool SAL_CALL ReportComponentHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir //------------------------------------------------------------------------
getSupportedServiceNames()76cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupportedServiceNames(  ) throw(uno::RuntimeException)
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 	return getSupportedServiceNames_static();
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir //------------------------------------------------------------------------
getImplementationName_Static()82cdf0e10cSrcweir ::rtl::OUString ReportComponentHandler::getImplementationName_Static(  ) throw(uno::RuntimeException)
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ReportComponentHandler"));
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir //------------------------------------------------------------------------
getSupportedServiceNames_static()88cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > ReportComponentHandler::getSupportedServiceNames_static(  ) throw(uno::RuntimeException)
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aSupported(1);
91cdf0e10cSrcweir     aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.ReportComponentHandler"));
92cdf0e10cSrcweir 	return aSupported;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir //------------------------------------------------------------------------
create(const uno::Reference<uno::XComponentContext> & _rxContext)96cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL ReportComponentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	return *(new ReportComponentHandler( _rxContext ));
99cdf0e10cSrcweir }
100cdf0e10cSrcweir // overload WeakComponentImplHelperBase::disposing()
101cdf0e10cSrcweir // This function is called upon disposing the component,
102cdf0e10cSrcweir // if your component needs special work when it becomes
103cdf0e10cSrcweir // disposed, do it here.
disposing()104cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::disposing()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     ::comphelper::disposeComponent(m_xFormComponentHandler);
107cdf0e10cSrcweir }
addEventListener(const uno::Reference<lang::XEventListener> & xListener)108cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir     m_xFormComponentHandler->addEventListener(xListener);
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
removeEventListener(const uno::Reference<lang::XEventListener> & aListener)113cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     m_xFormComponentHandler->removeEventListener(aListener);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir // inspection::XPropertyHandler:
119cdf0e10cSrcweir 
120cdf0e10cSrcweir /********************************************************************************/
inspect(const uno::Reference<uno::XInterface> & Component)121cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::inspect(const uno::Reference< uno::XInterface > & Component) throw (uno::RuntimeException, lang::NullPointerException)
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     try
124cdf0e10cSrcweir     {
125cdf0e10cSrcweir         uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
126cdf0e10cSrcweir         const ::rtl::OUString sFormComponent(RTL_CONSTASCII_USTRINGPARAM("FormComponent"));
127cdf0e10cSrcweir         if ( xNameCont->hasByName(sFormComponent) )
128cdf0e10cSrcweir             xNameCont->getByName(sFormComponent) >>= m_xFormComponent;
129cdf0e10cSrcweir         const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
130cdf0e10cSrcweir         if ( xNameCont->hasByName(sRowSet) )
131cdf0e10cSrcweir         {
132cdf0e10cSrcweir             uno::Reference<beans::XPropertySet> xProp(m_xFormComponentHandler,uno::UNO_QUERY);
133cdf0e10cSrcweir             xProp->setPropertyValue(sRowSet,xNameCont->getByName(sRowSet));
134cdf0e10cSrcweir         }
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir     catch(uno::Exception)
137cdf0e10cSrcweir     {
138cdf0e10cSrcweir         throw lang::NullPointerException();
139cdf0e10cSrcweir     }
140cdf0e10cSrcweir     if ( m_xFormComponent.is() )
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         m_xFormComponentHandler->inspect(m_xFormComponent);
143cdf0e10cSrcweir     }
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
getPropertyValue(const::rtl::OUString & PropertyName)146cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     return m_xFormComponentHandler->getPropertyValue(PropertyName);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
setPropertyValue(const::rtl::OUString & PropertyName,const uno::Any & Value)151cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
getPropertyState(const::rtl::OUString & PropertyName)156cdf0e10cSrcweir beans::PropertyState SAL_CALL ReportComponentHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     return m_xFormComponentHandler->getPropertyState(PropertyName);
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
describePropertyLine(const::rtl::OUString & PropertyName,const uno::Reference<inspection::XPropertyControlFactory> & ControlFactory)161cdf0e10cSrcweir inspection::LineDescriptor SAL_CALL ReportComponentHandler::describePropertyLine(const ::rtl::OUString & PropertyName,  const uno::Reference< inspection::XPropertyControlFactory > & ControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
162cdf0e10cSrcweir {
163cdf0e10cSrcweir     return m_xFormComponentHandler->describePropertyLine(PropertyName, ControlFactory);
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
convertToPropertyValue(const::rtl::OUString & PropertyName,const uno::Any & ControlValue)166cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::convertToPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & ControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     return m_xFormComponentHandler->convertToPropertyValue(PropertyName, ControlValue);
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
convertToControlValue(const::rtl::OUString & PropertyName,const uno::Any & PropertyValue,const uno::Type & ControlValueType)171cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::convertToControlValue(const ::rtl::OUString & PropertyName, const uno::Any & PropertyValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     return m_xFormComponentHandler->convertToControlValue(PropertyName, PropertyValue, ControlValueType);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
addPropertyChangeListener(const uno::Reference<beans::XPropertyChangeListener> & Listener)176cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener) throw (uno::RuntimeException, lang::NullPointerException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     m_xFormComponentHandler->addPropertyChangeListener(Listener);
179cdf0e10cSrcweir }
180cdf0e10cSrcweir 
removePropertyChangeListener(const uno::Reference<beans::XPropertyChangeListener> & _rxListener)181cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
getSupportedProperties()186cdf0e10cSrcweir uno::Sequence< beans::Property > SAL_CALL ReportComponentHandler::getSupportedProperties() throw (uno::RuntimeException)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     ::std::vector< beans::Property > aNewProps;
189cdf0e10cSrcweir     m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     return aNewProps.empty() ? uno::Sequence< beans::Property > () : uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
getSupersededProperties()194cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupersededProperties() throw (uno::RuntimeException)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aRet;
197cdf0e10cSrcweir     return aRet;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
getActuatingProperties()200cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getActuatingProperties() throw (uno::RuntimeException)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     return m_xFormComponentHandler->getActuatingProperties();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
isComposable(const::rtl::OUString & _rPropertyName)205cdf0e10cSrcweir ::sal_Bool SAL_CALL ReportComponentHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (uno::RuntimeException, beans::UnknownPropertyException)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
onInteractivePropertySelection(const::rtl::OUString & PropertyName,::sal_Bool Primary,uno::Any & out_Data,const uno::Reference<inspection::XObjectInspectorUI> & InspectorUI)210cdf0e10cSrcweir inspection::InteractiveSelectionResult SAL_CALL ReportComponentHandler::onInteractivePropertySelection(const ::rtl::OUString & PropertyName, ::sal_Bool Primary, uno::Any & out_Data, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::NullPointerException)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir     return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, InspectorUI);
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
actuatingPropertyChanged(const::rtl::OUString & ActuatingPropertyName,const uno::Any & NewValue,const uno::Any & OldValue,const uno::Reference<inspection::XObjectInspectorUI> & InspectorUI,::sal_Bool FirstTimeInit)215cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::actuatingPropertyChanged(const ::rtl::OUString & ActuatingPropertyName, const uno::Any & NewValue, const uno::Any & OldValue, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI, ::sal_Bool FirstTimeInit) throw (uno::RuntimeException, lang::NullPointerException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir     m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
suspend(::sal_Bool Suspend)220cdf0e10cSrcweir ::sal_Bool SAL_CALL ReportComponentHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     return m_xFormComponentHandler->suspend(Suspend);
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir //........................................................................
226cdf0e10cSrcweir } // namespace rptui
227cdf0e10cSrcweir //........................................................................
228cdf0e10cSrcweir 
229