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