LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/editeng - flditem.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 59 69.5 %
Date: 2013-07-09 Functions: 57 79 72.2 %
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 _SVX_FLDITEM_HXX
      20             : #define _SVX_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        3514 : 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          68 :     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 int             operator==( const SvxFieldData& ) const;
      60             : 
      61             :     virtual MetaAction* createBeginComment() const;
      62             :     virtual MetaAction* createEndComment() const;
      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();
      79             : 
      80             :             SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId  );
      81             :             SvxFieldItem( const SvxFieldItem& rItem );
      82             :             ~SvxFieldItem();
      83             : 
      84             :     virtual int             operator==( const SfxPoolItem& ) const;
      85             :     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
      86             :     virtual SfxPoolItem*    Create( SvStream&, sal_uInt16 nVer ) const;
      87             :     virtual SvStream&       Store( SvStream& , sal_uInt16 nItemVersion ) const;
      88             : 
      89       59814 :     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        8644 : class EDITENG_DLLPUBLIC SvxDateField : public SvxFieldData
     111             : {
     112             :     sal_uInt32              nFixDate;
     113             :     SvxDateType             eType;
     114             :     SvxDateFormat           eFormat;
     115             : 
     116             : public:
     117         175 :     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          16 :     SvxDateType             GetType() const { return eType; }
     128           0 :     void                    SetType( SvxDateType eTp ) { eType = eTp; }
     129             : 
     130          16 :     SvxDateFormat           GetFormat() const { return eFormat; }
     131           7 :     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;
     139             :     virtual int             operator==( const SvxFieldData& ) const;
     140             : 
     141             :     virtual MetaAction* createBeginComment() const;
     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         410 : 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         138 :     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          34 :     const OUString&    GetURL() const { return aURL; }
     165           6 :     void                    SetURL( const OUString& rURL ) { aURL = rURL; }
     166             : 
     167          33 :     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           4 :     void                    SetTargetFrame( const OUString& rFrm ) { aTargetFrame = rFrm; }
     172             : 
     173          23 :     SvxURLFormat            GetFormat() const { return eFormat; }
     174           0 :     void                    SetFormat( SvxURLFormat eFmt ) { eFormat = eFmt; }
     175             : 
     176             :     virtual SvxFieldData*   Clone() const;
     177             :     virtual int             operator==( const SvxFieldData& ) const;
     178             : 
     179             :     virtual MetaAction* createBeginComment() const;
     180             : };
     181             : 
     182       12492 : class EDITENG_DLLPUBLIC SvxPageField : public SvxFieldData
     183             : {
     184             : public:
     185       37347 :     SV_DECL_PERSIST1( SvxPageField, SvxFieldData, com::sun::star::text::textfield::Type::PAGE )
     186             :     SvxPageField();
     187             : 
     188             :     virtual SvxFieldData*   Clone() const;
     189             :     virtual int             operator==( const SvxFieldData& ) const;
     190             : 
     191             :     virtual MetaAction* createBeginComment() const;
     192             : };
     193             : 
     194        5543 : class EDITENG_DLLPUBLIC SvxPagesField : public SvxFieldData
     195             : {
     196             : public:
     197        7134 :     SV_DECL_PERSIST1( SvxPagesField, SvxFieldData, com::sun::star::text::textfield::Type::PAGES )
     198             :     SvxPagesField();
     199             : 
     200             :     virtual SvxFieldData*   Clone() const;
     201             :     virtual int             operator==( const SvxFieldData& ) const;
     202             : };
     203             : 
     204        4387 : class EDITENG_DLLPUBLIC SvxTimeField : public SvxFieldData
     205             : {
     206             : public:
     207         133 :     SV_DECL_PERSIST1( SvxTimeField, SvxFieldData, com::sun::star::text::textfield::Type::TIME )
     208             :     SvxTimeField();
     209             : 
     210             :     virtual SvxFieldData*   Clone() const;
     211             :     virtual int             operator==( const SvxFieldData& ) const;
     212             : 
     213             :     virtual MetaAction* createBeginComment() const;
     214             : };
     215             : 
     216        5705 : class EDITENG_DLLPUBLIC SvxFileField : public SvxFieldData
     217             : {
     218             : public:
     219          90 :     SV_DECL_PERSIST1( SvxFileField, SvxFieldData, com::sun::star::text::textfield::Type::DOCINFO_TITLE )
     220             :     SvxFileField();
     221             : 
     222             :     virtual SvxFieldData*   Clone() const;
     223             :     virtual int             operator==( const SvxFieldData& ) const;
     224             : };
     225             : 
     226       12154 : class EDITENG_DLLPUBLIC SvxTableField : public SvxFieldData
     227             : {
     228             :     int mnTab;
     229             : public:
     230         721 :     SV_DECL_PERSIST1( SvxTableField, SvxFieldData, com::sun::star::text::textfield::Type::TABLE )
     231             :     SvxTableField();
     232             :     explicit SvxTableField(int nTab);
     233             : 
     234             :     void SetTab(int nTab);
     235             :     int GetTab() const;
     236             : 
     237             :     virtual SvxFieldData*   Clone() const;
     238             :     virtual int             operator==( const SvxFieldData& ) const;
     239             : };
     240             : 
     241             : 
     242             : enum SvxTimeType { SVXTIMETYPE_FIX, SVXTIMETYPE_VAR };
     243             : enum SvxTimeFormat {    SVXTIMEFORMAT_APPDEFAULT = 0,   // Set as in App
     244             :                         SVXTIMEFORMAT_SYSTEM,       // Set as in System
     245             :                         SVXTIMEFORMAT_STANDARD,
     246             :                         SVXTIMEFORMAT_24_HM,    // 13:49
     247             :                         SVXTIMEFORMAT_24_HMS,   // 13:49:38
     248             :                         SVXTIMEFORMAT_24_HMSH,  // 13:49:38.78
     249             :                         SVXTIMEFORMAT_12_HM,    // 01:49
     250             :                         SVXTIMEFORMAT_12_HMS,   // 01:49:38
     251             :                         SVXTIMEFORMAT_12_HMSH,  // 01:49:38.78
     252             :                         SVXTIMEFORMAT_AM_HM,    // 01:49 PM
     253             :                         SVXTIMEFORMAT_AM_HMS,   // 01:49:38 PM
     254             :                         SVXTIMEFORMAT_AM_HMSH   // 01:49:38.78 PM
     255             :                     };
     256             : 
     257        2044 : class EDITENG_DLLPUBLIC SvxExtTimeField : public SvxFieldData
     258             : {
     259             : private:
     260             :     sal_uInt32              nFixTime;
     261             :     SvxTimeType             eType;
     262             :     SvxTimeFormat           eFormat;
     263             : 
     264             : public:
     265          96 :     SV_DECL_PERSIST1( SvxExtTimeField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_TIME )
     266             :                             SvxExtTimeField();
     267             :     explicit                SvxExtTimeField( const Time& rTime,
     268             :                                 SvxTimeType eType = SVXTIMETYPE_VAR,
     269             :                                 SvxTimeFormat eFormat = SVXTIMEFORMAT_STANDARD );
     270             : 
     271           8 :     sal_uInt32              GetFixTime() const { return nFixTime; }
     272           0 :     void                    SetFixTime( const Time& rTime ) { nFixTime = rTime.GetTime(); }
     273             : 
     274           8 :     SvxTimeType             GetType() const { return eType; }
     275           0 :     void                    SetType( SvxTimeType eTp ) { eType = eTp; }
     276             : 
     277           8 :     SvxTimeFormat           GetFormat() const { return eFormat; }
     278           0 :     void                    SetFormat( SvxTimeFormat eFmt ) { eFormat = eFmt; }
     279             : 
     280             :                             // If eLanguage==LANGUAGE_DONTKNOW the language/country
     281             :                             // used in number formatter initialization is taken.
     282             :     OUString           GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLanguage ) const;
     283             :     static OUString    GetFormatted( Time& rTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
     284             : 
     285             :     virtual SvxFieldData*   Clone() const;
     286             :     virtual int             operator==( const SvxFieldData& ) const;
     287             : 
     288             :     virtual MetaAction* createBeginComment() const;
     289             : };
     290             : 
     291             : 
     292             : enum SvxFileType { SVXFILETYPE_FIX, SVXFILETYPE_VAR };
     293             : enum SvxFileFormat {    SVXFILEFORMAT_NAME_EXT = 0, // File name with Extension
     294             :                         SVXFILEFORMAT_FULLPATH, // full path
     295             :                         SVXFILEFORMAT_PATH,     // only path
     296             :                         SVXFILEFORMAT_NAME      // only file name
     297             :                    };
     298             : 
     299             : 
     300             : 
     301          22 : class EDITENG_DLLPUBLIC SvxExtFileField : public SvxFieldData
     302             : {
     303             : private:
     304             :     OUString           aFile;
     305             :     SvxFileType             eType;
     306             :     SvxFileFormat           eFormat;
     307             : 
     308             : public:
     309          68 :     SV_DECL_PERSIST1( SvxExtFileField, SvxFieldData, com::sun::star::text::textfield::Type::EXTENDED_FILE )
     310             :                             SvxExtFileField();
     311             :     explicit                SvxExtFileField( const OUString& rString,
     312             :                                 SvxFileType eType = SVXFILETYPE_VAR,
     313             :                                 SvxFileFormat eFormat = SVXFILEFORMAT_FULLPATH );
     314             : 
     315           0 :     OUString           GetFile() const { return aFile; }
     316           0 :     void                    SetFile( const OUString& rString ) { aFile = rString; }
     317             : 
     318           0 :     SvxFileType             GetType() const { return eType; }
     319           0 :     void                    SetType( SvxFileType eTp ) { eType = eTp; }
     320             : 
     321           0 :     SvxFileFormat           GetFormat() const { return eFormat; }
     322           0 :     void                    SetFormat( SvxFileFormat eFmt ) { eFormat = eFmt; }
     323             : 
     324             :     OUString           GetFormatted() const;
     325             : 
     326             :     virtual SvxFieldData*   Clone() const;
     327             :     virtual int             operator==( const SvxFieldData& ) const;
     328             : };
     329             : 
     330             : 
     331             : enum SvxAuthorType { SVXAUTHORTYPE_FIX, SVXAUTHORTYPE_VAR };
     332             : enum SvxAuthorFormat {  SVXAUTHORFORMAT_FULLNAME = 0, // full name
     333             :                         SVXAUTHORFORMAT_NAME,       // Only Last name
     334             :                         SVXAUTHORFORMAT_FIRSTNAME,  // Only first name
     335             :                         SVXAUTHORFORMAT_SHORTNAME   // Initials
     336             :                     };
     337             : 
     338           0 : class EDITENG_DLLPUBLIC SvxAuthorField : public SvxFieldData
     339             : {
     340             : private:
     341             :     OUString   aName;
     342             :     OUString   aFirstName;
     343             :     OUString   aShortName;
     344             :     SvxAuthorType   eType;
     345             :     SvxAuthorFormat eFormat;
     346             : 
     347             : public:
     348        6807 :     SV_DECL_PERSIST1( SvxAuthorField, SvxFieldData, com::sun::star::text::textfield::Type::AUTHOR )
     349             :                             SvxAuthorField();
     350             :                             SvxAuthorField(
     351             :                                 const OUString& rFirstName,
     352             :                                 const OUString& rLastName,
     353             :                                 const OUString& rShortName,
     354             :                                 SvxAuthorType eType = SVXAUTHORTYPE_VAR,
     355             :                                 SvxAuthorFormat eFormat = SVXAUTHORFORMAT_FULLNAME );
     356             : 
     357             :     OUString           GetName() const { return aName; }
     358             :     void                    SetName( const OUString& rString ) { aName = rString; }
     359             : 
     360             :     OUString           GetFirstName() const { return aFirstName; }
     361             :     void                    SetFirstName( const OUString& rString ) { aFirstName = rString; }
     362             : 
     363             :     OUString           GetShortName() const { return aShortName; }
     364             :     void                    SetShortName( const OUString& rString ) { aShortName = rString; }
     365             : 
     366           0 :     SvxAuthorType           GetType() const { return eType; }
     367           0 :     void                    SetType( SvxAuthorType eTp ) { eType = eTp; }
     368             : 
     369           0 :     SvxAuthorFormat         GetFormat() const { return eFormat; }
     370           0 :     void                    SetFormat( SvxAuthorFormat eFmt ) { eFormat = eFmt; }
     371             : 
     372             :     OUString           GetFormatted() const;
     373             : 
     374             :     virtual SvxFieldData*   Clone() const;
     375             :     virtual int             operator==( const SvxFieldData& ) const;
     376             : };
     377             : 
     378             : /** this field is used as a placeholder for a header&footer in impress. The actual
     379             :     value is stored at the page */
     380         387 : class EDITENG_DLLPUBLIC SvxHeaderField : public SvxFieldData
     381             : {
     382             : public:
     383       35964 :     SV_DECL_PERSIST1( SvxHeaderField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_HEADER )
     384             :     SvxHeaderField();
     385             : 
     386             :     virtual SvxFieldData*   Clone() const;
     387             :     virtual int             operator==( const SvxFieldData& ) const;
     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         585 : class EDITENG_DLLPUBLIC SvxFooterField : public SvxFieldData
     393             : {
     394             : public:
     395       36591 :     SV_DECL_PERSIST1( SvxFooterField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_FOOTER )
     396             :     SvxFooterField();
     397             :     virtual SvxFieldData*   Clone() const;
     398             :     virtual int             operator==( const SvxFieldData& ) const;
     399             : };
     400             : 
     401             : /** this field is used as a placeholder for a header&footer in impress. The actual
     402             :     value is stored at the page */
     403         581 : class EDITENG_DLLPUBLIC SvxDateTimeField : public SvxFieldData
     404             : {
     405             : public:
     406       36571 :     SV_DECL_PERSIST1( SvxDateTimeField, SvxFieldData, com::sun::star::text::textfield::Type::PRESENTATION_DATE_TIME )
     407             :     SvxDateTimeField();
     408             : 
     409             :     static OUString    GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage );
     410             : 
     411             :     virtual SvxFieldData*   Clone() const;
     412             :     virtual int             operator==( const SvxFieldData& ) const;
     413             : };
     414             : 
     415             : 
     416             : 
     417             : 
     418             : #endif
     419             : 
     420             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10