diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-10-29 12:03:22 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-10-29 12:03:22 +0000 |
commit | 7f12e8de94b87d13f61233deb58e2ac90e50ad24 (patch) | |
tree | 2768d3096ee59754eac974d4909d32b0295fce5a /svtools/bmpmaker | |
parent | 4f976ce5f5ca31a3c6092891ff6b78ccfc415a19 (diff) |
CWS-TOOLING: integrate CWS bmpsum1
Diffstat (limited to 'svtools/bmpmaker')
-rw-r--r-- | svtools/bmpmaker/bmpgui.cxx | 424 | ||||
-rw-r--r-- | svtools/bmpmaker/bmpsum.cxx | 82 | ||||
-rw-r--r-- | svtools/bmpmaker/makefile.mk | 6 |
3 files changed, 57 insertions, 455 deletions
diff --git a/svtools/bmpmaker/bmpgui.cxx b/svtools/bmpmaker/bmpgui.cxx deleted file mode 100644 index 99e349e89bec..000000000000 --- a/svtools/bmpmaker/bmpgui.cxx +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: bmpgui.cxx,v $ - * $Revision: 1.17 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org 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 version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - -#include <stdio.h> -#include <signal.h> - -#include <sal/main.h> - -#include <vcl/svapp.hxx> -#include <vcl/window.hxx> -#include <vcl/wrkwin.hxx> -#include <vcl/dialog.hxx> -#include <vcl/menu.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/group.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/virdev.hxx> -#include <vcl/bmpacc.hxx> -#include <tools/config.hxx> - -#include "svtools/solar.hrc" -#include "filedlg.hxx" -#include "bmpcore.hxx" -#include "bmp.hrc" - -// ----------- -// - statics - -// ----------- - -static LangInfo aLangEntries[] = -{ - { "deut", 49 }, - { "enus", 1 }, - { "fren", 33 }, - { "ital", 39 }, - { "dtch", 31 }, - { "span", 34 }, - { "hung", 36 }, - { "estonian", 77}, - { "dan", 45 }, - { "swed", 46 }, - { "port", 03 }, - { "japn", 81 }, - { "chinsim", 86 }, - { "chintrad", 88 }, - { "hebrew", 97 }, - { "russ", 07 }, - { "pol", 48 }, - { "arab",96 }, - { "greek", 30 }, - { "catalan", 37}, - { "korean", 82 }, - { "turk", 90 }, - { "slovenian", 50 } -}; - -// ---------- -// - BmpApp - -// ---------- - -class BmpWin; - -static ResMgr* pAppResMgr = NULL; - -class BmpApp : public Application -{ -private: - - BmpWin* pBmpWin; - String aOutputFileName; - BYTE cExitCode; - - DECL_LINK( Select, Menu* pMenu ); - -public: - - void Main(); - void SetExitCode( BYTE cExit ) - { - if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) ) - cExitCode = cExit; - } -}; - -// ----------------------------------------------------------------------- - -BmpApp aBmpApp; - -// ---------- -// - Pathes - -// ---------- - -class Pathes : public ModalDialog -{ - OKButton aBtnOk; - CancelButton aBtnCancel; - GroupBox aGrpPath; - FixedText aFtSrs; - FixedText aFtRes; - FixedText aFtOut; - Edit aEdtSrs; - PushButton aBtnSrs; - Edit aEdtRes; - PushButton aBtnRes; - Edit aEdtOut; - PushButton aBtnOut; - GroupBox aGrpLang; - ListBox aLbLang; - - DECL_LINK( ClickSrsHdl, void* ); - DECL_LINK( ClickResHdl, void* ); - DECL_LINK( ClickOutHdl, void* ); - - -public: - - Pathes( Window* pParent, - const String& rSrsPath, - const String& rResPath, - const String& rOutPath, - const USHORT nLang ); - - String GetSrsPath() const { return aEdtSrs.GetText(); } - String GetResPath() const { return aEdtRes.GetText(); } - String GetOutPath() const { return aEdtOut.GetText(); } - - USHORT GetLangNum() const { return aLbLang.GetSelectEntryPos(); } -}; - -// ----------------------------------------------------------------------------- - -Pathes::Pathes( Window* pParent, - const String& rSrsPath, - const String& rResPath, - const String& rOutPath, - const USHORT nLang ) : - ModalDialog ( pParent, ResId( DLG_PATH, *pAppResMgr ) ), - aBtnOk ( this, ResId( BTN_OK, *pAppResMgr ) ), - aBtnCancel ( this, ResId( BTN_CANCEL, *pAppResMgr ) ), - aGrpPath ( this, ResId( GRP_PATH, *pAppResMgr ) ), - aFtSrs ( this, ResId( FT_SRS, *pAppResMgr ) ), - aFtRes ( this, ResId( FT_RES, *pAppResMgr ) ), - aFtOut ( this, ResId( FT_OUT, *pAppResMgr ) ), - aEdtSrs ( this, ResId( EDT_SRS, *pAppResMgr ) ), - aBtnSrs ( this, ResId( BTN_SRS, *pAppResMgr ) ), - aEdtRes ( this, ResId( EDT_RES, *pAppResMgr ) ), - aBtnRes ( this, ResId( BTN_RES, *pAppResMgr ) ), - aEdtOut ( this, ResId( EDT_OUT, *pAppResMgr ) ), - aBtnOut ( this, ResId( BTN_OUT, *pAppResMgr ) ), - aGrpLang ( this, ResId( GRP_LANG, *pAppResMgr ) ), - aLbLang ( this, ResId( LB_LANG, *pAppResMgr ) ) -{ - FreeResource(); - - aBtnSrs.SetClickHdl( LINK( this, Pathes, ClickSrsHdl ) ); - aBtnRes.SetClickHdl( LINK( this, Pathes, ClickResHdl ) ); - aBtnOut.SetClickHdl( LINK( this, Pathes, ClickOutHdl ) ); - - aEdtSrs.SetText( rSrsPath ); - aEdtRes.SetText( rResPath ); - aEdtOut.SetText( rOutPath ); - aEdtSrs.GrabFocus(); - - aLbLang.InsertEntry( String( RTL_CONSTASCII_USTRINGPARAM( "all" ) ), 0 ); - for( USHORT i = 1, nCount = ( sizeof( aLangEntries ) / sizeof( aLangEntries[ 0 ] ) ); i <= nCount; i++ ) - aLbLang.InsertEntry( String::CreateFromInt32( aLangEntries[ i - 1 ].mnLangNum ), i ); - - aLbLang.SelectEntryPos( nLang ); -} - -// ----------------------------------------------------------------------------- - -IMPL_LINK( Pathes, ClickSrsHdl, void*, EMPTYARG ) -{ - FileDialog aFileDlg( this, WB_OPEN | WB_3DLOOK ); - DirEntry aPath( aEdtSrs.GetText() ); - - aFileDlg.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "SRS-Datei mit Imagelisten laden" ) ) ); - aPath += DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "*.srs" ) ) ); - aFileDlg.SetPath( aPath.GetFull() ); - if ( aFileDlg.Execute() == RET_OK ) - aEdtSrs.SetText( aFileDlg.GetPath() ); - - return 0L; -} - -// ----------------------------------------------------------------------------- - -IMPL_LINK( Pathes, ClickResHdl, void*, EMPTYARG ) -{ - PathDialog aPathDlg( this, WB_OPEN | WB_3DLOOK ); - - aPathDlg.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Quellpfad BMP-Dateien" ) ) ); - if ( aPathDlg.Execute() == RET_OK ) - aEdtRes.SetText( aPathDlg.GetPath() ); - - return 0L; -} - -// ----------------------------------------------------------------------------- - -IMPL_LINK( Pathes, ClickOutHdl, void*, EMPTYARG ) -{ - PathDialog aPathDlg( this, WB_OPEN | WB_3DLOOK ); - - aPathDlg.SetText( String( RTL_CONSTASCII_USTRINGPARAM( "Zielpfad BMP-Dateien" ) ) ); - if ( aPathDlg.Execute() == RET_OK ) - aEdtOut.SetText( aPathDlg.GetPath() ); - - return 0L; -} - -// ---------- -// - BmpWin - -// ---------- - -class BmpWin : public WorkWindow, public BmpCreator -{ -private: - - ListBox aLB; - USHORT nPos; - -protected: - - virtual void Message( const String& rText, BYTE cExitCode = EXIT_NOERROR ); - -public: - - BmpWin(); - - void Resize(); - void SetMode( BOOL bMode ) { aLB.SetUpdateMode( bMode ); } - void ClearInfo(); -}; - -// ----------------------------------------------------------------------------- - -BmpWin::BmpWin() : - WorkWindow( NULL, WB_APP | WB_STDWORK ), - aLB( this, WB_HSCROLL | WB_VSCROLL ), - nPos( 0 ) -{ - SetText( String( RTL_CONSTASCII_USTRINGPARAM( "SVX - BmpMaker" ) ) ); - aLB.SetUpdateMode( TRUE ); - aLB.Show(); -} - -// ----------------------------------------------------------------------- - -void BmpWin::Resize() -{ - aLB.SetPosSizePixel( Point(), GetOutputSizePixel() ); -} - -// ----------------------------------------------------------------------- - -void BmpWin::Message( const String& rText, BYTE cExitCode ) -{ - aLB.InsertEntry( rText, nPos ); - aLB.SelectEntryPos( nPos++ ); - - if( EXIT_NOERROR != cExitCode ) - aBmpApp.SetExitCode( cExitCode ); - - ByteString aText( rText, RTL_TEXTENCODING_UTF8 ); -#ifdef UNX - aText.Append( "\r\n" ); -#else - aText.Append( "\n" ); -#endif - fprintf( stderr, aText.GetBuffer() ); -} - -// ----------------------------------------------------------------------- - -void BmpWin::ClearInfo() -{ - aLB.Clear(); - Invalidate(); - nPos = 0; -} - -// ---------- -// - BmpApp - -// ---------- - -void BmpApp::Main( ) -{ - // Param1: filename of *.srs input file with image lists - // Param2: path to local bitmaps - // Param3: output directory - // Param4: Langugage dependent directory - - pAppResMgr = ResMgr::CreateResMgr( "bmp" ); - MenuBar* pMB = new MenuBar(); - PopupMenu* pPB = new PopupMenu(); - String aLangDir; - String aOutName; - - cExitCode = EXIT_NOERROR; - - pMB->InsertItem( 1, String( RTL_CONSTASCII_USTRINGPARAM( "~ImageList" ) ) ); - pPB->InsertItem( 1, String( RTL_CONSTASCII_USTRINGPARAM( "~Erstellen..." ) ) ); - pPB->InsertSeparator(); - pPB->InsertItem( 2, String( RTL_CONSTASCII_USTRINGPARAM( "~Beenden" ) ) ); - - pMB->SetPopupMenu( 1, pPB ); - pMB->SetSelectHdl( LINK( this, BmpApp, Select ) ); - - pBmpWin = new BmpWin; - pBmpWin->SetMenuBar( pMB ); - pBmpWin->Show(); - - Execute(); - - delete pPB; - delete pMB; - delete pBmpWin; - - delete pAppResMgr; - pAppResMgr = NULL; - - if( ( EXIT_NOERROR == cExitCode ) && aOutputFileName.Len() && aOutName.Len() ) - { - SvFileStream aOStm( aOutputFileName, STREAM_WRITE | STREAM_TRUNC ); - ByteString aStr( "Successfully generated ImageList(s) in: " ); - - aOStm.WriteLine( aStr.Append( ByteString( aOutName, RTL_TEXTENCODING_UTF8 ) ) ); - aOStm.Close(); - } - - if( EXIT_NOERROR != cExitCode ) - raise( SIGABRT ); - - return; -} - -// ----------------------------------------------------------------------- - -IMPL_LINK( BmpApp, Select, Menu*, pMenu ) -{ - if ( pMenu->GetCurItemId() == 1 ) - { - Config aCfg; - aCfg.SetGroup( "Path-Entries" ); - - String aSrsPath( String::CreateFromAscii( aCfg.ReadKey( "SRS", ByteString() ).GetBuffer() ) ); - String aResPath( String::CreateFromAscii( aCfg.ReadKey( "RES", ByteString() ).GetBuffer() ) ); - String aOutPath( String::CreateFromAscii( aCfg.ReadKey( "OUT", ByteString() ).GetBuffer() ) ); - USHORT nLanguage = (USHORT) aCfg.ReadKey( "LNG", '1' ).ToInt32(); - Pathes aPathDlg( pBmpWin, aSrsPath, aResPath, aOutPath, nLanguage ); - - if ( aPathDlg.Execute() == RET_OK ) - { - ::std::vector< String > aInDirs; - - aCfg.WriteKey( "SRS", ByteString( aSrsPath = String( aPathDlg.GetSrsPath() ), RTL_TEXTENCODING_UTF8 ) ); - aCfg.WriteKey( "RES", ByteString( aResPath = String( aPathDlg.GetResPath() ), RTL_TEXTENCODING_UTF8 ) ); - aCfg.WriteKey( "OUT", ByteString( aOutPath = String( aPathDlg.GetOutPath() ), RTL_TEXTENCODING_UTF8 ) ); - aCfg.WriteKey( "LNG", ByteString::CreateFromInt32( nLanguage = aPathDlg.GetLangNum() ) ); - - pBmpWin->ClearInfo(); - - aInDirs.push_back( aResPath ); - - if( getenv( "SOLARSRC" ) ) - aInDirs.push_back( ::rtl::OUString::createFromAscii( getenv( "SOLARSRC" ) ) ); - - if( !nLanguage ) - { - for ( USHORT i = 0, nCount = ( sizeof( aLangEntries ) / sizeof( aLangEntries[ 0 ] ) ); i < nCount; i++ ) - pBmpWin->Create( aSrsPath, aInDirs, aOutPath, aLangEntries[ i ] ); - } - else - pBmpWin->Create( aSrsPath, aInDirs, aOutPath, aLangEntries[ nLanguage - 1 ] ); - } - } - else if( pMenu->GetCurItemId() == 2 ) - Quit(); - - return 0; -} - -BOOL SVMain(); - -SAL_IMPLEMENT_MAIN() -{ - SVMain(); - return 0; -} diff --git a/svtools/bmpmaker/bmpsum.cxx b/svtools/bmpmaker/bmpsum.cxx index 834008b6c42b..0633eb4c6a09 100644 --- a/svtools/bmpmaker/bmpsum.cxx +++ b/svtools/bmpmaker/bmpsum.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: bmpsum.cxx,v $ - * $Revision: 1.13 $ + * $Revision: 1.13.150.1 $ * * This file is part of OpenOffice.org. * @@ -31,8 +31,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svtools.hxx" -#include <stdio.h> -#include <signal.h> +#include <cstdio> +#include <csignal> #include <vector> #include <set> #include <map> @@ -46,7 +46,6 @@ #include <vcl/pngread.hxx> #include "svtools/solar.hrc" -#include "filedlg.hxx" #define EXIT_NOERROR 0x00000000 #define EXIT_INVALIDFILE 0x00000001 @@ -73,13 +72,13 @@ private: void ShowUsage(); void Message( const String& rText, BYTE cExitCode ); - sal_uInt64 GetCRC( Bitmap& rBmp ); + sal_uInt64 GetCRC( const BitmapEx& rBmpEx ); void ProcessFile( const String& rBmpFileName ); void ProcessFileList( const String& rInFileList, const String& rOutFileList, const String& rOutPath ); public: - +// BmpSum(); ~BmpSum(); @@ -220,11 +219,20 @@ int BmpSum::Start( const ::std::vector< String >& rArgs ) // ----------------------------------------------------------------------------- -sal_uInt64 BmpSum::GetCRC( Bitmap& rBmp ) +sal_uInt64 BmpSum::GetCRC( const BitmapEx& rBmpEx ) { - BitmapReadAccess* pRAcc = rBmp.AcquireReadAccess(); - sal_uInt64 nRet = 0; - sal_uInt32 nCrc = 0; + Bitmap aBmp( rBmpEx.GetBitmap() ); + BitmapReadAccess* pRAcc = aBmp.AcquireReadAccess(); + AlphaMask aAlpha; + BitmapReadAccess* pAAcc = NULL; + sal_uInt64 nRet = 0; + sal_uInt32 nCrc = 0; + + if( rBmpEx.IsTransparent() ) + { + aAlpha = rBmpEx.GetAlpha(); + pAAcc = aAlpha.AcquireReadAccess(); + } if( pRAcc && pRAcc->Width() && pRAcc->Height() ) { @@ -244,6 +252,20 @@ sal_uInt64 BmpSum::GetCRC( Bitmap& rBmp ) UInt32ToSVBT32( aCol.GetBlue(), aBT32 ); nCrc = rtl_crc32( nCrc, aBT32, 4 ); + + if( pAAcc ) + { + const BitmapColor aMaskCol( pAAcc->GetColor( nY, nX ) ); + + UInt32ToSVBT32( aMaskCol.GetRed(), aBT32 ); + nCrc = rtl_crc32( nCrc, aBT32, 4 ); + + UInt32ToSVBT32( aMaskCol.GetGreen(), aBT32 ); + nCrc = rtl_crc32( nCrc, aBT32, 4 ); + + UInt32ToSVBT32( aMaskCol.GetBlue(), aBT32 ); + nCrc = rtl_crc32( nCrc, aBT32, 4 ); + } } } @@ -252,7 +274,10 @@ sal_uInt64 BmpSum::GetCRC( Bitmap& rBmp ) ( (sal_uInt64) nCrc ); } - rBmp.ReleaseAccess( pRAcc ); + if( pAAcc ) + aAlpha.ReleaseAccess( pAAcc); + + aBmp.ReleaseAccess( pRAcc ); return nRet; } @@ -265,13 +290,13 @@ void BmpSum::ProcessFile( const String& rBmpFileName ) if( aIStm.IsOpen() ) { - Bitmap aBmp; + BitmapEx aBmpEx; - aIStm >> aBmp; + aIStm >> aBmpEx; - if( !aBmp.IsEmpty() ) + if( !aBmpEx.IsEmpty() ) { - fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmp ) ); + fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmpEx ) ); } else { @@ -280,11 +305,11 @@ void BmpSum::ProcessFile( const String& rBmpFileName ) ::vcl::PNGReader aPngReader( aIStm ); - aBmp = aPngReader.Read().GetBitmap(); + aBmpEx = aPngReader.Read(); - if( !aBmp.IsEmpty() ) + if( !aBmpEx.IsEmpty() ) { - fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmp ) ); + fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmpEx ) ); } else Message( String( RTL_CONSTASCII_USTRINGPARAM( "file not valid" ) ), EXIT_INVALIDFILE ); @@ -365,12 +390,12 @@ void BmpSum::ProcessFileList( const String& rInFileList, if( aBmpStm.IsOpen() ) { - Bitmap aBmp; + BitmapEx aBmpEx; - aBmpStm >> aBmp; + aBmpStm >> aBmpEx; - if( !aBmp.IsEmpty() ) - nCRC = GetCRC( aBmp ); + if( !aBmpEx.IsEmpty() ) + nCRC = GetCRC( aBmpEx ); else { aBmpStm.ResetError(); @@ -378,10 +403,10 @@ void BmpSum::ProcessFileList( const String& rInFileList, ::vcl::PNGReader aPngReader( aBmpStm ); - aBmp = aPngReader.Read().GetBitmap(); + aBmpEx = aPngReader.Read(); - if( !aBmp.IsEmpty() ) - nCRC = GetCRC( aBmp ); + if( !aBmpEx.IsEmpty() ) + nCRC = GetCRC( aBmpEx ); else fprintf( stderr, "%s could not be opened\n", aStr.GetBuffer() ); @@ -467,6 +492,13 @@ void BmpSum::ProcessFileList( const String& rInFileList, int main( int nArgCount, char* ppArgs[] ) { +#ifdef UNX + static char aDisplayVar[ 1024 ]; + + strcpy( aDisplayVar, "DISPLAY=" ); + putenv( aDisplayVar ); +#endif + ::std::vector< String > aArgs; BmpSum aBmpSum; diff --git a/svtools/bmpmaker/makefile.mk b/svtools/bmpmaker/makefile.mk index 57b6d6a9fd23..d5280a2ab500 100644 --- a/svtools/bmpmaker/makefile.mk +++ b/svtools/bmpmaker/makefile.mk @@ -43,16 +43,10 @@ ENABLE_EXCEPTIONS=true # --- Files -------------------------------------------------------- OBJFILES= $(OBJ)$/bmp.obj \ - $(OBJ)$/bmpgui.obj \ $(OBJ)$/bmpcore.obj \ $(OBJ)$/g2g.obj \ $(OBJ)$/bmpsum.obj -SRC1FILES=bmp.src -SRS1NAME=bmp -RES1TARGET=bmp -SRS1FILES=$(SRS)$/bmp.srs - # --- APP1TARGET --------------------------------------------------- APP1TARGET= $(TARGET) |