Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "lotfntbf.hxx"
31 : :
32 : : #include "scitems.hxx"
33 : : #include <editeng/cntritem.hxx>
34 : : #include <editeng/crsditem.hxx>
35 : : #include <editeng/eeitem.hxx>
36 : : #include <editeng/postitem.hxx>
37 : : #include <editeng/shdditem.hxx>
38 : : #include <editeng/escpitem.hxx>
39 : : #include <editeng/udlnitem.hxx>
40 : : #include <editeng/wghtitem.hxx>
41 : : #include <sfx2/printer.hxx>
42 : :
43 : : #include "attrib.hxx"
44 : : #include "document.hxx"
45 : : #include "global.hxx"
46 : : #include "docpool.hxx"
47 : : #include "patattr.hxx"
48 : : #include "ftools.hxx"
49 : :
50 : 0 : void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
51 : : {
52 : 0 : sal_uInt8 nIntIndex = nIndex & 0x07;
53 : :
54 : 0 : ENTRY* pAkt = pData + nIntIndex;
55 : :
56 [ # # ]: 0 : if( pAkt->pFont )
57 : 0 : rItemSet.Put( *pAkt->pFont );
58 : :
59 [ # # ]: 0 : if( pAkt->pHeight )
60 : 0 : rItemSet.Put( *pAkt->pHeight );
61 : :
62 [ # # ]: 0 : if( pAkt->pColor )
63 : 0 : rItemSet.Put( *pAkt->pColor );
64 : :
65 [ # # ]: 0 : if( nIndex & 0x08 )
66 : : {
67 [ # # ]: 0 : SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
68 [ # # ][ # # ]: 0 : rItemSet.Put( aWeightItem );
69 : : }
70 : :
71 [ # # ]: 0 : if( nIndex & 0x10 )
72 : : {
73 [ # # ]: 0 : SvxPostureItem aAttr( ITALIC_NORMAL, ATTR_FONT_POSTURE );
74 [ # # ][ # # ]: 0 : rItemSet.Put( aAttr );
75 : : }
76 : :
77 : : FontUnderline eUnderline;
78 [ # # # ]: 0 : switch( nIndex & 0x60 ) // Bit 5+6
79 : : {
80 : : case 0x60:
81 : 0 : case 0x20: eUnderline = UNDERLINE_SINGLE; break;
82 : 0 : case 0x40: eUnderline = UNDERLINE_DOUBLE; break;
83 : 0 : default: eUnderline = UNDERLINE_NONE;
84 : : }
85 [ # # ]: 0 : if( eUnderline != UNDERLINE_NONE )
86 : : {
87 [ # # ]: 0 : SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
88 [ # # ][ # # ]: 0 : rItemSet.Put( aUndItem );
89 : : }
90 : 0 : }
91 : :
92 : :
93 : 0 : void LotusFontBuffer::SetName( const sal_uInt16 nIndex, const String& rName )
94 : : {
95 : : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetName(): Array zu klein!" );
96 [ # # ]: 0 : if( nIndex < nSize )
97 : : {
98 : 0 : register ENTRY* pEntry = pData + nIndex;
99 : 0 : pEntry->TmpName( rName );
100 : :
101 [ # # ]: 0 : if( pEntry->nType >= 0 )
102 : 0 : MakeFont( pEntry );
103 : : }
104 : 0 : }
105 : :
106 : :
107 : 0 : void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight )
108 : : {
109 : : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array zu klein!" );
110 [ # # ]: 0 : if( nIndex < nSize )
111 [ # # ]: 0 : pData[ nIndex ].Height( *( new SvxFontHeightItem( ( sal_uLong ) nHeight * 20, 100, ATTR_FONT_HEIGHT ) ) );
112 : 0 : }
113 : :
114 : :
115 : 0 : void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
116 : : {
117 : : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetType(): Array zu klein!" );
118 [ # # ]: 0 : if( nIndex < nSize )
119 : : {
120 : 0 : register ENTRY* pEntry = pData + nIndex;
121 : 0 : pEntry->Type( nType );
122 : :
123 [ # # ]: 0 : if( pEntry->pTmpName )
124 : 0 : MakeFont( pEntry );
125 : : }
126 : 0 : }
127 : :
128 : :
129 : 0 : void LotusFontBuffer::MakeFont( ENTRY* pEntry )
130 : : {
131 : 0 : FontFamily eFamily = FAMILY_DONTKNOW;
132 : 0 : FontPitch ePitch = PITCH_DONTKNOW;
133 : 0 : CharSet eCharSet = RTL_TEXTENCODING_DONTKNOW;
134 : :
135 [ # # # # : 0 : switch( pEntry->nType )
# ]
136 : : {
137 : : case 0x00: // Helvetica
138 : 0 : eFamily = FAMILY_SWISS;
139 : 0 : ePitch = PITCH_VARIABLE;
140 : 0 : break;
141 : : case 0x01: // Times Roman
142 : 0 : eFamily = FAMILY_ROMAN;
143 : 0 : ePitch = PITCH_VARIABLE;
144 : 0 : break;
145 : : case 0x02: // Courier
146 : 0 : ePitch = PITCH_FIXED;
147 : 0 : break;
148 : : case 0x03: // Symbol
149 : 0 : eCharSet = RTL_TEXTENCODING_SYMBOL;
150 : 0 : break;
151 : : }
152 : :
153 [ # # ]: 0 : pEntry->pFont = new SvxFontItem( eFamily, *pEntry->pTmpName, EMPTY_STRING, ePitch, eCharSet, ATTR_FONT );
154 : :
155 [ # # ]: 0 : delete pEntry->pTmpName;
156 : 0 : pEntry->pTmpName = NULL;
157 : 0 : }
158 : :
159 : :
160 : :
161 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|