1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <sfx2/sfxsids.hrc>
30 #include "fontdialog.hxx"
31 #include "formresid.hrc"
32 #include "modulepcr.hxx"
33 #include "formlocalid.hrc"
34 #include <vcl/svapp.hxx>
35 #include <toolkit/unohlp.hxx>
36 #include <comphelper/types.hxx>
37 #include <comphelper/extract.hxx>
38 #include <com/sun/star/awt/FontDescriptor.hpp>
39 #include <com/sun/star/awt/FontWeight.hpp>
40 #include <com/sun/star/awt/FontSlant.hpp>
41 #include <com/sun/star/awt/FontUnderline.hpp>
42 #include <com/sun/star/awt/FontStrikeout.hpp>
43 #include "formstrings.hxx"
44 #include "fontitemids.hxx"
45 #include <editeng/charreliefitem.hxx>
46 #include <editeng/emphitem.hxx>
47 #include <editeng/fontitem.hxx>
48 #include <editeng/fhgtitem.hxx>
49 #include <editeng/postitem.hxx>
50 #include <editeng/wghtitem.hxx>
51 #include <editeng/udlnitem.hxx>
52 #include <editeng/crsditem.hxx>
53 #include <editeng/colritem.hxx>
54 #include <editeng/langitem.hxx>
55 #include <editeng/wrlmitem.hxx>
56 #include <editeng/cmapitem.hxx>
57 #include <editeng/cntritem.hxx>
58 #include <editeng/shdditem.hxx>
59 #include <editeng/flstitem.hxx>
60 #include <svtools/ctrltool.hxx>
61 #include <tools/diagnose_ex.h>
62 #include <com/sun/star/beans/XPropertyState.hpp>
63 #include <svx/svxids.hrc>
64 #include <svx/svxdlg.hxx>
65 #include <svx/dialogs.hrc>
66 #include <svx/flagsdef.hxx>
67 //............................................................................
70 //............................................................................
72 using namespace ::com::sun::star::uno
;
73 using namespace ::com::sun::star::beans
;
75 //========================================================================
76 //= OFontPropertyExtractor
77 //========================================================================
78 class OFontPropertyExtractor
81 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
83 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>
87 OFontPropertyExtractor( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>&
91 sal_Bool
getCheckFontProperty(const ::rtl::OUString
& _rPropName
, ::com::sun::star::uno::Any
& _rValue
);
92 ::rtl::OUString
getStringFontProperty(const ::rtl::OUString
& _rPropName
, const ::rtl::OUString
& _rDefault
);
93 sal_Int16
getInt16FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int16 _nDefault
);
94 sal_Int32
getInt32FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int32 _nDefault
);
95 float getFloatFontProperty(const ::rtl::OUString
& _rPropName
, const float _nDefault
);
98 const ::rtl::OUString
& _rPropName
,
101 sal_Bool _bForceInvalidation
= sal_False
);
104 //------------------------------------------------------------------------
105 OFontPropertyExtractor::OFontPropertyExtractor(const Reference
< XPropertySet
>& _rxProps
)
106 :m_xPropValueAccess(_rxProps
)
107 ,m_xPropStateAccess(_rxProps
, UNO_QUERY
)
109 OSL_ENSURE(m_xPropValueAccess
.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
112 //------------------------------------------------------------------------
113 sal_Bool
OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString
& _rPropName
, Any
& _rValue
)
115 _rValue
= m_xPropValueAccess
->getPropertyValue(_rPropName
);
116 if (m_xPropStateAccess
.is())
117 return PropertyState_DEFAULT_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
);
122 //------------------------------------------------------------------------
123 ::rtl::OUString
OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString
& _rPropName
, const ::rtl::OUString
& _rDefault
)
126 if (getCheckFontProperty(_rPropName
, aValue
))
129 return ::comphelper::getString(aValue
);
132 //------------------------------------------------------------------------
133 sal_Int16
OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int16 _nDefault
)
136 if (getCheckFontProperty(_rPropName
, aValue
))
139 sal_Int32
nValue(_nDefault
);
140 ::cppu::enum2int(nValue
, aValue
);
141 return (sal_Int16
)nValue
;
144 //------------------------------------------------------------------------
145 sal_Int32
OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int32 _nDefault
)
148 if (getCheckFontProperty(_rPropName
, aValue
))
151 sal_Int32
nValue(_nDefault
);
152 ::cppu::enum2int(nValue
, aValue
);
156 //------------------------------------------------------------------------
157 float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString
& _rPropName
, const float _nDefault
)
160 if (getCheckFontProperty(_rPropName
, aValue
))
163 return ::comphelper::getFloat(aValue
);
166 //------------------------------------------------------------------------
167 void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString
& _rPropName
, sal_uInt16 _nItemId
, SfxItemSet
& _rSet
, sal_Bool _bForceInvalidation
)
169 if ( _bForceInvalidation
170 || ( m_xPropStateAccess
.is()
171 && (PropertyState_AMBIGUOUS_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
))
174 _rSet
.InvalidateItem(_nItemId
);
177 //========================================================================
178 //= ControlCharacterDialog
179 //========================================================================
180 //------------------------------------------------------------------------
181 ControlCharacterDialog::ControlCharacterDialog(Window
* _pParent
, const SfxItemSet
& _rCoreSet
)
182 :SfxTabDialog(_pParent
, PcrRes(RID_TABDLG_FONTDIALOG
), &_rCoreSet
)
185 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
186 DBG_ASSERT(pFact
, "CreateFactory fail!");
187 AddTabPage(TABPAGE_CHARACTERS
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME
), 0 );
188 AddTabPage(TABPAGE_CHARACTERS_EXT
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS
), 0 );
191 //------------------------------------------------------------------------
192 ControlCharacterDialog::~ControlCharacterDialog()
196 //------------------------------------------------------------------------
197 void ControlCharacterDialog::translatePropertiesToItems(const Reference
< XPropertySet
>& _rxModel
, SfxItemSet
* _pSet
)
199 OSL_ENSURE(_pSet
&& _rxModel
.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
200 if (!_pSet
|| !_rxModel
.is())
205 OFontPropertyExtractor
aPropExtractor(_rxModel
);
207 // some items, which may be in default state, have to be filled with non-void information
208 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
209 ::com::sun::star::awt::FontDescriptor aDefaultFont
= VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont
);
211 // get the current properties
212 ::rtl::OUString aFontName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_NAME
, aDefaultFont
.Name
);
213 ::rtl::OUString aFontStyleName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_STYLENAME
, aDefaultFont
.StyleName
);
214 sal_Int16 nFontFamily
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_FAMILY
, aDefaultFont
.Family
);
215 sal_Int16 nFontCharset
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_CHARSET
, aDefaultFont
.CharSet
);
216 float nFontHeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_HEIGHT
, (float)aDefaultFont
.Height
);
217 float nFontWeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_WEIGHT
, aDefaultFont
.Weight
);
218 sal_Int16 nFontSlant
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_SLANT
, (sal_Int16
)aDefaultFont
.Slant
);
219 sal_Int16 nFontUnderline
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_UNDERLINE
, aDefaultFont
.Underline
);
220 sal_Int16 nFontStrikeout
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT
, aDefaultFont
.Strikeout
);
222 sal_Int32 nTextLineColor
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTLINECOLOR
, COL_AUTO
);
223 sal_Int16 nFontRelief
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_RELIEF
, (sal_Int16
)aDefaultVCLFont
.GetRelief());
224 sal_Int16 nFontEmphasisMark
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK
, aDefaultVCLFont
.GetEmphasisMark());
227 sal_Bool bWordLineMode
= aPropExtractor
.getCheckFontProperty(PROPERTY_WORDLINEMODE
, aValue
) ? aDefaultFont
.WordLineMode
: ::cppu::any2bool(aValue
);
228 sal_Int32 nColor32
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTCOLOR
, 0);
230 // build SfxItems with the values
231 SvxFontItem
aFontItem((FontFamily
)nFontFamily
, aFontName
, aFontStyleName
, PITCH_DONTKNOW
, nFontCharset
, CFID_FONT
);
233 nFontHeight
= (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32
)nFontHeight
), MAP_POINT
, MAP_TWIP
).Height();
234 SvxFontHeightItem
aSvxFontHeightItem((sal_uInt32
)nFontHeight
,100,CFID_HEIGHT
);
236 FontWeight eWeight
=VCLUnoHelper::ConvertFontWeight(nFontWeight
);
237 FontItalic eItalic
=(FontItalic
)nFontSlant
;
238 FontUnderline eUnderline
=(FontUnderline
)nFontUnderline
;
239 FontStrikeout eStrikeout
=(FontStrikeout
)nFontStrikeout
;
241 SvxWeightItem
aWeightItem(eWeight
,CFID_WEIGHT
);
242 SvxPostureItem
aPostureItem(eItalic
,CFID_POSTURE
);
244 SvxCrossedOutItem
aCrossedOutItem(eStrikeout
,CFID_STRIKEOUT
);
245 SvxWordLineModeItem
aWordLineModeItem(bWordLineMode
, CFID_WORDLINEMODE
);
247 SvxUnderlineItem
aUnderlineItem(eUnderline
,CFID_UNDERLINE
);
248 aUnderlineItem
.SetColor(Color(nTextLineColor
));
250 SvxColorItem
aSvxColorItem(nColor32
,CFID_CHARCOLOR
);
251 SvxLanguageItem
aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE
);
254 SvxCharReliefItem
aFontReliefItem((FontRelief
)nFontRelief
, CFID_RELIEF
);
255 SvxEmphasisMarkItem
aEmphasisMarkitem((FontEmphasisMark
)nFontEmphasisMark
, CFID_EMPHASIS
);
257 _pSet
->Put(aFontItem
, CFID_FONT
);
258 _pSet
->Put(aSvxFontHeightItem
,CFID_HEIGHT
);
259 _pSet
->Put(aWeightItem
, CFID_WEIGHT
);
260 _pSet
->Put(aPostureItem
, CFID_POSTURE
);
261 _pSet
->Put(aLanguageItem
, CFID_LANGUAGE
);
262 _pSet
->Put(aUnderlineItem
,CFID_UNDERLINE
);
263 _pSet
->Put(aCrossedOutItem
,CFID_STRIKEOUT
);
264 _pSet
->Put(aWordLineModeItem
, CFID_WORDLINEMODE
);
265 _pSet
->Put(aSvxColorItem
, CFID_CHARCOLOR
);
266 _pSet
->Put(aFontReliefItem
, CFID_RELIEF
);
267 _pSet
->Put(aEmphasisMarkitem
, CFID_EMPHASIS
);
269 aPropExtractor
.invalidateItem(PROPERTY_FONT_NAME
, CFID_FONT
, *_pSet
);
270 aPropExtractor
.invalidateItem(PROPERTY_FONT_HEIGHT
, CFID_HEIGHT
, *_pSet
);
271 aPropExtractor
.invalidateItem(PROPERTY_FONT_WEIGHT
, CFID_WEIGHT
, *_pSet
, ::com::sun::star::awt::FontWeight::DONTKNOW
== nFontWeight
);
272 aPropExtractor
.invalidateItem(PROPERTY_FONT_SLANT
, CFID_POSTURE
, *_pSet
, ::com::sun::star::awt::FontSlant_DONTKNOW
== nFontSlant
);
273 aPropExtractor
.invalidateItem(PROPERTY_FONT_UNDERLINE
, CFID_UNDERLINE
, *_pSet
, ::com::sun::star::awt::FontUnderline::DONTKNOW
== nFontUnderline
);
274 aPropExtractor
.invalidateItem(PROPERTY_FONT_STRIKEOUT
, CFID_STRIKEOUT
, *_pSet
, ::com::sun::star::awt::FontStrikeout::DONTKNOW
== nFontStrikeout
);
275 aPropExtractor
.invalidateItem(PROPERTY_WORDLINEMODE
, CFID_WORDLINEMODE
, *_pSet
);
276 aPropExtractor
.invalidateItem(PROPERTY_TEXTCOLOR
, CFID_CHARCOLOR
, *_pSet
);
277 aPropExtractor
.invalidateItem(PROPERTY_FONT_RELIEF
, CFID_RELIEF
, *_pSet
);
278 aPropExtractor
.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK
, CFID_EMPHASIS
, *_pSet
);
280 catch (const Exception
&)
282 OSL_FAIL("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
285 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONT
);
286 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT
);
287 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE
);
288 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_POSTURE
);
289 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT
);
291 _pSet
->DisableItem(SID_ATTR_CHAR_CASEMAP
);
292 _pSet
->DisableItem(SID_ATTR_CHAR_CONTOUR
);
293 _pSet
->DisableItem(SID_ATTR_CHAR_SHADOWED
);
297 //------------------------------------------------------------------------
300 void lcl_pushBackPropertyValue( Sequence
< NamedValue
>& _out_properties
, const ::rtl::OUString
& _name
, const Any
& _value
)
302 _out_properties
.realloc( _out_properties
.getLength() + 1 );
303 _out_properties
[ _out_properties
.getLength() - 1 ] = NamedValue( _name
, _value
);
307 //------------------------------------------------------------------------
308 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, Sequence
< NamedValue
>& _out_properties
)
310 _out_properties
.realloc( 0 );
314 // --------------------------
316 SfxItemState eState
= _rSet
.GetItemState(CFID_FONT
);
318 if ( eState
== SFX_ITEM_SET
)
320 const SvxFontItem
& rFontItem
=
321 static_cast<const SvxFontItem
&>(_rSet
.Get(CFID_FONT
));
323 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_NAME
, makeAny(::rtl::OUString(rFontItem
.GetFamilyName())));
324 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STYLENAME
, makeAny(::rtl::OUString(rFontItem
.GetStyleName())));
325 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_FAMILY
, makeAny((sal_Int16
)rFontItem
.GetFamily()));
326 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_CHARSET
, makeAny((sal_Int16
)rFontItem
.GetCharSet()));
329 // --------------------------
331 eState
= _rSet
.GetItemState(CFID_HEIGHT
);
333 if ( eState
== SFX_ITEM_SET
)
335 const SvxFontHeightItem
& rSvxFontHeightItem
=
336 static_cast<const SvxFontHeightItem
&>(_rSet
.Get(CFID_HEIGHT
));
338 float nHeight
= (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem
.GetHeight()), MAP_TWIP
, MAP_POINT
).Height();
339 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_HEIGHT
,makeAny(nHeight
));
343 // --------------------------
345 eState
= _rSet
.GetItemState(CFID_WEIGHT
);
347 if ( eState
== SFX_ITEM_SET
)
349 const SvxWeightItem
& rWeightItem
=
350 static_cast<const SvxWeightItem
&>(_rSet
.Get(CFID_WEIGHT
));
352 float nWeight
= VCLUnoHelper::ConvertFontWeight( rWeightItem
.GetWeight());
353 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_WEIGHT
,makeAny(nWeight
));
356 // --------------------------
358 eState
= _rSet
.GetItemState(CFID_POSTURE
);
360 if ( eState
== SFX_ITEM_SET
)
362 const SvxPostureItem
& rPostureItem
=
363 static_cast<const SvxPostureItem
&>(_rSet
.Get(CFID_POSTURE
));
365 ::com::sun::star::awt::FontSlant eSlant
= (::com::sun::star::awt::FontSlant
)rPostureItem
.GetPosture();
366 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_SLANT
, makeAny((sal_Int16
)eSlant
));
369 // --------------------------
371 eState
= _rSet
.GetItemState(CFID_UNDERLINE
);
373 if ( eState
== SFX_ITEM_SET
)
375 const SvxUnderlineItem
& rUnderlineItem
=
376 static_cast<const SvxUnderlineItem
&>(_rSet
.Get(CFID_UNDERLINE
));
378 sal_Int16 nUnderline
= (sal_Int16
)rUnderlineItem
.GetLineStyle();
379 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_UNDERLINE
,makeAny(nUnderline
));
381 // the text line color is transported in this item, too
382 sal_Int32 nColor
= rUnderlineItem
.GetColor().GetColor();
385 if (COL_AUTO
!= (sal_uInt32
)nColor
)
386 aUnoColor
<<= nColor
;
388 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTLINECOLOR
, aUnoColor
);
391 // --------------------------
393 eState
= _rSet
.GetItemState(CFID_STRIKEOUT
);
395 if ( eState
== SFX_ITEM_SET
)
397 const SvxCrossedOutItem
& rCrossedOutItem
=
398 static_cast<const SvxCrossedOutItem
&>(_rSet
.Get(CFID_STRIKEOUT
));
400 sal_Int16 nStrikeout
= (sal_Int16
)rCrossedOutItem
.GetStrikeout();
401 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STRIKEOUT
,makeAny(nStrikeout
));
405 // --------------------------
406 // font wordline mode
407 eState
= _rSet
.GetItemState(CFID_WORDLINEMODE
);
409 if ( eState
== SFX_ITEM_SET
)
411 const SvxWordLineModeItem
& rWordLineModeItem
=
412 static_cast<const SvxWordLineModeItem
&>(_rSet
.Get(CFID_WORDLINEMODE
));
414 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_WORDLINEMODE
, ::cppu::bool2any(rWordLineModeItem
.GetValue()));
418 // --------------------------
420 eState
= _rSet
.GetItemState(CFID_CHARCOLOR
);
422 if ( eState
== SFX_ITEM_SET
)
424 const SvxColorItem
& rColorItem
=
425 static_cast<const SvxColorItem
&>(_rSet
.Get(CFID_CHARCOLOR
));
427 sal_Int32 nColor
= rColorItem
.GetValue().GetColor();
430 if (COL_AUTO
!= (sal_uInt32
)nColor
)
431 aUnoColor
<<= nColor
;
433 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTCOLOR
, aUnoColor
);
436 // --------------------------
438 eState
= _rSet
.GetItemState(CFID_RELIEF
);
440 if ( eState
== SFX_ITEM_SET
)
442 const SvxCharReliefItem
& rReliefItem
=
443 static_cast<const SvxCharReliefItem
&>(_rSet
.Get(CFID_RELIEF
));
445 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_RELIEF
, makeAny((sal_Int16
)rReliefItem
.GetValue()) );
448 // --------------------------
449 // font emphasis mark
450 eState
= _rSet
.GetItemState(CFID_EMPHASIS
);
452 if ( eState
== SFX_ITEM_SET
)
454 const SvxEmphasisMarkItem
& rEmphMarkItem
=
455 static_cast<const SvxEmphasisMarkItem
&>(_rSet
.Get(CFID_EMPHASIS
));
457 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_EMPHASIS_MARK
, makeAny((sal_Int16
)rEmphMarkItem
.GetEmphasisMark()) );
460 catch (const Exception
& )
462 DBG_UNHANDLED_EXCEPTION();
466 //------------------------------------------------------------------------
467 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, const Reference
< XPropertySet
>& _rxModel
)
469 OSL_ENSURE( _rxModel
.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
473 Sequence
< NamedValue
> aPropertyValues
;
474 translateItemsToProperties( _rSet
, aPropertyValues
);
477 const NamedValue
* propertyValue
= aPropertyValues
.getConstArray();
478 const NamedValue
* propertyValueEnd
= propertyValue
+ aPropertyValues
.getLength();
479 for ( ; propertyValue
!= propertyValueEnd
; ++propertyValue
)
480 _rxModel
->setPropertyValue( propertyValue
->Name
, propertyValue
->Value
);
482 catch( const Exception
& )
484 DBG_UNHANDLED_EXCEPTION();
488 //------------------------------------------------------------------------
489 SfxItemSet
* ControlCharacterDialog::createItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
491 // just to be sure ....
496 // create and initialize the defaults
497 _rppDefaults
= new SfxPoolItem
*[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1];
499 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
501 SfxPoolItem
** pCounter
= _rppDefaults
; // want to modify this without affecting the out param _rppDefaults
502 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_FONT
);
503 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_HEIGHT
);
504 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_WEIGHT
);
505 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_POSTURE
);
506 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE
);
507 *pCounter
++ = new SvxUnderlineItem(aDefaultVCLFont
.GetUnderline(), CFID_UNDERLINE
);
508 *pCounter
++ = new SvxCrossedOutItem(aDefaultVCLFont
.GetStrikeout(), CFID_STRIKEOUT
);
509 *pCounter
++ = new SvxWordLineModeItem(aDefaultVCLFont
.IsWordLineMode(), CFID_WORDLINEMODE
);
510 *pCounter
++ = new SvxColorItem(aDefaultVCLFont
.GetColor(), CFID_CHARCOLOR
);
511 *pCounter
++ = new SvxCharReliefItem(aDefaultVCLFont
.GetRelief(), CFID_RELIEF
);
512 *pCounter
++ = new SvxEmphasisMarkItem(aDefaultVCLFont
.GetEmphasisMark(), CFID_EMPHASIS
);
514 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_CJK_FONT
);
515 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_CJK_HEIGHT
);
516 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_CJK_WEIGHT
);
517 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_CJK_POSTURE
);
518 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE
);
520 *pCounter
++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, CFID_CASEMAP
);
521 *pCounter
++ = new SvxContourItem(sal_False
, CFID_CONTOUR
);
522 *pCounter
++ = new SvxShadowedItem(sal_False
, CFID_SHADOWED
);
524 *pCounter
++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST
);
527 static SfxItemInfo
const aItemInfos
[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1] =
529 { SID_ATTR_CHAR_FONT
, 0 },
530 { SID_ATTR_CHAR_FONTHEIGHT
, 0 },
531 { SID_ATTR_CHAR_WEIGHT
, 0 },
532 { SID_ATTR_CHAR_POSTURE
, 0 },
533 { SID_ATTR_CHAR_LANGUAGE
, 0 },
534 { SID_ATTR_CHAR_UNDERLINE
, 0 },
535 { SID_ATTR_CHAR_STRIKEOUT
, 0 },
536 { SID_ATTR_CHAR_WORDLINEMODE
, 0 },
537 { SID_ATTR_CHAR_COLOR
, 0 },
538 { SID_ATTR_CHAR_RELIEF
, 0 },
539 { SID_ATTR_CHAR_EMPHASISMARK
, 0 },
548 { SID_ATTR_CHAR_FONTLIST
, 0 }
551 _rpPool
= new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID
, CFID_LAST_ITEM_ID
,
552 aItemInfos
, _rppDefaults
);
553 _rpPool
->FreezeIdRanges();
555 // and, finally, the set
556 _rpSet
= new SfxItemSet(*_rpPool
, sal_True
);
561 //-------------------------------------------------------------------------
562 void ControlCharacterDialog::destroyItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
564 // from the pool, get and remember the font list (needs to be deleted)
565 const SvxFontListItem
& rFontListItem
= static_cast<const SvxFontListItem
&>(_rpPool
->GetDefaultItem(CFID_FONTLIST
));
566 const FontList
* pFontList
= rFontListItem
.GetFontList();
568 // _first_ delete the set (refering the pool)
578 _rpPool
->ReleaseDefaults(sal_True
);
579 // the "true" means delete the items, too
580 SfxItemPool::Free(_rpPool
);
584 // reset the defaults ptr
586 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
591 //------------------------------------------------------------------------
592 void ControlCharacterDialog::PageCreated( sal_uInt16 _nId
, SfxTabPage
& _rPage
)
594 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
595 if ( _nId
== TABPAGE_CHARACTERS
) {
596 aSet
.Put (SvxFontListItem(static_cast<const SvxFontListItem
&>(GetInputSetImpl()->Get(CFID_FONTLIST
))));
597 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_HIDE_LANGUAGE
));
598 _rPage
.PageCreated(aSet
);
602 //............................................................................
604 //............................................................................
606 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */