Branch data 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 DBAUI_TABLEFIELDDESC_HXX
20 : : #define DBAUI_TABLEFIELDDESC_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 : :
29 : : #include <salhelper/simplereferenceobject.hxx>
30 : :
31 : : namespace comphelper
32 : : {
33 : : class NamedValueCollection;
34 : : }
35 : :
36 : : class Window;
37 : :
38 : : namespace dbaui
39 : : {
40 : : class OTableFieldDesc : public ::salhelper::SimpleReferenceObject
41 : : {
42 : : private:
43 : : ::std::vector< ::rtl::OUString >
44 : : m_aCriteria;
45 : :
46 : : ::rtl::OUString m_aTableName;
47 : : ::rtl::OUString m_aAliasName; ///< table range
48 : : ::rtl::OUString m_aFieldName; ///< column
49 : : ::rtl::OUString m_aFieldAlias; ///< column alias
50 : : ::rtl::OUString m_aFunctionName;///< contains the function name (only if m_eFunctionType != FKT_NONE)
51 : :
52 : : Window* m_pTabWindow;
53 : :
54 : : sal_Int32 m_eDataType;
55 : : sal_Int32 m_eFunctionType;
56 : : ETableFieldType m_eFieldType;
57 : : EOrderDir m_eOrderDir;
58 : : sal_Int32 m_nIndex;
59 : : sal_Int32 m_nColWidth;
60 : : sal_uInt16 m_nColumnId;
61 : : sal_Bool m_bGroupBy;
62 : : sal_Bool m_bVisible;
63 : :
64 : : // when adding new fields, please take care of IsEmpty!
65 : :
66 : : public:
67 : : OTableFieldDesc();
68 : : OTableFieldDesc(const ::rtl::OUString& rTable, const ::rtl::OUString& rField );
69 : : OTableFieldDesc(const OTableFieldDesc& rRS);
70 : : ~OTableFieldDesc();
71 : :
72 : : inline sal_Bool IsEmpty() const;
73 : :
74 : : OTableFieldDesc& operator=( const OTableFieldDesc& _aField );
75 : : sal_Bool operator==( const OTableFieldDesc& rDesc );
76 : :
77 : 0 : sal_Bool IsVisible() const { return m_bVisible;}
78 : 0 : sal_Bool IsGroupBy() const { return m_bGroupBy;}
79 : :
80 : 0 : void SetVisible( sal_Bool bVis=sal_True ) { m_bVisible = bVis; }
81 : 0 : void SetGroupBy( sal_Bool bGb=sal_False ) { m_bGroupBy = bGb; }
82 : 0 : void SetTabWindow( Window* pWin ){ m_pTabWindow = pWin; }
83 : 0 : void SetField( const ::rtl::OUString& rF ) { m_aFieldName = rF; }
84 : 0 : void SetFieldAlias( const ::rtl::OUString& rF ) { m_aFieldAlias = rF; }
85 : 0 : void SetTable( const ::rtl::OUString& rT ) { m_aTableName = rT; }
86 : 0 : void SetAlias( const ::rtl::OUString& rT ) { m_aAliasName = rT; }
87 : 0 : void SetFunction( const ::rtl::OUString& rT ) { m_aFunctionName = rT; }
88 : 0 : void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; }
89 : 0 : void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; }
90 : 0 : void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; }
91 : : void SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit );
92 : 0 : void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
93 : 0 : void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
94 : 0 : void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; }
95 : 0 : void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
96 : :
97 : 0 : ::rtl::OUString GetField() const { return m_aFieldName;}
98 : 0 : ::rtl::OUString GetFieldAlias() const { return m_aFieldAlias;}
99 : 0 : ::rtl::OUString GetTable() const { return m_aTableName;}
100 : 0 : ::rtl::OUString GetAlias() const { return m_aAliasName;}
101 : 0 : ::rtl::OUString GetFunction() const { return m_aFunctionName;}
102 : 0 : sal_Int32 GetDataType() const { return m_eDataType; }
103 : 0 : ETableFieldType GetFieldType() const { return m_eFieldType; }
104 : 0 : EOrderDir GetOrderDir() const { return m_eOrderDir; }
105 : : ::rtl::OUString GetCriteria( sal_uInt16 nIdx ) const;
106 : 0 : sal_Int32 GetColWidth() const { return m_nColWidth; }
107 : 0 : sal_Int32 GetFieldIndex() const { return m_nIndex; }
108 : 0 : Window* GetTabWindow() const { return m_pTabWindow;}
109 : 0 : sal_Int32 GetFunctionType() const { return m_eFunctionType; }
110 : 0 : sal_uInt16 GetColumnId() const { return m_nColumnId;}
111 : :
112 : 0 : inline sal_Bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; }
113 : 0 : inline sal_Bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; }
114 : 0 : inline sal_Bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; }
115 : 0 : inline sal_Bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; }
116 : 0 : inline sal_Bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; }
117 [ # # ][ # # ]: 0 : inline sal_Bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); }
118 : :
119 : 0 : sal_Bool HasCriteria() const
120 : : {
121 : 0 : ::std::vector< ::rtl::OUString>::const_iterator aIter = m_aCriteria.begin();
122 : 0 : ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_aCriteria.end();
123 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
124 [ # # ]: 0 : if(!aIter->isEmpty())
125 : 0 : break;
126 [ # # ]: 0 : return aIter != aEnd;
127 : : }
128 : :
129 : 0 : const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_aCriteria; }
130 : :
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 );
133 : : };
134 : :
135 : 0 : inline sal_Bool OTableFieldDesc::IsEmpty() const
136 : : {
137 : 0 : sal_Bool bEmpty = (m_aTableName.isEmpty() &&
138 : 0 : m_aAliasName.isEmpty() &&
139 : 0 : m_aFieldName.isEmpty() &&
140 : 0 : m_aFieldAlias.isEmpty() &&
141 : 0 : m_aFunctionName.isEmpty() &&
142 [ # # ][ # # : 0 : !HasCriteria());
# # # # #
# # # ]
143 : 0 : return bEmpty;
144 : : }
145 : :
146 : : typedef ::rtl::Reference< OTableFieldDesc> OTableFieldDescRef;
147 : : typedef ::std::vector<OTableFieldDescRef> OTableFields;
148 : : }
149 : : #endif
150 : :
151 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|