LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vcl - txtattr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 34 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 8 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                 :            : #ifndef _TXTATTR_HXX
      30                 :            : #define _TXTATTR_HXX
      31                 :            : 
      32                 :            : #include <vcl/dllapi.h>
      33                 :            : #include <tools/color.hxx>
      34                 :            : #include <vcl/vclenum.hxx>
      35                 :            : #include <tools/string.hxx>
      36                 :            : #include <tools/debug.hxx>
      37                 :            : 
      38                 :            : class Font;
      39                 :            : 
      40                 :            : #define TEXTATTR_INVALID    0
      41                 :            : #define TEXTATTR_FONTCOLOR  1
      42                 :            : #define TEXTATTR_HYPERLINK  2
      43                 :            : #define TEXTATTR_FONTWEIGHT 3
      44                 :            : 
      45                 :            : #define TEXTATTR_USER_START 1000 //start id for user defined text attributes
      46                 :            : #define TEXTATTR_PROTECTED  4
      47                 :            : 
      48                 :            : 
      49                 :            : class VCL_DLLPUBLIC TextAttrib
      50                 :            : {
      51                 :            : private:
      52                 :            :     sal_uInt16                  mnWhich;
      53                 :            : 
      54                 :            : protected:
      55                 :          0 :                             TextAttrib( sal_uInt16 nWhich ) { mnWhich = nWhich; }
      56                 :          0 :                             TextAttrib( const TextAttrib& rAttr ) { mnWhich = rAttr.mnWhich; }
      57                 :            : 
      58                 :            : public:
      59                 :            : 
      60                 :            :     virtual                 ~TextAttrib();
      61                 :            : 
      62                 :          0 :     sal_uInt16              Which() const   { return mnWhich; }
      63                 :            :     virtual void            SetFont( Font& rFont ) const = 0;
      64                 :            :     virtual TextAttrib*     Clone() const = 0;
      65                 :            : 
      66                 :            :     virtual int             operator==( const TextAttrib& rAttr ) const = 0;
      67                 :            :     int                     operator!=( const TextAttrib& rAttr ) const
      68                 :            :                                 { return !(*this == rAttr ); }
      69                 :            : };
      70                 :            : 
      71                 :            : 
      72                 :            : 
      73                 :            : class VCL_DLLPUBLIC TextAttribFontColor : public TextAttrib
      74                 :            : {
      75                 :            : private:
      76                 :            :     Color   maColor;
      77                 :            : 
      78                 :            : public:
      79                 :            :                             TextAttribFontColor( const Color& rColor );
      80                 :            :                             TextAttribFontColor( const TextAttribFontColor& rAttr );
      81                 :            :                             ~TextAttribFontColor();
      82                 :            : 
      83                 :          0 :     const Color&            GetColor() const { return maColor; }
      84                 :            : 
      85                 :            :     virtual void            SetFont( Font& rFont ) const;
      86                 :            :     virtual TextAttrib*     Clone() const;
      87                 :            :     virtual int             operator==( const TextAttrib& rAttr ) const;
      88                 :            : 
      89                 :            : };
      90                 :            : 
      91                 :            : class VCL_DLLPUBLIC TextAttribFontWeight : public TextAttrib
      92                 :            : {
      93                 :            : private:
      94                 :            :     FontWeight  meWeight;
      95                 :            : 
      96                 :            : public:
      97                 :            :                             TextAttribFontWeight( FontWeight eWeight );
      98                 :            :                             TextAttribFontWeight( const TextAttribFontWeight& rAttr );
      99                 :            :                             ~TextAttribFontWeight();
     100                 :            : 
     101                 :            :     virtual void            SetFont( Font& rFont ) const;
     102                 :            :     virtual TextAttrib*     Clone() const;
     103                 :            :     virtual int             operator==( const TextAttrib& rAttr ) const;
     104                 :            : 
     105                 :          0 :     inline FontWeight getFontWeight() const { return meWeight; }
     106                 :            : };
     107                 :            : 
     108                 :            : 
     109                 :            : class TextAttribHyperLink : public TextAttrib
     110                 :            : {
     111                 :            : private:
     112                 :            :     XubString   maURL;
     113                 :            :     XubString   maDescription;
     114                 :            :     Color       maColor;
     115                 :            : 
     116                 :            : public:
     117                 :            :                             TextAttribHyperLink( const TextAttribHyperLink& rAttr );
     118                 :            :                             ~TextAttribHyperLink();
     119                 :            : 
     120                 :            :     void                    SetURL( const XubString& rURL )             { maURL = rURL; }
     121                 :          0 :     const XubString&            GetURL() const                              { return maURL; }
     122                 :            : 
     123                 :            :     void                    SetDescription( const XubString& rDescr )   { maDescription = rDescr; }
     124                 :            :     const XubString&            GetDescription() const                      { return maDescription; }
     125                 :            : 
     126                 :            :     void                    SetColor( const Color& rColor )             { maColor = rColor; }
     127                 :            :     const Color&            GetColor() const                            { return maColor; }
     128                 :            : 
     129                 :            :     virtual void            SetFont( Font& rFont ) const;
     130                 :            :     virtual TextAttrib*     Clone() const;
     131                 :            :     virtual int             operator==( const TextAttrib& rAttr ) const;
     132                 :            : };
     133                 :            : 
     134                 :            : class VCL_DLLPUBLIC TextAttribProtect : public TextAttrib
     135                 :            : {
     136                 :            : public:
     137                 :            :                             TextAttribProtect();
     138                 :            :                             TextAttribProtect( const TextAttribProtect& rAttr );
     139                 :            :                             ~TextAttribProtect();
     140                 :            : 
     141                 :            :     virtual void            SetFont( Font& rFont ) const;
     142                 :            :     virtual TextAttrib*     Clone() const;
     143                 :            :     virtual int             operator==( const TextAttrib& rAttr ) const;
     144                 :            : 
     145                 :            : };
     146                 :            : 
     147                 :            : 
     148                 :            : class TextCharAttrib
     149                 :            : {
     150                 :            : private:
     151                 :            :     TextAttrib*     mpAttr;
     152                 :            :     sal_uInt16          mnStart;
     153                 :            :     sal_uInt16          mnEnd;
     154                 :            : 
     155                 :            : protected:
     156                 :            : 
     157                 :            : public:
     158                 :            : 
     159                 :            :                     TextCharAttrib( const TextAttrib& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     160                 :            :                     TextCharAttrib( const TextCharAttrib& rTextCharAttrib );
     161                 :            :                     ~TextCharAttrib();
     162                 :            : 
     163                 :          0 :     const TextAttrib&   GetAttr() const         { return *mpAttr; }
     164                 :            : 
     165                 :          0 :     sal_uInt16          Which() const               { return mpAttr->Which(); }
     166                 :            : 
     167                 :          0 :     sal_uInt16          GetStart() const            { return mnStart; }
     168                 :          0 :     sal_uInt16&         GetStart()                  { return mnStart; }
     169                 :            : 
     170                 :          0 :     sal_uInt16          GetEnd() const              { return mnEnd; }
     171                 :          0 :     sal_uInt16&         GetEnd()                    { return mnEnd; }
     172                 :            : 
     173                 :            :     inline sal_uInt16   GetLen() const;
     174                 :            : 
     175                 :            :     inline void     MoveForward( sal_uInt16 nDiff );
     176                 :            :     inline void     MoveBackward( sal_uInt16 nDiff );
     177                 :            : 
     178                 :            :     inline void     Expand( sal_uInt16 nDiff );
     179                 :            :     inline void     Collaps( sal_uInt16 nDiff );
     180                 :            : 
     181                 :            :     inline sal_Bool     IsIn( sal_uInt16 nIndex );
     182                 :            :     inline sal_Bool     IsInside( sal_uInt16 nIndex );
     183                 :            :     inline sal_Bool     IsEmpty();
     184                 :            : 
     185                 :            : };
     186                 :            : 
     187                 :          0 : inline sal_uInt16 TextCharAttrib::GetLen() const
     188                 :            : {
     189                 :            :     DBG_ASSERT( mnEnd >= mnStart, "TextCharAttrib: nEnd < nStart!" );
     190                 :          0 :     return mnEnd-mnStart;
     191                 :            : }
     192                 :            : 
     193                 :          0 : inline void TextCharAttrib::MoveForward( sal_uInt16 nDiff )
     194                 :            : {
     195                 :            :     DBG_ASSERT( ((long)mnEnd + nDiff) <= 0xFFFF, "TextCharAttrib: MoveForward?!" );
     196                 :          0 :     mnStart = mnStart + nDiff;
     197                 :          0 :     mnEnd = mnEnd + nDiff;
     198                 :          0 : }
     199                 :            : 
     200                 :          0 : inline void TextCharAttrib::MoveBackward( sal_uInt16 nDiff )
     201                 :            : {
     202                 :            :     DBG_ASSERT( ((long)mnStart - nDiff) >= 0, "TextCharAttrib: MoveBackward?!" );
     203                 :          0 :     mnStart = mnStart - nDiff;
     204                 :          0 :     mnEnd = mnEnd - nDiff;
     205                 :          0 : }
     206                 :            : 
     207                 :          0 : inline void TextCharAttrib::Expand( sal_uInt16 nDiff )
     208                 :            : {
     209                 :            :     DBG_ASSERT( ( ((long)mnEnd + nDiff) <= (long)0xFFFF ), "TextCharAttrib: Expand?!" );
     210                 :          0 :     mnEnd = mnEnd + nDiff;
     211                 :          0 : }
     212                 :            : 
     213                 :          0 : inline void TextCharAttrib::Collaps( sal_uInt16 nDiff )
     214                 :            : {
     215                 :            :     DBG_ASSERT( (long)mnEnd - nDiff >= (long)mnStart, "TextCharAttrib: Collaps?!" );
     216                 :          0 :     mnEnd = mnEnd - nDiff;
     217                 :          0 : }
     218                 :            : 
     219                 :          0 : inline sal_Bool TextCharAttrib::IsIn( sal_uInt16 nIndex )
     220                 :            : {
     221 [ #  # ][ #  # ]:          0 :     return ( ( mnStart <= nIndex ) && ( mnEnd >= nIndex ) );
     222                 :            : }
     223                 :            : 
     224                 :          0 : inline sal_Bool TextCharAttrib::IsInside( sal_uInt16 nIndex )
     225                 :            : {
     226 [ #  # ][ #  # ]:          0 :     return ( ( mnStart < nIndex ) && ( mnEnd > nIndex ) );
     227                 :            : }
     228                 :            : 
     229                 :          0 : inline sal_Bool TextCharAttrib::IsEmpty()
     230                 :            : {
     231                 :          0 :     return mnStart == mnEnd;
     232                 :            : }
     233                 :            : 
     234                 :            : #endif // _TXTATTR_HXX
     235                 :            : 
     236                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10