diff options
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk/a11y/atkutil.cxx | 11 | ||||
-rw-r--r-- | vcl/unx/gtk/a11y/atkwindow.cxx | 41 | ||||
-rw-r--r-- | vcl/unx/gtk/a11y/atkwrapper.cxx | 54 | ||||
-rw-r--r-- | vcl/unx/gtk/app/gtkinst.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/gtk/window/gtkframe.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/headless/svpprn.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/source/app/randrwrapper.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/X11_dndcontext.cxx | 12 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/X11_dndcontext.hxx | 20 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/X11_selection.cxx | 192 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/X11_selection.hxx | 100 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/bmp.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/source/dtrans/bmp.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salgdi.cxx | 18 | ||||
-rw-r--r-- | vcl/unx/source/gdi/salprnpsp.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/source/printer/cupsmgr.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/source/printer/ppdparser.cxx | 440 | ||||
-rw-r--r-- | vcl/unx/source/printer/printerinfomanager.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/source/printergfx/printerjob.cxx | 3 |
19 files changed, 704 insertions, 210 deletions
diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx index c92a69d3fb49..f5db066151d3 100644 --- a/vcl/unx/gtk/a11y/atkutil.cxx +++ b/vcl/unx/gtk/a11y/atkutil.cxx @@ -666,7 +666,16 @@ long WindowEventHandler(void *, ::VclSimpleEvent const * pEvent) static_cast< ::VclWindowEvent const * >(pEvent)->GetWindow()); */ case VCLEVENT_MENU_HIGHLIGHT: - handle_menu_highlighted(static_cast< ::VclMenuEvent const * >(pEvent)); + if (const VclMenuEvent* pMenuEvent = dynamic_cast<const VclMenuEvent*>(pEvent)) + { + handle_menu_highlighted(pMenuEvent); + } + else if (const VclAccessibleEvent* pAccEvent = dynamic_cast<const VclAccessibleEvent*>(pEvent)) + { + uno::Reference< accessibility::XAccessible > xAccessible = pAccEvent->GetAccessible(); + if (xAccessible.is()) + atk_wrapper_focus_tracker_notify_when_idle(xAccessible); + } break; case VCLEVENT_TOOLBOX_HIGHLIGHT: diff --git a/vcl/unx/gtk/a11y/atkwindow.cxx b/vcl/unx/gtk/a11y/atkwindow.cxx index 5961556e85d7..1bda4eea774e 100644 --- a/vcl/unx/gtk/a11y/atkwindow.cxx +++ b/vcl/unx/gtk/a11y/atkwindow.cxx @@ -33,6 +33,7 @@ #include <plugins/gtk/gtkframe.hxx> #include <vcl/window.hxx> +#include "vcl/popupmenuwindow.hxx" #include "atkwindow.hxx" #include "atkwrapper.hxx" @@ -108,6 +109,17 @@ init_from_window( AtkObject *accessible, Window *pWindow ) pChild->SetAccessibleRole( AccessibleRole::LABEL ); accessible->name = g_strdup( rtl::OUStringToOString( pChild->GetText(), RTL_TEXTENCODING_UTF8 ).getStr() ); } + else if ( pWindow->GetType() == WINDOW_BORDERWINDOW && pChild->GetType() == WINDOW_FLOATINGWINDOW ) + { + PopupMenuFloatingWindow* p = dynamic_cast<PopupMenuFloatingWindow*>(pChild); + if (p && p->IsPopupMenu() && p->GetMenuStackLevel() == 0) + { + // This is a top-level menu popup. Register it. + role = ATK_ROLE_POPUP_MENU; + pChild->SetAccessibleRole( AccessibleRole::POPUP_MENU ); + accessible->name = g_strdup( rtl::OUStringToOString( pChild->GetText(), RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } } break; } @@ -136,6 +148,23 @@ ooo_window_wrapper_real_focus_gtk (GtkWidget *, GdkEventFocus *) /*****************************************************************************/ +static bool +isChildPopupMenu(Window* pWindow) +{ + Window* pChild = pWindow->GetAccessibleChildWindow(0); + if (!pChild) + return false; + + if (WINDOW_FLOATINGWINDOW != pChild->GetType()) + return false; + + PopupMenuFloatingWindow* p = dynamic_cast<PopupMenuFloatingWindow*>(pChild); + if (!p) + return false; + + return p->IsPopupMenu(); +} + static void ooo_window_wrapper_real_initialize(AtkObject *obj, gpointer data) { @@ -157,8 +186,16 @@ ooo_window_wrapper_real_initialize(AtkObject *obj, gpointer data) */ if( WINDOW_BORDERWINDOW == pWindow->GetType() ) { - ooo_wrapper_registry_add( xAccessible, obj ); - g_object_set_data( G_OBJECT(obj), "ooo:atk-wrapper-key", xAccessible.get() ); + if ( isChildPopupMenu(pWindow) ) + { + AtkObject *child = atk_object_wrapper_new( xAccessible, obj ); + ooo_wrapper_registry_add( xAccessible, child ); + } + else + { + ooo_wrapper_registry_add( xAccessible, obj ); + g_object_set_data( G_OBJECT(obj), "ooo:atk-wrapper-key", xAccessible.get() ); + } } else { diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index 8854083e1509..302c096e5915 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -515,6 +515,60 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) /*****************************************************************************/ +#if 0 +struct { + sal_Int16 value; + const sal_Char* name; +} aStateTypeTable[] = { + { accessibility::AccessibleStateType::INVALID, "INVALID" }, + { accessibility::AccessibleStateType::ACTIVE, "ACTIVE" }, + { accessibility::AccessibleStateType::ARMED, "ARMED" }, + { accessibility::AccessibleStateType::BUSY, "BUSY" }, + { accessibility::AccessibleStateType::CHECKED, "CHECKED" }, + { accessibility::AccessibleStateType::DEFUNC, "DEFUNC" }, + { accessibility::AccessibleStateType::EDITABLE, "EDITABLE" }, + { accessibility::AccessibleStateType::ENABLED, "ENABLED" }, + { accessibility::AccessibleStateType::EXPANDABLE, "EXPANDABLE" }, + { accessibility::AccessibleStateType::EXPANDED, "EXPANDED" }, + { accessibility::AccessibleStateType::FOCUSABLE, "FOCUSABLE" }, + { accessibility::AccessibleStateType::FOCUSED, "FOCUSED" }, + { accessibility::AccessibleStateType::HORIZONTAL, "HORIZONTAL" }, + { accessibility::AccessibleStateType::ICONIFIED, "ICONIFIED" }, + { accessibility::AccessibleStateType::INDETERMINATE, "INDETERMINATE" }, + { accessibility::AccessibleStateType::MANAGES_DESCENDANTS, "MANAGES_DESCENDANTS" }, + { accessibility::AccessibleStateType::MODAL, "MODAL" }, + { accessibility::AccessibleStateType::MULTI_LINE, "MULTI_LINE" }, + { accessibility::AccessibleStateType::MULTI_SELECTABLE, "MULTI_SELECTABLE" }, + { accessibility::AccessibleStateType::OPAQUE, "OPAQUE" }, + { accessibility::AccessibleStateType::PRESSED, "PRESSED" }, + { accessibility::AccessibleStateType::RESIZABLE, "RESIZABLE" }, + { accessibility::AccessibleStateType::SELECTABLE, "SELECTABLE" }, + { accessibility::AccessibleStateType::SELECTED, "SELECTED" }, + { accessibility::AccessibleStateType::SENSITIVE, "SENSITIVE" }, + { accessibility::AccessibleStateType::SHOWING, "SHOWING" }, + { accessibility::AccessibleStateType::SINGLE_LINE, "SINGLE_LINE" }, + { accessibility::AccessibleStateType::STALE, "STALE" }, + { accessibility::AccessibleStateType::TRANSIENT, "TRANSIENT" }, + { accessibility::AccessibleStateType::VERTICAL, "VERTICAL" }, + { accessibility::AccessibleStateType::VISIBLE, "VISIBLE" } +}; + +static void printStates(const uno::Sequence<sal_Int16>& rStates) +{ + sal_Int32 n = rStates.getLength(); + size_t nTypes = sizeof(aStateTypeTable)/sizeof(aStateTypeTable[0]); + for (sal_Int32 i = 0; i < n; ++i) + { + for (size_t j = 0; j < nTypes; ++j) + { + if (aStateTypeTable[j].value == rStates[i]) + printf("%s ", aStateTypeTable[j].name); + } + } + printf("\n"); +} +#endif + static AtkStateSet * wrapper_ref_state_set( AtkObject *atk_obj ) { diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index af3a1df97a8c..92a8ff641a38 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -144,11 +144,6 @@ extern "C" if( ! ( pNoXInitThreads && *pNoXInitThreads ) ) XInitThreads(); - #if OSL_DEBUG_LEVEL > 1 - int nFd = open( "/home/pl93762/log.txt", O_CREAT | O_TRUNC | O_WRONLY, 0755 ); - dup2( nFd, STDERR_FILENO ); - #endif - const gchar* pVersion = gtk_check_version( 2, 2, 0 ); if( pVersion ) { diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx index 92ff2d3b8d8e..69f42637d203 100644 --- a/vcl/unx/gtk/window/gtkframe.cxx +++ b/vcl/unx/gtk/window/gtkframe.cxx @@ -1315,7 +1315,7 @@ void GtkSalFrame::Show( BOOL bVisible, BOOL bNoActivate ) setMinMaxSize(); // #i45160# switch to desktop where a dialog with parent will appear - if( m_pParent && m_pParent->m_nWorkArea != m_nWorkArea ) + if( m_pParent && m_pParent->m_nWorkArea != m_nWorkArea && GTK_WIDGET_MAPPED(m_pParent->m_pWindow) ) getDisplay()->getWMAdaptor()->switchToWorkArea( m_pParent->m_nWorkArea ); if( isFloatGrabWindow() && diff --git a/vcl/unx/headless/svpprn.cxx b/vcl/unx/headless/svpprn.cxx index 75d86959b2b5..2c0ba3dad84c 100644 --- a/vcl/unx/headless/svpprn.cxx +++ b/vcl/unx/headless/svpprn.cxx @@ -736,7 +736,7 @@ String PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, ULONG { const PPDValue* pValue = pKey->getValue( nPaperBin ); if( pValue ) - aRet = pValue->m_aOptionTranslation.Len() ? pValue->m_aOptionTranslation : pValue->m_aOption; + aRet = aData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption ); } } diff --git a/vcl/unx/source/app/randrwrapper.cxx b/vcl/unx/source/app/randrwrapper.cxx index 4fbe5db97ab9..85f60a07903a 100644 --- a/vcl/unx/source/app/randrwrapper.cxx +++ b/vcl/unx/source/app/randrwrapper.cxx @@ -288,6 +288,9 @@ void RandRWrapper::releaseWrapper() #include "saldisp.hxx" #include "salframe.h" +#if OSL_DEBUG_LEVEL > 1 +#include <cstdio> +#endif void SalDisplay::InitRandR( XLIB_Window aRoot ) const { diff --git a/vcl/unx/source/dtrans/X11_dndcontext.cxx b/vcl/unx/source/dtrans/X11_dndcontext.cxx index 59832c27c2a7..71aebde5b7af 100644 --- a/vcl/unx/source/dtrans/X11_dndcontext.cxx +++ b/vcl/unx/source/dtrans/X11_dndcontext.cxx @@ -42,8 +42,8 @@ using namespace x11; */ DropTargetDropContext::DropTargetDropContext( - Window aDropWindow, - Time aTimestamp, + XLIB_Window aDropWindow, + XLIB_Time aTimestamp, SelectionManager& rManager ) : m_aDropWindow( aDropWindow ), m_nTimestamp( aTimestamp ), @@ -77,8 +77,8 @@ void DropTargetDropContext::dropComplete( sal_Bool success ) throw() */ DropTargetDragContext::DropTargetDragContext( - Window aDropWindow, - Time aTimestamp, + XLIB_Window aDropWindow, + XLIB_Time aTimestamp, SelectionManager& rManager ) : m_aDropWindow( aDropWindow ), m_nTimestamp( aTimestamp ), @@ -106,8 +106,8 @@ void DropTargetDragContext::rejectDrag() throw() */ DragSourceContext::DragSourceContext( - Window aDropWindow, - Time aTimestamp, + XLIB_Window aDropWindow, + XLIB_Time aTimestamp, SelectionManager& rManager ) : m_aDropWindow( aDropWindow ), m_nTimestamp( aTimestamp ), diff --git a/vcl/unx/source/dtrans/X11_dndcontext.hxx b/vcl/unx/source/dtrans/X11_dndcontext.hxx index f2ecb7b0841b..3626b86d8617 100644 --- a/vcl/unx/source/dtrans/X11_dndcontext.hxx +++ b/vcl/unx/source/dtrans/X11_dndcontext.hxx @@ -36,7 +36,9 @@ #include <com/sun/star/datatransfer/dnd/XDropTargetDragContext.hpp> #include <cppuhelper/implbase1.hxx> +#include "tools/prex.h" #include <X11/Xlib.h> +#include "tools/postx.h" using namespace com::sun::star::uno; @@ -49,12 +51,12 @@ namespace x11 { ::com::sun::star::datatransfer::dnd::XDropTargetDropContext > { - Window m_aDropWindow; - Time m_nTimestamp; + XLIB_Window m_aDropWindow; + XLIB_Time m_nTimestamp; SelectionManager& m_rManager; Reference< XInterface > m_xManagerRef; public: - DropTargetDropContext( Window, Time, SelectionManager& ); + DropTargetDropContext( XLIB_Window, XLIB_Time, SelectionManager& ); virtual ~DropTargetDropContext(); // XDropTargetDropContext @@ -68,12 +70,12 @@ namespace x11 { ::com::sun::star::datatransfer::dnd::XDropTargetDragContext > { - Window m_aDropWindow; - Time m_nTimestamp; + XLIB_Window m_aDropWindow; + XLIB_Time m_nTimestamp; SelectionManager& m_rManager; Reference< XInterface > m_xManagerRef; public: - DropTargetDragContext( Window, Time, SelectionManager& ); + DropTargetDragContext( XLIB_Window, XLIB_Time, SelectionManager& ); virtual ~DropTargetDragContext(); // XDropTargetDragContext @@ -86,12 +88,12 @@ namespace x11 { ::com::sun::star::datatransfer::dnd::XDragSourceContext > { - Window m_aDropWindow; - Time m_nTimestamp; + XLIB_Window m_aDropWindow; + XLIB_Time m_nTimestamp; SelectionManager& m_rManager; Reference< XInterface > m_xManagerRef; public: - DragSourceContext( Window, Time, SelectionManager& ); + DragSourceContext( XLIB_Window, XLIB_Time, SelectionManager& ); virtual ~DragSourceContext(); // XDragSourceContext diff --git a/vcl/unx/source/dtrans/X11_selection.cxx b/vcl/unx/source/dtrans/X11_selection.cxx index c6036ae4f78e..e549d92d9c5f 100644 --- a/vcl/unx/source/dtrans/X11_selection.cxx +++ b/vcl/unx/source/dtrans/X11_selection.cxx @@ -35,11 +35,13 @@ #include <stdio.h> #include <string.h> #include <sys/time.h> +#include "tools/prex.h" #include <X11/Xatom.h> #include <X11/keysym.h> #include <X11/Xlib.h> #include <X11/X.h> #include <X11/Xutil.h> +#include "tools/postx.h" #if defined(LINUX) || defined(NETBSD) || defined (FREEBSD) #include <sys/poll.h> #else @@ -53,6 +55,8 @@ #include <X11_dndcontext.hxx> #include <bmp.hxx> +#include "vcl/svapp.hxx" + // pointer bitmaps #include <copydata_curs.h> #include <copydata_mask.h> @@ -66,9 +70,9 @@ #include <com/sun/star/awt/MouseEvent.hpp> #include <com/sun/star/awt/MouseButton.hpp> #include <rtl/tencinfo.h> -#ifndef OSL_PROCESS_H #include <osl/process.h> -#endif + +#include <comphelper/processfactory.hxx> #define DRAG_EVENT_MASK ButtonPressMask |\ ButtonReleaseMask |\ @@ -81,6 +85,7 @@ using namespace com::sun::star::datatransfer::dnd; using namespace com::sun::star::lang; using namespace com::sun::star::awt; using namespace com::sun::star::uno; +using namespace com::sun::star::frame; using namespace cppu; using namespace osl; using namespace rtl; @@ -280,7 +285,7 @@ SelectionManager::SelectionManager() : m_aDragRunning.reset(); } -Cursor SelectionManager::createCursor( const char* pPointerData, const char* pMaskData, int width, int height, int hotX, int hotY ) +XLIB_Cursor SelectionManager::createCursor( const char* pPointerData, const char* pMaskData, int width, int height, int hotX, int hotY ) { Pixmap aPointer; Pixmap aMask; @@ -306,7 +311,7 @@ Cursor SelectionManager::createCursor( const char* pPointerData, const char* pMa pMaskData, width, height ); - Cursor aCursor = + XLIB_Cursor aCursor = XCreatePixmapCursor( m_pDisplay, aPointer, aMask, &aBlack, &aWhite, hotX, @@ -928,7 +933,7 @@ bool SelectionManager::getPasteData( Atom selection, Atom type, Sequence< sal_In if( it == m_aSelections.end() ) return false; - Window aSelectionOwner = XGetSelectionOwner( m_pDisplay, selection ); + XLIB_Window aSelectionOwner = XGetSelectionOwner( m_pDisplay, selection ); if( aSelectionOwner == None ) return false; if( aSelectionOwner == m_aWindow ) @@ -1480,7 +1485,7 @@ static sal_Size GetTrueFormatSize(int nFormat) } bool SelectionManager::sendData( SelectionAdaptor* pAdaptor, - Window requestor, + XLIB_Window requestor, Atom target, Atom property, Atom selection ) @@ -1587,7 +1592,7 @@ bool SelectionManager::sendData( SelectionAdaptor* pAdaptor, { #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "using INCR protocol\n" ); - std::hash_map< Window, std::hash_map< Atom, IncrementalTransfer > >::const_iterator win_it = m_aIncrementals.find( requestor ); + std::hash_map< XLIB_Window, std::hash_map< Atom, IncrementalTransfer > >::const_iterator win_it = m_aIncrementals.find( requestor ); if( win_it != m_aIncrementals.end() ) { std::hash_map< Atom, IncrementalTransfer >::const_iterator inc_it = win_it->second.find( property ); @@ -1986,7 +1991,7 @@ bool SelectionManager::handleSendPropertyNotify( XPropertyEvent& rNotify ) // feed incrementals if( rNotify.state == PropertyDelete ) { - std::hash_map< Window, std::hash_map< Atom, IncrementalTransfer > >::iterator it; + std::hash_map< XLIB_Window, std::hash_map< Atom, IncrementalTransfer > >::iterator it; it = m_aIncrementals.find( rNotify.window ); if( it != m_aIncrementals.end() ) { @@ -2168,12 +2173,12 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) ResettableMutexGuard aGuard(m_aMutex); // handle drop related events - Window aSource = rMessage.data.l[0]; - Window aTarget = rMessage.window; + XLIB_Window aSource = rMessage.data.l[0]; + XLIB_Window aTarget = rMessage.window; bool bHandled = false; - ::std::hash_map< Window, DropTargetEntry >::iterator it = + ::std::hash_map< XLIB_Window, DropTargetEntry >::iterator it = m_aDropTargets.find( aTarget ); #if OSL_DEBUG_LEVEL > 1 @@ -2187,7 +2192,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) fprintf( stderr, "but no target found\n" ); else if( ! it->second.m_pTarget->m_bActive ) fprintf( stderr, "but target is inactive\n" ); - else if( m_aDropEnterEvent.data.l[0] != None && (Window)m_aDropEnterEvent.data.l[0] != aSource ) + else if( m_aDropEnterEvent.data.l[0] != None && (XLIB_Window)m_aDropEnterEvent.data.l[0] != aSource ) fprintf( stderr, "but source 0x%lx is unknown (expected 0x%lx or 0)\n", aSource, m_aDropEnterEvent.data.l[0] ); else fprintf( stderr, "processing.\n" ); @@ -2208,7 +2213,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) if( it != m_aDropTargets.end() && it->second.m_pTarget->m_bActive && - ( m_aDropEnterEvent.data.l[0] == None || Window(m_aDropEnterEvent.data.l[0]) == aSource ) + ( m_aDropEnterEvent.data.l[0] == None || XLIB_Window(m_aDropEnterEvent.data.l[0]) == aSource ) ) { if( rMessage.message_type == m_nXdndEnter ) @@ -2224,7 +2229,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) } else if( rMessage.message_type == m_nXdndPosition && - aSource == Window(m_aDropEnterEvent.data.l[0]) + aSource == XLIB_Window(m_aDropEnterEvent.data.l[0]) ) { bHandled = true; @@ -2232,7 +2237,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) if( ! m_bDropEnterSent ) m_nDropTimestamp = m_nDropTime; - Window aChild; + XLIB_Window aChild; XTranslateCoordinates( m_pDisplay, it->second.m_aRootWindow, it->first, @@ -2280,7 +2285,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) } else if( rMessage.message_type == m_nXdndLeave && - aSource == Window(m_aDropEnterEvent.data.l[0]) + aSource == XLIB_Window(m_aDropEnterEvent.data.l[0]) ) { bHandled = true; @@ -2298,7 +2303,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) } else if( rMessage.message_type == m_nXdndDrop && - aSource == Window(m_aDropEnterEvent.data.l[0]) + aSource == XLIB_Window(m_aDropEnterEvent.data.l[0]) ) { bHandled = true; @@ -2345,7 +2350,7 @@ bool SelectionManager::handleDropEvent( XClientMessageEvent& rMessage ) * methods for XDropTargetDropContext */ -void SelectionManager::dropComplete( sal_Bool bSuccess, Window aDropWindow, Time ) +void SelectionManager::dropComplete( sal_Bool bSuccess, XLIB_Window aDropWindow, XLIB_Time ) { ClearableMutexGuard aGuard(m_aMutex); @@ -2542,21 +2547,21 @@ bool SelectionManager::updateDragAction( int modifierState ) // ------------------------------------------------------------------------ -void SelectionManager::sendDropPosition( bool bForce, Time eventTime ) +void SelectionManager::sendDropPosition( bool bForce, XLIB_Time eventTime ) { ClearableMutexGuard aGuard(m_aMutex); if( m_bDropSent ) return; - ::std::hash_map< Window, DropTargetEntry >::const_iterator it = + ::std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it = m_aDropTargets.find( m_aDropWindow ); if( it != m_aDropTargets.end() ) { if( it->second.m_pTarget->m_bActive ) { int x, y; - Window aChild; + XLIB_Window aChild; XTranslateCoordinates( m_pDisplay, it->second.m_aRootWindow, m_aDropWindow, m_nLastDragX, m_nLastDragY, &x, &y, &aChild ); DropTargetDragEvent dtde; dtde.Source = static_cast< OWeakObject* >(it->second.m_pTarget ); @@ -2612,7 +2617,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) bool bHandled = false; // for shortcut - ::std::hash_map< Window, DropTargetEntry >::const_iterator it = + ::std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it = m_aDropTargets.find( m_aDropWindow ); #if OSL_DEBUG_LEVEL > 1 switch( rMessage.type ) @@ -2635,7 +2640,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) case ButtonRelease: fprintf( stderr, "handleDragEvent: ButtonRelease %d (m_nDragButton = %d)\n", rMessage.xbutton.button, m_nDragButton ); break; - case KeyPress: + case XLIB_KeyPress: fprintf( stderr, "handleDragEvent: KeyPress\n" ); break; case KeyRelease: @@ -2719,7 +2724,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) bool bForce = false; int root_x = rMessage.type == MotionNotify ? rMessage.xmotion.x_root : rMessage.xcrossing.x_root; int root_y = rMessage.type == MotionNotify ? rMessage.xmotion.y_root : rMessage.xcrossing.y_root; - Window root = rMessage.type == MotionNotify ? rMessage.xmotion.root : rMessage.xcrossing.root; + XLIB_Window root = rMessage.type == MotionNotify ? rMessage.xmotion.root : rMessage.xcrossing.root; m_nDragTimestamp = rMessage.type == MotionNotify ? rMessage.xmotion.time : rMessage.xcrossing.time; aGuard.clear(); @@ -2736,7 +2741,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) sendDropPosition( bForce, rMessage.type == MotionNotify ? rMessage.xmotion.time : rMessage.xcrossing.time ); } } - else if( rMessage.type == KeyPress || rMessage.type == KeyRelease ) + else if( rMessage.type == XLIB_KeyPress || rMessage.type == KeyRelease ) { bHandled = true; KeySym aKey = XKeycodeToKeysym( m_pDisplay, rMessage.xkey.keycode, 0 ); @@ -2793,7 +2798,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) case XK_Control_L: nNewState = ControlMask;break; // just interested in shift and ctrl for dnd } - if( rMessage.type == KeyPress ) + if( rMessage.type == XLIB_KeyPress ) nState |= nNewState; else nState &= ~nNewState; @@ -2815,7 +2820,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) { bHandled = true; int x, y; - Window aChild; + XLIB_Window aChild; XTranslateCoordinates( m_pDisplay, rMessage.xbutton.root, m_aDropWindow, rMessage.xbutton.x_root, rMessage.xbutton.y_root, &x, &y, &aChild ); DropTargetDropEvent dtde; dtde.Source = static_cast< OWeakObject* >(it->second.m_pTarget ); @@ -2865,7 +2870,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) { bHandled = true; - Window aDummy; + XLIB_Window aDummy; XEvent aEvent; aEvent.type = ButtonPress; aEvent.xbutton.display = m_pDisplay; @@ -2924,7 +2929,7 @@ bool SelectionManager::handleDragEvent( XEvent& rMessage ) // ------------------------------------------------------------------------ -void SelectionManager::accept( sal_Int8 dragOperation, Window aDropWindow, Time ) +void SelectionManager::accept( sal_Int8 dragOperation, XLIB_Window aDropWindow, XLIB_Time ) { if( aDropWindow == m_aCurrentDropWindow ) { @@ -2946,7 +2951,7 @@ void SelectionManager::accept( sal_Int8 dragOperation, Window aDropWindow, Time // ------------------------------------------------------------------------ -void SelectionManager::reject( Window aDropWindow, Time ) +void SelectionManager::reject( XLIB_Window aDropWindow, XLIB_Time ) { if( aDropWindow == m_aCurrentDropWindow ) { @@ -2982,7 +2987,7 @@ sal_Bool SelectionManager::isDragImageSupported() throw() sal_Int32 SelectionManager::getDefaultCursor( sal_Int8 dragAction ) throw() { - Cursor aCursor = m_aNoneCursor; + XLIB_Cursor aCursor = m_aNoneCursor; if( dragAction & DNDConstants::ACTION_MOVE ) aCursor = m_aMoveCursor; else if( dragAction & DNDConstants::ACTION_COPY ) @@ -2994,7 +2999,7 @@ sal_Int32 SelectionManager::getDefaultCursor( sal_Int8 dragAction ) throw() // ------------------------------------------------------------------------ -int SelectionManager::getXdndVersion( Window aWindow, Window& rProxy ) +int SelectionManager::getXdndVersion( XLIB_Window aWindow, XLIB_Window& rProxy ) { Atom* pProperties = NULL; int nProperties = 0; @@ -3022,7 +3027,7 @@ int SelectionManager::getXdndVersion( Window aWindow, Window& rProxy ) if( pBytes ) { if( nType == XA_WINDOW ) - rProxy = *(Window*)pBytes; + rProxy = *(XLIB_Window*)pBytes; XFree( pBytes ); pBytes = NULL; if( rProxy != None ) @@ -3032,7 +3037,7 @@ int SelectionManager::getXdndVersion( Window aWindow, Window& rProxy ) &nType, &nFormat, &nItems, &nBytes, &pBytes ); if( pBytes ) { - if( nType == XA_WINDOW && *(Window*)pBytes != rProxy ) + if( nType == XA_WINDOW && *(XLIB_Window*)pBytes != rProxy ) rProxy = None; XFree( pBytes ); pBytes = NULL; @@ -3044,7 +3049,7 @@ int SelectionManager::getXdndVersion( Window aWindow, Window& rProxy ) break; } } - Window aAwareWindow = rProxy != None ? rProxy : aWindow; + XLIB_Window aAwareWindow = rProxy != None ? rProxy : aWindow; XGetWindowProperty( m_pDisplay, aAwareWindow, m_nXdndAware, 0, 1, False, XA_ATOM, &nType, &nFormat, &nItems, &nBytes, &pBytes ); @@ -3062,7 +3067,7 @@ int SelectionManager::getXdndVersion( Window aWindow, Window& rProxy ) // ------------------------------------------------------------------------ -void SelectionManager::updateDragWindow( int nX, int nY, Window aRoot ) +void SelectionManager::updateDragWindow( int nX, int nY, XLIB_Window aRoot ) { ResettableMutexGuard aGuard( m_aMutex ); @@ -3071,9 +3076,9 @@ void SelectionManager::updateDragWindow( int nX, int nY, Window aRoot ) m_nLastDragX = nX; m_nLastDragY = nY; - Window aParent = aRoot; - Window aChild; - Window aNewProxy = None, aNewCurrentWindow = None; + XLIB_Window aParent = aRoot; + XLIB_Window aChild; + XLIB_Window aNewProxy = None, aNewCurrentWindow = None; int nNewProtocolVersion = -1; int nWinX, nWinY; @@ -3114,7 +3119,7 @@ void SelectionManager::updateDragWindow( int nX, int nY, Window aRoot ) dsde.DropAction = nNewProtocolVersion >= 0 ? m_nUserDragAction : DNDConstants::ACTION_COPY; dsde.UserAction = nNewProtocolVersion >= 0 ? m_nUserDragAction : DNDConstants::ACTION_COPY; - ::std::hash_map< Window, DropTargetEntry >::const_iterator it; + ::std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it; if( aNewCurrentWindow != m_aDropWindow ) { #if OSL_DEBUG_LEVEL > 1 @@ -3263,11 +3268,11 @@ void SelectionManager::startDrag( // the pointer is located in. since said window should be one // of our DropTargets at the time of executeDrag we can use // them for a start - Window aRoot, aParent, aChild; + XLIB_Window aRoot, aParent, aChild; int root_x, root_y, win_x, win_y; unsigned int mask; - ::std::hash_map< Window, DropTargetEntry >::const_iterator it; + ::std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it; it = m_aDropTargets.begin(); while( it != m_aDropTargets.end() ) { @@ -3379,10 +3384,9 @@ void SelectionManager::startDrag( m_bDropSuccess = false; m_bWaitingForPrimaryConversion = false; m_nDragButton = Button1; // default to left button - if( trigger.Event.getValueTypeName().equalsAsciiL( "com.sun.star.awt.MouseEvent", 27 ) ) + com::sun::star::awt::MouseEvent aEvent; + if( trigger.Event >>= aEvent ) { - MouseEvent aEvent; - trigger.Event >>= aEvent; if( aEvent.Buttons & MouseButton::LEFT ) m_nDragButton = Button1; else if( aEvent.Buttons & MouseButton::RIGHT ) @@ -3519,10 +3523,10 @@ sal_Int32 SelectionManager::getCurrentCursor() // ------------------------------------------------------------------------ -void SelectionManager::setCursor( sal_Int32 cursor, Window aDropWindow, Time ) +void SelectionManager::setCursor( sal_Int32 cursor, XLIB_Window aDropWindow, XLIB_Time ) { MutexGuard aGuard( m_aMutex ); - if( aDropWindow == m_aDropWindow && Cursor(cursor) != m_aCurrentCursor ) + if( aDropWindow == m_aDropWindow && XLIB_Cursor(cursor) != m_aCurrentCursor ) { if( m_xDragSourceListener.is() && ! m_bDropSent ) { @@ -3535,7 +3539,7 @@ void SelectionManager::setCursor( sal_Int32 cursor, Window aDropWindow, Time ) // ------------------------------------------------------------------------ -void SelectionManager::setImage( sal_Int32, Window, Time ) +void SelectionManager::setImage( sal_Int32, XLIB_Window, XLIB_Time ) { } @@ -3668,7 +3672,7 @@ bool SelectionManager::handleXEvent( XEvent& rEvent ) case MotionNotify: case ButtonPress: case ButtonRelease: - case KeyPress: + case XLIB_KeyPress: case KeyRelease: bHandled = handleDragEvent( rEvent ); break; @@ -3734,6 +3738,14 @@ void SelectionManager::run( void* pThis ) timeval aLast; gettimeofday( &aLast, 0 ); + Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() ); + if( xFact.is() ) + { + Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY ); + if( xDesktop.is() ) + xDesktop->addTerminateListener(This); + } + while( osl_scheduleThread(This->m_aThread) ) { This->dispatchEvent( 1000 ); @@ -3750,7 +3762,7 @@ void SelectionManager::run( void* pThis ) { if( it->first != This->m_nXdndSelection && ! it->second->m_bOwner ) { - Window aOwner = XGetSelectionOwner( This->m_pDisplay, it->first ); + XLIB_Window aOwner = XGetSelectionOwner( This->m_pDisplay, it->first ); if( aOwner != it->second->m_aLastOwner ) { it->second->m_aLastOwner = aOwner; @@ -3774,6 +3786,40 @@ void SelectionManager::run( void* pThis ) #endif } +void SelectionManager::shutdown() throw() +{ + ResettableMutexGuard aGuard(m_aMutex); + // stop dispatching + if( m_aThread ) + { + osl_terminateThread( m_aThread ); + /* + * Allow thread to finish before app exits to avoid pulling the carpet + * out from under it if pasting is occuring during shutdown + * + * a) allow it to have the Mutex and + * b) reschedule to allow it to complete callbacks to any + * Application::GetSolarMutex protected regions, etc. e.g. + * TransferableHelper::getTransferDataFlavors (via + * SelectionManager::handleSelectionRequest) which it might + * currently be trying to enter. + * + * Otherwise the thread may be left still waiting on a GlobalMutex + * when that gets destroyed, letting the thread blow up and die + * when enters the section in a now dead OOo instance. + */ + aGuard.clear(); + while (osl_isThreadRunning(m_aThread)) + Application::Reschedule(); + osl_joinWithThread( m_aThread ); + osl_destroyThread( m_aThread ); + m_aThread = NULL; + aGuard.reset(); + } + m_xDisplayConnection->removeEventHandler( Any(), this ); + m_xDisplayConnection.clear(); +} + // ------------------------------------------------------------------------ sal_Bool SelectionManager::handleEvent( const Any& event ) throw() @@ -3782,10 +3828,10 @@ sal_Bool SelectionManager::handleEvent( const Any& event ) throw() if( (event >>= aSeq) ) { XEvent* pEvent = (XEvent*)aSeq.getArray(); - Time nTimestamp = CurrentTime; + XLIB_Time nTimestamp = CurrentTime; if( pEvent->type == ButtonPress || pEvent->type == ButtonRelease ) nTimestamp = pEvent->xbutton.time; - else if( pEvent->type == KeyPress || pEvent->type == KeyRelease ) + else if( pEvent->type == XLIB_KeyPress || pEvent->type == KeyRelease ) nTimestamp = pEvent->xkey.time; else if( pEvent->type == MotionNotify ) nTimestamp = pEvent->xmotion.time; @@ -3806,16 +3852,38 @@ sal_Bool SelectionManager::handleEvent( const Any& event ) throw() #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "SelectionManager got downing event\n" ); #endif - MutexGuard aGuard(m_aMutex); - // stop dispatching - if( m_aThread ) - osl_terminateThread( m_aThread ); - m_xDisplayConnection->removeEventHandler( Any(), this ); - m_xDisplayConnection.clear(); + shutdown(); } return sal_True; } +void SAL_CALL SelectionManager::disposing( const ::com::sun::star::lang::EventObject& ) + throw( ::com::sun::star::uno::RuntimeException ) +{ +} + +void SAL_CALL SelectionManager::queryTermination( const ::com::sun::star::lang::EventObject& ) + throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException ) +{ +} + +/* + * To be safe, shutdown needs to be called before the ~SfxApplication is called, waiting until + * the downing event can be too late if paste are requested during shutdown and ~SfxApplication + * has been called before vcl is shutdown + */ +void SAL_CALL SelectionManager::notifyTermination( const ::com::sun::star::lang::EventObject& rEvent ) + throw( ::com::sun::star::uno::RuntimeException ) +{ + Reference< XDesktop > xDesktop( rEvent.Source, UNO_QUERY ); + if( xDesktop.is() == sal_True ) + xDesktop->removeTerminateListener( this ); + #if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "SelectionManager got app termination event\n" ); + #endif + shutdown(); +} + // ------------------------------------------------------------------------ void SelectionManager::registerHandler( Atom selection, SelectionAdaptor& rAdaptor ) @@ -3846,12 +3914,12 @@ void SelectionManager::deregisterHandler( Atom selection ) // ------------------------------------------------------------------------ -void SelectionManager::registerDropTarget( Window aWindow, DropTarget* pTarget ) +void SelectionManager::registerDropTarget( XLIB_Window aWindow, DropTarget* pTarget ) { MutexGuard aGuard(m_aMutex); // sanity check - ::std::hash_map< Window, DropTargetEntry >::const_iterator it = + ::std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it = m_aDropTargets.find( aWindow ); if( it != m_aDropTargets.end() ) OSL_ASSERT( "attempt to register window as drop target twice" ); @@ -3877,7 +3945,7 @@ void SelectionManager::registerDropTarget( Window aWindow, DropTarget* pTarget ) // ------------------------------------------------------------------------ -void SelectionManager::deregisterDropTarget( Window aWindow ) +void SelectionManager::deregisterDropTarget( XLIB_Window aWindow ) { ClearableMutexGuard aGuard(m_aMutex); @@ -3885,7 +3953,7 @@ void SelectionManager::deregisterDropTarget( Window aWindow ) if( aWindow == m_aDragSourceWindow && m_aDragRunning.check() ) { // abort drag - std::hash_map< Window, DropTargetEntry >::const_iterator it = + std::hash_map< XLIB_Window, DropTargetEntry >::const_iterator it = m_aDropTargets.find( m_aDropWindow ); if( it != m_aDropTargets.end() ) { diff --git a/vcl/unx/source/dtrans/X11_selection.hxx b/vcl/unx/source/dtrans/X11_selection.hxx index dc6c41247bbd..fa6c310ef8c1 100644 --- a/vcl/unx/source/dtrans/X11_selection.hxx +++ b/vcl/unx/source/dtrans/X11_selection.hxx @@ -32,6 +32,7 @@ #define _DTRANS_X11_SELECTION_HXX_ #include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase4.hxx> #include <com/sun/star/datatransfer/XTransferable.hpp> #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> @@ -39,6 +40,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/frame/XDesktop.hpp> #include <osl/thread.h> #ifndef _OSL_CONDITION_HXX_ @@ -48,7 +50,9 @@ #include <hash_map> #include <list> +#include "tools/prex.h" #include <X11/Xlib.h> +#include "tools/postx.h" #define XDND_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndSupport" #define XDND_DROPTARGET_IMPLEMENTATION_NAME "com.sun.star.datatransfer.dnd.XdndDropTarget" @@ -84,7 +88,7 @@ namespace x11 { ::osl::Mutex m_aMutex; bool m_bActive; sal_Int8 m_nDefaultActions; - Window m_aTargetWindow; + XLIB_Window m_aTargetWindow; class SelectionManager* m_pSelectionManager; Reference< ::com::sun::star::datatransfer::dnd::XDragSource > m_xSelectionManager; @@ -155,10 +159,11 @@ namespace x11 { class SelectionManager : - public ::cppu::WeakImplHelper3< + public ::cppu::WeakImplHelper4< ::com::sun::star::datatransfer::dnd::XDragSource, ::com::sun::star::lang::XInitialization, - ::com::sun::star::awt::XEventHandler + ::com::sun::star::awt::XEventHandler, + ::com::sun::star::frame::XTerminateListener >, public SelectionAdaptor { @@ -175,7 +180,7 @@ namespace x11 { { Sequence< sal_Int8 > m_aData; int m_nBufferPos; - Window m_aRequestor; + XLIB_Window m_aRequestor; Atom m_aProperty; Atom m_aTarget; int m_nFormat; @@ -209,11 +214,11 @@ namespace x11 { Atom m_aUTF8Type; bool m_bHaveCompound; bool m_bOwner; - Window m_aLastOwner; + XLIB_Window m_aLastOwner; PixmapHolder* m_pPixmap; - // m_nOrigTimestamp contains the timestamp at which the seclection - // was acquired; needed for TIMESTAMP target - Time m_nOrigTimestamp; + // m_nOrigXLIB_Timestamp contains the XLIB_Timestamp at which the seclection + // was acquired; needed for XLIB_TimeSTAMP target + XLIB_Time m_nOrigTimestamp; Selection() : m_eState( Inactive ), m_pAdaptor( NULL ), @@ -234,7 +239,7 @@ namespace x11 { struct DropTargetEntry { DropTarget* m_pTarget; - Window m_aRootWindow; + XLIB_Window m_aRootWindow; DropTargetEntry() : m_pTarget( NULL ), m_aRootWindow( None ) {} DropTargetEntry( DropTarget* pTarget ) : @@ -257,13 +262,13 @@ namespace x11 { oslThread m_aThread; oslThread m_aDragExecuteThread; ::osl::Condition m_aDragRunning; - Window m_aWindow; + XLIB_Window m_aWindow; Reference< ::com::sun::star::awt::XDisplayConnection > m_xDisplayConnection; Reference< com::sun::star::script::XInvocation > m_xBitmapConverter; sal_Int32 m_nSelectionTimeout; - Time m_nSelectionTimestamp; + XLIB_Time m_nSelectionTimestamp; // members used for Xdnd @@ -272,21 +277,21 @@ namespace x11 { // contains the XdndEnterEvent of a drop action running // with one of our targets. The data.l[0] member - // (conatining the drag source window) is set + // (conatining the drag source XLIB_Window) is set // to None while that is not the case XClientMessageEvent m_aDropEnterEvent; // set to false on XdndEnter // set to true on first XdndPosition or XdndLeave bool m_bDropEnterSent; - Window m_aCurrentDropWindow; - // time code of XdndDrop - Time m_nDropTime; + XLIB_Window m_aCurrentDropWindow; + // XLIB_Time code of XdndDrop + XLIB_Time m_nDropTime; sal_Int8 m_nLastDropAction; // XTransferable for Xdnd with foreign drag source Reference< ::com::sun::star::datatransfer::XTransferable > m_xDropTransferable; int m_nLastX, m_nLastY; - Time m_nDropTimestamp; + XLIB_Time m_nDropTimestamp; // set to true when calling drop() // if another XdndEnter is received this shows that // someone forgot to call dropComplete - we should reset @@ -296,10 +301,10 @@ namespace x11 { // drag only // None if no Dnd action is running with us as source - Window m_aDropWindow; - // either m_aDropWindow or its XdndProxy - Window m_aDropProxy; - Window m_aDragSourceWindow; + XLIB_Window m_aDropWindow; + // either m_aDropXLIB_Window or its XdndProxy + XLIB_Window m_aDropProxy; + XLIB_Window m_aDragSourceWindow; // XTransferable for Xdnd when we are drag source Reference< ::com::sun::star::datatransfer::XTransferable > m_xDragSourceTransferable; @@ -321,20 +326,20 @@ namespace x11 { bool m_bDropSent; time_t m_nDropTimeout; bool m_bWaitingForPrimaryConversion; - Time m_nDragTimestamp; + XLIB_Time m_nDragTimestamp; // drag cursors - Cursor m_aMoveCursor; - Cursor m_aCopyCursor; - Cursor m_aLinkCursor; - Cursor m_aNoneCursor; - Cursor m_aCurrentCursor; + XLIB_Cursor m_aMoveCursor; + XLIB_Cursor m_aCopyCursor; + XLIB_Cursor m_aLinkCursor; + XLIB_Cursor m_aNoneCursor; + XLIB_Cursor m_aCurrentCursor; // drag and drop int m_nCurrentProtocolVersion; - ::std::hash_map< Window, DropTargetEntry > + ::std::hash_map< XLIB_Window, DropTargetEntry > m_aDropTargets; @@ -374,7 +379,7 @@ namespace x11 { ::std::hash_map< Atom, Selection* > m_aSelections; // IncrementalTransfers in progress - std::hash_map< Window, std::hash_map< Atom, IncrementalTransfer > > + std::hash_map< XLIB_Window, std::hash_map< Atom, IncrementalTransfer > > m_aIncrementals; // do not use X11 multithreading capabilities @@ -398,12 +403,12 @@ namespace x11 { // dnd helpers void sendDragStatus( Atom nDropAction ); - void sendDropPosition( bool bForce, Time eventTime ); + void sendDropPosition( bool bForce, XLIB_Time eventXLIB_Time ); bool updateDragAction( int modifierState ); - int getXdndVersion( Window aWindow, Window& rProxy ); - Cursor createCursor( const char* pPointerData, const char* pMaskData, int width, int height, int hotX, int hotY ); - // coordinates on root window - void updateDragWindow( int nX, int nY, Window aRoot ); + int getXdndVersion( XLIB_Window aXLIB_Window, XLIB_Window& rProxy ); + XLIB_Cursor createCursor( const char* pPointerData, const char* pMaskData, int width, int height, int hotX, int hotY ); + // coordinates on root XLIB_Window + void updateDragWindow( int nX, int nY, XLIB_Window aRoot ); bool getPasteData( Atom selection, Atom type, Sequence< sal_Int8 >& rData ); // returns true if conversion was successful @@ -412,7 +417,7 @@ namespace x11 { Atom nSelection, int & rFormat, Sequence< sal_Int8 >& rData ); - bool sendData( SelectionAdaptor* pAdaptor, Window requestor, Atom target, Atom property, Atom selection ); + bool sendData( SelectionAdaptor* pAdaptor, XLIB_Window requestor, Atom target, Atom property, Atom selection ); // thread dispatch loop public: @@ -438,7 +443,7 @@ namespace x11 { static SelectionManager& get( const ::rtl::OUString& rDisplayName = ::rtl::OUString() ); Display * getDisplay() { return m_pDisplay; }; - Window getWindow() { return m_aWindow; }; + XLIB_Window getWindow() { return m_aWindow; }; void registerHandler( Atom selection, SelectionAdaptor& rAdaptor ); @@ -464,20 +469,22 @@ namespace x11 { bool getPasteData( Atom selection, const ::rtl::OUString& rType, Sequence< sal_Int8 >& rData ); // for XDropTarget to register/deregister itself - void registerDropTarget( Window aWindow, DropTarget* pTarget ); - void deregisterDropTarget( Window aWindow ); + void registerDropTarget( XLIB_Window aXLIB_Window, DropTarget* pTarget ); + void deregisterDropTarget( XLIB_Window aXLIB_Window ); // for XDropTarget{Drag|Drop}Context - void accept( sal_Int8 dragOperation, Window aDropWindow, Time aTimestamp ); - void reject( Window aDropWindow, Time aTimestamp ); - void dropComplete( sal_Bool success, Window aDropWindow, Time aTimestamp ); + void accept( sal_Int8 dragOperation, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); + void reject( XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); + void dropComplete( sal_Bool success, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); // for XDragSourceContext sal_Int32 getCurrentCursor(); - void setCursor( sal_Int32 cursor, Window aDropWindow, Time aTimestamp ); - void setImage( sal_Int32 image, Window aDropWindow, Time aTimestamp ); + void setCursor( sal_Int32 cursor, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); + void setImage( sal_Int32 image, XLIB_Window aDropXLIB_Window, XLIB_Time aXLIB_Timestamp ); void transferablesFlavorsChanged(); + void shutdown() throw(); + // XInitialization virtual void SAL_CALL initialize( const Sequence< Any >& arguments ) throw( ::com::sun::star::uno::Exception ); @@ -499,6 +506,15 @@ namespace x11 { virtual void clearTransferable() throw(); virtual void fireContentsChanged() throw(); virtual Reference< XInterface > getReference() throw(); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException ); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) + throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) + throw( ::com::sun::star::uno::RuntimeException ); }; // ------------------------------------------------------------------------ diff --git a/vcl/unx/source/dtrans/bmp.cxx b/vcl/unx/source/dtrans/bmp.cxx index 49219bfb0e2a..f3c7d78617a6 100644 --- a/vcl/unx/source/dtrans/bmp.cxx +++ b/vcl/unx/source/dtrans/bmp.cxx @@ -356,7 +356,7 @@ sal_uInt8* x11::X11_getBmpFromPixmap( ) { // get geometry of drawable - Window aRoot; + XLIB_Window aRoot; int x,y; unsigned int w, h, bw, d; XGetGeometry( pDisplay, aDrawable, &aRoot, &x, &y, &w, &h, &bw, &d ); diff --git a/vcl/unx/source/dtrans/bmp.hxx b/vcl/unx/source/dtrans/bmp.hxx index baf04ac31d90..6331122e726d 100644 --- a/vcl/unx/source/dtrans/bmp.hxx +++ b/vcl/unx/source/dtrans/bmp.hxx @@ -31,10 +31,12 @@ #ifndef _DTRANS_BMP_HXX_ #define _DTRANS_BMP_HXX_ +#include "tools/prex.h" #include <X11/Xatom.h> #include <X11/keysym.h> #include <X11/Xlib.h> #include <X11/Xutil.h> +#include "tools/postx.h" #include <sal/types.h> #include <com/sun/star/awt/XBitmap.hpp> diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx index 5fe2295a8fed..386be14f04d7 100644 --- a/vcl/unx/source/gdi/salgdi.cxx +++ b/vcl/unx/source/gdi/salgdi.cxx @@ -1428,14 +1428,17 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly // unless it splits another trapezoid that is still active bool bSplit = false; ActiveTrapSet::iterator aActiveTrapsIt = aActiveTraps.begin(); - for(; aActiveTrapsIt != aActiveTraps.end(); ++aActiveTrapsIt ) + while(aActiveTrapsIt != aActiveTraps.end()) { XTrapezoid& rLeftTrap = aTrapVector[ *aActiveTrapsIt ]; // skip until first overlap candidate // TODO: use stl::*er_bound() instead if( IsLeftOf( aTrapezoid.left, rLeftTrap.left) ) + { + ++aActiveTrapsIt; continue; + } // in the ActiveTrapSet there are still trapezoids where // a vertical overlap with new trapezoids is no longer possible @@ -1446,15 +1449,26 @@ bool X11SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rOrigPoly { ActiveTrapSet::iterator it = aActiveTrapsIt; if( aActiveTrapsIt != aActiveTraps.begin() ) + { --aActiveTrapsIt; - aActiveTraps.erase( it ); + aActiveTraps.erase( it ); + ++aActiveTrapsIt; + } + else + { + aActiveTraps.erase( it ); + aActiveTrapsIt = aActiveTraps.begin(); + } continue; } // check if there is horizontal overlap // aTrapezoid.left==rLeftTrap.right is allowed though if( !IsLeftOf( aTrapezoid.left, rLeftTrap.right ) ) + { + ++aActiveTrapsIt; continue; + } // prepare to split the old trapezoid and keep its upper part // find the old trapezoids entry in the VerticalTrapSet and remove it diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx index d47e30a89633..4dc9a0b6a455 100644 --- a/vcl/unx/source/gdi/salprnpsp.cxx +++ b/vcl/unx/source/gdi/salprnpsp.cxx @@ -839,7 +839,7 @@ String PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, ULONG { const PPDValue* pValue = pKey->getValue( nPaperBin ); if( pValue ) - aRet = pValue->m_aOptionTranslation.Len() ? pValue->m_aOptionTranslation : pValue->m_aOption; + aRet = aData.m_pParser->translateOption( pKey->getKey(), pValue->m_aOption ); } } diff --git a/vcl/unx/source/printer/cupsmgr.cxx b/vcl/unx/source/printer/cupsmgr.cxx index d0c7f184fb06..4c38479f1107 100644 --- a/vcl/unx/source/printer/cupsmgr.cxx +++ b/vcl/unx/source/printer/cupsmgr.cxx @@ -533,6 +533,10 @@ void CUPSManager::initialize() pDest->options ); if( pOpt ) m_bUseIncludeFeature = true; + // do not send include JobPatch; CUPS will insert that itself + // TODO: currently unknwon which versions of CUPS insert JobPatches + // so currently it is assumed CUPS = don't insert JobPatch files + m_bUseJobPatch = false; rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); int nPrinter = m_nDests; diff --git a/vcl/unx/source/printer/ppdparser.cxx b/vcl/unx/source/printer/ppdparser.cxx index 95bc7bca41ca..a70a5ac7f6c8 100644 --- a/vcl/unx/source/printer/ppdparser.cxx +++ b/vcl/unx/source/printer/ppdparser.cxx @@ -39,6 +39,7 @@ #include "vcl/ppdparser.hxx" #include "vcl/strhelper.hxx" #include "vcl/helper.hxx" +#include "vcl/svapp.hxx" #include "cupsmgr.hxx" #include "tools/debug.hxx" #include "tools/urlobj.hxx" @@ -51,6 +52,202 @@ #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" +#include "com/sun/star/lang/Locale.hpp" + +namespace psp +{ + class PPDTranslator + { + struct LocaleEqual + { + bool operator()(const com::sun::star::lang::Locale& i_rLeft, + const com::sun::star::lang::Locale& i_rRight) const + { + return i_rLeft.Language.equals( i_rRight.Language ) && + i_rLeft.Country.equals( i_rRight.Country ) && + i_rLeft.Variant.equals( i_rRight.Variant ); + } + }; + + struct LocaleHash + { + size_t operator()(const com::sun::star::lang::Locale& rLocale) const + { return + (size_t)rLocale.Language.hashCode() + ^ (size_t)rLocale.Country.hashCode() + ^ (size_t)rLocale.Variant.hashCode() + ; + } + }; + + typedef std::hash_map< com::sun::star::lang::Locale, rtl::OUString, LocaleHash, LocaleEqual > translation_map; + typedef std::hash_map< rtl::OUString, translation_map, rtl::OUStringHash > key_translation_map; + + key_translation_map m_aTranslations; + public: + PPDTranslator() {} + ~PPDTranslator() {} + + + void insertValue( + const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const rtl::OUString& i_rTranslation, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() + ); + + void insertOption( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rTranslation, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) + { + insertValue( i_rKey, i_rOption, rtl::OUString(), i_rTranslation, i_rLocale ); + } + + void insertKey( const rtl::OUString& i_rKey, + const rtl::OUString& i_rTranslation, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) + { + insertValue( i_rKey, rtl::OUString(), rtl::OUString(), i_rTranslation, i_rLocale ); + } + + rtl::OUString translateValue( + const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() + ) const; + + rtl::OUString translateOption( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const + { + return translateValue( i_rKey, i_rOption, rtl::OUString(), i_rLocale ); + } + + rtl::OUString translateKey( const rtl::OUString& i_rKey, + const com::sun::star::lang::Locale& i_rLocale = com::sun::star::lang::Locale() ) const + { + return translateValue( i_rKey, rtl::OUString(), rtl::OUString(), i_rLocale ); + } + }; + + static com::sun::star::lang::Locale normalizeInputLocale( + const com::sun::star::lang::Locale& i_rLocale, + bool bInsertDefault = false + ) + { + com::sun::star::lang::Locale aLoc( i_rLocale ); + if( bInsertDefault && aLoc.Language.getLength() == 0 ) + { + // empty locale requested, fill in application UI locale + aLoc = Application::GetSettings().GetUILocale(); + + #if OSL_DEBUG_LEVEL > 1 + static const char* pEnvLocale = getenv( "SAL_PPDPARSER_LOCALE" ); + if( pEnvLocale && *pEnvLocale ) + { + rtl::OString aStr( pEnvLocale ); + sal_Int32 nLen = aStr.getLength(); + aLoc.Language = rtl::OStringToOUString( aStr.copy( 0, nLen > 2 ? 2 : nLen ), RTL_TEXTENCODING_MS_1252 ); + if( nLen >=5 && aStr.getStr()[2] == '_' ) + aLoc.Country = rtl::OStringToOUString( aStr.copy( 3, 2 ), RTL_TEXTENCODING_MS_1252 ); + else + aLoc.Country = rtl::OUString(); + aLoc.Variant = rtl::OUString(); + } + #endif + } + aLoc.Language = aLoc.Language.toAsciiLowerCase(); + aLoc.Country = aLoc.Country.toAsciiUpperCase(); + aLoc.Variant = aLoc.Variant.toAsciiUpperCase(); + + return aLoc; + } + + void PPDTranslator::insertValue( + const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const rtl::OUString& i_rTranslation, + const com::sun::star::lang::Locale& i_rLocale + ) + { + rtl::OUStringBuffer aKey( i_rKey.getLength() + i_rOption.getLength() + i_rValue.getLength() + 2 ); + aKey.append( i_rKey ); + if( i_rOption.getLength() || i_rValue.getLength() ) + { + aKey.append( sal_Unicode( ':' ) ); + aKey.append( i_rOption ); + } + if( i_rValue.getLength() ) + { + aKey.append( sal_Unicode( ':' ) ); + aKey.append( i_rValue ); + } + if( aKey.getLength() && i_rTranslation.getLength() ) + { + rtl::OUString aK( aKey.makeStringAndClear() ); + com::sun::star::lang::Locale aLoc; + aLoc.Language = i_rLocale.Language.toAsciiLowerCase(); + aLoc.Country = i_rLocale.Country.toAsciiUpperCase(); + aLoc.Variant = i_rLocale.Variant.toAsciiUpperCase(); + m_aTranslations[ aK ][ aLoc ] = i_rTranslation; + } + } + + rtl::OUString PPDTranslator::translateValue( + const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const com::sun::star::lang::Locale& i_rLocale + ) const + { + rtl::OUString aResult; + + rtl::OUStringBuffer aKey( i_rKey.getLength() + i_rOption.getLength() + i_rValue.getLength() + 2 ); + aKey.append( i_rKey ); + if( i_rOption.getLength() || i_rValue.getLength() ) + { + aKey.append( sal_Unicode( ':' ) ); + aKey.append( i_rOption ); + } + if( i_rValue.getLength() ) + { + aKey.append( sal_Unicode( ':' ) ); + aKey.append( i_rValue ); + } + if( aKey.getLength() ) + { + rtl::OUString aK( aKey.makeStringAndClear() ); + key_translation_map::const_iterator it = m_aTranslations.find( aK ); + if( it != m_aTranslations.end() ) + { + const translation_map& rMap( it->second ); + + com::sun::star::lang::Locale aLoc( normalizeInputLocale( i_rLocale, true ) ); + for( int nTry = 0; nTry < 4; nTry++ ) + { + translation_map::const_iterator tr = rMap.find( aLoc ); + if( tr != rMap.end() ) + { + aResult = tr->second; + break; + } + switch( nTry ) + { + case 0: aLoc.Variant = rtl::OUString();break; + case 1: aLoc.Country = rtl::OUString();break; + case 2: aLoc.Language = rtl::OUString();break; + } + } + } + } + return aResult; + } +} + using namespace psp; using namespace rtl; @@ -481,7 +678,8 @@ PPDParser::PPDParser( const String& rFile ) : m_pResolutions( NULL ), m_pDefaultDuplexType( NULL ), m_pDuplexTypes( NULL ), - m_pFontList( NULL ) + m_pFontList( NULL ), + m_pTranslator( new PPDTranslator() ) { // read in the file std::list< ByteString > aLines; @@ -648,6 +846,7 @@ PPDParser::~PPDParser() { for( PPDParser::hash_type::iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it ) delete it->second; + delete m_pTranslator; } void PPDParser::insertKey( const String& rKey, PPDKey* pKey ) @@ -687,11 +886,11 @@ static sal_uInt8 getNibble( sal_Char cChar ) return nRet; } -String PPDParser::handleTranslation( const ByteString& rString ) +String PPDParser::handleTranslation( const ByteString& i_rString, bool bIsGlobalized ) { - int nOrigLen = rString.Len(); + int nOrigLen = i_rString.Len(); OStringBuffer aTrans( nOrigLen ); - const sal_Char* pStr = rString.GetBuffer(); + const sal_Char* pStr = i_rString.GetBuffer(); const sal_Char* pEnd = pStr + nOrigLen; while( pStr < pEnd ) { @@ -710,14 +909,11 @@ String PPDParser::handleTranslation( const ByteString& rString ) else aTrans.append( *pStr++ ); } - return OStringToOUString( aTrans.makeStringAndClear(), m_aFileEncoding ); + return OStringToOUString( aTrans.makeStringAndClear(), bIsGlobalized ? RTL_TEXTENCODING_UTF8 : m_aFileEncoding ); } void PPDParser::parse( ::std::list< ByteString >& rLines ) { - PPDValue* pValue = NULL; - PPDKey* pKey = NULL; - std::list< ByteString >::iterator line = rLines.begin(); PPDParser::hash_type::const_iterator keyit; while( line != rLines.end() ) @@ -765,14 +961,25 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) } String aUniKey( aKey, RTL_TEXTENCODING_MS_1252 ); - keyit = m_aKeys.find( aUniKey ); - if( keyit == m_aKeys.end() ) + // handle CUPS extension for globalized PPDs + bool bIsGlobalizedLine = false; + com::sun::star::lang::Locale aTransLocale; + if( ( aUniKey.Len() > 3 && aUniKey.GetChar( 2 ) == '.' ) || + ( aUniKey.Len() > 5 && aUniKey.GetChar( 2 ) == '_' && aUniKey.GetChar( 5 ) == '.' ) ) { - pKey = new PPDKey( aUniKey ); - insertKey( aUniKey, pKey ); + if( aUniKey.GetChar( 2 ) == '.' ) + { + aTransLocale.Language = aUniKey.Copy( 0, 2 ); + aUniKey = aUniKey.Copy( 3 ); + } + else + { + aTransLocale.Language = aUniKey.Copy( 0, 2 ); + aTransLocale.Country = aUniKey.Copy( 3, 2 ); + aUniKey = aUniKey.Copy( 6 ); + } + bIsGlobalizedLine = true; } - else - pKey = keyit->second; String aOption; nPos = aCurrentLine.Search( ':' ); @@ -784,76 +991,125 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) if( nTransPos != STRING_NOTFOUND ) aOption.Erase( nTransPos ); } - pValue = pKey->insertValue( aOption ); - if( ! pValue ) - continue; - if( nPos == STRING_NOTFOUND ) + PPDValueType eType = eNo; + String aValue; + rtl::OUString aOptionTranslation; + rtl::OUString aValueTranslation; + if( nPos != STRING_NOTFOUND ) { - // have a single main keyword - pValue->m_eType = eNo; - if( bQuery ) - pKey->eraseValue( aOption ); - continue; - } + // found a colon, there may be an option + ByteString aLine = aCurrentLine.Copy( 1, nPos-1 ); + aLine = WhitespaceToSpace( aLine ); + int nTransPos = aLine.Search( '/' ); + if( nTransPos != STRING_NOTFOUND ) + aOptionTranslation = handleTranslation( aLine.Copy( nTransPos+1 ), bIsGlobalizedLine ); - // found a colon, there may be an option - ByteString aLine = aCurrentLine.Copy( 1, nPos-1 ); - aLine = WhitespaceToSpace( aLine ); - int nTransPos = aLine.Search( '/' ); - if( nTransPos != STRING_NOTFOUND ) - pValue->m_aOptionTranslation = handleTranslation( aLine.Copy( nTransPos+1 ) ); - - // read in more lines if necessary for multiline values - aLine = aCurrentLine.Copy( nPos+1 ); - while( ! ( aLine.GetTokenCount( '"' ) & 1 ) && - line != rLines.end() ) - // while there is an even number of tokens; that m_eans - // an odd number of doubleqoutes - { - // copy the newlines also - aLine += '\n'; - aLine += *line; - ++line; + // read in more lines if necessary for multiline values + aLine = aCurrentLine.Copy( nPos+1 ); + if( aLine.Len() ) + { + while( ! ( aLine.GetTokenCount( '"' ) & 1 ) && + line != rLines.end() ) + // while there is an even number of tokens; that means + // an odd number of doubleqoutes + { + // copy the newlines also + aLine += '\n'; + aLine += *line; + ++line; + } + } + aLine = WhitespaceToSpace( aLine ); + + // #i100644# handle a missing value (actually a broken PPD) + if( ! aLine.Len() ) + { + if( aOption.Len() && + aUniKey.CompareToAscii( "JCL", 3 ) != COMPARE_EQUAL ) + eType = eInvocation; + else + eType = eQuoted; + } + // check for invocation or quoted value + else if( aLine.GetChar(0) == '"' ) + { + aLine.Erase( 0, 1 ); + nTransPos = aLine.Search( '"' ); + aValue = String( aLine.Copy( 0, nTransPos ), RTL_TEXTENCODING_MS_1252 ); + // after the second doublequote can follow a / and a translation + aValueTranslation = handleTranslation( aLine.Copy( nTransPos+2 ), bIsGlobalizedLine ); + // check for quoted value + if( aOption.Len() && + aUniKey.CompareToAscii( "JCL", 3 ) != COMPARE_EQUAL ) + eType = eInvocation; + else + eType = eQuoted; + } + // check for symbol value + else if( aLine.GetChar(0) == '^' ) + { + aLine.Erase( 0, 1 ); + aValue = String( aLine, RTL_TEXTENCODING_MS_1252 ); + eType = eSymbol; + } + else + { + // must be a string value then + // strictly this is false because string values + // can contain any whitespace which is reduced + // to one space by now + // who cares ... + nTransPos = aLine.Search( '/' ); + if( nTransPos == STRING_NOTFOUND ) + nTransPos = aLine.Len(); + aValue = String( aLine.Copy( 0, nTransPos ), RTL_TEXTENCODING_MS_1252 ); + aValueTranslation = handleTranslation( aLine.Copy( nTransPos+1 ), bIsGlobalizedLine ); + eType = eString; + } } - aLine = WhitespaceToSpace( aLine ); - // check for invocation or quoted value - if( aLine.GetChar(0) == '"' ) + // handle globalized PPD entries + if( bIsGlobalizedLine ) { - aLine.Erase( 0, 1 ); - nTransPos = aLine.Search( '"' ); - pValue->m_aValue = String( aLine.Copy( 0, nTransPos ), RTL_TEXTENCODING_MS_1252 ); - // after the second doublequote can follow a / and a translation - pValue->m_aValueTranslation = handleTranslation( aLine.Copy( nTransPos+2 ) ); - // check for quoted value - if( pValue->m_aOption.Len() && - aKey.CompareTo( "JCL", 3 ) != COMPARE_EQUAL ) - pValue->m_eType = eInvocation; + // handle main key translations of form: + // *ll_CC.Translation MainKeyword/translated text: "" + if( aUniKey.EqualsAscii( "Translation" ) ) + { + m_pTranslator->insertKey( aOption, aOptionTranslation, aTransLocale ); + } + // handle options translations of for: + // *ll_CC.MainKeyword OptionKeyword/translated text: "" else - pValue->m_eType = eQuoted; + { + m_pTranslator->insertOption( aUniKey, aOption, aOptionTranslation, aTransLocale ); + } + continue; } - // check for symbol value - else if( aLine.GetChar(0) == '^' ) + + PPDKey* pKey = NULL; + keyit = m_aKeys.find( aUniKey ); + if( keyit == m_aKeys.end() ) { - aLine.Erase( 0, 1 ); - pValue->m_aValue = String( aLine, RTL_TEXTENCODING_MS_1252 ); - pValue->m_eType = eSymbol; + pKey = new PPDKey( aUniKey ); + insertKey( aUniKey, pKey ); } else - { - // must be a string value then - // strictly this is false because string values - // can contain any whitespace which is reduced - // to one space by now - // who cares ... - nTransPos = aLine.Search( '/' ); - if( nTransPos == STRING_NOTFOUND ) - nTransPos = aLine.Len(); - pValue->m_aValue = String( aLine.Copy( 0, nTransPos ), RTL_TEXTENCODING_MS_1252 ); - pValue->m_aValueTranslation = handleTranslation( aLine.Copy( nTransPos+1 ) ); - pValue->m_eType = eString; - } + pKey = keyit->second; + + if( eType == eNo && bQuery ) + continue; + + PPDValue* pValue = pKey->insertValue( aOption ); + if( ! pValue ) + continue; + pValue->m_eType = eType; + pValue->m_aValue = aValue; + + if( aOptionTranslation.getLength() ) + m_pTranslator->insertOption( aUniKey, aOption, aOptionTranslation, aTransLocale ); + if( aValueTranslation.getLength() ) + m_pTranslator->insertValue( aUniKey, aOption, aValue, aValueTranslation, aTransLocale ); // eventually update query and remove from option list if( bQuery && pKey->m_bQueryValue == FALSE ) @@ -879,7 +1135,7 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) keyit = m_aKeys.find( aKey ); if( keyit != m_aKeys.end() ) { - pKey = keyit->second; + PPDKey* pKey = keyit->second; const PPDValue* pDefValue = pKey->getValue( aOption ); if( pKey->m_pDefaultValue == NULL ) pKey->m_pDefaultValue = pDefValue; @@ -890,7 +1146,7 @@ void PPDParser::parse( ::std::list< ByteString >& rLines ) // do not exist otherwise // (example: DefaultResolution) // so invent that key here and have a default value - pKey = new PPDKey( aKey ); + PPDKey* pKey = new PPDKey( aKey ); PPDValue* pNewValue = pKey->insertValue( aOption ); pNewValue->m_eType = eInvocation; // or what ? insertKey( aKey, pKey ); @@ -915,7 +1171,7 @@ void PPDParser::parseOpenUI( const ByteString& rLine ) nPos = aKey.Search( '/' ); if( nPos != STRING_NOTFOUND ) { - aTranslation = handleTranslation( aKey.Copy( nPos + 1 ) ); + aTranslation = handleTranslation( aKey.Copy( nPos + 1 ), false ); aKey.Erase( nPos ); } aKey = GetCommandLineToken( 1, aKey ); @@ -933,7 +1189,7 @@ void PPDParser::parseOpenUI( const ByteString& rLine ) pKey = keyit->second; pKey->m_bUIOption = true; - pKey->m_aUITranslation = aTranslation; + m_pTranslator->insertKey( pKey->getKey(), aTranslation ); ByteString aValue = WhitespaceToSpace( rLine.GetToken( 1, ':' ) ); if( aValue.CompareIgnoreCaseToAscii( "boolean" ) == COMPARE_EQUAL ) @@ -1393,6 +1649,36 @@ const String& PPDParser::getFont( int nFont ) const return aEmptyString; } +rtl::OUString PPDParser::translateKey( const rtl::OUString& i_rKey, + const com::sun::star::lang::Locale& i_rLocale ) const +{ + rtl::OUString aResult( m_pTranslator->translateKey( i_rKey, i_rLocale ) ); + if( aResult.getLength() == 0 ) + aResult = i_rKey; + return aResult; +} + +rtl::OUString PPDParser::translateOption( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const com::sun::star::lang::Locale& i_rLocale ) const +{ + rtl::OUString aResult( m_pTranslator->translateOption( i_rKey, i_rOption, i_rLocale ) ); + if( aResult.getLength() == 0 ) + aResult = i_rOption; + return aResult; +} + +rtl::OUString PPDParser::translateValue( const rtl::OUString& i_rKey, + const rtl::OUString& i_rOption, + const rtl::OUString& i_rValue, + const com::sun::star::lang::Locale& i_rLocale ) const +{ + rtl::OUString aResult( m_pTranslator->translateValue( i_rKey, i_rOption, i_rValue, i_rLocale ) ); + if( aResult.getLength() == 0 ) + aResult = i_rValue; + return aResult; +} + /* * PPDKey */ diff --git a/vcl/unx/source/printer/printerinfomanager.cxx b/vcl/unx/source/printer/printerinfomanager.cxx index 53cd662db8e0..ef6a67203cd8 100644 --- a/vcl/unx/source/printer/printerinfomanager.cxx +++ b/vcl/unx/source/printer/printerinfomanager.cxx @@ -119,6 +119,7 @@ PrinterInfoManager::PrinterInfoManager( Type eType ) : m_pQueueInfo( NULL ), m_eType( eType ), m_bUseIncludeFeature( false ), + m_bUseJobPatch( true ), m_aSystemDefaultPaper( RTL_CONSTASCII_USTRINGPARAM( "A4" ) ), m_bDisableCUPS( false ) { diff --git a/vcl/unx/source/printergfx/printerjob.cxx b/vcl/unx/source/printergfx/printerjob.cxx index 1c42cafa4cb9..bc9746c3fe77 100644 --- a/vcl/unx/source/printergfx/printerjob.cxx +++ b/vcl/unx/source/printergfx/printerjob.cxx @@ -915,6 +915,9 @@ bool PrinterJob::writePageSetup( osl::File* pFile, const JobData& rJob, bool bWr void PrinterJob::writeJobPatch( osl::File* pFile, const JobData& rJobData ) { + if( ! PrinterInfoManager::get().getUseJobPatch() ) + return; + const PPDKey* pKey = NULL; if( rJobData.m_pParser ) |