LCOV - code coverage report
Current view: top level - sfx2/source/doc - objmisc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 523 874 59.8 %
Date: 2012-08-25 Functions: 74 104 71.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 571 1768 32.3 %

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

Generated by: LCOV version 1.10