xref: /AOO41X/main/forms/source/component/formcontrolfont.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_forms.hxx"
30*cdf0e10cSrcweir #include "formcontrolfont.hxx"
31*cdf0e10cSrcweir #ifndef _FRM_PROPERTY_HRC_
32*cdf0e10cSrcweir #include "property.hrc"
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include "property.hxx"
35*cdf0e10cSrcweir #include <tools/debug.hxx>
36*cdf0e10cSrcweir #include <comphelper/property.hxx>
37*cdf0e10cSrcweir #include <comphelper/types.hxx>
38*cdf0e10cSrcweir #include <tools/color.hxx>
39*cdf0e10cSrcweir #include <toolkit/helper/emptyfontdescriptor.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/awt/FontRelief.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/awt/FontEmphasisMark.hpp>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //.........................................................................
44*cdf0e10cSrcweir namespace frm
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir //.........................................................................
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     using namespace ::comphelper;
49*cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
50*cdf0e10cSrcweir     using namespace ::com::sun::star::awt;
51*cdf0e10cSrcweir     using namespace ::com::sun::star::lang;
52*cdf0e10cSrcweir     using namespace ::com::sun::star::beans;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir     //------------------------------------------------------------------------------
55*cdf0e10cSrcweir     namespace
56*cdf0e10cSrcweir     {
57*cdf0e10cSrcweir         Any lcl_extractFontDescriptorAggregate( sal_Int32 _nHandle, const FontDescriptor& _rFont )
58*cdf0e10cSrcweir         {
59*cdf0e10cSrcweir             Any aValue;
60*cdf0e10cSrcweir             switch ( _nHandle )
61*cdf0e10cSrcweir             {
62*cdf0e10cSrcweir 		    case PROPERTY_ID_FONT_NAME:
63*cdf0e10cSrcweir 			    aValue <<= _rFont.Name;
64*cdf0e10cSrcweir 			    break;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir             case PROPERTY_ID_FONT_STYLENAME:
67*cdf0e10cSrcweir 			    aValue <<= _rFont.StyleName;
68*cdf0e10cSrcweir 			    break;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir             case PROPERTY_ID_FONT_FAMILY:
71*cdf0e10cSrcweir 			    aValue <<= (sal_Int16)_rFont.Family;
72*cdf0e10cSrcweir 			    break;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir             case PROPERTY_ID_FONT_CHARSET:
75*cdf0e10cSrcweir 			    aValue <<= (sal_Int16)_rFont.CharSet;
76*cdf0e10cSrcweir 			    break;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir             case PROPERTY_ID_FONT_CHARWIDTH:
79*cdf0e10cSrcweir 			    aValue <<= _rFont.CharacterWidth;
80*cdf0e10cSrcweir                 break;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir             case PROPERTY_ID_FONT_KERNING:
83*cdf0e10cSrcweir 			    aValue <<= _rFont.Kerning;
84*cdf0e10cSrcweir                 break;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             case PROPERTY_ID_FONT_ORIENTATION:
87*cdf0e10cSrcweir 			    aValue <<= _rFont.Orientation;
88*cdf0e10cSrcweir                 break;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir             case PROPERTY_ID_FONT_PITCH:
91*cdf0e10cSrcweir 			    aValue <<= _rFont.Pitch;
92*cdf0e10cSrcweir                 break;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir             case PROPERTY_ID_FONT_TYPE:
95*cdf0e10cSrcweir 			    aValue <<= _rFont.Type;
96*cdf0e10cSrcweir                 break;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir             case PROPERTY_ID_FONT_WIDTH:
99*cdf0e10cSrcweir 			    aValue <<= _rFont.Width;
100*cdf0e10cSrcweir                 break;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             case PROPERTY_ID_FONT_HEIGHT:
103*cdf0e10cSrcweir 			    aValue <<= (float)( _rFont.Height );
104*cdf0e10cSrcweir 			    break;
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir             case PROPERTY_ID_FONT_WEIGHT:
107*cdf0e10cSrcweir 			    aValue <<= (float)_rFont.Weight;
108*cdf0e10cSrcweir 			    break;
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir             case PROPERTY_ID_FONT_SLANT:
111*cdf0e10cSrcweir 			    aValue = makeAny(_rFont.Slant);
112*cdf0e10cSrcweir 			    break;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir             case PROPERTY_ID_FONT_UNDERLINE:
115*cdf0e10cSrcweir 			    aValue <<= (sal_Int16)_rFont.Underline;
116*cdf0e10cSrcweir 			    break;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir             case PROPERTY_ID_FONT_STRIKEOUT:
119*cdf0e10cSrcweir 			    aValue <<= (sal_Int16)_rFont.Strikeout;
120*cdf0e10cSrcweir 			    break;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir             case PROPERTY_ID_FONT_WORDLINEMODE:
123*cdf0e10cSrcweir 			    aValue = makeAny( (sal_Bool)_rFont.WordLineMode );
124*cdf0e10cSrcweir 			    break;
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir             default:
127*cdf0e10cSrcweir                 OSL_ENSURE( sal_False, "lcl_extractFontDescriptorAggregate: invalid handle!" );
128*cdf0e10cSrcweir                 break;
129*cdf0e10cSrcweir             }
130*cdf0e10cSrcweir             return aValue;
131*cdf0e10cSrcweir         }
132*cdf0e10cSrcweir     }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     //=====================================================================
135*cdf0e10cSrcweir     //= FontControlModel
136*cdf0e10cSrcweir     //=====================================================================
137*cdf0e10cSrcweir     //---------------------------------------------------------------------
138*cdf0e10cSrcweir     FontControlModel::FontControlModel( bool _bToolkitCompatibleDefaults )
139*cdf0e10cSrcweir         :m_nFontRelief( FontRelief::NONE )
140*cdf0e10cSrcweir         ,m_nFontEmphasis( FontEmphasisMark::NONE )
141*cdf0e10cSrcweir         ,m_bToolkitCompatibleDefaults( _bToolkitCompatibleDefaults )
142*cdf0e10cSrcweir     {
143*cdf0e10cSrcweir     }
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir     //---------------------------------------------------------------------
146*cdf0e10cSrcweir     FontControlModel::FontControlModel( const FontControlModel* _pOriginal )
147*cdf0e10cSrcweir     {
148*cdf0e10cSrcweir         m_aFont = _pOriginal->m_aFont;
149*cdf0e10cSrcweir 	    m_nFontRelief = _pOriginal->m_nFontRelief;
150*cdf0e10cSrcweir 	    m_nFontEmphasis = _pOriginal->m_nFontEmphasis;
151*cdf0e10cSrcweir         m_aTextLineColor = _pOriginal->m_aTextLineColor;
152*cdf0e10cSrcweir         m_aTextColor = _pOriginal->m_aTextColor;
153*cdf0e10cSrcweir         m_bToolkitCompatibleDefaults = _pOriginal->m_bToolkitCompatibleDefaults;
154*cdf0e10cSrcweir     }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     //---------------------------------------------------------------------
157*cdf0e10cSrcweir     bool FontControlModel::isFontRelatedProperty( sal_Int32 _nPropertyHandle ) const
158*cdf0e10cSrcweir     {
159*cdf0e10cSrcweir         return isFontAggregateProperty( _nPropertyHandle )
160*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT )
161*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONTEMPHASISMARK )
162*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONTRELIEF )
163*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_TEXTLINECOLOR )
164*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_TEXTCOLOR );
165*cdf0e10cSrcweir     }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     //---------------------------------------------------------------------
168*cdf0e10cSrcweir     bool FontControlModel::isFontAggregateProperty( sal_Int32 _nPropertyHandle ) const
169*cdf0e10cSrcweir     {
170*cdf0e10cSrcweir         return ( _nPropertyHandle == PROPERTY_ID_FONT_CHARWIDTH )
171*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_ORIENTATION )
172*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_WIDTH )
173*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_NAME )
174*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_STYLENAME )
175*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_FAMILY )
176*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_CHARSET )
177*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_HEIGHT )
178*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_WEIGHT )
179*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_SLANT )
180*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_UNDERLINE )
181*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_STRIKEOUT )
182*cdf0e10cSrcweir 		    || ( _nPropertyHandle == PROPERTY_ID_FONT_WORDLINEMODE )
183*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_PITCH )
184*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_KERNING )
185*cdf0e10cSrcweir             || ( _nPropertyHandle == PROPERTY_ID_FONT_TYPE );
186*cdf0e10cSrcweir     }
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     //---------------------------------------------------------------------
189*cdf0e10cSrcweir     sal_Int32 FontControlModel::getTextColor( ) const
190*cdf0e10cSrcweir     {
191*cdf0e10cSrcweir         sal_Int32 nColor = COL_TRANSPARENT;
192*cdf0e10cSrcweir         m_aTextColor >>= nColor;
193*cdf0e10cSrcweir         return nColor;
194*cdf0e10cSrcweir     }
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     //---------------------------------------------------------------------
197*cdf0e10cSrcweir     sal_Int32 FontControlModel::getTextLineColor( ) const
198*cdf0e10cSrcweir     {
199*cdf0e10cSrcweir         sal_Int32 nColor = COL_TRANSPARENT;
200*cdf0e10cSrcweir         m_aTextLineColor >>= nColor;
201*cdf0e10cSrcweir         return nColor;
202*cdf0e10cSrcweir     }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir     //------------------------------------------------------------------------------
205*cdf0e10cSrcweir     void FontControlModel::describeFontRelatedProperties( Sequence< Property >& /* [out] */ _rProps ) const
206*cdf0e10cSrcweir     {
207*cdf0e10cSrcweir         sal_Int32 nPos = _rProps.getLength();
208*cdf0e10cSrcweir         _rProps.realloc( nPos + 21 );
209*cdf0e10cSrcweir         Property* pProperties = _rProps.getArray();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir         DECL_PROP2      ( FONT,               FontDescriptor,   BOUND, MAYBEDEFAULT );
212*cdf0e10cSrcweir         DECL_PROP2      ( FONTEMPHASISMARK,   sal_Int16,        BOUND, MAYBEDEFAULT );
213*cdf0e10cSrcweir         DECL_PROP2      ( FONTRELIEF,         sal_Int16,        BOUND, MAYBEDEFAULT );
214*cdf0e10cSrcweir         DECL_PROP3      ( TEXTCOLOR,          sal_Int32,        BOUND, MAYBEDEFAULT, MAYBEVOID );
215*cdf0e10cSrcweir         DECL_PROP3      ( TEXTLINECOLOR,      sal_Int32,        BOUND, MAYBEDEFAULT, MAYBEVOID );
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         DECL_PROP1      ( FONT_CHARWIDTH,     float,            MAYBEDEFAULT );
218*cdf0e10cSrcweir         DECL_BOOL_PROP1 ( FONT_KERNING,                         MAYBEDEFAULT );
219*cdf0e10cSrcweir         DECL_PROP1      ( FONT_ORIENTATION,   float,            MAYBEDEFAULT );
220*cdf0e10cSrcweir         DECL_PROP1      ( FONT_PITCH,         sal_Int16,        MAYBEDEFAULT );
221*cdf0e10cSrcweir         DECL_PROP1      ( FONT_TYPE,          sal_Int16,        MAYBEDEFAULT );
222*cdf0e10cSrcweir         DECL_PROP1      ( FONT_WIDTH,         sal_Int16,        MAYBEDEFAULT );
223*cdf0e10cSrcweir         DECL_PROP1      ( FONT_NAME,          ::rtl::OUString,  MAYBEDEFAULT );
224*cdf0e10cSrcweir         DECL_PROP1      ( FONT_STYLENAME,     ::rtl::OUString,  MAYBEDEFAULT );
225*cdf0e10cSrcweir         DECL_PROP1      ( FONT_FAMILY,        sal_Int16,        MAYBEDEFAULT );
226*cdf0e10cSrcweir         DECL_PROP1      ( FONT_CHARSET,       sal_Int16,        MAYBEDEFAULT );
227*cdf0e10cSrcweir         DECL_PROP1      ( FONT_HEIGHT,        float,            MAYBEDEFAULT );
228*cdf0e10cSrcweir         DECL_PROP1      ( FONT_WEIGHT,        float,            MAYBEDEFAULT );
229*cdf0e10cSrcweir         DECL_PROP1      ( FONT_SLANT,         sal_Int16,        MAYBEDEFAULT );
230*cdf0e10cSrcweir         DECL_PROP1      ( FONT_UNDERLINE,     sal_Int16,        MAYBEDEFAULT );
231*cdf0e10cSrcweir         DECL_PROP1      ( FONT_STRIKEOUT,     sal_Int16,        MAYBEDEFAULT );
232*cdf0e10cSrcweir         DECL_BOOL_PROP1 ( FONT_WORDLINEMODE,                    MAYBEDEFAULT );
233*cdf0e10cSrcweir     }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir     //---------------------------------------------------------------------
236*cdf0e10cSrcweir     void FontControlModel::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
237*cdf0e10cSrcweir     {
238*cdf0e10cSrcweir         switch( _nHandle )
239*cdf0e10cSrcweir         {
240*cdf0e10cSrcweir         case PROPERTY_ID_TEXTCOLOR:
241*cdf0e10cSrcweir 			_rValue = m_aTextColor;
242*cdf0e10cSrcweir 			break;
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 		case PROPERTY_ID_FONTEMPHASISMARK:
245*cdf0e10cSrcweir 			_rValue <<= m_nFontEmphasis;
246*cdf0e10cSrcweir 			break;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         case PROPERTY_ID_FONTRELIEF:
249*cdf0e10cSrcweir 			_rValue <<= m_nFontRelief;
250*cdf0e10cSrcweir 			break;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
253*cdf0e10cSrcweir 			_rValue = m_aTextLineColor;
254*cdf0e10cSrcweir 			break;
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir         case PROPERTY_ID_FONT:
257*cdf0e10cSrcweir 			_rValue = makeAny( m_aFont );
258*cdf0e10cSrcweir 			break;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         default:
261*cdf0e10cSrcweir             _rValue = lcl_extractFontDescriptorAggregate( _nHandle, m_aFont );
262*cdf0e10cSrcweir             break;
263*cdf0e10cSrcweir         }
264*cdf0e10cSrcweir     }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir     //---------------------------------------------------------------------
267*cdf0e10cSrcweir     sal_Bool FontControlModel::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue,
268*cdf0e10cSrcweir                 sal_Int32 _nHandle, const Any& _rValue ) throw( IllegalArgumentException )
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir         sal_Bool bModified = sal_False;
271*cdf0e10cSrcweir         switch( _nHandle )
272*cdf0e10cSrcweir         {
273*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
274*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_aTextColor, ::getCppuType( static_cast< const sal_Int32* >( NULL ) ) );
275*cdf0e10cSrcweir 			break;
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir         case PROPERTY_ID_TEXTLINECOLOR:
278*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_aTextLineColor, ::getCppuType( static_cast< sal_Int32* >( NULL ) ) );
279*cdf0e10cSrcweir 			break;
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir         case PROPERTY_ID_FONTEMPHASISMARK:
282*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_nFontEmphasis );
283*cdf0e10cSrcweir 			break;
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         case PROPERTY_ID_FONTRELIEF:
286*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_nFontRelief );
287*cdf0e10cSrcweir 			break;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         case PROPERTY_ID_FONT:
290*cdf0e10cSrcweir         {
291*cdf0e10cSrcweir             Any aWorkAroundGccLimitation = makeAny( m_aFont );
292*cdf0e10cSrcweir             bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, aWorkAroundGccLimitation, ::getCppuType( &m_aFont ) );
293*cdf0e10cSrcweir         }
294*cdf0e10cSrcweir         break;
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir         case PROPERTY_ID_FONT_NAME:
297*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_aFont.Name );
298*cdf0e10cSrcweir 			break;
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir         case PROPERTY_ID_FONT_STYLENAME:
301*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_aFont.StyleName );
302*cdf0e10cSrcweir 			break;
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir         case PROPERTY_ID_FONT_FAMILY:
305*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Family );
306*cdf0e10cSrcweir 			break;
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir         case PROPERTY_ID_FONT_CHARSET:
309*cdf0e10cSrcweir             bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.CharSet );
310*cdf0e10cSrcweir 			break;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir         case PROPERTY_ID_FONT_CHARWIDTH:
313*cdf0e10cSrcweir             bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, float( m_aFont.CharacterWidth ) );
314*cdf0e10cSrcweir             break;
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir         case PROPERTY_ID_FONT_KERNING:
317*cdf0e10cSrcweir             bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Kerning );
318*cdf0e10cSrcweir             break;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir         case PROPERTY_ID_FONT_ORIENTATION:
321*cdf0e10cSrcweir             bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, float( m_aFont.Orientation ) );
322*cdf0e10cSrcweir             break;
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir         case PROPERTY_ID_FONT_PITCH:
325*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Pitch );
326*cdf0e10cSrcweir 			break;
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir         case PROPERTY_ID_FONT_TYPE:
329*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Type );
330*cdf0e10cSrcweir 			break;
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WIDTH:
333*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Width );
334*cdf0e10cSrcweir 			break;
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir         case PROPERTY_ID_FONT_HEIGHT:
337*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, float( m_aFont.Height ) );
338*cdf0e10cSrcweir 			break;
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WEIGHT:
341*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, m_aFont.Weight );
342*cdf0e10cSrcweir 			break;
343*cdf0e10cSrcweir 
344*cdf0e10cSrcweir         case PROPERTY_ID_FONT_SLANT:
345*cdf0e10cSrcweir 			bModified = tryPropertyValueEnum( _rConvertedValue, _rOldValue, _rValue, m_aFont.Slant );
346*cdf0e10cSrcweir 			break;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir         case PROPERTY_ID_FONT_UNDERLINE:
349*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Underline );
350*cdf0e10cSrcweir 			break;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir         case PROPERTY_ID_FONT_STRIKEOUT:
353*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Int16)m_aFont.Strikeout );
354*cdf0e10cSrcweir 			break;
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WORDLINEMODE:
357*cdf0e10cSrcweir 			bModified = tryPropertyValue( _rConvertedValue, _rOldValue, _rValue, (sal_Bool)m_aFont.WordLineMode );
358*cdf0e10cSrcweir 			break;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir         default:
361*cdf0e10cSrcweir             DBG_ERROR( "FontControlModel::convertFastPropertyValue: no font aggregate!" );
362*cdf0e10cSrcweir         }
363*cdf0e10cSrcweir         return bModified;
364*cdf0e10cSrcweir     }
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir     //------------------------------------------------------------------------------
367*cdf0e10cSrcweir     void FontControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw ( Exception )
368*cdf0e10cSrcweir     {
369*cdf0e10cSrcweir         switch( _nHandle )
370*cdf0e10cSrcweir         {
371*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
372*cdf0e10cSrcweir 			m_aTextColor = _rValue;
373*cdf0e10cSrcweir 			break;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
376*cdf0e10cSrcweir 			m_aTextLineColor = _rValue;
377*cdf0e10cSrcweir 			break;
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir         case PROPERTY_ID_FONTEMPHASISMARK:
380*cdf0e10cSrcweir 			_rValue >>= m_nFontEmphasis;
381*cdf0e10cSrcweir 			break;
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir         case PROPERTY_ID_FONTRELIEF:
384*cdf0e10cSrcweir 			_rValue >>= m_nFontRelief;
385*cdf0e10cSrcweir 			break;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir         case PROPERTY_ID_FONT:
388*cdf0e10cSrcweir 			_rValue >>= m_aFont;
389*cdf0e10cSrcweir 			break;
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir         case PROPERTY_ID_FONT_NAME:
392*cdf0e10cSrcweir 			_rValue >>= m_aFont.Name;
393*cdf0e10cSrcweir 			break;
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir         case PROPERTY_ID_FONT_STYLENAME:
396*cdf0e10cSrcweir 			_rValue >>= m_aFont.StyleName;
397*cdf0e10cSrcweir 			break;
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir         case PROPERTY_ID_FONT_FAMILY:
400*cdf0e10cSrcweir 			_rValue >>= m_aFont.Family;
401*cdf0e10cSrcweir 			break;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir         case PROPERTY_ID_FONT_CHARSET:
404*cdf0e10cSrcweir 			_rValue >>= m_aFont.CharSet;
405*cdf0e10cSrcweir 			break;
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir         case PROPERTY_ID_FONT_CHARWIDTH:
408*cdf0e10cSrcweir 			_rValue >>= m_aFont.CharacterWidth;
409*cdf0e10cSrcweir             break;
410*cdf0e10cSrcweir 
411*cdf0e10cSrcweir         case PROPERTY_ID_FONT_KERNING:
412*cdf0e10cSrcweir 			_rValue >>= m_aFont.Kerning;
413*cdf0e10cSrcweir             break;
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir         case PROPERTY_ID_FONT_ORIENTATION:
416*cdf0e10cSrcweir 			_rValue >>= m_aFont.Orientation;
417*cdf0e10cSrcweir             break;
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir         case PROPERTY_ID_FONT_PITCH:
420*cdf0e10cSrcweir 			_rValue >>= m_aFont.Pitch;
421*cdf0e10cSrcweir             break;
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir         case PROPERTY_ID_FONT_TYPE:
424*cdf0e10cSrcweir 			_rValue >>= m_aFont.Type;
425*cdf0e10cSrcweir             break;
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WIDTH:
428*cdf0e10cSrcweir 			_rValue >>= m_aFont.Width;
429*cdf0e10cSrcweir             break;
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir         case PROPERTY_ID_FONT_HEIGHT:
432*cdf0e10cSrcweir         {
433*cdf0e10cSrcweir             float nHeight = 0;
434*cdf0e10cSrcweir             _rValue >>= nHeight;
435*cdf0e10cSrcweir 			m_aFont.Height = (sal_Int16)nHeight;
436*cdf0e10cSrcweir         }
437*cdf0e10cSrcweir 		break;
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WEIGHT:
440*cdf0e10cSrcweir 			_rValue >>= m_aFont.Weight;
441*cdf0e10cSrcweir 			break;
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir         case PROPERTY_ID_FONT_SLANT:
444*cdf0e10cSrcweir             _rValue >>= m_aFont.Slant;
445*cdf0e10cSrcweir 			break;
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir         case PROPERTY_ID_FONT_UNDERLINE:
448*cdf0e10cSrcweir 			_rValue >>= m_aFont.Underline;
449*cdf0e10cSrcweir 			break;
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir         case PROPERTY_ID_FONT_STRIKEOUT:
452*cdf0e10cSrcweir 			_rValue >>= m_aFont.Strikeout;
453*cdf0e10cSrcweir 			break;
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WORDLINEMODE:
456*cdf0e10cSrcweir         {
457*cdf0e10cSrcweir             sal_Bool bWordLineMode = sal_False;
458*cdf0e10cSrcweir             _rValue >>= bWordLineMode;
459*cdf0e10cSrcweir 			m_aFont.WordLineMode = bWordLineMode;
460*cdf0e10cSrcweir         }
461*cdf0e10cSrcweir         break;
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir         default:
464*cdf0e10cSrcweir             DBG_ERROR( "FontControlModel::setFastPropertyValue_NoBroadcast: invalid property!" );
465*cdf0e10cSrcweir         }
466*cdf0e10cSrcweir     }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir     //------------------------------------------------------------------------------
469*cdf0e10cSrcweir     Any FontControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const
470*cdf0e10cSrcweir     {
471*cdf0e10cSrcweir         Any aReturn;
472*cdf0e10cSrcweir         // some defaults which are the same, not matter if we have toolkit-compatible
473*cdf0e10cSrcweir         // defaults or not
474*cdf0e10cSrcweir         bool bHandled = false;
475*cdf0e10cSrcweir         switch( _nHandle )
476*cdf0e10cSrcweir         {
477*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTCOLOR:
478*cdf0e10cSrcweir 		case PROPERTY_ID_TEXTLINECOLOR:
479*cdf0e10cSrcweir             // void
480*cdf0e10cSrcweir             bHandled = true;
481*cdf0e10cSrcweir             break;
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir         case PROPERTY_ID_FONTEMPHASISMARK:
484*cdf0e10cSrcweir 			aReturn <<= FontEmphasisMark::NONE;
485*cdf0e10cSrcweir             bHandled = true;
486*cdf0e10cSrcweir 			break;
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir 		case PROPERTY_ID_FONTRELIEF:
489*cdf0e10cSrcweir 			aReturn <<= FontRelief::NONE;
490*cdf0e10cSrcweir             bHandled = true;
491*cdf0e10cSrcweir 			break;
492*cdf0e10cSrcweir         }
493*cdf0e10cSrcweir         if ( bHandled )
494*cdf0e10cSrcweir             return aReturn;
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir         if ( m_bToolkitCompatibleDefaults )
497*cdf0e10cSrcweir         {
498*cdf0e10cSrcweir             EmptyFontDescriptor aEmpty;
499*cdf0e10cSrcweir             if ( PROPERTY_ID_FONT == _nHandle )
500*cdf0e10cSrcweir                 return makeAny( (FontDescriptor)aEmpty );
501*cdf0e10cSrcweir             return lcl_extractFontDescriptorAggregate( _nHandle, aEmpty );
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir         switch( _nHandle )
505*cdf0e10cSrcweir         {
506*cdf0e10cSrcweir 		case PROPERTY_ID_FONT:
507*cdf0e10cSrcweir 			aReturn <<= ::comphelper::getDefaultFont();
508*cdf0e10cSrcweir 			break;
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_WORDLINEMODE:
511*cdf0e10cSrcweir 			aReturn = makeBoolAny(sal_False);
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_NAME:
514*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_STYLENAME:
515*cdf0e10cSrcweir 			aReturn <<= ::rtl::OUString();
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_FAMILY:
518*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_CHARSET:
519*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_SLANT:
520*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_UNDERLINE:
521*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_STRIKEOUT:
522*cdf0e10cSrcweir 			aReturn <<= (sal_Int16)1;
523*cdf0e10cSrcweir             break;
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir         case PROPERTY_ID_FONT_KERNING:
526*cdf0e10cSrcweir 			aReturn = makeBoolAny(sal_False);
527*cdf0e10cSrcweir             break;
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir         case PROPERTY_ID_FONT_PITCH:
530*cdf0e10cSrcweir         case PROPERTY_ID_FONT_TYPE:
531*cdf0e10cSrcweir         case PROPERTY_ID_FONT_WIDTH:
532*cdf0e10cSrcweir 			aReturn <<= (sal_Int16)0;
533*cdf0e10cSrcweir             break;
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir         case PROPERTY_ID_FONT_HEIGHT:
536*cdf0e10cSrcweir 		case PROPERTY_ID_FONT_WEIGHT:
537*cdf0e10cSrcweir         case PROPERTY_ID_FONT_CHARWIDTH:
538*cdf0e10cSrcweir         case PROPERTY_ID_FONT_ORIENTATION:
539*cdf0e10cSrcweir 			aReturn <<= (float)0;
540*cdf0e10cSrcweir 			break;
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir         default:
543*cdf0e10cSrcweir             DBG_ERROR( "FontControlModel::getPropertyDefaultByHandle: invalid property!" );
544*cdf0e10cSrcweir         }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir         return aReturn;
547*cdf0e10cSrcweir     }
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir //.........................................................................
550*cdf0e10cSrcweir }   // namespace frm
551*cdf0e10cSrcweir //.........................................................................
552