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_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <svx/dialogs.hrc> 35*cdf0e10cSrcweir #include <svx/svdglue.hxx> 36*cdf0e10cSrcweir #include <svl/intitem.hxx> 37*cdf0e10cSrcweir #include <sfx2/app.hxx> 38*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 39*cdf0e10cSrcweir #include <vcl/toolbox.hxx> 40*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include "strings.hrc" 43*cdf0e10cSrcweir #include "gluectrl.hxx" 44*cdf0e10cSrcweir #include "sdresid.hxx" 45*cdf0e10cSrcweir #include "app.hrc" 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 48*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 49*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt 52*cdf0e10cSrcweir #define ESCDIR_COUNT 5 53*cdf0e10cSrcweir static sal_uInt16 aEscDirArray[] = 54*cdf0e10cSrcweir { 55*cdf0e10cSrcweir SDRESC_SMART, 56*cdf0e10cSrcweir SDRESC_LEFT, 57*cdf0e10cSrcweir SDRESC_RIGHT, 58*cdf0e10cSrcweir SDRESC_TOP, 59*cdf0e10cSrcweir SDRESC_BOTTOM, 60*cdf0e10cSrcweir // SDRESC_LO, 61*cdf0e10cSrcweir // SDRESC_LU, 62*cdf0e10cSrcweir // SDRESC_RO, 63*cdf0e10cSrcweir // SDRESC_RU, 64*cdf0e10cSrcweir // SDRESC_HORZ, 65*cdf0e10cSrcweir // SDRESC_VERT, 66*cdf0e10cSrcweir // SDRESC_ALL 67*cdf0e10cSrcweir }; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item ) 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir /************************************************************************* 74*cdf0e10cSrcweir |* 75*cdf0e10cSrcweir |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox 76*cdf0e10cSrcweir |* 77*cdf0e10cSrcweir \************************************************************************/ 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) : 80*cdf0e10cSrcweir ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ), 81*cdf0e10cSrcweir m_xFrame( rFrame ) 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir String aStr; aStr += sal_Unicode('X'); 84*cdf0e10cSrcweir Size aXSize( GetTextWidth( aStr ), GetTextHeight() ); 85*cdf0e10cSrcweir //SetPosPixel( Point( aSize.Width(), 0 ) ); 86*cdf0e10cSrcweir SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) ); 87*cdf0e10cSrcweir Fill(); 88*cdf0e10cSrcweir //SelectEntryPos( 0 ); 89*cdf0e10cSrcweir Show(); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir /************************************************************************* 93*cdf0e10cSrcweir |* 94*cdf0e10cSrcweir |* Dtor 95*cdf0e10cSrcweir |* 96*cdf0e10cSrcweir \************************************************************************/ 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir GlueEscDirLB::~GlueEscDirLB() 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /************************************************************************* 103*cdf0e10cSrcweir |* 104*cdf0e10cSrcweir |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot 105*cdf0e10cSrcweir |* 106*cdf0e10cSrcweir \************************************************************************/ 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir void GlueEscDirLB::Select() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir sal_uInt16 nPos = GetSelectEntryPos(); 111*cdf0e10cSrcweir SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] ); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if ( m_xFrame.is() ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir Any a; 116*cdf0e10cSrcweir Sequence< PropertyValue > aArgs( 1 ); 117*cdf0e10cSrcweir aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GlueEscapeDirection" )); 118*cdf0e10cSrcweir aItem.QueryValue( a ); 119*cdf0e10cSrcweir aArgs[0].Value = a; 120*cdf0e10cSrcweir SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ), 121*cdf0e10cSrcweir rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GlueEscapeDirection" )), 122*cdf0e10cSrcweir aArgs ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir /* 125*cdf0e10cSrcweir SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GLUE_ESCDIR, SFX_CALLMODE_ASYNCHRON | 126*cdf0e10cSrcweir SFX_CALLMODE_RECORD, &aItem, (void*) NULL, 0L ); 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir /************************************************************************* 131*cdf0e10cSrcweir |* 132*cdf0e10cSrcweir |* Fuellen der Listbox mit Strings 133*cdf0e10cSrcweir |* 134*cdf0e10cSrcweir \************************************************************************/ 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void GlueEscDirLB::Fill() 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) ); 139*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) ); 140*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) ); 141*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) ); 142*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) ); 143*cdf0e10cSrcweir /* 144*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) ); 145*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) ); 146*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) ); 147*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) ); 148*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) ); 149*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) ); 150*cdf0e10cSrcweir InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) ); 151*cdf0e10cSrcweir */ 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir /************************************************************************* 155*cdf0e10cSrcweir |* 156*cdf0e10cSrcweir |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control 157*cdf0e10cSrcweir |* 158*cdf0e10cSrcweir \************************************************************************/ 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir( 161*cdf0e10cSrcweir sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 162*cdf0e10cSrcweir SfxToolBoxControl( nSlotId, nId, rTbx ) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir /************************************************************************* 167*cdf0e10cSrcweir |* 168*cdf0e10cSrcweir |* Stellt Status in der Listbox des Controllers dar 169*cdf0e10cSrcweir |* 170*cdf0e10cSrcweir \************************************************************************/ 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId, 173*cdf0e10cSrcweir SfxItemState eState, const SfxPoolItem* pState ) 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if( eState == SFX_ITEM_AVAILABLE ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox(). 178*cdf0e10cSrcweir GetItemWindow( GetId() ) ); 179*cdf0e10cSrcweir if( pGlueEscDirLB ) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if( pState ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir pGlueEscDirLB->Enable(); 184*cdf0e10cSrcweir if ( IsInvalidItem( pState ) ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir pGlueEscDirLB->SetNoSelection(); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir else 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue(); 191*cdf0e10cSrcweir pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir else 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir pGlueEscDirLB->Disable(); 197*cdf0e10cSrcweir pGlueEscDirLB->SetNoSelection(); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir SfxToolBoxControl::StateChanged( nSId, eState, pState ); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir /************************************************************************* 206*cdf0e10cSrcweir |* 207*cdf0e10cSrcweir |* No Comment 208*cdf0e10cSrcweir |* 209*cdf0e10cSrcweir \************************************************************************/ 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir if( GetSlotId() == SID_GLUE_ESCDIR ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir return( new GlueEscDirLB( pParent, m_xFrame ) ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir return( NULL ); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir /************************************************************************* 223*cdf0e10cSrcweir |* 224*cdf0e10cSrcweir |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox) 225*cdf0e10cSrcweir |* 226*cdf0e10cSrcweir \************************************************************************/ 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir ) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir if( aEscDirArray[ i ] == nEscDir ) 233*cdf0e10cSrcweir return( i ); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir return( 99 ); 236*cdf0e10cSrcweir } 237