xref: /trunk/main/svl/source/items/sfontitm.cxx (revision 40df464e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svl.hxx"
26 #include <tools/stream.hxx>
27 #include <tools/vcompat.hxx>
28 #include <svl/sfontitm.hxx>
29 
30 //============================================================================
31 //
32 //  class SfxFontItem
33 //
34 //============================================================================
35 
36 TYPEINIT1(SfxFontItem, SfxPoolItem);
37 
38 //============================================================================
39 // virtual
operator ==(const SfxPoolItem & rItem) const40 int SfxFontItem::operator ==(const SfxPoolItem & rItem) const
41 {
42 	const SfxFontItem * pFontItem = PTR_CAST(SfxFontItem, &rItem);
43 	return pFontItem && m_bHasFont == pFontItem->m_bHasFont
44 	       && m_bHasColor == pFontItem->m_bHasColor
45 	       && m_bHasFillColor == pFontItem->m_bHasFillColor
46 	       && (!m_bHasColor || m_aColor == pFontItem->m_aColor)
47 	       && (!m_bHasFillColor || m_aFillColor == pFontItem->m_aFillColor)
48 	       && (!m_bHasFont || (m_bKerning == pFontItem->m_bKerning
49 			                  && m_bShadow == pFontItem->m_bShadow
50 			                  && m_bOutline == pFontItem->m_bOutline
51 			                  && m_bWordLine == pFontItem->m_bWordLine
52 			                  && m_nOrientation == pFontItem->m_nOrientation
53 			                  && m_nStrikeout == pFontItem->m_nStrikeout
54 			                  && m_nUnderline == pFontItem->m_nUnderline
55 			                  && m_nItalic == pFontItem->m_nItalic
56 			                  && m_nWidthType == pFontItem->m_nWidthType
57 			                  && m_nWeight == pFontItem->m_nWeight
58 			                  && m_nPitch == pFontItem->m_nPitch
59 			                  && m_nFamily == pFontItem->m_nFamily
60 			                  && m_nLanguage == pFontItem->m_nLanguage
61 			                  && m_nCharSet == pFontItem->m_nCharSet
62 			                  && m_aFillColor == pFontItem->m_aFillColor
63 			                  && m_aColor == pFontItem->m_aColor
64 			                  && m_aSize == pFontItem->m_aSize
65 			                  && m_aStyleName == pFontItem->m_aStyleName
66 			                  && m_aName == pFontItem->m_aName));
67 }
68 
69 //============================================================================
70 // virtual
Create(SvStream & rStream,sal_uInt16) const71 SfxPoolItem * SfxFontItem::Create(SvStream & rStream, sal_uInt16) const
72 {
73 	VersionCompat aItemCompat(rStream, STREAM_READ);
74 	SfxFontItem * pItem = new SfxFontItem(Which());
75 	{
76 		VersionCompat aFontCompat(rStream, STREAM_READ);
77 		readByteString(rStream, pItem->m_aName);
78 		readByteString(rStream, pItem->m_aStyleName);
79 		rStream >> pItem->m_aSize;
80 		sal_Int16 nCharSet = 0;
81 		rStream >> nCharSet;
82 		pItem->m_nCharSet = rtl_TextEncoding(nCharSet);
83 		rStream >> pItem->m_nFamily >> pItem->m_nPitch >> pItem->m_nWeight
84 				>> pItem->m_nUnderline >> pItem->m_nStrikeout
85 				>> pItem->m_nItalic;
86 		sal_Int16 nLanguage = 0;
87 		rStream >> nLanguage;
88 		pItem->m_nLanguage = LanguageType(nLanguage);
89 		rStream >> pItem->m_nWidthType >> pItem->m_nOrientation;
90 		sal_Int8 nWordLine = 0;
91 		rStream >> nWordLine;
92 		pItem->m_bWordLine = nWordLine != 0;
93 		sal_Int8 nOutline = 0;
94 		rStream >> nOutline;
95 		pItem->m_bOutline = nOutline != 0;
96 		sal_Int8 nShadow = 0;
97 		rStream >> nShadow;
98 		pItem->m_bShadow = nShadow != 0;
99 		sal_Int8 nKerning = 0;
100 		rStream >> nKerning;
101 		pItem->m_bKerning = nKerning != 0;
102 	}
103 	pItem->m_aColor.Read(rStream, sal_True);
104 	pItem->m_aFillColor.Read(rStream, sal_True);
105 	sal_Int16 nFlags = 0;
106 	rStream >> nFlags;
107 	pItem->m_bHasFont = (nFlags & 4) != 0;
108 	pItem->m_bHasColor = (nFlags & 1) != 0;
109 	pItem->m_bHasFillColor = (nFlags & 2) != 0;
110 	return pItem;
111 }
112 
113 //============================================================================
114 // virtual
Store(SvStream & rStream,sal_uInt16) const115 SvStream & SfxFontItem::Store(SvStream & rStream, sal_uInt16) const
116 {
117 	VersionCompat aItemCompat(rStream, STREAM_WRITE, 1);
118 	{
119 		VersionCompat aFontCompat(rStream, STREAM_WRITE, 1);
120 		writeByteString(rStream, m_aName);
121 		writeByteString(rStream, m_aStyleName);
122 		rStream << m_aSize << sal_Int16(m_nCharSet)
123 				<< m_nFamily << m_nPitch << m_nWeight << m_nUnderline
124 				<< m_nStrikeout << m_nItalic << sal_Int16(m_nLanguage)
125 				<< m_nWidthType << m_nOrientation << sal_Int8(m_bWordLine)
126 				<< sal_Int8(m_bOutline) << sal_Int8(m_bShadow)
127 				<< sal_Int8(m_bKerning);
128 	}
129 	SAL_CONST_CAST(Color &, m_aColor).Write(rStream, sal_True);
130 	SAL_CONST_CAST(Color &, m_aFillColor).Write(rStream, sal_True);
131 	rStream << sal_Int16(m_bHasFont << 2 | m_bHasColor
132 						  | m_bHasFillColor << 1);
133 	return rStream;
134 }
135 
136