Branch data 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 : : * Number style for table cell.
59 : : ************************************************************************/
60 : : #ifndef _XFNUMBERSTYLE_HXX
61 : : #define _XFNUMBERSTYLE_HXX
62 : :
63 : : #include "xfstyle.hxx"
64 : : #include "xfstylemanager.hxx"
65 : : #include "xfcolor.hxx"
66 : : #include <rtl/ustring.hxx>
67 : :
68 [ - + ]: 270 : class XFNumberStyle : public XFStyle
69 : : {
70 : : public:
71 : : XFNumberStyle();
72 : :
73 : : public:
74 : : void SetDecimalDigits(sal_Int32 decimal);
75 : :
76 : : void SetMinInteger(sal_Int32 integer);
77 : :
78 : : void SetMinExponent(sal_Int32 exponent);
79 : :
80 : : void SetGroup(sal_Bool group = sal_True);
81 : :
82 : : void SetColor(const XFColor& color);
83 : 0 : XFColor GetColor(){return m_aColor;}
84 : :
85 : : void SetPrefix(rtl::OUString prefix);
86 : :
87 : : void SetSurfix(rtl::OUString surfix);
88 : :
89 : : void SetNegativeStyle(rtl::OUString prefix, rtl::OUString suffix, const XFColor& color=XFColor(255,0,0));
90 : :
91 : : void SetNumberType(enumXFNumberType type);
92 : :
93 : : void SetCurrencySymbol(sal_Bool post, rtl::OUString symbol, sal_Bool bShowSpace=sal_False);
94 : :
95 : : virtual enumXFStyle GetStyleFamily();
96 : :
97 : : virtual sal_Bool Equal(IXFStyle *pStyle);
98 : :
99 : : virtual void ToXml(IXFStream *pStrm);
100 : :
101 : : protected:
102 : : void ToXml_StartElement(IXFStream *pStrm);
103 : :
104 : : void ToXml_EndElement(IXFStream *pStrm);
105 : :
106 : : void ToXml_Normal(IXFStream *pStrm);
107 : :
108 : : void ToXml_Negative(IXFStream *pStrm);
109 : :
110 : : void ToXml_Content(IXFStream *pStrm, sal_Bool nagetive);
111 : :
112 : : protected:
113 : : enumXFNumberType m_eType;
114 : : sal_Int32 m_nDecimalDigits;
115 : : sal_Int32 m_nMinInteger;
116 : : sal_Int32 m_nMinExponent;
117 : : sal_Bool m_bGroup;
118 : : XFColor m_aColor;
119 : : sal_Bool m_bCurrencySymbolPost;
120 : : rtl::OUString m_strCurrencySymbol;
121 : : rtl::OUString m_strPrefix;
122 : : rtl::OUString m_strSuffix;
123 : :
124 : : sal_Bool m_bRedIfNegative;
125 : : XFColor m_aNegativeColor;
126 : : rtl::OUString m_strNegativePrefix;
127 : : rtl::OUString m_strNegativeSuffix;
128 : : };
129 : :
130 : 81 : inline void XFNumberStyle::SetDecimalDigits(sal_Int32 decimal)
131 : : {
132 : 81 : m_nDecimalDigits = decimal;
133 : 81 : }
134 : :
135 : : inline void XFNumberStyle::SetMinInteger(sal_Int32 integer)
136 : : {
137 : : m_nMinInteger = integer;
138 : : }
139 : :
140 : : inline void XFNumberStyle::SetMinExponent(sal_Int32 exponent)
141 : : {
142 : : m_nMinExponent = exponent;
143 : : }
144 : :
145 : 81 : inline void XFNumberStyle::SetNegativeStyle(rtl::OUString prefix, rtl::OUString suffix, const XFColor& color)
146 : : {
147 : 81 : m_bRedIfNegative = sal_True;
148 : 81 : m_aNegativeColor = color;
149 : 81 : m_strNegativePrefix = prefix;
150 : 81 : m_strNegativeSuffix = suffix;
151 : 81 : }
152 : :
153 : 0 : inline void XFNumberStyle::SetGroup(sal_Bool group)
154 : : {
155 : 0 : m_bGroup = group;
156 : 0 : }
157 : :
158 : 81 : inline void XFNumberStyle::SetColor(const XFColor& color)
159 : : {
160 : 81 : m_aColor = color;
161 : 81 : }
162 : :
163 : 81 : inline void XFNumberStyle::SetNumberType(enumXFNumberType type)
164 : : {
165 : 81 : m_eType = type;
166 : 81 : }
167 : :
168 : 81 : inline void XFNumberStyle::SetPrefix(rtl::OUString prefix)
169 : : {
170 : 81 : m_strPrefix = prefix;
171 : 81 : }
172 : :
173 : 81 : inline void XFNumberStyle::SetSurfix(rtl::OUString surfix)
174 : : {
175 : 81 : m_strSuffix = surfix;
176 : 81 : }
177 : :
178 : : inline void XFNumberStyle::SetCurrencySymbol(sal_Bool post, rtl::OUString symbol, sal_Bool bShowSpace)
179 : : {
180 : : m_bCurrencySymbolPost = post;
181 : : m_strCurrencySymbol = symbol;
182 : :
183 : : if( bShowSpace )
184 : : {
185 : : if( post )
186 : : m_strCurrencySymbol = A2OUSTR(" ") + m_strCurrencySymbol;
187 : : else
188 : : m_strCurrencySymbol += A2OUSTR(" ");
189 : : }
190 : : }
191 : :
192 : : #endif
193 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|