1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SW_FLDDAT_HXX 29 #define SW_FLDDAT_HXX 30 31 #include <tools/string.hxx> 32 33 #include "fldbas.hxx" 34 35 class DateTime; 36 class Date; 37 class Time; 38 39 /*-------------------------------------------------------------------- 40 Beschreibung: Formate 41 --------------------------------------------------------------------*/ 42 43 enum SwDateFormat 44 { 45 DF_BEGIN, 46 //neue Formate: 47 DFF_SSYS = DF_BEGIN, 48 DFF_LSYS , 49 DFF_DMY , 50 DFF_DMYY , 51 DFF_DMMY , 52 DFF_DMMYY, 53 DFF_DMMMY , 54 DFF_DMMMYY, 55 DFF_DDMMY , 56 DFF_DDMMMY , 57 DFF_DDMMMYY , 58 DFF_DDDMMMY , 59 DFF_DDDMMMYY , 60 DFF_MY , 61 DFF_MD , 62 DFF_YMD , 63 DFF_YYMD , 64 DF_END , 65 // Kompatibilitaet: 66 DF_SSYS = DFF_SSYS, 67 DF_LSYS = DFF_LSYS, 68 DF_SHORT = DFF_DMY, 69 DF_SCENT = DFF_DMYY, 70 DF_LMON = DFF_DMMYY, 71 DF_LMONTH = DFF_DMMMYY, 72 DF_LDAYMON = DFF_DDMMMYY, 73 DF_LDAYMONTH= DFF_DDDMMMYY 74 }; 75 76 enum SwTimeFormat 77 { 78 TF_BEGIN, 79 TF_SYSTEM=TF_BEGIN, 80 TF_SSMM_24, 81 TF_SSMM_12, 82 TF_END 83 }; 84 85 enum SwTimeSubFormat 86 { 87 TIME_FIX, 88 TIME_VAR 89 }; 90 91 enum SwDateSubFormat 92 { 93 DATE_FIX, 94 DATE_VAR 95 }; 96 97 /*-------------------------------------------------------------------- 98 Beschreibung: Datum/Uhrzeitfeld 99 --------------------------------------------------------------------*/ 100 101 class SwDateTimeFieldType : public SwValueFieldType 102 { 103 public: 104 SwDateTimeFieldType(SwDoc* pDoc); 105 106 virtual SwFieldType* Copy() const; 107 }; 108 109 /*-------------------------------------------------------------------- 110 Beschreibung: Datum/Uhrzeitfeld 111 --------------------------------------------------------------------*/ 112 113 class SW_DLLPUBLIC SwDateTimeField : public SwValueField 114 { 115 sal_uInt16 nSubType; 116 long nOffset; // Offset in Minuten 117 118 virtual String Expand() const; 119 virtual SwField* Copy() const; 120 121 public: 122 SwDateTimeField(SwDateTimeFieldType* pType, sal_uInt16 nSubType = DATEFLD, 123 sal_uLong nFmt = 0, sal_uInt16 nLng = 0); 124 125 virtual sal_uInt16 GetSubType() const; 126 virtual void SetSubType(sal_uInt16 nSub); 127 128 virtual double GetValue() const; 129 130 virtual void SetPar2(const String& rStr); 131 virtual String GetPar2() const; 132 133 inline sal_Bool IsDate() const 134 { return (nSubType & DATEFLD) != 0; } 135 136 inline void SetOffset(long nMinutes) { nOffset = nMinutes; } 137 inline long GetOffset() const { return nOffset; } 138 139 Date GetDate(sal_Bool bUseOffset = sal_False) const; 140 Time GetTime(sal_Bool bUseOffset = sal_False) const; 141 void SetDateTime(const DateTime& rDT); 142 static double GetDateTime(SwDoc* pDoc, const DateTime& rDT); 143 144 virtual sal_Bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const; 145 virtual sal_Bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId ); 146 }; 147 148 #endif // SW_FLDDAT_HXX 149