1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "fontdialog.hxx"
21 #include <vcl/outdev.hxx>
22 #include <vcl/settings.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/unohelp.hxx>
25 #include <i18nlangtag/languagetag.hxx>
26 #include <toolkit/helper/vclunohelper.hxx>
27 #include <comphelper/types.hxx>
28 #include <comphelper/extract.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"
35 #include <editeng/charreliefitem.hxx>
36 #include <editeng/emphasismarkitem.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>
42 #include <editeng/crossedoutitem.hxx>
43 #include <editeng/colritem.hxx>
44 #include <editeng/langitem.hxx>
45 #include <editeng/wrlmitem.hxx>
46 #include <editeng/cmapitem.hxx>
47 #include <editeng/contouritem.hxx>
48 #include <editeng/shdditem.hxx>
49 #include <editeng/flstitem.hxx>
50 #include <svtools/ctrltool.hxx>
51 #include <comphelper/diagnose_ex.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>
63 using namespace ::com::sun::star::uno
;
64 using namespace ::com::sun::star::beans
;
67 //= OFontPropertyExtractor
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;
78 constexpr TypedWhichId
<SvxWordLineModeItem
> CFID_WORDLINEMODE(8);
79 constexpr sal_uInt16 CFID_CHARCOLOR
= 9;
80 constexpr sal_uInt16 CFID_RELIEF
= 10;
81 constexpr TypedWhichId
<SvxEmphasisMarkItem
> CFID_EMPHASIS(11);
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;
89 constexpr TypedWhichId
<SvxContourItem
> CFID_CONTOUR(18);
90 constexpr TypedWhichId
<SvxShadowedItem
> CFID_SHADOWED(19);
92 constexpr sal_uInt16 CFID_FONTLIST
= 20;
94 constexpr sal_uInt16 CFID_FIRST_ITEM_ID
= CFID_FONT
;
95 constexpr sal_uInt16 CFID_LAST_ITEM_ID
= CFID_FONTLIST
;
100 class OFontPropertyExtractor
103 css::uno::Reference
< css::beans::XPropertySet
>
105 css::uno::Reference
< css::beans::XPropertyState
>
109 explicit OFontPropertyExtractor( const css::uno::Reference
< css::beans::XPropertySet
>&
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
);
120 const OUString
& _rPropName
,
123 bool _bForceInvalidation
= false);
128 OFontPropertyExtractor::OFontPropertyExtractor(const Reference
< XPropertySet
>& _rxProps
)
129 :m_xPropValueAccess(_rxProps
)
130 ,m_xPropStateAccess(_rxProps
, UNO_QUERY
)
132 OSL_ENSURE(m_xPropValueAccess
.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
136 bool OFontPropertyExtractor::getCheckFontProperty(const OUString
& _rPropName
, Any
& _rValue
)
138 _rValue
= m_xPropValueAccess
->getPropertyValue(_rPropName
);
139 if (m_xPropStateAccess
.is())
140 return PropertyState_DEFAULT_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
);
146 OUString
OFontPropertyExtractor::getStringFontProperty(const OUString
& _rPropName
, const OUString
& _rDefault
)
149 if (getCheckFontProperty(_rPropName
, aValue
))
152 return ::comphelper::getString(aValue
);
156 sal_Int16
OFontPropertyExtractor::getInt16FontProperty(const OUString
& _rPropName
, const sal_Int16 _nDefault
)
159 if (getCheckFontProperty(_rPropName
, aValue
))
162 sal_Int32
nValue(_nDefault
);
163 ::cppu::enum2int(nValue
, aValue
);
164 return static_cast<sal_Int16
>(nValue
);
168 sal_Int32
OFontPropertyExtractor::getInt32FontProperty(const OUString
& _rPropName
, const sal_Int32 _nDefault
)
171 if (getCheckFontProperty(_rPropName
, aValue
))
174 sal_Int32
nValue(_nDefault
);
175 ::cppu::enum2int(nValue
, aValue
);
180 float OFontPropertyExtractor::getFloatFontProperty(const OUString
& _rPropName
, const float _nDefault
)
183 if (getCheckFontProperty(_rPropName
, aValue
))
186 return ::comphelper::getFloat(aValue
);
190 void OFontPropertyExtractor::invalidateItem(const OUString
& _rPropName
, sal_uInt16 _nItemId
, SfxItemSet
& _rSet
, bool _bForceInvalidation
)
192 if ( _bForceInvalidation
193 || ( m_xPropStateAccess
.is()
194 && (PropertyState_AMBIGUOUS_VALUE
== m_xPropStateAccess
->getPropertyState(_rPropName
))
197 _rSet
.InvalidateItem(_nItemId
);
200 //= ControlCharacterDialog
201 ControlCharacterDialog::ControlCharacterDialog(weld::Window
* pParent
, const SfxItemSet
& _rCoreSet
)
202 : SfxTabDialogController(pParent
, "modules/spropctrlr/ui/controlfontdialog.ui", "ControlFontDialog", &_rCoreSet
)
204 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
205 AddTabPage("font", pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME
), nullptr );
206 AddTabPage("fonteffects", pFact
->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS
), nullptr );
209 ControlCharacterDialog::~ControlCharacterDialog()
213 void ControlCharacterDialog::translatePropertiesToItems(const Reference
< XPropertySet
>& _rxModel
, SfxItemSet
* _pSet
)
215 OSL_ENSURE(_pSet
&& _rxModel
.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
216 if (!_pSet
|| !_rxModel
.is())
221 OFontPropertyExtractor
aPropExtractor(_rxModel
);
223 // some items, which may be in default state, have to be filled with non-void information
224 vcl::Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
225 css::awt::FontDescriptor aDefaultFont
= VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont
);
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
);
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()));
243 bool bWordLineMode
= aPropExtractor
.getCheckFontProperty(PROPERTY_WORDLINEMODE
, aValue
) ? aDefaultFont
.WordLineMode
: ::cppu::any2bool(aValue
);
244 sal_Int32 nColor32
= aPropExtractor
.getInt32FontProperty(PROPERTY_TEXTCOLOR
, 0);
246 // build SfxItems with the values
247 SvxFontItem
aFontItem(static_cast<FontFamily
>(nFontFamily
), aFontName
, aFontStyleName
, PITCH_DONTKNOW
, nFontCharset
, FontItemIds::CFID_FONT
);
249 nFontHeight
= static_cast<float>(o3tl::convert(nFontHeight
, o3tl::Length::pt
, o3tl::Length::twip
));
251 SvxFontHeightItem
aSvxFontHeightItem(static_cast<sal_uInt32
>(nFontHeight
),100,FontItemIds::CFID_HEIGHT
);
253 FontWeight eWeight
=vcl::unohelper::ConvertFontWeight(nFontWeight
);
254 FontItalic eItalic
=vcl::unohelper::ConvertFontSlant(nFontSlant
);
255 FontLineStyle eUnderline
=static_cast<FontLineStyle
>(nFontLineStyle
);
256 FontStrikeout eStrikeout
=static_cast<FontStrikeout
>(nFontStrikeout
);
258 SvxWeightItem
aWeightItem(eWeight
,FontItemIds::CFID_WEIGHT
);
259 SvxPostureItem
aPostureItem(eItalic
,FontItemIds::CFID_POSTURE
);
261 SvxCrossedOutItem
aCrossedOutItem(eStrikeout
,FontItemIds::CFID_STRIKEOUT
);
262 SvxWordLineModeItem
aWordLineModeItem(bWordLineMode
, FontItemIds::CFID_WORDLINEMODE
);
264 SvxUnderlineItem
aUnderlineItem(eUnderline
,FontItemIds::CFID_UNDERLINE
);
265 aUnderlineItem
.SetColor(Color(ColorTransparency
, nTextLineColor
));
267 SvxColorItem
aSvxColorItem(Color(ColorTransparency
, nColor32
),FontItemIds::CFID_CHARCOLOR
);
268 SvxLanguageItem
aLanguageItem(Application::GetSettings().GetUILanguageTag().getLanguageType(), FontItemIds::CFID_LANGUAGE
);
271 SvxCharReliefItem
aFontReliefItem(static_cast<FontRelief
>(nFontRelief
), FontItemIds::CFID_RELIEF
);
272 SvxEmphasisMarkItem
aEmphasisMarkitem(static_cast<FontEmphasisMark
>(nFontEmphasisMark
), FontItemIds::CFID_EMPHASIS
);
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
);
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
);
297 catch (const Exception
&)
299 TOOLS_WARN_EXCEPTION( "extensions.propctrlr", "ControlCharacterDialog::translatePropertiesToItems");
302 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONT
);
303 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT
);
304 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE
);
305 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_POSTURE
);
306 _pSet
->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT
);
308 _pSet
->DisableItem(SID_ATTR_CHAR_CASEMAP
);
309 _pSet
->DisableItem(SID_ATTR_CHAR_CONTOUR
);
310 _pSet
->DisableItem(SID_ATTR_CHAR_SHADOWED
);
315 void lcl_pushBackPropertyValue( std::vector
< NamedValue
>& _out_properties
, const OUString
& _name
, const Any
& _value
)
317 _out_properties
.push_back( NamedValue( _name
, _value
) );
321 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, std::vector
< NamedValue
>& _out_properties
)
323 _out_properties
.clear();
329 SfxItemState eState
= _rSet
.GetItemState(FontItemIds::CFID_FONT
);
331 if ( eState
== SfxItemState::SET
)
333 const SvxFontItem
& rFontItem
=
334 static_cast<const SvxFontItem
&>(_rSet
.Get(FontItemIds::CFID_FONT
));
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())));
344 eState
= _rSet
.GetItemState(FontItemIds::CFID_HEIGHT
);
346 if ( eState
== SfxItemState::SET
)
348 const SvxFontHeightItem
& rSvxFontHeightItem
=
349 static_cast<const SvxFontHeightItem
&>(_rSet
.Get(FontItemIds::CFID_HEIGHT
));
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
));
358 eState
= _rSet
.GetItemState(FontItemIds::CFID_WEIGHT
);
360 if ( eState
== SfxItemState::SET
)
362 const SvxWeightItem
& rWeightItem
=
363 static_cast<const SvxWeightItem
&>(_rSet
.Get(FontItemIds::CFID_WEIGHT
));
365 float nWeight
= vcl::unohelper::ConvertFontWeight(rWeightItem
.GetWeight());
366 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_WEIGHT
,Any(nWeight
));
371 eState
= _rSet
.GetItemState(FontItemIds::CFID_POSTURE
);
373 if ( eState
== SfxItemState::SET
)
375 const SvxPostureItem
& rPostureItem
=
376 static_cast<const SvxPostureItem
&>(_rSet
.Get(FontItemIds::CFID_POSTURE
));
378 css::awt::FontSlant eSlant
= vcl::unohelper::ConvertFontSlant(rPostureItem
.GetPosture());
379 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_SLANT
, Any(static_cast<sal_Int16
>(eSlant
)));
384 eState
= _rSet
.GetItemState(FontItemIds::CFID_UNDERLINE
);
386 if ( eState
== SfxItemState::SET
)
388 const SvxUnderlineItem
& rUnderlineItem
=
389 static_cast<const SvxUnderlineItem
&>(_rSet
.Get(FontItemIds::CFID_UNDERLINE
));
391 sal_Int16 nUnderline
= static_cast<sal_Int16
>(rUnderlineItem
.GetLineStyle());
392 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_UNDERLINE
,Any(nUnderline
));
394 // the text line color is transported in this item, too
395 Color nColor
= rUnderlineItem
.GetColor();
398 if (COL_AUTO
!= nColor
)
399 aUnoColor
<<= nColor
;
401 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTLINECOLOR
, aUnoColor
);
406 eState
= _rSet
.GetItemState(FontItemIds::CFID_STRIKEOUT
);
408 if ( eState
== SfxItemState::SET
)
410 const SvxCrossedOutItem
& rCrossedOutItem
=
411 static_cast<const SvxCrossedOutItem
&>(_rSet
.Get(FontItemIds::CFID_STRIKEOUT
));
413 sal_Int16 nStrikeout
= static_cast<sal_Int16
>(rCrossedOutItem
.GetStrikeout());
414 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_STRIKEOUT
,Any(nStrikeout
));
418 // font wordline mode
419 eState
= _rSet
.GetItemState(FontItemIds::CFID_WORDLINEMODE
);
421 if ( eState
== SfxItemState::SET
)
423 const SvxWordLineModeItem
& rWordLineModeItem
=
424 _rSet
.Get(FontItemIds::CFID_WORDLINEMODE
);
426 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_WORDLINEMODE
, css::uno::Any(rWordLineModeItem
.GetValue()));
431 eState
= _rSet
.GetItemState(FontItemIds::CFID_CHARCOLOR
);
433 if ( eState
== SfxItemState::SET
)
435 const SvxColorItem
& rColorItem
=
436 static_cast<const SvxColorItem
&>(_rSet
.Get(FontItemIds::CFID_CHARCOLOR
));
438 Color nColor
= rColorItem
.GetValue();
441 if (COL_AUTO
!= nColor
)
442 aUnoColor
<<= nColor
;
444 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_TEXTCOLOR
, aUnoColor
);
449 eState
= _rSet
.GetItemState(FontItemIds::CFID_RELIEF
);
451 if ( eState
== SfxItemState::SET
)
453 const SvxCharReliefItem
& rReliefItem
=
454 static_cast<const SvxCharReliefItem
&>(_rSet
.Get(FontItemIds::CFID_RELIEF
));
456 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_RELIEF
, Any(static_cast<sal_Int16
>(rReliefItem
.GetValue())) );
460 // font emphasis mark
461 eState
= _rSet
.GetItemState(FontItemIds::CFID_EMPHASIS
);
463 if ( eState
== SfxItemState::SET
)
465 const SvxEmphasisMarkItem
& rEmphMarkItem
= _rSet
.Get(FontItemIds::CFID_EMPHASIS
);
467 lcl_pushBackPropertyValue( _out_properties
, PROPERTY_FONT_EMPHASIS_MARK
, Any(static_cast<sal_Int16
>(rEmphMarkItem
.GetEmphasisMark())) );
470 catch (const Exception
& )
472 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
476 void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet
& _rSet
, const Reference
< XPropertySet
>& _rxModel
)
478 OSL_ENSURE( _rxModel
.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
482 std::vector
< NamedValue
> aPropertyValues
;
483 translateItemsToProperties( _rSet
, aPropertyValues
);
486 for ( const NamedValue
& rNV
: aPropertyValues
)
487 _rxModel
->setPropertyValue( rNV
.Name
, rNV
.Value
);
489 catch( const Exception
& )
491 DBG_UNHANDLED_EXCEPTION("extensions.propctrlr");
495 void ControlCharacterDialog::createItemSet(std::unique_ptr
<SfxItemSet
>& _rpSet
, rtl::Reference
<SfxItemPool
>& _rpPool
, std::vector
<SfxPoolItem
*>*& _rpDefaults
)
497 // just to be sure...
500 _rpDefaults
= nullptr;
502 // create and initialize the defaults
503 _rpDefaults
= new std::vector
<SfxPoolItem
*>(FontItemIds::CFID_LAST_ITEM_ID
- FontItemIds::CFID_FIRST_ITEM_ID
+ 1);
505 vcl::Font aDefaultVCLFont
= Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
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
);
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
);
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
);
530 *pCounter
++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), FontItemIds::CFID_FONTLIST
);
533 static SfxItemInfo
const aItemInfos
[FontItemIds::CFID_LAST_ITEM_ID
- FontItemIds::CFID_FIRST_ITEM_ID
+ 1] =
535 // _nSID, _bNeedsPoolRegistration, _bShareable
536 { SID_ATTR_CHAR_FONT
, false, false },
537 { SID_ATTR_CHAR_FONTHEIGHT
, false, false },
538 { SID_ATTR_CHAR_WEIGHT
, false, false },
539 { SID_ATTR_CHAR_POSTURE
, false, false },
540 { SID_ATTR_CHAR_LANGUAGE
, false, false },
541 { SID_ATTR_CHAR_UNDERLINE
, false, false },
542 { SID_ATTR_CHAR_STRIKEOUT
, false, false },
543 { SID_ATTR_CHAR_WORDLINEMODE
, false, false },
544 { SID_ATTR_CHAR_COLOR
, false, false },
545 { SID_ATTR_CHAR_RELIEF
, false, false },
546 { SID_ATTR_CHAR_EMPHASISMARK
, false, false },
555 { SID_ATTR_CHAR_FONTLIST
, false, false }
558 _rpPool
= new SfxItemPool("PCRControlFontItemPool", FontItemIds::CFID_FIRST_ITEM_ID
, FontItemIds::CFID_LAST_ITEM_ID
,
559 aItemInfos
, _rpDefaults
);
560 _rpPool
->FreezeIdRanges();
562 // and, finally, the set
563 _rpSet
.reset(new SfxItemSet(*_rpPool
));
566 void ControlCharacterDialog::destroyItemSet(std::unique_ptr
<SfxItemSet
>& _rpSet
, rtl::Reference
<SfxItemPool
>& _rpPool
, std::vector
<SfxPoolItem
*>*& _rpDefaults
)
568 // from the pool, get and remember the font list (needs to be deleted)
569 const SvxFontListItem
& rFontListItem
= static_cast<const SvxFontListItem
&>(_rpPool
->GetDefaultItem(FontItemIds::CFID_FONTLIST
));
570 const FontList
* pFontList
= rFontListItem
.GetFontList();
572 // _first_ delete the set (referring the pool)
576 _rpPool
->ReleaseDefaults(true);
577 // the "true" means delete the items, too
580 // reset the defaults ptr
581 _rpDefaults
= nullptr;
582 // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
587 void ControlCharacterDialog::PageCreated(const OUString
& rId
, SfxTabPage
& rPage
)
589 SfxAllItemSet
aSet(*(GetInputSetImpl()->GetPool()));
592 aSet
.Put (static_cast<const SvxFontListItem
&>(GetInputSetImpl()->Get(FontItemIds::CFID_FONTLIST
)));
593 aSet
.Put (SfxUInt16Item(SID_DISABLE_CTL
,DISABLE_HIDE_LANGUAGE
));
594 rPage
.PageCreated(aSet
);
600 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */