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