#104537#: added support for localized bitmaps

This commit is contained in:
Kai Ahrens 2002-10-30 15:27:55 +00:00
parent 9046c3b531
commit 169dd3968c
4 changed files with 137 additions and 114 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: bmp.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: hr $ $Date: 2002-02-25 13:49:36 $
* last change: $Author: ka $ $Date: 2002-10-30 16:27:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -83,6 +83,8 @@ private:
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 ) )
@ -114,7 +116,7 @@ BmpApp::~BmpApp()
// -----------------------------------------------------------------------
BOOL BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rFollowingParam )
BOOL BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam )
{
BOOL bRet = FALSE;
@ -131,9 +133,9 @@ BOOL BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const Strin
bRet = TRUE;
if( i < ( nCount - 1 ) )
rFollowingParam = rArgs[ i + 1 ];
rParam = rArgs[ i + 1 ];
else
rFollowingParam = String();
rParam = String();
}
if( 0 == n )
@ -146,6 +148,38 @@ BOOL BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const Strin
// -----------------------------------------------------------------------
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 cExitCode )
{
if( EXIT_NOERROR != cExitCode )
@ -161,11 +195,12 @@ void BmpApp::Message( const String& rText, BYTE cExitCode )
void BmpApp::ShowUsage()
{
Message( String( RTL_CONSTASCII_USTRINGPARAM( "Usage:" ) ), EXIT_NOERROR );
Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmp srs_inputfile bmp_dir output_dir lang_dir [-f err_file]" ) ), EXIT_NOERROR );
Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmp srs_inputfile output_dir lang_dir -i input_dir [-i input_dir ][-f err_file]" ) ), EXIT_NOERROR );
Message( String( RTL_CONSTASCII_USTRINGPARAM( "Options:" ) ), EXIT_NOERROR );
Message( String( RTL_CONSTASCII_USTRINGPARAM( " -f name of file output should be written to" ) ), 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/res /home/out /home/res/enus" ) ), EXIT_NOERROR );
Message( String( RTL_CONSTASCII_USTRINGPARAM( " bmp /home/test.srs /home/out enus -i /home/res -f /home/out/bmp.err" ) ), EXIT_NOERROR );
}
// -----------------------------------------------------------------------------
@ -176,23 +211,24 @@ int BmpApp::Start( const ::std::vector< String >& rArgs )
cExitCode = EXIT_NOERROR;
if( rArgs.size() >= 4 )
if( rArgs.size() >= 5 )
{
LangInfo aLangInfo;
USHORT nCurCmd = 0;
const String aSrsName( rArgs[ nCurCmd++ ] );
const String aInName( rArgs[ nCurCmd++ ] );
ByteString aLangDir;
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 );
GetCommandOption( rArgs, 'f', aOutputFileName );
GetCommandOptions( rArgs, 'i', aInDirVector );
memcpy( aLangInfo.maLangDir, aLangDir.GetBuffer(), aLangDir.Len() + 1 );
aLangInfo.mnLangNum = (USHORT) DirEntry( aOutName ).GetName().ToInt32();
Create( aSrsName, aInName, aOutName, aLangInfo );
Create( aSrsName, aInDirVector, aOutName, aLangInfo );
}
else
{

View file

@ -2,9 +2,9 @@
*
* $RCSfile: bmpcore.cxx,v $
*
* $Revision: 1.9 $
* $Revision: 1.10 $
*
* last change: $Author: mh $ $Date: 2002-06-28 09:26:43 $
* last change: $Author: ka $ $Date: 2002-10-30 16:27:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -66,8 +66,6 @@
#include <vector>
#include <algorithm>
#define FILETEST(FileEntry) ((FileEntry).Exists())
// -------------------------
// - ImplGetSystemFileName -
// -------------------------
@ -105,27 +103,28 @@ void BmpCreator::Message( const String& rText, BYTE cExitCode )
// -----------------------------------------------------------------------
void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry& rOut, const String& rName, const LangInfo& rLang )
void BmpCreator::ImplCreate( SvStream& rStm,
const ::std::vector< DirEntry >& rInDirs,
const DirEntry& rOut,
const String& rName,
const LangInfo& rLang )
{
const char* pCollectPath = getenv( "BMP_COLLECT_PATH" );
const char* pResPath = getenv( "SOLARSRC" );
const sal_uInt32 nOldPos = pSRS->Tell();
if( pResPath && *pResPath )
if( rInDirs.size() )
{
ByteString aLine;
String aFileName, aInfo, aPrefix, aName( rName );
String aString( String::CreateFromAscii( ByteString( pResPath ).GetBuffer() ) );
const String aResPath( ( DirEntry( aString ) += DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "res" ) ) ) ).GetFull() );
SvFileStream aOutStream;
Bitmap aTotalBmp;
DirEntry aOutFile( rOut );
DirEntry aLocalPath( rIn + DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "x.bmp" ) ) ) );
DirEntry aLocalCollectPath;
DirEntry aGlobalPath( aResPath );
DirEntry aGlobalLangPath( aResPath );
DirEntry aGlobalCollectPath;
::std::vector< String > aNameVector;
ByteString aLine;
String aInfo, aPrefix, aName( rName ), aString;
SvFileStream aOutStream;
Bitmap aTotalBmp;
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( "x.bmp" ) ) );
// get prefix for files
#if SUPD >= 642
@ -146,16 +145,11 @@ void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry
aName = DirEntry( aName ).GetBase();
aName += aNumStr;
aName += String( RTL_CONSTASCII_USTRINGPARAM( ".bmp" ) );
aGlobalLangPath += DirEntry( ::rtl::OUString::createFromAscii( rLang.maLangDir ) );
}
// create output file name
aOutFile += DirEntry( aName );
// names are replaced later
aGlobalLangPath += DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "x.bmp" ) ) );
aGlobalPath += DirEntry( String( RTL_CONSTASCII_USTRINGPARAM( "x.bmp" ) ) );
// get number of bitmaps
while( aLine.Search( '}' ) == STRING_NOTFOUND )
{
@ -188,19 +182,14 @@ void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry
aInfo = String( RTL_CONSTASCII_USTRINGPARAM( "CREATING ImageList for language: " ) );
aInfo += String( ::rtl::OUString::createFromAscii( rLang.maLangDir ) );
aInfo += String( RTL_CONSTASCII_USTRINGPARAM( " [ " ) );
aInfo += aLocalPath.GetPath().GetFull();
aInfo += String( RTL_CONSTASCII_USTRINGPARAM( "; " ) );
aInfo += aGlobalLangPath.GetPath().GetFull();
if( aGlobalPath != aGlobalLangPath )
{
aInfo += String( RTL_CONSTASCII_USTRINGPARAM( "; " ) );
aInfo += aGlobalPath.GetPath().GetFull();
}
for( i = 0; i < rInDirs.size(); i++ )
( aInfo += rInDirs[ i ].GetFull() ) += String( RTL_CONSTASCII_USTRINGPARAM( "; " ) );
aInfo += String( RTL_CONSTASCII_USTRINGPARAM( " ]" ) );
Message( aInfo );
/*
if( pCollectPath )
{
String aLocalStr( aLocalPath.GetPath().GetFull() );
@ -223,6 +212,7 @@ void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry
Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: couldn't create collect path" ) ), 0 );
}
}
*/
// create bit vector to hold flags for valid bitmaps
::std::bit_vector aValidBmpBitVector( aNameVector.size(), false );
@ -231,62 +221,26 @@ void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry
{
Bitmap aBmp;
aLocalPath.SetName( aString = aNameVector[ n ] );
if( !FILETEST( aLocalPath ) )
for( i = 0; i < aInFiles.size() && aBmp.IsEmpty(); i++ )
{
// Falls nicht deutsch, suchen wir zuerst im jeweiligen Sprach-Unterverz.
if( rLang.mnLangNum != 49 )
{
aGlobalLangPath.SetName( aString );
DirEntry aInFile( aInFiles[ i ] );
if ( !FILETEST( aGlobalLangPath ) )
aInFile.SetName( aString = aNameVector[ n ] );
if( aInFile.Exists() )
{
const String aFileName( aInFile.GetFull() );
SvFileStream aIStm( aFileName, STREAM_READ );
aIStm >> aBmp;
aIStm.Close();
/*
if( pCollectPath && !aBmp.IsEmpty() )
{
aGlobalPath.SetName( aString );
if( !FILETEST( aGlobalPath ) )
aBmp = Bitmap();
else
{
SvFileStream aIStm( aFileName = aGlobalPath.GetFull(), STREAM_READ );
aIStm >> aBmp;
}
DirEntry aSrcPath( aFileName ), aDstPath( aLocalCollectPath );
aSrcPath.CopyTo( aDstPath += aSrcPath.GetName(), FSYS_ACTION_COPYFILE );
}
else
{
SvFileStream aIStm( aFileName = aGlobalLangPath.GetFull(), STREAM_READ );
aIStm >> aBmp;
}
}
else
{
aGlobalPath.SetName( aString );
if( !FILETEST( aGlobalPath ) )
aBmp = Bitmap();
else
{
SvFileStream aIStm( aFileName = aGlobalPath.GetFull(), STREAM_READ );
aIStm >> aBmp;
}
}
if( pCollectPath && !aBmp.IsEmpty() )
{
DirEntry aSrcPath( aFileName ), aDstPath( aGlobalCollectPath );
aSrcPath.CopyTo( aDstPath += aSrcPath.GetName(), FSYS_ACTION_COPYFILE );
}
}
else
{
SvFileStream aIStm( aFileName = aLocalPath.GetFull(), STREAM_READ );
aIStm >> aBmp;
aIStm.Close();
if( pCollectPath && !aBmp.IsEmpty() )
{
DirEntry aSrcPath( aFileName ), aDstPath( aLocalCollectPath );
aSrcPath.CopyTo( aDstPath += aSrcPath.GetName(), FSYS_ACTION_COPYFILE );
*/
}
}
@ -391,16 +345,37 @@ void BmpCreator::ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry
// -----------------------------------------------------------------------------
void BmpCreator::Create( const String& rSRSName, const String& rInName,
const String& rOutName, const LangInfo& rLang )
void BmpCreator::Create( const String& rSRSName,
const ::std::vector< String >& rInDirs,
const String& rOutName,
const LangInfo& rLang )
{
DirEntry aFileName( ImplGetSystemFileName( rSRSName ) ), aInDir( ImplGetSystemFileName( rInName ) ), aOutDir( ImplGetSystemFileName( rOutName ) );
BOOL bDone = FALSE;
DirEntry aFileName( ImplGetSystemFileName( rSRSName ) ), aOutDir( ImplGetSystemFileName( rOutName ) );
::std::vector< DirEntry > aInDirs;
BOOL bDone = FALSE;
aFileName.ToAbs();
aInDir.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() )
@ -450,7 +425,7 @@ void BmpCreator::Create( const String& rSRSName, const String& rInName,
if( aText.Len() )
{
bDone = TRUE;
ImplCreate( *pSRS, aInDir, aOutDir, aName, rLang );
ImplCreate( *pSRS, aInDirs, aOutDir, aName, rLang );
}
else if( ( rLang.mnLangNum != 49 ) && !bLangDep )
{

View file

@ -2,9 +2,9 @@
*
* $RCSfile: bmpcore.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: ka $ $Date: 2002-03-22 16:19:45 $
* last change: $Author: ka $ $Date: 2002-10-30 16:27:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -65,6 +65,7 @@
#include <tools/stream.hxx>
#include <tools/fsys.hxx>
#include <vcl/bitmap.hxx>
#include <vector>
// --------------
// - Exit codes -
@ -107,7 +108,11 @@ private:
ULONG nTotCount;
USHORT nPos;
void ImplCreate( SvStream& rStm, const DirEntry& rIn, const DirEntry& rOut, const String& rName, const LangInfo& rLang );
void ImplCreate( SvStream& rStm,
const ::std::vector< DirEntry >& rInDirs,
const DirEntry& rOut,
const String& rName,
const LangInfo& rLang );
protected:
@ -119,7 +124,7 @@ public:
virtual ~BmpCreator();
void Create( const String& rSRSName,
const String& rInName,
const ::std::vector< String >& rInDirs,
const String& rOutName,
const LangInfo& rLang );
};

View file

@ -2,9 +2,9 @@
*
* $RCSfile: bmpgui.cxx,v $
*
* $Revision: 1.3 $
* $Revision: 1.4 $
*
* last change: $Author: hr $ $Date: 2002-02-25 13:49:36 $
* last change: $Author: ka $ $Date: 2002-10-30 16:27:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -408,6 +408,8 @@ IMPL_LINK( BmpApp, Select, Menu*, pMenu )
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 ) );
@ -415,13 +417,18 @@ IMPL_LINK( BmpApp, Select, Menu*, pMenu )
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, aResPath, aOutPath, aLangEntries[ i ] );
pBmpWin->Create( aSrsPath, aInDirs, aOutPath, aLangEntries[ i ] );
}
else
pBmpWin->Create( aSrsPath, aResPath, aOutPath, aLangEntries[ nLanguage - 1 ] );
pBmpWin->Create( aSrsPath, aInDirs, aOutPath, aLangEntries[ nLanguage - 1 ] );
}
}
else if( pMenu->GetCurItemId() == 2 )