Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / ui / inc / TableFieldDescription.hxx
blobd8e5f3d524d216a59b3bf881ce741e48eb3a6665
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
22 #include <vector>
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>
32 namespace comphelper
34 class NamedValueCollection;
37 namespace vcl { class Window; }
39 namespace dbaui
41 class OTableFieldDesc : public ::salhelper::SimpleReferenceObject
43 private:
44 ::std::vector< OUString >
45 m_aCriteria;
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;
59 sal_Int32 m_nIndex;
60 sal_Int32 m_nColWidth;
61 sal_uInt16 m_nColumnId;
62 bool m_bGroupBy;
63 bool m_bVisible;
65 // when adding new fields, please take care of IsEmpty!
67 public:
68 OTableFieldDesc();
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 );
76 bool operator==( const OTableFieldDesc& rDesc );
78 bool IsVisible() const { return m_bVisible;}
79 bool IsGroupBy() const { return m_bGroupBy;}
81 void SetVisible( bool bVis=true ) { m_bVisible = bVis; }
82 void SetGroupBy( bool bGb=false ) { m_bGroupBy = bGb; }
83 void SetTabWindow( vcl::Window* pWin ){ m_pTabWindow = pWin; }
84 void SetField( const OUString& rF ) { m_aFieldName = rF; }
85 void SetFieldAlias( const OUString& rF ) { m_aFieldAlias = rF; }
86 void SetTable( const OUString& rT ) { m_aTableName = rT; }
87 void SetAlias( const OUString& rT ) { m_aAliasName = rT; }
88 void SetFunction( const OUString& rT ) { m_aFunctionName = rT; }
89 void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; }
90 void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; }
91 void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; }
92 void SetCriteria( sal_uInt16 nIdx, const OUString& rCrit );
93 void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
94 void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
95 void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; }
96 void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
98 OUString GetField() const { return m_aFieldName;}
99 OUString GetFieldAlias() const { return m_aFieldAlias;}
100 OUString GetTable() const { return m_aTableName;}
101 OUString GetAlias() const { return m_aAliasName;}
102 OUString GetFunction() const { return m_aFunctionName;}
103 sal_Int32 GetDataType() const { return m_eDataType; }
104 ETableFieldType GetFieldType() const { return m_eFieldType; }
105 EOrderDir GetOrderDir() const { return m_eOrderDir; }
106 OUString GetCriteria( sal_uInt16 nIdx ) const;
107 sal_Int32 GetColWidth() const { return m_nColWidth; }
108 sal_Int32 GetFieldIndex() const { return m_nIndex; }
109 vcl::Window* GetTabWindow() const { return m_pTabWindow;}
110 sal_Int32 GetFunctionType() const { return m_eFunctionType; }
111 sal_uInt16 GetColumnId() const { return m_nColumnId;}
113 inline bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; }
114 inline bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; }
115 inline bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; }
116 inline bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; }
117 inline bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; }
118 inline bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
120 bool HasCriteria() const
122 ::std::vector< OUString>::const_iterator aIter = m_aCriteria.begin();
123 ::std::vector< OUString>::const_iterator aEnd = m_aCriteria.end();
124 for(;aIter != aEnd;++aIter)
125 if(!aIter->isEmpty())
126 break;
127 return aIter != aEnd;
130 const ::std::vector< OUString>& GetCriteria() const { return m_aCriteria; }
132 void Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria );
133 void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria );
136 inline bool OTableFieldDesc::IsEmpty() const
138 bool bEmpty = (m_aTableName.isEmpty() &&
139 m_aAliasName.isEmpty() &&
140 m_aFieldName.isEmpty() &&
141 m_aFieldAlias.isEmpty() &&
142 m_aFunctionName.isEmpty() &&
143 !HasCriteria());
144 return bEmpty;
147 typedef ::rtl::Reference< OTableFieldDesc> OTableFieldDescRef;
148 typedef ::std::vector<OTableFieldDescRef> OTableFields;
150 #endif
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */