update dev300-m58
[ooovba.git] / dbaccess / source / core / api / datasettings.cxx
blobae079d30961d744c492361f056c340c4ec010ba6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: datasettings.cxx,v $
10 * $Revision: 1.27 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
34 #ifndef _DBA_CORE_DATASETTINGS_HXX_
35 #include "datasettings.hxx"
36 #endif
37 #ifndef _DBASHARED_APITOOLS_HXX_
38 #include "apitools.hxx"
39 #endif
40 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC
41 #include "dbastrings.hrc"
42 #endif
43 #ifndef _OSL_DIAGNOSE_H_
44 #include <osl/diagnose.h>
45 #endif
46 #ifndef _COMPHELPER_PROPERTY_HXX_
47 #include <comphelper/property.hxx>
48 #endif
49 #ifndef _COMPHELPER_TYPES_HXX_
50 #include <comphelper/types.hxx>
51 #endif
52 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
53 #include <com/sun/star/beans/PropertyAttribute.hpp>
54 #endif
55 #ifndef _SV_SVAPP_HXX
56 #include <vcl/svapp.hxx>
57 #endif
58 #ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_
59 #include <com/sun/star/awt/FontWeight.hpp>
60 #endif
61 #ifndef _COM_SUN_STAR_AWT_FONTEMPHASISMARK_HPP_
62 #include <com/sun/star/awt/FontEmphasisMark.hpp>
63 #endif
64 #ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_
65 #include <com/sun/star/awt/FontRelief.hpp>
66 #endif
68 #ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_
69 #include <com/sun/star/awt/FontWidth.hpp>
70 #endif
72 using namespace ::com::sun::star::uno;
73 using namespace ::com::sun::star::awt;
74 using namespace ::com::sun::star::lang;
75 using namespace ::com::sun::star::beans;
76 using namespace ::comphelper;
77 using namespace ::cppu;
79 //........................................................................
80 namespace dbaccess
82 //==========================================================================
83 //= ODataSettings
84 //==========================================================================
85 //--------------------------------------------------------------------------
86 void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem)
88 if ( m_bQuery )
90 registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND,
91 &_pItem->m_sHavingClause, ::getCppuType(&_pItem->m_sHavingClause));
93 registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND,
94 &_pItem->m_sGroupBy, ::getCppuType(&_pItem->m_sGroupBy));
97 registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
98 &_pItem->m_sFilter, ::getCppuType(&_pItem->m_sFilter));
100 registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
101 &_pItem->m_sOrder, ::getCppuType(&_pItem->m_sOrder));
103 registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
104 &_pItem->m_bApplyFilter, ::getBooleanCppuType());
106 registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
107 &_pItem->m_aFont, ::getCppuType(&_pItem->m_aFont));
109 registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
110 &_pItem->m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
112 registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
113 &_pItem->m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
115 registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
116 &_pItem->m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
118 registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
119 &_pItem->m_nFontEmphasis, ::getCppuType(&_pItem->m_nFontEmphasis));
121 registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, ::getCppuType(&_pItem->m_nFontRelief));
123 registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, ::getCppuType(&_pItem->m_aFont.Name));
124 registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, ::getCppuType(&_pItem->m_aFont.Height));
125 registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, ::getCppuType(&_pItem->m_aFont.Width));
126 registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, ::getCppuType(&_pItem->m_aFont.StyleName));
127 registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, ::getCppuType(&_pItem->m_aFont.Family));
128 registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, ::getCppuType(&_pItem->m_aFont.CharSet));
129 registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, ::getCppuType(&_pItem->m_aFont.Pitch));
130 registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, ::getCppuType(&_pItem->m_aFont.CharacterWidth));
131 registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, ::getCppuType(&_pItem->m_aFont.Weight));
132 registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, ::getCppuType(&_pItem->m_aFont.Slant));
133 registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, ::getCppuType(&_pItem->m_aFont.Underline));
134 registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, ::getCppuType(&_pItem->m_aFont.Strikeout));
135 registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, ::getCppuType(&_pItem->m_aFont.Orientation));
136 registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, ::getCppuType(&_pItem->m_aFont.Kerning));
137 registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, ::getCppuType(&_pItem->m_aFont.WordLineMode));
138 registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, ::getCppuType(&_pItem->m_aFont.Type));
141 //--------------------------------------------------------------------------
142 ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,sal_Bool _bQuery)
143 :OPropertyStateContainer(_rBHelper)
144 ,ODataSettings_Base()
145 ,m_bQuery(_bQuery)
149 //--------------------------------------------------------------------------
150 ODataSettings_Base::ODataSettings_Base()
151 :m_bApplyFilter(sal_False)
152 ,m_aFont(::comphelper::getDefaultFont())
153 ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE)
154 ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE)
158 //--------------------------------------------------------------------------
159 ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource)
161 m_sFilter = _rSource.m_sFilter;
162 m_sHavingClause = _rSource.m_sHavingClause;
163 m_sGroupBy = _rSource.m_sGroupBy;
164 m_sOrder = _rSource.m_sOrder;
165 m_bApplyFilter = _rSource.m_bApplyFilter;
166 m_aFont = _rSource.m_aFont;
167 m_aRowHeight = _rSource.m_aRowHeight;
168 m_aTextColor = _rSource.m_aTextColor;
169 m_aTextLineColor= _rSource.m_aTextLineColor;
170 m_nFontEmphasis = _rSource.m_nFontEmphasis;
171 m_nFontRelief = _rSource.m_nFontRelief;
173 // -----------------------------------------------------------------------------
174 void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
176 static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont();
177 switch( _nHandle )
179 case PROPERTY_ID_HAVING_CLAUSE:
180 case PROPERTY_ID_GROUP_BY:
181 case PROPERTY_ID_FILTER:
182 case PROPERTY_ID_ORDER:
183 _rDefault <<= ::rtl::OUString();
184 break;
185 case PROPERTY_ID_FONT:
186 _rDefault <<= ::comphelper::getDefaultFont();
187 break;
188 case PROPERTY_ID_APPLYFILTER:
189 _rDefault <<= sal_False;
190 break;
191 case PROPERTY_ID_TEXTRELIEF:
192 _rDefault <<= ::com::sun::star::awt::FontRelief::NONE;
193 break;
194 case PROPERTY_ID_TEXTEMPHASIS:
195 _rDefault <<= ::com::sun::star::awt::FontEmphasisMark::NONE;
196 break;
197 case PROPERTY_ID_FONTNAME:
198 _rDefault <<= aFD.Name;
199 break;
200 case PROPERTY_ID_FONTHEIGHT:
201 _rDefault <<= aFD.Height;
202 break;
203 case PROPERTY_ID_FONTWIDTH:
204 _rDefault <<= aFD.Width;
205 break;
206 case PROPERTY_ID_FONTSTYLENAME:
207 _rDefault <<= aFD.StyleName;
208 break;
209 case PROPERTY_ID_FONTFAMILY:
210 _rDefault <<= aFD.Family;
211 break;
212 case PROPERTY_ID_FONTCHARSET:
213 _rDefault <<= aFD.CharSet;
214 break;
215 case PROPERTY_ID_FONTPITCH:
216 _rDefault <<= aFD.Pitch;
217 break;
218 case PROPERTY_ID_FONTCHARWIDTH:
219 _rDefault <<= aFD.CharacterWidth;
220 break;
221 case PROPERTY_ID_FONTWEIGHT:
222 _rDefault <<= aFD.Weight;
223 break;
224 case PROPERTY_ID_FONTSLANT:
225 _rDefault <<= aFD.Slant;
226 break;
227 case PROPERTY_ID_FONTUNDERLINE:
228 _rDefault <<= aFD.Underline;
229 break;
230 case PROPERTY_ID_FONTSTRIKEOUT:
231 _rDefault <<= aFD.Strikeout;
232 break;
233 case PROPERTY_ID_FONTORIENTATION:
234 _rDefault <<= aFD.Orientation;
235 break;
236 case PROPERTY_ID_FONTKERNING:
237 _rDefault <<= aFD.Kerning;
238 break;
239 case PROPERTY_ID_FONTWORDLINEMODE:
240 _rDefault <<= aFD.WordLineMode;
241 break;
242 case PROPERTY_ID_FONTTYPE:
243 _rDefault <<= aFD.Type;
244 break;
247 //........................................................................
248 } // namespace dbaccess
249 //........................................................................