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 353 // #123042# for e.g. SVG the path is needed, see same TaskID in svx for more info 354 nRes = pGF->ImportGraphic( rGrf, sFileNm, *pStream, nFilter ); 355 } 356 else 357 { 358 nRes = pGF->ImportGraphic( pDownLoadData->aGrf, aEmptyStr, 359 *pStream, nFilter ); 360 361 if( pDownLoadData ) 362 { 363 rGrf = pDownLoadData->aGrf; 364 if( GRAPHIC_NONE == rGrf.GetType() ) 365 rGrf.SetDefaultType(); 366 367 368 if( !pDownLoadData->aGrf.GetContext() ) 369 { 370 xMed->SetDataAvailableLink( Link() ); 371 // xMed->SetDoneLink( Link() ); 372 delete pDownLoadData, pDownLoadData = 0; 373 bDataReady = sal_True; 374 bWaitForData = sal_False; 375 } 376 else if( sal_False ) 377 { 378 // Timer aufsetzen, um zurueck zukehren 379 pDownLoadData->aTimer.Start(); 380 } 381 } 382 } 383 384 if( pStream && ERRCODE_IO_PENDING == pStream->GetError() ) 385 pStream->ResetError(); 386 387 #ifdef DBG_UTIL 388 if( nRes ) 389 { 390 if( xMed.Is() && !pStream ) 391 { 392 DBG_WARNING3( "GrafikFehler [%d] - [%s] URL[%s]", 393 nRes, 394 xMed->GetPhysicalName().GetBuffer(), 395 sFileNm.GetBuffer() ); 396 } 397 else 398 { 399 DBG_WARNING2( "GrafikFehler [%d] - [%s]", 400 nRes, sFileNm.GetBuffer() ); 401 } 402 } 403 #endif 404 405 return GRFILTER_OK == nRes; 406 } 407 408 /** detect the filter of the given file 409 410 @param _rURL 411 specifies the URL of the file which filter is to detected.<br/> 412 If the URL doesn't denote a valid (existent and accessible) file, the 413 request is silently dropped. 414 */ 415 String impl_getFilter( const String& _rURL ) 416 { 417 String sFilter; 418 if ( _rURL.Len() == 0 ) 419 return sFilter; 420 421 try 422 { 423 css::uno::Reference< ::com::sun::star::document::XTypeDetection > xTypeDetection( 424 ::comphelper::getProcessServiceFactory()->createInstance( 425 ::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection") ), 426 css::uno::UNO_QUERY ); 427 if ( xTypeDetection.is() ) 428 { 429 ::comphelper::MediaDescriptor aDescr; 430 aDescr[ ::comphelper::MediaDescriptor::PROP_URL() ] <<= ::rtl::OUString( _rURL ); 431 css::uno::Sequence< css::beans::PropertyValue > aDescrList = 432 aDescr.getAsConstPropertyValueList(); 433 ::rtl::OUString sType = xTypeDetection->queryTypeByDescriptor( aDescrList, sal_True ); 434 if ( sType.getLength() ) 435 { 436 css::uno::Reference< css::container::XNameAccess > xTypeCont( xTypeDetection, 437 css::uno::UNO_QUERY ); 438 if ( xTypeCont.is() ) 439 { 440 ::comphelper::SequenceAsHashMap lTypeProps( xTypeCont->getByName( sType ) ); 441 sFilter = lTypeProps.getUnpackedValueOrDefault( 442 ::rtl::OUString::createFromAscii("PreferredFilter"), ::rtl::OUString() ); 443 } 444 } 445 } 446 } 447 catch( const css::uno::Exception& ) 448 { 449 } 450 451 return sFilter; 452 } 453 454 void SvFileObject::Edit( Window* pParent, sfx2::SvBaseLink* pLink, const Link& rEndEditHdl ) 455 { 456 aEndEditLink = rEndEditHdl; 457 String sFile, sRange, sTmpFilter; 458 if( pLink && pLink->GetLinkManager() ) 459 { 460 pLink->GetLinkManager()->GetDisplayNames( pLink, 0, &sFile, &sRange, &sTmpFilter ); 461 462 switch( pLink->GetObjType() ) 463 { 464 case OBJECT_CLIENT_GRF: 465 { 466 nType = FILETYPE_GRF; // falls noch nicht gesetzt 467 468 SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK)); 469 aDlg.EnableLink(sal_False); 470 aDlg.SetPath( sFile, sal_True ); 471 aDlg.SetCurrentFilter( sTmpFilter ); 472 473 if( !aDlg.Execute() ) 474 { 475 sFile = aDlg.GetPath(); 476 sFile += ::sfx2::cTokenSeperator; 477 sFile += ::sfx2::cTokenSeperator; 478 sFile += aDlg.GetCurrentFilter(); 479 480 if ( aEndEditLink.IsSet() ) 481 aEndEditLink.Call( &sFile ); 482 } 483 else 484 sFile.Erase(); 485 } 486 break; 487 488 case OBJECT_CLIENT_OLE: 489 { 490 nType = FILETYPE_OBJECT; // if not set already 491 pOldParent = Application::GetDefDialogParent(); 492 Application::SetDefDialogParent( pParent ); 493 494 ::sfx2::FileDialogHelper* pFileDlg = 495 pLink->GetFileDialog( (SFXWB_INSERT | WB_3DLOOK), String() ); 496 pFileDlg->StartExecuteModal( LINK( this, SvFileObject, DialogClosedHdl ) ); 497 } 498 break; 499 500 case OBJECT_CLIENT_FILE: 501 { 502 nType = FILETYPE_TEXT; // if not set already 503 pOldParent = Application::GetDefDialogParent(); 504 Application::SetDefDialogParent( pParent ); 505 506 String sFactory; 507 SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist(); 508 if ( pShell ) 509 sFactory = pShell->GetFactory().GetFactoryName(); 510 511 ::sfx2::FileDialogHelper* pFileDlg = 512 pLink->GetFileDialog( (SFXWB_INSERT | WB_3DLOOK), sFactory ); 513 pFileDlg->StartExecuteModal( LINK( this, SvFileObject, DialogClosedHdl ) ); 514 } 515 break; 516 517 default: 518 sFile.Erase(); 519 } 520 } 521 } 522 523 IMPL_STATIC_LINK( SvFileObject, LoadGrfReady_Impl, void*, EMPTYARG ) 524 { 525 // wenn wir von hier kommen, kann es kein Fehler mehr sein 526 pThis->bLoadError = sal_False; 527 pThis->bWaitForData = sal_False; 528 pThis->bInCallDownLoad = sal_False; 529 530 if( !pThis->bInNewData && !pThis->bDataReady ) 531 { 532 // Grafik ist fertig, also DataChanged von der Status- 533 // aederung schicken: 534 pThis->bDataReady = sal_True; 535 pThis->SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_OK ); 536 537 // und dann nochmal die Daten senden 538 pThis->NotifyDataChanged(); 539 } 540 541 if( pThis->bDataReady ) 542 { 543 pThis->bLoadAgain = sal_True; 544 if( pThis->xMed.Is() ) 545 { 546 pThis->xMed->SetDataAvailableLink( Link() ); 547 pThis->xMed->SetDoneLink( Link() ); 548 549 Application::PostUserEvent( 550 STATIC_LINK( pThis, SvFileObject, DelMedium_Impl ), 551 new SfxMediumRef( pThis->xMed )); 552 pThis->xMed.Clear(); 553 } 554 if( pThis->pDownLoadData ) 555 delete pThis->pDownLoadData, pThis->pDownLoadData = 0; 556 } 557 558 return 0; 559 } 560 561 IMPL_STATIC_LINK( SvFileObject, DelMedium_Impl, SfxMediumRef*, pDelMed ) 562 { 563 (void)pThis; 564 delete pDelMed; 565 return 0; 566 } 567 568 IMPL_STATIC_LINK( SvFileObject, LoadGrfNewData_Impl, void*, EMPTYARG ) 569 { 570 // wenn wir von hier kommen, kann es kein Fehler mehr sein 571 if( pThis->bInNewData ) 572 return 0; 573 574 pThis->bInNewData = sal_True; 575 pThis->bLoadError = sal_False; 576 577 if( !pThis->pDownLoadData ) 578 { 579 pThis->pDownLoadData = new Impl_DownLoadData( 580 STATIC_LINK( pThis, SvFileObject, LoadGrfNewData_Impl ) ); 581 582 // Null-Link setzen, damit keine temporaeren Grafiken 583 // rausgeswapt werden; der Filter prueft, ob schon 584 // ein Link gesetzt ist => falls dies zutrifft, wird 585 // _kein_ neuer Link gesetzt; der Link muss hier gesetzt werden, 586 // (bevor das erste Mal gefiltert wird), um zu verhindern, 587 // dass der Kontext zurueckgesetzt wird (aynchrones Laden) 588 if( !pThis->bNativFormat ) 589 { 590 static GfxLink aDummyLink; 591 pThis->pDownLoadData->aGrf.SetLink( aDummyLink ); 592 } 593 } 594 595 pThis->NotifyDataChanged(); 596 597 SvStream* pStrm = pThis->xMed.Is() ? pThis->xMed->GetInStream() : 0; 598 if( pStrm && pStrm->GetError() ) 599 { 600 if( ERRCODE_IO_PENDING == pStrm->GetError() ) 601 pStrm->ResetError(); 602 603 // im DataChanged ein DataReady? 604 else if( pThis->bWaitForData && pThis->pDownLoadData ) 605 { 606 pThis->bLoadError = sal_True; 607 } 608 } 609 610 if( pThis->bDataReady ) 611 { 612 // Grafik ist fertig, also DataChanged von der Status- 613 // aederung schicken: 614 pThis->SendStateChg_Impl( pStrm->GetError() ? sfx2::LinkManager::STATE_LOAD_ERROR : sfx2::LinkManager::STATE_LOAD_OK ); 615 } 616 617 pThis->bInNewData = sal_False; 618 return 0; 619 } 620 621 IMPL_LINK( SvFileObject, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) 622 { 623 String sFile; 624 Application::SetDefDialogParent( pOldParent ); 625 626 if ( FILETYPE_TEXT == nType || FILETYPE_OBJECT == nType ) 627 { 628 if ( _pFileDlg && _pFileDlg->GetError() == ERRCODE_NONE ) 629 { 630 String sURL( _pFileDlg->GetPath() ); 631 sFile = sURL; 632 sFile += ::sfx2::cTokenSeperator; 633 sFile += ::sfx2::cTokenSeperator; 634 sFile += impl_getFilter( sURL ); 635 } 636 } 637 else 638 { 639 DBG_ERRORFILE( "SvFileObject::DialogClosedHdl(): wrong file type" ); 640 } 641 642 if ( aEndEditLink.IsSet() ) 643 aEndEditLink.Call( &sFile ); 644 return 0; 645 } 646 647 /* [Beschreibung] 648 649 Die Methode stellt fest, ob aus einem DDE-Object die Daten gelesen 650 werden kann. 651 Zurueckgegeben wird: 652 ERRCODE_NONE wenn sie komplett gelesen wurde 653 ERRCODE_SO_PENDING wenn sie noch nicht komplett gelesen wurde 654 ERRCODE_SO_FALSE sonst 655 */ 656 sal_Bool SvFileObject::IsPending() const 657 { 658 return FILETYPE_GRF == nType && !bLoadError && 659 ( pDownLoadData || bWaitForData ); 660 } 661 sal_Bool SvFileObject::IsDataComplete() const 662 { 663 sal_Bool bRet = sal_False; 664 if( FILETYPE_GRF != nType ) 665 bRet = sal_True; 666 else if( !bLoadError && ( !bWaitForData && !pDownLoadData )) 667 { 668 SvFileObject* pThis = (SvFileObject*)this; 669 if( bDataReady || 670 ( bSynchron && pThis->LoadFile_Impl() && xMed.Is() ) ) 671 bRet = sal_True; 672 else 673 { 674 INetURLObject aUrl( sFileNm ); 675 if( aUrl.HasError() || 676 INET_PROT_NOT_VALID == aUrl.GetProtocol() ) 677 bRet = sal_True; 678 } 679 } 680 return bRet; 681 } 682 683 684 685 void SvFileObject::CancelTransfers() 686 { 687 // und aus dem Cache austragen, wenn man mitten im Laden ist 688 if( !bDataReady ) 689 { 690 // nicht noch mal aufsetzen 691 bLoadAgain = sal_False; 692 bDataReady = bLoadError = bWaitForData = sal_True; 693 SendStateChg_Impl( sfx2::LinkManager::STATE_LOAD_ABORT ); 694 } 695 } 696 697 698 void SvFileObject::SendStateChg_Impl( sfx2::LinkManager::LinkState nState ) 699 { 700 if( !bStateChangeCalled && HasDataLinks() ) 701 { 702 css::uno::Any aAny; 703 aAny <<= rtl::OUString::valueOf( (sal_Int32)nState ); 704 DataChanged( SotExchange::GetFormatName( 705 sfx2::LinkManager::RegisterStatusInfoId()), aAny ); 706 bStateChangeCalled = sal_True; 707 } 708 } 709 710 711