LCOV - code coverage report
Current view: top level - editeng/source/items - flditem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 224 577 38.8 %
Date: 2014-04-11 Functions: 106 224 47.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      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         176 : SvxFieldData* SvxFieldData::Create(const uno::Reference<text::XTextContent>& xTextContent)
      41             : {
      42         176 :     uno::Reference<beans::XPropertySet> xPropSet(xTextContent, uno::UNO_QUERY);
      43         176 :     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         346 :     uno::Any aAny;
      49             :     try {
      50         173 :         aAny = xPropSet->getPropertyValue(UNO_TC_PROP_TEXTFIELD_TYPE);
      51         173 :         if ( !aAny.has<sal_Int32>() )
      52           0 :             return NULL;
      53             : 
      54         173 :         sal_Int32 nFieldType = aAny.get<sal_Int32>();
      55             : 
      56         173 :         switch (nFieldType)
      57             :         {
      58             :             case text::textfield::Type::TIME:
      59             :             case text::textfield::Type::EXTENDED_TIME:
      60             :             case text::textfield::Type::DATE:
      61             :                 {
      62          18 :                     sal_Bool bIsDate = false;
      63          18 :                     xPropSet->getPropertyValue(UNO_TC_PROP_IS_DATE) >>= bIsDate;
      64             : 
      65          18 :                     if (bIsDate)
      66             :                     {
      67          18 :                         util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
      68          18 :                         Date aDate(aDateTime.Day, aDateTime.Month, aDateTime.Year);
      69          18 :                         sal_Bool bIsFixed = false;
      70          18 :                         xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
      71             : 
      72          18 :                         SvxDateField* pData = new SvxDateField(aDate, bIsFixed ? SVXDATETYPE_FIX : SVXDATETYPE_VAR);
      73          18 :                         sal_Int32 nNumFmt = -1;
      74          18 :                         xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
      75          18 :                         if (nNumFmt >= SVXDATEFORMAT_APPDEFAULT && nNumFmt <= SVXDATEFORMAT_F)
      76          18 :                             pData->SetFormat(static_cast<SvxDateFormat>(nNumFmt));
      77             : 
      78          18 :                         return pData;
      79             :                     }
      80             : 
      81           0 :                     if (nFieldType != text::textfield::Type::TIME)
      82             :                     {
      83           0 :                         util::DateTime aDateTime = xPropSet->getPropertyValue(UNO_TC_PROP_DATE_TIME).get<util::DateTime>();
      84           0 :                         Time aTime(aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds, aDateTime.NanoSeconds);
      85             : 
      86           0 :                         sal_Bool bIsFixed = false;
      87           0 :                         xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
      88             : 
      89           0 :                         SvxExtTimeField* pData = new SvxExtTimeField(aTime, bIsFixed ? SVXTIMETYPE_FIX : SVXTIMETYPE_VAR);
      90             : 
      91           0 :                         sal_Int32 nNumFmt = -1;
      92           0 :                         xPropSet->getPropertyValue(UNO_TC_PROP_NUMFORMAT) >>= nNumFmt;
      93           0 :                         if (nNumFmt >= SVXTIMEFORMAT_APPDEFAULT && nNumFmt <= SVXTIMEFORMAT_AM_HMSH)
      94           0 :                             pData->SetFormat(static_cast<SvxTimeFormat>(nNumFmt));
      95             : 
      96           0 :                         return pData;
      97             :                     }
      98             : 
      99           0 :                     return new SvxTimeField();
     100             :                 }
     101             :             case text::textfield::Type::URL:
     102             :                 {
     103           2 :                     OUString aRep, aTarget, aURL;
     104           1 :                     sal_Int16 nFmt = -1;
     105           1 :                     xPropSet->getPropertyValue(UNO_TC_PROP_URL_REPRESENTATION) >>= aRep;
     106           1 :                     xPropSet->getPropertyValue(UNO_TC_PROP_URL_TARGET) >>= aTarget;
     107           1 :                     xPropSet->getPropertyValue(UNO_TC_PROP_URL) >>= aURL;
     108           1 :                     xPropSet->getPropertyValue(UNO_TC_PROP_URL_FORMAT) >>= nFmt;
     109           1 :                     SvxURLField* pData = new SvxURLField(aURL, aRep, aRep.isEmpty() ? SVXURLFORMAT_URL : SVXURLFORMAT_REPR);
     110           1 :                     pData->SetTargetFrame(aTarget);
     111           1 :                     if (nFmt >= SVXURLFORMAT_APPDEFAULT && nFmt <= SVXURLFORMAT_REPR)
     112           1 :                         pData->SetFormat(static_cast<SvxURLFormat>(nFmt));
     113             : 
     114           2 :                     return pData;
     115             :                 }
     116             :             case text::textfield::Type::PAGE:
     117          58 :                 return new SvxPageField();
     118             :             case text::textfield::Type::PAGES:
     119           0 :                 return new SvxPagesField();
     120             :             case text::textfield::Type::DOCINFO_TITLE:
     121           0 :                 return new SvxFileField();
     122             :             case text::textfield::Type::TABLE:
     123             :                 {
     124           0 :                     sal_Int32 nTab = 0;
     125           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_TABLE_POSITION) >>= nTab;
     126           0 :                     return new SvxTableField(nTab);
     127             :                 }
     128             :             case text::textfield::Type::EXTENDED_FILE:
     129             :                 {
     130           0 :                     OUString aPresentation;
     131           0 :                     sal_Bool bIsFixed = false;
     132           0 :                     sal_Int16 nFmt = text::FilenameDisplayFormat::FULL;
     133           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
     134           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
     135           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_FILE_FORMAT) >>= nFmt;
     136             : 
     137           0 :                     SvxFileFormat eFmt = SVXFILEFORMAT_NAME_EXT;
     138           0 :                     switch (nFmt)
     139             :                     {
     140           0 :                         case text::FilenameDisplayFormat::FULL: eFmt = SVXFILEFORMAT_FULLPATH; break;
     141           0 :                         case text::FilenameDisplayFormat::PATH: eFmt = SVXFILEFORMAT_PATH;     break;
     142           0 :                         case text::FilenameDisplayFormat::NAME: eFmt = SVXFILEFORMAT_NAME;     break;
     143             :                         default:;
     144             :                     }
     145             : 
     146             :                     // pass fixed attribute to constructor
     147             :                     return new SvxExtFileField(
     148           0 :                             aPresentation, bIsFixed ? SVXFILETYPE_FIX : SVXFILETYPE_VAR, eFmt);
     149             :                 }
     150             :             case text::textfield::Type::AUTHOR:
     151             :                 {
     152           0 :                     sal_Bool bIsFixed = false;
     153           0 :                     sal_Bool bFullName = false;
     154           0 :                     sal_Int16 nFmt = -1;
     155           0 :                     OUString aPresentation, aContent, aFirstName, aLastName;
     156           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_IS_FIXED) >>= bIsFixed;
     157           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FULLNAME) >>= bFullName;
     158           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_CURRENT_PRESENTATION) >>= aPresentation;
     159           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_CONTENT) >>= aContent;
     160           0 :                     xPropSet->getPropertyValue(UNO_TC_PROP_AUTHOR_FORMAT) >>= nFmt;
     161             : 
     162             :                     // do we have CurrentPresentation given?  Mimic behaviour of
     163             :                     // writer, which means: prefer CurrentPresentation over Content
     164             :                     // if both are given.
     165           0 :                     if (!aPresentation.isEmpty())
     166           0 :                         aContent = aPresentation;
     167             : 
     168           0 :                     sal_Int32 nPos = aContent.lastIndexOf(' ', 0);
     169           0 :                     if (nPos > 0)
     170             :                     {
     171           0 :                         aFirstName = aContent.copy(0, nPos);
     172           0 :                         aLastName = aContent.copy(nPos + 1);
     173             :                     }
     174             :                     else
     175             :                     {
     176           0 :                         aLastName = aContent;
     177             :                     }
     178             : 
     179             :                     // #92009# pass fixed attribute to constructor
     180             :                     SvxAuthorField* pData = new SvxAuthorField(
     181           0 :                             aFirstName, aLastName, OUString(), bIsFixed ? SVXAUTHORTYPE_FIX : SVXAUTHORTYPE_VAR);
     182             : 
     183           0 :                     if (!bFullName)
     184             :                     {
     185           0 :                         pData->SetFormat(SVXAUTHORFORMAT_SHORTNAME);
     186             :                     }
     187           0 :                     else if (nFmt >= SVXAUTHORFORMAT_FULLNAME || nFmt <= SVXAUTHORFORMAT_SHORTNAME)
     188             :                     {
     189           0 :                         pData->SetFormat(static_cast<SvxAuthorFormat>(nFmt));
     190             :                     }
     191             : 
     192           0 :                     return pData;
     193             :                 }
     194             :             case text::textfield::Type::MEASURE:
     195             :                 {
     196           4 :                     SdrMeasureFieldKind eKind = SDRMEASUREFIELD_VALUE;
     197           4 :                     sal_Int16 nTmp = -1;
     198           4 :                     xPropSet->getPropertyValue(UNO_TC_PROP_MEASURE_KIND) >>= nTmp;
     199           7 :                     if (nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_UNIT) ||
     200           3 :                             nTmp == static_cast<sal_Int16>(SDRMEASUREFIELD_ROTA90BLANCS))
     201           3 :                         eKind = static_cast<SdrMeasureFieldKind>(nTmp);
     202             : 
     203           4 :                     return new SdrMeasureField(eKind);
     204             :                 }
     205             :             case text::textfield::Type::PRESENTATION_HEADER:
     206          24 :                 return new SvxHeaderField();
     207             :             case text::textfield::Type::PRESENTATION_FOOTER:
     208          34 :                 return new SvxFooterField();
     209             :             case text::textfield::Type::PRESENTATION_DATE_TIME:
     210          34 :                 return new SvxDateTimeField();
     211             :             default:
     212             :                 ;
     213             :         };
     214           0 :     } catch ( const beans::UnknownPropertyException& )
     215             :     {
     216           0 :         return NULL;
     217             :     }
     218             : 
     219         176 :     return NULL;
     220             : }
     221             : 
     222      102801 : TYPEINIT1( SvxFieldItem, SfxPoolItem );
     223             : 
     224         959 : SV_IMPL_PERSIST1( SvxFieldData, SvPersistBase );
     225             : 
     226             : 
     227             : 
     228       30611 : SvxFieldData::SvxFieldData()
     229             : {
     230       30611 : }
     231             : 
     232             : 
     233             : 
     234       35383 : SvxFieldData::~SvxFieldData()
     235             : {
     236       35383 : }
     237             : 
     238             : 
     239             : 
     240          76 : SvxFieldData* SvxFieldData::Clone() const
     241             : {
     242          76 :     return new SvxFieldData;
     243             : }
     244             : 
     245             : 
     246             : 
     247          11 : bool SvxFieldData::operator==( const SvxFieldData& rFld ) const
     248             : {
     249             :     DBG_ASSERT( Type() == rFld.Type(), "==: Different Types" );
     250             :     (void)rFld;
     251          11 :     return 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        5614 : SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) :
     288        5614 :     SfxPoolItem( nId )
     289             : {
     290        5614 :     pField = rField.Clone();
     291        5614 : }
     292             : 
     293             : 
     294             : 
     295       24507 : SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) :
     296       24507 :     SfxPoolItem ( rItem )
     297             : {
     298       24507 :     pField = rItem.GetField() ? rItem.GetField()->Clone() : 0;
     299       24507 : }
     300             : 
     301             : 
     302             : 
     303       84521 : SvxFieldItem::~SvxFieldItem()
     304             : {
     305       30002 :     delete pField;
     306       54519 : }
     307             : 
     308             : 
     309             : 
     310       24339 : SfxPoolItem* SvxFieldItem::Clone( SfxItemPool* ) const
     311             : {
     312       24339 :     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         294 : SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
     335             : {
     336             :     DBG_ASSERT( pField, "SvxFieldItem::Store: Field?!" );
     337         294 :     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         588 :     if ( ( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_31 ) && pField &&
     341         294 :             pField->GetClassId() == 50 /* SdrMeasureField */ )
     342             :     {
     343             :         // SvxFieldData not enough, because not registered on ClassMgr.
     344           0 :         SvxURLField aDummyData;
     345           0 :         WriteSvPersistBase( aPStrm , &aDummyData );
     346             :     }
     347             :     else
     348         294 :         WriteSvPersistBase( aPStrm, pField );
     349             : 
     350         294 :     return rStrm;
     351             : }
     352             : 
     353             : 
     354             : 
     355       19495 : bool SvxFieldItem::operator==( const SfxPoolItem& rItem ) const
     356             : {
     357             :     DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
     358             : 
     359       19495 :     const SvxFieldData* pOtherFld = ((const SvxFieldItem&)rItem).GetField();
     360       19495 :     if ( !pField && !pOtherFld )
     361           0 :         return true;
     362             : 
     363       19495 :     if ( ( !pField && pOtherFld ) || ( pField && !pOtherFld ) )
     364           0 :         return false;
     365             : 
     366       19495 :     return ( ( pField->Type() == pOtherFld->Type() )
     367       19495 :                 && ( *pField == *pOtherFld ) );
     368             : }
     369             : 
     370             : 
     371             : // The following are the derivatives of SvxFieldData ...
     372             : 
     373             : 
     374        5019 : SV_IMPL_PERSIST1( SvxDateField, SvxFieldData );
     375             : 
     376             : 
     377             : 
     378         116 : SvxDateField::SvxDateField()
     379             : {
     380         116 :     nFixDate = Date( Date::SYSTEM ).GetDate();
     381         116 :     eType = SVXDATETYPE_VAR;
     382         116 :     eFormat = SVXDATEFORMAT_STDSMALL;
     383         116 : }
     384             : 
     385             : 
     386             : 
     387         406 : SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF )
     388             : {
     389         406 :     nFixDate = rDate.GetDate();
     390         406 :     eType = eT;
     391         406 :     eFormat = eF;
     392         406 : }
     393             : 
     394             : 
     395             : 
     396        3661 : SvxFieldData* SvxDateField::Clone() const
     397             : {
     398        3661 :     return new SvxDateField( *this );
     399             : }
     400             : 
     401             : 
     402             : 
     403          43 : bool SvxDateField::operator==( const SvxFieldData& rOther ) const
     404             : {
     405          43 :     if ( rOther.Type() != Type() )
     406           0 :         return false;
     407             : 
     408          43 :     const SvxDateField& rOtherFld = (const SvxDateField&) rOther;
     409          86 :     return ( ( nFixDate == rOtherFld.nFixDate ) &&
     410          86 :                 ( eType == rOtherFld.eType ) &&
     411          86 :                 ( eFormat == rOtherFld.eFormat ) );
     412             : }
     413             : 
     414             : 
     415             : 
     416           0 : void SvxDateField::Load( SvPersistStream & rStm )
     417             : {
     418             :     sal_uInt16 nType, nFormat;
     419             : 
     420           0 :     rStm.ReadUInt32( nFixDate );
     421           0 :     rStm.ReadUInt16( nType );
     422           0 :     rStm.ReadUInt16( nFormat );
     423             : 
     424           0 :     eType = (SvxDateType)nType;
     425           0 :     eFormat= (SvxDateFormat)nFormat;
     426           0 : }
     427             : 
     428             : 
     429             : 
     430           4 : void SvxDateField::Save( SvPersistStream & rStm )
     431             : {
     432           4 :     rStm.WriteUInt32( nFixDate );
     433           4 :     rStm.WriteUInt16( (sal_uInt16)eType );
     434           4 :     rStm.WriteUInt16( (sal_uInt16)eFormat );
     435           4 : }
     436             : 
     437             : 
     438             : 
     439          13 : OUString SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const
     440             : {
     441          13 :     Date aDate( Date::EMPTY );
     442          13 :     if ( eType == SVXDATETYPE_FIX )
     443           0 :         aDate.SetDate( nFixDate );
     444             :     else
     445          13 :         aDate = Date( Date::SYSTEM ); // current date
     446             : 
     447          13 :     return GetFormatted( aDate, eFormat, rFormatter, eLang );
     448             : }
     449             : 
     450          13 : OUString SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang )
     451             : {
     452          13 :     if ( eFormat == SVXDATEFORMAT_SYSTEM )
     453             :     {
     454             :         OSL_FAIL( "SVXDATEFORMAT_SYSTEM not implemented!" );
     455           0 :         eFormat = SVXDATEFORMAT_STDSMALL;
     456             :     }
     457          13 :     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          13 :     switch( eFormat )
     466             :     {
     467             :         case SVXDATEFORMAT_STDSMALL:
     468             :             // short
     469          13 :             nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang );
     470          13 :         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          13 :     double fDiffDate = aDate - *(rFormatter.GetNullDate());
     504          13 :     OUString aStr;
     505          13 :     Color* pColor = NULL;
     506          13 :     rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor );
     507          13 :     return aStr;
     508             : }
     509             : 
     510           0 : MetaAction* SvxDateField::createBeginComment() const
     511             : {
     512           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
     513             : }
     514             : 
     515        3833 : SV_IMPL_PERSIST1( SvxURLField, SvxFieldData );
     516             : 
     517             : 
     518             : 
     519           0 : SvxURLField::SvxURLField()
     520             : {
     521           0 :     eFormat = SVXURLFORMAT_URL;
     522           0 : }
     523             : 
     524             : 
     525             : 
     526          21 : SvxURLField::SvxURLField( const OUString& rURL, const OUString& rRepres, SvxURLFormat eFmt )
     527          21 :     : aURL( rURL ), aRepresentation( rRepres )
     528             : {
     529          21 :     eFormat = eFmt;
     530          21 : }
     531             : 
     532             : 
     533             : 
     534         141 : SvxFieldData* SvxURLField::Clone() const
     535             : {
     536         141 :     return new SvxURLField( *this );
     537             : }
     538             : 
     539             : 
     540             : 
     541         924 : bool SvxURLField::operator==( const SvxFieldData& rOther ) const
     542             : {
     543         924 :     if ( rOther.Type() != Type() )
     544           0 :         return false;
     545             : 
     546         924 :     const SvxURLField& rOtherFld = (const SvxURLField&) rOther;
     547        1848 :     return ( ( eFormat == rOtherFld.eFormat ) &&
     548        1173 :                 ( aURL == rOtherFld.aURL ) &&
     549        1338 :                 ( aRepresentation == rOtherFld.aRepresentation ) &&
     550        1089 :                 ( 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.WriteUInt16( 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.ReadUInt16( 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.ReadUInt16( 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.WriteUInt16( (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       12763 : SV_IMPL_PERSIST1( SvxPageField, SvxFieldData );
     615             : 
     616        8943 : SvxPageField::SvxPageField() {}
     617             : 
     618        7597 : SvxFieldData* SvxPageField::Clone() const
     619             : {
     620        7597 :     return new SvxPageField;        // empty
     621             : }
     622             : 
     623         846 : bool SvxPageField::operator==( const SvxFieldData& rCmp ) const
     624             : {
     625         846 :     return ( rCmp.Type() == TYPE(SvxPageField) );
     626             : }
     627             : 
     628           0 : void SvxPageField::Load( SvPersistStream & /*rStm*/ )
     629             : {
     630           0 : }
     631             : 
     632         130 : void SvxPageField::Save( SvPersistStream & /*rStm*/ )
     633             : {
     634         130 : }
     635             : 
     636           0 : MetaAction* SvxPageField::createBeginComment() const
     637             : {
     638           0 :     return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
     639             : }
     640             : 
     641             : 
     642        4710 : SV_IMPL_PERSIST1( SvxPagesField, SvxFieldData );
     643             : 
     644        3835 : SvxPagesField::SvxPagesField() {}
     645             : 
     646        3341 : SvxFieldData* SvxPagesField::Clone() const
     647             : {
     648        3341 :     return new SvxPagesField;   // empty
     649             : }
     650             : 
     651          38 : bool SvxPagesField::operator==( const SvxFieldData& rCmp ) const
     652             : {
     653          38 :     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        3284 : SV_IMPL_PERSIST1( SvxTimeField, SvxFieldData );
     665             : 
     666        2863 : SvxTimeField::SvxTimeField() {}
     667             : 
     668        2473 : SvxFieldData* SvxTimeField::Clone() const
     669             : {
     670        2473 :     return new SvxTimeField;    // empty
     671             : }
     672             : 
     673           6 : bool SvxTimeField::operator==( const SvxFieldData& rCmp ) const
     674             : {
     675           6 :     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        4915 : SV_IMPL_PERSIST1( SvxFileField, SvxFieldData );
     692             : 
     693        3950 : SvxFileField::SvxFileField() {}
     694             : 
     695        3454 : SvxFieldData* SvxFileField::Clone() const
     696             : {
     697        3454 :     return new SvxFileField;    // empty
     698             : }
     699             : 
     700          41 : bool SvxFileField::operator==( const SvxFieldData& rCmp ) const
     701             : {
     702          41 :     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        9028 : SV_IMPL_PERSIST1( SvxTableField, SvxFieldData );
     714             : 
     715        1051 : SvxTableField::SvxTableField() : mnTab(0) {}
     716             : 
     717        7375 : SvxTableField::SvxTableField(int nTab) : mnTab(nTab) {}
     718             : 
     719           0 : void SvxTableField::SetTab(int nTab)
     720             : {
     721           0 :     mnTab = nTab;
     722           0 : }
     723             : 
     724           2 : int SvxTableField::GetTab() const
     725             : {
     726           2 :     return mnTab;
     727             : }
     728             : 
     729        7373 : SvxFieldData* SvxTableField::Clone() const
     730             : {
     731        7373 :     return new SvxTableField(mnTab);
     732             : }
     733             : 
     734         602 : bool SvxTableField::operator==( const SvxFieldData& rCmp ) const
     735             : {
     736         602 :     if (rCmp.Type() != TYPE(SvxTableField))
     737           0 :         return false;
     738             : 
     739         602 :     return mnTab == static_cast<const SvxTableField&>(rCmp).mnTab;
     740             : }
     741             : 
     742           0 : void SvxTableField::Load( SvPersistStream & /*rStm*/ )
     743             : {
     744           0 : }
     745             : 
     746         160 : void SvxTableField::Save( SvPersistStream & /*rStm*/ )
     747             : {
     748         160 : }
     749             : 
     750             : 
     751             : //      SvxExtTimeField
     752             : 
     753             : 
     754        1549 : SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData );
     755             : 
     756             : 
     757             : 
     758         107 : SvxExtTimeField::SvxExtTimeField()
     759         107 :     : m_nFixTime( Time(Time::SYSTEM).GetTime() )
     760             : {
     761         107 :     eType = SVXTIMETYPE_VAR;
     762         107 :     eFormat = SVXTIMEFORMAT_STANDARD;
     763         107 : }
     764             : 
     765             : 
     766             : 
     767           0 : SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF )
     768           0 :     : m_nFixTime( rTime.GetTime() )
     769             : {
     770           0 :     eType = eT;
     771           0 :     eFormat = eF;
     772           0 : }
     773             : 
     774             : 
     775             : 
     776         991 : SvxFieldData* SvxExtTimeField::Clone() const
     777             : {
     778         991 :     return new SvxExtTimeField( *this );
     779             : }
     780             : 
     781             : 
     782             : 
     783          32 : bool SvxExtTimeField::operator==( const SvxFieldData& rOther ) const
     784             : {
     785          32 :     if ( rOther.Type() != Type() )
     786           0 :         return false;
     787             : 
     788          32 :     const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther;
     789          64 :     return ((m_nFixTime == rOtherFld.m_nFixTime) &&
     790          64 :                 ( eType == rOtherFld.eType ) &&
     791          64 :                 ( eFormat == rOtherFld.eFormat ) );
     792             : }
     793             : 
     794             : 
     795             : 
     796           0 : void SvxExtTimeField::Load( SvPersistStream & rStm )
     797             : {
     798             :     sal_uInt16 nType, nFormat;
     799             : 
     800           0 :     rStm.ReadInt64(m_nFixTime);
     801           0 :     rStm.ReadUInt16( nType );
     802           0 :     rStm.ReadUInt16( 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.WriteInt64(m_nFixTime);
     813           0 :     rStm.WriteUInt16( (sal_uInt16) eType );
     814           0 :     rStm.WriteUInt16( (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(m_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 : bool SvxExtFileField::operator==( const SvxFieldData& rOther ) const
     928             : {
     929           0 :     if ( rOther.Type() != Type() )
     930           0 :         return 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.ReadUInt16( nType );
     948           0 :     rStm.ReadUInt16( 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.WriteUInt16( (sal_uInt16) eType );
     962           0 :     rStm.WriteUInt16( (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 : bool SvxAuthorField::operator==( const SvxFieldData& rOther ) const
    1080             : {
    1081           0 :     if ( rOther.Type() != Type() )
    1082           0 :         return 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.ReadUInt16( nType );
    1103           0 :     rStm.ReadUInt16( 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.WriteUInt16( (sal_uInt16) eType );
    1118           0 :     rStm.WriteUInt16( (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           0 :             aString = aFirstName + " " + aName;
    1131           0 :         break;
    1132             :         case SVXAUTHORFORMAT_NAME:
    1133           0 :             aString = aName;
    1134           0 :         break;
    1135             : 
    1136             :         case SVXAUTHORFORMAT_FIRSTNAME:
    1137           0 :             aString = aFirstName;
    1138           0 :         break;
    1139             : 
    1140             :         case SVXAUTHORFORMAT_SHORTNAME:
    1141           0 :             aString = aShortName;
    1142           0 :         break;
    1143             :     }
    1144             : 
    1145           0 :     return aString;
    1146             : }
    1147             : 
    1148             : static SvClassManager* pClassMgr=0;
    1149             : 
    1150         624 : SvClassManager& SvxFieldItem::GetClassManager()
    1151             : {
    1152         624 :     if ( !pClassMgr )
    1153             :     {
    1154          74 :         pClassMgr = new SvClassManager;
    1155          74 :         pClassMgr->Register(SvxFieldData::StaticClassId(),    SvxFieldData::CreateInstance);
    1156          74 :         pClassMgr->Register(SvxURLField::StaticClassId(),     SvxURLField::CreateInstance);
    1157          74 :         pClassMgr->Register(SvxDateField::StaticClassId(),    SvxDateField::CreateInstance);
    1158          74 :         pClassMgr->Register(SvxPageField::StaticClassId(),    SvxPageField::CreateInstance);
    1159          74 :         pClassMgr->Register(SvxTimeField::StaticClassId(),    SvxTimeField::CreateInstance);
    1160          74 :         pClassMgr->Register(SvxExtTimeField::StaticClassId(), SvxExtTimeField::CreateInstance);
    1161          74 :         pClassMgr->Register(SvxExtFileField::StaticClassId(), SvxExtFileField::CreateInstance);
    1162          74 :         pClassMgr->Register(SvxAuthorField::StaticClassId(),  SvxAuthorField::CreateInstance);
    1163             :     }
    1164             : 
    1165         624 :     return *pClassMgr;
    1166             : }
    1167             : 
    1168             : 
    1169             : 
    1170        2261 : SV_IMPL_PERSIST1( SvxHeaderField, SvxFieldData );
    1171             : 
    1172         444 : SvxHeaderField::SvxHeaderField() {}
    1173             : 
    1174         272 : SvxFieldData* SvxHeaderField::Clone() const
    1175             : {
    1176         272 :     return new SvxHeaderField;      // empty
    1177             : }
    1178             : 
    1179         110 : bool SvxHeaderField::operator==( const SvxFieldData& rCmp ) const
    1180             : {
    1181         110 :     return ( rCmp.Type() == TYPE(SvxHeaderField) );
    1182             : }
    1183             : 
    1184           0 : void SvxHeaderField::Load( SvPersistStream & /*rStm*/ )
    1185             : {
    1186           0 : }
    1187             : 
    1188           0 : void SvxHeaderField::Save( SvPersistStream & /*rStm*/ )
    1189             : {
    1190           0 : }
    1191             : 
    1192             : 
    1193             : 
    1194        4816 : SV_IMPL_PERSIST1( SvxFooterField, SvxFieldData );
    1195         671 : SvxFooterField::SvxFooterField() {}
    1196             : 
    1197         400 : SvxFieldData* SvxFooterField::Clone() const
    1198             : {
    1199         400 :     return new SvxFooterField;      // empty
    1200             : }
    1201             : 
    1202         209 : bool SvxFooterField::operator==( const SvxFieldData& rCmp ) const
    1203             : {
    1204         209 :     return ( rCmp.Type() == TYPE(SvxFooterField) );
    1205             : }
    1206             : 
    1207           0 : void SvxFooterField::Load( SvPersistStream & /*rStm*/ )
    1208             : {
    1209           0 : }
    1210             : 
    1211           0 : void SvxFooterField::Save( SvPersistStream & /*rStm*/ )
    1212             : {
    1213           0 : }
    1214             : 
    1215             : 
    1216             : 
    1217        5793 : SV_IMPL_PERSIST1( SvxDateTimeField, SvxFieldData );
    1218             : 
    1219         399 : SvxFieldData* SvxDateTimeField::Clone() const
    1220             : {
    1221         399 :     return new SvxDateTimeField;        // empty
    1222             : }
    1223             : 
    1224         208 : bool SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const
    1225             : {
    1226         208 :     return ( rCmp.Type() == TYPE(SvxDateTimeField) );
    1227             : }
    1228             : 
    1229           0 : void SvxDateTimeField::Load( SvPersistStream & /*rStm*/ )
    1230             : {
    1231           0 : }
    1232             : 
    1233           0 : void SvxDateTimeField::Save( SvPersistStream & /*rStm*/ )
    1234             : {
    1235           0 : }
    1236             : 
    1237         669 : SvxDateTimeField::SvxDateTimeField() {}
    1238             : 
    1239           0 : OUString SvxDateTimeField::GetFormatted(
    1240             :     Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage )
    1241             : {
    1242           0 :     OUString aRet;
    1243             : 
    1244           0 :     SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f);
    1245             : 
    1246           0 :     if(eDateFormat)
    1247             :     {
    1248           0 :         aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage );
    1249             :     }
    1250             : 
    1251           0 :     SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f);
    1252             : 
    1253           0 :     if(eTimeFormat)
    1254             :     {
    1255           0 :         OUStringBuffer aBuf(aRet);
    1256             : 
    1257           0 :         if (!aRet.isEmpty())
    1258           0 :             aBuf.append(' ');
    1259             : 
    1260             :         aBuf.append(
    1261           0 :             SvxExtTimeField::GetFormatted(rTime, eTimeFormat, rFormatter, eLanguage));
    1262             : 
    1263           0 :         aRet = aBuf.makeStringAndClear();
    1264             :     }
    1265             : 
    1266           0 :     return aRet;
    1267             : }
    1268             : 
    1269             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10