diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 12:47:44 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 12:47:44 +0200 |
commit | 941020379b1ea1ec7c564c21e68ea1674cda7683 (patch) | |
tree | 40fcaf109d6d585bcdc0faf7ea6c0812b3cc9a39 /sax/source/tools | |
parent | 0692507dcc62e94c7af88388961db1d7d12d6dbd (diff) | |
parent | 0d2916e03ea51529e15995830a1a8c36bd72e442 (diff) |
Merge branch 'master' into feature/gnumake4
Conflicts:
basebmp/prj/d.lst
basebmp/test/basictest.cxx
basebmp/test/makefile.mk
basegfx/inc/basegfx/basegfxdllapi.h
basegfx/inc/basegfx/tools/debugplotter.hxx
basegfx/inc/basegfx/tuple/b2ituple.hxx
basegfx/prj/d.lst
basegfx/source/numeric/makefile.mk
basegfx/source/polygon/makefile.mk
basegfx/source/range/makefile.mk
basegfx/source/raster/makefile.mk
basegfx/source/tuple/makefile.mk
basegfx/source/vector/makefile.mk
basegfx/test/basegfx1d.cxx
basegfx/test/makefile.mk
basegfx/util/makefile.mk
canvas/Library_canvasfactory.mk
canvas/Module_canvas.mk
canvas/prj/build.lst
canvas/prj/d.lst
canvas/source/cairo/cairo_canvashelper_texturefill.cxx
canvas/source/cairo/makefile.mk
canvas/source/tools/makefile.mk
comphelper/qa/string/makefile.mk
cppcanvas/Module_cppcanvas.mk
cppcanvas/inc/cppcanvas/cppcanvasdllapi.h
cppcanvas/prj/build.lst
cppcanvas/prj/d.lst
cppcanvas/source/mtfrenderer/makefile.mk
cppcanvas/util/makefile.mk
i18npool/source/search/makefile.mk
regexp/Library_regexp.mk
regexp/prj/d.lst
sax/CppunitTest_sax.mk
sax/Library_sax.mk
sax/prj/d.lst
sax/qa/cppunit/test_converter.cxx
sax/source/expatwrap/attrlistimpl.hxx
sax/util/makefile.mk
svtools/Library_svt.mk
tools/Executable_sspretty.mk
ucbhelper/prj/d.lst
ucbhelper/source/provider/configureucb.cxx
ucbhelper/source/provider/provconf.cxx
ucbhelper/util/makefile.mk
unotools/Library_utl.mk
unotools/Module_unotools.mk
unotools/Package_inc.mk
unotools/prj/build.lst
vcl/Library_desktop_detector.mk
vcl/Library_vcl.mk
vcl/Library_vclplug_gtk.mk
vcl/aqua/source/gdi/salprn.cxx
vcl/inc/aqua/saldata.hxx
vcl/unx/generic/gdi/salgdi3.cxx
Diffstat (limited to 'sax/source/tools')
-rw-r--r-- | sax/source/tools/converter.cxx | 215 | ||||
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 7 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 149 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 60 | ||||
-rw-r--r-- | sax/source/tools/fshelper.cxx | 12 |
5 files changed, 212 insertions, 231 deletions
diff --git a/sax/source/tools/converter.cxx b/sax/source/tools/converter.cxx index 26b3c48998f3..efa9f1687d7f 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"; @@ -269,198 +270,11 @@ void Converter::convertMeasure( OUStringBuffer& rBuffer, sal_Int16 nSourceUnit /* = MeasureUnit::MM_100TH */, sal_Int16 nTargetUnit /* = MeasureUnit::INCH */ ) { - OSL_ENSURE( false, "Converter::convertMeasure - not implemented, tools/BigInt needs replacement" ); + OSL_FAIL( "Converter::convertMeasure - not implemented, tools/BigInt needs replacement" ); (void)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() @@ -847,7 +661,7 @@ bool Converter::convertDuration(double& rfTime, { //! how many days is a year or month? - OSL_ENSURE( false, "years or months in duration: not implemented"); + OSL_FAIL( "years or months in duration: not implemented"); bSuccess = false; } else @@ -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..68e2f5ebfac5 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 <iostream> +#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,36 @@ namespace sax_fastparser { return aRet; } - void FastSaxSerializer::mark() + void FastSaxSerializer::mark( Int32Sequence aOrder ) { - maMarkStack.push( ForMerge() ); + 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( ) + { + ::std::stack< boost::shared_ptr< ForMerge > > aCopy( maMarkStack ); + int nSize = aCopy.size(); + int i = 0; + while ( !aCopy.empty() ) + { + std::cerr << nSize - i << "\n"; + aCopy.top( )->print( ); + std::cerr << "\n"; + aCopy.pop( ); + i++; + } } +#endif void FastSaxSerializer::mergeTopMarks( sax_fastparser::MergeMarksEnum eMergeType ) { @@ -330,19 +370,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 +391,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 +402,25 @@ namespace sax_fastparser { return maData; } +#if DEBUG + void FastSaxSerializer::ForMerge::print( ) + { + std::cerr << "Data: "; + for ( sal_Int32 i=0, len=maData.getLength(); i < len; i++ ) + { + std::cerr << maData[i]; + } + + std::cerr << "\nPostponed: "; + for ( sal_Int32 i=0, len=maPostponed.getLength(); i < len; i++ ) + { + std::cerr << maPostponed[i]; + } + + std::cerr << "\n"; + } +#endif + void FastSaxSerializer::ForMerge::prepend( const Int8Sequence &rWhat ) { merge( maData, rWhat, false ); @@ -399,5 +458,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( ) ) + { + std::cerr << "pair: " << iter->first; + for ( sal_Int32 i=0, len=iter->second.getLength(); i < len; ++i ) + std::cerr << iter->second[i]; + std::cerr << "\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..961875194a20 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; @@ -132,18 +138,56 @@ private: public: ForMerge() : maData(), maPostponed() {} + virtual ~ForMerge() {} - 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 +203,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: */ |