1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dbaccess.hxx" 26 27 #ifndef _DBA_CORE_DATASETTINGS_HXX_ 28 #include "datasettings.hxx" 29 #endif 30 #ifndef _DBASHARED_APITOOLS_HXX_ 31 #include "apitools.hxx" 32 #endif 33 #ifndef DBACCESS_SHARED_DBASTRINGS_HRC 34 #include "dbastrings.hrc" 35 #endif 36 #ifndef _OSL_DIAGNOSE_H_ 37 #include <osl/diagnose.h> 38 #endif 39 #ifndef _COMPHELPER_PROPERTY_HXX_ 40 #include <comphelper/property.hxx> 41 #endif 42 #ifndef _COMPHELPER_TYPES_HXX_ 43 #include <comphelper/types.hxx> 44 #endif 45 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ 46 #include <com/sun/star/beans/PropertyAttribute.hpp> 47 #endif 48 #ifndef _SV_SVAPP_HXX 49 #include <vcl/svapp.hxx> 50 #endif 51 #ifndef _COM_SUN_STAR_AWT_FONTWEIGHT_HPP_ 52 #include <com/sun/star/awt/FontWeight.hpp> 53 #endif 54 #ifndef _COM_SUN_STAR_AWT_FONTEMPHASISMARK_HPP_ 55 #include <com/sun/star/awt/FontEmphasisMark.hpp> 56 #endif 57 #ifndef _COM_SUN_STAR_AWT_FONTRELIEF_HPP_ 58 #include <com/sun/star/awt/FontRelief.hpp> 59 #endif 60 61 #ifndef _COM_SUN_STAR_AWT_FONTWIDTH_HPP_ 62 #include <com/sun/star/awt/FontWidth.hpp> 63 #endif 64 65 66 using namespace ::com::sun::star::uno; 67 using namespace ::com::sun::star::awt; 68 using namespace ::com::sun::star::lang; 69 using namespace ::com::sun::star::beans; 70 using namespace ::comphelper; 71 using namespace ::cppu; 72 73 //........................................................................ 74 namespace dbaccess 75 { 76 //========================================================================== 77 //= ODataSettings 78 //========================================================================== 79 //-------------------------------------------------------------------------- 80 void ODataSettings::registerPropertiesFor(ODataSettings_Base* _pItem) 81 { 82 if ( m_bQuery ) 83 { 84 registerProperty(PROPERTY_HAVING_CLAUSE, PROPERTY_ID_HAVING_CLAUSE, PropertyAttribute::BOUND, 85 &_pItem->m_sHavingClause, ::getCppuType(&_pItem->m_sHavingClause)); 86 87 registerProperty(PROPERTY_GROUP_BY, PROPERTY_ID_GROUP_BY, PropertyAttribute::BOUND, 88 &_pItem->m_sGroupBy, ::getCppuType(&_pItem->m_sGroupBy)); 89 } 90 91 registerProperty(PROPERTY_FILTER, PROPERTY_ID_FILTER, PropertyAttribute::BOUND, 92 &_pItem->m_sFilter, ::getCppuType(&_pItem->m_sFilter)); 93 94 registerProperty(PROPERTY_ORDER, PROPERTY_ID_ORDER, PropertyAttribute::BOUND, 95 &_pItem->m_sOrder, ::getCppuType(&_pItem->m_sOrder)); 96 97 registerProperty(PROPERTY_APPLYFILTER, PROPERTY_ID_APPLYFILTER, PropertyAttribute::BOUND, 98 &_pItem->m_bApplyFilter, ::getBooleanCppuType()); 99 100 registerProperty(PROPERTY_FONT, PROPERTY_ID_FONT, PropertyAttribute::BOUND, 101 &_pItem->m_aFont, ::getCppuType(&_pItem->m_aFont)); 102 103 registerMayBeVoidProperty(PROPERTY_ROW_HEIGHT, PROPERTY_ID_ROW_HEIGHT, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID, 104 &_pItem->m_aRowHeight, ::getCppuType(static_cast<sal_Int32*>(NULL))); 105 106 registerMayBeVoidProperty(PROPERTY_TEXTCOLOR, PROPERTY_ID_TEXTCOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID, 107 &_pItem->m_aTextColor, ::getCppuType(static_cast<sal_Int32*>(NULL))); 108 109 registerMayBeVoidProperty(PROPERTY_TEXTLINECOLOR, PROPERTY_ID_TEXTLINECOLOR, PropertyAttribute::BOUND | PropertyAttribute::MAYBEVOID, 110 &_pItem->m_aTextLineColor, ::getCppuType(static_cast<sal_Int32*>(NULL))); 111 112 registerProperty(PROPERTY_TEXTEMPHASIS, PROPERTY_ID_TEXTEMPHASIS, PropertyAttribute::BOUND, 113 &_pItem->m_nFontEmphasis, ::getCppuType(&_pItem->m_nFontEmphasis)); 114 115 registerProperty(PROPERTY_TEXTRELIEF, PROPERTY_ID_TEXTRELIEF, PropertyAttribute::BOUND,&_pItem->m_nFontRelief, ::getCppuType(&_pItem->m_nFontRelief)); 116 117 registerProperty(PROPERTY_FONTNAME, PROPERTY_ID_FONTNAME, PropertyAttribute::BOUND,&_pItem->m_aFont.Name, ::getCppuType(&_pItem->m_aFont.Name)); 118 registerProperty(PROPERTY_FONTHEIGHT, PROPERTY_ID_FONTHEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Height, ::getCppuType(&_pItem->m_aFont.Height)); 119 registerProperty(PROPERTY_FONTWIDTH, PROPERTY_ID_FONTWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.Width, ::getCppuType(&_pItem->m_aFont.Width)); 120 registerProperty(PROPERTY_FONTSTYLENAME, PROPERTY_ID_FONTSTYLENAME, PropertyAttribute::BOUND,&_pItem->m_aFont.StyleName, ::getCppuType(&_pItem->m_aFont.StyleName)); 121 registerProperty(PROPERTY_FONTFAMILY, PROPERTY_ID_FONTFAMILY, PropertyAttribute::BOUND,&_pItem->m_aFont.Family, ::getCppuType(&_pItem->m_aFont.Family)); 122 registerProperty(PROPERTY_FONTCHARSET, PROPERTY_ID_FONTCHARSET, PropertyAttribute::BOUND,&_pItem->m_aFont.CharSet, ::getCppuType(&_pItem->m_aFont.CharSet)); 123 registerProperty(PROPERTY_FONTPITCH, PROPERTY_ID_FONTPITCH, PropertyAttribute::BOUND,&_pItem->m_aFont.Pitch, ::getCppuType(&_pItem->m_aFont.Pitch)); 124 registerProperty(PROPERTY_FONTCHARWIDTH, PROPERTY_ID_FONTCHARWIDTH, PropertyAttribute::BOUND,&_pItem->m_aFont.CharacterWidth, ::getCppuType(&_pItem->m_aFont.CharacterWidth)); 125 registerProperty(PROPERTY_FONTWEIGHT, PROPERTY_ID_FONTWEIGHT, PropertyAttribute::BOUND,&_pItem->m_aFont.Weight, ::getCppuType(&_pItem->m_aFont.Weight)); 126 registerProperty(PROPERTY_FONTSLANT, PROPERTY_ID_FONTSLANT, PropertyAttribute::BOUND,&_pItem->m_aFont.Slant, ::getCppuType(&_pItem->m_aFont.Slant)); 127 registerProperty(PROPERTY_FONTUNDERLINE, PROPERTY_ID_FONTUNDERLINE, PropertyAttribute::BOUND,&_pItem->m_aFont.Underline, ::getCppuType(&_pItem->m_aFont.Underline)); 128 registerProperty(PROPERTY_FONTSTRIKEOUT, PROPERTY_ID_FONTSTRIKEOUT, PropertyAttribute::BOUND,&_pItem->m_aFont.Strikeout, ::getCppuType(&_pItem->m_aFont.Strikeout)); 129 registerProperty(PROPERTY_FONTORIENTATION, PROPERTY_ID_FONTORIENTATION, PropertyAttribute::BOUND,&_pItem->m_aFont.Orientation, ::getCppuType(&_pItem->m_aFont.Orientation)); 130 registerProperty(PROPERTY_FONTKERNING, PROPERTY_ID_FONTKERNING, PropertyAttribute::BOUND,&_pItem->m_aFont.Kerning, ::getCppuType(&_pItem->m_aFont.Kerning)); 131 registerProperty(PROPERTY_FONTWORDLINEMODE, PROPERTY_ID_FONTWORDLINEMODE,PropertyAttribute::BOUND,&_pItem->m_aFont.WordLineMode, ::getCppuType(&_pItem->m_aFont.WordLineMode)); 132 registerProperty(PROPERTY_FONTTYPE, PROPERTY_ID_FONTTYPE, PropertyAttribute::BOUND,&_pItem->m_aFont.Type, ::getCppuType(&_pItem->m_aFont.Type)); 133 } 134 135 //-------------------------------------------------------------------------- 136 ODataSettings::ODataSettings(OBroadcastHelper& _rBHelper,sal_Bool _bQuery) 137 :OPropertyStateContainer(_rBHelper) 138 ,ODataSettings_Base() 139 ,m_bQuery(_bQuery) 140 { 141 } 142 143 //-------------------------------------------------------------------------- 144 ODataSettings_Base::ODataSettings_Base() 145 :m_bApplyFilter(sal_False) 146 ,m_aFont(::comphelper::getDefaultFont()) 147 ,m_nFontEmphasis(::com::sun::star::awt::FontEmphasisMark::NONE) 148 ,m_nFontRelief(::com::sun::star::awt::FontRelief::NONE) 149 { 150 } 151 152 //-------------------------------------------------------------------------- 153 ODataSettings_Base::ODataSettings_Base(const ODataSettings_Base& _rSource) 154 :m_sFilter( _rSource.m_sFilter ) 155 ,m_sHavingClause( _rSource.m_sHavingClause ) 156 ,m_sGroupBy( _rSource.m_sGroupBy ) 157 ,m_sOrder( _rSource.m_sOrder ) 158 ,m_bApplyFilter( _rSource.m_bApplyFilter ) 159 ,m_aFont( _rSource.m_aFont ) 160 ,m_aRowHeight( _rSource.m_aRowHeight ) 161 ,m_aTextColor( _rSource.m_aTextColor ) 162 ,m_aTextLineColor( _rSource.m_aTextLineColor ) 163 ,m_nFontEmphasis( _rSource.m_nFontEmphasis ) 164 ,m_nFontRelief( _rSource.m_nFontRelief ) 165 { 166 } 167 168 // ----------------------------------------------------------------------------- 169 ODataSettings_Base::~ODataSettings_Base() 170 { 171 } 172 173 // ----------------------------------------------------------------------------- 174 void ODataSettings::getPropertyDefaultByHandle( sal_Int32 _nHandle, Any& _rDefault ) const 175 { 176 static ::com::sun::star::awt::FontDescriptor aFD = ::comphelper::getDefaultFont(); 177 switch( _nHandle ) 178 { 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; 245 } 246 } 247 //........................................................................ 248 } // namespace dbaccess 249 //........................................................................ 250 251