LibreOffice Module sw (master)  1
docsh2.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <osl/diagnose.h>
23 #include <com/sun/star/drawing/ModuleDispatcher.hpp>
24 #include <com/sun/star/frame/DispatchHelper.hpp>
25 #include <ooo/vba/word/XDocument.hpp>
26 #include <comphelper/fileformat.h>
29 #include <comphelper/string.hxx>
30 
31 #include <sal/log.hxx>
32 #include <edtwin.hxx>
33 #include <tools/urlobj.hxx>
34 #include <unotools/tempfile.hxx>
35 #include <unotools/configmgr.hxx>
36 #include <vcl/errinf.hxx>
37 #include <vcl/svapp.hxx>
38 #include <vcl/weld.hxx>
39 #include <svl/eitem.hxx>
40 #include <svl/macitem.hxx>
41 #include <unotools/pathoptions.hxx>
42 #include <vcl/transfer.hxx>
43 #include <sfx2/dinfdlg.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/dispatch.hxx>
46 #include <sfx2/new.hxx>
48 #include <sfx2/filedlghelper.hxx>
49 #include <sfx2/printer.hxx>
50 #include <sfx2/evntconf.hxx>
51 #include <sfx2/docfile.hxx>
52 #include <sfx2/docfilt.hxx>
53 #include <svx/dialogs.hrc>
54 #include <svx/drawitem.hxx>
55 #include <editeng/svxacorr.hxx>
56 #include <svx/fmshell.hxx>
57 #include <sfx2/linkmgr.hxx>
59 #include <sfx2/watermarkitem.hxx>
60 
61 #include <svx/ofaitem.hxx>
62 #include <SwSmartTagMgr.hxx>
63 #include <sfx2/app.hxx>
64 #include <basic/sbstar.hxx>
65 #include <basic/basmgr.hxx>
66 #include <comphelper/classids.hxx>
67 #include <fmtcol.hxx>
68 #include <istype.hxx>
69 #include <view.hxx>
70 #include <docsh.hxx>
71 #include <docary.hxx>
72 #include <wrtsh.hxx>
73 #include <rootfrm.hxx>
74 #include <fldbas.hxx>
75 #include <viewopt.hxx>
76 #include <globdoc.hxx>
77 #include <fldwrap.hxx>
78 #include <redlndlg.hxx>
79 #include <doc.hxx>
80 #include <IDocumentUndoRedo.hxx>
85 #include <IDocumentStatistics.hxx>
88 #include <IDocumentState.hxx>
89 #include <shellio.hxx>
90 #include <pview.hxx>
91 #include <srcview.hxx>
92 #include <wdocsh.hxx>
93 #include <unotxdoc.hxx>
94 #include <acmplwrd.hxx>
95 #include <swmodule.hxx>
96 #include <unobaseclass.hxx>
97 #include <swwait.hxx>
98 #include <swcli.hxx>
99 
100 #include <cmdid.h>
101 #include <helpids.h>
102 #include <strings.hrc>
103 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
104 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
105 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
106 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
107 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
108 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
109 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
110 #include <com/sun/star/script/vba/VBAEventId.hpp>
111 #include <editeng/acorrcfg.hxx>
112 #include <officecfg/Office/Security.hxx>
113 #include <officecfg/Office/Common.hxx>
114 
115 #include <sfx2/fcontnr.hxx>
117 #include <svtools/embedhlp.hxx>
118 
119 #include <swabstdlg.hxx>
120 #include <watermarkdialog.hxx>
121 
122 #include <ndtxt.hxx>
123 #include <iodetect.hxx>
124 
125 #include <memory>
126 
127 using namespace ::com::sun::star::ui::dialogs;
128 using namespace ::com::sun::star::lang;
129 using namespace ::com::sun::star::uno;
130 using namespace ::com::sun::star;
131 using namespace ::sfx2;
132 
133 // create DocInfo (virtual)
134 std::shared_ptr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
135 {
136  std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
137  //only with statistics, when this document is being shown, not
138  //from within the Doc-Manager
139  SwDocShell* pDocSh = static_cast<SwDocShell*>( SfxObjectShell::Current());
140  if( pDocSh == this )
141  {
142  //Not for SourceView.
144  if ( pVSh && dynamic_cast< const SwSrcView *>( pVSh ) == nullptr )
145  {
147  xDlg->AddFontTabPage();
148  xDlg->AddTabPage("writerstats", SwResId(STR_DOC_STAT), pFact->GetTabPageCreatorFunc(RID_SW_TP_DOC_STAT));
149  }
150  }
151  return xDlg;
152 }
153 
155 {
156  OSL_ENSURE( pView, "SwDocShell::ToggleLayoutMode, pView is null." );
157 
158  const SwViewOption& rViewOptions = *pView->GetWrtShell().GetViewOptions();
159 
160  //TODO: Should HideWhitespace flag be saved in the document settings?
162  UpdateFontList(); // Why is this necessary here?
163 
165  if( !GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) )
166  pView->SetPrinter( GetDoc()->getIDocumentDeviceAccess().getPrinter( false ), SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP );
168  SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this, false);
169  while (pTmpFrame)
170  {
171  if( pTmpFrame != pView->GetViewFrame() )
172  {
173  pTmpFrame->DoClose();
174  pTmpFrame = SfxViewFrame::GetFirst(this, false);
175  }
176  else
177  pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this, false);
178  }
179 
180  pView->GetWrtShell().InvalidateLayout(true);
181 
182  pView->RecheckBrowseMode();
183 
184  pView->SetNewWindowAllowed(!rViewOptions.getBrowseMode());
185 }
186 
187 // update text fields on document properties changes
189 {
190  if (!m_xDoc)
191  return;
192 
193  bool bUnlockView(true);
194  if (m_pWrtShell)
195  {
196  bUnlockView = !m_pWrtShell->IsViewLocked();
197  m_pWrtShell->LockView( true ); // lock visible section
199  }
200 
201  m_xDoc->getIDocumentStatistics().DocInfoChgd(IsEnableSetModified());
202 
203  if (m_pWrtShell)
204  {
206  if (bUnlockView)
207  {
208  m_pWrtShell->LockView( false );
209  }
210  }
211 }
212 
213 static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint )
214 {
215  using namespace com::sun::star::script::vba::VBAEventId;
216  const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
217  if ( !pSfxEventHint )
218  return;
219 
220  uno::Sequence< uno::Any > aArgs;
221  switch( pSfxEventHint->GetEventId() )
222  {
223  case SfxEventHintId::CreateDoc:
224  xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
225  break;
226  case SfxEventHintId::OpenDoc:
227  xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
228  break;
229  default: break;
230  }
231 }
232 
233 // Notification on DocInfo changes
235 {
236  if (!m_xDoc)
237  {
238  return ;
239  }
240 
241  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
242  m_xDoc->GetVbaEventProcessor();
243  if( xVbaEvents.is() )
244  lcl_processCompatibleSfxHint( xVbaEvents, rHint );
245 
246  if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
247  {
248  switch( pSfxEventHint->GetEventId() )
249  {
250  case SfxEventHintId::ActivateDoc:
251  case SfxEventHintId::CreateDoc:
252  case SfxEventHintId::OpenDoc:
253  {
254  uno::Sequence< css::uno::Any > aArgs;
255  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentChange", aArgs );
256  break;
257  }
258  default:
259  break;
260  }
261 
262  switch( pSfxEventHint->GetEventId() )
263  {
264  case SfxEventHintId::CreateDoc:
265  {
267  aDocument <<= mxAutomationDocumentObject;
268  uno::Sequence< uno::Any > aArgs{ aDocument };
269  SW_MOD()->CallAutomationApplicationEventSinks( "NewDocument", aArgs );
270  }
271  break;
272  case SfxEventHintId::OpenDoc:
273  {
275  aDocument <<= mxAutomationDocumentObject;
276  uno::Sequence< uno::Any > aArgs{ aDocument };
277  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentOpen", aArgs );
278  }
279  break;
280  default:
281  break;
282  }
283  }
284 
285  sal_uInt16 nAction = 0;
286  auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
287  if( pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished )
288  {
289  // #i38126# - own action id
290  nAction = 3;
291  }
292  else
293  {
294  // switch for more actions
295  if( rHint.GetId() == SfxHintId::TitleChanged)
296  {
297  if( GetMedium() )
298  nAction = 2;
299  }
300  }
301 
302  if( !nAction )
303  return;
304 
305  bool bUnlockView = true; //initializing prevents warning
306  if (m_pWrtShell)
307  {
308  bUnlockView = !m_pWrtShell->IsViewLocked();
309  m_pWrtShell->LockView( true ); //lock visible section
311  }
312  switch( nAction )
313  {
314  case 2:
315  m_xDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Filename )->UpdateFields();
316  break;
317  // #i38126# - own action for event LOADFINISHED
318  // in order to avoid a modified document.
319  // #i41679# - Also for the instance of <SwDoc>
320  // it has to be assured, that it's not modified.
321  // Perform the same as for action id 1, but disable <SetModified>.
322  case 3:
323  {
324  const bool bResetModified = IsEnableSetModified();
325  if ( bResetModified )
326  EnableSetModified( false );
327  // #i41679#
328  const bool bIsDocModified = m_xDoc->getIDocumentState().IsModified();
329  // TODO: is the ResetModified() below because of only the direct call from DocInfoChgd, or does UpdateFields() set it too?
330 
331  m_xDoc->getIDocumentStatistics().DocInfoChgd(false);
332 
333  // #i41679#
334  if ( !bIsDocModified )
335  m_xDoc->getIDocumentState().ResetModified();
336  if ( bResetModified )
338  }
339  break;
340  }
341 
342  if (m_pWrtShell)
343  {
345  if( bUnlockView )
346  m_pWrtShell->LockView( false );
347  }
348 }
349 
350 // Notification Close Doc
351 bool SwDocShell::PrepareClose( bool bUI )
352 {
353  bool bRet = SfxObjectShell::PrepareClose( bUI );
354 
355  // If we are going to close it at this point, let potential DocumentBeforeClose event handlers
356  // in Automation clients veto it.
357  if (bRet && m_xDoc && IsInPrepareClose())
358  {
360  aDocument <<= mxAutomationDocumentObject;
361 
362  uno::Sequence<uno::Any> aArgs{ // Arg 0: Document
363  aDocument,
364  // Arg 1: Cancel
365  uno::Any(false)
366  };
367 
368  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentBeforeClose", aArgs );
369 
370  // If the Cancel argument was set to True by an event handler, return false.
371  bool bCancel(false);
372  aArgs[1] >>= bCancel;
373  if (bCancel)
374  bRet = false;
375  }
376 
377  if( bRet )
378  EndListening( *this );
379 
380  if (m_xDoc && IsInPrepareClose())
381  {
382  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
383  m_xDoc->GetVbaEventProcessor();
384  if( xVbaEvents.is() )
385  {
386  using namespace com::sun::star::script::vba::VBAEventId;
387  uno::Sequence< uno::Any > aNoArgs;
388  xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aNoArgs );
389  }
390  }
391  return bRet;
392 }
393 
395 {
396  const SfxItemSet* pArgs = rReq.GetArgs();
397  const SfxPoolItem* pItem;
398  sal_uInt16 nWhich = rReq.GetSlot();
399  bool bDone = false;
400  switch ( nWhich )
401  {
402  case SID_AUTO_CORRECT_DLG:
403  {
406 
407  bool bOldLocked = rACW.IsLockWordLstLocked(),
408  bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
409 
410  rACW.SetLockWordLstLocked( true );
411 
413  pAFlags->m_pAutoCompleteList = &aTmpLst;
414 
415  SfxApplication* pApp = SfxGetpApp();
416  SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SfxCallMode::SYNCHRON, pApp->GetPool());
417  SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, true );
418  aAppReq.AppendItem(aSwOptions);
419 
420  pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
421 
423  aSet.Put( aSwOptions );
424 
425  const SfxBoolItem* pOpenSmartTagOptionsItem = nullptr;
426  if( pArgs && (pOpenSmartTagOptionsItem = pArgs->GetItemIfSet( SID_OPEN_SMARTTAGOPTIONS, false )) )
427  aSet.Put( *pOpenSmartTagOptionsItem );
428 
431  pDlg->Execute();
432  pDlg.disposeAndClear();
433 
434 
435  rACW.SetLockWordLstLocked( bOldLocked );
436 
438  rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
439  rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
440  if (pAFlags->m_pAutoCompleteList) // any changes?
441  {
442  rACW.CheckChangedList( aTmpLst );
443  // clear the temp WordList pointer
444  pAFlags->m_pAutoCompleteList = nullptr;
445  }
446 
447  if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
448  pAFlags->bAutoCmpltCollectWords )
449  {
450  // call on all Docs the idle formatter to start
451  // the collection of Words
452  for( SwDocShell *pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<SwDocShell>));
453  pDocSh;
454  pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetNext( *pDocSh, checkSfxObjectShell<SwDocShell> )) )
455  {
456  SwDoc* pTmp = pDocSh->GetDoc();
459  }
460  }
461  }
462  break;
463 
464  case SID_PRINTPREVIEW:
465  {
466  bool bSet = false;
467  bool bFound = false, bOnly = true;
468  SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this);
469  SfxViewShell* pViewShell = SfxViewShell::Current();
470  SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
471  bool bCurrent = isType<SwPagePreview>( pViewShell );
472 
473  while( pTmpFrame ) // search Preview
474  {
475  if( isType<SwView>( pTmpFrame->GetViewShell()) )
476  bOnly = false;
477  else if( isType<SwPagePreview>( pTmpFrame->GetViewShell()))
478  {
479  pTmpFrame->GetFrame().Appear();
480  bFound = true;
481  }
482  if( bFound && !bOnly )
483  break;
484  pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this);
485  }
486 
487  if( pArgs && SfxItemState::SET ==
488  pArgs->GetItemState( SID_PRINTPREVIEW, false, &pItem ))
489  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
490  else
491  bSet = !bCurrent;
492 
493  sal_uInt16 nSlotId = 0;
494  if( bSet && !bFound ) // Nothing found, so create new Preview
495  nSlotId = SID_VIEWSHELL1;
496  else if( bFound && !bSet )
497  nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
498 
499  if( nSlotId )
500  {
501  // PagePreview in the WebDocShell
502  // is found under Id VIEWSHELL2.
503  if( dynamic_cast< const SwWebDocShell *>( this ) != nullptr && SID_VIEWSHELL1 == nSlotId )
504  nSlotId = SID_VIEWSHELL2;
505 
506  if( pCurrView && pCurrView->GetDocShell() == this )
507  pTmpFrame = pCurrView->GetViewFrame();
508  else
509  pTmpFrame = SfxViewFrame::GetFirst( this );
510 
511  if (pTmpFrame)
512  pTmpFrame->GetDispatcher()->Execute( nSlotId, SfxCallMode::ASYNCHRON );
513  }
514 
515  rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
516  }
517  break;
518  case SID_TEMPLATE_LOAD:
519  {
520  OUString aFileName;
521  static bool bText = true;
522  static bool bFrame = false;
523  static bool bPage = false;
524  static bool bNum = false;
525  static bool bMerge = false;
526 
527  SfxTemplateFlags nFlags = bFrame ? SfxTemplateFlags::LOAD_FRAME_STYLES : SfxTemplateFlags::NONE;
528  if(bPage)
529  nFlags |= SfxTemplateFlags::LOAD_PAGE_STYLES;
530  if(bNum)
531  nFlags |= SfxTemplateFlags::LOAD_NUM_STYLES;
532  if(nFlags == SfxTemplateFlags::NONE || bText)
533  nFlags |= SfxTemplateFlags::LOAD_TEXT_STYLES;
534  if(bMerge)
535  nFlags |= SfxTemplateFlags::MERGE_STYLES;
536 
537  if ( pArgs )
538  {
539  const SfxStringItem* pTemplateItem = rReq.GetArg<SfxStringItem>(SID_TEMPLATE_NAME);
540  if ( pTemplateItem )
541  {
542  aFileName = pTemplateItem->GetValue();
543  const SfxInt32Item* pFlagsItem = rReq.GetArg<SfxInt32Item>(SID_TEMPLATE_LOAD);
544  if ( pFlagsItem )
545  nFlags = static_cast<SfxTemplateFlags>(o3tl::narrowing<sal_uInt16>(pFlagsItem->GetValue()));
546  }
547  }
548 
549  if ( aFileName.isEmpty() )
550  {
551  SfxNewFileDialog aNewFileDlg(GetView()->GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate);
552  aNewFileDlg.SetTemplateFlags(nFlags);
553 
554  sal_uInt16 nRet = aNewFileDlg.run();
555  if(RET_TEMPLATE_LOAD == nRet)
556  {
557  FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE,
558  FileDialogFlags::NONE, GetView()->GetFrameWeld());
559  aDlgHelper.SetContext(FileDialogHelper::WriterLoadTemplate);
560  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
561 
562  SfxObjectFactory &rFact = GetFactory();
563  SfxFilterMatcher aMatcher( rFact.GetFactoryName() );
564  SfxFilterMatcherIter aIter( aMatcher );
565  std::shared_ptr<const SfxFilter> pFlt = aIter.First();
566  while( pFlt )
567  {
568  // --> OD #i117339#
569  if( pFlt && pFlt->IsAllowedAsTemplate() &&
570  ( pFlt->GetUserData() == "CXML" ||
571  pFlt->GetUserData() == "CXMLV" ) )
572  {
573  const OUString sWild = pFlt->GetWildcard().getGlob();
574  xFP->appendFilter( pFlt->GetUIName(), sWild );
575  }
576  pFlt = aIter.Next();
577  }
578  bool bWeb = dynamic_cast< SwWebDocShell *>( this ) != nullptr;
579  std::shared_ptr<const SfxFilter> pOwnFlt =
580  SwDocShell::Factory().GetFilterContainer()->
581  GetFilter4FilterName("writer8");
582 
583  // make sure the default file format is also available
584  if(bWeb)
585  {
586  const OUString sWild = pOwnFlt->GetWildcard().getGlob();
587  xFP->appendFilter( pOwnFlt->GetUIName(), sWild );
588  }
589 
590  bool bError = false;
591  // catch exception if wrong filter is selected - should not happen anymore
592  try
593  {
594  xFP->setCurrentFilter( pOwnFlt->GetUIName() );
595  }
596  catch (const uno::Exception&)
597  {
598  bError = true;
599  }
600 
601  if( !bError && ERRCODE_NONE == aDlgHelper.Execute() )
602  {
603  aFileName = xFP->getSelectedFiles().getConstArray()[0];
604  }
605  }
606  else if( RET_OK == nRet)
607  {
608  aFileName = aNewFileDlg.GetTemplateFileName();
609  }
610 
611  nFlags = aNewFileDlg.GetTemplateFlags();
612  rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
613  rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, static_cast<tools::Long>(nFlags) ) );
614  }
615 
616  if( !aFileName.isEmpty() )
617  {
618  SwgReaderOption aOpt;
619  bText = bool(nFlags & SfxTemplateFlags::LOAD_TEXT_STYLES );
620  aOpt.SetTextFormats(bText);
621  bFrame = bool(nFlags & SfxTemplateFlags::LOAD_FRAME_STYLES);
622  aOpt.SetFrameFormats(bFrame);
623  bPage = bool(nFlags & SfxTemplateFlags::LOAD_PAGE_STYLES );
624  aOpt.SetPageDescs(bPage);
625  bNum = bool(nFlags & SfxTemplateFlags::LOAD_NUM_STYLES );
626  aOpt.SetNumRules(bNum);
627  //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge!
628  bMerge = bool(nFlags & SfxTemplateFlags::MERGE_STYLES);
629  aOpt.SetMerge( !bMerge );
630 
631  SetError(LoadStylesFromFile(aFileName, aOpt, false));
632  if ( !GetError() )
633  rReq.Done();
634  }
635  }
636  break;
637  case SID_SOURCEVIEW:
638  {
639  SfxViewShell* pViewShell = GetView()
640  ? static_cast<SfxViewShell*>(GetView())
642  SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
643  SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell );
644  if(!pSrcView)
645  {
646  // 3 possible state:
647  // 1 - file unsaved -> save as HTML
648  // 2 - file modified and HTML filter active -> save
649  // 3 - file saved in non-HTML -> QueryBox to save as HTML
650  std::shared_ptr<const SfxFilter> pHtmlFlt =
652  u"HTML",
653  SwWebDocShell::Factory().GetFilterContainer() );
654  bool bLocalHasName = HasName();
655  if(bLocalHasName)
656  {
657  //check for filter type
658  std::shared_ptr<const SfxFilter> pFlt = GetMedium()->GetFilter();
659  if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
660  {
661  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pViewFrame->GetFrameWeld(), "modules/swriter/ui/saveashtmldialog.ui"));
662  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("SaveAsHTMLDialog"));
663  if (RET_YES == xQuery->run())
664  bLocalHasName = false;
665  else
666  break;
667  }
668  }
669  if(!bLocalHasName)
670  {
671  FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION,
672  FileDialogFlags::NONE,
673  GetView()->GetFrameWeld());
674  aDlgHelper.SetContext(FileDialogHelper::WriterSaveHTML);
675  aDlgHelper.AddFilter( pHtmlFlt->GetFilterName(), pHtmlFlt->GetDefaultExtension() );
676  aDlgHelper.SetCurrentFilter( pHtmlFlt->GetFilterName() );
677  if( ERRCODE_NONE != aDlgHelper.Execute())
678  {
679  break;
680  }
681  OUString sPath = aDlgHelper.GetPath();
682  SfxStringItem aName(SID_FILE_NAME, sPath);
683  SfxStringItem aFilter(SID_FILTER_NAME, pHtmlFlt->GetName());
684  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(
685  pViewFrame->GetDispatcher()->ExecuteList(
686  SID_SAVEASDOC, SfxCallMode::SYNCHRON,
687  { &aName, &aFilter }));
688  if(!pBool || !pBool->GetValue())
689  break;
690  }
691  }
692 
693  assert(dynamic_cast<SwWebDocShell*>(this) && "SourceView only in WebDocShell");
694 
695  // the SourceView is not the 1 for SwWebDocShell
696  sal_uInt16 nSlot = SID_VIEWSHELL1;
697  bool bSetModified = false;
698  VclPtr<SfxPrinter> pSavePrinter;
699  if( nullptr != pSrcView)
700  {
701  SfxPrinter* pTemp = GetDoc()->getIDocumentDeviceAccess().getPrinter( false );
702  if(pTemp)
703  pSavePrinter = VclPtr<SfxPrinter>::Create(*pTemp);
704  bSetModified = IsModified() || pSrcView->IsModified();
705  if(pSrcView->IsModified()||pSrcView->HasSourceSaved())
706  {
707  utl::TempFile aTempFile;
708  aTempFile.EnableKillingFile();
709  pSrcView->SaveContent(aTempFile.GetURL());
710  bDone = true;
711  SvxMacro aMac(OUString(), OUString(), STARBASIC);
712  SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::OPENDOC ), aMac, this);
713  SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEDOC ), aMac, this);
714  SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::ACTIVATEDOC ), aMac, this);
715  SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::DEACTIVATEDOC ), aMac, this);
716  ReloadFromHtml(aTempFile.GetURL(), pSrcView);
717  nSlot = 0;
718  }
719  else
720  {
721  nSlot = SID_VIEWSHELL0;
722  }
723  }
724  if(nSlot)
725  pViewFrame->GetDispatcher()->Execute(nSlot, SfxCallMode::SYNCHRON);
726  if(bSetModified)
728  if(pSavePrinter)
729  {
730  GetDoc()->getIDocumentDeviceAccess().setPrinter( pSavePrinter, true, true);
731  //pSavePrinter must not be deleted again
732  }
733  pViewFrame->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, false)); // not SID_VIEWSHELL2
734  pViewFrame->GetBindings().Invalidate( SID_NEWWINDOW );
735  pViewFrame->GetBindings().Invalidate( SID_BROWSER_MODE );
736  pViewFrame->GetBindings().Invalidate( FN_PRINT_LAYOUT );
737  }
738  break;
739  case SID_GET_COLORLIST:
740  {
741  const SvxColorListItem* pColItem = GetItem(SID_COLOR_TABLE);
742  const XColorListRef& pList = pColItem->GetColorList();
743  rReq.SetReturnValue(OfaXColorListItem(SID_GET_COLORLIST, pList));
744  }
745  break;
747  case FN_ABSTRACT_NEWDOC:
748  {
751  if(RET_OK == pDlg->Execute())
752  {
753  sal_uInt8 nLevel = pDlg->GetLevel();
754  sal_uInt8 nPara = pDlg->GetPara();
755  SwDoc* pSmryDoc = new SwDoc();
756  SfxObjectShellLock xDocSh(new SwDocShell(*pSmryDoc, SfxObjectCreateMode::STANDARD));
757  xDocSh->DoInitNew();
758 
759  bool bImpress = FN_ABSTRACT_STARIMPRESS == nWhich;
760  m_xDoc->Summary(*pSmryDoc, nLevel, nPara, bImpress);
761  if( bImpress )
762  {
763  WriterRef xWrt;
764  // mba: looks as if relative URLs don't make sense here
765  ::GetRTFWriter(std::u16string_view(), OUString(), xWrt);
766  SvMemoryStream *pStrm = new SvMemoryStream();
767  pStrm->SetBufferSize( 16348 );
768  SwWriter aWrt( *pStrm, *pSmryDoc );
769  ErrCode eErr = aWrt.Write( xWrt );
770  if( !eErr.IgnoreWarning() )
771  {
772  uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
773  uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
774 
775  uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
776  pStrm->Seek( STREAM_SEEK_TO_END );
777  pStrm->WriteChar( '\0' );
778  pStrm->Seek( STREAM_SEEK_TO_BEGIN );
779 
780  // Transfer ownership of stream to a lockbytes object
781  SvLockBytes aLockBytes( pStrm, true );
782  SvLockBytesStat aStat;
783  if ( aLockBytes.Stat( &aStat ) == ERRCODE_NONE )
784  {
785  sal_uInt32 nLen = aStat.nSize;
786  std::size_t nRead = 0;
787  uno::Sequence< sal_Int8 > aSeq( nLen );
788  aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
789 
790  uno::Sequence< beans::PropertyValue > aArgs{
791  comphelper::makePropertyValue("RtfOutline", aSeq)
792  };
793  xHelper->executeDispatch( xProv, "SendOutlineToImpress", OUString(), 0, aArgs );
794  }
795  }
796  else
798  }
799  else
800  {
801  // Create new document
803  SwView *pCurrView = static_cast<SwView*>( pFrame->GetViewShell());
804 
805  // Set document's title
806  OUString aTmp = SwResId(STR_ABSTRACT_TITLE) + GetTitle();
807  xDocSh->SetTitle( aTmp );
808  pCurrView->GetWrtShell().SetNewDoc();
809  pFrame->Show();
810  pSmryDoc->getIDocumentState().SetModified();
811  }
812 
813  }
814  }
815  break;
818  {
819  bool bEnable = IsEnableSetModified();
820  EnableSetModified( false );
821  WriterRef xWrt;
822  // mba: looks as if relative URLs don't make sense here
823  ::GetRTFWriter( u"O", OUString(), xWrt );
824  std::unique_ptr<SvMemoryStream> pStrm (new SvMemoryStream());
825  pStrm->SetBufferSize( 16348 );
826  SwWriter aWrt( *pStrm, *GetDoc() );
827  ErrCode eErr = aWrt.Write( xWrt );
828  EnableSetModified( bEnable );
829  if( !eErr.IgnoreWarning() )
830  {
831  pStrm->Seek( STREAM_SEEK_TO_END );
832  pStrm->WriteChar( '\0' );
833  pStrm->Seek( STREAM_SEEK_TO_BEGIN );
834  if ( nWhich == FN_OUTLINE_TO_IMPRESS )
835  {
836  uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
837  uno::Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
838 
839  uno::Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
840  pStrm->Seek( STREAM_SEEK_TO_END );
841  pStrm->WriteChar( '\0' );
842  pStrm->Seek( STREAM_SEEK_TO_BEGIN );
843 
844  // Transfer ownership of stream to a lockbytes object
845  SvLockBytes aLockBytes( pStrm.release(), true );
846  SvLockBytesStat aStat;
847  if ( aLockBytes.Stat( &aStat ) == ERRCODE_NONE )
848  {
849  sal_uInt32 nLen = aStat.nSize;
850  std::size_t nRead = 0;
851  uno::Sequence< sal_Int8 > aSeq( nLen );
852  aLockBytes.ReadAt( 0, aSeq.getArray(), nLen, &nRead );
853 
854  uno::Sequence< beans::PropertyValue > aArgs{
855  comphelper::makePropertyValue("RtfOutline", aSeq)
856  };
857  xHelper->executeDispatch( xProv, "SendOutlineToImpress", OUString(), 0, aArgs );
858  }
859  }
860  else
861  {
863 
864  pClipCntnr->CopyAnyData( SotClipboardFormatId::RTF, static_cast<char const *>(
865  pStrm->GetData()), pStrm->GetEndOfData() );
866  pClipCntnr->CopyToClipboard(
867  GetView()? &GetView()->GetEditWin() : nullptr );
868  }
869  }
870  else
872  }
873  break;
874  case SID_SPELLCHECKER_CHANGED:
876  SwModule::CheckSpellChanges(false, true, true, false );
877  break;
878 
879  case SID_MAIL_PREPAREEXPORT:
880  {
881  //pWrtShell is not set in page preview
882  if (m_pWrtShell)
884  m_xDoc->getIDocumentFieldsAccess().UpdateFields( false );
885  m_xDoc->getIDocumentLinksAdministration().EmbedAllLinks();
889  m_xDoc->RemoveInvisibleContent();
890  if (m_pWrtShell)
892  }
893  break;
894 
895  case SID_MAIL_EXPORT_FINISHED:
896  {
897  if (m_pWrtShell)
899  //try to undo the removal of invisible content
901  m_xDoc->RestoreInvisibleContent();
902  if (m_pWrtShell)
904  }
905  break;
906  case FN_NEW_HTML_DOC:
907  case FN_NEW_GLOBAL_DOC:
908  {
909  bDone = false;
910  bool bCreateHtml = FN_NEW_HTML_DOC == nWhich;
911 
912  bool bCreateByOutlineLevel = false;
913  sal_Int32 nTemplateOutlineLevel = 0;
914 
915  OUString aFileName, aTemplateName;
916  if( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich, false, &pItem ) )
917  {
918  aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
919  const SfxStringItem* pTemplItem = SfxItemSet::GetItem<SfxStringItem>(pArgs, SID_TEMPLATE_NAME, false);
920  if ( pTemplItem )
921  aTemplateName = pTemplItem->GetValue();
922  }
923  if ( aFileName.isEmpty() )
924  {
925  bool bError = false;
926 
927  FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, FileDialogFlags::NONE,
928  GetView()->GetFrameWeld());
929  aDlgHelper.SetContext(FileDialogHelper::WriterNewHTMLGlobalDoc);
930 
931  const sal_Int16 nControlIds[] = {
932  CommonFilePickerElementIds::PUSHBUTTON_OK,
933  CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
934  CommonFilePickerElementIds::LISTBOX_FILTER,
935  CommonFilePickerElementIds::CONTROL_FILEVIEW,
936  CommonFilePickerElementIds::EDIT_FILEURL,
937  ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
938  ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
939  0
940  };
941 
942  if (bCreateHtml)
943  {
944  const char* aHTMLHelpIds[] =
945  {
953  ""
954  };
955  aDlgHelper.SetControlHelpIds( nControlIds, aHTMLHelpIds );
956  }
957  else
958  {
959  const char* aMasterHelpIds[] =
960  {
968  ""
969  };
970  aDlgHelper.SetControlHelpIds( nControlIds, aMasterHelpIds );
971  }
972  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
973 
974  std::shared_ptr<const SfxFilter> pFlt;
975  TranslateId pStrId;
976 
977  if( bCreateHtml )
978  {
979  // for HTML there is only one filter!!
981  u"HTML",
982  SwWebDocShell::Factory().GetFilterContainer() );
983  pStrId = STR_LOAD_HTML_DOC;
984  }
985  else
986  {
987  // for Global-documents we now only offer the current one.
988  pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
989  GetFilter4Extension( "odm" );
990  pStrId = STR_LOAD_GLOBAL_DOC;
991  }
992 
993  if( pFlt )
994  {
995  const OUString sWild = pFlt->GetWildcard().getGlob();
996  xFP->appendFilter( pFlt->GetUIName(), sWild );
997  try
998  {
999  xFP->setCurrentFilter( pFlt->GetUIName() ) ;
1000  }
1001  catch (const uno::Exception&)
1002  {
1003  bError = true;
1004  }
1005  }
1006  if(!bError)
1007  {
1008  uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
1009 
1010  bool bOutline[MAXLEVEL] = {false};
1011  const SwOutlineNodes& rOutlNds = m_xDoc->GetNodes().GetOutLineNds();
1012  for( size_t n = 0; n < rOutlNds.size(); ++n )
1013  {
1014  const int nLevel = rOutlNds[n]->GetTextNode()->GetAttrOutlineLevel();
1015  if( nLevel > 0 && ! bOutline[nLevel-1] )
1016  {
1017  bOutline[nLevel-1] = true;
1018  }
1019  }
1020 
1021  const sal_uInt16 nStyleCount = m_xDoc->GetTextFormatColls()->size();
1022  Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
1023  OUString* pEntries = aListBoxEntries.getArray();
1024  sal_Int32 nIdx = 0 ;
1025 
1026  OUString sOutline( SwResId(STR_FDLG_OUTLINE_LEVEL) );
1027  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
1028  {
1029  if( bOutline[i] )
1030  pEntries[nIdx++] = sOutline + OUString::number( i+1 );
1031  }
1032 
1033  OUString sStyle( SwResId(STR_FDLG_STYLE) );
1034  for(sal_uInt16 i = 0; i < nStyleCount; ++i)
1035  {
1036  SwTextFormatColl &rTextColl = *(*m_xDoc->GetTextFormatColls())[ i ];
1037  if( !rTextColl.IsDefault() && rTextColl.IsAtDocNodeSet() )
1038  {
1039  pEntries[nIdx++] = sStyle + rTextColl.GetName();
1040  }
1041  }
1042 
1043  aListBoxEntries.realloc(nIdx);
1044  sal_Int16 nSelect = 0;
1045 
1046  try
1047  {
1048  Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get());
1049 
1050  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1051  ListboxControlActions::ADD_ITEMS , aTemplates );
1052  Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get());
1053  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1054  ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
1055  xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1056  SwResId( STR_FDLG_TEMPLATE_NAME ));
1057  }
1058  catch (const Exception&)
1059  {
1060  OSL_FAIL("control access failed");
1061  }
1062 
1063  xFP->setTitle(SwResId(pStrId));
1064  SvtPathOptions aPathOpt;
1065  xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
1066  if( ERRCODE_NONE == aDlgHelper.Execute())
1067  {
1068  aFileName = xFP->getSelectedFiles().getConstArray()[0];
1069  Any aTemplateValue = xCtrlAcc->getValue(
1070  ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1071  ListboxControlActions::GET_SELECTED_ITEM );
1072  OUString sTmpl;
1073  aTemplateValue >>= sTmpl;
1074 
1075  OUString aStyle(SwResId(STR_FDLG_STYLE));
1076  OUString aOutline(SwResId(STR_FDLG_OUTLINE_LEVEL));
1077 
1078  if ( sTmpl.startsWith(aStyle) )
1079  {
1080  aTemplateName = sTmpl.copy( aStyle.getLength() ); //get string behind "Style: "
1081  }
1082  else if ( sTmpl.startsWith(aOutline) )
1083  {
1084  nTemplateOutlineLevel = o3tl::toInt32(sTmpl.subView(aOutline.getLength())); //get string behind "Outline: Level ";
1085  bCreateByOutlineLevel = true;
1086  }
1087 
1088  if ( !aFileName.isEmpty() )
1089  {
1090  rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
1091  if( !aTemplateName.isEmpty() )
1092  rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
1093  }
1094  }
1095  }
1096  }
1097 
1098  if( !aFileName.isEmpty() )
1099  {
1100  if( PrepareClose( false ) )
1101  {
1102  SwWait aWait( *this, true );
1103 
1104  if ( bCreateByOutlineLevel )
1105  {
1106  bDone = bCreateHtml
1107  ? m_xDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
1108  : m_xDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
1109  }
1110  else
1111  {
1112  const SwTextFormatColl* pSplitColl = nullptr;
1113  if ( !aTemplateName.isEmpty() )
1114  pSplitColl = m_xDoc->FindTextFormatCollByName(aTemplateName);
1115  bDone = bCreateHtml
1116  ? m_xDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1117  : m_xDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1118  }
1119  if( bDone )
1120  {
1121  SfxStringItem aName( SID_FILE_NAME, aFileName );
1122  SfxStringItem aReferer(SID_REFERER, OUString());
1123  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1124  while(pViewShell)
1125  {
1126  //search for the view that created the call
1127  if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
1128  {
1129  SfxFrameItem aFrameItem( SID_DOCFRAME, pViewShell->GetViewFrame() );
1130  SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
1131  pDispatch->ExecuteList(SID_OPENDOC,
1132  SfxCallMode::ASYNCHRON,
1133  { &aName, &aReferer, &aFrameItem });
1134  break;
1135  }
1136  pViewShell = SfxViewShell::GetNext(*pViewShell);
1137  }
1138  }
1139  }
1140  if( !bDone && !rReq.IsAPI() )
1141  {
1142  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
1143  VclMessageType::Info, VclButtonsType::Ok,
1144  SwResId(STR_CANTCREATE)));
1145  xInfoBox->run();
1146  }
1147  }
1148  }
1149  rReq.SetReturnValue(SfxBoolItem( nWhich, bDone ));
1150  if (bDone)
1151  rReq.Done();
1152  else
1153  rReq.Ignore();
1154  break;
1155 
1156  case SID_ATTR_YEAR2000:
1157  if ( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich , false, &pItem ))
1158  {
1159  assert(dynamic_cast< const SfxUInt16Item *>( pItem ) && "wrong Item");
1160  sal_uInt16 nYear2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1161  // iterate over Views and put the State to FormShells
1162 
1163  SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this );
1164  SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : nullptr;
1165  SwView* pCurrView = dynamic_cast< SwView* >( pViewShell );
1166  while(pCurrView)
1167  {
1168  FmFormShell* pFormShell = pCurrView->GetFormShell();
1169  if(pFormShell)
1170  pFormShell->SetY2KState(nYear2K);
1171  pVFrame = SfxViewFrame::GetNext( *pVFrame, this );
1172  pViewShell = pVFrame ? pVFrame->GetViewShell() : nullptr;
1173  pCurrView = dynamic_cast<SwView*>( pViewShell );
1174  }
1175  m_xDoc->GetNumberFormatter()->SetYear2000(nYear2K);
1176  }
1177  break;
1178  case FN_OPEN_FILE:
1179  {
1180  SfxViewShell* pViewShell = GetView();
1181  if (!pViewShell)
1182  pViewShell = SfxViewShell::Current();
1183 
1184  if (!pViewShell)
1185  // Ok. I did my best.
1186  break;
1187 
1188  SfxStringItem aApp(SID_DOC_SERVICE, "com.sun.star.text.TextDocument");
1189  SfxStringItem aTarget(SID_TARGETNAME, "_blank");
1190  pViewShell->GetDispatcher()->ExecuteList(SID_OPENDOC,
1191  SfxCallMode::API|SfxCallMode::SYNCHRON,
1192  { &aApp, &aTarget });
1193  }
1194  break;
1195  case SID_CLASSIFICATION_APPLY:
1196  {
1197  if (pArgs && pArgs->GetItemState(nWhich, false, &pItem) == SfxItemState::SET)
1198  {
1199  SwWrtShell* pSh = GetWrtShell();
1200  const OUString& rValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
1201  auto eType = SfxClassificationPolicyType::IntellectualProperty;
1202  if (const SfxStringItem* pTypeNameItem = pArgs->GetItemIfSet(SID_TYPE_NAME, false))
1203  {
1204  const OUString& rType = pTypeNameItem->GetValue();
1206  }
1207  pSh->SetClassification(rValue, eType);
1208  }
1209  else
1210  SAL_WARN("sw.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
1211  }
1212  break;
1213  case SID_CLASSIFICATION_DIALOG:
1214  {
1215  auto xDialog = std::make_shared<svx::ClassificationDialog>(GetView()->GetFrameWeld(), false);
1216 
1217  SwWrtShell* pShell = GetWrtShell();
1218  std::vector<svx::ClassificationResult> aInput = pShell->CollectAdvancedClassification();
1219  xDialog->setupValues(std::move(aInput));
1220 
1221  weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){
1222  if (RET_OK == nResult)
1223  pShell->ApplyAdvancedClassification(xDialog->getResult());
1224  });
1225  }
1226  break;
1227  case SID_PARAGRAPH_SIGN_CLASSIFY_DLG:
1228  {
1229  SwWrtShell* pShell = GetWrtShell();
1230  auto xDialog = std::make_shared<svx::ClassificationDialog>(GetView()->GetFrameWeld(), true, [pShell]()
1231  {
1232  pShell->SignParagraph();
1233  });
1234 
1235  std::vector<svx::ClassificationResult> aInput = pShell->CollectParagraphClassification();
1236  xDialog->setupValues(std::move(aInput));
1237 
1238  weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){
1239  if (RET_OK == nResult)
1240  pShell->ApplyParagraphClassification(xDialog->getResult());
1241  });
1242  }
1243  break;
1244  case SID_WATERMARK:
1245  {
1246  SwWrtShell* pSh = GetWrtShell();
1247  if ( pSh )
1248  {
1249  if (pArgs && pArgs->GetItemState( SID_WATERMARK, false, &pItem ) == SfxItemState::SET)
1250  {
1251  SfxWatermarkItem aItem;
1252  aItem.SetText( static_cast<const SfxStringItem*>( pItem )->GetValue() );
1253 
1254  if ( const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_WATERMARK_FONT, false ) )
1255  aItem.SetFont( pFontItem->GetValue() );
1256  if ( const SfxInt16Item* pAngleItem = pArgs->GetItemIfSet( SID_WATERMARK_ANGLE, false ) )
1257  aItem.SetAngle( pAngleItem->GetValue() );
1258  if ( const SfxInt16Item* pTransItem = pArgs->GetItemIfSet( SID_WATERMARK_TRANSPARENCY, false ) )
1259  aItem.SetTransparency( pTransItem->GetValue() );
1260  if ( const SfxUInt32Item* pColorItem = pArgs->GetItemIfSet( SID_WATERMARK_COLOR, false ) )
1261  aItem.SetColor( Color(ColorTransparency, pColorItem->GetValue()) );
1262 
1263  pSh->SetWatermark( aItem );
1264  }
1265  else
1266  {
1267  SfxViewShell* pViewShell = GetView() ? GetView() : SfxViewShell::Current();
1268  SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() );
1269  auto xDlg = std::make_shared<SwWatermarkDialog>(pViewShell->GetViewFrame()->GetFrameWeld(),
1270  rBindings);
1271  weld::DialogController::runAsync(xDlg, [](sal_Int32 /*nResult*/){});
1272  }
1273  }
1274  }
1275  break;
1276  case SID_NOTEBOOKBAR:
1277  {
1278  const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( SID_NOTEBOOKBAR );
1279  SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current();
1280  SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() );
1281 
1282  if ( SfxNotebookBar::IsActive() )
1283  sfx2::SfxNotebookBar::ExecMethod( rBindings, pFile ? pFile->GetValue() : "" );
1284  else
1285  {
1286  sfx2::SfxNotebookBar::CloseMethod( rBindings );
1287  }
1288  }
1289  break;
1290  case FN_REDLINE_ACCEPT_ALL:
1291  case FN_REDLINE_REJECT_ALL:
1292  {
1294  SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
1295 
1296  if (rRedlineAccess.GetRedlineTable().empty())
1297  {
1298  break;
1299  }
1300 
1301  // tables with tracked deletion need Show Changes
1302  bool bHideChanges = pWrtShell && pWrtShell->GetLayout() &&
1303  pWrtShell->GetLayout()->IsHideRedlines();
1304  bool bChangedHideChanges = false;
1305  if ( bHideChanges )
1306  {
1307  SwTableNode* pOldTableNd = nullptr;
1308  const SwRedlineTable& aRedlineTable = rRedlineAccess.GetRedlineTable();
1309  for (SwRedlineTable::size_type n = 0; n < aRedlineTable.size(); ++n)
1310  {
1311  const SwRangeRedline* pRedline = aRedlineTable[n];
1312  if ( pRedline->GetType() == RedlineType::Delete )
1313  {
1314  SwTableNode* pTableNd =
1315  pRedline->GetPoint()->nNode.GetNode().FindTableNode();
1316  if ( pTableNd && pTableNd !=
1317  pOldTableNd && pTableNd->GetTable().HasDeletedRow() )
1318  {
1319  SfxBoolItem aShow(FN_REDLINE_SHOW, true);
1320  SfxViewShell* pViewShell = GetView()
1321  ? GetView()
1323  pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
1324  FN_REDLINE_SHOW, SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
1325  { &aShow });
1326  bChangedHideChanges = true;
1327  break;
1328  }
1329  pOldTableNd = pTableNd;
1330  }
1331  }
1332  }
1333 
1334  if (pWrtShell)
1335  {
1336  pWrtShell->StartAllAction();
1337  }
1338 
1339  rRedlineAccess.AcceptAllRedline(nWhich == FN_REDLINE_ACCEPT_ALL);
1340 
1341  if (pWrtShell)
1342  {
1343  pWrtShell->EndAllAction();
1344  }
1345 
1346  if ( bChangedHideChanges )
1347  {
1348  SfxBoolItem aShow(FN_REDLINE_SHOW, false);
1349  SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current();
1350  pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
1351  FN_REDLINE_SHOW, SfxCallMode::SYNCHRON|SfxCallMode::RECORD, { &aShow });
1352  }
1353 
1354  Broadcast(SfxHint(SfxHintId::RedlineChanged));
1355  rReq.Done();
1356  }
1357  break;
1358 
1359  default: OSL_FAIL("wrong Dispatcher");
1360  }
1361 }
1362 
1363 #if defined(_WIN32)
1364 bool SwDocShell::DdeGetData( const OUString& rItem, const OUString& rMimeType,
1365  uno::Any & rValue )
1366 {
1367  return m_xDoc->getIDocumentLinksAdministration().GetData( rItem, rMimeType, rValue );
1368 }
1369 
1370 bool SwDocShell::DdeSetData( const OUString& rItem, const OUString& /*rMimeType*/,
1371  const uno::Any & /*rValue*/ )
1372 {
1373  m_xDoc->getIDocumentLinksAdministration().SetData( rItem );
1374  return false;
1375 }
1376 
1377 #endif
1378 
1380 {
1381  return m_xDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem );
1382 }
1383 
1385 {
1386  if (m_xDoc)
1387  {
1388  ::sfx2::LinkManager& rLinkManager = m_xDoc->getIDocumentLinksAdministration().GetLinkManager();
1389  rLinkManager.ReconnectDdeLink(rServer);
1390  }
1391 }
1392 
1394  SotClipboardFormatId * pClipFormat,
1395  OUString * pLongUserName,
1396  sal_Int32 nVersion,
1397  bool bTemplate /* = false */) const
1398 {
1399  if (nVersion == SOFFICE_FILEFORMAT_60)
1400  {
1401  *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1402  *pClipFormat = SotClipboardFormatId::STARWRITER_60;
1403  *pLongUserName = SwResId(STR_WRITER_DOCUMENT_FULLTYPE);
1404  }
1405  else if (nVersion == SOFFICE_FILEFORMAT_8)
1406  {
1407  *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1408  *pClipFormat = bTemplate ? SotClipboardFormatId::STARWRITER_8_TEMPLATE : SotClipboardFormatId::STARWRITER_8;
1409  *pLongUserName = SwResId(STR_WRITER_DOCUMENT_FULLTYPE);
1410  }
1411 // #FIXME check with new Event handling
1412 #if 0
1413  uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper = m_xDoc->GetVbaEventsHelper();
1414  if( xVbaEventsHelper.is() )
1415  lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
1416 #endif
1417 }
1418 
1419 void SwDocShell::SetModified( bool bSet )
1420 {
1422  return;
1424  if( !IsEnableSetModified())
1425  return;
1426 
1427  if (!m_xDoc->getIDocumentState().IsInCallModified())
1428  {
1429  EnableSetModified( false );
1430  if( bSet )
1431  {
1432  bool const bOld = m_xDoc->getIDocumentState().IsModified();
1433  m_xDoc->getIDocumentState().SetModified();
1434  if( !bOld )
1435  {
1436  m_xDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1437  }
1438  }
1439  else
1440  m_xDoc->getIDocumentState().ResetModified();
1441 
1443  }
1444 
1446  Broadcast(SfxHint(SfxHintId::DocChanged));
1447 }
1448 
1450 {
1451  // if necessary newly initialize Fielddlg (i.e. for TYP_SETVAR)
1452  if(!GetView())
1453  return;
1454  SfxViewFrame* pVFrame = GetView()->GetViewFrame();
1455  SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(pVFrame->
1456  GetChildWindow( SwFieldDlgWrapper::GetChildWindowId() ));
1457  if( pWrp )
1458  pWrp->ReInitDlg( this );
1459 
1460  // if necessary newly initialize RedlineDlg
1461  SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->
1462  GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() ));
1463  if( pRed )
1464  pRed->ReInitDlg( this );
1465 }
1466 
1467 namespace {
1468 
1469 // #i48748#
1470 class SwReloadFromHtmlReader : public SwReader
1471 {
1472  public:
1473  SwReloadFromHtmlReader( SfxMedium& _rTmpMedium,
1474  const OUString& _rFilename,
1475  SwDoc* _pDoc )
1476  : SwReader( _rTmpMedium, _rFilename, _pDoc )
1477  {
1478  SetBaseURL( _rFilename );
1479  }
1480 };
1481 
1482 }
1483 
1484 void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView )
1485 {
1486  bool bModified = IsModified();
1487 
1488  // The HTTP-Header fields have to be removed, otherwise
1489  // there are some from Meta-Tags duplicated or triplicated afterwards.
1491 
1492 #if HAVE_FEATURE_SCRIPTING
1493  // The Document-Basic also bites the dust ...
1494  // A EnterBasicCall is not needed here, because nothing is called and
1495  // there can't be any Dok-Basic, that has not yet been loaded inside
1496  // of an HTML document.
1497  //#59620# HasBasic() shows, that there already is a BasicManager at the DocShell.
1498  // That was always generated in HTML-Import, when there are
1499  // Macros in the source code.
1501  {
1502  BasicManager *pBasicMan = GetBasicManager();
1503  if( pBasicMan && (pBasicMan != SfxApplication::GetBasicManager()) )
1504  {
1505  sal_uInt16 nLibCount = pBasicMan->GetLibCount();
1506  while( nLibCount )
1507  {
1508  StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
1509  if( pBasic )
1510  {
1511  // Notify the IDE
1512  SfxUnoAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( GetModel() ) );
1513  OUString aLibName( pBasic->GetName() );
1514  SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
1515  pSrcView->GetViewFrame()->GetDispatcher()->ExecuteList(
1516  SID_BASICIDE_LIBREMOVED,
1517  SfxCallMode::SYNCHRON,
1518  { &aShellItem, &aLibNameItem });
1519 
1520  // Only the modules are deleted from the standard-lib
1521  if( nLibCount )
1522  pBasicMan->RemoveLib( nLibCount, true );
1523  else
1524  pBasic->Clear();
1525  }
1526  }
1527 
1528  OSL_ENSURE( pBasicMan->GetLibCount() <= 1,
1529  "Deleting Basics didn't work" );
1530  }
1531  }
1532 #endif
1533  bool bWasBrowseMode = m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
1534  RemoveLink();
1535 
1536  // now also the UNO-Model has to be informed about the new Doc #51535#
1537  uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
1538  text::XTextDocument* pxDoc = xDoc.get();
1539  static_cast<SwXTextDocument*>(pxDoc)->InitNewDoc();
1540 
1541  AddLink();
1542  //#116402# update font list when new document is created
1543  UpdateFontList();
1544  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bWasBrowseMode);
1545  pSrcView->SetPool(&GetPool());
1546 
1547  const OUString& rMedname = GetMedium()->GetName();
1548 
1549  // The HTML template still has to be set
1550  SetHTMLTemplate( *GetDoc() ); //Styles from HTML.vor
1551 
1552  SfxViewShell* pViewShell = GetView() ? static_cast<SfxViewShell*>(GetView())
1554  SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
1555  pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON );
1556 
1557  SubInitNew();
1558 
1559  SfxMedium aMed( rStreamName, StreamMode::READ );
1560  // #i48748# - use class <SwReloadFromHtmlReader>, because
1561  // the base URL has to be set to the filename of the document <rMedname>
1562  // and not to the base URL of the temporary file <aMed> in order to get
1563  // the URLs of the linked graphics correctly resolved.
1564  SwReloadFromHtmlReader aReader( aMed, rMedname, m_xDoc.get() );
1565 
1566  aReader.Read( *ReadHTML );
1567 
1568  const SwView* pCurrView = GetView();
1569  //in print layout the first page(s) may have been formatted as a mix of browse
1570  //and print layout
1571  if(!bWasBrowseMode && pCurrView)
1572  {
1573  SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
1574  if( rWrtSh.GetLayout())
1575  rWrtSh.InvalidateLayout( true );
1576  }
1577 
1578  // Take HTTP-Header-Attributes over into the DocInfo again.
1579  // The Base-URL doesn't matter here because TLX uses the one from the document
1580  // for absolutization.
1582 
1583  if(bModified && !IsReadOnly())
1584  SetModified();
1585  else
1586  m_xDoc->getIDocumentState().ResetModified();
1587 }
1588 
1589 ErrCode SwDocShell::LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, bool bUnoCall)
1590 {
1591  ErrCode nErr = ERRCODE_NONE;
1592 
1593  // Set filter:
1594  SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() );
1595 
1596  // search for filter in WebDocShell, too
1597  SfxMedium aMed( rURL, StreamMode::STD_READ );
1598  if (rURL == "private:stream")
1599  aMed.setStreamToLoadFrom(rOpt.GetInputStream(), true);
1600  std::shared_ptr<const SfxFilter> pFlt;
1601  aMatcher.DetectFilter( aMed, pFlt );
1602  if(!pFlt)
1603  {
1604  SfxFilterMatcher aWebMatcher( SwWebDocShell::Factory().GetFactoryName() );
1605  aWebMatcher.DetectFilter( aMed, pFlt );
1606  }
1607  // --> OD #i117339# - trigger import only for own formats
1608  bool bImport( false );
1609  if ( aMed.IsStorage() )
1610  {
1611  // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat()
1612  // does not work correct (e.g., MS Word 2007 XML Template),
1613  // use workaround provided by MAV.
1614  uno::Reference< embed::XStorage > xStorage = aMed.GetStorage();
1615  if ( xStorage.is() )
1616  {
1617  // use <try-catch> on retrieving <MediaType> in order to check,
1618  // if the storage is one of our own ones.
1619  try
1620  {
1621  uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW );
1622  xProps->getPropertyValue( "MediaType" );
1623  bImport = true;
1624  }
1625  catch (const uno::Exception&)
1626  {
1627  bImport = false;
1628  }
1629  }
1630  }
1631  if ( bImport )
1632  {
1633  Reader* pRead = ReadXML;
1634  SwReaderPtr pReader;
1635  std::optional<SwPaM> pPam;
1636  // the SW3IO - Reader need the pam/wrtshell, because only then he
1637  // insert the styles!
1638  if( bUnoCall )
1639  {
1640  SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfContent(), -1 );
1641  pPam.emplace( aIdx );
1642  pReader.reset(new SwReader( aMed, rURL, *pPam ));
1643  }
1644  else
1645  {
1646  pReader.reset(new SwReader( aMed, rURL, *m_pWrtShell->GetCursor() ));
1647  }
1648 
1649  pRead->GetReaderOpt().SetTextFormats( rOpt.IsTextFormats() );
1650  pRead->GetReaderOpt().SetFrameFormats( rOpt.IsFrameFormats() );
1651  pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
1652  pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
1653  pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
1654 
1655  if( bUnoCall )
1656  {
1657  UnoActionContext aAction( m_xDoc.get() );
1658  nErr = pReader->Read( *pRead );
1659  }
1660  else
1661  {
1663  nErr = pReader->Read( *pRead );
1665  }
1666  }
1667 
1668  return nErr;
1669 }
1670 
1671 // Get a client for an embedded object if possible.
1672 SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
1673 {
1674  SfxInPlaceClient* pResult = nullptr;
1675 
1676  SwWrtShell* pShell = GetWrtShell();
1677  if ( pShell )
1678  {
1679  pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), &pShell->GetView().GetEditWin() );
1680  if ( !pResult )
1681  pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
1682  }
1683 
1684  return pResult;
1685 }
1686 
1688  SfxObjectShellLock& xLockRef,
1689  std::u16string_view rFileName,
1690  const OUString& rPasswd,
1691  const OUString& rFilter,
1692  sal_Int16 nVersion,
1693  SwDocShell* pDestSh )
1694 {
1695  if ( rFileName.empty() )
1696  return 0;
1697 
1698  // 1. Does the file already exist in the list of all Documents?
1699  INetURLObject aTmpObj( rFileName );
1700  aTmpObj.SetMark( u"" );
1701 
1702  // Iterate over the DocShell and get the ones with the name
1703 
1704  SfxObjectShell* pShell = pDestSh;
1705  bool bFirst = nullptr != pShell;
1706 
1707  if( !bFirst )
1708  // No DocShell passed, starting with the first from the DocShell list
1709  pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1710 
1711  while( pShell )
1712  {
1713  // We want this one
1714  SfxMedium* pMed = pShell->GetMedium();
1715  if( pMed && pMed->GetURLObject() == aTmpObj )
1716  {
1717  const SfxPoolItem* pItem;
1718  if( ( SfxItemState::SET == pMed->GetItemSet()->GetItemState(
1719  SID_VERSION, false, &pItem ) )
1720  ? (nVersion == static_cast<const SfxInt16Item*>(pItem)->GetValue())
1721  : !nVersion )
1722  {
1723  // Found, thus return
1724  xDocSh = pShell;
1725  return 1;
1726  }
1727  }
1728 
1729  if( bFirst )
1730  {
1731  bFirst = false;
1732  pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1733  }
1734  else
1735  pShell = SfxObjectShell::GetNext( *pShell, checkSfxObjectShell<SwDocShell> );
1736  }
1737 
1738  // 2. Open the file ourselves
1739  std::unique_ptr<SfxMedium> xMed(new SfxMedium( aTmpObj.GetMainURL(
1740  INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
1741  if( INetProtocol::File == aTmpObj.GetProtocol() )
1742  xMed->Download(); // Touch the medium (download it)
1743 
1744  std::shared_ptr<const SfxFilter> pSfxFlt;
1745  if (!xMed->GetError())
1746  {
1747  SfxFilterMatcher aMatcher( rFilter == "writerglobal8"
1748  ? SwGlobalDocShell::Factory().GetFactoryName()
1749  : SwDocShell::Factory().GetFactoryName() );
1750 
1751  // No Filter, so search for it. Else test if the one passed is a valid one
1752  if( !rFilter.isEmpty() )
1753  {
1754  pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
1755  }
1756 
1757  if( nVersion )
1758  xMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
1759 
1760  if( !rPasswd.isEmpty() )
1761  xMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
1762 
1763  if( !pSfxFlt )
1764  aMatcher.DetectFilter( *xMed, pSfxFlt );
1765 
1766  if( pSfxFlt )
1767  {
1768  // We cannot do anything without a Filter
1769  xMed->SetFilter( pSfxFlt );
1770 
1771  // If the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
1772  SwDocShell *const pNew(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1773  xLockRef = pNew;
1774  xDocSh = static_cast<SfxObjectShell*>(xLockRef);
1775  if (xDocSh->DoLoad(xMed.release()))
1776  {
1777  return 2;
1778  }
1779  }
1780  }
1781 
1782  return 0;
1783 }
1784 
1785 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SfxViewFrame * GetViewFrame() const
void SetText(const OUString &aText)
#define FN_ABSTRACT_NEWDOC
Definition: cmdid.h:448
void Appear()
sal_Int32 GetValue() const
#define FN_REDLINE_ACCEPT_ALL
Definition: cmdid.h:150
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 HID_SEND_HTML_CTRL_PUSHBUTTON_OK
Definition: helpids.h:93
SAL_DLLPRIVATE void SubInitNew()
for InitNew and HtmlSourceMode.
Definition: docshini.cxx:615
virtual SfxObjectFactory & GetFactory() const =0
virtual void SetModified(bool=true) override
Definition: docsh2.cxx:1419
#define FN_REDLINE_REJECT_ALL
Definition: cmdid.h:151
#define FN_NEW_GLOBAL_DOC
Definition: cmdid.h:68
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
static SvxAutoCorrCfg & Get()
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
bool HasSourceSaved() const
Definition: srcview.hxx:82
bool IsMerge() const
Definition: shellio.hxx:131
SfxInPlaceClient * GetIPClient(const ::svt::EmbeddedObjectRef &xObjRef)
Definition: docsh2.cxx:1672
void SaveContent(const OUString &rTmpFile)
Definition: srcview.cxx:250
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
std::vector< svx::ClassificationResult > CollectParagraphClassification()
Definition: edfcol.cxx:1341
bool IsDefault() const
Definition: format.hxx:129
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem) override
Definition: docsh2.cxx:1379
#define HID_SEND_MASTER_CTRL_EDIT_FILEURL
Definition: helpids.h:89
ScriptDocument aDocument
static SfxClassificationPolicyType stringToPolicyType(std::u16string_view rType)
static SfxAbstractDialogFactory * Create()
OUString GetTitle(sal_uInt16 nMaxLen=0) const
void SetState(const SfxItemSet &rSet)
const OUString & GetFactoryName() const
static SwAutoCompleteWord & GetAutoCompleteWords()
Definition: doc.hxx:1537
void SetPageDescs(const bool bNew)
Definition: shellio.hxx:123
std::string GetValue
void UpdateFontList()
Definition: docshini.cxx:414
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
bool IsPageDescs() const
Definition: shellio.hxx:122
void ToggleLayoutMode(SwView *pView)
Definition: docsh2.cxx:154
SwNodeIndex nNode
Definition: pam.hxx:38
#define HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION
Definition: helpids.h:90
bool IsFrameFormats() const
Definition: shellio.hxx:119
ErrCode IgnoreWarning() const
SfxDispatcher * GetDispatcher()
static SfxViewFrame * LoadDocument(SfxObjectShell const &i_rDoc, SfxInterfaceId i_nViewId)
virtual void SetModified(bool bModified=true)
const OUString & GetName() const
virtual void SetModified()=0
Must be called manually at changes of format.
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void disposeAndClear()
void SetHeaderAttributesForSourceViewHack()
sal_Int64 n
css::uno::Reference< css::frame::XModel3 > GetModel() const
#define HID_SEND_MASTER_CTRL_LISTBOX_FILTER
Definition: helpids.h:87
Definition: doc.hxx:187
void ReloadFromHtml(const OUString &rStreamName, SwSrcView *pSrcView)
Re-read Doc from Html-source.
Definition: docsh2.cxx:1484
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
static void ConfigureEvent(const OUString &aName, const SvxMacro &, SfxObjectShell const *pObjSh)
#define STREAM_SEEK_TO_END
#define FN_ABSTRACT_STARIMPRESS
Definition: cmdid.h:449
sal_uInt64 Seek(sal_uInt64 nPos)
SwNode & GetNode() const
Definition: ndindex.hxx:119
SwEditWin & GetEditWin()
Definition: view.hxx:416
void Done(bool bRemove=false)
int SwFindDocShell(SfxObjectShellRef &xDocSh, SfxObjectShellLock &xLockRef, std::u16string_view 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:1687
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
Definition: shellio.cxx:731
static SfxObjectShell * Current()
void RecheckBrowseMode()
Definition: view0.cxx:171
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1749
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: fldwrap.cxx:79
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
SfxInPlaceClient * FindIPClient(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, vcl::Window *pObjParentWin) const
#define HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:99
void EndAllAction()
Definition: edws.cxx:97
bool IsInPrepareClose() const
SfxHintId GetId() const
#define RET_TEMPLATE_LOAD
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
virtual ErrCode ReadAt(sal_uInt64 nPos, void *pBuffer, std::size_t nCount, std::size_t *pRead) const
void SetTextFormats(const bool bNew)
Definition: shellio.hxx:126
SfxApplication * SfxGetpApp()
size_type size() const
Definition: docary.hxx:267
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
virtual bool PrepareClose(bool bUI=true)
void SetWatermark(const SfxWatermarkItem &rText)
Definition: edfcol.cxx:1606
static void CheckSpellChanges(bool bOnlineSpelling, bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags)
Definition: swmodul1.cxx:638
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
bool IsStorage()
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
Reader * ReadXML
Definition: fltini.cxx:46
constexpr auto SFX_INTERFACE_NONE
const SwView & GetView() const
Definition: wrtsh.hxx:437
RET_YES
virtual VclPtr< AbstractSwInsertAbstractDlg > CreateSwInsertAbstractDlg(weld::Window *pParent)=0
bool empty() const
Definition: docary.hxx:266
bool getBrowseMode() const
Definition: viewopt.hxx:472
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2115
const OUString & GetName() const
Definition: format.hxx:131
static bool IsFuzzing()
SfxFrame & GetFrame() const
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
weld::Window * GetFrameWeld() const
static SfxViewShell * Current()
Reader * ReadHTML
Definition: fltini.cxx:46
bool IsModified() const
Definition: srcview.hxx:67
SvxSwAutoFormatFlags & GetSwFlags()
void SetTransparency(const sal_Int16 nTransparency)
const SwTable & GetTable() const
Definition: node.hxx:506
SotClipboardFormatId
size_type size() const
SfxItemPool & GetPool() const
const editeng::SortedAutoCompleteStrings * m_pAutoCompleteList
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
virtual VclPtr< SfxAbstractTabDialog > CreateAutoCorrTabDialog(weld::Window *pParent, const SfxItemSet *pAttrSet)=0
DocumentType eType
bool IsModified() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
#define HID_SEND_HTML_CTRL_CONTROL_FILEVIEW
Definition: helpids.h:96
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pClipFormat, OUString *pLongUserName, sal_Int32 nFileFormat, bool bTemplate=false) const override
Definition: docsh2.cxx:1393
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:204
bool IsAtDocNodeSet() const
Definition: fmtcol.cxx:323
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void CheckDefaultPageFormat()
The html import sometimes overwrites the page sizes set in the page descriptions. ...
Definition: docdesc.cxx:985
void CheckChangedList(const editeng::SortedAutoCompleteStrings &rNewLst)
Definition: acmplwrd.cxx:340
SwgReaderOption & GetReaderOpt()
Definition: shellio.hxx:240
#define HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL
Definition: helpids.h:86
#define SOFFICE_FILEFORMAT_60
virtual FmFormShell * GetFormShell() override
Definition: view.hxx:578
static SW_DLLPUBLIC std::shared_ptr< const SfxFilter > GetFilterOfFormat(std::u16string_view rFormat, const SfxFilterContainer *pCnt=nullptr)
find for an internal format name the corresponding filter entry
Definition: iodetect.cxx:68
sal_uInt16 nAutoCmpltWordLen
SwDocShell(SfxObjectCreateMode eMode=SfxObjectCreateMode::EMBEDDED)
Doc is required for SO data exchange!
Definition: docshini.cxx:317
#define SW_MOD()
Definition: swmodule.hxx:255
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SfxDispatcher * GetDispatcher() const
int i
css::uno::Reference< css::io::XInputStream > & GetInputStream()
Definition: shellio.hxx:138
const SwPosition * GetPoint() const
Definition: pam.hxx:208
#define HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL
Definition: helpids.h:94
OUString const & GetURL() const
static SwSmartTagMgr & Get()
sal_uInt16 nAutoCmpltListLen
#define STREAM_SEEK_TO_BEGIN
static OUString GetEventName(GlobalEventId nID)
void SetColor(Color nColor)
SmartTagMgr * pSmartTagMgr
bool IsNumRules() const
Definition: shellio.hxx:128
SAL_DLLPRIVATE void RemoveLink()
Definition: docshini.cxx:429
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
void ReconnectDdeLink(SfxObjectShell &rServer)
SvxAutoCorrect * GetAutoCorrect()
SfxBindings & GetBindings()
virtual void AcceptAllRedline(bool bAcceptReject)=0
vector_type::size_type size_type
Definition: docary.hxx:222
const OUString & GetValue() const
void SetTitle(const OUString &rTitle)
#define HID_SEND_MASTER_CTRL_PUSHBUTTON_OK
Definition: helpids.h:85
void UpdateChildWindows()
Definition: docsh2.cxx:1449
bool SetMark(std::u16string_view rTheFragment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
virtual void Clear() override
const T * GetArg(sal_uInt16 nSlotId) const
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void SetPool(SfxItemPool *pNewPool)
#define SO3_SW_CLASSID_60
void ApplyParagraphClassification(std::vector< svx::ClassificationResult > aResult)
Apply the classification to the paragraph at cursor.
Definition: edfcol.cxx:1262
float u
void ClearHeaderAttributesForSourceViewHack()
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
virtual SAL_DLLPRIVATE std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rSet) override
Make DocInfo known to the Doc.
Definition: docsh2.cxx:134
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:225
bool HasBasic() const
SfxItemSet * GetItemSet() const
SortedAutoCompleteStrings createNonOwningCopy() const
void Execute(SfxRequest &)
Dispatcher.
Definition: docsh2.cxx:394
void SetLockWordLstLocked(bool bFlag)
Definition: acmplwrd.hxx:60
#define FN_SHADOWCURSOR
Definition: cmdid.h:525
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
Marks a node in the document model.
Definition: ndindex.hxx:30
const editeng::SortedAutoCompleteStrings & GetWordList() const
Definition: acmplwrd.hxx:67
bool HasName() const
#define HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION
Definition: helpids.h:98
void SetBufferSize(sal_uInt16 m_nBufSize)
OUString GetTemplateFileName() const
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
ColorTransparency
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
const XColorListRef & GetColorList() const
void SetClassification(const OUString &rName, SfxClassificationPolicyType eType)
Definition: edfcol.cxx:1066
void GetRTFWriter(std::u16string_view rFltName, const OUString &rBaseURL, WriterRef &xRet)
Definition: fltini.cxx:656
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
bool SetHTMLTemplate(SwDoc &rDoc)
Definition: shellio.cxx:907
bool IsTextFormats() const
Definition: shellio.hxx:125
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
const std::shared_ptr< const SfxFilter > & GetFilter() const
virtual void setPrinter(SfxPrinter *pP, bool bDeleteOld, bool bCallPrtDataChanged)=0
Set the printer at the document.
SfxViewShell * GetViewShell() const
virtual SAL_DLLPRIVATE void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Catch hint for DocInfo.
Definition: docsh2.cxx:234
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual sal_uInt16 SetPrinter(SfxPrinter *pNew, SfxPrinterChangeFlags nDiff=SFX_PRINTER_ALL) override
Definition: viewprt.cxx:97
SwDocShell * GetDocShell()
Definition: view.cxx:1132
bool IsReadOnly() const
bool m_IsRemovedInvisibleContent
whether SID_MAIL_PREPAREEXPORT removed content that SID_MAIL_EXPORT_FINISHED needs to restore ...
Definition: docsh.hxx:90
#define FN_OPEN_FILE
Definition: cmdid.h:69
void SetReturnValue(const SfxPoolItem &)
ErrCode LoadStylesFromFile(const OUString &rURL, SwgReaderOption &rOpt, bool bUnoCall)
Definition: docsh2.cxx:1589
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define HID_SEND_HTML_CTRL_EDIT_FILEURL
Definition: helpids.h:97
IDocumentDeviceAccess & getIDocumentDeviceAccess()
Definition: docshini.cxx:694
virtual ErrCode Stat(SvLockBytesStat *pStat) const
virtual void ReconnectDdeLink(SfxObjectShell &rServer) override
Definition: docsh2.cxx:1384
const OUString & GetWorkPath() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
#define HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:91
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
void SetMinWordLen(sal_uInt16 n)
Definition: acmplwrd.cxx:305
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
weld::Window * GetFrameWeld() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
static BasicManager * GetBasicManager()
#define HID_SEND_HTML_CTRL_LISTBOX_FILTER
Definition: helpids.h:95
void SetTemplateFlags(SfxTemplateFlags nSet)
SfxEventHintId GetEventId() const
#define ERRCODE_NONE
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
unsigned char sal_uInt8
void LockView(bool b)
Definition: viewsh.hxx:467
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:428
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
#define FN_OUTLINE_TO_CLIPBOARD
Definition: cmdid.h:72
std::size_t nSize
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: redlndlg.cxx:71
OUString aName
INetProtocol GetProtocol() const
#define FN_PRINT_LAYOUT
Definition: cmdid.h:173
RET_OK
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:176
SwWrtShell * m_pWrtShell
Definition: docsh.hxx:84
static VclPtr< reference_type > Create(Arg &&...arg)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
SfxTemplateFlags
static void ExecMethod(SfxBindings &rBindings, const OUString &rUIName)
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1929
const INetURLObject & GetURLObject() const
bool IsLockWordLstLocked() const
Definition: acmplwrd.hxx:59
void SetFont(const OUString &aFont)
bool HasDeletedRow() const
Definition: swtable.cxx:1575
Sequence< sal_Int8 > aSeq
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:421
SvStream & WriteChar(char nChar)
bool DoClose()
void SetMaxCount(editeng::SortedAutoCompleteStrings::size_type n)
Definition: acmplwrd.cxx:285
#define HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW
Definition: helpids.h:88
static void lcl_processCompatibleSfxHint(const uno::Reference< script::vba::XVBAEventProcessor > &xVbaEvents, const SfxHint &rHint)
Definition: docsh2.cxx:213
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
void SetNewDoc()
Optimizing UI.
Definition: edws.cxx:284
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
virtual SAL_DLLPRIVATE bool PrepareClose(bool bUI=true) override
Definition: docsh2.cxx:351
bool IsEnableSetModified() const
ErrCode GetError() const
virtual SfxObjectShell * GetObjectShell() override
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void AppendItem(const SfxPoolItem &)
#define SAL_WARN(area, stream)
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
bool IsAPI() const
const SwView * GetView() const
Definition: docsh.hxx:221
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SAL_DLLPRIVATE void AddLink()
Methods for access to doc.
Definition: docshini.cxx:395
virtual void DoFlushDocInfo() override
override to update text fields
Definition: docsh2.cxx:188
void EnableSetModified(bool bEnable=true)
virtual const SwRedlineTable & GetRedlineTable() const =0
void SetAngle(const sal_Int16 nAngle)
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *)
Definition: autofmt.cxx:2809
#define FN_REDLINE_SHOW
Definition: cmdid.h:129
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2172
void Ignore()
void SetFrameFormats(const bool bNew)
Definition: shellio.hxx:120
void SetY2KState(sal_uInt16 n)
void SetError(ErrCode rErr)
void EnableKillingFile(bool bEnable=true)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
bool IsViewLocked() const
Definition: viewsh.hxx:466
ErrCode DetectFilter(SfxMedium &rMedium, std::shared_ptr< const SfxFilter > &) const
BasicManager * GetBasicManager() const
#define FN_NEW_HTML_DOC
Definition: cmdid.h:74
Definition: view.hxx:144
SfxTemplateFlags GetTemplateFlags() const
#define SOFFICE_FILEFORMAT_8
void SetNewWindowAllowed(bool bSet)
static void CloseMethod(SfxBindings &rBindings)
void InvalidateAutoCompleteFlag()
Definition: doc.cxx:1180
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
#define FN_OUTLINE_TO_IMPRESS
Definition: cmdid.h:71
void SetMerge(const bool bNew)
Definition: shellio.hxx:132
void SetNumRules(const bool bNew)
Definition: shellio.hxx:129
void setStreamToLoadFrom(const css::uno::Reference< css::io::XInputStream > &xInputStream, bool bIsReadOnly)
css::uno::Reference< ooo::vba::word::XDocument > mxAutomationDocumentObject
Definition: docsh.hxx:95
SfxMedium * GetMedium() const