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