merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / inc / framework / ViewShellWrapper.hxx
blobb0b045bc200cfd6c22a96258e7eda9350accaffe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ViewShellWrapper.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
32 #define SD_FRAMEWORK_VIEW_SHELL_WRAPPER_HXX
34 #include "MutexOwner.hxx"
35 #include <com/sun/star/drawing/framework/XView.hpp>
36 #include <com/sun/star/drawing/framework/XRelocatableResource.hpp>
37 #include <com/sun/star/awt/XWindow.hpp>
38 #include <com/sun/star/lang/XUnoTunnel.hpp>
39 #include <osl/mutex.hxx>
40 #include <cppuhelper/compbase4.hxx>
42 #include <boost/shared_ptr.hpp>
44 namespace {
46 typedef ::cppu::WeakComponentImplHelper4 <
47 ::com::sun::star::drawing::framework::XView,
48 ::com::sun::star::lang::XUnoTunnel,
49 ::com::sun::star::awt::XWindowListener,
50 ::com::sun::star::drawing::framework::XRelocatableResource
51 > ViewShellWrapperInterfaceBase;
53 } // end of anonymous namespace.
55 namespace sd { class ViewShell; }
57 namespace sd { namespace framework {
59 /** This class wraps ViewShell objects and makes them look like an XView.
60 Most importantly it provides a tunnel to the ViewShell implementation.
61 Then it forwards size changes of the pane window to the view shell.
63 class ViewShellWrapper
64 : private sd::MutexOwner,
65 public ViewShellWrapperInterfaceBase
67 public:
68 /** Create a new ViewShellWrapper object that wraps the given ViewShell
69 object.
70 @param pViewShell
71 The ViewShell object to wrap.
72 @param rsViewURL
73 URL of the view type of the wrapped view shell.
74 @param rxWindow
75 This window reference is optional. When a valid reference is
76 given then size changes of the referenced window are forwarded
77 to the ViewShell object.
79 ViewShellWrapper (
80 ::boost::shared_ptr<ViewShell> pViewShell,
81 const ::com::sun::star::uno::Reference<
82 ::com::sun::star::drawing::framework::XResourceId>& rxViewId,
83 const ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow>& rxWindow);
84 virtual ~ViewShellWrapper (void);
86 virtual void SAL_CALL disposing (void);
88 static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId (void);
90 /** This method is typically used together with the XUnoTunnel interface
91 to obtain a pointer to the wrapped ViewShell object for a given
92 XView object.
94 ::boost::shared_ptr<ViewShell> GetViewShell (void);
96 /** Returns whether there is exactly one reference to the called
97 ViewShellWrapper object (the number of references to the wrapped
98 ViewShell object is not taken into account). This method is
99 typically used by the owner of a ViewShellWrapper object to verify
100 that, at the end of the ViewShellWrapper object's lifetime, the
101 owner holds the last reference and by releasing it will destroy the
102 object.
104 bool IsUnique (void);
107 // XUnoTunnel
109 virtual sal_Int64 SAL_CALL getSomething (const com::sun::star::uno::Sequence<sal_Int8>& rId)
110 throw (com::sun::star::uno::RuntimeException);
113 // XResource
115 virtual ::com::sun::star::uno::Reference<com::sun::star::drawing::framework::XResourceId>
116 SAL_CALL getResourceId (void)
117 throw (com::sun::star::uno::RuntimeException);
119 virtual sal_Bool SAL_CALL isAnchorOnly (void)
120 throw (com::sun::star::uno::RuntimeException);
123 // XRelocatableResource
125 virtual sal_Bool SAL_CALL relocateToAnchor (
126 const ::com::sun::star::uno::Reference<
127 com::sun::star::drawing::framework::XResource>& xResource)
128 throw (com::sun::star::uno::RuntimeException);
131 // XWindowListener
133 virtual void SAL_CALL windowResized(
134 const ::com::sun::star::awt::WindowEvent& rEvent)
135 throw (::com::sun::star::uno::RuntimeException);
137 virtual void SAL_CALL windowMoved(
138 const ::com::sun::star::awt::WindowEvent& rEvent)
139 throw (::com::sun::star::uno::RuntimeException);
141 virtual void SAL_CALL windowShown(
142 const ::com::sun::star::lang::EventObject& rEvent)
143 throw (::com::sun::star::uno::RuntimeException);
145 virtual void SAL_CALL windowHidden(
146 const ::com::sun::star::lang::EventObject& rEvent)
147 throw (::com::sun::star::uno::RuntimeException);
150 // XEventListener
152 virtual void SAL_CALL disposing(
153 const com::sun::star::lang::EventObject& rEvent)
154 throw (com::sun::star::uno::RuntimeException);
156 private:
157 ::boost::shared_ptr<ViewShell> mpViewShell;
158 const ::com::sun::star::uno::Reference<
159 com::sun::star::drawing::framework::XResourceId> mxViewId;
160 ::com::sun::star::uno::Reference<com::sun::star::awt::XWindow> mxWindow;
163 } } // end of namespace sd::framework
165 #endif