xref: /aoo42x/main/sc/source/ui/pagedlg/tptable.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir //------------------------------------------------------------------
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include "scitems.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include "tptable.hxx"
40*cdf0e10cSrcweir #include "global.hxx"
41*cdf0e10cSrcweir #include "attrib.hxx"
42*cdf0e10cSrcweir #include "scresid.hxx"
43*cdf0e10cSrcweir #include "sc.hrc"
44*cdf0e10cSrcweir #include "pagedlg.hrc"
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir // =======================================================================
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir void EmptyNumericField::Modify()
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir     if( GetText().Len() )
51*cdf0e10cSrcweir         NumericField::Modify();
52*cdf0e10cSrcweir     else
53*cdf0e10cSrcweir         SetEmptyFieldValue();
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir void EmptyNumericField::SetValue( sal_Int64 nValue )
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     if( nValue == 0 )
59*cdf0e10cSrcweir         SetEmptyFieldValue();
60*cdf0e10cSrcweir     else
61*cdf0e10cSrcweir         NumericField::SetValue( nValue );
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir sal_Int64 EmptyNumericField::GetValue() const
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir     return IsEmptyFieldValue() ? 0 : NumericField::GetValue();
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir // =======================================================================
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir static sal_uInt16 pPageTableRanges[] =
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir 	ATTR_PAGE_NOTES, ATTR_PAGE_FIRSTPAGENO,
76*cdf0e10cSrcweir 	0
77*cdf0e10cSrcweir };
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir sal_Bool lcl_PutVObjModeItem( sal_uInt16			nWhich,
80*cdf0e10cSrcweir 						  SfxItemSet&		rCoreSet,
81*cdf0e10cSrcweir 						  const SfxItemSet&	rOldSet,
82*cdf0e10cSrcweir 						  const CheckBox&	rBtn );
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir sal_Bool lcl_PutScaleItem( sal_uInt16				nWhich,
85*cdf0e10cSrcweir 					   SfxItemSet&			rCoreSet,
86*cdf0e10cSrcweir 					   const SfxItemSet&	rOldSet,
87*cdf0e10cSrcweir                        const ListBox&       rListBox,
88*cdf0e10cSrcweir                        sal_uInt16               nLBEntry,
89*cdf0e10cSrcweir                        const SpinField&     rEd,
90*cdf0e10cSrcweir                        sal_uInt16               nValue );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir sal_Bool lcl_PutScaleItem2( sal_uInt16               nWhich,
93*cdf0e10cSrcweir                        SfxItemSet&          rCoreSet,
94*cdf0e10cSrcweir                        const SfxItemSet&    rOldSet,
95*cdf0e10cSrcweir                        const ListBox&       rListBox,
96*cdf0e10cSrcweir                        sal_uInt16               nLBEntry,
97*cdf0e10cSrcweir                        const NumericField&  rEd1,
98*cdf0e10cSrcweir                        const NumericField&  rEd2 );
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir sal_Bool lcl_PutBoolItem( sal_uInt16			nWhich,
101*cdf0e10cSrcweir 					  SfxItemSet&		rCoreSet,
102*cdf0e10cSrcweir 					  const SfxItemSet&	rOldSet,
103*cdf0e10cSrcweir 					  sal_Bool				bIsChecked,
104*cdf0e10cSrcweir 					  sal_Bool				bSavedValue );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir //------------------------------------------------------------------------
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir #define PAGENO_HDL 			LINK(this,ScTablePage,PageNoHdl)
109*cdf0e10cSrcweir #define PAGEDIR_HDL 		LINK(this,ScTablePage,PageDirHdl)
110*cdf0e10cSrcweir #define SCALE_HDL			LINK(this,ScTablePage,ScaleHdl)
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir #define WAS_DEFAULT(w,s)    (SFX_ITEM_DEFAULT==(s).GetItemState((w),sal_True))
113*cdf0e10cSrcweir #define GET_BOOL(sid,set)	((const SfxBoolItem&)((set).Get(GetWhich((sid))))).GetValue()
114*cdf0e10cSrcweir #define GET_USHORT(sid,set)	(sal_uInt16)((const SfxUInt16Item&)((set).Get(GetWhich((sid))))).GetValue()
115*cdf0e10cSrcweir #define GET_SHOW(sid,set) 	( ScVObjMode( ((const ScViewObjectModeItem&)((set).Get(GetWhich((sid))))).GetValue() ) \
116*cdf0e10cSrcweir 							  == VOBJ_MODE_SHOW )
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir //========================================================================
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir ScTablePage::ScTablePage( Window* pParent, const SfxItemSet& rCoreAttrs ) :
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir         SfxTabPage( pParent, ScResId( RID_SCPAGE_TABLE ), rCoreAttrs ),
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir         aFlPageDir          ( this, ScResId( FL_PAGEDIR ) ),
125*cdf0e10cSrcweir 		aBtnTopDown 		( this, ScResId( BTN_TOPDOWN ) ),
126*cdf0e10cSrcweir 		aBtnLeftRight		( this, ScResId( BTN_LEFTRIGHT ) ),
127*cdf0e10cSrcweir 		aBmpPageDir 		( this, ScResId( BMP_PAGEDIR ) ),
128*cdf0e10cSrcweir 		aImgLeftRight		( ScResId( IMG_LEFTRIGHT ) ),
129*cdf0e10cSrcweir 		aImgTopDown 		( ScResId( IMG_TOPDOWN ) ),
130*cdf0e10cSrcweir         aImgLeftRightHC     ( ScResId( IMG_LEFTRIGHT_H ) ),
131*cdf0e10cSrcweir         aImgTopDownHC       ( ScResId( IMG_TOPDOWN_H ) ),
132*cdf0e10cSrcweir 		aBtnPageNo			( this, ScResId( BTN_PAGENO ) ),
133*cdf0e10cSrcweir 		aEdPageNo			( this, ScResId( ED_PAGENO ) ),
134*cdf0e10cSrcweir         aFlPrint            ( this, ScResId( FL_PRINT ) ),
135*cdf0e10cSrcweir 		aBtnHeaders 		( this, ScResId( BTN_HEADER ) ),
136*cdf0e10cSrcweir 		aBtnGrid			( this, ScResId( BTN_GRID ) ),
137*cdf0e10cSrcweir 		aBtnNotes			( this, ScResId( BTN_NOTES ) ),
138*cdf0e10cSrcweir 		aBtnObjects 		( this, ScResId( BTN_OBJECTS ) ),
139*cdf0e10cSrcweir 		aBtnCharts			( this, ScResId( BTN_CHARTS ) ),
140*cdf0e10cSrcweir 		aBtnDrawings		( this, ScResId( BTN_DRAWINGS ) ),
141*cdf0e10cSrcweir 		aBtnFormulas		( this, ScResId( BTN_FORMULAS ) ),
142*cdf0e10cSrcweir 		aBtnNullVals		( this, ScResId( BTN_NULLVALS ) ),
143*cdf0e10cSrcweir         aFlScale            ( this, ScResId( FL_SCALE ) ),
144*cdf0e10cSrcweir         aFtScaleMode        ( this, ScResId( FT_SCALEMODE ) ),
145*cdf0e10cSrcweir         aLbScaleMode        ( this, ScResId( LB_SCALEMODE ) ),
146*cdf0e10cSrcweir         aFtScaleAll         ( this, ScResId( FT_SCALEFACTOR ) ),
147*cdf0e10cSrcweir 		aEdScaleAll 		( this, ScResId( ED_SCALEALL ) ),
148*cdf0e10cSrcweir         aFtScalePageWidth   ( this, ScResId( FT_SCALEPAGEWIDTH ) ),
149*cdf0e10cSrcweir         aEdScalePageWidth   ( this, ScResId( ED_SCALEPAGEWIDTH ) ),
150*cdf0e10cSrcweir         aFtScalePageHeight  ( this, ScResId( FT_SCALEPAGEHEIGHT ) ),
151*cdf0e10cSrcweir         aEdScalePageHeight  ( this, ScResId( ED_SCALEPAGEHEIGHT ) ),
152*cdf0e10cSrcweir         aFtScalePageNum     ( this, ScResId( FT_SCALEPAGENUM ) ),
153*cdf0e10cSrcweir         aEdScalePageNum     ( this, ScResId( ED_SCALEPAGENUM ) )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	SetExchangeSupport();
156*cdf0e10cSrcweir     aBtnPageNo.SetClickHdl( PAGENO_HDL );
157*cdf0e10cSrcweir     aBtnTopDown.SetClickHdl( PAGEDIR_HDL );
158*cdf0e10cSrcweir     aBtnLeftRight.SetClickHdl( PAGEDIR_HDL );
159*cdf0e10cSrcweir     aLbScaleMode.SetSelectHdl( SCALE_HDL );
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     Size aBmpSize = Image( ScResId( IMG_LEFTRIGHT ) ).GetSizePixel();
162*cdf0e10cSrcweir     aBmpPageDir.SetOutputSizePixel( aBmpSize );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir 	FreeResource();
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 	aEdPageNo.SetAccessibleName(aBtnPageNo.GetText());
167*cdf0e10cSrcweir 	aEdPageNo.SetAccessibleRelationLabeledBy(&aBtnPageNo);
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir // -----------------------------------------------------------------------
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir void ScTablePage::ShowImage()
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
175*cdf0e10cSrcweir     bool bLeftRight = aBtnLeftRight.IsChecked();
176*cdf0e10cSrcweir     aBmpPageDir.SetImage( bHC ?
177*cdf0e10cSrcweir         (bLeftRight ? aImgLeftRightHC : aImgTopDownHC) :
178*cdf0e10cSrcweir         (bLeftRight ? aImgLeftRight : aImgTopDown) );
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir // -----------------------------------------------------------------------
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir ScTablePage::~ScTablePage()
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir //------------------------------------------------------------------------
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir sal_uInt16* ScTablePage::GetRanges()
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir 	return pPageTableRanges;
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir // -----------------------------------------------------------------------
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir SfxTabPage* ScTablePage::Create( Window* pParent, const SfxItemSet& rCoreSet )
197*cdf0e10cSrcweir {
198*cdf0e10cSrcweir 	return ( new ScTablePage( pParent, rCoreSet ) );
199*cdf0e10cSrcweir }
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir // -----------------------------------------------------------------------
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir void ScTablePage::Reset( const SfxItemSet& rCoreSet )
204*cdf0e10cSrcweir {
205*cdf0e10cSrcweir 	sal_Bool	bTopDown = GET_BOOL( SID_SCATTR_PAGE_TOPDOWN, rCoreSet );
206*cdf0e10cSrcweir 	sal_uInt16	nWhich   = 0;
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 	//-----------
209*cdf0e10cSrcweir 	// sal_Bool-Flags
210*cdf0e10cSrcweir 	//-----------
211*cdf0e10cSrcweir 	aBtnNotes		.Check( GET_BOOL(SID_SCATTR_PAGE_NOTES,rCoreSet) );
212*cdf0e10cSrcweir 	aBtnGrid		.Check( GET_BOOL(SID_SCATTR_PAGE_GRID,rCoreSet) );
213*cdf0e10cSrcweir 	aBtnHeaders 	.Check( GET_BOOL(SID_SCATTR_PAGE_HEADERS,rCoreSet) );
214*cdf0e10cSrcweir 	aBtnFormulas	.Check( GET_BOOL(SID_SCATTR_PAGE_FORMULAS,rCoreSet) );
215*cdf0e10cSrcweir 	aBtnNullVals	.Check( GET_BOOL(SID_SCATTR_PAGE_NULLVALS,rCoreSet) );
216*cdf0e10cSrcweir 	aBtnTopDown 	.Check( bTopDown );
217*cdf0e10cSrcweir 	aBtnLeftRight	.Check( !bTopDown );
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	//------------------
220*cdf0e10cSrcweir 	// Erste Druckseite:
221*cdf0e10cSrcweir 	//------------------
222*cdf0e10cSrcweir 	sal_uInt16 nPage = GET_USHORT(SID_SCATTR_PAGE_FIRSTPAGENO,rCoreSet);
223*cdf0e10cSrcweir 	aBtnPageNo.Check( nPage != 0 );
224*cdf0e10cSrcweir 	aEdPageNo.SetValue( (nPage != 0) ? nPage : 1 );
225*cdf0e10cSrcweir 	PageNoHdl( NULL );
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir 	//-------------------
228*cdf0e10cSrcweir 	// Objektdarstellung:
229*cdf0e10cSrcweir 	//-------------------
230*cdf0e10cSrcweir 	aBtnCharts		.Check( GET_SHOW( SID_SCATTR_PAGE_CHARTS, rCoreSet ) );
231*cdf0e10cSrcweir 	aBtnObjects 	.Check( GET_SHOW( SID_SCATTR_PAGE_OBJECTS, rCoreSet ) );
232*cdf0e10cSrcweir 	aBtnDrawings	.Check( GET_SHOW( SID_SCATTR_PAGE_DRAWINGS, rCoreSet ) );
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	//------------
235*cdf0e10cSrcweir 	// Skalierung:
236*cdf0e10cSrcweir 	//------------
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	nWhich = GetWhich(SID_SCATTR_PAGE_SCALE);
239*cdf0e10cSrcweir 	if ( rCoreSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
240*cdf0e10cSrcweir 	{
241*cdf0e10cSrcweir 		sal_uInt16 nScale = ((const SfxUInt16Item&)rCoreSet.Get(nWhich)).GetValue();
242*cdf0e10cSrcweir         if( nScale > 0 )
243*cdf0e10cSrcweir             aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
244*cdf0e10cSrcweir         aEdScaleAll.SetValue( (nScale > 0) ? nScale : 100 );
245*cdf0e10cSrcweir 	}
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     nWhich = GetWhich(SID_SCATTR_PAGE_SCALETO);
248*cdf0e10cSrcweir     if ( rCoreSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         const ScPageScaleToItem& rItem = static_cast< const ScPageScaleToItem& >( rCoreSet.Get( nWhich ) );
251*cdf0e10cSrcweir         sal_uInt16 nWidth = rItem.GetWidth();
252*cdf0e10cSrcweir         sal_uInt16 nHeight = rItem.GetHeight();
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         /*  width==0 and height==0 is invalid state, used as "not selected".
255*cdf0e10cSrcweir             Dialog shows width=height=1 then. */
256*cdf0e10cSrcweir         bool bValid = nWidth || nHeight;
257*cdf0e10cSrcweir         if( bValid )
258*cdf0e10cSrcweir             aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_TO );
259*cdf0e10cSrcweir         aEdScalePageWidth.SetValue( bValid ? nWidth : 1 );
260*cdf0e10cSrcweir         aEdScalePageHeight.SetValue( bValid ? nHeight : 1 );
261*cdf0e10cSrcweir     }
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir 	nWhich = GetWhich(SID_SCATTR_PAGE_SCALETOPAGES);
264*cdf0e10cSrcweir 	if ( rCoreSet.GetItemState( nWhich, sal_True ) >= SFX_ITEM_AVAILABLE )
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 		sal_uInt16 nPages = ((const SfxUInt16Item&)rCoreSet.Get(nWhich)).GetValue();
267*cdf0e10cSrcweir         if( nPages > 0 )
268*cdf0e10cSrcweir             aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_TO_PAGES );
269*cdf0e10cSrcweir         aEdScalePageNum.SetValue( (nPages > 0) ? nPages : 1 );
270*cdf0e10cSrcweir 	}
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir     if( aLbScaleMode.GetSelectEntryCount() == 0 )
273*cdf0e10cSrcweir     {
274*cdf0e10cSrcweir         // fall back to 100%
275*cdf0e10cSrcweir         DBG_ERRORFILE( "ScTablePage::Reset - missing scaling item" );
276*cdf0e10cSrcweir         aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
277*cdf0e10cSrcweir         aEdScaleAll.SetValue( 100 );
278*cdf0e10cSrcweir     }
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	PageDirHdl( NULL );
281*cdf0e10cSrcweir 	ScaleHdl( NULL );
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 	// merken fuer FillItemSet
284*cdf0e10cSrcweir 	aBtnFormulas	.SaveValue();
285*cdf0e10cSrcweir 	aBtnNullVals	.SaveValue();
286*cdf0e10cSrcweir 	aBtnNotes		.SaveValue();
287*cdf0e10cSrcweir 	aBtnGrid		.SaveValue();
288*cdf0e10cSrcweir 	aBtnHeaders 	.SaveValue();
289*cdf0e10cSrcweir 	aBtnTopDown 	.SaveValue();
290*cdf0e10cSrcweir 	aBtnLeftRight	.SaveValue();
291*cdf0e10cSrcweir     aLbScaleMode    .SaveValue();
292*cdf0e10cSrcweir 	aBtnCharts		.SaveValue();
293*cdf0e10cSrcweir 	aBtnObjects 	.SaveValue();
294*cdf0e10cSrcweir 	aBtnDrawings	.SaveValue();
295*cdf0e10cSrcweir 	aBtnPageNo		.SaveValue();
296*cdf0e10cSrcweir 	aEdPageNo		.SaveValue();
297*cdf0e10cSrcweir 	aEdScaleAll		.SaveValue();
298*cdf0e10cSrcweir     aEdScalePageWidth.SaveValue();
299*cdf0e10cSrcweir     aEdScalePageHeight.SaveValue();
300*cdf0e10cSrcweir 	aEdScalePageNum	.SaveValue();
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir // -----------------------------------------------------------------------
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir sal_Bool ScTablePage::FillItemSet( SfxItemSet& rCoreSet )
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir 	const SfxItemSet&	rOldSet		 = GetItemSet();
308*cdf0e10cSrcweir 	sal_uInt16				nWhichPageNo = GetWhich(SID_SCATTR_PAGE_FIRSTPAGENO);
309*cdf0e10cSrcweir 	sal_Bool				bDataChanged = sal_False;
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir 	//-----------
312*cdf0e10cSrcweir 	// sal_Bool-Flags
313*cdf0e10cSrcweir 	//-----------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_NOTES),
316*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
317*cdf0e10cSrcweir 									 aBtnNotes.IsChecked(),
318*cdf0e10cSrcweir                                      aBtnNotes.GetSavedValue() != STATE_NOCHECK );
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_GRID),
321*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
322*cdf0e10cSrcweir 									 aBtnGrid.IsChecked(),
323*cdf0e10cSrcweir                                      aBtnGrid.GetSavedValue() != STATE_NOCHECK );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_HEADERS),
326*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
327*cdf0e10cSrcweir 									 aBtnHeaders.IsChecked(),
328*cdf0e10cSrcweir                                      aBtnHeaders.GetSavedValue() != STATE_NOCHECK );
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_TOPDOWN),
331*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
332*cdf0e10cSrcweir 									 aBtnTopDown.IsChecked(),
333*cdf0e10cSrcweir 									 aBtnTopDown.GetSavedValue() );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_FORMULAS),
336*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
337*cdf0e10cSrcweir 									 aBtnFormulas.IsChecked(),
338*cdf0e10cSrcweir                                      aBtnFormulas.GetSavedValue() != STATE_NOCHECK );
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir 	bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_NULLVALS),
341*cdf0e10cSrcweir 									 rCoreSet, rOldSet,
342*cdf0e10cSrcweir 									 aBtnNullVals.IsChecked(),
343*cdf0e10cSrcweir                                      aBtnNullVals.GetSavedValue() != STATE_NOCHECK );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 	//------------------
346*cdf0e10cSrcweir 	// Erste Druckseite:
347*cdf0e10cSrcweir 	//------------------
348*cdf0e10cSrcweir 	sal_Bool bUseValue = aBtnPageNo.IsChecked();
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 	if (   WAS_DEFAULT(nWhichPageNo,rOldSet)
351*cdf0e10cSrcweir 		&& (	(!bUseValue && bUseValue == aBtnPageNo.GetSavedValue())
352*cdf0e10cSrcweir 			|| (   bUseValue && bUseValue == aBtnPageNo.GetSavedValue()
353*cdf0e10cSrcweir 				&& aEdPageNo.GetText() == aEdPageNo.GetSavedValue() ) ) )
354*cdf0e10cSrcweir 	{
355*cdf0e10cSrcweir 			rCoreSet.ClearItem( nWhichPageNo );
356*cdf0e10cSrcweir 	}
357*cdf0e10cSrcweir 	else
358*cdf0e10cSrcweir 	{
359*cdf0e10cSrcweir 		sal_uInt16 nPage = (sal_uInt16)( aBtnPageNo.IsChecked()
360*cdf0e10cSrcweir 									? aEdPageNo.GetValue()
361*cdf0e10cSrcweir 									: 0 );
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 		rCoreSet.Put( SfxUInt16Item( nWhichPageNo, nPage ) );
364*cdf0e10cSrcweir 		bDataChanged = sal_True;
365*cdf0e10cSrcweir 	}
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	//-------------------
368*cdf0e10cSrcweir 	// Objektdarstellung:
369*cdf0e10cSrcweir 	//-------------------
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 	bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_CHARTS),
372*cdf0e10cSrcweir 										 rCoreSet, rOldSet, aBtnCharts );
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 	bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_OBJECTS),
375*cdf0e10cSrcweir 										 rCoreSet, rOldSet, aBtnObjects );
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_DRAWINGS),
378*cdf0e10cSrcweir 										 rCoreSet, rOldSet, aBtnDrawings );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	//------------
381*cdf0e10cSrcweir 	// Skalierung:
382*cdf0e10cSrcweir 	//------------
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir     if( !aEdScalePageWidth.GetValue() && !aEdScalePageHeight.GetValue() )
385*cdf0e10cSrcweir     {
386*cdf0e10cSrcweir         aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
387*cdf0e10cSrcweir         aEdScaleAll.SetValue( 100 );
388*cdf0e10cSrcweir     }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir 	bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALE),
391*cdf0e10cSrcweir 									  rCoreSet, rOldSet,
392*cdf0e10cSrcweir                                       aLbScaleMode, SC_TPTABLE_SCALE_PERCENT,
393*cdf0e10cSrcweir                                       aEdScaleAll, (sal_uInt16)aEdScaleAll.GetValue() );
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     bDataChanged |= lcl_PutScaleItem2( GetWhich(SID_SCATTR_PAGE_SCALETO),
396*cdf0e10cSrcweir                                       rCoreSet, rOldSet,
397*cdf0e10cSrcweir                                       aLbScaleMode, SC_TPTABLE_SCALE_TO,
398*cdf0e10cSrcweir                                       aEdScalePageWidth, aEdScalePageHeight );
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir 	bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALETOPAGES),
401*cdf0e10cSrcweir 									  rCoreSet, rOldSet,
402*cdf0e10cSrcweir                                       aLbScaleMode, SC_TPTABLE_SCALE_TO_PAGES,
403*cdf0e10cSrcweir                                       aEdScalePageNum, (sal_uInt16)aEdScalePageNum.GetValue() );
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 	return bDataChanged;
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir //------------------------------------------------------------------------
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir int ScTablePage::DeactivatePage( SfxItemSet* pSetP )
411*cdf0e10cSrcweir {
412*cdf0e10cSrcweir     if ( pSetP )
413*cdf0e10cSrcweir         FillItemSet( *pSetP );
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir 	return LEAVE_PAGE;
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir //------------------------------------------------------------------------
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir void ScTablePage::DataChanged( const DataChangedEvent& rDCEvt )
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir     if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
423*cdf0e10cSrcweir         ShowImage();
424*cdf0e10cSrcweir     SfxTabPage::DataChanged( rDCEvt );
425*cdf0e10cSrcweir }
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir //------------------------------------------------------------------------
428*cdf0e10cSrcweir // Handler:
429*cdf0e10cSrcweir //------------------------------------------------------------------------
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir IMPL_LINK( ScTablePage, PageDirHdl, RadioButton*, EMPTYARG )
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir     ShowImage();
434*cdf0e10cSrcweir 	return 0;
435*cdf0e10cSrcweir }
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir //------------------------------------------------------------------------
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir IMPL_LINK( ScTablePage, PageNoHdl, CheckBox*, pBtn )
440*cdf0e10cSrcweir {
441*cdf0e10cSrcweir 	if ( aBtnPageNo.IsChecked() )
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		aEdPageNo.Enable();
444*cdf0e10cSrcweir 		if ( pBtn )
445*cdf0e10cSrcweir 			aEdPageNo.GrabFocus();
446*cdf0e10cSrcweir 	}
447*cdf0e10cSrcweir 	else
448*cdf0e10cSrcweir 		aEdPageNo.Disable();
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir 	return 0;
451*cdf0e10cSrcweir }
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir //------------------------------------------------------------------------
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir IMPL_LINK( ScTablePage, ScaleHdl, ListBox*, EMPTYARG )
456*cdf0e10cSrcweir {
457*cdf0e10cSrcweir     // controls for "Reduce/enlarge"
458*cdf0e10cSrcweir     bool bPercent = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_PERCENT);
459*cdf0e10cSrcweir     aFtScaleAll.Show( bPercent );
460*cdf0e10cSrcweir     aEdScaleAll.Show( bPercent );
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir     // controls for "Scale to width/height"
463*cdf0e10cSrcweir     bool bScaleTo = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_TO);
464*cdf0e10cSrcweir     aFtScalePageWidth.Show( bScaleTo );
465*cdf0e10cSrcweir     aEdScalePageWidth.Show( bScaleTo );
466*cdf0e10cSrcweir     aFtScalePageHeight.Show( bScaleTo );
467*cdf0e10cSrcweir     aEdScalePageHeight.Show( bScaleTo );
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir     // controls for "Scale to pages"
470*cdf0e10cSrcweir     bool bScalePages = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_TO_PAGES);
471*cdf0e10cSrcweir     aFtScalePageNum.Show( bScalePages );
472*cdf0e10cSrcweir     aEdScalePageNum.Show( bScalePages );
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 	return 0;
475*cdf0e10cSrcweir }
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir //========================================================================
478*cdf0e10cSrcweir // Hilfsfunktionen fuer FillItemSet:
479*cdf0e10cSrcweir //========================================================================
480*cdf0e10cSrcweir 
481*cdf0e10cSrcweir sal_Bool lcl_PutBoolItem( sal_uInt16			nWhich,
482*cdf0e10cSrcweir 					 SfxItemSet&		rCoreSet,
483*cdf0e10cSrcweir 					 const SfxItemSet&	rOldSet,
484*cdf0e10cSrcweir 					 sal_Bool				bIsChecked,
485*cdf0e10cSrcweir 					 sal_Bool				bSavedValue )
486*cdf0e10cSrcweir {
487*cdf0e10cSrcweir 	sal_Bool bDataChanged = (   bSavedValue == bIsChecked
488*cdf0e10cSrcweir 						 && WAS_DEFAULT(nWhich,rOldSet) );
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir 	if ( bDataChanged )
491*cdf0e10cSrcweir 		rCoreSet.ClearItem(nWhich);
492*cdf0e10cSrcweir 	else
493*cdf0e10cSrcweir 		rCoreSet.Put( SfxBoolItem( nWhich, bIsChecked ) );
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir 	return bDataChanged;
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir //------------------------------------------------------------------------
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir sal_Bool lcl_PutVObjModeItem( sal_uInt16			nWhich,
501*cdf0e10cSrcweir 						 SfxItemSet&		rCoreSet,
502*cdf0e10cSrcweir 						 const SfxItemSet&	rOldSet,
503*cdf0e10cSrcweir 						 const CheckBox&	rBtn )
504*cdf0e10cSrcweir {
505*cdf0e10cSrcweir 	sal_Bool bIsChecked   = rBtn.IsChecked();
506*cdf0e10cSrcweir 	sal_Bool bDataChanged = (   rBtn.GetSavedValue() == bIsChecked
507*cdf0e10cSrcweir 						 && WAS_DEFAULT(nWhich,rOldSet) );
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 	if ( bDataChanged )
510*cdf0e10cSrcweir 		rCoreSet.ClearItem( nWhich );
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir 	else
513*cdf0e10cSrcweir 		rCoreSet.Put( ScViewObjectModeItem( nWhich, bIsChecked
514*cdf0e10cSrcweir 													? VOBJ_MODE_SHOW
515*cdf0e10cSrcweir 													: VOBJ_MODE_HIDE ) );
516*cdf0e10cSrcweir 	return bDataChanged;
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir //------------------------------------------------------------------------
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir sal_Bool lcl_PutScaleItem( sal_uInt16				nWhich,
522*cdf0e10cSrcweir 					  SfxItemSet&			rCoreSet,
523*cdf0e10cSrcweir 					  const SfxItemSet&		rOldSet,
524*cdf0e10cSrcweir                       const ListBox&        rListBox,
525*cdf0e10cSrcweir                       sal_uInt16                nLBEntry,
526*cdf0e10cSrcweir                       const SpinField&      rEd,
527*cdf0e10cSrcweir                       sal_uInt16                nValue )
528*cdf0e10cSrcweir {
529*cdf0e10cSrcweir     sal_Bool bIsSel = (rListBox.GetSelectEntryPos() == nLBEntry);
530*cdf0e10cSrcweir     sal_Bool bDataChanged = (rListBox.GetSavedValue() != nLBEntry) ||
531*cdf0e10cSrcweir                         (rEd.GetSavedValue() != rEd.GetText()) ||
532*cdf0e10cSrcweir                         !WAS_DEFAULT( nWhich, rOldSet );
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir     if( bDataChanged )
535*cdf0e10cSrcweir         rCoreSet.Put( SfxUInt16Item( nWhich, bIsSel ? nValue : 0 ) );
536*cdf0e10cSrcweir     else
537*cdf0e10cSrcweir         rCoreSet.ClearItem( nWhich );
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir 	return bDataChanged;
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir sal_Bool lcl_PutScaleItem2( sal_uInt16               nWhich,
544*cdf0e10cSrcweir                       SfxItemSet&           rCoreSet,
545*cdf0e10cSrcweir                       const SfxItemSet&     rOldSet,
546*cdf0e10cSrcweir                       const ListBox&        rListBox,
547*cdf0e10cSrcweir                       sal_uInt16                nLBEntry,
548*cdf0e10cSrcweir                       const NumericField&   rEd1,
549*cdf0e10cSrcweir                       const NumericField&   rEd2 )
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir     sal_uInt16 nValue1 = (sal_uInt16)rEd1.GetValue();
552*cdf0e10cSrcweir     sal_uInt16 nValue2 = (sal_uInt16)rEd2.GetValue();
553*cdf0e10cSrcweir     sal_Bool bIsSel = (rListBox.GetSelectEntryPos() == nLBEntry);
554*cdf0e10cSrcweir     sal_Bool bDataChanged = (rListBox.GetSavedValue() != nLBEntry) ||
555*cdf0e10cSrcweir                         (rEd1.GetSavedValue() != rEd1.GetText()) ||
556*cdf0e10cSrcweir                         (rEd2.GetSavedValue() != rEd2.GetText()) ||
557*cdf0e10cSrcweir                         !WAS_DEFAULT( nWhich, rOldSet );
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir     if( bDataChanged )
560*cdf0e10cSrcweir     {
561*cdf0e10cSrcweir         ScPageScaleToItem aItem;
562*cdf0e10cSrcweir         if( bIsSel )
563*cdf0e10cSrcweir             aItem.Set( nValue1, nValue2 );
564*cdf0e10cSrcweir         rCoreSet.Put( aItem );
565*cdf0e10cSrcweir     }
566*cdf0e10cSrcweir     else
567*cdf0e10cSrcweir         rCoreSet.ClearItem( nWhich );
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir     return bDataChanged;
570*cdf0e10cSrcweir }
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir 
574