summaryrefslogtreecommitdiff
path: root/sw/source/core/unocore
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 /sw/source/core/unocore
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 'sw/source/core/unocore')
-rw-r--r--sw/source/core/unocore/unocoll.cxx12
-rw-r--r--sw/source/core/unocore/unofield.cxx8
-rw-r--r--sw/source/core/unocore/unoframe.cxx12
-rw-r--r--sw/source/core/unocore/unoidx.cxx12
-rw-r--r--sw/source/core/unocore/unoobj2.cxx15
-rw-r--r--sw/source/core/unocore/unoparagraph.cxx3
-rw-r--r--sw/source/core/unocore/unoportenum.cxx8
-rw-r--r--sw/source/core/unocore/unorefmk.cxx8
-rw-r--r--sw/source/core/unocore/unosect.cxx4
-rw-r--r--sw/source/core/unocore/unostyle.cxx18
-rw-r--r--sw/source/core/unocore/unotbl.cxx4
-rw-r--r--sw/source/core/unocore/unotext.cxx4
12 files changed, 102 insertions, 6 deletions
diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx
index 787f38918915..ffd3316faf7f 100644
--- a/sw/source/core/unocore/unocoll.cxx
+++ b/sw/source/core/unocore/unocoll.cxx
@@ -92,6 +92,8 @@ using namespace ::com::sun::star::lang;
#if HAVE_FEATURE_SCRIPTING
+namespace {
+
class SwVbaCodeNameProvider : public ::cppu::WeakImplHelper< document::XCodeNameQuery >
{
SwDocShell* const mpDocShell;
@@ -168,8 +170,12 @@ public:
}
};
+}
+
typedef std::unordered_map< OUString, OUString > StringHashMap;
+namespace {
+
class SwVbaProjectNameProvider : public ::cppu::WeakImplHelper< container::XNameContainer >
{
StringHashMap mTemplateToProject;
@@ -268,14 +274,20 @@ public:
};
+}
+
#endif
+namespace {
+
struct ProvNamesId_Type
{
const char * pName;
SwServiceType const nType;
};
+}
+
// note: this thing is indexed as an array, so do not insert/remove entries!
const ProvNamesId_Type aProvNamesId[] =
{
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index b5b7f4e1a88e..90b014202640 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -128,12 +128,16 @@ static const sal_uInt16 aDocInfoSubTypeFromService[] =
DI_DOCNO //PROPERTY_MAP_FLDTYP_DOCINFO_REVISION
};
+namespace {
+
struct ServiceIdResId
{
SwFieldIds const nResId;
SwServiceType const nServiceId;
};
+}
+
static const ServiceIdResId aServiceToRes[] =
{
{SwFieldIds::DateTime, SwServiceType::FieldTypeDateTime },
@@ -1071,6 +1075,8 @@ OUString SwXFieldMaster::LocalizeFormula(
return rFormula;
}
+namespace {
+
struct SwFieldProperties_Impl
{
OUString sPar1;
@@ -1112,6 +1118,8 @@ struct SwFieldProperties_Impl
{}
};
+}
+
class SwXTextField::Impl
: public SvtListener
{
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 294db651c919..7dbd91d656d4 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -962,6 +962,8 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
return bRet;
}
+namespace {
+
class SwFrameProperties_Impl : public BaseFrameProperties_Impl
{
public:
@@ -970,6 +972,8 @@ public:
bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrameSet, SfxItemSet& rSet, bool& rSizeFound) override;
};
+}
+
SwFrameProperties_Impl::SwFrameProperties_Impl():
BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_FRAME)*/ )
{
@@ -1026,6 +1030,8 @@ bool SwFrameProperties_Impl::AnyToItemSet(SwDoc *pDoc, SfxItemSet& rSet, SfxItem
return bRet;
}
+namespace {
+
class SwGraphicProperties_Impl : public BaseFrameProperties_Impl
{
public:
@@ -1034,6 +1040,8 @@ public:
virtual bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrameSet, SfxItemSet& rSet, bool& rSizeFound) override;
};
+}
+
SwGraphicProperties_Impl::SwGraphicProperties_Impl( ) :
BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_GRAPHIC)*/ )
{
@@ -1125,6 +1133,8 @@ bool SwGraphicProperties_Impl::AnyToItemSet(
return bRet;
}
+namespace {
+
class SwOLEProperties_Impl : public SwFrameProperties_Impl
{
public:
@@ -1134,6 +1144,8 @@ public:
virtual bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrameSet, SfxItemSet& rSet, bool& rSizeFound) override;
};
+}
+
bool SwOLEProperties_Impl::AnyToItemSet(
SwDoc* pDoc, SfxItemSet& rFrameSet, SfxItemSet& rSet, bool& rSizeFound)
{
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index ae93e9c63b07..87e06e218d7d 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -245,6 +245,8 @@ public:
};
+namespace {
+
class SwDocIndexDescriptorProperties_Impl
{
private:
@@ -259,6 +261,8 @@ public:
void SetTypeName(const OUString& rSet) { m_sUserTOXTypeName = rSet; }
};
+}
+
SwDocIndexDescriptorProperties_Impl::SwDocIndexDescriptorProperties_Impl(
SwTOXType const*const pType)
{
@@ -1884,6 +1888,8 @@ SwXDocumentIndexMark::attach(
m_pImpl->m_bIsDescriptor = false;
}
+namespace {
+
template<typename T> struct NotContainedIn
{
std::vector<T> const& m_rVector;
@@ -1895,6 +1901,8 @@ template<typename T> struct NotContainedIn
}
};
+}
+
void SwXDocumentIndexMark::Impl::InsertTOXMark(
SwTOXType & rTOXType, SwTOXMark & rMark, SwPaM & rPam,
SwXTextCursor const*const pTextCursor)
@@ -2639,11 +2647,15 @@ SwXDocumentIndex::TokenAccess_Impl::getSupportedServiceNames()
return { "com.sun.star.text.DocumentIndexLevelFormat" };
}
+namespace {
+
struct TokenType_ {
const char *pName;
enum FormTokenType const eTokenType;
};
+}
+
static const struct TokenType_ g_TokenTypes[] =
{
{ "TokenEntryNumber", TOKEN_ENTRY_NO },
diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx
index 502e2e74c2dd..e4a282212751 100644
--- a/sw/source/core/unocore/unoobj2.cxx
+++ b/sw/source/core/unocore/unoobj2.cxx
@@ -138,6 +138,8 @@ void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
} // namespace sw
+namespace {
+
struct FrameClientSortListLess
{
bool operator() (FrameClientSortListEntry const& r1,
@@ -148,8 +150,6 @@ struct FrameClientSortListLess
}
};
-namespace
-{
void lcl_CollectFrameAtNodeWithLayout(const SwContentFrame* pCFrame,
FrameClientSortList_t& rFrames,
const RndStdIds nAnchorType)
@@ -399,6 +399,8 @@ void SwUnoCursorHelper::GetCursorAttr(SwPaM & rPam,
}
}
+namespace {
+
struct SwXParagraphEnumerationImpl final : public SwXParagraphEnumeration
{
uno::Reference< text::XText > const m_xParentText;
@@ -485,6 +487,8 @@ struct SwXParagraphEnumerationImpl final : public SwXParagraphEnumeration
bool IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable);
};
+}
+
SwXParagraphEnumeration* SwXParagraphEnumeration::Create(
uno::Reference< text::XText > const& xParent,
const std::shared_ptr<SwUnoCursor>& pCursor,
@@ -1418,6 +1422,8 @@ SwXTextRange::makeRedline(
SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
}
+namespace {
+
struct SwXTextRangesImpl final : public SwXTextRanges
{
@@ -1462,6 +1468,8 @@ struct SwXTextRangesImpl final : public SwXTextRanges
sw::UnoCursorPointer m_pUnoCursor;
};
+}
+
void SwXTextRangesImpl::MakeRanges()
{
if (GetCursor())
@@ -1540,6 +1548,8 @@ void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
}
+namespace {
+
struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
{
// XServiceInfo
@@ -1584,6 +1594,7 @@ struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
::sw::UnoCursorPointer m_pUnoCursor;
};
+}
SwXParaFrameEnumeration* SwXParaFrameEnumeration::Create(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat)
{ return new SwXParaFrameEnumerationImpl(rPaM, eParaFrameMode, pFormat); }
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index 2b632ab78e79..2d3e33922aa3 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -59,6 +59,7 @@
using namespace ::com::sun::star;
+namespace {
class SwParaSelection
{
@@ -68,6 +69,8 @@ public:
~SwParaSelection();
};
+}
+
SwParaSelection::SwParaSelection(SwCursor & rCursor)
: m_rCursor(rCursor)
{
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 42d4658138a1..9cba2c7d9dd4 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -685,6 +685,8 @@ static void lcl_ExportSoftPageBreak(
}
}
+namespace {
+
struct SwXRedlinePortion_Impl
{
const SwRangeRedline* m_pRedline;
@@ -703,9 +705,13 @@ struct SwXRedlinePortion_Impl
}
};
+}
+
typedef std::shared_ptr < SwXRedlinePortion_Impl >
SwXRedlinePortion_ImplSharedPtr;
+namespace {
+
struct RedlineCompareStruct
{
static const SwPosition& getPosition ( const SwXRedlinePortion_ImplSharedPtr &r )
@@ -720,6 +726,8 @@ struct RedlineCompareStruct
}
};
+}
+
typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct >
SwXRedlinePortion_ImplList;
diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx
index adab40c9d319..ee5756c761cd 100644
--- a/sw/source/core/unocore/unorefmk.cxx
+++ b/sw/source/core/unocore/unorefmk.cxx
@@ -187,6 +187,8 @@ SwXReferenceMark::getSupportedServiceNames()
};
}
+namespace {
+
template<typename T> struct NotContainedIn
{
std::vector<T> const& m_rVector;
@@ -198,6 +200,8 @@ template<typename T> struct NotContainedIn
}
};
+}
+
void SwXReferenceMark::Impl::InsertRefMark(SwPaM& rPam,
SwXTextCursor const*const pCursor)
{
@@ -492,6 +496,8 @@ void SAL_CALL SwXReferenceMark::removeVetoableChangeListener(
OSL_FAIL("SwXReferenceMark::removeVetoableChangeListener(): not implemented");
}
+namespace {
+
class SwXMetaText : public cppu::OWeakObject, public SwXText
{
private:
@@ -530,6 +536,8 @@ public:
};
+}
+
SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta)
: SwXText(&rDoc, CursorType::Meta)
, m_rMeta(rMeta)
diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx
index 05c4ba13275a..ff12dc325695 100644
--- a/sw/source/core/unocore/unosect.cxx
+++ b/sw/source/core/unocore/unosect.cxx
@@ -67,6 +67,8 @@
using namespace ::com::sun::star;
+namespace {
+
struct SwTextSectionProperties_Impl
{
uno::Sequence<sal_Int8> m_Password;
@@ -103,6 +105,8 @@ struct SwTextSectionProperties_Impl
};
+}
+
class SwXTextSection::Impl
: public SvtListener
{
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 2169cb9cd285..acf2ae04d9f7 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -114,11 +114,11 @@
#include <set>
#include <limits>
+namespace {
+
class SwXStyle;
class SwStyleProperties_Impl;
-namespace
-{
struct StyleFamilyEntry
{
using GetCountOrName_t = std::function<sal_Int32 (const SwDoc&, OUString*, sal_Int32)>;
@@ -184,6 +184,8 @@ using namespace ::com::sun::star;
namespace sw
{
+ namespace {
+
class XStyleFamily : public cppu::WeakImplHelper
<
container::XNameContainer,
@@ -281,8 +283,11 @@ namespace sw
{ return { "com.sun.star.style.StyleFamily" }; }
};
+ }
}
+namespace {
+
class SwStyleBase_Impl;
class SwXStyle : public cppu::WeakImplHelper
<
@@ -454,6 +459,7 @@ public:
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
};
+}
using sw::XStyleFamily;
@@ -1114,6 +1120,8 @@ static const std::vector<ParagraphStyleCategoryEntry>* lcl_GetParagraphStyleCate
return our_pParagraphStyleCategoryEntries;
}
+namespace {
+
class SwStyleProperties_Impl
{
const PropertyEntryVector_t aPropertyEntries;
@@ -1168,6 +1176,8 @@ public:
}
};
+}
+
static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum(SfxStyleFamily eFamily)
{
auto pEntries(lcl_GetStyleFamilyEntries());
@@ -1463,6 +1473,8 @@ void SwXStyle::ApplyDescriptorProperties()
m_pPropertiesImpl->Apply(*this);
}
+namespace {
+
class SwStyleBase_Impl
{
private:
@@ -1528,8 +1540,6 @@ public:
};
};
-namespace
-{
const char* STR_POOLPAGE_ARY[] =
{
// Page styles
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 1ad6dc454657..77330375aebf 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1805,6 +1805,8 @@ void SwXTextTableCursor::Notify( const SfxHint& rHint )
// SwXTextTable ===========================================================
+namespace {
+
class SwTableProperties_Impl
{
SwUnoCursorHelper::SwAnyMapHelper aAnyMap;
@@ -1819,6 +1821,8 @@ public:
void ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc);
};
+}
+
SwTableProperties_Impl::SwTableProperties_Impl()
{ }
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index d49b07e35cb9..7b528399a035 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1777,6 +1777,8 @@ SwXText::convertToTextFrame(
return xRet;
}
+namespace {
+
// Move previously imported paragraphs into a new text table.
struct VerticallyMergedCell
{
@@ -1793,6 +1795,8 @@ struct VerticallyMergedCell
}
};
+}
+
#define COL_POS_FUZZY 2
static bool lcl_SimilarPosition( const sal_Int32 nPos1, const sal_Int32 nPos2 )