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