xref: /AOO41X/main/connectivity/inc/connectivity/warningscontainer.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef DBTOOLS_WARNINGSCONTAINER_HXX
29 #define DBTOOLS_WARNINGSCONTAINER_HXX
30 
31 /** ==== begin UNO includes === **/
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/sdb/SQLContext.hpp>
34 /** ==== end UNO includes === **/
35 
36 #include "connectivity/dbtoolsdllapi.hxx"
37 
38 //.........................................................................
39 namespace dbtools
40 {
41 //.........................................................................
42 
43 	//=====================================================================
44 	//= IWarningsContainer
45 	//=====================================================================
46 	class SAL_NO_VTABLE IWarningsContainer
47 	{
48 	public:
49 		virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning) = 0;
50 		virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning) = 0;
51 		virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext) = 0;
52 	};
53 
54     //====================================================================
55     //= WarningsContainer
56     //====================================================================
57     /** helper class for implementing XWarningsSupplier, which mixes own warnings with
58         warnings obtained from an external instance
59     */
60     class OOO_DLLPUBLIC_DBTOOLS WarningsContainer : public IWarningsContainer
61     {
62     private:
63         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >   m_xExternalWarnings;
64 	    ::com::sun::star::uno::Any	                                                    m_aOwnWarnings;
65 
66     public:
67         WarningsContainer() { }
68         WarningsContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
69             :m_xExternalWarnings( _rxExternalWarnings )
70         {
71         }
72         virtual ~WarningsContainer();
73 
74         void setExternalWarnings( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
75         {
76             m_xExternalWarnings = _rxExternalWarnings;
77         }
78 
79         // convenience
80         /** appends an SQLWarning instance to the chain
81             @param  _rWarning
82                 the warning message
83             @param  _pAsciiSQLState
84                 the SQLState of the warning
85             @param  _rxContext
86                 the context of the warning
87         */
88         void appendWarning(
89             const ::rtl::OUString& _rWarning,
90             const sal_Char* _pAsciiSQLState,
91             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
92 
93         // IWarningsContainer
94 	    virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning);
95 	    virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning);
96 	    virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext);
97 
98         // XWarningsSupplier equivalents
99         ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) const;
100         void SAL_CALL clearWarnings(  );
101     };
102 
103 //.........................................................................
104 }	// namespace dbtools
105 //.........................................................................
106 
107 #endif // DBTOOLS_WARNINGSCONTAINER_HXX
108