1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_FIELDDESCRIPTIONS_HXX
28 #define DBAUI_FIELDDESCRIPTIONS_HXX
29 
30 #ifndef DBAUI_ENUMTYPES_HXX
31 #include "QEnumTypes.hxx"
32 #endif
33 #ifndef _SVX_SVXENUM_HXX
34 #include <editeng/svxenum.hxx>
35 #endif
36 #ifndef DBAUI_TYPEINFO_HXX
37 #include "TypeInfo.hxx"
38 #endif
39 #ifndef _OSL_DIAGNOSE_H_
40 #include <osl/diagnose.h>
41 #endif
42 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
46 #include <com/sun/star/beans/XPropertySetInfo.hpp>
47 #endif
48 
49 namespace dbaui
50 {
51 	class OFieldDescription
52 	{
53 	private:
54 		::com::sun::star::uno::Any		m_aDefaultValue;	// the default value from the database
55 		::com::sun::star::uno::Any		m_aControlDefault;	// the value which the control inserts as default
56 		::com::sun::star::uno::Any		m_aWidth;				// sal_Int32 or void
57 		::com::sun::star::uno::Any		m_aRelativePosition;	// sal_Int32 or void
58 
59 		TOTypeInfoSP	m_pType;
60 
61 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >		m_xDest;
62 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >	m_xDestInfo;
63 
64 		::rtl::OUString		m_sName;
65 		::rtl::OUString		m_sTypeName;
66 		::rtl::OUString		m_sDescription;
67         ::rtl::OUString		m_sHelpText;
68 
69 		::rtl::OUString		m_sAutoIncrementValue;
70 		sal_Int32			m_nType;	// only used when m_pType is null
71 		sal_Int32			m_nPrecision;
72 		sal_Int32			m_nScale;
73 		sal_Int32			m_nIsNullable;
74 		sal_Int32			m_nFormatKey;
75 		SvxCellHorJustify	m_eHorJustify;
76 		sal_Bool			m_bIsAutoIncrement;
77 		sal_Bool			m_bIsPrimaryKey;
78 		sal_Bool			m_bIsCurrency;
79 		sal_Bool			m_bHidden;
80 
81 	public:
82 		OFieldDescription();
83 		OFieldDescription( const OFieldDescription& rDescr );
84 		OFieldDescription(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xAffectedCol
85 						 ,sal_Bool _bUseAsDest = sal_False);
86 		~OFieldDescription();
87 
88 		void SetName(const ::rtl::OUString& _rName);
89 		void SetDescription(const ::rtl::OUString& _rDescription);
90         void SetHelpText(const ::rtl::OUString& _sHelptext);
91 		void SetDefaultValue(const ::com::sun::star::uno::Any& _rDefaultValue);
92 		void SetControlDefault(const ::com::sun::star::uno::Any& _rControlDefault);
93 		void SetAutoIncrementValue(const ::rtl::OUString& _sAutoIncValue);
94 		void SetType(TOTypeInfoSP _pType);
95 		void SetTypeValue(sal_Int32 _nType);
96 		void SetTypeName(const ::rtl::OUString& _sTypeName);
97 		void SetPrecision(const sal_Int32& _rPrecision);
98 		void SetScale(const sal_Int32& _rScale);
99 		void SetIsNullable(const sal_Int32& _rIsNullable);
100 		void SetFormatKey(const sal_Int32& _rFormatKey);
101 		void SetHorJustify(const SvxCellHorJustify& _rHorJustify);
102 		void SetAutoIncrement(sal_Bool _bAuto);
103 		void SetPrimaryKey(sal_Bool _bPKey);
104 		void SetCurrency(sal_Bool _bIsCurrency);
105 
106 		/** copies the content of the field eescription into the column
107 			@param	_rxColumn the dest
108 		*/
109 		void copyColumnSettingsTo(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumn);
110 
111 		void FillFromTypeInfo(const TOTypeInfoSP& _pType,sal_Bool _bForce,sal_Bool _bReset);
112 
113 		::rtl::OUString				GetName()				const;
114 		::rtl::OUString				GetDescription()		const;
115         ::rtl::OUString				GetHelpText()		    const;
116 		::com::sun::star::uno::Any	GetControlDefault()		const;
117 		::rtl::OUString				GetAutoIncrementValue()	const;
118 		sal_Int32					GetType()				const;
119 		::rtl::OUString				GetTypeName()			const;
120 		sal_Int32					GetPrecision()			const;
121 		sal_Int32					GetScale()				const;
122 		sal_Int32					GetIsNullable()			const;
123 		sal_Int32					GetFormatKey()			const;
124 		SvxCellHorJustify			GetHorJustify()			const;
125 		TOTypeInfoSP				getTypeInfo()			const;
126         TOTypeInfoSP				getSpecialTypeInfo()	const;
127 		sal_Bool					IsAutoIncrement()		const;
128 		sal_Bool					IsPrimaryKey()			const;
129 		sal_Bool					IsCurrency()			const;
130 		sal_Bool					IsNullable()			const;
131 	};
132 }
133 #endif // DBAUI_FIELDDESCRIPTIONS_HXX
134 
135 
136