xref: /trunk/main/sd/source/ui/inc/framework/ViewShellWrapper.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
25 #define SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
26 
27 #include "MutexOwner.hxx"
28 #include <com/sun/star/drawing/framework/XView.hpp>
29 #include <com/sun/star/drawing/framework/XRelocatableResource.hpp>
30 #include <com/sun/star/awt/XWindow.hpp>
31 #include <com/sun/star/lang/XUnoTunnel.hpp>
32 #include <osl/mutex.hxx>
33 #include <cppuhelper/compbase4.hxx>
34 #include <cppuhelper/implbase1.hxx>
35 
36 #include <boost/shared_ptr.hpp>
37 
38 namespace {
39 
40 typedef ::cppu::WeakComponentImplHelper4    <   ::com::sun::star::lang::XUnoTunnel
41                                             ,   ::com::sun::star::awt::XWindowListener
42                                             ,   ::com::sun::star::drawing::framework::XRelocatableResource
43                                             ,   ::com::sun::star::drawing::framework::XView
44                                             >   ViewShellWrapperInterfaceBase;
45 
46 } // end of anonymous namespace.
47 
48 namespace sd { class ViewShell; }
49 
50 namespace sd { namespace framework {
51 
52 /** This class wraps ViewShell objects and makes them look like an XView.
53     Most importantly it provides a tunnel to the ViewShell implementation.
54     Then it forwards size changes of the pane window to the view shell.
55 */
56 class ViewShellWrapper  :private sd::MutexOwner
57                         ,public ViewShellWrapperInterfaceBase
58 {
59 public:
60     /** Create a new ViewShellWrapper object that wraps the given ViewShell
61         object.
62         @param pViewShell
63             The ViewShell object to wrap.
64         @param rsViewURL
65             URL of the view type of the wrapped view shell.
66         @param rxWindow
67             This window reference is optional.  When a valid reference is
68             given then size changes of the referenced window are forwarded
69             to the ViewShell object.
70     */
71     ViewShellWrapper (
72         ::boost::shared_ptr<ViewShell> pViewShell,
73         const ::com::sun::star::uno::Reference<
74             ::com::sun::star::drawing::framework::XResourceId>& rxViewId,
75         const ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow>& rxWindow);
76     virtual ~ViewShellWrapper (void);
77 
78     virtual void SAL_CALL disposing (void);
79 
80     static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
81 
82     /** This method is typically used together with the XUnoTunnel interface
83         to obtain a pointer to the wrapped ViewShell object for a given
84         XView object.
85     */
86     ::boost::shared_ptr<ViewShell> GetViewShell (void);
87 
88     // XUnoTunnel
89 
90     virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId);
91 
92     // XResource
93 
94     virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>
95         SAL_CALL getResourceId (void);
96 
97     virtual sal_Bool SAL_CALL isAnchorOnly (void);
98 
99 
100     // XRelocatableResource
101 
102     virtual sal_Bool SAL_CALL relocateToAnchor (
103         const ::com::sun::star::uno::Reference<
104             com::sun::star::drawing::framework::XResource>& xResource);
105 
106 
107     // XWindowListener
108 
109     virtual void SAL_CALL windowResized(
110         const ::com::sun::star::awt::WindowEvent& rEvent);
111 
112     virtual void SAL_CALL windowMoved(
113         const ::com::sun::star::awt::WindowEvent& rEvent);
114 
115     virtual void SAL_CALL windowShown(
116         const ::com::sun::star::lang::EventObject& rEvent);
117 
118     virtual void SAL_CALL windowHidden(
119         const ::com::sun::star::lang::EventObject& rEvent);
120 
121 
122     // XEventListener
123 
124     virtual void SAL_CALL disposing(
125         const com::sun::star::lang::EventObject& rEvent);
126 
127 private:
128     ::boost::shared_ptr< ViewShell >                                                            mpViewShell;
129     const ::com::sun::star::uno::Reference< com::sun::star::drawing::framework::XResourceId >   mxViewId;
130     ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow >                             mxWindow;
131 };
132 
133 } } // end of namespace sd::framework
134 
135 #endif
136