summaryrefslogtreecommitdiff
path: root/writerperfect
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 /writerperfect
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 'writerperfect')
-rw-r--r--writerperfect/source/calc/MSWorksCalcImportFilter.cxx3
-rw-r--r--writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx6
-rw-r--r--writerperfect/source/writer/exp/XMLTextFrameContext.cxx6
-rw-r--r--writerperfect/source/writer/exp/txtparai.cxx27
-rw-r--r--writerperfect/source/writer/exp/txtstyli.cxx24
-rw-r--r--writerperfect/source/writer/exp/xmlfmt.cxx3
-rw-r--r--writerperfect/source/writer/exp/xmlimp.cxx5
-rw-r--r--writerperfect/source/writer/exp/xmlmetai.cxx15
-rw-r--r--writerperfect/source/writer/exp/xmltbli.cxx6
9 files changed, 94 insertions, 1 deletions
diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
index 0ed1903172e1..b2f00e437e3a 100644
--- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
+++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx
@@ -58,6 +58,8 @@ catch (...)
return uno::Reference<sdbc::XResultSet>();
}
+namespace
+{
/** internal class used to create a structured RVNGInputStream from a list of path and their short names
*/
class FolderStream : public librevenge::RVNGInputStream
@@ -170,6 +172,7 @@ private:
FolderStream& operator=(const FolderStream&) = delete;
};
}
+}
////////////////////////////////////////////////////////////
bool MSWorksCalcImportFilter::doImportDocument(weld::Window* pParent,
diff --git a/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx b/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx
index 15753306a97d..d11ad62e7357 100644
--- a/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx
+++ b/writerperfect/source/writer/exp/XMLFootnoteImportContext.cxx
@@ -20,6 +20,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <text:note-citation>.
class XMLTextNoteCitationContext : public XMLImportContext
{
@@ -33,6 +35,7 @@ private:
librevenge::RVNGPropertyList& m_rProperties;
OUString m_aCharacters;
};
+}
XMLTextNoteCitationContext::XMLTextNoteCitationContext(XMLImport& rImport,
librevenge::RVNGPropertyList& rProperties)
@@ -51,6 +54,8 @@ void XMLTextNoteCitationContext::characters(const OUString& rCharacters)
m_aCharacters += rCharacters;
}
+namespace
+{
/// Handler for <text:note-body>.
class XMLFootnoteBodyImportContext : public XMLImportContext
{
@@ -70,6 +75,7 @@ public:
private:
const librevenge::RVNGPropertyList& m_rProperties;
};
+}
XMLFootnoteBodyImportContext::XMLFootnoteBodyImportContext(
XMLImport& rImport, const librevenge::RVNGPropertyList& rProperties)
diff --git a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
index dc62f8bf85ce..23a60970bc1a 100644
--- a/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
+++ b/writerperfect/source/writer/exp/XMLTextFrameContext.cxx
@@ -22,6 +22,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <draw:text-box>.
class XMLTextBoxContext : public XMLImportContext
{
@@ -37,6 +39,7 @@ public:
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
void SAL_CALL endElement(const OUString& rName) override;
};
+}
XMLTextBoxContext::XMLTextBoxContext(XMLImport& rImport)
: XMLImportContext(rImport)
@@ -61,6 +64,8 @@ void XMLTextBoxContext::endElement(const OUString& /*rName*/)
GetImport().GetGenerator().closeTextBox();
}
+namespace
+{
/// Handler for <draw:image>.
class XMLTextImageContext : public XMLImportContext
{
@@ -80,6 +85,7 @@ private:
OString m_aMimeType;
rtl::Reference<XMLBase64ImportContext> m_xBinaryData;
};
+}
XMLTextImageContext::XMLTextImageContext(XMLImport& rImport)
: XMLImportContext(rImport)
diff --git a/writerperfect/source/writer/exp/txtparai.cxx b/writerperfect/source/writer/exp/txtparai.cxx
index a129db80763d..e3ba3bde1f26 100644
--- a/writerperfect/source/writer/exp/txtparai.cxx
+++ b/writerperfect/source/writer/exp/txtparai.cxx
@@ -54,6 +54,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <text:sequence>.
class XMLTextSequenceContext : public XMLImportContext
{
@@ -65,6 +67,7 @@ public:
private:
librevenge::RVNGPropertyList m_aPropertyList;
};
+}
XMLTextSequenceContext::XMLTextSequenceContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -86,6 +89,8 @@ void XMLTextSequenceContext::characters(const OUString& rChars)
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <text:span>.
class XMLSpanContext : public XMLImportContext
{
@@ -104,6 +109,7 @@ public:
private:
librevenge::RVNGPropertyList m_aPropertyList;
};
+}
XMLSpanContext::XMLSpanContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -150,6 +156,8 @@ void XMLSpanContext::characters(const OUString& rChars)
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <text:ruby>.
class XMLRubyContext : public XMLImportContext
{
@@ -203,6 +211,7 @@ public:
private:
XMLRubyContext& m_rParent;
};
+}
XMLRubyContext::XMLRubyContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -235,6 +244,8 @@ void XMLRubyContext::endElement(const OUString& /*rName*/)
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Base class for contexts that represent a single character only.
class XMLCharContext : public XMLImportContext
{
@@ -246,6 +257,7 @@ public:
private:
librevenge::RVNGPropertyList m_aPropertyList;
};
+}
XMLCharContext::XMLCharContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -257,6 +269,8 @@ XMLCharContext::XMLCharContext(XMLImport& rImport,
m_aPropertyList.insert(itProp.key(), itProp()->clone());
}
+namespace
+{
/// Handler for <text:line-break>.
class XMLLineBreakContext : public XMLCharContext
{
@@ -267,6 +281,7 @@ public:
startElement(const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
};
+}
XMLLineBreakContext::XMLLineBreakContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -283,6 +298,8 @@ void XMLLineBreakContext::startElement(
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <text:s>.
class XMLSpaceContext : public XMLCharContext
{
@@ -293,6 +310,7 @@ public:
startElement(const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
};
+}
XMLSpaceContext::XMLSpaceContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
@@ -309,6 +327,8 @@ void XMLSpaceContext::startElement(
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <text:tab>.
class XMLTabContext : public XMLCharContext
{
@@ -319,6 +339,7 @@ public:
startElement(const OUString& rName,
const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
};
+}
XMLTabContext::XMLTabContext(XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList)
: XMLCharContext(rImport, rPropertyList)
@@ -334,6 +355,8 @@ void XMLTabContext::startElement(
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <draw:a>.
class XMLTextFrameHyperlinkContext : public XMLImportContext
{
@@ -354,6 +377,7 @@ private:
librevenge::RVNGPropertyList m_aPropertyList;
PopupState m_ePopupState = PopupState::NONE;
};
+}
XMLTextFrameHyperlinkContext::XMLTextFrameHyperlinkContext(
XMLImport& rImport, const librevenge::RVNGPropertyList& rPropertyList)
@@ -419,6 +443,8 @@ void XMLTextFrameHyperlinkContext::characters(const OUString& rChars)
GetImport().GetGenerator().closeSpan();
}
+namespace
+{
/// Handler for <text:a>.
class XMLHyperlinkContext : public XMLImportContext
{
@@ -438,6 +464,7 @@ private:
librevenge::RVNGPropertyList m_aPropertyList;
PopupState m_ePopupState = PopupState::NONE;
};
+}
XMLHyperlinkContext::XMLHyperlinkContext(XMLImport& rImport,
const librevenge::RVNGPropertyList& rPropertyList)
diff --git a/writerperfect/source/writer/exp/txtstyli.cxx b/writerperfect/source/writer/exp/txtstyli.cxx
index 02d2bb206e4b..9c7a156de984 100644
--- a/writerperfect/source/writer/exp/txtstyli.cxx
+++ b/writerperfect/source/writer/exp/txtstyli.cxx
@@ -17,6 +17,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <style:paragraph-properties>.
class XMLParagraphPropertiesContext : public XMLImportContext
{
@@ -30,6 +32,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLParagraphPropertiesContext::XMLParagraphPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
@@ -49,6 +52,8 @@ void XMLParagraphPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:text-properties>.
class XMLTextPropertiesContext : public XMLImportContext
{
@@ -62,6 +67,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLTextPropertiesContext::XMLTextPropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle)
: XMLImportContext(rImport)
@@ -80,6 +86,8 @@ void XMLTextPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:graphic-properties>.
class XMLGraphicPropertiesContext : public XMLImportContext
{
@@ -93,6 +101,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLGraphicPropertiesContext::XMLGraphicPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
@@ -112,6 +121,8 @@ void XMLGraphicPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:page-layout-properties>.
class XMLPageLayoutPropertiesContext : public XMLImportContext
{
@@ -125,6 +136,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLPageLayoutPropertiesContext::XMLPageLayoutPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
@@ -148,6 +160,8 @@ void XMLPageLayoutPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:table-properties>.
class XMLTablePropertiesContext : public XMLImportContext
{
@@ -161,6 +175,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLTablePropertiesContext::XMLTablePropertiesContext(XMLImport& rImport, XMLStyleContext& rStyle)
: XMLImportContext(rImport)
@@ -184,6 +199,8 @@ void XMLTablePropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:table-row-properties>.
class XMLTableRowPropertiesContext : public XMLImportContext
{
@@ -197,6 +214,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLTableRowPropertiesContext::XMLTableRowPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
@@ -216,6 +234,8 @@ void XMLTableRowPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:table-column-properties>.
class XMLTableColumnPropertiesContext : public XMLImportContext
{
@@ -229,6 +249,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLTableColumnPropertiesContext::XMLTableColumnPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
@@ -248,6 +269,8 @@ void XMLTableColumnPropertiesContext::startElement(
}
}
+namespace
+{
/// Handler for <style:table-cell-properties>.
class XMLTableCellPropertiesContext : public XMLImportContext
{
@@ -261,6 +284,7 @@ public:
private:
XMLStyleContext& mrStyle;
};
+}
XMLTableCellPropertiesContext::XMLTableCellPropertiesContext(XMLImport& rImport,
XMLStyleContext& rStyle)
diff --git a/writerperfect/source/writer/exp/xmlfmt.cxx b/writerperfect/source/writer/exp/xmlfmt.cxx
index 20269949ebe9..eaba8085fa4e 100644
--- a/writerperfect/source/writer/exp/xmlfmt.cxx
+++ b/writerperfect/source/writer/exp/xmlfmt.cxx
@@ -95,6 +95,8 @@ std::map<OUString, librevenge::RVNGPropertyList>& XMLStylesContext::GetCurrentMa
return m_rMasterStyles;
}
+namespace
+{
/// Handler for <style:font-face>.
class XMLFontFaceContext : public XMLImportContext
{
@@ -161,6 +163,7 @@ public:
private:
XMLFontFaceUriContext& mrFontFaceUri;
};
+}
XMLFontFaceFormatContext::XMLFontFaceFormatContext(XMLImport& rImport,
XMLFontFaceUriContext& rFontFaceUri)
diff --git a/writerperfect/source/writer/exp/xmlimp.cxx b/writerperfect/source/writer/exp/xmlimp.cxx
index 1ed88dffcf73..2f95f2dde4bc 100644
--- a/writerperfect/source/writer/exp/xmlimp.cxx
+++ b/writerperfect/source/writer/exp/xmlimp.cxx
@@ -198,7 +198,6 @@ void FindXMPMetadata(const uno::Reference<uno::XComponentContext>& xContext,
return;
}
}
-}
/// Handler for <office:body>.
class XMLBodyContext : public XMLImportContext
@@ -210,6 +209,7 @@ public:
CreateChildContext(const OUString& rName,
const uno::Reference<xml::sax::XAttributeList>& /*xAttribs*/) override;
};
+}
XMLBodyContext::XMLBodyContext(XMLImport& rImport)
: XMLImportContext(rImport)
@@ -225,6 +225,8 @@ XMLBodyContext::CreateChildContext(const OUString& rName,
return nullptr;
}
+namespace
+{
/// Handler for <office:document>.
class XMLOfficeDocContext : public XMLImportContext
{
@@ -238,6 +240,7 @@ public:
// Handles metafile for a single page.
void HandleFixedLayoutPage(const FixedLayoutPage& rPage, bool bFirst);
};
+}
XMLOfficeDocContext::XMLOfficeDocContext(XMLImport& rImport)
: XMLImportContext(rImport)
diff --git a/writerperfect/source/writer/exp/xmlmetai.cxx b/writerperfect/source/writer/exp/xmlmetai.cxx
index 19641d345cfb..76b8699f5e97 100644
--- a/writerperfect/source/writer/exp/xmlmetai.cxx
+++ b/writerperfect/source/writer/exp/xmlmetai.cxx
@@ -17,6 +17,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <dc:title>.
class XMLDcTitleContext : public XMLImportContext
{
@@ -28,6 +30,7 @@ public:
private:
XMLMetaDocumentContext& mrMeta;
};
+}
XMLDcTitleContext::XMLDcTitleContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta)
: XMLImportContext(rImport)
@@ -42,6 +45,8 @@ void XMLDcTitleContext::characters(const OUString& rChars)
mrMeta.GetPropertyList().insert("dc:title", librevenge::RVNGString(sCharU8.getStr()));
}
+namespace
+{
/// Handler for <dc:language>.
class XMLDcLanguageContext : public XMLImportContext
{
@@ -53,6 +58,7 @@ public:
private:
XMLMetaDocumentContext& mrMeta;
};
+}
XMLDcLanguageContext::XMLDcLanguageContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta)
: XMLImportContext(rImport)
@@ -67,6 +73,8 @@ void XMLDcLanguageContext::characters(const OUString& rChars)
mrMeta.GetPropertyList().insert("dc:language", librevenge::RVNGString(sCharU8.getStr()));
}
+namespace
+{
/// Handler for <dc:date>.
class XMLDcDateContext : public XMLImportContext
{
@@ -78,6 +86,7 @@ public:
private:
XMLMetaDocumentContext& mrMeta;
};
+}
XMLDcDateContext::XMLDcDateContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta)
: XMLImportContext(rImport)
@@ -92,6 +101,8 @@ void XMLDcDateContext::characters(const OUString& rChars)
mrMeta.GetPropertyList().insert("dc:date", librevenge::RVNGString(sCharU8.getStr()));
}
+namespace
+{
/// Handler for <meta:generator>.
class XMLMetaGeneratorContext : public XMLImportContext
{
@@ -103,6 +114,7 @@ public:
private:
XMLMetaDocumentContext& mrMeta;
};
+}
XMLMetaGeneratorContext::XMLMetaGeneratorContext(XMLImport& rImport, XMLMetaDocumentContext& rMeta)
: XMLImportContext(rImport)
@@ -116,6 +128,8 @@ void XMLMetaGeneratorContext::characters(const OUString& rChars)
mrMeta.GetPropertyList().insert("meta:generator", librevenge::RVNGString(sCharU8.getStr()));
}
+namespace
+{
/// Handler for <meta:initial-creator>.
class XMLMetaInitialCreatorContext : public XMLImportContext
{
@@ -127,6 +141,7 @@ public:
private:
XMLMetaDocumentContext& mrMeta;
};
+}
XMLMetaInitialCreatorContext::XMLMetaInitialCreatorContext(XMLImport& rImport,
XMLMetaDocumentContext& rMeta)
diff --git a/writerperfect/source/writer/exp/xmltbli.cxx b/writerperfect/source/writer/exp/xmltbli.cxx
index 263b6c3af414..68e0b29116a4 100644
--- a/writerperfect/source/writer/exp/xmltbli.cxx
+++ b/writerperfect/source/writer/exp/xmltbli.cxx
@@ -21,6 +21,8 @@ namespace writerperfect
{
namespace exp
{
+namespace
+{
/// Handler for <table:table-row>.
class XMLTableRowContext : public XMLImportContext
{
@@ -60,6 +62,7 @@ public:
private:
XMLTableRowContext& m_rRow;
};
+}
XMLTableCellContext::XMLTableCellContext(XMLImport& rImport, XMLTableRowContext& rRow)
: XMLImportContext(rImport)
@@ -102,6 +105,8 @@ void XMLTableCellContext::endElement(const OUString& /*rName*/)
GetImport().GetGenerator().closeTableCell();
}
+namespace
+{
/// Handler for <table:table-column>.
class XMLTableColumnContext : public XMLImportContext
{
@@ -115,6 +120,7 @@ public:
private:
librevenge::RVNGPropertyListVector& m_rColumns;
};
+}
XMLTableColumnContext::XMLTableColumnContext(XMLImport& rImport,
librevenge::RVNGPropertyListVector& rColumns)