Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #include "ReportComponentHandler.hxx"
20 : #include <com/sun/star/lang/XInitialization.hpp>
21 : #include <comphelper/sequence.hxx>
22 : #include "uistrings.hrc"
23 : #include <comphelper/types.hxx>
24 : #include <toolkit/helper/vclunohelper.hxx>
25 : #include <unotools/syslocale.hxx>
26 : #include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
27 : #include <com/sun/star/inspection/PropertyControlType.hpp>
28 : #include <com/sun/star/report/XReportDefinition.hpp>
29 : #include <com/sun/star/report/XSection.hpp>
30 : #include <com/sun/star/inspection/XNumericControl.hpp>
31 : #include <com/sun/star/container/XNameContainer.hpp>
32 : #include <com/sun/star/util/MeasureUnit.hpp>
33 : #include <tools/fldunit.hxx>
34 : #include "metadata.hxx"
35 :
36 : //........................................................................
37 : namespace rptui
38 : {
39 : //........................................................................
40 : using namespace ::com::sun::star;
41 :
42 0 : ReportComponentHandler::ReportComponentHandler(uno::Reference< uno::XComponentContext > const & context)
43 : :ReportComponentHandler_Base(m_aMutex)
44 : ,m_xContext(context)
45 0 : ,m_pInfoService( new OPropertyInfoService() )
46 : {
47 : try
48 : {
49 0 : m_xFormComponentHandler = form::inspection::FormComponentPropertyHandler::create(m_xContext);
50 :
51 0 : }catch(const uno::Exception &)
52 : {
53 : }
54 0 : }
55 :
56 : //------------------------------------------------------------------------
57 0 : OUString SAL_CALL ReportComponentHandler::getImplementationName( ) throw(uno::RuntimeException)
58 : {
59 0 : return getImplementationName_Static();
60 : }
61 :
62 : //------------------------------------------------------------------------
63 0 : sal_Bool SAL_CALL ReportComponentHandler::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
64 : {
65 0 : return ::comphelper::existsValue(ServiceName,getSupportedServiceNames_static());
66 : }
67 :
68 : //------------------------------------------------------------------------
69 0 : uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getSupportedServiceNames( ) throw(uno::RuntimeException)
70 : {
71 0 : return getSupportedServiceNames_static();
72 : }
73 :
74 : //------------------------------------------------------------------------
75 0 : OUString ReportComponentHandler::getImplementationName_Static( ) throw(uno::RuntimeException)
76 : {
77 0 : return OUString("com.sun.star.comp.report.ReportComponentHandler");
78 : }
79 :
80 : //------------------------------------------------------------------------
81 0 : uno::Sequence< OUString > ReportComponentHandler::getSupportedServiceNames_static( ) throw(uno::RuntimeException)
82 : {
83 0 : uno::Sequence< OUString > aSupported(1);
84 0 : aSupported[0] = OUString("com.sun.star.report.inspection.ReportComponentHandler");
85 0 : return aSupported;
86 : }
87 :
88 : //------------------------------------------------------------------------
89 0 : uno::Reference< uno::XInterface > SAL_CALL ReportComponentHandler::create( const uno::Reference< uno::XComponentContext >& _rxContext )
90 : {
91 0 : return *(new ReportComponentHandler( _rxContext ));
92 : }
93 : // overload WeakComponentImplHelperBase::disposing()
94 : // This function is called upon disposing the component,
95 : // if your component needs special work when it becomes
96 : // disposed, do it here.
97 0 : void SAL_CALL ReportComponentHandler::disposing()
98 : {
99 0 : ::comphelper::disposeComponent(m_xFormComponentHandler);
100 0 : }
101 0 : void SAL_CALL ReportComponentHandler::addEventListener(const uno::Reference< lang::XEventListener > & xListener) throw (uno::RuntimeException)
102 : {
103 0 : m_xFormComponentHandler->addEventListener(xListener);
104 0 : }
105 :
106 0 : void SAL_CALL ReportComponentHandler::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw (uno::RuntimeException)
107 : {
108 0 : m_xFormComponentHandler->removeEventListener(aListener);
109 0 : }
110 :
111 : // inspection::XPropertyHandler:
112 :
113 : /********************************************************************************/
114 0 : void SAL_CALL ReportComponentHandler::inspect(const uno::Reference< uno::XInterface > & Component) throw (uno::RuntimeException, lang::NullPointerException)
115 : {
116 : try
117 : {
118 0 : uno::Reference< container::XNameContainer > xNameCont(Component,uno::UNO_QUERY);
119 0 : const OUString sFormComponent("FormComponent");
120 0 : if ( xNameCont->hasByName(sFormComponent) )
121 0 : xNameCont->getByName(sFormComponent) >>= m_xFormComponent;
122 0 : const OUString sRowSet("RowSet");
123 0 : if ( xNameCont->hasByName(sRowSet) )
124 : {
125 0 : uno::Reference<beans::XPropertySet> xProp(m_xFormComponentHandler,uno::UNO_QUERY);
126 0 : xProp->setPropertyValue(sRowSet,xNameCont->getByName(sRowSet));
127 0 : }
128 : }
129 0 : catch(const uno::Exception &)
130 : {
131 0 : throw lang::NullPointerException();
132 : }
133 0 : if ( m_xFormComponent.is() )
134 : {
135 0 : m_xFormComponentHandler->inspect(m_xFormComponent);
136 : }
137 0 : }
138 :
139 0 : uno::Any SAL_CALL ReportComponentHandler::getPropertyValue(const OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
140 : {
141 0 : return m_xFormComponentHandler->getPropertyValue(PropertyName);
142 : }
143 :
144 0 : void SAL_CALL ReportComponentHandler::setPropertyValue(const OUString & PropertyName, const uno::Any & Value) throw (uno::RuntimeException, beans::UnknownPropertyException)
145 : {
146 0 : m_xFormComponentHandler->setPropertyValue(PropertyName, Value);
147 0 : }
148 :
149 0 : beans::PropertyState SAL_CALL ReportComponentHandler::getPropertyState(const OUString & PropertyName) throw (uno::RuntimeException, beans::UnknownPropertyException)
150 : {
151 0 : return m_xFormComponentHandler->getPropertyState(PropertyName);
152 : }
153 :
154 0 : inspection::LineDescriptor SAL_CALL ReportComponentHandler::describePropertyLine(const OUString & PropertyName, const uno::Reference< inspection::XPropertyControlFactory > & ControlFactory) throw (beans::UnknownPropertyException, lang::NullPointerException,uno::RuntimeException)
155 : {
156 0 : return m_xFormComponentHandler->describePropertyLine(PropertyName, ControlFactory);
157 : }
158 :
159 0 : uno::Any SAL_CALL ReportComponentHandler::convertToPropertyValue(const OUString & PropertyName, const uno::Any & ControlValue) throw (uno::RuntimeException, beans::UnknownPropertyException)
160 : {
161 0 : return m_xFormComponentHandler->convertToPropertyValue(PropertyName, ControlValue);
162 : }
163 :
164 0 : uno::Any SAL_CALL ReportComponentHandler::convertToControlValue(const OUString & PropertyName, const uno::Any & PropertyValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, beans::UnknownPropertyException)
165 : {
166 0 : return m_xFormComponentHandler->convertToControlValue(PropertyName, PropertyValue, ControlValueType);
167 : }
168 :
169 0 : void SAL_CALL ReportComponentHandler::addPropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & Listener) throw (uno::RuntimeException, lang::NullPointerException)
170 : {
171 0 : m_xFormComponentHandler->addPropertyChangeListener(Listener);
172 0 : }
173 :
174 0 : void SAL_CALL ReportComponentHandler::removePropertyChangeListener(const uno::Reference< beans::XPropertyChangeListener > & _rxListener) throw (uno::RuntimeException)
175 : {
176 0 : m_xFormComponentHandler->removePropertyChangeListener(_rxListener);
177 0 : }
178 :
179 0 : uno::Sequence< beans::Property > SAL_CALL ReportComponentHandler::getSupportedProperties() throw (uno::RuntimeException)
180 : {
181 0 : ::std::vector< beans::Property > aNewProps;
182 0 : m_pInfoService->getExcludeProperties( aNewProps, m_xFormComponentHandler );
183 :
184 0 : return aNewProps.empty() ? uno::Sequence< beans::Property > () : uno::Sequence< beans::Property > (&(*aNewProps.begin()),aNewProps.size());
185 : }
186 :
187 0 : uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getSupersededProperties() throw (uno::RuntimeException)
188 : {
189 0 : uno::Sequence< OUString > aRet;
190 0 : return aRet;
191 : }
192 :
193 0 : uno::Sequence< OUString > SAL_CALL ReportComponentHandler::getActuatingProperties() throw (uno::RuntimeException)
194 : {
195 0 : return m_xFormComponentHandler->getActuatingProperties();
196 : }
197 :
198 0 : ::sal_Bool SAL_CALL ReportComponentHandler::isComposable( const OUString& _rPropertyName ) throw (uno::RuntimeException, beans::UnknownPropertyException)
199 : {
200 0 : return m_pInfoService->isComposable( _rPropertyName, m_xFormComponentHandler );
201 : }
202 :
203 0 : inspection::InteractiveSelectionResult SAL_CALL ReportComponentHandler::onInteractivePropertySelection(const OUString & PropertyName, ::sal_Bool Primary, uno::Any & out_Data, const uno::Reference< inspection::XObjectInspectorUI > & InspectorUI) throw (uno::RuntimeException, beans::UnknownPropertyException, lang::NullPointerException)
204 : {
205 0 : return m_xFormComponentHandler->onInteractivePropertySelection(PropertyName, Primary, out_Data, InspectorUI);
206 : }
207 :
208 0 : 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) throw (uno::RuntimeException, lang::NullPointerException)
209 : {
210 0 : m_xFormComponentHandler->actuatingPropertyChanged(ActuatingPropertyName, NewValue, OldValue, InspectorUI, FirstTimeInit);
211 0 : }
212 :
213 0 : ::sal_Bool SAL_CALL ReportComponentHandler::suspend(::sal_Bool Suspend) throw (uno::RuntimeException)
214 : {
215 0 : return m_xFormComponentHandler->suspend(Suspend);
216 : }
217 :
218 : //........................................................................
219 0 : } // namespace rptui
220 : //........................................................................
221 :
222 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|