1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sfontitm.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <tools/stream.hxx>
34 #include <tools/vcompat.hxx>
35 #include <svtools/sfontitm.hxx>
37 //============================================================================
41 //============================================================================
43 TYPEINIT1(SfxFontItem
, SfxPoolItem
);
45 //============================================================================
47 int SfxFontItem::operator ==(const SfxPoolItem
& rItem
) const
49 const SfxFontItem
* pFontItem
= PTR_CAST(SfxFontItem
, &rItem
);
50 return pFontItem
&& m_bHasFont
== pFontItem
->m_bHasFont
51 && m_bHasColor
== pFontItem
->m_bHasColor
52 && m_bHasFillColor
== pFontItem
->m_bHasFillColor
53 && (!m_bHasColor
|| m_aColor
== pFontItem
->m_aColor
)
54 && (!m_bHasFillColor
|| m_aFillColor
== pFontItem
->m_aFillColor
)
55 && (!m_bHasFont
|| (m_bKerning
== pFontItem
->m_bKerning
56 && m_bShadow
== pFontItem
->m_bShadow
57 && m_bOutline
== pFontItem
->m_bOutline
58 && m_bWordLine
== pFontItem
->m_bWordLine
59 && m_nOrientation
== pFontItem
->m_nOrientation
60 && m_nStrikeout
== pFontItem
->m_nStrikeout
61 && m_nUnderline
== pFontItem
->m_nUnderline
62 && m_nItalic
== pFontItem
->m_nItalic
63 && m_nWidthType
== pFontItem
->m_nWidthType
64 && m_nWeight
== pFontItem
->m_nWeight
65 && m_nPitch
== pFontItem
->m_nPitch
66 && m_nFamily
== pFontItem
->m_nFamily
67 && m_nLanguage
== pFontItem
->m_nLanguage
68 && m_nCharSet
== pFontItem
->m_nCharSet
69 && m_aFillColor
== pFontItem
->m_aFillColor
70 && m_aColor
== pFontItem
->m_aColor
71 && m_aSize
== pFontItem
->m_aSize
72 && m_aStyleName
== pFontItem
->m_aStyleName
73 && m_aName
== pFontItem
->m_aName
));
76 //============================================================================
78 SfxPoolItem
* SfxFontItem::Create(SvStream
& rStream
, USHORT
) const
80 VersionCompat
aItemCompat(rStream
, STREAM_READ
);
81 SfxFontItem
* pItem
= new SfxFontItem(Which());
83 VersionCompat
aFontCompat(rStream
, STREAM_READ
);
84 readByteString(rStream
, pItem
->m_aName
);
85 readByteString(rStream
, pItem
->m_aStyleName
);
86 rStream
>> pItem
->m_aSize
;
87 sal_Int16 nCharSet
= 0;
89 pItem
->m_nCharSet
= rtl_TextEncoding(nCharSet
);
90 rStream
>> pItem
->m_nFamily
>> pItem
->m_nPitch
>> pItem
->m_nWeight
91 >> pItem
->m_nUnderline
>> pItem
->m_nStrikeout
93 sal_Int16 nLanguage
= 0;
95 pItem
->m_nLanguage
= LanguageType(nLanguage
);
96 rStream
>> pItem
->m_nWidthType
>> pItem
->m_nOrientation
;
97 sal_Int8 nWordLine
= 0;
99 pItem
->m_bWordLine
= nWordLine
!= 0;
100 sal_Int8 nOutline
= 0;
102 pItem
->m_bOutline
= nOutline
!= 0;
103 sal_Int8 nShadow
= 0;
105 pItem
->m_bShadow
= nShadow
!= 0;
106 sal_Int8 nKerning
= 0;
108 pItem
->m_bKerning
= nKerning
!= 0;
110 pItem
->m_aColor
.Read(rStream
, TRUE
);
111 pItem
->m_aFillColor
.Read(rStream
, TRUE
);
112 sal_Int16 nFlags
= 0;
114 pItem
->m_bHasFont
= (nFlags
& 4) != 0;
115 pItem
->m_bHasColor
= (nFlags
& 1) != 0;
116 pItem
->m_bHasFillColor
= (nFlags
& 2) != 0;
120 //============================================================================
122 SvStream
& SfxFontItem::Store(SvStream
& rStream
, USHORT
) const
124 VersionCompat
aItemCompat(rStream
, STREAM_WRITE
, 1);
126 VersionCompat
aFontCompat(rStream
, STREAM_WRITE
, 1);
127 writeByteString(rStream
, m_aName
);
128 writeByteString(rStream
, m_aStyleName
);
129 rStream
<< m_aSize
<< sal_Int16(m_nCharSet
)
130 << m_nFamily
<< m_nPitch
<< m_nWeight
<< m_nUnderline
131 << m_nStrikeout
<< m_nItalic
<< sal_Int16(m_nLanguage
)
132 << m_nWidthType
<< m_nOrientation
<< sal_Int8(m_bWordLine
)
133 << sal_Int8(m_bOutline
) << sal_Int8(m_bShadow
)
134 << sal_Int8(m_bKerning
);
136 SAL_CONST_CAST(Color
&, m_aColor
).Write(rStream
, TRUE
);
137 SAL_CONST_CAST(Color
&, m_aFillColor
).Write(rStream
, TRUE
);
138 rStream
<< sal_Int16(m_bHasFont
<< 2 | m_bHasColor
139 | m_bHasFillColor
<< 1);