improved FLP-filter a lot
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@118 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
74
ChangeLog
74
ChangeLog
@@ -1,5 +1,79 @@
|
||||
2006-04-04 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/flp_import/unrtf/*:
|
||||
* plugins/flp_import/flp_import.cpp:
|
||||
use integrated unrtf-source into FLP-import-filter for converting
|
||||
RTF-comments to plain HTML which is usable with QTextEdit
|
||||
|
||||
2006-04-02 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* src/core/song_editor.cpp:
|
||||
set master-volume-slider correctly in songEditor::setMasterVolume()
|
||||
|
||||
* include/envelope_tab_widget.h:
|
||||
* src/core/envelope_tab_widget.cpp:
|
||||
* src/core/note_play_handle.cpp:
|
||||
- in envelopeTabWidget::releaseFrames():
|
||||
if the volume-envelope is used, do not check
|
||||
release-frames of other envelope-targets, as it is not
|
||||
interesting if they're beyond the end of the volume-envelope
|
||||
(silent so or so) - may result in less CPU-usage in some
|
||||
situations if the user set a bigger release to an envelope
|
||||
other than the volume-env
|
||||
- for arpeggio-base-notes only use number of release-frames of
|
||||
volume-envelope for m_releaseFramesToDo (for not creating silent notes
|
||||
in release-phase of arp-base-note)
|
||||
|
||||
* plugins/vibed/impulse_editor.cpp:
|
||||
use saw-wave as default shape for strings as it sounds much more like
|
||||
a typical guitar-string than a sine-wave
|
||||
|
||||
* plugins/triple_oscillator/triple_oscillator.h:
|
||||
* plugins/triple_oscillator/triple_oscillator.cpp:
|
||||
re-implement setParameter()-method for setting user-defined wave-shape
|
||||
(used by FLP-import-filter)
|
||||
|
||||
* plugins/flp_import/flp_import.cpp:
|
||||
- convert 3x Osc params to TripleOscillator-settings and load them
|
||||
- load Vibed-Plugin for Plucked!-instrument
|
||||
- load arpeggio-settings of channel
|
||||
- load filter-settings of channel
|
||||
- handle base-note of each channel
|
||||
- correct master-volume-calculation
|
||||
|
||||
2006-04-01 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/flp_import/flp_import.cpp:
|
||||
- hack for converting RTF-comment to HTML using unrtf (if installed)
|
||||
|
||||
2006-03-30 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/flp_import/flp_import.h:
|
||||
* plugins/flp_import/flp_import.cpp:
|
||||
- try to load samples correctly using FL Studio installation
|
||||
- recognize steps (not working properly yet)
|
||||
- set current pattern of project
|
||||
- separate handling of plugin-parameters (will allow support of FL
|
||||
presets later!)
|
||||
- added FLP_StepData (225) (not handled as format not known yet)
|
||||
- added FLP_EnvLfoParams (218) (not handled as format not known yet)
|
||||
- load envelope-settings of instrument-tracks
|
||||
|
||||
* src/core/track_container.cpp:
|
||||
disable journalling in destructor of trackContainer
|
||||
|
||||
* include/config_mgr.h:
|
||||
* include/setup_dialog.h:
|
||||
* src/core/config_mgr.cpp:
|
||||
* src/core/setup_dialog.cpp:
|
||||
support for setting path to installation directory of FL Studio
|
||||
|
||||
2006-03-29 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* include/song_editor.h:
|
||||
* src/core/song_editor.cpp:
|
||||
added setMasterVolume() and setMasterPitch()
|
||||
|
||||
* plugins/flp_import/flp_import.h:
|
||||
* plugins/flp_import/flp_import.cpp:
|
||||
- read text-len correctly
|
||||
|
||||
4
TODO
4
TODO
@@ -1,3 +1,7 @@
|
||||
- do REAL release in envelopes (can't be precalculated as it depends on key-press-duration/rest of envelope)
|
||||
- correctly load steps/dots from FLP-files
|
||||
- vibed-plugin: do not crash at destruction
|
||||
- convert FL-Plucked!-parameters to Vibed-parameters
|
||||
- in flp-import-filter: merge play-list-items if possible
|
||||
- integrated sample-browser in context-menu of sample-track/-tco
|
||||
- font-size-scaling-coefficient in setup-dialog
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT(lmms, 0.1.4-cvs20060329, tobydox/at/users/dot/sourceforge/dot/net)
|
||||
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060329)
|
||||
AC_INIT(lmms, 0.1.4-cvs20060404, tobydox/at/users/dot/sourceforge/dot/net)
|
||||
AM_INIT_AUTOMAKE(lmms, 0.1.4-cvs20060404)
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
class QPixmap;
|
||||
|
||||
class automatableButtonGroup;
|
||||
class flpImport;
|
||||
class instrumentTrack;
|
||||
class comboBox;
|
||||
class groupBox;
|
||||
@@ -131,6 +132,8 @@ private:
|
||||
|
||||
comboBox * m_arpModeComboBox;
|
||||
|
||||
friend class flpImport;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -132,6 +132,11 @@ public:
|
||||
return( m_vstDir );
|
||||
}
|
||||
|
||||
const QString & flDir( void ) const
|
||||
{
|
||||
return( m_flDir );
|
||||
}
|
||||
|
||||
const QString & value( const QString & _class,
|
||||
const QString & _attribute ) const;
|
||||
void setValue( const QString & _class, const QString & _attribute,
|
||||
@@ -145,6 +150,7 @@ public slots:
|
||||
void setWorkingDir( const QString & _wd );
|
||||
void setVSTDir( const QString & _vd );
|
||||
void setArtworkDir( const QString & _ad );
|
||||
void setFLDir( const QString & _fd );
|
||||
|
||||
|
||||
protected slots:
|
||||
@@ -182,6 +188,7 @@ private:
|
||||
QString m_artworkDir;
|
||||
QString m_pluginDir;
|
||||
QString m_vstDir;
|
||||
QString m_flDir;
|
||||
|
||||
typedef vvector<QPair<QString, QString> > stringPairVector;
|
||||
typedef QMap<QString, stringPairVector> settingsMap;
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
// set whether debug-stuff (like messages on the console, asserts and other
|
||||
// additional range-checkings) should be compiled
|
||||
|
||||
#ifdef LMMS_DEBUG
|
||||
/*#ifdef LMMS_DEBUG*/
|
||||
#include <assert.h>
|
||||
#include <cstdio>
|
||||
#endif
|
||||
/*#endif*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,6 +66,8 @@ class pixmapButton;
|
||||
class tempoSyncKnob;
|
||||
|
||||
|
||||
class flpImport;
|
||||
|
||||
|
||||
class envelopeAndLFOWidget : public QWidget, public journallingObject,
|
||||
public specialBgHandlingWidget
|
||||
@@ -185,6 +187,7 @@ private:
|
||||
|
||||
|
||||
friend class envelopeTabWidget;
|
||||
friend class flpImport;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ class notePlayHandle;
|
||||
class pixmapButton;
|
||||
class tabWidget;
|
||||
|
||||
class flpImport;
|
||||
|
||||
|
||||
class envelopeTabWidget : public QWidget, public journallingObject
|
||||
{
|
||||
@@ -77,8 +79,8 @@ public:
|
||||
TARGET_COUNT
|
||||
} ;
|
||||
|
||||
f_cnt_t envFrames( void );
|
||||
f_cnt_t releaseFrames( void );
|
||||
f_cnt_t envFrames( const bool _only_vol = FALSE );
|
||||
f_cnt_t releaseFrames( const bool _only_vol = FALSE );
|
||||
|
||||
float FASTCALL volumeLevel( notePlayHandle * _n, const f_cnt_t _frame );
|
||||
|
||||
@@ -102,6 +104,8 @@ private:
|
||||
knob * m_filterCutKnob;
|
||||
knob * m_filterResKnob;
|
||||
|
||||
friend class flpImport;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -69,6 +69,8 @@ class pianoWidget;
|
||||
class presetPreviewPlayHandle;
|
||||
class surroundArea;
|
||||
|
||||
class flpImport;
|
||||
|
||||
|
||||
|
||||
class instrumentTrack : public QWidget, public track, public midiEventProcessor
|
||||
@@ -255,6 +257,7 @@ private:
|
||||
friend class instrumentTrackButton;
|
||||
friend class notePlayHandle;
|
||||
friend class presetPreviewPlayHandle;
|
||||
friend class flpImport;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
@@ -82,6 +82,7 @@ private slots:
|
||||
void setWorkingDir( const QString & _wd );
|
||||
void setVSTDir( const QString & _vd );
|
||||
void setArtworkDir( const QString & _ad );
|
||||
void setFLDir( const QString & _fd );
|
||||
|
||||
// audio settings widget
|
||||
void audioInterfaceChanged( const QString & _driver );
|
||||
@@ -102,6 +103,7 @@ private slots:
|
||||
void openWorkingDir( void );
|
||||
void openVSTDir( void );
|
||||
void openArtworkDir( void );
|
||||
void openFLDir( void );
|
||||
|
||||
|
||||
void toggleDisableChActInd( bool _disabled );
|
||||
@@ -125,10 +127,12 @@ private:
|
||||
QLineEdit * m_wdLineEdit;
|
||||
QLineEdit * m_vdLineEdit;
|
||||
QLineEdit * m_adLineEdit;
|
||||
QLineEdit * m_fdLineEdit;
|
||||
|
||||
QString m_workingDir;
|
||||
QString m_vstDir;
|
||||
QString m_artworkDir;
|
||||
QString m_flDir;
|
||||
|
||||
|
||||
bool m_disableChActInd;
|
||||
|
||||
@@ -329,14 +329,6 @@ void audioFileProcessor::loadSettings( const QDomElement & _this )
|
||||
|
||||
|
||||
|
||||
QString audioFileProcessor::nodeName( void ) const
|
||||
{
|
||||
return( audiofileprocessor_plugin_descriptor.name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void audioFileProcessor::setParameter( const QString & _param,
|
||||
const QString & _value )
|
||||
{
|
||||
@@ -353,6 +345,14 @@ void audioFileProcessor::setParameter( const QString & _param,
|
||||
|
||||
|
||||
|
||||
QString audioFileProcessor::nodeName( void ) const
|
||||
{
|
||||
return( audiofileprocessor_plugin_descriptor.name );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Uint32 audioFileProcessor::getBeatLen( notePlayHandle * _n ) const
|
||||
{
|
||||
const float freq_factor = BASE_FREQ /
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
AUTOMAKE_OPTIONS = foreign 1.4
|
||||
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include -I.
|
||||
INCLUDES = -I$(top_srcdir)/include -I. -I./unrtf
|
||||
|
||||
EXTRA_DIST = $(wildcard unrtf/*.c unrtf/*.h)
|
||||
|
||||
AM_CXXFLAGS := $(AM_CXXFLAGS) $(QT_CXXFLAGS) -DPLUGIN_NAME="flpimport"
|
||||
|
||||
|
||||
@@ -32,6 +32,18 @@
|
||||
#include "instrument_track.h"
|
||||
#include "pattern.h"
|
||||
#include "project_journal.h"
|
||||
#include "instrument.h"
|
||||
#include "config_mgr.h"
|
||||
#include "envelope_tab_widget.h"
|
||||
#include "envelope_and_lfo_widget.h"
|
||||
#include "knob.h"
|
||||
#include "oscillator.h"
|
||||
#include "basic_filters.h"
|
||||
#include "combobox.h"
|
||||
#include "group_box.h"
|
||||
#include "arp_and_chords_tab_widget.h"
|
||||
#include "tempo_sync_knob.h"
|
||||
#include "piano_widget.h"
|
||||
|
||||
|
||||
#ifdef QT4
|
||||
@@ -39,15 +51,16 @@
|
||||
#include <Qt/QtXml>
|
||||
#include <QApplication>
|
||||
#include <QProgressDialog>
|
||||
#include <QDir>
|
||||
#include <QBuffer>
|
||||
|
||||
#else
|
||||
|
||||
#include <qdom.h>
|
||||
#include <qapplication.h>
|
||||
#include <qprogressdialog.h>
|
||||
|
||||
#define pos at
|
||||
#define setValue setProgress
|
||||
#include <qdir.h>
|
||||
#include <qbuffer.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -70,6 +83,27 @@ plugin::descriptor flpimport_plugin_descriptor =
|
||||
new QPixmap()
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
// unrtf-stuff
|
||||
#include "defs.h"
|
||||
#include "main.h"
|
||||
#include "html.h"
|
||||
#include "word.h"
|
||||
#include "hash.h"
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
OutputPersonality * op = NULL;
|
||||
int lineno = 0;
|
||||
#define inline_mode 0
|
||||
#define debug_mode 0
|
||||
#define nopict_mode 1
|
||||
#define verbose_mode 0
|
||||
#define simple_mode 0
|
||||
|
||||
extern QString outstring;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +112,7 @@ void dump_mem( const void * buffer, uint n_bytes )
|
||||
uchar * cp = (uchar *) buffer;
|
||||
for( uint k = 0; k < n_bytes; ++k )
|
||||
{
|
||||
printf( "%02x ", ( cp[k] > 31 || cp[k] < 7 ) ? cp[k] : '.' );
|
||||
printf( "%02x ", (unsigned int)cp[k] );//( cp[k] > 31 || cp[k] < 7 ) ? cp[k] : '.' );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
@@ -189,10 +223,19 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
printf( "channels: %d\n", num_channels );
|
||||
|
||||
instrumentTrack * it = NULL;
|
||||
instrument * it_inst = NULL;
|
||||
flPlugins cur_plugin = FL_Plugin_Undef;
|
||||
|
||||
int current_pattern = 0;
|
||||
char * text = NULL;
|
||||
int text_len = 0;
|
||||
Uint32 text_len = 0;
|
||||
vlist<instrumentTrack *> i_tracks;
|
||||
int project_cur_pat = 0;
|
||||
|
||||
int step_pattern = 0;
|
||||
int last_step_pos = 0;
|
||||
|
||||
int env_lfo_target = 0;
|
||||
|
||||
int ev_cnt = 0;
|
||||
|
||||
@@ -208,10 +251,11 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
ev_cnt = 0;
|
||||
#ifdef QT4
|
||||
qApp->processEvents( QEventLoop::AllEvents, 100 );
|
||||
pd.setValue( i_tracks.size() );
|
||||
#else
|
||||
qApp->processEvents( 100 );
|
||||
pd.setProgress( i_tracks.size() );
|
||||
#endif
|
||||
pd.setValue( i_tracks.size() );
|
||||
|
||||
if( pd.wasCanceled() )
|
||||
{
|
||||
@@ -237,13 +281,14 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
if( ev >= FLP_Text )
|
||||
{
|
||||
text_len = data & 0x7F;
|
||||
int shift = 0;
|
||||
Uint8 shift = 0;
|
||||
while( data & 0x80 )
|
||||
{
|
||||
data = readByte();
|
||||
//text_len = ( text_len << 7 ) | ( data & 0x7F );
|
||||
text_len = text_len | ( ( data & 0x7F ) << ( shift += 7 ) );
|
||||
text_len = text_len | ( ( data & 0x7F ) <<
|
||||
( shift += 7 ) );
|
||||
}
|
||||
|
||||
delete[] text;
|
||||
text = new char[text_len+1];
|
||||
if( readBlock( text, text_len ) <= 0 )
|
||||
@@ -251,6 +296,7 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
printf( "could not read string (len: %d)\n",
|
||||
text_len );
|
||||
}
|
||||
|
||||
text[text_len] = 0;
|
||||
}
|
||||
|
||||
@@ -281,7 +327,8 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
case FLP_MainVol:
|
||||
printf( "main-volume: %d\n", data );
|
||||
_tc->eng()->getSongEditor()->setMasterVolume(
|
||||
static_cast<volume>( data ) );
|
||||
static_cast<volume>( data * 100 /
|
||||
128 ) );
|
||||
break;
|
||||
|
||||
case FLP_PatLength:
|
||||
@@ -303,15 +350,7 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
case FLP_MixSliceNum:
|
||||
printf( "mix slice num: %d\n", data );
|
||||
break;
|
||||
/*
|
||||
case 31:
|
||||
case 32:
|
||||
case 33:
|
||||
case 34:
|
||||
case 35:
|
||||
case 36:
|
||||
printf( "ev: %d data: %d\n", ev, data );
|
||||
break;*/
|
||||
|
||||
|
||||
// WORD EVENTS
|
||||
case FLP_NewChan:
|
||||
@@ -321,9 +360,15 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
track::create( track::CHANNEL_TRACK, _tc->eng()->getBBEditor() ) );
|
||||
assert( it != NULL );
|
||||
i_tracks.push_back( it );
|
||||
it->loadInstrument( "tripleoscillator" );
|
||||
it_inst = it->loadInstrument(
|
||||
"audiofileprocessor" );
|
||||
it->toggledInstrumentTrackButton( FALSE );
|
||||
|
||||
// reset some values
|
||||
step_pattern = 0;
|
||||
last_step_pos = 0;
|
||||
env_lfo_target = 0;
|
||||
|
||||
break;
|
||||
|
||||
case FLP_NewPat:
|
||||
@@ -336,7 +381,7 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
break;
|
||||
|
||||
case FLP_CurrentPatNum:
|
||||
printf( "current pattern: %d\n", data );
|
||||
project_cur_pat = data;
|
||||
break;
|
||||
|
||||
case FLP_FX:
|
||||
@@ -349,33 +394,28 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
break;
|
||||
|
||||
case FLP_CutOff:
|
||||
printf( "cutoff (for cur channel?): %d\n",
|
||||
data );
|
||||
printf( "cutoff (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_PreAmp:
|
||||
printf( "pre-amp (for cur channel?): %d\n",
|
||||
data );
|
||||
printf( "pre-amp (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_Decay:
|
||||
printf( "decay (for cur channel?): %d\n",
|
||||
data );
|
||||
printf( "decay (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_Attack:
|
||||
printf( "attack (for cur channel?): %d\n",
|
||||
data );
|
||||
printf( "attack (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_MainPitch:
|
||||
printf( "main-pitch: %d\n", data );
|
||||
_tc->eng()->getSongEditor()->setMasterPitch(
|
||||
data );
|
||||
break;
|
||||
|
||||
case FLP_Resonance:
|
||||
printf( "reso (for cur channel?): %d\n", data );
|
||||
printf( "reso (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_LoopBar:
|
||||
@@ -394,6 +434,21 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
printf( "shift delay: %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_Dot:
|
||||
{
|
||||
printf( "dot/step at: %d\n", data );
|
||||
const int pos = data & 0xff;
|
||||
if( last_step_pos > pos )
|
||||
{
|
||||
++step_pattern;
|
||||
}
|
||||
last_step_pos = pos;
|
||||
m_steps.push_back(
|
||||
( ( i_tracks.size() - 1 ) << 16 ) |
|
||||
( pos + 16 * step_pattern ) );
|
||||
break;
|
||||
}
|
||||
|
||||
// DWORD EVENTS
|
||||
case FLP_Color:
|
||||
printf( "color r:%d g:%d b:%d\n",
|
||||
@@ -416,16 +471,25 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
printf( "cut cut by: %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_MiddleNote:
|
||||
data += 8;
|
||||
it->setBaseTone( static_cast<tones>( data %
|
||||
NOTES_PER_OCTAVE ) );
|
||||
it->setBaseOctave( static_cast<octaves>( data /
|
||||
NOTES_PER_OCTAVE ) );
|
||||
it->m_pianoWidget->update();
|
||||
break;
|
||||
|
||||
case FLP_DelayReso:
|
||||
printf( "delay resonance: %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_Reverb:
|
||||
printf( "reverb: %d\n", data );
|
||||
printf( "reverb (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
case FLP_IntStretch:
|
||||
printf( "int stretch: %d\n", data );
|
||||
printf( "int stretch (sample): %d\n", data );
|
||||
break;
|
||||
|
||||
// TEXT EVENTS
|
||||
@@ -441,36 +505,113 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
break;
|
||||
|
||||
case FLP_Text_CommentRTF:
|
||||
_tc->eng()->getProjectNotes()->setText( text );
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.setRawData( text, text_len );
|
||||
QBuffer buf( ba );
|
||||
#ifndef QT3
|
||||
buf.open( QBuffer::ReadOnly );
|
||||
#else
|
||||
buf.open( IO_ReadOnly );
|
||||
#endif
|
||||
op = html_init();
|
||||
hash_init();
|
||||
Word * word = word_read( &buf );
|
||||
QString out;
|
||||
word_print( word, out );
|
||||
word_free( word );
|
||||
op_free( op );
|
||||
ba.resetRawData( text, text_len );
|
||||
|
||||
_tc->eng()->getProjectNotes()->setText( out );
|
||||
outstring = "";
|
||||
#if 0
|
||||
#warning HACK !!! - replace by integrating unrtf-source
|
||||
system(
|
||||
QString( "echo \"%1\" > /tmp/flp_rtf_comment.rtf ; unrtf -n --html /tmp/flp_rtf_comment.rtf > /tmp/flp_rtf_comment.html" ).arg( text ).ascii() );
|
||||
QFile f( "/tmp/flp_rtf_comment.html" );
|
||||
f.open( IO_ReadOnly );
|
||||
char * out = new char[f.size()+1];
|
||||
f.readBlock( out, f.size() );
|
||||
_tc->eng()->getProjectNotes()->setText( out );
|
||||
f.remove();
|
||||
|
||||
delete[] out;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_Text_Title:
|
||||
printf( "project title: %s\n", text );
|
||||
break;
|
||||
|
||||
case FLP_Text_SampleFileName:
|
||||
printf( "sample for current channel: %s\n",
|
||||
text );
|
||||
{
|
||||
if( it_inst == NULL )
|
||||
{
|
||||
printf( "!! tried to set sample for "
|
||||
"instrument but no channel or "
|
||||
"instrument was "
|
||||
"created so far\n" );
|
||||
break;
|
||||
}
|
||||
QString dir = text;
|
||||
/* if( dir.mid( 1, 11 ) == "Instruments" )
|
||||
{
|
||||
dir = "\\Patches\\Packs" +
|
||||
dir.mid( 12 );
|
||||
}*/
|
||||
dir.replace( '\\', QDir::separator() );
|
||||
if( QFileInfo( configManager::inst()->flDir() +
|
||||
"/Data/" ).exists() )
|
||||
{
|
||||
dir = configManager::inst()->flDir() +
|
||||
"/Data/" + dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
// FL 3 compat
|
||||
dir = configManager::inst()->flDir() +
|
||||
"/Samples/" + dir;
|
||||
}
|
||||
it_inst->setParameter( "samplefile", dir );
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_Version:
|
||||
printf( "FL Version: %s\n", text );
|
||||
break;
|
||||
|
||||
case FLP_Text_PluginName:
|
||||
{
|
||||
instrument * new_inst = NULL;
|
||||
if( QString( text ) == "3x Osc" )
|
||||
{
|
||||
printf( "loading TripleOscillator for "
|
||||
"3x Osc\n" );
|
||||
it->loadInstrument(
|
||||
"3x Osc\n" );
|
||||
new_inst = it->loadInstrument(
|
||||
"tripleoscillator" );
|
||||
cur_plugin = FL_Plugin_3x_Osc;
|
||||
}
|
||||
else if( QString( text ) == "Plucked!" )
|
||||
{
|
||||
printf( "loading Vibed for Plucked!\n"
|
||||
);
|
||||
new_inst = it->loadInstrument(
|
||||
"vibedstrings" );
|
||||
cur_plugin = FL_Plugin_Plucked;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "unsupported plugin: %s\n",
|
||||
printf( "unsupported plugin: %s!\n",
|
||||
text );
|
||||
}
|
||||
if( new_inst != NULL )
|
||||
{
|
||||
it_inst = new_inst;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_Delay:
|
||||
printf( "delay-data:\n" );
|
||||
@@ -482,21 +623,126 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
break;
|
||||
|
||||
case FLP_PluginParams:
|
||||
printf( "plugin params:\n" );
|
||||
dump_mem( text, text_len );
|
||||
if( it_inst != NULL &&
|
||||
cur_plugin != FL_Plugin_Undef )
|
||||
{
|
||||
processPluginParams( cur_plugin,
|
||||
(const char *) text,
|
||||
text_len, it_inst );
|
||||
cur_plugin = FL_Plugin_Undef;
|
||||
}
|
||||
break;
|
||||
|
||||
case FLP_ChanParams:
|
||||
printf( "plugin params:\n" );
|
||||
dump_mem( text, text_len );
|
||||
break;
|
||||
|
||||
case FLP_PatternData:
|
||||
{
|
||||
printf( "pattern data:\n" );
|
||||
const arpAndChordsTabWidget::arpDirections
|
||||
mappedArpDir[] =
|
||||
{
|
||||
arpAndChordsTabWidget::OFF,
|
||||
arpAndChordsTabWidget::UP,
|
||||
arpAndChordsTabWidget::DOWN,
|
||||
arpAndChordsTabWidget::UP_AND_DOWN,
|
||||
arpAndChordsTabWidget::UP_AND_DOWN,
|
||||
arpAndChordsTabWidget::RANDOM
|
||||
} ;
|
||||
const Uint32 * p = (const Uint32 *) text;
|
||||
arpAndChordsTabWidget * actw = it->m_arpWidget;
|
||||
actw->m_arpDirectionBtnGrp->setValue(
|
||||
mappedArpDir[p[10]] - 1 );
|
||||
actw->m_arpRangeKnob->setValue( p[11] );
|
||||
actw->m_arpComboBox->setValue( p[12] );
|
||||
actw->m_arpTimeKnob->setValue( p[13] / 8.0f );
|
||||
//// 100.0f );
|
||||
actw->m_arpGateKnob->setValue( p[14] * 100.0f /
|
||||
48.0f );
|
||||
actw->m_arpGroupBox->setState(
|
||||
mappedArpDir[p[10]] !=
|
||||
arpAndChordsTabWidget::OFF );
|
||||
printf( "channel params: " );
|
||||
dump_mem( text, text_len );
|
||||
//printf( "channel params: arpdir: %d range: %d time: %d gate: %d\n", p[10], p[11], p[13], p[14] );
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_EnvLfoParams:
|
||||
{
|
||||
const Uint32 * p = (const Uint32 *) text;
|
||||
printf( "envelope and lfo params: " );
|
||||
dump_mem( text, text_len );
|
||||
envelopeTabWidget * etw = it->m_envWidget;
|
||||
envelopeAndLFOWidget * elw = NULL;
|
||||
switch( env_lfo_target )
|
||||
{
|
||||
case 1:
|
||||
elw = etw->m_envLFOWidgets[envelopeTabWidget::VOLUME];
|
||||
break;
|
||||
case 2:
|
||||
elw = etw->m_envLFOWidgets[envelopeTabWidget::CUT];
|
||||
break;
|
||||
case 3:
|
||||
elw = etw->m_envLFOWidgets[envelopeTabWidget::RES];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++env_lfo_target;
|
||||
if( elw == NULL )
|
||||
{
|
||||
break;
|
||||
}
|
||||
const float scaling = 0.8f / 65536.0f;
|
||||
elw->m_predelayKnob->setValue( p[2] * scaling );
|
||||
elw->m_attackKnob->setValue( p[3] * scaling );
|
||||
elw->m_holdKnob->setValue( p[4] * scaling );
|
||||
elw->m_decayKnob->setValue( p[5] * scaling );
|
||||
elw->m_sustainKnob->setValue( p[6] * scaling );
|
||||
elw->m_releaseKnob->setValue( p[7] * scaling );
|
||||
elw->m_amountKnob->setValue( p[1] ? 1 : 0 );
|
||||
elw->updateSampleVars();
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_FilterParams:
|
||||
{
|
||||
const basicFilters<>::filterTypes
|
||||
mappedFilter[] =
|
||||
{
|
||||
basicFilters<>::LOWPASS,// fast LP
|
||||
basicFilters<>::LOWPASS,
|
||||
basicFilters<>::BANDPASS_CSG,
|
||||
basicFilters<>::HIPASS,
|
||||
basicFilters<>::NOTCH,
|
||||
basicFilters<>::DOUBLE_LOWPASS,
|
||||
basicFilters<>::LOWPASS,
|
||||
basicFilters<>::DOUBLE_LOWPASS
|
||||
} ;
|
||||
Uint32 * p = (Uint32 *) text;
|
||||
envelopeTabWidget * etw = it->m_envWidget;
|
||||
/* printf( "filter values: " );
|
||||
for( int i = 0; i < 6; ++i )
|
||||
{
|
||||
printf( "%d ", ((Sint32*)text)[i] );
|
||||
}
|
||||
printf( "\n" );*/
|
||||
etw->m_filterComboBox->setValue(
|
||||
mappedFilter[p[5]] );
|
||||
etw->m_filterCutKnob->setValue( p[3] / 255.0 *
|
||||
( etw->m_filterCutKnob->maxValue() -
|
||||
etw->m_filterCutKnob->minValue() ) +
|
||||
etw->m_filterCutKnob->minValue() );
|
||||
etw->m_filterResKnob->setValue( p[4] / 512.0 *
|
||||
( etw->m_filterResKnob->maxValue() -
|
||||
etw->m_filterResKnob->minValue() ) +
|
||||
etw->m_filterResKnob->minValue() );
|
||||
etw->m_filterGroupBox->setState( p[3] < 256 );
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_PatternNotes:
|
||||
{
|
||||
//dump_mem( text, text_len );
|
||||
const int bpn = 20;
|
||||
for( int i = 0; i*bpn < text_len; ++i )
|
||||
for( Uint32 i = 0; i*bpn < text_len; ++i )
|
||||
{
|
||||
int ch = *( text + i*bpn + 6 );
|
||||
int pos = *( (int *)( text + i*bpn ) );
|
||||
@@ -518,6 +764,35 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
break;
|
||||
}
|
||||
|
||||
case FLP_StepData:
|
||||
{
|
||||
printf( "step data:\n" );
|
||||
dump_mem( text, text_len );
|
||||
#if 0
|
||||
const int bpn = 20;
|
||||
for( int i = 0; i*bpn < text_len; ++i )
|
||||
{
|
||||
int ch = *( text + i*bpn + 6 );
|
||||
int pos = *( (int *)( text + i*bpn ) );
|
||||
int key = *( text + i*bpn + 12 );
|
||||
int len = *( (int*)( text + i*bpn +
|
||||
8 ) );
|
||||
pos /= 6;
|
||||
len /= 6;
|
||||
/*note n( NULL, len, pos );
|
||||
n.setKey( key );
|
||||
m_notes.push_back( qMakePair(
|
||||
num_channels * current_pattern + ch, n ) );*/
|
||||
|
||||
//printf( "note on channel %d at pos %d with key %d and length %d ", (int)*((text+i*bpn+6)), *((int*)(text+i*bpc)), (int) *(text+i*bpc+12), (int) *((int*)(text+i*bpc+8)));
|
||||
//printf( "step-note (?) on channel %d at pos %d with key %d and length %d\n", ch, pos, key, len );
|
||||
|
||||
dump_mem( text+i*bpn, bpn );
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if( ev >= FLP_Text )
|
||||
{
|
||||
@@ -529,12 +804,34 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
else
|
||||
{
|
||||
printf( "!! handling of FLP-event %d "
|
||||
"not implemented yet.\n", ev );
|
||||
"not implemented yet "
|
||||
"(data=%d).\n", ev, data );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// process all steps
|
||||
for( stepVector::const_iterator it = m_steps.begin();
|
||||
it != m_steps.end(); ++it )
|
||||
{
|
||||
const int ch = ( *it ) >> 16;
|
||||
const csize pat = ( ( *it ) & 0xffff ) / 16;
|
||||
const csize pos = ( ( ( *it ) & 0xffff ) % 16 ) * 4;
|
||||
while( _tc->eng()->getBBEditor()->numOfBBs() <= pat )
|
||||
{
|
||||
track::create( track::BB_TRACK,
|
||||
_tc->eng()->getSongEditor() );
|
||||
}
|
||||
pattern * p = dynamic_cast<pattern *>(
|
||||
i_tracks[ch]->getTCO( pat ) );
|
||||
if( p == NULL )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p->setNoteAt( pos / 4, note( NULL, -1, pos ) );
|
||||
}
|
||||
|
||||
// now process all notes
|
||||
for( patternNoteVector::const_iterator it = m_notes.begin();
|
||||
it != m_notes.end(); ++it )
|
||||
@@ -571,6 +868,8 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
tco->movePosition( midiTime( ( ( *it ) & 0xffff ) * 64 ) );
|
||||
}
|
||||
|
||||
_tc->eng()->getBBEditor()->setCurrentBB( project_cur_pat );
|
||||
|
||||
_tc->eng()->getProjectJournal()->setJournalling( is_journ );
|
||||
return( TRUE );
|
||||
}
|
||||
@@ -578,6 +877,75 @@ bool flpImport::tryImport( trackContainer * _tc )
|
||||
|
||||
|
||||
|
||||
bool flpImport::processPluginParams( const flPlugins _plugin,
|
||||
const char * _data,
|
||||
const int _data_len, instrument * _i )
|
||||
{
|
||||
printf( "plugin params for plugin %d (%d bytes): ", _plugin,
|
||||
_data_len );
|
||||
dump_mem( _data, _data_len );
|
||||
switch( _plugin )
|
||||
{
|
||||
case FL_Plugin_3x_Osc:
|
||||
{
|
||||
const oscillator::waveShapes mapped_3xOsc_Shapes[] =
|
||||
{
|
||||
oscillator::SIN_WAVE,
|
||||
oscillator::TRIANGLE_WAVE,
|
||||
oscillator::SQUARE_WAVE,
|
||||
oscillator::SAW_WAVE,
|
||||
oscillator::SQUARE_WAVE, // square-sin
|
||||
oscillator::WHITE_NOISE_WAVE,
|
||||
oscillator::USER_DEF_WAVE
|
||||
} ;
|
||||
|
||||
QDomDocument dd;
|
||||
QDomElement de = dd.createElement( _i->nodeName() );
|
||||
de.setAttribute( "modalgo1", oscillator::MIX );
|
||||
de.setAttribute( "modalgo2", oscillator::MIX );
|
||||
for( Uint8 i = 0; i < 3; ++i )
|
||||
{
|
||||
const Sint32 * d = (const Sint32 *)( _data +
|
||||
i * 28 );
|
||||
QString is = QString::number( i );
|
||||
de.setAttribute( "vol" + is,
|
||||
QString::number( d[0] * 100 / 128 ) );
|
||||
de.setAttribute( "pan" + is,
|
||||
QString::number( d[1] ) );
|
||||
de.setAttribute( "coarse" + is,
|
||||
QString::number( d[3] ) );
|
||||
de.setAttribute( "finel" + is,
|
||||
QString::number( d[4] - d[6] / 2 ) );
|
||||
de.setAttribute( "finer" + is,
|
||||
QString::number( d[4] + d[6] / 2 ) );
|
||||
de.setAttribute( "stphdetun" + is,
|
||||
QString::number( d[5] ) );
|
||||
de.setAttribute( "wavetype" + is,
|
||||
QString::number(
|
||||
mapped_3xOsc_Shapes[d[2]] ) );
|
||||
}
|
||||
de.setAttribute( "vol0", QString::number( 100 ) );
|
||||
// now apply the prepared plugin-state
|
||||
_i->restoreState( de );
|
||||
break;
|
||||
}
|
||||
|
||||
case FL_Plugin_Plucked:
|
||||
{
|
||||
// TODO: setup vibed-instrument
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
printf( "handling of plugin params not implemented "
|
||||
"for current plugin\n" );
|
||||
break;
|
||||
}
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -589,8 +957,19 @@ plugin * lmms_plugin_main( void * _data )
|
||||
}
|
||||
|
||||
|
||||
// include unrtf-source
|
||||
#include "attr.c"
|
||||
#include "convert.c"
|
||||
#include "error.c"
|
||||
#include "hash.c"
|
||||
#include "html.c"
|
||||
#include "malloc.c"
|
||||
#include "output.c"
|
||||
#include "parse.c"
|
||||
#include "util.c"
|
||||
#include "word.c"
|
||||
|
||||
}
|
||||
|
||||
|
||||
#undef pos
|
||||
#undef setValue
|
||||
|
||||
@@ -155,15 +155,31 @@ enum flpEvents
|
||||
FLP_PluginParams = FLP_Text + 21,
|
||||
FLP_ChanParams = FLP_Text + 23,// block of various channel
|
||||
// params (can grow)
|
||||
FLP_PatternData = FLP_Text + 32,
|
||||
FLP_EnvLfoParams = FLP_Text + 26,
|
||||
FLP_FilterParams = FLP_Text + 27,
|
||||
FLP_PatternNotes = FLP_Text + 32,
|
||||
FLP_StepData = FLP_Text + 33,
|
||||
|
||||
FLP_CmdCount
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
enum flPlugins
|
||||
{
|
||||
FL_Plugin_3x_Osc,
|
||||
FL_Plugin_Sampler,
|
||||
FL_Plugin_Plucked,
|
||||
FL_Plugin_SimSynth,
|
||||
FL_Plugin_DX10,
|
||||
FL_Plugin_Sytrus,
|
||||
FL_Plugin_WASP,
|
||||
FL_Plugin_Undef
|
||||
} ;
|
||||
|
||||
|
||||
class instrument;
|
||||
|
||||
|
||||
class flpImport : public importFilter
|
||||
{
|
||||
@@ -175,6 +191,9 @@ public:
|
||||
private:
|
||||
virtual bool tryImport( trackContainer * _tc );
|
||||
|
||||
bool processPluginParams( const flPlugins _plugin, const char * _data,
|
||||
const int _data_len, instrument * _i );
|
||||
|
||||
inline int readInt( int _bytes )
|
||||
{
|
||||
int c, value = 0;
|
||||
@@ -204,31 +223,6 @@ private:
|
||||
value |= readByte() << 8;
|
||||
return( value );
|
||||
}
|
||||
/* inline int readVar( void )
|
||||
{
|
||||
int c = readByte();
|
||||
int value = c & 0x7f;
|
||||
if( c & 0x80 )
|
||||
{
|
||||
c = readByte();
|
||||
value = ( value << 7 ) | ( c & 0x7f );
|
||||
if( c & 0x80 )
|
||||
{
|
||||
c = readByte();
|
||||
value = ( value << 7 ) | ( c & 0x7f );
|
||||
if( c & 0x80 )
|
||||
{
|
||||
c = readByte();
|
||||
value = ( value << 7 ) | c;
|
||||
if( c & 0x80 )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return( !file().atEnd() ? value : -1 );
|
||||
}*/
|
||||
|
||||
inline Sint32 readID( void )
|
||||
{
|
||||
@@ -248,6 +242,9 @@ private:
|
||||
typedef vlist<QPair<int, note> > patternNoteVector;
|
||||
patternNoteVector m_notes;
|
||||
|
||||
typedef vlist<int> stepVector;
|
||||
stepVector m_steps;
|
||||
|
||||
typedef vlist<Uint32> playListItems;
|
||||
playListItems m_plItems;
|
||||
|
||||
|
||||
633
plugins/flp_import/unrtf/attr.c
Normal file
633
plugins/flp_import/unrtf/attr.c
Normal file
@@ -0,0 +1,633 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: attr
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Aug 01
|
||||
* Purpose: Character attribute stack.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 01 Aug 01, tuorfa@yahoo.com: moved code over from convert.c
|
||||
* 06 Aug 01, tuorfa@yahoo.com: added several font attributes.
|
||||
* 18 Sep 01, tuorfa@yahoo.com: added AttrStack (stack of stacks) paradigm
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added comment blocks
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "defs.h"
|
||||
#include "error.h"
|
||||
#include "attr.h"
|
||||
#include "main.h"
|
||||
|
||||
extern void starting_body();
|
||||
extern void starting_text();
|
||||
|
||||
extern QString outstring;
|
||||
|
||||
extern int simulate_allcaps;
|
||||
extern int simulate_smallcaps;
|
||||
|
||||
|
||||
#define MAX_ATTRS (10000)
|
||||
|
||||
|
||||
/* For each RTF text block (the text within braces) we must keep
|
||||
* an AttrStack which is a stack of attributes and their optional
|
||||
* parameter. Since RTF text blocks are nested, these make up a
|
||||
* stack of stacks. And, since RTF text blocks inherit attributes
|
||||
* from parent blocks, all new AttrStacks do the same from
|
||||
* their parent AttrStack.
|
||||
*/
|
||||
typedef struct _stack {
|
||||
unsigned char attr_stack[MAX_ATTRS];
|
||||
char *attr_stack_params[MAX_ATTRS];
|
||||
int tos;
|
||||
struct _stack *next;
|
||||
} AttrStack;
|
||||
|
||||
static AttrStack *stack_of_stacks = NULL;
|
||||
static AttrStack *stack_of_stacks_top = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_express_begin
|
||||
* Purpose: Print the HTML for beginning an attribute.
|
||||
* Args: Attribute number, optional string parameter.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_express_begin (int attr, char* param) {
|
||||
switch(attr)
|
||||
{
|
||||
case ATTR_BOLD:
|
||||
outstring+=QString().sprintf(op->bold_begin);
|
||||
break;
|
||||
case ATTR_ITALIC:
|
||||
outstring+=QString().sprintf(op->italic_begin);
|
||||
break;
|
||||
|
||||
/* Various underlines, they all resolve to HTML's <u> */
|
||||
case ATTR_THICK_UL:
|
||||
case ATTR_WAVE_UL:
|
||||
case ATTR_DASH_UL:
|
||||
case ATTR_DOT_UL:
|
||||
case ATTR_DOT_DASH_UL:
|
||||
case ATTR_2DOT_DASH_UL:
|
||||
case ATTR_WORD_UL:
|
||||
case ATTR_UNDERLINE:
|
||||
outstring+=QString().sprintf(op->underline_begin);
|
||||
break;
|
||||
|
||||
case ATTR_DOUBLE_UL:
|
||||
outstring+=QString().sprintf(op->dbl_underline_begin);
|
||||
break;
|
||||
|
||||
case ATTR_FONTSIZE:
|
||||
op_begin_std_fontsize (op, atoi (param));
|
||||
break;
|
||||
|
||||
case ATTR_FONTFACE:
|
||||
outstring+=QString().sprintf(op->font_begin,param);
|
||||
break;
|
||||
|
||||
case ATTR_FOREGROUND:
|
||||
outstring+=QString().sprintf(op->foreground_begin, param);
|
||||
break;
|
||||
|
||||
case ATTR_BACKGROUND:
|
||||
if (!simple_mode)
|
||||
outstring+=QString().sprintf(op->foreground_begin,param);
|
||||
break;
|
||||
|
||||
case ATTR_SUPER:
|
||||
outstring+=QString().sprintf(op->superscript_begin);
|
||||
break;
|
||||
case ATTR_SUB:
|
||||
outstring+=QString().sprintf(op->subscript_begin);
|
||||
break;
|
||||
|
||||
case ATTR_STRIKE:
|
||||
outstring+=QString().sprintf(op->strikethru_begin);
|
||||
break;
|
||||
|
||||
case ATTR_DBL_STRIKE:
|
||||
outstring+=QString().sprintf(op->dbl_strikethru_begin);
|
||||
break;
|
||||
|
||||
case ATTR_EXPAND:
|
||||
outstring+=QString().sprintf(op->expand_begin, param);
|
||||
break;
|
||||
|
||||
case ATTR_OUTLINE:
|
||||
outstring+=QString().sprintf(op->outline_begin);
|
||||
break;
|
||||
case ATTR_SHADOW:
|
||||
outstring+=QString().sprintf(op->shadow_begin);
|
||||
break;
|
||||
case ATTR_EMBOSS:
|
||||
outstring+=QString().sprintf(op->emboss_begin);
|
||||
break;
|
||||
case ATTR_ENGRAVE:
|
||||
outstring+=QString().sprintf(op->engrave_begin);
|
||||
break;
|
||||
|
||||
case ATTR_CAPS:
|
||||
if (op->simulate_all_caps)
|
||||
simulate_allcaps = TRUE;
|
||||
break;
|
||||
|
||||
case ATTR_SMALLCAPS:
|
||||
if (op->simulate_small_caps)
|
||||
simulate_smallcaps = TRUE;
|
||||
else {
|
||||
if (op->small_caps_begin)
|
||||
outstring+=QString().sprintf(op->small_caps_begin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_express_end
|
||||
* Purpose: Print HTML to complete an attribute.
|
||||
* Args: Attribute number.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_express_end (int attr, char *param)
|
||||
{
|
||||
switch(attr)
|
||||
{
|
||||
case ATTR_BOLD:
|
||||
outstring+=QString().sprintf(op->bold_end);
|
||||
break;
|
||||
case ATTR_ITALIC:
|
||||
outstring+=QString().sprintf(op->italic_end);
|
||||
break;
|
||||
|
||||
/* Various underlines, they all resolve to HTML's </u> */
|
||||
case ATTR_THICK_UL:
|
||||
case ATTR_WAVE_UL:
|
||||
case ATTR_DASH_UL:
|
||||
case ATTR_DOT_UL:
|
||||
case ATTR_DOT_DASH_UL:
|
||||
case ATTR_2DOT_DASH_UL:
|
||||
case ATTR_WORD_UL:
|
||||
case ATTR_UNDERLINE:
|
||||
outstring+=QString().sprintf(op->underline_end);
|
||||
break;
|
||||
|
||||
case ATTR_DOUBLE_UL:
|
||||
outstring+=QString().sprintf(op->dbl_underline_end);
|
||||
break;
|
||||
|
||||
case ATTR_FONTSIZE:
|
||||
op_end_std_fontsize (op, atoi (param));
|
||||
break;
|
||||
|
||||
case ATTR_FONTFACE:
|
||||
outstring+=QString().sprintf(op->font_end);
|
||||
break;
|
||||
|
||||
case ATTR_FOREGROUND:
|
||||
outstring+=QString().sprintf(op->foreground_end);
|
||||
break;
|
||||
case ATTR_BACKGROUND:
|
||||
if (!simple_mode)
|
||||
outstring+=QString().sprintf(op->background_end);
|
||||
break;
|
||||
|
||||
case ATTR_SUPER:
|
||||
outstring+=QString().sprintf(op->superscript_end);
|
||||
break;
|
||||
case ATTR_SUB:
|
||||
outstring+=QString().sprintf(op->subscript_end);
|
||||
break;
|
||||
|
||||
case ATTR_STRIKE:
|
||||
outstring+=QString().sprintf(op->strikethru_end);
|
||||
break;
|
||||
|
||||
case ATTR_DBL_STRIKE:
|
||||
outstring+=QString().sprintf(op->dbl_strikethru_end);
|
||||
break;
|
||||
|
||||
case ATTR_OUTLINE:
|
||||
outstring+=QString().sprintf(op->outline_end);
|
||||
break;
|
||||
case ATTR_SHADOW:
|
||||
outstring+=QString().sprintf(op->shadow_end);
|
||||
break;
|
||||
case ATTR_EMBOSS:
|
||||
outstring+=QString().sprintf(op->emboss_end);
|
||||
break;
|
||||
case ATTR_ENGRAVE:
|
||||
outstring+=QString().sprintf(op->engrave_end);
|
||||
break;
|
||||
|
||||
case ATTR_EXPAND:
|
||||
outstring+=QString().sprintf(op->expand_end);
|
||||
break;
|
||||
|
||||
case ATTR_CAPS:
|
||||
if (op->simulate_all_caps)
|
||||
simulate_allcaps = FALSE;
|
||||
break;
|
||||
|
||||
case ATTR_SMALLCAPS:
|
||||
if (op->simulate_small_caps)
|
||||
simulate_smallcaps = FALSE;
|
||||
else {
|
||||
if (op->small_caps_end)
|
||||
outstring+=QString().sprintf(op->small_caps_end);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_push
|
||||
* Purpose: Pushes an attribute onto the current attribute stack.
|
||||
* Args: Attribute number, optional string parameter.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_push(int attr, char* param)
|
||||
{
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
if (!stack) {
|
||||
warning_handler("No stack to push attribute onto");
|
||||
return;
|
||||
}
|
||||
|
||||
if (stack->tos >= MAX_ATTRS) {
|
||||
fprintf(stderr, "Too many attributes!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure it's understood we're in the <body> section. */
|
||||
/* KLUDGE */
|
||||
starting_body();
|
||||
starting_text();
|
||||
|
||||
++stack->tos;
|
||||
stack->attr_stack[stack->tos] = attr;
|
||||
if (param)
|
||||
stack->attr_stack_params[stack->tos] = my_strdup(param);
|
||||
else
|
||||
stack->attr_stack_params[stack->tos] = NULL;
|
||||
|
||||
attr_express_begin(attr, param);
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attrstack_copy_all
|
||||
* Purpose: Routine to copy all attributes from one stack to another.
|
||||
* Args: Two stacks.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attrstack_copy_all (AttrStack *src, AttrStack *dest)
|
||||
{
|
||||
int i;
|
||||
int total;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(src);
|
||||
CHECK_PARAM_NOT_NULL(dest);
|
||||
|
||||
total = src->tos + 1;
|
||||
|
||||
for (i=0; i<total; i++)
|
||||
{
|
||||
int attr=src->attr_stack [i];
|
||||
char *param=src->attr_stack_params [i];
|
||||
|
||||
dest->attr_stack[i] = attr;
|
||||
if (param)
|
||||
dest->attr_stack_params[i] = my_strdup (param);
|
||||
else
|
||||
dest->attr_stack_params[i] = NULL;
|
||||
}
|
||||
|
||||
dest->tos = src->tos;
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
* Name: attrstack_unexpress_all
|
||||
* Purpose: Routine to un-express all attributes heretofore applied,
|
||||
* without removing any from the stack.
|
||||
* Args: Stack whost contents should be unexpressed.
|
||||
* Returns: None.
|
||||
* Notes: This is needed by attrstack_push, but also for \cell, which
|
||||
* often occurs within a brace group, yet HTML uses <td></td>
|
||||
* which clear attribute info within that block.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attrstack_unexpress_all (AttrStack *stack)
|
||||
{
|
||||
int i;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(stack);
|
||||
|
||||
i=stack->tos;
|
||||
while (i>=0)
|
||||
{
|
||||
int attr=stack->attr_stack [i];
|
||||
char *param=stack->attr_stack_params [i];
|
||||
|
||||
attr_express_end (attr, param);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attrstack_push
|
||||
* Purpose: Creates a new attribute stack, pushes it onto the stack
|
||||
* of stacks, performs inheritance from previous stack.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
void
|
||||
attrstack_push ()
|
||||
{
|
||||
AttrStack *new_stack;
|
||||
AttrStack *prev_stack;
|
||||
|
||||
new_stack = (AttrStack*) my_malloc (sizeof (AttrStack));
|
||||
memset ((void*) new_stack, 0, sizeof (AttrStack));
|
||||
|
||||
prev_stack = stack_of_stacks_top;
|
||||
|
||||
if (!stack_of_stacks) {
|
||||
stack_of_stacks = new_stack;
|
||||
} else {
|
||||
stack_of_stacks_top->next = new_stack;
|
||||
}
|
||||
stack_of_stacks_top = new_stack;
|
||||
new_stack->tos = -1;
|
||||
|
||||
if (prev_stack) {
|
||||
attrstack_unexpress_all (prev_stack);
|
||||
attrstack_copy_all (prev_stack, new_stack);
|
||||
attrstack_express_all ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_pop
|
||||
* Purpose: Removes and undoes the effect of the top attribute of
|
||||
* the current AttrStack.
|
||||
* Args: The top attribute's number, for verification.
|
||||
* Returns: Success/fail flag.
|
||||
*=======================================================================*/
|
||||
|
||||
int
|
||||
attr_pop (int attr)
|
||||
{
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
|
||||
if (!stack) {
|
||||
warning_handler ("no stack to pop attribute from");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(stack->tos>=0 && stack->attr_stack[stack->tos]==attr)
|
||||
{
|
||||
char *param = stack->attr_stack_params [stack->tos];
|
||||
|
||||
attr_express_end (attr, param);
|
||||
|
||||
if (param) my_free(param);
|
||||
|
||||
stack->tos--;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_read
|
||||
* Purpose: Reads but leaves in place the top attribute of the top
|
||||
* attribute stack.
|
||||
* Args: None.
|
||||
* Returns: Attribute number.
|
||||
*=======================================================================*/
|
||||
|
||||
int
|
||||
attr_read() {
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
if (!stack) {
|
||||
warning_handler ("no stack to read attribute from");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(stack->tos>=0)
|
||||
{
|
||||
int attr = stack->attr_stack [stack->tos];
|
||||
return attr;
|
||||
}
|
||||
else
|
||||
return ATTR_NONE;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_drop_all
|
||||
* Purpose: Undoes all attributes that an AttrStack contains.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_drop_all ()
|
||||
{
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
if (!stack) {
|
||||
warning_handler ("no stack to drop all attributes from");
|
||||
return;
|
||||
}
|
||||
|
||||
while (stack->tos>=0)
|
||||
{
|
||||
char *param=stack->attr_stack_params [stack->tos];
|
||||
if (param) my_free(param);
|
||||
stack->tos--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attrstack_drop
|
||||
* Purpose: Removes the top AttrStack from the stack of stacks, undoing
|
||||
* all attributes that it had in it.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attrstack_drop ()
|
||||
{
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
AttrStack *prev_stack;
|
||||
if (!stack) {
|
||||
warning_handler ("no attr-stack to drop");
|
||||
return;
|
||||
}
|
||||
|
||||
attr_pop_all ();
|
||||
|
||||
prev_stack = stack_of_stacks;
|
||||
while(prev_stack && prev_stack->next && prev_stack->next != stack)
|
||||
prev_stack = prev_stack->next;
|
||||
|
||||
if (prev_stack) {
|
||||
stack_of_stacks_top = prev_stack;
|
||||
prev_stack->next = NULL;
|
||||
} else {
|
||||
stack_of_stacks_top = NULL;
|
||||
stack_of_stacks = NULL;
|
||||
}
|
||||
my_free ((char*) stack);
|
||||
|
||||
attrstack_express_all ();
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_pop_all
|
||||
* Purpose: Routine to undo all attributes heretofore applied,
|
||||
* also reversing the order in which they were applied.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_pop_all()
|
||||
{
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
if (!stack) {
|
||||
warning_handler ("no stack to pop from");
|
||||
return;
|
||||
}
|
||||
|
||||
while (stack->tos>=0) {
|
||||
int attr=stack->attr_stack [stack->tos];
|
||||
char *param=stack->attr_stack_params [stack->tos];
|
||||
attr_express_end (attr,param);
|
||||
if (param) my_free(param);
|
||||
stack->tos--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attrstack_express_all
|
||||
* Purpose: Routine to re-express all attributes heretofore applied.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
* Notes: This is needed by attrstack_push, but also for \cell, which
|
||||
* often occurs within a brace group, yet HTML uses <td></td>
|
||||
* which clear attribute info within that block.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attrstack_express_all() {
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
int i;
|
||||
|
||||
if (!stack) {
|
||||
warning_handler ("no stack to pop from");
|
||||
return;
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (i<=stack->tos)
|
||||
{
|
||||
int attr=stack->attr_stack [i];
|
||||
char *param=stack->attr_stack_params [i];
|
||||
attr_express_begin (attr, param);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: attr_pop_dump
|
||||
* Purpose: Routine to un-express all attributes heretofore applied.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
* Notes: This is needed for \cell, which often occurs within a
|
||||
* brace group, yet HTML uses <td></td> which clear attribute
|
||||
* info within that block.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
attr_pop_dump() {
|
||||
AttrStack *stack = stack_of_stacks_top;
|
||||
int i;
|
||||
|
||||
if (!stack) return;
|
||||
|
||||
i=stack->tos;
|
||||
while (i>=0)
|
||||
{
|
||||
int attr=stack->attr_stack [i];
|
||||
attr_pop (attr);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
92
plugins/flp_import/unrtf/attr.h
Normal file
92
plugins/flp_import/unrtf/attr.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: attr
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Aug 2001
|
||||
* Purpose: Definitions for attribute stack module.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 01 Aug 01, tuorfa@yahoo.com: moved code over from convert.c
|
||||
* 06 Aug 01, tuorfa@yahoo.com: added several attributes
|
||||
* 18 Sep 01, tuorfa@yahoo.com: updates for AttrStack paradigm
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _ATTR
|
||||
#define _ATTR
|
||||
|
||||
enum {
|
||||
ATTR_NONE=0,
|
||||
ATTR_BOLD, ATTR_ITALIC,
|
||||
|
||||
ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL,
|
||||
|
||||
ATTR_THICK_UL, ATTR_WAVE_UL,
|
||||
|
||||
ATTR_DOT_UL, ATTR_DASH_UL, ATTR_DOT_DASH_UL, ATTR_2DOT_DASH_UL,
|
||||
|
||||
ATTR_FONTSIZE, ATTR_STD_FONTSIZE,
|
||||
ATTR_FONTFACE,
|
||||
ATTR_FOREGROUND, ATTR_BACKGROUND,
|
||||
ATTR_CAPS,
|
||||
ATTR_SMALLCAPS,
|
||||
|
||||
ATTR_SHADOW,
|
||||
ATTR_OUTLINE,
|
||||
ATTR_EMBOSS,
|
||||
ATTR_ENGRAVE,
|
||||
|
||||
ATTR_SUPER, ATTR_SUB,
|
||||
ATTR_STRIKE,
|
||||
ATTR_DBL_STRIKE,
|
||||
|
||||
ATTR_EXPAND
|
||||
/* ATTR_CONDENSE */
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern void attr_push_core (int attr, char* param);
|
||||
|
||||
extern void attr_pop_core (int attr);
|
||||
|
||||
extern void attr_push(int attr, char* param);
|
||||
|
||||
extern void attrstack_push();
|
||||
extern void attrstack_drop();
|
||||
extern void attrstack_express_all();
|
||||
|
||||
extern int attr_pop(int attr);
|
||||
|
||||
extern int attr_read();
|
||||
|
||||
extern void attr_drop_all ();
|
||||
|
||||
extern void attr_pop_all();
|
||||
|
||||
extern void attr_pop_dump();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
3172
plugins/flp_import/unrtf/convert.c
Normal file
3172
plugins/flp_import/unrtf/convert.c
Normal file
File diff suppressed because it is too large
Load Diff
58
plugins/flp_import/unrtf/convert.h
Normal file
58
plugins/flp_import/unrtf/convert.h
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
/*===========================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
===========================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: convert
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 19 Sep 2001
|
||||
* Purpose: Definitions for the conversion module
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 31 March 2005 by daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _CONVERT
|
||||
|
||||
enum {
|
||||
CHARSET_ANSI=1,
|
||||
CHARSET_MAC,
|
||||
CHARSET_CP437,
|
||||
CHARSET_CP850
|
||||
};
|
||||
|
||||
#ifndef _WORD
|
||||
#include "word.h"
|
||||
#endif
|
||||
|
||||
extern void word_print (Word*, QString & _s);
|
||||
|
||||
#if 1 /* daved 0.19.6 - support for multiple char number->output tables */
|
||||
short numchar_table;
|
||||
#define FONTROMAN_TABLE 0
|
||||
#define FONTSYMBOL_TABLE 1
|
||||
#endif
|
||||
|
||||
#define _CONVERT
|
||||
#endif
|
||||
|
||||
75
plugins/flp_import/unrtf/defs.h
Normal file
75
plugins/flp_import/unrtf/defs.h
Normal file
@@ -0,0 +1,75 @@
|
||||
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: defs.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Basic definitions plus externs for UnRTF
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 21 Oct 00, tuorfa@yahoo.com: moved program version to this file
|
||||
* 08 Apr 01, tuorfa@yahoo.com: updated usage info.
|
||||
* 08 Sep 01, tuorfa@yahoo.com: added UnRTF.
|
||||
* 19 Sep 01, tuorfa@yahoo.com: added PROGRAM_WEBSITE.
|
||||
* 09 Oct 03, daved@physiol.usyd.edu.au: changed to GNU website
|
||||
* 17 Feb 04, marcossamaral@terra.com.br: changed some information
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define PROGRAM_WEBSITE "http://www.gnu.org/software/unrtf/unrtf.html"
|
||||
|
||||
|
||||
/* Select the language for reporting of file creation/modificaton dates */
|
||||
#define ENGLISH
|
||||
#if 0
|
||||
#define FRANCAIS
|
||||
#define ITALIANO
|
||||
#define PORTUGUES /* amaral - 0.19.4 */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef TRUE /* daved 0.19.0 */
|
||||
#define TRUE (1)
|
||||
#endif
|
||||
#ifndef FALSE /* daved 0.19.0 */
|
||||
#define FALSE (0)
|
||||
#endif
|
||||
#if 1 /* daved - 0.19.4 */
|
||||
#define SKIP_ONE_WORD 2
|
||||
#endif
|
||||
|
||||
|
||||
#define USAGE "unrtf [--version] [--verbose] [--help] [--nopict|-n] [--html] [--text] [--vt] [--latex] [-t html|text|vt|latex] <filename>"
|
||||
|
||||
|
||||
/* Default names for RTF's default fonts */
|
||||
#define FONTNIL_STR "Times,TimesRoman,TimesNewRoman"
|
||||
#define FONTROMAN_STR "Times,Palatino"
|
||||
#define FONTSWISS_STR "Helvetica,Arial"
|
||||
#define FONTMODERN_STR "Courier,Verdana"
|
||||
#define FONTSCRIPT_STR "Cursive,ZapfChancery"
|
||||
#define FONTDECOR_STR "ZapfChancery"
|
||||
#define FONTTECH_STR "Symbol"
|
||||
|
||||
104
plugins/flp_import/unrtf/error.c
Normal file
104
plugins/flp_import/unrtf/error.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: error
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Sep 00
|
||||
* Purpose: Management of errors and warnings, when reporting
|
||||
* the source code file/line is not necessary.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes
|
||||
* 10 Oct 00, tuorfa@yahoo.com: added usage()
|
||||
* 15 Oct 00, tuorfa@yahoo.com: improved output readability
|
||||
* 22 Sep 01, tuorfa@yahoo.com: removed mention of line number in handlers
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 22 Aug 05, ax2groin@arbornet.org: added lineno to error_handler
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: usage
|
||||
* Purpose: Prints usage information and exits with an error.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
usage ()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s\n", USAGE);
|
||||
exit(-3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: error_handler
|
||||
* Purpose: Prints error message and other useful info, then exits.
|
||||
* Args: Message.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
error_handler (char* message)
|
||||
{
|
||||
#if 1
|
||||
fprintf(stderr, "Error (line %d): %s\n", lineno, message);
|
||||
#else
|
||||
fprintf(stderr, "Error: %s\n", message);
|
||||
#endif
|
||||
exit(10);
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: warning_handler
|
||||
* Purpose: Prints useful info to stderr, but doesn't exit.
|
||||
* Args: Message.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
warning_handler (char* message)
|
||||
{
|
||||
fprintf(stderr, "Warning: %s\n", message);
|
||||
}
|
||||
44
plugins/flp_import/unrtf/error.h
Normal file
44
plugins/flp_import/unrtf/error.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: error.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Macros to be executed at the start of a function,
|
||||
* when reporting source code file/line is useful.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define CHECK_PARAM_NOT_NULL(XX) { if ((XX)==NULL) { fprintf (stderr, "internal error: null pointer param in %s at %d\n", __FILE__, __LINE__); exit (1); }}
|
||||
|
||||
#define CHECK_MALLOC_SUCCESS(XX) { if ((XX)==NULL) { fprintf (stderr, "internal error: cannot allocate memory in %s at %d\n", __FILE__, __LINE__); exit (1); }}
|
||||
|
||||
|
||||
extern void usage(void);
|
||||
extern void error_handler (char*);
|
||||
extern void warning_handler (char*);
|
||||
|
||||
|
||||
217
plugins/flp_import/unrtf/hash.c
Normal file
217
plugins/flp_import/unrtf/hash.c
Normal file
@@ -0,0 +1,217 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: hash
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Sep 00
|
||||
* Purpose: Word-hash management. Words are put into a hash and an
|
||||
* identifier is returned. This is used to save us from
|
||||
* doing multiple mallocs for recurring strings such as
|
||||
* 'the' and \par. This is not a big issue under Unix,
|
||||
* but it is under other OSes and anyway, waste not want not.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 08 Apr 01, tuorfa@yahoo.com: check for out of memory after malloc.
|
||||
* 21 Apr 01, tuorfa@yahoo.com: signed to conversion unsigned bug
|
||||
* 03 Aug 01, tuorfa@yahoo.com: fixes for using 16-bit compiler
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: some type fixes
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requsted by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats function
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "main.h"
|
||||
#include "malloc.h"
|
||||
|
||||
|
||||
typedef struct _hi {
|
||||
struct _hi *next;
|
||||
char *str;
|
||||
unsigned long value;
|
||||
} hashItem;
|
||||
|
||||
|
||||
/* Index by first char of string */
|
||||
static hashItem *hash2[256];
|
||||
static unsigned long hash_length[256];
|
||||
static unsigned long hash_value=0;
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hash_init
|
||||
* Purpose: Clear the hash table.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
hash_init ()
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<256; i++) {
|
||||
hash2[i]=NULL;
|
||||
hash_length[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hash_stats
|
||||
* Purpose: Return the number of words stored. This is all words,
|
||||
* including commands to RTF, NOT the number of printed words in
|
||||
* a given document.
|
||||
* Args: None.
|
||||
* Returns: Number of words stored.
|
||||
*=======================================================================*/
|
||||
|
||||
unsigned long
|
||||
hash_stats ()
|
||||
{
|
||||
int i;
|
||||
unsigned long total=0;
|
||||
for (i=0; i<256; i++) {
|
||||
total += hash_length[i];
|
||||
}
|
||||
return(total);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hashitem_new
|
||||
* Purpose: Creates a new linked list item for the hash table.
|
||||
* Args: String.
|
||||
* Returns: hashItem.
|
||||
*=======================================================================*/
|
||||
|
||||
static hashItem *
|
||||
hashitem_new (char *str)
|
||||
{
|
||||
hashItem *hi;
|
||||
unsigned long i;
|
||||
|
||||
hi=(hashItem*) my_malloc(sizeof(hashItem));
|
||||
if (!hi)
|
||||
error_handler("Out of memory");
|
||||
memset ((void*)hi, 0, sizeof (hashItem));
|
||||
|
||||
hi->str = my_strdup(str);
|
||||
|
||||
i = *str;
|
||||
if (i=='\\') i=str[1];
|
||||
i <<= 24;
|
||||
hi->value = i | (hash_value++ & 0xffffff);
|
||||
hi->next = NULL;
|
||||
|
||||
#if 0
|
||||
if (debug_mode) {
|
||||
printf ("<!-- storing val %08lx str %s -->\n",
|
||||
hi->value, hi->str);
|
||||
}
|
||||
#endif
|
||||
|
||||
return hi;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hash_get_index
|
||||
* Purpose: Given a string, returns the "index" i.e. the word identifier.
|
||||
* Args: String.
|
||||
* Returns: Index.
|
||||
*=======================================================================*/
|
||||
|
||||
unsigned long
|
||||
hash_get_index (char *str)
|
||||
{
|
||||
#if 1 /* daved - 0.19.1 */
|
||||
unsigned short index;
|
||||
unsigned char ch;
|
||||
#else
|
||||
int index;
|
||||
char ch;
|
||||
#endif
|
||||
hashItem *hi;
|
||||
|
||||
#if 1 /* daved - 0.19.1 */
|
||||
ch = (unsigned char)*str;
|
||||
#else
|
||||
ch = *str;
|
||||
#endif
|
||||
if (ch=='\\' && *(str+1))
|
||||
ch = *(str+1);
|
||||
index = ch;
|
||||
hi = hash2[index];
|
||||
while (hi) {
|
||||
if (!strcmp(hi->str,str))
|
||||
return hi->value;
|
||||
hi=hi->next;
|
||||
}
|
||||
/* not in hash */
|
||||
hi = hashitem_new (str);
|
||||
hi->next = hash2[index];
|
||||
hash2[index] = hi;
|
||||
++hash_length [index];
|
||||
return hi->value;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: hash_get_string
|
||||
|
||||
* Purpose: Given the index (word identifier) returns the word string.
|
||||
* Args: Index.
|
||||
* Returns: String, or NULL if not found.
|
||||
*=======================================================================*/
|
||||
|
||||
char*
|
||||
hash_get_string (unsigned long value)
|
||||
{
|
||||
int index;
|
||||
hashItem *hi;
|
||||
|
||||
index = value >> 24;
|
||||
hi = hash2[index];
|
||||
while (hi) {
|
||||
if (hi->value == value)
|
||||
return hi->str;
|
||||
hi=hi->next;
|
||||
}
|
||||
warning_handler("Word not in hash");
|
||||
return NULL;
|
||||
}
|
||||
41
plugins/flp_import/unrtf/hash.h
Normal file
41
plugins/flp_import/unrtf/hash.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: hash.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Definitions for the hash module.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
extern void hash_init (void);
|
||||
extern unsigned long hash_stats (void);
|
||||
extern unsigned long hash_get_index (char *);
|
||||
extern char* hash_get_string (unsigned long );
|
||||
|
||||
|
||||
1102
plugins/flp_import/unrtf/html.c
Normal file
1102
plugins/flp_import/unrtf/html.c
Normal file
File diff suppressed because it is too large
Load Diff
42
plugins/flp_import/unrtf/html.h
Normal file
42
plugins/flp_import/unrtf/html.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: html
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 19 Sep 01
|
||||
* Purpose: Definitions for the HTML output personality
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _HTML
|
||||
|
||||
|
||||
extern OutputPersonality* html_init(void);
|
||||
|
||||
|
||||
#define _HTML
|
||||
#endif
|
||||
|
||||
45
plugins/flp_import/unrtf/main.h
Normal file
45
plugins/flp_import/unrtf/main.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: main.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Externs for main.c.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 15 Oct 00, tuorfa@yahoo.com: removed echo_mode extern
|
||||
* 19 Sep 01, tuorfa@yahoo.com: added output personality
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
extern int lineno;
|
||||
|
||||
|
||||
#ifndef _OUTPUT
|
||||
#include "output.h"
|
||||
#endif
|
||||
|
||||
extern OutputPersonality *op;
|
||||
|
||||
|
||||
131
plugins/flp_import/unrtf/malloc.c
Normal file
131
plugins/flp_import/unrtf/malloc.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: malloc
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Aug 01
|
||||
* Purpose: Memory management. Allows us to keep track of how
|
||||
* much memory is being used.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 14 Aug 01, tuorfa@yahoo.com: added Turbo C support.
|
||||
* 16 Aug 01, Lars Unger <l.unger@tu-bs.de>: added Amiga/GCC support.
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 28 Sep 01, tuorfa@yahoo.com: removed Turbo C support.
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "error.h"
|
||||
#include "malloc.h"
|
||||
|
||||
static unsigned long count=0;
|
||||
|
||||
/*========================================================================
|
||||
* Name: my_malloc
|
||||
* Purpose: Internal version of malloc necessary for record keeping.
|
||||
* Args: Amount.
|
||||
* Returns: Pointer.
|
||||
*=======================================================================*/
|
||||
|
||||
char *
|
||||
my_malloc (unsigned long size) {
|
||||
char *ptr;
|
||||
|
||||
ptr = (char *) malloc (size);
|
||||
if (ptr)
|
||||
count += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*========================================================================
|
||||
* Name: my_free
|
||||
* Purpose: Internal version of free necessary for record keeping.
|
||||
* Args: Pointer.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
my_free (char* ptr) {
|
||||
CHECK_PARAM_NOT_NULL(ptr);
|
||||
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: total_malloced
|
||||
* Purpose: Returns total amount of memory thus far allocated. Called at
|
||||
* the end of main() when in debug mode.
|
||||
* Args: None.
|
||||
* Returns: Amount.
|
||||
*=======================================================================*/
|
||||
|
||||
unsigned long
|
||||
total_malloced (void) {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: my_strdup
|
||||
* Purpose: Internal version of strdup necessary for record keeping.
|
||||
* Args: String.
|
||||
* Returns: String.
|
||||
*=======================================================================*/
|
||||
|
||||
char *
|
||||
my_strdup (char *src) {
|
||||
unsigned long len;
|
||||
char *ptr;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(src);
|
||||
|
||||
len = strlen(src);
|
||||
ptr = my_malloc (len+1);
|
||||
if (!ptr)
|
||||
error_handler ("out of memory in strdup()");
|
||||
|
||||
strcpy (ptr, src);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
37
plugins/flp_import/unrtf/malloc.h
Normal file
37
plugins/flp_import/unrtf/malloc.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: malloc
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Aug 2001
|
||||
* Purpose: Definitions for memory management.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
extern char * my_malloc (unsigned long);
|
||||
extern void my_free (char*);
|
||||
extern unsigned long total_malloced (void);
|
||||
extern char * my_strdup (char*);
|
||||
|
||||
436
plugins/flp_import/unrtf/output.c
Normal file
436
plugins/flp_import/unrtf/output.c
Normal file
@@ -0,0 +1,436 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: output
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 18 Sep 01
|
||||
* Purpose: Generalized output module
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 22 Sep 01, tuorfa@yahoo.com: addition of functions to change font size
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
|
||||
* 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
* 06 Jan 06, marcossamaral@terra.com.br: changes in STDOUT
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "defs.h"
|
||||
#include "error.h"
|
||||
#include "output.h"
|
||||
#include "main.h"
|
||||
#include "convert.h"
|
||||
|
||||
|
||||
extern QString outstring;
|
||||
|
||||
/*========================================================================
|
||||
* Name: op_create
|
||||
* Purpose: Creates a blank output personality.
|
||||
* Args: None.
|
||||
* Returns: Output personality struct.
|
||||
*=======================================================================*/
|
||||
|
||||
OutputPersonality*
|
||||
op_create ()
|
||||
{
|
||||
OutputPersonality* new_op;
|
||||
|
||||
new_op = (OutputPersonality*) my_malloc (sizeof(OutputPersonality));
|
||||
if (!new_op)
|
||||
error_handler ("cannot allocate output personality");
|
||||
|
||||
memset ((void*) new_op, 0, sizeof (OutputPersonality));
|
||||
return new_op;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: op_free
|
||||
* Purpose: Deallocates an output personality, but none of the strings
|
||||
* it points to since they are usually constants.
|
||||
* Args: OutputPersonality.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
op_free (OutputPersonality *op)
|
||||
{
|
||||
CHECK_PARAM_NOT_NULL(op);
|
||||
|
||||
my_free ((char*) op);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: op_translate_char
|
||||
* Purpose: Performs a translation of a character in the context of
|
||||
* a given output personality.
|
||||
* Args: OutputPersonality, character set#, character.
|
||||
* Returns: String.
|
||||
*=======================================================================*/
|
||||
|
||||
char *
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
op_translate_char (OutputPersonality *op, int charset, int ch, int ntable)
|
||||
#else
|
||||
op_translate_char (OutputPersonality *op, int charset, int ch)
|
||||
#endif
|
||||
{
|
||||
short start;
|
||||
char *result=NULL;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(op);
|
||||
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
/* if we are seeking a character from a symbol font we can
|
||||
be below 0x80
|
||||
*/
|
||||
if(ntable == FONTSYMBOL_TABLE)
|
||||
{
|
||||
start = op->symbol_first_char;
|
||||
|
||||
if(ch >= start && ch <= op->symbol_last_char)
|
||||
result = op->symbol_translation_table[ch - start];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (ch >= 0x20 && ch < 0x80) {
|
||||
result = op->ascii_translation_table [ch - 0x20];
|
||||
}
|
||||
else
|
||||
if (charset != CHARSET_ANSI &&
|
||||
charset != CHARSET_MAC &&
|
||||
charset != CHARSET_CP437 &&
|
||||
charset != CHARSET_CP850)
|
||||
error_handler ("invalid character set value, cannot translate character");
|
||||
else
|
||||
switch (charset) {
|
||||
case CHARSET_ANSI:
|
||||
start = op->ansi_first_char;
|
||||
if (ch >= start &&
|
||||
ch <= op->ansi_last_char)
|
||||
result = op->ansi_translation_table [ch-start];
|
||||
break;
|
||||
case CHARSET_MAC:
|
||||
start = op->mac_first_char;
|
||||
if (ch >= start &&
|
||||
ch <= op->mac_last_char)
|
||||
result = op->mac_translation_table [ch-start];
|
||||
break;
|
||||
case CHARSET_CP437:
|
||||
start = op->cp437_first_char;
|
||||
if (ch >= start &&
|
||||
ch <= op->cp437_last_char)
|
||||
result = op->cp437_translation_table [ch-start];
|
||||
break;
|
||||
case CHARSET_CP850:
|
||||
start = op->cp850_first_char;
|
||||
if (ch >= start &&
|
||||
ch <= op->cp850_last_char)
|
||||
result = op->cp850_translation_table [ch-start];
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: op_begin_std_fontsize
|
||||
* Purpose: Prints whatever is necessary to perform a change in the
|
||||
* current font size.
|
||||
* Args: OutputPersonality, desired size.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
op_begin_std_fontsize (OutputPersonality *op, int size)
|
||||
{
|
||||
int found_std_expr = FALSE;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(op);
|
||||
|
||||
/* Look for an exact match with a standard point size.
|
||||
*/
|
||||
switch (size) {
|
||||
case 8:
|
||||
if (op->fontsize8_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize8_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (op->fontsize10_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize10_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (op->fontsize12_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize12_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (op->fontsize14_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize14_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
if (op->fontsize18_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize18_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
if (op->fontsize24_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize24_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 36:
|
||||
if (op->fontsize36_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize36_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 48:
|
||||
if (op->fontsize48_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize48_begin);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* If no exact match, try to write out a change to the
|
||||
* exact point size.
|
||||
*/
|
||||
if (!found_std_expr) {
|
||||
if (op->fontsize_begin) {
|
||||
char expr[16];
|
||||
sprintf (expr, "%d", size);
|
||||
outstring+=QString().sprintf (op->fontsize_begin, expr);
|
||||
} else {
|
||||
/* If we cannot write out a change for the exact
|
||||
* point size, we must approximate to a standard
|
||||
* size.
|
||||
*/
|
||||
if (size<9 && op->fontsize8_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize8_begin);
|
||||
} else
|
||||
if (size<11 && op->fontsize10_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize10_begin);
|
||||
} else
|
||||
if (size<13 && op->fontsize12_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize12_begin);
|
||||
} else
|
||||
if (size<16 && op->fontsize14_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize14_begin);
|
||||
} else
|
||||
if (size<21 && op->fontsize18_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize18_begin);
|
||||
} else
|
||||
if (size<30 && op->fontsize24_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize24_begin);
|
||||
} else
|
||||
if (size<42 && op->fontsize36_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize36_begin);
|
||||
} else
|
||||
if (size>40 && op->fontsize48_begin) {
|
||||
outstring+=QString().sprintf (op->fontsize48_begin);
|
||||
} else
|
||||
/* If we can't even produce a good approximation,
|
||||
* just try to get a font size near 12 point.
|
||||
*/
|
||||
if (op->fontsize12_begin)
|
||||
outstring+=QString().sprintf (op->fontsize12_begin);
|
||||
else
|
||||
if (op->fontsize14_begin)
|
||||
outstring+=QString().sprintf (op->fontsize14_begin);
|
||||
else
|
||||
if (op->fontsize10_begin)
|
||||
outstring+=QString().sprintf (op->fontsize10_begin);
|
||||
else
|
||||
if (op->fontsize18_begin)
|
||||
outstring+=QString().sprintf (op->fontsize18_begin);
|
||||
else
|
||||
if (op->fontsize8_begin)
|
||||
outstring+=QString().sprintf (op->fontsize8_begin);
|
||||
else
|
||||
error_handler ("output personality lacks sufficient font size change capability");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: op_end_std_fontsize
|
||||
* Purpose: Prints whatever is necessary to perform a change in the
|
||||
* current font size.
|
||||
* Args: OutputPersonality, desired size.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
op_end_std_fontsize (OutputPersonality *op, int size)
|
||||
{
|
||||
int found_std_expr = FALSE;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(op);
|
||||
|
||||
/* Look for an exact match with a standard point size.
|
||||
*/
|
||||
switch (size) {
|
||||
case 8:
|
||||
if (op->fontsize8_end) {
|
||||
outstring+=QString().sprintf (op->fontsize8_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
if (op->fontsize10_end) {
|
||||
outstring+=QString().sprintf (op->fontsize10_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (op->fontsize12_end) {
|
||||
outstring+=QString().sprintf (op->fontsize12_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 14:
|
||||
if (op->fontsize14_end) {
|
||||
outstring+=QString().sprintf (op->fontsize14_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
if (op->fontsize18_end) {
|
||||
outstring+=QString().sprintf (op->fontsize18_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
if (op->fontsize24_end) {
|
||||
outstring+=QString().sprintf (op->fontsize24_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 36:
|
||||
if (op->fontsize36_end) {
|
||||
outstring+=QString().sprintf (op->fontsize36_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
case 48:
|
||||
if (op->fontsize48_end) {
|
||||
outstring+=QString().sprintf (op->fontsize48_end);
|
||||
found_std_expr = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* If no exact match, try to write out a change to the
|
||||
* exact point size.
|
||||
*/
|
||||
if (!found_std_expr) {
|
||||
if (op->fontsize_end) {
|
||||
char expr[16];
|
||||
sprintf (expr, "%d", size);
|
||||
outstring+=QString().sprintf (op->fontsize_end, expr);
|
||||
} else {
|
||||
/* If we cannot write out a change for the exact
|
||||
* point size, we must approximate to a standard
|
||||
* size.
|
||||
*/
|
||||
if (size<9 && op->fontsize8_end) {
|
||||
outstring+=QString().sprintf (op->fontsize8_end);
|
||||
} else
|
||||
if (size<11 && op->fontsize10_end) {
|
||||
outstring+=QString().sprintf (op->fontsize10_end);
|
||||
} else
|
||||
if (size<13 && op->fontsize12_end) {
|
||||
outstring+=QString().sprintf (op->fontsize12_end);
|
||||
} else
|
||||
if (size<16 && op->fontsize14_end) {
|
||||
outstring+=QString().sprintf (op->fontsize14_end);
|
||||
} else
|
||||
if (size<21 && op->fontsize18_end) {
|
||||
outstring+=QString().sprintf (op->fontsize18_end);
|
||||
} else
|
||||
if (size<30 && op->fontsize24_end) {
|
||||
outstring+=QString().sprintf (op->fontsize24_end);
|
||||
} else
|
||||
if (size<42 && op->fontsize36_end) {
|
||||
outstring+=QString().sprintf (op->fontsize36_end);
|
||||
} else
|
||||
if (size>40 && op->fontsize48_end) {
|
||||
outstring+=QString().sprintf (op->fontsize48_end);
|
||||
} else
|
||||
/* If we can't even produce a good approximation,
|
||||
* just try to get a font size near 12 point.
|
||||
*/
|
||||
if (op->fontsize12_end)
|
||||
outstring+=QString().sprintf (op->fontsize12_end);
|
||||
else
|
||||
if (op->fontsize14_end)
|
||||
outstring+=QString().sprintf (op->fontsize14_end);
|
||||
else
|
||||
if (op->fontsize10_end)
|
||||
outstring+=QString().sprintf (op->fontsize10_end);
|
||||
else
|
||||
if (op->fontsize18_end)
|
||||
outstring+=QString().sprintf (op->fontsize18_end);
|
||||
else
|
||||
if (op->fontsize8_end)
|
||||
outstring+=QString().sprintf (op->fontsize8_end);
|
||||
else
|
||||
error_handler ("output personality lacks sufficient font size change capability");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
298
plugins/flp_import/unrtf/output.h
Normal file
298
plugins/flp_import/unrtf/output.h
Normal file
@@ -0,0 +1,298 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: output
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 18 Sep 01
|
||||
* Purpose: Definitions for the generalized output module
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _OUTPUT
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *comment_begin;
|
||||
char *comment_end;
|
||||
|
||||
char *document_begin;
|
||||
char *document_end;
|
||||
|
||||
char *header_begin;
|
||||
char *header_end;
|
||||
|
||||
char *document_title_begin;
|
||||
char *document_title_end;
|
||||
|
||||
char *document_keywords_begin;
|
||||
char *document_keywords_end;
|
||||
|
||||
char *document_author_begin;
|
||||
char *document_author_end;
|
||||
|
||||
char *document_changedate_begin;
|
||||
char *document_changedate_end;
|
||||
|
||||
char *body_begin;
|
||||
char *body_end;
|
||||
|
||||
char *word_begin;
|
||||
char *word_end;
|
||||
|
||||
char *paragraph_begin;
|
||||
char *paragraph_end;
|
||||
|
||||
char *center_begin;
|
||||
char *center_end;
|
||||
|
||||
char *align_left_begin;
|
||||
char *align_left_end;
|
||||
|
||||
char *align_right_begin;
|
||||
char *align_right_end;
|
||||
|
||||
char *justify_begin;
|
||||
char *justify_end;
|
||||
|
||||
char *forced_space;
|
||||
char *line_break;
|
||||
char *page_break;
|
||||
|
||||
char *hyperlink_begin;
|
||||
char *hyperlink_end;
|
||||
|
||||
char *imagelink_begin;
|
||||
char *imagelink_end;
|
||||
|
||||
char *table_begin;
|
||||
char *table_end;
|
||||
|
||||
char *table_row_begin;
|
||||
char *table_row_end;
|
||||
|
||||
char *table_cell_begin;
|
||||
char *table_cell_end;
|
||||
|
||||
/* Character attributes */
|
||||
char *font_begin;
|
||||
char *font_end;
|
||||
|
||||
char *fontsize_begin;
|
||||
char *fontsize_end;
|
||||
|
||||
/* standard font sizes are optional */
|
||||
char *fontsize8_begin;
|
||||
char *fontsize8_end;
|
||||
|
||||
char *fontsize10_begin;
|
||||
char *fontsize10_end;
|
||||
|
||||
char *fontsize12_begin;
|
||||
char *fontsize12_end;
|
||||
|
||||
char *fontsize14_begin;
|
||||
char *fontsize14_end;
|
||||
|
||||
char *fontsize18_begin;
|
||||
char *fontsize18_end;
|
||||
|
||||
char *fontsize24_begin;
|
||||
char *fontsize24_end;
|
||||
|
||||
char *fontsize36_begin;
|
||||
char *fontsize36_end;
|
||||
|
||||
char *fontsize48_begin;
|
||||
char *fontsize48_end;
|
||||
|
||||
char *smaller_begin;
|
||||
char *smaller_end;
|
||||
|
||||
char *bigger_begin;
|
||||
char *bigger_end;
|
||||
|
||||
char *foreground_begin;
|
||||
char *foreground_end;
|
||||
|
||||
char *background_begin;
|
||||
char *background_end;
|
||||
|
||||
char *bold_begin;
|
||||
char *bold_end;
|
||||
|
||||
char *italic_begin;
|
||||
char *italic_end;
|
||||
|
||||
char *underline_begin;
|
||||
char *underline_end;
|
||||
|
||||
char *dbl_underline_begin;
|
||||
char *dbl_underline_end;
|
||||
|
||||
char *superscript_begin;
|
||||
char *superscript_end;
|
||||
|
||||
char *subscript_begin;
|
||||
char *subscript_end;
|
||||
|
||||
char *strikethru_begin;
|
||||
char *strikethru_end;
|
||||
|
||||
char *dbl_strikethru_begin;
|
||||
char *dbl_strikethru_end;
|
||||
|
||||
char *emboss_begin;
|
||||
char *emboss_end;
|
||||
|
||||
char *engrave_begin;
|
||||
char *engrave_end;
|
||||
|
||||
char *shadow_begin;
|
||||
char *shadow_end;
|
||||
|
||||
char *outline_begin;
|
||||
char *outline_end;
|
||||
|
||||
char *small_caps_begin;
|
||||
char *small_caps_end;
|
||||
|
||||
char *pointlist_begin;
|
||||
char *pointlist_end;
|
||||
|
||||
char *pointlist_item_begin;
|
||||
char *pointlist_item_end;
|
||||
|
||||
char *numericlist_begin;
|
||||
char *numericlist_end;
|
||||
|
||||
char *numericlist_item_begin;
|
||||
char *numericlist_item_end;
|
||||
|
||||
char *expand_begin;
|
||||
char *expand_end;
|
||||
|
||||
char *toc_entry_begin;
|
||||
char *toc_entry_end;
|
||||
|
||||
char *index_entry_begin;
|
||||
char *index_entry_end;
|
||||
|
||||
/* XX These should really be replaced by references
|
||||
* to one of the charsets.
|
||||
*/
|
||||
struct {
|
||||
char *bullet;
|
||||
char *left_quote;
|
||||
char *right_quote;
|
||||
char *left_dbl_quote;
|
||||
char *right_dbl_quote;
|
||||
char *nonbreaking_space;
|
||||
char *emdash;
|
||||
char *endash;
|
||||
char *lessthan;
|
||||
char *greaterthan;
|
||||
char *amp;
|
||||
char *copyright;
|
||||
char *trademark;
|
||||
char *nonbreaking_hyphen;
|
||||
char *optional_hyphen;
|
||||
} chars;
|
||||
|
||||
char **ascii_translation_table;
|
||||
|
||||
int simulate_small_caps : 1;
|
||||
int simulate_all_caps : 1;
|
||||
int simulate_word_underline : 1;
|
||||
|
||||
char **ansi_translation_table;
|
||||
short ansi_first_char;
|
||||
short ansi_last_char;
|
||||
char **cp437_translation_table;
|
||||
short cp437_first_char;
|
||||
short cp437_last_char;
|
||||
char **cp850_translation_table;
|
||||
short cp850_first_char;
|
||||
short cp850_last_char;
|
||||
char **mac_translation_table;
|
||||
short mac_first_char;
|
||||
short mac_last_char;
|
||||
#if 1 /* daved 0.20.0 */
|
||||
unsigned int unisymbol1_first_char;
|
||||
unsigned int unisymbol1_last_char;
|
||||
char **unisymbol1_translation_table;
|
||||
unsigned int unisymbol2_first_char;
|
||||
unsigned int unisymbol2_last_char;
|
||||
char **unisymbol2_translation_table;
|
||||
unsigned int unisymbol3_first_char;
|
||||
unsigned int unisymbol3_last_char;
|
||||
char **unisymbol3_translation_table;
|
||||
unsigned int unisymbol4_first_char;
|
||||
unsigned int unisymbol4_last_char;
|
||||
char **unisymbol4_translation_table;
|
||||
#else
|
||||
#if 1 /* daved 0.19.4 unicode support */
|
||||
short unisymbol1_first_char;
|
||||
short unisymbol1_last_char;
|
||||
char **unisymbol1_translation_table;
|
||||
short unisymbol2_first_char;
|
||||
short unisymbol2_last_char;
|
||||
char **unisymbol2_translation_table;
|
||||
short unisymbol3_first_char;
|
||||
short unisymbol3_last_char;
|
||||
char **unisymbol3_translation_table;
|
||||
#endif
|
||||
#if 1 /* daved 0.19.5 more unicode support */
|
||||
short unisymbol4_first_char;
|
||||
short unisymbol4_last_char;
|
||||
char **unisymbol4_translation_table;
|
||||
#endif
|
||||
#endif
|
||||
#if 1 /* daved 0.19.5 SYMBOL font support */
|
||||
short symbol_first_char;
|
||||
short symbol_last_char;
|
||||
char **symbol_translation_table;
|
||||
#endif
|
||||
|
||||
void (*write_set_foreground) (int,int,int);
|
||||
}
|
||||
OutputPersonality;
|
||||
|
||||
|
||||
extern OutputPersonality* op_create(void);
|
||||
extern void op_free (OutputPersonality*);
|
||||
#if 1 /* daved - 0.19.6 */
|
||||
extern char* op_translate_char (OutputPersonality*,int,int, int);
|
||||
#else
|
||||
extern char* op_translate_char (OutputPersonality*,int,int);
|
||||
#endif
|
||||
|
||||
extern void op_begin_std_fontsize (OutputPersonality*, int);
|
||||
extern void op_end_std_fontsize (OutputPersonality*, int);
|
||||
|
||||
|
||||
#define _OUTPUT
|
||||
#endif
|
||||
|
||||
471
plugins/flp_import/unrtf/parse.c
Normal file
471
plugins/flp_import/unrtf/parse.c
Normal file
@@ -0,0 +1,471 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001 Zachary Thayer Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The author is reachable by electronic mail at tuorfa@yahoo.com.
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: parse
|
||||
* Author name: Zach Smith
|
||||
* Create date: 01 Sep 00
|
||||
* Purpose: Parsing of the RTF file into a structure of Word objects.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 15 Oct 00, tuorfa@yahoo.com: parse.c created with functions taken from word.c
|
||||
* 15 Oct 00, tuorfa@yahoo.com: backslash before newline is now \par
|
||||
* 08 Apr 01, tuorfa@yahoo.com: removed limit on word length
|
||||
* 03 Aug 01, tuorfa@yahoo.com: added input buffering
|
||||
* 19 Sep 01, tuorfa@yahoo.com: cleaned up read_word()
|
||||
* 22 Sep 01, tuorfa@yahoo.com: moved word_dump() to word.c
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 08 Sep 03, daved@physiol.usyd.edu.au: type fixes; ANSI C fixes
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "parse.h"
|
||||
#include "malloc.h"
|
||||
#include "main.h"
|
||||
#include "error.h"
|
||||
#include "word.h"
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
|
||||
/* local to getchar stuff */
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
static int ungot_char=-1;
|
||||
static int ungot_char2=-1;
|
||||
static int ungot_char3=-1;
|
||||
#else
|
||||
static int ungot_char = -1;
|
||||
static int ungot_char2 = -1;
|
||||
static int ungot_char3 = -1;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: my_unget_char
|
||||
* Purpose: My own unget routine, handling up to 3 ungot characters.
|
||||
* Args: Character.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
static void my_unget_char (int ch)
|
||||
{
|
||||
if (ungot_char>=0 && ungot_char2>=0 && ungot_char3>=0)
|
||||
error_handler("More than 3 ungot chars");
|
||||
|
||||
ungot_char3 = ungot_char2;
|
||||
ungot_char2 = ungot_char;
|
||||
ungot_char = ch;
|
||||
}
|
||||
|
||||
|
||||
static int last_returned_ch=0;
|
||||
|
||||
|
||||
#define READ_BUF_LEN 2048
|
||||
static int buffer_size = 0;
|
||||
static char *read_buf = NULL;
|
||||
static int read_buf_end = 0;
|
||||
static int read_buf_index = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: my_getchar
|
||||
* Purpose: Gets a character: either an ungot one, or a buffered one.
|
||||
* Args: Input file.
|
||||
* Returns: Character, or EOF.
|
||||
*=======================================================================*/
|
||||
|
||||
static int my_getchar (QBuffer* f)
|
||||
{
|
||||
int ch;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(f);
|
||||
|
||||
if (ungot_char>=0) {
|
||||
ch = ungot_char;
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
ungot_char=ungot_char2;
|
||||
ungot_char2=ungot_char3;
|
||||
ungot_char3=-1;
|
||||
#else
|
||||
ungot_char = ungot_char2;
|
||||
ungot_char2 = ungot_char3;
|
||||
ungot_char3 = -1;
|
||||
#endif
|
||||
last_returned_ch = ch;
|
||||
if(ch > 255)
|
||||
{
|
||||
fprintf(stderr, "returning bad ch = '%c' (0%o)\n",
|
||||
ch, ch);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
do {
|
||||
if (read_buf_index >= read_buf_end) {
|
||||
if (!read_buf) {
|
||||
buffer_size = READ_BUF_LEN;
|
||||
read_buf = my_malloc (buffer_size);
|
||||
if (!read_buf) {
|
||||
buffer_size /= 4;
|
||||
read_buf = my_malloc (buffer_size);
|
||||
if (!read_buf)
|
||||
error_handler("Cannot allocate read buffer");
|
||||
}
|
||||
}
|
||||
read_buf_end = f->readBlock(read_buf, buffer_size);
|
||||
read_buf_index = 0;
|
||||
if (!read_buf_end)
|
||||
return EOF;
|
||||
}
|
||||
ch = read_buf [read_buf_index++];
|
||||
|
||||
if (ch=='\n') {
|
||||
lineno++;
|
||||
/* Convert \(newline) into \par here */
|
||||
if (last_returned_ch=='\\') {
|
||||
my_unget_char (' ');
|
||||
my_unget_char ('r');
|
||||
my_unget_char ('a');
|
||||
ch = 'p';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (ch=='\r' /* || ch=='\n' */ );
|
||||
|
||||
if (ch=='\t') ch = ' ';
|
||||
|
||||
last_returned_ch = ch;
|
||||
if(ch > 255)
|
||||
{
|
||||
fprintf(stderr,"returning bad ch '%c' (0%o)\n", ch, ch);
|
||||
exit(1);
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
/* local to read_word */
|
||||
static char *input_str = NULL;
|
||||
static unsigned long current_max_length = 1;
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: expand_word_buffer
|
||||
* Purpose: Expands the buffer used to store an incoming word.
|
||||
* This allows us to remove the limit on word length.
|
||||
* Args: None.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
static int
|
||||
expand_word_buffer ()
|
||||
{
|
||||
char *new_ptr;
|
||||
unsigned long old_length;
|
||||
if (!input_str)
|
||||
error_handler("No input buffer allocated");
|
||||
old_length = current_max_length;
|
||||
current_max_length *= 2;
|
||||
new_ptr = my_malloc (current_max_length);
|
||||
if (!new_ptr)
|
||||
error_handler("Out of memory while resizing buffer");
|
||||
|
||||
memcpy (new_ptr, input_str, old_length);
|
||||
my_free(input_str);
|
||||
input_str = new_ptr;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: read_word
|
||||
* Purpose: The core of the parser, this reads a word.
|
||||
* Args: Input file.
|
||||
* Returns: Number of characters in the word, or zero.
|
||||
* Note: The word buffer is static and local to this file.
|
||||
*=======================================================================*/
|
||||
|
||||
static int
|
||||
read_word (QBuffer*f)
|
||||
{
|
||||
#if 0 /* daved - 0.19.0 */
|
||||
int ch, ch2, ix=0;
|
||||
#else
|
||||
int ch, ch2;
|
||||
unsigned long ix=0;
|
||||
#endif
|
||||
int have_whitespace=FALSE;
|
||||
int is_control_word=FALSE;
|
||||
int has_numeric_param=FALSE; /* if is_control_word==TRUE */
|
||||
int need_unget=FALSE;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(f);
|
||||
|
||||
current_max_length = 10; /* XX */
|
||||
|
||||
/* Get some storage for a word.
|
||||
*/
|
||||
input_str = my_malloc (current_max_length);
|
||||
if (!input_str)
|
||||
error_handler("Cannot allocate word storage");
|
||||
|
||||
do {
|
||||
ch = my_getchar(f);
|
||||
}
|
||||
while (ch=='\n');
|
||||
|
||||
if (ch==' ')
|
||||
{
|
||||
/* Compress multiple space chars down to one.
|
||||
*/
|
||||
while (ch == ' ') {
|
||||
ch = my_getchar(f);
|
||||
have_whitespace=TRUE;
|
||||
}
|
||||
if (have_whitespace) {
|
||||
my_unget_char (ch);
|
||||
input_str[0]=' ';
|
||||
input_str[1]=0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
switch(ch)
|
||||
{
|
||||
case EOF:
|
||||
return 0;
|
||||
|
||||
case '\\':
|
||||
ch2 = my_getchar(f);
|
||||
|
||||
/* Look for two-character command words.
|
||||
*/
|
||||
switch (ch2)
|
||||
{
|
||||
case '\n':
|
||||
strcpy (input_str, "\\par");
|
||||
return 4;
|
||||
case '~':
|
||||
case '{':
|
||||
case '}':
|
||||
case '\\':
|
||||
case '_':
|
||||
case '-':
|
||||
input_str[0] = '\\';
|
||||
input_str[1] = ch2;
|
||||
input_str[2] = 0;
|
||||
return 2;
|
||||
case '\'':
|
||||
/* Preserve \'## expressions (hex char exprs) for later.
|
||||
*/
|
||||
input_str[0]='\\';
|
||||
input_str[1]='\'';
|
||||
ix=2;
|
||||
if(ix==current_max_length) {
|
||||
if (!expand_word_buffer ())
|
||||
error_handler("Word too long");
|
||||
}
|
||||
ch = my_getchar(f);
|
||||
input_str[ix++]=ch;
|
||||
if(ix==current_max_length) {
|
||||
if (!expand_word_buffer ())
|
||||
error_handler("Word too long");
|
||||
}
|
||||
ch = my_getchar(f);
|
||||
input_str[ix++]=ch;
|
||||
if(ix==current_max_length) {
|
||||
if (!expand_word_buffer ())
|
||||
error_handler("Word too long");
|
||||
}
|
||||
input_str[ix]=0;
|
||||
return ix;
|
||||
}
|
||||
|
||||
is_control_word=TRUE;
|
||||
ix=1;
|
||||
input_str[0]=ch;
|
||||
ch=ch2;
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
/* In RTF, a tab char is the same as \tab.
|
||||
*/
|
||||
strcpy (input_str, "\\tab");
|
||||
return 4;
|
||||
|
||||
case '{':
|
||||
case '}':
|
||||
case ';':
|
||||
input_str[0]=ch;
|
||||
input_str[1]=0;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
while (ch!=EOF)
|
||||
{
|
||||
/* Several chars always ends a word, and we need to save them.
|
||||
*/
|
||||
if (ch=='\t' || ch=='{' || ch=='}' || ch=='\\') {
|
||||
need_unget=TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* A newline always ends a command word; we don't save it.
|
||||
* A newline is ignored if this is not a command word.
|
||||
*/
|
||||
if (ch=='\n') {
|
||||
if (is_control_word)
|
||||
break;
|
||||
ch = my_getchar(f);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* A semicolon always ends a command word; we do save it.
|
||||
* A semicolon never ends a regular word.
|
||||
*/
|
||||
if (ch==';') {
|
||||
if (is_control_word) {
|
||||
need_unget=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* In this parser, a space character terminates
|
||||
* any word, and if it does not follow a command,
|
||||
* then it is a word in itself.
|
||||
*/
|
||||
if (ch==' ') {
|
||||
if (!is_control_word)
|
||||
need_unget=TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Identify a control word's numeric parameter.
|
||||
*/
|
||||
if (is_control_word) {
|
||||
if (!has_numeric_param && (isdigit(ch) || ch=='-'))
|
||||
has_numeric_param = TRUE;
|
||||
else
|
||||
if (has_numeric_param && !isdigit(ch)) {
|
||||
if (ch!=' ')
|
||||
need_unget=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
input_str[ix++] = ch;
|
||||
if (ix==current_max_length) {
|
||||
if (!expand_word_buffer ())
|
||||
error_handler("Word too long");
|
||||
}
|
||||
ch = my_getchar (f);
|
||||
}
|
||||
|
||||
if (need_unget)
|
||||
my_unget_char(ch);
|
||||
|
||||
input_str[ix]=0;
|
||||
return ix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: word_read
|
||||
* Purpose: This is the recursive metareader which pieces together the
|
||||
* structure of Word objects.
|
||||
* Args: Input file.
|
||||
* Returns: Tree of Word objects.
|
||||
*=======================================================================*/
|
||||
|
||||
Word *
|
||||
word_read (QBuffer* f) {
|
||||
Word * prev_word = NULL;
|
||||
Word * first_word = NULL;
|
||||
Word * new_word = NULL; /* temp */
|
||||
|
||||
CHECK_PARAM_NOT_NULL(f);
|
||||
|
||||
do {
|
||||
if (!read_word(f))
|
||||
return first_word;
|
||||
|
||||
if (input_str[0] == '{') {
|
||||
/* Process subwords */
|
||||
|
||||
/* Create a dummy word to point to a sublist */
|
||||
new_word = word_new(NULL);
|
||||
if (!new_word)
|
||||
error_handler("Cannot allocate word");
|
||||
|
||||
/* Get the sublist */
|
||||
new_word->child = word_read(f);
|
||||
|
||||
} else if (input_str[0] == '}') {
|
||||
return first_word;
|
||||
} else {
|
||||
new_word = word_new(input_str);
|
||||
}
|
||||
|
||||
if (prev_word)
|
||||
prev_word->next = new_word;
|
||||
|
||||
if (!first_word)
|
||||
first_word = new_word;
|
||||
|
||||
prev_word = new_word;
|
||||
|
||||
/* Free up the memory allocated by read_word. */
|
||||
my_free(input_str);
|
||||
input_str = NULL;
|
||||
} while (1);
|
||||
}
|
||||
44
plugins/flp_import/unrtf/parse.h
Normal file
44
plugins/flp_import/unrtf/parse.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: parse.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 15 Oct 2000
|
||||
* Purpose: Definitions and externs for parse.c.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 15 Oct 00, tuorfa@yahoo.com: parse.h created with functions taken from word.c
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#ifndef _WORD
|
||||
#include "word.h"
|
||||
#endif
|
||||
|
||||
|
||||
extern Word *word_read(QBuffer*);
|
||||
|
||||
|
||||
|
||||
71
plugins/flp_import/unrtf/util.c
Normal file
71
plugins/flp_import/unrtf/util.c
Normal file
@@ -0,0 +1,71 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: util
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Aug 01
|
||||
* Purpose: Utility functions.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: h2toi
|
||||
* Purpose: Converts a 2-digit hexadecimal value to an unsigned integer.
|
||||
* Args: String.
|
||||
* Returns: Integer.
|
||||
*=======================================================================*/
|
||||
|
||||
/* Convert a two-char hexadecimal expression to an integer */
|
||||
int
|
||||
h2toi (char *s) {
|
||||
int tmp;
|
||||
int ch;
|
||||
tmp = tolower(*s++);
|
||||
if (tmp>'9') tmp-=('a'-10);
|
||||
else tmp-='0';
|
||||
ch=16*tmp;
|
||||
tmp = tolower(*s++);
|
||||
if (tmp>'9') tmp-=('a'-10);
|
||||
else tmp-='0';
|
||||
ch+=tmp;
|
||||
return ch;
|
||||
}
|
||||
|
||||
33
plugins/flp_import/unrtf/util.h
Normal file
33
plugins/flp_import/unrtf/util.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: util
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Aug 2001
|
||||
* Purpose: Definitions for util module.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
extern int h2toi (char *);
|
||||
215
plugins/flp_import/unrtf/word.c
Normal file
215
plugins/flp_import/unrtf/word.c
Normal file
@@ -0,0 +1,215 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: word
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 01 Sep 00
|
||||
* Purpose: Management of Word objects, which contain strings
|
||||
* as well as other Words.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 14 Oct 00, tuorfa@yahoo.com: fixed \fs bug (# is 2X the point size).
|
||||
* 14 Oct 00, tuorfa@yahoo.com: fixed table data printing.
|
||||
* 14 Oct 00, tuorfa@yahoo.com: protection against null entries in \info
|
||||
* 14 Oct 00, tuorfa@yahoo.com: fixed printing of <body> again
|
||||
* 14 Oct 00, tuorfa@yahoo.com: fixed closure of tables
|
||||
* 15 Oct 00, tuorfa@yahoo.com: fixed font attributes preceding <tr><td>
|
||||
* 15 Oct 00, tuorfa@yahoo.com: attributes now continue if >1 \cell in group
|
||||
* 15 Oct 00, tuorfa@yahoo.com: fixed font-size bug, lack of </head>
|
||||
* 7 Nov 00, tuorfa@yahoo.com: fixed \'## translatin bug
|
||||
* 8 Apr 01, tuorfa@yahoo.com: added check for out of memory after malloc
|
||||
* 21 Apr 01, tuorfa@yahoo.com: bug fixes regarding author, date
|
||||
* 21 Apr 01, tuorfa@yahoo.com: added paragraph alignment
|
||||
* 21 Apr 01, tuorfa@yahoo.com: fix for words getting lost after \par
|
||||
* 24 Jul 01, tuorfa@yahoo.com: moved conversion code to convert.c
|
||||
* 22 Sep 01, tuorfa@yahoo.com: moved word_dump to here from parse.c
|
||||
* 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTYPE_H
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "parse.h"
|
||||
#include "malloc.h"
|
||||
#include "main.h"
|
||||
#include "error.h"
|
||||
#include "word.h"
|
||||
#include "hash.h"
|
||||
|
||||
|
||||
/* For word_dump */
|
||||
static int indent_level=0;
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: word_string
|
||||
* Purpose: Obtains the string of a Word object. This involves accessing
|
||||
* the Word hash.
|
||||
* Args: Word*.
|
||||
* Returns: String.
|
||||
*=======================================================================*/
|
||||
|
||||
char *
|
||||
word_string (Word *w) {
|
||||
char *str;
|
||||
CHECK_PARAM_NOT_NULL(w);
|
||||
if (w->hash_index) str = hash_get_string (w->hash_index);
|
||||
else str = NULL;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: word_new
|
||||
* Purpose: Instantiates a new Word object.
|
||||
* Args: String.
|
||||
* Returns: Word*.
|
||||
*=======================================================================*/
|
||||
|
||||
Word *
|
||||
word_new (char *str) {
|
||||
Word * w;
|
||||
|
||||
w = (Word *) my_malloc(sizeof(Word));
|
||||
if (!w)
|
||||
error_handler ("out of memory");
|
||||
memset ((void*) w, 0, sizeof(Word));
|
||||
if (!w) error_handler ("cannot allocate a Word");
|
||||
|
||||
if (str) w->hash_index = hash_get_index (str);
|
||||
else w->hash_index = 0;
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: word_free
|
||||
* Purpose: Deallocates a Word object. This is only called at the end of
|
||||
* main(), after everything is processed and output complete.
|
||||
* Args: Word.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void word_free (Word *w) {
|
||||
Word *prev;
|
||||
Word *w2;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(w);
|
||||
|
||||
while (w) {
|
||||
w2 = w->child;
|
||||
if (w2)
|
||||
word_free(w2);
|
||||
|
||||
prev = w;
|
||||
w = w->next;
|
||||
my_free((char*) prev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: print_indentation
|
||||
* Purpose: Prints padding for the word_dump routine.
|
||||
* Args: Identation level.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
static void
|
||||
print_indentation (int level)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (level) {
|
||||
for (i=0;i<level;i+=2)
|
||||
printf (". ");
|
||||
} else {
|
||||
printf ("\n-----------------------------------------------------------------------\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*========================================================================
|
||||
* Name: word_dump
|
||||
* Purpose: Recursive diagnostic routine to print out a tree of words.
|
||||
* Args: Word tree.
|
||||
* Returns: None.
|
||||
*=======================================================================*/
|
||||
|
||||
void
|
||||
word_dump (Word *w)
|
||||
{
|
||||
char *s;
|
||||
|
||||
CHECK_PARAM_NOT_NULL(w);
|
||||
|
||||
printf ("\n");
|
||||
indent_level += 2;
|
||||
print_indentation (indent_level);
|
||||
|
||||
while (w) {
|
||||
s = word_string (w);
|
||||
if (s) {
|
||||
printf ("\"%s\" ", s);
|
||||
} else {
|
||||
if (w->child) {
|
||||
word_dump (w->child);
|
||||
printf ("\n");
|
||||
print_indentation (indent_level);
|
||||
}
|
||||
else
|
||||
warning_handler ("Word object has no string and no children");
|
||||
}
|
||||
w = w->next;
|
||||
}
|
||||
|
||||
indent_level -= 2;
|
||||
}
|
||||
52
plugins/flp_import/unrtf/word.h
Normal file
52
plugins/flp_import/unrtf/word.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*=============================================================================
|
||||
GNU UnRTF, a command-line program to convert RTF documents to other formats.
|
||||
Copyright (C) 2000,2001,2004 by Zachary Smith
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
The maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au
|
||||
=============================================================================*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* Module name: word.h
|
||||
* Author name: Zachary Smith
|
||||
* Create date: 1 Sept 2000
|
||||
* Purpose: Definitions for Word class.
|
||||
*----------------------------------------------------------------------
|
||||
* Changes:
|
||||
* 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _WORD
|
||||
#define _WORD
|
||||
|
||||
class QBuffer;
|
||||
|
||||
typedef struct _w {
|
||||
unsigned long hash_index;
|
||||
struct _w * next;
|
||||
struct _w * child;
|
||||
} Word;
|
||||
|
||||
extern Word* word_new (char*);
|
||||
extern void word_free (Word*);
|
||||
extern Word* word_read (QBuffer*);
|
||||
extern char* word_string (Word*);
|
||||
extern void word_dump (Word*);
|
||||
extern void word_print_html (Word*);
|
||||
|
||||
#define _WORD
|
||||
#endif
|
||||
@@ -574,6 +574,21 @@ void tripleOscillator::loadSettings( const QDomElement & _this )
|
||||
|
||||
|
||||
|
||||
void tripleOscillator::setParameter( const QString & _param,
|
||||
const QString & _value )
|
||||
{
|
||||
if( _param == "samplefile" )
|
||||
{
|
||||
for( int i = 0; i < NUM_OF_OSCILLATORS; ++i )
|
||||
{
|
||||
m_osc[i].m_sampleBuffer->setAudioFile( _value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QString tripleOscillator::nodeName( void ) const
|
||||
{
|
||||
return( tripleoscillator_plugin_descriptor.name );
|
||||
|
||||
@@ -56,6 +56,9 @@ public:
|
||||
QDomElement & _parent );
|
||||
virtual void FASTCALL loadSettings( const QDomElement & _this );
|
||||
|
||||
virtual void FASTCALL setParameter( const QString & _param,
|
||||
const QString & _value );
|
||||
|
||||
virtual QString nodeName( void ) const;
|
||||
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ impulseEditor::impulseEditor( QWidget * _parent, int _x, int _y,
|
||||
m_graph->setSamplePointer( m_sampleShape, m_sampleLength );
|
||||
|
||||
m_lastBtn = m_sinWaveBtn;
|
||||
emit( sinWaveClicked() );
|
||||
emit( sawWaveClicked() );
|
||||
|
||||
move( _x, _y );
|
||||
|
||||
|
||||
@@ -514,8 +514,7 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
|
||||
// correctly... -> arp_frames frames silence at the start of every note!
|
||||
int cur_frame = ( ( m_arpModeComboBox->value() != FREE ) ?
|
||||
cnphv.first()->totalFramesPlayed() :
|
||||
_n->totalFramesPlayed() )
|
||||
+ arp_frames - 1;
|
||||
_n->totalFramesPlayed() ) + arp_frames - 1;
|
||||
// used for loop
|
||||
fpab_t frames_processed = 0;
|
||||
|
||||
@@ -536,6 +535,8 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
|
||||
// init with zero
|
||||
int cur_arp_idx = 0;
|
||||
|
||||
// in sorted mode: is it our turn or do we have to be quiet for
|
||||
// now?
|
||||
if( m_arpModeComboBox->value() == SORT &&
|
||||
( ( cur_frame / arp_frames ) % total_range ) /
|
||||
range != (Uint32) _n->index() )
|
||||
|
||||
@@ -180,6 +180,7 @@ configManager::configManager( void ) :
|
||||
m_pluginDir( "/usr/lib/lmms" ),
|
||||
#endif
|
||||
m_vstDir( QDir::home().absolutePath() ),
|
||||
m_flDir( QDir::home().absolutePath() ),
|
||||
m_currentPage( 0 )
|
||||
{
|
||||
}
|
||||
@@ -557,6 +558,14 @@ void configManager::setArtworkDir( const QString & _ad )
|
||||
|
||||
|
||||
|
||||
void configManager::setFLDir( const QString & _fd )
|
||||
{
|
||||
m_flDir = _fd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void configManager::accept( void )
|
||||
{
|
||||
if( m_workingDir.right( 1 ) != "/" )
|
||||
@@ -821,12 +830,18 @@ bool configManager::loadConfigFile( void )
|
||||
}
|
||||
m_workingDir = value( "paths", "workingdir" );
|
||||
m_vstDir = value( "paths", "vstdir" );
|
||||
m_flDir = value( "paths", "fldir" );
|
||||
|
||||
if( m_vstDir == "" )
|
||||
{
|
||||
m_vstDir = QDir::home().absolutePath();
|
||||
}
|
||||
|
||||
if( m_flDir == "" )
|
||||
{
|
||||
m_flDir = QDir::home().absolutePath();
|
||||
}
|
||||
|
||||
if( root.isElement() )
|
||||
{
|
||||
QString cfg_file_ver = root.toElement().attribute( "version" );
|
||||
@@ -872,6 +887,7 @@ void configManager::saveConfigFile( void )
|
||||
setValue( "paths", "artwork", m_artworkDir );
|
||||
setValue( "paths", "workingdir", m_workingDir );
|
||||
setValue( "paths", "vstdir", m_vstDir );
|
||||
setValue( "paths", "fldir", m_flDir );
|
||||
|
||||
QDomDocument doc( "lmms-config-file" );
|
||||
|
||||
|
||||
@@ -458,16 +458,19 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab,
|
||||
|
||||
|
||||
|
||||
f_cnt_t envelopeTabWidget::envFrames( void )
|
||||
f_cnt_t envelopeTabWidget::envFrames( const bool _only_vol )
|
||||
{
|
||||
f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_pahdFrames;
|
||||
|
||||
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
|
||||
if( _only_vol == FALSE )
|
||||
{
|
||||
if( m_envLFOWidgets[i]->used() &&
|
||||
m_envLFOWidgets[i]->m_pahdFrames > ret_val )
|
||||
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
|
||||
{
|
||||
ret_val = m_envLFOWidgets[i]->m_pahdFrames;
|
||||
if( m_envLFOWidgets[i]->used() &&
|
||||
m_envLFOWidgets[i]->m_pahdFrames > ret_val )
|
||||
{
|
||||
ret_val = m_envLFOWidgets[i]->m_pahdFrames;
|
||||
}
|
||||
}
|
||||
}
|
||||
return( ret_val );
|
||||
@@ -476,15 +479,19 @@ f_cnt_t envelopeTabWidget::envFrames( void )
|
||||
|
||||
|
||||
|
||||
f_cnt_t envelopeTabWidget::releaseFrames( void )
|
||||
f_cnt_t envelopeTabWidget::releaseFrames( const bool _only_vol )
|
||||
{
|
||||
f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->m_rFrames;
|
||||
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
|
||||
f_cnt_t ret_val = m_envLFOWidgets[VOLUME]->used() ?
|
||||
m_envLFOWidgets[VOLUME]->m_rFrames : 0;
|
||||
if( m_envLFOWidgets[VOLUME]->used() == FALSE )
|
||||
{
|
||||
if( m_envLFOWidgets[i]->used() &&
|
||||
m_envLFOWidgets[i]->m_rFrames > ret_val )
|
||||
for( int i = VOLUME+1; i < TARGET_COUNT; ++i )
|
||||
{
|
||||
ret_val = m_envLFOWidgets[i]->m_rFrames;
|
||||
if( m_envLFOWidgets[i]->used() &&
|
||||
m_envLFOWidgets[i]->m_rFrames > ret_val )
|
||||
{
|
||||
ret_val = m_envLFOWidgets[i]->m_rFrames;
|
||||
}
|
||||
}
|
||||
}
|
||||
return( ret_val );
|
||||
|
||||
@@ -251,7 +251,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
|
||||
if( m_instrumentTrack != NULL )
|
||||
{
|
||||
m_releaseFramesToDo = tMax<f_cnt_t>( 10,
|
||||
m_instrumentTrack->m_envWidget->releaseFrames() );
|
||||
m_instrumentTrack->m_envWidget->releaseFrames() );
|
||||
if( !configManager::inst()->value( "ui",
|
||||
"manualchannelpiano" ).toInt() )
|
||||
{
|
||||
@@ -280,7 +280,8 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
|
||||
f_cnt_t notePlayHandle::actualReleaseFramesToDo( void ) const
|
||||
{
|
||||
return( ( m_instrumentTrack != NULL ) ?
|
||||
m_instrumentTrack->m_envWidget->releaseFrames() : 0 );
|
||||
m_instrumentTrack->m_envWidget->releaseFrames(
|
||||
arpBaseNote() ) : 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
|
||||
m_workingDir( configManager::inst()->workingDir() ),
|
||||
m_vstDir( configManager::inst()->vstDir() ),
|
||||
m_artworkDir( configManager::inst()->artworkDir() ),
|
||||
m_flDir( configManager::inst()->flDir() ),
|
||||
m_disableChActInd( configManager::inst()->value( "ui",
|
||||
"disablechannelactivityindicators" ).toInt() ),
|
||||
m_manualChPiano( configManager::inst()->value( "ui",
|
||||
@@ -137,7 +138,7 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
|
||||
m_tabBar->setFixedWidth( 72 );
|
||||
|
||||
QWidget * ws = new QWidget( settings );
|
||||
ws->setFixedSize( 360, 240 );
|
||||
ws->setFixedSize( 360, 300 );
|
||||
|
||||
QWidget * general = new QWidget( ws );
|
||||
general->setFixedSize( 360, 240 );
|
||||
@@ -245,7 +246,7 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
|
||||
|
||||
|
||||
QWidget * directories = new QWidget( ws );
|
||||
directories->setFixedSize( 360, 200 );
|
||||
directories->setFixedSize( 360, 260 );
|
||||
QVBoxLayout * dir_layout = new QVBoxLayout( directories );
|
||||
dir_layout->setSpacing( 0 );
|
||||
dir_layout->setMargin( 0 );
|
||||
@@ -289,7 +290,6 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
|
||||
connect( vstdir_select_btn, SIGNAL( clicked() ), this,
|
||||
SLOT( openVSTDir() ) );
|
||||
|
||||
|
||||
// artwork-dir
|
||||
tabWidget * artwork_tw = new tabWidget( tr(
|
||||
"Artwork directory" ).toUpper(),
|
||||
@@ -309,12 +309,33 @@ setupDialog::setupDialog( engine * _engine, configTabs _tab_to_open ) :
|
||||
connect( artworkdir_select_btn, SIGNAL( clicked() ), this,
|
||||
SLOT( openArtworkDir() ) );
|
||||
|
||||
// FL Studio-dir
|
||||
tabWidget * fl_tw = new tabWidget( tr(
|
||||
"FL Studio installation directory" ).toUpper(),
|
||||
directories );
|
||||
fl_tw->setFixedHeight( 56 );
|
||||
|
||||
m_fdLineEdit = new QLineEdit( m_flDir, fl_tw );
|
||||
m_fdLineEdit->setGeometry( 10, 20, 300, 16 );
|
||||
connect( m_fdLineEdit, SIGNAL( textChanged( const QString & ) ), this,
|
||||
SLOT( setFLDir( const QString & ) ) );
|
||||
|
||||
QPushButton * fldir_select_btn = new QPushButton(
|
||||
embed::getIconPixmap( "project_open", 16, 16 ),
|
||||
"", fl_tw );
|
||||
fldir_select_btn->setFixedSize( 24, 24 );
|
||||
fldir_select_btn->move( 320, 20 );
|
||||
connect( fldir_select_btn, SIGNAL( clicked() ), this,
|
||||
SLOT( openFLDir() ) );
|
||||
|
||||
|
||||
dir_layout->addWidget( lmms_wd_tw );
|
||||
dir_layout->addSpacing( 10 );
|
||||
dir_layout->addWidget( vst_tw );
|
||||
dir_layout->addSpacing( 10 );
|
||||
dir_layout->addWidget( artwork_tw );
|
||||
dir_layout->addSpacing( 10 );
|
||||
dir_layout->addWidget( fl_tw );
|
||||
dir_layout->addStretch();
|
||||
|
||||
|
||||
@@ -623,6 +644,7 @@ void setupDialog::accept( void )
|
||||
configManager::inst()->setWorkingDir( m_workingDir );
|
||||
configManager::inst()->setVSTDir( m_vstDir );
|
||||
configManager::inst()->setArtworkDir( m_artworkDir );
|
||||
configManager::inst()->setFLDir( m_flDir );
|
||||
|
||||
// tell all audio-settings-widget to save their settings
|
||||
for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin();
|
||||
@@ -847,6 +869,33 @@ void setupDialog::setArtworkDir( const QString & _ad )
|
||||
|
||||
|
||||
|
||||
void setupDialog::openFLDir( void )
|
||||
{
|
||||
#ifdef QT4
|
||||
QString new_dir = QFileDialog::getExistingDirectory( this,
|
||||
tr( "Choose FL Studio installation directory" ),
|
||||
m_flDir );
|
||||
#else
|
||||
QString new_dir = QFileDialog::getExistingDirectory( m_flDir, 0, 0,
|
||||
tr( "Choose FL Studio installation directory" ), TRUE );
|
||||
#endif
|
||||
if( new_dir != QString::null )
|
||||
{
|
||||
m_fdLineEdit->setText( new_dir );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void setupDialog::setFLDir( const QString & _fd )
|
||||
{
|
||||
m_flDir = _fd;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void setupDialog::audioInterfaceChanged( const QString & _iface )
|
||||
{
|
||||
for( aswMap::iterator it = m_audioIfaceSetupWidgets.begin();
|
||||
|
||||
@@ -741,7 +741,7 @@ void songEditor::setTempo( int _new_bpm )
|
||||
|
||||
void songEditor::setMasterVolume( volume _vol )
|
||||
{
|
||||
m_masterVolumeSlider->setValue( _vol );
|
||||
m_masterVolumeSlider->setValue( 200 - _vol );
|
||||
}
|
||||
|
||||
|
||||
@@ -749,7 +749,7 @@ void songEditor::setMasterVolume( volume _vol )
|
||||
|
||||
void songEditor::setMasterPitch( int _master_pitch )
|
||||
{
|
||||
m_masterPitchSlider->setValue( _master_pitch );
|
||||
m_masterPitchSlider->setValue( -_master_pitch );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,10 +96,14 @@ trackContainer::trackContainer( engine * _engine ) :
|
||||
|
||||
trackContainer::~trackContainer()
|
||||
{
|
||||
eng()->getProjectJournal()->setJournalling( FALSE );
|
||||
|
||||
while( m_trackWidgets.size() )
|
||||
{
|
||||
removeTrack( m_trackWidgets.front()->getTrack() );
|
||||
}
|
||||
|
||||
eng()->getProjectJournal()->setJournalling( TRUE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user