LibreOffice Module dbaccess (master) 1
TableFieldDescription.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
21#include <vector>
22
23#include "QEnumTypes.hxx"
24#include <rtl/ustring.hxx>
25#include <com/sun/star/beans/PropertyValue.hpp>
26#include <rtl/ref.hxx>
27#include <vcl/vclptr.hxx>
28#include <vcl/window.hxx>
29
31
32namespace comphelper
33{
34 class NamedValueCollection;
35}
36
37namespace vcl { class Window; }
38
39namespace dbaui
40{
42 {
43 private:
44 std::vector< OUString >
46
47 OUString m_aTableName;
48 OUString m_aAliasName;
49 OUString m_aFieldName;
50 OUString m_aFieldAlias;
52
54
55 sal_Int32 m_eDataType;
56 sal_Int32 m_eFunctionType;
59 sal_Int32 m_nIndex;
60 sal_Int32 m_nColWidth;
61 sal_uInt16 m_nColumnId;
64
65 // when adding new fields, please take care of IsEmpty!
66
67 public:
69 OTableFieldDesc(const OUString& rTable, const OUString& rField );
71 virtual ~OTableFieldDesc() override;
72
73 inline bool IsEmpty() const;
74
75 OTableFieldDesc& operator=( const OTableFieldDesc& _aField );
76
77 bool IsVisible() const { return m_bVisible;}
78 bool IsGroupBy() const { return m_bGroupBy;}
79
80 void SetVisible( bool bVis=true ) { m_bVisible = bVis; }
81 void SetGroupBy( bool bGb ) { m_bGroupBy = bGb; }
82 void SetTabWindow( vcl::Window* pWin ){ m_pTabWindow = pWin; }
83 void SetField( const OUString& rF ) { m_aFieldName = rF; }
84 void SetFieldAlias( const OUString& rF ) { m_aFieldAlias = rF; }
85 void SetTable( const OUString& rT ) { m_aTableName = rT; }
86 void SetAlias( const OUString& rT ) { m_aAliasName = rT; }
87 void SetFunction( const OUString& rT ) { m_aFunctionName = rT; }
88 void SetOrderDir( EOrderDir eDir ) { m_eOrderDir = eDir; }
89 void SetDataType( sal_Int32 eTyp ) { m_eDataType = eTyp; }
90 void SetFieldType( ETableFieldType eTyp ) { m_eFieldType = eTyp; }
91 void SetCriteria( sal_uInt16 nIdx, const OUString& rCrit );
92 void SetColWidth( sal_Int32 nWidth ) { m_nColWidth = nWidth; }
93 void SetFieldIndex( sal_Int32 nFieldIndex ) { m_nIndex = nFieldIndex; }
94 void SetFunctionType( sal_Int32 eTyp ) { m_eFunctionType = eTyp; }
95 void SetColumnId(sal_uInt16 _nColumnId) { m_nColumnId = _nColumnId; }
96
97 const OUString& GetField() const { return m_aFieldName;}
98 const OUString& GetFieldAlias() const { return m_aFieldAlias;}
99 const OUString& GetTable() const { return m_aTableName;}
100 const OUString& GetAlias() const { return m_aAliasName;}
101 const OUString& GetFunction() const { return m_aFunctionName;}
102 sal_Int32 GetDataType() const { return m_eDataType; }
105 OUString GetCriteria( sal_uInt16 nIdx ) const;
106 sal_Int32 GetColWidth() const { return m_nColWidth; }
107 sal_Int32 GetFieldIndex() const { return m_nIndex; }
109 sal_Int32 GetFunctionType() const { return m_eFunctionType; }
110 sal_uInt16 GetColumnId() const { return m_nColumnId;}
111
113 bool isOtherFunction() const { return (m_eFunctionType & FKT_OTHER) == FKT_OTHER; }
114 bool isNumeric() const { return (m_eFunctionType & FKT_NUMERIC) == FKT_NUMERIC; }
115 bool isNoneFunction() const { return m_eFunctionType == FKT_NONE; }
118
119 bool HasCriteria() const
120 {
121 for (auto const& criteria : m_aCriteria)
122 {
123 if(!criteria.isEmpty())
124 return true;
125 }
126 return false;
127 }
128
129 const std::vector< OUString>& GetCriteria() const { return m_aCriteria; }
130
131 void Load( const css::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria );
132 void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria );
133 };
134
135 inline bool OTableFieldDesc::IsEmpty() const
136 {
137 bool bEmpty = (m_aTableName.isEmpty() &&
138 m_aAliasName.isEmpty() &&
139 m_aFieldName.isEmpty() &&
140 m_aFieldAlias.isEmpty() &&
141 m_aFunctionName.isEmpty() &&
142 !HasCriteria());
143 return bEmpty;
144 }
145
146 typedef ::rtl::Reference< OTableFieldDesc> OTableFieldDescRef;
147 typedef std::vector<OTableFieldDescRef> OTableFields;
148}
149
150/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAlias(const OUString &rT)
void SetColumnId(sal_uInt16 _nColumnId)
const std::vector< OUString > & GetCriteria() const
std::vector< OUString > m_aCriteria
const OUString & GetAlias() const
void SetOrderDir(EOrderDir eDir)
vcl::Window * GetTabWindow() const
void SetColWidth(sal_Int32 nWidth)
void SetFieldType(ETableFieldType eTyp)
void Save(::comphelper::NamedValueCollection &o_rSettings, const bool i_bIncludingCriteria)
OUString m_aFieldAlias
column alias
void SetVisible(bool bVis=true)
void SetCriteria(sal_uInt16 nIdx, const OUString &rCrit)
const OUString & GetFieldAlias() const
void SetTabWindow(vcl::Window *pWin)
void SetFunctionType(sal_Int32 eTyp)
virtual ~OTableFieldDesc() override
void Load(const css::beans::PropertyValue &i_rSettings, const bool i_bIncludingCriteria)
VclPtr< vcl::Window > m_pTabWindow
void SetDataType(sal_Int32 eTyp)
OTableFieldDesc & operator=(const OTableFieldDesc &_aField)
OUString m_aFunctionName
contains the function name (only if m_eFunctionType != FKT_NONE)
const OUString & GetFunction() const
ETableFieldType GetFieldType() const
const OUString & GetTable() const
void SetFieldAlias(const OUString &rF)
void SetTable(const OUString &rT)
OUString m_aAliasName
table range
void SetField(const OUString &rF)
void SetFieldIndex(sal_Int32 nFieldIndex)
void SetFunction(const OUString &rT)
const OUString & GetField() const
::rtl::Reference< OTableFieldDesc > OTableFieldDescRef
@ FKT_OTHER
Definition: QEnumTypes.hxx:33
@ FKT_NONE
Definition: QEnumTypes.hxx:32
@ FKT_NUMERIC
Definition: QEnumTypes.hxx:36
@ FKT_CONDITION
Definition: QEnumTypes.hxx:35
@ FKT_AGGREGATE
Definition: QEnumTypes.hxx:34
ETableFieldType
Definition: QEnumTypes.hxx:48
std::vector< OTableFieldDescRef > OTableFields