diff options
-rw-r--r-- | sw/inc/iodetect.hxx | 26 | ||||
-rw-r--r-- | sw/source/filter/basflt/fltini.cxx | 32 | ||||
-rw-r--r-- | sw/source/filter/basflt/iodetect.cxx | 8 |
3 files changed, 31 insertions, 35 deletions
diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx index 33673cc83742..91ee8ae56d21 100644 --- a/sw/inc/iodetect.hxx +++ b/sw/inc/iodetect.hxx @@ -58,21 +58,21 @@ struct SwIoDetect } }; -enum class ReaderWriterType { - Rtf, - Bas, - Ww6, - Ww8, - RtfWh, - Html, - Ww5, - Xml, - TextDlg, - Text, - LAST = Text +enum ReaderWriterEnum { + READER_WRITER_RTF, + READER_WRITER_BAS, + READER_WRITER_WW6, + READER_WRITER_WW8, + READER_WRITER_RTF_WH, + READER_WRITER_HTML, + READER_WRITER_WW5, + READER_WRITER_XML, + READER_WRITER_TEXT_DLG, + READER_WRITER_TEXT, + MAXFILTER }; -SwIoDetect& GetSwIoDetect(ReaderWriterType); +extern SwIoDetect aFilterDetect[]; /** The following class is a wrapper for basic i/o functions of Writer 3.0. Everything is static. All filter names mentioned are Writer-internal diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 8534eac44690..071751bd7006 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -57,8 +57,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/util/XMacroExpander.hpp> #include <rtl/bootstrap.hxx> -#include <o3tl/enumarray.hxx> -#include <o3tl/enumrange.hxx> using namespace utl; using namespace com::sun::star::uno; @@ -70,8 +68,8 @@ Reader* GetRTFReader(); Reader* GetWW8Reader(); // Note: if editing, please don't forget to modify also the enum -// ReaderWriterType and aFilterDetect in iodetect.cxx -o3tl::enumarray<ReaderWriterType, SwReaderWriterEntry> aReaderWriter = +// ReaderWriterEnum and aFilterDetect in shellio.hxx +SwReaderWriterEntry aReaderWriter[] = { SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter, true ), SwReaderWriterEntry( nullptr, &::GetASCWriter, false ), @@ -110,16 +108,20 @@ SwRead SwGetReaderXML() // SW_DLLPUBLIC return ReadXML; } +inline void SetFltPtr( sal_uInt16 rPos, SwRead pReader ) +{ + aReaderWriter[ rPos ].pReader = pReader; +} namespace sw { Filters::Filters() { - aReaderWriter[ ReaderWriterType::Bas ].pReader = ReadAscii = new AsciiReader; - aReaderWriter[ ReaderWriterType::Html ].pReader = ReadHTML = new HTMLReader; - aReaderWriter[ ReaderWriterType::Xml ].pReader = ReadXML = new XMLReader; - aReaderWriter[ ReaderWriterType::TextDlg ].pReader = ReadAscii; - aReaderWriter[ ReaderWriterType::Text ].pReader = ReadAscii; + SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) ); + SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) ); + SetFltPtr( READER_WRITER_XML, (ReadXML = new XMLReader) ); + SetFltPtr( READER_WRITER_TEXT_DLG, ReadAscii ); + SetFltPtr( READER_WRITER_TEXT, ReadAscii ); } Filters::~Filters() @@ -159,15 +161,15 @@ namespace SwReaderWriter { Reader* GetRtfReader() { - return aReaderWriter[ReaderWriterType::Rtf].GetReader(); + return aReaderWriter[READER_WRITER_RTF].GetReader(); } void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& xRet ) { - for( ReaderWriterType aType : o3tl::enumrange<ReaderWriterType>() ) - if ( GetSwIoDetect(aType).IsFilter( rFltName ) ) + for( int n = 0; n < MAXFILTER; ++n ) + if ( aFilterDetect[n].IsFilter( rFltName ) ) { - aReaderWriter[aType].GetWriter( rFltName, rBaseURL, xRet ); + aReaderWriter[n].GetWriter( rFltName, rBaseURL, xRet ); break; } } @@ -175,9 +177,9 @@ void GetWriter( const OUString& rFltName, const OUString& rBaseURL, WriterRef& x SwRead GetReader( const OUString& rFltName ) { SwRead pRead = nullptr; - for( ReaderWriterType n : o3tl::enumrange<ReaderWriterType>() ) + for( int n = 0; n < MAXFILTER; ++n ) { - if ( GetSwIoDetect(n).IsFilter( rFltName ) ) + if ( aFilterDetect[n].IsFilter( rFltName ) ) { pRead = aReaderWriter[n].GetReader(); // add special treatment for some readers diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx index 2fc3c0909b1c..5b6e92ff8a91 100644 --- a/sw/source/filter/basflt/iodetect.cxx +++ b/sw/source/filter/basflt/iodetect.cxx @@ -24,7 +24,6 @@ #include <svtools/parhtml.hxx> #include <tools/urlobj.hxx> #include <unotools/moduleoptions.hxx> -#include <o3tl/enumarray.hxx> using namespace ::com::sun::star; @@ -34,7 +33,7 @@ static bool IsDocShellRegistered() return SvtModuleOptions().IsWriter(); } -o3tl::enumarray<ReaderWriterType, SwIoDetect> aFilterDetect = +SwIoDetect aFilterDetect[] = { SwIoDetect( FILTER_RTF ), SwIoDetect( FILTER_BAS ), @@ -48,11 +47,6 @@ o3tl::enumarray<ReaderWriterType, SwIoDetect> aFilterDetect = SwIoDetect( FILTER_TEXT ) }; -SwIoDetect& GetSwIoDetect(ReaderWriterType eType) -{ - return aFilterDetect[eType]; -} - const OUString SwIoSystem::GetSubStorageName( const SfxFilter& rFltr ) { // for StorageFilters also set the SubStorageName |