1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef DBAUI_TABLEFIELDDESC_HXX
20 #define DBAUI_TABLEFIELDDESC_HXX
24 #include "QEnumTypes.hxx"
25 #include <rtl/ustring.hxx>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <rtl/ref.hxx>
29 #include <salhelper/simplereferenceobject.hxx>
33 class NamedValueCollection
;
40 class OTableFieldDesc
: public ::salhelper::SimpleReferenceObject
43 ::std::vector
< OUString
>
46 OUString m_aTableName
;
47 OUString m_aAliasName
; ///< table range
48 OUString m_aFieldName
; ///< column
49 OUString m_aFieldAlias
; ///< column alias
50 OUString m_aFunctionName
;///< contains the function name (only if m_eFunctionType != FKT_NONE)
54 sal_Int32 m_eDataType
;
55 sal_Int32 m_eFunctionType
;
56 ETableFieldType m_eFieldType
;
57 EOrderDir m_eOrderDir
;
59 sal_Int32 m_nColWidth
;
60 sal_uInt16 m_nColumnId
;
64 // when adding new fields, please take care of IsEmpty!
68 OTableFieldDesc(const OUString
& rTable
, const OUString
& rField
);
69 OTableFieldDesc(const OTableFieldDesc
& rRS
);
72 inline sal_Bool
IsEmpty() const;
74 OTableFieldDesc
& operator=( const OTableFieldDesc
& _aField
);
75 sal_Bool
operator==( const OTableFieldDesc
& rDesc
);
77 sal_Bool
IsVisible() const { return m_bVisible
;}
78 sal_Bool
IsGroupBy() const { return m_bGroupBy
;}
80 void SetVisible( sal_Bool bVis
=sal_True
) { m_bVisible
= bVis
; }
81 void SetGroupBy( sal_Bool bGb
=sal_False
) { m_bGroupBy
= bGb
; }
82 void SetTabWindow( Window
* pWin
){ m_pTabWindow
= pWin
; }
83 void SetField( const OUString
& rF
) { m_aFieldName
= rF
; }
84 void SetFieldAlias( const OUString
& rF
) { m_aFieldAlias
= rF
; }
85 void SetTable( const OUString
& rT
) { m_aTableName
= rT
; }
86 void SetAlias( const OUString
& rT
) { m_aAliasName
= rT
; }
87 void SetFunction( const OUString
& rT
) { m_aFunctionName
= rT
; }
88 void SetOrderDir( EOrderDir eDir
) { m_eOrderDir
= eDir
; }
89 void SetDataType( sal_Int32 eTyp
) { m_eDataType
= eTyp
; }
90 void SetFieldType( ETableFieldType eTyp
) { m_eFieldType
= eTyp
; }
91 void SetCriteria( sal_uInt16 nIdx
, const OUString
& rCrit
);
92 void SetColWidth( sal_Int32 nWidth
) { m_nColWidth
= nWidth
; }
93 void SetFieldIndex( sal_Int32 nFieldIndex
) { m_nIndex
= nFieldIndex
; }
94 void SetFunctionType( sal_Int32 eTyp
) { m_eFunctionType
= eTyp
; }
95 void SetColumnId(sal_uInt16 _nColumnId
) { m_nColumnId
= _nColumnId
; }
97 OUString
GetField() const { return m_aFieldName
;}
98 OUString
GetFieldAlias() const { return m_aFieldAlias
;}
99 OUString
GetTable() const { return m_aTableName
;}
100 OUString
GetAlias() const { return m_aAliasName
;}
101 OUString
GetFunction() const { return m_aFunctionName
;}
102 sal_Int32
GetDataType() const { return m_eDataType
; }
103 ETableFieldType
GetFieldType() const { return m_eFieldType
; }
104 EOrderDir
GetOrderDir() const { return m_eOrderDir
; }
105 OUString
GetCriteria( sal_uInt16 nIdx
) const;
106 sal_Int32
GetColWidth() const { return m_nColWidth
; }
107 sal_Int32
GetFieldIndex() const { return m_nIndex
; }
108 Window
* GetTabWindow() const { return m_pTabWindow
;}
109 sal_Int32
GetFunctionType() const { return m_eFunctionType
; }
110 sal_uInt16
GetColumnId() const { return m_nColumnId
;}
112 inline sal_Bool
isAggreateFunction() const { return (m_eFunctionType
& FKT_AGGREGATE
) == FKT_AGGREGATE
; }
113 inline sal_Bool
isOtherFunction() const { return (m_eFunctionType
& FKT_OTHER
) == FKT_OTHER
; }
114 inline sal_Bool
isNumeric() const { return (m_eFunctionType
& FKT_NUMERIC
) == FKT_NUMERIC
; }
115 inline sal_Bool
isNoneFunction() const { return m_eFunctionType
== FKT_NONE
; }
116 inline sal_Bool
isCondition() const { return (m_eFunctionType
& FKT_CONDITION
) == FKT_CONDITION
; }
117 inline sal_Bool
isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
119 sal_Bool
HasCriteria() const
121 ::std::vector
< OUString
>::const_iterator aIter
= m_aCriteria
.begin();
122 ::std::vector
< OUString
>::const_iterator aEnd
= m_aCriteria
.end();
123 for(;aIter
!= aEnd
;++aIter
)
124 if(!aIter
->isEmpty())
126 return aIter
!= aEnd
;
129 const ::std::vector
< OUString
>& GetCriteria() const { return m_aCriteria
; }
131 void Load( const ::com::sun::star::beans::PropertyValue
& i_rSettings
, const bool i_bIncludingCriteria
);
132 void Save( ::comphelper::NamedValueCollection
& o_rSettings
, const bool i_bIncludingCriteria
);
135 inline sal_Bool
OTableFieldDesc::IsEmpty() const
137 sal_Bool bEmpty
= (m_aTableName
.isEmpty() &&
138 m_aAliasName
.isEmpty() &&
139 m_aFieldName
.isEmpty() &&
140 m_aFieldAlias
.isEmpty() &&
141 m_aFunctionName
.isEmpty() &&
146 typedef ::rtl::Reference
< OTableFieldDesc
> OTableFieldDescRef
;
147 typedef ::std::vector
<OTableFieldDescRef
> OTableFields
;
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */