summaryrefslogtreecommitdiff
path: root/vcl/source/helper
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-03-06 09:33:41 +0000
committerOliver Bolte <obo@openoffice.org>2009-03-06 09:33:41 +0000
commit659af2052b0471ff4507f1742a4f0c0681d66e8e (patch)
treed047328a27e779c050e18e63766fed55f759bdd1 /vcl/source/helper
parent3315021862137d58fd8d57c035d397474a9df644 (diff)
CWS-TOOLING: integrate CWS movepsprint
2009-02-27 10:42:24 +0100 pl r268559 : #i99633# remove X11 build for mac 2009-02-26 16:38:01 +0100 pl r268535 : #i97898# move psprint to vcl: no more linking psprint 2009-02-26 16:36:35 +0100 pl r268534 : #i97898# move psprint to vcl: tentative os2 changes 2009-02-26 16:20:36 +0100 pl r268532 : #i97898# move psprint to vcl: make compile again, round 5 2009-02-26 15:53:12 +0100 pl r268530 : #i97898# psprint removed 2009-02-26 13:43:40 +0100 pl r268513 : #i97898# use proper X display in PrintFontManager::initialize 2009-02-26 12:39:05 +0100 pl r268496 : #i99633# remove unsused header 2009-02-25 19:12:54 +0100 pl r268467 : #i99633# get rid of special casing for the now discontinued Mac X11 port 2009-02-25 18:25:37 +0100 pl r268466 : #i97898# move psprint to vcl: make compile again, round 4 2009-02-25 17:38:55 +0100 pl r268458 : #i97898# move psprint to vcl: make compile again, round 3 2009-02-25 16:55:15 +0100 pl r268452 : #i97898# move psprint to vcl: remove psp lib from install set 2009-02-25 16:50:25 +0100 pl r268451 : #i97898# move psprint to vcl: make compile again, round 2 2009-02-25 16:10:50 +0100 pl r268448 : #i97898# move psprint to vcl: make compile again, round 1 2009-02-25 14:38:12 +0100 pl r268440 : #i97898# move psprint to vcl: remove references to psprint in solenv 2009-02-25 14:22:22 +0100 pl r268437 : #i97898# move psprint to vcl, first step: move in svn
Diffstat (limited to 'vcl/source/helper')
-rw-r--r--vcl/source/helper/makefile.mk1
-rw-r--r--vcl/source/helper/strhelper.cxx445
2 files changed, 446 insertions, 0 deletions
diff --git a/vcl/source/helper/makefile.mk b/vcl/source/helper/makefile.mk
index 520ed6b3a17a..6f0d4959c9c4 100644
--- a/vcl/source/helper/makefile.mk
+++ b/vcl/source/helper/makefile.mk
@@ -44,6 +44,7 @@ TARGET=helper
# --- Files --------------------------------------------------------
SLOFILES=\
+ $(SLO)$/strhelper.obj \
$(SLO)$/evntpost.obj \
$(SLO)$/canvasbitmap.obj \
$(SLO)$/canvastools.obj \
diff --git a/vcl/source/helper/strhelper.cxx b/vcl/source/helper/strhelper.cxx
new file mode 100644
index 000000000000..5b503fa65c05
--- /dev/null
+++ b/vcl/source/helper/strhelper.cxx
@@ -0,0 +1,445 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: strhelper.cxx,v $
+ * $Revision: 1.16 $
+ *
+ * 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_vcl.hxx"
+
+#include "vcl/strhelper.hxx"
+#include "sal/alloca.h"
+
+namespace psp {
+
+inline int isSpace( char cChar )
+{
+ return
+ cChar == ' ' || cChar == '\t' ||
+ cChar == '\r' || cChar == '\n' ||
+ cChar == 0x0c || cChar == 0x0b;
+}
+
+inline int isSpace( sal_Unicode cChar )
+{
+ return
+ cChar == ' ' || cChar == '\t' ||
+ cChar == '\r' || cChar == '\n' ||
+ cChar == 0x0c || cChar == 0x0b;
+}
+
+inline int isProtect( char cChar )
+{
+ return cChar == '`' || cChar == '\'' || cChar == '"';
+}
+
+inline int isProtect( sal_Unicode cChar )
+{
+ return cChar == '`' || cChar == '\'' || cChar == '"';
+}
+
+inline void CopyUntil( char*& pTo, const char*& pFrom, char cUntil, int bIncludeUntil = 0 )
+{
+ do
+ {
+ if( *pFrom == '\\' )
+ {
+ pFrom++;
+ if( *pFrom )
+ {
+ *pTo = *pFrom;
+ pTo++;
+ }
+ }
+ else if( bIncludeUntil || ! isProtect( *pFrom ) )
+ {
+ *pTo = *pFrom;
+ pTo++;
+ }
+ pFrom++;
+ } while( *pFrom && *pFrom != cUntil );
+ // copy the terminating character unless zero or protector
+ if( ! isProtect( *pFrom ) || bIncludeUntil )
+ {
+ *pTo = *pFrom;
+ if( *pTo )
+ pTo++;
+ }
+ if( *pFrom )
+ pFrom++;
+}
+
+inline void CopyUntil( sal_Unicode*& pTo, const sal_Unicode*& pFrom, sal_Unicode cUntil, int bIncludeUntil = 0 )
+{
+ do
+ {
+ if( *pFrom == '\\' )
+ {
+ pFrom++;
+ if( *pFrom )
+ {
+ *pTo = *pFrom;
+ pTo++;
+ }
+ }
+ else if( bIncludeUntil || ! isProtect( *pFrom ) )
+ {
+ *pTo = *pFrom;
+ pTo++;
+ }
+ pFrom++;
+ } while( *pFrom && *pFrom != cUntil );
+ // copy the terminating character unless zero or protector
+ if( ! isProtect( *pFrom ) || bIncludeUntil )
+ {
+ *pTo = *pFrom;
+ if( *pTo )
+ pTo++;
+ }
+ if( *pFrom )
+ pFrom++;
+}
+
+String GetCommandLineToken( int nToken, const String& rLine )
+{
+ int nLen = rLine.Len();
+ if( ! nLen )
+ return String();
+
+ int nActualToken = 0;
+ sal_Unicode* pBuffer = (sal_Unicode*)alloca( sizeof(sal_Unicode)*( nLen + 1 ) );
+ const sal_Unicode* pRun = rLine.GetBuffer();
+ sal_Unicode* pLeap = NULL;
+
+ while( *pRun && nActualToken <= nToken )
+ {
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ pLeap = pBuffer;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ *pLeap = *pRun;
+ pLeap++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '`' )
+ CopyUntil( pLeap, pRun, '`' );
+ else if( *pRun == '\'' )
+ CopyUntil( pLeap, pRun, '\'' );
+ else if( *pRun == '"' )
+ CopyUntil( pLeap, pRun, '"' );
+ else
+ {
+ *pLeap = *pRun;
+ pLeap++;
+ pRun++;
+ }
+ }
+ if( nActualToken != nToken )
+ pBuffer[0] = 0;
+ nActualToken++;
+ }
+
+ *pLeap = 0;
+
+ String aRet( pBuffer );
+ return aRet;
+}
+
+ByteString GetCommandLineToken( int nToken, const ByteString& rLine )
+{
+ int nLen = rLine.Len();
+ if( ! nLen )
+ return ByteString();
+
+ int nActualToken = 0;
+ char* pBuffer = (char*)alloca( nLen + 1 );
+ const char* pRun = rLine.GetBuffer();
+ char* pLeap = NULL;
+
+ while( *pRun && nActualToken <= nToken )
+ {
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ pLeap = pBuffer;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ *pLeap = *pRun;
+ pLeap++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '`' )
+ CopyUntil( pLeap, pRun, '`' );
+ else if( *pRun == '\'' )
+ CopyUntil( pLeap, pRun, '\'' );
+ else if( *pRun == '"' )
+ CopyUntil( pLeap, pRun, '"' );
+ else
+ {
+ *pLeap = *pRun;
+ pLeap++;
+ pRun++;
+ }
+ }
+ if( nActualToken != nToken )
+ pBuffer[0] = 0;
+ nActualToken++;
+ }
+
+ *pLeap = 0;
+
+ ByteString aRet( pBuffer );
+ return aRet;
+}
+
+int GetCommandLineTokenCount( const String& rLine )
+{
+ if( ! rLine.Len() )
+ return 0;
+
+ int nTokenCount = 0;
+ const sal_Unicode *pRun = rLine.GetBuffer();
+
+
+ while( *pRun )
+ {
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ if( ! *pRun )
+ break;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '`' )
+ {
+ do pRun++; while( *pRun && *pRun != '`' );
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '\'' )
+ {
+ do pRun++; while( *pRun && *pRun != '\'' );
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '"' )
+ {
+ do pRun++; while( *pRun && *pRun != '"' );
+ if( *pRun )
+ pRun++;
+ }
+ else
+ pRun++;
+ }
+ nTokenCount++;
+ }
+
+ return nTokenCount;
+}
+
+int GetCommandLineTokenCount( const ByteString& rLine )
+{
+ if( ! rLine.Len() )
+ return 0;
+
+ int nTokenCount = 0;
+ const char *pRun = rLine.GetBuffer();
+
+
+ while( *pRun )
+ {
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ if( ! *pRun )
+ break;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '`' )
+ {
+ do pRun++; while( *pRun && *pRun != '`' );
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '\'' )
+ {
+ do pRun++; while( *pRun && *pRun != '\'' );
+ if( *pRun )
+ pRun++;
+ }
+ else if( *pRun == '"' )
+ {
+ do pRun++; while( *pRun && *pRun != '"' );
+ if( *pRun )
+ pRun++;
+ }
+ else
+ pRun++;
+ }
+ nTokenCount++;
+ }
+
+ return nTokenCount;
+}
+
+String WhitespaceToSpace( const String& rLine, BOOL bProtect )
+{
+ int nLen = rLine.Len();
+ if( ! nLen )
+ return String();
+
+ sal_Unicode *pBuffer = (sal_Unicode*)alloca( sizeof(sal_Unicode)*(nLen + 1) );
+ const sal_Unicode *pRun = rLine.GetBuffer();
+ sal_Unicode *pLeap = pBuffer;
+
+ while( *pRun )
+ {
+ if( *pRun && isSpace( *pRun ) )
+ {
+ *pLeap = ' ';
+ pLeap++;
+ pRun++;
+ }
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ *pLeap = *pRun;
+ pLeap++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( bProtect && *pRun == '`' )
+ CopyUntil( pLeap, pRun, '`', TRUE );
+ else if( bProtect && *pRun == '\'' )
+ CopyUntil( pLeap, pRun, '\'', TRUE );
+ else if( bProtect && *pRun == '"' )
+ CopyUntil( pLeap, pRun, '"', TRUE );
+ else
+ {
+ *pLeap = *pRun;
+ *pLeap++;
+ *pRun++;
+ }
+ }
+ }
+
+ *pLeap = 0;
+
+ // there might be a space at beginning or end
+ pLeap--;
+ if( *pLeap == ' ' )
+ *pLeap = 0;
+
+ String aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
+ return aRet;
+}
+
+ByteString WhitespaceToSpace( const ByteString& rLine, BOOL bProtect )
+{
+ int nLen = rLine.Len();
+ if( ! nLen )
+ return ByteString();
+
+ char *pBuffer = (char*)alloca( nLen + 1 );
+ const char *pRun = rLine.GetBuffer();
+ char *pLeap = pBuffer;
+
+ while( *pRun )
+ {
+ if( *pRun && isSpace( *pRun ) )
+ {
+ *pLeap = ' ';
+ pLeap++;
+ pRun++;
+ }
+ while( *pRun && isSpace( *pRun ) )
+ pRun++;
+ while( *pRun && ! isSpace( *pRun ) )
+ {
+ if( *pRun == '\\' )
+ {
+ // escapement
+ pRun++;
+ *pLeap = *pRun;
+ pLeap++;
+ if( *pRun )
+ pRun++;
+ }
+ else if( bProtect && *pRun == '`' )
+ CopyUntil( pLeap, pRun, '`', TRUE );
+ else if( bProtect && *pRun == '\'' )
+ CopyUntil( pLeap, pRun, '\'', TRUE );
+ else if( bProtect && *pRun == '"' )
+ CopyUntil( pLeap, pRun, '"', TRUE );
+ else
+ {
+ *pLeap = *pRun;
+ *pLeap++;
+ *pRun++;
+ }
+ }
+ }
+
+ *pLeap = 0;
+
+ // there might be a space at beginning or end
+ pLeap--;
+ if( *pLeap == ' ' )
+ *pLeap = 0;
+
+ ByteString aRet( *pBuffer == ' ' ? pBuffer+1 : pBuffer );
+ return aRet;
+}
+
+} // namespace