1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PANE_CONTAINER_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_PANE_CONTAINER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "PresenterTheme.hxx"
28cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
29cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
31cdf0e10cSrcweir #include <com/sun/star/drawing/XPresenterHelper.hpp>
32cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XResourceId.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
35cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
36cdf0e10cSrcweir #include <com/sun/star/util/Color.hpp>
37cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx>
38cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
39cdf0e10cSrcweir #include <rtl/ref.hxx>
40cdf0e10cSrcweir #include <vector>
41cdf0e10cSrcweir #include <boost/function.hpp>
42cdf0e10cSrcweir #include <boost/noncopyable.hpp>
43cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir namespace css = ::com::sun::star;
46cdf0e10cSrcweir 
47cdf0e10cSrcweir namespace sdext { namespace presenter {
48cdf0e10cSrcweir 
49cdf0e10cSrcweir class PresenterPaneBase;
50cdf0e10cSrcweir class PresenterSprite;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir namespace {
53cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper1 <
54cdf0e10cSrcweir         css::lang::XEventListener
55cdf0e10cSrcweir     > PresenterPaneContainerInterfaceBase;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir /** This class could also be called PresenterPaneAndViewContainer because it
59cdf0e10cSrcweir     stores not only references to all panes that belong to the presenter
60cdf0e10cSrcweir     screen but stores the views displayed in these panes as well.
61cdf0e10cSrcweir */
62cdf0e10cSrcweir class PresenterPaneContainer
63cdf0e10cSrcweir     : private ::boost::noncopyable,
64cdf0e10cSrcweir       private ::cppu::BaseMutex,
65cdf0e10cSrcweir       public PresenterPaneContainerInterfaceBase
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir     PresenterPaneContainer (
69cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext);
70cdf0e10cSrcweir     virtual ~PresenterPaneContainer (void);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     typedef ::boost::function1<void, const css::uno::Reference<css::drawing::framework::XView>&>
75cdf0e10cSrcweir         ViewInitializationFunction;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     /** Each pane descriptor holds references to one pane and the view
78cdf0e10cSrcweir         displayed in this pane as well as the other information that is used
79cdf0e10cSrcweir         to manage the pane window like an XWindow reference, the title, and
80cdf0e10cSrcweir         the coordinates.
81cdf0e10cSrcweir 
82cdf0e10cSrcweir         A initialization function for the view is stored as well.  This
83cdf0e10cSrcweir         function is executed as soon as a view is created.
84cdf0e10cSrcweir     */
85cdf0e10cSrcweir     class PaneDescriptor
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir     public:
88cdf0e10cSrcweir         typedef ::boost::function<void(bool)> Activator;
89cdf0e10cSrcweir         typedef ::boost::function<boost::shared_ptr<PresenterSprite>()> SpriteProvider;
90cdf0e10cSrcweir         css::uno::Reference<css::drawing::framework::XResourceId> mxPaneId;
91cdf0e10cSrcweir         ::rtl::OUString msViewURL;
92cdf0e10cSrcweir         ::rtl::Reference<PresenterPaneBase> mxPane;
93cdf0e10cSrcweir         css::uno::Reference<css::drawing::framework::XView> mxView;
94cdf0e10cSrcweir         css::uno::Reference<css::awt::XWindow> mxContentWindow;
95cdf0e10cSrcweir         css::uno::Reference<css::awt::XWindow> mxBorderWindow;
96cdf0e10cSrcweir         ::rtl::OUString msTitleTemplate;
97cdf0e10cSrcweir         ::rtl::OUString msAccessibleTitleTemplate;
98cdf0e10cSrcweir         ::rtl::OUString msTitle;
99cdf0e10cSrcweir         ViewInitializationFunction maViewInitialization;
100cdf0e10cSrcweir         double mnLeft;
101cdf0e10cSrcweir         double mnTop;
102cdf0e10cSrcweir         double mnRight;
103cdf0e10cSrcweir         double mnBottom;
104cdf0e10cSrcweir         SharedBitmapDescriptor mpViewBackground;
105cdf0e10cSrcweir         bool mbIsActive;
106cdf0e10cSrcweir         bool mbNeedsClipping;
107cdf0e10cSrcweir         bool mbIsOpaque;
108cdf0e10cSrcweir         SpriteProvider maSpriteProvider;
109cdf0e10cSrcweir         bool mbIsSprite;
110cdf0e10cSrcweir         Activator maActivator;
111cdf0e10cSrcweir         css::awt::Point maCalloutAnchorLocation;
112cdf0e10cSrcweir         bool mbHasCalloutAnchor;
113cdf0e10cSrcweir 
114cdf0e10cSrcweir         void SetActivationState (const bool bIsActive);
115cdf0e10cSrcweir     };
116cdf0e10cSrcweir     typedef ::boost::shared_ptr<PaneDescriptor> SharedPaneDescriptor;
117cdf0e10cSrcweir     typedef ::std::vector<SharedPaneDescriptor> PaneList;
118cdf0e10cSrcweir     PaneList maPanes;
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     void PreparePane (
121cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
122cdf0e10cSrcweir         const ::rtl::OUString& rsViewURL,
123cdf0e10cSrcweir         const ::rtl::OUString& rsTitle,
124cdf0e10cSrcweir         const ::rtl::OUString& rsAccessibleTitle,
125cdf0e10cSrcweir         const bool bIsOpaque,
126cdf0e10cSrcweir         const ViewInitializationFunction& rViewIntialization,
127cdf0e10cSrcweir         const double nLeft,
128cdf0e10cSrcweir         const double nTop,
129cdf0e10cSrcweir         const double nRight,
130cdf0e10cSrcweir         const double nBottom);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     SharedPaneDescriptor StorePane (
133cdf0e10cSrcweir         const rtl::Reference<PresenterPaneBase>& rxPane);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir     SharedPaneDescriptor StoreBorderWindow(
136cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId,
137cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     SharedPaneDescriptor StoreView (
140cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XView>& rxView,
141cdf0e10cSrcweir         const SharedBitmapDescriptor& rpViewBackground);
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     SharedPaneDescriptor RemovePane (
144cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XResourceId>& rxPaneId);
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     SharedPaneDescriptor RemoveView (
147cdf0e10cSrcweir         const css::uno::Reference<css::drawing::framework::XView>& rxView);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     void CreateBorderWindow (PaneDescriptor& rDescriptor);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     /** Find the pane whose border window is identical to the given border
152cdf0e10cSrcweir         window.
153cdf0e10cSrcweir     */
154cdf0e10cSrcweir     SharedPaneDescriptor FindBorderWindow (
155cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     /** Find the pane whose border window is identical to the given content
158cdf0e10cSrcweir         window.
159cdf0e10cSrcweir     */
160cdf0e10cSrcweir     SharedPaneDescriptor FindContentWindow (
161cdf0e10cSrcweir         const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     /** Find the pane whose pane URL is identical to the given URL string.
164cdf0e10cSrcweir     */
165cdf0e10cSrcweir     SharedPaneDescriptor FindPaneURL (const ::rtl::OUString& rsPaneURL);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     /** Find the pane whose resource id is identical to the given one.
168cdf0e10cSrcweir     */
169cdf0e10cSrcweir     SharedPaneDescriptor FindPaneId (const css::uno::Reference<
170cdf0e10cSrcweir         css::drawing::framework::XResourceId>& rxPaneId);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     SharedPaneDescriptor FindViewURL (const ::rtl::OUString& rsViewURL);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     ::rtl::OUString GetPaneURLForViewURL (const ::rtl::OUString& rsViewURL);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     void ToTop (const SharedPaneDescriptor& rpDescriptor);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     // XEventListener
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     virtual void SAL_CALL disposing (
182cdf0e10cSrcweir         const com::sun::star::lang::EventObject& rEvent)
183cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir private:
186cdf0e10cSrcweir     css::uno::Reference<css::drawing::XPresenterHelper> mxPresenterHelper;
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     PaneList::const_iterator FindIteratorForPaneURL (const ::rtl::OUString& rsPaneURL);
189cdf0e10cSrcweir };
190cdf0e10cSrcweir 
191cdf0e10cSrcweir } } // end of namespace ::sdext::presenter
192cdf0e10cSrcweir 
193cdf0e10cSrcweir #endif
194