• Main Page
  • Classes
  • Files
  • File List

CXWindowsClipboardTextConverter.cpp

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include "CXWindowsClipboardTextConverter.h"
00020 #include "CUnicode.h"
00021 
00022 //
00023 // CXWindowsClipboardTextConverter
00024 //
00025 
00026 CXWindowsClipboardTextConverter::CXWindowsClipboardTextConverter(
00027                 Display* display, const char* name) :
00028     m_atom(XInternAtom(display, name, False))
00029 {
00030     // do nothing
00031 }
00032 
00033 CXWindowsClipboardTextConverter::~CXWindowsClipboardTextConverter()
00034 {
00035     // do nothing
00036 }
00037 
00038 IClipboard::EFormat
00039 CXWindowsClipboardTextConverter::getFormat() const
00040 {
00041     return IClipboard::kText;
00042 }
00043 
00044 Atom
00045 CXWindowsClipboardTextConverter::getAtom() const
00046 {
00047     return m_atom;
00048 }
00049 
00050 int
00051 CXWindowsClipboardTextConverter::getDataSize() const
00052 {
00053     return 8;
00054 }
00055 
00056 CString
00057 CXWindowsClipboardTextConverter::fromIClipboard(const CString& data) const
00058 {
00059     return CUnicode::UTF8ToText(data);
00060 }
00061 
00062 CString
00063 CXWindowsClipboardTextConverter::toIClipboard(const CString& data) const
00064 {
00065     // convert to UTF-8
00066     bool errors;
00067     CString utf8 = CUnicode::textToUTF8(data, &errors);
00068 
00069     // if there were decoding errors then, to support old applications
00070     // that don't understand UTF-8 but can report the exact binary
00071     // UTF-8 representation, see if the data appears to be UTF-8.  if
00072     // so then use it as is.
00073     if (errors && CUnicode::isUTF8(data)) {
00074         return data;
00075     }
00076 
00077     return utf8;
00078 }

Generated on Sat May 25 2013 00:00:04 for Synergy by  doxygen 1.7.1