summaryrefslogtreecommitdiff
path: root/svx/source/gallery2
diff options
context:
space:
mode:
authorKai Ahrens <ka@openoffice.org>2001-11-07 07:43:31 +0000
committerKai Ahrens <ka@openoffice.org>2001-11-07 07:43:31 +0000
commit8bc75aee64529d7f108d34aab0866f555002af95 (patch)
treedde128b849e1d8f0a276e01bfcc11fdf09602692 /svx/source/gallery2
parent90ddb0c280ac959481c411ecfc640561a580a3d9 (diff)
#94204#: save FmFormModels as XML files
Diffstat (limited to 'svx/source/gallery2')
-rw-r--r--svx/source/gallery2/codec.cxx278
-rw-r--r--svx/source/gallery2/codec.hxx25
-rw-r--r--svx/source/gallery2/galmisc.cxx74
-rw-r--r--svx/source/gallery2/galobj.cxx8
-rw-r--r--svx/source/gallery2/galtheme.cxx97
5 files changed, 160 insertions, 322 deletions
diff --git a/svx/source/gallery2/codec.cxx b/svx/source/gallery2/codec.cxx
index e54ac032c408..4a6b33c0bc77 100644
--- a/svx/source/gallery2/codec.cxx
+++ b/svx/source/gallery2/codec.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: codec.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:01:18 $
+ * last change: $Author: ka $ $Date: 2001-11-07 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,91 +59,71 @@
*
************************************************************************/
-
-#include <string.h>
#include <tools/stream.hxx>
-#include <tools/new.hxx>
-#include <svtools/fltdefs.hxx>
+#include <tools/zcodec.hxx>
#include "codec.hxx"
-#define SUBBUFFER_SIZE 8192
-
-#ifdef WIN
-typedef BYTE huge* HPBYTE;
-#else
-typedef BYTE* HPBYTE;
-#endif
+// ----------------
+// - GalleryCodec -
+// ----------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-RLECodec::RLECodec( SvStream& rIOStm ) : rStm( rIOStm )
+GalleryCodec::GalleryCodec( SvStream& rIOStm ) :
+ rStm( rIOStm )
{
}
+// -----------------------------------------------------------------------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-RLECodec::~RLECodec()
+GalleryCodec::~GalleryCodec()
{
}
+// -----------------------------------------------------------------------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-BOOL RLECodec::IsRLECoded( SvStream& rStm )
+BOOL GalleryCodec::IsCoded( SvStream& rStm, UINT32& rVersion )
{
const ULONG nPos = rStm.Tell();
- BOOL bRet = FALSE;
+ BOOL bRet;
BYTE cByte1, cByte2, cByte3, cByte4, cByte5, cByte6;
rStm >> cByte1 >> cByte2 >> cByte3 >> cByte4 >> cByte5 >> cByte6;
- if ( cByte1 == 'S' && cByte2 == 'V' && cByte3 == 'R' &&
- cByte4 == 'L' && cByte5 == 'E' && cByte6 == '1' )
+ if ( cByte1 == 'S' && cByte2 == 'V' && cByte3 == 'R' && cByte4 == 'L' && cByte5 == 'E' && ( cByte6 == '1' || cByte6 == '2' ) )
{
+ rVersion = ( ( cByte6 == '1' ) ? 1 : 2 );
bRet = TRUE;
}
+ else
+ {
+ rVersion = 0;
+ bRet = FALSE;
+ }
rStm.Seek( nPos );
return bRet;
}
+// -----------------------------------------------------------------------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-ULONG RLECodec::Write( SvMemoryStream& rStmToWrite )
+ULONG GalleryCodec::Write( SvMemoryStream& rStmToWrite )
{
- UINT32 nPos;
- UINT32 nCompSize;
+ UINT32 nPos, nCompSize;
rStmToWrite.Seek( STREAM_SEEK_TO_END );
const UINT32 nSize = rStmToWrite.Tell();
rStmToWrite.Seek( 0UL );
- rStm << 'S' << 'V' << 'R' << 'L' << 'E' << '1';
+ rStm << 'S' << 'V' << 'R' << 'L' << 'E' << '2';
rStm << nSize;
nPos = rStm.Tell();
rStm.SeekRel( 4UL );
- ImpWriteBuffer( (BYTE*) rStmToWrite.GetData(), nSize );
+ ZCodec aCodec;
+ aCodec.BeginCompression();
+ aCodec.Write( rStm, static_cast< const BYTE* >( rStmToWrite.GetData() ), nSize );
+ aCodec.EndCompression();
nCompSize = rStm.Tell() - nPos - 4UL;
rStm.Seek( nPos );
@@ -153,181 +133,43 @@ ULONG RLECodec::Write( SvMemoryStream& rStmToWrite )
return 0UL;
}
+// -----------------------------------------------------------------------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-ULONG RLECodec::Read( SvMemoryStream& rStmToRead )
+ULONG GalleryCodec::Read( SvMemoryStream& rStmToRead )
{
- UINT32 nReadBytes = 0UL;
+ UINT32 nVersion = 0;
+ UINT32 nReadBytes = 0;
- if ( IsRLECoded( rStm ) )
+ if( IsCoded( rStm, nVersion ) )
{
- UINT32 nCompressedSize;
+ BYTE* pUnCompressedBuffer = NULL;
+ UINT32 nCompressedSize, nUnCompressedSize;
rStm.SeekRel( 6 );
- rStm >> nReadBytes;
- rStm >> nCompressedSize;
-
- HPBYTE pReadBuffer = (HPBYTE) SvMemAlloc( nCompressedSize );
+ rStm >> nUnCompressedSize >> nCompressedSize;
- // komprimierte Bytefolge lesen
- rStm.Read( pReadBuffer, nCompressedSize );
+ // decompress
+ if( 1 == nVersion )
+ pUnCompressedBuffer = ImpReadRLEBuffer( rStm, nCompressedSize, nUnCompressedSize );
+ else if( 2 == nVersion )
+ pUnCompressedBuffer = ImpReadZBuffer( rStm, nCompressedSize, nUnCompressedSize );
- // Dekomprimieren
- rStmToRead.SetBuffer( (char*) ImpReadBuffer( pReadBuffer, nReadBytes ),
- nReadBytes, TRUE, nReadBytes );
-
- SvMemFree( pReadBuffer );
+ if( pUnCompressedBuffer )
+ rStmToRead.SetBuffer( reinterpret_cast< char* >( pUnCompressedBuffer ), nUnCompressedSize, TRUE, nUnCompressedSize );
}
return nReadBytes;
}
+// -----------------------------------------------------------------------------
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-void RLECodec::ImpWriteBuffer( BYTE* pInBuf, const ULONG nSize )
-{
- HPBYTE pTmpIn = (HPBYTE) pInBuf;
- const ULONG nCount = nSize / SUBBUFFER_SIZE;
- const ULONG nRest = nCount ? nSize % ( nCount * SUBBUFFER_SIZE ) : nSize;
-
- for( ULONG i = 0; i < nCount; i++ )
- ImpWriteSubBuffer( &pTmpIn[ i * SUBBUFFER_SIZE ], SUBBUFFER_SIZE );
-
- if ( nRest )
- ImpWriteSubBuffer( &pTmpIn[ nCount * SUBBUFFER_SIZE ], nRest );
-
- // BlockEnde schreiben
- rStm << (BYTE) 0;
- rStm << (BYTE) 1;
-}
-
-
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-void RLECodec::ImpWriteSubBuffer( BYTE* pInBuf, const ULONG nSize )
-{
- HPBYTE pTmpIn = (HPBYTE) pInBuf;
- HPBYTE pOutBuf = (HPBYTE) SvMemAlloc( nSize << 1 );
- HPBYTE pTmpOut = pOutBuf;
- ULONG nIndex = 0UL;
- ULONG nBufCount = 0UL;
- ULONG nSaveIndex;
- ULONG nCount;
- BYTE cPix;
- BYTE cLast;
- BOOL bFound;
-
- while( nIndex < nSize )
- {
- nCount = 1L;
- cPix = pTmpIn[ nIndex++ ];
-
- // Anzahl der aufeinanderf. gleichen Eintraege bestimmen
- while( ( nIndex < nSize ) && ( nCount < 255L ) && ( pTmpIn[ nIndex ] == cPix ) )
- {
- nIndex++;
- nCount++;
- }
-
- // gleiche Eintraege hintereinander werden kodiert geschrieben
- if ( nCount > 1 )
- {
- *pTmpOut++ = (BYTE) nCount;
- *pTmpOut++ = cPix;
- nBufCount += 2;
- }
- else
- {
- cLast = cPix;
- nSaveIndex = nIndex - 1;
- bFound = FALSE;
-
- // Anzahl der unterschiedlichen Eintraege bestimmen
- while( ( nIndex < nSize ) && ( nCount < 256L ) && ( ( cPix = pTmpIn[ nIndex ] ) != cLast ) )
- {
- nIndex++;
- nCount++;
- cLast = cPix;
- bFound = TRUE;
- }
-
- // Falls untersch. Eintrag gefunden, dec. wir den Index
- // da der letzte Index der erste der neuen Sequenz
- // sein soll
- if ( bFound )
- nIndex--;
-
- // mehrere untersch. Eintraege ueber abs. Coding schreiben
- if ( nCount > 3 )
- {
- // wir wollen nur so wenig wie moeglich
- // unterschiedliche Eintraege schreiben
- *pTmpOut++ = 0;
- *pTmpOut++ = (BYTE) --nCount;
-
- MEMCPY( pTmpOut, &pTmpIn[ nSaveIndex ], nCount );
- pTmpOut += nCount;
-
- // WORD-Alignment beachten
- if ( nCount & 1 )
- {
- *pTmpOut++ = 0;
- nBufCount += ( nCount + 3 );
- }
- else
- nBufCount += ( nCount + 2 );
- }
- else
- {
- *pTmpOut++ = 1;
- *pTmpOut++ = pTmpIn[ nSaveIndex ];
-
- if ( nCount == 3 )
- {
- *pTmpOut++ = 1;
- *pTmpOut++ = pTmpIn[ ++nSaveIndex ];
- nBufCount += 4;
- }
- else
- nBufCount += 2;
- }
- }
- }
-
- // Puffer schreiben
- rStm.Write( pOutBuf, nBufCount );
-
- // temp. Puffer wieder zerstoeren
- SvMemFree( pOutBuf );
-}
-
-
-/******************************************************************************
-|*
-|*
-|*
-\******************************************************************************/
-
-BYTE* RLECodec::ImpReadBuffer( BYTE* pStmBuf, const ULONG nSize )
+BYTE* GalleryCodec::ImpReadRLEBuffer( SvStream& rIStm, ULONG nCompressedSize, ULONG nUnCompressedSize )
{
- HPBYTE pInBuf = (HPBYTE) pStmBuf;
- HPBYTE pOutBuf = (HPBYTE) SvMemAlloc( nSize );
- HPBYTE pTmpBuf = pOutBuf;
- HPBYTE pLast = pOutBuf + nSize - 1;
+ BYTE* pCompressedBuffer = new BYTE[ nCompressedSize ]; rIStm.Read( pCompressedBuffer, nCompressedSize );
+ BYTE* pInBuf = pCompressedBuffer;
+ BYTE* pOutBuf = new BYTE[ nUnCompressedSize ];
+ BYTE* pTmpBuf = pOutBuf;
+ BYTE* pLast = pOutBuf + nUnCompressedSize - 1;
ULONG nIndex = 0UL;
ULONG nCountByte;
ULONG nRunByte;
@@ -344,7 +186,7 @@ BYTE* RLECodec::ImpReadBuffer( BYTE* pStmBuf, const ULONG nSize )
if ( nRunByte > 2 )
{
// absolutes Fuellen
- MEMCPY( &pTmpBuf[ nIndex ], pInBuf, nRunByte );
+ memcpy( &pTmpBuf[ nIndex ], pInBuf, nRunByte );
pInBuf += nRunByte;
nIndex += nRunByte;
@@ -359,11 +201,27 @@ BYTE* RLECodec::ImpReadBuffer( BYTE* pStmBuf, const ULONG nSize )
{
const BYTE cVal = *pInBuf++;
- MEMSET( &pTmpBuf[ nIndex ], cVal, nCountByte );
+ memset( &pTmpBuf[ nIndex ], cVal, nCountByte );
nIndex += nCountByte;
}
}
while ( !bEndDecoding && ( pTmpBuf <= pLast ) );
+ delete[] pCompressedBuffer;
+
+ return pOutBuf;
+}
+
+// -----------------------------------------------------------------------------
+
+BYTE* GalleryCodec::ImpReadZBuffer( SvStream& rIStm, ULONG nCompressedSize, ULONG nUnCompressedSize )
+{
+ ZCodec aCodec;
+ BYTE* pOutBuf = new BYTE[ nUnCompressedSize ];
+
+ aCodec.BeginCompression();
+ aCodec.Read( rIStm, pOutBuf, nUnCompressedSize );
+ aCodec.EndCompression();
+
return pOutBuf;
}
diff --git a/svx/source/gallery2/codec.hxx b/svx/source/gallery2/codec.hxx
index c901c8a8f890..91978ed36b14 100644
--- a/svx/source/gallery2/codec.hxx
+++ b/svx/source/gallery2/codec.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: codec.hxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:01:18 $
+ * last change: $Author: ka $ $Date: 2001-11-07 08:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,25 +61,28 @@
#include <tools/gen.hxx>
+// ----------------
+// - GalleryCodec -
+// ----------------
+
class SvStream;
class SvMemoryStreamStream;
-// ------------------------------------------------------------------------
-
-class RLECodec
+class GalleryCodec
{
+private:
+
SvStream& rStm;
- void ImpWriteBuffer( BYTE* pOutBuf, const ULONG nSize );
- void ImpWriteSubBuffer( BYTE* pOutBuf, const ULONG nSize );
- BYTE* ImpReadBuffer( BYTE* pInBuf, const ULONG nSize );
+ BYTE* ImpReadRLEBuffer( SvStream& rIStm, ULONG nCompressedSize, ULONG nUnCompressedSize );
+ BYTE* ImpReadZBuffer( SvStream& rIStm, ULONG nCompressedSize, ULONG nUnCompressedSize );
public:
- RLECodec( SvStream& rIOStm );
- ~RLECodec();
+ GalleryCodec( SvStream& rIOStm );
+ ~GalleryCodec();
ULONG Write( SvMemoryStream& rStmToWrite );
ULONG Read( SvMemoryStream& rStmToRead );
- static BOOL IsRLECoded( SvStream& rStm );
+ static BOOL IsCoded( SvStream& rStm, UINT32& rVersion );
};
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index f5058e4a2cf8..33dc94101320 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galmisc.cxx,v $
*
- * $Revision: 1.19 $
+ * $Revision: 1.20 $
*
- * last change: $Author: ka $ $Date: 2001-11-06 12:47:33 $
+ * last change: $Author: ka $ $Date: 2001-11-07 08:43:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -142,12 +142,12 @@ IMPL_LINK( SgaUserDataFactory, MakeUserData, SdrObjFactory*, pObjFactory )
return 0L;
}
-// -------------
-// - SGAImport -
-// -------------
+// ------------------------
+// - GalleryGraphicImport -
+// ------------------------
-USHORT SGAImport( const INetURLObject& rURL, Graphic& rGraphic,
- String& rFilterName, BOOL bShowProgress )
+USHORT GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic,
+ String& rFilterName, BOOL bShowProgress )
{
USHORT nRet = SGA_IMPORT_NONE;
SfxMedium aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ, TRUE );
@@ -176,44 +176,61 @@ USHORT SGAImport( const INetURLObject& rURL, Graphic& rGraphic,
return nRet;
}
-// -------------------
-// - SGASvDrawImport -
-// -------------------
+// -----------------------
+// - GallerySvDrawImport -
+// -----------------------
-BOOL SGASvDrawImport( SvStream& rIStm, FmFormModel& rModel )
+BOOL GallerySvDrawImport( SvStream& rIStm, FmFormModel& rModel )
{
- BOOL bRet;
+ UINT32 nVersion;
+ BOOL bRet;
- if ( RLECodec::IsRLECoded( rIStm ) )
+ if( GalleryCodec::IsCoded( rIStm, nVersion ) )
{
- SvMemoryStream aMemStm;
- RLECodec aCodec( rIStm );
+ SvMemoryStream aMemStm( 65535, 65535 );
+ GalleryCodec aCodec( rIStm );
aCodec.Read( aMemStm );
aMemStm.Seek( 0UL );
- bRet = SGASvDrawImport( aMemStm, rModel );
- }
+
+ if( 1 == nVersion )
+ {
+ // read as binary
+ SgaUserDataFactory aFactory;
+
+ aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rModel.SetStreamingSdrModel( TRUE );
+ rModel.GetItemPool().Load( aMemStm );
+ aMemStm >> rModel;
+ rModel.SetStreamingSdrModel( FALSE );
+ rModel.GetItemPool().LoadCompleted();
+ bRet = ( rIStm.GetError() == 0 );
+ }
+ else if( 2 == nVersion )
+ {
+ // recall to read as XML
+ bRet = GallerySvDrawImport( aMemStm, rModel );
+ }
+ }
else
{
- SgaUserDataFactory aFactory;
+ // read as XML
+ uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rIStm ) );
- rIStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ rModel.GetItemPool().SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
rModel.SetStreamingSdrModel( TRUE );
- rModel.GetItemPool().Load( rIStm );
- rIStm >> rModel;
+ bRet = SvxDrawingLayerImport( &rModel, xInputStream );
rModel.SetStreamingSdrModel( FALSE );
- rModel.GetItemPool().LoadCompleted();
- bRet = ( rIStm.GetError() == 0 );
}
return bRet;
}
-// ------------------
-// - SGAIsSoundFile -
-// ------------------
+// ----------------------
+// - GalleryIsSoundFile -
+// ----------------------
-BOOL SGAIsSoundFile( const INetURLObject& rURL )
+BOOL GalleryIsSoundFile( const INetURLObject& rURL )
{
DBG_ASSERT( rURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
@@ -573,6 +590,7 @@ void GalleryTransferable::InitData()
mpGraphicObject = new GraphicObject( aGraphic );
mpModel = new FmFormModel;
+ mpModel->GetItemPool().FreezeIdRanges();
if( !mpTheme->GetModel( mnObjectPos, *mpModel ) )
delete mpModel, mpModel = NULL;
@@ -602,8 +620,6 @@ void GalleryTransferable::AddSupportedFormats()
Graphic aGraphic;
ImageMap aImageMap;
- mpModel->GetItemPool().FreezeIdRanges();
-
if( CreateIMapGraphic( *mpModel, aGraphic, aImageMap ) )
{
delete mpGraphicObject, mpGraphicObject = new GraphicObject( aGraphic );
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index b138e6a7e5c5..ebc647d34194 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galobj.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: ka $ $Date: 2001-09-04 12:31:45 $
+ * last change: $Author: ka $ $Date: 2001-11-07 08:43:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -229,7 +229,7 @@ SgaObjectBmp::SgaObjectBmp( const INetURLObject& rURL )
Graphic aGraphic;
String aFilter;
- if ( SGA_IMPORT_NONE != SGAImport( rURL, aGraphic, aFilter ) )
+ if ( SGA_IMPORT_NONE != GalleryGraphicImport( rURL, aGraphic, aFilter ) )
Init( aGraphic, rURL );
}
@@ -418,7 +418,7 @@ SgaObjectSvDraw::SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL )
aModel.GetItemPool().FreezeIdRanges();
- if( SGASvDrawImport( rIStm, aModel ) )
+ if( GallerySvDrawImport( rIStm, aModel ) )
{
aURL = rURL;
bIsValid = CreateThumb( aModel );
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
index d58a2f5ff0b7..ac7d47129903 100644
--- a/svx/source/gallery2/galtheme.cxx
+++ b/svx/source/gallery2/galtheme.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: galtheme.cxx,v $
*
- * $Revision: 1.21 $
+ * $Revision: 1.22 $
*
- * last change: $Author: ka $ $Date: 2001-10-31 17:04:45 $
+ * last change: $Author: ka $ $Date: 2001-11-07 08:43:31 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -565,7 +565,7 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
{
aGraphic.Clear();
- if ( SGAImport( aURL, aGraphic, aFormat ) )
+ if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) )
{
SgaObject* pNewObj;
@@ -594,55 +594,19 @@ void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProg
}
else
{
- INetURLObject aURL( pEntry->aURL );
-
if ( aSvDrawStorageRef.Is() )
{
- const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
+ const String aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
SvStorageStreamRef pIStm = aSvDrawStorageRef->OpenStream( aStmName, STREAM_READ );
- if ( pIStm && !pIStm->GetError() )
+ if( pIStm && !pIStm->GetError() )
{
- SvMemoryStream aMemStm;
-
pIStm->SetBufferSize( 16384 );
- if ( !RLECodec::IsRLECoded( *pIStm ) )
- {
- const ULONG nSize = pIStm->Seek( STREAM_SEEK_TO_END );
- void* pBuffer = SvMemAlloc( nSize );
-
- pIStm->Seek( STREAM_SEEK_TO_BEGIN );
-
- if ( pBuffer && nSize )
- {
- pIStm->Read( pBuffer, nSize );
-
- pIStm->SetBufferSize( 0 );
- pIStm.Clear();
- pIStm = aSvDrawStorageRef->OpenStream( aStmName, STREAM_WRITE | STREAM_TRUNC );
- pIStm->SetBufferSize( 16384 );
- pIStm->Seek( STREAM_SEEK_TO_BEGIN );
-
- RLECodec aCodec( *pIStm );
-
- aMemStm.SetBuffer( (char*) pBuffer, nSize, FALSE, nSize );
- aCodec.Write( aMemStm );
+ SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
- SgaObjectSvDraw aNewObj( aMemStm, aURL );
- if( !InsertObject( aNewObj ) )
- pEntry->bDummy = TRUE;
- }
-
- if( pBuffer )
- SvMemFree( pBuffer );
- }
- else
- {
- SgaObjectSvDraw aNewObj( *pIStm, aURL );
- if( !InsertObject( aNewObj ) )
- pEntry->bDummy = TRUE;
- }
+ if( !InsertObject( aNewObj ) )
+ pEntry->bDummy = TRUE;
pIStm->SetBufferSize( 0L );
}
@@ -855,7 +819,7 @@ BOOL GalleryTheme::GetGraphic( ULONG nPos, Graphic& rGraphic, BOOL bProgress )
case( SGA_OBJ_INET ):
{
String aFilterDummy;
- bRet = ( SGAImport( aURL, rGraphic, aFilterDummy, bProgress ) != SGA_IMPORT_NONE );
+ bRet = ( GalleryGraphicImport( aURL, rGraphic, aFilterDummy, bProgress ) != SGA_IMPORT_NONE );
}
break;
@@ -1006,7 +970,7 @@ BOOL GalleryTheme::GetModel( ULONG nPos, FmFormModel& rModel, BOOL bProgress )
if( xIStm.Is() && !xIStm->GetError() )
{
xIStm->SetBufferSize( STREAMBUF_SIZE );
- bRet = SGASvDrawImport( *xIStm, rModel );
+ bRet = GallerySvDrawImport( *xIStm, rModel );
xIStm->SetBufferSize( 0L );
}
}
@@ -1031,30 +995,34 @@ BOOL GalleryTheme::InsertModel( const FmFormModel& rModel, ULONG nInsertPos )
if( xOStm.Is() && !xOStm->GetError() )
{
SvMemoryStream aMemStm( 65535, 65535 );
- RLECodec aCodec( *xOStm );
FmFormModel* pFormModel = (FmFormModel*) &rModel;
- aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
+ pFormModel->BurnInStyleSheetAttributes();
pFormModel->SetStreamingSdrModel( TRUE );
- pFormModel->PreSave();
- pFormModel->GetItemPool().SetFileFormatVersion( (USHORT) aMemStm.GetVersion() );
- pFormModel->GetItemPool().Store( aMemStm );
- aMemStm << *pFormModel;
- pFormModel->PostSave();
+ pFormModel->RemoveNotPersistentObjects( TRUE );
+
+ {
+ com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( aMemStm ) );
+
+ if( xDocOut.is() )
+ SvxDrawingLayerExport( pFormModel, xDocOut );
+ }
+
pFormModel->SetStreamingSdrModel( FALSE );
- aMemStm.Seek( 0L );
+ aMemStm.Seek( 0 );
- xOStm->SetBufferSize( STREAMBUF_SIZE );
+ xOStm->SetBufferSize( 16348 );
+ GalleryCodec aCodec( *xOStm );
aCodec.Write( aMemStm );
if( !xOStm->GetError() )
{
SgaObjectSvDraw aObjSvDraw( rModel, aURL );
- InsertObject( aObjSvDraw, nInsertPos );
- bRet = TRUE;
+ bRet = InsertObject( aObjSvDraw, nInsertPos );
}
xOStm->SetBufferSize( 0L );
+ xOStm->Commit();
}
}
@@ -1084,7 +1052,7 @@ BOOL GalleryTheme::InsertURL( const INetURLObject& rURL, ULONG nInsertPos )
Graphic aGraphic;
String aFormat;
SgaObject* pNewObj = NULL;
- const USHORT nImportRet = SGAImport( rURL, aGraphic, aFormat );
+ const USHORT nImportRet = GalleryGraphicImport( rURL, aGraphic, aFormat );
BOOL bRet = FALSE;
if( nImportRet != SGA_IMPORT_NONE )
@@ -1096,7 +1064,7 @@ BOOL GalleryTheme::InsertURL( const INetURLObject& rURL, ULONG nInsertPos )
else
pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, rURL, aFormat );
}
- else if( SGAIsSoundFile( rURL ) )
+ else if( GalleryIsSoundFile( rURL ) )
pNewObj = (SgaObject*) new SgaObjectSound( rURL );
if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )
@@ -1124,18 +1092,11 @@ BOOL GalleryTheme::InsertTransferable( const ::com::sun::star::uno::Reference< :
if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xModelStm ) )
{
- FmFormModel aModel;
- Reference< XInputStream > xInputStream( new utl::OInputStreamWrapper( *xModelStm ) );
+ FmFormModel aModel;
- aModel.GetItemPool().SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
aModel.GetItemPool().FreezeIdRanges();
- aModel.SetStreamingSdrModel( TRUE );
-
- xModelStm->Seek( 0 );
- bRet = SvxDrawingLayerImport( &aModel, xInputStream );
- aModel.SetStreamingSdrModel( FALSE );
- if( bRet )
+ if( GallerySvDrawImport( *xModelStm, aModel ) )
bRet = InsertModel( aModel, nInsertPos );
}
}