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