LibreOffice Module extensions (master) 1
fontdialog.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "fontdialog.hxx"
21#include <vcl/outdev.hxx>
22#include <vcl/settings.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/unohelp.hxx>
27#include <comphelper/types.hxx>
29#include <com/sun/star/awt/FontDescriptor.hpp>
30#include <com/sun/star/awt/FontWeight.hpp>
31#include <com/sun/star/awt/FontSlant.hpp>
32#include <com/sun/star/awt/FontUnderline.hpp>
33#include <com/sun/star/awt/FontStrikeout.hpp>
34#include "formstrings.hxx"
37#include <editeng/fontitem.hxx>
38#include <editeng/fhgtitem.hxx>
39#include <editeng/postitem.hxx>
40#include <editeng/wghtitem.hxx>
41#include <editeng/udlnitem.hxx>
43#include <editeng/colritem.hxx>
44#include <editeng/langitem.hxx>
45#include <editeng/wrlmitem.hxx>
46#include <editeng/cmapitem.hxx>
48#include <editeng/shdditem.hxx>
49#include <editeng/flstitem.hxx>
50#include <svtools/ctrltool.hxx>
52#include <com/sun/star/beans/XPropertyState.hpp>
53#include <svx/svxids.hrc>
54#include <svx/svxdlg.hxx>
55#include <svx/dialogs.hrc>
56#include <svx/flagsdef.hxx>
57
58
59namespace pcr
60{
61
62
63 using namespace ::com::sun::star::uno;
64 using namespace ::com::sun::star::beans;
65
66
67 //= OFontPropertyExtractor
68
69 namespace FontItemIds
70 {
71 constexpr sal_uInt16 CFID_FONT = 1;
72 constexpr sal_uInt16 CFID_HEIGHT = 2;
73 constexpr sal_uInt16 CFID_WEIGHT = 3;
74 constexpr sal_uInt16 CFID_POSTURE = 4;
75 constexpr sal_uInt16 CFID_LANGUAGE = 5;
76 constexpr sal_uInt16 CFID_UNDERLINE = 6;
77 constexpr sal_uInt16 CFID_STRIKEOUT = 7;
79 constexpr sal_uInt16 CFID_CHARCOLOR = 9;
80 constexpr sal_uInt16 CFID_RELIEF = 10;
82
83 constexpr sal_uInt16 CFID_CJK_FONT = 12;
84 constexpr sal_uInt16 CFID_CJK_HEIGHT = 13;
85 constexpr sal_uInt16 CFID_CJK_WEIGHT = 14;
86 constexpr sal_uInt16 CFID_CJK_POSTURE = 15;
87 constexpr sal_uInt16 CFID_CJK_LANGUAGE = 16;
88 constexpr sal_uInt16 CFID_CASEMAP = 17;
91
92 constexpr sal_uInt16 CFID_FONTLIST = 20;
93
94 constexpr sal_uInt16 CFID_FIRST_ITEM_ID = CFID_FONT;
95 constexpr sal_uInt16 CFID_LAST_ITEM_ID = CFID_FONTLIST;
96 }
97
98 namespace {
99
100 class OFontPropertyExtractor
101 {
102 protected:
103 css::uno::Reference< css::beans::XPropertySet >
104 m_xPropValueAccess;
105 css::uno::Reference< css::beans::XPropertyState >
106 m_xPropStateAccess;
107
108 public:
109 explicit OFontPropertyExtractor( const css::uno::Reference< css::beans::XPropertySet >&
110 _rxProps );
111
112 public:
113 bool getCheckFontProperty(const OUString& _rPropName, css::uno::Any& _rValue);
114 OUString getStringFontProperty(const OUString& _rPropName, const OUString& _rDefault);
115 sal_Int16 getInt16FontProperty(const OUString& _rPropName, const sal_Int16 _nDefault);
116 sal_Int32 getInt32FontProperty(const OUString& _rPropName, const sal_Int32 _nDefault);
117 float getFloatFontProperty(const OUString& _rPropName, const float _nDefault);
118
119 void invalidateItem(
120 const OUString& _rPropName,
121 sal_uInt16 _nItemId,
122 SfxItemSet& _rSet,
123 bool _bForceInvalidation = false);
124 };
125
126 }
127
128 OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
129 :m_xPropValueAccess(_rxProps)
130 ,m_xPropStateAccess(_rxProps, UNO_QUERY)
131 {
132 OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
133 }
134
135
136 bool OFontPropertyExtractor::getCheckFontProperty(const OUString& _rPropName, Any& _rValue)
137 {
138 _rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
139 if (m_xPropStateAccess.is())
140 return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
141
142 return false;
143 }
144
145
146 OUString OFontPropertyExtractor::getStringFontProperty(const OUString& _rPropName, const OUString& _rDefault)
147 {
148 Any aValue;
149 if (getCheckFontProperty(_rPropName, aValue))
150 return _rDefault;
151
152 return ::comphelper::getString(aValue);
153 }
154
155
156 sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const OUString& _rPropName, const sal_Int16 _nDefault)
157 {
158 Any aValue;
159 if (getCheckFontProperty(_rPropName, aValue))
160 return _nDefault;
161
162 sal_Int32 nValue(_nDefault);
163 ::cppu::enum2int(nValue, aValue);
164 return static_cast<sal_Int16>(nValue);
165 }
166
167
168 sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const OUString& _rPropName, const sal_Int32 _nDefault)
169 {
170 Any aValue;
171 if (getCheckFontProperty(_rPropName, aValue))
172 return _nDefault;
173
174 sal_Int32 nValue(_nDefault);
175 ::cppu::enum2int(nValue, aValue);
176 return nValue;
177 }
178
179
180 float OFontPropertyExtractor::getFloatFontProperty(const OUString& _rPropName, const float _nDefault)
181 {
182 Any aValue;
183 if (getCheckFontProperty(_rPropName, aValue))
184 return _nDefault;
185
186 return ::comphelper::getFloat(aValue);
187 }
188
189
190 void OFontPropertyExtractor::invalidateItem(const OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, bool _bForceInvalidation)
191 {
192 if ( _bForceInvalidation
193 || ( m_xPropStateAccess.is()
194 && (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
195 )
196 )
197 _rSet.InvalidateItem(_nItemId);
198 }
199
200 //= ControlCharacterDialog
202 : SfxTabDialogController(pParent, "modules/spropctrlr/ui/controlfontdialog.ui", "ControlFontDialog", &_rCoreSet)
203 {
205 AddTabPage("font", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), nullptr );
206 AddTabPage("fonteffects", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), nullptr );
207 }
208
210 {
211 }
212
213 void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
214 {
215 OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
216 if (!_pSet || !_rxModel.is())
217 return;
218
219 try
220 {
221 OFontPropertyExtractor aPropExtractor(_rxModel);
222
223 // some items, which may be in default state, have to be filled with non-void information
225 css::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
226
227 // get the current properties
228 OUString aFontName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
229 OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
230 sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
231 sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
232 float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, static_cast<float>(aDefaultFont.Height));
233 float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
234 css::awt::FontSlant nFontSlant = static_cast<css::awt::FontSlant>(aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, static_cast<sal_Int16>(aDefaultFont.Slant)));
235 sal_Int16 nFontLineStyle = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
236 sal_Int16 nFontStrikeout = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
237
238 sal_Int32 nTextLineColor = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, sal_uInt32(COL_AUTO));
239 sal_Int16 nFontRelief = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, static_cast<sal_Int16>(aDefaultVCLFont.GetRelief()));
240 sal_Int16 nFontEmphasisMark = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, static_cast<sal_uInt16>(aDefaultVCLFont.GetEmphasisMark()));
241
242 Any aValue;
243 bool bWordLineMode = aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
244 sal_Int32 nColor32 = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
245
246 // build SfxItems with the values
247 SvxFontItem aFontItem(static_cast<FontFamily>(nFontFamily), aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, FontItemIds::CFID_FONT);
248
249 nFontHeight = static_cast<float>(o3tl::convert(nFontHeight, o3tl::Length::pt, o3tl::Length::twip));
250
251 SvxFontHeightItem aSvxFontHeightItem(static_cast<sal_uInt32>(nFontHeight),100,FontItemIds::CFID_HEIGHT);
252
255 FontLineStyle eUnderline=static_cast<FontLineStyle>(nFontLineStyle);
256 FontStrikeout eStrikeout=static_cast<FontStrikeout>(nFontStrikeout);
257
258 SvxWeightItem aWeightItem(eWeight,FontItemIds::CFID_WEIGHT);
259 SvxPostureItem aPostureItem(eItalic,FontItemIds::CFID_POSTURE);
260
261 SvxCrossedOutItem aCrossedOutItem(eStrikeout,FontItemIds::CFID_STRIKEOUT);
262 SvxWordLineModeItem aWordLineModeItem(bWordLineMode, FontItemIds::CFID_WORDLINEMODE);
263
264 SvxUnderlineItem aUnderlineItem(eUnderline,FontItemIds::CFID_UNDERLINE);
265 aUnderlineItem.SetColor(Color(ColorTransparency, nTextLineColor));
266
268 SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), FontItemIds::CFID_LANGUAGE);
269
270 // the 2 CJK props
271 SvxCharReliefItem aFontReliefItem(static_cast<FontRelief>(nFontRelief), FontItemIds::CFID_RELIEF);
272 SvxEmphasisMarkItem aEmphasisMarkitem(static_cast<FontEmphasisMark>(nFontEmphasisMark), FontItemIds::CFID_EMPHASIS);
273
274 _pSet->Put(aFontItem);
275 _pSet->Put(aSvxFontHeightItem);
276 _pSet->Put(aWeightItem);
277 _pSet->Put(aPostureItem);
278 _pSet->Put(aLanguageItem);
279 _pSet->Put(aUnderlineItem);
280 _pSet->Put(aCrossedOutItem);
281 _pSet->Put(aWordLineModeItem);
282 _pSet->Put(aSvxColorItem);
283 _pSet->Put(aFontReliefItem);
284 _pSet->Put(aEmphasisMarkitem);
285
286 aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, FontItemIds::CFID_FONT, *_pSet);
287 aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, FontItemIds::CFID_HEIGHT, *_pSet);
288 aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, FontItemIds::CFID_WEIGHT, *_pSet, css::awt::FontWeight::DONTKNOW == nFontWeight);
289 aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, FontItemIds::CFID_POSTURE, *_pSet, css::awt::FontSlant_DONTKNOW == nFontSlant);
290 aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, FontItemIds::CFID_UNDERLINE, *_pSet, css::awt::FontUnderline::DONTKNOW == nFontLineStyle);
291 aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, FontItemIds::CFID_STRIKEOUT, *_pSet, css::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
292 aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, FontItemIds::CFID_WORDLINEMODE, *_pSet);
293 aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, FontItemIds::CFID_CHARCOLOR, *_pSet);
294 aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, FontItemIds::CFID_RELIEF, *_pSet);
295 aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, FontItemIds::CFID_EMPHASIS, *_pSet);
296 }
297 catch (const Exception&)
298 {
299 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "ControlCharacterDialog::translatePropertiesToItems");
300 }
301
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);
307
308 _pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
309 _pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
310 _pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
311 }
312
313 namespace
314 {
315 void lcl_pushBackPropertyValue( std::vector< NamedValue >& _out_properties, const OUString& _name, const Any& _value )
316 {
317 _out_properties.push_back( NamedValue( _name, _value ) );
318 }
319 }
320
321 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, std::vector< NamedValue >& _out_properties )
322 {
323 _out_properties.clear();
324
325 try
326 {
327
328 // font name
330
331 if ( eState == SfxItemState::SET )
332 {
333 const SvxFontItem& rFontItem =
334 static_cast<const SvxFontItem&>(_rSet.Get(FontItemIds::CFID_FONT));
335
336 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , Any(rFontItem.GetFamilyName()));
337 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, Any(rFontItem.GetStyleName()));
338 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , Any(static_cast<sal_Int16>(rFontItem.GetFamily())));
339 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , Any(static_cast<sal_Int16>(rFontItem.GetCharSet())));
340 }
341
342
343 // font height
345
346 if ( eState == SfxItemState::SET )
347 {
348 const SvxFontHeightItem& rSvxFontHeightItem =
349 static_cast<const SvxFontHeightItem&>(_rSet.Get(FontItemIds::CFID_HEIGHT));
350
351 float nHeight = static_cast<float>(o3tl::convert(rSvxFontHeightItem.GetHeight(), o3tl::Length::twip, o3tl::Length::pt));
352 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,Any(nHeight));
353
354 }
355
356
357 // font weight
359
360 if ( eState == SfxItemState::SET )
361 {
362 const SvxWeightItem& rWeightItem =
363 static_cast<const SvxWeightItem&>(_rSet.Get(FontItemIds::CFID_WEIGHT));
364
365 float nWeight = vcl::unohelper::ConvertFontWeight(rWeightItem.GetWeight());
366 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,Any(nWeight));
367 }
368
369
370 // font slant
372
373 if ( eState == SfxItemState::SET )
374 {
375 const SvxPostureItem& rPostureItem =
376 static_cast<const SvxPostureItem&>(_rSet.Get(FontItemIds::CFID_POSTURE));
377
378 css::awt::FontSlant eSlant = vcl::unohelper::ConvertFontSlant(rPostureItem.GetPosture());
379 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, Any(static_cast<sal_Int16>(eSlant)));
380 }
381
382
383 // font underline
385
386 if ( eState == SfxItemState::SET )
387 {
388 const SvxUnderlineItem& rUnderlineItem =
389 static_cast<const SvxUnderlineItem&>(_rSet.Get(FontItemIds::CFID_UNDERLINE));
390
391 sal_Int16 nUnderline = static_cast<sal_Int16>(rUnderlineItem.GetLineStyle());
392 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,Any(nUnderline));
393
394 // the text line color is transported in this item, too
395 Color nColor = rUnderlineItem.GetColor();
396
397 Any aUnoColor;
398 if (COL_AUTO != nColor)
399 aUnoColor <<= nColor;
400
401 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
402 }
403
404
405 // font strikeout
407
408 if ( eState == SfxItemState::SET )
409 {
410 const SvxCrossedOutItem& rCrossedOutItem =
411 static_cast<const SvxCrossedOutItem&>(_rSet.Get(FontItemIds::CFID_STRIKEOUT));
412
413 sal_Int16 nStrikeout = static_cast<sal_Int16>(rCrossedOutItem.GetStrikeout());
414 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,Any(nStrikeout));
415 }
416
417
418 // font wordline mode
420
421 if ( eState == SfxItemState::SET )
422 {
423 const SvxWordLineModeItem& rWordLineModeItem =
425
426 lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, css::uno::Any(rWordLineModeItem.GetValue()));
427 }
428
429
430 // text color
432
433 if ( eState == SfxItemState::SET )
434 {
435 const SvxColorItem& rColorItem =
436 static_cast<const SvxColorItem&>(_rSet.Get(FontItemIds::CFID_CHARCOLOR));
437
438 Color nColor = rColorItem.GetValue();
439
440 Any aUnoColor;
441 if (COL_AUTO != nColor)
442 aUnoColor <<= nColor;
443
444 lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
445 }
446
447
448 // font relief
450
451 if ( eState == SfxItemState::SET )
452 {
453 const SvxCharReliefItem& rReliefItem =
454 static_cast<const SvxCharReliefItem&>(_rSet.Get(FontItemIds::CFID_RELIEF));
455
456 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, Any(static_cast<sal_Int16>(rReliefItem.GetValue())) );
457 }
458
459
460 // font emphasis mark
462
463 if ( eState == SfxItemState::SET )
464 {
465 const SvxEmphasisMarkItem& rEmphMarkItem = _rSet.Get(FontItemIds::CFID_EMPHASIS);
466
467 lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, Any(static_cast<sal_Int16>(rEmphMarkItem.GetEmphasisMark())) );
468 }
469 }
470 catch (const Exception& )
471 {
472 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
473 }
474 }
475
476 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
477 {
478 OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
479 if ( !_rxModel.is())
480 return;
481
482 std::vector< NamedValue > aPropertyValues;
483 translateItemsToProperties( _rSet, aPropertyValues );
484 try
485 {
486 for ( const NamedValue& rNV : aPropertyValues )
487 _rxModel->setPropertyValue( rNV.Name, rNV.Value );
488 }
489 catch( const Exception& )
490 {
491 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
492 }
493 }
494
495 void ControlCharacterDialog::createItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
496 {
497 // just to be sure...
498 _rpSet = nullptr;
499 _rpPool = nullptr;
500 _rpDefaults = nullptr;
501
502 // create and initialize the defaults
503 _rpDefaults = new std::vector<SfxPoolItem*>(FontItemIds::CFID_LAST_ITEM_ID - FontItemIds::CFID_FIRST_ITEM_ID + 1);
504
506
507 SfxPoolItem** pCounter = _rpDefaults->data(); // want to modify this without affecting the out param _rppDefaults
508 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamilyType(), aDefaultVCLFont.GetFamilyName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), FontItemIds::CFID_FONT);
509 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetFontHeight(), 100, FontItemIds::CFID_HEIGHT);
510 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), FontItemIds::CFID_WEIGHT);
511 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), FontItemIds::CFID_POSTURE);
512 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), FontItemIds::CFID_LANGUAGE);
513 *pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), FontItemIds::CFID_UNDERLINE);
514 *pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), FontItemIds::CFID_STRIKEOUT);
515 *pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), FontItemIds::CFID_WORDLINEMODE);
516 *pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), FontItemIds::CFID_CHARCOLOR);
517 *pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), FontItemIds::CFID_RELIEF);
518 *pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), FontItemIds::CFID_EMPHASIS);
519
520 *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamilyType(), aDefaultVCLFont.GetFamilyName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), FontItemIds::CFID_CJK_FONT);
521 *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetFontHeight(), 100, FontItemIds::CFID_CJK_HEIGHT);
522 *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), FontItemIds::CFID_CJK_WEIGHT);
523 *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), FontItemIds::CFID_CJK_POSTURE);
524 *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), FontItemIds::CFID_CJK_LANGUAGE);
525
526 *pCounter++ = new SvxCaseMapItem(SvxCaseMap::NotMapped, FontItemIds::CFID_CASEMAP);
527 *pCounter++ = new SvxContourItem(false, FontItemIds::CFID_CONTOUR);
528 *pCounter++ = new SvxShadowedItem(false, FontItemIds::CFID_SHADOWED);
529
531
532 // create the pool
534 {
535 { SID_ATTR_CHAR_FONT, false },
536 { SID_ATTR_CHAR_FONTHEIGHT, false },
537 { SID_ATTR_CHAR_WEIGHT, false },
538 { SID_ATTR_CHAR_POSTURE, false },
539 { SID_ATTR_CHAR_LANGUAGE, false },
540 { SID_ATTR_CHAR_UNDERLINE, false },
541 { SID_ATTR_CHAR_STRIKEOUT, false },
542 { SID_ATTR_CHAR_WORDLINEMODE, false },
543 { SID_ATTR_CHAR_COLOR, false },
544 { SID_ATTR_CHAR_RELIEF, false },
545 { SID_ATTR_CHAR_EMPHASISMARK, false },
546 { 0, false },
547 { 0, false },
548 { 0, false },
549 { 0, false },
550 { 0, false },
551 { 0, false },
552 { 0, false },
553 { 0, false },
554 { SID_ATTR_CHAR_FONTLIST, false }
555 };
556
557 _rpPool = new SfxItemPool("PCRControlFontItemPool", FontItemIds::CFID_FIRST_ITEM_ID, FontItemIds::CFID_LAST_ITEM_ID,
558 aItemInfos, _rpDefaults);
559 _rpPool->FreezeIdRanges();
560
561 // and, finally, the set
562 _rpSet.reset(new SfxItemSet(*_rpPool));
563 }
564
565 void ControlCharacterDialog::destroyItemSet(std::unique_ptr<SfxItemSet>& _rpSet, rtl::Reference<SfxItemPool>& _rpPool, std::vector<SfxPoolItem*>*& _rpDefaults)
566 {
567 // from the pool, get and remember the font list (needs to be deleted)
568 const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(FontItemIds::CFID_FONTLIST));
569 const FontList* pFontList = rFontListItem.GetFontList();
570
571 // _first_ delete the set (referring the pool)
572 _rpSet.reset();
573
574 // delete the pool
575 _rpPool->ReleaseDefaults(true);
576 // the "true" means delete the items, too
577 _rpPool = nullptr;
578
579 // reset the defaults ptr
580 _rpDefaults = nullptr;
581 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
582
583 delete pFontList;
584 }
585
586 void ControlCharacterDialog::PageCreated(const OUString& rId, SfxTabPage& rPage)
587 {
588 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
589 if (rId == "font")
590 {
591 aSet.Put (static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(FontItemIds::CFID_FONTLIST)));
592 aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
593 rPage.PageCreated(aSet);
594 }
595 }
596} // namespace pcr
597
598
599/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertyValueVector_t aPropertyValues
const StyleSettings & GetStyleSettings() const
static OutputDevice * GetDefaultDevice()
static const AllSettings & GetSettings()
const AllSettings & GetSettings() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void InvalidateItem(sal_uInt16 nWhich)
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const SfxAllItemSet &aSet)
const vcl::Font & GetAppFont() const
static SvxAbstractDialogFactory * Create()
const Color & GetValue() const
FontStrikeout GetStrikeout() const
FontEmphasisMark GetEmphasisMark() const
sal_uInt32 GetHeight() const
FontFamily GetFamily() const
const OUString & GetStyleName() const
rtl_TextEncoding GetCharSet() const
const OUString & GetFamilyName() const
const FontList * GetFontList() const
FontItalic GetPosture() const
FontLineStyle GetLineStyle() const
const Color & GetColor() const
void SetColor(const Color &rColor)
FontWeight GetWeight() const
static css::awt::FontDescriptor CreateFontDescriptor(const vcl::Font &rFont)
static void translateItemsToProperties(const SfxItemSet &_rSet, const css::uno::Reference< css::beans::XPropertySet > &_rxModel)
fills the given property set with values obtained from the given item set
static void destroyItemSet(std::unique_ptr< SfxItemSet > &_rpSet, rtl::Reference< SfxItemPool > &_rpPool, std::vector< SfxPoolItem * > *&_rpDefaults)
destroys an item previously created with <method>createItemSet</method>
Definition: fontdialog.cxx:565
static void createItemSet(std::unique_ptr< SfxItemSet > &_rpSet, rtl::Reference< SfxItemPool > &_rpPool, std::vector< SfxPoolItem * > *&_rpDefaults)
creates an item set to be used with this dialog
Definition: fontdialog.cxx:495
ControlCharacterDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)
Definition: fontdialog.cxx:201
virtual ~ControlCharacterDialog() override
Definition: fontdialog.cxx:209
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: fontdialog.cxx:586
static void translatePropertiesToItems(const css::uno::Reference< css::beans::XPropertySet > &_rxModel, SfxItemSet *_pSet)
fills the given item set with values obtained from the given property set
Definition: fontdialog.cxx:213
tools::Long GetFontHeight() const
FontFamily GetFamilyType()
const OUString & GetStyleName() const
FontStrikeout GetStrikeout() const
FontRelief GetRelief() const
FontEmphasisMark GetEmphasisMark() const
FontItalic GetItalic()
const OUString & GetFamilyName() const
const Color & GetColor() const
FontPitch GetPitch()
FontWeight GetWeight()
FontLineStyle GetUnderline() const
rtl_TextEncoding GetCharSet() const
bool IsWordLineMode() const
ColorTransparency
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
SfxItemInfo const aItemInfos[]
#define DISABLE_HIDE_LANGUAGE
sal_Int16 nValue
FontRelief
FontLineStyle
FontStrikeout
PITCH_DONTKNOW
FontItalic
FontEmphasisMark
FontFamily
constexpr OUStringLiteral PROPERTY_FONT_FAMILY
constexpr OUStringLiteral PROPERTY_FONT_SLANT
constexpr OUStringLiteral PROPERTY_FONT_WEIGHT
constexpr OUStringLiteral PROPERTY_FONT_HEIGHT
constexpr OUStringLiteral PROPERTY_FONT_UNDERLINE
constexpr OUStringLiteral PROPERTY_FONT_STRIKEOUT
constexpr OUStringLiteral PROPERTY_FONT_RELIEF
constexpr OUStringLiteral PROPERTY_TEXTCOLOR
constexpr OUStringLiteral PROPERTY_FONT_CHARSET
constexpr OUStringLiteral PROPERTY_FONT_EMPHASIS_MARK
constexpr OUStringLiteral PROPERTY_WORDLINEMODE
constexpr OUStringLiteral PROPERTY_FONT_STYLENAME
constexpr OUStringLiteral PROPERTY_TEXTLINECOLOR
constexpr OUStringLiteral PROPERTY_FONT_NAME
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
@ Exception
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
constexpr sal_uInt16 CFID_LANGUAGE
Definition: fontdialog.cxx:75
constexpr sal_uInt16 CFID_HEIGHT
Definition: fontdialog.cxx:72
constexpr sal_uInt16 CFID_RELIEF
Definition: fontdialog.cxx:80
constexpr sal_uInt16 CFID_CJK_FONT
Definition: fontdialog.cxx:83
constexpr sal_uInt16 CFID_FONT
Definition: fontdialog.cxx:71
constexpr sal_uInt16 CFID_CASEMAP
Definition: fontdialog.cxx:88
constexpr sal_uInt16 CFID_CJK_POSTURE
Definition: fontdialog.cxx:86
constexpr sal_uInt16 CFID_POSTURE
Definition: fontdialog.cxx:74
constexpr sal_uInt16 CFID_LAST_ITEM_ID
Definition: fontdialog.cxx:95
constexpr TypedWhichId< SvxShadowedItem > CFID_SHADOWED(19)
constexpr sal_uInt16 CFID_FIRST_ITEM_ID
Definition: fontdialog.cxx:94
constexpr sal_uInt16 CFID_CJK_HEIGHT
Definition: fontdialog.cxx:84
constexpr TypedWhichId< SvxContourItem > CFID_CONTOUR(18)
constexpr sal_uInt16 CFID_CHARCOLOR
Definition: fontdialog.cxx:79
constexpr TypedWhichId< SvxEmphasisMarkItem > CFID_EMPHASIS(11)
constexpr sal_uInt16 CFID_WEIGHT
Definition: fontdialog.cxx:73
constexpr sal_uInt16 CFID_FONTLIST
Definition: fontdialog.cxx:92
constexpr sal_uInt16 CFID_CJK_WEIGHT
Definition: fontdialog.cxx:85
constexpr sal_uInt16 CFID_STRIKEOUT
Definition: fontdialog.cxx:77
constexpr sal_uInt16 CFID_CJK_LANGUAGE
Definition: fontdialog.cxx:87
constexpr TypedWhichId< SvxWordLineModeItem > CFID_WORDLINEMODE(8)
constexpr sal_uInt16 CFID_UNDERLINE
Definition: fontdialog.cxx:76
a property handler for any virtual string properties
Definition: browserline.cxx:39
FontWeight
VCL_DLLPUBLIC css::awt::FontSlant ConvertFontSlant(FontItalic eWeight)
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)
SfxItemState