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

Generated by: LCOV version 1.10