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 : #include "xfdatestyle.hxx"
61 :
62 15 : XFDatePart::XFDatePart()
63 : {
64 15 : m_bTexture = sal_False;
65 15 : }
66 :
67 10 : void XFDatePart::ToXml(IXFStream *pStrm)
68 : {
69 10 : IXFAttrList *pAttrList = pStrm->GetAttrList();
70 :
71 10 : switch(m_ePart)
72 : {
73 : case enumXFDateUnknown:
74 0 : break;
75 : case enumXFDateYear:
76 2 : pAttrList->Clear();
77 2 : if( m_bLongFmt )
78 2 : pAttrList->AddAttribute( "number:style", "long" );
79 2 : pStrm->StartElement( "number:year" );
80 2 : pStrm->EndElement( "number:year" );
81 2 : break;
82 : case enumXFDateMonth:
83 2 : pAttrList->Clear();
84 2 : if( m_bTexture )
85 2 : pAttrList->AddAttribute( "number:textual", "true" );
86 2 : if( m_bLongFmt )
87 2 : pAttrList->AddAttribute( "number:style", "long" );
88 2 : pStrm->StartElement( "number:month" );
89 2 : pStrm->EndElement( "number:month" );
90 2 : break;
91 : case enumXFDateMonthDay:
92 2 : pAttrList->Clear();
93 2 : if( m_bLongFmt )
94 0 : pAttrList->AddAttribute( "number:style", "long" );
95 2 : pStrm->StartElement( "number:day" );
96 2 : pStrm->EndElement( "number:day" );
97 2 : break;
98 : case enumXFDateWeekDay:
99 0 : pAttrList->Clear();
100 0 : if( m_bLongFmt )
101 0 : pAttrList->AddAttribute( "number:style", "long" );
102 0 : pStrm->StartElement( "number:day-of-week" );
103 0 : pStrm->EndElement( "number:day-of-week" );
104 0 : break;
105 : case enumXFDateYearWeek:
106 0 : pAttrList->Clear();
107 0 : pStrm->StartElement( "number:week-of-year" );
108 0 : pStrm->EndElement( "number:week-of-year" );
109 0 : break;
110 : case enumXFDateEra:
111 0 : pAttrList->Clear();
112 0 : if( m_bLongFmt )
113 0 : pAttrList->AddAttribute( "number:style", "long" );
114 0 : pStrm->StartElement( "number:era" );
115 0 : pStrm->EndElement( "number:era" );
116 0 : break;
117 : case enumXFDateQuarter:
118 0 : pAttrList->Clear();
119 0 : if( m_bLongFmt )
120 0 : pAttrList->AddAttribute( "number:style", "long" );
121 0 : pStrm->StartElement( "number:quarter" );
122 0 : pStrm->EndElement( "number:quarter" );
123 0 : break;
124 : case enumXFDateHour:
125 0 : pAttrList->Clear();
126 0 : if( m_bLongFmt )
127 0 : pAttrList->AddAttribute( "number:style", "long" );
128 0 : pStrm->StartElement( "number:hours" );
129 0 : pStrm->EndElement( "number:hours" );
130 0 : break;
131 : case enumXFDateMinute:
132 0 : pAttrList->Clear();
133 0 : if( m_bLongFmt )
134 0 : pAttrList->AddAttribute( "number:style", "long" );
135 0 : pStrm->StartElement( "number:minutes" );
136 0 : pStrm->EndElement( "number:minutes" );
137 0 : break;
138 : case enumXFDateSecond:
139 0 : pAttrList->Clear();
140 0 : if( m_bLongFmt )
141 0 : pAttrList->AddAttribute( "number:style", "long" );
142 0 : if( m_nDecimalPos )
143 0 : pAttrList->AddAttribute( "number:decimal-places", OUString::number(m_nDecimalPos) );
144 0 : pStrm->StartElement( "number:seconds" );
145 0 : pStrm->EndElement( "number:seconds" );
146 0 : break;
147 : case enumXFDateAmPm:
148 0 : pStrm->StartElement( "number:am-pm" );
149 0 : pStrm->EndElement( "number:am-pm" );
150 0 : break;
151 : case enumXFDateText:
152 4 : pAttrList->Clear();
153 4 : pStrm->StartElement( "number:text" );
154 4 : pStrm->Characters( m_strText );
155 4 : pStrm->EndElement( "number:text" );
156 4 : break;
157 : }
158 10 : }
159 :
160 3 : XFDateStyle::XFDateStyle()
161 : {
162 3 : m_bFixed = sal_False;
163 3 : m_bAutoOrder = sal_False;
164 3 : }
165 :
166 6 : XFDateStyle::~XFDateStyle()
167 : {
168 6 : }
169 :
170 33 : enumXFStyle XFDateStyle::GetStyleFamily()
171 : {
172 33 : return enumXFStyleDate;
173 : }
174 :
175 2 : void XFDateStyle::ToXml(IXFStream *pStrm)
176 : {
177 2 : IXFAttrList *pAttrList = pStrm->GetAttrList();
178 :
179 2 : pAttrList->Clear();
180 2 : pAttrList->AddAttribute( "style:name", GetStyleName() );
181 2 : pAttrList->AddAttribute( "style:family", "data-style" );
182 :
183 2 : pStrm->StartElement( "number:date-style" );
184 :
185 2 : m_aParts.ToXml(pStrm);
186 :
187 2 : pStrm->EndElement( "number:date-style" );
188 2 : }
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|