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