xref: /AOO41X/main/reportdesign/source/ui/inspection/ReportComponentHandler.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #include "precompiled_reportdesign.hxx"
28*cdf0e10cSrcweir #include "ReportComponentHandler.hxx"
29*cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
30*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
31*cdf0e10cSrcweir #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
32*cdf0e10cSrcweir #include "uistrings.hrc"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include <comphelper/types.hxx>
35*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
36*cdf0e10cSrcweir #include <unotools/syslocale.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/report/XReportDefinition.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/report/XSection.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/inspection/XNumericControl.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/util/MeasureUnit.hpp>
43*cdf0e10cSrcweir #include <tools/fldunit.hxx>
44*cdf0e10cSrcweir #include "metadata.hxx"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //........................................................................
47*cdf0e10cSrcweir namespace rptui
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir //........................................................................
50*cdf0e10cSrcweir using namespace ::com::sun::star;
51*cdf0e10cSrcweir // using namespace comphelper;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir ReportComponentHandler::ReportComponentHandler(uno::Reference< uno::XComponentContext > const & context)
54*cdf0e10cSrcweir     :ReportComponentHandler_Base(m_aMutex)
55*cdf0e10cSrcweir     ,m_xContext(context)
56*cdf0e10cSrcweir     ,m_pInfoService( new OPropertyInfoService() )
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     try
59*cdf0e10cSrcweir     {
60*cdf0e10cSrcweir         m_xFormComponentHandler.set(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     }catch(uno::Exception)
63*cdf0e10cSrcweir     {
64*cdf0e10cSrcweir     }
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir //------------------------------------------------------------------------
68*cdf0e10cSrcweir ::rtl::OUString SAL_CALL ReportComponentHandler::getImplementationName(  ) throw(uno::RuntimeException)
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 	return getImplementationName_Static();
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir //------------------------------------------------------------------------
74*cdf0e10cSrcweir sal_Bool SAL_CALL ReportComponentHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir //------------------------------------------------------------------------
80*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupportedServiceNames(  ) throw(uno::RuntimeException)
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir 	return getSupportedServiceNames_static();
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir //------------------------------------------------------------------------
86*cdf0e10cSrcweir ::rtl::OUString ReportComponentHandler::getImplementationName_Static(  ) throw(uno::RuntimeException)
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ReportComponentHandler"));
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir //------------------------------------------------------------------------
92*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > ReportComponentHandler::getSupportedServiceNames_static(  ) throw(uno::RuntimeException)
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aSupported(1);
95*cdf0e10cSrcweir     aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.ReportComponentHandler"));
96*cdf0e10cSrcweir 	return aSupported;
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir //------------------------------------------------------------------------
100*cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL ReportComponentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir 	return *(new ReportComponentHandler( _rxContext ));
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir // overload WeakComponentImplHelperBase::disposing()
105*cdf0e10cSrcweir // This function is called upon disposing the component,
106*cdf0e10cSrcweir // if your component needs special work when it becomes
107*cdf0e10cSrcweir // disposed, do it here.
108*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::disposing()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir     ::comphelper::disposeComponent(m_xFormComponentHandler);
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir     m_xFormComponentHandler->addEventListener(xListener);
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir     m_xFormComponentHandler->removeEventListener(aListener);
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir // inspection::XPropertyHandler:
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir /********************************************************************************/
125*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::inspect(const uno::Reference< uno::XInterface > & Component) throw (uno::RuntimeException, lang::NullPointerException)
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir     try
128*cdf0e10cSrcweir     {
129*cdf0e10cSrcweir         uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
130*cdf0e10cSrcweir         const ::rtl::OUString sFormComponent(RTL_CONSTASCII_USTRINGPARAM("FormComponent"));
131*cdf0e10cSrcweir         if ( xNameCont->hasByName(sFormComponent) )
132*cdf0e10cSrcweir             xNameCont->getByName(sFormComponent) >>= m_xFormComponent;
133*cdf0e10cSrcweir         const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
134*cdf0e10cSrcweir         if ( xNameCont->hasByName(sRowSet) )
135*cdf0e10cSrcweir         {
136*cdf0e10cSrcweir             uno::Reference<beans::XPropertySet> xProp(m_xFormComponentHandler,uno::UNO_QUERY);
137*cdf0e10cSrcweir             xProp->setPropertyValue(sRowSet,xNameCont->getByName(sRowSet));
138*cdf0e10cSrcweir         }
139*cdf0e10cSrcweir     }
140*cdf0e10cSrcweir     catch(uno::Exception)
141*cdf0e10cSrcweir     {
142*cdf0e10cSrcweir         throw lang::NullPointerException();
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir     if ( m_xFormComponent.is() )
145*cdf0e10cSrcweir     {
146*cdf0e10cSrcweir         m_xFormComponentHandler->inspect(m_xFormComponent);
147*cdf0e10cSrcweir     }
148*cdf0e10cSrcweir }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir     return m_xFormComponentHandler->getPropertyValue(PropertyName);
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir     m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir beans::PropertyState SAL_CALL ReportComponentHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir     return m_xFormComponentHandler->getPropertyState(PropertyName);
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir inspection::LineDescriptor SAL_CALL ReportComponentHandler::describePropertyLine(const ::rtl::OUString & PropertyName,  const uno::Reference< inspection::XPropertyControlFactory > & ControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir     return m_xFormComponentHandler->describePropertyLine(PropertyName, ControlFactory);
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::convertToPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & ControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir     return m_xFormComponentHandler->convertToPropertyValue(PropertyName, ControlValue);
173*cdf0e10cSrcweir }
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir uno::Any SAL_CALL ReportComponentHandler::convertToControlValue(const ::rtl::OUString & PropertyName, const uno::Any & PropertyValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir     return m_xFormComponentHandler->convertToControlValue(PropertyName, PropertyValue, ControlValueType);
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener) throw (uno::RuntimeException, lang::NullPointerException)
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir     m_xFormComponentHandler->addPropertyChangeListener(Listener);
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir void SAL_CALL ReportComponentHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir     m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir uno::Sequence< beans::Property > SAL_CALL ReportComponentHandler::getSupportedProperties() throw (uno::RuntimeException)
191*cdf0e10cSrcweir {
192*cdf0e10cSrcweir     ::std::vector< beans::Property > aNewProps;
193*cdf0e10cSrcweir     m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     return aNewProps.empty() ? uno::Sequence< beans::Property > () : uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupersededProperties() throw (uno::RuntimeException)
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aRet;
201*cdf0e10cSrcweir     return aRet;
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getActuatingProperties() throw (uno::RuntimeException)
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir     return m_xFormComponentHandler->getActuatingProperties();
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir ::sal_Bool SAL_CALL ReportComponentHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (uno::RuntimeException, beans::UnknownPropertyException)
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir     return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
212*cdf0e10cSrcweir }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 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)
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir     return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, InspectorUI);
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 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)
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir     m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
222*cdf0e10cSrcweir }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir ::sal_Bool SAL_CALL ReportComponentHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir     return m_xFormComponentHandler->suspend(Suspend);
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir //........................................................................
230*cdf0e10cSrcweir } // namespace rptui
231*cdf0e10cSrcweir //........................................................................
232*cdf0e10cSrcweir 
233