diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2013-03-20 13:13:13 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-03-21 16:13:46 +0000 |
commit | ec8ada0221d26524806d469a08c0bcc0bd3a8796 (patch) | |
tree | 03fcd1f05dc114eb82f3ffe0165794d73106c9b9 /svtools | |
parent | stop uninitialized memory leaking into resource files. (diff) | |
download | core-ec8ada0221d26524806d469a08c0bcc0bd3a8796.tar.gz core-ec8ada0221d26524806d469a08c0bcc0bd3a8796.zip |
remove unused code svtools/bmpmaker
Investigated the usage of bmpmaker for fdo#39445, seemingly
it's not used anywhere. I removed it but I would be happier
if someone could confirm this.
Change-Id: I21c98e7857299aef8c482bb07750f4c13529c937
Reviewed-on: https://gerrit.libreoffice.org/2868
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Thomas Arnhold <thomas@arnhold.org>
Tested-by: Thomas Arnhold <thomas@arnhold.org>
Reviewed-by: Noel Power <noel.power@suse.com>
Tested-by: Noel Power <noel.power@suse.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Executable_bmp.mk | 46 | ||||
-rw-r--r-- | svtools/Executable_bmpsum.mk | 44 | ||||
-rw-r--r-- | svtools/Executable_g2g.mk | 46 | ||||
-rw-r--r-- | svtools/Module_svtools.mk | 5 | ||||
-rw-r--r-- | svtools/bmpmaker/bmp.cxx | 237 | ||||
-rw-r--r-- | svtools/bmpmaker/bmp.hrc | 38 | ||||
-rw-r--r-- | svtools/bmpmaker/bmp.src | 118 | ||||
-rw-r--r-- | svtools/bmpmaker/bmpcore.cxx | 414 | ||||
-rw-r--r-- | svtools/bmpmaker/bmpcore.hxx | 89 | ||||
-rw-r--r-- | svtools/bmpmaker/bmpsum.cxx | 470 | ||||
-rw-r--r-- | svtools/bmpmaker/g2g.cxx | 241 |
11 files changed, 0 insertions, 1748 deletions
diff --git a/svtools/Executable_bmp.mk b/svtools/Executable_bmp.mk deleted file mode 100644 index 7723b4b82b56..000000000000 --- a/svtools/Executable_bmp.mk +++ /dev/null @@ -1,46 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -$(eval $(call gb_Executable_Executable,bmp)) - -$(eval $(call gb_Executable_set_include,bmp,\ - $$(INCLUDE) \ - -I$(SRCDIR)/svtools/inc \ - -I$(SRCDIR)/svtools/inc/svtools \ - -I$(SRCDIR)/svtools/source/inc \ -)) - -$(eval $(call gb_Executable_use_external,bmp,boost_headers)) - -$(eval $(call gb_Executable_use_sdk_api,bmp)) - -$(eval $(call gb_Executable_use_libraries,bmp,\ - sal \ - comphelper \ - tl \ - vcl \ - $(gb_UWINAPI) \ -)) - -$(eval $(call gb_Executable_add_exception_objects,bmp,\ - svtools/bmpmaker/bmp \ - svtools/bmpmaker/bmpcore \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/svtools/Executable_bmpsum.mk b/svtools/Executable_bmpsum.mk deleted file mode 100644 index f4ebdd6177ff..000000000000 --- a/svtools/Executable_bmpsum.mk +++ /dev/null @@ -1,44 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -$(eval $(call gb_Executable_Executable,bmpsum)) - -$(eval $(call gb_Executable_set_include,bmpsum,\ - $$(INCLUDE) \ - -I$(SRCDIR)/svtools/inc \ - -I$(SRCDIR)/svtools/inc/svtools \ -)) - -$(eval $(call gb_Executable_use_external,bmpsum,boost_headers)) - -$(eval $(call gb_Executable_use_sdk_api,bmpsum)) - -$(eval $(call gb_Executable_use_libraries,bmpsum,\ - sal \ - comphelper \ - tl \ - vcl \ - $(gb_UWINAPI) \ -)) - -$(eval $(call gb_Executable_add_exception_objects,bmpsum,\ - svtools/bmpmaker/bmpsum \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/svtools/Executable_g2g.mk b/svtools/Executable_g2g.mk deleted file mode 100644 index 72856b79cada..000000000000 --- a/svtools/Executable_g2g.mk +++ /dev/null @@ -1,46 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This file incorporates work covered by the following license notice: -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed -# with this work for additional information regarding copyright -# ownership. The ASF licenses this file to you under the Apache -# License, Version 2.0 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.apache.org/licenses/LICENSE-2.0 . -# - -$(eval $(call gb_Executable_Executable,g2g)) - -$(eval $(call gb_Executable_set_include,g2g,\ - $$(INCLUDE) \ - -I$(SRCDIR)/svtools/inc \ - -I$(SRCDIR)/svtools/inc/svtools \ -)) - -$(eval $(call gb_Executable_use_external,g2g,boost_headers)) - -$(eval $(call gb_Executable_use_sdk_api,g2g)) - -$(eval $(call gb_Executable_use_libraries,g2g,\ - cppuhelper \ - jvmfwk \ - sal \ - svt \ - tl \ - vcl \ - $(gb_UWINAPI) \ -)) - -$(eval $(call gb_Executable_add_exception_objects,g2g,\ - svtools/bmpmaker/g2g \ -)) - -# vim: set noet sw=4 ts=4: diff --git a/svtools/Module_svtools.mk b/svtools/Module_svtools.mk index 604668f7ccc5..c2d10c116b41 100644 --- a/svtools/Module_svtools.mk +++ b/svtools/Module_svtools.mk @@ -28,11 +28,6 @@ $(eval $(call gb_Module_add_targets,svtools,\ )) ifneq ($(CROSS_COMPILING),YES) -$(eval $(call gb_Module_add_targets,svtools,\ - Executable_bmp \ - Executable_bmpsum \ - Executable_g2g \ -)) ifneq ($(OS),WNT) $(eval $(call gb_Module_add_targets,svtools,\ diff --git a/svtools/bmpmaker/bmp.cxx b/svtools/bmpmaker/bmp.cxx deleted file mode 100644 index c75042a1d607..000000000000 --- a/svtools/bmpmaker/bmp.cxx +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <rtl/math.hxx> -#include <rtl/strbuf.hxx> - -#include <math.h> -#include <stdio.h> -#include <signal.h> -#include <vector> -using namespace std; - -#include <vcl/svapp.hxx> - -#include "svl/solar.hrc" -#include "bmpcore.hxx" -#include "bmp.hrc" - -// ---------- -// - BmpApp - -// ---------- - -class BmpApp : public BmpCreator -{ -private: - - String aOutputFileName; - sal_uInt8 cExitCode; - - sal_Bool GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rSwitchParam ); - sal_Bool GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rSwitchParams ); - - void SetExitCode( sal_uInt8 cExit ) - { - if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) ) - cExitCode = cExit; - } - void ShowUsage(); - - virtual void Message( const String& rText, sal_uInt8 cExitCode ); - -public: - - BmpApp(); - ~BmpApp(); - - int Start( const ::std::vector< String >& rArgs ); -}; - -// ----------------------------------------------------------------------------- - -BmpApp::BmpApp() -{ -} - -// ----------------------------------------------------------------------------- - -BmpApp::~BmpApp() -{ -} - -// ----------------------------------------------------------------------- - -sal_Bool BmpApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam ) -{ - sal_Bool bRet = sal_False; - - for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ ) - { - rtl::OUString aTestStr( '-' ); - - for( int n = 0; ( n < 2 ) && !bRet; n++ ) - { - aTestStr += rSwitch; - - if( aTestStr.equalsIgnoreAsciiCase( rArgs[ i ] ) ) - { - bRet = sal_True; - - if( i < ( nCount - 1 ) ) - rParam = rArgs[ i + 1 ]; - else - rParam = String(); - } - - if( 0 == n ) - aTestStr = rtl::OUString('/'); - } - } - - return bRet; -} - -// ----------------------------------------------------------------------- - -sal_Bool BmpApp::GetCommandOptions( const ::std::vector< String >& rArgs, const String& rSwitch, ::std::vector< String >& rParams ) -{ - sal_Bool bRet = sal_False; - - for( int i = 0, nCount = rArgs.size(); ( i < nCount ); i++ ) - { - rtl::OUString aTestStr( '-' ); - - for( int n = 0; ( n < 2 ) && !bRet; n++ ) - { - aTestStr += rSwitch; - - if( aTestStr.equalsIgnoreAsciiCase( rArgs[ i ] ) ) - { - if( i < ( nCount - 1 ) ) - rParams.push_back( rArgs[ i + 1 ] ); - else - rParams.push_back( String() ); - - break; - } - - if( 0 == n ) - aTestStr = rtl::OUString('/'); - } - } - - return( rParams.size() > 0 ); -} - -// ----------------------------------------------------------------------- - -void BmpApp::Message( const String& rText, sal_uInt8 cExit ) -{ - if( EXIT_NOERROR != cExit ) - SetExitCode( cExit ); - - rtl::OStringBuffer aText(rtl::OUStringToOString(rText, RTL_TEXTENCODING_UTF8)); - aText.append(RTL_CONSTASCII_STRINGPARAM("\r\n")); - fprintf(stderr, "%s", aText.getStr()); -} - -// ----------------------------------------------------------------------------- - -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 occurrence 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; - sal_uInt16 nCurCmd = 0; - const String aSrsName( rArgs[ nCurCmd++ ] ); - ::std::vector< String > aInDirVector; - - aOutName = rArgs[ nCurCmd++ ]; - - rtl::OString aLangDir(rtl::OUStringToOString(rArgs[nCurCmd++], RTL_TEXTENCODING_ASCII_US)); - aLangInfo.mnLangNum = static_cast< sal_uInt16 >( rArgs[ nCurCmd++ ].ToInt32() ); - - memcpy( aLangInfo.maLangDir, aLangDir.getStr(), aLangDir.getLength() + 1 ); - - GetCommandOption( rArgs, rtl::OUString('f'), aOutputFileName ); - GetCommandOptions( rArgs, rtl::OUString('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 ); - rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("Successfully generated ImageList(s) in: ")); - aStr.append(rtl::OUStringToOString(aOutName, RTL_TEXTENCODING_UTF8)); - aOStm.WriteLine(aStr.makeStringAndClear()); - 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(); - - for( int i = 1; i < nArgCount; i++ ) - aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) ); - - return aBmpApp.Start( aArgs ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/bmp.hrc b/svtools/bmpmaker/bmp.hrc deleted file mode 100644 index 324de849b12d..000000000000 --- a/svtools/bmpmaker/bmp.hrc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/bmp.src b/svtools/bmpmaker/bmp.src deleted file mode 100644 index f84033a1a0e7..000000000000 --- a/svtools/bmpmaker/bmp.src +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "bmp.hrc" -ModalDialog DLG_PATH { - HelpID = "svtools: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 { - HelpID = "svtools:Edit:DLG_PATH:EDT_SRS"; - Border = TRUE; - Pos = MAP_APPFONT( 65, 14 ); - Size = MAP_APPFONT( 160, 12 ); - TabStop = TRUE; - }; - Edit EDT_RES { - HelpID = "svtools:Edit:DLG_PATH:EDT_RES"; - Border = TRUE; - Pos = MAP_APPFONT( 65, 29 ); - Size = MAP_APPFONT( 160, 12 ); - TabStop = TRUE; - }; - Edit EDT_OUT { - HelpID = "svtools:Edit:DLG_PATH:EDT_OUT"; - Border = TRUE; - Pos = MAP_APPFONT( 65, 44 ); - Size = MAP_APPFONT( 160, 12 ); - TabStop = TRUE; - }; - PushButton BTN_SRS { - HelpID = "svtools:PushButton:DLG_PATH:BTN_SRS"; - Pos = MAP_APPFONT( 228, 14 ); - Size = MAP_APPFONT( 15, 12 ); - Text = "..."; - TabStop = TRUE; - }; - PushButton BTN_RES { - HelpID = "svtools:PushButton:DLG_PATH:BTN_RES"; - Pos = MAP_APPFONT( 228, 29 ); - Size = MAP_APPFONT( 15, 12 ); - Text = "..."; - TabStop = TRUE; - }; - PushButton BTN_OUT { - HelpID = "svtools:PushButton:DLG_PATH: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 { - HelpID = "svtools:ListBox:DLG_PATH:LB_LANG"; - Border = TRUE; - Pos = MAP_APPFONT( 12, 76 ); - Size = MAP_APPFONT( 231, 70 ); - TabStop = TRUE; - DropDown = TRUE; - VScroll = TRUE; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/bmpcore.cxx b/svtools/bmpmaker/bmpcore.cxx deleted file mode 100644 index 22be38edcc15..000000000000 --- a/svtools/bmpmaker/bmpcore.cxx +++ /dev/null @@ -1,414 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <comphelper/string.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():pSRS(NULL) -{ -} - -// ----------------------------------------------------------------------------- - -BmpCreator::~BmpCreator() -{ -} - -// ----------------------------------------------------------------------------- - -void BmpCreator::Message( const String&, sal_uInt8 ) -{ -} - -// ----------------------------------------------------------------------- - -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.empty() ) - { - rtl::OString 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(rtl::OUString::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.indexOf('}') == -1 ) - { - if( !pSRS->ReadLine( aLine ) ) - break; - - aLine = comphelper::string::stripStart(aLine, ' '); - aLine = comphelper::string::stripStart(aLine, '\t'); - aLine = comphelper::string::remove(aLine, ';'); - - if (comphelper::string::isdigitAsciiString(aLine)) - { - aString = aPrefix; - - if( atoi( aLine.getStr() ) < 10000 ) - aString += OUString::number( 0 ); - - // search for pngs by default - String aPngString( aString += rtl::OStringToOUString(aLine, 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::vector<bool, std::allocator<bool> > 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 rtl::OString aCollectString(rtl::OUStringToOString( - 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( rtl::OUString(' ') ); - } - } - else - Message( rtl::OUString("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; - sal_Bool bDone = sal_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; - rtl::OString aByteText; - sal_Bool bLangDep = sal_False; - - do - { - do - { - if (!pSRS->ReadLine(aByteText)) - break; - } - while ( aByteText.indexOfL(RTL_CONSTASCII_STRINGPARAM("ImageList")) == -1 ); - - do - { - if (!pSRS->ReadLine( aByteText ) ) - break; - } - while ( aByteText.indexOfL(RTL_CONSTASCII_STRINGPARAM("File")) == -1 ); - aText = rtl::OStringToOUString(aByteText, RTL_TEXTENCODING_ASCII_US); - - const String aName( aText.GetToken( 1, '"' ) ); - - do - { - if( !bLangDep && - aByteText.indexOfL(RTL_CONSTASCII_STRINGPARAM("File")) != -1 && - aByteText.indexOf('[') != -1 && - aByteText.indexOf(']') != -1 ) - { - bLangDep = sal_True; - } - - if (!pSRS->ReadLine(aByteText)) - break; - } - while (aByteText.indexOfL(RTL_CONSTASCII_STRINGPARAM("IdList")) == -1); - aText = rtl::OStringToOUString(aByteText, RTL_TEXTENCODING_ASCII_US); - - // if image list is not language dependent, don't do anything for languages except german - if( aText.Len() ) - { - bDone = sal_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 = sal_True; - }*/ - } - while ( aText.Len() ); - } - - if( !bDone ) - Message( String( RTL_CONSTASCII_USTRINGPARAM( "ERROR: No ImageList found in SRS file!" ) ), EXIT_NOIMGLIST ); - - delete pSRS; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/bmpcore.hxx b/svtools/bmpmaker/bmpcore.hxx deleted file mode 100644 index 9230b291b837..000000000000 --- a/svtools/bmpmaker/bmpcore.hxx +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#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 ]; - sal_uInt16 mnLangNum; -}; - -// -------------- -// - BmpCreator - -// -------------- - -class BmpCreator -{ -private: - - Bitmap aOutBmp; - Size aOneSize; - Size aTotSize; - Point aPos; - SvFileStream* pSRS; - - void ImplCreate( const ::std::vector< DirEntry >& rInDirs, - const DirEntry& rOut, - const String& rName, - const LangInfo& rLang ); - -protected: - - virtual void Message( const String& rText, sal_uInt8 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 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/bmpsum.cxx b/svtools/bmpmaker/bmpsum.cxx deleted file mode 100644 index 0551ddebdde9..000000000000 --- a/svtools/bmpmaker/bmpsum.cxx +++ /dev/null @@ -1,470 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <cstdio> -#include <csignal> -#include <vector> -#include <set> -#include <map> - -#include <comphelper/string.hxx> -#include <rtl/crc.h> -#include <rtl/strbuf.hxx> -#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; - - sal_Bool GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rSwitchParam ); - - void SetExitCode( sal_uInt8 cExit ) - { - if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) ) - cExitCode = cExit; - } - void ShowUsage(); - void Message( const String& rText, sal_uInt8 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() -{ -} - -// ----------------------------------------------------------------------- - -sal_Bool BmpSum::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam ) -{ - sal_Bool bRet = sal_False; - - for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ ) - { - rtl::OUString aTestStr( '-' ); - - for( int n = 0; ( n < 2 ) && !bRet; n++ ) - { - aTestStr += rSwitch; - - if( aTestStr.equalsIgnoreAsciiCase( rArgs[ i ] ) ) - { - bRet = sal_True; - - if( i < ( nCount - 1 ) ) - rParam = rArgs[ i + 1 ]; - else - rParam = String(); - } - - if( 0 == n ) - aTestStr = rtl::OUString('/'); - } - } - - return bRet; -} - -// ----------------------------------------------------------------------- - -void BmpSum::Message( const String& rText, sal_uInt8 nExitCode ) -{ - if( EXIT_NOERROR != nExitCode ) - SetExitCode( nExitCode ); - - rtl::OStringBuffer aText(rtl::OUStringToOString(rText, RTL_TEXTENCODING_UTF8)); - aText.append(RTL_CONSTASCII_STRINGPARAM("\r\n")); - fprintf(stderr, "%s", aText.getStr()); -} - -// ----------------------------------------------------------------------------- - -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, rtl::OUString('i'), aInFileList ) && - GetCommandOption( rArgs, rtl::OUString('o'), aOutFileList ) ) - { - GetCommandOption( rArgs, rtl::OUString('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; - - if( rBmpEx.IsTransparent() ) - { - aAlpha = rBmpEx.GetAlpha(); - pAAcc = aAlpha.AcquireReadAccess(); - } - - if( pRAcc && pRAcc->Width() && pRAcc->Height() ) - { - SVBT32 aBT32; - sal_uInt32 nCrc = 0; - - 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() ) - { - rtl::OString aReadLine; - ::std::set<rtl::OString> aFileNameSet; - - while( aIStm.ReadLine( aReadLine ) ) - { - if( !aReadLine.isEmpty() ) - aFileNameSet.insert( aReadLine ); - - if( aReadLine.indexOfL(RTL_CONSTASCII_STRINGPARAM("enus") ) != -1 ) - { - 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 ) - { - rtl::OString aLangPath( - aReadLine.replaceAll( - rtl::OString(RTL_CONSTASCII_STRINGPARAM("enus")), - rtl::OString(aLanguages[n]))); - - DirEntry aTestFile( aLangPath ); - - if( aTestFile.Exists() ) - aFileNameSet.insert( aLangPath ); - } - } - - aReadLine = rtl::OString(); - } - - aIStm.Close(); - - ::std::set< rtl::OString >::iterator aIter( aFileNameSet.begin() ); - ::std::map< sal_uInt64, ::std::vector< rtl::OString > > aFileNameMap; - - while( aIter != aFileNameSet.end() ) - { - rtl::OString aStr( *aIter++ ); - SvFileStream aBmpStm(rtl::OStringToOUString(aStr, 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.getStr() ); - } - - aBmpStm.Close(); - } - - if( nCRC ) - { - ::std::map< sal_uInt64, ::std::vector< rtl::OString > >::iterator aFound( aFileNameMap.find( nCRC ) ); - - if( aFound != aFileNameMap.end() ) - (*aFound).second.push_back( aStr ); - else - { - ::std::vector< rtl::OString > aVector( 1, aStr ); - aFileNameMap[ nCRC ] = aVector; - } - - } - else - { - ::std::vector< rtl::OString > aVector( 1, aStr ); - aFileNameMap[ nCRC ] = aVector; - } - } - - ::std::map< sal_uInt64, ::std::vector< rtl::OString > >::iterator aMapIter( aFileNameMap.begin() ); - sal_uInt32 nFileCount = 0; - - while( aMapIter != aFileNameMap.end() ) - { - ::std::pair< const sal_uInt64, ::std::vector< rtl::OString > > aPair( *aMapIter++ ); - ::std::vector< rtl::OString > aFileNameVector( aPair.second ); - - // write new entries - for( sal_uInt32 i = 0; i < aFileNameVector.size(); ++i ) - { - rtl::OString aFileName( aFileNameVector[ i ] ); - DirEntry aSrcFile( aFileName ); - - rtl::OStringBuffer aStr; - aStr.append(static_cast<sal_Int64>(aPair.first)) - .append('\t').append(aFileName); - aOStm.WriteLine( aStr.makeStringAndClear() ); - - // copy bitmap - if( rOutPath.Len() ) - { - sal_Int32 nIndex = aFileName.indexOf(":\\"); - if (nIndex != -1) - aFileName = aFileName.copy(nIndex + 2); - - aFileName = aFileName.replace('\\', '/'); - - sal_Int32 nTokenCount = comphelper::string::getTokenCount(aFileName, '/'); - DirEntry aNewDir( aBaseDir ); - - for (sal_Int32 n = 0; ( n < nTokenCount - 1 ); ++n) - { - aNewDir += DirEntry( comphelper::string::getToken(aFileName, n, '/') ); - aNewDir.MakeDir(); - } - - aNewDir += DirEntry( comphelper::string::getToken(aFileName, 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(); - - for( int i = 1; i < nArgCount; i++ ) - aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) ); - - return aBmpSum.Start( aArgs ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/bmpmaker/g2g.cxx b/svtools/bmpmaker/g2g.cxx deleted file mode 100644 index 9a3508c96198..000000000000 --- a/svtools/bmpmaker/g2g.cxx +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include <stdio.h> -#include <signal.h> -#include <ctype.h> - -#include <rtl/strbuf.hxx> -#include <tools/fsys.hxx> -#include <tools/stream.hxx> -#include <vcl/svapp.hxx> -#include <vcl/graphicfilter.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: - - sal_uInt8 cExitCode; - - void ShowUsage(); - sal_Bool GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam ); - void SetExitCode( sal_uInt8 cExit ) { if( ( EXIT_NOERROR == cExitCode ) || ( cExit != EXIT_NOERROR ) ) cExitCode = cExit; } - - virtual void Message( const String& rText, sal_uInt8 cExitCode = EXIT_NOERROR ); - -public: - - G2GApp(); - virtual ~G2GApp(); - - int Start( const ::std::vector< String >& rArgs ); -}; - -// ----------------------------------------------------------------------- - -G2GApp::G2GApp() -{ -} - -// ----------------------------------------------------------------------- - -G2GApp::~G2GApp() -{ -} - -// ----------------------------------------------------------------------- - -sal_Bool G2GApp::GetCommandOption( const ::std::vector< String >& rArgs, const String& rSwitch, String& rParam ) -{ - sal_Bool bRet = sal_False; - - for( int i = 0, nCount = rArgs.size(); ( i < nCount ) && !bRet; i++ ) - { - rtl::OUString aTestStr( '-' ); - - for( int n = 0; ( n < 2 ) && !bRet; n++ ) - { - aTestStr += rSwitch; - - if( aTestStr.equalsIgnoreAsciiCase( rArgs[ i ] ) ) - { - bRet = sal_True; - - if( i < ( nCount - 1 ) ) - rParam = rArgs[ i + 1 ]; - else - rParam = String(); - } - - if( 0 == n ) - aTestStr = rtl::OUString('/'); - } - } - - return bRet; -} - -// ----------------------------------------------------------------------- - -void G2GApp::Message( const String& rText, sal_uInt8 nExitCode ) -{ - if( EXIT_NOERROR != nExitCode ) - SetExitCode( nExitCode ); - - rtl::OStringBuffer aText(rtl::OUStringToOString(rText, RTL_TEXTENCODING_UTF8)); - aText.append(RTL_CONSTASCII_STRINGPARAM("\r\n")); - fprintf(stderr, "%s", aText.getStr()); -} - -// ----------------------------------------------------------------------------- - -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 ) -{ - size_t nCmdCount = rArgs.size(); - - cExitCode = EXIT_NOERROR; - - if( nCmdCount >= 6 ) - { - GraphicFilter aFilter( sal_False ); - String aInFile, aOutFile, aFilterStr, aFilterPath, aTransColStr; - size_t nCurCmd = 0; - - aInFile = rArgs[ nCurCmd++ ]; - aOutFile = rArgs[ nCurCmd++ ]; - GetCommandOption( rArgs, rtl::OUString("format"), aFilterStr ); - GetCommandOption( rArgs, rtl::OUString("filterpath"), aFilterPath ); - GetCommandOption( rArgs, rtl::OUString('#'), aTransColStr ); - - aFilter.SetFilterPath( aFilterPath ); - - if( aInFile.Len() && aOutFile.Len() && aFilterStr.Len() ) - { - const sal_uInt16 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 ) ) - { - rtl::OString aHexStr(rtl::OUStringToOString(aTransColStr, RTL_TEXTENCODING_ASCII_US). - toAsciiLowerCase()); - sal_Bool bHex = sal_True; - - for( sal_uInt16 i = 0; ( i < 6 ) && bHex; i++ ) - if( !isxdigit( aHexStr[i] ) ) - bHex = sal_False; - - if( bHex ) - { - const sal_uInt8 cTransR = ( LOWERHEXTONUM( aHexStr[0] ) << 4 ) | LOWERHEXTONUM( aHexStr[1] ); - const sal_uInt8 cTransG = ( LOWERHEXTONUM( aHexStr[2] ) << 4 ) | LOWERHEXTONUM( aHexStr[3] ); - const sal_uInt8 cTransB = ( LOWERHEXTONUM( aHexStr[4] ) << 4 ) | LOWERHEXTONUM( aHexStr[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(); - - for( int i = 1; i < nArgCount; i++ ) - aArgs.push_back( String( ppArgs[ i ], RTL_TEXTENCODING_ASCII_US ) ); - - return aG2GApp.Start( aArgs ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |