cid#1607171 Data race condition
[LibreOffice.git] / sd / source / ui / inc / framework / ViewShellWrapper.hxx
blobfc944623a75a3848e9542314c4d2d400c9ac4cdc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <com/sun/star/drawing/framework/XView.hpp>
23 #include <com/sun/star/drawing/framework/XRelocatableResource.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include <com/sun/star/awt/XWindowListener.hpp>
26 #include <comphelper/compbase.hxx>
28 #include <memory>
30 namespace sd { class ViewShell; }
31 namespace sd::slidesorter { class SlideSorterViewShell; }
32 namespace com::sun::star::awt { class XWindow; }
34 namespace sd::framework {
36 typedef comphelper::WeakComponentImplHelper < css::awt::XWindowListener
37 , css::view::XSelectionSupplier
38 , css::drawing::framework::XRelocatableResource
39 , css::drawing::framework::XView
40 > ViewShellWrapperInterfaceBase;
42 /** This class wraps ViewShell objects and makes them look like an XView.
43 Most importantly it provides access to the ViewShell implementation.
44 Then it forwards size changes of the pane window to the view shell.
46 class ViewShellWrapper final : public ViewShellWrapperInterfaceBase
48 public:
49 /** Create a new ViewShellWrapper object that wraps the given ViewShell
50 object.
51 @param pViewShell
52 The ViewShell object to wrap.
53 @param rsViewURL
54 URL of the view type of the wrapped view shell.
55 @param rxWindow
56 This window reference is optional. When a valid reference is
57 given then size changes of the referenced window are forwarded
58 to the ViewShell object.
60 ViewShellWrapper (
61 const ::std::shared_ptr<ViewShell>& pViewShell,
62 const css::uno::Reference<css::drawing::framework::XResourceId>& rxViewId,
63 const css::uno::Reference<css::awt::XWindow>& rxWindow);
64 virtual ~ViewShellWrapper() override;
66 virtual void disposing(std::unique_lock<std::mutex>&) override;
67 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
69 /** This method is typically used
70 to obtain a pointer to the wrapped ViewShell object for a given
71 XView object.
73 const ::std::shared_ptr<ViewShell>& GetViewShell() const { return mpViewShell;}
75 // XResource
77 virtual css::uno::Reference<css::drawing::framework::XResourceId>
78 SAL_CALL getResourceId() override;
80 virtual sal_Bool SAL_CALL isAnchorOnly() override;
82 // XSelectionSupplier
84 virtual sal_Bool SAL_CALL select( const css::uno::Any& aSelection ) override;
85 virtual css::uno::Any SAL_CALL getSelection() override;
86 virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override;
87 virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override;
89 // XRelocatableResource
91 virtual sal_Bool SAL_CALL relocateToAnchor (
92 const css::uno::Reference<
93 css::drawing::framework::XResource>& xResource) override;
95 // XWindowListener
97 virtual void SAL_CALL windowResized(
98 const css::awt::WindowEvent& rEvent) override;
100 virtual void SAL_CALL windowMoved(
101 const css::awt::WindowEvent& rEvent) override;
103 virtual void SAL_CALL windowShown(
104 const css::lang::EventObject& rEvent) override;
106 virtual void SAL_CALL windowHidden(
107 const css::lang::EventObject& rEvent) override;
109 // XEventListener
111 virtual void SAL_CALL disposing(
112 const css::lang::EventObject& rEvent) override;
114 private:
115 ::std::shared_ptr< ViewShell > mpViewShell;
116 ::std::shared_ptr< ::sd::slidesorter::SlideSorterViewShell > mpSlideSorterViewShell;
117 const css::uno::Reference< css::drawing::framework::XResourceId > mxViewId;
118 css::uno::Reference<css::awt::XWindow > mxWindow;
121 } // end of namespace sd::framework
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */