fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / qpro / qprostyle.cxx
blobe0db22096c4a11df4e23dc517853b62944faac86
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>
21 #include <stdio.h>
22 #include <sfx2/docfile.hxx>
24 #include "qproform.hxx"
25 #include "qpro.hxx"
26 #include "qprostyle.hxx"
28 #include <scitems.hxx>
29 #include <svx/algitem.hxx>
30 #include <editeng/udlnitem.hxx>
31 #include <editeng/wghtitem.hxx>
32 #include <editeng/postitem.hxx>
33 #include <editeng/crossedoutitem.hxx>
34 #include <editeng/fhgtitem.hxx>
35 #include <editeng/fontitem.hxx>
36 #include <editeng/justifyitem.hxx>
37 #include <map>
39 #include "global.hxx"
40 #include "scerrors.hxx"
41 #include "docpool.hxx"
42 #include "patattr.hxx"
43 #include "filter.hxx"
44 #include "document.hxx"
45 #include "formulacell.hxx"
47 ScQProStyle::ScQProStyle()
49 memset (maAlign, 0, sizeof (maAlign));
50 memset (maFont, 0, sizeof (maFont));
51 memset (maFontRecord, 0, sizeof (maFontRecord));
52 memset (maFontHeight, 0, sizeof (maFontHeight));
55 void ScQProStyle::SetFormat( ScDocument *pDoc, sal_uInt8 nCol, sal_uInt16 nRow, SCTAB nTab, sal_uInt16 nStyle )
57 if (nStyle >= maxsize)
58 return;
60 ScPatternAttr aPattern(pDoc->GetPool());
61 SfxItemSet& rItemSet = aPattern.GetItemSet();
63 sal_uInt8 nTmp = maAlign[ nStyle ];
64 sal_uInt8 nHor = ( nTmp & 0x07 );
65 sal_uInt8 nVer = ( nTmp & 0x18 );
66 sal_uInt8 nOrient = ( nTmp & 0x60 );
68 // Horizontal Alignment
69 SvxCellHorJustify eJustify = SVX_HOR_JUSTIFY_STANDARD;
70 switch( nHor )
72 case 0x00:
73 eJustify = SVX_HOR_JUSTIFY_STANDARD;
74 break;
76 case 0x01:
77 eJustify = SVX_HOR_JUSTIFY_LEFT;
78 break;
80 case 0x02:
81 eJustify = SVX_HOR_JUSTIFY_CENTER;
82 break;
84 case 0x03:
85 eJustify = SVX_HOR_JUSTIFY_RIGHT;
86 break;
88 case 0x04:
89 eJustify = SVX_HOR_JUSTIFY_BLOCK;
90 break;
92 rItemSet.Put( SvxHorJustifyItem( eJustify, ATTR_HOR_JUSTIFY ) );
94 // Vertical Alignment
95 SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
96 switch( nVer )
98 case 0x00:
99 eVerJustify = SVX_VER_JUSTIFY_BOTTOM;
100 break;
102 case 0x08:
103 eVerJustify = SVX_VER_JUSTIFY_CENTER;
104 break;
106 case 0x10:
107 eVerJustify = SVX_VER_JUSTIFY_TOP;
108 break;
111 rItemSet.Put(SvxVerJustifyItem( eVerJustify, ATTR_VER_JUSTIFY ) );
113 // Orientation
114 SvxCellOrientation eOrient = SVX_ORIENTATION_STANDARD;
115 switch( nOrient )
117 case 0x20:
118 eOrient = SVX_ORIENTATION_TOPBOTTOM;
119 break;
122 rItemSet.Put( SvxOrientationItem( eOrient, 0) );
124 // Wrap cell contents
125 if( nTmp & 0x80 )
127 SfxBoolItem aWrapItem( ATTR_LINEBREAK );
128 aWrapItem.SetValue( true );
129 rItemSet.Put( aWrapItem );
132 // Font Attributes
133 sal_uInt16 nTmpFnt = maFontRecord[ maFont[ nStyle ] ];
134 bool bIsBold, bIsItalic, bIsUnderLine;
136 bIsBold = ( nTmpFnt & 0x0001 ) != 0;
137 bIsItalic = ( nTmpFnt & 0x0002 ) != 0;
138 bIsUnderLine = ( nTmpFnt & 0x0004 ) != 0;
139 //(nTmpFnt & 0x0020 ) for StrikeThrough
141 if( bIsBold )
142 rItemSet.Put( SvxWeightItem( WEIGHT_BOLD,ATTR_FONT_WEIGHT) );
143 if( bIsItalic )
144 rItemSet.Put( SvxPostureItem( ITALIC_NORMAL, ATTR_FONT_POSTURE ) );
145 if( bIsUnderLine )
146 rItemSet.Put( SvxUnderlineItem( UNDERLINE_SINGLE, ATTR_FONT_UNDERLINE ) );
148 if (maFontHeight[ maFont [ nStyle ] ])
149 rItemSet.Put( SvxFontHeightItem( (sal_uLong) (20 * maFontHeight[ maFont[ nStyle ] ] ), 100, ATTR_FONT_HEIGHT ) );
151 OUString fntName = maFontType[ maFont[ nStyle ] ];
152 rItemSet.Put( SvxFontItem( FAMILY_SYSTEM, fntName, EMPTY_OUSTRING, PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, ATTR_FONT ) );
154 pDoc->ApplyPattern( nCol, nRow, nTab, aPattern );
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */