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