diff options
Diffstat (limited to 'xml2cmp/source/support')
-rw-r--r-- | xml2cmp/source/support/badcast.cxx | 45 | ||||
-rw-r--r-- | xml2cmp/source/support/cmdline.cxx | 222 | ||||
-rw-r--r-- | xml2cmp/source/support/cmdline.hxx | 86 | ||||
-rw-r--r-- | xml2cmp/source/support/heap.cxx | 207 | ||||
-rw-r--r-- | xml2cmp/source/support/heap.hxx | 91 | ||||
-rw-r--r-- | xml2cmp/source/support/list.hxx | 251 | ||||
-rw-r--r-- | xml2cmp/source/support/makefile.mk | 61 | ||||
-rw-r--r-- | xml2cmp/source/support/sistr.cxx | 400 | ||||
-rw-r--r-- | xml2cmp/source/support/sistr.hxx | 148 | ||||
-rw-r--r-- | xml2cmp/source/support/syshelp.cxx | 314 | ||||
-rw-r--r-- | xml2cmp/source/support/syshelp.hxx | 85 |
11 files changed, 1910 insertions, 0 deletions
diff --git a/xml2cmp/source/support/badcast.cxx b/xml2cmp/source/support/badcast.cxx new file mode 100644 index 000000000000..f36d9875b52c --- /dev/null +++ b/xml2cmp/source/support/badcast.cxx @@ -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. + * + ************************************************************************/ + + + +/* Include this for instantiating bad-cast, + due to problems with WNT-STL-headers. +*/ + +#if defined(WNT) && !defined(__MINGW32__) + +#define _NTSDK +#include<typeinfo> + +_STD_BEGIN +bad_cast G_Dummy_Inst_bad_cast; +_STD_END +#endif // WNT + + + diff --git a/xml2cmp/source/support/cmdline.cxx b/xml2cmp/source/support/cmdline.cxx new file mode 100644 index 000000000000..c8e10bb141ff --- /dev/null +++ b/xml2cmp/source/support/cmdline.cxx @@ -0,0 +1,222 @@ +/************************************************************************* + * + * 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 "cmdline.hxx" + +#include <ctype.h> +#include <string.h> +#include <stdlib.h> +#include <iostream> + + +char C_sUseText[] = "Use: xml2cmp.exe \n" + " [-func funcFile] \n" + " [-html htmlFile] \n" + " [-types typeFile] \n" + " [-idlpath idlPath] \n" + " Xml_FileName\n" + " or: xml2cmp.exe \n" + " -ix \n" + " sourceDirectory \n" + " outputDirectory \n" + " [-idlpath idlPath] \n" + " tagname [tagname ...]"; + + +char C_sCmdFunc[] = "-func"; +char C_sCmdHtml[] = "-html"; +char C_sCmdType[] = "-types"; +char C_sCmdIndex[] = "-ix"; +char C_sCmdIdlPath[] = "-idlpath"; + + + +bool GetParameter( Simstr & o_rMemory, int & io_nCountArg, int argc, char * argv[] ); + + +CommandLine::CommandLine( int argc, + char * argv[] ) + : bIsOk(true) +{ + bool bDisplayUse = false; + + /* Check command line: */ + if ( argc < 2 ) + bDisplayUse = true; + else if ( argc == 2 && ! isalnum(argv[1][0]) ) + bDisplayUse = true; + else if ( strcmp( argv[1], C_sCmdIndex ) == 0 && argc < 5 ) + bDisplayUse = true; + + if (bDisplayUse) + { + std::cout << C_sUseText << std::endl; + bIsOk = false; + exit(0); + } + + if ( strcmp( argv[1], C_sCmdIndex ) == 0 ) + { + ParseIndexCommand(argc,argv); + } + else + { + ParseSingleFileCommand(argc,argv); + } + + if ( sXmlSourceFile.l() == 0 + && sXmlSourceDirectory.l() == 0 ) + { + bIsOk = false; + } + else if ( sXmlSourceFile.l() > 0 + && sXmlSourceDirectory.l() > 0 ) + { + bIsOk = false; + } + else if ( sIndexFile.l() > 0 + && ( sXmlSourceDirectory.l() == 0 + || aTagsInIndex.size() == 0 + ) + ) + { + bIsOk = false; + } + +} + +CommandLine::~CommandLine() +{ +} + + +const char * +CommandLine::ErrorText() const +{ + static char cOut[] = "Error: Command line was incorrect. Probably there was a flag without\n" + " the corresponding parameter. Or there was no XML-sourcefile specified.\n"; + return cOut; +} + +bool +GetParameter( Simstr & o_pMemory, + int & io_pCountArg, + int argc, + char * argv[] ) +{ + io_pCountArg++; + if( io_pCountArg < argc ) + { + o_pMemory = argv[io_pCountArg]; + return true; + } + return false; +} + + +void +CommandLine::ParseIndexCommand( int argc, + char * argv[] ) +{ + int nCountArg = 1; + bIsOk = GetParameter( + sXmlSourceDirectory, + nCountArg, + argc, + argv ); + if (bIsOk) + bIsOk = GetParameter( + sOutputDirectory, + nCountArg, + argc, + argv ); + if (bIsOk && strcmp( argv[nCountArg+1], C_sCmdIdlPath ) == 0 ) + bIsOk = GetParameter( + sIdlRootPath, + ++nCountArg, + argc, + argv ); + + sIndexFile = sOutputDirectory; +#if defined(WNT) || defined(OS2) + sIndexFile+= "\\xmlindex.html"; +#elif defined(UNX) + sIndexFile+= "/xmlindex.html"; +#endif + + for ( ++nCountArg; nCountArg < argc; ++nCountArg ) + { + Simstr sElementName(argv[nCountArg]); + aTagsInIndex.push_back( sElementName ); + } +} + + +void +CommandLine::ParseSingleFileCommand( int argc, + char * argv[] ) +{ + for ( int nCountArg = 1; nCountArg < argc && bIsOk; ++nCountArg ) + { + if ( strcmp( argv[nCountArg], C_sCmdFunc ) == 0 ) + { + bIsOk = GetParameter( + sFuncFile, + nCountArg, + argc, + argv ); + } + else if ( strcmp( argv[nCountArg], C_sCmdHtml ) == 0 ) + { + bIsOk = GetParameter( + sHtmlFile, + nCountArg, + argc, + argv ); + } + else if ( strcmp( argv[nCountArg], C_sCmdType ) == 0 ) + { + bIsOk = GetParameter( + sTypeInfoFile, + nCountArg, + argc, + argv ); + } + else if ( strcmp( argv[nCountArg], C_sCmdIdlPath ) == 0 ) + { + bIsOk = GetParameter( + sIdlRootPath, + nCountArg, + argc, + argv ); + } + else + { + sXmlSourceFile = argv[nCountArg]; + } + } /* end for */ +} diff --git a/xml2cmp/source/support/cmdline.hxx b/xml2cmp/source/support/cmdline.hxx new file mode 100644 index 000000000000..2faaf3cabe31 --- /dev/null +++ b/xml2cmp/source/support/cmdline.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * 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 X2C_CMDLINE_HXX +#define X2C_CMDLINE_HXX + +#include "sistr.hxx" +#include "list.hxx" + + +class CommandLine +{ + public: + CommandLine( + int i_argc, + char * i_argv[] ); + ~CommandLine(); + + bool IsOk() const { return bIsOk; } + const char * ErrorText() const; + + const char * XmlSrcFile() const { return sXmlSourceFile.str(); } + const char * FuncFile() const { return sFuncFile.str(); } + const char * HtmlFile() const { return sHtmlFile.str(); } + const char * TypeInfoFile() const { return sTypeInfoFile.str(); } + + bool IsIndexCommand() const { return sIndexFile.l() > 0; } + const char * XmlSrcDirectory() const { return sXmlSourceDirectory.str(); } + const char * IndexOutputFile() const { return sIndexFile.str(); } + const char * OutputDirectory() const { return sOutputDirectory.str(); } + const List<Simstr> & + IndexedTags() const { return aTagsInIndex; } + + const char * IdlRootPath() const { return sIdlRootPath.str(); } + + private: + void ParseIndexCommand( + int argc, + char * argv[] ); + void ParseSingleFileCommand( + int argc, + char * argv[] ); + Simstr sXmlSourceFile; + Simstr sFuncFile; + Simstr sHtmlFile; + Simstr sTypeInfoFile; + + Simstr sXmlSourceDirectory; + Simstr sIndexFile; + Simstr sOutputDirectory; + List<Simstr> aTagsInIndex; + + Simstr sIdlRootPath; + + bool bIsOk; +}; + + + + +#endif + diff --git a/xml2cmp/source/support/heap.cxx b/xml2cmp/source/support/heap.cxx new file mode 100644 index 000000000000..74896302bd27 --- /dev/null +++ b/xml2cmp/source/support/heap.cxx @@ -0,0 +1,207 @@ +/************************************************************************* + * + * 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 <string.h> +#include "heap.hxx" + + +#include <iostream> +#include <stdlib.h> +#define AssertionOf(x) {if (!(x)) {std::cerr << "Assertion failed: " << #x << __FILE__ << __LINE__ << std::endl; exit(3); }} + +#ifdef UNX +#define stricmp strcasecmp +#endif + + + +Heap::Heap(unsigned i_nWidth) + : dpColumnsArray(new Column[i_nWidth]), + nColumnsArraySize(i_nWidth), + nActiveColumn(nColumnsArraySize-1) +{ + for ( unsigned i = 0; i < nColumnsArraySize; i++) + { + dpColumnsArray[i] = 0; + } // end for +} + +Heap::~Heap() +{ + for ( unsigned i = 0; i < nColumnsArraySize; i++) + { + HeapItem * & rColumn = dpColumnsArray[i]; + for ( HeapItem * pValue = rColumn; pValue != 0; pValue = rColumn ) + { + rColumn = rColumn->Next(); + delete pValue; + } + } // end for + + delete [] dpColumnsArray; +} + +void +Heap::InsertValue( const char * i_sKey, + const char * i_sValue ) +{ + HeapItem * pSearch1 = 0; + HeapItem * pSearch2 = 0; + HeapItem * pNew = new HeapItem(i_sKey, i_sValue); + + IncColumn(); + pSearch1 = ActiveColumn(); + + if ( pSearch1 != 0 ? *pNew < *pSearch1 : true ) + { + pNew->SetNext( pSearch1 ); + ActiveColumn() = pNew; + + if ( pNew->Next() != 0) + { + AssertionOf( *pNew <= *pNew->Next() ); + } + + return; + } + + do + { + pSearch2 = pSearch1; + pSearch1 = pSearch1->Next(); + + if ( pSearch1 != 0 ? *pNew < *pSearch1 : true ) + { + pNew->SetNext( pSearch1 ); + pSearch2->SetNext(pNew); + + + AssertionOf( *pSearch2 <= *pNew ); + if ( pNew->Next() != 0) + { + AssertionOf( *pNew <= *pNew->Next() ); + } + + } + } while (pSearch2->Next() != pNew); +} + + +Simstr sKey1; +Simstr sValue1; +Simstr sKey2; +Simstr sValue2; +int nCol1 = 0; +int nCol2 = 0; + + +HeapItem * +Heap::ReleaseTop() +{ + unsigned nRetColumn = 0; + HeapItem * ret = dpColumnsArray[0]; + HeapItem * pSearch = 0; + + for ( unsigned i = 1; i < nColumnsArraySize; ++i ) + { + pSearch = dpColumnsArray[i]; + if (pSearch != 0) + { + if ( ret == 0 ? true : *pSearch < *ret) + { + ret = pSearch; + nRetColumn = i; + } + } + } // for + + if (ret != 0) + { + dpColumnsArray[nRetColumn] = ret->Next(); + } + return ret; +} + +void +Heap::IncColumn() +{ + if (++nActiveColumn >= nColumnsArraySize) + nActiveColumn = 0; +} + + + +HeapItem::HeapItem( const char * i_sKey, + const char * i_sValue ) + : sValue(i_sValue), + sKey(i_sKey), + pNext(0) +{ +} + +HeapItem::~HeapItem() +{ +} + +bool +HeapItem::operator<( const HeapItem & i_rOther ) const +{ + int ret = stricmp(sKey.str(), i_rOther.sKey.str()); + if (ret == 0) + ret = strcmp(sKey.str(), i_rOther.sKey.str()); + if (ret == 0) + ret = stricmp(sValue.str(), i_rOther.sValue.str()); + if (ret == 0) + ret = strcmp(sValue.str(), i_rOther.sValue.str()); + return ret < 0; +} + +const Simstr & +HeapItem::Value() const +{ + return sValue; +} + +const Simstr & +HeapItem::Key() const +{ + return sKey; +} + +HeapItem * +HeapItem::Next() const +{ + return pNext; +} + +void +HeapItem::SetNext( HeapItem * i_pNext ) +{ + pNext = i_pNext; +} + + diff --git a/xml2cmp/source/support/heap.hxx b/xml2cmp/source/support/heap.hxx new file mode 100644 index 000000000000..d1d51d8ce640 --- /dev/null +++ b/xml2cmp/source/support/heap.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 X2C_HEAP_HXX +#define X2C_HEAP_HXX + +#include "sistr.hxx" + +class HeapItem; + +class Heap +{ + public: + Heap( + unsigned i_nWidth ); + ~Heap(); + + void InsertValue( + const char * i_sKey, + const char * i_sValue ); + HeapItem * ReleaseTop(); /// @return must be deleted by caller of method. + + private: + typedef HeapItem * Column; + + void IncColumn(); + Column & ActiveColumn() { return dpColumnsArray[nActiveColumn]; } + + Column * dpColumnsArray; + unsigned nColumnsArraySize; + unsigned nActiveColumn; +}; + + +class HeapItem +{ + public: + HeapItem( + const char * i_sKey, + const char * i_sValue ); + ~HeapItem( ); + + bool operator<( + const HeapItem & i_rOther ) const; + bool operator<=( + const HeapItem & i_rOther ) const + { return ! (i_rOther < *this); } + const Simstr & Value() const; + const Simstr & Key() const; + HeapItem * Next() const; + + void SetNext( + HeapItem * i_pNext ); + private: + Simstr sValue; + Simstr sKey; + HeapItem * pNext; +}; + + + + + + +#endif + + diff --git a/xml2cmp/source/support/list.hxx b/xml2cmp/source/support/list.hxx new file mode 100644 index 000000000000..163cd74ece83 --- /dev/null +++ b/xml2cmp/source/support/list.hxx @@ -0,0 +1,251 @@ +/************************************************************************* + * + * 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 __LISTEN_123456__ +#define __LISTEN_123456__ + +#include <string.h> +#include <iostream> +#include <stdlib.h> + +template <class XX> +class List +{ + public : + typedef XX * iterator; + typedef const XX * const_iterator; + + // LIFECYCLE + List(); + virtual ~List() { delete [] inhalt; } + + // OPERATORS + const XX & operator[]( + unsigned n) const + { return elem(n); } + XX & operator[]( + unsigned n) + { return elem(n); } + // OPERATIONS + void reserve( + unsigned i_nSize ) + { alloc(i_nSize,true); } + virtual void insert( + unsigned pos, + const XX & elem ); + void push_back( + const XX & elem_) + { insert(size(),elem_); } + + virtual void remove( + unsigned pos ); + void pop_back() { remove(size()-1); } + void erase_all() { while (size()) remove(size()-1); } + + // INQUIRY + const XX & front() const { return elem(0); } + const XX & back() const { return elem(len-1); } + + unsigned size() const { return len; } + unsigned space() const { return allocated; } + bool is_valid_index( + unsigned n) const + { return n < len; } + // ACCESS + XX & front() { return elem(0); } + XX & back() { return elem(len-1); } + + protected: + void checkSize( + unsigned newLength); + void alloc( + unsigned newSpace, + bool re = false ); + + const XX & elem( + unsigned n ) const + { return inhalt[n]; } + XX & elem( + unsigned n ) + { return inhalt[n]; } + // DATA + XX * inhalt; + unsigned len; + unsigned allocated; + + private: + // forbidden functions + List(const List<XX> & L); + List<XX> & operator=( + const List<XX> & L); + +}; + +template <class XY> +class DynamicList : public List<XY*> +{ + public: + virtual ~DynamicList(); + + virtual void insert( + unsigned pos, + XY * const & elem ); + virtual void remove( + unsigned pos ); +}; + + + +template <class XX> +List<XX>::List() + : inhalt(0), + len(0), + allocated(0) + +{ + alloc(1); +} + + +template <class XX> +void +List<XX>::insert(unsigned pos, const XX & elem_) +{ + if ( pos > len ) + return; + + checkSize(len+2); + for ( unsigned p = len; p > pos; --p) + { + inhalt[p] = inhalt[p-1]; + } + inhalt[pos] = elem_; + len++; +} + + +template <class XX> +void +List<XX>::remove(unsigned pos) +{ + if ( pos >= len ) + return; + len--; + for ( unsigned p = pos; p < len; ++p) + { + inhalt[p] = inhalt[p+1]; + } +} + + +// Protected: +template <class XX> +void +List<XX>::checkSize(unsigned newLength) +{ + // neuen Platzbedarf pruefen: + unsigned newSpace = space(); + if (newLength > newSpace) + { + if (!newSpace) + newSpace = 1; + const unsigned nBorder = 65536 / 2; + while(newLength > newSpace) + { + if (newSpace < nBorder) + newSpace <<= 1; + else + { + std::cerr << "List becomes too big" << std::endl; + exit(1); + } + } + } + + // Veraenderung ?: + if (newSpace != space()) + alloc(newSpace,true); +} + +template <class XX> +void +List<XX>::alloc( unsigned newSpace, + bool re ) +{ + XX * pNew = new XX[newSpace]; + + if (inhalt != 0) + { + if (re) + { + for (unsigned i = 0; i < len; ++i) + { + pNew[i] = inhalt[i]; + } // end for + } + delete [] inhalt; + } + + inhalt = pNew; + allocated = newSpace; +} + + +template <class XY> +DynamicList<XY>::~DynamicList() +{ + this->erase_all(); +} + +template <class XY> +void +DynamicList<XY>::insert(unsigned pos, XY * const & elem_) +{ + if ( pos > this->len ) + return; + + checkSize(this->len+2); + memmove(this->inhalt[pos+1], this->inhalt[pos], (this->len-pos) * sizeof(XY*) ); + this->inhalt[pos] = elem_; + this->len++; +} + +template <class XY> +void +DynamicList<XY>::remove( unsigned pos ) +{ + if (!this->is_valid_index(pos) ) + return; + this->len--; + delete this->inhalt[pos]; + memmove(this->inhalt[pos], this->inhalt[pos+1], (this->len-pos) * sizeof(XY*) ); +} + + + +#endif + diff --git a/xml2cmp/source/support/makefile.mk b/xml2cmp/source/support/makefile.mk new file mode 100644 index 000000000000..8f0abcd5a19c --- /dev/null +++ b/xml2cmp/source/support/makefile.mk @@ -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. +# +#************************************************************************* + +PRJ=..$/.. + +PRJNAME=xml2cmp +TARGET=x2c_support +TARGETTYPE=CUI + + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=TRUE + +.INCLUDE : settings.mk + + + +# --- Files -------------------------------------------------------- + +OBJFILES= \ + $(OBJ)$/cmdline.obj \ + $(OBJ)$/heap.obj \ + $(OBJ)$/sistr.obj \ + $(OBJ)$/syshelp.obj \ + $(OBJ)$/badcast.obj + + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/xml2cmp/source/support/sistr.cxx b/xml2cmp/source/support/sistr.cxx new file mode 100644 index 000000000000..1d506ba0afe3 --- /dev/null +++ b/xml2cmp/source/support/sistr.cxx @@ -0,0 +1,400 @@ +/************************************************************************* + * + * 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 <sistr.hxx> + +// The following two header-files declare +// standard ANSI-C++ functions. They may be replaced +// by the corresponding header-file-names of the +// actually used runtime library. +#include <string.h> // strlen(), memcpy(), memset() +#include <ctype.h> // tolower() +#include <limits.h> // INT_MAX + +#if (_MSC_VER >=1400) +#pragma warning(disable:4365) +#endif + +const char NULCH = '\0'; +const int NO_POS = -1; + + +Simstr::Simstr(const char * str_) +{ + if (str_ == 0) + { + len = 0; + sz = new char[1]; + *sz = 0; + } + else + { + len = strlen(str_); + sz = new char[len+1]; + memcpy(sz,str_,len+1); + } +} + +Simstr::Simstr( const char * anybytes, + int firstBytesPos, + int nrOfBytes) +{ + unsigned slen = strlen(anybytes); + if (anybytes == 0 || slen <= unsigned(firstBytesPos)) + { + len = 0; + sz = new char[1]; + *sz = 0; + } + else + { + int maxLen = slen - unsigned(firstBytesPos); + len = maxLen < nrOfBytes + ? maxLen + : nrOfBytes; + sz = new char[len+1]; + memcpy(sz,anybytes+firstBytesPos,len); + *(sz+len) = 0; + } +} + + +Simstr::Simstr(const Simstr & S) +{ + len = S.len; + sz = new char[len+1]; + memcpy(sz,S.sz,len+1); +} + +Simstr & Simstr::operator=(const Simstr & S) +{ + if (sz == S.sz) + return *this; + + delete [] sz; + + len = S.len; + sz = new char[len+1]; + memcpy(sz,S.sz,len+1); + + return *this; +} + +Simstr::~Simstr() +{ + delete [] sz; +} + +Simstr +Simstr::operator+(const Simstr & S) const +{ + Simstr ret = sz; + ret.push_back(S); + return ret; +} + +Simstr & +Simstr::operator+=(const Simstr & S) +{ + push_back(S); + return *this; +} + + +// REL + +bool +Simstr::operator==(const Simstr & S) const +{ return !strcmp(sz,S.sz) ? true : false; } + +bool +Simstr::operator!=(const Simstr & S) const +{ return strcmp(sz,S.sz) ? true : false; } + +bool +Simstr::operator<(const Simstr & S) const +{ return (strcmp(sz,S.sz) < 0) ? true : false; } + +bool +Simstr::operator>(const Simstr & S) const +{ return (strcmp(sz,S.sz) > 0) ? true : false; } + +bool +Simstr::operator<=(const Simstr & S) const +{ return (strcmp(sz,S.sz) <= 0) ? true : false; } + +bool +Simstr::operator>=(const Simstr & S) const +{ return (strcmp(sz,S.sz) >= 0) ? true : false; } + + + + +// ************** LIST - Funktionen ***************** + +// Insert + +void +Simstr::push_front(char c) +{ + char * result = new char[len+2]; + + result[0] = c; + memcpy(result+1,sz,len+1); + + delete [] sz; + sz = result; + len++; +} + +void +Simstr::push_back(char c) +{ + char * result = new char[len+2]; + + memcpy(result,sz,len); + result[len] = c; + result[len+1] = 0; + + delete [] sz; + sz = result; + len++; +} + +void +Simstr::push_front(const Simstr & S) +{ + char * result = new char[len+1+S.len]; + + memcpy(result,S.sz,S.len); + memcpy(result+S.len,sz,len+1); + + delete [] sz; + sz = result; + len += S.len; +} + +void +Simstr::push_back(const Simstr & S) +{ + char * result = new char[len+1+S.len]; + + memcpy(result,sz,len); + memcpy(result+len,S.sz,S.len+1); + + delete [] sz; + sz = result; + len += S.len; +} + + +// Remove + +void +Simstr::remove(int pos, int anzahl) +{ + if (pos >= len || pos < 0 || anzahl < 1) + return; + + int anz = len - pos < anzahl ? len - pos : anzahl; + + char * result = new char[len-anz+1]; + + memcpy(result,sz,pos); + memcpy(result+pos,sz+pos+anz,len-pos-anz+1); + + delete [] sz; + sz = result; + len -= anz; +} + +void +Simstr::remove_trailing_blanks() +{ + int newlen = len-1; + for ( ; newlen > 1 && sz[newlen] <= 32; --newlen ) {} + + if (newlen < len-1) + remove ( newlen+1, len-newlen); +} + +// Find + +int +Simstr::pos_first(char c) const +{ + int i = 0; + for (i = 0; i < len ? sz[i] != c : false; i++) ; + if (i >= len) + return NO_POS; + else + return i; +} + +int +Simstr::pos_last(char c) const +{ + int i = 0; + for (i = len-1; i >= 0 ? sz[i] != c : false; i--) ; + if (i < 0) + return NO_POS; + else + return i; +} + +bool +Simstr::is_no_text() const +{ + if (!len) + return true; + + int i; + for (i = 0; sz[i] <= 32 && i < len; i++) ; + if (i < len) + return false; + return true; +} + +// Change + +void +Simstr::replace_all(char oldCh, char newCh) +{ + for (int i=0; i < len; i++) + if (sz[i] == oldCh) + sz[i] = newCh; +} + +// Simstr addition +Simstr +operator+(const char * str, const Simstr & S) +{ + Simstr ret = S; + ret.push_front(str); + return ret; +} + +Simstr +operator+(const Simstr & S, const char * str) +{ + Simstr ret = S; + ret.push_back(str); + return ret; +} + +Simstr +operator+(char c, const Simstr & S) +{ + Simstr ret = S; + ret.push_front(c); + return ret; +} + +Simstr +operator+(const Simstr & S, char c) +{ + Simstr ret = S; + ret.push_back(c); + return ret; +} + + +// Simstr-Vergleiche mit char * +bool +operator==(const Simstr & S, const char * str) +{ + return strcmp(S,str) == 0; +} + +bool +operator!=(const Simstr & S, const char * str) +{ + return strcmp(S,str) != 0; +} + +bool +operator<(const Simstr & S, const char * str) +{ + return strcmp(S,str) < 0; +} + +bool +operator>(const Simstr & S, const char * str) +{ + return strcmp(S,str) > 0; +} + +bool +operator<=(const Simstr & S, const char * str) +{ + return strcmp(S,str) <= 0; +} + +bool +operator>=(const Simstr & S, const char * str) +{ + return strcmp(S,str) >= 0; +} + +bool +operator==(const char * str, const Simstr & S) +{ + return strcmp(str,S) == 0; +} + +bool +operator!=(const char * str, const Simstr & S) +{ + return strcmp(str,S) != 0; +} + +bool +operator<(const char * str, const Simstr & S) +{ + return strcmp(str,S) < 0; +} + +bool +operator>(const char * str, const Simstr & S) +{ + return strcmp(str,S) > 0; +} + +bool +operator<=(const char * str, const Simstr & S) +{ + return strcmp(str,S) <= 0; +} + +bool +operator>=(const char * str, const Simstr & S) +{ + return strcmp(str,S) >= 0; +} + + diff --git a/xml2cmp/source/support/sistr.hxx b/xml2cmp/source/support/sistr.hxx new file mode 100644 index 000000000000..7ef22de18f8a --- /dev/null +++ b/xml2cmp/source/support/sistr.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * 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 XML2CMP_SISTR_HXX +#define XML2CMP_SISTR_HXX + + +class Simstr +{ +// INTERFACE + public: + // Constructors, destructor, '=' and typecasts + Simstr( + const char * str = 0); + Simstr( // Creates Simstr out of a copy of the described bytes within 'anyBytes'. + // Adds a '\0' at the end. + const char * anybytes, + int firstBytesPos, + int nrOfBytes); + virtual ~Simstr(); + Simstr( + const Simstr & S); + Simstr & operator=( + const Simstr & S); + operator const char*() const; + + // diverse utility functions + const char * str() const { return sz; } + char * s(); // ATTENTION !!! // Only to be used, when a function needs a 'char*' but + // nevertheless THAT WILL BE NOT CHANGED! + // Typecasts to 'const char*' are performed automatically. + int l() const; // Length of string without '\0' at end. + Simstr operator+( + const Simstr & S) const; + Simstr & operator+=( + const Simstr & S); + + // comparison operators + bool operator==( + const Simstr & S) const; + bool operator!=( + const Simstr & S) const; + bool operator<( + const Simstr & S) const; + bool operator>( + const Simstr & S) const; + bool operator<=( + const Simstr & S) const; + bool operator>=( + const Simstr & S) const; + + + // 'List of characters' - functions + // insert - functions + void push_front( + char c); + void push_back( + char c); + void push_front( + const Simstr & S); + void push_back( + const Simstr & S); + // remove - functions + void remove( + int pos, + int anzahl = 1); + void remove_trailing_blanks(); + + // search functions + int pos_first( + char c) const; + int pos_last( + char c) const; + bool is_empty() const; // Only true if object == "". + bool is_no_text() const; // String may contain spaces or tabs. + + // substitution functions + void replace_all( + char oldCh, + char newCh); + // token functions + // get...-functions return the token, separated by char 'c' and leave the object unchanged. + // take...-functions return the same, but remove the token and the corresponding separator from the object. + Simstr get_last_token( + char c) const; + + private: + char * sz; + int len; +}; + +// Simstr - char* / char - concatenations +Simstr operator+(const char * str, const Simstr & S); +Simstr operator+(const Simstr & S, const char * str); +Simstr operator+(char c, const Simstr & S); +Simstr operator+(const Simstr & S, char c); + +// Simstr - char* - comparison operators +bool operator==(const Simstr & S, const char * str); +bool operator!=(const Simstr & S, const char * str); +bool operator<(const Simstr & S, const char * str); +bool operator>(const Simstr & S, const char * str); +bool operator<=(const Simstr & S, const char * str); +bool operator>=(const Simstr & S, const char * str); +bool operator==(const char * str, const Simstr & S); +bool operator!=(const char * str, const Simstr & S); +bool operator<(const char * str, const Simstr & S); +bool operator>(const char * str, const Simstr & S); +bool operator<=(const char * str, const Simstr & S); +bool operator>=(const char * str, const Simstr & S); + + +inline char * +Simstr::s() { return sz; } +inline int +Simstr::l() const { return len; } +inline +Simstr::operator const char*() const { return sz; } +inline bool +Simstr::is_empty() const { return len == 0; } + + +#endif + diff --git a/xml2cmp/source/support/syshelp.cxx b/xml2cmp/source/support/syshelp.cxx new file mode 100644 index 000000000000..4eb742030048 --- /dev/null +++ b/xml2cmp/source/support/syshelp.cxx @@ -0,0 +1,314 @@ +/************************************************************************* + * + * 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 <syshelp.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <string.h> +#include "sistr.hxx" +#include "list.hxx" + +#ifdef WNT +#include <io.h> +#elif defined(UNX) || defined(OS2) +#include <sys/types.h> +#include <sys/stat.h> +#include <dirent.h> +#define stricmp strcasecmp +#else +#error Must run under unix or windows, please define UNX or WNT. +#endif + + +char C_sSpaceInName[] = " "; + +void +WriteName( std::ostream & o_rFile, + const Simstr & i_rIdlDocuBaseDir, + const Simstr & i_rName, + E_LinkType i_eLinkType ) +{ + if (i_rName.l() == 0) + return; + + + const char * pNameEnd = strstr( i_rName.str(), " in " ); + + // No link: + if ( i_eLinkType == lt_nolink ) + { + if ( pNameEnd != 0 ) + { + const char * pStart = i_rName.str(); + o_rFile.write( pStart, pNameEnd - pStart ); + WriteStr( o_rFile, C_sSpaceInName ); + WriteStr( o_rFile, pNameEnd ); + } + else + { + WriteStr( o_rFile, i_rName ); + } + return; + } + + if ( i_eLinkType == lt_idl ) + { + Simstr sPath(i_rName); + sPath.replace_all('.','/'); + int nNameEnd = sPath.pos_first(' '); + int nPathStart = sPath.pos_last(' '); + WriteStr( o_rFile, "<A HREF=\"" ); + + if ( nNameEnd > -1 ) + { + WriteStr( o_rFile, "file:///" ); + WriteStr( o_rFile, i_rIdlDocuBaseDir ); + WriteStr( o_rFile, "/" ); + WriteStr( o_rFile, sPath.str() + 1 + nPathStart ); + WriteStr( o_rFile, "/" ); + o_rFile.write( sPath.str(), nNameEnd ); + WriteStr( o_rFile, ".html\">" ); + } + else + { // Should not be reached: + WriteStr(o_rFile, i_rName); + return; + } + } + else if ( i_eLinkType == lt_html ) + { + int nKomma = i_rName.pos_first(','); + int nEnd = i_rName.pos_first(' '); + if ( nKomma > -1 ) + { + o_rFile.write( i_rName.str(), nKomma ); + WriteStr( o_rFile, ": " ); + + WriteStr( o_rFile, "<A HREF=\"" ); + + o_rFile.write( i_rName.str(), nKomma ); + WriteStr( o_rFile, ".html#" ); + if ( nEnd > -1 ) + o_rFile.write( i_rName.str() + nKomma + 1, nEnd - nKomma ); + else + WriteStr( o_rFile, i_rName.str() + nKomma + 1 ); + WriteStr( o_rFile, "\">" ); + + o_rFile.write( i_rName.str() + nKomma + 1, nEnd - nKomma ); + } + else + { + WriteStr( o_rFile, "<A HREF=\"" ); + WriteStr( o_rFile, i_rName ); + WriteStr( o_rFile, ".html\">" ); + + WriteStr( o_rFile, i_rName ); + } + WriteStr( o_rFile, "</A>" ); + return; + } + + if ( pNameEnd != 0 ) + { + const char * pStart = i_rName.str(); + if ( pNameEnd > pStart ) + o_rFile.write( pStart, pNameEnd - pStart ); + WriteStr( o_rFile, "</A>" ); + + WriteStr( o_rFile, C_sSpaceInName ); + WriteStr( o_rFile, pNameEnd ); + } + else + { + WriteStr( o_rFile, i_rName ); + WriteStr( o_rFile, "</A>" ); + } +} + + +void +WriteStr( std::ostream & o_rFile, + const char * i_sStr ) +{ + o_rFile.write( i_sStr, (int) strlen(i_sStr) ); +} + +void +WriteStr( std::ostream & o_rFile, + const Simstr & i_sStr ) +{ + o_rFile.write( i_sStr.str(), i_sStr.l() ); +} + + +const char C_sXML_END[] = "\\*.xml"; + +void +GatherFileNames( List<Simstr> & o_sFiles, + const char * i_sSrcDirectory ) +{ + static int nAliveCounter = 0; + + char * sNextDir = 0; + Simstr sNew = 0; + +#ifdef WNT + struct _finddata_t aEntry; + long hFile = 0; + int bFindMore = 0; + char * sFilter = new char[ strlen(i_sSrcDirectory) + sizeof C_sXML_END ]; + + // Stayingalive sign + if (++nAliveCounter % 100 == 1) + std::cout << "." << std::flush; + + strcpy(sFilter, i_sSrcDirectory); // STRCPY SAFE HERE + strcat(sFilter,C_sXML_END); // STRCAT SAFE HERE + + hFile = _findfirst( sFilter, &aEntry ); + for ( bFindMore = hFile == -1; + bFindMore == 0; + bFindMore = _findnext( hFile, &aEntry ) ) + { + sNew = i_sSrcDirectory; + sNew += "\\"; + sNew += aEntry.name; + o_sFiles.push_back(sNew); + } // end for + + _findclose(hFile); + delete [] sFilter; +#elif defined(UNX) || defined(OS2) + DIR * pDir = opendir( i_sSrcDirectory ); + dirent * pEntry = 0; + char * sEnding; + + // Stayingalive sign + if (++nAliveCounter % 100 == 1) + std::cout << "." << std::flush; + + while ( (pEntry = readdir(pDir)) != 0 ) + { + sEnding = strrchr(pEntry->d_name,'.'); + if (sEnding != 0 ? stricmp(sEnding,".xml") == 0 : 0 ) + { + sNew = i_sSrcDirectory; + sNew += "/"; + sNew += pEntry->d_name; + o_sFiles.push_back(sNew); + } + } // end while + + closedir( pDir ); +#else +#error Must run on unix or windows, please define UNX or WNT. +#endif + + // gathering from subdirectories: + List<Simstr> aSubDirectories; + GatherSubDirectories( aSubDirectories, i_sSrcDirectory ); + + unsigned d_max = aSubDirectories.size(); + for ( unsigned d = 0; d < d_max; ++d ) + { + sNextDir = new char[ strlen(i_sSrcDirectory) + 2 + aSubDirectories[d].l() ]; + + strcpy(sNextDir, i_sSrcDirectory); + strcat(sNextDir, C_sSLASH); + strcat(sNextDir, aSubDirectories[d].str()); + GatherFileNames(o_sFiles, sNextDir); + + delete [] sNextDir; + } +} + + +const char * C_sANYDIR = "\\*.*"; + +void +GatherSubDirectories( List<Simstr> & o_sSubDirectories, + const char * i_sParentdDirectory ) +{ + Simstr sNew; + +#ifdef WNT + struct _finddata_t aEntry; + long hFile = 0; + int bFindMore = 0; + char * sFilter = new char[strlen(i_sParentdDirectory) + sizeof C_sANYDIR]; + + strcpy(sFilter, i_sParentdDirectory); + strcat(sFilter,C_sANYDIR); + + hFile = _findfirst( sFilter, &aEntry ); + for ( bFindMore = hFile == -1; + bFindMore == 0; + bFindMore = _findnext( hFile, &aEntry ) ) + { + if (aEntry.attrib == _A_SUBDIR) + { + // Do not gather . .. and outputtree directories + if ( strchr(aEntry.name,'.') == 0 + && strncmp(aEntry.name, "wnt", 3) != 0 + && strncmp(aEntry.name, "unx", 3) != 0 ) + { + sNew = aEntry.name; + o_sSubDirectories.push_back(sNew); + } + } // endif (aEntry.attrib == _A_SUBDIR) + } // end for + _findclose(hFile); + delete [] sFilter; + +#elif defined(UNX) || defined(OS2) + DIR * pDir = opendir( i_sParentdDirectory ); + dirent * pEntry = 0; + struct stat aEntryStatus; + + while ( ( pEntry = readdir(pDir) ) != 0 ) + { + stat(pEntry->d_name, &aEntryStatus); + if ( ( aEntryStatus.st_mode & S_IFDIR ) == S_IFDIR ) + { + // Do not gather . .. and outputtree directories + if ( strchr(pEntry->d_name,'.') == 0 + && strncmp(pEntry->d_name, "wnt", 3) != 0 + && strncmp(pEntry->d_name, "unx", 3) != 0 ) + { + sNew = pEntry->d_name; + o_sSubDirectories.push_back(sNew); + } + } // endif (aEntry.attrib == _A_SUBDIR) + } // end while + closedir( pDir ); +#else +#error Must run on unix or windows, please define UNX or WNT. +#endif +} + diff --git a/xml2cmp/source/support/syshelp.hxx b/xml2cmp/source/support/syshelp.hxx new file mode 100644 index 000000000000..bd380ccc1bb3 --- /dev/null +++ b/xml2cmp/source/support/syshelp.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * 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 X2C_SYSHELP_HXX +#define X2C_SYSHELP_HXX + + + +// USED SERVICES + // BASE CLASSES + // COMPONENTS + // PARAMETERS +#include <iosfwd> + +class Simstr; +template <class XY> class List; + + +#if defined(WNT) || defined(OS2) +const char C_sSLASH[] = "\\"; +const char C_cSLASH = '\\'; +#elif defined(UNX) +const char C_sSLASH[] = "/"; +const char C_cSLASH = '/'; +#else +#error Must run under unix or windows, please define UNX or WNT. +#endif + +enum E_LinkType +{ + lt_nolink = 0, + lt_idl, + lt_html +}; + + +void WriteName( + std::ostream & o_rFile, + const Simstr & i_rIdlDocuBaseDir, + const Simstr & i_rName, + E_LinkType i_eLinkType ); + + +void WriteStr( + std::ostream & o_rFile, + const char * i_sStr ); +void WriteStr( + std::ostream & o_rFile, + const Simstr & i_sStr ); + +void GatherFileNames( + List<Simstr> & o_sFiles, + const char * i_sSrcDirectory ); +void GatherSubDirectories( + List<Simstr> & o_sSubDirectories, + const char * i_sParentdDirectory ); + + + +#endif + |