LibreOffice Module sc (master) 1
qprostyle.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 <sal/config.h>
21
22#include <qprostyle.hxx>
23
24#include <scitems.hxx>
25#include <svx/algitem.hxx>
26#include <editeng/udlnitem.hxx>
27#include <editeng/wghtitem.hxx>
28#include <editeng/postitem.hxx>
29#include <editeng/fhgtitem.hxx>
30#include <editeng/fontitem.hxx>
32
33#include <attrib.hxx>
34#include <docpool.hxx>
35#include <patattr.hxx>
36#include <document.hxx>
37
38void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle )
39{
40 if (nStyle >= maxsize)
41 return;
42
43 ScPatternAttr aPattern(pDoc->GetPool());
44 SfxItemSet& rItemSet = aPattern.GetItemSet();
45
46 sal_uInt8 nTmp = maAlign[ nStyle ];
47 sal_uInt8 nHor = ( nTmp & 0x07 );
48 sal_uInt8 nVer = ( nTmp & 0x18 );
49 sal_uInt8 nOrient = ( nTmp & 0x60 );
50
51 // Horizontal Alignment
52 SvxCellHorJustify eJustify = SvxCellHorJustify::Standard;
53 switch( nHor )
54 {
55 case 0x00:
56 eJustify = SvxCellHorJustify::Standard;
57 break;
58
59 case 0x01:
60 eJustify = SvxCellHorJustify::Left;
61 break;
62
63 case 0x02:
64 eJustify = SvxCellHorJustify::Center;
65 break;
66
67 case 0x03:
68 eJustify = SvxCellHorJustify::Right;
69 break;
70
71 case 0x04:
72 eJustify = SvxCellHorJustify::Block;
73 break;
74 }
75 rItemSet.Put( SvxHorJustifyItem( eJustify, ATTR_HOR_JUSTIFY ) );
76
77 // Vertical Alignment
78 SvxCellVerJustify eVerJustify = SvxCellVerJustify::Standard;
79 switch( nVer )
80 {
81 case 0x00:
82 eVerJustify = SvxCellVerJustify::Bottom;
83 break;
84
85 case 0x08:
86 eVerJustify = SvxCellVerJustify::Center;
87 break;
88
89 case 0x10:
90 eVerJustify = SvxCellVerJustify::Top;
91 break;
92 }
93
94 rItemSet.Put(SvxVerJustifyItem( eVerJustify, ATTR_VER_JUSTIFY ) );
95
96 // Orientation
97 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
98 switch( nOrient )
99 {
100 case 0x20:
101 eOrient = SvxCellOrientation::TopBottom;
102 break;
103
104 }
106
107 // Wrap cell contents
108 if( nTmp & 0x80 )
109 {
110 ScLineBreakCell aWrapItem(true);
111 rItemSet.Put( aWrapItem );
112 }
113
114 // Font Attributes
115 sal_uInt16 nTmpFnt = maFontRecord[ maFont[ nStyle ] ];
116 bool bIsBold, bIsItalic, bIsUnderLine;
117
118 bIsBold = ( nTmpFnt & 0x0001 ) != 0;
119 bIsItalic = ( nTmpFnt & 0x0002 ) != 0;
120 bIsUnderLine = ( nTmpFnt & 0x0004 ) != 0;
121 //(nTmpFnt & 0x0020 ) for StrikeThrough
122
123 if( bIsBold )
125 if( bIsItalic )
127 if( bIsUnderLine )
129
130 if (maFontHeight[ maFont [ nStyle ] ])
131 rItemSet.Put( SvxFontHeightItem( static_cast<sal_uLong>(20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) );
132
133 OUString fntName = maFontType[ maFont[ nStyle ] ];
134 rItemSet.Put( SvxFontItem( FAMILY_SYSTEM, fntName, OUString(), PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
135
136 pDoc->ApplyPattern( nCol, nRow, nTab, aPattern );
137}
138
139/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6170
SC_DLLPUBLIC void ApplyPattern(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4841
SfxItemSet & GetItemSet()
Definition: patattr.hxx:155
OUString maFontType[maxsize]
Definition: qprostyle.hxx:35
sal_uInt16 maFontHeight[maxsize]
Definition: qprostyle.hxx:34
sal_uInt16 maFontRecord[maxsize]
Definition: qprostyle.hxx:33
sal_uInt8 maFont[maxsize]
Definition: qprostyle.hxx:32
void SetFormat(ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle)
Definition: qprostyle.cxx:38
sal_uInt8 maAlign[maxsize]
Definition: qprostyle.hxx:31
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
LINESTYLE_SINGLE
PITCH_DONTKNOW
ITALIC_NORMAL
FAMILY_SYSTEM
WEIGHT_BOLD
constexpr TypedWhichId< SvxFontHeightItem > ATTR_FONT_HEIGHT(101)
constexpr TypedWhichId< SvxPostureItem > ATTR_FONT_POSTURE(103)
constexpr TypedWhichId< SvxWeightItem > ATTR_FONT_WEIGHT(102)
constexpr TypedWhichId< SvxHorJustifyItem > ATTR_HOR_JUSTIFY(129)
constexpr TypedWhichId< SvxVerJustifyItem > ATTR_VER_JUSTIFY(132)
constexpr TypedWhichId< SvxFontItem > ATTR_FONT(100)
constexpr TypedWhichId< SvxUnderlineItem > ATTR_FONT_UNDERLINE(104)
sal_uIntPtr sal_uLong
SvxCellHorJustify
SvxCellVerJustify
SvxCellOrientation
unsigned char sal_uInt8
sal_Int16 SCTAB
Definition: types.hxx:22