xref: /trunk/main/sc/inc/autoform.hxx (revision 38d50f7b)
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 
24 #ifndef SC_AUTOFORM_HXX
25 #define SC_AUTOFORM_HXX
26 
27 /*************************************************************************
28 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 
30 JP 20.07.95:
31 
32 	Die akt. Struktur der Autoformatierung darf nicht mehr veraendert werden.
33 	Diese wird durch unterschiedlichen Code vom StartWriter und vom StarCalc
34 	eingelesen/geschrieben.
35 	Sollte sich doch mal eine Aenderung nicht vermeiden lassen, dann auf
36 	jedenfall in beiden Applikationen aendern.
37 
38     The structure of table auto formatting should not changed. It is used
39     by different code of Writer and Calc. If a change is necessary, the
40     source code of both applications must be changed!
41 
42 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43 **************************************************************************/
44 
45 #include "scitems.hxx"
46 #include <editeng/adjitem.hxx>
47 #include <svx/algitem.hxx>
48 #include <editeng/boxitem.hxx>
49 #include <editeng/brshitem.hxx>
50 #include <editeng/cntritem.hxx>
51 #include <editeng/colritem.hxx>
52 #include <editeng/crsditem.hxx>
53 #include <editeng/fhgtitem.hxx>
54 #include <editeng/fontitem.hxx>
55 #include <editeng/postitem.hxx>
56 #include <editeng/shdditem.hxx>
57 #include <editeng/udlnitem.hxx>
58 #include <editeng/wghtitem.hxx>
59 #include <svx/rotmodit.hxx>
60 #include <svl/intitem.hxx>
61 #include <editeng/bolnitem.hxx>
62 #include "scdllapi.h"
63 #include "collect.hxx"
64 #include "global.hxx"
65 #include "zforauto.hxx"
66 
67 
68 struct ScAfVersions;
69 
70 
71 /// Contains all items for one cell of a table autoformat.
72 class ScAutoFormatDataField
73 {
74 private:
75     SvxFontItem                 aFont;
76     SvxFontHeightItem           aHeight;
77     SvxWeightItem               aWeight;
78     SvxPostureItem              aPosture;
79 
80     SvxFontItem                 aCJKFont;
81     SvxFontHeightItem           aCJKHeight;
82     SvxWeightItem               aCJKWeight;
83     SvxPostureItem              aCJKPosture;
84 
85     SvxFontItem                 aCTLFont;
86     SvxFontHeightItem           aCTLHeight;
87     SvxWeightItem               aCTLWeight;
88     SvxPostureItem              aCTLPosture;
89 
90     SvxUnderlineItem            aUnderline;
91     SvxOverlineItem             aOverline;
92     SvxCrossedOutItem           aCrossedOut;
93     SvxContourItem              aContour;
94     SvxShadowedItem             aShadowed;
95     SvxColorItem                aColor;
96     SvxBoxItem                  aBox;
97     SvxLineItem                 aTLBR;
98     SvxLineItem                 aBLTR;
99     SvxBrushItem                aBackground;
100 
101     // Writer specific
102     SvxAdjustItem               aAdjust;
103 
104     // Calc specific
105     SvxHorJustifyItem           aHorJustify;
106     SvxVerJustifyItem           aVerJustify;
107     SfxBoolItem                 aStacked;
108     SvxMarginItem               aMargin;
109     SfxBoolItem                 aLinebreak;
110     // from SO5, 504k on, rotated text
111     SfxInt32Item                aRotateAngle;
112     SvxRotateModeItem           aRotateMode;
113 
114     // number format
115     ScNumFormatAbbrev           aNumFormat;
116 
117 public:
118                                 ScAutoFormatDataField();
119                                 ScAutoFormatDataField( const ScAutoFormatDataField& rCopy );
120                                 ~ScAutoFormatDataField();
121 
GetNumFormat() const122     const ScNumFormatAbbrev&    GetNumFormat() const    { return aNumFormat; }
GetFont() const123     const SvxFontItem&          GetFont() const         { return aFont; }
GetHeight() const124     const SvxFontHeightItem&    GetHeight() const       { return aHeight; }
GetWeight() const125     const SvxWeightItem&        GetWeight() const       { return aWeight; }
GetPosture() const126     const SvxPostureItem&       GetPosture() const      { return aPosture; }
GetCJKFont() const127     const SvxFontItem&          GetCJKFont() const      { return aCJKFont; }
GetCJKHeight() const128     const SvxFontHeightItem&    GetCJKHeight() const    { return aCJKHeight; }
GetCJKWeight() const129     const SvxWeightItem&        GetCJKWeight() const    { return aCJKWeight; }
GetCJKPosture() const130     const SvxPostureItem&       GetCJKPosture() const   { return aCJKPosture; }
GetCTLFont() const131     const SvxFontItem&          GetCTLFont() const      { return aCTLFont; }
GetCTLHeight() const132     const SvxFontHeightItem&    GetCTLHeight() const    { return aCTLHeight; }
GetCTLWeight() const133     const SvxWeightItem&        GetCTLWeight() const    { return aCTLWeight; }
GetCTLPosture() const134     const SvxPostureItem&       GetCTLPosture() const   { return aCTLPosture; }
GetUnderline() const135     const SvxUnderlineItem&     GetUnderline() const    { return aUnderline; }
GetOverline() const136     const SvxOverlineItem&      GetOverline() const     { return aOverline; }
GetCrossedOut() const137     const SvxCrossedOutItem&    GetCrossedOut() const   { return aCrossedOut; }
GetContour() const138     const SvxContourItem&       GetContour() const      { return aContour; }
GetShadowed() const139     const SvxShadowedItem&      GetShadowed() const     { return aShadowed; }
GetColor() const140     const SvxColorItem&         GetColor() const        { return aColor; }
GetHorJustify() const141     const SvxHorJustifyItem&    GetHorJustify() const   { return aHorJustify; }
GetVerJustify() const142     const SvxVerJustifyItem&    GetVerJustify() const   { return aVerJustify; }
GetStacked() const143     const SfxBoolItem&          GetStacked() const      { return aStacked; }
GetLinebreak() const144     const SfxBoolItem&          GetLinebreak() const    { return aLinebreak; }
GetMargin() const145     const SvxMarginItem&        GetMargin() const       { return aMargin; }
GetBox() const146     const SvxBoxItem&           GetBox() const          { return aBox; }
GetTLBR() const147     const SvxLineItem&          GetTLBR() const         { return aTLBR; }
GetBLTR() const148     const SvxLineItem&          GetBLTR() const         { return aBLTR; }
GetBackground() const149     const SvxBrushItem&         GetBackground() const   { return aBackground; }
GetAdjust() const150     const SvxAdjustItem&        GetAdjust() const       { return aAdjust; }
GetRotateAngle() const151     const SfxInt32Item&         GetRotateAngle() const  { return aRotateAngle; }
GetRotateMode() const152     const SvxRotateModeItem&    GetRotateMode() const   { return aRotateMode; }
153 
SetNumFormat(const ScNumFormatAbbrev & rNumFormat)154     void    SetNumFormat( const ScNumFormatAbbrev& rNumFormat )     { aNumFormat = rNumFormat; }
SetFont(const SvxFontItem & rFont)155     void    SetFont( const SvxFontItem& rFont )                     { aFont = rFont; }
SetHeight(const SvxFontHeightItem & rHeight)156     void    SetHeight( const SvxFontHeightItem& rHeight )           { aHeight = rHeight; }
SetWeight(const SvxWeightItem & rWeight)157     void    SetWeight( const SvxWeightItem& rWeight )               { aWeight = rWeight; }
SetPosture(const SvxPostureItem & rPosture)158     void    SetPosture( const SvxPostureItem& rPosture )            { aPosture = rPosture; }
SetCJKFont(const SvxFontItem & rCJKFont)159     void    SetCJKFont( const SvxFontItem& rCJKFont )               { aCJKFont = rCJKFont; }
SetCJKHeight(const SvxFontHeightItem & rCJKHeight)160     void    SetCJKHeight( const SvxFontHeightItem& rCJKHeight )     { aCJKHeight = rCJKHeight; }
SetCJKWeight(const SvxWeightItem & rCJKWeight)161     void    SetCJKWeight( const SvxWeightItem& rCJKWeight )         { aCJKWeight = rCJKWeight; }
SetCJKPosture(const SvxPostureItem & rCJKPosture)162     void    SetCJKPosture( const SvxPostureItem& rCJKPosture )      { aCJKPosture = rCJKPosture; }
SetCTLFont(const SvxFontItem & rCTLFont)163     void    SetCTLFont( const SvxFontItem& rCTLFont )               { aCTLFont = rCTLFont; }
SetCTLHeight(const SvxFontHeightItem & rCTLHeight)164     void    SetCTLHeight( const SvxFontHeightItem& rCTLHeight )     { aCTLHeight = rCTLHeight; }
SetCTLWeight(const SvxWeightItem & rCTLWeight)165     void    SetCTLWeight( const SvxWeightItem& rCTLWeight )         { aCTLWeight = rCTLWeight; }
SetCTLPosture(const SvxPostureItem & rCTLPosture)166     void    SetCTLPosture( const SvxPostureItem& rCTLPosture )      { aCTLPosture = rCTLPosture; }
SetUnderline(const SvxUnderlineItem & rUnderline)167     void    SetUnderline( const SvxUnderlineItem& rUnderline )      { aUnderline = rUnderline; }
SetOverline(const SvxOverlineItem & rOverline)168     void    SetOverline( const SvxOverlineItem& rOverline )         { aOverline = rOverline; }
SetCrossedOut(const SvxCrossedOutItem & rCrossedOut)169     void    SetCrossedOut( const SvxCrossedOutItem& rCrossedOut )   { aCrossedOut = rCrossedOut; }
SetContour(const SvxContourItem & rContour)170     void    SetContour( const SvxContourItem& rContour )            { aContour = rContour; }
SetShadowed(const SvxShadowedItem & rShadowed)171     void    SetShadowed( const SvxShadowedItem& rShadowed )         { aShadowed = rShadowed; }
SetColor(const SvxColorItem & rColor)172     void    SetColor( const SvxColorItem& rColor )                  { aColor = rColor; }
SetHorJustify(const SvxHorJustifyItem & rHorJustify)173     void    SetHorJustify( const SvxHorJustifyItem& rHorJustify )   { aHorJustify = rHorJustify; }
SetVerJustify(const SvxVerJustifyItem & rVerJustify)174     void    SetVerJustify( const SvxVerJustifyItem& rVerJustify )   { aVerJustify = rVerJustify; }
SetStacked(const SfxBoolItem & rStacked)175     void    SetStacked( const SfxBoolItem& rStacked )               { aStacked.SetValue( rStacked.GetValue() ); }
SetLinebreak(const SfxBoolItem & rLinebreak)176     void    SetLinebreak( const SfxBoolItem& rLinebreak )           { aLinebreak.SetValue( rLinebreak.GetValue() ); }
SetMargin(const SvxMarginItem & rMargin)177     void    SetMargin( const SvxMarginItem& rMargin )               { aMargin = rMargin; }
SetBox(const SvxBoxItem & rBox)178     void    SetBox( const SvxBoxItem& rBox )                        { aBox = rBox; }
SetTLBR(const SvxLineItem & rTLBR)179     void    SetTLBR( const SvxLineItem& rTLBR )                     { aTLBR = rTLBR; }
SetBLTR(const SvxLineItem & rBLTR)180     void    SetBLTR( const SvxLineItem& rBLTR )                     { aBLTR = rBLTR; }
SetBackground(const SvxBrushItem & rBackground)181     void    SetBackground( const SvxBrushItem& rBackground )        { aBackground = rBackground; }
182     void    SetAdjust( const SvxAdjustItem& rAdjust );
SetRotateAngle(const SfxInt32Item & rRotateAngle)183     void    SetRotateAngle( const SfxInt32Item& rRotateAngle )      { aRotateAngle.SetValue( rRotateAngle.GetValue() ); }
SetRotateMode(const SvxRotateModeItem & rRotateMode)184     void    SetRotateMode( const SvxRotateModeItem& rRotateMode )   { aRotateMode.SetValue( rRotateMode.GetValue() ); }
185 
186     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions, sal_uInt16 nVer );
187     sal_Bool                        Save( SvStream& rStream );
188 
189 #ifdef READ_OLDVERS
190     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
191 #endif
192 };
193 
194 
195 class SC_DLLPUBLIC ScAutoFormatData : public ScDataObject
196 {
197 private:
198     String                      aName;
199     sal_uInt16                      nStrResId;
200     // common flags of Calc and Writer
201     sal_Bool                        bIncludeFont : 1;
202     sal_Bool                        bIncludeJustify : 1;
203     sal_Bool                        bIncludeFrame : 1;
204     sal_Bool                        bIncludeBackground : 1;
205 
206     // Calc specific flags
207     sal_Bool                        bIncludeValueFormat : 1;
208     sal_Bool                        bIncludeWidthHeight : 1;
209 
210     ScAutoFormatDataField**     ppDataField;
211 
212     SC_DLLPRIVATE ScAutoFormatDataField&       GetField( sal_uInt16 nIndex );
213     SC_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
214 
215 public:
216                     ScAutoFormatData();
217                     ScAutoFormatData( const ScAutoFormatData& rData );
218     virtual         ~ScAutoFormatData();
219 
Clone() const220     virtual         ScDataObject* Clone() const { return new ScAutoFormatData( *this ); }
221 
SetName(const String & rName)222     void            SetName( const String& rName )              { aName = rName; nStrResId = USHRT_MAX; }
GetName(String & rName) const223     void            GetName( String& rName ) const              { rName = aName; }
224 
GetIncludeValueFormat() const225     sal_Bool            GetIncludeValueFormat() const               { return bIncludeValueFormat; }
GetIncludeFont() const226     sal_Bool            GetIncludeFont() const                      { return bIncludeFont; }
GetIncludeJustify() const227     sal_Bool            GetIncludeJustify() const                   { return bIncludeJustify; }
GetIncludeFrame() const228     sal_Bool            GetIncludeFrame() const                     { return bIncludeFrame; }
GetIncludeBackground() const229     sal_Bool            GetIncludeBackground() const                { return bIncludeBackground; }
GetIncludeWidthHeight() const230     sal_Bool            GetIncludeWidthHeight() const               { return bIncludeWidthHeight; }
231 
SetIncludeValueFormat(sal_Bool bValueFormat)232     void            SetIncludeValueFormat( sal_Bool bValueFormat )  { bIncludeValueFormat = bValueFormat; }
SetIncludeFont(sal_Bool bFont)233     void            SetIncludeFont( sal_Bool bFont )                { bIncludeFont = bFont; }
SetIncludeJustify(sal_Bool bJustify)234     void            SetIncludeJustify( sal_Bool bJustify )          { bIncludeJustify = bJustify; }
SetIncludeFrame(sal_Bool bFrame)235     void            SetIncludeFrame( sal_Bool bFrame )              { bIncludeFrame = bFrame; }
SetIncludeBackground(sal_Bool bBackground)236     void            SetIncludeBackground( sal_Bool bBackground )    { bIncludeBackground = bBackground; }
SetIncludeWidthHeight(sal_Bool bWidthHeight)237     void            SetIncludeWidthHeight( sal_Bool bWidthHeight )  { bIncludeWidthHeight = bWidthHeight; }
238 
239     const SfxPoolItem*          GetItem( sal_uInt16 nIndex, sal_uInt16 nWhich ) const;
240     void                        PutItem( sal_uInt16 nIndex, const SfxPoolItem& rItem );
241     void                        CopyItem( sal_uInt16 nToIndex, sal_uInt16 nFromIndex, sal_uInt16 nWhich );
242 
243     const ScNumFormatAbbrev&    GetNumFormat( sal_uInt16 nIndex ) const;
244 
245     sal_Bool                        IsEqualData( sal_uInt16 nIndex1, sal_uInt16 nIndex2 ) const;
246 
247     void                        FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, ScDocument& rDoc ) const;
248     void                        GetFromItemSet( sal_uInt16 nIndex, const SfxItemSet& rItemSet, const ScNumFormatAbbrev& rNumFormat );
249 
250     sal_Bool                        Load( SvStream& rStream, const ScAfVersions& rVersions );
251     sal_Bool                        Save( SvStream& rStream );
252 
253 #ifdef READ_OLDVERS
254     sal_Bool                        LoadOld( SvStream& rStream, const ScAfVersions& rVersions );
255 #endif
256 };
257 
258 class SC_DLLPUBLIC ScAutoFormat : public ScSortedCollection
259 {
260 private:
261     sal_Bool                        bSaveLater;
262 
263 public:
264                                 ScAutoFormat( sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = sal_False );
265                                 ScAutoFormat( const ScAutoFormat& AutoFormat );
266     virtual                     ~ScAutoFormat();
Clone() const267     virtual                     ScDataObject*         Clone() const { return new ScAutoFormat( *this ); }
operator [](const sal_uInt16 nIndex) const268                                 ScAutoFormatData*   operator[]( const sal_uInt16 nIndex ) const {return (ScAutoFormatData*)At( nIndex );}
269     virtual short               Compare( ScDataObject* pKey1, ScDataObject* pKey2 ) const;
270     sal_Bool                        Load();
271     sal_Bool                        Save();
272     sal_uInt16                      FindIndexPerName( const String& rName ) const;
273     void                        SetSaveLater( sal_Bool bSet );
IsSaveLater() const274     sal_Bool                        IsSaveLater() const         { return bSaveLater; }
275 };
276 
277 
278 #endif
279