1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fontdialog.cxx,v $
10 * $Revision: 1.19.80.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <sfx2/sfxsids.hrc>
34 #include "fontdialog.hxx"
35 #ifndef EXTENSIONS_PROPRESID_HRC
36 #include "formresid.hrc"
38 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
39 #include "modulepcr.hxx"
41 #ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
42 #include "formlocalid.hrc"
44 #include <vcl/svapp.hxx>
45 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
46 #include <toolkit/unohlp.hxx>
48 #include <comphelper/types.hxx>
49 #include <comphelper/extract.hxx>
50 #include <com/sun/star/awt/FontDescriptor.hpp>
51 #include <com/sun/star/awt/FontWeight.hpp>
52 #include <com/sun/star/awt/FontSlant.hpp>
53 #include <com/sun/star/awt/FontUnderline.hpp>
54 #include <com/sun/star/awt/FontStrikeout.hpp>
55 #include "formstrings.hxx"
56 #include "fontitemids.hxx"
57 #include <svx/charreliefitem.hxx>
58 #ifndef _SVX_EMPHITEM_HXX
59 #include <svx/emphitem.hxx>
61 #include <svx/fontitem.hxx>
62 #include <svx/fhgtitem.hxx>
63 #include <svx/postitem.hxx>
64 #include <svx/wghtitem.hxx>
65 #include <svx/udlnitem.hxx>
66 #include <svx/crsditem.hxx>
67 #include <svx/colritem.hxx>
68 #include <svx/flstitem.hxx>
69 #include <svx/langitem.hxx>
70 #include <svx/wrlmitem.hxx>
71 #include <svx/cmapitem.hxx>
72 #include <svx/cntritem.hxx>
73 #include <svx/shdditem.hxx>
74 #include <svx/flstitem.hxx>
75 #include <svtools/ctrltool.hxx>
76 #include <tools/diagnose_ex.h>
77 #include <com/sun/star/beans/XPropertyState.hpp>
78 #ifndef _SVX_SVXIDS_HRC
79 #include <svx/svxids.hrc> //CHINA001
81 #include <svx/svxdlg.hxx> //CHINA001
82 #include <svx/dialogs.hrc> //CHINA001
83 #include <svx/flagsdef.hxx>
84 //............................................................................
87 //............................................................................
89 using namespace ::com::sun::star::uno
;
90 using namespace ::com::sun::star::beans
;
92 //========================================================================
93 //= OFontPropertyExtractor
94 //========================================================================
95 class OFontPropertyExtractor
98 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
100 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyState
>
104 OFontPropertyExtractor( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>&
108 sal_Bool
getCheckFontProperty(const ::rtl::OUString
& _rPropName
, ::com::sun::star::uno::Any
& _rValue
);
109 ::rtl::OUString
getStringFontProperty(const ::rtl::OUString
& _rPropName
, const ::rtl::OUString
& _rDefault
);
110 sal_Int16
getInt16FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int16 _nDefault
);
111 sal_Int32
getInt32FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int32 _nDefault
);
112 float getFloatFontProperty(const ::rtl::OUString
& _rPropName
, const float _nDefault
);
115 const ::rtl::OUString
& _rPropName
,
118 sal_Bool _bForceInvalidation
= sal_False
);
121 //------------------------------------------------------------------------
122 OFontPropertyExtractor::OFontPropertyExtractor(const Reference
< XPropertySet
>& _rxProps
)
123 :m_xPropValueAccess(_rxProps
)
124 ,m_xPropStateAccess(_rxProps
, UNO_QUERY
)
126 OSL_ENSURE(m_xPropValueAccess
.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
129 //------------------------------------------------------------------------
130 sal_Bool
OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString
& _rPropName
, Any
& _rValue
)
132 _rValue
= m_xPropValueAccess
->getPropertyValue(_rPropName
);
133 if (m_xPropStateAccess
.is())
134 return PropertyState_DEFAULT_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
);
139 //------------------------------------------------------------------------
140 ::rtl::OUString
OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString
& _rPropName
, const ::rtl::OUString
& _rDefault
)
143 if (getCheckFontProperty(_rPropName
, aValue
))
146 return ::comphelper::getString(aValue
);
149 //------------------------------------------------------------------------
150 sal_Int16
OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int16 _nDefault
)
153 if (getCheckFontProperty(_rPropName
, aValue
))
156 sal_Int32
nValue(_nDefault
);
157 ::cppu::enum2int(nValue
, aValue
);
158 return (sal_Int16
)nValue
;
161 //------------------------------------------------------------------------
162 sal_Int32
OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString
& _rPropName
, const sal_Int32 _nDefault
)
165 if (getCheckFontProperty(_rPropName
, aValue
))
168 sal_Int32
nValue(_nDefault
);
169 ::cppu::enum2int(nValue
, aValue
);
173 //------------------------------------------------------------------------
174 float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString
& _rPropName
, const float _nDefault
)
177 if (getCheckFontProperty(_rPropName
, aValue
))
180 return ::comphelper::getFloat(aValue
);
183 //------------------------------------------------------------------------
184 void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString
& _rPropName
, sal_uInt16 _nItemId
, SfxItemSet
& _rSet
, sal_Bool _bForceInvalidation
)
186 if ( _bForceInvalidation
187 || ( m_xPropStateAccess
.is()
188 && (PropertyState_AMBIGUOUS_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
))
191 _rSet
.InvalidateItem(_nItemId
);
194 //========================================================================
195 //= ControlCharacterDialog
196 //========================================================================
197 //------------------------------------------------------------------------
198 ControlCharacterDialog::ControlCharacterDialog(Window
* _pParent
, const SfxItemSet
& _rCoreSet
)
199 :SfxTabDialog(_pParent
, PcrRes(RID_TABDLG_FONTDIALOG
), &_rCoreSet
)
202 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
203 DBG_ASSERT(pFact
, "CreateFactory fail!");
204 AddTabPage(TABPAGE_CHARACTERS
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME
), 0 );
205 AddTabPage(TABPAGE_CHARACTERS_EXT
, pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS
), 0 );
208 //------------------------------------------------------------------------
209 ControlCharacterDialog::~ControlCharacterDialog()
213 //------------------------------------------------------------------------
214 void ControlCharacterDialog::translatePropertiesToItems(const Reference
< XPropertySet
>& _rxModel
, SfxItemSet
* _pSet
)
216 OSL_ENSURE(_pSet
&& _rxModel
.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
217 if (!_pSet
|| !_rxModel
.is())
222 OFontPropertyExtractor
aPropExtractor(_rxModel
);
224 // some items, which may be in default state, have to be filled with non-void information
225 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
226 ::com::sun::star::awt::FontDescriptor aDefaultFont
= VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont
);
228 // get the current properties
229 ::rtl::OUString aFontName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_NAME
, aDefaultFont
.Name
);
230 ::rtl::OUString aFontStyleName
= aPropExtractor
.getStringFontProperty(PROPERTY_FONT_STYLENAME
, aDefaultFont
.StyleName
);
231 sal_Int16 nFontFamily
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_FAMILY
, aDefaultFont
.Family
);
232 sal_Int16 nFontCharset
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_CHARSET
, aDefaultFont
.CharSet
);
233 float nFontHeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_HEIGHT
, (float)aDefaultFont
.Height
);
234 float nFontWeight
= aPropExtractor
.getFloatFontProperty(PROPERTY_FONT_WEIGHT
, aDefaultFont
.Weight
);
235 sal_Int16 nFontSlant
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_SLANT
, (sal_Int16
)aDefaultFont
.Slant
);
236 sal_Int16 nFontUnderline
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_UNDERLINE
, aDefaultFont
.Underline
);
237 sal_Int16 nFontStrikeout
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT
, aDefaultFont
.Strikeout
);
239 sal_Int32 nTextLineColor
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTLINECOLOR
, COL_AUTO
);
240 sal_Int16 nFontRelief
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_RELIEF
, (sal_Int16
)aDefaultVCLFont
.GetRelief());
241 sal_Int16 nFontEmphasisMark
= aPropExtractor
.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK
, aDefaultVCLFont
.GetEmphasisMark());
244 sal_Bool bWordLineMode
= aPropExtractor
.getCheckFontProperty(PROPERTY_WORDLINEMODE
, aValue
) ? aDefaultFont
.WordLineMode
: ::cppu::any2bool(aValue
);
245 sal_Int32 nColor32
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTCOLOR
, 0);
247 // build SfxItems with the values
248 SvxFontItem
aFontItem((FontFamily
)nFontFamily
, aFontName
, aFontStyleName
, PITCH_DONTKNOW
, nFontCharset
, CFID_FONT
);
250 nFontHeight
= (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32
)nFontHeight
), MAP_POINT
, MAP_TWIP
).Height();
251 SvxFontHeightItem
aSvxFontHeightItem((sal_uInt32
)nFontHeight
,100,CFID_HEIGHT
);
253 FontWeight eWeight
=VCLUnoHelper::ConvertFontWeight(nFontWeight
);
254 FontItalic eItalic
=(FontItalic
)nFontSlant
;
255 FontUnderline eUnderline
=(FontUnderline
)nFontUnderline
;
256 FontStrikeout eStrikeout
=(FontStrikeout
)nFontStrikeout
;
258 SvxWeightItem
aWeightItem(eWeight
,CFID_WEIGHT
);
259 SvxPostureItem
aPostureItem(eItalic
,CFID_POSTURE
);
261 SvxCrossedOutItem
aCrossedOutItem(eStrikeout
,CFID_STRIKEOUT
);
262 SvxWordLineModeItem
aWordLineModeItem(bWordLineMode
, CFID_WORDLINEMODE
);
264 SvxUnderlineItem
aUnderlineItem(eUnderline
,CFID_UNDERLINE
);
265 aUnderlineItem
.SetColor(Color(nTextLineColor
));
267 SvxColorItem
aSvxColorItem(nColor32
,CFID_CHARCOLOR
);
268 SvxLanguageItem
aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE
);
271 SvxCharReliefItem
aFontReliefItem((FontRelief
)nFontRelief
, CFID_RELIEF
);
272 SvxEmphasisMarkItem
aEmphasisMarkitem((FontEmphasisMark
)nFontEmphasisMark
, CFID_EMPHASIS
);
274 _pSet
->Put(aFontItem
, CFID_FONT
);
275 _pSet
->Put(aSvxFontHeightItem
,CFID_HEIGHT
);
276 _pSet
->Put(aWeightItem
, CFID_WEIGHT
);
277 _pSet
->Put(aPostureItem
, CFID_POSTURE
);
278 _pSet
->Put(aLanguageItem
, CFID_LANGUAGE
);
279 _pSet
->Put(aUnderlineItem
,CFID_UNDERLINE
);
280 _pSet
->Put(aCrossedOutItem
,CFID_STRIKEOUT
);
281 _pSet
->Put(aWordLineModeItem
, CFID_WORDLINEMODE
);
282 _pSet
->Put(aSvxColorItem
, CFID_CHARCOLOR
);
283 _pSet
->Put(aFontReliefItem
, CFID_RELIEF
);
284 _pSet
->Put(aEmphasisMarkitem
, CFID_EMPHASIS
);
286 aPropExtractor
.invalidateItem(PROPERTY_FONT_NAME
, CFID_FONT
, *_pSet
);
287 aPropExtractor
.invalidateItem(PROPERTY_FONT_HEIGHT
, CFID_HEIGHT
, *_pSet
);
288 aPropExtractor
.invalidateItem(PROPERTY_FONT_WEIGHT
, CFID_WEIGHT
, *_pSet
, ::com::sun::star::awt::FontWeight::DONTKNOW
== nFontWeight
);
289 aPropExtractor
.invalidateItem(PROPERTY_FONT_SLANT
, CFID_POSTURE
, *_pSet
, ::com::sun::star::awt::FontSlant_DONTKNOW
== nFontSlant
);
290 aPropExtractor
.invalidateItem(PROPERTY_FONT_UNDERLINE
, CFID_UNDERLINE
, *_pSet
, ::com::sun::star::awt::FontUnderline::DONTKNOW
== nFontUnderline
);
291 aPropExtractor
.invalidateItem(PROPERTY_FONT_STRIKEOUT
, CFID_STRIKEOUT
, *_pSet
, ::com::sun::star::awt::FontStrikeout::DONTKNOW
== nFontStrikeout
);
292 aPropExtractor
.invalidateItem(PROPERTY_WORDLINEMODE
, CFID_WORDLINEMODE
, *_pSet
);
293 aPropExtractor
.invalidateItem(PROPERTY_TEXTCOLOR
, CFID_CHARCOLOR
, *_pSet
);
294 aPropExtractor
.invalidateItem(PROPERTY_FONT_RELIEF
, CFID_RELIEF
, *_pSet
);
295 aPropExtractor
.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK
, CFID_EMPHASIS
, *_pSet
);
299 DBG_ERROR("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
302 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONT
);
303 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT
);
304 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE
);
305 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_POSTURE
);
306 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT
);
308 _pSet
->DisableItem(SID_ATTR_CHAR_CASEMAP
);
309 _pSet
->DisableItem(SID_ATTR_CHAR_CONTOUR
);
310 _pSet
->DisableItem(SID_ATTR_CHAR_SHADOWED
);
314 //------------------------------------------------------------------------
317 void lcl_pushBackPropertyValue( Sequence
< NamedValue
>& _out_properties
, const ::rtl::OUString
& _name
, const Any
& _value
)
319 _out_properties
.realloc( _out_properties
.getLength() + 1 );
320 _out_properties
[ _out_properties
.getLength() - 1 ] = NamedValue( _name
, _value
);
324 //------------------------------------------------------------------------
325 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, Sequence
< NamedValue
>& _out_properties
)
327 _out_properties
.realloc( 0 );
331 // --------------------------
333 SfxItemState eState
= _rSet
.GetItemState(CFID_FONT
);
335 if ( eState
== SFX_ITEM_SET
)
337 const SvxFontItem
& rFontItem
=
338 static_cast<const SvxFontItem
&>(_rSet
.Get(CFID_FONT
));
340 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_NAME
, makeAny(::rtl::OUString(rFontItem
.GetFamilyName())));
341 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STYLENAME
, makeAny(::rtl::OUString(rFontItem
.GetStyleName())));
342 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_FAMILY
, makeAny((sal_Int16
)rFontItem
.GetFamily()));
343 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_CHARSET
, makeAny((sal_Int16
)rFontItem
.GetCharSet()));
346 // --------------------------
348 eState
= _rSet
.GetItemState(CFID_HEIGHT
);
350 if ( eState
== SFX_ITEM_SET
)
352 const SvxFontHeightItem
& rSvxFontHeightItem
=
353 static_cast<const SvxFontHeightItem
&>(_rSet
.Get(CFID_HEIGHT
));
355 float nHeight
= (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem
.GetHeight()), MAP_TWIP
, MAP_POINT
).Height();
356 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_HEIGHT
,makeAny(nHeight
));
360 // --------------------------
362 eState
= _rSet
.GetItemState(CFID_WEIGHT
);
364 if ( eState
== SFX_ITEM_SET
)
366 const SvxWeightItem
& rWeightItem
=
367 static_cast<const SvxWeightItem
&>(_rSet
.Get(CFID_WEIGHT
));
369 float nWeight
= VCLUnoHelper::ConvertFontWeight( rWeightItem
.GetWeight());
370 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_WEIGHT
,makeAny(nWeight
));
373 // --------------------------
375 eState
= _rSet
.GetItemState(CFID_POSTURE
);
377 if ( eState
== SFX_ITEM_SET
)
379 const SvxPostureItem
& rPostureItem
=
380 static_cast<const SvxPostureItem
&>(_rSet
.Get(CFID_POSTURE
));
382 ::com::sun::star::awt::FontSlant eSlant
= (::com::sun::star::awt::FontSlant
)rPostureItem
.GetPosture();
383 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_SLANT
, makeAny((sal_Int16
)eSlant
));
386 // --------------------------
388 eState
= _rSet
.GetItemState(CFID_UNDERLINE
);
390 if ( eState
== SFX_ITEM_SET
)
392 const SvxUnderlineItem
& rUnderlineItem
=
393 static_cast<const SvxUnderlineItem
&>(_rSet
.Get(CFID_UNDERLINE
));
395 sal_Int16 nUnderline
= (sal_Int16
)rUnderlineItem
.GetLineStyle();
396 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_UNDERLINE
,makeAny(nUnderline
));
398 // the text line color is transported in this item, too
399 sal_Int32 nColor
= rUnderlineItem
.GetColor().GetColor();
402 if (COL_AUTO
!= (UINT32
)nColor
)
403 aUnoColor
<<= nColor
;
405 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTLINECOLOR
, aUnoColor
);
408 // --------------------------
410 eState
= _rSet
.GetItemState(CFID_STRIKEOUT
);
412 if ( eState
== SFX_ITEM_SET
)
414 const SvxCrossedOutItem
& rCrossedOutItem
=
415 static_cast<const SvxCrossedOutItem
&>(_rSet
.Get(CFID_STRIKEOUT
));
417 sal_Int16 nStrikeout
= (sal_Int16
)rCrossedOutItem
.GetStrikeout();
418 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STRIKEOUT
,makeAny(nStrikeout
));
422 // --------------------------
423 // font wordline mode
424 eState
= _rSet
.GetItemState(CFID_WORDLINEMODE
);
426 if ( eState
== SFX_ITEM_SET
)
428 const SvxWordLineModeItem
& rWordLineModeItem
=
429 static_cast<const SvxWordLineModeItem
&>(_rSet
.Get(CFID_WORDLINEMODE
));
431 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_WORDLINEMODE
, ::cppu::bool2any(rWordLineModeItem
.GetValue()));
435 // --------------------------
437 eState
= _rSet
.GetItemState(CFID_CHARCOLOR
);
439 if ( eState
== SFX_ITEM_SET
)
441 const SvxColorItem
& rColorItem
=
442 static_cast<const SvxColorItem
&>(_rSet
.Get(CFID_CHARCOLOR
));
444 sal_Int32 nColor
= rColorItem
.GetValue().GetColor();
447 if (COL_AUTO
!= (UINT32
)nColor
)
448 aUnoColor
<<= nColor
;
450 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTCOLOR
, aUnoColor
);
453 // --------------------------
455 eState
= _rSet
.GetItemState(CFID_RELIEF
);
457 if ( eState
== SFX_ITEM_SET
)
459 const SvxCharReliefItem
& rReliefItem
=
460 static_cast<const SvxCharReliefItem
&>(_rSet
.Get(CFID_RELIEF
));
462 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_RELIEF
, makeAny((sal_Int16
)rReliefItem
.GetValue()) );
465 // --------------------------
466 // font emphasis mark
467 eState
= _rSet
.GetItemState(CFID_EMPHASIS
);
469 if ( eState
== SFX_ITEM_SET
)
471 const SvxEmphasisMarkItem
& rEmphMarkItem
=
472 static_cast<const SvxEmphasisMarkItem
&>(_rSet
.Get(CFID_EMPHASIS
));
474 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_EMPHASIS_MARK
, makeAny((sal_Int16
)rEmphMarkItem
.GetEmphasisMark()) );
477 catch (const Exception
& )
479 DBG_UNHANDLED_EXCEPTION();
483 //------------------------------------------------------------------------
484 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, const Reference
< XPropertySet
>& _rxModel
)
486 OSL_ENSURE( _rxModel
.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
490 Sequence
< NamedValue
> aPropertyValues
;
491 translateItemsToProperties( _rSet
, aPropertyValues
);
494 const NamedValue
* propertyValue
= aPropertyValues
.getConstArray();
495 const NamedValue
* propertyValueEnd
= propertyValue
+ aPropertyValues
.getLength();
496 for ( ; propertyValue
!= propertyValueEnd
; ++propertyValue
)
497 _rxModel
->setPropertyValue( propertyValue
->Name
, propertyValue
->Value
);
499 catch( const Exception
& )
501 DBG_UNHANDLED_EXCEPTION();
505 //------------------------------------------------------------------------
506 SfxItemSet
* ControlCharacterDialog::createItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
508 // just to be sure ....
513 // create and initialize the defaults
514 _rppDefaults
= new SfxPoolItem
*[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1];
516 Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
518 SfxPoolItem
** pCounter
= _rppDefaults
; // want to modify this without affecting the out param _rppDefaults
519 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_FONT
);
520 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_HEIGHT
);
521 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_WEIGHT
);
522 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_POSTURE
);
523 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE
);
524 *pCounter
++ = new SvxUnderlineItem(aDefaultVCLFont
.GetUnderline(), CFID_UNDERLINE
);
525 *pCounter
++ = new SvxCrossedOutItem(aDefaultVCLFont
.GetStrikeout(), CFID_STRIKEOUT
);
526 *pCounter
++ = new SvxWordLineModeItem(aDefaultVCLFont
.IsWordLineMode(), CFID_WORDLINEMODE
);
527 *pCounter
++ = new SvxColorItem(aDefaultVCLFont
.GetColor(), CFID_CHARCOLOR
);
528 *pCounter
++ = new SvxCharReliefItem(aDefaultVCLFont
.GetRelief(), CFID_RELIEF
);
529 *pCounter
++ = new SvxEmphasisMarkItem(aDefaultVCLFont
.GetEmphasisMark(), CFID_EMPHASIS
);
531 *pCounter
++ = new SvxFontItem(aDefaultVCLFont
.GetFamily(), aDefaultVCLFont
.GetName(), aDefaultVCLFont
.GetStyleName(), aDefaultVCLFont
.GetPitch(), aDefaultVCLFont
.GetCharSet(), CFID_CJK_FONT
);
532 *pCounter
++ = new SvxFontHeightItem(aDefaultVCLFont
.GetHeight(), 100, CFID_CJK_HEIGHT
);
533 *pCounter
++ = new SvxWeightItem(aDefaultVCLFont
.GetWeight(), CFID_CJK_WEIGHT
);
534 *pCounter
++ = new SvxPostureItem(aDefaultVCLFont
.GetItalic(), CFID_CJK_POSTURE
);
535 *pCounter
++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE
);
537 *pCounter
++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED
, CFID_CASEMAP
);
538 *pCounter
++ = new SvxContourItem(sal_False
, CFID_CONTOUR
);
539 *pCounter
++ = new SvxShadowedItem(sal_False
, CFID_SHADOWED
);
541 *pCounter
++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST
);
544 static SfxItemInfo __READONLY_DATA aItemInfos
[CFID_LAST_ITEM_ID
- CFID_FIRST_ITEM_ID
+ 1] =
546 { SID_ATTR_CHAR_FONT
, 0 },
547 { SID_ATTR_CHAR_FONTHEIGHT
, 0 },
548 { SID_ATTR_CHAR_WEIGHT
, 0 },
549 { SID_ATTR_CHAR_POSTURE
, 0 },
550 { SID_ATTR_CHAR_LANGUAGE
, 0 },
551 { SID_ATTR_CHAR_UNDERLINE
, 0 },
552 { SID_ATTR_CHAR_STRIKEOUT
, 0 },
553 { SID_ATTR_CHAR_WORDLINEMODE
, 0 },
554 { SID_ATTR_CHAR_COLOR
, 0 },
555 { SID_ATTR_CHAR_RELIEF
, 0 },
556 { SID_ATTR_CHAR_EMPHASISMARK
, 0 },
565 { SID_ATTR_CHAR_FONTLIST
, 0 }
568 _rpPool
= new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID
, CFID_LAST_ITEM_ID
,
569 aItemInfos
, _rppDefaults
);
570 _rpPool
->FreezeIdRanges();
572 // and, finally, the set
573 _rpSet
= new SfxItemSet(*_rpPool
, sal_True
);
578 //-------------------------------------------------------------------------
579 void ControlCharacterDialog::destroyItemSet(SfxItemSet
*& _rpSet
, SfxItemPool
*& _rpPool
, SfxPoolItem
**& _rppDefaults
)
581 // from the pool, get and remember the font list (needs to be deleted)
582 const SvxFontListItem
& rFontListItem
= static_cast<const SvxFontListItem
&>(_rpPool
->GetDefaultItem(CFID_FONTLIST
));
583 const FontList
* pFontList
= rFontListItem
.GetFontList();
585 // _first_ delete the set (refering the pool)
595 _rpPool
->ReleaseDefaults(sal_True
);
596 // the "true" means delete the items, too
597 SfxItemPool::Free(_rpPool
);
601 // reset the defaults ptr
603 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
608 //------------------------------------------------------------------------
609 void ControlCharacterDialog::PageCreated( sal_uInt16 _nId
, SfxTabPage
& _rPage
)
611 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
614 case TABPAGE_CHARACTERS
:
615 //CHINA001 static_cast<SvxCharNamePage&>(_rPage).SetFontList(
616 //CHINA001 static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))
618 //CHINA001 static_cast<SvxCharNamePage&>(_rPage).DisableControls( DISABLE_HIDE_LANGUAGE );
620 //CHINA001 SvxFontListItem aFontListItem( static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST) ));
621 //CHINA001 aSet.Put ( SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
623 // aSet.Put (SfxUInt16Item(SID_CFID_FONTLIST,CFID_FONTLIST));
624 aSet
.Put (SvxFontListItem(static_cast<const SvxFontListItem
&>(GetInputSetImpl()->Get(CFID_FONTLIST
))));
625 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_HIDE_LANGUAGE
));
626 _rPage
.PageCreated(aSet
);
631 //............................................................................
633 //............................................................................