1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sfx2/docfile.hxx>
23 #include "qproform.hxx"
25 #include "qprostyle.hxx"
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>
39 #include "scerrors.hxx"
40 #include "docpool.hxx"
41 #include "patattr.hxx"
43 #include "document.hxx"
44 #include "formulacell.hxx"
46 ScQProStyle::ScQProStyle()
48 memset (maAlign
, 0, sizeof (maAlign
));
49 memset (maFont
, 0, sizeof (maFont
));
50 memset (maFontRecord
, 0, sizeof (maFontRecord
));
51 memset (maFontHeight
, 0, sizeof (maFontHeight
));
54 void ScQProStyle::SetFormat( ScDocument
*pDoc
, sal_uInt8 nCol
, sal_uInt16 nRow
, SCTAB nTab
, sal_uInt16 nStyle
)
56 if (nStyle
>= maxsize
)
59 ScPatternAttr
aPattern(pDoc
->GetPool());
60 SfxItemSet
& rItemSet
= aPattern
.GetItemSet();
62 sal_uInt8 nTmp
= maAlign
[ nStyle
];
63 sal_uInt8 nHor
= ( nTmp
& 0x07 );
64 sal_uInt8 nVer
= ( nTmp
& 0x18 );
65 sal_uInt8 nOrient
= ( nTmp
& 0x60 );
67 // Horizontal Alignment
68 SvxCellHorJustify eJustify
= SVX_HOR_JUSTIFY_STANDARD
;
72 eJustify
= SVX_HOR_JUSTIFY_STANDARD
;
76 eJustify
= SVX_HOR_JUSTIFY_LEFT
;
80 eJustify
= SVX_HOR_JUSTIFY_CENTER
;
84 eJustify
= SVX_HOR_JUSTIFY_RIGHT
;
88 eJustify
= SVX_HOR_JUSTIFY_BLOCK
;
91 rItemSet
.Put( SvxHorJustifyItem( eJustify
, ATTR_HOR_JUSTIFY
) );
94 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
98 eVerJustify
= SVX_VER_JUSTIFY_BOTTOM
;
102 eVerJustify
= SVX_VER_JUSTIFY_CENTER
;
106 eVerJustify
= SVX_VER_JUSTIFY_TOP
;
110 rItemSet
.Put(SvxVerJustifyItem( eVerJustify
, ATTR_VER_JUSTIFY
) );
113 SvxCellOrientation eOrient
= SVX_ORIENTATION_STANDARD
;
117 eOrient
= SVX_ORIENTATION_TOPBOTTOM
;
121 rItemSet
.Put( SvxOrientationItem( eOrient
, 0) );
123 // Wrap cell contents
126 SfxBoolItem
aWrapItem( ATTR_LINEBREAK
);
127 aWrapItem
.SetValue( true );
128 rItemSet
.Put( aWrapItem
);
132 sal_uInt16 nTmpFnt
= maFontRecord
[ maFont
[ nStyle
] ];
133 bool bIsBold
, bIsItalic
, bIsUnderLine
;
135 bIsBold
= ( nTmpFnt
& 0x0001 ) != 0;
136 bIsItalic
= ( nTmpFnt
& 0x0002 ) != 0;
137 bIsUnderLine
= ( nTmpFnt
& 0x0004 ) != 0;
138 //(nTmpFnt & 0x0020 ) for StrikeThrough
141 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
,ATTR_FONT_WEIGHT
) );
143 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
145 rItemSet
.Put( SvxUnderlineItem( LINESTYLE_SINGLE
, ATTR_FONT_UNDERLINE
) );
147 if (maFontHeight
[ maFont
[ nStyle
] ])
148 rItemSet
.Put( SvxFontHeightItem( (sal_uLong
) (20 * maFontHeight
[ maFont
[ nStyle
] ] ), 100, ATTR_FONT_HEIGHT
) );
150 OUString fntName
= maFontType
[ maFont
[ nStyle
] ];
151 rItemSet
.Put( SvxFontItem( FAMILY_SYSTEM
, fntName
, EMPTY_OUSTRING
, PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
153 pDoc
->ApplyPattern( nCol
, nRow
, nTab
, aPattern
);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */