Index: inc/unohelp2.hxx =================================================================== RCS file: /cvs/gsl/vcl/inc/unohelp2.hxx,v retrieving revision 1.2 diff -u -r1.2 unohelp2.hxx --- inc/unohelp2.hxx 7 Jan 2004 09:25:54 -0000 1.2 +++ inc/unohelp2.hxx 13 Oct 2004 07:52:04 -0000 @@ -78,6 +78,11 @@ #include #endif +namespace com { namespace sun { namespace star { namespace datatransfer { namespace clipboard { + class XClipboard; +} } } } } + + namespace vcl { namespace unohelper { class TextDataObject : public ::com::sun::star::datatransfer::XTransferable, @@ -101,6 +106,12 @@ ::com::sun::star::uno::Any SAL_CALL getTransferData( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Sequence< ::com::sun::star::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) throw(::com::sun::star::uno::RuntimeException); sal_Bool SAL_CALL isDataFlavorSupported( const ::com::sun::star::datatransfer::DataFlavor& aFlavor ) throw(::com::sun::star::uno::RuntimeException); + + /// copies a given string to a given clipboard + static void CopyStringTo( + const String& rContent, + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard + ); }; struct MutexHelper Index: source/app/dbggui.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/app/dbggui.cxx,v retrieving revision 1.17 diff -u -r1.17 dbggui.cxx --- source/app/dbggui.cxx 8 Sep 2004 15:35:38 -0000 1.17 +++ source/app/dbggui.cxx 13 Oct 2004 07:52:05 -0000 @@ -119,6 +119,9 @@ #endif #include +#ifndef _VCL_UNOHELP2_HXX +#include "unohelp2.hxx" +#endif #include using namespace ::com::sun::star; @@ -494,8 +497,12 @@ virtual BOOL Close(); virtual void Resize(); + virtual long PreNotify( NotifyEvent& rNEvt ); void InsertLine( const XubString& rLine ); void Update() { WorkWindow::Update(); maLstBox.Update(); } + +private: + void GetAssertionEntryRange( USHORT nInbetweenEntry, USHORT& nFirst, USHORT& nLast ); }; // ----------------- @@ -623,22 +630,100 @@ // ----------------------------------------------------------------------- +void DbgWindow::GetAssertionEntryRange( USHORT nInbetweenEntry, USHORT& nFirst, USHORT& nLast ) +{ + nFirst = nInbetweenEntry; + while ( nFirst > 0 ) + { + if ( maLstBox.GetEntryData( nFirst ) != NULL ) + break; + --nFirst; + } + USHORT nEntryCount = maLstBox.GetEntryCount(); + nLast = nInbetweenEntry + 1; + while ( nLast < nEntryCount ) + { + if ( maLstBox.GetEntryData( nLast ) != NULL ) + break; + ++nLast; + } +} + +// ----------------------------------------------------------------------- + +long DbgWindow::PreNotify( NotifyEvent& rNEvt ) +{ + if ( rNEvt.GetType() == EVENT_COMMAND ) + { + if ( maLstBox.IsWindowOrChild( rNEvt.GetWindow() ) ) + { + const CommandEvent& rCommand = *rNEvt.GetCommandEvent(); + if ( rCommand.GetCommand() == COMMAND_CONTEXTMENU ) + { + PopupMenu aMenu; + aMenu.InsertItem( 1, String::CreateFromAscii( "copy to clipboard" ) ); + + Point aPos; + if ( rCommand.IsMouseEvent() ) + aPos = rCommand.GetMousePosPixel(); + else + { + Rectangle aEntryRect( maLstBox.GetBoundingRectangle( maLstBox.GetSelectEntryPos() ) ); + aPos = aEntryRect.Center(); + } + USHORT nSelected = aMenu.Execute( rNEvt.GetWindow(), aPos ); + if ( nSelected == 1 ) + { + // search all entries which belong to this assertion + USHORT nAssertionFirst = 0; + USHORT nAssertionLast = 0; + GetAssertionEntryRange( maLstBox.GetSelectEntryPos(), nAssertionFirst, nAssertionLast ); + + // build the string to copy to the clipboard + String sAssertion; + String sLineFeed = String::CreateFromAscii( "\n" ); + sLineFeed.ConvertLineEnd( GetSystemLineEnd() ); + while ( nAssertionFirst < nAssertionLast ) + { + sAssertion += maLstBox.GetEntry( nAssertionFirst++ ); + sAssertion += sLineFeed; + } + + ::vcl::unohelper::TextDataObject::CopyStringTo( sAssertion, GetClipboard() ); + } + } + return 1; // handled + } + } + return WorkWindow::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + void DbgWindow::InsertLine( const XubString& rLine ) { XubString aStr = rLine; aStr.ConvertLineEnd( LINEEND_LF ); xub_StrLen nPos = aStr.Search( _LF ); + BOOL bFirstEntry = TRUE; while ( nPos != STRING_NOTFOUND ) { if ( maLstBox.GetEntryCount() >= DBGWIN_MAXLINES ) maLstBox.RemoveEntry( 0 ); - maLstBox.InsertEntry( aStr.Copy( 0, nPos ) ); + + USHORT nInsertionPos = maLstBox.InsertEntry( aStr.Copy( 0, nPos ) ); + if ( bFirstEntry ) + maLstBox.SetEntryData( nInsertionPos, reinterpret_cast< void* >( 0x00000001 ) ); + bFirstEntry = FALSE; + aStr.Erase( 0, nPos+1 ); nPos = aStr.Search( _LF ); } if ( maLstBox.GetEntryCount() >= DBGWIN_MAXLINES ) maLstBox.RemoveEntry( 0 ); - maLstBox.InsertEntry( aStr ); + USHORT nInsertionPos = maLstBox.InsertEntry( aStr ); + if ( bFirstEntry ) + maLstBox.SetEntryData( nInsertionPos, reinterpret_cast< void* >( 0x00000001 ) ); maLstBox.SetTopEntry( DBGWIN_MAXLINES-1 ); maLstBox.Update(); } Index: source/app/unohelp2.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/app/unohelp2.cxx,v retrieving revision 1.1 diff -u -r1.1 unohelp2.cxx --- source/app/unohelp2.cxx 18 Mar 2002 17:36:18 -0000 1.1 +++ source/app/unohelp2.cxx 13 Oct 2004 07:52:05 -0000 @@ -71,9 +71,21 @@ #include #endif +#ifndef _TOOLS_DEBUG_HXX +#include +#endif +#ifndef _SV_SVAPP_HXX +#include +#endif +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XCLIPBOARD_HPP_ +#include +#endif +#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XFLUSHABLECLIPBOARD_HPP_ +#include +#endif -using namespace ::com::sun::star; +using namespace ::com::sun::star; namespace vcl { namespace unohelper { @@ -85,6 +97,30 @@ { } + void TextDataObject::CopyStringTo( const String& rContent, + const uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard ) + { + DBG_ASSERT( rxClipboard.is(), "TextDataObject::CopyStringTo: invalid clipboard!" ); + if ( !rxClipboard.is() ) + return; + + TextDataObject* pDataObj = new TextDataObject( rContent ); + + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + try + { + rxClipboard->setContents( pDataObj, NULL ); + + uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY ); + if( xFlushableClipboard.is() ) + xFlushableClipboard->flushClipboard(); + } + catch( const uno::Exception& ) + { + } + Application::AcquireSolarMutex( nRef ); + } + // ::com::sun::star::uno::XInterface uno::Any TextDataObject::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException) { Index: source/control/edit.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/control/edit.cxx,v retrieving revision 1.66.70.2 diff -u -r1.66.70.2 edit.cxx --- source/control/edit.cxx 20 Sep 2004 14:51:02 -0000 1.66.70.2 +++ source/control/edit.cxx 13 Oct 2004 07:52:05 -0000 @@ -126,10 +126,6 @@ #include #endif -#ifndef _COM_SUN_STAR_DATATRANSFER_CLIPBOARD_XFLUSHABLECLIPBOARD_HPP_ -#include -#endif - #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ #include #endif @@ -1198,26 +1194,7 @@ void Edit::ImplCopy( uno::Reference< datatransfer::clipboard::XClipboard >& rxClipboard ) { - if ( rxClipboard.is() ) - { - ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( GetSelected() ); - - const sal_uInt32 nRef = Application::ReleaseSolarMutex(); - - try - { - rxClipboard->setContents( pDataObj, NULL ); - - Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY ); - if( xFlushableClipboard.is() ) - xFlushableClipboard->flushClipboard(); - } - catch( const ::com::sun::star::uno::Exception& ) - { - } - - Application::AcquireSolarMutex( nRef ); - } + ::vcl::unohelper::TextDataObject::CopyStringTo( GetSelected(), rxClipboard ); } // -----------------------------------------------------------------------