diff options
Diffstat (limited to 'tools/inc')
96 files changed, 19880 insertions, 0 deletions
diff --git a/tools/inc/bootstrp/appdef.hxx b/tools/inc/bootstrp/appdef.hxx new file mode 100644 index 000000000000..bf73b215205e --- /dev/null +++ b/tools/inc/bootstrp/appdef.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * 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 _MHAPPDEF_HXX +#define _MHAPPDEF_HXX + + +#ifdef UNX +#define DEFAULT_INI_ROOT "/so/env" +#define DEFAULT_BS_ROOT "/so/env/b_server" +#define PATH_SEPARATOR '/' +#define S_PATH_SEPARATOR "/" +#else +#define DEFAULT_INI_ROOT "r:" +#define DEFAULT_BS_ROOT "n:" +#define PATH_SEPARATOR '\\' +#define S_PATH_SEPARATOR "\\" +#endif + +#define _INI_DRV DEFAULT_INI_ROOT +#define B_SERVER_ROOT DEFAULT_BS_ROOT +#define _SOLARLIST B_SERVER_ROOT S_PATH_SEPARATOR "config" S_PATH_SEPARATOR "solar.lst" +#define _DEF_STAND_LIST B_SERVER_ROOT S_PATH_SEPARATOR "config" S_PATH_SEPARATOR "stand.lst" +#define _DEF_SSOLARINI B_SERVER_ROOT S_PATH_SEPARATOR "config" S_PATH_SEPARATOR "ssolar.ini" +#define _DEF_SSCOMMON B_SERVER_ROOT S_PATH_SEPARATOR "config" S_PATH_SEPARATOR "ssolar.cmn" +#define _INIROOT B_SERVER_ROOT S_PATH_SEPARATOR "config" +#define _INIROOT_OLD B_SERVER_ROOT S_PATH_SEPARATOR "config" +#define _INI_UNC "\\\\jumbo2.germany.sun.com\\R-Laufwerk" +#define _INI_UNC_OLD "\\\\jumbo2.germany.sun.com\\R-Laufwerk" + + +// path conversion +const char* GetDefStandList(); +const char* GetIniRoot(); +const char* GetIniRootOld(); +const char* GetSSolarIni(); +const char* GetSSCommon(); +const char* GetBServerRoot(); + +const char* GetEnv( const char *pVar ); +const char* GetEnv( const char *pVar, const char *pDefault ); + + +#endif diff --git a/tools/inc/bootstrp/command.hxx b/tools/inc/bootstrp/command.hxx new file mode 100644 index 000000000000..638beb6cce1f --- /dev/null +++ b/tools/inc/bootstrp/command.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * 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 COMMAND_HXX +#define COMMAND_HXX + +#include <iostream> + +#include <tools/stream.hxx> +#define STRLEN 100 +#ifndef UNX +#define TMPNAME "\\command.tmp" +#else +#define TMPNAME "/tmp/command.tmp" +#endif + +/** Different types of spawnable programs +*/ +enum ExeType +{ + EXE, /// programm is a native executable + BAT, /// programm is a DOS-Batch + BTM /// programm is a 4DOS-Batch +}; + +#define COMMAND_NOTFOUND 0x0001 +#define COMMAND_TOOBIG 0x0002 +#define COMMAND_INVALID 0x0004 +#define COMMAND_NOEXEC 0x0008 +#define COMMAND_NOMEM 0x0010 +#define COMMAND_UNKNOWN 0x0020 + +#ifdef WNT +#define COMMAND_SHELL "4nt.exe" +#endif +#ifdef OS2 +#define COMMAND_SHELL "4os2.exe" +#endif +#ifdef UNX +#define COMMAND_SHELL "csh" +#endif + +class CommandLine; +class LogWindow; + +class CommandLine +{ +friend class ChildProcess; +private: + char *CommandBuffer; + char *ComShell; + char **ppArgv; + BOOL bTmpWrite; + +public: + CommandLine(BOOL bTmpWrite = FALSE); + CommandLine(const char *, BOOL bTmpWrite = FALSE); + CommandLine(const CommandLine&, BOOL bTmpWrite = FALSE); + virtual ~CommandLine(); + + int nArgc; + + CommandLine& operator=(const CommandLine&); + CommandLine& operator=(const char *); + void BuildCommand(const char *); + char** GetCommand(void) { return ppArgv; } + void Strtokens(const char *); + void Print(); +}; + +/** Declares and spawns a child process. + The spawned programm could be a native executable or a schell script. +*/ +class CCommand +{ +private: + ByteString aCommandLine; + ByteString aCommand; + char *pArgv; + char **ppArgv; + ULONG nArgc; + int nError; + +protected: + void ImplInit(); + void Initpp( ULONG nCount, ByteString &rStr ); + +public: + /** Creates the process specified without spawning it + @param rString specifies the programm or shell scrip + */ + CCommand( ByteString &rString ); + + /** Creates the process specified without spawning it + @param pChar specifies the programm or shell scrip + */ + CCommand( const char *pChar ); + + /** Try to find the given programm in specified path + @param sEnv specifies the current search path, defaulted by environment + @param sItem specifies the system shell + @return the Location (when programm was found) + */ + static ByteString Search( ByteString sEnv, + ByteString sItem = COMMAND_SHELL ); + + /** Spawns the Process + @return 0 when spawned without errors, otherwise a error code + */ + operator int(); + + ByteString GetCommandLine_() { return aCommandLine; } + ByteString GetCommand() { return aCommand; } + + char** GetCommandStr() { return ppArgv; } +}; + +#define COMMAND_EXECUTE_WINDOW 0x0000001 +#define COMMAND_EXECUTE_CONSOLE 0x0000002 +#define COMMAND_EXECUTE_HIDDEN 0x0000004 +#define COMMAND_EXECUTE_START 0x0000008 +#define COMMAND_EXECUTE_WAIT 0x0000010 +#define COMMAND_EXECUTE_REMOTE 0x1000000 + +typedef ULONG CommandBits; + +/** Allowes to spawn programms hidden, waiting etc. + @see CCommand +*/ +class CCommandd : public CCommand +{ + CommandBits nFlag; +public: + CCommandd( ByteString &rString, CommandBits nBits ); + CCommandd( const char *pChar, CommandBits nBits ); + operator int(); +}; + +#endif diff --git a/tools/inc/bootstrp/inimgr.hxx b/tools/inc/bootstrp/inimgr.hxx new file mode 100644 index 000000000000..7be00ce14d48 --- /dev/null +++ b/tools/inc/bootstrp/inimgr.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * 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 _INIMGR_HXX +#define _INIMGR_HXX + +#include <tools/fsys.hxx> +#include <tools/string.hxx> + +/***************************************************************************** +Purpose: Allows to work on a local set of initialisation files +If Update is used, the user must ensure that only one set of +Source and Destination Dir is used. Otherwise ForceUpdate has to be used +*****************************************************************************/ + +class IniManager +{ +private: + BOOL bUpdate; + + ByteString sGlobalDir; /// holds the org. ini dir + ByteString sLocalPath; /// holds path of local ini dir + +public: + IniManager( ByteString &rDir, ByteString &rLocalDir ); + IniManager( ByteString &rDir ); + IniManager(); + + ByteString ToLocal( ByteString &rPath ); + void Update(); /// Call ForceUpdate the First Time called + void ForceUpdate(); + + static ByteString GetLocalIni(); + static ByteString GetGlobalIni(); +}; + +#endif + diff --git a/tools/inc/bootstrp/listmacr.hxx b/tools/inc/bootstrp/listmacr.hxx new file mode 100644 index 000000000000..8c678ff32275 --- /dev/null +++ b/tools/inc/bootstrp/listmacr.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * 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 _LISTMACR_HXX +#define _LISTMACR_HXX + +#define DECL_DEST_LIST( TmpListType, ListType, PointerType ) \ +DECLARE_LIST(TmpListType, PointerType) \ +class ListType : public TmpListType \ +{ \ +public: \ + void ClearAndDelete() \ + { \ + while ( Count()) { \ + PointerType pTmp = GetObject(( ULONG ) 0 ); \ + delete pTmp; \ + Remove(( ULONG ) 0 ); \ + } \ + } \ + ~ListType() \ + { \ + ClearAndDelete(); \ + } \ +}; \ + +#endif + + + + + + + + + + diff --git a/tools/inc/bootstrp/mkcreate.hxx b/tools/inc/bootstrp/mkcreate.hxx new file mode 100644 index 000000000000..991b5961a096 --- /dev/null +++ b/tools/inc/bootstrp/mkcreate.hxx @@ -0,0 +1,295 @@ +/************************************************************************* + * + * 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 _MK_CREATE_HXX +#define _MK_CREATE_HXX + +#include <tools/string.hxx> +#include "bootstrp/sstring.hxx" + +#include <tools/list.hxx> +#include "bootstrp/prj.hxx" + +class SvStream; +class SourceDirectoryList; + +// +// class SourceDirectoryDependency +// + +class CodedDependency : public ByteString +{ +private: + USHORT nOSType; // operating systems where dependeny exists + +public: + /* create a dependency instance with given coded directory name + */ + CodedDependency( + const ByteString &rCodedIdentifier, // the coded name of the directory + USHORT nOperatingSystems // the operating systems where this dependency exists + ) : + ByteString( rCodedIdentifier ), + nOSType( nOperatingSystems ) + { + } + + /* returns the operating system + */ + USHORT GetOperatingSystem() + { + return nOSType; + } + + /* set operating system + */ + void SetOperatingSystem( USHORT nOperatingSystems ) + { + nOSType = nOperatingSystems; + } + + /* add operating systems if same dependency + */ + BOOL TryToMerge( + const ByteString &rCodedIdentifier, // the coded name of the directory + USHORT nOperatingSystems // the operating systems where this dependency exists + ) + { + if ( rCodedIdentifier != *this ) + return FALSE; + nOSType |= nOperatingSystems; + return TRUE; + } +}; + +// +// class Dependecy +// + +class Dependency : public ByteString +{ +private: + USHORT nOSType; // operating systems where dependecy exists + +public: + /* create a dependency instance with given directory name + */ + Dependency( + const ByteString &rDirectoryName, // the coded name of the directory + USHORT nOperatingSystems // the operating systems where this dependency exists + ) : + ByteString( rDirectoryName ), + nOSType( nOperatingSystems ) + { + } + + /* returns the operating system + */ + USHORT GetOperatingSystem() + { + return nOSType; + } +}; + +// +// class SourceDirectory +// + +class SourceDirectory : public ByteString +{ +private: + SourceDirectory *pParent; // the parent directory + SourceDirectoryList *pSubDirectories; // list of sub directories + USHORT nOSType; // operating systems where this directory is used + USHORT nDepth; // depth of directory structure (root is 0) + + SByteStringList *pDependencies; // dependencies on other directories in this depth + + SByteStringList *pCodedDependencies; // dependencies on other directories in different depth + SByteStringList *pCodedIdentifier; // symbolic identifier to resolve dependencies + + /* try to resolve a single dependency + */ + Dependency *ResolvesDependency( + CodedDependency *pCodedDependency // the dependency + ); + + /* returns the operating systems of a coded dependency + */ + static USHORT GetOSType( + const ByteString &sDependExt // the corresponding dependency extension (see also prj.hxx) + ); + + /* removes this and all sub directories with all dependencies + */ + BOOL RemoveDirectoryTreeAndAllDependencies(); + +public: + + /* create a directory instance with given parent and name, no parent means this is the root + * (not the file system root but the root of the source tree, e.g. o:\569) + */ + SourceDirectory( + const ByteString &rDirectoryName, // name without parent + USHORT nOperatingSystem, // the operating systems where this directory is used + SourceDirectory *pParentDirectory = NULL // parent (if not root) + ); + ~SourceDirectory(); + + /* returns the full absolute path of this directory + */ + ByteString GetFullPath(); + + /* returns a list of all sub directories + */ + SourceDirectoryList *GetSubDirectories() { return pSubDirectories; } + + /* returns the Operating systems where this directory is used + */ + USHORT GetOperatingSystems() { return nOSType; } + + /* returns the given directory + */ + SourceDirectory *GetDirectory( + const ByteString &rDirectoryName, // full path + USHORT nOperatingSystem // the operating systems where this directory is used + ); + + /* create the directory and all mandatory parents + */ + SourceDirectory *InsertFull( + const ByteString &rDirectoryName, // full path + USHORT nOperatingSystem // the operating systems where this directory is used + ) + { + return GetDirectory( rDirectoryName, nOperatingSystem ); + } + + /* create the directory as sub directory of this directory + */ + SourceDirectory *Insert( + const ByteString &rDirectoryName, // name without parent + USHORT nOperatingSystem // the operating systems where this directory is used + ); + + /* get the root directory + */ + SourceDirectory *GetRootDirectory(); + + /* get sub directory if exists + */ + SourceDirectory *GetSubDirectory( + const ByteString &rDirectoryPath, // full sub path + USHORT nOperatingSystem // the operating systems where this directory is used + ); + + /* add a dependency for several platforms + */ + CodedDependency *AddCodedDependency( + const ByteString &rCodedIdentifier, // the coded name of the directory + USHORT nOperatingSystems // the operating systems where this dependency exists + ); + + /* returns the dependency list + */ + SByteStringList *GetCodedDependencies() + { + return pCodedDependencies; + } + + /* add symbolic identifier to resolve dependencies (to this directory and all parents) + */ + CodedDependency *AddCodedIdentifier( + const ByteString &rCodedIdentifier, // the coded name of the directory + USHORT nOperatingSystems // the operating systems where this dependency exists + ); + + /* returns the identifier list + */ + SByteStringList *GetCodedIdentifier() + { + return pCodedIdentifier; + } + + /* create dependencies on other directory, coded dependecies are used + */ + void ResolveDependencies(); + + /* returns the target definition for this directory (if dependencies exist) + */ + ByteString GetTarget(); + + /* returns the target definition for all sub directory + */ + ByteString GetSubDirsTarget(); + + /* create the full directory tree (only virtual, not in file system) + */ + static SourceDirectory *CreateRootDirectory( + const ByteString &rRoot, // the root directory in file system + const ByteString &rVersion, // the solar verion (r.g. SRC590, SRC591 etc.) + BOOL bAll = FALSE // add all directories or only buildable ones + ); + + /* create the makefile.rc in file system + */ + BOOL CreateRecursiveMakefile( + BOOL bAllChilds = FALSE // create rcursive for all sub directories + ); +}; + +// +// class SourceDirectoryList +// + +class SourceDirectoryList : public SByteStringList +{ +public: + /* create a empty directory list + */ + SourceDirectoryList() + { + } + ~SourceDirectoryList(); + + /* search for a directory by directory name + */ + SourceDirectory *Search( + const ByteString &rDirectoryName // name without parent + ); + + /* insert a new directory + */ + ULONG InsertSorted( + SourceDirectory *pDirectory // directory + ) + { + return PutString(( ByteString * ) pDirectory ); + } +}; + +#endif diff --git a/tools/inc/bootstrp/prj.hxx b/tools/inc/bootstrp/prj.hxx new file mode 100644 index 000000000000..994418bae4b5 --- /dev/null +++ b/tools/inc/bootstrp/prj.hxx @@ -0,0 +1,331 @@ +/************************************************************************* + * + * 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 _PRJ_HXX +#define _PRJ_HXX + +#include <tools/fsys.hxx> +#include <tools/stream.hxx> +#include "bootstrp/listmacr.hxx" +#include <vos/mutex.hxx> + +#define OS_NONE 0x0000 +#define OS_WIN16 0x0001 +#define OS_WIN32 0x0002 +#define OS_OS2 0x0004 +#define OS_UNX 0x0008 +#define OS_ALL ( OS_WIN16 | OS_WIN32 | OS_OS2 | OS_UNX ) + +#define COMMAND_PROJECTROOT 0x0000 +#define COMMAND_NMAKE 0x0001 +#define COMMAND_GET 0x0002 +#define COMMAND_USER_START 0x0003 +#define COMMAND_USER_END 0xFFFE +#define COMMAND_ALLDIRS 0xFFFF + +class SByteStringList; +class GenericInformationList; + +/* +// Pfade auf Konfigurationsdateien des Build-Servers + +#define REQUEST_DIR \\src\data4\source\b_server\server\newjob +*/ +/********************************************************************* +* +* Die Klasse CommandData haelte alle Informationen, die fuer die +* Abarbeitung eines Kommandos (nmake, get) noetig sind +* +*********************************************************************/ + +class CommandData +{ + ByteString aPrj; + ByteString aLogFileName; + ByteString aInpath; + ByteString aUpd; + ByteString aUpdMinor; + ByteString aProduct; + ByteString aCommand; + ByteString aPath; + ByteString aPrePath; + ByteString aPreFix; + ByteString aCommandPara; + ByteString aComment; + ByteString sClientRestriction; + SByteStringList *pDepList; + USHORT nOSType; + USHORT nCommand; + + ULONG nDepth; // Tiefe der Abhaenigkeit + +public: + CommandData(); + ~CommandData(); + ByteString GetProjectName(){return aPrj;} + void SetProjectName( ByteString aName ){aPrj = aName;} + ByteString GetLogFile(){return aLogFileName;} + void SetLogFile( ByteString aName ){aLogFileName = aName;} + ByteString GetInpath(){return aInpath;} + void SetInpath( ByteString aName ){aInpath = aName;} + ByteString GetUpd(){return aUpd;} + void SetUpd( ByteString aName ){aUpd = aName;} + ByteString GetUpdMinor(){return aUpdMinor;} + void SetUpdMinor( ByteString aName ){aUpdMinor = aName;} + ByteString GetProduct(){return aProduct;} + void SetProduct( ByteString aName ){aProduct = aName;} + ByteString GetCommand(){return aCommand;} + void SetCommand ( ByteString aName ){aCommand = aName;} + ByteString GetCommandPara(){return aCommandPara;} + void SetCommandPara ( ByteString aName ){aCommandPara = aName;} + ByteString GetComment(){return aComment;} + void SetComment ( ByteString aCommentString ){aComment = aCommentString;} + ByteString GetPath(){return aPath;} + void SetPath( ByteString aName ){aPath = aName;} + ByteString GetPrePath(){return aPrePath;} + void SetPrePath( ByteString aName ){aPrePath = aName;} + USHORT GetOSType(){return nOSType;} + ByteString GetOSTypeString(); + void SetOSType( USHORT nType ){nOSType = nType;} + USHORT GetCommandType(){return nCommand;} + ByteString GetCommandTypeString(); + void SetCommandType( USHORT nCommandType ){nCommand = nCommandType;} + SByteStringList* GetDependencies(){return pDepList;} + void SetDependencies( SByteStringList *pList ){pDepList = pList;} + ByteString GetClientRestriction() { return sClientRestriction; } + void SetClientRestriction( ByteString sRestriction ) { sClientRestriction = sRestriction; } + + void AddDepth(){nDepth++;} + ULONG GetDepth(){return nDepth;} +}; + +/********************************************************************* +* +* Die Klasse SimpleConfig kann benutzt werden, um aus einer Textdatei +* alle Tokens zu lesen +* +*********************************************************************/ + +class SimpleConfig +{ + long nLine; + String aFileName; + SvFileStream aFileStream; + ByteString aTmpStr; + ByteString aStringBuffer; + + ByteString GetNextLine(); +public: + SimpleConfig(String aSimpleConfigFileName); + SimpleConfig(DirEntry& rDirEntry); + ~SimpleConfig(); + ByteString GetNext(); + ByteString GetCleanedNextLine( BOOL bReadComments = FALSE ); +}; + +#define ENV_GUI 0x00000000 +#define ENV_OS 0x00000001 +#define ENV_UPD 0x00000002 +#define ENV_UPDMIN 0x00000004 +#define ENV_INPATH 0x00000008 +#define ENV_OUTPATH 0x00000010 +#define ENV_GUIBASE 0x00000020 +#define ENV_CVER 0x00000040 +#define ENV_GVER 0x00000080 +#define ENV_GUIENV 0x00000100 +#define ENV_CPU 0x00000200 +#define ENV_CPUNAME 0x00000400 +#define ENV_DLLSUFF 0x00000800 +#define ENV_COMEX 0x00001000 +#define ENV_COMPATH 0x00002000 +#define ENV_INCLUDE 0x00004000 +#define ENV_LIB 0x00008000 +#define ENV_PATH 0x00010000 +#define ENV_SOLVER 0x00020000 +#define ENV_SOLENV 0x00040000 +#define ENV_SOLROOT 0x00080000 +#define ENV_DEVROOT 0x00100000 +#define ENV_EMERG 0x00200000 +#define ENV_STAND 0x00400000 + +/********************************************************************* +* +* class Prj +* alle Daten eines Projektes werden hier gehalten +* +*********************************************************************/ + +DECL_DEST_LIST ( PrjList_tmp, PrjList, CommandData * ) + +class Star; +class Prj : public PrjList +{ +friend class Star; +private: + BOOL bVisited; + + ByteString aPrjPath; + ByteString aProjectName; + ByteString aProjectPrefix; // max. 2-buchstabige Abk. + SByteStringList* pPrjInitialDepList; + SByteStringList* pPrjDepList; + BOOL bHardDependencies; + BOOL bSorted; + +public: + Prj(); + Prj( ByteString aName ); + ~Prj(); + void SetPreFix( ByteString aPre ){aProjectPrefix = aPre;} + ByteString GetPreFix(){return aProjectPrefix;} + ByteString GetProjectName() + {return aProjectName;} + void SetProjectName(ByteString aName) + {aProjectName = aName;} + BOOL InsertDirectory( ByteString aDirName , USHORT aWhat, + USHORT aWhatOS, ByteString aLogFileName, + const ByteString &rClientRestriction ); + CommandData* RemoveDirectory( ByteString aLogFileName ); + CommandData* GetDirectoryList ( USHORT nWhatOs, USHORT nCommand ); + CommandData* GetDirectoryData( ByteString aLogFileName ); + inline CommandData* GetData( ByteString aLogFileName ) + { return GetDirectoryData( aLogFileName ); }; + + SByteStringList* GetDependencies( BOOL bExpanded = TRUE ); + void AddDependencies( ByteString aStr ); + void HasHardDependencies( BOOL bHard ) { bHardDependencies = bHard; } + BOOL HasHardDependencies() { return bHardDependencies; } +}; + +/********************************************************************* +* +* class Star +* Diese Klasse liest die Projectstruktur aller StarDivision Projekte +* aus \\dev\data1\upenv\data\config\solar.lst aus +* +*********************************************************************/ + +DECL_DEST_LIST ( StarList_tmp, StarList, Prj* ) +DECLARE_LIST ( SolarFileList, String* ) + +class StarFile +{ +private: + String aFileName; + Date aDate; + Time aTime; + + BOOL bExists; + +public: + StarFile( const String &rFile ); + const String &GetName() { return aFileName; } + Date GetDate() { return aDate; } + Time GetTime() { return aTime; } + + BOOL NeedsUpdate(); + BOOL Exists() { return bExists; } +}; + +DECLARE_LIST( StarFileList, StarFile * ) + +#define STAR_MODE_SINGLE_PARSE 0x0000 +#define STAR_MODE_RECURSIVE_PARSE 0x0001 +#define STAR_MODE_MULTIPLE_PARSE 0x0002 + +class Star : public StarList +{ +private: + ByteString aStarName; + + static Link aDBNotFoundHdl; +protected: + vos:: OMutex aMutex; + + USHORT nStarMode; + SolarFileList aFileList; + StarFileList aLoadedFilesList; + String sSourceRoot; + + void InsertSolarList( String sProject ); + String CreateFileName( String sProject ); + + void Expand_Impl(); + void ExpandPrj_Impl( Prj *pPrj, Prj *pDepPrj ); + +private: + void Read( String &rFileName ); + void Read( SolarFileList *pSOlarFiles ); + +public: + Star(); + Star( String aFileName, USHORT nMode = STAR_MODE_SINGLE_PARSE ); + Star( SolarFileList *pSolarFiles ); + Star( GenericInformationList *pStandLst, ByteString &rVersion, BOOL bLocal = FALSE, + const char *pSourceRoot = NULL ); + + ~Star(); + + static void SetDBNotFoundHdl( const Link &rLink ) { aDBNotFoundHdl = rLink; } + + ByteString GetName(){ return aStarName; }; + + BOOL HasProject( ByteString aProjectName ); + Prj* GetPrj( ByteString aProjectName ); + ByteString GetPrjName( DirEntry &rPath ); + + void InsertToken( char *pChar ); + BOOL NeedsUpdate(); + + USHORT GetMode() { return nStarMode; } +}; + +class StarWriter : public Star +{ +private: + USHORT WritePrj( Prj *pPrj, SvFileStream& rStream ); + +public: + StarWriter( String aFileName, BOOL bReadComments = FALSE, USHORT nMode = STAR_MODE_SINGLE_PARSE ); + StarWriter( SolarFileList *pSolarFiles, BOOL bReadComments = FALSE ); + StarWriter( GenericInformationList *pStandLst, ByteString &rVersion, BOOL bLocal = FALSE, + const char *pSourceRoot = NULL ); + + void CleanUp(); + + BOOL InsertProject ( Prj* pNewPrj ); + Prj* RemoveProject ( ByteString aProjectName ); + + USHORT Read( String aFileName, BOOL bReadComments = FALSE, USHORT nMode = STAR_MODE_SINGLE_PARSE ); + USHORT Read( SolarFileList *pSolarFiles, BOOL bReadComments = FALSE ); + USHORT Write( String aFileName ); + USHORT WriteMultiple( String rSourceRoot ); + + void InsertTokenLine( ByteString& rString ); +}; + +#endif diff --git a/tools/inc/bootstrp/sstring.hxx b/tools/inc/bootstrp/sstring.hxx new file mode 100644 index 000000000000..933770887e37 --- /dev/null +++ b/tools/inc/bootstrp/sstring.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * 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 _SSTRING_HXX +#define _SSTRING_HXX + +#include <tools/string.hxx> +#include <tools/list.hxx> + +#define NOT_THERE LIST_ENTRY_NOTFOUND + +#define SStringList SUniStringList +#define StringList UniStringList + +DECLARE_LIST( ByteStringList, ByteString* ) +DECLARE_LIST( UniStringList, UniString* ) + +class SvStream; + +// --------------------- +// - class SStringList - +// --------------------- + +class SByteStringList : public ByteStringList +{ +public: + SByteStringList(); + ~SByteStringList(); + + // neuen ByteString in Liste einfuegen + ULONG PutString( ByteString* ); + ByteString* RemoveString( const ByteString& rName ); + + // Position des ByteString in Liste, wenn nicht enthalten, dann + // return = NOT_THERE + ULONG IsString( ByteString* ); + + // Vorgaenger ermitteln ( auch wenn selbst noch nicht in + // Liste enthalten + ULONG GetPrevString( ByteString* ); + void CleanUp(); + + SByteStringList& operator<< ( SvStream& rStream ); + SByteStringList& operator>> ( SvStream& rStream ); +}; + +// --------------------- +// - class SUniStringList - +// --------------------- + +class SUniStringList : public UniStringList +{ +public: + SUniStringList(); + ~SUniStringList(); + + // neuen UniString in Liste einfuegen + ULONG PutString( UniString* ); + UniString* RemoveString( const UniString& rName ); + + // Position des UniString in Liste, wenn nicht enthalten, dann + // return = NOT_THERE + ULONG IsString( UniString* ); + + // Vorgaenger ermitteln ( auch wenn selbst noch nicht in + // Liste enthalten + ULONG GetPrevString( UniString* ); +}; + +class Text +{ +protected: + String aString; + +public: + Text( char* pChar ); + Text( String &rStr ) { aString = rStr; } + void Stderr(); +}; + +#endif diff --git a/tools/inc/impcont.hxx b/tools/inc/impcont.hxx new file mode 100644 index 000000000000..224d5a4429ef --- /dev/null +++ b/tools/inc/impcont.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * 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 _IMPCONT_HXX +#define _IMPCONT_HXX + +#include <tools/tools.h> +#include <tools/contnr.hxx> + +typedef void* PVOID; + +// ---------- +// - CBlock - +// ---------- + +class CBlock +{ +private: + CBlock* pPrev; // Vorheriger Block + CBlock* pNext; // Naechster Block + USHORT nSize; // Groesse des Blocks + USHORT nCount; // Anzahl Pointer + void** pNodes; // Pointer auf die Daten + +#if defined DBG_UTIL + static char const * DbgCheckCBlock(void const *); +#endif + +public: + // Fuer List-Container + CBlock( USHORT nSize, CBlock* pPrev, CBlock* pNext ); + // Fuer Array-Container + CBlock( USHORT nSize, CBlock* pPrev ); + // Copy-Ctor + CBlock( const CBlock& r, CBlock* pPrev ); + ~CBlock(); + + void Insert( void* p, USHORT nIndex, USHORT nReSize ); + CBlock* Split( void* p, USHORT nIndex, USHORT nReSize ); + void* Remove( USHORT nIndex, USHORT nReSize ); + void* Replace( void* pNew, USHORT nIndex ); + + void** GetNodes() const { return pNodes; } + void** GetObjectPtr( USHORT nIndex ); + void* GetObject( USHORT nIndex ) const; + + void SetSize( USHORT nNewSize ); + + USHORT GetSize() const { return nCount; } + USHORT Count() const { return nCount; } + void SetPrevBlock( CBlock* p ) { pPrev = p; } + void SetNextBlock( CBlock* p ) { pNext = p; } + CBlock* GetPrevBlock() const { return pPrev; } + CBlock* GetNextBlock() const { return pNext; } + void Reset() { nCount = 0; } + +private: + CBlock( const CBlock& r ); + + friend class Container; +}; + +/************************************************************************* +|* +|* CBlock::GetObject() +|* +|* Beschreibung Gibt einen Pointer aus dem Block zurueck +|* Ersterstellung TH 17.09.91 +|* Letzte Aenderung TH 17.09.91 +|* +*************************************************************************/ + +inline void* CBlock::GetObject( USHORT nIndex ) const +{ + return pNodes[nIndex]; +} + +/************************************************************************* +|* +|* Container::ImpGetObject() +|* +|* Beschreibung Wir gehen davon aus, das Pointer in der Regel +|* sich im ersten Block befindet und schalten +|* deshalb eine Inline-Methode davor +|* Ersterstellung TH 02.07.93 +|* Letzte Aenderung TH 02.07.93 +|* +*************************************************************************/ + +inline void* Container::ImpGetObject( ULONG nIndex ) const +{ + if ( pFirstBlock && (nIndex < pFirstBlock->Count()) ) + // Item innerhalb des gefundenen Blocks zurueckgeben + return pFirstBlock->GetObject( (USHORT)nIndex ); + else + return GetObject( nIndex ); +} + +/************************************************************************* +|* +|* Container::ImpGetOnlyNodes() +|* +|* Beschreibung Wenn es nur einen Block gibt, wird davon +|* das Daten-Array zurueckgegeben +|* Ersterstellung TH 24.01.96 +|* Letzte Aenderung TH 24.01.96 +|* +*************************************************************************/ + +// #i70651#: Prevent warnings on Mac OS X +#ifdef MACOSX +#pragma GCC system_header +#endif + +inline void** Container::ImpGetOnlyNodes() const +{ + if ( (pFirstBlock == pLastBlock) && pFirstBlock ) + return pFirstBlock->GetNodes(); + else + return NULL; +} + +#endif // _IMPCONT_HXX diff --git a/tools/inc/impstrg.hxx b/tools/inc/impstrg.hxx new file mode 100644 index 000000000000..60b25a4c3fd6 --- /dev/null +++ b/tools/inc/impstrg.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * 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 _IMPSTRG_HXX +#define _IMPSTRG_HXX + +#include <tools/tools.h> +#include <tools/string.hxx> + +// ------------------------------ +// - Debug-Methoden fuer String - +// ------------------------------ + +const char* DbgCheckByteString( const void* pString ); +const char* DbgCheckUniString( const void* pString ); + +// ------------------------------- +// - Hilfsfunktionen fuer String - +// ------------------------------- + +xub_StrLen ImplStringLen( const sal_Char* pStr ); +xub_StrLen ImplStringLen( const sal_Unicode* pStr ); + +// ------------------------------------ +// - Zugriff fuer International class - +// ------------------------------------ + +sal_Unicode* ImplGet1ByteUnicodeTab( rtl_TextEncoding eTextEncoding ); + +#endif // _IMPSTRG_HXX diff --git a/tools/inc/makefile.mk b/tools/inc/makefile.mk new file mode 100644 index 000000000000..a3a76dc94a11 --- /dev/null +++ b/tools/inc/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# +# 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=tools +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/tools/inc/pch/precompiled_tools.cxx b/tools/inc/pch/precompiled_tools.cxx new file mode 100644 index 000000000000..cafe6444a55d --- /dev/null +++ b/tools/inc/pch/precompiled_tools.cxx @@ -0,0 +1,29 @@ +/************************************************************************* + * + * 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 "precompiled_tools.hxx" + diff --git a/tools/inc/pch/precompiled_tools.hxx b/tools/inc/pch/precompiled_tools.hxx new file mode 100644 index 000000000000..2bc615738a08 --- /dev/null +++ b/tools/inc/pch/precompiled_tools.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * 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): Generated on 2006-09-01 17:50:15.029610 + +#ifdef PRECOMPILED_HEADERS +//---MARKER--- +#include "sal/config.h" +#include "sal/types.h" + +#include "basegfx/point/b2dpoint.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "basegfx/polygon/b2dpolygontools.hxx" +#include "basegfx/polygon/b2dpolypolygon.hxx" +#include "basegfx/polygon/b2dpolypolygontools.hxx" +#include "basegfx/vector/b2dvector.hxx" + +#include "boost/static_assert.hpp" + +#include "com/sun/star/lang/Locale.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/util/XStringWidth.hpp" + +#include "comphelper/fileformat.h" + +#include "cppuhelper/implbase1.hxx" + +#include "i18npool/lang.h" +#include "i18npool/mslangid.hxx" + +#include "osl/diagnose.h" +#include "osl/endian.h" +#include "osl/file.hxx" +#include "osl/interlck.h" +#include "osl/module.h" +#include "osl/module.hxx" +#include "osl/mutex.hxx" +#include "osl/process.h" +#include "osl/security.h" +#include "osl/thread.h" + +#include "rtl/alloc.h" +#include "rtl/crc.h" +#include "rtl/digest.h" +#include "rtl/instance.hxx" +#include "rtl/logfile.hxx" +#include "rtl/math.hxx" +#include "rtl/memory.h" +#include "rtl/string.h" +#include "rtl/string.hxx" +#include "rtl/tencinfo.h" +#include "rtl/textcvt.h" +#include "rtl/textenc.h" +#include "rtl/ustrbuf.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" + +#include "sys/stat.h" +#include "sys/types.h" + +#include "vos/macros.hxx" +#include "vos/mutex.hxx" +#include "vos/process.hxx" +#include "vos/signal.hxx" +#include "vos/timer.hxx" +//---MARKER--- +#endif diff --git a/tools/inc/poly.h b/tools/inc/poly.h new file mode 100644 index 000000000000..9228715b8da7 --- /dev/null +++ b/tools/inc/poly.h @@ -0,0 +1,92 @@ +/************************************************************************* + * + * 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 _POLY_H +#define _POLY_H + +#include <tools/gen.hxx> + +#define MAX_64KPOINTS ((((USHORT)0xFFFF)-32)/sizeof(Point)) + +// ------------------- +// - ImplPolygonData - +// ------------------- + +class ImplPolygonData +{ +public: + Point* mpPointAry; + BYTE* mpFlagAry; + USHORT mnPoints; + ULONG mnRefCount; +}; + +// --------------- +// - ImplPolygon - +// --------------- + +class ImplPolygon : public ImplPolygonData +{ +public: + ImplPolygon( USHORT nInitSize, BOOL bFlags = FALSE ); + ImplPolygon( USHORT nPoints, const Point* pPtAry, const BYTE* pInitFlags = NULL ); + ImplPolygon( const ImplPolygon& rImplPoly ); + ~ImplPolygon(); + + void ImplSetSize( USHORT nSize, BOOL bResize = TRUE ); + void ImplCreateFlagArray(); + void ImplSplit( USHORT nPos, USHORT nSpace, ImplPolygon* pInitPoly = NULL ); + void ImplRemove( USHORT nPos, USHORT nCount ); +}; + +// ------------------- +// - ImplPolyPolygon - +// ------------------- + +#define MAX_POLYGONS ((USHORT)0x3FF0) + +class Polygon; +typedef Polygon* SVPPOLYGON; + +class ImplPolyPolygon +{ +public: + SVPPOLYGON* mpPolyAry; + ULONG mnRefCount; + USHORT mnCount; + USHORT mnSize; + USHORT mnResize; + + ImplPolyPolygon( USHORT nInitSize, USHORT nResize ) + { mpPolyAry = NULL; mnCount = 0; mnRefCount = 1; + mnSize = nInitSize; mnResize = nResize; } + ImplPolyPolygon( USHORT nInitSize ); + ImplPolyPolygon( const ImplPolyPolygon& rImplPolyPoly ); + ~ImplPolyPolygon(); +}; + +#endif // _SV_POLY_H diff --git a/tools/inc/tools/StringListResource.hxx b/tools/inc/tools/StringListResource.hxx new file mode 100644 index 000000000000..9709435407fb --- /dev/null +++ b/tools/inc/tools/StringListResource.hxx @@ -0,0 +1,56 @@ +/************************************************************************* + * + * 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 TOOLS_STRINGLISTRESOURCE_HXX +#define TOOLS_STRINGLISTRESOURCE_HXX + +#include <vector> +#include <tools/resid.hxx> +#include <tools/rcid.h> +#include <tools/rc.hxx> + +namespace tools +{ + class StringListResource : public Resource + { + public: + StringListResource(const ResId& _aResId,::std::vector< ::rtl::OUString>& _rToFill ) : Resource(_aResId) + { + USHORT i = 1; + while( IsAvailableRes(ResId(i,*m_pResMgr).SetRT(RSC_STRING)) ) + { + String sStr = String(ResId(i,*m_pResMgr)); + _rToFill.push_back(sStr); + ++i; + } + } + ~StringListResource() + { + FreeResource(); + } + }; +} // namespace tools +#endif // TOOLS_STRINGLISTRESOURCE_HXX diff --git a/tools/inc/tools/appendunixshellword.hxx b/tools/inc/tools/appendunixshellword.hxx new file mode 100644 index 000000000000..66b333bb62a5 --- /dev/null +++ b/tools/inc/tools/appendunixshellword.hxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * 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 INCLUDED_TOOLS_APPENDUNIXSHELLWORD_HXX +#define INCLUDED_TOOLS_APPENDUNIXSHELLWORD_HXX + +#include "sal/config.h" + +#if defined UNX + +#include "tools/toolsdllapi.h" + +namespace rtl { + class OString; + class OStringBuffer; +} + +namespace tools { + +// append arbitrary bytes as a properly quoted Unix-style shell word +// +// @param accumulator +// the string buffer to which the word is appended (without any surrounding +// whitespace); must not be null +// +// @param text +// the text to add +TOOLS_DLLPUBLIC void appendUnixShellWord( + rtl::OStringBuffer * accumulator, rtl::OString const & text); + +} + +#endif + +#endif diff --git a/tools/inc/tools/b3dtrans.hxx b/tools/inc/tools/b3dtrans.hxx new file mode 100644 index 000000000000..5b812bde15a2 --- /dev/null +++ b/tools/inc/tools/b3dtrans.hxx @@ -0,0 +1,352 @@ +/************************************************************************* + * + * 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 _B3D_B3DTRANS_HXX +#define _B3D_B3DTRANS_HXX + +// Zu verwendender DephRange des Z-Buffers +#define ZBUFFER_DEPTH_RANGE ((double)(256L * 256L * 256L)) + +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <basegfx/range/b3drange.hxx> +#include <tools/gen.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <tools/toolsdllapi.h> + +// Vorausdeklarationen + +/************************************************************************* +|* +|* Unterstuetzte Methoden, um das Seitenverhaeltnis einzuhalten +|* +\************************************************************************/ + +enum Base3DRatio +{ + Base3DRatioGrow = 1, + Base3DRatioShrink, + Base3DRatioMiddle +}; + +/************************************************************************* +|* +|* Typ der Projektion +|* +\************************************************************************/ + +enum Base3DProjectionType +{ + Base3DProjectionTypeParallel = 1, + Base3DProjectionTypePerspective +}; + +/************************************************************************* +|* +|* Transformationen fuer alle 3D Ausgaben +|* +\************************************************************************/ + +class TOOLS_DLLPUBLIC B3dTransformationSet +{ +private: + // Object Matrix Object -> World + basegfx::B3DHomMatrix maObjectTrans; + basegfx::B3DHomMatrix maInvObjectTrans; + + // Orientation Matrix + basegfx::B3DHomMatrix maOrientation; + basegfx::B3DHomMatrix maInvOrientation; + + // Projection Matrix + basegfx::B3DHomMatrix maProjection; + basegfx::B3DHomMatrix maInvProjection; + + // Texture Matrices + basegfx::B2DHomMatrix maTexture; + + // Speziell zum Umwandeln von Punkten Objekt -> Device + basegfx::B3DHomMatrix maObjectToDevice; + + // Transponierte Inverse fuer Vectortransformationen + basegfx::B3DHomMatrix maInvTransObjectToEye; + + // Transformation World->View + basegfx::B3DHomMatrix maMatFromWorldToView; + basegfx::B3DHomMatrix maInvMatFromWorldToView; + + // Parameters for ViewportTransformation + basegfx::B3DVector maScale; + basegfx::B3DVector maTranslate; + + // ViewPlane DeviceRectangle (vom Benutzer gesetzt) + double mfLeftBound; + double mfRightBound; + double mfBottomBound; + double mfTopBound; + + // Near and far clipping planes + double mfNearBound; + double mfFarBound; + + // Seitenverhaeltnis der 3D Abbildung (Y / X) + // default ist 1:1 -> 1.0 + // Deaktivieren mit 0.0 als Wert + double mfRatio; + + // Der gesetzte Ausgabebereich (in logischen Koordinaten) + // und der dazugehoerige sichtbare Bereich + Rectangle maViewportRectangle; + Rectangle maVisibleRectangle; + + // Die tatsaechlich von CalcViewport gesetzten Abmessungen + // des sichtbaren Bereichs (in logischen Koordinaten) + Rectangle maSetBound; + + // Methode zur Aufrechterhaltung des Seitenverhaeltnisses + // default ist Base3DRatioGrow + Base3DRatio meRatio; + + // Flags + unsigned mbPerspective : 1; + unsigned mbWorldToViewValid : 1; + unsigned mbInvTransObjectToEyeValid : 1; + unsigned mbObjectToDeviceValid : 1; + unsigned mbProjectionValid : 1; + +public: + B3dTransformationSet(); + virtual ~B3dTransformationSet(); + + // Zurueck auf Standard + void Reset(); + + // ObjectTrans + void SetObjectTrans(const basegfx::B3DHomMatrix& rObj); + const basegfx::B3DHomMatrix& GetObjectTrans() { return maObjectTrans; } + const basegfx::B3DHomMatrix& GetInvObjectTrans() { return maInvObjectTrans; } + + // Orientation + void SetOrientation( + basegfx::B3DPoint aVRP = basegfx::B3DPoint(0.0,0.0,1.0), + basegfx::B3DVector aVPN = basegfx::B3DVector(0.0,0.0,1.0), + basegfx::B3DVector aVUP = basegfx::B3DVector(0.0,1.0,0.0)); + void SetOrientation(basegfx::B3DHomMatrix& mOrient); + const basegfx::B3DHomMatrix& GetOrientation() { return maOrientation; } + const basegfx::B3DHomMatrix& GetInvOrientation() { return maInvOrientation; } + + // Projection + void SetProjection(const basegfx::B3DHomMatrix& mProject); + const basegfx::B3DHomMatrix& GetProjection(); + const basegfx::B3DHomMatrix& GetInvProjection(); + + // Texture + void SetTexture(const basegfx::B2DHomMatrix& rTxt); + const basegfx::B2DHomMatrix& GetTexture() { return maTexture; } + + // Seitenverhaeltnis und Modus zu dessen Aufrechterhaltung + double GetRatio() { return mfRatio; } + void SetRatio(double fNew=1.0); + Base3DRatio GetRatioMode() { return meRatio; } + void SetRatioMode(Base3DRatio eNew=Base3DRatioGrow); + + // Parameter der ViewportTransformation + void SetDeviceRectangle(double fL=-1.0, double fR=1.0, double fB=-1.0, double fT=1.0, sal_Bool bBroadCastChange=sal_True); + void SetDeviceVolume(const basegfx::B3DRange& rVol, sal_Bool bBroadCastChange=sal_True); + void GetDeviceRectangle(double &fL, double &fR, double& fB, double& fT); + basegfx::B3DRange GetDeviceVolume(); + double GetDeviceRectangleWidth() const { return mfRightBound - mfLeftBound; } + double GetDeviceRectangleHeight() const { return mfTopBound - mfBottomBound; } + void SetFrontClippingPlane(double fF=0.0); + double GetFrontClippingPlane() { return mfNearBound; } + void SetBackClippingPlane(double fB=1.0); + double GetBackClippingPlane() { return mfFarBound; } + void SetPerspective(sal_Bool bNew); + sal_Bool GetPerspective() { return mbPerspective; } + void SetViewportRectangle(Rectangle& rRect, Rectangle& rVisible); + void SetViewportRectangle(Rectangle& rRect) { SetViewportRectangle(rRect, rRect); } + const Rectangle& GetViewportRectangle() { return maViewportRectangle; } + void CalcViewport(); + + // Spezielle Matritzen anfordern + basegfx::B3DHomMatrix GetMatFromObjectToView(); + + // Transponierte Inverse fuer Vectortransformationen + const basegfx::B3DHomMatrix& GetInvTransObjectToEye(); + + // Speziell zum Umwandeln von Punkten Objekt -> Device + const basegfx::B3DHomMatrix& GetObjectToDevice(); + + // Speziell zum Umwandeln von Punkten World -> View + const basegfx::B3DHomMatrix& GetMatFromWorldToView(); + const basegfx::B3DHomMatrix& GetInvMatFromWorldToView(); + + // Bounds des Viewports lesen + const Rectangle& GetLogicalViewportBounds(); + const basegfx::B3DVector& GetScale(); + const basegfx::B3DVector& GetTranslate(); + + // Direkter Zugriff auf verschiedene Transformationen + const basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint EyeToViewCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ViewToEyeCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint WorldToViewCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ViewToWorldCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint DeviceToViewCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ViewToDeviceCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ObjectToWorldCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint WorldToObjectCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ObjectToViewCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ViewToObjectCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint ObjectToEyeCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint EyeToObjectCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint DeviceToEyeCoor(const basegfx::B3DPoint& rVec); + const basegfx::B3DPoint EyeToDeviceCoor(const basegfx::B3DPoint& rVec); + + const basegfx::B3DPoint InvTransObjectToEye(const basegfx::B3DPoint& rVec); + const basegfx::B2DPoint TransTextureCoor(const basegfx::B2DPoint& rVec); + + static void Frustum( + basegfx::B3DHomMatrix& rTarget, + double fLeft = -1.0, double fRight = 1.0, + double fBottom = -1.0, double fTop = 1.0, + double fNear = 0.001, double fFar = 1.0); + static void Ortho( + basegfx::B3DHomMatrix& rTarget, + double fLeft = -1.0, double fRight = 1.0, + double fBottom = -1.0, double fTop = 1.0, + double fNear = 0.0, double fFar = 1.0); + static void Orientation( + basegfx::B3DHomMatrix& rTarget, + basegfx::B3DPoint aVRP = basegfx::B3DPoint(0.0,0.0,1.0), + basegfx::B3DVector aVPN = basegfx::B3DVector(0.0,0.0,1.0), + basegfx::B3DVector aVUP = basegfx::B3DVector(0.0,1.0,0.0)); + +protected: + void PostSetObjectTrans(); + void PostSetOrientation(); + void PostSetProjection(); + void PostSetTexture(); + void PostSetViewport(); + + void CalcMatObjectToDevice(); + void CalcMatFromWorldToView(); + void CalcMatInvTransObjectToEye(); + + virtual void DeviceRectangleChange(); +}; + +/************************************************************************* +|* +|* Viewport fuer B3D +|* +|* Verwendet wird hier ein vereinfachtes System, bei dem der abzubildende +|* Punkt durch VRP repraesentiert wird +|* +\************************************************************************/ + +class TOOLS_DLLPUBLIC B3dViewport : public B3dTransformationSet +{ +private: + basegfx::B3DPoint aVRP; // View Reference Point + basegfx::B3DVector aVPN; // View Plane Normal + basegfx::B3DVector aVUV; // View Up Vector + +public: + B3dViewport(); + virtual ~B3dViewport(); + + void SetVRP(const basegfx::B3DPoint& rNewVRP); + void SetVPN(const basegfx::B3DVector& rNewVPN); + void SetVUV(const basegfx::B3DVector& rNewVUV); + void SetViewportValues( + const basegfx::B3DPoint& rNewVRP, + const basegfx::B3DVector& rNewVPN, + const basegfx::B3DVector& rNewVUV); + + const basegfx::B3DPoint& GetVRP() const { return aVRP; } + const basegfx::B3DVector& GetVPN() const { return aVPN; } + const basegfx::B3DVector& GetVUV() const { return aVUV; } + +protected: + void CalcOrientation(); +}; + +/************************************************************************* +|* +|* Kamera fuer B3D +|* +\************************************************************************/ + +class TOOLS_DLLPUBLIC B3dCamera : public B3dViewport +{ +private: + basegfx::B3DPoint aPosition; + basegfx::B3DPoint aCorrectedPosition; + basegfx::B3DVector aLookAt; + double fFocalLength; + double fBankAngle; + + unsigned bUseFocalLength : 1; + +public: + B3dCamera( + const basegfx::B3DPoint& rPos = basegfx::B3DPoint(0.0, 0.0, 1.0), + const basegfx::B3DVector& rLkAt = basegfx::B3DVector(0.0, 0.0, 0.0), + double fFocLen = 35.0, double fBnkAng = 0.0, + sal_Bool bUseFocLen = sal_False); + virtual ~B3dCamera(); + + // Positionen + void SetPosition(const basegfx::B3DPoint& rNewPos); + const basegfx::B3DPoint& GetPosition() const { return aPosition; } + void SetLookAt(const basegfx::B3DVector& rNewLookAt); + const basegfx::B3DVector& GetLookAt() const { return aLookAt; } + void SetPositionAndLookAt(const basegfx::B3DPoint& rNewPos, const basegfx::B3DVector& rNewLookAt); + + // Brennweite in mm + void SetFocalLength(double fLen); + double GetFocalLength() const { return fFocalLength; } + + // Neigung links/rechts + void SetBankAngle(double fAngle); + double GetBankAngle() const { return fBankAngle; } + + // FocalLength Flag + void SetUseFocalLength(sal_Bool bNew); + sal_Bool GetUseFocalLength() const { return (sal_Bool)bUseFocalLength; } + +protected: + void CalcNewViewportValues(); + sal_Bool CalcFocalLength(); + + virtual void DeviceRectangleChange(); +}; + + +#endif // _B3D_B3DTRANS_HXX diff --git a/tools/inc/tools/bigint.hxx b/tools/inc/tools/bigint.hxx new file mode 100644 index 000000000000..353fbb063191 --- /dev/null +++ b/tools/inc/tools/bigint.hxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * 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 _BIGINT_HXX +#define _BIGINT_HXX + +#include <climits> +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/string.hxx> + +class SvStream; +#ifdef _TLBIGINT_INT64 +struct SbxINT64; +struct SbxUINT64; +namespace binfilter { class SbxINT64Converter; } +#endif + +// ---------- +// - BigInt - +// ---------- + +#define MAX_DIGITS 8 + +class Fraction; + +class TOOLS_DLLPUBLIC BigInt +{ +#ifdef _TLBIGINT_INT64 + friend class ::binfilter::SbxINT64Converter; +#endif + +private: + long nVal; + unsigned short nNum[MAX_DIGITS]; + sal_uInt8 nLen : 5; // Aktuelle Laenge + sal_Bool bIsNeg : 1, // Is Sign negative + bIsBig : 1, // sal_True == BigInt + bIsSet : 1; // Not "Null" (not not 0) + + TOOLS_DLLPRIVATE void MakeBigInt(BigInt const &); + TOOLS_DLLPRIVATE void Normalize(); + TOOLS_DLLPRIVATE void Mult(BigInt const &, sal_uInt16); + TOOLS_DLLPRIVATE void Div(sal_uInt16, sal_uInt16 &); + TOOLS_DLLPRIVATE sal_Bool IsLess(BigInt const &) const; + TOOLS_DLLPRIVATE void AddLong(BigInt &, BigInt &); + TOOLS_DLLPRIVATE void SubLong(BigInt &, BigInt &); + TOOLS_DLLPRIVATE void MultLong(BigInt const &, BigInt &) const; + TOOLS_DLLPRIVATE void DivLong(BigInt const &, BigInt &) const; + TOOLS_DLLPRIVATE void ModLong(BigInt const &, BigInt &) const; + TOOLS_DLLPRIVATE sal_Bool ABS_IsLess(BigInt const &) const; + +public: + BigInt(); + BigInt( short nVal ); + BigInt( long nVal ); + BigInt( int nVal ); + BigInt( double nVal ); + BigInt( sal_uInt16 nVal ); + BigInt( sal_uInt32 nVal ); + BigInt( const BigInt& rBigInt ); + BigInt( const ByteString& rString ); + BigInt( const UniString& rString ); +#ifdef _TLBIGINT_INT64 + BigInt( const SbxINT64 &r ); + BigInt( const SbxUINT64 &r ); +#endif + + operator short() const; + operator long() const; + operator int() const; + operator double() const; + operator USHORT() const; + operator ULONG() const; + + void Set( sal_Bool bSet ) { bIsSet = bSet; } + ByteString GetByteString() const; + UniString GetString() const; + + sal_Bool IsSet() const { return bIsSet; } + sal_Bool IsNeg() const; + sal_Bool IsZero() const; + sal_Bool IsOne() const; + sal_Bool IsLong() const { return !bIsBig; } + void Abs(); + void DivMod( const BigInt &rDivisor, BigInt &rMod ); +#ifdef _TLBIGINT_INT64 + sal_Bool INT64 ( SbxINT64 *p ) const; + sal_Bool UINT64( SbxUINT64 *p ) const; +#endif + + BigInt& operator =( const BigInt& rVal ); + BigInt& operator +=( const BigInt& rVal ); + BigInt& operator -=( const BigInt& rVal ); + BigInt& operator *=( const BigInt& rVal ); + BigInt& operator /=( const BigInt& rVal ); + BigInt& operator %=( const BigInt& rVal ); + + BigInt& operator =( const short nValue ); + BigInt& operator =( const long nValue ); + BigInt& operator =( const int nValue ); + BigInt& operator =( const sal_uInt16 nValue ); + + friend inline BigInt operator +( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline BigInt operator -( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline BigInt operator *( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline BigInt operator /( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline BigInt operator %( const BigInt& rVal1, const BigInt& rVal2 ); + + TOOLS_DLLPUBLIC friend sal_Bool operator==( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline sal_Bool operator!=( const BigInt& rVal1, const BigInt& rVal2 ); + TOOLS_DLLPUBLIC friend sal_Bool operator< ( const BigInt& rVal1, const BigInt& rVal2 ); + TOOLS_DLLPUBLIC friend sal_Bool operator> ( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline sal_Bool operator<=( const BigInt& rVal1, const BigInt& rVal2 ); + friend inline sal_Bool operator>=( const BigInt& rVal1, const BigInt& rVal2 ); + + friend class Fraction; +}; + +inline BigInt::BigInt() +{ + bIsSet = sal_False; + bIsBig = sal_False; + nVal = 0; +} + +inline BigInt::BigInt( short nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; +} + +inline BigInt::BigInt( long nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; +} + +inline BigInt::BigInt( int nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; +} + +inline BigInt::BigInt( sal_uInt16 nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; +} + +inline BigInt::operator short() const +{ + if ( !bIsBig && nVal >= SHRT_MIN && nVal <= SHRT_MAX ) + return (short)nVal; + else + return 0; +} + +inline BigInt::operator long() const +{ + if ( !bIsBig ) + return nVal; + else + return 0; +} + +inline BigInt::operator int() const +{ + if ( !bIsBig && (nVal == (long)(int)nVal) ) + return (int)nVal; + else + return 0; +} + +inline BigInt::operator USHORT() const +{ + if ( !bIsBig && nVal >= 0 && nVal <= USHRT_MAX ) + return (USHORT)nVal; + else + return 0; +} + +inline BigInt& BigInt::operator =( const short nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; + + return *this; +} + +inline BigInt& BigInt::operator =( const long nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; + + return *this; +} + +inline BigInt& BigInt::operator =( const int nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; + + return *this; +} + +inline BigInt& BigInt::operator =( const sal_uInt16 nValue ) +{ + bIsSet = sal_True; + bIsBig = sal_False; + nVal = nValue; + + return *this; +} + +inline sal_Bool BigInt::IsNeg() const +{ + if ( !bIsBig ) + return (nVal < 0); + else + return (sal_Bool)bIsNeg; +} + +inline sal_Bool BigInt::IsZero() const +{ + if ( bIsBig ) + return sal_False; + else + return (nVal == 0); +} + +inline sal_Bool BigInt::IsOne() const +{ + if ( bIsBig ) + return sal_False; + else + return (nVal == 1); +} + +inline void BigInt::Abs() +{ + if ( bIsBig ) + bIsNeg = sal_False; + else if ( nVal < 0 ) + nVal = -nVal; +} + +inline BigInt operator+( const BigInt &rVal1, const BigInt &rVal2 ) +{ + BigInt aErg( rVal1 ); + aErg += rVal2; + return aErg; +} + +inline BigInt operator-( const BigInt &rVal1, const BigInt &rVal2 ) +{ + BigInt aErg( rVal1 ); + aErg -= rVal2; + return aErg; +} + +inline BigInt operator*( const BigInt &rVal1, const BigInt &rVal2 ) +{ + BigInt aErg( rVal1 ); + aErg *= rVal2; + return aErg; +} + +inline BigInt operator/( const BigInt &rVal1, const BigInt &rVal2 ) +{ + BigInt aErg( rVal1 ); + aErg /= rVal2; + return aErg; +} + +inline BigInt operator%( const BigInt &rVal1, const BigInt &rVal2 ) +{ + BigInt aErg( rVal1 ); + aErg %= rVal2; + return aErg; +} + +inline sal_Bool operator!=( const BigInt& rVal1, const BigInt& rVal2 ) +{ + return !(rVal1 == rVal2); +} + +inline sal_Bool operator<=( const BigInt& rVal1, const BigInt& rVal2 ) +{ + return !( rVal1 > rVal2); +} + +inline sal_Bool operator>=( const BigInt& rVal1, const BigInt& rVal2 ) +{ + return !(rVal1 < rVal2); +} + +#endif diff --git a/tools/inc/tools/cachestr.hxx b/tools/inc/tools/cachestr.hxx new file mode 100644 index 000000000000..1819792bb386 --- /dev/null +++ b/tools/inc/tools/cachestr.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * 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 _CACHESTR_HXX +#define _CACHESTR_HXX + +#include <tools/stream.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include "tools/toolsdllapi.h" + +// ----------------- +// - SvCacheStream - +// ----------------- + +class TempFile; +class TOOLS_DLLPUBLIC SvCacheStream : public SvStream +{ +private: + String aFileName; + ULONG nMaxSize; + int bPersistent; + + SvStream* pSwapStream; + SvStream* pCurrentStream; + TempFile* pTempFile; + + Link aFilenameLinkHdl; + + TOOLS_DLLPRIVATE virtual ULONG GetData( void* pData, ULONG nSize ); + TOOLS_DLLPRIVATE virtual ULONG PutData( const void* pData, ULONG nSize ); + TOOLS_DLLPRIVATE virtual ULONG SeekPos( ULONG nPos ); + TOOLS_DLLPRIVATE virtual void FlushData(); + TOOLS_DLLPRIVATE virtual void SetSize( ULONG nSize ); + +public: + SvCacheStream( ULONG nMaxMemSize = 0 ); + SvCacheStream( const String &rFileName, + ULONG nExpectedSize = 0, + ULONG nMaxMemSize = 0 ); + ~SvCacheStream(); + + void SetFilenameHdl( const Link& rLink); + const Link& GetFilenameHdl() const; + void SetFilename( const String& rFN ) + { aFileName = rFN; } // darf nur vom FilenameHdl gerufen werden! + const String& GetFilename() const { return aFileName; } + + void SwapOut(); + const void* GetBuffer(); + ULONG GetSize(); + + BOOL IsPersistent() { return bPersistent != 0; } + void SetPersistence( BOOL b = TRUE ) { bPersistent = b; } + void SetSwapStream( SvStream *p ) + { pSwapStream = p; } // darf nur vom FilenameHdl gerufen werden! +}; + +#endif diff --git a/tools/inc/tools/color.hxx b/tools/inc/tools/color.hxx new file mode 100644 index 000000000000..a99ad1dd11c4 --- /dev/null +++ b/tools/inc/tools/color.hxx @@ -0,0 +1,239 @@ +/************************************************************************* + * + * 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 _TOOLS_COLOR_HXX +#define _TOOLS_COLOR_HXX + +#include "tools/toolsdllapi.h" + +class SvStream; +class ResId; +#include <tools/solar.h> + +#ifndef _BGFX_COLOR_BCOLOR_HXX +#include <basegfx/color/bcolor.hxx> +#endif + +// -------------------- +// - ColorCount-Types - +// -------------------- + +#define COLCOUNT_MONOCHROM ((ULONG)2) +#define COLCOUNT_16 ((ULONG)16) +#define COLCOUNT_256 ((ULONG)256) +#define COLCOUNT_HICOLOR1 (((ULONG)0x00007FFF)+1) +#define COLCOUNT_HICOLOR2 (((ULONG)0x0000FFFF)+1) +#define COLCOUNT_TRUECOLOR (((ULONG)0x00FFFFFF)+1) + +// --------------- +// - Color-Types - +// --------------- + +typedef UINT32 ColorData; +#define RGB_COLORDATA( r,g,b ) ((ColorData)(((UINT32)((UINT8)(b))))|(((UINT32)((UINT8)(g)))<<8)|(((UINT32)((UINT8)(r)))<<16)) +#define TRGB_COLORDATA( t,r,g,b ) ((ColorData)(((UINT32)((UINT8)(b))))|(((UINT32)((UINT8)(g)))<<8)|(((UINT32)((UINT8)(r)))<<16)|(((UINT32)((UINT8)(t)))<<24)) +#define COLORDATA_RED( n ) ((UINT8)((n)>>16)) +#define COLORDATA_GREEN( n ) ((UINT8)(((UINT16)(n)) >> 8)) +#define COLORDATA_BLUE( n ) ((UINT8)(n)) +#define COLORDATA_TRANSPARENCY( n ) ((UINT8)((n)>>24)) +#define COLORDATA_RGB( n ) ((ColorData)((n) & 0x00FFFFFF)) + +#define COL_BLACK RGB_COLORDATA( 0x00, 0x00, 0x00 ) +#define COL_BLUE RGB_COLORDATA( 0x00, 0x00, 0x80 ) +#define COL_GREEN RGB_COLORDATA( 0x00, 0x80, 0x00 ) +#define COL_CYAN RGB_COLORDATA( 0x00, 0x80, 0x80 ) +#define COL_RED RGB_COLORDATA( 0x80, 0x00, 0x00 ) +#define COL_MAGENTA RGB_COLORDATA( 0x80, 0x00, 0x80 ) +#define COL_BROWN RGB_COLORDATA( 0x80, 0x80, 0x00 ) +#define COL_GRAY RGB_COLORDATA( 0x80, 0x80, 0x80 ) +#define COL_LIGHTGRAY RGB_COLORDATA( 0xC0, 0xC0, 0xC0 ) +#define COL_LIGHTBLUE RGB_COLORDATA( 0x00, 0x00, 0xFF ) +#define COL_LIGHTGREEN RGB_COLORDATA( 0x00, 0xFF, 0x00 ) +#define COL_LIGHTCYAN RGB_COLORDATA( 0x00, 0xFF, 0xFF ) +#define COL_LIGHTRED RGB_COLORDATA( 0xFF, 0x00, 0x00 ) +#define COL_LIGHTMAGENTA RGB_COLORDATA( 0xFF, 0x00, 0xFF ) +#define COL_YELLOW RGB_COLORDATA( 0xFF, 0xFF, 0x00 ) +#define COL_WHITE RGB_COLORDATA( 0xFF, 0xFF, 0xFF ) +#define COL_TRANSPARENT TRGB_COLORDATA( 0xFF, 0xFF, 0xFF, 0xFF ) +#define COL_AUTO (ColorData)0xFFFFFFFF +#define COL_AUTHOR1_DARK RGB_COLORDATA(198, 146, 0) +#define COL_AUTHOR1_NORMAL RGB_COLORDATA(255, 255, 158) +#define COL_AUTHOR1_LIGHT RGB_COLORDATA(255, 255, 195) +#define COL_AUTHOR2_DARK RGB_COLORDATA(6, 70, 162) +#define COL_AUTHOR2_NORMAL RGB_COLORDATA(216, 232, 255) +#define COL_AUTHOR2_LIGHT RGB_COLORDATA(233, 242, 255) +#define COL_AUTHOR3_DARK RGB_COLORDATA(87, 157, 28) +#define COL_AUTHOR3_NORMAL RGB_COLORDATA(218, 248, 193) +#define COL_AUTHOR3_LIGHT RGB_COLORDATA(226, 250, 207) +#define COL_AUTHOR4_DARK RGB_COLORDATA(105, 43, 157) +#define COL_AUTHOR4_NORMAL RGB_COLORDATA(228, 210, 245) +#define COL_AUTHOR4_LIGHT RGB_COLORDATA(239, 228, 248) +#define COL_AUTHOR5_DARK RGB_COLORDATA(197, 0, 11) +#define COL_AUTHOR5_NORMAL RGB_COLORDATA(254, 205, 208) +#define COL_AUTHOR5_LIGHT RGB_COLORDATA(255, 227, 229) +#define COL_AUTHOR6_DARK RGB_COLORDATA(0, 128, 128) +#define COL_AUTHOR6_NORMAL RGB_COLORDATA(210, 246, 246) +#define COL_AUTHOR6_LIGHT RGB_COLORDATA(230, 250, 250) +#define COL_AUTHOR7_DARK RGB_COLORDATA(140, 132, 0) +#define COL_AUTHOR7_NORMAL RGB_COLORDATA(237, 252, 163) +#define COL_AUTHOR7_LIGHT RGB_COLORDATA(242, 254, 181) +#define COL_AUTHOR8_DARK RGB_COLORDATA(53, 85, 107) +#define COL_AUTHOR8_NORMAL RGB_COLORDATA(211, 222, 232) +#define COL_AUTHOR8_LIGHT RGB_COLORDATA(226, 234, 241) +#define COL_AUTHOR9_DARK RGB_COLORDATA(209, 118, 0) +#define COL_AUTHOR9_NORMAL RGB_COLORDATA(255, 226, 185) +#define COL_AUTHOR9_LIGHT RGB_COLORDATA(255, 231, 199) + +#define COLOR_CHANNEL_MERGE( _def_cDst, _def_cSrc, _def_cSrcTrans ) \ + ((BYTE)((((long)(_def_cDst)-(_def_cSrc))*(_def_cSrcTrans)+(((_def_cSrc)<<8L)|(_def_cDst)))>>8L)) + +// --------- +// - Color - +// --------- + +class TOOLS_DLLPUBLIC Color +{ +protected: + ColorData mnColor; + +public: + Color() { mnColor = COL_BLACK; } + Color( ColorData nColor ) { mnColor = nColor; } + Color( UINT8 nRed, UINT8 nGreen, UINT8 nBlue ) + { mnColor = RGB_COLORDATA( nRed, nGreen, nBlue ); } + Color( UINT8 nTransparency, UINT8 nRed, UINT8 nGreen, UINT8 nBlue ) + { mnColor = TRGB_COLORDATA( nTransparency, nRed, nGreen, nBlue ); } + Color( const ResId& rResId ); + // This ctor is defined in svtools, not tools! + + // constructor to create a tools-Color from ::basegfx::BColor + explicit Color(const ::basegfx::BColor& rBColor) + { + mnColor = RGB_COLORDATA( + UINT8((rBColor.getRed() * 255.0) + 0.5), + UINT8((rBColor.getGreen() * 255.0) + 0.5), + UINT8((rBColor.getBlue() * 255.0) + 0.5)); + } + + void SetRed( UINT8 nRed ); + UINT8 GetRed() const { return COLORDATA_RED( mnColor ); } + void SetGreen( UINT8 nGreen ); + UINT8 GetGreen() const { return COLORDATA_GREEN( mnColor ); } + void SetBlue( UINT8 nBlue ); + UINT8 GetBlue() const { return COLORDATA_BLUE( mnColor ); } + void SetTransparency( UINT8 nTransparency ); + UINT8 GetTransparency() const { return COLORDATA_TRANSPARENCY( mnColor ); } + + void SetColor( ColorData nColor ) { mnColor = nColor; } + ColorData GetColor() const { return mnColor; } + ColorData GetRGBColor() const { return COLORDATA_RGB( mnColor ); } + + UINT8 GetColorError( const Color& rCompareColor ) const; + + UINT8 GetLuminance() const; + void IncreaseLuminance( UINT8 cLumInc ); + void DecreaseLuminance( UINT8 cLumDec ); + + void IncreaseContrast( UINT8 cContInc ); + void DecreaseContrast( UINT8 cContDec ); + + void Invert(); + + void Merge( const Color& rMergeColor, BYTE cTransparency ); + + BOOL IsRGBEqual( const Color& rColor ) const; + + // comparison with luminance thresholds + BOOL IsDark() const; + BOOL IsBright() const; + + // color space conversion tools + // the range for h/s/b is: + // Hue: 0-360 degree + // Saturation: 0-100 % + // Brightness: 0-100 % + static ColorData HSBtoRGB( USHORT nHue, USHORT nSat, USHORT nBri ); + void RGBtoHSB( USHORT& nHue, USHORT& nSat, USHORT& nBri ) const; + + BOOL operator==( const Color& rColor ) const + { return (mnColor == rColor.mnColor); } + BOOL operator!=( const Color& rColor ) const + { return !(Color::operator==( rColor )); } + + SvStream& Read( SvStream& rIStm, BOOL bNewFormat = TRUE ); + SvStream& Write( SvStream& rOStm, BOOL bNewFormat = TRUE ); + + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Color& rColor ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Color& rColor ); + + // get ::basegfx::BColor from this color + ::basegfx::BColor getBColor() const { return ::basegfx::BColor(GetRed() / 255.0, GetGreen() / 255.0, GetBlue() / 255.0); } +}; + +inline void Color::SetRed( UINT8 nRed ) +{ + mnColor &= 0xFF00FFFF; + mnColor |= ((UINT32)nRed)<<16; +} + +inline void Color::SetGreen( UINT8 nGreen ) +{ + mnColor &= 0xFFFF00FF; + mnColor |= ((UINT16)nGreen)<<8; +} + +inline void Color::SetBlue( UINT8 nBlue ) +{ + mnColor &= 0xFFFFFF00; + mnColor |= nBlue; +} + +inline void Color::SetTransparency( UINT8 nTransparency ) +{ + mnColor &= 0x00FFFFFF; + mnColor |= ((UINT32)nTransparency)<<24; +} + +inline BOOL Color::IsRGBEqual( const Color& rColor ) const +{ + return (COLORDATA_RGB( mnColor ) == COLORDATA_RGB( rColor.mnColor )); +} + +inline UINT8 Color::GetLuminance() const +{ + return( (UINT8) ( ( COLORDATA_BLUE( mnColor ) * 28UL + + COLORDATA_GREEN( mnColor ) * 151UL + + COLORDATA_RED( mnColor ) * 77UL ) >> 8UL ) ); +} + +inline void Color::Merge( const Color& rMergeColor, BYTE cTransparency ) +{ + SetRed( COLOR_CHANNEL_MERGE( COLORDATA_RED( mnColor ), COLORDATA_RED( rMergeColor.mnColor ), cTransparency ) ); + SetGreen( COLOR_CHANNEL_MERGE( COLORDATA_GREEN( mnColor ), COLORDATA_GREEN( rMergeColor.mnColor ), cTransparency ) ); + SetBlue( COLOR_CHANNEL_MERGE( COLORDATA_BLUE( mnColor ), COLORDATA_BLUE( rMergeColor.mnColor ), cTransparency ) ); +} + +#endif // _TOOLS_COLOR_HXX diff --git a/tools/inc/tools/config.hxx b/tools/inc/tools/config.hxx new file mode 100644 index 000000000000..cb64cc2ec5bd --- /dev/null +++ b/tools/inc/tools/config.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * 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 _CONFIG_HXX +#define _CONFIG_HXX + +#include "tools/toolsdllapi.h" +#include <tools/string.hxx> + +struct ImplConfigData; +struct ImplGroupData; + +// ---------- +// - Config - +// ---------- + +class TOOLS_DLLPUBLIC Config +{ +private: + XubString maFileName; + ByteString maGroupName; + ImplConfigData* mpData; + ImplGroupData* mpActGroup; + ULONG mnDataUpdateId; + USHORT mnLockCount; + BOOL mbPersistence; + BOOL mbDummy1; + +#ifdef _CONFIG_CXX + TOOLS_DLLPRIVATE BOOL ImplUpdateConfig() const; + TOOLS_DLLPRIVATE ImplGroupData* ImplGetGroup() const; +#endif + +public: + Config(); + Config( const XubString& rFileName ); + ~Config(); + + const XubString& GetPathName() const { return maFileName; } + static XubString GetDefDirectory(); + static XubString GetConfigName( const XubString& rPath, const XubString& rBaseName ); + + void SetGroup( const ByteString& rGroup ); + const ByteString& GetGroup() const { return maGroupName; } + void DeleteGroup( const ByteString& rGroup ); + ByteString GetGroupName( USHORT nGroup ) const; + USHORT GetGroupCount() const; + BOOL HasGroup( const ByteString& rGroup ) const; + + ByteString ReadKey( const ByteString& rKey ) const; + UniString ReadKey( const ByteString& rKey, rtl_TextEncoding eEncoding ) const; + ByteString ReadKey( const ByteString& rKey, const ByteString& rDefault ) const; + void WriteKey( const ByteString& rKey, const ByteString& rValue ); + void WriteKey( const ByteString& rKey, const UniString& rValue, rtl_TextEncoding eEncoding ); + void DeleteKey( const ByteString& rKey ); + ByteString GetKeyName( USHORT nKey ) const; + ByteString ReadKey( USHORT nKey ) const; + USHORT GetKeyCount() const; + + void EnterLock(); + void LeaveLock(); + BOOL IsLocked() const { return (mnLockCount != 0); } + BOOL Update(); + void Flush(); + + void EnablePersistence( BOOL bPersistence = TRUE ) + { mbPersistence = bPersistence; } + BOOL IsPersistenceEnabled() const { return mbPersistence; } + + void SetLineEnd( LineEnd eLineEnd ); + LineEnd GetLineEnd() const; + +private: + TOOLS_DLLPRIVATE Config( const Config& rConfig ); + TOOLS_DLLPRIVATE Config& operator = ( const Config& rConfig ); +}; + +#endif // _SV_CONFIG_HXX diff --git a/tools/inc/tools/contnr.hxx b/tools/inc/tools/contnr.hxx new file mode 100644 index 000000000000..5cf8e7b74569 --- /dev/null +++ b/tools/inc/tools/contnr.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * 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 _CONTNR_HXX +#define _CONTNR_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +#include <limits.h> + +class CBlock; + +// ------------- +// - Container - +// ------------- + +// Maximale Blockgroesse +#define CONTAINER_MAXBLOCKSIZE ((USHORT)0x3FF0) + +#define CONTAINER_APPEND ULONG_MAX +#define CONTAINER_ENTRY_NOTFOUND ULONG_MAX + +class TOOLS_DLLPUBLIC Container +{ +private: + CBlock* pFirstBlock; + CBlock* pCurBlock; + CBlock* pLastBlock; + USHORT nCurIndex; + USHORT nBlockSize; + USHORT nInitSize; + USHORT nReSize; + ULONG nCount; + + TOOLS_DLLPRIVATE void ImpCopyContainer(Container const *); +#if defined DBG_UTIL + TOOLS_DLLPRIVATE static char const * DbgCheckContainer(void const *); +#endif + +protected: +#ifdef _IMPCONT_HXX + void ImpInsert( void* p, CBlock* pBlock, USHORT nIndex ); + void* ImpRemove( CBlock* pBlock, USHORT nIndex ); + void* ImpGetObject( ULONG nIndex ) const; + void** ImpGetOnlyNodes() const; +#endif + void** GetObjectPtr( ULONG nIndex ); + +public: + Container( USHORT nBlockSize, + USHORT nInitSize, + USHORT nReSize ); + Container( ULONG nSize ); + Container( const Container& rContainer ); + ~Container(); + + void Insert( void* p ); + void Insert( void* p, ULONG nIndex ); + void Insert( void* pNew, void* pOld ); + + void* Remove(); + void* Remove( ULONG nIndex ); + void* Remove( void* p ) + { return Remove( GetPos( p ) ); } + + void* Replace( void* p ); + void* Replace( void* p, ULONG nIndex ); + void* Replace( void* pNew, void* pOld ) + { return Replace( pNew, GetPos( pOld ) ); } + + void SetSize( ULONG nNewSize ); + ULONG GetSize() const { return nCount; } + + ULONG Count() const { return nCount; } + void Clear(); + + void* GetCurObject() const; + ULONG GetCurPos() const; + void* GetObject( ULONG nIndex ) const; + ULONG GetPos( const void* p ) const; + ULONG GetPos( const void* p, ULONG nStartIndex, + BOOL bForward = TRUE ) const; + + void* Seek( ULONG nIndex ); + void* Seek( void* p ) { return Seek( GetPos( p ) ); } + + void* First(); + void* Last(); + void* Next(); + void* Prev(); + + Container& operator =( const Container& rContainer ); + + BOOL operator ==( const Container& rContainer ) const; + BOOL operator !=( const Container& rContainer ) const + { return !(Container::operator==( rContainer )); } +}; + +#endif // _CONTNR_HXX diff --git a/tools/inc/tools/date.hxx b/tools/inc/tools/date.hxx new file mode 100644 index 000000000000..50b31edb0f83 --- /dev/null +++ b/tools/inc/tools/date.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * 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 _DATE_HXX +#define _DATE_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +class ResId; + +// -------------- +// - Date-Types - +// -------------- + +enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, + SATURDAY, SUNDAY }; + +// -------- +// - Date - +// -------- + +class TOOLS_DLLPUBLIC Date +{ +private: + sal_uInt32 nDate; + +public: + Date(); + Date( const ResId & rResId ); + Date( sal_uInt32 _nDate ) { Date::nDate = _nDate; } + Date( const Date& rDate ) + { nDate = rDate.nDate; } + Date( USHORT nDay, USHORT nMonth, USHORT nYear ) + { nDate = ( sal_uInt32( nDay % 100 ) ) + + ( ( sal_uInt32( nMonth % 100 ) ) * 100 ) + + ( ( sal_uInt32( nYear % 10000 ) ) * 10000); } + + void SetDate( sal_uInt32 nNewDate ) { nDate = nNewDate; } + sal_uInt32 GetDate() const { return nDate; } + + void SetDay( USHORT nNewDay ); + void SetMonth( USHORT nNewMonth ); + void SetYear( USHORT nNewYear ); + USHORT GetDay() const { return (USHORT)(nDate % 100); } + USHORT GetMonth() const { return (USHORT)((nDate / 100) % 100); } + USHORT GetYear() const { return (USHORT)(nDate / 10000); } + + DayOfWeek GetDayOfWeek() const; + USHORT GetDayOfYear() const; + /** nMinimumNumberOfDaysInWeek: how many days of a week must reside in the + first week of a year. */ + USHORT GetWeekOfYear( DayOfWeek eStartDay = MONDAY, + sal_Int16 nMinimumNumberOfDaysInWeek = 4 ) const; + + USHORT GetDaysInMonth() const; + USHORT GetDaysInYear() const { return (IsLeapYear()) ? 366 : 365; } + BOOL IsLeapYear() const; + BOOL IsValid() const; + + BOOL IsBetween( const Date& rFrom, const Date& rTo ) const + { return ((nDate >= rFrom.nDate) && + (nDate <= rTo.nDate)); } + + BOOL operator ==( const Date& rDate ) const + { return (nDate == rDate.nDate); } + BOOL operator !=( const Date& rDate ) const + { return (nDate != rDate.nDate); } + BOOL operator >( const Date& rDate ) const + { return (nDate > rDate.nDate); } + BOOL operator <( const Date& rDate ) const + { return (nDate < rDate.nDate); } + BOOL operator >=( const Date& rDate ) const + { return (nDate >= rDate.nDate); } + BOOL operator <=( const Date& rDate ) const + { return (nDate <= rDate.nDate); } + + Date& operator =( const Date& rDate ) + { nDate = rDate.nDate; return *this; } + Date& operator +=( long nDays ); + Date& operator -=( long nDays ); + Date& operator ++(); + Date& operator --(); +#ifndef MPW33 + Date operator ++( int ); + Date operator --( int ); +#endif + + TOOLS_DLLPUBLIC friend Date operator +( const Date& rDate, long nDays ); + TOOLS_DLLPUBLIC friend Date operator -( const Date& rDate, long nDays ); + TOOLS_DLLPUBLIC friend long operator -( const Date& rDate1, const Date& rDate2 ); + + static long DateToDays( USHORT nDay, USHORT nMonth, USHORT nYear ); + +}; + +#endif // _DATE_HXX diff --git a/tools/inc/tools/datetime.hxx b/tools/inc/tools/datetime.hxx new file mode 100644 index 000000000000..1a782486250b --- /dev/null +++ b/tools/inc/tools/datetime.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * 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 _DATETIME_HXX +#define _DATETIME_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/date.hxx> +#include <tools/time.hxx> + +// ------------ +// - DateTime - +// ------------ + +class TOOLS_DLLPUBLIC DateTime : public Date, public Time +{ +public: + DateTime() : Date(), Time() {} + DateTime( const DateTime& rDateTime ) : + Date( rDateTime ), Time( rDateTime ) {} + DateTime( const Date& rDate ) : Date( rDate ), Time(0) {} + DateTime( const Time& rTime ) : Date(0), Time( rTime ) {} + DateTime( const Date& rDate, const Time& rTime ) : + Date( rDate ), Time( rTime ) {} + + BOOL IsBetween( const DateTime& rFrom, + const DateTime& rTo ) const; + + BOOL IsEqualIgnore100Sec( const DateTime& rDateTime ) const + { + if ( Date::operator!=( rDateTime ) ) + return FALSE; + return Time::IsEqualIgnore100Sec( rDateTime ); + } + + BOOL operator ==( const DateTime& rDateTime ) const + { return (Date::operator==( rDateTime ) && + Time::operator==( rDateTime )); } + BOOL operator !=( const DateTime& rDateTime ) const + { return (Date::operator!=( rDateTime ) || + Time::operator!=( rDateTime )); } + BOOL operator >( const DateTime& rDateTime ) const; + BOOL operator <( const DateTime& rDateTime ) const; + BOOL operator >=( const DateTime& rDateTime ) const; + BOOL operator <=( const DateTime& rDateTime ) const; + + long GetSecFromDateTime( const Date& rDate ) const; + void MakeDateTimeFromSec( const Date& rDate, ULONG nSec ); + + void ConvertToUTC() { *this -= Time::GetUTCOffset(); } + void ConvertToLocalTime() { *this += Time::GetUTCOffset(); } + + DateTime& operator +=( long nDays ) + { Date::operator+=( nDays ); return *this; } + DateTime& operator -=( long nDays ) + { Date::operator-=( nDays ); return *this; } + DateTime& operator +=( double fTimeInDays ); + DateTime& operator -=( double fTimeInDays ) + { return operator+=( -fTimeInDays ); } + DateTime& operator +=( const Time& rTime ); + DateTime& operator -=( const Time& rTime ); + + TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, long nDays ); + TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, long nDays ); + TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, double fTimeInDays ); + TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, double fTimeInDays ) + { return operator+( rDateTime, -fTimeInDays ); } + TOOLS_DLLPUBLIC friend DateTime operator +( const DateTime& rDateTime, const Time& rTime ); + TOOLS_DLLPUBLIC friend DateTime operator -( const DateTime& rDateTime, const Time& rTime ); + TOOLS_DLLPUBLIC friend double operator -( const DateTime& rDateTime1, const DateTime& rDateTime2 ); + TOOLS_DLLPUBLIC friend long operator -( const DateTime& rDateTime, const Date& rDate ) + { return (const Date&) rDateTime - rDate; } + + DateTime& operator =( const DateTime& rDateTime ); + + void GetWin32FileDateTime( sal_uInt32 & rLower, sal_uInt32 & rUpper ); + static DateTime CreateFromWin32FileDateTime( const sal_uInt32 & rLower, const sal_uInt32 & rUpper ); +}; + +inline DateTime& DateTime::operator =( const DateTime& rDateTime ) +{ + Date::operator=( rDateTime ); + Time::operator=( rDateTime ); + return *this; +} + +#endif // _DATETIME_HXX diff --git a/tools/inc/tools/debug.hxx b/tools/inc/tools/debug.hxx new file mode 100644 index 000000000000..b8aa1c8b59fe --- /dev/null +++ b/tools/inc/tools/debug.hxx @@ -0,0 +1,777 @@ +/************************************************************************* + * + * 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 _TOOLS_DEBUG_HXX +#define _TOOLS_DEBUG_HXX + +#include "tools/toolsdllapi.h" + +#ifndef _SAL_TYPES_H +#include <sal/types.h> +#endif +#include <tools/solar.h> + +// ------------ +// - DBG_UITL - +// ------------ + +#ifdef DBG_UTIL + +// --- Dbg-Daten --- + +typedef void (*DbgPrintLine)( const sal_Char* pLine ); +typedef const sal_Char* (*DbgUsr)(const void* pThis ); +typedef void (*DbgTestSolarMutexProc)(); + +#define DBG_BUF_MAXLEN 16384 + +#define DBG_TEST_XTOR (0x00000FFF) +#define DBG_TEST_XTOR_THIS (0x00000001) +#define DBG_TEST_XTOR_FUNC (0x00000002) +#define DBG_TEST_XTOR_EXIT (0x00000004) +#define DBG_TEST_XTOR_REPORT (0x00000008) +#define DBG_TEST_XTOR_TRACE (0x00000010) + +#define DBG_TEST_MEM (0x00FFF000) +#define DBG_TEST_MEM_INIT (0x00001000) +#define DBG_TEST_MEM_OVERWRITE (0x00002000) +#define DBG_TEST_MEM_OVERWRITEFREE (0x00004000) +#define DBG_TEST_MEM_POINTER (0x00008000) +#define DBG_TEST_MEM_REPORT (0x00010000) +#define DBG_TEST_MEM_TRACE (0x00020000) +#define DBG_TEST_MEM_NEWDEL (0x00040000) +#define DBG_TEST_MEM_XTOR (0x00080000) +#define DBG_TEST_MEM_SYSALLOC (0x00100000) +#define DBG_TEST_MEM_LEAKREPORT (0x00200000) + +#define DBG_TEST_PROFILING (0x01000000) +#define DBG_TEST_RESOURCE (0x02000000) +#define DBG_TEST_DIALOG (0x04000000) +#define DBG_TEST_BOLDAPPFONT (0x08000000) + +#define DBG_OUT_NULL 0 +#define DBG_OUT_FILE 1 +#define DBG_OUT_WINDOW 2 +#define DBG_OUT_SHELL 3 +#define DBG_OUT_MSGBOX 4 +#define DBG_OUT_TESTTOOL 5 +#define DBG_OUT_DEBUGGER 6 +#define DBG_OUT_COREDUMP 7 + +#define DBG_OUT_COUNT 8 + +// user (runtime) defined output channels +#define DBG_OUT_USER_CHANNEL_0 100 + +#define DBGGUI_RESTORE 0 +#define DBGGUI_MINIMIZE 1 +#define DBGGUI_MAXIMIZE 2 + +struct DbgData +{ + ULONG nTestFlags; + ULONG bOverwrite; + ULONG nTraceOut; + ULONG nWarningOut; + ULONG nErrorOut; + ULONG bHookOSLAssert; + BYTE bMemInit; + BYTE bMemBound; + BYTE bMemFree; + sal_Char aDebugName[260]; + sal_Char aInclFilter[512]; + sal_Char aExclFilter[512]; + sal_Char aInclClassFilter[512]; + sal_Char aExclClassFilter[512]; + sal_Char aDbgWinState[50]; // DbgGUIData for VCL +}; + +struct DbgDataType +{ + void* pData; + sal_Char const * pName; +}; + +// --- Dbg-Prototypen --- + +#define DBG_FUNC_DEBUGSTART 1 +#define DBG_FUNC_DEBUGEND 2 +#define DBG_FUNC_GLOBALDEBUGEND 3 +#define DBG_FUNC_GETDATA 4 +#define DBG_FUNC_SAVEDATA 5 +#define DBG_FUNC_SETPRINTMSGBOX 6 +#define DBG_FUNC_SETPRINTWINDOW 7 +#define DBG_FUNC_SETPRINTTESTTOOL 8 +#define DBG_FUNC_MEMTEST 9 +#define DBG_FUNC_XTORINFO 10 +#define DBG_FUNC_MEMINFO 11 +#define DBG_FUNC_COREDUMP 12 +#define DBG_FUNC_ALLERROROUT 13 +#define DBG_FUNC_SETTESTSOLARMUTEX 14 +#define DBG_FUNC_TESTSOLARMUTEX 15 +#define DBG_FUNC_PRINTFILE 16 +#define DBG_FUNC_GETPRINTMSGBOX 17 +#define DBG_FUNC_FILTERMESSAGE 18 // new for #i38967 +#define DBG_FUNC_UPDATEOSLHOOK 19 + +TOOLS_DLLPUBLIC void* DbgFunc( USHORT nAction, void* pData = NULL ); + +inline void DbgUpdateOslHook( DbgData* pData ) +{ + DbgFunc( DBG_FUNC_UPDATEOSLHOOK, pData ); +} + +inline void DbgDebugStart() +{ + DbgFunc( DBG_FUNC_DEBUGSTART ); +} + +inline void DbgDebugEnd() +{ + DbgFunc( DBG_FUNC_DEBUGEND ); +} + +inline void DbgGlobalDebugEnd() +{ + DbgFunc( DBG_FUNC_GLOBALDEBUGEND ); +} + +inline void DbgSetPrintMsgBox( DbgPrintLine pProc ) +{ + DbgFunc( DBG_FUNC_SETPRINTMSGBOX, (void*)(long)pProc ); +} + +inline DbgPrintLine DbgGetPrintMsgBox() +{ + return (DbgPrintLine)(long)DbgFunc( DBG_FUNC_GETPRINTMSGBOX ); +} + +inline void DbgSetPrintWindow( DbgPrintLine pProc ) +{ + DbgFunc( DBG_FUNC_SETPRINTWINDOW, (void*)(long)pProc ); +} + +inline void DbgSetPrintTestTool( DbgPrintLine pProc ) +{ + DbgFunc( DBG_FUNC_SETPRINTTESTTOOL, (void*)(long)pProc ); +} + +typedef USHORT DbgChannelId; +/** registers a user-defined channel for emitting the diagnostic messages + + Note that such a user-defined channel cannot be revoked during the lifetime + of the process. Thus, it's the caller's responsibility to ensure that the + procedure to which ->pProc points remains valid. + + @param pProc + the function for emitting the diagnostic messages + @return + a unique number for this channel, which can be used for ->DbgData::nErrorOut, + ->DbgData::nWarningOut and ->DbgData::nTraceOut + @see DBG_OUT_USER_CHANNEL_0 + + (In theory, this function could replace the other hard-coded channels. Well, at least + the ones for MsgBox, Window, Shell, TestTool. Perhaps in the next life ...) +*/ +TOOLS_DLLPUBLIC DbgChannelId DbgRegisterUserChannel( DbgPrintLine pProc ); + +inline BOOL DbgFilterMessage( const char* pMsg ) +{ + return (BOOL)(long) DbgFunc( DBG_FUNC_FILTERMESSAGE, (void*)pMsg ); +} + +inline int DbgIsAllErrorOut() +{ + return (DbgFunc( DBG_FUNC_ALLERROROUT ) != 0); +} + +inline DbgData* DbgGetData() +{ + return (DbgData*)DbgFunc( DBG_FUNC_GETDATA ); +} + +inline void DbgSaveData( const DbgData& rData ) +{ + DbgFunc( DBG_FUNC_SAVEDATA, (void*)&rData ); +} + +inline ULONG DbgIsTraceOut() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return (pData->nTraceOut != DBG_OUT_NULL); + else + return FALSE; +} + +inline ULONG DbgIsWarningOut() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return (pData->nWarningOut != DBG_OUT_NULL); + else + return FALSE; +} + +inline ULONG DbgIsErrorOut() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return (pData->nErrorOut != DBG_OUT_NULL); + else + return FALSE; +} + +inline ULONG DbgGetErrorOut() // Testtool: test wether to collect OSL_ASSERTions as well +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return pData->nErrorOut; + else + return DBG_OUT_NULL; +} + +inline ULONG DbgIsAssertWarning() +{ + return DbgIsWarningOut(); +} + +inline ULONG DbgIsAssert() +{ + return DbgIsErrorOut(); +} + +inline ULONG DbgIsResource() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return pData->nTestFlags & DBG_TEST_RESOURCE; + else + return FALSE; +} + +inline ULONG DbgIsDialog() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return pData->nTestFlags & DBG_TEST_DIALOG; + else + return FALSE; +} + +inline ULONG DbgIsBoldAppFont() +{ + DbgData* pData = DbgGetData(); + if ( pData ) + return pData->nTestFlags & DBG_TEST_BOLDAPPFONT; + else + return FALSE; +} + +inline void DbgXtorInfo( sal_Char* pBuf ) +{ + DbgFunc( DBG_FUNC_XTORINFO, (void*)pBuf ); +} + +inline void DbgMemInfo( sal_Char* pBuf ) +{ + DbgFunc( DBG_FUNC_MEMINFO, (void*)pBuf ); +} + +inline void DbgCoreDump() +{ + DbgFunc( DBG_FUNC_COREDUMP ); +} + +inline void DbgSetTestSolarMutex( DbgTestSolarMutexProc pProc ) +{ + DbgFunc( DBG_FUNC_SETTESTSOLARMUTEX, (void*)(long)pProc ); +} + +inline void DbgTestSolarMutex() +{ + DbgFunc( DBG_FUNC_TESTSOLARMUTEX ); +} + +inline void DbgPrintFile( const sal_Char* pLine ) +{ + DbgFunc( DBG_FUNC_PRINTFILE, (void*)(sal_Char*)pLine ); +} + +// --- Dbg-StackTree-Functions --- + +TOOLS_DLLPUBLIC void DbgStartStackTree(); +TOOLS_DLLPUBLIC void DbgEndStackTree(); +void* DbgGetStackTree( ULONG nAlloc = 0 ); +void DbgFreeStackTree( void* p, ULONG nAlloc = 0 ); +void DbgPrintStackTree( void* p ); + +// --- Dbg-Output --- + +#define DBG_OUT_TRACE 1 +#define DBG_OUT_WARNING 2 +#define DBG_OUT_ERROR 3 + +TOOLS_DLLPUBLIC void DbgOut( const sal_Char* pMsg, USHORT nOutType = DBG_OUT_TRACE, + const sal_Char* pFile = NULL, USHORT nLine = 0 ); +TOOLS_DLLPUBLIC void DbgPrintShell(char const * message); +TOOLS_DLLPUBLIC void DbgOutTypef( USHORT nOutType, const sal_Char* pFStr, ... ); +TOOLS_DLLPUBLIC void DbgOutf( const sal_Char* pFStr, ... ); +TOOLS_DLLPUBLIC void ImpDbgOutfBuf( sal_Char* pBuf, const sal_Char* pFStr, ... ); + +inline void DbgTrace( const sal_Char* pMsg, + const sal_Char* pFile = NULL, USHORT nLine = 0 ) +{ + DbgOut( pMsg, DBG_OUT_TRACE, pFile, nLine ); +} + +inline void DbgWarning( const sal_Char* pMsg, + const sal_Char* pFile = NULL, USHORT nLine = 0 ) +{ + DbgOut( pMsg, DBG_OUT_WARNING, pFile, nLine ); +} + +inline void DbgError( const sal_Char* pMsg, + const sal_Char* pFile = NULL, USHORT nLine = 0 ) +{ + DbgOut( pMsg, DBG_OUT_ERROR, pFile, nLine ); +} + +// --- Dbg-Test-Functions --- + +inline void DbgMemTest( void* p = NULL ) +{ + DbgFunc( DBG_FUNC_MEMTEST, p ); +} + +#define DBG_PROF_START 1 +#define DBG_PROF_STOP 2 +#define DBG_PROF_CONTINUE 3 +#define DBG_PROF_PAUSE 4 + +TOOLS_DLLPUBLIC void DbgProf( USHORT nAction, DbgDataType* ); + +#define DBG_XTOR_CTOR 1 +#define DBG_XTOR_DTOR 2 +#define DBG_XTOR_CHKTHIS 3 +#define DBG_XTOR_CHKOBJ 4 +#define DBG_XTOR_DTOROBJ 0x8000 + +TOOLS_DLLPUBLIC void DbgXtor( DbgDataType* pDbgData, + USHORT nAction, const void* pThis, DbgUsr fDbgUsr ); + +class DbgXtorObj +{ +private: + DbgDataType* pDbgData; + const void* pThis; + DbgUsr fDbgUsr; + USHORT nAction; + +public: + DbgXtorObj( DbgDataType* pData, + USHORT nAct, const void* pThs, DbgUsr fUsr ) + { + DbgXtor( pData, nAct, pThs, fUsr ); + pDbgData = pData; + nAction = nAct; + pThis = pThs; + fDbgUsr = fUsr; + } + + ~DbgXtorObj() + { + DbgXtor( pDbgData, nAction | DBG_XTOR_DTOROBJ, + pThis, fDbgUsr ); + } +}; + +// --- Dbg-Defines (intern) --- + +#define DBG_FUNC( aName ) DbgName_##aName() +#define DBG_NAME( aName ) static DbgDataType aImpDbgData_##aName = { 0, #aName }; \ + DbgDataType* DBG_FUNC( aName ) { return &aImpDbgData_##aName; } +#define DBG_NAMEEX_VISIBILITY( aName, vis ) vis DbgDataType* DBG_FUNC( aName ); +#define DBG_NAMEEX( aName ) DBG_NAMEEX_VISIBILITY( aName, ) + +// --- Dbg-Defines (extern) --- + +#define DBG_DEBUGSTART() DbgDebugStart() +#define DBG_DEBUGEND() DbgDebugEnd() +#define DBG_GLOBALDEBUGEND() DbgGlobalDebugEnd() + +#define DBG_STARTAPPEXECUTE() DbgStartStackTree() +#define DBG_ENDAPPEXECUTE() DbgEndStackTree() + +#define DBG_MEMTEST() DbgMemTest() +#define DBG_MEMTEST_PTR( p ) DbgMemTest( (void*)p ) + +#define DBG_PROFSTART( aName ) \ + DbgProf( DBG_PROF_START, DBG_FUNC( aName ) ) + +#define DBG_PROFSTOP( aName ) \ + DbgProf( DBG_PROF_STOP, DBG_FUNC( aName ) ) + +#define DBG_PROFCONTINUE( aName ) \ + DbgProf( DBG_PROF_CONTINUE, DBG_FUNC( aName ) ) + +#define DBG_PROFPAUSE( aName ) \ + DbgProf( DBG_PROF_PAUSE, DBG_FUNC( aName ) ) + +#define DBG_CTOR( aName, fTest ) \ + DbgXtorObj aDbgXtorObj( DBG_FUNC( aName ), \ + DBG_XTOR_CTOR, \ + (const void*)this, \ + fTest ) + +#define DBG_DTOR( aName, fTest ) \ + DbgXtorObj aDbgXtorObj( DBG_FUNC( aName ), \ + DBG_XTOR_DTOR, \ + (const void*)this, \ + fTest ) + +#define DBG_CHKTHIS( aName, fTest ) \ + DbgXtorObj aDbgXtorObj( DBG_FUNC( aName ), \ + DBG_XTOR_CHKTHIS, \ + (const void*)this, \ + fTest ) + +#define DBG_CHKOBJ( pObj, aName, fTest ) \ + DbgXtor( DBG_FUNC( aName ), DBG_XTOR_CHKOBJ, \ + (const void*)pObj, (DbgUsr)fTest ) + +#define DBG_ASSERTWARNING( sCon, aWarning ) \ +do \ +{ \ + if ( DbgIsAssertWarning() ) \ + { \ + if ( !( sCon ) ) \ + { \ + DbgWarning( aWarning, __FILE__, \ + __LINE__ ); \ + } \ + } \ +} while(0) + +#define DBG_ASSERT( sCon, aError ) \ +do \ +{ \ + if ( DbgIsAssert() ) \ + { \ + if ( !( sCon ) ) \ + { \ + DbgError( aError, \ + __FILE__, __LINE__ ); \ + } \ + } \ +} while(0) + +#ifdef DBG_BINFILTER +#define DBG_BF_ASSERT( sCon, aError ) \ +do \ +{ \ + if ( !( sCon ) ) \ + { \ + DbgError( aError, \ + __FILE__, __LINE__ ); \ + } \ +} while(0) +#else +#define DBG_BF_ASSERT( sCon, aError ) ((void)0) +#endif + +#define DBG_TRACE( aTrace ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + DbgTrace( aTrace ); \ +} while(0) +#define DBG_TRACE1( aTrace, x1 ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + { \ + DbgOutTypef( DBG_OUT_TRACE, aTrace, \ + x1 ); \ + } \ +} while(0) +#define DBG_TRACE2( aTrace, x1, x2 ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + { \ + DbgOutTypef( DBG_OUT_TRACE, aTrace, \ + x1, x2 ); \ + } \ +} while(0) +#define DBG_TRACE3( aTrace, x1, x2, x3 ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + { \ + DbgOutTypef( DBG_OUT_TRACE, aTrace, \ + x1, x2, x3 ); \ + } \ +} while(0) +#define DBG_TRACE4( aTrace, x1, x2, x3, x4 ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + { \ + DbgOutTypef( DBG_OUT_TRACE, aTrace, \ + x1, x2, x3, x4 ); \ + } \ +} while(0) +#define DBG_TRACE5( aTrace, x1, x2, x3, x4, x5 ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + { \ + DbgOutTypef( DBG_OUT_TRACE, aTrace, \ + x1, x2, x3, x4, x5 ); \ + } \ +} while(0) +#define DBG_TRACEFILE( aTrace ) \ +do \ +{ \ + if ( DbgIsTraceOut() ) \ + DbgTrace( aTrace, __FILE__, __LINE__ ); \ +} while(0) + +#define DBG_WARNING( aWarning ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + DbgWarning( aWarning ); \ +} while(0) +#define DBG_WARNING1( aWarning, x1 ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + { \ + DbgOutTypef( DBG_OUT_WARNING, aWarning, \ + x1 ); \ + } \ +} while(0) +#define DBG_WARNING2( aWarning, x1, x2 ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + { \ + DbgOutTypef( DBG_OUT_WARNING, aWarning, \ + x1, x2 ); \ + } \ +} while(0) +#define DBG_WARNING3( aWarning, x1, x2, x3 ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + { \ + DbgOutTypef( DBG_OUT_WARNING, aWarning, \ + x1, x2, x3 ); \ + } \ +} while(0) +#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + { \ + DbgOutTypef( DBG_OUT_WARNING, aWarning, \ + x1, x2, x3, x4 ); \ + } \ +} while(0) +#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 )\ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + { \ + DbgOutTypef( DBG_OUT_WARNING, aWarning, \ + x1, x2, x3, x4, x5 ); \ + } \ +} while(0) +#define DBG_WARNINGFILE( aWarning ) \ +do \ +{ \ + if ( DbgIsWarningOut() ) \ + DbgWarning( aWarning, __FILE__, __LINE__ ); \ +} while(0) + +#define DBG_ERROR( aError ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + DbgError( aError ); \ +} while(0) +#define DBG_ERROR1( aError, x1 ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + { \ + DbgOutTypef( DBG_OUT_ERROR, aError, \ + x1 ); \ + } \ +} while(0) +#define DBG_ERROR2( aError, x1, x2 ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + { \ + DbgOutTypef( DBG_OUT_ERROR, aError, \ + x1, x2 ); \ + } \ +} while(0) +#define DBG_ERROR3( aError, x1, x2, x3 ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + { \ + DbgOutTypef( DBG_OUT_ERROR, aError, \ + x1, x2, x3 ); \ + } \ +} while(0) +#define DBG_ERROR4( aError, x1, x2, x3, x4 ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + { \ + DbgOutTypef( DBG_OUT_ERROR, aError, \ + x1, x2, x3, x4 ); \ + } \ +} while(0) +#define DBG_ERROR5( aError, x1, x2, x3, x4, x5 ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + { \ + DbgOutTypef( DBG_OUT_ERROR, aError, \ + x1, x2, x3, x4, x5 ); \ + } \ +} while(0) +#define DBG_ERRORFILE( aError ) \ +do \ +{ \ + if ( DbgIsErrorOut() ) \ + DbgError( aError, __FILE__, __LINE__ ); \ +} while(0) + +#define DBG_TESTSOLARMUTEX() \ +do \ +{ \ + DbgTestSolarMutex(); \ +} while(0) + +// --- Dbg-Defines (An/Ausschlaten) --- + +#define DBG_INSTOUTTRACE( nOut ) \ +do \ +{ \ + DbgGetData()->nTraceOut = nOut; \ +} while(0) + +#define DBG_INSTOUTWARNING( nOut ) \ +do \ +{ \ + DbgGetData()->nWarningOut = nOut; \ +} while(0) + +#define DBG_INSTOUTERROR( nOut ) \ +do \ +{ \ + DbgGetData()->nErrorOut = nOut; \ +} while(0) + +#else + +// --------------- +// - NO DBG_UITL - +// --------------- + +struct DbgData; +struct DbgGUIData; +struct DbgDataType; + +typedef void (*DbgPrintLine)( const sal_Char* pLine ); +typedef const sal_Char* (*DbgUsr)(const void* pThis ); + +#define DBG_DEBUGSTART() ((void)0) +#define DBG_DEBUGEND() ((void)0) +#define DBG_GLOBALDEBUGEND() ((void)0) + +#define DBG_STARTAPPEXECUTE() ((void)0) +#define DBG_ENDAPPEXECUTE() ((void)0) + +#define DBG_MEMTEST() ((void)0) +#define DBG_MEMTEST_PTR( p ) ((void)0) + +#define DBG_NAME( aName ) +#define DBG_NAMEEX( aName ) +#define DBG_NAMEEX_VISIBILITY( aName, vis ) + +#define DBG_PROFSTART( aName ) ((void)0) +#define DBG_PROFSTOP( aName ) ((void)0) +#define DBG_PROFCONTINUE( aName ) ((void)0) +#define DBG_PROFPAUSE( aName ) ((void)0) + +#define DBG_CTOR( aName, fTest ) ((void)0) +#define DBG_DTOR( aName, fTest ) ((void)0) +#define DBG_CHKTHIS( aName, fTest ) ((void)0) +#define DBG_CHKOBJ( pObj, aName, fTest ) ((void)0) + +#define DBG_ASSERTWARNING( sCon, aWarning ) ((void)0) +#define DBG_ASSERT( sCon, aError ) ((void)0) +#define DBG_BF_ASSERT( sCon, aError ) ((void)0) +#define DBG_TRACE( aTrace ) ((void)0) +#define DBG_TRACE1( aTrace, x1 ) ((void)0) +#define DBG_TRACE2( aTrace, x1, x2 ) ((void)0) +#define DBG_TRACE3( aTrace, x1, x2, x3 ) ((void)0) +#define DBG_TRACE4( aTrace, x1, x2, x3, x4 ) ((void)0) +#define DBG_TRACE5( aTrace, x1, x2, x3, x4, x5 ) ((void)0) +#define DBG_TRACEFILE( aTrace ) ((void)0) +#define DBG_WARNING( aWarning ) ((void)0) +#define DBG_WARNING1( aWarning, x1 ) ((void)0) +#define DBG_WARNING2( aWarning, x1, x2 ) ((void)0) +#define DBG_WARNING3( aWarning, x1, x2, x3 ) ((void)0) +#define DBG_WARNING4( aWarning, x1, x2, x3, x4 ) ((void)0) +#define DBG_WARNING5( aWarning, x1, x2, x3, x4, x5 ) ((void)0) +#define DBG_WARNINGFILE( aWarning ) ((void)0) +#define DBG_ERROR( aError ) ((void)0) +#define DBG_ERROR1( aError, x1 ) ((void)0) +#define DBG_ERROR2( aError, x1, x2 ) ((void)0) +#define DBG_ERROR3( aError, x1, x2, x3 ) ((void)0) +#define DBG_ERROR4( aError, x1, x2, x3, x4 ) ((void)0) +#define DBG_ERROR5( aError, x1, x2, x3, x4, x5 ) ((void)0) +#define DBG_ERRORFILE( aError ) ((void)0) + +#define DBG_TESTSOLARMUTEX() ((void)0) + +#define DBG_INSTOUTTRACE( nOut ) ((void)0) +#define DBG_INSTOUTWARNING( nOut ) ((void)0) +#define DBG_INSTOUTERROR( nOut ) ((void)0) + +#endif + +#endif // _TOOLS_DEBUG_HXX diff --git a/tools/inc/tools/diagnose_ex.h b/tools/inc/tools/diagnose_ex.h new file mode 100644 index 000000000000..b244d11dc305 --- /dev/null +++ b/tools/inc/tools/diagnose_ex.h @@ -0,0 +1,175 @@ +/************************************************************************* + * + * 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 TOOLS_DIAGNOSE_EX_H +#define TOOLS_DIAGNOSE_EX_H + +#include <osl/diagnose.h> +#include <rtl/ustring.hxx> + +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> + +#include <boost/current_function.hpp> + + +#define OSL_UNUSED( expression ) \ + (void)(expression) + +#if OSL_DEBUG_LEVEL > 0 + + #include <cppuhelper/exc_hlp.hxx> + #include <osl/diagnose.h> + #include <osl/thread.h> + #include <boost/current_function.hpp> + #include <typeinfo> + + /** reports a caught UNO exception via OSL diagnostics + + Note that whenever you use this, it might be an indicator that your error + handling is not correct .... + */ + #define DBG_UNHANDLED_EXCEPTION() \ + ::com::sun::star::uno::Any caught( ::cppu::getCaughtException() ); \ + ::rtl::OString sMessage( "caught an exception!" ); \ + sMessage += "\nin function:"; \ + sMessage += BOOST_CURRENT_FUNCTION; \ + sMessage += "\ntype: "; \ + sMessage += ::rtl::OString( caught.getValueTypeName().getStr(), caught.getValueTypeName().getLength(), osl_getThreadTextEncoding() ); \ + ::com::sun::star::uno::Exception exception; \ + caught >>= exception; \ + if ( exception.Message.getLength() ) \ + { \ + sMessage += "\nmessage: "; \ + sMessage += ::rtl::OString( exception.Message.getStr(), exception.Message.getLength(), osl_getThreadTextEncoding() ); \ + } \ + if ( exception.Context.is() ) \ + { \ + const char* pContext = typeid( *exception.Context.get() ).name(); \ + sMessage += "\ncontext: "; \ + sMessage += pContext; \ + } \ + sMessage += "\n"; \ + OSL_ENSURE( false, sMessage ) + +#else // OSL_DEBUG_LEVEL + + #define DBG_UNHANDLED_EXCEPTION() + +#endif // OSL_DEBUG_LEVEL + + +/** This macro asserts the given condition (in debug mode), and throws + an IllegalArgumentException afterwards. + */ +#define ENSURE_ARG_OR_THROW(c, m) if( !(c) ) { \ + OSL_ENSURE(c, m); \ + throw ::com::sun::star::lang::IllegalArgumentException( \ + ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \ + ::rtl::OUString::createFromAscii(",\n"m), \ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(), \ + 0 ); } +#define ENSURE_ARG_OR_THROW2(c, m, ifc, arg) if( !(c) ) { \ + OSL_ENSURE(c, m); \ + throw ::com::sun::star::lang::IllegalArgumentException( \ + ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \ + ::rtl::OUString::createFromAscii(",\n"m), \ + ifc, \ + arg ); } + +/** This macro asserts the given condition (in debug mode), and throws + an RuntimeException afterwards. + */ +#define ENSURE_OR_THROW(c, m) if( !(c) ) { \ + OSL_ENSURE(c, m); \ + throw ::com::sun::star::uno::RuntimeException( \ + ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \ + ::rtl::OUString::createFromAscii(",\n"m), \ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); } +#define ENSURE_OR_THROW2(c, m, ifc) if( !(c) ) { \ + OSL_ENSURE(c, m); \ + throw ::com::sun::star::uno::RuntimeException( \ + ::rtl::OUString::createFromAscii(BOOST_CURRENT_FUNCTION) + \ + ::rtl::OUString::createFromAscii(",\n"m), \ + ifc ); } + +/** This macro asserts the given condition (in debug mode), and + returns the given value afterwards. + */ +#define ENSURE_OR_RETURN(c, m, r) if( !(c) ) { \ + OSL_ENSURE(c, m); \ + return r; } + +/** This macro asserts the given condition (in debug mode), and + returns false afterwards. + */ +#define ENSURE_OR_RETURN_FALSE(c, m) \ + ENSURE_OR_RETURN(c, m, false) + +/** This macro asserts the given condition (in debug mode), and + returns afterwards, without return value "void". + */ +#define ENSURE_OR_RETURN_VOID( c, m ) \ + if( !(c) ) \ + { \ + OSL_ENSURE( c, m ); \ + return; \ + } + + + +/** This macro asserts the given condition (in debug mode), and + returns afterwards, without return value "void". + */ +#define ENSURE_OR_RETURN_VOID( c, m ) \ + if( !(c) ) \ + { \ + OSL_ENSURE( c, m ); \ + return; \ + } + +/** asserts a given condition (in debug mode), and continues the most-inner + loop if the condition is not met +*/ +#define ENSURE_OR_CONTINUE( c, m ) \ + if ( !(c) ) \ + { \ + OSL_ENSURE( false, m ); \ + continue; \ + } + +/** asserts a given condition (in debug mode), and continues the most-inner + loop if the condition is not met +*/ +#define ENSURE_OR_BREAK( c, m ) \ + if ( !(c) ) \ + { \ + OSL_ENSURE( false, m ); \ + break; \ + } + +#endif // TOOLS_DIAGNOSE_EX_H diff --git a/tools/inc/tools/dynary.hxx b/tools/inc/tools/dynary.hxx new file mode 100644 index 000000000000..1693be40e435 --- /dev/null +++ b/tools/inc/tools/dynary.hxx @@ -0,0 +1,110 @@ +/************************************************************************* + * + * 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 _DYNARY_HXX +#define _DYNARY_HXX + +#include <tools/solar.h> +#include <tools/contnr.hxx> + +// ------------ +// - DynArray - +// ------------ + +#define DYNARRAY_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class DynArray : private Container +{ +public: + using Container::SetSize; + using Container::GetSize; + using Container::Clear; + + DynArray( ULONG nSize = 16 ) : Container( nSize ) {} + DynArray( const DynArray& rAry ) : Container( rAry ) {} + + void* Put( ULONG nIndex, void* p ) + { return Container::Replace( p, nIndex ); } + void* Get( ULONG nIndex ) const + { return Container::GetObject( nIndex ); } + + ULONG GetIndex( const void* p ) const + { return Container::GetPos( p ); } + ULONG GetIndex( const void* p, ULONG nStartIndex, + BOOL bForward = TRUE ) const + { return Container::GetPos( p, nStartIndex, bForward ); } + + DynArray& operator =( const DynArray& rAry ) + { Container::operator =( rAry ); return *this; } + + BOOL operator ==( const DynArray& rAry ) const + { return Container::operator ==( rAry ); } + BOOL operator !=( const DynArray& rAry ) const + { return Container::operator !=( rAry ); } +}; + +// -------------------- +// - DECLARE_DYNARRAY - +// -------------------- + +#define DECLARE_DYNARRAY( ClassName, Type ) \ +class ClassName : private DynArray \ +{ \ +public: \ + using DynArray::SetSize; \ + using DynArray::GetSize; \ + using DynArray::Clear; \ + \ + ClassName( ULONG nSize = 16 ) : \ + DynArray( nSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + DynArray( rClassName ) {} \ + \ + Type Put( ULONG nIndex, Type p ) \ + { return (Type)DynArray::Put( nIndex, (void*)p ); } \ + Type Get( ULONG nIndex ) const \ + { return (Type)DynArray::Get( nIndex ); } \ + \ + ULONG GetIndex( const Type p ) const \ + { return DynArray::GetIndex( (const void*)p ); } \ + ULONG GetIndex( const Type p, ULONG nStartIndex, \ + BOOL bForward = TRUE ) const \ + { return DynArray::GetIndex( (const void*)p, \ + nStartIndex, \ + bForward ); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { DynArray::operator =( rClassName ); \ + return *this; } \ + \ + BOOL operator ==( const ClassName& rAry ) const \ + { return DynArray::operator ==( rAry ); } \ + BOOL operator !=( const ClassName& rAry ) const \ + { return DynArray::operator !=( rAry ); } \ +}; + +#endif // _DYNARY_HXX diff --git a/tools/inc/tools/errcode.hxx b/tools/inc/tools/errcode.hxx new file mode 100644 index 000000000000..cf767b842b7a --- /dev/null +++ b/tools/inc/tools/errcode.hxx @@ -0,0 +1,323 @@ +/************************************************************************* + * + * 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 _ERRCODE_HXX +#define _ERRCODE_HXX + +#ifndef __RSC +#ifndef _SOLAR_H +#include <tools/solar.h> +#endif +#endif + +/* + +01234567012345670123456701234567 +|| || ||| || | +Warning || || | + | || || || | + Dynamic || || | + | || || | + Subsystembereiche | | + | || | + | || | + | || | + Class | + | | + | | + | | + Code +*/ + +#define ERRCODE_BUTTON_OK 0x01 +#define ERRCODE_BUTTON_CANCEL 0x02 +#define ERRCODE_BUTTON_RETRY 0x04 +#define ERRCODE_BUTTON_OK_CANCEL 0x03 +#define ERRCODE_BUTTON_OK_RETRY_CANCEL 0x07 +#define ERRCODE_BUTTON_NO 0x08 +#define ERRCODE_BUTTON_YES 0x10 +#define ERRCODE_BUTTON_YES_NO 0x18 +#define ERRCODE_BUTTON_YES_NO_CANCEL 0x1a + +#define ERRCODE_BUTTON_DEF_OK 0x100 +#define ERRCODE_BUTTON_DEF_CANCEL 0x200 +#define ERRCODE_BUTTON_DEF_YES 0x300 +#define ERRCODE_BUTTON_DEF_NO 0x400 + +#define ERRCODE_MSG_ERROR 0x1000 +#define ERRCODE_MSG_WARNING 0x2000 +#define ERRCODE_MSG_INFO 0x3000 +#define ERRCODE_MSG_QUERY 0x4000 + +#define ERRCODE_ERROR_MASK 0x3fffffffUL +#define ERRCODE_WARNING_MASK 0x80000000UL +#define ERRCODE_RES_MASK 0x7fff + +#define ERRCODE_CLASS_SHIFT 8 +#define ERRCODE_AREA_SHIFT 13 +#define ERRCODE_DYNAMIC_SHIFT 26 + +#define ERRCODE_CLASS_MASK (31UL <<ERRCODE_CLASS_SHIFT) + +#define ERRCODE_DYNAMIC_START (1UL <<ERRCODE_DYNAMIC_SHIFT) +#define ERRCODE_DYNAMIC_COUNT 31UL +#define ERRCODE_DYNAMIC_MASK (31UL <<ERRCODE_DYNAMIC_SHIFT) + +#ifdef __RSC + +#define ERRCODE_TOERRID(x) (x & ~ERRCODE_DYNAMIC_MASK) +#define ERRCODE_TOERROR(x) \ + ((x & ERRCODE_WARNING_MASK) ? 0 : (x & ERRCODE_ERROR_MASK)) + +#else + +typedef ULONG ErrCode; + +inline ULONG ERRCODE_TOERRID( ULONG x ) +{ + return x & ~ERRCODE_DYNAMIC_MASK; +} + +inline ULONG ERRCODE_TOERROR( ULONG x ) +{ + return ((x & ERRCODE_WARNING_MASK) ? 0 : (x & ERRCODE_ERROR_MASK)); +} + +#endif + +#define ERRCODE_AREA_TOOLS (0UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_SV (1UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_SFX (2UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_INET (3UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_IO ERRCODE_AREA_TOOLS + +#define ERRCODE_AREA_LIB1 (8UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_SVX ERRCODE_AREA_LIB1 +#define ERRCODE_AREA_SVX_END (ERRCODE_AREA_SO-1) +#define ERRCODE_AREA_SO (9UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_SO_END (ERRCODE_AREA_SBX-1) +#define ERRCODE_AREA_SBX (10UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_SBX_END ((11UL << ERRCODE_AREA_SHIFT) - 1) +#define ERRCODE_AREA_DB (11UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_DB_END ((12UL << ERRCODE_AREA_SHIFT) - 1) +#define ERRCODE_AREA_JAVA (12UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_JAVA_END ((13UL << ERRCODE_AREA_SHIFT) - 1) +#define ERRCODE_AREA_UUI (13UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_UUI_END ((14UL << ERRCODE_AREA_SHIFT) - 1) +#define ERRCODE_AREA_LIB2 (14UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_LIB2_END ((15UL << ERRCODE_AREA_SHIFT) - 1) +#define ERRCODE_AREA_CHAOS (15UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_CHAOS_END ((16UL << ERRCODE_AREA_SHIFT) - 1) + +#define ERRCODE_AREA_APP1 (32UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_APP2 (40UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_APP3 (48UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_APP4 (56UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_APP5 (64UL << ERRCODE_AREA_SHIFT) +#define ERRCODE_AREA_APP6 (72UL << ERRCODE_AREA_SHIFT) + +#define ERRCODE_AREA_SC ERRCODE_AREA_APP1 +#define ERRCODE_AREA_SC_END (ERRCODE_AREA_APP2-1) + +#define ERRCODE_AREA_SD ERRCODE_AREA_APP2 +#define ERRCODE_AREA_SD_END (ERRCODE_AREA_APP3-1) + +#define ERRCODE_AREA_SW ERRCODE_AREA_APP4 +#define ERRCODE_AREA_SW_END (ERRCODE_AREA_APP5-1) + +#define ERRCODE_AREA_OFA ERRCODE_AREA_APP5 +#define ERRCODE_AREA_OFA_END (ERRCODE_AREA_APP6-1) + +#define ERRCODE_CLASS_NONE (0UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_ABORT (1UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_GENERAL (2UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_NOTEXISTS (3UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_ALREADYEXISTS (4UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_ACCESS (5UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_PATH (6UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_LOCKING (7UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_PARAMETER (8UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_SPACE (9UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_NOTSUPPORTED (10UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_READ (11UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_WRITE (12UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_UNKNOWN (13UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_VERSION (14UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_FORMAT (15UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_CREATE (16UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_IMPORT (17UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_EXPORT (18UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_FILTER (19UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_SO (20UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_SBX (21UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_RUNTIME (22UL << ERRCODE_CLASS_SHIFT) +#define ERRCODE_CLASS_COMPILER (23UL << ERRCODE_CLASS_SHIFT) + +#define ERRCODE_NONE (0UL) +#define ERRCODE_ABORT ERRCODE_IO_ABORT + +#define ERRCODE_IO_MISPLACEDCHAR (1UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTEXISTS (2UL |ERRCODE_CLASS_NOTEXISTS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_ALREADYEXISTS (3UL |ERRCODE_CLASS_ALREADYEXISTS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTADIRECTORY (4UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTAFILE (5UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_INVALIDDEVICE (6UL |ERRCODE_CLASS_PATH|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_ACCESSDENIED (7UL |ERRCODE_CLASS_ACCESS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_LOCKVIOLATION (8UL |ERRCODE_CLASS_LOCKING|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_OUTOFSPACE (9UL |ERRCODE_CLASS_SPACE|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_ISWILDCARD (11UL|ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTSUPPORTED (12UL|ERRCODE_CLASS_NOTSUPPORTED|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_GENERAL (13UL|ERRCODE_CLASS_GENERAL|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_TOOMANYOPENFILES (14UL|ERRCODE_CLASS_SPACE|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CANTREAD (15UL|ERRCODE_CLASS_READ|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CANTWRITE (16UL|ERRCODE_CLASS_WRITE|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_OUTOFMEMORY (17UL|ERRCODE_CLASS_SPACE|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CANTSEEK (18UL|ERRCODE_CLASS_GENERAL|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CANTTELL (19UL|ERRCODE_CLASS_GENERAL|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_WRONGVERSION (20UL|ERRCODE_CLASS_VERSION|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_WRONGFORMAT (21UL|ERRCODE_CLASS_FORMAT|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_INVALIDCHAR (22UL|ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_UNKNOWN (23UL|ERRCODE_CLASS_UNKNOWN|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_INVALIDACCESS (24UL|ERRCODE_CLASS_ACCESS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CANTCREATE (25UL|ERRCODE_CLASS_CREATE|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_INVALIDPARAMETER (26UL|ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_ABORT (27UL|ERRCODE_CLASS_ABORT|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTEXISTSPATH (28UL |ERRCODE_CLASS_NOTEXISTS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_PENDING (29UL |ERRCODE_CLASS_NOTEXISTS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_RECURSIVE (30UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NAMETOOLONG (31UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_INVALIDLENGTH (32UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_CURRENTDIR (33UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTSAMEDEVICE (34UL |ERRCODE_CLASS_PARAMETER|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_DEVICENOTREADY (35UL |ERRCODE_CLASS_READ|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_BADCRC (36UL |ERRCODE_CLASS_READ|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_WRITEPROTECTED (37UL |ERRCODE_CLASS_ACCESS|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_BROKENPACKAGE (38UL |ERRCODE_CLASS_FORMAT|\ + ERRCODE_AREA_IO) +#define ERRCODE_IO_NOTSTORABLEINBINARYFORMAT (39UL |ERRCODE_CLASS_FORMAT|\ + ERRCODE_AREA_IO) + +// FsysErrorCodes + +#define FSYS_ERR_OK ERRCODE_NONE +#define FSYS_ERR_MISPLACEDCHAR ERRCODE_IO_MISPLACEDCHAR +#define FSYS_ERR_INVALIDCHAR ERRCODE_IO_INVALIDCHAR +#define FSYS_ERR_NOTEXISTS ERRCODE_IO_NOTEXISTS +#define FSYS_ERR_ALREADYEXISTS ERRCODE_IO_ALREADYEXISTS +#define FSYS_ERR_NOTADIRECTORY ERRCODE_IO_NOTADIRECTORY +#define FSYS_ERR_NOTAFILE ERRCODE_IO_NOTAFILE +#define FSYS_ERR_INVALIDDEVICE ERRCODE_IO_INVALIDDEVICE +#define FSYS_ERR_ACCESSDENIED ERRCODE_IO_ACCESSDENIED +#define FSYS_ERR_LOCKVIOLATION ERRCODE_IO_LOCKVIOLATION +#define FSYS_ERR_VOLUMEFULL ERRCODE_IO_OUTOFSPACE +#define FSYS_ERR_ISWILDCARD ERRCODE_IO_ISWILDCARD +#define FSYS_ERR_NOTSUPPORTED ERRCODE_IO_NOTSUPPORTED +#define FSYS_ERR_UNKNOWN ERRCODE_IO_UNKNOWN + +// StreamErrorCodes + +#define SVSTREAM_OK ERRCODE_NONE + +#define SVSTREAM_GENERALERROR ERRCODE_IO_GENERAL +#define SVSTREAM_FILE_NOT_FOUND ERRCODE_IO_NOTEXISTS +#define SVSTREAM_PATH_NOT_FOUND ERRCODE_IO_NOTEXISTSPATH +#define SVSTREAM_TOO_MANY_OPEN_FILES ERRCODE_IO_TOOMANYOPENFILES +#define SVSTREAM_ACCESS_DENIED ERRCODE_IO_ACCESSDENIED +#define SVSTREAM_SHARING_VIOLATION ERRCODE_IO_LOCKVIOLATION +#define SVSTREAM_LOCKING_VIOLATION ERRCODE_IO_LOCKVIOLATION +#define SVSTREAM_SHARE_BUFF_EXCEEDED ERRCODE_IO_LOCKVIOLATION + +#define SVSTREAM_INVALID_ACCESS ERRCODE_IO_INVALIDACCESS +#define SVSTREAM_INVALID_HANDLE ERRCODE_IO_GENERAL +#define SVSTREAM_CANNOT_MAKE ERRCODE_IO_CANTCREATE +#define SVSTREAM_INVALID_PARAMETER ERRCODE_IO_INVALIDPARAMETER + +#define SVSTREAM_READ_ERROR ERRCODE_IO_CANTREAD +#define SVSTREAM_WRITE_ERROR ERRCODE_IO_CANTWRITE +#define SVSTREAM_SEEK_ERROR ERRCODE_IO_CANTSEEK +#define SVSTREAM_TELL_ERROR ERRCODE_IO_CANTTELL + +#define SVSTREAM_OUTOFMEMORY ERRCODE_IO_OUTOFMEMORY + +#define SVSTREAM_FILEFORMAT_ERROR ERRCODE_IO_WRONGFORMAT +#define SVSTREAM_WRONGVERSION ERRCODE_IO_WRONGVERSION + +#define SVSTREAM_DISK_FULL ERRCODE_IO_OUTOFSPACE + +// Fuer die EditEngine: +#define SVSTREAM_ERRBASE_USER ERRCODE_AREA_LIB1 + +#define PRINTER_OK ERRCODE_NONE +#define PRINTER_ABORT ERRCODE_IO_ABORT +#define PRINTER_OUTOFMEMORY ERRCODE_IO_OUTOFMEMORY +#define PRINTER_GENERALERROR ERRCODE_IO_GENERAL +#define PRINTER_ACCESSDENIED ERRCODE_IO_ACCESSDENIED + +#define ERRCODE_INET_NAME_RESOLVE (ERRCODE_AREA_INET | ERRCODE_CLASS_READ | 1) +#define ERRCODE_INET_CONNECT (ERRCODE_AREA_INET | ERRCODE_CLASS_READ | 2) +#define ERRCODE_INET_READ (ERRCODE_AREA_INET | ERRCODE_CLASS_READ | 3) +#define ERRCODE_INET_WRITE (ERRCODE_AREA_INET | ERRCODE_CLASS_WRITE| 4) +#define ERRCODE_INET_GENERAL (ERRCODE_AREA_INET | ERRCODE_CLASS_WRITE |5) +#define ERRCODE_INET_OFFLINE (ERRCODE_AREA_INET | ERRCODE_CLASS_READ |6) + +#endif diff --git a/tools/inc/tools/errinf.hxx b/tools/inc/tools/errinf.hxx new file mode 100644 index 000000000000..45141af278b1 --- /dev/null +++ b/tools/inc/tools/errinf.hxx @@ -0,0 +1,243 @@ +/************************************************************************* + * + * 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 __RSC + +#ifndef _EINF_HXX +#define _EINF_HXX + +#include <limits.h> +#include <tools/rtti.hxx> +#include <tools/errcode.hxx> +#include <tools/string.hxx> +#include "tools/toolsdllapi.h" + +class EDcr_Impl; +class ErrHdl_Impl; +class Window; + +// ------------- +// - ErrorInfo - +// ------------- + +class ErrorInfo +{ +private: + ULONG lUserId; + +public: + TYPEINFO(); + + ErrorInfo( ULONG lArgUserId ) : + lUserId( lArgUserId ){} + virtual ~ErrorInfo(){} + + ULONG GetErrorCode() const { return lUserId; } + + static ErrorInfo* GetErrorInfo(ULONG); +}; + + +// -------------------- +// - DynamicErrorInfo - +// -------------------- + +class TOOLS_DLLPUBLIC DynamicErrorInfo : public ErrorInfo +{ + friend class EDcr_Impl; + +private: + EDcr_Impl* pImpl; + +public: + TYPEINFO(); + + DynamicErrorInfo(ULONG lUserId, USHORT nMask); + virtual ~DynamicErrorInfo(); + + operator ULONG() const; + USHORT GetDialogMask() const; +}; + + +// --------------------- +// - StandardErrorInfo - +// --------------------- + +class StandardErrorInfo : public DynamicErrorInfo +{ +private: + ULONG lExtId; + +public: + TYPEINFO(); + + StandardErrorInfo( ULONG lUserId, ULONG lExtId, + USHORT nFlags = 0); + ULONG GetExtendedErrorCode() const { return lExtId; } + +}; + + +// ------------------- +// - StringErrorInfo - +// ------------------- + +class TOOLS_DLLPUBLIC StringErrorInfo : public DynamicErrorInfo +{ +private: + String aString; + +public: + TYPEINFO(); + + StringErrorInfo( ULONG lUserId, + const String& aStringP, + USHORT nFlags = 0); + const String& GetErrorString() const { return aString; } +}; + +//============================================================================= +class TOOLS_DLLPUBLIC TwoStringErrorInfo: public DynamicErrorInfo +{ +private: + String aArg1; + String aArg2; + +public: + TYPEINFO(); + + TwoStringErrorInfo(ULONG nUserID, const String & rTheArg1, + const String & rTheArg2, USHORT nFlags = 0): + DynamicErrorInfo(nUserID, nFlags), aArg1(rTheArg1), aArg2(rTheArg2) {} + virtual ~TwoStringErrorInfo() {} + + String GetArg1() const { return aArg1; } + String GetArg2() const { return aArg2; } +}; + +// ------------------- +// - MessageInfo - +// ------------------- + +class TOOLS_DLLPUBLIC MessageInfo : public DynamicErrorInfo +{ + public: + + TYPEINFO(); + MessageInfo(ULONG UserId, USHORT nFlags = 0) : + DynamicErrorInfo(UserId, nFlags){} + MessageInfo(ULONG UserId, const String &rArg, + USHORT nFlags = 0 ) : + DynamicErrorInfo(UserId, nFlags), aArg(rArg) {} + const String& GetMessageArg() const { return aArg; } + + private: + + String aArg; +}; + + +// ---------------- +// - ErrorContext - +// ---------------- + +class TOOLS_DLLPUBLIC ErrorContext +{ + friend class ErrorHandler; + +private: + ErrorContext* pNext; + Window* pWin; + +public: + ErrorContext(Window *pWin=0); + virtual ~ErrorContext(); + + virtual BOOL GetString( ULONG nErrId, String& rCtxStr ) = 0; + Window* GetParent() { return pWin; } + + static ErrorContext* GetContext(); +}; + + +// ---------------- +// - ErrorHandler - +// ---------------- + +typedef USHORT WindowDisplayErrorFunc( + Window *, USHORT nMask, const String &rErr, const String &rAction); + +typedef void BasicDisplayErrorFunc( + const String &rErr, const String &rAction); + +class TOOLS_DLLPUBLIC ErrorHandler +{ + friend class ErrHdl_Impl; + +private: + ErrHdl_Impl* pImpl; + + static USHORT HandleError_Impl( ULONG lId, + USHORT nFlags, + BOOL bJustCreateString, + String & rError); +protected: + virtual BOOL CreateString( const ErrorInfo *, + String &, USHORT& nMask ) const = 0; + BOOL ForwCreateString( const ErrorInfo*, + String&, USHORT& nMask ) const; + +public: + ErrorHandler(); + virtual ~ErrorHandler(); + + static USHORT HandleError ( ULONG lId, USHORT nMask = USHRT_MAX ); + static BOOL GetErrorString( ULONG lId, String& rStr ); + + static void RegisterDisplay( BasicDisplayErrorFunc* ); + static void RegisterDisplay( WindowDisplayErrorFunc* ); +}; + + +// ---------------------- +// - SimpleErrorHandler - +// ---------------------- + +class TOOLS_DLLPUBLIC SimpleErrorHandler : private ErrorHandler +{ +protected: + virtual BOOL CreateString( const ErrorInfo*, String &, + USHORT &nMask ) const; + +public: + SimpleErrorHandler(); + +}; + +#endif +#endif diff --git a/tools/inc/tools/extendapplicationenvironment.hxx b/tools/inc/tools/extendapplicationenvironment.hxx new file mode 100644 index 000000000000..05eac33effba --- /dev/null +++ b/tools/inc/tools/extendapplicationenvironment.hxx @@ -0,0 +1,42 @@ +/************************************************************************* + * + * 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 INCLUDED_TOOLS_EXTENDAPPLICATIONENVIRONMENT_HXX +#define INCLUDED_TOOLS_EXTENDAPPLICATIONENVIRONMENT_HXX + +#include "sal/config.h" +#include "tools/toolsdllapi.h" + +namespace tools { + +// Extend the environment of the process in a platform specifc way as necessary +// for OOo-related applications; must be called first thing in main: +TOOLS_DLLPUBLIC void extendApplicationEnvironment(); + +} + +#endif diff --git a/tools/inc/tools/fldunit.hxx b/tools/inc/tools/fldunit.hxx new file mode 100644 index 000000000000..637539f6dd6f --- /dev/null +++ b/tools/inc/tools/fldunit.hxx @@ -0,0 +1,41 @@ +/************************************************************************* + * + * 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 _TOOLS_FLDUNIT_HXX +#define _TOOLS_FLDUNIT_HXX + +// -------------- +// - FieldTypes - +// -------------- + +// By changes you must also change: rsc/vclrsc.hxx +enum FieldUnit { FUNIT_NONE, FUNIT_MM, FUNIT_CM, FUNIT_M, FUNIT_KM, + FUNIT_TWIP, FUNIT_POINT, FUNIT_PICA, + FUNIT_INCH, FUNIT_FOOT, FUNIT_MILE, FUNIT_CUSTOM, + FUNIT_PERCENT, FUNIT_100TH_MM }; + +#endif // _TOOLS_FLDUNIT_HXX diff --git a/tools/inc/tools/fontenum.hxx b/tools/inc/tools/fontenum.hxx new file mode 100644 index 000000000000..0e0f1b2f7368 --- /dev/null +++ b/tools/inc/tools/fontenum.hxx @@ -0,0 +1,172 @@ +/************************************************************************* + * + * 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 _TOOLS_FONTENUM_HXX +#define _TOOLS_FONTENUM_HXX + +#include <sal/types.h> +#include <tools/solar.h> + +#ifndef ENUM_FONTFAMILY_DECLARED +#define ENUM_FONTFAMILY_DECLARED + +enum FontFamily { FAMILY_DONTKNOW, FAMILY_DECORATIVE, FAMILY_MODERN, + FAMILY_ROMAN, FAMILY_SCRIPT, FAMILY_SWISS, FAMILY_SYSTEM, FontFamily_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTPITCH_DECLARED +#define ENUM_FONTPITCH_DECLARED + +enum FontPitch { PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, FontPitch_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_TEXTALIGN_DECLARED +#define ENUM_TEXTALIGN_DECLARED + +enum TextAlign { ALIGN_TOP, ALIGN_BASELINE, ALIGN_BOTTOM, TextAlign_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTWEIGHT_DECLARED +#define ENUM_FONTWEIGHT_DECLARED + +enum FontWeight { WEIGHT_DONTKNOW, WEIGHT_THIN, WEIGHT_ULTRALIGHT, + WEIGHT_LIGHT, WEIGHT_SEMILIGHT, WEIGHT_NORMAL, + WEIGHT_MEDIUM, WEIGHT_SEMIBOLD, WEIGHT_BOLD, + WEIGHT_ULTRABOLD, WEIGHT_BLACK, FontWeight_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTWIDTH_DECLARED +#define ENUM_FONTWIDTH_DECLARED + +enum FontWidth { WIDTH_DONTKNOW, WIDTH_ULTRA_CONDENSED, WIDTH_EXTRA_CONDENSED, + WIDTH_CONDENSED, WIDTH_SEMI_CONDENSED, WIDTH_NORMAL, + WIDTH_SEMI_EXPANDED, WIDTH_EXPANDED, WIDTH_EXTRA_EXPANDED, + WIDTH_ULTRA_EXPANDED, + FontWidth_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTITALIC_DECLARED +#define ENUM_FONTITALIC_DECLARED + +enum FontItalic { ITALIC_NONE, ITALIC_OBLIQUE, ITALIC_NORMAL, ITALIC_DONTKNOW, FontItalic_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTUNDERLINE_DECLARED +#define ENUM_FONTUNDERLINE_DECLARED + +enum FontUnderline { UNDERLINE_NONE, UNDERLINE_SINGLE, UNDERLINE_DOUBLE, + UNDERLINE_DOTTED, UNDERLINE_DONTKNOW, + UNDERLINE_DASH, UNDERLINE_LONGDASH, + UNDERLINE_DASHDOT, UNDERLINE_DASHDOTDOT, + UNDERLINE_SMALLWAVE, + UNDERLINE_WAVE, UNDERLINE_DOUBLEWAVE, + UNDERLINE_BOLD, UNDERLINE_BOLDDOTTED, + UNDERLINE_BOLDDASH, UNDERLINE_BOLDLONGDASH, + UNDERLINE_BOLDDASHDOT, UNDERLINE_BOLDDASHDOTDOT, + UNDERLINE_BOLDWAVE, + FontUnderline_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTSTRIKEOUT_DECLARED +#define ENUM_FONTSTRIKEOUT_DECLARED + +enum FontStrikeout { STRIKEOUT_NONE, STRIKEOUT_SINGLE, STRIKEOUT_DOUBLE, + STRIKEOUT_DONTKNOW, STRIKEOUT_BOLD, + STRIKEOUT_SLASH, STRIKEOUT_X, + FontStrikeout_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTEMPHASISMARK_DECLARED +#define ENUM_FONTEMPHASISMARK_DECLARED + +typedef USHORT FontEmphasisMark; +#define EMPHASISMARK_NONE ((FontEmphasisMark)0x0000) +#define EMPHASISMARK_DOT ((FontEmphasisMark)0x0001) +#define EMPHASISMARK_CIRCLE ((FontEmphasisMark)0x0002) +#define EMPHASISMARK_DISC ((FontEmphasisMark)0x0003) +#define EMPHASISMARK_ACCENT ((FontEmphasisMark)0x0004) +#define EMPHASISMARK_STYLE ((FontEmphasisMark)0x00FF) +#define EMPHASISMARK_POS_ABOVE ((FontEmphasisMark)0x1000) +#define EMPHASISMARK_POS_BELOW ((FontEmphasisMark)0x2000) + +// Only for kompability +#define EMPHASISMARK_DOTS_ABOVE (EMPHASISMARK_DOT | EMPHASISMARK_POS_ABOVE) +#define EMPHASISMARK_DOTS_BELOW (EMPHASISMARK_DOT | EMPHASISMARK_POS_BELOW) +#define EMPHASISMARK_SIDE_DOTS (EMPHASISMARK_ACCENT | EMPHASISMARK_POS_ABOVE) +#define EMPHASISMARK_CIRCLE_ABOVE (EMPHASISMARK_CIRCLE | EMPHASISMARK_POS_ABOVE) + +#endif + +// ------------------------------------------------------------ + +#ifndef ENUM_FONTTYPE_DECLARED +#define ENUM_FONTTYPE_DECLARED + +enum FontType { TYPE_DONTKNOW, TYPE_RASTER, TYPE_VECTOR, TYPE_SCALABLE, + FontType_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +#endif + +#ifndef ENUM_FONTEMBEDDEDBITMAP_DECLARED +#define ENUM_FONTEMBEDDEDBITMAP_DECLARED + +enum FontEmbeddedBitmap { EMBEDDEDBITMAP_DONTKNOW, EMBEDDEDBITMAP_FALSE, EMBEDDEDBITMAP_TRUE }; + +#endif + +#ifndef ENUM_FONTANTIALIAS_DECLARED +#define ENUM_FONTANTIALIAS_DECLARED + +enum FontAntiAlias { ANTIALIAS_DONTKNOW, ANTIALIAS_FALSE, ANTIALIAS_TRUE }; + +#endif + +#endif // _TOOLS_FONTENUM_HXX diff --git a/tools/inc/tools/fract.hxx b/tools/inc/tools/fract.hxx new file mode 100644 index 000000000000..7769e88ab541 --- /dev/null +++ b/tools/inc/tools/fract.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * 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 _FRACT_HXX +#define _FRACT_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +class SvStream; +// ------------ +// - Fraction - +// ------------ + +class TOOLS_DLLPUBLIC Fraction +{ +private: + long nNumerator; + long nDenominator; + +public: + Fraction() { nNumerator = 0; nDenominator = 1; } + Fraction( const Fraction & rFrac ); + Fraction( long nNum, long nDen=1 ); + Fraction( long nN1, long nN2, long nD1, long nD2 ); + Fraction( double dVal ); + + BOOL IsValid() const; + + long GetNumerator() const { return nNumerator; } + long GetDenominator() const { return nDenominator; } + + operator long() const; + operator double() const; + + Fraction& operator=( const Fraction& rfrFrac ); + + Fraction& operator+=( const Fraction& rfrFrac ); + Fraction& operator-=( const Fraction& rfrFrac ); + Fraction& operator*=( const Fraction& rfrFrac ); + Fraction& operator/=( const Fraction& rfrFrac ); + + void ReduceInaccurate( unsigned nSignificantBits ); +#ifdef __BORLANDC__ + friend Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 ); + friend Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 ); + friend Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 ); + friend Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 ); + + friend BOOL operator==( const Fraction& rVal1, const Fraction& rVal2 ); + friend BOOL operator!=( const Fraction& rVal1, const Fraction& rVal2 ); + friend BOOL operator< ( const Fraction& rVal1, const Fraction& rVal2 ); + friend BOOL operator> ( const Fraction& rVal1, const Fraction& rVal2 ); + friend BOOL operator<=( const Fraction& rVal1, const Fraction& rVal2 ); + friend BOOL operator>=( const Fraction& rVal1, const Fraction& rVal2 ); +#else + friend inline Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 ); + + TOOLS_DLLPUBLIC friend BOOL operator==( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline BOOL operator!=( const Fraction& rVal1, const Fraction& rVal2 ); + TOOLS_DLLPUBLIC friend BOOL operator< ( const Fraction& rVal1, const Fraction& rVal2 ); + TOOLS_DLLPUBLIC friend BOOL operator> ( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline BOOL operator<=( const Fraction& rVal1, const Fraction& rVal2 ); + friend inline BOOL operator>=( const Fraction& rVal1, const Fraction& rVal2 ); +#endif + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Fraction& rFract ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Fraction& rFract ); +}; + +inline Fraction::Fraction( const Fraction& rFrac ) +{ + nNumerator = rFrac.nNumerator; + nDenominator = rFrac.nDenominator; +} + +inline Fraction& Fraction::operator=( const Fraction& rFrac ) +{ + nNumerator = rFrac.nNumerator; + nDenominator = rFrac.nDenominator; + return *this; +} + +inline BOOL Fraction::IsValid() const +{ + return (nDenominator > 0); +} + +inline Fraction::operator long() const +{ + if ( nDenominator > 0 ) + return (nNumerator / nDenominator); + else + return 0; +} + +inline Fraction operator+( const Fraction& rVal1, const Fraction& rVal2 ) +{ + Fraction aErg( rVal1 ); + aErg += rVal2; + return aErg; +} + +inline Fraction operator-( const Fraction& rVal1, const Fraction& rVal2 ) +{ + Fraction aErg( rVal1 ); + aErg -= rVal2; + return aErg; +} + +inline Fraction operator*( const Fraction& rVal1, const Fraction& rVal2 ) +{ + Fraction aErg( rVal1 ); + aErg *= rVal2; + return aErg; +} + +inline Fraction operator/( const Fraction& rVal1, const Fraction& rVal2 ) +{ + Fraction aErg( rVal1 ); + aErg /= rVal2; + return aErg; +} + +inline BOOL operator !=( const Fraction& rVal1, const Fraction& rVal2 ) +{ + return !(rVal1 == rVal2); +} + +inline BOOL operator <=( const Fraction& rVal1, const Fraction& rVal2 ) +{ + return !(rVal1 > rVal2); +} + +inline BOOL operator >=( const Fraction& rVal1, const Fraction& rVal2 ) +{ + return !(rVal1 < rVal2); +} + +#endif // _FRACT_HXX diff --git a/tools/inc/tools/fsys.hxx b/tools/inc/tools/fsys.hxx new file mode 100644 index 000000000000..5ef51803734b --- /dev/null +++ b/tools/inc/tools/fsys.hxx @@ -0,0 +1,564 @@ +/************************************************************************* + * + * 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 _FSYS_HXX +#define _FSYS_HXX + +#include <tools/solar.h> +#include <tools/datetime.hxx> +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <tools/wldcrd.hxx> +#ifndef __ERRCODE_HXX +#include <tools/errcode.hxx> +#endif +#include "tools/toolsdllapi.h" + +#include <cstdarg> + +#define FEAT_FSYS_DOUBLESPEED + +// -------------- +// - FSys-Types - +// -------------- + +class DirEntry; +class DirEntryList; +class FSysSortList; +class FileStatList; +struct FileCopier_Impl; +class SvFileStream; +class BigInt; + +#define FSYS_BUFSIZE 1024 +#define FSYS_SHORTNAME_DELIMITER '@' + +// FSysAccess +typedef int FSysAccess; +#define FSYS_ACCESS_FORCED 1 +#define FSYS_ACCESS_FLOPPY FSYS_ACCESS_FORCED +#define FSYS_ACCESS_CACHED 2 + +// DirEntryKind +typedef int DirEntryKind; +#define FSYS_KIND_NONE ((DirEntryKind) 0) +#define FSYS_KIND_UNKNOWN FSYS_KIND_NONE +#define FSYS_KIND_FILE ((DirEntryKind) 1) +#define FSYS_KIND_DIR ((DirEntryKind) 2) +#define FSYS_KIND_DEV ((DirEntryKind) 4) +#define FSYS_KIND_BLOCK ((DirEntryKind) 8) +#define FSYS_KIND_CHAR ((DirEntryKind) 16) +#define FSYS_KIND_WILD ((DirEntryKind) 32) +#define FSYS_KIND_BLOCK_REMOTE ((DirEntryKind) 64) //TPF: fuer RFS +#define FSYS_KIND_REMOVEABLE ((DirEntryKind) 128) +#define FSYS_KIND_FIXED ((DirEntryKind) 256) +#define FSYS_KIND_REMOTE ((DirEntryKind) 512) +#define FSYS_KIND_RAM ((DirEntryKind) 1024) +#define FSYS_KIND_CDROM ((DirEntryKind) 2048) +#define FSYS_KIND_ALL ((DirEntryKind) 4095) +#define FSYS_KIND_VISIBLE ((DirEntryKind) 4096) + +// FSysSort +typedef int FSysSort; +#define FSYS_SORT_NONE ((FSysSort) 0) +#define FSYS_SORT_SIZE ((FSysSort) 1) +#define FSYS_SORT_CREATED ((FSysSort) 2) +#define FSYS_SORT_MODIFYED ((FSysSort) 4) +#define FSYS_SORT_ACCESSED ((FSysSort) 8) +#define FSYS_SORT_ASCENDING ((FSysSort) 16) +#define FSYS_SORT_DESCENDING ((FSysSort) 32) +#define FSYS_SORT_EXT ((FSysSort) 64) +#define FSYS_SORT_NAME ((FSysSort) 128) +#define FSYS_SORT_KIND ((FSysSort) 256) +#define FSYS_SORT_CREATOR ((FSysSort) 512) +#define FSYS_SORT_END ((FSysSort)1024) + +// DirEntryFlag +enum DirEntryFlag +{ + FSYS_FLAG_NORMAL, + FSYS_FLAG_VOLUME, // Dir( FSYS_FLAG_VOLUME ) und GetDevice() + FSYS_FLAG_ABSROOT, // z.B. "a:\" oder "\" + FSYS_FLAG_RELROOT, // z.B. "a:", "a:." oder "." + FSYS_FLAG_CURRENT = FSYS_FLAG_RELROOT, // Synonym fuer FSYS_FLAG_RELROOT + FSYS_FLAG_PARENT, // z.B. ".." + FSYS_FLAG_INVALID +}; + +// FSysPathStyle +enum FSysPathStyle +{ + FSYS_STYLE_HOST, + FSYS_STYLE_FAT, + FSYS_STYLE_MSDOS = FSYS_STYLE_FAT, + FSYS_STYLE_VFAT, + FSYS_STYLE_WIN95 = FSYS_STYLE_VFAT, + FSYS_STYLE_HPFS, + FSYS_STYLE_OS2 = FSYS_STYLE_HPFS, + FSYS_STYLE_NTFS, + FSYS_STYLE_NWFS, + FSYS_STYLE_SYSV, + FSYS_STYLE_BSD, + FSYS_STYLE_UNX = FSYS_STYLE_BSD, + FSYS_STYLE_MAC, + FSYS_STYLE_DETECT, + FSYS_STYLE_UNKNOWN, + FSYS_STYLE_URL +}; + +// FSysAction +typedef int FSysAction; +#define FSYS_ACTION_COPYFILE 0x01 // not only create hardlink +#define FSYS_ACTION_RECURSIVE 0x02 // deep through dircetory structure +#define FSYS_ACTION_USERECYCLEBIN 0x04 // move to recycle bin +#define FSYS_ACTION_MOVE 0x08 // delete after copy (=> move) +#define FSYS_ACTION_CONTINUE 0x10 // continue on error +#define FSYS_ACTION_KEEP_EXISTING 0x20 // do not overwrite objects in + // target folder in case of name + // clashes +#define FSYS_ACTION_STANDARD 0 + +// Fuer RFS +#define RFS_IDENTIFIER "-rfs-" +#define RFS_LOWER "-rfs-" +#define RFS_UPPER "-RFS-" + +typedef ULONG FSysError; + +// FSysExact +enum FSysExact +{ + FSYS_NOTEXACT, + FSYS_EXACT +}; + +// ------------ +// - Char-Set - +// ------------ + +// Was different for WIN, no longer needed... +#define GUI2FSYS(s) s +#define FSYS2GUI(s) s + + +// ------------ +// - FileStat - +// ------------ + +struct dirent; +class TOOLS_DLLPUBLIC FileStat +{ + friend class CORmFSys; + friend class Dir; + friend struct DirReader_Impl; + friend void ImpInitFileStat( FileStat&, dirent* ); + + ULONG nError; + DirEntryKind nKindFlags; + ULONG nSize; + String aCreator; + String aType; + Date aDateCreated; + Time aTimeCreated; + Date aDateModified; + Time aTimeModified; + Date aDateAccessed; + Time aTimeAccessed; +private: + TOOLS_DLLPRIVATE void ImpInit( void* ); + +protected: + // Implementation + FileStat( const void *pInfo, // CInfoPBRec + const void *pVolInfo ); // ParamBlockRec + +public: + FileStat(); + FileStat( const DirEntry& rDirEntry, + FSysAccess nAccess = FSYS_ACCESS_FLOPPY ); + BOOL Update( const DirEntry& rDirEntry, + BOOL bForceAccess = TRUE ); + + ULONG GetError() const { return ERRCODE_TOERROR(nError); } + ULONG GetErrorCode() const { return nError; } + + ULONG GetSize() const { return nSize; } + + DirEntryKind GetKind() const { return nKindFlags; } + BOOL IsKind( DirEntryKind nKind ) const; + + String GetType() const { return aType; } + String GetCreator() const { return aCreator; } + + Date DateCreated() const { return aDateCreated; } + Time TimeCreated() const { return aTimeCreated; } + Date DateModified() const { return aDateModified; } + Time TimeModified() const { return aTimeModified; } + Date DateAccessed() const { return aDateAccessed; } + Time TimeAccessed() const { return aTimeAccessed; } + BOOL IsYounger( const FileStat& rIsOlder ) const; + +#define TF_FSYS_READONLY_FLAG + static ULONG SetReadOnlyFlag( const DirEntry &rEntry, BOOL bRO = TRUE ); + static BOOL GetReadOnlyFlag( const DirEntry &rEntry ); + static BOOL HasReadOnlyFlag(); + + static ErrCode QueryDiskSpace( const String &rPath, + BigInt &rFreeBytes, BigInt &rTotalBytes ); + + static void SetDateTime( const String& rFileName, + const DateTime& rNewDateTime ); +}; + +// ------------ +// - DirEntry - +// ------------ + +class DirEntryStack; + +const char* ImpCheckDirEntry( const void* p ); + +class TOOLS_DLLPUBLIC DirEntry +{ +friend struct DirReader_Impl; +friend class FileCopier; + +#ifdef FEAT_FSYS_DOUBLESPEED + FileStat* pStat; // optional +#endif + ByteString aName; + DirEntry* pParent; + ULONG nError; + DirEntryFlag eFlag; + +private: + TOOLS_DLLPRIVATE DirEntry( const ByteString& rInitName, + DirEntryFlag aDirFlag, + FSysPathStyle eStyle ); + +//#if 0 // _SOLAR__PRIVATE + + friend class Dir; + friend class FileStat; + friend const char* ImpCheckDirEntry( const void* p ); + + TOOLS_DLLPRIVATE FSysError ImpParseName( const ByteString& rIntiName, + FSysPathStyle eParser ); + TOOLS_DLLPRIVATE FSysError ImpParseOs2Name( const ByteString& rPfad, + FSysPathStyle eStyle ); + TOOLS_DLLPRIVATE FSysError ImpParseUnixName( const ByteString& rPfad, + FSysPathStyle eStyle ); + TOOLS_DLLPRIVATE USHORT ImpTryUrl( DirEntryStack& rStack, const String& rPfad, FSysPathStyle eStyle ); + TOOLS_DLLPRIVATE const DirEntry* ImpGetTopPtr() const; + TOOLS_DLLPRIVATE DirEntry* ImpGetTopPtr(); + TOOLS_DLLPRIVATE DirEntry* ImpGetPreTopPtr(); + TOOLS_DLLPRIVATE BOOL ImpToRel( String aStart ); + +protected: + void ImpTrim( FSysPathStyle eStyle ); + const ByteString& ImpTheName() const; + DirEntryFlag ImpTheFlag() const { return eFlag; }; + DirEntry* ImpChangeParent( DirEntry* pNewParent, BOOL bNormalize = TRUE ); + DirEntry* ImpGetParent() { return pParent; } +#ifdef FEAT_FSYS_DOUBLESPEED + FileStat* ImpGetStat() const { return pStat; } + void ImpSetStat( FileStat *p ) { pStat = p; } +#endif + +//#endif + +protected: + void SetError( ULONG nErr ) { nError = nErr; } + DirEntry* GetParent() { return pParent; } +public: + DirEntry( DirEntryFlag aDirFlag = FSYS_FLAG_CURRENT ); + DirEntry( const DirEntry& rEntry ); + DirEntry( const ByteString& rInitName, + FSysPathStyle eParser = FSYS_STYLE_HOST ); + DirEntry( const String& rInitName, + FSysPathStyle eParser = FSYS_STYLE_HOST ); + ~DirEntry(); + + BOOL IsLongNameOnFAT() const; + BOOL IsCaseSensitive (FSysPathStyle eFormatter = FSYS_STYLE_HOST) const; + + ULONG GetError() const { return nError; } + BOOL IsValid() const; + DirEntryFlag GetFlag() const { return eFlag; }; + + void SetExtension( const String& rExt, char cSep = '.' ); + String GetExtension( char cSep = '.' ) const; + String CutExtension( char cSep = '.' ); + void SetName( const String& rName, FSysPathStyle eFormatter = FSYS_STYLE_HOST ); + inline const String GetNameDirect() const { return String(aName, osl_getThreadTextEncoding()); } + String GetName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ) const; + String CutName( FSysPathStyle eFormatter = FSYS_STYLE_HOST ); + void SetBase( const String& rBase, char cSep = '.' ); + String GetBase(char cSep = '.' ) const; + DirEntry GetPath() const; + DirEntry GetDevice() const; + String GetVolume() const; + String GetFull( FSysPathStyle eFormatter = FSYS_STYLE_HOST, + BOOL bWithDelimiter = FALSE, + USHORT nMaxChars = STRING_MAXLEN ) const; + + DirEntry TempName( DirEntryKind = FSYS_KIND_NONE ) const; + static const DirEntry& SetTempNameBase( const String &rBaseName ); + BOOL MakeShortName( const String& rLongName, + DirEntryKind eCreateKind = FSYS_KIND_NONE, + BOOL bUseTilde = TRUE, + FSysPathStyle eStyle = FSYS_STYLE_DETECT ); + + bool IsAbs() const; + BOOL ToAbs(); + BOOL Find( const String& rPfad, char cDelim = 0 ); + BOOL ToRel(); + BOOL ToRel( const DirEntry& rRefDir ); + USHORT CutRelParents(); + + BOOL SetCWD( BOOL bSloppy = FALSE ) const; + BOOL MakeDir( BOOL bSloppy = FALSE ) const; + BOOL Exists( FSysAccess nAccess = FSYS_ACCESS_FLOPPY ) const; + BOOL First(); + + USHORT Level() const; + const DirEntry& operator []( USHORT nParentLevel ) const; + BOOL Contains( const DirEntry &rSubEntry ) const; + + FSysError CopyTo( const DirEntry& rDestDir, + FSysAction nActions = FSYS_ACTION_STANDARD ) const; + FSysError MoveTo( const DirEntry& rDestDir ) const; + FSysError Kill( FSysAction nActions = FSYS_ACTION_STANDARD ) const; + + DirEntry& operator =( const DirEntry& rOrigDir ); + DirEntry operator +( const DirEntry& rSubDir ) const; + DirEntry& operator +=( const DirEntry& rSubDir ); + BOOL operator ==( const DirEntry& rAnotherDir ) const; + BOOL operator !=( const DirEntry& rAnotherDir ) const + { return !(DirEntry::operator==( rAnotherDir )); } + + StringCompare NameCompare( const DirEntry &rWith ) const; + inline StringCompare NameCompareDirect( const DirEntry &rWith ) const + { +#ifdef UNX + return rWith.aName.CompareTo( aName ); +#else + return rWith.aName.CompareIgnoreCaseToAscii( aName ); +#endif + } + + static String GetAccessDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST ); + static String GetSearchDelimiter( FSysPathStyle eFormatter = FSYS_STYLE_HOST ); + static USHORT GetMaxNameLen( FSysPathStyle eFormatter = FSYS_STYLE_HOST ); + static FSysPathStyle GetPathStyle( const String &rDevice ); + static String ConvertNameToSystem( const String & rName ); + static String ConvertSystemToName( const String & rName ); + static BOOL IsRFSAvailable(); +}; + +// -------------- +// - FileCopier - +// -------------- + +class TOOLS_DLLPUBLIC FileCopier +{ + DirEntry aSource; + DirEntry aTarget; + ULONG nBytesTotal; + ULONG nBytesCopied; + Link aProgressLink; + USHORT nBlockSize; + FileCopier_Impl* pImp; + +private: + TOOLS_DLLPRIVATE FSysError DoCopy_Impl( + const DirEntry &rSource, const DirEntry &rTarget ); + +protected: + virtual BOOL Progress(); + virtual ErrCode Error( ErrCode eErr, + const DirEntry *pSource, const DirEntry *pTarget ); + +public: + FileCopier(); + FileCopier( const DirEntry &rSource, + const DirEntry &rTarget ); + FileCopier( const FileCopier &rCopier ); + virtual ~FileCopier(); + + FileCopier& operator = ( const FileCopier &rCopier ); + + void SetBlockSize( USHORT nBytes ) { nBlockSize = nBytes; } + USHORT GetBlockSize() const { return nBlockSize; } + + ULONG GetBytesTotal() const { return nBytesTotal; } + ULONG GetBytesCopied() const { return nBytesCopied; } + + void SetSource( const DirEntry &rSource ) { aSource = rSource; } + void SetTarget( const DirEntry &rTarget ) { aTarget = rTarget; } + const DirEntry& GetSource() const { return aSource; } + const DirEntry& GetTarget() const { return aTarget; } + + FSysError Execute( FSysAction nActions = FSYS_ACTION_STANDARD ); + FSysError ExecuteExact( FSysAction nActions = FSYS_ACTION_STANDARD, + FSysExact eExact = FSYS_NOTEXACT); + + const DirEntry* GetErrorSource() const; + const DirEntry* GetErrorTarget() const; + ErrCode GetError() const; + + void SetProgressHdl( const Link& rLink ) { aProgressLink = rLink; } + const Link& GetProgressHdl() const { return aProgressLink; } + void SetErrorHdl( const Link& rLink ); + const Link& GetErrorHdl() const; +}; + +// ------- +// - Dir - +// ------- + +struct DirReader_Impl; +class TOOLS_DLLPUBLIC Dir : public DirEntry +{ +friend struct DirReader_Impl; +friend class CORmFSys; + + DirReader_Impl* pReader; // systemabhaengig + DirEntryList* pLst; + FSysSortList* pSortLst; // NULL, wenn kein Sort gefordert + FileStatList* pStatLst; // NULL, wenn keine Stat's benoetigt + WildCard aNameMask; + DirEntryKind eAttrMask; + +private: + TOOLS_DLLPRIVATE Dir( const Dir& ); // not allowed + TOOLS_DLLPRIVATE Dir& operator=( const Dir& ); // not allowed + +#ifdef _DIR_CXX + TOOLS_DLLPRIVATE FSysError ImpSetSort( std::va_list pArgs, FSysSort nSort ); + TOOLS_DLLPRIVATE void Construct( DirEntryKind nKind = FSYS_KIND_DIR|FSYS_KIND_FILE ); +#endif + +#ifndef _TOOLS_HXX +protected: + BOOL ImpInsertPointReached( const DirEntry& rIsSmaller, + const FileStat& rNewStat, + ULONG nCurPos, + ULONG nSortIndex ) const; + void ImpSortedInsert( const DirEntry *pNewEntry, + const FileStat *pNewStat ); +#endif + +public: + Dir(); + Dir( const DirEntry& rDirEntry, + DirEntryKind nKind = FSYS_KIND_ALL ); + Dir( const DirEntry& rDirEntry, + DirEntryKind nKind, + FSysSort nSort, ... ); + ~Dir(); + + const WildCard& GetNameMask() const { return aNameMask; } + + FSysError SetSort( FSysSort nSort, ... ); + + void Reset(); + USHORT Scan( USHORT nCount = 5 ); + USHORT Count( BOOL bUpdated = TRUE ) const; + BOOL Update(); + + Dir& operator +=( const Dir& rDir ); + DirEntry& operator []( USHORT nIndex ) const; +}; + +// we don't need this stuff for bootstraping +#ifndef BOOTSTRAP + +//======================================================================== + +/** FSysRedirector is an abstract base class for a hook to redirect + mirrored directory trees. + + <P>One instance of a subclass can be instanciated and registered + using the method FSysRedirector::Register(FSysRedirector*). + */ + +class FSysRedirector +{ + static FSysRedirector* _pRedirector; + static BOOL _bEnabled; + +public: + /** This method must called with the one and only instance of the + subclass which implements the redirection. + + <P>It must be called with 0 when the instance is destroyed. + */ + static void Register( FSysRedirector *pRedirector ); + + //----------------------------------------------------------------------- + /** This method returns the currently registererd instance of + a subclass which implements the redirection. + + <P>If no redirector is registered, it returns 0. + */ + static FSysRedirector* Redirector(); + + //----------------------------------------------------------------------- + /** This method is to be used to redirect a file system path. + + <P>It will not redirect while redirection is disabled. + + <P>It may block while another thread is accessing the redirector + or another thread has disabled redirections. + + @param String &rPath<BR> + This inout-argument accepts a file:-URL even as a native + file system path name to redirect in 'rPath'. It returns the + redirected (modified) path too, which can be of both formats + too. + + @return BOOL<BR> + TRUE, if the path is redirected + FALSE, if the path is not redirected (unchanged) + */ + static void DoRedirect( String &rPath ); +}; + +#endif // BOOTSTRP + +//======================================================================== + +void FSysEnableSysErrorBox( BOOL bEnable ); + +//======================================================================== + +#if defined(DBG_UTIL) +void FSysTest(); +#endif + +#endif // #ifndef _FSYS_HXX + diff --git a/tools/inc/tools/gen.hxx b/tools/inc/tools/gen.hxx new file mode 100644 index 000000000000..308cc02165ce --- /dev/null +++ b/tools/inc/tools/gen.hxx @@ -0,0 +1,712 @@ +/************************************************************************* + * + * 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 _SV_GEN_HXX +#define _SV_GEN_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +#include <limits.h> + +class SvStream; + +// -------------------- +// - Helper functions - +// -------------------- + +inline long MinMax( long nVal, long nMin, long nMax ); +inline long AlignedWidth4Bytes( long nWidthBits ); +inline long FRound( double fVal ); + +// --------------- +// - Inlines - +// --------------- + +inline long MinMax( long nVal, long nMin, long nMax ) +{ + return( nVal >= nMin ? ( nVal <= nMax ? nVal : nMax ) : nMin ); +} + +// ------------------------------------------------------------------ + +inline long AlignedWidth4Bytes( long nWidthBits ) +{ + return( ( ( nWidthBits + 31 ) >> 5 ) << 2 ); +} + +// ------------------------------------------------------------------ + +inline long FRound( double fVal ) +{ + return( fVal > 0.0 ? (long) ( fVal + 0.5 ) : -(long) ( -fVal + 0.5 ) ); +} + +// -------- +// - Pair - +// -------- + +class Pair +{ +public: + long nA; + long nB; + + Pair(); + Pair( long nA, long nB ); + + long A() const { return nA; } + long B() const { return nB; } + + long& A() { return nA; } + long& B() { return nB; } + + BOOL operator == ( const Pair& rPair ) const; + BOOL operator != ( const Pair& rPair ) const; + + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Pair& rPair ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Pair& rPair ); +}; + +inline Pair::Pair() +{ + nA = nB = 0; +} + +inline Pair::Pair( long _nA, long _nB ) +{ + Pair::nA = _nA; + Pair::nB = _nB; +} + +inline BOOL Pair::operator == ( const Pair& rPair ) const +{ + return ((nA == rPair.nA) && (nB == rPair.nB)); +} + +inline BOOL Pair::operator != ( const Pair& rPair ) const +{ + return ((nA != rPair.nA) || (nB != rPair.nB)); +} + +// --------- +// - Point - +// --------- + +class Point : public Pair +{ +public: + Point(); + Point( long nX, long nY ); + + long X() const { return nA; } + long Y() const { return nB; } + + long& X() { return nA; } + long& Y() { return nB; } + + void Move( long nHorzMove, long nVertMove ); + BOOL IsAbove( const Point& rPoint ) const; + BOOL IsBelow( const Point& rPoint ) const; + BOOL IsLeft( const Point& rPoint ) const; + BOOL IsRight( const Point& rPoint ) const; + + Point& operator += ( const Point& rPoint ); + Point& operator -= ( const Point& rPoint ); + Point& operator *= ( const long nVal ); + Point& operator /= ( const long nVal ); + +#ifdef __BORLANDC__ + friend Point operator+( const Point &rVal1, const Point &rVal2 ); + friend Point operator-( const Point &rVal1, const Point &rVal2 ); + friend Point operator*( const Point &rVal1, const long nVal2 ); + friend Point operator/( const Point &rVal1, const long nVal2 ); +#else + friend inline Point operator+( const Point &rVal1, const Point &rVal2 ); + friend inline Point operator-( const Point &rVal1, const Point &rVal2 ); + friend inline Point operator*( const Point &rVal1, const long nVal2 ); + friend inline Point operator/( const Point &rVal1, const long nVal2 ); +#endif + + long getX() const { return X(); } + long getY() const { return Y(); } + void setX(long nX) { X() = nX; } + void setY(long nY) { Y() = nY; } +}; + +inline Point::Point() +{ +} + +inline Point::Point( long nX, long nY ) : Pair( nX, nY ) +{ +} + +inline void Point::Move( long nHorzMove, long nVertMove ) +{ + nA += nHorzMove; + nB += nVertMove; +} + +inline BOOL Point::IsAbove( const Point& rPoint ) const +{ + return (nB > rPoint.nB); +} + +inline BOOL Point::IsBelow( const Point& rPoint ) const +{ + return (nB < rPoint.nB); +} + +inline BOOL Point::IsLeft( const Point& rPoint ) const +{ + return (nA < rPoint.nA); +} + +inline BOOL Point::IsRight( const Point& rPoint ) const +{ + return (nA > rPoint.nA); +} + +inline Point& Point::operator += ( const Point& rPoint ) +{ + nA += rPoint.nA; + nB += rPoint.nB; + return *this; +} + +inline Point& Point::operator -= ( const Point& rPoint ) +{ + nA -= rPoint.nA; + nB -= rPoint.nB; + return *this; +} + +inline Point& Point::operator *= ( const long nVal ) +{ + nA *= nVal; + nB *= nVal; + return *this; +} + +inline Point& Point::operator /= ( const long nVal ) +{ + nA /= nVal; + nB /= nVal; + return *this; +} + +inline Point operator+( const Point &rVal1, const Point &rVal2 ) +{ + return Point( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB ); +} + +inline Point operator-( const Point &rVal1, const Point &rVal2 ) +{ + return Point( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB ); +} + +inline Point operator*( const Point &rVal1, const long nVal2 ) +{ + return Point( rVal1.nA*nVal2, rVal1.nB*nVal2 ); +} + +inline Point operator/( const Point &rVal1, const long nVal2 ) +{ + return Point( rVal1.nA/nVal2, rVal1.nB/nVal2 ); +} + +// -------- +// - Size - +// -------- + +class Size : public Pair +{ +public: + Size(); + Size( long nWidth, long nHeight ); + + long Width() const { return nA; } + long Height() const { return nB; } + + long& Width() { return nA; } + long& Height() { return nB; } + + long getWidth() const { return Width(); } + long getHeight() const { return Height(); } + void setWidth(long nWidth) { Width() = nWidth; } + void setHeight(long nHeight) { Height() = nHeight; } +}; + +inline Size::Size() +{ +} + +inline Size::Size( long nWidth, long nHeight ) : + Pair( nWidth, nHeight ) +{ +} + +// --------- +// - Range - +// --------- + +#define RANGE_MIN LONG_MIN +#define RANGE_MAX LONG_MAX + +class Range : public Pair +{ +public: + Range(); + Range( long nMin, long nMax ); + + long Min() const { return nA; } + long Max() const { return nB; } + long Len() const { return nB - nA + 1; } + + long& Min() { return nA; } + long& Max() { return nB; } + + BOOL IsInside( long nIs ) const; + + void Justify(); +}; + +inline Range::Range() +{ +} + +inline Range::Range( long nMin, long nMax ) : Pair( nMin, nMax ) +{ +} + +inline BOOL Range::IsInside( long nIs ) const +{ + return ((nA <= nIs) && (nIs <= nB )); +} + +inline void Range::Justify() +{ + if ( nA > nB ) + { + long nHelp = nA; + nA = nB; + nB = nHelp; + } +} + +// ------------- +// - Selection - +// ------------- + +#define SELECTION_MIN LONG_MIN +#define SELECTION_MAX LONG_MAX + +class Selection : public Pair +{ +public: + Selection(); + Selection( long nPos ); + Selection( long nMin, long nMax ); + + long Min() const { return nA; } + long Max() const { return nB; } + long Len() const { return nB - nA; } + + long& Min() { return nA; } + long& Max() { return nB; } + + BOOL IsInside( long nIs ) const; + + void Justify(); + + BOOL operator !() const { return !Len(); } + + long getMin() const { return Min(); } + long getMax() const { return Max(); } + void setMin(long nMin) { Min() = nMin; } + void setMax(long nMax) { Max() = nMax; } +}; + +inline Selection::Selection() +{ +} + +inline Selection::Selection( long nPos ) : Pair( nPos, nPos ) +{ +} + +inline Selection::Selection( long nMin, long nMax ) : + Pair( nMin, nMax ) +{ +} + +inline BOOL Selection::IsInside( long nIs ) const +{ + return ((nA <= nIs) && (nIs < nB )); +} + +inline void Selection::Justify() +{ + if ( nA > nB ) + { + long nHelp = nA; + nA = nB; + nB = nHelp; + } +} + +// ------------- +// - Rectangle - +// ------------- + +#define RECT_EMPTY ((short)-32767) + +class TOOLS_DLLPUBLIC Rectangle +{ +public: + long nLeft; + long nTop; + long nRight; + long nBottom; + + Rectangle(); + Rectangle( const Point& rLT, const Point& rRB ); + Rectangle( long nLeft, long nTop, + long nRight, long nBottom ); + Rectangle( const Point& rLT, const Size& rSize ); + + long Left() const { return nLeft; } + long Right() const { return nRight; } + long Top() const { return nTop; } + long Bottom() const { return nBottom; } + + long& Left() { return nLeft; } + long& Right() { return nRight; } + long& Top() { return nTop; } + long& Bottom() { return nBottom; } + + inline Point TopLeft() const; + Point TopRight() const; + Point TopCenter() const; + Point BottomLeft() const; + Point BottomRight() const; + Point BottomCenter() const; + Point LeftCenter() const; + Point RightCenter() const; + Point Center() const; + + void Move( long nHorzMove, long nVertMove ); + inline void Transpose(); + inline void SetPos( const Point& rPoint ); + void SetSize( const Size& rSize ); + inline Size GetSize() const; + + long GetWidth() const; + long GetHeight() const; + + Rectangle& Union( const Rectangle& rRect ); + Rectangle& Intersection( const Rectangle& rRect ); + Rectangle GetUnion( const Rectangle& rRect ) const; + Rectangle GetIntersection( const Rectangle& rRect ) const; + + void Justify(); + + BOOL IsInside( const Point& rPOINT ) const; + BOOL IsInside( const Rectangle& rRect ) const; + BOOL IsOver( const Rectangle& rRect ) const; + + void SetEmpty() { nRight = nBottom = RECT_EMPTY; } + BOOL IsEmpty() const; + + BOOL operator == ( const Rectangle& rRect ) const; + BOOL operator != ( const Rectangle& rRect ) const; + + Rectangle& operator += ( const Point& rPt ); + Rectangle& operator -= ( const Point& rPt ); + +#ifdef __BORLANDC__ + friend Rectangle operator + ( const Rectangle& rRect, const Point& rPt ); + friend Rectangle operator - ( const Rectangle& rRect, const Point& rPt ); +#else + friend inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt ); + friend inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt ); +#endif + + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Rectangle& rRect ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Rectangle& rRect ); + + // ONE + long getX() const { return nLeft; } + long getY() const { return nTop; } + long getWidth() const { return nRight - nLeft; } + long getHeight() const { return nBottom - nTop; } + void setX( long n ) { nRight += n-nLeft; nLeft = n; } + void setY( long n ) { nBottom += n-nTop; nTop = n; } + void setWidth( long n ) { nRight = nLeft + n; } + void setHeight( long n ) { nBottom = nTop + n; } +}; + +inline Rectangle::Rectangle() +{ + nLeft = nTop = 0; + nRight = nBottom = RECT_EMPTY; +} + +inline Rectangle::Rectangle( const Point& rLT, const Point& rRB ) +{ + nLeft = rLT.X(); + nTop = rLT.Y(); + nRight = rRB.X(); + nBottom = rRB.Y(); +} + +inline Rectangle::Rectangle( long _nLeft, long _nTop, + long _nRight, long _nBottom ) +{ + nLeft = _nLeft; + nTop = _nTop; + nRight = _nRight; + nBottom = _nBottom; +} + +inline Rectangle::Rectangle( const Point& rLT, const Size& rSize ) +{ + nLeft = rLT.X(); + nTop = rLT.Y(); + nRight = rSize.Width() ? nLeft+rSize.Width()-1 : RECT_EMPTY; + nBottom = rSize.Height() ? nTop+rSize.Height()-1 : RECT_EMPTY; +} + +inline BOOL Rectangle::IsEmpty() const +{ + return ((nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY)); +} + +inline Point Rectangle::TopLeft() const +{ + return Point( nLeft, nTop ); +} + +inline Point Rectangle::TopRight() const +{ + return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop ); +} + +inline Point Rectangle::BottomLeft() const +{ + return Point( nLeft, (nBottom == RECT_EMPTY) ? nTop : nBottom ); +} + +inline Point Rectangle::BottomRight() const +{ + return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, + (nBottom == RECT_EMPTY) ? nTop : nBottom ); +} + +inline Point Rectangle::TopCenter() const +{ + if ( IsEmpty() ) + return Point( nLeft, nTop ); + else + return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ), + Min( nTop, nBottom) ); +} + +inline Point Rectangle::BottomCenter() const +{ + if ( IsEmpty() ) + return Point( nLeft, nTop ); + else + return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ), + Max( nTop, nBottom) ); +} + +inline Point Rectangle::LeftCenter() const +{ + if ( IsEmpty() ) + return Point( nLeft, nTop ); + else + return Point( Min( nLeft, nRight ), nTop + (nBottom - nTop)/2 ); +} + +inline Point Rectangle::RightCenter() const +{ + if ( IsEmpty() ) + return Point( nLeft, nTop ); + else + return Point( Max( nLeft, nRight ), nTop + (nBottom - nTop)/2 ); +} + +inline Point Rectangle::Center() const +{ + if ( IsEmpty() ) + return Point( nLeft, nTop ); + else + return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 ); +} + +inline void Rectangle::Move( long nHorzMove, long nVertMove ) +{ + nLeft += nHorzMove; + nTop += nVertMove; + if ( nRight != RECT_EMPTY ) + nRight += nHorzMove; + if ( nBottom != RECT_EMPTY ) + nBottom += nVertMove; +} + +void Rectangle::Transpose() +{ + if ( !IsEmpty() ) + { + long swap( nLeft ); + nLeft = nTop; + nTop = swap; + + swap = nRight; + nRight = nBottom; + nBottom = swap; + } +} + +inline void Rectangle::SetPos( const Point& rPoint ) +{ + if ( nRight != RECT_EMPTY ) + nRight += rPoint.X() - nLeft; + if ( nBottom != RECT_EMPTY ) + nBottom += rPoint.Y() - nTop; + nLeft = rPoint.X(); + nTop = rPoint.Y(); +} + +inline long Rectangle::GetWidth() const +{ + long n; + if ( nRight == RECT_EMPTY ) + n = 0; + else + { + n = nRight - nLeft; + if( n < 0 ) + n--; + else + n++; + } + + return n; +} + +inline long Rectangle::GetHeight() const +{ + long n; + if ( nBottom == RECT_EMPTY ) + n = 0; + else + { + n = nBottom - nTop; + if ( n < 0 ) + n--; + else + n++; + } + + return n; +} + +inline Size Rectangle::GetSize() const +{ + return Size( GetWidth(), GetHeight() ); +} + +inline Rectangle Rectangle::GetUnion( const Rectangle& rRect ) const +{ + Rectangle aTmpRect( *this ); + return aTmpRect.Union( rRect ); +} + +inline Rectangle Rectangle::GetIntersection( const Rectangle& rRect ) const +{ + Rectangle aTmpRect( *this ); + return aTmpRect.Intersection( rRect ); +} + +inline BOOL Rectangle::operator == ( const Rectangle& rRect ) const +{ + return ((nLeft == rRect.nLeft ) && + (nTop == rRect.nTop ) && + (nRight == rRect.nRight ) && + (nBottom == rRect.nBottom )); +} + +inline BOOL Rectangle::operator != ( const Rectangle& rRect ) const +{ + return ((nLeft != rRect.nLeft ) || + (nTop != rRect.nTop ) || + (nRight != rRect.nRight ) || + (nBottom != rRect.nBottom )); +} + +inline Rectangle& Rectangle::operator +=( const Point& rPt ) +{ + nLeft += rPt.X(); + nTop += rPt.Y(); + if ( nRight != RECT_EMPTY ) + nRight += rPt.X(); + if ( nBottom != RECT_EMPTY ) + nBottom += rPt.Y(); + return *this; +} + +inline Rectangle& Rectangle::operator -= ( const Point& rPt ) +{ + nLeft -= rPt.X(); + nTop -= rPt.Y(); + if ( nRight != RECT_EMPTY ) + nRight -= rPt.X(); + if ( nBottom != RECT_EMPTY ) + nBottom -= rPt.Y(); + return *this; +} + +inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt ) +{ + Rectangle aRect( rRect.nLeft + rPt.X(), rRect.nTop + rPt.Y(), + (rRect.nRight == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight + rPt.X(), + (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom + rPt.Y() ); + return aRect; +} + +inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt ) +{ + Rectangle aRect( rRect.nLeft - rPt.X(), + rRect.nTop - rPt.Y(), + (rRect.nRight == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight - rPt.X(), + (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom - rPt.Y() ); + return aRect; +} + +#endif // _GEN_HXX diff --git a/tools/inc/tools/geninfo.hxx b/tools/inc/tools/geninfo.hxx new file mode 100644 index 000000000000..720ccb9cd788 --- /dev/null +++ b/tools/inc/tools/geninfo.hxx @@ -0,0 +1,230 @@ +/************************************************************************* + * + * 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 _BOOTSTRP_GENINFO_HXX +#define _BOOTSTRP_GENINFO_HXX + +#include "tools/toolsdllapi.h" + +#include <tools/string.hxx> +#include <tools/list.hxx> + +// forwards +class GenericInformationList; + +// +// class GenericInformation +// + +/****************************************************************************** +Purpose: holds generic informations and subinformations in a simple format +******************************************************************************/ + +class TOOLS_DLLPUBLIC GenericInformation : public ByteString // the key is stored in base class +{ +friend class GenericInformationList; // can be child or/and parent +private: + ByteString sValue; // holds value of data + ByteString sComment; + + GenericInformationList *pInfoList; // holds subinformations + GenericInformationList *pParent; // holds a pointer to parent list + + // methods + void ListDeleted() { pParent = NULL; } // allowed to be accessed + // from friend class + // GenericInformationList + +public: + GenericInformation( const ByteString &rKey, const ByteString &rValue, + GenericInformationList *pParentList = NULL, + GenericInformationList *pSubInfos = NULL ); + GenericInformation( const GenericInformation& rInf, BOOL bCopySubs = TRUE); + + ~GenericInformation(); + + ByteString &GetValue() { return sValue; } + void SetValue( const ByteString &rValue ) { sValue = rValue; } + + ByteString &GetComment() { return sComment; } + void SetComment( const ByteString &rComment ) { sComment = rComment; } + + // this methods used to handle sub informations + BOOL InsertSubInfo( GenericInformation *pInfo ); + // siehe GenericInformationList + BOOL InsertSubInfo( const ByteString &rPathKey, const ByteString &rValue, + BOOL bSearchByPath = FALSE, BOOL bNewPath = FALSE); + void RemoveSubInfo( GenericInformation *pInfo, BOOL bDelete = FALSE ); + // void RemoveSelf( BOOL bDelete = FALSE ); // loescht sich selbst aus der Parentliste + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // bei bDelete = TRUE werden auch alle Sublisten UND DIE INFO SELBST geloescht. + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + GenericInformation *GetSubInfo( ByteString &rKey, BOOL bSearchByPath = FALSE, + BOOL bCreatePath = FALSE ); + // path can be something like this: src370/drives/o: + + void SetSubList( GenericInformationList *pSubList ) + { pInfoList = pSubList; } + GenericInformationList *GetSubList() { return pInfoList; } +}; + +/* diese Klasse bietet einen SemaphoreLock zum lesen (und nicht Schreiben) + * oder schreiben (und nicht lesen) + */ +class GenericLockInformation : public GenericInformation +{ +public: +GenericLockInformation( const ByteString &rKey, const ByteString &rValue, + GenericInformationList *pParentList = NULL, + GenericInformationList *pSubInfos = NULL ) + : GenericInformation( rKey, rValue, pParentList, pSubInfos), + aLockState( read ), nLockKey( 0 ) {}; + //~GenericLockInformation(); + + /* bietet einen Lockmechanismus fuer exclusive Zugriffe + * + * -"writeonly" wird angesprochen, wenn von der Wurzel ausgehend + * ein Item veraendert werden soll. In der Zeit kann die Liste nicht + * gelesen werden, womit keine Inconsistenzen entstehen koennen. + * + * -"read" wird zum Normalen lesen der Infos benutzt, 90% der Betriebszeit. + * waerenddessen kann nicht geschrieben werden -> writeonly Lock. + * Ist fuer den atomaren(nicht unterbrochenen) Lesezugriff gedacht + * + * -"readonly" wird zum niederschreiben des Teilbaums benutzt, was schon mal + * 10 Minuten dauern kann. In der Zeit kann kein Writeonlylock gesetzt + * werden, aber ein rescedule. Damit koennen andere Aktionen asynchron ausgefuert + * werden, aber die Datensicherheit bleibt gewahrt + * + * Zustandsaenderung: writeonly <-> read <-> readonly + * + * nLockKey ist zum verschluesseln des LockZugriffs mit einem 32bit Wort vorgesehen. + * ist der Schluessel nicht null, so kann nur mit dem Schluessel in + * die Baumstruktur geschrieben werden. + * ist der Schluessel nLockKey Null, dann kann jeder Schreiben und die Locks loesen + */ + enum LockState{ writeonly, read, readonly }; + + /* der Schreibschutz darf nur aktiviert werden, wenn + * der Status auf Lesen steht + */ + BOOL SetWriteLock(UINT32 nKey = 0) { return ((read==aLockState) && + (aLockState=writeonly, nLockKey=nKey, TRUE)); } + /* Schreibschutz darf nur geloest werden, wenn + * der Schreibschutz drin ist, und + * entweder der LockKey Null ist(Generalschluessel) oder der Key zum LockKey passt + */ + BOOL ReleaseWriteLock(UINT32 nKey = 0) { return ((writeonly==aLockState) && + (!nLockKey||nKey==nLockKey) && + (aLockState=read, nLockKey=0, TRUE)); } // setzt den zustand auf "read" + BOOL SetReadLock(UINT32 nKey = 0) { return ((read==aLockState) && + (aLockState=readonly, nLockKey=nKey, TRUE)); } + BOOL ReleaseReadLock(UINT32 nKey = 0) { return ((readonly==aLockState) && + (!nLockKey||nKey==nLockKey) && + (aLockState=read, nLockKey=0, TRUE)); } // setzt den zustand auf "read" + + LockState GetLockState() const { return aLockState; } + BOOL IsWriteLocked() const { return (writeonly==aLockState); } + BOOL IsReadLocked() const { return (readonly==aLockState); } + BOOL IsNotLocked() const { return (read==aLockState); } + BOOL IsLocker( UINT32 nKey ) { return (nKey==nLockKey || !nLockKey); } + + /* wenn der Schreibschutz aktiviert wurde, + * und bei vorhandenem Schreibschutz die Keys stimmen + * rufe die Parentmethode auf */ + BOOL InsertSubInfo( GenericInformation *pInfo, UINT32 nKey = 0 ) { + return ((writeonly==aLockState) && + (!nLockKey || nKey==nLockKey) && + (GenericInformation::InsertSubInfo( pInfo ), TRUE)); } + + BOOL InsertSubInfo( const ByteString &rPathKey, const ByteString &rValue, UINT32 nKey = 0, + BOOL bSearchByPath = FALSE, BOOL bNewPath = FALSE) { + return ((writeonly==aLockState) && + (!nLockKey || nKey==nLockKey) && + (GenericInformation::InsertSubInfo( rPathKey, rValue, bSearchByPath, bNewPath ), TRUE)); } + /* 29.jan.98: erweiterung um lesemoeglichkeit vom Lockclienten */ + GenericInformation *GetSubInfo( ByteString &rKey, BOOL bSearchByPath = FALSE, + BOOL bCreatePath = FALSE, UINT32 nKey = 0 ) { + if (writeonly==aLockState && nLockKey && nKey!=nLockKey ) + return NULL; + return GenericInformation::GetSubInfo(rKey, bSearchByPath, bCreatePath); } + + // TYPEINFO(); +private: + + LockState aLockState; + UINT32 nLockKey; +}; + +// +// class GenericInformationList +// + +/****************************************************************************** +Purpose: holds set of generic informations in a sorted list +******************************************************************************/ + +DECLARE_LIST( GenericInformationList_Impl, GenericInformation * ) + +class TOOLS_DLLPUBLIC GenericInformationList : public GenericInformationList_Impl +{ +private: + GenericInformation *pOwner; // holds parent of this list + +protected: + // methods + ULONG InsertSorted( GenericInformation *pInfo, BOOL bOverwrite, + ULONG nStart, ULONG nEnd ); + GenericInformation *Search( ULONG &rPos, ByteString sKey, + ULONG nStart, ULONG nEnd ); + +public: + GenericInformationList( GenericInformation *pParent = NULL ); + GenericInformationList(const GenericInformationList& rList, GenericInformation *pParent = NULL); + ~GenericInformationList(); + + // this methods used to handle the informations using binary search + GenericInformation *GetInfo( ByteString &rKey, BOOL bSearchByPath = FALSE, + BOOL bCreatePath = FALSE ); + /* path can be something like this: src370/drives/o: + * bCreatePath will create the neccecary paths to the GI */ + + BOOL InsertInfo( GenericInformation *pInfo, BOOL bOverwrite = TRUE ); + /* legt eine GenericInformation im Baum an mit Key-Value + * wenn bNewPath gesetzt, wird der nichtexistente Teil des Pfades neu kreiert + * wenn bNewPath nicht gesetzt ist und ein Teil des Pfades nicht vorhanden ist, + * gibt die Methode FALSE zurueck.*/ + BOOL InsertInfo( const ByteString &rPathKey, const ByteString &rValue, + BOOL bSearchByPath = FALSE, BOOL bNewPath = FALSE); + void RemoveInfo( GenericInformation *pInfo, BOOL bDelete = FALSE ); + + GenericInformation* SetOwner( GenericInformation *pNewOwner ); + +}; + +#endif + diff --git a/tools/inc/tools/getprocessworkingdir.hxx b/tools/inc/tools/getprocessworkingdir.hxx new file mode 100644 index 000000000000..1b0688379590 --- /dev/null +++ b/tools/inc/tools/getprocessworkingdir.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * + * 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 INCLUDED_TOOLS_GETPROCESSWORKINGDIR_HXX +#define INCLUDED_TOOLS_GETPROCESSWORKINGDIR_HXX + +#include "sal/config.h" + +#include "tools/toolsdllapi.h" + +namespace rtl { class OUString; } + +namespace tools { + +// get the process's current working directory, taking OOO_CWD into account +// +// @param url +// a non-null pointer that receives the directory URL (with or without a final +// slash) upon successful return, and the empty string upon unsuccessful return +TOOLS_DLLPUBLIC bool getProcessWorkingDir(rtl::OUString * url); + +} + +#endif diff --git a/tools/inc/tools/globname.hxx b/tools/inc/tools/globname.hxx new file mode 100644 index 000000000000..7fac64e2f74b --- /dev/null +++ b/tools/inc/tools/globname.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * 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 _GLOBNAME_HXX +#define _GLOBNAME_HXX + +#include "tools/toolsdllapi.h" +#include <com/sun/star/uno/Sequence.hxx> +#include <tools/string.hxx> +#include <tools/list.hxx> + +/************************************************************************* +*************************************************************************/ +struct ImpSvGlobalName +{ + BYTE szData[ 16 ]; + USHORT nRefCount; + + ImpSvGlobalName() + { + nRefCount = 0; + } + ImpSvGlobalName( const ImpSvGlobalName & rObj ); + ImpSvGlobalName( int ); + + BOOL operator == ( const ImpSvGlobalName & rObj ) const; +}; + +#ifdef WNT +struct _GUID; +typedef struct _GUID GUID; +#else +struct GUID; +#endif +typedef GUID CLSID; +class SvStream; +class SvGlobalNameList; +class TOOLS_DLLPUBLIC SvGlobalName +{ +friend class SvGlobalNameList; + ImpSvGlobalName * pImp; + void NewImp(); +public: + SvGlobalName(); + SvGlobalName( const SvGlobalName & rObj ) + { + pImp = rObj.pImp; + pImp->nRefCount++; + } + SvGlobalName( ImpSvGlobalName * pImpP ) + { + pImp = pImpP; + pImp->nRefCount++; + } + SvGlobalName( UINT32 n1, USHORT n2, USHORT n3, + BYTE b8, BYTE b9, BYTE b10, BYTE b11, + BYTE b12, BYTE b13, BYTE b14, BYTE b15 ); + + // create SvGlobalName from a platform independent representation + SvGlobalName( const ::com::sun::star::uno::Sequence< sal_Int8 >& aSeq ); + + SvGlobalName & operator = ( const SvGlobalName & rObj ); + ~SvGlobalName(); + + TOOLS_DLLPUBLIC friend SvStream & operator >> ( SvStream &, SvGlobalName & ); + TOOLS_DLLPUBLIC friend SvStream & operator << ( SvStream &, const SvGlobalName & ); + + BOOL operator < ( const SvGlobalName & rObj ) const; + SvGlobalName & operator += ( UINT32 ); + SvGlobalName & operator ++ () { return operator += ( 1 ); } + + BOOL operator == ( const SvGlobalName & rObj ) const; + BOOL operator != ( const SvGlobalName & rObj ) const + { return !(*this == rObj); } + + void MakeFromMemory( void * pData ); + BOOL MakeId( const String & rId ); + String GetctorName() const; + String GetHexName() const; + String GetRegDbName() const + { + String a = '{'; + a += GetHexName(); + a += '}'; + return a; + } + + SvGlobalName( const CLSID & rId ); + const CLSID & GetCLSID() const { return *(CLSID *)pImp->szData; } + const BYTE* GetBytes() const { return pImp->szData; } + + // platform independent representation of a "GlobalName" + // maybe transported remotely + com::sun::star::uno::Sequence < sal_Int8 > GetByteSequence() const; +}; + +class SvGlobalNameList +{ + List aList; +public: + SvGlobalNameList(); + ~SvGlobalNameList(); + + void Append( const SvGlobalName & ); + SvGlobalName GetObject( ULONG ); + BOOL IsEntry( const SvGlobalName & rName ); + ULONG Count() const { return aList.Count(); } +private: + // nicht erlaubt + SvGlobalNameList( const SvGlobalNameList & ); + SvGlobalNameList & operator = ( const SvGlobalNameList & ); +}; + +#endif // _GLOBNAME_HXX + diff --git a/tools/inc/tools/inetdef.hxx b/tools/inc/tools/inetdef.hxx new file mode 100644 index 000000000000..7341225912ab --- /dev/null +++ b/tools/inc/tools/inetdef.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * 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 _TOOLS_INETDEF_HXX +#define _TOOLS_INETDEF_HXX + +//============================================================================ +#if defined WNT +#define TOOLS_INETDEF_OS "Win32" +#elif defined OS2 +#define TOOLS_INETDEF_OS "OS/2" +#elif defined UNX +#if defined AIX +#define TOOLS_INETDEF_OS "AIX" +#elif defined HPUX +#define TOOLS_INETDEF_OS "HP/UX" +#elif defined SOLARIS && defined SPARC +#define TOOLS_INETDEF_OS "Solaris Sparc" +#elif defined SOLARIS && defined INTEL +#define TOOLS_INETDEF_OS "Solaris x86" +#elif defined SCO +#define TOOLS_INETDEF_OS "SCO" +#elif defined NETBSD && defined X86 +#define TOOLS_INETDEF_OS "NETBSD x86" +#elif defined NETBSD && defined ARM32 +#define TOOLS_INETDEF_OS "NETBSD ARM32" +#elif defined NETBSD && defined SPARC +#define TOOLS_INETDEF_OS "NETBSD Sparc" +#elif defined LINUX && defined X86 +#define TOOLS_INETDEF_OS "Linux" +#elif defined FREEBSD && defined X86 +#define TOOLS_INETDEF_OS "FreeBSD/i386" +#elif defined FREEBSD && defined X86_64 +#define TOOLS_INETDEF_OS "FreeBSD/amd64" +#elif defined SINIX +#define TOOLS_INETDEF_OS "SINIX" +#else // AIX, HPUX, SOLARIS, ... +#define TOOLS_INETDEF_OS "Unix" +#endif // AIX, HPUX, SOLARIS, ... +#else // WNT, ... +#define TOOLS_INETDEF_OS "unknown OS" +#endif // WN, ... + +#define TOOLS_INETDEF_PRODUCT "StarOffice/5.2" +#define TOOLS_INETDEF_MOZILLA "Mozilla/3.0" + +#define INET_PRODUCTNAME TOOLS_INETDEF_PRODUCT " (" TOOLS_INETDEF_OS ")" +#define INET_DEF_CALLERNAME TOOLS_INETDEF_MOZILLA " (compatible; " \ + TOOLS_INETDEF_PRODUCT "; " TOOLS_INETDEF_OS ")" + +//============================================================================ +// The following definitions seem obsolete and might get removed in future. + +#define INET_PERS_CERT_HOMEPAGE "http://www.stardivision.de/certs.html" +#define INET_PERS_CERT_HOMEPAGE_INT \ + "http://www.stardivision.de/certs/certs##.html" + // the above definitions are only used in svx/source/options/optinet2.cxx + +#if defined __RSC +#define INET_UNDEFINED 0 +#define INET_NAME_RESOLVE_START 1 +#define INET_NAME_RESOLVE_ERROR 2 +#define INET_NAME_RESOLVE_SUCCESS 3 +#define INET_CONNECT_START 4 +#define INET_CONNECT_ERROR 5 +#define INET_CONNECT_SUCCESS 6 +#define INET_WRITE_START 7 +#define INET_WRITE_STATUS 8 +#define INET_WRITE_ERROR 9 +#define INET_WRITE_SUCCESS 10 +#define INET_READ_START 11 +#define INET_READ_STATUS 12 +#define INET_READ_ERROR 13 +#define INET_READ_SUCCESS 14 +#define INET_CLOSING_CONNECTION 15 +#define INET_CONNECTION_CLOSED 16 +#define INET_REQUEST_CANCELED 17 +#define INET_CONNECTION_CANCELED 18 +#define INET_SESSION_CANCELED 19 +#define INET_AUTHENTICATION 20 +#define INET_OFFLINE_ERROR 21 +#define INET_PROXY_AUTHENTICATION 22 +#endif // __RSC + // the above definitions are only used in sfx2/source/doc/doc.src + +#endif // _TOOLS_INETDEF_HXX + diff --git a/tools/inc/tools/inetmime.hxx b/tools/inc/tools/inetmime.hxx new file mode 100644 index 000000000000..4e8065f6264c --- /dev/null +++ b/tools/inc/tools/inetmime.hxx @@ -0,0 +1,1445 @@ +/************************************************************************* + * + * 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 TOOLS_INETMIME_HXX +#define TOOLS_INETMIME_HXX + +#include "tools/toolsdllapi.h" +#include <rtl/alloc.h> +#include <rtl/string.h> +#include "rtl/tencinfo.h" +#include <tools/debug.hxx> +#include <tools/errcode.hxx> +#include <tools/list.hxx> +#include <tools/string.hxx> + +class DateTime; +class INetContentTypeParameterList; +class INetMIMECharsetList_Impl; +class INetMIMEOutputSink; + +//============================================================================ +class TOOLS_DLLPUBLIC INetMIME +{ +public: + enum { SOFT_LINE_LENGTH_LIMIT = 76, + HARD_LINE_LENGTH_LIMIT = 998 }; + + /** The various types of message header field bodies, with respect to + encoding and decoding them. + + @descr At the moment, five different types of header fields suffice + to describe how to encoded and decode any known message header field + body, but need for more types may arise in the future as new header + fields are introduced. + + @descr The following is an exhaustive list of all the header fields + currently known to our implementation. For every header field, it + includes a 'canonic' (with regard to capitalization) name, a grammar + rule for the body (using RFC 822 and RFC 2234 conventions), a list of + relevant sources of information, and the HeaderFieldType value to use + with that header field. The list is based on RFC 2076 and draft- + palme-mailext-headers-02.txt (see also <http://www.dsv.su.se/~jpalme/ + ietf/jp-ietf-home.html#anchor1003783>). + + Approved: address ;RFC 1036; HEADER_FIELD_ADDRESS + bcc: #address ;RFCs 822, 2047; HEADER_FIELD_ADDRESS + cc: 1#address ;RFCs 822, 2047; HEADER_FIELD_ADDRESS + Comments: *text ;RFCs 822, RFC 2047; HEADER_FIELD_TEXT + Content-Base: absoluteURI ;RFC 2110; HEADER_FIELD_TEXT + Content-Description: *text ;RFC 2045, RFC 2047; HEADER_FIELD_TEXT + Content-Disposition: disposition-type *(";" disposition-parm) + ;RFC 1806; HEADER_FIELD_STRUCTURED + Content-ID: msg-id ;RFC 2045, RFC 2047; HEADER_FIELD_MESSAGE_ID + Content-Location: absoluteURI / relativeURI ;RFC 2110; + HEADER_FIELD_TEXT + Content-Transfer-Encoding: mechanism ;RFC 2045, RFC 2047; + HEADER_FIELD_STRUCTURED + Content-Type: type "/" subtype *(";" parameter) ;RFC 2045, RFC 2047; + HEADER_FIELD_STRUCTURED + Control: *text ;RFC 1036; HEADER_FIELD_TEXT + Date: date-time ;RFC 822, RFC 1123, RFC 2047; HEADER_FIELD_STRUCTURED + Distribution: 1#atom ;RFC 1036; HEADER_FIELD_STRUCTURED + Encrypted: 1#2word ;RFC 822, RFC 2047; HEADER_FIELD_STRUCTURED + Expires: date-time ;RFC 1036; HEADER_FIELD_STRUCTURED + Followup-To: 1#(atom *("." atom)) ;RFC 1036; HEADER_FIELD_STRUCTURED + From: mailbox / 1#mailbox ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + In-Reply-To: *(phrase / msg-id) ;RFC 822, RFC 2047; + HEADER_FIELD_ADDRESS + Keywords: #phrase ;RFC 822, RFC 2047; HEADER_FIELD_PHRASE + MIME-Version: 1*DIGIT "." 1*DIGIT ;RFC 2045, RFC 2047; + HEADER_FIELD_STRUCTURED + Message-ID: msg-id ;RFC 822, RFC 2047; HEADER_FIELD_MESSAGE_ID + Newsgroups: 1#(atom *("." atom)) ;RFC 1036, RFC 2047; + HEADER_FIELD_STRUCTURED + Organization: *text ;RFC 1036; HEADER_FIELD_TEXT + Received: ["from" domain] ["by" domain] ["via" atom] *("with" atom) + ["id" msg-id] ["for" addr-spec] ";" date-time ;RFC 822, RFC 1123, + RFC 2047; HEADER_FIELD_STRUCTURED + References: *(phrase / msg-id) ;RFC 822, RFC 2047; + HEADER_FIELD_ADDRESS + Reply-To: 1#address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Resent-Date: date-time ;RFC 822, RFC 1123, RFC 2047; + HEADER_FIELD_STRUCTURED + Resent-From: mailbox / 1#mailbox ;RFC 822, RFC 2047; + HEADER_FIELD_ADDRESS + Resent-Message-ID: msg-id ;RFC 822, RFC 2047; HEADER_FIELD_MESSAGE_ID + Resent-Reply-To: 1#address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Resent-Sender: mailbox ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Resent-To: 1#address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Resent-bcc: #address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Resent-cc: 1#address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Return-path: route-addr / ("<" ">") ;RFC 822, RFC 1123, RFC 2047; + HEADER_FIELD_STRUCTURED + Return-Receipt-To: address ;Not Internet standard; + HEADER_FIELD_ADDRES + Sender: mailbox ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + Subject: *text ;RFC 822, RFC 2047; HEADER_FIELD_TEXT + Summary: *text ;RFC 1036; HEADER_FIELD_TEXT + To: 1#address ;RFC 822, RFC 2047; HEADER_FIELD_ADDRESS + X-CHAOS-Marked: "YES" / "NO" ;local; HEADER_FIELD_STRUCTURED + X-CHAOS-Read: "YES" / "NO" ;local; HEADER_FIELD_STRUCTURED + X-CHAOS-Recipients: #*("<" atom word ">") ;local; + HEADER_FIELD_STRUCTURED + X-CHAOS-Size: 1*DIGIT ;local; HEADER_FIELD_STRUCTURED + X-Mailer: *text ;Not Internet standard; HEADER_FIELD_TEXT + X-Mozilla-Status: 4HEXDIG ;Mozilla; HEADER_FIELD_STRUCTURED + X-Newsreader: *text ;Not Internet standard; HEADER_FIELD_TEXT + X-Priority: "1" / "2" / "3" / "4" / "5" ;Not Internet standard; + HEADER_FIELD_STRUCTURED + Xref: sub-domain + 1*((atom / string) *("." (atom / string)) ":" msg-number) + ;RFCs 1036, 2047, local; HEADER_FIELD_STRUCTURED + */ + enum HeaderFieldType + { + HEADER_FIELD_TEXT, + HEADER_FIELD_STRUCTURED, + HEADER_FIELD_PHRASE, + HEADER_FIELD_MESSAGE_ID, + HEADER_FIELD_ADDRESS + }; + + /** Check for US-ASCII character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII character (0x00--0x7F). + */ + static inline bool isUSASCII(sal_uInt32 nChar); + + /** Check for ISO 8859-1 character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a ISO 8859-1 character (0x00--0xFF). + */ + static inline bool isISO88591(sal_uInt32 nChar); + + /** Check for US-ASCII control character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII control character (US-ASCII + 0x00--0x1F or 0x7F). + */ + static inline bool isControl(sal_uInt32 nChar); + + /** Check for US-ASCII white space character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII white space character (US-ASCII + 0x09 or 0x20). + */ + static inline bool isWhiteSpace(sal_uInt32 nChar); + + /** Check for US-ASCII visible character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII visible character (US-ASCII + 0x21--0x7E). + */ + static inline bool isVisible(sal_uInt32 nChar); + + /** Check for US-ASCII digit character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII (decimal) digit character (US- + ASCII '0'--'9'). + */ + static inline bool isDigit(sal_uInt32 nChar); + + /** Check for US-ASCII canonic hexadecimal digit character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII canonic (i.e., upper case) + hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F'). + */ + static inline bool isCanonicHexDigit(sal_uInt32 nChar); + + /** Check for US-ASCII hexadecimal digit character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII hexadecimal digit character (US- + ASCII '0'--'9', 'A'--'F', 'a'--'f'). + */ + static inline bool isHexDigit(sal_uInt32 nChar); + + /** Check for US-ASCII upper case character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII upper case alphabetic character + (US-ASCII 'A'--'Z'). + */ + static inline bool isUpperCase(sal_uInt32 nChar); + + /** Check for US-ASCII lower case character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII lower case alphabetic character + (US-ASCII 'a'--'z'). + */ + static inline bool isLowerCase(sal_uInt32 nChar); + + /** Check for US-ASCII alphabetic character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII alphabetic character (US-ASCII + 'A'--'Z' or 'a'--'z'). + */ + static inline bool isAlpha(sal_uInt32 nChar); + + /** Check for US-ASCII alphanumeric character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII alphanumeric character (US-ASCII + '0'--'9', 'A'--'Z' or 'a'--'z'). + */ + static inline bool isAlphanumeric(sal_uInt32 nChar); + + /** Check for US-ASCII Base 64 digit character. + + @param nChar Some UCS-4 character. + + @return True if nChar is a US-ASCII Base 64 digit character (US-ASCII + 'A'--'Z', 'a'--'z', '0'--'9', '+', or '/'). + */ + static inline bool isBase64Digit(sal_uInt32 nChar); + + /** Check whether some character is valid within an RFC 822 <atom>. + + @param nChar Some UCS-4 character. + + @return True if nChar is valid within an RFC 822 <atom> (US-ASCII + 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+', + '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', or '~'). + */ + static bool isAtomChar(sal_uInt32 nChar); + + /** Check whether some character is valid within an RFC 2045 <token>. + + @param nChar Some UCS-4 character. + + @return True if nChar is valid within an RFC 2047 <token> (US-ASCII + 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+', + '-', '.', '^', '_', '`', '{', '|', '}', or '~'). + */ + static bool isTokenChar(sal_uInt32 nChar); + + /** Check whether some character is valid within an RFC 2047 <token>. + + @param nChar Some UCS-4 character. + + @return True if nChar is valid within an RFC 2047 <token> (US-ASCII + 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '%', '&', ''', '*', '+', + '-', '^', '_', '`', '{', '|', '}', or '~'). + */ + static bool isEncodedWordTokenChar(sal_uInt32 nChar); + + /** Check whether some character is valid within an RFC 2060 <atom>. + + @param nChar Some UCS-4 character. + + @return True if nChar is valid within an RFC 2060 <atom> (US-ASCII + 'A'--'Z', 'a'--'z', '0'--'9', '!', '#', '$', '&', ''', '+', ',', '-', + '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', ']', '^', '_', '`', + '|', '}', or '~'). + */ + static bool isIMAPAtomChar(sal_uInt32 nChar); + + /** Translate an US-ASCII character to upper case. + + @param nChar Some UCS-4 character. + + @return If nChar is a US-ASCII upper case character (US-ASCII + 'A'--'Z'), return the corresponding US-ASCII lower case character (US- + ASCII 'a'--'z'); otherwise, return nChar unchanged. + */ + static inline sal_uInt32 toUpperCase(sal_uInt32 nChar); + + /** Translate an US-ASCII character to lower case. + + @param nChar Some UCS-4 character. + + @return If nChar is a US-ASCII lower case character (US-ASCII + 'a'--'z'), return the corresponding US-ASCII upper case character (US- + ASCII 'A'--'Z'); otherwise, return nChar unchanged. + */ + static inline sal_uInt32 toLowerCase(sal_uInt32 nChar); + + /** Get the digit weight of a US-ASCII character. + + @param nChar Some UCS-4 character. + + @return If nChar is a US-ASCII (decimal) digit character (US-ASCII + '0'--'9'), return the corresponding weight (0--9); otherwise, + return -1. + */ + static inline int getWeight(sal_uInt32 nChar); + + /** Get the hexadecimal digit weight of a US-ASCII character. + + @param nChar Some UCS-4 character. + + @return If nChar is a US-ASCII hexadecimal digit character (US-ASCII + '0'--'9', 'A'--'F', or 'a'--'f'), return the corresponding weight + (0--15); otherwise, return -1. + */ + static inline int getHexWeight(sal_uInt32 nChar); + + /** Get the Base 64 digit weight of a US-ASCII character. + + @param nChar Some UCS-4 character. + + @return If nChar is a US-ASCII Base 64 digit character (US-ASCII + 'A'--'F', or 'a'--'f', '0'--'9', '+', or '/'), return the + corresponding weight (0--63); if nChar is the US-ASCII Base 64 padding + character (US-ASCII '='), return -1; otherwise, return -2. + */ + static inline int getBase64Weight(sal_uInt32 nChar); + + /** Get a decimal digit encoded as US-ASCII. + + @param nWeight Must be in the range 0--9, inclusive. + + @return The decimal digit corresponding to nWeight (US-ASCII + '0'--'9'). + */ + static sal_uInt32 getDigit(int nWeight); + + /** Get a hexadecimal digit encoded as US-ASCII. + + @param nWeight Must be in the range 0--15, inclusive. + + @return The canonic (i.e., upper case) hexadecimal digit + corresponding to nWeight (US-ASCII '0'--'9' or 'A'--'F'). + */ + static sal_uInt32 getHexDigit(int nWeight); + + /** Get a Base 64 digit encoded as US-ASCII. + + @param nWeight Must be in the range 0--63, inclusive. + + @return The Base 64 digit corresponding to nWeight (US-ASCII 'A'-- + 'Z', 'a'--'z', '0'--'9', '+' or '/'). + */ + static sal_uInt32 getBase64Digit(int nWeight); + + static inline bool isHighSurrogate(sal_uInt32 nUTF16); + + static inline bool isLowSurrogate(sal_uInt32 nUTF16); + + static inline sal_uInt32 toUTF32(sal_Unicode cHighSurrogate, + sal_Unicode cLowSurrogate); + + /** Check two US-ASCII strings for equality, ignoring case. + + @param pBegin1 Points to the start of the first string, must not be + null. + + @param pEnd1 Points past the end of the first string, must be >= + pBegin1. + + @param pBegin2 Points to the start of the second string, must not be + null. + + @param pEnd2 Points past the end of the second string, must be >= + pBegin2. + + @return True if the two strings are equal, ignoring the case of US- + ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z'). + */ + static bool equalIgnoreCase(const sal_Char * pBegin1, + const sal_Char * pEnd1, + const sal_Char * pBegin2, + const sal_Char * pEnd2); + + /** Check two US-ASCII strings for equality, ignoring case. + + @param pBegin1 Points to the start of the first string, must not be + null. + + @param pEnd1 Points past the end of the first string, must be >= + pBegin1. + + @param pString2 Points to the start of the null terminated second + string, must not be null. + + @return True if the two strings are equal, ignoring the case of US- + ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z'). + */ + static bool equalIgnoreCase(const sal_Char * pBegin1, + const sal_Char * pEnd1, + const sal_Char * pString2); + + /** Check two US-ASCII strings for equality, ignoring case. + + @param pBegin1 Points to the start of the first string, must not be + null. + + @param pEnd1 Points past the end of the first string, must be >= + pBegin1. + + @param pString2 Points to the start of the null terminated second + string, must not be null. + + @return True if the two strings are equal, ignoring the case of US- + ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z'). + */ + static bool equalIgnoreCase(const sal_Unicode * pBegin1, + const sal_Unicode * pEnd1, + const sal_Char * pString2); + + /** Check two US-ASCII strings for equality, ignoring case. + + @param rString1 The first string. + + @param sString2 Points to the start of the null terminated second + string, must not be null. + + @return True if the two strings are equal, ignoring the case of US- + ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z'). + */ + static inline bool equalIgnoreCase(const ByteString & rString1, + const sal_Char * pString2); + + static inline bool startsWithLineBreak(const sal_Char * pBegin, + const sal_Char * pEnd); + + static inline bool startsWithLineBreak(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static inline bool startsWithLineFolding(const sal_Char * pBegin, + const sal_Char * pEnd); + + static inline bool startsWithLineFolding(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static bool startsWithLinearWhiteSpace(const sal_Char * pBegin, + const sal_Char * pEnd); + + static const sal_Char * skipLinearWhiteSpace(const sal_Char * pBegin, + const sal_Char * pEnd); + + static const sal_Unicode * skipLinearWhiteSpace(const sal_Unicode * + pBegin, + const sal_Unicode * pEnd); + + static const sal_Char * skipComment(const sal_Char * pBegin, + const sal_Char * pEnd); + + static const sal_Unicode * skipComment(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static const sal_Char * skipLinearWhiteSpaceComment(const sal_Char * + pBegin, + const sal_Char * + pEnd); + + static const sal_Unicode * skipLinearWhiteSpaceComment(const sal_Unicode * + pBegin, + const sal_Unicode * + pEnd); + + static inline bool needsQuotedStringEscape(sal_uInt32 nChar); + + static const sal_Char * skipQuotedString(const sal_Char * pBegin, + const sal_Char * pEnd); + + static const sal_Unicode * skipQuotedString(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static const sal_Char * scanAtom(const sal_Char * pBegin, + const sal_Char * pEnd); + + static const sal_Unicode * scanAtom(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static bool scanUnsigned(const sal_Char *& rBegin, const sal_Char * pEnd, + bool bLeadingZeroes, sal_uInt32 & rValue); + + static bool scanUnsigned(const sal_Unicode *& rBegin, + const sal_Unicode * pEnd, bool bLeadingZeroes, + sal_uInt32 & rValue); + + static bool scanUnsignedHex(const sal_Char *& rBegin, + const sal_Char * pEnd, bool bLeadingZeroes, + sal_uInt32 & rValue); + + static bool scanUnsignedHex(const sal_Unicode *& rBegin, + const sal_Unicode * pEnd, bool bLeadingZeroes, + sal_uInt32 & rValue); + + static const sal_Char * scanQuotedBlock(const sal_Char * pBegin, + const sal_Char * pEnd, + sal_uInt32 nOpening, + sal_uInt32 nClosing, + sal_Size & rLength, + bool & rModify); + + static const sal_Unicode * scanQuotedBlock(const sal_Unicode * pBegin, + const sal_Unicode * pEnd, + sal_uInt32 nOpening, + sal_uInt32 nClosing, + sal_Size & rLength, + bool & rModify); + + static sal_Char const * scanParameters(sal_Char const * pBegin, + sal_Char const * pEnd, + INetContentTypeParameterList * + pParameters); + + static sal_Unicode const * scanParameters(sal_Unicode const * pBegin, + sal_Unicode const * pEnd, + INetContentTypeParameterList * + pParameters); + + static inline rtl_TextEncoding translateToMIME(rtl_TextEncoding + eEncoding); + + static inline rtl_TextEncoding translateFromMIME(rtl_TextEncoding + eEncoding); + + static const sal_Char * getCharsetName(rtl_TextEncoding eEncoding); + + static rtl_TextEncoding getCharsetEncoding(const sal_Char * pBegin, + const sal_Char * pEnd); + + static rtl_TextEncoding getCharsetEncoding(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + + static inline bool isMIMECharsetEncoding(rtl_TextEncoding eEncoding); + + static INetMIMECharsetList_Impl * + createPreferredCharsetList(rtl_TextEncoding eEncoding); + + static sal_Unicode * convertToUnicode(const sal_Char * pBegin, + const sal_Char * pEnd, + rtl_TextEncoding eEncoding, + sal_Size & rSize); + + static sal_Char * convertFromUnicode(const sal_Unicode * pBegin, + const sal_Unicode * pEnd, + rtl_TextEncoding eEncoding, + sal_Size & rSize); + + /** Get the number of octets required to encode an UCS-4 character using + UTF-8 encoding. + + @param nChar Some UCS-4 character. + + @return The number of octets required (in the range 1--6, inclusive). + */ + static inline int getUTF8OctetCount(sal_uInt32 nChar); + + static inline void writeEscapeSequence(INetMIMEOutputSink & rSink, + sal_uInt32 nChar); + + static void writeUTF8(INetMIMEOutputSink & rSink, sal_uInt32 nChar); + + static void writeUnsigned(INetMIMEOutputSink & rSink, sal_uInt32 nValue, + int nMinDigits = 1); + + static void writeDateTime(INetMIMEOutputSink & rSink, + const DateTime & rUTC); + + static void writeHeaderFieldBody(INetMIMEOutputSink & rSink, + HeaderFieldType eType, + const ByteString & rBody, + rtl_TextEncoding ePreferredEncoding, + bool bInitialSpace = true); + + static void writeHeaderFieldBody(INetMIMEOutputSink & rSink, + HeaderFieldType eType, + const UniString & rBody, + rtl_TextEncoding ePreferredEncoding, + bool bInitialSpace = true); + + static bool translateUTF8Char(const sal_Char *& rBegin, + const sal_Char * pEnd, + rtl_TextEncoding eEncoding, + sal_uInt32 & rCharacter); + + static ByteString decodeUTF8(const ByteString & rText, + rtl_TextEncoding eEncoding); + + static UniString decodeHeaderFieldBody(HeaderFieldType eType, + const ByteString & rBody); + +// #i70651#: Prevent warnings on Mac OS X. +#ifdef MACOSX +#pragma GCC system_header +#endif + + /** Get the UTF-32 character at the head of a UTF-16 encoded string. + + @param rBegin Points to the start of the UTF-16 encoded string, must + not be null. On exit, it points past the first UTF-32 character's + encoding. + + @param pEnd Points past the end of the UTF-16 encoded string, must be + strictly greater than rBegin. + + @return The UCS-4 character at the head of the UTF-16 encoded string. + If the string does not start with the UTF-16 encoding of a UCS-32 + character, the first UTF-16 value is returned. + */ + static inline sal_uInt32 getUTF32Character(const sal_Unicode *& rBegin, + const sal_Unicode * pEnd); + + /** Put the UTF-16 encoding of a UTF-32 character into a buffer. + + @param pBuffer Points to a buffer, must not be null. + + @param nUTF32 An UTF-32 character, must be in the range 0..0x10FFFF. + + @return A pointer past the UTF-16 characters put into the buffer + (i.e., pBuffer + 1 or pBuffer + 2). + */ + static inline sal_Unicode * putUTF32Character(sal_Unicode * pBuffer, + sal_uInt32 nUTF32); +}; + +// static +inline bool INetMIME::isUSASCII(sal_uInt32 nChar) +{ + return nChar <= 0x7F; +} + +// static +inline bool INetMIME::isISO88591(sal_uInt32 nChar) +{ + return nChar <= 0xFF; +} + +// static +inline bool INetMIME::isControl(sal_uInt32 nChar) +{ + return nChar <= 0x1F || nChar == 0x7F; +} + +// static +inline bool INetMIME::isWhiteSpace(sal_uInt32 nChar) +{ + return nChar == '\t' || nChar == ' '; +} + +// static +inline bool INetMIME::isVisible(sal_uInt32 nChar) +{ + return nChar >= '!' && nChar <= '~'; +} + +// static +inline bool INetMIME::isDigit(sal_uInt32 nChar) +{ + return nChar >= '0' && nChar <= '9'; +} + +// static +inline bool INetMIME::isCanonicHexDigit(sal_uInt32 nChar) +{ + return isDigit(nChar) || (nChar >= 'A' && nChar <= 'F'); +} + +// static +inline bool INetMIME::isHexDigit(sal_uInt32 nChar) +{ + return isCanonicHexDigit(nChar) || (nChar >= 'a' && nChar <= 'f'); +} + +// static +inline bool INetMIME::isUpperCase(sal_uInt32 nChar) +{ + return nChar >= 'A' && nChar <= 'Z'; +} + +// static +inline bool INetMIME::isLowerCase(sal_uInt32 nChar) +{ + return nChar >= 'a' && nChar <= 'z'; +} + +// static +inline bool INetMIME::isAlpha(sal_uInt32 nChar) +{ + return isUpperCase(nChar) || isLowerCase(nChar); +} + +// static +inline bool INetMIME::isAlphanumeric(sal_uInt32 nChar) +{ + return isAlpha(nChar) || isDigit(nChar); +} + +// static +inline bool INetMIME::isBase64Digit(sal_uInt32 nChar) +{ + return isUpperCase(nChar) || isLowerCase(nChar) || isDigit(nChar) + || nChar == '+' || nChar == '/'; +} + +// static +inline sal_uInt32 INetMIME::toUpperCase(sal_uInt32 nChar) +{ + return isLowerCase(nChar) ? nChar - ('a' - 'A') : nChar; +} + +// static +inline sal_uInt32 INetMIME::toLowerCase(sal_uInt32 nChar) +{ + return isUpperCase(nChar) ? nChar + ('a' - 'A') : nChar; +} + +// static +inline int INetMIME::getWeight(sal_uInt32 nChar) +{ + return isDigit(nChar) ? int(nChar - '0') : -1; +} + +// static +inline int INetMIME::getHexWeight(sal_uInt32 nChar) +{ + return isDigit(nChar) ? int(nChar - '0') : + nChar >= 'A' && nChar <= 'F' ? int(nChar - 'A' + 10) : + nChar >= 'a' && nChar <= 'f' ? int(nChar - 'a' + 10) : -1; +} + +// static +inline int INetMIME::getBase64Weight(sal_uInt32 nChar) +{ + return isUpperCase(nChar) ? int(nChar - 'A') : + isLowerCase(nChar) ? int(nChar - 'a' + 26) : + isDigit(nChar) ? int(nChar - '0' + 52) : + nChar == '+' ? 62 : + nChar == '/' ? 63 : + nChar == '=' ? -1 : -2; +} + +// static +inline bool INetMIME::isHighSurrogate(sal_uInt32 nUTF16) +{ + return nUTF16 >= 0xD800 && nUTF16 <= 0xDBFF; +} + +// static +inline bool INetMIME::isLowSurrogate(sal_uInt32 nUTF16) +{ + return nUTF16 >= 0xDC00 && nUTF16 <= 0xDFFF; +} + +// static +inline sal_uInt32 INetMIME::toUTF32(sal_Unicode cHighSurrogate, + sal_Unicode cLowSurrogate) +{ + DBG_ASSERT(isHighSurrogate(cHighSurrogate) + && isLowSurrogate(cLowSurrogate), + "INetMIME::toUTF32(): Bad chars"); + return ((sal_uInt32(cHighSurrogate) & 0x3FF) << 10) + | (sal_uInt32(cLowSurrogate) & 0x3FF); +} + +// static +inline bool INetMIME::equalIgnoreCase(const ByteString & rString1, + const sal_Char * pString2) +{ + return equalIgnoreCase(rString1.GetBuffer(), + rString1.GetBuffer() + rString1.Len(), pString2); +} + +// static +inline bool INetMIME::startsWithLineBreak(const sal_Char * pBegin, + const sal_Char * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIME::startsWithLineBreak(): Bad sequence"); + + return pEnd - pBegin >= 2 && pBegin[0] == 0x0D && pBegin[1] == 0x0A; + // CR, LF +} + +// static +inline bool INetMIME::startsWithLineBreak(const sal_Unicode * pBegin, + const sal_Unicode * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIME::startsWithLineBreak(): Bad sequence"); + + return pEnd - pBegin >= 2 && pBegin[0] == 0x0D && pBegin[1] == 0x0A; + // CR, LF +} + +// static +inline bool INetMIME::startsWithLineFolding(const sal_Char * pBegin, + const sal_Char * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIME::startsWithLineFolding(): Bad sequence"); + + return pEnd - pBegin >= 3 && pBegin[0] == 0x0D && pBegin[1] == 0x0A + && isWhiteSpace(pBegin[2]); // CR, LF +} + +// static +inline bool INetMIME::startsWithLineFolding(const sal_Unicode * pBegin, + const sal_Unicode * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIME::startsWithLineFolding(): Bad sequence"); + + return pEnd - pBegin >= 3 && pBegin[0] == 0x0D && pBegin[1] == 0x0A + && isWhiteSpace(pBegin[2]); // CR, LF +} + +// static +inline bool INetMIME::startsWithLinearWhiteSpace(const sal_Char * pBegin, + const sal_Char * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIME::startsWithLinearWhiteSpace(): Bad sequence"); + + return pBegin != pEnd + && (isWhiteSpace(*pBegin) || startsWithLineFolding(pBegin, pEnd)); +} + +// static +inline bool INetMIME::needsQuotedStringEscape(sal_uInt32 nChar) +{ + return nChar == '"' || nChar == '\\'; +} + +// static +inline rtl_TextEncoding INetMIME::translateToMIME(rtl_TextEncoding eEncoding) +{ +#if defined WNT + return eEncoding == RTL_TEXTENCODING_MS_1252 ? + RTL_TEXTENCODING_ISO_8859_1 : eEncoding; +#else // WNT + return eEncoding; +#endif // WNT +} + +// static +inline rtl_TextEncoding INetMIME::translateFromMIME(rtl_TextEncoding + eEncoding) +{ +#if defined WNT + return eEncoding == RTL_TEXTENCODING_ISO_8859_1 ? + RTL_TEXTENCODING_MS_1252 : eEncoding; +#else // WNT + return eEncoding; +#endif // WNT +} + +// static +inline bool INetMIME::isMIMECharsetEncoding(rtl_TextEncoding eEncoding) +{ + return ( rtl_isOctetTextEncoding(eEncoding) == sal_True ); +} + +// static +inline int INetMIME::getUTF8OctetCount(sal_uInt32 nChar) +{ + DBG_ASSERT(nChar < 0x80000000, "INetMIME::getUTF8OctetCount(): Bad char"); + + return nChar < 0x80 ? 1 : + nChar < 0x800 ? 2 : + nChar <= 0x10000 ? 3 : + nChar <= 0x200000 ? 4 : + nChar <= 0x4000000 ? 5 : 6; +} + +// static +inline sal_uInt32 INetMIME::getUTF32Character(const sal_Unicode *& rBegin, + const sal_Unicode * pEnd) +{ + DBG_ASSERT(rBegin && rBegin < pEnd, + "INetMIME::getUTF32Character(): Bad sequence"); + if (rBegin + 1 < pEnd && rBegin[0] >= 0xD800 && rBegin[0] <= 0xDBFF + && rBegin[1] >= 0xDC00 && rBegin[1] <= 0xDFFF) + { + sal_uInt32 nUTF32 = sal_uInt32(*rBegin++ & 0x3FF) << 10; + return (nUTF32 | (*rBegin++ & 0x3FF)) + 0x10000; + } + else + return *rBegin++; +} + +// static +inline sal_Unicode * INetMIME::putUTF32Character(sal_Unicode * pBuffer, + sal_uInt32 nUTF32) +{ + DBG_ASSERT(nUTF32 <= 0x10FFFF, "INetMIME::putUTF32Character(): Bad char"); + if (nUTF32 < 0x10000) + *pBuffer++ = sal_Unicode(nUTF32); + else + { + nUTF32 -= 0x10000; + *pBuffer++ = sal_Unicode(0xD800 | (nUTF32 >> 10)); + *pBuffer++ = sal_Unicode(0xDC00 | (nUTF32 & 0x3FF)); + } + return pBuffer; +} + +//============================================================================ +class INetMIMEOutputSink +{ +public: + static sal_uInt32 const NO_LINE_LENGTH_LIMIT = SAL_MAX_UINT32; + +private: + sal_uInt32 m_nColumn; + sal_uInt32 m_nLineLengthLimit; + +protected: + /** Write a sequence of octets. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + virtual void writeSequence(const sal_Char * pBegin, + const sal_Char * pEnd) = 0; + + /** Write a null terminated sequence of octets (without the terminating + null). + + @param pOctets A null terminated sequence of octets, must not be + null. + + @return The length of pOctets (without the terminating null). + */ + virtual sal_Size writeSequence(const sal_Char * pSequence); + + /** Write a sequence of octets. + + @descr The supplied sequence of UCS-4 characters is interpreted as a + sequence of octets. It is an error if any of the elements of the + sequence has a numerical value greater than 255. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + virtual void writeSequence(const sal_uInt32 * pBegin, + const sal_uInt32 * pEnd); + + /** Write a sequence of octets. + + @descr The supplied sequence of Unicode characters is interpreted as + a sequence of octets. It is an error if any of the elements of the + sequence has a numerical value greater than 255. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + virtual void writeSequence(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + +public: + INetMIMEOutputSink(sal_uInt32 nTheColumn = 0, + sal_uInt32 nTheLineLengthLimit + = INetMIME::SOFT_LINE_LENGTH_LIMIT): + m_nColumn(nTheColumn), m_nLineLengthLimit(nTheLineLengthLimit) {} + + virtual ~INetMIMEOutputSink() {} + + /** Get the current column. + + @return The current column (starting from zero). + */ + sal_uInt32 getColumn() const { return m_nColumn; } + + sal_uInt32 getLineLengthLimit() const { return m_nLineLengthLimit; } + + void setLineLengthLimit(sal_uInt32 nTheLineLengthLimit) + { m_nLineLengthLimit = nTheLineLengthLimit; } + + virtual ErrCode getError() const; + + /** Write a sequence of octets. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + inline void write(const sal_Char * pBegin, const sal_Char * pEnd); + + /** Write a sequence of octets. + + @param pBegin Points to the start of the sequence, must not be null. + + @param nLength The length of the sequence. + */ + void write(const sal_Char * pBegin, sal_Size nLength) + { write(pBegin, pBegin + nLength); } + + /** Write a sequence of octets. + + @descr The supplied sequence of UCS-4 characters is interpreted as a + sequence of octets. It is an error if any of the elements of the + sequence has a numerical value greater than 255. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + inline void write(const sal_uInt32 * pBegin, const sal_uInt32 * pEnd); + + /** Write a sequence of octets. + + @descr The supplied sequence of Unicode characters is interpreted as + a sequence of octets. It is an error if any of the elements of the + sequence has a numerical value greater than 255. + + @param pBegin Points to the start of the sequence, must not be null. + + @param pEnd Points past the end of the sequence, must be >= pBegin. + */ + inline void write(const sal_Unicode * pBegin, const sal_Unicode * pEnd); + + /** Write a sequence of octets. + + @param rOctets A ByteString, interpreted as a sequence of octets. + + @param nBegin The offset of the first character to write. + + @param nEnd The offset past the last character to write. + */ + inline void write(const ByteString & rString, xub_StrLen nBegin, + xub_StrLen nEnd); + + /** Write a single octet. + + @param nOctet Some octet. + + @return This instance. + */ + inline INetMIMEOutputSink & operator <<(sal_Char nOctet); + + /** Write a null terminated sequence of octets (without the terminating + null). + + @param pOctets A null terminated sequence of octets, must not be + null. + + @return This instance. + */ + inline INetMIMEOutputSink & operator <<(const sal_Char * pOctets); + + /** Write a sequence of octets. + + @param rOctets A ByteString, interpreted as a sequence of octets. + + @return This instance. + */ + inline INetMIMEOutputSink & operator <<(const ByteString & rOctets); + + /** Call a manipulator function. + + @param pManipulator A manipulator function. + + @return Whatever the manipulator function returns. + */ + INetMIMEOutputSink & + operator <<(INetMIMEOutputSink & (* pManipulator)(INetMIMEOutputSink &)) + { return pManipulator(*this); } + + /** Write a line end (CR LF). + */ + void writeLineEnd(); + + /** A manipulator function that writes a line end (CR LF). + + @param rSink Some sink. + + @return The sink rSink. + */ + static inline INetMIMEOutputSink & endl(INetMIMEOutputSink & rSink); +}; + +inline void INetMIMEOutputSink::write(const sal_Char * pBegin, + const sal_Char * pEnd) +{ + writeSequence(pBegin, pEnd); + m_nColumn += pEnd - pBegin; +} + +inline void INetMIMEOutputSink::write(const sal_uInt32 * pBegin, + const sal_uInt32 * pEnd) +{ + writeSequence(pBegin, pEnd); + m_nColumn += pEnd - pBegin; +} + +inline void INetMIMEOutputSink::write(const sal_Unicode * pBegin, + const sal_Unicode * pEnd) +{ + writeSequence(pBegin, pEnd); + m_nColumn += pEnd - pBegin; +} + +inline void INetMIMEOutputSink::write(const ByteString & rOctets, + xub_StrLen nBegin, xub_StrLen nEnd) +{ + writeSequence(rOctets.GetBuffer() + nBegin, rOctets.GetBuffer() + nEnd); + m_nColumn += nEnd - nBegin; +} + +inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(sal_Char nOctet) +{ + writeSequence(&nOctet, &nOctet + 1); + ++m_nColumn; + return *this; +} + +inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const sal_Char * + pOctets) +{ + m_nColumn += writeSequence(pOctets); + return *this; +} + +inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const ByteString & + rOctets) +{ + writeSequence(rOctets.GetBuffer(), rOctets.GetBuffer() + rOctets.Len()); + m_nColumn += rOctets.Len(); + return *this; +} + +// static +inline INetMIMEOutputSink & INetMIMEOutputSink::endl(INetMIMEOutputSink & + rSink) +{ + rSink.writeLineEnd(); + return rSink; +} + +// static +inline void INetMIME::writeEscapeSequence(INetMIMEOutputSink & rSink, + sal_uInt32 nChar) +{ + DBG_ASSERT(nChar <= 0xFF, "INetMIME::writeEscapeSequence(): Bad char"); + rSink << '=' << sal_uInt8(getHexDigit(nChar >> 4)) + << sal_uInt8(getHexDigit(nChar & 15)); +} + +//============================================================================ +class INetMIMEStringOutputSink: public INetMIMEOutputSink +{ + ByteString m_aBuffer; + bool m_bOverflow; + + using INetMIMEOutputSink::writeSequence; + + virtual void writeSequence(const sal_Char * pBegin, + const sal_Char * pEnd); + +public: + inline INetMIMEStringOutputSink(sal_uInt32 nColumn = 0, + sal_uInt32 nLineLengthLimit + = INetMIME::SOFT_LINE_LENGTH_LIMIT): + INetMIMEOutputSink(nColumn, nLineLengthLimit), m_bOverflow(false) {} + + virtual ErrCode getError() const; + + inline ByteString takeBuffer(); +}; + +inline ByteString INetMIMEStringOutputSink::takeBuffer() +{ + ByteString aTheBuffer = m_aBuffer; + m_aBuffer.Erase(); + m_bOverflow = false; + return aTheBuffer; +} + +//============================================================================ +class INetMIMEUnicodeOutputSink: public INetMIMEOutputSink +{ + UniString m_aBuffer; + bool m_bOverflow; + + using INetMIMEOutputSink::writeSequence; + + virtual void writeSequence(const sal_Char * pBegin, + const sal_Char * pEnd); + + virtual void writeSequence(const sal_uInt32 * pBegin, + const sal_uInt32 * pEnd); + + virtual void writeSequence(const sal_Unicode * pBegin, + const sal_Unicode * pEnd); + +public: + inline INetMIMEUnicodeOutputSink(sal_uInt32 nColumn = 0, + sal_uInt32 nLineLengthLimit + = INetMIME::SOFT_LINE_LENGTH_LIMIT): + INetMIMEOutputSink(nColumn, nLineLengthLimit), m_bOverflow(false) {} + + virtual ErrCode getError() const; + + inline UniString takeBuffer(); +}; + +inline UniString INetMIMEUnicodeOutputSink::takeBuffer() +{ + UniString aTheBuffer = m_aBuffer; + m_aBuffer.Erase(); + m_bOverflow = false; + return aTheBuffer; +} + +//============================================================================ +class INetMIMEEncodedWordOutputSink +{ +public: + enum Context { CONTEXT_TEXT = 1, + CONTEXT_COMMENT = 2, + CONTEXT_PHRASE = 4 }; + + enum Space { SPACE_NO, SPACE_ENCODED, SPACE_ALWAYS }; + +private: + enum { BUFFER_SIZE = 256 }; + + enum Coding { CODING_NONE, CODING_QUOTED, CODING_ENCODED, + CODING_ENCODED_TERMINATED }; + + enum EncodedWordState { STATE_INITIAL, STATE_FIRST_EQUALS, + STATE_FIRST_QUESTION, STATE_CHARSET, + STATE_SECOND_QUESTION, STATE_ENCODING, + STATE_THIRD_QUESTION, STATE_ENCODED_TEXT, + STATE_FOURTH_QUESTION, STATE_SECOND_EQUALS, + STATE_BAD }; + + INetMIMEOutputSink & m_rSink; + Context m_eContext; + Space m_eInitialSpace; + sal_uInt32 m_nExtraSpaces; + INetMIMECharsetList_Impl * m_pEncodingList; + sal_Unicode * m_pBuffer; + sal_uInt32 m_nBufferSize; + sal_Unicode * m_pBufferEnd; + Coding m_ePrevCoding; + rtl_TextEncoding m_ePrevMIMEEncoding; + Coding m_eCoding; + sal_uInt32 m_nQuotedEscaped; + EncodedWordState m_eEncodedWordState; + + inline bool needsEncodedWordEscape(sal_uInt32 nChar) const; + + void finish(bool bWriteTrailer); + +public: + inline INetMIMEEncodedWordOutputSink(INetMIMEOutputSink & rTheSink, + Context eTheContext, + Space eTheInitialSpace, + rtl_TextEncoding ePreferredEncoding); + + ~INetMIMEEncodedWordOutputSink(); + + INetMIMEEncodedWordOutputSink & operator <<(sal_uInt32 nChar); + + inline void write(const sal_Char * pBegin, const sal_Char * pEnd); + + inline void write(const sal_Unicode * pBegin, const sal_Unicode * pEnd); + + inline bool flush(); +}; + +inline INetMIMEEncodedWordOutputSink::INetMIMEEncodedWordOutputSink( + INetMIMEOutputSink & rTheSink, Context eTheContext, + Space eTheInitialSpace, rtl_TextEncoding ePreferredEncoding): + m_rSink(rTheSink), + m_eContext(eTheContext), + m_eInitialSpace(eTheInitialSpace), + m_nExtraSpaces(0), + m_pEncodingList(INetMIME::createPreferredCharsetList(ePreferredEncoding)), + m_ePrevCoding(CODING_NONE), + m_eCoding(CODING_NONE), + m_nQuotedEscaped(0), + m_eEncodedWordState(STATE_INITIAL) +{ + m_nBufferSize = BUFFER_SIZE; + m_pBuffer = static_cast< sal_Unicode * >(rtl_allocateMemory( + m_nBufferSize + * sizeof (sal_Unicode))); + m_pBufferEnd = m_pBuffer; +} + +inline void INetMIMEEncodedWordOutputSink::write(const sal_Char * pBegin, + const sal_Char * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIMEEncodedWordOutputSink::write(): Bad sequence"); + + while (pBegin != pEnd) + operator <<(*pBegin++); +} + +inline void INetMIMEEncodedWordOutputSink::write(const sal_Unicode * pBegin, + const sal_Unicode * pEnd) +{ + DBG_ASSERT(pBegin && pBegin <= pEnd, + "INetMIMEEncodedWordOutputSink::write(): Bad sequence"); + + while (pBegin != pEnd) + operator <<(*pBegin++); +} + +inline bool INetMIMEEncodedWordOutputSink::flush() +{ + finish(true); + return m_ePrevCoding != CODING_NONE; +} + +//============================================================================ +struct INetContentTypeParameter +{ + /** The name of the attribute, in US-ASCII encoding and converted to lower + case. If a parameter value is split as described in RFC 2231, there + will only be one item for the complete parameter, with the attribute + name lacking any section suffix. + */ + const ByteString m_sAttribute; + + /** The optional character set specification (see RFC 2231), in US-ASCII + encoding and converted to lower case. + */ + const ByteString m_sCharset; + + /** The optional language specification (see RFC 2231), in US-ASCII + encoding and converted to lower case. + */ + const ByteString m_sLanguage; + + /** The attribute value. If the value is a quoted-string, it is + 'unpacked.' If a character set is specified, and the value can be + converted to Unicode, this is done. Also, if no character set is + specified, it is first tried to convert the value from UTF-8 encoding + to Unicode, and if that doesn't work (because the value is not in + UTF-8 encoding), it is converted from ISO-8859-1 encoding to Unicode + (which will always work). But if a character set is specified and the + value cannot be converted from that character set to Unicode, special + action is taken to produce a value that can possibly be transformed + back into its original form: Any 8-bit character from a non-encoded + part of the original value is directly converted to Unicode + (effectively handling it as if it was ISO-8859-1 encoded), and any + 8-bit character from an encoded part of the original value is mapped + to the range U+F800..U+F8FF at the top of the Corporate Use Subarea + within Unicode's Private Use Area (effectively adding 0xF800 to the + character's numeric value). + */ + const UniString m_sValue; + + /** This is true if the value is successfuly converted to Unicode, and + false if the value is a special mixture of ISO-LATIN-1 characters and + characters from Unicode's Private Use Area. + */ + const bool m_bConverted; + + inline INetContentTypeParameter(const ByteString & rTheAttribute, + const ByteString & rTheCharset, + const ByteString & rTheLanguage, + const UniString & rTheValue, + bool bTheConverted); +}; + +inline INetContentTypeParameter::INetContentTypeParameter(const ByteString & + rTheAttribute, + const ByteString & + rTheCharset, + const ByteString & + rTheLanguage, + const UniString & + rTheValue, + bool bTheConverted): + m_sAttribute(rTheAttribute), + m_sCharset(rTheCharset), + m_sLanguage(rTheLanguage), + m_sValue(rTheValue), + m_bConverted(bTheConverted) +{} + +//============================================================================ +class TOOLS_DLLPUBLIC INetContentTypeParameterList: private List +{ +public: + ~INetContentTypeParameterList() { Clear(); } + + using List::Count; + + void Clear(); + + void Insert(INetContentTypeParameter * pParameter, ULONG nIndex) + { List::Insert(pParameter, nIndex); } + + inline const INetContentTypeParameter * GetObject(ULONG nIndex) const; + + const INetContentTypeParameter * find(const ByteString & rAttribute) + const; +}; + +inline const INetContentTypeParameter * +INetContentTypeParameterList::GetObject(ULONG nIndex) const +{ + return static_cast< INetContentTypeParameter * >(List::GetObject(nIndex)); +} + +#endif // TOOLS_INETMIME_HXX + diff --git a/tools/inc/tools/inetmsg.hxx b/tools/inc/tools/inetmsg.hxx new file mode 100644 index 000000000000..d7619fc34a4d --- /dev/null +++ b/tools/inc/tools/inetmsg.hxx @@ -0,0 +1,623 @@ +/************************************************************************* + * + * 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 _TOOLS_INETMSG_HXX +#define _TOOLS_INETMSG_HXX + +#include "tools/toolsdllapi.h" +#include <sal/types.h> + +#ifndef _RTL_TEXTENC_H_ +#include <rtl/textenc.h> +#endif + +#ifndef _TOOLS_INETMIME_HXX +#include <tools/inetmime.hxx> +#endif +#include <tools/list.hxx> +#include <tools/stream.hxx> +#include <tools/string.hxx> + +class DateTime; + +/*======================================================================= + * + * INetMessageHeader Interface. + * + *=====================================================================*/ +class INetMessageHeader +{ + ByteString m_aName; + ByteString m_aValue; + +public: + INetMessageHeader (void) + {} + + INetMessageHeader ( + const ByteString& rName, const ByteString& rValue) + : m_aName (rName), m_aValue (rValue) + {} + + INetMessageHeader ( + const INetMessageHeader& rHdr) + : m_aName (rHdr.m_aName), m_aValue (rHdr.m_aValue) + {} + + ~INetMessageHeader (void) + {} + + INetMessageHeader& operator= (const INetMessageHeader& rHdr) + { + m_aName = rHdr.m_aName; + m_aValue = rHdr.m_aValue; + return *this; + } + + const ByteString& GetName (void) const { return m_aName; } + const ByteString& GetValue (void) const { return m_aValue; } + + friend SvStream& operator<< ( + SvStream& rStrm, const INetMessageHeader& rHdr) + { +#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS + rStrm << rHdr.m_aName; + rStrm << rHdr.m_aValue; +#else + rStrm.WriteByteString (rHdr.m_aName); + rStrm.WriteByteString (rHdr.m_aValue); +#endif + return rStrm; + } + + friend SvStream& operator>> ( + SvStream& rStrm, INetMessageHeader& rHdr) + { +#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS + rStrm >> rHdr.m_aName; + rStrm >> rHdr.m_aValue; +#else + rStrm.ReadByteString (rHdr.m_aName); + rStrm.ReadByteString (rHdr.m_aValue); +#endif + return rStrm; + } +}; + +/*======================================================================= + * + * INetMessage Interface. + * + *=====================================================================*/ +class INetMessage +{ + List m_aHeaderList; + + ULONG m_nDocSize; + UniString m_aDocName; + SvLockBytesRef m_xDocLB; + + void ListCleanup_Impl (void); + void ListCopy (const INetMessage& rMsg); + +protected: + UniString GetHeaderName_Impl ( + ULONG nIndex, rtl_TextEncoding eEncoding) const + { + INetMessageHeader *p = + (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); + if (p) + return UniString(p->GetName(), eEncoding); + else + return UniString(); + } + + UniString GetHeaderValue_Impl ( + ULONG nIndex, INetMIME::HeaderFieldType eType) const + { + INetMessageHeader *p = + (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); + if (p) + return INetMIME::decodeHeaderFieldBody (eType, p->GetValue()); + else + return UniString(); + } + + void SetHeaderField_Impl ( + const INetMessageHeader &rHeader, ULONG &rnIndex) + { + INetMessageHeader *p = new INetMessageHeader (rHeader); + if (m_aHeaderList.Count() <= rnIndex) + { + m_aHeaderList.Insert (p, LIST_APPEND); + rnIndex = m_aHeaderList.Count() - 1; + } + else + { + p = (INetMessageHeader*)(m_aHeaderList.Replace(p, rnIndex)); + delete p; + } + } + + void SetHeaderField_Impl ( + INetMIME::HeaderFieldType eType, + const ByteString &rName, + const UniString &rValue, + ULONG &rnIndex); + + virtual SvStream& operator<< (SvStream& rStrm) const; + virtual SvStream& operator>> (SvStream& rStrm); + +public: + INetMessage (void) : m_nDocSize(0) {} + virtual ~INetMessage (void); + + INetMessage (const INetMessage& rMsg) + : m_nDocSize (rMsg.m_nDocSize), + m_aDocName (rMsg.m_aDocName), + m_xDocLB (rMsg.m_xDocLB) + { + ListCopy (rMsg); + } + + INetMessage& operator= (const INetMessage& rMsg) + { + m_nDocSize = rMsg.m_nDocSize; + m_aDocName = rMsg.m_aDocName; + m_xDocLB = rMsg.m_xDocLB; + ListCopy (rMsg); + return *this; + } + + ULONG GetHeaderCount (void) const { return m_aHeaderList.Count(); } + + UniString GetHeaderName (ULONG nIndex) const + { + return GetHeaderName_Impl (nIndex, RTL_TEXTENCODING_ASCII_US); + } + + UniString GetHeaderValue (ULONG nIndex) const + { + return GetHeaderValue_Impl (nIndex, INetMIME::HEADER_FIELD_TEXT); + } + + INetMessageHeader GetHeaderField (ULONG nIndex) const + { + INetMessageHeader *p = + (INetMessageHeader*)(m_aHeaderList.GetObject(nIndex)); + if (p) + return INetMessageHeader(*p); + else + return INetMessageHeader(); + } + + ULONG SetHeaderField ( + const UniString& rName, + const UniString& rValue, + ULONG nIndex = LIST_APPEND); + + virtual ULONG SetHeaderField ( + const INetMessageHeader &rField, ULONG nIndex = LIST_APPEND); + + ULONG GetDocumentSize (void) const { return m_nDocSize; } + void SetDocumentSize (ULONG nSize) { m_nDocSize = nSize; } + + const UniString& GetDocumentName (void) const { return m_aDocName; } + void SetDocumentName (const UniString& rName) { m_aDocName = rName; } + + SvLockBytes* GetDocumentLB (void) const { return m_xDocLB; } + void SetDocumentLB (SvLockBytes *pDocLB) { m_xDocLB = pDocLB; } + + friend SvStream& operator<< ( + SvStream& rStrm, const INetMessage& rMsg) + { + return rMsg.operator<< (rStrm); + } + + friend SvStream& operator>> ( + SvStream& rStrm, INetMessage& rMsg) + { + return rMsg.operator>> (rStrm); + } +}; + +/*======================================================================= + * + * INetMessageHeaderIterator Interface. + * + *=====================================================================*/ +class INetMessageHeaderIterator +{ + ULONG nValueCount; + List aValueList; + UniString aEmptyString; + +public: + INetMessageHeaderIterator ( + const INetMessage& rMsg, const UniString& rHdrName); + virtual ~INetMessageHeaderIterator (void); + + ULONG GetValueCount (void) const { return nValueCount; } + const UniString& GetValue (ULONG nIndex) const + { + if (nIndex < nValueCount) + { + return *((UniString*)(aValueList.GetObject(nIndex))); + } + else + { + return aEmptyString; + } + } +}; + +/*======================================================================= + * + * INetRFC822Message Interface. + * + *=====================================================================*/ +#define INETMSG_RFC822_BCC 0 +#define INETMSG_RFC822_CC 1 +#define INETMSG_RFC822_COMMENTS 2 +#define INETMSG_RFC822_DATE 3 +#define INETMSG_RFC822_FROM 4 +#define INETMSG_RFC822_IN_REPLY_TO 5 +#define INETMSG_RFC822_KEYWORDS 6 +#define INETMSG_RFC822_MESSAGE_ID 7 +#define INETMSG_RFC822_REFERENCES 8 +#define INETMSG_RFC822_REPLY_TO 9 +#define INETMSG_RFC822_RETURN_PATH 10 +#define INETMSG_RFC822_SENDER 11 +#define INETMSG_RFC822_SUBJECT 12 +#define INETMSG_RFC822_TO 13 + +#define INETMSG_RFC822_X_MAILER 14 +#define INETMSG_RFC822_RETURN_RECEIPT_TO 15 + +#define INETMSG_RFC822_NUMHDR 16 + +class TOOLS_DLLPUBLIC INetRFC822Message : public INetMessage +{ + ULONG m_nIndex[INETMSG_RFC822_NUMHDR]; + +protected: + virtual SvStream& operator<< (SvStream& rStrm) const; + virtual SvStream& operator>> (SvStream& rStrm); + +public: + INetRFC822Message (void); + INetRFC822Message (const INetRFC822Message& rMsg); + virtual ~INetRFC822Message (void); + + INetRFC822Message& operator= (const INetRFC822Message& rMsg); + + static BOOL GenerateDateField ( + const DateTime& rDateTime, UniString& rDateField); + static BOOL ParseDateField ( + const UniString& rDateField, DateTime& rDateTime); + + using INetMessage::SetHeaderField; + virtual ULONG SetHeaderField ( + const INetMessageHeader &rHeader, ULONG nIndex = LIST_APPEND); + + /** Header fields. + */ + void SetBCC (const UniString& rBCC); + UniString GetBCC (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_BCC], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetCC (const UniString& rCC); + UniString GetCC (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_CC], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetComments (const UniString& rComments); + UniString GetComments (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_COMMENTS], + INetMIME::HEADER_FIELD_TEXT); + } + + void SetDate (const UniString& rDate); + UniString GetDate (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_DATE], + INetMIME::HEADER_FIELD_STRUCTURED); + } + + void SetFrom (const UniString& rFrom); + UniString GetFrom (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_FROM], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetInReplyTo (const UniString& rInReplyTo); + UniString GetInReplyTo (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_IN_REPLY_TO], + INetMIME::HEADER_FIELD_ADDRESS); // ??? MESSAGE_ID ??? + } + + void SetKeywords (const UniString& rKeywords); + UniString GetKeywords (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_KEYWORDS], + INetMIME::HEADER_FIELD_PHRASE); + } + + void SetMessageID (const UniString& rMessageID); + UniString GetMessageID (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_MESSAGE_ID], + INetMIME::HEADER_FIELD_MESSAGE_ID); + } + + void SetReferences (const UniString& rReferences); + UniString GetReferences (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_REFERENCES], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetReplyTo (const UniString& rReplyTo); + UniString GetReplyTo (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_REPLY_TO], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetReturnPath (const UniString& rReturnPath); + UniString GetReturnPath (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_RETURN_PATH], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetReturnReceiptTo (const UniString& rReturnReceiptTo); + UniString GetReturnReceiptTo (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_RETURN_RECEIPT_TO], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetSender (const UniString& rSender); + UniString GetSender (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_SENDER], + INetMIME::HEADER_FIELD_ADDRESS); + } + + void SetSubject (const UniString& rSubject); + UniString GetSubject (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_SUBJECT], + INetMIME::HEADER_FIELD_TEXT); + } + + void SetTo (const UniString& rTo); + UniString GetTo (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_TO], + INetMIME::HEADER_FIELD_TEXT); + } + + void SetXMailer (const UniString& rXMailer); + UniString GetXMailer (void) const + { + return GetHeaderValue_Impl ( + m_nIndex[INETMSG_RFC822_X_MAILER], + INetMIME::HEADER_FIELD_TEXT); + } + + /** Stream operators. + */ + friend SvStream& operator<< ( + SvStream& rStrm, const INetRFC822Message& rMsg) + { + return rMsg.operator<< (rStrm); + } + + friend SvStream& operator>> ( + SvStream& rStrm, INetRFC822Message& rMsg) + { + return rMsg.operator>> (rStrm); + } +}; + +/*======================================================================= + * + * INetMIMEMessage Interface. + * + *=====================================================================*/ +#define INETMSG_MIME_VERSION 0 +#define INETMSG_MIME_CONTENT_DESCRIPTION 1 +#define INETMSG_MIME_CONTENT_DISPOSITION 2 +#define INETMSG_MIME_CONTENT_ID 3 +#define INETMSG_MIME_CONTENT_TYPE 4 +#define INETMSG_MIME_CONTENT_TRANSFER_ENCODING 5 + +#define INETMSG_MIME_NUMHDR 6 + +enum INetMessageContainerType +{ + INETMSG_MESSAGE_RFC822, + INETMSG_MULTIPART_MIXED, + INETMSG_MULTIPART_ALTERNATIVE, + INETMSG_MULTIPART_DIGEST, + INETMSG_MULTIPART_PARALLEL, + INETMSG_MULTIPART_RELATED, + INETMSG_MULTIPART_FORM_DATA +}; + +class TOOLS_DLLPUBLIC INetMIMEMessage : public INetRFC822Message +{ + ULONG m_nIndex[INETMSG_MIME_NUMHDR]; + + INetMIMEMessage *pParent; + ULONG nNumChildren; + List aChildren; + ByteString m_aBoundary; + BOOL bHeaderParsed; + + friend class INetMIMEMessageStream; + + void SetChildCount (ULONG nCount) { nNumChildren = nCount; } + const ByteString& GetMultipartBoundary (void) const { return m_aBoundary; } + void SetMultipartBoundary (const ByteString& rBnd) { m_aBoundary = rBnd; } + + void CleanupImp (void); + void CopyImp (const INetMIMEMessage& rMsg); + void SetHeaderParsed() { bHeaderParsed = TRUE; } + +protected: + virtual SvStream& operator<< (SvStream& rStrm) const; + virtual SvStream& operator>> (SvStream& rStrm); + +public: + INetMIMEMessage (void); + INetMIMEMessage (const INetMIMEMessage& rMsg); + virtual ~INetMIMEMessage (void); + + INetMIMEMessage& operator= (const INetMIMEMessage& rMsg); + + BOOL HeaderParsed() const { return bHeaderParsed; } + + virtual INetMIMEMessage* CreateMessage ( + const INetMIMEMessage& rMsg) const; + + using INetRFC822Message::SetHeaderField; + virtual ULONG SetHeaderField ( + const INetMessageHeader &rHeader, ULONG nIndex = LIST_APPEND); + + /** Header fields. + */ + void SetMIMEVersion (const UniString& rVersion); + UniString GetMIMEVersion (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_VERSION]); + } + + void SetContentDescription (const UniString& rDescription); + UniString GetContentDescription (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DESCRIPTION]); + } + + void SetContentDisposition (const UniString& rDisposition); + UniString GetContentDisposition (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_DISPOSITION]); + } + + void SetContentID (const UniString& rID); + UniString GetContentID (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_ID]); + } + + void SetContentType (const UniString& rType); + UniString GetContentType (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TYPE]); + } + + void SetContentTransferEncoding (const UniString& rEncoding); + UniString GetContentTransferEncoding (void) const + { + return GetHeaderValue (m_nIndex[INETMSG_MIME_CONTENT_TRANSFER_ENCODING]); + } + + virtual void GetDefaultContentType (UniString& rContentType); + + /** Message container methods. + */ + BOOL IsContainer (void) const + { + return (IsMessage() || IsMultipart()); + } + BOOL IsMessage (void) const + { + UniString aType (GetContentType()); + return (aType.CompareIgnoreCaseToAscii("message/", 8) == 0); + } + BOOL IsMultipart (void) const + { + UniString aType (GetContentType()); + return (aType.CompareIgnoreCaseToAscii("multipart/", 10) == 0); + } + + ULONG GetChildCount (void) const { return nNumChildren; } + INetMIMEMessage* GetChild (ULONG nIndex) const + { + return ((INetMIMEMessage *)(aChildren.GetObject (nIndex))); + } + INetMIMEMessage* GetParent (void) const { return pParent; } + + BOOL EnableAttachChild ( + INetMessageContainerType eType = INETMSG_MULTIPART_MIXED); + BOOL AttachChild ( + INetMIMEMessage& rChildMsg, BOOL bOwner = TRUE); + BOOL DetachChild ( + ULONG nIndex, INetMIMEMessage& rChildMsg) const; + + /** Stream operators. + */ + friend SvStream& operator<< ( + SvStream& rStrm, const INetMIMEMessage& rMsg) + { + return rMsg.operator<< (rStrm); + } + + friend SvStream& operator>> ( + SvStream& rStrm, INetMIMEMessage& rMsg) + { + return rMsg.operator>> (rStrm); + } +}; + +#endif /* !_TOOLS_INETMSG_HXX */ + diff --git a/tools/inc/tools/inetstrm.hxx b/tools/inc/tools/inetstrm.hxx new file mode 100644 index 000000000000..1fd9a913b382 --- /dev/null +++ b/tools/inc/tools/inetstrm.hxx @@ -0,0 +1,275 @@ +/************************************************************************* + * + * 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 _TOOLS_INETSTRM_HXX +#define _TOOLS_INETSTRM_HXX + +#include "tools/toolsdllapi.h" +#include <sal/types.h> +#include <tools/string.hxx> + +class INetMessage; +class INetMIMEMessage; +class INetHTTPMessage; +class SvMemoryStream; +class SvStream; + +/*========================================================================= + * + * INetStream Interface. + * + *=======================================================================*/ +enum INetStreamStatus +{ + INETSTREAM_STATUS_LOADED = -4, + INETSTREAM_STATUS_WOULDBLOCK = -3, + INETSTREAM_STATUS_OK = -2, + INETSTREAM_STATUS_ERROR = -1 +}; + +/* + * INetIStream. + */ +class TOOLS_DLLPUBLIC INetIStream +{ + // Not implemented. + INetIStream (const INetIStream& rStrm); + INetIStream& operator= (const INetIStream& rStrm); + +protected: + virtual int GetData (sal_Char *pData, ULONG nSize) = 0; + +public: + INetIStream (); + virtual ~INetIStream (void); + + int Read (sal_Char *pData, ULONG nSize); + + static void Decode64 (SvStream& rIn, SvStream& rOut); + static void Encode64 (SvStream& rIn, SvStream& rOut); +}; + +/* + * INetOStream. + */ +class INetOStream +{ + // Not implemented. + INetOStream (const INetOStream& rStrm); + INetOStream& operator= (const INetOStream& rStrm); + +protected: + virtual int PutData ( + const sal_Char *pData, ULONG nSize) = 0; + +public: + INetOStream (); + virtual ~INetOStream (void); + + int Write (const sal_Char *pData, ULONG nSize); +}; + +/* + * INetIOStream. + */ +class INetIOStream : public INetIStream, public INetOStream +{ + // Not implemented. + INetIOStream (const INetIOStream& rStrm); + INetIOStream& operator= (const INetIOStream& rStrm); + +public: + INetIOStream (ULONG nIBufferSize = 0, ULONG nOBufferSize = 0); + virtual ~INetIOStream (void); +}; + +/*========================================================================= + * + * INetMessageStream Interface. + * + *=======================================================================*/ +enum INetMessageStreamState +{ + INETMSG_EOL_BEGIN, + INETMSG_EOL_DONE, + INETMSG_EOL_SCR, + INETMSG_EOL_FCR, + INETMSG_EOL_FLF, + INETMSG_EOL_FSP, + INETMSG_EOL_FESC +}; + +/* + * INetMessageIStream (Message Generator) Interface. + */ +class INetMessageIStream : public INetIStream +{ + INetMessage *pSourceMsg; + BOOL bHeaderGenerated; + + ULONG nBufSiz; + sal_Char *pBuffer; + sal_Char *pRead; + sal_Char *pWrite; + + SvStream *pMsgStrm; + SvMemoryStream *pMsgBuffer; + sal_Char *pMsgRead; + sal_Char *pMsgWrite; + + virtual int GetData (sal_Char *pData, ULONG nSize); + + // Not implemented. + INetMessageIStream (const INetMessageIStream& rStrm); + INetMessageIStream& operator= (const INetMessageIStream& rStrm); + +protected: + virtual int GetMsgLine (sal_Char *pData, ULONG nSize); + +public: + INetMessageIStream (ULONG nBufferSize = 2048); + virtual ~INetMessageIStream (void); + + INetMessage *GetSourceMessage (void) const { return pSourceMsg; } + void SetSourceMessage (INetMessage *pMsg) { pSourceMsg = pMsg; } + + void GenerateHeader (BOOL bGen = TRUE) { bHeaderGenerated = !bGen; } + BOOL IsHeaderGenerated (void) const { return bHeaderGenerated; } +}; + +/* + * INetMessageOStream (Message Parser) Interface. + */ +class INetMessageOStream : public INetOStream +{ + INetMessage *pTargetMsg; + BOOL bHeaderParsed; + + INetMessageStreamState eOState; + + SvMemoryStream *pMsgBuffer; + + virtual int PutData (const sal_Char *pData, ULONG nSize); + + // Not implemented. + INetMessageOStream (const INetMessageOStream& rStrm); + INetMessageOStream& operator= (const INetMessageOStream& rStrm); + +protected: + virtual int PutMsgLine (const sal_Char *pData, ULONG nSize); + +public: + INetMessageOStream (void); + virtual ~INetMessageOStream (void); + + INetMessage *GetTargetMessage (void) const { return pTargetMsg; } + void SetTargetMessage (INetMessage *pMsg) { pTargetMsg = pMsg; } + + void ParseHeader (BOOL bParse = TRUE) { bHeaderParsed = !bParse; } + BOOL IsHeaderParsed (void) const { return bHeaderParsed; } +}; + +/* + * INetMessageIOStream Interface. + */ +class INetMessageIOStream + : public INetMessageIStream, + public INetMessageOStream +{ + // Not implemented. + INetMessageIOStream (const INetMessageIOStream& rStrm); + INetMessageIOStream& operator= (const INetMessageIOStream& rStrm); + +public: + INetMessageIOStream (ULONG nBufferSize = 2048); + virtual ~INetMessageIOStream (void); +}; + +/*========================================================================= + * + * INetMIMEMessageStream Interface. + * + *=======================================================================*/ +enum INetMessageEncoding +{ + INETMSG_ENCODING_7BIT, + INETMSG_ENCODING_8BIT, + INETMSG_ENCODING_BINARY, + INETMSG_ENCODING_QUOTED, + INETMSG_ENCODING_BASE64 +}; + +class TOOLS_DLLPUBLIC INetMIMEMessageStream : public INetMessageIOStream +{ + int eState; + + ULONG nChildIndex; + INetMIMEMessageStream *pChildStrm; + + INetMessageEncoding eEncoding; + INetMessageIStream *pEncodeStrm; + INetMessageOStream *pDecodeStrm; + + SvMemoryStream *pMsgBuffer; + + static INetMessageEncoding GetMsgEncoding ( + const String& rContentType); + + // Not implemented. + INetMIMEMessageStream (const INetMIMEMessageStream& rStrm); + INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm); + +protected: + virtual int GetMsgLine (sal_Char *pData, ULONG nSize); + virtual int PutMsgLine (const sal_Char *pData, ULONG nSize); + +public: + INetMIMEMessageStream (ULONG nBufferSize = 2048); + virtual ~INetMIMEMessageStream (void); + + using INetMessageIStream::SetSourceMessage; + void SetSourceMessage (INetMIMEMessage *pMsg) + { + INetMessageIStream::SetSourceMessage ((INetMessage *)pMsg); + } + INetMIMEMessage *GetSourceMessage (void) const + { + return ((INetMIMEMessage *)INetMessageIStream::GetSourceMessage()); + } + + using INetMessageOStream::SetTargetMessage; + void SetTargetMessage (INetMIMEMessage *pMsg) + { + INetMessageOStream::SetTargetMessage ((INetMessage *)pMsg); + } + INetMIMEMessage *GetTargetMessage (void) const + { + return ((INetMIMEMessage *)INetMessageOStream::GetTargetMessage()); + } +}; + +#endif /* !_TOOLS_INETSTRM_HXX */ + diff --git a/tools/inc/tools/iparser.hxx b/tools/inc/tools/iparser.hxx new file mode 100644 index 000000000000..78eed43e8391 --- /dev/null +++ b/tools/inc/tools/iparser.hxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * 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 IPARSER_HXX +#define IPARSER_HXX + +#include <tools/string.hxx> +#include <tools/link.hxx> +#include <tools/stream.hxx> +#include "tools/toolsdllapi.h" + +// forwards +class Dir; +class GenericInformation; +class GenericInformationList; + +// +// class InformationParser +// + +/****************************************************************************** +Purpose: reads generic information files into a simple structure in memory +******************************************************************************/ + +// information files used by this parser have following format: + +/* + +key [value] +{ + key [value] + key [value] + { + key [value] + ... + ... + } +} +key [value] +... +... + +*/ + +#define DEF_STAND_LST "\\\\dev4\\data1\\b_server\\config\\stand.lst" + +// error codes: + +#define IP_NO_ERROR 0x0000 +#define IP_UNEXPECTED_EOF 0x0001 + +#define REPLACE_VARIABLES TRUE + +class TOOLS_DLLPUBLIC InformationParser +{ +private: + BOOL bRecover; + ByteString sOldLine; + + ByteString sCurrentComment; + + BOOL bReplaceVariables; // meaning %UPD and %VERSION + USHORT nLevel; + ByteString sUPD; + ByteString sVersion; + + Link aStatusLink; + SvStream *pActStream; + UniString sStreamName; + + USHORT nErrorCode; + ULONG nErrorLine; + ByteString sErrorText; + ULONG nActLine; + + // methods + TOOLS_DLLPRIVATE ByteString &ReadLine(); + TOOLS_DLLPRIVATE GenericInformation *ReadKey( GenericInformationList *pExistingList ); + inline void Recover(); + +protected: + BOOL Save( SvStream &rOutStream, + const GenericInformationList *pSaveList, USHORT nLevel, BOOL bStripped ); + GenericInformationList *Execute( SvStream &rSourceStream, + GenericInformationList *pExistingList ); + virtual void PrintStatus( ByteString &rStatus ) + { if ( aStatusLink.IsSet()) aStatusLink.Call( &rStatus ); } + +public: + InformationParser( BOOL bReplace = FALSE ); + virtual ~InformationParser(); + + // the following methods return NULL if any errors are detected + + // reads a information file and stores the data in a + // GenericInformationList + GenericInformationList *Execute( SvMemoryStream &rSourceStream, + GenericInformationList *pExistingList = NULL ); + GenericInformationList *Execute( SvFileStream &rSourceStream, + GenericInformationList *pExistingList = NULL ); + GenericInformationList *Execute( UniString &rSourceFile, + GenericInformationList *pExistingList = NULL ); + // reads all information files in the dir and stores the data in a + // GenericInformationList => first key is the filename + GenericInformationList *Execute( Dir &rDir, + GenericInformationList *pExistingList = NULL ); + + // save the InfrormationList to rSourceFile + // returns FALSE on error + BOOL Save( SvFileStream &rSourceStream, + const GenericInformationList *pSaveList ); + BOOL Save( SvMemoryStream &rSourceStream, + const GenericInformationList *pSaveList ); + BOOL Save( const UniString &rSourceFile, + const GenericInformationList *pSaveList ); + + USHORT GetErrorCode(); + ByteString &GetErrorText(); + + void SetStatusHdl( const Link &rHdl ) { aStatusLink = rHdl; } +}; + +#endif + diff --git a/tools/inc/tools/isofallback.hxx b/tools/inc/tools/isofallback.hxx new file mode 100644 index 000000000000..dcf4bd938376 --- /dev/null +++ b/tools/inc/tools/isofallback.hxx @@ -0,0 +1,38 @@ +/************************************************************************* + * + * 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 _ISOFALLBACK_HXX +#define _ISOFALLBACK_HXX + +#include <tools/string.hxx> +#include "tools/toolsdllapi.h" + +// Return true if valid fallback found +TOOLS_DLLPUBLIC sal_Bool GetIsoFallback( ByteString& rLanguage ); + +#endif //_ISOFALLBACK_HXX + diff --git a/tools/inc/tools/line.hxx b/tools/inc/tools/line.hxx new file mode 100644 index 000000000000..c6c70df842ca --- /dev/null +++ b/tools/inc/tools/line.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * 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 _LINE_HXX +#define _LINE_HXX + +#include "tools/toolsdllapi.h" +#include <tools/gen.hxx> + +class Link; + +// -------- +// - Line - +// -------- + +class TOOLS_DLLPUBLIC Line +{ +private: + + Point maStart; + Point maEnd; + +public: + Line() {}; + Line( const Point& rStartPt, const Point& rEndPt ) : maStart( rStartPt ), maEnd( rEndPt ) {} + + void SetStart( const Point& rStartPt ) { maStart = rStartPt; } + const Point& GetStart() const { return maStart; } + + void SetEnd( const Point& rEndPt ) { maEnd = rEndPt; } + const Point& GetEnd() const { return maEnd; } + + long Left() const { return ( maStart.X() < maEnd.X() ) ? maStart.X() : maEnd.X(); } + long Top() const { return ( maStart.Y() < maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } + long Right() const { return ( maStart.X() > maEnd.X() ) ? maStart.X() : maEnd.X(); } + long Bottom() const { return ( maStart.Y() > maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } + + double GetLength() const; + + BOOL Intersection( const Line& rLine, double& rIntersectionX, double& rIntersectionY ) const; + BOOL Intersection( const Line& rLine, Point& rIntersection ) const; + BOOL Intersection( const Rectangle& rRect, Line& rIntersection ) const; + + double GetDistance( const double& rPtX, const double& rPtY ) const; + double GetDistance( const Point& rPoint ) const { return( GetDistance( rPoint.X(), rPoint.Y() ) ); } + + Point NearestPoint( const Point& rPoint ) const; + + void Enum( const Link& rEnumLink ); +}; + +#endif // _SV_LINE_HXX diff --git a/tools/inc/tools/link.hxx b/tools/inc/tools/link.hxx new file mode 100644 index 000000000000..1742759055d6 --- /dev/null +++ b/tools/inc/tools/link.hxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * 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 _LINK_HXX +#define _LINK_HXX + +#include "tools/toolsdllapi.h" +#include "sal/config.h" +#include "sal/types.h" +#include <tools/solar.h> + +// --------------- +// - Link-Makros - +// --------------- + +typedef long (*PSTUB)( void*, void* ); + +#define DECL_LINK( Method, ArgType ) \ + long Method( ArgType ); \ + static long LinkStub##Method( void* pThis, void* ) + +#define DECL_STATIC_LINK( Class, Method, ArgType ) \ + static long Method( Class*, ArgType ) + +#define DECL_DLLPRIVATE_LINK(Method, ArgType) \ + SAL_DLLPRIVATE long Method(ArgType); \ + SAL_DLLPRIVATE static long LinkStub##Method(void * pThis, void *) + +#define DECL_DLLPRIVATE_STATIC_LINK(Class, Method, ArgType) \ + SAL_DLLPRIVATE static long Method(Class *, ArgType) + +#define IMPL_METHOD( Class, Method, ArgType, ArgName ) \ + long Class::Method( ArgType ArgName ) + +#define IMPL_STUB(Class, Method, ArgType) \ + long __EXPORT Class::LinkStub##Method( void* pThis, void* pCaller) \ + { \ + return ((Class*)pThis )->Method( (ArgType)pCaller ); \ + } + +#define IMPL_STATIC_LINK( Class, Method, ArgType, ArgName ) \ + long __EXPORT Class::Method( Class* pThis, ArgType ArgName ) + +#define IMPL_STATIC_LINK_NOINSTANCE( Class, Method, ArgType, ArgName ) \ + long __EXPORT Class::Method( Class*, ArgType ArgName ) + +#define LINK( Inst, Class, Member ) \ + Link( (Class*)Inst, (PSTUB)&Class::LinkStub##Member ) + +#define STATIC_LINK( Inst, Class, Member ) \ + Link( (Class*)Inst, (PSTUB)&Class::Member ) + +#define IMPL_LINK( Class, Method, ArgType, ArgName ) \ + IMPL_STUB( Class, Method, ArgType ) \ + long Class::Method( ArgType ArgName ) + +#if defined GCC && defined NO_OPTIMIZE +#define IMPL_LINK_INLINE_START( Class, Method, ArgType, ArgName ) \ + IMPL_LINK( Class, Method, ArgType, ArgName ) + +#define IMPL_LINK_INLINE_END( Class, Method, ArgType, ArgName ) +#else +#define IMPL_LINK_INLINE_START( Class, Method, ArgType, ArgName ) \ + inline long Class::Method( ArgType ArgName ) + +#define IMPL_LINK_INLINE_END( Class, Method, ArgType, ArgName ) \ + IMPL_STUB( Class, Method, ArgType ) +#endif + +#define IMPL_LINK_INLINE( Class, Method, ArgType, ArgName, Body ) \ + long Class::Method( ArgType ArgName ) \ + Body \ + IMPL_STUB( Class, Method, ArgType ) + +#define EMPTYARG + +// -------- +// - Link - +// -------- + +class TOOLS_DLLPUBLIC Link +{ + void* pInst; + PSTUB pFunc; + +public: + Link(); + Link( void* pLinkHdl, PSTUB pMemFunc ); + + long Call( void* pCaller ) const; + + BOOL IsSet() const; + BOOL operator !() const; + + BOOL operator==( const Link& rLink ) const; + BOOL operator!=( const Link& rLink ) const + { return !(Link::operator==( rLink )); } + BOOL operator<( const Link& rLink ) const + { return ((ULONG)rLink.pFunc < (ULONG)pFunc); } +}; + +inline Link::Link() +{ + pInst = 0; + pFunc = 0; +} + +inline Link::Link( void* pLinkHdl, PSTUB pMemFunc ) +{ + pInst = pLinkHdl; + pFunc = pMemFunc; +} + +inline long Link::Call(void *pCaller) const +{ + return pFunc ? (*pFunc)(pInst, pCaller) : 0; +} + +inline BOOL Link::IsSet() const +{ + if ( pFunc ) + return TRUE; + else + return FALSE; +} + +inline BOOL Link::operator !() const +{ + if ( !pFunc ) + return TRUE; + else + return FALSE; +} + +#endif // _LINK_HXX diff --git a/tools/inc/tools/list.hxx b/tools/inc/tools/list.hxx new file mode 100644 index 000000000000..dd8fbf454f80 --- /dev/null +++ b/tools/inc/tools/list.hxx @@ -0,0 +1,143 @@ +/************************************************************************* + * + * 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 _LIST_HXX +#define _LIST_HXX + +#include <tools/solar.h> +#include <tools/contnr.hxx> + +// -------- +// - List - +// -------- + +#define LIST_APPEND CONTAINER_APPEND +#define LIST_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class List : private Container +{ +public: + using Container::Insert; + using Container::Remove; + using Container::Replace; + using Container::Clear; + using Container::Count; + using Container::GetCurObject; + using Container::GetCurPos; + using Container::GetObject; + using Container::GetPos; + using Container::Seek; + using Container::First; + using Container::Last; + using Container::Next; + using Container::Prev; + + List( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) : + Container( 1024, _nInitSize, _nReSize ) {} + List( USHORT _nBlockSize, USHORT _nInitSize, USHORT _nReSize ) : + Container( _nBlockSize, _nInitSize, _nReSize ) {} + List( const List& rList ) : Container( rList ) {} + + List& operator =( const List& rList ) + { Container::operator =( rList ); return *this; } + + BOOL operator ==( const List& rList ) const + { return Container::operator ==( rList ); } + BOOL operator !=( const List& rList ) const + { return Container::operator !=( rList ); } +}; + +// ---------------- +// - DECLARE_LIST - +// ---------------- + +#define DECLARE_LIST( ClassName, Type ) \ +class ClassName : private List \ +{ \ +public: \ + using List::Clear; \ + using List::Count; \ + using List::GetCurPos; \ + \ + ClassName( USHORT _nInitSize = 16, \ + USHORT _nReSize = 16 ) : \ + List( _nInitSize, _nReSize ) {} \ + ClassName( USHORT _nBlockSize, USHORT _nInitSize, \ + USHORT _nReSize ) : \ + List( _nBlockSize, _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + List( rClassName ) {} \ + \ + void Insert( Type p, ULONG nIndex ) \ + { List::Insert( (void*)p, nIndex ); } \ + void Insert( Type p ) \ + { List::Insert( (void*)p ); } \ + void Insert( Type pNew, Type pOld ) \ + { List::Insert( (void*)pNew, (void*)pOld ); } \ + Type Remove() \ + { return (Type)List::Remove(); } \ + Type Remove( ULONG nIndex ) \ + { return (Type)List::Remove( nIndex ); } \ + Type Remove( Type p ) \ + { return (Type)List::Remove( (void*)p ); } \ + Type Replace( Type p ) \ + { return (Type)List::Replace( (void*)p ); } \ + Type Replace( Type p, ULONG nIndex ) \ + { return (Type)List::Replace( (void*)p, nIndex ); } \ + Type Replace( Type pNew, Type pOld ) \ + { return (Type)List::Replace( (void*)pNew, \ + (void*)pOld ); } \ + \ + Type GetCurObject() const \ + { return (Type)List::GetCurObject(); } \ + Type GetObject( ULONG nIndex ) const \ + { return (Type)List::GetObject( nIndex ); } \ + ULONG GetPos( const Type p ) const \ + { return List::GetPos( (const void*)p ); } \ + ULONG GetPos( const Type p, ULONG nStartIndex, \ + BOOL bForward = TRUE ) const \ + { return List::GetPos( (const void*)p, nStartIndex, \ + bForward ); } \ + \ + Type Seek( ULONG nIndex ) \ + { return (Type)List::Seek( nIndex ); } \ + Type Seek( void* p ) { return (Type)List::Seek( p ); } \ + Type First() { return (Type)List::First(); } \ + Type Last() { return (Type)List::Last(); } \ + Type Next() { return (Type)List::Next(); } \ + Type Prev() { return (Type)List::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { List::operator =( rClassName ); return *this; } \ + \ + BOOL operator ==( const ClassName& rList ) const \ + { return List::operator ==( rList ); } \ + BOOL operator !=( const ClassName& rList ) const \ + { return List::operator !=( rList ); } \ +}; + +#endif // _LIST_HXX diff --git a/tools/inc/tools/mapunit.hxx b/tools/inc/tools/mapunit.hxx new file mode 100644 index 000000000000..0b5f5d044d19 --- /dev/null +++ b/tools/inc/tools/mapunit.hxx @@ -0,0 +1,41 @@ +/************************************************************************* + * + * 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 _TOOLS_MAPUNIT_HXX +#define _TOOLS_MAPUNIT_HXX + +// ----------------- +// - MapMode-Types - +// ----------------- + +// By changes you must also change: rsc/vclrsc.hxx +enum MapUnit { MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM, + MAP_1000TH_INCH, MAP_100TH_INCH, MAP_10TH_INCH, MAP_INCH, + MAP_POINT, MAP_TWIP, MAP_PIXEL, MAP_SYSFONT, MAP_APPFONT, + MAP_RELATIVE, MAP_REALAPPFONT, MAP_LASTENUMDUMMY }; + +#endif // _TOOLS_MAPUNIT_HXX diff --git a/tools/inc/tools/mempool.hxx b/tools/inc/tools/mempool.hxx new file mode 100644 index 000000000000..a96a024d4b27 --- /dev/null +++ b/tools/inc/tools/mempool.hxx @@ -0,0 +1,120 @@ +/************************************************************************* + * + * 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 _SVMEMPOOL_HXX +#define _SVMEMPOOL_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +// ---------------- +// - FixedMemPool - +// ---------------- + +struct FixedMemPool_Impl; + +class TOOLS_DLLPUBLIC FixedMemPool +{ + FixedMemPool_Impl * m_pImpl; + +public: + FixedMemPool( USHORT nTypeSize, + USHORT nInitSize = 512, + USHORT nGrowSize = 256 ); + ~FixedMemPool(); + + void* Alloc(); + void Free( void* p ); +}; + +// ---------------------------- +// - DECL_FIXEDMEMPOOL_NEWDEL - +// ---------------------------- + +#define DECL_FIXEDMEMPOOL_NEW_DECL() \ +static void * operator new( size_t n ) + +#define DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \ +void * Class::operator new( size_t n ) + +#define IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \ +{ \ + if ( n == sizeof( Class ) ) \ + return (aPool).Alloc(); \ + else \ + return ::operator new(n); \ +} + +#define DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \ +DECL_FIXEDMEMPOOL_NEW_DECL() \ +IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) + +#define DECL_FIXEDMEMPOOL_DEL_DECL() \ +static void operator delete( void * p, size_t n ) + +#define DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \ +void Class::operator delete( void * p, size_t n ) + +#define IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) \ +{ \ + if ( n == sizeof( Class ) ) \ + (aPool).Free(p); \ + else \ + ::operator delete(p); \ +} + +#define DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) \ +DECL_FIXEDMEMPOOL_DEL_DECL() \ +IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) + +#define DECL_FIXEDMEMPOOL_NEWDEL( Class ) \ + private: \ + static FixedMemPool aPool; \ + public: \ + DECL_FIXEDMEMPOOL_NEW_INLINE( Class, aPool ) \ + DECL_FIXEDMEMPOOL_DEL_INLINE( Class, aPool ) + +#define IMPL_FIXEDMEMPOOL_NEWDEL( Class, InitSize, GrowSize) \ + FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); + +#define DECL_FIXEDMEMPOOL_NEWDEL_DLL( Class ) \ + private: \ + static FixedMemPool aPool; \ + public: \ + DECL_FIXEDMEMPOOL_NEW_DECL(); \ + DECL_FIXEDMEMPOOL_DEL_DECL(); + +#define IMPL_FIXEDMEMPOOL_NEWDEL_DLL( Class, InitSize, GrowSize) \ + FixedMemPool Class::aPool( sizeof( Class ), (InitSize), (GrowSize) ); \ + DECL_FIXEDMEMPOOL_NEW_IMPL( Class ) \ + IMPL_FIXEDMEMPOOL_NEW_BODY( Class, aPool ) \ + DECL_FIXEDMEMPOOL_DEL_IMPL( Class ) \ + IMPL_FIXEDMEMPOOL_DEL_BODY( Class, aPool ) + +#define INIT_FIXEDMEMPOOL_NEWDEL_DLL( class, aPool, InitSize, GrowSize ) \ + aPool( sizeof( class ), InitSize, GrowSize ) + +#endif // _SVMEMPOOL_HXX diff --git a/tools/inc/tools/multisel.hxx b/tools/inc/tools/multisel.hxx new file mode 100644 index 000000000000..f75f4c5f03af --- /dev/null +++ b/tools/inc/tools/multisel.hxx @@ -0,0 +1,216 @@ +/************************************************************************* + * + * 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 _SV_MULTISEL_HXX +#define _SV_MULTISEL_HXX + +#include "tools/toolsdllapi.h" +#include <tools/gen.hxx> +#include <tools/list.hxx> +#include <tools/string.hxx> + +#include <vector> +#include <set> + +//------------------------------------------------------------------ + +#ifdef _SV_MULTISEL_CXX +DECLARE_LIST( ImpSelList, Range* ) +#else +#define ImpSelList List +#endif + +#define SFX_ENDOFSELECTION CONTAINER_ENTRY_NOTFOUND + +//------------------------------------------------------------------ + +// ------------------ +// - MultiSelection - +// ------------------ + +class TOOLS_DLLPUBLIC MultiSelection +{ +private: + ImpSelList aSels; // array of SV-selections + Range aTotRange; // total range of indexes + ULONG nCurSubSel; // index in aSels of current selected index + long nCurIndex; // current selected entry + ULONG nSelCount; // number of selected indexes + BOOL bInverseCur;// inverse cursor + BOOL bCurValid; // are nCurIndex and nCurSubSel valid + BOOL bSelectNew; // auto-select newly inserted indexes + +#ifdef _SV_MULTISEL_CXX + TOOLS_DLLPRIVATE void ImplClear(); + TOOLS_DLLPRIVATE ULONG ImplFindSubSelection( long nIndex ) const; + TOOLS_DLLPRIVATE BOOL ImplMergeSubSelections( ULONG nPos1, ULONG nPos2 ); + TOOLS_DLLPRIVATE long ImplFwdUnselected(); + TOOLS_DLLPRIVATE long ImplBwdUnselected(); +#endif + +public: + MultiSelection(); + MultiSelection( const MultiSelection& rOrig ); + MultiSelection( const Range& rRange ); + MultiSelection( const UniString& rString, + sal_Unicode cRange = '-', + sal_Unicode cSep = ';' ); + ~MultiSelection(); + + MultiSelection& operator= ( const MultiSelection& rOrig ); + BOOL operator== ( MultiSelection& rOrig ); + BOOL operator!= ( MultiSelection& rOrig ) + { return !operator==( rOrig ); } + BOOL operator !() const + { return nSelCount == 0; } + + void SelectAll( BOOL bSelect = TRUE ); + BOOL Select( long nIndex, BOOL bSelect = TRUE ); + void Select( const Range& rIndexRange, BOOL bSelect = TRUE ); + BOOL IsSelected( long nIndex ) const; + BOOL IsAllSelected() const + { return nSelCount == ULONG(aTotRange.Len()); } + long GetSelectCount() const { return nSelCount; } + + void SetTotalRange( const Range& rTotRange ); + void Insert( long nIndex, long nCount = 1 ); + void Remove( long nIndex ); + void Append( long nCount = 1 ); + + const Range& GetTotalRange() const { return aTotRange; } + BOOL IsCurValid() const { return bCurValid; } + long GetCurSelected() const { return nCurIndex; } + long FirstSelected( BOOL bInverse = FALSE ); + long LastSelected(); + long NextSelected(); + long PrevSelected(); + + ULONG GetRangeCount() const { return aSels.Count(); } + const Range& GetRange( ULONG nRange ) const { return *(const Range*)aSels.GetObject(nRange); } +}; + +class TOOLS_DLLPUBLIC StringRangeEnumerator +{ + struct Range + { + sal_Int32 nFirst; + sal_Int32 nLast; + + Range() : nFirst( -1 ), nLast( -1 ) {} + Range( sal_Int32 i_nFirst, sal_Int32 i_nLast ) : nFirst( i_nFirst ), nLast( i_nLast ) {} + }; + std::vector< StringRangeEnumerator::Range > maSequence; + sal_Int32 mnCount; + sal_Int32 mnMin; + sal_Int32 mnMax; + sal_Int32 mnOffset; + + bool insertRange( sal_Int32 nFirst, sal_Int32 nLast, bool bSequence, bool bMayAdjust ); + bool checkValue( sal_Int32, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; +public: + class TOOLS_DLLPUBLIC Iterator + { + const StringRangeEnumerator* pEnumerator; + const std::set< sal_Int32 >* pPossibleValues; + sal_Int32 nRangeIndex; + sal_Int32 nCurrent; + + friend class StringRangeEnumerator; + Iterator( const StringRangeEnumerator* i_pEnum, + const std::set< sal_Int32 >* i_pPossibleValues, + sal_Int32 i_nRange, + sal_Int32 i_nCurrent ) + : pEnumerator( i_pEnum ), pPossibleValues( i_pPossibleValues ) + , nRangeIndex( i_nRange ), nCurrent( i_nCurrent ) {} + public: + Iterator() : pEnumerator( NULL ), pPossibleValues( NULL ), nRangeIndex( -1 ), nCurrent( -1 ) {} + Iterator& operator++(); + sal_Int32 operator*() const; + bool operator==(const Iterator&) const; + bool operator!=(const Iterator& i_rComp) const + { return ! (*this == i_rComp); } + }; + + friend class StringRangeEnumerator::Iterator; + + StringRangeEnumerator() : mnCount( 0 ), mnMin( -1 ), mnMax( -1 ), mnOffset( -1 ) {} + StringRangeEnumerator( const rtl::OUString& i_rInput, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1 + ); + + size_t size() const { return size_t(mnCount); } + Iterator begin( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; + Iterator end( const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; + + sal_Int32 getMin() const { return mnMin; } + void setMin( sal_Int32 i_nMinValue ) { mnMin = i_nMinValue; } + sal_Int32 getMax() const { return mnMax; } + void setMax( sal_Int32 i_nMaxValue ) { mnMax = i_nMaxValue; } + sal_Int32 getLogicalOffset() const { return mnOffset; } + void setLogicalOffset( sal_Int32 i_nOffset ) { mnOffset = i_nOffset; } + + bool setRange( const rtl::OUString& i_rNewRange, bool i_bStrict = false ); + bool hasValue( sal_Int32 nValue, const std::set< sal_Int32 >* i_pPossibleValues = NULL ) const; + + + /** + i_rPageRange: the string to be changed into a sequence of numbers + valid format example "5-3,9,9,7-8" ; instead of ',' ';' or ' ' are allowed as well + o_rPageVector: the output sequence of numbers + i_nLogicalOffset: an offset to be applied to each number in the string before inserting it in the resulting sequence + example: a user enters page numbers from 1 to n (since that is logical) + of course usable page numbers in code would start from 0 and end at n-1 + so the logical offset would be -1 + i_nMinNumber: the minimum allowed number, a negative number means no minimum check + i_nMaxNumber: the maximum allowed number, a negative number means no maximum check + + @returns: true if the input string was valid, o_rPageVector will contain the resulting sequence + false if the input string was invalid, o_rPageVector will be unchanged + + behavior: + - only non-negative sequence numbers are allowed + - only non-negative values in the input string are allowed + - the string "-3" will be either + * an error if no minimum is given + * or result in the sequence i_nMinNumber to 3 + - the string "3-" will be either + * an error if no maximum is given + * or result in the seqeuence 3 to i_nMaxNumber + - an empty string as input is valid and will result in the range [min,max] if given + or an empty vector, if not + */ + static bool getRangesFromString( const rtl::OUString& i_rPageRange, + std::vector< sal_Int32 >& o_rPageVector, + sal_Int32 i_nMinNumber = -1, + sal_Int32 i_nMaxNumber = -1, + sal_Int32 i_nLogicalOffset = -1, + std::set< sal_Int32 >* i_pPossibleValues = NULL + ); +}; + +#endif // _SV_MULTISEL_HXX diff --git a/tools/inc/tools/ownlist.hxx b/tools/inc/tools/ownlist.hxx new file mode 100644 index 000000000000..ac99537a9f0d --- /dev/null +++ b/tools/inc/tools/ownlist.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * 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 _TOOLS_OWNLIST_HXX +#define _TOOLS_OWNLIST_HXX + +#ifndef _TOOLS_LIST_HXX //autogen +#include <tools/list.hxx> +#endif +/************************************************************************* +*************************************************************************/ + +#define PRV_SV_DECL_OWNER_LIST(ClassName,Type) \ + List aTypes; \ +public: \ + ClassName( USHORT nInitSize = 16, \ + USHORT nReSize = 16 ) \ + : aTypes( nInitSize, nReSize ) {} \ + ClassName( const ClassName & rObj ) \ + { *this = rObj; } \ + ClassName & operator = ( const ClassName & ); \ + ~ClassName() \ + { Clear(); } \ + void Clear(); \ + void Remove() \ + { delete (Type *)aTypes.Remove(); } \ + void Remove( Type * pObj ) \ + { delete (Type *)aTypes.Remove( pObj ); } \ + void Remove( ULONG nPos ) \ + { delete (Type *)aTypes.Remove( nPos ); } \ + Type & Insert( const Type &, ULONG nPos ); \ + Type & Insert( const Type & rType ) \ + { return Insert( rType, aTypes.GetCurPos() ); } \ + Type & Append( const Type & rType ) \ + { return Insert( rType, LIST_APPEND ); } \ + Type & GetObject( ULONG nPos ) const \ + { return *(Type *)aTypes.GetObject( nPos ); } \ + Type & operator []( ULONG nPos ) const \ + { return *(Type *)aTypes.GetObject( nPos ); } \ + ULONG Count() const { return aTypes.Count(); } + +#define PRV_SV_IMPL_OWNER_LIST(ClassName,Type) \ +ClassName & ClassName::operator = ( const ClassName & rObj ) \ +{ \ + if( this != &rObj ) \ + { \ + Clear(); \ + for( ULONG i = 0; i < rObj.Count(); i++ ) \ + Append( rObj.GetObject( i ) ); \ + } \ + return *this; \ +} \ +void ClassName::Clear() \ +{ \ + Type * p = (Type *)aTypes.First(); \ + while( p ) \ + { \ + delete p; \ + p = (Type *)aTypes.Next(); \ + } \ + aTypes.Clear(); \ +} \ +Type & ClassName::Insert( const Type & rType, ULONG nPos ) \ +{ \ + Type * pType = new Type( rType ); \ + aTypes.Insert( pType, nPos ); \ + return *pType; \ +} + +#endif // _TOOLS_OWNLIST_HXX diff --git a/tools/inc/tools/pathutils.hxx b/tools/inc/tools/pathutils.hxx new file mode 100644 index 000000000000..e5c54b09fb4b --- /dev/null +++ b/tools/inc/tools/pathutils.hxx @@ -0,0 +1,101 @@ +/************************************************************************* + * + * 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 INCLUDED_TOOLS_PATHUTILS_HXX +#define INCLUDED_TOOLS_PATHUTILS_HXX + +#include "sal/config.h" + +#if defined WNT + +#include <cstddef> + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +// The compiled code is not part of the tl dynamic library, but is delivered as +// pathutils-obj and pathutils-slo objects (it is linked into special +// executables and dynamic libraries that do not link against OOo libraries): + +namespace tools { + +// Determine the filename part of a path. +// +// @param path +// A non-NULL pointer to a null-terminated path. +// +// @return +// A pointer to the trailing filename part of the given path. +WCHAR * filename(WCHAR * path); + +// Concatenate two paths. +// +// Either the first path is empty and the second path is an absolute path. Or +// the first path is an absolute path that ends in a backslash and the second +// path is a relative path. In the latter case, to avoid paths that grow too +// long, leading .. segments of the second path are removed together with +// trailing segments from the first path. This should not cause problems as +// long as there are no symbolic links on Windows (as with symbolic links, +// x\y\.. and x might denote different directories). +// +// @param path +// An output paremeter taking the resulting path; must point at a valid range of +// memory of size at least MAX_PATH. If NULL is returned, the content is +// unspecified. +// +// @param frontBegin, frontEnd +// Forms a valid range [frontBegin .. frontEnd) of less than MAX_PATH size. +// +// @param backBegin, backLength +// Forms a valid range [backBeghin .. backBegin + backLength) of less than +// MAX_PATH size. +// +// @return +// A pointer to the terminating null character of the concatenation, or NULL if +// a failure occurred. +WCHAR * buildPath( + WCHAR * path, WCHAR const * frontBegin, WCHAR const * frontEnd, + WCHAR const * backBegin, std::size_t backLength); + +// Resolve a link file. +// +// @param path +// An input/output parameter taking the path; must point at a valid range of +// memory of size at least MAX_PATH. On input, contains the null-terminated +// full path of the link file. On output, contains the null-terminated full +// path of the resolved link; if NULL is returned, the content is unspecified. +// +// @return +// A pointer to the terminating null character of path, or NULL if a failure +// occurred. +WCHAR * resolveLink(WCHAR * path); + +} + +#endif + +#endif diff --git a/tools/inc/tools/poly.hxx b/tools/inc/tools/poly.hxx new file mode 100644 index 000000000000..b83877b88959 --- /dev/null +++ b/tools/inc/tools/poly.hxx @@ -0,0 +1,347 @@ +/************************************************************************* + * + * 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 _TL_POLY_HXX +#define _TL_POLY_HXX + +#include "tools/toolsdllapi.h" +#include <tools/gen.hxx> +#include <tools/debug.hxx> + +#include <vector> + +// ----------- +// - Defines - +// ----------- + +#define POLY_APPEND (0xFFFF) +#define POLYPOLY_APPEND (0xFFFF) + +// ------------------------------------------------------------------------ + +#define POLY_OPTIMIZE_NONE 0x00000000UL +#define POLY_OPTIMIZE_OPEN 0x00000001UL +#define POLY_OPTIMIZE_CLOSE 0x00000002UL +#define POLY_OPTIMIZE_NO_SAME 0x00000004UL +#define POLY_OPTIMIZE_REDUCE 0x00000008UL +#define POLY_OPTIMIZE_EDGES 0x00000010UL + +// ------------- +// - PolyStyle - +// ------------- + +enum PolyStyle +{ + POLY_ARC = 1, + POLY_PIE = 2, + POLY_CHORD = 3 +}; + +// ------------- +// - PolyFlags - +// ------------- + +#ifndef ENUM_POLYFLAGS_DECLARED +#define ENUM_POLYFLAGS_DECLARED +enum PolyFlags +{ + POLY_NORMAL, + POLY_SMOOTH, + POLY_CONTROL, + POLY_SYMMTR +}; +#endif + +// ---------------- +// - PolyOptimize - +// ---------------- + +class PolyOptimizeData +{ +private: + + enum DataType { DATA_NONE = 0, DATA_ABSOLUT = 1, DATA_PERCENT = 2 }; + DataType eType; + union { ULONG mnAbsolut; USHORT mnPercent; }; + +public: + + PolyOptimizeData() : eType( DATA_NONE ) {} + PolyOptimizeData( ULONG nAbsolut ) : eType( DATA_ABSOLUT ), mnAbsolut( nAbsolut ) {} + PolyOptimizeData( USHORT nPercent ) : eType( DATA_PERCENT ), mnPercent( nPercent ) {} + + ULONG GetAbsValue() const { DBG_ASSERT( eType == DATA_ABSOLUT, "Wrong data type" ); return mnAbsolut; } + USHORT GetPercentValue() const { DBG_ASSERT( eType == DATA_PERCENT, "Wrong data type" ); return mnPercent; } +}; + +// ----------- +// - Polygon - +// ----------- + +class SvStream; +class ImplPolygon; +class ImplPolyPolygon; +class PolyPolygon; + +namespace basegfx +{ + class B2DPolygon; + class B2DPolyPolygon; +} // end of namespace basegfx + +class TOOLS_DLLPUBLIC Polygon +{ +private: + + ImplPolygon* mpImplPolygon; + + TOOLS_DLLPRIVATE inline void ImplMakeUnique(); + +//#if 0 // _SOLAR__PRIVATE + +public: + + Point* ImplGetPointAry(); + BYTE* ImplGetFlagAry(); + + static void ImplReduceEdges( Polygon& rPoly, const double& rArea, USHORT nPercent ); + void ImplRead( SvStream& rIStream ); + void ImplWrite( SvStream& rOStream ) const; + +//#endif // __PRIVATE + +public: + Polygon(); + Polygon( USHORT nSize ); + Polygon( USHORT nPoints, const Point* pPtAry, + const BYTE* pFlagAry = NULL ); + Polygon( const Rectangle& rRect ); + Polygon( const Rectangle& rRect, + ULONG nHorzRound, ULONG nVertRound ); + Polygon( const Point& rCenter, + long nRadX, long nRadY, + USHORT nPoints = 0 ); + Polygon( const Rectangle& rBound, + const Point& rStart, const Point& rEnd, + PolyStyle ePolyStyle = POLY_ARC ); + Polygon( const Point& rBezPt1, const Point& rCtrlPt1, + const Point& rBezPt2, const Point& rCtrlPt2, + USHORT nPoints = 0 ); + + Polygon( const Polygon& rPoly ); + ~Polygon(); + + void SetPoint( const Point& rPt, USHORT nPos ); + const Point& GetPoint( USHORT nPos ) const; + + void SetFlags( USHORT nPos, PolyFlags eFlags ); + PolyFlags GetFlags( USHORT nPos ) const; + sal_Bool HasFlags() const; + + BOOL IsControl( USHORT nPos ) const; + BOOL IsSmooth( USHORT nPos ) const; + BOOL IsRect() const; + + void SetSize( USHORT nNewSize ); + USHORT GetSize() const; + + void Clear(); + + Rectangle GetBoundRect() const; + double GetArea() const; + double GetSignedArea() const; + BOOL IsInside( const Point& rPt ) const; + BOOL IsRightOrientated() const; + double CalcDistance( USHORT nPt1, USHORT nPt2 ); + void Clip( const Rectangle& rRect, BOOL bPolygon = TRUE ); + void Optimize( ULONG nOptimizeFlags, const PolyOptimizeData* pData = NULL ); + + /** Adaptive subdivision of polygons with curves + + This method adaptively subdivides bezier arcs within the + polygon to straight line segments and returns the resulting + polygon. + + @param rResult + The resulting subdivided polygon + + @param d + This parameter controls the amount of subdivision. The + original curve is guaranteed to not differ by more than this + amount per bezier segment from the subdivided + lines. Concretely, if the polygon is in device coordinates and + d equals 1.0, then the difference between the subdivided and + the original polygon is guaranteed to be smaller than one + pixel. + */ + void AdaptiveSubdivide( Polygon& rResult, const double d = 1.0 ) const; + + void GetIntersection( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetUnion( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetDifference( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetXOR( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + + void Move( long nHorzMove, long nVertMove ); + void Translate( const Point& rTrans ); + void Scale( double fScaleX, double fScaleY ); + void Rotate( const Point& rCenter, double fSin, double fCos ); + void Rotate( const Point& rCenter, USHORT nAngle10 ); + void SlantX( long nYRef, double fSin, double fCos ); + void SlantY( long nXRef, double fSin, double fCos ); + void Distort( const Rectangle& rRefRect, const Polygon& rDistortedRect ); + + void Insert( USHORT nPos, const Point& rPt, PolyFlags eFlags = POLY_NORMAL ); + void Insert( USHORT nPos, const Polygon& rPoly ); + void Remove( USHORT nPos, USHORT nCount ); + + const Point& operator[]( USHORT nPos ) const { return GetPoint( nPos ); } + Point& operator[]( USHORT nPos ); + + Polygon& operator=( const Polygon& rPoly ); + BOOL operator==( const Polygon& rPoly ) const; + BOOL operator!=( const Polygon& rPoly ) const + { return !(Polygon::operator==( rPoly )); } + sal_Bool IsEqual( const Polygon& rPoly ) const; + + // streaming a Polygon does ignore PolyFlags, so use the Write Or Read + // method to take care of PolyFlags + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Polygon& rPoly ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Polygon& rPoly ); + + void Read( SvStream& rIStream ); + void Write( SvStream& rOStream ) const; + + const Point* GetConstPointAry() const; + const BYTE* GetConstFlagAry() const; + + // convert to ::basegfx::B2DPolygon and return + ::basegfx::B2DPolygon getB2DPolygon() const; + + // constructor to convert from ::basegfx::B2DPolygon + // #i76339# made explicit + explicit Polygon(const ::basegfx::B2DPolygon& rPolygon); +}; + +// --------------- +// - PolyPolygon - +// --------------- + +class TOOLS_DLLPUBLIC PolyPolygon +{ +private: + + ImplPolyPolygon* mpImplPolyPolygon; + +//#if 0 // _SOLAR__PRIVATE + TOOLS_DLLPRIVATE void ImplDoOperation( const PolyPolygon& rPolyPoly, PolyPolygon& rResult, ULONG nOperation ) const; + TOOLS_DLLPRIVATE void *ImplCreateArtVpath() const; + TOOLS_DLLPRIVATE void ImplSetFromArtVpath( void *pVpath ); +//#endif // __PRIVATE + +public: + + PolyPolygon( USHORT nInitSize = 16, USHORT nResize = 16 ); + PolyPolygon( const Polygon& rPoly ); + PolyPolygon( USHORT nPoly, const USHORT* pPointCountAry, + const Point* pPtAry ); + PolyPolygon( const PolyPolygon& rPolyPoly ); + ~PolyPolygon(); + + void Insert( const Polygon& rPoly, USHORT nPos = POLYPOLY_APPEND ); + void Remove( USHORT nPos ); + void Replace( const Polygon& rPoly, USHORT nPos ); + const Polygon& GetObject( USHORT nPos ) const; + + BOOL IsRect() const; + + void Clear(); + + USHORT Count() const; + Rectangle GetBoundRect() const; + void Clip( const Rectangle& rRect ); + void Optimize( ULONG nOptimizeFlags, const PolyOptimizeData* pData = NULL ); + + /** Adaptive subdivision of polygons with curves + + This method adaptively subdivides bezier arcs within the + polygon to straight line segments and returns the resulting + polygon. + + @param rResult + The resulting subdivided polygon + + @param d + This parameter controls the amount of subdivision. The + original curve is guaranteed to not differ by more than this + amount per bezier segment from the subdivided + lines. Concretely, if the polygon is in device coordinates and + d equals 1.0, then the difference between the subdivided and + the original polygon is guaranteed to be smaller than one + pixel. + */ + void AdaptiveSubdivide( PolyPolygon& rResult, const double d = 1.0 ) const; + + void GetIntersection( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetUnion( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetDifference( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + void GetXOR( const PolyPolygon& rPolyPoly, PolyPolygon& rResult ) const; + + void Move( long nHorzMove, long nVertMove ); + void Translate( const Point& rTrans ); + void Scale( double fScaleX, double fScaleY ); + void Rotate( const Point& rCenter, double fSin, double fCos ); + void Rotate( const Point& rCenter, USHORT nAngle10 ); + void SlantX( long nYRef, double fSin, double fCos ); + void SlantY( long nXRef, double fSin, double fCos ); + void Distort( const Rectangle& rRefRect, const Polygon& rDistortedRect ); + + const Polygon& operator[]( USHORT nPos ) const { return GetObject( nPos ); } + Polygon& operator[]( USHORT nPos ); + + PolyPolygon& operator=( const PolyPolygon& rPolyPoly ); + BOOL operator==( const PolyPolygon& rPolyPoly ) const; + BOOL operator!=( const PolyPolygon& rPolyPoly ) const + { return !(PolyPolygon::operator==( rPolyPoly )); } + + sal_Bool IsEqual( const PolyPolygon& rPolyPoly ) const; + + TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, PolyPolygon& rPolyPoly ); + TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const PolyPolygon& rPolyPoly ); + + void Read( SvStream& rIStream ); + void Write( SvStream& rOStream ) const; + + // convert to ::basegfx::B2DPolyPolygon and return + ::basegfx::B2DPolyPolygon getB2DPolyPolygon() const; + + // constructor to convert from ::basegfx::B2DPolyPolygon + // #i76339# made explicit + explicit PolyPolygon(const ::basegfx::B2DPolyPolygon& rPolyPolygon); +}; + +typedef std::vector< PolyPolygon > PolyPolyVector; + +#endif // _SV_POLY_HXX diff --git a/tools/inc/tools/postsys.h b/tools/inc/tools/postsys.h new file mode 100644 index 000000000000..3b7e37a4c23b --- /dev/null +++ b/tools/inc/tools/postsys.h @@ -0,0 +1,244 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +/* nicht geschuetz, muss als gegenstueck zu prestl.h includet werden */ + +#if defined WNT + +#undef Region +#undef PolyPolygon +#undef Polygon +#undef Rectangle +#undef BYTE +#undef BOOL +#undef DELETE + +/* Hilfe-Ids umbenennen */ +#define WIN_HELP_INDEX 0x0003 +#define WIN_HELP_HELPONHELP 0x0004 +#undef HELP_INDEX +#undef HELP_HELPONHELP + +#define WIN_MOUSE_MOVED 0x0001 +#undef MOUSE_MOVED + +#define WIN_WB_LEFT 0 +#define WIN_WB_RIGHT 1 +#undef WB_LEFT +#undef WB_RIGHT + +#ifdef GetObject +#undef GetObject +#ifdef UNICODE +#define WIN_GetObject GetObjectW +#else +#define WIN_GetObject GetObjectA +#endif +#else +#define WIN_GetObject GetObject +#endif + +#ifdef SetPrinter +#undef SetPrinter +#ifdef UNICODE +#define WIN_SetPrinter SetPrinterW +#else +#define WIN_SetPrinter SetPrinterA +#endif +#else +#define WIN_SetPrinter SetPrinter +#endif + +#ifdef GetPrinter +#undef GetPrinter +#ifdef UNICODE +#define WIN_GetPrinter GetPrinterW +#else +#define WIN_GetPrinter GetPrinterA +#endif +#else +#define WIN_GetPrinter GetPrinter +#endif + +#ifdef DrawText +#undef DrawText +#ifdef UNICODE +#define WIN_DrawText DrawTextW +#else +#define WIN_DrawText DrawTextA +#endif +#else +#define WIN_DrawText DrawText +#endif + +#ifdef mciSetCommand +#undef mciSetCommand +#ifdef UNICODE +#define WIN_mciSetCommand mciSetCommandW +#else +#define WIN_mciSetCommand mciSetCommandA +#endif +#else +#define mciSetCommand mciSetCommand +#endif + +#ifdef SetPort +#undef SetPort +#ifdef UNICODE +#define WIN_SetPort SetPortW +#else +#define WIN_SetPort SetPortA +#endif +#else +#define WIN_SetPort SetPort +#endif + +#ifdef CopyFile +#undef CopyFile +#ifdef UNICODE +#define WIN_CopyFile CopyFileW +#else +#define WIN_CopyFile CopyFileA +#endif +#else +#define WIN_CopyFile CopyFile +#endif + +#ifdef GetUserName +#undef GetUserName +#ifdef UNICODE +#define WIN_GetUserName GetUserNameW +#else +#define WIN_GetUserName GetUserNameA +#endif +#else +#define WIN_GetUserName GetUserName +#endif + +#ifdef GetClassName +#undef GetClassName +#ifdef UNICODE +#define WIN_GetClassName GetClassNameW +#else +#define WIN_GetClassName GetClassNameA +#endif +#else +#define WIN_GetClassName GetClassName +#endif + +#ifdef GetCharWidth +#undef GetCharWidth +#ifdef UNICODE +#define WIN_GetCharWidth GetCharWidthW +#else +#define WIN_GetCharWidth GetCharWidthA +#endif +#else +#define WIN_GetCharWidth GetCharWidth +#endif + +#ifdef GetMetaFile +#undef GetMetaFile +#ifdef UNICODE +#define WIN_GetMetaFile GetMetaFileW +#else +#define WIN_GetMetaFile GetMetaFileA +#endif +#else +#define WIN_GetMetaFile GetMetaFile +#endif + +#ifdef GetNumberFormat +#undef GetNumberFormat +#ifdef UNICODE +#define WIN_GetNumberFormat GetNumberFormatW +#else +#define WIN_GetNumberFormat GetNumberFormatA +#endif +#else +#define WIN_GetNumberFormat GetNumberFormat +#endif + +#ifdef GetGlyphOutline +#undef GetGlyphOutline +#ifdef UNICODE +#define WIN_GetGlyphOutline GetGlyphOutlineW +#else +#define WIN_GetGlyphOutline GetGlyphOutlineA +#endif +#else +#define WIN_GetGlyphOutline GetGlyphOutline +#endif + +#ifdef GetKerningPairs +#undef GetKerningPairs +#ifdef UNICODE +#define WIN_GetKerningPairs GetKerningPairsW +#else +#define WIN_GetKerningPairs GetKerningPairsA +#endif +#else +#define WIN_GetKerningPairs GetKerningPairs +#endif + +#ifdef FindWindow +#undef FindWindow +#ifdef UNICODE +#define WIN_FindWindow FindWindowW +#else +#define WIN_FindWindow FindWindowA +#endif +#else +#define WIN_FindWindow FindWindow +#endif + +// keine Yield-Definition +#undef Yield + +/* new StretchBlt() Modes (simpler names) */ +#ifndef STRETCH_ANDSCANS +#define STRETCH_ANDSCANS 1 +#endif +#ifndef STRETCH_ORSCANS +#define STRETCH_ORSCANS 2 +#endif +#ifndef STRETCH_DELETESCANS +#define STRETCH_DELETESCANS 3 +#endif + +extern "C" +{ +WIN_BOOL WINAPI WIN_Rectangle( HDC hDC, int X1, int Y1, int X2, int Y2 ); +WIN_BOOL WINAPI WIN_Polygon( HDC hDC, CONST POINT * ppt, int ncnt ); +WIN_BOOL WINAPI WIN_PolyPolygon( HDC hDC, CONST POINT * ppt, LPINT npcnt, int ncnt ); +} + +#endif + +// Konfl�kt mit den Tools-Pair vermeiden +#undef Pair + diff --git a/tools/inc/tools/postwin.h b/tools/inc/tools/postwin.h new file mode 100644 index 000000000000..a6bd3431a9dc --- /dev/null +++ b/tools/inc/tools/postwin.h @@ -0,0 +1,257 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +/* nicht geschuetz, muss als gegenstueck zu prewin.h includet werden */ + +#ifdef WNT +#ifdef __cplusplus +} +#endif +#endif + +#undef Region +#undef PolyPolygon +#undef Polygon +#undef Rectangle +#undef BYTE +#undef BOOL +#undef DELETE + +#ifndef VCL_NEED_BASETSD +#undef INT64 +#undef UINT64 +#undef INT32 +#undef UINT32 +#endif +#undef Folder +#undef GradientStyle_RECT + +/* Hilfe-Ids umbenennen */ +#define WIN_HELP_INDEX 0x0003 +#define WIN_HELP_HELPONHELP 0x0004 +#undef HELP_INDEX +#undef HELP_HELPONHELP + +#define WIN_MOUSE_MOVED 0x0001 +#undef MOUSE_MOVED + +#define WIN_WB_LEFT 0 +#define WIN_WB_RIGHT 1 +#undef WB_LEFT +#undef WB_RIGHT + +#ifdef GetObject +#undef GetObject +#ifdef UNICODE +#define WIN_GetObject GetObjectW +#else +#define WIN_GetObject GetObjectA +#endif +#else +#define WIN_GetObject GetObject +#endif + +#ifdef SetPrinter +#undef SetPrinter +#ifdef UNICODE +#define WIN_SetPrinter SetPrinterW +#else +#define WIN_SetPrinter SetPrinterA +#endif +#else +#define WIN_SetPrinter SetPrinter +#endif + +#ifdef GetPrinter +#undef GetPrinter +#ifdef UNICODE +#define WIN_GetPrinter GetPrinterW +#else +#define WIN_GetPrinter GetPrinterA +#endif +#else +#define WIN_GetPrinter GetPrinter +#endif + +#ifdef DrawText +#undef DrawText +#ifdef UNICODE +#define WIN_DrawText DrawTextW +#else +#define WIN_DrawText DrawTextA +#endif +#else +#define WIN_DrawText DrawText +#endif + +#ifdef mciSetCommand +#undef mciSetCommand +#ifdef UNICODE +#define WIN_mciSetCommand mciSetCommandW +#else +#define WIN_mciSetCommand mciSetCommandA +#endif +#else +#define mciSetCommand mciSetCommand +#endif + +#ifdef SetPort +#undef SetPort +#ifdef UNICODE +#define WIN_SetPort SetPortW +#else +#define WIN_SetPort SetPortA +#endif +#else +#define WIN_SetPort SetPort +#endif + +#ifdef CopyFile +#undef CopyFile +#ifdef UNICODE +#define WIN_CopyFile CopyFileW +#else +#define WIN_CopyFile CopyFileA +#endif +#else +#define WIN_CopyFile CopyFile +#endif + + +#ifdef GetUserName +#undef GetUserName +#ifdef UNICODE +#define WIN_GetUserName GetUserNameW +#else +#define WIN_GetUserName GetUserNameA +#endif +#else +#define WIN_GetUserName GetUserName +#endif + +#ifdef GetClassName +#undef GetClassName +#ifdef UNICODE +#define WIN_GetClassName GetClassNameW +#else +#define WIN_GetClassName GetClassNameA +#endif +#else +#define WIN_GetClassName GetClassName +#endif + +#ifdef GetCharWidth +#undef GetCharWidth +#ifdef UNICODE +#define WIN_GetCharWidth GetCharWidthW +#else +#define WIN_GetCharWidth GetCharWidthA +#endif +#else +#define WIN_GetCharWidth GetCharWidth +#endif + +#ifdef GetMetaFile +#undef GetMetaFile +#ifdef UNICODE +#define WIN_GetMetaFile GetMetaFileW +#else +#define WIN_GetMetaFile GetMetaFileA +#endif +#else +#define WIN_GetMetaFile GetMetaFile +#endif + +#ifdef GetNumberFormat +#undef GetNumberFormat +#ifdef UNICODE +#define WIN_GetNumberFormat GetNumberFormatW +#else +#define WIN_GetNumberFormat GetNumberFormatA +#endif +#else +#define WIN_GetNumberFormat GetNumberFormat +#endif + +#ifdef GetGlyphOutline +#undef GetGlyphOutline +#ifdef UNICODE +#define WIN_GetGlyphOutline GetGlyphOutlineW +#else +#define WIN_GetGlyphOutline GetGlyphOutlineA +#endif +#else +#define WIN_GetGlyphOutline GetGlyphOutline +#endif + +#ifdef GetKerningPairs +#undef GetKerningPairs +#ifdef UNICODE +#define WIN_GetKerningPairs GetKerningPairsW +#else +#define WIN_GetKerningPairs GetKerningPairsA +#endif +#else +#define WIN_GetKerningPairs GetKerningPairs +#endif + +#ifdef FindWindow +#undef FindWindow +#ifdef UNICODE +#define WIN_FindWindow FindWindowW +#else +#define WIN_FindWindow FindWindowA +#endif +#else +#define WIN_FindWindow FindWindow +#endif + +// keine Yield-Definition +#undef Yield + +/* new StretchBlt() Modes (simpler names) */ +#ifndef STRETCH_ANDSCANS +#define STRETCH_ANDSCANS 1 +#endif +#ifndef STRETCH_ORSCANS +#define STRETCH_ORSCANS 2 +#endif +#ifndef STRETCH_DELETESCANS +#define STRETCH_DELETESCANS 3 +#endif + +#ifdef WNT +extern "C" +{ +WIN_BOOL WINAPI WIN_Rectangle( HDC hDC, int X1, int Y1, int X2, int Y2 ); +WIN_BOOL WINAPI WIN_Polygon( HDC hDC, CONST POINT * ppt, int ncnt ); +WIN_BOOL WINAPI WIN_PolyPolygon( HDC hDC, CONST POINT * ppt, LPINT npcnt, int ncnt ); +} +#endif + +// svwin.h nicht mehr includen +#define _SVWIN_H diff --git a/tools/inc/tools/postx.h b/tools/inc/tools/postx.h new file mode 100644 index 000000000000..3e77fde5d14b --- /dev/null +++ b/tools/inc/tools/postx.h @@ -0,0 +1,73 @@ +/************************************************************************* + * + * 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 _POSTX_H +#define _POSTX_H + +#if defined __cplusplus +} +#endif + +/* X-Types */ +#undef Window +#undef BYTE +#undef INT8 +#undef INT64 +#undef BOOL +#undef Font +#undef Cursor +#undef String +#undef KeyCode +#undef Region +#undef Icon +#undef Time +#undef Boolean + +#undef Min +#undef Max +#undef DestroyAll +#undef Success + +#undef Printer +/* #undef FontInfo */ +#undef Orientation + +#undef GetToken +#undef ReleaseToken +#undef InitializeToken +#undef NextRequest + +#ifdef KeyPress +#if KeyPress != 2 +Error KeyPress must be Equal 2 +#endif +#undef KeyPress +#endif +#define XLIB_KeyPress 2 + +#endif + diff --git a/tools/inc/tools/presys.h b/tools/inc/tools/presys.h new file mode 100644 index 000000000000..457b57142dcd --- /dev/null +++ b/tools/inc/tools/presys.h @@ -0,0 +1,43 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +/* nicht geschuetzt, darf nur einmal includet werden */ + +// Konflíkt mit den Tools-Pair vermeiden +#define Pair StlPair + +#if defined WNT + +#define BOOL WIN_BOOL +#define BYTE WIN_BYTE + +#define Rectangle BLA_Rectangle +#define Polygon BLA_Polygon +#define PolyPolygon BLA_PolyPolygon +#define Region WIN_Region + +#endif diff --git a/tools/inc/tools/prewin.h b/tools/inc/tools/prewin.h new file mode 100644 index 000000000000..43a4452594cc --- /dev/null +++ b/tools/inc/tools/prewin.h @@ -0,0 +1,80 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +/* nicht geschuetzt, darf nur einmal includet werden */ + +#if defined WNT + +#define BOOL WIN_BOOL +#define BYTE WIN_BYTE +#ifndef VCL_NEED_BASETSD +#define INT64 WIN_INT64 +#define UINT64 WIN_UINT64 +#define INT32 WIN_INT32 +#define UINT32 WIN_UINT32 +#endif + +#define Rectangle BLA_Rectangle +#define Polygon BLA_Polygon +#define PolyPolygon BLA_PolyPolygon +#define Region WIN_Region +#define Folder WIN_Folder +#define GradientStyle_RECT WIN_GradientStyle_RECT + +#ifdef __cplusplus +extern "C" { +#endif + +#define STRICT +#ifdef _MSC_VER +#pragma warning(push, 1) +#endif +#include <windows.h> +#ifdef _MSC_VER +#pragma warning(pop) +#endif +#include <shellapi.h> +#include <commdlg.h> +#include <dlgs.h> +#ifdef USE_TOOLHELP +#include <tlhelp32.h> +#endif +#ifdef USE_IMAGEHLP +#include <imagehlp.h> +#endif +#ifdef INCLUDE_MMSYSTEM +#include <mmsystem.h> +#endif +#ifdef _MSC_VER +#pragma warning(push, 1) +#endif +#include <commctrl.h> +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif diff --git a/tools/inc/tools/prex.h b/tools/inc/tools/prex.h new file mode 100644 index 000000000000..61088960bbfd --- /dev/null +++ b/tools/inc/tools/prex.h @@ -0,0 +1,78 @@ +/************************************************************************* + * + * 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 _PREX_H +#define _PREX_H + +#define Window XLIB_Window +#define BYTE XLIB_BYTE +#define INT8 XLIB_INT8 +#define INT64 XLIB_INT64 +#define BOOL XLIB_BOOL +#define Font XLIB_Font +#define Cursor XLIB_Cursor +#define String XLIB_String +#define KeyCode XLIB_KeyCode +#define Region XLIB_Region +#define Icon XLIB_Icon +#define Time XLIB_Time +#define Region XLIB_Region +#define Boolean XLIB_Boolean + +#if defined __cplusplus +extern "C" { +#endif + +#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX) // should really check for xfree86 or for X11R6.1 and higher +#define __XKeyboardExtension__ 1 +#else +#define __XKeyboardExtension__ 0 +#endif + +#include <X11/X.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/StringDefs.h> +#include <X11/extensions/Xrender.h> +#if __XKeyboardExtension__ +#include <X11/XKBlib.h> +#endif +typedef unsigned long Pixel; + +#undef DestroyAll +#define DestroyAll XLIB_DestroyAll +#define XLIB_DestroyAll 0 +#undef String +#define String XLIB_String + +#undef KeyCode +#define KeyCode XLIB_KeyCode //undef in intrinsics + +#define __Ol_OlXlibExt_h__ + +#endif + diff --git a/tools/inc/tools/pstm.hxx b/tools/inc/tools/pstm.hxx new file mode 100644 index 000000000000..2575ccae8f3e --- /dev/null +++ b/tools/inc/tools/pstm.hxx @@ -0,0 +1,261 @@ +/************************************************************************* + * + * 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 _PSTM_HXX +#define _PSTM_HXX + +#include <hash_map> +#include "tools/toolsdllapi.h" + +#ifndef _TABLE_HXX +#include <tools/table.hxx> +#endif + +#ifndef _INQIDX_HXX +#include <tools/unqidx.hxx> +#endif +#include <tools/ref.hxx> +#include <tools/rtti.hxx> +#include <tools/stream.hxx> + +#define ERRCODE_IO_NOFACTORY ERRCODE_IO_WRONGFORMAT + +/************************************************************************* +*************************************************************************/ +class SvPersistBase; +typedef void * (*SvCreateInstancePersist)( SvPersistBase ** ); +#define SV_CLASS_REGISTER( Class ) \ + Register( Class::StaticClassId(), Class::CreateInstance ) + +class TOOLS_DLLPUBLIC SvClassManager +{ + typedef std::hash_map< USHORT, SvCreateInstancePersist > Map; + Map aAssocTable; +public: + void Register( USHORT nClassId, SvCreateInstancePersist pFunc ); + SvCreateInstancePersist Get( USHORT nClassId ); +}; + +/************************** S v R t t i B a s e **************************/ + +class TOOLS_DLLPUBLIC SvRttiBase : public SvRefBase +{ +public: + TYPEINFO(); +}; +SV_DECL_IMPL_REF(SvRttiBase) + +/*************************************************************************/ +#define SV_DECL_PERSIST( Class, CLASS_ID ) \ + TYPEINFO(); \ + static USHORT StaticClassId() { return CLASS_ID; } \ + static void * CreateInstance( SvPersistBase ** ppBase ); \ + friend SvPersistStream& operator >> ( SvPersistStream & rStm, \ + Class *& rpObj); \ + virtual USHORT GetClassId() const; \ + virtual void Load( SvPersistStream & ); \ + virtual void Save( SvPersistStream & ); + +#define SV_DECL_PERSIST1( Class, Super1, CLASS_ID ) \ + SV_DECL_PERSIST( Class, CLASS_ID ) + +#define PRV_SV_IMPL_PERSIST( Class ) \ + void * Class::CreateInstance( SvPersistBase ** ppBase )\ + { \ + Class * p = new Class(); \ + *ppBase = p; \ + return p; \ + } \ + USHORT Class::GetClassId() const \ + { return StaticClassId(); } \ + SvPersistStream& operator >> (SvPersistStream & rStm, Class *& rpObj)\ + { \ + SvPersistBase * pObj; \ + rStm >> pObj; \ + rpObj = PTR_CAST( Class, pObj ); \ + return rStm; \ + } + +#define SV_IMPL_PERSIST( Class ) \ + TYPEINIT0( Class ) \ + PRV_SV_IMPL_PERSIST( Class ) + +#define SV_IMPL_PERSIST1( Class, Super1 ) \ + TYPEINIT1( Class, Super1 ) \ + PRV_SV_IMPL_PERSIST( Class ) + +/*************************************************************************/ +class SvPersistStream; +class SvPersistBase : public SvRttiBase +{ +public: + virtual USHORT GetClassId() const = 0; + virtual void Load( SvPersistStream & ) = 0; + virtual void Save( SvPersistStream & ) = 0; + TOOLS_DLLPUBLIC friend SvPersistStream& operator >> ( SvPersistStream & rStm, + SvPersistBase *& rpObj ); +}; +SV_DECL_IMPL_REF(SvPersistBase) + +/*************************************************************************/ +// Damit die Liste, anders benannt wird +typedef SvPersistBase SuperSvPersistBase; +SV_DECL_REF_LIST_VISIBILITY(SuperSvPersistBase,SuperSvPersistBase*,TOOLS_DLLPUBLIC) +SV_IMPL_REF_LIST(SuperSvPersistBase,SuperSvPersistBase*) + +class TOOLS_DLLPUBLIC SvPersistBaseMemberList : public SuperSvPersistBaseMemberList +{ +public: + SvPersistBaseMemberList(); + SvPersistBaseMemberList(USHORT nInitSz, USHORT nResize ); + + void WriteObjects( SvPersistStream &, BOOL bOnlyStreamedObj = FALSE ) const; + TOOLS_DLLPUBLIC friend SvPersistStream& operator << (SvPersistStream &, const SvPersistBaseMemberList &); + TOOLS_DLLPUBLIC friend SvPersistStream& operator >> (SvPersistStream &, SvPersistBaseMemberList &); +}; + +/*************************************************************************/ +#define SV_DECL_PERSIST_LIST(ClassName,EntryName)\ +class ClassName##MemberList : public SvPersistBaseMemberList\ +{\ +public:\ + PRV_SV_DECL_MEMBER_LIST(ClassName,EntryName)\ +}; + +#define SV_IMPL_PERSIST_LIST(ClassName,EntryName)\ + PRV_SV_IMPL_MEMBER_LIST(ClassName,EntryName,SvPersistBaseMemberList) + +#define SV_DECL_IMPL_PERSIST_LIST(ClassName,EntryName)\ +SV_DECL_PERSIST_LIST(ClassName,EntryName)\ +SV_IMPL_PERSIST_LIST(ClassName,EntryName) + +//#if 0 // _SOLAR__PRIVATE +DECLARE_UNIQUEINDEX( SvPersistUIdx,SvPersistBase *) +//#else +//typedef UniqueIndex SvPersistUIdx; +//#endif + +//========================================================================= +class SvStream; +class TOOLS_DLLPUBLIC SvPersistStream : public SvStream +/* [Beschreibung] + + Mit dieser Klasse k"onnen Laufzeit Objektstrukturen gespeichert + und geladen werden. Es m"ussen immer alle beteiligten Objekte + gespeichert oder geladen werden. Um die Objekte automatisch + laden zu k"onnen, wird eine Factory f"ur jede Klasse von Objekten, + die im Stream vorkommen k"onnen, ben"otigt. Die Liste aller Klassen + wird in einem <SvClassManager> Objekt gespeichert und dem + SvPersistStream "ubergeben, wenn er erzeugt wird. + Weiterhin wird die M"oglichkeit geboten UINT32 Werte komprimiert + zu schreiben und zu lesen (<SvPersistStream::WriteCompressed>, + <SvPersistStream::ReadCompressed>). + Es gibt auch die drei Hilfsmethoden <SvPersistStream::WriteDummyLen>, + <SvPersistStream::WriteLen> und <SvPersistStream::ReadLen> um eine + L"ange vor das Objekt zu schreiben. + + [Beispiel] + + Ein konkretes Beispiel ist im Konstruktor beschrieben. + Objekt A verweist auf B, dieses auf C und das wieder auf A. + C verweist auf D. + + Die Reihenfolge beim Speichern und Laden ist egal, sie muss nur + gleich sein: + Speichern: Laden: + A,B,C,D A,B,C,D richtig + B,A,C,D B,A,C,D richtig + C,A,B,D A,B,C,D falsch + A,B,C,D A,B,C falsch + + [Anmerkung] + + Das Dateiformat zwischen DBG_UTIL und !DBG_UTIL ist unterschiedlich, + kann aber von beiden Versionen gelesen werden. +*/ +{ + SvClassManager & rClassMgr; + SvStream * pStm; + Table aPTable; // Pointer und Key gedreht + SvPersistUIdx aPUIdx; + ULONG nStartIdx; + const SvPersistStream * pRefStm; + UINT32 nFlags; + + virtual ULONG GetData( void* pData, ULONG nSize ); + virtual ULONG PutData( const void* pData, ULONG nSize ); + virtual ULONG SeekPos( ULONG nPos ); + virtual void FlushData(); +protected: + ULONG GetCurMaxIndex( const SvPersistUIdx & ) const; + ULONG GetCurMaxIndex() const + { return GetCurMaxIndex( aPUIdx ); } + + void WriteObj( BYTE nHdr, SvPersistBase * pObj ); + UINT32 ReadObj( SvPersistBase * & rpObj, + BOOL bRegister ); +public: + BOOL IsStreamed( SvPersistBase * pObj ) const + { return 0 != GetIndex( pObj ); } + virtual void ResetError(); + + SvPersistStream( SvClassManager &, SvStream * pStream, + UINT32 nStartIdx = 1 ); + SvPersistStream( SvClassManager &, SvStream * pStream, + const SvPersistStream & rPersStm ); + ~SvPersistStream(); + + void SetStream( SvStream * pStream ); + SvStream * GetStream() const { return pStm; } + virtual USHORT IsA() const; + + SvPersistBase * GetObject( ULONG nIdx ) const; + ULONG GetIndex( SvPersistBase * ) const; + + void SetContextFlags( UINT32 n ) { nFlags = n; } + UINT32 GetContextFlags() const { return nFlags; } + + static void WriteCompressed( SvStream & rStm, UINT32 nVal ); + static UINT32 ReadCompressed( SvStream & rStm ); + + UINT32 WriteDummyLen(); + void WriteLen( UINT32 nLenPos ); + UINT32 ReadLen( UINT32 * pTestPos ); + + SvPersistStream& WritePointer( SvPersistBase * pObj ); + SvPersistStream& ReadPointer( SvPersistBase * & rpObj ); + TOOLS_DLLPUBLIC friend SvPersistStream& operator << (SvPersistStream &, SvPersistBase *); + TOOLS_DLLPUBLIC friend SvPersistStream& operator >> (SvPersistStream &, SvPersistBase * &); + + // Objekte halten ihre Id's w"ahrend geladen und + // gespeichert werden. + friend SvStream& operator >> ( SvStream &, SvPersistStream & ); + friend SvStream& operator << ( SvStream &, SvPersistStream & ); + ULONG InsertObj( SvPersistBase * ); + ULONG RemoveObj( SvPersistBase * ); +}; + +#endif // _PSTM_HXX diff --git a/tools/inc/tools/queue.hxx b/tools/inc/tools/queue.hxx new file mode 100644 index 000000000000..cb89bce6cdda --- /dev/null +++ b/tools/inc/tools/queue.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * 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 _QUEUE_HXX +#define _QUEUE_HXX + +#include <tools/solar.h> +#include <tools/contnr.hxx> + +// --------- +// - Queue - +// --------- + +#define QUEUE_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class Queue : private Container +{ +public: + using Container::Clear; + using Container::Count; + using Container::GetObject; + using Container::GetPos; + + Queue( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) : + Container( _nReSize, _nInitSize, _nReSize ) {} + Queue( const Queue& rQueue ) : Container( rQueue ) {} + + void Put( void* p ) { Container::Insert( p, CONTAINER_APPEND ); } + void* Get() { return Container::Remove( (ULONG)0 ); } + + Queue& operator =( const Queue& rQueue ) + { Container::operator =( rQueue ); return *this; } + + BOOL operator ==( const Queue& rQueue ) const + { return Container::operator ==( rQueue ); } + BOOL operator !=( const Queue& rQueue ) const + { return Container::operator !=( rQueue ); } +}; + +// ----------------- +// - DECLARE_QUEUE - +// ----------------- + +#define DECLARE_QUEUE( ClassName, Type ) \ +class ClassName : private Queue \ +{ \ +public: \ + using Queue::Clear; \ + using Queue::Count; \ + \ + ClassName( USHORT _nInitSize = 16, \ + USHORT _nReSize = 16 ) : \ + Queue( _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + Queue( rClassName ) {} \ + \ + void Put( Type p ) { Queue::Put( (void*)p ); } \ + Type Get() { return (Type)Queue::Get(); } \ + \ + Type GetObject( ULONG nIndex ) const \ + { return (Type)Queue::GetObject( nIndex ); } \ + ULONG GetPos( const Type p ) const \ + { return Queue::GetPos( (const void*)p ); } \ + ULONG GetPos( const Type p, ULONG nStartIndex, \ + BOOL bForward = TRUE ) const \ + { return Queue::GetPos( (const void*)p, \ + nStartIndex, \ + bForward ); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { Queue::operator =( rClassName ); \ + return *this; } \ + \ + BOOL operator ==( const Queue& rQueue ) const \ + { return Queue::operator ==( rQueue ); } \ + BOOL operator !=( const Queue& rQueue ) const \ + { return Queue::operator !=( rQueue ); } \ +}; + +#endif // _QUEUE_HXX diff --git a/tools/inc/tools/rc.h b/tools/inc/tools/rc.h new file mode 100644 index 000000000000..e11aed2937fd --- /dev/null +++ b/tools/inc/tools/rc.h @@ -0,0 +1,221 @@ +/************************************************************************* + * + * 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 _TOOLS_RC_H +#define _TOOLS_RC_H + +#include <tools/rcid.h> + +// Definition der Struktur die alle "Window"-Resourcen haben +// Hier sind die Fensterstyles definiert die nicht in WinBits sind +#define RSC_EXTRAMAPUNIT 0xFFFF //Wert nicht veraendern!!! + +typedef short RSWND_STYLE; +#define RSWND_DISABLED 0x01 +#define RSWND_CLIENTSIZE 0x02 + +#define WINDOW_XYMAPMODE 0x0001 +#define WINDOW_X 0x0002 +#define WINDOW_Y 0x0004 +#define WINDOW_WHMAPMODE 0x0008 +#define WINDOW_WIDTH 0x0010 +#define WINDOW_HEIGHT 0x0020 +#define WINDOW_TEXT 0x0080 +#define WINDOW_HELPTEXT 0x0100 +#define WINDOW_QUICKTEXT 0x0200 +#define WINDOW_EXTRALONG 0x0800 +#define WINDOW_UNIQUEID 0x1000 +#define WINDOW_BORDER_STYLE 0x2000 +#define WINDOW_HELPID 0x4000 + +// Definition der Struktur die alle "WorkWindow"-Resourcen haben +#define WORKWIN_SHOWNORMAL 0 +#define WORKWIN_SHOWMINIMIZED 1 +#define WORKWIN_SHOWMAXIMIZED 2 + +// Definition der Struktur der FixedBitmap-Resource. +#define RSC_FIXEDBITMAP_BITMAP 0x0001 + +// Definition der Struktur der FixedImage-Resource. +#define RSC_FIXEDIMAGE_IMAGE 0x0001 + +// Definition der Struktur des MenuButtons +#define RSCMENUBUTTON_MENU 0x01 + +// Definition der Struktur die alle Menu-Resourcen haben +#define RSC_MENU_ITEMS 0x01 +#define RSC_MENU_TEXT 0x02 +#define RSC_MENU_DEFAULTITEMID 0x04 + +// Hier sind die MenuItem-Resourceoptionen definiert +#define RSC_MENUITEM_SEPARATOR 0x001 +#define RSC_MENUITEM_ID 0x002 +#define RSC_MENUITEM_STATUS 0x004 +#define RSC_MENUITEM_TEXT 0x008 +#define RSC_MENUITEM_BITMAP 0x010 +#define RSC_MENUITEM_HELPTEXT 0x020 +#define RSC_MENUITEM_HELPID 0x040 +#define RSC_MENUITEM_KEYCODE 0x080 +#define RSC_MENUITEM_MENU 0x100 +#define RSC_MENUITEM_CHECKED 0x200 +#define RSC_MENUITEM_DISABLE 0x400 +#define RSC_MENUITEM_COMMAND 0x800 + +// Hier sind die AccelKey-Resourceoptionen definiert +#define ACCELITEM_ACCEL 0x01 +#define ACCELITEM_KEY 0x02 + +// Definition der Struktur die alle "Field"-Resourcen haben +#define PATTERNFORMATTER_STRICTFORMAT 0x01 +#define PATTERNFORMATTER_EDITMASK 0x02 +#define PATTERNFORMATTER_LITTERALMASK 0x04 + +#define NUMERICFORMATTER_MIN 0x01 +#define NUMERICFORMATTER_MAX 0x02 +#define NUMERICFORMATTER_STRICTFORMAT 0x04 +//#define NUMERICFORMATTER_I12 0x08 // erAck: got rid of class International (2005-06-17) +#define NUMERICFORMATTER_DECIMALDIGITS 0x10 +#define NUMERICFORMATTER_VALUE 0x20 +#define NUMERICFORMATTER_NOTHOUSANDSEP 0x40 + +#define METRICFORMATTER_UNIT 0x01 +#define METRICFORMATTER_CUSTOMUNITTEXT 0x02 + +#define DATEFORMATTER_MIN 0x01 +#define DATEFORMATTER_MAX 0x02 +#define DATEFORMATTER_LONGFORMAT 0x04 +#define DATEFORMATTER_STRICTFORMAT 0x08 +//#define DATEFORMATTER_I12 0x10 // erAck: got rid of class International (2005-06-17) +#define DATEFORMATTER_VALUE 0x20 + +#define TIMEFORMATTER_MIN 0x01 +#define TIMEFORMATTER_MAX 0x02 +#define TIMEFORMATTER_TIMEFIELDFORMAT 0x04 +#define TIMEFORMATTER_DURATION 0x08 +#define TIMEFORMATTER_STRICTFORMAT 0x10 +//#define TIMEFORMATTER_I12 0x20 // erAck: got rid of class International (2005-06-17) +#define TIMEFORMATTER_VALUE 0x40 + +#define NUMERICFIELD_FIRST 0x01 +#define NUMERICFIELD_LAST 0x02 +#define NUMERICFIELD_SPINSIZE 0x04 + +#define METRICFIELD_FIRST 0x01 +#define METRICFIELD_LAST 0x02 +#define METRICFIELD_SPINSIZE 0x04 + +#define CURRENCYFIELD_FIRST 0x01 +#define CURRENCYFIELD_LAST 0x02 +#define CURRENCYFIELD_SPINSIZE 0x04 + +#define DATEFIELD_FIRST 0x01 +#define DATEFIELD_LAST 0x02 + +#define TIMEFIELD_FIRST 0x01 +#define TIMEFIELD_LAST 0x02 + +// Definition der Struktur die alle "ToolBoxItem"-Resourcen haben +#define RSC_TOOLBOXITEM_ID 0x0001 +#define RSC_TOOLBOXITEM_TYPE 0x0002 +#define RSC_TOOLBOXITEM_STATUS 0x0004 +#define RSC_TOOLBOXITEM_HELPID 0x0008 +#define RSC_TOOLBOXITEM_TEXT 0x0010 +#define RSC_TOOLBOXITEM_HELPTEXT 0x0020 +#define RSC_TOOLBOXITEM_BITMAP 0x0040 +#define RSC_TOOLBOXITEM_IMAGE 0x0080 +#define RSC_TOOLBOXITEM_DISABLE 0x0100 +#define RSC_TOOLBOXITEM_STATE 0x0200 +#define RSC_TOOLBOXITEM_HIDE 0x0400 +#define RSC_TOOLBOXITEM_COMMAND 0x0800 +#define RSC_TOOLBOXITEM_MENUSTRINGS 0x1000 + +// Definition der Struktur die alle ToolBox-Resourcen haben +#define RSC_TOOLBOX_BUTTONTYPE 0x01 +#define RSC_TOOLBOX_ALIGN 0x02 +#define RSC_TOOLBOX_LINECOUNT 0x04 +#define RSC_TOOLBOX_FLOATLINES 0x08 +#define RSC_TOOLBOX_CUSTOMIZE 0x10 +#define RSC_TOOLBOX_MENUSTRINGS 0x20 +#define RSC_TOOLBOX_ITEMIMAGELIST 0x40 +#define RSC_TOOLBOX_ITEMLIST 0x80 + +// Definition der Struktur die alle MoreButton-Resourcen haben +#define RSC_MOREBUTTON_STATE 0x01 +#define RSC_MOREBUTTON_MAPUNIT 0x02 +#define RSC_MOREBUTTON_DELTA 0x04 + +// Definition der Struktur die alle FloatingWindow-Resourcen haben +#define RSC_FLOATINGWINDOW_WHMAPMODE 0x01 +#define RSC_FLOATINGWINDOW_WIDTH 0x02 +#define RSC_FLOATINGWINDOW_HEIGHT 0x04 +#define RSC_FLOATINGWINDOW_ZOOMIN 0x08 + +// Definition der Struktur die alle DockingWindow-Resourcen haben +#define RSC_DOCKINGWINDOW_XYMAPMODE 0x01 +#define RSC_DOCKINGWINDOW_X 0x02 +#define RSC_DOCKINGWINDOW_Y 0x04 +#define RSC_DOCKINGWINDOW_FLOATING 0x08 + +// Definition der Struktur die alle "TabControlItem"-Resourcen haben +#define RSC_TABCONTROLITEM_ID 0x0001 +#define RSC_TABCONTROLITEM_TEXT 0x0002 +#define RSC_TABCONTROLITEM_PAGERESID 0x0008 + +// Definition der Struktur die alle TabControl-Resourcen haben +#define RSC_TABCONTROL_ITEMLIST 0x01 + +// Definition der Struktur des ImageButtons +#define RSC_IMAGEBUTTON_IMAGE 0x01 +#define RSC_IMAGEBUTTON_SYMBOL 0x02 +#define RSC_IMAGEBUTTON_STATE 0x04 + +// Definition der Struktur des ImageRadioButtons +#define RSC_IMAGERADIOBUTTON_IMAGE 0x01 + +// Definition der Struktur des Image +#define RSC_IMAGE_IMAGEBITMAP 0x01 +#define RSC_IMAGE_MASKBITMAP 0x02 +#define RSC_IMAGE_MASKCOLOR 0x04 + +// Definition der Struktur des Image +#define RSC_IMAGELIST_IMAGEBITMAP 0x01 +#define RSC_IMAGELIST_MASKBITMAP 0x02 +#define RSC_IMAGELIST_MASKCOLOR 0x04 +#define RSC_IMAGELIST_IDLIST 0x08 +#define RSC_IMAGELIST_IDCOUNT 0x10 + +// obsolete, should be removed by MM +#define RSC_COLOR (RSC_NOTYPE + 0x16) +#define TIME_HOUR 0x01 +#define TIME_MINUTE 0x02 +#define TIME_SECOND 0x04 +#define TIME_SEC100 0x08 +#define DATE_YEAR 0x01 +#define DATE_MONTH 0x02 +#define DATE_DAY 0x04 + +#endif // _TOOLS_RC_H diff --git a/tools/inc/tools/rc.hxx b/tools/inc/tools/rc.hxx new file mode 100644 index 000000000000..15e077c3c62c --- /dev/null +++ b/tools/inc/tools/rc.hxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * 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 _TOOLS_RC_HXX +#define _TOOLS_RC_HXX + +#include "tools/toolsdllapi.h" +#include <i18npool/lang.h> +#include <tools/string.hxx> +#include <tools/resmgr.hxx> + +// ------------ +// - Resource - +// ------------ + +class TOOLS_DLLPUBLIC Resource +{ + protected: + ResMgr* m_pResMgr; + + // check availability of Resource + BOOL IsAvailableRes( const ResId& rId ) const + { return m_pResMgr->IsAvailable( rId, this ); } + + // Load a Resource + void GetRes( const ResId& rResId ); + + // check Resource state + void TestRes(); + + // Get a pointer to the Resource's data + void* GetClassRes() + { return m_pResMgr->GetClass(); } + + // read a string from the resource + static sal_uInt32 GetStringRes( UniString& rStr, const BYTE* pStr ) + { return ResMgr::GetString( rStr, pStr ); } + + // increase the memory pointer gotten by GetClassRes() + void* IncrementRes( sal_uInt32 nBytes ) + { return m_pResMgr->Increment( nBytes ); } + + // return the memory size of a Resource data block + static sal_uInt32 GetObjSizeRes( RSHEADER_TYPE * pHT ) + { return ResMgr::GetObjSize( pHT ); } + + // return the remaining size of this Resource's data + sal_uInt32 GetRemainSizeRes() + { return m_pResMgr->GetRemainSize(); } + + // get a 32bit value from Resource data + static sal_Int32 GetLongRes( void * pLong ) + { return ResMgr::GetLong( pLong ); } + // get a 16bit value from Resource data + static sal_Int16 GetShortRes( void * pShort ) + { return ResMgr::GetShort( pShort ); } + + // read a 32bit value from resource data and increment pointer + sal_Int32 ReadLongRes() + { return m_pResMgr->ReadLong(); } + // read a 16bit value from resource data and increment pointer + sal_Int16 ReadShortRes() + { return m_pResMgr->ReadShort(); } + // read a string from resource data and increment pointer + UniString ReadStringRes() + { return m_pResMgr->ReadString(); } + // read a byte string from resource data and increment pointer + rtl::OString ReadByteStringRes() + { return m_pResMgr->ReadByteString(); } + + // Gibt die Resource frei (this-Zeiger fuer Fehlerueberpruefung) + // free the resource from m_pResMgr's stack (pass this ptr for validation) + void FreeResource() + { m_pResMgr->PopContext( this ); } + + // constructors + Resource() : m_pResMgr( NULL ) {} + Resource( const ResId& rResId ); + + public: + #ifdef DBG_UTIL + ~Resource() { TestRes(); } + #else + ~Resource() {} + #endif +}; + +#endif // _SV_RC_HXX diff --git a/tools/inc/tools/rcid.h b/tools/inc/tools/rcid.h new file mode 100644 index 000000000000..3daf64c547a7 --- /dev/null +++ b/tools/inc/tools/rcid.h @@ -0,0 +1,134 @@ +/************************************************************************* + * + * 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 _TOOLS_RCID_H +#define _TOOLS_RCID_H + +#include <tools/resid.hxx> + +// Definition der Versionsnummer +#define RSCVERSION_ID 200U +// Definition eines ungueltige Identifiers. +#define RC_NO_ID (sal_uInt32(0xFFFFFFFF)) + +// Dies sind die Resourcetypen +// Mindestens 0x100 wegen MS-Windows Resourcetypen +//#define RSC_NOTYPE 0x100 +//RSC_NOTYPE wird in resid.hxx definiert +#define RSC_BYNAME (RSC_NOTYPE + 0x01) +#define RSC_VERSIONCONTROL (RSC_NOTYPE + 0x02) // Versionskontrolle + +#define RSC_RESOURCE (RSC_NOTYPE + 0x10) +#define RSC_STRING (RSC_NOTYPE + 0x11) +#define RSC_BITMAP (RSC_NOTYPE + 0x13) +#define RSC_ACCEL (RSC_NOTYPE + 0x1a) +#define RSC_ACCELITEM (RSC_NOTYPE + 0x1b)// nur intern +#define RSC_MENU (RSC_NOTYPE + 0x1c) +#define RSC_MENUITEM (RSC_NOTYPE + 0x1d)// nur intern +#define RSC_KEYCODE (RSC_NOTYPE + 0x1f) +#define RSC_TIME (RSC_NOTYPE + 0x20) +#define RSC_DATE (RSC_NOTYPE + 0x21) +//#define RSC_INTERNATIONAL (RSC_NOTYPE + 0x22) // erAck: got rid of class International (2005-06-17) +#define RSC_IMAGE (RSC_NOTYPE + 0x23) +#define RSC_IMAGELIST (RSC_NOTYPE + 0x24) + +#define RSC_MESSBOX (RSC_NOTYPE + 0x30) +#define RSC_INFOBOX (RSC_NOTYPE + 0x31) +#define RSC_WARNINGBOX (RSC_NOTYPE + 0x32) +#define RSC_ERRORBOX (RSC_NOTYPE + 0x33) +#define RSC_QUERYBOX (RSC_NOTYPE + 0x34) +#define RSC_WINDOW (RSC_NOTYPE + 0x35) +#define RSC_SYSWINDOW (RSC_NOTYPE + 0x36) +#define RSC_WORKWIN (RSC_NOTYPE + 0x37) +#define RSC_MDIWINDOW (RSC_NOTYPE + 0x38) +#define RSC_FLOATINGWINDOW (RSC_NOTYPE + 0x39) +#define RSC_DIALOG (RSC_NOTYPE + 0x3a) +#define RSC_MODELESSDIALOG (RSC_NOTYPE + 0x3b) +#define RSC_MODALDIALOG (RSC_NOTYPE + 0x3c) +#define RSC_CONTROL (RSC_NOTYPE + 0x44) +#define RSC_BUTTON (RSC_NOTYPE + 0x45) +#define RSC_PUSHBUTTON (RSC_NOTYPE + 0x46) +#define RSC_OKBUTTON (RSC_NOTYPE + 0x47) +#define RSC_CANCELBUTTON (RSC_NOTYPE + 0x48) +#define RSC_HELPBUTTON (RSC_NOTYPE + 0x49) +#define RSC_IMAGEBUTTON (RSC_NOTYPE + 0x4a) +#define RSC_MENUBUTTON (RSC_NOTYPE + 0x4b) +#define RSC_MOREBUTTON (RSC_NOTYPE + 0x4c) +#define RSC_SPINBUTTON (RSC_NOTYPE + 0x4d) +#define RSC_RADIOBUTTON (RSC_NOTYPE + 0x4e) +#define RSC_IMAGERADIOBUTTON (RSC_NOTYPE + 0x4f) +#define RSC_CHECKBOX (RSC_NOTYPE + 0x50) +#define RSC_TRISTATEBOX (RSC_NOTYPE + 0x51) +#define RSC_EDIT (RSC_NOTYPE + 0x52) +#define RSC_MULTILINEEDIT (RSC_NOTYPE + 0x53) +#define RSC_COMBOBOX (RSC_NOTYPE + 0x54) +#define RSC_LISTBOX (RSC_NOTYPE + 0x55) +#define RSC_MULTILISTBOX (RSC_NOTYPE + 0x56) +#define RSC_TEXT (RSC_NOTYPE + 0x57) +#define RSC_FIXEDLINE (RSC_NOTYPE + 0x58) +#define RSC_FIXEDBITMAP (RSC_NOTYPE + 0x59) +#define RSC_FIXEDIMAGE (RSC_NOTYPE + 0x5a) +#define RSC_GROUPBOX (RSC_NOTYPE + 0x5c) +#define RSC_SCROLLBAR (RSC_NOTYPE + 0x5d) +#define RSC_SCROLLBARBOX (RSC_NOTYPE + 0x5e) +#define RSC_SPLITTER (RSC_NOTYPE + 0x5f) +#define RSC_SPLITWINDOW (RSC_NOTYPE + 0x60) +#define RSC_SPINFIELD (RSC_NOTYPE + 0x61) +#define RSC_PATTERNFIELD (RSC_NOTYPE + 0x62) +#define RSC_NUMERICFIELD (RSC_NOTYPE + 0x63) +#define RSC_METRICFIELD (RSC_NOTYPE + 0x64) +#define RSC_CURRENCYFIELD (RSC_NOTYPE + 0x65) +#define RSC_DATEFIELD (RSC_NOTYPE + 0x66) +#define RSC_TIMEFIELD (RSC_NOTYPE + 0x67) +#define RSC_PATTERNBOX (RSC_NOTYPE + 0x68) +#define RSC_NUMERICBOX (RSC_NOTYPE + 0x69) +#define RSC_METRICBOX (RSC_NOTYPE + 0x6a) +#define RSC_CURRENCYBOX (RSC_NOTYPE + 0x6b) +#define RSC_DATEBOX (RSC_NOTYPE + 0x6c) +#define RSC_TIMEBOX (RSC_NOTYPE + 0x6d) +#define RSC_LONGCURRENCYFIELD (RSC_NOTYPE + 0x6e) +#define RSC_LONGCURRENCYBOX (RSC_NOTYPE + 0x6f) +#define RSC_TOOLBOXITEM (RSC_NOTYPE + 0x70) +#define RSC_TOOLBOX (RSC_NOTYPE + 0x71) +#define RSC_DOCKINGWINDOW (RSC_NOTYPE + 0x72) +#define RSC_STATUSBAR (RSC_NOTYPE + 0x73) +#define RSC_TABPAGE (RSC_NOTYPE + 0x74) +#define RSC_TABCONTROL (RSC_NOTYPE + 0x75) +#define RSC_TABDIALOG (RSC_NOTYPE + 0x76) +#define RSC_TABCONTROLITEM (RSC_NOTYPE + 0x77) +#define RSC_TREELISTBOX (RSC_NOTYPE + 0x78) +#define RSC_STRINGARRAY (RSC_NOTYPE + 0x79) + +// (RSC_NOTYPE + 0x200) - (RSC_NOTYPE + 0x300) fuer Sfx reserviert + +#define RT_SYS_BITMAP (RSC_NOTYPE + 0xf2) +#define RT_SYS_STRING (RSC_NOTYPE + 0xf3) // Sonderbehandlung +#define RT_SYS_FILE (RSC_NOTYPE + 0xf4) // nicht implementiert + +// (RSC_NOTYPE + 0x200) - (RSC_NOTYPE + 0x300) fuer Sfx reserviert + +#endif // _RCID_H diff --git a/tools/inc/tools/ref.hxx b/tools/inc/tools/ref.hxx new file mode 100644 index 000000000000..ea1886b73e04 --- /dev/null +++ b/tools/inc/tools/ref.hxx @@ -0,0 +1,456 @@ +/************************************************************************* + * + * 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 _REF_HXX +#define _REF_HXX + +#include "tools/toolsdllapi.h" +#include <tools/list.hxx> +#include <tools/link.hxx> + +//========================================================================= + +#define PRV_SV_DECL_REF_SIGNATURE( ClassName, Ref ) \ + inline ClassName##Ref() { pObj = 0; } \ + inline ClassName##Ref( const ClassName##Ref & rObj ); \ + inline ClassName##Ref( ClassName * pObjP ); \ + inline void Clear(); \ + inline ~ClassName##Ref(); \ + inline ClassName##Ref & operator = ( const ClassName##Ref & rObj ); \ + inline ClassName##Ref & operator = ( ClassName * pObj ); \ + inline BOOL Is() const { return pObj != NULL; } \ + inline ClassName * operator & () const { return pObj; } \ + inline ClassName * operator -> () const { return pObj; } \ + inline ClassName & operator * () const { return *pObj; } \ + inline operator ClassName * () const { return pObj; } + +#define PRV_SV_IMPL_REF_COUNTERS( ClassName, Ref, AddRef, AddNextRef, ReleaseRef, Init, pRefbase ) \ +inline ClassName##Ref::ClassName##Ref( const ClassName##Ref & rObj ) \ + { pObj = rObj.pObj; if( pObj ) { Init pRefbase->AddNextRef; } } \ +inline ClassName##Ref::ClassName##Ref( ClassName * pObjP ) \ +{ pObj = pObjP; if( pObj ) { Init pRefbase->AddRef; } } \ +inline void ClassName##Ref::Clear() \ +{ \ + if( pObj ) \ + { \ + ClassName* const pRefObj = pRefbase; \ + pObj = 0; \ + pRefObj->ReleaseRef; \ + } \ +} \ +inline ClassName##Ref::~ClassName##Ref() \ +{ if( pObj ) { pRefbase->ReleaseRef; } } \ +inline ClassName##Ref & ClassName##Ref:: \ + operator = ( const ClassName##Ref & rObj ) \ +{ \ + if( rObj.pObj ) rObj.pRefbase->AddNextRef; \ + ClassName* const pRefObj = pRefbase; \ + pObj = rObj.pObj; \ + Init if( pRefObj ) { pRefObj->ReleaseRef; } \ + return *this; \ +} \ +inline ClassName##Ref & ClassName##Ref::operator = ( ClassName * pObjP ) \ +{ return *this = ClassName##Ref( pObjP ); } + +#define PRV_SV_DECL_REF_LOCK(ClassName, Ref) \ +protected: \ + ClassName * pObj; \ +public: \ +PRV_SV_DECL_REF_SIGNATURE(ClassName, Ref) + +#define PRV_SV_DECL_REF( ClassName ) \ +PRV_SV_DECL_REF_LOCK( ClassName, Ref ) + +#define PRV_SV_DECL_LOCK( ClassName ) \ +PRV_SV_DECL_REF_LOCK( ClassName, Lock ) + +#define SV_DECL_REF( ClassName ) \ +class ClassName; \ +class ClassName##Ref \ +{ \ + PRV_SV_DECL_REF( ClassName ) \ +}; + +#define SV_DECL_LOCK( ClassName ) \ +class ClassName; \ +class ClassName##Lock \ +{ \ + PRV_SV_DECL_LOCK( ClassName ) \ +}; + +#define SV_IMPL_REF( ClassName ) \ +PRV_SV_IMPL_REF_COUNTERS( ClassName, Ref, AddRef(), AddNextRef(),\ + ReleaseReference(), EMPTYARG, pObj ) + +#define SV_IMPL_LOCK( ClassName ) \ +PRV_SV_IMPL_REF_COUNTERS( ClassName, Lock, OwnerLock( TRUE ), \ + OwnerLock( TRUE ), OwnerLock( FALSE ), \ + EMPTYARG, pObj ) + +#define SV_DECL_IMPL_REF(ClassName) \ + SV_DECL_REF(ClassName) \ + SV_IMPL_REF(ClassName) + +#define SV_DECL_IMPL_LOCK( ClassName ) \ + SV_DECL_LOCK(ClassName) \ + SV_IMPL_LOCK(ClassName) + + +/************************** S v R e f L i s t ****************************/ +#define PRV_SV_DECL_REF_LIST(CN,EN,vis) \ +DECLARE_LIST(CN##List,EN)\ +class vis CN##MemberList : public CN##List\ +{\ +public:\ +inline CN##MemberList();\ +inline CN##MemberList(USHORT nInitSz, USHORT nResize );\ +inline CN##MemberList( const CN##MemberList & rRef );\ +inline ~CN##MemberList();\ +inline CN##MemberList & operator =\ + ( const CN##MemberList & rRef );\ +inline void Clear();\ +inline void Insert( EN p )\ +{ CN##List::Insert( p ); p->AddRef();}\ +inline void Insert( EN p, ULONG nIndex )\ +{ CN##List::Insert( p, nIndex ); p->AddRef();}\ +inline void Insert( EN p, EN pOld )\ +{ CN##List::Insert( p, pOld ); p->AddRef();}\ +inline void Append( EN p )\ +{ Insert( p, LIST_APPEND );}\ +inline EN Remove();\ +inline EN Remove( ULONG nIndex );\ +inline EN Remove( EN p );\ +inline EN Replace( EN p );\ +inline EN Replace( EN p, ULONG nIndex );\ +inline EN Replace( EN pNew, EN pOld );\ +inline void Append( const CN##MemberList & );\ +}; + +#define SV_DECL_REF_LIST(CN,EN) \ +PRV_SV_DECL_REF_LIST(CN,EN,/* empty */) +#define SV_DECL_REF_LIST_VISIBILITY(CN,EN,vis) \ +PRV_SV_DECL_REF_LIST(CN,EN,vis) + +/************************** S v R e f L i s t ****************************/ +#define SV_IMPL_REF_LIST( CN, EN ) \ +inline CN##MemberList::CN##MemberList(){}\ +inline CN##MemberList::CN##MemberList(USHORT nInitSz, USHORT nResize )\ + : CN##List( nInitSz, nResize ){}\ +inline CN##MemberList::CN##MemberList( const CN##MemberList & rRef ) \ + : CN##List( rRef ) \ +{\ + ULONG nOldCount = Count(); \ + EN pEntry = First(); \ + while( pEntry ) \ + { pEntry->AddRef(); pEntry = Next(); } \ + Seek( nOldCount ); /* auch Curser gleich */ \ +}\ +inline CN##MemberList::~CN##MemberList() { Clear(); } \ +inline CN##MemberList & CN##MemberList::operator = \ + ( const CN##MemberList & rRef ) \ +{\ + CN##MemberList & rList = (CN##MemberList &)rRef; \ + ULONG nOldCount = rList.Count(); \ + /* Count der Objekte erhoehen */ \ + EN pEntry = rList.First(); \ + while( pEntry ) \ + { pEntry->AddRef(); pEntry = rList.Next(); } \ + rList.Seek( nOldCount ); /* Curser zurueck */ \ + /* Liste kopieren */ \ + Clear(); \ + CN##List::operator = ( rRef ); \ + return *this; \ +}\ +inline void CN##MemberList::Clear() \ +{\ + EN pEntry = Last();\ + while( NULL != pEntry )\ + pEntry = Remove();\ +}\ +inline EN CN##MemberList::Remove() \ +{\ + EN p = CN##List::Remove(); \ + if( p ) p->ReleaseReference(); return p; \ +}\ +inline EN CN##MemberList::Remove( ULONG nIndex ) \ +{\ + EN p = CN##List::Remove( nIndex ); \ + if( p ) p->ReleaseReference(); return p; \ +}\ +inline EN CN##MemberList::Remove( EN p ) \ +{\ + p = CN##List::Remove( p ); \ + if( p ) p->ReleaseReference(); return p; \ +}\ +inline EN CN##MemberList::Replace( EN p ) \ +{\ + p->AddRef(); p = CN##List::Replace( p ); \ + if( p ) p->ReleaseReference(); return p; \ +}\ +inline EN CN##MemberList::Replace( EN p, ULONG nIndex ) \ +{\ + p->AddRef(); p = CN##List::Replace( p, nIndex ); \ + if( p ) p->ReleaseReference(); return p; \ +}\ +inline EN CN##MemberList::Replace( EN pNew, EN pOld ) \ +{\ + pNew->AddRef(); CN##List::Replace( pNew, pOld ); \ + if( pOld ) pOld->ReleaseReference(); return pOld; \ +}\ +inline void CN##MemberList::Append( const CN##MemberList & rList )\ +{\ + for( ULONG i = 0; i < rList.Count(); i++ )\ + Append( rList.GetObject( i ) );\ +} + +/************************** S V _ D E C L _ R E F _ L I S T **************/ +#define SV_DECL_IMPL_REF_LIST(ClassName,EntryName) \ + SV_DECL_REF_LIST(ClassName,EntryName) \ + SV_IMPL_REF_LIST(ClassName,EntryName) + +/************************** S v M e m b e r L i s t **********************/ +#define PRV_SV_DECL_MEMBER_LIST(Class,EntryName) \ + Class##MemberList() {} \ +inline Class##MemberList(USHORT nInitSz,USHORT nResize);\ +inline void Insert( EntryName p ); \ +inline void Insert( EntryName p, ULONG nIndex ); \ +inline void Insert( EntryName p, EntryName pOld ); \ +inline void Append( EntryName p ); \ +inline EntryName Remove(); \ +inline EntryName Remove( ULONG nIndex ); \ +inline EntryName Remove( EntryName p ); \ +inline EntryName Replace( EntryName p ); \ +inline EntryName Replace( EntryName p, ULONG nIndex );\ +inline EntryName Replace( EntryName pNew, EntryName pOld );\ +inline EntryName GetCurObject() const;\ +inline EntryName GetObject( ULONG nIndex ) const;\ +inline ULONG GetPos( const EntryName ) const;\ +inline ULONG GetPos( const EntryName, ULONG nStartIndex,\ + BOOL bForward = TRUE ) const;\ +inline EntryName Seek( ULONG nIndex );\ +inline EntryName Seek( EntryName p );\ +inline EntryName First();\ +inline EntryName Last();\ +inline EntryName Next();\ +inline EntryName Prev();\ +inline void Append( const Class##MemberList & rList ); + +#define PRV_SV_IMPL_MEMBER_LIST(ClassName,EntryName,BaseList)\ +inline ClassName##MemberList::ClassName##MemberList\ + (USHORT nInitSz,USHORT nResize)\ + : BaseList( nInitSz, nResize ){}\ +inline void ClassName##MemberList::Insert( EntryName p )\ + {BaseList::Insert(p);}\ +inline void ClassName##MemberList::Insert( EntryName p, ULONG nIdx )\ + {BaseList::Insert(p,nIdx);}\ +inline void ClassName##MemberList::Insert( EntryName p, EntryName pOld )\ + {BaseList::Insert(p,pOld);}\ +inline void ClassName##MemberList::Append( EntryName p )\ + {BaseList::Append(p);}\ +inline EntryName ClassName##MemberList::Remove()\ + {return (EntryName)BaseList::Remove();}\ +inline EntryName ClassName##MemberList::Remove( ULONG nIdx )\ + {return (EntryName)BaseList::Remove(nIdx);}\ +inline EntryName ClassName##MemberList::Remove( EntryName p )\ + {return (EntryName)BaseList::Remove(p);}\ +inline EntryName ClassName##MemberList::Replace( EntryName p )\ + {return (EntryName)BaseList::Replace(p);}\ +inline EntryName ClassName##MemberList::Replace( EntryName p, ULONG nIdx )\ + {return (EntryName)BaseList::Replace(p,nIdx);}\ +inline EntryName ClassName##MemberList::Replace( EntryName p, EntryName pOld )\ + {return (EntryName)BaseList::Replace(p,pOld);}\ +inline EntryName ClassName##MemberList::GetCurObject() const\ + {return (EntryName)BaseList::GetCurObject();}\ +inline EntryName ClassName##MemberList::GetObject( ULONG nIdx ) const\ + {return (EntryName)BaseList::GetObject( nIdx );}\ +inline EntryName ClassName##MemberList::Seek( ULONG nIdx )\ + {return (EntryName)BaseList::Seek( nIdx );}\ +inline EntryName ClassName##MemberList::Seek( EntryName p )\ + {return (EntryName)BaseList::Seek( p );}\ +inline EntryName ClassName##MemberList::First()\ + {return (EntryName)BaseList::First();}\ +inline EntryName ClassName##MemberList::Last()\ + {return (EntryName)BaseList::Last();}\ +inline EntryName ClassName##MemberList::Next()\ + {return (EntryName)BaseList::Next();}\ +inline EntryName ClassName##MemberList::Prev()\ + {return (EntryName)BaseList::Prev();}\ +inline void ClassName##MemberList::Append( const ClassName##MemberList & rList )\ + {BaseList::Append(rList);}\ +inline ULONG ClassName##MemberList::GetPos( const EntryName p) const\ + {return BaseList::GetPos( p );}\ +inline ULONG ClassName##MemberList::GetPos\ + ( const EntryName p, ULONG nStart, BOOL bForward ) const\ + {return BaseList::GetPos( p, nStart, bForward );} + +#define SV_DECL_MEMBER_LIST(ClassName,EntryName)\ +class ClassName##MemberList : public SvRefBaseMemberList\ +{\ +public:\ + PRV_SV_DECL_MEMBER_LIST(ClassName,EntryName)\ +}; + +#define SV_IMPL_MEMBER_LIST(ClassName,EntryName)\ + PRV_SV_IMPL_MEMBER_LIST(ClassName,EntryName,SvRefBaseMemberList) + +#define SV_DECL_IMPL_MEMBER_LIST(ClassName,EntryName)\ +SV_DECL_MEMBER_LIST(ClassName,EntryName)\ +SV_IMPL_MEMBER_LIST(ClassName,EntryName) + +/************************** S v R e f B a s e ****************************/ +#define SV_NO_DELETE_REFCOUNT 0x80000000 +class TOOLS_DLLPUBLIC SvRefBase +{ + UINT32 nRefCount; +#if defined (GCC) && (defined (C281) || defined (C290) || defined (C291)) +public: +#else +protected: +#endif + virtual ~SvRefBase(); + virtual void QueryDelete(); +public: + SvRefBase() { nRefCount = SV_NO_DELETE_REFCOUNT; } + SvRefBase( const SvRefBase & /* rObj */ ) + { nRefCount = SV_NO_DELETE_REFCOUNT; } + SvRefBase & operator = ( const SvRefBase & ) { return *this; } + + void RestoreNoDelete() + { + if( nRefCount < SV_NO_DELETE_REFCOUNT ) + nRefCount += SV_NO_DELETE_REFCOUNT; + } + UINT32 AddMulRef( UINT32 n ) { return nRefCount += n; } + UINT32 AddNextRef() { return ++nRefCount; } + UINT32 AddRef() + { + if( nRefCount >= SV_NO_DELETE_REFCOUNT ) + nRefCount -= SV_NO_DELETE_REFCOUNT; + return ++nRefCount; + } + void ReleaseReference() + { + if( !--nRefCount ) + QueryDelete(); + } + UINT32 ReleaseRef() + { + UINT32 n = --nRefCount; + if( !n ) + QueryDelete(); + return n; + } + UINT32 GetRefCount() const { return nRefCount; } +}; + +//#if 0 // _SOLAR__PRIVATE +#ifndef EMPTYARG +#define EMPTYARG +#endif +//#endif + +SV_DECL_IMPL_REF(SvRefBase) + +SV_DECL_REF_LIST(SvRefBase,SvRefBase*) + +class SvWeakBase; +class SvWeakHdl : public SvRefBase +{ + friend class SvWeakBase; + SvWeakBase* _pObj; +public: + void ResetWeakBase( ) { _pObj = 0; } +private: + SvWeakHdl( SvWeakBase* pObj ) : _pObj( pObj ) {} +public: + SvWeakBase* GetObj() { return _pObj; } +}; + +SV_DECL_IMPL_REF( SvWeakHdl ) + +class SvCompatWeakHdl : public SvRefBase +{ + friend class SvCompatWeakBase; + void* _pObj; + SvCompatWeakHdl( void* pObj ) : _pObj( pObj ) {} +public: + void ResetWeakBase( ) { _pObj = 0; } + void* GetObj() { return _pObj; } +}; + +SV_DECL_IMPL_REF( SvCompatWeakHdl ) + +class SvWeakBase +{ + SvWeakHdlRef _xHdl; +public: + SvWeakHdl* GetHdl() { return _xHdl; } + + // Wg CompilerWarnung nicht ueber Initializer + SvWeakBase() { _xHdl = new SvWeakHdl( this ); } + ~SvWeakBase() { _xHdl->ResetWeakBase(); } +}; + +class SvCompatWeakBase +{ + SvCompatWeakHdlRef _xHdl; +public: + SvCompatWeakHdl* GetHdl() { return _xHdl; } + + // Wg CompilerWarnung nicht ueber Initializer + SvCompatWeakBase( void* pObj ) { _xHdl = new SvCompatWeakHdl( pObj ); } + ~SvCompatWeakBase() { _xHdl->ResetWeakBase(); } +}; + +#define SV_DECL_WEAK_IMPL( ClassName, HdlName ) \ +class ClassName##Weak \ +{ \ + HdlName _xHdl; \ +public: \ + inline ClassName##Weak( ) {} \ + inline ClassName##Weak( ClassName* pObj ) { \ + if( pObj ) _xHdl = pObj->GetHdl(); } \ + inline void Clear() { _xHdl.Clear(); } \ + inline ClassName##Weak& operator = ( ClassName * pObj ) { \ + _xHdl = pObj ? pObj->GetHdl() : 0; return *this; } \ + inline BOOL Is() const { \ + return _xHdl.Is() && _xHdl->GetObj(); } \ + inline ClassName * operator & () const { \ + return (ClassName*) ( _xHdl.Is() ? _xHdl->GetObj() : 0 ); } \ + inline ClassName * operator -> () const { \ + return (ClassName*) ( _xHdl.Is() ? _xHdl->GetObj() : 0 ); } \ + inline ClassName & operator * () const { \ + return *(ClassName*) _xHdl->GetObj(); } \ + inline operator ClassName * () const { \ + return (ClassName*) (_xHdl.Is() ? _xHdl->GetObj() : 0 ); } \ +}; + +#define SV_DECL_WEAK( ClassName ) SV_DECL_WEAK_IMPL( ClassName, SvWeakHdlRef ) +#define SV_DECL_COMPAT_WEAK( ClassName ) SV_DECL_WEAK_IMPL( ClassName, SvCompatWeakHdlRef ) + +SV_DECL_WEAK( SvWeakBase ) + +#endif // _Weak_HXX diff --git a/tools/inc/tools/resary.hxx b/tools/inc/tools/resary.hxx new file mode 100644 index 000000000000..b6cd8f8943c6 --- /dev/null +++ b/tools/inc/tools/resary.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * 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 _TOOLS_RESARY_HXX +#define _TOOLS_RESARY_HXX + +#include "tools/toolsdllapi.h" +#include <tools/resid.hxx> +#include <tools/rc.hxx> + +// --------------------- +// - ImplResStringItem - +// --------------------- + +struct ImplResStringItem +{ + XubString maStr; + long mnValue; + +//#if 0 // _SOLAR__PRIVATE +#ifdef _TOOLS_RESARY_CXX + ImplResStringItem( const XubString& rStr ) : + maStr( rStr ) {} +#endif +//#endif +}; + +// ------------------ +// - ResStringArray - +// ------------------ + +#define RESARRAY_INDEX_NOTFOUND (0xffffffff) + +class TOOLS_DLLPUBLIC ResStringArray +{ + private: + // --------------------- + // - ImplResStringItem - + // --------------------- + struct ImplResStringItem + { + XubString m_aStr; + long m_nValue; + + ImplResStringItem( const XubString& rStr, long nValue = 0 ) : + m_aStr( rStr ), + m_nValue( nValue ) + {} + }; + + std::vector< ImplResStringItem > m_aStrings; + + public: + ResStringArray( const ResId& rResId ); + ~ResStringArray(); + + const XubString& GetString( sal_uInt32 nIndex ) const + { return (nIndex < m_aStrings.size()) ? m_aStrings[nIndex].m_aStr : String::EmptyString(); } + long GetValue( sal_uInt32 nIndex ) const + { return (nIndex < m_aStrings.size()) ? m_aStrings[nIndex].m_nValue : -1; } + sal_uInt32 Count() const { return sal_uInt32(m_aStrings.size()); } + + sal_uInt32 FindIndex( long nValue ) const; + + private: + ResStringArray( const ResStringArray& ); + ResStringArray& operator=( const ResStringArray& ); +}; + +#endif // _TOOLS_RESARY_HXX diff --git a/tools/inc/tools/resid.hxx b/tools/inc/tools/resid.hxx new file mode 100644 index 000000000000..cfefce8e6ab0 --- /dev/null +++ b/tools/inc/tools/resid.hxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * 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 _TOOLS_RESID_HXX +#define _TOOLS_RESID_HXX + +#include <tools/solar.h> +#include <osl/diagnose.h> + +struct RSHEADER_TYPE; +typedef sal_uInt32 RESOURCE_TYPE; +#define RSC_NOTYPE 0x100 +#define RSC_DONTRELEASE (sal_uInt32(1 << 31)) + +class ResMgr; + +//--------- +//- ResId - +//--------- + +class ResId +{ + /* + consider two cases: either m_pResource is valid and points + two a resource data buffer; then m_nResId and m_pResMgr are + not used and may be 0 resp. NULL + or m_pResource is NULL, the m_nResId and m_pResMgr must be valid. + In this case the highest bit if set decides whether to + not to release the Resource context after loading this id + */ + RSHEADER_TYPE* m_pResource; + + mutable sal_uInt32 m_nResId; // Resource Identifier + mutable RESOURCE_TYPE m_nRT; // type for loading (mutable to be set later) + mutable ResMgr * m_pResMgr; // load from this ResMgr (mutable for setting on demand) + mutable RESOURCE_TYPE m_nRT2; // type for loading (supercedes m_nRT) + mutable sal_uInt32 m_nWinBits; // container for original style bits on a window in a resource + + void ImplInit( sal_uInt32 nId, ResMgr& rMgr, RSHEADER_TYPE* pRes ) + { + m_pResource = pRes; m_nResId = nId; m_nRT = RSC_NOTYPE; m_pResMgr = &rMgr; m_nRT2 = RSC_NOTYPE; m_nWinBits = 0; + OSL_ENSURE( m_pResMgr != NULL, "ResId without ResMgr created" ); + } + public: + ResId( RSHEADER_TYPE * pRc, ResMgr& rMgr ) + { + ImplInit( 0, rMgr, pRc ); + } + ResId( sal_uInt32 nId, ResMgr& rMgr ) + { + ImplInit( nId, rMgr, NULL ); + } + // backwards compatibility; avoid ambiguities + ResId( USHORT nId, ResMgr& rMgr ) + { + ImplInit( sal_uInt32(nId), rMgr, NULL ); + } + ResId( int nId, ResMgr& rMgr ) + { + ImplInit( sal_uInt32(nId), rMgr, NULL ); + } + ResId( long nId, ResMgr& rMgr ) + { + ImplInit( sal_uInt32(nId), rMgr, NULL ); + } + + sal_uInt32 GetWinBits() const + { return m_nWinBits; } + void SetWinBits( sal_uInt32 nBits ) const + { m_nWinBits = nBits; } + + RESOURCE_TYPE GetRT() const { return( m_nRT ); } + const ResId & SetRT( RESOURCE_TYPE nType ) const + /* + Set the type if not already set. Ask for tye with GetRT() + + [Example] + ResId aId( 1000 ); + aId.SetRT( RSC_WINDOW ); // settype window Window + aId.SetRT( RSC_BUTTON ); // will not set type Button + //aId.GetRT() == RSC_WINDOW is true + + @see + ResId::GetRT2(), ResId::GetRT() + */ + { + if( RSC_NOTYPE == m_nRT ) + m_nRT = nType; + return *this; + } + RESOURCE_TYPE GetRT2() const + /* + Get the effective type (m_nRT2 or m_nRT1) + + A second resource type is used to supercede settings + of the base class ( e.g. Window ) + */ + { + return (RSC_NOTYPE == m_nRT2) ? m_nRT : m_nRT2; + } + const ResId & SetRT2( RESOURCE_TYPE nTyp ) const + /* + Set the superceding type. Ask spcifically for it with GetRT2() + + SetRT2() may only be called if no derived class calls SetRT in its + Resource constructor. + */ + { + if( RSC_NOTYPE == m_nRT2 ) + m_nRT2 = nTyp; + return *this; + } + + ResMgr * GetResMgr() const { return m_pResMgr; } + const ResId & SetResMgr( ResMgr * pMgr ) const + { + m_pResMgr = pMgr; + OSL_ENSURE( m_pResMgr != NULL, "invalid ResMgr set on ResId" ); + return *this; + } + + const ResId & SetAutoRelease(BOOL bRelease) const + { + if( bRelease ) + m_nResId &= ~RSC_DONTRELEASE; + else + m_nResId |= RSC_DONTRELEASE; + return *this; + } + + BOOL IsAutoRelease() const + { return !(m_nResId & RSC_DONTRELEASE); } + + sal_uInt32 GetId() const { return m_nResId & ~RSC_DONTRELEASE; } + RSHEADER_TYPE* GetpResource() const { return m_pResource; } +}; + +#endif // _RESID_HXX diff --git a/tools/inc/tools/resmgr.hxx b/tools/inc/tools/resmgr.hxx new file mode 100644 index 000000000000..4b79040921b3 --- /dev/null +++ b/tools/inc/tools/resmgr.hxx @@ -0,0 +1,241 @@ +/************************************************************************* + * + * 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 _TOOLS_RESMGR_HXX +#define _TOOLS_RESMGR_HXX + +#include "tools/toolsdllapi.h" +#include <i18npool/lang.h> +#include <tools/string.hxx> +#include <tools/ref.hxx> +#include <tools/resid.hxx> +#include <com/sun/star/lang/Locale.hpp> + +#define CREATEVERSIONRESMGR_NAME( Name ) #Name +#define CREATEVERSIONRESMGR( Name ) ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( Name ) ) + +#define LOCALE_MAX_FALLBACK 6 + +#include <vector> + +class SvStream; +class InternalResMgr; + +// ----------------- +// - RSHEADER_TYPE - +// ----------------- + +// Definition der Struktur, aus denen die Resource aufgebaut ist +struct RSHEADER_TYPE +{ +private: + sal_uInt32 nId; // Identifier der Resource + RESOURCE_TYPE nRT; // Resource Typ + sal_uInt32 nGlobOff; // Globaler Offset + sal_uInt32 nLocalOff; // Lokaler Offset + +public: + inline sal_uInt32 GetId(); // Identifier der Resource + inline RESOURCE_TYPE GetRT(); // Resource Typ + inline sal_uInt32 GetGlobOff(); // Globaler Offset + inline sal_uInt32 GetLocalOff(); // Lokaler Offset +}; + +// ---------- +// - ResMgr - +// ---------- + +typedef void (*ResHookProc)( UniString& rStr ); + +// ---------- +// - ResMgr - +// ---------- + +// Initialisierung +#define RC_NOTYPE 0x00 +// Globale Resource +#define RC_GLOBAL 0x01 +#define RC_AUTORELEASE 0x02 +#define RC_NOTFOUND 0x04 +#define RC_FALLBACK_DOWN 0x08 +#define RC_FALLBACK_UP 0x10 + +class Resource; +class ResMgr; +struct ImpRCStack +{ + // pResource and pClassRes equal NULL: resource was not loaded + RSHEADER_TYPE * pResource; // pointer to resource + void * pClassRes; // pointer to class specified init data + short Flags; // resource status + void * aResHandle; // Resource-Identifier from InternalResMgr + const Resource* pResObj; // pointer to Resource object + sal_uInt32 nId; // ResId used for error message + ResMgr* pResMgr; // ResMgr for Resource pResObj + + void Clear(); + void Init( ResMgr * pMgr, const Resource * pObj, sal_uInt32 nId ); +}; + +class TOOLS_DLLPUBLIC ResMgr +{ +private: + InternalResMgr* pImpRes; + std::vector< ImpRCStack > aStack; // resource context stack + int nCurStack; + ResMgr* pFallbackResMgr; // fallback ResMgr in case the Resource + // was not contained in this ResMgr + ResMgr* pOriginalResMgr; // the res mgr that fell back to this + // stack level + + TOOLS_DLLPRIVATE void incStack(); + TOOLS_DLLPRIVATE void decStack(); + + TOOLS_DLLPRIVATE const ImpRCStack * StackTop( sal_uInt32 nOff = 0 ) const + { + return (((int)nOff >= nCurStack) ? NULL : &aStack[nCurStack-nOff]); + } + TOOLS_DLLPRIVATE void Init( const rtl::OUString& rFileName ); + + TOOLS_DLLPRIVATE ResMgr( InternalResMgr * pImp ); + + #ifdef DBG_UTIL + TOOLS_DLLPRIVATE static void RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr, + RESOURCE_TYPE nRT, sal_uInt32 nId, + std::vector< ImpRCStack >& rResStack, int nDepth ); + #endif + + // called from within GetResource() if a resource could not be found + TOOLS_DLLPRIVATE ResMgr* CreateFallbackResMgr( const ResId& rId, const Resource* pResource ); + // creates a 1k sized buffer set to zero for unfound resources + // used in case RC_NOTFOUND + static void* pEmptyBuffer; + TOOLS_DLLPRIVATE static void* getEmptyBuffer(); + + // the next two methods are needed to prevent the string hook called + // with the res mgr mutex locked + // like GetString, but doesn't call the string hook + TOOLS_DLLPRIVATE static sal_uInt32 GetStringWithoutHook( UniString& rStr, const BYTE* pStr ); + // like ReadString but doesn't call the string hook + TOOLS_DLLPRIVATE UniString ReadStringWithoutHook(); + + static ResMgr* ImplCreateResMgr( InternalResMgr* pImpl ) { return new ResMgr( pImpl ); } + + //No copying + ResMgr(const ResMgr&); + ResMgr& operator=(const ResMgr&); +public: + static void DestroyAllResMgr(); // Wird gerufen, wenn App beendet wird + + ~ResMgr(); + + // Sprachabhaengige Ressource Library + static const sal_Char* GetLang( LanguageType& eLanguage, USHORT nPrio = 0 ); //depricated! see "tools/source/rc/resmgr.cxx" + static ResMgr* SearchCreateResMgr( const sal_Char* pPrefixName, + com::sun::star::lang::Locale& rLocale ); + static ResMgr* CreateResMgr( const sal_Char* pPrefixName, + com::sun::star::lang::Locale aLocale = com::sun::star::lang::Locale( rtl::OUString(), + rtl::OUString(), + rtl::OUString())); + + // Testet ob Resource noch da ist + void TestStack( const Resource * ); + + // ist Resource verfuegbar + BOOL IsAvailable( const ResId& rId, + const Resource* = NULL) const; + + // Resource suchen und laden + BOOL GetResource( const ResId& rId, const Resource * = NULL ); + static void * GetResourceSkipHeader( const ResId& rResId, ResMgr ** ppResMgr ); + // Kontext freigeben + void PopContext( const Resource* = NULL ); + + // Resourcezeiger erhoehen + void* Increment( sal_uInt32 nSize ); + + // Groesse ein Objektes in der Resource + static sal_uInt32 GetObjSize( RSHEADER_TYPE* pHT ) + { return( pHT->GetGlobOff() ); } + + // returns a string and its length out of the resource + static sal_uInt32 GetString( UniString& rStr, const BYTE* pStr ); + // returns a byte string and its length out of the resource + static sal_uInt32 GetByteString( rtl::OString& rStr, const BYTE* pStr ); + + // Groesse eines Strings in der Resource + static sal_uInt32 GetStringSize( sal_uInt32 nLen ) + { nLen++; return (nLen + nLen%2); } + static sal_uInt32 GetStringSize( const BYTE* pStr, sal_uInt32& nLen ); + + // return a int64 + static sal_uInt64 GetUInt64( void* pDatum ); + // Gibt einen long zurueck + static INT32 GetLong( void * pLong ); + // return a short + static INT16 GetShort( void * pShort ); + + // Gibt einen Zeiger auf die Resource zurueck + void * GetClass(); + + RSHEADER_TYPE * CreateBlock( const ResId & rId ); + + // Gibt die verbleibende Groesse zurueck + sal_uInt32 GetRemainSize(); + + const rtl::OUString&GetFileName() const; + + INT16 ReadShort(); + INT32 ReadLong(); + UniString ReadString(); + rtl::OString ReadByteString(); + + // generate auto help id for current resource stack + rtl::OString GetAutoHelpId(); + + static void SetReadStringHook( ResHookProc pProc ); + static ResHookProc GetReadStringHook(); + static void SetDefaultLocale( const com::sun::star::lang::Locale& rLocale ); +}; + +inline sal_uInt32 RSHEADER_TYPE::GetId() +{ + return (sal_uInt32)ResMgr::GetLong( &nId ); +} +inline RESOURCE_TYPE RSHEADER_TYPE::GetRT() +{ + return (RESOURCE_TYPE)ResMgr::GetLong( &nRT ); +} +inline sal_uInt32 RSHEADER_TYPE::GetGlobOff() +{ + return (sal_uInt32)ResMgr::GetLong( &nGlobOff ); +} +inline sal_uInt32 RSHEADER_TYPE::GetLocalOff() +{ + return (sal_uInt32)ResMgr::GetLong( &nLocalOff ); +} + +#endif // _SV_RESMGR_HXX diff --git a/tools/inc/tools/rtti.hxx b/tools/inc/tools/rtti.hxx new file mode 100644 index 000000000000..1f8673596b48 --- /dev/null +++ b/tools/inc/tools/rtti.hxx @@ -0,0 +1,174 @@ +/************************************************************************* + * + * 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 _RTTI_HXX +#define _RTTI_HXX + +#include <string.h> +#include <tools/solar.h> + +typedef void* (*TypeId)(); + +//------------------------------------------------------------------------- + +#define TYPEINFO() \ + static void* CreateType(); \ + static TypeId StaticType(); \ + static BOOL IsOf( TypeId aSameOrSuperType ); \ + virtual TypeId Type() const; \ + virtual BOOL IsA( TypeId aSameOrSuperType ) const + +#define TYPEINFO_VISIBILITY(visibility) \ + visibility static void* CreateType(); \ + visibility static TypeId StaticType(); \ + visibility static BOOL IsOf( TypeId aSameOrSuperType ); \ + visibility virtual TypeId Type() const; \ + visibility virtual BOOL IsA( TypeId aSameOrSuperType ) const + +#define TYPEINIT_FACTORY(sType, Factory ) \ + void* sType::CreateType() { return Factory; } \ + TypeId sType::StaticType() { return &CreateType; } \ + TypeId sType::Type() const { return &CreateType; } \ + BOOL sType::IsOf( TypeId aSameOrSuperType ) \ + { \ + if ( aSameOrSuperType == StaticType() ) \ + return TRUE + +#define STATICTYPE(sType) (sType::StaticType()) + +//------------------------------------------------------------------------- + +#define TYPEINIT_AUTOFACTORY(sType) TYPEINIT_FACTORY(sType, new sType) +#define TYPEINIT(sType) TYPEINIT_FACTORY(sType, 0) + +#define SUPERTYPE(sSuper) \ + if ( sSuper::IsOf(aSameOrSuperType ) ) \ + return TRUE + +#define TYPEINIT_END(sType) \ + return FALSE; \ + } \ + BOOL sType::IsA( TypeId aSameOrSuperType ) const \ + { return IsOf( aSameOrSuperType ); } + +#define TYPEINIT0_FACTORY(sType, Factory) \ + TYPEINIT_FACTORY(sType, Factory); \ + TYPEINIT_END(sType) +#define TYPEINIT0_AUTOFACTORY(sType) TYPEINIT0_FACTORY(sType, new sType) +#define TYPEINIT0(sType) TYPEINIT0_FACTORY(sType, 0) + +#define TYPEINIT1_FACTORY(sType, sSuper, Factory) \ + TYPEINIT_FACTORY(sType, Factory); \ + SUPERTYPE(sSuper); \ + TYPEINIT_END(sType) +#define TYPEINIT1_AUTOFACTORY(sType, sSuper) \ + TYPEINIT1_FACTORY(sType, sSuper, new sType) +#define TYPEINIT1(sType, sSuper) \ + TYPEINIT1_FACTORY(sType, sSuper, 0) + +#define TYPEINIT2_FACTORY(sType, sSuper1, sSuper2, Factory) \ + TYPEINIT_FACTORY(sType, Factory); \ + SUPERTYPE(sSuper1); \ + SUPERTYPE(sSuper2); \ + TYPEINIT_END(sType) +#define TYPEINIT2_AUTOFACTORY(sType, sSuper1, sSuper2) \ + TYPEINIT2_FACTORY(sType, sSuper1, sSuper2, new sType) +#define TYPEINIT2(sType, sSuper1, sSuper2) \ + TYPEINIT2_FACTORY(sType, sSuper1, sSuper2, 0) + +#define TYPEINIT3_FACTORY(sType, sSuper1, sSuper2, sSuper3, Factory) \ + TYPEINIT_FACTORY(sType, Factory); \ + SUPERTYPE(sSuper1); \ + SUPERTYPE(sSuper2); \ + SUPERTYPE(sSuper3); \ + TYPEINIT_END(sType) +#define TYPEINIT3_AUTOFACTORY(sType, sSuper1, sSuper2, sSuper3) \ + TYPEINIT3_FACTORY(sType, sSuper1, sSuper2, sSuper3, new sType) +#define TYPEINIT3(sType, sSuper1, sSuper2, sSuper3) \ + TYPEINIT3_FACTORY(sType, sSuper1, sSuper2, sSuper3, 0) + +#define TYPE(sType) (sType::StaticType()) +#define ISA(sType) IsA(sType::StaticType()) +#define ISOF(sType) IsOf(sType::StaticType()) +#define CREATE(TypeId) (TypeId()) + +//------------------------------------------------------------------------- +// On-Demand-faehige persistent-TypeId Version + +#define TYPEINFO_ID(id) \ + static TypeId StaticType() { return (TypeId) ( id | 0xF000000L ); } \ + static BOOL IsOf( TypeId aSameOrSuperType ); \ + virtual TypeId Type() const; \ + virtual BOOL IsA( TypeId aSameOrSuperType ) const + +#define TYPEINIT_ID(sType) \ + TypeId sType::Type() const { return StaticType(); } \ + BOOL sType::IsOf( TypeId aSameOrSuperType ) \ + { \ + if ( aSameOrSuperType == StaticType() ) \ + return TRUE + +#define TYPEINIT0_ID(sType) \ + TYPEINIT_ID(sType); \ + TYPEINIT_END(sType) + +#define TYPEINIT1_ID(sType, sSuper) \ + TYPEINIT_ID(sType); \ + SUPERTYPE(sSuper); \ + TYPEINIT_END(sType) + +#define TYPEINIT2_ID(sType, sSuper1, sSuper2) \ + TYPEINIT_ID(sType); \ + SUPERTYPE(sSuper1); \ + SUPERTYPE(sSuper2); \ + TYPEINIT_END(sType) + +//------------------------------------------------------------------------- + +// Die (exemplarischen) Makros fuer die Anwendung ( hier fuer +// Pointer, kann aber nach dem gleichen Strickmuster fuer +// Referenzen erweitert werden. +// PTR_CAST: sicheres Casten eines Pointers auf einen Pointer +// einer abgeleiteten Klasse. Liefert im Fehlerfall einen +// Nullpointer (wahrscheinlich die haeufigste Anwendung) +// +// T: Typ, auf den gecastet werden soll +// p: Pointer, der gecastet werden soll +#define PTR_CAST( T, pObj ) \ + ( pObj && (pObj)->IsA( TYPE(T) ) ? (T*)(pObj) : 0 ) + +// Abfrage, ob ein Objekt eine bestimmte Klasse als +// Basisklasse hat (oder genau von dieser Klasse ist) +#define HAS_BASE( T, pObj ) \ + ( pObj && (pObj)->IsA( TYPE(T) ) ) + +// Abfrage, ob ein Pointer auf ein Objekt eines bestimmten +// Typs zeigt +#define IS_TYPE(T,pObj) \ + ( pObj && (pObj)->Type() == TYPE(T) ) + +#endif // _RTTI_HXX diff --git a/tools/inc/tools/shl.hxx b/tools/inc/tools/shl.hxx new file mode 100644 index 000000000000..ab08e3cc7a58 --- /dev/null +++ b/tools/inc/tools/shl.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * 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 _SHL_HXX +#define _SHL_HXX + +#include <tools/solar.h> +#include "tools/toolsdllapi.h" + +// ---------------- +// - GetAppData() - +// ---------------- + +#define SHL_SHL1 0 +#define SHL_SHL2 1 +#define SHL_SHL3 2 +#define SHL_APP1 3 +#define SHL_APP2 4 +#define SHL_APP3 5 +#define SHL_TOOLS 6 +#define SHL_SV 7 +#define SHL_SVT 8 +#define SHL_SVDDE 9 +#define SHL_ERR 10 +#define SHL_IPC 11 +#define SHL_SVX 12 +#define SHL_ITEM 13 +#define SHL_SVD 14 +#define SHL_SI 15 +#define SHL_SFC 16 +#define SHL_SFX 17 +//#define SHL_SO2 18 +#define SHL_IDL 19 +#define SHL_IDE 20 +#define SHL_EDIT 21 +#define SHL_VCED 22 +#define SHL_BASIC 23 +#define SHL_HELP 24 +#define SHL_LNKCCH 25 +#define SHL_CHANNEL 26 +#define SHL_SBX 27 +#define SHL_SBC 28 +#define SHL_SDB 29 +#define SHL_SBA 30 +#define SHL_SBA2 31 +#define SHL_SCH 32 +#define SHL_SIM 33 +#define SHL_SM 34 +#define SHL_SGA 35 +#define SHL_DOCMGR 36 +// 37 removed +#define SHL_MAIL 38 +#define SHL_NEWS 39 +#define SHL_OFFAPP 40 +#define SHL_INET 41 +#define SHL_CHAOS 42 +#define SHL_HISTORY 43 +#define SHL_SJ 44 +#define SHL_CALC 45 +#define SHL_DRAW 46 +#define SHL_WRITER 47 +#define SHL_MONEY 48 +#define SHL_HBCI 49 +#define SHL_BASE3D 50 +#define SHL_BRUSHITEM 51 +#define SHL_SFONTITEM 52 + +// #110743# +// #define SHL_COUNT 53 +// the following added for binary filter project +// Sice an array is created for that values, it is necessary to +// put them directly behind the defined ones. Else, some space is +// wasted. +#define BF_SHL_SVX 53 +#define BF_SHL_ITEM 54 +#define BF_SHL_SVD 55 +#define BF_SHL_EDIT 56 +#define BF_SHL_SCH 57 +#define BF_SHL_SM 58 +#define BF_SHL_CALC 59 +#define BF_SHL_DRAW 60 +#define BF_SHL_WRITER 61 +#define BF_SHL_SVT 62 +#define BF_SHL_SVDDE 63 + +#define SHL_COUNT 64 + +TOOLS_DLLPUBLIC void** GetAppData( USHORT nSharedLib ); + +#endif // _SHL_HXX diff --git a/tools/inc/tools/simplerm.hxx b/tools/inc/tools/simplerm.hxx new file mode 100644 index 000000000000..6b8f31147f96 --- /dev/null +++ b/tools/inc/tools/simplerm.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// ---------------- +// - SimpleResMgr - +// ---------------- + +// a simple resource manager : no stacks, no sharing of the impl class, only loading of strings and blobs +// but thread-safety !! :) + +#ifndef _TOOLS_SIMPLERESMGR_HXX_ +#define _TOOLS_SIMPLERESMGR_HXX_ + +#include <vos/mutex.hxx> +#include <tools/resid.hxx> +#include <i18npool/lang.h> +#include <tools/string.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include "tools/toolsdllapi.h" + +class InternalResMgr; +class TOOLS_DLLPUBLIC SimpleResMgr +{ +protected: + vos::OMutex m_aAccessSafety; + InternalResMgr* m_pResImpl; + +public: + /** creates a new SimpleResManager + @param pPrefixName + denotes the prefix of the resource file name, in ThreadTextEncoding + @param rLocale + denotes the locale of the resource file to load. If empty, a default locale + will be used. + */ + SimpleResMgr( const sal_Char* pPrefixName, + const ::com::sun::star::lang::Locale& _rLocale); + + /** creates a new SimpleResManager + @param _rPrefixName + denotes the prefix of the resource file name + @param _inout_Locale + denotes the locale of the resource file to load. If empty, no default handling + (like in the other constructor) will happen, instead an unlocalized version will be + attempted to be loaded. + Upon return, the variable will contain the actual locale of the loaded resource file. + For instance, if "en-US" is requested, but only "en" exists, the latter will be loaded + and returned. Furthermore, if an unlocalized resource file with only the base name exists, + this one will be loaded as final fallback. + */ + SimpleResMgr( const ::rtl::OUString& _rPrefixName, ::com::sun::star::lang::Locale& _inout_Locale ); + virtual ~SimpleResMgr(); + + static SimpleResMgr* Create( const sal_Char* pPrefixName, + ::com::sun::star::lang::Locale aLocale = ::com::sun::star::lang::Locale( rtl::OUString(), + rtl::OUString(), + rtl::OUString()));// nur in VCL + + bool IsValid() const { return m_pResImpl != NULL; } + + /** retrieves the locale of the resource file represented by this instance + @precond + IsValid returns <TRUE/> + */ + const ::com::sun::star::lang::Locale& + GetLocale() const; + + /** reads the string with the given resource id + @param nId + the resource id of the string to read + @return + the string with the given resource id, or an empty string if the id does not denote + an existent string + @seealso IsAvailable + */ + UniString ReadString( sal_uInt32 nId ); + + /** checks whether a certain resource is availble + @param _resourceType + the type of the resource to check. Currently, only RSC_STRING (strings) and RSC_RESOURCE (blobs) + are supported, for every other type, <FALSE/> will be returned. + @param _resourceId + the id of the resource to lookup. + @return + <TRUE/> if and only if a resource of the given type, with the given id, is available. + */ + bool IsAvailable( RESOURCE_TYPE _resourceType, sal_uInt32 _resourceId ); + + sal_uInt32 ReadBlob( sal_uInt32 nId, void** pBuffer ); + void FreeBlob( void* pBuffer ); +}; + +#endif // _TOOLS_SIMPLERESMGR_HXX_ diff --git a/tools/inc/tools/solar.h b/tools/inc/tools/solar.h new file mode 100644 index 000000000000..cc7c189fbf84 --- /dev/null +++ b/tools/inc/tools/solar.h @@ -0,0 +1,403 @@ +/************************************************************************* + * + * 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 _SOLAR_H +#define _SOLAR_H + +#include <sal/types.h> +#include <osl/endian.h> +#include <comphelper/fileformat.h> + +/*** common solar defines ***********************************/ + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef _SOLAR__PRIVATE +#undef _SOLAR__PRIVATE +#endif +#define _SOLAR__PRIVATE 1 +#define __REFERENCED 0 + +/*** common solar types ********************************************/ +/* NOTE: these types are deprecated, or soon will be. They should */ +/* not be used in new code, and should be replaced with their */ +/* corresponding types from sal/types.h in old code when possible. */ +/* Previous typedefs from before sal convergence are in comments */ +/* to the right of the new types. */ + +typedef sal_Bool BOOL; /* typedef unsigned char BOOL; */ +typedef sal_uInt8 BYTE; /* typedef unsigned char BYTE; */ +typedef sal_uInt16 USHORT; /* typedef unsigned short USHORT; */ +typedef sal_uIntPtr ULONG; /* typedef unsigned long ULONG; */ +typedef int FASTBOOL; + +#if !defined(VCL_NEED_BASETSD) || defined(__MINGW32__) +#ifndef _SOLAR_NOUINT +typedef sal_Int16 INT16; /* typedef short INT16; */ +typedef sal_uInt16 UINT16; /* typedef unsigned short UINT16; */ +#if defined(SAL_W32) +typedef sal_sChar INT8; +#else +typedef sal_Char INT8; /* typedef char INT8; */ +#endif +typedef sal_uInt8 UINT8; /* typedef unsigned char UINT8; */ +#endif /* _SOLAR_NOUINT */ +#endif + +#ifndef VCL_NEED_BASETSD +#ifndef _SOLAR_NOUINT +/* types with exact defined size (not just the minimum size) */ +typedef sal_Int64 INT64; /* typedef long INT64; previously "void" on Windows */ +typedef sal_uInt64 UINT64; /* typedef unsigned long UINT64; previously "void" on Windows */ +typedef sal_Int32 INT32; /* typedef int INT32; previously "long" on Windows */ +typedef sal_uInt32 UINT32; /* typedef unsigned int UINT32; previously "unsigned long" on Windows */ +#endif /* _SOLAR_NOUINT */ +#endif + +/*** misc. macros to leverage platform and compiler differences ********/ + +#define DELETEZ( p ) ( delete p,p = 0 ) + +#define __FAR_DATA +#define __READONLY_DATA const +#define __EXPORT + +#ifdef WNT +#if defined (_MSC_VER) && ( _MSC_VER < 1200 ) +#define __LOADONCALLAPI _cdecl +#else +#define __LOADONCALLAPI __cdecl +#endif +#else +#define __LOADONCALLAPI +#endif + +#if defined UNX +#define ILLEGAL_POINTER ((void*)1) +#else +#define ILLEGAL_POINTER NULL +#endif + +/*** solar binary types **********************************************/ + +#ifndef _SOLAR_NOSVBT +/* Solar (portable) Binary (exchange) Type; OSI 6 subset + always little endian; + not necessarily aligned */ + +typedef BYTE SVBT8[1]; +typedef BYTE SVBT16[2]; +typedef BYTE SVBT32[4]; +typedef BYTE SVBT64[8]; + +#ifdef __cplusplus + +inline BYTE SVBT8ToByte ( const SVBT8 p ) { return p[0]; } +inline USHORT SVBT16ToShort( const SVBT16 p ) { return (USHORT)p[0] + + ((USHORT)p[1] << 8); } +inline sal_uInt32 SVBT32ToUInt32 ( const SVBT32 p ) { return (sal_uInt32)p[0] + + ((sal_uInt32)p[1] << 8) + + ((sal_uInt32)p[2] << 16) + + ((sal_uInt32)p[3] << 24); } +#if defined OSL_LITENDIAN +inline double SVBT64ToDouble( const SVBT64 p ) { double n; + ((BYTE*)&n)[0] = p[0]; + ((BYTE*)&n)[1] = p[1]; + ((BYTE*)&n)[2] = p[2]; + ((BYTE*)&n)[3] = p[3]; + ((BYTE*)&n)[4] = p[4]; + ((BYTE*)&n)[5] = p[5]; + ((BYTE*)&n)[6] = p[6]; + ((BYTE*)&n)[7] = p[7]; + return n; } +#else +inline double SVBT64ToDouble( const SVBT64 p ) { double n; + ((BYTE*)&n)[0] = p[7]; + ((BYTE*)&n)[1] = p[6]; + ((BYTE*)&n)[2] = p[5]; + ((BYTE*)&n)[3] = p[4]; + ((BYTE*)&n)[4] = p[3]; + ((BYTE*)&n)[5] = p[2]; + ((BYTE*)&n)[6] = p[1]; + ((BYTE*)&n)[7] = p[0]; + return n; } +#endif + +inline void ByteToSVBT8 ( BYTE n, SVBT8 p ) { p[0] = n; } +inline void ShortToSVBT16( USHORT n, SVBT16 p ) { p[0] = (BYTE) n; + p[1] = (BYTE)(n >> 8); } +inline void UInt32ToSVBT32 ( sal_uInt32 n, SVBT32 p ) { p[0] = (BYTE) n; + p[1] = (BYTE)(n >> 8); + p[2] = (BYTE)(n >> 16); + p[3] = (BYTE)(n >> 24); } +#if defined OSL_LITENDIAN +inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((BYTE*)&n)[0]; + p[1] = ((BYTE*)&n)[1]; + p[2] = ((BYTE*)&n)[2]; + p[3] = ((BYTE*)&n)[3]; + p[4] = ((BYTE*)&n)[4]; + p[5] = ((BYTE*)&n)[5]; + p[6] = ((BYTE*)&n)[6]; + p[7] = ((BYTE*)&n)[7]; } +#else +inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = ((BYTE*)&n)[7]; + p[1] = ((BYTE*)&n)[6]; + p[2] = ((BYTE*)&n)[5]; + p[3] = ((BYTE*)&n)[4]; + p[4] = ((BYTE*)&n)[3]; + p[5] = ((BYTE*)&n)[2]; + p[6] = ((BYTE*)&n)[1]; + p[7] = ((BYTE*)&n)[0]; } +#endif +#endif +#endif + + +/*** standard floating point definitions *******************************/ + +#ifndef F_PI +#define F_PI 3.14159265358979323846 +#endif +#ifndef F_PI2 +#define F_PI2 1.57079632679489661923 +#endif +#ifndef F_PI4 +#define F_PI4 0.785398163397448309616 +#endif +#ifndef F_PI180 +#define F_PI180 0.01745329251994 +#endif +#ifndef F_PI1800 +#define F_PI1800 0.001745329251994 +#endif +#ifndef F_PI18000 +#define F_PI18000 0.0001745329251994 +#endif +#ifndef F_2PI +#define F_2PI 6.28318530717958647694 +#endif + + +/*** standard macros *****************************************/ + +#define SWAPSHORT(x) ((((x) >> 8) & 0x00FF) | (((x) & 0x00FF) << 8)) +#define SWAPLONG(x) ((((x) >> 24) & 0x000000FF) | (((x) & 0x00FF0000) >> 8) | \ + (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)) + +#ifndef __cplusplus +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#endif + + + +/*** standard inline functions *****************************************/ + +#ifdef __cplusplus +template<typename T> inline T Min(T a, T b) { return (a<b?a:b); } +template<typename T> inline T Max(T a, T b) { return (a>b?a:b); } +template<typename T> inline T Abs(T a) { return (a>=0?a:-a); } +#endif + + +/*** C / C++ - macros **************************************************/ + +#ifdef __cplusplus +#define BEGIN_C extern "C" { +#define END_C } +#define EXTERN_C extern "C" +#else +#define BEGIN_C +#define END_C +#define EXTERN_C +#endif + + +/*** macros ************************************************************/ + +#ifdef NOHACKS +#define HACK( comment ) #error hack: comment +#else +#define HACK( comment ) +#endif + +#define _MAKE_NUMSTR( n ) # n +#define MAKE_NUMSTR( n ) _MAKE_NUMSTR( n ) + +#define _LF ((char)0x0A) +#define _CR ((char)0x0D) + + +/*** pragmas ************************************************************/ + +#if defined _MSC_VER +/* deletion of pointer to incomplete type '...'; no destructor called + serious error, memory deleted without call of dtor */ +#pragma warning( error: 4150 ) +// warning C4002: too many actual parameters for macro +// warning C4003: not enough actual parameters for macro +#pragma warning(error : 4002 4003) +#endif + + +/* dll file extensions *******************************************************/ + +#if defined WNT +#if defined(__MINGW32__) + #define __DLLEXTENSION "gi" +#else + #define __DLLEXTENSION "mi" +#endif +#elif defined OS2 + #define __DLLEXTENSION "go" +#elif defined UNX +#ifdef AIX + #define __DLLEXTENSION "ap.so" +#elif defined HPUX + #define __DLLEXTENSION "hr.sl" +#elif defined SOLARIS && defined SPARC && defined IS_LP64 + #define __DLLEXTENSION "su.so" +#elif defined SOLARIS && defined SPARC && !defined __GNUC__ + #define __DLLEXTENSION "ss.so" +#elif defined SOLARIS && defined SPARC && defined __GNUC__ + #define __DLLEXTENSION "sogs.so" +#elif defined SOLARIS && defined INTEL && !defined __GNUC__ + #define __DLLEXTENSION "si.so" +#elif defined SOLARIS && defined INTEL && defined __GNUC__ + #define __DLLEXTENSION "sogi.so" +#elif defined SCO + #define __DLLEXTENSION "ci.so" +#elif defined NETBSD && defined X86 + #define __DLLEXTENSION "bi.so" +#elif defined NETBSD && defined ARM32 + #define __DLLEXTENSION "ba.so" +#elif defined NETBSD && defined SPARC + #define __DLLEXTENSION "bs.so" +#elif defined NETBSD && defined POWERPC + #define __DLLEXTENSION "bp.so" +#elif defined LINUX && defined X86 + #define __DLLEXTENSION "li.so" +#elif defined LINUX && defined POWERPC + #define __DLLEXTENSION "lp.so" +#elif defined LINUX && defined S390 + #define __DLLEXTENSION "l3.so" +#elif defined LINUX && defined ARM32 + #define __DLLEXTENSION "lr.so" +#elif defined LINUX && defined SPARC + #define __DLLEXTENSION "ls.so" +#elif defined LINUX && defined __x86_64__ + #define __DLLEXTENSION "lx.so" +#elif defined LINUX && defined MIPS + #define __DLLEXTENSION "lm.so" +#elif defined LINUX && defined IA64 + #define __DLLEXTENSION "la.so" +#elif defined LINUX && defined M68K + #define __DLLEXTENSION "lm.so" +#elif defined LINUX && defined HPPA + #define __DLLEXTENSION "lh.so" +#elif defined LINUX && defined AXP + #define __DLLEXTENSION "ll.so" +#elif defined LINUX + #error unknown plattform +#elif defined FREEBSD && defined X86 + #define __DLLEXTENSION "fi.so" +#elif defined FREEBSD && defined X86_64 + #define __DLLEXTENSION "fx.so" +#elif defined MACOSX && defined POWERPC + #define __DLLEXTENSION "mxp.dylib" +#elif defined MACOSX && defined X86 + #define __DLLEXTENSION "mxi.dylib" +#else + #define __DLLEXTENSION ".so" +#endif +#endif + +// ----------------------------------------------------------------------- + +#ifndef NOREPLACESTRING +#define UniString String +#define XubString String +#else +#define XubString UniString +#endif +#define xub_Unicode sal_Unicode +#define xub_uUnicode sal_Unicode +#ifdef STRING32 +#define xub_StrLen sal_uInt32 +#else +#define xub_StrLen USHORT +#endif + +// -- moved here from libcall.hxx ---------------------------------------- + +#define LIBRARY_STR(s) # s +#define LIBRARY_STRING(s) LIBRARY_STR(s) + +#define GETFUNCTION( s ) GetFunction( s ) +#define LIBRARY_CONCAT3( s1, s2, s3 ) \ + s1 s2 s3 +#define LIBRARY_CONCAT4( s1, s2, s3, s4 ) \ + s1 s2 s3 s4 + +#if defined WNT || defined OS2 +#define SVLIBRARY( Base ) \ + LIBRARY_CONCAT3( Base, __DLLEXTENSION, ".DLL" ) +#define SVLIBRARYLANG( Base, Lang ) \ + LIBRARY_CONCAT3( Base, Lang, ".DLL" ) +#elif defined UNX +#define SVLIBRARY( Base ) \ + LIBRARY_CONCAT3( "lib", Base, __DLLEXTENSION ) +#define SVLIBRARYLANG( Base, Lang ) \ + LIBRARY_CONCAT3( "lib", Base, Lang ) +#else +#define SVLIBRARY( Base ) \ + LIBRARY_CONCAT2( Base, __DLLEXTENSION ) +#define SVLIBRARYLANG( Base, Lang ) \ + LIBRARY_CONCAT2( Base, Lang ) +#endif + +#if defined MACOSX +#define SV_LIBFILENAME(str) \ + LIBRARYFILENAME_CONCAT2( str, __DLLEXTENSION ) +#elif defined UNX +#define SV_LIBFILENAME(str) \ + LIBRARYFILENAME_CONCAT2( str, __DLLEXTENSION ) +#else +#define SV_LIBFILENAME(str) \ + LIBRARYFILENAME_CONCAT3( str, __DLLEXTENSION, ".dll" ) +#endif + +#endif /* _SOLAR_H */ diff --git a/tools/inc/tools/solarmutex.hxx b/tools/inc/tools/solarmutex.hxx new file mode 100644 index 000000000000..f8b784c9f9ae --- /dev/null +++ b/tools/inc/tools/solarmutex.hxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * 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 _TOOLS_SOLARMUTEX_HXX +#define _TOOLS_SOLARMUTEX_HXX + +#include "tools/toolsdllapi.h" +#include <vos/mutex.hxx> + +namespace tools +{ + class TOOLS_DLLPUBLIC SolarMutex + { + public: + static ::vos::IMutex* GetSolarMutex(); + static void SetSolarMutex( ::vos::IMutex* pMutex ); + static bool Acquire(); + static void Release(); + }; +} + +#endif diff --git a/tools/inc/tools/stack.hxx b/tools/inc/tools/stack.hxx new file mode 100644 index 000000000000..4f3223295114 --- /dev/null +++ b/tools/inc/tools/stack.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * 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 _STACK_HXX +#define _STACK_HXX + +#include <tools/contnr.hxx> + +// --------- +// - Stack - +// --------- + +#define STACK_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class Stack : private Container +{ +public: + using Container::Clear; + using Container::Count; + using Container::GetObject; + using Container::GetPos; + + Stack( USHORT _nInitSize = 16, USHORT _nReSize = 16 ) : + Container( CONTAINER_MAXBLOCKSIZE, _nInitSize, _nReSize ) {} + Stack( const Stack& rStack ) : Container( rStack ) {} + + void Push( void* p ) { Container::Insert( p, CONTAINER_APPEND ); } + void* Pop() { return Container::Remove( Count()-1 ); } + void* Top() const { return Container::GetObject( Count()-1 ); } + + Stack& operator =( const Stack& rStack ) + { Container::operator =( rStack ); return *this; } + + BOOL operator ==( const Stack& rStack ) const + { return Container::operator ==( rStack ); } + BOOL operator !=( const Stack& rStack ) const + { return Container::operator !=( rStack ); } +}; + +// ----------------- +// - DECLARE_STACK - +// ----------------- + +#define DECLARE_STACK( ClassName, Type ) \ +class ClassName : private Stack \ +{ \ +public: \ + using Stack::Clear; \ + using Stack::Count; \ + \ + ClassName( USHORT _nInitSize = 16, \ + USHORT _nReSize = 16 ) : \ + Stack( _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + Stack( rClassName ) {} \ + \ + void Push( Type p ) { Stack::Push( (void*)p ); } \ + Type Pop() { return (Type)Stack::Pop(); } \ + Type Top() const { return (Type)Stack::Top(); } \ + \ + Type GetObject( ULONG nIndex ) const \ + { return (Type)Stack::GetObject( nIndex ); } \ + ULONG GetPos( const Type p ) const \ + { return Stack::GetPos( (const void*)p ); } \ + ULONG GetPos( const Type p, ULONG nStartIndex, \ + BOOL bForward = TRUE ) const \ + { return Stack::GetPos( (const void*)p, \ + nStartIndex, \ + bForward ); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { Stack::operator =( rClassName ); \ + return *this; } \ + \ + BOOL operator ==( const ClassName& rStack ) const \ + { return Stack::operator ==( rStack ); } \ + BOOL operator !=( const ClassName& rStack ) const \ + { return Stack::operator !=( rStack ); } \ +}; + +#endif // _STACK_HXX diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx new file mode 100644 index 000000000000..61af361aa5b7 --- /dev/null +++ b/tools/inc/tools/stream.hxx @@ -0,0 +1,856 @@ +/************************************************************************* + * + * 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 _STREAM_HXX +#define _STREAM_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/string.hxx> +#ifndef _EINF_HXX +#include <tools/errinf.hxx> +#endif +#include <tools/ref.hxx> +#include <tools/rtti.hxx> + +class FileCopier; +class StreamData; + +// ------------------------ +// - FileFormat-Functions - +// ------------------------ + +inline rtl_TextEncoding GetStoreCharSet( rtl_TextEncoding eEncoding ) +{ + if ( eEncoding == RTL_TEXTENCODING_ISO_8859_1 ) + return RTL_TEXTENCODING_MS_1252; + else + return eEncoding; +} + +// --------------- +// - StreamTypes - +// --------------- + +typedef sal_uInt16 StreamMode; + +// read, write, create,... options +#define STREAM_READ 0x0001 // allow read accesses +#define STREAM_WRITE 0x0002 // allow write accesses +// file i/o +#define STREAM_NOCREATE 0x0004 // 1 == Dont create file +#define STREAM_TRUNC 0x0008 // Truncate _existing_ file to zero length +#define STREAM_COPY_ON_SYMLINK 0x0010 // copy-on-write for symlinks (UNX) + +#define STREAM_READWRITEBITS (STREAM_READ | STREAM_WRITE | \ + STREAM_NOCREATE | STREAM_TRUNC) + +// sharing options +#define STREAM_SHARE_DENYNONE 0x0100 +#define STREAM_SHARE_DENYREAD 0x0200 // overrides denynone +#define STREAM_SHARE_DENYWRITE 0x0400 // overrides denynone +#define STREAM_SHARE_DENYALL 0x0800 // overrides denyread,write,none + +#define STREAM_SHAREBITS (STREAM_SHARE_DENYNONE | STREAM_SHARE_DENYREAD |\ + STREAM_SHARE_DENYWRITE | STREAM_SHARE_DENYALL) + +#define STREAM_READWRITE (STREAM_READ | STREAM_WRITE) +#define STREAM_SHARE_DENYREADWRITE (STREAM_SHARE_DENYREAD | STREAM_SHARE_DENYWRITE) + +#define STREAM_STD_READ (STREAM_READ | STREAM_SHARE_DENYNONE | STREAM_NOCREATE) +#define STREAM_STD_WRITE (STREAM_WRITE | STREAM_SHARE_DENYALL) +#define STREAM_STD_READWRITE (STREAM_READWRITE | STREAM_SHARE_DENYALL) + +#define STREAM_SEEK_TO_BEGIN 0L +#define STREAM_SEEK_TO_END ULONG_MAX + +#define NUMBERFORMAT_INT_BIGENDIAN (sal_uInt16)0x0000 +#define NUMBERFORMAT_INT_LITTLEENDIAN (sal_uInt16)0xFFFF + +#define COMPRESSMODE_FULL (sal_uInt16)0xFFFF +#define COMPRESSMODE_NONE (sal_uInt16)0x0000 +#define COMPRESSMODE_ZBITMAP (sal_uInt16)0x0001 +#define COMPRESSMODE_NATIVE (sal_uInt16)0x0010 + +#define JUSTIFY_RIGHT 0x00 +#define JUSTIFY_LEFT 0x01 + +#define STREAM_IO_DONTKNOW 0 +#define STREAM_IO_READ 1 +#define STREAM_IO_WRITE 2 + +#define ID_STREAM 1 +#define ID_FILESTREAM 2 +#define ID_MEMORYSTREAM 3 +#define ID_SHAREDMEMORYSTREAM 4 +#define ID_STORAGESTREAM 5 +#define ID_PERSISTSTREAM 6 + +class SvStream; +typedef SvStream& (*SvStrPtr)( SvStream& ); + +// forward declaration with internal linkage +inline SvStream& operator<<( SvStream& rStr, SvStrPtr f ); + +// --------------- +// - SvLockBytes - +// --------------- + +enum LockType {}; + +struct SvLockBytesStat +{ + sal_Size nSize; + + SvLockBytesStat(): nSize(0) {} +}; + +enum SvLockBytesStatFlag { SVSTATFLAG_DEFAULT }; + +class TOOLS_DLLPUBLIC SvLockBytes: public virtual SvRefBase +{ + SvStream * m_pStream; + sal_Bool m_bOwner; + sal_Bool m_bSync; + +protected: + void close(); + +public: + TYPEINFO(); + + SvLockBytes(): m_pStream(0), m_bOwner(FALSE), m_bSync(FALSE) {} + + SvLockBytes(SvStream * pTheStream, sal_Bool bTheOwner = FALSE): + m_pStream(pTheStream), m_bOwner(bTheOwner), m_bSync(FALSE) {} + + virtual ~SvLockBytes() { close(); } + + virtual const SvStream * GetStream() const { return m_pStream; } + + virtual void SetSynchronMode(sal_Bool bTheSync = TRUE) { m_bSync = bTheSync; } + + virtual sal_Bool IsSynchronMode() const { return m_bSync; } + + virtual ErrCode ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount, + sal_Size * pRead) const; + + virtual ErrCode WriteAt(sal_Size nPos, const void * pBuffer, sal_Size nCount, + sal_Size * pWritten); + + virtual ErrCode Flush() const; + + virtual ErrCode SetSize(sal_Size nSize); + + virtual ErrCode LockRegion(sal_Size, sal_Size, LockType); + + virtual ErrCode UnlockRegion(sal_Size, sal_Size, LockType); + + virtual ErrCode Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag) const; +}; + +SV_DECL_IMPL_REF(SvLockBytes); + +// ------------------- +// - SvOpenLockBytes - +// ------------------- + +class TOOLS_DLLPUBLIC SvOpenLockBytes: public SvLockBytes +{ +public: + TYPEINFO(); + + SvOpenLockBytes(): SvLockBytes(0, FALSE) {} + + SvOpenLockBytes(SvStream * pStream, sal_Bool bOwner): + SvLockBytes(pStream, bOwner) {} + + virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount, + sal_Size * pWritten) = 0; + + virtual sal_Size Tell() const = 0; + + virtual sal_Size Seek(sal_Size nPos) = 0; + + virtual void Terminate() = 0; +}; + +SV_DECL_IMPL_REF(SvOpenLockBytes); + +// -------------------- +// - SvAsyncLockBytes - +// -------------------- + +class SvAsyncLockBytes: public SvOpenLockBytes +{ + sal_Size m_nSize; + sal_Bool m_bTerminated; + +public: + TYPEINFO(); + + SvAsyncLockBytes(SvStream * pStream, sal_Bool bOwner): + SvOpenLockBytes(pStream, bOwner), m_nSize(0), m_bTerminated(FALSE) {} + + virtual ErrCode ReadAt(sal_Size nPos, void * pBuffer, sal_Size nCount, + sal_Size * pRead) const; + + virtual ErrCode WriteAt(sal_Size nPos, const void * pBuffer, sal_Size nCount, + sal_Size * pWritten); + + virtual ErrCode FillAppend(const void * pBuffer, sal_Size nCount, + sal_Size * pWritten); + + virtual sal_Size Tell() const { return m_nSize; } + + virtual sal_Size Seek(sal_Size nPos); + + virtual void Terminate() { m_bTerminated = TRUE; } +}; + +SV_DECL_IMPL_REF(SvAsyncLockBytes); + +// ---------- +// - Stream - +// ---------- + +class TOOLS_DLLPUBLIC SvStream +{ +private: + // LockBytes Interface + void* pImp; // unused + SvLockBytesRef xLockBytes; // Default Implmentierung + sal_Size nActPos; // + + // Puffer-Verwaltung + sal_uInt8* pRWBuf; // Zeigt auf Read/Write-Puffer + sal_uInt8* pBufPos; // pRWBuf + nBufActualPos + sal_uInt16 nBufSize; // Allozierte Groesse des Puffers + sal_uInt16 nBufActualLen; // Laenge des beschriebenen Teils des Puffers + // Entspricht nBufSize, wenn EOF nicht + // ueberschritten wurde + sal_uInt16 nBufActualPos; // aktuelle Position im Puffer (0..nBufSize-1) + sal_uInt16 nBufFree; // freier Platz im Puffer fuer IO vom Typ eIOMode + unsigned int eIOMode:2; // STREAM_IO_* + + // Error-Codes, Konvertierung, Komprimierung, ... + int bIsDirty:1; // TRUE: Stream != Pufferinhalt + int bIsConsistent:1;// FALSE: Buffer enthaelt Daten, die NICHT + // per PutData in den abgeleiteten Stream + // geschrieben werden duerfen (siehe PutBack) + int bSwap:1; + int bIsEof:1; + sal_uInt32 nError; + sal_uInt16 nNumberFormatInt; + sal_uInt16 nCompressMode; + LineEnd eLineDelimiter; + CharSet eStreamCharSet; +// CharSet eTargetCharSet; + + // Verschluesselung + ByteString aKey; // aKey.Len != 0 -> Verschluesselung + unsigned char nCryptMask; + + // Formatierung von Strings + char cFiller; + sal_uInt8 nRadix; + sal_uInt8 nPrecision; + sal_uInt8 nWidth; + sal_uInt8 nPrintfParams; + sal_uInt8 nJustification; + ByteString aFormatString; + + // Userdata + long nVersion; // for external use + + // Hilfsmethoden + void CreateFormatString(); + TOOLS_DLLPRIVATE void ImpInit(); + + SvStream ( const SvStream& rStream ); // not implemented + SvStream& operator=( const SvStream& rStream ); // not implemented + +protected: + sal_Size nBufFilePos; // Fileposition von pBuf[0] + sal_uInt16 eStreamMode; + sal_Bool bIsWritable; + + virtual sal_Size GetData( void* pData, sal_Size nSize ); + virtual sal_Size PutData( const void* pData, sal_Size nSize ); + virtual sal_Size SeekPos( sal_Size nPos ); + virtual void FlushData(); + virtual void SetSize( sal_Size nSize ); + + void ClearError(); + void ClearBuffer(); + + // verschluesselt & schreibt blockweise + sal_Size CryptAndWriteBuffer( const void* pStart, sal_Size nLen ); + sal_Bool EncryptBuffer( void* pStart, sal_Size nLen ); + + void SyncSvStream( sal_Size nNewStreamPos ); // SvStream <- Medium + void SyncSysStream(); // SvStream -> Medium + +public: + SvStream(); + SvStream( SvLockBytes *pLockBytes); + virtual ~SvStream(); + + ErrCode SetLockBytes( SvLockBytesRef& rBytes ); + SvLockBytes* GetLockBytes() const { return xLockBytes; } + + sal_uInt32 GetError() const { return ERRCODE_TOERROR(nError); } + sal_uInt32 GetErrorCode() const { return nError; } + + void SetError( sal_uInt32 nErrorCode ); + virtual void ResetError(); + + void SetNumberFormatInt( sal_uInt16 nNewFormat ); + sal_uInt16 GetNumberFormatInt() const { return nNumberFormatInt; } + /// Enable/disable swapping of endians, may be needed for Unicode import/export + inline void SetEndianSwap( sal_Bool bVal ); + // returns status of endian swap flag + sal_Bool IsEndianSwap() const { return 0 != bSwap; } + + void SetCompressMode( sal_uInt16 nNewMode ) + { nCompressMode = nNewMode; } + sal_uInt16 GetCompressMode() const { return nCompressMode; } + + void SetKey( const ByteString& rKey ); + const ByteString& GetKey() const { return aKey; } + + void SetStreamCharSet( CharSet eCharSet ) + { eStreamCharSet = eCharSet; } + CharSet GetStreamCharSet() const { return eStreamCharSet; } +// void SetTargetCharSet( CharSet eCharSet ) +// { eTargetCharSet = eCharSet; } +// CharSet GetTargetCharSet() const { return eTargetCharSet; } + + void SetLineDelimiter( LineEnd eLineEnd ) + { eLineDelimiter = eLineEnd; } + LineEnd GetLineDelimiter() const { return eLineDelimiter; } + + SvStream& operator>>( sal_uInt16& rUInt16 ); + SvStream& operator>>( sal_uInt32& rUInt32 ); + SvStream& operator>>( long& rLong ); + SvStream& operator>>( short& rShort ); + SvStream& operator>>( int& rInt ); + SvStream& operator>>( signed char& rChar ); + SvStream& operator>>( char& rChar ); + SvStream& operator>>( unsigned char& rChar ); + SvStream& operator>>( float& rFloat ); + SvStream& operator>>( double& rDouble ); +#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS + SvStream& operator>>( ByteString& rString ) { return ReadByteString(rString); } +#endif +#ifdef ENABLE_STRING_STREAM_OPERATORS + SvStream& operator>>( UniString& rString ) { return ReadByteString(rString); } +#endif + SvStream& operator>>( SvStream& rStream ); + + SvStream& operator<<( sal_uInt16 nUInt16 ); + SvStream& operator<<( sal_uInt32 nUInt32 ); + SvStream& operator<<( long nLong ); + SvStream& operator<<( short nShort ); + SvStream& operator<<( int nInt ); + SvStream& operator<<( signed char nChar ); + SvStream& operator<<( char nChar ); + SvStream& operator<<( unsigned char nChar ); + SvStream& operator<<( float nFloat ); + SvStream& operator<<( const double& rDouble ); + SvStream& operator<<( const char* pBuf ); + SvStream& operator<<( const unsigned char* pBuf ); +#ifdef ENABLE_BYTESTRING_STREAM_OPERATORS + SvStream& operator<<( const ByteString& rString ) { return WriteByteString( rString ); } +#endif +#ifdef ENABLE_STRING_STREAM_OPERATORS + SvStream& operator<<( const UniString& rString ) { return WriteByteString(rString); } +#endif + SvStream& operator<<( SvStream& rStream ); + + SvStream& ReadByteString( UniString& rStr, rtl_TextEncoding eSrcCharSet ); + SvStream& ReadByteString( UniString& rStr ) { return ReadByteString( rStr, GetStreamCharSet() ); } + SvStream& ReadByteString( ByteString& rStr ); + SvStream& WriteByteString( const UniString& rStr, rtl_TextEncoding eDestCharSet ); + SvStream& WriteByteString( const UniString& rStr ) { return WriteByteString( rStr, GetStreamCharSet() ); } + SvStream& WriteByteString( const ByteString& rStr ); + + void SetRadix( sal_uInt8 nRad ) + { nRadix = nRad; CreateFormatString(); } + sal_uInt8 GetRadix() const { return nRadix; } + void SetPrecision( sal_uInt8 nPrec ) + { nPrecision = nPrec; CreateFormatString(); } + sal_uInt8 GetPrecision() const { return nPrecision; } + void SetWidth( sal_uInt8 nWid) + { nWidth = nWid; CreateFormatString(); } + sal_uInt8 GetWidth() const { return nWidth; } + void SetFiller( char cFil ) + { cFiller = cFil; CreateFormatString(); } + char GetFiller() const { return cFiller; } + void SetJustification( sal_uInt8 nJus ) + { nJustification = nJus; CreateFormatString(); } + sal_uInt8 GetJustification() const { return nJustification; } + + SvStream& ReadNumber( short& rShort ); + SvStream& ReadNumber( sal_uInt16& rUInt16 ); + SvStream& ReadNumber( long& rLong ); + SvStream& ReadNumber( sal_uInt32& rUInt32 ); + SvStream& ReadNumber( int& rInt ); + SvStream& ReadNumber( float& rFloat ); + SvStream& ReadNumber( double& rDouble ); + + SvStream& WriteNumber( short nShort ); + SvStream& WriteNumber( sal_uInt16 nUInt16 ); + SvStream& WriteNumber( long nLong ); + SvStream& WriteNumber( sal_uInt32 nUInt32 ); + SvStream& WriteNumber( int nInt ); + SvStream& WriteNumber( float nFloat ); + SvStream& WriteNumber( const double& rDouble ); + + sal_Size Read( void* pData, sal_Size nSize ); + sal_Size Write( const void* pData, sal_Size nSize ); + sal_Size Seek( sal_Size nPos ); + sal_Size SeekRel( sal_sSize nPos ); + sal_Size Tell() const { return nBufFilePos+nBufActualPos; } + void Flush(); + sal_Bool IsEof() const { return bIsEof; } + // next Tell() <= nSize + sal_Bool SetStreamSize( sal_Size nSize ); + + /// Read in the stream to a zero character and put all + /// read chracters in the Bytestring. The String interface + /// convert the BytString with the given encoding to a String + sal_Bool ReadCString( ByteString& rStr ); + sal_Bool ReadCString( String& rStr, rtl_TextEncoding eToEncode ); + sal_Bool ReadCString( String& rStr ) { return ReadCString( rStr, GetStreamCharSet()); } + + sal_Bool ReadLine( ByteString& rStr ); + sal_Bool WriteLine( const ByteString& rStr ); + sal_Bool WriteLines( const ByteString& rStr ); + + sal_Bool ReadByteStringLine( String& rStr, rtl_TextEncoding eSrcCharSet ); + sal_Bool ReadByteStringLine( String& rStr ) { return ReadByteStringLine( rStr, GetStreamCharSet()); } + sal_Bool WriteByteStringLine( const String& rStr, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteByteStringLine( const String& rStr ) { return WriteByteStringLine( rStr, GetStreamCharSet()); } + sal_Bool WriteByteStringLines( const String& rStr, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteByteStringLines( const String& rStr ) { return WriteByteStringLine( rStr, GetStreamCharSet()); } + + /// Switch to no endian swapping and write 0xfeff + sal_Bool StartWritingUnicodeText(); + /// Read 16bit, if 0xfeff do nothing, if 0xfffe switch + /// endian swapping, if none of them put back + sal_Bool StartReadingUnicodeText(); + + /// Read a line of Unicode + sal_Bool ReadUniStringLine( String& rStr ); + /// Read a line of Unicode if eSrcCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise read a line of Bytecode and convert from eSrcCharSet + sal_Bool ReadUniOrByteStringLine( String& rStr, rtl_TextEncoding eSrcCharSet ); + sal_Bool ReadUniOrByteStringLine( String& rStr ) + { return ReadUniOrByteStringLine( rStr, GetStreamCharSet() ); } + /// Write a sequence of Unicode characters + sal_Bool WriteUnicodeText( const String& rStr ); + /// Write a sequence of Unicode characters if eDestCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise write a sequence of Bytecodes converted to eDestCharSet + sal_Bool WriteUnicodeOrByteText( const String& rStr, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteUnicodeOrByteText( const String& rStr ) + { return WriteUnicodeOrByteText( rStr, GetStreamCharSet() ); } + /// Write a line of Unicode and append line end (endlu()) + sal_Bool WriteUniStringLine( const String& rStr ); + /// Write multiple lines of Unicode (with CovertLineEnd) and append line end (endlu()) + sal_Bool WriteUniStringLines( const String& rStr ); + /// Write a line of Unicode if eDestCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise write a line of Bytecode converted to eDestCharSet + sal_Bool WriteUniOrByteStringLine( const String& rStr, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteUniOrByteStringLine( const String& rStr ) + { return WriteUniOrByteStringLine( rStr, GetStreamCharSet() ); } + /// Write multiple lines of Unicode if eDestCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise write multiple lines of Bytecode converted to eDestCharSet, + /// CovertLineEnd is applied. + sal_Bool WriteUniOrByteStringLines( const String& rStr, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteUniOrByteStringLines( const String& rStr ) + { return WriteUniOrByteStringLines( rStr, GetStreamCharSet() ); } + /// Write a Unicode character if eDestCharSet==RTL_TEXTENCODING_UNICODE, + /// otherwise write as Bytecode converted to eDestCharSet. + /// This may result in more than one byte being written + /// if a multi byte encoding (e.g. UTF7, UTF8) is chosen. + sal_Bool WriteUniOrByteChar( sal_Unicode ch, rtl_TextEncoding eDestCharSet ); + sal_Bool WriteUniOrByteChar( sal_Unicode ch ) + { return WriteUniOrByteChar( ch, GetStreamCharSet() ); } + + /** Read a CSV (comma separated values) data line using + ReadUniOrByteStringLine(). + + @param bEmbeddedLineBreak + If sal_True and a line-break occurs inside a field of data, + a line feed LF '\n' and the next line are appended. Repeats + until a line-break is not in a field. A field is determined + by delimiting rFieldSeparators and optionally surrounded by + a pair of cFieldQuote characters. For a line-break to be + within a field, the field content MUST be surrounded by + cFieldQuote characters, and the opening cFieldQuote MUST be + at the very start of a line or follow right behind a field + separator with no extra characters in between. Anything, + including field separators and escaped quotes (by doubling + them, or preceding them with a backslash if + bAllowBackslashEscape==sal_True) may appear in a quoted + field. + + If bEmbeddedLineBreak==sal_False, nothing is parsed and the + string returned is simply one ReadUniOrByteStringLine(). + + @param rFieldSeparators + A list of characters that each may act as a field separator. + + @param cFieldQuote + The quote character used. + + @param bAllowBackslashEscape + If sal_True, an embedded quote character inside a quoted + field may also be escaped with a preceding backslash. + Normally, quotes are escaped by doubling them. + + @return + sal_True if no stream error. + + @ATTENTION + Note that the string returned may be truncated even inside + a quoted field if STRING_MAXLEN was reached. There + currently is no way to exactly determine the conditions, + whether this was at a line end, or whether open quotes + would have closed the field before the line end, as even a + ReadUniOrByteStringLine() may return prematurely but the + stream was positioned ahead until the real end of line. + Additionally, due to character encoding conversions, string + length and bytes read don't necessarily match, and + resyncing to a previous position matching the string's + length isn't always possible. As a result, a logical line + with embedded line breaks and more than STRING_MAXLEN + characters will be spoiled, and a subsequent ReadCsvLine() + may start under false preconditions. + */ + sal_Bool ReadCsvLine( String& rStr, sal_Bool bEmbeddedLineBreak, + const String& rFieldSeparators, sal_Unicode cFieldQuote, + sal_Bool bAllowBackslashEscape = sal_False); + + void SetBufferSize( sal_uInt16 nBufSize ); + sal_uInt16 GetBufferSize() const { return nBufSize; } + + void RefreshBuffer(); + SvStream& PutBack( char aCh ); + void EatWhite(); + + sal_Bool IsWritable() const { return bIsWritable; } + StreamMode GetStreamMode() const { return eStreamMode; } + virtual sal_uInt16 IsA() const; + + long GetVersion() { return nVersion; } + void SetVersion( long n ) { nVersion = n; } + + /** Add a mark to indicate to which position in the stream you want to be + able to seek back. + + @descr If you set a mark at nPos, you indicate to the stream that you + won't issue seek operations to any position 'before' nPos. This can + be exploited by 'transient streams' that do not permanently store + their data; they can discard any buffered data up to nPos. + + @descr However, if the stream is already positioned past nPos, this + method is not guaranteed to have the desired effect. A 'transient + stream' may have already discarded the buffered data at nPos, so that + a seek operation to nPos will fail nonetheless. + + @descr There can be more than one mark for a stream, indicating that + you want to be able to seek back in the stream as far as the 'lowest' + off all the marks. There can even be multiple marks at the same + position (and they must all be individually removed with + RemoveMark()). + + @param nPos The position in the stream at which to add a mark. + */ + virtual void AddMark(sal_Size nPos); + + /** Remove a mark introduced with AddMark(). + + @descr If you no longer need to seek back to some position for which + you added a mark, you should remove that mark. (And a 'transient + stream' that does not permanently store its data can then potentially + discard some of its buffered data.) + + @descr Removing one mark does not have any effects on any other + marks. Especially, if you have multiple marks at the same position, + you must call this method multiple times to effectively 'unmark' that + position. + + @descr If you specify a position for which there is no mark, this + method simply has no effect. + + @param nPos The position in the stream at which to remove the mark. + */ + virtual void RemoveMark(sal_Size nPos); + + friend SvStream& operator<<( SvStream& rStr, SvStrPtr f ); // fuer Manips +}; + +inline SvStream& operator<<( SvStream& rStr, SvStrPtr f ) +{ + (*f)(rStr); + return rStr; +} + +inline SvStream& SvStream::ReadNumber( short& rShort ) +{ + long nTmp; + ReadNumber( nTmp ); + rShort = (short)nTmp; + return *this; +} + +inline SvStream& SvStream::ReadNumber( sal_uInt16& rUShort ) +{ + sal_uInt32 nTmp; + ReadNumber( nTmp ); + rUShort = (sal_uInt16)nTmp; + return *this; +} + +inline SvStream& SvStream::ReadNumber( int& rInt ) +{ + long nTmp; + ReadNumber( nTmp ); + rInt = (int)nTmp; + return *this; +} + +/* +inline SvStream& SvStream::ReadNumber( unsigned int& rUInt ) +{ + ULONG nTmp; + ReadNumber( nTmp ); + rUInt = (unsigned int)nTmp; + return *this; +} +*/ + +inline SvStream& SvStream::ReadNumber( float& rFloat ) +{ + double nTmp; + ReadNumber( nTmp ); + rFloat = (float)nTmp; + return *this; +} + +inline SvStream& SvStream::WriteNumber( short nShort ) +{ + WriteNumber( (long)nShort ); + return *this; +} + +inline SvStream& SvStream::WriteNumber( sal_uInt16 nUShort ) +{ + WriteNumber( (sal_uInt32)nUShort ); + return *this; +} + +inline SvStream& SvStream::WriteNumber( int nInt ) +{ + WriteNumber( (long)nInt ); + return *this; +} + +/* +inline SvStream& SvStream::WriteNumber( unsigned int nUInt ) +{ + WriteNumber( (ULONG)nUInt ); + return *this; +} +*/ + +inline SvStream& SvStream::WriteNumber( float nFloat ) +{ + double nTemp = nFloat; + WriteNumber( nTemp ); + return *this; +} + +inline void SvStream::SetEndianSwap( sal_Bool bVal ) +{ +#ifdef OSL_BIGENDIAN + SetNumberFormatInt( bVal ? NUMBERFORMAT_INT_LITTLEENDIAN : NUMBERFORMAT_INT_BIGENDIAN ); +#else + SetNumberFormatInt( bVal ? NUMBERFORMAT_INT_BIGENDIAN : NUMBERFORMAT_INT_LITTLEENDIAN ); +#endif +} + +TOOLS_DLLPUBLIC SvStream& endl( SvStream& rStr ); +/// same as endl() but Unicode +TOOLS_DLLPUBLIC SvStream& endlu( SvStream& rStr ); +/// call endlu() if eStreamCharSet==RTL_TEXTECODING_UNICODE otherwise endl() +TOOLS_DLLPUBLIC SvStream& endlub( SvStream& rStr ); + +// -------------- +// - FileStream - +// -------------- + +class TOOLS_DLLPUBLIC SvFileStream : public SvStream +{ + friend class ImpEaMgr; + friend class CORmFileStream; + friend class FileCopier; + +private: + StreamData* pInstanceData; + String aFilename; + sal_uInt16 nLockCounter; + sal_Bool bIsOpen; + sal_uInt32 GetFileHandle() const; + + // Forbidden and not implemented. + SvFileStream (const SvFileStream&); + SvFileStream & operator= (const SvFileStream&); + +protected: + + virtual sal_Size GetData( void* pData, sal_Size nSize ); + virtual sal_Size PutData( const void* pData, sal_Size nSize ); + virtual sal_Size SeekPos( sal_Size nPos ); + virtual void SetSize( sal_Size nSize ); + virtual void FlushData(); + +public: + // Schaltet bei fehlgeschlagenem Schreiboeffnen auf Lesen zurueck + SvFileStream( const String& rFileName, StreamMode eOpenMode ); + SvFileStream(); + ~SvFileStream(); + + virtual void ResetError(); + + sal_Bool LockRange( sal_Size nByteOffset, sal_Size nBytes ); + sal_Bool UnlockRange( sal_Size nByteOffset, sal_Size nBytes ); + sal_Bool LockFile(); + sal_Bool UnlockFile(); + + void Open( const String& rFileName, StreamMode eOpenMode ); + void Close(); + void ReOpen(); // Aufruf nach Close, FilePointer == 0 + sal_Bool IsOpen() const { return bIsOpen; } + sal_Bool IsLocked() const { return ( nLockCounter!=0 ); } + virtual sal_uInt16 IsA() const; + + const String& GetFileName() const { return aFilename; } +}; + +// ---------------- +// - MemoryStream - +// ---------------- + +class TOOLS_DLLPUBLIC SvMemoryStream : public SvStream +{ + // Forbidden and not implemented. + SvMemoryStream (const SvMemoryStream&); + SvMemoryStream & operator= (const SvMemoryStream&); + + friend class SvCacheStream; + sal_Size GetSize() const { return nSize; } + +protected: + sal_Size nSize; + sal_Size nResize; + sal_Size nPos; + sal_Size nEndOfData; + sal_uInt8* pBuf; + sal_Bool bOwnsData; + + virtual sal_Size GetData( void* pData, sal_Size nSize ); + virtual sal_Size PutData( const void* pData, sal_Size nSize ); + virtual sal_Size SeekPos( sal_Size nPos ); + virtual void SetSize( sal_Size nSize ); + virtual void FlushData(); + + // AllocateMemory muss folgende Variable mitpflegen: + // - pBuf: Adresse des neuen Blocks + virtual sal_Bool AllocateMemory( sal_Size nSize ); + + // ReAllocateMemory muss folgende Variablen mitpflegen: + // - pBuf: Adresse des neuen Blocks + // - nEndOfData: Muss auf nNewSize-1L gesetzt werden, wenn ausserhalb des Blocks + // Muss auf 0 gesetzt werden, wenn neuer Block 0 Byte gross + // - nSize: Neue Groesse des Blocks + // - nPos: Muss auf 0 gesetzt werden, wenn ausserhalb des Blocks + virtual sal_Bool ReAllocateMemory( long nDiff ); + + // wird aufgerufen, wenn dem Stream der Speicher gehoert oder wenn + // der Speicher in der Groesse veraendert wird. + // FreeMemory muss folgende Variablen mitpflegen: + // - in abgeleiteten Klassen muessen ggf. Handles genullt werden + virtual void FreeMemory(); + + SvMemoryStream(void*) { } // Fuer unsere Subklassen + +public: + SvMemoryStream( void* pBuf, sal_Size nSize, StreamMode eMode); + SvMemoryStream( sal_Size nInitSize=512, sal_Size nResize=64 ); + ~SvMemoryStream(); + + virtual void ResetError(); + + sal_Size GetEndOfData() const { return nEndOfData; } + const void* GetData() { Flush(); return pBuf; } + operator const void*() { Flush(); return pBuf; } + virtual sal_uInt16 IsA() const; + + void* SwitchBuffer( sal_Size nInitSize=512, sal_Size nResize=64 ); + void* SetBuffer( void* pBuf, sal_Size nSize, + sal_Bool bOwnsData=TRUE, sal_Size nEOF=0 ); + + void ObjectOwnsMemory( sal_Bool bOwn ) { bOwnsData = bOwn; } + sal_Bool IsObjectMemoryOwner() { return bOwnsData; } + void SetResizeOffset( sal_Size nNewResize ) { nResize = nNewResize; } + sal_Size GetResizeOffset() const { return nResize; } +}; + +// -------------------- +// - SvDataCopyStream - +// -------------------- + +// AB 10.5.1996: Diese Klasse bildet die Basis fuer Klassen, die mittels +// SvData (SO2\DTRANS.HXX/CXX) transportiert werden sollen, z.B. Graphik +// Die abgeleiteten Klassen muessen die virtuellen Funktionen ueberladen. + +class TOOLS_DLLPUBLIC SvDataCopyStream +{ +public: + /*-----------------MM 30.04.96 11:01----------------- + mehrfaches Aufrufen von Load und Assign erlaubt + --------------------------------------------------*/ + TYPEINFO(); + virtual ~SvDataCopyStream(){} + virtual void Load( SvStream & ) = 0; + virtual void Save( SvStream & ) = 0; + virtual void Assign( const SvDataCopyStream & ); +}; + +#endif // _STREAM_HXX diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx new file mode 100644 index 000000000000..1e438a1296b6 --- /dev/null +++ b/tools/inc/tools/string.hxx @@ -0,0 +1,691 @@ +/************************************************************************* + * + * 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 _STRING_HXX +#define _STRING_HXX + +#include <tools/solar.h> +#include <osl/thread.h> +#include <rtl/textenc.h> +#include <rtl/textcvt.h> +#ifndef _RTL_STRING_HXX +#include <rtl/string.hxx> +#endif +#ifndef _RTL_USTRING_HXX +#include <rtl/ustring.hxx> +#endif +#include "tools/toolsdllapi.h" + +/******************************************************************************* + * + * THIS CODE IS DEPRECATED. DO NOT USE IT IN ANY NEW CODE. + * + * Use the string classes in rtl/ustring.hxx and rtl/ustrbuf.hxx (and + * rtl/string.hxx and rtl/strbuf.hxx for byte-sized strings) instead. If you + * feel functionality missing from those string classes, please request + * improvements on discuss@openoffice.org. + * + * There will not be any fixes to the code here. + ******************************************************************************/ + +// ----------------------------------------------------------------------- + +class ResId; +class String; +class ByteString; +class UniString; + +// ----------------------------------------------------------------------- + +#define BYTESTRING_TO_UNISTRING_CVTFLAGS (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |\ + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |\ + RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT) +#define UNISTRING_TO_BYTESTRING_CVTFLAGS (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT |\ + RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE |\ + RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 |\ + RTL_UNICODETOTEXT_FLAGS_NOCOMPOSITE) + +// ----------------------------------------------------------------------- + +// ----------- +// - CharSet - +// ----------- + +#ifndef ENUM_CHARSET_DECLARED +#define ENUM_CHARSET_DECLARED + +typedef rtl_TextEncoding CharSet; + +#endif // ENUM_CHARSET_DECLARED + +inline rtl_TextEncoding gsl_getSystemTextEncoding() +{ + return osl_getThreadTextEncoding(); +} + +// ----------------------------------------------------------------------- + +// ----------- +// - LineEnd - +// ----------- + +enum LineEnd { LINEEND_CR, LINEEND_LF, LINEEND_CRLF }; + +inline LineEnd GetSystemLineEnd() +{ +#if defined UNX + return LINEEND_LF; +#else + return LINEEND_CRLF; +#endif +} + +// ----------------------------------------------------------------------- + +// ---------------- +// - String-Types - +// ---------------- + +#ifdef STRING32 +#define STRING_NOTFOUND ((xub_StrLen)0x7FFFFFFF) +#define STRING_MATCH ((xub_StrLen)0x7FFFFFFF) +#define STRING_LEN ((xub_StrLen)0x7FFFFFFF) +#define STRING_MAXLEN ((xub_StrLen)0x7FFFFFFF) +#else +#define STRING_NOTFOUND ((xub_StrLen)0xFFFF) +#define STRING_MATCH ((xub_StrLen)0xFFFF) +#define STRING_LEN ((xub_StrLen)0xFFFF) +#define STRING_MAXLEN ((xub_StrLen)0xFFFF) +#endif + +enum StringCompare { COMPARE_LESS = -1, COMPARE_EQUAL = 0, COMPARE_GREATER = 1 }; + +// ----------------------------------------------------------------------- + +// ------------------------ +// - Interne String-Daten - +// ------------------------ + +// Daten vom String, mit denen der String verwaltet wird +// Nur fuer Debug-Zwecke (darf nie direkt einem String zugewiesen werden) + +#ifdef SAL_W32 +#pragma pack(push, 8) +#elif defined(SAL_OS2) +#pragma pack(1) +#endif + +typedef struct _ByteStringData +{ + sal_Int32 mnRefCount; // Referenz counter + sal_Int32 mnLen; // Length of the String + sal_Char maStr[1]; // CharArray (String) +} ByteStringData; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +// -------------- +// - ByteString - +// -------------- + +class TOOLS_DLLPUBLIC ByteString +{ + friend class UniString; + + TOOLS_DLLPRIVATE void InitStringRes( const UniString& rStr ); + +private: + ByteStringData* mpData; + + TOOLS_DLLPRIVATE inline void ImplCopyData(); + TOOLS_DLLPRIVATE inline char * ImplCopyStringData(char *); + TOOLS_DLLPRIVATE void ImplUpdateStringFromUniString( + sal_Unicode const *, sal_Size, rtl_TextEncoding, sal_uInt32); + TOOLS_DLLPRIVATE void ImplStringConvert( + rtl_TextEncoding, rtl_TextEncoding, BOOL); + + ByteString( const int* pDummy ); // not implemented: to prevent ByteString( NULL ) + ByteString(int); // not implemented; to detect misuses + // of ByteString(sal_Char); + void Assign(int); // not implemented; to detect misuses of + // Assign(sal_Char) + void operator =(int); // not implemented; to detect misuses + // of operator =(sal_Char) + void Append(int); // not implemented; to detect misuses of + // Append(char) + void operator +=(int); // not implemented; to detect misuses + // of operator +=(sal_Char) + +public: + ByteString(); + ByteString( const ByteString& rStr ); + ByteString( const ByteString& rStr, xub_StrLen nPos, xub_StrLen nLen ); + ByteString( const rtl::OString& rStr ); + ByteString( const sal_Char* pCharStr ); + ByteString( const sal_Char* pCharStr, xub_StrLen nLen ); + ByteString( sal_Char c ); + ByteString( const UniString& rUniStr, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); + ByteString( const UniString& rUniStr, xub_StrLen nPos, xub_StrLen nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); + ByteString( const sal_Unicode* pUniStr, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); + ByteString( const sal_Unicode* pUniStr, xub_StrLen nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = UNISTRING_TO_BYTESTRING_CVTFLAGS ); + ~ByteString(); + + operator rtl::OString () const + { + return rtl::OString (reinterpret_cast<rtl_String*>(mpData)); + } + + static ByteString CreateFromInt32( sal_Int32 n, sal_Int16 nRadix = 10 ); + static ByteString CreateFromInt64( sal_Int64 n, sal_Int16 nRadix = 10 ); + static ByteString CreateFromFloat( float f ); + static ByteString CreateFromDouble( double d ); + static const ByteString& EmptyString(); + sal_Int32 ToInt32() const; + sal_Int64 ToInt64() const; + float ToFloat() const; + double ToDouble() const; + + ByteString& Assign( const ByteString& rStr ); + ByteString& Assign( const rtl::OString& rStr ); + ByteString& Assign( const sal_Char* pCharStr ); + ByteString& Assign( const sal_Char* pCharStr, xub_StrLen nLen ); + ByteString& Assign( sal_Char c ); + ByteString& operator =( const ByteString& rStr ) + { return Assign( rStr ); } + ByteString& operator =( const rtl::OString& rStr ) + { return Assign( rStr ); } + ByteString& operator =( const sal_Char* pCharStr ) + { return Assign( pCharStr ); } + ByteString& operator =( const sal_Char c ) + { return Assign( c ); } + + ByteString& Append( const ByteString& rStr ); + ByteString& Append( const sal_Char* pCharStr ); + ByteString& Append( const sal_Char* pCharStr, xub_StrLen nLen ); + ByteString& Append( char c ); + ByteString& operator +=( const ByteString& rStr ) + { return Append( rStr ); } + ByteString& operator +=( const sal_Char* pCharStr ) + { return Append( pCharStr ); } + ByteString& operator +=( sal_Char c ) + { return Append( c ); } + + void SetChar( xub_StrLen nIndex, sal_Char c ); + sal_Char GetChar( xub_StrLen nIndex ) const + { return mpData->maStr[nIndex]; } + + xub_StrLen Len() const { return (xub_StrLen)mpData->mnLen; } + + ByteString& Insert( const ByteString& rStr, xub_StrLen nIndex = STRING_LEN ); + ByteString& Insert( const ByteString& rStr, xub_StrLen nPos, xub_StrLen nLen, + xub_StrLen nIndex = STRING_LEN ); + ByteString& Insert( const sal_Char* pCharStr, xub_StrLen nIndex = STRING_LEN ); + ByteString& Insert( sal_Char c, xub_StrLen nIndex = STRING_LEN ); + ByteString& Replace( xub_StrLen nIndex, xub_StrLen nCount, const ByteString& rStr ); + ByteString& Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ); + ByteString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const; + + ByteString& Fill( xub_StrLen nCount, sal_Char cFillChar = ' ' ); + ByteString& Expand( xub_StrLen nCount, sal_Char cExpandChar = ' ' ); + + ByteString& EraseLeadingChars( sal_Char c = ' ' ); + ByteString& EraseTrailingChars( sal_Char c = ' ' ); + ByteString& EraseLeadingAndTrailingChars( sal_Char c = ' ' ); + ByteString& EraseAllChars( sal_Char c = ' ' ); + ByteString& Reverse(); + + ByteString& Convert( rtl_TextEncoding eSource, + rtl_TextEncoding eTarget, + BOOL bReplace = TRUE ); + static sal_Char Convert( sal_Char c, rtl_TextEncoding eSource, + rtl_TextEncoding eTarget, + BOOL bReplace = TRUE ); + static sal_Unicode ConvertToUnicode( sal_Char c, + rtl_TextEncoding eTextEncoding ); + static sal_Char ConvertFromUnicode( sal_Unicode c, + rtl_TextEncoding eTextEncoding, + BOOL bReplace = TRUE ); + static sal_Unicode ConvertToUnicode( const sal_Char* pChar, sal_Size* pLen, + rtl_TextEncoding eTextEncoding ); + static sal_Size ConvertFromUnicode( sal_Unicode c, sal_Char* pBuf, sal_Size nBufLen, + rtl_TextEncoding eTextEncoding, + BOOL bReplace = TRUE ); + ByteString& ConvertLineEnd( LineEnd eLineEnd ); + ByteString& ConvertLineEnd() + { return ConvertLineEnd( GetSystemLineEnd() ); } + + BOOL IsLowerAscii() const; + BOOL IsUpperAscii() const; + BOOL IsAlphaAscii() const; + BOOL IsNumericAscii() const; + BOOL IsAlphaNumericAscii() const; + + ByteString& ToLowerAscii(); + ByteString& ToUpperAscii(); + + StringCompare CompareTo( const ByteString& rStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareTo( const sal_Char* pCharStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareIgnoreCaseToAscii( const ByteString& rStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareIgnoreCaseToAscii( const sal_Char* pCharStr, + xub_StrLen nLen = STRING_LEN ) const; + BOOL Equals( const ByteString& rStr ) const; + BOOL Equals( const sal_Char* pCharStr ) const; + BOOL EqualsIgnoreCaseAscii( const ByteString& rStr ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Char* pCharStr ) const; + BOOL Equals( const ByteString& rStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL Equals( const sal_Char* pCharStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsIgnoreCaseAscii( const ByteString& rStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Char* pCharStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + + xub_StrLen Match( const ByteString& rStr ) const; + xub_StrLen Match( const sal_Char* pCharStr ) const; + + xub_StrLen Search( sal_Char c, xub_StrLen nIndex = 0 ) const; + xub_StrLen Search( const ByteString& rStr, xub_StrLen nIndex = 0 ) const; + xub_StrLen Search( const sal_Char* pCharStr, xub_StrLen nIndex = 0 ) const; + xub_StrLen SearchBackward( sal_Char c, xub_StrLen nIndex = STRING_LEN ) const; + xub_StrLen SearchChar( const sal_Char* pChars, xub_StrLen nIndex = 0 ) const; + xub_StrLen SearchCharBackward( const sal_Char* pChars, xub_StrLen nIndex = STRING_LEN ) const; + + xub_StrLen SearchAndReplace( sal_Char c, sal_Char cRep, xub_StrLen nIndex = 0 ); + xub_StrLen SearchAndReplace( const ByteString& rStr, const ByteString& rRepStr, + xub_StrLen nIndex = 0 ); + xub_StrLen SearchAndReplace( const sal_Char* pCharStr, const ByteString& rRepStr, + xub_StrLen nIndex = 0 ); + void SearchAndReplaceAll( sal_Char c, sal_Char cRep ); + void SearchAndReplaceAll( const ByteString& rStr, const ByteString& rRepStr ); + void SearchAndReplaceAll( const sal_Char* pCharStr, const ByteString& rRepStr ); + + xub_StrLen GetTokenCount( sal_Char cTok = ';' ) const; + void SetToken( xub_StrLen nToken, sal_Char cTok, const ByteString& rStr, + xub_StrLen nIndex = 0 ); + ByteString GetToken( xub_StrLen nToken, sal_Char cTok, xub_StrLen& rIndex ) const; + ByteString GetToken( xub_StrLen nToken, sal_Char cTok = ';' ) const; + + xub_StrLen GetQuotedTokenCount( const ByteString& rQuotedPairs, sal_Char cTok = ';' ) const; + ByteString GetQuotedToken( xub_StrLen nToken, const ByteString& rQuotedPairs, + sal_Char cTok, xub_StrLen& rIndex ) const; + ByteString GetQuotedToken( xub_StrLen nToken, const ByteString& rQuotedPairs, + sal_Char cTok = ';' ) const; + + const sal_Char* GetBuffer() const { return mpData->maStr; } + sal_Char* GetBufferAccess(); + void ReleaseBufferAccess( xub_StrLen nLen = STRING_LEN ); + sal_Char* AllocBuffer( xub_StrLen nLen ); + + friend BOOL operator == ( const ByteString& rStr1, const ByteString& rStr2 ) + { return rStr1.Equals( rStr2 ); } + friend BOOL operator == ( const ByteString& rStr, const sal_Char* pCharStr ) + { return rStr.Equals( pCharStr ); } + friend BOOL operator == ( const sal_Char* pCharStr, const ByteString& rStr ) + { return rStr.Equals( pCharStr ); } + friend BOOL operator != ( const ByteString& rStr1, const ByteString& rStr2 ) + { return !(operator == ( rStr1, rStr2 )); } + friend BOOL operator != ( const ByteString& rStr, const sal_Char* pCharStr ) + { return !(operator == ( rStr, pCharStr )); } + friend BOOL operator != ( const sal_Char* pCharStr, const ByteString& rStr ) + { return !(operator == ( pCharStr, rStr )); } + friend BOOL operator < ( const ByteString& rStr1, const ByteString& rStr2 ) + { return (rStr1.CompareTo( rStr2 ) == COMPARE_LESS); } + friend BOOL operator < ( const ByteString& rStr, const sal_Char* pCharStr ) + { return (rStr.CompareTo( pCharStr ) == COMPARE_LESS); } + friend BOOL operator < ( const sal_Char* pCharStr, const ByteString& rStr ) + { return (rStr.CompareTo( pCharStr ) >= COMPARE_EQUAL); } + friend BOOL operator > ( const ByteString& rStr1, const ByteString& rStr2 ) + { return (rStr1.CompareTo( rStr2 ) == COMPARE_GREATER); } + friend BOOL operator > ( const ByteString& rStr, const sal_Char* pCharStr ) + { return (rStr.CompareTo( pCharStr ) == COMPARE_GREATER); } + friend BOOL operator > ( const sal_Char* pCharStr, const ByteString& rStr ) + { return (rStr.CompareTo( pCharStr ) <= COMPARE_EQUAL); } + friend BOOL operator <= ( const ByteString& rStr1, const ByteString& rStr2 ) + { return !(operator > ( rStr1, rStr2 )); } + friend BOOL operator <= ( const ByteString& rStr, const sal_Char* pCharStr ) + { return !(operator > ( rStr, pCharStr )); } + friend BOOL operator <= ( const sal_Char* pCharStr, const ByteString& rStr ) + { return !(operator > ( pCharStr, rStr )); } + friend BOOL operator >= ( const ByteString& rStr1, const ByteString& rStr2 ) + { return !(operator < ( rStr1, rStr2 )); } + friend BOOL operator >= ( const ByteString& rStr, const sal_Char* pCharStr ) + { return !(operator < ( rStr, pCharStr )); } + friend BOOL operator >= ( const sal_Char* pCharStr, const ByteString& rStr ) + { return !(operator < ( pCharStr, rStr )); } +}; + +inline ByteString ByteString::Copy( xub_StrLen nIndex, xub_StrLen nCount ) const +{ + return ByteString( *this, nIndex, nCount ); +} + +inline ByteString ByteString::GetToken( xub_StrLen nToken, sal_Char cTok ) const +{ + xub_StrLen nTempPos = 0; + return GetToken( nToken, cTok, nTempPos ); +} + +inline ByteString ByteString::GetQuotedToken( xub_StrLen nToken, const ByteString& rQuotedPairs, + sal_Char cTok ) const +{ + xub_StrLen nTempPos = 0; + return GetQuotedToken( nToken, rQuotedPairs, cTok, nTempPos ); +} + +// ----------------------------------------------------------------------- + +// ------------------------ +// - Interne String-Daten - +// ------------------------ + +// Daten vom String, mit denen der String verwaltet wird +// Nur fuer Debug-Zwecke (darf nie direkt einem String zugewiesen werden) + +#ifdef SAL_W32 +#pragma pack(push, 4) +#elif defined(SAL_OS2) +#pragma pack(1) +#endif + +typedef struct _UniStringData +{ + sal_Int32 mnRefCount; // Referenz counter + sal_Int32 mnLen; // Length of the String + sal_Unicode maStr[1]; // CharArray (String) +} UniStringData; + +#ifdef SAL_W32 +#pragma pack(pop) +#elif defined(SAL_OS2) +#pragma pack() +#endif + +// ------------- +// - UniString - +// ------------- + +class TOOLS_DLLPUBLIC UniString +{ + friend class ByteString; + + TOOLS_DLLPRIVATE void InitStringRes( const sal_Char* pUTF8Str, sal_Int32 nLen ); + +private: + UniStringData* mpData; + + TOOLS_DLLPRIVATE inline void ImplCopyData(); + TOOLS_DLLPRIVATE inline sal_Unicode * ImplCopyStringData(sal_Unicode *); + + UniString( const int* pDummy ); // not implemented: to prevent UniString( NULL ) + UniString(int); // not implemented; to detect misuses of + // UniString(sal_Unicode) + void Assign(int); // not implemented; to detect misuses of + // Assign(sal_Unicode) + void operator =(int); // not implemented; to detect misuses + // of operator =(sal_Unicode) + void Append(int); // not implemented; to detect misuses of + // Append(sal_Unicode) + void operator +=(int); // not implemented; to detect misuses + // of operator +=(sal_Unicode) + +public: + UniString(); + UniString( const ResId& rResId ); + UniString( const UniString& rStr ); + UniString( const UniString& rStr, xub_StrLen nPos, xub_StrLen nLen ); + UniString( const rtl::OUString& rStr ); + UniString( const sal_Unicode* pCharStr ); + UniString( const sal_Unicode* pCharStr, xub_StrLen nLen ); + UniString( sal_Unicode c ); + UniString(char c); // ...but allow "UniString('a')" + UniString( const ByteString& rByteStr, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); + UniString( const ByteString& rByteStr, xub_StrLen nPos, xub_StrLen nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); + UniString( const sal_Char* pByteStr, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); + UniString( const sal_Char* pByteStr, xub_StrLen nLen, + rtl_TextEncoding eTextEncoding, + sal_uInt32 nCvtFlags = BYTESTRING_TO_UNISTRING_CVTFLAGS ); + ~UniString(); + + operator rtl::OUString () const + { + return rtl::OUString (reinterpret_cast<rtl_uString*>(mpData)); + } + + UniString intern() const; + + static UniString CreateFromAscii( const sal_Char* pAsciiStr ); + static UniString CreateFromAscii( const sal_Char* pAsciiStr, xub_StrLen nLen ); + + static UniString CreateFromInt32( sal_Int32 n, sal_Int16 nRadix = 10 ); + static UniString CreateFromInt64( sal_Int64 n, sal_Int16 nRadix = 10 ); + static UniString CreateFromFloat( float f ); + static UniString CreateFromDouble( double d ); + static const UniString& EmptyString(); + sal_Int32 ToInt32() const; + sal_Int64 ToInt64() const; + float ToFloat() const; + double ToDouble() const; + + UniString& Assign( const UniString& rStr ); + UniString& Assign( const rtl::OUString& rStr ); + UniString& Assign( const sal_Unicode* pCharStr ); + UniString& Assign( const sal_Unicode* pCharStr, xub_StrLen nLen ); + UniString& Assign( sal_Unicode c ); + inline UniString & Assign(char c) // ...but allow "Assign('a')" + { return Assign(static_cast< sal_Unicode >(c)); } + UniString& AssignAscii( const sal_Char* pAsciiStr ); + UniString& AssignAscii( const sal_Char* pAsciiStr, xub_StrLen nLen ); + UniString& operator =( const UniString& rStr ) + { return Assign( rStr ); } + UniString& operator =( const rtl::OUString& rStr ) + { return Assign( rStr ); } + UniString& operator =( const sal_Unicode* pCharStr ) + { return Assign( pCharStr ); } + UniString& operator =( sal_Unicode c ) + { return Assign( c ); } + inline UniString & operator =(char c) // ...but allow "= 'a'" + { return operator =(static_cast< sal_Unicode >(c)); } + + UniString& Append( const UniString& rStr ); + UniString& Append( const sal_Unicode* pCharStr ); + UniString& Append( const sal_Unicode* pCharStr, xub_StrLen nLen ); + UniString& Append( sal_Unicode c ); + inline UniString & Append(char c) // ...but allow "Append('a')" + { return Append(static_cast< sal_Unicode >(c)); } + UniString& AppendAscii( const sal_Char* pAsciiStr ); + UniString& AppendAscii( const sal_Char* pAsciiStr, xub_StrLen nLen ); + UniString& operator +=( const UniString& rStr ) + { return Append( rStr ); } + UniString& operator +=( const sal_Unicode* pCharStr ) + { return Append( pCharStr ); } + UniString& operator +=( sal_Unicode c ) + { return Append( c ); } + inline UniString & operator +=(char c) // ...but allow "+= 'a'" + { return operator +=(static_cast< sal_Unicode >(c)); } + + void SetChar( xub_StrLen nIndex, sal_Unicode c ); + sal_Unicode GetChar( xub_StrLen nIndex ) const + { return mpData->maStr[nIndex]; } + + xub_StrLen Len() const { return (xub_StrLen)mpData->mnLen; } + + UniString& Insert( const UniString& rStr, xub_StrLen nIndex = STRING_LEN ); + UniString& Insert( const UniString& rStr, xub_StrLen nPos, xub_StrLen nLen, + xub_StrLen nIndex = STRING_LEN ); + UniString& Insert( const sal_Unicode* pCharStr, xub_StrLen nIndex = STRING_LEN ); + UniString& Insert( sal_Unicode c, xub_StrLen nIndex = STRING_LEN ); + UniString& InsertAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex = STRING_LEN ); + UniString& Replace( xub_StrLen nIndex, xub_StrLen nLen, const UniString& rStr ); + UniString& ReplaceAscii( xub_StrLen nIndex, xub_StrLen nLen, + const sal_Char* pAsciiStr, xub_StrLen nStrLen = STRING_LEN ); + UniString& Erase( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ); + UniString Copy( xub_StrLen nIndex = 0, xub_StrLen nCount = STRING_LEN ) const; + + UniString& Fill( xub_StrLen nCount, sal_Unicode cFillChar = ' ' ); + UniString& Expand( xub_StrLen nCount, sal_Unicode cExpandChar = ' ' ); + + UniString& EraseLeadingChars( sal_Unicode c = ' ' ); + UniString& EraseTrailingChars( sal_Unicode c = ' ' ); + UniString& EraseLeadingAndTrailingChars( sal_Unicode c = ' ' ); + UniString& EraseAllChars( sal_Unicode c = ' ' ); + UniString& Reverse(); + + UniString& ConvertLineEnd( LineEnd eLineEnd ); + UniString& ConvertLineEnd() + { return ConvertLineEnd( GetSystemLineEnd() ); } + + UniString& ToLowerAscii(); + UniString& ToUpperAscii(); + + StringCompare CompareTo( const UniString& rStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareTo( const sal_Unicode* pCharStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareToAscii( const sal_Char* pAsciiStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareIgnoreCaseToAscii( const UniString& rStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareIgnoreCaseToAscii( const sal_Unicode* pCharStr, + xub_StrLen nLen = STRING_LEN ) const; + StringCompare CompareIgnoreCaseToAscii( const sal_Char* pAsciiStr, + xub_StrLen nLen = STRING_LEN ) const; + BOOL Equals( const UniString& rStr ) const; + BOOL Equals( const sal_Unicode* pCharStr ) const; + BOOL EqualsAscii( const sal_Char* pAsciiStr ) const; + BOOL EqualsIgnoreCaseAscii( const UniString& rStr ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Unicode* pCharStr ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr ) const; + BOOL Equals( const UniString& rStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL Equals( const sal_Unicode* pCharStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsAscii( const sal_Char* pAsciiStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsIgnoreCaseAscii( const UniString& rStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Unicode* pCharStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + BOOL EqualsIgnoreCaseAscii( const sal_Char* pAsciiStr, + xub_StrLen nIndex, xub_StrLen nLen ) const; + + xub_StrLen Match( const UniString& rStr ) const; + xub_StrLen Match( const sal_Unicode* pCharStr ) const; + + xub_StrLen Search( sal_Unicode c, xub_StrLen nIndex = 0 ) const; + xub_StrLen Search( const UniString& rStr, xub_StrLen nIndex = 0 ) const; + xub_StrLen Search( const sal_Unicode* pCharStr, xub_StrLen nIndex = 0 ) const; + xub_StrLen SearchAscii( const sal_Char* pAsciiStr, xub_StrLen nIndex = 0 ) const; + xub_StrLen SearchBackward( sal_Unicode c, xub_StrLen nIndex = STRING_LEN ) const; + xub_StrLen SearchChar( const sal_Unicode* pChars, xub_StrLen nIndex = 0 ) const; + xub_StrLen SearchCharBackward( const sal_Unicode* pChars, xub_StrLen nIndex = STRING_LEN ) const; + + xub_StrLen SearchAndReplace( sal_Unicode c, sal_Unicode cRep, + xub_StrLen nIndex = 0 ); + xub_StrLen SearchAndReplace( const UniString& rStr, const UniString& rRepStr, + xub_StrLen nIndex = 0 ); + xub_StrLen SearchAndReplace( const sal_Unicode* pCharStr, const UniString& rRepStr, + xub_StrLen nIndex = 0 ); + xub_StrLen SearchAndReplaceAscii( const sal_Char* pAsciiStr, const UniString& rRepStr, + xub_StrLen nIndex = 0 ); + void SearchAndReplaceAll( sal_Unicode c, sal_Unicode cRep ); + void SearchAndReplaceAll( const UniString& rStr, const UniString& rRepStr ); + void SearchAndReplaceAll( const sal_Unicode* pCharStr, const UniString& rRepStr ); + void SearchAndReplaceAllAscii( const sal_Char* pAsciiStr, const UniString& rRepStr ); + + xub_StrLen GetTokenCount( sal_Unicode cTok = ';' ) const; + void SetToken( xub_StrLen nToken, sal_Unicode cTok, const UniString& rStr, + xub_StrLen nIndex = 0 ); + UniString GetToken( xub_StrLen nToken, sal_Unicode cTok, xub_StrLen& rIndex ) const; + UniString GetToken( xub_StrLen nToken, sal_Unicode cTok = ';' ) const; + + xub_StrLen GetQuotedTokenCount( const UniString& rQuotedPairs, sal_Unicode cTok = ';' ) const; + UniString GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs, + sal_Unicode cTok, xub_StrLen& rIndex ) const; + UniString GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs, + sal_Unicode cTok = ';' ) const; + + const sal_Unicode* GetBuffer() const { return mpData->maStr; } + sal_Unicode* GetBufferAccess(); + void ReleaseBufferAccess( xub_StrLen nLen = STRING_LEN ); + sal_Unicode* AllocBuffer( xub_StrLen nLen ); + + friend BOOL operator == ( const UniString& rStr1, const UniString& rStr2 ) + { return rStr1.Equals( rStr2 ); } + friend BOOL operator != ( const UniString& rStr1, const UniString& rStr2 ) + { return !(operator == ( rStr1, rStr2 )); } + friend BOOL operator < ( const UniString& rStr1, const UniString& rStr2 ) + { return (rStr1.CompareTo( rStr2 ) == COMPARE_LESS); } + friend BOOL operator > ( const UniString& rStr1, const UniString& rStr2 ) + { return (rStr1.CompareTo( rStr2 ) == COMPARE_GREATER); } + friend BOOL operator <= ( const UniString& rStr1, const UniString& rStr2 ) + { return !(operator > ( rStr1, rStr2 )); } + friend BOOL operator >= ( const UniString& rStr1, const UniString& rStr2 ) + { return !(operator < ( rStr1, rStr2 )); } +}; + +inline UniString UniString::Copy( xub_StrLen nIndex, xub_StrLen nCount ) const +{ + return UniString( *this, nIndex, nCount ); +} + +inline UniString UniString::GetToken( xub_StrLen nToken, sal_Unicode cTok ) const +{ + xub_StrLen nTempPos = 0; + return GetToken( nToken, cTok, nTempPos ); +} + +inline UniString UniString::GetQuotedToken( xub_StrLen nToken, const UniString& rQuotedPairs, + sal_Unicode cTok ) const +{ + xub_StrLen nTempPos = 0; + return GetQuotedToken( nToken, rQuotedPairs, cTok, nTempPos ); +} + +#endif // _STRING_HXX diff --git a/tools/inc/tools/svborder.hxx b/tools/inc/tools/svborder.hxx new file mode 100644 index 000000000000..a0509bcc89be --- /dev/null +++ b/tools/inc/tools/svborder.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 _SVBORDER_HXX +#define _SVBORDER_HXX + +#include "tools/toolsdllapi.h" +#include <tools/gen.hxx> + +class TOOLS_DLLPUBLIC SvBorder +{ + long nTop, nRight, nBottom, nLeft; +public: + SvBorder() + { nTop = nRight = nBottom = nLeft = 0; } + SvBorder( const Size & rSz ) + { nTop = nBottom = rSz.Height(); nRight = nLeft = rSz.Width(); } + SvBorder( const Rectangle & rOuter, const Rectangle & rInner ); + SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP ) + { nLeft = nLeftP; nTop = nTopP; nRight = nRightP; nBottom = nBottomP; } + BOOL operator == ( const SvBorder & rObj ) const + { + return nTop == rObj.nTop && nRight == rObj.nRight && + nBottom == rObj.nBottom && nLeft == rObj.nLeft; + } + BOOL operator != ( const SvBorder & rObj ) const + { return !(*this == rObj); } + SvBorder & operator = ( const SvBorder & rBorder ) + { + Left() = rBorder.Left(); + Top() = rBorder.Top(); + Right() = rBorder.Right(); + Bottom() = rBorder.Bottom(); + return *this; + } + SvBorder & operator += ( const SvBorder & rBorder ) + { + Left() += rBorder.Left(); + Top() += rBorder.Top(); + Right() += rBorder.Right(); + Bottom() += rBorder.Bottom(); + return *this; + } + SvBorder & operator -= ( const SvBorder & rBorder ) + { + Left() -= rBorder.Left(); + Top() -= rBorder.Top(); + Right() -= rBorder.Right(); + Bottom() -= rBorder.Bottom(); + return *this; + } + BOOL IsInside( const SvBorder & rInside ) + { + return nTop >= rInside.nTop && nRight >= rInside.nRight && + nBottom >= rInside.nBottom && nLeft >= rInside.nLeft; + } + long & Top() { return nTop; } + long & Right() { return nRight; } + long & Bottom() { return nBottom; } + long & Left() { return nLeft; } + long Top() const { return nTop; } + long Right() const { return nRight; } + long Bottom() const { return nBottom; } + long Left() const { return nLeft; } +}; + +TOOLS_DLLPUBLIC Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder ); +TOOLS_DLLPUBLIC Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder ); + +//========================================================================= + +#endif + diff --git a/tools/inc/tools/svlibrary.hxx b/tools/inc/tools/svlibrary.hxx new file mode 100644 index 000000000000..fa8ff7c8068b --- /dev/null +++ b/tools/inc/tools/svlibrary.hxx @@ -0,0 +1,42 @@ +/************************************************************************* + * + * 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 _SVLIBRARY_HXX +#define _SVLIBRARY_HXX + +#include "tools/toolsdllapi.h" + +#include <osl/module.hxx> +#include <rtl/ustring.hxx> + +class TOOLS_DLLPUBLIC SvLibrary +{ +public: + static bool LoadModule( osl::Module&, const rtl::OUString& rLibName, ::oslGenericFunction baseModule, ::sal_Int32 mode = SAL_LOADMODULE_DEFAULT ); +}; + +#endif + diff --git a/tools/inc/tools/svwin.h b/tools/inc/tools/svwin.h new file mode 100644 index 000000000000..b4ea6fcc3374 --- /dev/null +++ b/tools/inc/tools/svwin.h @@ -0,0 +1,36 @@ +/************************************************************************* + * + * 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 _SVWIN_H +#define _SVWIN_H + +#if defined WNT +#include <tools/prewin.h> +#include <tools/postwin.h> +#endif + +#endif diff --git a/tools/inc/tools/table.hxx b/tools/inc/tools/table.hxx new file mode 100644 index 000000000000..1ac3fbe27b6f --- /dev/null +++ b/tools/inc/tools/table.hxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * 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 _TOOLS_TABLE_HXX +#define _TOOLS_TABLE_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/contnr.hxx> + +// --------- +// - Table - +// --------- + +#define TABLE_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class TOOLS_DLLPUBLIC Table : private Container +{ +private: + ULONG nCount; +//#if 0 // _SOLAR__PRIVATE + TOOLS_DLLPRIVATE ULONG ImplGetIndex( ULONG nKey, ULONG* pIndex = NULL ) const; +//#endif +public: + Table( USHORT nInitSize = 16, USHORT nReSize = 16 ); + Table( const Table& rTable ) : Container( rTable ) + { nCount = rTable.nCount; } + + BOOL Insert( ULONG nKey, void* p ); + void* Remove( ULONG nKey ); + void* Replace( ULONG nKey, void* p ); + void* Get( ULONG nKey ) const; + + void Clear() { Container::Clear(); nCount = 0; } + ULONG Count() const { return( nCount ); } + + void* GetCurObject() const; + ULONG GetCurKey() const { return (ULONG)Container::GetCurObject(); } + ULONG GetKey( const void* p ) const; + BOOL IsKeyValid( ULONG nKey ) const; + + void* GetObject( ULONG nPos ) const + { return Container::GetObject( (nPos*2)+1 ); } + ULONG GetObjectKey( ULONG nPos ) const + { return (ULONG)Container::GetObject( nPos*2 ); } + ULONG GetUniqueKey( ULONG nStartKey = 1 ) const; + ULONG SearchKey( ULONG nKey, ULONG* pPos = NULL ) const; + + void* Seek( ULONG nKey ); + void* Seek( void* p ); + void* First(); + void* Last(); + void* Next(); + void* Prev(); + + Table& operator =( const Table& rTable ); + + BOOL operator ==( const Table& rTable ) const + { return Container::operator ==( rTable ); } + BOOL operator !=( const Table& rTable ) const + { return Container::operator !=( rTable ); } +}; + +inline Table& Table::operator =( const Table& r ) +{ + Container::operator =( r ); + nCount = r.nCount; + return *this; +} + +// ----------------- +// - DECLARE_TABLE - +// ----------------- + +#define DECLARE_TABLE( ClassName, Type ) \ +class ClassName : private Table \ +{ \ +public: \ + using Table::Clear; \ + using Table::Count; \ + using Table::GetCurKey; \ + using Table::GetObjectKey; \ + using Table::GetUniqueKey; \ + using Table::SearchKey; \ + using Table::IsKeyValid; \ + \ + ClassName( USHORT _nInitSize = 16, \ + USHORT _nReSize = 16 ) : \ + Table( _nInitSize, _nReSize ) {} \ + ClassName( const ClassName& rClassName ) : \ + Table( rClassName ) {} \ + \ + BOOL Insert( ULONG nKey, Type p ) \ + { return Table::Insert( nKey, (void*)p ); } \ + Type Remove( ULONG nKey ) \ + { return (Type)Table::Remove( nKey ); } \ + Type Replace( ULONG nKey, Type p ) \ + { return (Type)Table::Replace( nKey, (void*)p ); } \ + Type Get( ULONG nKey ) const \ + { return (Type)Table::Get( nKey ); } \ + \ + Type GetCurObject() const \ + { return (Type)Table::GetCurObject(); } \ + ULONG GetKey( const Type p ) const \ + { return Table::GetKey( (const void*)p ); } \ + \ + Type GetObject( ULONG nPos ) const \ + { return (Type)Table::GetObject( nPos ); } \ + \ + Type Seek( ULONG nKey ) \ + { return (Type)Table::Seek( nKey ); } \ + Type Seek( Type p ) \ + { return (Type)Table::Seek( (void*)p ); } \ + Type First() { return (Type)Table::First(); } \ + Type Last() { return (Type)Table::Last(); } \ + Type Next() { return (Type)Table::Next(); } \ + Type Prev() { return (Type)Table::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { Table::operator =( rClassName ); \ + return *this; } \ + \ + BOOL operator ==( const ClassName& rTable ) const \ + { return Table::operator ==( rTable ); } \ + BOOL operator !=( const ClassName& rTable ) const \ + { return Table::operator !=( rTable ); } \ +}; + +#endif // _TOOLS_TABLE_HXX diff --git a/tools/inc/tools/tempfile.hxx b/tools/inc/tools/tempfile.hxx new file mode 100644 index 000000000000..896fed5da0cd --- /dev/null +++ b/tools/inc/tools/tempfile.hxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * 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 _TOOLS_TEMPFILE_HXX +#define _TOOLS_TEMPFILE_HXX + +#include <tools/string.hxx> +#include "tools/toolsdllapi.h" + +struct TempFile_Impl; +class TOOLS_DLLPUBLIC TempFile +{ + TempFile_Impl* pImp; + sal_Bool bKillingFileEnabled; + +public: + // Create a temporary file or directory in a given folder or the default tempfile folder + TempFile( const String* pParent=NULL, sal_Bool bDirectory=sal_False ); + + // Create a temporary file or directory in a given folder or the default tempfile folder; its name starts + // with some given characters followed by a counter ( example: rLeadingChars="abc" means "abc0","abc1" + // and so on, depending on existing files in that folder ). + // The extension string may be f.e. ".txt" or "", if no extension string is given, ".tmp" is used + TempFile( const String& rLeadingChars, const String* pExtension=NULL, const String* pParent=NULL, sal_Bool bDirectory=sal_False ); + + // TempFile will be removed from disk in dtor if EnableKillingTempFile was called before. + // TempDirs will be removed recursively in that case. + ~TempFile(); + + sal_Bool IsValid() const; + + // Returns the real name of the tempfile in file URL scheme. + String GetName() const; + + // If enabled the file will be removed from disk when the dtor is called ( default is not enabled ) + void EnableKillingFile( sal_Bool bEnable=sal_True ) + { bKillingFileEnabled = bEnable; } + + sal_Bool IsKillingFileEnabled() const + { return bKillingFileEnabled; } + + // Only create a name for a temporary file that would be valid at that moment. + static String CreateTempName( const String* pParent=NULL ); + + // The TempNameBase is a folder in the default ( system ) tempfile folder. + // This subfolder will be used if a TempFile or TempName is created without a parent name. + // The caller of the SetTempNameBase is responsible for deleting this folder and all temporary files in it. + // The argument must be a simple name, not a complete URL. + // The return value of both methods is the complete URL of the tempname base folder. + static String SetTempNameBaseDirectory( const String &rBaseName ); + static String GetTempNameBaseDirectory(); +}; + +#endif diff --git a/tools/inc/tools/tenccvt.hxx b/tools/inc/tools/tenccvt.hxx new file mode 100644 index 000000000000..e24c2e259022 --- /dev/null +++ b/tools/inc/tools/tenccvt.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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 _TOOLS_TENCCVT_HXX +#define _TOOLS_TENCCVT_HXX + +#include <rtl/textenc.h> +#ifndef _TOOLS_SOLAR_H +#include <tools/solar.h> +#endif +#include "tools/toolsdllapi.h" + +// ---------------------------------------- +// - Functions for handling Import/Export - +// ---------------------------------------- + +// return an encoding which has more defined Characters as the given +// encoding, but have the same definition for the defined characters +// e.g.: windows-1252 for iso-8859-1 or windows-1254 for iso-8859-9 +TOOLS_DLLPUBLIC rtl_TextEncoding GetExtendedCompatibilityTextEncoding( rtl_TextEncoding eEncoding ); + +// return an encoding which has more defined Characters as the given +// encoding. The encodings could be different. +// e.g.: windows-1251 for iso-8859-5 +TOOLS_DLLPUBLIC rtl_TextEncoding GetExtendedTextEncoding( rtl_TextEncoding eEncoding ); + +// if the given encoding is an multi-byte encoding (which allows more than +// one byte per char, e.g. UTF-8 or Shift-JIS), a one-byte encoding +// is returned (normally windows-1252). +TOOLS_DLLPUBLIC rtl_TextEncoding GetOneByteTextEncoding( rtl_TextEncoding eEncoding ); + +TOOLS_DLLPUBLIC rtl_TextEncoding GetSOLoadTextEncoding( rtl_TextEncoding eEncoding, USHORT nVersion = SOFFICE_FILEFORMAT_50 ); +TOOLS_DLLPUBLIC rtl_TextEncoding GetSOStoreTextEncoding( rtl_TextEncoding eEncoding, USHORT nVersion = SOFFICE_FILEFORMAT_50 ); + +#endif // _TOOLS_TENCCVT_HXX diff --git a/tools/inc/tools/testtoolloader.hxx b/tools/inc/tools/testtoolloader.hxx new file mode 100644 index 000000000000..04431d622959 --- /dev/null +++ b/tools/inc/tools/testtoolloader.hxx @@ -0,0 +1,39 @@ +/************************************************************************* + * + * 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 _TOOLS_TESTTOOLLOADER_HXX_ +#define _TOOLS_TESTTOOLLOADER_HXX_ + +#include "tools/toolsdllapi.h" + +namespace tools +{ + TOOLS_DLLPUBLIC void InitTestToolLib(); + TOOLS_DLLPUBLIC void DeInitTestToolLib(); +} + +#endif // _TOOLS_TESTTOOLLOADER_HXX_ diff --git a/tools/inc/tools/time.hxx b/tools/inc/tools/time.hxx new file mode 100644 index 000000000000..269b104e57e6 --- /dev/null +++ b/tools/inc/tools/time.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * 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 _TOOLS_TIME_HXX +#define _TOOLS_TIME_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +class ResId; + +// -------- +// - Time - +// -------- + +class TOOLS_DLLPUBLIC Time +{ +private: + sal_Int32 nTime; + +public: + Time(); + Time( const ResId & rResId ); + Time( sal_Int32 _nTime ) { Time::nTime = _nTime; } + Time( const Time& rTime ); + Time( ULONG nHour, ULONG nMin, + ULONG nSec = 0, ULONG n100Sec = 0 ); + + void SetTime( sal_Int32 nNewTime ) { nTime = nNewTime; } + sal_Int32 GetTime() const { return nTime; } + + void SetHour( USHORT nNewHour ); + void SetMin( USHORT nNewMin ); + void SetSec( USHORT nNewSec ); + void Set100Sec( USHORT nNew100Sec ); + USHORT GetHour() const + { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1; + return (USHORT)(nTempTime / 1000000); } + USHORT GetMin() const + { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1; + return (USHORT)((nTempTime / 10000) % 100); } + USHORT GetSec() const + { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1; + return (USHORT)((nTempTime / 100) % 100); } + USHORT Get100Sec() const + { ULONG nTempTime = (nTime >= 0) ? nTime : nTime*-1; + return (USHORT)(nTempTime % 100); } + + sal_Int32 GetMSFromTime() const; + void MakeTimeFromMS( sal_Int32 nMS ); + + /// 12 hours == 0.5 days + double GetTimeInDays() const; + + BOOL IsBetween( const Time& rFrom, const Time& rTo ) const + { return ((nTime >= rFrom.nTime) && (nTime <= rTo.nTime)); } + + BOOL IsEqualIgnore100Sec( const Time& rTime ) const; + + BOOL operator ==( const Time& rTime ) const + { return (nTime == rTime.nTime); } + BOOL operator !=( const Time& rTime ) const + { return (nTime != rTime.nTime); } + BOOL operator >( const Time& rTime ) const + { return (nTime > rTime.nTime); } + BOOL operator <( const Time& rTime ) const + { return (nTime < rTime.nTime); } + BOOL operator >=( const Time& rTime ) const + { return (nTime >= rTime.nTime); } + BOOL operator <=( const Time& rTime ) const + { return (nTime <= rTime.nTime); } + + static Time GetUTCOffset(); + static ULONG GetSystemTicks(); // Elapsed time + static ULONG GetProcessTicks(); // CPU time + + void ConvertToUTC() { *this -= Time::GetUTCOffset(); } + void ConvertToLocalTime() { *this += Time::GetUTCOffset(); } + + Time& operator =( const Time& rTime ); + Time operator -() const + { return Time( nTime * -1 ); } + Time& operator +=( const Time& rTime ); + Time& operator -=( const Time& rTime ); + TOOLS_DLLPUBLIC friend Time operator +( const Time& rTime1, const Time& rTime2 ); + TOOLS_DLLPUBLIC friend Time operator -( const Time& rTime1, const Time& rTime2 ); +}; + +#endif // _TOOLS_TIME_HXX diff --git a/tools/inc/tools/tools.h b/tools/inc/tools/tools.h new file mode 100644 index 000000000000..e1ad470cf620 --- /dev/null +++ b/tools/inc/tools/tools.h @@ -0,0 +1,38 @@ +/************************************************************************* + * + * 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 _TOOLS_H +#define _TOOLS_H + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +// Methoden, die von VCL gerufen werden muessen +TOOLS_DLLPUBLIC void InitTools(); +TOOLS_DLLPUBLIC void DeInitTools(); +TOOLS_DLLPUBLIC void GlobalDeInitTools(); + +#endif // _TOOLS_H diff --git a/tools/inc/tools/toolsdllapi.h b/tools/inc/tools/toolsdllapi.h new file mode 100644 index 000000000000..fbd41130a145 --- /dev/null +++ b/tools/inc/tools/toolsdllapi.h @@ -0,0 +1,41 @@ +/************************************************************************* + * + * 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 INCLUDED_TOOLSDLLAPI_H +#define INCLUDED_TOOLSDLLAPI_H + +#include "sal/types.h" + +#if defined(TOOLS_DLLIMPLEMENTATION) +#define TOOLS_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define TOOLS_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define TOOLS_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_TOOLSDLLAPI_H */ + diff --git a/tools/inc/tools/unqid.hxx b/tools/inc/tools/unqid.hxx new file mode 100644 index 000000000000..4e255e0efdd1 --- /dev/null +++ b/tools/inc/tools/unqid.hxx @@ -0,0 +1,109 @@ +/************************************************************************* + * + * 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 _UNQID_HXX +#define _UNQID_HXX + +#include "tools/toolsdllapi.h" +#include <tools/unqidx.hxx> + +// --------------- +// - ImpUniqueId - +// --------------- + +struct ImpUniqueId +{ + ULONG nId; + USHORT nRefCount; + void Release() + { + nRefCount--; + if( 0 == nRefCount ) + delete this; + } +}; + +// ------------ +// - UniqueId - +// ------------ + +class UniqueIdContainer; +class UniqueItemId +{ + friend class UniqueIdContainer; + ImpUniqueId* pId; + + UniqueItemId( ImpUniqueId * pIdP ) + { pId = pIdP; pId->nRefCount++; } +public: + UniqueItemId() { pId = NULL; } + UniqueItemId( const UniqueItemId & rId ) + { pId = rId.pId; if( pId ) pId->nRefCount++; } + ~UniqueItemId() + { if( pId ) pId->Release(); } + UniqueItemId& operator = ( const UniqueItemId & rId ) + { + if( rId.pId ) rId.pId->nRefCount++; + if( pId ) pId->Release(); + pId = rId.pId; + return *this; + } + ULONG GetId() const { return pId ? pId->nId : 0; } +}; + +// --------------------- +// - UniqueIdContainer - +// --------------------- + +class TOOLS_DLLPUBLIC UniqueIdContainer : private UniqueIndex +{ + USHORT nCollectCount; + +public: // Irgend etwas mit protected falsch + void Clear( BOOL bAll ); + UniqueItemId CreateIdProt( ULONG nId ); + +public: + UniqueIdContainer( ULONG _nStartIndex, + ULONG _nInitSize = 16, + ULONG _nReSize = 16 ) + : UniqueIndex( _nStartIndex, _nInitSize, _nReSize ) + , nCollectCount( 0 ) + {} + UniqueIdContainer( const UniqueIdContainer& ); + + ~UniqueIdContainer() + { Clear( TRUE ); } + UniqueIdContainer& operator = ( const UniqueIdContainer & ); + + BOOL IsIndexValid( ULONG nIndex ) const + { return UniqueIndex::IsIndexValid( nIndex ); } + + UniqueItemId CreateId(); + static UniqueItemId CreateFreeId( ULONG nId ); // freies Id +}; + +#endif // _UNQID_HXX diff --git a/tools/inc/tools/unqidx.hxx b/tools/inc/tools/unqidx.hxx new file mode 100644 index 000000000000..95aac95d9cf4 --- /dev/null +++ b/tools/inc/tools/unqidx.hxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * 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 _UNQIDX_HXX +#define _UNQIDX_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/contnr.hxx> + +// --------------- +// - UniqueIndex - +// --------------- + +#define UNIQUEINDEX_ENTRY_NOTFOUND CONTAINER_ENTRY_NOTFOUND + +class TOOLS_DLLPUBLIC UniqueIndex : private Container +{ +private: + ULONG nReSize; + ULONG nStartIndex; + ULONG nUniqIndex; + ULONG nCount; + +public: + using Container::GetCurObject; + + UniqueIndex( ULONG nStartIndex = 0, + ULONG nInitSize = 16, + ULONG nReSize = 16 ); + UniqueIndex( const UniqueIndex& rIdx ); + + ULONG Insert( ULONG nIndex, void* p ); + ULONG Insert( void* p ); + void* Remove( ULONG nIndex ); + void* Replace( ULONG nIndex, void* p ); + void* Get( ULONG nIndex ) const; + + void Clear(); + ULONG Count() const { return nCount; } + + ULONG GetCurIndex() const; + ULONG GetIndex( const void* p ) const; + BOOL IsIndexValid( ULONG nIndex ) const; + + void* Seek( ULONG nIndex ); + void* Seek( void* p ); + void* First(); + void* Last(); + void* Next(); + void* Prev(); + + ULONG GetStartIndex() const { return nStartIndex; } + ULONG GetCurMaxIndex() const + { return (nStartIndex + Container::GetSize()); } + + UniqueIndex& operator =( const UniqueIndex& rIdx ); + + BOOL operator ==( const UniqueIndex& rIdx ) const; + BOOL operator !=( const UniqueIndex& rIdx ) const + { return !(UniqueIndex::operator==( rIdx )); } +}; + +inline void UniqueIndex::Clear() +{ + Container::Clear(); + nCount = 0; + nUniqIndex = 0; +} + +// ----------------------- +// - DECLARE_UNIQUEINDEX - +// ----------------------- + +#define DECLARE_UNIQUEINDEX( ClassName, Type ) \ +class ClassName : private UniqueIndex \ +{ \ +public: \ + using UniqueIndex::Clear; \ + using UniqueIndex::Count; \ + using UniqueIndex::GetCurIndex; \ + using UniqueIndex::IsIndexValid; \ + using UniqueIndex::GetStartIndex; \ + using UniqueIndex::GetCurMaxIndex; \ + \ + ClassName( ULONG _nStartIndex = 0, \ + ULONG _nInitSize = 16, ULONG _nReSize = 16 ):\ + UniqueIndex( _nStartIndex, _nInitSize, _nReSize ) {}\ + ClassName( const ClassName& rClassName ) : \ + UniqueIndex( rClassName ) {} \ + \ + ULONG Insert( ULONG nIndex, Type p ) \ + { return UniqueIndex::Insert( nIndex, (void*)p ); } \ + ULONG Insert( Type p ) \ + { return UniqueIndex::Insert( (void*)p ); } \ + Type Remove( ULONG nIndex ) \ + { return (Type)UniqueIndex::Remove( nIndex ); } \ + Type Replace( ULONG nIndex, Type p ) \ + { return (Type)UniqueIndex::Replace( nIndex, \ + (void*)p ); } \ + Type Get( ULONG nIndex ) const \ + { return (Type)UniqueIndex::Get( nIndex ); } \ + \ + Type GetCurObject() const \ + { return (Type)UniqueIndex::GetCurObject(); } \ + ULONG GetIndex( const Type p ) const \ + { return UniqueIndex::GetIndex( (const void*)p ); } \ + \ + Type Seek( ULONG nKey ) \ + { return (Type)UniqueIndex::Seek( nKey ); } \ + Type Seek( Type p ) \ + { return (Type)UniqueIndex::Seek( (void*)p ); } \ + Type First() { return (Type)UniqueIndex::First(); } \ + Type Last() { return (Type)UniqueIndex::Last(); } \ + Type Next() { return (Type)UniqueIndex::Next(); } \ + Type Prev() { return (Type)UniqueIndex::Prev(); } \ + \ + ClassName& operator =( const ClassName& rClassName ) \ + { UniqueIndex::operator =( rClassName ); \ + return *this; } \ + \ + BOOL operator ==( const ClassName& rIdx ) const \ + { return UniqueIndex::operator ==( rIdx ); } \ + BOOL operator !=( const ClassName& rIdx ) const \ + { return UniqueIndex::operator !=( rIdx ); } \ +}; + +#endif // _UNQIDX_HXX diff --git a/tools/inc/tools/urlobj.hxx b/tools/inc/tools/urlobj.hxx new file mode 100644 index 000000000000..cb9c7e407bcc --- /dev/null +++ b/tools/inc/tools/urlobj.hxx @@ -0,0 +1,1922 @@ +/************************************************************************* + * + * 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 _URLOBJ_HXX +#define _URLOBJ_HXX + +#include "tools/toolsdllapi.h" +#include <tools/string.hxx> +#include "com/sun/star/uno/Reference.hxx" +#include "rtl/string.h" +#include "rtl/ustrbuf.hxx" +#include "rtl/textenc.h" +#include "sal/types.h" + +namespace com { namespace sun { namespace star { namespace util { + class XStringWidth; +} } } } + +//============================================================================ +// Special tokens: +#define INET_PASS_TOKEN '@' +#define INET_DELIM_TOKEN ':' +#define INET_DELIM_IMAPID ';' +#define INET_ENC_DELIM_TOKEN '|' +#define INET_DELIM_HOST_TOKEN '.' +#define INET_PATH_TOKEN '/' +#define INET_DOSPATH_TOKEN '\\' +#define INET_MARK_TOKEN '#' +#define INET_PARAM_TOKEN '?' +#define INET_HEX_ESCAPE '%' + +//============================================================================ +// Common URL prefixes for various schemes: +#define INET_FTP_SCHEME "ftp://" +#define INET_HTTP_SCHEME "http://" +#define INET_HTTPS_SCHEME "https://" +#define INET_FILE_SCHEME "file://" +#define INET_GOPHER_SCHEME "gopher://" +#define INET_MAILTO_SCHEME "mailto:" +#define INET_CID_SCHEME "cid:" +#define INET_NEWS_SCHEME "news:" +#define INET_POP3_SCHEME "pop3://" +#define INET_LDAP_SCHEME "ldap://" +#define INET_PRIVATE_SCHEME "private:" +#define INET_BUGDOC_SCHEME "bugdoc:" +#define INET_SLOT_SCHEME "slot:" +#define INET_MACRO_SCHEME "macro:" +#define INET_JAVASCRIPT_SCHEME "javascript:" +#define INET_IMAP_SCHEME "imap://" +#define INET_DOWNPASS_SCHEME ".." +#define INET_DATA_SCHEME "data:" +#define INET_OUT_SCHEME "out://" +#define INET_FIF_SCHEME "fif://" +#define INET_CEPT_SCHEME "cept://" +#define INET_VIM_SCHEME "vim://" +#define INET_UNO_SCHEME ".uno:" +#define INET_COMPONENT_SCHEME ".component:" +#define INET_DB_SCHEME "db:" +#define INET_BUGID_SCHEME "bugid:" +#define INET_TELNET_SCHEME "telnet://" +#define INET_HID_SCHEME "hid:" + +#define URL_PREFIX_PRIV_SOFFICE "private:" +enum +{ + URL_PREFIX_PRIV_SOFFICE_LEN + = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_SOFFICE) +}; + +#define URL_PREFIX_PRIV_OBSOLETE URL_PREFIX_PRIV_SOFFICE +enum +{ + URL_PREFIX_PRIV_OBSOLETE_LEN + = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_OBSOLETE) +}; + +#define URL_PREFIX_PRIV_EXTERN "staroffice:" +enum +{ + URL_PREFIX_PRIV_EXTERN_LEN = RTL_CONSTASCII_LENGTH(URL_PREFIX_PRIV_EXTERN) +}; + +//============================================================================ +// Schemes: +enum INetProtocol +{ + INET_PROT_NOT_VALID = 0, + INET_PROT_FTP = 1, + INET_PROT_HTTP = 2, + INET_PROT_FILE = 3, + INET_PROT_MAILTO = 4, + INET_PROT_VND_SUN_STAR_WEBDAV = 5, + INET_PROT_NEWS = 6, + INET_PROT_PRIV_SOFFICE = 7, + INET_PROT_PRIVATE = INET_PROT_PRIV_SOFFICE, // obsolete + INET_PROT_VND_SUN_STAR_HELP = 8, + INET_PROT_HTTPS = 9, + INET_PROT_SLOT = 10, + INET_PROT_MACRO = 11, + INET_PROT_JAVASCRIPT = 12, + INET_PROT_IMAP = 13, + INET_PROT_POP3 = 14, + INET_PROT_DATA = 15, + INET_PROT_CID = 16, + INET_PROT_OUT = 17, + INET_PROT_VND_SUN_STAR_HIER = 18, + INET_PROT_VIM = 19, + INET_PROT_UNO = 20, + INET_PROT_COMPONENT = 21, + INET_PROT_VND_SUN_STAR_PKG = 22, + INET_PROT_LDAP = 23, + INET_PROT_DB = 24, + INET_PROT_VND_SUN_STAR_CMD = 25, + INET_PROT_VND_SUN_STAR_ODMA = 26, + INET_PROT_TELNET = 27, + INET_PROT_VND_SUN_STAR_EXPAND = 28, + INET_PROT_VND_SUN_STAR_TDOC = 29, + INET_PROT_GENERIC = 30, + INET_PROT_SMB = 31, + INET_PROT_HID = 32, + INET_PROT_END = 33 +}; + +//============================================================================ +class TOOLS_DLLPUBLIC INetURLObject +{ +public: + //======================================================================== + // Get- and Set-Methods: + + /** The way input strings that represent (parts of) URIs are interpreted + in set-methods. + + @descr Most set-methods accept either a ByteString or a rtl::OUString + as input. Using a ByteString, octets in the range 0x80--0xFF are + replaced by single escape sequences. Using a rtl::OUString , UTF-32 + characters in the range 0x80--0x10FFFF are replaced by sequences of + escape sequences, representing the UTF-8 coded characters. + + @descr Along with an EncodeMechanism parameter, the set-methods all + take an rtl_TextEncoding parameter, which is ignored unless the + EncodeMechanism is WAS_ENCODED. + */ + enum EncodeMechanism + { + /** All escape sequences that are already present are ignored, and are + interpreted as literal sequences of three characters. + */ + ENCODE_ALL, + + /** Sequences of escape sequences, that represent characters from the + specified character set and that can be converted to UTF-32 + characters, are first decoded. If they have to be encoded, they + are converted to UTF-8 characters and are than translated into + (sequences of) escape sequences. Other escape sequences are + copied verbatim (but using upper case hex digits). + */ + WAS_ENCODED, + + /** All escape sequences that are already present are copied verbatim + (but using upper case hex digits). + */ + NOT_CANONIC + }; + + /** The way strings that represent (parts of) URIs are returned from get- + methods. + + @descr Along with a DecodeMechanism parameter, the get-methods all + take an rtl_TextEncoding parameter, which is ignored unless the + DecodeMechanism is DECODE_WITH_CHARSET or DECODE_UNAMBIGUOUS. + */ + enum DecodeMechanism + { + /** The (part of the) URI is returned unchanged. Since URIs are + written using a subset of US-ASCII, the returned string is + guaranteed to contain only US-ASCII characters. + */ + NO_DECODE, + + /** All sequences of escape sequences that represent UTF-8 coded + UTF-32 characters with a numerical value greater than 0x7F, are + replaced by the respective UTF-16 characters. All other escape + sequences are not decoded. + */ + DECODE_TO_IURI, + + /** All (sequences of) escape sequences that represent characters from + the specified character set, and that can be converted to UTF-32, + are replaced by the respective UTF-16 characters. All other + escape sequences are not decoded. + */ + DECODE_WITH_CHARSET, + + /** All (sequences of) escape sequences that represent characters from + the specified character set, that can be converted to UTF-32, and + that (in the case of ASCII characters) can safely be decoded + without altering the meaning of the (part of the) URI, are + replaced by the respective UTF-16 characters. All other escape + sequences are not decoded. + */ + DECODE_UNAMBIGUOUS + }; + + //======================================================================== + // General Structure: + + inline INetURLObject(): + m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) {} + + inline bool HasError() const { return m_eScheme == INET_PROT_NOT_VALID; } + + inline rtl::OUString GetMainURL(DecodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aAbsURIRef, getEscapePrefix(), eMechanism, eCharset); } + + rtl::OUString GetURLNoPass(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + rtl::OUString GetURLNoMark(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + rtl::OUString + getAbbreviated(com::sun::star::uno::Reference< + com::sun::star::util::XStringWidth > const & + rStringWidth, + sal_Int32 nWidth, + DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + bool operator ==(INetURLObject const & rObject) const; + + inline bool operator !=(INetURLObject const & rObject) const + { return !(*this == rObject); } + + bool operator <(INetURLObject const & rObject) const; + + inline bool operator >(INetURLObject const & rObject) const + { return rObject < *this; } + + //======================================================================== + // Strict Parsing: + + inline INetURLObject(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline INetURLObject(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetURL(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetURL(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + bool ConcatData(INetProtocol eTheScheme, rtl::OUString const & rTheUser, + rtl::OUString const & rThePassword, + rtl::OUString const & rTheHost, sal_uInt32 nThePort, + rtl::OUString const & rThePath, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + //======================================================================== + // Smart Parsing: + + /** The supported notations for file system paths. + */ + enum FSysStyle + { + /** VOS notation (e.g., "//server/dir/file"). + */ + FSYS_VOS = 0x1, + + /** Unix notation (e.g., "/dir/file"). + */ + FSYS_UNX = 0x2, + + /** DOS notation (e.g., "a:\dir\file" and "\\server\dir\file"). + */ + FSYS_DOS = 0x4, + + /** Mac notation (e.g., "dir:file"). + */ + FSYS_MAC = 0x8, + + /** Detect the used notation. + + @descr For the following descriptions, please note that + whereas FSYS_DEFAULT includes all style bits, combinations of only + a few style bits are also possible, and are also described. + + @descr When used to translate a file system path to a file URL, + the subset of the following productions for which the appropriate + style bit is set are checked in order (using the conventions of + RFC 2234, RFC 2396, and RFC 2732; UCS4 stands for any UCS4 + character): + + Production T1 (VOS local; FSYS_VOS only): + "//." ["/" *UCS4] + becomes + "file:///" *UCS4 + + Production T2 (VOS host; FSYS_VOS only): + "//" [host] ["/" *UCS4] + becomes + "file://" host "/" *UCS4 + + Production T3 (UNC; FSYS_DOS only): + "\\" [host] ["\" *UCS4] + becomes + "file://" host "/" *UCS4 + replacing "\" by "/" within <*UCS4> + + Production T4 (Unix-like DOS; FSYS_DOS only): + ALPHA ":" ["/" *UCS4] + becomes + "file:///" ALPHA ":/" *UCS4 + replacing "\" by "/" within <*UCS4> + + Production T5 (DOS; FSYS_DOS only): + ALPHA ":" ["\" *UCS4] + becomes + "file:///" ALPHA ":/" *UCS4 + replacing "\" by "/" within <*UCS4> + + Production T6 (any): + *UCS4 + becomes + "file:///" *UCS4 + replacing the delimiter by "/" within <*UCS4>. The delimiter is + that character from the set { "/", "\", ":" } which appears most + often in <*UCS4> (if FSYS_UNX is not among the style bits, "/" + is removed from the set; if FSYS_DOS is not among the style + bits, "\" is removed from the set; if FSYS_MAC is not among the + style bits, ":" is removed from the set). If two or more + characters appear the same number of times, the character + mentioned first in that set is chosen. If the first character + of <*UCS4> is the delimiter, that character is not copied. + + @descr When used to translate a file URL to a file system path, + the following productions are checked in order (using the + conventions of RFC 2234, RFC 2396, and RFC 2732): + + Production F1 (VOS; FSYS_VOS): + "file://" host "/" fpath ["#" fragment] + becomes + "//" host "/" fpath + + Production F2 (DOS; FSYS_DOS): + "file:///" ALPHA ":" ["/" fpath] ["#" fragment] + becomes + ALPHA ":" ["\" fpath] + replacing "/" by "\" in <fpath> + + Production F3 (Unix; FSYS_UNX): + "file:///" fpath ["#" fragment] + becomes + "/" fpath + */ + FSYS_DETECT = FSYS_VOS | FSYS_UNX | FSYS_DOS + }; + + inline INetURLObject(rtl::OUString const & rTheAbsURIRef, + INetProtocol eTheSmartScheme, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + inline void SetSmartProtocol(INetProtocol eTheSmartScheme) + { m_eSmartScheme = eTheSmartScheme; } + + inline bool + SetSmartURL(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + inline bool + SetSmartURL(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + inline INetURLObject + smartRel2Abs(ByteString const & rTheRelURIRef, + bool & rWasAbsolute, + bool bIgnoreFragment = false, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + bool bRelativeNonURIs = false, + FSysStyle eStyle = FSYS_DETECT) const; + + inline INetURLObject + smartRel2Abs(rtl::OUString const & rTheRelURIRef, + bool & rWasAbsolute, + bool bIgnoreFragment = false, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + bool bRelativeNonURIs = false, + FSysStyle eStyle = FSYS_DETECT) const; + + //======================================================================== + // Relative URLs: + + inline bool + GetNewAbsURL(ByteString const & rTheRelURIRef, + INetURLObject * pTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT, bool bIgnoreFragment = false) + const; + + inline bool + GetNewAbsURL(rtl::OUString const & rTheRelURIRef, + INetURLObject * pTheAbsURIRef, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT, bool bIgnoreFragment = false) + const; + + /** @descr If rTheRelURIRef cannot be converted to an absolute URL + (because of syntactic reasons), either rTheRelURIRef or an empty + string is returned: If all of the parameters eEncodeMechanism, + eDecodeMechanism and eCharset have their respective default values, + then rTheRelURIRef is returned unmodified; otherwise, an empty string + is returned. + */ + static rtl::OUString + GetAbsURL(rtl::OUString const & rTheBaseURIRef, + rtl::OUString const & rTheRelURIRef, + bool bIgnoreFragment = false, + EncodeMechanism eEncodeMechanism = WAS_ENCODED, + DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + static inline rtl::OUString + GetRelURL(ByteString const & rTheBaseURIRef, + ByteString const & rTheAbsURIRef, + EncodeMechanism eEncodeMechanism = WAS_ENCODED, + DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + static inline rtl::OUString + GetRelURL(rtl::OUString const & rTheBaseURIRef, + rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eEncodeMechanism = WAS_ENCODED, + DecodeMechanism eDecodeMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8, + FSysStyle eStyle = FSYS_DETECT); + + //======================================================================== + // External URLs: + + rtl::OUString getExternalURL(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const; + + static inline bool translateToExternal(ByteString const & rTheIntURIRef, + rtl::OUString & rTheExtURIRef, + DecodeMechanism eDecodeMechanism + = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + static inline bool translateToExternal(rtl::OUString const & rTheIntURIRef, + rtl::OUString & rTheExtURIRef, + DecodeMechanism eDecodeMechanism + = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + static inline bool translateToInternal(ByteString const & rTheExtURIRef, + rtl::OUString & rTheIntURIRef, + DecodeMechanism eDecodeMechanism + = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + static inline bool translateToInternal(rtl::OUString const & rTheExtURIRef, + rtl::OUString & rTheIntURIRef, + DecodeMechanism eDecodeMechanism + = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + //======================================================================== + // Scheme: + + struct SchemeInfo; + + inline INetProtocol GetProtocol() const { return m_eScheme; } + + /** Return the URL 'prefix' for a given scheme. + + @param eTheScheme One of the supported URL schemes. + + @return The 'prefix' of URLs of the given scheme. + */ + static rtl::OUString GetScheme(INetProtocol eTheScheme); + + static inline INetProtocol CompareProtocolScheme(ByteString const & + rTheAbsURIRef) + { return CompareProtocolScheme(extend(rTheAbsURIRef)); } + + static INetProtocol CompareProtocolScheme(rtl::OUString const & + rTheAbsURIRef); + + //======================================================================== + // User Info: + + inline bool HasUserData() const { return m_aUser.isPresent(); } + + inline bool IsEmptyUser() const + { return m_aUser.isPresent() && m_aUser.isEmpty(); } + + bool hasPassword() const; + + inline bool IsEmptyPass() const + { return hasPassword() && m_aAuth.isEmpty(); } + + inline rtl::OUString GetUser(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aUser, getEscapePrefix(), eMechanism, eCharset); } + + inline rtl::OUString GetPass(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aAuth, getEscapePrefix(), eMechanism, eCharset); } + + inline bool SetUser(ByteString const & rTheUser, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setUser(extend(rTheUser), true, eMechanism, eCharset); } + + inline bool SetUser(rtl::OUString const & rTheUser, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setUser(rTheUser, false, eMechanism, eCharset); } + + void makeAuthCanonic(); + + inline bool SetPass(ByteString const & rThePassword, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetPass(rtl::OUString const & rThePassword, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetUserAndPass(ByteString const & rTheUser, + ByteString const & rThePassword, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + inline bool SetUserAndPass(rtl::OUString const & rTheUser, + rtl::OUString const & rThePassword, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + //======================================================================== + // Host and Port: + + inline bool HasPort() const { return m_aPort.isPresent(); } + + inline rtl::OUString GetHost(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aHost, getEscapePrefix(), eMechanism, eCharset); } + + rtl::OUString GetHostPort(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + sal_uInt32 GetPort() const; + + inline bool SetHost(ByteString const & rTheHost, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setHost(extend(rTheHost), true, eMechanism, eCharset); } + + inline bool SetHost(rtl::OUString const & rTheHost, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setHost(rTheHost, false, eMechanism, eCharset); } + + bool SetPort(sal_uInt32 nThePort); + + void makePortCanonic(); + + /** Encode the <hostport> part of a URL. + + @ATT Obsolete, because at the moment the <hostport> part of a URL may + not contain any escape sequences anyway, and because this method does + not inform the caller whether the given <hostport> part is legal. + + @param rTheHostPort The <hostport> part of a URL (for its + interpretation, see the general discussion for set-methods). + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return The <hostport> part, encoded according to the given mechanism + and charset ('forbidden' characters replaced by escape sequences). + */ + static inline rtl::OUString encodeHostPort(ByteString const & rTheHostPort, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + /** Encode the <hostport> part of a URL. + + @ATT Obsolete, because at the moment the <hostport> part of a URL may + not contain any escape sequences anyway, and because this method does + not inform the caller whether the given <hostport> part is legal. + + @param rTheHostPort The <hostport> part of a URL (for its + interpretation, see the general discussion for set-methods). + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return The <hostport> part, encoded according to the given mechanism + and charset ('forbidden' characters replaced by escape sequences). + */ + static inline rtl::OUString encodeHostPort(rtl::OUString const & rTheHostPort, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) + { return encodeHostPort(rTheHostPort, false, eMechanism, eCharset); } + + //======================================================================== + // Path: + + inline bool HasURLPath() const { return !m_aPath.isEmpty(); } + + inline rtl::OUString GetURLPath(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aPath, getEscapePrefix(), eMechanism, eCharset); } + + inline bool SetURLPath(ByteString const & rThePath, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setPath(extend(rThePath), true, eMechanism, eCharset); } + + inline bool SetURLPath(rtl::OUString const & rThePath, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return setPath(rThePath, false, eMechanism, eCharset); } + + //======================================================================== + // Hierarchical Path: + + /** A constant to address the last segment in various methods dealing with + hierarchical paths. + + @descr It is often more efficient to address the last segment using + this constant, than to determine its ordinal value using + getSegmentCount(). + */ + enum { LAST_SEGMENT = -1 }; + + /** The number of segments in the hierarchical path. + + @descr Using RFC 2396 and RFC 2234, a hierarchical path is of the + form + + hierarchical-path = 1*("/" segment) + + segment = name *(";" param) + + name = [base ["." extension]] + + base = 1*pchar + + extension = *<any pchar except "."> + + param = *pchar + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @return The number of segments in the hierarchical path. If the path + is not hierarchical, 0 is returned. + */ + sal_Int32 getSegmentCount(bool bIgnoreFinalSlash = true) const; + + /** Remove a segment from the hierarchical path. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @return True if the segment has successfully been removed (and the + resulting URI is still valid). If the path is not hierarchical, or + the specified segment does not exist, false is returned. If false is + returned, the object is not modified. + */ + bool removeSegment(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true); + + /** Insert a new segment into the hierarchical path. + + @param rTheName The name part of the new segment. The new segment + will contain no parameters. + + @param bAppendFinalSlash If the new segment is appended at the end of + the hierarchical path, this parameter specifies whether to add a final + slash after it or not. + + @param nIndex The non-negative index of the segment before which + to insert the new segment. LAST_SEGMENT or an nIndex that equals + getSegmentCount() inserts the new segment at the end of the + hierarchical path. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return True if the segment has successfully been inserted (and the + resulting URI is still valid). If the path is not hierarchical, or + the specified place to insert the new segment does not exist, false is + returned. If false is returned, the object is not modified. + */ + inline bool insertName(rtl::OUString const & rTheName, + bool bAppendFinalSlash = false, + sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + /** Get the name of a segment of the hierarchical path. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return The name part of the specified segment. If the path is not + hierarchical, or the specified segment does not exits, an empty string + is returned. + */ + rtl::OUString getName(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + /** Set the name of a segment (preserving any parameters and any query or + fragment part). + + @param rTheName The new name. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return True if the name has successfully been modified (and the + resulting URI is still valid). If the path is not hierarchical, or + the specified segment does not exist, false is returned. If false is + returned, the object is not modified. + */ + bool setName(rtl::OUString const & rTheName, + sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + /** Get the base of the name of a segment. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return The base part of the specified segment. If the path is + not hierarchical, or the specified segment does not exits, an empty + string is returned. + */ + rtl::OUString getBase(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + /** Set the base of the name of a segment (preserving the extension). + + @param rTheBase The new base. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return True if the base has successfully been modified (and the + resulting URI is still valid). If the path is not hierarchical, or + the specified segment does not exist, false is returned. If false is + returned, the object is not modified. + */ + bool setBase(rtl::OUString const & rTheBase, + sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + /** Determine whether the name of a segment has an extension. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @return True if the name of the specified segment has an extension. + If the path is not hierarchical, or the specified segment does not + exist, false is returned. + */ + bool hasExtension(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true) const; + + /** Get the extension of the name of a segment. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return The extension part of the specified segment. If the path is + not hierarchical, or the specified segment does not exits, an empty + string is returned. + */ + rtl::OUString getExtension(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + /** Set the extension of the name of a segment (replacing an already + existing extension). + + @param rTheExtension The new extension. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return True if the extension has successfully been modified (and the + resulting URI is still valid). If the path is not hierarchical, or + the specified segment does not exist, false is returned. If false is + returned, the object is not modified. + */ + bool setExtension(rtl::OUString const & rTheExtension, + sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + /** Remove the extension of the name of a segment. + + @param nIndex The non-negative index of the segment, or LAST_SEGMENT + if addressing the last segment. + + @param bIgnoreFinalSlash If true, a final slash at the end of the + hierarchical path does not denote an empty segment, but is ignored. + + @return True if the extension has successfully been removed (and the + resulting URI is still valid), or if the name did not have an + extension. If the path is not hierarchical, or the specified segment + does not exist, false is returned. If false is returned, the object + is not modified. + */ + bool removeExtension(sal_Int32 nIndex = LAST_SEGMENT, + bool bIgnoreFinalSlash = true); + + /** Determine whether the hierarchical path ends in a final slash. + + @return True if the hierarchical path ends in a final slash. If the + path is not hierarchical, false is returned. + */ + bool hasFinalSlash() const; + + /** Make the hierarchical path end in a final slash (if it does not + already do so). + + @return True if a final slash has successfully been appended (and the + resulting URI is still valid), or if the hierarchical path already + ended in a final slash. If the path is not hierarchical, false is + returned. If false is returned, the object is not modified. + */ + bool setFinalSlash(); + + /** Remove a final slash from the hierarchical path. + + @return True if a final slash has successfully been removed (and the + resulting URI is still valid), or if the hierarchical path already did + not end in a final slash. If the path is not hierarchical, false is + returned. If false is returned, the object is not modified. + */ + bool removeFinalSlash(); + + //======================================================================== + // Query: + + inline bool HasParam() const { return m_aQuery.isPresent(); } + + inline rtl::OUString GetParam(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aQuery, getEscapePrefix(), eMechanism, eCharset); } + + inline bool SetParam(ByteString const & rTheQuery, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetParam(rtl::OUString const & rTheQuery, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + //======================================================================== + // Fragment: + + inline bool HasMark() const { return m_aFragment.isPresent(); } + + inline rtl::OUString GetMark(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return decode(m_aFragment, getEscapePrefix(), eMechanism, eCharset); } + + inline bool SetMark(ByteString const & rTheFragment, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline bool SetMark(rtl::OUString const & rTheFragment, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + static rtl::OUString createFragment(rtl::OUString const & rText); + + //======================================================================== + // File URLs: + + /** Create an INetURLObject from a file system path. + + @param rFSysPath A file system path. An URL is not allowed here! + + @param eStyle The notation of rFSysPath. + */ + inline INetURLObject(rtl::OUString const & rFSysPath, FSysStyle eStyle); + + /** Set this INetURLObject to a file URL constructed from a file system + path. + + @param rFSysPath A file system path. An URL is not allowed here! + + @param eStyle The notation of rFSysPath. + + @return True if this INetURLObject has successfully been changed. If + false is returned, this INetURLObject has not been modified. + */ + bool setFSysPath(rtl::OUString const & rFSysPath, FSysStyle eStyle); + + /** Return the file system path represented by a file URL (ignoring any + fragment part). + + @param eStyle The notation of the returned file system path. + + @param pDelimiter Upon successful return, this parameter can return + the character that is the 'main' delimiter within the returned file + system path (e.g., "/" for Unix, "\" for DOS, ":" for Mac). This is + especially useful for routines that later try to shorten the returned + file system path at a 'good' position, e.g. to fit it into some + limited display space. + + @return The file system path represented by this file URL. If this + file URL does not represent a file system path according to the + specified notation, or if this is not a file URL at all, an empty + string is returned. + */ + rtl::OUString getFSysPath(FSysStyle eStyle, sal_Unicode * pDelimiter = 0) + const; + + //======================================================================== + // POP3 and URLs: + + bool HasMsgId() const; + + rtl::OUString GetMsgId(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + //======================================================================== + // Coding: + + enum Part + { + PART_OBSOLETE_NORMAL = 0x001, // Obsolete, do not use! + PART_OBSOLETE_FILE = 0x002, // Obsolete, do not use! + PART_OBSOLETE_PARAM = 0x004, // Obsolete, do not use! + PART_USER_PASSWORD = 0x008, + PART_IMAP_ACHAR = 0x010, + PART_VIM = 0x020, + PART_HOST_EXTRA = 0x040, + PART_FPATH = 0x080, + PART_AUTHORITY = 0x100, + PART_PATH_SEGMENTS_EXTRA = 0x200, + PART_REL_SEGMENT_EXTRA = 0x400, + PART_URIC = 0x800, + PART_HTTP_PATH = 0x1000, + PART_FILE_SEGMENT_EXTRA = 0x2000, // Obsolete, do not use! + PART_MESSAGE_ID = 0x4000, + PART_MESSAGE_ID_PATH = 0x8000, + PART_MAILTO = 0x10000, + PART_PATH_BEFORE_QUERY = 0x20000, + PART_PCHAR = 0x40000, + PART_FRAGMENT = 0x80000, // Obsolete, do not use! + PART_VISIBLE = 0x100000, + PART_VISIBLE_NONSPECIAL = 0x200000, + PART_CREATEFRAGMENT = 0x400000, + PART_UNO_PARAM_VALUE = 0x800000, + PART_UNAMBIGUOUS = 0x1000000, + PART_URIC_NO_SLASH = 0x2000000, + PART_HTTP_QUERY = 0x4000000, //TODO! unused? + PART_NEWS_ARTICLE_LOCALPART = 0x8000000, + max_part = 0x80000000 + // Do not use! Only there to allow compatible changes in the + // future. + }; + + enum EscapeType + { + ESCAPE_NO, + ESCAPE_OCTET, + ESCAPE_UTF32 + }; + + /** Encode some text as part of a URI. + + @param rText Some text (for its interpretation, see the general + discussion for set-methods). + + @param ePart The part says which characters are 'forbidden' and must + be encoded (replaced by escape sequences). Characters outside the US- + ASCII range are always 'forbidden.' + + @param cEscapePrefix The first character in an escape sequence + (normally '%'). + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return The encoded representation of the text ('forbidden' + characters replaced by escape sequences). + */ + static inline rtl::OUString encode(ByteString const & rText, Part ePart, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + /** Encode some text as part of a URI. + + @param rText Some text (for its interpretation, see the general + discussion for set-methods). + + @param ePart The part says which characters are 'forbidden' and must + be encoded (replaced by escape sequences). Characters outside the US- + ASCII range are always 'forbidden.' + + @param cEscapePrefix The first character in an escape sequence + (normally '%'). + + @param eMechanism See the general discussion for set-methods. + + @param eCharset See the general discussion for set-methods. + + @return The text, encoded according to the given mechanism and + charset ('forbidden' characters replaced by escape sequences). + */ + static inline rtl::OUString encode(rtl::OUString const & rText, Part ePart, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + /** Decode some text. + + @param rText Some (encoded) text. + + @param cEscapePrefix The first character in an escape sequence + (normally '%'). + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return The text, decoded according to the given mechanism and + charset (escape sequences replaced by 'raw' characters). + */ + static inline rtl::OUString decode(rtl::OUString const & rText, + sal_Char cEscapePrefix, + DecodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + static inline rtl::OUString decode(rtl::OUStringBuffer const & rText, + sal_Char cEscapePrefix, + DecodeMechanism eMechanism, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8); + + static void appendUCS4Escape(rtl::OUStringBuffer & rTheText, + sal_Char cEscapePrefix, + sal_uInt32 nUCS4); + + static void appendUCS4(rtl::OUStringBuffer & rTheText, sal_uInt32 nUCS4, + EscapeType eEscapeType, bool bOctets, Part ePart, + sal_Char cEscapePrefix, rtl_TextEncoding eCharset, + bool bKeepVisibleEscapes); + + static sal_uInt32 getUTF32(sal_Unicode const *& rBegin, + sal_Unicode const * pEnd, bool bOctets, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + EscapeType & rEscapeType); + + //======================================================================== + // Specialized helpers: + + static sal_uInt32 scanDomain(sal_Unicode const *& rBegin, + sal_Unicode const * pEnd, + bool bEager = true); + + //======================================================================== + // OBSOLETE Hierarchical Path: + + rtl::OUString GetPartBeforeLastName(DecodeMechanism eMechanism + = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const; + + /** Get the last segment in the path. + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return For a hierarchical URL, the last segment (everything after + the last unencoded '/'). Not that this last segment may be empty. If + the URL is not hierarchical, an empty string is returned. + */ + rtl::OUString GetLastName(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + const; + + /** Get the 'extension' of the last segment in the path. + + @param eMechanism See the general discussion for get-methods. + + @param eCharset See the general discussion for get-methods. + + @return For a hierarchical URL, everything after the first unencoded + '.' in the last segment of the path. Note that this 'extension' may + be empty. If the URL is not hierarchical, or if the last segment does + not contain an unencoded '.', an empty string is returned. + */ + rtl::OUString GetFileExtension(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const; + + inline bool Append(ByteString const & rTheSegment, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return appendSegment(extend(rTheSegment), true, eMechanism, eCharset); } + + inline bool Append(rtl::OUString const & rTheSegment, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8) + { return appendSegment(rTheSegment, false, eMechanism, eCharset); } + + bool CutLastName(); + + //======================================================================== + // OBSOLETE File URLs: + + rtl::OUString PathToFileName() const; + + rtl::OUString GetFull() const; + + rtl::OUString GetPath() const; + + void SetBase(rtl::OUString const & rTheBase); + + rtl::OUString GetBase() const; + + void SetName(rtl::OUString const & rTheName, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline rtl::OUString GetName(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return GetLastName(eMechanism, eCharset); } + + rtl::OUString CutName(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + void SetExtension(rtl::OUString const & rTheExtension, + EncodeMechanism eMechanism = WAS_ENCODED, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + inline rtl::OUString GetExtension( + DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset + = RTL_TEXTENCODING_UTF8) const + { return GetFileExtension(eMechanism, eCharset); } + + rtl::OUString CutExtension(DecodeMechanism eMechanism = DECODE_TO_IURI, + rtl_TextEncoding eCharset = RTL_TEXTENCODING_UTF8); + + bool IsCaseSensitive() const; + + //======================================================================== + +private: + // General Structure: + + class SubString + { + sal_Int32 m_nBegin; + sal_Int32 m_nLength; + + public: + explicit inline SubString(sal_Int32 nTheBegin = -1, + sal_Int32 nTheLength = 0): + m_nBegin(nTheBegin), m_nLength(nTheLength) {} + + inline bool isPresent() const { return m_nBegin != -1; } + + inline bool isEmpty() const { return m_nLength == 0; } + + inline sal_Int32 getBegin() const { return m_nBegin; } + + inline sal_Int32 getLength() const { return m_nLength; } + + inline sal_Int32 getEnd() const { return m_nBegin + m_nLength; } + + inline sal_Int32 clear(); + + inline sal_Int32 set(rtl::OUStringBuffer & rString, + rtl::OUString const & rSubString, + sal_Int32 nTheBegin); + + inline sal_Int32 set(rtl::OUString & rString, + rtl::OUString const & rSubString); + + inline sal_Int32 set(rtl::OUStringBuffer & rString, + rtl::OUString const & rSubString); + + inline void operator +=(sal_Int32 nDelta); + + int compare(SubString const & rOther, + rtl::OUStringBuffer const & rThisString, + rtl::OUStringBuffer const & rOtherString) const; + }; + + rtl::OUStringBuffer m_aAbsURIRef; + SubString m_aScheme; + SubString m_aUser; + SubString m_aAuth; + SubString m_aHost; + SubString m_aPort; + SubString m_aPath; + SubString m_aQuery; + SubString m_aFragment; + INetProtocol m_eScheme; + INetProtocol m_eSmartScheme; + + TOOLS_DLLPRIVATE void setInvalid(); + + bool setAbsURIRef( + rtl::OUString const & rTheAbsURIRef, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset, bool bSmart, + FSysStyle eStyle); + + // Relative URLs: + + bool convertRelToAbs( + rtl::OUString const & rTheRelURIRef, bool bOctets, + INetURLObject & rTheAbsURIRef, bool & rWasAbsolute, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset, + bool bIgnoreFragment, bool bSmart, bool bRelativeNonURIs, + FSysStyle eStyle) const; + + bool convertAbsToRel( + rtl::OUString const & rTheAbsURIRef, bool bOctets, + rtl::OUString & rTheRelURIRef, EncodeMechanism eEncodeMechanism, + DecodeMechanism eDecodeMechanism, rtl_TextEncoding eCharset, + FSysStyle eStyle) const; + + // External URLs: + + static bool convertIntToExt( + rtl::OUString const & rTheIntURIRef, bool bOctets, + rtl::OUString & rTheExtURIRef, DecodeMechanism eDecodeMechanism, + rtl_TextEncoding eCharset); + + static bool convertExtToInt( + rtl::OUString const & rTheExtURIRef, bool bOctets, + rtl::OUString & rTheIntURIRef, DecodeMechanism eDecodeMechanism, + rtl_TextEncoding eCharset); + + // Scheme: + + struct PrefixInfo; + + TOOLS_DLLPRIVATE static inline SchemeInfo const & getSchemeInfo( + INetProtocol eTheScheme); + + TOOLS_DLLPRIVATE inline SchemeInfo const & getSchemeInfo() const; + + TOOLS_DLLPRIVATE static PrefixInfo const * getPrefix( + sal_Unicode const *& rBegin, sal_Unicode const * pEnd); + + // Authority: + + TOOLS_DLLPRIVATE sal_Int32 getAuthorityBegin() const; + + TOOLS_DLLPRIVATE SubString getAuthority() const; + + // User Info: + + bool setUser( + rtl::OUString const & rTheUser, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + bool clearPassword(); + + bool setPassword( + rtl::OUString const & rThePassword, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + // Host and Port: + + TOOLS_DLLPRIVATE static bool parseHost( + sal_Unicode const *& rBegin, sal_Unicode const * pEnd, + rtl::OUString & rCanonic); + + TOOLS_DLLPRIVATE static bool parseHostOrNetBiosName( + sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset, + bool bNetBiosName, rtl::OUStringBuffer* pCanonic); + + static rtl::OUString encodeHostPort( + rtl::OUString const & rTheHostPort, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + bool setHost( + rtl::OUString const & rTheHost, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + // Path: + + TOOLS_DLLPRIVATE static bool parsePath( + INetProtocol eScheme, sal_Unicode const ** pBegin, + sal_Unicode const * pEnd, bool bOctets, EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, bool bSkippedInitialSlash, + sal_uInt32 nSegmentDelimiter, sal_uInt32 nAltSegmentDelimiter, + sal_uInt32 nQueryDelimiter, sal_uInt32 nFragmentDelimiter, + rtl::OUStringBuffer &rSynPath); + + bool setPath( + rtl::OUString const & rThePath, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + // Hierarchical Path: + + TOOLS_DLLPRIVATE bool checkHierarchical() const; + + bool appendSegment( + rtl::OUString const & rTheSegment, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + TOOLS_DLLPRIVATE SubString getSegment( + sal_Int32 nIndex, bool bIgnoreFinalSlash) const; + + bool insertName( + rtl::OUString const & rTheName, bool bOctets, bool bAppendFinalSlash, + sal_Int32 nIndex, bool bIgnoreFinalSlash, EncodeMechanism eMechanism, + rtl_TextEncoding eCharset); + + // Query: + + bool clearQuery(); + + bool setQuery( + rtl::OUString const & rTheQuery, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + // Fragment: + + bool clearFragment(); + + bool setFragment( + rtl::OUString const & rTheMark, bool bOctets, + EncodeMechanism eMechanism, rtl_TextEncoding eCharset); + + // FTP URLs: + + enum FTPType { FTP_TYPE_NONE, FTP_TYPE_A, FTP_TYPE_I, FTP_TYPE_D }; + + TOOLS_DLLPRIVATE FTPType getFTPType() const; + + // FILE URLs: + + TOOLS_DLLPRIVATE bool hasDosVolume(FSysStyle eStyle) const; + + // IMAP URLs: + + TOOLS_DLLPRIVATE sal_uInt32 getIMAPUID() const; + + // Coding: + + static inline rtl::OUString extend(ByteString const & rOctets) + { + return rtl::OUString(rOctets.GetBuffer(), rOctets.Len(), + RTL_TEXTENCODING_ISO_8859_1); + } + + static inline sal_Char getEscapePrefix(INetProtocol eTheScheme) + { return eTheScheme == INET_PROT_VIM ? '=' : '%'; } + + inline sal_Char getEscapePrefix() const + { return getEscapePrefix(m_eScheme); } + + TOOLS_DLLPRIVATE static inline void appendEscape( + rtl::OUStringBuffer & rTheText, sal_Char cEscapePrefix, + sal_uInt32 nOctet); + + static rtl::OUString encodeText( + sal_Unicode const * pBegin, sal_Unicode const * pEnd, bool bOctets, + Part ePart, sal_Char cEscapePrefix, EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, bool bKeepVisibleEscapes); + + static inline rtl::OUString encodeText( + rtl::OUString const & rTheText, bool bOctets, Part ePart, + sal_Char cEscapePrefix, EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, bool bKeepVisibleEscapes); + + static rtl::OUString decode( + sal_Unicode const * pBegin, sal_Unicode const * pEnd, + sal_Char cEscapePrefix, DecodeMechanism, rtl_TextEncoding eCharset); + + inline rtl::OUString decode( + SubString const & rSubString, sal_Char cEscapePrefix, + DecodeMechanism eMechanism, rtl_TextEncoding eCharset) const; + + // Specialized helpers: + + TOOLS_DLLPRIVATE static bool scanIPv6reference( + sal_Unicode const *& rBegin, sal_Unicode const * pEnd); +}; + +// static +inline rtl::OUString INetURLObject::encodeText(rtl::OUString const & rTheText, + bool bOctets, Part ePart, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + bool bKeepVisibleEscapes) +{ + return encodeText(rTheText.getStr(), + rTheText.getStr() + rTheText.getLength(), bOctets, ePart, + cEscapePrefix, eMechanism, eCharset, + bKeepVisibleEscapes); +} + +inline rtl::OUString INetURLObject::decode(SubString const & rSubString, + sal_Char cEscapePrefix, + DecodeMechanism eMechanism, + rtl_TextEncoding eCharset) const +{ + return rSubString.isPresent() ? + decode(m_aAbsURIRef.getStr() + rSubString.getBegin(), + m_aAbsURIRef.getStr() + rSubString.getEnd(), + cEscapePrefix, eMechanism, eCharset) : + rtl::OUString(); +} + +inline INetURLObject::INetURLObject(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset): + m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) +{ + setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset, false, + FSysStyle(0)); +} + +inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset): + m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) +{ + setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false, + FSysStyle(0)); +} + +inline bool INetURLObject::SetURL(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset, + false, FSysStyle(0)); +} + +inline bool INetURLObject::SetURL(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, false, + FSysStyle(0)); +} + +inline INetURLObject::INetURLObject(rtl::OUString const & rTheAbsURIRef, + INetProtocol eTheSmartScheme, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle): + m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(eTheSmartScheme) +{ + setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, eStyle); +} + +inline bool INetURLObject::SetSmartURL(ByteString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle) +{ + return setAbsURIRef(extend(rTheAbsURIRef), true, eMechanism, eCharset, + true, eStyle); +} + +inline bool INetURLObject::SetSmartURL(rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle) +{ + return setAbsURIRef(rTheAbsURIRef, false, eMechanism, eCharset, true, + eStyle); +} + +inline INetURLObject +INetURLObject::smartRel2Abs(ByteString const & rTheRelURIRef, + bool & rWasAbsolute, + bool bIgnoreFragment, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + bool bRelativeNonURIs, + FSysStyle eStyle) const +{ + INetURLObject aTheAbsURIRef; + convertRelToAbs(extend(rTheRelURIRef), true, aTheAbsURIRef, rWasAbsolute, + eMechanism, eCharset, bIgnoreFragment, true, + bRelativeNonURIs, eStyle); + return aTheAbsURIRef; +} + +inline INetURLObject +INetURLObject::smartRel2Abs(rtl::OUString const & rTheRelURIRef, + bool & rWasAbsolute, + bool bIgnoreFragment, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + bool bRelativeNonURIs, + FSysStyle eStyle) const +{ + INetURLObject aTheAbsURIRef; + convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, rWasAbsolute, + eMechanism, eCharset, bIgnoreFragment, true, + bRelativeNonURIs, eStyle); + return aTheAbsURIRef; +} + +inline bool INetURLObject::GetNewAbsURL(ByteString const & rTheRelURIRef, + INetURLObject * pTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle, bool bIgnoreFragment) + const +{ + INetURLObject aTheAbsURIRef; + bool bWasAbsolute; + if (!convertRelToAbs(extend(rTheRelURIRef), true, aTheAbsURIRef, + bWasAbsolute, eMechanism, eCharset, bIgnoreFragment, + false, false, eStyle)) + return false; + if (pTheAbsURIRef) + *pTheAbsURIRef = aTheAbsURIRef; + return true; +} + +inline bool INetURLObject::GetNewAbsURL(rtl::OUString const & rTheRelURIRef, + INetURLObject * pTheAbsURIRef, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle, bool bIgnoreFragment) + const +{ + INetURLObject aTheAbsURIRef; + bool bWasAbsolute; + if (!convertRelToAbs(rTheRelURIRef, false, aTheAbsURIRef, bWasAbsolute, + eMechanism, eCharset, bIgnoreFragment, false, false, + eStyle)) + return false; + if (pTheAbsURIRef) + *pTheAbsURIRef = aTheAbsURIRef; + return true; +} + +// static +inline rtl::OUString INetURLObject::GetRelURL(ByteString const & rTheBaseURIRef, + ByteString const & rTheAbsURIRef, + EncodeMechanism eEncodeMechanism, + DecodeMechanism eDecodeMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle) +{ + rtl::OUString aTheRelURIRef; + INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset). + convertAbsToRel(extend(rTheAbsURIRef), true, aTheRelURIRef, + eEncodeMechanism, eDecodeMechanism, eCharset, eStyle); + return aTheRelURIRef; +} + +// static +inline rtl::OUString INetURLObject::GetRelURL(rtl::OUString const & rTheBaseURIRef, + rtl::OUString const & rTheAbsURIRef, + EncodeMechanism eEncodeMechanism, + DecodeMechanism eDecodeMechanism, + rtl_TextEncoding eCharset, + FSysStyle eStyle) +{ + rtl::OUString aTheRelURIRef; + INetURLObject(rTheBaseURIRef, eEncodeMechanism, eCharset). + convertAbsToRel(rTheAbsURIRef, false, aTheRelURIRef, eEncodeMechanism, + eDecodeMechanism, eCharset, eStyle); + return aTheRelURIRef; +} + +// static +inline bool INetURLObject::translateToExternal(ByteString const & + rTheIntURIRef, + rtl::OUString & rTheExtURIRef, + DecodeMechanism + eDecodeMechanism, + rtl_TextEncoding eCharset) +{ + rtl::OUString aTheExtURIRef; + bool bRet = convertIntToExt(extend(rTheIntURIRef), true, aTheExtURIRef, + eDecodeMechanism, eCharset); + rTheExtURIRef = aTheExtURIRef; + return bRet; +} + +// static +inline bool INetURLObject::translateToExternal(rtl::OUString const & + rTheIntURIRef, + rtl::OUString & rTheExtURIRef, + DecodeMechanism + eDecodeMechanism, + rtl_TextEncoding eCharset) +{ + return convertIntToExt(rTheIntURIRef, false, rTheExtURIRef, + eDecodeMechanism, eCharset); +} + +// static +inline bool INetURLObject::translateToInternal(ByteString const & + rTheExtURIRef, + rtl::OUString & rTheIntURIRef, + DecodeMechanism + eDecodeMechanism, + rtl_TextEncoding eCharset) +{ + rtl::OUString aTheIntURIRef; + bool bRet = convertExtToInt(extend(rTheExtURIRef), true, aTheIntURIRef, + eDecodeMechanism, eCharset); + rTheIntURIRef = aTheIntURIRef; + return bRet; +} + +// static +inline bool INetURLObject::translateToInternal(rtl::OUString const & + rTheExtURIRef, + rtl::OUString & rTheIntURIRef, + DecodeMechanism + eDecodeMechanism, + rtl_TextEncoding eCharset) +{ + return convertExtToInt(rTheExtURIRef, false, rTheIntURIRef, + eDecodeMechanism, eCharset); +} + +inline bool INetURLObject::SetPass(ByteString const & rThePassword, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rThePassword.Len() == 0 ? + clearPassword() : + setPassword(extend(rThePassword), true, eMechanism, eCharset); +} + +inline bool INetURLObject::SetPass(rtl::OUString const & rThePassword, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rThePassword.getLength() == 0 ? + clearPassword() : + setPassword(rThePassword, false, eMechanism, eCharset); +} + +inline bool INetURLObject::SetUserAndPass(ByteString const & rTheUser, + ByteString const & rThePassword, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return setUser(extend(rTheUser), true, eMechanism, eCharset) + && (rThePassword.Len() == 0 ? + clearPassword() : + setPassword(extend(rThePassword), true, eMechanism, + eCharset)); +} + +inline bool INetURLObject::SetUserAndPass(rtl::OUString const & rTheUser, + rtl::OUString const & rThePassword, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return setUser(rTheUser, false, eMechanism, eCharset) + && (rThePassword.getLength() == 0 ? + clearPassword() : + setPassword(rThePassword, false, eMechanism, eCharset)); +} + +// static +inline rtl::OUString INetURLObject::encodeHostPort(ByteString const & + rTheHostPort, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return encodeHostPort(extend(rTheHostPort), true, eMechanism, eCharset); +} + +inline bool INetURLObject::insertName(rtl::OUString const & rTheName, + bool bAppendFinalSlash, + sal_Int32 nIndex, + bool bIgnoreFinalSlash, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return insertName(rTheName, false, bAppendFinalSlash, nIndex, + bIgnoreFinalSlash, eMechanism, eCharset); +} + +inline bool INetURLObject::SetParam(ByteString const & rTheQuery, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rTheQuery.Len() == 0 ? + clearQuery() : + setQuery(extend(rTheQuery), true, eMechanism, eCharset); +} + +inline bool INetURLObject::SetParam(rtl::OUString const & rTheQuery, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rTheQuery.getLength() == 0 ? + clearQuery() : + setQuery(rTheQuery, false, eMechanism, eCharset); +} + +inline bool INetURLObject::SetMark(ByteString const & rTheFragment, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rTheFragment.Len() == 0 ? + clearFragment() : + setFragment(extend(rTheFragment), true, eMechanism, eCharset); +} + +inline bool INetURLObject::SetMark(rtl::OUString const & rTheFragment, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return rTheFragment.getLength() == 0 ? + clearFragment() : + setFragment(rTheFragment, false, eMechanism, eCharset); +} + +inline INetURLObject::INetURLObject(rtl::OUString const & rFSysPath, + FSysStyle eStyle): + m_eScheme(INET_PROT_NOT_VALID), m_eSmartScheme(INET_PROT_HTTP) +{ + setFSysPath(rFSysPath, eStyle); +} + +// static +inline rtl::OUString INetURLObject::encode(ByteString const & rText, Part ePart, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return encodeText(extend(rText), true, ePart, cEscapePrefix, eMechanism, + eCharset, false); +} + +// static +inline rtl::OUString INetURLObject::encode(rtl::OUString const & rText, Part ePart, + sal_Char cEscapePrefix, + EncodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return encodeText(rText, false, ePart, cEscapePrefix, eMechanism, + eCharset, false); +} + +// static +inline rtl::OUString INetURLObject::decode(rtl::OUString const & rText, + sal_Char cEscapePrefix, + DecodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return decode(rText.getStr(), rText.getStr() + rText.getLength(), + cEscapePrefix, eMechanism, eCharset); +} + +inline rtl::OUString INetURLObject::decode(rtl::OUStringBuffer const & rText, + sal_Char cEscapePrefix, + DecodeMechanism eMechanism, + rtl_TextEncoding eCharset) +{ + return decode(rText.getStr(), rText.getStr() + rText.getLength(), + cEscapePrefix, eMechanism, eCharset); +} + +#endif // _URLOBJ_HXX diff --git a/tools/inc/tools/vcompat.hxx b/tools/inc/tools/vcompat.hxx new file mode 100644 index 000000000000..f6ee6922faac --- /dev/null +++ b/tools/inc/tools/vcompat.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * 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 _VCOMPAT_HXX +#define _VCOMPAT_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +// ----------- +// - Defines - +// ----------- + +#define COMPAT_FORMAT( char1, char2, char3, char4 ) \ + ((UINT32)((((UINT32)(char)(char1)))| \ + (((UINT32)(char)(char2))<<8UL)| \ + (((UINT32)(char)(char3))<<16UL)| \ + ((UINT32)(char)(char4))<<24UL)) + +// -------------- +// - ImplCompat - +// -------------- + +class SvStream; + +class TOOLS_DLLPUBLIC VersionCompat +{ + SvStream* mpRWStm; + UINT32 mnCompatPos; + UINT32 mnTotalSize; + UINT16 mnStmMode; + UINT16 mnVersion; + + VersionCompat() {} + VersionCompat( const VersionCompat& ) {} + VersionCompat& operator=( const VersionCompat& ) { return *this; } + BOOL operator==( const VersionCompat& ) { return FALSE; } + +public: + + VersionCompat( SvStream& rStm, USHORT nStreamMode, UINT16 nVersion = 1 ); + ~VersionCompat(); + + UINT16 GetVersion() const { return mnVersion; } +}; + +#endif // _VCOMPAT_HXX diff --git a/tools/inc/tools/vector2d.hxx b/tools/inc/tools/vector2d.hxx new file mode 100644 index 000000000000..d346e1af2bbf --- /dev/null +++ b/tools/inc/tools/vector2d.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * 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 _VECTOR2D_HXX +#define _VECTOR2D_HXX + +#include <math.h> +#include <tools/gen.hxx> + +// ------------ +// - Vector2D - +// ------------ + +class Vector2D +{ +private: + double mfX; + double mfY; + +public: + inline Vector2D() : mfX( 0.0 ), mfY( 0.0 ) {} + inline Vector2D( double fX, double fY ) : mfX( fX ), mfY( fY ) {} + inline Vector2D( const Vector2D& rVec ) : mfX( rVec.mfX ), mfY( rVec.mfY ) {} + inline Vector2D( const Pair& rPair ) : mfX( rPair.nA ), mfY( rPair.nB ) {}; + inline ~Vector2D() {} + + inline const double& X() const { return mfX; } + inline const double& Y() const { return mfY; } + inline double& X() { return mfX; } + inline double& Y() { return mfY; } + inline const double& operator[] (int nPos) const { return (nPos ? mfY : mfX); } + inline double& operator[] (int nPos) { return (nPos ? mfY : mfX); } + + inline double GetLength() const { return hypot( mfX, mfY ); } + inline Vector2D& Normalize(); + + inline void Min(const Vector2D& rVec) { if(rVec.mfX < mfX) mfX = rVec.mfX; if(rVec.mfY < mfY) mfY = rVec.mfY; } + inline void Max(const Vector2D& rVec) { if(rVec.mfX > mfX) mfX = rVec.mfX; if(rVec.mfY > mfY) mfY = rVec.mfY; } + inline void Abs() { if(mfX < 0.0) mfX = -mfX; if(mfY < 0.0) mfY = -mfY; } + + inline void CalcInBetween(Vector2D& rOld1, Vector2D& rOld2, double t) + { mfX = ((rOld2.mfX - rOld1.mfX) + t) + rOld1.mfX; mfY = ((rOld2.mfY - rOld1.mfY) + t) + rOld1.mfY; } + inline void CalcMiddle(Vector2D& rOld1, Vector2D& rOld2) + { mfX = (rOld1.mfX + rOld2.mfX) / 2.0; mfY = (rOld1.mfY + rOld2.mfY) / 2.0; } + inline void CalcMiddle(Vector2D& rOld1, Vector2D& rOld2, Vector2D& rOld3) + { mfX = (rOld1.mfX + rOld2.mfX + rOld3.mfX) / 3.0; mfY = (rOld1.mfY + rOld2.mfY + rOld3.mfY) / 3.0; } + + inline Vector2D& operator+=( const Vector2D& rVec ) { mfX += rVec.mfX, mfY += rVec.mfY; return *this; } + inline Vector2D& operator-=( const Vector2D& rVec ) { mfX -= rVec.mfX, mfY -= rVec.mfY; return *this; } + inline Vector2D operator+(const Vector2D& rVec) const { Vector2D aSum(*this); aSum += rVec; return aSum; } + inline Vector2D operator-(const Vector2D& rVec) const { Vector2D aSub(*this); aSub -= rVec; return aSub; } + inline Vector2D operator-(void) const { return Vector2D(-mfX, -mfY); } + + inline double Scalar( const Vector2D& rVec ) const { return( mfX * rVec.mfX + mfY * rVec.mfY ); } + + inline Vector2D& operator/=( const Vector2D& rVec ) { mfX /= rVec.mfX, mfY /= rVec.mfY; return *this; } + inline Vector2D& operator*=( const Vector2D& rVec ) { mfX *= rVec.mfX, mfY *= rVec.mfY; return *this; } + inline Vector2D operator/(const Vector2D& rVec) const { Vector2D aDiv(*this); aDiv /= rVec; return aDiv; } + inline Vector2D operator*(const Vector2D& rVec) const { Vector2D aMul(*this); aMul *= rVec; return aMul; } + + inline Vector2D& operator*=(double t) { mfX *= t; mfY *= t; return *this; } + inline Vector2D operator*(double t) const { Vector2D aNew(*this); aNew *= t; return aNew; } + inline Vector2D& operator/=(double t) { mfX /= t; mfY /= t; return *this; } + inline Vector2D operator/(double t) const { Vector2D aNew(*this); aNew /= t; return aNew; } + + inline BOOL operator==( const Vector2D& rVec ) const { return( mfX == rVec.mfX && mfY == rVec.mfY ); } + inline BOOL operator!=( const Vector2D& rVec ) const { return !( *this == rVec ); } + + inline Vector2D& operator=( const Vector2D& rVec ) { mfX = rVec.mfX, mfY = rVec.mfY; return *this; } + inline Vector2D& operator=( const Pair& rPair ) { mfX = rPair.nA, mfY = rPair.nB; return *this; } + inline Vector2D& operator-=( const Pair& rPair ) { mfX -= rPair.nA, mfY -= rPair.nB; return *this; } + inline Vector2D& operator+=( const Pair& rPair ) { mfX += rPair.nA, mfY += rPair.nB; return *this; } + inline Vector2D& operator*=( const Pair& rPair ) { mfX *= rPair.nA, mfY *= rPair.nB; return *this; } + inline Vector2D& operator/=( const Pair& rPair ) { mfX /= rPair.nA, mfY /= rPair.nB; return *this; } + + inline BOOL operator==( const Pair& rPair ) const { return( mfX == rPair.nA && mfY == rPair.nB ); } + inline BOOL operator!=( const Pair& rPair ) const { return !( *this == rPair ); } + + inline BOOL IsPositive( Vector2D& rVec ) const { return( ( mfX * rVec.mfY - mfY * rVec.mfX ) >= 0.0 ); } + inline BOOL IsNegative( Vector2D& rVec ) const { return !IsPositive( rVec ); } +}; + +// ----------------------------------------------------------------------------- + +inline Vector2D& Vector2D::Normalize() +{ + double fLen = Scalar( *this ); + + if( ( fLen != 0.0 ) && ( fLen != 1.0 ) && ( ( fLen = sqrt( fLen ) ) != 0.0 ) ) + mfX /= fLen, mfY /= fLen; + + return *this; +} + +#endif // _SV_VECTOR2D_HXX diff --git a/tools/inc/tools/weakbase.h b/tools/inc/tools/weakbase.h new file mode 100644 index 000000000000..a66da8c7c33f --- /dev/null +++ b/tools/inc/tools/weakbase.h @@ -0,0 +1,160 @@ +/************************************************************************* + * + * 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 _TOOLS_WEAKBASE_H_ +#define _TOOLS_WEAKBASE_H_ + +#include <sal/types.h> +#include <osl/diagnose.h> + +/** the template classes in this header are helper to implement weak references + to implementation objects that are not refcounted. + + THIS IS NOT THREADSAFE + + Use this only to have 'safe' pointers to implementation objects that you + don't own but that you reference with a pointer. + + Example: + + class ImplClass : public tools::WeakBase< ImplClass > + { + ~ImplClass() { clearWeek(); } // not needed but safer, see method description + ... + }; + + class UserClass + { + tools::WeakReference< ImplClass > mxWeakRef; + + UserClass( ImplClass* pOjbect ) : mxWeakRef( pObject ) {} + + DoSomething() + { + if( mxWeakRef.is() ) + mxWeakRef->DoSomethingMore(); + } + }; +*/ +namespace tools +{ + +// -------------------------------------------------------------------- + +/** private connection helper, do not use directly */ +template <class reference_type> +struct WeakConnection +{ + sal_Int32 mnRefCount; + reference_type* mpReference; + + WeakConnection( reference_type* pReference ) : mnRefCount( 0 ), mpReference( pReference ) {}; + void acquire() { mnRefCount++; } + void release() { mnRefCount--; if( mnRefCount == 0 ) delete this; } +}; + +// -------------------------------------------------------------------- + +/** template implementation to hold a weak reference to an instance of type reference_type */ +template <class reference_type> +class WeakReference +{ +public: + /** constructs an empty reference */ + inline WeakReference(); + + /** constructs a reference with a pointer to a class derived from WeakBase */ + inline WeakReference( reference_type* pReference ); + + /** constructs a reference with another reference */ + inline WeakReference( const WeakReference< reference_type >& rWeakRef ); + + inline ~WeakReference(); + + /** returns true if the reference object is not null and still alive */ + inline bool is() const; + + /** returns the pointer to the reference object or null */ + inline reference_type * get() const; + + /** sets this reference to the given object or null */ + inline void reset( reference_type* pReference ); + + /** returns the pointer to the reference object or null */ + inline reference_type * operator->() const; + + /** returns true if this instance references pReferenceObject */ + inline sal_Bool operator== (const reference_type * pReferenceObject) const; + + /** returns true if this instance and the given weakref reference the same object */ + inline sal_Bool operator== (const WeakReference<reference_type> & handle) const; + + /** only needed for using this class with stl containers */ + inline sal_Bool operator!= (const WeakReference<reference_type> & handle) const; + + /** only needed for using this class with stl containers */ + inline sal_Bool operator< (const WeakReference<reference_type> & handle) const; + + /** only needed for using this class with stl containers */ + inline sal_Bool operator> (const WeakReference<reference_type> & handle) const; + + /** the assignment operator */ + inline WeakReference<reference_type>& operator= (const WeakReference<reference_type> & handle); + +private: + WeakConnection< reference_type >* mpWeakConnection; +}; + +// -------------------------------------------------------------------- + +/** derive your implementation classes from this class if you want them to support weak references */ +template <class reference_type> +class WeakBase +{ + friend class WeakReference<reference_type>; + +public: + inline WeakBase(); + + inline ~WeakBase(); + /** clears the reference pointer in all living weak references for this instance. + Further created weak references will also be invalid. + You should call this method in the d'tor of your derived classes for an early + invalidate of all living weak references while youre object is already inside + it d'tor. + */ + inline void clearWeak(); + +private: + inline WeakConnection< reference_type >* getWeakConnection(); + WeakConnection< reference_type >* mpWeakConnection; +}; + +} + +#endif // _TOOLS_WEAKBASE_H_ + diff --git a/tools/inc/tools/weakbase.hxx b/tools/inc/tools/weakbase.hxx new file mode 100644 index 000000000000..81f53fb3516b --- /dev/null +++ b/tools/inc/tools/weakbase.hxx @@ -0,0 +1,183 @@ +/************************************************************************* + * + * 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 _TOOLS_WEAKBASE_HXX_ +#define _TOOLS_WEAKBASE_HXX_ + +#include <tools/weakbase.h> + +/// see weakbase.h for documentation + +namespace tools +{ + +template< class reference_type > +inline WeakReference< reference_type >::WeakReference() +{ + mpWeakConnection = new WeakConnection<reference_type>( 0 ); + mpWeakConnection->acquire(); +} + +template< class reference_type > +inline WeakReference< reference_type >::WeakReference( reference_type* pReference ) +{ + if( pReference ) + mpWeakConnection = pReference->getWeakConnection(); + else + mpWeakConnection = new WeakConnection<reference_type>( 0 ); + + mpWeakConnection->acquire(); +} + +template< class reference_type > +inline WeakReference< reference_type >::WeakReference( const WeakReference< reference_type >& rWeakRef ) +{ + mpWeakConnection = rWeakRef.mpWeakConnection; + mpWeakConnection->acquire(); +} + +template< class reference_type > +inline WeakReference< reference_type >::~WeakReference() +{ + mpWeakConnection->release(); +} + +template< class reference_type > +inline bool WeakReference< reference_type >::is() const +{ + return mpWeakConnection->mpReference != 0; +} + +template< class reference_type > +inline reference_type * WeakReference< reference_type >::get() const +{ + return mpWeakConnection->mpReference; +} + +template< class reference_type > +inline void WeakReference< reference_type >::reset( reference_type* pReference ) +{ + mpWeakConnection->release(); + + if( pReference ) + mpWeakConnection = pReference->getWeakConnection(); + else + mpWeakConnection = new WeakConnection<reference_type>( 0 ); + + mpWeakConnection->acquire(); +} + +template< class reference_type > +inline reference_type * WeakReference< reference_type >::operator->() const +{ + OSL_PRECOND(mpWeakConnection, "tools::WeakReference::operator->() : null body"); + return mpWeakConnection->mpReference; +} + +template< class reference_type > +inline sal_Bool WeakReference< reference_type >::operator==(const reference_type * pReferenceObject) const +{ + return mpWeakConnection->mpReference == pReferenceObject; +} + +template< class reference_type > +inline sal_Bool WeakReference< reference_type >::operator==(const WeakReference<reference_type> & handle) const +{ + return mpWeakConnection == handle.mpWeakConnection; +} + +template< class reference_type > +inline sal_Bool WeakReference< reference_type >::operator!=(const WeakReference<reference_type> & handle) const +{ + return mpWeakConnection != handle.mpWeakConnection; +} + +template< class reference_type > +inline sal_Bool WeakReference< reference_type >::operator<(const WeakReference<reference_type> & handle) const +{ + return mpWeakConnection->mpReference < handle.mpWeakConnection->mpReference; +} + +template< class reference_type > +inline sal_Bool WeakReference< reference_type >::operator>(const WeakReference<reference_type> & handle) const +{ + return mpWeakConnection->mpReference > handle.mpWeakConnection->mpReference; +} + +template< class reference_type > +inline WeakReference<reference_type>& WeakReference<reference_type>::operator= ( + const WeakReference<reference_type>& rReference) +{ + if (&rReference != this) + { + mpWeakConnection->release(); + + mpWeakConnection = rReference.mpWeakConnection; + mpWeakConnection->acquire(); + } + return *this; +} + +template< class reference_type > +inline WeakBase< reference_type >::WeakBase() +{ + mpWeakConnection = 0; +} + +template< class reference_type > +inline WeakBase< reference_type >::~WeakBase() +{ + if( mpWeakConnection ) + { + mpWeakConnection->mpReference = 0; + mpWeakConnection->release(); + mpWeakConnection = 0; + } +} + +template< class reference_type > +inline void WeakBase< reference_type >::clearWeak() +{ + if( mpWeakConnection ) + mpWeakConnection->mpReference = 0; +} + +template< class reference_type > +inline WeakConnection< reference_type >* WeakBase< reference_type >::getWeakConnection() +{ + if( !mpWeakConnection ) + { + mpWeakConnection = new WeakConnection< reference_type >( static_cast< reference_type* >( this ) ); + mpWeakConnection->acquire(); + } + return mpWeakConnection; +} + +} + +#endif // _TOOLS_WEAKBASE_HXX_ + diff --git a/tools/inc/tools/wintypes.hxx b/tools/inc/tools/wintypes.hxx new file mode 100644 index 000000000000..9c7052e22d77 --- /dev/null +++ b/tools/inc/tools/wintypes.hxx @@ -0,0 +1,349 @@ +/************************************************************************* + * + * 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 _TOOLS_WINTYPES_HXX +#define _TOOLS_WINTYPES_HXX + +#include <tools/solar.h> +#include <sal/types.h> + +// ---------------- +// - Window-Types - +// ---------------- + +typedef USHORT WindowType; +#define WINDOW_BASE 0x0100 +#define WINDOW_FIRST (WINDOW_BASE + 0x30) +#define WINDOW_MESSBOX (WINDOW_FIRST) +#define WINDOW_INFOBOX (WINDOW_FIRST + 0x01) +#define WINDOW_WARNINGBOX (WINDOW_FIRST + 0x02) +#define WINDOW_ERRORBOX (WINDOW_FIRST + 0x03) +#define WINDOW_QUERYBOX (WINDOW_FIRST + 0x04) +#define WINDOW_WINDOW (WINDOW_FIRST + 0x05) +#define WINDOW_SYSWINDOW (WINDOW_FIRST + 0x06) +#define WINDOW_WORKWINDOW (WINDOW_FIRST + 0x07) +// #define WINDOW_MDIWINDOW (WINDOW_FIRST + 0x08) +#define WINDOW_FLOATINGWINDOW (WINDOW_FIRST + 0x09) +#define WINDOW_DIALOG (WINDOW_FIRST + 0x0a) +#define WINDOW_MODELESSDIALOG (WINDOW_FIRST + 0x0b) +#define WINDOW_MODALDIALOG (WINDOW_FIRST + 0x0c) +#define WINDOW_SYSTEMDIALOG (WINDOW_FIRST + 0x0d) +#define WINDOW_PATHDIALOG (WINDOW_FIRST + 0x0e) +#define WINDOW_FILEDIALOG (WINDOW_FIRST + 0x0f) +#define WINDOW_PRINTERSETUPDIALOG (WINDOW_FIRST + 0x10) +#define WINDOW_PRINTDIALOG (WINDOW_FIRST + 0x11) +#define WINDOW_COLORDIALOG (WINDOW_FIRST + 0x12) +#define WINDOW_FONTDIALOG (WINDOW_FIRST + 0x13) +#define WINDOW_CONTROL (WINDOW_FIRST + 0x14) +#define WINDOW_BUTTON (WINDOW_FIRST + 0x15) +#define WINDOW_PUSHBUTTON (WINDOW_FIRST + 0x16) +#define WINDOW_OKBUTTON (WINDOW_FIRST + 0x17) +#define WINDOW_CANCELBUTTON (WINDOW_FIRST + 0x18) +#define WINDOW_HELPBUTTON (WINDOW_FIRST + 0x19) +#define WINDOW_IMAGEBUTTON (WINDOW_FIRST + 0x1a) +#define WINDOW_MENUBUTTON (WINDOW_FIRST + 0x1b) +#define WINDOW_MOREBUTTON (WINDOW_FIRST + 0x1c) +#define WINDOW_SPINBUTTON (WINDOW_FIRST + 0x1d) +#define WINDOW_RADIOBUTTON (WINDOW_FIRST + 0x1e) +#define WINDOW_IMAGERADIOBUTTON (WINDOW_FIRST + 0x1f) +#define WINDOW_CHECKBOX (WINDOW_FIRST + 0x20) +#define WINDOW_TRISTATEBOX (WINDOW_FIRST + 0x21) +#define WINDOW_EDIT (WINDOW_FIRST + 0x22) +#define WINDOW_MULTILINEEDIT (WINDOW_FIRST + 0x23) +#define WINDOW_COMBOBOX (WINDOW_FIRST + 0x24) +#define WINDOW_LISTBOX (WINDOW_FIRST + 0x25) +#define WINDOW_MULTILISTBOX (WINDOW_FIRST + 0x26) +#define WINDOW_FIXEDTEXT (WINDOW_FIRST + 0x27) +#define WINDOW_FIXEDLINE (WINDOW_FIRST + 0x28) +#define WINDOW_FIXEDBITMAP (WINDOW_FIRST + 0x29) +#define WINDOW_FIXEDIMAGE (WINDOW_FIRST + 0x2a) +#define WINDOW_GROUPBOX (WINDOW_FIRST + 0x2c) +#define WINDOW_SCROLLBAR (WINDOW_FIRST + 0x2d) +#define WINDOW_SCROLLBARBOX (WINDOW_FIRST + 0x2e) +#define WINDOW_SPLITTER (WINDOW_FIRST + 0x2f) +#define WINDOW_SPLITWINDOW (WINDOW_FIRST + 0x30) +#define WINDOW_SPINFIELD (WINDOW_FIRST + 0x31) +#define WINDOW_PATTERNFIELD (WINDOW_FIRST + 0x32) +#define WINDOW_NUMERICFIELD (WINDOW_FIRST + 0x33) +#define WINDOW_METRICFIELD (WINDOW_FIRST + 0x34) +#define WINDOW_CURRENCYFIELD (WINDOW_FIRST + 0x35) +#define WINDOW_DATEFIELD (WINDOW_FIRST + 0x36) +#define WINDOW_TIMEFIELD (WINDOW_FIRST + 0x37) +#define WINDOW_PATTERNBOX (WINDOW_FIRST + 0x38) +#define WINDOW_NUMERICBOX (WINDOW_FIRST + 0x39) +#define WINDOW_METRICBOX (WINDOW_FIRST + 0x3a) +#define WINDOW_CURRENCYBOX (WINDOW_FIRST + 0x3b) +#define WINDOW_DATEBOX (WINDOW_FIRST + 0x3c) +#define WINDOW_TIMEBOX (WINDOW_FIRST + 0x3d) +#define WINDOW_LONGCURRENCYFIELD (WINDOW_FIRST + 0x3e) +#define WINDOW_LONGCURRENCYBOX (WINDOW_FIRST + 0x3f) +#define WINDOW_TOOLBOX (WINDOW_FIRST + 0x41) +#define WINDOW_DOCKINGWINDOW (WINDOW_FIRST + 0x42) +#define WINDOW_STATUSBAR (WINDOW_FIRST + 0x43) +#define WINDOW_TABPAGE (WINDOW_FIRST + 0x44) +#define WINDOW_TABCONTROL (WINDOW_FIRST + 0x45) +#define WINDOW_TABDIALOG (WINDOW_FIRST + 0x46) +#define WINDOW_BORDERWINDOW (WINDOW_FIRST + 0x47) +#define WINDOW_BUTTONDIALOG (WINDOW_FIRST + 0x48) +#define WINDOW_SYSTEMCHILDWINDOW (WINDOW_FIRST + 0x49) +#define WINDOW_FIXEDBORDER (WINDOW_FIRST + 0x4a) +#define WINDOW_SLIDER (WINDOW_FIRST + 0x4b) +#define WINDOW_MENUBARWINDOW (WINDOW_FIRST + 0x4c) +#define WINDOW_TREELISTBOX (WINDOW_FIRST + 0x4d) +#define WINDOW_HELPTEXTWINDOW (WINDOW_FIRST + 0x4e) +#define WINDOW_INTROWINDOW (WINDOW_FIRST + 0x4f) +#define WINDOW_LISTBOXWINDOW (WINDOW_FIRST + 0x50) +#define WINDOW_DOCKINGAREA (WINDOW_FIRST + 0x51) +#define WINDOW_LAST (WINDOW_DOCKINGAREA) + + +// --------------- +// - Window-Bits - +// --------------- + +// By changes you must also change: rsc/vclrsc.hxx +typedef sal_Int64 WinBits; + +// Window-Bits fuer Window +#define WB_CLIPCHILDREN ((WinBits)0x00000001) +#define WB_DIALOGCONTROL ((WinBits)0x00000002) +#define WB_NODIALOGCONTROL ((WinBits)0x00000004) +#define WB_BORDER ((WinBits)0x00000008) +#define WB_NOBORDER ((WinBits)0x00000010) +#define WB_SIZEABLE ((WinBits)0x00000020) +#define WB_3DLOOK ((WinBits)0x00000040) +#define WB_AUTOSIZE ((WinBits)0x00000080) + +// Window-Bits fuer SystemWindows +#define WB_MOVEABLE ((WinBits)0x00000100) +#define WB_ROLLABLE ((WinBits)0x00000200) +#define WB_CLOSEABLE ((WinBits)0x00000400) +#define WB_STANDALONE ((WinBits)0x00000800) +#define WB_APP ((WinBits)0x00001000) +#define WB_PINABLE ((WinBits)0x00002000) +#define WB_SYSTEMWINDOW ((WinBits)SAL_CONST_INT64(0x40000000)) +// warning: do not confuse WB_SYSTEMCHILDWINDOW with the SystemChildWindow class + +// the SystemChildWindow class was there first and is a very specialized +// sytem child window type for plugged applications. The SystemChildWindow class +// explicitly should never use the WB_SYSTEMCHILDWINDOW WinBit + +// WB_SYSTEMCHILDWINDOW on the other hand is to be used on system windows +// which should be created as system child windows with (more or less) +// normal event handling +#define WB_SYSTEMCHILDWINDOW ((WinBits)SAL_CONST_INT64(0x8000000000)) +#define WB_SIZEMOVE (WB_SIZEABLE | WB_MOVEABLE) + +// Standard-Window-Bits fuer ChildWindows +#define WB_TABSTOP ((WinBits)0x00000100) +#define WB_NOTABSTOP ((WinBits)0x00000200) +#define WB_GROUP ((WinBits)0x00000400) +#define WB_NOGROUP ((WinBits)0x00000800) +#define WB_HORZ ((WinBits)0x00001000) +#define WB_VERT ((WinBits)0x00002000) +#define WB_LEFT ((WinBits)0x00004000) +#define WB_CENTER ((WinBits)0x00008000) +#define WB_RIGHT ((WinBits)0x00010000) +#define WB_TOP ((WinBits)0x00020000) +#define WB_VCENTER ((WinBits)0x00040000) +#define WB_BOTTOM ((WinBits)0x00080000) +#define WB_DRAG ((WinBits)0x00100000) +#define WB_SPIN ((WinBits)0x00200000) +#define WB_REPEAT ((WinBits)0x00400000) +#define WB_NOPOINTERFOCUS ((WinBits)0x00800000) +#define WB_WORDBREAK ((WinBits)0x01000000) +#define WB_NOLABEL ((WinBits)0x02000000) +#define WB_SORT ((WinBits)0x04000000) +#define WB_DROPDOWN ((WinBits)0x08000000) +#define WB_HIDE ((WinBits)SAL_CONST_INT64(0x80000000)) +#define WB_AUTOHSCROLL ((WinBits)SAL_CONST_INT64(0x10000000)) +#define WB_DOCKABLE ((WinBits)SAL_CONST_INT64(0x20000000)) +#define WB_AUTOVSCROLL ((WinBits)SAL_CONST_INT64(0x40000000)) +#define WB_HYPHENATION (((WinBits)SAL_CONST_INT64(0x800000000)) | WB_WORDBREAK) +#define WB_CHILDDLGCTRL ((WinBits)SAL_CONST_INT64(0x100000000000)) + +// system floating window +#define WB_SYSTEMFLOATWIN ((WinBits)SAL_CONST_INT64(0x100000000)) +#define WB_INTROWIN ((WinBits)SAL_CONST_INT64(0x200000000)) +#define WB_NOSHADOW ((WinBits)SAL_CONST_INT64(0x400000000)) +#define WB_TOOLTIPWIN ((WinBits)SAL_CONST_INT64(0x800000000)) +#define WB_OWNERDRAWDECORATION ((WinBits)SAL_CONST_INT64(0x2000000000)) +#define WB_DEFAULTWIN ((WinBits)SAL_CONST_INT64(0x4000000000)) +#define WB_NEEDSFOCUS ((WinBits)SAL_CONST_INT64(0x1000000000)) + +#define WB_HSCROLL WB_HORZ +#define WB_VSCROLL WB_VERT +#define WB_TOPIMAGE WB_TOP + +// Window-Bits for PushButtons +#define WB_DEFBUTTON ((WinBits)0x10000000) +#define WB_NOLIGHTBORDER ((WinBits)0x20000000) +#define WB_RECTSTYLE ((WinBits)0x08000000) +#define WB_SMALLSTYLE ((WinBits)0x04000000) +#define WB_TOGGLE ((WinBits)SAL_CONST_INT64(0x1000000000)) +#define WB_BEVELBUTTON ((WinBits)SAL_CONST_INT64(0x2000000000)) +#define WB_FLATBUTTON ((WinBits)SAL_CONST_INT64(0x4000000000)) + +// Window-Bits for FixedText +#define WB_PATHELLIPSIS ((WinBits)0x00100000) +#define WB_EXTRAOFFSET ((WinBits)0x02000000) +#define WB_NOMULTILINE ((WinBits)0x10000000) +#define WB_INFO ((WinBits)0x20000000) + +// Window-Bits for CheckBox +#define WB_CBLINESTYLE ((WinBits)SAL_CONST_INT64(0x2000000000)) +#define WB_EARLYTOGGLE ((WinBits)SAL_CONST_INT64(0x4000000000)) + +// Window-Bits for Edit +#define WB_PASSWORD ((WinBits)0x01000000) +#define WB_READONLY ((WinBits)0x02000000) +#define WB_NOHIDESELECTION ((WinBits)SAL_CONST_INT64(0x1000000000)) +#define WB_FORCECTRLBACKGROUND ((WinBits)0x80000000) + +// Window-Bits for MultiLineEdit +#define WB_IGNORETAB ((WinBits)0x20000000) + +// Window-Bits for ListBox and MultiListBox +#define WB_SIMPLEMODE ((WinBits)0x20000000) + +// Window-Bits for FixedBitmap +#define WB_FAST ((WinBits)0x04000000) +#define WB_SCALE ((WinBits)0x08000000) +#define WB_TOPLEFTVISIBLE ((WinBits)0x10000000) + +// Window-Bits for ToolBox +#define WB_LINESPACING ((WinBits)0x01000000) +#define WB_SCROLL ((WinBits)0x02000000) +#define WB_FORCETABCYCLE ((WinBits)0x04000000) + +// Window-Bits for TabControl +#define WB_SINGLELINE ((WinBits)0x02000000) + +// Window-Bits for DockingWindows +#define WB_DOCKBORDER ((WinBits)0x00001000) + +// Window-Bits for SplitWindow +#define WB_NOSPLITDRAW ((WinBits)0x01000000) +#define WB_FLATSPLITDRAW ((WinBits)0x02000000) + +// Window-Bits for MessageBoxen +#define WB_OK ((WinBits)0x00100000) +#define WB_OK_CANCEL ((WinBits)0x00200000) +#define WB_YES_NO ((WinBits)0x00400000) +#define WB_YES_NO_CANCEL ((WinBits)0x00800000) +#define WB_RETRY_CANCEL ((WinBits)0x01000000) +#define WB_DEF_OK ((WinBits)0x02000000) +#define WB_DEF_CANCEL ((WinBits)0x04000000) +#define WB_DEF_RETRY ((WinBits)0x08000000) +#define WB_DEF_YES ((WinBits)SAL_CONST_INT64(0x10000000)) +#define WB_DEF_NO ((WinBits)SAL_CONST_INT64(0x20000000)) +#define WB_ABORT_RETRY_IGNORE ((WinBits)SAL_CONST_INT64(0x1000000000)) +#define WB_DEF_IGNORE ((WinBits)SAL_CONST_INT64(0x2000000000)) + +// Standard-WinBits +#define WB_STDWORK (WB_SIZEMOVE | WB_CLOSEABLE) +#define WB_STDDOCKWIN (WB_DOCKABLE | WB_MOVEABLE | WB_CLOSEABLE) +#define WB_STDFLOATWIN (WB_SIZEMOVE | WB_CLOSEABLE | WB_ROLLABLE) +#define WB_STDDIALOG (WB_MOVEABLE | WB_CLOSEABLE) +#define WB_STDMODELESS (WB_STDDIALOG) +#define WB_STDMODAL (WB_STDDIALOG) +#define WB_STDTABDIALOG (WB_STDDIALOG) +#define WB_STDTABCONTROL 0 + +// For TreeListBox +#define WB_HASBUTTONS ((WinBits)SAL_CONST_INT64(0x000100000000)) +#define WB_HASLINES ((WinBits)SAL_CONST_INT64(0x000200000000)) +#define WB_HASLINESATROOT ((WinBits)SAL_CONST_INT64(0x000400000000)) +#define WB_HASBUTTONSATROOT ((WinBits)SAL_CONST_INT64(0x000800000000)) +#define WB_NOINITIALSELECTION ((WinBits)SAL_CONST_INT64(0x001000000000)) +#define WB_HIDESELECTION ((WinBits)SAL_CONST_INT64(0x002000000000)) +#define WB_FORCE_MAKEVISIBLE ((WinBits)SAL_CONST_INT64(0x004000000000)) +// DO NOT USE: 0x008000000000, that's WB_SYSTEMCHILDWINDOW +#define WB_QUICK_SEARCH ((WinBits)SAL_CONST_INT64(0x010000000000)) + + +// For FileOpen Dialog +#define WB_PATH ((WinBits)0x00100000) +#define WB_OPEN ((WinBits)0x00200000) +#define WB_SAVEAS ((WinBits)0x00400000) + +// For Slider +// Window-Bits for TabControl +#define WB_SLIDERSET ((WinBits)0x02000000) + + +// -------------------- +// - extended WinBits - +// -------------------- +#define WB_EXT_DOCUMENT ((WinBits)0x00000001) +#define WB_EXT_DOCMODIFIED ((WinBits)0x00000002) + +// --------------- +// - WindowAlign - +// --------------- + +// By changes you must also change: rsc/vclrsc.hxx +enum WindowAlign { WINDOWALIGN_LEFT, WINDOWALIGN_TOP, WINDOWALIGN_RIGHT, WINDOWALIGN_BOTTOM }; +enum ImageAlign { IMAGEALIGN_LEFT, IMAGEALIGN_TOP, IMAGEALIGN_RIGHT, IMAGEALIGN_BOTTOM, + IMAGEALIGN_LEFT_TOP, IMAGEALIGN_LEFT_BOTTOM, IMAGEALIGN_TOP_LEFT, + IMAGEALIGN_TOP_RIGHT, IMAGEALIGN_RIGHT_TOP, IMAGEALIGN_RIGHT_BOTTOM, + IMAGEALIGN_BOTTOM_LEFT, IMAGEALIGN_BOTTOM_RIGHT, IMAGEALIGN_CENTER }; +enum SymbolAlign { SYMBOLALIGN_LEFT, SYMBOLALIGN_RIGHT }; + +// ------------ +// - TriState - +// ------------ + +// By changes you must also change: rsc/vclrsc.hxx +enum TriState { STATE_NOCHECK, STATE_CHECK, STATE_DONTKNOW }; + + +// ---------------------- +// - ButtonDialog-Types - +// ---------------------- + +typedef USHORT StandardButtonType; +#define BUTTON_OK ((StandardButtonType)0) +#define BUTTON_CANCEL ((StandardButtonType)1) +#define BUTTON_YES ((StandardButtonType)2) +#define BUTTON_NO ((StandardButtonType)3) +#define BUTTON_RETRY ((StandardButtonType)4) +#define BUTTON_HELP ((StandardButtonType)5) +#define BUTTON_CLOSE ((StandardButtonType)6) +#define BUTTON_MORE ((StandardButtonType)7) +#define BUTTON_IGNORE ((StandardButtonType)8) +#define BUTTON_ABORT ((StandardButtonType)9) +#define BUTTON_LESS ((StandardButtonType)10) +#define BUTTON_COUNT 11 + +// -------------------------------------------- +// - prominent place for ListBox window types - +// -------------------------------------------- + +enum ProminentEntry { PROMINENT_TOP, PROMINENT_MIDDLE }; + +#endif // _TOOLS_WINTYPES_HXX + diff --git a/tools/inc/tools/wldcrd.hxx b/tools/inc/tools/wldcrd.hxx new file mode 100644 index 000000000000..478566ce9b44 --- /dev/null +++ b/tools/inc/tools/wldcrd.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * 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 _WLDCRD_HXX +#define _WLDCRD_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> +#include <tools/string.hxx> +#include <osl/thread.h> + +// ------------ +// - WildCard - +// ------------ + +class TOOLS_DLLPUBLIC WildCard +{ +private: + ByteString aWildString; + char cSepSymbol; + + USHORT ImpMatch( const char *pWild, const char *pStr ) const; + +public: + WildCard(); + WildCard( const String& rWildCards, + const char cSeparator = '\0' ); + + const String GetWildCard() const { return UniString( aWildString, osl_getThreadTextEncoding()); } + const String operator ()() const { return UniString( aWildString, osl_getThreadTextEncoding()); } + + BOOL Matches( const String& rStr ) const; + + BOOL operator ==( const String& rString ) const + { return Matches( rString ); } + BOOL operator !=( const String& rString ) const + { return !( Matches( rString ) ); } + + WildCard& operator =( const String& rString ); + WildCard& operator =( const WildCard& rWildCard ); +}; + +inline WildCard::WildCard() : + aWildString( '*' ) +{ + cSepSymbol = '\0'; +} + +inline WildCard::WildCard( const String& rWildCard, const char cSeparator ) : + aWildString( rWildCard, osl_getThreadTextEncoding()) +{ + cSepSymbol = cSeparator; +} + +inline WildCard& WildCard::operator=( const String& rString ) +{ + aWildString = ByteString(rString, osl_getThreadTextEncoding()); + return *this; +} + +inline WildCard& WildCard::operator=( const WildCard& rWildCard ) +{ + aWildString = rWildCard.aWildString; + cSepSymbol = rWildCard.cSepSymbol; + return *this; +} + +#endif diff --git a/tools/inc/tools/zcodec.hxx b/tools/inc/tools/zcodec.hxx new file mode 100644 index 000000000000..430caa363663 --- /dev/null +++ b/tools/inc/tools/zcodec.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * 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 _ZCODEC_HXX +#define _ZCODEC_HXX + +#include "tools/toolsdllapi.h" +#include <tools/solar.h> + +// ----------- +// - Defines - +// ----------- + +#define DEFAULT_IN_BUFSIZE (0x00008000UL) +#define DEFAULT_OUT_BUFSIZE (0x00008000UL) + +#define MAX_MEM_USAGE 8 + +// +// memory requirement using compress: +// [ INBUFFER ] + [ OUTBUFFER ] + 128KB + 1 << (MEM_USAGE+9) +// +// memory requirement using decompress: +// [ INBUFFER ] + [ OUTBUFFER ] + 32KB +// + +#define ZCODEC_NO_COMPRESSION (0x00000000UL) +#define ZCODEC_BEST_SPEED (0x00000001UL) +#define ZCODEC_DEFAULT_COMPRESSION (0x00000006UL) +#define ZCODEC_BEST_COMPRESSION (0x00000009UL) + +#define ZCODEC_DEFAULT_STRATEGY (0x00000000UL) +#define ZCODEC_ZFILTERED (0x00000100UL) +#define ZCODEC_ZHUFFMAN_ONLY (0x00000200UL) + +#define ZCODEC_UPDATE_CRC (0x00010000UL) +#define ZCODEC_GZ_LIB (0x00020000UL) + +#define ZCODEC_PNG_DEFAULT ( ZCODEC_NO_COMPRESSION | ZCODEC_DEFAULT_STRATEGY | ZCODEC_UPDATE_CRC ) +#define ZCODEC_DEFAULT ( ZCODEC_DEFAULT_COMPRESSION | ZCODEC_DEFAULT_STRATEGY ) + +// ---------- +// - ZCodec - +// ---------- + +class SvStream; + +class TOOLS_DLLPUBLIC ZCodec +{ +private: + + ULONG mbInit; + BOOL mbStatus; + BOOL mbFinish; + ULONG mnMemUsage; + SvStream* mpIStm; + BYTE* mpInBuf; + ULONG mnInBufSize; + ULONG mnInToRead; + SvStream* mpOStm; + BYTE* mpOutBuf; + ULONG mnOutBufSize; + + ULONG mnCRC; + ULONG mnCompressMethod; + void* mpsC_Stream; + + void ImplInitBuf( BOOL nIOFlag ); + void ImplWriteBack( void ); + +public: + ZCodec( ULONG nInBuf, ULONG nOutBuf, ULONG nMemUsage = MAX_MEM_USAGE ); + ZCodec( void ); + virtual ~ZCodec(); + + virtual void BeginCompression( ULONG nCompressMethod = ZCODEC_DEFAULT ); + virtual long EndCompression(); + BOOL IsFinished () const { return mbFinish; } + + long Compress( SvStream& rIStm, SvStream& rOStm ); + long Decompress( SvStream& rIStm, SvStream& rOStm ); + + long Write( SvStream& rOStm, const BYTE* pData, ULONG nSize ); + long Read( SvStream& rIStm, BYTE* pData, ULONG nSize ); + long ReadAsynchron( SvStream& rIStm, BYTE* pData, ULONG nSize ); + + void SetBreak( ULONG ); + ULONG GetBreak( void ); + void SetCRC( ULONG nCurrentCRC ); + ULONG UpdateCRC( ULONG nLatestCRC, ULONG nSource ); + ULONG UpdateCRC( ULONG nLatestCRC, BYTE* pSource, long nDatSize ); + ULONG GetCRC(); +}; + +class GZCodec : public ZCodec +{ + +public: + GZCodec(){}; + ~GZCodec(){}; + virtual void BeginCompression( ULONG nCompressMethod = ZCODEC_DEFAULT ); +}; + +#endif // _ZCODEC_HXX diff --git a/tools/inc/toolsin.hxx b/tools/inc/toolsin.hxx new file mode 100644 index 000000000000..7259682c9895 --- /dev/null +++ b/tools/inc/toolsin.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * 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 _TOOLSIN_HXX +#define _TOOLSIN_HXX + +#include <tools/tools.h> + +struct ImplRegisterLanguageData; +struct ImplRegisterFormatData; +struct Impl1ByteUnicodeTabData; +struct Impl1ByteConvertTabData; + +// -------------- +// - TOOLSNDATA - +// -------------- + +struct TOOLSINDATA +{ + ImplRegisterLanguageData* mpFirstLangData; + ImplRegisterFormatData* mpFirstFormatData; + Impl1ByteUnicodeTabData* mpFirstUniTabData; + Impl1ByteConvertTabData* mpFirstConvertTabData; +}; + +TOOLSINDATA* ImplGetToolsInData(); + +#endif // _TOOLSIN_HXX |