1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef DBTOOLS_WARNINGSCONTAINER_HXX
25 #define DBTOOLS_WARNINGSCONTAINER_HXX
26 
27 /** ==== begin UNO includes === **/
28 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
29 #include <com/sun/star/sdb/SQLContext.hpp>
30 /** ==== end UNO includes === **/
31 
32 #include "connectivity/dbtoolsdllapi.hxx"
33 
34 //.........................................................................
35 namespace dbtools
36 {
37 //.........................................................................
38 
39 	//=====================================================================
40 	//= IWarningsContainer
41 	//=====================================================================
42 	class SAL_NO_VTABLE IWarningsContainer
43 	{
44 	public:
45 		virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning) = 0;
46 		virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning) = 0;
47 		virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext) = 0;
48 	};
49 
50     //====================================================================
51     //= WarningsContainer
52     //====================================================================
53     /** helper class for implementing XWarningsSupplier, which mixes own warnings with
54         warnings obtained from an external instance
55     */
56     class OOO_DLLPUBLIC_DBTOOLS WarningsContainer : public IWarningsContainer
57     {
58     private:
59         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >   m_xExternalWarnings;
60 	    ::com::sun::star::uno::Any	                                                    m_aOwnWarnings;
61 
62     public:
WarningsContainer()63         WarningsContainer() { }
WarningsContainer(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XWarningsSupplier> & _rxExternalWarnings)64         WarningsContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
65             :m_xExternalWarnings( _rxExternalWarnings )
66         {
67         }
68         virtual ~WarningsContainer();
69 
setExternalWarnings(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XWarningsSupplier> & _rxExternalWarnings)70         void setExternalWarnings( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XWarningsSupplier >& _rxExternalWarnings )
71         {
72             m_xExternalWarnings = _rxExternalWarnings;
73         }
74 
75         // convenience
76         /** appends an SQLWarning instance to the chain
77             @param  _rWarning
78                 the warning message
79             @param  _pAsciiSQLState
80                 the SQLState of the warning
81             @param  _rxContext
82                 the context of the warning
83         */
84         void appendWarning(
85             const ::rtl::OUString& _rWarning,
86             const sal_Char* _pAsciiSQLState,
87             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
88 
89         // IWarningsContainer
90 	    virtual void appendWarning(const ::com::sun::star::sdbc::SQLException& _rWarning);
91 	    virtual void appendWarning(const ::com::sun::star::sdbc::SQLWarning& _rWarning);
92 	    virtual void appendWarning(const ::com::sun::star::sdb::SQLContext& _rContext);
93 
94         // XWarningsSupplier equivalents
95         ::com::sun::star::uno::Any SAL_CALL getWarnings(  ) const;
96         void SAL_CALL clearWarnings(  );
97     };
98 
99 //.........................................................................
100 }	// namespace dbtools
101 //.........................................................................
102 
103 #endif // DBTOOLS_WARNINGSCONTAINER_HXX
104