1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include <sfx2/sfxsids.hrc>
27 #include "fontdialog.hxx"
28 #ifndef EXTENSIONS_PROPRESID_HRC
29 #include "formresid.hrc"
30 #endif
31 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
32 #include "modulepcr.hxx"
33 #endif
34 #ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
35 #include "formlocalid.hrc"
36 #endif
37 #include <vcl/svapp.hxx>
38 #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
39 #include <toolkit/unohlp.hxx>
40 #endif
41 #include <comphelper/types.hxx>
42 #include <comphelper/extract.hxx>
43 #include <com/sun/star/awt/FontDescriptor.hpp>
44 #include <com/sun/star/awt/FontWeight.hpp>
45 #include <com/sun/star/awt/FontSlant.hpp>
46 #include <com/sun/star/awt/FontUnderline.hpp>
47 #include <com/sun/star/awt/FontStrikeout.hpp>
48 #include "formstrings.hxx"
49 #include "fontitemids.hxx"
50 #include <editeng/charreliefitem.hxx>
51 #ifndef _SVX_EMPHITEM_HXX
52 #include <editeng/emphitem.hxx>
53 #endif
54 #include <editeng/fontitem.hxx>
55 #include <editeng/fhgtitem.hxx>
56 #include <editeng/postitem.hxx>
57 #include <editeng/wghtitem.hxx>
58 #include <editeng/udlnitem.hxx>
59 #include <editeng/crsditem.hxx>
60 #include <editeng/colritem.hxx>
61 #include <editeng/flstitem.hxx>
62 #include <editeng/langitem.hxx>
63 #include <editeng/wrlmitem.hxx>
64 #include <editeng/cmapitem.hxx>
65 #include <editeng/cntritem.hxx>
66 #include <editeng/shdditem.hxx>
67 #include <editeng/flstitem.hxx>
68 #include <svtools/ctrltool.hxx>
69 #include <tools/diagnose_ex.h>
70 #include <com/sun/star/beans/XPropertyState.hpp>
71 #ifndef _SVX_SVXIDS_HRC
72 #include <svx/svxids.hrc> //CHINA001
73 #endif
74 #include <svx/svxdlg.hxx> //CHINA001
75 #include <svx/dialogs.hrc> //CHINA001
76 #include <svx/flagsdef.hxx>
77 //............................................................................
78 namespace pcr
79 {
80 //............................................................................
81 
82 	using namespace ::com::sun::star::uno;
83 	using namespace ::com::sun::star::beans;
84 
85 	//========================================================================
86 	//= OFontPropertyExtractor
87 	//========================================================================
88 	class OFontPropertyExtractor
89 	{
90 	protected:
91 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
92 					m_xPropValueAccess;
93 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >
94 					m_xPropStateAccess;
95 
96 	public:
97 		OFontPropertyExtractor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >&
98 			_rxProps );
99 
100 	public:
101 		sal_Bool		getCheckFontProperty(const ::rtl::OUString& _rPropName, ::com::sun::star::uno::Any& _rValue);
102 		::rtl::OUString	getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault);
103 		sal_Int16		getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault);
104 		sal_Int32		getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault);
105 		float			getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault);
106 
107 		void			invalidateItem(
108 							const ::rtl::OUString& _rPropName,
109 							sal_uInt16 _nItemId,
110 							SfxItemSet& _rSet,
111 							sal_Bool _bForceInvalidation = sal_False);
112 	};
113 
114 	//------------------------------------------------------------------------
OFontPropertyExtractor(const Reference<XPropertySet> & _rxProps)115 	OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
116 		:m_xPropValueAccess(_rxProps)
117 		,m_xPropStateAccess(_rxProps, UNO_QUERY)
118 	{
119 		OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
120 	}
121 
122 	//------------------------------------------------------------------------
getCheckFontProperty(const::rtl::OUString & _rPropName,Any & _rValue)123 	sal_Bool OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString& _rPropName, Any& _rValue)
124 	{
125 		_rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
126 		if (m_xPropStateAccess.is())
127 			return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
128 
129 		return sal_False;
130 	}
131 
132 	//------------------------------------------------------------------------
getStringFontProperty(const::rtl::OUString & _rPropName,const::rtl::OUString & _rDefault)133 	::rtl::OUString	OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault)
134 	{
135 		Any aValue;
136 		if (getCheckFontProperty(_rPropName, aValue))
137 			return _rDefault;
138 
139 		return ::comphelper::getString(aValue);
140 	}
141 
142 	//------------------------------------------------------------------------
getInt16FontProperty(const::rtl::OUString & _rPropName,const sal_Int16 _nDefault)143 	sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault)
144 	{
145 		Any aValue;
146 		if (getCheckFontProperty(_rPropName, aValue))
147 			return _nDefault;
148 
149 		sal_Int32 nValue(_nDefault);
150 		::cppu::enum2int(nValue, aValue);
151 		return (sal_Int16)nValue;
152 	}
153 
154 	//------------------------------------------------------------------------
getInt32FontProperty(const::rtl::OUString & _rPropName,const sal_Int32 _nDefault)155 	sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault)
156 	{
157 		Any aValue;
158 		if (getCheckFontProperty(_rPropName, aValue))
159 			return _nDefault;
160 
161 		sal_Int32 nValue(_nDefault);
162 		::cppu::enum2int(nValue, aValue);
163 		return nValue;
164 	}
165 
166 	//------------------------------------------------------------------------
getFloatFontProperty(const::rtl::OUString & _rPropName,const float _nDefault)167 	float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault)
168 	{
169 		Any aValue;
170 		if (getCheckFontProperty(_rPropName, aValue))
171 			return _nDefault;
172 
173 		return ::comphelper::getFloat(aValue);
174 	}
175 
176 	//------------------------------------------------------------------------
invalidateItem(const::rtl::OUString & _rPropName,sal_uInt16 _nItemId,SfxItemSet & _rSet,sal_Bool _bForceInvalidation)177 	void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, sal_Bool _bForceInvalidation)
178 	{
179 		if	(	_bForceInvalidation
180 			||	(	m_xPropStateAccess.is()
181 				&& (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
182 				)
183 			)
184 			_rSet.InvalidateItem(_nItemId);
185 	}
186 
187 	//========================================================================
188 	//= ControlCharacterDialog
189 	//========================================================================
190 	//------------------------------------------------------------------------
ControlCharacterDialog(Window * _pParent,const SfxItemSet & _rCoreSet)191 	ControlCharacterDialog::ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet)
192 		:SfxTabDialog(_pParent, PcrRes(RID_TABDLG_FONTDIALOG), &_rCoreSet)
193 	{
194 		FreeResource();
195 		SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
196 		DBG_ASSERT(pFact, "CreateFactory fail!");
197 		AddTabPage(TABPAGE_CHARACTERS, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), 0 );
198 		AddTabPage(TABPAGE_CHARACTERS_EXT, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), 0 );
199 	}
200 
201 	//------------------------------------------------------------------------
~ControlCharacterDialog()202 	ControlCharacterDialog::~ControlCharacterDialog()
203 	{
204 	}
205 
206 	//------------------------------------------------------------------------
translatePropertiesToItems(const Reference<XPropertySet> & _rxModel,SfxItemSet * _pSet)207 	void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
208 	{
209 		OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
210 		if (!_pSet || !_rxModel.is())
211 			return;
212 
213 		try
214 		{
215 			OFontPropertyExtractor aPropExtractor(_rxModel);
216 
217 			// some items, which may be in default state, have to be filled with non-void information
218 			Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
219 			::com::sun::star::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
220 
221 			// get the current properties
222 			::rtl::OUString aFontName		= aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
223 			::rtl::OUString aFontStyleName	= aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
224 			sal_Int16	nFontFamily			= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
225 			sal_Int16	nFontCharset		= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
226 			float	nFontHeight				= aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, (float)aDefaultFont.Height);
227 			float	nFontWeight				= aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
228 			sal_Int16 nFontSlant			= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, (sal_Int16)aDefaultFont.Slant);
229 			sal_Int16 nFontUnderline		= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
230 			sal_Int16 nFontStrikeout		= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
231 
232 			sal_Int32 nTextLineColor		= aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, COL_AUTO);
233 			sal_Int16 nFontRelief			= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, (sal_Int16)aDefaultVCLFont.GetRelief());
234 			sal_Int16 nFontEmphasisMark		= aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, aDefaultVCLFont.GetEmphasisMark());
235 
236 			Any aValue;
237 			sal_Bool bWordLineMode			= aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
238 			sal_Int32 nColor32				= aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
239 
240 			// build SfxItems with the values
241 			SvxFontItem aFontItem((FontFamily)nFontFamily, aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT);
242 
243 			nFontHeight = (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32)nFontHeight), MAP_POINT, MAP_TWIP).Height();
244 			SvxFontHeightItem aSvxFontHeightItem((sal_uInt32)nFontHeight,100,CFID_HEIGHT);
245 
246 			FontWeight		eWeight=VCLUnoHelper::ConvertFontWeight(nFontWeight);
247 			FontItalic		eItalic=(FontItalic)nFontSlant;
248 			FontUnderline	eUnderline=(FontUnderline)nFontUnderline;
249 			FontStrikeout	eStrikeout=(FontStrikeout)nFontStrikeout;
250 
251 			SvxWeightItem		aWeightItem(eWeight,CFID_WEIGHT);
252 			SvxPostureItem		aPostureItem(eItalic,CFID_POSTURE);
253 
254 			SvxCrossedOutItem	aCrossedOutItem(eStrikeout,CFID_STRIKEOUT);
255 			SvxWordLineModeItem aWordLineModeItem(bWordLineMode, CFID_WORDLINEMODE);
256 
257 			SvxUnderlineItem 	aUnderlineItem(eUnderline,CFID_UNDERLINE);
258 			aUnderlineItem.SetColor(Color(nTextLineColor));
259 
260 			SvxColorItem aSvxColorItem(nColor32,CFID_CHARCOLOR);
261 			SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
262 
263 			// the 2 CJK props
264             SvxCharReliefItem aFontReliefItem((FontRelief)nFontRelief, CFID_RELIEF);
265             SvxEmphasisMarkItem aEmphasisMarkitem((FontEmphasisMark)nFontEmphasisMark, CFID_EMPHASIS);
266 
267 			_pSet->Put(aFontItem, CFID_FONT);
268 			_pSet->Put(aSvxFontHeightItem,CFID_HEIGHT);
269 			_pSet->Put(aWeightItem, CFID_WEIGHT);
270 			_pSet->Put(aPostureItem, CFID_POSTURE);
271 			_pSet->Put(aLanguageItem, CFID_LANGUAGE);
272 			_pSet->Put(aUnderlineItem,CFID_UNDERLINE);
273 			_pSet->Put(aCrossedOutItem,CFID_STRIKEOUT);
274 			_pSet->Put(aWordLineModeItem, CFID_WORDLINEMODE);
275 			_pSet->Put(aSvxColorItem, CFID_CHARCOLOR);
276 			_pSet->Put(aFontReliefItem, CFID_RELIEF);
277 			_pSet->Put(aEmphasisMarkitem, CFID_EMPHASIS);
278 
279 			aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
280 			aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
281 			aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, CFID_WEIGHT, *_pSet, ::com::sun::star::awt::FontWeight::DONTKNOW == nFontWeight);
282 			aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, CFID_POSTURE, *_pSet, ::com::sun::star::awt::FontSlant_DONTKNOW == nFontSlant);
283 			aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, CFID_UNDERLINE, *_pSet, ::com::sun::star::awt::FontUnderline::DONTKNOW == nFontUnderline);
284 			aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, CFID_STRIKEOUT, *_pSet, ::com::sun::star::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
285 			aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, CFID_WORDLINEMODE, *_pSet);
286 			aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, CFID_CHARCOLOR, *_pSet);
287 			aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, CFID_RELIEF, *_pSet);
288 			aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, CFID_EMPHASIS, *_pSet);
289 		}
290 		catch (Exception&)
291 		{
292 			DBG_ERROR("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
293 		}
294 
295 		_pSet->DisableItem(SID_ATTR_CHAR_CJK_FONT);
296 		_pSet->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT);
297 		_pSet->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE);
298 		_pSet->DisableItem(SID_ATTR_CHAR_CJK_POSTURE);
299 		_pSet->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT);
300 
301 		_pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
302 		_pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
303 		_pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
304 
305 	}
306 
307 	//------------------------------------------------------------------------
308     namespace
309     {
lcl_pushBackPropertyValue(Sequence<NamedValue> & _out_properties,const::rtl::OUString & _name,const Any & _value)310         void lcl_pushBackPropertyValue( Sequence< NamedValue >& _out_properties, const ::rtl::OUString& _name, const Any& _value )
311         {
312             _out_properties.realloc( _out_properties.getLength() + 1 );
313             _out_properties[ _out_properties.getLength() - 1 ] = NamedValue( _name, _value );
314         }
315     }
316 
317 	//------------------------------------------------------------------------
translateItemsToProperties(const SfxItemSet & _rSet,Sequence<NamedValue> & _out_properties)318     void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, Sequence< NamedValue >& _out_properties )
319     {
320         _out_properties.realloc( 0 );
321 
322 		try
323 		{
324 			// --------------------------
325 			// font name
326 			SfxItemState eState = _rSet.GetItemState(CFID_FONT);
327 
328 			if ( eState == SFX_ITEM_SET )
329 			{
330 				const SvxFontItem& rFontItem =
331 					static_cast<const SvxFontItem&>(_rSet.Get(CFID_FONT));
332 
333 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME     , makeAny(::rtl::OUString(rFontItem.GetFamilyName())));
334 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(::rtl::OUString(rFontItem.GetStyleName())));
335 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY   , makeAny((sal_Int16)rFontItem.GetFamily()));
336 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET  , makeAny((sal_Int16)rFontItem.GetCharSet()));
337 			}
338 
339 			// --------------------------
340 			// font height
341 			eState = _rSet.GetItemState(CFID_HEIGHT);
342 
343 			if ( eState == SFX_ITEM_SET )
344 			{
345 				const SvxFontHeightItem& rSvxFontHeightItem =
346 					static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT));
347 
348 				float nHeight = (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MAP_TWIP, MAP_POINT).Height();
349 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight));
350 
351 			}
352 
353 			// --------------------------
354 			// font weight
355 			eState = _rSet.GetItemState(CFID_WEIGHT);
356 
357 			if ( eState == SFX_ITEM_SET )
358 			{
359 				const SvxWeightItem& rWeightItem =
360 					static_cast<const SvxWeightItem&>(_rSet.Get(CFID_WEIGHT));
361 
362 				float nWeight = VCLUnoHelper::ConvertFontWeight( rWeightItem.GetWeight());
363 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,makeAny(nWeight));
364 			}
365 
366 			// --------------------------
367 			// font slant
368 			eState = _rSet.GetItemState(CFID_POSTURE);
369 
370 			if ( eState == SFX_ITEM_SET )
371 			{
372 				const SvxPostureItem& rPostureItem =
373 					static_cast<const SvxPostureItem&>(_rSet.Get(CFID_POSTURE));
374 
375 				::com::sun::star::awt::FontSlant eSlant = (::com::sun::star::awt::FontSlant)rPostureItem.GetPosture();
376 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, makeAny((sal_Int16)eSlant));
377 			}
378 
379 			// --------------------------
380 			// font underline
381 			eState = _rSet.GetItemState(CFID_UNDERLINE);
382 
383 			if ( eState == SFX_ITEM_SET )
384 			{
385 				const SvxUnderlineItem& rUnderlineItem =
386 					static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE));
387 
388 				sal_Int16 nUnderline = (sal_Int16)rUnderlineItem.GetLineStyle();
389 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline));
390 
391 				// the text line color is transported in this item, too
392 				sal_Int32 nColor = rUnderlineItem.GetColor().GetColor();
393 
394 				Any aUnoColor;
395 				if (COL_AUTO != (sal_uInt32)nColor)
396 					aUnoColor <<= nColor;
397 
398 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
399 			}
400 
401 			// --------------------------
402 			// font strikeout
403 			eState = _rSet.GetItemState(CFID_STRIKEOUT);
404 
405 			if ( eState == SFX_ITEM_SET )
406 			{
407 				const SvxCrossedOutItem& rCrossedOutItem =
408 					static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT));
409 
410 				sal_Int16 nStrikeout = (sal_Int16)rCrossedOutItem.GetStrikeout();
411 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout));
412 			}
413 
414 
415 			// --------------------------
416 			// font wordline mode
417 			eState = _rSet.GetItemState(CFID_WORDLINEMODE);
418 
419 			if ( eState == SFX_ITEM_SET )
420 			{
421 				const SvxWordLineModeItem& rWordLineModeItem =
422 					static_cast<const SvxWordLineModeItem&>(_rSet.Get(CFID_WORDLINEMODE));
423 
424 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, ::cppu::bool2any(rWordLineModeItem.GetValue()));
425 			}
426 
427 
428 			// --------------------------
429 			// text color
430 			eState = _rSet.GetItemState(CFID_CHARCOLOR);
431 
432 			if ( eState == SFX_ITEM_SET )
433 			{
434 				const SvxColorItem& rColorItem =
435 					static_cast<const SvxColorItem&>(_rSet.Get(CFID_CHARCOLOR));
436 
437 				sal_Int32 nColor = rColorItem.GetValue().GetColor();
438 
439 				Any aUnoColor;
440 				if (COL_AUTO != (sal_uInt32)nColor)
441 					aUnoColor <<= nColor;
442 
443 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
444 			}
445 
446 			// --------------------------
447 			// font relief
448 			eState = _rSet.GetItemState(CFID_RELIEF);
449 
450 			if ( eState == SFX_ITEM_SET )
451 			{
452 				const SvxCharReliefItem& rReliefItem =
453 					static_cast<const SvxCharReliefItem&>(_rSet.Get(CFID_RELIEF));
454 
455 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, makeAny((sal_Int16)rReliefItem.GetValue()) );
456 			}
457 
458 			// --------------------------
459 			// font emphasis mark
460 			eState = _rSet.GetItemState(CFID_EMPHASIS);
461 
462 			if ( eState == SFX_ITEM_SET )
463 			{
464 				const SvxEmphasisMarkItem& rEmphMarkItem =
465 					static_cast<const SvxEmphasisMarkItem&>(_rSet.Get(CFID_EMPHASIS));
466 
467 				lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, makeAny((sal_Int16)rEmphMarkItem.GetEmphasisMark()) );
468 			}
469 		}
470 		catch (const Exception& )
471 		{
472         	DBG_UNHANDLED_EXCEPTION();
473 		}
474     }
475 
476 	//------------------------------------------------------------------------
translateItemsToProperties(const SfxItemSet & _rSet,const Reference<XPropertySet> & _rxModel)477 	void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
478 	{
479 		OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
480 		if ( !_rxModel.is())
481 			return;
482 
483         Sequence< NamedValue > aPropertyValues;
484         translateItemsToProperties( _rSet, aPropertyValues );
485         try
486         {
487             const NamedValue* propertyValue = aPropertyValues.getConstArray();
488             const NamedValue* propertyValueEnd = propertyValue + aPropertyValues.getLength();
489             for ( ; propertyValue != propertyValueEnd; ++propertyValue )
490                 _rxModel->setPropertyValue( propertyValue->Name, propertyValue->Value );
491         }
492         catch( const Exception& )
493         {
494         	DBG_UNHANDLED_EXCEPTION();
495         }
496 	}
497 
498 	//------------------------------------------------------------------------
createItemSet(SfxItemSet * & _rpSet,SfxItemPool * & _rpPool,SfxPoolItem ** & _rppDefaults)499 	SfxItemSet*	ControlCharacterDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
500 	{
501 		// just to be sure ....
502 		_rpSet = NULL;
503 		_rpPool = NULL;
504 		_rppDefaults = NULL;
505 
506 		// create and initialize the defaults
507 		_rppDefaults = new SfxPoolItem*[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1];
508 
509 		Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
510 
511 		SfxPoolItem** pCounter = _rppDefaults;	// want to modify this without affecting the out param _rppDefaults
512 		*pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_FONT);
513 		*pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_HEIGHT);
514 		*pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_WEIGHT);
515 		*pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_POSTURE);
516 		*pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
517 		*pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), CFID_UNDERLINE);
518 		*pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), CFID_STRIKEOUT);
519 		*pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), CFID_WORDLINEMODE);
520 		*pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), CFID_CHARCOLOR);
521 		*pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), CFID_RELIEF);
522 		*pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), CFID_EMPHASIS);
523 
524 		*pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_CJK_FONT);
525 		*pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_CJK_HEIGHT);
526 		*pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_CJK_WEIGHT);
527 		*pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_CJK_POSTURE);
528 		*pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE);
529 
530 		*pCounter++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, CFID_CASEMAP);
531 		*pCounter++ = new SvxContourItem(sal_False, CFID_CONTOUR);
532 		*pCounter++ = new SvxShadowedItem(sal_False, CFID_SHADOWED);
533 
534 		*pCounter++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST);
535 
536 		// create the pool
537 		static SfxItemInfo __READONLY_DATA aItemInfos[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1] =
538 		{
539 			{ SID_ATTR_CHAR_FONT,				0 },
540 			{ SID_ATTR_CHAR_FONTHEIGHT,			0 },
541 			{ SID_ATTR_CHAR_WEIGHT,				0 },
542 			{ SID_ATTR_CHAR_POSTURE,			0 },
543 			{ SID_ATTR_CHAR_LANGUAGE,			0 },
544 			{ SID_ATTR_CHAR_UNDERLINE,			0 },
545 			{ SID_ATTR_CHAR_STRIKEOUT,			0 },
546 			{ SID_ATTR_CHAR_WORDLINEMODE,		0 },
547 			{ SID_ATTR_CHAR_COLOR,				0 },
548 			{ SID_ATTR_CHAR_RELIEF,				0 },
549 			{ SID_ATTR_CHAR_EMPHASISMARK,		0 },
550 			{ 0,								0 },
551 			{ 0,								0 },
552 			{ 0,								0 },
553 			{ 0,								0 },
554 			{ 0,								0 },
555 			{ 0,								0 },
556 			{ 0,								0 },
557 			{ 0,								0 },
558 			{ SID_ATTR_CHAR_FONTLIST,			0 }
559 		};
560 
561 		_rpPool = new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID, CFID_LAST_ITEM_ID,
562 			aItemInfos, _rppDefaults);
563 		_rpPool->FreezeIdRanges();
564 
565 		// and, finally, the set
566 		_rpSet = new SfxItemSet(*_rpPool, sal_True);
567 
568 		return _rpSet;
569 	}
570 
571 	//-------------------------------------------------------------------------
destroyItemSet(SfxItemSet * & _rpSet,SfxItemPool * & _rpPool,SfxPoolItem ** & _rppDefaults)572 	void ControlCharacterDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
573 	{
574 		// from the pool, get and remember the font list (needs to be deleted)
575 		const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST));
576 		const FontList* pFontList = rFontListItem.GetFontList();
577 
578 		// _first_ delete the set (refering the pool)
579 		if (_rpSet)
580 		{
581 			delete _rpSet;
582 			_rpSet = NULL;
583 		}
584 
585 		// delete the pool
586 		if (_rpPool)
587 		{
588 			_rpPool->ReleaseDefaults(sal_True);
589 				// the "true" means delete the items, too
590             SfxItemPool::Free(_rpPool);
591 			_rpPool = NULL;
592 		}
593 
594 		// reset the defaults ptr
595 		_rppDefaults = NULL;
596 			// no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
597 
598 		delete pFontList;
599 	}
600 
601 	//------------------------------------------------------------------------
PageCreated(sal_uInt16 _nId,SfxTabPage & _rPage)602 	void ControlCharacterDialog::PageCreated( sal_uInt16 _nId, SfxTabPage& _rPage )
603 	{
604 		SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
605 		switch ( _nId )
606 		{
607 			case TABPAGE_CHARACTERS:
608 //CHINA001				static_cast<SvxCharNamePage&>(_rPage).SetFontList(
609 //CHINA001				static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))
610 //CHINA001				);
611 //CHINA001				static_cast<SvxCharNamePage&>(_rPage).DisableControls( DISABLE_HIDE_LANGUAGE );
612 
613 //CHINA001 				SvxFontListItem aFontListItem( static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST) ));
614 //CHINA001 				aSet.Put ( SvxFontListItem( aFontListItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
615 
616 //				aSet.Put (SfxUInt16Item(SID_CFID_FONTLIST,CFID_FONTLIST));
617 				aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))));
618 				aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
619 				_rPage.PageCreated(aSet);
620 				break;
621 		}
622 	}
623 
624 //............................................................................
625 }	// namespace pcr
626 //............................................................................
627 
628