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_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // include --------------------------------------------------------------- 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <limits.h> 34*cdf0e10cSrcweir #include <tools/shl.hxx> 35*cdf0e10cSrcweir #include <vcl/status.hxx> 36*cdf0e10cSrcweir #include <vcl/menu.hxx> 37*cdf0e10cSrcweir #include <vcl/image.hxx> 38*cdf0e10cSrcweir #include <svl/stritem.hxx> 39*cdf0e10cSrcweir #include <svl/ptitem.hxx> 40*cdf0e10cSrcweir #include <svl/itempool.hxx> 41*cdf0e10cSrcweir #include <sfx2/app.hxx> 42*cdf0e10cSrcweir #include <sfx2/module.hxx> 43*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 44*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 45*cdf0e10cSrcweir #include <svl/intitem.hxx> 46*cdf0e10cSrcweir #define _SVX_PSZCTRL_CXX 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include "svx/pszctrl.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #define PAINT_OFFSET 5 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 53*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 54*cdf0e10cSrcweir #include "svx/dlgutil.hxx" 55*cdf0e10cSrcweir #include "stbctrls.h" 56*cdf0e10cSrcweir #include "sfx2/module.hxx" 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir #include <svx/dialogs.hrc> 59*cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx> 60*cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX 61*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir // ----------------------------------------------------------------------- 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir /* [Beschreibung] 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir Funktion, mit der ein metrischer Wert in textueller Darstellung 69*cdf0e10cSrcweir umgewandelt wird. 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir nVal ist hier der metrische Wert in der Einheit eUnit. 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir [Querverweise] 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir <SvxPosSizeStatusBarControl::Paint(const UserDrawEvent&)> 76*cdf0e10cSrcweir */ 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir String SvxPosSizeStatusBarControl::GetMetricStr_Impl( long nVal ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir // Applikations-Metrik besorgen und setzen 81*cdf0e10cSrcweir FieldUnit eOutUnit = SfxModule::GetModuleFieldUnit( getFrameInterface() ); 82*cdf0e10cSrcweir FieldUnit eInUnit = FUNIT_100TH_MM; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir String sMetric; 85*cdf0e10cSrcweir const sal_Unicode cSep = Application::GetSettings().GetLocaleDataWrapper().getNumDecimalSep().GetChar(0); 86*cdf0e10cSrcweir sal_Int64 nConvVal = MetricField::ConvertValue( nVal * 100, 0L, 0, eInUnit, eOutUnit ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if ( nConvVal < 0 && ( nConvVal / 100 == 0 ) ) 89*cdf0e10cSrcweir sMetric += '-'; 90*cdf0e10cSrcweir sMetric += String::CreateFromInt64( nConvVal / 100 ); 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir if( FUNIT_NONE != eOutUnit ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir sMetric += cSep; 95*cdf0e10cSrcweir sal_Int64 nFract = nConvVal % 100; 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir if ( nFract < 0 ) 98*cdf0e10cSrcweir nFract *= -1; 99*cdf0e10cSrcweir if ( nFract < 10 ) 100*cdf0e10cSrcweir sMetric += '0'; 101*cdf0e10cSrcweir sMetric += String::CreateFromInt64( nFract ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir return sMetric; 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // ----------------------------------------------------------------------- 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir // class FunctionPopup_Impl ---------------------------------------------- 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir class FunctionPopup_Impl : public PopupMenu 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir public: 116*cdf0e10cSrcweir FunctionPopup_Impl( sal_uInt16 nCheck ); 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir sal_uInt16 GetSelected() const { return nSelected; } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir private: 121*cdf0e10cSrcweir sal_uInt16 nSelected; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir virtual void Select(); 124*cdf0e10cSrcweir }; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // ----------------------------------------------------------------------- 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt16 nCheck ) : 129*cdf0e10cSrcweir PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ), 130*cdf0e10cSrcweir nSelected( 0 ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if (nCheck) 133*cdf0e10cSrcweir CheckItem( nCheck ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // ----------------------------------------------------------------------- 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir void FunctionPopup_Impl::Select() 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir nSelected = GetCurItemId(); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // struct SvxPosSizeStatusBarControl_Impl -------------------------------- 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir struct SvxPosSizeStatusBarControl_Impl 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /* [Beschreibung] 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir Diese Implementations-Struktur der Klasse SvxPosSizeStatusBarControl 150*cdf0e10cSrcweir dient der Entkopplung von "Anderungen vom exportierten Interface sowie 151*cdf0e10cSrcweir der Verringerung von extern sichtbaren Symbolen. 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir Eine Instanz exisitiert pro SvxPosSizeStatusBarControl-Instanz 154*cdf0e10cSrcweir f"ur deren Laufzeit. 155*cdf0e10cSrcweir */ 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir Point aPos; // g"ultig, wenn eine Position angezeigt wird 159*cdf0e10cSrcweir Size aSize; // g"ultig, wenn eine Gr"o/se angezeigt wird 160*cdf0e10cSrcweir String aStr; // g"ultig, wenn ein Text angezeigt wird 161*cdf0e10cSrcweir sal_Bool bPos; // show position 162*cdf0e10cSrcweir sal_Bool bSize; // Gr"o/se anzeigen? 163*cdf0e10cSrcweir sal_Bool bTable; // Tabellenindex anzeigen? 164*cdf0e10cSrcweir sal_Bool bHasMenu; // StarCalc Popup-Menue anzeigen? 165*cdf0e10cSrcweir sal_uInt16 nFunction; // selektierte StarCalc Funktion 166*cdf0e10cSrcweir Image aPosImage; // Image f"ur die Positionsanzeige 167*cdf0e10cSrcweir Image aSizeImage; // Image f"ur die Gr"o/senanzeige 168*cdf0e10cSrcweir }; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // class SvxPosSizeStatusBarControl ------------------------------------------ 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir /* [Beschreibung] 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir Ctor(): 175*cdf0e10cSrcweir Anlegen einer Impl-Klassen-Instanz, Default die Zeitanzeige enablen, 176*cdf0e10cSrcweir Images fu"r die Position und Gro"sse laden. 177*cdf0e10cSrcweir */ 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir #define STR_POSITION ".uno:Position" 180*cdf0e10cSrcweir #define STR_TABLECELL ".uno:StateTableCell" 181*cdf0e10cSrcweir #define STR_FUNC ".uno:StatusBarFunc" 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( sal_uInt16 _nSlotId, 184*cdf0e10cSrcweir sal_uInt16 _nId, 185*cdf0e10cSrcweir StatusBar& rStb ) : 186*cdf0e10cSrcweir SfxStatusBarControl( _nSlotId, _nId, rStb ), 187*cdf0e10cSrcweir pImp( new SvxPosSizeStatusBarControl_Impl ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir pImp->bPos = sal_False; 190*cdf0e10cSrcweir pImp->bSize = sal_False; 191*cdf0e10cSrcweir pImp->bTable = sal_False; 192*cdf0e10cSrcweir pImp->bHasMenu = sal_False; 193*cdf0e10cSrcweir pImp->nFunction = 0; 194*cdf0e10cSrcweir pImp->aPosImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); 195*cdf0e10cSrcweir pImp->aSizeImage = Image( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) ); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_POSITION ))); // SID_ATTR_POSITION 198*cdf0e10cSrcweir addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_TABLECELL ))); // SID_TABLE_CELL 199*cdf0e10cSrcweir addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_FUNC ))); // SID_PSZ_FUNCTION 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // ----------------------------------------------------------------------- 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir /* [Beschreibung] 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir Dtor(): 207*cdf0e10cSrcweir Pointer auf die Impl-Klasse lo"schen, damit der Timer gestoppt wird. 208*cdf0e10cSrcweir */ 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir SvxPosSizeStatusBarControl::~SvxPosSizeStatusBarControl() 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir delete pImp; 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir // ----------------------------------------------------------------------- 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir /* [Beschreibung] 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir SID_PSZ_FUNCTION aktiviert das Popup-Menue fuer Calc, ansonsten: 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir Statusbenachrichtigung; 222*cdf0e10cSrcweir Je nach Item-Typ wird eine bestimmte Anzeige enabled, die anderen disabled. 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir NULL/Void SfxPointItem SvxSizeItem SfxStringItem 225*cdf0e10cSrcweir ------------------------------------------------------------------------ 226*cdf0e10cSrcweir Zeit sal_True sal_False sal_False FALSE 227*cdf0e10cSrcweir Position sal_False FALSE 228*cdf0e10cSrcweir Gro"sse FALSE TRUE FALSE 229*cdf0e10cSrcweir Text sal_False sal_False TRUE 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir Ein anderes Item bewirkt einen Assert, die Zeitanzeige wird enabled. 232*cdf0e10cSrcweir */ 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, 235*cdf0e10cSrcweir const SfxPoolItem* pState ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir // da Kombi-Controller, immer die aktuelle Id als HelpId setzen 238*cdf0e10cSrcweir // gecachten HelpText vorher l"oschen 239*cdf0e10cSrcweir GetStatusBar().SetHelpText( GetId(), String() ); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir switch ( nSID ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir case SID_ATTR_POSITION : GetStatusBar().SetHelpId( GetId(), STR_POSITION ); break; 244*cdf0e10cSrcweir case SID_TABLE_CELL: GetStatusBar().SetHelpId( GetId(), STR_TABLECELL ); break; 245*cdf0e10cSrcweir case SID_PSZ_FUNCTION: GetStatusBar().SetHelpId( GetId(), STR_FUNC ); break; 246*cdf0e10cSrcweir default: break; 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir if ( nSID == SID_PSZ_FUNCTION ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir if ( eState == SFX_ITEM_AVAILABLE ) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir pImp->bHasMenu = sal_True; 254*cdf0e10cSrcweir if ( pState && pState->ISA(SfxUInt16Item) ) 255*cdf0e10cSrcweir pImp->nFunction = ((const SfxUInt16Item*)pState)->GetValue(); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir else 258*cdf0e10cSrcweir pImp->bHasMenu = sal_False; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir else if ( SFX_ITEM_AVAILABLE != eState ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir // #i34458# don't switch to empty display before an empty state was 263*cdf0e10cSrcweir // notified for all display types 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if ( nSID == SID_TABLE_CELL ) 266*cdf0e10cSrcweir pImp->bTable = sal_False; 267*cdf0e10cSrcweir else if ( nSID == SID_ATTR_POSITION ) 268*cdf0e10cSrcweir pImp->bPos = sal_False; 269*cdf0e10cSrcweir else if ( nSID == GetSlotId() ) // controller is registered for SID_ATTR_SIZE 270*cdf0e10cSrcweir pImp->bSize = sal_False; 271*cdf0e10cSrcweir else 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir DBG_ERRORFILE("unknown slot id"); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir else if ( pState->ISA( SfxPointItem ) ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir // Position anzeigen 279*cdf0e10cSrcweir pImp->aPos = ( (SfxPointItem*)pState )->GetValue(); 280*cdf0e10cSrcweir pImp->bPos = sal_True; 281*cdf0e10cSrcweir pImp->bTable = sal_False; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir else if ( pState->ISA( SvxSizeItem ) ) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir // Groesse anzeigen 286*cdf0e10cSrcweir pImp->aSize = ( (SvxSizeItem*)pState )->GetSize(); 287*cdf0e10cSrcweir pImp->bSize = sal_True; 288*cdf0e10cSrcweir pImp->bTable = sal_False; 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir else if ( pState->ISA( SfxStringItem ) ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir // String anzeigen (Tabellen-Zelle oder anderes) 293*cdf0e10cSrcweir pImp->aStr = ( (SfxStringItem*)pState )->GetValue(); 294*cdf0e10cSrcweir pImp->bTable = sal_True; 295*cdf0e10cSrcweir pImp->bPos = sal_False; 296*cdf0e10cSrcweir pImp->bSize = sal_False; 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir else 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir DBG_ERRORFILE( "invalid item type" ); 301*cdf0e10cSrcweir // trotzdem Datum und Zeit anzeigen 302*cdf0e10cSrcweir pImp->bPos = sal_False; 303*cdf0e10cSrcweir pImp->bSize = sal_False; 304*cdf0e10cSrcweir pImp->bTable = sal_False; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir if ( GetStatusBar().AreItemsVisible() ) 308*cdf0e10cSrcweir GetStatusBar().SetItemData( GetId(), 0 ); 309*cdf0e10cSrcweir 310*cdf0e10cSrcweir // nur Strings auch als Text an der StatusBar setzen, damit Tip-Hilfe 311*cdf0e10cSrcweir // funktioniert, wenn der Text zu lang ist. 312*cdf0e10cSrcweir String aText; 313*cdf0e10cSrcweir if ( pImp->bTable ) 314*cdf0e10cSrcweir aText = pImp->aStr; 315*cdf0e10cSrcweir GetStatusBar().SetItemText( GetId(), aText ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir // ----------------------------------------------------------------------- 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir /* [Beschreibung] 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir Popup-Menue ausfuehren, wenn per Status enabled 323*cdf0e10cSrcweir */ 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && pImp->bHasMenu ) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir sal_uInt16 nSelect = pImp->nFunction; 330*cdf0e10cSrcweir if (!nSelect) 331*cdf0e10cSrcweir nSelect = PSZ_FUNC_NONE; 332*cdf0e10cSrcweir FunctionPopup_Impl aMenu( nSelect ); 333*cdf0e10cSrcweir if ( aMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) ) 334*cdf0e10cSrcweir { 335*cdf0e10cSrcweir nSelect = aMenu.GetSelected(); 336*cdf0e10cSrcweir if (nSelect) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir if (nSelect == PSZ_FUNC_NONE) 339*cdf0e10cSrcweir nSelect = 0; 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir ::com::sun::star::uno::Any a; 342*cdf0e10cSrcweir SfxUInt16Item aItem( SID_PSZ_FUNCTION, nSelect ); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 ); 345*cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusBarFunc" )); 346*cdf0e10cSrcweir aItem.QueryValue( a ); 347*cdf0e10cSrcweir aArgs[0].Value = a; 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir execute( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StatusBarFunc" )), aArgs ); 350*cdf0e10cSrcweir // GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L ); 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir else 355*cdf0e10cSrcweir SfxStatusBarControl::Command( rCEvt ); 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir // ----------------------------------------------------------------------- 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir /* [Beschreibung] 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir Je nach enableden Anzeigentyp, wird der Wert angezeigt. Vorher wird 363*cdf0e10cSrcweir das Rectangle u"bermalt (gelo"scht). 364*cdf0e10cSrcweir */ 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir OutputDevice* pDev = rUsrEvt.GetDevice(); 369*cdf0e10cSrcweir DBG_ASSERT( pDev, "no OutputDevice on UserDrawEvent" ); 370*cdf0e10cSrcweir const Rectangle& rRect = rUsrEvt.GetRect(); 371*cdf0e10cSrcweir StatusBar& rBar = GetStatusBar(); 372*cdf0e10cSrcweir Point aItemPos = rBar.GetItemTextPos( GetId() ); 373*cdf0e10cSrcweir Color aOldLineColor = pDev->GetLineColor(); 374*cdf0e10cSrcweir Color aOldFillColor = pDev->GetFillColor(); 375*cdf0e10cSrcweir pDev->SetLineColor(); 376*cdf0e10cSrcweir pDev->SetFillColor( pDev->GetBackground().GetColor() ); 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir if ( pImp->bPos || pImp->bSize ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir // Position fuer Size-Anzeige berechnen 381*cdf0e10cSrcweir long nSizePosX = 382*cdf0e10cSrcweir rRect.Left() + rRect.GetWidth() / 2 + PAINT_OFFSET; 383*cdf0e10cSrcweir // Position zeichnen 384*cdf0e10cSrcweir Point aPnt = rRect.TopLeft(); 385*cdf0e10cSrcweir aPnt.Y() = aItemPos.Y(); 386*cdf0e10cSrcweir aPnt.X() += PAINT_OFFSET; 387*cdf0e10cSrcweir pDev->DrawImage( aPnt, pImp->aPosImage ); 388*cdf0e10cSrcweir aPnt.X() += pImp->aPosImage.GetSizePixel().Width(); 389*cdf0e10cSrcweir aPnt.X() += PAINT_OFFSET; 390*cdf0e10cSrcweir String aStr = GetMetricStr_Impl( pImp->aPos.X()); 391*cdf0e10cSrcweir aStr.AppendAscii(" / "); 392*cdf0e10cSrcweir aStr += GetMetricStr_Impl( pImp->aPos.Y()); 393*cdf0e10cSrcweir pDev->DrawRect( 394*cdf0e10cSrcweir Rectangle( aPnt, Point( nSizePosX, rRect.Bottom() ) ) ); 395*cdf0e10cSrcweir pDev->DrawText( aPnt, aStr ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // falls verf"ugbar, Gr"osse zeichnen 398*cdf0e10cSrcweir aPnt.X() = nSizePosX; 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir if ( pImp->bSize ) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir pDev->DrawImage( aPnt, pImp->aSizeImage ); 403*cdf0e10cSrcweir aPnt.X() += pImp->aSizeImage.GetSizePixel().Width(); 404*cdf0e10cSrcweir Point aDrwPnt = aPnt; 405*cdf0e10cSrcweir aPnt.X() += PAINT_OFFSET; 406*cdf0e10cSrcweir aStr = GetMetricStr_Impl( pImp->aSize.Width() ); 407*cdf0e10cSrcweir aStr.AppendAscii(" x "); 408*cdf0e10cSrcweir aStr += GetMetricStr_Impl( pImp->aSize.Height() ); 409*cdf0e10cSrcweir pDev->DrawRect( Rectangle( aDrwPnt, rRect.BottomRight() ) ); 410*cdf0e10cSrcweir pDev->DrawText( aPnt, aStr ); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir else 413*cdf0e10cSrcweir pDev->DrawRect( Rectangle( aPnt, rRect.BottomRight() ) ); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir else if ( pImp->bTable ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir pDev->DrawRect( rRect ); 418*cdf0e10cSrcweir pDev->DrawText( Point( 419*cdf0e10cSrcweir rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( pImp->aStr ) / 2, 420*cdf0e10cSrcweir aItemPos.Y() ), pImp->aStr ); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir else 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir // Empty display if neither size nor table position are available. 425*cdf0e10cSrcweir // Date/Time are no longer used (#65302#). 426*cdf0e10cSrcweir pDev->DrawRect( rRect ); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir pDev->SetLineColor( aOldLineColor ); 430*cdf0e10cSrcweir pDev->SetFillColor( aOldFillColor ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir // ----------------------------------------------------------------------- 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir sal_uIntPtr SvxPosSizeStatusBarControl::GetDefItemWidth(const StatusBar& rStb) 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir Image aTmpPosImage( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); 438*cdf0e10cSrcweir Image aTmpSizeImage( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) ); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir sal_uIntPtr nWidth=PAINT_OFFSET+aTmpPosImage.GetSizePixel().Width(); 441*cdf0e10cSrcweir nWidth+=PAINT_OFFSET+aTmpSizeImage.GetSizePixel().Width(); 442*cdf0e10cSrcweir nWidth+=2*(PAINT_OFFSET+rStb.GetTextWidth(String::CreateFromAscii("XXXX,XX / XXXX,XX"))); 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir return nWidth; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir 448