diff options
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/expatwrap/attrlistimpl.cxx | 15 | ||||
-rw-r--r-- | sax/source/expatwrap/attrlistimpl.hxx | 3 | ||||
-rw-r--r-- | sax/source/expatwrap/factory.hxx | 2 | ||||
-rw-r--r-- | sax/source/expatwrap/sax_expat.cxx | 64 | ||||
-rw-r--r-- | sax/source/expatwrap/saxwriter.cxx | 29 | ||||
-rw-r--r-- | sax/source/expatwrap/xml2utf.cxx | 6 | ||||
-rw-r--r-- | sax/source/fastparser/facreg.cxx | 3 | ||||
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 11 | ||||
-rw-r--r-- | sax/source/fastparser/fastparser.hxx | 7 | ||||
-rw-r--r-- | sax/source/tools/converter.cxx | 211 | ||||
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 7 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 152 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 59 | ||||
-rw-r--r-- | sax/source/tools/fshelper.cxx | 12 |
14 files changed, 294 insertions, 287 deletions
diff --git a/sax/source/expatwrap/attrlistimpl.cxx b/sax/source/expatwrap/attrlistimpl.cxx index 114eb653f648..f7ec5d16f664 100644 --- a/sax/source/expatwrap/attrlistimpl.cxx +++ b/sax/source/expatwrap/attrlistimpl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -111,8 +112,10 @@ OUString AttributeList::getTypeByName( const OUString& sName ) throw (RuntimeExc { vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin(); - for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { - if( (*ii).sName == sName ) { + for (; ii != m_pImpl->vecAttribute.end(); ++ii ) + { + if( (*ii).sName == sName ) + { return (*ii).sType; } } @@ -123,8 +126,10 @@ OUString AttributeList::getValueByName(const OUString& sName) throw (RuntimeExce { vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin(); - for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { - if( (*ii).sName == sName ) { + for (; ii != m_pImpl->vecAttribute.end(); ++ii) + { + if( (*ii).sName == sName ) + { return (*ii).sValue; } } @@ -166,3 +171,5 @@ void AttributeList::clear() } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/attrlistimpl.hxx b/sax/source/expatwrap/attrlistimpl.hxx index aaf6cf84b359..870f4dd258ac 100644 --- a/sax/source/expatwrap/attrlistimpl.hxx +++ b/sax/source/expatwrap/attrlistimpl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,7 +30,6 @@ #define _SAX_ATTRLISTIMPL_HXX #include "sal/config.h" -//#include "sax/saxdllapi.h" #include <cppuhelper/implbase2.hxx> @@ -83,3 +83,4 @@ private: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/factory.hxx b/sax/source/expatwrap/factory.hxx index c6a566781044..169788a02bfe 100644 --- a/sax/source/expatwrap/factory.hxx +++ b/sax/source/expatwrap/factory.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,3 +33,4 @@ OUString SaxWriter_getImplementationName() throw(); Sequence< OUString > SaxWriter_getSupportedServiceNames(void) throw(); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index aaaac6bd564e..114d29bea648 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -466,7 +467,7 @@ void SaxExpatParser::parseStream( const InputSource& structSource) if( ! entity.structSource.aInputStream.is() ) { - throw SAXException( OUString::createFromAscii( "No input source" ) , + throw SAXException( OUString(RTL_CONSTASCII_USTRINGPARAM("No input source")) , Reference< XInterface > () , Any() ); } @@ -481,7 +482,7 @@ void SaxExpatParser::parseStream( const InputSource& structSource) entity.pParser = XML_ParserCreate( 0 ); if( ! entity.pParser ) { - throw SAXException( OUString::createFromAscii( "Couldn't create parser" ) , + throw SAXException( OUString(RTL_CONSTASCII_USTRINGPARAM("Couldn't create parser")) , Reference< XInterface > (), Any() ); } @@ -595,7 +596,7 @@ void SaxExpatParser::setLocale( const Locale & locale ) throw (RuntimeException) // XServiceInfo OUString SaxExpatParser::getImplementationName() throw () { - return OUString::createFromAscii( IMPLEMENTATION_NAME ); + return OUString(RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME )); } // XServiceInfo @@ -616,7 +617,7 @@ Sequence< OUString > SaxExpatParser::getSupportedServiceNames(void) throw () { Sequence<OUString> seq(1); - seq.getArray()[0] = OUString::createFromAscii( SERVICE_NAME ); + seq.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME )); return seq; } @@ -631,82 +632,82 @@ OUString getErrorMessage( XML_Error xmlE, OUString sSystemId , sal_Int32 nLine ) { OUString Message; if( XML_ERROR_NONE == xmlE ) { - Message = OUString::createFromAscii( "No" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("No")); } else if( XML_ERROR_NO_MEMORY == xmlE ) { - Message = OUString::createFromAscii( "no memory" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("no memory")); } else if( XML_ERROR_SYNTAX == xmlE ) { - Message = OUString::createFromAscii( "syntax" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("syntax")); } else if( XML_ERROR_NO_ELEMENTS == xmlE ) { - Message = OUString::createFromAscii( "no elements" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("no elements")); } else if( XML_ERROR_INVALID_TOKEN == xmlE ) { - Message = OUString::createFromAscii( "invalid token" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("invalid token")); } else if( XML_ERROR_UNCLOSED_TOKEN == xmlE ) { - Message = OUString::createFromAscii( "unclosed token" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("unclosed token")); } else if( XML_ERROR_PARTIAL_CHAR == xmlE ) { - Message = OUString::createFromAscii( "partial char" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("partial char")); } else if( XML_ERROR_TAG_MISMATCH == xmlE ) { - Message = OUString::createFromAscii( "tag mismatch" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("tag mismatch")); } else if( XML_ERROR_DUPLICATE_ATTRIBUTE == xmlE ) { - Message = OUString::createFromAscii( "duplicate attribute" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("duplicate attribute")); } else if( XML_ERROR_JUNK_AFTER_DOC_ELEMENT == xmlE ) { - Message = OUString::createFromAscii( "junk after doc element" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("junk after doc element")); } else if( XML_ERROR_PARAM_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "parameter entity reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("parameter entity reference")); } else if( XML_ERROR_UNDEFINED_ENTITY == xmlE ) { - Message = OUString::createFromAscii( "undefined entity" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("undefined entity")); } else if( XML_ERROR_RECURSIVE_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "recursive entity reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("recursive entity reference")); } else if( XML_ERROR_ASYNC_ENTITY == xmlE ) { - Message = OUString::createFromAscii( "async entity" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("async entity")); } else if( XML_ERROR_BAD_CHAR_REF == xmlE ) { - Message = OUString::createFromAscii( "bad char reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("bad char reference")); } else if( XML_ERROR_BINARY_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "binary entity reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("binary entity reference")); } else if( XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF == xmlE ) { - Message = OUString::createFromAscii( "attribute external entity reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("attribute external entity reference")); } else if( XML_ERROR_MISPLACED_XML_PI == xmlE ) { - Message = OUString::createFromAscii( "misplaced xml processing instruction" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("misplaced xml processing instruction")); } else if( XML_ERROR_UNKNOWN_ENCODING == xmlE ) { - Message = OUString::createFromAscii( "unknown encoding" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("unknown encoding")); } else if( XML_ERROR_INCORRECT_ENCODING == xmlE ) { - Message = OUString::createFromAscii( "incorrect encoding" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("incorrect encoding")); } else if( XML_ERROR_UNCLOSED_CDATA_SECTION == xmlE ) { - Message = OUString::createFromAscii( "unclosed cdata section" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("unclosed cdata section")); } else if( XML_ERROR_EXTERNAL_ENTITY_HANDLING == xmlE ) { - Message = OUString::createFromAscii( "external entity reference" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("external entity reference")); } else if( XML_ERROR_NOT_STANDALONE == xmlE ) { - Message = OUString::createFromAscii( "not standalone" ); + Message = OUString(RTL_CONSTASCII_USTRINGPARAM("not standalone")); } - OUString str = OUString::createFromAscii( "[" ); + OUString str(RTL_CONSTASCII_USTRINGPARAM("[")); str += sSystemId; - str += OUString::createFromAscii( " line " ); + str += OUString(RTL_CONSTASCII_USTRINGPARAM(" line ")); str += OUString::valueOf( nLine ); - str += OUString::createFromAscii( "]: " ); + str += OUString(RTL_CONSTASCII_USTRINGPARAM("]: ")); str += Message; - str += OUString::createFromAscii( "error" ); + str += OUString(RTL_CONSTASCII_USTRINGPARAM("error")); return str; } @@ -1074,3 +1075,4 @@ void * SAL_CALL component_getFactory( } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index 92d53700aa86..122928f1d934 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -178,7 +179,8 @@ public: sal_Bool bDoNormalization, sal_Bool bNormalizeWhitespace) throw( SAXException ); - sal_uInt32 GetLastColumnCount() { return (sal_uInt32)(nCurrentPos - nLastLineFeedPos); } + sal_uInt32 GetLastColumnCount() const + { return (sal_uInt32)(nCurrentPos - nLastLineFeedPos); } inline void startDocument() throw( SAXException ); @@ -244,7 +246,7 @@ inline sal_uInt32 SaxWriterHelper::writeSequence() throw( SAXException ) Any a; a <<= e; throw SAXException( - OUString::createFromAscii( "io exception during writing" ), + OUString(RTL_CONSTASCII_USTRINGPARAM("io exception during writing")), Reference< XInterface > (), a ); } @@ -1001,7 +1003,7 @@ public: // XServiceInfo private: void writeSequence( const Sequence<sal_Int8> & seq ); - sal_Int32 getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurence ) throw(); + sal_Int32 getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence ) throw(); Reference< XOutputStream > m_out; Sequence < sal_Int8 > m_seqStartElement; @@ -1029,12 +1031,12 @@ Reference < XInterface > SAL_CALL SaxWriter_CreateInstance( OUString SaxWriter_getServiceName() throw() { - return OUString::createFromAscii( "com.sun.star.xml.sax.Writer" ); + return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer")); } OUString SaxWriter_getImplementationName() throw() { - return OUString::createFromAscii( "com.sun.star.extensions.xml.sax.Writer" ); + return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.extensions.xml.sax.Writer")); } Sequence< OUString > SaxWriter_getSupportedServiceNames(void) throw() @@ -1045,14 +1047,14 @@ Sequence< OUString > SaxWriter_getSupportedServiceNames(void) throw() } -sal_Int32 SAXWriter::getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurence ) throw() +sal_Int32 SAXWriter::getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence ) throw() { sal_Int32 nLength =-1; if (mp_SaxWriterHelper) { if ( m_bForceLineBreak || (m_bAllowLineBreak && - ((nFirstLineBreakOccurence + mp_SaxWriterHelper->GetLastColumnCount()) > MAXCOLUMNCOUNT)) ) + ((nFirstLineBreakOccurrence + mp_SaxWriterHelper->GetLastColumnCount()) > MAXCOLUMNCOUNT)) ) nLength = m_nLevel; } m_bForceLineBreak = sal_False; @@ -1110,12 +1112,12 @@ void SAXWriter::endDocument(void) throw(SAXException, RuntimeE if( ! m_bDocStarted ) { throw SAXException( - OUString::createFromAscii( "endDocument called before startDocument" ), + OUString(RTL_CONSTASCII_USTRINGPARAM("endDocument called before startDocument")), Reference< XInterface >() , Any() ); } if( m_nLevel ) { throw SAXException( - OUString::createFromAscii( "unexpected end of document" ), + OUString(RTL_CONSTASCII_USTRINGPARAM("unexpected end of document")), Reference< XInterface >() , Any() ); } mp_SaxWriterHelper->endDocument(); @@ -1128,7 +1130,7 @@ void SAXWriter::endDocument(void) throw(SAXException, RuntimeE Any a; a <<= e; throw SAXException( - OUString::createFromAscii( "IO exception during closing the IO Stream" ), + OUString(RTL_CONSTASCII_USTRINGPARAM("IO exception during closing the IO Stream")), Reference< XInterface > (), a ); } @@ -1256,19 +1258,19 @@ void SAXWriter::characters(const OUString& aChars) throw(SAXException, RuntimeE bThrowException = !mp_SaxWriterHelper->writeString( aChars, sal_False, sal_False ); else { - // Note : nFirstLineBreakOccurence is not exact, because we don't know, how + // Note : nFirstLineBreakOccurrence is not exact, because we don't know, how // many 2 and 3 byte chars are inbetween. However this whole stuff // is eitherway for pretty printing only, so it does not need to be exact. sal_Int32 nLength(0); sal_Int32 nIndentPrefix(-1); if (m_bAllowLineBreak) { - sal_Int32 nFirstLineBreakOccurence = getFirstLineBreak( aChars ); + sal_Int32 nFirstLineBreakOccurrence = getFirstLineBreak( aChars ); nLength = calcXMLByteLength( aChars.getStr(), aChars.getLength(), ! m_bIsCDATA , sal_False ); nIndentPrefix = getIndentPrefixLength( - nFirstLineBreakOccurence >= 0 ? nFirstLineBreakOccurence : nLength ); + nFirstLineBreakOccurrence >= 0 ? nFirstLineBreakOccurrence : nLength ); } else nIndentPrefix = getIndentPrefixLength(nLength); @@ -1452,3 +1454,4 @@ void SAXWriter::unknown(const OUString& sString) throw (SAXException, RuntimeExc } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/xml2utf.cxx b/sax/source/expatwrap/xml2utf.cxx index bbd72b2a0d8b..b7aa1cad0424 100644 --- a/sax/source/expatwrap/xml2utf.cxx +++ b/sax/source/expatwrap/xml2utf.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,10 +35,11 @@ #include <com/sun/star/io/XInputStream.hpp> -using namespace rtl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; +using ::rtl::OString; + #include "xml2utf.hxx" namespace sax_expatwrap { @@ -568,3 +570,5 @@ void Unicode2TextConverter::init( rtl_TextEncoding encoding ) } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/fastparser/facreg.cxx b/sax/source/fastparser/facreg.cxx index 98a55823271e..af05616854c1 100644 --- a/sax/source/fastparser/facreg.cxx +++ b/sax/source/fastparser/facreg.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <cppuhelper/factory.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase2.hxx> @@ -76,3 +77,5 @@ void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServic } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 1a4cc9278e1e..bff58a6a5817 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -25,9 +26,6 @@ * ************************************************************************/ -//#include <stdlib.h> -//#include <sal/alloca.h> - #include <boost/scoped_ptr.hpp> #include <osl/diagnose.h> @@ -51,7 +49,6 @@ using namespace ::cppu; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::xml::sax; -//using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; namespace sax_fastparser { @@ -553,7 +550,7 @@ Sequence< OUString > FastSaxParser::getSupportedServiceNames_Static(void) // XServiceInfo OUString FastSaxParser::getImplementationName() throw (RuntimeException) { - return OUString::createFromAscii( PARSER_IMPLEMENTATION_NAME ); + return OUString(RTL_CONSTASCII_USTRINGPARAM( PARSER_IMPLEMENTATION_NAME )); } // XServiceInfo @@ -574,7 +571,7 @@ Sequence< OUString > FastSaxParser::getSupportedServiceNames(void) throw (Runtim { Sequence<OUString> seq(1); - seq.getArray()[0] = OUString::createFromAscii( PARSER_SERVICE_NAME ); + seq.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( PARSER_SERVICE_NAME )); return seq; } @@ -951,3 +948,5 @@ int FastSaxParser::callbackExternalEntityRef( XML_Parser parser, } } // namespace sax_fastparser + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/fastparser/fastparser.hxx b/sax/source/fastparser/fastparser.hxx index a0331fe4035a..77f04c798433 100644 --- a/sax/source/fastparser/fastparser.hxx +++ b/sax/source/fastparser/fastparser.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,7 @@ #include <vector> #include <stack> -#include <hash_map> +#include <boost/unordered_map.hpp> #include <boost/shared_ptr.hpp> #include <rtl/ref.hxx> #include <com/sun/star/xml/sax/XFastParser.hpp> @@ -56,7 +57,7 @@ struct SaxContextImpl; typedef ::boost::shared_ptr< SaxContextImpl > SaxContextImplPtr; typedef ::boost::shared_ptr< NamespaceDefine > NamespaceDefineRef; -typedef ::std::hash_map< ::rtl::OUString, sal_Int32, +typedef ::boost::unordered_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > NamespaceMap; // -------------------------------------------------------------------- @@ -162,3 +163,5 @@ private: } #endif // _SAX_FASTPARSER_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 26b3c48998f3..5dceeb38ab0d 100644 --- a/sax/source/tools/converter.cxx +++ b/sax/source/tools/converter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,14 +37,14 @@ #include <rtl/math.hxx> #include "sax/tools/converter.hxx" -using namespace rtl; using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::util; -//using namespace com::sun::star::text; -//using namespace com::sun::star::style; using namespace ::com::sun::star::i18n; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + namespace sax { static const sal_Char* gpsMM = "mm"; @@ -274,193 +275,6 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer, (void)nMeasure; (void)nSourceUnit; (void)nTargetUnit; -#if 0 - if( nSourceUnit == MeasureUnit::PERCENT ) - { - OSL_ENSURE( nTargetUnit == MeasureUnit::PERCENT, - "MeasureUnit::PERCENT only maps to MeasureUnit::PERCENT!" ); - - rBuffer.append( nMeasure ); - rBuffer.append( sal_Unicode('%' ) ); - } - else - { - // the sign is processed seperatly - if( nMeasure < 0 ) - { - nMeasure = -nMeasure; - rBuffer.append( sal_Unicode('-') ); - } - - // The new length is (nVal * nMul)/(nDiv*nFac*10) - long nMul = 1000; - long nDiv = 1; - long nFac = 100; - const sal_Char* psUnit = 0; - switch( nSourceUnit ) - { - case MeasureUnit::TWIP: - switch( nTargetUnit ) - { - case MeasureUnit::MM_100TH: - case MeasureUnit::MM_10TH: - OSL_ENSURE( MeasureUnit::INCH == nTargetUnit,"output unit not supported for twip values" ); - case MeasureUnit::MM: - // 0.01mm = 0.57twip (exactly) - nMul = 25400; // 25.4 * 1000 - nDiv = 1440; // 72 * 20; - nFac = 100; - psUnit = gpsMM; - break; - - case MeasureUnit::CM: - // 0.001cm = 0.57twip (exactly) - nMul = 25400; // 2.54 * 10000 - nDiv = 1440; // 72 * 20; - nFac = 1000; - psUnit = gpsCM; - break; - - case MeasureUnit::POINT: - // 0.01pt = 0.2twip (exactly) - nMul = 1000; - nDiv = 20; - nFac = 100; - psUnit = gpsPT; - break; - - case MeasureUnit::INCH: - default: - OSL_ENSURE( MeasureUnit::INCH == nTargetUnit, - "output unit not supported for twip values" ); - // 0.0001in = 0.144twip (exactly) - nMul = 100000; - nDiv = 1440; // 72 * 20; - nFac = 10000; - psUnit = gpsINCH; - break; - } - break; - - case MeasureUnit::POINT: - // 1pt = 1pt (exactly) - OSL_ENSURE( MeasureUnit::POINT == nTargetUnit, - "output unit not supported for pt values" ); - nMul = 10; - nDiv = 1; - nFac = 1; - psUnit = gpsPT; - break; - case MeasureUnit::MM_10TH: - case MeasureUnit::MM_100TH: - { - long nFac2 = (MeasureUnit::MM_100TH == nSourceUnit) ? 100 : 10; - switch( nTargetUnit ) - { - case MeasureUnit::MM_100TH: - case MeasureUnit::MM_10TH: - OSL_ENSURE( MeasureUnit::INCH == nTargetUnit, - "output unit not supported for 1/100mm values" ); - case MeasureUnit::MM: - // 0.01mm = 1 mm/100 (exactly) - nMul = 10; - nDiv = 1; - nFac = nFac2; - psUnit = gpsMM; - break; - - case MeasureUnit::CM: - // 0.001mm = 1 mm/100 (exactly) - nMul = 10; - nDiv = 1; // 72 * 20; - nFac = 10*nFac2; - psUnit = gpsCM; - break; - - case MeasureUnit::POINT: - // 0.01pt = 0.35 mm/100 (exactly) - nMul = 72000; - nDiv = 2540; - nFac = nFac2; - psUnit = gpsPT; - break; - - case MeasureUnit::INCH: - default: - OSL_ENSURE( MeasureUnit::INCH == nTargetUnit, - "output unit not supported for 1/100mm values" ); - // 0.0001in = 0.254 mm/100 (exactly) - nMul = 100000; - nDiv = 2540; - nFac = 100*nFac2; - psUnit = gpsINCH; - break; - } - break; - } - } - - long nLongVal = 0; - bool bOutLongVal = true; - if( nMeasure > SAL_INT32_MAX / nMul ) - { - // A big int is required for calculation - BigInt nBigVal( nMeasure ); - BigInt nBigFac( nFac ); - nBigVal *= nMul; - nBigVal /= nDiv; - nBigVal += 5; - nBigVal /= 10; - - if( nBigVal.IsLong() ) - { - // To convert the value into a string a long is sufficient - nLongVal = (long)nBigVal; - } - else - { - BigInt nBigFac2( nFac ); - BigInt nBig10( 10 ); - rBuffer.append( (sal_Int32)(nBigVal / nBigFac2) ); - if( !(nBigVal % nBigFac2).IsZero() ) - { - rBuffer.append( sal_Unicode('.') ); - while( nFac > 1 && !(nBigVal % nBigFac2).IsZero() ) - { - nFac /= 10; - nBigFac2 = nFac; - rBuffer.append( (sal_Int32)((nBigVal / nBigFac2) % nBig10 ) ); - } - } - bOutLongVal = false; - } - } - else - { - nLongVal = nMeasure * nMul; - nLongVal /= nDiv; - nLongVal += 5; - nLongVal /= 10; - } - - if( bOutLongVal ) - { - rBuffer.append( (sal_Int32)(nLongVal / nFac) ); - if( nFac > 1 && (nLongVal % nFac) != 0 ) - { - rBuffer.append( sal_Unicode('.') ); - while( nFac > 1 && (nLongVal % nFac) != 0 ) - { - nFac /= 10; - rBuffer.append( (sal_Int32)((nLongVal / nFac) % 10) ); - } - } - } - - if( psUnit ) - rBuffer.appendAscii( psUnit ); - } -#endif } static const OUString& getTrueString() @@ -1365,11 +1179,10 @@ bool Converter::convertDateOrDateTime( const ::rtl::OUString string = rString.trim().toAsciiUpperCase(); sal_Int32 nPos(0); - bool bNegative(false); if ((string.getLength() > nPos) && (sal_Unicode('-') == string[nPos])) { + //Negative Number ++nPos; - bNegative = true; } sal_Int32 nYear(0); @@ -1495,13 +1308,6 @@ bool Converter::convertDateOrDateTime( { bSuccess = false; // only 24:00:00 is valid } -#if 0 - else - { - nHours = 0; // normalize 24:00:00 to 00:00:00 of next day - lcl_addDay(bNegative, nYear, nMonth, nDay, 1); - } -#endif } } @@ -1569,11 +1375,6 @@ bool Converter::convertDateOrDateTime( if (bSuccess && bHaveTimezone) { // util::DateTime does not support timezones! -#if 0 - // do not add timezone, just strip it (as suggested by er) - lcl_addTimezone(bNegative, nYear, nMonth, nDay, nHours, nMinutes, - !bHaveTimezoneMinus, nTimezoneHours, nTimezoneMinutes); -#endif } if (bSuccess) @@ -2096,3 +1897,5 @@ sal_Int16 Converter::GetUnitFromString(const ::rtl::OUString& rString, sal_Int16 } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 4bf9d55c75b8..53fc40350022 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -147,7 +148,7 @@ Sequence< Attribute > FastAttributeList::getUnknownAttributes( ) throw (Runtime { Sequence< Attribute > aSeq( maUnknownAttributes.size() ); Attribute* pAttr = aSeq.getArray(); - for( UnknownAttributeList::iterator attrIter = maUnknownAttributes.begin(); attrIter != maUnknownAttributes.end(); attrIter++ ) + for( UnknownAttributeList::iterator attrIter = maUnknownAttributes.begin(); attrIter != maUnknownAttributes.end(); ++attrIter ) (*attrIter).FillAttribute( pAttr++ ); return aSeq; } @@ -156,7 +157,7 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes( ) throw (Runtim Sequence< FastAttribute > aSeq( maAttributes.size() ); FastAttribute* pAttr = aSeq.getArray(); FastAttributeMap::iterator fastAttrIter = maAttributes.begin(); - for(; fastAttrIter != maAttributes.end(); fastAttrIter++ ) + for(; fastAttrIter != maAttributes.end(); ++fastAttrIter ) { pAttr->Token = fastAttrIter->first; pAttr->Value = OStringToOUString( fastAttrIter->second, RTL_TEXTENCODING_UTF8 ); @@ -166,3 +167,5 @@ Sequence< FastAttribute > FastAttributeList::getFastAttributes( ) throw (Runtim } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index af89761a2c86..e894c2ca0d13 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,12 +30,19 @@ #include <rtl/ustrbuf.hxx> #include <rtl/byteseq.hxx> +#include <comphelper/sequenceasvector.hxx> + #include <com/sun/star/xml/Attribute.hpp> #include <com/sun/star/xml/FastAttribute.hpp> #include <com/sun/star/xml/sax/XFastAttributeList.hpp> #include <string.h> +#if DEBUG +#include <cstdio> +#endif + +using ::comphelper::SequenceAsVector; using ::rtl::OString; using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -82,7 +90,7 @@ namespace sax_fastparser { OUString FastSaxSerializer::escapeXml( const OUString& s ) { ::rtl::OUStringBuffer sBuf( s.getLength() ); - const sal_Unicode* pStr = s; + const sal_Unicode* pStr = s.getStr(); sal_Int32 nLen = s.getLength(); for( sal_Int32 i = 0; i < nLen; ++i) { @@ -130,6 +138,9 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; + if ( !maMarkStack.empty() ) + maMarkStack.top()->setCurrentElement( Element ); + writeBytes(toUnoSequence(aOpeningBracket)); writeId(Element); @@ -197,6 +208,9 @@ namespace sax_fastparser { if (!mxOutputStream.is()) return; + if ( !maMarkStack.empty() ) + maMarkStack.top()->setCurrentElement( Element ); + writeBytes(toUnoSequence(aOpeningBracket)); writeId(Element); @@ -282,7 +296,7 @@ namespace sax_fastparser { // XServiceInfo OUString FastSaxSerializer::getImplementationName() throw (RuntimeException) { - return OUString::createFromAscii( SERIALIZER_IMPLEMENTATION_NAME ); + return OUString(RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_IMPLEMENTATION_NAME )); } // XServiceInfo @@ -302,13 +316,13 @@ namespace sax_fastparser { Sequence< OUString > FastSaxSerializer::getSupportedServiceNames(void) throw (RuntimeException) { Sequence<OUString> seq(1); - seq.getArray()[0] = OUString::createFromAscii( SERIALIZER_SERVICE_NAME ); + seq.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_SERVICE_NAME )); return seq; } OUString FastSaxSerializer::getImplementationName_Static() { - return OUString::createFromAscii( SERIALIZER_IMPLEMENTATION_NAME ); + return OUString(RTL_CONSTASCII_USTRINGPARAM( SERIALIZER_IMPLEMENTATION_NAME )); } Sequence< OUString > FastSaxSerializer::getSupportedServiceNames_Static(void) @@ -318,10 +332,39 @@ namespace sax_fastparser { return aRet; } - void FastSaxSerializer::mark() + void FastSaxSerializer::mark( Int32Sequence aOrder ) + { + if ( aOrder.hasElements() ) + { + boost::shared_ptr< ForMerge > pSort( new ForSort( aOrder ) ); + maMarkStack.push( pSort ); + } + else + { + boost::shared_ptr< ForMerge > pMerge( new ForMerge( ) ); + maMarkStack.push( pMerge ); + } + } + +#if DEBUG + void FastSaxSerializer::printMarkStack( ) { - maMarkStack.push( ForMerge() ); + ::std::stack< boost::shared_ptr< ForMerge > > aCopy( maMarkStack ); + int nSize = aCopy.size(); + int i = 0; + while ( !aCopy.empty() ) + { + fprintf( stderr, "%d\n", nSize - i ); + + aCopy.top( )->print( ); + + fprintf( stderr, "\n" ); + + aCopy.pop( ); + i++; + } } +#endif void FastSaxSerializer::mergeTopMarks( sax_fastparser::MergeMarksEnum eMergeType ) { @@ -330,19 +373,19 @@ namespace sax_fastparser { if ( maMarkStack.size() == 1 ) { - mxOutputStream->writeBytes( maMarkStack.top().getData() ); + mxOutputStream->writeBytes( maMarkStack.top()->getData() ); maMarkStack.pop(); return; } - const Int8Sequence aMerge( maMarkStack.top().getData() ); + const Int8Sequence aMerge( maMarkStack.top()->getData() ); maMarkStack.pop(); switch ( eMergeType ) { - case MERGE_MARKS_APPEND: maMarkStack.top().append( aMerge ); break; - case MERGE_MARKS_PREPEND: maMarkStack.top().prepend( aMerge ); break; - case MERGE_MARKS_POSTPONE: maMarkStack.top().postpone( aMerge ); break; + case MERGE_MARKS_APPEND: maMarkStack.top()->append( aMerge ); break; + case MERGE_MARKS_PREPEND: maMarkStack.top()->prepend( aMerge ); break; + case MERGE_MARKS_POSTPONE: maMarkStack.top()->postpone( aMerge ); break; } } @@ -351,7 +394,7 @@ namespace sax_fastparser { if ( maMarkStack.empty() ) mxOutputStream->writeBytes( aData ); else - maMarkStack.top().append( aData ); + maMarkStack.top()->append( aData ); } FastSaxSerializer::Int8Sequence& FastSaxSerializer::ForMerge::getData() @@ -362,6 +405,25 @@ namespace sax_fastparser { return maData; } +#if DEBUG + void FastSaxSerializer::ForMerge::print( ) + { + fprintf( stderr, "Data: " ); + for ( sal_Int32 i=0, len=maData.getLength(); i < len; i++ ) + { + fprintf( stderr, "%c", maData[i] ); + } + + fprintf( stderr, "\nPostponed: " ); + for ( sal_Int32 i=0, len=maPostponed.getLength(); i < len; i++ ) + { + fprintf( stderr, "%c", maPostponed[i] ); + } + + fprintf( stderr, "\n" ); + } +#endif + void FastSaxSerializer::ForMerge::prepend( const Int8Sequence &rWhat ) { merge( maData, rWhat, false ); @@ -399,5 +461,71 @@ namespace sax_fastparser { } } + void FastSaxSerializer::ForMerge::resetData( ) + { + maData = Int8Sequence(); + } + + void FastSaxSerializer::ForSort::setCurrentElement( sal_Int32 nElement ) + { + SequenceAsVector< sal_Int32 > aOrder( maOrder ); + if( std::find( aOrder.begin(), aOrder.end(), nElement ) != aOrder.end() ) + { + mnCurrentElement = nElement; + if ( maData.find( nElement ) == maData.end() ) + maData[ nElement ] = Int8Sequence(); + } + } + + void FastSaxSerializer::ForSort::prepend( const Int8Sequence &rWhat ) + { + append( rWhat ); + } + + void FastSaxSerializer::ForSort::append( const Int8Sequence &rWhat ) + { + merge( maData[mnCurrentElement], rWhat, true ); + } + + void FastSaxSerializer::ForSort::sort() + { + // Clear the ForMerge data to avoid duplicate items + resetData(); + + // Sort it all + std::map< sal_Int32, Int8Sequence >::iterator iter; + for ( sal_Int32 i=0, len=maOrder.getLength(); i < len; i++ ) + { + iter = maData.find( maOrder[i] ); + if ( iter != maData.end() ) + ForMerge::append( iter->second ); + } + } + + FastSaxSerializer::Int8Sequence& FastSaxSerializer::ForSort::getData() + { + sort( ); + return ForMerge::getData(); + } + +#if DEBUG + void FastSaxSerializer::ForSort::print( ) + { + std::map< sal_Int32, Int8Sequence >::iterator iter = maData.begin(); + while ( iter != maData.end( ) ) + { + fprintf( stderr, "pair: %d, ", iter->first ); + for ( sal_Int32 i=0, len=iter->second.getLength(); i < len; ++i ) + fprintf( stderr, "%c", iter->second[i] ); + fprintf( stderr, "\n" ); + ++iter; + } + + sort( ); + ForMerge::print(); + } +#endif + } // namespace sax_fastparser +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index a98a0ff7a67d..493ef5cb3c92 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,6 +36,9 @@ #include <cppuhelper/implbase2.hxx> #include <stack> +#include <map> + +#include <boost/shared_ptr.hpp> #include "sax/dllapi.h" #include "sax/fshelper.hxx" @@ -46,6 +50,9 @@ namespace sax_fastparser { class SAX_DLLPUBLIC FastSaxSerializer : public ::cppu::WeakImplHelper2< ::com::sun::star::xml::sax::XFastSerializer, ::com::sun::star::lang::XServiceInfo > { + typedef ::com::sun::star::uno::Sequence< ::sal_Int8 > Int8Sequence; + typedef ::com::sun::star::uno::Sequence< ::sal_Int32 > Int32Sequence; + public: explicit FastSaxSerializer( ); virtual ~FastSaxSerializer(); @@ -101,7 +108,7 @@ public: mergeTopMarks( true ), mergeTopMarks(), /r, /p and you are done. */ - void mark(); + void mark( Int32Sequence aOrder = Int32Sequence() ); /** Merge 2 topmost marks. @@ -124,7 +131,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > mxOutputStream; ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastTokenHandler > mxFastTokenHandler; - typedef ::com::sun::star::uno::Sequence< ::sal_Int8 > Int8Sequence; class ForMerge { Int8Sequence maData; @@ -133,17 +139,54 @@ private: public: ForMerge() : maData(), maPostponed() {} - Int8Sequence& getData(); + virtual void setCurrentElement( ::sal_Int32 /*nToken*/ ) {} + virtual Int8Sequence& getData(); +#if DEBUG + virtual void print(); +#endif - void prepend( const Int8Sequence &rWhat ); - void append( const Int8Sequence &rWhat ); + virtual void prepend( const Int8Sequence &rWhat ); + virtual void append( const Int8Sequence &rWhat ); void postpone( const Int8Sequence &rWhat ); - private: + protected: + void resetData( ); static void merge( Int8Sequence &rTop, const Int8Sequence &rMerge, bool bAppend ); }; - ::std::stack< ForMerge > maMarkStack; + class ForSort : public ForMerge + { + std::map< ::sal_Int32, Int8Sequence > maData; + sal_Int32 mnCurrentElement; + + Int32Sequence maOrder; + + public: + ForSort( Int32Sequence aOrder ) : + ForMerge(), + maData(), + mnCurrentElement( 0 ), + maOrder( aOrder ) {} + + void setCurrentElement( ::sal_Int32 nToken ); + + virtual Int8Sequence& getData(); + +#if DEBUG + virtual void print(); +#endif + + virtual void prepend( const Int8Sequence &rWhat ); + virtual void append( const Int8Sequence &rWhat ); + private: + void sort(); + }; + +#if DEBUG + void printMarkStack( ); +#endif + + ::std::stack< boost::shared_ptr< ForMerge > > maMarkStack; void writeFastAttributeList( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ); void write( const ::rtl::OUString& s ); @@ -159,3 +202,5 @@ protected: } // namespace sax_fastparser #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx index 6956e5b32bf3..239096ae8a05 100644 --- a/sax/source/tools/fshelper.cxx +++ b/sax/source/tools/fshelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ #include <sax/fshelper.hxx> #include "fastserializer.hxx" #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> @@ -9,7 +10,7 @@ using namespace ::com::sun::star::uno; namespace sax_fastparser { -FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream ) : +FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) : mpSerializer(new FastSaxSerializer()) { Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_SET_THROW ); @@ -18,7 +19,8 @@ FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& mpSerializer->setFastTokenHandler( mxTokenHandler ); mpSerializer->setOutputStream( xOutputStream ); - mpSerializer->startDocument(); + if( bWriteHeader ) + mpSerializer->startDocument(); } FastSerializerHelper::~FastSerializerHelper() @@ -179,9 +181,9 @@ FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId) return mpSerializer->getOutputStream(); } -void FastSerializerHelper::mark() +void FastSerializerHelper::mark( Sequence< sal_Int32 > aOrder ) { - mpSerializer->mark(); + mpSerializer->mark( aOrder ); } void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType ) @@ -196,3 +198,5 @@ FastAttributeList * FastSerializerHelper::createAttrList() } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |