LibreOffice Module sw (master)  1
docsh2.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <com/sun/star/drawing/ModuleDispatcher.hpp>
23 #include <com/sun/star/frame/DispatchHelper.hpp>
24 #include <ooo/vba/word/XDocument.hpp>
25 #include <comphelper/fileformat.h>
27 
28 #include <sal/log.hxx>
29 #include <edtwin.hxx>
30 #include <tools/urlobj.hxx>
31 #include <unotools/tempfile.hxx>
32 #include <unotools/configmgr.hxx>
33 #include <vcl/errinf.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/weld.hxx>
36 #include <svl/eitem.hxx>
37 #include <svl/macitem.hxx>
38 #include <svl/zforlist.hxx>
39 #include <unotools/pathoptions.hxx>
40 #include <vcl/transfer.hxx>
41 #include <sfx2/dinfdlg.hxx>
42 #include <sfx2/request.hxx>
43 #include <sfx2/dispatch.hxx>
44 #include <sfx2/new.hxx>
46 #include <sfx2/filedlghelper.hxx>
47 #include <sfx2/printer.hxx>
48 #include <sfx2/evntconf.hxx>
49 #include <sfx2/docfile.hxx>
50 #include <sfx2/docfilt.hxx>
51 #include <svx/dialogs.hrc>
52 #include <svx/drawitem.hxx>
53 #include <editeng/svxacorr.hxx>
54 #include <svx/fmshell.hxx>
55 #include <sfx2/linkmgr.hxx>
57 #include <sfx2/watermarkitem.hxx>
58 
59 #include <svtools/htmlcfg.hxx>
60 #include <svx/ofaitem.hxx>
61 #include <SwSmartTagMgr.hxx>
62 #include <sfx2/app.hxx>
63 #include <basic/sbstar.hxx>
64 #include <basic/basmgr.hxx>
65 #include <comphelper/classids.hxx>
66 #include <fmtcol.hxx>
67 #include <view.hxx>
68 #include <docsh.hxx>
69 #include <docary.hxx>
70 #include <wrtsh.hxx>
71 #include <fldbas.hxx>
72 #include <viewopt.hxx>
73 #include <globdoc.hxx>
74 #include <fldwrap.hxx>
75 #include <redlndlg.hxx>
76 #include <doc.hxx>
77 #include <IDocumentUndoRedo.hxx>
82 #include <IDocumentStatistics.hxx>
85 #include <IDocumentState.hxx>
86 #include <shellio.hxx>
87 #include <pview.hxx>
88 #include <srcview.hxx>
89 #include <wdocsh.hxx>
90 #include <unotxdoc.hxx>
91 #include <acmplwrd.hxx>
92 #include <swmodule.hxx>
93 #include <unobaseclass.hxx>
94 #include <swwait.hxx>
95 #include <swcli.hxx>
96 
97 #include <cmdid.h>
98 #include <helpids.h>
99 #include <strings.hrc>
100 #include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
101 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
102 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
103 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
104 #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
105 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
106 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
107 #include <com/sun/star/script/vba/VBAEventId.hpp>
108 #include <editeng/acorrcfg.hxx>
109 #include <officecfg/Office/Security.hxx>
110 #include <officecfg/Office/Common.hxx>
111 
112 #include <sfx2/fcontnr.hxx>
114 #include <svtools/embedhlp.hxx>
115 
116 #include <swabstdlg.hxx>
117 #include <watermarkdialog.hxx>
118 
119 #include <ndtxt.hxx>
120 #include <iodetect.hxx>
121 
122 #include <memory>
123 
124 using namespace ::com::sun::star::ui::dialogs;
125 using namespace ::com::sun::star::lang;
126 using namespace ::com::sun::star::uno;
127 using namespace ::com::sun::star;
128 using namespace ::sfx2;
129 
130 // create DocInfo (virtual)
131 std::shared_ptr<SfxDocumentInfoDialog> SwDocShell::CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet)
132 {
133  std::shared_ptr<SfxDocumentInfoDialog> xDlg = std::make_shared<SfxDocumentInfoDialog>(pParent, rSet);
134  //only with statistics, when this document is being shown, not
135  //from within the Doc-Manager
136  SwDocShell* pDocSh = static_cast<SwDocShell*>( SfxObjectShell::Current());
137  if( pDocSh == this )
138  {
139  //Not for SourceView.
141  if ( pVSh && dynamic_cast< const SwSrcView *>( pVSh ) == nullptr )
142  {
144  xDlg->AddFontTabPage();
145  xDlg->AddTabPage("writerstats", SwResId(STR_DOC_STAT), pFact->GetTabPageCreatorFunc(RID_SW_TP_DOC_STAT));
146  }
147  }
148  return xDlg;
149 }
150 
152 {
153  OSL_ENSURE( pView, "SwDocShell::ToggleLayoutMode, pView is null." );
154 
155  const SwViewOption& rViewOptions = *pView->GetWrtShell().GetViewOptions();
156 
157  //TODO: Should HideWhitespace flag be saved in the document settings?
159  UpdateFontList(); // Why is this necessary here?
160 
162  if( !GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) )
163  pView->SetPrinter( GetDoc()->getIDocumentDeviceAccess().getPrinter( false ), SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP );
165  SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this, false);
166  while (pTmpFrame)
167  {
168  if( pTmpFrame != pView->GetViewFrame() )
169  {
170  pTmpFrame->DoClose();
171  pTmpFrame = SfxViewFrame::GetFirst(this, false);
172  }
173  else
174  pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this, false);
175  }
176 
177  pView->GetWrtShell().InvalidateLayout(true);
178 
179  pView->RecheckBrowseMode();
180 
181  pView->SetNewWindowAllowed(!rViewOptions.getBrowseMode());
182 }
183 
184 // update text fields on document properties changes
186 {
187  if (!m_xDoc)
188  return;
189 
190  bool bUnlockView(true);
191  if (m_pWrtShell)
192  {
193  bUnlockView = !m_pWrtShell->IsViewLocked();
194  m_pWrtShell->LockView( true ); // lock visible section
196  }
197 
198  m_xDoc->getIDocumentStatistics().DocInfoChgd(IsEnableSetModified());
199 
200  if (m_pWrtShell)
201  {
203  if (bUnlockView)
204  {
205  m_pWrtShell->LockView( false );
206  }
207  }
208 }
209 
210 static void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint )
211 {
212  using namespace com::sun::star::script::vba::VBAEventId;
213  const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
214  if ( !pSfxEventHint )
215  return;
216 
217  uno::Sequence< uno::Any > aArgs;
218  switch( pSfxEventHint->GetEventId() )
219  {
220  case SfxEventHintId::CreateDoc:
221  xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs );
222  break;
223  case SfxEventHintId::OpenDoc:
224  xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs );
225  break;
226  default: break;
227  }
228 }
229 
230 // Notification on DocInfo changes
232 {
233  if (!m_xDoc)
234  {
235  return ;
236  }
237 
238  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
239  m_xDoc->GetVbaEventProcessor();
240  if( xVbaEvents.is() )
241  lcl_processCompatibleSfxHint( xVbaEvents, rHint );
242 
243  if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
244  {
245  switch( pSfxEventHint->GetEventId() )
246  {
247  case SfxEventHintId::ActivateDoc:
248  case SfxEventHintId::CreateDoc:
249  case SfxEventHintId::OpenDoc:
250  {
251  uno::Sequence< css::uno::Any > aArgs;
252  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentChange", aArgs );
253  break;
254  }
255  default:
256  break;
257  }
258 
259  switch( pSfxEventHint->GetEventId() )
260  {
261  case SfxEventHintId::CreateDoc:
262  {
264  aDocument <<= mxAutomationDocumentObject;
265  uno::Sequence< uno::Any > aArgs(1);
266  aArgs[0] = aDocument;
267  SW_MOD()->CallAutomationApplicationEventSinks( "NewDocument", aArgs );
268  }
269  break;
270  case SfxEventHintId::OpenDoc:
271  {
273  aDocument <<= mxAutomationDocumentObject;
274  uno::Sequence< uno::Any > aArgs(1);
275  aArgs[0] = aDocument;
276  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentOpen", aArgs );
277  }
278  break;
279  default:
280  break;
281  }
282  }
283 
284  sal_uInt16 nAction = 0;
285  auto pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
286  if( pEventHint && pEventHint->GetEventId() == SfxEventHintId::LoadFinished )
287  {
288  // #i38126# - own action id
289  nAction = 3;
290  }
291  else
292  {
293  // switch for more actions
294  if( rHint.GetId() == SfxHintId::TitleChanged)
295  {
296  if( GetMedium() )
297  nAction = 2;
298  }
299  }
300 
301  if( !nAction )
302  return;
303 
304  bool bUnlockView = true; //initializing prevents warning
305  if (m_pWrtShell)
306  {
307  bUnlockView = !m_pWrtShell->IsViewLocked();
308  m_pWrtShell->LockView( true ); //lock visible section
310  }
311  switch( nAction )
312  {
313  case 2:
314  m_xDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Filename )->UpdateFields();
315  break;
316  // #i38126# - own action for event LOADFINISHED
317  // in order to avoid a modified document.
318  // #i41679# - Also for the instance of <SwDoc>
319  // it has to be assured, that it's not modified.
320  // Perform the same as for action id 1, but disable <SetModified>.
321  case 3:
322  {
323  const bool bResetModified = IsEnableSetModified();
324  if ( bResetModified )
325  EnableSetModified( false );
326  // #i41679#
327  const bool bIsDocModified = m_xDoc->getIDocumentState().IsModified();
328  // TODO: is the ResetModified() below because of only the direct call from DocInfoChgd, or does UpdateFields() set it too?
329 
330  m_xDoc->getIDocumentStatistics().DocInfoChgd(false);
331 
332  // #i41679#
333  if ( !bIsDocModified )
334  m_xDoc->getIDocumentState().ResetModified();
335  if ( bResetModified )
337  }
338  break;
339  }
340 
341  if (m_pWrtShell)
342  {
344  if( bUnlockView )
345  m_pWrtShell->LockView( false );
346  }
347 }
348 
349 // Notification Close Doc
350 bool SwDocShell::PrepareClose( bool bUI )
351 {
352  bool bRet = SfxObjectShell::PrepareClose( bUI );
353 
354  // If we are going to close it at this point, let potential DocumentBeforeClose event handlers
355  // in Automation clients veto it.
356  if (bRet && m_xDoc && IsInPrepareClose())
357  {
359  aDocument <<= mxAutomationDocumentObject;
360 
361  uno::Sequence< uno::Any > aArgs(2);
362  // Arg 0: Document
363  aArgs[0] = aDocument;
364  // Arg 1: Cancel
365  aArgs[1] <<= false;
366 
367  SW_MOD()->CallAutomationApplicationEventSinks( "DocumentBeforeClose", aArgs );
368 
369  // If the Cancel argument was set to True by an event handler, return false.
370  bool bCancel(false);
371  aArgs[1] >>= bCancel;
372  if (bCancel)
373  bRet = false;
374  }
375 
376  if( bRet )
377  EndListening( *this );
378 
379  if (m_xDoc && IsInPrepareClose())
380  {
381  uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents =
382  m_xDoc->GetVbaEventProcessor();
383  if( xVbaEvents.is() )
384  {
385  using namespace com::sun::star::script::vba::VBAEventId;
386  uno::Sequence< uno::Any > aNoArgs;
387  xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aNoArgs );
388  }
389  }
390  return bRet;
391 }
392 
394 {
395  const SfxItemSet* pArgs = rReq.GetArgs();
396  const SfxPoolItem* pItem;
397  sal_uInt16 nWhich = rReq.GetSlot();
398  bool bDone = false;
399  switch ( nWhich )
400  {
401  case SID_AUTO_CORRECT_DLG:
402  {
405 
406  bool bOldLocked = rACW.IsLockWordLstLocked(),
407  bOldAutoCmpltCollectWords = pAFlags->bAutoCmpltCollectWords;
408 
409  rACW.SetLockWordLstLocked( true );
410 
412  pAFlags->m_pAutoCompleteList = &aTmpLst;
413 
414  SfxApplication* pApp = SfxGetpApp();
415  SfxRequest aAppReq(SID_AUTO_CORRECT_DLG, SfxCallMode::SYNCHRON, pApp->GetPool());
416  SfxBoolItem aSwOptions( SID_AUTO_CORRECT_DLG, true );
417  aAppReq.AppendItem(aSwOptions);
418 
419  pAFlags->pSmartTagMgr = &SwSmartTagMgr::Get();
420 
421  SfxItemSet aSet( pApp->GetPool(), svl::Items<SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG, SID_OPEN_SMARTTAGOPTIONS, SID_OPEN_SMARTTAGOPTIONS> );
422  aSet.Put( aSwOptions );
423 
424  const SfxPoolItem* pOpenSmartTagOptionsItem = nullptr;
425  if( pArgs && SfxItemState::SET == pArgs->GetItemState( SID_OPEN_SMARTTAGOPTIONS, false, &pOpenSmartTagOptionsItem ) )
426  aSet.Put( *static_cast<const SfxBoolItem*>(pOpenSmartTagOptionsItem) );
427 
430  pDlg->Execute();
431  pDlg.disposeAndClear();
432 
433 
434  rACW.SetLockWordLstLocked( bOldLocked );
435 
437  rACW.SetMinWordLen( pAFlags->nAutoCmpltWordLen );
438  rACW.SetMaxCount( pAFlags->nAutoCmpltListLen );
439  if (pAFlags->m_pAutoCompleteList) // any changes?
440  {
441  rACW.CheckChangedList( aTmpLst );
442  // clear the temp WordList pointer
443  pAFlags->m_pAutoCompleteList = nullptr;
444  }
445 
446  if( !bOldAutoCmpltCollectWords && bOldAutoCmpltCollectWords !=
447  pAFlags->bAutoCmpltCollectWords )
448  {
449  // call on all Docs the idle formatter to start
450  // the collection of Words
451  for( SwDocShell *pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<SwDocShell>));
452  pDocSh;
453  pDocSh = static_cast<SwDocShell*>(SfxObjectShell::GetNext( *pDocSh, checkSfxObjectShell<SwDocShell> )) )
454  {
455  SwDoc* pTmp = pDocSh->GetDoc();
458  }
459  }
460  }
461  break;
462 
463  case SID_PRINTPREVIEW:
464  {
465  bool bSet = false;
466  bool bFound = false, bOnly = true;
467  SfxViewFrame *pTmpFrame = SfxViewFrame::GetFirst(this);
468  SfxViewShell* pViewShell = SfxViewShell::Current();
469  SwView* pCurrView = dynamic_cast< SwView *> ( pViewShell );
470  bool bCurrent = typeid(SwPagePreview) == typeid( pViewShell );
471 
472  while( pTmpFrame ) // search Preview
473  {
474  if( typeid(SwView) == typeid( pTmpFrame->GetViewShell()) )
475  bOnly = false;
476  else if( typeid(SwPagePreview) == typeid( pTmpFrame->GetViewShell()))
477  {
478  pTmpFrame->GetFrame().Appear();
479  bFound = true;
480  }
481  if( bFound && !bOnly )
482  break;
483  pTmpFrame = SfxViewFrame::GetNext(*pTmpFrame, this);
484  }
485 
486  if( pArgs && SfxItemState::SET ==
487  pArgs->GetItemState( SID_PRINTPREVIEW, false, &pItem ))
488  bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
489  else
490  bSet = !bCurrent;
491 
492  sal_uInt16 nSlotId = 0;
493  if( bSet && !bFound ) // Nothing found, so create new Preview
494  nSlotId = SID_VIEWSHELL1;
495  else if( bFound && !bSet )
496  nSlotId = bOnly ? SID_VIEWSHELL0 : SID_VIEWSHELL1;
497 
498  if( nSlotId )
499  {
500  // PagePreview in the WebDocShell
501  // is found under Id VIEWSHELL2.
502  if( dynamic_cast< const SwWebDocShell *>( this ) != nullptr && SID_VIEWSHELL1 == nSlotId )
503  nSlotId = SID_VIEWSHELL2;
504 
505  if( pCurrView && pCurrView->GetDocShell() == this )
506  pTmpFrame = pCurrView->GetViewFrame();
507  else
508  pTmpFrame = SfxViewFrame::GetFirst( this );
509 
510  if (pTmpFrame)
511  pTmpFrame->GetDispatcher()->Execute( nSlotId, SfxCallMode::ASYNCHRON );
512  }
513 
514  rReq.SetReturnValue(SfxBoolItem(SID_PRINTPREVIEW, bSet ));
515  }
516  break;
517  case SID_TEMPLATE_LOAD:
518  {
519  OUString aFileName;
520  static bool bText = true;
521  static bool bFrame = false;
522  static bool bPage = false;
523  static bool bNum = false;
524  static bool bMerge = false;
525 
526  SfxTemplateFlags nFlags = bFrame ? SfxTemplateFlags::LOAD_FRAME_STYLES : SfxTemplateFlags::NONE;
527  if(bPage)
528  nFlags |= SfxTemplateFlags::LOAD_PAGE_STYLES;
529  if(bNum)
530  nFlags |= SfxTemplateFlags::LOAD_NUM_STYLES;
531  if(nFlags == SfxTemplateFlags::NONE || bText)
532  nFlags |= SfxTemplateFlags::LOAD_TEXT_STYLES;
533  if(bMerge)
534  nFlags |= SfxTemplateFlags::MERGE_STYLES;
535 
536  if ( pArgs )
537  {
538  const SfxStringItem* pTemplateItem = rReq.GetArg<SfxStringItem>(SID_TEMPLATE_NAME);
539  if ( pTemplateItem )
540  {
541  aFileName = pTemplateItem->GetValue();
542  const SfxInt32Item* pFlagsItem = rReq.GetArg<SfxInt32Item>(SID_TEMPLATE_LOAD);
543  if ( pFlagsItem )
544  nFlags = static_cast<SfxTemplateFlags>(o3tl::narrowing<sal_uInt16>(pFlagsItem->GetValue()));
545  }
546  }
547 
548  if ( aFileName.isEmpty() )
549  {
550  SfxNewFileDialog aNewFileDlg(GetView()->GetFrameWeld(), SfxNewFileDialogMode::LoadTemplate);
551  aNewFileDlg.SetTemplateFlags(nFlags);
552 
553  sal_uInt16 nRet = aNewFileDlg.run();
554  if(RET_TEMPLATE_LOAD == nRet)
555  {
556  FileDialogHelper aDlgHelper(TemplateDescription::FILEOPEN_SIMPLE,
557  FileDialogFlags::NONE, GetView()->GetFrameWeld());
558  aDlgHelper.SetContext(FileDialogHelper::WriterLoadTemplate);
559  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
560 
561  SfxObjectFactory &rFact = GetFactory();
562  SfxFilterMatcher aMatcher( rFact.GetFactoryName() );
563  SfxFilterMatcherIter aIter( aMatcher );
564  std::shared_ptr<const SfxFilter> pFlt = aIter.First();
565  while( pFlt )
566  {
567  // --> OD #i117339#
568  if( pFlt && pFlt->IsAllowedAsTemplate() &&
569  ( pFlt->GetUserData() == "CXML" ||
570  pFlt->GetUserData() == "CXMLV" ) )
571  {
572  const OUString sWild = pFlt->GetWildcard().getGlob();
573  xFP->appendFilter( pFlt->GetUIName(), sWild );
574  }
575  pFlt = aIter.Next();
576  }
577  bool bWeb = dynamic_cast< SwWebDocShell *>( this ) != nullptr;
578  std::shared_ptr<const SfxFilter> pOwnFlt =
579  SwDocShell::Factory().GetFilterContainer()->
580  GetFilter4FilterName("writer8");
581 
582  // make sure the default file format is also available
583  if(bWeb)
584  {
585  const OUString sWild = pOwnFlt->GetWildcard().getGlob();
586  xFP->appendFilter( pOwnFlt->GetUIName(), sWild );
587  }
588 
589  bool bError = false;
590  // catch exception if wrong filter is selected - should not happen anymore
591  try
592  {
593  xFP->setCurrentFilter( pOwnFlt->GetUIName() );
594  }
595  catch (const uno::Exception&)
596  {
597  bError = true;
598  }
599 
600  if( !bError && ERRCODE_NONE == aDlgHelper.Execute() )
601  {
602  aFileName = xFP->getSelectedFiles().getConstArray()[0];
603  }
604  }
605  else if( RET_OK == nRet)
606  {
607  aFileName = aNewFileDlg.GetTemplateFileName();
608  }
609 
610  nFlags = aNewFileDlg.GetTemplateFlags();
611  rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aFileName ) );
612  rReq.AppendItem( SfxInt32Item( SID_TEMPLATE_LOAD, static_cast<tools::Long>(nFlags) ) );
613  }
614 
615  if( !aFileName.isEmpty() )
616  {
617  SwgReaderOption aOpt;
618  bText = bool(nFlags & SfxTemplateFlags::LOAD_TEXT_STYLES );
619  aOpt.SetTextFormats(bText);
620  bFrame = bool(nFlags & SfxTemplateFlags::LOAD_FRAME_STYLES);
621  aOpt.SetFrameFormats(bFrame);
622  bPage = bool(nFlags & SfxTemplateFlags::LOAD_PAGE_STYLES );
623  aOpt.SetPageDescs(bPage);
624  bNum = bool(nFlags & SfxTemplateFlags::LOAD_NUM_STYLES );
625  aOpt.SetNumRules(bNum);
626  //different meaning between SFX_MERGE_STYLES and aOpt.SetMerge!
627  bMerge = bool(nFlags & SfxTemplateFlags::MERGE_STYLES);
628  aOpt.SetMerge( !bMerge );
629 
630  SetError(LoadStylesFromFile(aFileName, aOpt, false));
631  if ( !GetError() )
632  rReq.Done();
633  }
634  }
635  break;
636  case SID_SOURCEVIEW:
637  {
638  SfxViewShell* pViewShell = GetView()
639  ? static_cast<SfxViewShell*>(GetView())
641  SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
642  SwSrcView* pSrcView = dynamic_cast< SwSrcView *>( pViewShell );
643  if(!pSrcView)
644  {
645  // 3 possible state:
646  // 1 - file unsaved -> save as HTML
647  // 2 - file modified and HTML filter active -> save
648  // 3 - file saved in non-HTML -> QueryBox to save as HTML
649  std::shared_ptr<const SfxFilter> pHtmlFlt =
651  u"HTML",
652  SwWebDocShell::Factory().GetFilterContainer() );
653  bool bLocalHasName = HasName();
654  if(bLocalHasName)
655  {
656  //check for filter type
657  std::shared_ptr<const SfxFilter> pFlt = GetMedium()->GetFilter();
658  if(!pFlt || pFlt->GetUserData() != pHtmlFlt->GetUserData())
659  {
660  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pViewFrame->GetFrameWeld(), "modules/swriter/ui/saveashtmldialog.ui"));
661  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("SaveAsHTMLDialog"));
662  if (RET_YES == xQuery->run())
663  bLocalHasName = false;
664  else
665  break;
666  }
667  }
668  if(!bLocalHasName)
669  {
670  FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION,
671  FileDialogFlags::NONE,
672  GetView()->GetFrameWeld());
673  aDlgHelper.SetContext(FileDialogHelper::WriterSaveHTML);
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  aDlgHelper.SetContext(FileDialogHelper::WriterNewHTMLGlobalDoc);
930 
931  const sal_Int16 nControlIds[] = {
932  CommonFilePickerElementIds::PUSHBUTTON_OK,
933  CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
934  CommonFilePickerElementIds::LISTBOX_FILTER,
935  CommonFilePickerElementIds::CONTROL_FILEVIEW,
936  CommonFilePickerElementIds::EDIT_FILEURL,
937  ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
938  ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
939  0
940  };
941 
942  if (bCreateHtml)
943  {
944  const char* aHTMLHelpIds[] =
945  {
953  ""
954  };
955  aDlgHelper.SetControlHelpIds( nControlIds, aHTMLHelpIds );
956  }
957  else
958  {
959  const char* aMasterHelpIds[] =
960  {
968  ""
969  };
970  aDlgHelper.SetControlHelpIds( nControlIds, aMasterHelpIds );
971  }
972  uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
973 
974  std::shared_ptr<const SfxFilter> pFlt;
975  const char* pStrId;
976 
977  if( bCreateHtml )
978  {
979  // for HTML there is only one filter!!
981  u"HTML",
982  SwWebDocShell::Factory().GetFilterContainer() );
983  pStrId = STR_LOAD_HTML_DOC;
984  }
985  else
986  {
987  // for Global-documents we now only offer the current one.
988  pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
989  GetFilter4Extension( "odm" );
990  pStrId = STR_LOAD_GLOBAL_DOC;
991  }
992 
993  if( pFlt )
994  {
995  const OUString sWild = pFlt->GetWildcard().getGlob();
996  xFP->appendFilter( pFlt->GetUIName(), sWild );
997  try
998  {
999  xFP->setCurrentFilter( pFlt->GetUIName() ) ;
1000  }
1001  catch (const uno::Exception&)
1002  {
1003  bError = true;
1004  }
1005  }
1006  if(!bError)
1007  {
1008  uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
1009 
1010  bool bOutline[MAXLEVEL] = {false};
1011  const SwOutlineNodes& rOutlNds = m_xDoc->GetNodes().GetOutLineNds();
1012  for( size_t n = 0; n < rOutlNds.size(); ++n )
1013  {
1014  const int nLevel = rOutlNds[n]->GetTextNode()->GetAttrOutlineLevel();
1015  if( nLevel > 0 && ! bOutline[nLevel-1] )
1016  {
1017  bOutline[nLevel-1] = true;
1018  }
1019  }
1020 
1021  const sal_uInt16 nStyleCount = m_xDoc->GetTextFormatColls()->size();
1022  Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
1023  OUString* pEntries = aListBoxEntries.getArray();
1024  sal_Int32 nIdx = 0 ;
1025 
1026  OUString sOutline( SwResId(STR_FDLG_OUTLINE_LEVEL) );
1027  for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
1028  {
1029  if( bOutline[i] )
1030  pEntries[nIdx++] = sOutline + OUString::number( i+1 );
1031  }
1032 
1033  OUString sStyle( SwResId(STR_FDLG_STYLE) );
1034  for(sal_uInt16 i = 0; i < nStyleCount; ++i)
1035  {
1036  SwTextFormatColl &rTextColl = *(*m_xDoc->GetTextFormatColls())[ i ];
1037  if( !rTextColl.IsDefault() && rTextColl.IsAtDocNodeSet() )
1038  {
1039  pEntries[nIdx++] = sStyle + rTextColl.GetName();
1040  }
1041  }
1042 
1043  aListBoxEntries.realloc(nIdx);
1044  sal_Int16 nSelect = 0;
1045 
1046  try
1047  {
1048  Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get());
1049 
1050  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1051  ListboxControlActions::ADD_ITEMS , aTemplates );
1052  Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get());
1053  xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1054  ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
1055  xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1056  SwResId( STR_FDLG_TEMPLATE_NAME ));
1057  }
1058  catch (const Exception&)
1059  {
1060  OSL_FAIL("control access failed");
1061  }
1062 
1063  xFP->setTitle(SwResId(pStrId));
1064  SvtPathOptions aPathOpt;
1065  xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
1066  if( ERRCODE_NONE == aDlgHelper.Execute())
1067  {
1068  aFileName = xFP->getSelectedFiles().getConstArray()[0];
1069  Any aTemplateValue = xCtrlAcc->getValue(
1070  ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1071  ListboxControlActions::GET_SELECTED_ITEM );
1072  OUString sTmpl;
1073  aTemplateValue >>= sTmpl;
1074 
1075  OUString aStyle(SwResId(STR_FDLG_STYLE));
1076  OUString aOutline(SwResId(STR_FDLG_OUTLINE_LEVEL));
1077 
1078  if ( sTmpl.startsWith(aStyle) )
1079  {
1080  aTemplateName = sTmpl.copy( aStyle.getLength() ); //get string behind "Style: "
1081  }
1082  else if ( sTmpl.startsWith(aOutline) )
1083  {
1084  nTemplateOutlineLevel = sTmpl.copy(aOutline.getLength()).toInt32(); //get string behind "Outline: Level ";
1085  bCreateByOutlineLevel = true;
1086  }
1087 
1088  if ( !aFileName.isEmpty() )
1089  {
1090  rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
1091  if( !aTemplateName.isEmpty() )
1092  rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
1093  }
1094  }
1095  }
1096  }
1097 
1098  if( !aFileName.isEmpty() )
1099  {
1100  if( PrepareClose( false ) )
1101  {
1102  SwWait aWait( *this, true );
1103 
1104  if ( bCreateByOutlineLevel )
1105  {
1106  bDone = bCreateHtml
1107  ? m_xDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
1108  : m_xDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
1109  }
1110  else
1111  {
1112  const SwTextFormatColl* pSplitColl = nullptr;
1113  if ( !aTemplateName.isEmpty() )
1114  pSplitColl = m_xDoc->FindTextFormatCollByName(aTemplateName);
1115  bDone = bCreateHtml
1116  ? m_xDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1117  : m_xDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1118  }
1119  if( bDone )
1120  {
1121  SfxStringItem aName( SID_FILE_NAME, aFileName );
1122  SfxStringItem aReferer(SID_REFERER, OUString());
1123  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1124  while(pViewShell)
1125  {
1126  //search for the view that created the call
1127  if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
1128  {
1129  SfxFrameItem aFrameItem( SID_DOCFRAME, pViewShell->GetViewFrame() );
1130  SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
1131  pDispatch->ExecuteList(SID_OPENDOC,
1132  SfxCallMode::ASYNCHRON,
1133  { &aName, &aReferer, &aFrameItem });
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(ColorTransparency, 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()->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  //#59620# HasBasic() shows, that there already is a BasicManager at the DocShell.
1457  // That was always generated in HTML-Import, when there are
1458  // Macros in the source code.
1460  {
1461  BasicManager *pBasicMan = GetBasicManager();
1462  if( pBasicMan && (pBasicMan != SfxApplication::GetBasicManager()) )
1463  {
1464  sal_uInt16 nLibCount = pBasicMan->GetLibCount();
1465  while( nLibCount )
1466  {
1467  StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
1468  if( pBasic )
1469  {
1470  // Notify the IDE
1471  SfxUnoAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, makeAny( GetModel() ) );
1472  OUString aLibName( pBasic->GetName() );
1473  SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
1474  pSrcView->GetViewFrame()->GetDispatcher()->ExecuteList(
1475  SID_BASICIDE_LIBREMOVED,
1476  SfxCallMode::SYNCHRON,
1477  { &aShellItem, &aLibNameItem });
1478 
1479  // Only the modules are deleted from the standard-lib
1480  if( nLibCount )
1481  pBasicMan->RemoveLib( nLibCount, true );
1482  else
1483  pBasic->Clear();
1484  }
1485  }
1486 
1487  OSL_ENSURE( pBasicMan->GetLibCount() <= 1,
1488  "Deleting Basics didn't work" );
1489  }
1490  }
1491 #endif
1492  bool bWasBrowseMode = m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
1493  RemoveLink();
1494 
1495  // now also the UNO-Model has to be informed about the new Doc #51535#
1496  uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
1497  text::XTextDocument* pxDoc = xDoc.get();
1498  static_cast<SwXTextDocument*>(pxDoc)->InitNewDoc();
1499 
1500  AddLink();
1501  //#116402# update font list when new document is created
1502  UpdateFontList();
1503  m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bWasBrowseMode);
1504  pSrcView->SetPool(&GetPool());
1505 
1506  const OUString& rMedname = GetMedium()->GetName();
1507 
1508  // The HTML template still has to be set
1509  SetHTMLTemplate( *GetDoc() ); //Styles from HTML.vor
1510 
1511  SfxViewShell* pViewShell = GetView() ? static_cast<SfxViewShell*>(GetView())
1513  SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
1514  pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON );
1515 
1516  SubInitNew();
1517 
1518  SfxMedium aMed( rStreamName, StreamMode::READ );
1519  // #i48748# - use class <SwReloadFromHtmlReader>, because
1520  // the base URL has to be set to the filename of the document <rMedname>
1521  // and not to the base URL of the temporary file <aMed> in order to get
1522  // the URLs of the linked graphics correctly resolved.
1523  SwReloadFromHtmlReader aReader( aMed, rMedname, m_xDoc.get() );
1524 
1525  aReader.Read( *ReadHTML );
1526 
1527  const SwView* pCurrView = GetView();
1528  //in print layout the first page(s) may have been formatted as a mix of browse
1529  //and print layout
1530  if(!bWasBrowseMode && pCurrView)
1531  {
1532  SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
1533  if( rWrtSh.GetLayout())
1534  rWrtSh.InvalidateLayout( true );
1535  }
1536 
1537  // Take HTTP-Header-Attributes over into the DocInfo again.
1538  // The Base-URL doesn't matter here because TLX uses the one from the document
1539  // for absolutization.
1541 
1542  if(bModified && !IsReadOnly())
1543  SetModified();
1544  else
1545  m_xDoc->getIDocumentState().ResetModified();
1546 }
1547 
1548 ErrCode SwDocShell::LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, bool bUnoCall)
1549 {
1550  ErrCode nErr = ERRCODE_NONE;
1551 
1552  // Set filter:
1553  SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() );
1554 
1555  // search for filter in WebDocShell, too
1556  SfxMedium aMed( rURL, StreamMode::STD_READ );
1557  if (rURL == "private:stream")
1558  aMed.setStreamToLoadFrom(rOpt.GetInputStream(), true);
1559  std::shared_ptr<const SfxFilter> pFlt;
1560  aMatcher.DetectFilter( aMed, pFlt );
1561  if(!pFlt)
1562  {
1563  SfxFilterMatcher aWebMatcher( SwWebDocShell::Factory().GetFactoryName() );
1564  aWebMatcher.DetectFilter( aMed, pFlt );
1565  }
1566  // --> OD #i117339# - trigger import only for own formats
1567  bool bImport( false );
1568  if ( aMed.IsStorage() )
1569  {
1570  // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat()
1571  // does not work correct (e.g., MS Word 2007 XML Template),
1572  // use workaround provided by MAV.
1573  uno::Reference< embed::XStorage > xStorage = aMed.GetStorage();
1574  if ( xStorage.is() )
1575  {
1576  // use <try-catch> on retrieving <MediaType> in order to check,
1577  // if the storage is one of our own ones.
1578  try
1579  {
1580  uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW );
1581  xProps->getPropertyValue( "MediaType" );
1582  bImport = true;
1583  }
1584  catch (const uno::Exception&)
1585  {
1586  bImport = false;
1587  }
1588  }
1589  }
1590  if ( bImport )
1591  {
1592  Reader* pRead = ReadXML;
1593  SwReaderPtr pReader;
1594  std::unique_ptr<SwPaM> pPam;
1595  // the SW3IO - Reader need the pam/wrtshell, because only then he
1596  // insert the styles!
1597  if( bUnoCall )
1598  {
1599  SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfContent(), -1 );
1600  pPam.reset(new SwPaM( aIdx ));
1601  pReader.reset(new SwReader( aMed, rURL, *pPam ));
1602  }
1603  else
1604  {
1605  pReader.reset(new SwReader( aMed, rURL, *m_pWrtShell->GetCursor() ));
1606  }
1607 
1608  pRead->GetReaderOpt().SetTextFormats( rOpt.IsTextFormats() );
1609  pRead->GetReaderOpt().SetFrameFormats( rOpt.IsFrameFormats() );
1610  pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
1611  pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
1612  pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
1613 
1614  if( bUnoCall )
1615  {
1616  UnoActionContext aAction( m_xDoc.get() );
1617  nErr = pReader->Read( *pRead );
1618  }
1619  else
1620  {
1622  nErr = pReader->Read( *pRead );
1624  }
1625  }
1626 
1627  return nErr;
1628 }
1629 
1630 // Get a client for an embedded object if possible.
1631 SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
1632 {
1633  SfxInPlaceClient* pResult = nullptr;
1634 
1635  SwWrtShell* pShell = GetWrtShell();
1636  if ( pShell )
1637  {
1638  pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), &pShell->GetView().GetEditWin() );
1639  if ( !pResult )
1640  pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
1641  }
1642 
1643  return pResult;
1644 }
1645 
1647  SfxObjectShellLock& xLockRef,
1648  const OUString& rFileName,
1649  const OUString& rPasswd,
1650  const OUString& rFilter,
1651  sal_Int16 nVersion,
1652  SwDocShell* pDestSh )
1653 {
1654  if ( rFileName.isEmpty() )
1655  return 0;
1656 
1657  // 1. Does the file already exist in the list of all Documents?
1658  INetURLObject aTmpObj( rFileName );
1659  aTmpObj.SetMark( u"" );
1660 
1661  // Iterate over the DocShell and get the ones with the name
1662 
1663  SfxObjectShell* pShell = pDestSh;
1664  bool bFirst = nullptr != pShell;
1665 
1666  if( !bFirst )
1667  // No DocShell passed, starting with the first from the DocShell list
1668  pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1669 
1670  while( pShell )
1671  {
1672  // We want this one
1673  SfxMedium* pMed = pShell->GetMedium();
1674  if( pMed && pMed->GetURLObject() == aTmpObj )
1675  {
1676  const SfxPoolItem* pItem;
1677  if( ( SfxItemState::SET == pMed->GetItemSet()->GetItemState(
1678  SID_VERSION, false, &pItem ) )
1679  ? (nVersion == static_cast<const SfxInt16Item*>(pItem)->GetValue())
1680  : !nVersion )
1681  {
1682  // Found, thus return
1683  xDocSh = pShell;
1684  return 1;
1685  }
1686  }
1687 
1688  if( bFirst )
1689  {
1690  bFirst = false;
1691  pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1692  }
1693  else
1694  pShell = SfxObjectShell::GetNext( *pShell, checkSfxObjectShell<SwDocShell> );
1695  }
1696 
1697  // 2. Open the file ourselves
1698  std::unique_ptr<SfxMedium> xMed(new SfxMedium( aTmpObj.GetMainURL(
1699  INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
1700  if( INetProtocol::File == aTmpObj.GetProtocol() )
1701  xMed->Download(); // Touch the medium (download it)
1702 
1703  std::shared_ptr<const SfxFilter> pSfxFlt;
1704  if (!xMed->GetError())
1705  {
1706  SfxFilterMatcher aMatcher( rFilter == "writerglobal8"
1707  ? SwGlobalDocShell::Factory().GetFactoryName()
1708  : SwDocShell::Factory().GetFactoryName() );
1709 
1710  // No Filter, so search for it. Else test if the one passed is a valid one
1711  if( !rFilter.isEmpty() )
1712  {
1713  pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
1714  }
1715 
1716  if( nVersion )
1717  xMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
1718 
1719  if( !rPasswd.isEmpty() )
1720  xMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
1721 
1722  if( !pSfxFlt )
1723  aMatcher.DetectFilter( *xMed, pSfxFlt );
1724 
1725  if( pSfxFlt )
1726  {
1727  // We cannot do anything without a Filter
1728  xMed->SetFilter( pSfxFlt );
1729 
1730  // If the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
1731  SwDocShell *const pNew(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1732  xLockRef = pNew;
1733  xDocSh = static_cast<SfxObjectShell*>(xLockRef);
1734  if (xDocSh->DoLoad(xMed.release()))
1735  {
1736  return 2;
1737  }
1738  }
1739  }
1740 
1741  return 0;
1742 }
1743 
1744 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SfxViewFrame * GetViewFrame() const
void SetText(const OUString &aText)
#define FN_ABSTRACT_NEWDOC
Definition: cmdid.h:437
void Appear()
sal_Int32 GetValue() const
#define FN_REDLINE_ACCEPT_ALL
Definition: cmdid.h:143
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
#define HID_SEND_HTML_CTRL_PUSHBUTTON_OK
Definition: helpids.h:115
SAL_DLLPRIVATE void SubInitNew()
for InitNew and HtmlSourceMode.
Definition: docshini.cxx:611
virtual SfxObjectFactory & GetFactory() const =0
virtual void SetModified(bool=true) override
Definition: docsh2.cxx:1378
#define FN_REDLINE_REJECT_ALL
Definition: cmdid.h:144
#define FN_NEW_GLOBAL_DOC
Definition: cmdid.h:61
Represents the style of a paragraph.
Definition: fmtcol.hxx:56
static SvxAutoCorrCfg & Get()
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
bool HasSourceSaved() const
Definition: srcview.hxx:82
bool IsMerge() const
Definition: shellio.hxx:131
SfxInPlaceClient * GetIPClient(const ::svt::EmbeddedObjectRef &xObjRef)
Definition: docsh2.cxx:1631
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
void SaveContent(const OUString &rTmpFile)
Definition: srcview.cxx:253
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
std::vector< svx::ClassificationResult > CollectParagraphClassification()
Definition: edfcol.cxx:1341
bool IsDefault() const
Definition: format.hxx:113
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem) override
Definition: docsh2.cxx:1338
#define HID_SEND_MASTER_CTRL_EDIT_FILEURL
Definition: helpids.h:111
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:1535
void SetPageDescs(const bool bNew)
Definition: shellio.hxx:123
std::string GetValue
void UpdateFontList()
Definition: docshini.cxx:410
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:238
bool IsPageDescs() const
Definition: shellio.hxx:122
void ToggleLayoutMode(SwView *pView)
Definition: docsh2.cxx:151
#define HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION
Definition: helpids.h:112
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
sal_Int64 n
css::uno::Reference< css::frame::XModel3 > GetModel() const
#define HID_SEND_MASTER_CTRL_LISTBOX_FILTER
Definition: helpids.h:109
Definition: doc.hxx:188
void ReloadFromHtml(const OUString &rStreamName, SwSrcView *pSrcView)
Re-read Doc from Html-source.
Definition: docsh2.cxx:1443
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:90
static void ConfigureEvent(const OUString &aName, const SvxMacro &, SfxObjectShell const *pObjSh)
#define STREAM_SEEK_TO_END
#define FN_ABSTRACT_STARIMPRESS
Definition: cmdid.h:438
sal_uInt64 Seek(sal_uInt64 nPos)
SwEditWin & GetEditWin()
Definition: view.hxx:416
void Done(bool bRemove=false)
ErrCode Write(WriterRef const &rxWriter, const OUString *=nullptr)
Definition: shellio.cxx:731
static SfxObjectShell * Current()
void RecheckBrowseMode()
Definition: view0.cxx:169
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1749
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:1646
#define HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:121
void EndAllAction()
Definition: edws.cxx:97
bool IsInPrepareClose() const
SfxHintId GetId() const
#define RET_TEMPLATE_LOAD
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
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:93
virtual bool PrepareClose(bool bUI=true)
void SetWatermark(const SfxWatermarkItem &rText)
Definition: edfcol.cxx:1606
static void CheckSpellChanges(bool bOnlineSpelling, bool bIsSpellWrongAgain, bool bIsSpellAllAgain, bool bSmartTags)
Definition: swmodul1.cxx:630
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
bool IsStorage()
virtual void set(DocumentSettingId id, bool value)=0
Set the specified document setting.
Reader * ReadXML
Definition: fltini.cxx:46
constexpr auto SFX_INTERFACE_NONE
const SwView & GetView() const
Definition: wrtsh.hxx:431
RET_YES
virtual VclPtr< AbstractSwInsertAbstractDlg > CreateSwInsertAbstractDlg(weld::Window *pParent)=0
bool empty() const
Definition: docary.hxx:260
bool getBrowseMode() const
Definition: viewopt.hxx:472
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2011
const OUString & GetName() const
Definition: format.hxx:115
static bool IsFuzzing()
SfxFrame & GetFrame() const
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
weld::Window * GetFrameWeld() const
static SfxViewShell * Current()
Reader * ReadHTML
Definition: fltini.cxx:46
bool IsModified() const
Definition: srcview.hxx:67
SvxSwAutoFormatFlags & GetSwFlags()
void SetTransparency(const sal_Int16 nTransparency)
SotClipboardFormatId
size_type size() 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
DocumentType eType
bool IsModified() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
#define HID_SEND_HTML_CTRL_CONTROL_FILEVIEW
Definition: helpids.h:118
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:328
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:985
void CheckChangedList(const editeng::SortedAutoCompleteStrings &rNewLst)
Definition: acmplwrd.cxx:340
SwgReaderOption & GetReaderOpt()
Definition: shellio.hxx:240
#define HID_SEND_MASTER_CTRL_PUSHBUTTON_CANCEL
Definition: helpids.h:108
#define SOFFICE_FILEFORMAT_60
virtual FmFormShell * GetFormShell() override
Definition: view.hxx:578
static SW_DLLPUBLIC std::shared_ptr< const SfxFilter > GetFilterOfFormat(std::u16string_view rFormat, const SfxFilterContainer *pCnt=nullptr)
find for an internal format name the corresponding filter entry
Definition: iodetect.cxx:68
sal_uInt16 nAutoCmpltWordLen
SwDocShell(SfxObjectCreateMode eMode=SfxObjectCreateMode::EMBEDDED)
Doc is required for SO data exchange!
Definition: docshini.cxx:313
#define SW_MOD()
Definition: swmodule.hxx:256
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SfxDispatcher * GetDispatcher() const
int i
css::uno::Reference< css::io::XInputStream > & GetInputStream()
Definition: shellio.hxx:138
#define HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL
Definition: helpids.h:116
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: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:107
void UpdateChildWindows()
Definition: docsh2.cxx:1408
bool SetMark(std::u16string_view rTheFragment, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
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:1262
float u
void ClearHeaderAttributesForSourceViewHack()
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
virtual SAL_DLLPRIVATE std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rSet) override
Make DocInfo known to the Doc.
Definition: docsh2.cxx:131
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:393
void SetLockWordLstLocked(bool bFlag)
Definition: acmplwrd.hxx:60
#define FN_SHADOWCURSOR
Definition: cmdid.h:514
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:120
void SetBufferSize(sal_uInt16 m_nBufSize)
OUString GetTemplateFileName() const
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
ColorTransparency
const XColorListRef & GetColorList() const
void SetClassification(const OUString &rName, SfxClassificationPolicyType eType)
Definition: edfcol.cxx:1066
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
bool SetHTMLTemplate(SwDoc &rDoc)
Definition: shellio.cxx:907
bool IsTextFormats() const
Definition: shellio.hxx: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:231
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
virtual sal_uInt16 SetPrinter(SfxPrinter *pNew, SfxPrinterChangeFlags nDiff=SFX_PRINTER_ALL) override
Definition: viewprt.cxx:97
SwDocShell * GetDocShell()
Definition: view.cxx:1122
bool IsReadOnly() const
bool m_IsRemovedInvisibleContent
whether SID_MAIL_PREPAREEXPORT removed content that SID_MAIL_EXPORT_FINISHED needs to restore ...
Definition: docsh.hxx:90
#define FN_OPEN_FILE
Definition: cmdid.h:62
void SetReturnValue(const SfxPoolItem &)
ErrCode LoadStylesFromFile(const OUString &rURL, SwgReaderOption &rOpt, bool bUnoCall)
Definition: docsh2.cxx:1548
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define HID_SEND_HTML_CTRL_EDIT_FILEURL
Definition: helpids.h:119
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:657
const OUString & GetWorkPath() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
#define HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:113
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
void SetMinWordLen(sal_uInt16 n)
Definition: acmplwrd.cxx:305
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:117
void SetTemplateFlags(SfxTemplateFlags nSet)
SfxEventHintId GetEventId() const
#define ERRCODE_NONE
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
unsigned char sal_uInt8
void LockView(bool b)
Definition: viewsh.hxx:462
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
#define FN_OUTLINE_TO_CLIPBOARD
Definition: cmdid.h:65
std::size_t nSize
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: redlndlg.cxx:71
OUString aName
INetProtocol GetProtocol() const
#define FN_PRINT_LAYOUT
Definition: cmdid.h:166
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 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:110
static void lcl_processCompatibleSfxHint(const uno::Reference< script::vba::XVBAEventProcessor > &xVbaEvents, const SfxHint &rHint)
Definition: docsh2.cxx:210
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:350
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:185
void EnableSetModified(bool bEnable=true)
virtual const SwRedlineTable & GetRedlineTable() const =0
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
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:2816
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2068
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)
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:1180
#define FN_OUTLINE_TO_IMPRESS
Definition: cmdid.h:64
void SetMerge(const bool bNew)
Definition: shellio.hxx:132
void SetNumRules(const bool bNew)
Definition: shellio.hxx:129
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)