/src/libreoffice/sw/source/uibase/app/appopt.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <memory> |
21 | | #include <cmdid.h> |
22 | | |
23 | | #include <com/sun/star/i18n/ScriptType.hpp> |
24 | | |
25 | | #include <sal/log.hxx> |
26 | | #include <hintids.hxx> |
27 | | #include <svl/eitem.hxx> |
28 | | #include <sfx2/app.hxx> |
29 | | #include <sfx2/printer.hxx> |
30 | | #include <sfx2/htmlmode.hxx> |
31 | | #include <sfx2/bindings.hxx> |
32 | | #include <editeng/brushitem.hxx> |
33 | | #include <editeng/tstpitem.hxx> |
34 | | #include <svx/optgrid.hxx> |
35 | | #include <svx/dialogs.hrc> |
36 | | #include <tools/UnitConversion.hxx> |
37 | | #include <i18nlangtag/mslangid.hxx> |
38 | | #include <i18nlangtag/languagetag.hxx> |
39 | | #include <fontcfg.hxx> |
40 | | #include <swmodule.hxx> |
41 | | #include <view.hxx> |
42 | | #include <doc.hxx> |
43 | | #include <wrtsh.hxx> |
44 | | #include <IDocumentDeviceAccess.hxx> |
45 | | #include <IDocumentSettingAccess.hxx> |
46 | | #include <uitool.hxx> |
47 | | #include <wview.hxx> |
48 | | #include <cfgitems.hxx> |
49 | | #include <prtopt.hxx> |
50 | | #include <pview.hxx> |
51 | | #include <usrpref.hxx> |
52 | | #include <uiitems.hxx> |
53 | | #include <editeng/langitem.hxx> |
54 | | #include <unotools/lingucfg.hxx> |
55 | | #include <globals.hrc> |
56 | | #include <swabstdlg.hxx> |
57 | | #include <swwrtshitem.hxx> |
58 | | |
59 | | #include <sfx2/dispatch.hxx> |
60 | | |
61 | | using namespace ::com::sun::star::uno; |
62 | | using namespace ::com::sun::star::lang; |
63 | | |
64 | | std::optional<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId ) |
65 | 0 | { |
66 | 0 | bool bTextDialog = (nId == SID_SW_EDITOPTIONS); |
67 | | |
68 | | // the options for the Web- and Textdialog are put together here |
69 | 0 | SwViewOption aViewOpt = *GetUsrPref(!bTextDialog); |
70 | 0 | SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref.get() : m_pWebUsrPref.get(); |
71 | | // no MakeUsrPref, because only options from textdoks can be used here |
72 | 0 | SwView* pAppView = GetView(); |
73 | 0 | if(pAppView && &pAppView->GetViewFrame() != SfxViewFrame::Current()) |
74 | 0 | pAppView = nullptr; |
75 | 0 | if(pAppView) |
76 | 0 | { |
77 | 0 | bool bWebView = dynamic_cast<SwWebView*>( pAppView ) != nullptr; |
78 | | // if Text then no WebView and vice versa |
79 | 0 | if (bWebView != bTextDialog) |
80 | 0 | { |
81 | 0 | aViewOpt = *pAppView->GetWrtShell().GetViewOptions(); |
82 | 0 | } |
83 | 0 | else |
84 | 0 | pAppView = nullptr; // with View, there's nothing to win here |
85 | 0 | } |
86 | | |
87 | | // Options/Edit |
88 | 0 | SfxItemSetFixed< |
89 | 0 | RES_BACKGROUND, RES_BACKGROUND, |
90 | 0 | XATTR_FILL_FIRST, XATTR_FILL_LAST, |
91 | 0 | SID_PRINTPREVIEW, SID_PRINTPREVIEW, |
92 | 0 | SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS, |
93 | 0 | SID_HTML_MODE, SID_HTML_MODE, |
94 | 0 | SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE, |
95 | 0 | SID_ATTR_CHAR_CTL_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE, |
96 | 0 | SID_ATTR_LANGUAGE, SID_ATTR_METRIC, |
97 | 0 | SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP, |
98 | 0 | SID_ATTR_APPLYCHARUNIT, SID_ATTR_APPLYCHARUNIT, |
99 | 0 | FN_HSCROLL_METRIC, FN_VSCROLL_METRIC, |
100 | 0 | FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER, |
101 | 0 | FN_PARAM_DOCDISP, FN_PARAM_ELEM, |
102 | 0 | FN_PARAM_PRINTER, FN_PARAM_STDFONTS, |
103 | 0 | FN_PARAM_WRTSHELL, FN_PARAM_WRTSHELL, |
104 | 0 | FN_PARAM_SHADOWCURSOR, FN_PARAM_SHADOWCURSOR, |
105 | 0 | FN_PARAM_CRSR_IN_PROTECTED, FN_PARAM_CRSR_IN_PROTECTED, |
106 | 0 | FN_PARAM_FMT_AIDS_AUTOCOMPL, FN_PARAM_FMT_AIDS_AUTOCOMPL, |
107 | 0 | FN_PARAM_BASELINE_GRID_VISIBLE, FN_PARAM_BASELINE_GRID_VISIBLE> |
108 | 0 | aRet(GetPool()); |
109 | |
|
110 | 0 | aRet.Put( SwDocDisplayItem( aViewOpt ) ); |
111 | 0 | SwElemItem aElemItem( aViewOpt ); |
112 | 0 | if( bTextDialog ) |
113 | 0 | { |
114 | 0 | aRet.Put( SwShadowCursorItem( aViewOpt )); |
115 | 0 | aRet.Put( SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, aViewOpt.IsCursorInProtectedArea())); |
116 | 0 | aRet.Put(SwFmtAidsAutoComplItem(aViewOpt)); |
117 | 0 | aElemItem.SetDefaultZoom(pPref->IsDefaultZoom()); |
118 | 0 | aElemItem.SetDefaultZoomType(pPref->GetDefaultZoomType()); |
119 | 0 | aElemItem.SetDefaultZoomValue(pPref->GetDefaultZoomValue()); |
120 | 0 | } |
121 | 0 | aRet.Put( aElemItem ); |
122 | |
|
123 | 0 | if( pAppView ) |
124 | 0 | { |
125 | 0 | SwWrtShell& rWrtShell = pAppView->GetWrtShell(); |
126 | |
|
127 | 0 | SfxPrinter* pPrt = rWrtShell.getIDocumentDeviceAccess().getPrinter( false ); |
128 | 0 | if( pPrt ) |
129 | 0 | aRet.Put(SwPtrItem(FN_PARAM_PRINTER, pPrt)); |
130 | 0 | aRet.Put(SwPtrItem(FN_PARAM_WRTSHELL, &rWrtShell)); |
131 | |
|
132 | 0 | aRet.Put(rWrtShell.GetDefault(RES_CHRATR_LANGUAGE).CloneSetWhich(SID_ATTR_LANGUAGE)); |
133 | 0 | aRet.Put(rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CJK_LANGUAGE)); |
134 | 0 | aRet.Put(rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CTL_LANGUAGE)); |
135 | 0 | } |
136 | 0 | else |
137 | 0 | { |
138 | 0 | SvtLinguConfig aLinguCfg; |
139 | 0 | css::lang::Locale aLocale; |
140 | 0 | LanguageType nLang; |
141 | |
|
142 | 0 | using namespace ::com::sun::star::i18n::ScriptType; |
143 | |
|
144 | 0 | Any aLang = aLinguCfg.GetProperty(u"DefaultLocale"); |
145 | 0 | aLang >>= aLocale; |
146 | 0 | nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), LATIN); |
147 | 0 | aRet.Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE)); |
148 | |
|
149 | 0 | aLang = aLinguCfg.GetProperty(u"DefaultLocale_CJK"); |
150 | 0 | aLang >>= aLocale; |
151 | 0 | nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), ASIAN); |
152 | 0 | aRet.Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE)); |
153 | |
|
154 | 0 | aLang = aLinguCfg.GetProperty(u"DefaultLocale_CTL"); |
155 | 0 | aLang >>= aLocale; |
156 | 0 | nLang = MsLangId::resolveSystemLanguageByScriptType(LanguageTag::convertToLanguageType( aLocale, false), COMPLEX); |
157 | 0 | aRet.Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE)); |
158 | 0 | } |
159 | 0 | if(bTextDialog) |
160 | 0 | aRet.Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig())); |
161 | 0 | if( dynamic_cast<SwPagePreview*>( SfxViewShell::Current())!=nullptr ) |
162 | 0 | { |
163 | 0 | SfxBoolItem aBool(SfxBoolItem(SID_PRINTPREVIEW, true)); |
164 | 0 | aRet.Put(aBool); |
165 | 0 | } |
166 | |
|
167 | 0 | FieldUnit eUnit = pPref->GetHScrollMetric(); |
168 | 0 | if(pAppView) |
169 | 0 | pAppView->GetHRulerMetric(eUnit); |
170 | 0 | aRet.Put(SfxUInt16Item( FN_HSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit))); |
171 | |
|
172 | 0 | eUnit = pPref->GetVScrollMetric(); |
173 | 0 | if(pAppView) |
174 | 0 | pAppView->GetVRulerMetric(eUnit); |
175 | 0 | aRet.Put(SfxUInt16Item( FN_VSCROLL_METRIC, static_cast< sal_uInt16 >(eUnit) )); |
176 | 0 | aRet.Put(SfxUInt16Item( SID_ATTR_METRIC, static_cast< sal_uInt16 >(pPref->GetMetric()) )); |
177 | 0 | aRet.Put(SfxBoolItem(SID_ATTR_APPLYCHARUNIT, pPref->IsApplyCharUnit())); |
178 | 0 | if(bTextDialog) |
179 | 0 | { |
180 | 0 | if(pAppView) |
181 | 0 | { |
182 | 0 | const SvxTabStopItem& rDefTabs = |
183 | 0 | pAppView->GetWrtShell().GetDefault(RES_PARATR_TABSTOP); |
184 | 0 | aRet.Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP, o3tl::narrowing<sal_uInt16>(::GetTabDist(rDefTabs)))); |
185 | 0 | } |
186 | 0 | else |
187 | 0 | aRet.Put(SfxUInt16Item( SID_ATTR_DEFTABSTOP, o3tl::toTwips(pPref->GetDefTabInMm100(), o3tl::Length::mm100))); |
188 | 0 | } |
189 | | |
190 | | // Options for GridTabPage |
191 | 0 | SvxGridItem aGridItem( SID_ATTR_GRID_OPTIONS); |
192 | |
|
193 | 0 | aGridItem.SetUseGridSnap( aViewOpt.IsSnap()); |
194 | 0 | aGridItem.SetSynchronize( aViewOpt.IsSynchronize()); |
195 | 0 | aGridItem.SetGridVisible( aViewOpt.IsGridVisible()); |
196 | |
|
197 | 0 | const Size& rSnapSize = aViewOpt.GetSnapSize(); |
198 | 0 | aGridItem.SetFieldDrawX( o3tl::narrowing<sal_uInt16>(rSnapSize.Width() )); |
199 | 0 | aGridItem.SetFieldDrawY( o3tl::narrowing<sal_uInt16>(rSnapSize.Height())); |
200 | |
|
201 | 0 | aGridItem.SetFieldDivisionX( aViewOpt.GetDivisionX()); |
202 | 0 | aGridItem.SetFieldDivisionY( aViewOpt.GetDivisionY()); |
203 | |
|
204 | 0 | aRet.Put(aGridItem); |
205 | | |
206 | | // Baseline grid options |
207 | 0 | aRet.Put( SfxBoolItem(FN_PARAM_BASELINE_GRID_VISIBLE, aViewOpt.IsBaselineGridVisible())); |
208 | | |
209 | | // Options for PrintTabPage |
210 | 0 | const SwPrintData* pOpt = GetPrtOptions(!bTextDialog); |
211 | 0 | SwAddPrinterItem aAddPrinterItem(*pOpt ); |
212 | 0 | aRet.Put(aAddPrinterItem); |
213 | | |
214 | | // Options for Web |
215 | 0 | if(!bTextDialog) |
216 | 0 | { |
217 | 0 | aRet.Put(SvxBrushItem(aViewOpt.GetRetoucheColor(), RES_BACKGROUND)); |
218 | 0 | aRet.Put(SfxUInt16Item(SID_HTML_MODE, HTMLMODE_ON)); |
219 | 0 | } |
220 | |
|
221 | 0 | return aRet; |
222 | 0 | } |
223 | | |
224 | | void SwModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) |
225 | 0 | { |
226 | 0 | bool bTextDialog = nId == SID_SW_EDITOPTIONS; |
227 | 0 | SwView* pAppView = GetView(); |
228 | 0 | if(pAppView && &pAppView->GetViewFrame() != SfxViewFrame::Current()) |
229 | 0 | pAppView = nullptr; |
230 | 0 | if(pAppView) |
231 | 0 | { |
232 | | // the text dialog mustn't apply data to the web view and vice versa |
233 | 0 | bool bWebView = dynamic_cast<SwWebView*>( pAppView ) != nullptr; |
234 | 0 | if(bWebView == bTextDialog) |
235 | 0 | pAppView = nullptr; |
236 | 0 | } |
237 | |
|
238 | 0 | SwViewOption aViewOpt = *GetUsrPref(!bTextDialog); |
239 | 0 | SwMasterUsrPref* pPref = bTextDialog ? m_pUsrPref.get() : m_pWebUsrPref.get(); |
240 | |
|
241 | 0 | SfxBindings *pBindings = pAppView ? &pAppView->GetViewFrame().GetBindings() |
242 | 0 | : nullptr; |
243 | | |
244 | | // Interpret the page Documentview |
245 | 0 | if( const SwDocDisplayItem* pDocDispItem = rSet.GetItemIfSet( FN_PARAM_DOCDISP, false )) |
246 | 0 | { |
247 | 0 | if(!aViewOpt.IsViewMetaChars()) |
248 | 0 | { |
249 | 0 | if( (!aViewOpt.IsTab( true ) && pDocDispItem->m_bTab) || |
250 | 0 | (!aViewOpt.IsBlank( true ) && pDocDispItem->m_bSpace) || |
251 | 0 | (!aViewOpt.IsShowBookmarks(true) && pDocDispItem->m_bBookmarks) || |
252 | 0 | (!aViewOpt.IsParagraph( true ) && pDocDispItem->m_bParagraphEnd) || |
253 | 0 | (!aViewOpt.IsLineBreak( true ) && pDocDispItem->m_bManualBreak) ) |
254 | 0 | { |
255 | 0 | aViewOpt.SetViewMetaChars(true); |
256 | 0 | if(pBindings) |
257 | 0 | pBindings->Invalidate(FN_VIEW_META_CHARS); |
258 | 0 | } |
259 | |
|
260 | 0 | } |
261 | 0 | pDocDispItem->FillViewOptions( aViewOpt ); |
262 | 0 | if(pBindings) |
263 | 0 | { |
264 | 0 | pBindings->Invalidate(FN_VIEW_GRAPHIC); |
265 | 0 | pBindings->Invalidate(FN_VIEW_HIDDEN_PARA); |
266 | 0 | } |
267 | 0 | } |
268 | | |
269 | | // Elements - interpret Item |
270 | 0 | bool bReFoldOutlineFolding = false; |
271 | 0 | if( const SwElemItem* pElemItem = rSet.GetItemIfSet( FN_PARAM_ELEM, false ) ) |
272 | 0 | { |
273 | 0 | pElemItem->FillViewOptions( aViewOpt ); |
274 | 0 | if (bTextDialog) |
275 | 0 | { |
276 | 0 | pPref->SetDefaultZoom(pElemItem->IsDefaultZoom()); |
277 | 0 | pPref->SetDefaultZoomType(pElemItem->GetDefaultZoomType()); |
278 | 0 | pPref->SetDefaultZoomValue(pElemItem->GetDefaultZoomValue()); |
279 | 0 | } |
280 | | |
281 | | // Outline-folding options |
282 | 0 | if (SwWrtShell* pWrtShell = GetActiveWrtShell()) |
283 | 0 | { |
284 | 0 | bool bIsOutlineFoldingOn = pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton(); |
285 | 0 | bool bTreatSubsChanged = aViewOpt.IsTreatSubOutlineLevelsAsContent() |
286 | 0 | != pWrtShell->GetViewOptions()->IsTreatSubOutlineLevelsAsContent(); |
287 | 0 | if (bIsOutlineFoldingOn && |
288 | 0 | (!aViewOpt.IsShowOutlineContentVisibilityButton() || bTreatSubsChanged)) |
289 | 0 | { |
290 | | // Outline-folding options have change which require to show all content. |
291 | | // Either outline-folding is being switched off or outline-folding is currently on |
292 | | // and the treat subs option has changed. |
293 | 0 | pWrtShell->GetView().GetViewFrame().GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); |
294 | 0 | if (bTreatSubsChanged) |
295 | 0 | bReFoldOutlineFolding = true; // folding method changed, set flag to refold below |
296 | 0 | } |
297 | 0 | else |
298 | 0 | { |
299 | | // Refold needs to be done when outline-folding is being turned on or off |
300 | 0 | bReFoldOutlineFolding = |
301 | 0 | pWrtShell->GetViewOptions()->IsShowOutlineContentVisibilityButton() != |
302 | 0 | aViewOpt.IsShowOutlineContentVisibilityButton(); |
303 | 0 | } |
304 | 0 | } |
305 | 0 | } |
306 | |
|
307 | 0 | if( const SfxUInt16Item* pMetricItem = rSet.GetItemIfSet(SID_ATTR_METRIC, false ) ) |
308 | 0 | { |
309 | 0 | SfxApplication::SetOptions(rSet); |
310 | 0 | PutItem(*pMetricItem); |
311 | 0 | ::SetDfltMetric(static_cast<FieldUnit>(pMetricItem->GetValue()), !bTextDialog); |
312 | 0 | } |
313 | 0 | if( const SfxBoolItem* pCharItem = rSet.GetItemIfSet(SID_ATTR_APPLYCHARUNIT, |
314 | 0 | false ) ) |
315 | 0 | { |
316 | 0 | SfxApplication::SetOptions(rSet); |
317 | 0 | ::SetApplyCharUnit(pCharItem->GetValue(), !bTextDialog); |
318 | 0 | } |
319 | |
|
320 | 0 | if( const SfxUInt16Item* pMetricItem = rSet.GetItemIfSet(FN_HSCROLL_METRIC, false ) ) |
321 | 0 | { |
322 | 0 | FieldUnit eUnit = static_cast<FieldUnit>(pMetricItem->GetValue()); |
323 | 0 | pPref->SetHScrollMetric(eUnit); |
324 | 0 | if(pAppView) |
325 | 0 | pAppView->ChangeTabMetric(eUnit); |
326 | 0 | } |
327 | |
|
328 | 0 | if( const SfxUInt16Item* pMetricItem = rSet.GetItemIfSet(FN_VSCROLL_METRIC, false ) ) |
329 | 0 | { |
330 | 0 | FieldUnit eUnit = static_cast<FieldUnit>(pMetricItem->GetValue()); |
331 | 0 | pPref->SetVScrollMetric(eUnit); |
332 | 0 | if(pAppView) |
333 | 0 | pAppView->ChangeVRulerMetric(eUnit); |
334 | 0 | } |
335 | |
|
336 | 0 | if( const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_ATTR_DEFTABSTOP, false ) ) |
337 | 0 | { |
338 | 0 | sal_uInt16 nTabDist = pItem->GetValue(); |
339 | 0 | pPref->SetDefTabInMm100(convertTwipToMm100(nTabDist)); |
340 | 0 | if(pAppView) |
341 | 0 | { |
342 | 0 | SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP ); |
343 | 0 | MakeDefTabs( nTabDist, aDefTabs ); |
344 | 0 | pAppView->GetWrtShell().SetDefault( aDefTabs ); |
345 | 0 | } |
346 | 0 | } |
347 | | |
348 | | // Background only in WebDialog |
349 | 0 | if(SfxItemState::SET == rSet.GetItemState(RES_BACKGROUND)) |
350 | 0 | { |
351 | 0 | const SvxBrushItem& rBrushItem = rSet.Get(RES_BACKGROUND); |
352 | 0 | aViewOpt.SetRetoucheColor( rBrushItem.GetColor() ); |
353 | 0 | } |
354 | | |
355 | | // Interpret page Grid Settings |
356 | 0 | if( const SvxGridItem* pGridItem = rSet.GetItemIfSet( SID_ATTR_GRID_OPTIONS, false )) |
357 | 0 | { |
358 | 0 | aViewOpt.SetSnap( pGridItem->GetUseGridSnap() ); |
359 | 0 | aViewOpt.SetSynchronize(pGridItem->GetSynchronize()); |
360 | 0 | if( aViewOpt.IsGridVisible() != pGridItem->GetGridVisible() ) |
361 | 0 | aViewOpt.SetGridVisible( pGridItem->GetGridVisible()); |
362 | 0 | Size aSize( pGridItem->GetFieldDrawX(), pGridItem->GetFieldDrawY() ); |
363 | 0 | if( aViewOpt.GetSnapSize() != aSize ) |
364 | 0 | aViewOpt.SetSnapSize( aSize ); |
365 | 0 | short nDiv = static_cast<short>(pGridItem->GetFieldDivisionX()) ; |
366 | 0 | if( aViewOpt.GetDivisionX() != nDiv ) |
367 | 0 | aViewOpt.SetDivisionX( nDiv ); |
368 | 0 | nDiv = static_cast<short>(pGridItem->GetFieldDivisionY()); |
369 | 0 | if( aViewOpt.GetDivisionY() != nDiv ) |
370 | 0 | aViewOpt.SetDivisionY( nDiv ); |
371 | |
|
372 | 0 | if(pBindings) |
373 | 0 | { |
374 | 0 | pBindings->Invalidate(SID_GRID_VISIBLE); |
375 | 0 | pBindings->Invalidate(SID_GRID_USE); |
376 | 0 | } |
377 | 0 | } |
378 | | |
379 | | // Baseline grid options |
380 | 0 | if( const SfxBoolItem* pItem = rSet.GetItemIfSet( FN_PARAM_BASELINE_GRID_VISIBLE, false )) |
381 | 0 | { |
382 | 0 | aViewOpt.SetBaselineGridVisible(pItem->GetValue()); |
383 | 0 | if(pBindings) |
384 | 0 | { |
385 | 0 | pBindings->Invalidate(FN_VIEW_BASELINE_GRID_VISIBLE); |
386 | 0 | } |
387 | 0 | } |
388 | | |
389 | | // Interpret Writer Printer Options |
390 | 0 | if( const SwAddPrinterItem* pAddPrinterAttr = rSet.GetItemIfSet( FN_PARAM_ADDPRINTER, false ) ) |
391 | 0 | { |
392 | 0 | SwPrintOptions* pOpt = GetPrtOptions(!bTextDialog); |
393 | 0 | if (pOpt) |
394 | 0 | { |
395 | 0 | *pOpt = *pAddPrinterAttr; |
396 | 0 | SwPagePreview* pPagePreview = dynamic_cast<SwPagePreview*>( SfxViewShell::Current()); |
397 | 0 | if( pPagePreview !=nullptr ) |
398 | 0 | { |
399 | 0 | pPagePreview->GetViewShell()->getIDocumentDeviceAccess().setPrintData(*pOpt); |
400 | 0 | pPagePreview->PrintSettingsChanged(); |
401 | 0 | } |
402 | 0 | } |
403 | 0 | } |
404 | |
|
405 | 0 | if( const SwShadowCursorItem* pItem = rSet.GetItemIfSet( FN_PARAM_SHADOWCURSOR, false )) |
406 | 0 | { |
407 | 0 | pItem->FillViewOptions( aViewOpt ); |
408 | 0 | if(pBindings) |
409 | 0 | pBindings->Invalidate(FN_SHADOWCURSOR); |
410 | 0 | } |
411 | |
|
412 | 0 | if( pAppView ) |
413 | 0 | { |
414 | 0 | SwWrtShell &rWrtSh = pAppView->GetWrtShell(); |
415 | 0 | const bool bAlignFormulas = rWrtSh.GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ); |
416 | 0 | pPref->SetAlignMathObjectsToBaseline( bAlignFormulas ); |
417 | | |
418 | | // tdf#99205: The itemset doesn't contain SID_AUTOSPELL_CHECK, |
419 | | // and m_pUsrPref was created before a view existed; bOnlineSpell might be default value |
420 | | // so pull the globally-shared value from the view |
421 | 0 | const bool bOnlineSpell = rWrtSh.GetViewOptions()->IsOnlineSpell(); |
422 | 0 | aViewOpt.SetOnlineSpell(bOnlineSpell); |
423 | | |
424 | | // don't align formulas in documents that are currently loading |
425 | 0 | if (bAlignFormulas && !rWrtSh.GetDoc()->IsInReading()) |
426 | 0 | rWrtSh.AlignAllFormulasToBaseline(); |
427 | 0 | } |
428 | |
|
429 | 0 | if( const SfxBoolItem* pItem = rSet.GetItemIfSet( FN_PARAM_CRSR_IN_PROTECTED, false )) |
430 | 0 | { |
431 | 0 | aViewOpt.SetCursorInProtectedArea(pItem->GetValue()); |
432 | 0 | } |
433 | |
|
434 | 0 | if (const SwFmtAidsAutoComplItem* pItem = rSet.GetItemIfSet(FN_PARAM_FMT_AIDS_AUTOCOMPL, false)) |
435 | 0 | { |
436 | 0 | aViewOpt.SetEncloseWithCharactersOn(pItem->IsEncloseWithCharactersOn()); |
437 | 0 | } |
438 | | |
439 | | // set elements for the current view and shell |
440 | 0 | ApplyUsrPref( aViewOpt, pAppView, bTextDialog? SvViewOpt::DestText : SvViewOpt::DestWeb); |
441 | | |
442 | | // must be done after ApplyUsrPref |
443 | 0 | if (SfxItemState::SET != rSet.GetItemState(FN_PARAM_ELEM, false)) |
444 | 0 | return; |
445 | | |
446 | 0 | if (bReFoldOutlineFolding) |
447 | 0 | { |
448 | 0 | if (SwWrtShell* pWrtShell = GetActiveWrtShell()) |
449 | 0 | { |
450 | 0 | pWrtShell->GetView().GetViewFrame().GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); |
451 | 0 | pWrtShell->GetView().GetViewFrame().GetDispatcher()->Execute(FN_SHOW_OUTLINECONTENTVISIBILITYBUTTON); |
452 | 0 | } |
453 | 0 | } |
454 | 0 | } |
455 | | |
456 | | std::unique_ptr<SfxTabPage> SwModule::CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) |
457 | 0 | { |
458 | 0 | std::unique_ptr<SfxTabPage> xRet; |
459 | 0 | SfxAllItemSet aSet(*(rSet.GetPool())); |
460 | 0 | switch( nId ) |
461 | 0 | { |
462 | 0 | case RID_SW_TP_CONTENT_OPT: |
463 | 0 | case RID_SW_TP_HTML_CONTENT_OPT: |
464 | 0 | { |
465 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
466 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
467 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
468 | 0 | break; |
469 | 0 | } |
470 | 0 | case RID_SW_TP_HTML_OPTGRID_PAGE: |
471 | 0 | xRet = SvxGridTabPage::Create(pPage, pController, rSet); |
472 | 0 | break; |
473 | 0 | case RID_SVXPAGE_GRID: |
474 | 0 | { |
475 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
476 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
477 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
478 | 0 | break; |
479 | 0 | } |
480 | | |
481 | 0 | case RID_SW_TP_STD_FONT: |
482 | 0 | case RID_SW_TP_STD_FONT_CJK: |
483 | 0 | case RID_SW_TP_STD_FONT_CTL: |
484 | 0 | { |
485 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
486 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
487 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
488 | 0 | if(RID_SW_TP_STD_FONT != nId) |
489 | 0 | { |
490 | 0 | aSet.Put (SfxUInt16Item(SID_FONTMODE_TYPE, RID_SW_TP_STD_FONT_CJK == nId ? FONT_GROUP_CJK : FONT_GROUP_CTL)); |
491 | 0 | xRet->PageCreated(aSet); |
492 | 0 | } |
493 | 0 | } |
494 | 0 | break; |
495 | 0 | case RID_SW_TP_HTML_OPTPRINT_PAGE: |
496 | 0 | case RID_SW_TP_OPTPRINT_PAGE: |
497 | 0 | { |
498 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
499 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
500 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
501 | 0 | aSet.Put (SfxBoolItem(SID_FAX_LIST, true)); |
502 | 0 | xRet->PageCreated(aSet); |
503 | 0 | } |
504 | 0 | break; |
505 | 0 | case RID_SW_TP_HTML_OPTTABLE_PAGE: |
506 | 0 | case RID_SW_TP_OPTTABLE_PAGE: |
507 | 0 | { |
508 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
509 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
510 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
511 | 0 | SwView* pCurrView = GetView(); |
512 | 0 | if(pCurrView) |
513 | 0 | { |
514 | | // if text then not WebView and vice versa |
515 | 0 | bool bWebView = dynamic_cast<SwWebView*>( pCurrView ) != nullptr; |
516 | 0 | if( (bWebView && RID_SW_TP_HTML_OPTTABLE_PAGE == nId) || |
517 | 0 | (!bWebView && RID_SW_TP_HTML_OPTTABLE_PAGE != nId) ) |
518 | 0 | { |
519 | 0 | aSet.Put (SwWrtShellItem(pCurrView->GetWrtShellPtr())); |
520 | 0 | xRet->PageCreated(aSet); |
521 | 0 | } |
522 | 0 | } |
523 | 0 | } |
524 | 0 | break; |
525 | 0 | case RID_SW_TP_OPTSHDWCRSR: |
526 | 0 | case RID_SW_TP_HTML_OPTSHDWCRSR: |
527 | 0 | case RID_SW_TP_REDLINE_OPT: |
528 | 0 | case RID_SW_TP_COMPARISON_OPT: |
529 | 0 | case RID_SW_TP_OPTLOAD_PAGE: |
530 | 0 | case RID_SW_TP_OPTCOMPATIBILITY_PAGE: |
531 | 0 | case RID_SW_TP_MAILCONFIG: |
532 | 0 | { |
533 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
534 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
535 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
536 | 0 | if (nId == RID_SW_TP_OPTSHDWCRSR || nId == RID_SW_TP_HTML_OPTSHDWCRSR) |
537 | 0 | { |
538 | 0 | SwView* pCurrView = GetView(); |
539 | 0 | if(pCurrView) |
540 | 0 | { |
541 | 0 | aSet.Put( SwWrtShellItem( pCurrView->GetWrtShellPtr() ) ); |
542 | 0 | xRet->PageCreated(aSet); |
543 | 0 | } |
544 | 0 | } |
545 | 0 | } |
546 | 0 | break; |
547 | 0 | case RID_SW_TP_OPTTEST_PAGE: |
548 | 0 | { |
549 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
550 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( nId ); |
551 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
552 | 0 | break; |
553 | 0 | } |
554 | 0 | case RID_SW_TP_OPTCAPTION_PAGE: |
555 | 0 | { |
556 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
557 | 0 | ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SW_TP_OPTCAPTION_PAGE ); |
558 | 0 | xRet = (*fnCreatePage)( pPage, pController, &rSet ); |
559 | 0 | } |
560 | 0 | break; |
561 | 0 | } |
562 | | |
563 | 0 | if(!xRet) |
564 | 0 | SAL_WARN( "sw", "SwModule::CreateTabPage(): Unknown tabpage id " << nId ); |
565 | 0 | return xRet; |
566 | 0 | } |
567 | | |
568 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |