1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TableFieldDescription.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef DBAUI_TABLEFIELDDESC_HXX
31 #define DBAUI_TABLEFIELDDESC_HXX
33 #ifndef INCLUDED_VECTOR
34 #define INCLUDED_VECTOR
37 #ifndef DBAUI_ENUMTYPES_HXX
38 #include "QEnumTypes.hxx"
40 #ifndef _RTL_USTRING_HXX_
41 #include <rtl/ustring.hxx>
43 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
44 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <vos/ref.hxx>
53 class OTableFieldDesc
: public ::vos::OReference
56 ::std::vector
< ::rtl::OUString
> m_vecCriteria
;
58 ::rtl::OUString m_aTableName
;
59 ::rtl::OUString m_aAliasName
; // table range
60 ::rtl::OUString m_aFieldName
; // column
61 ::rtl::OUString m_aFieldAlias
; // column alias
62 ::rtl::OUString m_aFunctionName
; // enth"alt den Funktionsnamen, nur wenn m_eFunctionType != FKT_NONE gesetzt
66 sal_Int32 m_eDataType
;
67 sal_Int32 m_eFunctionType
;
68 ETableFieldType m_eFieldType
;
69 EOrderDir m_eOrderDir
;
71 sal_Int32 m_nColWidth
;
72 sal_uInt16 m_nColumnId
;
76 // !!!! bitte bei Erweiterung um neue Felder auch IsEmpty mitpflegen !!!!
80 OTableFieldDesc(const ::rtl::OUString
& rTable
, const ::rtl::OUString
& rField
);
81 OTableFieldDesc(const OTableFieldDesc
& rRS
);
84 inline sal_Bool
IsEmpty() const;
86 sal_Bool
operator==( const OTableFieldDesc
& rDesc
);
88 sal_Bool
IsVisible() const { return m_bVisible
;}
89 sal_Bool
IsGroupBy() const { return m_bGroupBy
;}
91 void SetVisible( sal_Bool bVis
=sal_True
){ m_bVisible
= bVis
;}
92 void SetGroupBy( sal_Bool bGb
=sal_False
){ m_bGroupBy
= bGb
;}
93 void SetTabWindow( Window
* pWin
){ m_pTabWindow
= pWin
;}
94 void SetField( const ::rtl::OUString
& rF
){ m_aFieldName
= rF
;}
95 void SetFieldAlias( const ::rtl::OUString
& rF
){ m_aFieldAlias
= rF
;}
96 void SetTable( const ::rtl::OUString
& rT
){ m_aTableName
= rT
;}
97 void SetAlias( const ::rtl::OUString
& rT
){ m_aAliasName
= rT
;}
98 void SetFunction( const ::rtl::OUString
& rT
) { m_aFunctionName
= rT
;}
99 void SetOrderDir( EOrderDir eDir
) { m_eOrderDir
= eDir
; }
100 void SetDataType( sal_Int32 eTyp
) { m_eDataType
= eTyp
; }
101 void SetFieldType( ETableFieldType eTyp
) { m_eFieldType
= eTyp
; }
102 void SetCriteria( sal_uInt16 nIdx
, const ::rtl::OUString
& rCrit
);
103 void SetColWidth( sal_Int32 nWidth
) { m_nColWidth
= nWidth
; }
104 void SetFieldIndex( sal_Int32 nFieldIndex
) { m_nIndex
= nFieldIndex
; }
105 void SetFunctionType( sal_Int32 eTyp
) { m_eFunctionType
= eTyp
; }
106 void SetColumnId(sal_uInt16 _nColumnId
) { m_nColumnId
= _nColumnId
; }
109 ::rtl::OUString
GetField() const { return m_aFieldName
;}
110 ::rtl::OUString
GetFieldAlias() const { return m_aFieldAlias
;}
111 ::rtl::OUString
GetTable() const { return m_aTableName
;}
112 ::rtl::OUString
GetAlias() const { return m_aAliasName
;}
113 ::rtl::OUString
GetFunction() const { return m_aFunctionName
;}
114 sal_Int32
GetDataType() const { return m_eDataType
; }
115 ETableFieldType
GetFieldType() const { return m_eFieldType
; }
116 EOrderDir
GetOrderDir() const { return m_eOrderDir
; }
117 ::rtl::OUString
GetCriteria( sal_uInt16 nIdx
) const;
118 sal_Int32
GetColWidth() const { return m_nColWidth
; }
119 sal_Int32
GetFieldIndex() const { return m_nIndex
; }
120 Window
* GetTabWindow() const { return m_pTabWindow
;}
121 sal_Int32
GetFunctionType() const { return m_eFunctionType
; }
122 sal_uInt16
GetColumnId() const { return m_nColumnId
;}
124 inline sal_Bool
isAggreateFunction() const { return (m_eFunctionType
& FKT_AGGREGATE
) == FKT_AGGREGATE
; }
125 inline sal_Bool
isOtherFunction() const { return (m_eFunctionType
& FKT_OTHER
) == FKT_OTHER
; }
126 inline sal_Bool
isNumeric() const { return (m_eFunctionType
& FKT_NUMERIC
) == FKT_NUMERIC
; }
127 inline sal_Bool
isNoneFunction() const { return m_eFunctionType
== FKT_NONE
; }
128 inline sal_Bool
isCondition() const { return (m_eFunctionType
& FKT_CONDITION
) == FKT_CONDITION
; }
129 inline sal_Bool
isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
131 sal_Bool
HasCriteria() const
133 ::std::vector
< ::rtl::OUString
>::const_iterator aIter
= m_vecCriteria
.begin();
134 ::std::vector
< ::rtl::OUString
>::const_iterator aEnd
= m_vecCriteria
.end();
135 for(;aIter
!= aEnd
;++aIter
)
136 if(aIter
->getLength())
138 return aIter
!= aEnd
;
141 const ::std::vector
< ::rtl::OUString
>& GetCriteria() const { return m_vecCriteria
;}
143 void Load(const ::com::sun::star::beans::PropertyValue
& _rProperty
);
144 void Save(::com::sun::star::beans::PropertyValue
& _rProperty
);
147 //------------------------------------------------------------------
148 inline sal_Bool
OTableFieldDesc::IsEmpty() const
150 sal_Bool bEmpty
= (!m_aTableName
.getLength() &&
151 !m_aAliasName
.getLength() &&
152 !m_aFieldName
.getLength() &&
153 !m_aFieldAlias
.getLength() &&
154 !m_aFunctionName
.getLength() &&
158 //------------------------------------------------------------------
159 typedef ::vos::ORef
< OTableFieldDesc
> OTableFieldDescRef
;
160 typedef ::std::vector
<OTableFieldDescRef
> OTableFields
;