Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * The Contents of this file are made available subject to the terms of
5 : * either of the following licenses
6 : *
7 : * - GNU Lesser General Public License Version 2.1
8 : * - Sun Industry Standards Source License Version 1.1
9 : *
10 : * Sun Microsystems Inc., October, 2000
11 : *
12 : * GNU Lesser General Public License Version 2.1
13 : * =============================================
14 : * Copyright 2000 by Sun Microsystems, Inc.
15 : * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 : *
17 : * This library is free software; you can redistribute it and/or
18 : * modify it under the terms of the GNU Lesser General Public
19 : * License version 2.1, as published by the Free Software Foundation.
20 : *
21 : * This library is distributed in the hope that it will be useful,
22 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 : * Lesser General Public License for more details.
25 : *
26 : * You should have received a copy of the GNU Lesser General Public
27 : * License along with this library; if not, write to the Free Software
28 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 : * MA 02111-1307 USA
30 : *
31 : *
32 : * Sun Industry Standards Source License Version 1.1
33 : * =================================================
34 : * The contents of this file are subject to the Sun Industry Standards
35 : * Source License Version 1.1 (the "License"); You may not use this file
36 : * except in compliance with the License. You may obtain a copy of the
37 : * License at http://www.openoffice.org/license.html.
38 : *
39 : * Software provided under this License is provided on an "AS IS" basis,
40 : * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
41 : * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
42 : * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
43 : * See the License for the specific provisions governing your rights and
44 : * obligations concerning the Software.
45 : *
46 : * The Initial Developer of the Original Code is: IBM Corporation
47 : *
48 : * Copyright: 2008 by IBM Corporation
49 : *
50 : * All Rights Reserved.
51 : *
52 : * Contributor(s): _______________________________________
53 : *
54 : *
55 : ************************************************************************/
56 : /*************************************************************************
57 : * @file
58 : * Date style. The date format for date field.
59 : ************************************************************************/
60 : #ifndef _XFDATESTYLE_HXX
61 : #define _XFDATESTYLE_HXX
62 :
63 : #include "xfglobal.hxx"
64 : #include "xfstyle.hxx"
65 : #include "ixfproperty.hxx"
66 : #include "xftimestyle.hxx"
67 : #include "xfstylecont.hxx"
68 : #include <vector>
69 :
70 30 : class XFDatePart : public XFTimePart
71 : {
72 : public:
73 : XFDatePart();
74 : public:
75 : void SetTexture(sal_Bool bTexture);
76 :
77 : virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
78 :
79 : private:
80 : sal_Bool m_bTexture;
81 : };
82 :
83 : class XFDateStyle : public XFStyle
84 : {
85 : public:
86 : XFDateStyle();
87 :
88 : virtual ~XFDateStyle();
89 :
90 : public:
91 :
92 : void SetFixed(sal_Bool fixed);
93 :
94 : void SetLanguage(const OUString& lang);
95 :
96 : void SetCountry(const OUString& country);
97 :
98 : void SetAutoOrder(sal_Bool bAutoOrder);
99 :
100 : void AddYear( sal_Bool bLongFmt = sal_True );
101 :
102 : void AddMonth( sal_Bool bLongFmt = sal_True, sal_Bool bTexture = sal_False );
103 :
104 : void AddMonthDay( sal_Bool bLongFmt = sal_True );
105 :
106 : void AddWeekDay( sal_Bool bLongFmt = sal_True );
107 :
108 : void AddYearWeek();
109 :
110 : void AddEra(sal_Bool bLongFmt = sal_False);
111 :
112 : void AddQuarter(sal_Bool bLongFmt = sal_False);
113 :
114 : void AddHour( sal_Bool bLongFmt = sal_True );
115 :
116 : void AddMinute( sal_Bool bLongFmt = sal_True );
117 :
118 : void AddSecond( sal_Bool bLongFmt = sal_True, sal_Int16 nDecimalPos = 2);
119 :
120 : void AddAmPm(sal_Bool bAmPm);
121 :
122 : void AddText( const OUString& part );
123 :
124 : virtual enumXFStyle GetStyleFamily() SAL_OVERRIDE;
125 :
126 : virtual void ToXml(IXFStream *pStrm) SAL_OVERRIDE;
127 :
128 : private:
129 : sal_Bool m_bFixed;
130 : sal_Bool m_bAutoOrder;
131 : OUString m_strLanguage;
132 : OUString m_strCountry;
133 : XFStyleContainer m_aParts;
134 : };
135 :
136 3 : inline void XFDatePart::SetTexture(sal_Bool bTexture)
137 : {
138 3 : m_bTexture = bTexture;
139 3 : }
140 :
141 : inline void XFDateStyle::SetFixed(sal_Bool fixed)
142 : {
143 : m_bFixed = fixed;
144 : }
145 :
146 : inline void XFDateStyle::SetLanguage(const OUString& lang)
147 : {
148 : m_strLanguage = lang;
149 : }
150 :
151 : inline void XFDateStyle::SetCountry(const OUString& country)
152 : {
153 : m_strCountry = country;
154 : }
155 :
156 : inline void XFDateStyle::SetAutoOrder(sal_Bool bAutoOrder)
157 : {
158 : m_bAutoOrder = bAutoOrder;
159 : }
160 :
161 3 : inline void XFDateStyle::AddYear( sal_Bool bLongFmt )
162 : {
163 3 : XFDatePart *part = new XFDatePart();
164 3 : part->SetPartType(enumXFDateYear);
165 3 : part->SetLongFmt(bLongFmt);
166 3 : m_aParts.AddStyle(part);
167 3 : }
168 :
169 3 : inline void XFDateStyle::AddMonth( sal_Bool bLongFmt, sal_Bool bTexture )
170 : {
171 3 : XFDatePart *part = new XFDatePart();
172 3 : part->SetPartType(enumXFDateMonth);
173 3 : part->SetLongFmt(bLongFmt);
174 3 : part->SetTexture(bTexture);
175 3 : m_aParts.AddStyle(part);
176 3 : }
177 :
178 3 : inline void XFDateStyle::AddMonthDay( sal_Bool bLongFmt )
179 : {
180 3 : XFDatePart *part = new XFDatePart();
181 3 : part->SetPartType(enumXFDateMonthDay);
182 3 : part->SetLongFmt(bLongFmt);
183 3 : m_aParts.AddStyle(part);
184 3 : }
185 :
186 0 : inline void XFDateStyle::AddWeekDay( sal_Bool bLongFmt )
187 : {
188 0 : XFDatePart *part = new XFDatePart();
189 0 : part->SetPartType(enumXFDateWeekDay);
190 0 : part->SetLongFmt(bLongFmt);
191 0 : m_aParts.AddStyle(part);
192 0 : }
193 :
194 : inline void XFDateStyle::AddYearWeek()
195 : {
196 : XFDatePart *part = new XFDatePart();
197 : part->SetPartType(enumXFDateYearWeek);
198 : m_aParts.AddStyle(part);
199 : }
200 :
201 0 : inline void XFDateStyle::AddEra(sal_Bool bLongFmt)
202 : {
203 0 : XFDatePart *part = new XFDatePart();
204 0 : part->SetPartType(enumXFDateEra);
205 0 : part->SetLongFmt(bLongFmt);
206 0 : m_aParts.AddStyle(part);
207 0 : }
208 :
209 : inline void XFDateStyle::AddQuarter(sal_Bool bLongFmt)
210 : {
211 : XFDatePart *part = new XFDatePart();
212 : part->SetPartType(enumXFDateQuarter);
213 : part->SetLongFmt(bLongFmt);
214 : m_aParts.AddStyle(part);
215 : }
216 :
217 6 : inline void XFDateStyle::AddText( const OUString& text )
218 : {
219 6 : XFDatePart *part = new XFDatePart();
220 6 : part->SetPartType(enumXFDateText);
221 6 : part->SetText(text);
222 6 : m_aParts.AddStyle(part);
223 6 : }
224 :
225 0 : inline void XFDateStyle::AddHour( sal_Bool bLongFmt )
226 : {
227 0 : XFDatePart *part = new XFDatePart();
228 0 : part->SetPartType(enumXFDateHour);
229 0 : part->SetLongFmt(bLongFmt);
230 0 : m_aParts.AddStyle(part);
231 0 : }
232 :
233 0 : inline void XFDateStyle::AddMinute( sal_Bool bLongFmt )
234 : {
235 0 : XFDatePart *part = new XFDatePart();
236 0 : part->SetPartType(enumXFDateMinute);
237 0 : part->SetLongFmt(bLongFmt);
238 0 : m_aParts.AddStyle(part);
239 0 : }
240 :
241 0 : inline void XFDateStyle::AddSecond( sal_Bool bLongFmt, sal_Int16 pos)
242 : {
243 0 : XFDatePart *part = new XFDatePart();
244 0 : part->SetPartType(enumXFDateSecond);
245 0 : part->SetLongFmt(bLongFmt);
246 0 : part->SetDecimalPos(pos);
247 0 : m_aParts.AddStyle(part);
248 0 : }
249 :
250 0 : inline void XFDateStyle::AddAmPm(sal_Bool /*bAmPm*/)
251 : {
252 0 : XFDatePart *part = new XFDatePart();
253 0 : part->SetPartType(enumXFDateAmPm);
254 0 : m_aParts.AddStyle(part);
255 0 : }
256 :
257 : #endif
258 :
259 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|