Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "lotfntbf.hxx"
21 :
22 : #include "scitems.hxx"
23 : #include <editeng/contouritem.hxx>
24 : #include <editeng/crossedoutitem.hxx>
25 : #include <editeng/eeitem.hxx>
26 : #include <editeng/postitem.hxx>
27 : #include <editeng/shdditem.hxx>
28 : #include <editeng/escapementitem.hxx>
29 : #include <editeng/udlnitem.hxx>
30 : #include <editeng/wghtitem.hxx>
31 : #include <sfx2/printer.hxx>
32 :
33 : #include "attrib.hxx"
34 : #include "document.hxx"
35 : #include "global.hxx"
36 : #include "docpool.hxx"
37 : #include "patattr.hxx"
38 : #include "ftools.hxx"
39 :
40 0 : void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
41 : {
42 0 : sal_uInt8 nIntIndex = nIndex & 0x07;
43 :
44 0 : ENTRY* pAkt = pData + nIntIndex;
45 :
46 0 : if( pAkt->pFont )
47 0 : rItemSet.Put( *pAkt->pFont );
48 :
49 0 : if( pAkt->pHeight )
50 0 : rItemSet.Put( *pAkt->pHeight );
51 :
52 0 : if( pAkt->pColor )
53 0 : rItemSet.Put( *pAkt->pColor );
54 :
55 0 : if( nIndex & 0x08 )
56 : {
57 0 : SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
58 0 : rItemSet.Put( aWeightItem );
59 : }
60 :
61 0 : if( nIndex & 0x10 )
62 : {
63 0 : SvxPostureItem aAttr( ITALIC_NORMAL, ATTR_FONT_POSTURE );
64 0 : rItemSet.Put( aAttr );
65 : }
66 :
67 : FontUnderline eUnderline;
68 0 : switch( nIndex & 0x60 ) // Bit 5+6
69 : {
70 : case 0x60:
71 0 : case 0x20: eUnderline = UNDERLINE_SINGLE; break;
72 0 : case 0x40: eUnderline = UNDERLINE_DOUBLE; break;
73 0 : default: eUnderline = UNDERLINE_NONE;
74 : }
75 0 : if( eUnderline != UNDERLINE_NONE )
76 : {
77 0 : SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
78 0 : rItemSet.Put( aUndItem );
79 : }
80 0 : }
81 :
82 0 : void LotusFontBuffer::SetName( const sal_uInt16 nIndex, const OUString& rName )
83 : {
84 : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetName(): Array too small!" );
85 0 : if( nIndex < nSize )
86 : {
87 0 : ENTRY* pEntry = pData + nIndex;
88 0 : pEntry->TmpName( rName );
89 :
90 0 : if( pEntry->nType >= 0 )
91 0 : MakeFont( pEntry );
92 : }
93 0 : }
94 :
95 0 : void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight )
96 : {
97 : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" );
98 0 : if( nIndex < nSize )
99 0 : pData[ nIndex ].Height( *( new SvxFontHeightItem( ( sal_uLong ) nHeight * 20, 100, ATTR_FONT_HEIGHT ) ) );
100 0 : }
101 :
102 0 : void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
103 : {
104 : OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetType(): Array too small!" );
105 0 : if( nIndex < nSize )
106 : {
107 0 : ENTRY* pEntry = pData + nIndex;
108 0 : pEntry->Type( nType );
109 :
110 0 : if( pEntry->pTmpName )
111 0 : MakeFont( pEntry );
112 : }
113 0 : }
114 :
115 0 : void LotusFontBuffer::MakeFont( ENTRY* pEntry )
116 : {
117 0 : FontFamily eFamily = FAMILY_DONTKNOW;
118 0 : FontPitch ePitch = PITCH_DONTKNOW;
119 0 : rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
120 :
121 0 : switch( pEntry->nType )
122 : {
123 : case 0x00: // Helvetica
124 0 : eFamily = FAMILY_SWISS;
125 0 : ePitch = PITCH_VARIABLE;
126 0 : break;
127 : case 0x01: // Times Roman
128 0 : eFamily = FAMILY_ROMAN;
129 0 : ePitch = PITCH_VARIABLE;
130 0 : break;
131 : case 0x02: // Courier
132 0 : ePitch = PITCH_FIXED;
133 0 : break;
134 : case 0x03: // Symbol
135 0 : eCharSet = RTL_TEXTENCODING_SYMBOL;
136 0 : break;
137 : }
138 :
139 0 : pEntry->pFont = new SvxFontItem( eFamily, *pEntry->pTmpName, EMPTY_OUSTRING, ePitch, eCharSet, ATTR_FONT );
140 :
141 0 : delete pEntry->pTmpName;
142 0 : pEntry->pTmpName = NULL;
143 30 : }
144 :
145 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|