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 DBACCESS_DOCERRORHANDLING_HXX
25 #define DBACCESS_DOCERRORHANDLING_HXX
26 
27 /** === begin UNO includes === **/
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/task/XInteractionHandler.hpp>
30 /** === end UNO includes === **/
31 
32 namespace comphelper {
33     class ComponentContext;
34 }
35 
36 #include <memory>
37 
38 //........................................................................
39 namespace dbmm
40 {
41 //........................................................................
42 
43 	//====================================================================
44 	//= DocumentErrorHandling
45 	//====================================================================
46     struct InteractionHandler_Data;
47     /** wraps common operations with an interaction handler.
48     */
49     class InteractionHandler
50     {
51     public:
52         /** creates an interaction handler by instantiating a css.task.InteractionHandler
53             component at the given component context, or using the given document's interaction handler,
54             if one is specified in the document's media descriptor.
55         */
56         InteractionHandler( const ::comphelper::ComponentContext& _rContext, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument );
57 
58         /** destructor
59         */
60         ~InteractionHandler();
61 
62         /** requests a document password
63             @param _rDocumentName
64                 the document name
65             @param _io_rPassword
66                 the initial password on method entry, the password as entered by the user on method leave
67             @return
68                 <TRUE/> if and only if the user entered a password, and confirmed with OK, <FALSE/>
69                 if the user aborted the request.
70         */
71         bool    requestDocumentPassword(
72                     const ::rtl::OUString& _rDocumentName,
73                           ::rtl::OUString& _io_rPassword
74                 );
75 
76         /** reports the given error (usually an exception caught on the caller's side)
77             to the user
78         */
79         void    reportError(
80                     const ::com::sun::star::uno::Any& _rError
81                 );
82 
83     private:
84         ::std::auto_ptr< InteractionHandler_Data >  m_pData;
85     };
86 
87 //........................................................................
88 } // namespace dbmm
89 //........................................................................
90 
91 #endif // DBACCESS_DOCERRORHANDLING_HXX
92