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