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