LCOV - code coverage report
Current view: top level - include/editeng - flditem.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 44 62 71.0 %
Date: 2015-06-13 12:38:46 Functions: 60 83 72.3 %
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             : #ifndef INCLUDED_EDITENG_FLDITEM_HXX
      20             : #define INCLUDED_EDITENG_FLDITEM_HXX
      21             : 
      22             : #include <i18nlangtag/lang.h>
      23             : #include <tools/time.hxx>
      24             : #include <tools/date.hxx>
      25             : #include <svl/poolitem.hxx>
      26             : #include <tools/pstm.hxx>
      27             : #include <editeng/editengdllapi.h>
      28             : 
      29             : #include <com/sun/star/text/textfield/Type.hpp>
      30             : 
      31             : #include <boost/noncopyable.hpp>
      32             : 
      33             : namespace com { namespace sun { namespace star { namespace text {
      34             : 
      35             : class XTextContent;
      36             : 
      37             : }}}}
      38             : 
      39             : class SvNumberFormatter;
      40             : class MetaAction;
      41             : 
      42             : // class SvxFieldItem ---------------------------------------------------
      43             : 
      44             : 
      45             : 
      46        7583 : class EDITENG_DLLPUBLIC SvxFieldData : public SvPersistBase
      47             : {
      48             : public:
      49             :     static const sal_Int32 UNKNOWN_FIELD;
      50             : 
      51             :     static SvxFieldData* Create(const com::sun::star::uno::Reference<com::sun::star::text::XTextContent>& xContent);
      52             : 
      53         114 :     SV_DECL_PERSIST1( SvxFieldData, SvPersistBase, com::sun::star::text::textfield::Type::UNSPECIFIED)
      54             : 
      55             :                             SvxFieldData();
      56             :     virtual                 ~SvxFieldData();
      57             : 
      58             :     virtual SvxFieldData*   Clone() const;
      59             :     virtual bool            operator==( const SvxFieldData& ) const;
      60             : 
      61             :     virtual MetaAction*     createBeginComment() const;
      62             :     static MetaAction*      createEndComment();
      63             : };
      64             : 
      65             : /**
      66             :  * This item stores a field (SvxFieldData).  The field is controlled by or
      67             :  * belongs to the item.  The field itself is determined by a derivation from
      68             :  * SvxFieldData (RTTI)
      69             :  */
      70             : class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem
      71             : {
      72             : private:
      73             :     SvxFieldData*           pField;
      74             : 
      75             :                     EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId );
      76             : 
      77             : public:
      78             :             TYPEINFO_OVERRIDE();
      79             : 
      80             :             SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId  );
      81             :             SvxFieldItem( const SvxFieldItem& rItem );
      82             :             virtual ~SvxFieldItem();
      83             : 
      84             :     virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
      85             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
      86             :     virtual SfxPoolItem*    Create( SvStream&, sal_uInt16 nVer ) const SAL_OVERRIDE;
      87             :     virtual SvStream&       Store( SvStream& , sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
      88             : 
      89      154850 :     const SvxFieldData*     GetField() const    { return pField; }
      90             :     static SvClassManager&  GetClassManager();
      91             : };
      92             : 
      93             : 
      94             : // The following are the derivatives of SvxFieldData ...
      95             : 
      96             : 
      97             : enum SvxDateType { SVXDATETYPE_FIX, SVXDATETYPE_VAR };
      98             : enum SvxDateFormat {    SVXDATEFORMAT_APPDEFAULT = 0,   // Set as in App
      99             :                         SVXDATEFORMAT_SYSTEM,       // Set as in System
     100             :                         SVXDATEFORMAT_STDSMALL,
     101             :                         SVXDATEFORMAT_STDBIG,
     102             :                         SVXDATEFORMAT_A,    // 13.02.96
     103             :                         SVXDATEFORMAT_B,    // 13.02.1996
     104             :                         SVXDATEFORMAT_C,    // 13.Feb 1996
     105             :                         SVXDATEFORMAT_D,    // 13.February 1996
     106             :                         SVXDATEFORMAT_E,    // Tue, 13.February 1996
     107             :                         SVXDATEFORMAT_F     // Tuesday, 13.February 1996
     108             :                     };
     109             : 
     110       17445 : class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
     111             : {
     112             :     sal_uInt32              nFixDate;
     113             :     SvxDateType             eType;
     114             :     SvxDateFormat           eFormat;
     115             : 
     116             : public:
     117         589 :     SV_DECL_PERSIST1( SvxDateField, SvxFieldData, com::sun::star::text::textfield::Type::DATE )
     118             : 
     119             :                             SvxDateField();
     120             :     explicit                SvxDateField( const Date& rDate,
     121             :                                 SvxDateType eType = SVXDATETYPE_VAR,
     122             :                                 SvxDateFormat eFormat = SVXDATEFORMAT_STDSMALL );
     123             : 
     124           0 :     sal_uInt32              GetFixDate() const { return nFixDate; }
     125           0 :     void                    SetFixDate( const Date& rDate ) { nFixDate = rDate.GetDate(); }
     126             : 
     127          86 :     SvxDateType             GetType() const { return eType; }
     128           0 :     void                    SetType( SvxDateType eTp ) { eType = eTp; }
     129             : 
     130          86 :     SvxDateFormat           GetFormat() const { return eFormat; }
     131          45 :     void                    SetFormat( SvxDateFormat eFmt ) { eFormat = eFmt; }
     132             : 
     133             :                             // If eLanguage==LANGUAGE_DONTKNOW the language/country
     134             :                             // used in number formatter initialization is taken.
     135             :     OUString           GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
     136             :     static OUString    GetFormatted( Date& rDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
     137             : 
     138             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     139             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     140             : 
     141             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     142             : };
     143             : 
     144             : 
     145             : enum SvxURLFormat   {   SVXURLFORMAT_APPDEFAULT = 0,    // Set as in App
     146             :                         SVXURLFORMAT_URL,           // Represent URL
     147             :                         SVXURLFORMAT_REPR           // Constitute repraesentation
     148             :                     };
     149             : 
     150         545 : class EDITENG_DLLPUBLIC SvxURLField : public SvxFieldData
     151             : {
     152             : private:
     153             :     SvxURLFormat            eFormat;
     154             :     OUString           aURL;               // URL-Address
     155             :     OUString           aRepresentation;    // What is shown
     156             :     OUString           aTargetFrame;       // In what Frame
     157             : 
     158             : public:
     159         224 :     SV_DECL_PERSIST1( SvxURLField, SvxFieldData, com::sun::star::text::textfield::Type::URL )
     160             : 
     161             :                             SvxURLField();
     162             :                             SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt = SVXURLFORMAT_URL );
     163             : 
     164          63 :     const OUString&    GetURL() const { return aURL; }
     165           9 :     void                    SetURL( const OUString& rURL ) { aURL = rURL; }
     166             : 
     167          60 :     const OUString&    GetRepresentation() const { return aRepresentation; }
     168           6 :     void                    SetRepresentation( const OUString& rRep ) { aRepresentation= rRep; }
     169             : 
     170           9 :     const OUString&    GetTargetFrame() const { return aTargetFrame; }
     171           6 :     void                    SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; }
     172             : 
     173          47 :     SvxURLFormat            GetFormat() const { return eFormat; }
     174           2 :     void                    SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
     175             : 
     176             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     177             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     178             : 
     179             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     180             : };
     181             : 
     182       26241 : class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData
     183             : {
     184             : public:
     185      121038 :     SV_DECL_PERSIST1( SvxPageField, SvxFieldData, com::sun::star::text::textfield::Type::PAGE )
     186             :     SvxPageField();
     187             : 
     188             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     189             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     190             : 
     191             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     192             : };
     193             : 
     194           0 : class EDITENG_DLLPUBLIC SvxPageTitleField : public SvxFieldData
     195             : {
     196             : public:
     197         114 :     SV_DECL_PERSIST1( SvxPageTitleField, SvxFieldData, com::sun::star::text::textfield::Type::PAGE_NAME )
     198             :     SvxPageTitleField();
     199             : 
     200             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     201             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     202             : 
     203             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     204             : };
     205             : 
     206       10547 : class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData
     207             : {
     208             : public:
     209       17485 :     SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, com::sun::star::text::textfield::Type::PAGES )
     210             :     SvxPagesField();
     211             : 
     212             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     213             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     214             : };
     215             : 
     216        8201 : class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData
     217             : {
     218             : public:
     219         186 :     SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, com::sun::star::text::textfield::Type::TIME )
     220             :     SvxTimeField();
     221             : 
     222             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     223             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     224             : 
     225             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     226             : };
     227             : 
     228       10897 : class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData
     229             : {
     230             : public:
     231         276 :     SV_DECL_PERSIST1( SvxFileField, SvxFieldData, com::sun::star::text::textfield::Type::DOCINFO_TITLE )
     232             :     SvxFileField();
     233             : 
     234             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     235             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     236             : };
     237             : 
     238       22873 : class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
     239             : {
     240             :     int mnTab;
     241             : public:
     242        1392 :     SV_DECL_PERSIST1( SvxTableField, SvxFieldData, com::sun::star::text::textfield::Type::TABLE )
     243             :     SvxTableField();
     244             :     explicit SvxTableField(int nTab);
     245             : 
     246             :     void SetTab(int nTab);
     247           2 :     int GetTab() const { return mnTab;}
     248             : 
     249             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     250             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     251             : };
     252             : 
     253             : 
     254             : enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR };
     255             : enum SvxTimeFormat {    SVXTIMEFORMAT_APPDEFAULT = 0,   // Set as in App
     256             :                         SVXTIMEFORMAT_SYSTEM,       // Set as in System
     257             :                         SVXTIMEFORMAT_STANDARD,
     258             :                         SVXTIMEFORMAT_24_HM,    // 13:49
     259             :                         SVXTIMEFORMAT_24_HMS,   // 13:49:38
     260             :                         SVXTIMEFORMAT_24_HMSH,  // 13:49:38.78
     261             :                         SVXTIMEFORMAT_12_HM,    // 01:49
     262             :                         SVXTIMEFORMAT_12_HMS,   // 01:49:38
     263             :                         SVXTIMEFORMAT_12_HMSH,  // 01:49:38.78
     264             :                         SVXTIMEFORMAT_AM_HM,    // 01:49 PM
     265             :                         SVXTIMEFORMAT_AM_HMS,   // 01:49:38 PM
     266             :                         SVXTIMEFORMAT_AM_HMSH   // 01:49:38.78 PM
     267             :                     };
     268             : 
     269        4150 : class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
     270             : {
     271             : private:
     272             :     sal_Int64               m_nFixTime;
     273             :     SvxTimeType             eType;
     274             :     SvxTimeFormat           eFormat;
     275             : 
     276             : public:
     277         282 :     SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_TIME )
     278             :                             SvxExtTimeField();
     279             :     explicit                SvxExtTimeField( const tools::Time& rTime,
     280             :                                 SvxTimeType eType = SVXTIMETYPE_VAR,
     281             :                                 SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
     282             : 
     283          48 :     sal_Int64               GetFixTime() const { return m_nFixTime; }
     284           0 :     void SetFixTime( const tools::Time& rTime ) { m_nFixTime = rTime.GetTime(); }
     285             : 
     286          48 :     SvxTimeType             GetType() const { return eType; }
     287           0 :     void                    SetType( SvxTimeType eTp ) { eType = eTp; }
     288             : 
     289          48 :     SvxTimeFormat           GetFormat() const { return eFormat; }
     290           0 :     void                    SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
     291             : 
     292             :                             // If eLanguage==LANGUAGE_DONTKNOW the language/country
     293             :                             // used in number formatter initialization is taken.
     294             :     OUString           GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
     295             :     static OUString    GetFormatted( tools::Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
     296             : 
     297             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     298             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     299             : 
     300             :     virtual MetaAction* createBeginComment() const SAL_OVERRIDE;
     301             : };
     302             : 
     303             : 
     304             : enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR };
     305             : enum SvxFileFormat {    SVXFILEFORMAT_NAME_EXT = 0, // File name with Extension
     306             :                         SVXFILEFORMAT_FULLPATH, // full path
     307             :                         SVXFILEFORMAT_PATH,     // only path
     308             :                         SVXFILEFORMAT_NAME      // only file name
     309             :                    };
     310             : 
     311             : 
     312             : 
     313          22 : class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
     314             : {
     315             : private:
     316             :     OUString           aFile;
     317             :     SvxFileType             eType;
     318             :     SvxFileFormat           eFormat;
     319             : 
     320             : public:
     321         114 :     SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_FILE )
     322             :                             SvxExtFileField();
     323             :     explicit                SvxExtFileField( const OUString& rString,
     324             :                                 SvxFileType eType = SVXFILETYPE_VAR,
     325             :                                 SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
     326             : 
     327           0 :     OUString           GetFile() const { return aFile; }
     328           0 :     void                    SetFile( const OUString& rString ) { aFile = rString; }
     329             : 
     330           0 :     SvxFileType             GetType() const { return eType; }
     331           0 :     void                    SetType( SvxFileType eTp ) { eType = eTp; }
     332             : 
     333           0 :     SvxFileFormat           GetFormat() const { return eFormat; }
     334           0 :     void                    SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
     335             : 
     336             :     OUString           GetFormatted() const;
     337             : 
     338             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     339             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     340             : };
     341             : 
     342             : 
     343             : enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
     344             : enum SvxAuthorFormat {  SVXAUTHORFORMAT_FULLNAME = 0, // full name
     345             :                         SVXAUTHORFORMAT_NAME,       // Only Last name
     346             :                         SVXAUTHORFORMAT_FIRSTNAME,  // Only first name
     347             :                         SVXAUTHORFORMAT_SHORTNAME   // Initials
     348             :                     };
     349             : 
     350           0 : class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
     351             : {
     352             : private:
     353             :     OUString   aName;
     354             :     OUString   aFirstName;
     355             :     OUString   aShortName;
     356             :     SvxAuthorType   eType;
     357             :     SvxAuthorFormat eFormat;
     358             : 
     359             : public:
     360       16224 :     SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, com::sun::star::text::textfield::Type::AUTHOR )
     361             :                             SvxAuthorField();
     362             :                             SvxAuthorField(
     363             :                                 const OUString& rFirstName,
     364             :                                 const OUString& rLastName,
     365             :                                 const OUString& rShortName,
     366             :                                 SvxAuthorType eType = SVXAUTHORTYPE_VAR,
     367             :                                 SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
     368             : 
     369             :     OUString           GetName() const { return aName; }
     370             :     void                    SetName( const OUString& rString ) { aName = rString; }
     371             : 
     372             :     OUString           GetFirstName() const { return aFirstName; }
     373             :     void                    SetFirstName( const OUString& rString ) { aFirstName = rString; }
     374             : 
     375             :     OUString           GetShortName() const { return aShortName; }
     376             :     void                    SetShortName( const OUString& rString ) { aShortName = rString; }
     377             : 
     378           0 :     SvxAuthorType           GetType() const { return eType; }
     379           0 :     void                    SetType( SvxAuthorType eTp ) { eType = eTp; }
     380             : 
     381           0 :     SvxAuthorFormat         GetFormat() const { return eFormat; }
     382           0 :     void                    SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
     383             : 
     384             :     OUString           GetFormatted() const;
     385             : 
     386             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     387             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     388             : };
     389             : 
     390             : /** this field is used as a placeholder for a header&footer in impress. The actual
     391             :     value is stored at the page */
     392        2379 : class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData
     393             : {
     394             : public:
     395      115935 :     SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_HEADER )
     396             :     SvxHeaderField();
     397             : 
     398             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     399             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     400             : };
     401             : 
     402             : /** this field is used as a placeholder for a header&footer in impress. The actual
     403             :     value is stored at the page */
     404        3587 : class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData
     405             : {
     406             : public:
     407      119479 :     SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_FOOTER )
     408             :     SvxFooterField();
     409             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     410             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     411             : };
     412             : 
     413             : /** this field is used as a placeholder for a header&footer in impress. The actual
     414             :     value is stored at the page */
     415        3583 : class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData
     416             : {
     417             : public:
     418      119459 :     SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_DATE_TIME )
     419             :     SvxDateTimeField();
     420             : 
     421             :     static OUString    GetFormatted( Date& rDate, tools::Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
     422             : 
     423             :     virtual SvxFieldData*   Clone() const SAL_OVERRIDE;
     424             :     virtual bool            operator==( const SvxFieldData& ) const SAL_OVERRIDE;
     425             : };
     426             : 
     427             : 
     428             : 
     429             : 
     430             : #endif
     431             : 
     432             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11