Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / dbaccess / source / core / api / datasettings.cxx
blob522da407334a97b47e19662902e297b386515afa
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 .
21 #include "datasettings.hxx"
22 #include "apitools.hxx"
23 #include "dbastrings.hrc"
24 #include <osl/diagnose.h>
25 #include <comphelper/property.hxx>
26 #include <comphelper/types.hxx>
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <vcl/svapp.hxx>
29 #include <com/sun/star/awt/FontWeight.hpp>
30 #include <com/sun/star/awt/FontEmphasisMark.hpp>
31 #include <com/sun/star/awt/FontRelief.hpp>
33 #include <com/sun/star/awt/FontWidth.hpp>
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::awt;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::beans;
40 using namespace ::comphelper;
41 using namespace ::cppu;
43 namespace dbaccess
45 //==========================================================================
46 //= ODataSettings
47 //==========================================================================
48 void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem)
50 if ( m_bQuery )
52 registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND,
53 &_pItem->m_sHavingClause, ::getCppuType(&_pItem->m_sHavingClause));
55 registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND,
56 &_pItem->m_sGroupBy, ::getCppuType(&_pItem->m_sGroupBy));
59 registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
60 &_pItem->m_sFilter, ::getCppuType(&_pItem->m_sFilter));
62 registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
63 &_pItem->m_sOrder, ::getCppuType(&_pItem->m_sOrder));
65 registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
66 &_pItem->m_bApplyFilter, ::getBooleanCppuType());
68 registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
69 &_pItem->m_aFont, ::getCppuType(&_pItem->m_aFont));
71 registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
72 &_pItem->m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
74 registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
75 &_pItem->m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
77 registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
78 &_pItem->m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
80 registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
81 &_pItem->m_nFontEmphasis, ::getCppuType(&_pItem->m_nFontEmphasis));
83 registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, ::getCppuType(&_pItem->m_nFontRelief));
85 registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, ::getCppuType(&_pItem->m_aFont.Name));
86 registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, ::getCppuType(&_pItem->m_aFont.Height));
87 registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, ::getCppuType(&_pItem->m_aFont.Width));
88 registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, ::getCppuType(&_pItem->m_aFont.StyleName));
89 registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, ::getCppuType(&_pItem->m_aFont.Family));
90 registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, ::getCppuType(&_pItem->m_aFont.CharSet));
91 registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, ::getCppuType(&_pItem->m_aFont.Pitch));
92 registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, ::getCppuType(&_pItem->m_aFont.CharacterWidth));
93 registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, ::getCppuType(&_pItem->m_aFont.Weight));
94 registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, ::getCppuType(&_pItem->m_aFont.Slant));
95 registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, ::getCppuType(&_pItem->m_aFont.Underline));
96 registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, ::getCppuType(&_pItem->m_aFont.Strikeout));
97 registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, ::getCppuType(&_pItem->m_aFont.Orientation));
98 registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, ::getCppuType(&_pItem->m_aFont.Kerning));
99 registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, ::getCppuType(&_pItem->m_aFont.WordLineMode));
100 registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, ::getCppuType(&_pItem->m_aFont.Type));
103 ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,sal_Bool _bQuery)
104 :OPropertyStateContainer(_rBHelper)
105 ,ODataSettings_Base()
106 ,m_bQuery(_bQuery)
110 ODataSettings_Base::ODataSettings_Base()
111 :m_bApplyFilter(sal_False)
112 ,m_aFont(::comphelper::getDefaultFont())
113 ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE)
114 ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE)
118 ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource)
119 :m_sFilter( _rSource.m_sFilter )
120 ,m_sHavingClause( _rSource.m_sHavingClause )
121 ,m_sGroupBy( _rSource.m_sGroupBy )
122 ,m_sOrder( _rSource.m_sOrder )
123 ,m_bApplyFilter( _rSource.m_bApplyFilter )
124 ,m_aFont( _rSource.m_aFont )
125 ,m_aRowHeight( _rSource.m_aRowHeight )
126 ,m_aTextColor( _rSource.m_aTextColor )
127 ,m_aTextLineColor( _rSource.m_aTextLineColor )
128 ,m_nFontEmphasis( _rSource.m_nFontEmphasis )
129 ,m_nFontRelief( _rSource.m_nFontRelief )
133 ODataSettings_Base::~ODataSettings_Base()
137 void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
139 static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont();
140 switch( _nHandle )
142 case PROPERTY_ID_HAVING_CLAUSE:
143 case PROPERTY_ID_GROUP_BY:
144 case PROPERTY_ID_FILTER:
145 case PROPERTY_ID_ORDER:
146 _rDefault <<= ::rtl::OUString();
147 break;
148 case PROPERTY_ID_FONT:
149 _rDefault <<= ::comphelper::getDefaultFont();
150 break;
151 case PROPERTY_ID_APPLYFILTER:
152 _rDefault <<= sal_False;
153 break;
154 case PROPERTY_ID_TEXTRELIEF:
155 _rDefault <<= ::com::sun::star::awt::FontRelief::NONE;
156 break;
157 case PROPERTY_ID_TEXTEMPHASIS:
158 _rDefault <<= ::com::sun::star::awt::FontEmphasisMark::NONE;
159 break;
160 case PROPERTY_ID_FONTNAME:
161 _rDefault <<= aFD.Name;
162 break;
163 case PROPERTY_ID_FONTHEIGHT:
164 _rDefault <<= aFD.Height;
165 break;
166 case PROPERTY_ID_FONTWIDTH:
167 _rDefault <<= aFD.Width;
168 break;
169 case PROPERTY_ID_FONTSTYLENAME:
170 _rDefault <<= aFD.StyleName;
171 break;
172 case PROPERTY_ID_FONTFAMILY:
173 _rDefault <<= aFD.Family;
174 break;
175 case PROPERTY_ID_FONTCHARSET:
176 _rDefault <<= aFD.CharSet;
177 break;
178 case PROPERTY_ID_FONTPITCH:
179 _rDefault <<= aFD.Pitch;
180 break;
181 case PROPERTY_ID_FONTCHARWIDTH:
182 _rDefault <<= aFD.CharacterWidth;
183 break;
184 case PROPERTY_ID_FONTWEIGHT:
185 _rDefault <<= aFD.Weight;
186 break;
187 case PROPERTY_ID_FONTSLANT:
188 _rDefault <<= aFD.Slant;
189 break;
190 case PROPERTY_ID_FONTUNDERLINE:
191 _rDefault <<= aFD.Underline;
192 break;
193 case PROPERTY_ID_FONTSTRIKEOUT:
194 _rDefault <<= aFD.Strikeout;
195 break;
196 case PROPERTY_ID_FONTORIENTATION:
197 _rDefault <<= aFD.Orientation;
198 break;
199 case PROPERTY_ID_FONTKERNING:
200 _rDefault <<= aFD.Kerning;
201 break;
202 case PROPERTY_ID_FONTWORDLINEMODE:
203 _rDefault <<= aFD.WordLineMode;
204 break;
205 case PROPERTY_ID_FONTTYPE:
206 _rDefault <<= aFD.Type;
207 break;
211 } // namespace dbaccess
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */