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