summaryrefslogtreecommitdiff
path: root/cui
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 /cui
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 'cui')
-rw-r--r--cui/source/dialogs/SpellDialog.cxx5
-rw-r--r--cui/source/dialogs/colorpicker.cxx20
-rw-r--r--cui/source/dialogs/hangulhanjadlg.cxx3
-rw-r--r--cui/source/dialogs/hldocntp.cxx4
-rw-r--r--cui/source/dialogs/hlmarkwn.cxx4
-rw-r--r--cui/source/dialogs/linkdlg.cxx4
-rw-r--r--cui/source/factory/dlgfact.cxx4
-rw-r--r--cui/source/options/optasian.cxx4
-rw-r--r--cui/source/options/optcolor.cxx4
-rw-r--r--cui/source/options/optlingu.cxx11
-rw-r--r--cui/source/options/optpath.cxx4
-rw-r--r--cui/source/options/treeopt.cxx16
-rw-r--r--cui/source/tabpages/autocdlg.cxx8
-rw-r--r--cui/source/tabpages/swpossizetabpage.cxx4
14 files changed, 88 insertions, 7 deletions
diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 9c65d47cf6da..44bca8f89a5b 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -1805,6 +1805,8 @@ void SentenceEditWindow_Impl::SetText( const OUString& rStr )
m_xEditEngine->SetText(rStr);
}
+namespace {
+
struct LanguagePosition_Impl
{
sal_Int32 nPosition;
@@ -1815,6 +1817,9 @@ struct LanguagePosition_Impl
eLanguage(eLang)
{}
};
+
+}
+
typedef std::vector<LanguagePosition_Impl> LanguagePositions_Impl;
static void lcl_InsertBreakPosition_Impl(
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index e3b46bcdec87..565c3ca2c8b1 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -144,6 +144,8 @@ static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& f
}
}
+namespace {
+
class ColorPreviewControl : public weld::CustomWidgetController
{
private:
@@ -172,6 +174,8 @@ public:
}
};
+}
+
void ColorPreviewControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
rRenderContext.SetFillColor(m_aColor);
@@ -187,6 +191,8 @@ enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
const ColorMode DefaultMode = HUE;
+namespace {
+
class ColorFieldControl : public weld::CustomWidgetController
{
public:
@@ -243,6 +249,8 @@ private:
std::vector<sal_uInt16> maPercent_Vert;
};
+}
+
void ColorFieldControl::UpdateBitmap()
{
const Size aSize(GetOutputSizePixel());
@@ -506,6 +514,8 @@ void ColorFieldControl::UpdatePosition()
ShowPosition(Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false);
}
+namespace {
+
class ColorSliderControl : public weld::CustomWidgetController
{
public:
@@ -540,6 +550,8 @@ private:
double mdValue;
};
+}
+
ColorSliderControl::ColorSliderControl()
: meMode( DefaultMode )
, mnLevel( 0 )
@@ -714,6 +726,8 @@ void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double d
}
}
+namespace {
+
class ColorPickerDialog : public weld::GenericDialogController
{
private:
@@ -774,6 +788,8 @@ private:
double mdCyan, mdMagenta, mdYellow, mdKey;
};
+}
+
ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nDialogMode)
: GenericDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker")
, m_xColorField(new weld::CustomWeld(*m_xBuilder, "colorField", m_aColorField))
@@ -1192,6 +1208,8 @@ void ColorPickerDialog::setColorComponent( ColorComponent nComp, double dValue )
typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
+namespace {
+
class ColorPicker : protected ::cppu::BaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses.
public ColorPickerBase
{
@@ -1220,6 +1238,8 @@ private:
Reference<css::awt::XWindow> mxParent;
};
+}
+
OUString ColorPicker_getImplementationName()
{
return "com.sun.star.cui.ColorPicker";
diff --git a/cui/source/dialogs/hangulhanjadlg.cxx b/cui/source/dialogs/hangulhanjadlg.cxx
index e3b0b2e5d592..a90d1725a50d 100644
--- a/cui/source/dialogs/hangulhanjadlg.cxx
+++ b/cui/source/dialogs/hangulhanjadlg.cxx
@@ -76,7 +76,6 @@ namespace svx
m_rDev.Pop();
}
};
- }
/** a class which allows to draw two texts in a pseudo-ruby way (which basically
means one text above or below the other, and a little bit smaller)
@@ -105,6 +104,8 @@ namespace svx
::tools::Rectangle* _pPrimaryLocation, ::tools::Rectangle* _pSecondaryLocation );
};
+ }
+
PseudoRubyText::PseudoRubyText()
: m_ePosition(eAbove)
{
diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index 3e875bef1994..a68388d83031 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -55,6 +55,8 @@ using namespace ::com::sun::star;
|*
|************************************************************************/
+namespace {
+
struct DocumentTypeData
{
OUString aStrURL;
@@ -63,6 +65,8 @@ struct DocumentTypeData
{}
};
+}
+
bool SvxHyperlinkNewDocTp::ImplGetURLObject( const OUString& rPath, const OUString& rBase, INetURLObject& aURLObject ) const
{
bool bIsValidURL = !rPath.isEmpty();
diff --git a/cui/source/dialogs/hlmarkwn.cxx b/cui/source/dialogs/hlmarkwn.cxx
index 08d1798b42e5..3b985b2b0d40 100644
--- a/cui/source/dialogs/hlmarkwn.cxx
+++ b/cui/source/dialogs/hlmarkwn.cxx
@@ -41,6 +41,8 @@
using namespace ::com::sun::star;
+namespace {
+
// Userdata-struct for tree-entries
struct TargetData
{
@@ -55,6 +57,8 @@ struct TargetData
}
};
+}
+
//*** Window-Class ***
// Constructor / Destructor
SvxHlinkDlgMarkWnd::SvxHlinkDlgMarkWnd(weld::Window* pParentDialog, SvxHyperlinkTabPageBase *pParentPage)
diff --git a/cui/source/dialogs/linkdlg.cxx b/cui/source/dialogs/linkdlg.cxx
index f8388ece411c..c70fa676a315 100644
--- a/cui/source/dialogs/linkdlg.cxx
+++ b/cui/source/dialogs/linkdlg.cxx
@@ -46,6 +46,8 @@
using namespace sfx2;
using namespace ::com::sun::star;
+namespace {
+
class SvBaseLinkMemberList {
private:
std::vector<SvBaseLink*> mLinks;
@@ -71,6 +73,8 @@ public:
}
};
+}
+
SvBaseLinksDlg::SvBaseLinksDlg(weld::Window * pParent, LinkManager* pMgr, bool bHtmlMode)
: GenericDialogController(pParent, "cui/ui/baselinksdialog.ui", "BaseLinksDialog")
, aStrAutolink( CuiResId( STR_AUTOLINK ) )
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 80e28b271b63..039f713d2279 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1375,6 +1375,8 @@ VclPtr<AbstractSvxPostItDialog> AbstractDialogFactory_Impl::CreateSvxPostItDialo
return VclPtr<AbstractSvxPostItDialog_Impl>::Create(std::make_unique<SvxPostItDialog>(pParent, rCoreSet, bPrevNext));
}
+namespace {
+
class SvxMacroAssignDialog : public VclAbstractDialog
{
public:
@@ -1393,6 +1395,8 @@ private:
std::unique_ptr<SvxMacroAssignDlg> m_xDialog;
};
+}
+
short SvxMacroAssignDialog::Execute()
{
return m_xDialog->run();
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx
index 89feb5760f41..07d68df2dd65 100644
--- a/cui/source/options/optasian.cxx
+++ b/cui/source/options/optasian.cxx
@@ -44,12 +44,16 @@ using namespace com::sun::star::beans;
const sal_Char cIsKernAsianPunctuation[] = "IsKernAsianPunctuation";
const sal_Char cCharacterCompressionType[] = "CharacterCompressionType";
+namespace {
+
struct SvxForbiddenChars_Impl
{
bool bRemoved;
std::unique_ptr<ForbiddenCharacters> pCharacters;
};
+}
+
struct SvxAsianLayoutPage_Impl
{
SvxAsianConfig aConfig;
diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx
index 56e75fecd969..244cbbbf0dea 100644
--- a/cui/source/options/optcolor.cxx
+++ b/cui/source/options/optcolor.cxx
@@ -159,8 +159,6 @@ const vEntryInfo[] =
#undef IDS
};
-} // namespace
-
// ColorConfigWindow_Impl
class ColorConfigWindow_Impl
@@ -260,6 +258,8 @@ private:
bool IsGroupVisible (Group) const;
};
+} // namespace
+
// ColorConfigWindow_Impl::Chapter
// ctor for default groups
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index 5e394e9753e3..dca1b491932f 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -113,6 +113,8 @@ static bool KillFile_Impl( const OUString& rURL )
#define TYPE_HYPH sal_uInt8(3)
#define TYPE_THES sal_uInt8(4)
+namespace {
+
class ModuleUserData_Impl
{
bool bParent;
@@ -156,6 +158,7 @@ public:
bool IsDeletable() const { return static_cast<bool>((nVal >> 10) & 0x01); }
};
+}
DicUserData::DicUserData(
sal_uInt16 nEID,
@@ -212,6 +215,8 @@ static OUString lcl_GetPropertyName( EID_OPTIONS eEntryId )
return OUString::createFromAscii( aEidToPropName[ static_cast<int>(eEntryId) ] );
}
+namespace {
+
class OptionsBreakSet : public weld::GenericDialogController
{
std::unique_ptr<weld::Widget> m_xBeforeFrame;
@@ -273,6 +278,8 @@ public:
void SetNumericValue( sal_uInt8 nNumVal );
};
+}
+
OptionsUserData::OptionsUserData( sal_uInt16 nEID,
bool bHasNV, sal_uInt16 nNumVal,
bool bCheckable, bool bChecked )
@@ -298,6 +305,8 @@ void OptionsUserData::SetNumericValue( sal_uInt8 nNumVal )
// ServiceInfo_Impl ----------------------------------------------------
+namespace {
+
struct ServiceInfo_Impl
{
OUString sDisplayName;
@@ -314,6 +323,8 @@ struct ServiceInfo_Impl
ServiceInfo_Impl() : bConfigured(false) {}
};
+}
+
typedef std::vector< ServiceInfo_Impl > ServiceInfoArr;
typedef std::map< LanguageType, Sequence< OUString > > LangImplNameTable;
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index b287852f2329..a35f98ec3248 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -74,6 +74,8 @@ struct OptPath_Impl
}
};
+namespace {
+
struct PathUserData_Impl
{
sal_uInt16 nRealId;
@@ -96,6 +98,8 @@ struct Handle2CfgNameMapping_Impl
const char* m_pCfgName;
};
+}
+
static Handle2CfgNameMapping_Impl const Hdl2CfgMap_Impl[] =
{
{ SvtPathOptions::PATH_AUTOCORRECT, "AutoCorrect" },
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index f36a8ab76029..8b7c32b051bd 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -130,6 +130,8 @@ static OUString GetViewOptUserItem( const SvtViewOptions& rOpt )
return aUserData;
}
+namespace {
+
struct ModuleToGroupNameMap_Impl
{
const char* m_pModule;
@@ -137,6 +139,8 @@ struct ModuleToGroupNameMap_Impl
sal_uInt16 m_nNodeId;
};
+}
+
static ModuleToGroupNameMap_Impl ModuleMap[] =
{
{ "ProductName", OUString(), SID_GENERAL_OPTIONS },
@@ -232,6 +236,8 @@ static sal_uInt16 getGroupNodeId( const OUString& rModule )
return nNodeId;
}
+namespace {
+
class MailMergeCfg_Impl : public utl::ConfigItem
{
private:
@@ -250,6 +256,8 @@ public:
};
+}
+
MailMergeCfg_Impl::MailMergeCfg_Impl() :
utl::ConfigItem("Office.Writer/MailMergeWizard"),
bIsEmailSupported(false)
@@ -314,6 +322,8 @@ static std::unique_ptr<SfxTabPage> CreateGeneralTabPage(sal_uInt16 nId, weld::Co
return fnCreate ? (*fnCreate)( pPage, pController, &rSet ) : nullptr;
}
+namespace {
+
struct OptionsMapping_Impl
{
const char* m_pGroupName;
@@ -321,6 +331,8 @@ struct OptionsMapping_Impl
sal_uInt16 m_nPageId;
};
+}
+
static OptionsMapping_Impl const OptionsMap_Impl[] =
{
// GROUP PAGE PAGE-ID
@@ -450,6 +462,8 @@ struct OptionsPageInfo
explicit OptionsPageInfo( sal_uInt16 nId ) : m_nPageId( nId ) {}
};
+namespace {
+
struct OptionsGroupInfo
{
std::unique_ptr<SfxItemSet> m_pInItemSet;
@@ -463,6 +477,8 @@ struct OptionsGroupInfo
m_pModule( pMod ), m_nDialogId( nId ) {}
};
+}
+
#define INI_LIST() \
, m_pParent ( pParent )\
, sTitle ( m_xDialog->get_title() )\
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index edb129d8c227..4952e7b8203c 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -283,6 +283,8 @@ void OfaAutocorrOptionsPage::Reset( const SfxItemSet* )
/* */
/*********************************************************************/
+namespace {
+
struct ImpUserData
{
OUString *pString;
@@ -321,8 +323,6 @@ public:
/* */
/*********************************************************************/
-namespace {
-
enum OfaAutoFmtOptions
{
USE_REPLACE_TABLE,
@@ -2139,6 +2139,8 @@ std::unique_ptr<SfxTabPage> OfaSmartTagOptionsTabPage::Create(weld::Container* p
return std::make_unique<OfaSmartTagOptionsTabPage>(pPage, pController, *rSet);
}
+namespace {
+
/** This struct is used to associate list box entries with smart tag data
*/
struct ImplSmartTagLBUserData
@@ -2155,6 +2157,8 @@ struct ImplSmartTagLBUserData
mnSmartTagIdx( nSmartTagIdx ) {}
};
+}
+
/** Clears m_xSmartTagTypesLB
*/
void OfaSmartTagOptionsTabPage::ClearListBox()
diff --git a/cui/source/tabpages/swpossizetabpage.cxx b/cui/source/tabpages/swpossizetabpage.cxx
index 33a0649d21e6..24251a1800c1 100644
--- a/cui/source/tabpages/swpossizetabpage.cxx
+++ b/cui/source/tabpages/swpossizetabpage.cxx
@@ -55,6 +55,8 @@ struct FrmMap
LB nLBRelations;
};
+namespace {
+
struct RelationMap
{
SvxSwFramePosString::StringId eStrId;
@@ -68,8 +70,6 @@ struct StringIdPair_Impl
SvxSwFramePosString::StringId eVert;
};
-namespace {
-
enum class LB {
NONE = 0x000000,
Frame = 0x000001, // paragraph text area