~nobuto/ubuntu/natty/synergy/merge-from-experimental

« back to all changes in this revision

Viewing changes to lib/platform/CXWindowsClipboardTextConverter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Lutz
  • Date: 2003-10-31 19:36:30 UTC
  • Revision ID: james.westby@ubuntu.com-20031031193630-knbv79x5az7qh49y
Tags: upstream-1.0.14
ImportĀ upstreamĀ versionĀ 1.0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * synergy -- mouse and keyboard sharing utility
 
3
 * Copyright (C) 2002 Chris Schoeneman
 
4
 * 
 
5
 * This package is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * found in the file COPYING that should have accompanied this file.
 
8
 * 
 
9
 * This package is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 */
 
14
 
 
15
#include "CXWindowsClipboardTextConverter.h"
 
16
#include "CUnicode.h"
 
17
 
 
18
//
 
19
// CXWindowsClipboardTextConverter
 
20
//
 
21
 
 
22
CXWindowsClipboardTextConverter::CXWindowsClipboardTextConverter(
 
23
                                Display* display, const char* name) :
 
24
        m_atom(XInternAtom(display, name, False))
 
25
{
 
26
        // do nothing
 
27
}
 
28
 
 
29
CXWindowsClipboardTextConverter::~CXWindowsClipboardTextConverter()
 
30
{
 
31
        // do nothing
 
32
}
 
33
 
 
34
IClipboard::EFormat
 
35
CXWindowsClipboardTextConverter::getFormat() const
 
36
{
 
37
        return IClipboard::kText;
 
38
}
 
39
 
 
40
Atom
 
41
CXWindowsClipboardTextConverter::getAtom() const
 
42
{
 
43
        return m_atom;
 
44
}
 
45
 
 
46
int
 
47
CXWindowsClipboardTextConverter::getDataSize() const
 
48
{
 
49
        return 8;
 
50
}
 
51
 
 
52
CString
 
53
CXWindowsClipboardTextConverter::fromIClipboard(const CString& data) const
 
54
{
 
55
        return CUnicode::UTF8ToText(data);
 
56
}
 
57
 
 
58
CString
 
59
CXWindowsClipboardTextConverter::toIClipboard(const CString& data) const
 
60
{
 
61
        // convert to UTF-8
 
62
        bool errors;
 
63
        CString utf8 = CUnicode::textToUTF8(data, &errors);
 
64
 
 
65
        // if there were decoding errors then, to support old applications
 
66
        // that don't understand UTF-8 but can report the exact binary
 
67
        // UTF-8 representation, see if the data appears to be UTF-8.  if
 
68
        // so then use it as is.
 
69
        if (errors && CUnicode::isUTF8(data)) {
 
70
                return data;
 
71
        }
 
72
 
 
73
        return utf8;
 
74
}