1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: qprostyle.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 #include <sal/config.h>
37 #include <sfx2/docfile.hxx>
39 #include "qproform.hxx"
41 #include "qprostyle.hxx"
43 #include <tools/color.hxx>
44 #include <scitems.hxx>
45 #include <svx/algitem.hxx>
46 #include <svx/udlnitem.hxx>
47 #include <svx/wghtitem.hxx>
48 #include <svx/postitem.hxx>
49 #include <svx/crsditem.hxx>
50 #include <svx/fhgtitem.hxx>
51 #include <svx/fontitem.hxx>
55 #include "scerrors.hxx"
56 #include "docpool.hxx"
57 #include "patattr.hxx"
59 #include "document.hxx"
62 ScQProStyle::ScQProStyle()
64 rtl_fillMemory (maAlign
, sizeof (maAlign
), 0);
65 rtl_fillMemory (maFont
, sizeof (maFont
), 0);
66 rtl_fillMemory (maFontRecord
, sizeof (maFontRecord
), 0);
67 rtl_fillMemory (maFontHeight
, sizeof (maFontHeight
), 0);
70 void ScQProStyle::SetFormat( ScDocument
*pDoc
, sal_uInt8 nCol
, sal_uInt16 nRow
, SCTAB nTab
, sal_uInt16 nStyle
)
72 if (nStyle
>= maxsize
)
75 ScPatternAttr
aPattern(pDoc
->GetPool());
76 SfxItemSet
& rItemSet
= aPattern
.GetItemSet();
78 sal_uInt8 nTmp
= maAlign
[ nStyle
];
79 sal_uInt8 nHor
= ( nTmp
& 0x07 );
80 sal_uInt8 nVer
= ( nTmp
& 0x18 );
81 sal_uInt8 nOrient
= ( nTmp
& 0x60 );
83 // Horizontal Alignment
84 SvxCellHorJustify eJustify
= SVX_HOR_JUSTIFY_STANDARD
;
88 eJustify
= SVX_HOR_JUSTIFY_STANDARD
;
92 eJustify
= SVX_HOR_JUSTIFY_LEFT
;
96 eJustify
= SVX_HOR_JUSTIFY_CENTER
;
100 eJustify
= SVX_HOR_JUSTIFY_RIGHT
;
104 eJustify
= SVX_HOR_JUSTIFY_BLOCK
;
107 rItemSet
.Put( SvxHorJustifyItem( eJustify
, ATTR_HOR_JUSTIFY
) );
109 // Vertical Alignment
110 SvxCellVerJustify eVerJustify
= SVX_VER_JUSTIFY_STANDARD
;
114 eVerJustify
= SVX_VER_JUSTIFY_BOTTOM
;
118 eVerJustify
= SVX_VER_JUSTIFY_CENTER
;
122 eVerJustify
= SVX_VER_JUSTIFY_TOP
;
126 rItemSet
.Put(SvxVerJustifyItem( eVerJustify
, ATTR_VER_JUSTIFY
) );
129 SvxCellOrientation eOrient
= SVX_ORIENTATION_STANDARD
;
133 eOrient
= SVX_ORIENTATION_TOPBOTTOM
;
137 rItemSet
.Put( SvxOrientationItem( eOrient
, 0) );
139 // Wrap cell contents
142 SfxBoolItem
aWrapItem( ATTR_LINEBREAK
);
143 aWrapItem
.SetValue( TRUE
);
144 rItemSet
.Put( aWrapItem
);
148 sal_uInt16 nTmpFnt
= maFontRecord
[ maFont
[ nStyle
] ];
149 BOOL bIsBold
, bIsItalic
, bIsUnderLine
, bIsStrikeThrough
;
151 bIsBold
= ( nTmpFnt
& 0x0001 ) != 0;
152 bIsItalic
= ( nTmpFnt
& 0x0002 ) != 0;
153 bIsUnderLine
= ( nTmpFnt
& 0x0004 ) != 0;
154 bIsStrikeThrough
= (nTmpFnt
& 0x0020 ) != 0;
157 rItemSet
.Put( SvxWeightItem( WEIGHT_BOLD
,ATTR_FONT_WEIGHT
) );
159 rItemSet
.Put( SvxPostureItem( ITALIC_NORMAL
, ATTR_FONT_POSTURE
) );
161 rItemSet
.Put( SvxUnderlineItem( UNDERLINE_SINGLE
, ATTR_FONT_UNDERLINE
) );
163 if (maFontHeight
[ maFont
[ nStyle
] ])
164 rItemSet
.Put( SvxFontHeightItem( (ULONG
) (20 * maFontHeight
[ maFont
[ nStyle
] ] ), 100, ATTR_FONT_HEIGHT
) );
166 String fntName
= maFontType
[ maFont
[ nStyle
] ];
167 rItemSet
.Put( SvxFontItem( FAMILY_SYSTEM
, fntName
, EMPTY_STRING
, PITCH_DONTKNOW
, RTL_TEXTENCODING_DONTKNOW
, ATTR_FONT
) );
169 pDoc
->ApplyPattern( nCol
, nRow
, nTab
, aPattern
);