Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / fontdialog.cxx
blobd065e7b63429327b063aba92217abba4789e6efb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <strings.hrc>
23 #include "modulepcr.hxx"
24 #include <vcl/svapp.hxx>
25 #include <vcl/unohelp.hxx>
26 #include <i18nlangtag/languagetag.hxx>
27 #include <toolkit/helper/vclunohelper.hxx>
28 #include <comphelper/types.hxx>
29 #include <comphelper/extract.hxx>
30 #include <com/sun/star/awt/FontDescriptor.hpp>
31 #include <com/sun/star/awt/FontWeight.hpp>
32 #include <com/sun/star/awt/FontSlant.hpp>
33 #include <com/sun/star/awt/FontUnderline.hpp>
34 #include <com/sun/star/awt/FontStrikeout.hpp>
35 #include "formstrings.hxx"
36 #include "fontitemids.hxx"
37 #include <editeng/charreliefitem.hxx>
38 #include <editeng/emphasismarkitem.hxx>
39 #include <editeng/fontitem.hxx>
40 #include <editeng/fhgtitem.hxx>
41 #include <editeng/postitem.hxx>
42 #include <editeng/wghtitem.hxx>
43 #include <editeng/udlnitem.hxx>
44 #include <editeng/crossedoutitem.hxx>
45 #include <editeng/colritem.hxx>
46 #include <editeng/langitem.hxx>
47 #include <editeng/wrlmitem.hxx>
48 #include <editeng/cmapitem.hxx>
49 #include <editeng/contouritem.hxx>
50 #include <editeng/shdditem.hxx>
51 #include <editeng/flstitem.hxx>
52 #include <svtools/ctrltool.hxx>
53 #include <tools/diagnose_ex.h>
54 #include <com/sun/star/beans/XPropertyState.hpp>
55 #include <svx/svxids.hrc>
56 #include <svx/svxdlg.hxx>
57 #include <svx/dialogs.hrc>
58 #include <svx/flagsdef.hxx>
59 #include <vcl/settings.hxx>
62 namespace pcr
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::beans;
70 //= OFontPropertyExtractor
72 class OFontPropertyExtractor
74 protected:
75 css::uno::Reference< css::beans::XPropertySet >
76 m_xPropValueAccess;
77 css::uno::Reference< css::beans::XPropertyState >
78 m_xPropStateAccess;
80 public:
81 explicit OFontPropertyExtractor( const css::uno::Reference< css::beans::XPropertySet >&
82 _rxProps );
84 public:
85 bool getCheckFontProperty(const OUString& _rPropName, css::uno::Any& _rValue);
86 OUString getStringFontProperty(const OUString& _rPropName, const OUString& _rDefault);
87 sal_Int16 getInt16FontProperty(const OUString& _rPropName, const sal_Int16 _nDefault);
88 sal_Int32 getInt32FontProperty(const OUString& _rPropName, const sal_Int32 _nDefault);
89 float getFloatFontProperty(const OUString& _rPropName, const float _nDefault);
91 void invalidateItem(
92 const OUString& _rPropName,
93 sal_uInt16 _nItemId,
94 SfxItemSet& _rSet,
95 bool _bForceInvalidation = false);
99 OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
100 :m_xPropValueAccess(_rxProps)
101 ,m_xPropStateAccess(_rxProps, UNO_QUERY)
103 OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
107 bool OFontPropertyExtractor::getCheckFontProperty(const OUString& _rPropName, Any& _rValue)
109 _rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
110 if (m_xPropStateAccess.is())
111 return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
113 return false;
117 OUString OFontPropertyExtractor::getStringFontProperty(const OUString& _rPropName, const OUString& _rDefault)
119 Any aValue;
120 if (getCheckFontProperty(_rPropName, aValue))
121 return _rDefault;
123 return ::comphelper::getString(aValue);
127 sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const OUString& _rPropName, const sal_Int16 _nDefault)
129 Any aValue;
130 if (getCheckFontProperty(_rPropName, aValue))
131 return _nDefault;
133 sal_Int32 nValue(_nDefault);
134 ::cppu::enum2int(nValue, aValue);
135 return static_cast<sal_Int16>(nValue);
139 sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const OUString& _rPropName, const sal_Int32 _nDefault)
141 Any aValue;
142 if (getCheckFontProperty(_rPropName, aValue))
143 return _nDefault;
145 sal_Int32 nValue(_nDefault);
146 ::cppu::enum2int(nValue, aValue);
147 return nValue;
151 float OFontPropertyExtractor::getFloatFontProperty(const OUString& _rPropName, const float _nDefault)
153 Any aValue;
154 if (getCheckFontProperty(_rPropName, aValue))
155 return _nDefault;
157 return ::comphelper::getFloat(aValue);
161 void OFontPropertyExtractor::invalidateItem(const OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, bool _bForceInvalidation)
163 if ( _bForceInvalidation
164 || ( m_xPropStateAccess.is()
165 && (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
168 _rSet.InvalidateItem(_nItemId);
171 //= ControlCharacterDialog
172 ControlCharacterDialog::ControlCharacterDialog(weld::Window* pParent, const SfxItemSet& _rCoreSet)
173 : SfxTabDialogController(pParent, "modules/spropctrlr/ui/controlfontdialog.ui", "ControlFontDialog", &_rCoreSet)
175 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
176 AddTabPage("font", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), nullptr );
177 AddTabPage("fonteffects", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), nullptr );
180 ControlCharacterDialog::~ControlCharacterDialog()
184 void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
186 OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
187 if (!_pSet || !_rxModel.is())
188 return;
192 OFontPropertyExtractor aPropExtractor(_rxModel);
194 // some items, which may be in default state, have to be filled with non-void information
195 vcl::Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
196 css::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
198 // get the current properties
199 OUString aFontName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
200 OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
201 sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
202 sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
203 float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, static_cast<float>(aDefaultFont.Height));
204 float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
205 css::awt::FontSlant nFontSlant = static_cast<css::awt::FontSlant>(aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, static_cast<sal_Int16>(aDefaultFont.Slant)));
206 sal_Int16 nFontLineStyle = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
207 sal_Int16 nFontStrikeout = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
209 sal_Int32 nTextLineColor = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, sal_uInt32(COL_AUTO));
210 sal_Int16 nFontRelief = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, static_cast<sal_Int16>(aDefaultVCLFont.GetRelief()));
211 sal_Int16 nFontEmphasisMark = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, static_cast<sal_uInt16>(aDefaultVCLFont.GetEmphasisMark()));
213 Any aValue;
214 bool bWordLineMode = aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
215 sal_Int32 nColor32 = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
217 // build SfxItems with the values
218 SvxFontItem aFontItem(static_cast<FontFamily>(nFontFamily), aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT);
220 nFontHeight = static_cast<float>(OutputDevice::LogicToLogic(Size(0, static_cast<sal_Int32>(nFontHeight)), MapMode(MapUnit::MapPoint), MapMode(MapUnit::MapTwip)).Height());
221 SvxFontHeightItem aSvxFontHeightItem(static_cast<sal_uInt32>(nFontHeight),100,CFID_HEIGHT);
223 FontWeight eWeight=vcl::unohelper::ConvertFontWeight(nFontWeight);
224 FontItalic eItalic=vcl::unohelper::ConvertFontSlant(nFontSlant);
225 FontLineStyle eUnderline=static_cast<FontLineStyle>(nFontLineStyle);
226 FontStrikeout eStrikeout=static_cast<FontStrikeout>(nFontStrikeout);
228 SvxWeightItem aWeightItem(eWeight,CFID_WEIGHT);
229 SvxPostureItem aPostureItem(eItalic,CFID_POSTURE);
231 SvxCrossedOutItem aCrossedOutItem(eStrikeout,CFID_STRIKEOUT);
232 SvxWordLineModeItem aWordLineModeItem(bWordLineMode, CFID_WORDLINEMODE);
234 SvxUnderlineItem aUnderlineItem(eUnderline,CFID_UNDERLINE);
235 aUnderlineItem.SetColor(Color(nTextLineColor));
237 SvxColorItem aSvxColorItem(Color(nColor32),CFID_CHARCOLOR);
238 SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE);
240 // the 2 CJK props
241 SvxCharReliefItem aFontReliefItem(static_cast<FontRelief>(nFontRelief), CFID_RELIEF);
242 SvxEmphasisMarkItem aEmphasisMarkitem(static_cast<FontEmphasisMark>(nFontEmphasisMark), CFID_EMPHASIS);
244 _pSet->Put(aFontItem);
245 _pSet->Put(aSvxFontHeightItem);
246 _pSet->Put(aWeightItem);
247 _pSet->Put(aPostureItem);
248 _pSet->Put(aLanguageItem);
249 _pSet->Put(aUnderlineItem);
250 _pSet->Put(aCrossedOutItem);
251 _pSet->Put(aWordLineModeItem);
252 _pSet->Put(aSvxColorItem);
253 _pSet->Put(aFontReliefItem);
254 _pSet->Put(aEmphasisMarkitem);
256 aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
257 aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
258 aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, CFID_WEIGHT, *_pSet, css::awt::FontWeight::DONTKNOW == nFontWeight);
259 aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, CFID_POSTURE, *_pSet, css::awt::FontSlant_DONTKNOW == nFontSlant);
260 aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, CFID_UNDERLINE, *_pSet, css::awt::FontUnderline::DONTKNOW == nFontLineStyle);
261 aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, CFID_STRIKEOUT, *_pSet, css::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
262 aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, CFID_WORDLINEMODE, *_pSet);
263 aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, CFID_CHARCOLOR, *_pSet);
264 aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, CFID_RELIEF, *_pSet);
265 aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, CFID_EMPHASIS, *_pSet);
267 catch (const Exception&)
269 OSL_FAIL("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
272 _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONT);
273 _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT);
274 _pSet->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE);
275 _pSet->DisableItem(SID_ATTR_CHAR_CJK_POSTURE);
276 _pSet->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT);
278 _pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
279 _pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
280 _pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
283 namespace
285 void lcl_pushBackPropertyValue( std::vector< NamedValue >& _out_properties, const OUString& _name, const Any& _value )
287 _out_properties.push_back( NamedValue( _name, _value ) );
291 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, std::vector< NamedValue >& _out_properties )
293 _out_properties.clear();
298 // font name
299 SfxItemState eState = _rSet.GetItemState(CFID_FONT);
301 if ( eState == SfxItemState::SET )
303 const SvxFontItem& rFontItem =
304 static_cast<const SvxFontItem&>(_rSet.Get(CFID_FONT));
306 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , makeAny(rFontItem.GetFamilyName()));
307 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(rFontItem.GetStyleName()));
308 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny(static_cast<sal_Int16>(rFontItem.GetFamily())));
309 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny(static_cast<sal_Int16>(rFontItem.GetCharSet())));
313 // font height
314 eState = _rSet.GetItemState(CFID_HEIGHT);
316 if ( eState == SfxItemState::SET )
318 const SvxFontHeightItem& rSvxFontHeightItem =
319 static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT));
321 float nHeight = static_cast<float>(OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MapMode(MapUnit::MapTwip), MapMode(MapUnit::MapPoint)).Height());
322 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight));
327 // font weight
328 eState = _rSet.GetItemState(CFID_WEIGHT);
330 if ( eState == SfxItemState::SET )
332 const SvxWeightItem& rWeightItem =
333 static_cast<const SvxWeightItem&>(_rSet.Get(CFID_WEIGHT));
335 float nWeight = vcl::unohelper::ConvertFontWeight(rWeightItem.GetWeight());
336 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,makeAny(nWeight));
340 // font slant
341 eState = _rSet.GetItemState(CFID_POSTURE);
343 if ( eState == SfxItemState::SET )
345 const SvxPostureItem& rPostureItem =
346 static_cast<const SvxPostureItem&>(_rSet.Get(CFID_POSTURE));
348 css::awt::FontSlant eSlant = vcl::unohelper::ConvertFontSlant(rPostureItem.GetPosture());
349 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, makeAny(static_cast<sal_Int16>(eSlant)));
353 // font underline
354 eState = _rSet.GetItemState(CFID_UNDERLINE);
356 if ( eState == SfxItemState::SET )
358 const SvxUnderlineItem& rUnderlineItem =
359 static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE));
361 sal_Int16 nUnderline = static_cast<sal_Int16>(rUnderlineItem.GetLineStyle());
362 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline));
364 // the text line color is transported in this item, too
365 Color nColor = rUnderlineItem.GetColor();
367 Any aUnoColor;
368 if (COL_AUTO != nColor)
369 aUnoColor <<= nColor;
371 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
375 // font strikeout
376 eState = _rSet.GetItemState(CFID_STRIKEOUT);
378 if ( eState == SfxItemState::SET )
380 const SvxCrossedOutItem& rCrossedOutItem =
381 static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT));
383 sal_Int16 nStrikeout = static_cast<sal_Int16>(rCrossedOutItem.GetStrikeout());
384 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout));
388 // font wordline mode
389 eState = _rSet.GetItemState(CFID_WORDLINEMODE);
391 if ( eState == SfxItemState::SET )
393 const SvxWordLineModeItem& rWordLineModeItem =
394 static_cast<const SvxWordLineModeItem&>(_rSet.Get(CFID_WORDLINEMODE));
396 lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, css::uno::makeAny(rWordLineModeItem.GetValue()));
400 // text color
401 eState = _rSet.GetItemState(CFID_CHARCOLOR);
403 if ( eState == SfxItemState::SET )
405 const SvxColorItem& rColorItem =
406 static_cast<const SvxColorItem&>(_rSet.Get(CFID_CHARCOLOR));
408 Color nColor = rColorItem.GetValue();
410 Any aUnoColor;
411 if (COL_AUTO != nColor)
412 aUnoColor <<= nColor;
414 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
418 // font relief
419 eState = _rSet.GetItemState(CFID_RELIEF);
421 if ( eState == SfxItemState::SET )
423 const SvxCharReliefItem& rReliefItem =
424 static_cast<const SvxCharReliefItem&>(_rSet.Get(CFID_RELIEF));
426 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, makeAny(static_cast<sal_Int16>(rReliefItem.GetValue())) );
430 // font emphasis mark
431 eState = _rSet.GetItemState(CFID_EMPHASIS);
433 if ( eState == SfxItemState::SET )
435 const SvxEmphasisMarkItem& rEmphMarkItem =
436 static_cast<const SvxEmphasisMarkItem&>(_rSet.Get(CFID_EMPHASIS));
438 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, makeAny(static_cast<sal_Int16>(rEmphMarkItem.GetEmphasisMark())) );
441 catch (const Exception& )
443 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
447 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
449 OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
450 if ( !_rxModel.is())
451 return;
453 std::vector< NamedValue > aPropertyValues;
454 translateItemsToProperties( _rSet, aPropertyValues );
457 for ( const NamedValue& rNV : aPropertyValues )
458 _rxModel->setPropertyValue( rNV.Name, rNV.Value );
460 catch( const Exception& )
462 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
466 void ControlCharacterDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
468 // just to be sure...
469 _rpSet = nullptr;
470 _rpPool = nullptr;
471 _rpDefaults = nullptr;
473 // create and initialize the defaults
474 _rpDefaults = new std::vector<SfxPoolItem*>(CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1);
476 vcl::Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
478 SfxPoolItem** pCounter = _rpDefaults->data(); // want to modify this without affecting the out param _rppDefaults
479 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamilyType(), aDefaultVCLFont.GetFamilyName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_FONT);
480 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetFontHeight(), 100, CFID_HEIGHT);
481 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_WEIGHT);
482 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_POSTURE);
483 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_LANGUAGE);
484 *pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), CFID_UNDERLINE);
485 *pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), CFID_STRIKEOUT);
486 *pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), CFID_WORDLINEMODE);
487 *pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), CFID_CHARCOLOR);
488 *pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), CFID_RELIEF);
489 *pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), CFID_EMPHASIS);
491 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamilyType(), aDefaultVCLFont.GetFamilyName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_CJK_FONT);
492 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetFontHeight(), 100, CFID_CJK_HEIGHT);
493 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_CJK_WEIGHT);
494 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_CJK_POSTURE);
495 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), CFID_CJK_LANGUAGE);
497 *pCounter++ = new SvxCaseMapItem(SvxCaseMap::NotMapped, CFID_CASEMAP);
498 *pCounter++ = new SvxContourItem(false, CFID_CONTOUR);
499 *pCounter++ = new SvxShadowedItem(false, CFID_SHADOWED);
501 *pCounter++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST);
503 // create the pool
504 static SfxItemInfo const aItemInfos[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1] =
506 { SID_ATTR_CHAR_FONT, false },
507 { SID_ATTR_CHAR_FONTHEIGHT, false },
508 { SID_ATTR_CHAR_WEIGHT, false },
509 { SID_ATTR_CHAR_POSTURE, false },
510 { SID_ATTR_CHAR_LANGUAGE, false },
511 { SID_ATTR_CHAR_UNDERLINE, false },
512 { SID_ATTR_CHAR_STRIKEOUT, false },
513 { SID_ATTR_CHAR_WORDLINEMODE, false },
514 { SID_ATTR_CHAR_COLOR, false },
515 { SID_ATTR_CHAR_RELIEF, false },
516 { SID_ATTR_CHAR_EMPHASISMARK, false },
517 { 0, false },
518 { 0, false },
519 { 0, false },
520 { 0, false },
521 { 0, false },
522 { 0, false },
523 { 0, false },
524 { 0, false },
525 { SID_ATTR_CHAR_FONTLIST, false }
528 _rpPool = new SfxItemPool("PCRControlFontItemPool", CFID_FIRST_ITEM_ID, CFID_LAST_ITEM_ID,
529 aItemInfos, _rpDefaults);
530 _rpPool->FreezeIdRanges();
532 // and, finally, the set
533 _rpSet.reset(new SfxItemSet(*_rpPool));
536 void ControlCharacterDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, SfxItemPool*& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
538 // from the pool, get and remember the font list (needs to be deleted)
539 const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST));
540 const FontList* pFontList = rFontListItem.GetFontList();
542 // _first_ delete the set (referring the pool)
543 _rpSet.reset();
545 // delete the pool
546 _rpPool->ReleaseDefaults(true);
547 // the "true" means delete the items, too
548 SfxItemPool::Free(_rpPool);
549 _rpPool = nullptr;
551 // reset the defaults ptr
552 _rpDefaults = nullptr;
553 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
555 delete pFontList;
558 void ControlCharacterDialog::PageCreated(const OString& rId, SfxTabPage& rPage)
560 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
561 if (rId == "font")
563 aSet.Put (static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST)));
564 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
565 rPage.PageCreated(aSet);
568 } // namespace pcr
571 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */