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 24 #ifndef TOOLKIT_FORMATTED_CONTROL_HXX 25 #define TOOLKIT_FORMATTED_CONTROL_HXX 26 27 #include <toolkit/controls/unocontrols.hxx> 28 #include <toolkit/controls/unocontrolmodel.hxx> 29 #include <toolkit/helper/servicenames.hxx> 30 31 #include <com/sun/star/util/XNumberFormatter.hpp> 32 33 //........................................................................ 34 namespace toolkit 35 { 36 //........................................................................ 37 38 // =================================================================== 39 // = UnoControlFormattedFieldModel 40 // =================================================================== 41 class UnoControlFormattedFieldModel : public UnoControlModel 42 { 43 protected: 44 ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; 45 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); 46 ::com::sun::star::uno::Any m_aCachedFormat; 47 bool m_bRevokedAsClient; 48 bool m_bSettingValueAndText; 49 ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > 50 m_xCachedFormatter; 51 52 protected: 53 sal_Bool SAL_CALL convertFastPropertyValue( 54 ::com::sun::star::uno::Any& rConvertedValue, 55 ::com::sun::star::uno::Any& rOldValue, 56 sal_Int32 nPropId, 57 const ::com::sun::star::uno::Any& rValue 58 ) throw (::com::sun::star::lang::IllegalArgumentException); 59 60 void SAL_CALL setFastPropertyValue_NoBroadcast( 61 sal_Int32 nHandle, 62 const ::com::sun::star::uno::Any& rValue 63 ) throw (::com::sun::star::uno::Exception); 64 65 public: 66 UnoControlFormattedFieldModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); UnoControlFormattedFieldModel(const UnoControlFormattedFieldModel & rModel)67 UnoControlFormattedFieldModel( const UnoControlFormattedFieldModel& rModel ) 68 :UnoControlModel( rModel ) 69 { 70 } 71 Clone() const72 UnoControlModel* Clone() const { return new UnoControlFormattedFieldModel( *this ); } 73 74 // ::com::sun::star::io::XPersistObject 75 ::rtl::OUString SAL_CALL getServiceName() throw(::com::sun::star::uno::RuntimeException); 76 77 // ::com::sun::star::beans::XMultiPropertySet 78 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException); 79 80 81 // ::com::sun::star::lang::XServiceInfo 82 DECLIMPL_SERVICEINFO_DERIVED( UnoControlFormattedFieldModel, UnoControlModel, szServiceName2_UnoControlFormattedFieldModel ) 83 84 protected: 85 ~UnoControlFormattedFieldModel(); 86 87 // XComponent 88 void SAL_CALL dispose( ) throw(::com::sun::star::uno::RuntimeException); 89 90 // XPropertySet 91 void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); 92 93 // UnoControlModel 94 virtual void ImplNormalizePropertySequence( 95 const sal_Int32 _nCount, /// the number of entries in the arrays 96 sal_Int32* _pHandles, /// the handles of the properties to set 97 ::com::sun::star::uno::Any* _pValues, /// the values of the properties to set 98 sal_Int32* _pValidHandles /// pointer to the valid handles, allowed to be adjusted 99 ) const SAL_THROW(()); 100 private: 101 void impl_updateTextFromValue_nothrow(); 102 void impl_updateCachedFormatter_nothrow(); 103 void impl_updateCachedFormatKey_nothrow(); 104 }; 105 106 // =================================================================== 107 // = UnoFormattedFieldControl 108 // =================================================================== 109 class UnoFormattedFieldControl : public UnoSpinFieldControl 110 { 111 public: 112 UnoFormattedFieldControl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ); 113 ::rtl::OUString GetComponentServiceName(); 114 115 // ::com::sun::star::awt::XTextListener 116 void SAL_CALL textChanged( const ::com::sun::star::awt::TextEvent& rEvent ) throw(::com::sun::star::uno::RuntimeException); 117 118 // ::com::sun::star::lang::XServiceInfo 119 DECLIMPL_SERVICEINFO_DERIVED( UnoFormattedFieldControl, UnoEditControl, szServiceName2_UnoControlFormattedField ) 120 }; 121 122 //........................................................................ 123 } // namespace toolkit 124 //........................................................................ 125 126 #endif // TOOLKIT_FORMATTED_CONTROL_HXX 127