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