1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fontbuff.cxx,v $
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>
48 #include "document.hxx"
50 #include "docpool.hxx"
51 #include "patattr.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
;
63 rItemSet
.Put( *pAkt
->pFont
);
66 rItemSet
.Put( *pAkt
->pHeight
);
69 rItemSet
.Put( *pAkt
->pColor
);
73 SvxWeightItem
aWeightItem( WEIGHT_BOLD
, ATTR_FONT_WEIGHT
);
74 rItemSet
.Put( aWeightItem
);
79 SvxPostureItem
aAttr( ITALIC_NORMAL
, ATTR_FONT_POSTURE
);
80 rItemSet
.Put( aAttr
);
83 FontUnderline eUnderline
;
84 switch( nIndex
& 0x60 ) // Bit 5+6
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!" );
104 register ENTRY
* pEntry
= pData
+ nIndex
;
105 pEntry
->TmpName( rName
);
107 if( pEntry
->nType
>= 0 )
113 void LotusFontBuffer::SetHeight( const UINT16 nIndex
, const UINT16 nHeight
)
115 DBG_ASSERT( nIndex
< nSize
, "*LotusFontBuffer::SetHeight(): Array zu klein!" );
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!" );
126 register ENTRY
* pEntry
= pData
+ nIndex
;
127 pEntry
->Type( nType
);
129 if( pEntry
->pTmpName
)
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
;
147 case 0x01: // Times Roman
148 eFamily
= FAMILY_ROMAN
;
149 ePitch
= PITCH_VARIABLE
;
151 case 0x02: // Courier
152 ePitch
= PITCH_FIXED
;
155 eCharSet
= RTL_TEXTENCODING_SYMBOL
;
159 pEntry
->pFont
= new SvxFontItem( eFamily
, *pEntry
->pTmpName
, EMPTY_STRING
, ePitch
, eCharSet
, ATTR_FONT
);
161 delete pEntry
->pTmpName
;
162 pEntry
->pTmpName
= NULL
;