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/helper/vclunohelper.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 #include <vcl/settings.hxx>
65 using namespace ::com::sun::star::uno
;
66 using namespace ::com::sun::star::beans
;
69 //= OFontPropertyExtractor
71 class OFontPropertyExtractor
74 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
76 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>
80 OFontPropertyExtractor( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>&
84 bool getCheckFontProperty(const OUString
& _rPropName
, ::com::sun::star::uno::Any
& _rValue
);
85 OUString
getStringFontProperty(const OUString
& _rPropName
, const OUString
& _rDefault
);
86 sal_Int16
getInt16FontProperty(const OUString
& _rPropName
, const sal_Int16 _nDefault
);
87 sal_Int32
getInt32FontProperty(const OUString
& _rPropName
, const sal_Int32 _nDefault
);
88 float getFloatFontProperty(const OUString
& _rPropName
, const float _nDefault
);
91 const OUString
& _rPropName
,
94 bool _bForceInvalidation
= false);
98 OFontPropertyExtractor::OFontPropertyExtractor(const Reference
< XPropertySet
>& _rxProps
)
99 :m_xPropValueAccess(_rxProps
)
100 ,m_xPropStateAccess(_rxProps
, UNO_QUERY
)
102 OSL_ENSURE(m_xPropValueAccess
.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
106 bool OFontPropertyExtractor::getCheckFontProperty(const OUString
& _rPropName
, Any
& _rValue
)
108 _rValue
= m_xPropValueAccess
->getPropertyValue(_rPropName
);
109 if (m_xPropStateAccess
.is())
110 return PropertyState_DEFAULT_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
);
116 OUString
OFontPropertyExtractor::getStringFontProperty(const OUString
& _rPropName
, const OUString
& _rDefault
)
119 if (getCheckFontProperty(_rPropName
, aValue
))
122 return ::comphelper::getString(aValue
);
126 sal_Int16
OFontPropertyExtractor::getInt16FontProperty(const OUString
& _rPropName
, const sal_Int16 _nDefault
)
129 if (getCheckFontProperty(_rPropName
, aValue
))
132 sal_Int32
nValue(_nDefault
);
133 ::cppu::enum2int(nValue
, aValue
);
134 return (sal_Int16
)nValue
;
138 sal_Int32
OFontPropertyExtractor::getInt32FontProperty(const OUString
& _rPropName
, const sal_Int32 _nDefault
)
141 if (getCheckFontProperty(_rPropName
, aValue
))
144 sal_Int32
nValue(_nDefault
);
145 ::cppu::enum2int(nValue
, aValue
);
150 float OFontPropertyExtractor::getFloatFontProperty(const OUString
& _rPropName
, const float _nDefault
)
153 if (getCheckFontProperty(_rPropName
, aValue
))
156 return ::comphelper::getFloat(aValue
);
160 void OFontPropertyExtractor::invalidateItem(const OUString
& _rPropName
, sal_uInt16 _nItemId
, SfxItemSet
& _rSet
, bool _bForceInvalidation
)
162 if ( _bForceInvalidation
163 || ( m_xPropStateAccess
.is()
164 && (PropertyState_AMBIGUOUS_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
))
167 _rSet
.InvalidateItem(_nItemId
);
171 //= ControlCharacterDialog
174 ControlCharacterDialog::ControlCharacterDialog(vcl::Window
* _pParent
, const SfxItemSet
& _rCoreSet
)
175 : SfxTabDialog(_pParent
, "ControlFontDialog",
176 "modules/spropctrlr/ui/controlfontdialog.ui", &_rCoreSet
)
179 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
180 assert(pFact
); //CreateFactory fail!
181 m_nCharsId
= AddTabPage("font", pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME
), 0 );
182 AddTabPage("fonteffects", pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS
), 0 );
186 ControlCharacterDialog::~ControlCharacterDialog()
191 void ControlCharacterDialog::translatePropertiesToItems(const Reference
< XPropertySet
>& _rxModel
, SfxItemSet
* _pSet
)
193 OSL_ENSURE(_pSet
&& _rxModel
.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
194 if (!_pSet
|| !_rxModel
.is())
199 OFontPropertyExtractor
aPropExtractor(_rxModel
);
201 // some items, which may be in default state, have to be filled with non-void information
202 vcl::Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
203 ::com::sun::star::awt::FontDescriptor aDefaultFont
= VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont
);
205 // get the current properties
206 OUString aFontName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_NAME
, aDefaultFont
.Name
);
207 OUString aFontStyleName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_STYLENAME
, aDefaultFont
.StyleName
);
208 sal_Int16 nFontFamily
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_FAMILY
, aDefaultFont
.Family
);
209 sal_Int16 nFontCharset
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_CHARSET
, aDefaultFont
.CharSet
);
210 float nFontHeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_HEIGHT
, (float)aDefaultFont
.Height
);
211 float nFontWeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_WEIGHT
, aDefaultFont
.Weight
);
212 css::awt::FontSlant nFontSlant
= static_cast<css::awt::FontSlant
>(aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_SLANT
, (sal_Int16
)aDefaultFont
.Slant
));
213 sal_Int16 nFontUnderline
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_UNDERLINE
, aDefaultFont
.Underline
);
214 sal_Int16 nFontStrikeout
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT
, aDefaultFont
.Strikeout
);
216 sal_Int32 nTextLineColor
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTLINECOLOR
, COL_AUTO
);
217 sal_Int16 nFontRelief
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_RELIEF
, (sal_Int16
)aDefaultVCLFont
.GetRelief());
218 sal_Int16 nFontEmphasisMark
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK
, aDefaultVCLFont
.GetEmphasisMark());
221 bool bWordLineMode
= aPropExtractor
.getCheckFontProperty(PROPERTY_WORDLINEMODE
, aValue
) ? aDefaultFont
.WordLineMode
: ::cppu::any2bool(aValue
);
222 sal_Int32 nColor32
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTCOLOR
, 0);
224 // build SfxItems with the values
225 SvxFontItem
aFontItem((FontFamily
)nFontFamily
, aFontName
, aFontStyleName
, PITCH_DONTKNOW
, nFontCharset
, CFID_FONT
);
227 nFontHeight
= (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32
)nFontHeight
), MAP_POINT
, MAP_TWIP
).Height();
228 SvxFontHeightItem
aSvxFontHeightItem((sal_uInt32
)nFontHeight
,100,CFID_HEIGHT
);
230 FontWeight eWeight
=VCLUnoHelper::ConvertFontWeight(nFontWeight
);
231 FontItalic eItalic
=VCLUnoHelper::ConvertFontSlant(nFontSlant
);
232 FontUnderline eUnderline
=(FontUnderline
)nFontUnderline
;
233 FontStrikeout eStrikeout
=(FontStrikeout
)nFontStrikeout
;
235 SvxWeightItem
aWeightItem(eWeight
,CFID_WEIGHT
);
236 SvxPostureItem
aPostureItem(eItalic
,CFID_POSTURE
);
238 SvxCrossedOutItem
aCrossedOutItem(eStrikeout
,CFID_STRIKEOUT
);
239 SvxWordLineModeItem
aWordLineModeItem(bWordLineMode
, CFID_WORDLINEMODE
);
241 SvxUnderlineItem
aUnderlineItem(eUnderline
,CFID_UNDERLINE
);
242 aUnderlineItem
.SetColor(Color(nTextLineColor
));
244 SvxColorItem
aSvxColorItem(nColor32
,CFID_CHARCOLOR
);
245 SvxLanguageItem
aLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE
);
248 SvxCharReliefItem
aFontReliefItem((FontRelief
)nFontRelief
, CFID_RELIEF
);
249 SvxEmphasisMarkItem
aEmphasisMarkitem((FontEmphasisMark
)nFontEmphasisMark
, CFID_EMPHASIS
);
251 _pSet
->Put(aFontItem
, CFID_FONT
);
252 _pSet
->Put(aSvxFontHeightItem
,CFID_HEIGHT
);
253 _pSet
->Put(aWeightItem
, CFID_WEIGHT
);
254 _pSet
->Put(aPostureItem
, CFID_POSTURE
);
255 _pSet
->Put(aLanguageItem
, CFID_LANGUAGE
);
256 _pSet
->Put(aUnderlineItem
,CFID_UNDERLINE
);
257 _pSet
->Put(aCrossedOutItem
,CFID_STRIKEOUT
);
258 _pSet
->Put(aWordLineModeItem
, CFID_WORDLINEMODE
);
259 _pSet
->Put(aSvxColorItem
, CFID_CHARCOLOR
);
260 _pSet
->Put(aFontReliefItem
, CFID_RELIEF
);
261 _pSet
->Put(aEmphasisMarkitem
, CFID_EMPHASIS
);
263 aPropExtractor
.invalidateItem(PROPERTY_FONT_NAME
, CFID_FONT
, *_pSet
);
264 aPropExtractor
.invalidateItem(PROPERTY_FONT_HEIGHT
, CFID_HEIGHT
, *_pSet
);
265 aPropExtractor
.invalidateItem(PROPERTY_FONT_WEIGHT
, CFID_WEIGHT
, *_pSet
, ::com::sun::star::awt::FontWeight::DONTKNOW
== nFontWeight
);
266 aPropExtractor
.invalidateItem(PROPERTY_FONT_SLANT
, CFID_POSTURE
, *_pSet
, ::com::sun::star::awt::FontSlant_DONTKNOW
== nFontSlant
);
267 aPropExtractor
.invalidateItem(PROPERTY_FONT_UNDERLINE
, CFID_UNDERLINE
, *_pSet
, ::com::sun::star::awt::FontUnderline::DONTKNOW
== nFontUnderline
);
268 aPropExtractor
.invalidateItem(PROPERTY_FONT_STRIKEOUT
, CFID_STRIKEOUT
, *_pSet
, ::com::sun::star::awt::FontStrikeout::DONTKNOW
== nFontStrikeout
);
269 aPropExtractor
.invalidateItem(PROPERTY_WORDLINEMODE
, CFID_WORDLINEMODE
, *_pSet
);
270 aPropExtractor
.invalidateItem(PROPERTY_TEXTCOLOR
, CFID_CHARCOLOR
, *_pSet
);
271 aPropExtractor
.invalidateItem(PROPERTY_FONT_RELIEF
, CFID_RELIEF
, *_pSet
);
272 aPropExtractor
.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK
, CFID_EMPHASIS
, *_pSet
);
274 catch (const Exception
&)
276 OSL_FAIL("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
279 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONT
);
280 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT
);
281 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE
);
282 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_POSTURE
);
283 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT
);
285 _pSet
->DisableItem(SID_ATTR_CHAR_CASEMAP
);
286 _pSet
->DisableItem(SID_ATTR_CHAR_CONTOUR
);
287 _pSet
->DisableItem(SID_ATTR_CHAR_SHADOWED
);
294 void lcl_pushBackPropertyValue( Sequence
< NamedValue
>& _out_properties
, const OUString
& _name
, const Any
& _value
)
296 _out_properties
.realloc( _out_properties
.getLength() + 1 );
297 _out_properties
[ _out_properties
.getLength() - 1 ] = NamedValue( _name
, _value
);
302 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, Sequence
< NamedValue
>& _out_properties
)
304 _out_properties
.realloc( 0 );
310 SfxItemState eState
= _rSet
.GetItemState(CFID_FONT
);
312 if ( eState
== SfxItemState::SET
)
314 const SvxFontItem
& rFontItem
=
315 static_cast<const SvxFontItem
&>(_rSet
.Get(CFID_FONT
));
317 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_NAME
, makeAny(OUString(rFontItem
.GetFamilyName())));
318 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STYLENAME
, makeAny(OUString(rFontItem
.GetStyleName())));
319 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_FAMILY
, makeAny((sal_Int16
)rFontItem
.GetFamily()));
320 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_CHARSET
, makeAny((sal_Int16
)rFontItem
.GetCharSet()));
325 eState
= _rSet
.GetItemState(CFID_HEIGHT
);
327 if ( eState
== SfxItemState::SET
)
329 const SvxFontHeightItem
& rSvxFontHeightItem
=
330 static_cast<const SvxFontHeightItem
&>(_rSet
.Get(CFID_HEIGHT
));
332 float nHeight
= (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem
.GetHeight()), MAP_TWIP
, MAP_POINT
).Height();
333 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_HEIGHT
,makeAny(nHeight
));
339 eState
= _rSet
.GetItemState(CFID_WEIGHT
);
341 if ( eState
== SfxItemState::SET
)
343 const SvxWeightItem
& rWeightItem
=
344 static_cast<const SvxWeightItem
&>(_rSet
.Get(CFID_WEIGHT
));
346 float nWeight
= VCLUnoHelper::ConvertFontWeight(rWeightItem
.GetWeight());
347 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_WEIGHT
,makeAny(nWeight
));
352 eState
= _rSet
.GetItemState(CFID_POSTURE
);
354 if ( eState
== SfxItemState::SET
)
356 const SvxPostureItem
& rPostureItem
=
357 static_cast<const SvxPostureItem
&>(_rSet
.Get(CFID_POSTURE
));
359 ::com::sun::star::awt::FontSlant eSlant
= VCLUnoHelper::ConvertFontSlant(rPostureItem
.GetPosture());
360 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_SLANT
, makeAny((sal_Int16
)eSlant
));
365 eState
= _rSet
.GetItemState(CFID_UNDERLINE
);
367 if ( eState
== SfxItemState::SET
)
369 const SvxUnderlineItem
& rUnderlineItem
=
370 static_cast<const SvxUnderlineItem
&>(_rSet
.Get(CFID_UNDERLINE
));
372 sal_Int16 nUnderline
= (sal_Int16
)rUnderlineItem
.GetLineStyle();
373 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_UNDERLINE
,makeAny(nUnderline
));
375 // the text line color is transported in this item, too
376 sal_Int32 nColor
= rUnderlineItem
.GetColor().GetColor();
379 if (COL_AUTO
!= (sal_uInt32
)nColor
)
380 aUnoColor
<<= nColor
;
382 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTLINECOLOR
, aUnoColor
);
387 eState
= _rSet
.GetItemState(CFID_STRIKEOUT
);
389 if ( eState
== SfxItemState::SET
)
391 const SvxCrossedOutItem
& rCrossedOutItem
=
392 static_cast<const SvxCrossedOutItem
&>(_rSet
.Get(CFID_STRIKEOUT
));
394 sal_Int16 nStrikeout
= (sal_Int16
)rCrossedOutItem
.GetStrikeout();
395 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STRIKEOUT
,makeAny(nStrikeout
));
400 // font wordline mode
401 eState
= _rSet
.GetItemState(CFID_WORDLINEMODE
);
403 if ( eState
== SfxItemState::SET
)
405 const SvxWordLineModeItem
& rWordLineModeItem
=
406 static_cast<const SvxWordLineModeItem
&>(_rSet
.Get(CFID_WORDLINEMODE
));
408 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_WORDLINEMODE
, css::uno::makeAny(rWordLineModeItem
.GetValue()));
414 eState
= _rSet
.GetItemState(CFID_CHARCOLOR
);
416 if ( eState
== SfxItemState::SET
)
418 const SvxColorItem
& rColorItem
=
419 static_cast<const SvxColorItem
&>(_rSet
.Get(CFID_CHARCOLOR
));
421 sal_Int32 nColor
= rColorItem
.GetValue().GetColor();
424 if (COL_AUTO
!= (sal_uInt32
)nColor
)
425 aUnoColor
<<= nColor
;
427 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTCOLOR
, aUnoColor
);
432 eState
= _rSet
.GetItemState(CFID_RELIEF
);
434 if ( eState
== SfxItemState::SET
)
436 const SvxCharReliefItem
& rReliefItem
=
437 static_cast<const SvxCharReliefItem
&>(_rSet
.Get(CFID_RELIEF
));
439 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_RELIEF
, makeAny((sal_Int16
)rReliefItem
.GetValue()) );
443 // font emphasis mark
444 eState
= _rSet
.GetItemState(CFID_EMPHASIS
);
446 if ( eState
== SfxItemState::SET
)
448 const SvxEmphasisMarkItem
& rEmphMarkItem
=
449 static_cast<const SvxEmphasisMarkItem
&>(_rSet
.Get(CFID_EMPHASIS
));
451 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_EMPHASIS_MARK
, makeAny((sal_Int16
)rEmphMarkItem
.GetEmphasisMark()) );
454 catch (const Exception
& )
456 DBG_UNHANDLED_EXCEPTION();
461 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, const Reference
< XPropertySet
>& _rxModel
)
463 OSL_ENSURE( _rxModel
.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
467 Sequence
< NamedValue
> aPropertyValues
;
468 translateItemsToProperties( _rSet
, aPropertyValues
);
471 const NamedValue
* propertyValue
= aPropertyValues
.getConstArray();
472 const NamedValue
* propertyValueEnd
= propertyValue
+ aPropertyValues
.getLength();
473 for ( ; propertyValue
!= propertyValueEnd
; ++propertyValue
)
474 _rxModel
->setPropertyValue( propertyValue
->Name
, propertyValue
->Value
);
476 catch( const Exception
& )
478 DBG_UNHANDLED_EXCEPTION();
483 SfxItemSet
* ControlCharacterDialog::createItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
485 // just to be sure ....
490 // create and initialize the defaults
491 _rppDefaults
= new SfxPoolItem
*[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1];
493 vcl::Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
495 SfxPoolItem
** pCounter
= _rppDefaults
; // want to modify this without affecting the out param _rppDefaults
496 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_FONT
);
497 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_HEIGHT
);
498 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_WEIGHT
);
499 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_POSTURE
);
500 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE
);
501 *pCounter
++ = new SvxUnderlineItem(aDefaultVCLFont
.GetUnderline(), CFID_UNDERLINE
);
502 *pCounter
++ = new SvxCrossedOutItem(aDefaultVCLFont
.GetStrikeout(), CFID_STRIKEOUT
);
503 *pCounter
++ = new SvxWordLineModeItem(aDefaultVCLFont
.IsWordLineMode(), CFID_WORDLINEMODE
);
504 *pCounter
++ = new SvxColorItem(aDefaultVCLFont
.GetColor(), CFID_CHARCOLOR
);
505 *pCounter
++ = new SvxCharReliefItem(aDefaultVCLFont
.GetRelief(), CFID_RELIEF
);
506 *pCounter
++ = new SvxEmphasisMarkItem(aDefaultVCLFont
.GetEmphasisMark(), CFID_EMPHASIS
);
508 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_CJK_FONT
);
509 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_CJK_HEIGHT
);
510 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_CJK_WEIGHT
);
511 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_CJK_POSTURE
);
512 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_CJK_LANGUAGE
);
514 *pCounter
++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, CFID_CASEMAP
);
515 *pCounter
++ = new SvxContourItem(false, CFID_CONTOUR
);
516 *pCounter
++ = new SvxShadowedItem(false, CFID_SHADOWED
);
518 *pCounter
++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST
);
521 static SfxItemInfo
const aItemInfos
[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1] =
523 { SID_ATTR_CHAR_FONT
, SfxItemPoolFlags::NONE
},
524 { SID_ATTR_CHAR_FONTHEIGHT
, SfxItemPoolFlags::NONE
},
525 { SID_ATTR_CHAR_WEIGHT
, SfxItemPoolFlags::NONE
},
526 { SID_ATTR_CHAR_POSTURE
, SfxItemPoolFlags::NONE
},
527 { SID_ATTR_CHAR_LANGUAGE
, SfxItemPoolFlags::NONE
},
528 { SID_ATTR_CHAR_UNDERLINE
, SfxItemPoolFlags::NONE
},
529 { SID_ATTR_CHAR_STRIKEOUT
, SfxItemPoolFlags::NONE
},
530 { SID_ATTR_CHAR_WORDLINEMODE
, SfxItemPoolFlags::NONE
},
531 { SID_ATTR_CHAR_COLOR
, SfxItemPoolFlags::NONE
},
532 { SID_ATTR_CHAR_RELIEF
, SfxItemPoolFlags::NONE
},
533 { SID_ATTR_CHAR_EMPHASISMARK
, SfxItemPoolFlags::NONE
},
534 { 0, SfxItemPoolFlags::NONE
},
535 { 0, SfxItemPoolFlags::NONE
},
536 { 0, SfxItemPoolFlags::NONE
},
537 { 0, SfxItemPoolFlags::NONE
},
538 { 0, SfxItemPoolFlags::NONE
},
539 { 0, SfxItemPoolFlags::NONE
},
540 { 0, SfxItemPoolFlags::NONE
},
541 { 0, SfxItemPoolFlags::NONE
},
542 { SID_ATTR_CHAR_FONTLIST
, SfxItemPoolFlags::NONE
}
545 _rpPool
= new SfxItemPool(OUString("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID
, CFID_LAST_ITEM_ID
,
546 aItemInfos
, _rppDefaults
);
547 _rpPool
->FreezeIdRanges();
549 // and, finally, the set
550 _rpSet
= new SfxItemSet(*_rpPool
, true);
556 void ControlCharacterDialog::destroyItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
558 // from the pool, get and remember the font list (needs to be deleted)
559 const SvxFontListItem
& rFontListItem
= static_cast<const SvxFontListItem
&>(_rpPool
->GetDefaultItem(CFID_FONTLIST
));
560 const FontList
* pFontList
= rFontListItem
.GetFontList();
562 // _first_ delete the set (referring the pool)
570 _rpPool
->ReleaseDefaults(true);
571 // the "true" means delete the items, too
572 SfxItemPool::Free(_rpPool
);
575 // reset the defaults ptr
577 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
583 void ControlCharacterDialog::PageCreated( sal_uInt16 _nId
, SfxTabPage
& _rPage
)
585 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
586 if ( _nId
== m_nCharsId
) {
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
);
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */