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* pViewFrame = 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(pViewFrame->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 pViewFrame->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 pViewFrame->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 pViewFrame->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, false)); // not SID_VIEWSHELL2
737 pViewFrame->GetBindings().Invalidate( SID_NEWWINDOW );
738 pViewFrame->GetBindings().Invalidate( SID_BROWSER_MODE );
739 pViewFrame->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 SfxPoolItem* pNoUpdate;
885
886 //pWrtShell is not set in page preview
887 if (m_pWrtShell)
889
890 if (!pArgs || (pArgs && !pArgs->HasItem(FN_PARAM_1, &pNoUpdate)))
891 {
892 m_xDoc->getIDocumentFieldsAccess().UpdateFields( false );
893 m_xDoc->getIDocumentLinksAdministration().EmbedAllLinks();
894 }
895
899 m_xDoc->RemoveInvisibleContent();
900 if (m_pWrtShell)
902 }
903 break;
904
905 case SID_MAIL_EXPORT_FINISHED:
906 {
907 if (m_pWrtShell)
909 //try to undo the removal of invisible content
911 m_xDoc->RestoreInvisibleContent();
912 if (m_pWrtShell)
914 }
915 break;
916 case FN_NEW_HTML_DOC:
918 {
919 bDone = false;
920 bool bCreateHtml = FN_NEW_HTML_DOC == nWhich;
921
922 bool bCreateByOutlineLevel = false;
923 sal_Int32 nTemplateOutlineLevel = 0;
924
925 OUString aFileName, aTemplateName;
926 if( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich, false, &pItem ) )
927 {
928 aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
929 const SfxStringItem* pTemplItem = SfxItemSet::GetItem<SfxStringItem>(pArgs, SID_TEMPLATE_NAME, false);
930 if ( pTemplItem )
931 aTemplateName = pTemplItem->GetValue();
932 }
933 if ( aFileName.isEmpty() )
934 {
935 bool bError = false;
936
937 FileDialogHelper aDlgHelper(TemplateDescription::FILESAVE_AUTOEXTENSION_TEMPLATE, FileDialogFlags::NONE,
938 GetView()->GetFrameWeld());
939 aDlgHelper.SetContext(FileDialogHelper::WriterNewHTMLGlobalDoc);
940
941 const sal_Int16 nControlIds[] = {
942 CommonFilePickerElementIds::PUSHBUTTON_OK,
943 CommonFilePickerElementIds::PUSHBUTTON_CANCEL,
944 CommonFilePickerElementIds::LISTBOX_FILTER,
945 CommonFilePickerElementIds::CONTROL_FILEVIEW,
946 CommonFilePickerElementIds::EDIT_FILEURL,
947 ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
948 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
949 0
950 };
951
952 if (bCreateHtml)
953 {
954 const char* aHTMLHelpIds[] =
955 {
963 ""
964 };
965 aDlgHelper.SetControlHelpIds( nControlIds, aHTMLHelpIds );
966 }
967 else
968 {
969 const char* aMasterHelpIds[] =
970 {
978 ""
979 };
980 aDlgHelper.SetControlHelpIds( nControlIds, aMasterHelpIds );
981 }
982 uno::Reference < XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
983
984 std::shared_ptr<const SfxFilter> pFlt;
985 TranslateId pStrId;
986
987 if( bCreateHtml )
988 {
989 // for HTML there is only one filter!!
991 u"HTML",
992 SwWebDocShell::Factory().GetFilterContainer() );
993 pStrId = STR_LOAD_HTML_DOC;
994 }
995 else
996 {
997 // for Global-documents we now only offer the current one.
998 pFlt = SwGlobalDocShell::Factory().GetFilterContainer()->
999 GetFilter4Extension( "odm" );
1000 pStrId = STR_LOAD_GLOBAL_DOC;
1001 }
1002
1003 if( pFlt )
1004 {
1005 const OUString sWild = pFlt->GetWildcard().getGlob();
1006 xFP->appendFilter( pFlt->GetUIName(), sWild );
1007 try
1008 {
1009 xFP->setCurrentFilter( pFlt->GetUIName() ) ;
1010 }
1011 catch (const uno::Exception&)
1012 {
1013 bError = true;
1014 }
1015 }
1016 if(!bError)
1017 {
1018 uno::Reference<XFilePickerControlAccess> xCtrlAcc(xFP, UNO_QUERY);
1019
1020 bool bOutline[MAXLEVEL] = {false};
1021 const SwOutlineNodes& rOutlNds = m_xDoc->GetNodes().GetOutLineNds();
1022 for( size_t n = 0; n < rOutlNds.size(); ++n )
1023 {
1024 const int nLevel = rOutlNds[n]->GetTextNode()->GetAttrOutlineLevel();
1025 if( nLevel > 0 && ! bOutline[nLevel-1] )
1026 {
1027 bOutline[nLevel-1] = true;
1028 }
1029 }
1030
1031 const sal_uInt16 nStyleCount = m_xDoc->GetTextFormatColls()->size();
1032 Sequence<OUString> aListBoxEntries( MAXLEVEL + nStyleCount);
1033 OUString* pEntries = aListBoxEntries.getArray();
1034 sal_Int32 nIdx = 0 ;
1035
1036 OUString sOutline( SwResId(STR_FDLG_OUTLINE_LEVEL) );
1037 for( sal_uInt16 i = 0; i < MAXLEVEL; ++i )
1038 {
1039 if( bOutline[i] )
1040 pEntries[nIdx++] = sOutline + OUString::number( i+1 );
1041 }
1042
1043 OUString sStyle( SwResId(STR_FDLG_STYLE) );
1044 for(sal_uInt16 i = 0; i < nStyleCount; ++i)
1045 {
1046 SwTextFormatColl &rTextColl = *(*m_xDoc->GetTextFormatColls())[ i ];
1047 if( !rTextColl.IsDefault() && rTextColl.IsAtDocNodeSet() )
1048 {
1049 pEntries[nIdx++] = sStyle + rTextColl.GetName();
1050 }
1051 }
1052
1053 aListBoxEntries.realloc(nIdx);
1054 sal_Int16 nSelect = 0;
1055
1056 try
1057 {
1058 Any aTemplates(&aListBoxEntries, cppu::UnoType<decltype(aListBoxEntries)>::get());
1059
1060 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1061 ListboxControlActions::ADD_ITEMS , aTemplates );
1062 Any aSelectPos(&nSelect, cppu::UnoType<decltype(nSelect)>::get());
1063 xCtrlAcc->setValue( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1064 ListboxControlActions::SET_SELECT_ITEM, aSelectPos );
1065 xCtrlAcc->setLabel( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1066 SwResId( STR_FDLG_TEMPLATE_NAME ));
1067 }
1068 catch (const Exception&)
1069 {
1070 OSL_FAIL("control access failed");
1071 }
1072
1073 xFP->setTitle(SwResId(pStrId));
1074 SvtPathOptions aPathOpt;
1075 xFP->setDisplayDirectory( aPathOpt.GetWorkPath() );
1076 if( ERRCODE_NONE == aDlgHelper.Execute())
1077 {
1078 aFileName = xFP->getSelectedFiles().getConstArray()[0];
1079 Any aTemplateValue = xCtrlAcc->getValue(
1080 ExtendedFilePickerElementIds::LISTBOX_TEMPLATE,
1081 ListboxControlActions::GET_SELECTED_ITEM );
1082 OUString sTmpl;
1083 aTemplateValue >>= sTmpl;
1084
1085 OUString aStyle(SwResId(STR_FDLG_STYLE));
1086 OUString aOutline(SwResId(STR_FDLG_OUTLINE_LEVEL));
1087
1088 if ( sTmpl.startsWith(aStyle) )
1089 {
1090 aTemplateName = sTmpl.copy( aStyle.getLength() ); //get string behind "Style: "
1091 }
1092 else if ( sTmpl.startsWith(aOutline) )
1093 {
1094 nTemplateOutlineLevel = o3tl::toInt32(sTmpl.subView(aOutline.getLength())); //get string behind "Outline: Level ";
1095 bCreateByOutlineLevel = true;
1096 }
1097
1098 if ( !aFileName.isEmpty() )
1099 {
1100 rReq.AppendItem( SfxStringItem( nWhich, aFileName ) );
1101 if( !aTemplateName.isEmpty() )
1102 rReq.AppendItem( SfxStringItem( SID_TEMPLATE_NAME, aTemplateName ) );
1103 }
1104 }
1105 }
1106 }
1107
1108 if( !aFileName.isEmpty() )
1109 {
1110 if( PrepareClose( false ) )
1111 {
1112 SwWait aWait( *this, true );
1113
1114 if ( bCreateByOutlineLevel )
1115 {
1116 bDone = bCreateHtml
1117 ? m_xDoc->GenerateHTMLDoc( aFileName, nTemplateOutlineLevel )
1118 : m_xDoc->GenerateGlobalDoc( aFileName, nTemplateOutlineLevel );
1119 }
1120 else
1121 {
1122 const SwTextFormatColl* pSplitColl = nullptr;
1123 if ( !aTemplateName.isEmpty() )
1124 pSplitColl = m_xDoc->FindTextFormatCollByName(aTemplateName);
1125 bDone = bCreateHtml
1126 ? m_xDoc->GenerateHTMLDoc( aFileName, pSplitColl )
1127 : m_xDoc->GenerateGlobalDoc( aFileName, pSplitColl );
1128 }
1129 if( bDone )
1130 {
1131 SfxStringItem aName( SID_FILE_NAME, aFileName );
1132 SfxStringItem aReferer(SID_REFERER, OUString());
1133 SfxViewShell* pViewShell = SfxViewShell::GetFirst();
1134 while(pViewShell)
1135 {
1136 //search for the view that created the call
1137 if(pViewShell->GetObjectShell() == this && pViewShell->GetDispatcher())
1138 {
1139 SfxFrameItem aFrameItem( SID_DOCFRAME, pViewShell->GetViewFrame() );
1140 SfxDispatcher* pDispatch = pViewShell->GetDispatcher();
1141 pDispatch->ExecuteList(SID_OPENDOC,
1142 SfxCallMode::ASYNCHRON,
1143 { &aName, &aReferer, &aFrameItem });
1144 break;
1145 }
1146 pViewShell = SfxViewShell::GetNext(*pViewShell);
1147 }
1148 }
1149 }
1150 if( !bDone && !rReq.IsAPI() )
1151 {
1152 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
1153 VclMessageType::Info, VclButtonsType::Ok,
1154 SwResId(STR_CANTCREATE)));
1155 xInfoBox->run();
1156 }
1157 }
1158 }
1159 rReq.SetReturnValue(SfxBoolItem( nWhich, bDone ));
1160 if (bDone)
1161 rReq.Done();
1162 else
1163 rReq.Ignore();
1164 break;
1165
1166 case SID_ATTR_YEAR2000:
1167 if ( pArgs && SfxItemState::SET == pArgs->GetItemState( nWhich , false, &pItem ))
1168 {
1169 assert(dynamic_cast< const SfxUInt16Item *>( pItem ) && "wrong Item");
1170 sal_uInt16 nYear2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1171 // iterate over Views and put the State to FormShells
1172
1173 SfxViewFrame* pVFrame = SfxViewFrame::GetFirst( this );
1174 SfxViewShell* pViewShell = pVFrame ? pVFrame->GetViewShell() : nullptr;
1175 SwView* pCurrView = dynamic_cast< SwView* >( pViewShell );
1176 while(pCurrView)
1177 {
1178 FmFormShell* pFormShell = pCurrView->GetFormShell();
1179 if(pFormShell)
1180 pFormShell->SetY2KState(nYear2K);
1181 pVFrame = SfxViewFrame::GetNext( *pVFrame, this );
1182 pViewShell = pVFrame ? pVFrame->GetViewShell() : nullptr;
1183 pCurrView = dynamic_cast<SwView*>( pViewShell );
1184 }
1185 m_xDoc->GetNumberFormatter()->SetYear2000(nYear2K);
1186 }
1187 break;
1188 case FN_OPEN_FILE:
1189 {
1190 SfxViewShell* pViewShell = GetView();
1191 if (!pViewShell)
1192 pViewShell = SfxViewShell::Current();
1193
1194 if (!pViewShell)
1195 // Ok. I did my best.
1196 break;
1197
1198 SfxStringItem aApp(SID_DOC_SERVICE, "com.sun.star.text.TextDocument");
1199 SfxStringItem aTarget(SID_TARGETNAME, "_blank");
1200 pViewShell->GetDispatcher()->ExecuteList(SID_OPENDOC,
1201 SfxCallMode::API|SfxCallMode::SYNCHRON,
1202 { &aApp, &aTarget });
1203 }
1204 break;
1205 case SID_CLASSIFICATION_APPLY:
1206 {
1207 if (pArgs && pArgs->GetItemState(nWhich, false, &pItem) == SfxItemState::SET)
1208 {
1209 SwWrtShell* pSh = GetWrtShell();
1210 const OUString& rValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
1211 auto eType = SfxClassificationPolicyType::IntellectualProperty;
1212 if (const SfxStringItem* pTypeNameItem = pArgs->GetItemIfSet(SID_TYPE_NAME, false))
1213 {
1214 const OUString& rType = pTypeNameItem->GetValue();
1216 }
1217 pSh->SetClassification(rValue, eType);
1218 }
1219 else
1220 SAL_WARN("sw.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
1221 }
1222 break;
1223 case SID_CLASSIFICATION_DIALOG:
1224 {
1225 auto xDialog = std::make_shared<svx::ClassificationDialog>(GetView()->GetFrameWeld(), false);
1226
1227 SwWrtShell* pShell = GetWrtShell();
1228 std::vector<svx::ClassificationResult> aInput = pShell->CollectAdvancedClassification();
1229 xDialog->setupValues(std::move(aInput));
1230
1231 weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){
1232 if (RET_OK == nResult)
1233 pShell->ApplyAdvancedClassification(xDialog->getResult());
1234 });
1235 }
1236 break;
1237 case SID_PARAGRAPH_SIGN_CLASSIFY_DLG:
1238 {
1239 SwWrtShell* pShell = GetWrtShell();
1240 auto xDialog = std::make_shared<svx::ClassificationDialog>(GetView()->GetFrameWeld(), true, [pShell]()
1241 {
1242 pShell->SignParagraph();
1243 });
1244
1245 std::vector<svx::ClassificationResult> aInput = pShell->CollectParagraphClassification();
1246 xDialog->setupValues(std::move(aInput));
1247
1248 weld::DialogController::runAsync(xDialog, [xDialog, pShell](sal_Int32 nResult){
1249 if (RET_OK == nResult)
1250 pShell->ApplyParagraphClassification(xDialog->getResult());
1251 });
1252 }
1253 break;
1254 case SID_WATERMARK:
1255 {
1256 SwWrtShell* pSh = GetWrtShell();
1257 if ( pSh )
1258 {
1259 if (pArgs && pArgs->GetItemState( SID_WATERMARK, false, &pItem ) == SfxItemState::SET)
1260 {
1261 SfxWatermarkItem aItem;
1262 aItem.SetText( static_cast<const SfxStringItem*>( pItem )->GetValue() );
1263
1264 if ( const SfxStringItem* pFontItem = pArgs->GetItemIfSet( SID_WATERMARK_FONT, false ) )
1265 aItem.SetFont( pFontItem->GetValue() );
1266 if ( const SfxInt16Item* pAngleItem = pArgs->GetItemIfSet( SID_WATERMARK_ANGLE, false ) )
1267 aItem.SetAngle( pAngleItem->GetValue() );
1268 if ( const SfxInt16Item* pTransItem = pArgs->GetItemIfSet( SID_WATERMARK_TRANSPARENCY, false ) )
1269 aItem.SetTransparency( pTransItem->GetValue() );
1270 if ( const SfxUInt32Item* pColorItem = pArgs->GetItemIfSet( SID_WATERMARK_COLOR, false ) )
1271 aItem.SetColor( Color(ColorTransparency, pColorItem->GetValue()) );
1272
1273 pSh->SetWatermark( aItem );
1274 }
1275 else
1276 {
1277 SfxViewShell* pViewShell = GetView() ? GetView() : SfxViewShell::Current();
1278 SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() );
1279 auto xDlg = std::make_shared<SwWatermarkDialog>(pViewShell->GetViewFrame()->GetFrameWeld(),
1280 rBindings);
1281 weld::DialogController::runAsync(xDlg, [](sal_Int32 /*nResult*/){});
1282 }
1283 }
1284 }
1285 break;
1286 case SID_NOTEBOOKBAR:
1287 {
1288 const SfxStringItem* pFile = rReq.GetArg<SfxStringItem>( SID_NOTEBOOKBAR );
1289 SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current();
1290 SfxBindings& rBindings( pViewShell->GetViewFrame()->GetBindings() );
1291
1292 if ( SfxNotebookBar::IsActive() )
1293 sfx2::SfxNotebookBar::ExecMethod( rBindings, pFile ? pFile->GetValue() : "" );
1294 else
1295 {
1297 }
1298 }
1299 break;
1302 {
1304 SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
1305
1306 if (rRedlineAccess.GetRedlineTable().empty())
1307 {
1308 break;
1309 }
1310
1311 // tables with tracked deletion need Show Changes
1312 bool bHideChanges = pWrtShell && pWrtShell->GetLayout() &&
1313 pWrtShell->GetLayout()->IsHideRedlines();
1314 bool bChangedHideChanges = false;
1315 if ( bHideChanges )
1316 {
1317 SwTableNode* pOldTableNd = nullptr;
1318 const SwRedlineTable& aRedlineTable = rRedlineAccess.GetRedlineTable();
1319 for (SwRedlineTable::size_type n = 0; n < aRedlineTable.size(); ++n)
1320 {
1321 const SwRangeRedline* pRedline = aRedlineTable[n];
1322 if ( pRedline->GetType() == RedlineType::Delete )
1323 {
1324 SwTableNode* pTableNd =
1325 pRedline->GetPoint()->GetNode().FindTableNode();
1326 if ( pTableNd && pTableNd !=
1327 pOldTableNd && pTableNd->GetTable().HasDeletedRow() )
1328 {
1329 SfxBoolItem aShow(FN_REDLINE_SHOW, true);
1330 SfxViewShell* pViewShell = GetView()
1331 ? GetView()
1333 pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
1334 FN_REDLINE_SHOW, SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
1335 { &aShow });
1336 bChangedHideChanges = true;
1337 break;
1338 }
1339 pOldTableNd = pTableNd;
1340 }
1341 }
1342 }
1343
1344 if (pWrtShell)
1345 {
1346 pWrtShell->StartAllAction();
1347 }
1348
1349 rRedlineAccess.AcceptAllRedline(nWhich == FN_REDLINE_ACCEPT_ALL);
1350
1351 if (pWrtShell)
1352 {
1353 pWrtShell->EndAllAction();
1354 }
1355
1356 if ( bChangedHideChanges )
1357 {
1358 SfxBoolItem aShow(FN_REDLINE_SHOW, false);
1359 SfxViewShell* pViewShell = GetView()? GetView(): SfxViewShell::Current();
1360 pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
1361 FN_REDLINE_SHOW, SfxCallMode::SYNCHRON|SfxCallMode::RECORD, { &aShow });
1362 }
1363
1364 Broadcast(SfxHint(SfxHintId::RedlineChanged));
1365 rReq.Done();
1366 }
1367 break;
1368
1369 default: OSL_FAIL("wrong Dispatcher");
1370 }
1371}
1372
1373#if defined(_WIN32)
1374bool SwDocShell::DdeGetData( const OUString& rItem, const OUString& rMimeType,
1375 uno::Any & rValue )
1376{
1377 return m_xDoc->getIDocumentLinksAdministration().GetData( rItem, rMimeType, rValue );
1378}
1379
1380bool SwDocShell::DdeSetData( const OUString& rItem, const OUString& /*rMimeType*/,
1381 const uno::Any & /*rValue*/ )
1382{
1383 m_xDoc->getIDocumentLinksAdministration().SetData( rItem );
1384 return false;
1385}
1386
1387#endif
1388
1390{
1391 return m_xDoc->getIDocumentLinksAdministration().CreateLinkSource( rItem );
1392}
1393
1395{
1396 if (m_xDoc)
1397 {
1398 ::sfx2::LinkManager& rLinkManager = m_xDoc->getIDocumentLinksAdministration().GetLinkManager();
1399 rLinkManager.ReconnectDdeLink(rServer);
1400 }
1401}
1402
1404 SotClipboardFormatId * pClipFormat,
1405 OUString * pLongUserName,
1406 sal_Int32 nVersion,
1407 bool bTemplate /* = false */) const
1408{
1410 {
1411 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1412 *pClipFormat = SotClipboardFormatId::STARWRITER_60;
1413 *pLongUserName = SwResId(STR_WRITER_DOCUMENT_FULLTYPE);
1414 }
1415 else if (nVersion == SOFFICE_FILEFORMAT_8)
1416 {
1417 *pClassName = SvGlobalName( SO3_SW_CLASSID_60 );
1418 *pClipFormat = bTemplate ? SotClipboardFormatId::STARWRITER_8_TEMPLATE : SotClipboardFormatId::STARWRITER_8;
1419 *pLongUserName = SwResId(STR_WRITER_DOCUMENT_FULLTYPE);
1420 }
1421// #FIXME check with new Event handling
1422#if 0
1423 uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper = m_xDoc->GetVbaEventsHelper();
1424 if( xVbaEventsHelper.is() )
1425 lcl_processCompatibleSfxHint( xVbaEventsHelper, rHint );
1426#endif
1427}
1428
1430{
1432 return;
1434 if( !IsEnableSetModified())
1435 return;
1436
1437 if (!m_xDoc->getIDocumentState().IsInCallModified())
1438 {
1439 EnableSetModified( false );
1440 if( bSet )
1441 {
1442 bool const bOld = m_xDoc->getIDocumentState().IsModified();
1443 m_xDoc->getIDocumentState().SetModified();
1444 if( !bOld )
1445 {
1446 m_xDoc->GetIDocumentUndoRedo().SetUndoNoResetModified();
1447 }
1448 }
1449 else
1450 m_xDoc->getIDocumentState().ResetModified();
1451
1453 }
1454
1456 Broadcast(SfxHint(SfxHintId::DocChanged));
1457}
1458
1460{
1461 // if necessary newly initialize Fielddlg (i.e. for TYP_SETVAR)
1462 if(!GetView())
1463 return;
1464 SfxViewFrame* pVFrame = GetView()->GetViewFrame();
1465 SwFieldDlgWrapper *pWrp = static_cast<SwFieldDlgWrapper*>(pVFrame->
1466 GetChildWindow( SwFieldDlgWrapper::GetChildWindowId() ));
1467 if( pWrp )
1468 pWrp->ReInitDlg( this );
1469
1470 // if necessary newly initialize RedlineDlg
1471 SwRedlineAcceptChild *pRed = static_cast<SwRedlineAcceptChild*>(pVFrame->
1472 GetChildWindow( SwRedlineAcceptChild::GetChildWindowId() ));
1473 if( pRed )
1474 pRed->ReInitDlg( this );
1475}
1476
1477namespace {
1478
1479// #i48748#
1480class SwReloadFromHtmlReader : public SwReader
1481{
1482 public:
1483 SwReloadFromHtmlReader( SfxMedium& _rTmpMedium,
1484 const OUString& _rFilename,
1485 SwDoc* _pDoc )
1486 : SwReader( _rTmpMedium, _rFilename, _pDoc )
1487 {
1488 SetBaseURL( _rFilename );
1489 }
1490};
1491
1492}
1493
1494void SwDocShell::ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView )
1495{
1496 bool bModified = IsModified();
1497
1498 // The HTTP-Header fields have to be removed, otherwise
1499 // there are some from Meta-Tags duplicated or triplicated afterwards.
1501
1502#if HAVE_FEATURE_SCRIPTING
1503 // The Document-Basic also bites the dust ...
1504 // A EnterBasicCall is not needed here, because nothing is called and
1505 // there can't be any Dok-Basic, that has not yet been loaded inside
1506 // of an HTML document.
1507 //#59620# HasBasic() shows, that there already is a BasicManager at the DocShell.
1508 // That was always generated in HTML-Import, when there are
1509 // Macros in the source code.
1511 {
1512 BasicManager *pBasicMan = GetBasicManager();
1513 if( pBasicMan && (pBasicMan != SfxApplication::GetBasicManager()) )
1514 {
1515 sal_uInt16 nLibCount = pBasicMan->GetLibCount();
1516 while( nLibCount )
1517 {
1518 StarBASIC *pBasic = pBasicMan->GetLib( --nLibCount );
1519 if( pBasic )
1520 {
1521 // Notify the IDE
1522 SfxUnoAnyItem aShellItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( GetModel() ) );
1523 OUString aLibName( pBasic->GetName() );
1524 SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
1525 pSrcView->GetViewFrame()->GetDispatcher()->ExecuteList(
1526 SID_BASICIDE_LIBREMOVED,
1527 SfxCallMode::SYNCHRON,
1528 { &aShellItem, &aLibNameItem });
1529
1530 // Only the modules are deleted from the standard-lib
1531 if( nLibCount )
1532 pBasicMan->RemoveLib( nLibCount, true );
1533 else
1534 pBasic->Clear();
1535 }
1536 }
1537
1538 OSL_ENSURE( pBasicMan->GetLibCount() <= 1,
1539 "Deleting Basics didn't work" );
1540 }
1541 }
1542#endif
1543 bool bWasBrowseMode = m_xDoc->getIDocumentSettingAccess().get(DocumentSettingId::BROWSE_MODE);
1544 RemoveLink();
1545
1546 // now also the UNO-Model has to be informed about the new Doc #51535#
1547 uno::Reference<text::XTextDocument> xDoc(GetBaseModel(), uno::UNO_QUERY);
1548 text::XTextDocument* pxDoc = xDoc.get();
1549 static_cast<SwXTextDocument*>(pxDoc)->InitNewDoc();
1550
1551 AddLink();
1552 //#116402# update font list when new document is created
1554 m_xDoc->getIDocumentSettingAccess().set(DocumentSettingId::BROWSE_MODE, bWasBrowseMode);
1555 pSrcView->SetPool(&GetPool());
1556
1557 const OUString& rMedname = GetMedium()->GetName();
1558
1559 // The HTML template still has to be set
1560 SetHTMLTemplate( *GetDoc() ); //Styles from HTML.vor
1561
1562 SfxViewShell* pViewShell = GetView() ? static_cast<SfxViewShell*>(GetView())
1564 SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
1565 pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON );
1566
1567 SubInitNew();
1568
1569 SfxMedium aMed( rStreamName, StreamMode::READ );
1570 // #i48748# - use class <SwReloadFromHtmlReader>, because
1571 // the base URL has to be set to the filename of the document <rMedname>
1572 // and not to the base URL of the temporary file <aMed> in order to get
1573 // the URLs of the linked graphics correctly resolved.
1574 SwReloadFromHtmlReader aReader( aMed, rMedname, m_xDoc.get() );
1575
1576 aReader.Read( *ReadHTML );
1577
1578 const SwView* pCurrView = GetView();
1579 //in print layout the first page(s) may have been formatted as a mix of browse
1580 //and print layout
1581 if(!bWasBrowseMode && pCurrView)
1582 {
1583 SwWrtShell& rWrtSh = pCurrView->GetWrtShell();
1584 if( rWrtSh.GetLayout())
1585 rWrtSh.InvalidateLayout( true );
1586 }
1587
1588 // Take HTTP-Header-Attributes over into the DocInfo again.
1589 // The Base-URL doesn't matter here because TLX uses the one from the document
1590 // for absolutization.
1592
1593 if(bModified && !IsReadOnly())
1594 SetModified();
1595 else
1596 m_xDoc->getIDocumentState().ResetModified();
1597}
1598
1599ErrCode SwDocShell::LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, bool bUnoCall)
1600{
1601 ErrCode nErr = ERRCODE_NONE;
1602
1603 // Set filter:
1604 SfxFilterMatcher aMatcher( SwDocShell::Factory().GetFactoryName() );
1605
1606 // search for filter in WebDocShell, too
1607 SfxMedium aMed( rURL, StreamMode::STD_READ );
1608 if (rURL == "private:stream")
1609 aMed.setStreamToLoadFrom(rOpt.GetInputStream(), true);
1610 std::shared_ptr<const SfxFilter> pFlt;
1611 aMatcher.DetectFilter( aMed, pFlt );
1612 if(!pFlt)
1613 {
1614 SfxFilterMatcher aWebMatcher( SwWebDocShell::Factory().GetFactoryName() );
1615 aWebMatcher.DetectFilter( aMed, pFlt );
1616 }
1617 // --> OD #i117339# - trigger import only for own formats
1618 bool bImport( false );
1619 if ( aMed.IsStorage() )
1620 {
1621 // As <SfxMedium.GetFilter().IsOwnFormat() resp. IsOwnTemplateFormat()
1622 // does not work correct (e.g., MS Word 2007 XML Template),
1623 // use workaround provided by MAV.
1624 uno::Reference< embed::XStorage > xStorage = aMed.GetStorage();
1625 if ( xStorage.is() )
1626 {
1627 // use <try-catch> on retrieving <MediaType> in order to check,
1628 // if the storage is one of our own ones.
1629 try
1630 {
1631 uno::Reference< beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY_THROW );
1632 xProps->getPropertyValue( "MediaType" );
1633 bImport = true;
1634 }
1635 catch (const uno::Exception&)
1636 {
1637 bImport = false;
1638 }
1639 }
1640 }
1641 if ( bImport )
1642 {
1643 Reader* pRead = ReadXML;
1644 SwReaderPtr pReader;
1645 std::optional<SwPaM> pPam;
1646 // the SW3IO - Reader need the pam/wrtshell, because only then he
1647 // insert the styles!
1648 if( bUnoCall )
1649 {
1650 SwNodeIndex aIdx( m_xDoc->GetNodes().GetEndOfContent(), -1 );
1651 pPam.emplace( aIdx );
1652 pReader.reset(new SwReader( aMed, rURL, *pPam ));
1653 }
1654 else
1655 {
1656 pReader.reset(new SwReader( aMed, rURL, *m_pWrtShell->GetCursor() ));
1657 }
1658
1659 pRead->GetReaderOpt().SetTextFormats( rOpt.IsTextFormats() );
1660 pRead->GetReaderOpt().SetFrameFormats( rOpt.IsFrameFormats() );
1661 pRead->GetReaderOpt().SetPageDescs( rOpt.IsPageDescs() );
1662 pRead->GetReaderOpt().SetNumRules( rOpt.IsNumRules() );
1663 pRead->GetReaderOpt().SetMerge( rOpt.IsMerge() );
1664
1665 if( bUnoCall )
1666 {
1667 UnoActionContext aAction( m_xDoc.get() );
1668 nErr = pReader->Read( *pRead );
1669 }
1670 else
1671 {
1673 nErr = pReader->Read( *pRead );
1675 }
1676 }
1677
1678 return nErr;
1679}
1680
1681// Get a client for an embedded object if possible.
1682SfxInPlaceClient* SwDocShell::GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef )
1683{
1684 SfxInPlaceClient* pResult = nullptr;
1685
1686 SwWrtShell* pShell = GetWrtShell();
1687 if ( pShell )
1688 {
1689 pResult = pShell->GetView().FindIPClient( xObjRef.GetObject(), &pShell->GetView().GetEditWin() );
1690 if ( !pResult )
1691 pResult = new SwOleClient( &pShell->GetView(), &pShell->GetView().GetEditWin(), xObjRef );
1692 }
1693
1694 return pResult;
1695}
1696
1698 SfxObjectShellLock& xLockRef,
1699 std::u16string_view rFileName,
1700 const OUString& rPasswd,
1701 const OUString& rFilter,
1702 sal_Int16 nVersion,
1703 SwDocShell* pDestSh )
1704{
1705 if ( rFileName.empty() )
1706 return 0;
1707
1708 // 1. Does the file already exist in the list of all Documents?
1709 INetURLObject aTmpObj( rFileName );
1710 aTmpObj.SetMark( u"" );
1711
1712 // Iterate over the DocShell and get the ones with the name
1713
1714 SfxObjectShell* pShell = pDestSh;
1715 bool bFirst = nullptr != pShell;
1716
1717 if( !bFirst )
1718 // No DocShell passed, starting with the first from the DocShell list
1719 pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1720
1721 while( pShell )
1722 {
1723 // We want this one
1724 SfxMedium* pMed = pShell->GetMedium();
1725 if( pMed && pMed->GetURLObject() == aTmpObj )
1726 {
1727 const SfxPoolItem* pItem;
1728 if( ( SfxItemState::SET == pMed->GetItemSet()->GetItemState(
1729 SID_VERSION, false, &pItem ) )
1730 ? (nVersion == static_cast<const SfxInt16Item*>(pItem)->GetValue())
1731 : !nVersion )
1732 {
1733 // Found, thus return
1734 xDocSh = pShell;
1735 return 1;
1736 }
1737 }
1738
1739 if( bFirst )
1740 {
1741 bFirst = false;
1742 pShell = SfxObjectShell::GetFirst( checkSfxObjectShell<SwDocShell> );
1743 }
1744 else
1745 pShell = SfxObjectShell::GetNext( *pShell, checkSfxObjectShell<SwDocShell> );
1746 }
1747
1748 // 2. Open the file ourselves
1749 std::unique_ptr<SfxMedium> xMed(new SfxMedium( aTmpObj.GetMainURL(
1750 INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ));
1751 if( INetProtocol::File == aTmpObj.GetProtocol() )
1752 xMed->Download(); // Touch the medium (download it)
1753
1754 std::shared_ptr<const SfxFilter> pSfxFlt;
1755 if (!xMed->GetError())
1756 {
1757 SfxFilterMatcher aMatcher( rFilter == "writerglobal8"
1758 ? SwGlobalDocShell::Factory().GetFactoryName()
1759 : SwDocShell::Factory().GetFactoryName() );
1760
1761 // No Filter, so search for it. Else test if the one passed is a valid one
1762 if( !rFilter.isEmpty() )
1763 {
1764 pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
1765 }
1766
1767 if( nVersion )
1768 xMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
1769
1770 if( !rPasswd.isEmpty() )
1771 xMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
1772
1773 if( !pSfxFlt )
1774 aMatcher.DetectFilter( *xMed, pSfxFlt );
1775
1776 if( pSfxFlt )
1777 {
1778 // We cannot do anything without a Filter
1779 xMed->SetFilter( pSfxFlt );
1780
1781 // If the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
1782 SwDocShell *const pNew(new SwDocShell(SfxObjectCreateMode::INTERNAL));
1783 xLockRef = pNew;
1784 xDocSh = static_cast<SfxObjectShell*>(xLockRef);
1785 if (xDocSh->DoLoad(xMed.release()))
1786 {
1787 return 2;
1788 }
1789 }
1790 }
1791
1792 return 0;
1793}
1794
1795/* 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, bool bMobile=false)
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:233
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
bool HasItem(sal_uInt16 nWhich, const SfxPoolItem **ppItem=nullptr) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) 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 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 SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
static 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 SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxDispatcher * GetDispatcher()
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
SfxFrame & GetFrame() const
weld::Window * GetFrameWeld() const
SfxInPlaceClient * FindIPClient(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, vcl::Window *pObjParentWin) const
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
SfxViewFrame * GetViewFrame() const
virtual SfxObjectShell * GetObjectShell() override
static 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:305
void SetMaxCount(editeng::SortedAutoCompleteStrings::size_type n)
Definition: acmplwrd.cxx:285
void CheckChangedList(const editeng::SortedAutoCompleteStrings &rNewLst)
Definition: acmplwrd.cxx:340
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:1599
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:1394
void UpdateFontList()
Definition: docshini.cxx:414
SAL_DLLPRIVATE void RemoveLink()
Definition: docshini.cxx:429
virtual void DoFlushDocInfo() override
override to update text fields
Definition: docsh2.cxx:188
IDocumentDeviceAccess & getIDocumentDeviceAccess()
Definition: docshini.cxx:695
SwDocShell(SfxObjectCreateMode eMode=SfxObjectCreateMode::EMBEDDED)
Doc is required for SO data exchange!
Definition: docshini.cxx:317
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pClipFormat, OUString *pLongUserName, sal_Int32 nFileFormat, bool bTemplate=false) const override
Definition: docsh2.cxx:1403
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem) override
Definition: docsh2.cxx:1389
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:1494
SfxInPlaceClient * GetIPClient(const ::svt::EmbeddedObjectRef &xObjRef)
Definition: docsh2.cxx:1682
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:615
SAL_DLLPRIVATE void AddLink()
Methods for access to doc.
Definition: docshini.cxx:395
void UpdateChildWindows()
Definition: docsh2.cxx:1459
virtual void SetModified(bool=true) override
Definition: docsh2.cxx:1429
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:194
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:400
static SwAutoCompleteWord & GetAutoCompleteWords()
Definition: doc.hxx:1547
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:244
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:341
void InvalidateAutoCompleteFlag()
Definition: doc.cxx:1186
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:411
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:182
std::vector< svx::ClassificationResult > CollectAdvancedClassification()
Definition: edfcol.cxx:947
void ApplyParagraphClassification(std::vector< svx::ClassificationResult > aResult)
Apply the classification to the paragraph at cursor.
Definition: edfcol.cxx:1264
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void SetWatermark(const SfxWatermarkItem &rText)
Definition: edfcol.cxx:1608
void SignParagraph()
Sign the paragraph at the cursor.
Definition: edfcol.cxx:1751
void SetNewDoc()
Optimizing UI.
Definition: edws.cxx:284
static void SetAutoFormatFlags(SvxSwAutoFormatFlags const *)
Definition: autofmt.cxx:2801
std::vector< svx::ClassificationResult > CollectParagraphClassification()
Definition: edfcol.cxx:1343
void SetClassification(const OUString &rName, SfxClassificationPolicyType eType)
Definition: edfcol.cxx:1068
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:175
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:421
static SwSmartTagMgr & Get()
void SaveContent(const OUString &rTmpFile)
Definition: srcview.cxx:250
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:1583
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
bool IsAtDocNodeSet() const
Definition: fmtcol.cxx:334
bool getBrowseMode() const
Definition: viewopt.hxx:580
bool IsViewLocked() const
Definition: viewsh.hxx:471
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:433
void InvalidateLayout(bool bSizeChanged)
Definition: viewsh.cxx:2103
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2160
void LockView(bool b)
Definition: viewsh.hxx:472
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:416
virtual FmFormShell * GetFormShell() override
Definition: view.hxx:581
virtual sal_uInt16 SetPrinter(SfxPrinter *pNew, SfxPrinterChangeFlags nDiff=SFX_PRINTER_ALL) override
Definition: viewprt.cxx:97
SwEditWin & GetEditWin()
Definition: view.hxx:419
SwDocShell * GetDocShell()
Definition: view.cxx:1160
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:122
bool IsPageDescs() const
Definition: shellio.hxx:115
bool IsMerge() const
Definition: shellio.hxx:124
bool IsNumRules() const
Definition: shellio.hxx:121
void SetTextFormats(const bool bNew)
Definition: shellio.hxx:119
css::uno::Reference< css::io::XInputStream > & GetInputStream()
Definition: shellio.hxx:131
void SetMerge(const bool bNew)
Definition: shellio.hxx:125
void SetPageDescs(const bool bNew)
Definition: shellio.hxx:116
bool IsFrameFormats() const
Definition: shellio.hxx:112
bool IsTextFormats() const
Definition: shellio.hxx:118
void SetFrameFormats(const bool bNew)
Definition: shellio.hxx:113
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:170
#define FN_OUTLINE_TO_CLIPBOARD
Definition: cmdid.h:72
#define FN_OPEN_FILE
Definition: cmdid.h:69
#define FN_SHADOWCURSOR
Definition: cmdid.h:531
#define FN_REDLINE_ACCEPT_ALL
Definition: cmdid.h:147
#define FN_ABSTRACT_NEWDOC
Definition: cmdid.h:454
#define FN_NEW_GLOBAL_DOC
Definition: cmdid.h:68
#define FN_ABSTRACT_STARIMPRESS
Definition: cmdid.h:455
#define FN_NEW_HTML_DOC
Definition: cmdid.h:74
#define FN_REDLINE_REJECT_ALL
Definition: cmdid.h:148
#define FN_REDLINE_SHOW
Definition: cmdid.h:129
#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:1697
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:86
#define HID_SEND_HTML_CTRL_EDIT_FILEURL
Definition: helpids.h:97
#define HID_SEND_MASTER_CTRL_CHECKBOX_AUTOEXTENSION
Definition: helpids.h:90
#define HID_SEND_MASTER_CTRL_EDIT_FILEURL
Definition: helpids.h:89
#define HID_SEND_HTML_CTRL_PUSHBUTTON_CANCEL
Definition: helpids.h:94
#define HID_SEND_HTML_CTRL_PUSHBUTTON_OK
Definition: helpids.h:93
#define HID_SEND_HTML_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:99
#define HID_SEND_MASTER_CTRL_LISTBOX_FILTER
Definition: helpids.h:87
#define HID_SEND_MASTER_CTRL_CONTROL_FILEVIEW
Definition: helpids.h:88
#define HID_SEND_HTML_CTRL_CONTROL_FILEVIEW
Definition: helpids.h:96
#define HID_SEND_HTML_CTRL_LISTBOX_FILTER
Definition: helpids.h:95
#define HID_SEND_MASTER_CTRL_PUSHBUTTON_OK
Definition: helpids.h:85
#define HID_SEND_HTML_CTRL_CHECKBOX_AUTOEXTENSION
Definition: helpids.h:98
#define HID_SEND_MASTER_CTRL_LISTBOX_TEMPLATE
Definition: helpids.h:91
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:165
#define SW_MOD()
Definition: swmodule.hxx:256
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
unsigned char sal_uInt8
RET_OK
RET_YES