[Libreoffice-commits] core.git: editeng/source include/svx include/tools svtools/source svx/source tools/source vcl/source

Noel Grandin noel at peralex.com
Wed Jan 7 02:55:17 PST 2015


 editeng/source/items/bulitem.cxx   |    2 +-
 include/svx/svdmodel.hxx           |    1 -
 include/tools/stream.hxx           |   18 ++++++++++++------
 svtools/source/misc/transfer.cxx   |    2 +-
 svx/source/gallery2/galobj.cxx     |    6 +++---
 svx/source/svdraw/svdmodel.cxx     |    1 -
 svx/source/xml/xmlgrhlp.cxx        |    4 ++--
 tools/source/stream/stream.cxx     |    2 +-
 vcl/source/gdi/dibtools.cxx        |    2 +-
 vcl/source/gdi/gdimtf.cxx          |    4 ++--
 vcl/source/gdi/impgraph.cxx        |    6 +++---
 vcl/source/gdi/pdfwriter_impl2.cxx |    2 +-
 12 files changed, 27 insertions(+), 23 deletions(-)

New commits:
commit 306f04830300c239fd74677bcc61efcb5a4532ea
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Jan 7 11:53:42 2015 +0200

    fdo#84938: convert COMPRESSMODE_ #defines to 'enum class'
    
    Change-Id: Ica501fc73e7e5f9dbd30dd9da3f337b2dc7e6f02

diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx
index a0dd0ec..0936d98 100644
--- a/editeng/source/items/bulitem.cxx
+++ b/editeng/source/items/bulitem.cxx
@@ -328,7 +328,7 @@ SvStream& SvxBulletItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) c
         sal_Size _nStart = rStrm.Tell();
 
         // Small preliminary estimate of the size ...
-        sal_uInt16 nFac = ( rStrm.GetCompressMode() != COMPRESSMODE_NONE ) ? 3 : 1;
+        sal_uInt16 nFac = ( rStrm.GetCompressMode() != SvStreamCompressFlags::NONE ) ? 3 : 1;
         const Bitmap aBmp( pGraphicObject->GetGraphic().GetBitmap() );
         sal_uLong nBytes = aBmp.GetSizeBytes();
         if ( nBytes < sal_uLong(0xFF00*nFac) )
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index bbca710..30db1ef 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -205,7 +205,6 @@ protected:
     bool                bSaveNative:1;
     bool                bStarDrawPreviewMode:1;
     bool                mbDisableTextEditUsesCommonUndoManager:1;
-    sal_uInt16          nStreamCompressMode;  // write compressedly?
     SvStreamEndian      nStreamNumberFormat;
     sal_uInt16          nDefaultTabulator;
     sal_uInt32          nMaxUndoCount;
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index e80d097..59561de 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -79,9 +79,15 @@ namespace o3tl
 
 enum class SvStreamEndian { BIG, LITTLE };
 
-#define COMPRESSMODE_NONE               (sal_uInt16)0x0000
-#define COMPRESSMODE_ZBITMAP            (sal_uInt16)0x0001
-#define COMPRESSMODE_NATIVE             (sal_uInt16)0x0010
+enum class SvStreamCompressFlags {
+    NONE     = 0x0000,
+    ZBITMAP  = 0x0001,
+    NATIVE   = 0x0010,
+};
+namespace o3tl
+{
+    template<> struct typed_flags<SvStreamCompressFlags> : is_typed_flags<SvStreamCompressFlags, 0x0011> {};
+}
 
 class SvStream;
 
@@ -222,7 +228,7 @@ private:
     bool            bIsEof;
     sal_uInt32      nError;
     SvStreamEndian  nEndian;
-    sal_uInt16      nCompressMode;
+    SvStreamCompressFlags nCompressMode;
     LineEnd         eLineDelimiter;
     rtl_TextEncoding eStreamCharSet;
 
@@ -278,9 +284,9 @@ public:
     /// returns status of endian swap flag
     bool            IsEndianSwap() const { return bSwap; }
 
-    void            SetCompressMode( sal_uInt16 nNewMode )
+    void            SetCompressMode( SvStreamCompressFlags nNewMode )
                         { nCompressMode = nNewMode; }
-    sal_uInt16      GetCompressMode() const { return nCompressMode; }
+    SvStreamCompressFlags GetCompressMode() const { return nCompressMode; }
 
     void SetCryptMaskKey(const OString& rCryptMaskKey);
     const OString& GetCryptMaskKey() const { return m_aCryptMaskKey; }
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index 81defcc..d963953 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -801,7 +801,7 @@ bool TransferableHelper::SetGraphic( const Graphic& rGraphic, const DataFlavor&
         SvMemoryStream aMemStm( 65535, 65535 );
 
         aMemStm.SetVersion( SOFFICE_FILEFORMAT_50 );
-        aMemStm.SetCompressMode( COMPRESSMODE_NATIVE );
+        aMemStm.SetCompressMode( SvStreamCompressFlags::NATIVE );
         WriteGraphic( aMemStm, rGraphic );
         maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
     }
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index 4fe3e05..3205a9c 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -178,10 +178,10 @@ void SgaObject::WriteData( SvStream& rOut, const OUString& rDestDir ) const
 
     if( bIsThumbBmp )
     {
-        const sal_uInt16    nOldCompressMode = rOut.GetCompressMode();
-        const sal_uIntPtr       nOldVersion = rOut.GetVersion();
+        const SvStreamCompressFlags nOldCompressMode = rOut.GetCompressMode();
+        const sal_uIntPtr           nOldVersion = rOut.GetVersion();
 
-        rOut.SetCompressMode( COMPRESSMODE_ZBITMAP );
+        rOut.SetCompressMode( SvStreamCompressFlags::ZBITMAP );
         rOut.SetVersion( SOFFICE_FILEFORMAT_50 );
 
         WriteDIBBitmapEx(aThumbBmp, rOut);
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 84efe695..60aec94 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -154,7 +154,6 @@ void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbe
     bPasteResize=false;
     bNoBitmapCaching=false;
     bReadOnly=false;
-    nStreamCompressMode=COMPRESSMODE_NONE;
     nStreamNumberFormat=SvStreamEndian::BIG;
     nDefaultTabulator=0;
     mpNumberFormatter = NULL;
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 568d76b..07d475a 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -134,7 +134,7 @@ SvXMLGraphicInputStream::SvXMLGraphicInputStream( const OUString& rGraphicId )
                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
                 {
                     pStm->SetVersion( SOFFICE_FILEFORMAT_8 );
-                    pStm->SetCompressMode( COMPRESSMODE_ZBITMAP );
+                    pStm->SetCompressMode( SvStreamCompressFlags::ZBITMAP );
                     ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm );
                     bRet = ( pStm->GetError() == 0 );
                 }
@@ -554,7 +554,7 @@ bool SvXMLGraphicHelper::ImplWriteGraphic( const OUString& rPictureStorageName,
                 else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
                 {
                     pStream->SetVersion( SOFFICE_FILEFORMAT_8 );
-                    pStream->SetCompressMode( COMPRESSMODE_ZBITMAP );
+                    pStream->SetCompressMode( SvStreamCompressFlags::ZBITMAP );
 
                     // SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
                     GDIMetaFile& rMtf( (GDIMetaFile&)aGraphic.GetGDIMetaFile() );
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 4287fb7..19ebddf 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -378,7 +378,7 @@ void SvStream::SetSize(sal_uInt64 const nSize)
 void SvStream::ImpInit()
 {
     m_nActPos           = 0;
-    nCompressMode       = COMPRESSMODE_NONE;
+    nCompressMode       = SvStreamCompressFlags::NONE;
     eStreamCharSet      = osl_getThreadTextEncoding();
     nCryptMask          = 0;
     bIsEof              = false;
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index 054c070..d226edc 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -1259,7 +1259,7 @@ bool ImplWriteDIBBody(const Bitmap& rBitmap, SvStream& rOStm, BitmapReadAccess&
         }
     }
 
-    if((rOStm.GetCompressMode() & COMPRESSMODE_ZBITMAP) && (rOStm.GetVersion() >= SOFFICE_FILEFORMAT_40))
+    if((rOStm.GetCompressMode() & SvStreamCompressFlags::ZBITMAP) && (rOStm.GetVersion() >= SOFFICE_FILEFORMAT_40))
     {
         aHeader.nCompression = ZCOMPRESS;
     }
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 3a6159e..ac83c6d 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -2856,7 +2856,7 @@ SvStream& GDIMetaFile::Read( SvStream& rIStm )
 SvStream& GDIMetaFile::Write( SvStream& rOStm )
 {
     VersionCompat*   pCompat;
-    const sal_uInt32 nStmCompressMode = rOStm.GetCompressMode();
+    const SvStreamCompressFlags nStmCompressMode = rOStm.GetCompressMode();
     SvStreamEndian   nOldFormat = rOStm.GetEndian();
 
     rOStm.SetEndian( SvStreamEndian::LITTLE );
@@ -2864,7 +2864,7 @@ SvStream& GDIMetaFile::Write( SvStream& rOStm )
 
     pCompat = new VersionCompat( rOStm, StreamMode::WRITE, 1 );
 
-    rOStm.WriteUInt32( nStmCompressMode );
+    rOStm.WriteUInt32( static_cast<sal_uInt32>(nStmCompressMode) );
     WriteMapMode( rOStm, aPrefMapMode );
     WritePair( rOStm, aPrefSize );
     rOStm.WriteUInt32( GetActionSize() );
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 308d65d..d0b74f4 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1172,7 +1172,7 @@ bool ImpGraphic::ImplSwapOut()
             if( pOStm )
             {
                 pOStm->SetVersion( SOFFICE_FILEFORMAT_50 );
-                pOStm->SetCompressMode( COMPRESSMODE_NATIVE );
+                pOStm->SetCompressMode( SvStreamCompressFlags::NATIVE );
 
                 if( ( bRet = ImplSwapOut( pOStm.get() ) ) )
                 {
@@ -1271,7 +1271,7 @@ bool ImpGraphic::ImplSwapIn()
             if( pIStm )
             {
                 pIStm->SetVersion( SOFFICE_FILEFORMAT_50 );
-                pIStm->SetCompressMode( COMPRESSMODE_NATIVE );
+                pIStm->SetCompressMode( SvStreamCompressFlags::NATIVE );
 
                 bRet = ImplSwapIn( pIStm.get() );
                 pIStm.reset();
@@ -1580,7 +1580,7 @@ SvStream& WriteImpGraphic( SvStream& rOStm, const ImpGraphic& rImpGraphic )
         if( !rImpGraphic.ImplIsSwapOut() )
         {
             if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
-                ( rOStm.GetCompressMode() & COMPRESSMODE_NATIVE ) &&
+                ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
                 rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() )
             {
                 VersionCompat* pCompat;
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index c879934..73344f9 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -162,7 +162,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
                 sal_uInt32 nZippedFileSize;     // sj: we will calculate the filesize of a zipped bitmap
                 {                               // to determine if jpeg compression is useful
                     SvMemoryStream aTemp;
-                    aTemp.SetCompressMode( aTemp.GetCompressMode() | COMPRESSMODE_ZBITMAP );
+                    aTemp.SetCompressMode( aTemp.GetCompressMode() | SvStreamCompressFlags::ZBITMAP );
                     aTemp.SetVersion( SOFFICE_FILEFORMAT_40 );  // sj: up from version 40 our bitmap stream operator
                     WriteDIBBitmapEx(aBitmapEx, aTemp); // is capable of zlib stream compression
                     aTemp.Seek( STREAM_SEEK_TO_END );


More information about the Libreoffice-commits mailing list