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