bump product version to 4.1.6.2
[LibreOffice.git] / sc / source / ui / optdlg / tpview.cxx
blobcb7b49c787cea1375cff24070659d07ed1e8fa28
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #undef SC_DLLIMPLEMENTATION
25 //------------------------------------------------------------------
27 #include "scitems.hxx"
28 #include "tpview.hxx"
29 #include "global.hxx"
30 #include "viewopti.hxx"
31 #include "tabvwsh.hxx"
32 #include "uiitems.hxx"
33 #include "scresid.hxx"
34 #include "docsh.hxx"
35 #include "sc.hrc" // -> Slot-IDs
36 #include "optdlg.hrc"
37 #include "globstr.hrc"
38 #include <appoptio.hxx>
39 #include <scmod.hxx>
40 #include <svx/dlgutil.hxx>
41 #include <svx/drawitem.hxx>
42 #include <svx/xtable.hxx>
45 // STATIC DATA -----------------------------------------------------------
49 ScTpContentOptions::ScTpContentOptions( Window* pParent,
50 const SfxItemSet& rArgSet ) :
51 SfxTabPage(pParent, ScResId( RID_SCPAGE_CONTENT ), rArgSet),
53 aLinesGB( this, ScResId(GB_LINES )),
54 aGridFT( this, ScResId(FT_GRID )),
55 aGridLB( this, ScResId(LB_GRID )),
56 aColorFT( this, ScResId(FT_COLOR )),
57 aColorLB( this, ScResId(LB_COLOR )),
58 aBreakCB( this, ScResId(CB_PAGEBREAKS )),
59 aGuideLineCB( this, ScResId(CB_GUIDELINE )),
61 aSeparator1FL (this, ScResId(FL_SEPARATOR1 )),
62 aDisplayGB( this, ScResId(GB_DISPLAY)),
63 aFormulaCB( this, ScResId(CB_FORMULA)),
64 aNilCB( this, ScResId(CB_NIL )),
65 aAnnotCB( this, ScResId(CB_ANNOT )),
66 aValueCB( this, ScResId(CB_VALUE )),
67 aAnchorCB( this, ScResId(CB_ANCHOR )),
68 aClipMarkCB( this, ScResId(CB_CLIP )),
69 aRangeFindCB( this, ScResId( CB_RFIND )),
71 aObjectGB( this, ScResId(GB_OBJECT )),
72 aObjGrfFT( this, ScResId(FT_OBJGRF )),
73 aObjGrfLB( this, ScResId(LB_OBJGRF )),
74 aDiagramFT( this, ScResId(FT_DIAGRAM)),
75 aDiagramLB( this, ScResId(LB_DIAGRAM)),
76 aDrawFT( this, ScResId(FT_DRAW )),
77 aDrawLB( this, ScResId(LB_DRAW )),
79 aZoomGB( this, ScResId(GB_ZOOM) ),
80 aSyncZoomCB( this, ScResId(CB_SYNCZOOM) ),
82 aSeparator2FL (this, ScResId(FL_SEPARATOR2)),
83 aWindowGB( this, ScResId(GB_WINDOW )),
84 aRowColHeaderCB(this, ScResId(CB_ROWCOLHEADER )),
85 aHScrollCB( this, ScResId(CB_HSCROLL )),
86 aVScrollCB( this, ScResId(CB_VSCROLL )),
87 aTblRegCB( this, ScResId(CB_TBLREG )),
88 aOutlineCB( this, ScResId(CB_OUTLINE )),
89 pLocalOptions(0)
91 FreeResource();
92 aSeparator1FL.SetStyle( aSeparator1FL.GetStyle() | WB_VERT );
93 aSeparator2FL.SetStyle( aSeparator2FL.GetStyle() | WB_VERT );
94 SetExchangeSupport();
95 Link aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) );
96 aObjGrfLB. SetSelectHdl(aSelObjHdl);
97 aDiagramLB. SetSelectHdl(aSelObjHdl);
98 aDrawLB. SetSelectHdl(aSelObjHdl);
99 aGridLB. SetSelectHdl( LINK( this, ScTpContentOptions, GridHdl ) );
101 Link aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
102 aFormulaCB .SetClickHdl(aCBHdl);
103 aNilCB .SetClickHdl(aCBHdl);
104 aAnnotCB .SetClickHdl(aCBHdl);
105 aValueCB .SetClickHdl(aCBHdl);
106 aAnchorCB .SetClickHdl(aCBHdl);
107 aClipMarkCB .SetClickHdl(aCBHdl);
109 aVScrollCB .SetClickHdl(aCBHdl);
110 aHScrollCB .SetClickHdl(aCBHdl);
111 aTblRegCB .SetClickHdl(aCBHdl);
112 aOutlineCB .SetClickHdl(aCBHdl);
113 aBreakCB .SetClickHdl(aCBHdl);
114 aGuideLineCB.SetClickHdl(aCBHdl);
115 aRowColHeaderCB.SetClickHdl(aCBHdl);
119 ScTpContentOptions::~ScTpContentOptions()
121 delete pLocalOptions;
124 SfxTabPage* ScTpContentOptions::Create( Window* pParent,
125 const SfxItemSet& rCoreSet )
127 return new ScTpContentOptions(pParent, rCoreSet);
130 sal_Bool ScTpContentOptions::FillItemSet( SfxItemSet& rCoreSet )
132 sal_Bool bRet = false;
133 if( aFormulaCB .GetSavedValue() != aFormulaCB .IsChecked() ||
134 aNilCB .GetSavedValue() != aNilCB .IsChecked() ||
135 aAnnotCB .GetSavedValue() != aAnnotCB .IsChecked() ||
136 aValueCB .GetSavedValue() != aValueCB .IsChecked() ||
137 aAnchorCB .GetSavedValue() != aAnchorCB .IsChecked() ||
138 aClipMarkCB .GetSavedValue() != aClipMarkCB .IsChecked() ||
139 aObjGrfLB .GetSavedValue() != aObjGrfLB .GetSelectEntryPos() ||
140 aDiagramLB .GetSavedValue() != aDiagramLB .GetSelectEntryPos() ||
141 aDrawLB .GetSavedValue() != aDrawLB .GetSelectEntryPos() ||
142 aGridLB .GetSavedValue() != aGridLB .GetSelectEntryPos() ||
143 aRowColHeaderCB .GetSavedValue() != aRowColHeaderCB.IsChecked() ||
144 aHScrollCB .GetSavedValue() != aHScrollCB .IsChecked() ||
145 aVScrollCB .GetSavedValue() != aVScrollCB .IsChecked() ||
146 aTblRegCB .GetSavedValue() != aTblRegCB .IsChecked() ||
147 aOutlineCB .GetSavedValue() != aOutlineCB .IsChecked() ||
148 aColorLB .GetSavedValue() != aColorLB .GetSelectEntryPos() ||
149 aBreakCB .GetSavedValue() != aBreakCB .IsChecked() ||
150 aGuideLineCB .GetSavedValue() != aGuideLineCB .IsChecked())
152 pLocalOptions->SetGridColor( aColorLB.GetSelectEntryColor(),
153 aColorLB.GetSelectEntry() );
154 rCoreSet.Put(ScTpViewItem(SID_SCVIEWOPTIONS, *pLocalOptions));
155 bRet = sal_True;
157 if(aRangeFindCB.GetSavedValue() != aRangeFindCB.IsChecked())
159 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, aRangeFindCB.IsChecked()));
160 bRet = sal_True;
162 if(aSyncZoomCB.GetSavedValue() != aSyncZoomCB.IsChecked())
164 rCoreSet.Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, aSyncZoomCB.IsChecked()));
165 bRet = sal_True;
169 return bRet;
172 void ScTpContentOptions::Reset( const SfxItemSet& rCoreSet )
174 const SfxPoolItem* pItem;
175 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
176 pLocalOptions = new ScViewOptions(
177 ((const ScTpViewItem*)pItem)->GetViewOptions() );
178 else
179 pLocalOptions = new ScViewOptions;
180 aFormulaCB .Check(pLocalOptions->GetOption(VOPT_FORMULAS));
181 aNilCB .Check(pLocalOptions->GetOption(VOPT_NULLVALS));
182 aAnnotCB .Check(pLocalOptions->GetOption(VOPT_NOTES));
183 aValueCB .Check(pLocalOptions->GetOption(VOPT_SYNTAX));
184 aAnchorCB .Check(pLocalOptions->GetOption(VOPT_ANCHOR));
185 aClipMarkCB .Check(pLocalOptions->GetOption(VOPT_CLIPMARKS));
187 aObjGrfLB .SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) );
188 aDiagramLB .SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) );
189 aDrawLB .SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) );
191 aRowColHeaderCB.Check( pLocalOptions->GetOption(VOPT_HEADER) );
192 aHScrollCB .Check( pLocalOptions->GetOption(VOPT_HSCROLL) );
193 aVScrollCB .Check( pLocalOptions->GetOption(VOPT_VSCROLL) );
194 aTblRegCB .Check( pLocalOptions->GetOption(VOPT_TABCONTROLS) );
195 aOutlineCB .Check( pLocalOptions->GetOption(VOPT_OUTLINER) );
197 InitGridOpt();
199 aBreakCB.Check( pLocalOptions->GetOption(VOPT_PAGEBREAKS) );
200 aGuideLineCB.Check( pLocalOptions->GetOption(VOPT_HELPLINES) );
202 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_RANGEFINDER, false, &pItem))
203 aRangeFindCB.Check(((const SfxBoolItem*)pItem)->GetValue());
204 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_OPT_SYNCZOOM, false, &pItem))
205 aSyncZoomCB.Check(((const SfxBoolItem*)pItem)->GetValue());
207 aRangeFindCB.SaveValue();
208 aSyncZoomCB.SaveValue();
210 aFormulaCB .SaveValue();
211 aNilCB .SaveValue();
212 aAnnotCB .SaveValue();
213 aValueCB .SaveValue();
214 aAnchorCB .SaveValue();
215 aClipMarkCB .SaveValue();
216 aObjGrfLB .SaveValue();
217 aDiagramLB .SaveValue();
218 aDrawLB .SaveValue();
219 aRowColHeaderCB .SaveValue();
220 aHScrollCB .SaveValue();
221 aVScrollCB .SaveValue();
222 aTblRegCB .SaveValue();
223 aOutlineCB .SaveValue();
224 aGridLB .SaveValue();
225 aColorLB .SaveValue();
226 aBreakCB .SaveValue();
227 aGuideLineCB .SaveValue();
230 void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
232 const SfxPoolItem* pItem;
233 if(SFX_ITEM_SET == rSet.GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
234 *pLocalOptions = ((const ScTpViewItem*)pItem)->GetViewOptions();
237 int ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
239 if(pSetP)
240 FillItemSet(*pSetP);
241 return SfxTabPage::LEAVE_PAGE;
244 IMPL_LINK( ScTpContentOptions, SelLbObjHdl, ListBox*, pLb )
246 sal_uInt16 nSelPos = pLb->GetSelectEntryPos();
247 ScVObjMode eMode = ScVObjMode(nSelPos);
248 ScVObjType eType = VOBJ_TYPE_OLE;
250 if ( pLb == &aDiagramLB )
251 eType = VOBJ_TYPE_CHART;
252 else if ( pLb == &aDrawLB )
253 eType = VOBJ_TYPE_DRAW;
255 pLocalOptions->SetObjMode( eType, eMode );
257 return 0;
260 IMPL_LINK( ScTpContentOptions, CBHdl, CheckBox*, pBtn )
262 ScViewOption eOption = VOPT_FORMULAS;
263 sal_Bool bChecked = pBtn->IsChecked();
265 if ( &aFormulaCB == pBtn ) eOption = VOPT_FORMULAS;
266 else if ( &aNilCB == pBtn ) eOption = VOPT_NULLVALS;
267 else if ( &aAnnotCB == pBtn ) eOption = VOPT_NOTES;
268 else if ( &aValueCB == pBtn ) eOption = VOPT_SYNTAX;
269 else if ( &aAnchorCB == pBtn ) eOption = VOPT_ANCHOR;
270 else if ( &aClipMarkCB == pBtn ) eOption = VOPT_CLIPMARKS;
271 else if ( &aVScrollCB == pBtn ) eOption = VOPT_VSCROLL;
272 else if ( &aHScrollCB == pBtn ) eOption = VOPT_HSCROLL;
273 else if ( &aTblRegCB == pBtn ) eOption = VOPT_TABCONTROLS;
274 else if ( &aOutlineCB == pBtn ) eOption = VOPT_OUTLINER;
275 else if ( &aBreakCB == pBtn ) eOption = VOPT_PAGEBREAKS;
276 else if ( &aGuideLineCB == pBtn ) eOption = VOPT_HELPLINES;
277 else if ( &aRowColHeaderCB == pBtn ) eOption = VOPT_HEADER;
279 pLocalOptions->SetOption( eOption, bChecked );
282 return 0;
285 void ScTpContentOptions::InitGridOpt()
287 sal_Bool bGrid = pLocalOptions->GetOption( VOPT_GRID );
288 sal_Bool bGridOnTop = pLocalOptions->GetOption( VOPT_GRID_ONTOP );
289 sal_uInt16 nSelPos = 0;
291 if ( bGrid || bGridOnTop )
293 aColorFT.Enable(), aColorLB.Enable();
294 if ( !bGridOnTop )
295 nSelPos = 0;
296 else
297 nSelPos = 1;
299 else
301 aColorFT.Disable(), aColorLB.Disable();
302 nSelPos = 2;
305 aGridLB.SelectEntryPos (nSelPos);
307 if ( aColorLB.GetEntryCount() == 0 )
309 SfxObjectShell* pDocSh = SfxObjectShell::Current();
310 // there might be another DocShell here
311 pDocSh = PTR_CAST(ScDocShell, pDocSh);
313 XColorListRef pColorList;
314 if ( pDocSh )
316 const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
317 if ( pItem )
318 pColorList = ((SvxColorListItem*)pItem)->GetColorList();
320 else
321 pColorList = XColorList::GetStdColorList();
323 if ( !pColorList.is() )
324 return;
326 //------------------------------------------------------
328 aColorLB.SetUpdateMode( false );
330 // items from ColorTable
332 long nCount = pColorList->Count();
333 for ( long n=0; n<nCount; n++ )
335 XColorEntry* pEntry = pColorList->GetColor(n);
336 aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
339 // default GridColor
341 Color aStdCol( SC_STD_GRIDCOLOR ); // same default as in ScViewOptions
342 if ( LISTBOX_ENTRY_NOTFOUND ==
343 aColorLB.GetEntryPos( aStdCol ) )
344 aColorLB.InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) );
346 aColorLB.SetUpdateMode( sal_True );
348 Invalidate();
351 // also select grid color entry on subsequent calls
353 String aName;
354 Color aCol = pLocalOptions->GetGridColor( &aName );
355 nSelPos = aColorLB.GetEntryPos( aCol );
357 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
358 aColorLB.SelectEntryPos( nSelPos );
359 else
360 aColorLB.SelectEntryPos( aColorLB.InsertEntry( aCol, aName ) );
363 IMPL_LINK( ScTpContentOptions, GridHdl, ListBox*, pLb )
365 sal_uInt16 nSelPos = pLb->GetSelectEntryPos();
366 sal_Bool bGrid = ( nSelPos <= 1 );
367 sal_Bool bGridOnTop = ( nSelPos == 1 );
369 aColorFT.Enable(bGrid);
370 aColorLB.Enable(bGrid);
371 pLocalOptions->SetOption( VOPT_GRID, bGrid );
372 pLocalOptions->SetOption( VOPT_GRID_ONTOP, bGridOnTop );
373 return 0;
376 ScTpLayoutOptions::ScTpLayoutOptions( Window* pParent,
377 const SfxItemSet& rArgSet ) :
378 SfxTabPage(pParent, ScResId( RID_SCPAGE_LAYOUT ), rArgSet),
379 aUnitGB( this, ScResId(GB_UNIT )),
380 aUnitFT( this, ScResId(FT_UNIT )),
381 aUnitLB( this, ScResId(LB_UNIT )),
382 aTabFT( this, ScResId( FT_TAB )),
383 aTabMF( this, ScResId( MF_TAB )),
384 aSeparatorFL( this, ScResId( FL_SEPARATOR )),
385 aLinkGB (this, ScResId(GB_LINK )),
386 aLinkFT(this, ScResId(FT_UPDATE_LINKS )),
387 aAlwaysRB (this, ScResId(RB_ALWAYS )),
388 aRequestRB (this, ScResId(RB_REQUEST )),
389 aNeverRB (this, ScResId(RB_NEVER )),
391 aOptionsGB( this, ScResId( GB_OPTIONS )),
392 aAlignCB ( this, ScResId( CB_ALIGN )),
393 aAlignLB ( this, ScResId( LB_ALIGN )),
394 aEditModeCB( this, ScResId( CB_EDITMODE )),
395 aFormatCB( this, ScResId( CB_FORMAT )),
396 aExpRefCB( this, ScResId( CB_EXPREF )),
397 aMarkHdrCB( this, ScResId( CB_MARKHDR )),
398 aTextFmtCB( this, ScResId( CB_TEXTFMT )),
399 aReplWarnCB( this, ScResId( CB_REPLWARN )),
400 aUnitArr( ScResId(ST_UNIT )),
401 pDoc(NULL)
403 FreeResource();
404 aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
405 SetExchangeSupport();
407 aUnitLB. SetSelectHdl( LINK( this, ScTpLayoutOptions, MetricHdl ) );
409 aAlignCB.SetClickHdl(LINK(this, ScTpLayoutOptions, AlignHdl));
412 for ( sal_uInt16 i = 0; i < aUnitArr.Count(); ++i )
414 String sMetric = aUnitArr.GetStringByPos( i );
415 FieldUnit eFUnit = (FieldUnit)aUnitArr.GetValue( i );
417 switch ( eFUnit )
419 case FUNIT_MM:
420 case FUNIT_CM:
421 case FUNIT_POINT:
422 case FUNIT_PICA:
423 case FUNIT_INCH:
425 // nur diese Metriken benutzen
426 sal_uInt16 nPos = aUnitLB.InsertEntry( sMetric );
427 aUnitLB.SetEntryData( nPos, (void*)(long)eFUnit );
429 break;
430 default:
432 // added to avoid warnings
439 ScTpLayoutOptions::~ScTpLayoutOptions()
443 SfxTabPage* ScTpLayoutOptions::Create( Window* pParent,
444 const SfxItemSet& rCoreSet )
446 ScTpLayoutOptions* pNew = new ScTpLayoutOptions(pParent, rCoreSet);
447 ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current());
449 if(pDocSh!=NULL)
450 pNew->SetDocument(pDocSh->GetDocument());
451 return pNew;
454 sal_Bool ScTpLayoutOptions::FillItemSet( SfxItemSet& rCoreSet )
456 sal_Bool bRet = sal_True;
457 const sal_uInt16 nMPos = aUnitLB.GetSelectEntryPos();
458 if ( nMPos != aUnitLB.GetSavedValue() )
460 sal_uInt16 nFieldUnit = (sal_uInt16)(long)aUnitLB.GetEntryData( nMPos );
461 rCoreSet.Put( SfxUInt16Item( SID_ATTR_METRIC,
462 (sal_uInt16)nFieldUnit ) );
463 bRet = sal_True;
466 if(aTabMF.GetText() != aTabMF.GetSavedValue())
468 rCoreSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
469 sal::static_int_cast<sal_uInt16>( aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP)) )));
470 bRet = sal_True;
473 ScLkUpdMode nSet=LM_ALWAYS;
475 if(aRequestRB.IsChecked())
477 nSet=LM_ON_DEMAND;
479 else if(aNeverRB.IsChecked())
481 nSet=LM_NEVER;
484 if(aRequestRB.IsChecked() != aRequestRB.GetSavedValue() ||
485 aNeverRB.IsChecked() != aNeverRB.GetSavedValue() )
487 if(pDoc)
488 pDoc->SetLinkMode(nSet);
489 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
490 aAppOptions.SetLinkMode(nSet );
491 SC_MOD()->SetAppOptions(aAppOptions);
492 bRet = sal_True;
494 if(aAlignCB.GetSavedValue() != aAlignCB.IsChecked())
496 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_SELECTION, aAlignCB.IsChecked()));
497 bRet = sal_True;
500 if(aAlignLB.GetSavedValue() != aAlignLB.GetSelectEntryPos())
502 rCoreSet.Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, aAlignLB.GetSelectEntryPos()));
503 bRet = sal_True;
506 if(aEditModeCB.GetSavedValue() != aEditModeCB.IsChecked())
508 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, aEditModeCB.IsChecked()));
509 bRet = sal_True;
512 if(aFormatCB.GetSavedValue() != aFormatCB.IsChecked())
514 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, aFormatCB.IsChecked()));
515 bRet = sal_True;
519 if(aExpRefCB.GetSavedValue() != aExpRefCB.IsChecked())
521 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, aExpRefCB.IsChecked()));
522 bRet = sal_True;
525 if(aMarkHdrCB.GetSavedValue() != aMarkHdrCB.IsChecked())
527 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, aMarkHdrCB.IsChecked()));
528 bRet = sal_True;
531 if(aTextFmtCB.GetSavedValue() != aTextFmtCB.IsChecked())
533 rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, aTextFmtCB.IsChecked()));
534 bRet = sal_True;
537 if( aReplWarnCB.GetSavedValue() != aReplWarnCB.IsChecked() )
539 rCoreSet.Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, aReplWarnCB.IsChecked() ) );
540 bRet = sal_True;
543 return bRet;
546 void ScTpLayoutOptions::Reset( const SfxItemSet& rCoreSet )
548 aUnitLB.SetNoSelection();
549 if ( rCoreSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
551 const SfxUInt16Item& rItem = (SfxUInt16Item&)rCoreSet.Get( SID_ATTR_METRIC );
552 FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
554 for ( sal_uInt16 i = 0; i < aUnitLB.GetEntryCount(); ++i )
556 if ( (FieldUnit)(long)aUnitLB.GetEntryData( i ) == eFieldUnit )
558 aUnitLB.SelectEntryPos( i );
559 break;
562 ::SetFieldUnit(aTabMF, eFieldUnit);
564 aUnitLB.SaveValue();
566 const SfxPoolItem* pItem;
567 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
568 aTabMF.SetValue(aTabMF.Normalize(((SfxUInt16Item*)pItem)->GetValue()), FUNIT_TWIP);
569 aTabMF.SaveValue();
571 aUnitLB .SaveValue();
572 aTabMF .SaveValue();
574 ScLkUpdMode nSet=LM_UNKNOWN;
576 if(pDoc!=NULL)
578 nSet=pDoc->GetLinkMode();
581 if(nSet==LM_UNKNOWN)
583 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
584 nSet=aAppOptions.GetLinkMode();
587 switch(nSet)
589 case LM_ALWAYS: aAlwaysRB. Check(); break;
590 case LM_NEVER: aNeverRB. Check(); break;
591 case LM_ON_DEMAND: aRequestRB. Check(); break;
592 default:
594 // added to avoid warnings
597 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTION, false, &pItem))
598 aAlignCB.Check(((const SfxBoolItem*)pItem)->GetValue());
600 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTIONPOS, false, &pItem))
601 aAlignLB.SelectEntryPos(((const SfxUInt16Item*)pItem)->GetValue());
603 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_EDITMODE, false, &pItem))
604 aEditModeCB.Check(((const SfxBoolItem*)pItem)->GetValue());
606 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_FMT_EXPAND, false, &pItem))
607 aFormatCB.Check(((const SfxBoolItem*)pItem)->GetValue());
610 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_REF_EXPAND, false, &pItem))
611 aExpRefCB.Check(((const SfxBoolItem*)pItem)->GetValue());
613 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_MARK_HEADER, false, &pItem))
614 aMarkHdrCB.Check(((const SfxBoolItem*)pItem)->GetValue());
616 if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_TEXTWYSIWYG, false, &pItem))
617 aTextFmtCB.Check(((const SfxBoolItem*)pItem)->GetValue());
619 if( SFX_ITEM_SET == rCoreSet.GetItemState( SID_SC_INPUT_REPLCELLSWARN, false, &pItem ) )
620 aReplWarnCB.Check( ( (const SfxBoolItem*)pItem)->GetValue() );
622 aAlignCB .SaveValue();
623 aAlignLB .SaveValue();
624 aEditModeCB .SaveValue();
625 aFormatCB .SaveValue();
627 aExpRefCB .SaveValue();
628 aMarkHdrCB .SaveValue();
629 aTextFmtCB .SaveValue();
630 aReplWarnCB .SaveValue();
631 AlignHdl(&aAlignCB);
633 aAlwaysRB.SaveValue();
634 aNeverRB.SaveValue();
635 aRequestRB.SaveValue();
638 void ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ )
642 int ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP )
644 if(pSetP)
645 FillItemSet(*pSetP);
646 return SfxTabPage::LEAVE_PAGE;
649 IMPL_LINK_NOARG(ScTpLayoutOptions, MetricHdl)
651 const sal_uInt16 nMPos = aUnitLB.GetSelectEntryPos();
652 if(nMPos != USHRT_MAX)
654 FieldUnit eFieldUnit = (FieldUnit)(long)aUnitLB.GetEntryData( nMPos );
655 sal_Int64 nVal =
656 aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) );
657 ::SetFieldUnit( aTabMF, eFieldUnit );
658 aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP );
661 return 0;
664 IMPL_LINK( ScTpLayoutOptions, AlignHdl, CheckBox*, pBox )
666 aAlignLB.Enable(pBox->IsChecked());
667 return 0;
671 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */