LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xffont.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 90 100 90.0 %
Date: 2014-04-11 Functions: 20 23 87.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  The Contents of this file are made available subject to the terms of
       5             :  *  either of the following licenses
       6             :  *
       7             :  *         - GNU Lesser General Public License Version 2.1
       8             :  *         - Sun Industry Standards Source License Version 1.1
       9             :  *
      10             :  *  Sun Microsystems Inc., October, 2000
      11             :  *
      12             :  *  GNU Lesser General Public License Version 2.1
      13             :  *  =============================================
      14             :  *  Copyright 2000 by Sun Microsystems, Inc.
      15             :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16             :  *
      17             :  *  This library is free software; you can redistribute it and/or
      18             :  *  modify it under the terms of the GNU Lesser General Public
      19             :  *  License version 2.1, as published by the Free Software Foundation.
      20             :  *
      21             :  *  This library is distributed in the hope that it will be useful,
      22             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  *  Lesser General Public License for more details.
      25             :  *
      26             :  *  You should have received a copy of the GNU Lesser General Public
      27             :  *  License along with this library; if not, write to the Free Software
      28             :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29             :  *  MA  02111-1307  USA
      30             :  *
      31             :  *
      32             :  *  Sun Industry Standards Source License Version 1.1
      33             :  *  =================================================
      34             :  *  The contents of this file are subject to the Sun Industry Standards
      35             :  *  Source License Version 1.1 (the "License"); You may not use this file
      36             :  *  except in compliance with the License. You may obtain a copy of the
      37             :  *  License at http://www.openoffice.org/license.html.
      38             :  *
      39             :  *  Software provided under this License is provided on an "AS IS" basis,
      40             :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41             :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42             :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43             :  *  See the License for the specific provisions governing your rights and
      44             :  *  obligations concerning the Software.
      45             :  *
      46             :  *  The Initial Developer of the Original Code is: IBM Corporation
      47             :  *
      48             :  *  Copyright: 2008 by IBM Corporation
      49             :  *
      50             :  *  All Rights Reserved.
      51             :  *
      52             :  *  Contributor(s): _______________________________________
      53             :  *
      54             :  *
      55             :  ************************************************************************/
      56             : /*************************************************************************
      57             :  * @file
      58             :  * Font object to serial to xml filter.
      59             :  ************************************************************************/
      60             : #ifndef     _XFFONT_HXX
      61             : #define     _XFFONT_HXX
      62             : 
      63             : #include "xfglobal.hxx"
      64             : #include "xfcolor.hxx"
      65             : 
      66             : #define     XFFONT_FLAG_NAME            0X00000001
      67             : #define     XFFONT_FLAG_NAME_ASIA       0X00000002
      68             : #define     XFFONT_FLAG_NAME_COMPLEX    0X00000004
      69             : 
      70             : #define     XFFONT_FLAG_SIZE            0X00000008
      71             : #define     XFFONT_FLAG_SIZE_ASIA       0X00000010
      72             : #define     XFFONT_FLAG_SIZE_COMPLEX    0X00000020
      73             : 
      74             : #define     XFFONT_FLAG_ITALIC          0X00000040
      75             : #define     XFFONT_FLAG_ITALIC_ASIA     0X00000080
      76             : #define     XFFONT_FLAG_ITALIC_COMPLEX  0X00000100
      77             : 
      78             : #define     XFFONT_FLAG_BOLD            0X00000200
      79             : #define     XFFONT_FLAG_BOLD_ASIA       0X00000400
      80             : #define     XFFONT_FLAG_BOLD_COMPLEX    0X00000800
      81             : 
      82             : #define     XFFONT_FLAG_UNDERLINE       0X00001000
      83             : #define     XFFONT_FLAG_UNDERLINECOLOR  0X00002000
      84             : 
      85             : #define     XFFONT_FLAG_POSITION        0X00004000
      86             : #define     XFFONT_FLAG_SCALE           0X00008000
      87             : #define     XFFONT_FLAG_CHARSPACE       0x00010000
      88             : 
      89             : #define     XFFONT_FLAG_COLOR           0x00020000
      90             : #define     XFFONT_FLAG_BGCOLOR         0x00040000
      91             : 
      92             : #define     XFFONT_FLAG_CROSSOUT        0x00080000
      93             : #define     XFFONT_FLAG_RELIEF          0x00100000
      94             : #define     XFFONT_FLAG_TRANSFORM       0x00200000
      95             : #define     XFFONT_FLAG_EMPHASIZE       0x00400000
      96             : #define     XFFONT_FLAG_OUTLINE         0x00800000
      97             : #define     XFFONT_FLAG_SHADOW          0x01000000
      98             : #define     XFFONT_FLAG_BLINK           0x02000000
      99             : #define     XFFONT_FLAG_WIDTHSCALE      0x04000000
     100             : 
     101             : /**
     102             :  * @descr
     103             :  * The font struct of openoffice xml filter.
     104             :  * There should be some basic members,ie:
     105             : 
     106             :  * font name
     107             :  * font family
     108             :  * font size
     109             :  * font italic
     110             :  * font bold
     111             :  * font underline
     112             :  * font underline color
     113             :  */
     114         248 : class XFFont
     115             : {
     116             : public:
     117             :     XFFont();
     118             : 
     119             : public:
     120             :     /**
     121             :      * @descr   Set font name.
     122             :      */
     123             :     void    SetFontName(const OUString& name);
     124             : 
     125             :     /**
     126             :      * @descr   Set font name for asia locale.
     127             :      */
     128             :     void    SetFontNameAsia(const OUString& name);
     129             : 
     130             :     /**
     131             :      * @descr   Set font name for BIDI locale.
     132             :      */
     133             :     void    SetFontNameComplex(const OUString& name);
     134             : 
     135             :     /**
     136             :      * @descr   Set font size.
     137             :      */
     138             :     void    SetFontSize(sal_Int16 size);
     139             : 
     140             :     /**
     141             :      * @descr   Set font size for asia locale.
     142             :      */
     143             :     void    SetFontSizeAsia(sal_Int16 size);
     144             : 
     145             :     /**
     146             :      * @descr   Set font size for BIDI locale.
     147             :      */
     148             :     void    SetFontSizeComplex(sal_Int16 size);
     149             : 
     150             :     /**
     151             :      * @descr   Set whether font is italic.
     152             :      */
     153             :     void    SetItalic(sal_Bool italic = true);
     154             : 
     155             :     /**
     156             :      * @descr   Set whether font is italic for asia locale.
     157             :      */
     158             :     void    SetItalicAsia(sal_Bool italic);
     159             : 
     160             :     /**
     161             :      * @descr   Set whether font is italic for BIDI locale.
     162             :      */
     163             :     void    SetItalicComplex(sal_Bool italic);
     164             : 
     165             :     /**
     166             :      * @descr   Set font bold.
     167             :      */
     168             :     void    SetBold(sal_Bool bold = true);
     169             : 
     170             :     /**
     171             :      * @descr   Set font bold for asia locale.
     172             :      */
     173             :     void    SetBoldAsia(sal_Bool bold);
     174             : 
     175             :     /**
     176             :      * @descr   Set font bold for complex locale.
     177             :      */
     178             :     void    SetBoldComplex(sal_Bool bold);
     179             : 
     180             :     /**
     181             :      * @descr   Set underline style.
     182             :      */
     183             :     void    SetUnderline(enumXFUnderline underline,sal_Bool wordByWord=sal_False);
     184             : 
     185             :     /**
     186             :      * @descr   Set underline color.
     187             :      */
     188             :     void    SetUnderlineColor(XFColor color=XFColor(128,128,0));
     189             : 
     190             :     /**
     191             :      * @descr   Set crossout.
     192             :      */
     193             :     void    SetCrossout(enumXFCrossout cross,sal_Bool wordByWord=sal_False);
     194             : 
     195             :     /**
     196             :      * @descr   Set font relief.
     197             :      */
     198             :     void    SetRelief(enumXFRelief relief);
     199             : 
     200             :     /**
     201             :      * @descr   Set font transform type,pls refer to enumXFTransform.
     202             :      */
     203             :     void    SetTransform(enumXFTransform transform);
     204             : 
     205             :     /**
     206             :      * @descr   Set font emphasize effect.
     207             :      */
     208             :     void    SetEmphasize(enumXFEmphasize emphasize, sal_Bool top = sal_True);
     209             : 
     210             :     /**
     211             :      * @descr   Set outline effect.
     212             :      */
     213             :     void    SetOutline(sal_Bool outline);
     214             : 
     215             :     /**
     216             :      * @descr   Set font shadow.
     217             :      */
     218             :     void    SetShadow(sal_Bool shadow);
     219             : 
     220             :     /**
     221             :      * @descr   Set font blink effect.
     222             :      */
     223             :     void    SetBlink(sal_Bool blink);
     224             : 
     225             :     /**
     226             :      * @descr   Set upper script or lower script.
     227             :      */
     228             :     void    SetPosition(sal_Bool bUpperScript = sal_True, sal_Int16 pos = 33, sal_Int16 scale = 58);
     229             : 
     230             :     /**
     231             :      * @descr   Set space between chars in percent.
     232             :      */
     233             :     void    SetCharSpace(sal_Int16 space);
     234             : 
     235             :     /**
     236             :      * @descr   Set char width scale in percent.
     237             :      */
     238             :     void    SetWidthScale(sal_Int16 widthScale);
     239             : 
     240             :     /**
     241             :      * @descr   Set font color.
     242             :      */
     243             :     void    SetColor(XFColor& color);
     244             : 
     245             :     /**
     246             :      * @descr   Set font background color.
     247             :      */
     248             :     void    SetBackColor(XFColor& color);
     249             :     void    SetBackColorTransparent();
     250             : 
     251             :     //getter:
     252             :     enumXFTransform GetTransform();
     253             : 
     254             :     sal_Int16 GetFontSize();
     255             :     XFColor GetColor();
     256             : 
     257             :     sal_uInt32  GetFlag(){ return m_nFlag; }
     258             : 
     259             :     void    ToXml(IXFStream *pStrm);
     260             : 
     261             :     friend bool operator==(XFFont& f1, XFFont& f2);
     262             :     friend bool operator!=(XFFont& f1, XFFont& f2);
     263             :     friend class    XFFontFactory;
     264             : private:
     265             :     OUString   m_strFontName;
     266             :     OUString   m_strFontNameAsia;
     267             :     OUString   m_strFontNameComplex;
     268             :     sal_Int16   m_nFontSize;
     269             :     sal_Int16   m_nFontSizeAsia;
     270             :     sal_Int16   m_nFontSizeComplex;
     271             :     sal_Bool    m_bItalic;
     272             :     sal_Bool    m_bItalicAsia;
     273             :     sal_Bool    m_bItalicComplex;
     274             :     sal_Bool    m_bBold;
     275             :     sal_Bool    m_bBoldAsia;
     276             :     sal_Bool    m_bBoldComplex;
     277             :     XFColor     m_aUnderlineColor;
     278             : 
     279             :     enumXFUnderline m_eUnderline;
     280             :     enumXFCrossout  m_eCrossout;
     281             :     enumXFRelief    m_eRelief;
     282             :     enumXFTransform m_eTransform;
     283             :     enumXFEmphasize m_eEmphasize;
     284             :     sal_Bool    m_bWordByWord;
     285             :     sal_Bool    m_bEmphasizeTop;
     286             :     sal_Bool    m_bOutline;
     287             :     sal_Bool    m_bShadow;
     288             :     sal_Bool    m_bBlink;
     289             :     sal_Int16   m_nPosition;
     290             :     sal_Int16   m_nScale;
     291             :     double      m_fCharSpace;
     292             :     sal_Int16   m_nWidthScale;
     293             :     XFColor     m_aColor;
     294             :     XFColor     m_aBackColor;
     295             :     //The flag defines which variable will be funtional.
     296             :     sal_uInt32  m_nFlag;
     297             :     sal_Bool    m_bTransparent;
     298             : };
     299             : 
     300         228 : inline void XFFont::SetFontName(const OUString& name)
     301             : {
     302         228 :     m_strFontName = name;
     303         228 :     m_nFlag |= XFFONT_FLAG_NAME;
     304             : 
     305         228 :     SetFontNameAsia(name);
     306         228 :     SetFontNameComplex(name);
     307         228 : }
     308             : 
     309         288 : inline void XFFont::SetFontNameAsia(const OUString& name)
     310             : {
     311         288 :     m_strFontNameAsia = name;
     312         288 :     m_nFlag |= XFFONT_FLAG_NAME_ASIA;
     313         288 : }
     314             : 
     315         228 : inline void XFFont::SetFontNameComplex(const OUString& name)
     316             : {
     317         228 :     m_strFontNameComplex = name;
     318         228 :     m_nFlag |= XFFONT_FLAG_NAME_COMPLEX;
     319         228 : }
     320             : 
     321         236 : inline void XFFont::SetFontSize(sal_Int16 size)
     322             : {
     323         236 :     m_nFontSize = size;
     324         236 :     m_nFlag |= XFFONT_FLAG_SIZE;
     325             : 
     326         236 :     SetFontSizeAsia(size);
     327         236 :     SetFontSizeComplex(size);
     328         236 : }
     329             : 
     330         236 : inline void XFFont::SetFontSizeAsia(sal_Int16 size)
     331             : {
     332         236 :     m_nFontSizeAsia = size;
     333         236 :     m_nFlag |= XFFONT_FLAG_SIZE_ASIA;
     334         236 : }
     335             : 
     336         236 : inline void XFFont::SetFontSizeComplex(sal_Int16 size)
     337             : {
     338         236 :     m_nFontSizeComplex = size;
     339         236 :     m_nFlag |= XFFONT_FLAG_SIZE_COMPLEX;
     340         236 : }
     341             : 
     342             : //---------Italic:
     343          73 : inline void XFFont::SetItalic(sal_Bool italic)
     344             : {
     345          73 :     m_bItalic = italic;
     346          73 :     m_nFlag |= XFFONT_FLAG_ITALIC;
     347             : 
     348          73 :     SetItalicAsia(italic);
     349          73 :     SetItalicComplex(italic);
     350          73 : }
     351             : 
     352          73 : inline void XFFont::SetItalicAsia(sal_Bool italic)
     353             : {
     354          73 :     m_bItalicAsia = italic;
     355          73 :     m_nFlag |= XFFONT_FLAG_ITALIC_ASIA;
     356          73 : }
     357             : 
     358          73 : inline void XFFont::SetItalicComplex(sal_Bool italic)
     359             : {
     360          73 :     m_bItalicComplex = italic;
     361          73 :     m_nFlag |= XFFONT_FLAG_ITALIC_COMPLEX;
     362          73 : }
     363             : 
     364             : //--------Bold
     365          89 : inline void XFFont::SetBold(sal_Bool bold)
     366             : {
     367          89 :     m_bBold = bold;
     368          89 :     m_nFlag |= XFFONT_FLAG_BOLD;
     369          89 :     SetBoldAsia(bold);
     370          89 :     SetBoldComplex(bold);
     371          89 : }
     372             : 
     373          89 : inline void XFFont::SetBoldAsia(sal_Bool bold)
     374             : {
     375          89 :     m_bBoldAsia = bold;
     376          89 :     m_nFlag |= XFFONT_FLAG_BOLD_ASIA;
     377          89 : }
     378             : 
     379          89 : inline void XFFont::SetBoldComplex(sal_Bool bold)
     380             : {
     381          89 :     m_bBoldComplex = bold;
     382          89 :     m_nFlag |= XFFONT_FLAG_BOLD_COMPLEX;
     383          89 : }
     384             : 
     385             : //--------Underline:
     386           1 : inline void XFFont::SetUnderline(enumXFUnderline underline, sal_Bool wordByWord)
     387             : {
     388           1 :     m_eUnderline = underline;
     389           1 :     m_bWordByWord = wordByWord;
     390           1 :     m_nFlag |= XFFONT_FLAG_UNDERLINE;
     391           1 : }
     392             : 
     393             : inline void XFFont::SetUnderlineColor(XFColor color)
     394             : {
     395             :     m_aUnderlineColor = color;
     396             :     m_nFlag |= XFFONT_FLAG_UNDERLINECOLOR;
     397             : }
     398             : 
     399          61 : inline void XFFont::SetCrossout(enumXFCrossout cross, sal_Bool wordByWord)
     400             : {
     401          61 :     m_eCrossout = cross;
     402          61 :     m_bWordByWord = wordByWord;
     403          61 :     m_nFlag |= XFFONT_FLAG_CROSSOUT;
     404          61 : }
     405             : inline void XFFont::SetRelief(enumXFRelief relief)
     406             : {
     407             :     m_eRelief = relief;
     408             :     m_nFlag |= XFFONT_FLAG_RELIEF;
     409             : }
     410          60 : inline void XFFont::SetTransform(enumXFTransform transform)
     411             : {
     412          60 :     m_eTransform = transform;
     413          60 :     m_nFlag |= XFFONT_FLAG_TRANSFORM;
     414          60 : }
     415             : 
     416             : inline void XFFont::SetEmphasize(enumXFEmphasize emphasize, sal_Bool top)
     417             : {
     418             :     m_eEmphasize = emphasize;
     419             :     m_bEmphasizeTop = top;
     420             :     m_nFlag |= XFFONT_FLAG_EMPHASIZE;
     421             : }
     422             : inline void XFFont::SetOutline(sal_Bool outline)
     423             : {
     424             :     m_bOutline = outline;
     425             :     m_nFlag |= XFFONT_FLAG_OUTLINE;
     426             : }
     427             : inline void XFFont::SetShadow(sal_Bool shadow)
     428             : {
     429             :     m_bShadow = shadow;
     430             :     m_nFlag |= XFFONT_FLAG_SHADOW;
     431             : }
     432             : inline void XFFont::SetBlink(sal_Bool blink)
     433             : {
     434             :     m_bBlink = blink;
     435             :     m_nFlag |= XFFONT_FLAG_BLINK;
     436             : }
     437             : 
     438           2 : inline void XFFont::SetPosition(sal_Bool bUpperScript, sal_Int16 pos, sal_Int16 scale)
     439             : {
     440             :     assert(pos>=0&&pos<=100);
     441             :     assert(scale>0&&scale<=100);
     442           2 :     m_nFlag |= XFFONT_FLAG_POSITION;
     443           2 :     m_nPosition = pos;
     444           2 :     m_nScale = scale;
     445           2 :     if( bUpperScript )
     446             :     {
     447           1 :         if( m_nPosition <0 )
     448           0 :             m_nPosition = -m_nPosition;
     449             :     }
     450             :     else
     451             :     {
     452           1 :         if( m_nPosition >0 )
     453           1 :             m_nPosition = -m_nPosition;
     454             :     }
     455           2 : }
     456             : 
     457             : inline void XFFont::SetCharSpace(sal_Int16 space)
     458             : {
     459             :     m_nFlag |= XFFONT_FLAG_CHARSPACE;
     460             :     m_fCharSpace = space;
     461             : }
     462             : 
     463             : inline void XFFont::SetWidthScale(sal_Int16 widthScale)
     464             : {
     465             :     m_nFlag |= XFFONT_FLAG_WIDTHSCALE;
     466             :     m_nWidthScale = widthScale;
     467             : }
     468             : 
     469          95 : inline void XFFont::SetColor(XFColor& color)
     470             : {
     471          95 :     m_nFlag |= XFFONT_FLAG_COLOR;
     472          95 :     m_aColor = color;
     473          95 : }
     474             : 
     475           0 : inline void XFFont::SetBackColor(XFColor& color)
     476             : {
     477           0 :     m_bTransparent = sal_False;
     478           0 :     m_nFlag |= XFFONT_FLAG_BGCOLOR;
     479           0 :     m_aBackColor = color;
     480           0 : }
     481             : 
     482          60 : inline void XFFont::SetBackColorTransparent()
     483             : {
     484          60 :     m_bTransparent = sal_True;
     485          60 :     m_nFlag |= XFFONT_FLAG_BGCOLOR;
     486          60 : }
     487             : 
     488          60 : inline enumXFTransform XFFont::GetTransform()
     489             : {
     490          60 :     return m_eTransform;
     491             : }
     492             : 
     493           0 : inline sal_Int16 XFFont::GetFontSize()
     494             : {
     495           0 :     return m_nFontSize;
     496             : }
     497             : 
     498           0 : inline XFColor XFFont::GetColor()
     499             : {
     500           0 :     return m_aColor;
     501             : }
     502             : 
     503             : #endif
     504             : 
     505             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10