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