summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-12-19 12:13:13 +0100
committerLuboš Luňák <l.lunak@suse.cz>2012-12-19 12:20:00 +0100
commit9c17f2b24bc97b46640b1728fb04d65b88c09f75 (patch)
tree793a1818707d40e3a05258fee96627bd25e84869 /sc
parenta6d5ed529a373863eb670cc75bd797057a339745 (diff)
wrap vararg sax functions in typesafe overloads
Now automatic conversions can take place (no getStr() needed), and there are compile errors when used improperly. The FSEND terminator is also no longer needed, but it's better to dump it only after forgetting it no longer silently breaks backports. Change-Id: Ib47e6eda2d5e12ce889b69bf2affbda3679c2d3f
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/excel/xestream.cxx4
-rw-r--r--sc/source/filter/inc/xestream.hxx36
2 files changed, 37 insertions, 3 deletions
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 9df58112cf23..a22496c2b52d 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -999,7 +999,7 @@ sax_fastparser::FSHelperPtr XclExpXmlStream::GetStreamForPath( const OUString& s
return maOpenedStreamMap[ sPath ].second;
}
-sax_fastparser::FSHelperPtr& XclExpXmlStream::WriteAttributes( sal_Int32 nAttribute, ... )
+sax_fastparser::FSHelperPtr& XclExpXmlStream::WriteAttributesInternal( sal_Int32 nAttribute, ... )
{
sax_fastparser::FSHelperPtr& rStream = GetCurrentStream();
@@ -1017,7 +1017,7 @@ sax_fastparser::FSHelperPtr& XclExpXmlStream::WriteAttributes( sal_Int32 nAttrib
}
nAttribute = va_arg( args, sal_Int32 );
- if( nAttribute == FSEND )
+ if( nAttribute == FSEND_internal )
break;
} while( true );
va_end( args );
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index 3c22bda1c096..571809c29276 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -311,7 +311,10 @@ public:
sax_fastparser::FSHelperPtr GetStreamForPath( const ::rtl::OUString& rPath );
- sax_fastparser::FSHelperPtr& WriteAttributes( sal_Int32 nAttribute, ... );
+ sax_fastparser::FSHelperPtr& WriteAttributes( sal_Int32 nAttribute, const char* value, FSEND_t )
+ { return WriteAttributesInternal( nAttribute, value, FSEND_internal ); }
+ sax_fastparser::FSHelperPtr& WriteAttributes( sal_Int32 nAttribute, const OString& value, FSEND_t )
+ { return WriteAttributesInternal( nAttribute, value.getStr(), FSEND_internal ); }
sax_fastparser::FSHelperPtr CreateOutputStream (
const ::rtl::OUString& sFullStream,
@@ -331,10 +334,41 @@ public:
virtual const oox::drawingml::table::TableStyleListPtr getTableStyles();
virtual oox::drawingml::chart::ChartConverter* getChartConverter();
+ /*
+ Now create all the overloads in a typesafe way (i.e. without varargs) by creating a number of overloads
+ up to a certain reasonable limit (feel free to raise it). This would be a lot easier with C++11 vararg templates.
+ */
+ // now overloads for 2 and more pairs
+ #define SAX_ARGS_FUNC_DECL( argsdecl, argsuse ) \
+ sax_fastparser::FSHelperPtr& WriteAttributes( argsdecl, FSEND_t ) \
+ { return WriteAttributesInternal( argsuse, FSEND_internal ); }
+ #define SAX_ARGS_FUNC_NUM( decl1, decl2, use1, use2, convert, num ) \
+ SAX_ARGS_FUNC_DECL( SAX_ARGS_ARG##num( decl1, decl2, ), SAX_ARGS_ARG##num( use1, use2, convert ))
+ #define SAX_ARGS_FUNC_SUBST( type, convert, num ) \
+ SAX_ARGS_FUNC_NUM( sal_Int32 attribute, type value, attribute, value, convert, num )
+ #define SAX_ARGS_FUNC( arg, convert ) SAX_ARGS_FUNC_SUBST( arg, convert, 2 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 3 ) SAX_ARGS_FUNC_SUBST( arg, convert, 4 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 5 ) SAX_ARGS_FUNC_SUBST( arg, convert, 6 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 7 ) SAX_ARGS_FUNC_SUBST( arg, convert, 8 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 9 ) SAX_ARGS_FUNC_SUBST( arg, convert, 10 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 11 ) SAX_ARGS_FUNC_SUBST( arg, convert, 12 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 13 ) SAX_ARGS_FUNC_SUBST( arg, convert, 14 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 15 ) SAX_ARGS_FUNC_SUBST( arg, convert, 16 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 17 ) SAX_ARGS_FUNC_SUBST( arg, convert, 18 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 19 ) SAX_ARGS_FUNC_SUBST( arg, convert, 20 ) \
+ SAX_ARGS_FUNC_SUBST( arg, convert, 21 ) SAX_ARGS_FUNC_SUBST( arg, convert, 22 )
+ SAX_ARGS_FUNC( const char*, )
+ SAX_ARGS_FUNC( const OString&, .getStr() )
+ #undef SAX_ARGS_FUNC_DECL
+ #undef SAX_ARGS_FUNC_NUM
+ #undef SAX_ARGS_FUNC_SUBST
+ #undef SAX_ARGS_FUNC
+
private:
virtual ::oox::ole::VbaProject* implCreateVbaProject() const;
virtual ::rtl::OUString implGetImplementationName() const;
ScDocShell *getDocShell();
+ sax_fastparser::FSHelperPtr& WriteAttributesInternal( sal_Int32 nAttribute, ... );
typedef std::map< ::rtl::OUString,
std::pair< ::rtl::OUString,