xref: /aoo42x/main/sw/inc/cellatr.hxx (revision cdf0e10c)
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 _CELLATR_HXX
29 #define _CELLATR_HXX
30 
31 #include <svl/intitem.hxx>
32 #include <svl/zforlist.hxx>
33 #include "swdllapi.h"
34 #include "format.hxx"
35 #include "cellfml.hxx"
36 
37 class SW_DLLPUBLIC SwTblBoxNumFormat : public SfxUInt32Item
38 {
39 	sal_Bool bAuto;		// automatisch vergebenes Flag
40 public:
41 	SwTblBoxNumFormat( sal_uInt32 nFormat = NUMBERFORMAT_TEXT,
42 						sal_Bool bAuto = sal_False );
43 
44 	// "pure virtual Methoden" vom SfxPoolItem
45 	virtual int             operator==( const SfxPoolItem& ) const;
46 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
47 
48 	inline SwTblBoxNumFormat& operator=( const SwTblBoxNumFormat& rAttr )
49 	{
50 		SetValue( rAttr.GetValue() );
51 		SetAutoFlag( rAttr.GetAutoFlag() );
52 		return *this;
53 	}
54 
55 	sal_Bool GetAutoFlag() const 					{ return bAuto; }
56 	void SetAutoFlag( sal_Bool bFlag = sal_True )		{ bAuto = bFlag; }
57 };
58 
59 class SwTblBoxFormula : public SfxPoolItem, public SwTableFormula
60 {
61 	SwModify* pDefinedIn;	// Modify-Object, in dem die Formel steht
62 							// kann nur TablenBoxFormat sein
63 
64 public:
65 	SwTblBoxFormula( const String& rFormula );
66 
67 	// "pure virtual Methoden" vom SfxPoolItem
68 	virtual int             operator==( const SfxPoolItem& ) const;
69 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
70 
71 	// erfrage und setze den Modify-Pointer
72 	inline const SwModify* GetDefinedIn() const { return pDefinedIn; }
73 	inline void ChgDefinedIn( const SwModify* pNew )
74 											{ pDefinedIn = (SwModify*)pNew; }
75 	// suche den Node, in dem die Formel steht:
76 	//	BoxAttribut	-> BoxStartNode
77 	virtual const SwNode* GetNodeOfFormula() const;
78 
79 		  SwTableBox* GetTableBox();
80 	const SwTableBox* GetTableBox() const
81 		{ return ((SwTblBoxFormula*)this)->GetTableBox(); }
82 
83 	// Status aendern
84 	void ChangeState( const SfxPoolItem* pItem );
85 	// berechne die Formel
86 	void Calc( SwTblCalcPara& rCalcPara, double& rValue );
87 };
88 
89 class SW_DLLPUBLIC SwTblBoxValue : public SfxPoolItem
90 {
91 	double nValue;
92 public:
93 	SwTblBoxValue();
94 	SwTblBoxValue( const double aVal );
95 
96 	// "pure virtual Methoden" vom SfxPoolItem
97 	virtual int             operator==( const SfxPoolItem& ) const;
98 	virtual SfxPoolItem*	Clone( SfxItemPool* pPool = 0 ) const;
99 
100 	inline SwTblBoxValue& operator=( const SwTblBoxValue& rCmp )
101 	{
102 		nValue = rCmp.nValue;
103 		return *this;
104 	}
105 
106 	double GetValue() const 					{ return nValue; }
107 };
108 
109 
110 
111 //***************************************************************************
112 
113 inline const SwTblBoxNumFormat      &SwAttrSet::GetTblBoxNumFmt(sal_Bool bInP) const
114 	{   return (const SwTblBoxNumFormat&)Get( RES_BOXATR_FORMAT,bInP); }
115 inline const SwTblBoxFormula		&SwAttrSet::GetTblBoxFormula(sal_Bool bInP) const
116 	{   return (const SwTblBoxFormula&)Get( RES_BOXATR_FORMULA,bInP); }
117 inline const SwTblBoxValue			&SwAttrSet::GetTblBoxValue(sal_Bool bInP) const
118 	{   return (const SwTblBoxValue&)Get( RES_BOXATR_VALUE, bInP); }
119 
120 //***************************************************************************
121 
122 inline const SwTblBoxNumFormat		&SwFmt::GetTblBoxNumFmt(sal_Bool bInP) const
123 	{   return aSet.GetTblBoxNumFmt(bInP); }
124 inline const SwTblBoxFormula		&SwFmt::GetTblBoxFormula(sal_Bool bInP) const
125 	{   return aSet.GetTblBoxFormula(bInP); }
126 inline const SwTblBoxValue			&SwFmt::GetTblBoxValue(sal_Bool bInP) const
127 	{   return aSet.GetTblBoxValue(bInP); }
128 
129 #endif
130