LCOV - code coverage report
Current view: top level - extensions/source/propctrlr - fontdialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 244 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10