nss: upgrade to release 3.73
[LibreOffice.git] / sc / source / filter / qpro / qprostyle.cxx
blob00938af0b75780014de5f2376653f2252066d8c8
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 <sal/config.h>
22 #include <qprostyle.hxx>
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>
31 #include <editeng/justifyitem.hxx>
33 #include <attrib.hxx>
34 #include <global.hxx>
35 #include <docpool.hxx>
36 #include <patattr.hxx>
37 #include <document.hxx>
39 void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle )
41 if (nStyle >= maxsize)
42 return;
44 ScPatternAttr aPattern(pDoc->GetPool());
45 SfxItemSet& rItemSet = aPattern.GetItemSet();
47 sal_uInt8 nTmp = maAlign[ nStyle ];
48 sal_uInt8 nHor = ( nTmp & 0x07 );
49 sal_uInt8 nVer = ( nTmp & 0x18 );
50 sal_uInt8 nOrient = ( nTmp & 0x60 );
52 // Horizontal Alignment
53 SvxCellHorJustify eJustify = SvxCellHorJustify::Standard;
54 switch( nHor )
56 case 0x00:
57 eJustify = SvxCellHorJustify::Standard;
58 break;
60 case 0x01:
61 eJustify = SvxCellHorJustify::Left;
62 break;
64 case 0x02:
65 eJustify = SvxCellHorJustify::Center;
66 break;
68 case 0x03:
69 eJustify = SvxCellHorJustify::Right;
70 break;
72 case 0x04:
73 eJustify = SvxCellHorJustify::Block;
74 break;
76 rItemSet.Put( SvxHorJustifyItem( eJustify, ATTR_HOR_JUSTIFY ) );
78 // Vertical Alignment
79 SvxCellVerJustify eVerJustify = SvxCellVerJustify::Standard;
80 switch( nVer )
82 case 0x00:
83 eVerJustify = SvxCellVerJustify::Bottom;
84 break;
86 case 0x08:
87 eVerJustify = SvxCellVerJustify::Center;
88 break;
90 case 0x10:
91 eVerJustify = SvxCellVerJustify::Top;
92 break;
95 rItemSet.Put(SvxVerJustifyItem( eVerJustify, ATTR_VER_JUSTIFY ) );
97 // Orientation
98 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
99 switch( nOrient )
101 case 0x20:
102 eOrient = SvxCellOrientation::TopBottom;
103 break;
106 rItemSet.Put( SvxOrientationItem( eOrient, 0) );
108 // Wrap cell contents
109 if( nTmp & 0x80 )
111 ScLineBreakCell aWrapItem(true);
112 rItemSet.Put( aWrapItem );
115 // Font Attributes
116 sal_uInt16 nTmpFnt = maFontRecord[ maFont[ nStyle ] ];
117 bool bIsBold, bIsItalic, bIsUnderLine;
119 bIsBold = ( nTmpFnt & 0x0001 ) != 0;
120 bIsItalic = ( nTmpFnt & 0x0002 ) != 0;
121 bIsUnderLine = ( nTmpFnt & 0x0004 ) != 0;
122 //(nTmpFnt & 0x0020 ) for StrikeThrough
124 if( bIsBold )
125 rItemSet.Put( SvxWeightItem( WEIGHT_BOLD,ATTR_FONT_WEIGHT) );
126 if( bIsItalic )
127 rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
128 if( bIsUnderLine )
129 rItemSet.Put( SvxUnderlineItem( LINESTYLE_SINGLE, ATTR_FONT_UNDERLINE ) );
131 if (maFontHeight[ maFont [ nStyle ] ])
132 rItemSet.Put( SvxFontHeightItem( static_cast<sal_uLong>(20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) );
134 OUString fntName = maFontType[ maFont[ nStyle ] ];
135 rItemSet.Put( SvxFontItem( FAMILY_SYSTEM, fntName, EMPTY_OUSTRING, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
137 pDoc->ApplyPattern( nCol, nRow, nTab, aPattern );
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */