00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "COSXClipboardAnyTextConverter.h"
00016 #include <algorithm>
00017
00018
00019
00020
00021
00022 COSXClipboardAnyTextConverter::COSXClipboardAnyTextConverter()
00023 {
00024
00025 }
00026
00027 COSXClipboardAnyTextConverter::~COSXClipboardAnyTextConverter()
00028 {
00029
00030 }
00031
00032 IClipboard::EFormat
00033 COSXClipboardAnyTextConverter::getFormat() const
00034 {
00035 return IClipboard::kText;
00036 }
00037
00038 CString
00039 COSXClipboardAnyTextConverter::fromIClipboard(const CString& data) const
00040 {
00041
00042 return doFromIClipboard(convertLinefeedToMacOS(data));
00043 }
00044
00045 CString
00046 COSXClipboardAnyTextConverter::toIClipboard(const CString& data) const
00047 {
00048
00049 return convertLinefeedToUnix(doToIClipboard(data));
00050 }
00051
00052 static
00053 bool
00054 isLF(char ch)
00055 {
00056 return (ch == '\n');
00057 }
00058
00059 static
00060 bool
00061 isCR(char ch)
00062 {
00063 return (ch == '\r');
00064 }
00065
00066 CString
00067 COSXClipboardAnyTextConverter::convertLinefeedToMacOS(const CString& src)
00068 {
00069
00070 CString copy = src;
00071
00072 std::replace_if(copy.begin(), copy.end(), isLF, '\r');
00073
00074 return copy;
00075 }
00076
00077 CString
00078 COSXClipboardAnyTextConverter::convertLinefeedToUnix(const CString& src)
00079 {
00080 CString copy = src;
00081
00082 std::replace_if(copy.begin(), copy.end(), isCR, '\n');
00083
00084 return copy;
00085 }