LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / source / filter / excel / fontbuff.cxx
blob2a23cee21f61318ed92625143a79689b176d71aa
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/postitem.hxx>
24 #include <editeng/udlnitem.hxx>
25 #include <editeng/wghtitem.hxx>
26 #include <osl/diagnose.h>
27 #include <svl/itemset.hxx>
29 #include <global.hxx>
31 void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
33 sal_uInt8 nIntIndex = nIndex & 0x07;
35 ENTRY* pCurrent = pData + nIntIndex;
37 if( pCurrent->pFont )
38 rItemSet.Put( *pCurrent->pFont );
40 if( pCurrent->pHeight )
41 rItemSet.Put( *pCurrent->pHeight );
43 if( nIndex & 0x08 )
45 SvxWeightItem aWeightItem( WEIGHT_BOLD, ATTR_FONT_WEIGHT );
46 rItemSet.Put( aWeightItem );
49 if( nIndex & 0x10 )
51 SvxPostureItem aAttr( ITALIC_NORMAL, ATTR_FONT_POSTURE );
52 rItemSet.Put( aAttr );
55 FontLineStyle eUnderline;
56 switch( nIndex & 0x60 ) // Bit 5+6
58 case 0x60:
59 case 0x20: eUnderline = LINESTYLE_SINGLE; break;
60 case 0x40: eUnderline = LINESTYLE_DOUBLE; break;
61 default: eUnderline = LINESTYLE_NONE;
63 if( eUnderline != LINESTYLE_NONE )
65 SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
66 rItemSet.Put( aUndItem );
70 void LotusFontBuffer::SetName( const sal_uInt16 nIndex, const OUString& rName )
72 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetName(): Array too small!" );
73 if( nIndex < nSize )
75 ENTRY* pEntry = pData + nIndex;
76 pEntry->TmpName( rName );
78 if( pEntry->nType >= 0 )
79 MakeFont( pEntry );
83 void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight )
85 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" );
86 if( nIndex < nSize )
87 pData[ nIndex ].Height( std::make_unique<SvxFontHeightItem>( static_cast<sal_uInt32>(nHeight) * 20, 100, ATTR_FONT_HEIGHT ) );
90 void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
92 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetType(): Array too small!" );
93 if( nIndex < nSize )
95 ENTRY* pEntry = pData + nIndex;
96 pEntry->Type( nType );
98 if( pEntry->xTmpName )
99 MakeFont( pEntry );
103 void LotusFontBuffer::MakeFont( ENTRY* pEntry )
105 FontFamily eFamily = FAMILY_DONTKNOW;
106 FontPitch ePitch = PITCH_DONTKNOW;
107 rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
109 switch( pEntry->nType )
111 case 0x00: // Helvetica
112 eFamily = FAMILY_SWISS;
113 ePitch = PITCH_VARIABLE;
114 break;
115 case 0x01: // Times Roman
116 eFamily = FAMILY_ROMAN;
117 ePitch = PITCH_VARIABLE;
118 break;
119 case 0x02: // Courier
120 ePitch = PITCH_FIXED;
121 break;
122 case 0x03: // Symbol
123 eCharSet = RTL_TEXTENCODING_SYMBOL;
124 break;
127 pEntry->pFont.reset( new SvxFontItem( eFamily, *pEntry->xTmpName, OUString(), ePitch, eCharSet, ATTR_FONT ) );
129 pEntry->xTmpName.reset();
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */