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