LibreOffice Module sc (master) 1
fontbuff.cxx
Go to the documentation of this file.
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/postitem.hxx>
24#include <editeng/udlnitem.hxx>
25#include <editeng/wghtitem.hxx>
26#include <osl/diagnose.h>
27#include <svl/itemset.hxx>
28
29void LotusFontBuffer::Fill( const sal_uInt8 nIndex, SfxItemSet& rItemSet )
30{
31 sal_uInt8 nIntIndex = nIndex & 0x07;
32
33 ENTRY* pCurrent = pData + nIntIndex;
34
35 if( pCurrent->pFont )
36 rItemSet.Put( *pCurrent->pFont );
37
38 if( pCurrent->pHeight )
39 rItemSet.Put( *pCurrent->pHeight );
40
41 if( nIndex & 0x08 )
42 {
44 rItemSet.Put( aWeightItem );
45 }
46
47 if( nIndex & 0x10 )
48 {
50 rItemSet.Put( aAttr );
51 }
52
53 FontLineStyle eUnderline;
54 switch( nIndex & 0x60 ) // Bit 5+6
55 {
56 case 0x60:
57 case 0x20: eUnderline = LINESTYLE_SINGLE; break;
58 case 0x40: eUnderline = LINESTYLE_DOUBLE; break;
59 default: eUnderline = LINESTYLE_NONE;
60 }
61 if( eUnderline != LINESTYLE_NONE )
62 {
63 SvxUnderlineItem aUndItem( eUnderline, ATTR_FONT_UNDERLINE );
64 rItemSet.Put( aUndItem );
65 }
66}
67
68void LotusFontBuffer::SetName( const sal_uInt16 nIndex, const OUString& rName )
69{
70 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetName(): Array too small!" );
71 if( nIndex < nSize )
72 {
73 ENTRY* pEntry = pData + nIndex;
74 pEntry->TmpName( rName );
75
76 if( pEntry->nType >= 0 )
77 MakeFont( pEntry );
78 }
79}
80
81void LotusFontBuffer::SetHeight( const sal_uInt16 nIndex, const sal_uInt16 nHeight )
82{
83 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetHeight(): Array too small!" );
84 if( nIndex < nSize )
85 pData[ nIndex ].Height( std::make_unique<SvxFontHeightItem>( static_cast<sal_uInt32>(nHeight) * 20, 100, ATTR_FONT_HEIGHT ) );
86}
87
88void LotusFontBuffer::SetType( const sal_uInt16 nIndex, const sal_uInt16 nType )
89{
90 OSL_ENSURE( nIndex < nSize, "*LotusFontBuffer::SetType(): Array too small!" );
91 if( nIndex < nSize )
92 {
93 ENTRY* pEntry = pData + nIndex;
94 pEntry->Type( nType );
95
96 if( pEntry->xTmpName )
97 MakeFont( pEntry );
98 }
99}
100
102{
103 FontFamily eFamily = FAMILY_DONTKNOW;
104 FontPitch ePitch = PITCH_DONTKNOW;
105 rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW;
106
107 switch( pEntry->nType )
108 {
109 case 0x00: // Helvetica
110 eFamily = FAMILY_SWISS;
111 ePitch = PITCH_VARIABLE;
112 break;
113 case 0x01: // Times Roman
114 eFamily = FAMILY_ROMAN;
115 ePitch = PITCH_VARIABLE;
116 break;
117 case 0x02: // Courier
118 ePitch = PITCH_FIXED;
119 break;
120 case 0x03: // Symbol
121 eCharSet = RTL_TEXTENCODING_SYMBOL;
122 break;
123 }
124
125 pEntry->pFont.reset( new SvxFontItem( eFamily, *pEntry->xTmpName, OUString(), ePitch, eCharSet, ATTR_FONT ) );
126
127 pEntry->xTmpName.reset();
128}
129
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Fill(const sal_uInt8 nIndex, SfxItemSet &rItemSet)
Definition: fontbuff.cxx:29
void SetHeight(const sal_uInt16 nIndex, const sal_uInt16 nHeight)
Definition: fontbuff.cxx:81
ENTRY pData[nSize]
Definition: lotfntbf.hxx:56
static const sal_uInt16 nSize
Definition: lotfntbf.hxx:50
void SetType(const sal_uInt16 nIndex, const sal_uInt16 nType)
Definition: fontbuff.cxx:88
static void MakeFont(ENTRY *pEntry)
Definition: fontbuff.cxx:101
void SetName(const sal_uInt16 nIndex, const OUString &rName)
Definition: fontbuff.cxx:68
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
FontLineStyle
LINESTYLE_SINGLE
LINESTYLE_DOUBLE
LINESTYLE_NONE
FontPitch
PITCH_VARIABLE
PITCH_FIXED
PITCH_DONTKNOW
ITALIC_NORMAL
FontFamily
FAMILY_DONTKNOW
FAMILY_SWISS
FAMILY_ROMAN
WEIGHT_BOLD
sal_Int32 nIndex
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
void Height(std::unique_ptr< SvxFontHeightItem > pNew)
Definition: lotfntbf.hxx:41
std::optional< OUString > xTmpName
Definition: lotfntbf.hxx:33
std::unique_ptr< SvxFontHeightItem > pHeight
Definition: lotfntbf.hxx:35
std::unique_ptr< SvxFontItem > pFont
Definition: lotfntbf.hxx:34
void Type(const sal_uInt16 nNew)
Definition: lotfntbf.hxx:45
void TmpName(const OUString &rNew)
Definition: lotfntbf.hxx:37
unsigned char sal_uInt8