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::shared_ptr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
130 {
131  std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<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  const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
212  if ( !pSfxEventHint )
213  return;
214 
215  uno::Sequence< uno::Any > aArgs;
216  switch( pSfxEventHint->GetEventId() )
217  {
218  case SfxEventHintId::CreateDoc:
219  xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
220  break;
221  case SfxEventHintId::OpenDoc:
222  xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
223  break;
224  default: break;
225  }
226 }
227 
228 // Notification on DocInfo changes
230 {
231  if (!m_xDoc)
232  {
233  return ;
234  }
235 
236  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
237  m_xDoc->GetVbaEventProcessor();
238  if( xVbaEvents.is() )
239  lcl_processCompatibleSfxHint( xVbaEvents, rHint );
240 
241  if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
242  {
243  switch( pSfxEventHint->GetEventId() )
244  {
245  case SfxEventHintId::ActivateDoc:
246  case SfxEventHintId::CreateDoc:
247  case SfxEventHintId::OpenDoc:
248  {
249  uno::Sequence< css::uno::Any > aArgs;
250  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentChange", aArgs );
251  break;
252  }
253  default:
254  break;
255  }
256 
257  switch( pSfxEventHint->GetEventId() )
258  {
259  case SfxEventHintId::CreateDoc:
260  {
262  aDocument <<= mxAutomationDocumentObject;
263  uno::Sequence< uno::Any > aArgs(1);
264  aArgs[0] = aDocument;
265  SW_MOD()->CallAutomationApplicationEventSinks( "NewDocument", aArgs );
266  }
267  break;
268  case SfxEventHintId::OpenDoc:
269  {
271  aDocument <<= mxAutomationDocumentObject;
272  uno::Sequence< uno::Any > aArgs(1);
273  aArgs[0] = aDocument;
274  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentOpen", aArgs );
275  }
276  break;
277  default:
278  break;
279  }
280  }
281 
282  sal_uInt16 nAction = 0;
283  auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
284  if( pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished )
285  {
286  // #i38126# - own action id
287  nAction = 3;
288  }
289  else
290  {
291  // switch for more actions
292  if( rHint.GetId() == SfxHintId::TitleChanged)
293  {
294  if( GetMedium() )
295  nAction = 2;
296  }
297  }
298 
299  if( !nAction )
300  return;
301 
302  bool bUnlockView = true; //initializing prevents warning
303  if (m_pWrtShell)
304  {
305  bUnlockView = !m_pWrtShell->IsViewLocked();
306  m_pWrtShell->LockView( true ); //lock visible section
308  }
309  switch( nAction )
310  {
311  case 2:
312  m_xDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Filename )->UpdateFields();
313  break;
314  // #i38126# - own action for event LOADFINISHED
315  // in order to avoid a modified document.
316  // #i41679# - Also for the instance of <SwDoc>
317  // it has to be assured, that it's not modified.
318  // Perform the same as for action id 1, but disable <SetModified>.
319  case 3:
320  {
321  const bool bResetModified = IsEnableSetModified();
322  if ( bResetModified )
323  EnableSetModified( false );
324  // #i41679#
325  const bool bIsDocModified = m_xDoc->getIDocumentState().IsModified();
326  // TODO: is the ResetModified() below because of only the direct call from DocInfoChgd, or does UpdateFields() set it too?
327 
328  m_xDoc->getIDocumentStatistics().DocInfoChgd(false);
329 
330  // #i41679#
331  if ( !bIsDocModified )
332  m_xDoc->getIDocumentState().ResetModified();
333  if ( bResetModified )
335  }
336  break;
337  }
338 
339  if (m_pWrtShell)
340  {
342  if( bUnlockView )
343  m_pWrtShell->LockView( false );
344  }
345 }
346 
347 // Notification Close Doc
348 bool SwDocShell::PrepareClose( bool bUI )
349 {
350  bool bRet = SfxObjectShell::PrepareClose( bUI );
351 
352  // If we are going to close it at this point, let potential DocumentBeforeClose event handlers
353  // in Automation clients veto it.
354  if (bRet && m_xDoc && IsInPrepareClose())
355  {
357  aDocument <<= mxAutomationDocumentObject;
358 
359  uno::Sequence< uno::Any > aArgs(2);
360  // Arg 0: Document
361  aArgs[0] = aDocument;
362  // Arg 1: Cancel
363  aArgs[1] <<= false;
364 
365  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentBeforeClose", aArgs );
366 
367  // If the Cancel argument was set to True by an event handler, return false.
368  bool bCancel(false);
369  aArgs[1] >>= bCancel;
370  if (bCancel)
371  bRet = false;
372  }
373 
374  if( bRet )
375  EndListening( *this );
376 
377  if (m_xDoc && IsInPrepareClose())
378  {
379  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
380  m_xDoc->GetVbaEventProcessor();
381  if( xVbaEvents.is() )
382  {
383  using namespace com::sun::star::script::vba::VBAEventId;
384  uno::Sequence< uno::Any > aNoArgs;
385  xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aNoArgs );
386  }
387  }
388  return bRet;
389 }
390 
392 {
393  const SfxItemSet* pArgs = rReq.GetArgs();
394  const SfxPoolItem* pItem;
395  sal_uInt16 nWhich = rReq.GetSlot();
396  bool bDone = false;
397  switch ( nWhich )
398  {
399  case SID_AUTO_CORRECT_DLG:
400  {
403 
404  bool bOldLocked = rACW.IsLockWordLstLocked(),
405  bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
406 
407  rACW.SetLockWordLstLocked( true );
408 
410  pAFlags->m_pAutoCompleteList = &aTmpLst;
411 
412  SfxApplication* pApp = SfxGetpApp();
413  SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SfxCallMode::SYNCHRON, pApp->GetPool());
414  SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, true );
415  aAppReq.AppendItem(aSwOptions);
416 
417  pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
418 
420  aSet.Put( aSwOptions );
421 
422  const SfxPoolItem* pOpenSmartTagOptionsItem = nullptr;
423  if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, false, &pOpenSmartTagOptionsItem ) )
424  aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) );
425 
428  pDlg->Execute();
429  pDlg.disposeAndClear();
430 
431 
432  rACW.SetLockWordLstLocked( bOldLocked );
433 
435  rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
436  rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
437  if (pAFlags->m_pAutoCompleteList) // any changes?
438  {
439  rACW.CheckChangedList( aTmpLst );
440  // clear the temp WordList pointer
441  pAFlags->m_pAutoCompleteList = nullptr;
442  }
443 
444  if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
445  pAFlags->bAutoCmpltCollectWords )
446  {
447  // call on all Docs the idle formatter to start
448  // the collection of Words
449  for( SwDocShell *pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<SwDocShell>));
450  pDocSh;
451  pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetNext( *pDocSh, checkSfxObjectShell<SwDocShell> )) )
452  {
453  SwDoc* pTmp = pDocSh->GetDoc();
456  }
457  }
458  }
459  break;
460 
461  case SID_PRINTPREVIEW:
462  {
463  bool bSet = false;
464  bool bFound = false, bOnly = true;
465  SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this);
466  SfxViewShell* pViewShell = SfxViewShell::Current();
467  SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
468  bool bCurrent = typeid(SwPagePreview) == typeid( pViewShell );
469 
470  while( pTmpFrame ) // search Preview
471  {
472  if( typeid(SwView) == typeid( pTmpFrame->GetViewShell()) )
473  bOnly = false;
474  else if( typeid(SwPagePreview) == typeid( pTmpFrame->GetViewShell()))
475  {
476  pTmpFrame->GetFrame().Appear();
477  bFound = true;
478  }
479  if( bFound && !bOnly )
480  break;
481  pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this);
482  }
483 
484  if( pArgs && SfxItemState::SET ==
485  pArgs->GetItemState( SID_PRINTPREVIEW, false, &pItem ))
486  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
487  else
488  bSet = !bCurrent;
489 
490  sal_uInt16 nSlotId = 0;
491  if( bSet && !bFound ) // Nothing found, so create new Preview
492  nSlotId = SID_VIEWSHELL1;
493  else if( bFound && !bSet )
494  nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
495 
496  if( nSlotId )
497  {
498  // PagePreview in the WebDocShell
499  // is found under Id VIEWSHELL2.
500  if( dynamic_cast< const SwWebDocShell *>( this ) != nullptr && SID_VIEWSHELL1 == nSlotId )
501  nSlotId = SID_VIEWSHELL2;
502 
503  if( pCurrView && pCurrView->GetDocShell() == this )
504  pTmpFrame = pCurrView->GetViewFrame();
505  else
506  pTmpFrame = SfxViewFrame::GetFirst( this );
507 
508  if (pTmpFrame)
509  pTmpFrame->GetDispatcher()->Execute( nSlotId, SfxCallMode::ASYNCHRON );
510  }
511 
512  rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
513  }
514  break;
515  case SID_TEMPLATE_LOAD:
516  {
517  OUString aFileName;
518  static bool bText = true;
519  static bool bFrame = false;
520  static bool bPage = false;
521  static bool bNum = false;
522  static bool bMerge = false;
523  sal_uInt16 nRet = USHRT_MAX;
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  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<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  "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  "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:436
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:55
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:189
void SaveContent(const OUString &rTmpFile)
Definition: srcview.cxx:255
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
std::vector< svx::ClassificationResult > CollectParagraphClassification()
Definition: edfcol.cxx:1336
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:1528
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:149
#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:184
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:437
sal_uInt64 Seek(sal_uInt64 nPos)
SwEditWin & GetEditWin()
Definition: view.hxx:401
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:1744
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:398
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:1601
static void CheckSpellChanges(bool bOnlineSpelling, bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags)
Definition: swmodul1.cxx:631
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:454
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2013
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:1352
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:869
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:563
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: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:1257
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:129
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:391
void SetLockWordLstLocked(bool bFlag)
Definition: acmplwrd.hxx:60
#define FN_SHADOWCURSOR
Definition: cmdid.h:512
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:1061
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:229
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:1108
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:643
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
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: redlndlg.cxx:69
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: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:348
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: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:2803
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2070
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)