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 : #ifndef INCLUDED_SW_INC_FLDDAT_HXX
21 : #define INCLUDED_SW_INC_FLDDAT_HXX
22 :
23 : #include "fldbas.hxx"
24 :
25 : class DateTime;
26 : class Date;
27 : class Time;
28 :
29 : enum SwDateFormat
30 : {
31 : DF_BEGIN,
32 : // new formats
33 : DFF_SSYS = DF_BEGIN,
34 : DFF_LSYS ,
35 : DFF_DMY ,
36 : DFF_DMYY ,
37 : DFF_DMMY ,
38 : DFF_DMMYY,
39 : DFF_DMMMY ,
40 : DFF_DMMMYY,
41 : DFF_DDMMY ,
42 : DFF_DDMMMY ,
43 : DFF_DDMMMYY ,
44 : DFF_DDDMMMY ,
45 : DFF_DDDMMMYY ,
46 : DFF_MY ,
47 : DFF_MD ,
48 : DFF_YMD ,
49 : DFF_YYMD ,
50 : DF_END ,
51 : // Compatibility
52 : DF_SSYS = DFF_SSYS,
53 : DF_LSYS = DFF_LSYS,
54 : DF_SHORT = DFF_DMY,
55 : DF_SCENT = DFF_DMYY,
56 : DF_LMON = DFF_DMMYY,
57 : DF_LMONTH = DFF_DMMMYY,
58 : DF_LDAYMON = DFF_DDMMMYY,
59 : DF_LDAYMONTH= DFF_DDDMMMYY
60 : };
61 :
62 : enum SwTimeFormat
63 : {
64 : TF_BEGIN,
65 : TF_SYSTEM=TF_BEGIN,
66 : TF_SSMM_24,
67 : TF_SSMM_12,
68 : TF_END
69 : };
70 :
71 : enum SwTimeSubFormat
72 : {
73 : TIME_FIX,
74 : TIME_VAR
75 : };
76 :
77 : enum SwDateSubFormat
78 : {
79 : DATE_FIX,
80 : DATE_VAR
81 : };
82 :
83 0 : class SwDateTimeFieldType : public SwValueFieldType
84 : {
85 : public:
86 : SwDateTimeFieldType(SwDoc* pDoc);
87 :
88 : virtual SwFieldType* Copy() const SAL_OVERRIDE;
89 : };
90 :
91 0 : class SW_DLLPUBLIC SwDateTimeField : public SwValueField
92 : {
93 : sal_uInt16 nSubType;
94 : long nOffset; // Offset in minutes.
95 :
96 : virtual OUString Expand() const SAL_OVERRIDE;
97 : virtual SwField* Copy() const SAL_OVERRIDE;
98 :
99 : public:
100 : SwDateTimeField(SwDateTimeFieldType* pType, sal_uInt16 nSubType = DATEFLD,
101 : sal_uLong nFmt = 0, sal_uInt16 nLng = 0);
102 :
103 : virtual sal_uInt16 GetSubType() const SAL_OVERRIDE;
104 : virtual void SetSubType(sal_uInt16 nSub) SAL_OVERRIDE;
105 :
106 : virtual double GetValue() const SAL_OVERRIDE;
107 :
108 : virtual void SetPar2(const OUString& rStr) SAL_OVERRIDE;
109 : virtual OUString GetPar2() const SAL_OVERRIDE;
110 :
111 0 : inline sal_Bool IsDate() const
112 0 : { return (nSubType & DATEFLD) != 0; }
113 :
114 0 : inline void SetOffset(long nMinutes) { nOffset = nMinutes; }
115 0 : inline long GetOffset() const { return nOffset; }
116 :
117 : Date GetDate(sal_Bool bUseOffset = sal_False) const;
118 : Time GetTime(sal_Bool bUseOffset = sal_False) const;
119 : void SetDateTime(const DateTime& rDT);
120 : static double GetDateTime(SwDoc* pDoc, const DateTime& rDT);
121 :
122 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) const SAL_OVERRIDE;
123 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nMId ) SAL_OVERRIDE;
124 : };
125 :
126 : #endif // INCLUDED_SW_INC_FLDDAT_HXX
127 :
128 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|