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