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