LCOV - code coverage report
Current view: top level - lotuswordpro/source/filter/xfilter - xfindex.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 33 0.0 %
Date: 2014-04-11 Functions: 0 10 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             :  *
       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             :  * Represente index source,index body and index index entry.
      59             :  ************************************************************************/
      60             : #ifndef     _XFINDEX_HXX
      61             : #define     _XFINDEX_HXX
      62             : #include <map>
      63             : #include <vector>
      64             : 
      65             : #include "xfcontent.hxx"
      66             : #include "ixfproperty.hxx"
      67             : #include "xfcontentcontainer.hxx"
      68             : #include "xftabstop.hxx"
      69             : 
      70             : class XFIndex;
      71             : class XFIndexTemplate;
      72             : class XFParagraph;
      73             : 
      74             : /**
      75             :  * @brief
      76             :  * Index template.
      77             :  * When index update, the template is used to decide the index body.
      78             :  */
      79           0 : class XFIndexTemplate : public XFContent
      80             : {
      81             : public:
      82             :     XFIndexTemplate();
      83             : 
      84             : public:
      85             :     /**
      86             :      * @descr   Set template level.
      87             :      */
      88             :     void    SetLevel(const OUString& level);
      89             :     /**
      90             :      * @descr   Set style.
      91             :      */
      92             :     void    SetStyleName(const OUString& style) SAL_OVERRIDE;
      93             :     /**
      94             :      * @descr   Add a entry in the template.
      95             :      */
      96             :     void    AddEntry(enumXFIndexTemplate entry, const OUString& styleName = "");
      97             : 
      98             :     /**
      99             :      * @descr   Add a tab entry in the template.
     100             :      */
     101             :     void    AddTabEntry(enumXFTab type, double len, sal_Unicode leader = '*', sal_Unicode delimiter='.', const OUString& styleName = "");
     102             : 
     103             :     /**
     104             :      * @descr   Add a entry in the template.
     105             :      */
     106             :     void    AddTextEntry(const OUString& sSpan, const OUString& styleName = "");
     107             : 
     108             :     /**
     109             :      * @descr   clear all index template parts.
     110             :      */
     111             :     void    Clear();
     112             :     virtual void    ToXml(IXFStream *pStrm) SAL_OVERRIDE;
     113             : 
     114             : private:
     115             :     /**
     116             :      * @descr   Helper function.
     117             :      */
     118             :     void    SetTagName(const OUString& tag);
     119             : 
     120             :     friend class XFIndex;
     121             : private:
     122             :     OUString   m_nLevel;
     123             :     OUString   m_strStyle;
     124             :     enumXFTab  m_eTabType;
     125             :     double     m_fTabLength;
     126             :     OUString   m_strTabDelimiter;
     127             :     OUString   m_strTabLeader;
     128             :     OUString   m_strTagName;
     129             :     typedef std::pair<enumXFIndexTemplate, OUString> TOCTEMPLATE_ENTRY_TYPE;
     130             :     std::vector<TOCTEMPLATE_ENTRY_TYPE> m_aEntries; // template entry + text style
     131             :     std::map<sal_uInt16, OUString> m_aTextEntries;
     132             : 
     133             :     OUString m_strChapterTextStyle;
     134             : };
     135             : 
     136             : /**
     137             :  * @brief
     138             :  * Index, include index template, index body.
     139             :  */
     140             : class XFIndex : public XFContentContainer
     141             : {
     142             : public:
     143             :     XFIndex();
     144             : 
     145             :     virtual ~XFIndex();
     146             : 
     147             : public:
     148             :     /**
     149             :      * @descr   Set index type.
     150             :      */
     151             :     void    SetIndexType(enumXFIndex type);
     152             : 
     153             :     /**
     154             :      * @descr   Add index templaet entry.
     155             :      */
     156             :     void    AddTemplate(const OUString& level, const OUString& style, XFIndexTemplate* templ);
     157             : 
     158             :     /**
     159             :      * @descr   Set if protected index to prevent handly-revise.
     160             :      */
     161             :     void    SetProtected(sal_Bool protect);
     162             : 
     163             :     /**
     164             :      * @descr   Set separator.
     165             :      */
     166             :     void    SetSeparator(sal_Bool sep);
     167             : 
     168             :     virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
     169             : 
     170             :     void AddTocSource(sal_uInt16 nLevel, const OUString& sStyleName);
     171             : 
     172             : private:
     173             :     enumXFIndex     m_eType;
     174             :     OUString        m_strTitle;
     175             :     OUString        m_strSectStyle;
     176             :     bool            m_bProtect;
     177             :     bool            m_bSeparator;
     178             :     XFParagraph*    m_pTitle;
     179             : 
     180             :     std::vector<XFIndexTemplate *>  m_aTemplates; // template entry + style
     181             : 
     182             :     #define MAX_TOC_LEVEL 10
     183             :     std::vector<OUString> m_aTOCSource[MAX_TOC_LEVEL+1];
     184             : 
     185             :     sal_uInt32      m_nMaxLevel;
     186             : };
     187             : 
     188           0 : inline XFIndexTemplate::XFIndexTemplate()
     189             :     : m_eTabType(enumXFTabNone)
     190           0 :     , m_fTabLength(0.0)
     191             : {
     192           0 :     m_nLevel = OUString::number(0);
     193           0 : }
     194             : 
     195           0 : inline void XFIndexTemplate::SetLevel(const OUString& level)
     196             : {
     197           0 :     m_nLevel = level;
     198           0 : }
     199           0 : inline void XFIndexTemplate::SetStyleName(const OUString& style)
     200             : {
     201           0 :     m_strStyle = style;
     202           0 : }
     203             : 
     204           0 : inline void XFIndexTemplate::SetTagName(const OUString& tag)
     205             : {
     206           0 :     m_strTagName = tag;
     207           0 : }
     208             : 
     209           0 : inline void XFIndexTemplate::AddEntry(enumXFIndexTemplate entry, const OUString& styleName)
     210             : {
     211           0 :     std::pair<enumXFIndexTemplate, OUString> pair(entry, styleName);
     212           0 :     m_aEntries.push_back(pair);
     213           0 : }
     214             : 
     215           0 : inline void XFIndexTemplate::AddTabEntry(enumXFTab type, double len, sal_Unicode leader, sal_Unicode delimiter, const OUString& styleName)
     216             : {
     217           0 :     m_eTabType = type;
     218           0 :     m_strTabLeader = OUString( leader );
     219           0 :     m_strTabDelimiter = OUString( delimiter );
     220           0 :     m_fTabLength = len;
     221             : 
     222           0 :     AddEntry(enumXFIndexTemplateTab, styleName);
     223           0 : }
     224             : 
     225           0 : inline void XFIndexTemplate::AddTextEntry(const OUString& sText, const OUString& styleName)
     226             : {
     227           0 :     sal_uInt16 nLen = m_aEntries.size();
     228           0 :     AddEntry(enumXFIndexTemplateSpan, styleName);
     229             : 
     230           0 :     m_aTextEntries[nLen] = sText;
     231           0 : }
     232             : 
     233             : inline void XFIndexTemplate::Clear()
     234             : {
     235             :     m_aEntries.clear();
     236             : }
     237             : 
     238           0 : inline void XFIndex::SetIndexType(enumXFIndex type)
     239             : {
     240           0 :     m_eType = type;
     241           0 : }
     242             : 
     243             : #endif
     244             : 
     245             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10