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