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