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 <SwCapObjType.hxx>
34 #include <SwStyleNameMapper.hxx>
35 #include <docary.hxx>
36 #include <hintids.hxx>
37 #include <SwRewriter.hxx>
38 #include <numrule.hxx>
39 #include <swundo.hxx>
40 #include <svl/PasswordHelper.hxx>
41 #include <svl/urihelper.hxx>
42 #include <svtools/miscopt.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>
83 #include <IDocumentUndoRedo.hxx>
86 #include <IDocumentStatistics.hxx>
87 #include <wrtsh.hxx>
88 #include <viewopt.hxx>
89 #include <basesh.hxx>
90 #include <swmodule.hxx>
91 #include <uitool.hxx>
92 #include <shellio.hxx>
93 #include <fmtinfmt.hxx>
94 #include <mdiexp.hxx>
95 #include <drawbase.hxx>
96 #include <frmatr.hxx>
97 #include <frmmgr.hxx>
98 #include <pagedesc.hxx>
99 #include <section.hxx>
100 #include <tox.hxx>
101 #include <edtwin.hxx>
102 #include <wview.hxx>
103 #include <cmdid.h>
104 #include <sfx2/strings.hrc>
105 #include <sfx2/sfxresid.hxx>
106 #include <strings.hrc>
107 #include <swerror.h>
108 #include <globals.hrc>
109 #include <fmtclds.hxx>
110 #include <sfx2/templatedlg.hxx>
111 #include <dbconfig.hxx>
112 #include <dbmgr.hxx>
113 #include <reffld.hxx>
114 #include <comphelper/lok.hxx>
115 
116 #include <PostItMgr.hxx>
117 
119 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
120 
121 #include <svx/svxdlg.hxx>
122 #include <swabstdlg.hxx>
123 #include <fmthdft.hxx>
124 #include <unotextrange.hxx>
125 #include <docstat.hxx>
126 #include <wordcountdialog.hxx>
127 #include <sfx2/sidebar/Sidebar.hxx>
129 
132 #include <vcl/settings.hxx>
133 #include <i18nutil/searchopt.hxx>
134 #include <paratr.hxx>
135 #include <rootfrm.hxx>
136 #include <frameformats.hxx>
137 
138 #include <viewimp.hxx>
139 #include <pagefrm.hxx>
140 
141 #include <memory>
142 #include <string_view>
143 
145 
146 const char sStatusDelim[] = " : ";
147 
148 using namespace sfx2;
149 using namespace ::com::sun::star;
150 using namespace ::com::sun::star::i18n;
151 using namespace ::com::sun::star::util;
152 using namespace ::com::sun::star::uno;
153 using namespace ::com::sun::star::lang;
154 using namespace ::com::sun::star::scanner;
155 using namespace ::com::sun::star::beans;
156 using namespace ::com::sun::star::container;
157 using namespace ::com::sun::star::sdb;
158 using namespace ::com::sun::star::ui::dialogs;
159 
160 static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhichId )
161 {
162  if (!(nWhichId == RES_CHRATR_LANGUAGE ||
163  nWhichId == RES_CHRATR_CJK_LANGUAGE ||
164  nWhichId == RES_CHRATR_CTL_LANGUAGE))
165  return;
166 
167  rWrtSh.StartAction();
168  rWrtSh.LockView( true );
169  rWrtSh.Push();
170 
171  // prepare to apply new language to all text in document
172  rWrtSh.SelAll();
173  rWrtSh.ExtendedSelectAll();
174 
175  // set language attribute to default for all text
176  std::set<sal_uInt16> aAttribs;
177  aAttribs.insert( nWhichId );
178  rWrtSh.ResetAttr( aAttribs );
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?
453  if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
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 FN_REFRESH_VIEW:
566  GetEditWin().Invalidate();
567  break;
568  case FN_PAGEUP:
569  case FN_PAGEUP_SEL:
570  case FN_PAGEDOWN:
571  case FN_PAGEDOWN_SEL:
572  {
573  tools::Rectangle aVis( GetVisArea() );
574  SwEditWin& rTmpWin = GetEditWin();
575  if ( FN_PAGEUP == nSlot || FN_PAGEUP_SEL == nSlot )
576  PageUpCursor(FN_PAGEUP_SEL == nSlot);
577  else
578  PageDownCursor(FN_PAGEDOWN_SEL == nSlot);
579 
580  rReq.SetReturnValue(SfxBoolItem(nSlot,
581  aVis != GetVisArea()));
582  //#i42732# - notify the edit window that from now on we do not use the input language
583  rTmpWin.SetUseInputLanguage( false );
584  }
585  break;
586  case SID_ZOOM_IN:
587  case SID_ZOOM_OUT:
588  {
589  tools::Long nFact = m_pWrtShell->GetViewOptions()->GetZoom();
590  if (SID_ZOOM_OUT == nSlot)
591  nFact = basegfx::zoomtools::zoomIn(nFact);
592  else
593  nFact = basegfx::zoomtools::zoomOut(nFact);
594  SetZoom(SvxZoomType::PERCENT, nFact);
595  }
596  break;
597  case FN_TO_PREV_PAGE:
598  case FN_TO_NEXT_PAGE:
599  {
600  sal_uInt16 nPage = 0;
601  if (m_pWrtShell->IsCursorVisible())
602  nPage = m_pWrtShell->GetCursor()->GetPageNum();
603  else
604  {
605  SwFrame* pPageFrame = m_pWrtShell->Imp()->GetFirstVisPage(m_pWrtShell->GetOut());
606  if (pPageFrame)
607  nPage = pPageFrame->GetPhyPageNum();
608  }
609  if (nPage != 0)
610  {
611  sal_uInt16 nOldPage(nPage);
612  if (FN_TO_PREV_PAGE == nSlot && nPage > 1)
613  nPage--;
614  else if (FN_TO_NEXT_PAGE == nSlot && nPage < m_pWrtShell->GetPageCount())
615  nPage++;
616  if (nPage != nOldPage)
617  {
618  m_pWrtShell->LockPaint();
619  if (IsDrawMode())
620  LeaveDrawCreate();
621  m_pWrtShell->EnterStdMode();
622  m_pWrtShell->GotoPage(nPage, true);
623  // set visible area (borrowed from SwView::PhyPageUp/Down)
624  const Point aPt(m_aVisArea.Left(), m_pWrtShell->GetPagePos(nPage).Y());
625  Point aAlPt(AlignToPixel(aPt));
626  if(aPt.Y() != aAlPt.Y())
627  aAlPt.AdjustY(3 * GetEditWin().PixelToLogic(Size(0, 1)).Height());
628  SetVisArea(aAlPt);
629  m_pWrtShell->UnlockPaint();
630  }
631  }
632  }
633  break;
634  case FN_REDLINE_ON:
635  {
636  if( pArgs &&
637  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
638  {
639  IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
640  Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
641  if( aPasswd.hasElements() )
642  {
643  OSL_ENSURE( !static_cast<const SfxBoolItem*>(pItem)->GetValue(), "SwView::Execute(): password set and redlining off doesn't match!" );
644 
645  // dummy password from OOXML import: only confirmation dialog
646  if (aPasswd.getLength() == 1 && aPasswd[0] == 1)
647  {
648  std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(m_pWrtShell->GetView().GetFrameWeld(),
649  VclMessageType::Warning, VclButtonsType::YesNo,
650  SfxResId(RID_SVXSTR_END_REDLINING_WARNING)));
651  xWarn->set_default_response(RET_NO);
652  if (xWarn->run() == RET_YES)
653  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
654  else
655  break;
656  }
657  else
658  {
659  // xmlsec05: new password dialog
660  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
661  aPasswdDlg.SetMinLen(1);
662  //#i69751# the result of Execute() can be ignored
663  (void)aPasswdDlg.run();
664  OUString sNewPasswd(aPasswdDlg.GetPassword());
665  Sequence <sal_Int8> aNewPasswd = rIDRA.GetRedlinePassword();
666  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
667  if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
668  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
669  else
670  { // xmlsec05: message box for wrong password
671  break;
672  }
673  }
674  }
675 
676  const RedlineFlags nOn = static_cast<const SfxBoolItem*>(pItem)->GetValue()
678  const RedlineFlags nMode = m_pWrtShell->GetRedlineFlags();
679  m_pWrtShell->SetRedlineFlagsAndCheckInsMode( (nMode & ~RedlineFlags::On) | nOn);
680 
681  // Notify all view shells of this document, as the track changes mode is document-global.
682  SwDocShell* pDocShell = GetDocShell();
683  for (SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(pDocShell); pViewFrame; pViewFrame = SfxViewFrame::GetNext(*pViewFrame, pDocShell))
684  {
685  pViewFrame->GetBindings().Invalidate(FN_REDLINE_ON);
686  pViewFrame->GetBindings().Update(FN_REDLINE_ON);
687  }
688  }
689  }
690  break;
691  case FN_REDLINE_PROTECT :
692  {
693  IDocumentRedlineAccess& rIDRA = m_pWrtShell->getIDocumentRedlineAccess();
694  Sequence <sal_Int8> aPasswd = rIDRA.GetRedlinePassword();
695  if( pArgs && SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem )
696  && static_cast<const SfxBoolItem*>(pItem)->GetValue() == aPasswd.hasElements() )
697  break;
698 
699  // xmlsec05: new password dialog
700  // message box for wrong password
701  SfxPasswordDialog aPasswdDlg(GetFrameWeld());
702  aPasswdDlg.SetMinLen(1);
703  if (!aPasswd.hasElements())
704  aPasswdDlg.ShowExtras(SfxShowExtras::CONFIRM);
705  if (aPasswdDlg.run())
706  {
708  OUString sNewPasswd(aPasswdDlg.GetPassword());
709  Sequence <sal_Int8> aNewPasswd =
710  rIDRA.GetRedlinePassword();
711  SvPasswordHelper::GetHashPassword( aNewPasswd, sNewPasswd );
712  if(!aPasswd.hasElements())
713  {
714  rIDRA.SetRedlinePassword(aNewPasswd);
715  }
716  else if(SvPasswordHelper::CompareHashPassword(aPasswd, sNewPasswd))
717  {
718  rIDRA.SetRedlinePassword(Sequence <sal_Int8> ());
719  nOn = RedlineFlags::NONE;
720  }
721  const RedlineFlags nMode = rIDRA.GetRedlineFlags();
722  m_pWrtShell->SetRedlineFlagsAndCheckInsMode( (nMode & ~RedlineFlags::On) | nOn);
723  rReq.AppendItem( SfxBoolItem( FN_REDLINE_PROTECT, !(nMode&RedlineFlags::On) ) );
724  }
725  else
726  bIgnore = true;
727  }
728  break;
729  case FN_REDLINE_SHOW:
730 
731  if( pArgs &&
732  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem))
733  {
734  // tdf#125754 avoid recursive layout
735  // because all views share the layout, have to use AllAction
736  m_pWrtShell->StartAllAction();
737  m_pWrtShell->GetLayout()->SetHideRedlines(
738  !static_cast<const SfxBoolItem*>(pItem)->GetValue());
739  m_pWrtShell->EndAllAction();
740  if (m_pWrtShell->IsRedlineOn())
741  m_pWrtShell->SetInsMode();
742  }
743  break;
745  case FN_REDLINE_ACCEPT:
746  GetViewFrame()->ToggleChildWindow(nSlot);
747  break;
752  {
753  SwDoc *pDoc = m_pWrtShell->GetDoc();
754  SwPaM *pCursor = m_pWrtShell->GetCursor();
755  const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
757  if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
758  {
759  const sal_Int64 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
760  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
761  {
762  if (nChangeId == rRedlineTable[i]->GetId())
763  nRedline = i;
764  }
765  }
766 
767  if( pCursor->HasMark() && nRedline == SwRedlineTable::npos)
768  {
769  if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
770  m_pWrtShell->AcceptRedlinesInSelection();
771  else
772  m_pWrtShell->RejectRedlinesInSelection();
773  }
774  else
775  {
776  // We check for a redline at the start of the selection/cursor, not the point.
777  // This ensures we work properly with FN_REDLINE_NEXT_CHANGE, which leaves the
778  // point at the *end* of the redline and the mark at the start (so GetRedline
779  // would return NULL if called on the point)
780  const SwRangeRedline* pRedline = nullptr;
781  if (nRedline != SwRedlineTable::npos)
782  {
783  // A redline was explicitly requested by specifying an
784  // index, don't guess based on the cursor position.
785 
786  if (nRedline < rRedlineTable.size())
787  pRedline = rRedlineTable[nRedline];
788  }
789  else
790  pRedline = pDoc->getIDocumentRedlineAccess().GetRedline(*pCursor->Start(), &nRedline);
791 
792  assert(pRedline != nullptr);
793  if (pRedline)
794  {
795  if (FN_REDLINE_ACCEPT_DIRECT == nSlot || FN_REDLINE_ACCEPT_TONEXT == nSlot)
796  m_pWrtShell->AcceptRedline(nRedline);
797  else
798  m_pWrtShell->RejectRedline(nRedline);
799  }
800  }
801  if (FN_REDLINE_ACCEPT_TONEXT == nSlot || FN_REDLINE_REJECT_TONEXT == nSlot)
802  {
803  // Go to next change after accepting or rejecting one (tdf#101977)
804  GetViewFrame()->GetDispatcher()->Execute(FN_REDLINE_NEXT_CHANGE, SfxCallMode::ASYNCHRON);
805  }
806  }
807  break;
808 
810  {
811  // If a parameter is provided, try going to the nth change, not to
812  // the next one.
813  SwDoc* pDoc = m_pWrtShell->GetDoc();
814  const SwRedlineTable& rRedlineTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
816  if (pArgs && pArgs->GetItemState(nSlot, false, &pItem) == SfxItemState::SET)
817  {
818  const sal_uInt32 nChangeId = static_cast<const SfxUInt32Item*>(pItem)->GetValue();
819  for (SwRedlineTable::size_type i = 0; i < rRedlineTable.size(); ++i)
820  {
821  if (nChangeId == rRedlineTable[i]->GetId())
822  nRedline = i;
823  }
824  }
825 
826  const SwRangeRedline *pNext = nullptr;
827  if (nRedline < rRedlineTable.size())
828  pNext = m_pWrtShell->GotoRedline(nRedline, true);
829  else
830  pNext = m_pWrtShell->SelNextRedline();
831 
832  if (pNext)
833  {
835  {
836  OString aPayload(".uno:CurrentTrackedChangeId=");
837  sal_uInt32 nRedlineId = pNext->GetId();
838  aPayload += OString::number(nRedlineId);
839  libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload.getStr());
840  }
841 
842  m_pWrtShell->SetInSelect();
843  }
844 
845  }
846  break;
847 
849  {
850  const SwRangeRedline *pPrev = m_pWrtShell->SelPrevRedline();
851 
852  if (pPrev)
853  {
855  {
856  OString aPayload(".uno:CurrentTrackedChangeId=");
857  sal_uInt32 nRedlineId = pPrev->GetId();
858  aPayload += OString::number(nRedlineId);
859  libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload.getStr());
860  }
861 
862  m_pWrtShell->SetInSelect();
863  }
864  }
865  break;
866 
867  case SID_DOCUMENT_COMPARE:
868  case SID_DOCUMENT_MERGE:
869  {
870  OUString sFileName, sFilterName;
871  sal_Int16 nVersion = 0;
872  bool bHasFileName = false;
873  m_pViewImpl->SetParam( 0 );
874  bool bNoAcceptDialog = false;
875 
876  if( pArgs )
877  {
878  if( SfxItemState::SET == pArgs->GetItemState( SID_FILE_NAME, false, &pItem ))
879  sFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
880  bHasFileName = !sFileName.isEmpty();
881 
882  if( SfxItemState::SET == pArgs->GetItemState( SID_FILTER_NAME, false, &pItem ))
883  sFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
884 
885  if( SfxItemState::SET == pArgs->GetItemState( SID_VERSION, false, &pItem ))
886  {
887  nVersion = static_cast<const SfxInt16Item *>(pItem)->GetValue();
888  m_pViewImpl->SetParam( nVersion );
889  }
890  if( SfxItemState::SET == pArgs->GetItemState( SID_NO_ACCEPT_DIALOG, false, &pItem ))
891  {
892  bNoAcceptDialog = static_cast<const SfxBoolItem *>(pItem)->GetValue();
893  }
894  }
895 
896  m_pViewImpl->InitRequest( rReq );
897  tools::Long nFound = InsertDoc( nSlot, sFileName, sFilterName, nVersion );
898 
899  if ( bHasFileName )
900  {
901  rReq.SetReturnValue( SfxInt32Item( nSlot, nFound ));
902 
903  if (nFound > 0 && !bNoAcceptDialog) // show Redline browser
904  {
905  SfxViewFrame* pVFrame = GetViewFrame();
907 
908  // re-initialize the Redline dialog
909  const sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
910  SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(
911  pVFrame->GetChildWindow(nId));
912  if (pRed)
913  pRed->ReInitDlg(GetDocShell());
914  }
915  }
916  else
917  bIgnore = true;
918  }
919  break;
920  case FN_SYNC_LABELS:
921  GetViewFrame()->ShowChildWindow(nSlot);
922  break;
923  case FN_ESCAPE:
924  {
925  if ( m_pWrtShell->HasDrawViewDrag() )
926  {
927  m_pWrtShell->BreakDrag();
928  m_pWrtShell->EnterSelFrameMode();
929  }
930  else if ( m_pWrtShell->IsDrawCreate() )
931  {
932  GetDrawFuncPtr()->BreakCreate();
933  AttrChangedNotify(nullptr); // shell change if needed
934  }
935  else if ( m_pWrtShell->HasSelection() || IsDrawMode() )
936  {
937  SdrView *pSdrView = m_pWrtShell->HasDrawView() ? m_pWrtShell->GetDrawView() : nullptr;
938  if(pSdrView && pSdrView->AreObjectsMarked() &&
939  pSdrView->GetHdlList().GetFocusHdl())
940  {
941  const_cast<SdrHdlList&>(pSdrView->GetHdlList()).ResetFocusHdl();
942  }
943  else
944  {
945  if(pSdrView)
946  {
947  LeaveDrawCreate();
948  Point aPt(LONG_MIN, LONG_MIN);
949  //go out of the frame
950  m_pWrtShell->SelectObj(aPt, SW_LEAVE_FRAME);
951  SfxBindings& rBind = GetViewFrame()->GetBindings();
952  rBind.Invalidate( SID_ATTR_SIZE );
953  }
954  m_pWrtShell->EnterStdMode();
955  AttrChangedNotify(nullptr); // shell change if necessary
956  }
957  }
958  else if ( GetEditWin().GetApplyTemplate() )
959  {
960  GetEditWin().SetApplyTemplate(SwApplyTemplate());
961  }
962  else if( static_cast<SfxObjectShell*>(GetDocShell())->IsInPlaceActive() )
963  {
964  Escape();
965  }
966  else if ( GetEditWin().IsChainMode() )
967  {
968  GetEditWin().SetChainMode( false );
969  }
970  else if( m_pWrtShell->GetFlyFrameFormat() )
971  {
972  const SwFrameFormat* pFormat = m_pWrtShell->GetFlyFrameFormat();
973  if(m_pWrtShell->GotoFly( pFormat->GetName(), FLYCNTTYPE_FRM ))
974  {
975  m_pWrtShell->HideCursor();
976  m_pWrtShell->EnterSelFrameMode();
977  }
978  }
979  else
980  {
981  SfxBoolItem aItem( SID_WIN_FULLSCREEN, false );
982  GetViewFrame()->GetDispatcher()->ExecuteList(SID_WIN_FULLSCREEN,
983  SfxCallMode::RECORD, { &aItem });
984  bIgnore = true;
985  }
986  }
987  break;
988  case SID_ATTR_BORDER_INNER:
989  case SID_ATTR_BORDER_OUTER:
990  case SID_ATTR_BORDER_SHADOW:
991  if(pArgs)
992  m_pWrtShell->SetAttrSet(*pArgs);
993  break;
994 
995  case SID_ATTR_PAGE:
996  case SID_ATTR_PAGE_SIZE:
997  case SID_ATTR_PAGE_MAXSIZE:
998  case SID_ATTR_PAGE_PAPERBIN:
999  case SID_ATTR_PAGE_EXT1:
1000  case FN_PARAM_FTN_INFO:
1001  {
1002  if(pArgs)
1003  {
1004  const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
1005  SwPageDesc aPageDesc( m_pWrtShell->GetPageDesc( nCurIdx ) );
1006  ::ItemSetToPageDesc( *pArgs, aPageDesc );
1007  // change the descriptor of the core
1008  m_pWrtShell->ChgPageDesc( nCurIdx, aPageDesc );
1009  }
1010  }
1011  break;
1012  case FN_GOTO_PAGE:
1013  {
1014  SwGotoPageDlg aDlg(GetViewFrame()->GetWindow().GetFrameWeld(), &GetViewFrame()->GetBindings());
1015  if (aDlg.run() == RET_OK)
1016  GetWrtShell().GotoPage(aDlg.GetPageSelection(), true);
1017  }
1018  break;
1019  case FN_EDIT_CURRENT_TOX:
1020  {
1021  GetViewFrame()->GetDispatcher()->Execute(
1022  FN_INSERT_MULTI_TOX, SfxCallMode::ASYNCHRON);
1023  }
1024  break;
1025  case FN_UPDATE_CUR_TOX:
1026  {
1027  const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
1028  if(pBase)
1029  {
1030  // tdf#106374: don't jump view on the update
1031  const bool bWasLocked = m_pWrtShell->IsViewLocked();
1032  m_pWrtShell->LockView(true);
1033  m_pWrtShell->StartAction();
1034  if(TOX_INDEX == pBase->GetType())
1035  m_pWrtShell->ApplyAutoMark();
1036  m_pWrtShell->UpdateTableOf( *pBase );
1037  m_pWrtShell->EndAction();
1038  if (!bWasLocked)
1039  m_pWrtShell->LockView(false);
1040  }
1041  }
1042  break;
1043  case FN_UPDATE_TOX:
1044  {
1045  m_pWrtShell->StartAction();
1046  m_pWrtShell->EnterStdMode();
1047  bool bOldCursorInReadOnly = m_pWrtShell->IsReadOnlyAvailable();
1048  m_pWrtShell->SetReadOnlyAvailable( true );
1049 
1050  for( int i = 0; i < 2; ++i )
1051  {
1052  if( m_pWrtShell->GetTOXCount() == 1 )
1053  ++i;
1054 
1055  while( m_pWrtShell->GotoPrevTOXBase() )
1056  ; // jump to the first "table of ..."
1057 
1058  // if we are not in one, jump to next
1059  const SwTOXBase* pBase = m_pWrtShell->GetCurTOX();
1060  if( !pBase )
1061  {
1062  m_pWrtShell->GotoNextTOXBase();
1063  pBase = m_pWrtShell->GetCurTOX();
1064  }
1065 
1066  bool bAutoMarkApplied = false;
1067  while( pBase )
1068  {
1069  if(TOX_INDEX == pBase->GetType() && !bAutoMarkApplied)
1070  {
1071  m_pWrtShell->ApplyAutoMark();
1072  bAutoMarkApplied = true;
1073  }
1074  // pBase is needed only for the interface. Should be changed in future! (JP 1996)
1075  m_pWrtShell->UpdateTableOf( *pBase );
1076 
1077  if( m_pWrtShell->GotoNextTOXBase() )
1078  pBase = m_pWrtShell->GetCurTOX();
1079  else
1080  pBase = nullptr;
1081  }
1082  }
1083  m_pWrtShell->SetReadOnlyAvailable( bOldCursorInReadOnly );
1084  m_pWrtShell->EndAction();
1085  }
1086  break;
1087  case SID_ATTR_BRUSH:
1088  {
1089  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_BACKGROUND, false, &pItem))
1090  {
1091  const size_t nCurIdx = m_pWrtShell->GetCurPageDesc();
1092  SwPageDesc aDesc( m_pWrtShell->GetPageDesc( nCurIdx ));
1093  SwFrameFormat& rMaster = aDesc.GetMaster();
1094  rMaster.SetFormatAttr(*pItem);
1095  m_pWrtShell->ChgPageDesc( nCurIdx, aDesc);
1096  }
1097  }
1098  break;
1099  case SID_CLEARHISTORY:
1100  {
1101  m_pWrtShell->DelAllUndoObj();
1102  }
1103  break;
1104  case SID_UNDO:
1105  {
1106  m_pShell->ExecuteSlot(rReq);
1107  }
1108  break;
1109 #if defined(_WIN32) || defined UNX
1110  case SID_TWAIN_SELECT:
1111  case SID_TWAIN_TRANSFER:
1112  GetViewImpl()->ExecuteScan( rReq );
1113  break;
1114 #endif
1115 
1116  case SID_ATTR_DEFTABSTOP:
1117  {
1118  if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_DEFTABSTOP, false, &pItem))
1119  {
1120  SvxTabStopItem aDefTabs( 0, 0, SvxTabAdjust::Default, RES_PARATR_TABSTOP );
1121  const sal_uInt16 nTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1122  MakeDefTabs( nTab, aDefTabs );
1123  m_pWrtShell->SetDefault( aDefTabs );
1124  }
1125  }
1126  break;
1127  case SID_ATTR_LANGUAGE :
1128  if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LANGUAGE, false, &pItem))
1129  {
1130  SvxLanguageItem aLang(static_cast<const SvxLanguageItem*>(pItem)->GetLanguage(), RES_CHRATR_LANGUAGE);
1131  m_pWrtShell->SetDefault( aLang );
1133  }
1134  break;
1135  case SID_ATTR_CHAR_CTL_LANGUAGE:
1136  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CTL_LANGUAGE, false, &pItem))
1137  {
1138  m_pWrtShell->SetDefault( *pItem );
1140  }
1141  break;
1142  case SID_ATTR_CHAR_CJK_LANGUAGE:
1143  if(pArgs && SfxItemState::SET == pArgs->GetItemState(RES_CHRATR_CJK_LANGUAGE, false, &pItem))
1144  {
1145  m_pWrtShell->SetDefault( *pItem );
1147  }
1148  break;
1150  {
1151  m_pWrtShell->EnterStdMode();
1152  size_t nPos(m_pWrtShell->GetOutlinePos());
1153  m_pWrtShell->ToggleOutlineContentVisibility(nPos);
1154  m_pWrtShell->GotoOutline(nPos);
1155  }
1156  break;
1157  case FN_NAV_ELEMENT:
1158  {
1159  // nothing here on purpose - if removed only the listbox that changed is changed
1160  }
1161  break;
1162  case FN_SCROLL_PREV:
1163  case FN_SCROLL_NEXT:
1164  {
1165  bool *pbNext = new bool(true); // FN_SCROLL_NEXT
1166  if (nSlot == FN_SCROLL_PREV)
1167  *pbNext = false;
1168  // #i75416# move the execution of the search to an asynchronously called static link
1169  Application::PostUserEvent( LINK(this, SwView, MoveNavigationHdl), pbNext );
1170  }
1171  break;
1172  case SID_JUMPTOMARK:
1173  if( pArgs && SfxItemState::SET == pArgs->GetItemState(SID_JUMPTOMARK, false, &pItem))
1174  JumpToSwMark( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1175  break;
1176  case SID_GALLERY :
1177  // First make sure that the sidebar is visible
1178  GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
1179 
1181  "GalleryPanel",
1182  GetViewFrame()->GetFrame().GetFrameInterface());
1183  break;
1184  case SID_AVMEDIA_PLAYER :
1185  GetViewFrame()->ChildWindowExecute(rReq);
1186  break;
1187  case SID_VIEW_DATA_SOURCE_BROWSER:
1188  {
1189  SfxViewFrame* pVFrame = GetViewFrame();
1190  pVFrame->ChildWindowExecute(rReq);
1191  if(pVFrame->HasChildWindow(SID_BROWSER))
1192  {
1193  const SwDBData& rData = GetWrtShell().GetDBDesc();
1194  SwModule::ShowDBObj(*this, rData);
1195  }
1196  }
1197  break;
1199  {
1200  bool bShow = false;
1201  if( pArgs &&
1202  SfxItemState::SET == pArgs->GetItemState(nSlot, false, &pItem ))
1203  bShow = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1204  if((bShow && m_bInMailMerge) != GetViewFrame()->HasChildWindow(nSlot))
1205  GetViewFrame()->ToggleChildWindow(nSlot);
1206  //if fields have been successfully inserted call the "real"
1207  //mail merge dialog
1208 #if HAVE_FEATURE_DBCONNECTIVITY
1209  SwWrtShell &rSh = GetWrtShell();
1210  if(m_bInMailMerge && rSh.IsAnyDatabaseFieldInDoc())
1211  {
1212  SwDBManager* pDBManager = rSh.GetDBManager();
1213  if (pDBManager)
1214  {
1215  SwDBData aData = rSh.GetDBData();
1216  rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
1217  AttrChangedNotify(nullptr);
1218 
1219  Sequence<PropertyValue> aProperties(3);
1220  PropertyValue* pValues = aProperties.getArray();
1221  pValues[0].Name = "DataSourceName";
1222  pValues[1].Name = "Command";
1223  pValues[2].Name = "CommandType";
1224  pValues[0].Value <<= aData.sDataSource;
1225  pValues[1].Value <<= aData.sCommand;
1226  pValues[2].Value <<= aData.nCommandType;
1227  pDBManager->ExecuteFormLetter(rSh, aProperties);
1228  }
1229  }
1230 #endif
1231  m_bInMailMerge &= bShow;
1232  GetViewFrame()->GetBindings().Invalidate(FN_INSERT_FIELD);
1233  }
1234  break;
1235  case FN_QRY_MERGE:
1236  {
1237  bool bUseCurrentDocument = true;
1238  bool bQuery = !pArgs || SfxItemState::SET != pArgs->GetItemState(nSlot);
1239  if(bQuery)
1240  {
1241  SfxViewFrame* pTmpFrame = GetViewFrame();
1244  if (RET_OK == pDlg->Execute())
1245  bUseCurrentDocument = pDlg->IsThisDocument();
1246  else
1247  break;
1248  }
1249  GenerateFormLetter(bUseCurrentDocument);
1250  }
1251  break;
1252  case SID_RECHECK_DOCUMENT:
1253  {
1254  SwDocShell* pDocShell = GetDocShell();
1255  SwDoc* pDoc = pDocShell->GetDoc();
1256  uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() );
1257  if( xGCIterator.is() )
1258  {
1259  xGCIterator->resetIgnoreRules();
1260  }
1261  // reset ignore lists
1262  pDoc->SpellItAgainSam( true, false, false );
1263  // clear ignore dictionary
1264  uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
1265  if( xDictionary.is() )
1266  xDictionary->clear();
1267  // put cursor to the start of the document
1268  m_pWrtShell->StartOfSection();
1269  [[fallthrough]]; // call spell/grammar dialog
1270  }
1272  {
1273  SfxViewFrame* pViewFrame = GetViewFrame();
1274  if (rReq.GetArgs() != nullptr)
1276  static_cast<const SfxBoolItem&>( (rReq.GetArgs()->
1277  Get(FN_SPELL_GRAMMAR_DIALOG))).GetValue());
1278  else
1280 
1282  rReq.Ignore ();
1283  }
1284  break;
1285  case SID_ALIGN_ANY_LEFT :
1286  case SID_ALIGN_ANY_HCENTER :
1287  case SID_ALIGN_ANY_RIGHT :
1288  case SID_ALIGN_ANY_JUSTIFIED:
1289  case SID_ALIGN_ANY_TOP :
1290  case SID_ALIGN_ANY_VCENTER :
1291  case SID_ALIGN_ANY_BOTTOM :
1292  case SID_ALIGN_ANY_HDEFAULT :
1293  case SID_ALIGN_ANY_VDEFAULT :
1294  {
1295  sal_uInt16 nAlias = 0;
1296  if( m_nSelectionType & (SelectionType::DrawObjectEditMode|SelectionType::Text) )
1297  {
1298  switch( nSlot )
1299  {
1300  case SID_ALIGN_ANY_LEFT : nAlias = SID_ATTR_PARA_ADJUST_LEFT; break;
1301  case SID_ALIGN_ANY_HCENTER : nAlias = SID_ATTR_PARA_ADJUST_CENTER; break;
1302  case SID_ALIGN_ANY_RIGHT : nAlias = SID_ATTR_PARA_ADJUST_RIGHT; break;
1303  case SID_ALIGN_ANY_JUSTIFIED: nAlias = SID_ATTR_PARA_ADJUST_BLOCK; break;
1304  case SID_ALIGN_ANY_TOP : nAlias = SID_TABLE_VERT_NONE; break;
1305  case SID_ALIGN_ANY_VCENTER : nAlias = SID_TABLE_VERT_CENTER; break;
1306  case SID_ALIGN_ANY_BOTTOM : nAlias = SID_TABLE_VERT_BOTTOM; break;
1307  }
1308  }
1309  else
1310  {
1311  switch( nSlot )
1312  {
1313  case SID_ALIGN_ANY_LEFT : nAlias = SID_OBJECT_ALIGN_LEFT ; break;
1314  case SID_ALIGN_ANY_HCENTER : nAlias = SID_OBJECT_ALIGN_CENTER ; break;
1315  case SID_ALIGN_ANY_RIGHT : nAlias = SID_OBJECT_ALIGN_RIGHT ; break;
1316  case SID_ALIGN_ANY_TOP : nAlias = SID_OBJECT_ALIGN_UP ; break;
1317  case SID_ALIGN_ANY_VCENTER : nAlias = SID_OBJECT_ALIGN_MIDDLE ; break;
1318  case SID_ALIGN_ANY_BOTTOM : nAlias = SID_OBJECT_ALIGN_DOWN ; break;
1319  }
1320  }
1321  //these slots are either re-mapped to text or object alignment
1322  if (nAlias)
1323  GetViewFrame()->GetDispatcher()->Execute(
1324  nAlias, SfxCallMode::ASYNCHRON);
1325  }
1326  break;
1327  case SID_RESTORE_EDITING_VIEW:
1328  {
1329  //#i33307# restore editing position
1330  Point aCursorPos;
1331  bool bSelectObj;
1332  if(m_pViewImpl->GetRestorePosition(aCursorPos, bSelectObj))
1333  {
1334  m_pWrtShell->SwCursorShell::SetCursor( aCursorPos, !bSelectObj );
1335  if( bSelectObj )
1336  {
1337  m_pWrtShell->SelectObj( aCursorPos );
1338  m_pWrtShell->EnterSelFrameMode( &aCursorPos );
1339  }
1340  }
1341  }
1342  break;
1343  case SID_INSERT_GRAPHIC:
1344  {
1345  rReq.SetReturnValue(SfxBoolItem(nSlot, InsertGraphicDlg( rReq )));
1346  }
1347  break;
1348 
1349  default:
1350  OSL_ENSURE(false, "wrong dispatcher");
1351  return;
1352  }
1353  if(!bIgnore)
1354  rReq.Done();
1355 }
1356 
1358 {
1359  sal_uInt16 nId = rReq.GetSlot();
1360  bool bRet = false;
1361 
1363  {
1365  bRet = true;
1366  }
1367  return bRet || SfxShell::IsConditionalFastCall(rReq);
1368 
1369 }
1370 
1372 void SwView::UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString& rPgStr)
1373 {
1374  OUString sTemp(GetPageStr( nPhyNum, nVirtNum, rPgStr ));
1375  const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
1376  // Used to distinguish which tooltip to show
1377  const SfxBoolItem bExtendedTooltip( FN_STAT_PAGE,
1378  !rPgStr.isEmpty()
1379  && std::u16string_view(OUString::number(nPhyNum)) != rPgStr
1380  && nPhyNum != nVirtNum );
1381 
1382  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1383  rBnd.SetState( aTmp );
1384  rBnd.Update( FN_STAT_PAGE );
1385  rBnd.SetState( bExtendedTooltip );
1386  rBnd.Update( FN_STAT_PAGE );
1387 }
1388 
1390 {
1391  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1392  rBnd.Invalidate( FN_STAT_WORDCOUNT );
1393  rBnd.Update( FN_STAT_WORDCOUNT );
1394 }
1395 
1398 {
1399  SwWrtShell& rShell = GetWrtShell();
1400 
1401  SfxWhichIter aIter( rSet );
1402  sal_uInt16 nWhich = aIter.FirstWhich();
1403  OSL_ENSURE( nWhich, "empty set");
1404 
1405  //get section change event
1406  const SwSection* CurrSect = rShell.GetCurrSection();
1407  if( CurrSect )
1408  {
1409  const OUString& sCurrentSectionName = CurrSect->GetSectionName();
1410  if(sCurrentSectionName != m_sOldSectionName)
1411  {
1413  }
1414  m_sOldSectionName = sCurrentSectionName;
1415  }
1416  else if (!m_sOldSectionName.isEmpty())
1417  {
1419  m_sOldSectionName= OUString();
1420  }
1421  //get column change event
1422  if(rShell.bColumnChange())
1423  {
1425  }
1426 
1427  while( nWhich )
1428  {
1429  switch( nWhich )
1430  {
1431  case FN_STAT_PAGE: {
1432  // number of pages, log. page number
1433  sal_uInt16 nPage, nLogPage;
1434  OUString sDisplay;
1435  rShell.GetPageNumber( -1, rShell.IsCursorVisible(), nPage, nLogPage, sDisplay );
1436  OUString sTemp( GetPageStr( nPage, nLogPage, sDisplay ) );
1437  const SfxStringItem aTmp( FN_STAT_PAGE, sTemp );
1438  GetViewFrame()->GetBindings().SetState( aTmp );
1439  // Used to distinguish which tooltip to show
1440  const SfxBoolItem bExtendedTooltip( FN_STAT_PAGE, !sDisplay.isEmpty() &&
1441  std::u16string_view(OUString::number( nPage ))
1442  != sDisplay &&
1443  nPage != nLogPage );
1444  GetViewFrame()->GetBindings().SetState( bExtendedTooltip );
1445  //if existing page number is not equal to old page number, send out this event.
1446  if (m_nOldPageNum != nLogPage )
1447  {
1448  if (m_nOldPageNum != 0)
1449  SwCursorShell::FirePageChangeEvent(m_nOldPageNum, nLogPage);
1450  m_nOldPageNum = nLogPage;
1451  }
1452  const sal_uInt16 nCnt = GetWrtShell().GetPageCnt();
1453  if (m_nPageCnt != nCnt) // notify Basic
1454  {
1455  m_nPageCnt = nCnt;
1456  SfxGetpApp()->NotifyEvent(SfxEventHint(SfxEventHintId::SwEventPageCount, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), false);
1457  }
1458  }
1459  break;
1460 
1461  case FN_STAT_WORDCOUNT:
1462  {
1463  SwDocStat selectionStats;
1464  SwDocStat documentStats;
1465  rShell.CountWords(selectionStats);
1466  documentStats = rShell.GetDoc()->getIDocumentStatistics().GetUpdatedDocStat( true /* complete-async */, false /* don't update fields */ );
1467 
1468  sal_uLong nWord = selectionStats.nWord ? selectionStats.nWord : documentStats.nWord;
1469  sal_uLong nChar = selectionStats.nChar ? selectionStats.nChar : documentStats.nChar;
1470  const char* pResId = selectionStats.nWord ? STR_WORDCOUNT : STR_WORDCOUNT_NO_SELECTION;
1471  const char* pWordResId = selectionStats.nWord ? STR_WORDCOUNT_WORDARG : STR_WORDCOUNT_WORDARG_NO_SELECTION;
1472  const char* pCharResId = selectionStats.nWord ? STR_WORDCOUNT_CHARARG : STR_WORDCOUNT_CHARARG_NO_SELECTION;
1473 
1475  OUString aWordArg = SwResId(pWordResId, nWord).replaceAll("$1", rLocaleData.getNum(nWord, 0));
1476  OUString aCharArg = SwResId(pCharResId, nChar).replaceAll("$1", rLocaleData.getNum(nChar, 0));
1477  OUString aWordCount(SwResId(pResId));
1478  aWordCount = aWordCount.replaceAll("$1", aWordArg);
1479  aWordCount = aWordCount.replaceAll("$2", aCharArg);
1480 
1481  rSet.Put( SfxStringItem( FN_STAT_WORDCOUNT, aWordCount ) );
1482 
1483  SwWordCountWrapper *pWrdCnt = static_cast<SwWordCountWrapper*>(GetViewFrame()->GetChildWindow(SwWordCountWrapper::GetChildWindowId()));
1484  if (pWrdCnt)
1485  pWrdCnt->SetCounts(selectionStats, documentStats);
1486  }
1487  break;
1488 
1489  case FN_STAT_TEMPLATE:
1490  {
1492  rShell.GetCurPageStyle()));
1493 
1494  }
1495  break;
1496  case SID_ATTR_ZOOM:
1497  {
1498  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1499  {
1500  const SwViewOption* pVOpt = rShell.GetViewOptions();
1501  SvxZoomType eZoom = pVOpt->GetZoomType();
1502  SvxZoomItem aZoom(eZoom,
1503  pVOpt->GetZoom());
1504  if( pVOpt->getBrowseMode() )
1505  {
1506  aZoom.SetValueSet(
1507  SvxZoomEnableFlags::N50|
1508  SvxZoomEnableFlags::N75|
1509  SvxZoomEnableFlags::N100|
1510  SvxZoomEnableFlags::N150|
1511  SvxZoomEnableFlags::N200);
1512  }
1513  rSet.Put( aZoom );
1514  }
1515  else
1516  rSet.DisableItem( SID_ATTR_ZOOM );
1517  }
1518  break;
1519  case SID_ATTR_VIEWLAYOUT:
1520  {
1521  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1522  {
1523  const SwViewOption* pVOpt = rShell.GetViewOptions();
1524  const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1525  const bool bBookMode = pVOpt->IsViewLayoutBookMode();
1526  SvxViewLayoutItem aViewLayout(nColumns, bBookMode);
1527  rSet.Put( aViewLayout );
1528  }
1529  else
1530  rSet.DisableItem( SID_ATTR_VIEWLAYOUT );
1531  }
1532  break;
1533  case SID_ATTR_ZOOMSLIDER:
1534  {
1535  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1536  {
1537  const SwViewOption* pVOpt = rShell.GetViewOptions();
1538  const sal_uInt16 nCurrentZoom = pVOpt->GetZoom();
1539  SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM );
1540  aZoomSliderItem.AddSnappingPoint( 100 );
1541 
1542  if ( !m_pWrtShell->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE) )
1543  {
1544  const sal_uInt16 nColumns = pVOpt->GetViewLayoutColumns();
1545  const bool bAutomaticViewLayout = 0 == nColumns;
1546  const SwPostItMgr* pMgr = GetPostItMgr();
1547 
1548  // snapping points:
1549  // automatic mode: 1 Page, 2 Pages, 100%
1550  // n Columns mode: n Pages, 100%
1551  // n Columns book mode: nPages without gaps, 100%
1552  const SwRect aPageRect( m_pWrtShell->GetAnyCurRect( CurRectType::PageCalc ) );
1553  const SwRect aRootRect( m_pWrtShell->GetAnyCurRect( CurRectType::PagesArea ) ); // width of columns
1554  Size aPageSize( aPageRect.SSize() );
1555  aPageSize.AdjustWidth(pMgr->HasNotes() && pMgr->ShowNotes() ?
1556  pMgr->GetSidebarWidth() + pMgr->GetSidebarBorderWidth() :
1557  0 );
1558 
1559  Size aRootSize( aRootRect.SSize() );
1560 
1561  const MapMode aTmpMap( MapUnit::MapTwip );
1562  const Size& rEditSize = GetEditWin().GetOutputSizePixel();
1563  const Size aWindowSize( GetEditWin().PixelToLogic( rEditSize, aTmpMap ) );
1564 
1565  const tools::Long nOf = pVOpt->GetDocumentBorder() * 2;
1566  tools::Long nTmpWidth = bAutomaticViewLayout ? aPageSize.Width() : aRootSize.Width();
1567  nTmpWidth += nOf;
1568  aPageSize.AdjustHeight(nOf );
1569  tools::Long nFac = aWindowSize.Width() * 100 / nTmpWidth;
1570 
1571  tools::Long nVisPercent = aWindowSize.Height() * 100 / aPageSize.Height();
1572  nFac = std::min( nFac, nVisPercent );
1573 
1574  if (nFac >= MINZOOM)
1575  {
1576  aZoomSliderItem.AddSnappingPoint( nFac );
1577  }
1578 
1579  if ( bAutomaticViewLayout )
1580  {
1581  nTmpWidth += aPageSize.Width() + pVOpt->GetGapBetweenPages();
1582  nFac = aWindowSize.Width() * 100 / nTmpWidth;
1583  nFac = std::min( nFac, nVisPercent );
1584  if (nFac >= MINZOOM)
1585  {
1586  aZoomSliderItem.AddSnappingPoint( nFac );
1587  }
1588  }
1589  }
1590 
1591  rSet.Put( aZoomSliderItem );
1592  }
1593  else
1594  rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1595  }
1596  break;
1597  case SID_ATTR_POSITION:
1598  case SID_ATTR_SIZE:
1599  {
1600  if( !rShell.IsFrameSelected() && !rShell.IsObjSelected() )
1602  else
1603  {
1604  FlyMode eFrameMode = SwBaseShell::GetFrameMode();
1605  if ( eFrameMode == FLY_DRAG_START || eFrameMode == FLY_DRAG )
1606  {
1607  if ( nWhich == SID_ATTR_POSITION )
1608  rSet.Put( SfxPointItem( SID_ATTR_POSITION,
1609  rShell.GetAnchorObjDiff()));
1610  else
1611  rSet.Put( SvxSizeItem( SID_ATTR_SIZE,
1612  rShell.GetObjSize()));
1613  }
1614  }
1615  }
1616  break;
1617  case SID_TABLE_CELL:
1618 
1619  if( rShell.IsFrameSelected() || rShell.IsObjSelected() )
1620  {
1621  // #i39171# Don't put a SvxSizeItem into a slot which is defined as SfxStringItem.
1622  // SvxPosSizeStatusBarControl no longer resets to empty display if only one slot
1623  // has no item, so SID_TABLE_CELL can remain empty (the SvxSizeItem is supplied
1624  // in SID_ATTR_SIZE).
1625  }
1626  else
1627  {
1628  OUString sStr;
1629  if( rShell.IsCursorInTable() )
1630  {
1631  // table name + cell coordinate
1632  sStr = rShell.GetTableFormat()->GetName() + ":";
1633  sStr += rShell.GetBoxNms();
1634  }
1635  else
1636  {
1637  const SwSection* pCurrSect = rShell.GetCurrSection();
1638  if( pCurrSect )
1639  {
1640  switch( pCurrSect->GetType() )
1641  {
1644  {
1645  const SwTOXBase* pTOX = m_pWrtShell->GetCurTOX();
1646  if( pTOX )
1647  sStr = pTOX->GetTOXName();
1648  else
1649  {
1650  OSL_ENSURE( false,
1651  "Unknown kind of section" );
1652  sStr = pCurrSect->GetSectionName();
1653  }
1654  }
1655  break;
1656  default:
1657  sStr = pCurrSect->GetSectionName();
1658  break;
1659  }
1660  }
1661  }
1662 
1663  const SwNumRule* pNumRule = rShell.GetNumRuleAtCurrCursorPos();
1664  const bool bOutlineNum = pNumRule && pNumRule->IsOutlineRule();
1665 
1666  if (pNumRule && !bOutlineNum ) // cursor in numbering
1667  {
1668  sal_uInt8 nNumLevel = rShell.GetNumLevel();
1669  if ( nNumLevel < MAXLEVEL )
1670  {
1671  if(!pNumRule->IsAutoRule())
1672  {
1673  SfxItemSet aSet(GetPool(),
1675  rShell.GetCurAttr(aSet);
1676  if(SfxItemState::DEFAULT <=
1677  aSet.GetItemState(RES_PARATR_NUMRULE))
1678  {
1679  const OUString& rNumStyle =
1680  aSet.Get(RES_PARATR_NUMRULE).GetValue();
1681  if(!rNumStyle.isEmpty())
1682  {
1683  if(!sStr.isEmpty())
1684  sStr += sStatusDelim;
1685  sStr += rNumStyle;
1686  }
1687  }
1688  }
1689  if (!sStr.isEmpty())
1690  sStr += sStatusDelim;
1691  sStr += SwResId(STR_NUM_LEVEL) + OUString::number( nNumLevel + 1 );
1692 
1693  }
1694  }
1695  const int nOutlineLevel = rShell.GetCurrentParaOutlineLevel();
1696  if( nOutlineLevel != 0 )
1697  {
1698  if (!sStr.isEmpty())
1699  sStr += " , ";
1700  if( bOutlineNum )
1701  {
1702  sStr += SwResId(STR_OUTLINE_NUMBERING) +
1703  sStatusDelim + SwResId(STR_NUM_LEVEL);
1704  }
1705  else
1706  sStr += SwResId(STR_NUM_OUTLINE);
1707  sStr += OUString::number( nOutlineLevel);
1708  }
1709 
1710  if( rShell.HasReadonlySel() )
1711  {
1712  if (!sStr.isEmpty())
1713  sStr = sStatusDelim + sStr;
1714  sStr = SwResId(SW_STR_READONLY) + sStr;
1715  }
1716  if (!sStr.isEmpty())
1717  rSet.Put( SfxStringItem( SID_TABLE_CELL, sStr ));
1718  }
1719  break;
1720  case FN_STAT_SELMODE:
1721  {
1722  if(rShell.IsStdMode())
1723  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 0));
1724  else if(rShell.IsAddMode())
1725  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 2));
1726  else if(rShell.IsBlockMode())
1727  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 3));
1728  else
1729  rSet.Put(SfxUInt16Item(FN_STAT_SELMODE, 1));
1730  break;
1731  }
1732  case SID_ATTR_INSERT:
1733  if( rShell.IsRedlineOn() )
1734  rSet.DisableItem( nWhich );
1735  else
1736  {
1737  rSet.Put(SfxBoolItem(SID_ATTR_INSERT,rShell.IsInsMode()));
1738  }
1739  break;
1740  }
1741  nWhich = aIter.NextWhich();
1742  }
1743 }
1744 
1750 {
1751  SwWrtShell &rSh = GetWrtShell();
1752  const SfxItemSet* pArgs = rReq.GetArgs();
1753  const SfxPoolItem* pItem=nullptr;
1754  bool bUp = false;
1755  sal_uInt16 nWhich = rReq.GetSlot();
1756  switch( nWhich )
1757  {
1758  case FN_STAT_PAGE:
1759  {
1760  GetViewFrame()->GetDispatcher()->Execute( FN_GOTO_PAGE,
1761  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1762  }
1763  break;
1764 
1765  case FN_STAT_WORDCOUNT:
1766  {
1767  GetViewFrame()->GetDispatcher()->Execute(FN_WORDCOUNT_DIALOG,
1768  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1769  }
1770  break;
1771 
1772  case FN_STAT_BOOKMARK:
1773  if ( pArgs )
1774  {
1775  if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
1776  {
1777  const IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
1778  const sal_Int32 nIdx = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1779  if(nIdx < pMarkAccess->getBookmarksCount())
1780  {
1782  rSh.EnterStdMode();
1783  rSh.GotoMark( *ppBookmark );
1784  }
1785  else
1786  OSL_FAIL("SwView::ExecuteStatusLine(..)"
1787  " - Ignoring out of range bookmark index");
1788  }
1789  }
1790  break;
1791 
1792  case FN_STAT_TEMPLATE:
1793  {
1794  GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_PAGE_DLG,
1795  SfxCallMode::SYNCHRON|SfxCallMode::RECORD );
1796  }
1797  break;
1798  case SID_ATTR_ZOOM:
1799  {
1800  if ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() )
1801  {
1802  const SfxItemSet *pSet = nullptr;
1804  if ( pArgs )
1805  pSet = pArgs;
1806  else
1807  {
1808  const SwViewOption& rViewOptions = *rSh.GetViewOptions();
1810  SvxZoomItem aZoom( rViewOptions.GetZoomType(), rViewOptions.GetZoom() );
1811 
1812  const bool bBrowseMode = rSh.GetViewOptions()->getBrowseMode();
1813  if( bBrowseMode )
1814  {
1815  aZoom.SetValueSet(
1816  SvxZoomEnableFlags::N50|
1817  SvxZoomEnableFlags::N75|
1818  SvxZoomEnableFlags::N100|
1819  SvxZoomEnableFlags::N150|
1820  SvxZoomEnableFlags::N200);
1821  }
1822  aCoreSet.Put( aZoom );
1823 
1824  if ( !bBrowseMode )
1825  {
1826  const SvxViewLayoutItem aViewLayout( rViewOptions.GetViewLayoutColumns(), rViewOptions.IsViewLayoutBookMode() );
1827  aCoreSet.Put( aViewLayout );
1828  }
1829 
1831  pDlg.disposeAndReset(pFact->CreateSvxZoomDialog(GetViewFrame()->GetWindow().GetFrameWeld(), aCoreSet));
1832  pDlg->SetLimits( MINZOOM, MAXZOOM );
1833  if( pDlg->Execute() != RET_CANCEL )
1834  pSet = pDlg->GetOutputItemSet();
1835  }
1836 
1837  const SfxPoolItem* pViewLayoutItem = nullptr;
1838  if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pViewLayoutItem))
1839  {
1840  const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->GetValue();
1841  const bool bBookMode = static_cast<const SvxViewLayoutItem *>(pViewLayoutItem)->IsBookMode();
1842  SetViewLayout( nColumns, bBookMode );
1843  }
1844 
1845  if ( pSet && SfxItemState::SET == pSet->GetItemState(SID_ATTR_ZOOM, true, &pItem))
1846  {
1847  SvxZoomType eType = static_cast<const SvxZoomItem *>(pItem)->GetType();
1848  SetZoom( eType, static_cast<const SvxZoomItem *>(pItem)->GetValue() );
1849  }
1850  bUp = true;
1851  if ( pItem )
1852  rReq.AppendItem( *pItem );
1853  rReq.Done();
1854  }
1855  }
1856  break;
1857 
1858  case SID_ATTR_VIEWLAYOUT:
1859  {
1861  ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1862  {
1863  if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_VIEWLAYOUT, true, &pItem ))
1864  {
1865  const sal_uInt16 nColumns = static_cast<const SvxViewLayoutItem *>(pItem)->GetValue();
1866  const bool bBookMode = (0 != nColumns && 0 == (nColumns % 2)) &&
1867  static_cast<const SvxViewLayoutItem *>(pItem)->IsBookMode();
1868 
1869  SetViewLayout( nColumns, bBookMode );
1870  }
1871 
1872  bUp = true;
1873  rReq.Done();
1874 
1875  InvalidateRulerPos();
1876  }
1877  }
1878  break;
1879 
1880  case SID_ATTR_ZOOMSLIDER:
1881  {
1882  if ( pArgs && ( ( GetDocShell()->GetCreateMode() != SfxObjectCreateMode::EMBEDDED ) || !GetDocShell()->IsInPlaceActive() ) )
1883  {
1884  if ( SfxItemState::SET == pArgs->GetItemState(SID_ATTR_ZOOMSLIDER, true, &pItem ))
1885  {
1886  const sal_uInt16 nCurrentZoom = static_cast<const SvxZoomSliderItem *>(pItem)->GetValue();
1887  SetZoom( SvxZoomType::PERCENT, nCurrentZoom );
1888  }
1889 
1890  bUp = true;
1891  rReq.Done();
1892  }
1893  }
1894  break;
1895 
1896  case SID_ATTR_SIZE:
1897  {
1898  sal_uInt16 nId = 0;
1899  if( rSh.IsCursorInTable() )
1900  nId = FN_FORMAT_TABLE_DLG;
1901  else if( rSh.GetCurTOX() )
1902  nId = FN_INSERT_MULTI_TOX;
1903  else if( rSh.GetCurrSection() )
1904  nId = FN_EDIT_REGION;
1905  else
1906  {
1907  const SwNumRule* pNumRule = rSh.GetNumRuleAtCurrCursorPos();
1908  if( pNumRule ) // cursor in numbering
1909  {
1910  if( pNumRule->IsAutoRule() )
1911  nId = FN_NUMBER_BULLETS;
1912  else
1913  {
1914  // start dialog of the painter
1915  nId = 0;
1916  }
1917  }
1918  else if( rSh.IsFrameSelected() )
1919  nId = FN_FORMAT_FRAME_DLG;
1920  else if( rSh.IsObjSelected() )
1921  nId = SID_ATTR_TRANSFORM;
1922  }
1923  if( nId )
1924  GetViewFrame()->GetDispatcher()->Execute(nId,
1925  SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
1926  }
1927  break;
1928 
1929  case FN_STAT_SELMODE:
1930  {
1931  if ( pArgs )
1932  {
1933  if (SfxItemState::SET == pArgs->GetItemState( nWhich, true, &pItem))
1934  {
1935  switch ( static_cast<const SfxUInt16Item *>(pItem)->GetValue() )
1936  {
1937  case 0: rSh.EnterStdMode(); break;
1938  case 1: rSh.EnterExtMode(); break;
1939  case 2: rSh.EnterAddMode(); break;
1940  case 3: rSh.EnterBlockMode(); break;
1941  }
1942  }
1943  }
1944  else
1945  {
1946 
1947  if( !rSh.IsAddMode() && !rSh.IsExtMode() && !rSh.IsBlockMode() )
1948  rSh.ToggleExtMode();
1949  else if ( rSh.IsExtMode() )
1950  {
1951  rSh.ToggleExtMode();
1952  rSh.ToggleAddMode();
1953  }
1954  else if ( rSh.IsAddMode() )
1955  {
1956  rSh.ToggleAddMode();
1957  rSh.ToggleBlockMode();
1958  }
1959  else
1960  rSh.ToggleBlockMode();
1961  }
1962  bUp = true;
1963  break;
1964  }
1965  case FN_SET_ADD_MODE:
1966  rSh.ToggleAddMode();
1967  nWhich = FN_STAT_SELMODE;
1968  bUp = true;
1969  break;
1970  case FN_SET_BLOCK_MODE:
1971  rSh.ToggleBlockMode();
1972  nWhich = FN_STAT_SELMODE;
1973  bUp = true;
1974  break;
1975  case FN_SET_EXT_MODE:
1976  rSh.ToggleExtMode();
1977  nWhich = FN_STAT_SELMODE;
1978  bUp = true;
1979  break;
1980  case SID_ATTR_INSERT:
1981  SwPostItMgr* pMgr = GetPostItMgr();
1982  if ( pMgr && pMgr->HasActiveSidebarWin() )
1983  {
1985  }
1986  else
1987  rSh.ToggleInsMode();
1988  bUp = true;
1989  break;
1990 
1991  }
1992  if ( bUp )
1993  {
1994  SfxBindings &rBnd = GetViewFrame()->GetBindings();
1995  rBnd.Invalidate(nWhich);
1996  rBnd.Update(nWhich);
1997  }
1998 }
1999 
2000 void SwView::InsFrameMode(sal_uInt16 nCols)
2001 {
2002  if ( m_pWrtShell->HasWholeTabSelection() )
2003  {
2004  SwFlyFrameAttrMgr aMgr( true, m_pWrtShell.get(), Frmmgr_Type::TEXT, nullptr );
2005 
2006  const SwFrameFormat &rPageFormat =
2007  m_pWrtShell->GetPageDesc(m_pWrtShell->GetCurPageDesc()).GetMaster();
2008  SwTwips lWidth = rPageFormat.GetFrameSize().GetWidth();
2009  const SvxLRSpaceItem &rLR = rPageFormat.GetLRSpace();
2010  lWidth -= rLR.GetLeft() + rLR.GetRight();
2011  aMgr.SetSize(Size(lWidth, aMgr.GetSize().Height()));
2012  if(nCols > 1)
2013  {
2014  SwFormatCol aCol;
2015  aCol.Init( nCols, aCol.GetGutterWidth(), aCol.GetWishWidth() );
2016  aMgr.SetCol( aCol );
2017  }
2018  aMgr.InsertFlyFrame();
2019  }
2020  else
2021  GetEditWin().InsFrame(nCols);
2022 }
2023 
2026 {
2027  bool bWeb = dynamic_cast<SwWebView*>( this ) != nullptr;
2029  ScopedVclPtr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog(GetViewFrame()->GetWindow().GetFrameWeld(), &GetWrtShell().GetLinkManager(), bWeb));
2030  pDlg->Execute();
2031 }
2032 
2033 bool SwView::JumpToSwMark( const OUString& rMark )
2034 {
2035  bool bRet = false;
2036  if( !rMark.isEmpty() )
2037  {
2038  // place bookmark at top-center
2039  bool bSaveCC = m_bCenterCursor;
2040  bool bSaveCT = m_bTopCursor;
2041  SetCursorAtTop( true );
2042 
2043  // For scrolling the FrameSet, the corresponding shell needs to have the focus.
2044  bool bHasShFocus = m_pWrtShell->HasShellFocus();
2045  if( !bHasShFocus )
2046  m_pWrtShell->ShellGetFocus();
2047 
2048  const SwFormatINetFormat* pINet;
2049  OUString sCmp;
2050  OUString sMark( INetURLObject::decode( rMark,
2052 
2053  sal_Int32 nLastPos, nPos = sMark.indexOf( cMarkSeparator );
2054  if( -1 != nPos )
2055  while( -1 != ( nLastPos = sMark.indexOf( cMarkSeparator, nPos + 1 )) )
2056  nPos = nLastPos;
2057 
2059  IDocumentMarkAccess* const pMarkAccess = m_pWrtShell->getIDocumentMarkAccess();
2060  if( -1 != nPos )
2061  sCmp = sMark.copy(nPos + 1).replaceAll(" ", "");
2062 
2063  if( !sCmp.isEmpty() )
2064  {
2065  OUString sName( sMark.copy( 0, nPos ) );
2066  sCmp = sCmp.toAsciiLowerCase();
2067  FlyCntType eFlyType = FLYCNTTYPE_ALL;
2068 
2069  if( sCmp == "region" )
2070  {
2071  m_pWrtShell->EnterStdMode();
2072  bRet = m_pWrtShell->GotoRegion( sName );
2073  }
2074  else if( sCmp == "outline" )
2075  {
2076  m_pWrtShell->EnterStdMode();
2077  bRet = m_pWrtShell->GotoOutline( sName );
2078  }
2079  else if( sCmp == "frame" )
2080  eFlyType = FLYCNTTYPE_FRM;
2081  else if( sCmp == "graphic" )
2082  eFlyType = FLYCNTTYPE_GRF;
2083  else if( sCmp == "ole" )
2084  eFlyType = FLYCNTTYPE_OLE;
2085  else if( sCmp == "table" )
2086  {
2087  m_pWrtShell->EnterStdMode();
2088  bRet = m_pWrtShell->GotoTable( sName );
2089  }
2090  else if( sCmp == "sequence" )
2091  {
2092  m_pWrtShell->EnterStdMode();
2093  sal_Int32 nNoPos = sName.indexOf( cSequenceMarkSeparator );
2094  if ( nNoPos != -1 )
2095  {
2096  sal_uInt16 nSeqNo = sName.copy( nNoPos + 1 ).toInt32();
2097  sName = sName.copy( 0, nNoPos );
2098  bRet = m_pWrtShell->GotoRefMark(sName, REF_SEQUENCEFLD, nSeqNo);
2099  }
2100  }
2101  else if( sCmp == "text" )
2102  {
2103  // normal text search
2104  m_pWrtShell->EnterStdMode();
2105 
2106  i18nutil::SearchOptions2 aSearchOpt(
2107  SearchAlgorithms_ABSOLUTE, 0,
2108  sName, OUString(),
2109  SvtSysLocale().GetLanguageTag().getLocale(),
2110  0,0,0,
2111  TransliterationFlags::IGNORE_CASE,
2112  SearchAlgorithms2::ABSOLUTE,
2113  '\\' );
2114 
2115  //todo/mba: assuming that notes shouldn't be searched
2116  if( m_pWrtShell->SearchPattern( aSearchOpt, false/*bSearchInNotes*/, SwDocPositions::Start, SwDocPositions::End ))
2117  {
2118  m_pWrtShell->EnterStdMode(); // remove the selection
2119  bRet = true;
2120  }
2121  }
2122  else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)) )
2123  {
2124  bRet = m_pWrtShell->GotoMark( *ppMark, false );
2125  }
2126  else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) )) {
2127  m_pWrtShell->addCurrentPosition();
2128  bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
2129  }
2130 
2131  // for all types of Flys
2132  if( FLYCNTTYPE_ALL != eFlyType && m_pWrtShell->GotoFly( sName, eFlyType ))
2133  {
2134  bRet = true;
2135  if( FLYCNTTYPE_FRM == eFlyType )
2136  {
2137  // TextFrames: set Cursor in the frame
2138  m_pWrtShell->UnSelectFrame();
2139  m_pWrtShell->LeaveSelFrameMode();
2140  }
2141  else
2142  {
2143  m_pWrtShell->HideCursor();
2144  m_pWrtShell->EnterSelFrameMode();
2145  }
2146  }
2147  }
2148  else if( pMarkAccess->getAllMarksEnd() != (ppMark = pMarkAccess->findMark(sMark)))
2149  {
2150  bRet = m_pWrtShell->GotoMark( *ppMark, false );
2151  }
2152  else if( nullptr != ( pINet = m_pWrtShell->FindINetAttr( sMark ) ))
2153  bRet = m_pWrtShell->GotoINetAttr( *pINet->GetTextINetFormat() );
2154 
2155  // make selection visible later
2156  if ( m_aVisArea.IsEmpty() )
2157  m_bMakeSelectionVisible = true;
2158 
2159  // reset ViewStatus
2160  SetCursorAtTop( bSaveCT, bSaveCC );
2161 
2162  if( !bHasShFocus )
2163  m_pWrtShell->ShellLoseFocus();
2164  }
2165  return bRet;
2166 }
2167 
2168 // #i67305# Undo after insert from file:
2169 // Undo "Insert form file" crashes with documents imported from binary filter (.sdw) => disabled
2170 // Undo "Insert form file" crashes with (.odt) documents crashes if these documents contains
2171 // page styles with active header/footer => disabled for those documents
2172 static size_t lcl_PageDescWithHeader( const SwDoc& rDoc )
2173 {
2174  size_t nRet = 0;
2175  size_t nCnt = rDoc.GetPageDescCnt();
2176  for( size_t i = 0; i < nCnt; ++i )
2177  {
2178  const SwPageDesc& rPageDesc = rDoc.GetPageDesc( i );
2179  const SwFrameFormat& rMaster = rPageDesc.GetMaster();
2180  const SfxPoolItem* pItem;
2181  if( ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_HEADER, false, &pItem ) &&
2182  static_cast<const SwFormatHeader*>(pItem)->IsActive() ) ||
2183  ( SfxItemState::SET == rMaster.GetAttrSet().GetItemState( RES_FOOTER, false, &pItem ) &&
2184  static_cast<const SwFormatFooter*>(pItem)->IsActive()) )
2185  ++nRet;
2186  }
2187  return nRet; // number of page styles with active header/footer
2188 }
2189 
2190 void SwView::ExecuteInsertDoc( SfxRequest& rRequest, const SfxPoolItem* pItem )
2191 {
2192  m_pViewImpl->InitRequest( rRequest );
2193  m_pViewImpl->SetParam( pItem ? 1 : 0 );
2194  const sal_uInt16 nSlot = rRequest.GetSlot();
2195 
2196  if ( !pItem )
2197  {
2198  InsertDoc( nSlot, "", "" );
2199  }
2200  else
2201  {
2202  OUString sFile, sFilter;
2203  sFile = static_cast<const SfxStringItem *>( pItem )->GetValue();
2204  if ( SfxItemState::SET == rRequest.GetArgs()->GetItemState( FN_PARAM_1, true, &pItem ) )
2205  sFilter = static_cast<const SfxStringItem *>(pItem )->GetValue();
2206 
2207  bool bHasFileName = !sFile.isEmpty();
2208  tools::Long nFound = InsertDoc( nSlot, sFile, sFilter );
2209 
2210  if ( bHasFileName )
2211  {
2212  rRequest.SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2213  rRequest.Done();
2214  }
2215  }
2216 }
2217 
2218 tools::Long SwView::InsertDoc( sal_uInt16 nSlotId, const OUString& rFileName, const OUString& rFilterName, sal_Int16 nVersion )
2219 {
2220  std::unique_ptr<SfxMedium> pMed;
2221  SwDocShell* pDocSh = GetDocShell();
2222 
2223  if( !rFileName.isEmpty() )
2224  {
2225  SfxObjectFactory& rFact = pDocSh->GetFactory();
2226  std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( rFilterName );
2227  if ( !pFilter )
2228  {
2229  pMed.reset(new SfxMedium(rFileName, StreamMode::READ, nullptr, nullptr ));
2230  SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
2231  pMed->UseInteractionHandler( true );
2232  ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE);
2233  if ( nErr )
2234  pMed.reset();
2235  else
2236  pMed->SetFilter( pFilter );
2237  }
2238  else
2239  pMed.reset(new SfxMedium(rFileName, StreamMode::READ, pFilter, nullptr));
2240  }
2241  else
2242  {
2243  m_pViewImpl->StartDocumentInserter(
2244  // tdf#118578 allow inserting any Writer document except GlobalDoc
2245  SwDocShell::Factory().GetFactoryName(),
2246  LINK( this, SwView, DialogClosedHdl ),
2247  nSlotId
2248  );
2249  return -1;
2250  }
2251 
2252  if( !pMed )
2253  return -1;
2254 
2255  return InsertMedium( nSlotId, std::move(pMed), nVersion );
2256 }
2257 
2258 tools::Long SwView::InsertMedium( sal_uInt16 nSlotId, std::unique_ptr<SfxMedium> pMedium, sal_Int16 nVersion )
2259 {
2260  bool bInsert = false, bCompare = false;
2261  tools::Long nFound = 0;
2262  SwDocShell* pDocSh = GetDocShell();
2263 
2264  switch( nSlotId )
2265  {
2266  case SID_DOCUMENT_MERGE: break;
2267  case SID_DOCUMENT_COMPARE: bCompare = true; break;
2268  case SID_INSERTDOC: bInsert = true; break;
2269 
2270  default:
2271  OSL_ENSURE( false, "unknown SlotId!" );
2272  bInsert = true;
2273  break;
2274  }
2275 
2276  if( bInsert )
2277  {
2278  uno::Reference< frame::XDispatchRecorder > xRecorder =
2279  GetViewFrame()->GetBindings().GetRecorder();
2280  if ( xRecorder.is() )
2281  {
2282  SfxRequest aRequest(GetViewFrame(), SID_INSERTDOC);
2283  aRequest.AppendItem(SfxStringItem(SID_INSERTDOC, pMedium->GetOrigURL()));
2284  if(pMedium->GetFilter())
2285  aRequest.AppendItem(SfxStringItem(FN_PARAM_1, pMedium->GetFilter()->GetName()));
2286  aRequest.Done();
2287  }
2288 
2289  SfxObjectShellRef aRef( pDocSh );
2290 
2291  ErrCode nError = SfxObjectShell::HandleFilter( pMedium.get(), pDocSh );
2292  // #i16722# aborted?
2293  if(nError != ERRCODE_NONE)
2294  {
2295  return -1;
2296  }
2297 
2298  pMedium->Download(); // start download if needed
2299  if( aRef.is() && 1 < aRef->GetRefCount() ) // still a valid ref?
2300  {
2301  SwReaderPtr pRdr;
2302  Reader *pRead = pDocSh->StartConvertFrom(*pMedium, pRdr, m_pWrtShell.get());
2303  if( pRead ||
2304  (pMedium->GetFilter()->GetFilterFlags() & SfxFilterFlags::STARONEFILTER) )
2305  {
2306  size_t nUndoCheck = 0;
2307  SwDoc *pDoc = pDocSh->GetDoc();
2308  if( pRead && pDocSh->GetDoc() )
2309  nUndoCheck = lcl_PageDescWithHeader( *pDoc );
2310  ErrCode nErrno;
2311  { //Scope for SwWait-Object, to be able to execute slots
2312  //outside this scope.
2313  SwWait aWait( *GetDocShell(), true );
2314  m_pWrtShell->StartAllAction();
2315  if ( m_pWrtShell->HasSelection() )
2316  m_pWrtShell->DelRight(); // delete selections
2317  if( pRead )
2318  {
2319  nErrno = pRdr->Read( *pRead ); // and insert document
2320  pRdr.reset();
2321  }
2322  else
2323  {
2324  ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo());
2325  uno::Reference<text::XTextRange> const xInsertPosition(
2327  *m_pWrtShell->GetCursor()->GetPoint(), nullptr));
2328  nErrno = pDocSh->ImportFrom(*pMedium, xInsertPosition)
2330  }
2331 
2332  }
2333 
2334  // update all "table of ..." sections if needed
2335  if( m_pWrtShell->IsUpdateTOX() )
2336  {
2337  SfxRequest aReq( FN_UPDATE_TOX, SfxCallMode::SLOT, GetPool() );
2338  Execute( aReq );
2339  m_pWrtShell->SetUpdateTOX( false ); // reset
2340  }
2341 
2342  if( pDoc )
2343  { // Disable Undo for .sdw or
2344  // if the number of page styles with header/footer has changed
2345  if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) )
2346  {
2348  }
2349  }
2350 
2351  m_pWrtShell->EndAllAction();
2352  if( nErrno )
2353  {
2354  ErrorHandler::HandleError( nErrno );
2355  nFound = nErrno.IsError() ? -1 : 0;
2356  }
2357  else
2358  nFound = 0;
2359  }
2360  }
2361  }
2362  else
2363  {
2364  SfxObjectShellRef xDocSh;
2365  SfxObjectShellLock xLockRef;
2366 
2367  const int nRet = SwFindDocShell( xDocSh, xLockRef, pMedium->GetName(), OUString(),
2368  OUString(), nVersion, pDocSh );
2369  if( nRet )
2370  {
2371  SwWait aWait( *GetDocShell(), true );
2372  m_pWrtShell->StartAllAction();
2373 
2374  m_pWrtShell->EnterStdMode(); // delete selections
2375 
2376  if( bCompare )
2377  nFound = m_pWrtShell->CompareDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() );
2378  else
2379  nFound = m_pWrtShell->MergeDoc( *static_cast<SwDocShell*>( xDocSh.get() )->GetDoc() );
2380 
2381  m_pWrtShell->EndAllAction();
2382 
2383  if (!bCompare && !nFound)
2384  {
2385  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(),
2386  VclMessageType::Info, VclButtonsType::Ok,
2387  SwResId(STR_NO_MERGE_ENTRY)));
2388  xInfoBox->run();
2389  }
2390  if( nRet==2 && xDocSh.is() )
2391  xDocSh->DoClose();
2392  }
2393  }
2394 
2395  return nFound;
2396 }
2397 
2399 {
2400  m_bInMailMerge = true;
2401  SfxBindings& rBind = GetViewFrame()->GetBindings();
2404 }
2405 
2406 #if HAVE_FEATURE_DBCONNECTIVITY
2407 
2408 namespace
2409 {
2410  bool lcl_NeedAdditionalDataSource( const uno::Reference< XDatabaseContext >& _rDatasourceContext )
2411  {
2412  Sequence < OUString > aNames = _rDatasourceContext->getElementNames();
2413 
2414  return ( !aNames.hasElements()
2415  || ( ( 1 == aNames.getLength() )
2416  && aNames.getConstArray()[0] == SW_MOD()->GetDBConfig()->GetBibliographySource().sDataSource
2417  )
2418  );
2419  }
2420 }
2421 
2422 #endif
2423 
2424 void SwView::GenerateFormLetter(bool bUseCurrentDocument)
2425 {
2426 #if !HAVE_FEATURE_DBCONNECTIVITY
2427  (void) bUseCurrentDocument;
2428 #else
2429  if(bUseCurrentDocument)
2430  {
2431  if(!GetWrtShell().IsAnyDatabaseFieldInDoc())
2432  {
2433  //check availability of data sources (except biblio source)
2434  uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
2435  uno::Reference<XDatabaseContext> xDBContext = DatabaseContext::create(xContext);
2436  bool bCallAddressPilot = false;
2437  if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2438  {
2439  // no data sources are available - create a new one
2440  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/datasourcesunavailabledialog.ui"));
2441  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("DataSourcesUnavailableDialog"));
2442  // no cancel allowed
2443  if (RET_OK != xQuery->run())
2444  return;
2445  bCallAddressPilot = true;
2446  }
2447  else
2448  {
2449  //take an existing data source or create a new one?
2452  if(RET_OK == pConnectionsDlg->Execute())
2453  bCallAddressPilot = !pConnectionsDlg->IsUseExistingConnections();
2454  else
2455  return;
2456 
2457  }
2458  if(bCallAddressPilot)
2459  {
2460  GetViewFrame()->GetDispatcher()->Execute(
2461  SID_ADDRESS_DATA_SOURCE, SfxCallMode::SYNCHRON);
2462  if ( lcl_NeedAdditionalDataSource( xDBContext ) )
2463  // no additional data source has been created
2464  // -> assume that the user has cancelled the pilot
2465  return;
2466  }
2467 
2468  //call insert fields with database field page available, only
2469  SfxViewFrame* pVFrame = GetViewFrame();
2470  //at first hide the default field dialog if currently visible
2471  pVFrame->SetChildWindow(FN_INSERT_FIELD, false);
2472  //enable the status of the db field dialog - it is disabled in the status method
2473  //to prevent creation of the dialog without mail merge active
2474  EnableMailMerge();
2475  //then show the "Data base only" field dialog
2478  SfxCallMode::SYNCHRON, { &aOn });
2479  return;
2480  }
2481  else
2482  {
2483  OUString sSource;
2484  if(!GetWrtShell().IsFieldDataSourceAvailable(sSource))
2485  {
2486  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/warndatasourcedialog.ui"));
2487  std::unique_ptr<weld::MessageDialog> xWarning(xBuilder->weld_message_dialog("WarnDataSourceDialog"));
2488  OUString sTmp(xWarning->get_primary_text());
2489  xWarning->set_primary_text(sTmp.replaceFirst("%1", sSource));
2490  if (RET_OK == xWarning->run())
2491  {
2493  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( nullptr, SID_OPTIONS_DATABASES ));
2494  pDlg->Execute();
2495  }
2496  return ;
2497  }
2498  }
2499  SwDBManager* pDBManager = GetWrtShell().GetDBManager();
2500 
2501  SwDBData aData;
2502  SwWrtShell &rSh = GetWrtShell();
2503 
2504  std::vector<OUString> aDBNameList;
2505  std::vector<OUString> aAllDBNames;
2506  rSh.GetAllUsedDB( aDBNameList, &aAllDBNames );
2507  if(!aDBNameList.empty())
2508  {
2509  OUString sDBName(aDBNameList[0]);
2510  sal_Int32 nIdx {0};
2511  aData.sDataSource = sDBName.getToken(0, DB_DELIM, nIdx);
2512  aData.sCommand = sDBName.getToken(0, DB_DELIM, nIdx);
2513  aData.nCommandType = sDBName.getToken(0, DB_DELIM, nIdx).toInt32();
2514  }
2515  rSh.EnterStdMode(); // force change in text shell; necessary for mixing DB fields
2516  AttrChangedNotify(nullptr);
2517 
2518  if (pDBManager)
2519  {
2520  Sequence<PropertyValue> aProperties(3);
2521  PropertyValue* pValues = aProperties.getArray();
2522  pValues[0].Name = "DataSourceName";
2523  pValues[1].Name = "Command";
2524  pValues[2].Name = "CommandType";
2525  pValues[0].Value <<= aData.sDataSource;
2526  pValues[1].Value <<= aData.sCommand;
2527  pValues[2].Value <<= aData.nCommandType;
2528  pDBManager->ExecuteFormLetter(GetWrtShell(), aProperties);
2529  }
2530  }
2531  else
2532  {
2533  // call documents and template dialog
2534  SfxApplication* pSfxApp = SfxGetpApp();
2535  vcl::Window* pTopWin = pSfxApp->GetTopWindow();
2536 
2537  SfxTemplateManagerDlg aDocTemplDlg(GetFrameWeld());
2538  int nRet = aDocTemplDlg.run();
2539  bool bNewWin = false;
2540  if ( nRet == RET_OK )
2541  {
2542  if ( pTopWin != pSfxApp->GetTopWindow() )
2543  {
2544  // the dialogue opens a document -> a new TopWindow appears
2545  pTopWin = pSfxApp->GetTopWindow();
2546  bNewWin = true;
2547  }
2548  }
2549 
2550  if ( bNewWin )
2551  // after the destruction of the dialogue its parent comes to top,
2552  // but we want that the new document is on top
2553  pTopWin->ToTop();
2554  }
2555 #endif
2556 }
2557 
2558 IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
2559 {
2560  if ( ERRCODE_NONE != _pFileDlg->GetError() )
2561  return;
2562 
2563  std::unique_ptr<SfxMedium> pMed = m_pViewImpl->CreateMedium();
2564  if ( !pMed )
2565  {
2566  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetEditWin().GetFrameWeld(),
2567  VclMessageType::Info, VclButtonsType::Ok,
2568  SwResId(RID_SVXSTR_TXTFILTER_FILTERERROR)));
2569  xInfoBox->run();
2570  return;
2571  }
2572 
2573  const sal_uInt16 nSlot = m_pViewImpl->GetRequest()->GetSlot();
2574  tools::Long nFound = InsertMedium( nSlot, std::move(pMed), m_pViewImpl->GetParam() );
2575 
2576  if ( SID_INSERTDOC == nSlot )
2577  {
2578  if ( m_pViewImpl->GetParam() == 0 )
2579  {
2580  m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2581  m_pViewImpl->GetRequest()->Ignore();
2582  }
2583  else
2584  {
2585  m_pViewImpl->GetRequest()->SetReturnValue( SfxBoolItem( nSlot, nFound != -1 ) );
2586  m_pViewImpl->GetRequest()->Done();
2587  }
2588  }
2589  else if ( SID_DOCUMENT_COMPARE == nSlot || SID_DOCUMENT_MERGE == nSlot )
2590  {
2591  m_pViewImpl->GetRequest()->SetReturnValue( SfxInt32Item( nSlot, nFound ) );
2592 
2593  if ( nFound > 0 ) // show Redline browser
2594  {
2595  SfxViewFrame* pVFrame = GetViewFrame();
2597 
2598  // re-initialize Redline dialog
2599  sal_uInt16 nId = SwRedlineAcceptChild::GetChildWindowId();
2600  SwRedlineAcceptChild* pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->GetChildWindow( nId ));
2601  if ( pRed )
2602  pRed->ReInitDlg( GetDocShell() );
2603  }
2604  }
2605 }
2606 
2608 {
2609  if (m_pViewImpl)
2610  m_pViewImpl->ExecuteScan(rReq) ;
2611 }
2612 
2613 const OUString& SwView::GetOldGrfCat()
2614 {
2615  return GetCachedString(OldGrfCat);
2616 }
2617 
2618 void SwView::SetOldGrfCat(const OUString& sStr)
2619 {
2620  SetCachedString(OldGrfCat, sStr);
2621 }
2622 
2623 const OUString& SwView::GetOldTabCat()
2624 {
2625  return GetCachedString(OldTabCat);
2626 }
2627 
2628 void SwView::SetOldTabCat(const OUString& sStr)
2629 {
2630  SetCachedString(OldTabCat, sStr);
2631 }
2632 
2633 const OUString& SwView::GetOldFrameCat()
2634 {
2635  return GetCachedString(OldFrameCat);
2636 }
2637 
2638 void SwView::SetOldFrameCat(const OUString& sStr)
2639 {
2640  SetCachedString(OldFrameCat, sStr);
2641 }
2642 
2643 const OUString& SwView::GetOldDrwCat()
2644 {
2645  return GetCachedString(OldDrwCat);
2646 }
2647 
2648 void SwView::SetOldDrwCat(const OUString& sStr)
2649 {
2650  SwView::SetCachedString(OldDrwCat, sStr);
2651 }
2652 
2653 
2654 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetValue() const
bool is() const
#define MAXZOOM
Definition: view.hxx:81
static void ShowDBObj(SwView const &rView, const SwDBData &rData)
Definition: swmodul1.cxx:366
bool ToggleBlockMode()
Definition: select.cxx:763
Base class of the Writer layout elements.
Definition: frame.hxx:297
bool JumpToSwMark(const OUString &rMark)
Definition: view2.cxx:2033
void StateStatusLine(SfxItemSet &)
get status of the status line
Definition: view2.cxx:1397
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:503
#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:2613
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
FlyMode
Definition: mdiexp.hxx:42
OUString const & GetCurPageStyle() const
Definition: wrtsh1.cxx:1567
#define FN_EDIT_REGION
Definition: cmdid.h:108
void ItemSetToPageDesc(const SfxItemSet &rSet, SwPageDesc &rPageDesc)
Definition: uitool.cxx:262
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:118
void ToggleInsMode()
Definition: wrtsh.hxx:164
bool IsDefault() const
Definition: format.hxx:109
#define FN_SET_ADD_MODE
Definition: cmdid.h:671
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:294
const char aData[]
Definition: ww8scan.hxx:47
void SetState(const SfxItemSet &rSet)
constexpr TypedWhichId< SwFormatHeader > RES_HEADER(96)
std::string GetValue
static const std::vector< OUString > & GetFrameFormatUINameArray()
const SwNumRule * GetNumRuleAtCurrCursorPos() const
Definition: ednumber.cxx:723
#define FN_STAT_BOOKMARK
Definition: cmdid.h:833
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:2218
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:1070
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
Definition: langhelper.cxx:399
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:1722
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:184
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:320
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
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document setting interface.
Definition: viewsh.cxx:2602
long SwTwips
Definition: swtypes.hxx:49
void EnterStdMode()
Definition: select.cxx:550
void Done(bool bRemove=false)
void ExtendedSelectAll(bool bFootnotes=true)
Definition: crsrsh.cxx:593
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:2607
const OUString & GetOldFrameCat()
Definition: view2.cxx:2633
#define FN_STAT_PAGE
Definition: cmdid.h:829
void SetCachedString(CachedStringID id, const OUString &sStr)
Definition: view.hxx:662
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
#define ERRCODE_GRFILTER_IOERROR
unsigned long GetSidebarBorderWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2130
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:1646
virtual short Execute()=0
#define FN_TO_PREV_PAGE
Definition: cmdid.h:728
RET_CANCEL
bool IsStdMode() const
Definition: wrtsh.hxx:146
virtual const SfxItemSet * GetOutputItemSet() const =0
sal_uInt8 GetNumLevel() const
Definition: ednumber.cxx:698
void SetUseInputLanguage(bool bNew)
#i42732# display status of font size/name depending on either the input language or the selection pos...
Definition: edtwin.cxx:6419
SwFrameFormat * FindFrameFormatByName(const OUString &rName) const
Definition: docfmt.cxx:734
sal_uInt16 NextWhich()
Degree10 getRotation() const
SfxApplication * SfxGetpApp()
const SwSection * GetCurrSection() const
Definition: edsect.cxx:70
SvxZoomType GetZoomType() const
Definition: viewopt.hxx:535
size_type size() const
Definition: docary.hxx:266
const SwTextINetFormat * GetTextINetFormat() const
Definition: fmtinfmt.hxx:70
bool IsRedlineOn() const
Definition: edredln.cxx:42
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:463
RET_YES
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
sal_uInt16 GetDocumentBorder() const
Definition: viewopt.hxx:445
static void SetFrameMode_(FlyMode eMode)
Definition: basesh.hxx:111
PropertiesInfo aProperties
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
bool getBrowseMode() const
Definition: viewopt.hxx:461
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
#define FN_EDIT_LINK_DLG
Definition: cmdid.h:71
const OUString & GetName() const
Definition: format.hxx:111
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:768
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
void UpdatePageNums(sal_uInt16 nPhyNum, sal_uInt16 nVirtNum, const OUString &rPgStr)
invalidate page numbering field
Definition: view2.cxx:1372
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:832
#define FN_TO_NEXT_PAGE
Definition: cmdid.h:727
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:2606
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:61
const char * sName
const OUString & GetOldTabCat()
Definition: view2.cxx:2623
virtual bool IsConditionalFastCall(const SfxRequest &rReq) override
Definition: view2.cxx:1357
#define FN_INSERT_FIELD_DATA_ONLY
Definition: cmdid.h:210
#define FN_MAILMERGE_SENDMAIL_CHILDWINDOW
Definition: cmdid.h:267
#define FN_LINE_NUMBERING_DLG
Definition: cmdid.h:486
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
void GenerateFormLetter(bool bUseCurrentDocument)
Definition: view2.cxx:2424
const OUString & GetOldDrwCat()
Definition: view2.cxx:2643
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:20
SwDBManager * GetDBManager() const
For evaluation of DB fields (new DB-manager).
Definition: edfld.cxx:337
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:830
#define FN_REDLINE_ACCEPT_DIRECT
Definition: cmdid.h:137
T * get() const
#define FN_PAGEUP
Definition: cmdid.h:669
sal_uInt16 char * pName
static void FireColumnChangeEvent(sal_uInt16 nOldColumn, sal_uInt16 nNewColumn)
Definition: crsrsh.cxx:445
const SwTableNode * IsCursorInTable() const
Definition: crsrsh.hxx:889
Style of a layout element.
Definition: frmfmt.hxx:57
void UpdateDocStats()
Definition: view2.cxx:1389
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:310
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:2025
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
const OUString & GetSectionName() const
Definition: section.hxx:168
void ChildWindowExecute(SfxRequest &)
bool IsViewLayoutBookMode() const
Definition: viewopt.hxx:468
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:238
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:878
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:2236
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:933
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:2638
static void FireSectionChangeEvent(sal_uInt16 nOldSection, sal_uInt16 nNewSection)
Definition: crsrsh.cxx:456
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:337
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:2172
size_t GetPageDescCnt() const
Definition: doc.hxx:877
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
#define FN_SCROLL_NEXT
Definition: cmdid.h:183
SwDBData const & GetDBData() const
Database information.
Definition: edfld.cxx:295
static void ShowPanel(const OUString &rsPanelId, const css::uno::Reference< css::frame::XFrame > &rxFrame, bool bFocus=false)
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
#define FN_WORDCOUNT_DIALOG
Definition: cmdid.h:591
#define FN_SCROLL_PREV
Definition: cmdid.h:182
bool HasName() const
void LockPaint()
Definition: viewsh.hxx:601
#define FN_UPDATE_CUR_TOX
Definition: cmdid.h:504
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
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:3331
void SelAll()
Definition: select.cxx:122
const char sStatusDelim[]
Definition: view2.cxx:146
sal_Int16 nVersion
#define FN_REDLINE_REJECT_TONEXT
Definition: cmdid.h:146
void ExecuteStatusLine(SfxRequest &)
execute method for the status line
Definition: view2.cxx:1749
SW_DLLPUBLIC void MakeDefTabs(SwTwips nDefDist, SvxTabStopItem &rTabs)
Definition: uitool.cxx:569
bool StartExecuteAsync(const std::function< void(sal_Int32)> &rEndDialogFn)
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:129
sal_uInt32 GetId() const
Definition: redline.hxx:183
#define DB_DELIM
Definition: swtypes.hxx:133
#define FN_STAT_WORDCOUNT
Definition: cmdid.h:834
#define FN_TOGGLE_OUTLINE_CONTENT_VISIBILITY
Definition: cmdid.h:190
#define FN_QRY_MERGE
Definition: cmdid.h:228
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:745
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
void SetMinLen(sal_uInt16 Len)
css::uno::Reference< css::linguistic2::XProofreadingIterator > const & GetGCIterator() const
Definition: docnew.cxx:114
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:742
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:221
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:460
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:2258
#define ERRCODE_GRFILTER_TOOBIG
sal_uInt16 GetWishWidth() const
Definition: fmtclds.hxx:122
#define ERRCODE_GRFILTER_FILTERERROR
#define FN_FORMAT_FRAME_DLG
Definition: cmdid.h:318
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
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:181
sal_uInt16 GetSlot() const
void ExecuteInsertDoc(SfxRequest &rRequest, const SfxPoolItem *pItem)
Definition: view2.cxx:2190
bool IsAnyDatabaseFieldInDoc() const
Definition: edfld.cxx:392
bool HasChildWindow(sal_uInt16)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
#define FN_INSERT_FIELD
Definition: cmdid.h:198
void ToggleInsModeOnActiveSidebarWin()
Definition: PostItMgr.cxx:2398
static void FirePageChangeEvent(sal_uInt16 nOldPage, sal_uInt16 nNewPage)
Definition: crsrsh.cxx:434
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:601
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:704
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
#define FN_REFRESH_VIEW
Definition: cmdid.h:149
TOXTypes GetType() const
Definition: tox.hxx:731
#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:494
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:670
void SetOldGrfCat(const OUString &sStr)
Definition: view2.cxx:2618
bool HasNotes() const
Definition: PostItMgr.cxx:2099
bool IsExtMode() const
Definition: wrtsh.hxx:151
#define FN_FORMAT_PAGE_DLG
Definition: cmdid.h:315
virtual bool get(DocumentSettingId id) const =0
Return the specified document setting.
#define FN_SET_EXT_MODE
Definition: cmdid.h:672
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:176
static OUString GetEventName(sal_Int32 nId)
Definition: docsh.cxx:1314
bool bColumnChange()
Definition: crsrsh.cxx:467
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:1201
bool read(Graphic const &rGraphic)
#define ERR_SWG_READ_ERROR
Definition: swerror.h:25
#define SID_INSPECTOR_DECK
Definition: cmdid.h:870
void InsFrameMode(sal_uInt16 nCols)
Definition: view2.cxx:2000
static SVL_DLLPUBLIC bool CompareHashPassword(const css::uno::Sequence< sal_Int8 > &rOldPassHash, const OUString &sNewPass)
unsigned long GetSidebarWidth(bool bPx=false) const
Definition: PostItMgr.cxx:2104
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 &)
static void ToggleDeck(const OUString &rsDeckId, SfxViewFrame *pViewFrame)
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:2398
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:2628
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:184
void ResetAttr(const std::set< sal_uInt16 > &attrs=std::set< sal_uInt16 >(), SwPaM *pCursor=nullptr)
Definition: edatmisc.cxx:32
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:116
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:1054
int GetCurrentParaOutlineLevel() const
Get Outline level of current paragraph.
Definition: ednumber.cxx:406
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:79
virtual const SwRedlineTable & GetRedlineTable() const =0
bool ShowNotes() const
Definition: PostItMgr.cxx:2093
const SwFrameFormats * GetFrameFormats() const
Definition: doc.hxx:733
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:984
void EnterAddMode()
Definition: select.cxx:625
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1402
#define FN_ESCAPE
Definition: cmdid.h:673
#define FN_REDLINE_SHOW
Definition: cmdid.h:122
#define FN_INSERT_MULTI_TOX
Definition: cmdid.h:281
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:158
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:470
void SetOldDrwCat(const OUString &sStr)
Definition: view2.cxx:2648
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:160
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:446
void UnlockPaint(bool bVirDev=false)
Definition: viewsh.hxx:606
#define FN_GOTO_PAGE
Definition: cmdid.h:507
const OUString & GetTOXName() const
Definition: tox.hxx:476
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)