Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef DBTOOLS_WARNINGSCONTAINER_HXX
21 : : #define DBTOOLS_WARNINGSCONTAINER_HXX
22 : :
23 : : #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
24 : : #include <com/sun/star/sdb/SQLContext.hpp>
25 : :
26 : : #include "connectivity/dbtoolsdllapi.hxx"
27 : :
28 : : //.........................................................................
29 : : namespace dbtools
30 : : {
31 : : //.........................................................................
32 : :
33 : : //=====================================================================
34 : : //= IWarningsContainer
35 : : //=====================================================================
36 : 678 : class SAL_NO_VTABLE IWarningsContainer
37 : : {
38 : : public:
39 : : virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning) = 0;
40 : : virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning) = 0;
41 : : virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext) = 0;
42 : :
43 : : protected:
44 : 672 : ~IWarningsContainer() {}
45 : : };
46 : :
47 : : //====================================================================
48 : : //= WarningsContainer
49 : : //====================================================================
50 : : /** helper class for implementing XWarningsSupplier, which mixes own warnings with
51 : : warnings obtained from an external instance
52 : : */
53 : : class OOO_DLLPUBLIC_DBTOOLS WarningsContainer : public IWarningsContainer
54 : : {
55 : : private:
56 : : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier > m_xExternalWarnings;
57 : : ::com::sun::star::uno::Any m_aOwnWarnings;
58 : :
59 : : public:
60 : 582 : WarningsContainer() { }
61 : 96 : WarningsContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
62 : 96 : :m_xExternalWarnings( _rxExternalWarnings )
63 : : {
64 : 96 : }
65 : : virtual ~WarningsContainer();
66 : :
67 : 1067 : void setExternalWarnings( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
68 : : {
69 : 1067 : m_xExternalWarnings = _rxExternalWarnings;
70 : 1067 : }
71 : :
72 : : // convenience
73 : : /** appends an SQLWarning instance to the chain
74 : : @param _rWarning
75 : : the warning message
76 : : @param _pAsciiSQLState
77 : : the SQLState of the warning
78 : : @param _rxContext
79 : : the context of the warning
80 : : */
81 : : void appendWarning(
82 : : const ::rtl::OUString& _rWarning,
83 : : const sal_Char* _pAsciiSQLState,
84 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
85 : :
86 : : // IWarningsContainer
87 : : virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning);
88 : : virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning);
89 : : virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext);
90 : :
91 : : // XWarningsSupplier equivalents
92 : : ::com::sun::star::uno::Any SAL_CALL getWarnings( ) const;
93 : : void SAL_CALL clearWarnings( );
94 : : };
95 : :
96 : : //.........................................................................
97 : : } // namespace dbtools
98 : : //.........................................................................
99 : :
100 : : #endif // DBTOOLS_WARNINGSCONTAINER_HXX
101 : :
102 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|