sync master with lastest vba changes
[ooovba.git] / reportdesign / source / ui / inspection / ReportComponentHandler.cxx
blob1d7f20f83d262fe64ecd5f901ec87de74e09a4dd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ReportComponentHandler.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_reportdesign.hxx"
31 #include "ReportComponentHandler.hxx"
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <comphelper/sequence.hxx>
34 #ifndef REPORTDESIGN_SHARED_UISTRINGS_HRC
35 #include "uistrings.hrc"
36 #endif
37 #include <comphelper/types.hxx>
38 #include <toolkit/helper/vclunohelper.hxx>
39 #include <svtools/syslocale.hxx>
40 #include <com/sun/star/inspection/PropertyControlType.hpp>
41 #include <com/sun/star/report/XReportDefinition.hpp>
42 #include <com/sun/star/report/XSection.hpp>
43 #include <com/sun/star/inspection/XNumericControl.hpp>
44 #include <com/sun/star/container/XNameContainer.hpp>
45 #include <com/sun/star/util/MeasureUnit.hpp>
46 #include <vcl/fldunit.hxx>
47 #include "metadata.hxx"
49 //........................................................................
50 namespace rptui
52 //........................................................................
53 using namespace ::com::sun::star;
54 // using namespace comphelper;
56 ReportComponentHandler::ReportComponentHandler(uno::Reference< uno::XComponentContext > const & context)
57 :ReportComponentHandler_Base(m_aMutex)
58 ,m_xContext(context)
59 ,m_pInfoService( new OPropertyInfoService() )
61 try
63 m_xFormComponentHandler.set(m_xContext->getServiceManager()->createInstanceWithContext(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.inspection.FormComponentPropertyHandler")),m_xContext),uno::UNO_QUERY_THROW);
65 }catch(uno::Exception)
70 //------------------------------------------------------------------------
71 ::rtl::OUString SAL_CALL ReportComponentHandler::getImplementationName( ) throw(uno::RuntimeException)
73 return getImplementationName_Static();
76 //------------------------------------------------------------------------
77 sal_Bool SAL_CALL ReportComponentHandler::supportsService( const ::rtl::OUString& ServiceName ) throw(uno::RuntimeException)
79 return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
82 //------------------------------------------------------------------------
83 uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
85 return getSupportedServiceNames_static();
88 //------------------------------------------------------------------------
89 ::rtl::OUString ReportComponentHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
91 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.report.ReportComponentHandler"));
94 //------------------------------------------------------------------------
95 uno::Sequence< ::rtl::OUString > ReportComponentHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
97 uno::Sequence< ::rtl::OUString > aSupported(1);
98 aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.inspection.ReportComponentHandler"));
99 return aSupported;
102 //------------------------------------------------------------------------
103 uno::Reference< uno::XInterface > SAL_CALL ReportComponentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
105 return *(new ReportComponentHandler( _rxContext ));
107 // overload WeakComponentImplHelperBase::disposing()
108 // This function is called upon disposing the component,
109 // if your component needs special work when it becomes
110 // disposed, do it here.
111 void SAL_CALL ReportComponentHandler::disposing()
113 ::comphelper::disposeComponent(m_xFormComponentHandler);
115 void SAL_CALL ReportComponentHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
117 m_xFormComponentHandler->addEventListener(xListener);
120 void SAL_CALL ReportComponentHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
122 m_xFormComponentHandler->removeEventListener(aListener);
125 // inspection::XPropertyHandler:
127 /********************************************************************************/
128 void SAL_CALL ReportComponentHandler::inspect(const uno::Reference< uno::XInterface > & Component) throw (uno::RuntimeException, lang::NullPointerException)
132 uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
133 const ::rtl::OUString sFormComponent(RTL_CONSTASCII_USTRINGPARAM("FormComponent"));
134 if ( xNameCont->hasByName(sFormComponent) )
135 xNameCont->getByName(sFormComponent) >>= m_xFormComponent;
136 const ::rtl::OUString sRowSet(RTL_CONSTASCII_USTRINGPARAM("RowSet"));
137 if ( xNameCont->hasByName(sRowSet) )
139 uno::Reference<beans::XPropertySet> xProp(m_xFormComponentHandler,uno::UNO_QUERY);
140 xProp->setPropertyValue(sRowSet,xNameCont->getByName(sRowSet));
143 catch(uno::Exception)
145 throw lang::NullPointerException();
147 if ( m_xFormComponent.is() )
149 m_xFormComponentHandler->inspect(m_xFormComponent);
153 uno::Any SAL_CALL ReportComponentHandler::getPropertyValue(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
155 return m_xFormComponentHandler->getPropertyValue(PropertyName);
158 void SAL_CALL ReportComponentHandler::setPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
160 m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
163 beans::PropertyState SAL_CALL ReportComponentHandler::getPropertyState(const ::rtl::OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
165 return m_xFormComponentHandler->getPropertyState(PropertyName);
168 inspection::LineDescriptor SAL_CALL ReportComponentHandler::describePropertyLine(const ::rtl::OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & ControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
170 return m_xFormComponentHandler->describePropertyLine(PropertyName, ControlFactory);
173 uno::Any SAL_CALL ReportComponentHandler::convertToPropertyValue(const ::rtl::OUString & PropertyName, const uno::Any & ControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
175 return m_xFormComponentHandler->convertToPropertyValue(PropertyName, ControlValue);
178 uno::Any SAL_CALL ReportComponentHandler::convertToControlValue(const ::rtl::OUString & PropertyName, const uno::Any & PropertyValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
180 return m_xFormComponentHandler->convertToControlValue(PropertyName, PropertyValue, ControlValueType);
183 void SAL_CALL ReportComponentHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener) throw (uno::RuntimeException, lang::NullPointerException)
185 m_xFormComponentHandler->addPropertyChangeListener(Listener);
188 void SAL_CALL ReportComponentHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
190 m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
193 uno::Sequence< beans::Property > SAL_CALL ReportComponentHandler::getSupportedProperties() throw (uno::RuntimeException)
195 ::std::vector< beans::Property > aNewProps;
196 m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
198 return aNewProps.empty() ? uno::Sequence< beans::Property > () : uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
201 uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getSupersededProperties() throw (uno::RuntimeException)
203 uno::Sequence< ::rtl::OUString > aRet;
204 return aRet;
207 uno::Sequence< ::rtl::OUString > SAL_CALL ReportComponentHandler::getActuatingProperties() throw (uno::RuntimeException)
209 return m_xFormComponentHandler->getActuatingProperties();
212 ::sal_Bool SAL_CALL ReportComponentHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (uno::RuntimeException, beans::UnknownPropertyException)
214 return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
217 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)
219 return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, InspectorUI);
222 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)
224 m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
227 ::sal_Bool SAL_CALL ReportComponentHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
229 return m_xFormComponentHandler->suspend(Suspend);
232 //........................................................................
233 } // namespace rptui
234 //........................................................................