summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2004-07-23 09:45:21 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2004-07-23 09:45:21 +0000
commitac79c51716bea463291cd4bb6621a3eff5aec43f (patch)
tree33bba129db67c264d6b889a622d4249439ccf8d4
parent20f26b55b9b8b589dbe5a54f1ca96f3d982f4a4b (diff)
INTEGRATION: CWS dba14 (1.34.32); FILE MERGED
2004/07/16 07:24:30 fs 1.34.32.2: #i31536# moved ControlGraphicsHelper to svtools, renamed to ImageResourceAccess 2004/07/15 15:08:12 fs 1.34.32.1: #i31536# allow displaying images specified by resource URLs, using the css.graphic.GraphicsProvider
-rw-r--r--forms/source/component/ImageControl.cxx52
1 files changed, 34 insertions, 18 deletions
diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx
index 86a088984b03..9b41dea4fdda 100644
--- a/forms/source/component/ImageControl.cxx
+++ b/forms/source/component/ImageControl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ImageControl.cxx,v $
*
- * $Revision: 1.34 $
+ * $Revision: 1.35 $
*
- * last change: $Author: hr $ $Date: 2004-05-10 12:46:08 $
+ * last change: $Author: rt $ $Date: 2004-07-23 10:45:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,6 +75,9 @@
#ifndef _FRM_SERVICES_HXX_
#include "services.hxx"
#endif
+#ifndef SVTOOLS_INC_IMAGERESOURCEACCESS_HXX
+#include <svtools/imageresourceaccess.hxx>
+#endif
#ifndef _UNTOOLS_UCBLOCKBYTES_HXX
#include <unotools/ucblockbytes.hxx>
#endif
@@ -142,6 +145,8 @@
#include <unotools/ucbstreamhelper.hxx>
#endif
+#include <memory>
+
#define ID_OPEN_GRAPHICS 1
#define ID_CLEAR_GRAPHICS 2
@@ -437,22 +442,35 @@ sal_Bool OImageControlModel::handleNewImageURL( const ::rtl::OUString& _rURL )
if ( !xSink.is() )
return sal_False;
- SvStream* pFileStream = ::utl::UcbStreamHelper::CreateStream( _rURL, STREAM_READ );
- sal_Bool bSetNull = (NULL == pFileStream) || (ERRCODE_NONE != pFileStream->GetErrorCode());
+ // create a stream for the image specified by the URL
+ ::std::auto_ptr< SvStream > pImageStream;
+ Reference< XInputStream > xImageStream;
+
+ if ( ::svt::ImageResourceAccess::isImageResourceURL( _rURL ) )
+ {
+ xImageStream = ::svt::ImageResourceAccess::getImageXStream( getORB(), _rURL );
+ }
+ else
+ {
+ pImageStream.reset( ::utl::UcbStreamHelper::CreateStream( _rURL, STREAM_READ ) );
+ sal_Bool bSetNull = ( pImageStream.get() == NULL ) || ( ERRCODE_NONE != pImageStream->GetErrorCode() );
+
+ if (!bSetNull)
+ {
+ // get the size of the stream
+ pImageStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = (sal_Int32)pImageStream->Tell();
+ if (pImageStream->GetBufferSize() < 8192)
+ pImageStream->SetBufferSize(8192);
+ pImageStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ xImageStream = new ::utl::OInputStreamHelper( new SvLockBytes( pImageStream.get(), sal_True ), nSize );
+ }
+ }
- if (!bSetNull)
+ if ( xImageStream.is() )
{
- // get the size of the stream
- pFileStream->Seek(STREAM_SEEK_TO_END);
- sal_Int32 nSize = (sal_Int32)pFileStream->Tell();
- if (pFileStream->GetBufferSize() < 8192)
- pFileStream->SetBufferSize(8192);
- pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
-
- Reference<XInputStream> xInput
- (new ::utl::OInputStreamHelper(new SvLockBytes(pFileStream, sal_True),
- nSize));
- xSink->setInputStream( xInput );
+ xSink->setInputStream( xImageStream );
Reference< XInputStream > xInStream(xSink, UNO_QUERY);
if ( m_xColumnUpdate.is() )
@@ -475,8 +493,6 @@ sal_Bool OImageControlModel::handleNewImageURL( const ::rtl::OUString& _rURL )
updateColumnWithStream( NULL );
else
setControlValue( Any() );
-
- delete pFileStream;
}
return sal_True;