Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / optdlg / tpview.cxx
blob110cb3038c065ed2600d6733c7e7ce4868b538b3
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 .
20 #undef SC_DLLIMPLEMENTATION
22 #include "scitems.hxx"
23 #include "tpview.hxx"
24 #include "global.hxx"
25 #include "viewopti.hxx"
26 #include "tabvwsh.hxx"
27 #include "uiitems.hxx"
28 #include "scresid.hxx"
29 #include "docsh.hxx"
30 #include "sc.hrc"
31 #include "globstr.hrc"
32 #include <appoptio.hxx>
33 #include <scmod.hxx>
34 #include <svx/dlgutil.hxx>
35 #include <svx/drawitem.hxx>
36 #include <svx/xtable.hxx>
38 ScTpContentOptions::ScTpContentOptions( vcl::Window* pParent,
39 const SfxItemSet& rArgSet ) :
40 SfxTabPage(pParent, "TpViewPage", "modules/scalc/ui/tpviewpage.ui", &rArgSet),
41 pLocalOptions(nullptr)
43 get(pGridLB,"grid");
44 get(pColorFT,"color_label");
45 get(pColorLB,"color");
46 get(pBreakCB,"break");
47 get(pGuideLineCB,"guideline");
49 get(pFormulaCB,"formula");
50 get(pNilCB,"nil");
51 get(pAnnotCB,"annot");
52 get(pValueCB,"value");
53 get(pAnchorCB,"anchor");
54 get(pClipMarkCB,"clipmark");
55 get(pRangeFindCB,"rangefind");
57 get(pObjGrfLB,"objgrf");
58 get(pDiagramLB,"diagram");
59 get(pDrawLB,"draw");
61 get(pSyncZoomCB,"synczoom");
63 get(pRowColHeaderCB,"rowcolheader");
64 get(pHScrollCB,"hscroll");
65 get(pVScrollCB,"vscroll");
66 get(pTblRegCB,"tblreg");
67 get(pOutlineCB,"outline");
69 SetExchangeSupport();
70 Link<ListBox&,void> aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) );
71 pObjGrfLB-> SetSelectHdl(aSelObjHdl);
72 pDiagramLB-> SetSelectHdl(aSelObjHdl);
73 pDrawLB-> SetSelectHdl(aSelObjHdl);
74 pGridLB-> SetSelectHdl( LINK( this, ScTpContentOptions, GridHdl ) );
76 Link<Button*, void> aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
77 pFormulaCB ->SetClickHdl(aCBHdl);
78 pNilCB ->SetClickHdl(aCBHdl);
79 pAnnotCB ->SetClickHdl(aCBHdl);
80 pValueCB ->SetClickHdl(aCBHdl);
81 pAnchorCB ->SetClickHdl(aCBHdl);
82 pClipMarkCB ->SetClickHdl(aCBHdl);
84 pVScrollCB ->SetClickHdl(aCBHdl);
85 pHScrollCB ->SetClickHdl(aCBHdl);
86 pTblRegCB ->SetClickHdl(aCBHdl);
87 pOutlineCB ->SetClickHdl(aCBHdl);
88 pBreakCB ->SetClickHdl(aCBHdl);
89 pGuideLineCB->SetClickHdl(aCBHdl);
90 pRowColHeaderCB->SetClickHdl(aCBHdl);
94 ScTpContentOptions::~ScTpContentOptions()
96 disposeOnce();
99 void ScTpContentOptions::dispose()
101 delete pLocalOptions;
102 pGridLB.clear();
103 pColorFT.clear();
104 pColorLB.clear();
105 pBreakCB.clear();
106 pGuideLineCB.clear();
107 pFormulaCB.clear();
108 pNilCB.clear();
109 pAnnotCB.clear();
110 pValueCB.clear();
111 pAnchorCB.clear();
112 pClipMarkCB.clear();
113 pRangeFindCB.clear();
114 pObjGrfLB.clear();
115 pDiagramLB.clear();
116 pDrawLB.clear();
117 pSyncZoomCB.clear();
118 pRowColHeaderCB.clear();
119 pHScrollCB.clear();
120 pVScrollCB.clear();
121 pTblRegCB.clear();
122 pOutlineCB.clear();
123 SfxTabPage::dispose();
126 VclPtr<SfxTabPage> ScTpContentOptions::Create( vcl::Window* pParent,
127 const SfxItemSet* rCoreSet )
129 return VclPtr<ScTpContentOptions>::Create(pParent, *rCoreSet);
132 bool ScTpContentOptions::FillItemSet( SfxItemSet* rCoreSet )
134 bool bRet = false;
135 if( pFormulaCB ->IsValueChangedFromSaved() ||
136 pNilCB ->IsValueChangedFromSaved() ||
137 pAnnotCB ->IsValueChangedFromSaved() ||
138 pValueCB ->IsValueChangedFromSaved() ||
139 pAnchorCB ->IsValueChangedFromSaved() ||
140 pClipMarkCB->IsValueChangedFromSaved() ||
141 pObjGrfLB ->IsValueChangedFromSaved() ||
142 pDiagramLB ->IsValueChangedFromSaved() ||
143 pDrawLB ->IsValueChangedFromSaved() ||
144 pGridLB ->IsValueChangedFromSaved() ||
145 pRowColHeaderCB->IsValueChangedFromSaved() ||
146 pHScrollCB ->IsValueChangedFromSaved() ||
147 pVScrollCB ->IsValueChangedFromSaved() ||
148 pTblRegCB ->IsValueChangedFromSaved() ||
149 pOutlineCB ->IsValueChangedFromSaved() ||
150 pColorLB ->IsValueChangedFromSaved() ||
151 pBreakCB ->IsValueChangedFromSaved() ||
152 pGuideLineCB ->IsValueChangedFromSaved())
154 pLocalOptions->SetGridColor( pColorLB->GetSelectEntryColor(),
155 pColorLB->GetSelectEntry() );
156 rCoreSet->Put(ScTpViewItem(SID_SCVIEWOPTIONS, *pLocalOptions));
157 bRet = true;
159 if(pRangeFindCB->IsValueChangedFromSaved())
161 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, pRangeFindCB->IsChecked()));
162 bRet = true;
164 if(pSyncZoomCB->IsValueChangedFromSaved())
166 rCoreSet->Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, pSyncZoomCB->IsChecked()));
167 bRet = true;
170 return bRet;
173 void ScTpContentOptions::Reset( const SfxItemSet* rCoreSet )
175 const SfxPoolItem* pItem;
176 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
177 pLocalOptions = new ScViewOptions(
178 static_cast<const ScTpViewItem*>(pItem)->GetViewOptions() );
179 else
180 pLocalOptions = new ScViewOptions;
181 pFormulaCB ->Check(pLocalOptions->GetOption(VOPT_FORMULAS));
182 pNilCB ->Check(pLocalOptions->GetOption(VOPT_NULLVALS));
183 pAnnotCB ->Check(pLocalOptions->GetOption(VOPT_NOTES));
184 pValueCB ->Check(pLocalOptions->GetOption(VOPT_SYNTAX));
185 pAnchorCB ->Check(pLocalOptions->GetOption(VOPT_ANCHOR));
186 pClipMarkCB->Check(pLocalOptions->GetOption(VOPT_CLIPMARKS));
188 pObjGrfLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) );
189 pDiagramLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) );
190 pDrawLB ->SelectEntryPos( (sal_uInt16)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) );
192 pRowColHeaderCB->Check( pLocalOptions->GetOption(VOPT_HEADER) );
193 pHScrollCB->Check( pLocalOptions->GetOption(VOPT_HSCROLL) );
194 pVScrollCB->Check( pLocalOptions->GetOption(VOPT_VSCROLL) );
195 pTblRegCB ->Check( pLocalOptions->GetOption(VOPT_TABCONTROLS) );
196 pOutlineCB->Check( pLocalOptions->GetOption(VOPT_OUTLINER) );
198 InitGridOpt();
200 pBreakCB->Check( pLocalOptions->GetOption(VOPT_PAGEBREAKS) );
201 pGuideLineCB->Check( pLocalOptions->GetOption(VOPT_HELPLINES) );
203 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_RANGEFINDER, false, &pItem))
204 pRangeFindCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
205 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_OPT_SYNCZOOM, false, &pItem))
206 pSyncZoomCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
208 pRangeFindCB->SaveValue();
209 pSyncZoomCB->SaveValue();
211 pFormulaCB->SaveValue();
212 pNilCB->SaveValue();
213 pAnnotCB->SaveValue();
214 pValueCB->SaveValue();
215 pAnchorCB->SaveValue();
216 pClipMarkCB->SaveValue();
217 pObjGrfLB->SaveValue();
218 pDiagramLB->SaveValue();
219 pDrawLB->SaveValue();
220 pRowColHeaderCB->SaveValue();
221 pHScrollCB->SaveValue();
222 pVScrollCB->SaveValue();
223 pTblRegCB->SaveValue();
224 pOutlineCB->SaveValue();
225 pGridLB->SaveValue();
226 pColorLB->SaveValue();
227 pBreakCB->SaveValue();
228 pGuideLineCB->SaveValue();
231 void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
233 const SfxPoolItem* pItem;
234 if(SfxItemState::SET == rSet.GetItemState(SID_SCVIEWOPTIONS, false , &pItem))
235 *pLocalOptions = static_cast<const ScTpViewItem*>(pItem)->GetViewOptions();
238 SfxTabPage::sfxpg ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
240 if(pSetP)
241 FillItemSet(pSetP);
242 return SfxTabPage::LEAVE_PAGE;
245 IMPL_LINK_TYPED( ScTpContentOptions, SelLbObjHdl, ListBox&, rLb, void )
247 const sal_Int32 nSelPos = rLb.GetSelectEntryPos();
248 ScVObjMode eMode = ScVObjMode(nSelPos);
249 ScVObjType eType = VOBJ_TYPE_OLE;
251 if ( &rLb == pDiagramLB )
252 eType = VOBJ_TYPE_CHART;
253 else if ( &rLb == pDrawLB )
254 eType = VOBJ_TYPE_DRAW;
256 pLocalOptions->SetObjMode( eType, eMode );
259 IMPL_LINK_TYPED( ScTpContentOptions, CBHdl, Button*, pBtn, void )
261 ScViewOption eOption = VOPT_FORMULAS;
262 bool bChecked = static_cast<CheckBox*>(pBtn)->IsChecked();
264 if ( pFormulaCB == pBtn ) eOption = VOPT_FORMULAS;
265 else if ( pNilCB == pBtn ) eOption = VOPT_NULLVALS;
266 else if ( pAnnotCB == pBtn ) eOption = VOPT_NOTES;
267 else if ( pValueCB == pBtn ) eOption = VOPT_SYNTAX;
268 else if ( pAnchorCB == pBtn ) eOption = VOPT_ANCHOR;
269 else if ( pClipMarkCB == pBtn ) eOption = VOPT_CLIPMARKS;
270 else if ( pVScrollCB == pBtn ) eOption = VOPT_VSCROLL;
271 else if ( pHScrollCB == pBtn ) eOption = VOPT_HSCROLL;
272 else if ( pTblRegCB == pBtn ) eOption = VOPT_TABCONTROLS;
273 else if ( pOutlineCB == pBtn ) eOption = VOPT_OUTLINER;
274 else if ( pBreakCB == pBtn ) eOption = VOPT_PAGEBREAKS;
275 else if ( pGuideLineCB == pBtn ) eOption = VOPT_HELPLINES;
276 else if ( pRowColHeaderCB == pBtn ) eOption = VOPT_HEADER;
278 pLocalOptions->SetOption( eOption, bChecked );
281 void ScTpContentOptions::InitGridOpt()
283 bool bGrid = pLocalOptions->GetOption( VOPT_GRID );
284 bool bGridOnTop = pLocalOptions->GetOption( VOPT_GRID_ONTOP );
285 sal_Int32 nSelPos = 0;
287 if ( bGrid || bGridOnTop )
289 pColorFT->Enable();
290 pColorLB->Enable();
291 if ( !bGridOnTop )
292 nSelPos = 0;
293 else
294 nSelPos = 1;
296 else
298 pColorFT->Disable();
299 pColorLB->Disable();
300 nSelPos = 2;
303 pGridLB->SelectEntryPos (nSelPos);
305 if ( pColorLB->GetEntryCount() == 0 )
307 SfxObjectShell* pDocSh = SfxObjectShell::Current();
308 // there might be another DocShell here
309 pDocSh = dynamic_cast<ScDocShell*>( pDocSh );
311 XColorListRef pColorList;
312 if ( pDocSh )
314 const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
315 if ( pItem )
316 pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
318 else
319 pColorList = XColorList::GetStdColorList();
321 if ( !pColorList.is() )
322 return;
324 pColorLB->SetUpdateMode( false );
326 // items from ColorTable
328 long nCount = pColorList->Count();
329 for ( long n=0; n<nCount; n++ )
331 XColorEntry* pEntry = pColorList->GetColor(n);
332 pColorLB->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
335 // default GridColor
337 Color aStdCol( SC_STD_GRIDCOLOR ); // same default as in ScViewOptions
338 if ( LISTBOX_ENTRY_NOTFOUND ==
339 pColorLB->GetEntryPos( aStdCol ) )
340 pColorLB->InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) );
342 pColorLB->SetUpdateMode( true );
344 Invalidate();
347 // also select grid color entry on subsequent calls
349 OUString aName;
350 Color aCol = pLocalOptions->GetGridColor( &aName );
351 nSelPos = pColorLB->GetEntryPos( aCol );
353 if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
354 pColorLB->SelectEntryPos( nSelPos );
355 else
356 pColorLB->SelectEntryPos( pColorLB->InsertEntry( aCol, aName ) );
359 IMPL_LINK_TYPED( ScTpContentOptions, GridHdl, ListBox&, rLb, void )
361 sal_Int32 nSelPos = rLb.GetSelectEntryPos();
362 bool bGrid = ( nSelPos <= 1 );
363 bool bGridOnTop = ( nSelPos == 1 );
365 pColorFT->Enable(bGrid);
366 pColorLB->Enable(bGrid);
367 pLocalOptions->SetOption( VOPT_GRID, bGrid );
368 pLocalOptions->SetOption( VOPT_GRID_ONTOP, bGridOnTop );
371 ScTpLayoutOptions::ScTpLayoutOptions( vcl::Window* pParent,
372 const SfxItemSet& rArgSet ) :
373 SfxTabPage( pParent, "ScGeneralPage",
374 "modules/scalc/ui/scgeneralpage.ui", &rArgSet),
375 aUnitArr( ScResId(SCSTR_UNIT )),
376 pDoc(nullptr)
378 get( m_pUnitLB, "unitlb");
379 get( m_pTabMF, "tabmf");
381 get( m_pAlwaysRB, "alwaysrb");
382 get( m_pRequestRB, "requestrb");
383 get( m_pNeverRB, "neverrb");
385 get( m_pAlignCB, "aligncb");
386 get( m_pAlignLB, "alignlb");
387 get( m_pEditModeCB, "editmodecb");
388 get( m_pFormatCB, "formatcb");
389 get( m_pExpRefCB, "exprefcb");
390 get( m_pSortRefUpdateCB, "sortrefupdatecb");
391 get( m_pMarkHdrCB, "markhdrcb");
392 get( m_pTextFmtCB, "textfmtcb");
393 get( m_pReplWarnCB, "replwarncb");
394 get( m_pLegacyCellSelectionCB, "legacy_cell_selection_cb");
396 SetExchangeSupport();
398 m_pUnitLB->SetSelectHdl( LINK( this, ScTpLayoutOptions, MetricHdl ) );
400 m_pAlignCB->SetClickHdl(LINK(this, ScTpLayoutOptions, AlignHdl));
402 for ( sal_uInt32 i = 0; i < aUnitArr.Count(); ++i )
404 OUString sMetric = aUnitArr.GetStringByPos( i );
405 FieldUnit eFUnit = (FieldUnit)aUnitArr.GetValue( i );
407 switch ( eFUnit )
409 case FUNIT_MM:
410 case FUNIT_CM:
411 case FUNIT_POINT:
412 case FUNIT_PICA:
413 case FUNIT_INCH:
415 // nur diese Metriken benutzen
416 sal_Int32 nPos = m_pUnitLB->InsertEntry( sMetric );
417 m_pUnitLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)eFUnit) );
419 break;
420 default:
422 // added to avoid warnings
429 ScTpLayoutOptions::~ScTpLayoutOptions()
431 disposeOnce();
434 void ScTpLayoutOptions::dispose()
436 m_pUnitLB.clear();
437 m_pTabMF.clear();
438 m_pAlwaysRB.clear();
439 m_pRequestRB.clear();
440 m_pNeverRB.clear();
441 m_pAlignCB.clear();
442 m_pAlignLB.clear();
443 m_pEditModeCB.clear();
444 m_pFormatCB.clear();
445 m_pExpRefCB.clear();
446 m_pSortRefUpdateCB.clear();
447 m_pMarkHdrCB.clear();
448 m_pTextFmtCB.clear();
449 m_pReplWarnCB.clear();
450 m_pLegacyCellSelectionCB.clear();
451 SfxTabPage::dispose();
455 VclPtr<SfxTabPage> ScTpLayoutOptions::Create( vcl::Window* pParent,
456 const SfxItemSet* rCoreSet )
458 VclPtrInstance<ScTpLayoutOptions> pNew( pParent, *rCoreSet );
459 ScDocShell* pDocSh = dynamic_cast< ScDocShell *>( SfxObjectShell::Current() );
461 if(pDocSh!=nullptr)
462 pNew->SetDocument(&pDocSh->GetDocument());
463 return pNew;
466 bool ScTpLayoutOptions::FillItemSet( SfxItemSet* rCoreSet )
468 bool bRet = true;
469 const sal_Int32 nMPos = m_pUnitLB->GetSelectEntryPos();
470 if ( m_pUnitLB->IsValueChangedFromSaved() )
472 sal_uInt16 nFieldUnit = (sal_uInt16)reinterpret_cast<sal_IntPtr>(m_pUnitLB->GetEntryData( nMPos ));
473 rCoreSet->Put( SfxUInt16Item( SID_ATTR_METRIC,
474 (sal_uInt16)nFieldUnit ) );
475 bRet = true;
478 if(m_pTabMF->IsValueChangedFromSaved())
480 rCoreSet->Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
481 sal::static_int_cast<sal_uInt16>( m_pTabMF->Denormalize(m_pTabMF->GetValue(FUNIT_TWIP)) )));
482 bRet = true;
485 ScLkUpdMode nSet=LM_ALWAYS;
487 if(m_pRequestRB->IsChecked())
489 nSet=LM_ON_DEMAND;
491 else if(m_pNeverRB->IsChecked())
493 nSet=LM_NEVER;
496 if(m_pRequestRB->IsValueChangedFromSaved() ||
497 m_pNeverRB->IsValueChangedFromSaved() )
499 if(pDoc)
500 pDoc->SetLinkMode(nSet);
501 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
502 aAppOptions.SetLinkMode(nSet );
503 SC_MOD()->SetAppOptions(aAppOptions);
504 bRet = true;
506 if(m_pAlignCB->IsValueChangedFromSaved())
508 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_SELECTION, m_pAlignCB->IsChecked()));
509 bRet = true;
512 if(m_pAlignLB->IsValueChangedFromSaved())
514 rCoreSet->Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, m_pAlignLB->GetSelectEntryPos()));
515 bRet = true;
518 if(m_pEditModeCB->IsValueChangedFromSaved())
520 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, m_pEditModeCB->IsChecked()));
521 bRet = true;
524 if(m_pFormatCB->IsValueChangedFromSaved())
526 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, m_pFormatCB->IsChecked()));
527 bRet = true;
530 if(m_pExpRefCB->IsValueChangedFromSaved())
532 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, m_pExpRefCB->IsChecked()));
533 bRet = true;
536 if (m_pSortRefUpdateCB->IsValueChangedFromSaved())
538 rCoreSet->Put(SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE, m_pSortRefUpdateCB->IsChecked()));
539 bRet = true;
542 if(m_pMarkHdrCB->IsValueChangedFromSaved())
544 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, m_pMarkHdrCB->IsChecked()));
545 bRet = true;
548 if(m_pTextFmtCB->IsValueChangedFromSaved())
550 rCoreSet->Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, m_pTextFmtCB->IsChecked()));
551 bRet = true;
554 if( m_pReplWarnCB->IsValueChangedFromSaved() )
556 rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, m_pReplWarnCB->IsChecked() ) );
557 bRet = true;
560 if( m_pLegacyCellSelectionCB->IsValueChangedFromSaved() )
562 rCoreSet->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION, m_pLegacyCellSelectionCB->IsChecked() ) );
563 bRet = true;
566 return bRet;
569 void ScTpLayoutOptions::Reset( const SfxItemSet* rCoreSet )
571 m_pUnitLB->SetNoSelection();
572 if ( rCoreSet->GetItemState( SID_ATTR_METRIC ) >= SfxItemState::DEFAULT )
574 const SfxUInt16Item& rItem = static_cast<const SfxUInt16Item&>(rCoreSet->Get( SID_ATTR_METRIC ));
575 FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
577 for ( sal_Int32 i = 0; i < m_pUnitLB->GetEntryCount(); ++i )
579 if ( (FieldUnit)reinterpret_cast<sal_IntPtr>(m_pUnitLB->GetEntryData( i )) == eFieldUnit )
581 m_pUnitLB->SelectEntryPos( i );
582 break;
585 ::SetFieldUnit(*m_pTabMF, eFieldUnit);
587 m_pUnitLB->SaveValue();
589 const SfxPoolItem* pItem;
590 if(SfxItemState::SET == rCoreSet->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
591 m_pTabMF->SetValue(m_pTabMF->Normalize(static_cast<const SfxUInt16Item*>(pItem)->GetValue()), FUNIT_TWIP);
592 m_pTabMF->SaveValue();
594 m_pUnitLB ->SaveValue();
595 m_pTabMF ->SaveValue();
597 ScLkUpdMode nSet=LM_UNKNOWN;
599 if(pDoc!=nullptr)
601 nSet=pDoc->GetLinkMode();
604 if(nSet==LM_UNKNOWN)
606 ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
607 nSet=aAppOptions.GetLinkMode();
610 switch(nSet)
612 case LM_ALWAYS: m_pAlwaysRB-> Check(); break;
613 case LM_NEVER: m_pNeverRB-> Check(); break;
614 case LM_ON_DEMAND: m_pRequestRB-> Check(); break;
615 default:
617 // added to avoid warnings
620 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_SELECTION, false, &pItem))
621 m_pAlignCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
623 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_SELECTIONPOS, false, &pItem))
624 m_pAlignLB->SelectEntryPos(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
626 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_EDITMODE, false, &pItem))
627 m_pEditModeCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
629 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_FMT_EXPAND, false, &pItem))
630 m_pFormatCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
632 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_REF_EXPAND, false, &pItem))
633 m_pExpRefCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
635 if (rCoreSet->HasItem(SID_SC_OPT_SORT_REF_UPDATE, &pItem))
636 m_pSortRefUpdateCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
638 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_MARK_HEADER, false, &pItem))
639 m_pMarkHdrCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
641 if(SfxItemState::SET == rCoreSet->GetItemState(SID_SC_INPUT_TEXTWYSIWYG, false, &pItem))
642 m_pTextFmtCB->Check(static_cast<const SfxBoolItem*>(pItem)->GetValue());
644 if( SfxItemState::SET == rCoreSet->GetItemState( SID_SC_INPUT_REPLCELLSWARN, false, &pItem ) )
645 m_pReplWarnCB->Check( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
647 if( SfxItemState::SET == rCoreSet->GetItemState( SID_SC_INPUT_LEGACY_CELL_SELECTION, false, &pItem ) )
648 m_pLegacyCellSelectionCB->Check( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
650 m_pAlignCB ->SaveValue();
651 m_pAlignLB ->SaveValue();
652 m_pEditModeCB ->SaveValue();
653 m_pFormatCB ->SaveValue();
655 m_pExpRefCB ->SaveValue();
656 m_pSortRefUpdateCB->SaveValue();
657 m_pMarkHdrCB ->SaveValue();
658 m_pTextFmtCB ->SaveValue();
659 m_pReplWarnCB ->SaveValue();
661 m_pLegacyCellSelectionCB->SaveValue();
663 AlignHdl(m_pAlignCB);
665 m_pAlwaysRB->SaveValue();
666 m_pNeverRB->SaveValue();
667 m_pRequestRB->SaveValue();
670 void ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ )
674 SfxTabPage::sfxpg ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP )
676 if(pSetP)
677 FillItemSet(pSetP);
678 return SfxTabPage::LEAVE_PAGE;
681 IMPL_LINK_NOARG_TYPED(ScTpLayoutOptions, MetricHdl, ListBox&, void)
683 const sal_Int32 nMPos = m_pUnitLB->GetSelectEntryPos();
684 if(nMPos != LISTBOX_ENTRY_NOTFOUND)
686 FieldUnit eFieldUnit = (FieldUnit)reinterpret_cast<sal_IntPtr>(m_pUnitLB->GetEntryData( nMPos ));
687 sal_Int64 nVal =
688 m_pTabMF->Denormalize( m_pTabMF->GetValue( FUNIT_TWIP ) );
689 ::SetFieldUnit( *m_pTabMF, eFieldUnit );
690 m_pTabMF->SetValue( m_pTabMF->Normalize( nVal ), FUNIT_TWIP );
694 IMPL_LINK_TYPED( ScTpLayoutOptions, AlignHdl, Button*, pBox, void )
696 m_pAlignLB->Enable(static_cast<CheckBox*>(pBox)->IsChecked());
699 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */