/src/libreoffice/sw/source/uibase/uiview/view2.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 <config_features.h> |
21 | | #include <config_fuzzers.h> |
22 | | |
23 | | #include <com/sun/star/util/SearchAlgorithms2.hpp> |
24 | | #include <o3tl/any.hxx> |
25 | | #include <vcl/graphicfilter.hxx> |
26 | | #include <com/sun/star/sdb/DatabaseContext.hpp> |
27 | | #include <com/sun/star/ui/dialogs/XFilePicker3.hpp> |
28 | | #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> |
29 | | #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> |
30 | | #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> |
31 | | #include <com/sun/star/ui/dialogs/TemplateDescription.hpp> |
32 | | #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> |
33 | | #include <com/sun/star/linguistic2/XDictionary.hpp> |
34 | | #include <comphelper/propertyvalue.hxx> |
35 | | #include <officecfg/Office/Common.hxx> |
36 | | #include <SwCapObjType.hxx> |
37 | | #include <SwStyleNameMapper.hxx> |
38 | | #include <docary.hxx> |
39 | | #include <hintids.hxx> |
40 | | #include <SwRewriter.hxx> |
41 | | #include <numrule.hxx> |
42 | | #include <swundo.hxx> |
43 | | #include <svl/PasswordHelper.hxx> |
44 | | #include <svl/urihelper.hxx> |
45 | | #include <sfx2/passwd.hxx> |
46 | | #include <sfx2/sfxdlg.hxx> |
47 | | #include <sfx2/filedlghelper.hxx> |
48 | | #include <editeng/langitem.hxx> |
49 | | #include <svx/linkwarn.hxx> |
50 | | #include <svx/statusitem.hxx> |
51 | | #include <svx/viewlayoutitem.hxx> |
52 | | #include <svx/zoomslideritem.hxx> |
53 | | #include <sfx2/lokhelper.hxx> |
54 | | #include <sfx2/htmlmode.hxx> |
55 | | #include <vcl/svapp.hxx> |
56 | | #include <sfx2/app.hxx> |
57 | | #include <sfx2/request.hxx> |
58 | | #include <sfx2/bindings.hxx> |
59 | | #include <editeng/lrspitem.hxx> |
60 | | #include <unotools/localedatawrapper.hxx> |
61 | | #include <unotools/syslocale.hxx> |
62 | | #include <editeng/unolingu.hxx> |
63 | | #include <vcl/weld.hxx> |
64 | | #include <editeng/tstpitem.hxx> |
65 | | #include <sfx2/event.hxx> |
66 | | #include <sfx2/docfile.hxx> |
67 | | #include <sfx2/docfilt.hxx> |
68 | | #include <sfx2/fcontnr.hxx> |
69 | | #include <editeng/sizeitem.hxx> |
70 | | #include <sfx2/dispatch.hxx> |
71 | | #include <svl/whiter.hxx> |
72 | | #include <svl/ptitem.hxx> |
73 | | #include <sfx2/viewfrm.hxx> |
74 | | #include <vcl/errinf.hxx> |
75 | | #include <tools/hostfilter.hxx> |
76 | | #include <tools/urlobj.hxx> |
77 | | #include <svx/svdview.hxx> |
78 | | #include <swtypes.hxx> |
79 | | #include <swwait.hxx> |
80 | | #include <redlndlg.hxx> |
81 | | #include <view.hxx> |
82 | | #include <uivwimp.hxx> |
83 | | #include <docsh.hxx> |
84 | | #include <doc.hxx> |
85 | | #include <printdata.hxx> |
86 | | #include <IDocumentDeviceAccess.hxx> |
87 | | #include <IDocumentRedlineAccess.hxx> |
88 | | #include <DocumentRedlineManager.hxx> |
89 | | #include <IDocumentUndoRedo.hxx> |
90 | | #include <IDocumentSettingAccess.hxx> |
91 | | #include <IDocumentDrawModelAccess.hxx> |
92 | | #include <IDocumentStatistics.hxx> |
93 | | #include <IDocumentOutlineNodes.hxx> |
94 | | #include <wrtsh.hxx> |
95 | | #include <viewopt.hxx> |
96 | | #include <basesh.hxx> |
97 | | #include <swmodule.hxx> |
98 | | #include <uitool.hxx> |
99 | | #include <shellio.hxx> |
100 | | #include <fmtinfmt.hxx> |
101 | | #include <mdiexp.hxx> |
102 | | #include <drawbase.hxx> |
103 | | #include <frmatr.hxx> |
104 | | #include <frmmgr.hxx> |
105 | | #include <pagedesc.hxx> |
106 | | #include <section.hxx> |
107 | | #include <tox.hxx> |
108 | | #include <edtwin.hxx> |
109 | | #include <wview.hxx> |
110 | | #include <cmdid.h> |
111 | | #include <sfx2/strings.hrc> |
112 | | #include <sfx2/sfxresid.hxx> |
113 | | #include <strings.hrc> |
114 | | #include <swerror.h> |
115 | | #include <globals.hrc> |
116 | | #include <fmtclds.hxx> |
117 | | #include <sfx2/templatedlg.hxx> |
118 | | #include <dbconfig.hxx> |
119 | | #include <dbmgr.hxx> |
120 | | #include <reffld.hxx> |
121 | | #include <comphelper/lok.hxx> |
122 | | #include <comphelper/string.hxx> |
123 | | #include <comphelper/docpasswordhelper.hxx> |
124 | | #include <svtools/strings.hrc> |
125 | | #include <svtools/svtresid.hxx> |
126 | | |
127 | | #include <PostItMgr.hxx> |
128 | | |
129 | | #include <comphelper/processfactory.hxx> |
130 | | #include <LibreOfficeKit/LibreOfficeKitEnums.h> |
131 | | |
132 | | #include <svx/svxdlg.hxx> |
133 | | #include <swabstdlg.hxx> |
134 | | #include <fmthdft.hxx> |
135 | | #include <unotextrange.hxx> |
136 | | #include <docstat.hxx> |
137 | | #include <wordcountdialog.hxx> |
138 | | #include <OnlineAccessibilityCheck.hxx> |
139 | | #include <sfx2/sidebar/Sidebar.hxx> |
140 | | |
141 | | #include <vcl/GraphicNativeTransform.hxx> |
142 | | #include <vcl/GraphicNativeMetadata.hxx> |
143 | | #include <vcl/settings.hxx> |
144 | | #include <i18nutil/searchopt.hxx> |
145 | | #include <osl/diagnose.h> |
146 | | #include <paratr.hxx> |
147 | | #include <rootfrm.hxx> |
148 | | #include <frameformats.hxx> |
149 | | |
150 | | #include <viewimp.hxx> |
151 | | #include <pagefrm.hxx> |
152 | | |
153 | | #include <memory> |
154 | | #include <string_view> |
155 | | #include <svl/slstitm.hxx> |
156 | | |
157 | | #include <basegfx/utils/zoomtools.hxx> |
158 | | |
159 | | #include <ndtxt.hxx> |
160 | | #include <grfatr.hxx> |
161 | | |
162 | | #include <svx/srchdlg.hxx> |
163 | | #include <o3tl/string_view.hxx> |
164 | | |
165 | | #include <svx/dialog/gotodlg.hxx> |
166 | | |
167 | | const char sStatusDelim[] = " : "; |
168 | | |
169 | | using namespace sfx2; |
170 | | using namespace ::com::sun::star; |
171 | | using namespace ::com::sun::star::util; |
172 | | using namespace ::com::sun::star::uno; |
173 | | using namespace ::com::sun::star::lang; |
174 | | using namespace ::com::sun::star::scanner; |
175 | | using namespace ::com::sun::star::beans; |
176 | | using namespace ::com::sun::star::container; |
177 | | using namespace ::com::sun::star::sdb; |
178 | | using namespace ::com::sun::star::ui::dialogs; |
179 | | |
180 | | namespace { |
181 | | |
182 | | class SwNumberInputDlg : public SfxDialogController |
183 | | { |
184 | | private: |
185 | | std::unique_ptr<weld::Label> m_xLabel1; |
186 | | std::unique_ptr<weld::SpinButton> m_xSpinButton; |
187 | | std::unique_ptr<weld::Label> m_xLabel2; |
188 | | std::unique_ptr<weld::Button> m_xOKButton; |
189 | | |
190 | | DECL_LINK(InputModifiedHdl, weld::Entry&, void); |
191 | | public: |
192 | | SwNumberInputDlg(weld::Window* pParent, const OUString& rTitle, |
193 | | const OUString& rLabel1, const sal_Int64 nValue, const sal_Int64 min, const sal_Int64 max, |
194 | | const OUString& rLabel2 = OUString()) |
195 | 0 | : SfxDialogController(pParent, u"modules/swriter/ui/numberinput.ui"_ustr, u"NumberInputDialog"_ustr) |
196 | 0 | , m_xLabel1(m_xBuilder->weld_label(u"label1"_ustr)) |
197 | 0 | , m_xSpinButton(m_xBuilder->weld_spin_button(u"spinbutton"_ustr)) |
198 | 0 | , m_xLabel2(m_xBuilder->weld_label(u"label2"_ustr)) |
199 | 0 | , m_xOKButton(m_xBuilder->weld_button(u"ok"_ustr)) |
200 | 0 | { |
201 | 0 | m_xDialog->set_title(rTitle); |
202 | 0 | m_xLabel1->set_label(rLabel1); |
203 | 0 | m_xSpinButton->set_value(nValue); |
204 | 0 | m_xSpinButton->set_range(min, max); |
205 | 0 | m_xSpinButton->set_position(-1); |
206 | 0 | m_xSpinButton->select_region(0, -1); |
207 | 0 | m_xSpinButton->connect_changed(LINK(this, SwNumberInputDlg, InputModifiedHdl)); |
208 | 0 | if (!rLabel2.isEmpty()) |
209 | 0 | { |
210 | 0 | m_xLabel2->set_label(rLabel2); |
211 | 0 | m_xLabel2->show(); |
212 | 0 | } |
213 | 0 | } |
214 | | |
215 | | auto GetNumber() |
216 | 0 | { |
217 | 0 | return m_xSpinButton->get_text().toInt32(); |
218 | 0 | } |
219 | | }; |
220 | | |
221 | | IMPL_LINK_NOARG(SwNumberInputDlg, InputModifiedHdl, weld::Entry&, void) |
222 | 0 | { |
223 | 0 | m_xOKButton->set_sensitive(!m_xSpinButton->get_text().isEmpty()); |
224 | 0 | if (!m_xOKButton->get_sensitive()) |
225 | 0 | return; |
226 | | |
227 | 0 | auto nValue = m_xSpinButton->get_text().toInt32(); |
228 | 0 | if (nValue <= m_xSpinButton->get_min()) |
229 | 0 | m_xSpinButton->set_value(m_xSpinButton->get_min()); |
230 | 0 | else if (nValue > m_xSpinButton->get_max()) |
231 | 0 | m_xSpinButton->set_value(m_xSpinButton->get_max()); |
232 | 0 | else |
233 | 0 | m_xSpinButton->set_value(nValue); |
234 | |
|
235 | 0 | m_xSpinButton->set_position(-1); |
236 | 0 | } |
237 | | |
238 | | } |
239 | | |
240 | | static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, TypedWhichId<SvxLanguageItem> nWhichId ) |
241 | 0 | { |
242 | 0 | if (!(nWhichId == RES_CHRATR_LANGUAGE || |
243 | 0 | nWhichId == RES_CHRATR_CJK_LANGUAGE || |
244 | 0 | nWhichId == RES_CHRATR_CTL_LANGUAGE)) |
245 | 0 | return; |
246 | | |
247 | 0 | rWrtSh.StartAction(); |
248 | 0 | rWrtSh.LockView( true ); |
249 | 0 | rWrtSh.Push(); |
250 | | |
251 | | // prepare to apply new language to all text in document |
252 | 0 | rWrtSh.SelAll(); |
253 | 0 | rWrtSh.ExtendedSelectAll(); |
254 | | |
255 | | // set language attribute to default for all text |
256 | 0 | rWrtSh.ResetAttr({ nWhichId }); |
257 | |
|
258 | 0 | rWrtSh.Pop(SwCursorShell::PopMode::DeleteCurrent); |
259 | 0 | rWrtSh.LockView( false ); |
260 | 0 | rWrtSh.EndAction(); |
261 | |
|
262 | 0 | } |
263 | | |
264 | | /** |
265 | | * Create string for showing the page number in the statusbar |
266 | | * |
267 | | * @param nPhyNum The physical page number |
268 | | * @param nVirtNum The logical page number (user-assigned) |
269 | | * @param rPgStr User-defined page name (will be shown if different from logical page number) |
270 | | * |
271 | | * @return OUString Formatted string: Page 1 of 10 (Page 1 of 8 to print OR Page nVirtNumv/rPgStr) |
272 | | **/ |
273 | | OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr) |
274 | 0 | { |
275 | | // Show user-defined page number in brackets if any. |
276 | 0 | OUString extra; |
277 | 0 | if (!rPgStr.isEmpty() && std::u16string_view(OUString::number(nPhyNum)) != rPgStr) |
278 | 0 | extra = rPgStr; |
279 | 0 | else if (nPhyNum != nVirtNum) |
280 | 0 | extra = OUString::number(nVirtNum); |
281 | |
|
282 | 0 | sal_uInt16 nPageCount = GetWrtShell().GetPageCnt(); |
283 | 0 | sal_uInt16 nPrintedPhyNum = nPhyNum; |
284 | 0 | sal_uInt16 nPrintedPageCount = nPageCount; |
285 | 0 | if (!GetWrtShell().getIDocumentDeviceAccess().getPrintData().IsPrintEmptyPages()) |
286 | 0 | SwDoc::CalculateNonBlankPages(*m_pWrtShell->GetLayout(), nPrintedPageCount, nPrintedPhyNum); |
287 | | // Show printed page numbers only, when they are different |
288 | 0 | OUString aStr( nPageCount != nPrintedPageCount |
289 | 0 | ? SwResId(STR_PAGE_COUNT_PRINTED) |
290 | 0 | : (extra.isEmpty() ? SwResId(STR_PAGE_COUNT) : SwResId(STR_PAGE_COUNT_CUSTOM))); |
291 | 0 | aStr = aStr.replaceFirst("%1", OUString::number(nPhyNum)); |
292 | 0 | if (nPageCount != nPrintedPageCount) |
293 | 0 | { |
294 | 0 | aStr = aStr.replaceFirst("%2", OUString::number(nPageCount)); |
295 | 0 | aStr = aStr.replaceFirst("%3", OUString::number(nPrintedPhyNum)); |
296 | 0 | aStr = aStr.replaceFirst("%4", OUString::number(nPrintedPageCount)); |
297 | 0 | } |
298 | 0 | else { |
299 | 0 | if (extra.isEmpty()) |
300 | 0 | aStr = aStr.replaceFirst("%2", OUString::number(nPageCount)); |
301 | 0 | else |
302 | 0 | { |
303 | 0 | aStr = aStr.replaceFirst("%2", extra); |
304 | 0 | aStr = aStr.replaceFirst("%3", OUString::number(nPageCount)); |
305 | 0 | } |
306 | 0 | } |
307 | |
|
308 | 0 | return aStr; |
309 | 0 | } |
310 | | |
311 | | ErrCode SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter, |
312 | | bool bLink, GraphicFilter *pFilter ) |
313 | 0 | { |
314 | 0 | SwWait aWait( *GetDocShell(), true ); |
315 | |
|
316 | 0 | Graphic aGraphic; |
317 | 0 | ErrCode aResult = ERRCODE_NONE; |
318 | 0 | if( !pFilter ) |
319 | 0 | { |
320 | 0 | pFilter = &GraphicFilter::GetGraphicFilter(); |
321 | 0 | } |
322 | |
|
323 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
324 | 0 | { |
325 | 0 | INetURLObject aURL(rPath); |
326 | 0 | if (INetProtocol::File != aURL.GetProtocol() && HostFilter::isForbidden(aURL.GetHost())) |
327 | 0 | SfxLokHelper::sendNetworkAccessError("insert"); |
328 | 0 | } |
329 | |
|
330 | 0 | auto xHandler(GetDocShell()->GetMedium()->GetInteractionHandler()); |
331 | 0 | aResult = GraphicFilter::LoadGraphic(rPath, rFilter, aGraphic, pFilter, nullptr, xHandler); |
332 | |
|
333 | 0 | if( ERRCODE_NONE == aResult ) |
334 | 0 | { |
335 | 0 | Degree10 aRotation; |
336 | 0 | GraphicNativeMetadata aMetadata; |
337 | 0 | if ( aMetadata.read(aGraphic) ) |
338 | 0 | aRotation = aMetadata.getRotation(); |
339 | |
|
340 | 0 | SwWrtShell& rShell = GetWrtShell(); |
341 | 0 | SwFlyFrameAttrMgr aFrameManager( true, &rShell, Frmmgr_Type::GRF, nullptr ); |
342 | | |
343 | | // #i123922# determine if we really want to insert or replace the graphic at a selected object |
344 | 0 | const bool bReplaceMode(rShell.HasSelection() && SelectionType::Frame == rShell.GetSelectionType()); |
345 | |
|
346 | 0 | if(bReplaceMode) |
347 | 0 | { |
348 | | // #i123922# Do same as in D&D, ReRead graphic and all is done |
349 | 0 | rShell.ReRead( |
350 | 0 | bLink ? rPath : OUString(), |
351 | 0 | bLink ? rFilter : OUString(), |
352 | 0 | &aGraphic); |
353 | 0 | } |
354 | 0 | else |
355 | 0 | { |
356 | 0 | rShell.StartAction(); |
357 | 0 | if( bLink ) |
358 | 0 | { |
359 | 0 | SwDocShell* pDocSh = GetDocShell(); |
360 | 0 | INetURLObject aTemp( |
361 | 0 | pDocSh->HasName() ? |
362 | 0 | pDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) : |
363 | 0 | OUString()); |
364 | |
|
365 | 0 | OUString sURL = URIHelper::SmartRel2Abs( |
366 | 0 | aTemp, rPath, URIHelper::GetMaybeFileHdl() ); |
367 | 0 | aGraphic.setOriginURL(sURL); |
368 | 0 | rShell.InsertGraphic( sURL, rFilter, aGraphic, &aFrameManager ); |
369 | 0 | } |
370 | 0 | else |
371 | 0 | { |
372 | 0 | rShell.InsertGraphic( OUString(), OUString(), aGraphic, &aFrameManager ); |
373 | 0 | } |
374 | |
|
375 | 0 | if (aRotation) |
376 | 0 | { |
377 | 0 | SfxItemSetFixed<RES_GRFATR_ROTATION, RES_GRFATR_ROTATION> aSet( rShell.GetAttrPool() ); |
378 | 0 | rShell.GetCurAttr( aSet ); |
379 | 0 | const SwRotationGrf& rRotation = aSet.Get(RES_GRFATR_ROTATION); |
380 | 0 | aFrameManager.SetRotation(rRotation.GetValue(), aRotation, rRotation.GetUnrotatedSize()); |
381 | 0 | } |
382 | | |
383 | | // it is too late after "EndAction" because the Shell can already be destroyed. |
384 | 0 | rShell.EndAction(); |
385 | 0 | } |
386 | 0 | } |
387 | 0 | return aResult; |
388 | 0 | } |
389 | | |
390 | | bool SwView::InsertGraphicDlg( SfxRequest& rReq ) |
391 | 0 | { |
392 | 0 | bool bReturn = false; |
393 | 0 | SwDocShell* pDocShell = GetDocShell(); |
394 | 0 | SwDoc* pDoc = pDocShell->GetDoc(); |
395 | |
|
396 | 0 | UIName sGraphicFormat( SwResId(STR_POOLFRM_GRAPHIC) ); |
397 | |
|
398 | 0 | const SfxStringItem* pName = rReq.GetArg<SfxStringItem>(SID_INSERT_GRAPHIC); |
399 | 0 | bool bShowError = !pName; |
400 | | |
401 | | // No file pickers in a non-desktop (mobile app) build. |
402 | |
|
403 | | #if HAVE_FEATURE_DESKTOP |
404 | | // when in HTML mode insert only as a link |
405 | | const sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell); |
406 | | |
407 | | if (!pName && !Application::IsHeadlessModeEnabled()) |
408 | | { |
409 | | std::unique_ptr<FileDialogHelper> pFileDlg(new FileDialogHelper( |
410 | | ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE, |
411 | | FileDialogFlags::Graphic, GetFrameWeld())); |
412 | | pFileDlg->SetTitle(SwResId(STR_INSERT_GRAPHIC )); |
413 | | pFileDlg->SetContext( FileDialogHelper::WriterInsertImage ); |
414 | | |
415 | | uno::Reference < XFilePicker3 > xFP = pFileDlg->GetFilePicker(); |
416 | | uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY); |
417 | | if(nHtmlMode & HTMLMODE_ON) |
418 | | { |
419 | | xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, Any(true)); |
420 | | xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, false); |
421 | | } |
422 | | |
423 | | std::vector<OUString> aFormats; |
424 | | for( const auto& pSwFrameFormat : (*pDoc->GetFrameFormats()) ) |
425 | | { |
426 | | const SwFrameFormat* pFormat = pSwFrameFormat; |
427 | | if(pFormat->IsDefault() || pFormat->IsAuto()) |
428 | | continue; |
429 | | aFormats.push_back(pFormat->GetName().toString()); |
430 | | } |
431 | | |
432 | | // pool formats |
433 | | |
434 | | const std::vector<OUString>& rFramePoolArr( |
435 | | SwStyleNameMapper::GetFrameFormatUINameArray()); |
436 | | for(const auto & i : rFramePoolArr) |
437 | | { |
438 | | aFormats.push_back(i); |
439 | | } |
440 | | |
441 | | std::sort(aFormats.begin(), aFormats.end()); |
442 | | aFormats.erase(std::unique(aFormats.begin(), aFormats.end()), aFormats.end()); |
443 | | |
444 | | Sequence<OUString> aListBoxEntries(aFormats.size()); |
445 | | OUString* pEntries = aListBoxEntries.getArray(); |
446 | | sal_Int16 nSelect = 0; |
447 | | sal_Int16 i = 0; |
448 | | for( const auto& a : aFormats ) |
449 | | { |
450 | | pEntries[i] = a; |
451 | | if(pEntries[i] == sGraphicFormat) |
452 | | nSelect = i; |
453 | | ++i; |
454 | | } |
455 | | try |
456 | | { |
457 | | Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get()); |
458 | | |
459 | | xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, |
460 | | ListboxControlActions::ADD_ITEMS , aTemplates ); |
461 | | |
462 | | Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get()); |
463 | | xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, |
464 | | ListboxControlActions::SET_SELECT_ITEM, aSelectPos ); |
465 | | } |
466 | | catch (const Exception&) |
467 | | { |
468 | | OSL_FAIL("control access failed"); |
469 | | } |
470 | | |
471 | | // execute file dialog, without capturing mouse (tdf#156033) |
472 | | vcl::Window* pWin = GetWindow(); |
473 | | const bool bMouseCaptured = pWin && pWin->IsMouseCaptured(); |
474 | | if (bMouseCaptured) |
475 | | pWin->ReleaseMouse(); |
476 | | bool bHaveName = ERRCODE_NONE == pFileDlg->Execute(); |
477 | | if (bMouseCaptured) |
478 | | pWin->CaptureMouse(); |
479 | | if (bHaveName) |
480 | | { |
481 | | rReq.AppendItem(SfxStringItem(SID_INSERT_GRAPHIC, pFileDlg->GetPath())); |
482 | | rReq.AppendItem(SfxStringItem(FN_PARAM_FILTER, pFileDlg->GetCurrentFilter())); |
483 | | pName = rReq.GetArg<SfxStringItem>(SID_INSERT_GRAPHIC); |
484 | | |
485 | | bool bAsLink = false; |
486 | | if(nHtmlMode & HTMLMODE_ON) |
487 | | bAsLink = true; |
488 | | else |
489 | | { |
490 | | try |
491 | | { |
492 | | Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0); |
493 | | OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found"); |
494 | | bAsLink = !aVal.hasValue() || *o3tl::doAccess<bool>(aVal); |
495 | | Any aTemplateValue = xCtrlAcc->getValue( |
496 | | ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, |
497 | | ListboxControlActions::GET_SELECTED_ITEM ); |
498 | | OUString sTmpl; |
499 | | aTemplateValue >>= sTmpl; |
500 | | rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) ); |
501 | | } |
502 | | catch (const Exception&) |
503 | | { |
504 | | OSL_FAIL("control access failed"); |
505 | | } |
506 | | } |
507 | | rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) ); |
508 | | } |
509 | | } |
510 | | #endif |
511 | 0 | if (pName) |
512 | 0 | { |
513 | 0 | OUString aFileName = pName->GetValue(); |
514 | 0 | OUString aFilterName; |
515 | 0 | if (const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(FN_PARAM_FILTER)) |
516 | 0 | aFilterName = pFilter->GetValue(); |
517 | 0 | bool bAsLink = false; |
518 | 0 | if (const SfxBoolItem* pAsLink = rReq.GetArg<SfxBoolItem>(FN_PARAM_1)) |
519 | 0 | bAsLink = pAsLink->GetValue(); |
520 | 0 | if (const SfxStringItem* pStyle = rReq.GetArg<SfxStringItem>(FN_PARAM_2); |
521 | 0 | pStyle && !pStyle->GetValue().isEmpty()) |
522 | 0 | sGraphicFormat = UIName(pStyle->GetValue()); |
523 | |
|
524 | | #if HAVE_FEATURE_DESKTOP |
525 | | if( nHtmlMode & HTMLMODE_ON ) |
526 | | bAsLink = true; |
527 | | else |
528 | | { |
529 | | // really store as link only? |
530 | | if (bAsLink && bShowError |
531 | | && officecfg::Office::Common::Misc::ShowLinkWarningDialog::get()) |
532 | | { |
533 | | SvxLinkWarningDialog aWarnDlg(GetFrameWeld(), aFileName); |
534 | | if (aWarnDlg.run() != RET_OK) |
535 | | bAsLink=false; // don't store as link |
536 | | } |
537 | | } |
538 | | #endif |
539 | |
|
540 | 0 | SwWrtShell& rSh = GetWrtShell(); |
541 | 0 | rSh.LockPaint(LockPaintReason::InsertGraphic); |
542 | 0 | rSh.StartAction(); |
543 | |
|
544 | 0 | SwRewriter aRewriter; |
545 | 0 | aRewriter.AddRule(UndoArg1, SwResId(STR_GRAPHIC_DEFNAME)); |
546 | | |
547 | | // #i123922# determine if we really want to insert or replace the graphic at a selected object |
548 | 0 | const bool bReplaceMode(rSh.HasSelection() && SelectionType::Frame == rSh.GetSelectionType()); |
549 | |
|
550 | 0 | rSh.StartUndo(SwUndoId::INSERT, &aRewriter); |
551 | |
|
552 | 0 | ErrCode nError = InsertGraphic( aFileName, aFilterName, bAsLink, &GraphicFilter::GetGraphicFilter() ); |
553 | | |
554 | | // format not equal to current filter (with autodetection) |
555 | 0 | if( nError == ERRCODE_GRFILTER_FORMATERROR ) |
556 | 0 | nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() ); |
557 | | |
558 | | // #i123922# no new FrameFormat for replace mode, only when new object was created, |
559 | | // else this would reset the current setting for the frame holding the graphic |
560 | 0 | if ( !bReplaceMode && rSh.IsFrameSelected() ) |
561 | 0 | { |
562 | 0 | SwFrameFormat* pFormat = pDoc->FindFrameFormatByName( sGraphicFormat ); |
563 | 0 | if(!pFormat) |
564 | 0 | pFormat = pDoc->MakeFrameFormat(sGraphicFormat, |
565 | 0 | pDocShell->GetDoc()->GetDfltFrameFormat(), |
566 | 0 | false); |
567 | 0 | rSh.SetFrameFormat( pFormat ); |
568 | 0 | } |
569 | |
|
570 | 0 | TranslateId pResId; |
571 | 0 | if( nError == ERRCODE_GRFILTER_OPENERROR ) |
572 | 0 | pResId = STR_GRFILTER_OPENERROR; |
573 | 0 | else if( nError == ERRCODE_GRFILTER_IOERROR ) |
574 | 0 | pResId = STR_GRFILTER_IOERROR; |
575 | 0 | else if( nError ==ERRCODE_GRFILTER_FORMATERROR ) |
576 | 0 | pResId = STR_GRFILTER_FORMATERROR; |
577 | 0 | else if( nError ==ERRCODE_GRFILTER_VERSIONERROR ) |
578 | 0 | pResId = STR_GRFILTER_VERSIONERROR; |
579 | 0 | else if( nError ==ERRCODE_GRFILTER_FILTERERROR ) |
580 | 0 | pResId = STR_GRFILTER_FILTERERROR; |
581 | 0 | else if( nError ==ERRCODE_GRFILTER_TOOBIG ) |
582 | 0 | pResId = STR_GRFILTER_TOOBIG; |
583 | |
|
584 | 0 | rSh.EndAction(); |
585 | 0 | rSh.UnlockPaint(); |
586 | 0 | if (pResId) |
587 | 0 | { |
588 | 0 | if( bShowError ) |
589 | 0 | { |
590 | 0 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), |
591 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
592 | 0 | SwResId(pResId))); |
593 | 0 | xInfoBox->run(); |
594 | 0 | } |
595 | 0 | rReq.Ignore(); |
596 | 0 | } |
597 | 0 | else |
598 | 0 | { |
599 | | // set the specific graphic attributes to the graphic |
600 | 0 | bReturn = true; |
601 | 0 | AutoCaption( GRAPHIC_CAP ); |
602 | 0 | rReq.Done(); |
603 | 0 | } |
604 | |
|
605 | 0 | rSh.EndUndo(); // due to possible change of Shell |
606 | 0 | } |
607 | |
|
608 | 0 | return bReturn; |
609 | 0 | } |
610 | | |
611 | | void SwView::Execute(SfxRequest &rReq) |
612 | 0 | { |
613 | 0 | const sal_uInt16 nSlot = rReq.GetSlot(); |
614 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
615 | 0 | const SfxPoolItem* pItem; |
616 | 0 | bool bIgnore = false; |
617 | 0 | switch( nSlot ) |
618 | 0 | { |
619 | 0 | case SID_CREATE_SW_DRAWVIEW: |
620 | 0 | m_pWrtShell->getIDocumentDrawModelAccess().GetOrCreateDrawModel(); |
621 | 0 | break; |
622 | | |
623 | 0 | case FN_LINE_NUMBERING_DLG: |
624 | 0 | { |
625 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
626 | 0 | ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclSwViewDialog(*this)); |
627 | 0 | VclAbstractDialog::AsyncContext aContext; |
628 | 0 | aContext.maEndDialogFn = [](sal_Int32){}; |
629 | 0 | pDlg->StartExecuteAsync(aContext); |
630 | 0 | break; |
631 | 0 | } |
632 | 0 | case FN_EDIT_LINK_DLG: |
633 | 0 | EditLinkDlg(); |
634 | 0 | break; |
635 | 0 | case SID_REFRESH_VIEW: |
636 | 0 | GetEditWin().Invalidate(); |
637 | 0 | m_pWrtShell->Reformat(); |
638 | 0 | break; |
639 | 0 | case FN_PAGEUP: |
640 | 0 | case FN_PAGEUP_SEL: |
641 | 0 | case FN_PAGEDOWN: |
642 | 0 | case FN_PAGEDOWN_SEL: |
643 | 0 | { |
644 | 0 | tools::Rectangle aVis( GetVisArea() ); |
645 | 0 | SwEditWin& rTmpWin = GetEditWin(); |
646 | 0 | if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot ) |
647 | 0 | PageUpCursor(FN_PAGEUP_SEL == nSlot); |
648 | 0 | else |
649 | 0 | PageDownCursor(FN_PAGEDOWN_SEL == nSlot); |
650 | |
|
651 | 0 | rReq.SetReturnValue(SfxBoolItem(nSlot, |
652 | 0 | aVis != GetVisArea())); |
653 | | //#i42732# - notify the edit window that from now on we do not use the input language |
654 | 0 | rTmpWin.SetUseInputLanguage( false ); |
655 | 0 | } |
656 | 0 | break; |
657 | 0 | case SID_ZOOM_IN: |
658 | 0 | case SID_ZOOM_OUT: |
659 | 0 | { |
660 | 0 | sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); |
661 | 0 | if (SID_ZOOM_IN == nSlot) |
662 | 0 | nFact = basegfx::zoomtools::zoomIn(nFact); |
663 | 0 | else |
664 | 0 | nFact = basegfx::zoomtools::zoomOut(nFact); |
665 | 0 | SetZoom(SvxZoomType::PERCENT, nFact); |
666 | 0 | } |
667 | 0 | break; |
668 | 0 | case FN_TO_PREV_PAGE: |
669 | 0 | case FN_TO_NEXT_PAGE: |
670 | 0 | { |
671 | 0 | sal_uInt16 nPage = 0; |
672 | 0 | if (m_pWrtShell->IsCursorVisible()) |
673 | 0 | nPage = m_pWrtShell->GetCursor()->GetPageNum(); |
674 | 0 | else |
675 | 0 | { |
676 | 0 | SwFrame* pPageFrame = m_pWrtShell->Imp()->GetFirstVisPage(m_pWrtShell->GetOut()); |
677 | 0 | if (pPageFrame) |
678 | 0 | nPage = pPageFrame->GetPhyPageNum(); |
679 | 0 | } |
680 | 0 | if (nPage != 0) |
681 | 0 | { |
682 | 0 | sal_uInt16 nOldPage(nPage); |
683 | 0 | if (FN_TO_PREV_PAGE == nSlot && nPage > 1) |
684 | 0 | nPage--; |
685 | 0 | else if (FN_TO_NEXT_PAGE == nSlot && nPage < m_pWrtShell->GetPageCount()) |
686 | 0 | nPage++; |
687 | 0 | if (nPage != nOldPage) |
688 | 0 | { |
689 | 0 | m_pWrtShell->LockPaint(LockPaintReason::GotoPage); |
690 | 0 | if (IsDrawMode()) |
691 | 0 | LeaveDrawCreate(); |
692 | 0 | m_pWrtShell->EnterStdMode(); |
693 | 0 | m_pWrtShell->GotoPage(nPage, true); |
694 | | // set visible area (borrowed from SwView::PhyPageUp/Down) |
695 | 0 | const Point aPt(m_aVisArea.Left(), m_pWrtShell->GetPagePos(nPage).Y()); |
696 | 0 | Point aAlPt(AlignToPixel(aPt)); |
697 | 0 | if(aPt.Y() != aAlPt.Y()) |
698 | 0 | aAlPt.AdjustY(3 * GetEditWin().PixelToLogic(Size(0, 1)).Height()); |
699 | 0 | SetVisArea(aAlPt); |
700 | 0 | m_pWrtShell->UnlockPaint(); |
701 | 0 | } |
702 | 0 | } |
703 | 0 | } |
704 | 0 | break; |
705 | 0 | case FN_SELECTION_CYCLE: |
706 | 0 | { |
707 | 0 | if (m_pWrtShell->IsSelFrameMode()) |
708 | 0 | break; |
709 | 0 | if (!m_pWrtShell->IsStdMode()) |
710 | 0 | m_pWrtShell->EnterStdMode(); |
711 | 0 | SwShellCursor *pCursor = m_pWrtShell->SwCursorShell::GetCursor_(); |
712 | 0 | Point CurrMarkPt = pCursor->GetMkPos(); |
713 | 0 | Point CurrPointPt = pCursor->GetPtPos(); |
714 | 0 | sal_uInt16 nStep = m_aSelectCycle.nStep; |
715 | 0 | if (nStep && (CurrMarkPt != m_aSelectCycle.m_MarkPt || CurrPointPt != m_aSelectCycle.m_PointPt)) |
716 | 0 | nStep = 0; |
717 | 0 | switch(nStep) |
718 | 0 | { |
719 | 0 | case 0: |
720 | 0 | m_aSelectCycle.m_pInitialCursor = CurrPointPt; |
721 | 0 | m_pWrtShell->SwCursorShell::ClearMark(); |
722 | 0 | m_pWrtShell->SelWrd(&CurrPointPt); |
723 | 0 | break; |
724 | 0 | case 1: |
725 | 0 | m_pWrtShell->SelSentence(&CurrPointPt); |
726 | 0 | break; |
727 | 0 | case 2: |
728 | 0 | m_pWrtShell->SelPara(&CurrPointPt); |
729 | 0 | break; |
730 | 0 | case 3: |
731 | 0 | m_pWrtShell->SwCursorShell::ClearMark(); |
732 | 0 | m_pWrtShell->SwCursorShell::SetCursor(m_aSelectCycle.m_pInitialCursor); |
733 | 0 | break; |
734 | 0 | } |
735 | 0 | nStep++; |
736 | 0 | nStep %= 4; |
737 | 0 | pCursor = m_pWrtShell->SwCursorShell::GetCursor_(); |
738 | 0 | m_aSelectCycle.m_MarkPt = pCursor->GetMkPos(); |
739 | 0 | m_aSelectCycle.m_PointPt = pCursor->GetPtPos(); |
740 | 0 | m_aSelectCycle.nStep = nStep; |
741 | 0 | } |
742 | 0 | break; |
743 | 0 | case FN_REDLINE_ON: |
744 | 0 | case FN_TRACK_CHANGES_IN_THIS_VIEW: |
745 | 0 | case FN_TRACK_CHANGES_IN_ALL_VIEWS: |
746 | 0 | { |
747 | 0 | std::optional<bool> oOn; |
748 | 0 | if( pArgs && |
749 | 0 | SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )) |
750 | 0 | { |
751 | 0 | oOn = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
752 | 0 | } |
753 | 0 | else if (nSlot == FN_TRACK_CHANGES_IN_THIS_VIEW || nSlot == FN_TRACK_CHANGES_IN_ALL_VIEWS) |
754 | 0 | { |
755 | 0 | oOn = true; |
756 | 0 | } |
757 | |
|
758 | 0 | if (oOn.has_value()) |
759 | 0 | { |
760 | 0 | IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess(); |
761 | 0 | Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword(); |
762 | 0 | if( aPasswd.hasElements() ) |
763 | 0 | { |
764 | 0 | OSL_ENSURE( !oOn.value(), "SwView::Execute(): password set and redlining off doesn't match!" ); |
765 | | |
766 | | // xmlsec05: new password dialog |
767 | 0 | SfxPasswordDialog aPasswdDlg(GetFrameWeld()); |
768 | 0 | aPasswdDlg.SetMinLen(1); |
769 | | //#i69751# the result of Execute() can be ignored |
770 | 0 | (void)aPasswdDlg.run(); |
771 | 0 | OUString sNewPasswd(aPasswdDlg.GetPassword()); |
772 | | |
773 | | // password verification |
774 | 0 | bool bPasswordOk = false; |
775 | 0 | if (aPasswd.getLength() == 1 && aPasswd[0] == 1) |
776 | 0 | { |
777 | | // dummy RedlinePassword from OOXML import: get real password info |
778 | | // from the grab-bag to verify the password |
779 | 0 | const css::uno::Sequence< css::beans::PropertyValue > aDocumentProtection = |
780 | 0 | static_cast<SfxObjectShell*>(GetDocShell())-> |
781 | 0 | GetDocumentProtectionFromGrabBag(); |
782 | |
|
783 | 0 | bPasswordOk = |
784 | | // password is ok, if there is no DocumentProtection in the GrabBag, |
785 | | // i.e. the dummy RedlinePassword imported from an OpenDocument file |
786 | 0 | !aDocumentProtection.hasElements() || |
787 | | // verify password with the password info imported from OOXML |
788 | 0 | ::comphelper::DocPasswordHelper::IsModifyPasswordCorrect(sNewPasswd, |
789 | 0 | ::comphelper::DocPasswordHelper::ConvertPasswordInfo ( aDocumentProtection ) ); |
790 | 0 | } |
791 | 0 | else |
792 | 0 | { |
793 | | // the simplified RedlinePassword |
794 | 0 | Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword(); |
795 | 0 | SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); |
796 | 0 | bPasswordOk = SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd); |
797 | 0 | } |
798 | |
|
799 | 0 | if (bPasswordOk) |
800 | 0 | rIDRA.SetRedlinePassword(Sequence <sal_Int8> ()); |
801 | 0 | else |
802 | 0 | { // xmlsec05: message box for wrong password |
803 | 0 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr, |
804 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
805 | 0 | SfxResId(RID_SVXSTR_INCORRECT_PASSWORD))); |
806 | 0 | xInfoBox->run(); |
807 | 0 | break; |
808 | 0 | } |
809 | 0 | } |
810 | | |
811 | 0 | SwDocShell* pDocShell = GetDocShell(); |
812 | 0 | SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::AllViews; |
813 | 0 | if (nSlot == FN_TRACK_CHANGES_IN_THIS_VIEW) |
814 | 0 | { |
815 | 0 | eRedlineRecordingMode = SfxRedlineRecordingMode::ThisView; |
816 | 0 | } |
817 | 0 | pDocShell->SetChangeRecording( oOn.value(), /*bLockAllViews=*/true, eRedlineRecordingMode ); |
818 | | |
819 | | // Notify all view shells of this document, as the track changes mode is document-global. |
820 | 0 | for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(pDocShell); pViewFrame; pViewFrame = SfxViewFrame::GetNext(*pViewFrame, pDocShell)) |
821 | 0 | { |
822 | 0 | pViewFrame->GetBindings().Invalidate(FN_REDLINE_ON); |
823 | 0 | pViewFrame->GetBindings().Update(FN_REDLINE_ON); |
824 | 0 | pViewFrame->GetBindings().Invalidate(FN_TRACK_CHANGES_IN_THIS_VIEW); |
825 | 0 | pViewFrame->GetBindings().Update(FN_TRACK_CHANGES_IN_THIS_VIEW); |
826 | 0 | pViewFrame->GetBindings().Invalidate(FN_TRACK_CHANGES_IN_ALL_VIEWS); |
827 | 0 | pViewFrame->GetBindings().Update(FN_TRACK_CHANGES_IN_ALL_VIEWS); |
828 | 0 | } |
829 | 0 | } |
830 | 0 | } |
831 | 0 | break; |
832 | 0 | case FN_REDLINE_PROTECT : |
833 | 0 | { |
834 | 0 | IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess(); |
835 | 0 | Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword(); |
836 | 0 | if( pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ) |
837 | 0 | && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswd.hasElements() ) |
838 | 0 | break; |
839 | | |
840 | | // xmlsec05: new password dialog |
841 | | // message box for wrong password |
842 | 0 | SfxPasswordDialog aPasswdDlg(GetFrameWeld()); |
843 | 0 | aPasswdDlg.SetMinLen(1); |
844 | 0 | if (!aPasswd.hasElements()) |
845 | 0 | aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM); |
846 | 0 | if (aPasswdDlg.run()) |
847 | 0 | { |
848 | 0 | RedlineFlags nOn = RedlineFlags::On; |
849 | 0 | OUString sNewPasswd(aPasswdDlg.GetPassword()); |
850 | 0 | Sequence <sal_Int8> aNewPasswd = |
851 | 0 | rIDRA.GetRedlinePassword(); |
852 | 0 | SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd ); |
853 | 0 | if(!aPasswd.hasElements()) |
854 | 0 | { |
855 | 0 | rIDRA.SetRedlinePassword(aNewPasswd); |
856 | 0 | } |
857 | 0 | else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd)) |
858 | 0 | { |
859 | 0 | rIDRA.SetRedlinePassword(Sequence <sal_Int8> ()); |
860 | 0 | nOn = RedlineFlags::NONE; |
861 | 0 | } |
862 | 0 | const RedlineFlags nMode = rIDRA.GetRedlineFlags(); |
863 | 0 | m_pWrtShell->SetRedlineFlagsAndCheckInsMode( (nMode & ~RedlineFlags::On) | nOn); |
864 | 0 | rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, !(nMode&RedlineFlags::On) ) ); |
865 | 0 | } |
866 | 0 | else |
867 | 0 | bIgnore = true; |
868 | 0 | } |
869 | 0 | break; |
870 | 0 | case FN_REDLINE_SHOW: |
871 | |
|
872 | 0 | if( pArgs && |
873 | 0 | SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem)) |
874 | 0 | { |
875 | | // tdf#125754 avoid recursive layout |
876 | | // because all views share the layout, have to use AllAction |
877 | 0 | const bool bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
878 | 0 | m_pWrtShell->StartAllAction(); |
879 | | // always show redline insertions in Hide Changes mode |
880 | 0 | if ( m_pWrtShell->GetViewOptions()->IsShowChangesInMargin() && |
881 | 0 | m_pWrtShell->GetViewOptions()->IsShowChangesInMargin2() ) |
882 | 0 | { |
883 | 0 | GetDocShell()->GetDoc()->GetDocumentRedlineManager().HideAll(/*bDeletion=*/!bShow); |
884 | 0 | } |
885 | 0 | m_pWrtShell->GetLayout()->SetHideRedlines( !bShow ); |
886 | 0 | m_pWrtShell->EndAllAction(); |
887 | 0 | if (m_pWrtShell->IsRedlineOn()) |
888 | 0 | m_pWrtShell->SetInsMode(); |
889 | 0 | GetDocShell()->Broadcast(SfxHint(SfxHintId::SwRedlineShowChanged)); |
890 | 0 | } |
891 | 0 | break; |
892 | 0 | case FN_MAILMERGE_SENDMAIL_CHILDWINDOW: |
893 | 0 | case FN_REDLINE_ACCEPT: |
894 | 0 | GetViewFrame().ToggleChildWindow(nSlot); |
895 | 0 | break; |
896 | 0 | case FN_REDLINE_ACCEPT_DIRECT: |
897 | 0 | case FN_REDLINE_REJECT_DIRECT: |
898 | 0 | case FN_REDLINE_ACCEPT_TONEXT: |
899 | 0 | case FN_REDLINE_REJECT_TONEXT: |
900 | 0 | case FN_REDLINE_REINSTATE_DIRECT: |
901 | 0 | case FN_REDLINE_REINSTATE_TONEXT: |
902 | 0 | { |
903 | 0 | SwDoc *pDoc = m_pWrtShell->GetDoc(); |
904 | 0 | SwPaM *pCursor = m_pWrtShell->GetCursor(); |
905 | 0 | const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); |
906 | 0 | SwRedlineTable::size_type nRedline = SwRedlineTable::npos; |
907 | 0 | if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET) |
908 | 0 | { |
909 | 0 | const sal_Int64 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); |
910 | 0 | for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i) |
911 | 0 | { |
912 | 0 | if (nChangeId == rRedlineTable[i]->GetId()) |
913 | 0 | nRedline = i; |
914 | 0 | } |
915 | 0 | } |
916 | |
|
917 | 0 | if( pCursor->HasMark() && nRedline == SwRedlineTable::npos) |
918 | 0 | { |
919 | 0 | bool bAccept = FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot; |
920 | 0 | bool bReinstate = nSlot == FN_REDLINE_REINSTATE_DIRECT || nSlot == FN_REDLINE_REINSTATE_TONEXT; |
921 | 0 | SwUndoId eUndoId = bAccept ? SwUndoId::ACCEPT_REDLINE : SwUndoId::REJECT_REDLINE; |
922 | 0 | SwWrtShell& rSh = GetWrtShell(); |
923 | 0 | SwRewriter aRewriter; |
924 | 0 | bool bTableSelection = rSh.IsTableMode(); |
925 | 0 | if ( bTableSelection ) |
926 | 0 | { |
927 | 0 | aRewriter.AddRule(UndoArg1, SwResId( STR_REDLINE_TABLECHG )); |
928 | 0 | rSh.StartUndo( eUndoId, &aRewriter); |
929 | 0 | } |
930 | 0 | if ( bAccept ) |
931 | 0 | m_pWrtShell->AcceptRedlinesInSelection(); |
932 | 0 | else if (bReinstate) |
933 | 0 | { |
934 | 0 | m_pWrtShell->ReinstateRedlinesInSelection(); |
935 | 0 | } |
936 | 0 | else |
937 | 0 | m_pWrtShell->RejectRedlinesInSelection(); |
938 | 0 | if ( bTableSelection ) |
939 | 0 | rSh.EndUndo( eUndoId, &aRewriter); |
940 | 0 | } |
941 | 0 | else |
942 | 0 | { |
943 | | // We check for a redline at the start of the selection/cursor, not the point. |
944 | | // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the |
945 | | // point at the *end* of the redline and the mark at the start (so GetRedline |
946 | | // would return NULL if called on the point) |
947 | 0 | const SwRangeRedline* pRedline = nullptr; |
948 | 0 | if (nRedline != SwRedlineTable::npos) |
949 | 0 | { |
950 | | // A redline was explicitly requested by specifying an |
951 | | // index, don't guess based on the cursor position. |
952 | |
|
953 | 0 | if (nRedline < rRedlineTable.size()) |
954 | 0 | pRedline = rRedlineTable[nRedline]; |
955 | 0 | } |
956 | 0 | else |
957 | 0 | pRedline = pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline); |
958 | | |
959 | | // accept or reject table row deletion or insertion |
960 | 0 | bool bTableChange = false; |
961 | 0 | if ( !pRedline && m_pWrtShell->IsCursorInTable() ) |
962 | 0 | { |
963 | 0 | nRedline = 0; |
964 | 0 | auto pTabBox = pCursor->Start()->GetNode().GetTableBox(); |
965 | 0 | auto pTabLine = pTabBox->GetUpper(); |
966 | 0 | const SwTableNode* pTableNd = pCursor->Start()->GetNode().FindTableNode(); |
967 | |
|
968 | 0 | if ( RedlineType::None != pTabLine->GetRedlineType() ) |
969 | 0 | { |
970 | 0 | nRedline = pTabLine->UpdateTextChangesOnly(nRedline); |
971 | |
|
972 | 0 | if ( nRedline != SwRedlineTable::npos ) |
973 | 0 | { |
974 | 0 | bTableChange = true; |
975 | |
|
976 | 0 | SwWrtShell& rSh = GetWrtShell(); |
977 | 0 | SwRewriter aRewriter; |
978 | |
|
979 | 0 | aRewriter.AddRule(UndoArg1, SwResId( |
980 | 0 | rRedlineTable[nRedline]->GetType() == RedlineType::Delete |
981 | 0 | ? STR_REDLINE_TABLE_ROW_DELETE |
982 | 0 | : STR_REDLINE_TABLE_ROW_INSERT )); |
983 | |
|
984 | 0 | SwUndoId eUndoId = |
985 | 0 | (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot) |
986 | 0 | ? SwUndoId::ACCEPT_REDLINE |
987 | 0 | : SwUndoId::REJECT_REDLINE; |
988 | |
|
989 | 0 | rSh.StartUndo( eUndoId, &aRewriter); |
990 | 0 | while ( nRedline != SwRedlineTable::npos && nRedline < rRedlineTable.size() ) |
991 | 0 | { |
992 | 0 | pRedline = rRedlineTable[nRedline]; |
993 | | |
994 | | // until next redline is not in the same row |
995 | 0 | SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox(); |
996 | 0 | if ( !pTableBox || pTableBox->GetUpper() != pTabLine ) |
997 | 0 | break; |
998 | | |
999 | 0 | if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot) |
1000 | 0 | m_pWrtShell->AcceptRedline(nRedline); |
1001 | 0 | else |
1002 | 0 | m_pWrtShell->RejectRedline(nRedline); |
1003 | 0 | } |
1004 | 0 | rSh.EndUndo( eUndoId, &aRewriter); |
1005 | 0 | } |
1006 | 0 | } |
1007 | 0 | else if ( RedlineType::None != pTabBox->GetRedlineType() ) |
1008 | 0 | { |
1009 | 0 | nRedline = pTabBox->GetRedline(); |
1010 | |
|
1011 | 0 | if ( nRedline != SwRedlineTable::npos ) |
1012 | 0 | { |
1013 | 0 | bTableChange = true; |
1014 | |
|
1015 | 0 | SwWrtShell& rSh = GetWrtShell(); |
1016 | 0 | SwRewriter aRewriter; |
1017 | |
|
1018 | 0 | aRewriter.AddRule(UndoArg1, SwResId( |
1019 | 0 | rRedlineTable[nRedline]->GetType() == RedlineType::Delete |
1020 | 0 | ? STR_REDLINE_TABLE_COLUMN_DELETE |
1021 | 0 | : STR_REDLINE_TABLE_COLUMN_INSERT )); |
1022 | |
|
1023 | 0 | SwUndoId eUndoId = |
1024 | 0 | (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot) |
1025 | 0 | ? SwUndoId::ACCEPT_REDLINE |
1026 | 0 | : SwUndoId::REJECT_REDLINE; |
1027 | | |
1028 | | // change only the cells with the same data |
1029 | 0 | SwRedlineData aData(rRedlineTable[nRedline]->GetRedlineData(0)); |
1030 | | |
1031 | | // start from the first redline of the table to handle all the |
1032 | | // cells of the changed column(s) |
1033 | 0 | while ( nRedline ) |
1034 | 0 | { |
1035 | 0 | pRedline = rRedlineTable[nRedline-1]; |
1036 | 0 | SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox(); |
1037 | 0 | SwTableNode* pTableNode = pRedline->Start()->GetNode().FindTableNode(); |
1038 | | |
1039 | | // previous redline is not in the same table |
1040 | 0 | if ( !pTableBox || pTableNode != pTableNd ) |
1041 | 0 | break; |
1042 | | |
1043 | 0 | --nRedline; |
1044 | 0 | } |
1045 | |
|
1046 | 0 | rSh.StartUndo( eUndoId, &aRewriter); |
1047 | 0 | while ( nRedline != SwRedlineTable::npos && nRedline < rRedlineTable.size() ) |
1048 | 0 | { |
1049 | 0 | pRedline = rRedlineTable[nRedline]; |
1050 | | |
1051 | | // until next redline is not in the same table |
1052 | 0 | SwTableBox* pTableBox = pRedline->Start()->GetNode().GetTableBox(); |
1053 | 0 | SwTableNode* pTableNode = pRedline->Start()->GetNode().FindTableNode(); |
1054 | 0 | if ( !pTableBox || pTableNode != pTableNd ) |
1055 | 0 | break; |
1056 | | |
1057 | | // skip cells which are not from the same author, same type change |
1058 | | // or timestamp, i.e. keep only the cells of the same tracked |
1059 | | // column insertion or deletion |
1060 | 0 | if ( !pRedline->GetRedlineData(0).CanCombine(aData) || |
1061 | | // not a tracked cell change |
1062 | 0 | RedlineType::None == pTableBox->GetRedlineType() ) |
1063 | 0 | { |
1064 | 0 | ++nRedline; |
1065 | 0 | continue; |
1066 | 0 | } |
1067 | | |
1068 | 0 | if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot) |
1069 | 0 | m_pWrtShell->AcceptRedline(nRedline); |
1070 | 0 | else |
1071 | 0 | m_pWrtShell->RejectRedline(nRedline); |
1072 | 0 | } |
1073 | 0 | rSh.EndUndo( eUndoId, &aRewriter); |
1074 | 0 | } |
1075 | 0 | } |
1076 | 0 | } |
1077 | 0 | else |
1078 | 0 | { |
1079 | 0 | assert(pRedline != nullptr); |
1080 | 0 | } |
1081 | |
|
1082 | 0 | if (pRedline && !bTableChange) |
1083 | 0 | { |
1084 | 0 | if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot) |
1085 | 0 | m_pWrtShell->AcceptRedline(nRedline); |
1086 | 0 | else if (nSlot == FN_REDLINE_REINSTATE_DIRECT || nSlot == FN_REDLINE_REINSTATE_TONEXT) |
1087 | 0 | { |
1088 | 0 | m_pWrtShell->ReinstateRedline(nRedline); |
1089 | 0 | } |
1090 | 0 | else |
1091 | 0 | m_pWrtShell->RejectRedline(nRedline); |
1092 | 0 | } |
1093 | 0 | } |
1094 | 0 | switch (nSlot) |
1095 | 0 | { |
1096 | 0 | case FN_REDLINE_ACCEPT_TONEXT: |
1097 | 0 | case FN_REDLINE_REJECT_TONEXT: |
1098 | 0 | case FN_REDLINE_REINSTATE_TONEXT: |
1099 | | // Go to next change after accepting or rejecting one (tdf#101977) |
1100 | 0 | GetViewFrame().GetDispatcher()->Execute(FN_REDLINE_NEXT_CHANGE, SfxCallMode::ASYNCHRON); |
1101 | 0 | } |
1102 | 0 | } |
1103 | 0 | break; |
1104 | | |
1105 | 0 | case FN_REDLINE_NEXT_CHANGE: |
1106 | 0 | { |
1107 | | // If a parameter is provided, try going to the nth change, not to |
1108 | | // the next one. |
1109 | 0 | SwDoc* pDoc = m_pWrtShell->GetDoc(); |
1110 | 0 | const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); |
1111 | 0 | SwRedlineTable::size_type nRedline = SwRedlineTable::npos; |
1112 | 0 | if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET) |
1113 | 0 | { |
1114 | 0 | const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue(); |
1115 | 0 | for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i) |
1116 | 0 | { |
1117 | 0 | if (nChangeId == rRedlineTable[i]->GetId()) |
1118 | 0 | nRedline = i; |
1119 | 0 | } |
1120 | 0 | } |
1121 | |
|
1122 | 0 | const SwRangeRedline *pNext = nullptr; |
1123 | 0 | if (nRedline < rRedlineTable.size()) |
1124 | 0 | pNext = m_pWrtShell->GotoRedline(nRedline, true); |
1125 | 0 | else |
1126 | 0 | pNext = m_pWrtShell->SelNextRedline(); |
1127 | |
|
1128 | 0 | if (pNext) |
1129 | 0 | { |
1130 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
1131 | 0 | { |
1132 | 0 | sal_uInt32 nRedlineId = pNext->GetId(); |
1133 | 0 | OString aPayload(".uno:CurrentTrackedChangeId=" + OString::number(nRedlineId)); |
1134 | 0 | libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload); |
1135 | 0 | } |
1136 | |
|
1137 | 0 | m_pWrtShell->SetInSelect(); |
1138 | 0 | } |
1139 | |
|
1140 | 0 | } |
1141 | 0 | break; |
1142 | | |
1143 | 0 | case FN_REDLINE_PREV_CHANGE: |
1144 | 0 | { |
1145 | 0 | const SwRangeRedline *pPrev = m_pWrtShell->SelPrevRedline(); |
1146 | |
|
1147 | 0 | if (pPrev) |
1148 | 0 | { |
1149 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
1150 | 0 | { |
1151 | 0 | sal_uInt32 nRedlineId = pPrev->GetId(); |
1152 | 0 | OString aPayload(".uno:CurrentTrackedChangeId=" + OString::number(nRedlineId)); |
1153 | 0 | libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload); |
1154 | 0 | } |
1155 | |
|
1156 | 0 | m_pWrtShell->SetInSelect(); |
1157 | 0 | } |
1158 | 0 | } |
1159 | 0 | break; |
1160 | | |
1161 | 0 | case SID_DOCUMENT_COMPARE: |
1162 | 0 | case SID_DOCUMENT_MERGE: |
1163 | 0 | { |
1164 | 0 | OUString sFileName, sFilterName; |
1165 | 0 | sal_Int16 nVersion = 0; |
1166 | 0 | bool bHasFileName = false; |
1167 | 0 | m_pViewImpl->SetParam( 0 ); |
1168 | 0 | bool bNoAcceptDialog = false; |
1169 | |
|
1170 | 0 | if( pArgs ) |
1171 | 0 | { |
1172 | 0 | if( const SfxStringItem* pFileItem = pArgs->GetItemIfSet( SID_FILE_NAME, false )) |
1173 | 0 | sFileName = pFileItem->GetValue(); |
1174 | 0 | bHasFileName = !sFileName.isEmpty(); |
1175 | |
|
1176 | 0 | if( const SfxStringItem* pFilterNameItem = pArgs->GetItemIfSet( SID_FILTER_NAME, false )) |
1177 | 0 | sFilterName = pFilterNameItem->GetValue(); |
1178 | |
|
1179 | 0 | if( const SfxInt16Item* pVersionItem = pArgs->GetItemIfSet( SID_VERSION, false )) |
1180 | 0 | { |
1181 | 0 | nVersion = pVersionItem->GetValue(); |
1182 | 0 | m_pViewImpl->SetParam( nVersion ); |
1183 | 0 | } |
1184 | 0 | if( const SfxBoolItem* pDialogItem = pArgs->GetItemIfSet( SID_NO_ACCEPT_DIALOG, false )) |
1185 | 0 | { |
1186 | 0 | bNoAcceptDialog = pDialogItem->GetValue(); |
1187 | 0 | } |
1188 | 0 | } |
1189 | |
|
1190 | 0 | m_pViewImpl->InitRequest( rReq ); |
1191 | 0 | tools::Long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion ); |
1192 | |
|
1193 | 0 | if ( bHasFileName ) |
1194 | 0 | { |
1195 | 0 | rReq.SetReturnValue( SfxInt32Item( nSlot, nFound )); |
1196 | |
|
1197 | 0 | if (nFound > 0 && !bNoAcceptDialog) // show Redline browser |
1198 | 0 | { |
1199 | 0 | SfxViewFrame& rVFrame = GetViewFrame(); |
1200 | 0 | rVFrame.ShowChildWindow(FN_REDLINE_ACCEPT); |
1201 | | |
1202 | | // re-initialize the Redline dialog |
1203 | 0 | const sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId(); |
1204 | 0 | SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>( |
1205 | 0 | rVFrame.GetChildWindow(nId)); |
1206 | 0 | if (pRed) |
1207 | 0 | pRed->ReInitDlg(); |
1208 | 0 | } |
1209 | 0 | } |
1210 | 0 | else |
1211 | 0 | bIgnore = true; |
1212 | 0 | } |
1213 | 0 | break; |
1214 | 0 | case FN_SYNC_LABELS: |
1215 | 0 | GetViewFrame().ShowChildWindow(nSlot); |
1216 | 0 | break; |
1217 | 0 | case FN_ESCAPE: |
1218 | 0 | { |
1219 | 0 | if ( m_pWrtShell->HasDrawViewDrag() ) |
1220 | 0 | { |
1221 | 0 | m_pWrtShell->BreakDrag(); |
1222 | 0 | m_pWrtShell->EnterSelFrameMode(); |
1223 | 0 | } |
1224 | 0 | else if ( m_pWrtShell->IsDrawCreate() ) |
1225 | 0 | { |
1226 | 0 | GetDrawFuncPtr()->BreakCreate(); |
1227 | 0 | AttrChangedNotify(nullptr); // shell change if needed |
1228 | 0 | } |
1229 | 0 | else if ( m_pWrtShell->HasSelection() || IsDrawMode() ) |
1230 | 0 | { |
1231 | 0 | SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : nullptr; |
1232 | 0 | if(pSdrView && pSdrView->GetMarkedObjectList().GetMarkCount() != 0 && |
1233 | 0 | pSdrView->GetHdlList().GetFocusHdl()) |
1234 | 0 | { |
1235 | 0 | const_cast<SdrHdlList&>(pSdrView->GetHdlList()).ResetFocusHdl(); |
1236 | 0 | } |
1237 | 0 | else |
1238 | 0 | { |
1239 | 0 | if(pSdrView) |
1240 | 0 | { |
1241 | 0 | LeaveDrawCreate(); |
1242 | 0 | Point aPt(LONG_MIN, LONG_MIN); |
1243 | | //go out of the frame |
1244 | 0 | m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME); |
1245 | 0 | SfxBindings& rBind = GetViewFrame().GetBindings(); |
1246 | 0 | rBind.Invalidate( SID_ATTR_SIZE ); |
1247 | 0 | } |
1248 | 0 | m_pWrtShell->EnterStdMode(); |
1249 | 0 | AttrChangedNotify(nullptr); // shell change if necessary |
1250 | 0 | } |
1251 | 0 | } |
1252 | 0 | else if ( GetEditWin().GetApplyTemplate() ) |
1253 | 0 | { |
1254 | 0 | GetEditWin().SetApplyTemplate(SwApplyTemplate()); |
1255 | 0 | } |
1256 | 0 | else if( static_cast<SfxObjectShell*>(GetDocShell())->IsInPlaceActive() ) |
1257 | 0 | { |
1258 | 0 | Escape(); |
1259 | 0 | } |
1260 | 0 | else if ( GetEditWin().IsChainMode() ) |
1261 | 0 | { |
1262 | 0 | GetEditWin().SetChainMode( false ); |
1263 | 0 | } |
1264 | 0 | else if( m_pWrtShell->GetFlyFrameFormat() ) |
1265 | 0 | { |
1266 | 0 | const SwFrameFormat* pFormat = m_pWrtShell->GetFlyFrameFormat(); |
1267 | 0 | if(m_pWrtShell->GotoFly( pFormat->GetName(), FLYCNTTYPE_FRM )) |
1268 | 0 | { |
1269 | 0 | m_pWrtShell->HideCursor(); |
1270 | 0 | m_pWrtShell->EnterSelFrameMode(); |
1271 | 0 | } |
1272 | 0 | } |
1273 | 0 | else |
1274 | 0 | { |
1275 | 0 | SfxBoolItem aItem( SID_WIN_FULLSCREEN, false ); |
1276 | 0 | GetViewFrame().GetDispatcher()->ExecuteList(SID_WIN_FULLSCREEN, |
1277 | 0 | SfxCallMode::RECORD, { &aItem }); |
1278 | 0 | bIgnore = true; |
1279 | 0 | } |
1280 | 0 | } |
1281 | 0 | break; |
1282 | 0 | case SID_ATTR_BORDER_INNER: |
1283 | 0 | case SID_ATTR_BORDER_OUTER: |
1284 | 0 | case SID_ATTR_BORDER_SHADOW: |
1285 | 0 | if(pArgs) |
1286 | 0 | m_pWrtShell->SetAttrSet(*pArgs); |
1287 | 0 | break; |
1288 | | |
1289 | 0 | case SID_ATTR_PAGE: |
1290 | 0 | case SID_ATTR_PAGE_SIZE: |
1291 | 0 | case SID_ATTR_PAGE_MAXSIZE: |
1292 | 0 | case SID_ATTR_PAGE_PAPERBIN: |
1293 | 0 | case SID_ATTR_PAGE_EXT1: |
1294 | 0 | case FN_PARAM_FTN_INFO: |
1295 | 0 | case SID_ATTR_PAGE_ORIENTATION: |
1296 | 0 | { |
1297 | 0 | if(pArgs) |
1298 | 0 | { |
1299 | 0 | const size_t nCurIdx = m_pWrtShell->GetCurPageDesc(); |
1300 | 0 | SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) ); |
1301 | 0 | ::ItemSetToPageDesc( *pArgs, aPageDesc ); |
1302 | | // change the descriptor of the core |
1303 | 0 | m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc ); |
1304 | 0 | } |
1305 | 0 | } |
1306 | 0 | break; |
1307 | 0 | case SID_GO_TO_PAGE: |
1308 | 0 | { |
1309 | 0 | sal_uInt16 nPhyPage, nVirPage; |
1310 | 0 | GetWrtShell().GetPageNum(nPhyPage, nVirPage); |
1311 | |
|
1312 | 0 | std::shared_ptr<SfxRequest> xRequest = std::make_shared<SfxRequest>(rReq); |
1313 | 0 | rReq.Ignore(); |
1314 | |
|
1315 | 0 | auto xDialog = std::make_shared<svx::GotoPageDlg>( |
1316 | 0 | GetViewFrame().GetFrameWeld(), SwResId(STR_GOTO_PAGE_DLG_TITLE), |
1317 | 0 | SwResId(ST_PGE) + ":", nPhyPage, GetWrtShell().GetPageCnt()); |
1318 | 0 | weld::DialogController::runAsync(xDialog,[this, xDialog, xRequest=std::move(xRequest)](sal_uInt32 nResult) { |
1319 | 0 | if (nResult == RET_OK) |
1320 | 0 | GetWrtShell().GotoPage(xDialog->GetPageSelection(), true); |
1321 | |
|
1322 | 0 | xRequest->Done(); |
1323 | 0 | }); |
1324 | 0 | } |
1325 | 0 | break; |
1326 | 0 | case FN_EDIT_CURRENT_TOX: |
1327 | 0 | { |
1328 | 0 | GetViewFrame().GetDispatcher()->Execute( |
1329 | 0 | FN_INSERT_MULTI_TOX, SfxCallMode::ASYNCHRON); |
1330 | 0 | } |
1331 | 0 | break; |
1332 | 0 | case FN_UPDATE_CUR_TOX: |
1333 | 0 | { |
1334 | 0 | const SwTOXBase* pBase = m_pWrtShell->GetCurTOX(); |
1335 | 0 | if(pBase) |
1336 | 0 | { |
1337 | | // tdf#106374: don't jump view on the update |
1338 | 0 | const bool bWasLocked = m_pWrtShell->IsViewLocked(); |
1339 | 0 | m_pWrtShell->LockView(true); |
1340 | 0 | m_pWrtShell->StartAction(); |
1341 | 0 | if(TOX_INDEX == pBase->GetType()) |
1342 | 0 | m_pWrtShell->ApplyAutoMark(); |
1343 | 0 | m_pWrtShell->UpdateTableOf( *pBase ); |
1344 | 0 | m_pWrtShell->EndAction(); |
1345 | 0 | if (!bWasLocked) |
1346 | 0 | m_pWrtShell->LockView(false); |
1347 | 0 | } |
1348 | 0 | } |
1349 | 0 | break; |
1350 | 0 | case FN_UPDATE_TOX: |
1351 | 0 | { |
1352 | 0 | m_pWrtShell->StartAction(); |
1353 | 0 | m_pWrtShell->EnterStdMode(); |
1354 | 0 | bool bOldCursorInReadOnly = m_pWrtShell->IsReadOnlyAvailable(); |
1355 | 0 | m_pWrtShell->SetReadOnlyAvailable( true ); |
1356 | |
|
1357 | 0 | for( int i = 0; i < 2; ++i ) |
1358 | 0 | { |
1359 | 0 | if( m_pWrtShell->GetTOXCount() == 1 ) |
1360 | 0 | ++i; |
1361 | |
|
1362 | 0 | while( m_pWrtShell->GotoPrevTOXBase() ) |
1363 | 0 | ; // jump to the first "table of ..." |
1364 | | |
1365 | | // if we are not in one, jump to next |
1366 | 0 | const SwTOXBase* pBase = m_pWrtShell->GetCurTOX(); |
1367 | 0 | if( !pBase ) |
1368 | 0 | { |
1369 | 0 | if (m_pWrtShell->GotoNextTOXBase()) |
1370 | 0 | pBase = m_pWrtShell->GetCurTOX(); |
1371 | 0 | } |
1372 | |
|
1373 | 0 | bool bAutoMarkApplied = false; |
1374 | 0 | while( pBase ) |
1375 | 0 | { |
1376 | 0 | if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied) |
1377 | 0 | { |
1378 | 0 | m_pWrtShell->ApplyAutoMark(); |
1379 | 0 | bAutoMarkApplied = true; |
1380 | 0 | } |
1381 | | // pBase is needed only for the interface. Should be changed in future! (JP 1996) |
1382 | 0 | m_pWrtShell->UpdateTableOf( *pBase ); |
1383 | |
|
1384 | 0 | if( m_pWrtShell->GotoNextTOXBase() ) |
1385 | 0 | pBase = m_pWrtShell->GetCurTOX(); |
1386 | 0 | else |
1387 | 0 | pBase = nullptr; |
1388 | 0 | } |
1389 | 0 | } |
1390 | 0 | m_pWrtShell->SetReadOnlyAvailable( bOldCursorInReadOnly ); |
1391 | 0 | m_pWrtShell->EndAction(); |
1392 | 0 | } |
1393 | 0 | break; |
1394 | 0 | case SID_ATTR_BRUSH: |
1395 | 0 | { |
1396 | 0 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_BACKGROUND, false, &pItem)) |
1397 | 0 | { |
1398 | 0 | const size_t nCurIdx = m_pWrtShell->GetCurPageDesc(); |
1399 | 0 | SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx )); |
1400 | 0 | SwFrameFormat& rMaster = aDesc.GetMaster(); |
1401 | 0 | rMaster.SetFormatAttr(*pItem); |
1402 | 0 | m_pWrtShell->ChgPageDesc( nCurIdx, aDesc); |
1403 | 0 | } |
1404 | 0 | } |
1405 | 0 | break; |
1406 | 0 | case SID_CLEARHISTORY: |
1407 | 0 | { |
1408 | 0 | m_pWrtShell->DelAllUndoObj(); |
1409 | 0 | } |
1410 | 0 | break; |
1411 | 0 | case SID_UNDO: |
1412 | 0 | { |
1413 | 0 | m_pShell->ExecuteSlot(rReq); |
1414 | 0 | } |
1415 | 0 | break; |
1416 | 0 | #if defined(_WIN32) || defined UNX |
1417 | 0 | case SID_TWAIN_SELECT: |
1418 | 0 | case SID_TWAIN_TRANSFER: |
1419 | 0 | GetViewImpl()->ExecuteScan( rReq ); |
1420 | 0 | break; |
1421 | 0 | #endif |
1422 | | |
1423 | 0 | case SID_ATTR_DEFTABSTOP: |
1424 | 0 | { |
1425 | 0 | const SfxUInt16Item* pTabStopItem = nullptr; |
1426 | 0 | if(pArgs && (pTabStopItem = pArgs->GetItemIfSet(SID_ATTR_DEFTABSTOP, false))) |
1427 | 0 | { |
1428 | 0 | SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP ); |
1429 | 0 | const sal_uInt16 nTab = pTabStopItem->GetValue(); |
1430 | 0 | MakeDefTabs( nTab, aDefTabs ); |
1431 | 0 | m_pWrtShell->SetDefault( aDefTabs ); |
1432 | 0 | } |
1433 | 0 | } |
1434 | 0 | break; |
1435 | 0 | case SID_ATTR_LANGUAGE : |
1436 | 0 | { |
1437 | 0 | const SvxLanguageItem* pLangItem; |
1438 | 0 | if(pArgs && (pLangItem = pArgs->GetItemIfSet(SID_ATTR_LANGUAGE, false))) |
1439 | 0 | { |
1440 | 0 | SvxLanguageItem aLang(pLangItem->GetLanguage(), RES_CHRATR_LANGUAGE); |
1441 | 0 | m_pWrtShell->SetDefault( aLang ); |
1442 | 0 | lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_LANGUAGE ); |
1443 | 0 | } |
1444 | 0 | } |
1445 | 0 | break; |
1446 | 0 | case SID_ATTR_CHAR_CTL_LANGUAGE: |
1447 | 0 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, false, &pItem)) |
1448 | 0 | { |
1449 | 0 | m_pWrtShell->SetDefault( *pItem ); |
1450 | 0 | lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CTL_LANGUAGE ); |
1451 | 0 | } |
1452 | 0 | break; |
1453 | 0 | case SID_ATTR_CHAR_CJK_LANGUAGE: |
1454 | 0 | if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, false, &pItem)) |
1455 | 0 | { |
1456 | 0 | m_pWrtShell->SetDefault( *pItem ); |
1457 | 0 | lcl_SetAllTextToDefaultLanguage( *m_pWrtShell, RES_CHRATR_CJK_LANGUAGE ); |
1458 | 0 | } |
1459 | 0 | break; |
1460 | 0 | case FN_OUTLINE_LEVELS_SHOWN: |
1461 | 0 | { |
1462 | 0 | SwWrtShell& rSh = GetWrtShell(); |
1463 | 0 | int nOutlineLevel = -1; |
1464 | 0 | auto nOutlinePos = rSh.GetOutlinePos(); |
1465 | 0 | if (nOutlinePos != SwOutlineNodes::npos) |
1466 | 0 | nOutlineLevel = rSh.getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos); |
1467 | 0 | SwNumberInputDlg aDlg(GetViewFrame().GetFrameWeld(), |
1468 | 0 | SwResId(STR_OUTLINE_LEVELS_SHOWN_TITLE), |
1469 | 0 | SwResId(STR_OUTLINE_LEVELS_SHOWN_SPIN_LABEL), |
1470 | 0 | nOutlineLevel + 1, 1, 10, |
1471 | 0 | SwResId(STR_OUTLINE_LEVELS_SHOWN_HELP_LABEL)); |
1472 | 0 | if (aDlg.run() == RET_OK) |
1473 | 0 | rSh.MakeOutlineLevelsVisible(aDlg.GetNumber()); |
1474 | 0 | } |
1475 | 0 | break; |
1476 | 0 | case FN_TOGGLE_OUTLINE_CONTENT_VISIBILITY: |
1477 | 0 | { |
1478 | 0 | size_t nPos(m_pWrtShell->GetOutlinePos()); |
1479 | 0 | if (nPos != SwOutlineNodes::npos) |
1480 | 0 | GetEditWin().ToggleOutlineContentVisibility(nPos, false); |
1481 | 0 | } |
1482 | 0 | break; |
1483 | 0 | case FN_NAV_ELEMENT: |
1484 | 0 | { |
1485 | 0 | pArgs->GetItemState(GetPool().GetWhichIDFromSlotID(FN_NAV_ELEMENT), false, &pItem); |
1486 | 0 | if(pItem) |
1487 | 0 | { |
1488 | 0 | SvxSearchDialogWrapper::SetSearchLabel(SearchLabel::Empty); |
1489 | 0 | sal_uInt32 nMoveType(static_cast<const SfxUInt32Item*>(pItem)->GetValue()); |
1490 | 0 | SwView::SetMoveType(nMoveType); |
1491 | 0 | } |
1492 | 0 | } |
1493 | 0 | break; |
1494 | 0 | case FN_SCROLL_PREV: |
1495 | 0 | case FN_SCROLL_NEXT: |
1496 | 0 | { |
1497 | 0 | bool *pbNext = new bool(true); |
1498 | 0 | if (nSlot == FN_SCROLL_PREV) |
1499 | 0 | *pbNext = false; |
1500 | 0 | MoveNavigationHdl(pbNext); |
1501 | 0 | } |
1502 | 0 | break; |
1503 | 0 | case SID_JUMPTOMARK: |
1504 | 0 | if( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_JUMPTOMARK, false, &pItem)) |
1505 | 0 | JumpToSwMark( SwMarkName(static_cast<const SfxStringItem*>(pItem)->GetValue()) ); |
1506 | 0 | break; |
1507 | 0 | case SID_GALLERY : |
1508 | | // First make sure that the sidebar is visible |
1509 | 0 | GetViewFrame().ShowChildWindow(SID_SIDEBAR); |
1510 | |
|
1511 | 0 | ::sfx2::sidebar::Sidebar::ShowPanel( |
1512 | 0 | u"GalleryPanel", |
1513 | 0 | GetViewFrame().GetFrame().GetFrameInterface()); |
1514 | 0 | break; |
1515 | 0 | case SID_AVMEDIA_PLAYER : |
1516 | 0 | GetViewFrame().ChildWindowExecute(rReq); |
1517 | 0 | break; |
1518 | 0 | case SID_VIEW_DATA_SOURCE_BROWSER: |
1519 | 0 | { |
1520 | 0 | SfxViewFrame& rVFrame = GetViewFrame(); |
1521 | 0 | rVFrame.ChildWindowExecute(rReq); |
1522 | 0 | if(rVFrame.HasChildWindow(SID_BROWSER)) |
1523 | 0 | { |
1524 | 0 | const SwDBData& rData = GetWrtShell().GetDBData(); |
1525 | 0 | SwModule::ShowDBObj(*this, rData); |
1526 | 0 | } |
1527 | 0 | } |
1528 | 0 | break; |
1529 | 0 | case FN_INSERT_FIELD_DATA_ONLY: |
1530 | 0 | { |
1531 | 0 | bool bShow = false; |
1532 | 0 | if( pArgs && |
1533 | 0 | SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )) |
1534 | 0 | bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue(); |
1535 | 0 | if((bShow && m_bInMailMerge) != GetViewFrame().HasChildWindow(nSlot)) |
1536 | 0 | GetViewFrame().ToggleChildWindow(nSlot); |
1537 | | //if fields have been successfully inserted call the "real" |
1538 | | //mail merge dialog |
1539 | | #if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS |
1540 | | SwWrtShell &rSh = GetWrtShell(); |
1541 | | if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc()) |
1542 | | { |
1543 | | SwDBManager* pDBManager = rSh.GetDBManager(); |
1544 | | if (pDBManager) |
1545 | | { |
1546 | | SwDBData aData = rSh.GetDBData(); |
1547 | | rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields |
1548 | | AttrChangedNotify(nullptr); |
1549 | | |
1550 | | Sequence<PropertyValue> aProperties |
1551 | | { |
1552 | | comphelper::makePropertyValue(u"DataSourceName"_ustr, aData.sDataSource), |
1553 | | comphelper::makePropertyValue(u"Command"_ustr, aData.sCommand), |
1554 | | comphelper::makePropertyValue(u"CommandType"_ustr, aData.nCommandType) |
1555 | | }; |
1556 | | pDBManager->ExecuteFormLetter(rSh, aProperties); |
1557 | | } |
1558 | | } |
1559 | | #endif |
1560 | 0 | m_bInMailMerge &= bShow; |
1561 | 0 | GetViewFrame().GetBindings().Invalidate(FN_INSERT_FIELD); |
1562 | 0 | } |
1563 | 0 | break; |
1564 | 0 | case FN_QRY_MERGE: |
1565 | 0 | { |
1566 | 0 | bool bUseCurrentDocument = true; |
1567 | 0 | bool bQuery = !pArgs || SfxItemState::SET != pArgs->GetItemState(nSlot); |
1568 | 0 | if(bQuery) |
1569 | 0 | { |
1570 | 0 | SfxViewFrame& rTmpFrame = GetViewFrame(); |
1571 | 0 | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
1572 | 0 | ScopedVclPtr<AbstractMailMergeCreateFromDlg> pDlg(pFact->CreateMailMergeCreateFromDlg(rTmpFrame.GetFrameWeld())); |
1573 | 0 | if (RET_OK == pDlg->Execute()) |
1574 | 0 | bUseCurrentDocument = pDlg->IsThisDocument(); |
1575 | 0 | else |
1576 | 0 | break; |
1577 | 0 | } |
1578 | 0 | GenerateFormLetter(bUseCurrentDocument); |
1579 | 0 | } |
1580 | 0 | break; |
1581 | 0 | case SID_RECHECK_DOCUMENT: |
1582 | 0 | { |
1583 | 0 | SwDocShell* pDocShell = GetDocShell(); |
1584 | 0 | SwDoc* pDoc = pDocShell->GetDoc(); |
1585 | 0 | uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() ); |
1586 | 0 | if( xGCIterator.is() ) |
1587 | 0 | { |
1588 | 0 | xGCIterator->resetIgnoreRules(); |
1589 | 0 | } |
1590 | | // reset ignore lists |
1591 | 0 | pDoc->SpellItAgainSam( true, false, false ); |
1592 | | // clear ignore dictionary |
1593 | 0 | uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList(); |
1594 | 0 | if( xDictionary.is() ) |
1595 | 0 | xDictionary->clear(); |
1596 | | // put cursor to the start of the document |
1597 | 0 | m_pWrtShell->StartOfSection(); |
1598 | 0 | [[fallthrough]]; // call spell/grammar dialog |
1599 | 0 | } |
1600 | 0 | case FN_SPELL_GRAMMAR_DIALOG: |
1601 | 0 | { |
1602 | 0 | SfxViewFrame& rViewFrame = GetViewFrame(); |
1603 | 0 | if (rReq.GetArgs() != nullptr) |
1604 | 0 | rViewFrame.SetChildWindow (FN_SPELL_GRAMMAR_DIALOG, |
1605 | 0 | static_cast<const SfxBoolItem&>( (rReq.GetArgs()-> |
1606 | 0 | Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue()); |
1607 | 0 | else |
1608 | 0 | rViewFrame.ToggleChildWindow(FN_SPELL_GRAMMAR_DIALOG); |
1609 | |
|
1610 | 0 | rViewFrame.GetBindings().Invalidate(FN_SPELL_GRAMMAR_DIALOG); |
1611 | 0 | rReq.Ignore (); |
1612 | 0 | } |
1613 | 0 | break; |
1614 | 0 | case SID_ALIGN_ANY_LEFT : |
1615 | 0 | case SID_ALIGN_ANY_HCENTER : |
1616 | 0 | case SID_ALIGN_ANY_RIGHT : |
1617 | 0 | case SID_ALIGN_ANY_JUSTIFIED: |
1618 | 0 | case SID_ALIGN_ANY_TOP : |
1619 | 0 | case SID_ALIGN_ANY_VCENTER : |
1620 | 0 | case SID_ALIGN_ANY_BOTTOM : |
1621 | 0 | case SID_ALIGN_ANY_HDEFAULT : |
1622 | 0 | case SID_ALIGN_ANY_VDEFAULT : |
1623 | 0 | { |
1624 | 0 | sal_uInt16 nAlias = 0; |
1625 | 0 | if( m_nSelectionType & (SelectionType::DrawObjectEditMode|SelectionType::Text) ) |
1626 | 0 | { |
1627 | 0 | switch( nSlot ) |
1628 | 0 | { |
1629 | 0 | case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break; |
1630 | 0 | case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break; |
1631 | 0 | case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break; |
1632 | 0 | case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break; |
1633 | 0 | case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break; |
1634 | 0 | case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break; |
1635 | 0 | case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break; |
1636 | 0 | } |
1637 | 0 | } |
1638 | 0 | else |
1639 | 0 | { |
1640 | 0 | switch( nSlot ) |
1641 | 0 | { |
1642 | 0 | case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break; |
1643 | 0 | case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break; |
1644 | 0 | case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break; |
1645 | 0 | case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break; |
1646 | 0 | case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break; |
1647 | 0 | case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break; |
1648 | 0 | } |
1649 | 0 | } |
1650 | | //these slots are either re-mapped to text or object alignment |
1651 | 0 | if (nAlias) |
1652 | 0 | GetViewFrame().GetDispatcher()->Execute( |
1653 | 0 | nAlias, SfxCallMode::ASYNCHRON); |
1654 | 0 | } |
1655 | 0 | break; |
1656 | 0 | case SID_RESTORE_EDITING_VIEW: |
1657 | 0 | { |
1658 | | //#i33307# restore editing position |
1659 | 0 | Point aCursorPos; |
1660 | 0 | bool bSelectObj; |
1661 | 0 | if(m_pViewImpl->GetRestorePosition(aCursorPos, bSelectObj)) |
1662 | 0 | { |
1663 | 0 | m_pWrtShell->SwCursorShell::SetCursor( aCursorPos, !bSelectObj ); |
1664 | 0 | if( bSelectObj ) |
1665 | 0 | { |
1666 | 0 | m_pWrtShell->SelectObj( aCursorPos ); |
1667 | 0 | m_pWrtShell->EnterSelFrameMode( &aCursorPos ); |
1668 | 0 | } |
1669 | 0 | } |
1670 | 0 | } |
1671 | 0 | break; |
1672 | 0 | case SID_INSERT_GRAPHIC: |
1673 | 0 | { |
1674 | 0 | rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq ))); |
1675 | 0 | } |
1676 | 0 | break; |
1677 | 0 | case SID_MOVE_SHAPE_HANDLE: |
1678 | 0 | { |
1679 | 0 | if (pArgs && pArgs->Count() >= 3) |
1680 | 0 | { |
1681 | 0 | SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : nullptr; |
1682 | 0 | if (pSdrView == nullptr) |
1683 | 0 | break; |
1684 | 0 | const SfxUInt32Item* handleNumItem = rReq.GetArg<SfxUInt32Item>(FN_PARAM_1); |
1685 | 0 | const SfxUInt32Item* newPosXTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2); |
1686 | 0 | const SfxUInt32Item* newPosYTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_3); |
1687 | 0 | const SfxInt32Item* OrdNum = rReq.GetArg<SfxInt32Item>(FN_PARAM_4); |
1688 | |
|
1689 | 0 | const sal_uLong handleNum = handleNumItem->GetValue(); |
1690 | 0 | const sal_uLong newPosX = newPosXTwips->GetValue(); |
1691 | 0 | const sal_uLong newPosY = newPosYTwips->GetValue(); |
1692 | 0 | const Point mPoint(newPosX, newPosY); |
1693 | 0 | const SdrHdl* handle = pSdrView->GetHdlList().GetHdl(handleNum); |
1694 | 0 | if (!handle) |
1695 | 0 | { |
1696 | 0 | break; |
1697 | 0 | } |
1698 | | |
1699 | 0 | if (handle->GetKind() == SdrHdlKind::Anchor || handle->GetKind() == SdrHdlKind::Anchor_TR) |
1700 | 0 | m_pWrtShell->FindAnchorPos(mPoint, /*bMoveIt=*/true); |
1701 | 0 | else |
1702 | 0 | pSdrView->MoveShapeHandle(handleNum, mPoint, OrdNum ? OrdNum->GetValue() : -1); |
1703 | 0 | } |
1704 | 0 | break; |
1705 | 0 | } |
1706 | | |
1707 | 0 | default: |
1708 | 0 | OSL_ENSURE(false, "wrong dispatcher"); |
1709 | 0 | return; |
1710 | 0 | } |
1711 | 0 | if(!bIgnore) |
1712 | 0 | rReq.Done(); |
1713 | 0 | } |
1714 | | |
1715 | | bool SwView::IsConditionalFastCall( const SfxRequest &rReq ) |
1716 | 0 | { |
1717 | 0 | sal_uInt16 nId = rReq.GetSlot(); |
1718 | 0 | bool bRet = false; |
1719 | |
|
1720 | 0 | if (nId == FN_REDLINE_ACCEPT_DIRECT || nId == FN_REDLINE_REJECT_DIRECT) |
1721 | 0 | { |
1722 | 0 | if (comphelper::LibreOfficeKit::isActive()) |
1723 | 0 | bRet = true; |
1724 | 0 | } |
1725 | 0 | return bRet || SfxShell::IsConditionalFastCall(rReq); |
1726 | |
|
1727 | 0 | } |
1728 | | |
1729 | | /// invalidate page numbering field |
1730 | | void SwView::UpdatePageNums() |
1731 | 6.45k | { |
1732 | 6.45k | SfxBindings &rBnd = GetViewFrame().GetBindings(); |
1733 | 6.45k | rBnd.Invalidate(FN_STAT_PAGE); |
1734 | 6.45k | } |
1735 | | |
1736 | | void SwView::UpdateDocStats() |
1737 | 0 | { |
1738 | 0 | SfxBindings &rBnd = GetViewFrame().GetBindings(); |
1739 | 0 | rBnd.Invalidate( FN_STAT_WORDCOUNT ); |
1740 | 0 | rBnd.Update( FN_STAT_WORDCOUNT ); |
1741 | 0 | } |
1742 | | |
1743 | | /// get status of the status line |
1744 | | void SwView::StateStatusLine(SfxItemSet &rSet) |
1745 | 0 | { |
1746 | 0 | SwWrtShell& rShell = GetWrtShell(); |
1747 | |
|
1748 | 0 | SfxWhichIter aIter( rSet ); |
1749 | 0 | sal_uInt16 nWhich = aIter.FirstWhich(); |
1750 | 0 | OSL_ENSURE( nWhich, "empty set"); |
1751 | | |
1752 | | //get section change event |
1753 | 0 | const SwSection* CurrSect = rShell.GetCurrSection(); |
1754 | 0 | if( CurrSect ) |
1755 | 0 | { |
1756 | 0 | const UIName& sCurrentSectionName = CurrSect->GetSectionName(); |
1757 | 0 | if(sCurrentSectionName != m_sOldSectionName) |
1758 | 0 | { |
1759 | 0 | SwCursorShell::FireSectionChangeEvent(2, 1); |
1760 | 0 | } |
1761 | 0 | m_sOldSectionName = sCurrentSectionName; |
1762 | 0 | } |
1763 | 0 | else if (!m_sOldSectionName.isEmpty()) |
1764 | 0 | { |
1765 | 0 | SwCursorShell::FireSectionChangeEvent(2, 1); |
1766 | 0 | m_sOldSectionName= UIName(); |
1767 | 0 | } |
1768 | | //get column change event |
1769 | 0 | if(rShell.bColumnChange()) |
1770 | 0 | { |
1771 | 0 | SwCursorShell::FireColumnChangeEvent(2, 1); |
1772 | 0 | } |
1773 | |
|
1774 | 0 | while( nWhich ) |
1775 | 0 | { |
1776 | 0 | switch( nWhich ) |
1777 | 0 | { |
1778 | 0 | case FN_STAT_PAGE: |
1779 | 0 | { |
1780 | 0 | OUString aTooltip; |
1781 | 0 | OUString aPageStr; |
1782 | |
|
1783 | 0 | SwVisiblePageNumbers aVisiblePageNumbers; |
1784 | 0 | m_pWrtShell->GetFirstLastVisPageNumbers(aVisiblePageNumbers, m_pWrtShell->GetView()); |
1785 | | |
1786 | | // convert to strings and define references |
1787 | 0 | OUString sFirstPhy = OUString::number(aVisiblePageNumbers.nFirstPhy); |
1788 | 0 | OUString sLastPhy = OUString::number(aVisiblePageNumbers.nLastPhy); |
1789 | 0 | OUString sFirstVirt = OUString::number(aVisiblePageNumbers.nFirstVirt); |
1790 | 0 | OUString sLastVirt = OUString::number(aVisiblePageNumbers.nLastVirt); |
1791 | 0 | OUString& sFirstCustomPhy = aVisiblePageNumbers.sFirstCustomPhy; |
1792 | 0 | OUString& sLastCustomPhy = aVisiblePageNumbers.sLastCustomPhy; |
1793 | 0 | OUString& sFirstCustomVirt = aVisiblePageNumbers.sFirstCustomVirt; |
1794 | 0 | OUString& sLastCustomVirt = aVisiblePageNumbers.sLastCustomVirt; |
1795 | 0 | OUString sPageCount = OUString::number(m_pWrtShell->GetPageCount()); |
1796 | |
|
1797 | 0 | if (aVisiblePageNumbers.nFirstPhy == aVisiblePageNumbers.nFirstVirt) |
1798 | 0 | { |
1799 | 0 | aTooltip = SwResId(STR_BOOKCTRL_HINT); |
1800 | 0 | if (aVisiblePageNumbers.nFirstPhy != aVisiblePageNumbers.nLastPhy) |
1801 | 0 | { |
1802 | 0 | if (sFirstPhy == sFirstCustomPhy && sLastPhy == sLastCustomPhy) |
1803 | 0 | { |
1804 | 0 | aPageStr = SwResId(STR_PAGES_COUNT); |
1805 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1806 | 0 | aPageStr = aPageStr.replaceFirst("%2", sLastPhy); |
1807 | 0 | aPageStr = aPageStr.replaceFirst("%3", sPageCount); |
1808 | 0 | } |
1809 | 0 | else |
1810 | 0 | { |
1811 | 0 | aPageStr = SwResId(STR_PAGES_COUNT_CUSTOM); |
1812 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1813 | 0 | aPageStr = aPageStr.replaceFirst("%2", sLastPhy); |
1814 | 0 | aPageStr = aPageStr.replaceFirst("%3", sFirstCustomPhy); |
1815 | 0 | aPageStr = aPageStr.replaceFirst("%4", sLastCustomPhy); |
1816 | 0 | aPageStr = aPageStr.replaceFirst("%5", sPageCount); |
1817 | 0 | } |
1818 | 0 | } |
1819 | 0 | else |
1820 | 0 | { |
1821 | 0 | if (sFirstPhy == sFirstCustomPhy && sLastPhy == sLastCustomPhy) |
1822 | 0 | { |
1823 | 0 | aPageStr = SwResId(STR_PAGE_COUNT); |
1824 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1825 | 0 | aPageStr = aPageStr.replaceFirst("%2", sPageCount); |
1826 | 0 | } |
1827 | 0 | else |
1828 | 0 | { |
1829 | 0 | aPageStr = SwResId(STR_PAGE_COUNT_CUSTOM); |
1830 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1831 | 0 | aPageStr = aPageStr.replaceFirst("%2", sFirstCustomPhy); |
1832 | 0 | aPageStr = aPageStr.replaceFirst("%3", sPageCount); |
1833 | 0 | } |
1834 | 0 | } |
1835 | 0 | } |
1836 | 0 | else |
1837 | 0 | { |
1838 | 0 | aTooltip = SwResId(STR_BOOKCTRL_HINT_EXTENDED); |
1839 | 0 | if (aVisiblePageNumbers.nFirstPhy != aVisiblePageNumbers.nLastPhy) |
1840 | 0 | { |
1841 | 0 | if (sFirstPhy == sFirstCustomPhy && sLastPhy == sLastCustomPhy) |
1842 | 0 | { |
1843 | 0 | aPageStr = SwResId(STR_PAGES_COUNT_EXTENDED); |
1844 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1845 | 0 | aPageStr = aPageStr.replaceFirst("%2", sLastPhy); |
1846 | 0 | aPageStr = aPageStr.replaceFirst("%3", sPageCount); |
1847 | 0 | aPageStr = aPageStr.replaceFirst("%4", sFirstVirt); |
1848 | 0 | aPageStr = aPageStr.replaceFirst("%5", sLastVirt); |
1849 | 0 | } |
1850 | 0 | else |
1851 | 0 | { |
1852 | 0 | aPageStr = SwResId(STR_PAGES_COUNT_CUSTOM_EXTENDED); |
1853 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1854 | 0 | aPageStr = aPageStr.replaceFirst("%2", sLastPhy); |
1855 | 0 | aPageStr = aPageStr.replaceFirst("%3", sFirstCustomPhy); |
1856 | 0 | aPageStr = aPageStr.replaceFirst("%4", sLastCustomPhy); |
1857 | 0 | aPageStr = aPageStr.replaceFirst("%5", sPageCount); |
1858 | 0 | aPageStr = aPageStr.replaceFirst("%6", sFirstVirt); |
1859 | 0 | aPageStr = aPageStr.replaceFirst("%7", sLastVirt); |
1860 | 0 | aPageStr = aPageStr.replaceFirst("%8", sFirstCustomVirt); |
1861 | 0 | aPageStr = aPageStr.replaceFirst("%9", sLastCustomVirt); |
1862 | 0 | } |
1863 | 0 | } |
1864 | 0 | else |
1865 | 0 | { |
1866 | 0 | if (sFirstPhy == sFirstCustomPhy && sLastPhy == sLastCustomPhy) |
1867 | 0 | { |
1868 | 0 | aPageStr = SwResId(STR_PAGE_COUNT_EXTENDED); |
1869 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1870 | 0 | aPageStr = aPageStr.replaceFirst("%2", sPageCount); |
1871 | 0 | aPageStr = aPageStr.replaceFirst("%3", sFirstVirt); |
1872 | 0 | } |
1873 | 0 | else |
1874 | 0 | { |
1875 | 0 | aPageStr = SwResId(STR_PAGE_COUNT_CUSTOM_EXTENDED); |
1876 | 0 | aPageStr = aPageStr.replaceFirst("%1", sFirstPhy); |
1877 | 0 | aPageStr = aPageStr.replaceFirst("%2", sFirstCustomPhy); |
1878 | 0 | aPageStr = aPageStr.replaceFirst("%3", sPageCount); |
1879 | 0 | aPageStr = aPageStr.replaceFirst("%4", sFirstVirt); |
1880 | 0 | aPageStr = aPageStr.replaceFirst("%5", sFirstCustomVirt); |
1881 | 0 | } |
1882 | 0 | } |
1883 | 0 | } |
1884 | | |
1885 | | // replace range indicator with two pages conjunction if applicable |
1886 | 0 | if ((aVisiblePageNumbers.nLastPhy - aVisiblePageNumbers.nFirstPhy) == 1) |
1887 | 0 | aPageStr = aPageStr.replaceAll("-", SwResId(STR_PAGES_TWO_CONJUNCTION)); |
1888 | | |
1889 | | // status bar bookmark control string and tooltip |
1890 | 0 | std::vector<OUString> aStringList |
1891 | 0 | { |
1892 | 0 | aPageStr, |
1893 | 0 | aTooltip |
1894 | 0 | }; |
1895 | 0 | rSet.Put(SfxStringListItem(FN_STAT_PAGE, &aStringList)); |
1896 | | |
1897 | | //if existing page number is not equal to old page number, send out this event. |
1898 | 0 | if (m_nOldPageNum != aVisiblePageNumbers.nFirstPhy) |
1899 | 0 | { |
1900 | 0 | if (m_nOldPageNum != 0) |
1901 | 0 | SwCursorShell::FirePageChangeEvent(m_nOldPageNum, aVisiblePageNumbers.nFirstPhy); |
1902 | 0 | m_nOldPageNum = aVisiblePageNumbers.nFirstPhy; |
1903 | 0 | } |
1904 | 0 | const sal_uInt16 nCnt = GetWrtShell().GetPageCnt(); |
1905 | 0 | if (m_nPageCnt != nCnt) // notify Basic |
1906 | 0 | { |
1907 | 0 | m_nPageCnt = nCnt; |
1908 | 0 | SfxGetpApp()->NotifyEvent(SfxEventHint(SfxEventHintId::SwEventPageCount, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame().GetObjectShell()), false); |
1909 | 0 | } |
1910 | 0 | } |
1911 | 0 | break; |
1912 | | |
1913 | 0 | case FN_STAT_WORDCOUNT: |
1914 | 0 | { |
1915 | 0 | SwDocStat selectionStats; |
1916 | 0 | SwDocStat documentStats; |
1917 | 0 | rShell.CountWords(selectionStats); |
1918 | 0 | documentStats = rShell.GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ ); |
1919 | |
|
1920 | 0 | sal_uLong nWord = selectionStats.nChar ? selectionStats.nWord : documentStats.nWord; |
1921 | 0 | sal_uLong nChar = selectionStats.nChar ? selectionStats.nChar : documentStats.nChar; |
1922 | 0 | TranslateId pResId = selectionStats.nChar ? STR_WORDCOUNT : STR_WORDCOUNT_NO_SELECTION; |
1923 | 0 | TranslateNId pWordResId = selectionStats.nChar ? STR_WORDCOUNT_WORDARG : STR_WORDCOUNT_WORDARG_NO_SELECTION; |
1924 | 0 | TranslateNId pCharResId = selectionStats.nChar ? STR_WORDCOUNT_CHARARG : STR_WORDCOUNT_CHARARG_NO_SELECTION; |
1925 | |
|
1926 | 0 | const LocaleDataWrapper& rLocaleData = Application::GetSettings().GetUILocaleDataWrapper(); |
1927 | 0 | OUString aWordArg = SwResId(pWordResId, nWord).replaceAll("$1", rLocaleData.getNum(nWord, 0)); |
1928 | 0 | OUString aCharArg = SwResId(pCharResId, nChar).replaceAll("$1", rLocaleData.getNum(nChar, 0)); |
1929 | 0 | OUString aWordCount(SwResId(pResId)); |
1930 | 0 | aWordCount = aWordCount.replaceAll("$1", aWordArg); |
1931 | 0 | aWordCount = aWordCount.replaceAll("$2", aCharArg); |
1932 | 0 | rSet.Put( SfxStringItem( FN_STAT_WORDCOUNT, aWordCount ) ); |
1933 | |
|
1934 | 0 | SwPostItMgr* pPostItMgr = rShell.GetPostItMgr(); |
1935 | 0 | if (pPostItMgr) |
1936 | 0 | selectionStats.nComments = pPostItMgr->end() - pPostItMgr->begin(); |
1937 | |
|
1938 | 0 | SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetViewFrame().GetChildWindow(SwWordCountWrapper::GetChildWindowId())); |
1939 | 0 | if (pWrdCnt) |
1940 | 0 | pWrdCnt->SetCounts(selectionStats, documentStats); |
1941 | 0 | } |
1942 | 0 | break; |
1943 | 0 | case FN_STAT_ACCESSIBILITY_CHECK: |
1944 | 0 | { |
1945 | 0 | std::unique_ptr<sw::OnlineAccessibilityCheck> const& rOnlineAccessibilityCheck = rShell.GetDoc()->getOnlineAccessibilityCheck(); |
1946 | 0 | if (rOnlineAccessibilityCheck) |
1947 | 0 | { |
1948 | 0 | sal_Int32 nIssues = rOnlineAccessibilityCheck->getNumberOfAccessibilityIssues() |
1949 | 0 | + rOnlineAccessibilityCheck->getNumberOfDocumentLevelAccessibilityIssues(); |
1950 | 0 | rSet.Put(SfxInt32Item(FN_STAT_ACCESSIBILITY_CHECK, nIssues)); |
1951 | 0 | } |
1952 | 0 | } |
1953 | 0 | break; |
1954 | | |
1955 | 0 | case FN_STAT_TEMPLATE: |
1956 | 0 | { |
1957 | 0 | rSet.Put(SfxStringItem( FN_STAT_TEMPLATE, |
1958 | 0 | rShell.GetCurPageStyle().toString())); |
1959 | |
|
1960 | 0 | } |
1961 | 0 | break; |
1962 | 0 | case SID_ATTR_ZOOM: |
1963 | 0 | { |
1964 | 0 | if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) |
1965 | 0 | { |
1966 | 0 | const SwViewOption* pVOpt = rShell.GetViewOptions(); |
1967 | 0 | SvxZoomType eZoom = pVOpt->GetZoomType(); |
1968 | 0 | SvxZoomItem aZoom(eZoom, |
1969 | 0 | pVOpt->GetZoom()); |
1970 | 0 | if( pVOpt->getBrowseMode() ) |
1971 | 0 | { |
1972 | 0 | aZoom.SetValueSet( |
1973 | 0 | SvxZoomEnableFlags::N50| |
1974 | 0 | SvxZoomEnableFlags::N75| |
1975 | 0 | SvxZoomEnableFlags::N100| |
1976 | 0 | SvxZoomEnableFlags::N150| |
1977 | 0 | SvxZoomEnableFlags::N200); |
1978 | 0 | } |
1979 | 0 | rSet.Put( aZoom ); |
1980 | 0 | } |
1981 | 0 | else |
1982 | 0 | rSet.DisableItem( SID_ATTR_ZOOM ); |
1983 | 0 | } |
1984 | 0 | break; |
1985 | 0 | case SID_ATTR_VIEWLAYOUT: |
1986 | 0 | { |
1987 | 0 | if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) |
1988 | 0 | { |
1989 | 0 | const SwViewOption* pVOpt = rShell.GetViewOptions(); |
1990 | 0 | const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns(); |
1991 | 0 | const bool bBookMode = pVOpt->IsViewLayoutBookMode(); |
1992 | 0 | SvxViewLayoutItem aViewLayout(nColumns, bBookMode); |
1993 | 0 | rSet.Put( aViewLayout ); |
1994 | 0 | } |
1995 | 0 | else |
1996 | 0 | rSet.DisableItem( SID_ATTR_VIEWLAYOUT ); |
1997 | 0 | } |
1998 | 0 | break; |
1999 | 0 | case SID_ATTR_ZOOMSLIDER: |
2000 | 0 | { |
2001 | 0 | if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) |
2002 | 0 | { |
2003 | 0 | const SwViewOption* pVOpt = rShell.GetViewOptions(); |
2004 | 0 | const sal_uInt16 nCurrentZoom = pVOpt->GetZoom(); |
2005 | 0 | SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM ); |
2006 | 0 | aZoomSliderItem.AddSnappingPoint( 100 ); |
2007 | |
|
2008 | 0 | if ( !m_pWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) ) |
2009 | 0 | { |
2010 | 0 | const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns(); |
2011 | 0 | const bool bAutomaticViewLayout = 0 == nColumns; |
2012 | 0 | const SwPostItMgr* pMgr = GetPostItMgr(); |
2013 | | |
2014 | | // snapping points: |
2015 | | // automatic mode: 1 Page, 2 Pages, 100% |
2016 | | // n Columns mode: n Pages, 100% |
2017 | | // n Columns book mode: nPages without gaps, 100% |
2018 | 0 | const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( CurRectType::PageCalc ) ); |
2019 | 0 | const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( CurRectType::PagesArea ) ); // width of columns |
2020 | 0 | Size aPageSize( aPageRect.SSize() ); |
2021 | 0 | aPageSize.AdjustWidth(pMgr->HasNotes() && pMgr->ShowNotes() ? |
2022 | 0 | pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() : |
2023 | 0 | 0 ); |
2024 | |
|
2025 | 0 | Size aRootSize( aRootRect.SSize() ); |
2026 | |
|
2027 | 0 | const MapMode aTmpMap( MapUnit::MapTwip ); |
2028 | 0 | const Size aEditSize = GetEditWin().GetOutputSizePixel(); |
2029 | 0 | const Size aWindowSize( GetEditWin().PixelToLogic( aEditSize, aTmpMap ) ); |
2030 | |
|
2031 | 0 | const tools::Long nOf = pVOpt->GetDocumentBorder() * 2; |
2032 | 0 | tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width(); |
2033 | 0 | nTmpWidth += nOf; |
2034 | 0 | aPageSize.AdjustHeight(nOf ); |
2035 | 0 | tools::Long nFac = aWindowSize.Width() * 100 / nTmpWidth; |
2036 | |
|
2037 | 0 | tools::Long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height(); |
2038 | 0 | nFac = std::min( nFac, nVisPercent ); |
2039 | |
|
2040 | 0 | if (nFac >= MINZOOM) |
2041 | 0 | { |
2042 | 0 | aZoomSliderItem.AddSnappingPoint( nFac ); |
2043 | 0 | } |
2044 | |
|
2045 | 0 | if ( bAutomaticViewLayout ) |
2046 | 0 | { |
2047 | 0 | nTmpWidth += aPageSize.Width() + pVOpt->GetGapBetweenPages(); |
2048 | 0 | nFac = aWindowSize.Width() * 100 / nTmpWidth; |
2049 | 0 | nFac = std::min( nFac, nVisPercent ); |
2050 | 0 | if (nFac >= MINZOOM) |
2051 | 0 | { |
2052 | 0 | aZoomSliderItem.AddSnappingPoint( nFac ); |
2053 | 0 | } |
2054 | 0 | } |
2055 | 0 | } |
2056 | |
|
2057 | 0 | rSet.Put( aZoomSliderItem ); |
2058 | 0 | } |
2059 | 0 | else |
2060 | 0 | rSet.DisableItem( SID_ATTR_ZOOMSLIDER ); |
2061 | 0 | } |
2062 | 0 | break; |
2063 | 0 | case SID_ATTR_POSITION: |
2064 | 0 | case SID_ATTR_SIZE: |
2065 | 0 | { |
2066 | 0 | if( !rShell.IsFrameSelected() && !rShell.GetSelectedObjCount() ) |
2067 | 0 | SwBaseShell::SetFrameMode_( FLY_DRAG_END ); |
2068 | 0 | else |
2069 | 0 | { |
2070 | 0 | FlyMode eFrameMode = SwBaseShell::GetFrameMode(); |
2071 | 0 | if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG ) |
2072 | 0 | { |
2073 | 0 | if ( nWhich == SID_ATTR_POSITION ) |
2074 | 0 | rSet.Put( SfxPointItem( SID_ATTR_POSITION, |
2075 | 0 | rShell.GetAnchorObjDiff())); |
2076 | 0 | else |
2077 | 0 | rSet.Put( SvxSizeItem( SID_ATTR_SIZE, |
2078 | 0 | rShell.GetObjSize())); |
2079 | 0 | } |
2080 | 0 | } |
2081 | 0 | } |
2082 | 0 | break; |
2083 | 0 | case SID_TABLE_CELL: |
2084 | |
|
2085 | 0 | if( rShell.IsFrameSelected() || rShell.GetSelectedObjCount() ) |
2086 | 0 | { |
2087 | | // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem. |
2088 | | // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot |
2089 | | // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied |
2090 | | // in SID_ATTR_SIZE). |
2091 | 0 | } |
2092 | 0 | else |
2093 | 0 | { |
2094 | 0 | StatusCategory eCategory(StatusCategory::NONE); |
2095 | 0 | OUString sStr; |
2096 | 0 | if( rShell.IsCursorInTable() ) |
2097 | 0 | { |
2098 | | // table name + cell coordinate |
2099 | 0 | sStr = rShell.GetTableFormat()->GetName().toString() + ":" + rShell.GetBoxNms(); |
2100 | 0 | eCategory = StatusCategory::TableCell; |
2101 | 0 | } |
2102 | 0 | else |
2103 | 0 | { |
2104 | 0 | const SwSection* pCurrSect = rShell.GetCurrSection(); |
2105 | 0 | if( pCurrSect ) |
2106 | 0 | { |
2107 | 0 | switch( pCurrSect->GetType() ) |
2108 | 0 | { |
2109 | 0 | case SectionType::ToxHeader: |
2110 | 0 | case SectionType::ToxContent: |
2111 | 0 | { |
2112 | 0 | const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX(); |
2113 | 0 | if( pTOX ) |
2114 | 0 | { |
2115 | 0 | sStr = pTOX->GetTOXName().toString(); |
2116 | 0 | eCategory = StatusCategory::TableOfContents; |
2117 | 0 | } |
2118 | 0 | else |
2119 | 0 | { |
2120 | 0 | OSL_ENSURE( false, |
2121 | 0 | "Unknown kind of section" ); |
2122 | 0 | sStr = pCurrSect->GetSectionName().toString(); |
2123 | 0 | eCategory = StatusCategory::Section; |
2124 | 0 | } |
2125 | 0 | } |
2126 | 0 | break; |
2127 | 0 | default: |
2128 | 0 | sStr = pCurrSect->GetSectionName().toString(); |
2129 | 0 | eCategory = StatusCategory::Section; |
2130 | 0 | break; |
2131 | 0 | } |
2132 | 0 | } |
2133 | 0 | } |
2134 | | |
2135 | 0 | const SwNumRule* pNumRule = rShell.GetNumRuleAtCurrCursorPos(); |
2136 | 0 | const bool bOutlineNum = pNumRule && pNumRule->IsOutlineRule(); |
2137 | |
|
2138 | 0 | if (pNumRule && !bOutlineNum ) // cursor in numbering |
2139 | 0 | { |
2140 | 0 | sal_uInt8 nNumLevel = rShell.GetNumLevel(); |
2141 | 0 | if ( nNumLevel < MAXLEVEL ) |
2142 | 0 | { |
2143 | 0 | if(!pNumRule->IsAutoRule()) |
2144 | 0 | { |
2145 | 0 | SfxItemSetFixed<RES_PARATR_NUMRULE, RES_PARATR_NUMRULE> aSet(GetPool()); |
2146 | 0 | rShell.GetCurAttr(aSet); |
2147 | 0 | if(SfxItemState::DEFAULT <= |
2148 | 0 | aSet.GetItemState(RES_PARATR_NUMRULE)) |
2149 | 0 | { |
2150 | 0 | const UIName sNumStyle = |
2151 | 0 | aSet.Get(RES_PARATR_NUMRULE).GetValue(); |
2152 | 0 | if(!sNumStyle.isEmpty()) |
2153 | 0 | { |
2154 | 0 | if(!sStr.isEmpty()) |
2155 | 0 | sStr += sStatusDelim; |
2156 | 0 | if (eCategory == StatusCategory::NONE) |
2157 | 0 | eCategory = StatusCategory::ListStyle; |
2158 | 0 | sStr += sNumStyle.toString(); |
2159 | 0 | } |
2160 | 0 | } |
2161 | 0 | } |
2162 | 0 | if (!sStr.isEmpty()) |
2163 | 0 | sStr += sStatusDelim; |
2164 | 0 | sStr += SwResId(STR_NUM_LEVEL) + OUString::number( nNumLevel + 1 ); |
2165 | 0 | if (eCategory == StatusCategory::NONE) |
2166 | 0 | eCategory = StatusCategory::Numbering; |
2167 | 0 | } |
2168 | 0 | } |
2169 | 0 | const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel(); |
2170 | 0 | if( nOutlineLevel != 0 ) |
2171 | 0 | { |
2172 | 0 | if (!sStr.isEmpty()) |
2173 | 0 | sStr += " , "; |
2174 | 0 | if( bOutlineNum ) |
2175 | 0 | { |
2176 | 0 | sStr += SwResId(STR_OUTLINE_NUMBERING) + |
2177 | 0 | sStatusDelim + SwResId(STR_NUM_LEVEL); |
2178 | 0 | } |
2179 | 0 | else |
2180 | 0 | sStr += SwResId(STR_NUM_OUTLINE); |
2181 | 0 | sStr += OUString::number( nOutlineLevel); |
2182 | 0 | if (eCategory == StatusCategory::NONE) |
2183 | 0 | eCategory = StatusCategory::Numbering; |
2184 | 0 | } |
2185 | |
|
2186 | 0 | if( rShell.HasReadonlySel() ) |
2187 | 0 | { |
2188 | 0 | if (!sStr.isEmpty()) |
2189 | 0 | sStr = sStatusDelim + sStr; |
2190 | 0 | sStr = SwResId(SW_STR_READONLY) + sStr; |
2191 | 0 | } |
2192 | 0 | if (!sStr.isEmpty()) |
2193 | 0 | rSet.Put( SvxStatusItem( SID_TABLE_CELL, sStr, eCategory )); |
2194 | 0 | } |
2195 | 0 | break; |
2196 | 0 | case FN_STAT_SELMODE: |
2197 | 0 | { |
2198 | 0 | if(rShell.IsStdMode()) |
2199 | 0 | rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0)); |
2200 | 0 | else if(rShell.IsAddMode()) |
2201 | 0 | rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2)); |
2202 | 0 | else if(rShell.IsBlockMode()) |
2203 | 0 | rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3)); |
2204 | 0 | else |
2205 | 0 | rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1)); |
2206 | 0 | break; |
2207 | 0 | } |
2208 | 0 | case SID_ATTR_INSERT: |
2209 | 0 | if( rShell.IsRedlineOn() ) |
2210 | 0 | rSet.DisableItem( nWhich ); |
2211 | 0 | else |
2212 | 0 | { |
2213 | 0 | rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode())); |
2214 | 0 | } |
2215 | 0 | break; |
2216 | 0 | } |
2217 | 0 | nWhich = aIter.NextWhich(); |
2218 | 0 | } |
2219 | 0 | } |
2220 | | |
2221 | | /** execute method for the status line |
2222 | | * |
2223 | | * @param rReq ??? |
2224 | | */ |
2225 | | void SwView::ExecuteStatusLine(SfxRequest &rReq) |
2226 | 0 | { |
2227 | 0 | SwWrtShell &rSh = GetWrtShell(); |
2228 | 0 | const SfxItemSet* pArgs = rReq.GetArgs(); |
2229 | 0 | const SfxPoolItem* pItem=nullptr; |
2230 | 0 | bool bUp = false; |
2231 | 0 | sal_uInt16 nWhich = rReq.GetSlot(); |
2232 | 0 | switch( nWhich ) |
2233 | 0 | { |
2234 | 0 | case FN_STAT_PAGE: |
2235 | 0 | { |
2236 | 0 | GetViewFrame().GetDispatcher()->Execute( SID_GO_TO_PAGE, |
2237 | 0 | SfxCallMode::SYNCHRON|SfxCallMode::RECORD ); |
2238 | 0 | } |
2239 | 0 | break; |
2240 | | |
2241 | 0 | case FN_STAT_WORDCOUNT: |
2242 | 0 | { |
2243 | 0 | GetViewFrame().GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG, |
2244 | 0 | SfxCallMode::SYNCHRON|SfxCallMode::RECORD ); |
2245 | 0 | } |
2246 | 0 | break; |
2247 | | |
2248 | 0 | case FN_STAT_ACCESSIBILITY_CHECK: |
2249 | 0 | { |
2250 | 0 | const SfxStringItem sDeckName(SID_SIDEBAR_DECK, u"A11yCheckDeck"_ustr); |
2251 | 0 | GetViewFrame().GetDispatcher()->ExecuteList(SID_SIDEBAR_DECK, SfxCallMode::RECORD, |
2252 | 0 | { &sDeckName }); |
2253 | 0 | } |
2254 | 0 | break; |
2255 | | |
2256 | 0 | case FN_STAT_BOOKMARK: |
2257 | 0 | if ( pArgs ) |
2258 | 0 | { |
2259 | 0 | if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem)) |
2260 | 0 | { |
2261 | 0 | const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess(); |
2262 | 0 | const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); |
2263 | 0 | if(nIdx < pMarkAccess->getBookmarksCount()) |
2264 | 0 | { |
2265 | 0 | const auto ppBookmark = rSh.getIDocumentMarkAccess()->getBookmarksBegin() + nIdx; |
2266 | 0 | rSh.EnterStdMode(); |
2267 | 0 | rSh.GotoMark( *ppBookmark ); |
2268 | 0 | } |
2269 | 0 | else |
2270 | 0 | OSL_FAIL("SwView::ExecuteStatusLine(..)" |
2271 | 0 | " - Ignoring out of range bookmark index"); |
2272 | 0 | } |
2273 | 0 | } |
2274 | 0 | break; |
2275 | | |
2276 | 0 | case FN_STAT_TEMPLATE: |
2277 | 0 | { |
2278 | 0 | weld::Window* pDialogParent = GetViewFrame().GetFrameWeld(); |
2279 | 0 | css::uno::Any aAny(pDialogParent->GetXWindow()); |
2280 | 0 | SfxUnoAnyItem aDialogParent(SID_DIALOG_PARENT, aAny); |
2281 | 0 | const SfxPoolItem* pInternalItems[ 2 ]; |
2282 | 0 | pInternalItems[ 0 ] = &aDialogParent; |
2283 | 0 | pInternalItems[ 1 ] = nullptr; |
2284 | 0 | GetViewFrame().GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG, |
2285 | 0 | SfxCallMode::SYNCHRON|SfxCallMode::RECORD, |
2286 | 0 | nullptr, 0, pInternalItems); |
2287 | 0 | } |
2288 | 0 | break; |
2289 | 0 | case SID_ATTR_ZOOM: |
2290 | 0 | { |
2291 | 0 | if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) |
2292 | 0 | { |
2293 | 0 | const SfxItemSet *pSet = nullptr; |
2294 | 0 | ScopedVclPtr<AbstractSvxZoomDialog> pDlg; |
2295 | 0 | if ( pArgs ) |
2296 | 0 | pSet = pArgs; |
2297 | 0 | else |
2298 | 0 | { |
2299 | 0 | const SwViewOption& rViewOptions = *rSh.GetViewOptions(); |
2300 | 0 | SfxItemSetFixed<SID_ATTR_ZOOM, SID_ATTR_ZOOM, SID_ATTR_VIEWLAYOUT, SID_ATTR_VIEWLAYOUT> aCoreSet(m_pShell->GetPool()); |
2301 | 0 | SvxZoomItem aZoom( rViewOptions.GetZoomType(), rViewOptions.GetZoom() ); |
2302 | |
|
2303 | 0 | const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode(); |
2304 | 0 | if( bBrowseMode ) |
2305 | 0 | { |
2306 | 0 | aZoom.SetValueSet( |
2307 | 0 | SvxZoomEnableFlags::N50| |
2308 | 0 | SvxZoomEnableFlags::N75| |
2309 | 0 | SvxZoomEnableFlags::N100| |
2310 | 0 | SvxZoomEnableFlags::N150| |
2311 | 0 | SvxZoomEnableFlags::N200); |
2312 | 0 | } |
2313 | 0 | aCoreSet.Put( aZoom ); |
2314 | |
|
2315 | 0 | if ( !bBrowseMode ) |
2316 | 0 | { |
2317 | 0 | const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() ); |
2318 | 0 | aCoreSet.Put( aViewLayout ); |
2319 | 0 | } |
2320 | |
|
2321 | 0 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
2322 | 0 | pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetViewFrame().GetFrameWeld(), aCoreSet)); |
2323 | 0 | pDlg->SetLimits( MINZOOM, MAXZOOM ); |
2324 | 0 | if( pDlg->Execute() != RET_CANCEL ) |
2325 | 0 | pSet = pDlg->GetOutputItemSet(); |
2326 | 0 | } |
2327 | |
|
2328 | 0 | const SvxViewLayoutItem* pViewLayoutItem = nullptr; |
2329 | 0 | if ( pSet && (pViewLayoutItem = pSet->GetItemIfSet(SID_ATTR_VIEWLAYOUT))) |
2330 | 0 | { |
2331 | 0 | const sal_uInt16 nColumns = pViewLayoutItem->GetValue(); |
2332 | 0 | const bool bBookMode = pViewLayoutItem->IsBookMode(); |
2333 | 0 | SetViewLayout( nColumns, bBookMode ); |
2334 | 0 | } |
2335 | |
|
2336 | 0 | const SvxZoomItem* pZoomItem = nullptr; |
2337 | 0 | if ( pSet && (pZoomItem = pSet->GetItemIfSet(SID_ATTR_ZOOM))) |
2338 | 0 | { |
2339 | 0 | SvxZoomType eType = pZoomItem->GetType(); |
2340 | 0 | SetZoom( eType, pZoomItem->GetValue() ); |
2341 | 0 | } |
2342 | 0 | bUp = true; |
2343 | 0 | if ( pZoomItem ) |
2344 | 0 | rReq.AppendItem( *pZoomItem ); |
2345 | 0 | rReq.Done(); |
2346 | 0 | } |
2347 | 0 | } |
2348 | 0 | break; |
2349 | | |
2350 | 0 | case SID_ATTR_VIEWLAYOUT: |
2351 | 0 | { |
2352 | 0 | if ( pArgs && !rSh.getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) && |
2353 | 0 | ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) ) |
2354 | 0 | { |
2355 | 0 | if ( const SvxViewLayoutItem* pLayoutItem = pArgs->GetItemIfSet(SID_ATTR_VIEWLAYOUT )) |
2356 | 0 | { |
2357 | 0 | const sal_uInt16 nColumns = pLayoutItem->GetValue(); |
2358 | 0 | const bool bBookMode = (0 != nColumns && 0 == (nColumns % 2)) && pLayoutItem->IsBookMode(); |
2359 | |
|
2360 | 0 | SetViewLayout( nColumns, bBookMode ); |
2361 | 0 | } |
2362 | |
|
2363 | 0 | bUp = true; |
2364 | 0 | rReq.Done(); |
2365 | |
|
2366 | 0 | InvalidateRulerPos(); |
2367 | 0 | } |
2368 | 0 | } |
2369 | 0 | break; |
2370 | | |
2371 | 0 | case SID_ATTR_ZOOMSLIDER: |
2372 | 0 | { |
2373 | 0 | if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) ) |
2374 | 0 | { |
2375 | 0 | if ( const SvxZoomSliderItem* pZoomItem = pArgs->GetItemIfSet(SID_ATTR_ZOOMSLIDER) ) |
2376 | 0 | { |
2377 | 0 | const sal_uInt16 nCurrentZoom = pZoomItem->GetValue(); |
2378 | 0 | SetZoom( SvxZoomType::PERCENT, nCurrentZoom ); |
2379 | 0 | } |
2380 | |
|
2381 | 0 | bUp = true; |
2382 | 0 | rReq.Done(); |
2383 | 0 | } |
2384 | 0 | } |
2385 | 0 | break; |
2386 | | |
2387 | 0 | case SID_ATTR_SIZE: |
2388 | 0 | { |
2389 | 0 | sal_uInt16 nId = 0; |
2390 | 0 | if( rSh.IsCursorInTable() ) |
2391 | 0 | nId = FN_FORMAT_TABLE_DLG; |
2392 | 0 | else if( rSh.GetCurTOX() ) |
2393 | 0 | nId = FN_INSERT_MULTI_TOX; |
2394 | 0 | else if( rSh.GetCurrSection() ) |
2395 | 0 | nId = FN_EDIT_REGION; |
2396 | 0 | else |
2397 | 0 | { |
2398 | 0 | const SwNumRule* pNumRule = rSh.GetNumRuleAtCurrCursorPos(); |
2399 | 0 | if( pNumRule ) // cursor in numbering |
2400 | 0 | { |
2401 | 0 | if( pNumRule->IsAutoRule() ) |
2402 | 0 | nId = FN_NUMBER_BULLETS; |
2403 | 0 | else |
2404 | 0 | { |
2405 | | // start dialog of the painter |
2406 | 0 | nId = 0; |
2407 | 0 | } |
2408 | 0 | } |
2409 | 0 | else if( rSh.IsFrameSelected() ) |
2410 | 0 | nId = FN_FORMAT_FRAME_DLG; |
2411 | 0 | else if( rSh.GetSelectedObjCount() ) |
2412 | 0 | nId = SID_ATTR_TRANSFORM; |
2413 | 0 | } |
2414 | 0 | if( nId ) |
2415 | 0 | GetViewFrame().GetDispatcher()->Execute(nId, |
2416 | 0 | SfxCallMode::SYNCHRON | SfxCallMode::RECORD ); |
2417 | 0 | } |
2418 | 0 | break; |
2419 | | |
2420 | 0 | case FN_STAT_SELMODE: |
2421 | 0 | { |
2422 | 0 | if ( pArgs ) |
2423 | 0 | { |
2424 | 0 | if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem)) |
2425 | 0 | { |
2426 | 0 | switch ( static_cast<const SfxUInt16Item *>(pItem)->GetValue() ) |
2427 | 0 | { |
2428 | 0 | case 0: rSh.EnterStdMode(); break; |
2429 | 0 | case 1: rSh.EnterExtMode(); break; |
2430 | 0 | case 2: rSh.EnterAddMode(); break; |
2431 | 0 | case 3: rSh.EnterBlockMode(); break; |
2432 | 0 | } |
2433 | 0 | } |
2434 | 0 | } |
2435 | 0 | bUp = true; |
2436 | 0 | break; |
2437 | 0 | } |
2438 | 0 | case FN_SET_ADD_MODE: |
2439 | 0 | rSh.ToggleAddMode(); |
2440 | 0 | nWhich = FN_STAT_SELMODE; |
2441 | 0 | bUp = true; |
2442 | 0 | break; |
2443 | 0 | case FN_SET_BLOCK_MODE: |
2444 | 0 | rSh.ToggleBlockMode(); |
2445 | 0 | nWhich = FN_STAT_SELMODE; |
2446 | 0 | bUp = true; |
2447 | 0 | break; |
2448 | 0 | case FN_SET_EXT_MODE: |
2449 | 0 | rSh.ToggleExtMode(); |
2450 | 0 | nWhich = FN_STAT_SELMODE; |
2451 | 0 | bUp = true; |
2452 | 0 | break; |
2453 | 0 | case SID_ATTR_INSERT: |
2454 | 0 | SwPostItMgr* pMgr = GetPostItMgr(); |
2455 | 0 | if ( pMgr && pMgr->HasActiveSidebarWin() ) |
2456 | 0 | { |
2457 | 0 | pMgr->ToggleInsModeOnActiveSidebarWin(); |
2458 | 0 | } |
2459 | 0 | else |
2460 | 0 | rSh.ToggleInsMode(); |
2461 | 0 | bUp = true; |
2462 | 0 | break; |
2463 | |
|
2464 | 0 | } |
2465 | 0 | if ( bUp ) |
2466 | 0 | { |
2467 | 0 | SfxBindings &rBnd = GetViewFrame().GetBindings(); |
2468 | 0 | rBnd.Invalidate(nWhich); |
2469 | 0 | rBnd.Update(nWhich); |
2470 | 0 | } |
2471 | 0 | } |
2472 | | |
2473 | | void SwView::InsFrameMode(sal_uInt16 nCols) |
2474 | 0 | { |
2475 | 0 | if ( m_pWrtShell->HasWholeTabSelection() ) |
2476 | 0 | { |
2477 | 0 | SwFlyFrameAttrMgr aMgr( true, m_pWrtShell.get(), Frmmgr_Type::TEXT, nullptr ); |
2478 | |
|
2479 | 0 | const SwFrameFormat &rPageFormat = |
2480 | 0 | m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster(); |
2481 | 0 | SwTwips lWidth = rPageFormat.GetFrameSize().GetWidth(); |
2482 | 0 | const SvxLRSpaceItem &rLR = rPageFormat.GetLRSpace(); |
2483 | 0 | lWidth -= rLR.ResolveLeft({}) + rLR.ResolveRight({}); |
2484 | 0 | aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height())); |
2485 | 0 | if(nCols > 1) |
2486 | 0 | { |
2487 | 0 | SwFormatCol aCol; |
2488 | 0 | aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() ); |
2489 | 0 | aMgr.SetCol( aCol ); |
2490 | 0 | } |
2491 | 0 | aMgr.InsertFlyFrame(); |
2492 | 0 | } |
2493 | 0 | else |
2494 | 0 | GetEditWin().InsFrame(nCols); |
2495 | 0 | } |
2496 | | |
2497 | | /// show "edit link" dialog |
2498 | | void SwView::EditLinkDlg() |
2499 | 0 | { |
2500 | 0 | if (officecfg::Office::Common::Security::Scripting::DisableActiveContent::get()) |
2501 | 0 | { |
2502 | 0 | std::unique_ptr<weld::MessageDialog> xError( |
2503 | 0 | Application::CreateMessageDialog(nullptr, VclMessageType::Warning, VclButtonsType::Ok, |
2504 | 0 | SvtResId(STR_WARNING_EXTERNAL_LINK_EDIT_DISABLED))); |
2505 | 0 | xError->run(); |
2506 | 0 | return; |
2507 | 0 | } |
2508 | | |
2509 | 0 | bool bWeb = dynamic_cast<SwWebView*>( this ) != nullptr; |
2510 | 0 | SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); |
2511 | 0 | VclPtr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog(GetViewFrame().GetFrameWeld(), &GetWrtShell().GetLinkManager(), bWeb)); |
2512 | 0 | pDlg->StartExecuteAsync( |
2513 | 0 | [pDlg] (sal_Int32 /*nResult*/)->void |
2514 | 0 | { |
2515 | 0 | pDlg->disposeOnce(); |
2516 | 0 | } |
2517 | 0 | ); |
2518 | 0 | } |
2519 | | |
2520 | | namespace sw { |
2521 | | |
2522 | | auto PrepareJumpToTOXMark(SwDoc const& rDoc, std::u16string_view aName) |
2523 | | -> std::optional<std::pair<SwTOXMark, sal_Int32>> |
2524 | 0 | { |
2525 | 0 | size_t const first(aName.find(toxMarkSeparator)); |
2526 | 0 | if (first == std::u16string_view::npos) |
2527 | 0 | { |
2528 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: missing separator"); |
2529 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(); |
2530 | 0 | } |
2531 | 0 | sal_Int32 const counter(o3tl::toInt32(aName.substr(0, first))); |
2532 | 0 | if (counter <= 0) |
2533 | 0 | { |
2534 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: invalid counter"); |
2535 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(); |
2536 | 0 | } |
2537 | 0 | size_t const second(aName.find(toxMarkSeparator, first + 1)); |
2538 | 0 | if (second == std::u16string_view::npos) |
2539 | 0 | { |
2540 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: missing separator"); |
2541 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(); |
2542 | 0 | } |
2543 | 0 | std::u16string_view const entry(aName.substr(first + 1, second - (first + 1))); |
2544 | 0 | if (aName.size() < second + 2) |
2545 | 0 | { |
2546 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: invalid tox"); |
2547 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(); |
2548 | 0 | } |
2549 | 0 | sal_uInt16 const indexType(aName[second + 1]); |
2550 | 0 | std::u16string_view const indexName(aName.substr(second + 2)); |
2551 | 0 | SwTOXType const* pType(nullptr); |
2552 | 0 | switch (indexType) |
2553 | 0 | { |
2554 | 0 | case 'A': |
2555 | 0 | pType = rDoc.GetTOXType(TOX_INDEX, 0); |
2556 | 0 | assert(pType); |
2557 | 0 | break; |
2558 | 0 | case 'C': |
2559 | 0 | pType = rDoc.GetTOXType(TOX_CONTENT, 0); |
2560 | 0 | assert(pType); |
2561 | 0 | break; |
2562 | 0 | case 'U': |
2563 | 0 | for (auto i = rDoc.GetTOXTypeCount(TOX_USER); 0 < i; ) |
2564 | 0 | { |
2565 | 0 | --i; |
2566 | 0 | auto const pTmp(rDoc.GetTOXType(TOX_USER, i)); |
2567 | 0 | if (pTmp->GetTypeName() == indexName) |
2568 | 0 | { |
2569 | 0 | pType = pTmp; |
2570 | 0 | break; |
2571 | 0 | } |
2572 | 0 | } |
2573 | 0 | break; |
2574 | 0 | } |
2575 | 0 | if (!pType) |
2576 | 0 | { |
2577 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: tox doesn't exist"); |
2578 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(); |
2579 | 0 | } |
2580 | | // type and alt text are the search keys |
2581 | 0 | SwTOXMark tmp(pType); |
2582 | 0 | tmp.SetAlternativeText(OUString(entry)); |
2583 | 0 | return std::optional<std::pair<SwTOXMark, sal_Int32>>(std::pair<SwTOXMark, sal_Int32>(tmp, counter)); |
2584 | 0 | } |
2585 | | |
2586 | | } // namespace sw |
2587 | | |
2588 | | static auto JumpToTOXMark(SwWrtShell & rSh, std::u16string_view aName) -> bool |
2589 | 0 | { |
2590 | 0 | std::optional<std::pair<SwTOXMark, sal_Int32>> const tmp( |
2591 | 0 | sw::PrepareJumpToTOXMark(*rSh.GetDoc(), aName)); |
2592 | 0 | if (!tmp) |
2593 | 0 | { |
2594 | 0 | return false; |
2595 | 0 | } |
2596 | 0 | SwTOXMark const* pMark(&tmp->first); |
2597 | | // hack: check first if one exists |
2598 | | // need simple ptr control, else UnitTest CppunitTest_sw_uiwriter3 fails |
2599 | 0 | if (!areSfxPoolItemPtrsEqual(&tmp->first, &rSh.GetDoc()->GotoTOXMark(tmp->first, TOX_SAME_NXT, rSh.IsReadOnlyAvailable()))) |
2600 | 0 | { |
2601 | 0 | for (sal_Int32 i = 0; i < tmp->second; ++i) |
2602 | 0 | { |
2603 | 0 | pMark = &rSh.GotoTOXMark(*pMark, TOX_SAME_NXT); |
2604 | 0 | } |
2605 | 0 | return true; |
2606 | 0 | } |
2607 | 0 | else |
2608 | 0 | { |
2609 | 0 | SAL_WARN("sw.ui", "JumpToTOXMark: tox mark doesn't exist"); |
2610 | 0 | return false; |
2611 | 0 | } |
2612 | 0 | } |
2613 | | |
2614 | | bool SwView::JumpToSwMark( const SwMarkName& rMark ) |
2615 | 1 | { |
2616 | 1 | bool bRet = false; |
2617 | 1 | if( !rMark.toString().isEmpty() ) |
2618 | 1 | { |
2619 | | // place bookmark at top-center |
2620 | 1 | bool bSaveCC = m_bCenterCursor; |
2621 | 1 | bool bSaveCT = m_bTopCursor; |
2622 | 1 | SetCursorAtTop( true ); |
2623 | | |
2624 | | // For scrolling the FrameSet, the corresponding shell needs to have the focus. |
2625 | 1 | bool bHasShFocus = m_pWrtShell->HasShellFocus(); |
2626 | 1 | if( !bHasShFocus ) |
2627 | 0 | m_pWrtShell->ShellGetFocus(); |
2628 | | |
2629 | 1 | const SwFormatINetFormat* pINet; |
2630 | 1 | OUString sCmp; |
2631 | 1 | OUString sMark( INetURLObject::decode( rMark.toString(), |
2632 | 1 | INetURLObject::DecodeMechanism::WithCharset )); |
2633 | | |
2634 | 1 | sal_Int32 nLastPos, nPos = sMark.indexOf( cMarkSeparator ); |
2635 | 1 | if( -1 != nPos ) |
2636 | 0 | while( -1 != ( nLastPos = sMark.indexOf( cMarkSeparator, nPos + 1 )) ) |
2637 | 0 | nPos = nLastPos; |
2638 | | |
2639 | 1 | IDocumentMarkAccess::const_iterator ppMark; |
2640 | 1 | IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess(); |
2641 | 1 | if( -1 != nPos ) |
2642 | 0 | sCmp = sMark.copy(nPos + 1).replaceAll(" ", ""); |
2643 | | |
2644 | 1 | if( !sCmp.isEmpty() ) |
2645 | 0 | { |
2646 | 0 | OUString sName( sMark.copy( 0, nPos ) ); |
2647 | 0 | sCmp = sCmp.toAsciiLowerCase(); |
2648 | 0 | FlyCntType eFlyType = FLYCNTTYPE_ALL; |
2649 | |
|
2650 | 0 | if (sCmp == "drawingobject") |
2651 | 0 | bRet = m_pWrtShell->GotoDrawingObject(sName); |
2652 | 0 | else if( sCmp == "region" ) |
2653 | 0 | { |
2654 | 0 | m_pWrtShell->EnterStdMode(); |
2655 | 0 | bRet = m_pWrtShell->GotoRegion( sName ); |
2656 | 0 | } |
2657 | 0 | else if( sCmp == "outline" ) |
2658 | 0 | { |
2659 | 0 | m_pWrtShell->EnterStdMode(); |
2660 | 0 | bRet = m_pWrtShell->GotoOutline( sName ); |
2661 | 0 | } |
2662 | 0 | else if( sCmp == "frame" ) |
2663 | 0 | eFlyType = FLYCNTTYPE_FRM; |
2664 | 0 | else if( sCmp == "graphic" ) |
2665 | 0 | eFlyType = FLYCNTTYPE_GRF; |
2666 | 0 | else if( sCmp == "ole" ) |
2667 | 0 | eFlyType = FLYCNTTYPE_OLE; |
2668 | 0 | else if( sCmp == "table" ) |
2669 | 0 | { |
2670 | 0 | m_pWrtShell->EnterStdMode(); |
2671 | 0 | bRet = m_pWrtShell->GotoTable( UIName(sName) ); |
2672 | 0 | } |
2673 | 0 | else if( sCmp == "sequence" ) |
2674 | 0 | { |
2675 | 0 | m_pWrtShell->EnterStdMode(); |
2676 | 0 | sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator ); |
2677 | 0 | if ( nNoPos != -1 ) |
2678 | 0 | { |
2679 | 0 | sal_uInt16 nSeqNo = o3tl::toInt32(sName.subView( nNoPos + 1 )); |
2680 | 0 | sName = sName.copy( 0, nNoPos ); |
2681 | 0 | bRet = m_pWrtShell->GotoRefMark(SwMarkName(sName), ReferencesSubtype::SequenceField, nSeqNo); |
2682 | 0 | } |
2683 | 0 | } |
2684 | 0 | else if (sCmp == "toxmark") |
2685 | 0 | { |
2686 | 0 | bRet = JumpToTOXMark(*m_pWrtShell, sName); |
2687 | 0 | } |
2688 | 0 | else if( sCmp == "text" ) |
2689 | 0 | { |
2690 | | // normal text search |
2691 | 0 | m_pWrtShell->EnterStdMode(); |
2692 | |
|
2693 | 0 | i18nutil::SearchOptions2 aSearchOpt( |
2694 | 0 | 0, |
2695 | 0 | sName, OUString(), |
2696 | 0 | SvtSysLocale().GetLanguageTag().getLocale(), |
2697 | 0 | 0,0,0, |
2698 | 0 | TransliterationFlags::IGNORE_CASE, |
2699 | 0 | SearchAlgorithms2::ABSOLUTE, |
2700 | 0 | '\\' ); |
2701 | | |
2702 | | //todo/mba: assuming that notes shouldn't be searched |
2703 | 0 | if( m_pWrtShell->SearchPattern( aSearchOpt, false/*bSearchInNotes*/, SwDocPositions::Start, SwDocPositions::End )) |
2704 | 0 | { |
2705 | 0 | m_pWrtShell->EnterStdMode(); // remove the selection |
2706 | 0 | bRet = true; |
2707 | 0 | } |
2708 | 0 | } |
2709 | 0 | else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(SwMarkName(sMark))) ) |
2710 | 0 | { |
2711 | 0 | bRet = m_pWrtShell->GotoMark( *ppMark, false ); |
2712 | 0 | } |
2713 | 0 | else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) { |
2714 | 0 | m_pWrtShell->addCurrentPosition(); |
2715 | 0 | bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() ); |
2716 | 0 | } |
2717 | | |
2718 | | // for all types of Flys |
2719 | 0 | if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( UIName(sName), eFlyType )) |
2720 | 0 | { |
2721 | 0 | bRet = true; |
2722 | 0 | if( FLYCNTTYPE_FRM == eFlyType ) |
2723 | 0 | { |
2724 | | // TextFrames: set Cursor in the frame |
2725 | 0 | m_pWrtShell->UnSelectFrame(); |
2726 | 0 | m_pWrtShell->LeaveSelFrameMode(); |
2727 | 0 | } |
2728 | 0 | else |
2729 | 0 | { |
2730 | 0 | m_pWrtShell->HideCursor(); |
2731 | 0 | m_pWrtShell->EnterSelFrameMode(); |
2732 | 0 | } |
2733 | 0 | } |
2734 | 0 | } |
2735 | 1 | else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(SwMarkName(sMark)))) |
2736 | 1 | { |
2737 | 1 | bRet = m_pWrtShell->GotoMark( *ppMark, false ); |
2738 | 1 | } |
2739 | 0 | else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) |
2740 | 0 | bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() ); |
2741 | | |
2742 | | // make selection visible later |
2743 | 1 | if ( m_aVisArea.IsEmpty() ) |
2744 | 1 | m_bMakeSelectionVisible = true; |
2745 | | |
2746 | | // reset ViewStatus |
2747 | 1 | SetCursorAtTop( bSaveCT, bSaveCC ); |
2748 | | |
2749 | 1 | if(!m_pWrtShell->IsFrameSelected() && !m_pWrtShell->GetSelectedObjCount() && !m_pWrtShell->IsViewLocked()) |
2750 | 0 | m_pWrtShell->ShowCursor(); |
2751 | | |
2752 | 1 | if( !bHasShFocus ) |
2753 | 0 | m_pWrtShell->ShellLoseFocus(); |
2754 | 1 | } |
2755 | 1 | return bRet; |
2756 | 1 | } |
2757 | | |
2758 | | // #i67305# Undo after insert from file: |
2759 | | // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled |
2760 | | // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains |
2761 | | // page styles with active header/footer => disabled for those documents |
2762 | | static size_t lcl_PageDescWithHeader( const SwDoc& rDoc ) |
2763 | 0 | { |
2764 | 0 | size_t nRet = 0; |
2765 | 0 | size_t nCnt = rDoc.GetPageDescCnt(); |
2766 | 0 | for( size_t i = 0; i < nCnt; ++i ) |
2767 | 0 | { |
2768 | 0 | const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i ); |
2769 | 0 | const SwFrameFormat& rMaster = rPageDesc.GetMaster(); |
2770 | 0 | const SwFormatHeader* pHeaderItem = rMaster.GetAttrSet().GetItemIfSet( RES_HEADER, false ); |
2771 | 0 | const SwFormatFooter* pFooterItem = rMaster.GetAttrSet().GetItemIfSet( RES_FOOTER, false ); |
2772 | 0 | if( (pHeaderItem && pHeaderItem->IsActive()) || |
2773 | 0 | (pFooterItem && pFooterItem->IsActive()) ) |
2774 | 0 | ++nRet; |
2775 | 0 | } |
2776 | 0 | return nRet; // number of page styles with active header/footer |
2777 | 0 | } |
2778 | | |
2779 | | void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem ) |
2780 | 0 | { |
2781 | 0 | m_pViewImpl->InitRequest( rRequest ); |
2782 | 0 | m_pViewImpl->SetParam( pItem ? 1 : 0 ); |
2783 | 0 | const sal_uInt16 nSlot = rRequest.GetSlot(); |
2784 | |
|
2785 | 0 | if ( !pItem ) |
2786 | 0 | { |
2787 | 0 | InsertDoc( nSlot, u""_ustr, u""_ustr ); |
2788 | 0 | } |
2789 | 0 | else |
2790 | 0 | { |
2791 | 0 | OUString sFile, sFilter; |
2792 | 0 | sFile = static_cast<const SfxStringItem *>( pItem )->GetValue(); |
2793 | 0 | if ( SfxItemState::SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, true, &pItem ) ) |
2794 | 0 | sFilter = static_cast<const SfxStringItem *>(pItem )->GetValue(); |
2795 | |
|
2796 | 0 | bool bHasFileName = !sFile.isEmpty(); |
2797 | 0 | tools::Long nFound = InsertDoc( nSlot, sFile, sFilter ); |
2798 | |
|
2799 | 0 | if ( bHasFileName ) |
2800 | 0 | { |
2801 | 0 | rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); |
2802 | 0 | rRequest.Done(); |
2803 | 0 | } |
2804 | 0 | } |
2805 | 0 | } |
2806 | | |
2807 | | tools::Long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion ) |
2808 | 0 | { |
2809 | 0 | std::unique_ptr<SfxMedium> pMed; |
2810 | 0 | SwDocShell* pDocSh = GetDocShell(); |
2811 | |
|
2812 | 0 | if( !rFileName.isEmpty() ) |
2813 | 0 | { |
2814 | 0 | SfxObjectFactory& rFact = pDocSh->GetFactory(); |
2815 | 0 | std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName ); |
2816 | 0 | if ( !pFilter ) |
2817 | 0 | { |
2818 | 0 | pMed.reset(new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr )); |
2819 | 0 | SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() ); |
2820 | 0 | pMed->UseInteractionHandler( true ); |
2821 | 0 | ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE); |
2822 | 0 | if ( nErr ) |
2823 | 0 | pMed.reset(); |
2824 | 0 | else |
2825 | 0 | pMed->SetFilter( pFilter ); |
2826 | 0 | } |
2827 | 0 | else |
2828 | 0 | pMed.reset(new SfxMedium(rFileName, StreamMode::READ, std::move(pFilter), nullptr)); |
2829 | 0 | } |
2830 | 0 | else |
2831 | 0 | { |
2832 | 0 | m_pViewImpl->StartDocumentInserter( |
2833 | | // tdf#118578 allow inserting any Writer document except GlobalDoc |
2834 | 0 | SwDocShell::Factory().GetFactoryName(), |
2835 | 0 | LINK( this, SwView, DialogClosedHdl ), |
2836 | 0 | nSlotId |
2837 | 0 | ); |
2838 | 0 | return -1; |
2839 | 0 | } |
2840 | | |
2841 | 0 | if( !pMed ) |
2842 | 0 | return -1; |
2843 | | |
2844 | 0 | return InsertMedium( nSlotId, std::move(pMed), nVersion ); |
2845 | 0 | } |
2846 | | |
2847 | | tools::Long SwView::InsertMedium( sal_uInt16 nSlotId, std::unique_ptr<SfxMedium> pMedium, sal_Int16 nVersion ) |
2848 | 0 | { |
2849 | 0 | bool bInsert = false, bCompare = false; |
2850 | 0 | tools::Long nFound = 0; |
2851 | 0 | SwDocShell* pDocSh = GetDocShell(); |
2852 | |
|
2853 | 0 | switch( nSlotId ) |
2854 | 0 | { |
2855 | 0 | case SID_DOCUMENT_MERGE: break; |
2856 | 0 | case SID_DOCUMENT_COMPARE: bCompare = true; break; |
2857 | 0 | case SID_INSERTDOC: bInsert = true; break; |
2858 | | |
2859 | 0 | default: |
2860 | 0 | OSL_ENSURE( false, "unknown SlotId!" ); |
2861 | 0 | bInsert = true; |
2862 | 0 | break; |
2863 | 0 | } |
2864 | | |
2865 | 0 | if( bInsert ) |
2866 | 0 | { |
2867 | 0 | uno::Reference< frame::XDispatchRecorder > xRecorder = |
2868 | 0 | GetViewFrame().GetBindings().GetRecorder(); |
2869 | 0 | if ( xRecorder.is() ) |
2870 | 0 | { |
2871 | 0 | SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC); |
2872 | 0 | aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL())); |
2873 | 0 | if(pMedium->GetFilter()) |
2874 | 0 | aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName())); |
2875 | 0 | aRequest.Done(); |
2876 | 0 | } |
2877 | |
|
2878 | 0 | SfxObjectShellRef aRef( pDocSh ); |
2879 | |
|
2880 | 0 | ErrCode nError = SfxObjectShell::HandleFilter( pMedium.get(), pDocSh ); |
2881 | | // #i16722# aborted? |
2882 | 0 | if(nError != ERRCODE_NONE) |
2883 | 0 | { |
2884 | 0 | return -1; |
2885 | 0 | } |
2886 | | |
2887 | 0 | pMedium->Download(); // start download if needed |
2888 | 0 | if( aRef.is() && 1 < aRef->GetRefCount() ) // still a valid ref? |
2889 | 0 | { |
2890 | 0 | SwReaderPtr pRdr; |
2891 | 0 | Reader *pRead = pDocSh->StartConvertFrom(*pMedium, pRdr, m_pWrtShell.get()); |
2892 | 0 | if( pRead || |
2893 | 0 | (pMedium->GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER) ) |
2894 | 0 | { |
2895 | 0 | size_t nUndoCheck = 0; |
2896 | 0 | SwDoc *pDoc = pDocSh->GetDoc(); |
2897 | 0 | if( pRead && pDocSh->GetDoc() ) |
2898 | 0 | nUndoCheck = lcl_PageDescWithHeader( *pDoc ); |
2899 | 0 | ErrCodeMsg nErrno; |
2900 | 0 | { //Scope for SwWait-Object, to be able to execute slots |
2901 | | //outside this scope. |
2902 | 0 | SwWait aWait( *GetDocShell(), true ); |
2903 | 0 | m_pWrtShell->StartAllAction(); |
2904 | 0 | if ( m_pWrtShell->HasSelection() ) |
2905 | 0 | m_pWrtShell->DelRight(); // delete selections |
2906 | 0 | if( pRead ) |
2907 | 0 | { |
2908 | 0 | nErrno = pRdr->Read( *pRead ); // and insert document |
2909 | 0 | pRdr.reset(); |
2910 | 0 | } |
2911 | 0 | else |
2912 | 0 | { |
2913 | 0 | ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); |
2914 | 0 | rtl::Reference<SwXTextRange> const xInsertPosition( |
2915 | 0 | SwXTextRange::CreateXTextRange(*pDoc, |
2916 | 0 | *m_pWrtShell->GetCursor()->GetPoint(), nullptr)); |
2917 | 0 | nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition) |
2918 | 0 | ? ERRCODE_NONE : ERR_SWG_READ_ERROR; |
2919 | 0 | } |
2920 | |
|
2921 | 0 | } |
2922 | | |
2923 | | // update all "table of ..." sections if needed |
2924 | 0 | if( m_pWrtShell->IsUpdateTOX() ) |
2925 | 0 | { |
2926 | 0 | SfxRequest aReq( FN_UPDATE_TOX, SfxCallMode::SLOT, GetPool() ); |
2927 | 0 | Execute( aReq ); |
2928 | 0 | m_pWrtShell->SetUpdateTOX( false ); // reset |
2929 | 0 | } |
2930 | |
|
2931 | 0 | if( pDoc ) |
2932 | 0 | { // Disable Undo for .sdw or |
2933 | | // if the number of page styles with header/footer has changed |
2934 | 0 | if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) ) |
2935 | 0 | { |
2936 | 0 | pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); |
2937 | 0 | } |
2938 | 0 | } |
2939 | |
|
2940 | 0 | m_pWrtShell->EndAllAction(); |
2941 | 0 | if( nErrno ) |
2942 | 0 | { |
2943 | 0 | ErrorHandler::HandleError( nErrno ); |
2944 | 0 | nFound = nErrno.IsError() ? -1 : 0; |
2945 | 0 | } |
2946 | 0 | else |
2947 | 0 | nFound = 0; |
2948 | 0 | } |
2949 | 0 | } |
2950 | 0 | } |
2951 | 0 | else |
2952 | 0 | { |
2953 | 0 | SfxObjectShellRef xDocSh; |
2954 | 0 | SfxObjectShellLock xLockRef; |
2955 | |
|
2956 | 0 | const int nRet = SwFindDocShell( xDocSh, xLockRef, pMedium->GetName(), OUString(), |
2957 | 0 | OUString(), nVersion, pDocSh, pMedium->GetInteractionHandler() ); |
2958 | 0 | if( nRet ) |
2959 | 0 | { |
2960 | 0 | SwWait aWait( *GetDocShell(), true ); |
2961 | 0 | m_pWrtShell->StartAllAction(); |
2962 | |
|
2963 | 0 | m_pWrtShell->EnterStdMode(); // delete selections |
2964 | |
|
2965 | 0 | if( bCompare ) |
2966 | 0 | nFound = m_pWrtShell->CompareDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() ); |
2967 | 0 | else |
2968 | 0 | nFound = m_pWrtShell->MergeDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() ); |
2969 | |
|
2970 | 0 | m_pWrtShell->EndAllAction(); |
2971 | |
|
2972 | 0 | if (!bCompare && !nFound) |
2973 | 0 | { |
2974 | 0 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(), |
2975 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
2976 | 0 | SwResId(STR_NO_MERGE_ENTRY))); |
2977 | 0 | xInfoBox->run(); |
2978 | 0 | } |
2979 | 0 | if( nRet==2 && xDocSh.is() ) |
2980 | 0 | xDocSh->DoClose(); |
2981 | 0 | } |
2982 | 0 | } |
2983 | | |
2984 | 0 | return nFound; |
2985 | 0 | } |
2986 | | |
2987 | | void SwView::EnableMailMerge() |
2988 | 0 | { |
2989 | 0 | m_bInMailMerge = true; |
2990 | 0 | SfxBindings& rBind = GetViewFrame().GetBindings(); |
2991 | 0 | rBind.Invalidate(FN_INSERT_FIELD_DATA_ONLY); |
2992 | 0 | rBind.Update(FN_INSERT_FIELD_DATA_ONLY); |
2993 | 0 | } |
2994 | | |
2995 | | #if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS |
2996 | | |
2997 | | namespace |
2998 | | { |
2999 | | bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext ) |
3000 | | { |
3001 | | Sequence < OUString > aNames = _rDatasourceContext->getElementNames(); |
3002 | | |
3003 | | return ( !aNames.hasElements() |
3004 | | || ( ( 1 == aNames.getLength() ) |
3005 | | && aNames.getConstArray()[0] == SwModule::get()->GetDBConfig()->GetBibliographySource().sDataSource |
3006 | | ) |
3007 | | ); |
3008 | | } |
3009 | | } |
3010 | | |
3011 | | #endif |
3012 | | |
3013 | | void SwView::GenerateFormLetter(bool bUseCurrentDocument) |
3014 | 0 | { |
3015 | 0 | #if !HAVE_FEATURE_DBCONNECTIVITY || ENABLE_FUZZERS |
3016 | 0 | (void) bUseCurrentDocument; |
3017 | | #else |
3018 | | if(bUseCurrentDocument) |
3019 | | { |
3020 | | if(!GetWrtShell().IsAnyDatabaseFieldInDoc()) |
3021 | | { |
3022 | | //check availability of data sources (except biblio source) |
3023 | | const uno::Reference<XComponentContext>& xContext( ::comphelper::getProcessComponentContext() ); |
3024 | | uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext); |
3025 | | bool bCallAddressPilot = false; |
3026 | | if ( lcl_NeedAdditionalDataSource( xDBContext ) ) |
3027 | | { |
3028 | | // no data sources are available - create a new one |
3029 | | std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"modules/swriter/ui/datasourcesunavailabledialog.ui"_ustr)); |
3030 | | std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog(u"DataSourcesUnavailableDialog"_ustr)); |
3031 | | // no cancel allowed |
3032 | | if (RET_OK != xQuery->run()) |
3033 | | return; |
3034 | | bCallAddressPilot = true; |
3035 | | } |
3036 | | else |
3037 | | { |
3038 | | //take an existing data source or create a new one? |
3039 | | SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); |
3040 | | ScopedVclPtr<AbstractMailMergeFieldConnectionsDlg> pConnectionsDlg(pFact->CreateMailMergeFieldConnectionsDlg(GetFrameWeld())); |
3041 | | if(RET_OK == pConnectionsDlg->Execute()) |
3042 | | bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections(); |
3043 | | else |
3044 | | return; |
3045 | | |
3046 | | } |
3047 | | if(bCallAddressPilot) |
3048 | | { |
3049 | | GetViewFrame().GetDispatcher()->Execute( |
3050 | | SID_ADDRESS_DATA_SOURCE, SfxCallMode::SYNCHRON); |
3051 | | if ( lcl_NeedAdditionalDataSource( xDBContext ) ) |
3052 | | // no additional data source has been created |
3053 | | // -> assume that the user has cancelled the pilot |
3054 | | return; |
3055 | | } |
3056 | | |
3057 | | //call insert fields with database field page available, only |
3058 | | SfxViewFrame& rVFrame = GetViewFrame(); |
3059 | | //at first hide the default field dialog if currently visible |
3060 | | rVFrame.SetChildWindow(FN_INSERT_FIELD, false); |
3061 | | //enable the status of the db field dialog - it is disabled in the status method |
3062 | | //to prevent creation of the dialog without mail merge active |
3063 | | EnableMailMerge(); |
3064 | | //then show the "Data base only" field dialog |
3065 | | SfxBoolItem aOn(FN_INSERT_FIELD_DATA_ONLY, true); |
3066 | | rVFrame.GetDispatcher()->ExecuteList(FN_INSERT_FIELD_DATA_ONLY, |
3067 | | SfxCallMode::SYNCHRON, { &aOn }); |
3068 | | return; |
3069 | | } |
3070 | | else |
3071 | | { |
3072 | | OUString sSource; |
3073 | | if(!GetWrtShell().IsFieldDataSourceAvailable(sSource)) |
3074 | | { |
3075 | | std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), u"modules/swriter/ui/warndatasourcedialog.ui"_ustr)); |
3076 | | std::unique_ptr<weld::MessageDialog> xWarning(xBuilder->weld_message_dialog(u"WarnDataSourceDialog"_ustr)); |
3077 | | OUString sTmp(xWarning->get_primary_text()); |
3078 | | xWarning->set_primary_text(sTmp.replaceFirst("%1", sSource)); |
3079 | | if (RET_OK == xWarning->run()) |
3080 | | { |
3081 | | SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); |
3082 | | VclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( nullptr, SID_OPTIONS_DATABASES )); |
3083 | | pDlg->StartExecuteAsync( |
3084 | | [pDlg] (sal_Int32 /*nResult*/)->void |
3085 | | { |
3086 | | pDlg->disposeOnce(); |
3087 | | } |
3088 | | ); |
3089 | | } |
3090 | | return ; |
3091 | | } |
3092 | | } |
3093 | | SwDBManager* pDBManager = GetWrtShell().GetDBManager(); |
3094 | | |
3095 | | SwDBData aData; |
3096 | | SwWrtShell &rSh = GetWrtShell(); |
3097 | | |
3098 | | std::vector<OUString> aDBNameList; |
3099 | | std::vector<OUString> aAllDBNames; |
3100 | | rSh.GetAllUsedDB( aDBNameList, &aAllDBNames ); |
3101 | | if(!aDBNameList.empty()) |
3102 | | { |
3103 | | const OUString& sDBName(aDBNameList[0]); |
3104 | | sal_Int32 nIdx {0}; |
3105 | | aData.sDataSource = sDBName.getToken(0, DB_DELIM, nIdx); |
3106 | | aData.sCommand = sDBName.getToken(0, DB_DELIM, nIdx); |
3107 | | aData.nCommandType = o3tl::toInt32(o3tl::getToken(sDBName, 0, DB_DELIM, nIdx)); |
3108 | | } |
3109 | | rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields |
3110 | | AttrChangedNotify(nullptr); |
3111 | | |
3112 | | if (pDBManager) |
3113 | | { |
3114 | | Sequence<PropertyValue> aProperties |
3115 | | { |
3116 | | comphelper::makePropertyValue(u"DataSourceName"_ustr, aData.sDataSource), |
3117 | | comphelper::makePropertyValue(u"Command"_ustr, aData.sCommand), |
3118 | | comphelper::makePropertyValue(u"CommandType"_ustr, aData.nCommandType), |
3119 | | }; |
3120 | | pDBManager->ExecuteFormLetter(GetWrtShell(), aProperties); |
3121 | | } |
3122 | | } |
3123 | | else |
3124 | | { |
3125 | | // call documents and template dialog |
3126 | | SfxApplication* pSfxApp = SfxGetpApp(); |
3127 | | weld::Window* pTopWin = pSfxApp->GetTopWindow(); |
3128 | | |
3129 | | SfxTemplateManagerDlg aDocTemplDlg(GetFrameWeld()); |
3130 | | int nRet = aDocTemplDlg.run(); |
3131 | | bool bNewWin = false; |
3132 | | if ( nRet == RET_OK ) |
3133 | | { |
3134 | | if ( pTopWin != pSfxApp->GetTopWindow() ) |
3135 | | { |
3136 | | // the dialogue opens a document -> a new TopWindow appears |
3137 | | pTopWin = pSfxApp->GetTopWindow(); |
3138 | | bNewWin = true; |
3139 | | } |
3140 | | } |
3141 | | |
3142 | | if (bNewWin) |
3143 | | { |
3144 | | // after the destruction of the dialogue its parent comes to top, |
3145 | | // but we want that the new document is on top |
3146 | | pTopWin->present(); |
3147 | | } |
3148 | | } |
3149 | | #endif |
3150 | 0 | } |
3151 | | |
3152 | | IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void ) |
3153 | 0 | { |
3154 | 0 | if ( ERRCODE_NONE != _pFileDlg->GetError() ) |
3155 | 0 | return; |
3156 | | |
3157 | 0 | std::unique_ptr<SfxMedium> pMed = m_pViewImpl->CreateMedium(); |
3158 | 0 | if ( !pMed ) |
3159 | 0 | { |
3160 | 0 | std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(), |
3161 | 0 | VclMessageType::Info, VclButtonsType::Ok, |
3162 | 0 | SwResId(RID_SVXSTR_TXTFILTER_FILTERERROR))); |
3163 | 0 | xInfoBox->run(); |
3164 | 0 | return; |
3165 | 0 | } |
3166 | | |
3167 | 0 | const sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot(); |
3168 | 0 | tools::Long nFound = InsertMedium( nSlot, std::move(pMed), m_pViewImpl->GetParam() ); |
3169 | |
|
3170 | 0 | if ( SID_INSERTDOC == nSlot ) |
3171 | 0 | { |
3172 | 0 | if ( m_pViewImpl->GetParam() == 0 ) |
3173 | 0 | { |
3174 | 0 | m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); |
3175 | 0 | m_pViewImpl->GetRequest()->Ignore(); |
3176 | 0 | } |
3177 | 0 | else |
3178 | 0 | { |
3179 | 0 | m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) ); |
3180 | 0 | m_pViewImpl->GetRequest()->Done(); |
3181 | 0 | } |
3182 | 0 | } |
3183 | 0 | else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot ) |
3184 | 0 | { |
3185 | 0 | m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) ); |
3186 | |
|
3187 | 0 | if ( nFound > 0 ) // show Redline browser |
3188 | 0 | { |
3189 | 0 | SfxViewFrame& rVFrame = GetViewFrame(); |
3190 | 0 | rVFrame.ShowChildWindow(FN_REDLINE_ACCEPT); |
3191 | | |
3192 | | // re-initialize Redline dialog |
3193 | 0 | sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId(); |
3194 | 0 | SwRedlineAcceptChild* pRed = static_cast<SwRedlineAcceptChild*>(rVFrame.GetChildWindow( nId )); |
3195 | 0 | if ( pRed ) |
3196 | 0 | pRed->ReInitDlg(); |
3197 | 0 | } |
3198 | 0 | } |
3199 | 0 | } |
3200 | | |
3201 | | void SwView::ExecuteScan( SfxRequest& rReq ) |
3202 | 0 | { |
3203 | 0 | if (m_pViewImpl) |
3204 | 0 | m_pViewImpl->ExecuteScan(rReq) ; |
3205 | 0 | } |
3206 | | |
3207 | | const OUString& SwView::GetOldGrfCat() |
3208 | 0 | { |
3209 | 0 | return GetCachedString(OldGrfCat); |
3210 | 0 | } |
3211 | | |
3212 | | void SwView::SetOldGrfCat(const OUString& sStr) |
3213 | 0 | { |
3214 | 0 | SetCachedString(OldGrfCat, sStr); |
3215 | 0 | } |
3216 | | |
3217 | | const OUString& SwView::GetOldTabCat() |
3218 | 0 | { |
3219 | 0 | return GetCachedString(OldTabCat); |
3220 | 0 | } |
3221 | | |
3222 | | void SwView::SetOldTabCat(const OUString& sStr) |
3223 | 0 | { |
3224 | 0 | SetCachedString(OldTabCat, sStr); |
3225 | 0 | } |
3226 | | |
3227 | | const OUString& SwView::GetOldFrameCat() |
3228 | 0 | { |
3229 | 0 | return GetCachedString(OldFrameCat); |
3230 | 0 | } |
3231 | | |
3232 | | void SwView::SetOldFrameCat(const OUString& sStr) |
3233 | 0 | { |
3234 | 0 | SetCachedString(OldFrameCat, sStr); |
3235 | 0 | } |
3236 | | |
3237 | | const OUString& SwView::GetOldDrwCat() |
3238 | 0 | { |
3239 | 0 | return GetCachedString(OldDrwCat); |
3240 | 0 | } |
3241 | | |
3242 | | void SwView::SetOldDrwCat(const OUString& sStr) |
3243 | 0 | { |
3244 | 0 | SwView::SetCachedString(OldDrwCat, sStr); |
3245 | 0 | } |
3246 | | |
3247 | | |
3248 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |