1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <officecfg/Office/Calc.hxx>
25 #include <viewopti.hxx>
26 #include <scresid.hxx>
29 #include <strings.hrc>
31 #include <appoptio.hxx>
33 #include <svl/eitem.hxx>
34 #include <svtools/unitconv.hxx>
35 #include <unotools/localedatawrapper.hxx>
37 ScTpContentOptions::ScTpContentOptions(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rArgSet
)
38 : SfxTabPage(pPage
, pController
, u
"modules/scalc/ui/tpviewpage.ui"_ustr
, u
"TpViewPage"_ustr
, &rArgSet
)
39 , m_xGridLB(m_xBuilder
->weld_combo_box(u
"grid"_ustr
))
40 , m_xGridImg(m_xBuilder
->weld_widget(u
"lockgrid"_ustr
))
41 , m_xBreakCB(m_xBuilder
->weld_check_button(u
"break"_ustr
))
42 , m_xBreakImg(m_xBuilder
->weld_widget(u
"lockbreak"_ustr
))
43 , m_xGuideLineCB(m_xBuilder
->weld_check_button(u
"guideline"_ustr
))
44 , m_xGuideLineImg(m_xBuilder
->weld_widget(u
"lockguideline"_ustr
))
45 , m_xFormulaCB(m_xBuilder
->weld_check_button(u
"formula"_ustr
))
46 , m_xFormulaImg(m_xBuilder
->weld_widget(u
"lockformula"_ustr
))
47 , m_xNilCB(m_xBuilder
->weld_check_button(u
"nil"_ustr
))
48 , m_xNilImg(m_xBuilder
->weld_widget(u
"locknil"_ustr
))
49 , m_xAnnotCB(m_xBuilder
->weld_check_button(u
"annot"_ustr
))
50 , m_xAnnotImg(m_xBuilder
->weld_widget(u
"lockannot"_ustr
))
51 , m_xNoteAuthorCB(m_xBuilder
->weld_check_button(u
"cbNoteAuthor"_ustr
))
52 , m_xNoteAuthorImg(m_xBuilder
->weld_widget(u
"imNoteAuthor"_ustr
))
53 , m_xFormulaMarkCB(m_xBuilder
->weld_check_button(u
"formulamark"_ustr
))
54 , m_xFormulaMarkImg(m_xBuilder
->weld_widget(u
"lockformulamark"_ustr
))
55 , m_xValueCB(m_xBuilder
->weld_check_button(u
"value"_ustr
))
56 , m_xValueImg(m_xBuilder
->weld_widget(u
"lockvalue"_ustr
))
57 , m_xColRowHighCB(m_xBuilder
->weld_check_button(u
"colrowhigh"_ustr
))
58 , m_xColRowHighImg(m_xBuilder
->weld_widget(u
"lockcolrowhigh"_ustr
))
59 , m_xEditCellBgHighCB(m_xBuilder
->weld_check_button(u
"editcellbg"_ustr
))
60 , m_xEditCellBgHighImg(m_xBuilder
->weld_widget(u
"lockeditcellbghigh"_ustr
))
61 , m_xAnchorCB(m_xBuilder
->weld_check_button(u
"anchor"_ustr
))
62 , m_xAnchorImg(m_xBuilder
->weld_widget(u
"lockanchor"_ustr
))
63 , m_xRangeFindCB(m_xBuilder
->weld_check_button(u
"rangefind"_ustr
))
64 , m_xRangeFindImg(m_xBuilder
->weld_widget(u
"lockrangefind"_ustr
))
65 , m_xObjGrfLB(m_xBuilder
->weld_combo_box(u
"objgrf"_ustr
))
66 , m_xObjGrfImg(m_xBuilder
->weld_widget(u
"lockobjgrf"_ustr
))
67 , m_xDiagramLB(m_xBuilder
->weld_combo_box(u
"diagram"_ustr
))
68 , m_xDiagramImg(m_xBuilder
->weld_widget(u
"lockdiagram"_ustr
))
69 , m_xDrawLB(m_xBuilder
->weld_combo_box(u
"draw"_ustr
))
70 , m_xDrawImg(m_xBuilder
->weld_widget(u
"lockdraw"_ustr
))
71 , m_xSyncZoomCB(m_xBuilder
->weld_check_button(u
"synczoom"_ustr
))
72 , m_xSyncZoomImg(m_xBuilder
->weld_widget(u
"locksynczoom"_ustr
))
73 , m_xRowColHeaderCB(m_xBuilder
->weld_check_button(u
"rowcolheader"_ustr
))
74 , m_xRowColHeaderImg(m_xBuilder
->weld_widget(u
"lockrowcolheader"_ustr
))
75 , m_xHScrollCB(m_xBuilder
->weld_check_button(u
"hscroll"_ustr
))
76 , m_xHScrollImg(m_xBuilder
->weld_widget(u
"lockhscroll"_ustr
))
77 , m_xVScrollCB(m_xBuilder
->weld_check_button(u
"vscroll"_ustr
))
78 , m_xVScrollImg(m_xBuilder
->weld_widget(u
"lockvscroll"_ustr
))
79 , m_xTblRegCB(m_xBuilder
->weld_check_button(u
"tblreg"_ustr
))
80 , m_xTblRegImg(m_xBuilder
->weld_widget(u
"locktblreg"_ustr
))
81 , m_xOutlineCB(m_xBuilder
->weld_check_button(u
"outline"_ustr
))
82 , m_xOutlineImg(m_xBuilder
->weld_widget(u
"lockoutline"_ustr
))
83 , m_xSummaryCB(m_xBuilder
->weld_check_button(u
"cbSummary"_ustr
))
84 , m_xSummaryImg(m_xBuilder
->weld_widget(u
"lockcbSummary"_ustr
))
85 , m_xThemedCursorRB(m_xBuilder
->weld_radio_button(u
"rbThemedCursor"_ustr
))
86 , m_xSystemCursorRB(m_xBuilder
->weld_radio_button(u
"rbSystemCursor"_ustr
))
87 , m_xCursorImg(m_xBuilder
->weld_widget(u
"lockCursor"_ustr
))
90 Link
<weld::ComboBox
&,void> aSelObjHdl(LINK( this, ScTpContentOptions
, SelLbObjHdl
) );
91 m_xObjGrfLB
->connect_changed(aSelObjHdl
);
92 m_xDiagramLB
->connect_changed(aSelObjHdl
);
93 m_xDrawLB
->connect_changed(aSelObjHdl
);
94 m_xGridLB
->connect_changed( LINK( this, ScTpContentOptions
, GridHdl
) );
96 Link
<weld::Toggleable
&, void> aCBHdl(LINK( this, ScTpContentOptions
, CBHdl
) );
97 m_xFormulaCB
->connect_toggled(aCBHdl
);
98 m_xNilCB
->connect_toggled(aCBHdl
);
99 m_xAnnotCB
->connect_toggled(aCBHdl
);
100 m_xAnnotCB
->set_accessible_description(ScResId(STR_A11Y_DESC_ANNOT
));
101 m_xNoteAuthorCB
->connect_toggled(aCBHdl
);
102 m_xFormulaMarkCB
->connect_toggled(aCBHdl
);
103 m_xValueCB
->connect_toggled(aCBHdl
);
104 m_xColRowHighCB
->connect_toggled(aCBHdl
);
105 m_xEditCellBgHighCB
->connect_toggled(aCBHdl
);
106 m_xAnchorCB
->connect_toggled(aCBHdl
);
108 m_xVScrollCB
->connect_toggled(aCBHdl
);
109 m_xHScrollCB
->connect_toggled(aCBHdl
);
110 m_xTblRegCB
->connect_toggled(aCBHdl
);
111 m_xOutlineCB
->connect_toggled(aCBHdl
);
112 m_xBreakCB
->connect_toggled(aCBHdl
);
113 m_xGuideLineCB
->connect_toggled(aCBHdl
);
114 m_xRowColHeaderCB
->connect_toggled(aCBHdl
);
115 m_xSummaryCB
->connect_toggled(aCBHdl
);
116 m_xThemedCursorRB
->connect_toggled(aCBHdl
);
119 ScTpContentOptions::~ScTpContentOptions()
123 std::unique_ptr
<SfxTabPage
> ScTpContentOptions::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
124 const SfxItemSet
* rCoreSet
)
126 return std::make_unique
<ScTpContentOptions
>(pPage
, pController
, *rCoreSet
);
129 OUString
ScTpContentOptions::GetAllStrings()
131 OUString sAllStrings
;
132 OUString labels
[] = { u
"label4"_ustr
, u
"label5"_ustr
, u
"label3"_ustr
, u
"label1"_ustr
, u
"grid_label"_ustr
,
133 u
"lbCursor"_ustr
, u
"label2"_ustr
, u
"objgrf_label"_ustr
, u
"diagram_label"_ustr
, u
"draw_label"_ustr
};
135 for (const auto& label
: labels
)
137 if (const auto pString
= m_xBuilder
->weld_label(label
))
138 sAllStrings
+= pString
->get_label() + " ";
141 OUString checkButton
[]
142 = { u
"formula"_ustr
, u
"nil"_ustr
, u
"annot"_ustr
, u
"formulamark"_ustr
, u
"value"_ustr
, u
"anchor"_ustr
,
143 u
"rangefind"_ustr
, u
"rowcolheader"_ustr
, u
"hscroll"_ustr
, u
"vscroll"_ustr
, u
"tblreg"_ustr
, u
"outline"_ustr
,
144 u
"cbSummary"_ustr
, u
"synczoom"_ustr
, u
"break"_ustr
, u
"guideline"_ustr
};
146 for (const auto& check
: checkButton
)
148 if (const auto pString
= m_xBuilder
->weld_check_button(check
))
149 sAllStrings
+= pString
->get_label() + " ";
152 return sAllStrings
.replaceAll("_", "");
155 bool ScTpContentOptions::FillItemSet( SfxItemSet
* rCoreSet
)
158 if( m_xFormulaCB
->get_state_changed_from_saved() ||
159 m_xNilCB
->get_state_changed_from_saved() ||
160 m_xAnnotCB
->get_state_changed_from_saved() ||
161 m_xNoteAuthorCB
->get_state_changed_from_saved() ||
162 m_xFormulaMarkCB
->get_state_changed_from_saved() ||
163 m_xValueCB
->get_state_changed_from_saved() ||
164 m_xAnchorCB
->get_state_changed_from_saved() ||
165 m_xObjGrfLB
->get_value_changed_from_saved() ||
166 m_xDiagramLB
->get_value_changed_from_saved() ||
167 m_xDrawLB
->get_value_changed_from_saved() ||
168 m_xGridLB
->get_value_changed_from_saved() ||
169 m_xRowColHeaderCB
->get_state_changed_from_saved() ||
170 m_xHScrollCB
->get_state_changed_from_saved() ||
171 m_xVScrollCB
->get_state_changed_from_saved() ||
172 m_xTblRegCB
->get_state_changed_from_saved() ||
173 m_xOutlineCB
->get_state_changed_from_saved() ||
174 m_xBreakCB
->get_state_changed_from_saved() ||
175 m_xSummaryCB
->get_state_changed_from_saved() ||
176 m_xThemedCursorRB
->get_state_changed_from_saved() ||
177 m_xGuideLineCB
->get_state_changed_from_saved())
179 rCoreSet
->Put(ScTpViewItem(*m_xLocalOptions
));
182 if(m_xRangeFindCB
->get_state_changed_from_saved())
184 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER
, m_xRangeFindCB
->get_active()));
187 if(m_xSyncZoomCB
->get_state_changed_from_saved())
189 rCoreSet
->Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM
, m_xSyncZoomCB
->get_active()));
192 if (m_xColRowHighCB
->get_state_changed_from_saved())
194 auto pChange(comphelper::ConfigurationChanges::create());
195 officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::set(m_xColRowHighCB
->get_active(), pChange
);
199 if (m_xEditCellBgHighCB
->get_state_changed_from_saved())
201 auto pChange(comphelper::ConfigurationChanges::create());
202 officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::set(m_xEditCellBgHighCB
->get_active(), pChange
);
210 void ScTpContentOptions::Reset( const SfxItemSet
* rCoreSet
)
212 if(const ScTpViewItem
* pViewItem
= rCoreSet
->GetItemIfSet(SID_SCVIEWOPTIONS
, false))
213 m_xLocalOptions
.reset( new ScViewOptions( pViewItem
->GetViewOptions() ) );
215 m_xLocalOptions
.reset( new ScViewOptions
);
216 m_xFormulaCB
->set_active(m_xLocalOptions
->GetOption(VOPT_FORMULAS
));
217 m_xNilCB
->set_active(m_xLocalOptions
->GetOption(VOPT_NULLVALS
));
218 m_xAnnotCB
->set_active(m_xLocalOptions
->GetOption(VOPT_NOTES
));
219 m_xNoteAuthorCB
->set_active(m_xLocalOptions
->GetOption(VOPT_NOTEAUTHOR
));
220 m_xFormulaMarkCB
->set_active(m_xLocalOptions
->GetOption(VOPT_FORMULAS_MARKS
));
221 m_xValueCB
->set_active(m_xLocalOptions
->GetOption(VOPT_SYNTAX
));
222 m_xColRowHighCB
->set_active(officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::get());
223 m_xEditCellBgHighCB
->set_active(officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::get());
224 m_xAnchorCB
->set_active(m_xLocalOptions
->GetOption(VOPT_ANCHOR
));
226 m_xObjGrfLB
->set_active( static_cast<sal_uInt16
>(m_xLocalOptions
->GetObjMode(VOBJ_TYPE_OLE
)) );
227 m_xDiagramLB
->set_active( static_cast<sal_uInt16
>(m_xLocalOptions
->GetObjMode(VOBJ_TYPE_CHART
)) );
228 m_xDrawLB
->set_active( static_cast<sal_uInt16
>(m_xLocalOptions
->GetObjMode(VOBJ_TYPE_DRAW
)) );
230 m_xRowColHeaderCB
->set_active( m_xLocalOptions
->GetOption(VOPT_HEADER
) );
231 m_xHScrollCB
->set_active( m_xLocalOptions
->GetOption(VOPT_HSCROLL
) );
232 m_xVScrollCB
->set_active( m_xLocalOptions
->GetOption(VOPT_VSCROLL
) );
233 m_xTblRegCB
->set_active( m_xLocalOptions
->GetOption(VOPT_TABCONTROLS
) );
234 m_xOutlineCB
->set_active( m_xLocalOptions
->GetOption(VOPT_OUTLINER
) );
235 m_xSummaryCB
->set_active( m_xLocalOptions
->GetOption(VOPT_SUMMARY
) );
236 if ( m_xLocalOptions
->GetOption(VOPT_THEMEDCURSOR
) )
237 m_xThemedCursorRB
->set_active( true );
239 m_xSystemCursorRB
->set_active( true );
243 m_xBreakCB
->set_active( m_xLocalOptions
->GetOption(VOPT_PAGEBREAKS
) );
244 m_xGuideLineCB
->set_active( m_xLocalOptions
->GetOption(VOPT_HELPLINES
) );
246 if(const SfxBoolItem
* pFinderItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_RANGEFINDER
, false))
247 m_xRangeFindCB
->set_active(pFinderItem
->GetValue());
248 if(const SfxBoolItem
* pZoomItem
= rCoreSet
->GetItemIfSet(SID_SC_OPT_SYNCZOOM
, false))
249 m_xSyncZoomCB
->set_active(pZoomItem
->GetValue());
251 bool bReadOnly
= officecfg::Office::Calc::Layout::Line::GridLine::isReadOnly() ||
252 officecfg::Office::Calc::Layout::Line::GridOnColoredCells::isReadOnly();
253 m_xGridLB
->set_sensitive(!bReadOnly
);
254 m_xGridImg
->set_visible(bReadOnly
);
256 bReadOnly
= officecfg::Office::Calc::Layout::Line::PageBreak::isReadOnly();
257 m_xBreakCB
->set_sensitive(!bReadOnly
);
258 m_xBreakImg
->set_visible(bReadOnly
);
260 bReadOnly
= officecfg::Office::Calc::Layout::Line::Guide::isReadOnly();
261 m_xGuideLineCB
->set_sensitive(!bReadOnly
);
262 m_xGuideLineImg
->set_visible(bReadOnly
);
264 bReadOnly
= officecfg::Office::Calc::Content::Display::Formula::isReadOnly();
265 m_xFormulaCB
->set_sensitive(!bReadOnly
);
266 m_xFormulaImg
->set_visible(bReadOnly
);
268 bReadOnly
= officecfg::Office::Calc::Content::Display::ZeroValue::isReadOnly();
269 m_xNilCB
->set_sensitive(!bReadOnly
);
270 m_xNilImg
->set_visible(bReadOnly
);
272 bReadOnly
= officecfg::Office::Calc::Content::Display::NoteTag::isReadOnly();
273 m_xAnnotCB
->set_sensitive(!bReadOnly
);
274 m_xAnnotImg
->set_visible(bReadOnly
);
276 bReadOnly
= officecfg::Office::Calc::Content::Display::NoteAuthor::isReadOnly();
277 m_xNoteAuthorCB
->set_sensitive(!bReadOnly
);
278 m_xNoteAuthorImg
->set_visible(bReadOnly
);
280 bReadOnly
= officecfg::Office::Calc::Content::Display::FormulaMark::isReadOnly();
281 m_xFormulaMarkCB
->set_sensitive(!bReadOnly
);
282 m_xFormulaMarkImg
->set_visible(bReadOnly
);
284 bReadOnly
= officecfg::Office::Calc::Content::Display::ValueHighlighting::isReadOnly();
285 m_xValueCB
->set_sensitive(!bReadOnly
);
286 m_xValueImg
->set_visible(bReadOnly
);
288 bReadOnly
= officecfg::Office::Calc::Content::Display::ColumnRowHighlighting::isReadOnly();
289 m_xColRowHighCB
->set_sensitive(!bReadOnly
);
290 m_xColRowHighImg
->set_visible(bReadOnly
);
292 bReadOnly
= officecfg::Office::Calc::Content::Display::EditCellBackgroundHighlighting::isReadOnly();
293 m_xEditCellBgHighCB
->set_sensitive(!bReadOnly
);
294 m_xEditCellBgHighImg
->set_visible(bReadOnly
);
296 bReadOnly
= officecfg::Office::Calc::Content::Display::Anchor::isReadOnly();
297 m_xAnchorCB
->set_sensitive(!bReadOnly
);
298 m_xAnchorImg
->set_visible(bReadOnly
);
300 bReadOnly
= officecfg::Office::Calc::Input::ShowReference::isReadOnly();
301 m_xRangeFindCB
->set_sensitive(!bReadOnly
);
302 m_xRangeFindImg
->set_visible(bReadOnly
);
304 bReadOnly
= officecfg::Office::Calc::Content::Display::ObjectGraphic::isReadOnly();
305 m_xObjGrfLB
->set_sensitive(!bReadOnly
);
306 m_xObjGrfImg
->set_visible(bReadOnly
);
308 bReadOnly
= officecfg::Office::Calc::Content::Display::Chart::isReadOnly();
309 m_xDiagramLB
->set_sensitive(!bReadOnly
);
310 m_xDiagramImg
->set_visible(bReadOnly
);
312 bReadOnly
= officecfg::Office::Calc::Content::Display::DrawingObject::isReadOnly();
313 m_xDrawLB
->set_sensitive(!bReadOnly
);
314 m_xDrawImg
->set_visible(bReadOnly
);
316 bReadOnly
= officecfg::Office::Calc::Layout::Zoom::Synchronize::isReadOnly();
317 m_xSyncZoomCB
->set_sensitive(!bReadOnly
);
318 m_xSyncZoomImg
->set_visible(bReadOnly
);
320 bReadOnly
= officecfg::Office::Calc::Layout::Window::ColumnRowHeader::isReadOnly();
321 m_xRowColHeaderCB
->set_sensitive(!bReadOnly
);
322 m_xRowColHeaderImg
->set_visible(bReadOnly
);
324 bReadOnly
= officecfg::Office::Calc::Layout::Window::HorizontalScroll::isReadOnly();
325 m_xHScrollCB
->set_sensitive(!bReadOnly
);
326 m_xHScrollImg
->set_visible(bReadOnly
);
328 bReadOnly
= officecfg::Office::Calc::Layout::Window::VerticalScroll::isReadOnly();
329 m_xVScrollCB
->set_sensitive(!bReadOnly
);
330 m_xVScrollImg
->set_visible(bReadOnly
);
332 bReadOnly
= officecfg::Office::Calc::Layout::Window::SheetTab::isReadOnly();
333 m_xTblRegCB
->set_sensitive(!bReadOnly
);
334 m_xTblRegImg
->set_visible(bReadOnly
);
336 bReadOnly
= officecfg::Office::Calc::Layout::Window::OutlineSymbol::isReadOnly();
337 m_xOutlineCB
->set_sensitive(!bReadOnly
);
338 m_xOutlineImg
->set_visible(bReadOnly
);
340 bReadOnly
= officecfg::Office::Calc::Layout::Window::SearchSummary::isReadOnly();
341 m_xSummaryCB
->set_sensitive(!bReadOnly
);
342 m_xSummaryImg
->set_visible(bReadOnly
);
344 bReadOnly
= officecfg::Office::Calc::Layout::Window::ThemedCursor::isReadOnly();
345 m_xThemedCursorRB
->set_sensitive(!bReadOnly
);
346 m_xSystemCursorRB
->set_sensitive(!bReadOnly
);
347 m_xCursorImg
->set_visible(bReadOnly
);
349 m_xRangeFindCB
->save_state();
350 m_xSyncZoomCB
->save_state();
352 m_xFormulaCB
->save_state();
353 m_xNilCB
->save_state();
354 m_xAnnotCB
->save_state();
355 m_xNoteAuthorCB
->save_state();
356 m_xFormulaMarkCB
->save_state();
357 m_xValueCB
->save_state();
358 m_xColRowHighCB
->save_state();
359 m_xEditCellBgHighCB
->save_state();
360 m_xAnchorCB
->save_state();
361 m_xObjGrfLB
->save_value();
362 m_xDiagramLB
->save_value();
363 m_xDrawLB
->save_value();
364 m_xRowColHeaderCB
->save_state();
365 m_xHScrollCB
->save_state();
366 m_xVScrollCB
->save_state();
367 m_xTblRegCB
->save_state();
368 m_xOutlineCB
->save_state();
369 m_xGridLB
->save_value();
370 m_xBreakCB
->save_state();
371 m_xGuideLineCB
->save_state();
372 m_xSummaryCB
->save_state();
373 m_xThemedCursorRB
->save_state();
376 void ScTpContentOptions::ActivatePage( const SfxItemSet
& rSet
)
378 if(const ScTpViewItem
* pViewItem
= rSet
.GetItemIfSet(SID_SCVIEWOPTIONS
, false))
379 *m_xLocalOptions
= pViewItem
->GetViewOptions();
382 DeactivateRC
ScTpContentOptions::DeactivatePage( SfxItemSet
* pSetP
)
386 return DeactivateRC::LeavePage
;
389 IMPL_LINK( ScTpContentOptions
, SelLbObjHdl
, weld::ComboBox
&, rLb
, void )
391 const sal_Int32 nSelPos
= rLb
.get_active();
392 ScVObjMode eMode
= ScVObjMode(nSelPos
);
393 ScVObjType eType
= VOBJ_TYPE_OLE
;
395 if ( &rLb
== m_xDiagramLB
.get() )
396 eType
= VOBJ_TYPE_CHART
;
397 else if ( &rLb
== m_xDrawLB
.get() )
398 eType
= VOBJ_TYPE_DRAW
;
400 m_xLocalOptions
->SetObjMode( eType
, eMode
);
403 IMPL_LINK( ScTpContentOptions
, CBHdl
, weld::Toggleable
&, rBtn
, void )
405 ScViewOption eOption
= VOPT_FORMULAS
;
406 bool bChecked
= rBtn
.get_active();
408 if (m_xFormulaCB
.get() == &rBtn
) eOption
= VOPT_FORMULAS
;
409 else if ( m_xNilCB
.get() == &rBtn
) eOption
= VOPT_NULLVALS
;
410 else if ( m_xAnnotCB
.get() == &rBtn
) eOption
= VOPT_NOTES
;
411 else if ( m_xNoteAuthorCB
.get() == &rBtn
) eOption
= VOPT_NOTEAUTHOR
;
412 else if ( m_xFormulaMarkCB
.get() == &rBtn
) eOption
= VOPT_FORMULAS_MARKS
;
413 else if ( m_xValueCB
.get() == &rBtn
) eOption
= VOPT_SYNTAX
;
414 else if ( m_xAnchorCB
.get() == &rBtn
) eOption
= VOPT_ANCHOR
;
415 else if ( m_xVScrollCB
.get() == &rBtn
) eOption
= VOPT_VSCROLL
;
416 else if ( m_xHScrollCB
.get() == &rBtn
) eOption
= VOPT_HSCROLL
;
417 else if ( m_xTblRegCB
.get() == &rBtn
) eOption
= VOPT_TABCONTROLS
;
418 else if ( m_xOutlineCB
.get() == &rBtn
) eOption
= VOPT_OUTLINER
;
419 else if ( m_xBreakCB
.get() == &rBtn
) eOption
= VOPT_PAGEBREAKS
;
420 else if ( m_xGuideLineCB
.get() == &rBtn
) eOption
= VOPT_HELPLINES
;
421 else if ( m_xRowColHeaderCB
.get() == &rBtn
) eOption
= VOPT_HEADER
;
422 else if ( m_xSummaryCB
.get() == &rBtn
) eOption
= VOPT_SUMMARY
;
423 else if ( m_xThemedCursorRB
.get() == &rBtn
) eOption
= VOPT_THEMEDCURSOR
;
425 m_xLocalOptions
->SetOption( eOption
, bChecked
);
428 void ScTpContentOptions::InitGridOpt()
430 bool bGrid
= m_xLocalOptions
->GetOption( VOPT_GRID
);
431 bool bGridOnTop
= m_xLocalOptions
->GetOption( VOPT_GRID_ONTOP
);
432 sal_Int32 nSelPos
= 0;
434 if ( bGrid
|| bGridOnTop
)
444 m_xGridLB
->set_active (nSelPos
);
447 IMPL_LINK( ScTpContentOptions
, GridHdl
, weld::ComboBox
&, rLb
, void )
449 sal_Int32 nSelPos
= rLb
.get_active();
450 bool bGrid
= ( nSelPos
<= 1 );
451 bool bGridOnTop
= ( nSelPos
== 1 );
453 m_xLocalOptions
->SetOption( VOPT_GRID
, bGrid
);
454 m_xLocalOptions
->SetOption( VOPT_GRID_ONTOP
, bGridOnTop
);
457 ScTpLayoutOptions::ScTpLayoutOptions(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& rArgSet
)
458 : SfxTabPage(pPage
, pController
, u
"modules/scalc/ui/scgeneralpage.ui"_ustr
, u
"ScGeneralPage"_ustr
, &rArgSet
)
460 , m_xUnitLB(m_xBuilder
->weld_combo_box(u
"unitlb"_ustr
))
461 , m_xUnitImg(m_xBuilder
->weld_widget(u
"lockunitlb"_ustr
))
462 , m_xTabMF(m_xBuilder
->weld_metric_spin_button(u
"tabmf"_ustr
, FieldUnit::CM
))
463 , m_xTabImg(m_xBuilder
->weld_widget(u
"locktabmf"_ustr
))
464 , m_xAlwaysRB(m_xBuilder
->weld_radio_button(u
"alwaysrb"_ustr
))
465 , m_xRequestRB(m_xBuilder
->weld_radio_button(u
"requestrb"_ustr
))
466 , m_xNeverRB(m_xBuilder
->weld_radio_button(u
"neverrb"_ustr
))
467 , m_xUpdateLinksImg(m_xBuilder
->weld_widget(u
"lockupdatelinks"_ustr
))
468 , m_xAlignCB(m_xBuilder
->weld_check_button(u
"aligncb"_ustr
))
469 , m_xAlignImg(m_xBuilder
->weld_widget(u
"lockaligncb"_ustr
))
470 , m_xAlignLB(m_xBuilder
->weld_combo_box(u
"alignlb"_ustr
))
471 , m_xEditModeCB(m_xBuilder
->weld_check_button(u
"editmodecb"_ustr
))
472 , m_xEditModeImg(m_xBuilder
->weld_widget(u
"lockeditmodecb"_ustr
))
473 , m_xFormatCB(m_xBuilder
->weld_check_button(u
"formatcb"_ustr
))
474 , m_xFormatImg(m_xBuilder
->weld_widget(u
"lockformatcb"_ustr
))
475 , m_xExpRefCB(m_xBuilder
->weld_check_button(u
"exprefcb"_ustr
))
476 , m_xExpRefImg(m_xBuilder
->weld_widget(u
"lockexprefcb"_ustr
))
477 , m_xSortRefUpdateCB(m_xBuilder
->weld_check_button(u
"sortrefupdatecb"_ustr
))
478 , m_xSortRefUpdateImg(m_xBuilder
->weld_widget(u
"locksortrefupdatecb"_ustr
))
479 , m_xMarkHdrCB(m_xBuilder
->weld_check_button(u
"markhdrcb"_ustr
))
480 , m_xMarkHdrImg(m_xBuilder
->weld_widget(u
"lockmarkhdrcb"_ustr
))
481 , m_xReplWarnCB(m_xBuilder
->weld_check_button(u
"replwarncb"_ustr
))
482 , m_xReplWarnImg(m_xBuilder
->weld_widget(u
"lockreplwarncb"_ustr
))
483 , m_xLegacyCellSelectionCB(m_xBuilder
->weld_check_button(u
"legacy_cell_selection_cb"_ustr
))
484 , m_xLegacyCellSelectionImg(m_xBuilder
->weld_widget(u
"locklegacy_cell"_ustr
))
485 , m_xEnterPasteModeCB(m_xBuilder
->weld_check_button(u
"enter_paste_mode_cb"_ustr
))
486 , m_xEnterPasteModeImg(m_xBuilder
->weld_widget(u
"lockenter_paste"_ustr
))
487 , m_xWarnActiveSheetCB(m_xBuilder
->weld_check_button(u
"warnactivesheet_cb"_ustr
))
488 , m_xWarnActiveSheetImg(m_xBuilder
->weld_widget(u
"lockwarnactivesheet"_ustr
))
490 SetExchangeSupport();
492 m_xUnitLB
->connect_changed( LINK( this, ScTpLayoutOptions
, MetricHdl
) );
493 m_xAlignCB
->connect_toggled(LINK(this, ScTpLayoutOptions
, AlignHdl
));
495 for (size_t i
= 0; i
< SAL_N_ELEMENTS(SCSTR_UNIT
); ++i
)
497 OUString sMetric
= ScResId(SCSTR_UNIT
[i
].first
);
498 FieldUnit eFUnit
= SCSTR_UNIT
[i
].second
;
504 case FieldUnit::POINT
:
505 case FieldUnit::PICA
:
506 case FieldUnit::INCH
:
508 // only use these metrics
509 m_xUnitLB
->append(OUString::number(static_cast<sal_uInt32
>(eFUnit
)), sMetric
);
514 // added to avoid warnings
520 ScTpLayoutOptions::~ScTpLayoutOptions()
524 std::unique_ptr
<SfxTabPage
> ScTpLayoutOptions::Create( weld::Container
* pPage
, weld::DialogController
* pController
,
525 const SfxItemSet
* rCoreSet
)
527 auto xNew
= std::make_unique
<ScTpLayoutOptions
>(pPage
, pController
, *rCoreSet
);
529 ScDocShell
* pDocSh
= dynamic_cast< ScDocShell
*>( SfxObjectShell::Current() );
531 xNew
->pDoc
= &pDocSh
->GetDocument();
535 OUString
ScTpLayoutOptions::GetAllStrings()
537 OUString sAllStrings
;
538 OUString labels
[] = { u
"label1"_ustr
, u
"label4"_ustr
, u
"label5"_ustr
, u
"label6"_ustr
, u
"label3"_ustr
};
540 for (const auto& label
: labels
)
542 if (const auto pString
= m_xBuilder
->weld_label(label
))
543 sAllStrings
+= pString
->get_label() + " ";
546 OUString checkButton
[] = { u
"aligncb"_ustr
, u
"editmodecb"_ustr
, u
"enter_paste_mode_cb"_ustr
,
547 u
"formatcb"_ustr
, u
"exprefcb"_ustr
, u
"sortrefupdatecb"_ustr
,
548 u
"markhdrcb"_ustr
, u
"replwarncb"_ustr
, u
"legacy_cell_selection_cb"_ustr
,
549 u
"warnactivesheet_cb"_ustr
};
551 for (const auto& check
: checkButton
)
553 if (const auto pString
= m_xBuilder
->weld_check_button(check
))
554 sAllStrings
+= pString
->get_label() + " ";
557 OUString radioButton
[] = { u
"alwaysrb"_ustr
, u
"requestrb"_ustr
, u
"neverrb"_ustr
};
559 for (const auto& radio
: radioButton
)
561 if (const auto pString
= m_xBuilder
->weld_radio_button(radio
))
562 sAllStrings
+= pString
->get_label() + " ";
565 return sAllStrings
.replaceAll("_", "");
568 bool ScTpLayoutOptions::FillItemSet( SfxItemSet
* rCoreSet
)
571 if (m_xUnitLB
->get_value_changed_from_saved())
573 const sal_Int32 nMPos
= m_xUnitLB
->get_active();
574 sal_uInt16 nFieldUnit
= m_xUnitLB
->get_id(nMPos
).toUInt32();
575 rCoreSet
->Put( SfxUInt16Item( SID_ATTR_METRIC
, nFieldUnit
) );
579 if (m_xTabMF
->get_value_changed_from_saved())
581 rCoreSet
->Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP
,
582 sal::static_int_cast
<sal_uInt16
>( m_xTabMF
->denormalize(m_xTabMF
->get_value(FieldUnit::TWIP
)) )));
586 ScLkUpdMode nSet
=LM_ALWAYS
;
588 if (m_xRequestRB
->get_active())
592 else if (m_xNeverRB
->get_active())
597 if (m_xRequestRB
->get_state_changed_from_saved() ||
598 m_xNeverRB
->get_state_changed_from_saved() )
601 pDoc
->SetLinkMode(nSet
);
602 ScModule
* mod
= ScModule::get();
603 ScAppOptions aAppOptions
= mod
->GetAppOptions();
604 aAppOptions
.SetLinkMode(nSet
);
605 mod
->SetAppOptions(aAppOptions
);
608 if (m_xAlignCB
->get_state_changed_from_saved())
610 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_SELECTION
, m_xAlignCB
->get_active()));
614 if (m_xAlignLB
->get_value_changed_from_saved())
616 rCoreSet
->Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS
, m_xAlignLB
->get_active()));
620 if (m_xEditModeCB
->get_state_changed_from_saved())
622 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_EDITMODE
, m_xEditModeCB
->get_active()));
626 if (m_xFormatCB
->get_state_changed_from_saved())
628 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND
, m_xFormatCB
->get_active()));
632 if (m_xExpRefCB
->get_state_changed_from_saved())
634 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND
, m_xExpRefCB
->get_active()));
638 if (m_xSortRefUpdateCB
->get_state_changed_from_saved())
640 rCoreSet
->Put(SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE
, m_xSortRefUpdateCB
->get_active()));
644 if (m_xMarkHdrCB
->get_state_changed_from_saved())
646 rCoreSet
->Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER
, m_xMarkHdrCB
->get_active()));
650 if (m_xReplWarnCB
->get_state_changed_from_saved())
652 rCoreSet
->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN
, m_xReplWarnCB
->get_active() ) );
656 if (m_xLegacyCellSelectionCB
->get_state_changed_from_saved())
658 rCoreSet
->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION
, m_xLegacyCellSelectionCB
->get_active() ) );
662 if (m_xEnterPasteModeCB
->get_state_changed_from_saved())
664 rCoreSet
->Put( SfxBoolItem( SID_SC_INPUT_ENTER_PASTE_MODE
, m_xEnterPasteModeCB
->get_active() ) );
668 if (m_xWarnActiveSheetCB
->get_state_changed_from_saved())
670 rCoreSet
->Put( SfxBoolItem( SID_SC_INPUT_WARNACTIVESHEET
, m_xWarnActiveSheetCB
->get_active() ) );
677 void ScTpLayoutOptions::Reset( const SfxItemSet
* rCoreSet
)
679 m_xUnitLB
->set_active(-1);
680 if ( rCoreSet
->GetItemState( SID_ATTR_METRIC
) >= SfxItemState::DEFAULT
)
682 const SfxUInt16Item
& rItem
= rCoreSet
->Get( SID_ATTR_METRIC
);
683 FieldUnit eFieldUnit
= static_cast<FieldUnit
>(rItem
.GetValue());
685 for (sal_Int32 i
= 0, nEntryCount
= m_xUnitLB
->get_count(); i
< nEntryCount
; ++i
)
687 if (m_xUnitLB
->get_id(i
).toUInt32() == static_cast<sal_uInt32
>(eFieldUnit
))
689 m_xUnitLB
->set_active(i
);
693 ::SetFieldUnit(*m_xTabMF
, eFieldUnit
);
696 bool bReadOnly
= false;
697 MeasurementSystem eSys
= ScGlobal::getLocaleData().getMeasurementSystemEnum();
698 if (eSys
== MeasurementSystem::Metric
)
700 bReadOnly
= officecfg::Office::Calc::Layout::Other::MeasureUnit::Metric::isReadOnly();
704 bReadOnly
= officecfg::Office::Calc::Layout::Other::MeasureUnit::NonMetric::isReadOnly();
706 m_xUnitLB
->set_sensitive(!bReadOnly
);
707 m_xUnitImg
->set_visible(bReadOnly
);
709 if(const SfxUInt16Item
* pTabStopItem
= rCoreSet
->GetItemIfSet(SID_ATTR_DEFTABSTOP
, false))
710 m_xTabMF
->set_value(m_xTabMF
->normalize(pTabStopItem
->GetValue()), FieldUnit::TWIP
);
712 if (eSys
== MeasurementSystem::Metric
)
714 bReadOnly
= officecfg::Office::Calc::Layout::Other::TabStop::Metric::isReadOnly();
718 bReadOnly
= officecfg::Office::Calc::Layout::Other::TabStop::NonMetric::isReadOnly();
720 m_xTabMF
->set_sensitive(!bReadOnly
);
721 m_xTabImg
->set_visible(bReadOnly
);
723 m_xUnitLB
->save_value();
724 m_xTabMF
->save_value();
726 ScLkUpdMode nSet
=LM_UNKNOWN
;
730 nSet
=pDoc
->GetLinkMode();
735 ScAppOptions aAppOptions
= ScModule::get()->GetAppOptions();
736 nSet
=aAppOptions
.GetLinkMode();
741 case LM_ALWAYS
: m_xAlwaysRB
->set_active(true); break;
742 case LM_NEVER
: m_xNeverRB
->set_active(true); break;
743 case LM_ON_DEMAND
: m_xRequestRB
->set_active(true); break;
746 // added to avoid warnings
750 if (officecfg::Office::Calc::Content::Update::Link::isReadOnly())
752 m_xAlwaysRB
->set_sensitive(false);
753 m_xNeverRB
->set_sensitive(false);
754 m_xRequestRB
->set_sensitive(false);
755 m_xUpdateLinksImg
->set_visible(true);
757 if(const SfxBoolItem
* pSelectionItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_SELECTION
, false))
758 m_xAlignCB
->set_active(pSelectionItem
->GetValue());
760 bReadOnly
= officecfg::Office::Calc::Input::MoveSelection::isReadOnly();
761 m_xAlignCB
->set_sensitive(!bReadOnly
);
762 m_xAlignImg
->set_visible(bReadOnly
);
764 if(const SfxUInt16Item
* pPosItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_SELECTIONPOS
, false))
765 m_xAlignLB
->set_active(pPosItem
->GetValue());
767 bReadOnly
= officecfg::Office::Calc::Input::MoveSelectionDirection::isReadOnly();
768 m_xAlignCB
->set_sensitive(!bReadOnly
);
770 if(const SfxBoolItem
* pEditModeItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_EDITMODE
, false))
771 m_xEditModeCB
->set_active(pEditModeItem
->GetValue());
773 bReadOnly
= officecfg::Office::Calc::Input::SwitchToEditMode::isReadOnly();
774 m_xEditModeCB
->set_sensitive(!bReadOnly
);
775 m_xEditModeImg
->set_visible(bReadOnly
);
777 if(const SfxBoolItem
* pExpandItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_FMT_EXPAND
, false))
778 m_xFormatCB
->set_active(pExpandItem
->GetValue());
780 bReadOnly
= officecfg::Office::Calc::Input::ExpandFormatting::isReadOnly();
781 m_xFormatCB
->set_sensitive(!bReadOnly
);
782 m_xFormatImg
->set_visible(bReadOnly
);
784 if(const SfxBoolItem
* pExpandItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_REF_EXPAND
, false))
785 m_xExpRefCB
->set_active(pExpandItem
->GetValue());
787 bReadOnly
= officecfg::Office::Calc::Input::ExpandReference::isReadOnly();
788 m_xExpRefCB
->set_sensitive(!bReadOnly
);
789 m_xExpRefImg
->set_visible(bReadOnly
);
791 if (const SfxBoolItem
* pUpdateItem
= rCoreSet
->GetItemIfSet(SID_SC_OPT_SORT_REF_UPDATE
))
792 m_xSortRefUpdateCB
->set_active(pUpdateItem
->GetValue());
794 bReadOnly
= officecfg::Office::Calc::Input::UpdateReferenceOnSort::isReadOnly();
795 m_xSortRefUpdateCB
->set_sensitive(!bReadOnly
);
796 m_xSortRefUpdateImg
->set_visible(bReadOnly
);
798 if(const SfxBoolItem
* pHeaderItem
= rCoreSet
->GetItemIfSet(SID_SC_INPUT_MARK_HEADER
, false))
799 m_xMarkHdrCB
->set_active(pHeaderItem
->GetValue());
801 bReadOnly
= officecfg::Office::Calc::Input::HighlightSelection::isReadOnly();
802 m_xMarkHdrCB
->set_sensitive(!bReadOnly
);
803 m_xMarkHdrImg
->set_visible(bReadOnly
);
805 if( const SfxBoolItem
* pWarnItem
= rCoreSet
->GetItemIfSet( SID_SC_INPUT_REPLCELLSWARN
, false ) )
806 m_xReplWarnCB
->set_active( pWarnItem
->GetValue() );
808 bReadOnly
= officecfg::Office::Calc::Input::ReplaceCellsWarning::isReadOnly();
809 m_xReplWarnCB
->set_sensitive(!bReadOnly
);
810 m_xReplWarnImg
->set_visible(bReadOnly
);
812 if( const SfxBoolItem
* pSelectionItem
= rCoreSet
->GetItemIfSet( SID_SC_INPUT_LEGACY_CELL_SELECTION
, false ) )
813 m_xLegacyCellSelectionCB
->set_active( pSelectionItem
->GetValue() );
815 bReadOnly
= officecfg::Office::Calc::Input::LegacyCellSelection::isReadOnly();
816 m_xLegacyCellSelectionCB
->set_sensitive(!bReadOnly
);
817 m_xLegacyCellSelectionImg
->set_visible(bReadOnly
);
819 if( const SfxBoolItem
* pPasteModeItem
= rCoreSet
->GetItemIfSet( SID_SC_INPUT_ENTER_PASTE_MODE
, false ) )
820 m_xEnterPasteModeCB
->set_active( pPasteModeItem
->GetValue() );
822 bReadOnly
= officecfg::Office::Calc::Input::EnterPasteMode::isReadOnly();
823 m_xEnterPasteModeCB
->set_sensitive(!bReadOnly
);
824 m_xEnterPasteModeImg
->set_visible(bReadOnly
);
826 if( const SfxBoolItem
* pWarnActiveSheetItem
= rCoreSet
->GetItemIfSet( SID_SC_INPUT_WARNACTIVESHEET
, false ) )
827 m_xWarnActiveSheetCB
->set_active( pWarnActiveSheetItem
->GetValue() );
829 bReadOnly
= officecfg::Office::Calc::Input::WarnActiveSheet::isReadOnly();
830 m_xWarnActiveSheetCB
->set_sensitive(!bReadOnly
);
831 m_xWarnActiveSheetImg
->set_visible(bReadOnly
);
833 m_xAlignCB
->save_state();
834 m_xAlignLB
->save_value();
835 m_xEditModeCB
->save_state();
836 m_xFormatCB
->save_state();
838 m_xExpRefCB
->save_state();
839 m_xSortRefUpdateCB
->save_state();
840 m_xMarkHdrCB
->save_state();
841 m_xReplWarnCB
->save_state();
843 m_xLegacyCellSelectionCB
->save_state();
844 m_xEnterPasteModeCB
->save_state();
845 m_xWarnActiveSheetCB
->save_state();
847 AlignHdl(*m_xAlignCB
);
849 m_xAlwaysRB
->save_state();
850 m_xNeverRB
->save_state();
851 m_xRequestRB
->save_state();
854 void ScTpLayoutOptions::ActivatePage( const SfxItemSet
& /* rCoreSet */ )
858 DeactivateRC
ScTpLayoutOptions::DeactivatePage( SfxItemSet
* pSetP
)
862 return DeactivateRC::LeavePage
;
865 IMPL_LINK_NOARG(ScTpLayoutOptions
, MetricHdl
, weld::ComboBox
&, void)
867 const sal_Int32 nMPos
= m_xUnitLB
->get_active();
870 FieldUnit eFieldUnit
= static_cast<FieldUnit
>(m_xUnitLB
->get_id(nMPos
).toUInt32());
872 m_xTabMF
->denormalize( m_xTabMF
->get_value( FieldUnit::TWIP
) );
873 ::SetFieldUnit( *m_xTabMF
, eFieldUnit
);
874 m_xTabMF
->set_value( m_xTabMF
->normalize( nVal
), FieldUnit::TWIP
);
878 IMPL_LINK(ScTpLayoutOptions
, AlignHdl
, weld::Toggleable
&, rBox
, void)
880 m_xAlignLB
->set_sensitive(rBox
.get_active() &&
881 !officecfg::Office::Calc::Input::MoveSelectionDirection::isReadOnly());
884 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */