LCOV - code coverage report
Current view: top level - sw/inc - tox.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 102 135 75.6 %
Date: 2012-08-25 Functions: 70 85 82.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 30 40.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                 :            : #ifndef SW_TOX_HXX
      29                 :            : #define SW_TOX_HXX
      30                 :            : 
      31                 :            : #include <cppuhelper/weakref.hxx>
      32                 :            : 
      33                 :            : #include <i18npool/lang.h>
      34                 :            : #include <svl/poolitem.hxx>
      35                 :            : #include <tools/string.hxx>
      36                 :            : #include <osl/diagnose.h>
      37                 :            : 
      38                 :            : #include <editeng/svxenum.hxx>
      39                 :            : #include <swtypes.hxx>
      40                 :            : #include <toxe.hxx>
      41                 :            : #include <calbck.hxx>
      42                 :            : 
      43                 :            : #include <vector> // #i21237#
      44                 :            : 
      45                 :            : namespace com { namespace sun { namespace star {
      46                 :            :     namespace text { class XDocumentIndexMark; }
      47                 :            : } } }
      48                 :            : 
      49                 :            : class SwTOXType;
      50                 :            : class SwTOXMark;
      51                 :            : class SwTxtTOXMark;
      52                 :            : class SwDoc;
      53                 :            : 
      54                 :         56 : class SwTOXMarks : public std::vector<SwTOXMark*> {};
      55                 :            : 
      56                 :            : /*--------------------------------------------------------------------
      57                 :            :      Description:  Entry of content index, alphabetical index or user defined index
      58                 :            :  --------------------------------------------------------------------*/
      59                 :            : 
      60                 :            : class SW_DLLPUBLIC SwTOXMark
      61                 :            :     : public SfxPoolItem
      62                 :            :     , public SwModify
      63                 :            : {
      64                 :            :     friend void _InitCore();
      65                 :            :     friend class SwTxtTOXMark;
      66                 :            : 
      67                 :            :     String aAltText;    // Text of caption is different.
      68                 :            :     String aPrimaryKey, aSecondaryKey;
      69                 :            : 
      70                 :            :     // three more strings for phonetic sorting
      71                 :            :     String aTextReading;
      72                 :            :     String aPrimaryKeyReading;
      73                 :            :     String aSecondaryKeyReading;
      74                 :            : 
      75                 :            :     SwTxtTOXMark* pTxtAttr;
      76                 :            : 
      77                 :            :     sal_uInt16  nLevel;
      78                 :            :     sal_Bool    bAutoGenerated : 1;     // generated using a concordance file
      79                 :            :     sal_Bool    bMainEntry : 1;         // main entry emphasized by character style
      80                 :            : 
      81                 :            :     ::com::sun::star::uno::WeakReference<
      82                 :            :         ::com::sun::star::text::XDocumentIndexMark> m_wXDocumentIndexMark;
      83                 :            : 
      84                 :            :     SwTOXMark();                    // to create the dflt. atr. in _InitCore
      85                 :            : 
      86                 :            : protected:
      87                 :            :     // SwClient
      88                 :            :    virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew );
      89                 :            : 
      90                 :            : public:
      91                 :            :     TYPEINFO();   // rtti
      92                 :            : 
      93                 :            :     // single argument ctors shall be explicit.
      94                 :            :     explicit SwTOXMark( const SwTOXType* pTyp );
      95                 :            :     virtual ~SwTOXMark();
      96                 :            : 
      97                 :            :     SwTOXMark( const SwTOXMark& rCopy );
      98                 :            :     SwTOXMark& operator=( const SwTOXMark& rCopy );
      99                 :            : 
     100                 :            :     // "pure virtual methods" of SfxPoolItem
     101                 :            :     virtual int             operator==( const SfxPoolItem& ) const;
     102                 :            :     virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;
     103                 :            : 
     104                 :            :     void InvalidateTOXMark();
     105                 :            : 
     106                 :            :     String                  GetText() const;
     107                 :            : 
     108                 :            :     inline sal_Bool             IsAlternativeText() const;
     109                 :            :     inline const String&    GetAlternativeText() const;
     110                 :            : 
     111                 :            :     inline void             SetAlternativeText( const String& rAlt );
     112                 :            : 
     113                 :            :     // content or user defined index
     114                 :            :     inline void             SetLevel(sal_uInt16 nLevel);
     115                 :            :     inline sal_uInt16           GetLevel() const;
     116                 :            : 
     117                 :            :     // for alphabetical index only
     118                 :            :     inline void             SetPrimaryKey(const String& rStr );
     119                 :            :     inline void             SetSecondaryKey(const String& rStr);
     120                 :            :     inline void             SetTextReading(const String& rStr);
     121                 :            :     inline void             SetPrimaryKeyReading(const String& rStr );
     122                 :            :     inline void             SetSecondaryKeyReading(const String& rStr);
     123                 :            : 
     124                 :            :     inline const String&    GetPrimaryKey() const;
     125                 :            :     inline const String&    GetSecondaryKey() const;
     126                 :            :     inline const String&    GetTextReading() const;
     127                 :            :     inline const String&    GetPrimaryKeyReading() const;
     128                 :            :     inline const String&    GetSecondaryKeyReading() const;
     129                 :            : 
     130                 :          0 :     sal_Bool                    IsAutoGenerated() const {return bAutoGenerated;}
     131                 :          0 :     void                    SetAutoGenerated(sal_Bool bSet) {bAutoGenerated = bSet;}
     132                 :            : 
     133                 :          6 :     sal_Bool                    IsMainEntry() const {return bMainEntry;}
     134                 :         72 :     void                    SetMainEntry(sal_Bool bSet) { bMainEntry = bSet;}
     135                 :            : 
     136                 :            :     inline const SwTOXType*    GetTOXType() const;
     137                 :            : 
     138                 :         22 :     const SwTxtTOXMark* GetTxtTOXMark() const   { return pTxtAttr; }
     139                 :          4 :           SwTxtTOXMark* GetTxtTOXMark()         { return pTxtAttr; }
     140                 :            : 
     141                 :            :     SW_DLLPRIVATE ::com::sun::star::uno::WeakReference<
     142                 :         90 :         ::com::sun::star::text::XDocumentIndexMark> const& GetXTOXMark() const
     143                 :         90 :             { return m_wXDocumentIndexMark; }
     144                 :         64 :     SW_DLLPRIVATE void SetXTOXMark(::com::sun::star::uno::Reference<
     145                 :            :                     ::com::sun::star::text::XDocumentIndexMark> const& xMark)
     146                 :         64 :             { m_wXDocumentIndexMark = xMark; }
     147                 :         26 :     void DeRegister() { GetRegisteredInNonConst()->Remove( this ); }
     148                 :            :     void RegisterToTOXType( SwTOXType& rMark );
     149                 :            :     static void InsertTOXMarks( SwTOXMarks& aMarks, const SwTOXType& rType );
     150                 :            : };
     151                 :            : 
     152                 :            : /*--------------------------------------------------------------------
     153                 :            :      Description:  index types
     154                 :            :  --------------------------------------------------------------------*/
     155                 :            : 
     156 [ +  - ][ -  + ]:      21056 : class SwTOXType : public SwModify
     157                 :            : {
     158                 :            : public:
     159                 :            :     SwTOXType(TOXTypes eTyp, const String& aName);
     160                 :            : 
     161                 :            :     // @@@ public copy ctor, but no copy assignment?
     162                 :            :     SwTOXType(const SwTOXType& rCopy);
     163                 :            : 
     164                 :            :     inline  const String&   GetTypeName() const;
     165                 :            :     inline TOXTypes         GetType() const;
     166                 :            : 
     167                 :            : private:
     168                 :            :     String          aName;
     169                 :            :     TOXTypes        eType;
     170                 :            : 
     171                 :            :     // @@@ public copy ctor, but no copy assignment?
     172                 :            :     SwTOXType & operator= (const SwTOXType &);
     173                 :            : };
     174                 :            : 
     175                 :            : /*--------------------------------------------------------------------
     176                 :            :      Description:  Structure of the index lines
     177                 :            :  --------------------------------------------------------------------*/
     178                 :            : 
     179                 :            : #define FORM_TITLE              0
     180                 :            : #define FORM_ALPHA_DELIMITTER   1
     181                 :            : #define FORM_PRIMARY_KEY        2
     182                 :            : #define FORM_SECONDARY_KEY      3
     183                 :            : #define FORM_ENTRY              4
     184                 :            : 
     185                 :            : /*
     186                 :            :  Pattern structure
     187                 :            : 
     188                 :            :  <E#> - entry number                    <E# CharStyleName,PoolId>
     189                 :            :  <ET> - entry text                      <ET CharStyleName,PoolId>
     190                 :            :  <E>  - entry text and number           <E CharStyleName,PoolId>
     191                 :            :  <T>  - tab stop                        <T,,Position,Adjust>
     192                 :            :  <C>  - chapter info n = {0, 1, 2, 3, 4 } values of SwChapterFormat <C CharStyleName,PoolId>
     193                 :            :  <TX> - text token                      <X CharStyleName,PoolId, TOX_STYLE_DELIMITERTextContentTOX_STYLE_DELIMITER>
     194                 :            :  <#>  - Page number                     <# CharStyleName,PoolId>
     195                 :            :  <LS> - Link start                      <LS>
     196                 :            :  <LE> - Link end                        <LE>
     197                 :            :  <A00> - Authority entry field          <A02 CharStyleName, PoolId>
     198                 :            :  */
     199                 :            : 
     200                 :            : // These enum values are stored and must not be changed!
     201                 :            : enum FormTokenType
     202                 :            : {
     203                 :            :     TOKEN_ENTRY_NO,
     204                 :            :     TOKEN_ENTRY_TEXT,
     205                 :            :     TOKEN_ENTRY,
     206                 :            :     TOKEN_TAB_STOP,
     207                 :            :     TOKEN_TEXT,
     208                 :            :     TOKEN_PAGE_NUMS,
     209                 :            :     TOKEN_CHAPTER_INFO,
     210                 :            :     TOKEN_LINK_START,
     211                 :            :     TOKEN_LINK_END,
     212                 :            :     TOKEN_AUTHORITY,
     213                 :            :     TOKEN_END
     214                 :            : };
     215                 :            : 
     216      [ +  -  # ]:     100716 : struct SW_DLLPUBLIC SwFormToken
                 [ #  # ]
              [ #  +  - ]
                 [ #  # ]
     217                 :            : {
     218                 :            :     String          sText;
     219                 :            :     String          sCharStyleName;
     220                 :            :     SwTwips         nTabStopPosition;
     221                 :            :     FormTokenType   eTokenType;
     222                 :            :     sal_uInt16          nPoolId;
     223                 :            :     SvxTabAdjust    eTabAlign;
     224                 :            :     sal_uInt16          nChapterFormat;     //SwChapterFormat;
     225                 :            :     sal_uInt16          nOutlineLevel;//the maximum permitted outline level in numbering
     226                 :            :     sal_uInt16          nAuthorityField;    //enum ToxAuthorityField
     227                 :            :     sal_Unicode     cTabFillChar;
     228                 :            :     sal_Bool        bWithTab;      // sal_True: do generate tab
     229                 :            :                                    // character only the tab stop
     230                 :            :                                    // #i21237#
     231                 :            : 
     232                 :       2920 :     SwFormToken(FormTokenType eType ) :
     233                 :            :         nTabStopPosition(0),
     234                 :            :         eTokenType(eType),
     235                 :            :         nPoolId(USHRT_MAX),
     236                 :            :         eTabAlign( SVX_TAB_ADJUST_LEFT ),
     237                 :            :         nChapterFormat(0 /*CF_NUMBER*/),
     238                 :            :         nOutlineLevel(MAXLEVEL),   //default to maximum outline level
     239                 :            :         nAuthorityField(0 /*AUTH_FIELD_IDENTIFIER*/),
     240                 :            :         cTabFillChar(' '),
     241         [ +  - ]:       2920 :         bWithTab(sal_True)  // #i21237#
     242                 :       2920 :     {}
     243                 :            : 
     244                 :            :     String GetString() const;
     245                 :            : };
     246                 :            : 
     247                 :            : struct SwFormTokenEqualToFormTokenType
     248                 :            : {
     249                 :            :     FormTokenType eType;
     250                 :            : 
     251                 :          0 :     SwFormTokenEqualToFormTokenType(FormTokenType _eType) : eType(_eType) {}
     252                 :          0 :     bool operator()(const SwFormToken & rToken)
     253                 :            :     {
     254                 :          0 :         return rToken.eTokenType == eType;
     255                 :            :     }
     256                 :            : };
     257                 :            : 
     258                 :            : /**
     259                 :            :    Functor that appends the string representation of a given token to a string.
     260                 :            : 
     261                 :            :    @param _rText    string to append the string representation to
     262                 :            :    @param rToken    token whose string representation is appended
     263                 :            : */
     264                 :            : struct SwFormTokenToString
     265                 :            : {
     266                 :            :     String & rText;
     267                 :            :     SwFormTokenToString(String & _rText) : rText(_rText) {}
     268                 :            :     void operator()(const SwFormToken & rToken) { rText += rToken.GetString(); }
     269                 :            : };
     270                 :            : 
     271                 :            : /// Vector of tokens.
     272                 :            : typedef std::vector<SwFormToken> SwFormTokens;
     273                 :            : 
     274                 :            : /**
     275                 :            :    Helper class that converts vectors of tokens to strings and vice
     276                 :            :    versa.
     277                 :            :  */
     278                 :        198 : class SW_DLLPUBLIC SwFormTokensHelper
     279                 :            : {
     280                 :            :     /// the tokens
     281                 :            :     SwFormTokens aTokens;
     282                 :            : 
     283                 :            :     /**
     284                 :            :        Builds a token from its string representation.
     285                 :            : 
     286                 :            :        @sPattern          the whole pattern
     287                 :            :        @nCurPatternPos    starting position of the token
     288                 :            : 
     289                 :            :        @return the token
     290                 :            :      */
     291                 :            :     SW_DLLPRIVATE SwFormToken BuildToken( const String & sPattern,
     292                 :            :                                           xub_StrLen & nCurPatternPos ) const;
     293                 :            : 
     294                 :            :     /**
     295                 :            :        Returns the string of a token.
     296                 :            : 
     297                 :            :        @param sPattern    the whole pattern
     298                 :            :        @param nStt        starting position of the token
     299                 :            : 
     300                 :            :        @return   the string representation of the token
     301                 :            :     */
     302                 :            :     SW_DLLPRIVATE String SearchNextToken( const String & sPattern,
     303                 :            :                                           xub_StrLen nStt ) const;
     304                 :            : 
     305                 :            :     /**
     306                 :            :        Returns the type of a token.
     307                 :            : 
     308                 :            :        @param sToken     the string representation of the token
     309                 :            :        @param pTokenLen  return parameter the length of the head of the token
     310                 :            : 
     311                 :            :        If pTokenLen is non-NULL the length of the token's head is
     312                 :            :        written to *pTokenLen
     313                 :            : 
     314                 :            :        @return the type of the token
     315                 :            :     */
     316                 :            :     SW_DLLPRIVATE FormTokenType GetTokenType(const String & sToken,
     317                 :            :                                              xub_StrLen * pTokenLen) const;
     318                 :            : 
     319                 :            : public:
     320                 :            :     /**
     321                 :            :        contructor
     322                 :            : 
     323                 :            :        @param rTokens       vector of tokens
     324                 :            :     */
     325                 :            :     SwFormTokensHelper(const SwFormTokens & rTokens) : aTokens(rTokens) {}
     326                 :            : 
     327                 :            :     /**
     328                 :            :        constructor
     329                 :            : 
     330                 :            :        @param rStr   string representation of the tokens
     331                 :            :     */
     332                 :            :     SwFormTokensHelper(const String & rStr);
     333                 :            : 
     334                 :            :     /**
     335                 :            :        Returns vector of tokens.
     336                 :            : 
     337                 :            :        @return vector of tokens
     338                 :            :     */
     339                 :        198 :     const SwFormTokens & GetTokens() const { return aTokens; }
     340                 :            : };
     341                 :            : 
     342 [ +  - ][ +  + ]:      34780 : class SW_DLLPUBLIC SwForm
         [ +  - ][ +  - ]
                 [ +  + ]
           [ #  #  #  # ]
     343                 :            : {
     344                 :            :     SwFormTokens    aPattern[ AUTH_TYPE_END + 1 ]; // #i21237#
     345                 :            :     String  aTemplate[ AUTH_TYPE_END + 1 ];
     346                 :            : 
     347                 :            :     TOXTypes    eType;
     348                 :            :     sal_uInt16      nFormMaxLevel;
     349                 :            : 
     350                 :            :     sal_Bool    bGenerateTabPos : 1;
     351                 :            :     sal_Bool    bIsRelTabPos : 1;
     352                 :            :     sal_Bool    bCommaSeparated : 1;
     353                 :            : 
     354                 :            : public:
     355                 :            :     SwForm( TOXTypes eTOXType = TOX_CONTENT );
     356                 :            :     SwForm( const SwForm& rForm );
     357                 :            : 
     358                 :            :     SwForm& operator=( const SwForm& rForm );
     359                 :            : 
     360                 :            :     inline void SetTemplate(sal_uInt16 nLevel, const String& rName);
     361                 :            :     inline const String&    GetTemplate(sal_uInt16 nLevel) const;
     362                 :            : 
     363                 :            :     // #i21237#
     364                 :            :     void    SetPattern(sal_uInt16 nLevel, const SwFormTokens& rName);
     365                 :            :     void    SetPattern(sal_uInt16 nLevel, const String& rStr);
     366                 :            :     const SwFormTokens& GetPattern(sal_uInt16 nLevel) const;
     367                 :            : 
     368                 :            :     // fill tab stop positions from template to pattern
     369                 :            :     // #i21237#
     370                 :            :     void                    AdjustTabStops(SwDoc& rDoc,
     371                 :            :                                            sal_Bool bInsertNewTabStops = sal_False);
     372                 :            : 
     373                 :            :     inline TOXTypes GetTOXType() const;
     374                 :            :     inline sal_uInt16   GetFormMax() const;
     375                 :            : 
     376                 :         12 :     sal_Bool IsRelTabPos() const    {   return bIsRelTabPos; }
     377                 :         24 :     void SetRelTabPos( sal_Bool b ) {   bIsRelTabPos = b;       }
     378                 :            : 
     379                 :          6 :     sal_Bool IsCommaSeparated() const       { return bCommaSeparated;}
     380                 :          4 :     void SetCommaSeparated( sal_Bool b)     { bCommaSeparated = b;}
     381                 :            : 
     382                 :            :     static sal_uInt16 GetFormMaxLevel( TOXTypes eType );
     383                 :            : 
     384                 :            :     static const sal_Char*  aFormEntry;             // <E>
     385                 :            :     static sal_uInt8 nFormEntryLen;                      // 3 characters
     386                 :            :     static const sal_Char*  aFormTab;               // <T>
     387                 :            :     static sal_uInt8 nFormTabLen;                        // 3 characters
     388                 :            :     static const sal_Char*  aFormPageNums;          // <P>
     389                 :            :     static sal_uInt8 nFormPageNumsLen;                   // 3 characters
     390                 :            :     static const sal_Char* aFormLinkStt;            // <LS>
     391                 :            :     static sal_uInt8 nFormLinkSttLen;                    // 4 characters
     392                 :            :     static const sal_Char* aFormLinkEnd;            // <LE>
     393                 :            :     static sal_uInt8 nFormLinkEndLen;                    // 4 characters
     394                 :            :     static const sal_Char*  aFormEntryNum;          // <E#>
     395                 :            :     static sal_uInt8 nFormEntryNumLen;                   // 4 characters
     396                 :            :     static const sal_Char*  aFormEntryTxt;          // <ET>
     397                 :            :     static sal_uInt8 nFormEntryTxtLen;                   // 4 characters
     398                 :            :     static const sal_Char*  aFormChapterMark;       // <C>
     399                 :            :     static sal_uInt8 nFormChapterMarkLen;                // 3 characters
     400                 :            :     static const sal_Char*  aFormText;              // <TX>
     401                 :            :     static sal_uInt8 nFormTextLen;                       // 4 characters
     402                 :            :     static const sal_Char*  aFormAuth;              // <Axx> xx - decimal enum value
     403                 :            :     static sal_uInt8 nFormAuthLen;                       // 3 characters
     404                 :            : };
     405                 :            : 
     406                 :            : /*--------------------------------------------------------------------
     407                 :            :      Description: Content to create indexes of
     408                 :            :  --------------------------------------------------------------------*/
     409                 :            : 
     410                 :            : typedef sal_uInt16 SwTOXElement;
     411                 :            : namespace nsSwTOXElement
     412                 :            : {
     413                 :            :     const SwTOXElement TOX_MARK             = 1;
     414                 :            :     const SwTOXElement TOX_OUTLINELEVEL     = 2;
     415                 :            :     const SwTOXElement TOX_TEMPLATE         = 4;
     416                 :            :     const SwTOXElement TOX_OLE              = 8;
     417                 :            :     const SwTOXElement TOX_TABLE            = 16;
     418                 :            :     const SwTOXElement TOX_GRAPHIC          = 32;
     419                 :            :     const SwTOXElement TOX_FRAME            = 64;
     420                 :            :     const SwTOXElement TOX_SEQUENCE         = 128;
     421                 :            : }
     422                 :            : 
     423                 :            : typedef sal_uInt16 SwTOIOptions;
     424                 :            : namespace nsSwTOIOptions
     425                 :            : {
     426                 :            :     const SwTOIOptions TOI_SAME_ENTRY       = 1;
     427                 :            :     const SwTOIOptions TOI_FF               = 2;
     428                 :            :     const SwTOIOptions TOI_CASE_SENSITIVE   = 4;
     429                 :            :     const SwTOIOptions TOI_KEY_AS_ENTRY     = 8;
     430                 :            :     const SwTOIOptions TOI_ALPHA_DELIMITTER = 16;
     431                 :            :     const SwTOIOptions TOI_DASH             = 32;
     432                 :            :     const SwTOIOptions TOI_INITIAL_CAPS     = 64;
     433                 :            : }
     434                 :            : 
     435                 :            : //which part of the caption is to be displayed
     436                 :            : enum SwCaptionDisplay
     437                 :            : {
     438                 :            :     CAPTION_COMPLETE,
     439                 :            :     CAPTION_NUMBER,
     440                 :            :     CAPTION_TEXT
     441                 :            : };
     442                 :            : 
     443                 :            : typedef sal_uInt16 SwTOOElements;
     444                 :            : namespace nsSwTOOElements
     445                 :            : {
     446                 :            :     const SwTOOElements TOO_MATH            = 0x01;
     447                 :            :     const SwTOOElements TOO_CHART           = 0x02;
     448                 :            :     const SwTOOElements TOO_CALC            = 0x08;
     449                 :            :     const SwTOOElements TOO_DRAW_IMPRESS    = 0x10;
     450                 :            :     const SwTOOElements TOO_OTHER           = 0x80;
     451                 :            : }
     452                 :            : 
     453                 :            : #define TOX_STYLE_DELIMITER ((sal_Unicode)0x01)
     454                 :            : 
     455                 :            : /*--------------------------------------------------------------------
     456                 :            :      Description:  Class for all indexes
     457                 :            :  --------------------------------------------------------------------*/
     458                 :            : 
     459                 :            : class SW_DLLPUBLIC SwTOXBase : public SwClient
     460                 :            : {
     461                 :            :     SwForm      aForm;              // description of the lines
     462                 :            :     String      aName;              // unique name
     463                 :            :     String      aTitle;             // title
     464                 :            : 
     465                 :            :     String      sMainEntryCharStyle; // name of the character style applied to main index entries
     466                 :            : 
     467                 :            :     String      aStyleNames[MAXLEVEL]; // (additional) style names TOX_CONTENT, TOX_USER
     468                 :            :     String      sSequenceName;      // FieldTypeName of a caption sequence
     469                 :            : 
     470                 :            :     LanguageType    eLanguage;
     471                 :            :     String          sSortAlgorithm;
     472                 :            : 
     473                 :            :     union {
     474                 :            :         sal_uInt16      nLevel;             // consider outline levels
     475                 :            :         sal_uInt16      nOptions;           // options of alphabetical index
     476                 :            :     } aData;
     477                 :            : 
     478                 :            :     sal_uInt16      nCreateType;        // sources to create the index from
     479                 :            :     sal_uInt16      nOLEOptions;        // OLE sources
     480                 :            :     SwCaptionDisplay eCaptionDisplay;   //
     481                 :            :     sal_Bool        bProtected : 1;         // index protected ?
     482                 :            :     sal_Bool        bFromChapter : 1;       // create from chapter or document
     483                 :            :     sal_Bool        bFromObjectNames : 1;   // create a table or object index
     484                 :            :                                     // from the names rather than the caption
     485                 :            :     sal_Bool        bLevelFromChapter : 1; // User index: get the level from the source chapter
     486                 :            : public:
     487                 :            :     SwTOXBase( const SwTOXType* pTyp, const SwForm& rForm,
     488                 :            :                sal_uInt16 nCreaType, const String& rTitle );
     489                 :            :     SwTOXBase( const SwTOXBase& rCopy, SwDoc* pDoc = 0 );
     490                 :            :     virtual ~SwTOXBase();
     491                 :            : 
     492                 :            :     virtual sal_Bool GetInfo( SfxPoolItem& rInfo ) const;
     493                 :            : 
     494                 :            :     // a kind of CopyCtor - check if the TOXBase is at TOXType of the doc.
     495                 :            :     // If not, so create it an copy all other used things. The return is this
     496                 :            :     SwTOXBase& CopyTOXBase( SwDoc*, const SwTOXBase& );
     497                 :            : 
     498                 :            :     const SwTOXType*    GetTOXType() const; //
     499                 :            : 
     500                 :            :     sal_uInt16              GetCreateType() const;      // creation types
     501                 :            : 
     502                 :        300 :     const String&       GetTOXName() const {return aName;}
     503                 :         66 :     void                SetTOXName(const String& rSet) {aName = rSet;}
     504                 :            : 
     505                 :            :     const String&       GetTitle() const;           // Title
     506                 :            :     const String&       GetTypeName() const;        // Name
     507                 :            :     const SwForm&       GetTOXForm() const;         // description of the lines
     508                 :            : 
     509                 :            :     void                SetCreate(sal_uInt16);
     510                 :            :     void                SetTitle(const String& rTitle);
     511                 :            :     void                SetTOXForm(const SwForm& rForm);
     512                 :            : 
     513                 :            :     TOXTypes            GetType() const;
     514                 :            : 
     515                 :          6 :     const String&       GetMainEntryCharStyle() const {return sMainEntryCharStyle;}
     516                 :          2 :     void                SetMainEntryCharStyle(const String& rSet)  {sMainEntryCharStyle = rSet;}
     517                 :            : 
     518                 :            :     // content index only
     519                 :            :     inline void             SetLevel(sal_uInt16);                   // consider outline level
     520                 :            :     inline sal_uInt16           GetLevel() const;
     521                 :            : 
     522                 :            :     // alphabetical index only
     523                 :            :     inline sal_uInt16           GetOptions() const;                 // alphabetical index options
     524                 :            :     inline void             SetOptions(sal_uInt16 nOpt);
     525                 :            : 
     526                 :            :     // index of objects
     527                 :       1100 :     sal_uInt16      GetOLEOptions() const {return nOLEOptions;}
     528                 :        418 :     void        SetOLEOptions(sal_uInt16 nOpt) {nOLEOptions = nOpt;}
     529                 :            : 
     530                 :            :     // index of objects
     531                 :            : 
     532                 :            :     // user defined index only
     533                 :            :     inline void             SetTemplateName(const String& rName); // Absatzlayout beachten
     534                 :            : 
     535                 :         40 :     const String&           GetStyleNames(sal_uInt16 nLevel) const
     536                 :            :                                 {
     537                 :            :                                 OSL_ENSURE( nLevel < MAXLEVEL, "Which level?");
     538                 :         40 :                                 return aStyleNames[nLevel];
     539                 :            :                                 }
     540                 :          0 :     void                    SetStyleNames(const String& rSet, sal_uInt16 nLevel)
     541                 :            :                                 {
     542                 :            :                                 OSL_ENSURE( nLevel < MAXLEVEL, "Which level?");
     543                 :          0 :                                 aStyleNames[nLevel] = rSet;
     544                 :          0 :                                 }
     545                 :         20 :     sal_Bool                    IsFromChapter() const { return bFromChapter;}
     546                 :         26 :     void                    SetFromChapter(sal_Bool bSet) { bFromChapter = bSet;}
     547                 :            : 
     548                 :          4 :     sal_Bool                    IsFromObjectNames() const {return bFromObjectNames;}
     549                 :          8 :     void                    SetFromObjectNames(sal_Bool bSet) {bFromObjectNames = bSet;}
     550                 :            : 
     551                 :          2 :     sal_Bool                    IsLevelFromChapter() const {return bLevelFromChapter;}
     552                 :          4 :     void                    SetLevelFromChapter(sal_Bool bSet) {bLevelFromChapter = bSet;}
     553                 :            : 
     554                 :         58 :     sal_Bool                    IsProtected() const { return bProtected; }
     555                 :         30 :     void                    SetProtected(sal_Bool bSet) { bProtected = bSet; }
     556                 :            : 
     557                 :          6 :     const String&           GetSequenceName() const {return sSequenceName;}
     558                 :          8 :     void                    SetSequenceName(const String& rSet) {sSequenceName = rSet;}
     559                 :            : 
     560                 :          4 :     SwCaptionDisplay        GetCaptionDisplay() const { return eCaptionDisplay;}
     561                 :          8 :     void                    SetCaptionDisplay(SwCaptionDisplay eSet) {eCaptionDisplay = eSet;}
     562                 :            : 
     563                 :            :     sal_Bool                    IsTOXBaseInReadonly() const;
     564                 :            : 
     565                 :            :     const SfxItemSet*       GetAttrSet() const;
     566                 :            :     void                    SetAttrSet( const SfxItemSet& );
     567                 :            : 
     568                 :         10 :     LanguageType    GetLanguage() const {return eLanguage;}
     569                 :          6 :     void            SetLanguage(LanguageType nLang)  {eLanguage = nLang;}
     570                 :            : 
     571                 :         10 :     const String&   GetSortAlgorithm()const {return sSortAlgorithm;}
     572                 :          6 :     void            SetSortAlgorithm(const String& rSet) {sSortAlgorithm = rSet;}
     573                 :            :     // #i21237#
     574                 :            :     void AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop);
     575                 :            :     SwTOXBase&          operator=(const SwTOXBase& rSource);
     576                 :            :     void RegisterToTOXType( SwTOXType& rMark );
     577                 :            : };
     578                 :            : 
     579                 :            : 
     580                 :            : /*--------------------------------------------------------------------
     581                 :            :      Description:  Inlines
     582                 :            :  --------------------------------------------------------------------*/
     583                 :            : 
     584                 :            : //
     585                 :            : //SwTOXMark
     586                 :            : //
     587                 :        160 : inline const String& SwTOXMark::GetAlternativeText() const
     588                 :        160 :     {   return aAltText;    }
     589                 :            : 
     590                 :        146 : inline const SwTOXType* SwTOXMark::GetTOXType() const
     591                 :        146 :     { return (SwTOXType*)GetRegisteredIn(); }
     592                 :            : 
     593                 :          2 : inline sal_Bool SwTOXMark::IsAlternativeText() const
     594                 :          2 :     { return aAltText.Len() > 0; }
     595                 :            : 
     596                 :         44 : inline void SwTOXMark::SetAlternativeText(const String& rAlt)
     597                 :            : {
     598                 :         44 :     aAltText = rAlt;
     599                 :         44 : }
     600                 :            : 
     601                 :          0 : inline void SwTOXMark::SetLevel( sal_uInt16 nLvl )
     602                 :            : {
     603                 :            :     OSL_ENSURE( !GetTOXType() || GetTOXType()->GetType() != TOX_INDEX, "Falscher Feldtyp");
     604                 :          0 :     nLevel = nLvl;
     605                 :          0 : }
     606                 :            : 
     607                 :         66 : inline void SwTOXMark::SetPrimaryKey( const String& rKey )
     608                 :            : {
     609                 :            :     OSL_ENSURE( GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     610                 :         66 :     aPrimaryKey = rKey;
     611                 :         66 : }
     612                 :            : 
     613                 :          2 : inline void SwTOXMark::SetSecondaryKey( const String& rKey )
     614                 :            : {
     615                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     616                 :          2 :     aSecondaryKey = rKey;
     617                 :          2 : }
     618                 :            : 
     619                 :          0 : inline void SwTOXMark::SetTextReading( const String& rTxt )
     620                 :            : {
     621                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     622                 :          0 :     aTextReading = rTxt;
     623                 :          0 : }
     624                 :            : 
     625                 :          0 : inline void SwTOXMark::SetPrimaryKeyReading( const String& rKey )
     626                 :            : {
     627                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     628                 :          0 :     aPrimaryKeyReading = rKey;
     629                 :          0 : }
     630                 :            : 
     631                 :          0 : inline void SwTOXMark::SetSecondaryKeyReading( const String& rKey )
     632                 :            : {
     633                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     634                 :          0 :     aSecondaryKeyReading = rKey;
     635                 :          0 : }
     636                 :            : 
     637                 :          0 : inline sal_uInt16 SwTOXMark::GetLevel() const
     638                 :            : {
     639                 :            :     OSL_ENSURE( !GetTOXType() || GetTOXType()->GetType() != TOX_INDEX, "Falscher Feldtyp");
     640                 :          0 :     return nLevel;
     641                 :            : }
     642                 :            : 
     643                 :         96 : inline const String& SwTOXMark::GetPrimaryKey() const
     644                 :            : {
     645                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     646                 :         96 :     return aPrimaryKey;
     647                 :            : }
     648                 :            : 
     649                 :          4 : inline const String& SwTOXMark::GetSecondaryKey() const
     650                 :            : {
     651                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     652                 :          4 :     return aSecondaryKey;
     653                 :            : }
     654                 :            : 
     655                 :          2 : inline const String& SwTOXMark::GetTextReading() const
     656                 :            : {
     657                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     658                 :          2 :     return aTextReading;
     659                 :            : }
     660                 :            : 
     661                 :          0 : inline const String& SwTOXMark::GetPrimaryKeyReading() const
     662                 :            : {
     663                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     664                 :          0 :     return aPrimaryKeyReading;
     665                 :            : }
     666                 :            : 
     667                 :          0 : inline const String& SwTOXMark::GetSecondaryKeyReading() const
     668                 :            : {
     669                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     670                 :          0 :     return aSecondaryKeyReading;
     671                 :            : }
     672                 :            : 
     673                 :            : //
     674                 :            : //SwForm
     675                 :            : //
     676                 :        852 : inline void SwForm::SetTemplate(sal_uInt16 nLevel, const String& rTemplate)
     677                 :            : {
     678                 :            :     OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
     679                 :        852 :     aTemplate[nLevel] = rTemplate;
     680                 :        852 : }
     681                 :            : 
     682                 :        136 : inline const String& SwForm::GetTemplate(sal_uInt16 nLevel) const
     683                 :            : {
     684                 :            :     OSL_ENSURE(nLevel < GetFormMax(), "Index >= FORM_MAX");
     685                 :        136 :     return aTemplate[nLevel];
     686                 :            : }
     687                 :            : 
     688                 :          0 : inline TOXTypes SwForm::GetTOXType() const
     689                 :            : {
     690                 :          0 :     return eType;
     691                 :            : }
     692                 :            : 
     693                 :       1118 : inline sal_uInt16 SwForm::GetFormMax() const
     694                 :            : {
     695                 :       1118 :     return nFormMaxLevel;
     696                 :            : }
     697                 :            : 
     698                 :            : 
     699                 :            : //
     700                 :            : //SwTOXType
     701                 :            : //
     702                 :        188 : inline const String& SwTOXType::GetTypeName() const
     703                 :        188 :     {   return aName;   }
     704                 :            : 
     705                 :       2310 : inline TOXTypes SwTOXType::GetType() const
     706                 :       2310 :     {   return eType;   }
     707                 :            : 
     708                 :            : //
     709                 :            : // SwTOXBase
     710                 :            : //
     711                 :       1972 : inline const SwTOXType* SwTOXBase::GetTOXType() const
     712                 :       1972 :     { return (SwTOXType*)GetRegisteredIn(); }
     713                 :            : 
     714                 :       1114 : inline sal_uInt16 SwTOXBase::GetCreateType() const
     715                 :       1114 :     { return nCreateType; }
     716                 :            : 
     717                 :         60 : inline const String& SwTOXBase::GetTitle() const
     718                 :         60 :     { return aTitle; }
     719                 :            : 
     720                 :          0 : inline const String& SwTOXBase::GetTypeName() const
     721                 :          0 :     { return GetTOXType()->GetTypeName();  }
     722                 :            : 
     723                 :       1794 : inline const SwForm& SwTOXBase::GetTOXForm() const
     724                 :       1794 :     { return aForm; }
     725                 :            : 
     726                 :          0 : inline void SwTOXBase::AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop)
     727                 :            : {
     728                 :          0 :     aForm.AdjustTabStops(rDoc, bDefaultRightTabStop);
     729                 :          0 : }
     730                 :            : 
     731                 :        418 : inline void SwTOXBase::SetCreate(sal_uInt16 nCreate)
     732                 :        418 :     { nCreateType = nCreate; }
     733                 :            : 
     734                 :        264 : inline void SwTOXBase::SetTOXForm(const SwForm& rForm)
     735                 :        264 :     {  aForm = rForm; }
     736                 :            : 
     737                 :        276 : inline TOXTypes SwTOXBase::GetType() const
     738                 :        276 :     { return GetTOXType()->GetType(); }
     739                 :            : 
     740                 :         14 : inline void SwTOXBase::SetLevel(sal_uInt16 nLev)
     741                 :            : {
     742                 :            :     OSL_ENSURE(GetTOXType()->GetType() != TOX_INDEX, "Falscher Feldtyp");
     743                 :         14 :     aData.nLevel = nLev;
     744                 :         14 : }
     745                 :            : 
     746                 :          2 : inline sal_uInt16 SwTOXBase::GetLevel() const
     747                 :            : {
     748                 :            :     OSL_ENSURE(GetTOXType()->GetType() != TOX_INDEX, "Falscher Feldtyp");
     749                 :          2 :     return aData.nLevel;
     750                 :            : }
     751                 :            : 
     752                 :            : inline void SwTOXBase::SetTemplateName(const String& rName)
     753                 :            : {
     754                 :            :     OSL_FAIL("SwTOXBase::SetTemplateName obsolete");
     755                 :            :     aStyleNames[0] = rName;
     756                 :            : }
     757                 :            : 
     758                 :        334 : inline sal_uInt16 SwTOXBase::GetOptions() const
     759                 :            : {
     760                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     761                 :        334 :     return aData.nOptions;
     762                 :            : }
     763                 :            : 
     764                 :        134 : inline void SwTOXBase::SetOptions(sal_uInt16 nOpt)
     765                 :            : {
     766                 :            :     OSL_ENSURE(GetTOXType()->GetType() == TOX_INDEX, "Falscher Feldtyp");
     767                 :        134 :     aData.nOptions = nOpt;
     768                 :        134 : }
     769                 :            : 
     770                 :            : 
     771                 :            : #endif  // SW_TOX_HXX
     772                 :            : 
     773                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10