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