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>
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>
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
)
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
;
56 eJustify
= SvxCellHorJustify::Standard
;
60 eJustify
= SvxCellHorJustify::Left
;
64 eJustify
= SvxCellHorJustify::Center
;
68 eJustify
= SvxCellHorJustify::Right
;
72 eJustify
= SvxCellHorJustify::Block
;
75 rItemSet
.Put( SvxHorJustifyItem( eJustify
, ATTR_HOR_JUSTIFY
) );
78 SvxCellVerJustify eVerJustify
= SvxCellVerJustify::Standard
;
82 eVerJustify
= SvxCellVerJustify::Bottom
;
86 eVerJustify
= SvxCellVerJustify::Center
;
90 eVerJustify
= SvxCellVerJustify::Top
;
94 rItemSet
.Put(SvxVerJustifyItem( eVerJustify
, ATTR_VER_JUSTIFY
) );
97 SvxCellOrientation eOrient
= SvxCellOrientation::Standard
;
101 eOrient
= SvxCellOrientation::TopBottom
;
105 rItemSet
.Put( SvxOrientationItem( eOrient
, 0) );
107 // Wrap cell contents
110 SfxBoolItem
aWrapItem( ATTR_LINEBREAK
);
111 aWrapItem
.SetValue( true );
112 rItemSet
.Put( aWrapItem
);
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
125 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
,ATTR_FONT_WEIGHT
) );
127 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
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: */