Line data Source code
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 :
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>
31 :
32 : #include <com/sun/star/awt/FontWidth.hpp>
33 :
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;
40 :
41 : namespace dbaccess
42 : {
43 : // ODataSettings
44 0 : void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem)
45 : {
46 0 : if ( m_bQuery )
47 : {
48 : registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND,
49 0 : &_pItem->m_sHavingClause, ::getCppuType(&_pItem->m_sHavingClause));
50 :
51 : registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND,
52 0 : &_pItem->m_sGroupBy, ::getCppuType(&_pItem->m_sGroupBy));
53 : }
54 :
55 : registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND,
56 0 : &_pItem->m_sFilter, ::getCppuType(&_pItem->m_sFilter));
57 :
58 : registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND,
59 0 : &_pItem->m_sOrder, ::getCppuType(&_pItem->m_sOrder));
60 :
61 : registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND,
62 0 : &_pItem->m_bApplyFilter, ::getBooleanCppuType());
63 :
64 : registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND,
65 0 : &_pItem->m_aFont, ::getCppuType(&_pItem->m_aFont));
66 :
67 : registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
68 0 : &_pItem->m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL)));
69 :
70 : registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
71 0 : &_pItem->m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
72 :
73 : registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID,
74 0 : &_pItem->m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL)));
75 :
76 : registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND,
77 0 : &_pItem->m_nFontEmphasis, ::getCppuType(&_pItem->m_nFontEmphasis));
78 :
79 0 : registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, ::getCppuType(&_pItem->m_nFontRelief));
80 :
81 0 : registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, ::getCppuType(&_pItem->m_aFont.Name));
82 0 : registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, ::getCppuType(&_pItem->m_aFont.Height));
83 0 : registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, ::getCppuType(&_pItem->m_aFont.Width));
84 0 : registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, ::getCppuType(&_pItem->m_aFont.StyleName));
85 0 : registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, ::getCppuType(&_pItem->m_aFont.Family));
86 0 : registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, ::getCppuType(&_pItem->m_aFont.CharSet));
87 0 : registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, ::getCppuType(&_pItem->m_aFont.Pitch));
88 0 : registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, ::getCppuType(&_pItem->m_aFont.CharacterWidth));
89 0 : registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, ::getCppuType(&_pItem->m_aFont.Weight));
90 0 : registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, ::getCppuType(&_pItem->m_aFont.Slant));
91 0 : registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, ::getCppuType(&_pItem->m_aFont.Underline));
92 0 : registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, ::getCppuType(&_pItem->m_aFont.Strikeout));
93 0 : registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, ::getCppuType(&_pItem->m_aFont.Orientation));
94 0 : registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, ::getCppuType(&_pItem->m_aFont.Kerning));
95 0 : registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, ::getCppuType(&_pItem->m_aFont.WordLineMode));
96 0 : registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, ::getCppuType(&_pItem->m_aFont.Type));
97 0 : }
98 :
99 0 : ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,sal_Bool _bQuery)
100 : :OPropertyStateContainer(_rBHelper)
101 : ,ODataSettings_Base()
102 0 : ,m_bQuery(_bQuery)
103 : {
104 0 : }
105 :
106 0 : ODataSettings_Base::ODataSettings_Base()
107 : :m_bApplyFilter(sal_False)
108 : ,m_aFont(::comphelper::getDefaultFont())
109 : ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE)
110 0 : ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE)
111 : {
112 0 : }
113 :
114 0 : 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 0 : ,m_nFontRelief( _rSource.m_nFontRelief )
126 : {
127 0 : }
128 :
129 0 : ODataSettings_Base::~ODataSettings_Base()
130 : {
131 0 : }
132 :
133 0 : void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const
134 : {
135 0 : static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont();
136 0 : switch( _nHandle )
137 : {
138 : case PROPERTY_ID_HAVING_CLAUSE:
139 : case PROPERTY_ID_GROUP_BY:
140 : case PROPERTY_ID_FILTER:
141 : case PROPERTY_ID_ORDER:
142 0 : _rDefault <<= OUString();
143 0 : break;
144 : case PROPERTY_ID_FONT:
145 0 : _rDefault <<= ::comphelper::getDefaultFont();
146 0 : break;
147 : case PROPERTY_ID_APPLYFILTER:
148 0 : _rDefault <<= sal_False;
149 0 : break;
150 : case PROPERTY_ID_TEXTRELIEF:
151 0 : _rDefault <<= ::com::sun::star::awt::FontRelief::NONE;
152 0 : break;
153 : case PROPERTY_ID_TEXTEMPHASIS:
154 0 : _rDefault <<= ::com::sun::star::awt::FontEmphasisMark::NONE;
155 0 : break;
156 : case PROPERTY_ID_FONTNAME:
157 0 : _rDefault <<= aFD.Name;
158 0 : break;
159 : case PROPERTY_ID_FONTHEIGHT:
160 0 : _rDefault <<= aFD.Height;
161 0 : break;
162 : case PROPERTY_ID_FONTWIDTH:
163 0 : _rDefault <<= aFD.Width;
164 0 : break;
165 : case PROPERTY_ID_FONTSTYLENAME:
166 0 : _rDefault <<= aFD.StyleName;
167 0 : break;
168 : case PROPERTY_ID_FONTFAMILY:
169 0 : _rDefault <<= aFD.Family;
170 0 : break;
171 : case PROPERTY_ID_FONTCHARSET:
172 0 : _rDefault <<= aFD.CharSet;
173 0 : break;
174 : case PROPERTY_ID_FONTPITCH:
175 0 : _rDefault <<= aFD.Pitch;
176 0 : break;
177 : case PROPERTY_ID_FONTCHARWIDTH:
178 0 : _rDefault <<= aFD.CharacterWidth;
179 0 : break;
180 : case PROPERTY_ID_FONTWEIGHT:
181 0 : _rDefault <<= aFD.Weight;
182 0 : break;
183 : case PROPERTY_ID_FONTSLANT:
184 0 : _rDefault <<= aFD.Slant;
185 0 : break;
186 : case PROPERTY_ID_FONTUNDERLINE:
187 0 : _rDefault <<= aFD.Underline;
188 0 : break;
189 : case PROPERTY_ID_FONTSTRIKEOUT:
190 0 : _rDefault <<= aFD.Strikeout;
191 0 : break;
192 : case PROPERTY_ID_FONTORIENTATION:
193 0 : _rDefault <<= aFD.Orientation;
194 0 : break;
195 : case PROPERTY_ID_FONTKERNING:
196 0 : _rDefault <<= aFD.Kerning;
197 0 : break;
198 : case PROPERTY_ID_FONTWORDLINEMODE:
199 0 : _rDefault <<= aFD.WordLineMode;
200 0 : break;
201 : case PROPERTY_ID_FONTTYPE:
202 0 : _rDefault <<= aFD.Type;
203 0 : break;
204 : }
205 0 : }
206 :
207 : } // namespace dbaccess
208 :
209 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|