1 #/************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 32 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 33 34 #include <svx/dialogs.hrc> 35 #include <svx/svdglue.hxx> 36 #include <svl/intitem.hxx> 37 #include <sfx2/app.hxx> 38 #include <sfx2/dispatch.hxx> 39 #include <vcl/toolbox.hxx> 40 #include <sfx2/viewfrm.hxx> 41 42 #include "strings.hrc" 43 #include "gluectrl.hxx" 44 #include "sdresid.hxx" 45 #include "app.hrc" 46 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::beans; 49 using namespace ::com::sun::star::frame; 50 51 // z.Z. werden von Joe nur die u.a. Moeglichkeiten unterstuetzt 52 #define ESCDIR_COUNT 5 53 static sal_uInt16 aEscDirArray[] = 54 { 55 SDRESC_SMART, 56 SDRESC_LEFT, 57 SDRESC_RIGHT, 58 SDRESC_TOP, 59 SDRESC_BOTTOM, 60 // SDRESC_LO, 61 // SDRESC_LU, 62 // SDRESC_RO, 63 // SDRESC_RU, 64 // SDRESC_HORZ, 65 // SDRESC_VERT, 66 // SDRESC_ALL 67 }; 68 69 70 71 SFX_IMPL_TOOLBOX_CONTROL( SdTbxCtlGlueEscDir, SfxUInt16Item ) 72 73 /************************************************************************* 74 |* 75 |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Listbox 76 |* 77 \************************************************************************/ 78 79 GlueEscDirLB::GlueEscDirLB( Window* pParent, const Reference< XFrame >& rFrame ) : 80 ListBox( pParent, WinBits( WB_BORDER | WB_DROPDOWN ) ), 81 m_xFrame( rFrame ) 82 { 83 String aStr; aStr += sal_Unicode('X'); 84 Size aXSize( GetTextWidth( aStr ), GetTextHeight() ); 85 //SetPosPixel( Point( aSize.Width(), 0 ) ); 86 SetSizePixel( Size( aXSize.Width() * 12, aXSize.Height() * 10 ) ); 87 Fill(); 88 //SelectEntryPos( 0 ); 89 Show(); 90 } 91 92 /************************************************************************* 93 |* 94 |* Dtor 95 |* 96 \************************************************************************/ 97 98 GlueEscDirLB::~GlueEscDirLB() 99 { 100 } 101 102 /************************************************************************* 103 |* 104 |* Ermittelt die Austrittsrichtung und verschickt den entspr. Slot 105 |* 106 \************************************************************************/ 107 108 void GlueEscDirLB::Select() 109 { 110 sal_uInt16 nPos = GetSelectEntryPos(); 111 SfxUInt16Item aItem( SID_GLUE_ESCDIR, aEscDirArray[ nPos ] ); 112 113 if ( m_xFrame.is() ) 114 { 115 Any a; 116 Sequence< PropertyValue > aArgs( 1 ); 117 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GlueEscapeDirection" )); 118 aItem.QueryValue( a ); 119 aArgs[0].Value = a; 120 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ), 121 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GlueEscapeDirection" )), 122 aArgs ); 123 } 124 /* 125 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GLUE_ESCDIR, SFX_CALLMODE_ASYNCHRON | 126 SFX_CALLMODE_RECORD, &aItem, (void*) NULL, 0L ); 127 */ 128 } 129 130 /************************************************************************* 131 |* 132 |* Fuellen der Listbox mit Strings 133 |* 134 \************************************************************************/ 135 136 void GlueEscDirLB::Fill() 137 { 138 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_SMART ) ) ); 139 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LEFT ) ) ); 140 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RIGHT ) ) ); 141 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_TOP ) ) ); 142 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_BOTTOM ) ) ); 143 /* 144 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LO ) ) ); 145 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_LU ) ) ); 146 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RO ) ) ); 147 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_RU ) ) ); 148 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_HORZ ) ) ); 149 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_VERT ) ) ); 150 InsertEntry( String( SdResId( STR_GLUE_ESCDIR_ALL ) ) ); 151 */ 152 } 153 154 /************************************************************************* 155 |* 156 |* Konstruktor fuer Klebepunkt-Autrittsrichtungs-Toolbox-Control 157 |* 158 \************************************************************************/ 159 160 SdTbxCtlGlueEscDir::SdTbxCtlGlueEscDir( 161 sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : 162 SfxToolBoxControl( nSlotId, nId, rTbx ) 163 { 164 } 165 166 /************************************************************************* 167 |* 168 |* Stellt Status in der Listbox des Controllers dar 169 |* 170 \************************************************************************/ 171 172 void SdTbxCtlGlueEscDir::StateChanged( sal_uInt16 nSId, 173 SfxItemState eState, const SfxPoolItem* pState ) 174 { 175 if( eState == SFX_ITEM_AVAILABLE ) 176 { 177 GlueEscDirLB* pGlueEscDirLB = (GlueEscDirLB*) ( GetToolBox(). 178 GetItemWindow( GetId() ) ); 179 if( pGlueEscDirLB ) 180 { 181 if( pState ) 182 { 183 pGlueEscDirLB->Enable(); 184 if ( IsInvalidItem( pState ) ) 185 { 186 pGlueEscDirLB->SetNoSelection(); 187 } 188 else 189 { 190 sal_uInt16 nEscDir = ( (const SfxUInt16Item*) pState )->GetValue(); 191 pGlueEscDirLB->SelectEntryPos( GetEscDirPos( nEscDir ) ); 192 } 193 } 194 else 195 { 196 pGlueEscDirLB->Disable(); 197 pGlueEscDirLB->SetNoSelection(); 198 } 199 } 200 } 201 202 SfxToolBoxControl::StateChanged( nSId, eState, pState ); 203 } 204 205 /************************************************************************* 206 |* 207 |* No Comment 208 |* 209 \************************************************************************/ 210 211 Window* SdTbxCtlGlueEscDir::CreateItemWindow( Window *pParent ) 212 { 213 if( GetSlotId() == SID_GLUE_ESCDIR ) 214 { 215 return( new GlueEscDirLB( pParent, m_xFrame ) ); 216 } 217 218 return( NULL ); 219 } 220 221 222 /************************************************************************* 223 |* 224 |* Liefert Position im Array fuer EscDir zurueck (Mapping fuer Listbox) 225 |* 226 \************************************************************************/ 227 228 sal_uInt16 SdTbxCtlGlueEscDir::GetEscDirPos( sal_uInt16 nEscDir ) 229 { 230 for( sal_uInt16 i = 0; i < ESCDIR_COUNT; i++ ) 231 { 232 if( aEscDirArray[ i ] == nEscDir ) 233 return( i ); 234 } 235 return( 99 ); 236 } 237