122de8995SAndre Fischer /************************************************************** 222de8995SAndre Fischer * 322de8995SAndre Fischer * Licensed to the Apache Software Foundation (ASF) under one 422de8995SAndre Fischer * or more contributor license agreements. See the NOTICE file 522de8995SAndre Fischer * distributed with this work for additional information 622de8995SAndre Fischer * regarding copyright ownership. The ASF licenses this file 722de8995SAndre Fischer * to you under the Apache License, Version 2.0 (the 822de8995SAndre Fischer * "License"); you may not use this file except in compliance 922de8995SAndre Fischer * with the License. You may obtain a copy of the License at 1022de8995SAndre Fischer * 1122de8995SAndre Fischer * http://www.apache.org/licenses/LICENSE-2.0 1222de8995SAndre Fischer * 1322de8995SAndre Fischer * Unless required by applicable law or agreed to in writing, 1422de8995SAndre Fischer * software distributed under the License is distributed on an 1522de8995SAndre Fischer * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1622de8995SAndre Fischer * KIND, either express or implied. See the License for the 1722de8995SAndre Fischer * specific language governing permissions and limitations 1822de8995SAndre Fischer * under the License. 1922de8995SAndre Fischer * 2022de8995SAndre Fischer *************************************************************/ 2122de8995SAndre Fischer 2222de8995SAndre Fischer #include "precompiled_sfx2.hxx" 2322de8995SAndre Fischer 2422de8995SAndre Fischer #include "TabBar.hxx" 25ff12d537SAndre Fischer #include "TabItem.hxx" 2695a18594SAndre Fischer #include "sidebar/ControlFactory.hxx" 27ff12d537SAndre Fischer #include "DeckDescriptor.hxx" 28ff12d537SAndre Fischer #include "Paint.hxx" 29b9e67834SAndre Fischer #include "sfx2/sidebar/Theme.hxx" 30b9e67834SAndre Fischer #include "Tools.hxx" 31*65908a7eSAndre Fischer #include "FocusManager.hxx" 32ff12d537SAndre Fischer 3322de8995SAndre Fischer #include <vcl/gradient.hxx> 34ff12d537SAndre Fischer #include <vcl/image.hxx> 357a32b0c8SAndre Fischer #include <vcl/wrkwin.hxx> 36ff12d537SAndre Fischer #include <comphelper/processfactory.hxx> 37ff12d537SAndre Fischer #include <comphelper/componentcontext.hxx> 3895a18594SAndre Fischer #include <tools/svborder.hxx> 39ff12d537SAndre Fischer 40ff12d537SAndre Fischer #include <com/sun/star/graphic/XGraphicProvider.hpp> 41ff12d537SAndre Fischer 42ff12d537SAndre Fischer 43ff12d537SAndre Fischer using namespace ::com::sun::star; 44ff12d537SAndre Fischer using namespace ::com::sun::star::uno; 45ff12d537SAndre Fischer 46ff12d537SAndre Fischer 47ff12d537SAndre Fischer 4822de8995SAndre Fischer 49ff12d537SAndre Fischer namespace sfx2 { namespace sidebar { 5022de8995SAndre Fischer 51ff12d537SAndre Fischer TabBar::TabBar ( 52ff12d537SAndre Fischer Window* pParentWindow, 53ff12d537SAndre Fischer const Reference<frame::XFrame>& rxFrame, 5495a18594SAndre Fischer const ::boost::function<void(const ::rtl::OUString&)>& rDeckActivationFunctor, 5595a18594SAndre Fischer const PopupMenuProvider& rPopupMenuProvider) 56*65908a7eSAndre Fischer : Window(pParentWindow, WB_DIALOGCONTROL), 57ff12d537SAndre Fischer mxFrame(rxFrame), 58ff12d537SAndre Fischer mpMenuButton(ControlFactory::CreateMenuButton(this)), 59ff12d537SAndre Fischer maItems(), 60ff12d537SAndre Fischer maDeckActivationFunctor(rDeckActivationFunctor), 61ff12d537SAndre Fischer maPopupMenuProvider(rPopupMenuProvider) 6222de8995SAndre Fischer { 63b9e67834SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper()); 64ff12d537SAndre Fischer 65ff12d537SAndre Fischer mpMenuButton->SetModeImage( 667a32b0c8SAndre Fischer Theme::GetImage(Theme::Image_TabBarMenu), 67ff12d537SAndre Fischer Theme::IsHighContrastMode() 68ff12d537SAndre Fischer ? BMP_COLOR_HIGHCONTRAST 69ff12d537SAndre Fischer : BMP_COLOR_NORMAL); 70ff12d537SAndre Fischer mpMenuButton->SetClickHdl(LINK(this, TabBar, OnToolboxClicked)); 7195a18594SAndre Fischer Layout(); 727a32b0c8SAndre Fischer 737a32b0c8SAndre Fischer #ifdef DEBUG 747a32b0c8SAndre Fischer SetText(A2S("TabBar")); 757a32b0c8SAndre Fischer #endif 7622de8995SAndre Fischer } 7722de8995SAndre Fischer 7822de8995SAndre Fischer 7922de8995SAndre Fischer 8022de8995SAndre Fischer 8122de8995SAndre Fischer TabBar::~TabBar (void) 8222de8995SAndre Fischer { 8322de8995SAndre Fischer } 8422de8995SAndre Fischer 8522de8995SAndre Fischer 8622de8995SAndre Fischer 8722de8995SAndre Fischer 8822de8995SAndre Fischer void TabBar::Paint (const Rectangle& rUpdateArea) 8922de8995SAndre Fischer { 90ff12d537SAndre Fischer Window::Paint(rUpdateArea); 91ff12d537SAndre Fischer 92b9e67834SAndre Fischer const sal_Int32 nHorizontalPadding (Theme::GetInteger(Theme::Int_TabMenuSeparatorPadding)); 93b9e67834SAndre Fischer SetLineColor(Theme::GetColor(Theme::Color_TabMenuSeparator)); 94ff12d537SAndre Fischer DrawLine( 95ff12d537SAndre Fischer Point(nHorizontalPadding, mnMenuSeparatorY), 96ff12d537SAndre Fischer Point(GetSizePixel().Width()-nHorizontalPadding, mnMenuSeparatorY)); 9722de8995SAndre Fischer } 9822de8995SAndre Fischer 9922de8995SAndre Fischer 10022de8995SAndre Fischer 10122de8995SAndre Fischer 10222de8995SAndre Fischer sal_Int32 TabBar::GetDefaultWidth (void) 10322de8995SAndre Fischer { 104b9e67834SAndre Fischer return Theme::GetInteger(Theme::Int_TabItemWidth) 105b9e67834SAndre Fischer + Theme::GetInteger(Theme::Int_TabBarLeftPadding) 106b9e67834SAndre Fischer + Theme::GetInteger(Theme::Int_TabBarRightPadding); 107ff12d537SAndre Fischer } 108ff12d537SAndre Fischer 109ff12d537SAndre Fischer 110ff12d537SAndre Fischer 111ff12d537SAndre Fischer 112ff12d537SAndre Fischer void TabBar::SetDecks ( 11395a18594SAndre Fischer const ResourceManager::IdContainer& rDeckIds) 114ff12d537SAndre Fischer { 115ff12d537SAndre Fischer // Remove the current buttons. 116ff12d537SAndre Fischer { 1177a32b0c8SAndre Fischer for(ItemContainer::iterator 118ff12d537SAndre Fischer iItem(maItems.begin()), iEnd(maItems.end()); 119ff12d537SAndre Fischer iItem!=iEnd; 120ff12d537SAndre Fischer ++iItem) 121ff12d537SAndre Fischer { 1227a32b0c8SAndre Fischer iItem->mpButton.reset(); 123ff12d537SAndre Fischer } 124ff12d537SAndre Fischer maItems.clear(); 125ff12d537SAndre Fischer } 126ff12d537SAndre Fischer 12795a18594SAndre Fischer maItems.resize(rDeckIds.size()); 128ff12d537SAndre Fischer sal_Int32 nIndex (0); 12995a18594SAndre Fischer for (ResourceManager::IdContainer::const_iterator 13095a18594SAndre Fischer iDeckId(rDeckIds.begin()), 13195a18594SAndre Fischer iEnd(rDeckIds.end()); 13295a18594SAndre Fischer iDeckId!=iEnd; 13395a18594SAndre Fischer ++iDeckId) 134ff12d537SAndre Fischer { 13595a18594SAndre Fischer const DeckDescriptor* pDescriptor = ResourceManager::Instance().GetDeckDescriptor(*iDeckId); 13695a18594SAndre Fischer if (pDescriptor == NULL) 13795a18594SAndre Fischer { 13895a18594SAndre Fischer OSL_ASSERT(pDescriptor!=NULL); 13995a18594SAndre Fischer continue; 14095a18594SAndre Fischer } 14195a18594SAndre Fischer 142ff12d537SAndre Fischer Item& rItem (maItems[nIndex++]); 14395a18594SAndre Fischer rItem.msDeckId = pDescriptor->msId; 1447a32b0c8SAndre Fischer rItem.mpButton.reset(CreateTabItem(*pDescriptor)); 145ff12d537SAndre Fischer rItem.mpButton->SetClickHdl(LINK(&rItem, TabBar::Item, HandleClick)); 146ff12d537SAndre Fischer rItem.maDeckActivationFunctor = maDeckActivationFunctor; 147ff12d537SAndre Fischer rItem.mbIsHiddenByDefault = false; 14895a18594SAndre Fischer rItem.mbIsHidden = ! pDescriptor->mbIsEnabled; 149ff12d537SAndre Fischer } 150ff12d537SAndre Fischer 151ff12d537SAndre Fischer UpdateButtonIcons(); 152ff12d537SAndre Fischer Layout(); 153ff12d537SAndre Fischer } 154ff12d537SAndre Fischer 155ff12d537SAndre Fischer 156ff12d537SAndre Fischer 157ff12d537SAndre Fischer 158ff12d537SAndre Fischer void TabBar::UpdateButtonIcons (void) 159ff12d537SAndre Fischer { 160ff12d537SAndre Fischer const BmpColorMode eColorMode ( 161ff12d537SAndre Fischer Theme::IsHighContrastMode() 162ff12d537SAndre Fischer ? BMP_COLOR_HIGHCONTRAST 163ff12d537SAndre Fischer : BMP_COLOR_NORMAL); 164ff12d537SAndre Fischer 1657a32b0c8SAndre Fischer mpMenuButton->SetModeImage(Theme::GetImage(Theme::Image_TabBarMenu), eColorMode); 166ff12d537SAndre Fischer 167ff12d537SAndre Fischer for(ItemContainer::const_iterator 168ff12d537SAndre Fischer iItem(maItems.begin()), iEnd(maItems.end()); 169ff12d537SAndre Fischer iItem!=iEnd; 170ff12d537SAndre Fischer ++iItem) 171ff12d537SAndre Fischer { 17295a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId); 17395a18594SAndre Fischer if (pDeckDescriptor != NULL) 17495a18594SAndre Fischer iItem->mpButton->SetModeImage( 17595a18594SAndre Fischer GetItemImage(*pDeckDescriptor), 17695a18594SAndre Fischer eColorMode); 177ff12d537SAndre Fischer } 17895a18594SAndre Fischer 17995a18594SAndre Fischer Invalidate(); 180ff12d537SAndre Fischer } 181ff12d537SAndre Fischer 182ff12d537SAndre Fischer 183ff12d537SAndre Fischer 184ff12d537SAndre Fischer 185ff12d537SAndre Fischer void TabBar::Layout (void) 186ff12d537SAndre Fischer { 187b9e67834SAndre Fischer const SvBorder aPadding ( 188b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabBarLeftPadding), 189b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabBarTopPadding), 190b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabBarRightPadding), 191b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabBarBottomPadding)); 192ff12d537SAndre Fischer sal_Int32 nX (aPadding.Top()); 193ff12d537SAndre Fischer sal_Int32 nY (aPadding.Left()); 194b9e67834SAndre Fischer const Size aTabItemSize ( 195b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabItemWidth), 196b9e67834SAndre Fischer Theme::GetInteger(Theme::Int_TabItemHeight)); 197ff12d537SAndre Fischer 19895a18594SAndre Fischer // Place the menu button and the separator. 199ff12d537SAndre Fischer if (mpMenuButton != NULL) 200ff12d537SAndre Fischer { 201ff12d537SAndre Fischer mpMenuButton->SetPosSizePixel( 202ff12d537SAndre Fischer Point(nX,nY), 203b9e67834SAndre Fischer aTabItemSize); 204ff12d537SAndre Fischer mpMenuButton->Show(); 205b9e67834SAndre Fischer nY += mpMenuButton->GetSizePixel().Height() + 1 + Theme::GetInteger(Theme::Int_TabMenuPadding); 206b9e67834SAndre Fischer mnMenuSeparatorY = nY - Theme::GetInteger(Theme::Int_TabMenuPadding)/2 - 1; 207ff12d537SAndre Fischer } 20895a18594SAndre Fischer 20995a18594SAndre Fischer // Place the deck selection buttons. 210ff12d537SAndre Fischer for(ItemContainer::const_iterator 211ff12d537SAndre Fischer iItem(maItems.begin()), iEnd(maItems.end()); 212ff12d537SAndre Fischer iItem!=iEnd; 213ff12d537SAndre Fischer ++iItem) 214ff12d537SAndre Fischer { 21595a18594SAndre Fischer Button& rButton (*iItem->mpButton); 21695a18594SAndre Fischer rButton.Show( ! iItem->mbIsHidden); 21795a18594SAndre Fischer 218ff12d537SAndre Fischer if (iItem->mbIsHidden) 219ff12d537SAndre Fischer continue; 220ff12d537SAndre Fischer 221ff12d537SAndre Fischer // Place and size the icon. 222ff12d537SAndre Fischer rButton.SetPosSizePixel( 223ff12d537SAndre Fischer Point(nX,nY), 224b9e67834SAndre Fischer aTabItemSize); 225ff12d537SAndre Fischer rButton.Show(); 226ff12d537SAndre Fischer 227ff12d537SAndre Fischer nY += rButton.GetSizePixel().Height() + 1 + aPadding.Bottom(); 228ff12d537SAndre Fischer } 229ff12d537SAndre Fischer Invalidate(); 230ff12d537SAndre Fischer } 231ff12d537SAndre Fischer 232ff12d537SAndre Fischer 233ff12d537SAndre Fischer 234ff12d537SAndre Fischer 235ff12d537SAndre Fischer void TabBar::HighlightDeck (const ::rtl::OUString& rsDeckId) 236ff12d537SAndre Fischer { 237ff12d537SAndre Fischer for (ItemContainer::const_iterator iItem(maItems.begin()),iEnd(maItems.end()); 238ff12d537SAndre Fischer iItem!=iEnd; 239ff12d537SAndre Fischer ++iItem) 240ff12d537SAndre Fischer { 24195a18594SAndre Fischer if (iItem->msDeckId.equals(rsDeckId)) 242ff12d537SAndre Fischer { 243ff12d537SAndre Fischer iItem->mpButton->Check(); 244ff12d537SAndre Fischer break; 245ff12d537SAndre Fischer } 246ff12d537SAndre Fischer } 247ff12d537SAndre Fischer } 248ff12d537SAndre Fischer 249ff12d537SAndre Fischer 250ff12d537SAndre Fischer 251ff12d537SAndre Fischer 252ff12d537SAndre Fischer void TabBar::DataChanged (const DataChangedEvent& rDataChangedEvent) 253ff12d537SAndre Fischer { 25495a18594SAndre Fischer SetBackground(Theme::GetPaint(Theme::Paint_TabBarBackground).GetWallpaper()); 25595a18594SAndre Fischer UpdateButtonIcons(); 25695a18594SAndre Fischer 25795a18594SAndre Fischer Window::DataChanged(rDataChangedEvent); 258ff12d537SAndre Fischer } 259ff12d537SAndre Fischer 260ff12d537SAndre Fischer 261ff12d537SAndre Fischer 262ff12d537SAndre Fischer 263ff12d537SAndre Fischer RadioButton* TabBar::CreateTabItem (const DeckDescriptor& rDeckDescriptor) 264ff12d537SAndre Fischer { 265ff12d537SAndre Fischer RadioButton* pItem = ControlFactory::CreateTabItem(this); 266ff12d537SAndre Fischer pItem->SetHelpText(rDeckDescriptor.msHelpText); 267ff12d537SAndre Fischer pItem->SetQuickHelpText(rDeckDescriptor.msHelpText); 268ff12d537SAndre Fischer 269ff12d537SAndre Fischer return pItem; 27022de8995SAndre Fischer } 27122de8995SAndre Fischer 27222de8995SAndre Fischer 273ff12d537SAndre Fischer 274ff12d537SAndre Fischer Image TabBar::GetItemImage (const DeckDescriptor& rDeckDescriptor) const 275ff12d537SAndre Fischer { 276b9e67834SAndre Fischer return Tools::GetImage( 277b9e67834SAndre Fischer rDeckDescriptor.msIconURL, 278b9e67834SAndre Fischer rDeckDescriptor.msHighContrastIconURL, 279b9e67834SAndre Fischer mxFrame); 280ff12d537SAndre Fischer } 281ff12d537SAndre Fischer 282ff12d537SAndre Fischer 283ff12d537SAndre Fischer 284ff12d537SAndre Fischer 285ff12d537SAndre Fischer 28695a18594SAndre Fischer IMPL_LINK(TabBar::Item, HandleClick, Button*, EMPTYARG) 287ff12d537SAndre Fischer { 28895a18594SAndre Fischer maDeckActivationFunctor(msDeckId); 28995a18594SAndre Fischer return 1; 290ff12d537SAndre Fischer } 291ff12d537SAndre Fischer 292ff12d537SAndre Fischer 293ff12d537SAndre Fischer 294ff12d537SAndre Fischer 29595a18594SAndre Fischer const ::rtl::OUString TabBar::GetDeckIdForIndex (const sal_Int32 nIndex) const 296ff12d537SAndre Fischer { 29795a18594SAndre Fischer if (nIndex<0 || static_cast<size_t>(nIndex)>=maItems.size()) 298ff12d537SAndre Fischer throw RuntimeException(); 299ff12d537SAndre Fischer else 30095a18594SAndre Fischer return maItems[nIndex].msDeckId; 301ff12d537SAndre Fischer } 302ff12d537SAndre Fischer 303ff12d537SAndre Fischer 304ff12d537SAndre Fischer 305ff12d537SAndre Fischer 306ff12d537SAndre Fischer void TabBar::ToggleHideFlag (const sal_Int32 nIndex) 307ff12d537SAndre Fischer { 30895a18594SAndre Fischer if (nIndex<0 || static_cast<size_t>(nIndex)>=maItems.size()) 309ff12d537SAndre Fischer throw RuntimeException(); 310ff12d537SAndre Fischer else 311ff12d537SAndre Fischer { 312ff12d537SAndre Fischer maItems[nIndex].mbIsHidden = ! maItems[nIndex].mbIsHidden; 31395a18594SAndre Fischer ResourceManager::Instance().SetIsDeckEnabled( 31495a18594SAndre Fischer maItems[nIndex].msDeckId, 31595a18594SAndre Fischer maItems[nIndex].mbIsHidden); 316ff12d537SAndre Fischer Layout(); 317ff12d537SAndre Fischer } 318ff12d537SAndre Fischer } 319ff12d537SAndre Fischer 320ff12d537SAndre Fischer 321ff12d537SAndre Fischer 322ff12d537SAndre Fischer 323ff12d537SAndre Fischer void TabBar::RestoreHideFlags (void) 324ff12d537SAndre Fischer { 325ff12d537SAndre Fischer bool bNeedsLayout (false); 326ff12d537SAndre Fischer for(ItemContainer::iterator iItem(maItems.begin()),iEnd(maItems.end()); 327ff12d537SAndre Fischer iItem!=iEnd; 328ff12d537SAndre Fischer ++iItem) 329ff12d537SAndre Fischer { 330ff12d537SAndre Fischer if (iItem->mbIsHidden != iItem->mbIsHiddenByDefault) 331ff12d537SAndre Fischer { 332ff12d537SAndre Fischer iItem->mbIsHidden = iItem->mbIsHiddenByDefault; 333ff12d537SAndre Fischer bNeedsLayout = true; 334ff12d537SAndre Fischer } 335ff12d537SAndre Fischer } 336ff12d537SAndre Fischer if (bNeedsLayout) 337ff12d537SAndre Fischer Layout(); 338ff12d537SAndre Fischer } 339ff12d537SAndre Fischer 340ff12d537SAndre Fischer 341ff12d537SAndre Fischer 342ff12d537SAndre Fischer 343*65908a7eSAndre Fischer void TabBar::UpdateFocusManager (FocusManager& rFocusManager) 344*65908a7eSAndre Fischer { 345*65908a7eSAndre Fischer ::std::vector<Button*> aButtons; 346*65908a7eSAndre Fischer aButtons.reserve(maItems.size()+1); 347*65908a7eSAndre Fischer 348*65908a7eSAndre Fischer aButtons.push_back(mpMenuButton.get()); 349*65908a7eSAndre Fischer for(ItemContainer::const_iterator 350*65908a7eSAndre Fischer iItem(maItems.begin()), iEnd(maItems.end()); 351*65908a7eSAndre Fischer iItem!=iEnd; 352*65908a7eSAndre Fischer ++iItem) 353*65908a7eSAndre Fischer { 354*65908a7eSAndre Fischer aButtons.push_back(iItem->mpButton.get()); 355*65908a7eSAndre Fischer } 356*65908a7eSAndre Fischer rFocusManager.SetButtons(aButtons); 357*65908a7eSAndre Fischer } 358*65908a7eSAndre Fischer 359*65908a7eSAndre Fischer 360*65908a7eSAndre Fischer 361*65908a7eSAndre Fischer 36295a18594SAndre Fischer IMPL_LINK(TabBar, OnToolboxClicked, void*, EMPTYARG) 363ff12d537SAndre Fischer { 36495a18594SAndre Fischer ::std::vector<DeckMenuData> aSelectionData; 36595a18594SAndre Fischer ::std::vector<DeckMenuData> aShowData; 36695a18594SAndre Fischer 36795a18594SAndre Fischer for(ItemContainer::const_iterator iItem(maItems.begin()),iEnd(maItems.end()); 36895a18594SAndre Fischer iItem!=iEnd; 36995a18594SAndre Fischer ++iItem) 37095a18594SAndre Fischer { 37195a18594SAndre Fischer const DeckDescriptor* pDeckDescriptor = ResourceManager::Instance().GetDeckDescriptor(iItem->msDeckId); 37295a18594SAndre Fischer if (pDeckDescriptor != NULL) 37395a18594SAndre Fischer { 37495a18594SAndre Fischer if ( ! iItem->mbIsHidden) 37595a18594SAndre Fischer aSelectionData.push_back( 37695a18594SAndre Fischer DeckMenuData( 37795a18594SAndre Fischer pDeckDescriptor->msTitle, 37895a18594SAndre Fischer pDeckDescriptor->msId, 37995a18594SAndre Fischer iItem->mpButton->IsChecked())); 38095a18594SAndre Fischer 38195a18594SAndre Fischer aShowData.push_back( 38295a18594SAndre Fischer DeckMenuData( 38395a18594SAndre Fischer pDeckDescriptor->msTitle, 38495a18594SAndre Fischer pDeckDescriptor->msId, 38595a18594SAndre Fischer !iItem->mbIsHidden)); 38695a18594SAndre Fischer } 38795a18594SAndre Fischer } 38895a18594SAndre Fischer 389ff12d537SAndre Fischer maPopupMenuProvider( 390ff12d537SAndre Fischer Rectangle( 391ff12d537SAndre Fischer mpMenuButton->GetPosPixel(), 39295a18594SAndre Fischer mpMenuButton->GetSizePixel()), 39395a18594SAndre Fischer aSelectionData, 39495a18594SAndre Fischer aShowData); 395ff12d537SAndre Fischer 396ff12d537SAndre Fischer return 0; 397ff12d537SAndre Fischer } 398ff12d537SAndre Fischer 399ff12d537SAndre Fischer 400ff12d537SAndre Fischer 401ff12d537SAndre Fischer } } // end of namespace sfx2::sidebar 402