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>
52#include <com/sun/star/beans/XPropertyState.hpp>
53#include <svx/svxids.hrc>
55#include <svx/dialogs.hrc>
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))
202 :
SfxTabDialogController(pParent,
"modules/spropctrlr/ui/controlfontdialog.ui",
"ControlFontDialog", &_rCoreSet)
205 AddTabPage(
"font", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME),
nullptr );
206 AddTabPage(
"fonteffects", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS),
nullptr );
215 OSL_ENSURE(_pSet && _rxModel.is(),
"ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
216 if (!_pSet || !_rxModel.is())
221 OFontPropertyExtractor aPropExtractor(_rxModel);
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);
243 bool bWordLineMode = aPropExtractor.getCheckFontProperty(
PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
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);
299 TOOLS_WARN_EXCEPTION(
"extensions.propctrlr",
"ControlCharacterDialog::translatePropertiesToItems");
315 void lcl_pushBackPropertyValue( std::vector< NamedValue >& _out_properties,
const OUString& _name,
const Any& _value )
317 _out_properties.push_back( NamedValue( _name, _value ) );
323 _out_properties.clear();
331 if ( eState == SfxItemState::SET )
346 if ( eState == SfxItemState::SET )
360 if ( eState == SfxItemState::SET )
373 if ( eState == SfxItemState::SET )
386 if ( eState == SfxItemState::SET )
391 sal_Int16 nUnderline =
static_cast<sal_Int16
>(rUnderlineItem.
GetLineStyle());
398 if (COL_AUTO != nColor)
399 aUnoColor <<= nColor;
408 if ( eState == SfxItemState::SET )
413 sal_Int16 nStrikeout =
static_cast<sal_Int16
>(rCrossedOutItem.
GetStrikeout());
421 if ( eState == SfxItemState::SET )
426 lcl_pushBackPropertyValue( _out_properties,
PROPERTY_WORDLINEMODE, css::uno::Any(rWordLineModeItem.GetValue()));
433 if ( eState == SfxItemState::SET )
441 if (COL_AUTO != nColor)
442 aUnoColor <<= nColor;
451 if ( eState == SfxItemState::SET )
456 lcl_pushBackPropertyValue( _out_properties,
PROPERTY_FONT_RELIEF,
Any(
static_cast<sal_Int16
>(rReliefItem.GetValue())) );
463 if ( eState == SfxItemState::SET )
470 catch (
const Exception& )
478 OSL_ENSURE( _rxModel.is(),
"ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
486 for (
const NamedValue& rNV : aPropertyValues )
487 _rxModel->setPropertyValue( rNV.Name, rNV.Value );
489 catch(
const Exception& )
500 _rpDefaults =
nullptr;
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 },
554 { SID_ATTR_CHAR_FONTLIST,
false }
559 _rpPool->FreezeIdRanges();
575 _rpPool->ReleaseDefaults(
true);
580 _rpDefaults =
nullptr;
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>
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
ControlCharacterDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)
virtual ~ControlCharacterDialog() override
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
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
tools::Long GetFontHeight() const
FontFamily GetFamilyType()
const OUString & GetStyleName() const
FontStrikeout GetStrikeout() const
FontRelief GetRelief() const
FontEmphasisMark GetEmphasisMark() const
const OUString & GetFamilyName() const
const Color & GetColor() const
FontLineStyle GetUnderline() const
rtl_TextEncoding GetCharSet() const
bool IsWordLineMode() const
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
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
constexpr sal_uInt16 CFID_LANGUAGE
constexpr sal_uInt16 CFID_HEIGHT
constexpr sal_uInt16 CFID_RELIEF
constexpr sal_uInt16 CFID_CJK_FONT
constexpr sal_uInt16 CFID_FONT
constexpr sal_uInt16 CFID_CASEMAP
constexpr sal_uInt16 CFID_CJK_POSTURE
constexpr sal_uInt16 CFID_POSTURE
constexpr sal_uInt16 CFID_LAST_ITEM_ID
constexpr TypedWhichId< SvxShadowedItem > CFID_SHADOWED(19)
constexpr sal_uInt16 CFID_FIRST_ITEM_ID
constexpr sal_uInt16 CFID_CJK_HEIGHT
constexpr TypedWhichId< SvxContourItem > CFID_CONTOUR(18)
constexpr sal_uInt16 CFID_CHARCOLOR
constexpr TypedWhichId< SvxEmphasisMarkItem > CFID_EMPHASIS(11)
constexpr sal_uInt16 CFID_WEIGHT
constexpr sal_uInt16 CFID_FONTLIST
constexpr sal_uInt16 CFID_CJK_WEIGHT
constexpr sal_uInt16 CFID_STRIKEOUT
constexpr sal_uInt16 CFID_CJK_LANGUAGE
constexpr TypedWhichId< SvxWordLineModeItem > CFID_WORDLINEMODE(8)
constexpr sal_uInt16 CFID_UNDERLINE
a property handler for any virtual string properties
VCL_DLLPUBLIC css::awt::FontSlant ConvertFontSlant(FontItalic eWeight)
VCL_DLLPUBLIC float ConvertFontWeight(FontWeight eWeight)