LibreOffice Module sfx2 (master) 1
objmisc.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <tools/inetmsg.hxx>
24#include <svl/eitem.hxx>
25#include <svl/stritem.hxx>
26#include <svl/intitem.hxx>
27#include <svtools/svparser.hxx>
29#include <sal/log.hxx>
30#include <o3tl/string_view.hxx>
31
32#include <com/sun/star/awt/XTopWindow.hpp>
33#include <com/sun/star/beans/XPropertySet.hpp>
34#include <com/sun/star/container/XChild.hpp>
35#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
36#include <com/sun/star/document/XDocumentProperties.hpp>
37#include <com/sun/star/document/MacroExecMode.hpp>
38#include <com/sun/star/document/XScriptInvocationContext.hpp>
39#include <com/sun/star/embed/EmbedStates.hpp>
40#include <com/sun/star/embed/XEmbeddedObject.hpp>
41#include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
42#include <com/sun/star/script/provider/XScript.hpp>
43#include <com/sun/star/script/provider/XScriptProvider.hpp>
44#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
45#include <com/sun/star/uri/UriReferenceFactory.hpp>
46#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
47#include <com/sun/star/util/XModifiable.hpp>
48
49#include <com/sun/star/uno/Reference.h>
50#include <com/sun/star/uno/Any.h>
51#include <com/sun/star/task/ErrorCodeRequest.hpp>
52
54#include <comphelper/string.hxx>
55
56#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
57#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
58#include <com/sun/star/task/InteractionClassification.hpp>
59#include <com/sun/star/task/XInteractionHandler.hpp>
60#include <com/sun/star/frame/XModel.hpp>
61
62#include <basic/basmgr.hxx>
63#include <basic/sberrors.hxx>
64#include <utility>
65#include <vcl/weld.hxx>
66#include <basic/sbx.hxx>
67#include <svtools/sfxecode.hxx>
68
70#include <tools/urlobj.hxx>
72#include <rtl/uri.hxx>
73#include <vcl/svapp.hxx>
80#include <officecfg/Office/Common.hxx>
81
83#include <sfx2/app.hxx>
84#include <appdata.hxx>
85#include <sfx2/request.hxx>
86#include <sfx2/bindings.hxx>
87#include <sfx2/sfxresid.hxx>
88#include <sfx2/docfile.hxx>
89#include <sfx2/objsh.hxx>
90#include <objshimp.hxx>
91#include <sfx2/event.hxx>
92#include <sfx2/viewfrm.hxx>
93#include <sfx2/sfxuno.hxx>
94#include <sfx2/module.hxx>
95#include <sfx2/docfac.hxx>
96#include <sfx2/sfxsids.hrc>
97#include <sfx2/strings.hrc>
98#include <workwin.hxx>
99#include <sfx2/sfxdlg.hxx>
100#include <sfx2/infobar.hxx>
101#include <sfx2/sfxbasemodel.hxx>
102#include <openflag.hxx>
103#include "objstor.hxx"
104#include <appopen.hxx>
105
106#include <memory>
107
108using namespace ::com::sun::star;
109using namespace ::com::sun::star::uno;
110using namespace ::com::sun::star::ucb;
111using namespace ::com::sun::star::document;
112using namespace ::com::sun::star::frame;
113using namespace ::com::sun::star::script;
114using namespace ::com::sun::star::script::provider;
115using namespace ::com::sun::star::container;
116
117// class SfxHeaderAttributes_Impl ----------------------------------------
118
119namespace {
120
121class SfxHeaderAttributes_Impl : public SvKeyValueIterator
122{
123private:
124 SfxObjectShell* pDoc;
126 bool bAlert;
127
128public:
129 explicit SfxHeaderAttributes_Impl( SfxObjectShell* pSh ) :
130 pDoc( pSh ),
131 xIter( pSh->GetMedium()->GetHeaderAttributes_Impl() ),
132 bAlert( false ) {}
133
134 virtual bool GetFirst( SvKeyValue& rKV ) override { return xIter->GetFirst( rKV ); }
135 virtual bool GetNext( SvKeyValue& rKV ) override { return xIter->GetNext( rKV ); }
136 virtual void Append( const SvKeyValue& rKV ) override;
137
138 void ClearForSourceView() { xIter = new SvKeyValueIterator; bAlert = false; }
139 void SetAttributes();
140 void SetAttribute( const SvKeyValue& rKV );
141};
142
143}
144
145sal_uInt16 const aTitleMap_Impl[3][2] =
146{
147 // local remote
148 /* SFX_TITLE_CAPTION */ { SFX_TITLE_FILENAME, SFX_TITLE_TITLE },
149 /* SFX_TITLE_PICKLIST */ { 32, SFX_TITLE_FULLNAME },
150 /* SFX_TITLE_HISTORY */ { 32, SFX_TITLE_FULLNAME }
151};
152
153
155{
156 return pImpl->bIsAbortingImport;
157}
158
159
160uno::Reference<document::XDocumentProperties>
162{
163 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
164 GetModel(), uno::UNO_QUERY_THROW);
165 uno::Reference<document::XDocumentProperties> xDocProps(
166 xDPS->getDocumentProperties());
167 DBG_ASSERT(xDocProps.is(),
168 "SfxObjectShell: model has no DocumentProperties");
169 return xDocProps;
170}
171
172
174{
175}
176
177
178// Note: the only thing that calls this is the modification event handler
179// that is installed at the XDocumentProperties
181{
182 if ( IsLoading() )
183 return;
184
185 SetModified();
186 uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
187 DoFlushDocInfo(); // call template method
188 const OUString url(xDocProps->getAutoloadURL());
189 sal_Int32 delay(xDocProps->getAutoloadSecs());
190 SetAutoLoad( INetURLObject(url), delay * 1000,
191 (delay > 0) || !url.isEmpty() );
192}
193
194void SfxObjectShell::AppendInfoBarWhenReady(const OUString& sId, const OUString& sPrimaryMessage,
195 const OUString& sSecondaryMessage,
196 InfobarType aInfobarType, bool bShowCloseButton)
197{
198 InfobarData aInfobarData;
199 aInfobarData.msId = sId;
200 aInfobarData.msPrimaryMessage = sPrimaryMessage;
201 aInfobarData.msSecondaryMessage = sSecondaryMessage;
202 aInfobarData.maInfobarType = aInfobarType;
203 aInfobarData.mbShowCloseButton = bShowCloseButton;
204 Get_Impl()->m_aPendingInfobars.emplace_back(aInfobarData);
205}
206
207std::vector<InfobarData>& SfxObjectShell::getPendingInfobars()
208{
210}
211
213{
214 if (pImpl->lErr==ERRCODE_NONE)
215 {
216 pImpl->lErr=lErr;
217 }
218}
219
221{
222 return GetErrorCode().IgnoreWarning();
223}
224
226{
227 ErrCode lError=pImpl->lErr;
228 if(!lError && GetMedium())
229 lError=GetMedium()->GetErrorCode();
230 return lError;
231}
232
234{
235 pImpl->lErr=ERRCODE_NONE;
236 SfxMedium * pMed = GetMedium();
237 if( pMed )
238 pMed->ResetError();
239}
240
242{
243 SAL_INFO_IF( bEnable == pImpl->m_bEnableSetModified, "sfx", "SFX_PERSIST: EnableSetModified 2x called with the same value" );
244 pImpl->m_bEnableSetModified = bEnable;
245}
246
247
249{
250 // Don't allow when user explicitly requested read only (IsLoadReadonly() or IsOriginallyLoadedReadOnlyMedium())
251 return pImpl->m_bEnableSetModified && ! (IsLoadReadonly() || IsOriginallyLoadedReadOnlyMedium());
252}
253
254
256{
257 if ( pImpl->m_bIsModified )
258 return true;
259
260 if ( !pImpl->m_xDocStorage.is() || IsReadOnly() )
261 {
262 // if the document still has no storage and is not set to be modified explicitly it is not modified
263 // a readonly document is also not modified
264
265 return false;
266 }
267
268 if (pImpl->mxObjectContainer)
269 {
270 const uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
271 for ( const auto& rName : aNames )
272 {
273 uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( rName );
274 OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!" );
275 if ( xObj.is() )
276 {
277 try
278 {
279 sal_Int32 nState = xObj->getCurrentState();
280 if ( nState != embed::EmbedStates::LOADED )
281 {
282 uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
283 if ( xModifiable.is() && xModifiable->isModified() )
284 return true;
285 }
286 }
287 catch( uno::Exception& )
288 {}
289 }
290 }
291 }
292
293 return false;
294}
295
296
297void SfxObjectShell::SetModified( bool bModifiedP )
298{
299 SAL_INFO_IF( !bModifiedP && !IsEnableSetModified(), "sfx",
300 "SFX_PERSIST: SetModified( sal_False ), although IsEnableSetModified() == sal_False" );
301
302 if( !IsEnableSetModified() )
303 return;
304
305 if( pImpl->m_bIsModified != bModifiedP )
306 {
307 pImpl->m_bIsModified = bModifiedP;
309 }
310}
311
312
314{
315 if ( pImpl->bClosing )
316 // SetModified dispose of the models!
317 return;
318
319
320 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
321 if ( pViewFrame )
322 pViewFrame->GetBindings().Invalidate( SID_SAVEDOCS );
323
324 Invalidate( SID_SIGNATURE );
325 Invalidate( SID_MACRO_SIGNATURE );
326 Broadcast( SfxHint( SfxHintId::TitleChanged ) ); // xmlsec05, signed state might change in title...
327
329}
330
331
333
334/* [Description]
335
336 Returns sal_True if the document for the UI is treated as r/o. This is
337 regardless of the actual r/o, which can be checked with <IsReadOnly()>.
338*/
339
340{
341 return pImpl->bReadOnlyUI;
342}
343
344
346
347/* [Description]
348
349 Returns sal_True when the medium is r/o, for instance when opened as r/o.
350*/
351
352{
353 if ( !pMedium )
354 return true;
355 return pMedium->IsReadOnly();
356}
357
359{
360 return pMedium == nullptr || pMedium->IsOriginallyReadOnly();
361}
362
364{
365 return pMedium != nullptr && pMedium->IsOriginallyLoadedReadOnly();
366}
367
368
369void SfxObjectShell::SetReadOnlyUI( bool bReadOnly )
370
371/* [Description]
372
373 Turns the document in a r/o and r/w state respectively without reloading
374 it and without changing the open mode of the medium.
375*/
376
377{
378 if ( bReadOnly != pImpl->bReadOnlyUI )
379 {
380 pImpl->bReadOnlyUI = bReadOnly;
381 Broadcast( SfxHint(SfxHintId::ModeChanged) );
382 }
383}
384
385
387{
388 // Let the document be completely readonly, means that the
389 // medium open mode is adjusted accordingly, and the write lock
390 // on the file is removed.
391
392 if ( !pMedium || IsReadOnlyMedium() )
393 return;
394
395 bool bWasROUI = IsReadOnly();
396
397 pMedium->UnlockFile( false );
398
399 // the storage-based mediums are already based on the temporary file
400 // so UnlockFile has already closed the locking stream
403
405 pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) );
406
407 if ( !bWasROUI )
408 Broadcast( SfxHint(SfxHintId::ModeChanged) );
409}
410
411
413{
414 return pImpl->bReadOnlyUI || pMedium == nullptr;
415}
416
417
419{
420 return pImpl->bModalMode || pImpl->bRunningMacro;
421}
422
424{
425 return !IsInModalMode();
426}
427
428
430{
431 if ( !pImpl->bRunningMacro != !bModal )
432 {
433 pImpl->bRunningMacro = bModal;
434 Broadcast( SfxHint( SfxHintId::ModeChanged ) );
435 }
436}
437
438
440{
441 // Broadcast only if modified, or otherwise it will possibly go into
442 // an endless loop
443 if ( pImpl->bModalMode == bModal )
444 return;
445
446 // Central count
447 sal_uInt16 &rDocModalCount = SfxGetpApp()->Get_Impl()->nDocModalMode;
448 if ( bModal )
449 ++rDocModalCount;
450 else
451 --rDocModalCount;
452
453 // Switch
454 pImpl->bModalMode = bModal;
455 Broadcast( SfxHint( SfxHintId::ModeChanged ) );
456}
457
458#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
459
460bool SfxObjectShell::SwitchToShared( bool bShared, bool bSave )
461{
462 bool bResult = true;
463
464 if ( bShared != IsDocShared() )
465 {
467
468 if ( aOrigURL.isEmpty() && bSave )
469 {
470 // this is a new document, let it be stored before switching to the shared mode;
471 // the storing should be done without shared flag, since it is possible that the
472 // target location does not allow to create sharing control file;
473 // the shared flag will be set later after creation of sharing control file
474 SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( this );
475
476 if ( pViewFrame )
477 {
478 // TODO/LATER: currently the application guards against the reentrance problem
479 const SfxPoolItem* pItem = pViewFrame->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC : SID_SAVEASDOC );
480 const SfxBoolItem* pResult = dynamic_cast<const SfxBoolItem*>( pItem );
481 bResult = ( pResult && pResult->GetValue() );
482 if ( bResult )
484 }
485 }
486
487 bool bOldValue = HasSharedXMLFlagSet();
488 SetSharedXMLFlag( bShared );
489
490 bool bRemoveEntryOnError = false;
491 if ( bResult && bShared )
492 {
493 try
494 {
495 ::svt::ShareControlFile aControlFile( aOrigURL );
496 aControlFile.InsertOwnEntry();
497 bRemoveEntryOnError = true;
498 }
499 catch( uno::Exception& )
500 {
501 bResult = false;
502 }
503 }
504
505 if ( bResult && bSave )
506 {
507 SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( this );
508
509 if ( pViewFrame )
510 {
511 // TODO/LATER: currently the application guards against the reentrance problem
512 SetModified(); // the modified flag has to be set to let the document be stored with the shared flag
513 try
514 {
515 // Do *not* use dispatch mechanism in this place - we don't want others (extensions etc.) to intercept this.
516 pImpl->pBaseModel->store();
517 bResult = true;
518 }
519 catch (...)
520 {
521 bResult = false;
522 }
523 }
524 }
525
526 if ( bResult )
527 {
528 // TODO/LATER: Is it possible that the following calls fail?
529 if ( bShared )
530 {
531 pImpl->m_aSharedFileURL = aOrigURL;
533 }
534 else
535 {
536 const OUString aTempFileURL = pMedium->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE );
538 pImpl->m_aSharedFileURL.clear();
539
540 // now remove the temporary file the document was based on
541 ::utl::UCBContentHelper::Kill( aTempFileURL );
542
543 try
544 {
545 // aOrigURL can not be used since it contains an old value
546 ::svt::ShareControlFile aControlFile( GetMedium()->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
547 aControlFile.RemoveFile();
548 }
549 catch( uno::Exception& )
550 {
551 }
552 }
553 }
554 else
555 {
556 // the saving has failed!
557 if ( bRemoveEntryOnError )
558 {
559 try
560 {
561 ::svt::ShareControlFile aControlFile( aOrigURL );
562 aControlFile.RemoveEntry();
563 }
564 catch( uno::Exception& )
565 {}
566 }
567
568 SetSharedXMLFlag( bOldValue );
569 }
570 }
571 else
572 bResult = false; // the second switch to the same mode
573
574 if ( bResult )
575 SetTitle( "" );
576
577 return bResult;
578}
579
580
581void SfxObjectShell::FreeSharedFile( const OUString& aTempFileURL )
582{
583 SetSharedXMLFlag( false );
584
585 if ( !IsDocShared() || aTempFileURL.isEmpty()
586 || ::utl::UCBContentHelper::EqualURLs( aTempFileURL, GetSharedFileURL() ) )
587 return;
588
589 if ( pImpl->m_bAllowShareControlFileClean )
590 {
591 try
592 {
594 aControlFile.RemoveEntry();
595 }
596 catch( uno::Exception& )
597 {
598 }
599 }
600
601 // the cleaning is forbidden only once
602 pImpl->m_bAllowShareControlFileClean = true;
603
604 // now remove the temporary file the document is based currently on
605 ::utl::UCBContentHelper::Kill( aTempFileURL );
606
607 pImpl->m_aSharedFileURL.clear();
608}
609
610
612{
613 pImpl->m_bAllowShareControlFileClean = false;
614}
615
616
617void SfxObjectShell::SetSharedXMLFlag( bool bFlag ) const
618{
619 pImpl->m_bSharedXMLFlag = bFlag;
620}
621
622
624{
625 return pImpl->m_bSharedXMLFlag;
626}
627
628#endif
629
631{
632#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
633 return ( !pImpl->m_aSharedFileURL.isEmpty() );
634#else
635 return false;
636#endif
637}
638
639
641{
642#if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
643 return pImpl->m_aSharedFileURL;
644#else
645 return OUString();
646#endif
647}
648
650{
652}
653
654
656{
657 return pImpl->aBitSet;
658}
659
660
661// changes the title of the document
662
664(
665 const OUString& rTitle // the new Document Title
666)
667
668/* [Description]
669
670 With this method, the title of the document can be set.
671 This corresponds initially to the full file name. A setting of the
672 title does not affect the file name, but it will be shown in the
673 Caption-Bars of the MDI-window.
674*/
675
676{
677
678 // Nothing to do?
679 if ( ( ( HasName() && pImpl->aTitle == rTitle )
680 || ( !HasName() && GetTitle() == rTitle ) )
681 && !IsDocShared() )
682 return;
683
684 SfxApplication *pSfxApp = SfxGetpApp();
685
686 // If possible release the unnamed number.
687 if ( pImpl->bIsNamedVisible && USHRT_MAX != pImpl->nVisualDocumentNumber )
688 {
689 pSfxApp->ReleaseIndex(pImpl->nVisualDocumentNumber);
690 pImpl->bIsNamedVisible = false;
691 }
692
693 // Set Title
694 pImpl->aTitle = rTitle;
695
696 // Notification
697 if ( GetMedium() )
698 {
700 Broadcast( SfxHint(SfxHintId::TitleChanged) );
701 }
702}
703
704
705
706OUString SfxObjectShell::GetTitle( sal_uInt16 nMaxLength ) const
707
708/* [Description]
709
710 Returns the title or logical file name of the document, depending on the
711 'nMaxLength'.
712
713 If the file name with path is used, the Name shortened by replacing one or
714 more directory names with "...", URLs are currently always returned
715 in complete form.
716*/
717
718{
719 SfxMedium *pMed = GetMedium();
720 if ( IsLoading() )
721 return OUString();
722
723 // Create Title?
724 if ( SFX_TITLE_DETECT == nMaxLength && pImpl->aTitle.isEmpty() )
725 {
726 static bool bRecur = false;
727 if ( bRecur )
728 return "-not available-";
729 bRecur = true;
730
731 OUString aTitle;
732
733 if ( pMed )
734 {
735 const SfxStringItem* pNameItem = SfxItemSet::GetItem<SfxStringItem>(pMed->GetItemSet(), SID_DOCINFO_TITLE, false);
736 if ( pNameItem )
737 aTitle = pNameItem->GetValue();
738 }
739
740 if ( aTitle.isEmpty() )
741 aTitle = GetTitle( SFX_TITLE_FILENAME );
742
743 bRecur = false;
744 return aTitle;
745 }
746
747 if (SFX_TITLE_APINAME == nMaxLength )
748 return GetAPIName();
749
750 // Picklist/Caption is mapped
751 if ( pMed && ( nMaxLength == SFX_TITLE_CAPTION || nMaxLength == SFX_TITLE_PICKLIST ) )
752 {
753 // If a specific title was given at open:
754 // important for URLs: use INetProtocol::File for which the set title is not
755 // considered. (See below, analysis of aTitleMap_Impl)
756 const SfxStringItem* pNameItem = SfxItemSet::GetItem<SfxStringItem>(pMed->GetItemSet(), SID_DOCINFO_TITLE, false);
757 if ( pNameItem )
758 return pNameItem->GetValue();
759 }
760
761 // Still unnamed?
762 DBG_ASSERT( !HasName() || pMed, "HasName() but no Medium?!?" );
763 if ( !HasName() || !pMed )
764 {
765 // Title already set?
766 if ( !pImpl->aTitle.isEmpty() )
767 return pImpl->aTitle;
768
769 // must it be numbered?
770 const OUString aNoName(SfxResId(STR_NONAME));
771 if (pImpl->bIsNamedVisible)
772 {
773 // Append number
774 return aNoName + " " + OUString::number(pImpl->nVisualDocumentNumber);
775 }
776
777 // Document called "Untitled" for the time being
778 return aNoName;
779 }
780 assert(pMed);
781
782 const INetURLObject aURL( IsDocShared() ? GetSharedFileURL() : GetMedium()->GetName() );
783 if ( nMaxLength > SFX_TITLE_CAPTION && nMaxLength <= SFX_TITLE_HISTORY )
784 {
785 sal_uInt16 nRemote;
786 if (aURL.GetProtocol() == INetProtocol::File)
787 nRemote = 0;
788 else
789 nRemote = 1;
790 nMaxLength = aTitleMap_Impl[nMaxLength-SFX_TITLE_CAPTION][nRemote];
791 }
792
793 // Local file?
794 if ( aURL.GetProtocol() == INetProtocol::File )
795 {
796 if ( nMaxLength == SFX_TITLE_FULLNAME )
797 return aURL.HasMark() ? INetURLObject( aURL.GetURLNoMark() ).PathToFileName() : aURL.PathToFileName();
798 if ( nMaxLength == SFX_TITLE_FILENAME )
800 if ( pImpl->aTitle.isEmpty() )
801 pImpl->aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT,
803 }
804 else
805 {
806 if ( nMaxLength >= SFX_TITLE_MAXLEN )
807 {
808 const OUString aComplete( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
809 if( aComplete.getLength() > nMaxLength )
810 return OUString::Concat("...") + aComplete.subView( aComplete.getLength() - nMaxLength + 3, nMaxLength - 3 );
811 return aComplete;
812 }
813 if ( nMaxLength == SFX_TITLE_FILENAME )
814 {
816 return aName.isEmpty() ? aURL.GetURLNoPass() : aName;
817 }
818 if ( nMaxLength == SFX_TITLE_FULLNAME )
819 return aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri );
820
821 // Generate Title from file name if possible
822 if ( pImpl->aTitle.isEmpty() )
823 pImpl->aTitle = aURL.GetBase();
824
825 // workaround for the case when the name can not be retrieved from URL by INetURLObject
826 if ( pImpl->aTitle.isEmpty() )
827 pImpl->aTitle = aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
828 }
829
830 // Complete Title
831 return pImpl->aTitle;
832}
833
834
836
837/* [Description]
838
839 Returns the title of the new document, DocInfo-Title or
840 File name. Is required for loading from template or SaveAs.
841*/
842
843{
844 pImpl->aTitle.clear();
846
847 Broadcast( SfxHint(SfxHintId::TitleChanged) );
848}
849
850
852{
853 if ( !pImpl->bIsNamedVisible )
854 {
855 pImpl->bIsNamedVisible = true;
856 if ( !HasName() && USHRT_MAX == pImpl->nVisualDocumentNumber && pImpl->aTitle.isEmpty() )
857 {
858 pImpl->nVisualDocumentNumber = SfxGetpApp()->GetFreeIndex();
859 Broadcast( SfxHint(SfxHintId::TitleChanged) );
860 }
861 }
862
864}
865
867{
868 bHasName = false;
869 GetModel()->attachResource( OUString(), GetModel()->getArgs() );
870}
871
872
874{
875 return pImpl->pProgress;
876}
877
878
880(
881 SfxProgress *pProgress /* to started <SfxProgress> or 0,
882 if the progress is to be reset */
883)
884
885/* [Description]
886
887 Internal method to set or reset the Progress modes for
888 SfxObjectShell.
889*/
890
891{
892 DBG_ASSERT( ( !pImpl->pProgress && pProgress ) ||
893 ( pImpl->pProgress && !pProgress ),
894 "Progress activation/deactivation mismatch" );
895 pImpl->pProgress = pProgress;
896}
897
898
900{
901 SfxApplication* pSfxApp = SfxGetpApp();
902 if ( pSfxApp->IsDowning() || IsLoading() || !pFrame || pFrame->GetFrame().IsClosing_Impl() )
903 return;
904
905 const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_HIDDEN, false);
906 if ( !pHiddenItem || !pHiddenItem->GetValue() )
907 {
908 SfxEventHintId nId = pImpl->nEventId;
909 pImpl->nEventId = SfxEventHintId::NONE;
911 pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::OPENDOC), this, pFrame->GetFrame().GetController() ), false);
912 else if (nId == SfxEventHintId::CreateDoc )
913 pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::CREATEDOC), this, pFrame->GetFrame().GetController() ), false);
914 }
915}
916
917
919{
920 pImpl->nEventId = nId;
921}
922
924
925/* Returns whether an Autoload is allowed to be executed. Before the
926 surrounding FrameSet of the AutoLoad is also taken into account as well.
927*/
928
929{
930 return !IsReadOnly();
931}
932
933
934void SfxObjectShell::BreakMacroSign_Impl( bool bBreakMacroSign )
935{
936 pImpl->m_bMacroSignBroken = bBreakMacroSign;
937}
938
939
941{
942 // make sure LO evaluates the macro signatures, so it can be preserved
944
945 uno::Reference< task::XInteractionHandler > xInteraction;
946 if ( GetMedium() )
947 xInteraction = GetMedium()->GetInteractionHandler();
948
949 // check if there is a broken signature...
951
952 CheckEncryption_Impl( xInteraction );
953
954 // check macro security
955 const bool bHasValidContentSignature = HasValidSignatures();
956 pImpl->aMacroMode.checkMacrosOnLoading( xInteraction, bHasValidContentSignature );
957}
958
959
960void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
961{
962 OUString aVersion;
963 bool bIsEncrypted = false;
964 bool bHasNonEncrypted = false;
965
966 try
967 {
968 uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
969 xPropSet->getPropertyValue("Version") >>= aVersion;
970 xPropSet->getPropertyValue("HasEncryptedEntries") >>= bIsEncrypted;
971 xPropSet->getPropertyValue("HasNonEncryptedEntries") >>= bHasNonEncrypted;
972 }
973 catch( uno::Exception& )
974 {
975 }
976
977 if ( aVersion.compareTo( ODFVER_012_TEXT ) < 0 )
978 return;
979
980 // this is ODF1.2 or later
981 if ( !(bIsEncrypted && bHasNonEncrypted) )
982 return;
983
984 if ( !pImpl->m_bIncomplEncrWarnShown )
985 {
986 // this is an encrypted document with nonencrypted streams inside, show the warning
987 css::task::ErrorCodeRequest aErrorCode;
988 aErrorCode.ErrCode = sal_uInt32(ERRCODE_SFX_INCOMPLETE_ENCRYPTION);
989
990 SfxMedium::CallApproveHandler( xHandler, uno::Any( aErrorCode ), false );
991 pImpl->m_bIncomplEncrWarnShown = true;
992 }
993
994 // broken signatures imply no macro execution at all
995 pImpl->aMacroMode.disallowMacroExecution();
996}
997
998
1000{
1001 SignatureState nSignatureState = GetDocumentSignatureState();
1002 bool bSignatureBroken = ( nSignatureState == SignatureState::BROKEN );
1003 if ( !bSignatureBroken )
1004 return;
1005
1006 // broken signatures imply no macro execution at all
1007 pImpl->aMacroMode.disallowMacroExecution();
1008}
1009
1010
1012 const INetURLObject& rUrl, sal_uInt32 nTime, bool bReload )
1013{
1014 pImpl->pReloadTimer.reset();
1015 if ( bReload )
1016 {
1017 pImpl->pReloadTimer.reset(new AutoReloadTimer_Impl(
1019 nTime, this ));
1020 pImpl->pReloadTimer->Start();
1021 }
1022}
1023
1025{
1026 pImpl->nLoadedFlags = nFlags;
1027}
1028
1030{
1031 return ( pImpl->nLoadedFlags == SfxLoadedFlags::ALL );
1032}
1033
1035{
1036 if ( pImpl->bModelInitialized )
1037 return;
1038
1039 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false);
1040 if ( pSalvageItem )
1041 {
1042 pImpl->aTempName = pMedium->GetPhysicalName();
1043 pMedium->GetItemSet()->ClearItem( SID_DOC_SALVAGE );
1044 pMedium->GetItemSet()->ClearItem( SID_FILE_NAME );
1045 pMedium->GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetOrigURL() ) );
1046 }
1047 else
1048 {
1049 pMedium->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL );
1050 pMedium->GetItemSet()->ClearItem( SID_DOCUMENT );
1051 }
1052
1053 pMedium->GetItemSet()->ClearItem( SID_REFERER );
1054 uno::Reference< frame::XModel > xModel = GetModel();
1055 if ( xModel.is() )
1056 {
1057 SfxItemSet *pSet = GetMedium()->GetItemSet();
1058 if ( !GetMedium()->IsReadOnly() )
1059 pSet->ClearItem( SID_INPUTSTREAM );
1060 uno::Sequence< beans::PropertyValue > aArgs;
1061 TransformItems( SID_OPENDOC, *pSet, aArgs );
1062 xModel->attachResource( GetMedium()->GetOrigURL(), aArgs );
1064 }
1065
1066 pImpl->bModelInitialized = true;
1067}
1068
1070{
1071 bool bSetModifiedTRUE = false;
1072 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false);
1073 if( ( nFlags & SfxLoadedFlags::MAINDOCUMENT ) && !(pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT )
1074 && !(pImpl->nFlagsInProgress & SfxLoadedFlags::MAINDOCUMENT ))
1075 {
1076 pImpl->nFlagsInProgress |= SfxLoadedFlags::MAINDOCUMENT;
1077 static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())->SetAttributes();
1078
1079 if ( ( GetModifyPasswordHash() || GetModifyPasswordInfo().hasElements() ) && !IsModifyPasswordEntered() )
1080 SetReadOnly();
1081
1082 // Salvage
1083 if ( pSalvageItem )
1084 bSetModifiedTRUE = true;
1085
1086 if ( !IsEnableSetModified() )
1088
1089 if( !bSetModifiedTRUE && IsEnableSetModified() )
1090 SetModified( false );
1091
1093
1094 bHasName = true; // the document is loaded, so the name should already available
1097 pImpl->nFlagsInProgress &= ~SfxLoadedFlags::MAINDOCUMENT;
1098 }
1099
1100 if( ( nFlags & SfxLoadedFlags::IMAGES ) && !(pImpl->nLoadedFlags & SfxLoadedFlags::IMAGES )
1101 && !(pImpl->nFlagsInProgress & SfxLoadedFlags::IMAGES ))
1102 {
1103 pImpl->nFlagsInProgress |= SfxLoadedFlags::IMAGES;
1104 uno::Reference<document::XDocumentProperties> xDocProps(
1106 const OUString url(xDocProps->getAutoloadURL());
1107 sal_Int32 delay(xDocProps->getAutoloadSecs());
1108 SetAutoLoad( INetURLObject(url), delay * 1000,
1109 (delay > 0) || !url.isEmpty() );
1110 if( !bSetModifiedTRUE && IsEnableSetModified() )
1111 SetModified( false );
1112 Invalidate( SID_SAVEASDOC );
1113 pImpl->nFlagsInProgress &= ~SfxLoadedFlags::IMAGES;
1114 }
1115
1116 pImpl->nLoadedFlags |= nFlags;
1117
1118 if ( pImpl->nFlagsInProgress != SfxLoadedFlags::NONE )
1119 return;
1120
1121 // in case of reentrance calls the first called FinishedLoading() call on the stack
1122 // should do the notification, in result the notification is done when all the FinishedLoading() calls are finished
1123
1124 if ( bSetModifiedTRUE )
1125 SetModified();
1126 else
1127 SetModified( false );
1128
1129 if ( (pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT ) && (pImpl->nLoadedFlags & SfxLoadedFlags::IMAGES ) )
1130 {
1131 const SfxBoolItem* pTemplateItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_TEMPLATE, false);
1132 bool bTemplate = pTemplateItem && pTemplateItem->GetValue();
1133
1134 // closing the streams on loading should be under control of SFX!
1135 DBG_ASSERT( pMedium->IsOpen(), "Don't close the medium when loading documents!" );
1136
1137 if ( bTemplate )
1138 {
1140 }
1141 else
1142 {
1143 // if a readonly medium has storage then it's stream is already based on temporary file
1144 if( !(pMedium->GetOpenMode() & StreamMode::WRITE) && !pMedium->HasStorage_Impl() )
1145 // don't lock file opened read only
1147 }
1148 }
1149
1150 SetInitialized_Impl( false );
1151
1152 // Title is not available until loading has finished
1153 Broadcast( SfxHint( SfxHintId::TitleChanged ) );
1154 if ( pImpl->nEventId != SfxEventHintId::NONE )
1156}
1157
1159{
1160 // document is created from a template
1161 //TODO/LATER: should the templates always be XML docs!
1162
1163 SfxMedium* pTmpMedium = pMedium;
1164 if ( !pTmpMedium )
1165 return;
1166
1167 const OUString aName( pTmpMedium->GetName() );
1168 const SfxStringItem* pTemplNamItem = SfxItemSet::GetItem<SfxStringItem>(pTmpMedium->GetItemSet(), SID_TEMPLATE_NAME, false);
1169 OUString aTemplateName;
1170 if ( pTemplNamItem )
1171 aTemplateName = pTemplNamItem->GetValue();
1172 else
1173 {
1174 // !TODO/LATER: what's this?!
1175 // Interactive ( DClick, Contextmenu ) no long name is included
1176 aTemplateName = getDocProperties()->getTitle();
1177 if ( aTemplateName.isEmpty() )
1178 {
1180 aURL.CutExtension();
1182 }
1183 }
1184
1185 // set medium to noname
1186 pTmpMedium->SetName( OUString(), true );
1187 pTmpMedium->Init_Impl();
1188
1189 // drop resource
1190 SetNoName();
1192
1193 if( IsPackageStorageFormat_Impl( *pTmpMedium ) )
1194 {
1195 // untitled document must be based on temporary storage
1196 // the medium should not dispose the storage in this case
1197 uno::Reference < embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
1198 GetStorage()->copyToStorage( xTmpStor );
1199
1200 // the medium should disconnect from the original location
1201 // the storage should not be disposed since the document is still
1202 // based on it, but in DoSaveCompleted it will be disposed
1203 pTmpMedium->CanDisposeStorage_Impl( false );
1204 pTmpMedium->Close();
1205
1206 // setting the new storage the medium will be based on
1207 pTmpMedium->SetStorage_Impl( xTmpStor );
1208
1209 pMedium = nullptr;
1210 bool ok = DoSaveCompleted( pTmpMedium );
1211 assert(pMedium != nullptr);
1212 if( ok )
1213 {
1214 const SfxStringItem* pSalvageItem = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_DOC_SALVAGE, false);
1215 bool bSalvage = pSalvageItem != nullptr;
1216
1217 if ( !bSalvage )
1218 {
1219 // some further initializations for templates
1220 SetTemplate_Impl( aName, aTemplateName, this );
1221 }
1222
1223 // the medium should not dispose the storage, DoSaveCompleted() has let it to do so
1224 pTmpMedium->CanDisposeStorage_Impl( false );
1225 }
1226 else
1227 {
1229 }
1230 }
1231 else
1232 {
1233 // some further initializations for templates
1234 SetTemplate_Impl( aName, aTemplateName, this );
1235 pTmpMedium->CreateTempFile();
1236 }
1237
1238 // templates are never readonly
1239 pTmpMedium->GetItemSet()->ClearItem( SID_DOC_READONLY );
1240 pTmpMedium->SetOpenMode( SFX_STREAM_READWRITE, true );
1241
1242 // notifications about possible changes in readonly state and document info
1243 Broadcast( SfxHint(SfxHintId::ModeChanged) );
1244
1245 // created untitled document can't be modified
1246 SetModified( false );
1247}
1248
1249
1251/* [Description]
1252
1253 Has FinishedLoading been called?
1254*/
1255{
1256 return !( pImpl->nLoadedFlags & SfxLoadedFlags::MAINDOCUMENT );
1257}
1258
1259
1261/* [Description]
1262
1263 Here can Transfers get canceled, which were not registered
1264 by RegisterTransfer.
1265*/
1266{
1267 if( ( pImpl->nLoadedFlags & SfxLoadedFlags::ALL ) != SfxLoadedFlags::ALL )
1268 {
1269 pImpl->bIsAbortingImport = true;
1270 if( IsLoading() )
1272 }
1273}
1274
1275
1277 OUString _aURL, sal_uInt32 nTime, SfxObjectShell* pSh )
1278 : Timer("sfx2 AutoReloadTimer_Impl"), aUrl(std::move( _aURL )), pObjSh( pSh )
1279{
1280 SetTimeout( nTime );
1281}
1282
1283
1285{
1287
1288 if ( pFrame )
1289 {
1290 // Not possible/meaningful at the moment?
1292 {
1293 // Allow a retry
1294 Start();
1295 return;
1296 }
1297
1298 SfxAllItemSet aSet( SfxGetpApp()->GetPool() );
1299 aSet.Put( SfxBoolItem( SID_AUTOLOAD, true ) );
1300 if ( !aUrl.isEmpty() )
1301 aSet.Put( SfxStringItem( SID_FILE_NAME, aUrl ) );
1302 if (pObjSh->HasName()) {
1303 aSet.Put(
1304 SfxStringItem(SID_REFERER, pObjSh->GetMedium()->GetName()));
1305 }
1306 SfxRequest aReq( SID_RELOAD, SfxCallMode::SLOT, aSet );
1307 // this will delete this
1308 pObjSh->Get_Impl()->pReloadTimer.reset();
1309 pFrame->ExecReload_Impl( aReq );
1310 return;
1311 }
1312
1313 // this will delete this
1314 pObjSh->Get_Impl()->pReloadTimer.reset();
1315}
1316
1318{
1319 return GetFactory().GetModule();
1320}
1321
1322ErrCode SfxObjectShell::CallBasic( std::u16string_view rMacro,
1323 std::u16string_view rBasic, SbxArray* pArgs,
1324 SbxValue* pRet )
1325{
1326 SfxApplication* pApp = SfxGetpApp();
1327 if( pApp->GetName() != rBasic )
1328 {
1329 if ( !AdjustMacroMode() )
1331 }
1332
1333 BasicManager *pMgr = GetBasicManager();
1334 if( pApp->GetName() == rBasic )
1336 ErrCode nRet = SfxApplication::CallBasic( OUString(rMacro), pMgr, pArgs, pRet );
1337 return nRet;
1338}
1339
1340bool SfxObjectShell::isScriptAccessAllowed( const Reference< XInterface >& _rxScriptContext )
1341{
1342 try
1343 {
1344 Reference< XEmbeddedScripts > xScripts( _rxScriptContext, UNO_QUERY );
1345 if ( !xScripts.is() )
1346 {
1347 Reference< XScriptInvocationContext > xContext( _rxScriptContext, UNO_QUERY_THROW );
1348 xScripts.set( xContext->getScriptContainer(), UNO_SET_THROW );
1349 }
1350
1351 return xScripts->getAllowMacroExecution();
1352 }
1353 catch( const Exception& )
1354 {
1355 DBG_UNHANDLED_EXCEPTION("sfx.doc");
1356 }
1357 return false;
1358}
1359
1360// don't allow LibreLogo to be used with our mouseover/etc dom-alike events
1361bool SfxObjectShell::UnTrustedScript(const OUString& rScriptURL)
1362{
1363 if (!rScriptURL.startsWith("vnd.sun.star.script:"))
1364 return false;
1365
1366 // ensure URL Escape Codes are decoded
1367 css::uno::Reference<css::uri::XUriReference> uri(
1368 css::uri::UriReferenceFactory::create(comphelper::getProcessComponentContext())->parse(rScriptURL));
1369 css::uno::Reference<css::uri::XVndSunStarScriptUrl> sfUri(uri, css::uno::UNO_QUERY);
1370
1371 if (!sfUri.is())
1372 return false;
1373
1374 // pyuno encodes path separator as |
1375 OUString sScript = sfUri->getName().replace('|', '/');
1376
1377 // check if any path portion matches LibreLogo and ban it if it does
1378 sal_Int32 nIndex = 0;
1379 do
1380 {
1381 OUString aToken = sScript.getToken(0, '/', nIndex);
1382 if (aToken.startsWithIgnoreAsciiCase("LibreLogo") || aToken.indexOf('~') != -1)
1383 {
1384 return true;
1385 }
1386 }
1387 while (nIndex >= 0);
1388
1389 return false;
1390}
1391
1392ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL,
1393 const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const css::uno::Any* pCaller )
1394{
1395 SAL_INFO("sfx", "in CallXScript" );
1396 ErrCode nErr = ERRCODE_NONE;
1397
1398 bool bCaughtException = false;
1399 Any aException;
1400 try
1401 {
1402 if (!isScriptAccessAllowed(_rxScriptContext))
1404
1405 if ( UnTrustedScript(_rScriptURL) )
1407
1408 // obtain/create a script provider
1409 Reference< provider::XScriptProvider > xScriptProvider;
1410 Reference< provider::XScriptProviderSupplier > xSPS( _rxScriptContext, UNO_QUERY );
1411 if ( xSPS.is() )
1412 xScriptProvider.set( xSPS->getScriptProvider() );
1413
1414 if ( !xScriptProvider.is() )
1415 {
1416 Reference< provider::XScriptProviderFactory > xScriptProviderFactory =
1417 provider::theMasterScriptProviderFactory::get( ::comphelper::getProcessComponentContext() );
1418 xScriptProvider.set( xScriptProviderFactory->createScriptProvider( Any( _rxScriptContext ) ), UNO_SET_THROW );
1419 }
1420
1421 // ry to protect the invocation context's undo manager (if present), just in case the script tampers with it
1422 ::framework::DocumentUndoGuard aUndoGuard( _rxScriptContext );
1423
1424 // obtain the script, and execute it
1425 Reference< provider::XScript > xScript( xScriptProvider->getScript( _rScriptURL ), UNO_SET_THROW );
1426 if ( pCaller && pCaller->hasValue() )
1427 {
1428 Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY );
1429 if ( xProps.is() )
1430 {
1431 Sequence< uno::Any > aArgs{ *pCaller };
1432 xProps->setPropertyValue("Caller", uno::Any( aArgs ) );
1433 }
1434 }
1435 aRet = xScript->invoke( aParams, aOutParamIndex, aOutParam );
1436 }
1437 catch ( const uno::Exception& )
1438 {
1439 aException = ::cppu::getCaughtException();
1440 bCaughtException = true;
1442 }
1443
1444 if ( bCaughtException && bRaiseError )
1445 {
1447 pFact->ShowAsyncScriptErrorDialog( nullptr, aException );
1448 }
1449
1450 SAL_INFO("sfx", "leaving CallXScript" );
1451 return nErr;
1452}
1453
1454// perhaps rename to CallScript once we get rid of the existing CallScript
1455// and Call, CallBasic, CallStarBasic methods
1456ErrCode SfxObjectShell::CallXScript( const OUString& rScriptURL,
1457 const css::uno::Sequence< css::uno::Any >& aParams,
1458 css::uno::Any& aRet,
1459 css::uno::Sequence< sal_Int16 >& aOutParamIndex,
1460 css::uno::Sequence< css::uno::Any >& aOutParam,
1461 bool bRaiseError,
1462 const css::uno::Any* pCaller )
1463{
1464 return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError, pCaller );
1465}
1466
1467void SfxHeaderAttributes_Impl::SetAttributes()
1468{
1469 bAlert = true;
1470 SvKeyValue aPair;
1471 for( bool bCont = xIter->GetFirst( aPair ); bCont;
1472 bCont = xIter->GetNext( aPair ) )
1473 SetAttribute( aPair );
1474}
1475
1476void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV )
1477{
1478 const OUString& aValue = rKV.GetValue();
1479 if( rKV.GetKey().equalsIgnoreAsciiCase("refresh") && !rKV.GetValue().isEmpty() )
1480 {
1481 sal_Int32 nIdx{ 0 };
1482 const sal_Int32 nTime{ o3tl::toInt32(o3tl::getToken(aValue, 0, ';', nIdx )) };
1483 const OUString aURL{ comphelper::string::strip(o3tl::getToken(aValue, 0, ';', nIdx ), ' ') };
1484 uno::Reference<document::XDocumentProperties> xDocProps(
1485 pDoc->getDocProperties());
1486 if( aURL.startsWithIgnoreAsciiCase( "url=" ) )
1487 {
1488 try {
1489 xDocProps->setAutoloadURL(
1490 rtl::Uri::convertRelToAbs(pDoc->GetMedium()->GetName(), aURL.copy( 4 )) );
1491 } catch (rtl::MalformedUriException &) {
1492 TOOLS_WARN_EXCEPTION("sfx", "");
1493 }
1494 }
1495 try
1496 {
1497 xDocProps->setAutoloadSecs( nTime );
1498 }
1499 catch (lang::IllegalArgumentException &)
1500 {
1501 // ignore
1502 }
1503 }
1504 else if( rKV.GetKey().equalsIgnoreAsciiCase( "expires" ) )
1505 {
1506 DateTime aDateTime( DateTime::EMPTY );
1507 if( INetMIMEMessage::ParseDateField( rKV.GetValue(), aDateTime ) )
1508 {
1509 aDateTime.ConvertToLocalTime();
1510 pDoc->GetMedium()->SetExpired_Impl( aDateTime );
1511 }
1512 else
1513 {
1514 pDoc->GetMedium()->SetExpired_Impl( Date( 1, 1, 1970 ) );
1515 }
1516 }
1517}
1518
1519void SfxHeaderAttributes_Impl::Append( const SvKeyValue& rKV )
1520{
1521 xIter->Append( rKV );
1522 if( bAlert ) SetAttribute( rKV );
1523}
1524
1526{
1527 if( !pImpl->xHeaderAttributes.is() )
1528 {
1529 DBG_ASSERT( pMedium, "No Medium" );
1530 pImpl->xHeaderAttributes = new SfxHeaderAttributes_Impl( this );
1531 }
1532 return static_cast<SvKeyValueIterator*>( pImpl->xHeaderAttributes.get() );
1533}
1534
1536{
1537 static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())
1538 ->ClearForSourceView();
1539}
1540
1541
1543{
1544 static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())
1545 ->SetAttributes();
1546}
1547
1549{
1550 if ( !pMedium )
1551 return false;
1552
1553 bool bPreview = false;
1554 const SfxStringItem* pFlags = SfxItemSet::GetItem<SfxStringItem>(pMedium->GetItemSet(), SID_OPTIONS, false);
1555 if ( pFlags )
1556 {
1557 // Distributed values among individual items
1558 const OUString aFileFlags = pFlags->GetValue().toAsciiUpperCase();
1559 if ( -1 != aFileFlags.indexOf( 'B' ) )
1560 bPreview = true;
1561 }
1562
1563 if ( !bPreview )
1564 {
1565 const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(pMedium->GetItemSet(), SID_PREVIEW, false);
1566 if ( pItem )
1567 bPreview = pItem->GetValue();
1568 }
1569
1570 return bPreview;
1571}
1572
1573void SfxObjectShell::SetWaitCursor( bool bSet ) const
1574{
1575 for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
1576 {
1577 if ( bSet )
1578 pFrame->GetFrame().GetWindow().EnterWait();
1579 else
1580 pFrame->GetFrame().GetWindow().LeaveWait();
1581 }
1582}
1583
1585{
1587 OUString aName( aURL.GetBase() );
1588 if( aName.isEmpty() )
1589 aName = aURL.GetURLNoPass();
1590 if ( aName.isEmpty() )
1592 return aName;
1593}
1594
1595void SfxObjectShell::Invalidate( sal_uInt16 nId )
1596{
1597 for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
1598 Invalidate_Impl( pFrame->GetBindings(), nId );
1599}
1600
1602{
1603 uno::Reference< task::XInteractionHandler > xInteraction;
1604 if ( pMedium )
1605 xInteraction = pMedium->GetInteractionHandler();
1606
1608
1609 CheckEncryption_Impl( xInteraction );
1610
1611 return pImpl->aMacroMode.adjustMacroMode( xInteraction );
1612}
1613
1614css::uno::Reference<css::awt::XWindow> SfxObjectShell::GetDialogParent( SfxMedium const * pLoadingMedium )
1615{
1616 css::uno::Reference<css::awt::XWindow> xWindow;
1617 SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet();
1618 const SfxUnoFrameItem* pUnoItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pSet, SID_FILLFRAME, false);
1619 if ( pUnoItem )
1620 {
1621 const uno::Reference < frame::XFrame >& xFrame( pUnoItem->GetFrame() );
1622 xWindow = xFrame->getContainerWindow();
1623 }
1624
1625 if (!xWindow)
1626 {
1627 SfxFrame* pFrame = nullptr;
1628 const SfxFrameItem* pFrameItem = SfxItemSet::GetItem<SfxFrameItem>(pSet, SID_DOCFRAME, false);
1629 if( pFrameItem && pFrameItem->GetFrame() )
1630 // get target frame from ItemSet
1631 pFrame = pFrameItem->GetFrame();
1632 else
1633 {
1634 // try the current frame
1636 if ( !pView || pView->GetObjectShell() != this )
1637 // get any visible frame
1638 pView = SfxViewFrame::GetFirst(this);
1639 if ( pView )
1640 pFrame = &pView->GetFrame();
1641 }
1642
1643 if ( pFrame )
1644 {
1645 // get topmost window
1646 xWindow = pFrame->GetFrameInterface()->getContainerWindow();
1647 }
1648 }
1649
1650 if (xWindow)
1651 {
1652 // this frame may be invisible, show it if it is allowed
1653 const SfxBoolItem* pHiddenItem = SfxItemSet::GetItem<SfxBoolItem>(pSet, SID_HIDDEN, false);
1654 if ( !pHiddenItem || !pHiddenItem->GetValue() )
1655 {
1656 xWindow->setVisible(true);
1657 css::uno::Reference<css::awt::XTopWindow> xTopWindow(xWindow, uno::UNO_QUERY);
1658 SAL_WARN_IF(!xTopWindow, "sfx.appl", "XTopWindow not available from XWindow");
1659 if (xTopWindow)
1660 xTopWindow->toFront();
1661 }
1662 }
1663
1664 return xWindow;
1665}
1666
1668{
1669 eCreateMode = nMode;
1670}
1671
1673{
1675 return false;
1676
1677 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
1678 return pFrame && pFrame->GetFrame().IsInPlace();
1679}
1680
1682{
1684 return false;
1685
1686 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
1687 return pFrame && pFrame->GetFrame().IsInPlace() && pFrame->GetFrame().GetWorkWindow_Impl()->IsVisible_Impl();
1688}
1689
1691 const uno::Reference< task::XInteractionHandler >& xHandler,
1692 ErrCode nError )
1693{
1694 bool bResult = false;
1695
1696 if ( xHandler.is() )
1697 {
1698 try
1699 {
1700 uno::Any aInteraction;
1701 rtl::Reference<::comphelper::OInteractionAbort> pAbort = new ::comphelper::OInteractionAbort();
1702 rtl::Reference<::comphelper::OInteractionApprove> pApprove = new ::comphelper::OInteractionApprove();
1703 uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations{
1704 pAbort, pApprove
1705 };
1706
1707 task::ErrorCodeRequest aErrorCode;
1708 aErrorCode.ErrCode = sal_uInt32(nError);
1709 aInteraction <<= aErrorCode;
1710 xHandler->handle(::framework::InteractionRequest::CreateRequest (aInteraction,lContinuations));
1711 bResult = pAbort->wasSelected();
1712 }
1713 catch( uno::Exception& )
1714 {}
1715 }
1716
1717 return bResult;
1718}
1719
1721{
1722 sal_Int16 nImposedExecMode( MacroExecMode::NEVER_EXECUTE );
1723
1724 const SfxMedium* pMedium( rDocShell.GetMedium() );
1725 OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
1726 if ( pMedium )
1727 {
1728 const SfxUInt16Item* pMacroModeItem = SfxItemSet::GetItem<SfxUInt16Item>(pMedium->GetItemSet(), SID_MACROEXECMODE, false);
1729 if ( pMacroModeItem )
1730 nImposedExecMode = pMacroModeItem->GetValue();
1731 }
1732 return nImposedExecMode;
1733}
1734
1736{
1737 const SfxMedium* pMedium( rDocShell.GetMedium() );
1738 OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
1739 if ( pMedium )
1740 {
1741 pMedium->GetItemSet()->Put( SfxUInt16Item( SID_MACROEXECMODE, nMacroMode ) );
1742 }
1743}
1744
1746{
1747 OUString sLocation;
1748
1749 const SfxMedium* pMedium( rDocShell.GetMedium() );
1750 OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getDocumentLocation: no medium!" );
1751 if ( pMedium )
1752 {
1753 sLocation = pMedium->GetName();
1754 if ( sLocation.isEmpty() )
1755 {
1756 // for documents made from a template: get the name of the template
1757 sLocation = rDocShell.getDocProperties()->getTemplateURL();
1758 }
1759
1760 // tdf#128006 take document base url as location
1761 if (sLocation.isEmpty())
1762 sLocation = rDocShell.getDocumentBaseURL();
1763 }
1764
1765 return sLocation;
1766}
1767
1769{
1770 return ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocStorage );
1771}
1772
1774{
1776}
1777
1778Reference< XEmbeddedScripts > SfxObjectShell_Impl::getEmbeddedDocumentScripts() const
1779{
1780 return Reference< XEmbeddedScripts >( rDocShell.GetModel(), UNO_QUERY );
1781}
1782
1784{
1786
1787 if ( nSignatureState != SignatureState::NOSIGNATURES && m_bMacroSignBroken )
1788 {
1789 // if there is a macro signature it must be handled as broken
1790 nSignatureState = SignatureState::BROKEN;
1791 }
1792
1793 return nSignatureState;
1794}
1795
1797{
1798 bool bResult = false;
1799
1800 try
1801 {
1802 OUString aVersion;
1803 try
1804 {
1805 uno::Reference < beans::XPropertySet > xPropSet( rDocShell.GetStorage(), uno::UNO_QUERY_THROW );
1806 xPropSet->getPropertyValue("Version") >>= aVersion;
1807 }
1808 catch( uno::Exception& )
1809 {
1810 }
1811
1812 uno::Reference< security::XDocumentDigitalSignatures > xSigner( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) );
1813
1817 {
1818 const uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.GetDocumentSignatureInformation( true, xSigner );
1819
1820 if ( aInfo.hasElements() )
1821 {
1824
1827 {
1828 bResult = std::any_of(aInfo.begin(), aInfo.end(),
1829 [&xSigner](const security::DocumentSignatureInformation& rInfo) {
1830 return xSigner->isAuthorTrusted( rInfo.Signer ); });
1831
1832 if ( !bResult && bAllowUIToAddAuthor )
1833 {
1834 uno::Reference< task::XInteractionHandler > xInteraction;
1835 if ( rDocShell.GetMedium() )
1836 xInteraction = rDocShell.GetMedium()->GetInteractionHandler();
1837
1838 if ( xInteraction.is() )
1839 {
1840 task::DocumentMacroConfirmationRequest aRequest;
1841 aRequest.DocumentURL = getDocumentLocation();
1842 aRequest.DocumentStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl();
1843 aRequest.DocumentSignatureInformation = aInfo;
1844 aRequest.DocumentVersion = aVersion;
1845 aRequest.Classification = task::InteractionClassification_QUERY;
1846 bResult = SfxMedium::CallApproveHandler( xInteraction, uno::Any( aRequest ), true );
1847 }
1848 }
1849 }
1850 }
1851 }
1852 }
1853 catch( uno::Exception& )
1854 {}
1855
1856 return bResult;
1857}
1858
1859bool SfxObjectShell::IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage)
1860{
1862 {
1863 if (Application::GetDialogCancelMode() == DialogCancelMode::Off)
1864 {
1865 // Ask the user to try to continue or abort loading
1866 OUString aMessage = SfxResId(STR_QMSG_ERROR_OPENING_FILE);
1867 if (!aErrMessage.empty())
1868 aMessage += SfxResId(STR_QMSG_ERROR_OPENING_FILE_DETAILS) + aErrMessage;
1869 aMessage += SfxResId(STR_QMSG_ERROR_OPENING_FILE_CONTINUE);
1870 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(nullptr,
1871 VclMessageType::Question, VclButtonsType::YesNo, aMessage));
1872 mbContinueImportOnFilterExceptions = (xBox->run() == RET_YES) ? yes : no;
1873 }
1874 else
1876 }
1878}
1879
1881{
1882 Reference<XModel3> xModel = GetModel();
1883 if (!xModel.is())
1884 return false;
1885 if (!officecfg::Office::Common::Misc::AllowEditReadonlyDocs::get())
1886 return true;
1887 return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { "LockEditDoc" } ), u"LockEditDoc", false);
1888}
1889
1891{
1892 Reference<XModel3> xModel = GetModel();
1893 if (!xModel.is())
1894 return false;
1895 return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { "LockContentExtraction" } ), u"LockContentExtraction", false);
1896}
1897
1899{
1900 Reference<XModel3> xModel = GetModel();
1901 if (!xModel.is())
1902 return false;
1903 return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { "LockExport" } ), u"LockExport", false);
1904}
1905
1907{
1908 Reference<XModel3> xModel = GetModel();
1909 if (!xModel.is())
1910 return false;
1911 return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { "LockPrint" } ), u"LockPrint", false);
1912}
1913
1915{
1916 Reference<XModel3> xModel = GetModel();
1917 if (!xModel.is())
1918 return false;
1919 return comphelper::NamedValueCollection::getOrDefault(xModel->getArgs2( { "LockSave" } ), u"LockSave", false);
1920}
1921
1922/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxApplication * SfxGetpApp()
Definition: app.hxx:232
void SetTemplate_Impl(std::u16string_view rFileName, const OUString &rLongName, SfxObjectShell *pDoc)
Definition: appopen.cxx:104
void TransformItems(sal_uInt16 nSlotId, const SfxItemSet &rSet, uno::Sequence< beans::PropertyValue > &rArgs, const SfxSlot *pSlot)
Definition: appuno.cxx:908
static DialogCancelMode GetDialogCancelMode()
static bool IsUICaptured()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
AutoReloadTimer_Impl(OUString aURL, sal_uInt32 nTime, SfxObjectShell *pSh)
Definition: objmisc.cxx:1276
SfxObjectShell * pObjSh
Definition: objshimp.hxx:43
virtual void Invoke() override
Definition: objmisc.cxx:1284
sal_uInt16 GetValue() const
const OUString & GetValue() const
ErrCode IgnoreWarning() const
static OUString GetEventName(GlobalEventId nID)
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString PathToFileName() const
OUString msId
Definition: infobar.hxx:32
OUString msPrimaryMessage
Definition: infobar.hxx:33
bool mbShowCloseButton
Definition: infobar.hxx:36
InfobarType maInfobarType
Definition: infobar.hxx:35
OUString msSecondaryMessage
Definition: infobar.hxx:34
virtual void ShowAsyncScriptErrorDialog(weld::Window *pParent, const css::uno::Any &rException)=0
static SfxAbstractDialogFactory * Create()
Definition: sfxdlg.cxx:22
sal_uInt16 nDocModalMode
Definition: appdata.hxx:93
bool IsDowning() const
Definition: appmisc.cxx:102
SAL_DLLPRIVATE SfxAppData_Impl * Get_Impl() const
Definition: app.hxx:170
void ReleaseIndex(sal_uInt16 i)
Definition: app.cxx:318
static BasicManager * GetBasicManager()
Definition: appbas.cxx:62
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
Definition: appcfg.cxx:722
static ErrCode CallBasic(const OUString &, BasicManager *, SbxArray *pArgs, SbxValue *pRet)
Definition: app.cxx:530
sal_uInt16 GetFreeIndex()
Definition: app.cxx:312
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
Definition: bindings.cxx:858
void Invalidate(sal_uInt16 nId)
Definition: bindings.cxx:639
bool GetValue() const
void Broadcast(const SfxHint &rHint)
SfxFrame * GetFrame() const
Definition: frame.hxx:166
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
Definition: frame.cxx:515
bool IsClosing_Impl() const
Definition: frame.cxx:197
SAL_DLLPRIVATE SfxWorkWindow * GetWorkWindow_Impl() const
Definition: frame.cxx:588
bool IsInPlace() const
Definition: frame.cxx:657
css::uno::Reference< css::frame::XController > GetController() const
Definition: frame.cxx:507
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsOpen() const
Definition: docfile.cxx:4311
void SetOpenMode(StreamMode nStorOpen, bool bDontClose=false)
Definition: docfile.cxx:1962
void Close(bool bInDestruction=false)
Definition: docfile.cxx:3115
void CloseInStream()
Definition: docfile.cxx:701
void ResetError()
Definition: docfile.cxx:483
bool IsOriginallyLoadedReadOnly() const
Definition: docfile.cxx:3808
const INetURLObject & GetURLObject() const
Definition: docfile.cxx:3575
SAL_DLLPRIVATE void SetStorage_Impl(const css::uno::Reference< css::embed::XStorage > &xNewStorage)
Definition: docfile.cxx:3619
ErrCode GetErrorCode() const
Definition: docfile.cxx:512
SAL_DLLPRIVATE void CanDisposeStorage_Impl(bool bDisposeStorage)
Definition: docfile.cxx:1947
SfxItemSet * GetItemSet() const
Definition: docfile.cxx:3625
bool IsOriginallyReadOnly() const
Definition: docfile.cxx:3798
StreamMode GetOpenMode() const
Definition: docfile.cxx:1957
const OUString & GetOrigURL() const
Definition: docfile.cxx:3342
void SetName(const OUString &rName, bool bSetOrigURL=false)
Definition: docfile.cxx:3324
const OUString & GetName() const
Definition: docfile.cxx:3570
bool SwitchDocumentToFile(const OUString &aURL)
Definition: docfile.cxx:4462
SAL_DLLPRIVATE bool HasStorage_Impl() const
Definition: docfile.cxx:4306
void UnlockFile(bool bReleaseLockStream)
Definition: docfile.cxx:3149
void CreateTempFile(bool bReplace=true)
Definition: docfile.cxx:3872
static bool CallApproveHandler(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, const css::uno::Any &rRequest, bool bAllowAbort)
Definition: docfile.cxx:4355
bool IsReadOnly() const
Definition: docfile.cxx:3778
SAL_DLLPRIVATE void SetExpired_Impl(const DateTime &rDateTime)
Definition: docfile.cxx:3590
OUString SwitchDocumentToTempFile()
Definition: docfile.cxx:4386
SAL_DLLPRIVATE css::uno::Reference< css::embed::XStorage > const & GetZipStorageToSign_Impl(bool bReadOnly=true)
Definition: docfile.cxx:1878
SAL_DLLPRIVATE void Init_Impl()
Definition: docfile.cxx:2934
const OUString & GetPhysicalName() const
Definition: docfile.cxx:809
css::uno::Reference< css::task::XInteractionHandler > GetInteractionHandler(bool bGetAlways=false)
Definition: docfile.cxx:3054
SfxModule * GetModule() const
Definition: docfac.cxx:123
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
Definition: objembed.cxx:204
bool IsOriginallyReadOnlyMedium() const
Definition: objmisc.cxx:358
bool isEditDocLocked() const
Definition: objmisc.cxx:1880
SAL_DLLPRIVATE void BreakMacroSign_Impl(bool bBreakMacroSing)
Definition: objmisc.cxx:934
void SetWaitCursor(bool bSet) const
Definition: objmisc.cxx:1573
void FlushDocInfo()
Definition: objmisc.cxx:180
void SetError(ErrCode rErr)
Definition: objmisc.cxx:212
virtual void CancelTransfers()
Definition: objmisc.cxx:1260
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
Definition: objmisc.cxx:161
SAL_DLLPRIVATE void SetNamedVisibility_Impl()
Definition: objmisc.cxx:851
void SetTitle(const OUString &rTitle)
Definition: objmisc.cxx:664
virtual bool DoSaveCompleted(SfxMedium *pNewStor=nullptr, bool bRegisterRecent=true)
Definition: objstor.cxx:1948
SAL_DLLPRIVATE bool CanReload_Impl()
Definition: objstor.cxx:3060
ErrCode GetErrorCode() const
Definition: objmisc.cxx:225
bool IsLoadReadonly() const
Definition: objcont.cxx:640
bool HasValidSignatures() const
Definition: objserv.cxx:2032
bool AcceptStateUpdate() const
Definition: objmisc.cxx:423
SAL_DLLPRIVATE void SetInitialized_Impl(const bool i_fromInitNew)
Definition: objxtor.cxx:1064
void SetAutoLoad(const INetURLObject &, sal_uInt32 nTime, bool bReload)
Definition: objmisc.cxx:1011
bool IsInModalMode() const
Definition: objmisc.cxx:418
bool IsLoadingFinished() const
Definition: objmisc.cxx:1029
bool isSaveLocked() const
Definition: objmisc.cxx:1914
bool IsReadOnlyMedium() const
Definition: objmisc.cxx:345
OUString GetSharedFileURL() const
Definition: objmisc.cxx:640
sal_uInt32 GetModifyPasswordHash() const
Definition: objcont.cxx:664
bool IsAutoLoadLocked() const
Definition: objmisc.cxx:923
void SetHeaderAttributesForSourceViewHack()
Definition: objmisc.cxx:1542
SfxProgress * GetProgress() const
Definition: objmisc.cxx:873
void ClearHeaderAttributesForSourceViewHack()
Definition: objmisc.cxx:1535
BasicManager * GetBasicManager() const
Definition: objxtor.cxx:636
bool HasName() const
Definition: objsh.hxx:261
bool IsContinueImportOnFilterExceptions(std::u16string_view aErrMessage)
On first error ask user if import should continue; return saved answer.
Definition: objmisc.cxx:1859
bool IsEnableSetModified() const
Definition: objmisc.cxx:248
SfxObjectCreateMode eCreateMode
Definition: objsh.hxx:187
bool isContentExtractionLocked() const
Definition: objmisc.cxx:1890
void SetSharedXMLFlag(bool bFlag) const
virtual SfxObjectFactory & GetFactory() const =0
bool isExportLocked() const
Definition: objmisc.cxx:1898
SAL_DLLPRIVATE void SetMacroMode_Impl(bool bModal=true)
Definition: objmisc.cxx:429
virtual void Invalidate(sal_uInt16 nId=0) override
With this method can the slots of the subclasses be invalidated through the slot Id or alternatively ...
Definition: objmisc.cxx:1595
css::uno::Reference< css::awt::XWindow > GetDialogParent(SfxMedium const *pMedium=nullptr)
Definition: objmisc.cxx:1614
bool SwitchToShared(bool bShared, bool bSave)
bool IsUIActive() const
Definition: objmisc.cxx:1681
bool IsReadOnly() const
Definition: objmisc.cxx:412
bool IsLoading() const
Definition: objmisc.cxx:1250
bool IsAbortingImport() const
Definition: objmisc.cxx:154
bool IsOriginallyLoadedReadOnlyMedium() const
Definition: objmisc.cxx:363
ErrCode CallXScript(const OUString &rScriptURL, const css::uno::Sequence< css::uno::Any > &aParams, css::uno::Any &aRet, css::uno::Sequence< sal_Int16 > &aOutParamIndex, css::uno::Sequence< css::uno::Any > &aOutParam, bool bRaiseError=true, const css::uno::Any *aCaller=nullptr)
Definition: objmisc.cxx:1456
bool IsReadOnlyUI() const
Definition: objmisc.cxx:332
SfxModule * GetModule() const
Definition: objmisc.cxx:1317
bool IsDocShared() const
Definition: objmisc.cxx:630
SAL_DLLPRIVATE void FreeSharedFile(const OUString &aTempFileURL)
static bool UnTrustedScript(const OUString &rScriptURL)
Definition: objmisc.cxx:1361
static bool isScriptAccessAllowed(const css::uno::Reference< css::uno::XInterface > &rScriptContext)
Definition: objmisc.cxx:1340
void FinishedLoading(SfxLoadedFlags nWhich=SfxLoadedFlags::ALL)
Definition: objmisc.cxx:1069
bool IsModified() const
Definition: objmisc.cxx:255
void ModifyChanged()
Definition: objmisc.cxx:313
SvKeyValueIterator * GetHeaderAttributes()
Definition: objmisc.cxx:1525
void SetNoName()
Definition: objmisc.cxx:866
SfxMedium * pMedium
Definition: objsh.hxx:185
TriState mbContinueImportOnFilterExceptions
Definition: objsh.hxx:194
ErrCode GetError() const
Definition: objmisc.cxx:220
SAL_DLLPRIVATE SfxObjectShell_Impl * Get_Impl()
Definition: objsh.hxx:707
SfxMedium * GetMedium() const
Definition: objsh.hxx:256
void SetReadOnlyUI(bool bReadOnly=true)
Definition: objmisc.cxx:369
bool HasSharedXMLFlagSet() const
SAL_DLLPRIVATE void CheckSecurityOnLoading_Impl()
Definition: objmisc.cxx:940
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: objxtor.cxx:830
bool AdjustMacroMode()
adjusts the internal macro mode, according to the current security settings
Definition: objmisc.cxx:1601
OUString GetTitle(sal_uInt16 nMaxLen=0) const
Definition: objmisc.cxx:706
bool isPrintLocked() const
Definition: objmisc.cxx:1906
void SetLoading(SfxLoadedFlags nFlags)
Definition: objmisc.cxx:1024
SAL_DLLPRIVATE void InitOwnModel_Impl()
Definition: objmisc.cxx:1034
virtual void DoFlushDocInfo()
template method, called by FlushDocInfo; this implementation is empty
Definition: objmisc.cxx:173
virtual OUString getDocumentBaseURL() const override
Definition: objstor.cxx:3855
SAL_DLLPRIVATE void SetProgress_Impl(SfxProgress *pProgress)
Definition: objmisc.cxx:880
SAL_DLLPRIVATE void PostActivateEvent_Impl(SfxViewFrame const *)
Definition: objmisc.cxx:899
std::unique_ptr< struct SfxObjectShell_Impl > pImpl
Definition: objsh.hxx:183
SAL_DLLPRIVATE void CheckForBrokenDocSignatures_Impl()
Definition: objmisc.cxx:999
bool GetMacroCallsSeenWhileLoading() const
Definition: objstor.cxx:3787
static SAL_DLLPRIVATE bool IsPackageStorageFormat_Impl(const SfxMedium &)
Definition: objstor.cxx:962
css::uno::Reference< css::embed::XStorage > const & GetStorage()
Definition: objstor.cxx:3261
SAL_DLLPRIVATE void SetCreateMode_Impl(SfxObjectCreateMode nMode)
Definition: objmisc.cxx:1667
const tools::Rectangle & GetVisArea() const
Definition: objembed.cxx:73
void EnableSetModified(bool bEnable=true)
Definition: objmisc.cxx:241
Size GetFirstPageSize() const
Definition: objmisc.cxx:649
static SAL_DLLPRIVATE bool UseInteractionToHandleError(const css::uno::Reference< css::task::XInteractionHandler > &xHandler, ErrCode nError)
Definition: objmisc.cxx:1690
SAL_DLLPRIVATE IndexBitSet & GetNoSet_Impl()
Definition: objmisc.cxx:655
std::vector< InfobarData > & getPendingInfobars()
Definition: objmisc.cxx:207
void TemplateDisconnectionAfterLoad()
Definition: objmisc.cxx:1158
OUString GetAPIName() const
Definition: objmisc.cxx:1584
css::uno::Sequence< css::security::DocumentSignatureInformation > GetDocumentSignatureInformation(bool bScriptingContent, const css::uno::Reference< css::security::XDocumentDigitalSignatures > &xSigner=css::uno::Reference< css::security::XDocumentDigitalSignatures >())
Definition: objserv.cxx:1776
void InvalidateName()
Definition: objmisc.cxx:835
SignatureState GetScriptingSignatureState()
Definition: objserv.cxx:2160
bool IsInPlaceActive() const
Definition: objmisc.cxx:1672
bool IsPreview() const
Definition: objmisc.cxx:1548
SAL_DLLPRIVATE bool IsModifyPasswordEntered() const
Definition: objcont.cxx:707
const css::uno::Sequence< css::beans::PropertyValue > & GetModifyPasswordInfo() const
Definition: objcont.cxx:683
SignatureState GetDocumentSignatureState()
Definition: objserv.cxx:2039
SAL_DLLPRIVATE void CheckEncryption_Impl(const css::uno::Reference< css::task::XInteractionHandler > &xHandler)
Definition: objmisc.cxx:960
SAL_DLLPRIVATE void SetActivateEvent_Impl(SfxEventHintId)
Definition: objmisc.cxx:918
SAL_DLLPRIVATE void DoNotCleanShareControlFile()
SAL_DLLPRIVATE void SetModalMode_Impl(bool bModal)
Definition: objmisc.cxx:439
void ResetError()
Definition: objmisc.cxx:233
void SetReadOnly()
Definition: objmisc.cxx:386
void AppendInfoBarWhenReady(const OUString &sId, const OUString &sPrimaryMessage, const OUString &sSecondaryMessage, InfobarType aInfobarType, bool bShowCloseButton=true)
Append Infobar once the frame is ready.
Definition: objmisc.cxx:194
virtual void SetModified(bool bModified=true)
Definition: objmisc.cxx:297
ErrCode CallBasic(std::u16string_view rMacro, std::u16string_view rBasicName, SbxArray *pArgs, SbxValue *pRet=nullptr)
Definition: objmisc.cxx:1322
bool bHasName
Definition: objsh.hxx:188
const OUString & GetName() const
Returns the name of the Shell object.
Definition: shell.cxx:119
SAL_DLLPRIVATE void Invalidate_Impl(SfxBindings &rBindings, sal_uInt16 nId)
Definition: shell.cxx:251
void SetName(const OUString &rName)
Sets the name of the Shell object.
Definition: shell.cxx:114
const css::uno::Reference< css::frame::XFrame > & GetFrame() const
Definition: frame.hxx:193
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
Definition: viewfrm.cxx:1958
void ExecReload_Impl(SfxRequest &rReq)
Definition: viewfrm.cxx:275
SfxBindings & GetBindings()
Definition: viewfrm.hxx:110
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
Definition: viewfrm.cxx:1989
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
Definition: viewfrm.cxx:1966
SfxFrame & GetFrame() const
Definition: viewfrm.cxx:2765
virtual SfxObjectShell * GetObjectShell() override
Definition: viewfrm.cxx:2201
bool IsVisible_Impl() const
Definition: workwin.cxx:1493
virtual void Append(const SvKeyValue &rKeyVal)
virtual bool GetFirst(SvKeyValue &rKeyVal)
virtual bool GetNext(SvKeyValue &rKeyVal)
const OUString & GetKey() const
const OUString & GetValue() const
void SetTimeout(sal_uInt64 nTimeoutMs)
virtual void Start(bool bStartTimer=true) override
css::uno::Sequence< OUString > GetObjectNames() const
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
VALUE_TYPE getOrDefault(const OUString &_rValueName, const VALUE_TYPE &_rDefault) const
static css::uno::Reference< css::embed::XStorage > GetTemporaryStorage(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
static css::uno::Reference< css::task::XInteractionRequest > CreateRequest(const css::uno::Any &aRequest, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &lContinuations)
constexpr Size GetSize() const
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
URL aURL
virtual OUString GetName() const override
constexpr OUStringLiteral ODFVER_012_TEXT
float u
sal_Int32 nState
#define ERRCODE_IO_ACCESSDENIED
#define ERRCODE_IO_GENERAL
#define ERRCODE_NONE
SfxEventHintId
Definition: event.hxx:116
bool bReadOnly
InfobarType
Definition: infobar.hxx:22
sal_Int32 nIndex
OUString aName
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
SignatureState getSignatureState(const uno::Sequence< security::DocumentSignatureInformation > &aSigInfo)
@ Exception
OString strip(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
bool parse(OUString const &uri, SourceProviderScannerData *data)
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
sal_uInt16 const aTitleMap_Impl[3][2]
Definition: objmisc.cxx:145
#define SFX_TITLE_FILENAME
Definition: objsh.hxx:111
#define SFX_TITLE_PICKLIST
Definition: objsh.hxx:116
#define SFX_TITLE_FULLNAME
Definition: objsh.hxx:112
SfxObjectCreateMode
Definition: objsh.hxx:155
#define SFX_TITLE_CAPTION
Definition: objsh.hxx:115
#define SFX_TITLE_DETECT
Definition: objsh.hxx:114
#define SFX_TITLE_APINAME
Definition: objsh.hxx:113
#define SFX_TITLE_MAXLEN
Definition: objsh.hxx:118
#define SFX_TITLE_HISTORY
Definition: objsh.hxx:117
#define ASPECT_THUMBNAIL
Definition: objsh.hxx:82
SfxLoadedFlags
Definition: objsh.hxx:121
#define SFX_TITLE_TITLE
Definition: objsh.hxx:110
void impl_addToModelCollection(const css::uno::Reference< css::frame::XModel > &xModel)
Definition: objstor.cxx:132
sal_Int16 nId
#define SFX_STREAM_READONLY
Definition: openflag.hxx:26
#define SFX_STREAM_READWRITE
Definition: openflag.hxx:23
#define ERRCODE_BASIC_INTERNAL_ERROR
#define ERRCODE_SFX_INCOMPLETE_ENCRYPTION
OUString SfxResId(TranslateId aId)
Definition: sfxresid.cxx:22
SignatureState
virtual sal_Int16 getCurrentMacroExecMode() const override
retrieves the current MacroExecutionMode.
Definition: objmisc.cxx:1720
virtual OUString getDocumentLocation() const override
returns the origin of the document
Definition: objmisc.cxx:1745
virtual bool macroCallsSeenWhileLoading() const override
checks whether the document's contained calls to macros or scripts after loading
Definition: objmisc.cxx:1773
SignatureState nScriptingSignatureState
Definition: objshimp.hxx:68
std::unique_ptr< AutoReloadTimer_Impl > pReloadTimer
Definition: objshimp.hxx:99
virtual css::uno::Reference< css::document::XEmbeddedScripts > getEmbeddedDocumentScripts() const override
provides access to the XEmbeddedScripts interface of the document
Definition: objmisc.cxx:1778
SfxObjectShell & rDocShell
Definition: objshimp.hxx:55
virtual void setCurrentMacroExecMode(sal_uInt16 nMacroMode) override
sets the MacroExecutionMode of the document, as calculated by the DocumentMacroMode class.
Definition: objmisc.cxx:1735
css::uno::Reference< css::embed::XStorage > m_xDocStorage
Definition: objshimp.hxx:117
virtual bool documentStorageHasMacros() const override
checks whether the document's storage contains sub storages with macros or scripts
Definition: objmisc.cxx:1768
virtual bool hasTrustedScriptingSignature(bool bAllowUIToAddAuthor) override
allows to detect whether there is a trusted scripting signature
Definition: objmisc.cxx:1796
virtual SignatureState getScriptingSignatureState() override
returns the state of the signatures for the scripts embedded in the document
Definition: objmisc.cxx:1783
std::vector< InfobarData > m_aPendingInfobars
Holds Infobars until View is fully loaded.
Definition: objshimp.hxx:134
Reference< XFrame > xFrame
Reference< XModel > xModel
OUString sId
constexpr OUStringLiteral sScript
RET_YES