1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_editeng.hxx" 30*cdf0e10cSrcweir #include <vcl/metaact.hxx> 31*cdf0e10cSrcweir #include <svl/zforlist.hxx> 32*cdf0e10cSrcweir #include <tools/urlobj.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #define _SVX_FLDITEM_CXX 35*cdf0e10cSrcweir #include <unotools/localfilehelper.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <editeng/flditem.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <editeng/measfld.hxx> 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir // #90477# 42*cdf0e10cSrcweir #include <tools/tenccvt.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir #define FRAME_MARKER (sal_uInt32)0x21981357 45*cdf0e10cSrcweir #define CHARSET_MARKER (FRAME_MARKER+1) 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // ----------------------------------------------------------------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir TYPEINIT1( SvxFieldItem, SfxPoolItem ); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFieldData, SvPersistBase ); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir // ----------------------------------------------------------------------- 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir SvxFieldData::SvxFieldData() 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir // ----------------------------------------------------------------------- 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir SvxFieldData::~SvxFieldData() 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir // ----------------------------------------------------------------------- 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvxFieldData* SvxFieldData::Clone() const 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir return new SvxFieldData; 70*cdf0e10cSrcweir } 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // ----------------------------------------------------------------------- 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir int SvxFieldData::operator==( const SvxFieldData& rFld ) const 75*cdf0e10cSrcweir { 76*cdf0e10cSrcweir DBG_ASSERT( Type() == rFld.Type(), "==: Verschiedene Typen" ); 77*cdf0e10cSrcweir (void)rFld; 78*cdf0e10cSrcweir return sal_True; // Basicklasse immer gleich. 79*cdf0e10cSrcweir } 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir // ----------------------------------------------------------------------- 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir void SvxFieldData::Load( SvPersistStream & /*rStm*/ ) 84*cdf0e10cSrcweir { 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // ----------------------------------------------------------------------- 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void SvxFieldData::Save( SvPersistStream & /*rStm*/ ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir MetaAction* SvxFieldData::createBeginComment() const 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN" ); 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir MetaAction* SvxFieldData::createEndComment() const 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_END" ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // ----------------------------------------------------------------------- 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( SvxFieldData* pFld, const sal_uInt16 nId ) : 107*cdf0e10cSrcweir SfxPoolItem( nId ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir pField = pFld; // gehoert direkt dem Item 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // ----------------------------------------------------------------------- 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) : 115*cdf0e10cSrcweir SfxPoolItem( nId ) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir pField = rField.Clone(); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // ----------------------------------------------------------------------- 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) : 123*cdf0e10cSrcweir SfxPoolItem ( rItem ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir pField = rItem.GetField() ? rItem.GetField()->Clone() : 0; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir // ----------------------------------------------------------------------- 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir SvxFieldItem::~SvxFieldItem() 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir delete pField; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir // ----------------------------------------------------------------------- 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir SfxPoolItem* SvxFieldItem::Clone( SfxItemPool* ) const 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir return new SvxFieldItem(*this); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // ----------------------------------------------------------------------- 143*cdf0e10cSrcweir 144*cdf0e10cSrcweir SfxPoolItem* SvxFieldItem::Create( SvStream& rStrm, sal_uInt16 ) const 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir SvxFieldData* pData = 0; 147*cdf0e10cSrcweir SvPersistStream aPStrm( GetClassManager(), &rStrm ); 148*cdf0e10cSrcweir aPStrm >> pData; 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir if( aPStrm.IsEof() ) 151*cdf0e10cSrcweir aPStrm.SetError( SVSTREAM_GENERALERROR ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir if ( aPStrm.GetError() == ERRCODE_IO_NOFACTORY ) 154*cdf0e10cSrcweir aPStrm.ResetError(); // Eigentlich einen Code, dass nicht alle Attr gelesen wurden... 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir return new SvxFieldItem( pData, Which() ); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir // ----------------------------------------------------------------------- 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir DBG_ASSERT( pField, "SvxFieldItem::Store: Feld?!" ); 164*cdf0e10cSrcweir SvPersistStream aPStrm( GetClassManager(), &rStrm ); 165*cdf0e10cSrcweir // Das ResetError in der obigen Create-Methode gab es in 3.1 noch nicht, 166*cdf0e10cSrcweir // deshalb duerfen beim 3.x-Export neuere Items nicht gespeichert werden! 167*cdf0e10cSrcweir if ( ( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_31 ) && pField && 168*cdf0e10cSrcweir pField->GetClassId() == 50 /* SdrMeasureField */ ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir // SvxFieldData reicht nicht, weil auch nicht am ClassMgr angemeldet 171*cdf0e10cSrcweir SvxURLField aDummyData; 172*cdf0e10cSrcweir aPStrm << &aDummyData; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir else 175*cdf0e10cSrcweir aPStrm << pField; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir return rStrm; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir // ----------------------------------------------------------------------- 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir int SvxFieldItem::operator==( const SfxPoolItem& rItem ) const 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" ); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir const SvxFieldData* pOtherFld = ((const SvxFieldItem&)rItem).GetField(); 187*cdf0e10cSrcweir if ( !pField && !pOtherFld ) 188*cdf0e10cSrcweir return sal_True; 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir if ( ( !pField && pOtherFld ) || ( pField && !pOtherFld ) ) 191*cdf0e10cSrcweir return sal_False; 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir return ( ( pField->Type() == pOtherFld->Type() ) 194*cdf0e10cSrcweir && ( *pField == *pOtherFld ) ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir // ================================================================= 198*cdf0e10cSrcweir // Es folgen die Ableitungen von SvxFieldData... 199*cdf0e10cSrcweir // ================================================================= 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxDateField, SvxFieldData ); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir // ----------------------------------------------------------------------- 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir SvxDateField::SvxDateField() 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir nFixDate = Date().GetDate(); 208*cdf0e10cSrcweir eType = SVXDATETYPE_VAR; 209*cdf0e10cSrcweir eFormat = SVXDATEFORMAT_STDSMALL; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // ----------------------------------------------------------------------- 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir SvxDateField::SvxDateField( const Date& rDate, SvxDateType eT, SvxDateFormat eF ) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir nFixDate = rDate.GetDate(); 217*cdf0e10cSrcweir eType = eT; 218*cdf0e10cSrcweir eFormat = eF; 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // ----------------------------------------------------------------------- 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir SvxFieldData* SvxDateField::Clone() const 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir return new SvxDateField( *this ); 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir // ----------------------------------------------------------------------- 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir int SvxDateField::operator==( const SvxFieldData& rOther ) const 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if ( rOther.Type() != Type() ) 233*cdf0e10cSrcweir return sal_False; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir const SvxDateField& rOtherFld = (const SvxDateField&) rOther; 236*cdf0e10cSrcweir return ( ( nFixDate == rOtherFld.nFixDate ) && 237*cdf0e10cSrcweir ( eType == rOtherFld.eType ) && 238*cdf0e10cSrcweir ( eFormat == rOtherFld.eFormat ) ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir // ----------------------------------------------------------------------- 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir void SvxDateField::Load( SvPersistStream & rStm ) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir sal_uInt16 nType, nFormat; 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir rStm >> nFixDate; 248*cdf0e10cSrcweir rStm >> nType; 249*cdf0e10cSrcweir rStm >> nFormat; 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir eType = (SvxDateType)nType; 252*cdf0e10cSrcweir eFormat= (SvxDateFormat)nFormat; 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir // ----------------------------------------------------------------------- 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir void SvxDateField::Save( SvPersistStream & rStm ) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir rStm << nFixDate; 260*cdf0e10cSrcweir rStm << (sal_uInt16)eType; 261*cdf0e10cSrcweir rStm << (sal_uInt16)eFormat; 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir // ----------------------------------------------------------------------- 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir String SvxDateField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir Date aDate; // current date 269*cdf0e10cSrcweir if ( eType == SVXDATETYPE_FIX ) 270*cdf0e10cSrcweir aDate.SetDate( nFixDate ); 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir return GetFormatted( aDate, eFormat, rFormatter, eLang ); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir String SvxDateField::GetFormatted( Date& aDate, SvxDateFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang ) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if ( eFormat == SVXDATEFORMAT_SYSTEM ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir DBG_ERROR( "SVXDATEFORMAT_SYSTEM nicht implementiert!" ); 280*cdf0e10cSrcweir eFormat = SVXDATEFORMAT_STDSMALL; 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir else if ( eFormat == SVXDATEFORMAT_APPDEFAULT ) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir DBG_ERROR( "SVXDATEFORMAT_APPDEFAULT: Woher nehmen?" ); 285*cdf0e10cSrcweir eFormat = SVXDATEFORMAT_STDSMALL; 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir sal_uLong nFormatKey; 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir switch( eFormat ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir case SVXDATEFORMAT_STDSMALL: 293*cdf0e10cSrcweir // short 294*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_SHORT, eLang ); 295*cdf0e10cSrcweir break; 296*cdf0e10cSrcweir case SVXDATEFORMAT_STDBIG: 297*cdf0e10cSrcweir // long 298*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYSTEM_LONG, eLang ); 299*cdf0e10cSrcweir break; 300*cdf0e10cSrcweir case SVXDATEFORMAT_A: 301*cdf0e10cSrcweir // 13.02.96 302*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYY, eLang ); 303*cdf0e10cSrcweir break; 304*cdf0e10cSrcweir case SVXDATEFORMAT_B: 305*cdf0e10cSrcweir // 13.02.1996 306*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DDMMYYYY, eLang ); 307*cdf0e10cSrcweir break; 308*cdf0e10cSrcweir case SVXDATEFORMAT_C: 309*cdf0e10cSrcweir // 13. Feb 1996 310*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMYYYY, eLang ); 311*cdf0e10cSrcweir break; 312*cdf0e10cSrcweir case SVXDATEFORMAT_D: 313*cdf0e10cSrcweir // 13. Februar 1996 314*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY, eLang ); 315*cdf0e10cSrcweir break; 316*cdf0e10cSrcweir case SVXDATEFORMAT_E: 317*cdf0e10cSrcweir // Die, 13. Februar 1996 318*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY, eLang ); 319*cdf0e10cSrcweir break; 320*cdf0e10cSrcweir case SVXDATEFORMAT_F: 321*cdf0e10cSrcweir // Dienstag, 13. Februar 1996 322*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY, eLang ); 323*cdf0e10cSrcweir break; 324*cdf0e10cSrcweir default: 325*cdf0e10cSrcweir nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_DATE, eLang ); 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir double fDiffDate = aDate - *(rFormatter.GetNullDate()); 329*cdf0e10cSrcweir String aStr; 330*cdf0e10cSrcweir Color* pColor = NULL; 331*cdf0e10cSrcweir rFormatter.GetOutputString( fDiffDate, nFormatKey, aStr, &pColor ); 332*cdf0e10cSrcweir return aStr; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir MetaAction* SvxDateField::createBeginComment() const 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN" ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxURLField, SvxFieldData ); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir // ----------------------------------------------------------------------- 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir SvxURLField::SvxURLField() 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir eFormat = SVXURLFORMAT_URL; 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir // ----------------------------------------------------------------------- 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir SvxURLField::SvxURLField( const XubString& rURL, const XubString& rRepres, SvxURLFormat eFmt ) 352*cdf0e10cSrcweir : aURL( rURL ), aRepresentation( rRepres ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir eFormat = eFmt; 355*cdf0e10cSrcweir } 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // ----------------------------------------------------------------------- 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir SvxFieldData* SvxURLField::Clone() const 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir return new SvxURLField( *this ); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir // ----------------------------------------------------------------------- 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir int SvxURLField::operator==( const SvxFieldData& rOther ) const 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir if ( rOther.Type() != Type() ) 369*cdf0e10cSrcweir return sal_False; 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir const SvxURLField& rOtherFld = (const SvxURLField&) rOther; 372*cdf0e10cSrcweir return ( ( eFormat == rOtherFld.eFormat ) && 373*cdf0e10cSrcweir ( aURL == rOtherFld.aURL ) && 374*cdf0e10cSrcweir ( aRepresentation == rOtherFld.aRepresentation ) && 375*cdf0e10cSrcweir ( aTargetFrame == rOtherFld.aTargetFrame ) ); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // ----------------------------------------------------------------------- 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir static void write_unicode( SvPersistStream & rStm, const String& rString ) 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir sal_uInt16 nL = rString.Len(); 383*cdf0e10cSrcweir rStm << nL; 384*cdf0e10cSrcweir rStm.Write( rString.GetBuffer(), nL*sizeof(sal_Unicode) ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir static void read_unicode( SvPersistStream & rStm, String& rString ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir sal_uInt16 nL = 0; 390*cdf0e10cSrcweir rStm >> nL; 391*cdf0e10cSrcweir if ( nL ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir rString.AllocBuffer( nL ); 394*cdf0e10cSrcweir rStm.Read( rString.GetBufferAccess(), nL*sizeof(sal_Unicode) ); 395*cdf0e10cSrcweir rString.ReleaseBufferAccess( nL ); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir void SvxURLField::Load( SvPersistStream & rStm ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir sal_uInt16 nFormat = 0; 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir rStm >> nFormat; 404*cdf0e10cSrcweir eFormat= (SvxURLFormat)nFormat; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir read_unicode( rStm, aURL ); 407*cdf0e10cSrcweir read_unicode( rStm, aRepresentation ); 408*cdf0e10cSrcweir read_unicode( rStm, aTargetFrame ); 409*cdf0e10cSrcweir } 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir // ----------------------------------------------------------------------- 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir void SvxURLField::Save( SvPersistStream & rStm ) 414*cdf0e10cSrcweir { 415*cdf0e10cSrcweir rStm << (sal_uInt16)eFormat; 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir write_unicode( rStm, aURL ); 418*cdf0e10cSrcweir write_unicode( rStm, aRepresentation ); 419*cdf0e10cSrcweir write_unicode( rStm, aTargetFrame ); 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir MetaAction* SvxURLField::createBeginComment() const 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir // #i46618# Adding target URL to metafile comment 425*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN", 426*cdf0e10cSrcweir 0, 427*cdf0e10cSrcweir reinterpret_cast<const sal_uInt8*>(aURL.GetBuffer()), 428*cdf0e10cSrcweir 2*aURL.Len() ); 429*cdf0e10cSrcweir } 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir // ================================================================= 432*cdf0e10cSrcweir // Die Felder, die aus Calc ausgebaut wurden: 433*cdf0e10cSrcweir // ================================================================= 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxPageField, SvxFieldData ); 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxPageField::Clone() const 438*cdf0e10cSrcweir { 439*cdf0e10cSrcweir return new SvxPageField; // leer 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir int __EXPORT SvxPageField::operator==( const SvxFieldData& rCmp ) const 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxPageField) ); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir void __EXPORT SvxPageField::Load( SvPersistStream & /*rStm*/ ) 448*cdf0e10cSrcweir { 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir 451*cdf0e10cSrcweir void __EXPORT SvxPageField::Save( SvPersistStream & /*rStm*/ ) 452*cdf0e10cSrcweir { 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir MetaAction* SvxPageField::createBeginComment() const 456*cdf0e10cSrcweir { 457*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" ); 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxPagesField, SvxFieldData ); 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxPagesField::Clone() const 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir return new SvxPagesField; // leer 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir int __EXPORT SvxPagesField::operator==( const SvxFieldData& rCmp ) const 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxPagesField) ); 471*cdf0e10cSrcweir } 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir void __EXPORT SvxPagesField::Load( SvPersistStream & /*rStm*/ ) 474*cdf0e10cSrcweir { 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir void __EXPORT SvxPagesField::Save( SvPersistStream & /*rStm*/ ) 478*cdf0e10cSrcweir { 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxTimeField, SvxFieldData ); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxTimeField::Clone() const 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir return new SvxTimeField; // leer 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir int __EXPORT SvxTimeField::operator==( const SvxFieldData& rCmp ) const 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxTimeField) ); 491*cdf0e10cSrcweir } 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir void __EXPORT SvxTimeField::Load( SvPersistStream & /*rStm*/ ) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir void __EXPORT SvxTimeField::Save( SvPersistStream & /*rStm*/ ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir MetaAction* SvxTimeField::createBeginComment() const 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN" ); 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFileField, SvxFieldData ); 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxFileField::Clone() const 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir return new SvxFileField; // leer 511*cdf0e10cSrcweir } 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir int __EXPORT SvxFileField::operator==( const SvxFieldData& rCmp ) const 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxFileField) ); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir void __EXPORT SvxFileField::Load( SvPersistStream & /*rStm*/ ) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir void __EXPORT SvxFileField::Save( SvPersistStream & /*rStm*/ ) 523*cdf0e10cSrcweir { 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxTableField, SvxFieldData ); 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxTableField::Clone() const 529*cdf0e10cSrcweir { 530*cdf0e10cSrcweir return new SvxTableField; // leer 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir int __EXPORT SvxTableField::operator==( const SvxFieldData& rCmp ) const 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxTableField) ); 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir 538*cdf0e10cSrcweir void __EXPORT SvxTableField::Load( SvPersistStream & /*rStm*/ ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir void __EXPORT SvxTableField::Save( SvPersistStream & /*rStm*/ ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir //---------------------------------------------------------------------------- 547*cdf0e10cSrcweir // SvxExtTimeField 548*cdf0e10cSrcweir //---------------------------------------------------------------------------- 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxExtTimeField, SvxFieldData ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir //---------------------------------------------------------------------------- 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir SvxExtTimeField::SvxExtTimeField() 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir nFixTime = Time().GetTime(); 557*cdf0e10cSrcweir eType = SVXTIMETYPE_VAR; 558*cdf0e10cSrcweir eFormat = SVXTIMEFORMAT_STANDARD; 559*cdf0e10cSrcweir } 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir //---------------------------------------------------------------------------- 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir SvxExtTimeField::SvxExtTimeField( const Time& rTime, SvxTimeType eT, SvxTimeFormat eF ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir nFixTime = rTime.GetTime(); 566*cdf0e10cSrcweir eType = eT; 567*cdf0e10cSrcweir eFormat = eF; 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir //---------------------------------------------------------------------------- 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir SvxFieldData* SvxExtTimeField::Clone() const 573*cdf0e10cSrcweir { 574*cdf0e10cSrcweir return new SvxExtTimeField( *this ); 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir //---------------------------------------------------------------------------- 578*cdf0e10cSrcweir 579*cdf0e10cSrcweir int SvxExtTimeField::operator==( const SvxFieldData& rOther ) const 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir if ( rOther.Type() != Type() ) 582*cdf0e10cSrcweir return sal_False; 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir const SvxExtTimeField& rOtherFld = (const SvxExtTimeField&) rOther; 585*cdf0e10cSrcweir return ( ( nFixTime == rOtherFld.nFixTime ) && 586*cdf0e10cSrcweir ( eType == rOtherFld.eType ) && 587*cdf0e10cSrcweir ( eFormat == rOtherFld.eFormat ) ); 588*cdf0e10cSrcweir } 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir //---------------------------------------------------------------------------- 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir void SvxExtTimeField::Load( SvPersistStream & rStm ) 593*cdf0e10cSrcweir { 594*cdf0e10cSrcweir sal_uInt16 nType, nFormat; 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir rStm >> nFixTime; 597*cdf0e10cSrcweir rStm >> nType; 598*cdf0e10cSrcweir rStm >> nFormat; 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir eType = (SvxTimeType) nType; 601*cdf0e10cSrcweir eFormat= (SvxTimeFormat) nFormat; 602*cdf0e10cSrcweir } 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir //---------------------------------------------------------------------------- 605*cdf0e10cSrcweir 606*cdf0e10cSrcweir void SvxExtTimeField::Save( SvPersistStream & rStm ) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir rStm << nFixTime; 609*cdf0e10cSrcweir rStm << (sal_uInt16) eType; 610*cdf0e10cSrcweir rStm << (sal_uInt16) eFormat; 611*cdf0e10cSrcweir } 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir //---------------------------------------------------------------------------- 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir String SvxExtTimeField::GetFormatted( SvNumberFormatter& rFormatter, LanguageType eLang ) const 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir Time aTime; // current time 618*cdf0e10cSrcweir if ( eType == SVXTIMETYPE_FIX ) 619*cdf0e10cSrcweir aTime.SetTime( nFixTime ); 620*cdf0e10cSrcweir return GetFormatted( aTime, eFormat, rFormatter, eLang ); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir String SvxExtTimeField::GetFormatted( Time& aTime, SvxTimeFormat eFormat, SvNumberFormatter& rFormatter, LanguageType eLang ) 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir switch( eFormat ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir case SVXTIMEFORMAT_SYSTEM : 628*cdf0e10cSrcweir DBG_ERROR( "SVXTIMEFORMAT_SYSTEM: not implemented" ); 629*cdf0e10cSrcweir eFormat = SVXTIMEFORMAT_STANDARD; 630*cdf0e10cSrcweir break; 631*cdf0e10cSrcweir case SVXTIMEFORMAT_APPDEFAULT : 632*cdf0e10cSrcweir DBG_ERROR( "SVXTIMEFORMAT_APPDEFAULT: not implemented" ); 633*cdf0e10cSrcweir eFormat = SVXTIMEFORMAT_STANDARD; 634*cdf0e10cSrcweir break; 635*cdf0e10cSrcweir default: ;//prevent warning 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir 638*cdf0e10cSrcweir sal_uInt32 nFormatKey; 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir switch( eFormat ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir case SVXTIMEFORMAT_12_HM: 643*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMAMPM, eLang ); 644*cdf0e10cSrcweir break; 645*cdf0e10cSrcweir case SVXTIMEFORMAT_12_HMSH: 646*cdf0e10cSrcweir { // no builtin format available, try to insert or reuse 647*cdf0e10cSrcweir String aFormatCode( RTL_CONSTASCII_USTRINGPARAM( "HH:MM:SS.00 AM/PM" ) ); 648*cdf0e10cSrcweir xub_StrLen nCheckPos; 649*cdf0e10cSrcweir short nType; 650*cdf0e10cSrcweir /*sal_Bool bInserted = */rFormatter.PutandConvertEntry( aFormatCode, 651*cdf0e10cSrcweir nCheckPos, nType, nFormatKey, LANGUAGE_ENGLISH_US, eLang ); 652*cdf0e10cSrcweir DBG_ASSERT( nCheckPos == 0, "SVXTIMEFORMAT_12_HMSH: could not insert format code" ); 653*cdf0e10cSrcweir if ( nCheckPos ) 654*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang ); 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir break; 657*cdf0e10cSrcweir case SVXTIMEFORMAT_24_HM: 658*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMM, eLang ); 659*cdf0e10cSrcweir break; 660*cdf0e10cSrcweir case SVXTIMEFORMAT_24_HMSH: 661*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HH_MMSS00, eLang ); 662*cdf0e10cSrcweir break; 663*cdf0e10cSrcweir case SVXTIMEFORMAT_12_HMS: 664*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSSAMPM, eLang ); 665*cdf0e10cSrcweir break; 666*cdf0e10cSrcweir case SVXTIMEFORMAT_24_HMS: 667*cdf0e10cSrcweir nFormatKey = rFormatter.GetFormatIndex( NF_TIME_HHMMSS, eLang ); 668*cdf0e10cSrcweir break; 669*cdf0e10cSrcweir case SVXTIMEFORMAT_STANDARD: 670*cdf0e10cSrcweir default: 671*cdf0e10cSrcweir nFormatKey = rFormatter.GetStandardFormat( NUMBERFORMAT_TIME, eLang ); 672*cdf0e10cSrcweir } 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir double fFracTime = aTime.GetTimeInDays(); 675*cdf0e10cSrcweir String aStr; 676*cdf0e10cSrcweir Color* pColor = NULL; 677*cdf0e10cSrcweir rFormatter.GetOutputString( fFracTime, nFormatKey, aStr, &pColor ); 678*cdf0e10cSrcweir return aStr; 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir MetaAction* SvxExtTimeField::createBeginComment() const 682*cdf0e10cSrcweir { 683*cdf0e10cSrcweir return new MetaCommentAction( "FIELD_SEQ_BEGIN" ); 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir //---------------------------------------------------------------------------- 687*cdf0e10cSrcweir // SvxExtFileField 688*cdf0e10cSrcweir //---------------------------------------------------------------------------- 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxExtFileField, SvxFieldData ); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir //---------------------------------------------------------------------------- 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir SvxExtFileField::SvxExtFileField() 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir eType = SVXFILETYPE_VAR; 697*cdf0e10cSrcweir eFormat = SVXFILEFORMAT_FULLPATH; 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir //---------------------------------------------------------------------------- 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir SvxExtFileField::SvxExtFileField( const XubString& rStr, SvxFileType eT, SvxFileFormat eF ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir aFile = rStr; 705*cdf0e10cSrcweir eType = eT; 706*cdf0e10cSrcweir eFormat = eF; 707*cdf0e10cSrcweir } 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir //---------------------------------------------------------------------------- 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir SvxFieldData* SvxExtFileField::Clone() const 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir return new SvxExtFileField( *this ); 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir //---------------------------------------------------------------------------- 717*cdf0e10cSrcweir 718*cdf0e10cSrcweir int SvxExtFileField::operator==( const SvxFieldData& rOther ) const 719*cdf0e10cSrcweir { 720*cdf0e10cSrcweir if ( rOther.Type() != Type() ) 721*cdf0e10cSrcweir return sal_False; 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir const SvxExtFileField& rOtherFld = (const SvxExtFileField&) rOther; 724*cdf0e10cSrcweir return ( ( aFile == rOtherFld.aFile ) && 725*cdf0e10cSrcweir ( eType == rOtherFld.eType ) && 726*cdf0e10cSrcweir ( eFormat == rOtherFld.eFormat ) ); 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir //---------------------------------------------------------------------------- 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir void SvxExtFileField::Load( SvPersistStream & rStm ) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir sal_uInt16 nType, nFormat; 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir // UNICODE: rStm >> aFile; 736*cdf0e10cSrcweir rStm.ReadByteString(aFile); 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir rStm >> nType; 739*cdf0e10cSrcweir rStm >> nFormat; 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir eType = (SvxFileType) nType; 742*cdf0e10cSrcweir eFormat= (SvxFileFormat) nFormat; 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir //---------------------------------------------------------------------------- 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir void SvxExtFileField::Save( SvPersistStream & rStm ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir // UNICODE: rStm << aFile; 750*cdf0e10cSrcweir rStm.WriteByteString(aFile); 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir rStm << (sal_uInt16) eType; 753*cdf0e10cSrcweir rStm << (sal_uInt16) eFormat; 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir //---------------------------------------------------------------------------- 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir XubString SvxExtFileField::GetFormatted() const 759*cdf0e10cSrcweir { 760*cdf0e10cSrcweir XubString aString; 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir INetURLObject aURLObj( aFile ); 763*cdf0e10cSrcweir 764*cdf0e10cSrcweir if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() ) 765*cdf0e10cSrcweir { 766*cdf0e10cSrcweir // invalid? try to interpret string as system file name 767*cdf0e10cSrcweir String aURLStr; 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aURLStr ); 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir aURLObj.SetURL( aURLStr ); 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir // #92009# Be somewhat liberate when trying to 775*cdf0e10cSrcweir // get formatted content out of the FileField 776*cdf0e10cSrcweir if( INET_PROT_NOT_VALID == aURLObj.GetProtocol() ) 777*cdf0e10cSrcweir { 778*cdf0e10cSrcweir // still not valid? Then output as is 779*cdf0e10cSrcweir aString = aFile; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir else if( INET_PROT_FILE == aURLObj.GetProtocol() ) 782*cdf0e10cSrcweir { 783*cdf0e10cSrcweir switch( eFormat ) 784*cdf0e10cSrcweir { 785*cdf0e10cSrcweir case SVXFILEFORMAT_FULLPATH: 786*cdf0e10cSrcweir aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT); 787*cdf0e10cSrcweir break; 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir case SVXFILEFORMAT_PATH: 790*cdf0e10cSrcweir aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false); 791*cdf0e10cSrcweir // #101742# Leave trailing slash at the pathname 792*cdf0e10cSrcweir aURLObj.setFinalSlash(); 793*cdf0e10cSrcweir aString = aURLObj.getFSysPath(INetURLObject::FSYS_DETECT); 794*cdf0e10cSrcweir break; 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir case SVXFILEFORMAT_NAME: 797*cdf0e10cSrcweir aString = aURLObj.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS); 798*cdf0e10cSrcweir break; 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir case SVXFILEFORMAT_NAME_EXT: 801*cdf0e10cSrcweir aString = aURLObj.getName(INetURLObject::LAST_SEGMENT,true,INetURLObject::DECODE_UNAMBIGUOUS); 802*cdf0e10cSrcweir break; 803*cdf0e10cSrcweir } 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir else 806*cdf0e10cSrcweir { 807*cdf0e10cSrcweir switch( eFormat ) 808*cdf0e10cSrcweir { 809*cdf0e10cSrcweir case SVXFILEFORMAT_FULLPATH: 810*cdf0e10cSrcweir aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); 811*cdf0e10cSrcweir break; 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir case SVXFILEFORMAT_PATH: 814*cdf0e10cSrcweir aURLObj.removeSegment(INetURLObject::LAST_SEGMENT, false); 815*cdf0e10cSrcweir // #101742# Leave trailing slash at the pathname 816*cdf0e10cSrcweir aURLObj.setFinalSlash(); 817*cdf0e10cSrcweir aString = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); 818*cdf0e10cSrcweir break; 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir case SVXFILEFORMAT_NAME: 821*cdf0e10cSrcweir aString = aURLObj.getBase(); 822*cdf0e10cSrcweir break; 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir case SVXFILEFORMAT_NAME_EXT: 825*cdf0e10cSrcweir aString = aURLObj.getName(); 826*cdf0e10cSrcweir break; 827*cdf0e10cSrcweir } 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir return( aString ); 831*cdf0e10cSrcweir } 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir //---------------------------------------------------------------------------- 834*cdf0e10cSrcweir // SvxAuthorField 835*cdf0e10cSrcweir //---------------------------------------------------------------------------- 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxAuthorField, SvxFieldData ); 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir //---------------------------------------------------------------------------- 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir SvxAuthorField::SvxAuthorField() 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir eType = SVXAUTHORTYPE_VAR; 844*cdf0e10cSrcweir eFormat = SVXAUTHORFORMAT_FULLNAME; 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir //---------------------------------------------------------------------------- 848*cdf0e10cSrcweir 849*cdf0e10cSrcweir SvxAuthorField::SvxAuthorField( const XubString& rFirstName, 850*cdf0e10cSrcweir const XubString& rLastName, 851*cdf0e10cSrcweir const XubString& rShortName, 852*cdf0e10cSrcweir SvxAuthorType eT, SvxAuthorFormat eF ) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir aName = rLastName; 855*cdf0e10cSrcweir aFirstName = rFirstName; 856*cdf0e10cSrcweir aShortName = rShortName; 857*cdf0e10cSrcweir eType = eT; 858*cdf0e10cSrcweir eFormat = eF; 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir //---------------------------------------------------------------------------- 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir SvxFieldData* SvxAuthorField::Clone() const 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir return new SvxAuthorField( *this ); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir //---------------------------------------------------------------------------- 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir int SvxAuthorField::operator==( const SvxFieldData& rOther ) const 871*cdf0e10cSrcweir { 872*cdf0e10cSrcweir if ( rOther.Type() != Type() ) 873*cdf0e10cSrcweir return sal_False; 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir const SvxAuthorField& rOtherFld = (const SvxAuthorField&) rOther; 876*cdf0e10cSrcweir return ( ( aName == rOtherFld.aName ) && 877*cdf0e10cSrcweir ( aFirstName == rOtherFld.aFirstName ) && 878*cdf0e10cSrcweir ( aShortName == rOtherFld.aShortName ) && 879*cdf0e10cSrcweir ( eType == rOtherFld.eType ) && 880*cdf0e10cSrcweir ( eFormat == rOtherFld.eFormat ) ); 881*cdf0e10cSrcweir } 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir //---------------------------------------------------------------------------- 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir void SvxAuthorField::Load( SvPersistStream & rStm ) 886*cdf0e10cSrcweir { 887*cdf0e10cSrcweir sal_uInt16 nType = 0, nFormat = 0; 888*cdf0e10cSrcweir 889*cdf0e10cSrcweir read_unicode( rStm, aName ); 890*cdf0e10cSrcweir read_unicode( rStm, aFirstName ); 891*cdf0e10cSrcweir read_unicode( rStm, aShortName ); 892*cdf0e10cSrcweir 893*cdf0e10cSrcweir rStm >> nType; 894*cdf0e10cSrcweir rStm >> nFormat; 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir eType = (SvxAuthorType) nType; 897*cdf0e10cSrcweir eFormat= (SvxAuthorFormat) nFormat; 898*cdf0e10cSrcweir } 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir //---------------------------------------------------------------------------- 901*cdf0e10cSrcweir 902*cdf0e10cSrcweir void SvxAuthorField::Save( SvPersistStream & rStm ) 903*cdf0e10cSrcweir { 904*cdf0e10cSrcweir write_unicode( rStm, aName ); 905*cdf0e10cSrcweir write_unicode( rStm, aFirstName ); 906*cdf0e10cSrcweir write_unicode( rStm, aShortName ); 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir rStm << (sal_uInt16) eType; 909*cdf0e10cSrcweir rStm << (sal_uInt16) eFormat; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir //---------------------------------------------------------------------------- 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir XubString SvxAuthorField::GetFormatted() const 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir XubString aString; 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir switch( eFormat ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir case SVXAUTHORFORMAT_FULLNAME: 921*cdf0e10cSrcweir aString = aFirstName; 922*cdf0e10cSrcweir aString += sal_Unicode(' '); 923*cdf0e10cSrcweir aString += aName; 924*cdf0e10cSrcweir break; 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir case SVXAUTHORFORMAT_NAME: 927*cdf0e10cSrcweir aString = aName; 928*cdf0e10cSrcweir break; 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir case SVXAUTHORFORMAT_FIRSTNAME: 931*cdf0e10cSrcweir aString = aFirstName; 932*cdf0e10cSrcweir break; 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir case SVXAUTHORFORMAT_SHORTNAME: 935*cdf0e10cSrcweir aString = aShortName; 936*cdf0e10cSrcweir break; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir return( aString ); 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir static SvClassManager* pClassMgr=0; 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir SvClassManager& SvxFieldItem::GetClassManager() 945*cdf0e10cSrcweir { 946*cdf0e10cSrcweir if ( !pClassMgr ) 947*cdf0e10cSrcweir { 948*cdf0e10cSrcweir pClassMgr = new SvClassManager; 949*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxFieldData ); 950*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxURLField ); 951*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxDateField ); 952*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxPageField ); 953*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxTimeField ); 954*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxExtTimeField ); 955*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxExtFileField ); 956*cdf0e10cSrcweir pClassMgr->SV_CLASS_REGISTER( SvxAuthorField ); 957*cdf0e10cSrcweir } 958*cdf0e10cSrcweir 959*cdf0e10cSrcweir return *pClassMgr; 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxHeaderField, SvxFieldData ); 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxHeaderField::Clone() const 967*cdf0e10cSrcweir { 968*cdf0e10cSrcweir return new SvxHeaderField; // leer 969*cdf0e10cSrcweir } 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir int __EXPORT SvxHeaderField::operator==( const SvxFieldData& rCmp ) const 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxHeaderField) ); 974*cdf0e10cSrcweir } 975*cdf0e10cSrcweir 976*cdf0e10cSrcweir void __EXPORT SvxHeaderField::Load( SvPersistStream & /*rStm*/ ) 977*cdf0e10cSrcweir { 978*cdf0e10cSrcweir } 979*cdf0e10cSrcweir 980*cdf0e10cSrcweir void __EXPORT SvxHeaderField::Save( SvPersistStream & /*rStm*/ ) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxFooterField, SvxFieldData ); 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxFooterField::Clone() const 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir return new SvxFooterField; // leer 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir int __EXPORT SvxFooterField::operator==( const SvxFieldData& rCmp ) const 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxFooterField) ); 996*cdf0e10cSrcweir } 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir void __EXPORT SvxFooterField::Load( SvPersistStream & /*rStm*/ ) 999*cdf0e10cSrcweir { 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir void __EXPORT SvxFooterField::Save( SvPersistStream & /*rStm*/ ) 1003*cdf0e10cSrcweir { 1004*cdf0e10cSrcweir } 1005*cdf0e10cSrcweir 1006*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir SV_IMPL_PERSIST1( SvxDateTimeField, SvxFieldData ); 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir SvxFieldData* __EXPORT SvxDateTimeField::Clone() const 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir return new SvxDateTimeField; // leer 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir int __EXPORT SvxDateTimeField::operator==( const SvxFieldData& rCmp ) const 1016*cdf0e10cSrcweir { 1017*cdf0e10cSrcweir return ( rCmp.Type() == TYPE(SvxDateTimeField) ); 1018*cdf0e10cSrcweir } 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir void __EXPORT SvxDateTimeField::Load( SvPersistStream & /*rStm*/ ) 1021*cdf0e10cSrcweir { 1022*cdf0e10cSrcweir } 1023*cdf0e10cSrcweir 1024*cdf0e10cSrcweir void __EXPORT SvxDateTimeField::Save( SvPersistStream & /*rStm*/ ) 1025*cdf0e10cSrcweir { 1026*cdf0e10cSrcweir } 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir String SvxDateTimeField::GetFormatted( Date& rDate, Time& rTime, int eFormat, SvNumberFormatter& rFormatter, LanguageType eLanguage ) 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir String aRet; 1031*cdf0e10cSrcweir 1032*cdf0e10cSrcweir SvxDateFormat eDateFormat = (SvxDateFormat)(eFormat & 0x0f); 1033*cdf0e10cSrcweir 1034*cdf0e10cSrcweir if(eDateFormat) 1035*cdf0e10cSrcweir { 1036*cdf0e10cSrcweir aRet = SvxDateField::GetFormatted( rDate, eDateFormat, rFormatter, eLanguage ); 1037*cdf0e10cSrcweir } 1038*cdf0e10cSrcweir 1039*cdf0e10cSrcweir SvxTimeFormat eTimeFormat = (SvxTimeFormat)((eFormat >> 4) & 0x0f); 1040*cdf0e10cSrcweir 1041*cdf0e10cSrcweir if(eTimeFormat) 1042*cdf0e10cSrcweir { 1043*cdf0e10cSrcweir if(aRet.Len()) 1044*cdf0e10cSrcweir aRet += sal_Unicode(' '); 1045*cdf0e10cSrcweir 1046*cdf0e10cSrcweir aRet += SvxExtTimeField::GetFormatted( rTime, eTimeFormat, rFormatter, eLanguage ); 1047*cdf0e10cSrcweir } 1048*cdf0e10cSrcweir 1049*cdf0e10cSrcweir return aRet; 1050*cdf0e10cSrcweir } 1051*cdf0e10cSrcweir 1052