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