Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <toolkit/awt/vclxtabpagecontainer.hxx>
30 : : #include <com/sun/star/awt/tab/XTabPageModel.hpp>
31 : : #include <com/sun/star/awt/XControl.hpp>
32 : : #include <vcl/tabpage.hxx>
33 : : #include <vcl/tabctrl.hxx>
34 : : #include <vcl/svapp.hxx>
35 : : #include <toolkit/helper/property.hxx>
36 : : #include <toolkit/helper/vclunohelper.hxx>
37 : : #include <toolkit/helper/tkresmgr.hxx>
38 : : #include <cppuhelper/typeprovider.hxx>
39 : :
40 : : using ::rtl::OUString;
41 : : using namespace ::com::sun::star;
42 : : using namespace ::com::sun::star::uno;
43 : : using namespace ::com::sun::star::lang;
44 : : using namespace ::com::sun::star::beans;
45 : : using namespace ::com::sun::star::container;
46 : : using namespace ::com::sun::star::view;
47 : : // ----------------------------------------------------
48 : : // class VCLXTabPageContainer
49 : : // ----------------------------------------------------
50 : 0 : void VCLXTabPageContainer::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds )
51 : : {
52 : 0 : VCLXWindow::ImplGetPropertyIds( rIds );
53 : 0 : }
54 : :
55 : 0 : VCLXTabPageContainer::VCLXTabPageContainer() :
56 [ # # ][ # # ]: 0 : m_aTabPageListeners( *this )
57 : : {
58 : 0 : }
59 : :
60 [ # # ]: 0 : VCLXTabPageContainer::~VCLXTabPageContainer()
61 : : {
62 : : #ifndef __SUNPRO_CC
63 : : OSL_TRACE ("%s", __FUNCTION__);
64 : : #endif
65 [ # # ]: 0 : }
66 : :
67 : 0 : void SAL_CALL VCLXTabPageContainer::draw( sal_Int32 nX, sal_Int32 nY ) throw(RuntimeException)
68 : : {
69 [ # # ]: 0 : SolarMutexGuard aGuard;
70 : 0 : TabControl* pTabControl = (TabControl*)GetWindow();
71 [ # # ]: 0 : if ( pTabControl )
72 : : {
73 [ # # ][ # # ]: 0 : TabPage *pTabPage = pTabControl->GetTabPage( sal::static_int_cast< sal_uInt16 >( pTabControl->GetCurPageId( ) ) );
74 [ # # ]: 0 : if ( pTabPage )
75 : : {
76 : 0 : ::Point aPos( nX, nY );
77 [ # # ]: 0 : ::Size aSize = pTabPage->GetSizePixel();
78 : :
79 [ # # ][ # # ]: 0 : OutputDevice* pDev = VCLUnoHelper::GetOutputDevice( getGraphics() );
80 [ # # ]: 0 : aPos = pDev->PixelToLogic( aPos );
81 [ # # ]: 0 : aSize = pDev->PixelToLogic( aSize );
82 : :
83 [ # # ]: 0 : pTabPage->Draw( pDev, aPos, aSize, 0 );
84 : : }
85 : : }
86 : :
87 [ # # ][ # # ]: 0 : VCLXWindow::draw( nX, nY );
88 : 0 : }
89 : :
90 : 0 : ::com::sun::star::awt::DeviceInfo VCLXTabPageContainer::getInfo() throw(RuntimeException)
91 : : {
92 : 0 : ::com::sun::star::awt::DeviceInfo aInfo = VCLXDevice::getInfo();
93 : 0 : return aInfo;
94 : : }
95 : :
96 : 0 : void SAL_CALL VCLXTabPageContainer::setProperty(const ::rtl::OUString& PropertyName, const Any& Value ) throw(RuntimeException)
97 : : {
98 [ # # ]: 0 : SolarMutexGuard aGuard;
99 : :
100 : 0 : TabControl* pTabPage = (TabControl*)GetWindow();
101 [ # # ]: 0 : if ( pTabPage )
102 : : {
103 [ # # ]: 0 : VCLXWindow::setProperty( PropertyName, Value );
104 [ # # ]: 0 : }
105 : 0 : }
106 : 0 : ::sal_Int16 SAL_CALL VCLXTabPageContainer::getActiveTabPageID() throw (RuntimeException)
107 : : {
108 : 0 : TabControl* pTabCtrl = (TabControl*)GetWindow();
109 [ # # ]: 0 : return pTabCtrl != NULL ? pTabCtrl->GetCurPageId( ) : 0;
110 : : }
111 : 0 : void SAL_CALL VCLXTabPageContainer::setActiveTabPageID( ::sal_Int16 _activetabpageid ) throw (RuntimeException)
112 : : {
113 : 0 : TabControl* pTabCtrl = (TabControl*)GetWindow();
114 [ # # ]: 0 : if ( pTabCtrl )
115 : 0 : pTabCtrl->SelectTabPage(_activetabpageid);
116 : 0 : }
117 : 0 : ::sal_Int32 SAL_CALL VCLXTabPageContainer::getTabPageCount( ) throw (RuntimeException)
118 : : {
119 : 0 : TabControl* pTabCtrl = (TabControl*)GetWindow();
120 [ # # ]: 0 : return pTabCtrl != NULL ? pTabCtrl->GetPageCount() : 0;
121 : : }
122 : 0 : ::sal_Bool SAL_CALL VCLXTabPageContainer::isTabPageActive( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
123 : : {
124 : 0 : return (getActiveTabPageID() == tabPageIndex);
125 : : }
126 : 0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPage( ::sal_Int16 tabPageIndex ) throw (RuntimeException)
127 : : {
128 [ # # ][ # # ]: 0 : return (tabPageIndex >= 0 && tabPageIndex < static_cast<sal_Int16>(m_aTabPages.size())) ? m_aTabPages[tabPageIndex] : NULL;
129 : : }
130 : 0 : Reference< ::com::sun::star::awt::tab::XTabPage > SAL_CALL VCLXTabPageContainer::getTabPageByID( ::sal_Int16 tabPageID ) throw (RuntimeException)
131 : : {
132 [ # # ]: 0 : SolarMutexGuard aGuard;
133 : 0 : Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage;
134 : 0 : ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aIter = m_aTabPages.begin();
135 : 0 : ::std::vector< Reference< ::com::sun::star::awt::tab::XTabPage > >::iterator aEnd = m_aTabPages.end();
136 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
137 : : {
138 [ # # ]: 0 : Reference< awt::XControl > xControl(*aIter,UNO_QUERY );
139 [ # # ][ # # ]: 0 : Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
[ # # ]
140 [ # # ][ # # ]: 0 : if ( tabPageID == xP->getTabPageID() )
[ # # ]
141 : : {
142 [ # # ]: 0 : xTabPage = *aIter;
143 : : break;
144 : : }
145 [ # # ][ # # ]: 0 : }
146 [ # # ]: 0 : return xTabPage;
147 : : }
148 : 0 : void SAL_CALL VCLXTabPageContainer::addTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
149 : : {
150 : 0 : m_aTabPageListeners.addInterface( listener );
151 : 0 : }
152 : 0 : void SAL_CALL VCLXTabPageContainer::removeTabPageListener( const Reference< ::com::sun::star::awt::tab::XTabPageContainerListener >& listener ) throw (RuntimeException)
153 : : {
154 : 0 : m_aTabPageListeners.removeInterface( listener );
155 : 0 : }
156 : :
157 : 0 : void VCLXTabPageContainer::ProcessWindowEvent( const VclWindowEvent& _rVclWindowEvent )
158 : : {
159 [ # # ]: 0 : SolarMutexClearableGuard aGuard;
160 : 0 : TabControl* pTabControl = static_cast< TabControl* >( GetWindow() );
161 [ # # ]: 0 : if ( pTabControl )
162 : : {
163 [ # # ]: 0 : switch ( _rVclWindowEvent.GetId() )
164 : : {
165 : : case VCLEVENT_TABPAGE_ACTIVATE:
166 : : {
167 : 0 : sal_uLong page = (sal_uLong)_rVclWindowEvent.GetData();
168 [ # # ][ # # ]: 0 : awt::tab::TabPageActivatedEvent aEvent(NULL,page);
169 [ # # ]: 0 : m_aTabPageListeners.tabPageActivated(aEvent);
170 [ # # ]: 0 : break;
171 : : }
172 : : default:
173 [ # # ]: 0 : aGuard.clear();
174 [ # # ]: 0 : VCLXWindow::ProcessWindowEvent( _rVclWindowEvent );
175 : 0 : break;
176 : : }
177 [ # # ]: 0 : }
178 : 0 : }
179 : 0 : void SAL_CALL VCLXTabPageContainer::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
180 : : {
181 : 0 : }
182 : 0 : void SAL_CALL VCLXTabPageContainer::elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
183 : : {
184 [ # # ]: 0 : SolarMutexGuard aGuard;
185 : 0 : TabControl* pTabCtrl = (TabControl*)GetWindow();
186 [ # # ]: 0 : Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
187 [ # # ][ # # ]: 0 : if ( pTabCtrl && xTabPage.is() )
[ # # ]
188 : : {
189 [ # # ]: 0 : Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
190 [ # # ][ # # ]: 0 : Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
[ # # ]
191 [ # # ][ # # ]: 0 : sal_Int16 nPageID = xP->getTabPageID();
192 : :
193 [ # # ][ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
[ # # ]
194 : 0 : TabPage* pPage = (TabPage*)pWindow;
195 [ # # ][ # # ]: 0 : pTabCtrl->InsertPage(nPageID,pPage->GetText());
[ # # ]
196 : :
197 [ # # ]: 0 : pPage->Hide();
198 [ # # ]: 0 : pTabCtrl->SetTabPage(nPageID,pPage);
199 [ # # ][ # # ]: 0 : pTabCtrl->SetHelpText(nPageID,xP->getTooltip());
[ # # ][ # # ]
[ # # ]
200 [ # # ][ # # ]: 0 : pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL()));
[ # # ][ # # ]
[ # # ]
201 [ # # ]: 0 : pTabCtrl->SelectTabPage(nPageID);
202 [ # # ]: 0 : m_aTabPages.push_back(xTabPage);
203 [ # # ]: 0 : }
204 : 0 : }
205 : 0 : void SAL_CALL VCLXTabPageContainer::elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException)
206 : : {
207 [ # # ]: 0 : SolarMutexGuard aGuard;
208 : 0 : TabControl* pTabCtrl = (TabControl*)GetWindow();
209 [ # # ]: 0 : Reference< ::com::sun::star::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
210 [ # # ][ # # ]: 0 : if ( pTabCtrl && xTabPage.is() )
[ # # ]
211 : : {
212 [ # # ]: 0 : Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
213 [ # # ][ # # ]: 0 : Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
[ # # ]
214 [ # # ][ # # ]: 0 : pTabCtrl->RemovePage(xP->getTabPageID());
[ # # ]
215 [ # # ][ # # ]: 0 : m_aTabPages.erase(::std::remove(m_aTabPages.begin(),m_aTabPages.end(),xTabPage));
216 [ # # ]: 0 : }
217 : 0 : }
218 : 0 : void SAL_CALL VCLXTabPageContainer::elementReplaced( const ::com::sun::star::container::ContainerEvent& /*Event*/ ) throw (::com::sun::star::uno::RuntimeException)
219 : : {
220 : 0 : }
221 : :
222 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|