1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir #ifndef DBAUI_TABLEFIELDDESC_HXX 24cdf0e10cSrcweir #define DBAUI_TABLEFIELDDESC_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef INCLUDED_VECTOR 27cdf0e10cSrcweir #define INCLUDED_VECTOR 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef DBAUI_ENUMTYPES_HXX 31cdf0e10cSrcweir #include "QEnumTypes.hxx" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX_ 34cdf0e10cSrcweir #include <rtl/ustring.hxx> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ 37cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _VOS_REF_HXX_ 40cdf0e10cSrcweir #include <vos/ref.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir 43cdf0e10cSrcweir namespace comphelper 44cdf0e10cSrcweir { 45cdf0e10cSrcweir class NamedValueCollection; 46cdf0e10cSrcweir } 47cdf0e10cSrcweir 48cdf0e10cSrcweir class Window; 49cdf0e10cSrcweir namespace dbaui 50cdf0e10cSrcweir { 51cdf0e10cSrcweir class OTableFieldDesc : public ::vos::OReference 52cdf0e10cSrcweir { 53cdf0e10cSrcweir private: 54cdf0e10cSrcweir ::std::vector< ::rtl::OUString > 55cdf0e10cSrcweir m_aCriteria; 56cdf0e10cSrcweir 57cdf0e10cSrcweir ::rtl::OUString m_aTableName; 58cdf0e10cSrcweir ::rtl::OUString m_aAliasName; // table range 59cdf0e10cSrcweir ::rtl::OUString m_aFieldName; // column 60cdf0e10cSrcweir ::rtl::OUString m_aFieldAlias; // column alias 61cdf0e10cSrcweir ::rtl::OUString m_aFunctionName; // enth"alt den Funktionsnamen, nur wenn m_eFunctionType != FKT_NONE gesetzt 62cdf0e10cSrcweir 63cdf0e10cSrcweir Window* m_pTabWindow; 64cdf0e10cSrcweir 65cdf0e10cSrcweir sal_Int32 m_eDataType; 66cdf0e10cSrcweir sal_Int32 m_eFunctionType; 67cdf0e10cSrcweir ETableFieldType m_eFieldType; 68cdf0e10cSrcweir EOrderDir m_eOrderDir; 69cdf0e10cSrcweir sal_Int32 m_nIndex; 70cdf0e10cSrcweir sal_Int32 m_nColWidth; 71cdf0e10cSrcweir sal_uInt16 m_nColumnId; 72cdf0e10cSrcweir sal_Bool m_bGroupBy; 73cdf0e10cSrcweir sal_Bool m_bVisible; 74cdf0e10cSrcweir 75cdf0e10cSrcweir // !!!! bitte bei Erweiterung um neue Felder auch IsEmpty mitpflegen !!!! 76cdf0e10cSrcweir 77cdf0e10cSrcweir public: 78cdf0e10cSrcweir OTableFieldDesc(); 79cdf0e10cSrcweir OTableFieldDesc(const ::rtl::OUString& rTable, const ::rtl::OUString& rField ); 80cdf0e10cSrcweir OTableFieldDesc(const OTableFieldDesc& rRS); 81cdf0e10cSrcweir ~OTableFieldDesc(); 82cdf0e10cSrcweir 83cdf0e10cSrcweir inline sal_Bool IsEmpty() const; 84cdf0e10cSrcweir 85cdf0e10cSrcweir OTableFieldDesc& operator=( const OTableFieldDesc& _aField ); 86cdf0e10cSrcweir sal_Bool operator==( const OTableFieldDesc& rDesc ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir sal_Bool IsVisible() const { return m_bVisible;} 89cdf0e10cSrcweir sal_Bool IsGroupBy() const { return m_bGroupBy;} 90cdf0e10cSrcweir 91cdf0e10cSrcweir void SetVisible( sal_Bool bVis=sal_True ){ m_bVisible = bVis;} 92cdf0e10cSrcweir void SetGroupBy( sal_Bool bGb=sal_False ){ m_bGroupBy = bGb;} 93cdf0e10cSrcweir void SetTabWindow( Window* pWin ){ m_pTabWindow = pWin;} 94cdf0e10cSrcweir void SetField( const ::rtl::OUString& rF ){ m_aFieldName = rF;} 95cdf0e10cSrcweir void SetFieldAlias( const ::rtl::OUString& rF ){ m_aFieldAlias = rF;} 96cdf0e10cSrcweir void SetTable( const ::rtl::OUString& rT ){ m_aTableName = rT;} 97cdf0e10cSrcweir void SetAlias( const ::rtl::OUString& rT ){ m_aAliasName = rT;} 98cdf0e10cSrcweir void SetFunction( const ::rtl::OUString& rT ) { m_aFunctionName = rT;} 99cdf0e10cSrcweir void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; } 100cdf0e10cSrcweir void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; } 101cdf0e10cSrcweir void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; } 102cdf0e10cSrcweir void SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit); 103cdf0e10cSrcweir void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; } 104cdf0e10cSrcweir void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; } 105cdf0e10cSrcweir void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; } 106cdf0e10cSrcweir void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; } 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir ::rtl::OUString GetField() const { return m_aFieldName;} 110cdf0e10cSrcweir ::rtl::OUString GetFieldAlias() const { return m_aFieldAlias;} 111cdf0e10cSrcweir ::rtl::OUString GetTable() const { return m_aTableName;} 112cdf0e10cSrcweir ::rtl::OUString GetAlias() const { return m_aAliasName;} 113cdf0e10cSrcweir ::rtl::OUString GetFunction() const { return m_aFunctionName;} 114cdf0e10cSrcweir sal_Int32 GetDataType() const { return m_eDataType; } 115cdf0e10cSrcweir ETableFieldType GetFieldType() const { return m_eFieldType; } 116cdf0e10cSrcweir EOrderDir GetOrderDir() const { return m_eOrderDir; } 117cdf0e10cSrcweir ::rtl::OUString GetCriteria( sal_uInt16 nIdx ) const; 118cdf0e10cSrcweir sal_Int32 GetColWidth() const { return m_nColWidth; } 119cdf0e10cSrcweir sal_Int32 GetFieldIndex() const { return m_nIndex; } 120cdf0e10cSrcweir Window* GetTabWindow() const { return m_pTabWindow;} 121cdf0e10cSrcweir sal_Int32 GetFunctionType() const { return m_eFunctionType; } 122cdf0e10cSrcweir sal_uInt16 GetColumnId() const { return m_nColumnId;} 123cdf0e10cSrcweir 124cdf0e10cSrcweir inline sal_Bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; } 125cdf0e10cSrcweir inline sal_Bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; } 126cdf0e10cSrcweir inline sal_Bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; } 127cdf0e10cSrcweir inline sal_Bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; } 128cdf0e10cSrcweir inline sal_Bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; } 129cdf0e10cSrcweir inline sal_Bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); } 130cdf0e10cSrcweir 131cdf0e10cSrcweir sal_Bool HasCriteria() const 132cdf0e10cSrcweir { 133cdf0e10cSrcweir ::std::vector< ::rtl::OUString>::const_iterator aIter = m_aCriteria.begin(); 134cdf0e10cSrcweir ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_aCriteria.end(); 135cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 136cdf0e10cSrcweir if(aIter->getLength()) 137cdf0e10cSrcweir break; 138cdf0e10cSrcweir return aIter != aEnd; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_aCriteria; } 142cdf0e10cSrcweir 143cdf0e10cSrcweir void Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria ); 144cdf0e10cSrcweir void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria ); 145cdf0e10cSrcweir }; 146cdf0e10cSrcweir 147cdf0e10cSrcweir //------------------------------------------------------------------ 148cdf0e10cSrcweir inline sal_Bool OTableFieldDesc::IsEmpty() const 149cdf0e10cSrcweir { 150cdf0e10cSrcweir sal_Bool bEmpty = (!m_aTableName.getLength() && 151cdf0e10cSrcweir !m_aAliasName.getLength() && 152cdf0e10cSrcweir !m_aFieldName.getLength() && 153cdf0e10cSrcweir !m_aFieldAlias.getLength() && 154cdf0e10cSrcweir !m_aFunctionName.getLength() && 155cdf0e10cSrcweir !HasCriteria()); 156cdf0e10cSrcweir return bEmpty; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir //------------------------------------------------------------------ 159cdf0e10cSrcweir typedef ::vos::ORef< OTableFieldDesc> OTableFieldDescRef; 160cdf0e10cSrcweir typedef ::std::vector<OTableFieldDescRef> OTableFields; 161cdf0e10cSrcweir } 162cdf0e10cSrcweir #endif // 163cdf0e10cSrcweir 164