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