1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/stream.hxx>
21 #include <tools/vcompat.hxx>
22 #include <svl/sfontitm.hxx>
24 //============================================================================
28 //============================================================================
30 TYPEINIT1(SfxFontItem
, SfxPoolItem
);
32 //============================================================================
34 int SfxFontItem::operator ==(const SfxPoolItem
& rItem
) const
36 const SfxFontItem
* pFontItem
= PTR_CAST(SfxFontItem
, &rItem
);
37 return pFontItem
&& m_bHasFont
== pFontItem
->m_bHasFont
38 && m_bHasColor
== pFontItem
->m_bHasColor
39 && m_bHasFillColor
== pFontItem
->m_bHasFillColor
40 && (!m_bHasColor
|| m_aColor
== pFontItem
->m_aColor
)
41 && (!m_bHasFillColor
|| m_aFillColor
== pFontItem
->m_aFillColor
)
42 && (!m_bHasFont
|| (m_bKerning
== pFontItem
->m_bKerning
43 && m_bShadow
== pFontItem
->m_bShadow
44 && m_bOutline
== pFontItem
->m_bOutline
45 && m_bWordLine
== pFontItem
->m_bWordLine
46 && m_nOrientation
== pFontItem
->m_nOrientation
47 && m_nStrikeout
== pFontItem
->m_nStrikeout
48 && m_nUnderline
== pFontItem
->m_nUnderline
49 && m_nItalic
== pFontItem
->m_nItalic
50 && m_nWidthType
== pFontItem
->m_nWidthType
51 && m_nWeight
== pFontItem
->m_nWeight
52 && m_nPitch
== pFontItem
->m_nPitch
53 && m_nFamily
== pFontItem
->m_nFamily
54 && m_nLanguage
== pFontItem
->m_nLanguage
55 && m_nCharSet
== pFontItem
->m_nCharSet
56 && m_aFillColor
== pFontItem
->m_aFillColor
57 && m_aColor
== pFontItem
->m_aColor
58 && m_aSize
== pFontItem
->m_aSize
59 && m_aStyleName
== pFontItem
->m_aStyleName
60 && m_aName
== pFontItem
->m_aName
));
63 //============================================================================
65 SfxPoolItem
* SfxFontItem::Create(SvStream
& rStream
, sal_uInt16
) const
67 VersionCompat
aItemCompat(rStream
, STREAM_READ
);
68 SfxFontItem
* pItem
= new SfxFontItem(Which());
70 VersionCompat
aFontCompat(rStream
, STREAM_READ
);
71 pItem
->m_aName
= readByteString(rStream
);
72 pItem
->m_aStyleName
= readByteString(rStream
);
73 rStream
>> pItem
->m_aSize
;
74 sal_Int16 nCharSet
= 0;
76 pItem
->m_nCharSet
= rtl_TextEncoding(nCharSet
);
77 rStream
>> pItem
->m_nFamily
>> pItem
->m_nPitch
>> pItem
->m_nWeight
78 >> pItem
->m_nUnderline
>> pItem
->m_nStrikeout
80 sal_Int16 nLanguage
= 0;
82 pItem
->m_nLanguage
= LanguageType(nLanguage
);
83 rStream
>> pItem
->m_nWidthType
>> pItem
->m_nOrientation
;
84 sal_Int8 nWordLine
= 0;
86 pItem
->m_bWordLine
= nWordLine
!= 0;
87 sal_Int8 nOutline
= 0;
89 pItem
->m_bOutline
= nOutline
!= 0;
92 pItem
->m_bShadow
= nShadow
!= 0;
93 sal_Int8 nKerning
= 0;
95 pItem
->m_bKerning
= nKerning
!= 0;
97 pItem
->m_aColor
.Read(rStream
, sal_True
);
98 pItem
->m_aFillColor
.Read(rStream
, sal_True
);
101 pItem
->m_bHasFont
= (nFlags
& 4) != 0;
102 pItem
->m_bHasColor
= (nFlags
& 1) != 0;
103 pItem
->m_bHasFillColor
= (nFlags
& 2) != 0;
107 //============================================================================
109 SvStream
& SfxFontItem::Store(SvStream
& rStream
, sal_uInt16
) const
111 VersionCompat
aItemCompat(rStream
, STREAM_WRITE
, 1);
113 VersionCompat
aFontCompat(rStream
, STREAM_WRITE
, 1);
114 writeByteString(rStream
, m_aName
);
115 writeByteString(rStream
, m_aStyleName
);
116 rStream
<< m_aSize
<< sal_Int16(m_nCharSet
)
117 << m_nFamily
<< m_nPitch
<< m_nWeight
<< m_nUnderline
118 << m_nStrikeout
<< m_nItalic
<< sal_Int16(m_nLanguage
)
119 << m_nWidthType
<< m_nOrientation
<< sal_Int8(m_bWordLine
)
120 << sal_Int8(m_bOutline
) << sal_Int8(m_bShadow
)
121 << sal_Int8(m_bKerning
);
123 (const_cast< Color
& >(m_aColor
)).Write(rStream
, sal_True
);
124 (const_cast< Color
& >(m_aFillColor
)).Write(rStream
, sal_True
);
125 rStream
<< sal_Int16(m_bHasFont
<< 2 | m_bHasColor
126 | m_bHasFillColor
<< 1);
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */