1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <tools/inetmsg.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <svl/eitem.hxx>
25 #include <svl/stritem.hxx>
26 #include <svl/intitem.hxx>
27 #include <svtools/svparser.hxx> // SvKeyValue
28 #include <osl/mutex.hxx>
29 #include <cppuhelper/exc_hlp.hxx>
31 #include <com/sun/star/container/XChild.hpp>
32 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
33 #include <com/sun/star/document/XDocumentProperties.hpp>
34 #include <com/sun/star/document/UpdateDocMode.hpp>
35 #include <com/sun/star/document/MacroExecMode.hpp>
36 #include <com/sun/star/document/XScriptInvocationContext.hpp>
37 #include <com/sun/star/embed/EmbedStates.hpp>
38 #include <com/sun/star/embed/XEmbedPersist.hpp>
39 #include <com/sun/star/logging/DocumentIOLogRing.hpp>
40 #include <com/sun/star/script/XTypeConverter.hpp>
41 #include <com/sun/star/script/FinishEngineEvent.hpp>
42 #include <com/sun/star/script/InterruptReason.hpp>
43 #include <com/sun/star/script/XEngineListener.hpp>
44 #include <com/sun/star/script/XDebugging.hpp>
45 #include <com/sun/star/script/XInvocation.hpp>
46 #include <com/sun/star/script/ContextInformation.hpp>
47 #include <com/sun/star/script/FinishReason.hpp>
48 #include <com/sun/star/script/XEngine.hpp>
49 #include <com/sun/star/script/InterruptEngineEvent.hpp>
50 #include <com/sun/star/script/XLibraryAccess.hpp>
51 #include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
52 #include <com/sun/star/script/provider/XScript.hpp>
53 #include <com/sun/star/script/provider/XScriptProvider.hpp>
54 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
55 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
56 #include <com/sun/star/util/XModifiable.hpp>
58 #include <toolkit/unohlp.hxx>
60 #include <com/sun/star/uno/Reference.h>
61 #include <com/sun/star/uno/Any.h>
62 #include <com/sun/star/ucb/XContent.hpp>
63 #include <com/sun/star/task/ErrorCodeRequest.hpp>
64 #include <unotools/securityoptions.hxx>
66 #include <comphelper/componentcontext.hxx>
67 #include <comphelper/configurationhelper.hxx>
68 #include <comphelper/processfactory.hxx>
69 #include <comphelper/string.hxx>
71 #include <com/sun/star/security/DocumentDigitalSignatures.hpp>
72 #include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
73 #include <com/sun/star/task/InteractionClassification.hpp>
74 #include <com/sun/star/frame/XModel.hpp>
76 using namespace ::com::sun::star
;
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::ucb
;
79 using namespace ::com::sun::star::document
;
80 using namespace ::com::sun::star::frame
;
81 using namespace ::com::sun::star::script
;
82 using namespace ::com::sun::star::script::provider
;
83 using namespace ::com::sun::star::container
;
84 #include <basic/sbuno.hxx>
85 #include <basic/sbstar.hxx>
86 #include <basic/basmgr.hxx>
87 #include <vcl/msgbox.hxx>
88 #include <basic/sbx.hxx>
89 #include <svtools/sfxecode.hxx>
90 #include <svtools/ehdl.hxx>
92 #include <unotools/pathoptions.hxx>
93 #include <unotools/ucbhelper.hxx>
94 #include <tools/inetmime.hxx>
95 #include <tools/urlobj.hxx>
96 #include <svl/inettype.hxx>
97 #include <svl/sharecontrolfile.hxx>
98 #include <osl/file.hxx>
99 #include <rtl/bootstrap.hxx>
100 #include <vcl/svapp.hxx>
101 #include <framework/interaction.hxx>
102 #include <framework/documentundoguard.hxx>
103 #include <comphelper/interaction.hxx>
104 #include <comphelper/storagehelper.hxx>
105 #include <comphelper/documentconstants.hxx>
107 #include <sfx2/signaturestate.hxx>
108 #include <sfx2/app.hxx>
109 #include "appdata.hxx"
110 #include <sfx2/request.hxx>
111 #include <sfx2/bindings.hxx>
112 #include "sfx2/sfxresid.hxx"
113 #include <sfx2/docfile.hxx>
114 #include <sfx2/docfilt.hxx>
115 #include <sfx2/objsh.hxx>
116 #include "objshimp.hxx"
117 #include <sfx2/event.hxx>
118 #include "fltfnc.hxx"
119 #include <sfx2/sfx.hrc>
120 #include <sfx2/dispatch.hxx>
121 #include <sfx2/viewfrm.hxx>
122 #include <sfx2/viewsh.hxx>
123 #include <sfx2/ctrlitem.hxx>
124 #include "arrdecl.hxx"
125 #include <sfx2/module.hxx>
126 #include <sfx2/docfac.hxx>
127 #include "helper.hxx"
129 #include "workwin.hxx"
130 #include "helpid.hrc"
131 #include "../appl/app.hrc"
132 #include <sfx2/sfxdlg.hxx>
133 #include "appbaslib.hxx"
134 #include <openflag.hxx> // SFX_STREAM_READWRITE
136 // class SfxHeaderAttributes_Impl ----------------------------------------
138 class SfxHeaderAttributes_Impl
: public SvKeyValueIterator
141 SfxObjectShell
* pDoc
;
142 SvKeyValueIteratorRef xIter
;
146 SfxHeaderAttributes_Impl( SfxObjectShell
* pSh
) :
147 SvKeyValueIterator(), pDoc( pSh
),
148 xIter( pSh
->GetMedium()->GetHeaderAttributes_Impl() ),
149 bAlert( sal_False
) {}
151 virtual sal_Bool
GetFirst( SvKeyValue
& rKV
) { return xIter
->GetFirst( rKV
); }
152 virtual sal_Bool
GetNext( SvKeyValue
& rKV
) { return xIter
->GetNext( rKV
); }
153 virtual void Append( const SvKeyValue
& rKV
);
155 void ClearForSourceView() { xIter
= new SvKeyValueIterator
; bAlert
= sal_False
; }
156 void SetAttributes();
157 void SetAttribute( const SvKeyValue
& rKV
);
160 //=========================================================================
162 sal_uInt16
const aTitleMap_Impl
[3][2] =
165 /* SFX_TITLE_CAPTION */ { SFX_TITLE_FILENAME
, SFX_TITLE_TITLE
},
166 /* SFX_TITLE_PICKLIST */ { 32, SFX_TITLE_FULLNAME
},
167 /* SFX_TITLE_HISTORY */ { 32, SFX_TITLE_FULLNAME
}
170 //=========================================================================
172 void SfxObjectShell::AbortImport()
174 pImp
->bIsAbortingImport
= sal_True
;
177 //-------------------------------------------------------------------------
179 sal_Bool
SfxObjectShell::IsAbortingImport() const
181 return pImp
->bIsAbortingImport
;
184 //-------------------------------------------------------------------------
186 uno::Reference
<document::XDocumentProperties
>
187 SfxObjectShell::getDocProperties()
189 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
190 GetModel(), uno::UNO_QUERY_THROW
);
191 uno::Reference
<document::XDocumentProperties
> xDocProps(
192 xDPS
->getDocumentProperties());
193 DBG_ASSERT(xDocProps
.is(),
194 "SfxObjectShell: model has no DocumentProperties");
198 //-------------------------------------------------------------------------
200 void SfxObjectShell::DoFlushDocInfo()
204 //-------------------------------------------------------------------------
206 // Note: the only thing that calls this is the modification event handler
207 // that is installed at the XDocumentProperties
208 void SfxObjectShell::FlushDocInfo()
213 SetModified(sal_True
);
214 uno::Reference
<document::XDocumentProperties
> xDocProps(getDocProperties());
215 DoFlushDocInfo(); // call template method
216 OUString
url(xDocProps
->getAutoloadURL());
217 sal_Int32
delay(xDocProps
->getAutoloadSecs());
218 SetAutoLoad( INetURLObject(url
), delay
* 1000,
219 (delay
> 0) || !url
.isEmpty() );
222 //-------------------------------------------------------------------------
224 void SfxObjectShell::SetError( sal_uInt32 lErr
, const OUString
& aLogMessage
)
226 if(pImp
->lErr
==ERRCODE_NONE
)
230 if( lErr
!= ERRCODE_NONE
&& !aLogMessage
.isEmpty() )
231 AddLog( aLogMessage
);
235 //-------------------------------------------------------------------------
237 sal_uInt32
SfxObjectShell::GetError() const
239 return ERRCODE_TOERROR(GetErrorCode());
242 //-------------------------------------------------------------------------
244 sal_uInt32
SfxObjectShell::GetErrorCode() const
246 sal_uInt32 lError
=pImp
->lErr
;
247 if(!lError
&& GetMedium())
248 lError
=GetMedium()->GetErrorCode();
252 //-------------------------------------------------------------------------
254 void SfxObjectShell::ResetError()
256 if( pImp
->lErr
!= ERRCODE_NONE
)
257 AddLog( OUString( OSL_LOG_PREFIX
"Resetting Error." ) );
260 SfxMedium
* pMed
= GetMedium();
265 //-------------------------------------------------------------------------
267 sal_Bool
SfxObjectShell::IsTemplate() const
269 return pImp
->bIsTemplate
;
272 //-------------------------------------------------------------------------
274 void SfxObjectShell::EnableSetModified( sal_Bool bEnable
)
277 if ( bEnable
== pImp
->m_bEnableSetModified
)
278 DBG_WARNING( "SFX_PERSIST: EnableSetModified 2x called with the same value" );
280 pImp
->m_bEnableSetModified
= bEnable
;
283 //-------------------------------------------------------------------------
285 sal_Bool
SfxObjectShell::IsEnableSetModified() const
287 return pImp
->m_bEnableSetModified
&& !IsReadOnly();
290 //-------------------------------------------------------------------------
292 sal_Bool
SfxObjectShell::IsModified()
294 if ( pImp
->m_bIsModified
)
297 if ( !pImp
->m_xDocStorage
.is() || IsReadOnly() )
299 // if the document still has no storage and is not set to be modified explicitly it is not modified
300 // a readonly document is also not modified
305 uno::Sequence
< OUString
> aNames
= GetEmbeddedObjectContainer().GetObjectNames();
306 for ( sal_Int32 n
=0; n
<aNames
.getLength(); n
++ )
308 uno::Reference
< embed::XEmbeddedObject
> xObj
= GetEmbeddedObjectContainer().GetEmbeddedObject( aNames
[n
] );
309 OSL_ENSURE( xObj
.is(), "An empty entry in the embedded objects list!\n" );
314 sal_Int32 nState
= xObj
->getCurrentState();
315 if ( nState
!= embed::EmbedStates::LOADED
)
317 uno::Reference
< util::XModifiable
> xModifiable( xObj
->getComponent(), uno::UNO_QUERY
);
318 if ( xModifiable
.is() && xModifiable
->isModified() )
322 catch( uno::Exception
& )
330 //-------------------------------------------------------------------------
332 void SfxObjectShell::SetModified( sal_Bool bModifiedP
)
335 if ( !bModifiedP
&& !IsEnableSetModified() )
336 DBG_WARNING( "SFX_PERSIST: SetModified( sal_False ), although IsEnableSetModified() == sal_False" );
339 if( !IsEnableSetModified() )
342 if( pImp
->m_bIsModified
!= bModifiedP
)
344 pImp
->m_bIsModified
= bModifiedP
;
349 //-------------------------------------------------------------------------
351 void SfxObjectShell::ModifyChanged()
353 if ( pImp
->bClosing
)
354 // SetModified dispose of the models!
357 {DBG_CHKTHIS(SfxObjectShell
, 0);}
359 SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
361 pViewFrame
->GetBindings().Invalidate( SID_SAVEDOCS
);
363 Invalidate( SID_SIGNATURE
);
364 Invalidate( SID_MACRO_SIGNATURE
);
365 Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED
) ); // xmlsec05, signed state might change in title...
367 SFX_APP()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED
, GlobalEventConfig::GetEventName(STR_EVENT_MODIFYCHANGED
), this ) );
370 //-------------------------------------------------------------------------
372 sal_Bool
SfxObjectShell::IsReadOnlyUI() const
376 Returns sal_True if the document for the UI is treated as r/o. This is
377 regardless of the actual r/o, which can be checked with <IsReadOnly()>.
381 return pImp
->bReadOnlyUI
;
384 //-------------------------------------------------------------------------
386 sal_Bool
SfxObjectShell::IsReadOnlyMedium() const
390 Returns sal_True when the medium is r/o, for instance when opened as r/o.
396 return pMedium
->IsReadOnly();
399 bool SfxObjectShell::IsOriginallyReadOnlyMedium() const
401 return pMedium
== 0 || pMedium
->IsOriginallyReadOnly();
404 //-------------------------------------------------------------------------
406 void SfxObjectShell::SetReadOnlyUI( sal_Bool bReadOnly
)
410 Turns the document in an r/o and r/w state respectively without reloading
411 it and without changing the open mode of the medium.
415 if ( bReadOnly
!= pImp
->bReadOnlyUI
)
417 pImp
->bReadOnlyUI
= bReadOnly
;
418 Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED
) );
422 //-------------------------------------------------------------------------
424 void SfxObjectShell::SetReadOnly()
426 // Let the document be completely readonly, means that the
427 // medium open mode is adjusted accordingly, and the write lock
428 // on the file is removed.
430 if ( pMedium
&& !IsReadOnlyMedium() )
432 sal_Bool bWasROUI
= IsReadOnly();
434 pMedium
->UnlockFile( sal_False
);
436 // the storage-based mediums are already based on the temporary file
437 // so UnlockFile has already closed the locking stream
438 if ( !pMedium
->HasStorage_Impl() && IsLoadingFinished() )
439 pMedium
->CloseInStream();
441 pMedium
->SetOpenMode( SFX_STREAM_READONLY
, sal_True
);
442 pMedium
->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY
, sal_True
) );
445 Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED
) );
448 //-------------------------------------------------------------------------
450 sal_Bool
SfxObjectShell::IsReadOnly() const
452 return pImp
->bReadOnlyUI
|| pMedium
== 0;
455 //-------------------------------------------------------------------------
457 sal_Bool
SfxObjectShell::IsInModalMode() const
459 return pImp
->bModalMode
|| pImp
->bRunningMacro
;
462 sal_Bool
SfxObjectShell::AcceptStateUpdate() const
464 return !IsInModalMode();
467 //-------------------------------------------------------------------------
469 void SfxObjectShell::SetMacroMode_Impl( sal_Bool bModal
)
471 if ( !pImp
->bRunningMacro
!= !bModal
)
473 pImp
->bRunningMacro
= bModal
;
474 Broadcast( SfxSimpleHint( SFX_HINT_MODECHANGED
) );
478 //-------------------------------------------------------------------------
480 void SfxObjectShell::SetModalMode_Impl( sal_Bool bModal
)
482 // Broadcast only if modified, or otherwise it will possibly go into
484 if ( !pImp
->bModalMode
!= !bModal
)
487 sal_uInt16
&rDocModalCount
= SFX_APP()->Get_Impl()->nDocModalMode
;
494 pImp
->bModalMode
= bModal
;
495 Broadcast( SfxSimpleHint( SFX_HINT_MODECHANGED
) );
499 #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
501 sal_Bool
SfxObjectShell::SwitchToShared( sal_Bool bShared
, sal_Bool bSave
)
503 sal_Bool bResult
= sal_True
;
505 if ( bShared
!= IsDocShared() )
507 OUString aOrigURL
= GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
);
509 if ( aOrigURL
.isEmpty() && bSave
)
511 // this is a new document, let it be stored before switching to the shared mode;
512 // the storing should be done without shared flag, since it is possible that the
513 // target location does not allow to create sharing control file;
514 // the shared flag will be set later after creation of sharing control file
515 SfxViewFrame
* pViewFrame
= SfxViewFrame::GetFirst( this );
519 // TODO/LATER: currently the application guards against the reentrance problem
520 const SfxPoolItem
* pItem
= pViewFrame
->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC
: SID_SAVEASDOC
);
521 SfxBoolItem
* pResult
= PTR_CAST( SfxBoolItem
, pItem
);
522 bResult
= ( pResult
&& pResult
->GetValue() );
524 aOrigURL
= GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
);
528 sal_Bool bOldValue
= HasSharedXMLFlagSet();
529 SetSharedXMLFlag( bShared
);
531 sal_Bool bRemoveEntryOnError
= sal_False
;
532 if ( bResult
&& bShared
)
536 ::svt::ShareControlFile
aControlFile( aOrigURL
);
537 aControlFile
.InsertOwnEntry();
538 bRemoveEntryOnError
= sal_True
;
540 catch( uno::Exception
& )
546 if ( bResult
&& bSave
)
548 SfxViewFrame
* pViewFrame
= SfxViewFrame::GetFirst( this );
552 // TODO/LATER: currently the application guards against the reentrance problem
553 SetModified( sal_True
); // the modified flag has to be set to let the document be stored with the shared flag
554 const SfxPoolItem
* pItem
= pViewFrame
->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC
: SID_SAVEASDOC
);
555 SfxBoolItem
* pResult
= PTR_CAST( SfxBoolItem
, pItem
);
556 bResult
= ( pResult
&& pResult
->GetValue() );
562 // TODO/LATER: Is it possible that the following calls fail?
565 pImp
->m_aSharedFileURL
= aOrigURL
;
566 GetMedium()->SwitchDocumentToTempFile();
570 OUString aTempFileURL
= pMedium
->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
);
571 GetMedium()->SwitchDocumentToFile( GetSharedFileURL() );
572 pImp
->m_aSharedFileURL
= OUString();
574 // now remove the temporary file the document was based on
575 ::utl::UCBContentHelper::Kill( aTempFileURL
);
579 // aOrigURL can not be used since it contains an old value
580 ::svt::ShareControlFile
aControlFile( GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
) );
581 aControlFile
.RemoveFile();
583 catch( uno::Exception
& )
590 // the saving has failed!
591 if ( bRemoveEntryOnError
)
595 ::svt::ShareControlFile
aControlFile( aOrigURL
);
596 aControlFile
.RemoveEntry();
598 catch( uno::Exception
& )
602 SetSharedXMLFlag( bOldValue
);
606 bResult
= sal_False
; // the second switch to the same mode
609 SetTitle( String() );
614 //--------------------------------------------------------------------
616 void SfxObjectShell::FreeSharedFile()
619 FreeSharedFile( pMedium
->GetURLObject().GetMainURL( INetURLObject::NO_DECODE
) );
622 //--------------------------------------------------------------------
623 void SfxObjectShell::FreeSharedFile( const OUString
& aTempFileURL
)
625 SetSharedXMLFlag( sal_False
);
627 if ( IsDocShared() && !aTempFileURL
.isEmpty()
628 && !::utl::UCBContentHelper::EqualURLs( aTempFileURL
, GetSharedFileURL() ) )
630 if ( pImp
->m_bAllowShareControlFileClean
)
634 ::svt::ShareControlFile
aControlFile( GetSharedFileURL() );
635 aControlFile
.RemoveEntry();
637 catch( uno::Exception
& )
642 // the cleaning is forbidden only once
643 pImp
->m_bAllowShareControlFileClean
= sal_True
;
645 // now remove the temporary file the document is based currently on
646 ::utl::UCBContentHelper::Kill( aTempFileURL
);
648 pImp
->m_aSharedFileURL
= OUString();
652 //--------------------------------------------------------------------
653 void SfxObjectShell::DoNotCleanShareControlFile()
655 pImp
->m_bAllowShareControlFileClean
= sal_False
;
658 //--------------------------------------------------------------------
659 void SfxObjectShell::SetSharedXMLFlag( sal_Bool bFlag
) const
661 pImp
->m_bSharedXMLFlag
= bFlag
;
664 //--------------------------------------------------------------------
665 sal_Bool
SfxObjectShell::HasSharedXMLFlagSet() const
667 return pImp
->m_bSharedXMLFlag
;
670 //--------------------------------------------------------------------
672 sal_Bool
SfxObjectShell::IsDocShared() const
674 return ( !pImp
->m_aSharedFileURL
.isEmpty() );
677 //--------------------------------------------------------------------
679 OUString
SfxObjectShell::GetSharedFileURL() const
681 return pImp
->m_aSharedFileURL
;
686 //--------------------------------------------------------------------
688 Size
SfxObjectShell::GetFirstPageSize()
690 return GetVisArea(ASPECT_THUMBNAIL
).GetSize();
694 //--------------------------------------------------------------------
696 IndexBitSet
& SfxObjectShell::GetNoSet_Impl()
698 return pImp
->aBitSet
;
701 //--------------------------------------------------------------------
702 // changes the title of the document
704 void SfxObjectShell::SetTitle
706 const String
& rTitle
// the new Document Title
711 With this method, the title of the document can be set.
712 This corresponds initially to the full file name. A setting of the
713 title does not affect the file name, but it will be shown in the
714 Caption-Bars of the MDI-window.
718 DBG_CHKTHIS(SfxObjectShell
, 0);
721 if ( ( ( HasName() && pImp
->aTitle
== rTitle
)
722 || ( !HasName() && GetTitle() == rTitle
) )
726 SfxApplication
*pSfxApp
= SFX_APP();
728 // If possible relase the unnamed number.
729 if ( pImp
->bIsNamedVisible
&& USHRT_MAX
!= pImp
->nVisualDocumentNumber
)
731 pSfxApp
->ReleaseIndex(pImp
->nVisualDocumentNumber
);
732 pImp
->bIsNamedVisible
= 0;
736 pImp
->aTitle
= rTitle
;
741 SfxShell::SetName( GetTitle(SFX_TITLE_APINAME
) );
742 Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
746 //--------------------------------------------------------------------
748 #if OSL_DEBUG_LEVEL > 1
749 String
X(const String
&rRet
)
752 return String( "-empty-" );
759 //--------------------------------------------------------------------
760 String
SfxObjectShell::GetTitle
762 sal_uInt16 nMaxLength
/* 0 (default)
763 the title itself, as it is
765 1 (==SFX_TITLE_FILENAME)
766 provides the logical file name without path
767 (under WNT depending on the system settings
770 2 (==SFX_TITLE_FULLNAME)
771 provides the logical file names with full path
772 (remote =>:: com:: sun:: star:: util:: URL)
774 3 (==SFX_TITLE_APINAME)
775 provides the logical filname without path
778 4 (==SFX_TITLE_DETECT)
779 provides the complete title, if not set yet
780 it will be created from DocInfo or the name of
783 5 (==SFX_TITLE_CAPTION)
784 provides the Title just like MB now in the
787 6 (==SFX_TITLE_PICKLIST)
788 returns the Title, just like MB now would
789 display it in the in the PickList
791 7 (==SFX_TITLE_HISTORY)
792 returns the Title just like MB now would
793 display it in the in the History
796 provides the 'nMaxLength' of the logical
797 file name including the path
798 (remote => ::com::sun::star::util::URL)
804 Returns the title or logical file name of the document, depending on the
807 If the file name with path is used, the Name shortened by replacing one or
808 more directory names with "...", URLs are currently always returned
813 SfxMedium
*pMed
= GetMedium();
818 if ( SFX_TITLE_DETECT
== nMaxLength
&& !pImp
->aTitle
.Len() )
820 static sal_Bool bRecur
= sal_False
;
822 return String( "-not available-" );
826 SfxObjectShell
*pThis
= (SfxObjectShell
*) this;
830 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pNameItem
, SfxStringItem
, SID_DOCINFO_TITLE
, sal_False
);
832 aTitle
= pNameItem
->GetValue();
836 aTitle
= GetTitle( SFX_TITLE_FILENAME
);
839 pThis
->SetTitle( aTitle
);
843 else if (SFX_TITLE_APINAME
== nMaxLength
)
844 return X(GetAPIName());
846 // Special case templates:
847 if( IsTemplate() && pImp
->aTitle
.Len() &&
848 ( nMaxLength
== SFX_TITLE_CAPTION
|| nMaxLength
== SFX_TITLE_PICKLIST
) )
849 return X(pImp
->aTitle
);
851 // Picklist/Caption is mapped
852 if ( pMed
&& ( nMaxLength
== SFX_TITLE_CAPTION
|| nMaxLength
== SFX_TITLE_PICKLIST
) )
854 // If a specific title was given at open:
855 // important for URLs: use INET_PROT_FILE for which the set title is not
856 // considered. (See below, analysis of aTitleMap_Impl)
857 SFX_ITEMSET_ARG( pMed
->GetItemSet(), pNameItem
, SfxStringItem
, SID_DOCINFO_TITLE
, sal_False
);
859 return X( pNameItem
->GetValue() );
863 DBG_ASSERT( !HasName() || pMed
, "HasName() but no Medium?!?" );
864 if ( !HasName() || !pMed
)
866 // Title already set?
867 if ( pImp
->aTitle
.Len() )
868 return X(pImp
->aTitle
);
870 // must it be numbered?
871 OUString
aNoName(SFX2_RESSTR(STR_NONAME
));
872 if (pImp
->bIsNamedVisible
)
875 aNoName
+= OUString::valueOf(static_cast<sal_Int32
>(pImp
->nVisualDocumentNumber
));
878 // Document called "noname" for the time being
882 const INetURLObject
aURL( IsDocShared() ? GetSharedFileURL() : OUString( GetMedium()->GetName() ) );
883 if ( nMaxLength
> SFX_TITLE_CAPTION
&& nMaxLength
<= SFX_TITLE_HISTORY
)
886 if( !pMed
|| aURL
.GetProtocol() == INET_PROT_FILE
)
890 nMaxLength
= aTitleMap_Impl
[nMaxLength
-SFX_TITLE_CAPTION
][nRemote
];
894 if ( aURL
.GetProtocol() == INET_PROT_FILE
)
896 String
aName( aURL
.HasMark() ? INetURLObject( aURL
.GetURLNoMark() ).PathToFileName() : aURL
.PathToFileName() );
897 if ( nMaxLength
== SFX_TITLE_FULLNAME
)
899 else if ( nMaxLength
== SFX_TITLE_FILENAME
)
900 return X( aURL
.getName( INetURLObject::LAST_SEGMENT
,
901 true, INetURLObject::DECODE_WITH_CHARSET
) );
902 else if ( !pImp
->aTitle
.Len() )
903 pImp
->aTitle
= aURL
.getBase( INetURLObject::LAST_SEGMENT
,
904 true, INetURLObject::DECODE_WITH_CHARSET
);
908 // ::com::sun::star::util::URL-Versions
909 if ( nMaxLength
>= SFX_TITLE_MAXLEN
)
911 String
aComplete( aURL
.GetMainURL( INetURLObject::NO_DECODE
) );
912 if( aComplete
.Len() > nMaxLength
)
914 String
aRet( "..." );
915 aRet
+= aComplete
.Copy( aComplete
.Len() - nMaxLength
+ 3, nMaxLength
- 3 );
919 return X( aComplete
);
921 else if ( nMaxLength
== SFX_TITLE_FILENAME
)
923 String
aName( aURL
.GetBase() );
924 aName
= INetURLObject::decode( aName
, INET_HEX_ESCAPE
, INetURLObject::DECODE_WITH_CHARSET
);
926 aName
= aURL
.GetURLNoPass();
929 else if ( nMaxLength
== SFX_TITLE_FULLNAME
)
930 return X(aURL
.GetMainURL( INetURLObject::DECODE_TO_IURI
));
932 // Generate Title from file name if possible
933 if ( !pImp
->aTitle
.Len() )
934 pImp
->aTitle
= aURL
.GetBase();
936 // workaround for the case when the name can not be retrieved from URL by INetURLObject
937 if ( !pImp
->aTitle
.Len() )
938 pImp
->aTitle
= aURL
.GetMainURL( INetURLObject::DECODE_WITH_CHARSET
);
942 return X(pImp
->aTitle
);
945 //--------------------------------------------------------------------
947 void SfxObjectShell::InvalidateName()
951 Returns the title of the new document, DocInfo-Title or
952 File name. Is required for loading from template or SaveAs.
956 pImp
->aTitle
.Erase();
957 SetName( GetTitle( SFX_TITLE_APINAME
) );
959 Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
962 //--------------------------------------------------------------------
964 void SfxObjectShell::SetNamedVisibility_Impl()
966 if ( !pImp
->bIsNamedVisible
)
968 pImp
->bIsNamedVisible
= sal_True
;
969 if ( !HasName() && USHRT_MAX
== pImp
->nVisualDocumentNumber
&& !pImp
->aTitle
.Len() )
971 pImp
->nVisualDocumentNumber
= SFX_APP()->GetFreeIndex();
972 Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED
) );
976 SetName( GetTitle(SFX_TITLE_APINAME
) );
979 void SfxObjectShell::SetNoName()
983 GetModel()->attachResource( OUString(), GetModel()->getArgs() );
986 //--------------------------------------------------------------------
988 SfxProgress
* SfxObjectShell::GetProgress() const
990 return pImp
->pProgress
;
993 //--------------------------------------------------------------------
995 void SfxObjectShell::SetProgress_Impl
997 SfxProgress
*pProgress
/* to started <SfxProgress> or 0,
998 if the progress is to be reset */
1003 Internal method to set or reset the Progress modes for
1008 DBG_ASSERT( ( !pImp
->pProgress
&& pProgress
) ||
1009 ( pImp
->pProgress
&& !pProgress
),
1010 "Progress activation/deacitivation mismatch" );
1011 pImp
->pProgress
= pProgress
;
1014 //--------------------------------------------------------------------
1016 void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame
* pFrame
)
1018 SfxApplication
* pSfxApp
= SFX_APP();
1019 if ( !pSfxApp
->IsDowning() && !IsLoading() && pFrame
&& !pFrame
->GetFrame().IsClosing_Impl() )
1021 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pHiddenItem
, SfxBoolItem
, SID_HIDDEN
, sal_False
);
1022 if ( !pHiddenItem
|| !pHiddenItem
->GetValue() )
1024 sal_uInt16 nId
= pImp
->nEventId
;
1026 if ( nId
== SFX_EVENT_OPENDOC
)
1027 pSfxApp
->NotifyEvent(SfxViewEventHint( nId
, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC
), this, pFrame
->GetFrame().GetController() ), sal_False
);
1028 else if (nId
== SFX_EVENT_CREATEDOC
)
1029 pSfxApp
->NotifyEvent(SfxViewEventHint( nId
, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC
), this, pFrame
->GetFrame().GetController() ), sal_False
);
1034 //--------------------------------------------------------------------
1036 void SfxObjectShell::SetActivateEvent_Impl(sal_uInt16 nId
)
1038 if ( GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC
)
1039 pImp
->nEventId
= nId
;
1042 void SfxObjectShell::PrepareReload( )
1045 Is called before the Reload and gives the opportunity to clear any caches.
1050 // Can be moved to frame.cxx, when 358+36x-State have been merged
1052 sal_Bool
SfxFrame::IsAutoLoadLocked_Impl() const
1054 // Its own Docucument is locked?
1055 const SfxObjectShell
* pObjSh
= GetCurrentDocument();
1056 if ( !pObjSh
|| !pObjSh
->IsAutoLoadLocked() )
1059 // Its children are locked?
1060 for ( sal_uInt16 n
= GetChildFrameCount(); n
--; )
1061 if ( !GetChildFrame(n
)->IsAutoLoadLocked_Impl() )
1064 // otherwise allow AutoLoad
1068 //-------------------------------------------------------------------------
1070 sal_Bool
SfxObjectShell::IsAutoLoadLocked() const
1072 /* Returns whether an Autoload is allowed to be executed. Before the
1073 surrounding FrameSet of the AutoLoad is also taken into account as well.
1077 return !IsReadOnly() || pImp
->nAutoLoadLocks
> 0;
1080 //-------------------------------------------------------------------------
1081 void SfxObjectShell::BreakMacroSign_Impl( sal_Bool bBreakMacroSign
)
1083 pImp
->m_bMacroSignBroken
= bBreakMacroSign
;
1086 //-------------------------------------------------------------------------
1087 void SfxObjectShell::CheckSecurityOnLoading_Impl()
1089 uno::Reference
< task::XInteractionHandler
> xInteraction
;
1091 xInteraction
= GetMedium()->GetInteractionHandler();
1093 // check if there is a broken signature...
1094 CheckForBrokenDocSignatures_Impl( xInteraction
);
1096 CheckEncryption_Impl( xInteraction
);
1098 // check macro security
1099 pImp
->aMacroMode
.checkMacrosOnLoading( xInteraction
);
1102 //-------------------------------------------------------------------------
1103 void SfxObjectShell::CheckEncryption_Impl( const uno::Reference
< task::XInteractionHandler
>& xHandler
)
1106 sal_Bool bIsEncrypted
= sal_False
;
1107 sal_Bool bHasNonEncrypted
= sal_False
;
1111 uno::Reference
< beans::XPropertySet
> xPropSet( GetStorage(), uno::UNO_QUERY_THROW
);
1112 xPropSet
->getPropertyValue( OUString( "Version" ) ) >>= aVersion
;
1113 xPropSet
->getPropertyValue( OUString( "HasEncryptedEntries" ) ) >>= bIsEncrypted
;
1114 xPropSet
->getPropertyValue( OUString( "HasNonEncryptedEntries" ) ) >>= bHasNonEncrypted
;
1116 catch( uno::Exception
& )
1120 if ( aVersion
.compareTo( ODFVER_012_TEXT
) >= 0 )
1122 // this is ODF1.2 or later
1123 if ( bIsEncrypted
&& bHasNonEncrypted
)
1125 if ( !pImp
->m_bIncomplEncrWarnShown
)
1127 // this is an encrypted document with nonencrypted streams inside, show the warning
1128 ::com::sun::star::task::ErrorCodeRequest aErrorCode
;
1129 aErrorCode
.ErrCode
= ERRCODE_SFX_INCOMPLETE_ENCRYPTION
;
1131 SfxMedium::CallApproveHandler( xHandler
, uno::makeAny( aErrorCode
), sal_False
);
1132 pImp
->m_bIncomplEncrWarnShown
= sal_True
;
1135 // broken signatures imply no macro execution at all
1136 pImp
->aMacroMode
.disallowMacroExecution();
1141 //-------------------------------------------------------------------------
1142 void SfxObjectShell::CheckForBrokenDocSignatures_Impl( const uno::Reference
< task::XInteractionHandler
>& xHandler
)
1144 sal_Int16 nSignatureState
= GetDocumentSignatureState();
1145 bool bSignatureBroken
= ( nSignatureState
== SIGNATURESTATE_SIGNATURES_BROKEN
);
1146 if ( !bSignatureBroken
)
1149 pImp
->showBrokenSignatureWarning( xHandler
);
1151 // broken signatures imply no macro execution at all
1152 pImp
->aMacroMode
.disallowMacroExecution();
1155 //-------------------------------------------------------------------------
1156 void SfxObjectShell::SetAutoLoad(
1157 const INetURLObject
& rUrl
, sal_uInt32 nTime
, sal_Bool bReload
)
1159 if ( pImp
->pReloadTimer
)
1160 DELETEZ(pImp
->pReloadTimer
);
1163 pImp
->pReloadTimer
= new AutoReloadTimer_Impl(
1164 rUrl
.GetMainURL( INetURLObject::DECODE_TO_IURI
),
1166 pImp
->pReloadTimer
->Start();
1170 sal_Bool
SfxObjectShell::IsLoadingFinished() const
1172 return ( pImp
->nLoadedFlags
== SFX_LOADED_ALL
);
1175 void impl_addToModelCollection(const com::sun::star::uno::Reference
< com::sun::star::frame::XModel
>& xModel
);
1176 void SfxObjectShell::InitOwnModel_Impl()
1178 if ( !pImp
->bModelInitialized
)
1180 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pSalvageItem
, SfxStringItem
, SID_DOC_SALVAGE
, sal_False
);
1183 pImp
->aTempName
= pMedium
->GetPhysicalName();
1184 pMedium
->GetItemSet()->ClearItem( SID_DOC_SALVAGE
);
1185 pMedium
->GetItemSet()->ClearItem( SID_FILE_NAME
);
1186 pMedium
->GetItemSet()->Put( SfxStringItem( SID_FILE_NAME
, pMedium
->GetOrigURL() ) );
1190 pMedium
->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL
);
1191 pMedium
->GetItemSet()->ClearItem( SID_DOCUMENT
);
1194 pMedium
->GetItemSet()->ClearItem( SID_REFERER
);
1195 uno::Reference
< frame::XModel
> xModel ( GetModel(), uno::UNO_QUERY
);
1198 OUString aURL
= GetMedium()->GetOrigURL();
1199 SfxItemSet
*pSet
= GetMedium()->GetItemSet();
1200 if ( !GetMedium()->IsReadOnly() )
1201 pSet
->ClearItem( SID_INPUTSTREAM
);
1202 uno::Sequence
< beans::PropertyValue
> aArgs
;
1203 TransformItems( SID_OPENDOC
, *pSet
, aArgs
);
1204 xModel
->attachResource( aURL
, aArgs
);
1205 impl_addToModelCollection(xModel
);
1208 pImp
->bModelInitialized
= sal_True
;
1212 void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags
)
1214 sal_Bool bSetModifiedTRUE
= sal_False
;
1215 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pSalvageItem
, SfxStringItem
, SID_DOC_SALVAGE
, sal_False
);
1216 if( ( nFlags
& SFX_LOADED_MAINDOCUMENT
) && !(pImp
->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
)
1217 && !(pImp
->nFlagsInProgress
& SFX_LOADED_MAINDOCUMENT
))
1219 pImp
->nFlagsInProgress
|= SFX_LOADED_MAINDOCUMENT
;
1220 ((SfxHeaderAttributes_Impl
*)GetHeaderAttributes())->SetAttributes();
1221 pImp
->bImportDone
= sal_True
;
1222 if( !IsAbortingImport() )
1223 PositionView_Impl();
1225 if ( ( GetModifyPasswordHash() || GetModifyPasswordInfo().getLength() ) && !IsModifyPasswordEntered() )
1230 bSetModifiedTRUE
= sal_True
;
1232 if ( !IsEnableSetModified() )
1233 EnableSetModified( sal_True
);
1235 if( !bSetModifiedTRUE
&& IsEnableSetModified() )
1236 SetModified( sal_False
);
1238 CheckSecurityOnLoading_Impl();
1240 bHasName
= sal_True
; // the document is loaded, so the name should already available
1241 GetTitle( SFX_TITLE_DETECT
);
1242 InitOwnModel_Impl();
1243 pImp
->nFlagsInProgress
&= ~SFX_LOADED_MAINDOCUMENT
;
1246 if( ( nFlags
& SFX_LOADED_IMAGES
) && !(pImp
->nLoadedFlags
& SFX_LOADED_IMAGES
)
1247 && !(pImp
->nFlagsInProgress
& SFX_LOADED_IMAGES
))
1249 pImp
->nFlagsInProgress
|= SFX_LOADED_IMAGES
;
1250 uno::Reference
<document::XDocumentProperties
> xDocProps(
1251 getDocProperties());
1252 OUString
url(xDocProps
->getAutoloadURL());
1253 sal_Int32
delay(xDocProps
->getAutoloadSecs());
1254 SetAutoLoad( INetURLObject(url
), delay
* 1000,
1255 (delay
> 0) || !url
.isEmpty() );
1256 if( !bSetModifiedTRUE
&& IsEnableSetModified() )
1257 SetModified( sal_False
);
1258 Invalidate( SID_SAVEASDOC
);
1259 pImp
->nFlagsInProgress
&= ~SFX_LOADED_IMAGES
;
1262 pImp
->nLoadedFlags
|= nFlags
;
1264 if ( !pImp
->nFlagsInProgress
)
1266 // in case of reentrance calls the first called FinishedLoading() call on the stack
1267 // should do the notification, in result the notification is done when all the FinishedLoading() calls are finished
1269 if ( bSetModifiedTRUE
)
1270 SetModified( sal_True
);
1272 SetModified( sal_False
);
1274 if ( (pImp
->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
) && (pImp
->nLoadedFlags
& SFX_LOADED_IMAGES
) )
1276 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pTemplateItem
, SfxBoolItem
, SID_TEMPLATE
, sal_False
);
1277 sal_Bool bTemplate
= pTemplateItem
&& pTemplateItem
->GetValue();
1279 // closing the streams on loading should be under control of SFX!
1280 DBG_ASSERT( pMedium
->IsOpen(), "Don't close the medium when loading documents!" );
1284 TemplateDisconnectionAfterLoad();
1288 // if a readonly medium has storage then it's stream is already based on temporary file
1289 if( !(pMedium
->GetOpenMode() & STREAM_WRITE
) && !pMedium
->HasStorage_Impl() )
1290 // don't lock file opened read only
1291 pMedium
->CloseInStream();
1295 SetInitialized_Impl( false );
1297 // Title is not available until loading has finished
1298 Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED
) );
1299 if ( pImp
->nEventId
)
1300 PostActivateEvent_Impl(SfxViewFrame::GetFirst(this));
1304 //-------------------------------------------------------------------------
1305 extern void SetTemplate_Impl( const String
&, const String
&, SfxObjectShell
* );
1307 void SfxObjectShell::TemplateDisconnectionAfterLoad()
1309 // document is created from a template
1310 //TODO/LATER: should the templates always be XML docs!
1312 SfxMedium
* pTmpMedium
= pMedium
;
1315 String
aName( pTmpMedium
->GetName() );
1316 SFX_ITEMSET_ARG( pTmpMedium
->GetItemSet(), pTemplNamItem
, SfxStringItem
, SID_TEMPLATE_NAME
, sal_False
);
1317 String aTemplateName
;
1318 if ( pTemplNamItem
)
1319 aTemplateName
= pTemplNamItem
->GetValue();
1322 // !TODO/LATER: what's this?!
1323 // Interactiv ( DClick, Contextmenu ) no long name is included
1324 aTemplateName
= getDocProperties()->getTitle();
1325 if ( !aTemplateName
.Len() )
1327 INetURLObject
aURL( aName
);
1328 aURL
.CutExtension();
1329 aTemplateName
= aURL
.getName( INetURLObject::LAST_SEGMENT
, true, INetURLObject::DECODE_WITH_CHARSET
);
1333 // set medium to noname
1334 pTmpMedium
->SetName( String(), sal_True
);
1335 pTmpMedium
->Init_Impl();
1341 if( IsPackageStorageFormat_Impl( *pTmpMedium
) )
1343 // untitled document must be based on temporary storage
1344 // the medium should not dispose the storage in this case
1345 uno::Reference
< embed::XStorage
> xTmpStor
= ::comphelper::OStorageHelper::GetTemporaryStorage();
1346 GetStorage()->copyToStorage( xTmpStor
);
1348 // the medium should disconnect from the original location
1349 // the storage should not be disposed since the document is still
1350 // based on it, but in DoSaveCompleted it will be disposed
1351 pTmpMedium
->CanDisposeStorage_Impl( sal_False
);
1352 pTmpMedium
->Close();
1354 // setting the new storage the medium will be based on
1355 pTmpMedium
->SetStorage_Impl( xTmpStor
);
1358 if( !DoSaveCompleted( pTmpMedium
) )
1359 SetError( ERRCODE_IO_GENERAL
, OUString( OSL_LOG_PREFIX
) );
1362 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pSalvageItem
, SfxStringItem
, SID_DOC_SALVAGE
, sal_False
);
1363 sal_Bool bSalvage
= pSalvageItem
? sal_True
: sal_False
;
1367 // some further initializations for templates
1368 SetTemplate_Impl( aName
, aTemplateName
, this );
1371 // the medium should not dispose the storage, DoSaveCompleted() has let it to do so
1372 pTmpMedium
->CanDisposeStorage_Impl( sal_False
);
1377 // some further initializations for templates
1378 SetTemplate_Impl( aName
, aTemplateName
, this );
1379 pTmpMedium
->CreateTempFile( sal_True
);
1382 // templates are never readonly
1383 pTmpMedium
->GetItemSet()->ClearItem( SID_DOC_READONLY
);
1384 pTmpMedium
->SetOpenMode( SFX_STREAM_READWRITE
, sal_True
);
1386 // notifications about possible changes in readonly state and document info
1387 Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED
) );
1389 // created untitled document can't be modified
1390 SetModified( sal_False
);
1394 //-------------------------------------------------------------------------
1396 void SfxObjectShell::PositionView_Impl()
1398 MarkData_Impl
*pMark
= Get_Impl()->pMarkData
;
1401 SfxViewShell
* pSh
= pMark
->pFrame
->GetViewShell();
1402 if( pMark
->aUserData
.Len() )
1403 pSh
->ReadUserData( pMark
->aUserData
, sal_True
);
1404 else if( pMark
->aMark
.Len() )
1405 pSh
->JumpToMark( pMark
->aMark
);
1406 DELETEZ( Get_Impl()->pMarkData
);
1410 //-------------------------------------------------------------------------
1412 sal_Bool
SfxObjectShell::IsLoading() const
1415 Has FinishedLoading been called?
1418 return !( pImp
->nLoadedFlags
& SFX_LOADED_MAINDOCUMENT
);
1421 //-------------------------------------------------------------------------
1423 void SfxObjectShell::CancelTransfers()
1426 Here can Transfers get canceled, which were not regestered
1427 by RegisterTransfer.
1430 if( ( pImp
->nLoadedFlags
& SFX_LOADED_ALL
) != SFX_LOADED_ALL
)
1434 FinishedLoading( SFX_LOADED_ALL
);
1438 //-------------------------------------------------------------------------
1440 AutoReloadTimer_Impl::AutoReloadTimer_Impl(
1441 const String
& rURL
, sal_uInt32 nTime
, SfxObjectShell
* pSh
)
1442 : aUrl( rURL
), pObjSh( pSh
)
1444 SetTimeout( nTime
);
1447 //-------------------------------------------------------------------------
1449 void AutoReloadTimer_Impl::Timeout()
1451 SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst( pObjSh
);
1455 // Not possible/meanigfull at the moment?
1456 if ( !pObjSh
->CanReload_Impl() || pObjSh
->IsAutoLoadLocked() || Application::IsUICaptured() )
1463 SfxAllItemSet
aSet( SFX_APP()->GetPool() );
1464 aSet
.Put( SfxBoolItem( SID_AUTOLOAD
, sal_True
) );
1466 aSet
.Put( SfxStringItem( SID_FILE_NAME
, aUrl
) );
1467 SfxRequest
aReq( SID_RELOAD
, 0, aSet
);
1468 pObjSh
->Get_Impl()->pReloadTimer
= 0;
1470 pFrame
->ExecReload_Impl( aReq
);
1474 pObjSh
->Get_Impl()->pReloadTimer
= 0;
1478 SfxModule
* SfxObjectShell::GetModule() const
1480 return GetFactory().GetModule();
1483 ErrCode
SfxObjectShell::CallBasic( const String
& rMacro
,
1484 const String
& rBasic
, SbxArray
* pArgs
,
1487 SfxApplication
* pApp
= SFX_APP();
1488 if( pApp
->GetName() != rBasic
)
1490 if ( !AdjustMacroMode( String() ) )
1491 return ERRCODE_IO_ACCESSDENIED
;
1494 BasicManager
*pMgr
= GetBasicManager();
1495 if( pApp
->GetName() == rBasic
)
1496 pMgr
= pApp
->GetBasicManager();
1497 ErrCode nRet
= SfxApplication::CallBasic( rMacro
, pMgr
, pArgs
, pRet
);
1503 static bool lcl_isScriptAccessAllowed_nothrow( const Reference
< XInterface
>& _rxScriptContext
)
1507 Reference
< XEmbeddedScripts
> xScripts( _rxScriptContext
, UNO_QUERY
);
1508 if ( !xScripts
.is() )
1510 Reference
< XScriptInvocationContext
> xContext( _rxScriptContext
, UNO_QUERY_THROW
);
1511 xScripts
.set( xContext
->getScriptContainer(), UNO_SET_THROW
);
1514 return xScripts
->getAllowMacroExecution();
1516 catch( const Exception
& )
1518 DBG_UNHANDLED_EXCEPTION();
1524 ErrCode
SfxObjectShell::CallXScript( const Reference
< XInterface
>& _rxScriptContext
, const OUString
& _rScriptURL
,
1525 const Sequence
< Any
>& aParams
, Any
& aRet
, Sequence
< sal_Int16
>& aOutParamIndex
, Sequence
< Any
>& aOutParam
, bool bRaiseError
, const ::com::sun::star::uno::Any
* pCaller
)
1527 OSL_TRACE( "in CallXScript" );
1528 ErrCode nErr
= ERRCODE_NONE
;
1530 bool bIsDocumentScript
= ( _rScriptURL
.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "location=document" ) ) >= 0 );
1531 // TODO: we should parse the URL, and check whether there is a parameter with this name.
1532 // Otherwise, we might find too much.
1533 if ( bIsDocumentScript
&& !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext
) )
1534 return ERRCODE_IO_ACCESSDENIED
;
1536 bool bCaughtException
= false;
1540 // obtain/create a script provider
1541 Reference
< provider::XScriptProvider
> xScriptProvider
;
1542 Reference
< provider::XScriptProviderSupplier
> xSPS( _rxScriptContext
, UNO_QUERY
);
1544 xScriptProvider
.set( xSPS
->getScriptProvider() );
1546 if ( !xScriptProvider
.is() )
1548 Reference
< provider::XScriptProviderFactory
> xScriptProviderFactory
=
1549 provider::theMasterScriptProviderFactory::get( ::comphelper::getProcessComponentContext() );
1550 xScriptProvider
.set( xScriptProviderFactory
->createScriptProvider( makeAny( _rxScriptContext
) ), UNO_SET_THROW
);
1553 // ry to protect the invocation context's undo manager (if present), just in case the script tampers with it
1554 ::framework::DocumentUndoGuard
aUndoGuard( _rxScriptContext
.get() );
1556 // obtain the script, and execute it
1557 Reference
< provider::XScript
> xScript( xScriptProvider
->getScript( _rScriptURL
), UNO_QUERY_THROW
);
1558 if ( pCaller
&& pCaller
->hasValue() )
1560 Reference
< beans::XPropertySet
> xProps( xScript
, uno::UNO_QUERY
);
1563 Sequence
< uno::Any
> aArgs( 1 );
1564 aArgs
[ 0 ] = *pCaller
;
1565 xProps
->setPropertyValue( OUString("Caller"), uno::makeAny( aArgs
) );
1568 aRet
= xScript
->invoke( aParams
, aOutParamIndex
, aOutParam
);
1570 catch ( const uno::Exception
& )
1572 aException
= ::cppu::getCaughtException();
1573 bCaughtException
= sal_True
;
1574 nErr
= ERRCODE_BASIC_INTERNAL_ERROR
;
1577 if ( bCaughtException
&& bRaiseError
)
1579 ::std::auto_ptr
< VclAbstractDialog
> pScriptErrDlg
;
1580 SfxAbstractDialogFactory
* pFact
= SfxAbstractDialogFactory::Create();
1582 pScriptErrDlg
.reset( pFact
->CreateScriptErrorDialog( NULL
, aException
) );
1583 OSL_ENSURE( pScriptErrDlg
.get(), "SfxObjectShell::CallXScript: no script error dialog!" );
1585 if ( pScriptErrDlg
.get() )
1586 pScriptErrDlg
->Execute();
1589 OSL_TRACE( "leaving CallXScript" );
1593 // perhaps rename to CallScript once we get rid of the existing CallScript
1594 // and Call, CallBasic, CallStarBasic methods
1595 ErrCode
SfxObjectShell::CallXScript( const String
& rScriptURL
,
1596 const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>&
1598 ::com::sun::star::uno::Any
& aRet
,
1599 ::com::sun::star::uno::Sequence
< sal_Int16
>& aOutParamIndex
,
1600 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>&
1601 aOutParam
, bool bRaiseError
, const ::com::sun::star::uno::Any
* pCaller
)
1603 return CallXScript( GetModel(), rScriptURL
, aParams
, aRet
, aOutParamIndex
, aOutParam
, bRaiseError
, pCaller
);
1606 //-------------------------------------------------------------------------
1607 SfxFrame
* SfxObjectShell::GetSmartSelf( SfxFrame
* pSelf
, SfxMedium
& /*rMedium*/ )
1612 SfxObjectShellFlags
SfxObjectShell::GetFlags() const
1614 if( pImp
->eFlags
== SFXOBJECTSHELL_UNDEFINED
)
1615 pImp
->eFlags
= GetFactory().GetFlags();
1616 return pImp
->eFlags
;
1619 void SfxHeaderAttributes_Impl::SetAttributes()
1623 for( sal_Bool bCont
= xIter
->GetFirst( aPair
); bCont
;
1624 bCont
= xIter
->GetNext( aPair
) )
1625 SetAttribute( aPair
);
1628 void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue
& rKV
)
1630 String aValue
= rKV
.GetValue();
1631 if( rKV
.GetKey().CompareIgnoreCaseToAscii( "refresh" ) == COMPARE_EQUAL
&& rKV
.GetValue().Len() )
1633 sal_uInt32 nTime
= aValue
.GetToken( 0, ';' ).ToInt32() ;
1634 String aURL
= comphelper::string::strip(aValue
.GetToken( 1, ';' ), ' ');
1635 uno::Reference
<document::XDocumentProperties
> xDocProps(
1636 pDoc
->getDocProperties());
1637 if( aURL
.Copy(0, 4).CompareIgnoreCaseToAscii( "url=" ) == COMPARE_EQUAL
)
1640 INetURLObject( pDoc
->GetMedium()->GetName() ).GetNewAbsURL( aURL
.Copy( 4 ), &aObj
);
1641 xDocProps
->setAutoloadURL(
1642 aObj
.GetMainURL( INetURLObject::NO_DECODE
) );
1646 xDocProps
->setAutoloadSecs( nTime
);
1648 catch (lang::IllegalArgumentException
&)
1653 else if( rKV
.GetKey().CompareIgnoreCaseToAscii( "expires" ) == COMPARE_EQUAL
)
1655 DateTime
aDateTime( DateTime::EMPTY
);
1656 if( INetRFC822Message::ParseDateField( rKV
.GetValue(), aDateTime
) )
1658 aDateTime
.ConvertToLocalTime();
1659 pDoc
->GetMedium()->SetExpired_Impl( aDateTime
);
1663 pDoc
->GetMedium()->SetExpired_Impl( Date( 1, 1, 1970 ) );
1668 void SfxHeaderAttributes_Impl::Append( const SvKeyValue
& rKV
)
1670 xIter
->Append( rKV
);
1671 if( bAlert
) SetAttribute( rKV
);
1674 SvKeyValueIterator
* SfxObjectShell::GetHeaderAttributes()
1676 if( !pImp
->xHeaderAttributes
.Is() )
1678 DBG_ASSERT( pMedium
, "No Medium" );
1679 pImp
->xHeaderAttributes
= new SfxHeaderAttributes_Impl( this );
1681 return ( SvKeyValueIterator
*) &pImp
->xHeaderAttributes
;
1684 void SfxObjectShell::ClearHeaderAttributesForSourceViewHack()
1686 ((SfxHeaderAttributes_Impl
*)GetHeaderAttributes())
1687 ->ClearForSourceView();
1691 void SfxObjectShell::SetHeaderAttributesForSourceViewHack()
1693 ((SfxHeaderAttributes_Impl
*)GetHeaderAttributes())
1697 sal_Bool
SfxObjectShell::IsPreview() const
1702 sal_Bool bPreview
= sal_False
;
1703 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pFlags
, SfxStringItem
, SID_OPTIONS
, sal_False
);
1706 // Distributed values among individual items
1707 String aFileFlags
= pFlags
->GetValue();
1708 aFileFlags
.ToUpperAscii();
1709 if ( STRING_NOTFOUND
!= aFileFlags
.Search( 'B' ) )
1710 bPreview
= sal_True
;
1715 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pItem
, SfxBoolItem
, SID_PREVIEW
, sal_False
);
1717 bPreview
= pItem
->GetValue();
1723 void SfxObjectShell::SetWaitCursor( sal_Bool bSet
) const
1725 for( SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( this ); pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
, this ) )
1728 pFrame
->GetFrame().GetWindow().EnterWait();
1730 pFrame
->GetFrame().GetWindow().LeaveWait();
1734 String
SfxObjectShell::GetAPIName() const
1736 INetURLObject
aURL( IsDocShared() ? GetSharedFileURL() : OUString( GetMedium()->GetName() ) );
1737 String
aName( aURL
.GetBase() );
1739 aName
= aURL
.GetURLNoPass();
1741 aName
= GetTitle( SFX_TITLE_DETECT
);
1745 void SfxObjectShell::Invalidate( sal_uInt16 nId
)
1747 for( SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( this ); pFrame
; pFrame
= SfxViewFrame::GetNext( *pFrame
, this ) )
1748 Invalidate_Impl( pFrame
->GetBindings(), nId
);
1751 bool SfxObjectShell::AdjustMacroMode( const String
& /*rScriptType*/, bool bSuppressUI
)
1753 uno::Reference
< task::XInteractionHandler
> xInteraction
;
1754 if ( pMedium
&& !bSuppressUI
)
1755 xInteraction
= pMedium
->GetInteractionHandler();
1757 CheckForBrokenDocSignatures_Impl( xInteraction
);
1759 CheckEncryption_Impl( xInteraction
);
1761 return pImp
->aMacroMode
.adjustMacroMode( xInteraction
);
1764 Window
* SfxObjectShell::GetDialogParent( SfxMedium
* pLoadingMedium
)
1766 Window
* pWindow
= 0;
1767 SfxItemSet
* pSet
= pLoadingMedium
? pLoadingMedium
->GetItemSet() : GetMedium()->GetItemSet();
1768 SFX_ITEMSET_ARG( pSet
, pUnoItem
, SfxUnoFrameItem
, SID_FILLFRAME
, sal_False
);
1771 uno::Reference
< frame::XFrame
> xFrame( pUnoItem
->GetFrame() );
1772 pWindow
= VCLUnoHelper::GetWindow( xFrame
->getContainerWindow() );
1777 SfxFrame
* pFrame
= 0;
1778 SFX_ITEMSET_ARG( pSet
, pFrameItem
, SfxFrameItem
, SID_DOCFRAME
, sal_False
);
1779 if( pFrameItem
&& pFrameItem
->GetFrame() )
1780 // get target frame from ItemSet
1781 pFrame
= pFrameItem
->GetFrame();
1784 // try the current frame
1785 SfxViewFrame
* pView
= SfxViewFrame::Current();
1786 if ( !pView
|| pView
->GetObjectShell() != this )
1787 // get any visible frame
1788 pView
= SfxViewFrame::GetFirst(this);
1790 pFrame
= &pView
->GetFrame();
1794 // get topmost window
1795 pWindow
= VCLUnoHelper::GetWindow( pFrame
->GetFrameInterface()->getContainerWindow() );
1800 // this frame may be invisible, show it if it is allowed
1801 SFX_ITEMSET_ARG( pSet
, pHiddenItem
, SfxBoolItem
, SID_HIDDEN
, sal_False
);
1802 if ( !pHiddenItem
|| !pHiddenItem
->GetValue() )
1812 void SfxObjectShell::SetCreateMode_Impl( SfxObjectCreateMode nMode
)
1814 eCreateMode
= nMode
;
1817 sal_Bool
SfxObjectShell::IsInPlaceActive()
1819 if ( eCreateMode
!= SFX_CREATE_MODE_EMBEDDED
)
1822 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( this );
1823 return pFrame
&& pFrame
->GetFrame().IsInPlace();
1826 sal_Bool
SfxObjectShell::IsUIActive()
1828 if ( eCreateMode
!= SFX_CREATE_MODE_EMBEDDED
)
1831 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( this );
1832 return pFrame
&& pFrame
->GetFrame().IsInPlace() && pFrame
->GetFrame().GetWorkWindow_Impl()->IsVisible_Impl();
1835 void SfxObjectShell::UIActivate( sal_Bool
)
1839 void SfxObjectShell::InPlaceActivate( sal_Bool
)
1843 sal_Bool
SfxObjectShell::UseInteractionToHandleError(
1844 const uno::Reference
< task::XInteractionHandler
>& xHandler
,
1847 sal_Bool bResult
= sal_False
;
1849 if ( xHandler
.is() )
1853 uno::Any aInteraction
;
1854 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> > lContinuations(2);
1855 ::comphelper::OInteractionAbort
* pAbort
= new ::comphelper::OInteractionAbort();
1856 ::comphelper::OInteractionApprove
* pApprove
= new ::comphelper::OInteractionApprove();
1857 lContinuations
[0] = uno::Reference
< task::XInteractionContinuation
>(
1858 static_cast< task::XInteractionContinuation
* >( pAbort
), uno::UNO_QUERY
);
1859 lContinuations
[1] = uno::Reference
< task::XInteractionContinuation
>(
1860 static_cast< task::XInteractionContinuation
* >( pApprove
), uno::UNO_QUERY
);
1862 task::ErrorCodeRequest aErrorCode
;
1863 aErrorCode
.ErrCode
= nError
;
1864 aInteraction
<<= aErrorCode
;
1865 xHandler
->handle(::framework::InteractionRequest::CreateRequest (aInteraction
,lContinuations
));
1866 bResult
= pAbort
->wasSelected();
1868 catch( uno::Exception
& )
1875 sal_Int16
SfxObjectShell_Impl::getCurrentMacroExecMode() const
1877 sal_Int16
nImposedExecMode( MacroExecMode::NEVER_EXECUTE
);
1879 const SfxMedium
* pMedium( rDocShell
.GetMedium() );
1880 OSL_PRECOND( pMedium
, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
1883 SFX_ITEMSET_ARG( pMedium
->GetItemSet(), pMacroModeItem
, SfxUInt16Item
, SID_MACROEXECMODE
, sal_False
);
1884 if ( pMacroModeItem
)
1885 nImposedExecMode
= pMacroModeItem
->GetValue();
1887 return nImposedExecMode
;
1890 sal_Bool
SfxObjectShell_Impl::setCurrentMacroExecMode( sal_uInt16 nMacroMode
)
1892 const SfxMedium
* pMedium( rDocShell
.GetMedium() );
1893 OSL_PRECOND( pMedium
, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
1896 pMedium
->GetItemSet()->Put( SfxUInt16Item( SID_MACROEXECMODE
, nMacroMode
) );
1903 OUString
SfxObjectShell_Impl::getDocumentLocation() const
1907 const SfxMedium
* pMedium( rDocShell
.GetMedium() );
1908 OSL_PRECOND( pMedium
, "SfxObjectShell_Impl::getDocumentLocation: no medium!" );
1911 sLocation
= pMedium
->GetName();
1912 if ( sLocation
.isEmpty() )
1914 // for documents made from a template: get the name of the template
1915 sLocation
= rDocShell
.getDocProperties()->getTemplateURL();
1921 uno::Reference
< embed::XStorage
> SfxObjectShell_Impl::getZipStorageToSign()
1923 Reference
< embed::XStorage
> xStore
;
1925 SfxMedium
* pMedium( rDocShell
.GetMedium() );
1926 OSL_PRECOND( pMedium
, "SfxObjectShell_Impl::getLastCommitDocumentStorage: no medium!" );
1928 xStore
= pMedium
->GetZipStorageToSign_Impl();
1933 sal_Bool
SfxObjectShell_Impl::documentStorageHasMacros() const
1935 return ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocStorage
);
1938 Reference
< XEmbeddedScripts
> SfxObjectShell_Impl::getEmbeddedDocumentScripts() const
1940 return Reference
< XEmbeddedScripts
>( rDocShell
.GetModel(), UNO_QUERY
);
1943 sal_Int16
SfxObjectShell_Impl::getScriptingSignatureState()
1945 sal_Int16
nSignatureState( rDocShell
.GetScriptingSignatureState() );
1947 if ( nSignatureState
!= SIGNATURESTATE_NOSIGNATURES
&& m_bMacroSignBroken
)
1949 // if there is a macro signature it must be handled as broken
1950 nSignatureState
= SIGNATURESTATE_SIGNATURES_BROKEN
;
1953 return nSignatureState
;
1956 sal_Bool
SfxObjectShell_Impl::hasTrustedScriptingSignature( sal_Bool bAllowUIToAddAuthor
)
1958 sal_Bool bResult
= sal_False
;
1965 uno::Reference
< beans::XPropertySet
> xPropSet( rDocShell
.GetStorage(), uno::UNO_QUERY_THROW
);
1966 xPropSet
->getPropertyValue( OUString( "Version" ) ) >>= aVersion
;
1968 catch( uno::Exception
& )
1972 uno::Reference
< security::XDocumentDigitalSignatures
> xSigner( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion
) );
1974 if ( nScriptingSignatureState
== SIGNATURESTATE_UNKNOWN
1975 || nScriptingSignatureState
== SIGNATURESTATE_SIGNATURES_OK
1976 || nScriptingSignatureState
== SIGNATURESTATE_SIGNATURES_NOTVALIDATED
)
1978 uno::Sequence
< security::DocumentSignatureInformation
> aInfo
= rDocShell
.ImplAnalyzeSignature( sal_True
, xSigner
);
1980 if ( aInfo
.getLength() )
1982 if ( nScriptingSignatureState
== SIGNATURESTATE_UNKNOWN
)
1983 nScriptingSignatureState
= rDocShell
.ImplCheckSignaturesInformation( aInfo
);
1985 if ( nScriptingSignatureState
== SIGNATURESTATE_SIGNATURES_OK
1986 || nScriptingSignatureState
== SIGNATURESTATE_SIGNATURES_NOTVALIDATED
)
1988 for ( sal_Int32 nInd
= 0; !bResult
&& nInd
< aInfo
.getLength(); nInd
++ )
1990 bResult
= xSigner
->isAuthorTrusted( aInfo
[nInd
].Signer
);
1993 if ( !bResult
&& bAllowUIToAddAuthor
)
1995 uno::Reference
< task::XInteractionHandler
> xInteraction
;
1996 if ( rDocShell
.GetMedium() )
1997 xInteraction
= rDocShell
.GetMedium()->GetInteractionHandler();
1999 if ( xInteraction
.is() )
2001 task::DocumentMacroConfirmationRequest aRequest
;
2002 aRequest
.DocumentURL
= getDocumentLocation();
2003 aRequest
.DocumentStorage
= rDocShell
.GetMedium()->GetZipStorageToSign_Impl();
2004 aRequest
.DocumentSignatureInformation
= aInfo
;
2005 aRequest
.DocumentVersion
= aVersion
;
2006 aRequest
.Classification
= task::InteractionClassification_QUERY
;
2007 bResult
= SfxMedium::CallApproveHandler( xInteraction
, uno::makeAny( aRequest
), sal_True
);
2014 catch( uno::Exception
& )
2020 void SfxObjectShell_Impl::showBrokenSignatureWarning( const uno::Reference
< task::XInteractionHandler
>& _rxInteraction
) const
2022 if ( !bSignatureErrorIsShown
)
2024 SfxObjectShell::UseInteractionToHandleError( _rxInteraction
, ERRCODE_SFX_BROKENSIGNATURE
);
2025 const_cast< SfxObjectShell_Impl
* >( this )->bSignatureErrorIsShown
= sal_True
;
2029 void SfxObjectShell::AddLog( const OUString
& aMessage
)
2031 if ( !pImp
->m_xLogRing
.is() )
2035 Reference
<XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
2036 pImp
->m_xLogRing
.set( logging::DocumentIOLogRing::get(xContext
) );
2038 catch( uno::Exception
& )
2042 if ( pImp
->m_xLogRing
.is() )
2043 pImp
->m_xLogRing
->logString( aMessage
);
2048 void WriteStringInStream( const uno::Reference
< io::XOutputStream
>& xOutStream
, const OUString
& aString
)
2050 if ( xOutStream
.is() )
2052 OString aStrLog
= OUStringToOString( aString
, RTL_TEXTENCODING_UTF8
);
2053 uno::Sequence
< sal_Int8
> aLogData( (const sal_Int8
*)aStrLog
.getStr(), aStrLog
.getLength() );
2054 xOutStream
->writeBytes( aLogData
);
2056 aLogData
.realloc( 1 );
2058 xOutStream
->writeBytes( aLogData
);
2064 void SfxObjectShell::StoreLog()
2066 if ( !pImp
->m_xLogRing
.is() )
2070 Reference
<XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
2071 pImp
->m_xLogRing
.set( logging::DocumentIOLogRing::get(xContext
) );
2073 catch( uno::Exception
& )
2077 if ( pImp
->m_xLogRing
.is() )
2079 OUString aFileURL
= OUString( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}" );
2081 ::rtl::Bootstrap::expandMacros( aFileURL
);
2083 OUString aBuildID
= OUString( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("setup") ":buildid}" );
2085 ::rtl::Bootstrap::expandMacros( aBuildID
);
2087 if ( !aFileURL
.isEmpty() )
2089 aFileURL
+= OUString( "/user/temp/document_io_logring.txt" );
2092 uno::Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
2093 uno::Reference
< ucb::XSimpleFileAccess3
> xSimpleFileAccess(ucb::SimpleFileAccess::create(xContext
));
2094 uno::Reference
< io::XStream
> xStream( xSimpleFileAccess
->openFileReadWrite( aFileURL
), uno::UNO_SET_THROW
);
2095 uno::Reference
< io::XOutputStream
> xOutStream( xStream
->getOutputStream(), uno::UNO_SET_THROW
);
2096 uno::Reference
< io::XTruncate
> xTruncate( xOutStream
, uno::UNO_QUERY_THROW
);
2097 xTruncate
->truncate();
2099 if ( !aBuildID
.isEmpty() )
2100 WriteStringInStream( xOutStream
, aBuildID
);
2102 uno::Sequence
< OUString
> aLogSeq
= pImp
->m_xLogRing
->getCollectedLog();
2103 for ( sal_Int32 nInd
= 0; nInd
< aLogSeq
.getLength(); nInd
++ )
2104 WriteStringInStream( xOutStream
, aLogSeq
[nInd
] );
2106 catch( uno::Exception
& )
2112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */