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