1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SD_SOURCE_UI_INC_VIEWTABBAR_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_VIEWTABBAR_HXX
23 #include <com/sun/star/frame/XController.hpp>
24 #include <com/sun/star/drawing/framework/XPane.hpp>
25 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
26 #include <com/sun/star/drawing/framework/XTabBar.hpp>
27 #include <com/sun/star/drawing/framework/XToolBar.hpp>
28 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
29 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <vcl/tabctrl.hxx>
32 #include <cppuhelper/compbase4.hxx>
33 #include "MutexOwner.hxx"
36 #include <boost/scoped_ptr.hpp>
37 #include <boost/shared_ptr.hpp>
44 typedef ::cppu::WeakComponentImplHelper4
<
45 ::com::sun::star::drawing::framework::XToolBar
,
46 ::com::sun::star::drawing::framework::XTabBar
,
47 ::com::sun::star::drawing::framework::XConfigurationChangeListener
,
48 ::com::sun::star::lang::XUnoTunnel
49 > ViewTabBarInterfaceBase
;
54 /** Tab control for switching between views in the center pane.
57 : private sd::MutexOwner
,
58 public ViewTabBarInterfaceBase
62 const ::com::sun::star::uno::Reference
<
63 com::sun::star::drawing::framework::XResourceId
>& rxViewTabBarId
,
64 const ::com::sun::star::uno::Reference
<
65 ::com::sun::star::frame::XController
>& rxController
);
66 virtual ~ViewTabBar();
68 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
70 VclPtr
< ::TabControl
> GetTabControl() const { return mpTabControl
;}
74 //----- drawing::framework::XConfigurationChangeListener ------------------
77 notifyConfigurationChange (
78 const ::com::sun::star::drawing::framework::ConfigurationChangeEvent
& rEvent
)
79 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
81 //----- XEventListener ----------------------------------------------------
83 virtual void SAL_CALL
disposing(
84 const com::sun::star::lang::EventObject
& rEvent
)
85 throw (com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
87 //----- XTabBar -----------------------------------------------------------
90 SAL_CALL
addTabBarButtonAfter (
91 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
,
92 const ::com::sun::star::drawing::framework::TabBarButton
& rAnchor
)
93 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
96 SAL_CALL
appendTabBarButton (
97 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
)
98 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 SAL_CALL
removeTabBarButton (
102 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
)
103 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
106 SAL_CALL
hasTabBarButton (
107 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
)
108 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
110 virtual ::com::sun::star::uno::Sequence
<com::sun::star::drawing::framework::TabBarButton
>
111 SAL_CALL
getTabBarButtons()
112 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 //----- XResource ---------------------------------------------------------
116 virtual ::com::sun::star::uno::Reference
<
117 ::com::sun::star::drawing::framework::XResourceId
> SAL_CALL
getResourceId()
118 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 virtual sal_Bool SAL_CALL
isAnchorOnly()
121 throw (com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
123 //----- XUnoTunnel --------------------------------------------------------
125 virtual sal_Int64 SAL_CALL
getSomething (const com::sun::star::uno::Sequence
<sal_Int8
>& rId
)
126 throw (com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 /** The returned value is calculated as the difference between the
129 total height of the control and the heigh of its first tab page.
130 This can be considered a hack.
131 This procedure works only when the control is visible. Calling this
132 method when the control is not visible results in returning a
134 To be on the safe side wait for this control to become visible and
135 the call this method again.
139 void AddTabBarButton (
140 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
,
141 const ::com::sun::star::drawing::framework::TabBarButton
& rAnchor
);
142 void AddTabBarButton (
143 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
);
144 void RemoveTabBarButton (
145 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
);
146 bool HasTabBarButton (
147 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
);
148 ::com::sun::star::uno::Sequence
<com::sun::star::drawing::framework::TabBarButton
>
152 VclPtr
< ::TabControl
> mpTabControl
;
153 ::com::sun::star::uno::Reference
<
154 ::com::sun::star::frame::XController
> mxController
;
155 ::com::sun::star::uno::Reference
<
156 ::com::sun::star::drawing::framework::XConfigurationController
> mxConfigurationController
;
157 typedef ::std::vector
<com::sun::star::drawing::framework::TabBarButton
> TabBarButtonList
;
158 TabBarButtonList maTabBarButtons
;
159 VclPtr
<TabPage
> mpTabPage
;
160 ::com::sun::star::uno::Reference
<
161 ::com::sun::star::drawing::framework::XResourceId
> mxViewTabBarId
;
162 ViewShellBase
* mpViewShellBase
;
164 void UpdateActiveButton();
165 void AddTabBarButton (
166 const ::com::sun::star::drawing::framework::TabBarButton
& rButton
,
167 sal_Int32 nPosition
);
168 void UpdateTabBarButtons();
170 /** This method is called from the constructor to get the window for an
171 anchor ResourceId and pass it to our base class. It has to be
172 static because it must not access any of the, not yet initialized
175 static vcl::Window
* GetAnchorWindow(
176 const ::com::sun::star::uno::Reference
<
177 ::com::sun::star::drawing::framework::XResourceId
>& rxViewTabBarId
,
178 const ::com::sun::star::uno::Reference
<
179 ::com::sun::star::frame::XController
>& rxController
);
180 static const ::com::sun::star::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
183 } // end of namespace sd
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */