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 _SVTOOLS_JAVACONTEXT_HXX_
25 #define _SVTOOLS_JAVACONTEXT_HXX_
26 
27 #include "svtools/svtdllapi.h"
28 #include <osl/mutex.hxx>
29 
30 #include <com/sun/star/task/XInteractionHandler.hpp>
31 #include <com/sun/star/task/XInteractionRequest.hpp>
32 #include <com/sun/star/uno/XCurrentContext.hpp>
33 
34 
35 namespace svt
36 {
37 // We cannot derive from  cppu::WeakImplHelper because we would export the inline
38 //generated class. This conflicts with other libraries if they use the same inline
39 //class.
40 	class SVT_DLLPUBLIC JavaContext :
41         public com::sun::star::uno::XCurrentContext
42 	{
43 
44     public:
45         JavaContext( const com::sun::star::uno::Reference<
46                      com::sun::star::uno::XCurrentContext> & ctx);
47 
48         /** The parameter bShowErrorsOnce controls whether a message box is
49             only displayed once for a reocurring Java error. That is only
50             the first time JavaInteractionHandler.handle is called with a
51             particular Request then the message box is shown. Afterwards
52             nothing happens.
53          */
54         JavaContext( const com::sun::star::uno::Reference<
55                      com::sun::star::uno::XCurrentContext> & ctx,
56                      bool bReportErrorOnce);
57         virtual ~JavaContext();
58 
59         // XInterface
60         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
61             const ::com::sun::star::uno::Type& aType )
62             throw (::com::sun::star::uno::RuntimeException);
63 
64         virtual void SAL_CALL acquire() throw ();
65 
66         virtual void SAL_CALL release() throw ();
67 
68         // XCurrentContext
69         virtual com::sun::star::uno::Any SAL_CALL getValueByName( const rtl::OUString& Name )
70             throw (com::sun::star::uno::RuntimeException);
71 
72     private:
73         SVT_DLLPRIVATE JavaContext(); //not implemented
74         SVT_DLLPRIVATE JavaContext(JavaContext&); //not implemented
75         SVT_DLLPRIVATE JavaContext& operator = (JavaContext&); //not implemented
76 
77         oslInterlockedCount	m_aRefCount;
78 
79         com::sun::star::uno::Reference<
80             com::sun::star::uno::XCurrentContext > m_xNextContext;
81         com::sun::star::uno::Reference<
82             com::sun::star::task::XInteractionHandler> m_xHandler;
83         bool m_bShowErrorsOnce;
84 	};
85 }
86 
87 #endif
88