1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: flditem.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <vcl/metaact.hxx>
34 #include <svtools/zforlist.hxx>
35 #include <tools/urlobj.hxx>
37 #define _SVX_FLDITEM_CXX
38 #include <unotools/localfilehelper.hxx>
40 #include <svx/flditem.hxx>
42 #include <svx/svdfield.hxx>
45 #include <tools/tenccvt.hxx>
47 #define FRAME_MARKER (sal_uInt32)0x21981357
48 #define CHARSET_MARKER (FRAME_MARKER+1)
50 // -----------------------------------------------------------------------
52 TYPEINIT1( SvxFieldItem
, SfxPoolItem
);
54 SV_IMPL_PERSIST1( SvxFieldData
, SvPersistBase
);
56 // -----------------------------------------------------------------------
58 SvxFieldData::SvxFieldData()
62 // -----------------------------------------------------------------------
64 SvxFieldData::~SvxFieldData()
68 // -----------------------------------------------------------------------
70 SvxFieldData
* SvxFieldData::Clone() const
72 return new SvxFieldData
;
75 // -----------------------------------------------------------------------
77 int SvxFieldData::operator==( const SvxFieldData
& rFld
) const
79 DBG_ASSERT( Type() == rFld
.Type(), "==: Verschiedene Typen" );
81 return TRUE
; // Basicklasse immer gleich.
84 // -----------------------------------------------------------------------
86 void SvxFieldData::Load( SvPersistStream
& /*rStm*/ )
90 // -----------------------------------------------------------------------
92 void SvxFieldData::Save( SvPersistStream
& /*rStm*/ )
97 MetaAction
* SvxFieldData::createBeginComment() const
99 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
102 MetaAction
* SvxFieldData::createEndComment() const
104 return new MetaCommentAction( "FIELD_SEQ_END" );
107 // -----------------------------------------------------------------------
109 SvxFieldItem::SvxFieldItem( SvxFieldData
* pFld
, const USHORT nId
) :
112 pField
= pFld
; // gehoert direkt dem Item
115 // -----------------------------------------------------------------------
117 SvxFieldItem::SvxFieldItem( const SvxFieldData
& rField
, const USHORT nId
) :
120 pField
= rField
.Clone();
123 // -----------------------------------------------------------------------
125 SvxFieldItem::SvxFieldItem( const SvxFieldItem
& rItem
) :
126 SfxPoolItem ( rItem
)
128 pField
= rItem
.GetField() ? rItem
.GetField()->Clone() : 0;
131 // -----------------------------------------------------------------------
133 SvxFieldItem::~SvxFieldItem()
138 // -----------------------------------------------------------------------
140 SfxPoolItem
* SvxFieldItem::Clone( SfxItemPool
* ) const
142 return new SvxFieldItem(*this);
145 // -----------------------------------------------------------------------
147 SfxPoolItem
* SvxFieldItem::Create( SvStream
& rStrm
, USHORT
) const
149 SvxFieldData
* pData
= 0;
150 SvPersistStream
aPStrm( GetClassManager(), &rStrm
);
154 aPStrm
.SetError( SVSTREAM_GENERALERROR
);
156 if ( aPStrm
.GetError() == ERRCODE_IO_NOFACTORY
)
157 aPStrm
.ResetError(); // Eigentlich einen Code, dass nicht alle Attr gelesen wurden...
159 return new SvxFieldItem( pData
, Which() );
162 // -----------------------------------------------------------------------
164 SvStream
& SvxFieldItem::Store( SvStream
& rStrm
, USHORT
/*nItemVersion*/ ) const
166 DBG_ASSERT( pField
, "SvxFieldItem::Store: Feld?!" );
167 SvPersistStream
aPStrm( GetClassManager(), &rStrm
);
168 // Das ResetError in der obigen Create-Methode gab es in 3.1 noch nicht,
169 // deshalb duerfen beim 3.x-Export neuere Items nicht gespeichert werden!
170 if ( ( rStrm
.GetVersion() <= SOFFICE_FILEFORMAT_31
) && pField
&&
171 pField
->GetClassId() == 50 /* SdrMeasureField */ )
173 // SvxFieldData reicht nicht, weil auch nicht am ClassMgr angemeldet
174 SvxURLField aDummyData
;
175 aPStrm
<< &aDummyData
;
183 // -----------------------------------------------------------------------
185 int SvxFieldItem::operator==( const SfxPoolItem
& rItem
) const
187 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal which or type" );
189 const SvxFieldData
* pOtherFld
= ((const SvxFieldItem
&)rItem
).GetField();
190 if ( !pField
&& !pOtherFld
)
193 if ( ( !pField
&& pOtherFld
) || ( pField
&& !pOtherFld
) )
196 return ( ( pField
->Type() == pOtherFld
->Type() )
197 && ( *pField
== *pOtherFld
) );
200 // =================================================================
201 // Es folgen die Ableitungen von SvxFieldData...
202 // =================================================================
204 SV_IMPL_PERSIST1( SvxDateField
, SvxFieldData
);
206 // -----------------------------------------------------------------------
208 SvxDateField::SvxDateField()
210 nFixDate
= Date().GetDate();
211 eType
= SVXDATETYPE_VAR
;
212 eFormat
= SVXDATEFORMAT_STDSMALL
;
215 // -----------------------------------------------------------------------
217 SvxDateField::SvxDateField( const Date
& rDate
, SvxDateType eT
, SvxDateFormat eF
)
219 nFixDate
= rDate
.GetDate();
224 // -----------------------------------------------------------------------
226 SvxFieldData
* SvxDateField::Clone() const
228 return new SvxDateField( *this );
231 // -----------------------------------------------------------------------
233 int SvxDateField::operator==( const SvxFieldData
& rOther
) const
235 if ( rOther
.Type() != Type() )
238 const SvxDateField
& rOtherFld
= (const SvxDateField
&) rOther
;
239 return ( ( nFixDate
== rOtherFld
.nFixDate
) &&
240 ( eType
== rOtherFld
.eType
) &&
241 ( eFormat
== rOtherFld
.eFormat
) );
244 // -----------------------------------------------------------------------
246 void SvxDateField::Load( SvPersistStream
& rStm
)
248 USHORT nType
, nFormat
;
254 eType
= (SvxDateType
)nType
;
255 eFormat
= (SvxDateFormat
)nFormat
;
258 // -----------------------------------------------------------------------
260 void SvxDateField::Save( SvPersistStream
& rStm
)
263 rStm
<< (USHORT
)eType
;
264 rStm
<< (USHORT
)eFormat
;
267 // -----------------------------------------------------------------------
269 String
SvxDateField::GetFormatted( SvNumberFormatter
& rFormatter
, LanguageType eLang
) const
271 Date aDate
; // current date
272 if ( eType
== SVXDATETYPE_FIX
)
273 aDate
.SetDate( nFixDate
);
275 return GetFormatted( aDate
, eFormat
, rFormatter
, eLang
);
278 String
SvxDateField::GetFormatted( Date
& aDate
, SvxDateFormat eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLang
)
280 if ( eFormat
== SVXDATEFORMAT_SYSTEM
)
282 DBG_ERROR( "SVXDATEFORMAT_SYSTEM nicht implementiert!" );
283 eFormat
= SVXDATEFORMAT_STDSMALL
;
285 else if ( eFormat
== SVXDATEFORMAT_APPDEFAULT
)
287 DBG_ERROR( "SVXDATEFORMAT_APPDEFAULT: Woher nehmen?" );
288 eFormat
= SVXDATEFORMAT_STDSMALL
;
295 case SVXDATEFORMAT_STDSMALL
:
297 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYSTEM_SHORT
, eLang
);
299 case SVXDATEFORMAT_STDBIG
:
301 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYSTEM_LONG
, eLang
);
303 case SVXDATEFORMAT_A
:
305 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYY
, eLang
);
307 case SVXDATEFORMAT_B
:
309 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_DDMMYYYY
, eLang
);
311 case SVXDATEFORMAT_C
:
313 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_DMMMYYYY
, eLang
);
315 case SVXDATEFORMAT_D
:
317 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_DMMMMYYYY
, eLang
);
319 case SVXDATEFORMAT_E
:
320 // Die, 13. Februar 1996
321 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_NNDMMMMYYYY
, eLang
);
323 case SVXDATEFORMAT_F
:
324 // Dienstag, 13. Februar 1996
325 nFormatKey
= rFormatter
.GetFormatIndex( NF_DATE_SYS_NNNNDMMMMYYYY
, eLang
);
328 nFormatKey
= rFormatter
.GetStandardFormat( NUMBERFORMAT_DATE
, eLang
);
331 double fDiffDate
= aDate
- *(rFormatter
.GetNullDate());
333 Color
* pColor
= NULL
;
334 rFormatter
.GetOutputString( fDiffDate
, nFormatKey
, aStr
, &pColor
);
338 MetaAction
* SvxDateField::createBeginComment() const
340 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
343 SV_IMPL_PERSIST1( SvxURLField
, SvxFieldData
);
345 // -----------------------------------------------------------------------
347 SvxURLField::SvxURLField()
349 eFormat
= SVXURLFORMAT_URL
;
352 // -----------------------------------------------------------------------
354 SvxURLField::SvxURLField( const XubString
& rURL
, const XubString
& rRepres
, SvxURLFormat eFmt
)
355 : aURL( rURL
), aRepresentation( rRepres
)
360 // -----------------------------------------------------------------------
362 SvxFieldData
* SvxURLField::Clone() const
364 return new SvxURLField( *this );
367 // -----------------------------------------------------------------------
369 int SvxURLField::operator==( const SvxFieldData
& rOther
) const
371 if ( rOther
.Type() != Type() )
374 const SvxURLField
& rOtherFld
= (const SvxURLField
&) rOther
;
375 return ( ( eFormat
== rOtherFld
.eFormat
) &&
376 ( aURL
== rOtherFld
.aURL
) &&
377 ( aRepresentation
== rOtherFld
.aRepresentation
) &&
378 ( aTargetFrame
== rOtherFld
.aTargetFrame
) );
381 // -----------------------------------------------------------------------
383 void SvxURLField::Load( SvPersistStream
& rStm
)
386 sal_uInt32 nFrameMarker
, nCharSetMarker
;
387 long nUlongSize
= (long)sizeof(sal_uInt32
);
392 // UNICODE: rStm >> aTmpURL;
393 rStm
.ReadByteString(aTmpURL
);
395 // UNICODE: rStm >> aRepresentation;
396 // read to a temp string first, read text encoding and
397 // convert later to stay compatible to fileformat
398 ByteString aTempString
;
399 rtl_TextEncoding aTempEncoding
= RTL_TEXTENCODING_MS_1252
; // #101493# Init for old documents
400 rStm
.ReadByteString(aTempString
);
402 rStm
>> nFrameMarker
;
403 if ( nFrameMarker
== FRAME_MARKER
)
405 // UNICODE: rStm >> aTargetFrame;
406 rStm
.ReadByteString(aTargetFrame
);
408 rStm
>> nCharSetMarker
;
409 if ( nCharSetMarker
== CHARSET_MARKER
)
415 aTempEncoding
= (rtl_TextEncoding
)nCharSet
;
418 rStm
.SeekRel( -nUlongSize
);
421 rStm
.SeekRel( -nUlongSize
);
423 // now build representation string due to known encoding
424 aRepresentation
= String(aTempString
, aTempEncoding
);
426 eFormat
= (SvxURLFormat
)nFormat
;
428 // Relatives Speichern => Beim laden absolut machen.
429 DBG_ERROR("No BaseURL!");
430 // TODO/MBA: no BaseURL
431 aURL
= INetURLObject::GetAbsURL( String(), aTmpURL
);
434 // -----------------------------------------------------------------------
436 void SvxURLField::Save( SvPersistStream
& rStm
)
438 // Relatives Speichern der URL
439 DBG_ERROR("No BaseURL!");
440 // TODO/MBA: no BaseURL
441 String aTmpURL
= INetURLObject::GetRelURL( String(), aURL
);
443 rStm
<< (USHORT
)eFormat
;
445 // UNICODE: rStm << aTmpURL;
446 rStm
.WriteByteString(aTmpURL
);
448 // UNICODE: rStm << aRepresentation;
449 rStm
.WriteByteString(aRepresentation
);
451 rStm
<< FRAME_MARKER
;
453 // UNICODE: rStm << aTargetFrame;
454 rStm
.WriteByteString(aTargetFrame
);
456 rStm
<< CHARSET_MARKER
;
458 // #90477# rStm << (USHORT)GetStoreCharSet(gsl_getSystemTextEncoding(), rStm.GetVersion());
459 rStm
<< (USHORT
)GetSOStoreTextEncoding(gsl_getSystemTextEncoding(), (sal_uInt16
)rStm
.GetVersion());
462 MetaAction
* SvxURLField::createBeginComment() const
464 // #i46618# Adding target URL to metafile comment
465 return new MetaCommentAction( "FIELD_SEQ_BEGIN",
467 reinterpret_cast<const BYTE
*>(aURL
.GetBuffer()),
471 // =================================================================
472 // Die Felder, die aus Calc ausgebaut wurden:
473 // =================================================================
475 SV_IMPL_PERSIST1( SvxPageField
, SvxFieldData
);
477 SvxFieldData
* __EXPORT
SvxPageField::Clone() const
479 return new SvxPageField
; // leer
482 int __EXPORT
SvxPageField::operator==( const SvxFieldData
& rCmp
) const
484 return ( rCmp
.Type() == TYPE(SvxPageField
) );
487 void __EXPORT
SvxPageField::Load( SvPersistStream
& /*rStm*/ )
491 void __EXPORT
SvxPageField::Save( SvPersistStream
& /*rStm*/ )
495 MetaAction
* SvxPageField::createBeginComment() const
497 return new MetaCommentAction( "FIELD_SEQ_BEGIN;PageField" );
501 SV_IMPL_PERSIST1( SvxPagesField
, SvxFieldData
);
503 SvxFieldData
* __EXPORT
SvxPagesField::Clone() const
505 return new SvxPagesField
; // leer
508 int __EXPORT
SvxPagesField::operator==( const SvxFieldData
& rCmp
) const
510 return ( rCmp
.Type() == TYPE(SvxPagesField
) );
513 void __EXPORT
SvxPagesField::Load( SvPersistStream
& /*rStm*/ )
517 void __EXPORT
SvxPagesField::Save( SvPersistStream
& /*rStm*/ )
521 SV_IMPL_PERSIST1( SvxTimeField
, SvxFieldData
);
523 SvxFieldData
* __EXPORT
SvxTimeField::Clone() const
525 return new SvxTimeField
; // leer
528 int __EXPORT
SvxTimeField::operator==( const SvxFieldData
& rCmp
) const
530 return ( rCmp
.Type() == TYPE(SvxTimeField
) );
533 void __EXPORT
SvxTimeField::Load( SvPersistStream
& /*rStm*/ )
537 void __EXPORT
SvxTimeField::Save( SvPersistStream
& /*rStm*/ )
541 MetaAction
* SvxTimeField::createBeginComment() const
543 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
546 SV_IMPL_PERSIST1( SvxFileField
, SvxFieldData
);
548 SvxFieldData
* __EXPORT
SvxFileField::Clone() const
550 return new SvxFileField
; // leer
553 int __EXPORT
SvxFileField::operator==( const SvxFieldData
& rCmp
) const
555 return ( rCmp
.Type() == TYPE(SvxFileField
) );
558 void __EXPORT
SvxFileField::Load( SvPersistStream
& /*rStm*/ )
562 void __EXPORT
SvxFileField::Save( SvPersistStream
& /*rStm*/ )
566 SV_IMPL_PERSIST1( SvxTableField
, SvxFieldData
);
568 SvxFieldData
* __EXPORT
SvxTableField::Clone() const
570 return new SvxTableField
; // leer
573 int __EXPORT
SvxTableField::operator==( const SvxFieldData
& rCmp
) const
575 return ( rCmp
.Type() == TYPE(SvxTableField
) );
578 void __EXPORT
SvxTableField::Load( SvPersistStream
& /*rStm*/ )
582 void __EXPORT
SvxTableField::Save( SvPersistStream
& /*rStm*/ )
586 //----------------------------------------------------------------------------
588 //----------------------------------------------------------------------------
590 SV_IMPL_PERSIST1( SvxExtTimeField
, SvxFieldData
);
592 //----------------------------------------------------------------------------
594 SvxExtTimeField::SvxExtTimeField()
596 nFixTime
= Time().GetTime();
597 eType
= SVXTIMETYPE_VAR
;
598 eFormat
= SVXTIMEFORMAT_STANDARD
;
601 //----------------------------------------------------------------------------
603 SvxExtTimeField::SvxExtTimeField( const Time
& rTime
, SvxTimeType eT
, SvxTimeFormat eF
)
605 nFixTime
= rTime
.GetTime();
610 //----------------------------------------------------------------------------
612 SvxFieldData
* SvxExtTimeField::Clone() const
614 return new SvxExtTimeField( *this );
617 //----------------------------------------------------------------------------
619 int SvxExtTimeField::operator==( const SvxFieldData
& rOther
) const
621 if ( rOther
.Type() != Type() )
624 const SvxExtTimeField
& rOtherFld
= (const SvxExtTimeField
&) rOther
;
625 return ( ( nFixTime
== rOtherFld
.nFixTime
) &&
626 ( eType
== rOtherFld
.eType
) &&
627 ( eFormat
== rOtherFld
.eFormat
) );
630 //----------------------------------------------------------------------------
632 void SvxExtTimeField::Load( SvPersistStream
& rStm
)
634 USHORT nType
, nFormat
;
640 eType
= (SvxTimeType
) nType
;
641 eFormat
= (SvxTimeFormat
) nFormat
;
644 //----------------------------------------------------------------------------
646 void SvxExtTimeField::Save( SvPersistStream
& rStm
)
649 rStm
<< (USHORT
) eType
;
650 rStm
<< (USHORT
) eFormat
;
653 //----------------------------------------------------------------------------
655 String
SvxExtTimeField::GetFormatted( SvNumberFormatter
& rFormatter
, LanguageType eLang
) const
657 Time aTime
; // current time
658 if ( eType
== SVXTIMETYPE_FIX
)
659 aTime
.SetTime( nFixTime
);
660 return GetFormatted( aTime
, eFormat
, rFormatter
, eLang
);
663 String
SvxExtTimeField::GetFormatted( Time
& aTime
, SvxTimeFormat eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLang
)
667 case SVXTIMEFORMAT_SYSTEM
:
668 DBG_ERROR( "SVXTIMEFORMAT_SYSTEM: not implemented" );
669 eFormat
= SVXTIMEFORMAT_STANDARD
;
671 case SVXTIMEFORMAT_APPDEFAULT
:
672 DBG_ERROR( "SVXTIMEFORMAT_APPDEFAULT: not implemented" );
673 eFormat
= SVXTIMEFORMAT_STANDARD
;
675 default: ;//prevent warning
678 sal_uInt32 nFormatKey
;
682 case SVXTIMEFORMAT_12_HM
:
683 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HHMMAMPM
, eLang
);
685 case SVXTIMEFORMAT_12_HMSH
:
686 { // no builtin format available, try to insert or reuse
687 String
aFormatCode( RTL_CONSTASCII_USTRINGPARAM( "HH:MM:SS.00 AM/PM" ) );
688 xub_StrLen nCheckPos
;
690 /*BOOL bInserted = */rFormatter
.PutandConvertEntry( aFormatCode
,
691 nCheckPos
, nType
, nFormatKey
, LANGUAGE_ENGLISH_US
, eLang
);
692 DBG_ASSERT( nCheckPos
== 0, "SVXTIMEFORMAT_12_HMSH: could not insert format code" );
694 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HH_MMSS00
, eLang
);
697 case SVXTIMEFORMAT_24_HM
:
698 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HHMM
, eLang
);
700 case SVXTIMEFORMAT_24_HMSH
:
701 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HH_MMSS00
, eLang
);
703 case SVXTIMEFORMAT_12_HMS
:
704 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HHMMSSAMPM
, eLang
);
706 case SVXTIMEFORMAT_24_HMS
:
707 nFormatKey
= rFormatter
.GetFormatIndex( NF_TIME_HHMMSS
, eLang
);
709 case SVXTIMEFORMAT_STANDARD
:
711 nFormatKey
= rFormatter
.GetStandardFormat( NUMBERFORMAT_TIME
, eLang
);
714 double fFracTime
= aTime
.GetTimeInDays();
716 Color
* pColor
= NULL
;
717 rFormatter
.GetOutputString( fFracTime
, nFormatKey
, aStr
, &pColor
);
721 MetaAction
* SvxExtTimeField::createBeginComment() const
723 return new MetaCommentAction( "FIELD_SEQ_BEGIN" );
726 //----------------------------------------------------------------------------
728 //----------------------------------------------------------------------------
730 SV_IMPL_PERSIST1( SvxExtFileField
, SvxFieldData
);
732 //----------------------------------------------------------------------------
734 SvxExtFileField::SvxExtFileField()
736 eType
= SVXFILETYPE_VAR
;
737 eFormat
= SVXFILEFORMAT_FULLPATH
;
740 //----------------------------------------------------------------------------
742 SvxExtFileField::SvxExtFileField( const XubString
& rStr
, SvxFileType eT
, SvxFileFormat eF
)
749 //----------------------------------------------------------------------------
751 SvxFieldData
* SvxExtFileField::Clone() const
753 return new SvxExtFileField( *this );
756 //----------------------------------------------------------------------------
758 int SvxExtFileField::operator==( const SvxFieldData
& rOther
) const
760 if ( rOther
.Type() != Type() )
763 const SvxExtFileField
& rOtherFld
= (const SvxExtFileField
&) rOther
;
764 return ( ( aFile
== rOtherFld
.aFile
) &&
765 ( eType
== rOtherFld
.eType
) &&
766 ( eFormat
== rOtherFld
.eFormat
) );
769 //----------------------------------------------------------------------------
771 void SvxExtFileField::Load( SvPersistStream
& rStm
)
773 USHORT nType
, nFormat
;
775 // UNICODE: rStm >> aFile;
776 rStm
.ReadByteString(aFile
);
781 eType
= (SvxFileType
) nType
;
782 eFormat
= (SvxFileFormat
) nFormat
;
785 //----------------------------------------------------------------------------
787 void SvxExtFileField::Save( SvPersistStream
& rStm
)
789 // UNICODE: rStm << aFile;
790 rStm
.WriteByteString(aFile
);
792 rStm
<< (USHORT
) eType
;
793 rStm
<< (USHORT
) eFormat
;
796 //----------------------------------------------------------------------------
798 XubString
SvxExtFileField::GetFormatted() const
802 INetURLObject
aURLObj( aFile
);
804 if( INET_PROT_NOT_VALID
== aURLObj
.GetProtocol() )
806 // invalid? try to interpret string as system file name
809 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile
, aURLStr
);
811 aURLObj
.SetURL( aURLStr
);
814 // #92009# Be somewhat liberate when trying to
815 // get formatted content out of the FileField
816 if( INET_PROT_NOT_VALID
== aURLObj
.GetProtocol() )
818 // still not valid? Then output as is
821 else if( INET_PROT_FILE
== aURLObj
.GetProtocol() )
825 case SVXFILEFORMAT_FULLPATH
:
826 aString
= aURLObj
.getFSysPath(INetURLObject::FSYS_DETECT
);
829 case SVXFILEFORMAT_PATH
:
830 aURLObj
.removeSegment(INetURLObject::LAST_SEGMENT
, false);
831 // #101742# Leave trailing slash at the pathname
832 aURLObj
.setFinalSlash();
833 aString
= aURLObj
.getFSysPath(INetURLObject::FSYS_DETECT
);
836 case SVXFILEFORMAT_NAME
:
837 aString
= aURLObj
.getBase(INetURLObject::LAST_SEGMENT
,true,INetURLObject::DECODE_UNAMBIGUOUS
);
840 case SVXFILEFORMAT_NAME_EXT
:
841 aString
= aURLObj
.getName(INetURLObject::LAST_SEGMENT
,true,INetURLObject::DECODE_UNAMBIGUOUS
);
849 case SVXFILEFORMAT_FULLPATH
:
850 aString
= aURLObj
.GetMainURL( INetURLObject::DECODE_TO_IURI
);
853 case SVXFILEFORMAT_PATH
:
854 aURLObj
.removeSegment(INetURLObject::LAST_SEGMENT
, false);
855 // #101742# Leave trailing slash at the pathname
856 aURLObj
.setFinalSlash();
857 aString
= aURLObj
.GetMainURL( INetURLObject::DECODE_TO_IURI
);
860 case SVXFILEFORMAT_NAME
:
861 aString
= aURLObj
.getBase();
864 case SVXFILEFORMAT_NAME_EXT
:
865 aString
= aURLObj
.getName();
873 //----------------------------------------------------------------------------
875 //----------------------------------------------------------------------------
877 SV_IMPL_PERSIST1( SvxAuthorField
, SvxFieldData
);
879 //----------------------------------------------------------------------------
881 SvxAuthorField::SvxAuthorField()
883 eType
= SVXAUTHORTYPE_VAR
;
884 eFormat
= SVXAUTHORFORMAT_FULLNAME
;
887 //----------------------------------------------------------------------------
889 SvxAuthorField::SvxAuthorField( const XubString
& rFirstName
,
890 const XubString
& rLastName
,
891 const XubString
& rShortName
,
892 SvxAuthorType eT
, SvxAuthorFormat eF
)
895 aFirstName
= rFirstName
;
896 aShortName
= rShortName
;
901 //----------------------------------------------------------------------------
903 SvxFieldData
* SvxAuthorField::Clone() const
905 return new SvxAuthorField( *this );
908 //----------------------------------------------------------------------------
910 int SvxAuthorField::operator==( const SvxFieldData
& rOther
) const
912 if ( rOther
.Type() != Type() )
915 const SvxAuthorField
& rOtherFld
= (const SvxAuthorField
&) rOther
;
916 return ( ( aName
== rOtherFld
.aName
) &&
917 ( aFirstName
== rOtherFld
.aFirstName
) &&
918 ( aShortName
== rOtherFld
.aShortName
) &&
919 ( eType
== rOtherFld
.eType
) &&
920 ( eFormat
== rOtherFld
.eFormat
) );
923 //----------------------------------------------------------------------------
925 void SvxAuthorField::Load( SvPersistStream
& rStm
)
927 USHORT nType
, nFormat
;
929 // UNICODE: rStm >> aName;
930 rStm
.ReadByteString(aName
);
932 // UNICODE: rStm >> aFirstName;
933 rStm
.ReadByteString(aFirstName
);
935 // UNICODE: rStm >> aShortName;
936 rStm
.ReadByteString(aShortName
);
941 eType
= (SvxAuthorType
) nType
;
942 eFormat
= (SvxAuthorFormat
) nFormat
;
945 //----------------------------------------------------------------------------
947 void SvxAuthorField::Save( SvPersistStream
& rStm
)
949 // UNICODE: rStm << aName;
950 rStm
.WriteByteString(aName
);
952 // UNICODE: rStm << aFirstName;
953 rStm
.WriteByteString(aFirstName
);
955 // UNICODE: rStm << aShortName;
956 rStm
.WriteByteString(aShortName
);
958 rStm
<< (USHORT
) eType
;
959 rStm
<< (USHORT
) eFormat
;
962 //----------------------------------------------------------------------------
964 XubString
SvxAuthorField::GetFormatted() const
970 case SVXAUTHORFORMAT_FULLNAME
:
971 aString
= aFirstName
;
972 aString
+= sal_Unicode(' ');
976 case SVXAUTHORFORMAT_NAME
:
980 case SVXAUTHORFORMAT_FIRSTNAME
:
981 aString
= aFirstName
;
984 case SVXAUTHORFORMAT_SHORTNAME
:
985 aString
= aShortName
;
992 static SvClassManager
* pClassMgr
=0;
994 SvClassManager
& SvxFieldItem::GetClassManager()
998 pClassMgr
= new SvClassManager
;
999 pClassMgr
->SV_CLASS_REGISTER( SvxFieldData
);
1000 pClassMgr
->SV_CLASS_REGISTER( SvxURLField
);
1001 pClassMgr
->SV_CLASS_REGISTER( SvxDateField
);
1002 pClassMgr
->SV_CLASS_REGISTER( SvxPageField
);
1003 pClassMgr
->SV_CLASS_REGISTER( SvxTimeField
);
1004 pClassMgr
->SV_CLASS_REGISTER( SvxExtTimeField
);
1005 pClassMgr
->SV_CLASS_REGISTER( SvxExtFileField
);
1006 pClassMgr
->SV_CLASS_REGISTER( SvxAuthorField
);
1012 ///////////////////////////////////////////////////////////////////////
1014 SV_IMPL_PERSIST1( SvxHeaderField
, SvxFieldData
);
1016 SvxFieldData
* __EXPORT
SvxHeaderField::Clone() const
1018 return new SvxHeaderField
; // leer
1021 int __EXPORT
SvxHeaderField::operator==( const SvxFieldData
& rCmp
) const
1023 return ( rCmp
.Type() == TYPE(SvxHeaderField
) );
1026 void __EXPORT
SvxHeaderField::Load( SvPersistStream
& /*rStm*/ )
1030 void __EXPORT
SvxHeaderField::Save( SvPersistStream
& /*rStm*/ )
1034 ///////////////////////////////////////////////////////////////////////
1036 SV_IMPL_PERSIST1( SvxFooterField
, SvxFieldData
);
1038 SvxFieldData
* __EXPORT
SvxFooterField::Clone() const
1040 return new SvxFooterField
; // leer
1043 int __EXPORT
SvxFooterField::operator==( const SvxFieldData
& rCmp
) const
1045 return ( rCmp
.Type() == TYPE(SvxFooterField
) );
1048 void __EXPORT
SvxFooterField::Load( SvPersistStream
& /*rStm*/ )
1052 void __EXPORT
SvxFooterField::Save( SvPersistStream
& /*rStm*/ )
1056 ///////////////////////////////////////////////////////////////////////
1058 SV_IMPL_PERSIST1( SvxDateTimeField
, SvxFieldData
);
1060 SvxFieldData
* __EXPORT
SvxDateTimeField::Clone() const
1062 return new SvxDateTimeField
; // leer
1065 int __EXPORT
SvxDateTimeField::operator==( const SvxFieldData
& rCmp
) const
1067 return ( rCmp
.Type() == TYPE(SvxDateTimeField
) );
1070 void __EXPORT
SvxDateTimeField::Load( SvPersistStream
& /*rStm*/ )
1074 void __EXPORT
SvxDateTimeField::Save( SvPersistStream
& /*rStm*/ )
1078 String
SvxDateTimeField::GetFormatted( Date
& rDate
, Time
& rTime
, int eFormat
, SvNumberFormatter
& rFormatter
, LanguageType eLanguage
)
1082 SvxDateFormat eDateFormat
= (SvxDateFormat
)(eFormat
& 0x0f);
1086 aRet
= SvxDateField::GetFormatted( rDate
, eDateFormat
, rFormatter
, eLanguage
);
1089 SvxTimeFormat eTimeFormat
= (SvxTimeFormat
)((eFormat
>> 4) & 0x0f);
1094 aRet
+= sal_Unicode(' ');
1096 aRet
+= SvxExtTimeField::GetFormatted( rTime
, eTimeFormat
, rFormatter
, eLanguage
);