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