xref: /trunk/main/sc/source/ui/optdlg/tpview.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 #include "tpview.hxx"
35 #include "global.hxx"
36 #include "viewopti.hxx"
37 #include "tabvwsh.hxx"
38 #include "uiitems.hxx"
39 #include "scresid.hxx"
40 #include "docsh.hxx"
41 #include "sc.hrc"       // -> Slot-IDs
42 #include "optdlg.hrc"
43 #include "globstr.hrc"
44 #include <appoptio.hxx>
45 #include <scmod.hxx>
46 #include <svx/dlgutil.hxx>
47 #include <svx/drawitem.hxx>
48 #include <svx/xtable.hxx>
49 
50 
51 // STATIC DATA -----------------------------------------------------------
52 
53 
54 
55 /*-----------------11.01.97 10.52-------------------
56 	Optionen Inhalte
57 --------------------------------------------------*/
58 
59 ScTpContentOptions::ScTpContentOptions( Window*			pParent,
60 							 const SfxItemSet&	rArgSet ) :
61 	SfxTabPage(pParent, ScResId( RID_SCPAGE_CONTENT ), rArgSet),
62 
63     aLinesGB( this,         ScResId(GB_LINES          )),
64 	aGridCB( this, 			ScResId(CB_GRID			)),
65 	aColorFT( this, 		ScResId(FT_COLOR			)),
66 	aColorLB( this, 		ScResId(LB_COLOR			)),
67 	aBreakCB( this,			ScResId(CB_PAGEBREAKS		)),
68 	aGuideLineCB( this, 	ScResId(CB_GUIDELINE		)),
69 	aHandleCB( this,	 	ScResId(CB_HANDLES		)),
70 	aBigHandleCB( this,	 	ScResId(CB_BIGHANDLES		)),
71 
72     aSeparator1FL    (this, ScResId(FL_SEPARATOR1 )),
73     aDisplayGB( this,   ScResId(GB_DISPLAY)),
74 	aFormulaCB( this, 	ScResId(CB_FORMULA)),
75 	aNilCB( this, 		ScResId(CB_NIL	)),
76 	aAnnotCB( this, 	ScResId(CB_ANNOT	)),
77 	aValueCB( this, 	ScResId(CB_VALUE	)),
78 	aAnchorCB( this, 	ScResId(CB_ANCHOR	)),
79 	aClipMarkCB( this, 	ScResId(CB_CLIP	)),
80     aRangeFindCB( this,     ScResId( CB_RFIND     )),
81 
82     aObjectGB( this,    ScResId(GB_OBJECT )),
83 	aObjGrfFT( this, 	ScResId(FT_OBJGRF	)),
84 	aObjGrfLB( this, 	ScResId(LB_OBJGRF	)),
85     aDiagramFT( this,   ScResId(FT_DIAGRAM)),
86 	aDiagramLB( this, 	ScResId(LB_DIAGRAM)),
87 	aDrawFT( this, 		ScResId(FT_DRAW	)),
88 	aDrawLB( this, 		ScResId(LB_DRAW	)),
89 
90     aZoomGB( this,      ScResId(GB_ZOOM) ),
91     aSyncZoomCB( this,  ScResId(CB_SYNCZOOM) ),
92 
93     aSeparator2FL    (this, ScResId(FL_SEPARATOR2)),
94     aWindowGB( this,        ScResId(GB_WINDOW         )),
95 	aRowColHeaderCB(this,	ScResId(CB_ROWCOLHEADER	)),
96 	aHScrollCB( this, 		ScResId(CB_HSCROLL		)),
97 	aVScrollCB( this, 		ScResId(CB_VSCROLL		)),
98 	aTblRegCB( this, 		ScResId(CB_TBLREG			)),
99 	aOutlineCB( this, 		ScResId(CB_OUTLINE		)),
100     pLocalOptions(0)
101 {
102 	FreeResource();
103     aSeparator1FL.SetStyle( aSeparator1FL.GetStyle() | WB_VERT );
104     aSeparator2FL.SetStyle( aSeparator2FL.GetStyle() | WB_VERT );
105     SetExchangeSupport();
106     Link aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) );
107     aObjGrfLB.  SetSelectHdl(aSelObjHdl);
108     aDiagramLB. SetSelectHdl(aSelObjHdl);
109     aDrawLB.    SetSelectHdl(aSelObjHdl);
110 
111     Link aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
112     aFormulaCB  .SetClickHdl(aCBHdl);
113     aNilCB      .SetClickHdl(aCBHdl);
114     aAnnotCB    .SetClickHdl(aCBHdl);
115     aValueCB    .SetClickHdl(aCBHdl);
116     aAnchorCB   .SetClickHdl(aCBHdl);
117     aClipMarkCB .SetClickHdl(aCBHdl);
118 
119     aVScrollCB  .SetClickHdl(aCBHdl);
120     aHScrollCB  .SetClickHdl(aCBHdl);
121     aTblRegCB   .SetClickHdl(aCBHdl);
122     aOutlineCB  .SetClickHdl(aCBHdl);
123     aBreakCB    .SetClickHdl(aCBHdl);
124     aGuideLineCB.SetClickHdl(aCBHdl);
125     aHandleCB   .SetClickHdl(aCBHdl);
126     aBigHandleCB.SetClickHdl(aCBHdl);
127     aRowColHeaderCB.SetClickHdl(aCBHdl);
128 
129     aGridCB     .SetClickHdl( LINK( this, ScTpContentOptions, GridHdl ) );
130 }
131 /*-----------------11.01.97 10.52-------------------
132 
133 --------------------------------------------------*/
134 
135 ScTpContentOptions::~ScTpContentOptions()
136 {
137 	delete pLocalOptions;
138 }
139 /*-----------------11.01.97 10.52-------------------
140 
141 --------------------------------------------------*/
142 
143 SfxTabPage*	ScTpContentOptions::Create( Window*		pParent,
144 							  const SfxItemSet&		rCoreSet )
145 {
146 	return new ScTpContentOptions(pParent, rCoreSet);
147 }
148 /*-----------------11.01.97 10.52-------------------
149 
150 --------------------------------------------------*/
151 sal_Bool	ScTpContentOptions::FillItemSet( SfxItemSet& rCoreSet )
152 {
153 	sal_Bool bRet = sal_False;
154 	if(	aFormulaCB	.GetSavedValue() != aFormulaCB	.IsChecked() ||
155 		aNilCB		.GetSavedValue() != aNilCB		.IsChecked() ||
156 		aAnnotCB  	.GetSavedValue() != aAnnotCB	.IsChecked() ||
157 		aValueCB  	.GetSavedValue() != aValueCB  	.IsChecked() ||
158 		aAnchorCB 	.GetSavedValue() != aAnchorCB 	.IsChecked() ||
159 		aClipMarkCB	.GetSavedValue() != aClipMarkCB	.IsChecked() ||
160 		aObjGrfLB   .GetSavedValue() != aObjGrfLB  	.GetSelectEntryPos() ||
161 		aDiagramLB  .GetSavedValue() != aDiagramLB 	.GetSelectEntryPos() ||
162         aDrawLB     .GetSavedValue() != aDrawLB     .GetSelectEntryPos() ||
163         aGridCB         .GetSavedValue() != aGridCB.IsChecked() ||
164 		aRowColHeaderCB	.GetSavedValue() != aRowColHeaderCB.IsChecked() ||
165 		aHScrollCB      .GetSavedValue() != aHScrollCB     .IsChecked() ||
166 		aVScrollCB      .GetSavedValue() != aVScrollCB     .IsChecked() ||
167 		aTblRegCB       .GetSavedValue() != aTblRegCB      .IsChecked() ||
168 		aOutlineCB      .GetSavedValue() != aOutlineCB     .IsChecked() ||
169 		aColorLB        .GetSavedValue() != aColorLB       .GetSelectEntryPos() ||
170 		aBreakCB		.GetSavedValue() != aBreakCB	   .IsChecked() ||
171 		aGuideLineCB    .GetSavedValue() != aGuideLineCB   .IsChecked() ||
172 		aHandleCB		.GetSavedValue() != aHandleCB	   .IsChecked() ||
173         aBigHandleCB    .GetSavedValue() != aBigHandleCB   .IsChecked())
174 	{
175         pLocalOptions->SetGridColor( aColorLB.GetSelectEntryColor(),
176 									 aColorLB.GetSelectEntry() );
177         rCoreSet.Put(ScTpViewItem(SID_SCVIEWOPTIONS, *pLocalOptions));
178 		bRet = sal_True;
179 	}
180     if(aRangeFindCB.GetSavedValue() != aRangeFindCB.IsChecked())
181     {
182         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, aRangeFindCB.IsChecked()));
183         bRet = sal_True;
184     }
185     if(aSyncZoomCB.GetSavedValue() != aSyncZoomCB.IsChecked())
186     {
187         rCoreSet.Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, aSyncZoomCB.IsChecked()));
188         bRet = sal_True;
189     }
190 
191 
192     return bRet;
193 }
194 /*-----------------11.01.97 10.53-------------------
195 
196 --------------------------------------------------*/
197 
198 void	ScTpContentOptions::Reset( const SfxItemSet& rCoreSet )
199 {
200 	const SfxPoolItem* pItem;
201 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCVIEWOPTIONS, sal_False , &pItem))
202 		pLocalOptions  = new ScViewOptions(
203 							((const ScTpViewItem*)pItem)->GetViewOptions() );
204 	else
205 		pLocalOptions = new ScViewOptions;
206 	aFormulaCB	.Check(pLocalOptions->GetOption(VOPT_FORMULAS));
207 	aNilCB		.Check(pLocalOptions->GetOption(VOPT_NULLVALS));
208 	aAnnotCB  	.Check(pLocalOptions->GetOption(VOPT_NOTES));
209 	aValueCB  	.Check(pLocalOptions->GetOption(VOPT_SYNTAX));
210 	aAnchorCB 	.Check(pLocalOptions->GetOption(VOPT_ANCHOR));
211 	aClipMarkCB	.Check(pLocalOptions->GetOption(VOPT_CLIPMARKS));
212 
213 	aObjGrfLB 	.SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) );
214 	aDiagramLB  .SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) );
215 	aDrawLB     .SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) );
216 
217 	aRowColHeaderCB.Check( pLocalOptions->GetOption(VOPT_HEADER) );
218 	aHScrollCB .Check( pLocalOptions->GetOption(VOPT_HSCROLL) );
219 	aVScrollCB .Check( pLocalOptions->GetOption(VOPT_VSCROLL) );
220 	aTblRegCB  .Check( pLocalOptions->GetOption(VOPT_TABCONTROLS) );
221 	aOutlineCB .Check( pLocalOptions->GetOption(VOPT_OUTLINER) );
222 
223 	InitGridOpt();
224 
225 	aBreakCB.Check( pLocalOptions->GetOption(VOPT_PAGEBREAKS) );
226 	aGuideLineCB.Check( pLocalOptions->GetOption(VOPT_HELPLINES) );
227 	aHandleCB.Check( !pLocalOptions->GetOption(VOPT_SOLIDHANDLES) );	// inverted
228 	aBigHandleCB.Check( pLocalOptions->GetOption(VOPT_BIGHANDLES) );
229 
230     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_RANGEFINDER, sal_False, &pItem))
231 		aRangeFindCB.Check(((const SfxBoolItem*)pItem)->GetValue());
232     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_OPT_SYNCZOOM, sal_False, &pItem))
233 		aSyncZoomCB.Check(((const SfxBoolItem*)pItem)->GetValue());
234 
235     aRangeFindCB.SaveValue();
236     aSyncZoomCB.SaveValue();
237 
238     aFormulaCB  .SaveValue();
239 	aNilCB		.SaveValue();
240 	aAnnotCB  	.SaveValue();
241 	aValueCB  	.SaveValue();
242 	aAnchorCB 	.SaveValue();
243 	aClipMarkCB	.SaveValue();
244 	aObjGrfLB   .SaveValue();
245 	aDiagramLB  .SaveValue();
246 	aDrawLB     .SaveValue();
247     aRowColHeaderCB .SaveValue();
248 	aHScrollCB      .SaveValue();
249 	aVScrollCB      .SaveValue();
250 	aTblRegCB       .SaveValue();
251 	aOutlineCB      .SaveValue();
252 	aGridCB         .SaveValue();
253 	aColorLB        .SaveValue();
254 	aBreakCB		.SaveValue();
255 	aGuideLineCB    .SaveValue();
256 	aHandleCB		.SaveValue();
257 	aBigHandleCB	.SaveValue();
258 }
259 /*-----------------11.01.97 12.45-------------------
260 
261 --------------------------------------------------*/
262 
263 void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
264 {
265 	const SfxPoolItem* pItem;
266 	if(SFX_ITEM_SET == rSet.GetItemState(SID_SCVIEWOPTIONS, sal_False , &pItem))
267 		*pLocalOptions = ((const ScTpViewItem*)pItem)->GetViewOptions();
268 }
269 /*-----------------11.01.97 12.45-------------------
270 
271 --------------------------------------------------*/
272 
273 int	ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
274 {
275     if(pSetP)
276         FillItemSet(*pSetP);
277 	return SfxTabPage::LEAVE_PAGE;
278 }
279 /*-----------------11.01.97 13.43-------------------
280 
281 --------------------------------------------------*/
282 
283 IMPL_LINK( ScTpContentOptions, SelLbObjHdl, ListBox*, pLb )
284 {
285 	sal_uInt16		nSelPos = pLb->GetSelectEntryPos();
286 	ScVObjMode	eMode	= ScVObjMode(nSelPos);
287 	ScVObjType	eType	= VOBJ_TYPE_OLE;
288 
289 	if ( pLb == &aDiagramLB )
290 		eType = VOBJ_TYPE_CHART;
291 	else if ( pLb == &aDrawLB )
292 		eType = VOBJ_TYPE_DRAW;
293 
294 	pLocalOptions->SetObjMode( eType, eMode );
295 
296 	return 0;
297 }
298 
299 /*-----------------11.01.97 14.25-------------------
300 
301 --------------------------------------------------*/
302 
303 IMPL_LINK( ScTpContentOptions, CBHdl, CheckBox*, pBtn )
304 {
305     ScViewOption eOption = VOPT_FORMULAS;
306 	sal_Bool		 bChecked = pBtn->IsChecked();
307 
308 	if ( 	  &aFormulaCB 	== pBtn )	eOption = VOPT_FORMULAS;
309 	else if ( &aNilCB 		== pBtn )	eOption = VOPT_NULLVALS;
310 	else if ( &aAnnotCB		== pBtn )	eOption = VOPT_NOTES;
311 	else if ( &aValueCB		== pBtn )	eOption = VOPT_SYNTAX;
312 	else if ( &aAnchorCB	== pBtn )   eOption = VOPT_ANCHOR;
313 	else if ( &aClipMarkCB	== pBtn )   eOption = VOPT_CLIPMARKS;
314     else if ( &aVScrollCB       == pBtn )   eOption = VOPT_VSCROLL;
315 	else if ( &aHScrollCB		== pBtn )	eOption = VOPT_HSCROLL;
316 	else if ( &aTblRegCB		== pBtn )	eOption = VOPT_TABCONTROLS;
317 	else if ( &aOutlineCB 		== pBtn )	eOption = VOPT_OUTLINER;
318 	else if ( &aBreakCB			== pBtn )	eOption = VOPT_PAGEBREAKS;
319 	else if ( &aGuideLineCB 	== pBtn )	eOption = VOPT_HELPLINES;
320 	else if ( &aHandleCB	 	== pBtn )	eOption = VOPT_SOLIDHANDLES;
321 	else if ( &aBigHandleCB	 	== pBtn )	eOption = VOPT_BIGHANDLES;
322 	else if ( &aRowColHeaderCB 	== pBtn )	eOption = VOPT_HEADER;
323 
324 	//	VOPT_SOLIDHANDLES is inverted (CheckBox is "simple handles")
325 	if ( eOption == VOPT_SOLIDHANDLES )
326 		pLocalOptions->SetOption( eOption, !bChecked );
327 	else
328 		pLocalOptions->SetOption( eOption, bChecked );
329 
330 
331 	return 0;
332 }
333 /*-----------------11.01.97 13.13-------------------
334 
335 --------------------------------------------------*/
336 
337 void ScTpContentOptions::InitGridOpt()
338 {
339 	sal_Bool bGrid = pLocalOptions->GetOption( VOPT_GRID );
340 
341 	aGridCB.Check( bGrid );
342 
343 	if ( bGrid )
344 		aColorFT.Enable(), aColorLB.Enable();
345 	else
346 		aColorFT.Disable(), aColorLB.Disable();
347 
348 	if ( aColorLB.GetEntryCount() == 0 )
349 	{
350 		SfxObjectShell*	pDocSh = SfxObjectShell::Current();
351 		// hier koennte auch eine andere DocShell kommen!
352 		pDocSh = PTR_CAST(ScDocShell, pDocSh);
353 
354 		XColorTable* pColorTable = NULL;
355 
356 		if ( pDocSh  )
357 		{
358             const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
359 
360 			if ( pItem )
361 				pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
362 		}
363 		else
364 			pColorTable = XColorTable::GetStdColorTable();
365 
366 		if ( !pColorTable )
367 			return;
368 
369 		//------------------------------------------------------
370 
371 		aColorLB.SetUpdateMode( sal_False );
372 
373 		//	Eintraege aus der Colortable
374 
375 		long nCount = pColorTable->Count();
376 		for ( long n=0; n<nCount; n++ )
377 		{
378 			XColorEntry* pEntry = pColorTable->GetColor(n);
379 			aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
380 		}
381 
382 		//	Standard-Gitterfarbe
383 
384 		Color aStdCol( SC_STD_GRIDCOLOR );			// wie Default in ScViewOptions
385 		if ( LISTBOX_ENTRY_NOTFOUND ==
386 				aColorLB.GetEntryPos( aStdCol ) )
387 			aColorLB.InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) );
388 
389 		aColorLB.SetUpdateMode( sal_True );
390 
391 		Invalidate();
392 	}
393 
394 	//	#79720# also select grid color entry on subsequent calls
395 
396 	String	aName;
397 	Color	aCol	= pLocalOptions->GetGridColor( &aName );
398 	sal_uInt16	nSelPos	= aColorLB.GetEntryPos( aCol );
399 
400 	if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
401 		aColorLB.SelectEntryPos( nSelPos );
402 	else
403 		aColorLB.SelectEntryPos( aColorLB.InsertEntry( aCol, aName ) );
404 }
405 /*-----------------11.01.97 13.40-------------------
406 
407 --------------------------------------------------*/
408 
409 IMPL_LINK( ScTpContentOptions, GridHdl, CheckBox*, pBox )
410 {
411 	sal_Bool bChecked = pBox->IsChecked();
412 	aColorFT.Enable(bChecked);
413 	aColorLB.Enable(bChecked);
414 	pLocalOptions->SetOption( VOPT_GRID, bChecked );
415 	return 0;
416 }
417 /*-----------------11.01.97 10.53-------------------
418 
419 --------------------------------------------------*/
420 
421 ScTpLayoutOptions::ScTpLayoutOptions( 	Window*	pParent,
422 										const SfxItemSet&	rArgSet ) :
423 	SfxTabPage(pParent, ScResId( RID_SCPAGE_LAYOUT ), rArgSet),
424     aUnitGB( this,          ScResId(GB_UNIT           )),
425     aUnitFT( this,          ScResId(FT_UNIT           )),
426     aUnitLB( this,          ScResId(LB_UNIT           )),
427     aTabFT( this,           ScResId( FT_TAB           )),
428     aTabMF( this,           ScResId( MF_TAB           )),
429     aSeparatorFL( this,     ScResId( FL_SEPARATOR         )),
430 	aLinkGB		(this, ScResId(GB_LINK	)),
431     aLinkFT(this, ScResId(FT_UPDATE_LINKS )),
432 	aAlwaysRB	(this, ScResId(RB_ALWAYS	)),
433 	aRequestRB	(this, ScResId(RB_REQUEST	)),
434 	aNeverRB	(this, ScResId(RB_NEVER	)),
435 
436     aOptionsGB( this,       ScResId( GB_OPTIONS   )),
437 	aAlignCB  ( this, 		ScResId( CB_ALIGN		)),
438 	aAlignLB  ( this, 		ScResId( LB_ALIGN		)),
439 	aEditModeCB( this, 		ScResId( CB_EDITMODE	)),
440 	aFormatCB( this, 		ScResId( CB_FORMAT	)),
441     aExpRefCB( this,        ScResId( CB_EXPREF    )),
442     aMarkHdrCB( this,       ScResId( CB_MARKHDR   )),
443 	aTextFmtCB( this,       ScResId( CB_TEXTFMT   )),
444     aReplWarnCB( this,      ScResId( CB_REPLWARN  )),
445     aUnitArr(               ScResId(ST_UNIT           )),
446     pDoc(NULL)
447 {
448 	FreeResource();
449     aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
450     SetExchangeSupport();
451 
452     aUnitLB.    SetSelectHdl( LINK( this, ScTpLayoutOptions, MetricHdl ) );
453 
454     aAlignCB.SetClickHdl(LINK(this, ScTpLayoutOptions, AlignHdl));
455 
456 
457 	for ( sal_uInt16 i = 0; i < aUnitArr.Count(); ++i )
458 	{
459 		String sMetric = aUnitArr.GetStringByPos( i );
460 		FieldUnit eFUnit = (FieldUnit)aUnitArr.GetValue( i );
461 
462 		switch ( eFUnit )
463 		{
464 			case FUNIT_MM:
465 			case FUNIT_CM:
466 			case FUNIT_POINT:
467 			case FUNIT_PICA:
468 			case FUNIT_INCH:
469 			{
470 				// nur diese Metriken benutzen
471 				sal_uInt16 nPos = aUnitLB.InsertEntry( sMetric );
472 				aUnitLB.SetEntryData( nPos, (void*)(long)eFUnit );
473 			}
474             break;
475             default:
476             {
477                 // added to avoid warnings
478             }
479 		}
480 	}
481 
482 }
483 /*-----------------11.01.97 10.53-------------------
484 
485 --------------------------------------------------*/
486 
487 ScTpLayoutOptions::~ScTpLayoutOptions()
488 {
489 }
490 /*-----------------11.01.97 10.53-------------------
491 
492 --------------------------------------------------*/
493 
494 SfxTabPage*	ScTpLayoutOptions::Create( Window*			pParent,
495 									const SfxItemSet&	rCoreSet )
496 {
497     ScTpLayoutOptions* pNew = new ScTpLayoutOptions(pParent, rCoreSet);
498     ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current());
499 
500 	if(pDocSh!=NULL)
501 		pNew->SetDocument(pDocSh->GetDocument());
502     return pNew;
503 }
504 /*-----------------11.01.97 10.53-------------------
505 
506 --------------------------------------------------*/
507 
508 sal_Bool	ScTpLayoutOptions::FillItemSet( SfxItemSet& rCoreSet )
509 {
510 	sal_Bool bRet = sal_True;
511     const sal_uInt16 nMPos = aUnitLB.GetSelectEntryPos();
512 	if ( nMPos != aUnitLB.GetSavedValue() )
513 	{
514 		sal_uInt16 nFieldUnit = (sal_uInt16)(long)aUnitLB.GetEntryData( nMPos );
515 		rCoreSet.Put( SfxUInt16Item( SID_ATTR_METRIC,
516 									 (sal_uInt16)nFieldUnit ) );
517 		bRet = sal_True;
518 	}
519 
520 	if(aTabMF.GetText() != aTabMF.GetSavedValue())
521 	{
522 		rCoreSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
523                     sal::static_int_cast<sal_uInt16>( aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP)) )));
524 		bRet = sal_True;
525 	}
526 
527     ScLkUpdMode nSet=LM_ALWAYS;
528 
529 	if(aRequestRB.IsChecked())
530 	{
531 		nSet=LM_ON_DEMAND;
532 	}
533 	else if(aNeverRB.IsChecked())
534 	{
535 		nSet=LM_NEVER;
536 	}
537 
538     if(aRequestRB.IsChecked() != aRequestRB.GetSavedValue() ||
539             aNeverRB.IsChecked() != aNeverRB.GetSavedValue() )
540 	{
541         if(pDoc)
542             pDoc->SetLinkMode(nSet);
543         ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
544 		aAppOptions.SetLinkMode(nSet );
545 		SC_MOD()->SetAppOptions(aAppOptions);
546         bRet = sal_True;
547     }
548     if(aAlignCB.GetSavedValue() != aAlignCB.IsChecked())
549     {
550 		rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_SELECTION, aAlignCB.IsChecked()));
551         bRet = sal_True;
552     }
553 
554 	if(aAlignLB.GetSavedValue() != aAlignLB.GetSelectEntryPos())
555     {
556         rCoreSet.Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, aAlignLB.GetSelectEntryPos()));
557         bRet = sal_True;
558     }
559 
560 	if(aEditModeCB.GetSavedValue() != aEditModeCB.IsChecked())
561     {
562         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, aEditModeCB.IsChecked()));
563         bRet = sal_True;
564     }
565 
566 	if(aFormatCB.GetSavedValue() != aFormatCB.IsChecked())
567     {
568         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, aFormatCB.IsChecked()));
569         bRet = sal_True;
570     }
571 
572 
573     if(aExpRefCB.GetSavedValue() != aExpRefCB.IsChecked())
574     {
575         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, aExpRefCB.IsChecked()));
576         bRet = sal_True;
577     }
578 
579 	if(aMarkHdrCB.GetSavedValue() != aMarkHdrCB.IsChecked())
580     {
581         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, aMarkHdrCB.IsChecked()));
582         bRet = sal_True;
583     }
584 
585 	if(aTextFmtCB.GetSavedValue() != aTextFmtCB.IsChecked())
586     {
587         rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, aTextFmtCB.IsChecked()));
588         bRet = sal_True;
589     }
590 
591     if( aReplWarnCB.GetSavedValue() != aReplWarnCB.IsChecked() )
592     {
593         rCoreSet.Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, aReplWarnCB.IsChecked() ) );
594         bRet = sal_True;
595     }
596 
597     return bRet;
598 }
599 /*-----------------11.01.97 10.53-------------------
600 
601 --------------------------------------------------*/
602 
603 void	ScTpLayoutOptions::Reset( const SfxItemSet& rCoreSet )
604 {
605 	aUnitLB.SetNoSelection();
606 	if ( rCoreSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
607 	{
608 		const SfxUInt16Item& rItem = (SfxUInt16Item&)rCoreSet.Get( SID_ATTR_METRIC );
609 		FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
610 
611 		for ( sal_uInt16 i = 0; i < aUnitLB.GetEntryCount(); ++i )
612 		{
613 			if ( (FieldUnit)(long)aUnitLB.GetEntryData( i ) == eFieldUnit )
614 			{
615 				aUnitLB.SelectEntryPos( i );
616 				break;
617 			}
618 		}
619 		::SetFieldUnit(aTabMF, eFieldUnit);
620 	}
621 	aUnitLB.SaveValue();
622 
623     const SfxPoolItem* pItem;
624     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_ATTR_DEFTABSTOP, sal_False, &pItem))
625 		aTabMF.SetValue(aTabMF.Normalize(((SfxUInt16Item*)pItem)->GetValue()), FUNIT_TWIP);
626 	aTabMF.SaveValue();
627 
628     aUnitLB         .SaveValue();
629 	aTabMF			.SaveValue();
630 
631     ScLkUpdMode nSet=LM_UNKNOWN;
632 
633 	if(pDoc!=NULL)
634 	{
635 		nSet=pDoc->GetLinkMode();
636 	}
637 
638 	if(nSet==LM_UNKNOWN)
639 	{
640 		ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
641 		nSet=aAppOptions.GetLinkMode();
642 	}
643 
644 	switch(nSet)
645 	{
646 		case LM_ALWAYS:		aAlwaysRB.	Check();	break;
647 		case LM_NEVER:		aNeverRB.	Check();	break;
648 		case LM_ON_DEMAND:	aRequestRB.	Check();	break;
649         default:
650         {
651             // added to avoid warnings
652         }
653 	}
654     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTION, sal_False, &pItem))
655 		aAlignCB.Check(((const SfxBoolItem*)pItem)->GetValue());
656 
657 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTIONPOS, sal_False, &pItem))
658 		aAlignLB.SelectEntryPos(((const SfxUInt16Item*)pItem)->GetValue());
659 
660 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_EDITMODE, sal_False, &pItem))
661 		aEditModeCB.Check(((const SfxBoolItem*)pItem)->GetValue());
662 
663 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_FMT_EXPAND, sal_False, &pItem))
664 		aFormatCB.Check(((const SfxBoolItem*)pItem)->GetValue());
665 
666 
667     if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_REF_EXPAND, sal_False, &pItem))
668 		aExpRefCB.Check(((const SfxBoolItem*)pItem)->GetValue());
669 
670 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_MARK_HEADER, sal_False, &pItem))
671 		aMarkHdrCB.Check(((const SfxBoolItem*)pItem)->GetValue());
672 
673 	if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_TEXTWYSIWYG, sal_False, &pItem))
674 		aTextFmtCB.Check(((const SfxBoolItem*)pItem)->GetValue());
675 
676     if( SFX_ITEM_SET == rCoreSet.GetItemState( SID_SC_INPUT_REPLCELLSWARN, sal_False, &pItem ) )
677         aReplWarnCB.Check( ( (const SfxBoolItem*)pItem)->GetValue() );
678 
679     aAlignCB    .SaveValue();
680 	aAlignLB  	.SaveValue();
681 	aEditModeCB	.SaveValue();
682 	aFormatCB	.SaveValue();
683 
684     aExpRefCB   .SaveValue();
685 	aMarkHdrCB	.SaveValue();
686 	aTextFmtCB	.SaveValue();
687     aReplWarnCB .SaveValue();
688 	AlignHdl(&aAlignCB);
689 
690     aAlwaysRB.SaveValue();
691     aNeverRB.SaveValue();
692     aRequestRB.SaveValue();
693 }
694 
695 /*-----------------11.01.97 12.46-------------------
696 
697 --------------------------------------------------*/
698 
699 void	ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ )
700 {
701 }
702 /*-----------------11.01.97 12.46-------------------
703 
704 --------------------------------------------------*/
705 
706 int	ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP )
707 {
708     if(pSetP)
709         FillItemSet(*pSetP);
710 	return SfxTabPage::LEAVE_PAGE;
711 }
712 
713 
714 /*-----------------13.01.97 14.44-------------------
715 	Metric des Deftabstops umschalten
716 --------------------------------------------------*/
717 
718 IMPL_LINK(ScTpLayoutOptions, MetricHdl, ListBox*, EMPTYARG)
719 {
720 	const sal_uInt16 nMPos = aUnitLB.GetSelectEntryPos();
721 	if(nMPos != USHRT_MAX)
722 	{
723 		FieldUnit eFieldUnit = (FieldUnit)(long)aUnitLB.GetEntryData( nMPos );
724         sal_Int64 nVal =
725 			aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) );
726 		::SetFieldUnit( aTabMF, eFieldUnit );
727 		aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP );
728 	}
729 
730 	return 0;
731 }
732 /*-----------------11.01.97 15.30-------------------
733 
734 --------------------------------------------------*/
735 IMPL_LINK( ScTpLayoutOptions, AlignHdl, CheckBox*, pBox )
736 {
737 	aAlignLB.Enable(pBox->IsChecked());
738 	return 0;
739 }
740 
741 
742