LibreOffice Module sw (master)  1
view2.cxx
Go to the documentation of this file.
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 
22 #include <com/sun/star/util/SearchAlgorithms2.hpp>
23 #include <o3tl/any.hxx>
24 #include <vcl/graphicfilter.hxx>
25 #include <com/sun/star/sdb/DatabaseContext.hpp>
26 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
27 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
28 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
29 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
30 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
31 #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
32 #include <com/sun/star/linguistic2/XDictionary.hpp>
33 #include <officecfg/Office/Common.hxx>
34 #include <SwCapObjType.hxx>
35 #include <SwStyleNameMapper.hxx>
36 #include <docary.hxx>
37 #include <hintids.hxx>
38 #include <SwRewriter.hxx>
39 #include <numrule.hxx>
40 #include <swundo.hxx>
41 #include <svl/PasswordHelper.hxx>
42 #include <svl/urihelper.hxx>
43 #include <sfx2/passwd.hxx>
44 #include <sfx2/sfxdlg.hxx>
45 #include <sfx2/filedlghelper.hxx>
46 #include <editeng/langitem.hxx>
47 #include <svx/viewlayoutitem.hxx>
48 #include <svx/zoomslideritem.hxx>
49 #include <svx/linkwarn.hxx>
50 #include <sfx2/htmlmode.hxx>
51 #include <vcl/svapp.hxx>
52 #include <sfx2/app.hxx>
53 #include <sfx2/request.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <editeng/lrspitem.hxx>
57 #include <unotools/syslocale.hxx>
58 #include <editeng/unolingu.hxx>
59 #include <vcl/weld.hxx>
60 #include <editeng/tstpitem.hxx>
61 #include <sfx2/event.hxx>
62 #include <sfx2/docfile.hxx>
63 #include <sfx2/docfilt.hxx>
64 #include <sfx2/fcontnr.hxx>
65 #include <editeng/sizeitem.hxx>
66 #include <sfx2/dispatch.hxx>
67 #include <svl/whiter.hxx>
68 #include <svl/ptitem.hxx>
69 #include <sfx2/viewfrm.hxx>
70 #include <vcl/errinf.hxx>
71 #include <tools/urlobj.hxx>
72 #include <svx/svdview.hxx>
73 #include <swtypes.hxx>
74 #include <swwait.hxx>
75 #include <redlndlg.hxx>
76 #include <gotodlg.hxx>
77 #include <view.hxx>
78 #include <uivwimp.hxx>
79 #include <docsh.hxx>
80 #include <doc.hxx>
81 #include <printdata.hxx>
85 #include <IDocumentUndoRedo.hxx>
88 #include <IDocumentStatistics.hxx>
89 #include <wrtsh.hxx>
90 #include <viewopt.hxx>
91 #include <basesh.hxx>
92 #include <swmodule.hxx>
93 #include <uitool.hxx>
94 #include <shellio.hxx>
95 #include <fmtinfmt.hxx>
96 #include <mdiexp.hxx>
97 #include <drawbase.hxx>
98 #include <frmatr.hxx>
99 #include <frmmgr.hxx>
100 #include <pagedesc.hxx>
101 #include <section.hxx>
102 #include <tox.hxx>
103 #include <edtwin.hxx>
104 #include <wview.hxx>
105 #include <cmdid.h>
106 #include <sfx2/strings.hrc>
107 #include <sfx2/sfxresid.hxx>
108 #include <strings.hrc>
109 #include <swerror.h>
110 #include <globals.hrc>
111 #include <fmtclds.hxx>
112 #include <sfx2/templatedlg.hxx>
113 #include <dbconfig.hxx>
114 #include <dbmgr.hxx>
115 #include <reffld.hxx>
116 #include <comphelper/lok.hxx>
117 
118 #include <PostItMgr.hxx>
119 
121 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
122 
123 #include <svx/svxdlg.hxx>
124 #include <swabstdlg.hxx>
125 #include <fmthdft.hxx>
126 #include <unotextrange.hxx>
127 #include <docstat.hxx>
128 #include <wordcountdialog.hxx>
129 #include <sfx2/sidebar/Sidebar.hxx>
130 
133 #include <vcl/settings.hxx>
134 #include <i18nutil/searchopt.hxx>
135 #include <paratr.hxx>
136 #include <rootfrm.hxx>
137 #include <frameformats.hxx>
138 
139 #include <viewimp.hxx>
140 #include <pagefrm.hxx>
141 
142 #include <memory>
143 #include <string_view>
144 #include <svl/slstitm.hxx>
145 
147 
148 const char sStatusDelim[] = " : ";
149 
150 using namespace sfx2;
151 using namespace ::com::sun::star;
152 using namespace ::com::sun::star::i18n;
153 using namespace ::com::sun::star::util;
154 using namespace ::com::sun::star::uno;
155 using namespace ::com::sun::star::lang;
156 using namespace ::com::sun::star::scanner;
157 using namespace ::com::sun::star::beans;
158 using namespace ::com::sun::star::container;
159 using namespace ::com::sun::star::sdb;
160 using namespace ::com::sun::star::ui::dialogs;
161 
162 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
163 {
164  if (!(nWhichId == RES_CHRATR_LANGUAGE ||
165  nWhichId == RES_CHRATR_CJK_LANGUAGE ||
166  nWhichId == RES_CHRATR_CTL_LANGUAGE))
167  return;
168 
169  rWrtSh.StartAction();
170  rWrtSh.LockView( true );
171  rWrtSh.Push();
172 
173  // prepare to apply new language to all text in document
174  rWrtSh.SelAll();
175  rWrtSh.ExtendedSelectAll();
176 
177  // set language attribute to default for all text
178  rWrtSh.ResetAttr({ nWhichId });
179 
181  rWrtSh.LockView( false );
182  rWrtSh.EndAction();
183 
184 }
185 
195 OUString SwView::GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
196 {
197  // Show user-defined page number in brackets if any.
198  OUString extra;
199  if (!rPgStr.isEmpty() && std::u16string_view(OUString::number(nPhyNum)) != rPgStr)
200  extra = rPgStr;
201  else if (nPhyNum != nVirtNum)
202  extra = OUString::number(nVirtNum);
203 
204  sal_uInt16 nPageCount = GetWrtShell().GetPageCnt();
205  sal_uInt16 nPrintedPhyNum = nPhyNum;
206  sal_uInt16 nPrintedPageCount = nPageCount;
207  if (!GetWrtShell().getIDocumentDeviceAccess().getPrintData().IsPrintEmptyPages())
208  SwDoc::CalculateNonBlankPages(*m_pWrtShell->GetLayout(), nPrintedPageCount, nPrintedPhyNum);
209  // Show printed page numbers only, when they are different
210  OUString aStr( nPageCount != nPrintedPageCount
211  ? SwResId(STR_PAGE_COUNT_PRINTED)
212  : (extra.isEmpty() ? SwResId(STR_PAGE_COUNT) : SwResId(STR_PAGE_COUNT_CUSTOM)));
213  aStr = aStr.replaceFirst("%1", OUString::number(nPhyNum));
214  aStr = aStr.replaceFirst("%2", OUString::number(nPageCount));
215  if (nPageCount != nPrintedPageCount)
216  {
217  aStr = aStr.replaceFirst("%3", OUString::number(nPrintedPhyNum));
218  aStr = aStr.replaceFirst("%4", OUString::number(nPrintedPageCount));
219  }
220  else
221  aStr = aStr.replaceFirst("%3", extra);
222 
223  return aStr;
224 }
225 
226 ErrCode SwView::InsertGraphic( const OUString &rPath, const OUString &rFilter,
227  bool bLink, GraphicFilter *pFilter )
228 {
229  SwWait aWait( *GetDocShell(), true );
230 
231  Graphic aGraphic;
232  ErrCode aResult = ERRCODE_NONE;
233  if( !pFilter )
234  {
235  pFilter = &GraphicFilter::GetGraphicFilter();
236  }
237  aResult = GraphicFilter::LoadGraphic( rPath, rFilter, aGraphic, pFilter );
238 
239  if( ERRCODE_NONE == aResult )
240  {
241  GraphicNativeMetadata aMetadata;
242  if ( aMetadata.read(aGraphic) )
243  {
244  const Degree10 aRotation = aMetadata.getRotation();
245  if (aRotation)
246  {
247  GraphicNativeTransform aTransform( aGraphic );
248  aTransform.rotate( aRotation );
249  }
250  }
251 
252  SwFlyFrameAttrMgr aFrameManager( true, GetWrtShellPtr(), Frmmgr_Type::GRF, nullptr );
253  SwWrtShell& rShell = GetWrtShell();
254 
255  // #i123922# determine if we really want to insert or replace the graphic at a selected object
256  const bool bReplaceMode(rShell.HasSelection() && SelectionType::Frame == rShell.GetSelectionType());
257 
258  if(bReplaceMode)
259  {
260  // #i123922# Do same as in D&D, ReRead graphic and all is done
261  rShell.ReRead(
262  bLink ? rPath : OUString(),
263  bLink ? rFilter : OUString(),
264  &aGraphic);
265  }
266  else
267  {
268  rShell.StartAction();
269  if( bLink )
270  {
271  SwDocShell* pDocSh = GetDocShell();
272  INetURLObject aTemp(
273  pDocSh->HasName() ?
275  OUString());
276 
277  OUString sURL = URIHelper::SmartRel2Abs(
278  aTemp, rPath, URIHelper::GetMaybeFileHdl() );
279  aGraphic.setOriginURL(sURL);
280  rShell.Insert( sURL, rFilter, aGraphic, &aFrameManager );
281  }
282  else
283  {
284  rShell.Insert( OUString(), OUString(), aGraphic, &aFrameManager );
285  }
286 
287  // it is too late after "EndAction" because the Shell can already be destroyed.
288  rShell.EndAction();
289  }
290  }
291  return aResult;
292 }
293 
295 {
296  bool bReturn = false;
297  SwDocShell* pDocShell = GetDocShell();
298  SwDoc* pDoc = pDocShell->GetDoc();
299 
300  OUString sGraphicFormat = SwResId(STR_POOLFRM_GRAPHIC);
301 
302 // No file pickers in a non-desktop (mobile app) build.
303 
304 #if HAVE_FEATURE_DESKTOP
305  // when in HTML mode insert only as a link
306  const sal_uInt16 nHtmlMode = ::GetHtmlMode(pDocShell);
307  std::unique_ptr<FileDialogHelper> pFileDlg(new FileDialogHelper(
308  ui::dialogs::TemplateDescription::FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE,
309  FileDialogFlags::Graphic, GetFrameWeld()));
310  pFileDlg->SetTitle(SwResId(STR_INSERT_GRAPHIC ));
311  pFileDlg->SetContext( FileDialogHelper::SW_INSERT_GRAPHIC );
312 
313  uno::Reference < XFilePicker3 > xFP = pFileDlg->GetFilePicker();
314  uno::Reference < XFilePickerControlAccess > xCtrlAcc(xFP, UNO_QUERY);
315  if(nHtmlMode & HTMLMODE_ON)
316  {
317  xCtrlAcc->setValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, makeAny(true));
318  xCtrlAcc->enableControl( ExtendedFilePickerElementIds::CHECKBOX_LINK, false);
319  }
320 
321  std::vector<OUString> aFormats;
322  const size_t nArrLen = pDoc->GetFrameFormats()->size();
323  for( size_t i = 0; i < nArrLen; ++i )
324  {
325  const SwFrameFormat* pFormat = (*pDoc->GetFrameFormats())[ i ];
326  if(pFormat->IsDefault() || pFormat->IsAuto())
327  continue;
328  aFormats.push_back(pFormat->GetName());
329  }
330 
331  // pool formats
332 
333  const std::vector<OUString>& rFramePoolArr(
335  for(const auto & i : rFramePoolArr)
336  {
337  aFormats.push_back(i);
338  }
339 
340  std::sort(aFormats.begin(), aFormats.end());
341  aFormats.erase(std::unique(aFormats.begin(), aFormats.end()), aFormats.end());
342 
343  Sequence<OUString> aListBoxEntries(aFormats.size());
344  OUString* pEntries = aListBoxEntries.getArray();
345  sal_Int16 nSelect = 0;
346  for( size_t i = 0; i < aFormats.size(); ++i )
347  {
348  pEntries[i] = aFormats[i];
349  if(pEntries[i] == sGraphicFormat)
350  nSelect = i;
351  }
352  try
353  {
354  Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get());
355 
356  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
357  ListboxControlActions::ADD_ITEMS , aTemplates );
358 
359  Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get());
360  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
361  ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
362  }
363  catch (const Exception&)
364  {
365  OSL_FAIL("control access failed");
366  }
367 #endif
368 
369  const SfxStringItem* pName = rReq.GetArg<SfxStringItem>(SID_INSERT_GRAPHIC);
370  bool bShowError = !pName;
371  if( pName
372 #if HAVE_FEATURE_DESKTOP
373  || ERRCODE_NONE == pFileDlg->Execute()
374 #endif
375  )
376  {
377 
378  OUString aFileName, aFilterName;
379  if ( pName )
380  {
381  aFileName = pName->GetValue();
382  const SfxStringItem* pFilter = rReq.GetArg<SfxStringItem>(FN_PARAM_FILTER);
383  if ( pFilter )
384  aFilterName = pFilter->GetValue();
385  }
386 #if HAVE_FEATURE_DESKTOP
387  else
388  {
389  aFileName = pFileDlg->GetPath();
390  aFilterName = pFileDlg->GetCurrentFilter();
391  rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
392  rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
393 
394  bool bAsLink = false;
395  if(nHtmlMode & HTMLMODE_ON)
396  bAsLink = true;
397  else
398  {
399  try
400  {
401  Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
402  OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
403  bAsLink = !aVal.hasValue() || *o3tl::doAccess<bool>(aVal);
404  Any aTemplateValue = xCtrlAcc->getValue(
405  ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
406  ListboxControlActions::GET_SELECTED_ITEM );
407  OUString sTmpl;
408  aTemplateValue >>= sTmpl;
409  rReq.AppendItem( SfxStringItem( FN_PARAM_2, sTmpl) );
410  }
411  catch (const Exception&)
412  {
413  OSL_FAIL("control access failed");
414  }
415  }
416  rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
417  }
418  const SfxBoolItem* pAsLink = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
419  const SfxStringItem* pStyle = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
420 #endif
421 
422  bool bAsLink = false;
423 
424 #if HAVE_FEATURE_DESKTOP
425  if( nHtmlMode & HTMLMODE_ON )
426  bAsLink = true;
427  else
428  {
429  if ( rReq.GetArgs() )
430  {
431  if ( pAsLink )
432  bAsLink = pAsLink->GetValue();
433  if ( pStyle && !pStyle->GetValue().isEmpty() )
434  sGraphicFormat = pStyle->GetValue();
435  }
436  else
437  {
438  Any aVal = xCtrlAcc->getValue( ExtendedFilePickerElementIds::CHECKBOX_LINK, 0);
439  OSL_ENSURE(aVal.hasValue(), "Value CBX_INSERT_AS_LINK not found");
440  bAsLink = !aVal.hasValue() || *o3tl::doAccess<bool>(aVal);
441  Any aTemplateValue = xCtrlAcc->getValue(
442  ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE,
443  ListboxControlActions::GET_SELECTED_ITEM );
444  OUString sTmpl;
445  aTemplateValue >>= sTmpl;
446  if( !sTmpl.isEmpty() )
447  sGraphicFormat = sTmpl;
448  rReq.AppendItem( SfxStringItem( FN_PARAM_2, sGraphicFormat ) );
449  rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
450  }
451 
452  // really store as link only?
454  {
455  SvxLinkWarningDialog aWarnDlg(GetFrameWeld(), pFileDlg->GetPath());
456  if (aWarnDlg.run() != RET_OK)
457  bAsLink=false; // don't store as link
458  }
459  }
460 #endif
461 
462  SwWrtShell& rSh = GetWrtShell();
463  rSh.LockPaint();
464  rSh.StartAction();
465 
466  SwRewriter aRewriter;
467  aRewriter.AddRule(UndoArg1, SwResId(STR_GRAPHIC_DEFNAME));
468 
469  // #i123922# determine if we really want to insert or replace the graphic at a selected object
470  const bool bReplaceMode(rSh.HasSelection() && SelectionType::Frame == rSh.GetSelectionType());
471 
472  rSh.StartUndo(SwUndoId::INSERT, &aRewriter);
473 
474  ErrCode nError = InsertGraphic( aFileName, aFilterName, bAsLink, &GraphicFilter::GetGraphicFilter() );
475 
476  // format not equal to current filter (with autodetection)
477  if( nError == ERRCODE_GRFILTER_FORMATERROR )
478  nError = InsertGraphic( aFileName, OUString(), bAsLink, &GraphicFilter::GetGraphicFilter() );
479 
480  // #i123922# no new FrameFormat for replace mode, only when new object was created,
481  // else this would reset the current setting for the frame holding the graphic
482  if ( !bReplaceMode && rSh.IsFrameSelected() )
483  {
484  SwFrameFormat* pFormat = pDoc->FindFrameFormatByName( sGraphicFormat );
485  if(!pFormat)
486  pFormat = pDoc->MakeFrameFormat(sGraphicFormat,
487  pDocShell->GetDoc()->GetDfltFrameFormat(),
488  true, false);
489  rSh.SetFrameFormat( pFormat );
490  }
491 
492  const char* pResId(nullptr);
493  if( nError == ERRCODE_GRFILTER_OPENERROR )
494  pResId = STR_GRFILTER_OPENERROR;
495  else if( nError == ERRCODE_GRFILTER_IOERROR )
496  pResId = STR_GRFILTER_IOERROR;
497  else if( nError ==ERRCODE_GRFILTER_FORMATERROR )
498  pResId = STR_GRFILTER_FORMATERROR;
499  else if( nError ==ERRCODE_GRFILTER_VERSIONERROR )
500  pResId = STR_GRFILTER_VERSIONERROR;
501  else if( nError ==ERRCODE_GRFILTER_FILTERERROR )
502  pResId = STR_GRFILTER_FILTERERROR;
503  else if( nError ==ERRCODE_GRFILTER_TOOBIG )
504  pResId = STR_GRFILTER_TOOBIG;
505 
506  rSh.EndAction();
507  rSh.UnlockPaint();
508  if (pResId)
509  {
510  if( bShowError )
511  {
512  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
513  VclMessageType::Info, VclButtonsType::Ok,
514  SwResId(pResId)));
515  xInfoBox->run();
516  }
517  rReq.Ignore();
518  }
519  else
520  {
521  // set the specific graphic attributes to the graphic
522  bReturn = true;
523  AutoCaption( GRAPHIC_CAP );
524  rReq.Done();
525  }
526 
527  rSh.EndUndo(); // due to possible change of Shell
528  }
529 
530  return bReturn;
531 }
532 
534 {
535  const sal_uInt16 nSlot = rReq.GetSlot();
536  const SfxItemSet* pArgs = rReq.GetArgs();
537  const SfxPoolItem* pItem;
538  bool bIgnore = false;
539  switch( nSlot )
540  {
541  case SID_INSPECTOR_DECK:
542  {
543  OUString deckId;
544  if (nSlot == SID_INSPECTOR_DECK)
545  deckId = "InspectorDeck";
546  ::sfx2::sidebar::Sidebar::ToggleDeck(deckId, GetViewFrame());
547  }
548  break;
549  case SID_CREATE_SW_DRAWVIEW:
550  m_pWrtShell->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
551  break;
552 
554  {
558  aContext.maEndDialogFn = [](sal_Int32){};
559  pDlg->StartExecuteAsync(aContext);
560  break;
561  }
562  case FN_EDIT_LINK_DLG:
563  EditLinkDlg();
564  break;
565  case SID_REFRESH_VIEW:
566  GetEditWin().Invalidate();
567  m_pWrtShell->Reformat();
568  break;
569  case FN_PAGEUP:
570  case FN_PAGEUP_SEL:
571  case FN_PAGEDOWN:
572  case FN_PAGEDOWN_SEL:
573  {
574  tools::Rectangle aVis( GetVisArea() );
575  SwEditWin& rTmpWin = GetEditWin();
576  if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
577  PageUpCursor(FN_PAGEUP_SEL == nSlot);
578  else
579  PageDownCursor(FN_PAGEDOWN_SEL == nSlot);
580 
581  rReq.SetReturnValue(SfxBoolItem(nSlot,
582  aVis != GetVisArea()));
583  //#i42732# - notify the edit window that from now on we do not use the input language
584  rTmpWin.SetUseInputLanguage( false );
585  }
586  break;
587  case SID_ZOOM_IN:
588  case SID_ZOOM_OUT:
589  {
590  tools::Long nFact = m_pWrtShell->GetViewOptions()->GetZoom();
591  if (SID_ZOOM_OUT == nSlot)
592  nFact = basegfx::zoomtools::zoomIn(nFact);
593  else
594  nFact = basegfx::zoomtools::zoomOut(nFact);
595  SetZoom(SvxZoomType::PERCENT, nFact);
596  }
597  break;
598  case FN_TO_PREV_PAGE:
599  case FN_TO_NEXT_PAGE:
600  {
601  sal_uInt16 nPage = 0;
602  if (m_pWrtShell->IsCursorVisible())
603  nPage = m_pWrtShell->GetCursor()->GetPageNum();
604  else
605  {
606  SwFrame* pPageFrame = m_pWrtShell->Imp()->GetFirstVisPage(m_pWrtShell->GetOut());
607  if (pPageFrame)
608  nPage = pPageFrame->GetPhyPageNum();
609  }
610  if (nPage != 0)
611  {
612  sal_uInt16 nOldPage(nPage);
613  if (FN_TO_PREV_PAGE == nSlot && nPage > 1)
614  nPage--;
615  else if (FN_TO_NEXT_PAGE == nSlot && nPage < m_pWrtShell->GetPageCount())
616  nPage++;
617  if (nPage != nOldPage)
618  {
619  m_pWrtShell->LockPaint();
620  if (IsDrawMode())
621  LeaveDrawCreate();
622  m_pWrtShell->EnterStdMode();
623  m_pWrtShell->GotoPage(nPage, true);
624  // set visible area (borrowed from SwView::PhyPageUp/Down)
625  const Point aPt(m_aVisArea.Left(), m_pWrtShell->GetPagePos(nPage).Y());
626  Point aAlPt(AlignToPixel(aPt));
627  if(aPt.Y() != aAlPt.Y())
628  aAlPt.AdjustY(3 * GetEditWin().PixelToLogic(Size(0, 1)).Height());
629  SetVisArea(aAlPt);
630  m_pWrtShell->UnlockPaint();
631  }
632  }
633  }
634  break;
635  case FN_REDLINE_ON:
636  {
637  if( pArgs &&
638  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
639  {
640  IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
641  Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
642  if( aPasswd.hasElements() )
643  {
644  OSL_ENSURE( !static_cast<const SfxBoolItem*>(pItem)->GetValue(), "SwView::Execute(): password set and redlining off doesn't match!" );
645 
646  // dummy password from OOXML import: only confirmation dialog
647  if (aPasswd.getLength() == 1 && aPasswd[0] == 1)
648  {
649  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_pWrtShell->GetView().GetFrameWeld(),
650  VclMessageType::Warning, VclButtonsType::YesNo,
651  SfxResId(RID_SVXSTR_END_REDLINING_WARNING)));
652  xWarn->set_default_response(RET_NO);
653  if (xWarn->run() == RET_YES)
654  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
655  else
656  break;
657  }
658  else
659  {
660  // xmlsec05: new password dialog
661  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
662  aPasswdDlg.SetMinLen(1);
663  //#i69751# the result of Execute() can be ignored
664  (void)aPasswdDlg.run();
665  OUString sNewPasswd(aPasswdDlg.GetPassword());
666  Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword();
667  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
668  if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
669  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
670  else
671  { // xmlsec05: message box for wrong password
672  break;
673  }
674  }
675  }
676 
677  SwDocShell* pDocShell = GetDocShell();
678  pDocShell->SetChangeRecording( static_cast<const SfxBoolItem*>(pItem)->GetValue(), /*bLockAllViews=*/true );
679 
680  // Notify all view shells of this document, as the track changes mode is document-global.
681  for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(pDocShell); pViewFrame; pViewFrame = SfxViewFrame::GetNext(*pViewFrame, pDocShell))
682  {
683  pViewFrame->GetBindings().Invalidate(FN_REDLINE_ON);
684  pViewFrame->GetBindings().Update(FN_REDLINE_ON);
685  }
686  }
687  }
688  break;
689  case FN_REDLINE_PROTECT :
690  {
691  IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
692  Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
693  if( pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )
694  && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswd.hasElements() )
695  break;
696 
697  // xmlsec05: new password dialog
698  // message box for wrong password
699  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
700  aPasswdDlg.SetMinLen(1);
701  if (!aPasswd.hasElements())
702  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
703  if (aPasswdDlg.run())
704  {
706  OUString sNewPasswd(aPasswdDlg.GetPassword());
707  Sequence <sal_Int8> aNewPasswd =
708  rIDRA.GetRedlinePassword();
709  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
710  if(!aPasswd.hasElements())
711  {
712  rIDRA.SetRedlinePassword(aNewPasswd);
713  }
714  else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
715  {
716  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
717  nOn = RedlineFlags::NONE;
718  }
719  const RedlineFlags nMode = rIDRA.GetRedlineFlags();
720  m_pWrtShell->SetRedlineFlagsAndCheckInsMode( (nMode & ~RedlineFlags::On) | nOn);
721  rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, !(nMode&RedlineFlags::On) ) );
722  }
723  else
724  bIgnore = true;
725  }
726  break;
727  case FN_REDLINE_SHOW:
728 
729  if( pArgs &&
730  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
731  {
732  // tdf#125754 avoid recursive layout
733  // because all views share the layout, have to use AllAction
734  const bool bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
735  m_pWrtShell->StartAllAction();
736  // always show redline insertions in Hide Changes mode
737  if ( m_pWrtShell->GetViewOptions()->IsShowChangesInMargin() &&
738  m_pWrtShell->GetViewOptions()->IsShowChangesInMargin2() )
739  {
740  GetDocShell()->GetDoc()->GetDocumentRedlineManager().HideAll(/*bDeletion=*/!bShow);
741  }
742  m_pWrtShell->GetLayout()->SetHideRedlines( !bShow );
743  m_pWrtShell->EndAllAction();
744  if (m_pWrtShell->IsRedlineOn())
745  m_pWrtShell->SetInsMode();
746  }
747  break;
749  case FN_REDLINE_ACCEPT:
750  GetViewFrame()->ToggleChildWindow(nSlot);
751  break;
756  {
757  SwDoc *pDoc = m_pWrtShell->GetDoc();
758  SwPaM *pCursor = m_pWrtShell->GetCursor();
759  const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
761  if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
762  {
763  const sal_Int64 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
764  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
765  {
766  if (nChangeId == rRedlineTable[i]->GetId())
767  nRedline = i;
768  }
769  }
770 
771  if( pCursor->HasMark() && nRedline == SwRedlineTable::npos)
772  {
773  if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
774  m_pWrtShell->AcceptRedlinesInSelection();
775  else
776  m_pWrtShell->RejectRedlinesInSelection();
777  }
778  else
779  {
780  // We check for a redline at the start of the selection/cursor, not the point.
781  // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the
782  // point at the *end* of the redline and the mark at the start (so GetRedline
783  // would return NULL if called on the point)
784  const SwRangeRedline* pRedline = nullptr;
785  if (nRedline != SwRedlineTable::npos)
786  {
787  // A redline was explicitly requested by specifying an
788  // index, don't guess based on the cursor position.
789 
790  if (nRedline < rRedlineTable.size())
791  pRedline = rRedlineTable[nRedline];
792  }
793  else
794  pRedline = pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline);
795 
796  assert(pRedline != nullptr);
797  if (pRedline)
798  {
799  if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
800  m_pWrtShell->AcceptRedline(nRedline);
801  else
802  m_pWrtShell->RejectRedline(nRedline);
803  }
804  }
805  if (FN_REDLINE_ACCEPT_TONEXT == nSlot || FN_REDLINE_REJECT_TONEXT == nSlot)
806  {
807  // Go to next change after accepting or rejecting one (tdf#101977)
808  GetViewFrame()->GetDispatcher()->Execute(FN_REDLINE_NEXT_CHANGE, SfxCallMode::ASYNCHRON);
809  }
810  }
811  break;
812 
814  {
815  // If a parameter is provided, try going to the nth change, not to
816  // the next one.
817  SwDoc* pDoc = m_pWrtShell->GetDoc();
818  const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
820  if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
821  {
822  const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
823  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
824  {
825  if (nChangeId == rRedlineTable[i]->GetId())
826  nRedline = i;
827  }
828  }
829 
830  const SwRangeRedline *pNext = nullptr;
831  if (nRedline < rRedlineTable.size())
832  pNext = m_pWrtShell->GotoRedline(nRedline, true);
833  else
834  pNext = m_pWrtShell->SelNextRedline();
835 
836  if (pNext)
837  {
839  {
840  OString aPayload(".uno:CurrentTrackedChangeId=");
841  sal_uInt32 nRedlineId = pNext->GetId();
842  aPayload += OString::number(nRedlineId);
843  libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload.getStr());
844  }
845 
846  m_pWrtShell->SetInSelect();
847  }
848 
849  }
850  break;
851 
853  {
854  const SwRangeRedline *pPrev = m_pWrtShell->SelPrevRedline();
855 
856  if (pPrev)
857  {
859  {
860  OString aPayload(".uno:CurrentTrackedChangeId=");
861  sal_uInt32 nRedlineId = pPrev->GetId();
862  aPayload += OString::number(nRedlineId);
863  libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload.getStr());
864  }
865 
866  m_pWrtShell->SetInSelect();
867  }
868  }
869  break;
870 
871  case SID_DOCUMENT_COMPARE:
872  case SID_DOCUMENT_MERGE:
873  {
874  OUString sFileName, sFilterName;
875  sal_Int16 nVersion = 0;
876  bool bHasFileName = false;
877  m_pViewImpl->SetParam( 0 );
878  bool bNoAcceptDialog = false;
879 
880  if( pArgs )
881  {
882  if( SfxItemState::SET == pArgs->GetItemState( SID_FILE_NAME, false, &pItem ))
883  sFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
884  bHasFileName = !sFileName.isEmpty();
885 
886  if( SfxItemState::SET == pArgs->GetItemState( SID_FILTER_NAME, false, &pItem ))
887  sFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
888 
889  if( SfxItemState::SET == pArgs->GetItemState( SID_VERSION, false, &pItem ))
890  {
891  nVersion = static_cast<const SfxInt16Item *>(pItem)->GetValue();
892  m_pViewImpl->SetParam( nVersion );
893  }
894  if( SfxItemState::SET == pArgs->GetItemState( SID_NO_ACCEPT_DIALOG, false, &pItem ))
895  {
896  bNoAcceptDialog = static_cast<const SfxBoolItem *>(pItem)->GetValue();
897  }
898  }
899 
900  m_pViewImpl->InitRequest( rReq );
901  tools::Long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
902 
903  if ( bHasFileName )
904  {
905  rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
906 
907  if (nFound > 0 && !bNoAcceptDialog) // show Redline browser
908  {
909  SfxViewFrame* pVFrame = GetViewFrame();
911 
912  // re-initialize the Redline dialog
913  const sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
914  SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(
915  pVFrame->GetChildWindow(nId));
916  if (pRed)
917  pRed->ReInitDlg(GetDocShell());
918  }
919  }
920  else
921  bIgnore = true;
922  }
923  break;
924  case FN_SYNC_LABELS:
925  GetViewFrame()->ShowChildWindow(nSlot);
926  break;
927  case FN_ESCAPE:
928  {
929  if ( m_pWrtShell->HasDrawViewDrag() )
930  {
931  m_pWrtShell->BreakDrag();
932  m_pWrtShell->EnterSelFrameMode();
933  }
934  else if ( m_pWrtShell->IsDrawCreate() )
935  {
936  GetDrawFuncPtr()->BreakCreate();
937  AttrChangedNotify(nullptr); // shell change if needed
938  }
939  else if ( m_pWrtShell->HasSelection() || IsDrawMode() )
940  {
941  SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : nullptr;
942  if(pSdrView && pSdrView->AreObjectsMarked() &&
943  pSdrView->GetHdlList().GetFocusHdl())
944  {
945  const_cast<SdrHdlList&>(pSdrView->GetHdlList()).ResetFocusHdl();
946  }
947  else
948  {
949  if(pSdrView)
950  {
951  LeaveDrawCreate();
952  Point aPt(LONG_MIN, LONG_MIN);
953  //go out of the frame
954  m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
955  SfxBindings& rBind = GetViewFrame()->GetBindings();
956  rBind.Invalidate( SID_ATTR_SIZE );
957  }
958  m_pWrtShell->EnterStdMode();
959  AttrChangedNotify(nullptr); // shell change if necessary
960  }
961  }
962  else if ( GetEditWin().GetApplyTemplate() )
963  {
964  GetEditWin().SetApplyTemplate(SwApplyTemplate());
965  }
966  else if( static_cast<SfxObjectShell*>(GetDocShell())->IsInPlaceActive() )
967  {
968  Escape();
969  }
970  else if ( GetEditWin().IsChainMode() )
971  {
972  GetEditWin().SetChainMode( false );
973  }
974  else if( m_pWrtShell->GetFlyFrameFormat() )
975  {
976  const SwFrameFormat* pFormat = m_pWrtShell->GetFlyFrameFormat();
977  if(m_pWrtShell->GotoFly( pFormat->GetName(), FLYCNTTYPE_FRM ))
978  {
979  m_pWrtShell->HideCursor();
980  m_pWrtShell->EnterSelFrameMode();
981  }
982  }
983  else
984  {
985  SfxBoolItem aItem( SID_WIN_FULLSCREEN, false );
986  GetViewFrame()->GetDispatcher()->ExecuteList(SID_WIN_FULLSCREEN,
987  SfxCallMode::RECORD, { &aItem });
988  bIgnore = true;
989  }
990  }
991  break;
992  case SID_ATTR_BORDER_INNER:
993  case SID_ATTR_BORDER_OUTER:
994  case SID_ATTR_BORDER_SHADOW:
995  if(pArgs)
996  m_pWrtShell->SetAttrSet(*pArgs);
997  break;
998 
999  case SID_ATTR_PAGE:
1000  case SID_ATTR_PAGE_SIZE:
1001  case SID_ATTR_PAGE_MAXSIZE:
1002  case SID_ATTR_PAGE_PAPERBIN:
1003  case SID_ATTR_PAGE_EXT1:
1004  case FN_PARAM_FTN_INFO:
1005  {
1006  if(pArgs)
1007  {
1008  const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
1009  SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) );
1010  ::ItemSetToPageDesc( *pArgs, aPageDesc );
1011  // change the descriptor of the core
1012  m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
1013  }
1014  }
1015  break;
1016  case FN_GOTO_PAGE:
1017  {
1018  SwGotoPageDlg aDlg(GetViewFrame()->GetWindow().GetFrameWeld(), &GetViewFrame()->GetBindings());
1019  if (aDlg.run() == RET_OK)
1020  GetWrtShell().GotoPage(aDlg.GetPageSelection(), true);
1021  }
1022  break;
1023  case FN_EDIT_CURRENT_TOX:
1024  {
1025  GetViewFrame()->GetDispatcher()->Execute(
1026  FN_INSERT_MULTI_TOX, SfxCallMode::ASYNCHRON);
1027  }
1028  break;
1029  case FN_UPDATE_CUR_TOX:
1030  {
1031  const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
1032  if(pBase)
1033  {
1034  // tdf#106374: don't jump view on the update
1035  const bool bWasLocked = m_pWrtShell->IsViewLocked();
1036  m_pWrtShell->LockView(true);
1037  m_pWrtShell->StartAction();
1038  if(TOX_INDEX == pBase->GetType())
1039  m_pWrtShell->ApplyAutoMark();
1040  m_pWrtShell->UpdateTableOf( *pBase );
1041  m_pWrtShell->EndAction();
1042  if (!bWasLocked)
1043  m_pWrtShell->LockView(false);
1044  }
1045  }
1046  break;
1047  case FN_UPDATE_TOX:
1048  {
1049  m_pWrtShell->StartAction();
1050  m_pWrtShell->EnterStdMode();
1051  bool bOldCursorInReadOnly = m_pWrtShell->IsReadOnlyAvailable();
1052  m_pWrtShell->SetReadOnlyAvailable( true );
1053 
1054  for( int i = 0; i < 2; ++i )
1055  {
1056  if( m_pWrtShell->GetTOXCount() == 1 )
1057  ++i;
1058 
1059  while( m_pWrtShell->GotoPrevTOXBase() )
1060  ; // jump to the first "table of ..."
1061 
1062  // if we are not in one, jump to next
1063  const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
1064  if( !pBase )
1065  {
1066  m_pWrtShell->GotoNextTOXBase();
1067  pBase = m_pWrtShell->GetCurTOX();
1068  }
1069 
1070  bool bAutoMarkApplied = false;
1071  while( pBase )
1072  {
1073  if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
1074  {
1075  m_pWrtShell->ApplyAutoMark();
1076  bAutoMarkApplied = true;
1077  }
1078  // pBase is needed only for the interface. Should be changed in future! (JP 1996)
1079  m_pWrtShell->UpdateTableOf( *pBase );
1080 
1081  if( m_pWrtShell->GotoNextTOXBase() )
1082  pBase = m_pWrtShell->GetCurTOX();
1083  else
1084  pBase = nullptr;
1085  }
1086  }
1087  m_pWrtShell->SetReadOnlyAvailable( bOldCursorInReadOnly );
1088  m_pWrtShell->EndAction();
1089  }
1090  break;
1091  case SID_ATTR_BRUSH:
1092  {
1093  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_BACKGROUND, false, &pItem))
1094  {
1095  const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
1096  SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx ));
1097  SwFrameFormat& rMaster = aDesc.GetMaster();
1098  rMaster.SetFormatAttr(*pItem);
1099  m_pWrtShell->ChgPageDesc( nCurIdx, aDesc);
1100  }
1101  }
1102  break;
1103  case SID_CLEARHISTORY:
1104  {
1105  m_pWrtShell->DelAllUndoObj();
1106  }
1107  break;
1108  case SID_UNDO:
1109  {
1110  m_pShell->ExecuteSlot(rReq);
1111  }
1112  break;
1113 #if defined(_WIN32) || defined UNX
1114  case SID_TWAIN_SELECT:
1115  case SID_TWAIN_TRANSFER:
1116  GetViewImpl()->ExecuteScan( rReq );
1117  break;
1118 #endif
1119 
1120  case SID_ATTR_DEFTABSTOP:
1121  {
1122  if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
1123  {
1124  SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
1125  const sal_uInt16 nTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1126  MakeDefTabs( nTab, aDefTabs );
1127  m_pWrtShell->SetDefault( aDefTabs );
1128  }
1129  }
1130  break;
1131  case SID_ATTR_LANGUAGE :
1132  if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, false, &pItem))
1133  {
1134  SvxLanguageItem aLang(static_cast<const SvxLanguageItem*>(pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
1135  m_pWrtShell->SetDefault( aLang );
1137  }
1138  break;
1139  case SID_ATTR_CHAR_CTL_LANGUAGE:
1140  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, false, &pItem))
1141  {
1142  m_pWrtShell->SetDefault( *pItem );
1144  }
1145  break;
1146  case SID_ATTR_CHAR_CJK_LANGUAGE:
1147  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, false, &pItem))
1148  {
1149  m_pWrtShell->SetDefault( *pItem );
1151  }
1152  break;
1154  {
1155  m_pWrtShell->EnterStdMode();
1156  size_t nPos(m_pWrtShell->GetOutlinePos());
1157  m_pWrtShell->ToggleOutlineContentVisibility(nPos);
1158  m_pWrtShell->GotoOutline(nPos);
1159  }
1160  break;
1161  case FN_NAV_ELEMENT:
1162  {
1163  // nothing here on purpose - if removed only the listbox that changed is changed
1164  }
1165  break;
1166  case FN_SCROLL_PREV:
1167  case FN_SCROLL_NEXT:
1168  {
1169  bool *pbNext = new bool(true);
1170  if (nSlot == FN_SCROLL_PREV)
1171  *pbNext = false;
1172  MoveNavigationHdl(pbNext);
1173  }
1174  break;
1175  case SID_JUMPTOMARK:
1176  if( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_JUMPTOMARK, false, &pItem))
1177  JumpToSwMark( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1178  break;
1179  case SID_GALLERY :
1180  // First make sure that the sidebar is visible
1181  GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
1182 
1184  u"GalleryPanel",
1185  GetViewFrame()->GetFrame().GetFrameInterface());
1186  break;
1187  case SID_AVMEDIA_PLAYER :
1188  GetViewFrame()->ChildWindowExecute(rReq);
1189  break;
1190  case SID_VIEW_DATA_SOURCE_BROWSER:
1191  {
1192  SfxViewFrame* pVFrame = GetViewFrame();
1193  pVFrame->ChildWindowExecute(rReq);
1194  if(pVFrame->HasChildWindow(SID_BROWSER))
1195  {
1196  const SwDBData& rData = GetWrtShell().GetDBDesc();
1197  SwModule::ShowDBObj(*this, rData);
1198  }
1199  }
1200  break;
1202  {
1203  bool bShow = false;
1204  if( pArgs &&
1205  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
1206  bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1207  if((bShow && m_bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
1208  GetViewFrame()->ToggleChildWindow(nSlot);
1209  //if fields have been successfully inserted call the "real"
1210  //mail merge dialog
1211 #if HAVE_FEATURE_DBCONNECTIVITY
1212  SwWrtShell &rSh = GetWrtShell();
1213  if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
1214  {
1215  SwDBManager* pDBManager = rSh.GetDBManager();
1216  if (pDBManager)
1217  {
1218  SwDBData aData = rSh.GetDBData();
1219  rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
1220  AttrChangedNotify(nullptr);
1221 
1222  Sequence<PropertyValue> aProperties(3);
1223  PropertyValue* pValues = aProperties.getArray();
1224  pValues[0].Name = "DataSourceName";
1225  pValues[1].Name = "Command";
1226  pValues[2].Name = "CommandType";
1227  pValues[0].Value <<= aData.sDataSource;
1228  pValues[1].Value <<= aData.sCommand;
1229  pValues[2].Value <<= aData.nCommandType;
1230  pDBManager->ExecuteFormLetter(rSh, aProperties);
1231  }
1232  }
1233 #endif
1234  m_bInMailMerge &= bShow;
1235  GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
1236  }
1237  break;
1238  case FN_QRY_MERGE:
1239  {
1240  bool bUseCurrentDocument = true;
1241  bool bQuery = !pArgs || SfxItemState::SET != pArgs->GetItemState(nSlot);
1242  if(bQuery)
1243  {
1244  SfxViewFrame* pTmpFrame = GetViewFrame();
1247  if (RET_OK == pDlg->Execute())
1248  bUseCurrentDocument = pDlg->IsThisDocument();
1249  else
1250  break;
1251  }
1252  GenerateFormLetter(bUseCurrentDocument);
1253  }
1254  break;
1255  case SID_RECHECK_DOCUMENT:
1256  {
1257  SwDocShell* pDocShell = GetDocShell();
1258  SwDoc* pDoc = pDocShell->GetDoc();
1259  uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
1260  if( xGCIterator.is() )
1261  {
1262  xGCIterator->resetIgnoreRules();
1263  }
1264  // reset ignore lists
1265  pDoc->SpellItAgainSam( true, false, false );
1266  // clear ignore dictionary
1267  uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
1268  if( xDictionary.is() )
1269  xDictionary->clear();
1270  // put cursor to the start of the document
1271  m_pWrtShell->StartOfSection();
1272  [[fallthrough]]; // call spell/grammar dialog
1273  }
1275  {
1276  SfxViewFrame* pViewFrame = GetViewFrame();
1277  if (rReq.GetArgs() != nullptr)
1279  static_cast<const SfxBoolItem&>( (rReq.GetArgs()->
1280  Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
1281  else
1283 
1285  rReq.Ignore ();
1286  }
1287  break;
1288  case SID_ALIGN_ANY_LEFT :
1289  case SID_ALIGN_ANY_HCENTER :
1290  case SID_ALIGN_ANY_RIGHT :
1291  case SID_ALIGN_ANY_JUSTIFIED:
1292  case SID_ALIGN_ANY_TOP :
1293  case SID_ALIGN_ANY_VCENTER :
1294  case SID_ALIGN_ANY_BOTTOM :
1295  case SID_ALIGN_ANY_HDEFAULT :
1296  case SID_ALIGN_ANY_VDEFAULT :
1297  {
1298  sal_uInt16 nAlias = 0;
1299  if( m_nSelectionType & (SelectionType::DrawObjectEditMode|SelectionType::Text) )
1300  {
1301  switch( nSlot )
1302  {
1303  case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
1304  case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
1305  case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
1306  case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
1307  case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break;
1308  case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break;
1309  case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break;
1310  }
1311  }
1312  else
1313  {
1314  switch( nSlot )
1315  {
1316  case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
1317  case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
1318  case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
1319  case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
1320  case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
1321  case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
1322  }
1323  }
1324  //these slots are either re-mapped to text or object alignment
1325  if (nAlias)
1326  GetViewFrame()->GetDispatcher()->Execute(
1327  nAlias, SfxCallMode::ASYNCHRON);
1328  }
1329  break;
1330  case SID_RESTORE_EDITING_VIEW:
1331  {
1332  //#i33307# restore editing position
1333  Point aCursorPos;
1334  bool bSelectObj;
1335  if(m_pViewImpl->GetRestorePosition(aCursorPos, bSelectObj))
1336  {
1337  m_pWrtShell->SwCursorShell::SetCursor( aCursorPos, !bSelectObj );
1338  if( bSelectObj )
1339  {
1340  m_pWrtShell->SelectObj( aCursorPos );
1341  m_pWrtShell->EnterSelFrameMode( &aCursorPos );
1342  }
1343  }
1344  }
1345  break;
1346  case SID_INSERT_GRAPHIC:
1347  {
1348  rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
1349  }
1350  break;
1351 
1352  default:
1353  OSL_ENSURE(false, "wrong dispatcher");
1354  return;
1355  }
1356  if(!bIgnore)
1357  rReq.Done();
1358 }
1359 
1361 {
1362  sal_uInt16 nId = rReq.GetSlot();
1363  bool bRet = false;
1364 
1366  {
1368  bRet = true;
1369  }
1370  return bRet || SfxShell::IsConditionalFastCall(rReq);
1371 
1372 }
1373 
1376 {
1377  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1378  rBnd.Invalidate(FN_STAT_PAGE);
1379 }
1380 
1382 {
1383  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1384  rBnd.Invalidate( FN_STAT_WORDCOUNT );
1385  rBnd.Update( FN_STAT_WORDCOUNT );
1386 }
1387 
1390 {
1391  SwWrtShell& rShell = GetWrtShell();
1392 
1393  SfxWhichIter aIter( rSet );
1394  sal_uInt16 nWhich = aIter.FirstWhich();
1395  OSL_ENSURE( nWhich, "empty set");
1396 
1397  //get section change event
1398  const SwSection* CurrSect = rShell.GetCurrSection();
1399  if( CurrSect )
1400  {
1401  const OUString& sCurrentSectionName = CurrSect->GetSectionName();
1402  if(sCurrentSectionName != m_sOldSectionName)
1403  {
1405  }
1406  m_sOldSectionName = sCurrentSectionName;
1407  }
1408  else if (!m_sOldSectionName.isEmpty())
1409  {
1411  m_sOldSectionName= OUString();
1412  }
1413  //get column change event
1414  if(rShell.bColumnChange())
1415  {
1417  }
1418 
1419  while( nWhich )
1420  {
1421  switch( nWhich )
1422  {
1423  case FN_STAT_PAGE: {
1424  // number of pages, log. page number
1425  sal_uInt16 nPage, nLogPage;
1426  OUString sDisplay;
1427  rShell.GetPageNumber( -1, rShell.IsCursorVisible(), nPage, nLogPage, sDisplay );
1428  std::vector<OUString> aStringList;
1429  aStringList.push_back(GetPageStr(nPage, nLogPage, sDisplay));
1430  bool bExtendedTooltip(!sDisplay.isEmpty() &&
1431  std::u16string_view(OUString::number(nPage)) != sDisplay &&
1432  nPage != nLogPage);
1433  OUString aTooltip = bExtendedTooltip ? SwResId(STR_BOOKCTRL_HINT_EXTENDED)
1434  : SwResId(STR_BOOKCTRL_HINT);
1435  aStringList.push_back(aTooltip);
1436  rSet.Put(SfxStringListItem(FN_STAT_PAGE, &aStringList));
1437  //if existing page number is not equal to old page number, send out this event.
1438  if (m_nOldPageNum != nLogPage )
1439  {
1440  if (m_nOldPageNum != 0)
1441  SwCursorShell::FirePageChangeEvent(m_nOldPageNum, nLogPage);
1442  m_nOldPageNum = nLogPage;
1443  }
1444  const sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
1445  if (m_nPageCnt != nCnt) // notify Basic
1446  {
1447  m_nPageCnt = nCnt;
1448  SfxGetpApp()->NotifyEvent(SfxEventHint(SfxEventHintId::SwEventPageCount, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), false);
1449  }
1450  }
1451  break;
1452 
1453  case FN_STAT_WORDCOUNT:
1454  {
1455  SwDocStat selectionStats;
1456  SwDocStat documentStats;
1457  rShell.CountWords(selectionStats);
1458  documentStats = rShell.GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ );
1459 
1460  sal_uLong nWord = selectionStats.nWord ? selectionStats.nWord : documentStats.nWord;
1461  sal_uLong nChar = selectionStats.nChar ? selectionStats.nChar : documentStats.nChar;
1462  const char* pResId = selectionStats.nWord ? STR_WORDCOUNT : STR_WORDCOUNT_NO_SELECTION;
1463  const char* pWordResId = selectionStats.nWord ? STR_WORDCOUNT_WORDARG : STR_WORDCOUNT_WORDARG_NO_SELECTION;
1464  const char* pCharResId = selectionStats.nWord ? STR_WORDCOUNT_CHARARG : STR_WORDCOUNT_CHARARG_NO_SELECTION;
1465 
1467  OUString aWordArg = SwResId(pWordResId, nWord).replaceAll("$1", rLocaleData.getNum(nWord, 0));
1468  OUString aCharArg = SwResId(pCharResId, nChar).replaceAll("$1", rLocaleData.getNum(nChar, 0));
1469  OUString aWordCount(SwResId(pResId));
1470  aWordCount = aWordCount.replaceAll("$1", aWordArg);
1471  aWordCount = aWordCount.replaceAll("$2", aCharArg);
1472 
1473  rSet.Put( SfxStringItem( FN_STAT_WORDCOUNT, aWordCount ) );
1474 
1475  SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
1476  if (pWrdCnt)
1477  pWrdCnt->SetCounts(selectionStats, documentStats);
1478  }
1479  break;
1480 
1481  case FN_STAT_TEMPLATE:
1482  {
1484  rShell.GetCurPageStyle()));
1485 
1486  }
1487  break;
1488  case SID_ATTR_ZOOM:
1489  {
1490  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1491  {
1492  const SwViewOption* pVOpt = rShell.GetViewOptions();
1493  SvxZoomType eZoom = pVOpt->GetZoomType();
1494  SvxZoomItem aZoom(eZoom,
1495  pVOpt->GetZoom());
1496  if( pVOpt->getBrowseMode() )
1497  {
1498  aZoom.SetValueSet(
1499  SvxZoomEnableFlags::N50|
1500  SvxZoomEnableFlags::N75|
1501  SvxZoomEnableFlags::N100|
1502  SvxZoomEnableFlags::N150|
1503  SvxZoomEnableFlags::N200);
1504  }
1505  rSet.Put( aZoom );
1506  }
1507  else
1508  rSet.DisableItem( SID_ATTR_ZOOM );
1509  }
1510  break;
1511  case SID_ATTR_VIEWLAYOUT:
1512  {
1513  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1514  {
1515  const SwViewOption* pVOpt = rShell.GetViewOptions();
1516  const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1517  const bool bBookMode = pVOpt->IsViewLayoutBookMode();
1518  SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1519  rSet.Put( aViewLayout );
1520  }
1521  else
1522  rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1523  }
1524  break;
1525  case SID_ATTR_ZOOMSLIDER:
1526  {
1527  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1528  {
1529  const SwViewOption* pVOpt = rShell.GetViewOptions();
1530  const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1531  SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1532  aZoomSliderItem.AddSnappingPoint( 100 );
1533 
1534  if ( !m_pWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) )
1535  {
1536  const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1537  const bool bAutomaticViewLayout = 0 == nColumns;
1538  const SwPostItMgr* pMgr = GetPostItMgr();
1539 
1540  // snapping points:
1541  // automatic mode: 1 Page, 2 Pages, 100%
1542  // n Columns mode: n Pages, 100%
1543  // n Columns book mode: nPages without gaps, 100%
1544  const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( CurRectType::PageCalc ) );
1545  const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( CurRectType::PagesArea ) ); // width of columns
1546  Size aPageSize( aPageRect.SSize() );
1547  aPageSize.AdjustWidth(pMgr->HasNotes() && pMgr->ShowNotes() ?
1548  pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
1549  0 );
1550 
1551  Size aRootSize( aRootRect.SSize() );
1552 
1553  const MapMode aTmpMap( MapUnit::MapTwip );
1554  const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1555  const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1556 
1557  const tools::Long nOf = pVOpt->GetDocumentBorder() * 2;
1558  tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
1559  nTmpWidth += nOf;
1560  aPageSize.AdjustHeight(nOf );
1561  tools::Long nFac = aWindowSize.Width() * 100 / nTmpWidth;
1562 
1563  tools::Long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1564  nFac = std::min( nFac, nVisPercent );
1565 
1566  if (nFac >= MINZOOM)
1567  {
1568  aZoomSliderItem.AddSnappingPoint( nFac );
1569  }
1570 
1571  if ( bAutomaticViewLayout )
1572  {
1573  nTmpWidth += aPageSize.Width() + pVOpt->GetGapBetweenPages();
1574  nFac = aWindowSize.Width() * 100 / nTmpWidth;
1575  nFac = std::min( nFac, nVisPercent );
1576  if (nFac >= MINZOOM)
1577  {
1578  aZoomSliderItem.AddSnappingPoint( nFac );
1579  }
1580  }
1581  }
1582 
1583  rSet.Put( aZoomSliderItem );
1584  }
1585  else
1586  rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1587  }
1588  break;
1589  case SID_ATTR_POSITION:
1590  case SID_ATTR_SIZE:
1591  {
1592  if( !rShell.IsFrameSelected() && !rShell.IsObjSelected() )
1594  else
1595  {
1596  FlyMode eFrameMode = SwBaseShell::GetFrameMode();
1597  if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1598  {
1599  if ( nWhich == SID_ATTR_POSITION )
1600  rSet.Put( SfxPointItem( SID_ATTR_POSITION,
1601  rShell.GetAnchorObjDiff()));
1602  else
1603  rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
1604  rShell.GetObjSize()));
1605  }
1606  }
1607  }
1608  break;
1609  case SID_TABLE_CELL:
1610 
1611  if( rShell.IsFrameSelected() || rShell.IsObjSelected() )
1612  {
1613  // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1614  // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1615  // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1616  // in SID_ATTR_SIZE).
1617  }
1618  else
1619  {
1620  OUString sStr;
1621  if( rShell.IsCursorInTable() )
1622  {
1623  // table name + cell coordinate
1624  sStr = rShell.GetTableFormat()->GetName() + ":";
1625  sStr += rShell.GetBoxNms();
1626  }
1627  else
1628  {
1629  const SwSection* pCurrSect = rShell.GetCurrSection();
1630  if( pCurrSect )
1631  {
1632  switch( pCurrSect->GetType() )
1633  {
1636  {
1637  const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
1638  if( pTOX )
1639  sStr = pTOX->GetTOXName();
1640  else
1641  {
1642  OSL_ENSURE( false,
1643  "Unknown kind of section" );
1644  sStr = pCurrSect->GetSectionName();
1645  }
1646  }
1647  break;
1648  default:
1649  sStr = pCurrSect->GetSectionName();
1650  break;
1651  }
1652  }
1653  }
1654 
1655  const SwNumRule* pNumRule = rShell.GetNumRuleAtCurrCursorPos();
1656  const bool bOutlineNum = pNumRule && pNumRule->IsOutlineRule();
1657 
1658  if (pNumRule && !bOutlineNum ) // cursor in numbering
1659  {
1660  sal_uInt8 nNumLevel = rShell.GetNumLevel();
1661  if ( nNumLevel < MAXLEVEL )
1662  {
1663  if(!pNumRule->IsAutoRule())
1664  {
1665  SfxItemSet aSet(GetPool(),
1667  rShell.GetCurAttr(aSet);
1668  if(SfxItemState::DEFAULT <=
1669  aSet.GetItemState(RES_PARATR_NUMRULE))
1670  {
1671  const OUString& rNumStyle =
1672  aSet.Get(RES_PARATR_NUMRULE).GetValue();
1673  if(!rNumStyle.isEmpty())
1674  {
1675  if(!sStr.isEmpty())
1676  sStr += sStatusDelim;
1677  sStr += rNumStyle;
1678  }
1679  }
1680  }
1681  if (!sStr.isEmpty())
1682  sStr += sStatusDelim;
1683  sStr += SwResId(STR_NUM_LEVEL) + OUString::number( nNumLevel + 1 );
1684 
1685  }
1686  }
1687  const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1688  if( nOutlineLevel != 0 )
1689  {
1690  if (!sStr.isEmpty())
1691  sStr += " , ";
1692  if( bOutlineNum )
1693  {
1694  sStr += SwResId(STR_OUTLINE_NUMBERING) +
1695  sStatusDelim + SwResId(STR_NUM_LEVEL);
1696  }
1697  else
1698  sStr += SwResId(STR_NUM_OUTLINE);
1699  sStr += OUString::number( nOutlineLevel);
1700  }
1701 
1702  if( rShell.HasReadonlySel() )
1703  {
1704  if (!sStr.isEmpty())
1705  sStr = sStatusDelim + sStr;
1706  sStr = SwResId(SW_STR_READONLY) + sStr;
1707  }
1708  if (!sStr.isEmpty())
1709  rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1710  }
1711  break;
1712  case FN_STAT_SELMODE:
1713  {
1714  if(rShell.IsStdMode())
1715  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1716  else if(rShell.IsAddMode())
1717  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
1718  else if(rShell.IsBlockMode())
1719  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
1720  else
1721  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
1722  break;
1723  }
1724  case SID_ATTR_INSERT:
1725  if( rShell.IsRedlineOn() )
1726  rSet.DisableItem( nWhich );
1727  else
1728  {
1729  rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1730  }
1731  break;
1732  }
1733  nWhich = aIter.NextWhich();
1734  }
1735 }
1736 
1742 {
1743  SwWrtShell &rSh = GetWrtShell();
1744  const SfxItemSet* pArgs = rReq.GetArgs();
1745  const SfxPoolItem* pItem=nullptr;
1746  bool bUp = false;
1747  sal_uInt16 nWhich = rReq.GetSlot();
1748  switch( nWhich )
1749  {
1750  case FN_STAT_PAGE:
1751  {
1752  GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_PAGE,
1753  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1754  }
1755  break;
1756 
1757  case FN_STAT_WORDCOUNT:
1758  {
1759  GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
1760  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1761  }
1762  break;
1763 
1764  case FN_STAT_BOOKMARK:
1765  if ( pArgs )
1766  {
1767  if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
1768  {
1769  const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1770  const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1771  if(nIdx < pMarkAccess->getBookmarksCount())
1772  {
1774  rSh.EnterStdMode();
1775  rSh.GotoMark( *ppBookmark );
1776  }
1777  else
1778  OSL_FAIL("SwView::ExecuteStatusLine(..)"
1779  " - Ignoring out of range bookmark index");
1780  }
1781  }
1782  break;
1783 
1784  case FN_STAT_TEMPLATE:
1785  {
1786  GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1787  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1788  }
1789  break;
1790  case SID_ATTR_ZOOM:
1791  {
1792  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1793  {
1794  const SfxItemSet *pSet = nullptr;
1796  if ( pArgs )
1797  pSet = pArgs;
1798  else
1799  {
1800  const SwViewOption& rViewOptions = *rSh.GetViewOptions();
1802  SvxZoomItem aZoom( rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
1803 
1804  const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
1805  if( bBrowseMode )
1806  {
1807  aZoom.SetValueSet(
1808  SvxZoomEnableFlags::N50|
1809  SvxZoomEnableFlags::N75|
1810  SvxZoomEnableFlags::N100|
1811  SvxZoomEnableFlags::N150|
1812  SvxZoomEnableFlags::N200);
1813  }
1814  aCoreSet.Put( aZoom );
1815 
1816  if ( !bBrowseMode )
1817  {
1818  const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1819  aCoreSet.Put( aViewLayout );
1820  }
1821 
1823  pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetViewFrame()->GetWindow().GetFrameWeld(), aCoreSet));
1824  pDlg->SetLimits( MINZOOM, MAXZOOM );
1825  if( pDlg->Execute() != RET_CANCEL )
1826  pSet = pDlg->GetOutputItemSet();
1827  }
1828 
1829  const SfxPoolItem* pViewLayoutItem = nullptr;
1830  if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pViewLayoutItem))
1831  {
1832  const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->GetValue();
1833  const bool bBookMode = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->IsBookMode();
1834  SetViewLayout( nColumns, bBookMode );
1835  }
1836 
1837  if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_ZOOM, true, &pItem))
1838  {
1839  SvxZoomType eType = static_cast<const SvxZoomItem *>(pItem)->GetType();
1840  SetZoom( eType, static_cast<const SvxZoomItem *>(pItem)->GetValue() );
1841  }
1842  bUp = true;
1843  if ( pItem )
1844  rReq.AppendItem( *pItem );
1845  rReq.Done();
1846  }
1847  }
1848  break;
1849 
1850  case SID_ATTR_VIEWLAYOUT:
1851  {
1853  ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1854  {
1855  if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pItem ))
1856  {
1857  const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pItem)->GetValue();
1858  const bool bBookMode = (0 != nColumns && 0 == (nColumns % 2)) &&
1859  static_cast<const SvxViewLayoutItem *>(pItem)->IsBookMode();
1860 
1861  SetViewLayout( nColumns, bBookMode );
1862  }
1863 
1864  bUp = true;
1865  rReq.Done();
1866 
1867  InvalidateRulerPos();
1868  }
1869  }
1870  break;
1871 
1872  case SID_ATTR_ZOOMSLIDER:
1873  {
1874  if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1875  {
1876  if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ))
1877  {
1878  const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
1879  SetZoom( SvxZoomType::PERCENT, nCurrentZoom );
1880  }
1881 
1882  bUp = true;
1883  rReq.Done();
1884  }
1885  }
1886  break;
1887 
1888  case SID_ATTR_SIZE:
1889  {
1890  sal_uInt16 nId = 0;
1891  if( rSh.IsCursorInTable() )
1892  nId = FN_FORMAT_TABLE_DLG;
1893  else if( rSh.GetCurTOX() )
1894  nId = FN_INSERT_MULTI_TOX;
1895  else if( rSh.GetCurrSection() )
1896  nId = FN_EDIT_REGION;
1897  else
1898  {
1899  const SwNumRule* pNumRule = rSh.GetNumRuleAtCurrCursorPos();
1900  if( pNumRule ) // cursor in numbering
1901  {
1902  if( pNumRule->IsAutoRule() )
1903  nId = FN_NUMBER_BULLETS;
1904  else
1905  {
1906  // start dialog of the painter
1907  nId = 0;
1908  }
1909  }
1910  else if( rSh.IsFrameSelected() )
1911  nId = FN_FORMAT_FRAME_DLG;
1912  else if( rSh.IsObjSelected() )
1913  nId = SID_ATTR_TRANSFORM;
1914  }
1915  if( nId )
1916  GetViewFrame()->GetDispatcher()->Execute(nId,
1917  SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
1918  }
1919  break;
1920 
1921  case FN_STAT_SELMODE:
1922  {
1923  if ( pArgs )
1924  {
1925  if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
1926  {
1927  switch ( static_cast<const SfxUInt16Item *>(pItem)->GetValue() )
1928  {
1929  case 0: rSh.EnterStdMode(); break;
1930  case 1: rSh.EnterExtMode(); break;
1931  case 2: rSh.EnterAddMode(); break;
1932  case 3: rSh.EnterBlockMode(); break;
1933  }
1934  }
1935  }
1936  else
1937  {
1938 
1939  if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1940  rSh.ToggleExtMode();
1941  else if ( rSh.IsExtMode() )
1942  {
1943  rSh.ToggleExtMode();
1944  rSh.ToggleAddMode();
1945  }
1946  else if ( rSh.IsAddMode() )
1947  {
1948  rSh.ToggleAddMode();
1949  rSh.ToggleBlockMode();
1950  }
1951  else
1952  rSh.ToggleBlockMode();
1953  }
1954  bUp = true;
1955  break;
1956  }
1957  case FN_SET_ADD_MODE:
1958  rSh.ToggleAddMode();
1959  nWhich = FN_STAT_SELMODE;
1960  bUp = true;
1961  break;
1962  case FN_SET_BLOCK_MODE:
1963  rSh.ToggleBlockMode();
1964  nWhich = FN_STAT_SELMODE;
1965  bUp = true;
1966  break;
1967  case FN_SET_EXT_MODE:
1968  rSh.ToggleExtMode();
1969  nWhich = FN_STAT_SELMODE;
1970  bUp = true;
1971  break;
1972  case SID_ATTR_INSERT:
1973  SwPostItMgr* pMgr = GetPostItMgr();
1974  if ( pMgr && pMgr->HasActiveSidebarWin() )
1975  {
1977  }
1978  else
1979  rSh.ToggleInsMode();
1980  bUp = true;
1981  break;
1982 
1983  }
1984  if ( bUp )
1985  {
1986  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1987  rBnd.Invalidate(nWhich);
1988  rBnd.Update(nWhich);
1989  }
1990 }
1991 
1992 void SwView::InsFrameMode(sal_uInt16 nCols)
1993 {
1994  if ( m_pWrtShell->HasWholeTabSelection() )
1995  {
1996  SwFlyFrameAttrMgr aMgr( true, m_pWrtShell.get(), Frmmgr_Type::TEXT, nullptr );
1997 
1998  const SwFrameFormat &rPageFormat =
1999  m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster();
2000  SwTwips lWidth = rPageFormat.GetFrameSize().GetWidth();
2001  const SvxLRSpaceItem &rLR = rPageFormat.GetLRSpace();
2002  lWidth -= rLR.GetLeft() + rLR.GetRight();
2003  aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
2004  if(nCols > 1)
2005  {
2006  SwFormatCol aCol;
2007  aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
2008  aMgr.SetCol( aCol );
2009  }
2010  aMgr.InsertFlyFrame();
2011  }
2012  else
2013  GetEditWin().InsFrame(nCols);
2014 }
2015 
2018 {
2019  bool bWeb = dynamic_cast<SwWebView*>( this ) != nullptr;
2021  ScopedVclPtr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog(GetViewFrame()->GetWindow().GetFrameWeld(), &GetWrtShell().GetLinkManager(), bWeb));
2022  pDlg->Execute();
2023 }
2024 
2025 bool SwView::JumpToSwMark( const OUString& rMark )
2026 {
2027  bool bRet = false;
2028  if( !rMark.isEmpty() )
2029  {
2030  // place bookmark at top-center
2031  bool bSaveCC = m_bCenterCursor;
2032  bool bSaveCT = m_bTopCursor;
2033  SetCursorAtTop( true );
2034 
2035  // For scrolling the FrameSet, the corresponding shell needs to have the focus.
2036  bool bHasShFocus = m_pWrtShell->HasShellFocus();
2037  if( !bHasShFocus )
2038  m_pWrtShell->ShellGetFocus();
2039 
2040  const SwFormatINetFormat* pINet;
2041  OUString sCmp;
2042  OUString sMark( INetURLObject::decode( rMark,
2044 
2045  sal_Int32 nLastPos, nPos = sMark.indexOf( cMarkSeparator );
2046  if( -1 != nPos )
2047  while( -1 != ( nLastPos = sMark.indexOf( cMarkSeparator, nPos + 1 )) )
2048  nPos = nLastPos;
2049 
2051  IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess();
2052  if( -1 != nPos )
2053  sCmp = sMark.copy(nPos + 1).replaceAll(" ", "");
2054 
2055  if( !sCmp.isEmpty() )
2056  {
2057  OUString sName( sMark.copy( 0, nPos ) );
2058  sCmp = sCmp.toAsciiLowerCase();
2059  FlyCntType eFlyType = FLYCNTTYPE_ALL;
2060 
2061  if (sCmp == "drawingobject")
2062  bRet = m_pWrtShell->GotoDrawingObject(sName);
2063  else if( sCmp == "region" )
2064  {
2065  m_pWrtShell->EnterStdMode();
2066  bRet = m_pWrtShell->GotoRegion( sName );
2067  }
2068  else if( sCmp == "outline" )
2069  {
2070  m_pWrtShell->EnterStdMode();
2071  bRet = m_pWrtShell->GotoOutline( sName );
2072  }
2073  else if( sCmp == "frame" )
2074  eFlyType = FLYCNTTYPE_FRM;
2075  else if( sCmp == "graphic" )
2076  eFlyType = FLYCNTTYPE_GRF;
2077  else if( sCmp == "ole" )
2078  eFlyType = FLYCNTTYPE_OLE;
2079  else if( sCmp == "table" )
2080  {
2081  m_pWrtShell->EnterStdMode();
2082  bRet = m_pWrtShell->GotoTable( sName );
2083  }
2084  else if( sCmp == "sequence" )
2085  {
2086  m_pWrtShell->EnterStdMode();
2087  sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator );
2088  if ( nNoPos != -1 )
2089  {
2090  sal_uInt16 nSeqNo = sName.copy( nNoPos + 1 ).toInt32();
2091  sName = sName.copy( 0, nNoPos );
2092  bRet = m_pWrtShell->GotoRefMark(sName, REF_SEQUENCEFLD, nSeqNo);
2093  }
2094  }
2095  else if( sCmp == "text" )
2096  {
2097  // normal text search
2098  m_pWrtShell->EnterStdMode();
2099 
2100  i18nutil::SearchOptions2 aSearchOpt(
2101  SearchAlgorithms_ABSOLUTE, 0,
2102  sName, OUString(),
2103  SvtSysLocale().GetLanguageTag().getLocale(),
2104  0,0,0,
2105  TransliterationFlags::IGNORE_CASE,
2106  SearchAlgorithms2::ABSOLUTE,
2107  '\\' );
2108 
2109  //todo/mba: assuming that notes shouldn't be searched
2110  if( m_pWrtShell->SearchPattern( aSearchOpt, false/*bSearchInNotes*/, SwDocPositions::Start, SwDocPositions::End ))
2111  {
2112  m_pWrtShell->EnterStdMode(); // remove the selection
2113  bRet = true;
2114  }
2115  }
2116  else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
2117  {
2118  bRet = m_pWrtShell->GotoMark( *ppMark, false );
2119  }
2120  else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
2121  m_pWrtShell->addCurrentPosition();
2122  bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
2123  }
2124 
2125  // for all types of Flys
2126  if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( sName, eFlyType ))
2127  {
2128  bRet = true;
2129  if( FLYCNTTYPE_FRM == eFlyType )
2130  {
2131  // TextFrames: set Cursor in the frame
2132  m_pWrtShell->UnSelectFrame();
2133  m_pWrtShell->LeaveSelFrameMode();
2134  }
2135  else
2136  {
2137  m_pWrtShell->HideCursor();
2138  m_pWrtShell->EnterSelFrameMode();
2139  }
2140  }
2141  }
2142  else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
2143  {
2144  bRet = m_pWrtShell->GotoMark( *ppMark, false );
2145  }
2146  else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
2147  bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
2148 
2149  // make selection visible later
2150  if ( m_aVisArea.IsEmpty() )
2151  m_bMakeSelectionVisible = true;
2152 
2153  // reset ViewStatus
2154  SetCursorAtTop( bSaveCT, bSaveCC );
2155 
2156  if(!m_pWrtShell->IsFrameSelected() && !m_pWrtShell->IsObjSelected())
2157  m_pWrtShell->ShowCursor();
2158 
2159  if( !bHasShFocus )
2160  m_pWrtShell->ShellLoseFocus();
2161  }
2162  return bRet;
2163 }
2164 
2165 // #i67305# Undo after insert from file:
2166 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
2167 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
2168 // page styles with active header/footer => disabled for those documents
2169 static size_t lcl_PageDescWithHeader( const SwDoc& rDoc )
2170 {
2171  size_t nRet = 0;
2172  size_t nCnt = rDoc.GetPageDescCnt();
2173  for( size_t i = 0; i < nCnt; ++i )
2174  {
2175  const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
2176  const SwFrameFormat& rMaster = rPageDesc.GetMaster();
2177  const SfxPoolItem* pItem;
2178  if( ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, false, &pItem ) &&
2179  static_cast<const SwFormatHeader*>(pItem)->IsActive() ) ||
2180  ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, false, &pItem ) &&
2181  static_cast<const SwFormatFooter*>(pItem)->IsActive()) )
2182  ++nRet;
2183  }
2184  return nRet; // number of page styles with active header/footer
2185 }
2186 
2187 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2188 {
2189  m_pViewImpl->InitRequest( rRequest );
2190  m_pViewImpl->SetParam( pItem ? 1 : 0 );
2191  const sal_uInt16 nSlot = rRequest.GetSlot();
2192 
2193  if ( !pItem )
2194  {
2195  InsertDoc( nSlot, "", "" );
2196  }
2197  else
2198  {
2199  OUString sFile, sFilter;
2200  sFile = static_cast<const SfxStringItem *>( pItem )->GetValue();
2201  if ( SfxItemState::SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, true, &pItem ) )
2202  sFilter = static_cast<const SfxStringItem *>(pItem )->GetValue();
2203 
2204  bool bHasFileName = !sFile.isEmpty();
2205  tools::Long nFound = InsertDoc( nSlot, sFile, sFilter );
2206 
2207  if ( bHasFileName )
2208  {
2209  rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2210  rRequest.Done();
2211  }
2212  }
2213 }
2214 
2215 tools::Long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion )
2216 {
2217  std::unique_ptr<SfxMedium> pMed;
2218  SwDocShell* pDocSh = GetDocShell();
2219 
2220  if( !rFileName.isEmpty() )
2221  {
2222  SfxObjectFactory& rFact = pDocSh->GetFactory();
2223  std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2224  if ( !pFilter )
2225  {
2226  pMed.reset(new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr ));
2227  SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2228  pMed->UseInteractionHandler( true );
2229  ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE);
2230  if ( nErr )
2231  pMed.reset();
2232  else
2233  pMed->SetFilter( pFilter );
2234  }
2235  else
2236  pMed.reset(new SfxMedium(rFileName, StreamMode::READ, pFilter, nullptr));
2237  }
2238  else
2239  {
2240  m_pViewImpl->StartDocumentInserter(
2241  // tdf#118578 allow inserting any Writer document except GlobalDoc
2242  SwDocShell::Factory().GetFactoryName(),
2243  LINK( this, SwView, DialogClosedHdl ),
2244  nSlotId
2245  );
2246  return -1;
2247  }
2248 
2249  if( !pMed )
2250  return -1;
2251 
2252  return InsertMedium( nSlotId, std::move(pMed), nVersion );
2253 }
2254 
2255 tools::Long SwView::InsertMedium( sal_uInt16 nSlotId, std::unique_ptr<SfxMedium> pMedium, sal_Int16 nVersion )
2256 {
2257  bool bInsert = false, bCompare = false;
2258  tools::Long nFound = 0;
2259  SwDocShell* pDocSh = GetDocShell();
2260 
2261  switch( nSlotId )
2262  {
2263  case SID_DOCUMENT_MERGE: break;
2264  case SID_DOCUMENT_COMPARE: bCompare = true; break;
2265  case SID_INSERTDOC: bInsert = true; break;
2266 
2267  default:
2268  OSL_ENSURE( false, "unknown SlotId!" );
2269  bInsert = true;
2270  break;
2271  }
2272 
2273  if( bInsert )
2274  {
2275  uno::Reference< frame::XDispatchRecorder > xRecorder =
2276  GetViewFrame()->GetBindings().GetRecorder();
2277  if ( xRecorder.is() )
2278  {
2279  SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2280  aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2281  if(pMedium->GetFilter())
2282  aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2283  aRequest.Done();
2284  }
2285 
2286  SfxObjectShellRef aRef( pDocSh );
2287 
2288  ErrCode nError = SfxObjectShell::HandleFilter( pMedium.get(), pDocSh );
2289  // #i16722# aborted?
2290  if(nError != ERRCODE_NONE)
2291  {
2292  return -1;
2293  }
2294 
2295  pMedium->Download(); // start download if needed
2296  if( aRef.is() && 1 < aRef->GetRefCount() ) // still a valid ref?
2297  {
2298  SwReaderPtr pRdr;
2299  Reader *pRead = pDocSh->StartConvertFrom(*pMedium, pRdr, m_pWrtShell.get());
2300  if( pRead ||
2301  (pMedium->GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER) )
2302  {
2303  size_t nUndoCheck = 0;
2304  SwDoc *pDoc = pDocSh->GetDoc();
2305  if( pRead && pDocSh->GetDoc() )
2306  nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2307  ErrCode nErrno;
2308  { //Scope for SwWait-Object, to be able to execute slots
2309  //outside this scope.
2310  SwWait aWait( *GetDocShell(), true );
2311  m_pWrtShell->StartAllAction();
2312  if ( m_pWrtShell->HasSelection() )
2313  m_pWrtShell->DelRight(); // delete selections
2314  if( pRead )
2315  {
2316  nErrno = pRdr->Read( *pRead ); // and insert document
2317  pRdr.reset();
2318  }
2319  else
2320  {
2321  ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
2322  uno::Reference<text::XTextRange> const xInsertPosition(
2324  *m_pWrtShell->GetCursor()->GetPoint(), nullptr));
2325  nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition)
2327  }
2328 
2329  }
2330 
2331  // update all "table of ..." sections if needed
2332  if( m_pWrtShell->IsUpdateTOX() )
2333  {
2334  SfxRequest aReq( FN_UPDATE_TOX, SfxCallMode::SLOT, GetPool() );
2335  Execute( aReq );
2336  m_pWrtShell->SetUpdateTOX( false ); // reset
2337  }
2338 
2339  if( pDoc )
2340  { // Disable Undo for .sdw or
2341  // if the number of page styles with header/footer has changed
2342  if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2343  {
2345  }
2346  }
2347 
2348  m_pWrtShell->EndAllAction();
2349  if( nErrno )
2350  {
2351  ErrorHandler::HandleError( nErrno );
2352  nFound = nErrno.IsError() ? -1 : 0;
2353  }
2354  else
2355  nFound = 0;
2356  }
2357  }
2358  }
2359  else
2360  {
2361  SfxObjectShellRef xDocSh;
2362  SfxObjectShellLock xLockRef;
2363 
2364  const int nRet = SwFindDocShell( xDocSh, xLockRef, pMedium->GetName(), OUString(),
2365  OUString(), nVersion, pDocSh );
2366  if( nRet )
2367  {
2368  SwWait aWait( *GetDocShell(), true );
2369  m_pWrtShell->StartAllAction();
2370 
2371  m_pWrtShell->EnterStdMode(); // delete selections
2372 
2373  if( bCompare )
2374  nFound = m_pWrtShell->CompareDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() );
2375  else
2376  nFound = m_pWrtShell->MergeDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() );
2377 
2378  m_pWrtShell->EndAllAction();
2379 
2380  if (!bCompare && !nFound)
2381  {
2382  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(),
2383  VclMessageType::Info, VclButtonsType::Ok,
2384  SwResId(STR_NO_MERGE_ENTRY)));
2385  xInfoBox->run();
2386  }
2387  if( nRet==2 && xDocSh.is() )
2388  xDocSh->DoClose();
2389  }
2390  }
2391 
2392  return nFound;
2393 }
2394 
2396 {
2397  m_bInMailMerge = true;
2398  SfxBindings& rBind = GetViewFrame()->GetBindings();
2401 }
2402 
2403 #if HAVE_FEATURE_DBCONNECTIVITY
2404 
2405 namespace
2406 {
2407  bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext )
2408  {
2409  Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2410 
2411  return ( !aNames.hasElements()
2412  || ( ( 1 == aNames.getLength() )
2413  && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2414  )
2415  );
2416  }
2417 }
2418 
2419 #endif
2420 
2421 void SwView::GenerateFormLetter(bool bUseCurrentDocument)
2422 {
2423 #if !HAVE_FEATURE_DBCONNECTIVITY
2424  (void) bUseCurrentDocument;
2425 #else
2426  if(bUseCurrentDocument)
2427  {
2428  if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2429  {
2430  //check availability of data sources (except biblio source)
2431  uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
2432  uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
2433  bool bCallAddressPilot = false;
2434  if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2435  {
2436  // no data sources are available - create a new one
2437  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/datasourcesunavailabledialog.ui"));
2438  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("DataSourcesUnavailableDialog"));
2439  // no cancel allowed
2440  if (RET_OK != xQuery->run())
2441  return;
2442  bCallAddressPilot = true;
2443  }
2444  else
2445  {
2446  //take an existing data source or create a new one?
2449  if(RET_OK == pConnectionsDlg->Execute())
2450  bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
2451  else
2452  return;
2453 
2454  }
2455  if(bCallAddressPilot)
2456  {
2457  GetViewFrame()->GetDispatcher()->Execute(
2458  SID_ADDRESS_DATA_SOURCE, SfxCallMode::SYNCHRON);
2459  if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2460  // no additional data source has been created
2461  // -> assume that the user has cancelled the pilot
2462  return;
2463  }
2464 
2465  //call insert fields with database field page available, only
2466  SfxViewFrame* pVFrame = GetViewFrame();
2467  //at first hide the default field dialog if currently visible
2468  pVFrame->SetChildWindow(FN_INSERT_FIELD, false);
2469  //enable the status of the db field dialog - it is disabled in the status method
2470  //to prevent creation of the dialog without mail merge active
2471  EnableMailMerge();
2472  //then show the "Data base only" field dialog
2475  SfxCallMode::SYNCHRON, { &aOn });
2476  return;
2477  }
2478  else
2479  {
2480  OUString sSource;
2481  if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2482  {
2483  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/warndatasourcedialog.ui"));
2484  std::unique_ptr<weld::MessageDialog> xWarning(xBuilder->weld_message_dialog("WarnDataSourceDialog"));
2485  OUString sTmp(xWarning->get_primary_text());
2486  xWarning->set_primary_text(sTmp.replaceFirst("%1", sSource));
2487  if (RET_OK == xWarning->run())
2488  {
2490  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( nullptr, SID_OPTIONS_DATABASES ));
2491  pDlg->Execute();
2492  }
2493  return ;
2494  }
2495  }
2496  SwDBManager* pDBManager = GetWrtShell().GetDBManager();
2497 
2498  SwDBData aData;
2499  SwWrtShell &rSh = GetWrtShell();
2500 
2501  std::vector<OUString> aDBNameList;
2502  std::vector<OUString> aAllDBNames;
2503  rSh.GetAllUsedDB( aDBNameList, &aAllDBNames );
2504  if(!aDBNameList.empty())
2505  {
2506  OUString sDBName(aDBNameList[0]);
2507  sal_Int32 nIdx {0};
2508  aData.sDataSource = sDBName.getToken(0, DB_DELIM, nIdx);
2509  aData.sCommand = sDBName.getToken(0, DB_DELIM, nIdx);
2510  aData.nCommandType = sDBName.getToken(0, DB_DELIM, nIdx).toInt32();
2511  }
2512  rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
2513  AttrChangedNotify(nullptr);
2514 
2515  if (pDBManager)
2516  {
2517  Sequence<PropertyValue> aProperties(3);
2518  PropertyValue* pValues = aProperties.getArray();
2519  pValues[0].Name = "DataSourceName";
2520  pValues[1].Name = "Command";
2521  pValues[2].Name = "CommandType";
2522  pValues[0].Value <<= aData.sDataSource;
2523  pValues[1].Value <<= aData.sCommand;
2524  pValues[2].Value <<= aData.nCommandType;
2525  pDBManager->ExecuteFormLetter(GetWrtShell(), aProperties);
2526  }
2527  }
2528  else
2529  {
2530  // call documents and template dialog
2531  SfxApplication* pSfxApp = SfxGetpApp();
2532  vcl::Window* pTopWin = pSfxApp->GetTopWindow();
2533 
2534  SfxTemplateManagerDlg aDocTemplDlg(GetFrameWeld());
2535  int nRet = aDocTemplDlg.run();
2536  bool bNewWin = false;
2537  if ( nRet == RET_OK )
2538  {
2539  if ( pTopWin != pSfxApp->GetTopWindow() )
2540  {
2541  // the dialogue opens a document -> a new TopWindow appears
2542  pTopWin = pSfxApp->GetTopWindow();
2543  bNewWin = true;
2544  }
2545  }
2546 
2547  if ( bNewWin )
2548  // after the destruction of the dialogue its parent comes to top,
2549  // but we want that the new document is on top
2550  pTopWin->ToTop();
2551  }
2552 #endif
2553 }
2554 
2555 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
2556 {
2557  if ( ERRCODE_NONE != _pFileDlg->GetError() )
2558  return;
2559 
2560  std::unique_ptr<SfxMedium> pMed = m_pViewImpl->CreateMedium();
2561  if ( !pMed )
2562  {
2563  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(),
2564  VclMessageType::Info, VclButtonsType::Ok,
2565  SwResId(RID_SVXSTR_TXTFILTER_FILTERERROR)));
2566  xInfoBox->run();
2567  return;
2568  }
2569 
2570  const sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot();
2571  tools::Long nFound = InsertMedium( nSlot, std::move(pMed), m_pViewImpl->GetParam() );
2572 
2573  if ( SID_INSERTDOC == nSlot )
2574  {
2575  if ( m_pViewImpl->GetParam() == 0 )
2576  {
2577  m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2578  m_pViewImpl->GetRequest()->Ignore();
2579  }
2580  else
2581  {
2582  m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2583  m_pViewImpl->GetRequest()->Done();
2584  }
2585  }
2586  else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2587  {
2588  m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2589 
2590  if ( nFound > 0 ) // show Redline browser
2591  {
2592  SfxViewFrame* pVFrame = GetViewFrame();
2594 
2595  // re-initialize Redline dialog
2596  sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
2597  SwRedlineAcceptChild* pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->GetChildWindow( nId ));
2598  if ( pRed )
2599  pRed->ReInitDlg( GetDocShell() );
2600  }
2601  }
2602 }
2603 
2605 {
2606  if (m_pViewImpl)
2607  m_pViewImpl->ExecuteScan(rReq) ;
2608 }
2609 
2610 const OUString& SwView::GetOldGrfCat()
2611 {
2612  return GetCachedString(OldGrfCat);
2613 }
2614 
2615 void SwView::SetOldGrfCat(const OUString& sStr)
2616 {
2617  SetCachedString(OldGrfCat, sStr);
2618 }
2619 
2620 const OUString& SwView::GetOldTabCat()
2621 {
2622  return GetCachedString(OldTabCat);
2623 }
2624 
2625 void SwView::SetOldTabCat(const OUString& sStr)
2626 {
2627  SetCachedString(OldTabCat, sStr);
2628 }
2629 
2630 const OUString& SwView::GetOldFrameCat()
2631 {
2632  return GetCachedString(OldFrameCat);
2633 }
2634 
2635 void SwView::SetOldFrameCat(const OUString& sStr)
2636 {
2637  SetCachedString(OldFrameCat, sStr);
2638 }
2639 
2640 const OUString& SwView::GetOldDrwCat()
2641 {
2642  return GetCachedString(OldDrwCat);
2643 }
2644 
2645 void SwView::SetOldDrwCat(const OUString& sStr)
2646 {
2647  SwView::SetCachedString(OldDrwCat, sStr);
2648 }
2649 
2650 
2651 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static void ShowPanel(std::u16string_view rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
bool GetValue() const
bool is() const
#define MAXZOOM
Definition: view.hxx:81
static void ShowDBObj(SwView const &rView, const SwDBData &rData)
Definition: swmodul1.cxx:365
bool ToggleBlockMode()
Definition: select.cxx:763
Base class of the Writer layout elements.
Definition: frame.hxx:298
bool JumpToSwMark(const OUString &rMark)
Definition: view2.cxx:2025
void StateStatusLine(SfxItemSet &)
get status of the status line
Definition: view2.cxx:1389
void EnterBlockMode()
Definition: select.cxx:650
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
#define FN_UPDATE_TOX
Definition: cmdid.h:505
#define MINZOOM
Definition: view.hxx:80
IDocumentStatistics const & getIDocumentStatistics() const
Definition: doc.cxx:373
virtual SfxObjectFactory & GetFactory() const =0
const OUString & GetOldGrfCat()
Definition: view2.cxx:2610
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
FlyMode
Definition: mdiexp.hxx:39
OUString const & GetCurPageStyle() const
Definition: wrtsh1.cxx:1560
#define FN_EDIT_REGION
Definition: cmdid.h:108
void ItemSetToPageDesc(const SfxItemSet &rSet, SwPageDesc &rPageDesc)
Definition: uitool.cxx:269
constexpr TypedWhichId< SvxTabStopItem > RES_PARATR_TABSTOP(68)
SfxChildWindow * GetChildWindow(sal_uInt16)
bool IsInsMode() const
Definition: wrtsh.hxx:165
bool JumpToSwMark(SwViewShell const *pVwSh, const OUString &rMark)
Definition: edtwin3.cxx:117
void ToggleInsMode()
Definition: wrtsh.hxx:164
bool IsDefault() const
Definition: format.hxx:130
#define FN_SET_ADD_MODE
Definition: cmdid.h:673
void SetCounts(const SwDocStat &rCurrCnt, const SwDocStat &rDocStat)
static SfxAbstractDialogFactory * Create()
virtual const css::uno::Sequence< sal_Int8 > & GetRedlinePassword() const =0
void ReRead(const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic=nullptr)
Re-read if graphic is not ok. Current graphic is replaced by the new one.
Definition: editsh.cxx:295
virtual void SetChangeRecording(bool bActivate, bool bLockAllViews=false) override
Definition: docsh.cxx:1342
constexpr TypedWhichId< SwFormatHeader > RES_HEADER(96)
std::string GetValue
static const std::vector< OUString > & GetFrameFormatUINameArray()
const SwNumRule * GetNumRuleAtCurrCursorPos() const
Definition: ednumber.cxx:774
#define FN_STAT_BOOKMARK
Definition: cmdid.h:835
SfxDispatcher * GetDispatcher()
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
bool AreObjectsMarked() const
tools::Long InsertDoc(sal_uInt16 nSlotId, const OUString &rFileName, const OUString &rFilterName, sal_Int16 nVersion=0)
Definition: view2.cxx:2215
static SvxAbstractDialogFactory * Create()
sal_uIntPtr sal_uLong
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
long Long
tools::Long GetRight() const
Size GetObjSize() const
Definition: feshview.cxx:2293
OUString sDataSource
Definition: swdbdata.hxx:30
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
static const AllSettings & GetSettings()
void CountWords(SwDocStat &rStat) const
Count words in current selection.
Definition: editsh.cxx:1071
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:395
SwFrameFormat * MakeFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom, bool bBroadcast=false, bool bAuto=true)
Definition: docfmt.cxx:809
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1715
bool IsAutoRule() const
Definition: numrule.hxx:228
sal_uInt16 GetPageSelection() const
Definition: gotodlg.hxx:33
Provides access to the marks of a document.
Definition: doc.hxx:186
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:322
static SVL_DLLPUBLIC void GetHashPassword(css::uno::Sequence< sal_Int8 > &rPassHash, const char *pPass, sal_uInt32 nLen)
sal_uLong nChar
Definition: docstat.hxx:37
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
sal_Int16 nId
void setOriginURL(OUString const &rOriginURL)
sal_uInt16 FirstWhich()
const ContentProperties & rData
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document setting interface.
Definition: viewsh.cxx:2665
void EnterStdMode()
Definition: select.cxx:550
void Done(bool bRemove=false)
void ExtendedSelectAll(bool bFootnotes=true)
Definition: crsrsh.cxx:598
virtual short run() override
IMPL_LINK(SvDDEObject, ImplGetDDEData, const DdeData *, pData, void)
virtual const SwDocStat & GetUpdatedDocStat(bool bCompleteAsync, bool bFields)=0
Updates the document statistics if the document has been modified and returns a reference to the resu...
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
void ExecuteScan(SfxRequest &rReq)
Definition: view2.cxx:2604
const OUString & GetOldFrameCat()
Definition: view2.cxx:2630
#define FN_STAT_PAGE
Definition: cmdid.h:831
void SetCachedString(CachedStringID id, const OUString &sStr)
Definition: view.hxx:663
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
#define ERRCODE_GRFILTER_IOERROR
int SwFindDocShell(SfxObjectShellRef &xDocSh, SfxObjectShellLock &xLockRef, const OUString &rFileName, const OUString &rPasswd, const OUString &rFilter, sal_Int16 nVersion, SwDocShell *pDestSh)
Find the right DocShell and create a new one: The return value specifies what should happen to the Sh...
Definition: docsh2.cxx:1647
virtual short Execute()=0
SwFrameFormat * FindFrameFormatByName(std::u16string_view rName) const
Definition: docfmt.cxx:734
#define FN_TO_PREV_PAGE
Definition: cmdid.h:730
RET_CANCEL
bool IsStdMode() const
Definition: wrtsh.hxx:146
virtual const SfxItemSet * GetOutputItemSet() const =0
sal_uInt8 GetNumLevel() const
Definition: ednumber.cxx:749
void SetUseInputLanguage(bool bNew)
#i42732# display status of font size/name depending on either the input language or the selection pos...
Definition: edtwin.cxx:6445
sal_uInt16 NextWhich()
Degree10 getRotation() const
SfxApplication * SfxGetpApp()
const SwSection * GetCurrSection() const
Definition: edsect.cxx:71
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:547
size_type size() const
Definition: docary.hxx:266
const SwTextINetFormat * GetTextINetFormat() const
Definition: fmtinfmt.hxx:70
bool IsRedlineOn() const
Definition: edredln.cxx:43
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
void ToggleChildWindow(sal_uInt16)
RET_NO
weld::Window * GetFrameWeld() const
#define FN_NUMBER_BULLETS
Definition: cmdid.h:73
void disposeAndReset(reference_type *pBody)
void AddSnappingPoint(sal_Int32 nNew)
vcl::Window & GetWindow() const
virtual VclPtr< AbstractMailMergeFieldConnectionsDlg > CreateMailMergeFieldConnectionsDlg(weld::Window *pParent)=0
virtual VclPtr< AbstractMailMergeCreateFromDlg > CreateMailMergeCreateFromDlg(weld::Window *pParent)=0
#define FN_SYNC_LABELS
Definition: cmdid.h:465
RET_YES
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
sal_uInt16 GetDocumentBorder() const
Definition: viewopt.hxx:457
static void SetFrameMode_(FlyMode eMode)
Definition: basesh.hxx:111
PropertiesInfo aProperties
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool getBrowseMode() const
Definition: viewopt.hxx:473
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
#define FN_EDIT_LINK_DLG
Definition: cmdid.h:71
const OUString & GetName() const
Definition: format.hxx:132
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
vcl::Window * GetTopWindow() const
#define FN_EDIT_CURRENT_TOX
Definition: cmdid.h:132
virtual void DelAllUndoObj()=0
Delete all Undo actions.
#define FN_PARAM_FTN_INFO
Definition: cmdid.h:770
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
Point GetAnchorObjDiff() const
Methods for status line.
Definition: feshview.cxx:2306
const LocaleDataWrapper & GetUILocaleDataWrapper() const
#define ERRCODE_GRFILTER_OPENERROR
#define FN_STAT_SELMODE
Definition: cmdid.h:834
#define FN_TO_NEXT_PAGE
Definition: cmdid.h:729
bool IsBlockMode() const
Definition: wrtsh.hxx:161
#define ERRCODE_GRFILTER_FORMATERROR
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2669
const SwTOXBase * GetCurTOX() const
Get current listing before or at the Cursor.
Definition: edtox.cxx:187
const OUString & GetName() const
RedlineFlags on.
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
void Insert(SwField const &, SwPaM *pAnnotationRange=nullptr)
Definition: wrtsh2.cxx:60
const char * sName
const OUString & GetOldTabCat()
Definition: view2.cxx:2620
virtual bool IsConditionalFastCall(const SfxRequest &rReq) override
Definition: view2.cxx:1360
#define FN_INSERT_FIELD_DATA_ONLY
Definition: cmdid.h:212
#define FN_MAILMERGE_SENDMAIL_CHILDWINDOW
Definition: cmdid.h:269
#define FN_LINE_NUMBERING_DLG
Definition: cmdid.h:488
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
void GenerateFormLetter(bool bUseCurrentDocument)
Definition: view2.cxx:2421
constexpr OUStringLiteral aData
Definition: ww8scan.hxx:47
const OUString & GetOldDrwCat()
Definition: view2.cxx:2640
DocumentType eType
static ErrCode LoadGraphic(const OUString &rPath, const OUString &rFilter, Graphic &rGraphic, GraphicFilter *pFilter=nullptr, sal_uInt16 *pDeterminedFormat=nullptr)
tools::Long zoomOut(tools::Long nCurrent)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:331
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:203
static ErrCode HandleFilter(SfxMedium *pMedium, SfxObjectShell const *pDoc)
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
#define FN_STAT_TEMPLATE
Definition: cmdid.h:832
#define FN_REDLINE_ACCEPT_DIRECT
Definition: cmdid.h:137
T * get() const
#define FN_PAGEUP
Definition: cmdid.h:671
sal_uInt16 char * pName
static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn)
Definition: crsrsh.cxx:450
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:889
Style of a layout element.
Definition: frmfmt.hxx:58
void UpdateDocStats()
Definition: view2.cxx:1381
bool ToggleExtMode()
Definition: select.cxx:770
virtual bool IsThisDocument() const =0
bool HasSelection() const
Definition: wrtsh.hxx:141
#define SW_MOD()
Definition: swmodule.hxx:255
void GetAllUsedDB(std::vector< OUString > &rDBNameList, std::vector< OUString > const *pAllDBNames)
Definition: edfld.cxx:304
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
int i
void EditLinkDlg()
show "edit link" dialog
Definition: view2.cxx:2017
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
const OUString & GetSectionName() const
Definition: section.hxx:168
void ChildWindowExecute(SfxRequest &)
bool IsViewLayoutBookMode() const
Definition: viewopt.hxx:480
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:243
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:882
SVL_DLLPUBLIC Link< OUString *, bool > const & GetMaybeFileHdl()
FlyCntType
Definition: flyenum.hxx:23
virtual bool IsConditionalFastCall(const SfxRequest &rReq)
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2241
tools::Long zoomIn(tools::Long nCurrent)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
#define FN_REDLINE_ACCEPT_TONEXT
Definition: cmdid.h:145
sal_uInt16 GetGutterWidth(bool bMin=false) const
Definition: atrfrm.cxx:910
SfxBindings & GetBindings()
ErrCode InsertGraphic(const OUString &rPath, const OUString &rFilter, bool bLink, GraphicFilter *pFlt)
Definition: view2.cxx:226
void SetOldFrameCat(const OUString &sStr)
Definition: view2.cxx:2635
static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection)
Definition: crsrsh.cxx:461
vector_type::size_type size_type
Definition: docary.hxx:228
const OUString & GetValue() const
HTMLMODE_ON
#define FN_REDLINE_PREV_CHANGE
Definition: cmdid.h:142
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:355
const T * GetArg(sal_uInt16 nSlotId) const
tools::Long GetLeft() const
void ShowExtras(SfxShowExtras nExtras)
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
tools::Long Width() const
static size_t lcl_PageDescWithHeader(const SwDoc &rDoc)
Definition: view2.cxx:2169
size_t GetPageDescCnt() const
Definition: doc.hxx:881
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
float u
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
#define FN_SCROLL_NEXT
Definition: cmdid.h:181
SwDBData const & GetDBData() const
Database information.
Definition: edfld.cxx:289
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
tools::ULong GetSidebarBorderWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2130
#define FN_WORDCOUNT_DIALOG
Definition: cmdid.h:593
#define FN_SCROLL_PREV
Definition: cmdid.h:180
bool HasName() const
void LockPaint()
Definition: viewsh.hxx:602
#define FN_UPDATE_CUR_TOX
Definition: cmdid.h:506
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
OUString GetPageStr(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString &rPgStr)
Create string for showing the page number in the statusbar.
Definition: view2.cxx:195
Shell * m_pShell
Reader * StartConvertFrom(SfxMedium &rMedium, SwReaderPtr &rpRdr, SwCursorShell const *pCursorSh=nullptr, SwPaM *pPaM=nullptr)
For inserting document.
Definition: docsh.cxx:137
bool HasReadonlySel() const
Definition: crsrsh.cxx:3349
void SelAll()
Definition: select.cxx:122
const char sStatusDelim[]
Definition: view2.cxx:148
sal_Int16 nVersion
#define FN_REDLINE_REJECT_TONEXT
Definition: cmdid.h:146
void ExecuteStatusLine(SfxRequest &)
execute method for the status line
Definition: view2.cxx:1741
tools::ULong GetSidebarWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2104
SW_DLLPUBLIC void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem &rTabs)
Definition: uitool.cxx:576
bool StartExecuteAsync(const std::function< void(sal_Int32)> &rEndDialogFn)
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:129
sal_uInt32 GetId() const
Definition: redline.hxx:182
#define DB_DELIM
Definition: swtypes.hxx:133
#define FN_STAT_WORDCOUNT
Definition: cmdid.h:836
#define FN_TOGGLE_OUTLINE_CONTENT_VISIBILITY
Definition: cmdid.h:188
#define FN_QRY_MERGE
Definition: cmdid.h:230
tools::Long SwTwips
Definition: swtypes.hxx:49
void SpellItAgainSam(bool bInvalid, bool bOnlyWrong, bool bSmartTags)
Re-trigger spelling in the idle handler.
Definition: doc.cxx:1164
const SwPosition * Start() const
Definition: pam.hxx:212
OUString GetBoxNms() const
Definition: trvltbl.cxx:746
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
void SetMinLen(sal_uInt16 Len)
css::uno::Reference< css::linguistic2::XProofreadingIterator > const & GetGCIterator() const
Definition: docnew.cxx:118
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:746
SW_DLLPUBLIC bool HasActiveSidebarWin() const
Definition: PostItMgr.cxx:2355
virtual void SetLimits(sal_uInt16 nMin, sal_uInt16 nMax)=0
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
void StartAction()
Definition: crsrsh.cxx:226
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:464
void SetReturnValue(const SfxPoolItem &)
const LanguageTag & getLocale()
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SdrHdl * GetFocusHdl() const
void Update(sal_uInt16 nId)
bool IsError() const
tools::Long InsertMedium(sal_uInt16 nSlotId, std::unique_ptr< SfxMedium > pMedium, sal_Int16 nVersion)
Definition: view2.cxx:2255
void ResetAttr(const o3tl::sorted_vector< sal_uInt16 > &attrs=o3tl::sorted_vector< sal_uInt16 >(), SwPaM *pCursor=nullptr)
Definition: edatmisc.cxx:32
#define ERRCODE_GRFILTER_TOOBIG
sal_uInt16 GetWishWidth() const
Definition: fmtclds.hxx:122
#define ERRCODE_GRFILTER_FILTERERROR
#define FN_FORMAT_FRAME_DLG
Definition: cmdid.h:320
void UpdatePageNums()
invalidate page numbering field
Definition: view2.cxx:1375
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:216
const PropertyValue * pValues
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
#define ERRCODE_GRFILTER_VERSIONERROR
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:133
#define FN_NAV_ELEMENT
Definition: cmdid.h:179
sal_uInt16 GetSlot() const
void ExecuteInsertDoc(SfxRequest &rRequest, const SfxPoolItem *pItem)
Definition: view2.cxx:2187
bool IsAnyDatabaseFieldInDoc() const
Definition: edfld.cxx:386
bool HasChildWindow(sal_uInt16)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
#define FN_INSERT_FIELD
Definition: cmdid.h:200
void ToggleInsModeOnActiveSidebarWin()
Definition: PostItMgr.cxx:2398
static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
Definition: crsrsh.cxx:439
bool IsCursorVisible() const
Definition: crsrsh.hxx:520
void DisableItem(sal_uInt16 nWhich)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
void EnterExtMode()
Definition: select.cxx:583
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:603
Rect covering the pages area.
static void CalculateNonBlankPages(const SwRootFrame &rLayout, sal_uInt16 &nDocPageCount, sal_uInt16 &nActualPage)
Definition: doc.cxx:643
void ToggleAddMode()
Definition: select.cxx:757
#define ERRCODE_NONE
#define FN_SET_BLOCK_MODE
Definition: cmdid.h:706
void SetValueSet(SvxZoomEnableFlags nValues)
unsigned char sal_uInt8
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1694
#define STR_SW_EVENT_PAGE_COUNT
Definition: swevent.hxx:27
void LockView(bool b)
Definition: viewsh.hxx:462
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
TOXTypes GetType() const
Definition: tox.hxx:733
#define FN_REDLINE_NEXT_CHANGE
Definition: cmdid.h:141
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: redlndlg.cxx:70
RET_OK
... page will be formatted if required.
tools::Long AdjustWidth(tools::Long n)
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
const char sDisplay[]
tools::Long Height() const
const INetURLObject & GetURLObject() const
OUString GetPassword() const
sal_uInt16 GetZoom() const
Definition: viewopt.hxx:506
void Execute(SfxRequest &)
Definition: view2.cxx:533
size_t IsObjSelected() const
Definition: feshview.cxx:1149
virtual short run()
virtual short run() override
Reference< XComponentContext > getProcessComponentContext()
#define FN_PAGEDOWN
Definition: cmdid.h:672
void SetOldGrfCat(const OUString &sStr)
Definition: view2.cxx:2615
bool HasNotes() const
Definition: PostItMgr.cxx:2099
bool IsExtMode() const
Definition: wrtsh.hxx:151
static void ToggleDeck(std::u16string_view rsDeckId, SfxViewFrame *pViewFrame)
#define FN_FORMAT_PAGE_DLG
Definition: cmdid.h:317
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
#define FN_SET_EXT_MODE
Definition: cmdid.h:674
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:177
static OUString GetEventName(sal_Int32 nId)
Definition: docsh.cxx:1314
bool bColumnChange()
Definition: crsrsh.cxx:472
void ShowChildWindow(sal_uInt16, bool bVisible=true)
const char cSequenceMarkSeparator
Definition: swtypes.hxx:131
void SetFrameFormat(SwFrameFormat *pFormat, bool bKeepOrient=false, Point const *pDocPos=nullptr)
If frame then set frame style.
Definition: fefly1.cxx:1200
bool read(Graphic const &rGraphic)
const std::u16string_view aStringList[]
#define ERR_SWG_READ_ERROR
Definition: swerror.h:25
#define SID_INSPECTOR_DECK
Definition: cmdid.h:872
void InsFrameMode(sal_uInt16 nCols)
Definition: view2.cxx:1992
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
static GraphicFilter & GetGraphicFilter()
SAL_DLLPRIVATE bool InsertGraphicDlg(SfxRequest &)
Definition: view2.cxx:294
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
void AppendItem(const SfxPoolItem &)
void rotate(Degree10 aRotation)
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
OUString getNum(sal_Int64 nNumber, sal_uInt16 nDecimals, bool bUseThousandSep=true, bool bTrailingZeros=true) const
size_t size() const
const SdrHdlList & GetHdlList() const
bool IsAddMode() const
Definition: wrtsh.hxx:156
void EnableMailMerge()
Definition: view2.cxx:2395
SvxZoomType
#define SW_LEAVE_FRAME
Definition: fesh.hxx:167
virtual bool ImportFrom(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
void SetOldTabCat(const OUString &sStr)
Definition: view2.cxx:2625
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:184
virtual VclPtr< VclAbstractDialog > CreateVclSwViewDialog(SwView &rView)=0
SectionType GetType() const
Definition: section.hxx:170
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:137
sal_uLong nWord
Definition: docstat.hxx:35
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1203
int GetCurrentParaOutlineLevel() const
Get Outline level of current paragraph.
Definition: ednumber.cxx:457
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:78
virtual const SwRedlineTable & GetRedlineTable() const =0
bool ShowNotes() const
Definition: PostItMgr.cxx:2093
const SwFrameFormats * GetFrameFormats() const
Definition: doc.hxx:737
SfxFilterContainer * GetFilterContainer() const
virtual void SetRedlinePassword(const css::uno::Sequence< sal_Int8 > &rNewPassword)=0
static FlyMode GetFrameMode()
Definition: basesh.hxx:112
void Init(sal_uInt16 nNumCols, sal_uInt16 nGutterWidth, sal_uInt16 nAct)
This function allows to (repeatedly) initialize the columns.
Definition: atrfrm.cxx:961
void EnterAddMode()
Definition: select.cxx:625
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1395
#define FN_ESCAPE
Definition: cmdid.h:675
#define FN_REDLINE_SHOW
Definition: cmdid.h:122
#define FN_INSERT_MULTI_TOX
Definition: cmdid.h:283
void Ignore()
#define FN_REDLINE_REJECT_DIRECT
Definition: cmdid.h:138
void ExecuteFormLetter(SwWrtShell &rSh, const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
Definition: dbmgr.cxx:2917
static constexpr size_type npos
Definition: docary.hxx:229
OUString const & GetName() const
bool IsAuto() const
Query / set AutoFormat-flag.
Definition: format.hxx:179
OUString sCommand
Definition: swdbdata.hxx:31
#define FN_REDLINE_ACCEPT
Definition: cmdid.h:130
aStr
bool IsFrameSelected() const
Definition: feshview.cxx:1157
sal_uInt16 GetViewLayoutColumns() const
Definition: viewopt.hxx:482
void SetOldDrwCat(const OUString &sStr)
Definition: view2.cxx:2645
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
OUString SfxResId(const char *pId)
no RedlineFlags
bool IsOutlineRule() const
Definition: numrule.hxx:240
static void lcl_SetAllTextToDefaultLanguage(SwWrtShell &rWrtSh, sal_uInt16 nWhichId)
Definition: view2.cxx:162
Definition: view.hxx:144
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
sal_uInt16 nPos
sal_uInt16 GetGapBetweenPages() const
Definition: viewopt.hxx:458
void UnlockPaint(bool bVirDev=false)
Definition: viewsh.hxx:607
#define FN_GOTO_PAGE
Definition: cmdid.h:509
const OUString & GetTOXName() const
Definition: tox.hxx:478
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SfxMedium * GetMedium() const
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
static OUString decode(OUString const &rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)