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 IsVisible() const88 sal_Bool IsVisible() const { return m_bVisible;} IsGroupBy() const89 sal_Bool IsGroupBy() const { return m_bGroupBy;} 90 SetVisible(sal_Bool bVis=sal_True)91 void SetVisible( sal_Bool bVis=sal_True ){ m_bVisible = bVis;} SetGroupBy(sal_Bool bGb=sal_False)92 void SetGroupBy( sal_Bool bGb=sal_False ){ m_bGroupBy = bGb;} SetTabWindow(Window * pWin)93 void SetTabWindow( Window* pWin ){ m_pTabWindow = pWin;} SetField(const::rtl::OUString & rF)94 void SetField( const ::rtl::OUString& rF ){ m_aFieldName = rF;} SetFieldAlias(const::rtl::OUString & rF)95 void SetFieldAlias( const ::rtl::OUString& rF ){ m_aFieldAlias = rF;} SetTable(const::rtl::OUString & rT)96 void SetTable( const ::rtl::OUString& rT ){ m_aTableName = rT;} SetAlias(const::rtl::OUString & rT)97 void SetAlias( const ::rtl::OUString& rT ){ m_aAliasName = rT;} SetFunction(const::rtl::OUString & rT)98 void SetFunction( const ::rtl::OUString& rT ) { m_aFunctionName = rT;} SetOrderDir(EOrderDir eDir)99 void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; } SetDataType(sal_Int32 eTyp)100 void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; } SetFieldType(ETableFieldType eTyp)101 void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; } 102 void SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit); SetColWidth(sal_Int32 nWidth)103 void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; } SetFieldIndex(sal_Int32 nFieldIndex)104 void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; } SetFunctionType(sal_Int32 eTyp)105 void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; } SetColumnId(sal_uInt16 _nColumnId)106 void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; } 107 108 GetField() const109 ::rtl::OUString GetField() const { return m_aFieldName;} GetFieldAlias() const110 ::rtl::OUString GetFieldAlias() const { return m_aFieldAlias;} GetTable() const111 ::rtl::OUString GetTable() const { return m_aTableName;} GetAlias() const112 ::rtl::OUString GetAlias() const { return m_aAliasName;} GetFunction() const113 ::rtl::OUString GetFunction() const { return m_aFunctionName;} GetDataType() const114 sal_Int32 GetDataType() const { return m_eDataType; } GetFieldType() const115 ETableFieldType GetFieldType() const { return m_eFieldType; } GetOrderDir() const116 EOrderDir GetOrderDir() const { return m_eOrderDir; } 117 ::rtl::OUString GetCriteria( sal_uInt16 nIdx ) const; GetColWidth() const118 sal_Int32 GetColWidth() const { return m_nColWidth; } GetFieldIndex() const119 sal_Int32 GetFieldIndex() const { return m_nIndex; } GetTabWindow() const120 Window* GetTabWindow() const { return m_pTabWindow;} GetFunctionType() const121 sal_Int32 GetFunctionType() const { return m_eFunctionType; } GetColumnId() const122 sal_uInt16 GetColumnId() const { return m_nColumnId;} 123 isAggreateFunction() const124 inline sal_Bool isAggreateFunction() const { return (m_eFunctionType & FKT_AGGREGATE) == FKT_AGGREGATE; } isOtherFunction() const125 inline sal_Bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; } isNumeric() const126 inline sal_Bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; } isNoneFunction() const127 inline sal_Bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; } isCondition() const128 inline sal_Bool isCondition() const { return (m_eFunctionType & FKT_CONDITION) == FKT_CONDITION; } isNumericOrAggreateFunction() const129 inline sal_Bool isNumericOrAggreateFunction() const { return isNumeric() || isAggreateFunction(); } 130 HasCriteria() const131 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 GetCriteria() const141 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 //------------------------------------------------------------------ IsEmpty() const148 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