From fe1b87eb831d6e85b2db0591f933a9eede2e78cf Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 16 Jul 2018 14:41:05 +0200 Subject: convert SW*READER constants to scoped enum Change-Id: I7cf635e238a16e7ec96e585e6eb5e2e9c39b545a Reviewed-on: https://gerrit.libreoffice.org/57497 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sw/inc/shellio.hxx | 15 +++++++++++---- sw/source/filter/basflt/fltini.cxx | 2 +- sw/source/filter/basflt/shellio.cxx | 14 +++++++------- sw/source/filter/docx/swdocxreader.cxx | 4 ++-- sw/source/filter/docx/swdocxreader.hxx | 2 +- sw/source/filter/inc/fltini.hxx | 2 +- sw/source/filter/ww8/ww8par.cxx | 4 ++-- sw/source/filter/ww8/ww8par.hxx | 2 +- sw/source/filter/xml/swxml.cxx | 4 ++-- sw/source/uibase/app/docsh.cxx | 4 ++-- 10 files changed, 30 insertions(+), 23 deletions(-) diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 126374395895..efe86a0c2dbd 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -29,6 +29,7 @@ #include #include #include +#include #include "swdllapi.h" #include "docfac.hxx" @@ -172,8 +173,14 @@ protected: }; // Special Readers can be both!! (Excel, W4W, .. ). -#define SW_STREAM_READER 1 -#define SW_STORAGE_READER 2 +enum class SwReaderType { + NONE = 0x00, + Stream = 0x01, + Storage = 0x02 +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +}; extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDOC(SvStream &rStream, const OUString &rFltName); extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportRTF(SvStream &rStream); @@ -215,7 +222,7 @@ public: Reader(); virtual ~Reader(); - virtual int GetReaderType(); + virtual SwReaderType GetReaderType(); SwgReaderOption& GetReaderOpt() { return m_aOption; } virtual void SetFltName( const OUString& rFltNm ); @@ -277,7 +284,7 @@ class SW_DLLPUBLIC StgReader : public Reader OUString aFltName; public: - virtual int GetReaderType() override; + virtual SwReaderType GetReaderType() override; const OUString& GetFltName() { return aFltName; } virtual void SetFltName( const OUString& r ) override; }; diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 6c283a4cd9d0..64f607331d69 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -277,7 +277,7 @@ void SwFilterOptions::Notify( const css::uno::Sequence< OUString >& ) {} void StgReader::SetFltName( const OUString& rFltNm ) { - if( SW_STORAGE_READER & GetReaderType() ) + if( SwReaderType::Storage & GetReaderType() ) aFltName = rFltNm; } diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 24e92e23412b..ccfd9d69c74e 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -574,7 +574,7 @@ bool Reader::SetStrmStgPtr() if( m_pMedium->IsStorage() ) { - if( SW_STORAGE_READER & GetReaderType() ) + if( SwReaderType::Storage & GetReaderType() ) { m_xStorage = m_pMedium->GetStorage(); return true; @@ -583,12 +583,12 @@ bool Reader::SetStrmStgPtr() else { m_pStream = m_pMedium->GetInStream(); - if ( m_pStream && SotStorage::IsStorageFile(m_pStream) && (SW_STORAGE_READER & GetReaderType()) ) + if ( m_pStream && SotStorage::IsStorageFile(m_pStream) && (SwReaderType::Storage & GetReaderType()) ) { m_pStorage = new SotStorage( *m_pStream ); m_pStream = nullptr; } - else if ( !(SW_STREAM_READER & GetReaderType()) ) + else if ( !(SwReaderType::Stream & GetReaderType()) ) { m_pStream = nullptr; return false; @@ -599,9 +599,9 @@ bool Reader::SetStrmStgPtr() return false; } -int Reader::GetReaderType() +SwReaderType Reader::GetReaderType() { - return SW_STREAM_READER; + return SwReaderType::Stream; } void Reader::SetFltName( const OUString& ) @@ -678,9 +678,9 @@ bool Reader::ReadGlossaries( SwTextBlocks&, bool ) const return false; } -int StgReader::GetReaderType() +SwReaderType StgReader::GetReaderType() { - return SW_STORAGE_READER; + return SwReaderType::Storage; } /* diff --git a/sw/source/filter/docx/swdocxreader.cxx b/sw/source/filter/docx/swdocxreader.cxx index 7c9a59f863f9..90a6a9f1224f 100644 --- a/sw/source/filter/docx/swdocxreader.cxx +++ b/sw/source/filter/docx/swdocxreader.cxx @@ -99,9 +99,9 @@ ErrCode SwDOCXReader::Read(SwDoc& rDoc, const OUString& /* rBaseURL */, SwPaM& r return ret; } -int SwDOCXReader::GetReaderType() +SwReaderType SwDOCXReader::GetReaderType() { - return SW_STORAGE_READER | SW_STREAM_READER; + return SwReaderType::Storage | SwReaderType::Stream; } bool SwDOCXReader::HasGlossaries() const diff --git a/sw/source/filter/docx/swdocxreader.hxx b/sw/source/filter/docx/swdocxreader.hxx index 8035b6b746b0..57900c12143b 100644 --- a/sw/source/filter/docx/swdocxreader.hxx +++ b/sw/source/filter/docx/swdocxreader.hxx @@ -28,7 +28,7 @@ class SwDOCXReader : public StgReader { public: - virtual int GetReaderType() override; + virtual SwReaderType GetReaderType() override; virtual bool HasGlossaries() const override; virtual bool ReadGlossaries( SwTextBlocks& rBlocks, bool bSaveRelFiles ) const override; diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx index c20859fa5250..70cafaa46e94 100644 --- a/sw/source/filter/inc/fltini.hxx +++ b/sw/source/filter/inc/fltini.hxx @@ -43,7 +43,7 @@ class XMLReader : public Reader { virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override; public: - virtual int GetReaderType() override; + virtual SwReaderType GetReaderType() override; XMLReader(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 8d38f4a4e0f7..f3f45bfc4970 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -6347,9 +6347,9 @@ ErrCode WW8Reader::Read(SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, cons return nRet; } -int WW8Reader::GetReaderType() +SwReaderType WW8Reader::GetReaderType() { - return SW_STORAGE_READER | SW_STREAM_READER; + return SwReaderType::Storage | SwReaderType::Stream; } bool WW8Reader::HasGlossaries() const diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 8bf8db6195ea..bf342b0b4345 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -134,7 +134,7 @@ class WW8Reader : public StgReader virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override; ErrCode OpenMainStream( tools::SvRef& rRef, sal_uInt16& rBuffSize ); public: - virtual int GetReaderType() override; + virtual SwReaderType GetReaderType() override; virtual bool HasGlossaries() const override; virtual bool ReadGlossaries( SwTextBlocks&, bool bSaveRelFiles ) const override; diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 3d64af5c5c57..ea8c6eacdc1c 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -121,9 +121,9 @@ XMLReader::XMLReader() { } -int XMLReader::GetReaderType() +SwReaderType XMLReader::GetReaderType() { - return SW_STORAGE_READER; + return SwReaderType::Storage; } namespace diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index d1ed88666246..1692517501c5 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -191,8 +191,8 @@ Reader* SwDocShell::StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, return nullptr; if( rMedium.IsStorage() - ? SW_STORAGE_READER & pRead->GetReaderType() - : SW_STREAM_READER & pRead->GetReaderType() ) + ? SwReaderType::Storage & pRead->GetReaderType() + : SwReaderType::Stream & pRead->GetReaderType() ) { *ppRdr = pPaM ? new SwReader( rMedium, aFileName, *pPaM ) : pCursorShell ? -- cgit