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 <sfx2/docfile.hxx>
24 #include "qproform.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>
40 #include "scerrors.hxx"
41 #include "docpool.hxx"
42 #include "patattr.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
)
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
;
73 eJustify
= SVX_HOR_JUSTIFY_STANDARD
;
77 eJustify
= SVX_HOR_JUSTIFY_LEFT
;
81 eJustify
= SVX_HOR_JUSTIFY_CENTER
;
85 eJustify
= SVX_HOR_JUSTIFY_RIGHT
;
89 eJustify
= SVX_HOR_JUSTIFY_BLOCK
;
92 rItemSet
.Put( SvxHorJustifyItem( eJustify
, ATTR_HOR_JUSTIFY
) );
95 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
99 eVerJustify
= SVX_VER_JUSTIFY_BOTTOM
;
103 eVerJustify
= SVX_VER_JUSTIFY_CENTER
;
107 eVerJustify
= SVX_VER_JUSTIFY_TOP
;
111 rItemSet
.Put(SvxVerJustifyItem( eVerJustify
, ATTR_VER_JUSTIFY
) );
114 SvxCellOrientation eOrient
= SVX_ORIENTATION_STANDARD
;
118 eOrient
= SVX_ORIENTATION_TOPBOTTOM
;
122 rItemSet
.Put( SvxOrientationItem( eOrient
, 0) );
124 // Wrap cell contents
127 SfxBoolItem
aWrapItem( ATTR_LINEBREAK
);
128 aWrapItem
.SetValue( true );
129 rItemSet
.Put( aWrapItem
);
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
142 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
,ATTR_FONT_WEIGHT
) );
144 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
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: */