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