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 #ifndef _DTRANS_X11_SELECTION_HXX_ 29 #define _DTRANS_X11_SELECTION_HXX_ 30 31 #include <cppuhelper/compbase3.hxx> 32 #include <cppuhelper/compbase4.hxx> 33 #include <com/sun/star/datatransfer/XTransferable.hpp> 34 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> 35 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> 36 #include <com/sun/star/awt/XDisplayConnection.hpp> 37 #include <com/sun/star/lang/XInitialization.hpp> 38 #include <com/sun/star/lang/XServiceInfo.hpp> 39 #include <com/sun/star/script/XInvocation.hpp> 40 #include <com/sun/star/frame/XDesktop.hpp> 41 #include <osl/thread.h> 42 43 #ifndef _OSL_CONDITION_HXX_ 44 #include <osl/conditn.hxx> 45 #endif 46 47 #include <hash_map> 48 #include <list> 49 50 #include "tools/prex.h" 51 #include <X11/Xlib.h> 52 #include "tools/postx.h" 53 54 #define XDND_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndSupport" 55 #define XDND_DROPTARGET_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndDropTarget" 56 57 using namespace ::com::sun::star::uno; 58 59 namespace x11 { 60 61 class PixmapHolder; // in bmp.hxx 62 63 // ------------------------------------------------------------------------ 64 rtl_TextEncoding getTextPlainEncoding( const ::rtl::OUString& rMimeType ); 65 66 class SelectionAdaptor 67 { 68 public: 69 virtual com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable() = 0; 70 virtual void clearTransferable() = 0; 71 virtual void fireContentsChanged() = 0; 72 virtual com::sun::star::uno::Reference< XInterface > getReference() = 0; 73 // returns a reference that will keep the SelectionAdaptor alive until the 74 // refernce is released 75 }; 76 77 class DropTarget : 78 public ::cppu::WeakComponentImplHelper3< 79 ::com::sun::star::datatransfer::dnd::XDropTarget, 80 ::com::sun::star::lang::XInitialization, 81 ::com::sun::star::lang::XServiceInfo 82 > 83 { 84 public: 85 ::osl::Mutex m_aMutex; 86 bool m_bActive; 87 sal_Int8 m_nDefaultActions; 88 XLIB_Window m_aTargetWindow; 89 class SelectionManager* m_pSelectionManager; 90 com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > 91 m_xSelectionManager; 92 ::std::list< com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener > > 93 m_aListeners; 94 95 DropTarget(); 96 virtual ~DropTarget(); 97 98 // convenience functions that loop over listeners 99 void dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtde ) throw(); 100 void dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw(); 101 void dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw(); 102 void drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw(); 103 104 // XInitialization 105 virtual void SAL_CALL initialize( const Sequence< Any >& args ) throw ( ::com::sun::star::uno::Exception ); 106 107 // XDropTarget 108 virtual void SAL_CALL addDropTargetListener( const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw(); 109 virtual void SAL_CALL removeDropTargetListener( const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener >& ) throw(); 110 virtual sal_Bool SAL_CALL isActive() throw(); 111 virtual void SAL_CALL setActive( sal_Bool active ) throw(); 112 virtual sal_Int8 SAL_CALL getDefaultActions() throw(); 113 virtual void SAL_CALL setDefaultActions( sal_Int8 actions ) throw(); 114 115 // XServiceInfo 116 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(); 117 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(); 118 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 119 SAL_CALL getSupportedServiceNames() throw(); 120 }; 121 122 class SelectionManagerHolder : 123 public ::cppu::WeakComponentImplHelper3< 124 ::com::sun::star::datatransfer::dnd::XDragSource, 125 ::com::sun::star::lang::XInitialization, 126 ::com::sun::star::lang::XServiceInfo 127 > 128 { 129 ::osl::Mutex m_aMutex; 130 com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > 131 m_xRealDragSource; 132 public: 133 SelectionManagerHolder(); 134 virtual ~SelectionManagerHolder(); 135 136 // XServiceInfo 137 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(); 138 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(); 139 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > 140 SAL_CALL getSupportedServiceNames() throw(); 141 142 // XInitialization 143 virtual void SAL_CALL initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception ); 144 145 // XDragSource 146 virtual sal_Bool SAL_CALL isDragImageSupported() throw(); 147 virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) throw(); 148 virtual void SAL_CALL startDrag( 149 const ::com::sun::star::datatransfer::dnd::DragGestureEvent& trigger, 150 sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, 151 const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& transferable, 152 const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener >& listener 153 ) throw(); 154 155 }; 156 157 158 class SelectionManager : 159 public ::cppu::WeakImplHelper4< 160 ::com::sun::star::datatransfer::dnd::XDragSource, 161 ::com::sun::star::lang::XInitialization, 162 ::com::sun::star::awt::XEventHandler, 163 ::com::sun::star::frame::XTerminateListener 164 >, 165 public SelectionAdaptor 166 { 167 static ::std::hash_map< ::rtl::OUString, SelectionManager*, ::rtl::OUStringHash >& getInstances(); 168 169 // for INCR type selection transfer 170 // INCR protocol is used if the data cannot 171 // be transported at once but in parts 172 // IncrementalTransfer holds the bytes to be transmitted 173 // as well a the current position 174 // INCR triggers the delivery of the next part by deleting the 175 // property used to transfer the data 176 struct IncrementalTransfer 177 { 178 Sequence< sal_Int8 > m_aData; 179 int m_nBufferPos; 180 XLIB_Window m_aRequestor; 181 Atom m_aProperty; 182 Atom m_aTarget; 183 int m_nFormat; 184 int m_nTransferStartTime; 185 }; 186 int m_nIncrementalThreshold; 187 188 // a struct to hold the data associated with a selection 189 struct Selection 190 { 191 enum State 192 { 193 Inactive, WaitingForResponse, WaitingForData, IncrementalTransfer 194 }; 195 196 State m_eState; 197 SelectionAdaptor* m_pAdaptor; 198 Atom m_aAtom; 199 ::osl::Condition m_aDataArrived; 200 Sequence< sal_Int8 > m_aData; 201 Sequence< ::com::sun::star::datatransfer::DataFlavor > 202 m_aTypes; 203 std::vector< Atom > m_aNativeTypes; 204 // this is used for caching 205 // m_aTypes is invalid after 2 seconds 206 // m_aNativeTypes contains the corresponding original atom 207 Atom m_aRequestedType; 208 // m_aRequestedType is only valid while WaitingForResponse and WaitingFotData 209 int m_nLastTimestamp; 210 bool m_bHaveUTF16; 211 Atom m_aUTF8Type; 212 bool m_bHaveCompound; 213 bool m_bOwner; 214 XLIB_Window m_aLastOwner; 215 PixmapHolder* m_pPixmap; 216 // m_nOrigXLIB_Timestamp contains the XLIB_Timestamp at which the seclection 217 // was acquired; needed for XLIB_TimeSTAMP target 218 XLIB_Time m_nOrigTimestamp; 219 220 Selection() : m_eState( Inactive ), 221 m_pAdaptor( NULL ), 222 m_aAtom( None ), 223 m_aRequestedType( None ), 224 m_nLastTimestamp( 0 ), 225 m_bHaveUTF16( false ), 226 m_aUTF8Type( None ), 227 m_bHaveCompound( false ), 228 m_bOwner( false ), 229 m_aLastOwner( None ), 230 m_pPixmap( NULL ), 231 m_nOrigTimestamp( CurrentTime ) 232 {} 233 }; 234 235 // a struct to hold data associated with a XDropTarget 236 struct DropTargetEntry 237 { 238 DropTarget* m_pTarget; 239 XLIB_Window m_aRootWindow; 240 241 DropTargetEntry() : m_pTarget( NULL ), m_aRootWindow( None ) {} 242 DropTargetEntry( DropTarget* pTarget ) : 243 m_pTarget( pTarget ), 244 m_aRootWindow( None ) 245 {} 246 DropTargetEntry( const DropTargetEntry& rEntry ) : 247 m_pTarget( rEntry.m_pTarget ), 248 m_aRootWindow( rEntry.m_aRootWindow ) 249 {} 250 ~DropTargetEntry() {} 251 252 DropTarget* operator->() const { return m_pTarget; } 253 DropTargetEntry& operator=(const DropTargetEntry& rEntry) 254 { m_pTarget = rEntry.m_pTarget; m_aRootWindow = rEntry.m_aRootWindow; return *this; } 255 }; 256 257 // internal data 258 Display* m_pDisplay; 259 oslThread m_aThread; 260 oslThread m_aDragExecuteThread; 261 ::osl::Condition m_aDragRunning; 262 XLIB_Window m_aWindow; 263 com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayConnection > 264 m_xDisplayConnection; 265 com::sun::star::uno::Reference< com::sun::star::script::XInvocation > 266 m_xBitmapConverter; 267 sal_Int32 m_nSelectionTimeout; 268 XLIB_Time m_nSelectionTimestamp; 269 270 271 // members used for Xdnd 272 273 // drop only 274 275 // contains the XdndEnterEvent of a drop action running 276 // with one of our targets. The data.l[0] member 277 // (conatining the drag source XLIB_Window) is set 278 // to None while that is not the case 279 XClientMessageEvent m_aDropEnterEvent; 280 // set to false on XdndEnter 281 // set to true on first XdndPosition or XdndLeave 282 bool m_bDropEnterSent; 283 XLIB_Window m_aCurrentDropWindow; 284 // XLIB_Time code of XdndDrop 285 XLIB_Time m_nDropTime; 286 sal_Int8 m_nLastDropAction; 287 // XTransferable for Xdnd with foreign drag source 288 com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > 289 m_xDropTransferable; 290 int m_nLastX, m_nLastY; 291 XLIB_Time m_nDropTimestamp; 292 // set to true when calling drop() 293 // if another XdndEnter is received this shows that 294 // someone forgot to call dropComplete - we should reset 295 // and react to the new drop 296 bool m_bDropWaitingForCompletion; 297 298 // drag only 299 300 // None if no Dnd action is running with us as source 301 XLIB_Window m_aDropWindow; 302 // either m_aDropXLIB_Window or its XdndProxy 303 XLIB_Window m_aDropProxy; 304 XLIB_Window m_aDragSourceWindow; 305 // XTransferable for Xdnd when we are drag source 306 com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > 307 m_xDragSourceTransferable; 308 com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener > 309 m_xDragSourceListener; 310 // root coordinates 311 int m_nLastDragX, m_nLastDragY; 312 Sequence< ::com::sun::star::datatransfer::DataFlavor > 313 m_aDragFlavors; 314 // the rectangle the pointer must leave until a new XdndPosition should 315 // be sent. empty unless the drop target told to fill 316 int m_nNoPosX, m_nNoPosY, m_nNoPosWidth, m_nNoPosHeight; 317 unsigned int m_nDragButton; 318 sal_Int8 m_nUserDragAction; 319 sal_Int8 m_nTargetAcceptAction; 320 sal_Int8 m_nSourceActions; 321 bool m_bLastDropAccepted; 322 bool m_bDropSuccess; 323 bool m_bDropSent; 324 time_t m_nDropTimeout; 325 bool m_bWaitingForPrimaryConversion; 326 XLIB_Time m_nDragTimestamp; 327 328 // drag cursors 329 XLIB_Cursor m_aMoveCursor; 330 XLIB_Cursor m_aCopyCursor; 331 XLIB_Cursor m_aLinkCursor; 332 XLIB_Cursor m_aNoneCursor; 333 XLIB_Cursor m_aCurrentCursor; 334 335 336 // drag and drop 337 338 int m_nCurrentProtocolVersion; 339 ::std::hash_map< XLIB_Window, DropTargetEntry > 340 m_aDropTargets; 341 342 343 // some special atoms that are needed often 344 Atom m_nCLIPBOARDAtom; 345 Atom m_nTARGETSAtom; 346 Atom m_nTIMESTAMPAtom; 347 Atom m_nTEXTAtom; 348 Atom m_nINCRAtom; 349 Atom m_nCOMPOUNDAtom; 350 Atom m_nMULTIPLEAtom; 351 Atom m_nUTF16Atom; 352 Atom m_nImageBmpAtom; 353 Atom m_nXdndAware; 354 Atom m_nXdndEnter; 355 Atom m_nXdndLeave; 356 Atom m_nXdndPosition; 357 Atom m_nXdndStatus; 358 Atom m_nXdndDrop; 359 Atom m_nXdndFinished; 360 Atom m_nXdndSelection; 361 Atom m_nXdndTypeList; 362 Atom m_nXdndProxy; 363 Atom m_nXdndActionCopy; 364 Atom m_nXdndActionMove; 365 Atom m_nXdndActionLink; 366 Atom m_nXdndActionAsk; 367 Atom m_nXdndActionPrivate; 368 369 // caching for atoms 370 ::std::hash_map< Atom, ::rtl::OUString > 371 m_aAtomToString; 372 ::std::hash_map< ::rtl::OUString, Atom, ::rtl::OUStringHash > 373 m_aStringToAtom; 374 375 // the registered selections 376 ::std::hash_map< Atom, Selection* > 377 m_aSelections; 378 // IncrementalTransfers in progress 379 std::hash_map< XLIB_Window, std::hash_map< Atom, IncrementalTransfer > > 380 m_aIncrementals; 381 382 // do not use X11 multithreading capabilities 383 // since this leads to deadlocks in different Xlib implentations 384 // (XFree as well as Xsun) use an own mutex instead 385 ::osl::Mutex m_aMutex; 386 bool m_bShutDown; 387 388 SelectionManager(); 389 ~SelectionManager(); 390 391 SelectionAdaptor* getAdaptor( Atom selection ); 392 PixmapHolder* getPixmapHolder( Atom selection ); 393 394 // handle various events 395 bool handleSelectionRequest( XSelectionRequestEvent& rRequest ); 396 bool handleSendPropertyNotify( XPropertyEvent& rNotify ); 397 bool handleReceivePropertyNotify( XPropertyEvent& rNotify ); 398 bool handleSelectionNotify( XSelectionEvent& rNotify ); 399 bool handleDragEvent( XEvent& rMessage ); 400 bool handleDropEvent( XClientMessageEvent& rMessage ); 401 402 // dnd helpers 403 void sendDragStatus( Atom nDropAction ); 404 void sendDropPosition( bool bForce, XLIB_Time eventXLIB_Time ); 405 bool updateDragAction( int modifierState ); 406 int getXdndVersion( XLIB_Window aXLIB_Window, XLIB_Window& rProxy ); 407 XLIB_Cursor createCursor( const char* pPointerData, const char* pMaskData, int width, int height, int hotX, int hotY ); 408 // coordinates on root XLIB_Window 409 void updateDragWindow( int nX, int nY, XLIB_Window aRoot ); 410 411 bool getPasteData( Atom selection, Atom type, Sequence< sal_Int8 >& rData ); 412 // returns true if conversion was successful 413 bool convertData( const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable, 414 Atom nType, 415 Atom nSelection, 416 int & rFormat, 417 Sequence< sal_Int8 >& rData ); 418 bool sendData( SelectionAdaptor* pAdaptor, XLIB_Window requestor, Atom target, Atom property, Atom selection ); 419 420 // thread dispatch loop 421 public: 422 // public for extern "C" stub 423 static void run( void* ); 424 private: 425 void dispatchEvent( int millisec ); 426 // drag thread dispatch 427 public: 428 // public for extern "C" stub 429 static void runDragExecute( void* ); 430 private: 431 void dragDoDispatch(); 432 bool handleXEvent( XEvent& rEvent ); 433 434 // compound text conversion 435 ::rtl::OString convertToCompound( const ::rtl::OUString& rText ); 436 ::rtl::OUString convertFromCompound( const char* pText, int nLen = -1 ); 437 438 sal_Int8 getUserDragAction() const; 439 sal_Int32 getSelectionTimeout(); 440 public: 441 static SelectionManager& get( const ::rtl::OUString& rDisplayName = ::rtl::OUString() ); 442 443 Display * getDisplay() { return m_pDisplay; }; 444 XLIB_Window getWindow() { return m_aWindow; }; 445 446 447 void registerHandler( Atom selection, SelectionAdaptor& rAdaptor ); 448 void deregisterHandler( Atom selection ); 449 bool requestOwnership( Atom selection ); 450 451 // allow for synchronization over one mutex for XClipboard 452 osl::Mutex& getMutex() { return m_aMutex; } 453 454 455 Atom getAtom( const ::rtl::OUString& rString ); 456 const ::rtl::OUString& getString( Atom nAtom ); 457 458 // type conversion 459 // note: convertTypeToNative does NOT clear the list, so you can append 460 // multiple types to the same list 461 void convertTypeToNative( const ::rtl::OUString& rType, Atom selection, int& rFormat, ::std::list< Atom >& rConversions, bool bPushFront = false ); 462 ::rtl::OUString convertTypeFromNative( Atom nType, Atom selection, int& rFormat ); 463 void getNativeTypeList( const Sequence< com::sun::star::datatransfer::DataFlavor >& rTypes, std::list< Atom >& rOutTypeList, Atom targetselection ); 464 465 // methods for transferable 466 bool getPasteDataTypes( Atom selection, Sequence< ::com::sun::star::datatransfer::DataFlavor >& rTypes ); 467 bool getPasteData( Atom selection, const ::rtl::OUString& rType, Sequence< sal_Int8 >& rData ); 468 469 // for XDropTarget to register/deregister itself 470 void registerDropTarget( XLIB_Window aXLIB_Window, DropTarget* pTarget ); 471 void deregisterDropTarget( XLIB_Window aXLIB_Window ); 472 473 // for XDropTarget{Drag|Drop}Context 474 void accept( sal_Int8 dragOperation, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); 475 void reject( XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); 476 void dropComplete( sal_Bool success, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); 477 478 // for XDragSourceContext 479 sal_Int32 getCurrentCursor(); 480 void setCursor( sal_Int32 cursor, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); 481 void setImage( sal_Int32 image, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); 482 void transferablesFlavorsChanged(); 483 484 void shutdown() throw(); 485 486 // XInitialization 487 virtual void SAL_CALL initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception ); 488 489 // XEventHandler 490 virtual sal_Bool SAL_CALL handleEvent( const Any& event ) throw(); 491 492 // XDragSource 493 virtual sal_Bool SAL_CALL isDragImageSupported() throw(); 494 virtual sal_Int32 SAL_CALL getDefaultCursor( sal_Int8 dragAction ) throw(); 495 virtual void SAL_CALL startDrag( 496 const ::com::sun::star::datatransfer::dnd::DragGestureEvent& trigger, 497 sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, 498 const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& transferable, 499 const com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener >& listener 500 ) throw(); 501 502 // SelectionAdaptor for XdndSelection Drag (we are drag source) 503 virtual com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > getTransferable() throw(); 504 virtual void clearTransferable() throw(); 505 virtual void fireContentsChanged() throw(); 506 virtual com::sun::star::uno::Reference< XInterface > getReference() throw(); 507 508 // XEventListener 509 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException ); 510 511 // XTerminateListener 512 virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) 513 throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException ); 514 virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) 515 throw( ::com::sun::star::uno::RuntimeException ); 516 }; 517 518 // ------------------------------------------------------------------------ 519 520 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Xdnd_getSupportedServiceNames(); 521 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Xdnd_createInstance( 522 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory); 523 524 ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Xdnd_dropTarget_getSupportedServiceNames(); 525 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Xdnd_dropTarget_createInstance( 526 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xMultiServiceFactory); 527 528 // ------------------------------------------------------------------------ 529 530 } 531 532 #endif 533