summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-02-11 10:53:35 +0000
committerOliver Bolte <obo@openoffice.org>2009-02-11 10:53:35 +0000
commite03fcb7ad74e6f216529ad1109ac72acf155d004 (patch)
tree0895436a9ec19a28c5051281d9add3964e8ddcae /sdext
parentfb28cb32cf2de10d6f5a609873ca01eb231471c1 (diff)
CWS-TOOLING: integrate CWS vcl98
2009-01-16 15:17:38 +0100 pl r266422 : #i93515# add fix for compiz (thanks cmc) 2009-01-15 10:55:36 +0100 thb r266352 : #i97399# start==end angle means no arc at all 2009-01-14 18:54:37 +0100 pl r266327 : #i96536# #i96396# add: pagescroll for wheel events (thanks mod) 2009-01-14 18:21:06 +0100 pl r266325 : #i96536# #i96396# add: gestures, bracket matching (thanks mod) 2009-01-13 12:03:29 +0100 hdu r266206 : #i98024# preserve glyph zero-advance for artificial bold and vertical layout (thanks CMC!) 2009-01-12 16:32:20 +0100 hdu r266167 : #i97991# fix rotated text: temporary workaround for #i87686# 2009-01-08 17:16:17 +0100 hdu r266028 : #159054# ignore empty ATSULayout 2009-01-08 16:59:05 +0100 hdu r266026 : #159054# prevent invalid ATSUStyle 2009-01-07 19:04:06 +0100 pl r265976 : #158288# add extraction of fonts and individual object streams to pdfunzip 2009-01-07 14:42:17 +0100 pl r265969 : #i93011# workaround our ancient accelerator mechanisms to have deeper child window hirearchies working 2009-01-07 14:39:15 +0100 pl r265967 : #i93011# workaround our ancient accelerator mechanisms to have deeper child window hirearchies working 2009-01-07 11:10:58 +0100 hdu r265956 : #i97522# getPixel() returns COL_BLACK on printers or when out of bounds 2009-01-06 18:41:48 +0100 pl r265938 : #i97696# do not force user password to owner password after all 2009-01-06 18:00:52 +0100 pl r265934 : #i97157# fix a snafu 2009-01-06 13:23:38 +0100 pl r265914 : #i93515# support for _NET_WM_USER_TIME (thanks cmc) 2009-01-06 12:50:37 +0100 hdu r265912 : #i97538# get rid of compiler warnings for complex logical expressions 2009-01-06 12:49:09 +0100 hdu r265911 : #i97538# get rid of compiler warnings for complex logical expressions 2009-01-06 12:14:07 +0100 hdu r265906 : #i97522# implemented AquaSalGraphics::getPixel() 2008-12-18 16:46:59 +0100 pl r265706 : #i96343# reset quick job flag 2008-12-18 16:44:22 +0100 pl r265705 : #i96343# reset quick job flag 2008-12-18 14:08:22 +0100 pl r265688 : #i93241# fix bit field query 2008-12-18 12:41:52 +0100 pl r265682 : #i93241# eliminate useless static locale variable 2008-12-17 19:23:07 +0100 pl r265654 : #i97064# set language to OOo user configured UI language (thanks cmc) 2008-12-17 17:44:38 +0100 hdu r265651 : #i97326# debug-helper: print cairo version 2008-12-17 17:43:15 +0100 hdu r265650 : #i97326# ignore cairo changing the transformation of our FT_FACE 2008-12-17 14:44:32 +0100 pl r265604 : #i93631# refine control positioning 2008-12-17 12:40:39 +0100 hdu r265596 : #i97167# update VCL.xcu for MacOSX for Japanese (thanks maho!) 2008-12-17 11:59:51 +0100 hdu r265592 : #i97317# code movement to prevent needless and expensive construction/destruction in error path 2008-12-17 11:54:43 +0100 hdu r265590 : #i97317# workaround QUARTZ bug with drawing small polygons 2008-12-16 17:57:02 +0100 pl r265567 : #i97138# select num copies when grabbing focus 2008-12-16 17:15:11 +0100 pl r265561 : #i93173# lazy deletion of toolbars 2008-12-16 16:33:51 +0100 pl r265558 : #i93173# lazy deletion of toolbars: reparent floating DockingWindows in doLazyDelete 2008-12-16 13:23:17 +0100 pl r265536 : #i97196# ensure style engine has been loaded (thanks cmc)
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/pdfimport/test/pdfunzip.cxx154
1 files changed, 152 insertions, 2 deletions
diff --git a/sdext/source/pdfimport/test/pdfunzip.cxx b/sdext/source/pdfimport/test/pdfunzip.cxx
index 0feaa268b760..c9e5ece0b3ac 100644
--- a/sdext/source/pdfimport/test/pdfunzip.cxx
+++ b/sdext/source/pdfimport/test/pdfunzip.cxx
@@ -48,12 +48,22 @@ using namespace pdfparse;
void printHelp( const char* pExe )
{
fprintf( stdout,
- "USAGE: %s [-h,--help] [-a, --extract-add-streams] [-pw, --password <password>] <inputfile> [<outputfile>]\n"
+ "USAGE: %s [-h,--help]\n"
+ " %s [-pw, --password <password>] <inputfile> [<outputfile>]\n"
+ " %s <-a, --extract-add-streams> [-pw, --password <password>] <inputfile> [<outputfile>]\n"
+ " %s <-f, --extract-fonts> [-pw, --password <password>] <inputfile> [<outputfile>]\n"
+ " %s <-o, --extract-objects> <o0>[:<g0>][,<o1>[:g1][,...]] [-pw, --password <password>] <inputfile> [<outputfile>]\n"
" -h, --help: show help\n"
" -a, --extract-add-streams: extracts additional streams to outputfile_object\n"
" and prints the mimetype found to stdout\n"
+ " -f, --extract-fonts: extracts fonts (currently only type1 and truetype are supported\n"
+ " -o, --extract-objects: extracts object streams, the syntax of the argument is comma separated\n"
+ " object numbers, where object number and generation number are separated by \':\'\n"
+ " an omitted generation number defaults to 0\n"
" -pw, --password: use password for decryption\n"
- , pExe );
+ "\n"
+ "note: -f, -a, -o and normal unzip operation are mutually exclusive\n"
+ , pExe, pExe, pExe, pExe, pExe );
}
class FileEmitContext : public EmitContext
@@ -313,6 +323,119 @@ int write_addStreams( const char* pInFile, const char* pOutFile, PDFFile* pPDFFi
return nRet;
}
+int write_fonts( const char* i_pInFile, const char* i_pOutFile, PDFFile* i_pPDFFile )
+{
+ int nRet = 0;
+ unsigned int nElements = i_pPDFFile->m_aSubElements.size();
+ for( unsigned i = 0; i < nElements && nRet == 0; i++ )
+ {
+ // search FontDescriptors
+ PDFObject* pObj = dynamic_cast<PDFObject*>(i_pPDFFile->m_aSubElements[i]);
+ if( ! pObj )
+ continue;
+ PDFDict* pDict = dynamic_cast<PDFDict*>(pObj->m_pObject);
+ if( ! pDict )
+ continue;
+
+ std::hash_map<rtl::OString,PDFEntry*,rtl::OStringHash>::iterator map_it =
+ pDict->m_aMap.find( "Type" );
+ if( map_it == pDict->m_aMap.end() )
+ continue;
+
+ PDFName* pName = dynamic_cast<PDFName*>(map_it->second);
+ if( ! pName )
+ continue;
+ if( ! pName->m_aName.equals( "FontDescriptor" ) )
+ continue;
+
+ // the font name will be helpful, also there must be one in
+ // a font descriptor
+ map_it = pDict->m_aMap.find( "FontName" );
+ if( map_it == pDict->m_aMap.end() )
+ continue;
+ pName = dynamic_cast<PDFName*>(map_it->second);
+ if( ! pName )
+ continue;
+ rtl::OString aFontName( pName->m_aName );
+
+ PDFObjectRef* pStreamRef = 0;
+ const char* pFileType = NULL;
+ // we have a font descriptor, try for a type 1 font
+ map_it = pDict->m_aMap.find( "FontFile" );
+ if( map_it != pDict->m_aMap.end() )
+ {
+ pStreamRef = dynamic_cast<PDFObjectRef*>(map_it->second);
+ if( pStreamRef )
+ pFileType = "pfa";
+ }
+
+ // perhaps it's a truetype file ?
+ if( ! pStreamRef )
+ {
+ map_it = pDict->m_aMap.find( "FontFile2" );
+ if( map_it != pDict->m_aMap.end() )
+ {
+ pStreamRef = dynamic_cast<PDFObjectRef*>(map_it->second);
+ if( pStreamRef )
+ pFileType = "ttf";
+ }
+ }
+
+ if( ! pStreamRef )
+ continue;
+
+ PDFObject* pStream = i_pPDFFile->findObject( pStreamRef );
+ if( ! pStream )
+ continue;
+
+ rtl::OStringBuffer aOutStream( i_pOutFile );
+ aOutStream.append( "_font_" );
+ aOutStream.append( sal_Int32(pStreamRef->m_nNumber) );
+ aOutStream.append( "_" );
+ aOutStream.append( sal_Int32(pStreamRef->m_nGeneration) );
+ aOutStream.append( "_" );
+ aOutStream.append( aFontName );
+ if( pFileType )
+ {
+ aOutStream.append( "." );
+ aOutStream.append( pFileType );
+ }
+ FileEmitContext aContext( aOutStream.getStr(), i_pInFile, i_pPDFFile );
+ aContext.m_bDecrypt = i_pPDFFile->isEncrypted();
+ pStream->writeStream( aContext, i_pPDFFile );
+ }
+ return nRet;
+}
+
+std::vector< std::pair< sal_Int32, sal_Int32 > > s_aEmitObjects;
+
+int write_objects( const char* i_pInFile, const char* i_pOutFile, PDFFile* i_pPDFFile )
+{
+ int nRet = 0;
+ unsigned int nElements = s_aEmitObjects.size();
+ for( unsigned i = 0; i < nElements && nRet == 0; i++ )
+ {
+ sal_Int32 nObject = s_aEmitObjects[i].first;
+ sal_Int32 nGeneration = s_aEmitObjects[i].second;
+ PDFObject* pStream = i_pPDFFile->findObject( nObject, nGeneration );
+ if( ! pStream )
+ {
+ fprintf( stderr, "object %d %d not found !\n", (int)nObject, (int)nGeneration );
+ continue;
+ }
+
+ rtl::OStringBuffer aOutStream( i_pOutFile );
+ aOutStream.append( "_stream_" );
+ aOutStream.append( nObject );
+ aOutStream.append( "_" );
+ aOutStream.append( nGeneration );
+ FileEmitContext aContext( aOutStream.getStr(), i_pInFile, i_pPDFFile );
+ aContext.m_bDecrypt = i_pPDFFile->isEncrypted();
+ pStream->writeStream( aContext, i_pPDFFile );
+ }
+ return nRet;
+}
+
SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
{
const char* pInFile = NULL;
@@ -347,6 +470,33 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
{
aHdl = write_addStreams;
}
+ else if( ! rtl_str_compare( "-f", argv[nArg] ) ||
+ ! rtl_str_compare( "--extract-fonts", argv[nArg] ) )
+ {
+ aHdl = write_fonts;
+ }
+ else if( ! rtl_str_compare( "-o", argv[nArg] ) ||
+ ! rtl_str_compare( "--extract-objects", argv[nArg] ) )
+ {
+ aHdl = write_objects;
+ nArg++;
+ if( nArg < argc )
+ {
+ rtl::OString aObjs( argv[nArg] );
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 )
+ {
+ rtl::OString aToken( aObjs.getToken( 0, ',', nIndex ) );
+ sal_Int32 nObject = 0;
+ sal_Int32 nGeneration = 0;
+ sal_Int32 nGenIndex = 0;
+ nObject = aToken.getToken( 0, ':', nGenIndex ).toInt32();
+ if( nGenIndex != -1 )
+ nGeneration = aToken.getToken( 0, ':', nGenIndex ).toInt32();
+ s_aEmitObjects.push_back( std::pair<sal_Int32,sal_Int32>(nObject,nGeneration) );
+ }
+ }
+ }
else
{
fprintf( stderr, "unrecognized option \"%s\"\n",