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