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 INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEFIELDDESCRIPTION_HXX
20 #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEFIELDDESCRIPTION_HXX
24 #include "QEnumTypes.hxx"
25 #include <rtl/ustring.hxx>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <rtl/ref.hxx>
28 #include <vcl/vclptr.hxx>
30 #include <salhelper/simplereferenceobject.hxx>
34 class NamedValueCollection
;
37 namespace vcl
{ class Window
; }
41 class OTableFieldDesc
: public ::salhelper::SimpleReferenceObject
44 ::std::vector
< OUString
>
47 OUString m_aTableName
;
48 OUString m_aAliasName
; ///< table range
49 OUString m_aFieldName
; ///< column
50 OUString m_aFieldAlias
; ///< column alias
51 OUString m_aFunctionName
;///< contains the function name (only if m_eFunctionType != FKT_NONE)
53 VclPtr
<vcl::Window
> m_pTabWindow
;
55 sal_Int32 m_eDataType
;
56 sal_Int32 m_eFunctionType
;
57 ETableFieldType m_eFieldType
;
58 EOrderDir m_eOrderDir
;
60 sal_Int32 m_nColWidth
;
61 sal_uInt16 m_nColumnId
;
65 // when adding new fields, please take care of IsEmpty!
69 OTableFieldDesc(const OUString
& rTable
, const OUString
& rField
);
70 OTableFieldDesc(const OTableFieldDesc
& rRS
);
71 virtual ~OTableFieldDesc();
73 inline bool IsEmpty() const;
75 OTableFieldDesc
& operator=( const OTableFieldDesc
& _aField
);
77 bool IsVisible() const { return m_bVisible
;}
78 bool IsGroupBy() const { return m_bGroupBy
;}
80 void SetVisible( bool bVis
=true ) { m_bVisible
= bVis
; }
81 void SetGroupBy( bool bGb
) { m_bGroupBy
= bGb
; }
82 void SetTabWindow( vcl::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 const OUString
& GetField() const { return m_aFieldName
;}
98 const OUString
& GetFieldAlias() const { return m_aFieldAlias
;}
99 const OUString
& GetTable() const { return m_aTableName
;}
100 const OUString
& GetAlias() const { return m_aAliasName
;}
101 const 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 vcl::Window
* GetTabWindow() const { return m_pTabWindow
;}
109 sal_Int32
GetFunctionType() const { return m_eFunctionType
; }
110 sal_uInt16
GetColumnId() const { return m_nColumnId
;}
112 inline bool isAggreateFunction() const { return (m_eFunctionType
& FKT_AGGREGATE
) == FKT_AGGREGATE
; }
113 inline bool isOtherFunction() const { return (m_eFunctionType
& FKT_OTHER
) == FKT_OTHER
; }
114 inline bool isNumeric() const { return (m_eFunctionType
& FKT_NUMERIC
) == FKT_NUMERIC
; }
115 inline bool isNoneFunction() const { return m_eFunctionType
== FKT_NONE
; }
116 inline bool isCondition() const { return (m_eFunctionType
& FKT_CONDITION
) == FKT_CONDITION
; }
117 inline bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
119 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 css::beans::PropertyValue
& i_rSettings
, const bool i_bIncludingCriteria
);
132 void Save( ::comphelper::NamedValueCollection
& o_rSettings
, const bool i_bIncludingCriteria
);
135 inline bool OTableFieldDesc::IsEmpty() const
137 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: */