xref: /AOO41X/main/sw/inc/flddat.hxx (revision 1d2dbeb0b7301723c6d13094e87a8714ef81a328)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SW_FLDDAT_HXX
25 #define SW_FLDDAT_HXX
26 
27 #include <tools/string.hxx>
28 
29 #include "fldbas.hxx"
30 
31 class DateTime;
32 class Date;
33 class Time;
34 
35 /*--------------------------------------------------------------------
36     Beschreibung: Formate
37  --------------------------------------------------------------------*/
38 
39 enum SwDateFormat
40 {
41     DF_BEGIN,
42     //neue Formate:
43     DFF_SSYS = DF_BEGIN,
44     DFF_LSYS ,
45     DFF_DMY ,
46     DFF_DMYY ,
47     DFF_DMMY ,
48     DFF_DMMYY,
49     DFF_DMMMY ,
50     DFF_DMMMYY,
51     DFF_DDMMY ,
52     DFF_DDMMMY ,
53     DFF_DDMMMYY ,
54     DFF_DDDMMMY ,
55     DFF_DDDMMMYY ,
56     DFF_MY ,
57     DFF_MD ,
58     DFF_YMD ,
59     DFF_YYMD ,
60     DF_END ,
61 //  Kompatibilitaet:
62     DF_SSYS     = DFF_SSYS,
63     DF_LSYS     = DFF_LSYS,
64     DF_SHORT    = DFF_DMY,
65     DF_SCENT    = DFF_DMYY,
66     DF_LMON     = DFF_DMMYY,
67     DF_LMONTH   = DFF_DMMMYY,
68     DF_LDAYMON  = DFF_DDMMMYY,
69     DF_LDAYMONTH= DFF_DDDMMMYY
70 };
71 
72 enum SwTimeFormat
73 {
74     TF_BEGIN,
75     TF_SYSTEM=TF_BEGIN,
76     TF_SSMM_24,
77     TF_SSMM_12,
78     TF_END
79 };
80 
81 enum SwTimeSubFormat
82 {
83     TIME_FIX,
84     TIME_VAR
85 };
86 
87 enum SwDateSubFormat
88 {
89     DATE_FIX,
90     DATE_VAR
91 };
92 
93 /*--------------------------------------------------------------------
94     Beschreibung: Datum/Uhrzeitfeld
95  --------------------------------------------------------------------*/
96 
97 class SwDateTimeFieldType : public SwValueFieldType
98 {
99 public:
100         SwDateTimeFieldType(SwDoc* pDoc);
101 
102         virtual SwFieldType*    Copy() const;
103 };
104 
105 /*--------------------------------------------------------------------
106     Beschreibung: Datum/Uhrzeitfeld
107  --------------------------------------------------------------------*/
108 
109 class SW_DLLPUBLIC SwDateTimeField : public SwValueField
110 {
111         sal_uInt16              nSubType;
112         long                nOffset;    // Offset in Minuten
113 
114         virtual String      Expand() const;
115         virtual SwField*    Copy() const;
116 
117 public:
118         SwDateTimeField(SwDateTimeFieldType* pType, sal_uInt16 nSubType = DATEFLD,
119                     sal_uLong nFmt = 0, sal_uInt16 nLng = 0);
120 
121         virtual sal_uInt16          GetSubType() const;
122         virtual void            SetSubType(sal_uInt16 nSub);
123 
124         virtual double          GetValue() const;
125 
126         virtual void            SetPar2(const String& rStr);
127         virtual String          GetPar2() const;
128 
IsDate() const129         inline sal_Bool             IsDate() const
130                                 { return (nSubType & DATEFLD) != 0; }
131 
SetOffset(long nMinutes)132         inline void             SetOffset(long nMinutes)    { nOffset = nMinutes; }
GetOffset() const133         inline long             GetOffset() const           { return nOffset; }
134 
135         Date                    GetDate(sal_Bool bUseOffset = sal_False) const;
136         Time                    GetTime(sal_Bool bUseOffset = sal_False) const;
137         void                    SetDateTime(const DateTime& rDT);
138         static double           GetDateTime(SwDoc* pDoc, const DateTime& rDT);
139 
140     virtual sal_Bool        QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const;
141     virtual sal_Bool        PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId );
142 };
143 
144 #endif // SW_FLDDAT_HXX
145