summaryrefslogtreecommitdiff
path: root/svtools/source/items/wallitem.cxx
blob: d45e9748e95050f9ee18e37bc0841f9c9d6ba467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
/*************************************************************************
 *
 *  $RCSfile: wallitem.cxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 16:59:01 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef _CPPUHELPER_WEAK_HXX_
#include <cppuhelper/weak.hxx>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATASOURCE_HPP_
#include <com/sun/star/io/XActiveDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XACTIVEDATACONTROL_HPP_
#include <com/sun/star/io/XActiveDataControl.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_CHAOS_WALLPAPER_HPP_
#include <com/sun/star/chaos/WallPaper.hpp>
#endif

#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_
#include <unotools/processfactory.hxx>
#endif

#include <tools/stream.hxx>
#include <tools/debug.hxx>
#include <tools/string.hxx>

#ifndef _URLOBJ_HXX //autogen wg. INetURLObject
#include <tools/urlobj.hxx>
#endif
#ifndef _STREAM_HXX //autogen wg. SvMemoryStream
#include <tools/stream.hxx>
#endif
#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif

#include <vcl/graph.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#ifndef _SV_GRADIENT_HXX
#include <vcl/gradient.hxx>
#endif
#ifndef _SV_CVTGRF_HXX //autogen wg. GraphicConverter
#include <vcl/cvtgrf.hxx>
#endif

#include "wallitem.hxx"
#include "cntwall.hxx"

#define WALLITEMFLAG_ERROR      0x0001
#define WALLITEMFLAG_DITHERED   0x0002


DBG_NAME( SfxWallpaperItem );
TYPEINIT1( SfxWallpaperItem, SfxPoolItem );

// -----------------------------------------------------------------------

class WallpaperSink_Impl: public cppu::OWeakObject,
                          public com::sun::star::io::XOutputStream
{
    com::sun::star::uno::Reference<
        com::sun::star::io::XActiveDataSource > _aSource;
    SvMemoryStream  *_pStream;
    WallpaperLoader *_pWallpaper;

public:

    WallpaperSink_Impl();
    virtual ~WallpaperSink_Impl();

    void RequestData( WallpaperLoader *pWallpaper, const String& rURL );
    void Release();

    // XInterface
    virtual com::sun::star::uno::Any SAL_CALL
    queryInterface( const com::sun::star::uno::Type& aType )
        throw( com::sun::star::uno::RuntimeException );
    virtual void SAL_CALL
    acquire()
        throw(::com::sun::star::uno::RuntimeException );
    virtual void SAL_CALL
    release()
        throw(::com::sun::star::uno::RuntimeException );

    // XOutputStream
    virtual void SAL_CALL
    writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData )
        throw( com::sun::star::io::NotConnectedException,
               com::sun::star::io::BufferSizeExceededException,
               com::sun::star::io::IOException,
               com::sun::star::uno::RuntimeException );
    virtual void SAL_CALL
    flush()
        throw( com::sun::star::io::NotConnectedException,
               com::sun::star::io::BufferSizeExceededException,
               com::sun::star::io::IOException,
                com::sun::star::uno::RuntimeException );
    virtual void SAL_CALL
    closeOutput()
        throw( com::sun::star::io::NotConnectedException,
               com::sun::star::io::BufferSizeExceededException,
               com::sun::star::io::IOException,
               com::sun::star::uno::RuntimeException );
};

// -----------------------------------------------------------------------

//static
void SfxBrushItemLink::Set( SfxBrushItemLink* pLink )
{
    SfxBrushItemLink** ppLink =  (SfxBrushItemLink**)GetAppData(SHL_BRUSHITEM);
    if( !*ppLink )
        *ppLink = pLink;
    else
        delete pLink;
}

// -----------------------------------------------------------------------

SfxWallpaperItem::SfxWallpaperItem( USHORT nWhich ) :
    SfxPoolItem( nWhich ), _nFlags(0)
{
    DBG_CTOR( SfxWallpaperItem, 0 );
}

SfxWallpaperItem::SfxWallpaperItem( USHORT nWhich, SvStream& rStream, USHORT nVersion )
    : SfxPoolItem( nWhich )
{
    DBG_CTOR( SfxWallpaperItem, 0 );
    _nFlags = 0;
    rStream >> _aWallpaper;
    readByteString(rStream, _aURL);
    readByteString(rStream, _aFilter);
}
// -----------------------------------------------------------------------

SfxWallpaperItem::SfxWallpaperItem( const SfxWallpaperItem& rItem ) :
    SfxPoolItem( rItem ),
    _aWallpaper( rItem._aWallpaper ),
    _aURL( rItem._aURL ),
    _nFlags( rItem._nFlags )
{
    DBG_CTOR( SfxWallpaperItem, 0 );
}

// -----------------------------------------------------------------------

SfxWallpaperItem::SfxWallpaperItem( USHORT nWhich, const Wallpaper& rPaper ) :
    SfxPoolItem( nWhich ), _nFlags(0), _aWallpaper( rPaper )
{
    DBG_CTOR( SfxWallpaperItem, 0 );
}

// -----------------------------------------------------------------------

SfxWallpaperItem::~SfxWallpaperItem()
{
    DBG_DTOR(SfxWallpaperItem, 0);
}

// -----------------------------------------------------------------------

int SfxWallpaperItem::operator==( const SfxPoolItem& rItem ) const
{
    DBG_CHKTHIS( SfxWallpaperItem, 0 );
    DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
    const SfxWallpaperItem& rWallItem = (const SfxWallpaperItem&)rItem;
    if( rWallItem._aURL != _aURL )
        return 0;
    if( !_aURL.Len() )
    {
        if( rWallItem._aWallpaper == _aWallpaper )
            return TRUE;
        return 0;
    }
    else
    {
        // Wenn eine URL gesetzt ist, sind die Items auch dann gleich, wenn
        // das eine Item bereits die Bitmap geladen hat und das andere nicht.
        // Deshalb kann der Wallpaper-Vergleichsoperator nicht benutzt werden.
        if( rWallItem._aWallpaper.GetColor() != _aWallpaper.GetColor() )
            return 0;
        if( rWallItem._aWallpaper.GetStyle() != _aWallpaper.GetStyle() )
            return 0;
        if( rWallItem._aWallpaper.GetGradient() != _aWallpaper.GetGradient() )
            return 0;
        if( rWallItem._aWallpaper.GetRect() != _aWallpaper.GetRect() )
            return 0;
    }
    return TRUE;
}

// -----------------------------------------------------------------------

SfxPoolItem* SfxWallpaperItem::Create( SvStream& rStream, USHORT nVersion) const
{
    DBG_CHKTHIS(SfxWallpaperItem, 0);
    return new SfxWallpaperItem( Which(), rStream, nVersion );
}

// -----------------------------------------------------------------------

SvStream& SfxWallpaperItem::Store( SvStream& rStream, USHORT ) const
{
    DBG_CHKTHIS( SfxWallpaperItem, 0 );
    BitmapEx aBmpTemp;
    if( _aURL.Len() )
    {
        // Bei gesetzter URL die Grafik als Link speichern, und deshalb
        // temporaer in der Wallpaper zuruecksetzen.
        aBmpTemp = _aWallpaper.GetBitmap();
        ((SfxWallpaperItem*)this)->_aWallpaper.SetBitmap();
    }
    rStream << _aWallpaper;
    writeByteString(rStream, _aURL);
    writeByteString(rStream, _aFilter);
    if( _aURL.Len() )
        ((SfxWallpaperItem*)this)->_aWallpaper.SetBitmap( aBmpTemp );
    return rStream;
}

// -----------------------------------------------------------------------

SfxPoolItem* SfxWallpaperItem::Clone( SfxItemPool* ) const
{
    DBG_CHKTHIS( SfxWallpaperItem, 0 );
    return new SfxWallpaperItem( *this );
}

// -----------------------------------------------------------------------

BOOL SfxWallpaperItem::QueryValue( com::sun::star::uno::Any& rVal,
                                   BYTE nMemberId ) const
{
    com::sun::star::chaos::WallPaper aVal;

    aVal.Style = (com::sun::star::chaos::WallpaperStyle)_aWallpaper.GetStyle();
    aVal.Color = (sal_Int32) _aWallpaper.GetColor().GetColor();
    aVal.ImageURL = GetBitmapURL();
    rVal <<= aVal;
    return TRUE;
}

// -----------------------------------------------------------------------

BOOL SfxWallpaperItem::PutValue( const com::sun::star::uno::Any& rVal,
                                 BYTE nMemberId )
{
    com::sun::star::chaos::WallPaper aVal;
    if ( rVal >>= aVal )
    {
        if ( aVal.ImageURL.getLength() )
            SetBitmapURL( aVal.ImageURL, GetBitmapFilter() );

        SetColor( aVal.Color );
        SetStyle( (WallpaperStyle)aVal.Style );

        return TRUE;
    }

    DBG_ERROR( "SfxWallpaperItem::PutValue - Wrong type!" );
    return FALSE;
}

// -----------------------------------------------------------------------

void SfxWallpaperItem::SetBitmapURL( const XubString& rURL, const String& rFilter )
{
    DBG_CHKTHIS(SfxWallpaperItem, 0);
    if( rURL != _aURL || rFilter != _aFilter )
    {
        _aURL = rURL;
        _aFilter = rFilter;
        _nFlags = 0;
        _aWallpaper.SetBitmap();
    }
}

// -----------------------------------------------------------------------

const Wallpaper& SfxWallpaperItem::GetWallpaper( BOOL bNeedsBitmap ) const
{
    DBG_CHKTHIS(SfxWallpaperItem, 0);
    if( bNeedsBitmap && !IsDownloaded() )
        ((SfxWallpaperItem*)this)->Download();
    if( !(_nFlags & WALLITEMFLAG_DITHERED ))
    {
        if( _aWallpaper.IsBitmap())
        {
            BitmapEx aBmp( _aWallpaper.GetBitmap() );
            OutputDevice* pOutDev = Application::GetDefaultDevice();

            if ( pOutDev->GetBitCount() <= 8 && aBmp.GetBitmap().GetBitCount() >= 8 )
            {
                aBmp.Dither( BMP_DITHER_MATRIX );
                aBmp = BitmapEx( aBmp.GetBitmap().CreateDisplayBitmap( pOutDev ), aBmp.GetMask() );
                ( (SfxWallpaperItem*)this )->_aWallpaper.SetBitmap( aBmp );
            }
        }
        ( (SfxWallpaperItem*)this )->_nFlags |= WALLITEMFLAG_DITHERED;
    }
    return _aWallpaper;
}

void SfxWallpaperItem::SetGraphic( const Graphic& rGraphic, BOOL bKeepLink )
{
    DBG_CHKTHIS(SfxWallpaperItem, 0);
    BitmapEx aBmp( rGraphic.GetBitmapEx() );
    _aWallpaper.SetBitmap( aBmp );
    if( !bKeepLink )
    {
        _aURL.Erase();
        _aFilter.Erase();
    }
    _nFlags &= ~( WALLITEMFLAG_ERROR | WALLITEMFLAG_DITHERED );
}

BOOL SfxWallpaperItem::IsDownloaded() const
{
    if( _nFlags & WALLITEMFLAG_ERROR )
        return TRUE;  // Endlos-Downloads verhindern
    return !_aURL.Len() || _aWallpaper.IsBitmap();
}

void SfxWallpaperItem::Download()
{
    if( _aURL.Len() )
    {
        SfxBrushItemLink* pLink = SfxBrushItemLink::Get();
        if( pLink )
        {
            Graphic aGraphic( pLink->GetGraphic( _aURL, _aFilter ) );
            if( aGraphic.GetType() != GRAPHIC_NONE )
            {
                BitmapEx aBmp( aGraphic.GetBitmapEx() );
                _aWallpaper.SetBitmap( aBmp );
                _nFlags &= ~WALLITEMFLAG_ERROR;
            }
            else
                _nFlags |= WALLITEMFLAG_ERROR;
        }
    }
    _nFlags &= ~WALLITEMFLAG_DITHERED;
}

//============================================================================
class WallpaperLoader_Impl
{
public:

    Link                _aDoneLink;
    SfxWallpaperItem    _aWallpaper;
    com::sun::star::uno::Reference<
        com::sun::star::io::XOutputStream > _xOutputStream;
    WallpaperSink_Impl* _pWallpaperSink;
    BOOL                _bDone;

    WallpaperLoader_Impl( const SfxWallpaperItem& rItem );
};

WallpaperLoader_Impl::WallpaperLoader_Impl( const SfxWallpaperItem& rWallpaper )
    : _aWallpaper( rWallpaper )
{
    _pWallpaperSink = NULL;
    _bDone = FALSE;
}

WallpaperLoader::WallpaperLoader( const CntWallpaperItem& rWallpaper )
{
    SfxWallpaperItem aSfxWallpaper( rWallpaper.Which() );

    aSfxWallpaper.SetBitmapURL( rWallpaper.GetBitmapURL(), String() );
    aSfxWallpaper.SetColor( rWallpaper.GetColor() );
    aSfxWallpaper.SetStyle( (WallpaperStyle) rWallpaper.GetStyle() );

    pImp = new WallpaperLoader_Impl( aSfxWallpaper );
}

WallpaperLoader::~WallpaperLoader()
{
    if ( !pImp->_bDone && pImp->_pWallpaperSink )
    {
        pImp->_pWallpaperSink->Release();
        pImp->_pWallpaperSink = NULL;
    }
    delete pImp;
}

void WallpaperLoader::RequestData( const Link& rDoneLink )
{
    WallpaperLoaderRef aRef( this );

    pImp->_aDoneLink = rDoneLink;

    if ( pImp->_aWallpaper.GetBitmapURL().Len() )
    {
        WallpaperSink_Impl *pStream = new WallpaperSink_Impl();
        pImp->_xOutputStream = pStream;
        pImp->_pWallpaperSink = pStream;
        pStream->RequestData( this, pImp->_aWallpaper.GetBitmapURL() );
    }
    else
        Done();
}

const Wallpaper& WallpaperLoader::GetWallpaper() const
{
    return pImp->_aWallpaper.GetWallpaper();
}

void WallpaperLoader::Done()
{
    WallpaperLoaderRef aRef( this );

    pImp->_bDone = TRUE;

    if ( pImp->_aDoneLink.IsSet() )
        pImp->_aDoneLink.Call( this );
}

void WallpaperLoader::SetBitmap( SvStream *pStream )
{
    WallpaperLoaderRef aRef( this );

    if( pStream && ! pStream->GetError() )
    {
        pStream->Seek( STREAM_SEEK_TO_BEGIN );
        Graphic aGraphic;
        GraphicConverter::Import( *pStream, aGraphic );

        if( aGraphic.GetType() != GRAPHIC_NONE )
        {
            pImp->_aWallpaper.SetGraphic( aGraphic, TRUE );
        }
    }

    Done();
}


//============================================================================

WallpaperSink_Impl::WallpaperSink_Impl()
{
    _pStream = NULL;
    _pWallpaper = NULL;
}

//--------------------------------------------------------------------------------------------------
// virtual
WallpaperSink_Impl::~WallpaperSink_Impl()
{
    delete _pStream;
}

//--------------------------------------------------------------------------------------------------
void WallpaperSink_Impl::RequestData( WallpaperLoader *pWallpaper,
                                      const String& rURL )
{
    _pWallpaper = pWallpaper;

    com::sun::star::uno::Reference<
        com::sun::star::lang::XMultiServiceFactory > xMgr(
            utl::getProcessServiceFactory() );
    if ( !xMgr.is() )
        return;

    com::sun::star::uno::Reference<
        com::sun::star::lang::XMultiServiceFactory > xFact(
                xMgr->createInstance(
                    rtl::OUString::createFromAscii(
                         "com.sun.star.frame.DataSourceFactory" ) ),
                com::sun::star::uno::UNO_QUERY );
    if ( xFact.is() )
    {
        INetURLObject aURL( rURL );
        com::sun::star::uno::Sequence< com::sun::star::uno::Any > aArgs( 1 );
        aArgs.getArray()[ 0 ] <<= rtl::OUString( aURL.GetMainURL() );

        String aProt( INetURLObject::GetScheme( aURL.GetProtocol() ) );
        _aSource = com::sun::star::uno::Reference<
                        com::sun::star::io::XActiveDataSource >(
                            xFact->createInstanceWithArguments(
                                aProt, aArgs ),
                            com::sun::star::uno::UNO_QUERY );
        if ( _aSource.is() )
        {
            _aSource->setOutputStream( this );
            com::sun::star::uno::Reference<
                com::sun::star::io::XActiveDataControl > aControl(
                    _aSource, com::sun::star::uno::UNO_QUERY );
            if ( aControl.is() )
                aControl->start();
        }
    }
}

//--------------------------------------------------------------------------------------------------
void WallpaperSink_Impl::Release()
{
    com::sun::star::uno::Reference<
                        com::sun::star::io::XOutputStream > aRef( this );

    _pWallpaper = NULL;

    if ( _aSource.is() )
    {
        com::sun::star::uno::Reference<
            com::sun::star::io::XActiveDataControl > aControl(
                _aSource, com::sun::star::uno::UNO_QUERY );
        if ( aControl.is() )
            aControl->terminate();

        _aSource = com::sun::star::uno::Reference<
                                com::sun::star::io::XActiveDataSource >();
    }
}

//--------------------------------------------------------------------------------------------------
// virtual
com::sun::star::uno::Any SAL_CALL WallpaperSink_Impl::
    queryInterface( const com::sun::star::uno::Type& aType )
        throw( com::sun::star::uno::RuntimeException )
{
    com::sun::star::uno::Any aRet
        = cppu::queryInterface( aType,
            static_cast< com::sun::star::io::XOutputStream * >( this ) );
    return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
}

//--------------------------------------------------------------------------------------------------
// virtual
void SAL_CALL WallpaperSink_Impl::acquire()
    throw(::com::sun::star::uno::RuntimeException )
{
    OWeakObject::acquire();
}

//--------------------------------------------------------------------------------------------------
// virtual
void SAL_CALL WallpaperSink_Impl::release()
    throw(::com::sun::star::uno::RuntimeException )
{
    OWeakObject::release();
}

//--------------------------------------------------------------------------------------------------
// virtual
void SAL_CALL WallpaperSink_Impl::writeBytes(
                    const com::sun::star::uno::Sequence< sal_Int8 >& aData )
    throw( com::sun::star::io::NotConnectedException,
           com::sun::star::io::BufferSizeExceededException,
           com::sun::star::io::IOException,
           com::sun::star::uno::RuntimeException )
{
    if ( !_pStream )
        _pStream = new SvMemoryStream( aData.getLength(), 4096 );

    _pStream->Seek( STREAM_SEEK_TO_END );
    _pStream->Write( aData.getConstArray(), aData.getLength() );
}

//--------------------------------------------------------------------------------------------------
// virtual
void SAL_CALL WallpaperSink_Impl::flush()
    throw( com::sun::star::io::NotConnectedException,
           com::sun::star::io::BufferSizeExceededException,
           com::sun::star::io::IOException,
            com::sun::star::uno::RuntimeException )
{
}

//--------------------------------------------------------------------------------------------------
// virtual
void SAL_CALL WallpaperSink_Impl::closeOutput()
    throw( com::sun::star::io::NotConnectedException,
           com::sun::star::io::BufferSizeExceededException,
           com::sun::star::io::IOException,
           com::sun::star::uno::RuntimeException )
{
    if ( _pWallpaper )
        _pWallpaper->SetBitmap( _pStream );

    _aSource = com::sun::star::uno::Reference<
                                com::sun::star::io::XActiveDataSource >();
}

////////////////////////////////////////////////////////////////////////////////
/*
    $Log: not supported by cvs2svn $
    Revision 1.23  2000/09/18 14:13:36  willem.vandorp
    OpenOffice header added.

    Revision 1.22  2000/08/31 13:41:29  willem.vandorp
    Header and footer replaced

    Revision 1.21  2000/06/30 11:35:56  pb
    chg: GetAppWindow() replaced

    Revision 1.20  2000/04/12 08:01:40  sb
    Adapted to Unicode.

    Revision 1.19  2000/03/22 11:49:38  kso
    Removed: SmartUno leftovers.

    Revision 1.18  2000/03/21 11:37:55  kso
    Added: [Put|QueryValue( ... com::sun::star::uno::Any ... )

    Revision 1.17  2000/02/09 16:24:16  hr
    #70473# changes for unicode ( patched by automated patchtool )

    Revision 1.16  2000/01/28 11:23:43  dv
    #70466# Changed service name

    Revision 1.15  1999/11/19 17:12:36  sb
    Module structure transposition.

    Revision 1.14  1999/10/26 12:46:30  dv
    Don't use GetGlobalServiceMgr() any longer

    Revision 1.13  1999/08/23 13:30:58  dv
    The CntWallpaperItem now uses the class Color

    Revision 1.12  1999/08/18 14:14:21  dv
    added: include cntwall.hxx

    Revision 1.11  1999/08/18 09:12:51  dv
    #66082# The WallpaperLoader is now constructed with a CntWallpaperItem

*/