LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/editeng/source/items - flditem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 205 581 35.3 %
Date: 2013-07-09 Functions: 100 226 44.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             : 
      20             : #include <comphelper/string.hxx>
      21             : #include <vcl/metaact.hxx>
      22             : #include <svl/zforlist.hxx>
      23             : #include <tools/urlobj.hxx>
      24             : 
      25             : #include <unotools/localfilehelper.hxx>
      26             : 
      27             : #include <editeng/flditem.hxx>
      28             : #include <editeng/measfld.hxx>
      29             : #include "editeng/unonames.hxx"
      30             : 
      31             : #include <tools/tenccvt.hxx>
      32             : 
      33             : #include <com/sun/star/beans/XPropertySet.hpp>
      34             : #include <com/sun/star/text/XTextContent.hpp>
      35             : #include <com/sun/star/text/FilenameDisplayFormat.hpp>
      36             : #include <com/sun/star/util/DateTime.hpp>
      37             : 
      38             : using namespace com::sun::star;
      39             : 
      40          54 : SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTextContent)
      41             : {
      42          54 :     uno::Reference<beans::XPropertySet> xPropSet(xTextContent, uno::UNO_QUERY);
      43          54 :     if (!xPropSet.is())
      44           3 :         return NULL;
      45             : 
      46             :     // we do not support these fields from Writer, so make sure we do not throw
      47             :     // here - see fdo#63436 how to possibly extend Writer to make use of this
      48         102 :     uno::Any aAny;
      49             :     try {
      50          51 :         aAny = xPropSet->getPropertyValue(UNO_TC_PROP_TEXTFIELD_TYPE);
      51          51 :         if ( !aAny.has<sal_Int32>() )
      52           0 :             return NULL;
      53           0 :     } catch ( const beans::UnknownPropertyException& )
      54             :     {
      55           0 :         return NULL;
      56             :     }
      57             : 
      58          51 :     sal_Int32 nFieldType = aAny.get<sal_Int32>();
      59             : 
      60          51 :     switch (nFieldType)
      61             :     {
      62             :         case text::textfield::Type::TIME:
      63             :         case text::textfield::Type::EXTENDED_TIME:
      64             :         case text::textfield::Type::DATE:
      65             :         {
      66           6 :             sal_Bool bIsDate = false;
      67           6 :             xPropSet->getPropertyValue(UNO_TC_PROP_IS_DATE) >>= bIsDate;
      68             : 
      69           6 :             if (bIsDate)
      70             :             {
      71           6 :                 util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
      72           6 :                 Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
      73           6 :                 sal_Bool bIsFixed = false;
      74           6 :                 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
      75             : 
      76           6 :                 SvxDateField* pData = new SvxDateField(aDate, bIsFixed ? SVXDATETYPE_FIX : SVXDATETYPE_VAR);
      77           6 :                 sal_Int32 nNumFmt = -1;
      78           6 :                 xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
      79           6 :                 if (nNumFmt >= SVXDATEFORMAT_APPDEFAULT && nNumFmt <= SVXDATEFORMAT_F)
      80           6 :                     pData->SetFormat(static_cast<SvxDateFormat>(nNumFmt));
      81             : 
      82           6 :                 return pData;
      83             :             }
      84             : 
      85           0 :             if (nFieldType != text::textfield::Type::TIME && nFieldType != text::textfield::Type::DATE)
      86             :             {
      87           0 :                 util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
      88           0 :                 Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
      89             : 
      90           0 :                 sal_Bool bIsFixed = false;
      91           0 :                 xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
      92             : 
      93           0 :                 SvxExtTimeField* pData = new SvxExtTimeField(aTime, bIsFixed ? SVXTIMETYPE_FIX : SVXTIMETYPE_VAR);
      94             : 
      95           0 :                 sal_Int32 nNumFmt = -1;
      96           0 :                 xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
      97           0 :                 if (nNumFmt >= SVXTIMEFORMAT_APPDEFAULT && nNumFmt <= SVXTIMEFORMAT_AM_HMSH)
      98           0 :                     pData->SetFormat(static_cast<SvxTimeFormat>(nNumFmt));
      99             : 
     100           0 :                 return pData;
     101             :             }
     102             : 
     103           0 :             return new SvxTimeField();
     104             :         }
     105             :         case text::textfield::Type::URL:
     106             :         {
     107           0 :             OUString aRep, aTarget, aURL;
     108           0 :             sal_Int16 nFmt = -1;
     109           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_URL_REPRESENTATION) >>= aRep;
     110           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_URL_TARGET) >>= aTarget;
     111           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_URL) >>= aURL;
     112           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_URL_FORMAT) >>= nFmt;
     113           0 :             SvxURLField* pData = new SvxURLField(aURL, aRep, aRep.isEmpty() ? SVXURLFORMAT_URL : SVXURLFORMAT_REPR);
     114           0 :             pData->SetTargetFrame(aTarget);
     115           0 :             if (nFmt >= SVXURLFORMAT_APPDEFAULT && nFmt <= SVXURLFORMAT_REPR)
     116           0 :                 pData->SetFormat(static_cast<SvxURLFormat>(nFmt));
     117             : 
     118           0 :             return pData;
     119             :         }
     120             :         case text::textfield::Type::PAGE:
     121          17 :             return new SvxPageField();
     122             :         case text::textfield::Type::PAGES:
     123           0 :             return new SvxPagesField();
     124             :         case text::textfield::Type::DOCINFO_TITLE:
     125           0 :             return new SvxFileField();
     126             :         case text::textfield::Type::TABLE:
     127             :         {
     128           0 :             sal_Int32 nTab = 0;
     129           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_TABLE_POSITION) >>= nTab;
     130           0 :             return new SvxTableField(nTab);
     131             :         }
     132             :         case text::textfield::Type::EXTENDED_FILE:
     133             :         {
     134           0 :             OUString aPresentation;
     135           0 :             sal_Bool bIsFixed = false;
     136           0 :             sal_Int16 nFmt = text::FilenameDisplayFormat::FULL;
     137           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
     138           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
     139           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_FILE_FORMAT) >>= nFmt;
     140             : 
     141           0 :             SvxFileFormat eFmt = SVXFILEFORMAT_NAME_EXT;
     142           0 :             switch (nFmt)
     143             :             {
     144           0 :                 case text::FilenameDisplayFormat::FULL: eFmt = SVXFILEFORMAT_FULLPATH; break;
     145           0 :                 case text::FilenameDisplayFormat::PATH: eFmt = SVXFILEFORMAT_PATH;     break;
     146           0 :                 case text::FilenameDisplayFormat::NAME: eFmt = SVXFILEFORMAT_NAME;     break;
     147             :                 default:;
     148             :             }
     149             : 
     150             :             // pass fixed attribute to constructor
     151             :             return new SvxExtFileField(
     152           0 :                 aPresentation, bIsFixed ? SVXFILETYPE_FIX : SVXFILETYPE_VAR, eFmt);
     153             :         }
     154             :         case text::textfield::Type::AUTHOR:
     155             :         {
     156           0 :             sal_Bool bIsFixed = false;
     157           0 :             sal_Bool bFullName = false;
     158           0 :             sal_Int16 nFmt = -1;
     159           0 :             OUString aPresentation, aContent, aFirstName, aLastName;
     160           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
     161           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FULLNAME) >>= bFullName;
     162           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
     163           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_CONTENT) >>= aContent;
     164           0 :             xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FORMAT) >>= nFmt;
     165             : 
     166             :             // do we have CurrentPresentation given?  Mimic behaviour of
     167             :             // writer, which means: prefer CurrentPresentation over Content
     168             :             // if both are given.
     169           0 :             if (!aPresentation.isEmpty())
     170           0 :                 aContent = aPresentation;
     171             : 
     172           0 :             sal_Int32 nPos = aContent.lastIndexOf(sal_Unicode(' '), 0);
     173           0 :             if (nPos > 0)
     174             :             {
     175           0 :                 aFirstName = aContent.copy(0, nPos);
     176           0 :                 aLastName = aContent.copy(nPos + 1);
     177             :             }
     178             :             else
     179             :             {
     180           0 :                 aLastName = aContent;
     181             :             }
     182             : 
     183             :             // #92009# pass fixed attribute to constructor
     184             :             SvxAuthorField* pData = new SvxAuthorField(
     185           0 :                 aFirstName, aLastName, OUString(), bIsFixed ? SVXAUTHORTYPE_FIX : SVXAUTHORTYPE_VAR);
     186             : 
     187           0 :             if (!bFullName)
     188             :             {
     189           0 :                 pData->SetFormat(SVXAUTHORFORMAT_SHORTNAME);
     190             :             }
     191           0 :             else if (nFmt >= SVXAUTHORFORMAT_FULLNAME || nFmt <= SVXAUTHORFORMAT_SHORTNAME)
     192             :             {
     193           0 :                 pData->SetFormat(static_cast<SvxAuthorFormat>(nFmt));
     194             :             }
     195             : 
     196           0 :             return pData;
     197             :         }
     198             :         case text::textfield::Type::MEASURE:
     199             :         {
     200           4 :             SdrMeasureFieldKind eKind = SDRMEASUREFIELD_VALUE;
     201           4 :             sal_Int16 nTmp = -1;
     202           4 :             xPropSet->getPropertyValue(UNO_TC_PROP_MEASURE_KIND) >>= nTmp;
     203           7 :             if (nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_UNIT) ||
     204           3 :                 nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_ROTA90BLANCS))
     205           3 :                 eKind = static_cast<SdrMeasureFieldKind>(nTmp);
     206             : 
     207           4 :             return new SdrMeasureField(eKind);
     208             :         }
     209             :         case text::textfield::Type::PRESENTATION_HEADER:
     210           6 :             return new SvxHeaderField();
     211             :         case text::textfield::Type::PRESENTATION_FOOTER:
     212           9 :             return new SvxFooterField();
     213             :         case text::textfield::Type::PRESENTATION_DATE_TIME:
     214           9 :             return new SvxDateTimeField();
     215             :         default:
     216             :             ;
     217             :     };
     218             : 
     219          54 :     return NULL;
     220             : }
     221             : 
     222       74920 : TYPEINIT1( SvxFieldItem, SfxPoolItem );
     223             : 
     224         635 : SV_IMPL_PERSIST1( SvxFieldData, SvPersistBase );
     225             : 
     226             : // -----------------------------------------------------------------------
     227             : 
     228       22768 : SvxFieldData::SvxFieldData()
     229             : {
     230       22768 : }
     231             : 
     232             : // -----------------------------------------------------------------------
     233             : 
     234       26251 : SvxFieldData::~SvxFieldData()
     235             : {
     236       26251 : }
     237             : 
     238             : // -----------------------------------------------------------------------
     239             : 
     240          69 : SvxFieldData* SvxFieldData::Clone() const
     241             : {
     242          69 :     return new SvxFieldData;
     243             : }
     244             : 
     245             : // -----------------------------------------------------------------------
     246             : 
     247           0 : int SvxFieldData::operator==( const SvxFieldData& rFld ) const
     248             : {
     249             :     DBG_ASSERT( Type() == rFld.Type(), "==: Different Types" );
     250             :     (void)rFld;
     251           0 :     return sal_True;    // Basic class is always the same.
     252             : }
     253             : 
     254             : // -----------------------------------------------------------------------
     255             : 
     256           0 : void SvxFieldData::Load( SvPersistStream & /*rStm*/ )
     257             : {
     258           0 : }
     259             : 
     260             : // -----------------------------------------------------------------------
     261             : 
     262           0 : void SvxFieldData::Save( SvPersistStream & /*rStm*/ )
     263             : {
     264           0 : }
     265             : 
     266             : 
     267           0 : MetaAction* SvxFieldData::createBeginComment() const
     268             : {
     269           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
     270             : }
     271             : 
     272           0 : MetaAction* SvxFieldData::createEndComment() const
     273             : {
     274           0 :     return new MetaCommentAction( "FIELD_SEQ_END" );
     275             : }
     276             : 
     277             : // -----------------------------------------------------------------------
     278             : 
     279           0 : SvxFieldItem::SvxFieldItem( SvxFieldData* pFld, const sal_uInt16 nId ) :
     280           0 :     SfxPoolItem( nId )
     281             : {
     282           0 :     pField = pFld;  // belongs directly to the item
     283           0 : }
     284             : 
     285             : // -----------------------------------------------------------------------
     286             : 
     287        3903 : SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
     288        3903 :     SfxPoolItem( nId )
     289             : {
     290        3903 :     pField = rField.Clone();
     291        3903 : }
     292             : 
     293             : // -----------------------------------------------------------------------
     294             : 
     295       18581 : SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) :
     296       18581 :     SfxPoolItem ( rItem )
     297             : {
     298       18581 :     pField = rItem.GetField() ? rItem.GetField()->Clone() : 0;
     299       18581 : }
     300             : 
     301             : // -----------------------------------------------------------------------
     302             : 
     303       63364 : SvxFieldItem::~SvxFieldItem()
     304             : {
     305       22384 :     delete pField;
     306       40980 : }
     307             : 
     308             : // -----------------------------------------------------------------------
     309             : 
     310       18429 : SfxPoolItem* SvxFieldItem::Clone( SfxItemPool* ) const
     311             : {
     312       18429 :     return new SvxFieldItem(*this);
     313             : }
     314             : 
     315             : // -----------------------------------------------------------------------
     316             : 
     317           0 : SfxPoolItem* SvxFieldItem::Create( SvStream& rStrm, sal_uInt16 ) const
     318             : {
     319           0 :     SvxFieldData* pData = 0;
     320           0 :     SvPersistStream aPStrm( GetClassManager(), &rStrm );
     321           0 :     aPStrm >> pData;
     322             : 
     323           0 :     if( aPStrm.IsEof() )
     324           0 :         aPStrm.SetError( SVSTREAM_GENERALERROR );
     325             : 
     326           0 :     if ( aPStrm.GetError() == ERRCODE_IO_NOFACTORY )
     327           0 :         aPStrm.ResetError();    // Actually a code for that not all were read Attr ...
     328             : 
     329           0 :     return new SvxFieldItem( pData, Which() );
     330             : }
     331             : 
     332             : // -----------------------------------------------------------------------
     333             : 
     334         236 : SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
     335             : {
     336             :     DBG_ASSERT( pField, "SvxFieldItem::Store: Field?!" );
     337         236 :     SvPersistStream aPStrm( GetClassManager(), &rStrm );
     338             :     // The reset error in the above Create method did not exist in 3.1,
     339             :     // therefore newer items can not be saved for 3.x-exports!
     340         472 :     if ( ( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_31 ) && pField &&
     341         236 :             pField->GetClassId() == 50 /* SdrMeasureField */ )
     342             :     {
     343             :         // SvxFieldData not enough, because not registered on ClassMgr.
     344           0 :         SvxURLField aDummyData;
     345           0 :         aPStrm << &aDummyData;
     346             :     }
     347             :     else
     348         236 :         aPStrm << pField;
     349             : 
     350         236 :     return rStrm;
     351             : }
     352             : 
     353             : // -----------------------------------------------------------------------
     354             : 
     355       14003 : int SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
     356             : {
     357             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
     358             : 
     359       14003 :     const SvxFieldData* pOtherFld = ((const SvxFieldItem&)rItem).GetField();
     360       14003 :     if ( !pField && !pOtherFld )
     361           0 :         return sal_True;
     362             : 
     363       14003 :     if ( ( !pField && pOtherFld ) || ( pField && !pOtherFld ) )
     364           0 :         return sal_False;
     365             : 
     366       14003 :     return ( ( pField->Type() == pOtherFld->Type() )
     367       14003 :                 && ( *pField == *pOtherFld ) );
     368             : }
     369             : 
     370             : // =================================================================
     371             : // The following are the derivatives of SvxFieldData ...
     372             : // =================================================================
     373             : 
     374        3583 : SV_IMPL_PERSIST1( SvxDateField, SvxFieldData );
     375             : 
     376             : // -----------------------------------------------------------------------
     377             : 
     378          78 : SvxDateField::SvxDateField()
     379             : {
     380          78 :     nFixDate = Date( Date::SYSTEM ).GetDate();
     381          78 :     eType = SVXDATETYPE_VAR;
     382          78 :     eFormat = SVXDATEFORMAT_STDSMALL;
     383          78 : }
     384             : 
     385             : // -----------------------------------------------------------------------
     386             : 
     387         320 : SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF )
     388             : {
     389         320 :     nFixDate = rDate.GetDate();
     390         320 :     eType = eT;
     391         320 :     eFormat = eF;
     392         320 : }
     393             : 
     394             : // -----------------------------------------------------------------------
     395             : 
     396        2728 : SvxFieldData* SvxDateField::Clone() const
     397             : {
     398        2728 :     return new SvxDateField( *this );
     399             : }
     400             : 
     401             : // -----------------------------------------------------------------------
     402             : 
     403          22 : int SvxDateField::operator==( const SvxFieldData& rOther ) const
     404             : {
     405          22 :     if ( rOther.Type() != Type() )
     406           0 :         return sal_False;
     407             : 
     408          22 :     const SvxDateField& rOtherFld = (const SvxDateField&) rOther;
     409          44 :     return ( ( nFixDate == rOtherFld.nFixDate ) &&
     410          44 :                 ( eType == rOtherFld.eType ) &&
     411          44 :                 ( eFormat == rOtherFld.eFormat ) );
     412             : }
     413             : 
     414             : // -----------------------------------------------------------------------
     415             : 
     416           0 : void SvxDateField::Load( SvPersistStream & rStm )
     417             : {
     418             :     sal_uInt16 nType, nFormat;
     419             : 
     420           0 :     rStm >> nFixDate;
     421           0 :     rStm >> nType;
     422           0 :     rStm >> nFormat;
     423             : 
     424           0 :     eType = (SvxDateType)nType;
     425           0 :     eFormat= (SvxDateFormat)nFormat;
     426           0 : }
     427             : 
     428             : // -----------------------------------------------------------------------
     429             : 
     430           0 : void SvxDateField::Save( SvPersistStream & rStm )
     431             : {
     432           0 :     rStm << nFixDate;
     433           0 :     rStm << (sal_uInt16)eType;
     434           0 :     rStm << (sal_uInt16)eFormat;
     435           0 : }
     436             : 
     437             : // -----------------------------------------------------------------------
     438             : 
     439           5 : OUString SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
     440             : {
     441           5 :     Date aDate( Date::EMPTY );
     442           5 :     if ( eType == SVXDATETYPE_FIX )
     443           0 :         aDate.SetDate( nFixDate );
     444             :     else
     445           5 :         aDate = Date( Date::SYSTEM ); // current date
     446             : 
     447           5 :     return GetFormatted( aDate, eFormat, rFormatter, eLang );
     448             : }
     449             : 
     450           5 : OUString SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
     451             : {
     452           5 :     if ( eFormat == SVXDATEFORMAT_SYSTEM )
     453             :     {
     454             :         OSL_FAIL( "SVXDATEFORMAT_SYSTEM not implemented!" );
     455           0 :         eFormat = SVXDATEFORMAT_STDSMALL;
     456             :     }
     457           5 :     else if ( eFormat == SVXDATEFORMAT_APPDEFAULT )
     458             :     {
     459             :         OSL_FAIL( "SVXDATEFORMAT_APPDEFAULT: take them from where? ");
     460           0 :         eFormat = SVXDATEFORMAT_STDSMALL;
     461             :     }
     462             : 
     463             :     sal_uLong nFormatKey;
     464             : 
     465           5 :     switch( eFormat )
     466             :     {
     467             :         case SVXDATEFORMAT_STDSMALL:
     468             :             // short
     469           5 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang );
     470           5 :         break;
     471             :         case SVXDATEFORMAT_STDBIG:
     472             :             // long
     473           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang );
     474           0 :         break;
     475             :         case SVXDATEFORMAT_A:
     476             :             // 13.02.96
     477           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang );
     478           0 :         break;
     479             :         case SVXDATEFORMAT_B:
     480             :             // 13.02.1996
     481           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang );
     482           0 :         break;
     483             :         case SVXDATEFORMAT_C:
     484             :             // 13. Feb 1996
     485           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang );
     486           0 :         break;
     487             :         case SVXDATEFORMAT_D:
     488             :             // 13. February 1996
     489           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang );
     490           0 :         break;
     491             :         case SVXDATEFORMAT_E:
     492             :             // The, 13. February 1996
     493           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang );
     494           0 :         break;
     495             :         case SVXDATEFORMAT_F:
     496             :             // Tuesday, 13. February 1996
     497           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang );
     498           0 :         break;
     499             :         default:
     500           0 :             nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_DATE, eLang );
     501             :     }
     502             : 
     503           5 :     double fDiffDate = aDate - *(rFormatter.GetNullDate());
     504           5 :     OUString aStr;
     505           5 :        Color* pColor = NULL;
     506           5 :     rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
     507           5 :     return aStr;
     508             : }
     509             : 
     510           0 : MetaAction* SvxDateField::createBeginComment() const
     511             : {
     512           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
     513             : }
     514             : 
     515        3740 : SV_IMPL_PERSIST1( SvxURLField, SvxFieldData );
     516             : 
     517             : // -----------------------------------------------------------------------
     518             : 
     519           0 : SvxURLField::SvxURLField()
     520             : {
     521           0 :     eFormat = SVXURLFORMAT_URL;
     522           0 : }
     523             : 
     524             : // -----------------------------------------------------------------------
     525             : 
     526          17 : SvxURLField::SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt )
     527          17 :     : aURL( rURL ), aRepresentation( rRepres )
     528             : {
     529          17 :     eFormat = eFmt;
     530          17 : }
     531             : 
     532             : // -----------------------------------------------------------------------
     533             : 
     534         128 : SvxFieldData* SvxURLField::Clone() const
     535             : {
     536         128 :     return new SvxURLField( *this );
     537             : }
     538             : 
     539             : // -----------------------------------------------------------------------
     540             : 
     541         912 : int SvxURLField::operator==( const SvxFieldData& rOther ) const
     542             : {
     543         912 :     if ( rOther.Type() != Type() )
     544           0 :         return sal_False;
     545             : 
     546         912 :     const SvxURLField& rOtherFld = (const SvxURLField&) rOther;
     547        1824 :     return ( ( eFormat == rOtherFld.eFormat ) &&
     548        1158 :                 ( aURL == rOtherFld.aURL ) &&
     549        1320 :                 ( aRepresentation == rOtherFld.aRepresentation ) &&
     550        1074 :                 ( aTargetFrame == rOtherFld.aTargetFrame ) );
     551             : }
     552             : 
     553             : // -----------------------------------------------------------------------
     554             : 
     555           0 : static void write_unicode( SvPersistStream & rStm, const OUString& rString )
     556             : {
     557           0 :     sal_uInt16 nL =  sal::static_int_cast<sal_uInt16>(rString.getLength());
     558           0 :     rStm << nL;
     559             :     //endian specific?, yipes!
     560           0 :     rStm.Write( rString.getStr(), nL*sizeof(sal_Unicode) );
     561           0 : }
     562             : 
     563           0 : static OUString read_unicode( SvPersistStream & rStm )
     564             : {
     565           0 :     rtl_uString *pStr = NULL;
     566           0 :     sal_uInt16 nL = 0;
     567           0 :     rStm >> nL;
     568           0 :     if ( nL )
     569             :     {
     570           0 :         pStr = rtl_uString_alloc(nL);
     571             :         //endian specific?, yipes!
     572           0 :         rStm.Read(pStr->buffer, nL*sizeof(sal_Unicode));
     573             :     }
     574             :     //take ownership of buffer and return, otherwise return empty string
     575           0 :     return pStr ? OUString(pStr, SAL_NO_ACQUIRE) : OUString();
     576             : }
     577             : 
     578           0 : void SvxURLField::Load( SvPersistStream & rStm )
     579             : {
     580           0 :     sal_uInt16 nFormat = 0;
     581             : 
     582           0 :     rStm >> nFormat;
     583           0 :     eFormat= (SvxURLFormat)nFormat;
     584             : 
     585           0 :     aURL = read_unicode( rStm );
     586           0 :     aRepresentation = read_unicode( rStm );
     587           0 :     aTargetFrame = read_unicode( rStm );
     588           0 : }
     589             : 
     590             : // -----------------------------------------------------------------------
     591             : 
     592           0 : void SvxURLField::Save( SvPersistStream & rStm )
     593             : {
     594           0 :     rStm << (sal_uInt16)eFormat;
     595             : 
     596           0 :     write_unicode( rStm, aURL );
     597           0 :     write_unicode( rStm, aRepresentation );
     598           0 :     write_unicode( rStm, aTargetFrame );
     599           0 : }
     600             : 
     601           0 : MetaAction* SvxURLField::createBeginComment() const
     602             : {
     603             :     // #i46618# Adding target URL to metafile comment
     604             :     return new MetaCommentAction( "FIELD_SEQ_BEGIN",
     605             :                                   0,
     606           0 :                                   reinterpret_cast<const sal_uInt8*>(aURL.getStr()),
     607           0 :                                   2*aURL.getLength() );
     608             : }
     609             : 
     610             : // =================================================================
     611             : // The fields that were removed from Calc:
     612             : // =================================================================
     613             : 
     614        8423 : SV_IMPL_PERSIST1( SvxPageField, SvxFieldData );
     615             : 
     616        6597 : SvxPageField::SvxPageField() {}
     617             : 
     618        5655 : SvxFieldData* SvxPageField::Clone() const
     619             : {
     620        5655 :     return new SvxPageField;        // empty
     621             : }
     622             : 
     623         564 : int SvxPageField::operator==( const SvxFieldData& rCmp ) const
     624             : {
     625         564 :     return ( rCmp.Type() == TYPE(SvxPageField) );
     626             : }
     627             : 
     628           0 : void SvxPageField::Load( SvPersistStream & /*rStm*/ )
     629             : {
     630           0 : }
     631             : 
     632         112 : void SvxPageField::Save( SvPersistStream & /*rStm*/ )
     633             : {
     634         112 : }
     635             : 
     636           0 : MetaAction* SvxPageField::createBeginComment() const
     637             : {
     638           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
     639             : }
     640             : 
     641             : 
     642        3455 : SV_IMPL_PERSIST1( SvxPagesField, SvxFieldData );
     643             : 
     644        2939 : SvxPagesField::SvxPagesField() {}
     645             : 
     646        2551 : SvxFieldData* SvxPagesField::Clone() const
     647             : {
     648        2551 :     return new SvxPagesField;   // empty
     649             : }
     650             : 
     651          18 : int SvxPagesField::operator==( const SvxFieldData& rCmp ) const
     652             : {
     653          18 :     return ( rCmp.Type() == TYPE(SvxPagesField) );
     654             : }
     655             : 
     656           0 : void SvxPagesField::Load( SvPersistStream & /*rStm*/ )
     657             : {
     658           0 : }
     659             : 
     660           0 : void SvxPagesField::Save( SvPersistStream & /*rStm*/ )
     661             : {
     662           0 : }
     663             : 
     664        2730 : SV_IMPL_PERSIST1( SvxTimeField, SvxFieldData );
     665             : 
     666        2354 : SvxTimeField::SvxTimeField() {}
     667             : 
     668        2038 : SvxFieldData* SvxTimeField::Clone() const
     669             : {
     670        2038 :     return new SvxTimeField;    // empty
     671             : }
     672             : 
     673           8 : int SvxTimeField::operator==( const SvxFieldData& rCmp ) const
     674             : {
     675           8 :     return ( rCmp.Type() == TYPE(SvxTimeField) );
     676             : }
     677             : 
     678           0 : void SvxTimeField::Load( SvPersistStream & /*rStm*/ )
     679             : {
     680           0 : }
     681             : 
     682           0 : void SvxTimeField::Save( SvPersistStream & /*rStm*/ )
     683             : {
     684           0 : }
     685             : 
     686           0 : MetaAction* SvxTimeField::createBeginComment() const
     687             : {
     688           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
     689             : }
     690             : 
     691        3583 : SV_IMPL_PERSIST1( SvxFileField, SvxFieldData );
     692             : 
     693        3020 : SvxFileField::SvxFileField() {}
     694             : 
     695        2630 : SvxFieldData* SvxFileField::Clone() const
     696             : {
     697        2630 :     return new SvxFileField;    // empty
     698             : }
     699             : 
     700          20 : int SvxFileField::operator==( const SvxFieldData& rCmp ) const
     701             : {
     702          20 :     return ( rCmp.Type() == TYPE(SvxFileField) );
     703             : }
     704             : 
     705           0 : void SvxFileField::Load( SvPersistStream & /*rStm*/ )
     706             : {
     707           0 : }
     708             : 
     709           0 : void SvxFileField::Save( SvPersistStream & /*rStm*/ )
     710             : {
     711           0 : }
     712             : 
     713        6769 : SV_IMPL_PERSIST1( SvxTableField, SvxFieldData );
     714             : 
     715         821 : SvxTableField::SvxTableField() : mnTab(0) {}
     716             : 
     717        5598 : SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
     718             : 
     719           0 : void SvxTableField::SetTab(int nTab)
     720             : {
     721           0 :     mnTab = nTab;
     722           0 : }
     723             : 
     724           0 : int SvxTableField::GetTab() const
     725             : {
     726           0 :     return mnTab;
     727             : }
     728             : 
     729        5596 : SvxFieldData* SvxTableField::Clone() const
     730             : {
     731        5596 :     return new SvxTableField(mnTab);
     732             : }
     733             : 
     734         465 : int SvxTableField::operator==( const SvxFieldData& rCmp ) const
     735             : {
     736         465 :     if (rCmp.Type() != TYPE(SvxTableField))
     737           0 :         return false;
     738             : 
     739         465 :     return mnTab == static_cast<const SvxTableField&>(rCmp).mnTab;
     740             : }
     741             : 
     742           0 : void SvxTableField::Load( SvPersistStream & /*rStm*/ )
     743             : {
     744           0 : }
     745             : 
     746         124 : void SvxTableField::Save( SvPersistStream & /*rStm*/ )
     747             : {
     748         124 : }
     749             : 
     750             : //----------------------------------------------------------------------------
     751             : //      SvxExtTimeField
     752             : //----------------------------------------------------------------------------
     753             : 
     754         803 : SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData );
     755             : 
     756             : //----------------------------------------------------------------------------
     757             : 
     758          75 : SvxExtTimeField::SvxExtTimeField()
     759             : {
     760          75 :     nFixTime = Time( Time::SYSTEM ).GetTime();
     761          75 :     eType = SVXTIMETYPE_VAR;
     762          75 :     eFormat = SVXTIMEFORMAT_STANDARD;
     763          75 : }
     764             : 
     765             : //----------------------------------------------------------------------------
     766             : 
     767           0 : SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF )
     768             : {
     769           0 :     nFixTime = rTime.GetTime();
     770           0 :     eType = eT;
     771           0 :     eFormat = eF;
     772           0 : }
     773             : 
     774             : //----------------------------------------------------------------------------
     775             : 
     776         636 : SvxFieldData* SvxExtTimeField::Clone() const
     777             : {
     778         636 :     return new SvxExtTimeField( *this );
     779             : }
     780             : 
     781             : //----------------------------------------------------------------------------
     782             : 
     783          10 : int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
     784             : {
     785          10 :     if ( rOther.Type() != Type() )
     786           0 :         return sal_False;
     787             : 
     788          10 :     const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther;
     789          20 :     return ( ( nFixTime == rOtherFld.nFixTime ) &&
     790          20 :                 ( eType == rOtherFld.eType ) &&
     791          20 :                 ( eFormat == rOtherFld.eFormat ) );
     792             : }
     793             : 
     794             : //----------------------------------------------------------------------------
     795             : 
     796           0 : void SvxExtTimeField::Load( SvPersistStream & rStm )
     797             : {
     798             :     sal_uInt16 nType, nFormat;
     799             : 
     800           0 :     rStm >> nFixTime;
     801           0 :     rStm >> nType;
     802           0 :     rStm >> nFormat;
     803             : 
     804           0 :     eType = (SvxTimeType) nType;
     805           0 :     eFormat= (SvxTimeFormat) nFormat;
     806           0 : }
     807             : 
     808             : //----------------------------------------------------------------------------
     809             : 
     810           0 : void SvxExtTimeField::Save( SvPersistStream & rStm )
     811             : {
     812           0 :     rStm << nFixTime;
     813           0 :     rStm << (sal_uInt16) eType;
     814           0 :     rStm << (sal_uInt16) eFormat;
     815           0 : }
     816             : 
     817             : //----------------------------------------------------------------------------
     818             : 
     819           0 : OUString SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
     820             : {
     821           0 :     Time aTime( Time::EMPTY );
     822           0 :     if ( eType == SVXTIMETYPE_FIX )
     823           0 :         aTime.SetTime( nFixTime );
     824             :     else
     825           0 :         aTime = Time( Time::SYSTEM ); // current time
     826           0 :     return GetFormatted( aTime, eFormat, rFormatter, eLang );
     827             : }
     828             : 
     829           0 : OUString SvxExtTimeField::GetFormatted( Time& aTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
     830             : {
     831           0 :     switch( eFormat )
     832             :     {
     833             :         case SVXTIMEFORMAT_SYSTEM :
     834             :             OSL_FAIL( "SVXTIMEFORMAT_SYSTEM: not implemented" );
     835           0 :             eFormat = SVXTIMEFORMAT_STANDARD;
     836           0 :         break;
     837             :         case SVXTIMEFORMAT_APPDEFAULT :
     838             :             OSL_FAIL( "SVXTIMEFORMAT_APPDEFAULT: not implemented" );
     839           0 :             eFormat = SVXTIMEFORMAT_STANDARD;
     840           0 :         break;
     841             :         default: ;//prevent warning
     842             :     }
     843             : 
     844             :     sal_uInt32 nFormatKey;
     845             : 
     846           0 :     switch( eFormat )
     847             :     {
     848             :         case SVXTIMEFORMAT_12_HM:
     849           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMAMPM, eLang );
     850           0 :             break;
     851             :         case SVXTIMEFORMAT_12_HMSH:
     852             :         {
     853             :             // no builtin format available, try to insert or reuse
     854           0 :             OUString aFormatCode( "HH:MM:SS.00 AM/PM" );
     855             :             sal_Int32 nCheckPos;
     856             :             short nType;
     857             :             rFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType,
     858           0 :                                            nFormatKey, LANGUAGE_ENGLISH_US, eLang );
     859             :             DBG_ASSERT( nCheckPos == 0, "SVXTIMEFORMAT_12_HMSH: could not insert format code" );
     860           0 :             if ( nCheckPos )
     861             :             {
     862           0 :                 nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
     863             :             }
     864           0 :             break;
     865             :         }
     866             :         case SVXTIMEFORMAT_24_HM:
     867           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMM, eLang );
     868           0 :             break;
     869             :         case SVXTIMEFORMAT_24_HMSH:
     870           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang );
     871           0 :             break;
     872             :         case SVXTIMEFORMAT_12_HMS:
     873           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSSAMPM, eLang );
     874           0 :             break;
     875             :         case SVXTIMEFORMAT_24_HMS:
     876           0 :             nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSS, eLang );
     877           0 :             break;
     878             :         case SVXTIMEFORMAT_STANDARD:
     879             :         default:
     880           0 :             nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_TIME, eLang );
     881             :     }
     882             : 
     883           0 :     double fFracTime = aTime.GetTimeInDays();
     884           0 :     OUString aStr;
     885           0 :     Color* pColor = NULL;
     886           0 :     rFormatter.GetOutputString( fFracTime, nFormatKey, aStr, &pColor );
     887           0 :     return aStr;
     888             : }
     889             : 
     890           0 : MetaAction* SvxExtTimeField::createBeginComment() const
     891             : {
     892           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
     893             : }
     894             : 
     895             : //----------------------------------------------------------------------------
     896             : //      SvxExtFileField
     897             : //----------------------------------------------------------------------------
     898             : 
     899           1 : SV_IMPL_PERSIST1( SvxExtFileField, SvxFieldData );
     900             : 
     901             : //----------------------------------------------------------------------------
     902             : 
     903           0 : SvxExtFileField::SvxExtFileField()
     904             : {
     905           0 :     eType = SVXFILETYPE_VAR;
     906           0 :     eFormat = SVXFILEFORMAT_FULLPATH;
     907           0 : }
     908             : 
     909             : //----------------------------------------------------------------------------
     910             : 
     911           1 : SvxExtFileField::SvxExtFileField( const OUString& rStr, SvxFileType eT, SvxFileFormat eF )
     912             : {
     913           1 :     aFile = rStr;
     914           1 :     eType = eT;
     915           1 :     eFormat = eF;
     916           1 : }
     917             : 
     918             : //----------------------------------------------------------------------------
     919             : 
     920           7 : SvxFieldData* SvxExtFileField::Clone() const
     921             : {
     922           7 :     return new SvxExtFileField( *this );
     923             : }
     924             : 
     925             : //----------------------------------------------------------------------------
     926             : 
     927           0 : int SvxExtFileField::operator==( const SvxFieldData& rOther ) const
     928             : {
     929           0 :     if ( rOther.Type() != Type() )
     930           0 :         return sal_False;
     931             : 
     932           0 :     const SvxExtFileField& rOtherFld = (const SvxExtFileField&) rOther;
     933           0 :     return ( ( aFile == rOtherFld.aFile ) &&
     934           0 :                 ( eType == rOtherFld.eType ) &&
     935           0 :                 ( eFormat == rOtherFld.eFormat ) );
     936             : }
     937             : 
     938             : //----------------------------------------------------------------------------
     939             : 
     940           0 : void SvxExtFileField::Load( SvPersistStream & rStm )
     941             : {
     942             :     sal_uInt16 nType, nFormat;
     943             : 
     944             :     // UNICODE: rStm >> aFile;
     945           0 :     aFile = rStm.ReadUniOrByteString(rStm.GetStreamCharSet());
     946             : 
     947           0 :     rStm >> nType;
     948           0 :     rStm >> nFormat;
     949             : 
     950           0 :     eType = (SvxFileType) nType;
     951           0 :     eFormat= (SvxFileFormat) nFormat;
     952           0 : }
     953             : 
     954             : //----------------------------------------------------------------------------
     955             : 
     956           0 : void SvxExtFileField::Save( SvPersistStream & rStm )
     957             : {
     958             :     // UNICODE: rStm << aFile;
     959           0 :     rStm.WriteUniOrByteString(aFile, rStm.GetStreamCharSet());
     960             : 
     961           0 :     rStm << (sal_uInt16) eType;
     962           0 :     rStm << (sal_uInt16) eFormat;
     963           0 : }
     964             : 
     965             : //----------------------------------------------------------------------------
     966             : 
     967           0 : OUString SvxExtFileField::GetFormatted() const
     968             : {
     969           0 :     OUString aString;
     970             : 
     971           0 :     INetURLObject aURLObj( aFile );
     972             : 
     973           0 :     if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
     974             :     {
     975             :         // invalid? try to interpret string as system file name
     976           0 :         OUString aURLStr;
     977             : 
     978           0 :         ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aURLStr );
     979             : 
     980           0 :         aURLObj.SetURL( aURLStr );
     981             :     }
     982             : 
     983             :     // #92009# Be somewhat liberate when trying to
     984             :     // get formatted content out of the FileField
     985           0 :     if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() )
     986             :     {
     987             :         // still not valid? Then output as is
     988           0 :         aString = aFile;
     989             :     }
     990           0 :     else if( INET_PROT_FILE == aURLObj.GetProtocol() )
     991             :     {
     992           0 :         switch( eFormat )
     993             :         {
     994             :             case SVXFILEFORMAT_FULLPATH:
     995           0 :                 aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
     996           0 :             break;
     997             : 
     998             :             case SVXFILEFORMAT_PATH:
     999           0 :                 aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
    1000             :                 // #101742# Leave trailing slash at the pathname
    1001           0 :                 aURLObj.setFinalSlash();
    1002           0 :                 aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT);
    1003           0 :             break;
    1004             : 
    1005             :             case SVXFILEFORMAT_NAME:
    1006           0 :                 aString = aURLObj.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
    1007           0 :             break;
    1008             : 
    1009             :             case SVXFILEFORMAT_NAME_EXT:
    1010           0 :                 aString = aURLObj.getName(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS);
    1011           0 :             break;
    1012             :         }
    1013             :     }
    1014             :     else
    1015             :     {
    1016           0 :         switch( eFormat )
    1017             :         {
    1018             :             case SVXFILEFORMAT_FULLPATH:
    1019           0 :                 aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
    1020           0 :             break;
    1021             : 
    1022             :             case SVXFILEFORMAT_PATH:
    1023           0 :                 aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false);
    1024             :                 // #101742# Leave trailing slash at the pathname
    1025           0 :                 aURLObj.setFinalSlash();
    1026           0 :                 aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
    1027           0 :             break;
    1028             : 
    1029             :             case SVXFILEFORMAT_NAME:
    1030           0 :                 aString = aURLObj.getBase();
    1031           0 :             break;
    1032             : 
    1033             :             case SVXFILEFORMAT_NAME_EXT:
    1034           0 :                 aString = aURLObj.getName();
    1035           0 :             break;
    1036             :         }
    1037             :     }
    1038             : 
    1039           0 :     return aString;
    1040             : }
    1041             : 
    1042             : //----------------------------------------------------------------------------
    1043             : //      SvxAuthorField
    1044             : //----------------------------------------------------------------------------
    1045             : 
    1046           0 : SV_IMPL_PERSIST1( SvxAuthorField, SvxFieldData );
    1047             : 
    1048             : //----------------------------------------------------------------------------
    1049             : 
    1050           0 : SvxAuthorField::SvxAuthorField()
    1051             : {
    1052           0 :     eType = SVXAUTHORTYPE_VAR;
    1053           0 :     eFormat = SVXAUTHORFORMAT_FULLNAME;
    1054           0 : }
    1055             : 
    1056             : //----------------------------------------------------------------------------
    1057             : 
    1058           0 : SvxAuthorField::SvxAuthorField( const OUString& rFirstName,
    1059             :                                 const OUString& rLastName,
    1060             :                                 const OUString& rShortName,
    1061           0 :                                     SvxAuthorType eT, SvxAuthorFormat eF )
    1062             : {
    1063           0 :     aName      = rLastName;
    1064           0 :     aFirstName = rFirstName;
    1065           0 :     aShortName = rShortName;
    1066           0 :     eType   = eT;
    1067           0 :     eFormat = eF;
    1068           0 : }
    1069             : 
    1070             : //----------------------------------------------------------------------------
    1071             : 
    1072           0 : SvxFieldData* SvxAuthorField::Clone() const
    1073             : {
    1074           0 :     return new SvxAuthorField( *this );
    1075             : }
    1076             : 
    1077             : //----------------------------------------------------------------------------
    1078             : 
    1079           0 : int SvxAuthorField::operator==( const SvxFieldData& rOther ) const
    1080             : {
    1081           0 :     if ( rOther.Type() != Type() )
    1082           0 :         return sal_False;
    1083             : 
    1084           0 :     const SvxAuthorField& rOtherFld = (const SvxAuthorField&) rOther;
    1085           0 :     return ( ( aName == rOtherFld.aName ) &&
    1086           0 :                 ( aFirstName == rOtherFld.aFirstName ) &&
    1087           0 :                 ( aShortName == rOtherFld.aShortName ) &&
    1088           0 :                 ( eType == rOtherFld.eType ) &&
    1089           0 :                 ( eFormat == rOtherFld.eFormat ) );
    1090             : }
    1091             : 
    1092             : //----------------------------------------------------------------------------
    1093             : 
    1094           0 : void SvxAuthorField::Load( SvPersistStream & rStm )
    1095             : {
    1096           0 :     sal_uInt16 nType = 0, nFormat = 0;
    1097             : 
    1098           0 :     aName = read_unicode( rStm );
    1099           0 :     aFirstName = read_unicode( rStm );
    1100           0 :     aShortName = read_unicode( rStm );
    1101             : 
    1102           0 :     rStm >> nType;
    1103           0 :     rStm >> nFormat;
    1104             : 
    1105           0 :     eType = (SvxAuthorType) nType;
    1106           0 :     eFormat= (SvxAuthorFormat) nFormat;
    1107           0 : }
    1108             : 
    1109             : //----------------------------------------------------------------------------
    1110             : 
    1111           0 : void SvxAuthorField::Save( SvPersistStream & rStm )
    1112             : {
    1113           0 :     write_unicode( rStm, aName );
    1114           0 :     write_unicode( rStm, aFirstName );
    1115           0 :     write_unicode( rStm, aShortName );
    1116             : 
    1117           0 :     rStm << (sal_uInt16) eType;
    1118           0 :     rStm << (sal_uInt16) eFormat;
    1119           0 : }
    1120             : 
    1121             : //----------------------------------------------------------------------------
    1122             : 
    1123           0 : OUString SvxAuthorField::GetFormatted() const
    1124             : {
    1125           0 :     OUString aString;
    1126             : 
    1127           0 :     switch( eFormat )
    1128             :     {
    1129             :         case SVXAUTHORFORMAT_FULLNAME:
    1130             :         {
    1131           0 :             OUStringBuffer aBuf(aFirstName);
    1132           0 :             aBuf.append(sal_Unicode(' '));
    1133           0 :             aBuf.append(aName);
    1134           0 :             aString = aBuf.makeStringAndClear();
    1135             :         }
    1136           0 :         break;
    1137             :         case SVXAUTHORFORMAT_NAME:
    1138           0 :             aString = aName;
    1139           0 :         break;
    1140             : 
    1141             :         case SVXAUTHORFORMAT_FIRSTNAME:
    1142           0 :             aString = aFirstName;
    1143           0 :         break;
    1144             : 
    1145             :         case SVXAUTHORFORMAT_SHORTNAME:
    1146           0 :             aString = aShortName;
    1147           0 :         break;
    1148             :     }
    1149             : 
    1150           0 :     return aString;
    1151             : }
    1152             : 
    1153             : static SvClassManager* pClassMgr=0;
    1154             : 
    1155         539 : SvClassManager& SvxFieldItem::GetClassManager()
    1156             : {
    1157         539 :     if ( !pClassMgr )
    1158             :     {
    1159          68 :         pClassMgr = new SvClassManager;
    1160          68 :         pClassMgr->Register(SvxFieldData::StaticClassId(),    SvxFieldData::CreateInstance);
    1161          68 :         pClassMgr->Register(SvxURLField::StaticClassId(),     SvxURLField::CreateInstance);
    1162          68 :         pClassMgr->Register(SvxDateField::StaticClassId(),    SvxDateField::CreateInstance);
    1163          68 :         pClassMgr->Register(SvxPageField::StaticClassId(),    SvxPageField::CreateInstance);
    1164          68 :         pClassMgr->Register(SvxTimeField::StaticClassId(),    SvxTimeField::CreateInstance);
    1165          68 :         pClassMgr->Register(SvxExtTimeField::StaticClassId(), SvxExtTimeField::CreateInstance);
    1166          68 :         pClassMgr->Register(SvxExtFileField::StaticClassId(), SvxExtFileField::CreateInstance);
    1167          68 :         pClassMgr->Register(SvxAuthorField::StaticClassId(),  SvxAuthorField::CreateInstance);
    1168             :     }
    1169             : 
    1170         539 :     return *pClassMgr;
    1171             : }
    1172             : 
    1173             : ///////////////////////////////////////////////////////////////////////
    1174             : 
    1175         950 : SV_IMPL_PERSIST1( SvxHeaderField, SvxFieldData );
    1176             : 
    1177         200 : SvxHeaderField::SvxHeaderField() {}
    1178             : 
    1179         129 : SvxFieldData* SvxHeaderField::Clone() const
    1180             : {
    1181         129 :     return new SvxHeaderField;      // empty
    1182             : }
    1183             : 
    1184          42 : int SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
    1185             : {
    1186          42 :     return ( rCmp.Type() == TYPE(SvxHeaderField) );
    1187             : }
    1188             : 
    1189           0 : void SvxHeaderField::Load( SvPersistStream & /*rStm*/ )
    1190             : {
    1191           0 : }
    1192             : 
    1193           0 : void SvxHeaderField::Save( SvPersistStream & /*rStm*/ )
    1194             : {
    1195           0 : }
    1196             : 
    1197             : ///////////////////////////////////////////////////////////////////////
    1198             : 
    1199        2070 : SV_IMPL_PERSIST1( SvxFooterField, SvxFieldData );
    1200         302 : SvxFooterField::SvxFooterField() {}
    1201             : 
    1202         191 : SvxFieldData* SvxFooterField::Clone() const
    1203             : {
    1204         191 :     return new SvxFooterField;      // empty
    1205             : }
    1206             : 
    1207          82 : int SvxFooterField::operator==( const SvxFieldData& rCmp ) const
    1208             : {
    1209          82 :     return ( rCmp.Type() == TYPE(SvxFooterField) );
    1210             : }
    1211             : 
    1212           0 : void SvxFooterField::Load( SvPersistStream & /*rStm*/ )
    1213             : {
    1214           0 : }
    1215             : 
    1216           0 : void SvxFooterField::Save( SvPersistStream & /*rStm*/ )
    1217             : {
    1218           0 : }
    1219             : 
    1220             : ///////////////////////////////////////////////////////////////////////
    1221             : 
    1222        2480 : SV_IMPL_PERSIST1( SvxDateTimeField, SvxFieldData );
    1223             : 
    1224         190 : SvxFieldData* SvxDateTimeField::Clone() const
    1225             : {
    1226         190 :     return new SvxDateTimeField;        // empty
    1227             : }
    1228             : 
    1229          81 : int SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const
    1230             : {
    1231          81 :     return ( rCmp.Type() == TYPE(SvxDateTimeField) );
    1232             : }
    1233             : 
    1234           0 : void SvxDateTimeField::Load( SvPersistStream & /*rStm*/ )
    1235             : {
    1236           0 : }
    1237             : 
    1238           0 : void SvxDateTimeField::Save( SvPersistStream & /*rStm*/ )
    1239             : {
    1240           0 : }
    1241             : 
    1242         300 : SvxDateTimeField::SvxDateTimeField() {}
    1243             : 
    1244           0 : OUString SvxDateTimeField::GetFormatted(
    1245             :     Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage )
    1246             : {
    1247           0 :     OUString aRet;
    1248             : 
    1249           0 :     SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f);
    1250             : 
    1251           0 :     if(eDateFormat)
    1252             :     {
    1253           0 :         aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage );
    1254             :     }
    1255             : 
    1256           0 :     SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f);
    1257             : 
    1258           0 :     if(eTimeFormat)
    1259             :     {
    1260           0 :         OUStringBuffer aBuf(aRet);
    1261             : 
    1262           0 :         if (!aRet.isEmpty())
    1263           0 :             aBuf.append(sal_Unicode(' '));
    1264             : 
    1265             :         aBuf.append(
    1266           0 :             SvxExtTimeField::GetFormatted(rTime, eTimeFormat, rFormatter, eLanguage));
    1267             : 
    1268           0 :         aRet = aBuf.makeStringAndClear();
    1269             :     }
    1270             : 
    1271           0 :     return aRet;
    1272         267 : }
    1273             : 
    1274             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10