summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-11-19 16:32:49 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-11-22 12:57:32 +0100
commitf853ec317f6af1b8c65cc5bd758371689c75118d (patch)
treeb86d729bf9a9465ee619ead3b5635efa62a1804e /vcl/source/window
parentf31d36966bceb90e261cbecd42634bde4448d527 (diff)
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend loplugin:external to warn about enums". Cases where free functions were moved into an unnamed namespace along with a class, to not break ADL, are in: filter/source/svg/svgexport.cxx sc/source/filter/excel/xelink.cxx sc/source/filter/excel/xilink.cxx svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx All other free functions mentioning moved classes appear to be harmless and not give rise to (silent, even) ADL breakage. (One remaining TODO in compilerplugins/clang/external.cxx is that derived classes are not covered by computeAffectedTypes, even though they could also be affected by ADL-breakage--- but don't seem to be in any acutal case across the code base.) For friend declarations using elaborate type specifiers, like class C1 {}; class C2 { friend class C1; }; * If C2 (but not C1) is moved into an unnamed namespace, the friend declaration must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither qualified nor a template-id and the declaration is a function or an elaborated-type-specifier, the lookup to determine whether the entity has been previously declared shall not consider any scopes outside the innermost enclosing namespace.") * If C1 (but not C2) is moved into an unnamed namespace, the friend declaration must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882> "elaborated-type-specifier friend not looked up in unnamed namespace". Apart from that, to keep changes simple and mostly mechanical (which should help avoid regressions), out-of-line definitions of class members have been left in the enclosing (named) namespace. But explicit specializations of class templates had to be moved into the unnamed namespace to appease <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of template from unnamed namespace using unqualified-id in enclosing namespace". Also, accompanying declarations (of e.g. typedefs or static variables) that could arguably be moved into the unnamed namespace too have been left alone. And in some cases, mention of affected types in blacklists in other loplugins needed to be adapted. And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is not moved into an unnamed namespace (because it is declared in sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler doesn’t give this warning for types defined in the main .C file, as those are unlikely to have multiple definitions." (<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The warned-about classes also don't have multiple definitions in the given test, so disable the warning when including the .cxx. Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4 Reviewed-on: https://gerrit.libreoffice.org/83239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/builder.cxx4
-rw-r--r--vcl/source/window/dockmgr.cxx4
-rw-r--r--vcl/source/window/dockwin.cxx4
-rw-r--r--vcl/source/window/errinf.cxx5
-rw-r--r--vcl/source/window/layout.cxx12
-rw-r--r--vcl/source/window/splitwin.cxx3
-rw-r--r--vcl/source/window/taskpanelist.cxx4
-rw-r--r--vcl/source/window/winproc.cxx32
8 files changed, 66 insertions, 2 deletions
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 5663a2e09989..3936d94026f7 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1593,6 +1593,8 @@ void VclBuilder::cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Wind
extern "C" { static void thisModule() {} }
+namespace {
+
// Don't unload the module on destruction
class NoAutoUnloadModule : public osl::Module
{
@@ -1600,6 +1602,8 @@ public:
~NoAutoUnloadModule() { release(); }
};
+}
+
typedef std::map<OUString, std::shared_ptr<NoAutoUnloadModule>> ModuleMap;
static ModuleMap g_aModuleMap;
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 45708e8d709f..b81741108d28 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -35,6 +35,8 @@
#define DOCKWIN_FLOATSTYLES (WB_SIZEABLE | WB_MOVEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_ROLLABLE )
+namespace {
+
class ImplDockFloatWin2 : public FloatingWindow
{
private:
@@ -63,6 +65,8 @@ public:
virtual bool Close() override;
};
+}
+
ImplDockFloatWin2::ImplDockFloatWin2( vcl::Window* pParent, WinBits nWinBits,
ImplDockingWindowWrapper* pDockingWin ) :
FloatingWindow( pParent, nWinBits ),
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
index 6ac2562d2f41..108a7d5b3700 100644
--- a/vcl/source/window/dockwin.cxx
+++ b/vcl/source/window/dockwin.cxx
@@ -50,6 +50,8 @@ DockingWindow::ImplData::ImplData()
maMaxOutSize = Size( SHRT_MAX, SHRT_MAX );
}
+namespace {
+
class ImplDockFloatWin : public FloatingWindow
{
private:
@@ -75,6 +77,8 @@ public:
virtual bool Close() override;
};
+}
+
ImplDockFloatWin::ImplDockFloatWin( vcl::Window* pParent, WinBits nWinBits,
DockingWindow* pDockingWin ) :
FloatingWindow( pParent, nWinBits ),
diff --git a/vcl/source/window/errinf.cxx b/vcl/source/window/errinf.cxx
index f1e9109f5afb..1f4a60f70dca 100644
--- a/vcl/source/window/errinf.cxx
+++ b/vcl/source/window/errinf.cxx
@@ -28,8 +28,13 @@
#include <vector>
class ErrorHandler;
+
+namespace {
+
class TheErrorRegistry: public rtl::Static<ErrorRegistry, TheErrorRegistry> {};
+}
+
class ErrorStringFactory
{
public:
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 981ac621aa60..db0f26397927 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -684,12 +684,16 @@ void VclButtonBox::setAllocation(const Size &rAllocation)
}
}
+namespace {
+
struct ButtonOrder
{
const char* m_aType;
int const m_nPriority;
};
+}
+
static int getButtonPriority(const OString &rType)
{
static const size_t N_TYPES = 6;
@@ -733,6 +737,8 @@ static int getButtonPriority(const OString &rType)
return -1;
}
+namespace {
+
class sortButtons
{
bool const m_bVerticalContainer;
@@ -744,6 +750,8 @@ public:
bool operator()(const vcl::Window *pA, const vcl::Window *pB) const;
};
+}
+
bool sortButtons::operator()(const vcl::Window *pA, const vcl::Window *pB) const
{
//sort into two groups of pack start and pack end
@@ -791,6 +799,8 @@ void VclButtonBox::sort_native_button_order()
BuilderUtils::reorderWithinParent(aChilds, true);
}
+namespace {
+
struct GridEntry
{
VclPtr<vcl::Window> pChild;
@@ -808,6 +818,8 @@ struct GridEntry
}
};
+}
+
typedef boost::multi_array<GridEntry, 2> array_type;
static array_type assembleGrid(const VclGrid &rGrid);
diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx
index 8e234964ee27..4ae7f4851fda 100644
--- a/vcl/source/window/splitwin.cxx
+++ b/vcl/source/window/splitwin.cxx
@@ -43,6 +43,8 @@
#define SPLIT_WINDOW (sal_uInt16(0x0004))
#define SPLIT_NOSPLIT (sal_uInt16(0x8000))
+namespace {
+
class ImplSplitItem
{
public:
@@ -73,6 +75,7 @@ public:
long mnMaxSize;
};
+}
class ImplSplitSet
{
diff --git a/vcl/source/window/taskpanelist.cxx b/vcl/source/window/taskpanelist.cxx
index 1f382b824907..c7af916d16b0 100644
--- a/vcl/source/window/taskpanelist.cxx
+++ b/vcl/source/window/taskpanelist.cxx
@@ -45,8 +45,6 @@ Point ImplTaskPaneListGetPos( const vcl::Window *w )
return pos;
}
-}
-
// compares window pos left-to-right
struct LTRSort
{
@@ -75,6 +73,8 @@ struct LTRSortBackward
}
};
+}
+
static void ImplTaskPaneListGrabFocus( vcl::Window *pWindow, bool bForward )
{
// put focus in child of floating windows which is typically a toolbar
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 424b8b6cdbfa..ec1228b9fe69 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -241,12 +241,16 @@ static bool ImplCallCommand( const VclPtr<vcl::Window>& pChild, CommandEventId n
* necessary if there already was a popup menu running.
*/
+namespace {
+
struct ContextMenuEvent
{
VclPtr<vcl::Window> pWindow;
Point aChildPos;
};
+}
+
static void ContextMenuEventLink( void* pCEvent, void* )
{
ContextMenuEvent* pEv = static_cast<ContextMenuEvent*>(pCEvent);
@@ -1313,6 +1317,8 @@ static bool shouldReusePreviousMouseWindow(const SalWheelMouseEvent& rPrevEvt, c
return (rEvt.mnX == rPrevEvt.mnX && rEvt.mnY == rPrevEvt.mnY && rEvt.mnTime-rPrevEvt.mnTime < 500/*ms*/);
}
+namespace {
+
class HandleGestureEventBase
{
protected:
@@ -1334,6 +1340,8 @@ public:
virtual ~HandleGestureEventBase() {}
};
+}
+
bool HandleGestureEventBase::Setup()
{
@@ -1423,6 +1431,8 @@ vcl::Window *HandleGestureEventBase::Dispatch(vcl::Window* pMouseWindow)
return pDispatchedTo;
}
+namespace {
+
class HandleWheelEvent : public HandleGestureEventBase
{
private:
@@ -1457,6 +1467,8 @@ public:
bool HandleEvent(const SalWheelMouseEvent& rEvt);
};
+}
+
bool HandleWheelEvent::HandleEvent(const SalWheelMouseEvent& rEvt)
{
if (!Setup())
@@ -1482,6 +1494,8 @@ bool HandleWheelEvent::HandleEvent(const SalWheelMouseEvent& rEvt)
return pSVData->maWinData.mpLastWheelWindow.get();
}
+namespace {
+
class HandleGestureEvent : public HandleGestureEventBase
{
public:
@@ -1492,6 +1506,8 @@ public:
bool HandleEvent();
};
+}
+
bool HandleGestureEvent::HandleEvent()
{
if (!Setup())
@@ -1509,6 +1525,8 @@ static bool ImplHandleWheelEvent(vcl::Window* pWindow, const SalWheelMouseEvent&
return aHandler.HandleEvent(rEvt);
}
+namespace {
+
class HandleSwipeEvent : public HandleGestureEvent
{
private:
@@ -1525,12 +1543,16 @@ public:
}
};
+}
+
static bool ImplHandleSwipe(vcl::Window *pWindow, const SalSwipeEvent& rEvt)
{
HandleSwipeEvent aHandler(pWindow, rEvt);
return aHandler.HandleEvent();
}
+namespace {
+
class HandleLongPressEvent : public HandleGestureEvent
{
private:
@@ -1547,12 +1569,16 @@ public:
}
};
+}
+
static bool ImplHandleLongPress(vcl::Window *pWindow, const SalLongPressEvent& rEvt)
{
HandleLongPressEvent aHandler(pWindow, rEvt);
return aHandler.HandleEvent();
}
+namespace {
+
class HandleGeneralGestureEvent : public HandleGestureEvent
{
private:
@@ -1571,6 +1597,8 @@ public:
}
};
+}
+
static bool ImplHandleGestureEvent(vcl::Window* pWindow, const SalGestureEvent& rEvent)
{
HandleGeneralGestureEvent aHandler(pWindow, rEvent);
@@ -1877,11 +1905,15 @@ static void ImplHandleLoseFocus( vcl::Window* pWindow )
pFirstFloat->EndPopupMode(FloatWinPopupEndFlags::Cancel | FloatWinPopupEndFlags::CloseAll);
}
+namespace {
+
struct DelayedCloseEvent
{
VclPtr<vcl::Window> pWindow;
};
+}
+
static void DelayedCloseEventLink( void* pCEvent, void* )
{
DelayedCloseEvent* pEv = static_cast<DelayedCloseEvent*>(pCEvent);