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