Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / core / api / datasettings.cxx
blob732ceb11ac4f660ad5e28b4a7a231b970fc2f00f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "datasettings.hxx"
21 #include "apitools.hxx"
22 #include "dbastrings.hrc"
23 #include <osl/diagnose.h>
24 #include <comphelper/property.hxx>
25 #include <comphelper/types.hxx>
26 #include <com/sun/star/beans/PropertyAttribute.hpp>
27 #include <vcl/svapp.hxx>
28 #include <com/sun/star/awt/FontWeight.hpp>
29 #include <com/sun/star/awt/FontEmphasisMark.hpp>
30 #include <com/sun/star/awt/FontRelief.hpp>
32 #include <com/sun/star/awt/FontWidth.hpp>
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::awt;
36 using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::beans;
38 using namespace ::comphelper;
39 using namespace ::cppu;
41 namespace dbaccess
43 // ODataSettings
44 void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem)
46 if ( m_bQuery )
48 registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND,
49 &_pItem->m_sHavingClause, cppu::UnoType<decltype(_pItem->m_sHavingClause)>::get());
51 registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND,
52 &_pItem->m_sGroupBy, cppu::UnoType<decltype(_pItem->m_sGroupBy)>::get());
55 registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
56 &_pItem->m_sFilter, cppu::UnoType<decltype(_pItem->m_sFilter)>::get());
58 registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
59 &_pItem->m_sOrder, cppu::UnoType<decltype(_pItem->m_sOrder)>::get());
61 registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
62 &_pItem->m_bApplyFilter, cppu::UnoType<bool>::get());
64 registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
65 &_pItem->m_aFont, cppu::UnoType<decltype(_pItem->m_aFont)>::get());
67 registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
68 &_pItem->m_aRowHeight, ::cppu::UnoType<sal_Int32>::get());
70 registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
71 &_pItem->m_aTextColor, ::cppu::UnoType<sal_Int32>::get());
73 registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
74 &_pItem->m_aTextLineColor, ::cppu::UnoType<sal_Int32>::get());
76 registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
77 &_pItem->m_nFontEmphasis, cppu::UnoType<decltype(_pItem->m_nFontEmphasis)>::get());
79 registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, cppu::UnoType<decltype(_pItem->m_nFontRelief)>::get());
81 registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, cppu::UnoType<decltype(_pItem->m_aFont.Name)>::get());
82 registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, cppu::UnoType<decltype(_pItem->m_aFont.Height)>::get());
83 registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, cppu::UnoType<decltype(_pItem->m_aFont.Width)>::get());
84 registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, cppu::UnoType<decltype(_pItem->m_aFont.StyleName)>::get());
85 registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, cppu::UnoType<decltype(_pItem->m_aFont.Family)>::get());
86 registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, cppu::UnoType<decltype(_pItem->m_aFont.CharSet)>::get());
87 registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, cppu::UnoType<decltype(_pItem->m_aFont.Pitch)>::get());
88 registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, cppu::UnoType<decltype(_pItem->m_aFont.CharacterWidth)>::get());
89 registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, cppu::UnoType<decltype(_pItem->m_aFont.Weight)>::get());
90 registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, cppu::UnoType<decltype(_pItem->m_aFont.Slant)>::get());
91 registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, cppu::UnoType<decltype(_pItem->m_aFont.Underline)>::get());
92 registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, cppu::UnoType<decltype(_pItem->m_aFont.Strikeout)>::get());
93 registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, cppu::UnoType<decltype(_pItem->m_aFont.Orientation)>::get());
94 registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, cppu::UnoType<decltype(_pItem->m_aFont.Kerning)>::get());
95 registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, cppu::UnoType<decltype(_pItem->m_aFont.WordLineMode)>::get());
96 registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, cppu::UnoType<decltype(_pItem->m_aFont.Type)>::get());
99 ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,bool _bQuery)
100 :OPropertyStateContainer(_rBHelper)
101 ,ODataSettings_Base()
102 ,m_bQuery(_bQuery)
106 ODataSettings_Base::ODataSettings_Base()
107 :m_bApplyFilter(false)
108 ,m_aFont(::comphelper::getDefaultFont())
109 ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE)
110 ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE)
114 ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource)
115 :m_sFilter( _rSource.m_sFilter )
116 ,m_sHavingClause( _rSource.m_sHavingClause )
117 ,m_sGroupBy( _rSource.m_sGroupBy )
118 ,m_sOrder( _rSource.m_sOrder )
119 ,m_bApplyFilter( _rSource.m_bApplyFilter )
120 ,m_aFont( _rSource.m_aFont )
121 ,m_aRowHeight( _rSource.m_aRowHeight )
122 ,m_aTextColor( _rSource.m_aTextColor )
123 ,m_aTextLineColor( _rSource.m_aTextLineColor )
124 ,m_nFontEmphasis( _rSource.m_nFontEmphasis )
125 ,m_nFontRelief( _rSource.m_nFontRelief )
129 ODataSettings_Base::~ODataSettings_Base()
133 void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
135 static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont();
136 switch( _nHandle )
138 case PROPERTY_ID_HAVING_CLAUSE:
139 case PROPERTY_ID_GROUP_BY:
140 case PROPERTY_ID_FILTER:
141 case PROPERTY_ID_ORDER:
142 _rDefault <<= OUString();
143 break;
144 case PROPERTY_ID_FONT:
145 _rDefault <<= ::comphelper::getDefaultFont();
146 break;
147 case PROPERTY_ID_APPLYFILTER:
148 _rDefault <<= sal_False;
149 break;
150 case PROPERTY_ID_TEXTRELIEF:
151 _rDefault <<= ::com::sun::star::awt::FontRelief::NONE;
152 break;
153 case PROPERTY_ID_TEXTEMPHASIS:
154 _rDefault <<= ::com::sun::star::awt::FontEmphasisMark::NONE;
155 break;
156 case PROPERTY_ID_FONTNAME:
157 _rDefault <<= aFD.Name;
158 break;
159 case PROPERTY_ID_FONTHEIGHT:
160 _rDefault <<= aFD.Height;
161 break;
162 case PROPERTY_ID_FONTWIDTH:
163 _rDefault <<= aFD.Width;
164 break;
165 case PROPERTY_ID_FONTSTYLENAME:
166 _rDefault <<= aFD.StyleName;
167 break;
168 case PROPERTY_ID_FONTFAMILY:
169 _rDefault <<= aFD.Family;
170 break;
171 case PROPERTY_ID_FONTCHARSET:
172 _rDefault <<= aFD.CharSet;
173 break;
174 case PROPERTY_ID_FONTPITCH:
175 _rDefault <<= aFD.Pitch;
176 break;
177 case PROPERTY_ID_FONTCHARWIDTH:
178 _rDefault <<= aFD.CharacterWidth;
179 break;
180 case PROPERTY_ID_FONTWEIGHT:
181 _rDefault <<= aFD.Weight;
182 break;
183 case PROPERTY_ID_FONTSLANT:
184 _rDefault <<= aFD.Slant;
185 break;
186 case PROPERTY_ID_FONTUNDERLINE:
187 _rDefault <<= aFD.Underline;
188 break;
189 case PROPERTY_ID_FONTSTRIKEOUT:
190 _rDefault <<= aFD.Strikeout;
191 break;
192 case PROPERTY_ID_FONTORIENTATION:
193 _rDefault <<= aFD.Orientation;
194 break;
195 case PROPERTY_ID_FONTKERNING:
196 _rDefault <<= aFD.Kerning;
197 break;
198 case PROPERTY_ID_FONTWORDLINEMODE:
199 _rDefault <<= aFD.WordLineMode;
200 break;
201 case PROPERTY_ID_FONTTYPE:
202 _rDefault <<= aFD.Type;
203 break;
207 } // namespace dbaccess
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */