xref: /trunk/main/sc/inc/attrib.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 
28 #ifndef SC_SCATTR_HXX
29 #define SC_SCATTR_HXX
30 
31 #include <svl/poolitem.hxx>
32 #include <svl/intitem.hxx>
33 #include <svl/eitem.hxx>
34 #include "scdllapi.h"
35 #include "global.hxx"
36 #include "address.hxx"
37 
38 //------------------------------------------------------------------------
39 
40                                         // Flags fuer durch Merge verdeckte Zellen
41                                         // und Control fuer Auto-Filter
42 #define SC_MF_HOR               0x0001
43 #define SC_MF_VER               0x0002
44 #define SC_MF_AUTO              0x0004  /// autofilter arrow
45 #define SC_MF_BUTTON            0x0008  /// field button for datapilot
46 #define SC_MF_SCENARIO          0x0010
47 #define SC_MF_BUTTON_POPUP      0x0020  /// dp button with popup arrow
48 #define SC_MF_HIDDEN_MEMBER     0x0040  /// dp field button with presence of hidden member
49 #define SC_MF_DP_TABLE          0x0080  /// dp table output
50 
51 #define SC_MF_ALL               0x00FF
52 
53 
54 class EditTextObject;
55 class SvxBorderLine;
56 
57 sal_Bool SC_DLLPUBLIC ScHasPriority( const SvxBorderLine* pThis, const SvxBorderLine* pOther );
58 
59 //------------------------------------------------------------------------
60 
61 class SC_DLLPUBLIC ScMergeAttr: public SfxPoolItem
62 {
63     SCsCOL      nColMerge;
64     SCsROW      nRowMerge;
65 public:
66                 TYPEINFO();
67                 ScMergeAttr();
68                 ScMergeAttr( SCsCOL nCol, SCsROW nRow = 0);
69                 ScMergeAttr( const ScMergeAttr& );
70                 ~ScMergeAttr();
71 
72     virtual String              GetValueText() const;
73 
74     virtual int             operator==( const SfxPoolItem& ) const;
75     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
76     virtual SfxPoolItem*    Create( SvStream& rStream, sal_uInt16 nVer ) const;
77 
78             SCsCOL          GetColMerge() const {return nColMerge; }
79             SCsROW          GetRowMerge() const {return nRowMerge; }
80 
81             sal_Bool            IsMerged() const { return nColMerge>1 || nRowMerge>1; }
82 
83     inline  ScMergeAttr& operator=(const ScMergeAttr& rMerge)
84             {
85                 nColMerge = rMerge.nColMerge;
86                 nRowMerge = rMerge.nRowMerge;
87                 return *this;
88             }
89 };
90 
91 //------------------------------------------------------------------------
92 
93 class SC_DLLPUBLIC ScMergeFlagAttr: public SfxInt16Item
94 {
95 public:
96             ScMergeFlagAttr();
97             ScMergeFlagAttr(sal_Int16 nFlags);
98             ~ScMergeFlagAttr();
99 
100     sal_Bool    IsHorOverlapped() const     { return ( GetValue() & SC_MF_HOR ) != 0;  }
101     sal_Bool    IsVerOverlapped() const     { return ( GetValue() & SC_MF_VER ) != 0;  }
102     sal_Bool    IsOverlapped() const        { return ( GetValue() & ( SC_MF_HOR | SC_MF_VER ) ) != 0; }
103 
104     sal_Bool    HasAutoFilter() const       { return ( GetValue() & SC_MF_AUTO ) != 0; }
105     sal_Bool    HasButton() const           { return ( GetValue() & SC_MF_BUTTON ) != 0; }
106     bool    HasDPTable() const          { return ( GetValue() & SC_MF_DP_TABLE ) != 0; }
107 
108     sal_Bool    IsScenario() const          { return ( GetValue() & SC_MF_SCENARIO ) != 0; }
109 };
110 
111 //------------------------------------------------------------------------
112 class SC_DLLPUBLIC ScProtectionAttr: public SfxPoolItem
113 {
114     sal_Bool        bProtection;    // Zelle schuetzen
115     sal_Bool        bHideFormula;   // Formel nicht Anzeigen
116     sal_Bool        bHideCell;      // Zelle nicht Anzeigen
117     sal_Bool        bHidePrint;     // Zelle nicht Ausdrucken
118 public:
119                             TYPEINFO();
120                             ScProtectionAttr();
121                             ScProtectionAttr(   sal_Bool bProtect,
122                                                 sal_Bool bHFormula = sal_False,
123                                                 sal_Bool bHCell = sal_False,
124                                                 sal_Bool bHPrint = sal_False);
125                             ScProtectionAttr( const ScProtectionAttr& );
126                             ~ScProtectionAttr();
127 
128     virtual String              GetValueText() const;
129     virtual SfxItemPresentation GetPresentation(
130                                     SfxItemPresentation ePres,
131                                     SfxMapUnit eCoreMetric,
132                                     SfxMapUnit ePresMetric,
133                                     String& rText,
134                                     const IntlWrapper* pIntl = 0 ) const;
135 
136     virtual int             operator==( const SfxPoolItem& ) const;
137     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
138     virtual SfxPoolItem*    Create( SvStream& rStream, sal_uInt16 nVer ) const;
139 
140     virtual sal_Bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
141     virtual sal_Bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
142 
143             sal_Bool            GetProtection() const { return bProtection; }
144             sal_Bool            SetProtection( sal_Bool bProtect);
145             sal_Bool            GetHideFormula() const { return bHideFormula; }
146             sal_Bool            SetHideFormula( sal_Bool bHFormula);
147             sal_Bool            GetHideCell() const { return bHideCell; }
148             sal_Bool            SetHideCell( sal_Bool bHCell);
149             sal_Bool            GetHidePrint() const { return bHidePrint; }
150             sal_Bool            SetHidePrint( sal_Bool bHPrint);
151     inline  ScProtectionAttr& operator=(const ScProtectionAttr& rProtection)
152             {
153                 bProtection = rProtection.bProtection;
154                 bHideFormula = rProtection.bHideFormula;
155                 bHideCell = rProtection.bHideCell;
156                 bHidePrint = rProtection.bHidePrint;
157                 return *this;
158             }
159 };
160 
161 
162 //----------------------------------------------------------------------------
163 // ScRangeItem: verwaltet einen Tabellenbereich
164 
165 #define SCR_INVALID     0x01
166 #define SCR_ALLTABS     0x02
167 #define SCR_TONEWTAB    0x04
168 
169 class ScRangeItem : public SfxPoolItem
170 {
171 public:
172             TYPEINFO();
173 
174             inline  ScRangeItem( const sal_uInt16 nWhich );
175             inline  ScRangeItem( const sal_uInt16   nWhich,
176                                  const ScRange& rRange,
177                                  const sal_uInt16   nNewFlags = 0 );
178             inline  ScRangeItem( const ScRangeItem& rCpy );
179 
180     inline ScRangeItem& operator=( const ScRangeItem &rCpy );
181 
182     // "pure virtual Methoden" vom SfxPoolItem
183     virtual int                 operator==( const SfxPoolItem& ) const;
184     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
185                                                  SfxMapUnit eCoreMetric,
186                                                  SfxMapUnit ePresMetric,
187                                                  String &rText,
188                                                  const IntlWrapper* pIntl = 0 ) const;
189     virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
190 
191     const ScRange&  GetRange() const                { return aRange;  }
192     void            SetRange( const ScRange& rNew ) { aRange = rNew; }
193 
194     sal_uInt16          GetFlags() const                { return nFlags;  }
195     void            SetFlags( sal_uInt16 nNew )         { nFlags = nNew; }
196 
197 private:
198     ScRange aRange;
199     sal_uInt16  nFlags;
200 };
201 
202 inline ScRangeItem::ScRangeItem( const sal_uInt16 nWhichP )
203     :   SfxPoolItem( nWhichP ), nFlags( SCR_INVALID ) // == ungueltige Area
204 {
205 }
206 
207 inline ScRangeItem::ScRangeItem( const sal_uInt16   nWhichP,
208                                  const ScRange& rRange,
209                                  const sal_uInt16   nNew )
210     : SfxPoolItem( nWhichP ), aRange( rRange ), nFlags( nNew )
211 {
212 }
213 
214 inline ScRangeItem::ScRangeItem( const ScRangeItem& rCpy )
215     : SfxPoolItem( rCpy.Which() ), aRange( rCpy.aRange ), nFlags( rCpy.nFlags )
216 {}
217 
218 inline ScRangeItem& ScRangeItem::operator=( const ScRangeItem &rCpy )
219 {
220     aRange = rCpy.aRange;
221     return *this;
222 }
223 
224 //----------------------------------------------------------------------------
225 // ScTableListItem: verwaltet eine Liste von Tabellen
226 //----------------------------------------------------------------------------
227 class ScTableListItem : public SfxPoolItem
228 {
229 public:
230     TYPEINFO();
231 
232     inline  ScTableListItem( const sal_uInt16 nWhich );
233             ScTableListItem( const ScTableListItem& rCpy );
234 //UNUSED2008-05  ScTableListItem( const sal_uInt16 nWhich, const List& rList );
235             ~ScTableListItem();
236 
237     ScTableListItem& operator=( const ScTableListItem &rCpy );
238 
239     // "pure virtual Methoden" vom SfxPoolItem
240     virtual int                 operator==( const SfxPoolItem& ) const;
241     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
242                                                  SfxMapUnit eCoreMetric,
243                                                  SfxMapUnit ePresMetric,
244                                                  String &rText,
245                                                  const IntlWrapper* pIntl = 0 ) const;
246     virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
247 
248 //UNUSED2009-05 sal_Bool    GetTableList( List& aList ) const;
249 //UNUSED2009-05 void    SetTableList( const List& aList );
250 
251 public:
252     sal_uInt16  nCount;
253     SCTAB*  pTabArr;
254 };
255 
256 inline ScTableListItem::ScTableListItem( const sal_uInt16 nWhichP )
257     : SfxPoolItem(nWhichP), nCount(0), pTabArr(NULL)
258 {}
259 
260 //----------------------------------------------------------------------------
261 // Seitenformat-Item: Kopf-/Fusszeileninhalte
262 
263 #define SC_HF_LEFTAREA   1
264 #define SC_HF_CENTERAREA 2
265 #define SC_HF_RIGHTAREA  3
266 
267 class SC_DLLPUBLIC ScPageHFItem : public SfxPoolItem
268 {
269     EditTextObject* pLeftArea;
270     EditTextObject* pCenterArea;
271     EditTextObject* pRightArea;
272 
273 public:
274                 TYPEINFO();
275                 ScPageHFItem( sal_uInt16 nWhich );
276                 ScPageHFItem( const ScPageHFItem& rItem );
277                 ~ScPageHFItem();
278 
279     virtual String          GetValueText() const;
280     virtual int             operator==( const SfxPoolItem& ) const;
281     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
282 
283     virtual SfxPoolItem*    Create( SvStream& rStream, sal_uInt16 nVer ) const;
284 
285     virtual sal_Bool            QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
286     virtual sal_Bool            PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
287 
288     const EditTextObject* GetLeftArea() const       { return pLeftArea; }
289     const EditTextObject* GetCenterArea() const     { return pCenterArea; }
290     const EditTextObject* GetRightArea() const      { return pRightArea; }
291 
292     void SetLeftArea( const EditTextObject& rNew );
293     void SetCenterArea( const EditTextObject& rNew );
294     void SetRightArea( const EditTextObject& rNew );
295 
296     //Set mit Uebereignung der Pointer, nArea siehe defines oben
297     void SetArea( EditTextObject *pNew, int nArea );
298 };
299 
300 
301 //----------------------------------------------------------------------------
302 // Seitenformat-Item: Kopf-/Fusszeileninhalte
303 
304 class SC_DLLPUBLIC ScViewObjectModeItem: public SfxEnumItem
305 {
306 public:
307                 TYPEINFO();
308 
309                 ScViewObjectModeItem( sal_uInt16 nWhich );
310                 ScViewObjectModeItem( sal_uInt16 nWhich, ScVObjMode eMode );
311                 ~ScViewObjectModeItem();
312 
313     virtual sal_uInt16              GetValueCount() const;
314     virtual String              GetValueText( sal_uInt16 nVal ) const;
315     virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
316     virtual SfxPoolItem*        Create(SvStream &, sal_uInt16) const;
317     virtual sal_uInt16              GetVersion( sal_uInt16 nFileVersion ) const;
318     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
319                                                  SfxMapUnit eCoreMetric,
320                                                  SfxMapUnit ePresMetric,
321                                                  String& rText,
322                                                  const IntlWrapper* pIntl = 0 ) const;
323 };
324 
325 //----------------------------------------------------------------------------
326 //
327 
328 class ScDoubleItem : public SfxPoolItem
329 {
330 public:
331                 TYPEINFO();
332                 ScDoubleItem( sal_uInt16 nWhich, double nVal=0 );
333                 ScDoubleItem( const ScDoubleItem& rItem );
334                 ~ScDoubleItem();
335 
336     virtual String          GetValueText() const;
337     virtual int             operator==( const SfxPoolItem& ) const;
338     virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
339 
340     virtual SfxPoolItem*    Create( SvStream& rStream, sal_uInt16 nVer ) const;
341 
342     double GetValue() const     { return nValue; }
343 
344     void SetValue( const double nVal ) { nValue = nVal;}
345 
346 private:
347     double  nValue;
348 };
349 
350 
351 // ============================================================================
352 
353 /** Member ID for "page scale to width" value in QueryValue() and PutValue(). */
354 const sal_uInt8 SC_MID_PAGE_SCALETO_WIDTH    = 1;
355 /** Member ID for "page scale to height" value in QueryValue() and PutValue(). */
356 const sal_uInt8 SC_MID_PAGE_SCALETO_HEIGHT   = 2;
357 
358 
359 /** Contains the "scale to width/height" attribute in page styles. */
360 class SC_DLLPUBLIC ScPageScaleToItem : public SfxPoolItem
361 {
362 public:
363                                 TYPEINFO();
364 
365     /** Default c'tor sets the width and height to 0. */
366     explicit                    ScPageScaleToItem();
367     explicit                    ScPageScaleToItem( sal_uInt16 nWidth, sal_uInt16 nHeight );
368 
369     virtual                     ~ScPageScaleToItem();
370 
371     virtual ScPageScaleToItem*  Clone( SfxItemPool* = 0 ) const;
372 
373     virtual int                 operator==( const SfxPoolItem& rCmp ) const;
374 
375     inline sal_uInt16           GetWidth() const { return mnWidth; }
376     inline sal_uInt16           GetHeight() const { return mnHeight; }
377     inline bool                 IsValid() const { return mnWidth || mnHeight; }
378 
379     inline void                 SetWidth( sal_uInt16 nWidth ) { mnWidth = nWidth; }
380     inline void                 SetHeight( sal_uInt16 nHeight ) { mnHeight = nHeight; }
381     inline void                 Set( sal_uInt16 nWidth, sal_uInt16 nHeight )
382                                     { mnWidth = nWidth; mnHeight = nHeight; }
383     inline void                 SetInvalid() { mnWidth = mnHeight = 0; }
384 
385     virtual SfxItemPresentation GetPresentation(
386                                     SfxItemPresentation ePresentation,
387                                     SfxMapUnit, SfxMapUnit,
388                                     XubString& rText,
389                                     const IntlWrapper* = 0 ) const;
390 
391     virtual sal_Bool                QueryValue( ::com::sun::star::uno::Any& rAny, sal_uInt8 nMemberId = 0 ) const;
392     virtual sal_Bool                PutValue( const ::com::sun::star::uno::Any& rAny, sal_uInt8 nMemberId = 0 );
393 
394 private:
395     sal_uInt16                  mnWidth;
396     sal_uInt16                  mnHeight;
397 };
398 
399 // ============================================================================
400 
401 #endif
402 
403