LibreOffice Module xmerge (master)
1
xmerge
source
xmerge
java
org
openoffice
xmerge
converter
xml
sxc
Format.java
Go to the documentation of this file.
1
/*
2
* This file is part of the LibreOffice project.
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*
8
* This file incorporates work covered by the following license notice:
9
*
10
* Licensed to the Apache Software Foundation (ASF) under one or more
11
* contributor license agreements. See the NOTICE file distributed
12
* with this work for additional information regarding copyright
13
* ownership. The ASF licenses this file to you under the Apache
14
* License, Version 2.0 (the "License"); you may not use this file
15
* except in compliance with the License. You may obtain a copy of
16
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
17
*/
18
19
package
org.openoffice.xmerge.converter.xml.sxc;
20
21
import
java.awt.Color;
22
26
public
class
Format
{
27
29
final
public
static
int
RIGHT_ALIGN
= 0x01;
30
final
public
static
int
CENTER_ALIGN
= 0x02;
31
final
public
static
int
LEFT_ALIGN
= 0x03;
32
34
final
public
static
int
TOP_ALIGN
= 0x01;
35
final
public
static
int
MIDDLE_ALIGN
= 0x02;
36
final
public
static
int
BOTTOM_ALIGN
= 0x03;
37
39
final
public
static
int
BOLD
= 0x01;
41
final
public
static
int
ITALIC
= 0x02;
43
final
public
static
int
UNDERLINE
= 0x04;
45
final
public
static
int
STRIKETHRU
= 0x08;
47
final
public
static
int
SUPERSCRIPT
= 0x10;
49
final
public
static
int
SUBSCRIPT
= 0x20;
50
51
final
public
static
int
LEFT_BORDER
= 0x40;
52
final
public
static
int
RIGHT_BORDER
= 0x80;
53
final
public
static
int
TOP_BORDER
= 0x100;
54
final
public
static
int
BOTTOM_BORDER
= 0x200;
55
56
final
public
static
int
WORD_WRAP
= 0x400;
57
58
private
int
align
;
59
private
int
vertAlign
;
60
private
String
category
;
61
private
String
value
;
62
private
String
formatSpecifier
;
63
private
int
decimalPlaces
;
64
66
private
String
fontName
;
68
private
int
sizeInPoints
;
69
70
private
Color
foreground
,
background
;
71
73
private
int
attributes
= 0;
75
private
int
mask
= 0;
76
80
public
Format
() {
81
clearFormatting
();
82
}
83
92
public
Format
(
int
attributes
,
int
fontSize, String
fontName
) {
93
94
this.attributes =
attributes
;
95
sizeInPoints
= fontSize;
96
this.fontName =
fontName
;
97
}
98
105
public
Format
(
Format
fmt) {
106
category
= fmt.
getCategory
();
107
value
= fmt.
getValue
();
108
formatSpecifier
= fmt.
getFormatSpecifier
();
109
decimalPlaces
= fmt.
getDecimalPlaces
();
110
111
attributes
= fmt.
attributes
;
112
mask
= fmt.
mask
;
113
114
fontName
= fmt.
getFontName
();
115
align
= fmt.
getAlign
();
116
vertAlign
= fmt.
getVertAlign
();
117
foreground
= fmt.
getForeground
();
118
background
= fmt.
getBackground
();
119
sizeInPoints
= fmt.
sizeInPoints
;
120
}
121
125
public
void
clearFormatting
() {
126
category
=
""
;
127
value
=
""
;
128
formatSpecifier
=
""
;
129
decimalPlaces
= 0;
130
attributes
= 0;
131
mask
= 0;
132
sizeInPoints
= 10;
133
align
=
LEFT_ALIGN
;
134
vertAlign
=
BOTTOM_ALIGN
;
135
fontName
=
""
;
136
foreground
=
null
;
137
background
=
null
;
138
}
139
146
public
void
setAttribute
(
int
flags,
boolean
toggle) {
147
mask
|= flags;
148
if
(toggle) {
149
attributes
|= flags;
150
}
else
{
151
attributes
&= ~flags;
152
}
153
}
154
164
public
boolean
getAttribute
(
int
attribute) {
165
if
((
mask
&
attribute
) == 0)
166
return
false
;
167
return
((
attributes
&
attribute
) != 0);
168
}
169
180
public
void
setCategory
(String newCategory) {
181
category
= newCategory;
182
}
183
191
private
String
getCategory
() {
192
return
category
;
193
}
194
200
private
String
getValue
() {
201
return
value
;
202
}
203
210
public
void
setValue
(String newValue) {
211
value
= newValue;
212
}
213
219
public
void
setFormatSpecifier
(String formatString) {
220
formatSpecifier
= formatString;
221
}
222
228
private
String
getFormatSpecifier
() {
229
return
formatSpecifier
;
230
}
231
237
public
void
setDecimalPlaces
(
int
precision) {
238
decimalPlaces
=
precision
;
239
}
240
246
private
int
getDecimalPlaces
() {
247
return
decimalPlaces
;
248
}
249
255
public
void
setFontName
(String
fontName
) {
256
this.fontName =
fontName
;
257
}
258
264
public
String
getFontName
() {
265
return
fontName
;
266
}
267
273
public
void
setFontSize
(
int
fontSize) {
274
sizeInPoints
= fontSize;
275
}
276
282
public
int
getFontSize
() {
283
return
sizeInPoints
;
284
}
285
291
public
void
setVertAlign
(
int
vertAlign
) {
292
this.vertAlign =
vertAlign
;
293
}
294
300
public
int
getVertAlign
() {
301
return
vertAlign
;
302
}
303
309
public
void
setAlign
(
int
align
) {
310
this.align =
align
;
311
}
312
318
public
int
getAlign
() {
319
return
align
;
320
}
321
327
public
void
setForeground
(Color c) {
328
if
(c!=
null
)
329
foreground
=
new
Color
(c.getRGB());
330
}
331
337
public
Color
getForeground
() {
338
return
foreground
;
339
}
340
346
public
void
setBackground
(Color c) {
347
if
(c!=
null
)
348
background
=
new
Color
(c.getRGB());
349
}
350
356
public
Color
getBackground
() {
357
return
background
;
358
}
359
365
@Override
366
public
String
toString
() {
367
return
"Value : "
+
getValue
() +
" Category : "
+
getCategory
();
368
}
369
375
public
boolean
isDefault
() {
376
377
Format
rhs =
new
Format
();
378
379
if
(rhs.
attributes
!=
attributes
)
380
return
false
;
381
382
if
(
foreground
!=rhs.
foreground
)
383
return
false
;
384
385
if
(
background
!=rhs.
background
)
386
return
false
;
387
388
if
(rhs.
align
!=
align
)
389
return
false
;
390
391
return
rhs.
vertAlign
==
vertAlign
;
392
}
393
402
public
boolean
isSubset
(
Format
rhs) {
403
if
(rhs.getClass() !=
this
.getClass())
404
return
false
;
405
406
if
(rhs.
attributes
!=
attributes
)
407
return
false
;
408
409
if
(rhs.
sizeInPoints
!= 0 &&
sizeInPoints
!= rhs.
sizeInPoints
)
410
return
false
;
411
412
if
(
fontName
==
null
? rhs.
fontName
!=
null
: !
fontName
.equals(rhs.
fontName
))
413
return
false
;
414
415
if
(
foreground
!=rhs.
foreground
)
416
return
false
;
417
418
if
(
background
!=rhs.
background
)
419
return
false
;
420
421
if
(rhs.
align
!=
align
)
422
return
false
;
423
424
return
rhs.
vertAlign
==
vertAlign
;
425
}
426
}
org::openoffice.xmerge.converter.xml.sxc.Format
This class specifies the format for a given spreadsheet cell.
Definition:
Format.java:26
org::openoffice.xmerge.converter.xml.sxc.Format.getFontSize
int getFontSize()
Get the font size (in points) used for this cell.
Definition:
Format.java:282
org::openoffice.xmerge.converter.xml.sxc.Format.CENTER_ALIGN
final static int CENTER_ALIGN
Definition:
Format.java:30
org::openoffice.xmerge.converter.xml.sxc.Format.setVertAlign
void setVertAlign(int vertAlign)
Set the vertical alignment used for this cell.
Definition:
Format.java:291
org::openoffice.xmerge.converter.xml.sxc.Format.sizeInPoints
int sizeInPoints
Font size in points.
Definition:
Format.java:68
org::openoffice.xmerge.converter.xml.sxc.Format.getVertAlign
int getVertAlign()
Get the vertical alignment used for this cell.
Definition:
Format.java:300
org::openoffice.xmerge.converter.xml.sxc.Format.MIDDLE_ALIGN
final static int MIDDLE_ALIGN
Definition:
Format.java:35
org::openoffice.xmerge.converter.xml.sxc.Format.category
String category
Definition:
Format.java:60
org::openoffice.xmerge.converter.xml.sxc.Format.toString
String toString()
Get a String representation of this Format.
Definition:
Format.java:366
org::openoffice.xmerge.converter.xml.sxc.Format.BOTTOM_ALIGN
final static int BOTTOM_ALIGN
Definition:
Format.java:36
org::openoffice.xmerge.converter.xml.sxc.Format.RIGHT_BORDER
final static int RIGHT_BORDER
Definition:
Format.java:52
org::openoffice.xmerge.converter.xml.sxc.Format.WORD_WRAP
final static int WORD_WRAP
Definition:
Format.java:56
org::openoffice.xmerge.converter.xml.sxc.Format.RIGHT_ALIGN
final static int RIGHT_ALIGN
Horizontal Alignment Constants.
Definition:
Format.java:29
org::openoffice.xmerge.converter.xml.sxc.Format.setAlign
void setAlign(int align)
Set the alignment used for this cell.
Definition:
Format.java:309
org::openoffice.xmerge.converter.xml.sxc.Format.mask
int mask
Bitwise mask of text attributes.
Definition:
Format.java:75
org::openoffice.xmerge.converter.xml.sxc.Format.setFontName
void setFontName(String fontName)
Set the font used for this cell.
Definition:
Format.java:255
org::openoffice.xmerge.converter.xml.sxc.Format.setValue
void setValue(String newValue)
In the case of formula the contents are set as the formula string and the value of the formula is a f...
Definition:
Format.java:210
org::openoffice.xmerge.converter.xml.sxc.Format.getValue
String getValue()
In the case of Formula returns the value of the formula.
Definition:
Format.java:200
org::openoffice.xmerge.converter.xml.sxc.Format.isSubset
boolean isSubset(Format rhs)
Return true if passed Format specifies as much or less than this Format, and nothing it specifies con...
Definition:
Format.java:402
org::openoffice.xmerge.converter.xml.sxc.Format.align
int align
Definition:
Format.java:58
org::openoffice.xmerge.converter.xml.sxc.Format.BOLD
final static int BOLD
Indicates bold text.
Definition:
Format.java:39
org::openoffice.xmerge.converter.xml.sxc.Format.getForeground
Color getForeground()
Get the Foreground Color for this cell.
Definition:
Format.java:337
org::openoffice.xmerge.converter.xml.sxc.Format.isDefault
boolean isDefault()
Tests if the current Format object has default attribute values.
Definition:
Format.java:375
org::openoffice.xmerge.converter.xml.sxc.Format.setFontSize
void setFontSize(int fontSize)
Set the font size (in points) used for this cell.
Definition:
Format.java:273
org::openoffice.xmerge.converter.xml.sxc.Format.background
Color background
Definition:
Format.java:70
org::openoffice.xmerge.converter.xml.sxc.Format.formatSpecifier
String formatSpecifier
Definition:
Format.java:62
org::openoffice.xmerge.converter.xml.sxc.Format.setCategory
void setCategory(String newCategory)
Set the formatting category of this object, ie number, date, currency.
Definition:
Format.java:180
org::openoffice.xmerge.converter.xml.sxc.Format.setBackground
void setBackground(Color c)
Set the Background Color for this cell.
Definition:
Format.java:346
org::openoffice.xmerge.converter.xml.sxc.Format.getFontName
String getFontName()
Get the font used for this cell.
Definition:
Format.java:264
org::openoffice.xmerge.converter.xml.sxc.Format.LEFT_ALIGN
final static int LEFT_ALIGN
Definition:
Format.java:31
org::openoffice.xmerge.converter.xml.sxc.Format.Format
Format(Format fmt)
Constructor for creating a new Format object based on an existing one.
Definition:
Format.java:105
org::openoffice.xmerge.converter.xml.sxc.Format.value
String value
Definition:
Format.java:61
org::openoffice.xmerge.converter.xml.sxc.Format.attributes
int attributes
Values of text attributes.
Definition:
Format.java:73
org::openoffice.xmerge.converter.xml.sxc.Format.BOTTOM_BORDER
final static int BOTTOM_BORDER
Definition:
Format.java:54
org::openoffice.xmerge.converter.xml.sxc.Format.STRIKETHRU
final static int STRIKETHRU
Indicates strike-through in the text.
Definition:
Format.java:45
org::openoffice.xmerge.converter.xml.sxc.Format.Format
Format(int attributes, int fontSize, String fontName)
Constructor that creates a new Format object by setting all the format attributes.
Definition:
Format.java:92
org::openoffice.xmerge.converter.xml.sxc.Format.getFormatSpecifier
String getFormatSpecifier()
Get the Format specifier for this category.
Definition:
Format.java:228
org::openoffice.xmerge.converter.xml.sxc.Format.Format
Format()
Constructor for creating a new Format.
Definition:
Format.java:80
org::openoffice.xmerge.converter.xml.sxc.Format.foreground
Color foreground
Definition:
Format.java:70
org::openoffice.xmerge.converter.xml.sxc.Format.getDecimalPlaces
int getDecimalPlaces()
Get the number of decimal places displayed.
Definition:
Format.java:246
org::openoffice.xmerge.converter.xml.sxc.Format.SUPERSCRIPT
final static int SUPERSCRIPT
Indicates superscripted text.
Definition:
Format.java:47
org::openoffice.xmerge.converter.xml.sxc.Format.setAttribute
void setAttribute(int flags, boolean toggle)
Set one or more text attributes.
Definition:
Format.java:146
org::openoffice.xmerge.converter.xml.sxc.Format.SUBSCRIPT
final static int SUBSCRIPT
Indicates subscripted text.
Definition:
Format.java:49
org::openoffice.xmerge.converter.xml.sxc.Format.ITALIC
final static int ITALIC
Indicates italic text.
Definition:
Format.java:41
org::openoffice.xmerge.converter.xml.sxc.Format.clearFormatting
void clearFormatting()
Reset this Format description.
Definition:
Format.java:125
org::openoffice.xmerge.converter.xml.sxc.Format.TOP_BORDER
final static int TOP_BORDER
Definition:
Format.java:53
org::openoffice.xmerge.converter.xml.sxc.Format.getCategory
String getCategory()
Return the formatting category of the object.
Definition:
Format.java:191
org::openoffice.xmerge.converter.xml.sxc.Format.fontName
String fontName
Font name.
Definition:
Format.java:66
org::openoffice.xmerge.converter.xml.sxc.Format.setFormatSpecifier
void setFormatSpecifier(String formatString)
Set the Format specifier for this category.
Definition:
Format.java:219
org::openoffice.xmerge.converter.xml.sxc.Format.setDecimalPlaces
void setDecimalPlaces(int precision)
Set the precision of the number to be displayed.
Definition:
Format.java:237
org::openoffice.xmerge.converter.xml.sxc.Format.vertAlign
int vertAlign
Definition:
Format.java:59
org::openoffice.xmerge.converter.xml.sxc.Format.LEFT_BORDER
final static int LEFT_BORDER
Definition:
Format.java:51
org::openoffice.xmerge.converter.xml.sxc.Format.getAttribute
boolean getAttribute(int attribute)
Return true if the attribute is set to on.
Definition:
Format.java:164
org::openoffice.xmerge.converter.xml.sxc.Format.TOP_ALIGN
final static int TOP_ALIGN
Vertical Alignment Constants.
Definition:
Format.java:34
org::openoffice.xmerge.converter.xml.sxc.Format.getAlign
int getAlign()
Get the alignment used for this cell.
Definition:
Format.java:318
org::openoffice.xmerge.converter.xml.sxc.Format.UNDERLINE
final static int UNDERLINE
Indicates underlined text.
Definition:
Format.java:43
org::openoffice.xmerge.converter.xml.sxc.Format.setForeground
void setForeground(Color c)
Set the Foreground Color for this cell.
Definition:
Format.java:327
org::openoffice.xmerge.converter.xml.sxc.Format.decimalPlaces
int decimalPlaces
Definition:
Format.java:63
org::openoffice.xmerge.converter.xml.sxc.Format.getBackground
Color getBackground()
Get the Background Color for this cell.
Definition:
Format.java:356
ValueType::String
@ String
precision
sal_Int32 precision
attribute
sal_Int32 attribute
SdrHdlKind::Color
@ Color
Generated on Sun Jul 30 2023 04:32:48 for LibreOffice Module xmerge (master) by
1.9.3