LCOV - code coverage report
Current view: top level - sfx2/source/doc - objmisc.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 521 872 59.7 %
Date: 2014-11-03 Functions: 77 105 73.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include <config_folders.h>
      22             : 
      23             : #include <tools/inetmsg.hxx>
      24             : #include <tools/diagnose_ex.h>
      25             : #include <svl/eitem.hxx>
      26             : #include <svl/stritem.hxx>
      27             : #include <svl/intitem.hxx>
      28             : #include <svtools/svparser.hxx>
      29             : #include <osl/mutex.hxx>
      30             : #include <cppuhelper/exc_hlp.hxx>
      31             : 
      32             : #include <com/sun/star/container/XChild.hpp>
      33             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      34             : #include <com/sun/star/document/XDocumentProperties.hpp>
      35             : #include <com/sun/star/document/UpdateDocMode.hpp>
      36             : #include <com/sun/star/document/MacroExecMode.hpp>
      37             : #include <com/sun/star/document/XScriptInvocationContext.hpp>
      38             : #include <com/sun/star/embed/EmbedStates.hpp>
      39             : #include <com/sun/star/embed/XEmbedPersist.hpp>
      40             : #include <com/sun/star/logging/DocumentIOLogRing.hpp>
      41             : #include <com/sun/star/script/XTypeConverter.hpp>
      42             : #include <com/sun/star/script/FinishEngineEvent.hpp>
      43             : #include <com/sun/star/script/InterruptReason.hpp>
      44             : #include <com/sun/star/script/XEngineListener.hpp>
      45             : #include <com/sun/star/script/XDebugging.hpp>
      46             : #include <com/sun/star/script/XInvocation.hpp>
      47             : #include <com/sun/star/script/ContextInformation.hpp>
      48             : #include <com/sun/star/script/FinishReason.hpp>
      49             : #include <com/sun/star/script/XEngine.hpp>
      50             : #include <com/sun/star/script/InterruptEngineEvent.hpp>
      51             : #include <com/sun/star/script/XLibraryAccess.hpp>
      52             : #include <com/sun/star/script/provider/theMasterScriptProviderFactory.hpp>
      53             : #include <com/sun/star/script/provider/XScript.hpp>
      54             : #include <com/sun/star/script/provider/XScriptProvider.hpp>
      55             : #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
      56             : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      57             : #include <com/sun/star/util/XModifiable.hpp>
      58             : 
      59             : #include <toolkit/helper/vclunohelper.hxx>
      60             : 
      61             : #include <com/sun/star/uno/Reference.h>
      62             : #include <com/sun/star/uno/Any.h>
      63             : #include <com/sun/star/ucb/XContent.hpp>
      64             : #include <com/sun/star/task/ErrorCodeRequest.hpp>
      65             : #include <unotools/securityoptions.hxx>
      66             : 
      67             : #include <comphelper/processfactory.hxx>
      68             : #include <comphelper/string.hxx>
      69             : 
      70             : #include <com/sun/star/security/DocumentDigitalSignatures.hpp>
      71             : #include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
      72             : #include <com/sun/star/task/InteractionClassification.hpp>
      73             : #include <com/sun/star/frame/XModel.hpp>
      74             : 
      75             : #include <basic/sbuno.hxx>
      76             : #include <basic/sbstar.hxx>
      77             : #include <basic/basmgr.hxx>
      78             : #include <vcl/msgbox.hxx>
      79             : #include <basic/sbx.hxx>
      80             : #include <svtools/sfxecode.hxx>
      81             : #include <svtools/ehdl.hxx>
      82             : 
      83             : #include <unotools/pathoptions.hxx>
      84             : #include <unotools/ucbhelper.hxx>
      85             : #include <tools/inetmime.hxx>
      86             : #include <tools/urlobj.hxx>
      87             : #include <svl/inettype.hxx>
      88             : #include <svl/sharecontrolfile.hxx>
      89             : #include <osl/file.hxx>
      90             : #include <rtl/bootstrap.hxx>
      91             : #include <vcl/svapp.hxx>
      92             : #include <framework/interaction.hxx>
      93             : #include <framework/documentundoguard.hxx>
      94             : #include <comphelper/interaction.hxx>
      95             : #include <comphelper/storagehelper.hxx>
      96             : #include <comphelper/documentconstants.hxx>
      97             : 
      98             : #include <sfx2/signaturestate.hxx>
      99             : #include <sfx2/app.hxx>
     100             : #include "appdata.hxx"
     101             : #include <sfx2/request.hxx>
     102             : #include <sfx2/bindings.hxx>
     103             : #include <sfx2/sfxresid.hxx>
     104             : #include <sfx2/docfile.hxx>
     105             : #include <sfx2/docfilt.hxx>
     106             : #include <sfx2/objsh.hxx>
     107             : #include "objshimp.hxx"
     108             : #include <sfx2/event.hxx>
     109             : #include <sfx2/sfx.hrc>
     110             : #include <sfx2/dispatch.hxx>
     111             : #include <sfx2/viewfrm.hxx>
     112             : #include <sfx2/viewsh.hxx>
     113             : #include <sfx2/ctrlitem.hxx>
     114             : #include "arrdecl.hxx"
     115             : #include <sfx2/module.hxx>
     116             : #include <sfx2/docfac.hxx>
     117             : #include "helper.hxx"
     118             : #include "doc.hrc"
     119             : #include "workwin.hxx"
     120             : #include "helpid.hrc"
     121             : #include "../appl/app.hrc"
     122             : #include <sfx2/sfxdlg.hxx>
     123             : #include "appbaslib.hxx"
     124             : #include <openflag.hxx>
     125             : #include <objstor.hxx>
     126             : #include <appopen.hxx>
     127             : 
     128             : #include <boost/scoped_ptr.hpp>
     129             : 
     130             : using namespace ::com::sun::star;
     131             : using namespace ::com::sun::star::uno;
     132             : using namespace ::com::sun::star::ucb;
     133             : using namespace ::com::sun::star::document;
     134             : using namespace ::com::sun::star::frame;
     135             : using namespace ::com::sun::star::script;
     136             : using namespace ::com::sun::star::script::provider;
     137             : using namespace ::com::sun::star::container;
     138             : 
     139             : // class SfxHeaderAttributes_Impl ----------------------------------------
     140             : 
     141        9476 : class SfxHeaderAttributes_Impl : public SvKeyValueIterator
     142             : {
     143             : private:
     144             :     SfxObjectShell* pDoc;
     145             :     SvKeyValueIteratorRef xIter;
     146             :     bool bAlert;
     147             : 
     148             : public:
     149        4740 :     SfxHeaderAttributes_Impl( SfxObjectShell* pSh ) :
     150             :         SvKeyValueIterator(), pDoc( pSh ),
     151             :         xIter( pSh->GetMedium()->GetHeaderAttributes_Impl() ),
     152        4740 :         bAlert( false ) {}
     153             : 
     154          44 :     virtual bool GetFirst( SvKeyValue& rKV ) SAL_OVERRIDE { return xIter->GetFirst( rKV ); }
     155          58 :     virtual bool GetNext( SvKeyValue& rKV ) SAL_OVERRIDE { return xIter->GetNext( rKV ); }
     156             :     virtual void Append( const SvKeyValue& rKV ) SAL_OVERRIDE;
     157             : 
     158           0 :     void ClearForSourceView() { xIter = new SvKeyValueIterator; bAlert = false; }
     159             :     void SetAttributes();
     160             :     void SetAttribute( const SvKeyValue& rKV );
     161             : };
     162             : 
     163             : 
     164             : 
     165             : sal_uInt16 const aTitleMap_Impl[3][2] =
     166             : {
     167             :                                 //  local               remote
     168             :     /*  SFX_TITLE_CAPTION   */  {   SFX_TITLE_FILENAME, SFX_TITLE_TITLE },
     169             :     /*  SFX_TITLE_PICKLIST  */  {   32,                 SFX_TITLE_FULLNAME },
     170             :     /*  SFX_TITLE_HISTORY   */  {   32,                 SFX_TITLE_FULLNAME }
     171             : };
     172             : 
     173             : 
     174             : 
     175           0 : void SfxObjectShell::AbortImport()
     176             : {
     177           0 :     pImp->bIsAbortingImport = true;
     178           0 : }
     179             : 
     180             : 
     181             : 
     182       12376 : bool SfxObjectShell::IsAbortingImport() const
     183             : {
     184       12376 :     return pImp->bIsAbortingImport;
     185             : }
     186             : 
     187             : 
     188             : 
     189             : uno::Reference<document::XDocumentProperties>
     190       12791 : SfxObjectShell::getDocProperties()
     191             : {
     192             :     uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     193       12791 :         GetModel(), uno::UNO_QUERY_THROW);
     194             :     uno::Reference<document::XDocumentProperties> xDocProps(
     195       12791 :         xDPS->getDocumentProperties());
     196             :     DBG_ASSERT(xDocProps.is(),
     197             :         "SfxObjectShell: model has no DocumentProperties");
     198       12791 :     return xDocProps;
     199             : }
     200             : 
     201             : 
     202             : 
     203        1064 : void SfxObjectShell::DoFlushDocInfo()
     204             : {
     205        1064 : }
     206             : 
     207             : 
     208             : 
     209             : // Note: the only thing that calls this is the modification event handler
     210             : // that is installed at the XDocumentProperties
     211       55617 : void SfxObjectShell::FlushDocInfo()
     212             : {
     213       55617 :     if ( IsLoading() )
     214      107965 :         return;
     215             : 
     216        3269 :     SetModified(true);
     217        3269 :     uno::Reference<document::XDocumentProperties> xDocProps(getDocProperties());
     218        3269 :     DoFlushDocInfo(); // call template method
     219        6538 :     OUString url(xDocProps->getAutoloadURL());
     220        3269 :     sal_Int32 delay(xDocProps->getAutoloadSecs());
     221        3269 :     SetAutoLoad( INetURLObject(url), delay * 1000,
     222        9807 :                  (delay > 0) || !url.isEmpty() );
     223             : }
     224             : 
     225             : 
     226             : 
     227        4198 : void SfxObjectShell::SetError( sal_uInt32 lErr, const OUString& aLogMessage )
     228             : {
     229        4198 :     if(pImp->lErr==ERRCODE_NONE)
     230             :     {
     231        3024 :         pImp->lErr=lErr;
     232             : 
     233        3024 :         if( lErr != ERRCODE_NONE && !aLogMessage.isEmpty() )
     234        1450 :             AddLog( aLogMessage );
     235             :     }
     236        4198 : }
     237             : 
     238             : 
     239             : 
     240       15792 : sal_uInt32 SfxObjectShell::GetError() const
     241             : {
     242       15792 :     return ERRCODE_TOERROR(GetErrorCode());
     243             : }
     244             : 
     245             : 
     246             : 
     247       24852 : sal_uInt32 SfxObjectShell::GetErrorCode() const
     248             : {
     249       24852 :     sal_uInt32 lError=pImp->lErr;
     250       24852 :     if(!lError && GetMedium())
     251       23166 :         lError=GetMedium()->GetErrorCode();
     252       24852 :     return lError;
     253             : }
     254             : 
     255             : 
     256             : 
     257        8326 : void SfxObjectShell::ResetError()
     258             : {
     259        8326 :     if( pImp->lErr != ERRCODE_NONE )
     260        1430 :         AddLog( OUString( OSL_LOG_PREFIX "Resetting Error."  ) );
     261             : 
     262        8326 :     pImp->lErr=0;
     263        8326 :     SfxMedium * pMed = GetMedium();
     264        8326 :     if( pMed )
     265        8326 :         pMed->ResetError();
     266        8326 : }
     267             : 
     268             : 
     269             : 
     270       36721 : bool SfxObjectShell::IsTemplate() const
     271             : {
     272       36721 :     return pImp->bIsTemplate;
     273             : }
     274             : 
     275             : 
     276             : 
     277      107525 : void SfxObjectShell::EnableSetModified( bool bEnable )
     278             : {
     279             : #ifdef DBG_UTIL
     280             :     if ( bEnable == pImp->m_bEnableSetModified )
     281             :         DBG_WARNING( "SFX_PERSIST: EnableSetModified 2x called with the same value" );
     282             : #endif
     283      107525 :     pImp->m_bEnableSetModified = bEnable;
     284      107525 : }
     285             : 
     286             : 
     287             : 
     288     2500738 : bool SfxObjectShell::IsEnableSetModified() const
     289             : {
     290     2500738 :     return pImp->m_bEnableSetModified && !IsReadOnly();
     291             : }
     292             : 
     293             : 
     294             : 
     295      405799 : bool SfxObjectShell::IsModified()
     296             : {
     297      405799 :     if ( pImp->m_bIsModified )
     298      361319 :         return true;
     299             : 
     300       44480 :     if ( !pImp->m_xDocStorage.is() || IsReadOnly() )
     301             :     {
     302             :         // if the document still has no storage and is not set to be modified explicitly it is not modified
     303             :         // a readonly document is also not modified
     304             : 
     305        3542 :         return false;
     306             :     }
     307             : 
     308       40938 :     if (pImp->mpObjectContainer)
     309             :     {
     310       18498 :         uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
     311       27180 :         for ( sal_Int32 n=0; n<aNames.getLength(); n++ )
     312             :         {
     313        8834 :             uno::Reference < embed::XEmbeddedObject > xObj = GetEmbeddedObjectContainer().GetEmbeddedObject( aNames[n] );
     314             :             OSL_ENSURE( xObj.is(), "An empty entry in the embedded objects list!\n" );
     315        8834 :             if ( xObj.is() )
     316             :             {
     317             :                 try
     318             :                 {
     319        8834 :                     sal_Int32 nState = xObj->getCurrentState();
     320        8834 :                     if ( nState != embed::EmbedStates::LOADED )
     321             :                     {
     322        6708 :                         uno::Reference< util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
     323        6708 :                         if ( xModifiable.is() && xModifiable->isModified() )
     324         152 :                             return true;
     325             :                     }
     326             :                 }
     327           0 :                 catch( uno::Exception& )
     328             :                 {}
     329             :             }
     330       27028 :         }
     331             :     }
     332             : 
     333       40786 :     return false;
     334             : }
     335             : 
     336             : 
     337             : 
     338      213442 : void SfxObjectShell::SetModified( bool bModifiedP )
     339             : {
     340             : #ifdef DBG_UTIL
     341             :     if ( !bModifiedP && !IsEnableSetModified() )
     342             :         DBG_WARNING( "SFX_PERSIST: SetModified( sal_False ), although IsEnableSetModified() == sal_False" );
     343             : #endif
     344             : 
     345      213442 :     if( !IsEnableSetModified() )
     346      215965 :         return;
     347             : 
     348      210919 :     if( pImp->m_bIsModified != bModifiedP )
     349             :     {
     350       10954 :         pImp->m_bIsModified = bModifiedP;
     351       10954 :         ModifyChanged();
     352             :     }
     353             : }
     354             : 
     355             : 
     356             : 
     357       10954 : void SfxObjectShell::ModifyChanged()
     358             : {
     359       10954 :     if ( pImp->bClosing )
     360             :         // SetModified dispose of the models!
     361       11074 :         return;
     362             : 
     363             : 
     364       10834 :     SfxViewFrame* pViewFrame = SfxViewFrame::Current();
     365       10834 :     if ( pViewFrame )
     366        2735 :         pViewFrame->GetBindings().Invalidate( SID_SAVEDOCS );
     367             : 
     368       10834 :     Invalidate( SID_SIGNATURE );
     369       10834 :     Invalidate( SID_MACRO_SIGNATURE );
     370       10834 :     Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) );    // xmlsec05, signed state might change in title...
     371             : 
     372       10834 :     SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED, GlobalEventConfig::GetEventName(STR_EVENT_MODIFYCHANGED), this ) );
     373             : }
     374             : 
     375             : 
     376             : 
     377      121272 : bool SfxObjectShell::IsReadOnlyUI() const
     378             : 
     379             : /*  [Description]
     380             : 
     381             :     Returns sal_True if the document for the UI is treated as r/o. This is
     382             :     regardless of the actual r/o, which can be checked with <IsReadOnly()>.
     383             : */
     384             : 
     385             : {
     386      121272 :     return pImp->bReadOnlyUI;
     387             : }
     388             : 
     389             : 
     390             : 
     391        6262 : bool SfxObjectShell::IsReadOnlyMedium() const
     392             : 
     393             : /*  [Description]
     394             : 
     395             :     Returns sal_True when the medium is r/o, for instance when opened as r/o.
     396             : */
     397             : 
     398             : {
     399        6262 :     if ( !pMedium )
     400           0 :         return true;
     401        6262 :     return pMedium->IsReadOnly();
     402             : }
     403             : 
     404           0 : bool SfxObjectShell::IsOriginallyReadOnlyMedium() const
     405             : {
     406           0 :     return pMedium == 0 || pMedium->IsOriginallyReadOnly();
     407             : }
     408             : 
     409             : 
     410             : 
     411         654 : void SfxObjectShell::SetReadOnlyUI( bool bReadOnly )
     412             : 
     413             : /*  [Description]
     414             : 
     415             :     Turns the document in an r/o and r/w state respectively without reloading
     416             :     it and without changing the open mode of the medium.
     417             : */
     418             : 
     419             : {
     420         654 :     if ( bReadOnly != pImp->bReadOnlyUI )
     421             :     {
     422         654 :         pImp->bReadOnlyUI = bReadOnly;
     423         654 :         Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
     424             :     }
     425         654 : }
     426             : 
     427             : 
     428             : 
     429           2 : void SfxObjectShell::SetReadOnly()
     430             : {
     431             :     // Let the document be completely readonly, means that the
     432             :     // medium open mode is adjusted accordingly, and the write lock
     433             :     // on the file is removed.
     434             : 
     435           2 :      if ( pMedium && !IsReadOnlyMedium() )
     436             :     {
     437           0 :         bool bWasROUI = IsReadOnly();
     438             : 
     439           0 :         pMedium->UnlockFile( false );
     440             : 
     441             :         // the storage-based mediums are already based on the temporary file
     442             :         // so UnlockFile has already closed the locking stream
     443           0 :         if ( !pMedium->HasStorage_Impl() && IsLoadingFinished() )
     444           0 :             pMedium->CloseInStream();
     445             : 
     446           0 :         pMedium->SetOpenMode( SFX_STREAM_READONLY, true );
     447           0 :         pMedium->GetItemSet()->Put( SfxBoolItem( SID_DOC_READONLY, true ) );
     448             : 
     449           0 :         if ( !bWasROUI )
     450           0 :             Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
     451             :     }
     452           2 : }
     453             : 
     454             : 
     455     1008047 : bool SfxObjectShell::IsReadOnly() const
     456             : {
     457     1008047 :     return pImp->bReadOnlyUI || pMedium == 0;
     458             : }
     459             : 
     460             : 
     461             : 
     462        1603 : bool SfxObjectShell::IsInModalMode() const
     463             : {
     464        1603 :     return pImp->bModalMode || pImp->bRunningMacro;
     465             : }
     466             : 
     467        1564 : bool SfxObjectShell::AcceptStateUpdate() const
     468             : {
     469        1564 :     return !IsInModalMode();
     470             : }
     471             : 
     472             : 
     473             : 
     474           0 : void SfxObjectShell::SetMacroMode_Impl( bool bModal )
     475             : {
     476           0 :     if ( !pImp->bRunningMacro != !bModal )
     477             :     {
     478           0 :         pImp->bRunningMacro = bModal;
     479           0 :         Broadcast( SfxSimpleHint( SFX_HINT_MODECHANGED ) );
     480             :     }
     481           0 : }
     482             : 
     483             : 
     484             : 
     485           0 : void SfxObjectShell::SetModalMode_Impl( bool bModal )
     486             : {
     487             :     // Broadcast only if modified, or otherwise it will possibly go into
     488             :     // an endless loop
     489           0 :     if ( !pImp->bModalMode != !bModal )
     490             :     {
     491             :         // Central count
     492           0 :         sal_uInt16 &rDocModalCount = SfxGetpApp()->Get_Impl()->nDocModalMode;
     493           0 :         if ( bModal )
     494           0 :             ++rDocModalCount;
     495             :         else
     496           0 :             --rDocModalCount;
     497             : 
     498             :         // Switch
     499           0 :         pImp->bModalMode = bModal;
     500           0 :         Broadcast( SfxSimpleHint( SFX_HINT_MODECHANGED ) );
     501             :     }
     502           0 : }
     503             : 
     504             : #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
     505             : 
     506           0 : bool SfxObjectShell::SwitchToShared( bool bShared, bool bSave )
     507             : {
     508           0 :     bool bResult = true;
     509             : 
     510           0 :     if ( bShared != IsDocShared() )
     511             :     {
     512           0 :         OUString aOrigURL = GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
     513             : 
     514           0 :         if ( aOrigURL.isEmpty() && bSave )
     515             :         {
     516             :             // this is a new document, let it be stored before switching to the shared mode;
     517             :             // the storing should be done without shared flag, since it is possible that the
     518             :             // target location does not allow to create sharing control file;
     519             :             // the shared flag will be set later after creation of sharing control file
     520           0 :             SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( this );
     521             : 
     522           0 :             if ( pViewFrame )
     523             :             {
     524             :                 // TODO/LATER: currently the application guards against the reentrance problem
     525           0 :                 const SfxPoolItem* pItem = pViewFrame->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC : SID_SAVEASDOC );
     526           0 :                 const SfxBoolItem* pResult = PTR_CAST( SfxBoolItem, pItem );
     527           0 :                 bResult = ( pResult && pResult->GetValue() );
     528           0 :                 if ( bResult )
     529           0 :                     aOrigURL = GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
     530             :             }
     531             :         }
     532             : 
     533           0 :         bool bOldValue = HasSharedXMLFlagSet();
     534           0 :         SetSharedXMLFlag( bShared );
     535             : 
     536           0 :         bool bRemoveEntryOnError = false;
     537           0 :         if ( bResult && bShared )
     538             :         {
     539             :             try
     540             :             {
     541           0 :                 ::svt::ShareControlFile aControlFile( aOrigURL );
     542           0 :                 aControlFile.InsertOwnEntry();
     543           0 :                 bRemoveEntryOnError = true;
     544             :             }
     545           0 :             catch( uno::Exception& )
     546             :             {
     547           0 :                 bResult = false;
     548             :             }
     549             :         }
     550             : 
     551           0 :         if ( bResult && bSave )
     552             :         {
     553           0 :             SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst( this );
     554             : 
     555           0 :             if ( pViewFrame )
     556             :             {
     557             :                 // TODO/LATER: currently the application guards against the reentrance problem
     558           0 :                 SetModified( true ); // the modified flag has to be set to let the document be stored with the shared flag
     559           0 :                 const SfxPoolItem* pItem = pViewFrame->GetBindings().ExecuteSynchron( HasName() ? SID_SAVEDOC : SID_SAVEASDOC );
     560           0 :                 const SfxBoolItem* pResult = PTR_CAST( SfxBoolItem, pItem );
     561           0 :                 bResult = ( pResult && pResult->GetValue() );
     562             :             }
     563             :         }
     564             : 
     565           0 :         if ( bResult )
     566             :         {
     567             :             // TODO/LATER: Is it possible that the following calls fail?
     568           0 :             if ( bShared )
     569             :             {
     570           0 :                 pImp->m_aSharedFileURL = aOrigURL;
     571           0 :                 GetMedium()->SwitchDocumentToTempFile();
     572             :             }
     573             :             else
     574             :             {
     575           0 :                 OUString aTempFileURL = pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
     576           0 :                 GetMedium()->SwitchDocumentToFile( GetSharedFileURL() );
     577           0 :                 pImp->m_aSharedFileURL = OUString();
     578             : 
     579             :                 // now remove the temporary file the document was based on
     580           0 :                 ::utl::UCBContentHelper::Kill( aTempFileURL );
     581             : 
     582             :                 try
     583             :                 {
     584             :                     // aOrigURL can not be used since it contains an old value
     585           0 :                     ::svt::ShareControlFile aControlFile( GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
     586           0 :                     aControlFile.RemoveFile();
     587             :                 }
     588           0 :                 catch( uno::Exception& )
     589             :                 {
     590           0 :                 }
     591             :             }
     592             :         }
     593             :         else
     594             :         {
     595             :             // the saving has failed!
     596           0 :             if ( bRemoveEntryOnError )
     597             :             {
     598             :                 try
     599             :                 {
     600           0 :                     ::svt::ShareControlFile aControlFile( aOrigURL );
     601           0 :                     aControlFile.RemoveEntry();
     602             :                 }
     603           0 :                 catch( uno::Exception& )
     604             :                 {}
     605             :             }
     606             : 
     607           0 :             SetSharedXMLFlag( bOldValue );
     608           0 :         }
     609             :     }
     610             :     else
     611           0 :         bResult = false; // the second switch to the same mode
     612             : 
     613           0 :     if ( bResult )
     614           0 :         SetTitle( "" );
     615             : 
     616           0 :     return bResult;
     617             : }
     618             : 
     619             : 
     620             : 
     621           0 : void SfxObjectShell::FreeSharedFile()
     622             : {
     623           0 :     if ( pMedium )
     624           0 :         FreeSharedFile( pMedium->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
     625           0 : }
     626             : 
     627             : 
     628           0 : void SfxObjectShell::FreeSharedFile( const OUString& aTempFileURL )
     629             : {
     630           0 :     SetSharedXMLFlag( false );
     631             : 
     632           0 :     if ( IsDocShared() && !aTempFileURL.isEmpty()
     633           0 :       && !::utl::UCBContentHelper::EqualURLs( aTempFileURL, GetSharedFileURL() ) )
     634             :     {
     635           0 :         if ( pImp->m_bAllowShareControlFileClean )
     636             :         {
     637             :             try
     638             :             {
     639           0 :                 ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
     640           0 :                 aControlFile.RemoveEntry();
     641             :             }
     642           0 :             catch( uno::Exception& )
     643             :             {
     644             :             }
     645             :         }
     646             : 
     647             :         // the cleaning is forbidden only once
     648           0 :         pImp->m_bAllowShareControlFileClean = true;
     649             : 
     650             :         // now remove the temporary file the document is based currently on
     651           0 :         ::utl::UCBContentHelper::Kill( aTempFileURL );
     652             : 
     653           0 :         pImp->m_aSharedFileURL = OUString();
     654             :     }
     655           0 : }
     656             : 
     657             : 
     658           0 : void SfxObjectShell::DoNotCleanShareControlFile()
     659             : {
     660           0 :     pImp->m_bAllowShareControlFileClean = false;
     661           0 : }
     662             : 
     663             : 
     664         260 : void SfxObjectShell::SetSharedXMLFlag( bool bFlag ) const
     665             : {
     666         260 :     pImp->m_bSharedXMLFlag = bFlag;
     667         260 : }
     668             : 
     669             : 
     670         632 : bool SfxObjectShell::HasSharedXMLFlagSet() const
     671             : {
     672         632 :     return pImp->m_bSharedXMLFlag;
     673             : }
     674             : 
     675             : #endif
     676             : 
     677       81443 : bool SfxObjectShell::IsDocShared() const
     678             : {
     679             : #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
     680       81443 :     return ( !pImp->m_aSharedFileURL.isEmpty() );
     681             : #else
     682             :     return false;
     683             : #endif
     684             : }
     685             : 
     686             : 
     687             : 
     688           0 : OUString SfxObjectShell::GetSharedFileURL() const
     689             : {
     690             : #if HAVE_FEATURE_MULTIUSER_ENVIRONMENT
     691           0 :     return pImp->m_aSharedFileURL;
     692             : #else
     693             :     return OUString();
     694             : #endif
     695             : }
     696             : 
     697          68 : Size SfxObjectShell::GetFirstPageSize()
     698             : {
     699          68 :     return GetVisArea(ASPECT_THUMBNAIL).GetSize();
     700             : }
     701             : 
     702             : 
     703             : 
     704             : 
     705       10876 : IndexBitSet& SfxObjectShell::GetNoSet_Impl()
     706             : {
     707       10876 :     return pImp->aBitSet;
     708             : }
     709             : 
     710             : 
     711             : // changes the title of the document
     712             : 
     713         612 : void SfxObjectShell::SetTitle
     714             : (
     715             :     const OUString& rTitle                // the new Document Title
     716             : )
     717             : 
     718             : /*  [Description]
     719             : 
     720             :     With this method, the title of the document can be set.
     721             :     This corresponds initially to the full file name. A setting of the
     722             :     title does not affect the file name, but it will be shown in the
     723             :     Caption-Bars of the MDI-window.
     724             : */
     725             : 
     726             : {
     727             : 
     728             :     // Nothing to do?
     729        1840 :     if ( ( ( HasName() && pImp->aTitle == rTitle )
     730        1834 :         || ( !HasName() && GetTitle() == rTitle ) )
     731        1832 :       && !IsDocShared() )
     732        1220 :         return;
     733             : 
     734           4 :     SfxApplication *pSfxApp = SfxGetpApp();
     735             : 
     736             :     // If possible relase the unnamed number.
     737           4 :     if ( pImp->bIsNamedVisible && USHRT_MAX != pImp->nVisualDocumentNumber )
     738             :     {
     739           0 :         pSfxApp->ReleaseIndex(pImp->nVisualDocumentNumber);
     740           0 :         pImp->bIsNamedVisible = false;
     741             :     }
     742             : 
     743             :     // Set Title
     744           4 :     pImp->aTitle = rTitle;
     745             : 
     746             :     // Notification
     747           4 :     if ( GetMedium() )
     748             :     {
     749           4 :         SfxShell::SetName( GetTitle(SFX_TITLE_APINAME) );
     750           4 :         Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
     751             :     }
     752             : }
     753             : 
     754             : 
     755             : 
     756             : #if OSL_DEBUG_LEVEL > 1
     757             : OUString X(const OUString &rRet)
     758             : {
     759             :     if ( rRet.isEmpty() )
     760             :         return OUString( "-empty-" );
     761             :     return rRet;
     762             : }
     763             : #else
     764             : #define X(ret) ret
     765             : #endif
     766             : 
     767             : 
     768       47633 : OUString SfxObjectShell::GetTitle
     769             : (
     770             :     sal_uInt16  nMaxLength      /*  0 (default)
     771             :                                 the title itself, as it is
     772             : 
     773             :                                 1 (==SFX_TITLE_FILENAME)
     774             :                                 provides the logical file name without path
     775             :                                 (under WNT depending on the system settings
     776             :                                 without extension)
     777             : 
     778             :                                 2 (==SFX_TITLE_FULLNAME)
     779             :                                 provides the logical file names with full path
     780             :                                 (remote =>:: com:: sun:: star:: util:: URL)
     781             : 
     782             :                                 3 (==SFX_TITLE_APINAME)
     783             :                                 provides the logical filname without path
     784             :                                 and extension
     785             : 
     786             :                                 4 (==SFX_TITLE_DETECT)
     787             :                                 provides the complete title, if not set yet
     788             :                                 it will be created from DocInfo or the name of
     789             :                                 the medium.
     790             : 
     791             :                                 5 (==SFX_TITLE_CAPTION)
     792             :                                 provides the Title just like MB now in the
     793             :                                 CaptionBar view
     794             : 
     795             :                                 6 (==SFX_TITLE_PICKLIST)
     796             :                                 returns the Title, just like MB now would
     797             :                                 display it in the in the PickList
     798             : 
     799             :                                 7 (==SFX_TITLE_HISTORY)
     800             :                                 returns the Title just like MB now would
     801             :                                 display it in the in the History
     802             : 
     803             :                                 10 bis USHRT_MAX
     804             :                                 provides the 'nMaxLength' of the logical
     805             :                                 file name including the path
     806             :                                 (remote => ::com::sun::star::util::URL)
     807             :                                 */
     808             : ) const
     809             : 
     810             : /*  [Description]
     811             : 
     812             :     Returns the title or logical file name of the document, depending on the
     813             :     'nMaxLength'.
     814             : 
     815             :     If the file name with path is used, the Name shortened by replacing one or
     816             :     more directory names with "...", URLs are currently always returned
     817             :     in complete form.
     818             : */
     819             : 
     820             : {
     821       47633 :     SfxMedium *pMed = GetMedium();
     822       47633 :     if ( IsLoading() )
     823        5276 :         return OUString();
     824             : 
     825             :     // Create Title?
     826       42357 :     if ( SFX_TITLE_DETECT == nMaxLength && pImp->aTitle.isEmpty() )
     827             :     {
     828             :         static bool bRecur = false;
     829        3856 :         if ( bRecur )
     830           0 :             return OUString("-not available-");
     831        3856 :         bRecur = true;
     832             : 
     833        3856 :         OUString aTitle;
     834        3856 :         SfxObjectShell *pThis = (SfxObjectShell*) this;
     835             : 
     836        3856 :         if ( pMed )
     837             :         {
     838        3856 :             SFX_ITEMSET_ARG( pMed->GetItemSet(), pNameItem, SfxStringItem, SID_DOCINFO_TITLE, false );
     839        3856 :             if ( pNameItem )
     840           0 :                 aTitle = pNameItem->GetValue();
     841             :         }
     842             : 
     843        3856 :         if ( aTitle.isEmpty() )
     844        3856 :             aTitle = GetTitle( SFX_TITLE_FILENAME );
     845             : 
     846        3856 :         if ( IsTemplate() )
     847           0 :             pThis->SetTitle( aTitle );
     848        3856 :         bRecur = false;
     849        3856 :         return X(aTitle);
     850             :     }
     851       38501 :     else if (SFX_TITLE_APINAME == nMaxLength )
     852        5636 :         return X(GetAPIName());
     853             : 
     854             :     // Special case templates:
     855       32865 :     if( IsTemplate() && !pImp->aTitle.isEmpty() &&
     856           0 :          ( nMaxLength == SFX_TITLE_CAPTION || nMaxLength == SFX_TITLE_PICKLIST ) )
     857           0 :         return X(pImp->aTitle);
     858             : 
     859             :     // Picklist/Caption is mapped
     860       32865 :     if ( pMed && ( nMaxLength == SFX_TITLE_CAPTION || nMaxLength == SFX_TITLE_PICKLIST ) )
     861             :     {
     862             :         // If a specific title was given at open:
     863             :         // important for URLs: use INET_PROT_FILE for which the set title is not
     864             :         // considered. (See below, analysis of aTitleMap_Impl)
     865        5158 :         SFX_ITEMSET_ARG( pMed->GetItemSet(), pNameItem, SfxStringItem, SID_DOCINFO_TITLE, false );
     866        5158 :         if ( pNameItem )
     867           0 :             return X( pNameItem->GetValue() );
     868             :     }
     869             : 
     870             :     // Still unnamed?
     871             :     DBG_ASSERT( !HasName() || pMed, "HasName() but no Medium?!?" );
     872       32865 :     if ( !HasName() || !pMed )
     873             :     {
     874             :         // Title already set?
     875       18501 :         if ( !pImp->aTitle.isEmpty() )
     876          15 :             return X(pImp->aTitle);
     877             : 
     878             :         // must it be numbered?
     879       18486 :         OUString aNoName(SFX2_RESSTR(STR_NONAME));
     880       18486 :         if (pImp->bIsNamedVisible)
     881             :         {
     882             :             // Append number
     883        6442 :             aNoName += OUString::number(pImp->nVisualDocumentNumber);
     884             :         }
     885             : 
     886             :         // Document called "noname" for the time being
     887       18486 :         return X(aNoName);
     888             :     }
     889             : 
     890       14364 :     const INetURLObject aURL( IsDocShared() ? GetSharedFileURL() : OUString( GetMedium()->GetName() ) );
     891       14364 :     if ( nMaxLength > SFX_TITLE_CAPTION && nMaxLength <= SFX_TITLE_HISTORY )
     892             :     {
     893             :         sal_uInt16 nRemote;
     894        5158 :         if( !pMed || aURL.GetProtocol() == INET_PROT_FILE )
     895        5158 :             nRemote = 0;
     896             :         else
     897           0 :             nRemote = 1;
     898        5158 :         nMaxLength = aTitleMap_Impl[nMaxLength-SFX_TITLE_CAPTION][nRemote];
     899             :     }
     900             : 
     901             :     // Local file?
     902       14364 :     if ( aURL.GetProtocol() == INET_PROT_FILE )
     903             :     {
     904       14360 :         OUString aName( aURL.HasMark() ? INetURLObject( aURL.GetURLNoMark() ).PathToFileName() : aURL.PathToFileName() );
     905       14360 :         if ( nMaxLength == SFX_TITLE_FULLNAME )
     906          34 :             return X( aName );
     907       14326 :         else if ( nMaxLength == SFX_TITLE_FILENAME )
     908           0 :             return X( aURL.getName( INetURLObject::LAST_SEGMENT,
     909             :                 true, INetURLObject::DECODE_WITH_CHARSET ) );
     910       14326 :         else if ( pImp->aTitle.isEmpty() )
     911        9372 :             pImp->aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT,
     912       19012 :                                          true, INetURLObject::DECODE_WITH_CHARSET );
     913             :     }
     914             :     else
     915             :     {
     916           4 :         if ( nMaxLength >= SFX_TITLE_MAXLEN )
     917             :         {
     918           0 :             OUString aComplete( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
     919           0 :             if( aComplete.getLength() > nMaxLength )
     920             :             {
     921           0 :                 OUString aRet( "..." );
     922           0 :                 aRet += aComplete.copy( aComplete.getLength() - nMaxLength + 3, nMaxLength - 3 );
     923           0 :                 return X( aRet );
     924             :             }
     925             :             else
     926           0 :                 return X( aComplete );
     927             :         }
     928           4 :         else if ( nMaxLength == SFX_TITLE_FILENAME )
     929             :         {
     930           0 :             OUString aName( aURL.GetBase() );
     931           0 :             aName = INetURLObject::decode( aName, '%', INetURLObject::DECODE_WITH_CHARSET );
     932           0 :             if( aName.isEmpty() )
     933           0 :                 aName = aURL.GetURLNoPass();
     934           0 :             return X(aName);
     935             :         }
     936           4 :         else if ( nMaxLength == SFX_TITLE_FULLNAME )
     937           0 :             return X(aURL.GetMainURL( INetURLObject::DECODE_TO_IURI ));
     938             : 
     939             :         // Generate Title from file name if possible
     940           4 :         if ( pImp->aTitle.isEmpty() )
     941           4 :             pImp->aTitle = aURL.GetBase();
     942             : 
     943             :         // workaround for the case when the name can not be retrieved from URL by INetURLObject
     944           4 :         if ( pImp->aTitle.isEmpty() )
     945           4 :             pImp->aTitle = aURL.GetMainURL( INetURLObject::DECODE_WITH_CHARSET );
     946             :     }
     947             : 
     948             :     // Complete Title
     949       14330 :     return X(pImp->aTitle);
     950             : }
     951             : 
     952             : 
     953             : 
     954          88 : void SfxObjectShell::InvalidateName()
     955             : 
     956             : /*  [Description]
     957             : 
     958             :     Returns the title of the new document, DocInfo-Title or
     959             :     File name. Is required for loading from template or SaveAs.
     960             : */
     961             : 
     962             : {
     963          88 :     pImp->aTitle = "";
     964          88 :     SetName( GetTitle( SFX_TITLE_APINAME ) );
     965             : 
     966          88 :     Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
     967          88 : }
     968             : 
     969             : 
     970             : 
     971        5438 : void SfxObjectShell::SetNamedVisibility_Impl()
     972             : {
     973        5438 :     if ( !pImp->bIsNamedVisible )
     974             :     {
     975        5436 :         pImp->bIsNamedVisible = true;
     976        5436 :         if ( !HasName() && USHRT_MAX == pImp->nVisualDocumentNumber && pImp->aTitle.isEmpty() )
     977             :         {
     978        1468 :             pImp->nVisualDocumentNumber = SfxGetpApp()->GetFreeIndex();
     979        1468 :             Broadcast( SfxSimpleHint(SFX_HINT_TITLECHANGED) );
     980             :         }
     981             :     }
     982             : 
     983        5438 :     SetName( GetTitle(SFX_TITLE_APINAME) );
     984        5438 : }
     985             : 
     986          68 : void SfxObjectShell::SetNoName()
     987             : {
     988          68 :     bHasName = false;
     989          68 :     GetModel()->attachResource( OUString(), GetModel()->getArgs() );
     990          68 : }
     991             : 
     992             : 
     993             : 
     994       33314 : SfxProgress* SfxObjectShell::GetProgress() const
     995             : {
     996       33314 :     return pImp->pProgress;
     997             : }
     998             : 
     999             : 
    1000             : 
    1001       10712 : void SfxObjectShell::SetProgress_Impl
    1002             : (
    1003             :     SfxProgress *pProgress      /* to started <SfxProgress> or 0,
    1004             :                                    if the progress is to be reset */
    1005             : )
    1006             : 
    1007             : /*  [Description]
    1008             : 
    1009             :     Internal method to set or reset the Progress modes for
    1010             :     SfxObjectShell.
    1011             : */
    1012             : 
    1013             : {
    1014             :     DBG_ASSERT( ( !pImp->pProgress && pProgress ) ||
    1015             :                 ( pImp->pProgress && !pProgress ),
    1016             :                 "Progress activation/deacitivation mismatch" );
    1017       10712 :     pImp->pProgress = pProgress;
    1018       10712 : }
    1019             : 
    1020             : 
    1021             : 
    1022       10200 : void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame* pFrame )
    1023             : {
    1024       10200 :     SfxApplication* pSfxApp = SfxGetpApp();
    1025       10200 :     if ( !pSfxApp->IsDowning() && !IsLoading() && pFrame && !pFrame->GetFrame().IsClosing_Impl() )
    1026             :     {
    1027        5438 :         SFX_ITEMSET_ARG( pMedium->GetItemSet(), pHiddenItem, SfxBoolItem, SID_HIDDEN, false );
    1028        5438 :         if ( !pHiddenItem || !pHiddenItem->GetValue() )
    1029             :         {
    1030        5438 :             sal_uInt16 nId = pImp->nEventId;
    1031        5438 :             pImp->nEventId = 0;
    1032        5438 :             if ( nId == SFX_EVENT_OPENDOC )
    1033        3968 :                 pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC), this, pFrame->GetFrame().GetController() ), false);
    1034        1470 :             else if (nId == SFX_EVENT_CREATEDOC )
    1035        1468 :                 pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC), this, pFrame->GetFrame().GetController() ), false);
    1036             :         }
    1037             :     }
    1038       10200 : }
    1039             : 
    1040             : 
    1041             : 
    1042        6960 : void SfxObjectShell::SetActivateEvent_Impl(sal_uInt16 nId )
    1043             : {
    1044        6960 :     if ( GetFactory().GetFlags() & SFXOBJECTSHELL_HASOPENDOC )
    1045        6960 :         pImp->nEventId = nId;
    1046        6960 : }
    1047             : 
    1048           0 : void SfxObjectShell::PrepareReload( )
    1049             : /*  [Description]
    1050             : 
    1051             :     Is called before the Reload and gives the opportunity to clear any caches.
    1052             : */
    1053             : {
    1054           0 : }
    1055             : 
    1056           0 : bool SfxObjectShell::IsAutoLoadLocked() const
    1057             : 
    1058             : /* Returns whether an Autoload is allowed to be executed. Before the
    1059             :    surrounding FrameSet of the AutoLoad is also taken into account as well.
    1060             : */
    1061             : 
    1062             : {
    1063           0 :     return !IsReadOnly() || pImp->nAutoLoadLocks > 0;
    1064             : }
    1065             : 
    1066             : 
    1067           2 : void SfxObjectShell::BreakMacroSign_Impl( bool bBreakMacroSign )
    1068             : {
    1069           2 :     pImp->m_bMacroSignBroken = bBreakMacroSign;
    1070           2 : }
    1071             : 
    1072             : 
    1073       10244 : void SfxObjectShell::CheckSecurityOnLoading_Impl()
    1074             : {
    1075       10244 :     uno::Reference< task::XInteractionHandler > xInteraction;
    1076       10244 :     if ( GetMedium() )
    1077       10244 :         xInteraction = GetMedium()->GetInteractionHandler();
    1078             : 
    1079             :     // check if there is a broken signature...
    1080       10244 :     CheckForBrokenDocSignatures_Impl( xInteraction );
    1081             : 
    1082       10244 :     CheckEncryption_Impl( xInteraction );
    1083             : 
    1084             :     // check macro security
    1085       10244 :     pImp->aMacroMode.checkMacrosOnLoading( xInteraction );
    1086       10244 : }
    1087             : 
    1088             : 
    1089       10398 : void SfxObjectShell::CheckEncryption_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
    1090             : {
    1091       10398 :     OUString aVersion;
    1092       10398 :     bool bIsEncrypted = false;
    1093       10398 :     bool bHasNonEncrypted = false;
    1094             : 
    1095             :     try
    1096             :     {
    1097       10510 :         uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
    1098       10286 :         xPropSet->getPropertyValue("Version") >>= aVersion;
    1099       10290 :         xPropSet->getPropertyValue("HasEncryptedEntries") >>= bIsEncrypted;
    1100       10282 :         xPropSet->getPropertyValue("HasNonEncryptedEntries") >>= bHasNonEncrypted;
    1101             :     }
    1102         116 :     catch( uno::Exception& )
    1103             :     {
    1104             :     }
    1105             : 
    1106       10398 :     if ( aVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
    1107             :     {
    1108             :         // this is ODF1.2 or later
    1109       10268 :         if ( bIsEncrypted && bHasNonEncrypted )
    1110             :         {
    1111           0 :             if ( !pImp->m_bIncomplEncrWarnShown )
    1112             :             {
    1113             :                 // this is an encrypted document with nonencrypted streams inside, show the warning
    1114           0 :                 ::com::sun::star::task::ErrorCodeRequest aErrorCode;
    1115           0 :                 aErrorCode.ErrCode = ERRCODE_SFX_INCOMPLETE_ENCRYPTION;
    1116             : 
    1117           0 :                 SfxMedium::CallApproveHandler( xHandler, uno::makeAny( aErrorCode ), false );
    1118           0 :                 pImp->m_bIncomplEncrWarnShown = true;
    1119             :             }
    1120             : 
    1121             :             // broken signatures imply no macro execution at all
    1122           0 :             pImp->aMacroMode.disallowMacroExecution();
    1123             :         }
    1124       10398 :     }
    1125       10398 : }
    1126             : 
    1127             : 
    1128       10398 : void SfxObjectShell::CheckForBrokenDocSignatures_Impl( const uno::Reference< task::XInteractionHandler >& xHandler )
    1129             : {
    1130       10398 :     sal_Int16 nSignatureState = GetDocumentSignatureState();
    1131       10398 :     bool bSignatureBroken = ( nSignatureState == SIGNATURESTATE_SIGNATURES_BROKEN );
    1132       10398 :     if ( !bSignatureBroken )
    1133       20796 :         return;
    1134             : 
    1135           0 :     pImp->showBrokenSignatureWarning( xHandler );
    1136             : 
    1137             :     // broken signatures imply no macro execution at all
    1138           0 :     pImp->aMacroMode.disallowMacroExecution();
    1139             : }
    1140             : 
    1141             : 
    1142        8027 : void SfxObjectShell::SetAutoLoad(
    1143             :     const INetURLObject& rUrl, sal_uInt32 nTime, bool bReload )
    1144             : {
    1145        8027 :     if ( pImp->pReloadTimer )
    1146           0 :         DELETEZ(pImp->pReloadTimer);
    1147        8027 :     if ( bReload )
    1148             :     {
    1149             :         pImp->pReloadTimer = new AutoReloadTimer_Impl(
    1150             :                                 rUrl.GetMainURL( INetURLObject::DECODE_TO_IURI ),
    1151           0 :                                 nTime, this );
    1152           0 :         pImp->pReloadTimer->Start();
    1153             :     }
    1154        8027 : }
    1155             : 
    1156        5506 : bool SfxObjectShell::IsLoadingFinished() const
    1157             : {
    1158        5506 :     return ( pImp->nLoadedFlags == SFX_LOADED_ALL );
    1159             : }
    1160             : 
    1161        5186 : void SfxObjectShell::InitOwnModel_Impl()
    1162             : {
    1163        5186 :     if ( !pImp->bModelInitialized )
    1164             :     {
    1165        4746 :         SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, false);
    1166        4746 :         if ( pSalvageItem )
    1167             :         {
    1168           0 :             pImp->aTempName = pMedium->GetPhysicalName();
    1169           0 :             pMedium->GetItemSet()->ClearItem( SID_DOC_SALVAGE );
    1170           0 :             pMedium->GetItemSet()->ClearItem( SID_FILE_NAME );
    1171           0 :             pMedium->GetItemSet()->Put( SfxStringItem( SID_FILE_NAME, pMedium->GetOrigURL() ) );
    1172             :         }
    1173             :         else
    1174             :         {
    1175        4746 :             pMedium->GetItemSet()->ClearItem( SID_PROGRESS_STATUSBAR_CONTROL );
    1176        4746 :             pMedium->GetItemSet()->ClearItem( SID_DOCUMENT );
    1177             :         }
    1178             : 
    1179        4746 :         pMedium->GetItemSet()->ClearItem( SID_REFERER );
    1180        4746 :         uno::Reference< frame::XModel >  xModel ( GetModel(), uno::UNO_QUERY );
    1181        4746 :         if ( xModel.is() )
    1182             :         {
    1183        4746 :             OUString aURL = GetMedium()->GetOrigURL();
    1184        4746 :             SfxItemSet *pSet = GetMedium()->GetItemSet();
    1185        4746 :             if ( !GetMedium()->IsReadOnly() )
    1186        4074 :                 pSet->ClearItem( SID_INPUTSTREAM );
    1187        9492 :             uno::Sequence< beans::PropertyValue > aArgs;
    1188        4746 :             TransformItems( SID_OPENDOC, *pSet, aArgs );
    1189        4746 :             xModel->attachResource( aURL, aArgs );
    1190        9492 :             impl_addToModelCollection(xModel);
    1191             :         }
    1192             : 
    1193        4746 :         pImp->bModelInitialized = true;
    1194             :     }
    1195        5186 : }
    1196             : 
    1197        4762 : void SfxObjectShell::FinishedLoading( sal_uInt16 nFlags )
    1198             : {
    1199        4762 :     bool bSetModifiedTRUE = false;
    1200        4762 :     SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, false );
    1201        4762 :     if( ( nFlags & SFX_LOADED_MAINDOCUMENT ) && !(pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT )
    1202        4740 :         && !(pImp->nFlagsInProgress & SFX_LOADED_MAINDOCUMENT ))
    1203             :     {
    1204        4740 :         pImp->nFlagsInProgress |= SFX_LOADED_MAINDOCUMENT;
    1205        4740 :         static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())->SetAttributes();
    1206        4740 :         pImp->bImportDone = true;
    1207        4740 :         if( !IsAbortingImport() )
    1208        4740 :             PositionView_Impl();
    1209             : 
    1210        4740 :         if ( ( GetModifyPasswordHash() || GetModifyPasswordInfo().getLength() ) && !IsModifyPasswordEntered() )
    1211           2 :             SetReadOnly();
    1212             : 
    1213             :         // Salvage
    1214        4740 :         if ( pSalvageItem )
    1215           0 :             bSetModifiedTRUE = true;
    1216             : 
    1217        4740 :         if ( !IsEnableSetModified() )
    1218        4740 :             EnableSetModified( true );
    1219             : 
    1220        4740 :         if( !bSetModifiedTRUE && IsEnableSetModified() )
    1221        4726 :             SetModified( false );
    1222             : 
    1223        4740 :         CheckSecurityOnLoading_Impl();
    1224             : 
    1225        4740 :         bHasName = true; // the document is loaded, so the name should already available
    1226        4740 :         GetTitle( SFX_TITLE_DETECT );
    1227        4740 :         InitOwnModel_Impl();
    1228        4740 :         pImp->nFlagsInProgress &= ~SFX_LOADED_MAINDOCUMENT;
    1229             :     }
    1230             : 
    1231        4762 :     if( ( nFlags & SFX_LOADED_IMAGES ) && !(pImp->nLoadedFlags & SFX_LOADED_IMAGES )
    1232        4726 :         && !(pImp->nFlagsInProgress & SFX_LOADED_IMAGES ))
    1233             :     {
    1234        4726 :         pImp->nFlagsInProgress |= SFX_LOADED_IMAGES;
    1235             :         uno::Reference<document::XDocumentProperties> xDocProps(
    1236        4726 :             getDocProperties());
    1237        9452 :         OUString url(xDocProps->getAutoloadURL());
    1238        4726 :         sal_Int32 delay(xDocProps->getAutoloadSecs());
    1239        4726 :         SetAutoLoad( INetURLObject(url), delay * 1000,
    1240        9452 :                      (delay > 0) || !url.isEmpty() );
    1241        4726 :         if( !bSetModifiedTRUE && IsEnableSetModified() )
    1242        4726 :             SetModified( false );
    1243        4726 :         Invalidate( SID_SAVEASDOC );
    1244        9452 :         pImp->nFlagsInProgress &= ~SFX_LOADED_IMAGES;
    1245             :     }
    1246             : 
    1247        4762 :     pImp->nLoadedFlags |= nFlags;
    1248             : 
    1249        4762 :     if ( !pImp->nFlagsInProgress )
    1250             :     {
    1251             :         // in case of reentrance calls the first called FinishedLoading() call on the stack
    1252             :         // should do the notification, in result the notification is done when all the FinishedLoading() calls are finished
    1253             : 
    1254        4762 :         if ( bSetModifiedTRUE )
    1255           0 :             SetModified( true );
    1256             :         else
    1257        4762 :             SetModified( false );
    1258             : 
    1259        4762 :         if ( (pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT ) && (pImp->nLoadedFlags & SFX_LOADED_IMAGES ) )
    1260             :         {
    1261        4748 :             SFX_ITEMSET_ARG( pMedium->GetItemSet(), pTemplateItem, SfxBoolItem, SID_TEMPLATE, false);
    1262        4748 :             bool bTemplate = pTemplateItem && pTemplateItem->GetValue();
    1263             : 
    1264             :             // closing the streams on loading should be under control of SFX!
    1265             :             DBG_ASSERT( pMedium->IsOpen(), "Don't close the medium when loading documents!" );
    1266             : 
    1267        4748 :             if ( bTemplate )
    1268             :             {
    1269          68 :                 TemplateDisconnectionAfterLoad();
    1270             :             }
    1271             :             else
    1272             :             {
    1273             :                 // if a readonly medium has storage then it's stream is already based on temporary file
    1274        4680 :                 if( !(pMedium->GetOpenMode() & STREAM_WRITE) && !pMedium->HasStorage_Impl() )
    1275             :                     // don't lock file opened read only
    1276         318 :                     pMedium->CloseInStream();
    1277             :             }
    1278             :         }
    1279             : 
    1280        4762 :         SetInitialized_Impl( false );
    1281             : 
    1282             :         // Title is not available until loading has finished
    1283        4762 :         Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) );
    1284        4762 :         if ( pImp->nEventId )
    1285        4762 :             PostActivateEvent_Impl(SfxViewFrame::GetFirst(this));
    1286             :     }
    1287        4762 : }
    1288             : 
    1289             : 
    1290          68 : void SfxObjectShell::TemplateDisconnectionAfterLoad()
    1291             : {
    1292             :     // document is created from a template
    1293             :     //TODO/LATER: should the templates always be XML docs!
    1294             : 
    1295          68 :     SfxMedium* pTmpMedium = pMedium;
    1296          68 :     if ( pTmpMedium )
    1297             :     {
    1298          68 :         OUString aName( pTmpMedium->GetName() );
    1299          68 :         SFX_ITEMSET_ARG( pTmpMedium->GetItemSet(), pTemplNamItem, SfxStringItem, SID_TEMPLATE_NAME, false);
    1300         136 :         OUString aTemplateName;
    1301          68 :         if ( pTemplNamItem )
    1302           0 :             aTemplateName = pTemplNamItem->GetValue();
    1303             :         else
    1304             :         {
    1305             :             // !TODO/LATER: what's this?!
    1306             :             // Interactiv ( DClick, Contextmenu ) no long name is included
    1307          68 :             aTemplateName = getDocProperties()->getTitle();
    1308          68 :             if ( aTemplateName.isEmpty() )
    1309             :             {
    1310          62 :                 INetURLObject aURL( aName );
    1311          62 :                 aURL.CutExtension();
    1312          62 :                 aTemplateName = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
    1313             :             }
    1314             :         }
    1315             : 
    1316             :         // set medium to noname
    1317          68 :         pTmpMedium->SetName( OUString(), true );
    1318          68 :         pTmpMedium->Init_Impl();
    1319             : 
    1320             :         // drop resource
    1321          68 :         SetNoName();
    1322          68 :         InvalidateName();
    1323             : 
    1324          68 :         if( IsPackageStorageFormat_Impl( *pTmpMedium ) )
    1325             :         {
    1326             :             // untitled document must be based on temporary storage
    1327             :             // the medium should not dispose the storage in this case
    1328           8 :             uno::Reference < embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
    1329           8 :             GetStorage()->copyToStorage( xTmpStor );
    1330             : 
    1331             :             // the medium should disconnect from the original location
    1332             :             // the storage should not be disposed since the document is still
    1333             :             // based on it, but in DoSaveCompleted it will be disposed
    1334           8 :             pTmpMedium->CanDisposeStorage_Impl( false );
    1335           8 :             pTmpMedium->Close();
    1336             : 
    1337             :             // setting the new storage the medium will be based on
    1338           8 :             pTmpMedium->SetStorage_Impl( xTmpStor );
    1339             : 
    1340           8 :             pMedium = 0;
    1341           8 :             bool ok = DoSaveCompleted( pTmpMedium );
    1342             :             assert(pMedium != 0);
    1343           8 :             if( ok )
    1344             :             {
    1345           8 :                 SFX_ITEMSET_ARG( pMedium->GetItemSet(), pSalvageItem, SfxStringItem, SID_DOC_SALVAGE, false );
    1346           8 :                 bool bSalvage = pSalvageItem ? true : false;
    1347             : 
    1348           8 :                 if ( !bSalvage )
    1349             :                 {
    1350             :                     // some further initializations for templates
    1351           8 :                     SetTemplate_Impl( aName, aTemplateName, this );
    1352             :                 }
    1353             : 
    1354             :                 // the medium should not dispose the storage, DoSaveCompleted() has let it to do so
    1355           8 :                 pTmpMedium->CanDisposeStorage_Impl( false );
    1356             :             }
    1357             :             else
    1358             :             {
    1359           0 :                 SetError( ERRCODE_IO_GENERAL, OUString( OSL_LOG_PREFIX  ) );
    1360           8 :             }
    1361             :         }
    1362             :         else
    1363             :         {
    1364             :             // some further initializations for templates
    1365          60 :             SetTemplate_Impl( aName, aTemplateName, this );
    1366          60 :             pTmpMedium->CreateTempFile( true );
    1367             :         }
    1368             : 
    1369             :         // templates are never readonly
    1370          68 :         pTmpMedium->GetItemSet()->ClearItem( SID_DOC_READONLY );
    1371          68 :         pTmpMedium->SetOpenMode( SFX_STREAM_READWRITE, true );
    1372             : 
    1373             :         // notifications about possible changes in readonly state and document info
    1374          68 :         Broadcast( SfxSimpleHint(SFX_HINT_MODECHANGED) );
    1375             : 
    1376             :         // created untitled document can't be modified
    1377         136 :         SetModified( false );
    1378             :     }
    1379          68 : }
    1380             : 
    1381             : 
    1382             : 
    1383        4740 : void SfxObjectShell::PositionView_Impl()
    1384             : {
    1385        4740 :     MarkData_Impl *pMark = Get_Impl()->pMarkData;
    1386        4740 :     if( pMark )
    1387             :     {
    1388           0 :         SfxViewShell* pSh = pMark->pFrame->GetViewShell();
    1389           0 :         if( !pMark->aUserData.isEmpty() )
    1390           0 :             pSh->ReadUserData( pMark->aUserData, true );
    1391           0 :         else if( !pMark->aMark.isEmpty() )
    1392           0 :             pSh->JumpToMark( pMark->aMark );
    1393           0 :         DELETEZ( Get_Impl()->pMarkData );
    1394             :     }
    1395        4740 : }
    1396             : 
    1397             : 
    1398             : 
    1399      114300 : bool SfxObjectShell::IsLoading() const
    1400             : /*  [Description]
    1401             : 
    1402             :     Has FinishedLoading been called?
    1403             : */
    1404             : {
    1405      114300 :     return !( pImp->nLoadedFlags & SFX_LOADED_MAINDOCUMENT );
    1406             : }
    1407             : 
    1408             : 
    1409             : 
    1410        5265 : void SfxObjectShell::CancelTransfers()
    1411             : /*  [Description]
    1412             : 
    1413             :     Here can Transfers get canceled, which were not regestered
    1414             :     by RegisterTransfer.
    1415             : */
    1416             : {
    1417        5265 :     if( ( pImp->nLoadedFlags & SFX_LOADED_ALL ) != SFX_LOADED_ALL )
    1418             :     {
    1419           0 :         AbortImport();
    1420           0 :         if( IsLoading() )
    1421           0 :             FinishedLoading( SFX_LOADED_ALL );
    1422             :     }
    1423        5265 : }
    1424             : 
    1425             : 
    1426             : 
    1427           0 : AutoReloadTimer_Impl::AutoReloadTimer_Impl(
    1428             :     const OUString& rURL, sal_uInt32 nTime, SfxObjectShell* pSh )
    1429           0 :     : aUrl( rURL ), pObjSh( pSh )
    1430             : {
    1431           0 :     SetTimeout( nTime );
    1432           0 : }
    1433             : 
    1434             : 
    1435             : 
    1436           0 : void AutoReloadTimer_Impl::Timeout()
    1437             : {
    1438           0 :     SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pObjSh );
    1439             : 
    1440           0 :     if ( pFrame )
    1441             :     {
    1442             :         // Not possible/meanigfull at the moment?
    1443           0 :         if ( !pObjSh->CanReload_Impl() || pObjSh->IsAutoLoadLocked() || Application::IsUICaptured() )
    1444             :         {
    1445             :             // Allow a retry
    1446           0 :             Start();
    1447           0 :             return;
    1448             :         }
    1449             : 
    1450           0 :         SfxAllItemSet aSet( SfxGetpApp()->GetPool() );
    1451           0 :         aSet.Put( SfxBoolItem( SID_AUTOLOAD, true ) );
    1452           0 :         if ( !aUrl.isEmpty() )
    1453           0 :             aSet.Put(  SfxStringItem( SID_FILE_NAME, aUrl ) );
    1454           0 :         if (pObjSh->HasName()) {
    1455             :             aSet.Put(
    1456           0 :                 SfxStringItem(SID_REFERER, pObjSh->GetMedium()->GetName()));
    1457             :         }
    1458           0 :         SfxRequest aReq( SID_RELOAD, SfxCallMode::SLOT, aSet );
    1459           0 :         pObjSh->Get_Impl()->pReloadTimer = 0;
    1460           0 :         delete this;
    1461           0 :         pFrame->ExecReload_Impl( aReq );
    1462           0 :         return;
    1463             :     }
    1464             : 
    1465           0 :     pObjSh->Get_Impl()->pReloadTimer = 0;
    1466           0 :     delete this;
    1467             : }
    1468             : 
    1469      765813 : SfxModule* SfxObjectShell::GetModule() const
    1470             : {
    1471      765813 :     return GetFactory().GetModule();
    1472             : }
    1473             : 
    1474           0 : ErrCode SfxObjectShell::CallBasic( const OUString& rMacro,
    1475             :     const OUString& rBasic, SbxArray* pArgs,
    1476             :     SbxValue* pRet )
    1477             : {
    1478           0 :     SfxApplication* pApp = SfxGetpApp();
    1479           0 :     if( pApp->GetName() != rBasic )
    1480             :     {
    1481           0 :         if ( !AdjustMacroMode( OUString() ) )
    1482           0 :             return ERRCODE_IO_ACCESSDENIED;
    1483             :     }
    1484             : 
    1485           0 :     BasicManager *pMgr = GetBasicManager();
    1486           0 :     if( pApp->GetName() == rBasic )
    1487           0 :         pMgr = pApp->GetBasicManager();
    1488           0 :     ErrCode nRet = SfxApplication::CallBasic( rMacro, pMgr, pArgs, pRet );
    1489           0 :     return nRet;
    1490             : }
    1491             : 
    1492             : namespace
    1493             : {
    1494         146 :     static bool lcl_isScriptAccessAllowed_nothrow( const Reference< XInterface >& _rxScriptContext )
    1495             :     {
    1496             :         try
    1497             :         {
    1498         146 :             Reference< XEmbeddedScripts > xScripts( _rxScriptContext, UNO_QUERY );
    1499         146 :             if ( !xScripts.is() )
    1500             :             {
    1501           0 :                 Reference< XScriptInvocationContext > xContext( _rxScriptContext, UNO_QUERY_THROW );
    1502           0 :                 xScripts.set( xContext->getScriptContainer(), UNO_SET_THROW );
    1503             :             }
    1504             : 
    1505         146 :             return xScripts->getAllowMacroExecution();
    1506             :         }
    1507           0 :         catch( const Exception& )
    1508             :         {
    1509             :             DBG_UNHANDLED_EXCEPTION();
    1510             :         }
    1511           0 :         return false;
    1512             :     }
    1513             : }
    1514             : 
    1515         146 : ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const OUString& _rScriptURL,
    1516             :     const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError, const ::com::sun::star::uno::Any* pCaller )
    1517             : {
    1518             :     OSL_TRACE( "in CallXScript" );
    1519         146 :     ErrCode nErr = ERRCODE_NONE;
    1520             : 
    1521         146 :     bool bIsDocumentScript = ( _rScriptURL.indexOf( "location=document" ) >= 0 );
    1522             :         // TODO: we should parse the URL, and check whether there is a parameter with this name.
    1523             :         // Otherwise, we might find too much.
    1524         146 :     if ( bIsDocumentScript && !lcl_isScriptAccessAllowed_nothrow( _rxScriptContext ) )
    1525           0 :         return ERRCODE_IO_ACCESSDENIED;
    1526             : 
    1527         146 :     bool bCaughtException = false;
    1528         146 :     Any aException;
    1529             :     try
    1530             :     {
    1531             :         // obtain/create a script provider
    1532         146 :         Reference< provider::XScriptProvider > xScriptProvider;
    1533         292 :         Reference< provider::XScriptProviderSupplier > xSPS( _rxScriptContext, UNO_QUERY );
    1534         146 :         if ( xSPS.is() )
    1535         146 :             xScriptProvider.set( xSPS->getScriptProvider() );
    1536             : 
    1537         146 :         if ( !xScriptProvider.is() )
    1538             :         {
    1539             :             Reference< provider::XScriptProviderFactory > xScriptProviderFactory =
    1540           0 :                 provider::theMasterScriptProviderFactory::get( ::comphelper::getProcessComponentContext() );
    1541           0 :             xScriptProvider.set( xScriptProviderFactory->createScriptProvider( makeAny( _rxScriptContext ) ), UNO_SET_THROW );
    1542             :         }
    1543             : 
    1544             :         // ry to protect the invocation context's undo manager (if present), just in case the script tampers with it
    1545         292 :         ::framework::DocumentUndoGuard aUndoGuard( _rxScriptContext.get() );
    1546             : 
    1547             :         // obtain the script, and execute it
    1548         292 :         Reference< provider::XScript > xScript( xScriptProvider->getScript( _rScriptURL ), UNO_QUERY_THROW );
    1549         146 :         if ( pCaller && pCaller->hasValue() )
    1550             :         {
    1551           2 :             Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY );
    1552           2 :             if ( xProps.is() )
    1553             :             {
    1554           2 :                 Sequence< uno::Any > aArgs( 1 );
    1555           2 :                 aArgs[ 0 ] = *pCaller;
    1556           2 :                 xProps->setPropertyValue("Caller", uno::makeAny( aArgs ) );
    1557           2 :             }
    1558             :         }
    1559         292 :         aRet = xScript->invoke( aParams, aOutParamIndex, aOutParam );
    1560             :     }
    1561           0 :     catch ( const uno::Exception& )
    1562             :     {
    1563           0 :         aException = ::cppu::getCaughtException();
    1564           0 :         bCaughtException = true;
    1565           0 :         nErr = ERRCODE_BASIC_INTERNAL_ERROR;
    1566             :     }
    1567             : 
    1568         146 :     if ( bCaughtException && bRaiseError )
    1569             :     {
    1570           0 :         boost::scoped_ptr< VclAbstractDialog > pScriptErrDlg;
    1571           0 :         SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    1572           0 :         if ( pFact )
    1573           0 :             pScriptErrDlg.reset( pFact->CreateScriptErrorDialog( NULL, aException ) );
    1574             :         OSL_ENSURE( pScriptErrDlg.get(), "SfxObjectShell::CallXScript: no script error dialog!" );
    1575             : 
    1576           0 :         if ( pScriptErrDlg.get() )
    1577           0 :             pScriptErrDlg->Execute();
    1578             :     }
    1579             : 
    1580             :     OSL_TRACE( "leaving CallXScript" );
    1581         146 :     return nErr;
    1582             : }
    1583             : 
    1584             : // perhaps rename to CallScript once we get rid of the existing CallScript
    1585             : // and Call, CallBasic, CallStarBasic methods
    1586          92 : ErrCode SfxObjectShell::CallXScript( const OUString& rScriptURL,
    1587             :         const css::uno::Sequence< css::uno::Any >& aParams,
    1588             :         css::uno::Any& aRet,
    1589             :         css::uno::Sequence< sal_Int16 >& aOutParamIndex,
    1590             :         css::uno::Sequence< css::uno::Any >& aOutParam,
    1591             :         bool bRaiseError,
    1592             :         const css::uno::Any* pCaller )
    1593             : {
    1594          92 :     return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError, pCaller );
    1595             : }
    1596             : 
    1597             : 
    1598           0 : SfxFrame* SfxObjectShell::GetSmartSelf( SfxFrame* pSelf, SfxMedium& /*rMedium*/ )
    1599             : {
    1600           0 :     return pSelf;
    1601             : }
    1602             : 
    1603           0 : SfxObjectShellFlags SfxObjectShell::GetFlags() const
    1604             : {
    1605           0 :     if( pImp->eFlags == SFXOBJECTSHELL_UNDEFINED )
    1606           0 :         pImp->eFlags = GetFactory().GetFlags();
    1607           0 :     return pImp->eFlags;
    1608             : }
    1609             : 
    1610        4740 : void SfxHeaderAttributes_Impl::SetAttributes()
    1611             : {
    1612        4740 :     bAlert = true;
    1613        4740 :     SvKeyValue aPair;
    1614        9470 :     for( bool bCont = xIter->GetFirst( aPair ); bCont;
    1615        4730 :          bCont = xIter->GetNext( aPair ) )
    1616        9470 :         SetAttribute( aPair );
    1617        4740 : }
    1618             : 
    1619        4730 : void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV )
    1620             : {
    1621        4730 :     OUString aValue = rKV.GetValue();
    1622        4730 :     if( rKV.GetKey().equalsIgnoreAsciiCase("refresh") && !rKV.GetValue().isEmpty() )
    1623             :     {
    1624           0 :         sal_uInt32 nTime = aValue.getToken(  0, ';' ).toInt32() ;
    1625           0 :         OUString aURL = comphelper::string::strip(aValue.getToken( 1, ';' ), ' ');
    1626             :         uno::Reference<document::XDocumentProperties> xDocProps(
    1627           0 :             pDoc->getDocProperties());
    1628           0 :         if( aURL.startsWithIgnoreAsciiCase( "url=" ) )
    1629             :         {
    1630           0 :             INetURLObject aObj;
    1631           0 :             INetURLObject( pDoc->GetMedium()->GetName() ).GetNewAbsURL( aURL.copy( 4 ), &aObj );
    1632           0 :             xDocProps->setAutoloadURL(
    1633           0 :                 aObj.GetMainURL( INetURLObject::NO_DECODE ) );
    1634             :         }
    1635             :         try
    1636             :         {
    1637           0 :             xDocProps->setAutoloadSecs( nTime );
    1638             :         }
    1639           0 :         catch (lang::IllegalArgumentException &)
    1640             :         {
    1641             :             // ignore
    1642           0 :         }
    1643             :     }
    1644        4730 :     else if( rKV.GetKey().equalsIgnoreAsciiCase( "expires" ) )
    1645             :     {
    1646           0 :         DateTime aDateTime( DateTime::EMPTY );
    1647           0 :         if( INetRFC822Message::ParseDateField( rKV.GetValue(), aDateTime ) )
    1648             :         {
    1649           0 :             aDateTime.ConvertToLocalTime();
    1650           0 :             pDoc->GetMedium()->SetExpired_Impl( aDateTime );
    1651             :         }
    1652             :         else
    1653             :         {
    1654           0 :             pDoc->GetMedium()->SetExpired_Impl( Date( 1, 1, 1970 ) );
    1655             :         }
    1656        4730 :     }
    1657        4730 : }
    1658             : 
    1659          14 : void SfxHeaderAttributes_Impl::Append( const SvKeyValue& rKV )
    1660             : {
    1661          14 :     xIter->Append( rKV );
    1662          14 :     if( bAlert ) SetAttribute( rKV );
    1663          14 : }
    1664             : 
    1665        4870 : SvKeyValueIterator* SfxObjectShell::GetHeaderAttributes()
    1666             : {
    1667        4870 :     if( !pImp->xHeaderAttributes.Is() )
    1668             :     {
    1669             :         DBG_ASSERT( pMedium, "No Medium" );
    1670        4740 :         pImp->xHeaderAttributes = new SfxHeaderAttributes_Impl( this );
    1671             :     }
    1672        4870 :     return static_cast<SvKeyValueIterator*>( &pImp->xHeaderAttributes );
    1673             : }
    1674             : 
    1675           0 : void SfxObjectShell::ClearHeaderAttributesForSourceViewHack()
    1676             : {
    1677           0 :     static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())
    1678           0 :         ->ClearForSourceView();
    1679           0 : }
    1680             : 
    1681             : 
    1682           0 : void SfxObjectShell::SetHeaderAttributesForSourceViewHack()
    1683             : {
    1684           0 :     static_cast<SfxHeaderAttributes_Impl*>(GetHeaderAttributes())
    1685           0 :         ->SetAttributes();
    1686           0 : }
    1687             : 
    1688      140026 : bool SfxObjectShell::IsPreview() const
    1689             : {
    1690      140026 :     if ( !pMedium )
    1691          20 :         return false;
    1692             : 
    1693      140006 :     bool bPreview = false;
    1694      140006 :     SFX_ITEMSET_ARG( pMedium->GetItemSet(), pFlags, SfxStringItem, SID_OPTIONS, false);
    1695      140006 :     if ( pFlags )
    1696             :     {
    1697             :         // Distributed values among individual items
    1698        1753 :         OUString aFileFlags = pFlags->GetValue();
    1699        1753 :         aFileFlags = aFileFlags.toAsciiUpperCase();
    1700        1753 :         if ( -1 != aFileFlags.indexOf( 'B' ) )
    1701           0 :             bPreview = true;
    1702             :     }
    1703             : 
    1704      140006 :     if ( !bPreview )
    1705             :     {
    1706      140006 :         SFX_ITEMSET_ARG( pMedium->GetItemSet(), pItem, SfxBoolItem, SID_PREVIEW, false);
    1707      140006 :         if ( pItem )
    1708           0 :             bPreview = pItem->GetValue();
    1709             :     }
    1710             : 
    1711      140006 :     return bPreview;
    1712             : }
    1713             : 
    1714         736 : void SfxObjectShell::SetWaitCursor( bool bSet ) const
    1715             : {
    1716         736 :     for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
    1717             :     {
    1718           0 :         if ( bSet )
    1719           0 :             pFrame->GetFrame().GetWindow().EnterWait();
    1720             :         else
    1721           0 :             pFrame->GetFrame().GetWindow().LeaveWait();
    1722             :     }
    1723         736 : }
    1724             : 
    1725        5636 : OUString SfxObjectShell::GetAPIName() const
    1726             : {
    1727        5636 :     INetURLObject aURL( IsDocShared() ? GetSharedFileURL() : OUString( GetMedium()->GetName() ) );
    1728        5636 :     OUString aName( aURL.GetBase() );
    1729        5636 :     if( aName.isEmpty() )
    1730        1648 :         aName = aURL.GetURLNoPass();
    1731        5636 :     if ( aName.isEmpty() )
    1732        1648 :         aName = GetTitle( SFX_TITLE_DETECT );
    1733        5636 :     return aName;
    1734             : }
    1735             : 
    1736       26394 : void SfxObjectShell::Invalidate( sal_uInt16 nId )
    1737             : {
    1738       30458 :     for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this ); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, this ) )
    1739        4064 :         Invalidate_Impl( pFrame->GetBindings(), nId );
    1740       26394 : }
    1741             : 
    1742         154 : bool SfxObjectShell::AdjustMacroMode( const OUString& /*rScriptType*/, bool bSuppressUI )
    1743             : {
    1744         154 :     uno::Reference< task::XInteractionHandler > xInteraction;
    1745         154 :     if ( pMedium && !bSuppressUI )
    1746         154 :         xInteraction = pMedium->GetInteractionHandler();
    1747             : 
    1748         154 :     CheckForBrokenDocSignatures_Impl( xInteraction );
    1749             : 
    1750         154 :     CheckEncryption_Impl( xInteraction );
    1751             : 
    1752         154 :     return pImp->aMacroMode.adjustMacroMode( xInteraction );
    1753             : }
    1754             : 
    1755           8 : vcl::Window* SfxObjectShell::GetDialogParent( SfxMedium* pLoadingMedium )
    1756             : {
    1757           8 :     vcl::Window* pWindow = 0;
    1758           8 :     SfxItemSet* pSet = pLoadingMedium ? pLoadingMedium->GetItemSet() : GetMedium()->GetItemSet();
    1759           8 :     SFX_ITEMSET_ARG( pSet, pUnoItem, SfxUnoFrameItem, SID_FILLFRAME, false );
    1760           8 :     if ( pUnoItem )
    1761             :     {
    1762           0 :         uno::Reference < frame::XFrame > xFrame( pUnoItem->GetFrame() );
    1763           0 :         pWindow = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() );
    1764             :     }
    1765             : 
    1766           8 :     if ( !pWindow )
    1767             :     {
    1768           8 :         SfxFrame* pFrame = 0;
    1769           8 :         SFX_ITEMSET_ARG( pSet, pFrameItem, SfxFrameItem, SID_DOCFRAME, false );
    1770           8 :         if( pFrameItem && pFrameItem->GetFrame() )
    1771             :             // get target frame from ItemSet
    1772           0 :             pFrame = pFrameItem->GetFrame();
    1773             :         else
    1774             :         {
    1775             :             // try the current frame
    1776           8 :             SfxViewFrame* pView = SfxViewFrame::Current();
    1777           8 :             if ( !pView || pView->GetObjectShell() != this )
    1778             :                 // get any visible frame
    1779           8 :                 pView = SfxViewFrame::GetFirst(this);
    1780           8 :             if ( pView )
    1781           0 :                 pFrame = &pView->GetFrame();
    1782             :         }
    1783             : 
    1784           8 :         if ( pFrame )
    1785             :             // get topmost window
    1786           0 :             pWindow = VCLUnoHelper::GetWindow( pFrame->GetFrameInterface()->getContainerWindow() );
    1787             :     }
    1788             : 
    1789           8 :     if ( pWindow )
    1790             :     {
    1791             :         // this frame may be invisible, show it if it is allowed
    1792           0 :         SFX_ITEMSET_ARG( pSet, pHiddenItem, SfxBoolItem, SID_HIDDEN, false );
    1793           0 :         if ( !pHiddenItem || !pHiddenItem->GetValue() )
    1794             :         {
    1795           0 :             pWindow->Show();
    1796           0 :             pWindow->ToTop();
    1797             :         }
    1798             :     }
    1799             : 
    1800           8 :     return pWindow;
    1801             : }
    1802             : 
    1803         576 : void SfxObjectShell::SetCreateMode_Impl( SfxObjectCreateMode nMode )
    1804             : {
    1805         576 :     eCreateMode = nMode;
    1806         576 : }
    1807             : 
    1808      289872 : bool SfxObjectShell::IsInPlaceActive()
    1809             : {
    1810      289872 :     if ( eCreateMode != SFX_CREATE_MODE_EMBEDDED )
    1811      287352 :         return false;
    1812             : 
    1813        2520 :     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
    1814        2520 :     return pFrame && pFrame->GetFrame().IsInPlace();
    1815             : }
    1816             : 
    1817        5118 : bool SfxObjectShell::IsUIActive()
    1818             : {
    1819        5118 :     if ( eCreateMode != SFX_CREATE_MODE_EMBEDDED )
    1820        5118 :         return false;
    1821             : 
    1822           0 :     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
    1823           0 :     return pFrame && pFrame->GetFrame().IsInPlace() && pFrame->GetFrame().GetWorkWindow_Impl()->IsVisible_Impl();
    1824             : }
    1825             : 
    1826           0 : void SfxObjectShell::UIActivate( bool )
    1827             : {
    1828           0 : }
    1829             : 
    1830           0 : void SfxObjectShell::InPlaceActivate( bool )
    1831             : {
    1832           0 : }
    1833             : 
    1834         252 : bool SfxObjectShell::UseInteractionToHandleError(
    1835             :                     const uno::Reference< task::XInteractionHandler >& xHandler,
    1836             :                     sal_uInt32 nError )
    1837             : {
    1838         252 :     bool bResult = false;
    1839             : 
    1840         252 :     if ( xHandler.is() )
    1841             :     {
    1842             :         try
    1843             :         {
    1844         252 :             uno::Any aInteraction;
    1845         504 :             uno::Sequence< uno::Reference< task::XInteractionContinuation > > lContinuations(2);
    1846         252 :             ::comphelper::OInteractionAbort* pAbort = new ::comphelper::OInteractionAbort();
    1847         252 :             ::comphelper::OInteractionApprove* pApprove = new ::comphelper::OInteractionApprove();
    1848         504 :             lContinuations[0] = uno::Reference< task::XInteractionContinuation >(
    1849         504 :                                  static_cast< task::XInteractionContinuation* >( pAbort ), uno::UNO_QUERY );
    1850         504 :             lContinuations[1] = uno::Reference< task::XInteractionContinuation >(
    1851         504 :                                  static_cast< task::XInteractionContinuation* >( pApprove ), uno::UNO_QUERY );
    1852             : 
    1853         504 :             task::ErrorCodeRequest aErrorCode;
    1854         252 :             aErrorCode.ErrCode = nError;
    1855         252 :             aInteraction <<= aErrorCode;
    1856         252 :             xHandler->handle(::framework::InteractionRequest::CreateRequest (aInteraction,lContinuations));
    1857         504 :             bResult = pAbort->wasSelected();
    1858             :         }
    1859           0 :         catch( uno::Exception& )
    1860             :         {}
    1861             :     }
    1862             : 
    1863         252 :     return bResult;
    1864             : }
    1865             : 
    1866       10398 : sal_Int16 SfxObjectShell_Impl::getCurrentMacroExecMode() const
    1867             : {
    1868       10398 :     sal_Int16 nImposedExecMode( MacroExecMode::NEVER_EXECUTE );
    1869             : 
    1870       10398 :     const SfxMedium* pMedium( rDocShell.GetMedium() );
    1871             :     OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
    1872       10398 :     if ( pMedium )
    1873             :     {
    1874       10398 :         SFX_ITEMSET_ARG( pMedium->GetItemSet(), pMacroModeItem, SfxUInt16Item, SID_MACROEXECMODE, false);
    1875       10398 :         if ( pMacroModeItem )
    1876        9694 :             nImposedExecMode = pMacroModeItem->GetValue();
    1877             :     }
    1878       10398 :     return nImposedExecMode;
    1879             : }
    1880             : 
    1881       10110 : bool SfxObjectShell_Impl::setCurrentMacroExecMode( sal_uInt16 nMacroMode )
    1882             : {
    1883       10110 :     const SfxMedium* pMedium( rDocShell.GetMedium() );
    1884             :     OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getCurrentMacroExecMode: no medium!" );
    1885       10110 :     if ( pMedium )
    1886             :     {
    1887       10110 :         pMedium->GetItemSet()->Put( SfxUInt16Item( SID_MACROEXECMODE, nMacroMode ) );
    1888       10110 :         return true;
    1889             :     }
    1890             : 
    1891           0 :     return false;
    1892             : }
    1893             : 
    1894           0 : OUString SfxObjectShell_Impl::getDocumentLocation() const
    1895             : {
    1896           0 :     OUString sLocation;
    1897             : 
    1898           0 :     const SfxMedium* pMedium( rDocShell.GetMedium() );
    1899             :     OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getDocumentLocation: no medium!" );
    1900           0 :     if ( pMedium )
    1901             :     {
    1902           0 :         sLocation = pMedium->GetName();
    1903           0 :         if ( sLocation.isEmpty() )
    1904             :         {
    1905             :             // for documents made from a template: get the name of the template
    1906           0 :             sLocation = rDocShell.getDocProperties()->getTemplateURL();
    1907             :         }
    1908             :     }
    1909           0 :     return sLocation;
    1910             : }
    1911             : 
    1912           0 : uno::Reference< embed::XStorage > SfxObjectShell_Impl::getZipStorageToSign()
    1913             : {
    1914           0 :     Reference < embed::XStorage > xStore;
    1915             : 
    1916           0 :     SfxMedium* pMedium( rDocShell.GetMedium() );
    1917             :     OSL_PRECOND( pMedium, "SfxObjectShell_Impl::getLastCommitDocumentStorage: no medium!" );
    1918           0 :     if ( pMedium )
    1919           0 :         xStore = pMedium->GetZipStorageToSign_Impl();
    1920             : 
    1921           0 :     return xStore;
    1922             : }
    1923             : 
    1924       10244 : bool SfxObjectShell_Impl::documentStorageHasMacros() const
    1925             : {
    1926       10244 :     return ::sfx2::DocumentMacroMode::storageHasMacros( m_xDocStorage );
    1927             : }
    1928             : 
    1929       10212 : Reference< XEmbeddedScripts > SfxObjectShell_Impl::getEmbeddedDocumentScripts() const
    1930             : {
    1931       10212 :     return Reference< XEmbeddedScripts >( rDocShell.GetModel(), UNO_QUERY );
    1932             : }
    1933             : 
    1934           0 : sal_Int16 SfxObjectShell_Impl::getScriptingSignatureState()
    1935             : {
    1936           0 :     sal_Int16 nSignatureState( rDocShell.GetScriptingSignatureState() );
    1937             : 
    1938           0 :     if ( nSignatureState != SIGNATURESTATE_NOSIGNATURES && m_bMacroSignBroken )
    1939             :     {
    1940             :         // if there is a macro signature it must be handled as broken
    1941           0 :         nSignatureState = SIGNATURESTATE_SIGNATURES_BROKEN;
    1942             :     }
    1943             : 
    1944           0 :     return nSignatureState;
    1945             : }
    1946             : 
    1947           0 : bool SfxObjectShell_Impl::hasTrustedScriptingSignature( bool bAllowUIToAddAuthor )
    1948             : {
    1949           0 :     bool bResult = false;
    1950             : 
    1951             :     try
    1952             :     {
    1953           0 :         OUString aVersion;
    1954             :         try
    1955             :         {
    1956           0 :             uno::Reference < beans::XPropertySet > xPropSet( rDocShell.GetStorage(), uno::UNO_QUERY_THROW );
    1957           0 :             xPropSet->getPropertyValue("Version") >>= aVersion;
    1958             :         }
    1959           0 :         catch( uno::Exception& )
    1960             :         {
    1961             :         }
    1962             : 
    1963           0 :         uno::Reference< security::XDocumentDigitalSignatures > xSigner( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) );
    1964             : 
    1965           0 :         if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN
    1966           0 :           || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK
    1967           0 :           || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
    1968             :         {
    1969           0 :             uno::Sequence< security::DocumentSignatureInformation > aInfo = rDocShell.ImplAnalyzeSignature( true, xSigner );
    1970             : 
    1971           0 :             if ( aInfo.getLength() )
    1972             :             {
    1973           0 :                 if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN )
    1974           0 :                     nScriptingSignatureState = rDocShell.ImplCheckSignaturesInformation( aInfo );
    1975             : 
    1976           0 :                 if ( nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK
    1977           0 :                   || nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
    1978             :                 {
    1979           0 :                     for ( sal_Int32 nInd = 0; !bResult && nInd < aInfo.getLength(); nInd++ )
    1980             :                     {
    1981           0 :                         bResult = xSigner->isAuthorTrusted( aInfo[nInd].Signer );
    1982             :                     }
    1983             : 
    1984           0 :                     if ( !bResult && bAllowUIToAddAuthor )
    1985             :                     {
    1986           0 :                         uno::Reference< task::XInteractionHandler > xInteraction;
    1987           0 :                         if ( rDocShell.GetMedium() )
    1988           0 :                             xInteraction = rDocShell.GetMedium()->GetInteractionHandler();
    1989             : 
    1990           0 :                         if ( xInteraction.is() )
    1991             :                         {
    1992           0 :                             task::DocumentMacroConfirmationRequest aRequest;
    1993           0 :                             aRequest.DocumentURL = getDocumentLocation();
    1994           0 :                             aRequest.DocumentStorage = rDocShell.GetMedium()->GetZipStorageToSign_Impl();
    1995           0 :                             aRequest.DocumentSignatureInformation = aInfo;
    1996           0 :                             aRequest.DocumentVersion = aVersion;
    1997           0 :                             aRequest.Classification = task::InteractionClassification_QUERY;
    1998           0 :                             bResult = SfxMedium::CallApproveHandler( xInteraction, uno::makeAny( aRequest ), true );
    1999           0 :                         }
    2000             :                     }
    2001             :                 }
    2002           0 :             }
    2003           0 :         }
    2004             :     }
    2005           0 :     catch( uno::Exception& )
    2006             :     {}
    2007             : 
    2008           0 :     return bResult;
    2009             : }
    2010             : 
    2011           0 : void SfxObjectShell_Impl::showBrokenSignatureWarning( const uno::Reference< task::XInteractionHandler >& _rxInteraction ) const
    2012             : {
    2013           0 :     if  ( !bSignatureErrorIsShown )
    2014             :     {
    2015           0 :         SfxObjectShell::UseInteractionToHandleError( _rxInteraction, ERRCODE_SFX_BROKENSIGNATURE );
    2016           0 :         const_cast< SfxObjectShell_Impl* >( this )->bSignatureErrorIsShown = true;
    2017             :     }
    2018           0 : }
    2019             : 
    2020       12890 : void SfxObjectShell::AddLog( const OUString& aMessage )
    2021             : {
    2022       12890 :     if ( !pImp->m_xLogRing.is() )
    2023             :     {
    2024             :         try
    2025             :         {
    2026        1978 :             Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
    2027        1978 :             pImp->m_xLogRing.set( logging::DocumentIOLogRing::get(xContext) );
    2028             :         }
    2029           0 :         catch( uno::Exception& )
    2030             :         {}
    2031             :     }
    2032             : 
    2033       12890 :     if ( pImp->m_xLogRing.is() )
    2034       12890 :         pImp->m_xLogRing->logString( aMessage );
    2035       12890 : }
    2036             : 
    2037             : namespace {
    2038             : 
    2039           0 : void WriteStringInStream( const uno::Reference< io::XOutputStream >& xOutStream, const OUString& aString )
    2040             : {
    2041           0 :     if ( xOutStream.is() )
    2042             :     {
    2043           0 :         OString aStrLog = OUStringToOString( aString, RTL_TEXTENCODING_UTF8 );
    2044           0 :         uno::Sequence< sal_Int8 > aLogData( (const sal_Int8*)aStrLog.getStr(), aStrLog.getLength() );
    2045           0 :         xOutStream->writeBytes( aLogData );
    2046             : 
    2047           0 :         aLogData.realloc( 1 );
    2048           0 :         aLogData[0] = '\n';
    2049           0 :         xOutStream->writeBytes( aLogData );
    2050             :     }
    2051           0 : }
    2052             : 
    2053             : }
    2054             : 
    2055           0 : void SfxObjectShell::StoreLog()
    2056             : {
    2057           0 :     if ( !pImp->m_xLogRing.is() )
    2058             :     {
    2059             :         try
    2060             :         {
    2061           0 :             Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
    2062           0 :             pImp->m_xLogRing.set( logging::DocumentIOLogRing::get(xContext) );
    2063             :         }
    2064           0 :         catch( uno::Exception& )
    2065             :         {}
    2066             :     }
    2067             : 
    2068           0 :     if ( pImp->m_xLogRing.is() )
    2069             :     {
    2070           0 :         OUString aFileURL = ( "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}"  );
    2071             : 
    2072           0 :         ::rtl::Bootstrap::expandMacros( aFileURL );
    2073             : 
    2074           0 :         OUString aBuildID = ( "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("setup") ":buildid}"  );
    2075             : 
    2076           0 :         ::rtl::Bootstrap::expandMacros( aBuildID );
    2077             : 
    2078           0 :         if ( !aFileURL.isEmpty() )
    2079             :         {
    2080           0 :             aFileURL += "/user/temp/document_io_logring.txt";
    2081             :             try
    2082             :             {
    2083           0 :                 uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
    2084           0 :                 uno::Reference< ucb::XSimpleFileAccess3 > xSimpleFileAccess(ucb::SimpleFileAccess::create(xContext));
    2085           0 :                 uno::Reference< io::XStream > xStream( xSimpleFileAccess->openFileReadWrite( aFileURL ), uno::UNO_SET_THROW );
    2086           0 :                 uno::Reference< io::XOutputStream > xOutStream( xStream->getOutputStream(), uno::UNO_SET_THROW );
    2087           0 :                 uno::Reference< io::XTruncate > xTruncate( xOutStream, uno::UNO_QUERY_THROW );
    2088           0 :                 xTruncate->truncate();
    2089             : 
    2090           0 :                 if ( !aBuildID.isEmpty() )
    2091           0 :                     WriteStringInStream( xOutStream, aBuildID );
    2092             : 
    2093           0 :                 uno::Sequence< OUString > aLogSeq = pImp->m_xLogRing->getCollectedLog();
    2094           0 :                 for ( sal_Int32 nInd = 0; nInd < aLogSeq.getLength(); nInd++ )
    2095           0 :                     WriteStringInStream( xOutStream, aLogSeq[nInd] );
    2096             :             }
    2097           0 :             catch( uno::Exception& )
    2098             :             {}
    2099           0 :         }
    2100             :     }
    2101         951 : }
    2102             : 
    2103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10