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