sfx2/source/appl/fileobj.cxx |   33 +++++++++++++++++----------------
 sfx2/source/appl/fileobj.hxx |    4 +++-
 2 files changed, 20 insertions(+), 17 deletions(-)

New commits:
commit 3db13a8b12b36679bdd6cdb243633a0eb39bad38
Author:     Noel Grandin <n...@peralex.com>
AuthorDate: Mon Mar 30 11:58:27 2020 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Mar 30 12:49:56 2020 +0200

    convert to scoped enum in SvFileObject
    
    Change-Id: I361adf3a0d112967910da3305f1e8e0063170745
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91352
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index 2f20bb84fc87..14b5d4caf9f2 100644
--- a/sfx2/source/appl/fileobj.cxx
+++ b/sfx2/source/appl/fileobj.cxx
@@ -40,14 +40,15 @@
 #include <sfx2/strings.hrc>
 #include <vcl/svapp.hxx>
 
-#define FILETYPE_TEXT       1
-#define FILETYPE_GRF        2
-#define FILETYPE_OBJECT     3
+enum class SvFileObjectType
+{
+    Text = 1, Graphic = 2, Object = 3
+};
 
 SvFileObject::SvFileObject()
     : nPostUserEventId(nullptr)
     , mxDelMed()
-    , nType(FILETYPE_TEXT)
+    , nType(SvFileObjectType::Text)
     , bLoadAgain(true)
     , bSynchron(false)
     , bLoadError(false)
@@ -76,7 +77,7 @@ bool SvFileObject::GetData( css::uno::Any & rData,
     SotClipboardFormatId nFmt = SotExchange::RegisterFormatMimeType( rMimeType 
);
     switch( nType )
     {
-    case FILETYPE_TEXT:
+    case SvFileObjectType::Text:
         if( SotClipboardFormatId::SIMPLE_FILE == nFmt )
         {
             // The media in the application must be opened to lookup the
@@ -86,7 +87,7 @@ bool SvFileObject::GetData( css::uno::Any & rData,
         }
         break;
 
-    case FILETYPE_GRF:
+    case SvFileObjectType::Graphic:
         if (SotClipboardFormatId::GDIMETAFILE == nFmt
          || SotClipboardFormatId::BITMAP == nFmt
          || SotClipboardFormatId::SVXB == nFmt)
@@ -94,7 +95,7 @@ bool SvFileObject::GetData( css::uno::Any & rData,
             rData <<= sFileNm;
         }
         break;
-    case FILETYPE_OBJECT:
+    case SvFileObjectType::Object:
         // TODO/LATER: possibility to insert a new object
         rData <<= sFileNm;
         break;
@@ -126,16 +127,16 @@ bool SvFileObject::Connect( sfx2::SvBaseLink* pLink )
     switch( pLink->GetObjType() )
     {
     case OBJECT_CLIENT_GRF:
-        nType = FILETYPE_GRF;
+        nType = SvFileObjectType::Graphic;
         bSynchron = pLink->IsSynchron();
         break;
 
     case OBJECT_CLIENT_FILE:
-        nType = FILETYPE_TEXT;
+        nType = SvFileObjectType::Text;
         break;
 
     case OBJECT_CLIENT_OLE:
-        nType = FILETYPE_OBJECT;
+        nType = SvFileObjectType::Object;
         // TODO/LATER: introduce own type to be used for exchanging
         break;
 
@@ -264,7 +265,7 @@ void SvFileObject::Edit(weld::Window* pParent, 
sfx2::SvBaseLink* pLink, const Li
     {
         case OBJECT_CLIENT_GRF:
         {
-            nType = FILETYPE_GRF;       // If not set already
+            nType = SvFileObjectType::Graphic;       // If not set already
 
             SvxOpenGraphicDialog aDlg(SfxResId(RID_SVXSTR_EDITGRFLINK), 
pParent);
             aDlg.EnableLink(false);
@@ -287,7 +288,7 @@ void SvFileObject::Edit(weld::Window* pParent, 
sfx2::SvBaseLink* pLink, const Li
 
         case OBJECT_CLIENT_OLE:
         {
-            nType = FILETYPE_OBJECT; // if not set already
+            nType = SvFileObjectType::Object; // if not set already
 
             ::sfx2::FileDialogHelper & rFileDlg =
                 pLink->GetInsertFileDialog( OUString() );
@@ -298,7 +299,7 @@ void SvFileObject::Edit(weld::Window* pParent, 
sfx2::SvBaseLink* pLink, const Li
 
         case OBJECT_CLIENT_FILE:
         {
-            nType = FILETYPE_TEXT; // if not set already
+            nType = SvFileObjectType::Text; // if not set already
 
             OUString sFactory;
             SfxObjectShell* pShell = pLink->GetLinkManager()->GetPersist();
@@ -357,7 +358,7 @@ IMPL_LINK( SvFileObject, DialogClosedHdl, 
sfx2::FileDialogHelper*, _pFileDlg, vo
 {
     OUString sFile;
 
-    if ( FILETYPE_TEXT == nType || FILETYPE_OBJECT == nType )
+    if ( SvFileObjectType::Text == nType || SvFileObjectType::Object == nType )
     {
         if ( _pFileDlg && _pFileDlg->GetError() == ERRCODE_NONE )
         {
@@ -380,13 +381,13 @@ IMPL_LINK( SvFileObject, DialogClosedHdl, 
sfx2::FileDialogHelper*, _pFileDlg, vo
 */
 bool SvFileObject::IsPending() const
 {
-    return FILETYPE_GRF == nType && !bLoadError && bWaitForData;
+    return SvFileObjectType::Graphic == nType && !bLoadError && bWaitForData;
 }
 
 bool SvFileObject::IsDataComplete() const
 {
     bool bRet = false;
-    if( FILETYPE_GRF != nType )
+    if( SvFileObjectType::Graphic != nType )
         bRet = true;
     else if( !bLoadError && !bWaitForData )
     {
diff --git a/sfx2/source/appl/fileobj.hxx b/sfx2/source/appl/fileobj.hxx
index edcb56131214..7362f6b1a4d6 100644
--- a/sfx2/source/appl/fileobj.hxx
+++ b/sfx2/source/appl/fileobj.hxx
@@ -27,6 +27,8 @@ class Graphic;
 struct ImplSVEvent;
 namespace sfx2 { class FileDialogHelper; }
 
+enum class SvFileObjectType;
+
 class SvFileObject : public sfx2::SvLinkSource
 {
     OUString                    sFileNm;
@@ -37,7 +39,7 @@ class SvFileObject : public sfx2::SvLinkSource
     ImplSVEvent*                nPostUserEventId;
     tools::SvRef<SfxMedium>     mxDelMed;
 
-    sal_uInt8 nType;
+    SvFileObjectType nType;
 
     bool bLoadAgain : 1;
     bool bSynchron : 1;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to