LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xistring.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 12 75.0 %
Date: 2012-08-25 Functions: 9 12 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     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 SC_XISTRING_HXX
      21                 :            : #define SC_XISTRING_HXX
      22                 :            : 
      23                 :            : #include "xlstring.hxx"
      24                 :            : 
      25                 :            : // Byte/Unicode strings =======================================================
      26                 :            : 
      27                 :            : class XclImpStream;
      28                 :            : 
      29                 :            : /** This class represents an unformatted or formatted string and provides importing from stream. */
      30         [ +  - ]:        807 : class XclImpString
      31                 :            : {
      32                 :            : public:
      33                 :            :     /** Constructs an empty string. */
      34                 :            :     explicit            XclImpString();
      35                 :            :     /** Constructs an unformatted string. */
      36                 :            :     explicit            XclImpString( const String& rString );
      37                 :            : 
      38                 :            :                         ~XclImpString();
      39                 :            : 
      40                 :            :     /** Reads a complete string from the passed stream. */
      41                 :            :     void                Read( XclImpStream& rStrm, XclStrFlags nFlags = EXC_STR_DEFAULT );
      42                 :            : 
      43                 :            :     /** Sets the passed string data. */
      44                 :          0 :     inline void         SetText( const String& rText ) { maString = rText; }
      45                 :            :     /** Sets the passed formatting buffer. */
      46                 :          0 :     inline void         SetFormats( const XclFormatRunVec& rFormats ) { maFormats = rFormats; }
      47                 :            :     /** Insert a formatting run to the format buffer. */
      48                 :            :     inline void         AppendFormat( sal_uInt16 nChar, sal_uInt16 nFontIdx ) { AppendFormat( maFormats, nChar, nFontIdx ); }
      49                 :            :     /** Reads and appends the formatting information (run count and runs) from stream. */
      50                 :          0 :     inline void         ReadFormats( XclImpStream& rStrm ) { ReadFormats( rStrm, maFormats ); }
      51                 :            :     /** Reads and appends nRunCount formatting runs from stream. */
      52                 :        105 :     inline void         ReadFormats( XclImpStream& rStrm, sal_uInt16 nRunCount ) { ReadFormats( rStrm, maFormats, nRunCount ); }
      53                 :            :     /** Reads and appends formatting runs from an OBJ or TXO record. */
      54                 :         48 :     inline void         ReadObjFormats( XclImpStream& rStrm, sal_uInt16 nFormatSize ) { ReadObjFormats( rStrm, maFormats, nFormatSize ); }
      55                 :            : 
      56                 :            :     /** Returns true, if the string is empty. */
      57                 :         24 :     inline bool         IsEmpty() const { return maString.Len() == 0; }
      58                 :            :     /** Returns the pure text data of the string. */
      59                 :      12381 :     inline const String& GetText() const { return maString; }
      60                 :            : 
      61                 :            :     /** Returns true, if the string contains formatting information. */
      62                 :       2166 :     inline bool         IsRich() const { return !maFormats.empty(); }
      63                 :            :     /** Returns the formatting run vector. */
      64                 :        162 :     inline const XclFormatRunVec& GetFormats() const { return maFormats; }
      65                 :            : 
      66                 :            :     /** Insert a formatting run to the passed format buffer. */
      67                 :            :     static void         AppendFormat( XclFormatRunVec& rFormats, sal_uInt16 nChar, sal_uInt16 nFontIdx );
      68                 :            :     /** Reads and appends the formatting information (run count and runs) from stream. */
      69                 :            :     static void         ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats );
      70                 :            :     /** Reads and appends nRunCount formatting runs from stream. */
      71                 :            :     static void         ReadFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nRunCount );
      72                 :            :     /** Reads and appends formatting runs from an OBJ or TXO record. */
      73                 :            :     static void         ReadObjFormats( XclImpStream& rStrm, XclFormatRunVec& rFormats, sal_uInt16 nFormatSize );
      74                 :            : 
      75                 :            : private:
      76                 :            :     String              maString;       /// The text data of the string.
      77                 :            :     XclFormatRunVec     maFormats;      /// All formatting runs.
      78                 :            : };
      79                 :            : 
      80                 :            : // String iterator ============================================================
      81                 :            : 
      82                 :            : /** Iterates over formatted string portions. */
      83                 :            : class XclImpStringIterator
      84                 :            : {
      85                 :            : public:
      86                 :            :     explicit            XclImpStringIterator( const XclImpString& rString );
      87                 :            : 
      88                 :            :     /** Returns true, if the iterator references a valid text portion. */
      89                 :         24 :     inline bool         Is() const { return mnTextBeg < mrText.Len(); }
      90                 :            :     /** Returns the index of the current text portion. */
      91                 :          6 :     inline size_t       GetPortionIndex() const { return mnPortion; }
      92                 :            :     /** Returns the string of the current text portion. */
      93                 :            :     String              GetPortionText() const;
      94                 :            :     /** Returns the font index of the current text portion. */
      95                 :            :     sal_uInt16          GetPortionFont() const;
      96                 :            : 
      97                 :            :     /** Moves iterator to next text portion. */
      98                 :            :     XclImpStringIterator& operator++();
      99                 :            : 
     100                 :            : private:
     101                 :            :     const String&       mrText;         /// The processed string.
     102                 :            :     const XclFormatRunVec& mrFormats;   /// The vector of formatting runs.
     103                 :            :     size_t              mnPortion;      /// Current text portion.
     104                 :            :     xub_StrLen          mnTextBeg;      /// First character of current portion.
     105                 :            :     xub_StrLen          mnTextEnd;      /// First character of next portion.
     106                 :            :     size_t              mnFormatsBeg;   /// Formatting run index for current portion.
     107                 :            :     size_t              mnFormatsEnd;   /// Formatting run index for next portion.
     108                 :            : };
     109                 :            : 
     110                 :            : // ============================================================================
     111                 :            : 
     112                 :            : #endif
     113                 :            : 
     114                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10