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