summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-03-30 20:39:37 +0200
committerNoel Grandin <noel@peralex.com>2016-03-31 13:23:03 +0200
commiteb20c5c707e12780008c3a87803324f516a935e0 (patch)
treea00b3d8292282cbab81a6854fb3c57fc537ef104
parent183c990a47da6f2bbbd4a40ff16f9605b5fdda3a (diff)
tdf#84938 convert SWBLK_ constants to scoped enum
Change-Id: Ib5ff447973850cac8c1a31dd4778dda4d1c8c83c
-rw-r--r--sw/source/core/inc/SwXMLTextBlocks.hxx2
-rw-r--r--sw/source/core/inc/swblocks.hxx16
-rw-r--r--sw/source/core/swg/SwXMLTextBlocks.cxx4
-rw-r--r--sw/source/core/swg/swblocks.cxx23
4 files changed, 24 insertions, 21 deletions
diff --git a/sw/source/core/inc/SwXMLTextBlocks.hxx b/sw/source/core/inc/SwXMLTextBlocks.hxx
index 19e35fa68e35..9e6a54d53b1a 100644
--- a/sw/source/core/inc/SwXMLTextBlocks.hxx
+++ b/sw/source/core/inc/SwXMLTextBlocks.hxx
@@ -64,7 +64,7 @@ public:
virtual sal_uLong PutText( const OUString&, const OUString&, const OUString& ) override;
virtual sal_uLong MakeBlockList() override;
- virtual short GetFileType() const override;
+ virtual FileType GetFileType() const override;
virtual sal_uLong OpenFile( bool bReadOnly = true ) override;
virtual void CloseFile() override;
diff --git a/sw/source/core/inc/swblocks.hxx b/sw/source/core/inc/swblocks.hxx
index 1ca4b5251f81..8736273ee4c4 100644
--- a/sw/source/core/inc/swblocks.hxx
+++ b/sw/source/core/inc/swblocks.hxx
@@ -69,13 +69,15 @@ protected:
SwImpBlocks( const OUString&, bool = false );
virtual ~SwImpBlocks();
- static short GetFileType( const OUString& );
- virtual short GetFileType() const = 0;
-#define SWBLK_NO_FILE 0 // Not present
-#define SWBLK_NONE 1 // No TB file
-#define SWBLK_SW2 2 // SW2 file
-#define SWBLK_SW3 3 // SW3 file
-#define SWBLK_XML 4 // XML Block List
+ enum class FileType {
+ NoFile, // Not present
+ None, // No TB file
+ SW2, // SW2 file
+ SW3, // SW3 file
+ XML // XML Block List
+ };
+ static FileType GetFileType( const OUString& );
+ virtual FileType GetFileType() const = 0;
virtual void ClearDoc(); // Delete Doc content
SwPaM* MakePaM(); // Span PaM over Doc
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx
index accd64a86af1..c22157c50da8 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -528,9 +528,9 @@ bool SwXMLTextBlocks::IsFileUCBStorage( const OUString & rFileName)
return bRet;
}
-short SwXMLTextBlocks::GetFileType() const
+SwImpBlocks::FileType SwXMLTextBlocks::GetFileType() const
{
- return SWBLK_XML;
+ return FileType::XML;
}
OUString SwXMLTextBlocks::GeneratePackageName ( const OUString& rShort )
diff --git a/sw/source/core/swg/swblocks.cxx b/sw/source/core/swg/swblocks.cxx
index b7557eba343a..703a3de9e519 100644
--- a/sw/source/core/swg/swblocks.cxx
+++ b/sw/source/core/swg/swblocks.cxx
@@ -74,16 +74,16 @@ SwBlockName::SwBlockName( const OUString& rShort, const OUString& rLong, const O
/**
* Is the provided file a storage or doesn't it exist?
*/
-short SwImpBlocks::GetFileType( const OUString& rFile )
+SwImpBlocks::FileType SwImpBlocks::GetFileType( const OUString& rFile )
{
if( !FStatHelper::IsDocument( rFile ) )
- return SWBLK_NO_FILE;
+ return FileType::NoFile;
if( SwXMLTextBlocks::IsFileUCBStorage( rFile ) )
- return SWBLK_XML;
+ return FileType::XML;
if( SotStorage::IsStorageFile( rFile ) )
- return SWBLK_SW3;
+ return FileType::SW3;
//otherwise return NONE
- return SWBLK_NONE;
+ return FileType::None;
}
SwImpBlocks::SwImpBlocks( const OUString& rFile, bool )
@@ -239,8 +239,9 @@ SwTextBlocks::SwTextBlocks( const OUString& rFile )
const OUString sFileName = aObj.GetMainURL( INetURLObject::NO_DECODE );
switch( SwImpBlocks::GetFileType( rFile ) )
{
- case SWBLK_XML: pImp = new SwXMLTextBlocks( sFileName ); break;
- case SWBLK_NO_FILE: pImp = new SwXMLTextBlocks( sFileName ); break;
+ case SwImpBlocks::FileType::XML: pImp = new SwXMLTextBlocks( sFileName ); break;
+ case SwImpBlocks::FileType::NoFile: pImp = new SwXMLTextBlocks( sFileName ); break;
+ default: break;
}
if( !pImp )
nErr = ERR_SWG_FILE_FORMAT_ERROR;
@@ -266,8 +267,8 @@ bool SwTextBlocks::IsOld() const
{
if (pImp)
{
- short nType = pImp->GetFileType();
- if (SWBLK_SW3 == nType || SWBLK_SW2 == nType )
+ SwImpBlocks::FileType nType = pImp->GetFileType();
+ if (SwImpBlocks::FileType::SW3 == nType || SwImpBlocks::FileType::SW2 == nType )
return true;
}
return false;
@@ -377,8 +378,8 @@ sal_uLong SwTextBlocks::CopyBlock( SwTextBlocks& rSource, OUString& rSrcShort,
bool bIsOld = false;
if (rSource.pImp)
{
- short nType = rSource.pImp->GetFileType();
- if (SWBLK_SW2 == nType || SWBLK_SW3 == nType )
+ SwImpBlocks::FileType nType = rSource.pImp->GetFileType();
+ if (SwImpBlocks::FileType::SW2 == nType || SwImpBlocks::FileType::SW3 == nType )
bIsOld = true;
}
if( bIsOld ) //rSource.IsOld() )