[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Michael Stahl mstahl at redhat.com
Fri Oct 7 14:51:13 UTC 2016


 include/sfx2/recentdocsview.hxx            |   21 +++++++++++-
 sfx2/source/control/recentdocsview.cxx     |   47 ++++++++++++++++-------------
 sfx2/source/control/recentdocsviewitem.cxx |    9 +++--
 sfx2/source/dialog/backingwindow.cxx       |   14 ++++----
 sfx2/source/dialog/backingwindow.hxx       |    2 -
 5 files changed, 58 insertions(+), 35 deletions(-)

New commits:
commit 41c2c9ea02e6db37fd23012873fd30d665729122
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Oct 7 16:15:07 2016 +0200

    sfx2: resolve "enum ApplicationType" conflict...
    
    ... with windows.h by putting our enum into a namespace, and while we're
    at it convert it to enum class etc.
    
    Change-Id: I804cd82565e77e6ab9a9d3a529f1ea43379fe0be

diff --git a/include/sfx2/recentdocsview.hxx b/include/sfx2/recentdocsview.hxx
index 76c7647..1d316bf 100644
--- a/include/sfx2/recentdocsview.hxx
+++ b/include/sfx2/recentdocsview.hxx
@@ -14,10 +14,15 @@
 #include <sfx2/recentdocsviewitem.hxx>
 #include <vcl/image.hxx>
 
+#include <o3tl/typed_flags_set.hxx>
+
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/frame/XDispatch.hpp>
 
+namespace sfx2
+{
+
 struct LoadRecentFile
 {
     css::util::URL                                    aTargetURL;
@@ -26,7 +31,7 @@ struct LoadRecentFile
     VclPtr< ThumbnailView >                           pView;
 };
 
-enum ApplicationType
+enum class ApplicationType
 {
     TYPE_NONE     =      0,
     TYPE_WRITER   = 1 << 0,
@@ -38,6 +43,16 @@ enum ApplicationType
     TYPE_OTHER    = 1 << 6
 };
 
+} // namespace sfx2
+
+namespace o3tl {
+
+template<> struct typed_flags<sfx2::ApplicationType> : is_typed_flags<sfx2::ApplicationType, 0x7f> {};
+
+} // namespace o3tl
+
+namespace sfx2
+{
 
 class SFX2_DLLPUBLIC RecentDocsView : public ThumbnailView
 {
@@ -51,7 +66,7 @@ public:
     static bool typeMatchesExtension(ApplicationType type, const OUString &rExt);
     static BitmapEx getDefaultThumbnail(const OUString &rURL);
 
-    int     mnFileTypes;
+    ApplicationType mnFileTypes;
 
     virtual void Clear() override;
 
@@ -85,6 +100,8 @@ protected:
     OUString maWelcomeLine2;
 };
 
+} // namespace sfx2
+
 #endif // INCLUDED_SFX2_RECENTDOCSVIEW_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/recentdocsview.cxx b/sfx2/source/control/recentdocsview.cxx
index e58003e..623e261 100644
--- a/sfx2/source/control/recentdocsview.cxx
+++ b/sfx2/source/control/recentdocsview.cxx
@@ -52,9 +52,12 @@ void SetMessageFont(vcl::RenderContext& rRenderContext)
 
 }
 
+namespace sfx2
+{
+
 RecentDocsView::RecentDocsView( vcl::Window* pParent )
     : ThumbnailView(pParent)
-    , mnFileTypes(TYPE_NONE)
+    , mnFileTypes(ApplicationType::TYPE_NONE)
     , mnTextHeight(30)
     , mnItemPadding(5)
     , mnItemMaxTextLength(30)
@@ -86,32 +89,32 @@ bool RecentDocsView::typeMatchesExtension(ApplicationType type, const OUString &
     if (rExt == "odt" || rExt == "doc" || rExt == "docx" ||
         rExt == "rtf" || rExt == "txt" || rExt == "odm" || rExt == "otm")
     {
-        bRet = type & TYPE_WRITER;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_WRITER);
     }
     else if (rExt == "ods" || rExt == "xls" || rExt == "xlsx")
     {
-        bRet = type & TYPE_CALC;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_CALC);
     }
     else if (rExt == "odp" || rExt == "pps" || rExt == "ppt" ||
             rExt == "pptx")
     {
-        bRet = type & TYPE_IMPRESS;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_IMPRESS);
     }
     else if (rExt == "odg")
     {
-        bRet = type & TYPE_DRAW;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_DRAW);
     }
     else if (rExt == "odb")
     {
-        bRet = type & TYPE_DATABASE;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_DATABASE);
     }
     else if (rExt == "odf")
     {
-        bRet = type & TYPE_MATH;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_MATH);
     }
     else
     {
-        bRet = type & TYPE_OTHER;
+        bRet = static_cast<bool>(type & ApplicationType::TYPE_OTHER);
     }
 
     return bRet;
@@ -121,13 +124,13 @@ bool RecentDocsView::isAcceptedFile(const OUString &rURL) const
 {
     INetURLObject aUrl(rURL);
     OUString aExt = aUrl.getExtension();
-    return (mnFileTypes & TYPE_WRITER   && typeMatchesExtension(TYPE_WRITER,  aExt)) ||
-           (mnFileTypes & TYPE_CALC     && typeMatchesExtension(TYPE_CALC,    aExt)) ||
-           (mnFileTypes & TYPE_IMPRESS  && typeMatchesExtension(TYPE_IMPRESS, aExt)) ||
-           (mnFileTypes & TYPE_DRAW     && typeMatchesExtension(TYPE_DRAW,    aExt)) ||
-           (mnFileTypes & TYPE_DATABASE && typeMatchesExtension(TYPE_DATABASE,aExt)) ||
-           (mnFileTypes & TYPE_MATH     && typeMatchesExtension(TYPE_MATH,    aExt)) ||
-           (mnFileTypes & TYPE_OTHER    && typeMatchesExtension(TYPE_OTHER,   aExt));
+    return (mnFileTypes & ApplicationType::TYPE_WRITER   && typeMatchesExtension(ApplicationType::TYPE_WRITER,  aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_CALC     && typeMatchesExtension(ApplicationType::TYPE_CALC,    aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_IMPRESS  && typeMatchesExtension(ApplicationType::TYPE_IMPRESS, aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_DRAW     && typeMatchesExtension(ApplicationType::TYPE_DRAW,    aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_DATABASE && typeMatchesExtension(ApplicationType::TYPE_DATABASE,aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_MATH     && typeMatchesExtension(ApplicationType::TYPE_MATH,    aExt)) ||
+           (mnFileTypes & ApplicationType::TYPE_OTHER    && typeMatchesExtension(ApplicationType::TYPE_OTHER,   aExt));
 }
 
 BitmapEx RecentDocsView::getDefaultThumbnail(const OUString &rURL)
@@ -136,17 +139,17 @@ BitmapEx RecentDocsView::getDefaultThumbnail(const OUString &rURL)
     INetURLObject aUrl(rURL);
     OUString aExt = aUrl.getExtension();
 
-    if ( typeMatchesExtension( TYPE_WRITER, aExt) )
+    if (typeMatchesExtension(ApplicationType::TYPE_WRITER, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_TEXT ) );
-    else if ( typeMatchesExtension( TYPE_CALC, aExt) )
+    else if (typeMatchesExtension(ApplicationType::TYPE_CALC, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_SHEET ) );
-    else if ( typeMatchesExtension( TYPE_IMPRESS, aExt) )
+    else if (typeMatchesExtension(ApplicationType::TYPE_IMPRESS, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_PRESENTATION ) );
-    else if ( typeMatchesExtension( TYPE_DRAW, aExt) )
+    else if (typeMatchesExtension(ApplicationType::TYPE_DRAW, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DRAWING ) );
-    else if ( typeMatchesExtension( TYPE_DATABASE, aExt) )
+    else if (typeMatchesExtension(ApplicationType::TYPE_DATABASE, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DATABASE ) );
-    else if ( typeMatchesExtension( TYPE_MATH, aExt) )
+    else if (typeMatchesExtension(ApplicationType::TYPE_MATH, aExt))
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_MATH ) );
     else
         aImg = BitmapEx ( SfxResId( SFX_FILE_THUMBNAIL_DEFAULT ) );
@@ -344,4 +347,6 @@ IMPL_STATIC_LINK( RecentDocsView, ExecuteHdl_Impl, void*, p, void )
     delete pLoadRecentFile;
 }
 
+} // namespace sfx2
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/recentdocsviewitem.cxx b/sfx2/source/control/recentdocsviewitem.cxx
index fa1392d..317f9f47 100644
--- a/sfx2/source/control/recentdocsviewitem.cxx
+++ b/sfx2/source/control/recentdocsviewitem.cxx
@@ -59,13 +59,14 @@ RecentDocsViewItem::RecentDocsViewItem(ThumbnailView &rView, const OUString &rUR
     if (aThumbnail.IsEmpty())
     {
         // Use the default thumbnail if we have nothing else
-        BitmapEx aExt(RecentDocsView::getDefaultThumbnail(rURL));
+        BitmapEx aExt(sfx2::RecentDocsView::getDefaultThumbnail(rURL));
         Size aExtSize(aExt.GetSizePixel());
 
         // attempt to make it appear as if it is on a piece of paper
         long nPaperHeight;
         long nPaperWidth;
-        if( RecentDocsView::typeMatchesExtension(TYPE_IMPRESS, aURLObj.getExtension()) )
+        if (sfx2::RecentDocsView::typeMatchesExtension(
+                sfx2::ApplicationType::TYPE_IMPRESS, aURLObj.getExtension()))
         {
             // Swap width and height (PAPER_SCREEN_4_3 definition make it needed)
             PaperInfo aInfo(PAPER_SCREEN_4_3);
@@ -210,13 +211,13 @@ void RecentDocsViewItem::OpenDocument()
         // Call dispatch asynchronously as we can be destroyed while dispatch is
         // executed. VCL is not able to survive this as it wants to call listeners
         // after select!!!
-        LoadRecentFile* pLoadRecentFile = new LoadRecentFile;
+        sfx2::LoadRecentFile *const pLoadRecentFile = new sfx2::LoadRecentFile;
         pLoadRecentFile->xDispatch = xDispatch;
         pLoadRecentFile->aTargetURL = aTargetURL;
         pLoadRecentFile->aArgSeq = aArgsList;
         pLoadRecentFile->pView.set(&mrParent);
 
-        Application::PostUserEvent(LINK(nullptr, RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true);
+        Application::PostUserEvent(LINK(nullptr, sfx2::RecentDocsView, ExecuteHdl_Impl), pLoadRecentFile, true);
     }
 }
 
diff --git a/sfx2/source/dialog/backingwindow.cxx b/sfx2/source/dialog/backingwindow.cxx
index d022c2e..52b4518 100644
--- a/sfx2/source/dialog/backingwindow.cxx
+++ b/sfx2/source/dialog/backingwindow.cxx
@@ -236,24 +236,24 @@ void BackingWindow::initControls()
     }
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::WRITER))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_WRITER;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_WRITER;
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::CALC))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_CALC;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_CALC;
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::IMPRESS))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_IMPRESS;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_IMPRESS;
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::DRAW))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_DRAW;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_DRAW;
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::DATABASE))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_DATABASE;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_DATABASE;
 
     if (aModuleOptions.IsModuleInstalled(SvtModuleOptions::EModule::MATH))
-        mpAllRecentThumbnails->mnFileTypes |= TYPE_MATH;
+        mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_MATH;
 
-    mpAllRecentThumbnails->mnFileTypes |= TYPE_OTHER;
+    mpAllRecentThumbnails->mnFileTypes |= sfx2::ApplicationType::TYPE_OTHER;
     mpAllRecentThumbnails->Reload();
     mpAllRecentThumbnails->ShowTooltips( true );
     mpRecentButton->SetActive(true);
diff --git a/sfx2/source/dialog/backingwindow.hxx b/sfx2/source/dialog/backingwindow.hxx
index 2469409..5d3259b 100644
--- a/sfx2/source/dialog/backingwindow.hxx
+++ b/sfx2/source/dialog/backingwindow.hxx
@@ -79,7 +79,7 @@ class BackingWindow : public vcl::Window, public VclBuilderContainer
     VclPtr<VclBox> mpButtonsBox;
     VclPtr<VclBox> mpSmallButtonsBox;
 
-    VclPtr<RecentDocsView> mpAllRecentThumbnails;
+    VclPtr<sfx2::RecentDocsView> mpAllRecentThumbnails;
     VclPtr<TemplateDefaultView> mpLocalView;
     bool mbLocalViewInitialized;
 


More information about the Libreoffice-commits mailing list