xref: /trunk/main/sw/inc/tblafmt.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _TBLAFMT_HXX
28 #define _TBLAFMT_HXX
29 /*************************************************************************
30 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 
32 JP 20.07.95:
33 
34     Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
35     Diese wird durch unterschiedlichen Code vom StartWriter und vom StarCalc
36     eingelesen/geschrieben.
37     Sollte sich doch mal eine Aenderung nicht vermeiden lassen, dann auf
38     jedenfall in beiden Applikationen aendern.
39 
40     The structure of table auto formatting should not changed. It is used
41     by different code of Writer and Calc. If a change is necessary, the
42     source code of both applications must be changed!
43 
44 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45 **************************************************************************/
46 
47 #include <svl/svarray.hxx>
48 #include "hintids.hxx"          //_immmer_ vor den solar-items!
49 #include <svx/algitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <editeng/fhgtitem.hxx>
52 #include <editeng/wghtitem.hxx>
53 #include <editeng/postitem.hxx>
54 #include <editeng/udlnitem.hxx>
55 #include <editeng/crsditem.hxx>
56 #ifndef _SVX_CNTRTITEM_HXX //autogen
57 #include <editeng/cntritem.hxx>
58 #endif
59 #include <editeng/shdditem.hxx>
60 #include <editeng/colritem.hxx>
61 #include <editeng/boxitem.hxx>
62 #include <editeng/brshitem.hxx>
63 #include <editeng/adjitem.hxx>
64 #include <svx/rotmodit.hxx>
65 #include <svl/intitem.hxx>
66 #include <editeng/bolnitem.hxx>
67 #include "swdllapi.h"
68 
69 struct SwAfVersions;
70 
71 class SvNumberFormatter;
72 
73 class SwBoxAutoFmt
74 {
75     // common attributes of Calc and Writer
76     // --- from 641 on: CJK and CTL font settings
77     SvxFontItem         aFont;
78     SvxFontHeightItem   aHeight;
79     SvxWeightItem       aWeight;
80     SvxPostureItem      aPosture;
81 
82     SvxFontItem         aCJKFont;
83     SvxFontHeightItem   aCJKHeight;
84     SvxWeightItem       aCJKWeight;
85     SvxPostureItem      aCJKPosture;
86 
87     SvxFontItem         aCTLFont;
88     SvxFontHeightItem   aCTLHeight;
89     SvxWeightItem       aCTLWeight;
90     SvxPostureItem      aCTLPosture;
91 
92     SvxUnderlineItem    aUnderline;
93     SvxOverlineItem     aOverline;
94     SvxCrossedOutItem   aCrossedOut;
95     SvxContourItem      aContour;
96     SvxShadowedItem     aShadowed;
97     SvxColorItem        aColor;
98     SvxBoxItem          aBox;
99     SvxLineItem         aTLBR;
100     SvxLineItem         aBLTR;
101     SvxBrushItem        aBackground;
102 
103     // Writer specific
104     SvxAdjustItem       aAdjust;
105 
106     // Calc specific
107     SvxHorJustifyItem   aHorJustify;
108     SvxVerJustifyItem   aVerJustify;
109     SfxBoolItem         aStacked;
110     SvxMarginItem       aMargin;
111     SfxBoolItem         aLinebreak;
112     SfxInt32Item        aRotateAngle;
113     SvxRotateModeItem   aRotateMode;
114 
115     // number format
116     String              sNumFmtString;
117     LanguageType        eSysLanguage, eNumFmtLanguage;
118 
119 public:
120     SwBoxAutoFmt();
121     SwBoxAutoFmt( const SwBoxAutoFmt& rNew );
122     ~SwBoxAutoFmt();
123 
124     int operator==( const SwBoxAutoFmt& rCmp ) const;
125     SwBoxAutoFmt& operator=( const SwBoxAutoFmt& rNew );
126 
127     // die Get-Methoden
128     const SvxFontItem       &GetFont() const        { return aFont; }
129     const SvxFontHeightItem &GetHeight() const      { return aHeight; }
130     const SvxWeightItem     &GetWeight() const      { return aWeight; }
131     const SvxPostureItem    &GetPosture() const     { return aPosture; }
132     const SvxFontItem       &GetCJKFont() const     { return aCJKFont; }
133     const SvxFontHeightItem &GetCJKHeight() const   { return aCJKHeight; }
134     const SvxWeightItem     &GetCJKWeight() const   { return aCJKWeight; }
135     const SvxPostureItem    &GetCJKPosture() const  { return aCJKPosture; }
136     const SvxFontItem       &GetCTLFont() const     { return aCTLFont; }
137     const SvxFontHeightItem &GetCTLHeight() const   { return aCTLHeight; }
138     const SvxWeightItem     &GetCTLWeight() const   { return aCTLWeight; }
139     const SvxPostureItem    &GetCTLPosture() const  { return aCTLPosture; }
140     const SvxUnderlineItem  &GetUnderline() const   { return aUnderline; }
141     const SvxOverlineItem   &GetOverline() const    { return aOverline; }
142     const SvxCrossedOutItem &GetCrossedOut() const  { return aCrossedOut; }
143     const SvxContourItem    &GetContour() const     { return aContour; }
144     const SvxShadowedItem   &GetShadowed() const    { return aShadowed; }
145     const SvxColorItem      &GetColor() const       { return aColor; }
146     const SvxAdjustItem     &GetAdjust() const      { return aAdjust; }
147     const SvxBoxItem        &GetBox() const         { return aBox; }
148     const SvxLineItem       &GetTLBR() const        { return aTLBR; }
149     const SvxLineItem       &GetBLTR() const        { return aBLTR; }
150     const SvxBrushItem      &GetBackground() const  { return aBackground; }
151     void GetValueFormat( String& rFmt, LanguageType& rLng, LanguageType& rSys ) const
152         { rFmt = sNumFmtString; rLng = eNumFmtLanguage; rSys = eSysLanguage; }
153 
154     // die SetMethoden
155     void SetFont( const SvxFontItem& rNew )             { aFont = rNew; }
156     void SetHeight( const SvxFontHeightItem& rNew )     { aHeight = rNew; }
157     void SetWeight( const SvxWeightItem& rNew )         { aWeight = rNew; }
158     void SetPosture( const SvxPostureItem& rNew )       { aPosture = rNew; }
159     void SetCJKFont( const SvxFontItem& rNew )          { aCJKFont = rNew; }
160     void SetCJKHeight( const SvxFontHeightItem& rNew )  { aCJKHeight = rNew; }
161     void SetCJKWeight( const SvxWeightItem& rNew )      { aCJKWeight = rNew; }
162     void SetCJKPosture( const SvxPostureItem& rNew )    { aCJKPosture = rNew; }
163     void SetCTLFont( const SvxFontItem& rNew )          { aCTLFont = rNew; }
164     void SetCTLHeight( const SvxFontHeightItem& rNew )  { aCTLHeight = rNew; }
165     void SetCTLWeight( const SvxWeightItem& rNew )      { aCTLWeight = rNew; }
166     void SetCTLPosture( const SvxPostureItem& rNew )    { aCTLPosture = rNew; }
167     void SetUnderline( const SvxUnderlineItem& rNew )   { aUnderline = rNew; }
168     void SetOverline( const SvxOverlineItem& rNew )     { aOverline = rNew; }
169     void SetCrossedOut( const SvxCrossedOutItem& rNew ) { aCrossedOut = rNew; }
170     void SetContour( const SvxContourItem& rNew )       { aContour = rNew; }
171     void SetShadowed( const SvxShadowedItem& rNew )     { aShadowed = rNew; }
172     void SetColor( const SvxColorItem& rNew )           { aColor = rNew; }
173     void SetAdjust( const SvxAdjustItem& rNew )
174         {
175             aAdjust.SetAdjust( rNew.GetAdjust() );
176             aAdjust.SetOneWord( rNew.GetOneWord() );
177             aAdjust.SetLastBlock( rNew.GetLastBlock() );
178         }
179     void SetBox( const SvxBoxItem& rNew )               { aBox = rNew; }
180     void SetBackground( const SvxBrushItem& rNew )      { aBackground = rNew; }
181     void SetValueFormat( const String& rFmt, LanguageType eLng, LanguageType eSys )
182         { sNumFmtString = rFmt; eNumFmtLanguage = eLng; eSysLanguage = eSys; }
183 
184     sal_Bool Load( SvStream& rStream, const SwAfVersions& rVersions, sal_uInt16 nVer );
185     sal_Bool Save( SvStream& rStream ) const;
186     sal_Bool SaveVerionNo( SvStream& rStream ) const;
187 
188 #ifdef READ_OLDVERS
189     // lade alte Version
190     sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
191 #endif
192 };
193 
194 class SW_DLLPUBLIC SwTableAutoFmt
195 {
196     friend void _FinitCore();       // zum Zerstoeren des dflt. Pointers
197     static SwBoxAutoFmt* pDfltBoxAutoFmt;
198 
199     String aName;
200     sal_uInt16 nStrResId;
201 
202     // common flags of Calc and Writer
203     sal_Bool bInclFont : 1;
204     sal_Bool bInclJustify : 1;
205     sal_Bool bInclFrame : 1;
206     sal_Bool bInclBackground : 1;
207     sal_Bool bInclValueFormat : 1;
208 
209     // Calc specific flags
210     sal_Bool bInclWidthHeight : 1;
211 
212     SwBoxAutoFmt* aBoxAutoFmt[ 16 ];
213 
214 public:
215     SwTableAutoFmt( const String& rName );
216     SwTableAutoFmt( const SwTableAutoFmt& rNew );
217     ~SwTableAutoFmt();
218 
219     SwTableAutoFmt& operator=( const SwTableAutoFmt& rNew );
220 
221     void SetBoxFmt( const SwBoxAutoFmt& rNew, sal_uInt8 nPos );
222     const SwBoxAutoFmt& GetBoxFmt( sal_uInt8 nPos ) const;
223 
224     void SetName( const String& rNew ) { aName = rNew; nStrResId = USHRT_MAX; }
225     const String& GetName() const { return aName; }
226 
227     enum UpdateFlags { UPDATE_CHAR = 1, UPDATE_BOX = 2, UPDATE_ALL = 3 };
228     SwBoxAutoFmt& UpdateFromSet( sal_uInt8 nPos, const SfxItemSet& rSet,
229                                 UpdateFlags eFlags, SvNumberFormatter* );
230     void UpdateToSet( sal_uInt8 nPos, SfxItemSet& rSet, UpdateFlags eFlags,
231                         SvNumberFormatter* ) const ;
232 
233     sal_Bool IsFont() const         { return bInclFont; }
234     sal_Bool IsJustify() const      { return bInclJustify; }
235     sal_Bool IsFrame() const        { return bInclFrame; }
236     sal_Bool IsBackground() const   { return bInclBackground; }
237     sal_Bool IsValueFormat() const  { return bInclValueFormat; }
238 
239     void SetFont( const sal_Bool bNew )         { bInclFont = bNew; }
240     void SetJustify( const  sal_Bool bNew )     { bInclJustify = bNew; }
241     void SetFrame( const sal_Bool bNew )        { bInclFrame = bNew; }
242     void SetBackground( const sal_Bool bNew )   { bInclBackground = bNew; }
243     void SetValueFormat( const sal_Bool bNew )  { bInclValueFormat = bNew; }
244     void SetWidthHeight( const sal_Bool bNew )  { bInclWidthHeight = bNew; }
245 
246     sal_Bool Load( SvStream& rStream, const SwAfVersions& );
247     sal_Bool Save( SvStream& rStream ) const;
248 
249 #ifdef READ_OLDVERS
250     // lade alte Version
251     sal_Bool LoadOld( SvStream& rStream, sal_uInt16 aLoadVer[] );
252 #endif
253 };
254 
255 typedef SwTableAutoFmt* SwTableAutoFmtPtr ;
256 SV_DECL_PTRARR_DEL( _SwTableAutoFmtTbl, SwTableAutoFmtPtr, 1, 5 )
257 
258 class SW_DLLPUBLIC SwTableAutoFmtTbl : public _SwTableAutoFmtTbl
259 {
260     SW_DLLPRIVATE sal_Bool Load( SvStream& rStream );
261     SW_DLLPRIVATE sal_Bool Save( SvStream& rStream ) const;
262 
263 public:
264     SwTableAutoFmtTbl();
265 
266     sal_Bool Load();
267     sal_Bool Save() const;
268 };
269 
270 #endif
271