LCOV - code coverage report
Current view: top level - include/vcl - txtattr.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 34 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 20 0.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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_TXTATTR_HXX
      21             : #define INCLUDED_VCL_TXTATTR_HXX
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <tools/color.hxx>
      25             : #include <tools/debug.hxx>
      26             : #include <vcl/vclenum.hxx>
      27             : #include <vcl/dllapi.h>
      28             : 
      29             : namespace vcl { class Font; }
      30             : 
      31             : #define TEXTATTR_FONTCOLOR  1
      32             : #define TEXTATTR_HYPERLINK  2
      33             : #define TEXTATTR_FONTWEIGHT 3
      34             : 
      35             : #define TEXTATTR_USER_START 1000 //start id for user defined text attributes
      36             : #define TEXTATTR_PROTECTED  4
      37             : 
      38             : 
      39             : class VCL_DLLPUBLIC TextAttrib
      40             : {
      41             : private:
      42             :     sal_uInt16                  mnWhich;
      43             : 
      44             : protected:
      45           0 :                             TextAttrib( sal_uInt16 nWhich ) { mnWhich = nWhich; }
      46           0 :                             TextAttrib( const TextAttrib& rAttr ) { mnWhich = rAttr.mnWhich; }
      47             : 
      48             : public:
      49             : 
      50             :     virtual                 ~TextAttrib();
      51             : 
      52           0 :     sal_uInt16              Which() const   { return mnWhich; }
      53             :     virtual void            SetFont( vcl::Font& rFont ) const = 0;
      54             :     virtual TextAttrib*     Clone() const = 0;
      55             : 
      56             :     virtual bool            operator==( const TextAttrib& rAttr ) const = 0;
      57             :     bool                    operator!=( const TextAttrib& rAttr ) const
      58             :                                 { return !(*this == rAttr ); }
      59             : };
      60             : 
      61             : 
      62             : 
      63             : class VCL_DLLPUBLIC TextAttribFontColor : public TextAttrib
      64             : {
      65             : private:
      66             :     Color   maColor;
      67             : 
      68             : public:
      69             :                             TextAttribFontColor( const Color& rColor );
      70             :                             TextAttribFontColor( const TextAttribFontColor& rAttr );
      71             :                             virtual ~TextAttribFontColor();
      72             : 
      73           0 :     const Color&            GetColor() const { return maColor; }
      74             : 
      75             :     virtual void            SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
      76             :     virtual TextAttrib*     Clone() const SAL_OVERRIDE;
      77             :     virtual bool            operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
      78             : 
      79             : };
      80             : 
      81             : class VCL_DLLPUBLIC TextAttribFontWeight : public TextAttrib
      82             : {
      83             : private:
      84             :     FontWeight  meWeight;
      85             : 
      86             : public:
      87             :                             TextAttribFontWeight( FontWeight eWeight );
      88             :                             TextAttribFontWeight( const TextAttribFontWeight& rAttr );
      89             :                             virtual ~TextAttribFontWeight();
      90             : 
      91             :     virtual void            SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
      92             :     virtual TextAttrib*     Clone() const SAL_OVERRIDE;
      93             :     virtual bool            operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
      94             : 
      95           0 :     inline FontWeight getFontWeight() const { return meWeight; }
      96             : };
      97             : 
      98             : 
      99             : class TextAttribHyperLink : public TextAttrib
     100             : {
     101             : private:
     102             :     OUString    maURL;
     103             :     OUString    maDescription;
     104             :     Color       maColor;
     105             : 
     106             : public:
     107             :                             TextAttribHyperLink( const TextAttribHyperLink& rAttr );
     108             :                             virtual ~TextAttribHyperLink();
     109             : 
     110             :     void                    SetURL( const OUString& rURL )             { maURL = rURL; }
     111           0 :     const OUString&         GetURL() const                              { return maURL; }
     112             : 
     113             :     void                    SetDescription( const OUString& rDescr )   { maDescription = rDescr; }
     114             :     const OUString&         GetDescription() const                      { return maDescription; }
     115             : 
     116             :     void                    SetColor( const Color& rColor )             { maColor = rColor; }
     117             :     const Color&            GetColor() const                            { return maColor; }
     118             : 
     119             :     virtual void            SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
     120             :     virtual TextAttrib*     Clone() const SAL_OVERRIDE;
     121             :     virtual bool            operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
     122             : };
     123             : 
     124             : class VCL_DLLPUBLIC TextAttribProtect : public TextAttrib
     125             : {
     126             : public:
     127             :                             TextAttribProtect();
     128             :                             TextAttribProtect( const TextAttribProtect& rAttr );
     129             :                             virtual ~TextAttribProtect();
     130             : 
     131             :     virtual void            SetFont( vcl::Font& rFont ) const SAL_OVERRIDE;
     132             :     virtual TextAttrib*     Clone() const SAL_OVERRIDE;
     133             :     virtual bool            operator==( const TextAttrib& rAttr ) const SAL_OVERRIDE;
     134             : 
     135             : };
     136             : 
     137             : 
     138             : class TextCharAttrib
     139             : {
     140             : private:
     141             :     TextAttrib*     mpAttr;
     142             :     sal_uInt16          mnStart;
     143             :     sal_uInt16          mnEnd;
     144             : 
     145             : protected:
     146             : 
     147             : public:
     148             : 
     149             :                     TextCharAttrib( const TextAttrib& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
     150             :                     TextCharAttrib( const TextCharAttrib& rTextCharAttrib );
     151             :                     ~TextCharAttrib();
     152             : 
     153           0 :     const TextAttrib&   GetAttr() const         { return *mpAttr; }
     154             : 
     155           0 :     sal_uInt16          Which() const               { return mpAttr->Which(); }
     156             : 
     157           0 :     sal_uInt16          GetStart() const            { return mnStart; }
     158           0 :     sal_uInt16&         GetStart()                  { return mnStart; }
     159             : 
     160           0 :     sal_uInt16          GetEnd() const              { return mnEnd; }
     161           0 :     sal_uInt16&         GetEnd()                    { return mnEnd; }
     162             : 
     163             :     inline sal_uInt16   GetLen() const;
     164             : 
     165             :     inline void     MoveForward( sal_uInt16 nDiff );
     166             :     inline void     MoveBackward( sal_uInt16 nDiff );
     167             : 
     168             :     inline void     Expand( sal_uInt16 nDiff );
     169             :     inline void     Collaps( sal_uInt16 nDiff );
     170             : 
     171             :     inline bool     IsIn( sal_uInt16 nIndex );
     172             :     inline bool     IsInside( sal_uInt16 nIndex );
     173             :     inline bool     IsEmpty() const;
     174             : 
     175             : };
     176             : 
     177           0 : inline sal_uInt16 TextCharAttrib::GetLen() const
     178             : {
     179             :     DBG_ASSERT( mnEnd >= mnStart, "TextCharAttrib: nEnd < nStart!" );
     180           0 :     return mnEnd-mnStart;
     181             : }
     182             : 
     183           0 : inline void TextCharAttrib::MoveForward( sal_uInt16 nDiff )
     184             : {
     185             :     DBG_ASSERT( ((long)mnEnd + nDiff) <= 0xFFFF, "TextCharAttrib: MoveForward?!" );
     186           0 :     mnStart = mnStart + nDiff;
     187           0 :     mnEnd = mnEnd + nDiff;
     188           0 : }
     189             : 
     190           0 : inline void TextCharAttrib::MoveBackward( sal_uInt16 nDiff )
     191             : {
     192             :     DBG_ASSERT( ((long)mnStart - nDiff) >= 0, "TextCharAttrib: MoveBackward?!" );
     193           0 :     mnStart = mnStart - nDiff;
     194           0 :     mnEnd = mnEnd - nDiff;
     195           0 : }
     196             : 
     197           0 : inline void TextCharAttrib::Expand( sal_uInt16 nDiff )
     198             : {
     199             :     DBG_ASSERT( ( ((long)mnEnd + nDiff) <= (long)0xFFFF ), "TextCharAttrib: Expand?!" );
     200           0 :     mnEnd = mnEnd + nDiff;
     201           0 : }
     202             : 
     203           0 : inline void TextCharAttrib::Collaps( sal_uInt16 nDiff )
     204             : {
     205             :     DBG_ASSERT( (long)mnEnd - nDiff >= (long)mnStart, "TextCharAttrib: Collaps?!" );
     206           0 :     mnEnd = mnEnd - nDiff;
     207           0 : }
     208             : 
     209           0 : inline bool TextCharAttrib::IsIn( sal_uInt16 nIndex )
     210             : {
     211           0 :     return ( ( mnStart <= nIndex ) && ( mnEnd >= nIndex ) );
     212             : }
     213             : 
     214           0 : inline bool TextCharAttrib::IsInside( sal_uInt16 nIndex )
     215             : {
     216           0 :     return ( ( mnStart < nIndex ) && ( mnEnd > nIndex ) );
     217             : }
     218             : 
     219           0 : inline bool TextCharAttrib::IsEmpty() const
     220             : {
     221           0 :     return mnStart == mnEnd;
     222             : }
     223             : 
     224             : #endif // INCLUDED_VCL_TXTATTR_HXX
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11