You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.5 KiB
111 lines
3.5 KiB
/*
|
|
This file is part of the KDE project
|
|
Copyright 2001, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Library General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
This library 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
|
|
Library General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#include <tqtextcodec.h>
|
|
#include <tqradiobutton.h>
|
|
#include <tqbuttongroup.h>
|
|
|
|
#include <kdebug.h>
|
|
#include <klocale.h>
|
|
#include <kcharsets.h>
|
|
#include <kglobal.h>
|
|
#include <kapplication.h>
|
|
#include <kcombobox.h>
|
|
#include <kmessagebox.h>
|
|
|
|
#include <ExportDialogUI.h>
|
|
#include <ExportDialog.h>
|
|
|
|
AsciiExportDialog :: AsciiExportDialog(TQWidget* tqparent)
|
|
: KDialogBase(tqparent, 0, true, i18n("KWord's Plain Text Export Filter"), Ok|Cancel, No, true),
|
|
m_dialog(new ExportDialogUI(this))
|
|
{
|
|
|
|
kapp->restoreOverrideCursor();
|
|
|
|
TQStringList encodings;
|
|
encodings << i18n( "Descriptive encoding name", "Recommended ( %1 )" ).tqarg( "UTF-8" );
|
|
encodings << i18n( "Descriptive encoding name", "Locale ( %1 )" ).tqarg( TQTextCodec::codecForLocale()->name() );
|
|
encodings += KGlobal::charsets()->descriptiveEncodingNames();
|
|
// Add a few non-standard encodings, which might be useful for text files
|
|
const TQString description(i18n("Descriptive encoding name","Other ( %1 )"));
|
|
encodings << description.tqarg("Apple Roman"); // Apple
|
|
encodings << description.tqarg("IBM 850") << description.tqarg("IBM 866"); // MS DOS
|
|
encodings << description.tqarg("CP 1258"); // Windows
|
|
|
|
m_dialog->comboBoxEncoding->insertStringList(encodings);
|
|
|
|
setMainWidget(m_dialog);
|
|
|
|
}
|
|
|
|
AsciiExportDialog :: ~AsciiExportDialog(void)
|
|
{
|
|
kapp->setOverrideCursor(TQt::waitCursor);
|
|
}
|
|
|
|
TQTextCodec* AsciiExportDialog::getCodec(void) const
|
|
{
|
|
const TQString strCodec( KGlobal::charsets()->encodingForName( m_dialog->comboBoxEncoding->currentText() ) );
|
|
kdDebug(30502) << "Encoding: " << strCodec << endl;
|
|
|
|
bool ok = false;
|
|
TQTextCodec* codec = TQTextCodec::codecForName( strCodec.utf8() );
|
|
|
|
// If TQTextCodec has not found a valid encoding, so try with KCharsets.
|
|
if ( codec )
|
|
{
|
|
ok = true;
|
|
}
|
|
else
|
|
{
|
|
codec = KGlobal::charsets()->codecForName( strCodec, ok );
|
|
}
|
|
|
|
// Still nothing?
|
|
if ( !codec || !ok )
|
|
{
|
|
// Default: UTF-8
|
|
kdWarning(30502) << "Cannot find encoding:" << strCodec << endl;
|
|
// ### TODO: what tqparent to use?
|
|
KMessageBox::error( 0, i18n("Cannot find encoding: %1").tqarg( strCodec ) );
|
|
return 0;
|
|
}
|
|
|
|
return codec;
|
|
}
|
|
|
|
TQString AsciiExportDialog::getEndOfLine(void) const
|
|
{
|
|
TQString strReturn;
|
|
if (m_dialog->radioEndOfLineLF==m_dialog->buttonGroupEndOfLine->selected())
|
|
strReturn="\n";
|
|
else if (m_dialog->radioEndOfLineCRLF==m_dialog->buttonGroupEndOfLine->selected())
|
|
strReturn="\r\n";
|
|
else if (m_dialog->radioEndOfLineCR==m_dialog->buttonGroupEndOfLine->selected())
|
|
strReturn="\r";
|
|
else
|
|
strReturn="\n";
|
|
|
|
return strReturn;
|
|
}
|
|
|
|
#include <ExportDialog.moc>
|