1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sfx2/sfxsids.hrc>
21 #include "fontdialog.hxx"
22 #include "formresid.hrc"
23 #include "modulepcr.hxx"
24 #include "formlocalid.hrc"
25 #include <vcl/svapp.hxx>
26 #include <toolkit/unohlp.hxx>
27 #include <comphelper/types.hxx>
28 #include <comphelper/extract.hxx>
29 #include <com/sun/star/awt/FontDescriptor.hpp>
30 #include <com/sun/star/awt/FontWeight.hpp>
31 #include <com/sun/star/awt/FontSlant.hpp>
32 #include <com/sun/star/awt/FontUnderline.hpp>
33 #include <com/sun/star/awt/FontStrikeout.hpp>
34 #include "formstrings.hxx"
35 #include "fontitemids.hxx"
36 #include <editeng/charreliefitem.hxx>
37 #include <editeng/emphasismarkitem.hxx>
38 #include <editeng/fontitem.hxx>
39 #include <editeng/fhgtitem.hxx>
40 #include <editeng/postitem.hxx>
41 #include <editeng/wghtitem.hxx>
42 #include <editeng/udlnitem.hxx>
43 #include <editeng/crossedoutitem.hxx>
44 #include <editeng/colritem.hxx>
45 #include <editeng/langitem.hxx>
46 #include <editeng/wrlmitem.hxx>
47 #include <editeng/cmapitem.hxx>
48 #include <editeng/contouritem.hxx>
49 #include <editeng/shdditem.hxx>
50 #include <editeng/flstitem.hxx>
51 #include <svtools/ctrltool.hxx>
52 #include <tools/diagnose_ex.h>
53 #include <com/sun/star/beans/XPropertyState.hpp>
54 #include <svx/svxids.hrc>
55 #include <svx/svxdlg.hxx>
56 #include <svx/dialogs.hrc>
57 #include <svx/flagsdef.hxx>
58 //............................................................................
61 //............................................................................
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::beans
;
66 //========================================================================
67 //= OFontPropertyExtractor
68 //========================================================================
69 class OFontPropertyExtractor
72 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
74 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>
78 OFontPropertyExtractor( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>&
82 sal_Bool
getCheckFontProperty(const OUString
& _rPropName
, ::com::sun::star::uno::Any
& _rValue
);
83 OUString
getStringFontProperty(const OUString
& _rPropName
, const OUString
& _rDefault
);
84 sal_Int16
getInt16FontProperty(const OUString
& _rPropName
, const sal_Int16 _nDefault
);
85 sal_Int32
getInt32FontProperty(const OUString
& _rPropName
, const sal_Int32 _nDefault
);
86 float getFloatFontProperty(const OUString
& _rPropName
, const float _nDefault
);
89 const OUString
& _rPropName
,
92 sal_Bool _bForceInvalidation
= sal_False
);
95 //------------------------------------------------------------------------
96 OFontPropertyExtractor::OFontPropertyExtractor(const Reference
< XPropertySet
>& _rxProps
)
97 :m_xPropValueAccess(_rxProps
)
98 ,m_xPropStateAccess(_rxProps
, UNO_QUERY
)
100 OSL_ENSURE(m_xPropValueAccess
.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
103 //------------------------------------------------------------------------
104 sal_Bool
OFontPropertyExtractor::getCheckFontProperty(const OUString
& _rPropName
, Any
& _rValue
)
106 _rValue
= m_xPropValueAccess
->getPropertyValue(_rPropName
);
107 if (m_xPropStateAccess
.is())
108 return PropertyState_DEFAULT_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
);
113 //------------------------------------------------------------------------
114 OUString
OFontPropertyExtractor::getStringFontProperty(const OUString
& _rPropName
, const OUString
& _rDefault
)
117 if (getCheckFontProperty(_rPropName
, aValue
))
120 return ::comphelper::getString(aValue
);
123 //------------------------------------------------------------------------
124 sal_Int16
OFontPropertyExtractor::getInt16FontProperty(const OUString
& _rPropName
, const sal_Int16 _nDefault
)
127 if (getCheckFontProperty(_rPropName
, aValue
))
130 sal_Int32
nValue(_nDefault
);
131 ::cppu::enum2int(nValue
, aValue
);
132 return (sal_Int16
)nValue
;
135 //------------------------------------------------------------------------
136 sal_Int32
OFontPropertyExtractor::getInt32FontProperty(const OUString
& _rPropName
, const sal_Int32 _nDefault
)
139 if (getCheckFontProperty(_rPropName
, aValue
))
142 sal_Int32
nValue(_nDefault
);
143 ::cppu::enum2int(nValue
, aValue
);
147 //------------------------------------------------------------------------
148 float OFontPropertyExtractor::getFloatFontProperty(const OUString
& _rPropName
, const float _nDefault
)
151 if (getCheckFontProperty(_rPropName
, aValue
))
154 return ::comphelper::getFloat(aValue
);
157 //------------------------------------------------------------------------
158 void OFontPropertyExtractor::invalidateItem(const OUString
& _rPropName
, sal_uInt16 _nItemId
, SfxItemSet
& _rSet
, sal_Bool _bForceInvalidation
)
160 if ( _bForceInvalidation
161 || ( m_xPropStateAccess
.is()
162 && (PropertyState_AMBIGUOUS_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
))
165 _rSet
.InvalidateItem(_nItemId
);
168 //========================================================================
169 //= ControlCharacterDialog
170 //========================================================================
171 //------------------------------------------------------------------------
172 ControlCharacterDialog::ControlCharacterDialog(Window
* _pParent
, const SfxItemSet
& _rCoreSet
)
173 :SfxTabDialog(_pParent
, PcrRes(RID_TABDLG_FONTDIALOG
), &_rCoreSet
)
176 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
177 DBG_ASSERT(pFact
, "CreateFactory fail!");
178 AddTabPage(TABPAGE_CHARACTERS
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME
), 0 );
179 AddTabPage(TABPAGE_CHARACTERS_EXT
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS
), 0 );
182 //------------------------------------------------------------------------
183 ControlCharacterDialog::~ControlCharacterDialog()
187 //------------------------------------------------------------------------
188 void ControlCharacterDialog::translatePropertiesToItems(const Reference
< XPropertySet
>& _rxModel
, SfxItemSet
* _pSet
)
190 OSL_ENSURE(_pSet
&& _rxModel
.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
191 if (!_pSet
|| !_rxModel
.is())
196 OFontPropertyExtractor
aPropExtractor(_rxModel
);
198 // some items, which may be in default state, have to be filled with non-void information
199 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
200 ::com::sun::star::awt::FontDescriptor aDefaultFont
= VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont
);
202 // get the current properties
203 OUString aFontName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_NAME
, aDefaultFont
.Name
);
204 OUString aFontStyleName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_STYLENAME
, aDefaultFont
.StyleName
);
205 sal_Int16 nFontFamily
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_FAMILY
, aDefaultFont
.Family
);
206 sal_Int16 nFontCharset
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_CHARSET
, aDefaultFont
.CharSet
);
207 float nFontHeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_HEIGHT
, (float)aDefaultFont
.Height
);
208 float nFontWeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_WEIGHT
, aDefaultFont
.Weight
);
209 sal_Int16 nFontSlant
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_SLANT
, (sal_Int16
)aDefaultFont
.Slant
);
210 sal_Int16 nFontUnderline
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_UNDERLINE
, aDefaultFont
.Underline
);
211 sal_Int16 nFontStrikeout
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT
, aDefaultFont
.Strikeout
);
213 sal_Int32 nTextLineColor
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTLINECOLOR
, COL_AUTO
);
214 sal_Int16 nFontRelief
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_RELIEF
, (sal_Int16
)aDefaultVCLFont
.GetRelief());
215 sal_Int16 nFontEmphasisMark
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK
, aDefaultVCLFont
.GetEmphasisMark());
218 sal_Bool bWordLineMode
= aPropExtractor
.getCheckFontProperty(PROPERTY_WORDLINEMODE
, aValue
) ? aDefaultFont
.WordLineMode
: ::cppu::any2bool(aValue
);
219 sal_Int32 nColor32
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTCOLOR
, 0);
221 // build SfxItems with the values
222 SvxFontItem
aFontItem((FontFamily
)nFontFamily
, aFontName
, aFontStyleName
, PITCH_DONTKNOW
, nFontCharset
, CFID_FONT
);
224 nFontHeight
= (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32
)nFontHeight
), MAP_POINT
, MAP_TWIP
).Height();
225 SvxFontHeightItem
aSvxFontHeightItem((sal_uInt32
)nFontHeight
,100,CFID_HEIGHT
);
227 FontWeight eWeight
=VCLUnoHelper::ConvertFontWeight(nFontWeight
);
228 FontItalic eItalic
=(FontItalic
)nFontSlant
;
229 FontUnderline eUnderline
=(FontUnderline
)nFontUnderline
;
230 FontStrikeout eStrikeout
=(FontStrikeout
)nFontStrikeout
;
232 SvxWeightItem
aWeightItem(eWeight
,CFID_WEIGHT
);
233 SvxPostureItem
aPostureItem(eItalic
,CFID_POSTURE
);
235 SvxCrossedOutItem
aCrossedOutItem(eStrikeout
,CFID_STRIKEOUT
);
236 SvxWordLineModeItem
aWordLineModeItem(bWordLineMode
, CFID_WORDLINEMODE
);
238 SvxUnderlineItem
aUnderlineItem(eUnderline
,CFID_UNDERLINE
);
239 aUnderlineItem
.SetColor(Color(nTextLineColor
));
241 SvxColorItem
aSvxColorItem(nColor32
,CFID_CHARCOLOR
);
242 SvxLanguageItem
aLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE
);
245 SvxCharReliefItem
aFontReliefItem((FontRelief
)nFontRelief
, CFID_RELIEF
);
246 SvxEmphasisMarkItem
aEmphasisMarkitem((FontEmphasisMark
)nFontEmphasisMark
, CFID_EMPHASIS
);
248 _pSet
->Put(aFontItem
, CFID_FONT
);
249 _pSet
->Put(aSvxFontHeightItem
,CFID_HEIGHT
);
250 _pSet
->Put(aWeightItem
, CFID_WEIGHT
);
251 _pSet
->Put(aPostureItem
, CFID_POSTURE
);
252 _pSet
->Put(aLanguageItem
, CFID_LANGUAGE
);
253 _pSet
->Put(aUnderlineItem
,CFID_UNDERLINE
);
254 _pSet
->Put(aCrossedOutItem
,CFID_STRIKEOUT
);
255 _pSet
->Put(aWordLineModeItem
, CFID_WORDLINEMODE
);
256 _pSet
->Put(aSvxColorItem
, CFID_CHARCOLOR
);
257 _pSet
->Put(aFontReliefItem
, CFID_RELIEF
);
258 _pSet
->Put(aEmphasisMarkitem
, CFID_EMPHASIS
);
260 aPropExtractor
.invalidateItem(PROPERTY_FONT_NAME
, CFID_FONT
, *_pSet
);
261 aPropExtractor
.invalidateItem(PROPERTY_FONT_HEIGHT
, CFID_HEIGHT
, *_pSet
);
262 aPropExtractor
.invalidateItem(PROPERTY_FONT_WEIGHT
, CFID_WEIGHT
, *_pSet
, ::com::sun::star::awt::FontWeight::DONTKNOW
== nFontWeight
);
263 aPropExtractor
.invalidateItem(PROPERTY_FONT_SLANT
, CFID_POSTURE
, *_pSet
, ::com::sun::star::awt::FontSlant_DONTKNOW
== nFontSlant
);
264 aPropExtractor
.invalidateItem(PROPERTY_FONT_UNDERLINE
, CFID_UNDERLINE
, *_pSet
, ::com::sun::star::awt::FontUnderline::DONTKNOW
== nFontUnderline
);
265 aPropExtractor
.invalidateItem(PROPERTY_FONT_STRIKEOUT
, CFID_STRIKEOUT
, *_pSet
, ::com::sun::star::awt::FontStrikeout::DONTKNOW
== nFontStrikeout
);
266 aPropExtractor
.invalidateItem(PROPERTY_WORDLINEMODE
, CFID_WORDLINEMODE
, *_pSet
);
267 aPropExtractor
.invalidateItem(PROPERTY_TEXTCOLOR
, CFID_CHARCOLOR
, *_pSet
);
268 aPropExtractor
.invalidateItem(PROPERTY_FONT_RELIEF
, CFID_RELIEF
, *_pSet
);
269 aPropExtractor
.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK
, CFID_EMPHASIS
, *_pSet
);
271 catch (const Exception
&)
273 OSL_FAIL("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
276 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONT
);
277 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT
);
278 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE
);
279 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_POSTURE
);
280 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT
);
282 _pSet
->DisableItem(SID_ATTR_CHAR_CASEMAP
);
283 _pSet
->DisableItem(SID_ATTR_CHAR_CONTOUR
);
284 _pSet
->DisableItem(SID_ATTR_CHAR_SHADOWED
);
288 //------------------------------------------------------------------------
291 void lcl_pushBackPropertyValue( Sequence
< NamedValue
>& _out_properties
, const OUString
& _name
, const Any
& _value
)
293 _out_properties
.realloc( _out_properties
.getLength() + 1 );
294 _out_properties
[ _out_properties
.getLength() - 1 ] = NamedValue( _name
, _value
);
298 //------------------------------------------------------------------------
299 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, Sequence
< NamedValue
>& _out_properties
)
301 _out_properties
.realloc( 0 );
305 // --------------------------
307 SfxItemState eState
= _rSet
.GetItemState(CFID_FONT
);
309 if ( eState
== SFX_ITEM_SET
)
311 const SvxFontItem
& rFontItem
=
312 static_cast<const SvxFontItem
&>(_rSet
.Get(CFID_FONT
));
314 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_NAME
, makeAny(OUString(rFontItem
.GetFamilyName())));
315 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STYLENAME
, makeAny(OUString(rFontItem
.GetStyleName())));
316 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_FAMILY
, makeAny((sal_Int16
)rFontItem
.GetFamily()));
317 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_CHARSET
, makeAny((sal_Int16
)rFontItem
.GetCharSet()));
320 // --------------------------
322 eState
= _rSet
.GetItemState(CFID_HEIGHT
);
324 if ( eState
== SFX_ITEM_SET
)
326 const SvxFontHeightItem
& rSvxFontHeightItem
=
327 static_cast<const SvxFontHeightItem
&>(_rSet
.Get(CFID_HEIGHT
));
329 float nHeight
= (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem
.GetHeight()), MAP_TWIP
, MAP_POINT
).Height();
330 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_HEIGHT
,makeAny(nHeight
));
334 // --------------------------
336 eState
= _rSet
.GetItemState(CFID_WEIGHT
);
338 if ( eState
== SFX_ITEM_SET
)
340 const SvxWeightItem
& rWeightItem
=
341 static_cast<const SvxWeightItem
&>(_rSet
.Get(CFID_WEIGHT
));
343 float nWeight
= VCLUnoHelper::ConvertFontWeight( rWeightItem
.GetWeight());
344 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_WEIGHT
,makeAny(nWeight
));
347 // --------------------------
349 eState
= _rSet
.GetItemState(CFID_POSTURE
);
351 if ( eState
== SFX_ITEM_SET
)
353 const SvxPostureItem
& rPostureItem
=
354 static_cast<const SvxPostureItem
&>(_rSet
.Get(CFID_POSTURE
));
356 ::com::sun::star::awt::FontSlant eSlant
= (::com::sun::star::awt::FontSlant
)rPostureItem
.GetPosture();
357 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_SLANT
, makeAny((sal_Int16
)eSlant
));
360 // --------------------------
362 eState
= _rSet
.GetItemState(CFID_UNDERLINE
);
364 if ( eState
== SFX_ITEM_SET
)
366 const SvxUnderlineItem
& rUnderlineItem
=
367 static_cast<const SvxUnderlineItem
&>(_rSet
.Get(CFID_UNDERLINE
));
369 sal_Int16 nUnderline
= (sal_Int16
)rUnderlineItem
.GetLineStyle();
370 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_UNDERLINE
,makeAny(nUnderline
));
372 // the text line color is transported in this item, too
373 sal_Int32 nColor
= rUnderlineItem
.GetColor().GetColor();
376 if (COL_AUTO
!= (sal_uInt32
)nColor
)
377 aUnoColor
<<= nColor
;
379 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTLINECOLOR
, aUnoColor
);
382 // --------------------------
384 eState
= _rSet
.GetItemState(CFID_STRIKEOUT
);
386 if ( eState
== SFX_ITEM_SET
)
388 const SvxCrossedOutItem
& rCrossedOutItem
=
389 static_cast<const SvxCrossedOutItem
&>(_rSet
.Get(CFID_STRIKEOUT
));
391 sal_Int16 nStrikeout
= (sal_Int16
)rCrossedOutItem
.GetStrikeout();
392 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STRIKEOUT
,makeAny(nStrikeout
));
396 // --------------------------
397 // font wordline mode
398 eState
= _rSet
.GetItemState(CFID_WORDLINEMODE
);
400 if ( eState
== SFX_ITEM_SET
)
402 const SvxWordLineModeItem
& rWordLineModeItem
=
403 static_cast<const SvxWordLineModeItem
&>(_rSet
.Get(CFID_WORDLINEMODE
));
405 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_WORDLINEMODE
, ::cppu::bool2any(rWordLineModeItem
.GetValue()));
409 // --------------------------
411 eState
= _rSet
.GetItemState(CFID_CHARCOLOR
);
413 if ( eState
== SFX_ITEM_SET
)
415 const SvxColorItem
& rColorItem
=
416 static_cast<const SvxColorItem
&>(_rSet
.Get(CFID_CHARCOLOR
));
418 sal_Int32 nColor
= rColorItem
.GetValue().GetColor();
421 if (COL_AUTO
!= (sal_uInt32
)nColor
)
422 aUnoColor
<<= nColor
;
424 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTCOLOR
, aUnoColor
);
427 // --------------------------
429 eState
= _rSet
.GetItemState(CFID_RELIEF
);
431 if ( eState
== SFX_ITEM_SET
)
433 const SvxCharReliefItem
& rReliefItem
=
434 static_cast<const SvxCharReliefItem
&>(_rSet
.Get(CFID_RELIEF
));
436 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_RELIEF
, makeAny((sal_Int16
)rReliefItem
.GetValue()) );
439 // --------------------------
440 // font emphasis mark
441 eState
= _rSet
.GetItemState(CFID_EMPHASIS
);
443 if ( eState
== SFX_ITEM_SET
)
445 const SvxEmphasisMarkItem
& rEmphMarkItem
=
446 static_cast<const SvxEmphasisMarkItem
&>(_rSet
.Get(CFID_EMPHASIS
));
448 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_EMPHASIS_MARK
, makeAny((sal_Int16
)rEmphMarkItem
.GetEmphasisMark()) );
451 catch (const Exception
& )
453 DBG_UNHANDLED_EXCEPTION();
457 //------------------------------------------------------------------------
458 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, const Reference
< XPropertySet
>& _rxModel
)
460 OSL_ENSURE( _rxModel
.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
464 Sequence
< NamedValue
> aPropertyValues
;
465 translateItemsToProperties( _rSet
, aPropertyValues
);
468 const NamedValue
* propertyValue
= aPropertyValues
.getConstArray();
469 const NamedValue
* propertyValueEnd
= propertyValue
+ aPropertyValues
.getLength();
470 for ( ; propertyValue
!= propertyValueEnd
; ++propertyValue
)
471 _rxModel
->setPropertyValue( propertyValue
->Name
, propertyValue
->Value
);
473 catch( const Exception
& )
475 DBG_UNHANDLED_EXCEPTION();
479 //------------------------------------------------------------------------
480 SfxItemSet
* ControlCharacterDialog::createItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
482 // just to be sure ....
487 // create and initialize the defaults
488 _rppDefaults
= new SfxPoolItem
*[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1];
490 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
492 SfxPoolItem
** pCounter
= _rppDefaults
; // want to modify this without affecting the out param _rppDefaults
493 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_FONT
);
494 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_HEIGHT
);
495 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_WEIGHT
);
496 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_POSTURE
);
497 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE
);
498 *pCounter
++ = new SvxUnderlineItem(aDefaultVCLFont
.GetUnderline(), CFID_UNDERLINE
);
499 *pCounter
++ = new SvxCrossedOutItem(aDefaultVCLFont
.GetStrikeout(), CFID_STRIKEOUT
);
500 *pCounter
++ = new SvxWordLineModeItem(aDefaultVCLFont
.IsWordLineMode(), CFID_WORDLINEMODE
);
501 *pCounter
++ = new SvxColorItem(aDefaultVCLFont
.GetColor(), CFID_CHARCOLOR
);
502 *pCounter
++ = new SvxCharReliefItem(aDefaultVCLFont
.GetRelief(), CFID_RELIEF
);
503 *pCounter
++ = new SvxEmphasisMarkItem(aDefaultVCLFont
.GetEmphasisMark(), CFID_EMPHASIS
);
505 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_CJK_FONT
);
506 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_CJK_HEIGHT
);
507 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_CJK_WEIGHT
);
508 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_CJK_POSTURE
);
509 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_CJK_LANGUAGE
);
511 *pCounter
++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, CFID_CASEMAP
);
512 *pCounter
++ = new SvxContourItem(sal_False
, CFID_CONTOUR
);
513 *pCounter
++ = new SvxShadowedItem(sal_False
, CFID_SHADOWED
);
515 *pCounter
++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST
);
518 static SfxItemInfo
const aItemInfos
[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1] =
520 { SID_ATTR_CHAR_FONT
, 0 },
521 { SID_ATTR_CHAR_FONTHEIGHT
, 0 },
522 { SID_ATTR_CHAR_WEIGHT
, 0 },
523 { SID_ATTR_CHAR_POSTURE
, 0 },
524 { SID_ATTR_CHAR_LANGUAGE
, 0 },
525 { SID_ATTR_CHAR_UNDERLINE
, 0 },
526 { SID_ATTR_CHAR_STRIKEOUT
, 0 },
527 { SID_ATTR_CHAR_WORDLINEMODE
, 0 },
528 { SID_ATTR_CHAR_COLOR
, 0 },
529 { SID_ATTR_CHAR_RELIEF
, 0 },
530 { SID_ATTR_CHAR_EMPHASISMARK
, 0 },
539 { SID_ATTR_CHAR_FONTLIST
, 0 }
542 _rpPool
= new SfxItemPool(OUString("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID
, CFID_LAST_ITEM_ID
,
543 aItemInfos
, _rppDefaults
);
544 _rpPool
->FreezeIdRanges();
546 // and, finally, the set
547 _rpSet
= new SfxItemSet(*_rpPool
, sal_True
);
552 //-------------------------------------------------------------------------
553 void ControlCharacterDialog::destroyItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
555 // from the pool, get and remember the font list (needs to be deleted)
556 const SvxFontListItem
& rFontListItem
= static_cast<const SvxFontListItem
&>(_rpPool
->GetDefaultItem(CFID_FONTLIST
));
557 const FontList
* pFontList
= rFontListItem
.GetFontList();
559 // _first_ delete the set (refering the pool)
569 _rpPool
->ReleaseDefaults(sal_True
);
570 // the "true" means delete the items, too
571 SfxItemPool::Free(_rpPool
);
575 // reset the defaults ptr
577 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
582 //------------------------------------------------------------------------
583 void ControlCharacterDialog::PageCreated( sal_uInt16 _nId
, SfxTabPage
& _rPage
)
585 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
586 if ( _nId
== TABPAGE_CHARACTERS
) {
587 aSet
.Put (SvxFontListItem(static_cast<const SvxFontListItem
&>(GetInputSetImpl()->Get(CFID_FONTLIST
))));
588 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_HIDE_LANGUAGE
));
589 _rPage
.PageCreated(aSet
);
593 //............................................................................
595 //............................................................................
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */