summaryrefslogtreecommitdiff
path: root/sw/source/filter/html
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/filter/html
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/filter/html')
-rw-r--r--sw/source/filter/html/css1atr.cxx4
-rw-r--r--sw/source/filter/html/htmlatr.cxx12
-rw-r--r--sw/source/filter/html/htmlfld.cxx4
-rw-r--r--sw/source/filter/html/htmlform.cxx4
-rw-r--r--sw/source/filter/html/htmltab.cxx24
-rw-r--r--sw/source/filter/html/htmltabw.cxx4
-rw-r--r--sw/source/filter/html/svxcss1.cxx8
7 files changed, 58 insertions, 2 deletions
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 909ec61ba98c..093409868ebc 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -210,6 +210,8 @@ OString GetCSS1_Color(const Color& rColor)
return "#" + lclConvToHex(rColor.GetRed()) + lclConvToHex(rColor.GetGreen()) + lclConvToHex(rColor.GetBlue());
}
+namespace {
+
class SwCSS1OutMode
{
SwHTMLWriter& rWrt;
@@ -234,6 +236,8 @@ public:
}
};
+}
+
void SwHTMLWriter::OutCSS1_Property( const sal_Char *pProp,
const sal_Char *pVal,
const OUString *pSVal )
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 67ca2a1b4aec..72c3e20b68e8 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -201,6 +201,8 @@ sal_uInt16 SwHTMLWriter::GetCSS1ScriptForScriptType( sal_uInt16 nScriptType )
* Otherwise, attributes of the format are output as well.
*/
+namespace {
+
struct SwHTMLTextCollOutputInfo
{
OString aToken; // End token to be output
@@ -223,6 +225,8 @@ struct SwHTMLTextCollOutputInfo
bool ShouldOutputToken() const { return bOutPara || !HasParaToken(); }
};
+}
+
SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTemplate,
bool bOutStyles,
LanguageType eDfltLang,
@@ -1029,6 +1033,8 @@ static void OutHTML_SwFormatOff( Writer& rWrt, const SwHTMLTextCollOutputInfo& r
}
}
+namespace {
+
class HTMLStartEndPos
{
sal_Int32 nStart;
@@ -1048,6 +1054,8 @@ public:
void SetEnd( sal_Int32 nE ) { nEnd = nE; }
};
+}
+
HTMLStartEndPos::HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
sal_Int32 nE ) :
nStart( nStt ),
@@ -1069,8 +1077,6 @@ enum HTMLOnOffState { HTML_NOT_SUPPORTED, // unsupported Attribute
HTML_DROPCAP_VALUE, // DropCap-Attribute
HTML_AUTOFMT_VALUE }; // Attribute for automatic character styles
-}
-
class HTMLEndPosLst
{
HTMLStartEndPositions aStartLst; // list, sorted for start positions
@@ -1153,6 +1159,8 @@ public:
bool IsHTMLMode( sal_uLong nMode ) const { return (nHTMLMode & nMode) != 0; }
};
+}
+
void HTMLEndPosLst::InsertItem_( HTMLStartEndPos *pPos, HTMLStartEndPositions::size_type nEndPos )
{
// Insert the attribute in the Start list behind all attributes that
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 92ecf5578909..e7de3fad7ee6 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -38,12 +38,16 @@
using namespace nsSwDocInfoSubType;
using namespace ::com::sun::star;
+namespace {
+
struct HTMLNumFormatTableEntry
{
const sal_Char *pName;
NfIndexTableOffset const eFormat;
};
+}
+
static HTMLOptionEnum<SwFieldIds> const aHTMLFieldTypeTable[] =
{
{ OOO_STRING_SW_HTML_FT_author, SwFieldIds::Author },
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index 13f33ac57839..6f536bab0bdc 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -365,6 +365,8 @@ const uno::Reference< script::XEventAttacherManager >&
return m_xFormEventManager;
}
+namespace {
+
class SwHTMLImageWatcher :
public cppu::WeakImplHelper< awt::XImageConsumer, XEventListener >
{
@@ -408,6 +410,8 @@ public:
virtual void SAL_CALL disposing( const EventObject& Source ) override;
};
+}
+
SwHTMLImageWatcher::SwHTMLImageWatcher(
const uno::Reference< drawing::XShape >& rShape,
bool bWidth, bool bHeight ) :
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 0d659d7dfd65..12153fb74c4d 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -82,6 +82,8 @@ static HTMLOptionEnum<sal_Int16> const aHTMLTableVAlignTable[] =
// table tags options
+namespace {
+
struct HTMLTableOptions
{
sal_uInt16 nCols;
@@ -165,6 +167,8 @@ public:
size_t GetContextStAttrMin() const { return nContextStAttrMin; }
};
+}
+
// Cell content is a linked list with SwStartNodes and
// HTMLTables.
@@ -208,6 +212,8 @@ public:
const std::shared_ptr<SwHTMLTableLayoutCnts>& CreateLayoutInfo();
};
+namespace {
+
// Cell of a HTML table
class HTMLTableCell
{
@@ -271,9 +277,13 @@ public:
bool IsCovered() const { return mbCovered; }
};
+}
+
// Row of a HTML table
typedef std::vector<HTMLTableCell> HTMLTableCells;
+namespace {
+
class HTMLTableRow
{
HTMLTableCells m_aCells; ///< cells of the row
@@ -365,6 +375,8 @@ public:
std::unique_ptr<SwHTMLTableLayoutColumn> CreateLayoutInfo();
};
+}
+
// HTML table
typedef std::vector<HTMLTableRow> HTMLTableRows;
@@ -3874,6 +3886,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
xSaveStruct.reset();
}
+namespace {
+
class RowSaveStruct : public SwPendingData
{
public:
@@ -3886,6 +3900,8 @@ public:
{}
};
+}
+
void SwHTMLParser::BuildTableRow( HTMLTable *pCurTable, bool bReadOptions,
SvxAdjust eGrpAdjust,
sal_Int16 eGrpVertOri )
@@ -4245,6 +4261,8 @@ void SwHTMLParser::BuildTableSection( HTMLTable *pCurTable,
// now we stand (perhaps) in front of <TBODY>,... or </TABLE>
}
+namespace {
+
struct TableColGrpSaveStruct : public SwPendingData
{
sal_uInt16 nColGrpSpan;
@@ -4258,6 +4276,8 @@ struct TableColGrpSaveStruct : public SwPendingData
inline void CloseColGroup( HTMLTable *pTable );
};
+}
+
inline TableColGrpSaveStruct::TableColGrpSaveStruct() :
nColGrpSpan( 1 ), nColGrpWidth( 0 ),
bRelColGrpWidth( false ), eColGrpAdjust( SvxAdjust::End ),
@@ -4677,6 +4697,8 @@ void SwHTMLParser::BuildTableCaption( HTMLTable *pCurTable )
*m_pPam->GetPoint() = xSaveStruct->GetPos();
}
+namespace {
+
class TableSaveStruct : public SwPendingData
{
public:
@@ -4692,6 +4714,8 @@ public:
void MakeTable( sal_uInt16 nWidth, SwPosition& rPos, SwDoc *pDoc );
};
+}
+
void TableSaveStruct::MakeTable( sal_uInt16 nWidth, SwPosition& rPos, SwDoc *pDoc )
{
m_xCurrentTable->MakeTable(nullptr, nWidth);
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index 577a9f5c7b11..b34ae8485d6e 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -56,6 +56,8 @@
using namespace ::com::sun::star;
+namespace {
+
class SwHTMLWrtTable : public SwWriteTable
{
static void Pixelize( sal_uInt16& rValue );
@@ -88,6 +90,8 @@ public:
sal_uInt16 nHSpace=0, sal_uInt16 nVSpace=0 ) const;
};
+}
+
SwHTMLWrtTable::SwHTMLWrtTable( const SwTableLines& rLines, long nWidth,
sal_uInt32 nBWidth, bool bRel,
sal_uInt16 nLSub, sal_uInt16 nRSub,
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 721a9e4afd59..cbfbe2e919f3 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -256,6 +256,8 @@ static sal_uInt16 const aBorderWidths[] =
#undef SBORDER_ENTRY
#undef DBORDER_ENTRY
+namespace {
+
struct SvxCSS1ItemIds
{
sal_uInt16 nFont;
@@ -295,6 +297,8 @@ struct SvxCSS1ItemIds
sal_uInt16 nDirection;
};
+}
+
static SvxCSS1ItemIds aItemIds;
struct SvxCSS1BorderInfo
@@ -3062,6 +3066,8 @@ static void ParseCSS1_so_language( const CSS1Expression *pExpr,
}
}
+namespace {
+
// the assignment of property to parsing function
struct CSS1PropEntry
{
@@ -3069,6 +3075,8 @@ struct CSS1PropEntry
FnParseCSS1Prop pFunc;
};
+}
+
#define CSS1_PROP_ENTRY(p) \
{ sCSS1_P_##p, ParseCSS1_##p }