Update ooo320-m1
[ooovba.git] / sc / source / filter / excel / fontbuff.cxx
bloba925ad3c3bfe46089853148352be7a1bf97d5b4e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fontbuff.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "lotfntbf.hxx"
36 #include "scitems.hxx"
37 #include <svx/cntritem.hxx>
38 #include <svx/crsditem.hxx>
39 #include <svx/eeitem.hxx>
40 #include <svx/postitem.hxx>
41 #include <svx/shdditem.hxx>
42 #include <svx/escpitem.hxx>
43 #include <svx/udlnitem.hxx>
44 #include <svx/wghtitem.hxx>
45 #include <sfx2/printer.hxx>
47 #include "attrib.hxx"
48 #include "document.hxx"
49 #include "global.hxx"
50 #include "docpool.hxx"
51 #include "patattr.hxx"
52 #include "ftools.hxx"
54 const UINT16 LotusFontBuffer::nSize = 8;
56 void LotusFontBuffer::Fill( const UINT8 nIndex, SfxItemSet& rItemSet )
58 UINT8 nIntIndex = nIndex & 0x07;
60 ENTRY* pAkt = pData + nIntIndex;
62 if( pAkt->pFont )
63 rItemSet.Put( *pAkt->pFont );
65 if( pAkt->pHeight )
66 rItemSet.Put( *pAkt->pHeight );
68 if( pAkt->pColor )
69 rItemSet.Put( *pAkt->pColor );
71 if( nIndex & 0x08 )
73 SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
74 rItemSet.Put( aWeightItem );
77 if( nIndex & 0x10 )
79 SvxPostureItem aAttr( ITALIC_NORMAL, ATTR_FONT_POSTURE );
80 rItemSet.Put( aAttr );
83 FontUnderline eUnderline;
84 switch( nIndex & 0x60 ) // Bit 5+6
86 case 0x60:
87 case 0x20: eUnderline = UNDERLINE_SINGLE; break;
88 case 0x40: eUnderline = UNDERLINE_DOUBLE; break;
89 default: eUnderline = UNDERLINE_NONE;
91 if( eUnderline != UNDERLINE_NONE )
93 SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
94 rItemSet.Put( aUndItem );
99 void LotusFontBuffer::SetName( const UINT16 nIndex, const String& rName )
101 DBG_ASSERT( nIndex < nSize, "*LotusFontBuffer::SetName(): Array zu klein!" );
102 if( nIndex < nSize )
104 register ENTRY* pEntry = pData + nIndex;
105 pEntry->TmpName( rName );
107 if( pEntry->nType >= 0 )
108 MakeFont( pEntry );
113 void LotusFontBuffer::SetHeight( const UINT16 nIndex, const UINT16 nHeight )
115 DBG_ASSERT( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array zu klein!" );
116 if( nIndex < nSize )
117 pData[ nIndex ].Height( *( new SvxFontHeightItem( ( ULONG ) nHeight * 20, 100, ATTR_FONT_HEIGHT ) ) );
121 void LotusFontBuffer::SetType( const UINT16 nIndex, const UINT16 nType )
123 DBG_ASSERT( nIndex < nSize, "*LotusFontBuffer::SetType(): Array zu klein!" );
124 if( nIndex < nSize )
126 register ENTRY* pEntry = pData + nIndex;
127 pEntry->Type( nType );
129 if( pEntry->pTmpName )
130 MakeFont( pEntry );
135 void LotusFontBuffer::MakeFont( ENTRY* pEntry )
137 FontFamily eFamily = FAMILY_DONTKNOW;
138 FontPitch ePitch = PITCH_DONTKNOW;
139 CharSet eCharSet = RTL_TEXTENCODING_DONTKNOW;
141 switch( pEntry->nType )
143 case 0x00: // Helvetica
144 eFamily = FAMILY_SWISS;
145 ePitch = PITCH_VARIABLE;
146 break;
147 case 0x01: // Times Roman
148 eFamily = FAMILY_ROMAN;
149 ePitch = PITCH_VARIABLE;
150 break;
151 case 0x02: // Courier
152 ePitch = PITCH_FIXED;
153 break;
154 case 0x03: // Symbol
155 eCharSet = RTL_TEXTENCODING_SYMBOL;
156 break;
159 pEntry->pFont = new SvxFontItem( eFamily, *pEntry->pTmpName, EMPTY_STRING, ePitch, eCharSet, ATTR_FONT );
161 delete pEntry->pTmpName;
162 pEntry->pTmpName = NULL;