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