xref: /trunk/main/dbaccess/source/ui/inc/TableFieldDescription.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DBAUI_TABLEFIELDDESC_HXX
28 #define DBAUI_TABLEFIELDDESC_HXX
29 
30 #ifndef INCLUDED_VECTOR
31 #define INCLUDED_VECTOR
32 #include <vector>
33 #endif
34 #ifndef DBAUI_ENUMTYPES_HXX
35 #include "QEnumTypes.hxx"
36 #endif
37 #ifndef _RTL_USTRING_HXX_
38 #include <rtl/ustring.hxx>
39 #endif
40 #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #endif
43 #ifndef _VOS_REF_HXX_
44 #include <vos/ref.hxx>
45 #endif
46 
47 namespace comphelper
48 {
49     class NamedValueCollection;
50 }
51 
52 class Window;
53 namespace dbaui
54 {
55     class OTableFieldDesc : public ::vos::OReference
56     {
57     private:
58        ::std::vector< ::rtl::OUString >
59                                     m_aCriteria;
60 
61         ::rtl::OUString             m_aTableName;
62         ::rtl::OUString             m_aAliasName;       // table range
63         ::rtl::OUString             m_aFieldName;       // column
64         ::rtl::OUString             m_aFieldAlias;  // column alias
65         ::rtl::OUString             m_aFunctionName;    // enth"alt den Funktionsnamen, nur wenn m_eFunctionType != FKT_NONE gesetzt
66 
67         Window*                     m_pTabWindow;
68 
69         sal_Int32                   m_eDataType;
70         sal_Int32                   m_eFunctionType;
71         ETableFieldType             m_eFieldType;
72         EOrderDir                   m_eOrderDir;
73         sal_Int32                   m_nIndex;
74         sal_Int32                   m_nColWidth;
75         sal_uInt16                  m_nColumnId;
76         sal_Bool                    m_bGroupBy;
77         sal_Bool                    m_bVisible;
78 
79         // !!!! bitte bei Erweiterung um neue Felder auch IsEmpty mitpflegen !!!!
80 
81     public:
82         OTableFieldDesc();
83         OTableFieldDesc(const ::rtl::OUString& rTable, const ::rtl::OUString& rField );
84         OTableFieldDesc(const OTableFieldDesc& rRS);
85         ~OTableFieldDesc();
86 
87         inline sal_Bool         IsEmpty() const;
88 
89         OTableFieldDesc&        operator=( const OTableFieldDesc& _aField );
90         sal_Bool                operator==( const OTableFieldDesc& rDesc );
91 
92         sal_Bool                IsVisible() const    { return m_bVisible;}
93         sal_Bool                IsGroupBy() const    { return m_bGroupBy;}
94 
95         void                    SetVisible( sal_Bool bVis=sal_True ){ m_bVisible = bVis;}
96         void                    SetGroupBy( sal_Bool bGb=sal_False ){ m_bGroupBy = bGb;}
97         void                    SetTabWindow( Window* pWin ){ m_pTabWindow = pWin;}
98         void                    SetField( const ::rtl::OUString& rF ){ m_aFieldName = rF;}
99         void                    SetFieldAlias( const ::rtl::OUString& rF ){ m_aFieldAlias = rF;}
100         void                    SetTable( const ::rtl::OUString& rT ){ m_aTableName = rT;}
101         void                    SetAlias( const ::rtl::OUString& rT ){ m_aAliasName = rT;}
102         void                    SetFunction( const ::rtl::OUString& rT ) { m_aFunctionName = rT;}
103         void                    SetOrderDir( EOrderDir eDir )   { m_eOrderDir = eDir; }
104         void                    SetDataType( sal_Int32 eTyp )   { m_eDataType = eTyp; }
105         void                    SetFieldType( ETableFieldType eTyp )    { m_eFieldType = eTyp; }
106         void                    SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit);
107         void                    SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
108         void                    SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
109         void                    SetFunctionType( sal_Int32 eTyp )   { m_eFunctionType = eTyp; }
110         void                    SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
111 
112 
113         ::rtl::OUString         GetField()          const { return m_aFieldName;}
114         ::rtl::OUString         GetFieldAlias()     const { return m_aFieldAlias;}
115         ::rtl::OUString         GetTable()          const { return m_aTableName;}
116         ::rtl::OUString         GetAlias()          const { return m_aAliasName;}
117         ::rtl::OUString         GetFunction()       const { return m_aFunctionName;}
118         sal_Int32               GetDataType()       const { return m_eDataType; }
119         ETableFieldType         GetFieldType()      const { return m_eFieldType; }
120         EOrderDir               GetOrderDir()       const { return m_eOrderDir; }
121         ::rtl::OUString         GetCriteria( sal_uInt16 nIdx ) const;
122         sal_Int32               GetColWidth()       const { return m_nColWidth; }
123         sal_Int32               GetFieldIndex()     const { return m_nIndex; }
124         Window*                 GetTabWindow()      const { return m_pTabWindow;}
125         sal_Int32               GetFunctionType()   const { return m_eFunctionType; }
126         sal_uInt16              GetColumnId()       const { return m_nColumnId;}
127 
128         inline sal_Bool         isAggreateFunction()    const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE;  }
129         inline sal_Bool         isOtherFunction()       const { return (m_eFunctionType & FKT_OTHER)     == FKT_OTHER;      }
130         inline sal_Bool         isNumeric()             const { return (m_eFunctionType & FKT_NUMERIC)   == FKT_NUMERIC;    }
131         inline sal_Bool         isNoneFunction()        const { return  m_eFunctionType                  == FKT_NONE;       }
132         inline sal_Bool         isCondition()           const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION;  }
133         inline sal_Bool         isNumericOrAggreateFunction()   const { return isNumeric() || isAggreateFunction(); }
134 
135         sal_Bool                HasCriteria()       const
136         {
137             ::std::vector< ::rtl::OUString>::const_iterator aIter = m_aCriteria.begin();
138             ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_aCriteria.end();
139             for(;aIter != aEnd;++aIter)
140                 if(aIter->getLength())
141                     break;
142             return aIter != aEnd;
143         }
144 
145         const ::std::vector< ::rtl::OUString>&  GetCriteria() const { return m_aCriteria; }
146 
147         void Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria );
148         void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria );
149     };
150 
151     //------------------------------------------------------------------
152     inline sal_Bool OTableFieldDesc::IsEmpty()  const
153     {
154         sal_Bool bEmpty = (!m_aTableName.getLength()     &&
155                          !m_aAliasName.getLength()       &&
156                          !m_aFieldName.getLength()       &&
157                          !m_aFieldAlias.getLength()      &&
158                          !m_aFunctionName.getLength()    &&
159                          !HasCriteria());
160         return bEmpty;
161     }
162     //------------------------------------------------------------------
163     typedef ::vos::ORef< OTableFieldDesc>       OTableFieldDescRef;
164     typedef ::std::vector<OTableFieldDescRef>   OTableFields;
165 }
166 #endif //
167 
168