summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-06-12 22:25:22 +0200
committerMichael Stahl <mstahl@redhat.com>2017-06-13 10:41:24 +0200
commit4ffdb6750fa7d656d249a745f9c6d5ba98353b14 (patch)
treeb76a1b0d910886e9e6519c6fa31d918d253ebc3e /vcl
parent144edb88d29d397604010734f2d6c2e9d7626d1c (diff)
remove TDE integration (vclplug, address book, config backend)
It has ~no users, can't even be built on modern Linuxes, and it annoys folks who want to refactor VCL. Per ESC decision from 2017-06-08, remove --enable-tde and --enable-tdeab. Change-Id: I51ce4786f29f8fcac2e2bb2a654c41fbfbbd8afd Reviewed-on: https://gerrit.libreoffice.org/38718 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/CustomTarget_tde_moc.mk21
-rw-r--r--vcl/Executable_tdefilepicker.mk51
-rw-r--r--vcl/Library_vclplug_tde.mk86
-rw-r--r--vcl/Module_vcl.mk7
-rw-r--r--vcl/inc/unx/kde/kdedata.hxx110
-rw-r--r--vcl/unx/kde/FPServiceInfo.hxx42
-rw-r--r--vcl/unx/kde/UnxCommandThread.cxx300
-rw-r--r--vcl/unx/kde/UnxCommandThread.hxx126
-rw-r--r--vcl/unx/kde/UnxFilePicker.cxx910
-rw-r--r--vcl/unx/kde/UnxFilePicker.hxx165
-rw-r--r--vcl/unx/kde/UnxNotifyThread.cxx103
-rw-r--r--vcl/unx/kde/UnxNotifyThread.hxx77
-rw-r--r--vcl/unx/kde/fpicker/kdecommandthread.cxx185
-rw-r--r--vcl/unx/kde/fpicker/kdecommandthread.hxx103
-rw-r--r--vcl/unx/kde/fpicker/kdefilepicker.cxx806
-rw-r--r--vcl/unx/kde/fpicker/kdefilepicker.hxx138
-rw-r--r--vcl/unx/kde/fpicker/kdefpmain.cxx109
-rw-r--r--vcl/unx/kde/fpicker/kdemodalityfilter.cxx62
-rw-r--r--vcl/unx/kde/fpicker/kdemodalityfilter.hxx52
-rw-r--r--vcl/unx/kde/kdedata.cxx238
-rw-r--r--vcl/unx/kde/salnativewidgets-kde.cxx2097
21 files changed, 0 insertions, 5788 deletions
diff --git a/vcl/CustomTarget_tde_moc.mk b/vcl/CustomTarget_tde_moc.mk
deleted file mode 100644
index 72c8699f741d..000000000000
--- a/vcl/CustomTarget_tde_moc.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kde/fpicker))
-
-$(call gb_CustomTarget_get_target,vcl/unx/kde/fpicker) : \
- $(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/kdefilepicker.moc.cxx
-
-$(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/kdefilepicker.moc.cxx :\
- $(SRCDIR)/vcl/unx/kde/fpicker/kdefilepicker.hxx \
- | $(call gb_CustomTarget_get_workdir,vcl/unx/kde/fpicker)/.dir
- $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),MOC,1)
- cat $< | grep -v 'FILTER_OUT_KDE' | $(TDE_MOC) -o $@ -f$<
-
-# vim:set shiftwidth=4 tabstop=4 noexpandtab:
diff --git a/vcl/Executable_tdefilepicker.mk b/vcl/Executable_tdefilepicker.mk
deleted file mode 100644
index c779059bed2b..000000000000
--- a/vcl/Executable_tdefilepicker.mk
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-$(eval $(call gb_Executable_Executable,tdefilepicker))
-
-$(eval $(call gb_Executable_add_defs,tdefilepicker,\
- $(TDE_CFLAGS) \
- -DENABLE_TDE \
-))
-
-$(eval $(call gb_Executable_set_include,tdefilepicker,\
- $$(INCLUDE) \
- -I$(SRCDIR)/vcl/inc \
- -I$(SRCDIR)/vcl/inc/unx/kde \
-))
-
-$(eval $(call gb_Executable_use_libraries,tdefilepicker,\
- sal \
-))
-
-$(eval $(call gb_Executable_add_libs,tdefilepicker,\
- $(TDE_LIBS) \
- -ltdeio -lX11 \
-))
-
-$(eval $(call gb_Executable_add_exception_objects,tdefilepicker,\
- vcl/unx/kde/fpicker/kdecommandthread \
- vcl/unx/kde/fpicker/kdefilepicker \
- vcl/unx/kde/fpicker/kdefpmain \
- vcl/unx/kde/fpicker/kdemodalityfilter \
-))
-
-$(eval $(call gb_Executable_add_generated_exception_objects,tdefilepicker,\
- CustomTarget/vcl/unx/kde/fpicker/kdefilepicker.moc \
-))
-
-$(eval $(call gb_Executable_set_warnings_not_errors,tdefilepicker))
-
-# TDE/TQt consider -Wshadow more trouble than benefit
-$(eval $(call gb_Executable_add_cxxflags,kdefilepicker,\
- -Wno-shadow \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/vcl/Library_vclplug_tde.mk b/vcl/Library_vclplug_tde.mk
deleted file mode 100644
index 2dd582a3a40a..000000000000
--- a/vcl/Library_vclplug_tde.mk
+++ /dev/null
@@ -1,86 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# Copyright (C) 2012, Timothy Pearson <kb9vqf@pearsoncomputing.net>
-#
-
-$(eval $(call gb_Library_Library,vclplug_tde))
-
-$(eval $(call gb_Library_set_include,vclplug_tde,\
- $$(INCLUDE) \
- -I$(SRCDIR)/vcl/inc \
- -I$(SRCDIR)/vcl/inc/unx/kde \
-))
-
-$(eval $(call gb_Library_set_include,vclplug_tde,\
- $$(INCLUDE) \
- $$(TDE_CFLAGS) \
-))
-
-$(eval $(call gb_Library_add_defs,vclplug_tde,\
- -DVCLPLUG_TDE_IMPLEMENTATION \
-))
-
-$(eval $(call gb_Library_use_sdk_api,vclplug_tde))
-
-$(eval $(call gb_Library_add_libs,vclplug_tde,\
- $(TDE_LIBS) \
- -lX11 \
- -lXext \
- -lSM \
- -lICE \
-))
-
-$(eval $(call gb_Library_use_libraries,vclplug_tde,\
- vclplug_gen \
- vcl \
- tl \
- utl \
- sot \
- ucbhelper \
- basegfx \
- comphelper \
- cppuhelper \
- i18nlangtag \
- i18nutil \
- $(if $(ENABLE_JAVA), \
- jvmaccess) \
- cppu \
- sal \
-))
-
-$(eval $(call gb_Library_use_externals,vclplug_tde,\
- boost_headers \
- epoxy \
- icuuc \
-))
-
-$(eval $(call gb_Library_add_exception_objects,vclplug_tde,\
- vcl/unx/kde/kdedata \
- vcl/unx/kde/salnativewidgets-kde \
- vcl/unx/kde/UnxCommandThread \
- vcl/unx/kde/UnxFilePicker \
- vcl/unx/kde/UnxNotifyThread \
-))
-
-# TDE/TQt consider -Wshadow more trouble than benefit
-$(eval $(call gb_Library_add_cxxflags,vclplug_tde,\
- -Wno-shadow \
-))
-
-$(eval $(call gb_Library_set_warnings_not_errors,vclplug_tde))
-
-ifeq ($(OS),LINUX)
-$(eval $(call gb_Library_add_libs,vclplug_tde,\
- -lm \
- -ldl \
- -lpthread \
-))
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index c7d225b83a48..54ba2bf027c6 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -75,13 +75,6 @@ $(eval $(call gb_Module_add_targets,vcl,\
Library_vclplug_gtk3 \
))
endif
-ifneq ($(ENABLE_TDE),)
-$(eval $(call gb_Module_add_targets,vcl,\
- CustomTarget_tde_moc \
- Executable_tdefilepicker \
- Library_vclplug_tde \
-))
-endif
ifneq ($(ENABLE_KDE4),)
$(eval $(call gb_Module_add_targets,vcl,\
CustomTarget_kde4_moc \
diff --git a/vcl/inc/unx/kde/kdedata.hxx b/vcl/inc/unx/kde/kdedata.hxx
deleted file mode 100644
index 926909aac910..000000000000
--- a/vcl/inc/unx/kde/kdedata.hxx
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX
-#define INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX
-
-#include <unx/saldisp.hxx>
-#include <unx/saldata.hxx>
-#include <unx/salframe.h>
-#include <unx/salgdi.h>
-
-#include <memory>
-
-class KDEData : public X11SalData
-{
-public:
- KDEData( SalInstance *pInstance ) : X11SalData( SAL_DATA_KDE3, pInstance ) {}
- virtual ~KDEData() override;
-
- virtual void Init() override;
- virtual void initNWF() override;
- virtual void deInitNWF() override;
-};
-
-class SalKDEDisplay : public SalX11Display
-{
-public:
- SalKDEDisplay( Display* pDisp );
- virtual ~SalKDEDisplay() override;
-};
-
-class KDESalFrame : public X11SalFrame
-{
- static const int nMaxGraphics = 2;
-
- struct GraphicsHolder
- {
- std::unique_ptr<X11SalGraphics> pGraphics;
- bool bInUse;
- GraphicsHolder() : bInUse( false ) {}
- };
- GraphicsHolder m_aGraphics[ nMaxGraphics ];
-
-public:
- KDESalFrame( SalFrame* pParent, SalFrameStyleFlags );
- virtual ~KDESalFrame() override;
-
- virtual SalGraphics* AcquireGraphics() override;
- virtual void ReleaseGraphics( SalGraphics *pGraphics ) override;
- virtual void updateGraphics( bool bClear ) override;
- virtual void UpdateSettings( AllSettings& rSettings ) override;
- virtual void Show( bool bVisible, bool bNoActivate = false ) override;
-};
-
-class KDESalInstance : public X11SalInstance
-{
-protected:
- virtual SalX11Display* CreateDisplay() const override;
-
-public:
- KDESalInstance( SalYieldMutex* pMutex )
- : X11SalInstance( pMutex ) {}
- virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
-
- virtual bool hasNativeFileSelection() const override { return true; }
-
- virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 >
- createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& ) override;
-};
-
-class KDEXLib : public SalXLib
-{
- bool m_bStartupDone;
- void* m_pApplication;
- char** m_pFreeCmdLineArgs;
- char** m_pAppCmdLineArgs;
- int m_nFakeCmdLineArgs;
-public:
- KDEXLib() : SalXLib(),
- m_bStartupDone( false ),
- m_pApplication( nullptr ),
- m_pFreeCmdLineArgs( nullptr ),
- m_pAppCmdLineArgs( nullptr ),
- m_nFakeCmdLineArgs( 0 )
- {}
- virtual ~KDEXLib() override;
- virtual void Init() override;
-
- void doStartup();
-};
-
-#endif // INCLUDED_VCL_INC_UNX_KDE_KDEDATA_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/FPServiceInfo.hxx b/vcl/unx/kde/FPServiceInfo.hxx
deleted file mode 100644
index 34096b9f6cf9..000000000000
--- a/vcl/unx/kde/FPServiceInfo.hxx
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_FPSERVICEINFO_HXX
-#define INCLUDED_VCL_UNX_KDE_FPSERVICEINFO_HXX
-
-#include <config_vclplug.h>
-
-#if ENABLE_TDE
-
-// the service names
-#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.TDEFilePicker"
-
-#else // ENABLE_TDE
-
-// the service names
-#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.KDEFilePicker"
-
-#endif // ENABLE_TDE
-
-// the implementation names
-#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.UnxFilePicker"
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxCommandThread.cxx b/vcl/unx/kde/UnxCommandThread.cxx
deleted file mode 100644
index e2ca566dcce2..000000000000
--- a/vcl/unx/kde/UnxCommandThread.cxx
+++ /dev/null
@@ -1,300 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <UnxCommandThread.hxx>
-#include <UnxNotifyThread.hxx>
-
-#include <rtl/ustring.hxx>
-#include <rtl/ustrbuf.hxx>
-
-#include <unistd.h>
-#include <string.h>
-#include <iostream>
-#include <comphelper/sequence.hxx>
-
-using namespace ::com::sun::star;
-
-namespace {
-
-::std::list< OUString > tokenize( const OUString &rCommand )
-{
- ::std::list< OUString > aList;
- OUStringBuffer aBuffer( 1024 );
-
- const sal_Unicode *pUnicode = rCommand.getStr();
- const sal_Unicode *pEnd = pUnicode + rCommand.getLength();
- bool bQuoted = false;
-
- for ( ; pUnicode != pEnd; ++pUnicode )
- {
- if ( *pUnicode == '\\' )
- {
- ++pUnicode;
- if ( pUnicode != pEnd )
- {
- if ( *pUnicode == 'n' )
- aBuffer.append( "\n" );
- else
- aBuffer.append( *pUnicode );
- }
- }
- else if ( *pUnicode == '"' )
- bQuoted = !bQuoted;
- else if ( *pUnicode == ' ' && !bQuoted )
- aList.push_back( aBuffer.makeStringAndClear() );
- else
- aBuffer.append( *pUnicode );
- }
- aList.push_back( aBuffer.makeStringAndClear() );
-
- return aList;
-}
-
-}
-
-// UnxFilePickerCommandThread
-
-UnxFilePickerCommandThread::UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD )
- : m_pNotifyThread( pNotifyThread ),
- m_nReadFD( nReadFD )
-{
-}
-
-UnxFilePickerCommandThread::~UnxFilePickerCommandThread()
-{
-}
-
-bool SAL_CALL UnxFilePickerCommandThread::result()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_aResult;
-}
-
-OUString SAL_CALL UnxFilePickerCommandThread::getCurrentFilter()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_aGetCurrentFilter;
-}
-
-OUString SAL_CALL UnxFilePickerCommandThread::getDirectory()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_aGetDirectory;
-}
-
-uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getSelectedFiles()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- sal_Int32 nSize = m_aGetFiles.size();
- uno::Sequence< OUString > aFiles( nSize );
-
- size_t nIdx = 0;
- for ( ::std::list< OUString >::const_iterator it = m_aGetFiles.begin();
- it != m_aGetFiles.end(); ++it, ++nIdx )
- {
- aFiles[nIdx] = *it;
- }
-
- return aFiles;
-}
-uno::Sequence< OUString > SAL_CALL UnxFilePickerCommandThread::getFiles()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- uno::Sequence< OUString > aFiles = getSelectedFiles();
- if (aFiles.getLength() > 1)
- aFiles.realloc(1); // we just want the first entry here
-
- return aFiles;
-}
-
-uno::Any SAL_CALL UnxFilePickerCommandThread::getValue()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_aGetValue;
-}
-
-void SAL_CALL UnxFilePickerCommandThread::run()
-{
- osl_setThreadName("UnxFilePickerCommandThread");
-
- if ( m_nReadFD < 0 )
- return;
-
- sal_Int32 nBufferSize = 1024; // 1 is for testing, 1024 for real use
- sal_Char *pBuffer = new sal_Char[nBufferSize];
- sal_Char *pBufferEnd = pBuffer + nBufferSize;
-
- sal_Char *pWhereToRead = pBuffer;
- sal_Char *pEntryBegin = pBuffer;
- sal_Int32 nBytesRead = 0;
- bool bShouldExit = false;
- while ( !bShouldExit && ( nBytesRead = read( m_nReadFD, pWhereToRead, pBufferEnd - pWhereToRead ) ) > 0 )
- {
- bool bFoundNL = false;
- sal_Char *pWhereToReadEnd = pWhereToRead + nBytesRead;
- sal_Char *pEntryEnd = pWhereToRead;
- do {
- for ( ; pEntryEnd < pWhereToReadEnd && *pEntryEnd != '\n'; ++pEntryEnd )
- ;
-
- if ( pEntryEnd < pWhereToReadEnd )
- {
- bFoundNL = true;
- *pEntryEnd = 0;
-
- if ( strcmp( pEntryBegin, "exited" ) == 0 )
- bShouldExit = true;
- else
- handleCommand( OUString( pEntryBegin, pEntryEnd - pEntryBegin, RTL_TEXTENCODING_UTF8 )/*, bQuit*/ );
-
- pEntryBegin = pEntryEnd + 1;
- }
- } while ( pEntryEnd < pWhereToReadEnd );
-
- if ( bFoundNL )
- {
- if ( pEntryBegin < pBufferEnd )
- memmove( pBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin );
- }
- else
- {
- // enlarge the buffer size
- nBufferSize *= 2;
- sal_Char *pNewBuffer = new sal_Char[nBufferSize];
- if ( pEntryBegin < pBufferEnd )
- memcpy( pNewBuffer, pEntryBegin, pWhereToReadEnd - pEntryBegin );
-
- delete[] pBuffer;
- pBuffer = pNewBuffer;
- pBufferEnd = pBuffer + nBufferSize;
- }
-
- pWhereToRead = pBuffer + ( pWhereToReadEnd - pEntryBegin );
- pEntryBegin = pBuffer;
- }
-}
-
-void SAL_CALL UnxFilePickerCommandThread::handleCommand( const OUString &rCommand )
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
-#if OSL_DEBUG_LEVEL > 0
- ::std::cerr << "UnxFilePicker received: \"" <<
- OUStringToOString( rCommand, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl;
-#endif
-
- ::std::list< OUString > aList = tokenize( rCommand );
-
- if ( aList.empty() )
- return;
-
- OUString aCommandName = aList.front();
- aList.pop_front();
-
- if ( aCommandName == "accept" )
- {
- m_aResult = true;
- m_aExecCondition.set();
- }
- else if ( aCommandName == "reject" )
- {
- m_aResult = false;
- m_aExecCondition.set();
- }
- else if ( aCommandName == "fileSelectionChanged" )
- {
- if ( m_pNotifyThread )
- m_pNotifyThread->fileSelectionChanged();
- }
- else if ( aCommandName == "files" )
- {
- m_aGetFiles = aList;
- m_aGetFilesCondition.set();
- }
- else if ( aCommandName == "value" )
- {
- OUString aType;
- if ( !aList.empty() )
- {
- aType = aList.front();
- aList.pop_front();
- }
-
- if ( aType == "bool" )
- {
- bool bValue = !aList.empty() && aList.front().equalsIgnoreAsciiCase("true");
-
- m_aGetValue <<= bValue;
- m_aGetValueCondition.set();
- }
- else if ( aType == "int" )
- {
- sal_Int32 nValue = 0;
- if ( !aList.empty() )
- nValue = aList.front().toInt32();
-
- m_aGetValue <<= nValue;
- m_aGetValueCondition.set();
- }
- else if ( aType == "string" )
- {
- OUString aValue;
- if ( !aList.empty() )
- aValue = aList.front();
-
- m_aGetValue <<= aValue;
- m_aGetValueCondition.set();
- }
- else if ( aType == "stringList" )
- {
- m_aGetValue <<= comphelper::containerToSequence(aList);
- m_aGetValueCondition.set();
- }
- else
- {
- m_aGetValue = uno::Any();
- m_aGetValueCondition.set();
- }
- }
- else if ( aCommandName == "currentFilter" )
- {
- m_aGetCurrentFilter = aList.empty()? OUString(): aList.front();
- m_aGetCurrentFilterCondition.set();
- }
- else if ( aCommandName == "currentDirectory" )
- {
- m_aGetDirectory = aList.empty()? OUString(): aList.front();
- m_aGetDirectoryCondition.set();
- }
- else
- {
-#if OSL_DEBUG_LEVEL > 0
- ::std::cerr << "Unrecognized command: "
- << OUStringToOString( aCommandName, RTL_TEXTENCODING_ASCII_US ).getStr() << "\"" << ::std::endl;
-#endif
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxCommandThread.hxx b/vcl/unx/kde/UnxCommandThread.hxx
deleted file mode 100644
index 6c3a228e9f5c..000000000000
--- a/vcl/unx/kde/UnxCommandThread.hxx
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
-#define INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
-
-#include <com/sun/star/uno/Any.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
-#include <osl/thread.hxx>
-#include <rtl/ustring.hxx>
-
-#include <vcl/svapp.hxx>
-
-#include <list>
-
-class UnxFilePickerNotifyThread;
-
-/** Synchronization for the 'thread-less' version of the fpicker.
-
- Something like osl::Condition, but calls Application::Yield() while in
- wait().
-*/
-class YieldingCondition
-{
- ::osl::Mutex m_aMutex;
- bool m_bValue;
-
- bool get()
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- return m_bValue;
- }
-
-public:
- YieldingCondition() { reset(); }
-
- void reset()
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- m_bValue = false;
- }
-
- void set()
- {
- ::osl::MutexGuard aGuard( m_aMutex );
- m_bValue = true;
- }
-
- void wait()
- {
- while ( !get() )
- Application::Yield();
- }
-};
-
-class UnxFilePickerCommandThread : public ::osl::Thread
-{
-protected:
- UnxFilePickerNotifyThread *m_pNotifyThread;
- int m_nReadFD;
-
- ::osl::Mutex m_aMutex;
-
- YieldingCondition m_aExecCondition;
- bool m_aResult;
-
- ::osl::Condition m_aGetCurrentFilterCondition;
- OUString m_aGetCurrentFilter;
-
- ::osl::Condition m_aGetDirectoryCondition;
- OUString m_aGetDirectory;
-
- ::osl::Condition m_aGetFilesCondition;
- ::std::list< OUString > m_aGetFiles;
-
- ::osl::Condition m_aGetValueCondition;
- css::uno::Any m_aGetValue;
-
-public:
- UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD );
- virtual ~UnxFilePickerCommandThread() override;
-
- YieldingCondition& SAL_CALL execCondition() { return m_aExecCondition; }
- bool SAL_CALL result();
-
- ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; }
- OUString SAL_CALL getCurrentFilter();
-
- ::osl::Condition& SAL_CALL getDirectoryCondition() { return m_aGetDirectoryCondition; }
- OUString SAL_CALL getDirectory();
-
- ::osl::Condition& SAL_CALL getFilesCondition() { return m_aGetFilesCondition; }
- css::uno::Sequence< OUString > SAL_CALL getSelectedFiles();
- css::uno::Sequence< OUString > SAL_CALL getFiles();
-
- ::osl::Condition& SAL_CALL getValueCondition() { return m_aGetValueCondition; }
- css::uno::Any SAL_CALL getValue();
-
-protected:
- virtual void SAL_CALL run() override;
-
- virtual void SAL_CALL handleCommand( const OUString &rCommand/*, bool &rQuit*/ );
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxFilePicker.cxx b/vcl/unx/kde/UnxFilePicker.cxx
deleted file mode 100644
index 8fbed035a0b3..000000000000
--- a/vcl/unx/kde/UnxFilePicker.cxx
+++ /dev/null
@@ -1,910 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/IllegalArgumentException.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
-#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
-#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
-#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
-#include <com/sun/star/ui/dialogs/ControlActions.hpp>
-
-#include <FPServiceInfo.hxx>
-
-#include <cppuhelper/interfacecontainer.h>
-#include <cppuhelper/supportsservice.hxx>
-#include <osl/diagnose.h>
-#include <osl/file.hxx>
-#include <rtl/ustring.hxx>
-#include <rtl/ustrbuf.hxx>
-#include <rtl/bootstrap.hxx>
-#include <tools/resmgr.hxx>
-
-#include <UnxFilePicker.hxx>
-#include <UnxCommandThread.hxx>
-#include <UnxNotifyThread.hxx>
-
-#include <vcl/fpicker.hrc>
-#include <vcl/svapp.hxx>
-#include <vcl/sysdata.hxx>
-#include <vcl/syswin.hxx>
-#include <vcl/window.hxx>
-
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#include <iostream>
-
-#include <config_vclplug.h>
-
-using namespace ::com::sun::star;
-
-using namespace ::com::sun::star::ui::dialogs;
-using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
-
-// helper functions
-
-namespace
-{
- uno::Sequence<OUString> SAL_CALL FilePicker_getSupportedServiceNames()
- {
- uno::Sequence<OUString> aRet(3);
- aRet[0] = "com.sun.star.ui.dialogs.FilePicker";
- aRet[1] = "com.sun.star.ui.dialogs.SystemFilePicker";
-#if ENABLE_TDE
- aRet[2] = "com.sun.star.ui.dialogs.TDEFilePicker";
-#else // ENABLE_TDE
- aRet[2] = "com.sun.star.ui.dialogs.KDEFilePicker";
-#endif // ENABLE_TDE
- return aRet;
- }
-
-void appendEscaped( OUStringBuffer &rBuffer, const OUString &rString )
-{
- const sal_Unicode *pUnicode = rString.getStr();
- const sal_Unicode *pEnd = pUnicode + rString.getLength();
-
- rBuffer.append( "\"" );
-
- for ( ; pUnicode != pEnd; ++pUnicode )
- {
- if ( *pUnicode == '\\' )
- rBuffer.append( "\\\\" );
- else if ( *pUnicode == '"' )
- rBuffer.append( "\\\"" );
- else if ( *pUnicode == '\n' )
- rBuffer.append( "\\n" );
- else
- rBuffer.append( *pUnicode );
- }
-
- rBuffer.append( "\"" );
-}
-
-bool controlIdInfo( sal_Int16 nControlId, OUString &rType, sal_Int32 &rTitleId )
-{
- typedef struct {
- sal_Int16 nId;
- const OUString *pType;
- sal_Int32 nTitle;
- } ElementToName;
-
- const OUString aCheckBox( "checkbox" );
- const OUString aControl( "control" );
- const OUString aEdit( "edit" );
- const OUString aLabel( "label" );
- const OUString aListBox( "listbox" );
- const OUString aPushButton( "pushbutton" );
-
- const ElementToName *pPtr;
- const ElementToName pArray[] =
- {
- { CommonFilePickerElementIds::PUSHBUTTON_OK, &aPushButton, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::PUSHBUTTON_CANCEL, &aPushButton, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::LISTBOX_FILTER, &aListBox, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::CONTROL_FILEVIEW, &aControl, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::EDIT_FILEURL, &aEdit, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::LISTBOX_FILTER_LABEL, &aLabel, 0/*FIXME?*/ },
- { CommonFilePickerElementIds::EDIT_FILEURL_LABEL, &aLabel, 0/*FIXME?*/ },
-
- { ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, &aCheckBox, STR_SVT_FILEPICKER_AUTO_EXTENSION },
- { ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, &aCheckBox, STR_SVT_FILEPICKER_PASSWORD },
- { ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS, &aCheckBox, STR_SVT_FILEPICKER_FILTER_OPTIONS },
- { ExtendedFilePickerElementIds::CHECKBOX_READONLY, &aCheckBox, STR_SVT_FILEPICKER_READONLY },
- { ExtendedFilePickerElementIds::CHECKBOX_LINK, &aCheckBox, STR_SVT_FILEPICKER_INSERT_AS_LINK },
- { ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, &aCheckBox, STR_SVT_FILEPICKER_SHOW_PREVIEW },
- { ExtendedFilePickerElementIds::PUSHBUTTON_PLAY, &aPushButton, STR_SVT_FILEPICKER_PLAY },
- { ExtendedFilePickerElementIds::LISTBOX_VERSION, &aListBox, STR_SVT_FILEPICKER_VERSION },
- { ExtendedFilePickerElementIds::LISTBOX_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_TEMPLATES },
- { ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE, &aListBox, STR_SVT_FILEPICKER_IMAGE_TEMPLATE },
- { ExtendedFilePickerElementIds::CHECKBOX_SELECTION, &aCheckBox, STR_SVT_FILEPICKER_SELECTION },
- { 0, nullptr, 0 }
- };
-
- for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlId ); ++pPtr )
- ;
-
- if ( pPtr->nId == nControlId )
- {
- rType = *(pPtr->pType);
- rTitleId = pPtr->nTitle;
-
- return true;
- }
-
- return false;
-}
-
-bool controlActionInfo( sal_Int16 nControlAction, OUString &rType )
-{
- typedef struct {
- sal_Int16 nId;
- const OUString pType;
- } ElementToName;
-
- const ElementToName *pPtr;
- const ElementToName pArray[] =
- {
- { ControlActions::ADD_ITEM, OUString( "addItem" ) },
- { ControlActions::ADD_ITEMS, OUString( "addItems" ) },
- { ControlActions::DELETE_ITEM, OUString( "deleteItem" ) },
- { ControlActions::DELETE_ITEMS, OUString( "deleteItems" ) },
- { ControlActions::SET_SELECT_ITEM, OUString( "setSelectedItem" ) },
- { ControlActions::GET_ITEMS, OUString( "getItems" ) },
- { ControlActions::GET_SELECTED_ITEM, OUString( "getSelectedItem" ) },
- { ControlActions::GET_SELECTED_ITEM_INDEX, OUString( "getSelectedItemIndex" ) },
- { ControlActions::SET_HELP_URL, OUString( "setHelpURL" ) },
- { ControlActions::GET_HELP_URL, OUString( "getHelpURL" ) },
- { 0, OUString( "noAction" ) }
- };
-
- for ( pPtr = pArray; pPtr->nId && ( pPtr->nId != nControlAction ); ++pPtr )
- ;
-
- rType = pPtr->pType;
-
- return true;
-}
-
-}
-
-// UnxFilePicker
-
-UnxFilePicker::UnxFilePicker( const uno::Reference<uno::XComponentContext>& )
- : UnxFilePicker_Base( m_rbHelperMtx ),
- m_nFilePickerPid( -1 ),
- m_nFilePickerWrite( -1 ),
- m_nFilePickerRead( -1 ),
- m_pNotifyThread( nullptr ),
- m_pCommandThread( nullptr ),
- m_pResMgr( ResMgr::CreateResMgr("fps_office") )
-{
-}
-
-UnxFilePicker::~UnxFilePicker()
-{
- if ( m_nFilePickerPid > 0 )
- {
- sendCommand( "exit" );
- waitpid( m_nFilePickerPid, nullptr, 0 );
- }
-
- if ( m_pCommandThread )
- {
- m_pCommandThread->join();
-
- delete m_pCommandThread; m_pCommandThread = nullptr;
- }
-
- if ( m_pNotifyThread )
- {
- m_pNotifyThread->exit();
-
- m_pNotifyThread->join();
-
- delete m_pNotifyThread; m_pNotifyThread = nullptr;
- }
-
- if ( m_nFilePickerWrite >= 0 )
- close( m_nFilePickerWrite );
-
- if ( m_nFilePickerRead >= 0 )
- close( m_nFilePickerRead );
-
- delete m_pResMgr; m_pResMgr = nullptr;
-}
-
-void SAL_CALL UnxFilePicker::addFilePickerListener( const uno::Reference<XFilePickerListener>& xListener )
-{
- OSL_ASSERT( m_pNotifyThread );
- osl::MutexGuard aGuard( m_aMutex );
-
- m_pNotifyThread->addFilePickerListener( xListener );
-}
-
-void SAL_CALL UnxFilePicker::removeFilePickerListener( const uno::Reference<XFilePickerListener>& xListener )
-{
- OSL_ASSERT( m_pNotifyThread );
- osl::MutexGuard aGuard( m_aMutex );
-
- m_pNotifyThread->removeFilePickerListener( xListener );
-}
-
-void SAL_CALL UnxFilePicker::setTitle( const OUString &rTitle )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setTitle " );
- appendEscaped( aBuffer, rTitle );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-sal_Int16 SAL_CALL UnxFilePicker::execute()
-{
- checkFilePicker();
-
- // this is _not_ an osl::Condition, see i#93366
- m_pCommandThread->execCondition().reset();
-
- sendCommand( "exec" );
-
- m_pCommandThread->execCondition().wait();
-
- return m_pCommandThread->result()
- ? css::ui::dialogs::ExecutableDialogResults::OK
- : css::ui::dialogs::ExecutableDialogResults::CANCEL;
-}
-
-void SAL_CALL UnxFilePicker::setMultiSelectionMode( sal_Bool bMode )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- if ( bMode )
- sendCommand( "setMultiSelection true" );
- else
- sendCommand( "setMultiSelection false" );
-}
-
-void SAL_CALL UnxFilePicker::setDefaultName( const OUString &rName )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setDefaultName " );
- appendEscaped( aBuffer, rName );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-void SAL_CALL UnxFilePicker::setDisplayDirectory( const OUString &rDirectory )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setDirectory " );
- appendEscaped( aBuffer, rDirectory );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-OUString SAL_CALL UnxFilePicker::getDisplayDirectory()
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- sendCommand( "getDirectory",
- m_pCommandThread->getDirectoryCondition() );
-
- return m_pCommandThread->getDirectory();
-}
-
-uno::Sequence< OUString > SAL_CALL UnxFilePicker::getFiles()
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- sendCommand( "getFiles",
- m_pCommandThread->getFilesCondition() );
-
- return m_pCommandThread->getFiles();
-}
-
-void SAL_CALL UnxFilePicker::appendFilter( const OUString &rTitle, const OUString &rFilter )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "appendFilter " );
- appendEscaped( aBuffer, rTitle );
- aBuffer.append( " " );
- appendEscaped( aBuffer, rFilter );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-void SAL_CALL UnxFilePicker::setCurrentFilter( const OUString &rTitle )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setCurrentFilter " );
- appendEscaped( aBuffer, rTitle );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-OUString SAL_CALL UnxFilePicker::getCurrentFilter()
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- sendCommand( "getCurrentFilter",
- m_pCommandThread->getCurrentFilterCondition() );
-
- return m_pCommandThread->getCurrentFilter();
-}
-
-void SAL_CALL UnxFilePicker::appendFilterGroup( const OUString &rGroupTitle, const uno::Sequence<beans::StringPair> &rFilters )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "appendFilterGroup " );
- appendEscaped( aBuffer, rGroupTitle );
-
- for ( sal_Int32 i = 0; i < rFilters.getLength(); ++i )
- {
- beans::StringPair aPair = rFilters[i];
-
- aBuffer.append( " " );
- appendEscaped( aBuffer, aPair.First );
- aBuffer.append( " " );
- appendEscaped( aBuffer, aPair.Second );
- }
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-void SAL_CALL UnxFilePicker::setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const uno::Any &rValue )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUString aType;
- OUString aAction;
- sal_Int32 nTitleId;
-
- if ( controlIdInfo( nControlId, aType, nTitleId ) && controlActionInfo( nControlAction, aAction ) )
- {
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setValue " );
- aBuffer.append( static_cast< sal_Int32 >( nControlId ) );
- aBuffer.append( " " );
- aBuffer.append( aAction );
-
- if ( aType == "checkbox" )
- {
- bool bControlValue;
- if ( ( rValue >>= bControlValue ) && bControlValue )
- aBuffer.append( " true" );
- else
- aBuffer.append( " false" );
- }
- else if ( aType == "listbox" )
- {
- switch ( nControlAction )
- {
- case ControlActions::ADD_ITEM:
- case ControlActions::SET_HELP_URL:
- {
- OUString aString;
- if ( rValue >>= aString )
- {
- aBuffer.append( " " );
- appendEscaped( aBuffer, aString );
- }
- }
- break;
-
- case ControlActions::ADD_ITEMS:
- {
- uno::Sequence< OUString > aSequence;
- if ( rValue >>= aSequence )
- {
- for ( sal_Int32 nIdx = 0; nIdx < aSequence.getLength(); ++nIdx )
- {
- aBuffer.append( " " );
- appendEscaped( aBuffer, aSequence[nIdx] );
- }
-
- }
- }
- break;
-
- case ControlActions::DELETE_ITEM:
- case ControlActions::SET_SELECT_ITEM:
- {
- sal_Int32 nInt;
- if ( rValue >>= nInt )
- {
- aBuffer.append( " " );
- aBuffer.append( nInt );
- }
- }
- break;
-
- default:
- // nothing
- break;
- }
- }
- // TODO else if push button...
-
- sendCommand( aBuffer.makeStringAndClear() );
- }
-}
-
-uno::Any SAL_CALL UnxFilePicker::getValue( sal_Int16 nControlId, sal_Int16 nControlAction )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUString aAction;
-
- if ( controlActionInfo( nControlAction, aAction ) )
- {
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "getValue " );
- aBuffer.append( static_cast< sal_Int32 >( nControlId ) );
- aBuffer.append( " " );
- aBuffer.append( aAction );
-
- sendCommand( aBuffer.makeStringAndClear(),
- m_pCommandThread->getValueCondition() );
-
- return m_pCommandThread->getValue();
- }
-
- return uno::Any();
-}
-
-void SAL_CALL UnxFilePicker::enableControl( sal_Int16 nControlId, sal_Bool bEnable )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "enableControl " );
- aBuffer.append( static_cast< sal_Int32 >( nControlId ) );
- aBuffer.appendAscii( bEnable? " true": " false" );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-void SAL_CALL UnxFilePicker::setLabel( sal_Int16 nControlId, const OUString &rLabel )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "setLabel " );
- aBuffer.append( static_cast< sal_Int32 >( nControlId ) );
- aBuffer.append( " " );
- appendEscaped( aBuffer, rLabel );
-
- sendCommand( aBuffer.makeStringAndClear() );
-}
-
-OUString SAL_CALL UnxFilePicker::getLabel(sal_Int16 /*nControlId*/)
-{
- // FIXME getLabel() is not yet implemented
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- // TODO return m_pImpl->getLabel(nControlId);
- return OUString();
-}
-
-/* TODO
-uno::Sequence<sal_Int16> SAL_CALL UnxFilePicker::getSupportedImageFormats()
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->getSupportedImageFormats();
-}
-
-sal_Int32 SAL_CALL UnxFilePicker::getTargetColorDepth()
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->getTargetColorDepth();
-}
-
-sal_Int32 SAL_CALL UnxFilePicker::getAvailableWidth()
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->getAvailableWidth();
-}
-
-sal_Int32 SAL_CALL UnxFilePicker::getAvailableHeight()
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->getAvailableHeight();
-}
-
-void SAL_CALL UnxFilePicker::setImage( sal_Int16 aImageFormat, const uno::Any &rImage )
- throw( lang::IllegalArgumentException, uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_pImpl->setImage( aImageFormat, aImage );
-}
-
-sal_Bool SAL_CALL UnxFilePicker::setShowState( sal_Bool bShowState )
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->setShowState( bShowState );
-}
-
-sal_Bool SAL_CALL UnxFilePicker::getShowState()
- throw( uno::RuntimeException )
-{
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- return m_pImpl->getShowState();
-}
-*/
-
-void SAL_CALL UnxFilePicker::initialize( const uno::Sequence<uno::Any> &rArguments )
-{
- initFilePicker();
-
- // parameter checking
- uno::Any aAny;
- if ( 0 == rArguments.getLength( ) )
- throw lang::IllegalArgumentException(
- "no arguments",
- static_cast< XFilePicker2* >( this ), 1 );
-
- aAny = rArguments[0];
-
- if ( ( aAny.getValueType() != cppu::UnoType<sal_Int16>::get()) && ( aAny.getValueType() != cppu::UnoType<sal_Int8>::get()) )
- throw lang::IllegalArgumentException(
- "invalid argument type",
- static_cast< XFilePicker2* >( this ), 1 );
-
- sal_Int16 templateId = -1;
- aAny >>= templateId;
-
- OUString aTypeOpen( "setType \"open\"" );
- OUString aTypeSaveAs( "setType \"save\"" );
-
- switch ( templateId )
- {
- case FILEOPEN_SIMPLE:
- sendCommand( aTypeOpen );
- break;
-
- case FILESAVE_SIMPLE:
- sendCommand( aTypeSaveAs );
- break;
-
- case FILESAVE_AUTOEXTENSION_PASSWORD:
- sendCommand( aTypeSaveAs );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD );
- break;
-
- case FILESAVE_AUTOEXTENSION_PASSWORD_FILTEROPTIONS:
- sendCommand( aTypeSaveAs );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PASSWORD );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_FILTEROPTIONS );
- break;
-
- case FILESAVE_AUTOEXTENSION_SELECTION:
- sendCommand( aTypeSaveAs );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_SELECTION );
- break;
-
- case FILESAVE_AUTOEXTENSION_TEMPLATE:
- sendCommand( aTypeSaveAs );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
- sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_TEMPLATE );
- break;
-
- case FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW );
- sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_IMAGE_TEMPLATE );
- break;
-
- case FILEOPEN_PLAY:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY );
- break;
-
- case FILEOPEN_LINK_PLAY:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK );
- sendAppendControlCommand( ExtendedFilePickerElementIds::PUSHBUTTON_PLAY );
- break;
-
- case FILEOPEN_READONLY_VERSION:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_READONLY );
- sendAppendControlCommand( ExtendedFilePickerElementIds::LISTBOX_VERSION );
- break;
-
- case FILEOPEN_LINK_PREVIEW:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_LINK );
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW );
- break;
-
- case FILESAVE_AUTOEXTENSION:
- sendCommand( aTypeSaveAs );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION );
- break;
-
- case FILEOPEN_PREVIEW:
- sendCommand( aTypeOpen );
-
- sendAppendControlCommand( ExtendedFilePickerElementIds::CHECKBOX_PREVIEW );
- break;
-
- default:
- throw lang::IllegalArgumentException(
- "Unknown template",
- static_cast< XFilePicker2* >( this ),
- 1 );
- }
-}
-
-void SAL_CALL UnxFilePicker::cancel()
-{
- // FIXME cancel() is not implemented
- checkFilePicker();
- ::osl::MutexGuard aGuard( m_aMutex );
-
- // TODO m_pImpl->cancel();
-}
-
-void SAL_CALL UnxFilePicker::disposing( const lang::EventObject &rEvent )
-{
- uno::Reference<XFilePickerListener> xFilePickerListener( rEvent.Source, uno::UNO_QUERY );
-
- if ( xFilePickerListener.is() )
- removeFilePickerListener( xFilePickerListener );
-}
-
-OUString SAL_CALL UnxFilePicker::getImplementationName()
-{
- return OUString( FILE_PICKER_IMPL_NAME );
-}
-
-sal_Bool SAL_CALL UnxFilePicker::supportsService( const OUString& ServiceName )
-{
- return cppu::supportsService(this, ServiceName);
-}
-
-uno::Sequence< OUString > SAL_CALL UnxFilePicker::getSupportedServiceNames()
-{
- return FilePicker_getSupportedServiceNames();
-}
-
-void UnxFilePicker::initFilePicker()
-{
- int aFiledesStdin[2], aFiledesStdout[2];
- if ( pipe( aFiledesStdin ) < 0 || pipe( aFiledesStdout ) < 0 )
- return;
-
- m_nFilePickerPid = fork();
- if ( m_nFilePickerPid < 0 )
- return;
-
- if ( m_nFilePickerPid == 0 )
- {
- // Child...
- close( aFiledesStdin[1] ); // write end of the pipe
- dup2( aFiledesStdin[0], 0 );
- close( aFiledesStdin[0] );
-
- close( aFiledesStdout[0] ); // read end of the pipe
- dup2( aFiledesStdout[1], 1 );
- close( aFiledesStdout[1] );
-
-#if OSL_DEBUG_LEVEL == 0
- int nRedirect = open( "/dev/null", O_WRONLY );
- if( nRedirect != -1 )
- {
- dup2( nRedirect, 2 );
- }
-#endif
-
- // The executable name
-#if ENABLE_TDE
- OUString helperurl("${ORIGIN}/tdefilepicker");
-#else // ENABLE_TDE
- OUString helperurl("${ORIGIN}/kdefilepicker");
-#endif // ENABLE_TDE
- rtl::Bootstrap::expandMacros( helperurl );
- OUString helperpath;
- osl::FileBase::getSystemPathFromFileURL( helperurl, helperpath );
- OString helper( OUStringToOString( helperpath, osl_getThreadTextEncoding()));
-
- // ID of the main window
- const int nIdLen = 20;
- char pWinId[nIdLen] = "0";
-
- // TODO pass here the real parent (not possible for system dialogs
- // yet), and default to GetDefDialogParent() only when the real parent
- // is nullptr
- vcl::Window *pParentWin = Application::GetDefDialogParent();
- if ( pParentWin )
- {
- const SystemEnvData* pSysData = pParentWin->GetSystemData();
- if ( pSysData )
- {
- snprintf( pWinId, nIdLen, "%ld", pSysData->aWindow ); // unx only
- pWinId[nIdLen-1] = 0;
- }
- }
-
- // Execute the fpicker implementation
- execlp( helper.getStr(), helper.getStr(), "--winid", pWinId, nullptr );
-
- // Error, finish the child
- exit( -1 );
- }
-
- // Parent continues
- close( aFiledesStdin[0] );
- m_nFilePickerWrite = aFiledesStdin[1];
-
- close( aFiledesStdout[1] );
- m_nFilePickerRead = aFiledesStdout[0];
-
- // Create the notify thread
- if ( !m_pNotifyThread )
- m_pNotifyThread = new UnxFilePickerNotifyThread( this );
-
- // Create the command thread
- if ( !m_pCommandThread )
- m_pCommandThread = new UnxFilePickerCommandThread( m_pNotifyThread, m_nFilePickerRead );
-
- // Start the threads
- m_pNotifyThread->create();
- m_pCommandThread->create();
-
- return;
-}
-
-void UnxFilePicker::checkFilePicker()
-{
- if ( m_nFilePickerPid > 0 )
- {
- // TODO check if external file picker is running
- }
- else
- {
- throw uno::RuntimeException(
- "the external file picker does not run",
- *this );
- }
-}
-
-void UnxFilePicker::sendCommand( const OUString &rCommand )
-{
- if ( m_nFilePickerWrite < 0 )
- return;
-
- OString aUtfString = OUStringToOString( rCommand + "\n", RTL_TEXTENCODING_UTF8 );
-
-#if OSL_DEBUG_LEVEL > 0
- ::std::cerr << "UnxFilePicker sent: \"" << aUtfString.getStr() << "\"" << ::std::endl;
-#endif
-
- (void)write( m_nFilePickerWrite, aUtfString.getStr(), aUtfString.getLength() );
-}
-
-void UnxFilePicker::sendCommand( const OUString &rCommand, ::osl::Condition &rCondition )
-{
- rCondition.reset();
-
- sendCommand( rCommand );
-
- rCondition.wait();
-}
-
-void UnxFilePicker::sendAppendControlCommand( sal_Int16 nControlId )
-{
- OUString aType;
- sal_Int32 nTitleId;
-
- if ( controlIdInfo( nControlId, aType, nTitleId ) )
- {
- OUStringBuffer aBuffer( 1024 );
-
- aBuffer.append( "appendControl " );
- aBuffer.append( static_cast< sal_Int32 >( nControlId ) );
- aBuffer.append( " " );
- appendEscaped( aBuffer, aType );
- aBuffer.append( " " );
- appendEscaped( aBuffer, m_pResMgr? ResId(nTitleId, *m_pResMgr).toString(): OUString() );
-
- sendCommand( aBuffer.makeStringAndClear() );
- }
-}
-
-uno::Sequence< OUString > SAL_CALL UnxFilePicker::getSelectedFiles()
-{
- return getFiles();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxFilePicker.hxx b/vcl/unx/kde/UnxFilePicker.hxx
deleted file mode 100644
index 8d9f2627c07c..000000000000
--- a/vcl/unx/kde/UnxFilePicker.hxx
+++ /dev/null
@@ -1,165 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX
-#define INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX
-
-#include <cppuhelper/compbase.hxx>
-#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
-#include <rtl/ustrbuf.hxx>
-
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ui/dialogs/XFilePicker3.hpp>
-#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-#include <list>
-
-class UnxFilePickerCommandThread;
-class UnxFilePickerNotifyThread;
-class ResMgr;
-
-class UnxFilePickerDummy
-{
-protected:
- osl::Mutex m_aMutex;
- osl::Mutex m_rbHelperMtx;
-};
-
-typedef ::cppu::WeakComponentImplHelper<
- css::ui::dialogs::XFilePicker3,
- css::ui::dialogs::XFilePickerControlAccess,
-// TODO css::ui::dialogs::XFilePreview,
- css::lang::XInitialization,
- css::lang::XServiceInfo > UnxFilePicker_Base;
-
-class UnxFilePicker :
- public UnxFilePickerDummy,
- public UnxFilePicker_Base
-{
-protected:
-
- pid_t m_nFilePickerPid;
- int m_nFilePickerWrite; // (kde|...)filepicker gets it as stdin
- int m_nFilePickerRead; // (kde|...)filepicker gets it as stdout
-
- UnxFilePickerNotifyThread *m_pNotifyThread;
- UnxFilePickerCommandThread *m_pCommandThread;
-
- ResMgr *m_pResMgr;
-
-public:
- explicit UnxFilePicker( const css::uno::Reference< css::uno::XComponentContext >& );
- virtual ~UnxFilePicker() override;
-
- // XComponent
-
- using cppu::WeakComponentImplHelperBase::disposing;
-
- // XFilePickerNotifier
-
- virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override;
- virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener ) override;
-
- // XExecutableDialog functions
-
- virtual void SAL_CALL setTitle( const OUString &rTitle ) override;
- virtual sal_Int16 SAL_CALL execute() override;
-
- // XFilePicker functions
-
- virtual void SAL_CALL setMultiSelectionMode( sal_Bool bMode ) override;
- virtual void SAL_CALL setDefaultName( const OUString &rName ) override;
- virtual void SAL_CALL setDisplayDirectory( const OUString &rDirectory ) override;
- virtual OUString SAL_CALL getDisplayDirectory() override;
- virtual css::uno::Sequence< OUString > SAL_CALL getFiles() override;
-
- // XFilterManager functions
-
- virtual void SAL_CALL appendFilter( const OUString &rTitle, const OUString &rFilter ) override;
- virtual void SAL_CALL setCurrentFilter( const OUString &rTitle ) override;
- virtual OUString SAL_CALL getCurrentFilter() override;
-
- // XFilterGroupManager functions
-
- virtual void SAL_CALL appendFilterGroup( const OUString &rGroupTitle, const css::uno::Sequence< css::beans::StringPair > &rFilters ) override;
-
- // XFilePickerControlAccess functions
-
- virtual void SAL_CALL setValue( sal_Int16 nControlId, sal_Int16 nControlAction, const css::uno::Any &rValue ) override;
- virtual css::uno::Any SAL_CALL getValue( sal_Int16 nControlId, sal_Int16 nControlAction ) override;
- virtual void SAL_CALL enableControl( sal_Int16 nControlId, sal_Bool bEnable ) override;
- virtual void SAL_CALL setLabel( sal_Int16 nControlId, const OUString &rLabel ) override;
- virtual OUString SAL_CALL getLabel( sal_Int16 nControlId ) override;
-
- /* TODO XFilePreview
-
- virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedImageFormats( ) throw (css::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getTargetColorDepth( ) throw (css::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getAvailableWidth( ) throw (css::uno::RuntimeException);
- virtual sal_Int32 SAL_CALL getAvailableHeight( ) throw (css::uno::RuntimeException);
- virtual void SAL_CALL setImage( sal_Int16 aImageFormat, const css::uno::Any &rImage ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL setShowState( sal_Bool bShowState ) throw (css::uno::RuntimeException);
- virtual sal_Bool SAL_CALL getShowState( ) throw (css::uno::RuntimeException);
- */
-
- // XFilePicker2
-
- virtual css::uno::Sequence< OUString > SAL_CALL getSelectedFiles() override;
-
- // XInitialization
-
- virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any > &rArguments ) override;
-
- // XCancellable
-
- virtual void SAL_CALL cancel( ) override;
-
- // XEventListener
-
- virtual void SAL_CALL disposing( const css::lang::EventObject &rEvent );
-
- // XServiceInfo
-
- virtual OUString SAL_CALL getImplementationName() override;
- virtual sal_Bool SAL_CALL supportsService( const OUString &rServiceName ) override;
- virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
-
-private:
- UnxFilePicker( const UnxFilePicker& ) = delete;
- UnxFilePicker& operator=( const UnxFilePicker& ) = delete;
-
-protected:
- void initFilePicker();
- void checkFilePicker();
-
- // Async sendCommand
- void sendCommand( const OUString &rCommand );
- // Synchronized sendCommand
- void sendCommand( const OUString &rCommand, ::osl::Condition &rCondition );
-
-private:
- void sendAppendControlCommand( sal_Int16 nControlId );
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_UNXFILEPICKER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxNotifyThread.cxx b/vcl/unx/kde/UnxNotifyThread.cxx
deleted file mode 100644
index 583fae056486..000000000000
--- a/vcl/unx/kde/UnxNotifyThread.cxx
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <UnxNotifyThread.hxx>
-#include <UnxFilePicker.hxx>
-
-using namespace ::com::sun::star;
-
-// UnxFilePickerNotifyThread
-
-UnxFilePickerNotifyThread::UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker )
- : m_pUnxFilePicker( pUnxFilePicker ),
- m_bExit( false ),
- m_eNotifyType( Nothing ),
- m_nControlId( 0 )
-{
-}
-
-void SAL_CALL UnxFilePickerNotifyThread::addFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& xListener )
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_xListener = xListener;
-}
-
-void SAL_CALL UnxFilePickerNotifyThread::removeFilePickerListener( const uno::Reference< ui::dialogs::XFilePickerListener >& /*xListener*/ )
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_xListener.clear();
-}
-
-void SAL_CALL UnxFilePickerNotifyThread::exit()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_bExit = true;
-
- m_aExitCondition.reset();
- m_aNotifyCondition.set();
-
- m_aExitCondition.wait();
-}
-
-void SAL_CALL UnxFilePickerNotifyThread::fileSelectionChanged()
-{
- ::osl::MutexGuard aGuard( m_aMutex );
-
- m_eNotifyType = FileSelectionChanged;
- m_nControlId = 0;
-
- m_aNotifyCondition.set();
-}
-
-void SAL_CALL UnxFilePickerNotifyThread::run()
-{
- osl_setThreadName("UnxFilePickerNotifyThread");
-
- do {
- m_aNotifyCondition.reset();
- m_aNotifyCondition.wait();
-
- if ( m_xListener.is() && m_pUnxFilePicker )
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- ui::dialogs::FilePickerEvent aEvent( *m_pUnxFilePicker, m_nControlId );
-
- switch ( m_eNotifyType )
- {
- case FileSelectionChanged:
- m_xListener->fileSelectionChanged( aEvent );
- break;
-
- // TODO More to come...
-
- default:
- // nothing
- break;
- }
- }
- } while ( !m_bExit );
-
- m_aExitCondition.set();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/UnxNotifyThread.hxx b/vcl/unx/kde/UnxNotifyThread.hxx
deleted file mode 100644
index ca029d756a62..000000000000
--- a/vcl/unx/kde/UnxNotifyThread.hxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX
-#define INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX
-
-#include <com/sun/star/ui/dialogs/XFilePickerListener.hpp>
-#include <com/sun/star/uno/Reference.hxx>
-
-#include <osl/conditn.hxx>
-#include <osl/mutex.hxx>
-#include <osl/thread.hxx>
-
-class UnxFilePicker;
-
-class UnxFilePickerNotifyThread : public ::osl::Thread
-{
-protected:
- enum NotifyType
- {
- Nothing = 0,
- FileSelectionChanged
- // TODO More to come...
- };
-
- UnxFilePicker *m_pUnxFilePicker;
-
- ::osl::Mutex m_aMutex;
-
- css::uno::Reference< css::ui::dialogs::XFilePickerListener > m_xListener;
-
- bool m_bExit;
- ::osl::Condition m_aExitCondition;
-
- NotifyType m_eNotifyType;
- ::osl::Condition m_aNotifyCondition;
- sal_Int16 m_nControlId;
-
-public:
- UnxFilePickerNotifyThread( UnxFilePicker *pUnxFilePicker );
-
- virtual void SAL_CALL addFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener );
- virtual void SAL_CALL removeFilePickerListener( const css::uno::Reference< css::ui::dialogs::XFilePickerListener >& xListener );
-
- void SAL_CALL exit();
-
- void SAL_CALL fileSelectionChanged();
- /* TODO
- void SAL_CALL directoryChanged( css::ui::dialogs::FilePickerEvent aEvent );
- OUString SAL_CALL helpRequested( css::ui::dialogs::FilePickerEvent aEvent ) const;
- void SAL_CALL controlStateChanged( css::ui::dialogs::FilePickerEvent aEvent );
- void SAL_CALL dialogSizeChanged( );
- */
-
-protected:
- virtual void SAL_CALL run() override;
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_UNXNOTIFYTHREAD_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdecommandthread.cxx b/vcl/unx/kde/fpicker/kdecommandthread.cxx
deleted file mode 100644
index 241f5a8996ab..000000000000
--- a/vcl/unx/kde/fpicker/kdecommandthread.cxx
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cstddef>
-
-#include <kdecommandthread.hxx>
-
-#include <config_vclplug.h>
-
-#if ENABLE_TDE
-#include <tqstringlist.h>
-#include <tdeapplication.h>
-#else // ENABLE_TDE
-#include <qstringlist.h>
-#include <kapplication.h>
-#endif // ENABLE_TDE
-
-#if OSL_DEBUG_LEVEL > 1
-#include <iostream>
-#endif
-
-// CommandEvent
-
-KDECommandEvent::KDECommandEvent( const QString &qCommand, QStringList *pStringList )
- : QCustomEvent( TypeId, pStringList ),
- m_eCommand( Unknown )
-{
- struct {
- const char *pName;
- CommandEventType eType;
- } *pIdx, pMapping[] =
- {
- { "appendControl", AppendControl },
- { "enableControl", EnableControl },
- { "getValue", GetValue },
- { "setValue", SetValue },
- { "appendFilter", AppendFilter },
- { "appendFilterGroup", AppendFilterGroup },
- { "getCurrentFilter", GetCurrentFilter },
- { "setCurrentFilter", SetCurrentFilter },
- { "getDirectory", GetDirectory },
- { "setDirectory", SetDirectory },
- { "getFiles", GetFiles },
- { "getSelectedFiles", GetSelectedFiles },
- { "setTitle", SetTitle },
- { "setType", SetType },
- { "setDefaultName", SetDefaultName },
- { "setMultiSelection", SetMultiSelection },
- { "exec", Exec },
- { nullptr, Unknown }
- };
-
- for ( pIdx = pMapping; pIdx->pName && qCommand != pIdx->pName; ++pIdx )
- ;
-
- m_eCommand = pIdx->eType;
-}
-
-// CommandThread
-
-namespace {
-
-QStringList* tokenize( const QString &rString )
-{
- // Commands look like:
- // command arg1 arg2 arg3 ...
- // Args may be enclosed in '"', if they contain spaces.
-
- QStringList *pList = new QStringList();
-
- QString qBuffer;
- qBuffer.reserve( 1024 );
-
- const QChar *pUnicode = rString.unicode();
- const QChar *pEnd = pUnicode + rString.length();
- bool bQuoted = false;
-
- for ( ; pUnicode != pEnd; ++pUnicode )
- {
- if ( *pUnicode == '\\' )
- {
- ++pUnicode;
- if ( pUnicode != pEnd )
- {
- if ( *pUnicode == 'n' )
- qBuffer.append( '\n' );
- else
- qBuffer.append( *pUnicode );
- }
- }
- else if ( *pUnicode == '"' )
- bQuoted = !bQuoted;
- else if ( *pUnicode == ' ' && !bQuoted )
- {
- pList->push_back( qBuffer );
- qBuffer.setLength( 0 );
- }
- else
- qBuffer.append( *pUnicode );
- }
- pList->push_back( qBuffer );
-
- return pList;
-}
-
-}
-
-KDECommandThread::KDECommandThread( QWidget *pObject )
- : m_pObject( pObject )
-{
-}
-
-KDECommandThread::~KDECommandThread()
-{
-}
-
-void KDECommandThread::run()
-{
- QTextIStream qStream( stdin );
- qStream.setEncoding( QTextStream::UnicodeUTF8 );
-
- QString qLine;
- bool bQuit = false;
- while ( !bQuit && !qStream.atEnd() )
- {
- qLine = qStream.readLine();
- handleCommand( qLine, bQuit );
- }
-}
-
-void KDECommandThread::handleCommand( const QString &rString, bool &bQuit )
-{
- QMutexLocker qMutexLocker( &m_aMutex );
-
-#if OSL_DEBUG_LEVEL > 1
- ::std::cerr << "kdefilepicker received: " << rString.latin1() << ::std::endl;
-#endif
-
- bQuit = false;
- QStringList *pTokens = tokenize( rString );
-
- if ( !pTokens )
- return;
- if ( pTokens->empty() )
- {
- delete pTokens; pTokens = nullptr;
- return;
- }
-
- QString qCommand = pTokens->front();
- pTokens->pop_front();
-#if OSL_DEBUG_LEVEL > 1
- ::std::cerr << "kdefilepicker first command: " << qCommand.latin1() << ::std::endl;
-#endif
-
- if ( qCommand == "exit" )
- {
- bQuit = true;
- QApplication::exit();
- kapp->wakeUpGuiThread();
-#if OSL_DEBUG_LEVEL > 1
- ::std::cerr << "kdefilepicker: exiting" << ::std::endl;
-#endif
- }
- else
- QApplication::postEvent( m_pObject, new KDECommandEvent( qCommand, pTokens ) );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdecommandthread.hxx b/vcl/unx/kde/fpicker/kdecommandthread.hxx
deleted file mode 100644
index 374d74a4f1cb..000000000000
--- a/vcl/unx/kde/fpicker/kdecommandthread.hxx
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX
-#define INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX
-
-#include <sal/config.h>
-
-#include <config_vclplug.h>
-#include <sal/types.h>
-
-#if ENABLE_TDE
-#include <shell/tde_defines.h>
-#endif // ENABLE_TDE
-
-#if ENABLE_TDE
-#include <tqevent.h>
-#include <tqmutex.h>
-#include <tqthread.h>
-#else // ENABLE_TDE
-#include <qevent.h>
-#include <qmutex.h>
-#include <qthread.h>
-#endif // ENABLE_TDE
-
-class KDECommandEvent : public QCustomEvent
-{
-public:
- enum CommandEventType {
- Unknown = 0,
-
- AppendControl,
- EnableControl,
- GetValue,
- SetValue,
-
- AppendFilter,
- AppendFilterGroup,
- UpdateFilters,
- GetCurrentFilter,
- SetCurrentFilter,
-
- GetDirectory,
- SetDirectory,
-
- GetFiles,
- GetSelectedFiles,
-
- SetTitle,
- SetType,
- SetDefaultName,
- SetMultiSelection,
-
- Exec
- };
- static const QEvent::Type TypeId = (QEvent::Type) ( (int) QEvent::User + 42 /*random magic value*/ );
-
-protected:
- CommandEventType m_eCommand;
-
-public:
- KDECommandEvent( const QString &qCommand, QStringList *pStringList );
-
- CommandEventType command() const { return m_eCommand; }
- QStringList* stringList() { return static_cast< QStringList* >( data() ); }
-};
-
-class KDECommandThread : public QThread
-{
-protected:
- QObject *m_pObject;
-
- QMutex m_aMutex;
-
-public:
- KDECommandThread( QWidget *pObject );
- virtual ~KDECommandThread() override;
-
- virtual void run() override;
-
-protected:
- void handleCommand( const QString &rString, bool &bQuit );
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDECOMMANDTHREAD_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdefilepicker.cxx b/vcl/unx/kde/fpicker/kdefilepicker.cxx
deleted file mode 100644
index 1f7b7d693d39..000000000000
--- a/vcl/unx/kde/fpicker/kdefilepicker.cxx
+++ /dev/null
@@ -1,806 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cstddef>
-
-#include <kdecommandthread.hxx>
-#include <kdefilepicker.hxx>
-
-#include <config_vclplug.h>
-
-#if ENABLE_TDE
-
-#include <tqcheckbox.h>
-#include <tqcombobox.h>
-#include <tqgrid.h>
-#include <tqhbox.h>
-#include <tqlabel.h>
-#include <tqlayout.h>
-#include <tqobjectlist.h>
-#include <tqpushbutton.h>
-#include <tqregexp.h>
-#include <tqvbox.h>
-
-#ifdef TQT_NO_EMIT
-#define emit
-#endif
-
-#include <tdeversion.h>
-#include <tdediroperator.h>
-#include <tdefiledialog.h>
-#include <tdefilefiltercombo.h>
-#include <tdeio/netaccess.h>
-#include <tdelocale.h>
-#include <tdemessagebox.h>
-#include <tdetempfile.h>
-
-#else // ENABLE_TDE
-
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qgrid.h>
-#include <qhbox.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qobjectlist.h>
-#include <qpushbutton.h>
-#include <qregexp.h>
-#include <qvbox.h>
-
-#ifdef QT_NO_EMIT
-#define emit
-#endif
-
-#include <kdeversion.h>
-#include <kdiroperator.h>
-#include <kfiledialog.h>
-#include <kfilefiltercombo.h>
-#include <kio/netaccess.h>
-#include <klocale.h>
-#include <kmessagebox.h>
-#include <ktempfile.h>
-
-#endif // ENABLE_TDE
-
-#if ENABLE_TDE
-#define QCheckBox_String "TQCheckBox"
-#define QComboBox_String "TQComboBox"
-#else // ENABLE_TDE
-#define QCheckBox_String "QCheckBox"
-#define QComboBox_String "QComboBox"
-#endif // ENABLE_TDE
-
-#include <algorithm>
-#include <iostream>
-
-namespace {
-
-bool isSupportedProtocol( const QString &rProtocol )
-{
- // TODO Get this information directly from OOo
- const char * pOOoProtocols[] = { "", "smb", "ftp", "http", "file", "mailto",
- "vnd.sun.star.webdav", "vnd.sun.star.webdavs", "news", "private", "vnd.sun.star.help",
- "https", "slot", "macro", "javascript", "imap", "pop3", "data",
- "cid", "out", "vnd.sun.star.hier", "vim",
- ".uno", ".component", "vnd.sun.star.pkg", "ldap", "db",
- "vnd.sun.star.cmd", "vnd.sun.star.script",
- "telnet",
- nullptr };
-
- for ( const char **pIndex = pOOoProtocols; *pIndex != nullptr; ++pIndex )
- {
- if ( rProtocol == *pIndex )
- return true;
- }
-
- // TODO gnome-vfs bits here
-
- return false;
-}
-
-void sendCommand( const QString &rCommand )
-{
-#if OSL_DEBUG_LEVEL > 1
- ::std::cerr << "kdefilepicker sent: " << rCommand.latin1() << ::std::endl;
-#endif
-
- //m_aOutputStream << rCommand << endl;
- ::std::cout << rCommand.utf8() << ::std::endl;
-}
-
-void appendEscaped( QString &rBuffer, const QString &rString )
-{
- const QChar *pUnicode = rString.unicode();
- const QChar *pEnd = pUnicode + rString.length();
-
- rBuffer.append( '"' );
- for ( ; pUnicode != pEnd; ++pUnicode )
- {
- if ( *pUnicode == '\\' )
- rBuffer.append( "\\\\" );
- else if ( *pUnicode == '"' )
- rBuffer.append( "\\\"" );
- else if ( *pUnicode == '\n' )
- rBuffer.append( "\\\n" );
- else
- rBuffer.append( *pUnicode );
- }
- rBuffer.append( '"' );
-}
-
-QString escapeString( const QString &rString )
-{
- QString qString;
- qString.reserve( 2*rString.length() + 2 ); // every char escaped + quotes
-
- appendEscaped( qString, rString );
-
- return qString;
-}
-
-}
-
-// KDEFileDialog
-
-KDEFileDialog::KDEFileDialog( const QString &startDir, const QString &filter,
- QWidget *parent, const char *name )
- : KFileDialog( startDir, filter, parent, name, true, m_pCustomWidget = new QVBox() ),
- m_pCombosAndButtons( new QHBox( m_pCustomWidget ) ),
- m_pLabels( new QVBox( m_pCombosAndButtons ) ),
- m_pComboBoxes( new QVBox( m_pCombosAndButtons ) ),
- m_pPushButtons( new QVBox( m_pCombosAndButtons ) ),
- m_pCheckBoxes( new QGrid( 2, m_pCustomWidget ) ),
- m_bIsSave( false ),
- m_bIsExecuting( false ),
- m_bCanNotifySelection( true )
-{
-#if ENABLE_TDE
- connect( this, SIGNAL( fileHighlighted( const TQString & ) ),
- this, SLOT( fileHighlightedCommand( const TQString & ) ) );
-#else // ENABLE_TDE
- connect( this, SIGNAL( fileHighlighted( const QString & ) ),
- this, SLOT( fileHighlightedCommand( const QString & ) ) );
-#endif // ENABLE_TDE
-
- connect( this, SIGNAL( selectionChanged() ),
- this, SLOT( selectionChangedCommand() ) );
-
- m_pCustomWidget->setSpacing( KDialog::spacingHint() );
- m_pCombosAndButtons->setSpacing( KDialog::spacingHint() );
-
- updateCustomWidgetLayout();
-}
-
-KDEFileDialog::~KDEFileDialog()
-{
-}
-
-void KDEFileDialog::resizeEvent( QResizeEvent *pEvent )
-{
- KFileDialog::resizeEvent( pEvent );
-
- updateCustomWidgetLayout();
-}
-
-void KDEFileDialog::showEvent( QShowEvent *pEvent )
-{
- KFileDialog::showEvent( pEvent );
-
- updateCustomWidgetLayout();
-}
-
-void KDEFileDialog::updateCustomWidgetLayout()
-{
- QPoint qReferencePoint = filterWidget->mapTo( this, QPoint( 0, 0 ) );
- QPoint qCustomPoint = m_pCustomWidget->mapTo( this, QPoint( 0, 0 ) );
-
- int nLeft = qReferencePoint.x() - qCustomPoint.x();
- int nRight = m_pCustomWidget->width() - filterWidget->width() - nLeft;
-
- nLeft -= KDialog::spacingHint();
- nRight -= KDialog::spacingHint();
- m_pLabels->setFixedWidth( ( nLeft > 0 )? nLeft: 80 );
- // FIXME The following call sets the width of m_pPushButtons all right,
- // but it also increases the width of m_pComboBoxes rapidly. Can we do
- // anything about it?
- m_pPushButtons->setFixedWidth( ( nRight > 0 )? nRight: 100 );
-}
-
-void KDEFileDialog::customEvent( QCustomEvent *pEvent )
-{
- if ( pEvent && pEvent->type() == KDECommandEvent::TypeId )
- {
- KDECommandEvent *pCommandEvent = static_cast< KDECommandEvent* >( pEvent );
- QStringList *pStringList = pCommandEvent->stringList();
-
- int nListSize = -1;
- if ( pStringList )
- nListSize = pStringList->size();
-
- switch ( pCommandEvent->command() )
- {
- case KDECommandEvent::AppendControl:
- if ( nListSize >= 3 )
- {
- appendControl( (*pStringList)[0], (*pStringList)[1], (*pStringList)[2] );
- }
- break;
- case KDECommandEvent::EnableControl:
- if ( nListSize >= 2 )
- {
- enableControl( (*pStringList)[0], (*pStringList)[1] );
- }
- break;
- case KDECommandEvent::GetValue:
- if ( nListSize >= 2 )
- {
- getValue( (*pStringList)[0], (*pStringList)[1] );
- }
- break;
- case KDECommandEvent::SetValue:
- if ( nListSize >= 2 )
- {
- QStringList qStringList = (*pStringList);
- qStringList.pop_front();
- qStringList.pop_front();
-
- setValue( (*pStringList)[0], (*pStringList)[1], qStringList );
- }
- break;
- case KDECommandEvent::AppendFilter:
- if ( nListSize >= 2 )
- {
- appendFilter( (*pStringList)[0], (*pStringList)[1] );
-
- // update the filters widget
- setFilter( filters() );
- }
- break;
- case KDECommandEvent::AppendFilterGroup:
- if ( nListSize >= 1 )
- {
- QStringList::const_iterator it = pStringList->begin();
- ++it; // We ignore the filter group name
-
- while ( it != pStringList->end() )
- {
- QString qTitle = *it;
- ++it;
- if ( it != pStringList->end() )
- {
- appendFilter( qTitle, (*it) );
- ++it;
- }
- }
-
- // update the filters widget
- setFilter( filters() );
- }
- break;
- case KDECommandEvent::GetCurrentFilter:
- {
- QString qCurrentFilter = filterWidget->currentText();
- sendCommand( "currentFilter " + escapeString( qCurrentFilter ) );
- }
- break;
- case KDECommandEvent::SetCurrentFilter:
- if ( nListSize >= 1 )
- {
- static_cast< KDEFileFilterComboHack* >( filterWidget )->setCurrentFilter( pStringList->front() );
- }
- break;
- case KDECommandEvent::GetDirectory:
- {
- QString qDirectory = baseURL().url();
- if ( qDirectory.startsWith( "file:/" ) && qDirectory.mid( 6, 1 ) != "/" )
- qDirectory.replace( "file:/", "file:///" );
- sendCommand( "currentDirectory " + escapeString( qDirectory ) );
- }
- break;
- case KDECommandEvent::SetDirectory:
- if ( nListSize >= 1 )
- {
- setURL( pStringList->front() );
- }
- break;
- case KDECommandEvent::GetFiles:
- {
- QString qString;
- qString.reserve( 1024 );
-
- qString.append( "files" );
-
- if ( result() == QDialog::Accepted )
- {
- KURL::List qList( selectedURLs() );
- for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it )
- {
- appendURL( qString, (*it) );
- break; // we just want the first element
- }
- }
- else
- {
- // we have to return the selected files anyway
- const KFileItemList *pItems = ops->selectedItems();
- for ( KFileItemListIterator it( *pItems ); it.current(); ++it )
- {
- appendURL( qString, (*it)->url() );
- break; // we just want the first element
- }
- }
-
- sendCommand( qString );
- setCanNotifySelection( true );
- }
- break;
- case KDECommandEvent::GetSelectedFiles:
- {
- QString qString;
- qString.reserve( 1024 );
-
- qString.append( "files" );
-
- if ( result() == QDialog::Accepted )
- {
- KURL::List qList( selectedURLs() );
- for ( KURL::List::const_iterator it = qList.begin(); it != qList.end(); ++it )
- appendURL( qString, (*it) );
- }
- else
- {
- // we have to return the selected files anyway
- const KFileItemList *pItems = ops->selectedItems();
- for ( KFileItemListIterator it( *pItems ); it.current(); ++it )
- appendURL( qString, (*it)->url() );
- }
-
- sendCommand( qString );
- setCanNotifySelection( true );
- }
- break;
- case KDECommandEvent::SetTitle:
- if ( nListSize >= 1 )
- {
- setCaption( pStringList->front() );
- }
- break;
- case KDECommandEvent::SetType:
- if ( nListSize >= 1 )
- {
- QString qType( pStringList->front() );
- if ( qType == "open" )
- {
- setIsSave( false );
- setCaption( i18n( "Open" ) );
- }
- else if ( qType == "save" )
- {
- setIsSave( true );
- setCaption( i18n( "Save As" ) );
- }
- }
- break;
- case KDECommandEvent::SetDefaultName:
- if ( nListSize >= 1 )
- {
- setKeepLocation( true );
- setSelection( pStringList->front() );
- }
- break;
- case KDECommandEvent::SetMultiSelection:
- if ( nListSize >= 1 )
- {
- if ( pStringList->front() == "true" )
- setMode( KFile::Files );
- else
- setMode( KFile::File );
- }
- break;
- case KDECommandEvent::Exec:
- {
- filterWidget->setEditable( false );
- setIsExecuting( true );
- bool bCanExit = false;
- do {
- setCanNotifySelection( true );
- exec();
-
- KURL qLocalSelectedURL = mostLocalURL( selectedURL() );
- QString qProtocol( qLocalSelectedURL.protocol() );
-
- if ( isSave() && result() == QDialog::Accepted )
- {
- if ( qProtocol == "file" )
- {
- QString qFileName( addExtension( qLocalSelectedURL.path() ) );
- bCanExit =
- !QFile::exists( qFileName ) ||
- ( KMessageBox::warningYesNo( nullptr,
- i18n( "A file named \"%1\" already exists. "
- "Are you sure you want to overwrite it?" ).arg( qFileName ),
- i18n( "Overwrite File?" ),
- i18n( "Overwrite" ), KStdGuiItem::cancel() ) == KMessageBox::Yes );
- }
- else if ( !isSupportedProtocol( qProtocol ) )
- {
- KMessageBox::sorry( nullptr,
- i18n( "Saving using protocol \"%1\" is not supported." ).arg( qProtocol ) );
- bCanExit = false;
- }
- else
- bCanExit = true;
- }
- else if ( !isSave() && result() == QDialog::Accepted && !isSupportedProtocol( qProtocol ) )
- {
- KMessageBox::information( nullptr,
- i18n( "Protocol \"%1\" is supported only partially. "
- "Local copy of the file will be created." ).arg( qProtocol ) );
- bCanExit = true;
- }
- else
- bCanExit = true;
- } while ( !bCanExit );
- setIsExecuting( false );
-
- if ( result() == QDialog::Accepted )
- sendCommand( "accept" );
- else
- sendCommand( "reject" );
- }
- break;
- default:
- break;
- }
-
- // FIXME Some cleanup of pEvent? delete something, etc.?
- }
-}
-
-void KDEFileDialog::appendControl( const QString &rId, const QString &rType, const QString &rTitle )
-{
- QString qLabel( rTitle );
- qLabel.replace( '~', '&' );
-
- if ( rType == "checkbox" )
- {
- QCheckBox *pCheckBox = new QCheckBox( qLabel, m_pCheckBoxes, rId.utf8() );
-
- pCheckBox->setEnabled( true );
- pCheckBox->setChecked( false );
- }
- else if ( rType == "listbox" )
- {
- QLabel *pComboLabel = new QLabel( qLabel, m_pLabels );
- QComboBox *pComboBox = new QComboBox( m_pComboBoxes, rId.utf8() );
-
- pComboLabel->setBuddy( pComboBox );
- pComboBox->setEnabled( true );
- }
- else if ( rType == "pushbutton" )
- {
- QPushButton *pPushButton = new QPushButton( qLabel, m_pPushButtons, rId.utf8() );
- pPushButton->setEnabled( true );
- }
-}
-
-QWidget* KDEFileDialog::findControl( const QString &rId ) const
-{
- QObjectList *pList = m_pCustomWidget->queryList();
- QCString qName( rId.utf8() );
- QObjectList::const_iterator it = pList->begin();
-
- for ( ; it != pList->end() && qName != (*it)->name(); ++it )
- ;
-
- QWidget *pWidget = nullptr;
- if ( it != pList->end() )
- pWidget = static_cast< QWidget* >( *it );
-
- delete pList;
-
- return pWidget;
-}
-
-void KDEFileDialog::enableControl( const QString &rId, const QString &rValue )
-{
- QWidget *pWidget = findControl( rId );
-
- if ( pWidget )
- pWidget->setEnabled( rValue.lower() == "true" );
-}
-
-void KDEFileDialog::getValue( const QString &rId, const QString &rAction )
-{
- QWidget *pWidget = findControl( rId );
- QString qString;
- qString.reserve( 1024 );
- qString.append( "value" );
-
- if ( pWidget )
- {
- QCString qClassName = pWidget->className();
- if ( qClassName == QCheckBox_String )
- {
- QCheckBox *pCheckBox = static_cast< QCheckBox* >( pWidget );
-
- if ( pCheckBox->isChecked() )
- qString.append( " bool true" );
- else
- qString.append( " bool false" );
- }
- else if ( qClassName == QComboBox_String )
- {
- QComboBox *pComboBox = static_cast< QComboBox* >( pWidget );
- if ( rAction == "getItems" )
- {
- qString.append( " stringList" );
- for ( int nIdx = 0; nIdx < pComboBox->count(); ++nIdx )
- {
- qString.append( ' ' );
- appendEscaped( qString, pComboBox->text( nIdx ) );
- }
- }
- else if ( rAction == "getSelectedItem" )
- {
- qString.append( " string " );
- appendEscaped( qString, pComboBox->currentText() );
- }
- else if ( rAction == "getSelectedItemIndex" )
- {
- qString.append( " int " );
- qString.append( QString().setNum( pComboBox->currentItem() ) );
- }
- // TODO getHelpURL
- }
- // TODO push button
- }
-
- sendCommand( qString );
-}
-
-void KDEFileDialog::setValue( const QString &rId, const QString &rAction, const QStringList &rValue )
-{
- QWidget *pWidget = findControl( rId );
-
- if ( pWidget )
- {
- QCString qClassName = pWidget->className();
- if ( qClassName == QCheckBox_String )
- {
- QCheckBox *pCheckBox = static_cast< QCheckBox* >( pWidget );
-
- bool bValue = ( !rValue.isEmpty() ) && ( rValue.front().lower() == "true" );
- pCheckBox->setChecked( bValue );
- }
- else if ( qClassName == QComboBox_String )
- {
- QComboBox *pComboBox = static_cast< QComboBox* >( pWidget );
- if ( rAction == "addItem" )
- {
- if ( !rValue.isEmpty() )
- pComboBox->insertItem( rValue.front() );
- }
- else if ( rAction == "addItems" )
- {
- pComboBox->insertStringList( rValue );
- }
- else if ( rAction == "deleteItem" )
- {
- if ( !rValue.isEmpty() )
- pComboBox->removeItem( rValue.front().toInt() );
- }
- else if ( rAction == "deleteItems" )
- {
- pComboBox->clear();
- }
- else if ( rAction == "setSelectedItem" )
- {
- if ( !rValue.isEmpty() )
- pComboBox->setCurrentItem( rValue.front().toInt() );
- }
- // FIXME setHelpURL is ignored
- }
- // TODO push button
- }
-}
-
-void KDEFileDialog::appendFilter( const QString &rTitle, const QString &rFilter )
-{
- // Filters are separated by ';'
- QString qFilter( rFilter );
- qFilter.replace( QChar( ';' ), QChar( ' ' ) ).replace( "*.*", "*" );
-
- // Workaround for too wide <All formats> (*.bmp;...) entry
- QString qTitle( rTitle );
- qTitle.replace( QRegExp( "^<([^>]*)> \\(.*" ), "<\\1>" );
-
- m_aFilters.push_back( qMakePair( qTitle, qFilter ) );
-}
-
-QString KDEFileDialog::filters() const
-{
- QString qString, qTmp;
- bool bFirstFilter = true;
-
- for ( FilterList::const_iterator it = m_aFilters.begin(); it != m_aFilters.end(); ++it )
- {
- if ( bFirstFilter )
- bFirstFilter = false;
- else
- qString.append( '\n' );
-
- qString.append( (*it).second );
- qString.append( '|' );
-
- qTmp = (*it).first;
- qString.append( qTmp.replace( '/', "\\/" ) );
- }
-
- return qString;
-}
-
-QString KDEFileDialog::addExtension( const QString &rFileName ) const
-{
- if ( !isSave() )
- return rFileName;
-
- QString qExtension;
-
- QWidget *pExtensionWidget = findControl( "100" ); // CHECKBOX_AUTOEXTENSION
- QCheckBox *pExtensionCB = pExtensionWidget? static_cast< QCheckBox* >( pExtensionWidget->qt_cast( QCheckBox_String ) ): nullptr;
- if ( pExtensionCB && pExtensionCB->isChecked() )
- {
- // FIXME: qFilter can be a MIME; we ignore it now...
- QStringList qFilterList = QStringList::split( " ", currentFilter() );
- for ( QStringList::const_iterator it = qFilterList.begin();
- qExtension.isEmpty() && it != qFilterList.end();
- ++it )
- {
- int nUnwanted = (*it).findRev( '*' );
- if ( nUnwanted < 0 )
- nUnwanted = (*it).findRev( '?' );
- else
- nUnwanted = ::std::max( nUnwanted, (*it).find( '?', nUnwanted ) );
-
- int nIdx = (*it).find( '.', ::std::max( nUnwanted, 0 ) );
- if ( nIdx >= 0 )
- qExtension = (*it).mid( nIdx ).lower();
- }
- }
-
- if ( qExtension.isEmpty() || qExtension == "." || rFileName.endsWith( qExtension ) )
- return rFileName;
- else
- return rFileName + qExtension;
-}
-
-KURL KDEFileDialog::mostLocalURL( const KURL &rURL ) const
-{
-#if KDE_IS_VERSION(3,5,0)
- KURL qMostLocalURL( KIO::NetAccess::mostLocalURL( rURL, const_cast<KDEFileDialog*>( this ) ) );
- if ( qMostLocalURL.isLocalFile() )
- return qMostLocalURL;
- else
- {
- // Terrible hack to get even non-existing media:// files right
- qMostLocalURL.cd( ".." );
- KURL qMostLocalPath( KIO::NetAccess::mostLocalURL( qMostLocalURL, const_cast<KDEFileDialog*>( this ) ) );
- if ( qMostLocalPath.isLocalFile() )
- {
- qMostLocalPath.addPath( rURL.fileName() );
- return qMostLocalPath;
- }
- }
-#endif
-
- return rURL;
-}
-
-QString KDEFileDialog::localCopy( const QString &rFileName ) const
-{
- // 106 == MIB enum for UTF-8
- KURL qLocalURL = mostLocalURL( KURL( rFileName, 106 ) );
- if ( qLocalURL.isLocalFile() )
- return qLocalURL.url();
-
- int nExtensionPos = rFileName.findRev( '/' );
- if ( nExtensionPos >= 0 )
- nExtensionPos = rFileName.find( '.', nExtensionPos );
- else
- nExtensionPos = rFileName.find( '.' );
-
- KTempFile qTempFile( QString::null, ( nExtensionPos < 0 )? QString(): rFileName.mid( nExtensionPos ) );
- KURL qDestURL;
- qDestURL.setPath( qTempFile.name() );
-
- if ( !KIO::NetAccess::file_copy( rFileName, qDestURL, 0600, true ) )
- {
- KMessageBox::error( nullptr, KIO::NetAccess::lastErrorString() );
- return QString::null;
- }
-
- return qDestURL.url();
-}
-
-#if ENABLE_TDE
-void KDEFileDialog::fileHighlightedCommand( const TQString & )
-#else // ENABLE_TDE
-void KDEFileDialog::fileHighlightedCommand( const QString & )
-#endif // ENABLE_TDE
-{
- if ( canNotifySelection() )
- {
- sendCommand( "fileSelectionChanged" );
- setCanNotifySelection( false );
- }
-}
-
-void KDEFileDialog::selectionChangedCommand()
-{
- if ( canNotifySelection() )
- {
- sendCommand( "fileSelectionChanged" );
- setCanNotifySelection( false );
- }
-}
-
-void KDEFileDialog::appendURL( QString &rBuffer, const KURL &rURL )
-{
- // From Martin Kretzschmar:
- // file:///path/to/test%E0.odt is not a valid URL from OOo's point of
- // view. (?Most modern parts of?) OOo assume(s) that the URL contains only
- // ASCII characters (which test%E0.odt does) and is UTF-8 after unescaping
- // (which file:///path/test%E0.odt is not).
- // Cf. the comment in sal/inc/osl/file.h.
- // 106 == MIB enum for UTF-8
- QString qUrlStr = addExtension( rURL.url( 0, 106 ) );
-
- if ( !isExecuting() && !isSupportedProtocol( rURL.protocol() ) )
- qUrlStr = localCopy( qUrlStr );
-
- if ( qUrlStr.startsWith( "file:/" ) && qUrlStr.mid( 6, 1 ) != "/" )
- qUrlStr.replace( "file:/", "file:///" );
-
- rBuffer.append( " " );
- if ( !qUrlStr.isEmpty() )
- appendEscaped( rBuffer, qUrlStr );
-}
-
-void KDEFileFilterComboHack::setCurrentFilter( const QString& filter )
-{
- setCurrentText( filter );
- filterChanged();
-
- // Workaround for 'Filter name (*.blah)' vs. 'Filter name'
- if ( currentText() != text( currentItem() ) )
- {
- int nItem = 0;
- for ( ; nItem < count() && !text( nItem ).startsWith( filter ); ++nItem );
-
- if ( nItem < count() )
- setCurrentItem( nItem );
- else
- setCurrentItem( 0 );
-
- filterChanged();
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdefilepicker.hxx b/vcl/unx/kde/fpicker/kdefilepicker.hxx
deleted file mode 100644
index 630b4278811c..000000000000
--- a/vcl/unx/kde/fpicker/kdefilepicker.hxx
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX
-#define INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX
-
-#include <sal/config.h>
-
-#include <config_vclplug.h>
-#include <sal/types.h>
-
-#if ENABLE_TDE
-#include <shell/tde_defines.h>
-#endif // ENABLE_TDE
-
-#include <cstddef>
-
-#if ENABLE_TDE
-#include <tdefiledialog.h>
-#include <tdefilefiltercombo.h>
-#else // ENABLE_TDE
-#include <kfiledialog.h>
-#include <kfilefiltercombo.h>
-#endif // ENABLE_TDE
-
-class QGrid;
-class QHBox;
-class QVBox;
-
-class KDEFileDialog : public KFileDialog
-{
-#if ENABLE_TDE
- TQ_OBJECT
-#else // ENABLE_TDE
- Q_OBJECT
-#endif // ENABLE_TDE
-
-protected:
- typedef QPair< QString, QString > FilterEntry;
- typedef QValueList< FilterEntry > FilterList;
-
- QVBox *m_pCustomWidget;
- QHBox *m_pCombosAndButtons;
-
- QVBox *m_pLabels;
- QVBox *m_pComboBoxes;
- QVBox *m_pPushButtons;
-
- QGrid *m_pCheckBoxes;
-
- FilterList m_aFilters;
-
- /** Are we a "Save As" dialog?
- *
- * We cannot use KFileDialog::setOperationMode() here, because then
- * it automatically adds an "Automatically select filename extension"
- * check box, and completely destroys the dialog's layout
- * (custom list boxes are under this check box, which looks ugly).
- */
- bool m_bIsSave;
- bool m_bIsExecuting;
-
- bool m_bCanNotifySelection;
-
-public:
- KDEFileDialog( const QString &startDir, const QString &filter,
- QWidget *parent, const char *name );
- virtual ~KDEFileDialog() override;
-
-protected:
- virtual void resizeEvent( QResizeEvent *pEvent ) override;
- virtual void showEvent( QShowEvent *pEvent ) override;
- void updateCustomWidgetLayout();
-
- virtual void customEvent( QCustomEvent *pEvent ) override;
-
-protected:
- void appendControl( const QString &rId, const QString &rType, const QString &rTitle );
- QWidget* findControl( const QString &rId ) const;
- void enableControl( const QString &rId, const QString &rValue );
- void getValue( const QString &rId, const QString &rAction );
- void setValue( const QString &rId, const QString &rAction, const QStringList &rValue );
-
- void appendFilter( const QString &rTitle, const QString &rFilter );
- QString filters() const;
- QString addExtension( const QString &rFileName ) const;
-
- void setIsSave( bool bIsSave ) { m_bIsSave = bIsSave; }
- bool isSave() const { return m_bIsSave; }
-
- void setIsExecuting( bool bIsExecuting ) { m_bIsExecuting = bIsExecuting; }
- bool isExecuting() const { return m_bIsExecuting; }
-
- KURL mostLocalURL( const KURL &rURL ) const;
- QString localCopy( const QString &rFileName ) const;
-
- void setCanNotifySelection( bool bCanNotifySelection ) { m_bCanNotifySelection = bCanNotifySelection; }
- bool canNotifySelection() const { return m_bCanNotifySelection; }
-
-protected slots:
-// Qt3 moc does not really understand #ifdef and would process both slots,
-// so the FILTER_OUT_FOO tags are used to remove some slots before moc sees them.
-#if ENABLE_TDE
- void fileHighlightedCommand( const TQString & ); // FILTER_OUT_TDE
-#else // ENABLE_TDE
- void fileHighlightedCommand( const QString & ); // FILTER_OUT_KDE
-#endif // ENABLE_TDE
- void selectionChangedCommand();
-
-protected:
- void appendURL( QString &rBuffer, const KURL &rURL );
-};
-
-class KDEFileFilterComboHack : public KFileFilterCombo
-{
-public:
- void setCurrentFilter( const QString& filter );
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDEFILEPICKER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdefpmain.cxx b/vcl/unx/kde/fpicker/kdefpmain.cxx
deleted file mode 100644
index 0031ae0e92bf..000000000000
--- a/vcl/unx/kde/fpicker/kdefpmain.cxx
+++ /dev/null
@@ -1,109 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cstddef>
-
-#include <kdemodalityfilter.hxx>
-#include <kdefilepicker.hxx>
-#include <kdecommandthread.hxx>
-
-#if ENABLE_TDE
-#include <tqeventloop.h>
-#include <tdeaboutdata.h>
-#include <tdeapplication.h>
-#include <tdecmdlineargs.h>
-#else // ENABLE_TDE
-#include <kaboutdata.h>
-#include <kapplication.h>
-#include <kcmdlineargs.h>
-#endif // ENABLE_TDE
-
-#include <iostream>
-#include <stdlib.h>
-
-#include <config_vclplug.h>
-
-#if ENABLE_TDE
-#define THIS_DESKENV_NAME_CAP "TDE"
-#define THIS_DESKENV_NAME_LOW "tde"
-#else // ENABLE_TDE
-#define THIS_DESKENV_NAME_CAP "KDE"
-#define THIS_DESKENV_NAME_LOW "kde"
-#endif // ENABLE_TDE
-
-#if ENABLE_TDE
-#define KAboutData TDEAboutData
-#define KCmdLineArgs TDECmdLineArgs
-#define KCmdLineOptions TDECmdLineOptions
-#define KCmdLineLastOption TDECmdLineLastOption
-#define KApplication TDEApplication
-#define KLocale TDELocale
-#endif // ENABLE_TDE
-
-// Main
-
-static const KCmdLineOptions sOptions[] =
-{
- { "winid <argument>", I18N_NOOP("Window ID to which is the fpicker modal"), "0" },
- KCmdLineLastOption
-};
-
-int main( int argc, char* argv[] )
-{
- // we fake the name of the application to have "LibreOffice" in the
- // title
- KAboutData qAboutData( "kdefilepicker", I18N_NOOP( "LibreOffice" ),
- "0.1", I18N_NOOP( "kdefilepicker is an implementation of the " THIS_DESKENV_NAME_CAP " file dialog for LibreOffice." ),
- KAboutData::License_LGPL,
- "(c) 2004, Jan Holesovsky" );
- qAboutData.addAuthor( "Jan Holesovsky", I18N_NOOP("Original author"), "kendy@collabora.com" );
-
- // Let the user see that this does something...
- ::std::cerr << "kdefilepicker, an implementation of a " THIS_DESKENV_NAME_CAP " file dialog for OOo." << ::std::endl
- << "Type 'exit' and press Enter to finish." << ::std::endl;
-
- KCmdLineArgs::addCmdLineOptions( sOptions );
- KCmdLineArgs::init( argc, argv, &qAboutData );
-
- KLocale::setMainCatalogue( "kdialog" );
-
- KApplication kApplication;
-
- // Setup the modality
- KCmdLineArgs *pArgs = KCmdLineArgs::parsedArgs();
- long nWinId = atol( pArgs->getOption( "winid" ) );
- pArgs->clear();
-
- KDEModalityFilter qModalityFilter( nWinId );
-
- KDEFileDialog aFileDialog( nullptr, QString(), nullptr, THIS_DESKENV_NAME_LOW "filedialog" );
-
- KDECommandThread qCommandThread( &aFileDialog );
- qCommandThread.start();
-
- kApplication.exec();
-
- qCommandThread.wait();
-
- ::std::cout << "exited" << ::std::endl;
-
- return 0;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdemodalityfilter.cxx b/vcl/unx/kde/fpicker/kdemodalityfilter.cxx
deleted file mode 100644
index 007369353f54..000000000000
--- a/vcl/unx/kde/fpicker/kdemodalityfilter.cxx
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <cstddef>
-
-#include <kdemodalityfilter.hxx>
-#include <kdialogbase.h>
-
-#if ENABLE_TDE
-# include <tdeapplication.h>
-#else // ENABLE_TDE
-# include <kapplication.h>
-#endif // ENABLE_TDE
-
-#include <netwm.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-
-// Modality filter
-
-KDEModalityFilter::KDEModalityFilter( WId nWinId )
- : m_nWinId( nWinId )
-{
- kapp->installEventFilter( this );
-}
-
-KDEModalityFilter::~KDEModalityFilter()
-{
- kapp->removeEventFilter( this );
-}
-
-bool KDEModalityFilter::eventFilter( QObject *pObject, QEvent *pEvent )
-{
- if ( pObject->isWidgetType() && pEvent->type() == QEvent::Show )
- {
- KDialogBase* pDlg = ::qt_cast< KDialogBase* >( pObject );
- if ( pDlg != nullptr && m_nWinId != 0 )
- {
- XSetTransientForHint( qt_xdisplay(), pDlg->winId(), m_nWinId );
- m_nWinId = 0;
- }
- }
- return false;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/fpicker/kdemodalityfilter.hxx b/vcl/unx/kde/fpicker/kdemodalityfilter.hxx
deleted file mode 100644
index 4f068e3dea43..000000000000
--- a/vcl/unx/kde/fpicker/kdemodalityfilter.hxx
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX
-#define INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX
-
-#include <sal/config.h>
-
-#include <config_vclplug.h>
-#include <sal/types.h>
-
-#if ENABLE_TDE
-#include <shell/tde_defines.h>
-#endif // ENABLE_TDE
-
-#if ENABLE_TDE
-#include <tqobject.h>
-#else // ENABLE_TDE
-#include <qobject.h>
-#endif // ENABLE_TDE
-
-class KDEModalityFilter : public QObject
-{
-private:
- WId m_nWinId;
-
-public:
- KDEModalityFilter( WId nWinId );
- virtual ~KDEModalityFilter() override;
-
- virtual bool eventFilter( QObject *pObject, QEvent *pEvent ) override;
-};
-
-#endif // INCLUDED_VCL_UNX_KDE_FPICKER_KDEMODALITYFILTER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/kdedata.cxx b/vcl/unx/kde/kdedata.cxx
deleted file mode 100644
index 71955f5a764c..000000000000
--- a/vcl/unx/kde/kdedata.cxx
+++ /dev/null
@@ -1,238 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <shell/kde_headers.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <poll.h>
-#ifdef FREEBSD
-#include <sys/types.h>
-#include <sys/time.h>
-#endif
-
-#include <osl/thread.h>
-#include <osl/process.h>
-#include <osl/mutex.hxx>
-
-#include "unx/kde/kdedata.hxx"
-#include "unx/i18n_im.hxx"
-#include "unx/i18n_xkb.hxx"
-
-#include "vclpluginapi.h"
-
-#include <config_vclplug.h>
-
-/* #i59042# override KApplications method for session management
- * since it will interfere badly with our own.
- */
-class VCLKDEApplication : public KApplication
-{
- public:
- VCLKDEApplication() : KApplication() {}
-
- virtual void commitData(QSessionManager &sm) override;
-};
-
-void VCLKDEApplication::commitData(QSessionManager&)
-{
-}
-
-/***************************************************************************
- * class SalKDEDisplay *
- ***************************************************************************/
-
-SalKDEDisplay::SalKDEDisplay( Display* pDisp )
- : SalX11Display( pDisp )
-{
-}
-
-SalKDEDisplay::~SalKDEDisplay()
-{
- // in case never a frame opened
- static_cast<KDEXLib*>(GetXLib())->doStartup();
- // clean up own members
- doDestruct();
- // prevent SalDisplay from closing KApplication's display
- pDisp_ = nullptr;
-}
-
-/***************************************************************************
- * class KDEXLib *
- ***************************************************************************/
-
-KDEXLib::~KDEXLib()
-{
- // on 64 bit linux using libXRandr.so.2 will crash in
- // XCloseDisplay when freeing extension data
- // no known work around, therefore currently leak. Hopefully
- // this does not make problems since we're shutting down anyway
- // should we ever get a real kde plugin that uses the KDE event loop
- // we should use kde's method to signal screen changes similar
- // to the gtk plugin
- #if ! defined USE_RANDR || ! (defined LINUX && defined X86_64)
- // properly deinitialize KApplication
- delete static_cast<VCLKDEApplication*>(m_pApplication);
- #endif
- // free the faked cmdline arguments no longer needed by KApplication
- for( int i = 0; i < m_nFakeCmdLineArgs; i++ )
- free( m_pFreeCmdLineArgs[i] );
- delete [] m_pFreeCmdLineArgs;
- delete [] m_pAppCmdLineArgs;
-}
-
-void KDEXLib::Init()
-{
- m_pInputMethod = new SalI18N_InputMethod;
- m_pInputMethod->SetLocale();
- XrmInitialize();
-
- KAboutData *kAboutData = new KAboutData( "LibreOffice",
- I18N_NOOP( "LibreOffice" ),
- "3.4.0",
- I18N_NOOP( "LibreOffice with KDE Native Widget Support." ),
- KAboutData::License_File,
- I18N_NOOP( "Copyright (C) 2000, 2014 LibreOffice contributors" ),
- I18N_NOOP( "LibreOffice is an office suite.\n" ),
- "http://libreoffice.org",
- "libreoffice@lists.freedesktop.org");
- kAboutData->addAuthor( "Jan Holesovsky",
- I18N_NOOP( "Original author and maintainer of the KDE NWF." ),
- "kendy@artax.karlin.mff.cuni.cz",
- "http://artax.karlin.mff.cuni.cz/~kendy" );
-
- m_nFakeCmdLineArgs = 1;
- sal_uInt16 nIdx;
- int nParams = osl_getCommandArgCount();
- OString aDisplay;
- OUString aParam, aBin;
-
- for ( nIdx = 0; nIdx < nParams; ++nIdx )
- {
- osl_getCommandArg( nIdx, &aParam.pData );
- if ( !m_pFreeCmdLineArgs && aParam == "-display" && nIdx + 1 < nParams )
- {
- osl_getCommandArg( nIdx + 1, &aParam.pData );
- aDisplay = OUStringToOString( aParam, osl_getThreadTextEncoding() );
-
- m_nFakeCmdLineArgs = 3;
- m_pFreeCmdLineArgs = new char*[ m_nFakeCmdLineArgs ];
- m_pFreeCmdLineArgs[ 1 ] = strdup( "-display" );
- m_pFreeCmdLineArgs[ 2 ] = strdup( aDisplay.getStr() );
- }
- }
- if ( !m_pFreeCmdLineArgs )
- m_pFreeCmdLineArgs = new char*[ m_nFakeCmdLineArgs ];
-
- osl_getExecutableFile( &aParam.pData );
- osl_getSystemPathFromFileURL( aParam.pData, &aBin.pData );
- OString aExec = OUStringToOString( aBin, osl_getThreadTextEncoding() );
- m_pFreeCmdLineArgs[0] = strdup( aExec.getStr() );
-
- // make a copy of the string list for freeing it since
- // KApplication manipulates the pointers inside the argument vector
- // note: KApplication bad !
- m_pAppCmdLineArgs = new char*[ m_nFakeCmdLineArgs ];
- for( int i = 0; i < m_nFakeCmdLineArgs; i++ )
- m_pAppCmdLineArgs[i] = m_pFreeCmdLineArgs[i];
-
- KCmdLineArgs::init( m_nFakeCmdLineArgs, m_pAppCmdLineArgs, kAboutData );
-
- KApplication::disableAutoDcopRegistration();
- m_pApplication = new VCLKDEApplication();
- kapp->disableSessionManagement();
-
- m_pDisplay = QPaintDevice::x11AppDisplay();
-}
-
-void KDEXLib::doStartup()
-{
- if( ! m_bStartupDone )
- {
- KStartupInfo::appStarted();
- m_bStartupDone = true;
- SAL_INFO( "vcl.kde", "called KStartupInfo::appStarted()" );
- }
-}
-
-/**********************************************************************
- * class KDEData *
- **********************************************************************/
-
-KDEData::~KDEData()
-{
-}
-
-void KDEData::Init()
-{
- pXLib_ = new KDEXLib();
- pXLib_->Init();
-}
-
-/**********************************************************************
- * plugin entry point *
- **********************************************************************/
-
-extern "C" {
- VCLPLUG_KDE_PUBLIC SalInstance* create_SalInstance()
- {
- /* #i92121# workaround deadlocks in the X11 implementation
- */
- static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
- /* #i90094#
- from now on we know that an X connection will be
- established, so protect X against itself
- */
- if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
- XInitThreads();
-
- OString aVersion( qVersion() );
- SAL_INFO( "vcl.kde", "qt version string is \"" << aVersion << "\"" );
-
- sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0, nMicro = 0;
- nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
- if( nIndex > 0 )
- nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
- if( nIndex > 0 )
- nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
- if( nMajor != 3 || nMinor < 2 || (nMinor == 2 && nMicro < 2) )
- {
- SAL_INFO( "vcl.kde", "unsuitable qt version " << nMajor << "." << nMinor << "." << nMicro );
- return nullptr;
- }
-
- KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
- SAL_INFO( "vcl.kde", "created KDESalInstance " << &pInstance );
-
- // initialize SalData
- KDEData *pSalData = new KDEData( pInstance );
- pSalData->Init();
- pInstance->SetLib( pSalData->GetLib() );
- pSalData->initNWF();
-
- return pInstance;
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx
deleted file mode 100644
index d829edaf70b3..000000000000
--- a/vcl/unx/kde/salnativewidgets-kde.cxx
+++ /dev/null
@@ -1,2097 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <shell/kde_headers.h>
-
-#include "UnxFilePicker.hxx"
-
-#include <unx/salunx.h>
-#include <unx/saldata.hxx>
-#include <unx/saldisp.hxx>
-#include <unx/salgdi.h>
-#include <unx/kde/kdedata.hxx>
-#include "unx/pixmap.hxx"
-#include <unx/i18n_im.hxx>
-
-#include <vcl/settings.hxx>
-#include "unx/fontmanager.hxx"
-#include <vcl/vclenum.hxx>
-#include <rtl/ustrbuf.hxx>
-
-#include <config_vclplug.h>
-
-#include <boost/optional.hpp>
-
-#if ENABLE_TDE
-#define QPushButton_String "TQPushButton"
-#define QRadioButton_String "TQRadioButton"
-#define QCheckBox_String "TQCheckBox"
-#define QComboBox_String "TQComboBox"
-#define QLineEdit_String "TQLineEdit"
-#define QSpinWidget_String "TQSpinWidget"
-#define QTabBar_String "TQTabBar"
-#define QTabWidget_String "TQTabWidget"
-#define QListView_String "TQListView"
-#define QScrollBar_String "TQScrollBar"
-#define QMotifPlusStyle_String "TQMotifPlusStyle"
-#define QSGIStyle_String "TQSGIStyle"
-#define QToolBar_String "TQToolBar"
-#define QToolButton_String "TQToolButton"
-#define QMenuBar_String "TQMenuBar"
-#define QPopupMenu_String "TQPopupMenu"
-#define QProgressBar_String "TQProgressBar"
-#define QMotifStyle_String "TQMotifStyle"
-#define QWindowsStyle_String "TQWindowsStyle"
-#else // ENABLE_TDE
-#define QPushButton_String "QPushButton"
-#define QRadioButton_String "QRadioButton"
-#define QCheckBox_String "QCheckBox"
-#define QComboBox_String "QComboBox"
-#define QLineEdit_String "QLineEdit"
-#define QSpinWidget_String "QSpinWidget"
-#define QTabBar_String "QTabBar"
-#define QTabWidget_String "QTabWidget"
-#define QListView_String "QListView"
-#define QScrollBar_String "QScrollBar"
-#define QMotifPlusStyle_String "QMotifPlusStyle"
-#define QSGIStyle_String "QSGIStyle"
-#define QToolBar_String "QToolBar"
-#define QToolButton_String "QToolButton"
-#define QMenuBar_String "QMenuBar"
-#define QPopupMenu_String "QPopupMenu"
-#define QProgressBar_String "QProgressBar"
-#define QMotifStyle_String "QMotifStyle"
-#define QWindowsStyle_String "QWindowsStyle"
-#endif // ENABLE_TDE
-
-using namespace ::com::sun::star;
-
-namespace {
-
-/** Style conversion function.
-
- Conversion function between VCL ControlState together with ImplControlValue
- and Qt state flags.
-
- @param nState
- State of the widget (default, focused, ...) as defined in Native Widget
- Framework.
-
- @param aValue
- Value held by the widget (on, off, ...)
-*/
-QStyle::SFlags vclStateValue2SFlags( ControlState nState,
- const ImplControlValue& aValue )
-{
- QStyle::SFlags nStyle =
- ( (nState & ControlState::DEFAULT)? QStyle::Style_ButtonDefault: QStyle::Style_Default ) |
- ( (nState & ControlState::ENABLED)? QStyle::Style_Enabled: QStyle::Style_Default ) |
- ( (nState & ControlState::FOCUSED)? QStyle::Style_HasFocus: QStyle::Style_Default ) |
- ( (nState & ControlState::PRESSED)? QStyle::Style_Down: QStyle::Style_Raised ) |
- ( (nState & ControlState::SELECTED)? QStyle::Style_Selected : QStyle::Style_Default ) |
- ( (nState & ControlState::ROLLOVER)? QStyle::Style_MouseOver: QStyle::Style_Default );
-
- switch ( aValue.getTristateVal() )
- {
- case ButtonValue::On: nStyle |= QStyle::Style_On; break;
- case ButtonValue::Off: nStyle |= QStyle::Style_Off; break;
- case ButtonValue::Mixed: nStyle |= QStyle::Style_NoChange; break;
- default: break;
- }
-
- return nStyle;
-}
-
-}
-
-/** Qt implementation of X11Pixmap
-
- Wrapper around a QPixmap.
- */
-
-class KDEX11Pixmap : public X11Pixmap
-{
-public:
- KDEX11Pixmap( int nWidth, int nHeight );
-
- virtual int GetDepth() const override;
- virtual SalX11Screen GetScreen() const override;
- virtual Pixmap GetPixmap() const override;
- QPixmap GetQPixmap() const;
-
-protected:
- QPixmap mqPixmap;
-};
-
-KDEX11Pixmap::KDEX11Pixmap( int nWidth, int nHeight )
-: X11Pixmap( nWidth, nHeight )
-, mqPixmap( nWidth, nHeight )
-{
-}
-
-int KDEX11Pixmap::GetDepth() const
-{
- return mqPixmap.x11Depth();
-}
-
-SalX11Screen KDEX11Pixmap::GetScreen() const
-{
- return SalX11Screen( mqPixmap.x11Screen() );
-}
-
-Pixmap KDEX11Pixmap::GetPixmap() const
-{
- return mqPixmap.handle();
-}
-
-QPixmap KDEX11Pixmap::GetQPixmap() const
-{
- return mqPixmap;
-}
-
-
-/** Cached native widgets.
-
- A class which caches and paints the native widgets.
-*/
-class WidgetPainter
-{
- protected:
- /** Cached push button.
-
- It is necessary for the QStyle::drawControl(). The buttons are created
- on demand and they are still hidden (no QWidget::show() is called).
- */
- QPushButton *m_pPushButton;
-
- /** Cached radio button.
-
- @see m_pPushButton
- */
- QRadioButton *m_pRadioButton;
-
- /** Cached check box.
-
- @see m_pPushButton
- */
- QCheckBox *m_pCheckBox;
-
- /** Cached combo box.
-
- @see m_pPushButton
- */
- QComboBox *m_pComboBox;
-
- /** Cached editable combo box.
-
- Needed, because some styles do not like dynamic changes
- (QComboBox::setEditable()).
-
- @see m_pPushButton
- */
- QComboBox *m_pEditableComboBox;
-
- /** Cached line edit box.
-
- @see m_pPushButton
- */
- QLineEdit *m_pLineEdit;
-
- /** Cached spin box.
-
- @see m_pPushButton
- */
- QSpinWidget *m_pSpinWidget;
-
- /** Cached spin box'es line edit.
-
- @see m_pPushButton
- */
- QLineEdit *m_pSpinEdit;
-
- /** Cached tab.
-
- Left, middle, right tab and a tab which is alone.
-
- @see m_pPushButton
- */
- QTab *m_pTabLeft, *m_pTabMiddle, *m_pTabRight, *m_pTabAlone;
-
- /** Cached tab bar's parent widget.
-
- Needed, because the Qt windows style checks for the availability
- of tab bar's parent. We cannot use m_pTabWidget, because
- TabWidget::setTabBar() and TabWidget::tabBar() methods are
- protected.
-
- @see m_pPushButton, m_pTabWidget
- */
- QWidget *m_pTabBarParent;
-
- /** Cached tab bar widget.
-
- @see m_pPushButton
- */
- QTabBar *m_pTabBar;
-
- /** Cached tab widget.
-
- We need it to draw the tab page. It cannot be used to draw the
- tabs themselves, because the drawing has to be tweaked a little
- due to not enough information from VCL.
-
- @see m_pPushButton, m_pTabBarParent
- */
- QTabWidget *m_pTabWidget;
-
- /** Cached list view.
-
- @see m_pPushButton
- */
- QListView *m_pListView;
-
- /** Cached scroll bar.
-
- @see m_pPushButton
- */
- QScrollBar *m_pScrollBar;
-
- /** Cached dock area. Needed for proper functionality of tool bars.
-
- @see m_pPushButton
- */
- QMainWindow *m_pMainWindow;
-
- /** Cached tool bar.
-
- @see m_pPushButton
- */
- QToolBar *m_pToolBarHoriz, *m_pToolBarVert;
-
- /** Cached tool button.
-
- @see m_pPushButton
- */
- QToolButton *m_pToolButton;
-
- /** Cached menu bar.
-
- @see m_pPushButton
- */
- QMenuBar *m_pMenuBar;
-
- /** Identifiers of menu bar items.
- */
- int m_nMenuBarEnabledItem, m_nMenuBarDisabledItem;
-
- /** Cached popup menu.
-
- @see m_pPushButton
- */
- QPopupMenu *m_pPopupMenu;
-
- /** Identifiers of popup menu items.
- */
- int m_nPopupMenuEnabledItem, m_nPopupMenuDisabledItem;
-
- /** cached progress bar
- */
- QProgressBar *m_pProgressBar;
-
- // TODO other widgets
-
- public:
- /** Implicit constructor.
-
- It creates an empty WidgetPainter with all the cached widgets initialized
- to nullptr. The widgets are created on demand and they are still hidden
- (no QWidget::show()), because they are needed just as a parameter for
- QStyle::drawControl().
-
- @see m_pPushButton
- */
- WidgetPainter();
-
- /** Destructor.
-
- Destruct all the cached widgets.
- */
- virtual ~WidgetPainter();
-
- /** Paints the specified widget to the X window.
-
- Use X calls to bitblt (bit block transfer) the widget qWidget to
- the window specified by drawable with the style defined by nStyle.
-
- @param qWidget
- A pointer to the cached widget.
-
- @param nState
- The state of the control (focused, on/off, ...)
-
- @param aValue
- The value (true/false, ...)
-
- @param pGraphics
- The SalGraphics instance to read/write screen.
- */
- bool drawStyledWidget( QWidget *pWidget,
- ControlState nState, const ImplControlValue& aValue,
- X11SalGraphics* pGraphics,
- ControlPart nPart = ControlPart::Entire );
-
- /** 'Get' method for push button.
-
- The method returns the cached push button. It is constructed if it
- does not exist. It has nullptr as a parent and it stays hidden, but it
- is necessary for the drawStyledWidget() method.
-
- @return valid push button.
- */
- QPushButton *pushButton( const tools::Rectangle& rControlRegion, bool bDefault );
-
- /** 'Get' method for radio button.
-
- @see pushButton()
- */
- QRadioButton *radioButton( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for check box.
-
- @see pushButton()
- */
- QCheckBox *checkBox( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for combo box.
-
- It returns m_pComboBox or m_pEditableComboBox according to
- bEditable.
-
- @see pushButton(), m_pEditableComboBox
- */
- QComboBox *comboBox( const tools::Rectangle& rControlRegion, bool bEditable );
-
- /** 'Get' method for line edit box.
-
- @see pushButton()
- */
- QLineEdit *lineEdit( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for spin box.
-
- @see pushButton()
- */
- QSpinWidget *spinWidget( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for tab bar.
-
- @see pushButton()
- */
- QTabBar *tabBar( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for tab widget.
-
- @see pushButton()
- */
- QTabWidget *tabWidget( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for list view.
-
- @see pushButton()
- */
- QListView *listView( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for scroll bar.
-
- @see pushButton()
- */
- QScrollBar *scrollBar( const tools::Rectangle& rControlRegion,
- bool bHorizontal, const ImplControlValue& aValue );
-
- /** 'Get' method for tool bar.
-
- @see pushButton()
- */
- QToolBar *toolBar( const tools::Rectangle& rControlRegion, bool bHorizontal );
-
- /** 'Get' method for tool button.
-
- @see pushButton()
- */
- QToolButton *toolButton( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for menu bar.
-
- @see pushButton()
- */
- QMenuBar *menuBar( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for popup menu.
-
- @see pushButton()
- */
- QPopupMenu *popupMenu( const tools::Rectangle& rControlRegion );
-
- /** 'Get' method for progress bar
-
- @see pushButton()
- */
- QProgressBar *progressBar( const tools::Rectangle& rControlRegion );
-
- // TODO other widgets
-
- public:
- /** Convert tools::Rectangle to QRect.
-
- @param rControlRegion
- The region to convert.
-
- @return
- The bounding box of the region.
- */
- static QRect region2QRect( const tools::Rectangle& rControlRegion );
-};
-
-WidgetPainter::WidgetPainter()
- : m_pPushButton( nullptr ),
- m_pRadioButton( nullptr ),
- m_pCheckBox( nullptr ),
- m_pComboBox( nullptr ),
- m_pEditableComboBox( nullptr ),
- m_pLineEdit( nullptr ),
- m_pSpinWidget( nullptr ),
- m_pSpinEdit( nullptr ),
- m_pTabLeft( nullptr ),
- m_pTabMiddle( nullptr ),
- m_pTabRight( nullptr ),
- m_pTabAlone( nullptr ),
- m_pTabBarParent( nullptr ),
- m_pTabBar( nullptr ),
- m_pTabWidget( nullptr ),
- m_pListView( nullptr ),
- m_pScrollBar( nullptr ),
- m_pMainWindow( nullptr ),
- m_pToolBarHoriz( nullptr ),
- m_pToolBarVert( nullptr ),
- m_pToolButton( nullptr ),
- m_pMenuBar( nullptr ),
- m_nMenuBarEnabledItem( 0 ),
- m_nMenuBarDisabledItem( 0 ),
- m_pPopupMenu( nullptr ),
- m_nPopupMenuEnabledItem( 0 ),
- m_nPopupMenuDisabledItem( 0 ),
- m_pProgressBar( nullptr )
-{
-}
-
-WidgetPainter::~WidgetPainter()
-{
- delete m_pPushButton; m_pPushButton = nullptr;
- delete m_pRadioButton; m_pRadioButton = nullptr;
- delete m_pCheckBox; m_pCheckBox = nullptr;
- delete m_pComboBox; m_pComboBox = nullptr;
- delete m_pEditableComboBox; m_pEditableComboBox = nullptr;
- delete m_pLineEdit; m_pLineEdit = nullptr;
- delete m_pSpinWidget; m_pSpinWidget = nullptr;
- m_pSpinEdit = nullptr; // Deleted in m_pSpinWidget's destructor
- delete m_pTabAlone; m_pTabAlone = nullptr;
- delete m_pTabBarParent; m_pTabBarParent = nullptr;
- m_pTabBar = nullptr; // Deleted in m_pTabBarParent's destructor
- m_pTabLeft = nullptr;
- m_pTabMiddle = nullptr;
- m_pTabRight = nullptr;
- delete m_pTabWidget; m_pTabWidget = nullptr;
- delete m_pListView; m_pListView = nullptr;
- delete m_pScrollBar; m_pScrollBar = nullptr;
- delete m_pToolBarHoriz; m_pToolBarHoriz = nullptr;
- delete m_pToolBarVert; m_pToolBarVert = nullptr;
- delete m_pMainWindow; m_pMainWindow = nullptr;
- delete m_pToolButton; m_pToolButton = nullptr;
- delete m_pMenuBar; m_pMenuBar = nullptr;
- delete m_pPopupMenu; m_pPopupMenu = nullptr;
- delete m_pProgressBar; m_pProgressBar = nullptr;
-}
-
-bool WidgetPainter::drawStyledWidget( QWidget *pWidget,
- ControlState nState, const ImplControlValue& aValue,
- X11SalGraphics* pGraphics, ControlPart nPart )
-{
- if ( !pWidget )
- return false;
-
- // Normalize the widget
- QPoint qWidgetPos( pWidget->pos() );
- pWidget->move( 0, 0 );
-
- // Enable/disable the widget
- pWidget->setEnabled( bool(nState & ControlState::ENABLED) );
-
- // Create pixmap to paint to
- KDEX11Pixmap xPixmap( pWidget->width(), pWidget->height() );
- QPixmap qPixmap( xPixmap.GetQPixmap() );
- QPainter qPainter( &qPixmap );
- QRect qRect( 0, 0, pWidget->width(), pWidget->height() );
-
- // Use the background of the widget
- qPixmap.fill( pWidget, QPoint(0, 0) );
-
- // Convert the flags
- QStyle::SFlags nStyle = vclStateValue2SFlags( nState, aValue );
-
- // Store the widget class
- const char *pClassName = pWidget->className();
-
- // Draw the widget to the pixmap
- if ( strcmp( QPushButton_String, pClassName ) == 0 )
- {
- // Workaround for the Platinum style.
- // Platinum takes the state directly from the widget, not from SFlags.
- QPushButton *pPushButton = static_cast<QPushButton *>( pWidget->qt_cast( QPushButton_String ) );
- if ( pPushButton )
- {
- pPushButton->setDown ( nStyle & QStyle::Style_Down );
- pPushButton->setOn ( nStyle & QStyle::Style_On );
- pPushButton->setEnabled( nStyle & QStyle::Style_Enabled );
- }
-
- QApplication::style().drawControl( QStyle::CE_PushButton,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else if ( strcmp( QRadioButton_String, pClassName ) == 0 )
- {
- // Bitblt from the screen, because the radio buttons are usually not
- // rectangular, and there could be a bitmap under them
- pGraphics->FillPixmapFromScreen( &xPixmap, qWidgetPos.x(), qWidgetPos.y() );
-
- QApplication::style().drawControl( QStyle::CE_RadioButton,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else if ( strcmp( QCheckBox_String, pClassName ) == 0 )
- {
- QApplication::style().drawControl( QStyle::CE_CheckBox,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else if ( strcmp( QComboBox_String, pClassName ) == 0 )
- {
- QApplication::style().drawComplexControl( QStyle::CC_ComboBox,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
-
- // Editable combo box uses the background of the associated edit box
- QComboBox *pComboBox = static_cast<QComboBox *>( pWidget->qt_cast( QComboBox_String ) );
- if ( pComboBox && pComboBox->editable() && pComboBox->lineEdit() )
- {
- QColorGroup::ColorRole eColorRole = ( pComboBox->isEnabled() )?
- QColorGroup::Base: QColorGroup::Background;
- qPainter.fillRect(
- QApplication::style().querySubControlMetrics( QStyle::CC_ComboBox,
- pComboBox, QStyle::SC_ComboBoxEditField ),
- pComboBox->lineEdit()->colorGroup().brush( eColorRole ) );
- }
- }
- else if ( strcmp( QLineEdit_String, pClassName ) == 0 )
- {
- QApplication::style().drawPrimitive( QStyle::PE_PanelLineEdit,
- &qPainter, qRect,
- pWidget->colorGroup(), nStyle | QStyle::Style_Sunken );
- }
- else if ( strcmp( QSpinWidget_String, pClassName ) == 0 )
- {
- const SpinbuttonValue* pValue = (aValue.getType() == ControlType::SpinButtons) ? static_cast<const SpinbuttonValue*>(&aValue) : nullptr;
-
- // Is any of the buttons pressed?
- QStyle::SCFlags eActive = QStyle::SC_None;
- if ( pValue )
- {
- if ( pValue->mnUpperState & ControlState::PRESSED )
- eActive = QStyle::SC_SpinWidgetUp;
- else if ( pValue->mnLowerState & ControlState::PRESSED )
- eActive = QStyle::SC_SpinWidgetDown;
-
- // Update the enable/disable state of the widget
- if ( ( nState & ControlState::ENABLED ) ||
- ( pValue->mnUpperState & ControlState::ENABLED ) ||
- ( pValue->mnLowerState & ControlState::ENABLED ) )
- {
- pWidget->setEnabled( true );
- nStyle |= QStyle::Style_Enabled;
- }
- else
- pWidget->setEnabled( false );
-
- // Mouse-over effect
- if ( (pValue->mnUpperState & ControlState::ROLLOVER) ||
- (pValue->mnLowerState & ControlState::ROLLOVER) )
- nStyle |= QStyle::Style_MouseOver;
- }
-
- // Spin widget uses the background of the associated edit box
- QSpinWidget *pSpinWidget = static_cast<QSpinWidget *>( pWidget->qt_cast( QSpinWidget_String ) );
- if ( pSpinWidget && pSpinWidget->editWidget() )
- {
- QColorGroup::ColorRole eColorRole = ( pSpinWidget->isEnabled() )?
- QColorGroup::Base: QColorGroup::Background;
- qPainter.fillRect(
- QApplication::style().querySubControlMetrics( QStyle::CC_SpinWidget,
- pSpinWidget, QStyle::SC_SpinWidgetEditField ),
- pSpinWidget->editWidget()->colorGroup().brush( eColorRole ) );
- }
-
- // Adjust the frame (needed for Motif Plus style)
- QRect qFrameRect = QApplication::style().querySubControlMetrics( QStyle::CC_SpinWidget,
- pWidget, QStyle::SC_SpinWidgetFrame );
-
- QApplication::style().drawComplexControl( QStyle::CC_SpinWidget,
- &qPainter, pWidget, qFrameRect,
- pWidget->colorGroup(), nStyle,
- QStyle::SC_All, eActive );
- }
- else if ( strcmp( QTabBar_String, pClassName ) == 0 )
- {
- const TabitemValue *pValue = static_cast<const TabitemValue *> ( &aValue );
-
- QTab *pTab = nullptr;
- if ( pValue )
- {
- if ( ( pValue->isFirst() || pValue->isLeftAligned() ) && ( pValue->isLast() || pValue->isRightAligned() ) )
- pTab = m_pTabAlone;
- else if ( pValue->isFirst() || pValue->isLeftAligned() )
- pTab = m_pTabLeft;
- else if ( pValue->isLast() || pValue->isRightAligned() )
- pTab = m_pTabRight;
- else
- pTab = m_pTabMiddle;
- }
- if ( !pTab )
- return false;
-
- pTab->setRect( qRect );
-
- QApplication::style().drawControl( QStyle::CE_TabBarTab,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle,
- QStyleOption( pTab ) );
- }
- else if ( strcmp( QTabWidget_String, pClassName ) == 0 )
- {
- QApplication::style().drawPrimitive( QStyle::PE_PanelTabWidget,
- &qPainter, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else if ( strcmp( QListView_String, pClassName ) == 0 )
- {
- QApplication::style().drawPrimitive( QStyle::PE_Panel,
- &qPainter, qRect,
- pWidget->colorGroup(), nStyle | QStyle::Style_Sunken );
- }
- else if ( strcmp( QScrollBar_String, pClassName ) == 0 )
- {
- const ScrollbarValue* pValue = (aValue.getType() == ControlType::Scrollbar) ? static_cast<const ScrollbarValue*>(&aValue) : nullptr;
-
- QStyle::SCFlags eActive = QStyle::SC_None;
- if ( pValue )
- {
- // Workaround for Style_MouseOver-aware themes.
- // Quite ugly, but I do not know about a better solution.
- const char *pStyleName = QApplication::style().className();
- if ( strcmp( QMotifPlusStyle_String, pStyleName ) == 0 )
- {
- nStyle |= QStyle::Style_MouseOver;
- if ( pValue->mnThumbState & ControlState::ROLLOVER )
- eActive = QStyle::SC_ScrollBarSlider;
- }
- else if ( strcmp( QSGIStyle_String, pStyleName ) == 0 )
- {
- nStyle |= QStyle::Style_MouseOver;
- if ( pValue->mnButton1State & ControlState::ROLLOVER )
- eActive = QStyle::SC_ScrollBarSubLine;
- else if ( pValue->mnButton2State & ControlState::ROLLOVER )
- eActive = QStyle::SC_ScrollBarAddLine;
- else if ( pValue->mnThumbState & ControlState::ROLLOVER )
- eActive = QStyle::SC_ScrollBarSlider;
- }
-
- if ( pValue->mnButton1State & ControlState::PRESSED )
- eActive = QStyle::SC_ScrollBarSubLine;
- else if ( pValue->mnButton2State & ControlState::PRESSED )
- eActive = QStyle::SC_ScrollBarAddLine;
- else if ( pValue->mnThumbState & ControlState::PRESSED )
- eActive = QStyle::SC_ScrollBarSlider;
- else if ( pValue->mnPage1State & ControlState::PRESSED )
- eActive = QStyle::SC_ScrollBarSubPage;
- else if ( pValue->mnPage2State & ControlState::PRESSED )
- eActive = QStyle::SC_ScrollBarAddPage;
-
- // Update the enable/disable state of the widget
- if ( ( nState & ControlState::ENABLED ) ||
- ( pValue->mnButton1State & ControlState::ENABLED ) ||
- ( pValue->mnButton2State & ControlState::ENABLED ) ||
- ( pValue->mnThumbState & ControlState::ENABLED ) ||
- ( pValue->mnPage1State & ControlState::ENABLED ) ||
- ( pValue->mnPage2State & ControlState::ENABLED ) )
- {
- pWidget->setEnabled( true );
- nStyle |= QStyle::Style_Enabled;
- }
- else
- pWidget->setEnabled( false );
- }
-
- // Is it a horizontal scroll bar?
- QScrollBar *pScrollBar = static_cast<QScrollBar *> ( pWidget->qt_cast( QScrollBar_String ) );
- QStyle::StyleFlags eHoriz = QStyle::Style_Default;
- if ( pScrollBar && pScrollBar->orientation() == Qt::Horizontal )
- eHoriz = QStyle::Style_Horizontal;
-
- QApplication::style().drawComplexControl( QStyle::CC_ScrollBar,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle | eHoriz,
- QStyle::SC_All, eActive );
- }
- else if ( strcmp( QToolBar_String, pClassName ) == 0 )
- {
- QToolBar *pToolBar = static_cast< QToolBar * >( pWidget->qt_cast( QToolBar_String ) );
- bool bIsHorizontal = false;
- if ( pToolBar && pToolBar->orientation() == Qt::Horizontal )
- {
- nStyle |= QStyle::Style_Horizontal;
- bIsHorizontal = true;
- }
-
- QApplication::style().drawControl( QStyle::CE_DockWindowEmptyArea,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
-
- QApplication::style().drawPrimitive( QStyle::PE_PanelDockWindow,
- &qPainter, qRect, pWidget->colorGroup(), nStyle );
-
- if ( nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert )
- {
- const ToolbarValue *pValue = static_cast< const ToolbarValue * >( &aValue );
-
- QRect qThumbRect = region2QRect( pValue->maGripRect );
- qThumbRect.moveBy( -qWidgetPos.x(), -qWidgetPos.y() );
- if ( bIsHorizontal )
- qThumbRect.addCoords( 0, 2, 0, -3 ); // make the thumb a bit nicer
- else
- qThumbRect.addCoords( 2, 0, -3, 0 ); // make the thumb a bit nicer
-
- if ( QApplication::style().inherits( "HighColorStyle" ) ||
- QApplication::style().inherits( "HighContrastStyle" ) ||
- QApplication::style().inherits( "KeramikStyle" ) ||
- QApplication::style().inherits( "KThemeStyle" ) ||
- QApplication::style().inherits( "ThinKeramikStyle" ) )
- {
- // Workaround for the workaround in KStyle::drawPrimitive()
- KStyle *pStyle = static_cast< KStyle * >( &QApplication::style() );
- pStyle->drawKStylePrimitive( KStyle::KPE_ToolBarHandle,
- &qPainter, pToolBar, qThumbRect,
- pWidget->colorGroup(), nStyle );
- }
- else
- QApplication::style().drawPrimitive( QStyle::PE_DockWindowHandle,
- &qPainter, qThumbRect, pWidget->colorGroup(), nStyle );
- }
- }
- else if ( strcmp( QToolButton_String, pClassName ) == 0 )
- {
- if( (nStyle & QStyle::Style_MouseOver) )
- nStyle &= ~QStyle::Style_Off;
- QApplication::style().drawComplexControl( QStyle::CC_ToolButton,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle,
- QStyle::SC_ToolButton );
- }
- else if ( strcmp( QMenuBar_String, pClassName ) == 0 )
- {
- if ( nPart == ControlPart::Entire )
- {
- QApplication::style().drawControl( QStyle::CE_MenuBarEmptyArea,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else if ( nPart == ControlPart::MenuItem )
- {
- int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nMenuBarEnabledItem: m_nMenuBarDisabledItem;
- QMenuItem *pMenuItem = static_cast<QMenuBar*>( pWidget )->findItem( nMenuItem );
-
- if ( ( nStyle & QStyle::Style_MouseOver )
- && QApplication::style().styleHint( QStyle::SH_MenuBar_MouseTracking ) )
- nStyle |= QStyle::Style_Active;
-
- if ( nStyle & QStyle::Style_Selected )
- nStyle |= QStyle::Style_Active | QStyle::Style_Down | QStyle::Style_HasFocus;
-
- QApplication::style().drawControl( QStyle::CE_MenuBarItem,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle,
- QStyleOption( pMenuItem ) );
- }
- }
- else if ( strcmp( QPopupMenu_String, pClassName ) == 0 )
- {
- int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nPopupMenuEnabledItem: m_nPopupMenuDisabledItem;
- QMenuItem *pMenuItem = static_cast<QPopupMenu*>( pWidget )->findItem( nMenuItem );
-
- if ( nStyle & QStyle::Style_Selected )
- nStyle |= QStyle::Style_Active;
-
- QApplication::style().drawControl( QStyle::CE_PopupMenuItem,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle,
- QStyleOption( pMenuItem, 0, 0 ) );
- }
- else if ( strcmp( QProgressBar_String, pClassName ) == 0 )
- {
- long nProgressWidth = aValue.getNumericVal();
- QProgressBar* pProgress = static_cast<QProgressBar*>(pWidget);
- pProgress->setProgress( nProgressWidth, qRect.width() );
-
- QApplication::style().drawControl( QStyle::CE_ProgressBarGroove,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- QApplication::style().drawControl( QStyle::CE_ProgressBarContents,
- &qPainter, pWidget, qRect,
- pWidget->colorGroup(), nStyle );
- }
- else
- return false;
-
- // Bitblt it to the screen
- pGraphics->RenderPixmapToScreen( &xPixmap, nullptr, qWidgetPos.x(), qWidgetPos.y() );
-
- // Restore widget's position
- pWidget->move( qWidgetPos );
-
- return true;
-}
-
-QPushButton *WidgetPainter::pushButton( const tools::Rectangle& rControlRegion,
- bool bDefault )
-{
- if ( !m_pPushButton )
- m_pPushButton = new QPushButton( nullptr, "push_button" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- // Workaround for broken styles which do not add
- // QStyle::PM_ButtonDefaultIndicator to the size of the default button
- // (for example Keramik)
- // FIXME Fix Keramik style to be consistent with Qt built-in styles. Aargh!
- if ( bDefault )
- {
- QSize qContentsSize( 50, 50 );
- m_pPushButton->setDefault( false );
- QSize qNormalSize = QApplication::style().sizeFromContents( QStyle::CT_PushButton,
- m_pPushButton, qContentsSize );
- m_pPushButton->setDefault( true );
- QSize qDefSize = QApplication::style().sizeFromContents( QStyle::CT_PushButton,
- m_pPushButton, qContentsSize );
-
- int nIndicatorSize = QApplication::style().pixelMetric(
- QStyle::PM_ButtonDefaultIndicator, m_pPushButton );
- if ( qNormalSize.width() == qDefSize.width() )
- qRect.addCoords( nIndicatorSize, 0, -nIndicatorSize, 0 );
- if ( qNormalSize.height() == qDefSize.height() )
- qRect.addCoords( 0, nIndicatorSize, 0, -nIndicatorSize );
- }
-
- m_pPushButton->move( qRect.topLeft() );
- m_pPushButton->resize( qRect.size() );
- m_pPushButton->setDefault( bDefault );
-
- return m_pPushButton;
-}
-
-QRadioButton *WidgetPainter::radioButton( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pRadioButton )
- m_pRadioButton = new QRadioButton( nullptr, "radio_button" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- // Workaround for broken themes which do not honor the given size.
- // Quite ugly, but I do not know about a better solution.
- const char *pStyleName = QApplication::style().className();
- if ( strcmp( "KThemeStyle", pStyleName ) == 0 )
- {
- QRect qOldRect( qRect );
-
- qRect.setWidth( QApplication::style().pixelMetric(
- QStyle::PM_ExclusiveIndicatorWidth, m_pRadioButton ) );
- qRect.setHeight( QApplication::style().pixelMetric(
- QStyle::PM_ExclusiveIndicatorHeight, m_pRadioButton ) );
-
- qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2,
- ( qOldRect.height() - qRect.height() ) / 2 );
- }
-
- m_pRadioButton->move( qRect.topLeft() );
- m_pRadioButton->resize( qRect.size() );
-
- return m_pRadioButton;
-}
-
-QCheckBox *WidgetPainter::checkBox( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pCheckBox )
- m_pCheckBox = new QCheckBox( nullptr, "check_box" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- // Workaround for broken themes which do not honor the given size.
- // Quite ugly, but I do not know about a better solution.
- const char *pStyleName = QApplication::style().className();
- if ( strcmp( "KThemeStyle", pStyleName ) == 0 )
- {
- QRect qOldRect( qRect );
-
- qRect.setWidth( QApplication::style().pixelMetric(
- QStyle::PM_IndicatorWidth, m_pCheckBox ) );
- qRect.setHeight( QApplication::style().pixelMetric(
- QStyle::PM_IndicatorHeight, m_pCheckBox ) );
-
- qRect.moveBy( ( qOldRect.width() - qRect.width() ) / 2,
- ( qOldRect.height() - qRect.height() ) / 2 );
- }
-
- m_pCheckBox->move( qRect.topLeft() );
- m_pCheckBox->resize( qRect.size() );
-
- return m_pCheckBox;
-}
-
-QComboBox *WidgetPainter::comboBox( const tools::Rectangle& rControlRegion,
- bool bEditable )
-{
- QComboBox *pComboBox = nullptr;
- if ( bEditable )
- {
- if ( !m_pEditableComboBox )
- m_pEditableComboBox = new QComboBox( true, nullptr, "combo_box_edit" );
- pComboBox = m_pEditableComboBox;
- }
- else
- {
- if ( !m_pComboBox )
- m_pComboBox = new QComboBox( false, nullptr, "combo_box" );
- pComboBox = m_pComboBox;
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- pComboBox->move( qRect.topLeft() );
- pComboBox->resize( qRect.size() );
-
- return pComboBox;
-}
-
-QLineEdit *WidgetPainter::lineEdit( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pLineEdit )
- m_pLineEdit = new QLineEdit( nullptr, "line_edit" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pLineEdit->move( qRect.topLeft() );
- m_pLineEdit->resize( qRect.size() );
-
- return m_pLineEdit;
-}
-
-QSpinWidget *WidgetPainter::spinWidget( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pSpinWidget )
- {
- m_pSpinWidget = new QSpinWidget( nullptr, "spin_widget" );
- m_pSpinEdit = new QLineEdit( nullptr, "line_edit_spin" );
- m_pSpinWidget->setEditWidget( m_pSpinEdit );
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pSpinWidget->move( qRect.topLeft() );
- m_pSpinWidget->resize( qRect.size() );
- m_pSpinWidget->arrange();
-
- return m_pSpinWidget;
-}
-
-QTabBar *WidgetPainter::tabBar( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pTabBar )
- {
- if ( !m_pTabBarParent )
- m_pTabBarParent = new QWidget( nullptr, "tab_bar_parent" );
-
- m_pTabBar = new QTabBar( m_pTabBarParent, "tab_bar" );
-
- m_pTabLeft = new QTab();
- m_pTabMiddle = new QTab();
- m_pTabRight = new QTab();
- m_pTabAlone = new QTab();
-
- m_pTabBar->addTab( m_pTabLeft );
- m_pTabBar->addTab( m_pTabMiddle );
- m_pTabBar->addTab( m_pTabRight );
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pTabBar->move( qRect.topLeft() );
- m_pTabBar->resize( qRect.size() );
-
- m_pTabBar->setShape( QTabBar::RoundedAbove );
-
- return m_pTabBar;
-}
-
-QTabWidget *WidgetPainter::tabWidget( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pTabWidget )
- m_pTabWidget = new QTabWidget( nullptr, "tab_widget" );
-
- QRect qRect = region2QRect( rControlRegion );
- --qRect.rTop();
-
- m_pTabWidget->move( qRect.topLeft() );
- m_pTabWidget->resize( qRect.size() );
-
- return m_pTabWidget;
-}
-
-QListView *WidgetPainter::listView( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pListView )
- m_pListView = new QListView( nullptr, "list_view" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pListView->move( qRect.topLeft() );
- m_pListView->resize( qRect.size() );
-
- return m_pListView;
-}
-
-QScrollBar *WidgetPainter::scrollBar( const tools::Rectangle& rControlRegion,
- bool bHorizontal, const ImplControlValue& aValue )
-{
- if ( !m_pScrollBar )
- {
- m_pScrollBar = new QScrollBar( nullptr, "scroll_bar" );
- m_pScrollBar->setTracking( false );
- m_pScrollBar->setLineStep( 1 );
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pScrollBar->move( qRect.topLeft() );
- m_pScrollBar->resize( qRect.size() );
- m_pScrollBar->setOrientation( bHorizontal? Qt::Horizontal: Qt::Vertical );
-
- const ScrollbarValue* pValue = (aValue.getType() == ControlType::Scrollbar) ? static_cast<const ScrollbarValue*>(&aValue) : nullptr;
- if ( pValue )
- {
- m_pScrollBar->setMinValue( pValue->mnMin );
- m_pScrollBar->setMaxValue( pValue->mnMax - pValue->mnVisibleSize );
- m_pScrollBar->setValue( pValue->mnCur );
- m_pScrollBar->setPageStep( pValue->mnVisibleSize );
- }
-
- return m_pScrollBar;
-}
-
-QToolBar *WidgetPainter::toolBar( const tools::Rectangle& rControlRegion, bool bHorizontal )
-{
- if ( !m_pMainWindow )
- m_pMainWindow = new QMainWindow( nullptr, "main_window" );
-
- QToolBar *pToolBar;
- if ( bHorizontal )
- {
- if ( !m_pToolBarHoriz )
- {
- m_pToolBarHoriz = new QToolBar( m_pMainWindow, "tool_bar_horiz" );
- m_pMainWindow->moveDockWindow( m_pToolBarHoriz, Qt::DockTop );
- }
- pToolBar = m_pToolBarHoriz;
- }
- else
- {
- if ( !m_pToolBarVert )
- {
- m_pToolBarVert = new QToolBar( m_pMainWindow, "tool_bar_horiz" );
- m_pMainWindow->moveDockWindow( m_pToolBarVert, Qt::DockLeft );
- }
- pToolBar = m_pToolBarVert;
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- pToolBar->move( qRect.topLeft() );
- pToolBar->resize( qRect.size() );
-
- return pToolBar;
-}
-
-QToolButton *WidgetPainter::toolButton( const tools::Rectangle& rControlRegion)
-{
- if ( !m_pToolButton )
- m_pToolButton = new QToolButton( nullptr, "tool_button" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pToolButton->move( qRect.topLeft() );
- m_pToolButton->resize( qRect.size() );
-
- return m_pToolButton;
-}
-
-QMenuBar *WidgetPainter::menuBar( const tools::Rectangle& rControlRegion)
-{
- if ( !m_pMenuBar )
- {
- m_pMenuBar = new QMenuBar( nullptr, "menu_bar" );
-
- m_nMenuBarEnabledItem = m_pMenuBar->insertItem( "" );
- m_nMenuBarDisabledItem = m_pMenuBar->insertItem( "" );
-
- m_pMenuBar->setItemEnabled( m_nMenuBarEnabledItem, true );
- m_pMenuBar->setItemEnabled( m_nMenuBarDisabledItem, false );
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pMenuBar->move( qRect.topLeft() );
- m_pMenuBar->resize( qRect.size() );
-
- return m_pMenuBar;
-}
-
-QPopupMenu *WidgetPainter::popupMenu( const tools::Rectangle& rControlRegion)
-{
- if ( !m_pPopupMenu )
- {
- m_pPopupMenu = new QPopupMenu( nullptr, "popup_menu" );
-
- m_nPopupMenuEnabledItem = m_pPopupMenu->insertItem( "" );
- m_nPopupMenuDisabledItem = m_pPopupMenu->insertItem( "" );
-
- m_pPopupMenu->setItemEnabled( m_nPopupMenuEnabledItem, true );
- m_pPopupMenu->setItemEnabled( m_nPopupMenuDisabledItem, false );
- }
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pPopupMenu->move( qRect.topLeft() );
- m_pPopupMenu->resize( qRect.size() );
-
- return m_pPopupMenu;
-}
-
-QProgressBar *WidgetPainter::progressBar( const tools::Rectangle& rControlRegion )
-{
- if ( !m_pProgressBar )
- m_pProgressBar = new QProgressBar( nullptr, "progress_bar" );
-
- QRect qRect = region2QRect( rControlRegion );
-
- m_pProgressBar->move( qRect.topLeft() );
- m_pProgressBar->resize( qRect.size() );
-
- return m_pProgressBar;
-}
-
-QRect WidgetPainter::region2QRect( const tools::Rectangle& rControlRegion )
-{
- return QRect( QPoint( rControlRegion.Left(), rControlRegion.Top() ),
- QPoint( rControlRegion.Right(), rControlRegion.Bottom() ) );
-}
-
-/** Instance of WidgetPainter.
-
- It is used to paint the widgets requested by NWF.
-*/
-static WidgetPainter *pWidgetPainter;
-
-class KDESalGraphics : public X11SalGraphics
-{
- public:
- KDESalGraphics() {}
- virtual bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) override;
- virtual bool hitTestNativeControl( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, const Point& aPos,
- bool& rIsInside ) override;
- virtual bool drawNativeControl( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, ControlState nState,
- const ImplControlValue& aValue,
- const OUString& aCaption ) override;
- virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, ControlState nState,
- const ImplControlValue& aValue,
- const OUString& aCaption,
- tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override;
-};
-
-bool KDESalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
-{
- return
- ( (nType == ControlType::Pushbutton) && (nPart == ControlPart::Entire) ) ||
- ( (nType == ControlType::Radiobutton) && (nPart == ControlPart::Entire) ) ||
- ( (nType == ControlType::Checkbox) && (nPart == ControlPart::Entire) ) ||
- ( (nType == ControlType::Combobox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) ||
- ( (nType == ControlType::Editbox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) ||
- ( (nType == ControlType::Listbox) && (nPart == ControlPart::Entire || nPart == ControlPart::ListboxWindow || nPart == ControlPart::HasBackgroundTexture ) ) ||
- ( (nType == ControlType::Spinbox) && (nPart == ControlPart::Entire || nPart == ControlPart::HasBackgroundTexture) ) ||
- // no ControlType::SpinButtons for KDE
- ( (nType == ControlType::TabItem) && (nPart == ControlPart::Entire) ) ||
- ( (nType == ControlType::TabPane) && (nPart == ControlPart::Entire) ) ||
- // no ControlType::TabBody for KDE
- ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::Entire || nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert) ) ||
- ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::HasThreeButtons) ) || // TODO small optimization is possible here: return this only if the style really has 3 buttons
- // ControlType::Fixedline not supported
- ( (nType == ControlType::Toolbar) && (nPart == ControlPart::Entire ||
- nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert ||
- nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert ||
- nPart == ControlPart::Button) ) ||
- ( (nType == ControlType::Menubar) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) ||
- ( (nType == ControlType::MenuPopup) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) ) ||
- ( (nType == ControlType::Progress) && (nPart == ControlPart::Entire) )
- ;
-}
-
-bool KDESalGraphics::hitTestNativeControl( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, const Point& rPos,
- bool& rIsInside )
-{
- if ( nType == ControlType::Scrollbar )
- {
- // make position relative to rControlRegion
- Point aPos = rPos - rControlRegion.TopLeft();
- rIsInside = false;
-
- bool bHorizontal = ( nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight );
-
- QScrollBar *pScrollBar = pWidgetPainter->scrollBar( rControlRegion,
- bHorizontal, ImplControlValue() );
- QRect qRectSubLine = QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubLine );
- QRect qRectAddLine = QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarAddLine );
-
- // There are 2 buttons on the right/bottom side of the scrollbar
- bool bTwoSubButtons = false;
-
- // It is a Platinum style scroll bar
- bool bPlatinumStyle = false;
-
- // Workaround for Platinum and 3 button style scroll bars.
- // It makes the right/down button bigger.
- if ( bHorizontal )
- {
- qRectAddLine.setLeft( QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pScrollBar,
- QStyle::SC_ScrollBarAddPage ).right() + 1 );
- if ( qRectAddLine.width() > qRectSubLine.width() )
- bTwoSubButtons = true;
- if ( qRectSubLine.left() > QApplication::style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).left() )
- bPlatinumStyle = true;
- }
- else
- {
- qRectAddLine.setTop( QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pScrollBar,
- QStyle::SC_ScrollBarAddPage ).bottom() + 1 );
- if ( qRectAddLine.height() > qRectSubLine.height() )
- bTwoSubButtons = true;
- if ( qRectSubLine.top() > QApplication::style().querySubControlMetrics( QStyle::CC_ScrollBar, pScrollBar, QStyle::SC_ScrollBarSubPage ).top() )
- bPlatinumStyle = true;
- }
-
- switch ( nPart )
- {
- case ControlPart::ButtonLeft:
- if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) )
- rIsInside = true;
- else if ( bTwoSubButtons )
- {
- qRectAddLine.setWidth( qRectAddLine.width() / 2 );
- rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() );
- }
- break;
-
- case ControlPart::ButtonUp:
- if ( !bPlatinumStyle && qRectSubLine.contains( aPos.getX(), aPos.getY() ) )
- rIsInside = true;
- else if ( bTwoSubButtons )
- {
- qRectAddLine.setHeight( qRectAddLine.height() / 2 );
- rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() );
- }
- break;
-
- case ControlPart::ButtonRight:
- if ( bTwoSubButtons )
- qRectAddLine.setLeft( qRectAddLine.left() + qRectAddLine.width() / 2 );
-
- rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() );
- break;
-
- case ControlPart::ButtonDown:
- if ( bTwoSubButtons )
- qRectAddLine.setTop( qRectAddLine.top() + qRectAddLine.height() / 2 );
-
- rIsInside = qRectAddLine.contains( aPos.getX(), aPos.getY() );
- break;
-
- // cases ControlPart::TrackHorzArea and ControlPart::TrackVertArea
- default:
- return false;
- }
-
- return true;
- }
-
- return false;
-}
-
-bool KDESalGraphics::drawNativeControl( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, ControlState nState,
- const ImplControlValue& aValue,
- const OUString& )
-{
- bool bReturn = false;
-
- if ( (nType == ControlType::Pushbutton) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->pushButton( rControlRegion, bool(nState & ControlState::DEFAULT) ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Radiobutton) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->radioButton( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Checkbox) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->checkBox( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Combobox) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->comboBox( rControlRegion, true ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Editbox) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->lineEdit( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Listbox) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->comboBox( rControlRegion, false ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Listbox) && (nPart == ControlPart::ListboxWindow) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->listView( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Spinbox) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->spinWidget( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType==ControlType::TabItem) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->tabBar( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType==ControlType::TabPane) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->tabWidget( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Scrollbar) && (nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->scrollBar( rControlRegion, nPart == ControlPart::DrawBackgroundHorz, aValue ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Toolbar) && (nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::DrawBackgroundVert || nPart == ControlPart::ThumbHorz || nPart == ControlPart::ThumbVert) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->toolBar( rControlRegion, nPart == ControlPart::DrawBackgroundHorz || nPart == ControlPart::ThumbVert ),
- nState, aValue, this, nPart );
- }
- else if ( (nType == ControlType::Toolbar) && (nPart == ControlPart::Button) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->toolButton( rControlRegion ),
- nState, aValue, this, nPart );
- }
- else if ( (nType == ControlType::Menubar) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->menuBar( rControlRegion ),
- nState, aValue, this, nPart );
- }
- else if ( (nType == ControlType::MenuPopup) && (nPart == ControlPart::Entire || nPart == ControlPart::MenuItem) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->popupMenu( rControlRegion ),
- nState, aValue, this );
- }
- else if ( (nType == ControlType::Progress) && (nPart == ControlPart::Entire) )
- {
- bReturn = pWidgetPainter->drawStyledWidget(
- pWidgetPainter->progressBar( rControlRegion ),
- nState, aValue, this );
- }
-
- return bReturn;
-}
-
-bool KDESalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart,
- const tools::Rectangle& rControlRegion, ControlState nState,
- const ImplControlValue&,
- const OUString&,
- tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion )
-{
- bool bReturn = false;
- QRect qBoundingRect = WidgetPainter::region2QRect( rControlRegion );
- QRect qRect;
-
- QWidget *pWidget = nullptr;
- switch ( nType )
- {
- // Metrics of the push button
- case ControlType::Pushbutton:
- pWidget = pWidgetPainter->pushButton( rControlRegion, bool( nState & ControlState::DEFAULT ) );
-
- switch ( nPart )
- {
- case ControlPart::Entire:
- qRect = qBoundingRect;
-
- if ( nState & ControlState::DEFAULT )
- {
- int nIndicatorSize = QApplication::style().pixelMetric(
- QStyle::PM_ButtonDefaultIndicator, pWidget );
- qBoundingRect.addCoords( -nIndicatorSize, -nIndicatorSize,
- nIndicatorSize, nIndicatorSize );
- bReturn = true;
- }
- break;
- default:
- break;
- }
- break;
-
- // Metrics of the radio button
- case ControlType::Radiobutton:
- pWidget = pWidgetPainter->radioButton( rControlRegion );
-
- if ( nPart == ControlPart::Entire )
- {
- qRect.setWidth( QApplication::style().pixelMetric( QStyle::PM_ExclusiveIndicatorWidth, pWidget ) );
- qRect.setHeight( QApplication::style().pixelMetric( QStyle::PM_ExclusiveIndicatorHeight, pWidget ) );
-
- bReturn = true;
- }
- break;
-
- // Metrics of the check box
- case ControlType::Checkbox:
- pWidget = pWidgetPainter->checkBox( rControlRegion );
-
- if ( nPart == ControlPart::Entire )
- {
- qRect.setWidth( QApplication::style().pixelMetric( QStyle::PM_IndicatorWidth, pWidget ) );
- qRect.setHeight( QApplication::style().pixelMetric( QStyle::PM_IndicatorHeight, pWidget ) );
-
- bReturn = true;
- }
- break;
-
- // Metrics of the combo box
- case ControlType::Combobox:
- case ControlType::Listbox:
- pWidget = pWidgetPainter->comboBox( rControlRegion, ( nType == ControlType::Combobox ) );
- switch ( nPart )
- {
- case ControlPart::ButtonDown:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxArrow );
- qRect.setLeft( QApplication::style().querySubControlMetrics(
- QStyle::CC_ComboBox, pWidget,
- QStyle::SC_ComboBoxEditField ).right() + 1 );
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
- bReturn = true;
- break;
-
- case ControlPart::SubEdit:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_ComboBox, pWidget, QStyle::SC_ComboBoxEditField );
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
- bReturn = true;
- break;
-
- default:
- break;
- }
- break;
-
- // Metrics of the spin box
- case ControlType::Spinbox:
- pWidget = pWidgetPainter->spinWidget( rControlRegion );
- switch ( nPart )
- {
- case ControlPart::ButtonUp:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetUp );
- bReturn = true;
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
- break;
-
- case ControlPart::ButtonDown:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetDown );
- bReturn = true;
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
- break;
-
- case ControlPart::SubEdit:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_SpinWidget, pWidget, QStyle::SC_SpinWidgetEditField );
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
- bReturn = true;
- break;
-
- default:
- break;
- }
- break;
-
- // Metrics of the scroll bar
- case ControlType::Scrollbar:
- pWidget = pWidgetPainter->scrollBar( rControlRegion,
- ( nPart == ControlPart::ButtonLeft || nPart == ControlPart::ButtonRight ),
- ImplControlValue() );
- switch ( nPart )
- {
- case ControlPart::ButtonLeft:
- case ControlPart::ButtonUp:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarSubLine );
-
- // Workaround for Platinum style scroll bars. It makes the
- // left/up button invisible.
- if ( nPart == ControlPart::ButtonLeft )
- {
- if ( qRect.left() > QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget,
- QStyle::SC_ScrollBarSubPage ).left() )
- {
- qRect.setLeft( 0 );
- qRect.setRight( 0 );
- }
- }
- else
- {
- if ( qRect.top() > QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget,
- QStyle::SC_ScrollBarSubPage ).top() )
- {
- qRect.setTop( 0 );
- qRect.setBottom( 0 );
- }
- }
-
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
-
- bReturn = true;
- break;
-
- case ControlPart::ButtonRight:
- case ControlPart::ButtonDown:
- qRect = QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget, QStyle::SC_ScrollBarAddLine );
-
- // Workaround for Platinum and 3 button style scroll bars.
- // It makes the right/down button bigger.
- if ( nPart == ControlPart::ButtonRight )
- qRect.setLeft( QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget,
- QStyle::SC_ScrollBarAddPage ).right() + 1 );
- else
- qRect.setTop( QApplication::style().querySubControlMetrics(
- QStyle::CC_ScrollBar, pWidget,
- QStyle::SC_ScrollBarAddPage ).bottom() + 1 );
-
- qRect.moveBy( qBoundingRect.left(), qBoundingRect.top() );
-
- bReturn = true;
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
-
- // Fill rNativeBoundingRegion and rNativeContentRegion
- if ( bReturn )
- {
- // Bounding region
- Point aBPoint( qBoundingRect.x(), qBoundingRect.y() );
- Size aBSize( qBoundingRect.width(), qBoundingRect.height() );
- rNativeBoundingRegion = tools::Rectangle( aBPoint, aBSize );
-
- // vcl::Region of the content
- Point aPoint( qRect.x(), qRect.y() );
- Size aSize( qRect.width(), qRect.height() );
- rNativeContentRegion = tools::Rectangle( aPoint, aSize );
- }
-
- return bReturn;
-}
-
-// KDESalFrame implementation
-
-KDESalFrame::KDESalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) :
- X11SalFrame( pParent, nStyle )
-{
-}
-
-void KDESalFrame::Show( bool bVisible, bool bNoActivate )
-{
- if ( !GetParent() && ! (GetStyle() & SalFrameStyleFlags::INTRO) )
- {
- KDEXLib* pXLib = static_cast<KDEXLib*>(GetDisplay()->GetXLib());
- pXLib->doStartup();
- }
- X11SalFrame::Show( bVisible, bNoActivate );
-}
-
-/** Helper function to convert colors.
-*/
-static Color toColor( const QColor &rColor )
-{
- return Color( rColor.red(), rColor.green(), rColor.blue() );
-}
-
-/** Helper function to read untranslated text entry from KConfig configuration repository.
-*/
-static OUString readEntryUntranslated( KConfig *pConfig, const char *pKey )
-{
- return OUString::createFromAscii( pConfig->readEntryUntranslated( pKey ).ascii() );
-}
-
-/** Helper function to read color from KConfig configuration repository.
-*/
-static Color readColor( KConfig *pConfig, const char *pKey )
-{
- return toColor( pConfig->readColorEntry( pKey ) );
-}
-
-/** Helper function to add information to Font from QFont.
-
- Mostly grabbed from the Gtk+ vclplug (salnativewidgets-gtk.cxx).
-*/
-static vcl::Font toFont( const QFont &rQFont, const css::lang::Locale& rLocale )
-{
- psp::FastPrintFontInfo aInfo;
- QFontInfo qFontInfo( rQFont );
-
- // set family name
- aInfo.m_aFamilyName = OUString( rQFont.family().utf8(), strlen( rQFont.family().utf8() ), RTL_TEXTENCODING_UTF8 );
-
- // set italic
- aInfo.m_eItalic = ( qFontInfo.italic()? ITALIC_NORMAL: ITALIC_NONE );
-
- // set weight
- int nWeight = qFontInfo.weight();
- if ( nWeight <= QFont::Light )
- aInfo.m_eWeight = WEIGHT_LIGHT;
- else if ( nWeight <= QFont::Normal )
- aInfo.m_eWeight = WEIGHT_NORMAL;
- else if ( nWeight <= QFont::DemiBold )
- aInfo.m_eWeight = WEIGHT_SEMIBOLD;
- else if ( nWeight <= QFont::Bold )
- aInfo.m_eWeight = WEIGHT_BOLD;
- else
- aInfo.m_eWeight = WEIGHT_ULTRABOLD;
-
- // set width
- int nStretch = rQFont.stretch();
- if ( nStretch <= QFont::UltraCondensed )
- aInfo.m_eWidth = WIDTH_ULTRA_CONDENSED;
- else if ( nStretch <= QFont::ExtraCondensed )
- aInfo.m_eWidth = WIDTH_EXTRA_CONDENSED;
- else if ( nStretch <= QFont::Condensed )
- aInfo.m_eWidth = WIDTH_CONDENSED;
- else if ( nStretch <= QFont::SemiCondensed )
- aInfo.m_eWidth = WIDTH_SEMI_CONDENSED;
- else if ( nStretch <= QFont::Unstretched )
- aInfo.m_eWidth = WIDTH_NORMAL;
- else if ( nStretch <= QFont::SemiExpanded )
- aInfo.m_eWidth = WIDTH_SEMI_EXPANDED;
- else if ( nStretch <= QFont::Expanded )
- aInfo.m_eWidth = WIDTH_EXPANDED;
- else if ( nStretch <= QFont::ExtraExpanded )
- aInfo.m_eWidth = WIDTH_EXTRA_EXPANDED;
- else
- aInfo.m_eWidth = WIDTH_ULTRA_EXPANDED;
-
- SAL_INFO( "vcl.kde", "font name BEFORE system match: \"" << aInfo.m_aFamilyName << "\"" );
-
- // match font to e.g. resolve "Sans"
- psp::PrintFontManager::get().matchFont( aInfo, rLocale );
-
- SAL_INFO( "vcl.kde", "font match " <<
- (aInfo.m_nID != 0 ? "succeeded" : "failed") <<
- ", name AFTER: \"" << aInfo.m_aFamilyName << "\"" );
-
- // font height
- int nPointHeight = qFontInfo.pointSize();
- if ( nPointHeight <= 0 )
- nPointHeight = rQFont.pointSize();
-
- // Create the font
- vcl::Font aFont( aInfo.m_aFamilyName, Size( 0, nPointHeight ) );
- if( aInfo.m_eWeight != WEIGHT_DONTKNOW )
- aFont.SetWeight( aInfo.m_eWeight );
- if( aInfo.m_eWidth != WIDTH_DONTKNOW )
- aFont.SetWidthType( aInfo.m_eWidth );
- if( aInfo.m_eItalic != ITALIC_DONTKNOW )
- aFont.SetItalic( aInfo.m_eItalic );
- if( aInfo.m_ePitch != PITCH_DONTKNOW )
- aFont.SetPitch( aInfo.m_ePitch );
-
- return aFont;
-}
-
-/** Implementation of KDE integration's main method.
-*/
-void KDESalFrame::UpdateSettings( AllSettings& rSettings )
-{
- StyleSettings aStyleSettings( rSettings.GetStyleSettings() );
- bool bSetTitleFont = false;
-
- aStyleSettings.SetToolbarIconSize( ToolbarIconSize::Large );
-
- // WM settings
- KConfig *pConfig = KGlobal::config();
- if ( pConfig )
- {
- pConfig->setGroup( "WM" );
- const char *pKey;
-
- pKey = "activeBackground";
- if ( pConfig->hasKey( pKey ) )
- aStyleSettings.SetActiveColor( readColor( pConfig, pKey ) );
-
- pKey = "inactiveBackground";
- if ( pConfig->hasKey( pKey ) )
- aStyleSettings.SetDeactiveColor( readColor( pConfig, pKey ) );
-
- pKey = "inactiveForeground";
- if ( pConfig->hasKey( pKey ) )
- aStyleSettings.SetDeactiveTextColor( readColor( pConfig, pKey ) );
-
- pKey = "activeForeground";
- if ( pConfig->hasKey( pKey ) )
- aStyleSettings.SetActiveTextColor( readColor( pConfig, pKey ) );
-
- pKey = "titleFont";
- if ( pConfig->hasKey( pKey ) )
- {
- vcl::Font aFont = toFont( pConfig->readFontEntry( pKey ), rSettings.GetUILanguageTag().getLocale() );
- aStyleSettings.SetTitleFont( aFont );
- bSetTitleFont = true;
- }
-
- pConfig->setGroup( "Icons" );
-
- pKey = "Theme";
- if ( pConfig->hasKey( pKey ) )
- aStyleSettings.SetPreferredIconTheme( readEntryUntranslated( pConfig, pKey ) );
- }
-
- // General settings
- QColorGroup qColorGroup = QApplication::palette().active();
-
- Color aFore = toColor( qColorGroup.foreground() );
- Color aBack = toColor( qColorGroup.background() );
- Color aText = toColor( qColorGroup.text() );
- Color aBase = toColor( qColorGroup.base() );
-
- // Foreground
- aStyleSettings.SetRadioCheckTextColor( aFore );
- aStyleSettings.SetLabelTextColor( aFore );
- aStyleSettings.SetDialogTextColor( aFore );
- aStyleSettings.SetGroupTextColor( aFore );
-
- // Text
- aStyleSettings.SetFieldTextColor( aText );
- aStyleSettings.SetFieldRolloverTextColor( aText );
- aStyleSettings.SetWindowTextColor( aText );
- aStyleSettings.SetToolTextColor( aText );
- aStyleSettings.SetHelpTextColor( aText );
-
- // Base
- aStyleSettings.SetFieldColor( aBase );
- aStyleSettings.SetHelpColor( aBase );
- aStyleSettings.SetWindowColor( aBase );
- aStyleSettings.SetActiveTabColor( aBase );
-
- // Buttons
- aStyleSettings.SetButtonTextColor( toColor( qColorGroup.buttonText() ) );
- aStyleSettings.SetButtonRolloverTextColor( toColor( qColorGroup.buttonText() ) );
-
- // Tabs
- aStyleSettings.SetTabTextColor( toColor( qColorGroup.buttonText() ) );
- aStyleSettings.SetTabRolloverTextColor( toColor( qColorGroup.buttonText() ) );
- aStyleSettings.SetTabHighlightTextColor( toColor( qColorGroup.buttonText() ) );
-
- // Disable color
- aStyleSettings.SetDisableColor( toColor( qColorGroup.mid() ) );
-
- // Workspace
- aStyleSettings.SetWorkspaceColor( toColor( qColorGroup.mid() ) );
-
- // Background
- aStyleSettings.Set3DColors( aBack );
- aStyleSettings.SetFaceColor( aBack );
- aStyleSettings.SetInactiveTabColor( aBack );
- aStyleSettings.SetDialogColor( aBack );
- aStyleSettings.SetCheckedColorSpecialCase( );
-
- // Selection
- aStyleSettings.SetHighlightColor( toColor( qColorGroup.highlight() ) );
- aStyleSettings.SetHighlightTextColor( toColor( qColorGroup.highlightedText() ) );
-
- // Font
- vcl::Font aFont = toFont( QApplication::font(), rSettings.GetUILanguageTag().getLocale() );
-
- aStyleSettings.SetAppFont( aFont );
- aStyleSettings.SetHelpFont( aFont );
- aStyleSettings.SetMenuFont( aFont ); // will be changed according to pMenuBar
- aStyleSettings.SetToolFont( aFont ); // will be changed according to pToolBar
- aStyleSettings.SetLabelFont( aFont );
- aStyleSettings.SetRadioCheckFont( aFont );
- aStyleSettings.SetPushButtonFont( aFont );
- aStyleSettings.SetFieldFont( aFont );
- aStyleSettings.SetIconFont( aFont );
- aStyleSettings.SetTabFont( aFont );
- aStyleSettings.SetGroupFont( aFont );
-
- aFont.SetWeight( WEIGHT_BOLD );
- if( !bSetTitleFont )
- aStyleSettings.SetTitleFont( aFont );
- aStyleSettings.SetFloatTitleFont( aFont );
-
- int flash_time = QApplication::cursorFlashTime();
- aStyleSettings.SetCursorBlinkTime( flash_time != 0 ? flash_time/2 : STYLE_CURSOR_NOBLINKTIME );
-
- KMainWindow qMainWindow;
- qMainWindow.createGUI( "/dev/null" ); // hack
-
- // Menu
- aStyleSettings.SetSkipDisabledInMenus( true );
- KMenuBar *pMenuBar = qMainWindow.menuBar();
- if ( pMenuBar )
- {
- // Color
- QColorGroup qMenuCG = pMenuBar->colorGroup();
-
- // Menu text and background color, theme specific
- Color aMenuFore = toColor( qMenuCG.foreground() );
- Color aMenuBack = toColor( qMenuCG.background() );
- if ( QApplication::style().inherits( "LightStyleV2" ) ||
- QApplication::style().inherits( "LightStyleV3" ) ||
- ( QApplication::style().inherits( QMotifStyle_String ) && !QApplication::style().inherits( QSGIStyle_String ) ) ||
- QApplication::style().inherits( QWindowsStyle_String ) )
- {
- aMenuFore = toColor( qMenuCG.buttonText() );
- aMenuBack = toColor( qMenuCG.button() );
- }
-
- aStyleSettings.SetMenuTextColor( aMenuFore );
- aStyleSettings.SetMenuBarTextColor( aStyleSettings.GetPersonaMenuBarTextColor().get_value_or( aMenuFore ) );
- aStyleSettings.SetMenuColor( aMenuBack );
- aStyleSettings.SetMenuBarColor( aMenuBack );
- aStyleSettings.SetMenuHighlightColor( toColor ( qMenuCG.highlight() ) );
-
- // Menu items highlight text color, theme specific
- if ( QApplication::style().inherits( "HighContrastStyle" ) ||
- QApplication::style().inherits( "KeramikStyle" ) ||
- QApplication::style().inherits( QWindowsStyle_String ) ||
- QApplication::style().inherits( "ThinKeramikStyle" ) ||
- QApplication::style().inherits( "PlastikStyle" ) )
- {
- aStyleSettings.SetMenuHighlightTextColor( toColor ( qMenuCG.highlightedText() ) );
- }
- else
- aStyleSettings.SetMenuHighlightTextColor( aMenuFore );
-
- // set special menubar highlight text color
- if ( QApplication::style().inherits( "HighContrastStyle" ) )
- ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.highlightedText() );
- else
- ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore;
-
- // set menubar rollover color
- if ( QApplication::style().styleHint( QStyle::SH_MenuBar_MouseTracking ) )
- {
- aStyleSettings.SetMenuBarRolloverColor( toColor ( qMenuCG.highlight() ) );
- aStyleSettings.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor );
- }
- else
- {
- aStyleSettings.SetMenuBarRolloverColor( aMenuBack );
- aStyleSettings.SetMenuBarRolloverTextColor( aMenuFore );
- }
- aStyleSettings.SetMenuBarHighlightTextColor(aStyleSettings.GetMenuHighlightTextColor());
-
- // Font
- aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() );
- aStyleSettings.SetMenuFont( aFont );
- }
-
- // Tool bar
- KToolBar *pToolBar = qMainWindow.toolBar();
- if ( pToolBar )
- {
- aFont = toFont( pToolBar->font(), rSettings.GetUILanguageTag().getLocale() );
- aStyleSettings.SetToolFont( aFont );
- }
-
- // Scroll bar size
- aStyleSettings.SetScrollBarSize( QApplication::style().pixelMetric( QStyle::PM_ScrollBarExtent ) );
-
- rSettings.SetStyleSettings( aStyleSettings );
-}
-
-SalGraphics* KDESalFrame::AcquireGraphics()
-{
- if( GetWindow() )
- {
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( ! m_aGraphics[i].bInUse )
- {
- m_aGraphics[i].bInUse = true;
- if( ! m_aGraphics[i].pGraphics )
- {
- m_aGraphics[i].pGraphics.reset (new KDESalGraphics() );
- m_aGraphics[i].pGraphics->Init( this, GetWindow(), GetScreenNumber() );
- }
- return m_aGraphics[i].pGraphics.get();
- }
- }
- }
-
- return nullptr;
-}
-
-void KDESalFrame::ReleaseGraphics( SalGraphics *pGraphics )
-{
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( m_aGraphics[i].pGraphics.get() == pGraphics )
- {
- m_aGraphics[i].bInUse = false;
- break;
- }
- }
-}
-
-void KDESalFrame::updateGraphics( bool bClear )
-{
- Drawable aDrawable = bClear ? None : GetWindow();
- for( int i = 0; i < nMaxGraphics; i++ )
- {
- if( m_aGraphics[i].bInUse )
- m_aGraphics[i].pGraphics->SetDrawable( aDrawable, GetScreenNumber() );
- }
-}
-
-KDESalFrame::~KDESalFrame()
-{
-}
-
-// KDESalInstance implementation
-
-SalFrame * KDESalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nStyle )
-{
- return new KDESalFrame( pParent, nStyle );
-}
-
-uno::Reference< ui::dialogs::XFilePicker2 > KDESalInstance::createFilePicker(
- const uno::Reference< uno::XComponentContext >& xMSF )
-{
- return uno::Reference< ui::dialogs::XFilePicker2 >(
- new UnxFilePicker( xMSF ) );
-}
-
-SalX11Display* KDESalInstance::CreateDisplay() const
-{
- return new SalKDEDisplay( QPaintDevice::x11AppDisplay() );
-}
-
-// KDESalData pieces
-
-// Create the widget painter so we have some control over
-// the destruction sequence, so Qt doesn't die in action.
-
-void KDEData::initNWF()
-{
- ImplSVData *pSVData = ImplGetSVData();
- // draw toolbars on separate lines
- pSVData->maNWFData.mbDockingAreaSeparateTB = true;
-
- pWidgetPainter = new WidgetPainter();
-}
-
-void KDEData::deInitNWF()
-{
- delete pWidgetPainter;
- pWidgetPainter = nullptr;
-
- // We have to destroy the style early
- QApplication::setStyle( nullptr );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */