Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEFIELDDESCRIPTION_HXX
20 : #define INCLUDED_DBACCESS_SOURCE_UI_INC_TABLEFIELDDESCRIPTION_HXX
21 :
22 : #include <vector>
23 :
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>
29 :
30 : #include <salhelper/simplereferenceobject.hxx>
31 :
32 : namespace comphelper
33 : {
34 : class NamedValueCollection;
35 : }
36 :
37 : namespace vcl { class Window; }
38 :
39 : namespace dbaui
40 : {
41 : class OTableFieldDesc : public ::salhelper::SimpleReferenceObject
42 : {
43 : private:
44 : ::std::vector< OUString >
45 : m_aCriteria;
46 :
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)
52 :
53 : VclPtr<vcl::Window> m_pTabWindow;
54 :
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;
64 :
65 : // when adding new fields, please take care of IsEmpty!
66 :
67 : public:
68 : OTableFieldDesc();
69 : OTableFieldDesc(const OUString& rTable, const OUString& rField );
70 : OTableFieldDesc(const OTableFieldDesc& rRS);
71 : virtual ~OTableFieldDesc();
72 :
73 : inline bool IsEmpty() const;
74 :
75 : OTableFieldDesc& operator=( const OTableFieldDesc& _aField );
76 : bool operator==( const OTableFieldDesc& rDesc );
77 :
78 0 : bool IsVisible() const { return m_bVisible;}
79 0 : bool IsGroupBy() const { return m_bGroupBy;}
80 :
81 0 : void SetVisible( bool bVis=true ) { m_bVisible = bVis; }
82 0 : void SetGroupBy( bool bGb=false ) { m_bGroupBy = bGb; }
83 0 : void SetTabWindow( vcl::Window* pWin ){ m_pTabWindow = pWin; }
84 0 : void SetField( const OUString& rF ) { m_aFieldName = rF; }
85 0 : void SetFieldAlias( const OUString& rF ) { m_aFieldAlias = rF; }
86 0 : void SetTable( const OUString& rT ) { m_aTableName = rT; }
87 0 : void SetAlias( const OUString& rT ) { m_aAliasName = rT; }
88 0 : void SetFunction( const OUString& rT ) { m_aFunctionName = rT; }
89 0 : void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; }
90 0 : void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; }
91 0 : void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; }
92 : void SetCriteria( sal_uInt16 nIdx, const OUString& rCrit );
93 0 : void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
94 0 : void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
95 0 : void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; }
96 0 : void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
97 :
98 0 : OUString GetField() const { return m_aFieldName;}
99 0 : OUString GetFieldAlias() const { return m_aFieldAlias;}
100 0 : OUString GetTable() const { return m_aTableName;}
101 0 : OUString GetAlias() const { return m_aAliasName;}
102 0 : OUString GetFunction() const { return m_aFunctionName;}
103 0 : sal_Int32 GetDataType() const { return m_eDataType; }
104 0 : ETableFieldType GetFieldType() const { return m_eFieldType; }
105 0 : EOrderDir GetOrderDir() const { return m_eOrderDir; }
106 : OUString GetCriteria( sal_uInt16 nIdx ) const;
107 0 : sal_Int32 GetColWidth() const { return m_nColWidth; }
108 0 : sal_Int32 GetFieldIndex() const { return m_nIndex; }
109 0 : vcl::Window* GetTabWindow() const { return m_pTabWindow;}
110 0 : sal_Int32 GetFunctionType() const { return m_eFunctionType; }
111 0 : sal_uInt16 GetColumnId() const { return m_nColumnId;}
112 :
113 0 : inline bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; }
114 0 : inline bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; }
115 0 : inline bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; }
116 0 : inline bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; }
117 0 : inline bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; }
118 0 : inline bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
119 :
120 0 : bool HasCriteria() const
121 : {
122 0 : ::std::vector< OUString>::const_iterator aIter = m_aCriteria.begin();
123 0 : ::std::vector< OUString>::const_iterator aEnd = m_aCriteria.end();
124 0 : for(;aIter != aEnd;++aIter)
125 0 : if(!aIter->isEmpty())
126 0 : break;
127 0 : return aIter != aEnd;
128 : }
129 :
130 0 : const ::std::vector< OUString>& GetCriteria() const { return m_aCriteria; }
131 :
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 );
134 : };
135 :
136 0 : inline bool OTableFieldDesc::IsEmpty() const
137 : {
138 0 : bool bEmpty = (m_aTableName.isEmpty() &&
139 0 : m_aAliasName.isEmpty() &&
140 0 : m_aFieldName.isEmpty() &&
141 0 : m_aFieldAlias.isEmpty() &&
142 0 : m_aFunctionName.isEmpty() &&
143 0 : !HasCriteria());
144 0 : return bEmpty;
145 : }
146 :
147 : typedef ::rtl::Reference< OTableFieldDesc> OTableFieldDescRef;
148 : typedef ::std::vector<OTableFieldDescRef> OTableFields;
149 : }
150 : #endif
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|