1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "sal/config.h"
12 // Cannot include this, makes clang crash
13 //#include "xmloff/xmlimp.hxx"
14 // Cannot include this, cannot be found
15 //#include <xmloff/xmlictxt.hxx>
17 #include <com/sun/star/uno/Reference.hxx>
18 #include <rtl/ref.hxx>
20 namespace com::sun::star::xml::sax
23 class XFastContextHandler
;
26 class SvXMLImportContext
;
27 typedef rtl::Reference
<SvXMLImportContext
> SvXMLImportContextRef
;
28 class SvXMLImportContext
31 virtual ~SvXMLImportContext() {}
33 virtual void startFastElement() {}
34 virtual void endFastElement() {}
35 virtual void characters(const OUString
&) {}
36 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
> createFastChildContext()
40 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
> createUnknownChildContext()
45 virtual void StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>&) {}
46 virtual void EndElement() {}
47 virtual void Characters(const OUString
&) {}
48 virtual SvXMLImportContextRef
CreateChildContext() { return nullptr; }
53 void xxx(); // just here to avoid triggering a warning I don't want to check for
56 class Test1
: public SvXMLImportContext
59 // expected-error@+1 {{cannot override both startFastElement and StartElement [loplugin:xmlimport]}}
60 virtual void startFastElement() override
{ xxx(); }
61 // expected-error@+1 {{cannot override both startFastElement and StartElement [loplugin:xmlimport]}}
62 virtual void StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>&) override
68 class Test2
: public SvXMLImportContext
71 // expected-error@+1 {{cannot override both endFastElement and EndElement [loplugin:xmlimport]}}
72 virtual void endFastElement() override
{ xxx(); }
73 // expected-error@+1 {{cannot override both endFastElement and EndElement [loplugin:xmlimport]}}
74 virtual void EndElement() override
{ xxx(); }
77 class Test3
: public SvXMLImportContext
80 // expected-error@+1 {{cannot override both characters and Characters [loplugin:xmlimport]}}
81 virtual void Characters(const OUString
&) override
{ xxx(); }
82 // expected-error@+1 {{cannot override both characters and Characters [loplugin:xmlimport]}}
83 virtual void characters(const OUString
&) override
{ xxx(); }
86 class Test7
: public SvXMLImportContext
89 virtual void startFastElement() override
91 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
92 SvXMLImportContext::startFastElement();
94 virtual void endFastElement() override
96 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
97 SvXMLImportContext::endFastElement();
99 virtual void characters(const OUString
& rChars
) override
101 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
102 SvXMLImportContext::characters(rChars
);
104 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
>
105 createFastChildContext() override
107 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
108 return SvXMLImportContext::createFastChildContext();
110 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
>
111 createUnknownChildContext() override
113 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
114 return SvXMLImportContext::createUnknownChildContext();
118 class Test8
: public SvXMLImportContext
122 StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
) override
124 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
125 SvXMLImportContext::StartElement(xAttrList
);
127 virtual void EndElement() override
129 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
130 SvXMLImportContext::EndElement();
132 virtual void Characters(const OUString
& rChars
) override
134 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
135 SvXMLImportContext::Characters(rChars
);
137 virtual SvXMLImportContextRef
CreateChildContext() override
139 // expected-error@+1 {{don't call this superclass method [loplugin:xmlimport]}}
140 return SvXMLImportContext::CreateChildContext();
144 // no warning expected
145 class Test9a
: public SvXMLImportContext
148 virtual void StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>&) override
153 class Test9b
: public Test9a
157 StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttrList
) override
159 Test9a::StartElement(xAttrList
);
163 class Test10a
: public SvXMLImportContext
166 // expected-error@+1 {{empty, should be removed [loplugin:xmlimport]}}
167 virtual void startFastElement() override
{}
168 // expected-error@+1 {{empty, should be removed [loplugin:xmlimport]}}
169 virtual void endFastElement() override
{}
170 // expected-error@+1 {{empty, should be removed [loplugin:xmlimport]}}
171 virtual void characters(const OUString
&) override
{}
172 // expected-error@+1 {{empty, should be removed [loplugin:xmlimport]}}
173 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
>
174 createFastChildContext() override
178 // expected-error@+1 {{empty, should be removed [loplugin:xmlimport]}}
179 virtual css::uno::Reference
<css::xml::sax::XFastContextHandler
>
180 createUnknownChildContext() override
185 // no warning expected
186 class Test10b
: public SvXMLImportContext
189 virtual void StartElement(const css::uno::Reference
<css::xml::sax::XAttributeList
>&) override
{}
190 virtual void EndElement() override
{}
191 virtual void Characters(const OUString
&) override
{}
192 virtual SvXMLImportContextRef
CreateChildContext() override
{ return nullptr; }
200 void test20(sal_uInt32 p
, sal_uInt16 q
, XmlTokens e
)
202 // expected-error@+1 {{comparing XML_TOK enum to 'sal_uInt32', expected sal_uInt16 [loplugin:xmlimport]}}
205 // no warning expected
210 // expected-error@+1 {{comparing XML_TOK enum to 'sal_uInt32', expected sal_uInt16 [loplugin:xmlimport]}}
216 // no warning expected
222 // no warning expected
227 void callInt32(sal_Int32
);
230 // expected-error@+1 {{passing XML_TOK enum to 'sal_Int32', wrong param or XML token type [loplugin:xmlimport]}}
231 callInt32(XML_TOK_1
);
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */