LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sfx2/source/appl - fileobj.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 134 276 48.6 %
Date: 2013-07-09 Functions: 14 20 70.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/wrkwin.hxx>
      21             : #include <vcl/msgbox.hxx>
      22             : #include <tools/urlobj.hxx>
      23             : #include <tools/stream.hxx>
      24             : #include <sot/formats.hxx>
      25             : #include <vcl/graphicfilter.hxx>
      26             : #include <sfx2/lnkbase.hxx>
      27             : #include <sfx2/app.hxx>
      28             : #include <sfx2/progress.hxx>
      29             : #include <sfx2/docfilt.hxx>
      30             : #include <sfx2/filedlghelper.hxx>
      31             : #include <sot/exchange.hxx>
      32             : #include <com/sun/star/uno/Any.hxx>
      33             : #include <com/sun/star/uno/Sequence.hxx>
      34             : #include <sfx2/docfac.hxx>
      35             : #include <com/sun/star/document/XTypeDetection.hpp>
      36             : #include <comphelper/mediadescriptor.hxx>
      37             : #include <comphelper/processfactory.hxx>
      38             : #include <sfx2/linkmgr.hxx>
      39             : #include <sfx2/opengrf.hxx>
      40             : #include "sfx2/sfxresid.hxx"
      41             : #include "fileobj.hxx"
      42             : #include "app.hrc"
      43             : #include <vcl/dibtools.hxx>
      44             : 
      45             : #define FILETYPE_TEXT       1
      46             : #define FILETYPE_GRF        2
      47             : #define FILETYPE_OBJECT     3
      48             : 
      49             : struct Impl_DownLoadData
      50             : {
      51             :     Graphic aGrf;
      52             :     Timer aTimer;
      53             : 
      54             :     Impl_DownLoadData( const Link& rLink )
      55             :     {
      56             :         aTimer.SetTimeout( 100 );
      57             :         aTimer.SetTimeoutHdl( rLink  );
      58             :         aGrf.SetDefaultType();
      59             :     }
      60           0 :     ~Impl_DownLoadData()
      61           0 :     {
      62           0 :         aTimer.Stop();
      63           0 :     }
      64             : };
      65             : 
      66             : // --------------------------------------------------------------------------
      67             : 
      68             : 
      69          38 : SvFileObject::SvFileObject() :
      70          38 :     pDownLoadData( NULL ), pOldParent( NULL ), nType( FILETYPE_TEXT )
      71             : {
      72          38 :     bLoadAgain = sal_True;
      73             :     bSynchron = bLoadError = bWaitForData = bDataReady = bNativFormat =
      74          38 :     bClearMedium = bStateChangeCalled = bInCallDownLoad = sal_False;
      75          38 : }
      76             : 
      77             : 
      78         108 : SvFileObject::~SvFileObject()
      79             : {
      80          36 :     if ( xMed.Is() )
      81             :     {
      82           0 :         xMed->SetDoneLink( Link() );
      83           0 :         xMed.Clear();
      84             :     }
      85          36 :     delete pDownLoadData;
      86          72 : }
      87             : 
      88             : 
      89          49 : sal_Bool SvFileObject::GetData( ::com::sun::star::uno::Any & rData,
      90             :                                 const String & rMimeType,
      91             :                                 sal_Bool bGetSynchron )
      92             : {
      93          49 :     sal_uIntPtr nFmt = SotExchange::GetFormatStringId( rMimeType );
      94          49 :     switch( nType )
      95             :     {
      96             :     case FILETYPE_TEXT:
      97          30 :         if( FORMAT_FILE == nFmt )
      98             :         {
      99             :             // The media in the application must be opened to lookup the
     100             :             // relative file links!! This is done through the link manager
     101             :             // of the Storage.
     102          30 :             rData <<= OUString( sFileNm );
     103             :         }
     104          30 :         break;
     105             : 
     106             :     case FILETYPE_GRF:
     107          19 :         if( !bLoadError )
     108             :         {
     109          14 :             SfxMediumRef xTmpMed;
     110             : 
     111          14 :             if( FORMAT_GDIMETAFILE == nFmt || FORMAT_BITMAP == nFmt ||
     112             :                 SOT_FORMATSTR_ID_SVXB == nFmt )
     113             :             {
     114          14 :                 Graphic aGrf;
     115             : 
     116             :                 // If the native format is reqested, has to be reset at the
     117             :                 // end of the flag. Is solely in the sw/ndgrf.cxx used when
     118             :                 // the link is removed form GraphicNode.
     119          14 :                 sal_Bool bOldNativFormat = bNativFormat;
     120             : 
     121             :                 // If about to print, waiting for the data to be available
     122          14 :                 if( bGetSynchron )
     123             :                 {
     124             :                     // call a LoadFile every second time to test the loading
     125           8 :                     if( !xMed.Is() )
     126           0 :                         LoadFile_Impl();
     127             : 
     128           8 :                     if( !bInCallDownLoad )
     129             :                     {
     130           8 :                         xTmpMed = xMed;
     131          20 :                         while( bWaitForData )
     132           4 :                             Application::Reschedule();
     133             : 
     134           8 :                         xMed = xTmpMed;
     135           8 :                         bClearMedium = sal_True;
     136             :                     }
     137             :                 }
     138             : 
     139          36 :                 if( pDownLoadData ||
     140          28 :                     ( !bWaitForData && ( xMed.Is() ||  // was loaded as URL
     141           0 :                         ( bSynchron && LoadFile_Impl() && xMed.Is() ) )) )
     142             :                 {
     143             :                     // If it was loaded from the Internet, do not retry
     144           8 :                     if( !bGetSynchron )
     145           0 :                         bLoadAgain = !xMed->IsRemote();
     146           8 :                     bLoadError = !GetGraphic_Impl( aGrf, xMed->GetInStream() );
     147             :                 }
     148           6 :                 else if( !LoadFile_Impl() ||
     149           0 :                         !GetGraphic_Impl( aGrf, xMed.Is() ? xMed->GetInStream() : 0 ))
     150             :                 {
     151           6 :                     if( !xMed.Is() )
     152           0 :                         break;
     153           6 :                     aGrf.SetDefaultType();
     154             :                 }
     155             : 
     156          14 :                 if( SOT_FORMATSTR_ID_SVXB != nFmt )
     157           0 :                     nFmt = (bLoadError || GRAPHIC_BITMAP == aGrf.GetType())
     158             :                                 ? FORMAT_BITMAP
     159           0 :                                 : FORMAT_GDIMETAFILE;
     160             : 
     161          28 :                 SvMemoryStream aMemStm( 0, 65535 );
     162          14 :                 switch ( nFmt )
     163             :                 {
     164             :                 case SOT_FORMATSTR_ID_SVXB:
     165          14 :                     if( GRAPHIC_NONE != aGrf.GetType() )
     166             :                     {
     167           6 :                         aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
     168           6 :                         aMemStm << aGrf;
     169             :                     }
     170          14 :                     break;
     171             : 
     172             :                 case  FORMAT_BITMAP:
     173             :                 {
     174           0 :                     const Bitmap aBitmap(aGrf.GetBitmap());
     175             : 
     176           0 :                     if(!aBitmap.IsEmpty())
     177             :                     {
     178           0 :                         WriteDIB(aBitmap, aMemStm, false, true);
     179             :                     }
     180             : 
     181           0 :                     break;
     182             :                 }
     183             : 
     184             :                 default:
     185           0 :                     if( aGrf.GetGDIMetaFile().GetActionSize() )
     186             :                     {
     187           0 :                         GDIMetaFile aMeta( aGrf.GetGDIMetaFile() );
     188           0 :                         aMeta.Write( aMemStm );
     189             :                     }
     190             :                 }
     191          28 :                 rData <<= css::uno::Sequence< sal_Int8 >( (sal_Int8*) aMemStm.GetData(),
     192          28 :                                         aMemStm.Seek( STREAM_SEEK_TO_END ) );
     193             : 
     194          14 :                 bNativFormat = bOldNativFormat;
     195             : 
     196             :                 // Everything ready?
     197          14 :                 if( xMed.Is() && !bSynchron && bClearMedium )
     198             :                 {
     199           8 :                     xMed.Clear();
     200           8 :                     bClearMedium = sal_False;
     201          14 :                 }
     202          14 :             }
     203             :         }
     204          19 :         break;
     205             :     case FILETYPE_OBJECT:
     206             :         // TODO/LATER: possibility to insert a new object
     207           0 :         rData <<= OUString( sFileNm );
     208           0 :         break;
     209             :     }
     210          49 :     return sal_True/*0 != aTypeList.Count()*/;
     211             : }
     212             : 
     213          38 : sal_Bool SvFileObject::Connect( sfx2::SvBaseLink* pLink )
     214             : {
     215          38 :     if( !pLink || !pLink->GetLinkManager() )
     216           0 :         return sal_False;
     217             : 
     218             :     // Test if not another link of the same connection already exists
     219          38 :     pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sFileNm, 0, &sFilter );
     220             : 
     221          38 :     if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
     222             :     {
     223           6 :         SfxObjectShellRef pShell = pLink->GetLinkManager()->GetPersist();
     224           6 :         if( pShell.Is() )
     225             :         {
     226           6 :             if( pShell->IsAbortingImport() )
     227           0 :                 return sal_False;
     228             : 
     229           6 :             if( pShell->GetMedium() )
     230           6 :                 sReferer = pShell->GetMedium()->GetName();
     231           6 :         }
     232             :     }
     233             : 
     234          38 :     switch( pLink->GetObjType() )
     235             :     {
     236             :     case OBJECT_CLIENT_GRF:
     237           6 :         nType = FILETYPE_GRF;
     238           6 :         bSynchron = pLink->IsSynchron();
     239           6 :         break;
     240             : 
     241             :     case OBJECT_CLIENT_FILE:
     242          32 :         nType = FILETYPE_TEXT;
     243          32 :         break;
     244             : 
     245             :     case OBJECT_CLIENT_OLE:
     246           0 :         nType = FILETYPE_OBJECT;
     247             :         // TODO/LATER: introduce own type to be used for exchanging
     248           0 :         break;
     249             : 
     250             :     default:
     251           0 :         return sal_False;
     252             :     }
     253             : 
     254          38 :     SetUpdateTimeout( 0 );
     255             : 
     256             :     // and now register by this or other found Pseudo-Object
     257          38 :     AddDataAdvise( pLink, SotExchange::GetFormatMimeType( pLink->GetContentType()), 0 );
     258          38 :     return sal_True;
     259             : }
     260             : 
     261           6 : sal_Bool SvFileObject::LoadFile_Impl()
     262             : {
     263             :     // We are still at Loading!!
     264           6 :     if( bWaitForData || !bLoadAgain || xMed.Is() || pDownLoadData )
     265           0 :         return sal_False;
     266             : 
     267             :     // at the moment on the current DocShell
     268           6 :     xMed = new SfxMedium( sFileNm, STREAM_STD_READ );
     269             :     SvLinkSource::StreamToLoadFrom aStreamToLoadFrom =
     270           6 :         getStreamToLoadFrom();
     271             :     xMed->setStreamToLoadFrom(
     272             :         aStreamToLoadFrom.m_xInputStreamToLoadFrom,
     273           6 :         aStreamToLoadFrom.m_bIsReadOnly);
     274             : 
     275           6 :     if( !bSynchron )
     276             :     {
     277           6 :         bLoadAgain = bDataReady = bInNewData = sal_False;
     278           6 :         bWaitForData = sal_True;
     279             : 
     280           6 :         SfxMediumRef xTmpMed = xMed;
     281           6 :         bInCallDownLoad = sal_True;
     282           6 :         xMed->DownLoad( STATIC_LINK( this, SvFileObject, LoadGrfReady_Impl ) );
     283           6 :         bInCallDownLoad = sal_False;
     284             : 
     285           6 :         bClearMedium = !xMed.Is();
     286           6 :         if( bClearMedium )
     287           0 :             xMed = xTmpMed;  // If already finished in DownLoad
     288           6 :         return bDataReady;
     289             :     }
     290             : 
     291           0 :     bWaitForData = sal_True;
     292           0 :     bDataReady = bInNewData = sal_False;
     293           0 :     xMed->DownLoad();
     294           0 :     bLoadAgain = !xMed->IsRemote();
     295           0 :     bWaitForData = sal_False;
     296             : 
     297             :     // Graphic is finished, also send DataChanged of the Status change:
     298           0 :     SendStateChg_Impl( xMed->GetInStream() && xMed->GetInStream()->GetError()
     299           0 :                         ? sfx2::LinkManager::STATE_LOAD_ERROR : sfx2::LinkManager::STATE_LOAD_OK );
     300           0 :     return sal_True;
     301             : }
     302             : 
     303             : 
     304           8 : sal_Bool SvFileObject::GetGraphic_Impl( Graphic& rGrf, SvStream* pStream )
     305             : {
     306           8 :     GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
     307             : 
     308          10 :     const sal_uInt16 nFilter = sFilter.Len() && rGF.GetImportFormatCount()
     309           2 :                             ? rGF.GetImportFormatNumber( sFilter )
     310          10 :                             : GRFILTER_FORMAT_DONTKNOW;
     311             : 
     312           8 :     String aEmptyStr;
     313             :     int nRes;
     314             : 
     315             :     // To avoid that a native link is created
     316          16 :     if( ( !pStream || !pDownLoadData ) && !rGrf.IsLink() &&
     317          24 :         !rGrf.GetContext() && !bNativFormat )
     318           8 :         rGrf.SetLink( GfxLink() );
     319             : 
     320           8 :     if( !pStream )
     321           8 :         nRes = xMed.Is() ? GRFILTER_OPENERROR
     322             :                          : rGF.ImportGraphic( rGrf, INetURLObject(sFileNm),
     323           8 :                             nFilter );
     324           0 :     else if( !pDownLoadData )
     325             :     {
     326           0 :         pStream->Seek( STREAM_SEEK_TO_BEGIN );
     327           0 :         nRes = rGF.ImportGraphic( rGrf, aEmptyStr, *pStream, nFilter );
     328             :     }
     329             :     else
     330             :     {
     331             :         nRes = rGF.ImportGraphic( pDownLoadData->aGrf, aEmptyStr,
     332           0 :                                     *pStream, nFilter );
     333             : 
     334           0 :         if( pDownLoadData )
     335             :         {
     336           0 :             rGrf = pDownLoadData->aGrf;
     337           0 :             if( GRAPHIC_NONE == rGrf.GetType() )
     338           0 :                 rGrf.SetDefaultType();
     339             : 
     340             : 
     341           0 :             if( !pDownLoadData->aGrf.GetContext() )
     342             :             {
     343           0 :                 delete pDownLoadData, pDownLoadData = 0;
     344           0 :                 bDataReady = sal_True;
     345           0 :                 bWaitForData = sal_False;
     346             :             }
     347             :         }
     348             :     }
     349             : 
     350           8 :     if( pStream && ERRCODE_IO_PENDING == pStream->GetError() )
     351           0 :         pStream->ResetError();
     352             : 
     353             : #ifdef DBG_UTIL
     354             :     if( nRes )
     355             :     {
     356             :         if( xMed.Is() && !pStream )
     357             :         {
     358             :             DBG_WARNING3( "Graphic error [%d] - [%s] URL[%s]",
     359             :                             nRes,
     360             :                             xMed->GetPhysicalName().getStr(),
     361             :                             sFileNm.GetBuffer() );
     362             :         }
     363             :         else
     364             :         {
     365             :             DBG_WARNING2( "Graphic error [%d] - [%s]",
     366             :                             nRes, sFileNm.GetBuffer() );
     367             :         }
     368             :     }
     369             : #endif
     370             : 
     371           8 :     return GRFILTER_OK == nRes;
     372             : }
     373             : 
     374             : /** detect the filter of the given file
     375             : 
     376             :     @param _rURL
     377             :         specifies the URL of the file which filter is to detected.<br/>
     378             :         If the URL doesn't denote a valid (existent and accessible) file, the
     379             :         request is silently dropped.
     380             : */
     381           0 : String impl_getFilter( const String& _rURL )
     382             : {
     383           0 :     String sFilter;
     384           0 :     if ( _rURL.Len() == 0 )
     385           0 :         return sFilter;
     386             : 
     387             :     try
     388             :     {
     389             :         css::uno::Reference< ::com::sun::star::document::XTypeDetection > xTypeDetection(
     390           0 :             ::comphelper::getProcessServiceFactory()->createInstance(
     391           0 :                 OUString("com.sun.star.document.TypeDetection") ),
     392           0 :                 css::uno::UNO_QUERY );
     393           0 :         if ( xTypeDetection.is() )
     394             :         {
     395           0 :             ::comphelper::MediaDescriptor aDescr;
     396           0 :             aDescr[ ::comphelper::MediaDescriptor::PROP_URL() ] <<= OUString( _rURL );
     397             :             css::uno::Sequence< css::beans::PropertyValue > aDescrList =
     398           0 :                 aDescr.getAsConstPropertyValueList();
     399           0 :             OUString sType = xTypeDetection->queryTypeByDescriptor( aDescrList, sal_True );
     400           0 :             if ( !sType.isEmpty() )
     401             :             {
     402             :                 css::uno::Reference< css::container::XNameAccess > xTypeCont( xTypeDetection,
     403           0 :                                                                               css::uno::UNO_QUERY );
     404           0 :                 if ( xTypeCont.is() )
     405             :                 {
     406           0 :                     ::comphelper::SequenceAsHashMap lTypeProps( xTypeCont->getByName( sType ) );
     407           0 :                     sFilter = lTypeProps.getUnpackedValueOrDefault(
     408           0 :                         OUString("PreferredFilter"), OUString() );
     409           0 :                 }
     410           0 :             }
     411           0 :         }
     412             :     }
     413           0 :     catch( const css::uno::Exception& )
     414             :     {
     415             :     }
     416             : 
     417           0 :     return sFilter;
     418             : }
     419             : 
     420           0 : void SvFileObject::Edit( Window* pParent, sfx2::SvBaseLink* pLink, const Link& rEndEditHdl )
     421             : {
     422           0 :     aEndEditLink = rEndEditHdl;
     423           0 :     String sFile, sRange, sTmpFilter;
     424           0 :     if( pLink && pLink->GetLinkManager() )
     425             :     {
     426           0 :         pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sFile, &sRange, &sTmpFilter );
     427             : 
     428           0 :         switch( pLink->GetObjType() )
     429             :         {
     430             :             case OBJECT_CLIENT_GRF:
     431             :             {
     432           0 :                 nType = FILETYPE_GRF;       // If not set already
     433             : 
     434           0 :                 SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK).toString());
     435           0 :                 aDlg.EnableLink(sal_False);
     436           0 :                 aDlg.SetPath( sFile, sal_True );
     437           0 :                 aDlg.SetCurrentFilter( sTmpFilter );
     438             : 
     439           0 :                 if( !aDlg.Execute() )
     440             :                 {
     441           0 :                     sFile = aDlg.GetPath();
     442           0 :                     sFile += ::sfx2::cTokenSeparator;
     443           0 :                     sFile += ::sfx2::cTokenSeparator;
     444           0 :                     sFile += aDlg.GetCurrentFilter();
     445             : 
     446           0 :                     if ( aEndEditLink.IsSet() )
     447           0 :                         aEndEditLink.Call( &sFile );
     448             :                 }
     449             :                 else
     450           0 :                     sFile.Erase();
     451             :             }
     452           0 :             break;
     453             : 
     454             :             case OBJECT_CLIENT_OLE:
     455             :             {
     456           0 :                 nType = FILETYPE_OBJECT; // if not set already
     457           0 :                 pOldParent = Application::GetDefDialogParent();
     458           0 :                 Application::SetDefDialogParent( pParent );
     459             : 
     460             :                 ::sfx2::FileDialogHelper & rFileDlg =
     461           0 :                     pLink->GetInsertFileDialog( String() );
     462             :                 rFileDlg.StartExecuteModal(
     463           0 :                         LINK( this, SvFileObject, DialogClosedHdl ) );
     464             :             }
     465           0 :             break;
     466             : 
     467             :             case OBJECT_CLIENT_FILE:
     468             :             {
     469           0 :                 nType = FILETYPE_TEXT; // if not set already
     470           0 :                 pOldParent = Application::GetDefDialogParent();
     471           0 :                 Application::SetDefDialogParent( pParent );
     472             : 
     473           0 :                 String sFactory;
     474           0 :                 SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
     475           0 :                 if ( pShell )
     476           0 :                     sFactory = pShell->GetFactory().GetFactoryName();
     477             : 
     478             :                 ::sfx2::FileDialogHelper & rFileDlg =
     479           0 :                     pLink->GetInsertFileDialog(sFactory);
     480             :                 rFileDlg.StartExecuteModal(
     481           0 :                         LINK( this, SvFileObject, DialogClosedHdl ) );
     482             :             }
     483           0 :             break;
     484             : 
     485             :             default:
     486           0 :                 sFile.Erase();
     487             :         }
     488           0 :     }
     489           0 : }
     490             : 
     491           6 : IMPL_STATIC_LINK( SvFileObject, LoadGrfReady_Impl, void*, EMPTYARG )
     492             : {
     493             :     // When we come form here there it can not be an error no more.
     494           6 :     pThis->bLoadError = sal_False;
     495           6 :     pThis->bWaitForData = sal_False;
     496           6 :     pThis->bInCallDownLoad = sal_False;
     497             : 
     498           6 :     if( !pThis->bInNewData && !pThis->bDataReady )
     499             :     {
     500             :         // Graphic is finished, also send DataChanged from Status change
     501           6 :         pThis->bDataReady = sal_True;
     502           6 :         pThis->SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_OK );
     503             : 
     504             :         // and then send the data again
     505           6 :         pThis->NotifyDataChanged();
     506             :     }
     507             : 
     508           6 :     if( pThis->bDataReady )
     509             :     {
     510           6 :         pThis->bLoadAgain = sal_True;
     511           6 :         if( pThis->xMed.Is() )
     512             :         {
     513           0 :             pThis->xMed->SetDoneLink( Link() );
     514             : 
     515             :             Application::PostUserEvent(
     516             :                         STATIC_LINK( pThis, SvFileObject, DelMedium_Impl ),
     517           0 :                         new SfxMediumRef( pThis->xMed ));
     518           0 :             pThis->xMed.Clear();
     519             :         }
     520           6 :         if( pThis->pDownLoadData )
     521           0 :             delete pThis->pDownLoadData, pThis->pDownLoadData = 0;
     522             :     }
     523             : 
     524           6 :     return 0;
     525             : }
     526             : 
     527           0 : IMPL_STATIC_LINK( SvFileObject, DelMedium_Impl, SfxMediumRef*, pDelMed )
     528             : {
     529             :     (void)pThis;
     530           0 :     delete pDelMed;
     531           0 :     return 0;
     532             : }
     533             : 
     534           0 : IMPL_LINK( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
     535             : {
     536           0 :     String sFile;
     537           0 :     Application::SetDefDialogParent( pOldParent );
     538             : 
     539           0 :     if ( FILETYPE_TEXT == nType || FILETYPE_OBJECT == nType )
     540             :     {
     541           0 :         if ( _pFileDlg && _pFileDlg->GetError() == ERRCODE_NONE )
     542             :         {
     543           0 :             String sURL( _pFileDlg->GetPath() );
     544           0 :             sFile = sURL;
     545           0 :             sFile += ::sfx2::cTokenSeparator;
     546           0 :             sFile += ::sfx2::cTokenSeparator;
     547           0 :             sFile += impl_getFilter( sURL );
     548           0 :         }
     549             :     }
     550             :     else
     551             :     {
     552             :         SAL_WARN( "sfx2.appl", "SvFileObject::DialogClosedHdl(): wrong file type" );
     553             :     }
     554             : 
     555           0 :     if ( aEndEditLink.IsSet() )
     556           0 :         aEndEditLink.Call( &sFile );
     557           0 :     return 0;
     558             : }
     559             : 
     560             : /*  [Description]
     561             : 
     562             :     The method determines whether the data-object can be read from a DDE.
     563             : 
     564             :     The following can be returned:
     565             :         ERRCODE_NONE                    if it has been completely read
     566             :         ERRCODE_SO_PENDING              if it has not been completely read
     567             :         ERRCODE_SO_FALSE                otherwise
     568             : */
     569          14 : sal_Bool SvFileObject::IsPending() const
     570             : {
     571          20 :     return FILETYPE_GRF == nType && !bLoadError &&
     572          20 :             ( pDownLoadData || bWaitForData );
     573             : }
     574          39 : sal_Bool SvFileObject::IsDataComplete() const
     575             : {
     576          39 :     sal_Bool bRet = sal_False;
     577          39 :     if( FILETYPE_GRF != nType )
     578           0 :         bRet = sal_True;
     579          39 :     else if( !bLoadError && ( !bWaitForData && !pDownLoadData ))
     580             :     {
     581           0 :         SvFileObject* pThis = (SvFileObject*)this;
     582           0 :         if( bDataReady ||
     583           0 :             ( bSynchron && pThis->LoadFile_Impl() && xMed.Is() ) )
     584           0 :             bRet = sal_True;
     585             :         else
     586             :         {
     587           0 :             INetURLObject aUrl( sFileNm );
     588           0 :             if( aUrl.HasError() ||
     589           0 :                 INET_PROT_NOT_VALID == aUrl.GetProtocol() )
     590           0 :                 bRet = sal_True;
     591             :         }
     592             :     }
     593          39 :     return bRet;
     594             : }
     595             : 
     596             : 
     597             : 
     598           4 : void SvFileObject::CancelTransfers()
     599             : {
     600             :     // unsubscribe from the cache if in the middle of loading
     601           4 :     if( !bDataReady )
     602             :     {
     603             :         // Do not set-up again
     604           1 :         bLoadAgain = sal_False;
     605           1 :         bDataReady = bLoadError = bWaitForData = sal_True;
     606           1 :         SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_ABORT );
     607             :     }
     608           4 : }
     609             : 
     610             : 
     611           7 : void SvFileObject::SendStateChg_Impl( sfx2::LinkManager::LinkState nState )
     612             : {
     613           7 :     if( !bStateChangeCalled && HasDataLinks() )
     614             :     {
     615           7 :         css::uno::Any aAny;
     616           7 :         aAny <<= OUString::valueOf( (sal_Int32)nState );
     617             :         DataChanged( SotExchange::GetFormatName(
     618           7 :                         sfx2::LinkManager::RegisterStatusInfoId()), aAny );
     619           7 :         bStateChangeCalled = sal_True;
     620             :     }
     621         415 : }
     622             : 
     623             : 
     624             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10