xref: /aoo41x/main/sfx2/source/appl/fileobj.cxx (revision 45fd3b9a)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sfx2.hxx"
24 
25 #include <vcl/wrkwin.hxx>
26 #include <vcl/msgbox.hxx>
27 #include <tools/urlobj.hxx>
28 #include <tools/stream.hxx>
29 #include <sot/formats.hxx>
30 #include <svtools/filter.hxx>
31 #include <sfx2/lnkbase.hxx>
32 #include <sfx2/app.hxx>
33 #include <sfx2/progress.hxx>
34 #include <sfx2/docfilt.hxx>
35 #include <sfx2/filedlghelper.hxx>
36 #include <sot/exchange.hxx>
37 #include <com/sun/star/uno/Any.hxx>
38 #include <com/sun/star/uno/Sequence.hxx>
39 #include <sfx2/docfac.hxx>
40 #include <com/sun/star/document/XTypeDetection.hpp>
41 #include <comphelper/mediadescriptor.hxx>
42 #include <comphelper/processfactory.hxx>
43 #include <sfx2/linkmgr.hxx>
44 #include <sfx2/opengrf.hxx>
45 #include "sfx2/sfxresid.hxx"
46 #include "fileobj.hxx"
47 #include "app.hrc"
48 #include <vcl/dibtools.hxx>
49 
50 namespace css = ::com::sun::star;
51 
52 #define FILETYPE_TEXT		1
53 #define FILETYPE_GRF		2
54 #define FILETYPE_OBJECT		3
55 
56 struct Impl_DownLoadData
57 {
58 	Graphic aGrf;
59 	Timer aTimer;
60 
61 	Impl_DownLoadData( const Link& rLink )
62 	{
63 		aTimer.SetTimeout( 100 );
64 		aTimer.SetTimeoutHdl( rLink  );
65 		aGrf.SetDefaultType();
66 	}
67 	~Impl_DownLoadData()
68 	{
69 		aTimer.Stop();
70 	}
71 };
72 
73 // --------------------------------------------------------------------------
74 
75 
76 SvFileObject::SvFileObject() :
77 	pDownLoadData( NULL ), pOldParent( NULL ), nType( FILETYPE_TEXT )
78 {
79 	bLoadAgain = sal_True;
80 	bSynchron = bLoadError = bWaitForData = bDataReady = bNativFormat =
81 	bClearMedium = bStateChangeCalled = bInCallDownLoad = sal_False;
82 }
83 
84 
85 SvFileObject::~SvFileObject()
86 {
87 	if ( xMed.Is() )
88 	{
89 		xMed->SetDataAvailableLink( Link() );
90 		xMed->SetDoneLink( Link() );
91 		xMed.Clear();
92 	}
93 	delete pDownLoadData;
94 }
95 
96 
97 sal_Bool SvFileObject::GetData( ::com::sun::star::uno::Any & rData,
98 								const String & rMimeType,
99 								sal_Bool bGetSynchron )
100 {
101 	sal_uIntPtr nFmt = SotExchange::GetFormatStringId( rMimeType );
102 	switch( nType )
103 	{
104 	case FILETYPE_TEXT:
105 		if( FORMAT_FILE == nFmt )
106 		{
107 			// das Medium muss in der Applikation geoffnet werden, um die
108 			// relativen Datei Links aufzuloesen!!!! Wird ueber den
109 			// LinkManager und damit von dessen Storage erledigt.
110 			rData <<= rtl::OUString( sFileNm );
111 		}
112 		break;
113 
114 	case FILETYPE_GRF:
115 		if( !bLoadError )
116 		{
117 			SfxMediumRef xTmpMed;
118 
119 			if( FORMAT_GDIMETAFILE == nFmt || FORMAT_BITMAP == nFmt ||
120 				SOT_FORMATSTR_ID_SVXB == nFmt )
121 			{
122 				Graphic aGrf;
123 
124 				//JP 15.07.98: Bug 52959
125 				//		falls das Nativformat doch erwuenscht ist, muss am
126 				//		Ende das Flag zurueckgesetzt werden.
127 // wird einzig und allein im sw/ndgrf.cxx benutzt, wenn der Link vom
128 // GraphicNode entfernt wird.
129 				sal_Bool bOldNativFormat = bNativFormat;
130 //!!??				bNativFormat = 0 != (ASPECT_ICON & pSvData->GetAspect());
131 
132 				// falls gedruckt werden soll, warten wir bis die
133 				// Daten vorhanden sind
134 				if( bGetSynchron )
135 				{
136 					// testhalber mal ein LoadFile rufen um das nach-
137 					// laden ueberahaupt anzustossen
138 					if( !xMed.Is() )
139 						LoadFile_Impl();
140 
141 					if( !bInCallDownLoad )
142 					{
143 						xTmpMed = xMed;
144 						while( bWaitForData )
145 							Application::Reschedule();
146 
147 						xMed = xTmpMed;
148 						bClearMedium = sal_True;
149 					}
150 				}
151 
152 				if( pDownLoadData ||
153 					( !bWaitForData && ( xMed.Is() || 		// wurde als URL geladen
154 						( bSynchron && LoadFile_Impl() && xMed.Is() ) )) )
155 				{
156 					// falls
157 
158 					// falls es uebers Internet gesogen wurde, nicht
159 					// wieder versuchen
160 					if( !bGetSynchron )
161 						bLoadAgain = !xMed->IsRemote();
162 					bLoadError = !GetGraphic_Impl( aGrf, xMed->GetInStream() );
163 				}
164 				else if( !LoadFile_Impl() ||
165 						!GetGraphic_Impl( aGrf, xMed.Is() ? xMed->GetInStream() : 0 ))
166 				{
167 					if( !xMed.Is() )
168 						break;
169 					aGrf.SetDefaultType();
170 				}
171 
172 				if( SOT_FORMATSTR_ID_SVXB != nFmt )
173 					nFmt = (bLoadError || GRAPHIC_BITMAP == aGrf.GetType())
174 								? FORMAT_BITMAP
175 								: FORMAT_GDIMETAFILE;
176 
177 				SvMemoryStream aMemStm( 0, 65535 );
178 				switch ( nFmt )
179 				{
180 				case SOT_FORMATSTR_ID_SVXB:
181 					if( GRAPHIC_NONE != aGrf.GetType() )
182 					{
183 						aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
184 						aMemStm << aGrf;
185 					}
186 					break;
187 
188 				case  FORMAT_BITMAP:
189                 {
190                     const Bitmap aBitmap(aGrf.GetBitmap());
191 
192                     if(!aBitmap.IsEmpty())
193                     {
194                         WriteDIB(aBitmap, aMemStm, false, true);
195                     }
196 
197                     break;
198                 }
199 
200 				default:
201 					if( aGrf.GetGDIMetaFile().GetActionCount() )
202 					{
203 						GDIMetaFile aMeta( aGrf.GetGDIMetaFile() );
204 						aMeta.Write( aMemStm );
205 					}
206 				}
207                 rData <<= css::uno::Sequence< sal_Int8 >( (sal_Int8*) aMemStm.GetData(),
208 										aMemStm.Seek( STREAM_SEEK_TO_END ) );
209 
210 				bNativFormat = bOldNativFormat;
211 
212 				// alles fertig?
213 				if( xMed.Is() && !bSynchron && bClearMedium )
214 				{
215 					xMed.Clear();
216 					bClearMedium = sal_False;
217 				}
218 			}
219 		}
220 		break;
221 	case FILETYPE_OBJECT:
222 		// TODO/LATER: possibility to insert a new object
223 		rData <<= rtl::OUString( sFileNm );
224 		break;
225 	}
226 	return sal_True/*0 != aTypeList.Count()*/;
227 }
228 
229 
230 
231 
232 sal_Bool SvFileObject::Connect( sfx2::SvBaseLink* pLink )
233 {
234 	if( !pLink || !pLink->GetLinkManager() )
235 		return sal_False;
236 
237 	// teste doch mal, ob nicht ein anderer Link mit der gleichen
238 	// Verbindung schon existiert
239 	pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sFileNm, 0, &sFilter );
240 
241 	if( OBJECT_CLIENT_GRF == pLink->GetObjType() )
242 	{
243         SfxObjectShellRef pShell = pLink->GetLinkManager()->GetPersist();
244         if( pShell.Is() )
245 		{
246 			if( pShell->IsAbortingImport() )
247 				return sal_False;
248 
249 			if( pShell->GetMedium() )
250 				sReferer = pShell->GetMedium()->GetName();
251         }
252 	}
253 
254 	switch( pLink->GetObjType() )
255 	{
256 	case OBJECT_CLIENT_GRF:
257 		nType = FILETYPE_GRF;
258 		bSynchron = pLink->IsSynchron();
259 		break;
260 
261 	case OBJECT_CLIENT_FILE:
262 		nType = FILETYPE_TEXT;
263 		break;
264 
265 	case OBJECT_CLIENT_OLE:
266 		nType = FILETYPE_OBJECT;
267 		// TODO/LATER: introduce own type to be used for exchanging
268 		break;
269 
270 	default:
271 		return sal_False;
272 	}
273 
274 	SetUpdateTimeout( 0 );
275 
276 	// und jetzt bei diesem oder gefundenem Pseudo-Object anmelden
277 	AddDataAdvise( pLink, SotExchange::GetFormatMimeType( pLink->GetContentType()), 0 );
278 	return sal_True;
279 }
280 
281 
282 sal_Bool SvFileObject::LoadFile_Impl()
283 {
284 	// wir sind noch im Laden!!
285 	if( bWaitForData || !bLoadAgain || xMed.Is() || pDownLoadData )
286 		return sal_False;
287 
288 	// z.Z. nur auf die aktuelle DocShell
289 	xMed = new SfxMedium( sFileNm, STREAM_STD_READ, sal_True );
290     SvLinkSource::StreamToLoadFrom aStreamToLoadFrom =
291         getStreamToLoadFrom();
292     xMed->setStreamToLoadFrom(
293         aStreamToLoadFrom.m_xInputStreamToLoadFrom,
294         aStreamToLoadFrom.m_bIsReadOnly);
295 	// setStreamToLoadFrom(0,0);
296 	if( sReferer.Len() )
297 		xMed->SetReferer( sReferer );
298 
299 	if( !bSynchron )
300 	{
301 		bLoadAgain = bDataReady = bInNewData = sal_False;
302 		bWaitForData = sal_True;
303 
304 		SfxMediumRef xTmpMed = xMed;
305 		xMed->SetDataAvailableLink( STATIC_LINK( this, SvFileObject, LoadGrfNewData_Impl ) );
306 		bInCallDownLoad = sal_True;
307 		xMed->DownLoad( STATIC_LINK( this, SvFileObject, LoadGrfReady_Impl ) );
308 		bInCallDownLoad = sal_False;
309 
310 		bClearMedium = !xMed.Is();
311 		if( bClearMedium )
312 			xMed = xTmpMed;		// falls gleich im DownLoad schon schluss ist
313 		return bDataReady;
314 	}
315 
316 	bWaitForData = sal_True;
317 	bDataReady = bInNewData = sal_False;
318 	xMed->DownLoad();
319 	bLoadAgain = !xMed->IsRemote();
320 	bWaitForData = sal_False;
321 
322 	// Grafik ist fertig, also DataChanged von der Statusaederung schicken:
323 	SendStateChg_Impl( xMed->GetInStream() && xMed->GetInStream()->GetError()
324 						? sfx2::LinkManager::STATE_LOAD_ERROR : sfx2::LinkManager::STATE_LOAD_OK );
325 	return sal_True;
326 }
327 
328 
329 sal_Bool SvFileObject::GetGraphic_Impl( Graphic& rGrf, SvStream* pStream )
330 {
331 	GraphicFilter* pGF = GraphicFilter::GetGraphicFilter();
332 
333 	const sal_uInt16 nFilter = sFilter.Len() && pGF->GetImportFormatCount()
334 							? pGF->GetImportFormatNumber( sFilter )
335 							: GRFILTER_FORMAT_DONTKNOW;
336 
337 	String aEmptyStr;
338 	int nRes;
339 
340 	// vermeiden, dass ein native Link angelegt wird
341 	if( ( !pStream || !pDownLoadData ) && !rGrf.IsLink() &&
342 		!rGrf.GetContext() && !bNativFormat )
343 		rGrf.SetLink( GfxLink() );
344 
345 	if( !pStream )
346 		nRes = xMed.Is() ? GRFILTER_OPENERROR
347 						 : pGF->ImportGraphic( rGrf, INetURLObject(sFileNm),
348 							nFilter );
349 	else if( !pDownLoadData )
350 	{
351 		pStream->Seek( STREAM_SEEK_TO_BEGIN );
352 		nRes = pGF->ImportGraphic( rGrf, aEmptyStr, *pStream, nFilter );
353 	}
354 	else
355 	{
356 		nRes = pGF->ImportGraphic( pDownLoadData->aGrf, aEmptyStr,
357 									*pStream, nFilter );
358 
359 		if( pDownLoadData )
360 		{
361 			rGrf = pDownLoadData->aGrf;
362 			if( GRAPHIC_NONE == rGrf.GetType() )
363 				rGrf.SetDefaultType();
364 
365 
366 			if( !pDownLoadData->aGrf.GetContext() )
367 			{
368 				xMed->SetDataAvailableLink( Link() );
369 //				xMed->SetDoneLink( Link() );
370 				delete pDownLoadData, pDownLoadData = 0;
371 				bDataReady = sal_True;
372 				bWaitForData = sal_False;
373 			}
374 			else if( sal_False )
375 			{
376 				// Timer aufsetzen, um zurueck zukehren
377 				pDownLoadData->aTimer.Start();
378 			}
379 		}
380 	}
381 
382 	if( pStream && ERRCODE_IO_PENDING == pStream->GetError() )
383 		pStream->ResetError();
384 
385 #ifdef DBG_UTIL
386 	if( nRes )
387 	{
388 		if( xMed.Is() && !pStream )
389 		{
390 			DBG_WARNING3( "GrafikFehler [%d] - [%s] URL[%s]",
391 							nRes,
392 							xMed->GetPhysicalName().GetBuffer(),
393 							sFileNm.GetBuffer() );
394 		}
395 		else
396 		{
397 			DBG_WARNING2( "GrafikFehler [%d] - [%s]",
398 							nRes, sFileNm.GetBuffer() );
399 		}
400 	}
401 #endif
402 
403 	return GRFILTER_OK == nRes;
404 }
405 
406 /** detect the filter of the given file
407 
408     @param _rURL
409         specifies the URL of the file which filter is to detected.<br/>
410         If the URL doesn't denote a valid (existent and accessible) file, the
411         request is silently dropped.
412 */
413 String impl_getFilter( const String& _rURL )
414 {
415     String sFilter;
416     if ( _rURL.Len() == 0 )
417         return sFilter;
418 
419     try
420     {
421         css::uno::Reference< ::com::sun::star::document::XTypeDetection > xTypeDetection(
422             ::comphelper::getProcessServiceFactory()->createInstance(
423                 ::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection") ),
424                 css::uno::UNO_QUERY );
425         if ( xTypeDetection.is() )
426         {
427             ::comphelper::MediaDescriptor aDescr;
428             aDescr[ ::comphelper::MediaDescriptor::PROP_URL() ] <<= ::rtl::OUString( _rURL );
429             css::uno::Sequence< css::beans::PropertyValue > aDescrList =
430                 aDescr.getAsConstPropertyValueList();
431             ::rtl::OUString sType = xTypeDetection->queryTypeByDescriptor( aDescrList, sal_True );
432             if ( sType.getLength() )
433             {
434                 css::uno::Reference< css::container::XNameAccess > xTypeCont( xTypeDetection,
435                                                                               css::uno::UNO_QUERY );
436                 if ( xTypeCont.is() )
437                 {
438                     ::comphelper::SequenceAsHashMap lTypeProps( xTypeCont->getByName( sType ) );
439                     sFilter = lTypeProps.getUnpackedValueOrDefault(
440                         ::rtl::OUString::createFromAscii("PreferredFilter"), ::rtl::OUString() );
441                 }
442             }
443         }
444     }
445     catch( const css::uno::Exception& )
446     {
447     }
448 
449     return sFilter;
450 }
451 
452 void SvFileObject::Edit( Window* pParent, sfx2::SvBaseLink* pLink, const Link& rEndEditHdl )
453 {
454     aEndEditLink = rEndEditHdl;
455     String sFile, sRange, sTmpFilter;
456     if( pLink && pLink->GetLinkManager() )
457     {
458         pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sFile, &sRange, &sTmpFilter );
459 
460         switch( pLink->GetObjType() )
461         {
462             case OBJECT_CLIENT_GRF:
463             {
464                 nType = FILETYPE_GRF;       // falls noch nicht gesetzt
465 
466                 SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK));
467                 aDlg.EnableLink(sal_False);
468                 aDlg.SetPath( sFile, sal_True );
469                 aDlg.SetCurrentFilter( sTmpFilter );
470 
471                 if( !aDlg.Execute() )
472                 {
473                     sFile = aDlg.GetPath();
474                     sFile += ::sfx2::cTokenSeperator;
475                     sFile += ::sfx2::cTokenSeperator;
476                     sFile += aDlg.GetCurrentFilter();
477 
478                     if ( aEndEditLink.IsSet() )
479                         aEndEditLink.Call( &sFile );
480                 }
481                 else
482                     sFile.Erase();
483             }
484             break;
485 
486             case OBJECT_CLIENT_OLE:
487             {
488                 nType = FILETYPE_OBJECT; // if not set already
489                 pOldParent = Application::GetDefDialogParent();
490                 Application::SetDefDialogParent( pParent );
491 
492                 ::sfx2::FileDialogHelper* pFileDlg =
493                     pLink->GetFileDialog( (SFXWB_INSERT | WB_3DLOOK), String() );
494                 pFileDlg->StartExecuteModal( LINK( this, SvFileObject, DialogClosedHdl ) );
495             }
496             break;
497 
498             case OBJECT_CLIENT_FILE:
499             {
500                 nType = FILETYPE_TEXT; // if not set already
501                 pOldParent = Application::GetDefDialogParent();
502                 Application::SetDefDialogParent( pParent );
503 
504                 String sFactory;
505                 SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
506                 if ( pShell )
507                     sFactory = pShell->GetFactory().GetFactoryName();
508 
509                 ::sfx2::FileDialogHelper* pFileDlg =
510                     pLink->GetFileDialog( (SFXWB_INSERT | WB_3DLOOK), sFactory );
511                 pFileDlg->StartExecuteModal( LINK( this, SvFileObject, DialogClosedHdl ) );
512             }
513             break;
514 
515             default:
516                 sFile.Erase();
517         }
518 	}
519 }
520 
521 IMPL_STATIC_LINK( SvFileObject, LoadGrfReady_Impl, void*, EMPTYARG )
522 {
523 	// wenn wir von hier kommen, kann es kein Fehler mehr sein
524 	pThis->bLoadError = sal_False;
525 	pThis->bWaitForData = sal_False;
526 	pThis->bInCallDownLoad = sal_False;
527 
528 	if( !pThis->bInNewData && !pThis->bDataReady )
529 	{
530 			// Grafik ist fertig, also DataChanged von der Status-
531 			// aederung schicken:
532 		pThis->bDataReady = sal_True;
533 		pThis->SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_OK );
534 
535 			// und dann nochmal die Daten senden
536 		pThis->NotifyDataChanged();
537 	}
538 
539 	if( pThis->bDataReady )
540 	{
541 		pThis->bLoadAgain = sal_True;
542 		if( pThis->xMed.Is() )
543 		{
544 			pThis->xMed->SetDataAvailableLink( Link() );
545 			pThis->xMed->SetDoneLink( Link() );
546 
547 			Application::PostUserEvent(
548 						STATIC_LINK( pThis, SvFileObject, DelMedium_Impl ),
549 						new SfxMediumRef( pThis->xMed ));
550 			pThis->xMed.Clear();
551 		}
552 		if( pThis->pDownLoadData )
553 			delete pThis->pDownLoadData, pThis->pDownLoadData = 0;
554 	}
555 
556 	return 0;
557 }
558 
559 IMPL_STATIC_LINK( SvFileObject, DelMedium_Impl, SfxMediumRef*, pDelMed )
560 {
561 	(void)pThis;
562 	delete pDelMed;
563 	return 0;
564 }
565 
566 IMPL_STATIC_LINK( SvFileObject, LoadGrfNewData_Impl, void*, EMPTYARG )
567 {
568 	// wenn wir von hier kommen, kann es kein Fehler mehr sein
569 	if( pThis->bInNewData )
570 		return 0;
571 
572 	pThis->bInNewData = sal_True;
573 	pThis->bLoadError = sal_False;
574 
575 	if( !pThis->pDownLoadData )
576 	{
577 		pThis->pDownLoadData = new Impl_DownLoadData(
578 						STATIC_LINK( pThis, SvFileObject, LoadGrfNewData_Impl ) );
579 
580 		// Null-Link setzen, damit keine temporaeren Grafiken
581 		// rausgeswapt werden; der Filter prueft, ob schon
582 		// ein Link gesetzt ist => falls dies zutrifft, wird
583 		// _kein_ neuer Link gesetzt; der Link muss hier gesetzt werden,
584 		// (bevor das erste Mal gefiltert wird), um zu verhindern,
585 		// dass der Kontext zurueckgesetzt wird (aynchrones Laden)
586 		if( !pThis->bNativFormat )
587 		{
588 			static GfxLink aDummyLink;
589 			pThis->pDownLoadData->aGrf.SetLink( aDummyLink );
590 		}
591 	}
592 
593 	pThis->NotifyDataChanged();
594 
595 	SvStream* pStrm = pThis->xMed.Is() ? pThis->xMed->GetInStream() : 0;
596 	if( pStrm && pStrm->GetError() )
597 	{
598 		if( ERRCODE_IO_PENDING == pStrm->GetError() )
599 			pStrm->ResetError();
600 
601 		// im DataChanged ein DataReady?
602 		else if( pThis->bWaitForData && pThis->pDownLoadData )
603 		{
604 			pThis->bLoadError = sal_True;
605 		}
606 	}
607 
608 	if( pThis->bDataReady )
609 	{
610 		// Grafik ist fertig, also DataChanged von der Status-
611 		// aederung schicken:
612 		pThis->SendStateChg_Impl( pStrm->GetError() ? sfx2::LinkManager::STATE_LOAD_ERROR : sfx2::LinkManager::STATE_LOAD_OK );
613 	}
614 
615 	pThis->bInNewData = sal_False;
616 	return 0;
617 }
618 
619 IMPL_LINK( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
620 {
621     String sFile;
622     Application::SetDefDialogParent( pOldParent );
623 
624     if ( FILETYPE_TEXT == nType || FILETYPE_OBJECT == nType )
625     {
626         if ( _pFileDlg && _pFileDlg->GetError() == ERRCODE_NONE )
627         {
628             String sURL( _pFileDlg->GetPath() );
629             sFile = sURL;
630             sFile += ::sfx2::cTokenSeperator;
631             sFile += ::sfx2::cTokenSeperator;
632             sFile += impl_getFilter( sURL );
633         }
634     }
635     else
636     {
637         DBG_ERRORFILE( "SvFileObject::DialogClosedHdl(): wrong file type" );
638     }
639 
640     if ( aEndEditLink.IsSet() )
641         aEndEditLink.Call( &sFile );
642     return 0;
643 }
644 
645 /*	[Beschreibung]
646 
647 	Die Methode stellt fest, ob aus einem DDE-Object die Daten gelesen
648 	werden kann.
649 	Zurueckgegeben wird:
650 		ERRCODE_NONE 			wenn sie komplett gelesen wurde
651 		ERRCODE_SO_PENDING		wenn sie noch nicht komplett gelesen wurde
652 		ERRCODE_SO_FALSE		sonst
653 */
654 sal_Bool SvFileObject::IsPending() const
655 {
656 	return FILETYPE_GRF == nType && !bLoadError &&
657 			( pDownLoadData || bWaitForData );
658 }
659 sal_Bool SvFileObject::IsDataComplete() const
660 {
661 	sal_Bool bRet = sal_False;
662 	if( FILETYPE_GRF != nType )
663 		bRet = sal_True;
664 	else if( !bLoadError && ( !bWaitForData && !pDownLoadData ))
665 	{
666 		SvFileObject* pThis = (SvFileObject*)this;
667 		if( bDataReady ||
668 			( bSynchron && pThis->LoadFile_Impl() && xMed.Is() ) )
669 			bRet = sal_True;
670 		else
671 		{
672 			INetURLObject aUrl( sFileNm );
673 			if( aUrl.HasError() ||
674 				INET_PROT_NOT_VALID == aUrl.GetProtocol() )
675 				bRet = sal_True;
676 		}
677 	}
678 	return bRet;
679 }
680 
681 
682 
683 void SvFileObject::CancelTransfers()
684 {
685 	// und aus dem Cache austragen, wenn man mitten im Laden ist
686 	if( !bDataReady )
687 	{
688 		// nicht noch mal aufsetzen
689 		bLoadAgain = sal_False;
690 		bDataReady = bLoadError = bWaitForData = sal_True;
691 		SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_ABORT );
692 	}
693 }
694 
695 
696 void SvFileObject::SendStateChg_Impl( sfx2::LinkManager::LinkState nState )
697 {
698 	if( !bStateChangeCalled && HasDataLinks() )
699 	{
700         css::uno::Any aAny;
701 		aAny <<= rtl::OUString::valueOf( (sal_Int32)nState );
702 		DataChanged( SotExchange::GetFormatName(
703 						sfx2::LinkManager::RegisterStatusInfoId()), aAny );
704 		bStateChangeCalled = sal_True;
705 	}
706 }
707 
708 
709