masterfix DEV300: #i10000# build fix
[LibreOffice.git] / extensions / source / propctrlr / fontdialog.cxx
blobe1fe31c56bb84f9264a290345b4e0a19c976003b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <sfx2/sfxsids.hrc>
31 #include "fontdialog.hxx"
32 #ifndef EXTENSIONS_PROPRESID_HRC
33 #include "formresid.hrc"
34 #endif
35 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
36 #include "modulepcr.hxx"
37 #endif
38 #ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
39 #include "formlocalid.hrc"
40 #endif
41 #include <vcl/svapp.hxx>
42 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
43 #include <toolkit/unohlp.hxx>
44 #endif
45 #include <comphelper/types.hxx>
46 #include <comphelper/extract.hxx>
47 #include <com/sun/star/awt/FontDescriptor.hpp>
48 #include <com/sun/star/awt/FontWeight.hpp>
49 #include <com/sun/star/awt/FontSlant.hpp>
50 #include <com/sun/star/awt/FontUnderline.hpp>
51 #include <com/sun/star/awt/FontStrikeout.hpp>
52 #include "formstrings.hxx"
53 #include "fontitemids.hxx"
54 #include <editeng/charreliefitem.hxx>
55 #ifndef _SVX_EMPHITEM_HXX
56 #include <editeng/emphitem.hxx>
57 #endif
58 #include <editeng/fontitem.hxx>
59 #include <editeng/fhgtitem.hxx>
60 #include <editeng/postitem.hxx>
61 #include <editeng/wghtitem.hxx>
62 #include <editeng/udlnitem.hxx>
63 #include <editeng/crsditem.hxx>
64 #include <editeng/colritem.hxx>
65 #include <editeng/flstitem.hxx>
66 #include <editeng/langitem.hxx>
67 #include <editeng/wrlmitem.hxx>
68 #include <editeng/cmapitem.hxx>
69 #include <editeng/cntritem.hxx>
70 #include <editeng/shdditem.hxx>
71 #include <editeng/flstitem.hxx>
72 #include <svtools/ctrltool.hxx>
73 #include <tools/diagnose_ex.h>
74 #include <com/sun/star/beans/XPropertyState.hpp>
75 #ifndef _SVX_SVXIDS_HRC
76 #include <svx/svxids.hrc> //CHINA001
77 #endif
78 #include <svx/svxdlg.hxx> //CHINA001
79 #include <svx/dialogs.hrc> //CHINA001
80 #include <svx/flagsdef.hxx>
81 //............................................................................
82 namespace pcr
84 //............................................................................
86 using namespace ::com::sun::star::uno;
87 using namespace ::com::sun::star::beans;
89 //========================================================================
90 //= OFontPropertyExtractor
91 //========================================================================
92 class OFontPropertyExtractor
94 protected:
95 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
96 m_xPropValueAccess;
97 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >
98 m_xPropStateAccess;
100 public:
101 OFontPropertyExtractor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >&
102 _rxProps );
104 public:
105 sal_Bool getCheckFontProperty(const ::rtl::OUString& _rPropName, ::com::sun::star::uno::Any& _rValue);
106 ::rtl::OUString getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault);
107 sal_Int16 getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault);
108 sal_Int32 getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault);
109 float getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault);
111 void invalidateItem(
112 const ::rtl::OUString& _rPropName,
113 sal_uInt16 _nItemId,
114 SfxItemSet& _rSet,
115 sal_Bool _bForceInvalidation = sal_False);
118 //------------------------------------------------------------------------
119 OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
120 :m_xPropValueAccess(_rxProps)
121 ,m_xPropStateAccess(_rxProps, UNO_QUERY)
123 OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
126 //------------------------------------------------------------------------
127 sal_Bool OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString& _rPropName, Any& _rValue)
129 _rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
130 if (m_xPropStateAccess.is())
131 return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
133 return sal_False;
136 //------------------------------------------------------------------------
137 ::rtl::OUString OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault)
139 Any aValue;
140 if (getCheckFontProperty(_rPropName, aValue))
141 return _rDefault;
143 return ::comphelper::getString(aValue);
146 //------------------------------------------------------------------------
147 sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault)
149 Any aValue;
150 if (getCheckFontProperty(_rPropName, aValue))
151 return _nDefault;
153 sal_Int32 nValue(_nDefault);
154 ::cppu::enum2int(nValue, aValue);
155 return (sal_Int16)nValue;
158 //------------------------------------------------------------------------
159 sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault)
161 Any aValue;
162 if (getCheckFontProperty(_rPropName, aValue))
163 return _nDefault;
165 sal_Int32 nValue(_nDefault);
166 ::cppu::enum2int(nValue, aValue);
167 return nValue;
170 //------------------------------------------------------------------------
171 float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault)
173 Any aValue;
174 if (getCheckFontProperty(_rPropName, aValue))
175 return _nDefault;
177 return ::comphelper::getFloat(aValue);
180 //------------------------------------------------------------------------
181 void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, sal_Bool _bForceInvalidation)
183 if ( _bForceInvalidation
184 || ( m_xPropStateAccess.is()
185 && (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
188 _rSet.InvalidateItem(_nItemId);
191 //========================================================================
192 //= ControlCharacterDialog
193 //========================================================================
194 //------------------------------------------------------------------------
195 ControlCharacterDialog::ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet)
196 :SfxTabDialog(_pParent, PcrRes(RID_TABDLG_FONTDIALOG), &_rCoreSet)
198 FreeResource();
199 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
200 DBG_ASSERT(pFact, "CreateFactory fail!");
201 AddTabPage(TABPAGE_CHARACTERS, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), 0 );
202 AddTabPage(TABPAGE_CHARACTERS_EXT, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), 0 );
205 //------------------------------------------------------------------------
206 ControlCharacterDialog::~ControlCharacterDialog()
210 //------------------------------------------------------------------------
211 void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
213 OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
214 if (!_pSet || !_rxModel.is())
215 return;
219 OFontPropertyExtractor aPropExtractor(_rxModel);
221 // some items, which may be in default state, have to be filled with non-void information
222 Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
223 ::com::sun::star::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
225 // get the current properties
226 ::rtl::OUString aFontName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
227 ::rtl::OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
228 sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
229 sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
230 float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, (float)aDefaultFont.Height);
231 float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
232 sal_Int16 nFontSlant = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, (sal_Int16)aDefaultFont.Slant);
233 sal_Int16 nFontUnderline = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
234 sal_Int16 nFontStrikeout = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
236 sal_Int32 nTextLineColor = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, COL_AUTO);
237 sal_Int16 nFontRelief = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, (sal_Int16)aDefaultVCLFont.GetRelief());
238 sal_Int16 nFontEmphasisMark = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, aDefaultVCLFont.GetEmphasisMark());
240 Any aValue;
241 sal_Bool bWordLineMode = aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
242 sal_Int32 nColor32 = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
244 // build SfxItems with the values
245 SvxFontItem aFontItem((FontFamily)nFontFamily, aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT);
247 nFontHeight = (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32)nFontHeight), MAP_POINT, MAP_TWIP).Height();
248 SvxFontHeightItem aSvxFontHeightItem((sal_uInt32)nFontHeight,100,CFID_HEIGHT);
250 FontWeight eWeight=VCLUnoHelper::ConvertFontWeight(nFontWeight);
251 FontItalic eItalic=(FontItalic)nFontSlant;
252 FontUnderline eUnderline=(FontUnderline)nFontUnderline;
253 FontStrikeout eStrikeout=(FontStrikeout)nFontStrikeout;
255 SvxWeightItem aWeightItem(eWeight,CFID_WEIGHT);
256 SvxPostureItem aPostureItem(eItalic,CFID_POSTURE);
258 SvxCrossedOutItem aCrossedOutItem(eStrikeout,CFID_STRIKEOUT);
259 SvxWordLineModeItem aWordLineModeItem(bWordLineMode, CFID_WORDLINEMODE);
261 SvxUnderlineItem aUnderlineItem(eUnderline,CFID_UNDERLINE);
262 aUnderlineItem.SetColor(Color(nTextLineColor));
264 SvxColorItem aSvxColorItem(nColor32,CFID_CHARCOLOR);
265 SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
267 // the 2 CJK props
268 SvxCharReliefItem aFontReliefItem((FontRelief)nFontRelief, CFID_RELIEF);
269 SvxEmphasisMarkItem aEmphasisMarkitem((FontEmphasisMark)nFontEmphasisMark, CFID_EMPHASIS);
271 _pSet->Put(aFontItem, CFID_FONT);
272 _pSet->Put(aSvxFontHeightItem,CFID_HEIGHT);
273 _pSet->Put(aWeightItem, CFID_WEIGHT);
274 _pSet->Put(aPostureItem, CFID_POSTURE);
275 _pSet->Put(aLanguageItem, CFID_LANGUAGE);
276 _pSet->Put(aUnderlineItem,CFID_UNDERLINE);
277 _pSet->Put(aCrossedOutItem,CFID_STRIKEOUT);
278 _pSet->Put(aWordLineModeItem, CFID_WORDLINEMODE);
279 _pSet->Put(aSvxColorItem, CFID_CHARCOLOR);
280 _pSet->Put(aFontReliefItem, CFID_RELIEF);
281 _pSet->Put(aEmphasisMarkitem, CFID_EMPHASIS);
283 aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
284 aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
285 aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, CFID_WEIGHT, *_pSet, ::com::sun::star::awt::FontWeight::DONTKNOW == nFontWeight);
286 aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, CFID_POSTURE, *_pSet, ::com::sun::star::awt::FontSlant_DONTKNOW == nFontSlant);
287 aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, CFID_UNDERLINE, *_pSet, ::com::sun::star::awt::FontUnderline::DONTKNOW == nFontUnderline);
288 aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, CFID_STRIKEOUT, *_pSet, ::com::sun::star::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
289 aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, CFID_WORDLINEMODE, *_pSet);
290 aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, CFID_CHARCOLOR, *_pSet);
291 aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, CFID_RELIEF, *_pSet);
292 aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, CFID_EMPHASIS, *_pSet);
294 catch (Exception&)
296 DBG_ERROR("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
299 _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONT);
300 _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT);
301 _pSet->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE);
302 _pSet->DisableItem(SID_ATTR_CHAR_CJK_POSTURE);
303 _pSet->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT);
305 _pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
306 _pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
307 _pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
311 //------------------------------------------------------------------------
312 namespace
314 void lcl_pushBackPropertyValue( Sequence< NamedValue >& _out_properties, const ::rtl::OUString& _name, const Any& _value )
316 _out_properties.realloc( _out_properties.getLength() + 1 );
317 _out_properties[ _out_properties.getLength() - 1 ] = NamedValue( _name, _value );
321 //------------------------------------------------------------------------
322 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, Sequence< NamedValue >& _out_properties )
324 _out_properties.realloc( 0 );
328 // --------------------------
329 // font name
330 SfxItemState eState = _rSet.GetItemState(CFID_FONT);
332 if ( eState == SFX_ITEM_SET )
334 const SvxFontItem& rFontItem =
335 static_cast<const SvxFontItem&>(_rSet.Get(CFID_FONT));
337 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , makeAny(::rtl::OUString(rFontItem.GetFamilyName())));
338 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(::rtl::OUString(rFontItem.GetStyleName())));
339 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny((sal_Int16)rFontItem.GetFamily()));
340 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny((sal_Int16)rFontItem.GetCharSet()));
343 // --------------------------
344 // font height
345 eState = _rSet.GetItemState(CFID_HEIGHT);
347 if ( eState == SFX_ITEM_SET )
349 const SvxFontHeightItem& rSvxFontHeightItem =
350 static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT));
352 float nHeight = (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MAP_TWIP, MAP_POINT).Height();
353 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight));
357 // --------------------------
358 // font weight
359 eState = _rSet.GetItemState(CFID_WEIGHT);
361 if ( eState == SFX_ITEM_SET )
363 const SvxWeightItem& rWeightItem =
364 static_cast<const SvxWeightItem&>(_rSet.Get(CFID_WEIGHT));
366 float nWeight = VCLUnoHelper::ConvertFontWeight( rWeightItem.GetWeight());
367 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,makeAny(nWeight));
370 // --------------------------
371 // font slant
372 eState = _rSet.GetItemState(CFID_POSTURE);
374 if ( eState == SFX_ITEM_SET )
376 const SvxPostureItem& rPostureItem =
377 static_cast<const SvxPostureItem&>(_rSet.Get(CFID_POSTURE));
379 ::com::sun::star::awt::FontSlant eSlant = (::com::sun::star::awt::FontSlant)rPostureItem.GetPosture();
380 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, makeAny((sal_Int16)eSlant));
383 // --------------------------
384 // font underline
385 eState = _rSet.GetItemState(CFID_UNDERLINE);
387 if ( eState == SFX_ITEM_SET )
389 const SvxUnderlineItem& rUnderlineItem =
390 static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE));
392 sal_Int16 nUnderline = (sal_Int16)rUnderlineItem.GetLineStyle();
393 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline));
395 // the text line color is transported in this item, too
396 sal_Int32 nColor = rUnderlineItem.GetColor().GetColor();
398 Any aUnoColor;
399 if (COL_AUTO != (sal_uInt32)nColor)
400 aUnoColor <<= nColor;
402 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
405 // --------------------------
406 // font strikeout
407 eState = _rSet.GetItemState(CFID_STRIKEOUT);
409 if ( eState == SFX_ITEM_SET )
411 const SvxCrossedOutItem& rCrossedOutItem =
412 static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT));
414 sal_Int16 nStrikeout = (sal_Int16)rCrossedOutItem.GetStrikeout();
415 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout));
419 // --------------------------
420 // font wordline mode
421 eState = _rSet.GetItemState(CFID_WORDLINEMODE);
423 if ( eState == SFX_ITEM_SET )
425 const SvxWordLineModeItem& rWordLineModeItem =
426 static_cast<const SvxWordLineModeItem&>(_rSet.Get(CFID_WORDLINEMODE));
428 lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, ::cppu::bool2any(rWordLineModeItem.GetValue()));
432 // --------------------------
433 // text color
434 eState = _rSet.GetItemState(CFID_CHARCOLOR);
436 if ( eState == SFX_ITEM_SET )
438 const SvxColorItem& rColorItem =
439 static_cast<const SvxColorItem&>(_rSet.Get(CFID_CHARCOLOR));
441 sal_Int32 nColor = rColorItem.GetValue().GetColor();
443 Any aUnoColor;
444 if (COL_AUTO != (sal_uInt32)nColor)
445 aUnoColor <<= nColor;
447 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
450 // --------------------------
451 // font relief
452 eState = _rSet.GetItemState(CFID_RELIEF);
454 if ( eState == SFX_ITEM_SET )
456 const SvxCharReliefItem& rReliefItem =
457 static_cast<const SvxCharReliefItem&>(_rSet.Get(CFID_RELIEF));
459 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, makeAny((sal_Int16)rReliefItem.GetValue()) );
462 // --------------------------
463 // font emphasis mark
464 eState = _rSet.GetItemState(CFID_EMPHASIS);
466 if ( eState == SFX_ITEM_SET )
468 const SvxEmphasisMarkItem& rEmphMarkItem =
469 static_cast<const SvxEmphasisMarkItem&>(_rSet.Get(CFID_EMPHASIS));
471 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, makeAny((sal_Int16)rEmphMarkItem.GetEmphasisMark()) );
474 catch (const Exception& )
476 DBG_UNHANDLED_EXCEPTION();
480 //------------------------------------------------------------------------
481 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
483 OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
484 if ( !_rxModel.is())
485 return;
487 Sequence< NamedValue > aPropertyValues;
488 translateItemsToProperties( _rSet, aPropertyValues );
491 const NamedValue* propertyValue = aPropertyValues.getConstArray();
492 const NamedValue* propertyValueEnd = propertyValue + aPropertyValues.getLength();
493 for ( ; propertyValue != propertyValueEnd; ++propertyValue )
494 _rxModel->setPropertyValue( propertyValue->Name, propertyValue->Value );
496 catch( const Exception& )
498 DBG_UNHANDLED_EXCEPTION();
502 //------------------------------------------------------------------------
503 SfxItemSet* ControlCharacterDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
505 // just to be sure ....
506 _rpSet = NULL;
507 _rpPool = NULL;
508 _rppDefaults = NULL;
510 // create and initialize the defaults
511 _rppDefaults = new SfxPoolItem*[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1];
513 Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
515 SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults
516 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_FONT);
517 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_HEIGHT);
518 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_WEIGHT);
519 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_POSTURE);
520 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
521 *pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), CFID_UNDERLINE);
522 *pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), CFID_STRIKEOUT);
523 *pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), CFID_WORDLINEMODE);
524 *pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), CFID_CHARCOLOR);
525 *pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), CFID_RELIEF);
526 *pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), CFID_EMPHASIS);
528 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_CJK_FONT);
529 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_CJK_HEIGHT);
530 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_CJK_WEIGHT);
531 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_CJK_POSTURE);
532 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE);
534 *pCounter++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, CFID_CASEMAP);
535 *pCounter++ = new SvxContourItem(sal_False, CFID_CONTOUR);
536 *pCounter++ = new SvxShadowedItem(sal_False, CFID_SHADOWED);
538 *pCounter++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST);
540 // create the pool
541 static SfxItemInfo __READONLY_DATA aItemInfos[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1] =
543 { SID_ATTR_CHAR_FONT, 0 },
544 { SID_ATTR_CHAR_FONTHEIGHT, 0 },
545 { SID_ATTR_CHAR_WEIGHT, 0 },
546 { SID_ATTR_CHAR_POSTURE, 0 },
547 { SID_ATTR_CHAR_LANGUAGE, 0 },
548 { SID_ATTR_CHAR_UNDERLINE, 0 },
549 { SID_ATTR_CHAR_STRIKEOUT, 0 },
550 { SID_ATTR_CHAR_WORDLINEMODE, 0 },
551 { SID_ATTR_CHAR_COLOR, 0 },
552 { SID_ATTR_CHAR_RELIEF, 0 },
553 { SID_ATTR_CHAR_EMPHASISMARK, 0 },
554 { 0, 0 },
555 { 0, 0 },
556 { 0, 0 },
557 { 0, 0 },
558 { 0, 0 },
559 { 0, 0 },
560 { 0, 0 },
561 { 0, 0 },
562 { SID_ATTR_CHAR_FONTLIST, 0 }
565 _rpPool = new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID, CFID_LAST_ITEM_ID,
566 aItemInfos, _rppDefaults);
567 _rpPool->FreezeIdRanges();
569 // and, finally, the set
570 _rpSet = new SfxItemSet(*_rpPool, sal_True);
572 return _rpSet;
575 //-------------------------------------------------------------------------
576 void ControlCharacterDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
578 // from the pool, get and remember the font list (needs to be deleted)
579 const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST));
580 const FontList* pFontList = rFontListItem.GetFontList();
582 // _first_ delete the set (refering the pool)
583 if (_rpSet)
585 delete _rpSet;
586 _rpSet = NULL;
589 // delete the pool
590 if (_rpPool)
592 _rpPool->ReleaseDefaults(sal_True);
593 // the "true" means delete the items, too
594 SfxItemPool::Free(_rpPool);
595 _rpPool = NULL;
598 // reset the defaults ptr
599 _rppDefaults = NULL;
600 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
602 delete pFontList;
605 //------------------------------------------------------------------------
606 void ControlCharacterDialog::PageCreated( sal_uInt16 _nId, SfxTabPage& _rPage )
608 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
609 switch ( _nId )
611 case TABPAGE_CHARACTERS:
612 //CHINA001 static_cast<SvxCharNamePage&>(_rPage).SetFontList(
613 //CHINA001 static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))
614 //CHINA001 );
615 //CHINA001 static_cast<SvxCharNamePage&>(_rPage).DisableControls( DISABLE_HIDE_LANGUAGE );
617 //CHINA001 SvxFontListItem aFontListItem( static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST) ));
618 //CHINA001 aSet.Put ( SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
620 // aSet.Put (SfxUInt16Item(SID_CFID_FONTLIST,CFID_FONTLIST));
621 aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))));
622 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
623 _rPage.PageCreated(aSet);
624 break;
628 //............................................................................
629 } // namespace pcr
630 //............................................................................