/*
 * synergy -- mouse and keyboard sharing utility
 * Copyright (C) 2002 Chris Schoeneman
 * Copyright (C) 2006 Knut St. Osmundsen
 * 
 * This package is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * found in the file COPYING that should have accompanied this file.
 * 
 * This package is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef CPMCLIPBOARDANYTEXTCONVERTER_H
#define CPMCLIPBOARDANYTEXTCONVERTER_H

#include "CPMClipboard.h"

//! Convert to/from some text encoding
class CPMClipboardAnyTextConverter :
				public IPMClipboardConverter {
public:
	CPMClipboardAnyTextConverter();
	virtual ~CPMClipboardAnyTextConverter();

	// IPMClipboardConverter overrides
	virtual IClipboard::EFormat
						getFormat() const;
	virtual ULONG		getPMFormat() const = 0;
	virtual ULONG		getPMFormatInfo() const;
	virtual ULONG		fromIClipboard(const CString&) const;
	virtual void		freePMData(ULONG) const;
	virtual CString		toIClipboard(ULONG) const;

protected:
	//! Convert from IClipboard format
	/*!
	Do UTF-8 conversion only.  Memory handle allocation and
	linefeed conversion is done by this class.  doFromIClipboard()
	must include the nul terminator in the returned string (not
	including the CString's nul terminator).
	*/
	virtual CString		doFromIClipboard(const CString&) const = 0;

	//! Convert to IClipboard format
	/*!
	Do UTF-8 conversion only.  Memory handle allocation and
	linefeed conversion is done by this class.
	*/
	virtual CString		doToIClipboard(const CString&) const = 0;

private:
	CString				convertLinefeedToPM(const CString&) const;
	CString				convertLinefeedToUnix(const CString&) const;
};

#endif
