fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / excel / fontbuff.cxx
blob580a5132c987b58829d12a6eef5a32acfd215c9f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "lotfntbf.hxx"
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>
33 #include "attrib.hxx"
34 #include "document.hxx"
35 #include "global.hxx"
36 #include "docpool.hxx"
37 #include "patattr.hxx"
38 #include "ftools.hxx"
40 void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
42 sal_uInt8 nIntIndex = nIndex & 0x07;
44 ENTRY* pAkt = pData + nIntIndex;
46 if( pAkt->pFont )
47 rItemSet.Put( *pAkt->pFont );
49 if( pAkt->pHeight )
50 rItemSet.Put( *pAkt->pHeight );
52 if( pAkt->pColor )
53 rItemSet.Put( *pAkt->pColor );
55 if( nIndex & 0x08 )
57 SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
58 rItemSet.Put( aWeightItem );
61 if( nIndex & 0x10 )
63 SvxPostureItem aAttr( ITALIC_NORMAL, ATTR_FONT_POSTURE );
64 rItemSet.Put( aAttr );
67 FontUnderline eUnderline;
68 switch( nIndex & 0x60 ) // Bit 5+6
70 case 0x60:
71 case 0x20: eUnderline = UNDERLINE_SINGLE; break;
72 case 0x40: eUnderline = UNDERLINE_DOUBLE; break;
73 default: eUnderline = UNDERLINE_NONE;
75 if( eUnderline != UNDERLINE_NONE )
77 SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
78 rItemSet.Put( aUndItem );
82 void LotusFontBuffer::SetName( const sal_uInt16 nIndex, const OUString& rName )
84 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetName(): Array too small!" );
85 if( nIndex < nSize )
87 ENTRY* pEntry = pData + nIndex;
88 pEntry->TmpName( rName );
90 if( pEntry->nType >= 0 )
91 MakeFont( pEntry );
95 void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight )
97 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" );
98 if( nIndex < nSize )
99 pData[ nIndex ].Height( *( new SvxFontHeightItem( ( sal_uLong ) nHeight * 20, 100, ATTR_FONT_HEIGHT ) ) );
102 void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
104 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetType(): Array too small!" );
105 if( nIndex < nSize )
107 ENTRY* pEntry = pData + nIndex;
108 pEntry->Type( nType );
110 if( pEntry->pTmpName )
111 MakeFont( pEntry );
115 void LotusFontBuffer::MakeFont( ENTRY* pEntry )
117 FontFamily eFamily = FAMILY_DONTKNOW;
118 FontPitch ePitch = PITCH_DONTKNOW;
119 rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
121 switch( pEntry->nType )
123 case 0x00: // Helvetica
124 eFamily = FAMILY_SWISS;
125 ePitch = PITCH_VARIABLE;
126 break;
127 case 0x01: // Times Roman
128 eFamily = FAMILY_ROMAN;
129 ePitch = PITCH_VARIABLE;
130 break;
131 case 0x02: // Courier
132 ePitch = PITCH_FIXED;
133 break;
134 case 0x03: // Symbol
135 eCharSet = RTL_TEXTENCODING_SYMBOL;
136 break;
139 pEntry->pFont = new SvxFontItem( eFamily, *pEntry->pTmpName, EMPTY_OUSTRING, ePitch, eCharSet, ATTR_FONT );
141 delete pEntry->pTmpName;
142 pEntry->pTmpName = NULL;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */