1*caf5cd79SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*caf5cd79SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*caf5cd79SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*caf5cd79SAndrew Rist * distributed with this work for additional information 6*caf5cd79SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*caf5cd79SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*caf5cd79SAndrew Rist * "License"); you may not use this file except in compliance 9*caf5cd79SAndrew Rist * with the License. You may obtain a copy of the License at 10*caf5cd79SAndrew Rist * 11*caf5cd79SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*caf5cd79SAndrew Rist * 13*caf5cd79SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*caf5cd79SAndrew Rist * software distributed under the License is distributed on an 15*caf5cd79SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*caf5cd79SAndrew Rist * KIND, either express or implied. See the License for the 17*caf5cd79SAndrew Rist * specific language governing permissions and limitations 18*caf5cd79SAndrew Rist * under the License. 19*caf5cd79SAndrew Rist * 20*caf5cd79SAndrew Rist *************************************************************/ 21*caf5cd79SAndrew Rist 22*caf5cd79SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX 25cdf0e10cSrcweir #define CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** === begin UNO includes === **/ 28cdf0e10cSrcweir #include <com/sun/star/sdbc/XRowSet.hpp> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/sdb/XColumn.hpp> 31cdf0e10cSrcweir #include <com/sun/star/sdb/XColumnUpdate.hpp> 32cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp> 33cdf0e10cSrcweir /** === end UNO includes === **/ 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <boost/noncopyable.hpp> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <memory> 38cdf0e10cSrcweir #include "connectivity/dbtoolsdllapi.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace comphelper { class ComponentContext; } 41cdf0e10cSrcweir 42cdf0e10cSrcweir //........................................................................ 43cdf0e10cSrcweir namespace dbtools 44cdf0e10cSrcweir { 45cdf0e10cSrcweir //........................................................................ 46cdf0e10cSrcweir 47cdf0e10cSrcweir struct FormattedColumnValue_Data; 48cdf0e10cSrcweir //==================================================================== 49cdf0e10cSrcweir //= FormattedColumnValue 50cdf0e10cSrcweir //==================================================================== 51cdf0e10cSrcweir /** a class which helps retrieving and setting the value of a database column 52cdf0e10cSrcweir as formatted string. 53cdf0e10cSrcweir */ 54cdf0e10cSrcweir class OOO_DLLPUBLIC_DBTOOLS FormattedColumnValue : public ::boost::noncopyable 55cdf0e10cSrcweir { 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir /** constructs an instance 58cdf0e10cSrcweir 59cdf0e10cSrcweir The format key for the string value exchange is taken from the given column object. 60cdf0e10cSrcweir If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken. 61cdf0e10cSrcweir Otherwise, a default format matching the column type is determined. 62cdf0e10cSrcweir 63cdf0e10cSrcweir The locale of this fallback format is the current system locale. 64cdf0e10cSrcweir 65cdf0e10cSrcweir The number formats supplier is determined from the given <code>RowSet</code>, by 66cdf0e10cSrcweir examining its <code>ActiveConnection</code>. 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir FormattedColumnValue( 69cdf0e10cSrcweir const ::comphelper::ComponentContext& _rContext, 70cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxRowSet, 71cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn 72cdf0e10cSrcweir ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir /** constructs an instance 75cdf0e10cSrcweir 76cdf0e10cSrcweir The format key for the string value exchange is taken from the given column object. 77cdf0e10cSrcweir If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken. 78cdf0e10cSrcweir Otherwise, a default format matching the column type is determined. 79cdf0e10cSrcweir 80cdf0e10cSrcweir The locale of this fallback format is the current system locale. 81cdf0e10cSrcweir */ 82cdf0e10cSrcweir FormattedColumnValue( 83cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& i_rNumberFormatter, 84cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_rColumn 85cdf0e10cSrcweir ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir // note that all methods of this class need to be virtual, since it's 88cdf0e10cSrcweir // used in a load-on-demand context in module SVX 89cdf0e10cSrcweir 90cdf0e10cSrcweir virtual ~FormattedColumnValue(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir virtual void clear(); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // access to the details of the formatting we determined 95cdf0e10cSrcweir virtual sal_Int32 getFormatKey() const; 96cdf0e10cSrcweir virtual sal_Int32 getFieldType() const; 97cdf0e10cSrcweir virtual sal_Int16 getKeyType() const; 98cdf0e10cSrcweir virtual bool isNumericField() const; 99cdf0e10cSrcweir virtual const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& 100cdf0e10cSrcweir getColumn() const; 101cdf0e10cSrcweir virtual const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate >& 102cdf0e10cSrcweir getColumnUpdate() const; 103cdf0e10cSrcweir 104cdf0e10cSrcweir virtual bool setFormattedValue( const ::rtl::OUString& _rFormattedStringValue ) const; 105cdf0e10cSrcweir virtual ::rtl::OUString getFormattedValue() const; 106cdf0e10cSrcweir 107cdf0e10cSrcweir private: 108cdf0e10cSrcweir ::std::auto_ptr< FormattedColumnValue_Data > m_pData; 109cdf0e10cSrcweir }; 110cdf0e10cSrcweir 111cdf0e10cSrcweir //........................................................................ 112cdf0e10cSrcweir } // namespace dbtools 113cdf0e10cSrcweir //........................................................................ 114cdf0e10cSrcweir 115cdf0e10cSrcweir #endif // CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX 116