summaryrefslogtreecommitdiff
path: root/svtools/bmpmaker
diff options
context:
space:
mode:
Diffstat (limited to 'svtools/bmpmaker')
-rw-r--r--svtools/bmpmaker/bmp.cxx248
-rw-r--r--svtools/bmpmaker/bmp.hrc44
-rw-r--r--svtools/bmpmaker/bmp.src116
-rw-r--r--svtools/bmpmaker/bmpcore.cxx420
-rw-r--r--svtools/bmpmaker/bmpcore.hxx97
-rw-r--r--svtools/bmpmaker/bmpsum.cxx508
-rw-r--r--svtools/bmpmaker/g2g.cxx251
-rw-r--r--svtools/bmpmaker/makefile.mk74
8 files changed, 1758 insertions, 0 deletions
diff --git a/svtools/bmpmaker/bmp.cxx b/svtools/bmpmaker/bmp.cxx
new file mode 100644
index 000000000000..5b473b0289c2
--- /dev/null
+++ b/svtools/bmpmaker/bmp.cxx
@@ -0,0 +1,248 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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"
+
+#ifndef INCLUDED_RTL_MATH_HXX
+#include <rtl/math.hxx>
+#endif
+
+#include <math.h>
+#include <stdio.h>
+#include <signal.h>
+#include <vector>
+using namespace std;
+
+#include <vcl/svapp.hxx>
+
+#include "svl/solar.hrc"
+#include "filedlg.hxx"
+#include "bmpcore.hxx"
+#include "bmp.hrc"
+
+// ----------
+// - BmpApp -
+// ----------
+
+class BmpApp : public BmpCreator
+{
+private:
+
+ String aOutputFileName;
+ BYTE cExitCode;
+
+ BOOL GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rSwitchParam );
+ BOOL GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rSwitchParams );
+
+ void SetExitCode( BYTE cExit )
+ {
+ if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) )
+ cExitCode = cExit;
+ }
+ void ShowUsage();
+
+ virtual void Message( const String& rText, BYTE cExitCode );
+
+public:
+
+ BmpApp();
+ ~BmpApp();
+
+ int Start( const ::std::vector< String >& rArgs );
+};
+
+// -----------------------------------------------------------------------------
+
+BmpApp::BmpApp()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+BmpApp::~BmpApp()
+{
+}
+
+// -----------------------------------------------------------------------
+
+BOOL BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam )
+{
+ BOOL bRet = FALSE;
+
+ for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ )
+ {
+ String aTestStr( '-' );
+
+ for( int n = 0; ( n < 2 ) && !bRet; n++ )
+ {
+ aTestStr += rSwitch;
+
+ if( aTestStr.CompareIgnoreCaseToAscii( rArgs[ i ] ) == COMPARE_EQUAL )
+ {
+ bRet = TRUE;
+
+ if( i < ( nCount - 1 ) )
+ rParam = rArgs[ i + 1 ];
+ else
+ rParam = String();
+ }
+
+ if( 0 == n )
+ aTestStr = '/';
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL BmpApp::GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rParams )
+{
+ BOOL bRet = FALSE;
+
+ for( int i = 0, nCount = rArgs.size(); ( i < nCount ); i++ )
+ {
+ String aTestStr( '-' );
+
+ for( int n = 0; ( n < 2 ) && !bRet; n++ )
+ {
+ aTestStr += rSwitch;
+
+ if( aTestStr.CompareIgnoreCaseToAscii( rArgs[ i ] ) == COMPARE_EQUAL )
+ {
+ if( i < ( nCount - 1 ) )
+ rParams.push_back( rArgs[ i + 1 ] );
+ else
+ rParams.push_back( String() );
+
+ break;
+ }
+
+ if( 0 == n )
+ aTestStr = '/';
+ }
+ }
+
+ return( rParams.size() > 0 );
+}
+
+// -----------------------------------------------------------------------
+
+void BmpApp::Message( const String& rText, BYTE cExit )
+{
+ if( EXIT_NOERROR != cExit )
+ SetExitCode( cExit );
+
+ ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
+ aText.Append( "\r\n" );
+ fprintf( stderr, aText.GetBuffer() );
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpApp::ShowUsage()
+{
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Usage:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmp srs_inputfile output_dir lang_dir lang_num -i input_dir [-i input_dir ][-f err_file]" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Options:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " -i ... name of directory to be searched for input files [multiple occurence is possible]" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " -f name of file, output should be written to" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Examples:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmp /home/test.srs /home/out enus 01 -i /home/res -f /home/out/bmp.err" ) ), EXIT_NOERROR );
+}
+
+// -----------------------------------------------------------------------------
+
+int BmpApp::Start( const ::std::vector< String >& rArgs )
+{
+ String aOutName;
+
+ cExitCode = EXIT_NOERROR;
+
+ if( rArgs.size() >= 6 )
+ {
+ LangInfo aLangInfo;
+ USHORT nCurCmd = 0;
+ const String aSrsName( rArgs[ nCurCmd++ ] );
+ ::std::vector< String > aInDirVector;
+ ByteString aLangDir;
+
+ aOutName = rArgs[ nCurCmd++ ];
+
+ aLangDir = ByteString( rArgs[ nCurCmd++ ], RTL_TEXTENCODING_ASCII_US );
+ aLangInfo.mnLangNum = static_cast< sal_uInt16 >( rArgs[ nCurCmd++ ].ToInt32() );
+
+ memcpy( aLangInfo.maLangDir, aLangDir.GetBuffer(), aLangDir.Len() + 1 );
+
+ GetCommandOption( rArgs, 'f', aOutputFileName );
+ GetCommandOptions( rArgs, 'i', aInDirVector );
+
+ Create( aSrsName, aInDirVector, aOutName, aLangInfo );
+ }
+ else
+ {
+ ShowUsage();
+ cExitCode = EXIT_COMMONERROR;
+ }
+
+ 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();
+ }
+
+ return cExitCode;
+}
+
+// --------
+// - Main -
+// --------
+
+int main( int nArgCount, char* ppArgs[] )
+{
+#ifdef UNX
+ static char aDisplayVar[ 1024 ];
+
+ strcpy( aDisplayVar, "DISPLAY=" );
+ putenv( aDisplayVar );
+#endif
+
+ ::std::vector< String > aArgs;
+ BmpApp aBmpApp;
+
+ InitVCL( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >() );
+
+ for( int i = 1; i < nArgCount; i++ )
+ aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) );
+
+ return aBmpApp.Start( aArgs );
+}
diff --git a/svtools/bmpmaker/bmp.hrc b/svtools/bmpmaker/bmp.hrc
new file mode 100644
index 000000000000..528b3e4462d9
--- /dev/null
+++ b/svtools/bmpmaker/bmp.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define DLG_PATH 256
+
+#define GRP_PATH 1
+#define FT_SRS 1
+#define FT_RES 2
+#define FT_OUT 3
+#define EDT_SRS 1
+#define EDT_RES 2
+#define EDT_OUT 3
+#define BTN_SRS 1
+#define BTN_RES 2
+#define BTN_OUT 3
+#define BTN_OK 1
+#define BTN_CANCEL 1
+
+#define GRP_LANG 2
+#define LB_LANG 1
diff --git a/svtools/bmpmaker/bmp.src b/svtools/bmpmaker/bmp.src
new file mode 100644
index 000000000000..7431d2e335a4
--- /dev/null
+++ b/svtools/bmpmaker/bmp.src
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "bmp.hrc"
+ModalDialog DLG_PATH {
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Size = MAP_APPFONT( 301, 104 );
+ Text = "Pfad-Einstellungen";
+ Moveable = TRUE;
+ Closeable = TRUE;
+ GroupBox GRP_PATH {
+ Pos = MAP_APPFONT( 6, 3 );
+ Size = MAP_APPFONT( 243, 59 );
+ Text = "Pfade";
+ };
+ FixedText FT_SRS {
+ Pos = MAP_APPFONT( 12, 16 );
+ Size = MAP_APPFONT( 50, 10 );
+ Text = "SRS-Datei (inkl.Pfad):";
+ };
+ FixedText FT_OUT {
+ Pos = MAP_APPFONT( 12, 46 );
+ Size = MAP_APPFONT( 50, 10 );
+ Text = "Ausgabe-Pfad:";
+ };
+ FixedText FT_RES {
+ Pos = MAP_APPFONT( 12, 31 );
+ Size = MAP_APPFONT( 50, 10 );
+ Text = "Bitmap-Pfad:";
+ };
+ Edit EDT_SRS {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 65, 14 );
+ Size = MAP_APPFONT( 160, 12 );
+ TabStop = TRUE;
+ };
+ Edit EDT_RES {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 65, 29 );
+ Size = MAP_APPFONT( 160, 12 );
+ TabStop = TRUE;
+ };
+ Edit EDT_OUT {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 65, 44 );
+ Size = MAP_APPFONT( 160, 12 );
+ TabStop = TRUE;
+ };
+ PushButton BTN_SRS {
+ Pos = MAP_APPFONT( 228, 14 );
+ Size = MAP_APPFONT( 15, 12 );
+ Text = "...";
+ TabStop = TRUE;
+ };
+ PushButton BTN_RES {
+ Pos = MAP_APPFONT( 228, 29 );
+ Size = MAP_APPFONT( 15, 12 );
+ Text = "...";
+ TabStop = TRUE;
+ };
+ PushButton BTN_OUT {
+ Pos = MAP_APPFONT( 228, 44 );
+ Size = MAP_APPFONT( 15, 12 );
+ Text = "...";
+ TabStop = TRUE;
+ };
+ OKButton BTN_OK {
+ Pos = MAP_APPFONT( 255, 6 );
+ Size = MAP_APPFONT( 40, 12 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_CANCEL {
+ Pos = MAP_APPFONT( 255, 21 );
+ Size = MAP_APPFONT( 40, 12 );
+ TabStop = TRUE;
+ };
+ GroupBox GRP_LANG {
+ Pos = MAP_APPFONT( 6, 65 );
+ Size = MAP_APPFONT( 243, 33 );
+ Text = "Sprache";
+ };
+ ListBox LB_LANG {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 12, 76 );
+ Size = MAP_APPFONT( 231, 70 );
+ TabStop = TRUE;
+ DropDown = TRUE;
+ VScroll = TRUE;
+ };
+};
diff --git a/svtools/bmpmaker/bmpcore.cxx b/svtools/bmpmaker/bmpcore.cxx
new file mode 100644
index 000000000000..9e134c06a670
--- /dev/null
+++ b/svtools/bmpmaker/bmpcore.cxx
@@ -0,0 +1,420 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <tools/color.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/alpha.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/pngwrite.hxx>
+#include "bmpcore.hxx"
+
+#include <vector>
+#include <algorithm>
+
+#undef WRITE_ALPHA_PNG
+
+// -------------------------
+// - ImplGetSystemFileName -
+// -------------------------
+
+static String ImplGetSystemFileName( const String& rFileName )
+{
+ String aRet( rFileName );
+ const sal_Unicode aReplace = DirEntry::GetAccessDelimiter( FSYS_STYLE_HOST ).GetChar( 0 );
+
+ aRet.SearchAndReplaceAll( '/', aReplace );
+ aRet.SearchAndReplaceAll( '\\', aReplace );
+
+ return aRet;
+}
+
+// --------------
+// - BmpCreator -
+// --------------
+
+BmpCreator::BmpCreator()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+BmpCreator::~BmpCreator()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpCreator::Message( const String&, BYTE )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void BmpCreator::ImplCreate( const ::std::vector< DirEntry >& rInDirs,
+ const DirEntry& rOut,
+ const String& rName,
+ const LangInfo& rLang )
+{
+ const sal_uInt32 nOldPos = pSRS->Tell();
+ const char* pCollectFile = getenv( "BMP_COLLECT_FILE" );
+ SvFileStream* pCollectStm = pCollectFile ? new SvFileStream( String( pCollectFile, RTL_TEXTENCODING_ASCII_US ),
+ STREAM_WRITE ) : NULL;
+
+ if( pCollectStm )
+ pCollectStm->Seek( STREAM_SEEK_TO_END );
+
+ if( rInDirs.size() )
+ {
+ ByteString aLine;
+ String aInfo, aPrefix, aName( rName ), aString;
+ SvFileStream aOutStream;
+ BitmapEx aTotalBmpEx;
+ DirEntry aOutFile( rOut );
+ ::std::vector< DirEntry > aInFiles( rInDirs );
+ ::std::vector< String > aNameVector;
+ sal_uInt32 i;
+
+ for( i = 0; i < aInFiles.size(); i++ )
+ aInFiles[ i ] += DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "xxx.xxx" ) ) );
+
+ // get prefix for files
+ if( ( aName.Len() >= 3 ) && ( aName.GetChar( 2 ) != '_' ) )
+ aPrefix = String( aName, 0, 3 );
+ else
+ aPrefix = String( aName, 0, 2 );
+
+ String aNumStr( String::CreateFromAscii( rLang.maLangDir )) ;
+
+ if( aNumStr.Len() == 1 )
+ aNumStr.Insert( '0', 0 );
+
+ aName = DirEntry( aName ).GetBase();
+ aName += String( RTL_CONSTASCII_USTRINGPARAM( ".bmp" ) );
+
+ // create output file name
+ aOutFile += DirEntry( aName );
+
+ // get number of bitmaps
+ while( aLine.Search( '}' ) == STRING_NOTFOUND )
+ {
+ if( !pSRS->ReadLine( aLine ) )
+ break;
+
+ aLine.EraseLeadingChars( ' ' );
+ aLine.EraseLeadingChars( '\t' );
+ aLine.EraseAllChars( ';' );
+
+ if( aLine.IsNumericAscii() )
+ {
+ aString = aPrefix;
+
+ if( atoi( aLine.GetBuffer() ) < 10000 )
+ aString += String::CreateFromInt32( 0 );
+
+ // search for pngs by default
+ String aPngString( aString += String( aLine.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+ aNameVector.push_back( aPngString += String( RTL_CONSTASCII_USTRINGPARAM( ".png" ) ) );
+ }
+ }
+
+ if( !aNameVector.size() )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "WARNING: No imagelist resource found: " ) ).Append( aString ), EXIT_MISSING_RESOURCE );
+ else
+ {
+ // write info
+ aInfo = String( RTL_CONSTASCII_USTRINGPARAM( "CREATING ImageList for language: " ) );
+ aInfo += String( ::rtl::OUString::createFromAscii( rLang.maLangDir ) );
+ aInfo += String( RTL_CONSTASCII_USTRINGPARAM( " [ " ) );
+
+ for( i = 0; i < rInDirs.size(); i++ )
+ ( aInfo += rInDirs[ i ].GetFull() ) += String( RTL_CONSTASCII_USTRINGPARAM( "; " ) );
+
+ aInfo += String( RTL_CONSTASCII_USTRINGPARAM( " ]" ) );
+ Message( aInfo );
+
+ // create bit vector to hold flags for valid bitmaps
+ ::std::bit_vector aValidBmpBitVector( aNameVector.size(), false );
+ BitmapEx aBmpEx;
+
+ for( sal_uInt32 n = 0; n < aNameVector.size(); n++ )
+ {
+ aBmpEx.SetEmpty();
+
+ for( i = 0; i < aInFiles.size() && aBmpEx.IsEmpty(); i++ )
+ {
+ DirEntry aInFile( aInFiles[ i ] );
+
+ aInFile.SetName( aString = aNameVector[ n ] );
+ bool bPNG = aInFile.Exists();
+
+ if( !bPNG )
+ {
+ aInFile.SetExtension( String( RTL_CONSTASCII_USTRINGPARAM( "bmp" ) ) );
+ aString = aInFile.GetName();
+ }
+
+ if( aInFile.Exists() )
+ {
+ const String aFileName( aInFile.GetFull() );
+ SvFileStream aIStm( aFileName, STREAM_READ );
+
+ if( bPNG )
+ {
+ ::vcl::PNGReader aPNGReader( aIStm );
+ aBmpEx = aPNGReader.Read();
+ }
+ else
+ aIStm >> aBmpEx;
+
+ if( pCollectStm && !aBmpEx.IsEmpty() )
+ {
+ const ByteString aCollectString( aFileName, RTL_TEXTENCODING_ASCII_US );
+ pCollectStm->WriteLine( aCollectString );
+ }
+ }
+ }
+
+ const Size aSize( aBmpEx.GetSizePixel() );
+
+ if( aBmpEx.IsEmpty() )
+ {
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: graphic is missing: " ) ).Append( aString ), EXIT_MISSING_BITMAP );
+ }
+ else
+ {
+ if( aTotalBmpEx.IsEmpty() )
+ {
+ // first bitmap determines metrics of total bitmap
+ Size aTotalSize( aOneSize = aSize );
+
+ aTotalSize.Width() *= aNameVector.size();
+ aTotalBmpEx = Bitmap( aTotalSize, aBmpEx.GetBitmap().GetBitCount() );
+ }
+
+ if( ( aSize.Width() > aOneSize.Width() ) || ( aSize.Height() > aOneSize.Height() ) )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Different dimensions in file: " ) ).Append( aString ), EXIT_DIMENSIONERROR );
+ else
+ {
+ Point aPoint;
+ const Rectangle aDst( Point( aOneSize.Width() * n, 0L ), aSize );
+ const Rectangle aSrc( aPoint, aSize );
+
+ if( !aTotalBmpEx.IsEmpty() && !aBmpEx.IsEmpty() && !aDst.IsEmpty() && !aSrc.IsEmpty() )
+ {
+ if( !aTotalBmpEx.IsTransparent() && aBmpEx.IsTransparent() )
+ {
+ const Bitmap aTmpBmp( aTotalBmpEx.GetBitmap() );
+ aTotalBmpEx = BitmapEx( aTmpBmp, AlphaMask( aTmpBmp.CreateMask( COL_LIGHTMAGENTA ) ) );
+ }
+ else if( aTotalBmpEx.IsTransparent() && !aBmpEx.IsTransparent() )
+ {
+ const Bitmap aTmpBmp( aBmpEx.GetBitmap() );
+ aBmpEx = BitmapEx( aTmpBmp, AlphaMask( aTmpBmp.CreateMask( COL_LIGHTMAGENTA ) ) );
+ }
+
+ aTotalBmpEx.CopyPixel( aDst, aSrc, &aBmpEx );
+ aValidBmpBitVector[ n ] = true;
+ }
+ }
+ }
+ }
+
+ if( !aTotalBmpEx.IsEmpty() )
+ {
+ // do we have invalid bitmaps?
+ if( ::std::find( aValidBmpBitVector.begin(), aValidBmpBitVector.end(), false ) != aValidBmpBitVector.end() )
+ {
+ Bitmap aTmpBmp( aTotalBmpEx.GetBitmap() );
+ BitmapWriteAccess* pAcc = aTmpBmp.AcquireWriteAccess();
+
+ if( pAcc )
+ {
+ pAcc->SetLineColor( Color( COL_LIGHTGREEN ) );
+
+ for( sal_uInt32 n = 0; n < aValidBmpBitVector.size(); n++ )
+ {
+ if( !aValidBmpBitVector[ n ] )
+ {
+ const Rectangle aDst( Point( aOneSize.Width() * n, 0L ), aOneSize );
+
+ pAcc->DrawRect( aDst );
+ pAcc->DrawLine( aDst.TopLeft(), aDst.BottomRight() );
+ pAcc->DrawLine( aDst.TopRight(), aDst.BottomLeft() );
+ }
+ }
+
+ aTmpBmp.ReleaseAccess( pAcc );
+
+ if( aTotalBmpEx.IsAlpha() )
+ aTotalBmpEx = BitmapEx( aTmpBmp, aTotalBmpEx.GetAlpha() );
+ else if( aTotalBmpEx.IsTransparent() )
+ aTotalBmpEx = BitmapEx( aTmpBmp, aTotalBmpEx.GetMask() );
+ else
+ aTotalBmpEx = aTmpBmp;
+ }
+ }
+
+ // write output file
+ const String aOutFileName( aOutFile.GetFull() );
+
+ aOutStream.Open( aOutFileName, STREAM_WRITE | STREAM_TRUNC );
+
+ if( !aOutStream.IsOpen() )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Could not open output file: " ) ).Append( aOutFileName ), EXIT_IOERROR );
+ else
+ {
+ if( aOutFileName.Search( String( RTL_CONSTASCII_USTRINGPARAM( ".png" ) ) ) != STRING_NOTFOUND )
+ {
+ ::vcl::PNGWriter aPNGWriter( aTotalBmpEx );
+ aPNGWriter.Write( aOutStream );
+ }
+ else
+ aOutStream << aTotalBmpEx;
+
+ if( aOutStream.GetError() )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Could not write to output file: " ) ).Append( aOutFileName ), EXIT_IOERROR );
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Successfully generated ImageList " ) ).Append( aOutFileName ) );
+
+ aOutStream.Close();
+ }
+ }
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Could not generate " ) ).Append( aOutFile.GetFull() ), EXIT_COMMONERROR );
+
+ Message( ' ' );
+ }
+ }
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: SOLARSRC environment variable not set!" ) ), EXIT_MISSING_SOLARSRC_ENV );
+
+ pSRS->Seek( nOldPos );
+ delete pCollectStm;
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpCreator::Create( const String& rSRSName,
+ const ::std::vector< String >& rInDirs,
+ const String& rOutName,
+ const LangInfo& rLang )
+{
+ DirEntry aFileName( ImplGetSystemFileName( rSRSName ) ), aOutDir( ImplGetSystemFileName( rOutName ) );
+ ::std::vector< DirEntry > aInDirs;
+ BOOL bDone = FALSE;
+
+ aFileName.ToAbs();
+ aOutDir.ToAbs();
+
+ // create vector of all valid input directories,
+ // including language subdirectories
+ for( sal_uInt32 i = 0; i < rInDirs.size(); i++ )
+ {
+ DirEntry aInDir( ImplGetSystemFileName( rInDirs[ i ] ) );
+
+ aInDir.ToAbs();
+
+ if( aInDir.Exists() )
+ {
+ DirEntry aLangInDir( aInDir );
+
+ if( ( aLangInDir += DirEntry( ::rtl::OUString::createFromAscii( rLang.maLangDir ) ) ).Exists() )
+ aInDirs.push_back( aLangInDir );
+
+ aInDirs.push_back( aInDir );
+ }
+ }
+
+ pSRS = new SvFileStream ( aFileName.GetFull(), STREAM_STD_READ );
+
+ if( pSRS->GetError() )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Kein SRS file!" ) ), EXIT_NOSRSFILE );
+ else
+ {
+ String aText;
+ ByteString aByteText;
+ BOOL bLangDep = FALSE;
+
+ do
+ {
+ do
+ {
+ if (!pSRS->ReadLine(aByteText))
+ break;
+ }
+ while ( aByteText.Search( "ImageList" ) == STRING_NOTFOUND );
+
+ do
+ {
+ if (!pSRS->ReadLine( aByteText ) )
+ break;
+ }
+ while ( aByteText.Search( "File" ) == STRING_NOTFOUND );
+ aText = String::CreateFromAscii( aByteText.GetBuffer() );
+
+ const String aName( aText.GetToken( 1, '"' ) );
+
+ do
+ {
+ if( !bLangDep &&
+ aByteText.Search( "File" ) != STRING_NOTFOUND &&
+ aByteText.Search( '[' ) != STRING_NOTFOUND &&
+ aByteText.Search( ']' ) != STRING_NOTFOUND )
+ {
+ bLangDep = TRUE;
+ }
+
+ if (!pSRS->ReadLine(aByteText))
+ break;
+ }
+ while (aByteText.Search( "IdList" ) == STRING_NOTFOUND );
+ aText = String::CreateFromAscii( aByteText.GetBuffer() );
+
+ // if image list is not language dependent, don't do anything for languages except german
+ if( aText.Len() )
+ {
+ bDone = TRUE;
+ ImplCreate( aInDirs, aOutDir, aName, rLang );
+ }
+/* else if( ( rLang.mnLangNum != 49 ) && !bLangDep )
+ {
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "INFO: ImageList is not language dependent! Nothing to do for this language." ) ) );
+ bDone = TRUE;
+ }*/
+ }
+ while ( aText.Len() );
+ }
+
+ if( !bDone )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: No ImageList found in SRS file!" ) ), EXIT_NOIMGLIST );
+
+ delete pSRS;
+}
diff --git a/svtools/bmpmaker/bmpcore.hxx b/svtools/bmpmaker/bmpcore.hxx
new file mode 100644
index 000000000000..ece4fa09cf78
--- /dev/null
+++ b/svtools/bmpmaker/bmpcore.hxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _BMPCORE_HXX
+#define _BMPCORE_HXX
+
+#include <tools/stream.hxx>
+#include <tools/fsys.hxx>
+#include <vcl/bitmap.hxx>
+#include <vector>
+
+// --------------
+// - Exit codes -
+// --------------
+
+#define EXIT_NOERROR 0
+#define EXIT_MISSING_BITMAP 1
+#define EXIT_NOSRSFILE 2
+#define EXIT_NOIMGLIST 3
+#define EXIT_DIMENSIONERROR 4
+#define EXIT_IOERROR 5
+#define EXIT_COMMONERROR 6
+#define EXIT_MISSING_RESOURCE 7
+#define EXIT_COLORDEPTHERROR 8
+#define EXIT_MISSING_SOLARSRC_ENV 9
+
+// ------------
+// - LangInfo -
+// ------------
+
+struct LangInfo
+{
+ char maLangDir[ 257 ];
+ USHORT mnLangNum;
+};
+
+// --------------
+// - BmpCreator -
+// --------------
+
+class BmpCreator
+{
+private:
+
+ Bitmap aOutBmp;
+ Size aOneSize;
+ Size aTotSize;
+ Point aPos;
+ SvFileStream* pSRS;
+ ULONG nTotCount;
+ USHORT nPos;
+
+ void ImplCreate( const ::std::vector< DirEntry >& rInDirs,
+ const DirEntry& rOut,
+ const String& rName,
+ const LangInfo& rLang );
+
+protected:
+
+ virtual void Message( const String& rText, BYTE cExitCode = EXIT_NOERROR );
+
+public:
+
+ BmpCreator();
+ virtual ~BmpCreator();
+
+ void Create( const String& rSRSName,
+ const ::std::vector< String >& rInDirs,
+ const String& rOutName,
+ const LangInfo& rLang );
+};
+
+#endif // _BMPCORE_HXX
diff --git a/svtools/bmpmaker/bmpsum.cxx b/svtools/bmpmaker/bmpsum.cxx
new file mode 100644
index 000000000000..7c264e694a12
--- /dev/null
+++ b/svtools/bmpmaker/bmpsum.cxx
@@ -0,0 +1,508 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <cstdio>
+#include <csignal>
+#include <vector>
+#include <set>
+#include <map>
+
+#include <rtl/crc.h>
+#include <tools/stream.hxx>
+#include <tools/fsys.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/bmpacc.hxx>
+#include <vcl/pngread.hxx>
+
+#include "svl/solar.hrc"
+
+#define EXIT_NOERROR 0x00000000
+#define EXIT_INVALIDFILE 0x00000001
+#define EXIT_COMMONERROR 0x80000000
+
+// ----------
+// - BmpSum -
+// ----------
+
+class BmpSum
+{
+private:
+
+ sal_uInt32 cExitCode;
+
+ BOOL GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rSwitchParam );
+ BOOL GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rSwitchParams );
+
+ void SetExitCode( BYTE cExit )
+ {
+ if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) )
+ cExitCode = cExit;
+ }
+ void ShowUsage();
+ void Message( const String& rText, BYTE cExitCode );
+
+ 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();
+
+ int Start( const ::std::vector< String >& rArgs );
+};
+
+// -----------------------------------------------------------------------------
+
+BmpSum::BmpSum()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+BmpSum::~BmpSum()
+{
+}
+
+// -----------------------------------------------------------------------
+
+BOOL BmpSum::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam )
+{
+ BOOL bRet = FALSE;
+
+ for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ )
+ {
+ String aTestStr( '-' );
+
+ for( int n = 0; ( n < 2 ) && !bRet; n++ )
+ {
+ aTestStr += rSwitch;
+
+ if( aTestStr.CompareIgnoreCaseToAscii( rArgs[ i ] ) == COMPARE_EQUAL )
+ {
+ bRet = TRUE;
+
+ if( i < ( nCount - 1 ) )
+ rParam = rArgs[ i + 1 ];
+ else
+ rParam = String();
+ }
+
+ if( 0 == n )
+ aTestStr = '/';
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL BmpSum::GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rParams )
+{
+ BOOL bRet = FALSE;
+
+ for( int i = 0, nCount = rArgs.size(); ( i < nCount ); i++ )
+ {
+ String aTestStr( '-' );
+
+ for( int n = 0; ( n < 2 ) && !bRet; n++ )
+ {
+ aTestStr += rSwitch;
+
+ if( aTestStr.CompareIgnoreCaseToAscii( rArgs[ i ] ) == COMPARE_EQUAL )
+ {
+ if( i < ( nCount - 1 ) )
+ rParams.push_back( rArgs[ i + 1 ] );
+ else
+ rParams.push_back( String() );
+
+ break;
+ }
+
+ if( 0 == n )
+ aTestStr = '/';
+ }
+ }
+
+ return( rParams.size() > 0 );
+}
+
+// -----------------------------------------------------------------------
+
+void BmpSum::Message( const String& rText, BYTE nExitCode )
+{
+ if( EXIT_NOERROR != nExitCode )
+ SetExitCode( nExitCode );
+
+ ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
+ aText.Append( "\r\n" );
+ fprintf( stderr, aText.GetBuffer() );
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpSum::ShowUsage()
+{
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Usage:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmpsum bmp_inputfile" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmpsum -i input_filelist -o output_filelist [-p path_for_copied_bitmaps]" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Options:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Examples:" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmpsum /home/test.bmp" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmpsum -i /home/inlist.txt -o /home/outlist.txt" ) ), EXIT_NOERROR );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmpsum -i /home/inlist.txt -o /home/outlist.txt -p /home/outpath" ) ), EXIT_NOERROR );
+}
+
+// -----------------------------------------------------------------------------
+
+int BmpSum::Start( const ::std::vector< String >& rArgs )
+{
+ cExitCode = EXIT_NOERROR;
+
+ if( rArgs.size() >= 1 )
+ {
+ String aInFileList, aOutFileList, aOutPath;
+
+ if( GetCommandOption( rArgs, 'i', aInFileList ) &&
+ GetCommandOption( rArgs, 'o', aOutFileList ) )
+ {
+ GetCommandOption( rArgs, 'p', aOutPath );
+ ProcessFileList( aInFileList, aOutFileList, aOutPath );
+ }
+ else
+ {
+ ProcessFile( rArgs[ 0 ] );
+ }
+ }
+ else
+ {
+ ShowUsage();
+ cExitCode = EXIT_COMMONERROR;
+ }
+
+ return cExitCode;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_uInt64 BmpSum::GetCRC( const BitmapEx& rBmpEx )
+{
+ 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() )
+ {
+ SVBT32 aBT32;
+
+ for( long nY = 0; nY < pRAcc->Height(); ++nY )
+ {
+ for( long nX = 0; nX < pRAcc->Width(); ++nX )
+ {
+ const BitmapColor aCol( pRAcc->GetColor( nY, nX ) );
+
+ UInt32ToSVBT32( aCol.GetRed(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+
+ UInt32ToSVBT32( aCol.GetGreen(), aBT32 );
+ nCrc = rtl_crc32( nCrc, aBT32, 4 );
+
+ 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 );
+ }
+ }
+ }
+
+ nRet = ( ( (sal_uInt64) pRAcc->Width() ) << 48 ) |
+ ( ( (sal_uInt64) pRAcc->Height() ) << 32 ) |
+ ( (sal_uInt64) nCrc );
+ }
+
+ if( pAAcc )
+ aAlpha.ReleaseAccess( pAAcc);
+
+ aBmp.ReleaseAccess( pRAcc );
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpSum::ProcessFile( const String& rBmpFileName )
+{
+ SvFileStream aIStm( rBmpFileName, STREAM_READ );
+
+ if( aIStm.IsOpen() )
+ {
+ BitmapEx aBmpEx;
+
+ aIStm >> aBmpEx;
+
+ if( !aBmpEx.IsEmpty() )
+ {
+ fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmpEx ) );
+ }
+ else
+ {
+ aIStm.ResetError();
+ aIStm.Seek( 0 );
+
+ ::vcl::PNGReader aPngReader( aIStm );
+
+ aBmpEx = aPngReader.Read();
+
+ if( !aBmpEx.IsEmpty() )
+ {
+ fprintf( stdout, "%" SAL_PRIuUINT64 "\r\n", GetCRC( aBmpEx ) );
+ }
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "file not valid" ) ), EXIT_INVALIDFILE );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void BmpSum::ProcessFileList( const String& rInFileList,
+ const String& rOutFileList,
+ const String& rOutPath )
+{
+ SvFileStream aIStm( rInFileList, STREAM_READ );
+ SvFileStream aOStm( rOutFileList, STREAM_WRITE | STREAM_TRUNC );
+ const DirEntry aBaseDir( rOutPath );
+
+ if( rOutPath.Len() )
+ aBaseDir.MakeDir();
+
+ if( aIStm.IsOpen() && aOStm.IsOpen() )
+ {
+ ByteString aReadLine;
+ ::std::set< ByteString > aFileNameSet;
+
+ while( aIStm.ReadLine( aReadLine ) )
+ {
+ if( aReadLine.Len() )
+ aFileNameSet.insert( aReadLine );
+
+ if( aReadLine.Search( "enus" ) != STRING_NOTFOUND )
+ {
+ static const char* aLanguages[] =
+ {
+ "chinsim",
+ "chintrad",
+ "dtch",
+ "enus",
+ "fren",
+ "hebrew"
+ "ital",
+ "japn",
+ "korean",
+ "pol",
+ "poln",
+ "port",
+ "russ",
+ "span",
+ "turk"
+ };
+
+ for( sal_uInt32 n = 0; n < 14; ++n )
+ {
+ ByteString aLangPath( aReadLine );
+
+ aLangPath.SearchAndReplace( "enus", aLanguages[ n ] );
+
+ DirEntry aTestFile( aLangPath );
+
+ if( aTestFile.Exists() )
+ aFileNameSet.insert( aLangPath );
+ }
+ }
+
+ aReadLine.Erase();
+ }
+
+ aIStm.Close();
+
+ ::std::set< ByteString >::iterator aIter( aFileNameSet.begin() );
+ ::std::map< sal_uInt64, ::std::vector< ByteString > > aFileNameMap;
+
+ while( aIter != aFileNameSet.end() )
+ {
+ ByteString aStr( *aIter++ );
+ SvFileStream aBmpStm( String( aStr.GetBuffer(), RTL_TEXTENCODING_ASCII_US ), STREAM_READ );
+ sal_uInt64 nCRC = 0;
+
+ if( aBmpStm.IsOpen() )
+ {
+ BitmapEx aBmpEx;
+
+ aBmpStm >> aBmpEx;
+
+ if( !aBmpEx.IsEmpty() )
+ nCRC = GetCRC( aBmpEx );
+ else
+ {
+ aBmpStm.ResetError();
+ aBmpStm.Seek( 0 );
+
+ ::vcl::PNGReader aPngReader( aBmpStm );
+
+ aBmpEx = aPngReader.Read();
+
+ if( !aBmpEx.IsEmpty() )
+ nCRC = GetCRC( aBmpEx );
+
+ else
+ fprintf( stderr, "%s could not be opened\n", aStr.GetBuffer() );
+ }
+
+ aBmpStm.Close();
+ }
+
+ if( nCRC )
+ {
+ ::std::map< sal_uInt64, ::std::vector< ByteString > >::iterator aFound( aFileNameMap.find( nCRC ) );
+
+ if( aFound != aFileNameMap.end() )
+ (*aFound).second.push_back( aStr );
+ else
+ {
+ ::std::vector< ByteString > aVector( 1, aStr );
+ aFileNameMap[ nCRC ] = aVector;
+ }
+
+ }
+ else
+ {
+ ::std::vector< ByteString > aVector( 1, aStr );
+ aFileNameMap[ nCRC ] = aVector;
+ }
+ }
+
+ ::std::map< sal_uInt64, ::std::vector< ByteString > >::iterator aMapIter( aFileNameMap.begin() );
+ sal_uInt32 nFileCount = 0;
+
+ while( aMapIter != aFileNameMap.end() )
+ {
+ ::std::pair< const sal_uInt64, ::std::vector< ByteString > > aPair( *aMapIter++ );
+ ::std::vector< ByteString > aFileNameVector( aPair.second );
+
+ // write new entries
+ for( sal_uInt32 i = 0; i < aFileNameVector.size(); ++i )
+ {
+ ByteString aStr( ByteString::CreateFromInt64( aPair.first ) );
+ ByteString aFileName( aFileNameVector[ i ] );
+ DirEntry aSrcFile( aFileName );
+
+ aStr += '\t';
+ aStr += aFileName;
+
+ aOStm.WriteLine( aStr );
+
+ // copy bitmap
+ if( rOutPath.Len() )
+ {
+ if( aFileName.Search( ":\\" ) != STRING_NOTFOUND )
+ aFileName.Erase( 0, aFileName.Search( ":\\" ) + 2 );
+
+ aFileName.SearchAndReplaceAll( '\\', '/' );
+
+ sal_uInt16 nTokenCount = aFileName.GetTokenCount( '/' );
+ DirEntry aNewDir( aBaseDir );
+
+ for( sal_uInt16 n = 0; ( n < nTokenCount - 1 ); n++ )
+ {
+ aNewDir += DirEntry( aFileName.GetToken( n, '/' ) );
+ aNewDir.MakeDir();
+ }
+
+ aNewDir += DirEntry( aFileName.GetToken( nTokenCount - 1, '/' ) );
+ aSrcFile.CopyTo( aNewDir, FSYS_ACTION_COPYFILE );
+ }
+ }
+
+ ++nFileCount;
+ }
+
+ fprintf(
+ stdout, "unique file count: %lu",
+ sal::static_int_cast< unsigned long >(nFileCount) );
+ }
+}
+
+// --------
+// - Main -
+// --------
+
+int main( int nArgCount, char* ppArgs[] )
+{
+#ifdef UNX
+ static char aDisplayVar[ 1024 ];
+
+ strcpy( aDisplayVar, "DISPLAY=" );
+ putenv( aDisplayVar );
+#endif
+
+ ::std::vector< String > aArgs;
+ BmpSum aBmpSum;
+
+ InitVCL( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >() );
+
+ for( int i = 1; i < nArgCount; i++ )
+ aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) );
+
+ return aBmpSum.Start( aArgs );
+}
diff --git a/svtools/bmpmaker/g2g.cxx b/svtools/bmpmaker/g2g.cxx
new file mode 100644
index 000000000000..6f4ee0f86279
--- /dev/null
+++ b/svtools/bmpmaker/g2g.cxx
@@ -0,0 +1,251 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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 <ctype.h>
+
+#include <sal/main.h>
+
+#include <tools/fsys.hxx>
+#include <tools/stream.hxx>
+#include <vcl/svapp.hxx>
+#include "svtools/filter.hxx"
+
+#define EXIT_NOERROR 0x00000000
+#define EXIT_COMMONERROR 0x00000001
+#define EXIT_INVALID_FILE 0x00000002
+#define EXIT_INVALID_GRAPHICFILTER 0x00000004
+#define EXIT_INVALID_INPUTGRAPHIC 0x00000008
+#define EXIT_OUTPUTERROR 0x00000010
+
+#define LOWERHEXTONUM( _def_Char ) (((_def_Char)<='9') ? ((_def_Char)-'0') : ((_def_Char)-'a'+10))
+
+// ----------
+// - G2GApp -
+// ----------
+
+class G2GApp
+{
+private:
+
+ BYTE cExitCode;
+
+ void ShowUsage();
+ BOOL GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam );
+ void SetExitCode( BYTE cExit ) { if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) ) cExitCode = cExit; }
+
+ virtual void Message( const String& rText, BYTE cExitCode = EXIT_NOERROR );
+
+public:
+
+ G2GApp();
+ virtual ~G2GApp();
+
+ int Start( const ::std::vector< String >& rArgs );
+};
+
+// -----------------------------------------------------------------------
+
+G2GApp::G2GApp()
+{
+}
+
+// -----------------------------------------------------------------------
+
+G2GApp::~G2GApp()
+{
+}
+
+// -----------------------------------------------------------------------
+
+BOOL G2GApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam )
+{
+ BOOL bRet = FALSE;
+
+ for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ )
+ {
+ String aTestStr( '-' );
+
+ for( int n = 0; ( n < 2 ) && !bRet; n++ )
+ {
+ aTestStr += rSwitch;
+
+ if( aTestStr.CompareIgnoreCaseToAscii( rArgs[ i ] ) == COMPARE_EQUAL )
+ {
+ bRet = TRUE;
+
+ if( i < ( nCount - 1 ) )
+ rParam = rArgs[ i + 1 ];
+ else
+ rParam = String();
+ }
+
+ if( 0 == n )
+ aTestStr = '/';
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+void G2GApp::Message( const String& rText, BYTE nExitCode )
+{
+ if( EXIT_NOERROR != nExitCode )
+ SetExitCode( nExitCode );
+
+ ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
+ aText.Append( "\r\n" );
+ fprintf( stderr, aText.GetBuffer() );
+}
+
+// -----------------------------------------------------------------------------
+
+void G2GApp::ShowUsage()
+{
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Usage:" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " g2g inputfile outputfile -format exportformat -filterpath path [ -# RRGGBB ]" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Options:" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " -format short name of export filter to use ( e.g. gif, png, jpg, ... )" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " -filterpath path to externally loaded filter libraries" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " -# hex value of color to be set transparent in export file (optional)" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "Examples:" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " g2g /home/test.bmp /home/test.jpg -format jpg -filterpath /home/filter" ) ) );
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( " g2g /home/test.bmp /home/test.gif -format gif -filterpath /home/filter -# C0C0C0" ) ) );
+}
+
+// -----------------------------------------------------------------------------
+
+int G2GApp::Start( const ::std::vector< String >& rArgs )
+{
+ int nCmdCount = rArgs.size();
+ USHORT nCurCmd = 0;
+
+ cExitCode = EXIT_NOERROR;
+
+ if( nCmdCount >= 6 )
+ {
+ GraphicFilter aFilter( sal_False );
+ String aInFile, aOutFile, aFilterStr, aFilterPath, aTransColStr;
+
+ aInFile = rArgs[ nCurCmd++ ];
+ aOutFile = rArgs[ nCurCmd++ ];
+ GetCommandOption( rArgs, String( RTL_CONSTASCII_USTRINGPARAM( "format" ) ), aFilterStr );
+ GetCommandOption( rArgs, String( RTL_CONSTASCII_USTRINGPARAM( "filterpath" ) ), aFilterPath );
+ GetCommandOption( rArgs, '#', aTransColStr );
+
+ aFilter.SetFilterPath( aFilterPath );
+
+ if( aInFile.Len() && aOutFile.Len() && aFilterStr.Len() )
+ {
+ const USHORT nExportFilter = aFilter.GetExportFormatNumberForShortName( aFilterStr );
+
+ if( GRFILTER_FORMAT_NOTFOUND == nExportFilter )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "invalid graphic filter" ) ), EXIT_INVALID_GRAPHICFILTER );
+ else
+ {
+ if( DirEntry( aInFile ).Exists() )
+ {
+ SvFileStream aInStm( aInFile, STREAM_READ );
+ Graphic aGraphic;
+ const GfxLink aGfxLink;
+
+ aGraphic.SetLink( aGfxLink );
+
+ if( aFilter.ImportGraphic( aGraphic, aInFile, aInStm ) == GRFILTER_OK )
+ {
+ SvFileStream aOutStm( aOutFile, STREAM_WRITE | STREAM_TRUNC );
+
+ if( ( aTransColStr.Len() == 6 ) && aFilter.IsExportPixelFormat( nExportFilter ) )
+ {
+ ByteString aHexStr( aTransColStr, RTL_TEXTENCODING_ASCII_US );
+ sal_Bool bHex = sal_True;
+
+ aHexStr.ToLowerAscii();
+
+ for( sal_uInt16 i = 0; ( i < 6 ) && bHex; i++ )
+ if( !isxdigit( aHexStr.GetChar( i ) ) )
+ bHex = sal_False;
+
+ if( bHex )
+ {
+ const BYTE cTransR = ( LOWERHEXTONUM( aHexStr.GetChar( 0 ) ) << 4 ) | LOWERHEXTONUM( aHexStr.GetChar( 1 ) );
+ const BYTE cTransG = ( LOWERHEXTONUM( aHexStr.GetChar( 2 ) ) << 4 ) | LOWERHEXTONUM( aHexStr.GetChar( 3 ) );
+ const BYTE cTransB = ( LOWERHEXTONUM( aHexStr.GetChar( 4 ) ) << 4 ) | LOWERHEXTONUM( aHexStr.GetChar( 5 ) );
+
+ BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
+ Bitmap aOldBmp( aBmpEx.GetBitmap() );
+ Bitmap aOldMask( aBmpEx.GetMask() );
+ Bitmap aNewMask( aOldBmp.CreateMask( Color( cTransR, cTransG, cTransB ) ) );
+
+ if( !aOldMask.IsEmpty() )
+ aNewMask.CombineSimple( aOldMask, BMP_COMBINE_OR );
+
+ aGraphic = BitmapEx( aOldBmp, aNewMask );
+ }
+ }
+
+ aFilter.ExportGraphic( aGraphic, aOutFile, aOutStm, nExportFilter );
+
+ if( aOutStm.GetError() )
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "could not write output file" ) ), EXIT_OUTPUTERROR );
+ }
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "could import graphic" ) ), EXIT_INVALID_INPUTGRAPHIC );
+ }
+ else
+ Message( String( RTL_CONSTASCII_USTRINGPARAM( "invalid file(s)" ) ), EXIT_INVALID_FILE );
+ }
+ }
+ }
+ else
+ ShowUsage();
+
+ return cExitCode;
+}
+
+// --------
+// - Main -
+// --------
+
+int main( int nArgCount, char* ppArgs[] )
+{
+ ::std::vector< String > aArgs;
+ G2GApp aG2GApp;
+
+ InitVCL( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >() );
+
+ for( int i = 1; i < nArgCount; i++ )
+ aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) );
+
+ return aG2GApp.Start( aArgs );
+}
diff --git a/svtools/bmpmaker/makefile.mk b/svtools/bmpmaker/makefile.mk
new file mode 100644
index 000000000000..a1303343a503
--- /dev/null
+++ b/svtools/bmpmaker/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..
+PRJNAME=svtools
+TARGET=bmp
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+ENABLE_EXCEPTIONS=true
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+OBJFILES= $(OBJ)$/bmp.obj \
+ $(OBJ)$/bmpcore.obj \
+ $(OBJ)$/g2g.obj \
+ $(OBJ)$/bmpsum.obj
+
+# --- APP1TARGET ---------------------------------------------------
+
+APP1TARGET= $(TARGET)
+
+APP1STDLIBS = \
+ $(VCLLIB) \
+ $(TOOLSLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+APP1OBJS= $(OBJ)$/bmp.obj \
+ $(OBJ)$/bmpcore.obj
+
+APP1BASE=0x10000000
+
+# --- APP2TARGET --------------------------------------------------
+
+APP2TARGET = bmpsum
+APP2BASE = 0x10000000
+APP2OBJS = $(OBJ)$/bmpsum.obj
+
+APP2STDLIBS = $(VCLLIB) \
+ $(TOOLSLIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk