1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_starmath.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <rtl/logfile.hxx> 33*cdf0e10cSrcweir #include <svl/eitem.hxx> 34*cdf0e10cSrcweir #include <sfx2/app.hxx> 35*cdf0e10cSrcweir #include <svl/intitem.hxx> 36*cdf0e10cSrcweir #include <svtools/imgdef.hxx> 37*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 38*cdf0e10cSrcweir #include <sfx2/imgmgr.hxx> 39*cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 40*cdf0e10cSrcweir #include "toolbox.hxx" 41*cdf0e10cSrcweir #ifndef _STARMATH_HRC 42*cdf0e10cSrcweir #include "starmath.hrc" 43*cdf0e10cSrcweir #endif 44*cdf0e10cSrcweir #ifndef _TOOLBOX_HRC_ 45*cdf0e10cSrcweir #include "toolbox.hrc" 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir #include "view.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //////////////////////////////////////////////////////////// 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir static sal_uInt16 GetImageListRID( sal_uInt16 nCategoryRID, sal_Bool bHighContrast ) 53*cdf0e10cSrcweir { 54*cdf0e10cSrcweir sal_uInt16 nRes = 0xFFFF; 55*cdf0e10cSrcweir switch (nCategoryRID) 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir case RID_UNBINOPS_CAT : nRes = RID_IL_UNBINOPS; break; 58*cdf0e10cSrcweir case RID_RELATIONS_CAT : nRes = RID_IL_RELATIONS; break; 59*cdf0e10cSrcweir case RID_SETOPERATIONS_CAT : nRes = RID_IL_SETOPERATIONS; break; 60*cdf0e10cSrcweir case RID_FUNCTIONS_CAT : nRes = RID_IL_FUNCTIONS; break; 61*cdf0e10cSrcweir case RID_OPERATORS_CAT : nRes = RID_IL_OPERATORS; break; 62*cdf0e10cSrcweir case RID_ATTRIBUTES_CAT : nRes = RID_IL_ATTRIBUTES; break; 63*cdf0e10cSrcweir case RID_BRACKETS_CAT : nRes = RID_IL_BRACKETS; break; 64*cdf0e10cSrcweir case RID_FORMAT_CAT : nRes = RID_IL_FORMAT; break; 65*cdf0e10cSrcweir case RID_MISC_CAT : nRes = RID_IL_MISC; break; 66*cdf0e10cSrcweir default : 67*cdf0e10cSrcweir DBG_ERROR( "unkown category" ); 68*cdf0e10cSrcweir } 69*cdf0e10cSrcweir if (nRes != 0xFFFF && bHighContrast) 70*cdf0e10cSrcweir ++nRes; //! the resource ID for the high contrast image list is just +1 compared to the regular ones 71*cdf0e10cSrcweir return nRes; 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir static sal_Int16 GetToolBoxCategoriesIndex( sal_uInt16 nCategoryRID ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir sal_Int16 nIdx = -1; 78*cdf0e10cSrcweir switch (nCategoryRID) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir case RID_UNBINOPS_CAT : nIdx = 0; break; 81*cdf0e10cSrcweir case RID_RELATIONS_CAT : nIdx = 1; break; 82*cdf0e10cSrcweir case RID_SETOPERATIONS_CAT : nIdx = 2; break; 83*cdf0e10cSrcweir case RID_FUNCTIONS_CAT : nIdx = 3; break; 84*cdf0e10cSrcweir case RID_OPERATORS_CAT : nIdx = 4; break; 85*cdf0e10cSrcweir case RID_ATTRIBUTES_CAT : nIdx = 5; break; 86*cdf0e10cSrcweir case RID_BRACKETS_CAT : nIdx = 6; break; 87*cdf0e10cSrcweir case RID_FORMAT_CAT : nIdx = 7; break; 88*cdf0e10cSrcweir case RID_MISC_CAT : nIdx = 8; break; 89*cdf0e10cSrcweir default: 90*cdf0e10cSrcweir ; 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir return nIdx; 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir static sal_uInt16 GetCategoryRID( sal_uInt16 nResId ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir sal_uInt16 nRes = 0xFFFF; 99*cdf0e10cSrcweir switch (nResId) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir case RID_IL_UNBINOPS : 102*cdf0e10cSrcweir case RID_ILH_UNBINOPS : nRes = RID_UNBINOPS_CAT; break; 103*cdf0e10cSrcweir case RID_IL_RELATIONS : 104*cdf0e10cSrcweir case RID_ILH_RELATIONS : nRes = RID_RELATIONS_CAT; break; 105*cdf0e10cSrcweir case RID_IL_SETOPERATIONS : 106*cdf0e10cSrcweir case RID_ILH_SETOPERATIONS : nRes = RID_SETOPERATIONS_CAT; break; 107*cdf0e10cSrcweir case RID_IL_FUNCTIONS : 108*cdf0e10cSrcweir case RID_ILH_FUNCTIONS : nRes = RID_FUNCTIONS_CAT; break; 109*cdf0e10cSrcweir case RID_IL_OPERATORS : 110*cdf0e10cSrcweir case RID_ILH_OPERATORS : nRes = RID_OPERATORS_CAT; break; 111*cdf0e10cSrcweir case RID_IL_ATTRIBUTES : 112*cdf0e10cSrcweir case RID_ILH_ATTRIBUTES : nRes = RID_ATTRIBUTES_CAT; break; 113*cdf0e10cSrcweir case RID_IL_BRACKETS : 114*cdf0e10cSrcweir case RID_ILH_BRACKETS : nRes = RID_BRACKETS_CAT; break; 115*cdf0e10cSrcweir case RID_IL_FORMAT : 116*cdf0e10cSrcweir case RID_ILH_FORMAT : nRes = RID_FORMAT_CAT; break; 117*cdf0e10cSrcweir case RID_IL_MISC : 118*cdf0e10cSrcweir case RID_ILH_MISC : nRes = RID_MISC_CAT; break; 119*cdf0e10cSrcweir default : 120*cdf0e10cSrcweir if (nResId != RID_IL_CATALOG && nResId != RID_ILH_CATALOG) 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 123*cdf0e10cSrcweir DBG_ERROR( "unkown category" ); 124*cdf0e10cSrcweir #endif 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir return nRes; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //////////////////////////////////////////////////////////// 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir SmToolBoxWindow::SmToolBoxWindow(SfxBindings *pTmpBindings, 135*cdf0e10cSrcweir SfxChildWindow *pChildWindow, 136*cdf0e10cSrcweir Window *pParent) : 137*cdf0e10cSrcweir SfxFloatingWindow(pTmpBindings, pChildWindow, pParent, SmResId(RID_TOOLBOXWINDOW)), 138*cdf0e10cSrcweir aToolBoxCat(this, SmResId(TOOLBOX_CATALOG)), 139*cdf0e10cSrcweir aToolBoxCat_Delim(this, SmResId( FL_TOOLBOX_CAT_DELIM )) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmToolBoxWindow::SmToolBoxWindow" ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // allow for cursor travelling between toolbox and sub-categories 144*cdf0e10cSrcweir SetStyle( GetStyle() | WB_DIALOGCONTROL ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir nActiveCategoryRID = USHRT_MAX; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir aToolBoxCat.SetClickHdl(LINK(this, SmToolBoxWindow, CategoryClickHdl)); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir sal_uInt16 i; 151*cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES; ++i) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir ToolBox *pBox = new ToolBox(this, SmResId( TOOLBOX_CAT_A + i )); 154*cdf0e10cSrcweir vToolBoxCategories[i] = pBox; 155*cdf0e10cSrcweir pBox->SetSelectHdl(LINK(this, SmToolBoxWindow, CmdSelectHdl)); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir pToolBoxCmd = vToolBoxCategories[0]; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir for (i = 0; i <= NUM_TBX_CATEGORIES; ++i) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir aImageLists [i] = 0; 162*cdf0e10cSrcweir aImageListsH[i] = 0; 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir FreeResource(); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir SmToolBoxWindow::~SmToolBoxWindow() 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir int i; 171*cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES; ++i) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir ToolBox *pBox = vToolBoxCategories[i]; 174*cdf0e10cSrcweir delete pBox; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES + 1; ++i) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir delete aImageLists[i]; 179*cdf0e10cSrcweir delete aImageListsH[i]; 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir SmViewShell * SmToolBoxWindow::GetView() 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell(); 187*cdf0e10cSrcweir return PTR_CAST(SmViewShell, pView); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir const ImageList * SmToolBoxWindow::GetImageList( sal_uInt16 nResId, sal_Bool bHighContrast ) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir // creates the image list via its resource id and stores that 194*cdf0e10cSrcweir // list for later use in the respective array. 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir const ImageList *pIL = 0; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir // get index to use 199*cdf0e10cSrcweir sal_uInt16 nCategoryRID = GetCategoryRID( nResId ); 200*cdf0e10cSrcweir sal_Int16 nIndex = GetToolBoxCategoriesIndex( nCategoryRID ); 201*cdf0e10cSrcweir if (nIndex == -1 && (nResId == RID_IL_CATALOG || nResId == RID_ILH_CATALOG)) 202*cdf0e10cSrcweir nIndex = NUM_TBX_CATEGORIES; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if (nIndex >= 0) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir ImageList **pImgList = bHighContrast ? aImageListsH : aImageLists; 207*cdf0e10cSrcweir if (!pImgList[ nIndex ]) 208*cdf0e10cSrcweir pImgList[ nIndex ] = new ImageList( SmResId(nResId) ); 209*cdf0e10cSrcweir pIL = pImgList[ nIndex ]; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir DBG_ASSERT( pIL, "image list not found!" ); 213*cdf0e10cSrcweir return pIL; 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir void SmToolBoxWindow::ApplyImageLists( sal_uInt16 nCategoryRID ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir // set image list for toolbox 'catalog' 222*cdf0e10cSrcweir const ImageList *pImageList = GetImageList( bHighContrast ? RID_ILH_CATALOG : RID_IL_CATALOG, bHighContrast ); 223*cdf0e10cSrcweir DBG_ASSERT( pImageList, "image list missing" ); 224*cdf0e10cSrcweir if (pImageList) 225*cdf0e10cSrcweir aToolBoxCat.SetImageList( *pImageList ); 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir // set image list for active (visible) category of 'catalog' 228*cdf0e10cSrcweir sal_Int16 nIdx = GetToolBoxCategoriesIndex( nCategoryRID ); 229*cdf0e10cSrcweir sal_uInt16 nResId = GetImageListRID( nCategoryRID, bHighContrast ); 230*cdf0e10cSrcweir pImageList = GetImageList( nResId, bHighContrast ); 231*cdf0e10cSrcweir DBG_ASSERT( pImageList && nIdx >= 0, "image list or index missing" ); 232*cdf0e10cSrcweir if (pImageList && nIdx >= 0) 233*cdf0e10cSrcweir vToolBoxCategories[ nIdx ]->SetImageList( *pImageList ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir void SmToolBoxWindow::DataChanged( const DataChangedEvent &rEvt ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir if ( (rEvt.GetType() == DATACHANGED_SETTINGS) && (rEvt.GetFlags() & SETTINGS_STYLE) ) 239*cdf0e10cSrcweir ApplyImageLists( nActiveCategoryRID ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir SfxFloatingWindow::DataChanged( rEvt ); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir void SmToolBoxWindow::StateChanged( StateChangedType nStateChange ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir static sal_Bool bSetPosition = sal_True; 247*cdf0e10cSrcweir if (STATE_CHANGE_INITSHOW == nStateChange) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir SetCategory( nActiveCategoryRID == USHRT_MAX ? RID_UNBINOPS_CAT : nActiveCategoryRID ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir // calculate initial position to be used after creation of the window... 252*cdf0e10cSrcweir AdjustPosSize( bSetPosition ); 253*cdf0e10cSrcweir bSetPosition = sal_False; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir //... otherwise the base class will remember the last position of the window 256*cdf0e10cSrcweir SfxFloatingWindow::StateChanged( nStateChange ); 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir void SmToolBoxWindow::AdjustPosSize( sal_Bool bSetPos ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir Size aCatSize( aToolBoxCat.CalcWindowSizePixel( 2 ) ); 263*cdf0e10cSrcweir Size aCmdSize( pToolBoxCmd->CalcWindowSizePixel( 4 /* see nLines in SetCategory*/ ) ); 264*cdf0e10cSrcweir DBG_ASSERT( aCatSize.Width() == aCmdSize.Width(), "width mismatch" ); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir // catalog settings 267*cdf0e10cSrcweir aToolBoxCat.SetPosPixel( Point(0, 3) ); 268*cdf0e10cSrcweir aToolBoxCat.SetSizePixel( aCatSize ); 269*cdf0e10cSrcweir // settings for catalog / category delimiter 270*cdf0e10cSrcweir Point aP( aToolBoxCat_Delim.GetPosPixel() ); 271*cdf0e10cSrcweir aP.X() = 0; 272*cdf0e10cSrcweir aToolBoxCat_Delim.SetPosPixel( aP ); 273*cdf0e10cSrcweir aToolBoxCat_Delim.SetSizePixel( Size( aCatSize.Width(), aToolBoxCat_Delim.GetSizePixel().Height() ) ); 274*cdf0e10cSrcweir // category settings 275*cdf0e10cSrcweir aP.Y() += aToolBoxCat_Delim.GetSizePixel().Height(); 276*cdf0e10cSrcweir for (int i = 0; i < NUM_TBX_CATEGORIES; ++i) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir vToolBoxCategories[i]->SetPosPixel( aP ); 279*cdf0e10cSrcweir vToolBoxCategories[i]->SetSizePixel( aCmdSize ); 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir // main window settings 282*cdf0e10cSrcweir Size aWndSize ( aCatSize.Width(), pToolBoxCmd->GetPosPixel().Y() + pToolBoxCmd->GetSizePixel().Height() + 3); 283*cdf0e10cSrcweir SetOutputSizePixel( aWndSize ); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir if (bSetPos) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir SmViewShell *pView = GetView(); 288*cdf0e10cSrcweir DBG_ASSERT( pView, "view shell missing" ); 289*cdf0e10cSrcweir Point aPos( 50, 75 ); 290*cdf0e10cSrcweir if (pView) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir SmGraphicWindow &rWin = pView->GetGraphicWindow(); 293*cdf0e10cSrcweir aPos = Point( rWin.OutputToScreenPixel( 294*cdf0e10cSrcweir Point( rWin.GetSizePixel().Width() - aWndSize.Width(), 0) ) ); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir if (aPos.X() < 0) 297*cdf0e10cSrcweir aPos.X() = 0; 298*cdf0e10cSrcweir if (aPos.Y() < 0) 299*cdf0e10cSrcweir aPos.Y() = 0; 300*cdf0e10cSrcweir SetPosPixel( aPos ); 301*cdf0e10cSrcweir } 302*cdf0e10cSrcweir } 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir sal_Bool SmToolBoxWindow::Close() 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir SmViewShell *pViewSh = GetView(); 308*cdf0e10cSrcweir if (pViewSh) 309*cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->Execute( 310*cdf0e10cSrcweir SID_TOOLBOX, SFX_CALLMODE_STANDARD, 311*cdf0e10cSrcweir new SfxBoolItem(SID_TOOLBOX, sal_False), 0L); 312*cdf0e10cSrcweir return sal_True; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir void SmToolBoxWindow::GetFocus() 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir // give focus to category toolbox 318*cdf0e10cSrcweir // (allow for cursor travelling when a category is selected with the mouse) 319*cdf0e10cSrcweir aToolBoxCat.GrabFocus(); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir void SmToolBoxWindow::SetCategory(sal_uInt16 nCategoryRID) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir if (nCategoryRID != nActiveCategoryRID) 325*cdf0e10cSrcweir ApplyImageLists( nCategoryRID ); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir sal_uInt16 nLines; 328*cdf0e10cSrcweir // check for valid resource id 329*cdf0e10cSrcweir switch (nCategoryRID) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir case RID_UNBINOPS_CAT : nLines = 4; break; 332*cdf0e10cSrcweir case RID_RELATIONS_CAT: nLines = 4; break; 333*cdf0e10cSrcweir case RID_SETOPERATIONS_CAT: nLines = 4; break; 334*cdf0e10cSrcweir case RID_FUNCTIONS_CAT: nLines = 4; break; 335*cdf0e10cSrcweir case RID_OPERATORS_CAT: nLines = 3; break; 336*cdf0e10cSrcweir case RID_ATTRIBUTES_CAT: nLines = 4; break; 337*cdf0e10cSrcweir case RID_MISC_CAT: nLines = 4; break; 338*cdf0e10cSrcweir case RID_BRACKETS_CAT: nLines = 4; break; 339*cdf0e10cSrcweir case RID_FORMAT_CAT: nLines = 3; break; 340*cdf0e10cSrcweir default: 341*cdf0e10cSrcweir // nothing to be done 342*cdf0e10cSrcweir return; 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir pToolBoxCmd->Hide(); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir sal_Int16 nIdx = GetToolBoxCategoriesIndex( nCategoryRID ); 348*cdf0e10cSrcweir DBG_ASSERT( nIdx >= 0, "unkown category" ); 349*cdf0e10cSrcweir if (nIdx >= 0) 350*cdf0e10cSrcweir pToolBoxCmd = vToolBoxCategories[nIdx]; 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir // calculate actual size of window to use 353*cdf0e10cSrcweir Size aCatSize( aToolBoxCat.CalcWindowSizePixel( 2 ) ); 354*cdf0e10cSrcweir Size aCmdSize( pToolBoxCmd->CalcWindowSizePixel( nLines ) ); 355*cdf0e10cSrcweir DBG_ASSERT( aCatSize.Width() == aCmdSize.Width(), "width mismatch" ); 356*cdf0e10cSrcweir // main window settings 357*cdf0e10cSrcweir Size aWndSize ( aCatSize.Width(), pToolBoxCmd->GetPosPixel().Y() + aCmdSize.Height() + 3); 358*cdf0e10cSrcweir SetOutputSizePixel( aWndSize ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir if (nActiveCategoryRID) 361*cdf0e10cSrcweir aToolBoxCat.CheckItem(nActiveCategoryRID, sal_False); 362*cdf0e10cSrcweir nActiveCategoryRID = nCategoryRID; 363*cdf0e10cSrcweir aToolBoxCat.CheckItem(nActiveCategoryRID, sal_True); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir pToolBoxCmd->Show(); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir IMPL_LINK( SmToolBoxWindow, CategoryClickHdl, ToolBox*, pToolBox) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir int nItemId = pToolBox->GetCurItemId(); 372*cdf0e10cSrcweir if (nItemId != 0) 373*cdf0e10cSrcweir SetCategory( sal::static_int_cast< sal_uInt16 >(nItemId) ); 374*cdf0e10cSrcweir return 0; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir IMPL_LINK( SmToolBoxWindow, CmdSelectHdl, ToolBox*, pToolBox) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir SmViewShell *pViewSh = GetView(); 381*cdf0e10cSrcweir if (pViewSh) 382*cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->Execute( 383*cdf0e10cSrcweir SID_INSERTCOMMAND, SFX_CALLMODE_STANDARD, 384*cdf0e10cSrcweir new SfxInt16Item(SID_INSERTCOMMAND, pToolBox->GetCurItemId()), 0L); 385*cdf0e10cSrcweir return 0; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir /**************************************************************************/ 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir SFX_IMPL_FLOATINGWINDOW(SmToolBoxWrapper, SID_TOOLBOXWINDOW); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir SmToolBoxWrapper::SmToolBoxWrapper(Window *pParentWindow, 394*cdf0e10cSrcweir sal_uInt16 nId, SfxBindings* pBindings, 395*cdf0e10cSrcweir SfxChildWinInfo *pInfo) : 396*cdf0e10cSrcweir SfxChildWindow(pParentWindow, nId) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir pWindow = new SmToolBoxWindow(pBindings, this, pParentWindow); 401*cdf0e10cSrcweir ((SfxFloatingWindow *)pWindow)->Initialize(pInfo); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir 405