Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / qpro / qprostyle.cxx
blobaf6628162e9ac6f1381b64c978aa8d8dbff5f155
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 <global.hxx>
34 #include <docpool.hxx>
35 #include <patattr.hxx>
36 #include <document.hxx>
38 void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle )
40 if (nStyle >= maxsize)
41 return;
43 ScPatternAttr aPattern(pDoc->GetPool());
44 SfxItemSet& rItemSet = aPattern.GetItemSet();
46 sal_uInt8 nTmp = maAlign[ nStyle ];
47 sal_uInt8 nHor = ( nTmp & 0x07 );
48 sal_uInt8 nVer = ( nTmp & 0x18 );
49 sal_uInt8 nOrient = ( nTmp & 0x60 );
51 // Horizontal Alignment
52 SvxCellHorJustify eJustify = SvxCellHorJustify::Standard;
53 switch( nHor )
55 case 0x00:
56 eJustify = SvxCellHorJustify::Standard;
57 break;
59 case 0x01:
60 eJustify = SvxCellHorJustify::Left;
61 break;
63 case 0x02:
64 eJustify = SvxCellHorJustify::Center;
65 break;
67 case 0x03:
68 eJustify = SvxCellHorJustify::Right;
69 break;
71 case 0x04:
72 eJustify = SvxCellHorJustify::Block;
73 break;
75 rItemSet.Put( SvxHorJustifyItem( eJustify, ATTR_HOR_JUSTIFY ) );
77 // Vertical Alignment
78 SvxCellVerJustify eVerJustify = SvxCellVerJustify::Standard;
79 switch( nVer )
81 case 0x00:
82 eVerJustify = SvxCellVerJustify::Bottom;
83 break;
85 case 0x08:
86 eVerJustify = SvxCellVerJustify::Center;
87 break;
89 case 0x10:
90 eVerJustify = SvxCellVerJustify::Top;
91 break;
94 rItemSet.Put(SvxVerJustifyItem( eVerJustify, ATTR_VER_JUSTIFY ) );
96 // Orientation
97 SvxCellOrientation eOrient = SvxCellOrientation::Standard;
98 switch( nOrient )
100 case 0x20:
101 eOrient = SvxCellOrientation::TopBottom;
102 break;
105 rItemSet.Put( SvxOrientationItem( eOrient, 0) );
107 // Wrap cell contents
108 if( nTmp & 0x80 )
110 SfxBoolItem aWrapItem( ATTR_LINEBREAK );
111 aWrapItem.SetValue( 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: */