1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
25cdf0e10cSrcweir #define SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "MutexOwner.hxx"
28cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XRelocatableResource.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp>
32cdf0e10cSrcweir #include <osl/mutex.hxx>
33cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
34cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4    <   ::com::sun::star::lang::XUnoTunnel
41cdf0e10cSrcweir                                             ,   ::com::sun::star::awt::XWindowListener
42cdf0e10cSrcweir                                             ,   ::com::sun::star::drawing::framework::XRelocatableResource
43cdf0e10cSrcweir                                             ,   ::com::sun::star::drawing::framework::XView
44cdf0e10cSrcweir                                             >   ViewShellWrapperInterfaceBase;
45cdf0e10cSrcweir 
46cdf0e10cSrcweir } // end of anonymous namespace.
47cdf0e10cSrcweir 
48cdf0e10cSrcweir namespace sd { class ViewShell; }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace sd { namespace framework {
51cdf0e10cSrcweir 
52cdf0e10cSrcweir /** This class wraps ViewShell objects and makes them look like an XView.
53cdf0e10cSrcweir     Most importantly it provides a tunnel to the ViewShell implementation.
54cdf0e10cSrcweir     Then it forwards size changes of the pane window to the view shell.
55cdf0e10cSrcweir */
56cdf0e10cSrcweir class ViewShellWrapper  :private sd::MutexOwner
57cdf0e10cSrcweir                         ,public ViewShellWrapperInterfaceBase
58cdf0e10cSrcweir {
59cdf0e10cSrcweir public:
60cdf0e10cSrcweir     /** Create a new ViewShellWrapper object that wraps the given ViewShell
61cdf0e10cSrcweir         object.
62cdf0e10cSrcweir         @param pViewShell
63cdf0e10cSrcweir             The ViewShell object to wrap.
64cdf0e10cSrcweir         @param rsViewURL
65cdf0e10cSrcweir             URL of the view type of the wrapped view shell.
66cdf0e10cSrcweir         @param rxWindow
67cdf0e10cSrcweir             This window reference is optional.  When a valid reference is
68cdf0e10cSrcweir             given then size changes of the referenced window are forwarded
69cdf0e10cSrcweir             to the ViewShell object.
70cdf0e10cSrcweir     */
71cdf0e10cSrcweir     ViewShellWrapper (
72cdf0e10cSrcweir         ::boost::shared_ptr<ViewShell> pViewShell,
73cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
74cdf0e10cSrcweir             ::com::sun::star::drawing::framework::XResourceId>& rxViewId,
75cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow>& rxWindow);
76cdf0e10cSrcweir     virtual ~ViewShellWrapper (void);
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
79cdf0e10cSrcweir 
80cdf0e10cSrcweir     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     /** This method is typically used together with the XUnoTunnel interface
83cdf0e10cSrcweir         to obtain a pointer to the wrapped ViewShell object for a given
84cdf0e10cSrcweir         XView object.
85cdf0e10cSrcweir     */
86cdf0e10cSrcweir     ::boost::shared_ptr<ViewShell> GetViewShell (void);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     // XUnoTunnel
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
91cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // XResource
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>
96cdf0e10cSrcweir         SAL_CALL getResourceId (void)
97cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isAnchorOnly (void)
100cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     // XRelocatableResource
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     virtual sal_Bool SAL_CALL relocateToAnchor (
106cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
107cdf0e10cSrcweir             com::sun::star::drawing::framework::XResource>& xResource)
108cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     // XWindowListener
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     virtual void SAL_CALL windowResized(
114cdf0e10cSrcweir         const ::com::sun::star::awt::WindowEvent& rEvent)
115cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     virtual void SAL_CALL windowMoved(
118cdf0e10cSrcweir         const ::com::sun::star::awt::WindowEvent& rEvent)
119cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir     virtual void SAL_CALL windowShown(
122cdf0e10cSrcweir         const ::com::sun::star::lang::EventObject& rEvent)
123cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     virtual void SAL_CALL windowHidden(
126cdf0e10cSrcweir         const ::com::sun::star::lang::EventObject& rEvent)
127cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     // XEventListener
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     virtual void SAL_CALL disposing(
133cdf0e10cSrcweir         const com::sun::star::lang::EventObject& rEvent)
134cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 
136cdf0e10cSrcweir private:
137cdf0e10cSrcweir     ::boost::shared_ptr< ViewShell >                                                            mpViewShell;
138cdf0e10cSrcweir     const ::com::sun::star::uno::Reference< com::sun::star::drawing::framework::XResourceId >   mxViewId;
139cdf0e10cSrcweir     ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow >                             mxWindow;
140cdf0e10cSrcweir };
141cdf0e10cSrcweir 
142cdf0e10cSrcweir } } // end of namespace sd::framework
143cdf0e10cSrcweir 
144cdf0e10cSrcweir #endif
145