diff --git a/ChangeLog b/ChangeLog index fc236e421..ab24e44f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,79 @@ +2006-04-04 Tobias Doerffel + + * 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 + + * 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 + + * plugins/flp_import/flp_import.cpp: + - hack for converting RTF-comment to HTML using unrtf (if installed) + +2006-03-30 Tobias Doerffel + + * 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 + * 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 diff --git a/TODO b/TODO index b40430d86..8f64ba7d8 100644 --- a/TODO +++ b/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 diff --git a/configure.in b/configure.in index 6f006ebcc..789e16668 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/include/arp_and_chords_tab_widget.h b/include/arp_and_chords_tab_widget.h index a8949c1e1..ee910f3e4 100644 --- a/include/arp_and_chords_tab_widget.h +++ b/include/arp_and_chords_tab_widget.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; + } ; diff --git a/include/config_mgr.h b/include/config_mgr.h index bea65d9b7..a5d0d342c 100644 --- a/include/config_mgr.h +++ b/include/config_mgr.h @@ -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 > stringPairVector; typedef QMap settingsMap; diff --git a/include/debug.h b/include/debug.h index 6b3d5e2c1..b111cc155 100644 --- a/include/debug.h +++ b/include/debug.h @@ -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 #include -#endif +/*#endif*/ #endif diff --git a/include/envelope_and_lfo_widget.h b/include/envelope_and_lfo_widget.h index 0ba8fe00b..28ac3203d 100644 --- a/include/envelope_and_lfo_widget.h +++ b/include/envelope_and_lfo_widget.h @@ -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; } ; diff --git a/include/envelope_tab_widget.h b/include/envelope_tab_widget.h index 6e88c48d9..c3d77b2e1 100644 --- a/include/envelope_tab_widget.h +++ b/include/envelope_tab_widget.h @@ -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 diff --git a/include/instrument_track.h b/include/instrument_track.h index c3b73bb06..5895e8764 100755 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -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: diff --git a/include/setup_dialog.h b/include/setup_dialog.h index 877d0dc28..f2aa06d39 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -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; diff --git a/plugins/audio_file_processor/audio_file_processor.cpp b/plugins/audio_file_processor/audio_file_processor.cpp index b560e1176..ac42ec6e0 100644 --- a/plugins/audio_file_processor/audio_file_processor.cpp +++ b/plugins/audio_file_processor/audio_file_processor.cpp @@ -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 / diff --git a/plugins/flp_import/Makefile.am b/plugins/flp_import/Makefile.am index f2a288a31..e3e5f6c40 100644 --- a/plugins/flp_import/Makefile.am +++ b/plugins/flp_import/Makefile.am @@ -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" diff --git a/plugins/flp_import/flp_import.cpp b/plugins/flp_import/flp_import.cpp index 81f191146..6516d0dc1 100644 --- a/plugins/flp_import/flp_import.cpp +++ b/plugins/flp_import/flp_import.cpp @@ -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 #include #include +#include +#include #else #include #include #include - -#define pos at -#define setValue setProgress +#include +#include #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 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( data ) ); + static_cast( 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( data % + NOTES_PER_OCTAVE ) ); + it->setBaseOctave( static_cast( 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( + 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 diff --git a/plugins/flp_import/flp_import.h b/plugins/flp_import/flp_import.h index a995f169b..65ec48c3c 100755 --- a/plugins/flp_import/flp_import.h +++ b/plugins/flp_import/flp_import.h @@ -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 > patternNoteVector; patternNoteVector m_notes; + typedef vlist stepVector; + stepVector m_steps; + typedef vlist playListItems; playListItems m_plItems; diff --git a/plugins/flp_import/unrtf/attr.c b/plugins/flp_import/unrtf/attr.c new file mode 100644 index 000000000..43e352444 --- /dev/null +++ b/plugins/flp_import/unrtf/attr.c @@ -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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#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 */ + 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 */ + 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 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; iattr_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 + * 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 + * 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 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--; + } +} + diff --git a/plugins/flp_import/unrtf/attr.h b/plugins/flp_import/unrtf/attr.h new file mode 100644 index 000000000..640730f82 --- /dev/null +++ b/plugins/flp_import/unrtf/attr.h @@ -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 diff --git a/plugins/flp_import/unrtf/convert.c b/plugins/flp_import/unrtf/convert.c new file mode 100644 index 000000000..433514b3c --- /dev/null +++ b/plugins/flp_import/unrtf/convert.c @@ -0,0 +1,3172 @@ + +/*=========================================================================== + GNU UnRTF, a command-line program to convert RTF documents to other formats. + Copyright (C) 2000,2001,2004 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 maintainer is reachable by electronic mail at daved@physiol.usyd.edu.au +===========================================================================*/ + + +/*---------------------------------------------------------------------- + * Module name: convert + * Author name: Zachary Smith + * Create date: 24 Jul 01 + * Purpose: Performs conversion from RTF to other formats. + *---------------------------------------------------------------------- + * Changes: + * 24 Jul 01, tuorfa@yahoo.com: moved code over from word.c + * 24 Jul 01, tuorfa@yahoo.com: fixed color table reference numbering. + * 30 Jul 01, tuorfa@yahoo.com: moved hex convert to util.c + * 30 Jul 01, tuorfa@yahoo.com: moved special expr tables to special.c + * 30 Jul 01, tuorfa@yahoo.com: moved attribute stack to attr.c + * 31 Jul 01, tuorfa@yahoo.com: began addition of hash of rtf commands + * 01 Aug 01, tuorfa@yahoo.com: finished bulk of rtf command hash + * 03 Aug 01, tuorfa@yahoo.com: removed no-op hash entries to save space + * 03 Aug 01, tuorfa@yahoo.com: code to ignore rest of groups for \*, etc + * 03 Aug 01, tuorfa@yahoo.com: fixed para-alignnot being cleared by \pard + * 03 Aug 01, tuorfa@yahoo.com: added support for \keywords group + * 03 Aug 01, tuorfa@yahoo.com: added dummy funcs for header/footer + * 03 Aug 01, tuorfa@yahoo.com: began addition of hyperlink support + * 04 Aug 01, tuorfa@yahoo.com: fixed debug string printing + * 05 Aug 01, tuorfa@yahoo.com: added support for hyperlink data with \field + * 06 Aug 01, tuorfa@yahoo.com: added support for several font attributes + * 08 Aug 01, gommer@gmx.net: bugfix for picture storing mechanism + * 08 Sep 01, tuorfa@yahoo.com: added use of UnRTF + * 11 Sep 01, tuorfa@yahoo.com: added support for JPEG and PNG pictures + * 19 Sep 01, tuorfa@yahoo.com: added output personality support + * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks + * 23 Sep 01, tuorfa@yahoo.com: fixed translation of \'XX expressions + * 08 Oct 03, daved@physiol.usyd.edu.au: more special character code + * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith + * 29 Mar 05, daved@physiol.usyd.edu.au: more unicode support + * 31 Mar 05, daved@physiol.usyd.edu.au: strcat security bug fixed + * 06 Jan 06, marcossamaral@terra.com.br: patch from debian 0.19.3-1.1 + * 03 Mar 06, daved@physiol.usyd.edu.au: fixed creation date spelling + and added support for accented characters in titles from + Laurent Monin + # 09 Mar 06, daved@physiol.usyd.edu.au: don't print null post_trans + *--------------------------------------------------------------------*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_CTYPE_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#include "defs.h" +#include "parse.h" +#include "util.h" +#include "malloc.h" +#include "main.h" +#include "error.h" +#include "word.h" +#include "hash.h" +#include "convert.h" +#include "attr.h" + + +//extern int nopict_mode; + +/* +#define BINARY_ATTRS +*/ + +QString outstring; + + +static int charset_type=CHARSET_ANSI; + + +/* Nested tables aren't supported. + */ +static int coming_pars_that_are_tabular = 0; +static int within_table = FALSE; +static int have_printed_row_begin=FALSE; +static int have_printed_cell_begin=FALSE; +static int have_printed_row_end=FALSE; +static int have_printed_cell_end=FALSE; + + +/* Previously in word_print_core function + */ +static int total_chars_this_line=0; /* for simulating \tab */ + + +/* Paragraph alignment (kludge) + */ +enum { + ALIGN_LEFT=0, + ALIGN_RIGHT, + ALIGN_CENTER, + ALIGN_JUSTIFY +}; + + + +/* This value is set by attr_push and attr_pop + */ +int simulate_smallcaps; +int simulate_allcaps; + + +/* Most pictures must be written to files. */ +enum { + PICT_UNKNOWN=0, + PICT_WM, + PICT_MAC, + PICT_PM, + PICT_DI, + PICT_WB, + PICT_JPEG, + PICT_PNG, +}; +static int within_picture=FALSE; +static int picture_file_number=1; +static char picture_path[255]; +static int picture_width; +static int picture_height; +static int picture_bits_per_pixel=1; +static int picture_type=PICT_UNKNOWN; +static int picture_wmetafile_type; +static char *picture_wmetafile_type_str; + + +static int have_printed_body=FALSE; +static int within_header=TRUE; + + + +static char *hyperlink_base = NULL; + + + +void starting_body(); +void starting_text(); +#if 1 /* daved - 0.19.6 */ +void print_with_special_exprs (char *s); +#endif + + +#if 0 /* daved - 0.19.0 removed in 0.19.5 */ +char *entity(int symbol); +#endif + + + + +/*======================================================================== + * Name: starting_body + * Purpose: Switches output stream for writing document contents. + * Args: None. + * Returns: None. + *=======================================================================*/ + +void +starting_body () +{ + if (!have_printed_body) { + if (!inline_mode) { + outstring+=QString().sprintf(op->header_end); + outstring+=QString().sprintf(op->body_begin); + } + within_header = FALSE; + have_printed_body = TRUE; + } +} + + +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ + + +static char *month_strings[12]= { +#ifdef ENGLISH + "January","February","March","April","May","June","July","August", + "September","October","November","December" +#endif +#ifdef FRANCAIS + "Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre", + "Octobre","Novembre","Decembre" +#endif +#ifdef ITALIANO + "Ianuario","Febbraio","Marzo","Aprile","Maggio","Iuno", + "Luglio","Agusto","Settembre","Ottobre","Novembre","Dicembre" +#endif +#ifdef ESPANOL /* amaral - 0.19.2 */ + "Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto", + "Septiembre","Octubre","Noviembre","Diciembre" +#endif +#ifdef DEUTCH + "?","?","?","?","?","?","?","?", + "?","?","?","?" +#endif +#ifdef PORTUGUES /* amaral - 0.19.2 */ + "Janeiro","Fevereiro","Marco","Abril","Maio","Junho","Julho","Agosto", + "Setembro","Outubro","Novembro","Dezembro" +#endif +}; + + +/*======================================================================== + * Name: word_dump_date + * Purpose: Extracts date from an RTF input stream, writes it to + * output stream. + * Args: Word*, buffered RTF stream + * Returns: None. + *=======================================================================*/ + +void +word_dump_date (Word *w) +{ + int year=0, month=0, day=0, hour=0, minute=0; + CHECK_PARAM_NOT_NULL(w); + while (w) { + char *s = word_string (w); + if (*s == '\\') { + ++s; + if (!strncmp (s, "yr", 2) && isdigit(s[2])) { + year = atoi (&s[2]); + } + else if (!strncmp (s, "mo", 2) && isdigit(s[2])) { + month= atoi (&s[2]); + } + else if (!strncmp (s, "dy", 2) && isdigit(s[2])) { + day= atoi (&s[2]); + } + else if (!strncmp (s, "min", 3) && isdigit(s[3])) { + minute= atoi (&s[3]); + } + else if (!strncmp (s, "hr", 2) && isdigit(s[2])) { + hour= atoi (&s[2]); + } + } + w=w->next; + } + if (year && month && day) { + outstring+=QString().sprintf("%d %s %d ", day, month_strings[month-1], year); + } + if (hour && minute) { + outstring+=QString().sprintf("%02d:%02d ", hour, minute); + } +} + + + +/*-------------------------------------------------------------------*/ + +typedef struct { + int num; + char *name; +} FontEntry; + +#define MAX_FONTS (8192) +static FontEntry font_table[MAX_FONTS]; +static int total_fonts=0; + + + +/*======================================================================== + * Name: lookup_fontname + * Purpose: Fetches the name of a font from the already-read font table. + * Args: Font#. + * Returns: Font name. + *=======================================================================*/ + +char* +lookup_fontname (int num) { + int i; + if (total_fonts) + for(i=0;ichild)) { + tmp = word_string(w2); + if (!strncmp("\\f", tmp, 2)) { + num = atoi(&tmp[2]); + name[0] = 0; + + w2 = w2->next; + while (w2) { + tmp = word_string (w2); + if (tmp && tmp[0] != '\\') { + if (strlen(tmp) + strlen(name) > BUFSIZ - 1) { + printf("Invalid font table entry\n"); + name[0] = 0; + } + else + strncat(name,tmp,sizeof(name) - strlen(name) - 1); + } + w2 = w2->next; + } + + /* Chop the gall-derned semicolon. */ + if ((tmp = strchr(name, ';'))) + *tmp = 0; + + font_table[total_fonts].num=num; + font_table[total_fonts].name=my_strdup(name); + total_fonts++; + } + } + w=w->next; + } + + printf(op->comment_begin); + printf("font table contains %d fonts total",total_fonts); + printf(op->comment_end); + + if (debug_mode) { + int i; + + printf(op->comment_begin); + printf("font table dump: \n"); + for (i=0; icomment_end); + } +} + + +/*======================================================================== + * Name: process_index_entry + * Purpose: Processes an index entry of an RTF file. + * Args: Tree of words. + * Returns: None. + *=======================================================================*/ + +void +process_index_entry (Word *w) +{ + Word *w2; + + CHECK_PARAM_NOT_NULL(w); + + while(w) { + if ((w2=w->child)) { + char *str = word_string (w2); + + if (debug_mode && str) { + printf(op->comment_begin); + printf("index entry word: %s ", str); + printf(op->comment_end); + } + } + w=w->next; + } +} + + +/*======================================================================== + * Name: process_toc_entry + * Purpose: Processes an index entry of an RTF file. + * Args: Tree of words, flag to say whether to include a page#. + * Returns: None. + *=======================================================================*/ + +void +process_toc_entry (Word *w, int include_page_num) +{ + Word *w2; + + CHECK_PARAM_NOT_NULL(w); + + while(w) { + if ((w2=w->child)) { + char *str = word_string (w2); + + if (debug_mode && str) { + printf(op->comment_begin); + printf("toc %s entry word: %s ", + include_page_num ? "page#":"no page#", + str); + printf(op->comment_end); + } + } + w=w->next; + } +} + + +/*======================================================================== + * Name: process_info_group + * Purpose: Processes the \info group of an RTF file. + * Args: Tree of words. + * Returns: None. + *=======================================================================*/ + +void +process_info_group (Word *w) +{ + Word *child; + +#if 1 /* amaral - 0.19.2 */ + /* CHECK_PARAM_NOT_NULL(w); */ + if (!w) printf("AUTHOR'S COMMENT: \\info command is null!\n"); +#endif + + + while(w) { + child = w->child; + if (child) { + Word *w2; + char *s; + + s = word_string(child); + + if (!inline_mode) { + if (!strcmp("\\title", s)) { + outstring+=QString().sprintf(op->document_title_begin); + w2=child->next; + while (w2) { + char *s2 = word_string(w2); + if (s2[0] != '\\') +#if 1 /* daved 0.20.0 */ + { +#endif +#if 1 /* daved 0.19.6 */ + print_with_special_exprs (s2); +#else + outstring+=QString().sprintf("%s", s2); +#endif +#if 1 /* daved 0.20.0 */ + } + else + { + if (s2[1] == '\'') + { + int ch = h2toi (&s2[2]); + + char *s3; + s3 = op_translate_char (op, charset_type, ch, numchar_table); + if (!s3 || !*s3) + { + printf(op->comment_begin); + printf("char 0x%02x",ch); + printf(op->comment_end); + + } + else + { + if (op->word_begin) + outstring+=QString().sprintf(op->word_begin); + outstring+=QString().sprintf("%s", s3); + if (op->word_end) + outstring+=QString().sprintf(op->word_end); + } + } + } + +#endif + w2 = w2->next; + } + outstring+=QString().sprintf(op->document_title_end); + } + else if (!strcmp("\\keywords", s)) { + outstring+=QString().sprintf(op->document_keywords_begin); + w2=child->next; + while (w2) { + char *s2 = word_string(w2); + if (s2[0] != '\\') + outstring+=QString().sprintf("%s,", s2); + w2 = w2->next; + } + outstring+=QString().sprintf(op->document_keywords_end); + } + else if (!strcmp("\\author", s)) { + outstring+=QString().sprintf(op->document_author_begin); + w2=child->next; + while (w2) { + char *s2 = word_string(w2); + if (s2[0] != '\\') + outstring+=QString().sprintf("%s", s2); + w2 = w2->next; + } + outstring+=QString().sprintf(op->document_author_end); + } + else if (!strcmp("\\comment", s)) { + printf(op->comment_begin); + printf("comments: "); + w2=child->next; + while (w2) { + char *s2 = word_string(w2); + if (s2[0] != '\\') + printf("%s", s2); + w2 = w2->next; + } + printf(op->comment_end); + } + else if (!strncmp("\\nofpages", s, 9)) { + printf(op->comment_begin); + printf("total pages: %s",&s[9]); + printf(op->comment_end); + } + else if (!strncmp("\\nofwords", s, 9)) { + printf(op->comment_begin); + printf("total words: %s",&s[9]); + printf(op->comment_end); + } + else if (!strncmp("\\nofchars", s, 9) && isdigit(s[9])) { + printf(op->comment_begin); + printf("total chars: %s",&s[9]); + printf(op->comment_end); + } + else if (!strcmp("\\creatim", s)) { + printf(op->comment_begin); + printf("creation date: "); + if (child->next) word_dump_date (child->next); + printf(op->comment_end); + } + else if (!strcmp("\\printim", s)) { + printf(op->comment_begin); + printf("last printed: "); + if (child->next) word_dump_date (child->next); + printf(op->comment_end); + } + else if (!strcmp("\\buptim", s)) { + printf(op->comment_begin); + printf("last backup: "); + if (child->next) word_dump_date (child->next); + printf(op->comment_end); + } + else if (!strcmp("\\revtim", s)) { + printf(op->comment_begin); + printf("revision date: "); + if (child->next) word_dump_date (child->next); + printf(op->comment_end); + } + } + + /* Irregardless of whether we're in inline mode, + * we want to process the following. + */ + if (!strcmp("\\hlinkbase", s)) { + char *linkstr = NULL; + + printf(op->comment_begin); + printf("hyperlink base: "); + if (child->next) { + Word *nextword = child->next; + + if (nextword) + linkstr=word_string (nextword); + } + + if (linkstr) + printf("%s", linkstr); + else + printf("(none)"); + printf(op->comment_end); + + /* Store the pointer, it will remain good. */ + hyperlink_base = linkstr; + } + } + w = w->next; + } +} + +/*-------------------------------------------------------------------*/ + +/* RTF color table colors are RGB */ + +typedef struct { + unsigned char r,g,b; +} Color; + +#define MAX_COLORS (1024) +static Color color_table[MAX_COLORS]; +static int total_colors=0; + + +/*======================================================================== + * Name: process_color_table + * Purpose: Processes the color table of an RTF file. + * Args: Tree of words. + * Returns: None. + *=======================================================================*/ + +void +process_color_table (Word *w) +{ + int r,g,b; + + CHECK_PARAM_NOT_NULL(w); + + /* Sometimes, RTF color tables begin with a semicolon, + * i.e. an empty color entry. This seems to indicate that color 0 + * will not be used, so here I set it to black. + */ + r=g=b=0; + + while(w) { + char *s = word_string (w); + +#if 0 + printf(op->comment_begin); + printf("found this color table word: %s", word_string(w)); + printf(op->comment_end); +#endif + + if (!strncmp("\\red",s,4)) { + r = atoi(&s[4]); + while(r>255) r>>=8; + } + else if (!strncmp("\\green",s,6)) { + g = atoi(&s[6]); + while(g>255) g>>=8; + } + else if (!strncmp("\\blue",s,5)) { + b = atoi(&s[5]); + while(b>255) b>>=8; + } + else + /* If we find the semicolon which denotes the end of + * a color entry then store the color, even if we don't + * have all of it. + */ + if (!strcmp (";", s)) { + color_table[total_colors].r = r; + color_table[total_colors].g = g; + color_table[total_colors++].b = b; + if (debug_mode) { + printf(op->comment_begin); + printf("storing color entry %d: %02x%02x%02x", + total_colors-1, r,g,b); + printf(op->comment_end); + } + r=g=b=0; + } + + w=w->next; + } + + if (debug_mode) { + printf(op->comment_begin); + printf("color table had %d entries -->\n", total_colors); + printf(op->comment_end); + } +} + +/*======================================================================== + * Name: cmd_cf + * Purpose: Executes the \cf command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_cf (Word *w, int align, char has_param, int num) { + char str[40]; + + if (!has_param || num>=total_colors) { + warning_handler ("font color change attempted is invalid"); + } + else + { + sprintf(str,"#%02x%02x%02x", + color_table[num].r, + color_table[num].g, + color_table[num].b); + attr_push(ATTR_FOREGROUND,str); + } + return FALSE; +} + + + +/*======================================================================== + * Name: cmd_cb + * Purpose: Executes the \cb command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_cb (Word *w, int align, char has_param, int num) { + char str[40]; + + if (!has_param || num>=total_colors) { + warning_handler ("font color change attempted is invalid"); + } + else + { + sprintf(str,"#%02x%02x%02x", + color_table[num].r, + color_table[num].g, + color_table[num].b); + attr_push(ATTR_BACKGROUND,str); + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_fs + * Purpose: Executes the \fs command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_fs (Word *w, int align, char has_param, int points) { + char str[20]; + + if (!has_param) return FALSE; + + /* Note, fs20 means 10pt */ + points /= 2; + + sprintf(str,"%d",points); + attr_push(ATTR_FONTSIZE,str); + + return FALSE; +} + + +/*======================================================================== + * Name: cmd_field + * Purpose: Interprets fields looking for hyperlinks. + * Comment: Because hyperlinks are put in \field groups, + * we must interpret all \field groups, which is + * slow and laborious. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_field (Word *w, int align, char has_param, int num) { + Word *child; + + CHECK_PARAM_NOT_NULL(w); + + while(w) { + child = w->child; + if (child) { + Word *w2; + char *s; + + s = word_string(child); + + if (!strcmp("\\*", s)) + { + w2=child->next; + while (w2) + { + char *s2 = word_string(w2); + if (s2 && !strcmp("\\fldinst", s2)) + { + Word *w3; +#if 1 /* daved - 0.19.2 */ + char *s; + char *s4; + Word *w4; +#endif + w3=w2->next; +#if 1 /* daved - 0.19.0 */ + s = word_string(w3); + if (s && !strcmp(s, "SYMBOL") ) + { + w4=w3->next; + while(w4 && !strcmp(word_string(w4), " ")) + w4 = w4->next; + s4 = word_string(w4); + if (s4) + { + int char_num; + char_num = atoi(s4); + if + ( + op->symbol_first_char <= char_num + && + op->symbol_last_char >= char_num + ) + { + char * string; + if ((string = op->symbol_translation_table[char_num - op->symbol_first_char]) != 0) + outstring+=QString().sprintf("%s", string); + } + } + } +#endif + while (w3 && !w3->child) { + w3=w3->next; + } + if (w3) w3=w3->child; + while (w3) + { + char *s3=word_string(w3); + if (s3 && !strcmp("HYPERLINK",s3)) { + Word *w4; + char *s4; + w4=w3->next; + while (w4 && !strcmp(" ", word_string(w4))) + w4=w4->next; + if (w4) { + s4=word_string(w4); + outstring+=QString().sprintf(op->hyperlink_begin); + outstring+=QString().sprintf("%s", s4); + outstring+=QString().sprintf(op->hyperlink_end); + return TRUE; + } + + } + w3=w3->next; + } + } + w2 = w2->next; + } + + } + } + w=w->next; + } + return TRUE; +} + + + +/*======================================================================== + * Name: cmd_f + * Purpose: Executes the \f command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_f (Word *w, int align, char has_param, int num) { + char *name; + + /* no param exit early XX */ + if (!has_param) + return FALSE; + + name = lookup_fontname(num); +#if 1 /* daved - 0.19.6 */ + /* if a character is requested by number, we will need to know + which translation table to use - roman or symbol */ + numchar_table = FONTROMAN_TABLE; +#endif + if (!name) { + printf(op->comment_begin); + printf("invalid font number %d",num); + printf(op->comment_end); + } else { + attr_push(ATTR_FONTFACE,name); +#if 1 /* daved - 0.19.6 */ + if (strstr(name,"Symbol") != NULL) + numchar_table=FONTSYMBOL_TABLE; +#endif + } + + return FALSE; +} + + +/*======================================================================== + * Name: cmd_highlight + * Purpose: Executes the \cf command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_highlight (Word *w, int align, char has_param, int num) +{ + char str[40]; + + if (!has_param || num>=total_colors) { + warning_handler ("font background color change attempted is invalid"); + } + else + { + sprintf(str,"#%02x%02x%02x", + color_table[num].r, + color_table[num].g, + color_table[num].b); + attr_push(ATTR_BACKGROUND,str); + } + return FALSE; +} + + + +/*======================================================================== + * Name: cmd_tab + * Purpose: Executes the \tab command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_tab (Word *w, int align, char has_param, int param) +{ + /* Tab presents a genuine problem + * since some output formats don't have + * an equivalent. As a kludge fix, I shall + * assume the font is fixed width and that + * the tabstops are 8 characters apart. + */ + int need= 8-(total_chars_this_line%8); + total_chars_this_line += need; + while(need>0) { + outstring+=QString().sprintf(op->forced_space); + need--; + } + outstring+=QString().sprintf("\n"); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_plain + * Purpose: Executes the \plain command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_plain (Word *w, int align, char has_param, int param) { + attr_pop_all(); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_fnil + * Purpose: Executes the \fnil command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_fnil (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTNIL_STR); + return FALSE; +} + + + +/*======================================================================== + * Name: cmd_froman + * Purpose: Executes the \froman command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_froman (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTROMAN_STR); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_fswiss + * Purpose: Executes the \fswiss command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_fswiss (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTSWISS_STR); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_fmodern + * Purpose: Executes the \fmodern command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_fmodern (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTMODERN_STR); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_fscript + * Purpose: Executes the \fscript command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_fscript (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTSCRIPT_STR); + return FALSE; +} + +/*======================================================================== + * Name: cmd_fdecor + * Purpose: Executes the \fdecor command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_fdecor (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTDECOR_STR); + return FALSE; +} + +/*======================================================================== + * Name: cmd_ftech + * Purpose: Executes the \ftech command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_ftech (Word *w, int align, char has_param, int param) { + attr_push(ATTR_FONTFACE,FONTTECH_STR); + return FALSE; +} + +/*======================================================================== + * Name: cmd_expand + * Purpose: Executes the \expand command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_expand (Word *w, int align, char has_param, int param) { + char str[10]; + if (has_param) { + sprintf(str, "%d", param/4); + if (!param) + attr_pop(ATTR_EXPAND); + else + attr_push(ATTR_EXPAND, str); + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_emboss + * Purpose: Executes the \embo command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_emboss (Word *w, int align, char has_param, int param) { + char str[10]; + if (has_param && !param) + attr_pop(ATTR_EMBOSS); + else + { + sprintf(str, "%d", param); + attr_push(ATTR_EMBOSS, str); + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_engrave + * Purpose: Executes the \impr command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_engrave (Word *w, int align, char has_param, int param) { + char str[10]; + if (has_param && !param) + attr_pop(ATTR_ENGRAVE); + else + { + sprintf(str, "%d", param); + attr_push(ATTR_ENGRAVE, str); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_caps + * Purpose: Executes the \caps command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_caps (Word *w, int align, char has_param, int param) { + if (has_param && !param) + attr_pop(ATTR_CAPS); + else + attr_push(ATTR_CAPS,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_scaps + * Purpose: Executes the \scaps command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_scaps (Word *w, int align, char has_param, int param) { + if (has_param && !param) + attr_pop(ATTR_SMALLCAPS); + else + attr_push(ATTR_SMALLCAPS,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_bullet + * Purpose: Executes the \bullet command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_bullet (Word *w, int align, char has_param, int param) { + if (op->chars.bullet) { + outstring+=QString().sprintf(op->chars.bullet); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_ldblquote + * Purpose: Executes the \ldblquote command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_ldblquote (Word *w, int align, char has_param, int param) { + if (op->chars.left_dbl_quote) { + outstring+=QString().sprintf(op->chars.left_dbl_quote); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_rdblquote + * Purpose: Executes the \rdblquote command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_rdblquote (Word *w, int align, char has_param, int param) { + if (op->chars.right_dbl_quote) { + outstring+=QString().sprintf(op->chars.right_dbl_quote); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_lquote + * Purpose: Executes the \lquote command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_lquote (Word *w, int align, char has_param, int param) { + if (op->chars.left_quote) { + outstring+=QString().sprintf(op->chars.left_quote); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_nonbreaking_space + * Purpose: Executes the nonbreaking space command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_nonbreaking_space (Word *w, int align, char has_param, int param) { + if (op->chars.nonbreaking_space) { + outstring+=QString().sprintf(op->chars.nonbreaking_space); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_nonbreaking_hyphen + * Purpose: Executes the nonbreaking hyphen command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_nonbreaking_hyphen (Word *w, int align, char has_param, int param) { + if (op->chars.nonbreaking_hyphen) { + outstring+=QString().sprintf(op->chars.nonbreaking_hyphen); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_optional_hyphen + * Purpose: Executes the optional hyphen command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_optional_hyphen (Word *w, int align, char has_param, int param) { + if (op->chars.optional_hyphen) { + outstring+=QString().sprintf(op->chars.optional_hyphen); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_emdash + * Purpose: Executes the \emdash command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_emdash (Word *w, int align, char has_param, int param) { + if (op->chars.emdash) { + outstring+=QString().sprintf(op->chars.emdash); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_endash + * Purpose: Executes the \endash command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_endash (Word *w, int align, char has_param, int param) { + if (op->chars.endash) { + outstring+=QString().sprintf(op->chars.endash); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_rquote + * Purpose: Executes the \rquote command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_rquote (Word *w, int align, char has_param, int param) { + if (op->chars.right_quote) { + outstring+=QString().sprintf(op->chars.right_quote); + ++total_chars_this_line; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_par + * Purpose: Executes the \par command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int +cmd_par (Word *w, int align, char has_param, int param) { + if (op->line_break) { + outstring+=QString().sprintf(op->line_break); + total_chars_this_line = 0; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_line + * Purpose: Executes the \line command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_line (Word *w, int align, char has_param, int param) { + if (op->line_break) { + outstring+=QString().sprintf(op->line_break); + total_chars_this_line = 0; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_page + * Purpose: Executes the \page command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_page (Word *w, int align, char has_param, int param) { + if (op->page_break) { + outstring+=QString().sprintf(op->page_break); + total_chars_this_line = 0; /* \tab */ + } + return FALSE; +} + + +/*======================================================================== + * Name: cmd_intbl + * Purpose: Executes the \intbl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_intbl (Word *w, int align, char has_param, int param) { + ++coming_pars_that_are_tabular; + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulnone + * Purpose: Executes the \ulnone command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulnone (Word *w, int align, char has_param, int param) { + int attr, more=TRUE; +#ifdef BINARY_ATTRS + attr_remove_underlining(); +#else + do { + attr = attr_read(); + if (attr==ATTR_UNDERLINE || + attr==ATTR_DOT_UL || + attr==ATTR_DASH_UL || + attr==ATTR_DOT_DASH_UL || + attr==ATTR_2DOT_DASH_UL || + attr==ATTR_WORD_UL || + attr==ATTR_WAVE_UL || + attr==ATTR_THICK_UL || + attr==ATTR_DOUBLE_UL) + { + if (!attr_pop(ATTR_UNDERLINE)) + ; + } else + more=FALSE; + } while(more); +#endif + return FALSE; +} + +/*======================================================================== + * Name: cmd_ul + * Purpose: Executes the \ul command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ul (Word *w, int align, char has_param, int param) { + if (has_param && param == 0) { + cmd_ulnone(w, align, has_param, param); + } else { + attr_push(ATTR_UNDERLINE, NULL); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_uld + * Purpose: Executes the \uld command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_uld (Word *w, int align, char has_param, int param) { + attr_push(ATTR_DOUBLE_UL, NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_uldb + * Purpose: Executes the \uldb command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_uldb (Word *w, int align, char has_param, int param) { + attr_push(ATTR_DOT_UL, NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_uldash + * Purpose: Executes the \uldash command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_uldash (Word *w, int align, char has_param, int param) { + attr_push(ATTR_DASH_UL, NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_uldashd + * Purpose: Executes the \cmd_uldashd command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_uldashd (Word *w, int align, char has_param, int param) { + attr_push(ATTR_DOT_DASH_UL,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_uldashdd + * Purpose: Executes the \uldashdd command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_uldashdd (Word *w, int align, char has_param, int param) { + attr_push(ATTR_2DOT_DASH_UL,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulw + * Purpose: Executes the \ulw command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulw (Word *w, int align, char has_param, int param) { + attr_push(ATTR_WORD_UL,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulth + * Purpose: Executes the \ulth command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulth (Word *w, int align, char has_param, int param) { + attr_push(ATTR_THICK_UL,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulthd + * Purpose: Executes the \ulthd command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulthd (Word *w, int align, char has_param, int param) { + attr_push(ATTR_THICK_UL, NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulthdash + * Purpose: Executes the \ulthdash command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulthdash (Word *w, int align, char has_param, int param) { + attr_push(ATTR_THICK_UL, NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_ulwave + * Purpose: Executes the \ulwave command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ulwave (Word *w, int align, char has_param, int param) { + attr_push(ATTR_WAVE_UL,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_strike + * Purpose: Executes the \strike command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_strike (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_STRIKE); + else + attr_push(ATTR_STRIKE,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_strikedl + * Purpose: Executes the \strikedl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_strikedl (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_DBL_STRIKE); + else + attr_push(ATTR_DBL_STRIKE,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_striked + * Purpose: Executes the \striked command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_striked (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_DBL_STRIKE); + else + attr_push(ATTR_DBL_STRIKE,NULL); + return FALSE; +} + + +/*======================================================================== + * Name: cmd_rtf + * Purpose: Executes the \rtf command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_rtf (Word *w, int align, char has_param, int param) { + return FALSE; +} + + +/*======================================================================== + * Name: cmd_up + * Purpose: Executes the \up command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_up (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_SUPER); + else + attr_push(ATTR_SUPER,NULL); + return FALSE; +} + +#if 1 /* daved - 0.19.4 */ +/*======================================================================== + * Name: cmd_u + * Purpose: Processes a Unicode character + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, always false + *=======================================================================*/ + +static int cmd_u (Word *w, int align, char has_param, int param) { + short done=0; +/*#if DEBUG + char *str; + if (has_param == TRUE) + { + fprintf(stderr,"param is %d (%x)\n", param, + param); + } + if (w->hash_index) + { + str=hash_get_string (w->hash_index); + fprintf(stderr,"string is %s\n", str); + } +#endif*/ + if + ( + (uchar)param >= op->unisymbol1_first_char + && + (uchar)param <= op->unisymbol1_last_char + ) + { + char *string; + if ((string = op->unisymbol1_translation_table[param - op->unisymbol1_first_char]) != 0) + outstring+=QString().sprintf("%s", string); + else + outstring+=QString().sprintf("&#%u;", (unsigned int)param); + done++; + } + if + ( + (uchar)param >= op->unisymbol2_first_char + && + (uchar)param <= op->unisymbol2_last_char + ) + { + char *string; + if ((string = op->unisymbol2_translation_table[param - op->unisymbol2_first_char]) != 0) + outstring+=QString().sprintf("%s", string); + else + outstring+=QString().sprintf("&#%u;", (unsigned int)param); + done++; + } + if + ( + (uchar)param >= op->unisymbol3_first_char + && + (uchar)param <= op->unisymbol3_last_char + ) + { + char *string; + if ((string = op->unisymbol3_translation_table[param - op->unisymbol3_first_char]) != 0) + outstring+=QString().sprintf("%s", string); + else + outstring+=QString().sprintf("&#%u;", (unsigned int)param); + done++; + } +#if 1 /* 0.19.5 more unicode support */ + if + ( + (uchar)param >= op->unisymbol4_first_char + && + (uchar)param <= op->unisymbol4_last_char + ) + { + char *string; + if ((string = op->unisymbol4_translation_table[param - op->unisymbol4_first_char]) != 0) + outstring+=QString().sprintf("%s", string); + else + outstring+=QString().sprintf("&#%u;", (unsigned int)param); + done++; + } +#endif + + /* + ** if we know how to represent the unicode character in the + ** output language, we need to skip the next word, otherwise + ** we will output that alternative. + */ + if (done) + return(SKIP_ONE_WORD); + return(FALSE); +} +#endif + +/*======================================================================== + * Name: cmd_dn + * Purpose: Executes the \dn command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_dn (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_SUB); + else + attr_push(ATTR_SUB,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_nosupersub + * Purpose: Executes the \nosupersub command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_nosupersub (Word *w, int align, char has_param, int param) { + attr_pop(ATTR_SUPER); + attr_pop(ATTR_SUB); + return FALSE; +} + +/*======================================================================== + * Name: cmd_super + * Purpose: Executes the \super command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_super (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_SUPER); + else + attr_push(ATTR_SUPER,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_sub + * Purpose: Executes the \sub command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_sub (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_SUB); + else + attr_push(ATTR_SUB,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_shad + * Purpose: Executes the \shad command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_shad (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_SHADOW); + else + attr_push(ATTR_SHADOW,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_b + * Purpose: Executes the \b command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int +cmd_b (Word *w, int align, char has_param, int param) { + if (has_param && param==0) { + attr_pop(ATTR_BOLD); + } + else + attr_push(ATTR_BOLD,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_i + * Purpose: Executes the \i command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_i (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_ITALIC); + else + attr_push(ATTR_ITALIC,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_s + * Purpose: Executes the \s command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ +static int cmd_s (Word *w, int align, char has_param, int param) { + return FALSE; +} + +/*======================================================================== + * Name: cmd_sect + * Purpose: Executes the \sect command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_sect (Word *w, int align, char has_param, int param) { + /* XX kludge */ + if (op->paragraph_begin) { + outstring+=QString().sprintf(op->paragraph_begin); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_shp + * Purpose: Executes the \shp command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_shp (Word *w, int align, char has_param, int param) { + if (op->comment_begin) { + printf(op->comment_begin); + printf("Drawn Shape (ignored--not implemented yet)"); + printf(op->comment_begin); + } + + return FALSE; +} + +/*======================================================================== + * Name: cmd_outl + * Purpose: Executes the \outl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_outl (Word *w, int align, char has_param, int param) { + if (has_param && param==0) + attr_pop(ATTR_OUTLINE); + else + attr_push(ATTR_OUTLINE,NULL); + return FALSE; +} + +/*======================================================================== + * Name: cmd_ansi + * Purpose: Executes the \ansi command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ansi (Word *w, int align, char has_param, int param) { + charset_type = CHARSET_ANSI; + if (op->comment_begin) { + printf(op->comment_begin); + printf("document uses ANSI character set"); + printf(op->comment_end); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_pc + * Purpose: Executes the \pc command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pc (Word *w, int align, char has_param, int param) { + charset_type = CHARSET_CP437 ; + if (op->comment_begin) { + printf(op->comment_begin); + printf("document uses PC codepage 437 character set"); + printf(op->comment_end); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_pca + * Purpose: Executes the \pca command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pca (Word *w, int align, char has_param, int param) { + charset_type = CHARSET_CP850; + if (op->comment_begin) { + printf(op->comment_begin); + printf("document uses PC codepage 850 character set"); + printf(op->comment_end); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_mac + * Purpose: Executes the \mac command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_mac (Word *w, int align, char has_param, int param) { + charset_type = CHARSET_MAC; + if (op->comment_begin) { + printf(op->comment_begin); + printf("document uses Macintosh character set"); + printf(op->comment_end); + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_colortbl + * Purpose: Executes the \colortbl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_colortbl (Word *w, int align, char has_param, int param) { + if (w->next) { + process_color_table(w->next); + } + return TRUE; +} + +/*======================================================================== + * Name: cmd_fonttbl + * Purpose: Executes the \fonttbl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_fonttbl (Word *w, int align, char has_param, int param) { + if (w->next) { + process_font_table(w->next); + } + return TRUE; +} + +/*======================================================================== + * Name: cmd_header + * Purpose: Executes the \header command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_header (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_headerl + * Purpose: Executes the \headerl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_headerl (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_headerr + * Purpose: Executes the \headerr command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_headerr (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_headerf + * Purpose: Executes the \headerf command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_headerf (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_footer + * Purpose: Executes the \footer command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_footer (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_footerl + * Purpose: Executes the \footerl command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_footerl (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_footerr + * Purpose: Executes the \footerr command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_footerr (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_footerf + * Purpose: Executes the \footerf command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_footerf (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_ignore + * Purpose: Dummy function to get rid of subgroups + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_ignore (Word *w, int align, char has_param, int param) { + return TRUE; +} + +/*======================================================================== + * Name: cmd_info + * Purpose: Executes the \info command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_info (Word *w, int align, char has_param, int param) { + process_info_group (w->next); + return TRUE; +} + +/*======================================================================== + * Name: cmd_pict + * Purpose: Executes the \pict command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pict (Word *w, int align, char has_param, int param) { + within_picture=TRUE; + picture_width = picture_height = 0; + picture_type = PICT_WB; + return FALSE; +} + +/*======================================================================== + * Name: cmd_bin + * Purpose: Executes the \bin command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_bin (Word *w, int align, char has_param, int param) { + return FALSE; +} + + +/*======================================================================== + * Name: cmd_macpict + * Purpose: Executes the \macpict command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_macpict (Word *w, int align, char has_param, int param) { + picture_type = PICT_MAC; + return FALSE; +} + +/*======================================================================== + * Name: cmd_jpegblip + * Purpose: Executes the \jpegblip command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_jpegblip (Word *w, int align, char has_param, int param) { + picture_type = PICT_JPEG; + return FALSE; +} + +/*======================================================================== + * Name: cmd_pngblip + * Purpose: Executes the \pngblip command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pngblip (Word *w, int align, char has_param, int param) { + picture_type = PICT_PNG; + return FALSE; +} + +/*======================================================================== + * Name: cmd_pnmetafile + * Purpose: Executes the \pnmetafile command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pnmetafile (Word *w, int align, char has_param, int param) { + picture_type = PICT_PM; + return FALSE; +} + +/*======================================================================== + * Name: cmd_wmetafile + * Purpose: Executes the \wmetafile command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_wmetafile (Word *w, int align, char has_param, int param) { + picture_type = PICT_WM; + if (within_picture && has_param) { + picture_wmetafile_type=param; + switch(param) { + case 1: picture_wmetafile_type_str="MM_TEXT"; break; + case 2: picture_wmetafile_type_str="MM_LOMETRIC"; break; + case 3: picture_wmetafile_type_str="MM_HIMETRIC"; break; + case 4: picture_wmetafile_type_str="MM_LOENGLISH"; break; + case 5: picture_wmetafile_type_str="MM_HIENGLISH"; break; + case 6: picture_wmetafile_type_str="MM_TWIPS"; break; + case 7: picture_wmetafile_type_str="MM_ISOTROPIC"; break; + case 8: picture_wmetafile_type_str="MM_ANISOTROPIC"; break; + default: picture_wmetafile_type_str="default:MM_TEXT"; break; + } + } + return FALSE; +} + +/*======================================================================== + * Name: cmd_wbmbitspixel + * Purpose: Executes the \wbmbitspixel command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_wbmbitspixel (Word *w, int align, char has_param, int param) { + if (within_picture && has_param) + picture_bits_per_pixel = param; + return FALSE; +} + +/*======================================================================== + * Name: cmd_picw + * Purpose: Executes the \picw command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_picw (Word *w, int align, char has_param, int param) { + if (within_picture && has_param) + picture_width = param; + return FALSE; +} + +/*======================================================================== + * Name: cmd_pich + * Purpose: Executes the \pich command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_pich (Word *w, int align, char has_param, int param) { + if (within_picture && has_param) + picture_height = param; + return FALSE; +} + + +/*======================================================================== + * Name: cmd_xe + * Purpose: Executes the \xe (index entry) command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_xe (Word *w, int align, char has_param, int param) { + process_index_entry (w); + return TRUE; +} + +/*======================================================================== + * Name: cmd_tc + * Purpose: Executes the \tc (TOC entry) command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_tc (Word *w, int align, char has_param, int param) { + process_toc_entry (w, TRUE); + return TRUE; +} + +/*======================================================================== + * Name: cmd_tcn + * Purpose: Executes the \tcn (TOC entry, no page #) command. + * Args: Word, paragraph align info, and numeric param if any. + * Returns: Flag, true only if rest of Words on line should be ignored. + *=======================================================================*/ + +static int cmd_tcn (Word *w, int align, char has_param, int param) { + process_toc_entry (w, FALSE); + return TRUE; +} + + +typedef struct { + char *name; + int (*func)(Word*, int, char, int); + char *debug_print; +} HashItem; + + +/* All of the possible commands that RTF might recognize. */ +static HashItem hashArray_other [] = { + { "*", cmd_ignore, NULL }, + { "-", cmd_optional_hyphen, "optional hyphen" }, + { "_", cmd_nonbreaking_hyphen, "nonbreaking hyphen" }, + { "~", cmd_nonbreaking_space, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_a [] = { + { "ansi", &cmd_ansi , NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_b [] = { + { "b", &cmd_b, NULL }, + { "bullet", &cmd_bullet, NULL }, + { "bin", &cmd_bin, "picture is binary" }, +#if 0 + { "bgbdiag", NULL, NULL }, + { "bgcross", NULL, NULL }, + { "bgdcross", NULL, NULL }, + { "bgfdiag", NULL, NULL }, + { "bghoriz", NULL, NULL }, + { "bgkbdiag", NULL, NULL }, + { "bgkcross", NULL, NULL }, + { "bgkdcross", NULL, NULL }, + { "bgkfdiag", NULL, NULL }, + { "bgkhoriz", NULL, NULL }, + { "bgkvert", NULL, NULL }, + { "bgvert", NULL, NULL }, + { "brdrcf", NULL, NULL }, + { "brdrdb", NULL, NULL }, + { "brdrdot", NULL, NULL }, + { "brdrhair", NULL, NULL }, + { "brdrs", NULL, NULL }, + { "brdrsh", NULL, NULL }, + { "brdrth", NULL, NULL }, + { "brdrw", NULL, NULL }, +#endif + { NULL, NULL, NULL} +}; +static HashItem hashArray_c [] = { + { "caps", &cmd_caps, NULL }, + { "cb", cmd_cb, NULL }, + { "cf", cmd_cf, NULL }, + { "colortbl", &cmd_colortbl, "color table" }, + { "cols", NULL, "columns (not implemented)" }, + { "column", NULL, "column break (not implemented)" }, + { "cbpat", NULL, "Paragraph Shading" }, + { "cellx", NULL, "Table Definitions" }, + { "cfpat", NULL, NULL }, + { "cgrid", NULL, NULL }, + { "charrsid", NULL, "Revision Mark (ignore)" }, + { "clbgbcross", NULL, NULL }, + { "clbgbdiag", NULL, NULL }, + { "clbgbkbdiag", NULL, NULL }, + { "clbgbkcross", NULL, NULL }, + { "clbgbkdcross", NULL, NULL }, + { "clbgbkfdiag", NULL, NULL }, + { "clbgbkhor", NULL, NULL }, + { "clbgbkvert", NULL, NULL }, + { "clbgdcross", NULL, NULL }, + { "clbgfdiag", NULL, NULL }, + { "clbghoriz", NULL, NULL }, + { "clbgvert", NULL, NULL }, + { "clbrdrb", NULL, NULL }, + { "clbrdrl", NULL, NULL }, + { "clbrdrr", NULL, NULL }, + { "clbrdrt", NULL, NULL }, + { "clcbpat", NULL, NULL }, + { "clcfpat", NULL, NULL }, + { "clmgf", NULL, NULL }, + { "clmrg", NULL, NULL }, + { "clshdng", NULL, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_d [] = { + { "deff", NULL, "Default Font" }, + { "dn", &cmd_dn, NULL }, +#if 0 + { "dibitmap", NULL, NULL }, +#endif + { NULL, NULL, NULL} +}; +static HashItem hashArray_e [] = { + { "emdash", cmd_emdash, NULL }, + { "endash", cmd_endash, NULL }, + { "embo", &cmd_emboss, NULL }, + { "expand", &cmd_expand, NULL }, + { "expnd", &cmd_expand, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_f [] = { + { "f", cmd_f, NULL }, + { "fdecor", cmd_fdecor, NULL }, + { "fmodern", cmd_fmodern, NULL }, + { "fnil", cmd_fnil, NULL }, + { "fonttbl", cmd_fonttbl, "font table" }, + { "froman", cmd_froman, NULL }, + { "fs", cmd_fs, NULL }, + { "fscript", cmd_fscript, NULL }, + { "fswiss", cmd_fswiss, NULL }, + { "ftech", cmd_ftech, NULL }, + { "field", cmd_field, NULL }, + { "footer", cmd_footer, NULL }, + { "footerf", cmd_footerf, NULL }, + { "footerl", cmd_footerl, NULL }, + { "footerr", cmd_footerr, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_h [] = { + { "highlight", &cmd_highlight, NULL }, + { "header", cmd_header, NULL }, + { "headerf", cmd_headerf, NULL }, + { "headerl", cmd_headerl, NULL }, + { "headerr", cmd_headerr, NULL }, + { "hl", cmd_ignore, "hyperlink within object" }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_i [] = { + { "i", &cmd_i, NULL }, + { "info", &cmd_info, NULL }, + { "insrsid", NULL, "Revision Mark (ignore)" }, + { "intbl", &cmd_intbl, NULL }, + { "impr", &cmd_engrave, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_j [] = { + { "jpegblip", &cmd_jpegblip, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_l [] = { + { "ldblquote", &cmd_ldblquote, NULL }, + { "line", &cmd_line, NULL }, + { "lquote", &cmd_lquote, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_m [] = { + { "mac", &cmd_mac , NULL }, + { "macpict", &cmd_macpict, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_n [] = { + { "nosupersub", &cmd_nosupersub, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_o [] = { + { "outl", &cmd_outl, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_p [] = { + { "page", &cmd_page, NULL }, + { "par", &cmd_par, NULL }, + { "pc", &cmd_pc , NULL }, + { "pca", &cmd_pca , NULL }, + { "pich", &cmd_pich, NULL }, + { "pict", &cmd_pict, "picture" }, + { "picw", &cmd_picw, NULL }, + { "plain", &cmd_plain, NULL }, + { "pngblip", &cmd_pngblip, NULL }, + { "pnmetafile", &cmd_pnmetafile, NULL }, +#if 0 + { "piccropb", NULL, NULL }, + { "piccropl", NULL, NULL }, + { "piccropr", NULL, NULL }, + { "piccropt", NULL, NULL }, + { "pichgoal", NULL, NULL }, + { "pichgoal", NULL, NULL }, + { "picscaled", NULL, NULL }, + { "picscalex", NULL, NULL }, + { "picwgoal", NULL, NULL }, +#endif + { NULL, NULL, NULL} +}; +static HashItem hashArray_r [] = { + { "rdblquote", &cmd_rdblquote, NULL }, + { "rquote", &cmd_rquote, NULL }, + { "rtf", &cmd_rtf, NULL }, + { NULL, NULL, NULL} +}; +static HashItem hashArray_s [] = { + { "s", cmd_s, "style" }, + { "sect", &cmd_sect, "section break"}, + { "scaps", &cmd_scaps, NULL }, + { "super", &cmd_super, NULL }, + { "sub", &cmd_sub, NULL }, + { "shad", &cmd_shad, NULL }, + { "strike", &cmd_strike, NULL }, + { "striked", &cmd_striked, NULL }, + { "strikedl", &cmd_strikedl, NULL }, + { "stylesheet", &cmd_ignore, "style sheet" }, + { "shp", cmd_shp, "drawn shape" }, +#if 0 + { "shading", NULL, NULL }, +#endif + { NULL, NULL, NULL} +}; +static HashItem hashArray_t [] = { + { "tab", &cmd_tab, NULL }, + { "tc", cmd_tc, "TOC entry" }, + { "tcn", cmd_tcn, "TOC entry" }, +#if 0 + { "tcf", NULL , NULL }, + { "tcl", NULL , NULL }, + { "trgaph", NULL , NULL }, + { "trleft", NULL , NULL }, + { "trowd", NULL , NULL }, + { "trqc", NULL , NULL }, + { "trql", NULL , NULL }, + { "trqr", NULL , NULL }, + { "trrh", NULL , NULL }, +#endif + { NULL, NULL, NULL} +}; +static HashItem hashArray_u [] = { +#if 1 /* daved - 0.19.4 */ + { "u", &cmd_u, NULL }, +#endif + { "ul", &cmd_ul, NULL }, + { "up", &cmd_up, NULL }, + { "uld", &cmd_uld, NULL }, + { "uldash", &cmd_uldash, NULL }, + { "uldashd", &cmd_uldashd, NULL }, + { "uldashdd", &cmd_uldashdd, NULL }, + { "uldb", &cmd_uldb, NULL }, + { "ulnone", &cmd_ulnone, NULL }, + { "ulth", &cmd_ulth, NULL }, + { "ulthd", &cmd_ulthd, NULL }, + { "ulthdash", &cmd_ulthdash, NULL }, + { "ulw", &cmd_ulw, NULL }, + { "ulwave", &cmd_ulwave, NULL }, + { NULL, NULL, NULL} +}; + +static HashItem hashArray_v [] = { + { "v", NULL, "Hidden Text" }, + { NULL, NULL, NULL } +}; + +static HashItem hashArray_w [] = { + { "wbmbitspixel", &cmd_wbmbitspixel, NULL }, + { "wmetafile", &cmd_wmetafile, NULL }, +#if 0 + { "wbitmap", NULL, NULL }, + { "wbmplanes", NULL, NULL }, + { "wbmwidthbytes", NULL, NULL }, +#endif + { NULL, NULL, NULL} +}; + +static HashItem hashArray_x [] = { + { "xe", cmd_xe, "index entry" }, + { NULL, NULL, NULL} +}; + +static HashItem *hash [26] = { + hashArray_a, + hashArray_b, + hashArray_c, + hashArray_d, + hashArray_e, + hashArray_f, + NULL, + hashArray_h, + hashArray_i, + hashArray_j, + NULL, + hashArray_l, + hashArray_m, + hashArray_n, + hashArray_o, + hashArray_p, + NULL, + hashArray_r, + hashArray_s, + hashArray_t, + hashArray_u, + hashArray_v, + hashArray_w, + hashArray_x, + NULL, NULL +}; + + +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ + + + +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +void +print_with_special_exprs (char *s) { + int ch; + int state; + +enum { SMALL=0, BIG=1 }; + + CHECK_PARAM_NOT_NULL(s); + + state=SMALL; /* Pacify gcc, st001906 - 0.19.6 */ + if (simulate_smallcaps) { + if (*s >= 'a' && *s <= 'z') { + state=SMALL; + outstring+=QString().sprintf(op->smaller_begin); + } + else + state=BIG; + } + + while ((ch=*s)) { + char *post_trans = NULL; + + if (simulate_allcaps || simulate_smallcaps) + ch = toupper (ch); + + if (ch >= 0x20 && ch < 0x80) { +#if 1 /* daved - 0.19.6 */ + post_trans = op_translate_char (op, charset_type, ch, numchar_table); +#else + post_trans = op_translate_char (op, charset_type, ch); +#endif +#if 1 /* daved - 0.20.1 */ + if(post_trans) +#endif + outstring+=QString().sprintf("%s",post_trans); + } + + s++; + + if (simulate_smallcaps) { + ch = *s; + if (ch >= 'a' && ch <= 'z') { + if (state==BIG) + outstring+=QString().sprintf(op->smaller_begin); + state=SMALL; + } + else + { + if (state==SMALL) + outstring+=QString().sprintf(op->smaller_end); + state=BIG; + } + } + } +} + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +static void +begin_table() +{ + within_table=TRUE; + have_printed_row_begin = FALSE; + have_printed_cell_begin = FALSE; + have_printed_row_end = FALSE; + have_printed_cell_end = FALSE; + attrstack_push(); + starting_body(); + outstring+=QString().sprintf(op->table_begin); +} + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +void +end_table () +{ + if (within_table) { + if (!have_printed_cell_end) { + attr_pop_dump(); + outstring+=QString().sprintf(op->table_cell_end); + } + if (!have_printed_row_end) { + outstring+=QString().sprintf(op->table_row_end); + } + outstring+=QString().sprintf(op->table_end); + within_table=FALSE; + have_printed_row_begin = FALSE; + have_printed_cell_begin = FALSE; + have_printed_row_end = FALSE; + have_printed_cell_end = FALSE; + } +} + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +void +starting_text() { + if (within_table) { + if (!have_printed_row_begin) { + outstring+=QString().sprintf(op->table_row_begin); + have_printed_row_begin=TRUE; + have_printed_row_end=FALSE; + have_printed_cell_begin=FALSE; + } + if (!have_printed_cell_begin) { + outstring+=QString().sprintf(op->table_cell_begin); + attrstack_express_all(); + have_printed_cell_begin=TRUE; + have_printed_cell_end=FALSE; + } + } +} + + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +static void +starting_paragraph_align (int align) +{ + if (within_header && align != ALIGN_LEFT) + starting_body(); + + switch (align) + { + case ALIGN_CENTER: + outstring+=QString().sprintf(op->center_begin); + break; + case ALIGN_LEFT: + break; + case ALIGN_RIGHT: + outstring+=QString().sprintf(op->align_right_begin); + break; + case ALIGN_JUSTIFY: + outstring+=QString().sprintf(op->align_right_begin); /* This is WRONG! */ + break; + } +} + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +static void +ending_paragraph_align (int align) +{ + switch (align) { + case ALIGN_CENTER: + outstring+=QString().sprintf(op->center_end); + break; + case ALIGN_LEFT: + /* printf(op->align_left_end); */ + break; + case ALIGN_RIGHT: + outstring+=QString().sprintf(op->align_right_end); + break; + case ALIGN_JUSTIFY: + outstring+=QString().sprintf(op->justify_end); + break; + } +} + + +/*======================================================================== + * Name: + * Purpose: Recursive routine to produce the output in the target + * format given on a tree of words. + * Args: Word* (the tree). + * Returns: None. + *=======================================================================*/ + +static void +word_print_core (Word *w) +{ + char *s; + FILE *pictfile=NULL; + int is_cell_group=FALSE; + int paragraph_begined=FALSE; + int paragraph_align=ALIGN_LEFT; + + CHECK_PARAM_NOT_NULL(w); + + if (!coming_pars_that_are_tabular && within_table) { + end_table(); + } + else if (coming_pars_that_are_tabular && !within_table) { + begin_table(); + } + + /* Mark our place in the stack */ + attrstack_push(); + + while (w) { + s = word_string (w); + + if (s) { + /*--Ignore whitespace in header--------------------*/ + if (*s==' ' && within_header) { + /* no op */ + } + else + /*--Handle word -----------------------------------*/ + if (s[0] != '\\') + { + starting_body(); + starting_text(); + + if (!paragraph_begined) { + starting_paragraph_align (paragraph_align); + paragraph_begined=TRUE; + } + + /*----------------------------------------*/ + if (within_picture) { + starting_body(); + if (!pictfile && !nopict_mode) { + char *ext=NULL; + switch (picture_type) { + case PICT_WB: ext="bmp"; break; + case PICT_WM: ext="wmf"; break; + case PICT_MAC: ext="pict"; break; + case PICT_JPEG: ext="jpg"; break; + case PICT_PNG: ext="png"; break; + case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */ + case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */ + } + sprintf(picture_path, "pict%03d.%s", + picture_file_number++,ext); + pictfile=fopen(picture_path,"w"); + } + + if (s[0]!=' ') { + char *s2; + printf(op->comment_begin); + printf("picture data found, "); + if (picture_wmetafile_type_str) { + printf("WMF type is %s, ", + picture_wmetafile_type_str); + } + printf("picture dimensions are %d by %d, depth %d", + picture_width, picture_height, picture_bits_per_pixel); + printf(op->comment_end); + if (picture_width && picture_height && picture_bits_per_pixel) { + s2=s; + while (*s2) { + unsigned int tmp,value; + tmp=tolower(*s2++); + if (tmp>'9') tmp-=('a'-10); + else tmp-='0'; + value=16*tmp; + tmp=tolower(*s2++); + if (tmp>'9') tmp-=('a'-10); + else tmp-='0'; + value+=tmp; + if (pictfile) { + fprintf(pictfile,"%c", value); + } + } + } + } + } + /*----------------------------------------*/ + else { + total_chars_this_line += strlen(s); + + if (op->word_begin) + outstring+=QString().sprintf(op->word_begin); + + print_with_special_exprs (s); + + if (op->word_end) + outstring+=QString().sprintf(op->word_end); + } + + + } +#if 1 /* daved 0.19.5 */ + /* output an escaped backslash */ + /* do we need special handling for latex? */ + else if (*(s+1) == '\\') + { + s++; + putchar('\\'); + } + else if (*(s+1) == '{') + { + s++; + putchar('{'); + } + else if (*(s+1) == '}') + { + s++; + putchar('}'); + } +#endif + /*---Handle RTF keywords---------------------------*/ + else { + int done=FALSE; + + s++; + +/*----Paragraph alignment----------------------------------------------------*/ + if (!strcmp ("ql", s)) + paragraph_align = ALIGN_LEFT; + else if (!strcmp ("qr", s)) + paragraph_align = ALIGN_RIGHT; + else if (!strcmp ("qj", s)) + paragraph_align = ALIGN_JUSTIFY; + else if (!strcmp ("qc", s)) + paragraph_align = ALIGN_CENTER; + else if (!strcmp ("pard", s)) + { + /* Clear out all font attributes. + */ + attr_pop_all(); + if (coming_pars_that_are_tabular) { + --coming_pars_that_are_tabular; + } + + /* Clear out all paragraph attributes. + */ + ending_paragraph_align(paragraph_align); + paragraph_align = ALIGN_LEFT; + paragraph_begined = FALSE; + } +/*----Table keywords---------------------------------------------------------*/ + else + if (!strcmp (s, "cell")) { + is_cell_group=TRUE; + if (!have_printed_cell_begin) { + /* Need this with empty cells */ + outstring+=QString().sprintf(op->table_cell_begin); + attrstack_express_all(); + } + attr_pop_dump(); + outstring+=QString().sprintf(op->table_cell_end); + have_printed_cell_begin = FALSE; + have_printed_cell_end=TRUE; + } + else if (!strcmp (s, "row")) { + if (within_table) { + outstring+=QString().sprintf(op->table_row_end); + have_printed_row_begin = FALSE; + have_printed_row_end=TRUE; + } else { + if (debug_mode) { + printf(op->comment_begin); + printf("end of table row"); + printf(op->comment_end); + } + } + } + +/*----Special chars---------------------------------------------------------*/ + else if (*s == '\'') { + /* \'XX is a hex char code expression */ + int ch = h2toi (&s[1]); + char *s2; + +#if 1 /* daved - 0.19.6 */ + s2 = op_translate_char (op, charset_type, ch, numchar_table); +#else + s2 = op_translate_char (op, charset_type, ch); +#endif + + if (!s2 || !*s2) { + printf(op->comment_begin); + printf("char 0x%02x",ch); + printf(op->comment_end); + } else { + if (op->word_begin) + outstring+=QString().sprintf(op->word_begin); + outstring+=QString().sprintf("%s", s2); + if (op->word_end) + outstring+=QString().sprintf(op->word_end); + } + } + else +/*----Search the RTF command hash-------------------------------------------*/ + { + int ch; + int index=0; + int have_param = FALSE, param = 0; + HashItem *hip; + char *p; + int match = FALSE; /* Pacify gcc, st001906 - 0.19.6 */ + + /* Look for a parameter */ + p = s; + while (*p && (!isdigit(*p) && *p != '-')) p++; + if (*p && (isdigit(*p) || *p == '-')) { + have_param = TRUE; + param = atoi(p); + } + + /* Generate a hash index */ + ch = tolower(*s); + if (ch >= 'a' && ch <= 'z') + hip = hash[ch - 'a']; + else + hip = hashArray_other; + + if (!hip) { + if (debug_mode) { + printf(op->comment_begin); + printf("Unfamiliar RTF command: %s (HashIndex not found)", s); + printf(op->comment_begin); + } + } + else { + while (!done) { + match = FALSE; + + if (have_param) { + int len=p-s; + if (!hip[index].name[len] && !strncmp(s, hip[index].name, len)) + match = TRUE; + } + else + match = !strcmp(s, hip[index].name); + + if (match) { + char *debug; + int terminate_group; + + if (hip[index].func) { + terminate_group = hip[index].func (w,paragraph_align, have_param, param); + +#if 1 /* daved - 0.19.4 - unicode support may need to skip only one word */ + if (terminate_group == SKIP_ONE_WORD) + w=w->next; + else +#endif + if (terminate_group) + while(w) w=w->next; + } + + debug=hip[index].debug_print; + + if (debug && debug_mode) { + printf(op->comment_begin); + printf("%s", debug); + printf(op->comment_end); + } + + done=TRUE; + } + else { + index++; + if (!hip[index].name) + done = TRUE; + } + } + } + if (!match) { + if (debug_mode) { + printf(op->comment_begin); + printf("Unfamiliar RTF command: %s", s); + printf(op->comment_end); + } + } + } + } +/*-------------------------------------------------------------------------*/ + } else { + Word *child; + + child = w->child; + + if (!paragraph_begined) { + starting_paragraph_align (paragraph_align); + paragraph_begined=TRUE; + } + + if (child) + word_print_core (child); + } + + if (w) + w = w->next; + } + + if (within_picture) { + if(pictfile) { + fclose(pictfile); + outstring+=QString().sprintf(op->imagelink_begin); + outstring+=QString().sprintf("%s", picture_path); + outstring+=QString().sprintf(op->imagelink_end); + } + within_picture=FALSE; + } + + /* Undo font attributes UNLESS we're doing table cells + * since they would appear between and . + */ + if (!is_cell_group) + attr_pop_all(); + else + attr_drop_all(); + + /* Undo paragraph alignment + */ + if (paragraph_begined) + ending_paragraph_align (paragraph_align); + + attrstack_drop(); +} + + + + +/*======================================================================== + * Name: + * Purpose: + * Args: None. + * Returns: None. + *=======================================================================*/ + +void +word_print (Word *w, QString & _s) +{ + CHECK_PARAM_NOT_NULL (w); + + outstring = ""; + if (!inline_mode) { + outstring+=QString().sprintf(op->document_begin); + outstring+=QString().sprintf(op->header_begin); + } + + within_header=TRUE; + have_printed_body=FALSE; + within_table=FALSE; + simulate_allcaps=FALSE; + word_print_core (w); + end_table(); + + if (!inline_mode) { + outstring+=QString().sprintf(op->body_end); + outstring+=QString().sprintf(op->document_end); + } + _s = outstring; +} diff --git a/plugins/flp_import/unrtf/convert.h b/plugins/flp_import/unrtf/convert.h new file mode 100644 index 000000000..ea523eb23 --- /dev/null +++ b/plugins/flp_import/unrtf/convert.h @@ -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 + diff --git a/plugins/flp_import/unrtf/defs.h b/plugins/flp_import/unrtf/defs.h new file mode 100644 index 000000000..6e280a2d2 --- /dev/null +++ b/plugins/flp_import/unrtf/defs.h @@ -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] " + + +/* 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" + diff --git a/plugins/flp_import/unrtf/error.c b/plugins/flp_import/unrtf/error.c new file mode 100644 index 000000000..2cea4fdf8 --- /dev/null +++ b/plugins/flp_import/unrtf/error.c @@ -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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#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); +} diff --git a/plugins/flp_import/unrtf/error.h b/plugins/flp_import/unrtf/error.h new file mode 100644 index 000000000..9a4bf80e0 --- /dev/null +++ b/plugins/flp_import/unrtf/error.h @@ -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*); + + diff --git a/plugins/flp_import/unrtf/hash.c b/plugins/flp_import/unrtf/hash.c new file mode 100644 index 000000000..430b9c818 --- /dev/null +++ b/plugins/flp_import/unrtf/hash.c @@ -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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#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 ("\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; +} diff --git a/plugins/flp_import/unrtf/hash.h b/plugins/flp_import/unrtf/hash.h new file mode 100644 index 000000000..5b1c44681 --- /dev/null +++ b/plugins/flp_import/unrtf/hash.h @@ -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 ); + + diff --git a/plugins/flp_import/unrtf/html.c b/plugins/flp_import/unrtf/html.c new file mode 100644 index 000000000..3b982a98b --- /dev/null +++ b/plugins/flp_import/unrtf/html.c @@ -0,0 +1,1102 @@ +/*============================================================================= + 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: 18 Sep 01 + * Purpose: HTML-specific output module + *---------------------------------------------------------------------- + * Changes: + * 01 Aug 01, tuorfa@yahoo.com: code moved over from convert.c + * 03 Aug 01, tuorfa@yahoo.com: removed null entries to save space + * 08 Aug 01, tuorfa@yahoo.com, gommer@gmx.net: fixed/added some ANSI chars + * 18 Sep 01, tuorfa@yahoo.com: moved character sets into html.c etc + * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks + * 08 Oct 03, daved@physiol.usyd.edu.au: mac special character fixes + * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith + * 29 Mar 05, daved@physiol.usyd.edu.au: more unicode characters + * 21 Jul 05, daved@physiol.usyd.edu.au: added endash + * 19 Aug 05, ax2groin@arbornet.org: added more chars and changes to ANSI + * 05 Jan 06, marcossamaral@terra.com.br: fixed bugs #14982 and #14983 + *--------------------------------------------------------------------*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif + +#include "malloc.h" +#include "defs.h" +#include "error.h" +#include "main.h" +#include "output.h" + + +static char* ascii [96] = { + /* 0x20 */ " ", "!", """, "#", "$", "%", "&", "'", + /* 0x28 */ "(", ")", "*", "+", ",", "-", ".", "/", + /* 0x30 */ "0", "1", "2", "3", "4", "5", "6", "7", + /* 0x38 */ "8", "9", ":", ";", "<", "=", ">", "?", + /* 0x40 */ "@", "A", "B", "C", "D", "E", "F", "G", + /* 0x48 */ "H", "I", "J", "K", "L", "M", "N", "O", + /* 0x50 */ "P", "Q", "R", "S", "T", "U", "V", "W", + /* 0x58 */ "X", "Y", "Z", "[", "\\", "]", "^", "_", + /* 0x60 */ "`", "a", "b", "c", "d", "e", "f", "g", + /* 0x68 */ "h", "i", "j", "k", "l", "m", "n", "o", + /* 0x70 */ "p", "q", "r", "s", "t", "u", "v", "w", + /* 0x78 */ "x", "y", "z", "{", "|", "}", "~", "" +}; + + +static char* ansi [] = { +/* 0x78 */ "x", +/* 0x79 */ "y", +/* 0x7a */ "z", +/* 0x7b */ "{", +/* 0x7c */ "|", +/* 0x7d */ "}", +/* 0x7e */ "~", +/* 0x7f */ "", +/* 0x80 */ "€", /* € may be more widely recognized. */ +/* 0x81 */ "", +/* 0x82 */ "‚", /* ‚ not implemented in any browsers I've seen. */ +/* 0x83 */ "ƒ", +/* 0x84 */ "„", /* „ not implemented in any browsers I've seen. */ +/* 0x85 */ "…", +/* 0x86 */ "†", +/* 0x87 */ "‡", +/* 0x88 */ "ˆ", +/* 0x89 */ "‰", +/* 0x8a */ "Š", +/* 0x8b */ "‹", +/* 0x8c */ "Œ", +/* 0x8d */ "", +/* 0x8e */ "Ž", +/* 0x8f */ "", +/* 0x90 */ "", "‘", "’", "“", "”", "•", "–", "—", +/* 0x98 */ "˜", +/* 0x99 */ "™", +/* 0x9a */ "š", +/* 0x9b */ "›", /* daved - 0.9.6 */ +/* 0x9c */ "œ", +/* 0x9d */ "", +/* 0x9e */ "ž", +/* 0x9f */ "Ÿ", +/* 0xa0 */ " ","¡","¢","£","¤","¥","¦","§", +/* 0xa8 */ "¨","©","ª","«","¬","­","®","¯", +/* 0xb0 */ "°", "±","²","³","´","µ","¶","·", +/* 0xb8 */ "¸","¹", "º","»", "¼", "½","¾","¿", +/* 0xc0 */ "À","Á","Â","Ã","Ä","Å","Æ","Ç", +/* 0xc8 */ "È","É","Ê","Ë","Ì","Í","Î","Ï", +/* 0xd0 */ "Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×", +/* 0xd8 */ "Ø","Ù","Ú","Û","Ü","Ý","Þ","ß", +/* 0xe0 */ "à","á","â","ã","ä","å","æ","ç", +/* 0xe8 */ "è","é","ê","ë","ì","í","î","ï", +/* 0xf0 */ "ð","ñ","ò","ó","ô","õ","ö","÷", +/* 0xf8 */ "ø","ù","ú","û","ü","ý","þ","ÿ" +}; + +static char* mac [] = { +/* 0xa4 */ "•", NULL,NULL,NULL, +/* 0xa8 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +/* 0xb0 */ NULL,NULL,NULL,NULL,NULL,"μ",NULL,NULL, +/* 0xb8 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +/* 0xc0 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +/* 0xc8 */ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, +/* 0xd0 */ "—","–","“","”","&lquo;","&rquo;" +}; + +#if 1 /* daved - 0.19.4 - unicode symbol character support */ +static char * unisymbol1[] = { + /* 913 */ "Α", + /* 914 */ "Β", + /* 915 */ "Γ", + /* 916 */ "Δ", + /* 917 */ "Ε", + /* 918 */ "Ζ", + /* 919 */ "Η", + /* 920 */ "Θ", + /* 921 */ "Ι", + /* 922 */ "Κ", + /* 923 */ "Λ", + /* 924 */ "Μ", + /* 925 */ "Ν", + /* 926 */ "Ξ", + /* 927 */ "Ο", + /* 928 */ "Π", + /* 929 */ "Ρ", + /* 930 */ 0, + /* 931 */ "Σ", + /* 932 */ "Τ", + /* 933 */ "Υ", + /* 934 */ "Φ", + /* 935 */ "Χ", + /* 936 */ "Ψ", + /* 937 */ "Ω", + /* 938 */ 0, + /* 939 */ 0, + /* 940 */ 0, + /* 941 */ 0, + /* 942 */ 0, + /* 943 */ 0, + /* 944 */ 0, + /* 945 */ "α", + /* 946 */ "β", + /* 947 */ "γ", + /* 948 */ "δ", + /* 949 */ "ε", + /* 950 */ "ζ", + /* 951 */ "η", + /* 952 */ "θ", + /* 953 */ "ι", + /* 954 */ "κ", + /* 955 */ "λ", + /* 956 */ "μ", + /* 957 */ "ν", + /* 958 */ "ξ", + /* 959 */ "ο", + /* 960 */ "π", + /* 961 */ "ρ", + /* 962 */ "ς", + /* 963 */ "σ", + /* 964 */ "τ", + /* 965 */ "υ", + /* 966 */ "φ", + /* 967 */ "χ", + /* 968 */ "ψ", + /* 969 */ "ω", + /* 970 */ 0, + /* 971 */ 0, + /* 972 */ 0, + /* 973 */ 0, + /* 974 */ 0, + /* 975 */ 0, + /* 976 */ 0, + /* 977 */ "ϑ", + /* 978 */ "ϒ", + /* 979 */ 0, + /* 980 */ 0, + /* 981 */ 0, + /* 982 */ "ϖ", +}; +#endif +#if 1 /* daved - 0.19.4 - unicode symbol character support */ +static char * unisymbol2[] = { +/* 57516 */ "Γ", +/* 57517 */ "Δ", +/* 57518 */ "Θ", +/* 57519 */ "Λ", +/* 57520 */ "Ξ", +/* 57521 */ "Π", +/* 57522 */ "Σ", +/* 57523 */ "Υ", +/* 57524 */ "Φ", +/* 57525 */ "Ψ", +/* 57526 */ "Ω", +/* 57527 */ "α", +/* 57528 */ "β", +/* 57529 */ "γ", +/* 57530 */ "δ", +/* 57531 */ "ε", +/* 57532 */ "ζ", +/* 57533 */ "η", +/* 57534 */ "θ", +/* 57535 */ "ι", +/* 57536 */ "κ", +/* 57537 */ "λ", +/* 57538 */ "μ", +/* 57539 */ "ν", +/* 57540 */ "ξ", +/* 57541 */ "ο", +/* 57542 */ "π", +/* 57543 */ "ρ", +/* 57544 */ "σ", +/* 57545 */ "τ", +/* 57546 */ "υ", +/* 57547 */ "φ", +/* 57548 */ "χ", +/* 57549 */ "ψ", +/* 57550 */ "ω", +/* 57551 */ "ϵ", +/* 57552 */ "ϑ", +/* 57553 */ "ϖ", +/* 57554 */ 0, +/* 57555 */ "ς", +/* 57556 */ "ϕ", +/* 57557 */ "δ", +}; + +static char * unisymbol3[] = { + /* 61505 */ "Α", + /* 61506 */ "Β", + /* 61507 */ "Χ", + /* 61508 */ "Δ", + /* 61509 */ "Ε", + /* 61510 */ "Φ", + /* 61511 */ "Γ", + /* 61512 */ "Η", + /* 61513 */ "Ι", + /* 61514 */ "ϕ", + /* 61515 */ "Κ", + /* 61516 */ "Λ", + /* 61517 */ "Μ", + /* 61518 */ "Ν", + /* 61519 */ "Ο", + /* 61520 */ "Π", + /* 61521 */ "Θ", + /* 61522 */ "Ρ", + /* 61523 */ "Σ", + /* 61524 */ "Τ", + /* 61525 */ "Υ", + /* 61526 */ "ς", + /* 61527 */ "Ω", + /* 61528 */ "Ξ", + /* 61529 */ "Ψ", + /* 61530 */ "Ζ", + /* 61531 */ 0, + /* 61532 */ 0, + /* 61533 */ 0, + /* 61534 */ 0, + /* 61535 */ 0, + /* 61536 */ 0, + /* 61537 */ "α", + /* 61538 */ "β", + /* 61539 */ "χ", + /* 61540 */ "δ", + /* 61541 */ "ε", + /* 61542 */ "φ", + /* 61543 */ "γ", + /* 61544 */ "η", + /* 61545 */ "τ", + /* 61546 */ "ϕ", + /* 61547 */ "κ", + /* 61548 */ "λ", + /* 61549 */ "μ", + /* 61550 */ "ν", + /* 61551 */ "ο", + /* 61552 */ "π", + /* 61553 */ "θ", + /* 61554 */ "ρ", + /* 61555 */ "σ", + /* 61556 */ "τ", + /* 61557 */ "υ", + /* 61558 */ "ϖ", + /* 61559 */ "ω", + /* 61560 */ "ξ", + /* 61561 */ "ψ", + /* 61562 */ "ζ", +}; +#endif + +#if 1 /* 0.19.5 more unicode characters */ +static char * unisymbol4[] = { + /* 61600 */ "€", + /* 61601 */ "ϒ", + /* 61602 */ "′", + /* 61603 */ "≤", + /* 61604 */ "⁄", + /* 61605 */ "∞", + /* 61606 */ "ƒ", + /* 61607 */ "♣", + /* 61608 */ "♦", + /* 61609 */ "♥", + /* 61610 */ "♠", + /* 61611 */ "↔", + /* 61612 */ "&larr", + /* 61613 */ "↑", + /* 61614 */ "→", + /* 61615 */ "↓", + /* 61616 */ "°", + /* 61617 */ "±", + /* 61618 */ "″", + /* 61619 */ "≥", + /* 61620 */ "×", + /* 61621 */ "∝", + /* 61622 */ "∂", + /* 61623 */ "•", + /* 61624 */ "÷", + /* 61625 */ "≠", + /* 61626 */ "≡", + /* 61627 */ "≈", + /* 61628 */ "…", + /* 61629 */ 0, /* vertical bar */ + /* 61630 */ "—", + /* 61631 */ "↵", + /* 61632 */ "ℵ", + /* 61633 */ "ℑ", + /* 61634 */ "ℜ", + /* 61635 */ "℘", + /* 61636 */ "⊗", + /* 61637 */ "⊕", + /* 61638 */ "∅", + /* 61639 */ "∩", + /* 61640 */ "∪", + /* 61641 */ "⊃", + /* 61642 */ "⊇", + /* 61643 */ "⊄", + /* 61644 */ "⊂", + /* 61645 */ "⊆", + /* 61646 */ "∈", + /* 61647 */ "∉", + /* 61648 */ "∠", + /* 61649 */ "∇", + /* 61650 */ "®", + /* 61651 */ "©", + /* 61652 */ "™", + /* 61653 */ "∏", + /* 61654 */ "√", + /* 61655 */ "·", + /* 61656 */ "¬", + /* 61657 */ "∧", + /* 61658 */ "∨", + /* 61659 */ "⇔", + /* 61660 */ "⇐", + /* 61661 */ "⇑", + /* 61662 */ "⇒", + /* 61663 */ "⇓", + /* 61664 */ "◊", + /* 61665 */ "⟨", + /* 61666 */ "®", + /* 61667 */ "©", + /* 61668 */ "™", + /* 61669 */ "∑", + /* 61670 */ 0, /* large right parenthesis ceiling */ + /* 61671 */ 0, /* large parenthesis middle */ + /* 61672 */ 0, /* large left parenthesis floor */ + /* 61673 */ "⌈", /* large left square bracket ceiling */ + /* 61674 */ 0, /* large left square bracket middle */ + /* 61675 */ "⌊", /* large left square bracket floor */ + /* 61676 */ 0, /* large left bracket ceiling */ + /* 61677 */ 0, /* large left bracket middle */ + /* 61678 */ 0, /* large left bracket floor */ + /* 61679 */ 0, /* large vertical bar */ + /* 61680 */ 0, /* appears blank */ + /* 61681 */ "⟩", + /* 61682 */ "∫", /* integral */ + /* 61683 */ 0, /* large integral ceiling */ + /* 61684 */ 0, /* large integral middle */ + /* 61685 */ 0, /* large integral floor */ + /* 61686 */ 0, /* large right parenthesis ceiling */ + /* 61687 */ 0, /* large right parenthesis middle */ + /* 61688 */ 0, /* large right parenthesis floor */ + /* 61689 */ "⌉", /* large right square bracket ceiling */ + /* 61690 */ 0, /* large right square bracket middle */ + /* 61691 */ "⌋", /* large right square bracket floor */ + /* 61692 */ 0, /* large right bracket middle */ + /* 61694 */ 0 /* large right bracket floot */ +}; +#endif +#if 1 /* daved - SYMBOL font characters */ +static char* symbol[] = { +/* 60 */ "<", +/* 61 */ "=", +/* 62 */ ">", +/* 63 */ "?", +/* 64 */ "≅", +/* 65 */ "Α", +/* 66 */ "Β", +/* 67 */ "Β", +/* 68 */ "Δ", +/* 69 */ "Ε", +/* 70 */ "Φ", +/* 71 */ "Γ", +/* 72 */ "Η", +/* 73 */ "Ι", +/* 74 */ "ϑ", +/* 75 */ "Κ", +/* 76 */ "Λ", +/* 77 */ "Μ", +/* 78 */ "Ν", +/* 79 */ "Ο", +/* 80 */ "Π", +/* 81 */ "Θ", +/* 82 */ "Ρ", +/* 83 */ "Σ", +/* 84 */ "Τ", +/* 85 */ "Υ", +/* 86 */ "ς", +/* 87 */ "Ω", +/* 88 */ "Ξ", +/* 89 */ "Ψ", +/* 90 */ "Ζ", +/* 91 */ "[", +/* 92 */ "∴", +/* 93 */ "]", +/* 94 */ "⊥", +/* 95 */ "_", +/* 96 */ "‾", +/* 97 */ "α", +/* 98 */ "β", +/* 99 */ "χ", +/* 100 */ "δ", +/* 101 */ "ε", +/* 102 */ "φ", +/* 103 */ "γ", +/* 104 */ "η", +/* 105 */ "ι", +/* 106 */ "", /* ? */ +/* 107 */ "κ", +/* 108 */ "λ", +/* 109 */ "μ", +/* 110 */ "ν", +/* 111 */ "ο", +/* 112 */ "π", +/* 113 */ "θ", +/* 114 */ "ρ", +/* 115 */ "σ", +/* 116 */ "τ", +/* 117 */ "υ", +/* 118 */ "ϖ", +/* 119 */ "ω", +/* 120 */ "ξ", +/* 121 */ "ψ", +/* 122 */ "ζ", +/* 123 */ "{", +/* 124 */ "|", +/* 125 */ "}", +/* 126 */ "∼", +/* 127 */ 0, +/* 128 */ 0, +/* 129 */ 0, +/* 130 */ 0, +/* 131 */ 0, +/* 132 */ 0, +/* 133 */ 0, +/* 134 */ 0, +/* 135 */ 0, +/* 136 */ 0, +/* 137 */ 0, +/* 138 */ 0, +/* 139 */ 0, +/* 140 */ 0, +/* 141 */ 0, +/* 142 */ 0, +/* 143 */ 0, +/* 144 */ 0, +/* 145 */ 0, +/* 146 */ 0, +/* 147 */ 0, +/* 148 */ 0, +/* 149 */ 0, +/* 150 */ 0, +/* 151 */ 0, +/* 152 */ 0, +/* 153 */ 0, +/* 154 */ 0, +/* 155 */ 0, +/* 156 */ 0, +/* 157 */ 0, +/* 158 */ 0, +/* 159 */ 0, +/* 160 */ 0, +/* 161 */ "ϒ", +/* 162 */ "′", +/* 163 */ "≤", +/* 164 */ "⁄", +/* 165 */ "∞", +/* 166 */ "ƒ", +/* 167 */ "♣", +/* 168 */ "♦", +/* 169 */ "♥", +/* 170 */ "♠", +/* 171 */ "↔", +/* 172 */ "←", +/* 173 */ 0, +/* 174 */ "→", +/* 175 */ "↓", +/* 176 */ "°", +/* 177 */ "±", +/* 178 */ "″", +/* 179 */ "≥", +/* 180 */ "×", +/* 181 */ "∝", +/* 182 */ "∂", +/* 183 */ "•", +/* 184 */ "÷", +/* 185 */ "≠", +/* 186 */ "≡", +/* 187 */ "≈", +/* 188 */ "…", +/* 189 */ "│", /* vertical line */ +/* 190 */ "—", +/* 191 */ "↵", +/* 192 */ "ℵ", +/* 193 */ "ℑ", +/* 194 */ "ℜ", +/* 195 */ "℘", +/* 196 */ "⊗", +/* 197 */ "⊕", +/* 198 */ "∅", +/* 199 */ "∩", +/* 200 */ "∪", +/* 201 */ "⊃", +/* 202 */ "⊇", +/* 203 */ "⊄", +/* 204 */ "⊂", +/* 205 */ "⊆", +/* 206 */ "∈", +/* 207 */ "∉", +/* 208 */ "∠", +/* 209 */ "∇", +/* 210 */ "®", /* serif */ +/* 211 */ "©", /* serif */ +/* 212 */ "™", /* serif */ +/* 213 */ "∏", +/* 214 */ "√", +/* 215 */ "·", +/* 216 */ "¬", +/* 217 */ "∧", +/* 218 */ "∨", +/* 219 */ "⇔", +/* 220 */ "⇐", +/* 221 */ "⇑", +/* 222 */ "⇒", +/* 223 */ "⇓", +/* 224 */ "◊", +/* 225 */ "⟨", +/* 226 */ "®", /* sans serif */ +/* 227 */ "©", /* sans serif */ +/* 228 */ "™", /* sans serif */ +/* 229 */ "∑", +/* 230 */ 0, +/* 231 */ 0, +/* 232 */ 0, +/* 233 */ "⌈", +/* 234 */ "|", +/* 235 */ "⌊", +/* 236 */ 0, +/* 237 */ 0, +/* 238 */ 0, +/* 239 */ "|", +/* 240 */ "ð", +/* 241 */ "⟩", +/* 242 */ "∫", +/* 243 */ 0, +/* 244 */ 0, +/* 245 */ 0, +/* 246 */ 0, +/* 247 */ 0, +/* 248 */ 0, +/* 249 */ "⌉", +/* 250 */ "|", +/* 251 */ "⌋", +/* 252 */ 0, +/* 253 */ 0, +/* 254 */ 0, +}; +#endif +static char* cp437 [] = { +/* 0x80 */ "ç", +/* 0x81 */ "ü", +/* 0x82 */ "é", +/* 0x83 */ "â", +/* 0x84 */ "ä", +/* 0x85 */ "à", +/* 0x86 */ "å", +/* 0x87 */ "ç", +/* 0x88 */ "ê", +/* 0x89 */ "ë", +/* 0x8a */ "è", +/* 0x8b */ "ï", +/* 0x8c */ "î", +/* 0x8d */ "ì", +/* 0x8e */ "ä", +/* 0x8f */ "å", +/* 0x90 */ "é", +/* 0x91 */ "æ", +/* 0x92 */ "æ", +/* 0x93 */ "ô", +/* 0x94 */ "ö", +/* 0x95 */ "ò", +/* 0x96 */ "û", +/* 0x97 */ "ù", +/* 0x98 */ "ÿ", +/* 0x99 */ "ö", +/* 0x9a */ "ü", +/* 0x9b */ "¢", +/* 0x9c */ "£", +/* 0x9d */ "¥", +/* 0x9e */ "₧", /* peseta */ +/* 0x9f */ "ƒ", /* small f with hook */ +/* 0xa0 */ "á", +/* 0xa1 */ "í", +/* 0xa2 */ "ó", +/* 0xa3 */ "ú", +/* 0xa4 */ "ñ", +/* 0xa5 */ "ñ", +/* 0xa6 */ "ª", +/* 0xa7 */ "¼", +/* 0xa8 */ "¿", +/* 0xa9 */ "⌐", /* reversed not */ +/* 0xaa */ "¬", +/* 0xab */ "½", +/* 0xac */ "»", +/* 0xad */ "¡", +/* 0xae */ "«", +/* 0xaf */ "º", +/* 0xb0 */ "░", /* light shade */ +/* 0xb1 */ "▒", /* med. shade */ +/* 0xb2 */ "▓", /* dark shade */ +/* 0xb3 */ "│", /* box-draw light vert. */ +/* 0xb4 */ "┤", /* box-draw light vert. + lt. */ +/* 0xb5 */ "╡", /* box-draw vert. sgl. + lt. dbl. */ +/* 0xb6 */ "╢", /* box-draw vert. dbl. + lt. sgl. */ +/* 0xb7 */ "╖", /* box-draw dn. dbl. + lt. sgl. */ +/* 0xb8 */ "╕", /* box-draw dn. sgl. + lt. dbl. */ +/* 0xb9 */ "╣", /* box-draw dbl. vert. + lt. */ +/* 0xba */ "║", /* box-draw dbl. vert. */ +/* 0xbb */ "╗", /* box-draw dbl. dn. + lt. */ +/* 0xbc */ "╝", /* box-draw dbl. up + lt. */ +/* 0xbd */ "╜", /* box-draw up dbl. + lt. sgl. */ +/* 0xbe */ "╛", /* box-draw up sgl. + lt. dbl. */ +/* 0xbf */ "┐", /* box-draw light dn. + lt. */ +/* 0xc0 */ "└", /* box-draw light up + rt. */ +/* 0xc1 */ "┴", /* box-draw light up + horiz. */ +/* 0xc2 */ "┬", /* box-draw light dn. + horiz. */ +/* 0xc3 */ "├", /* box-draw light vert. + rt. */ +/* 0xc4 */ "─", /* box-draw light horiz. */ +/* 0xc5 */ "┼", /* box-draw light vert. + horiz. */ +/* 0xc6 */ "╞", /* box-draw vert. sgl. + rt. dbl. */ +/* 0xc7 */ "╟", /* box-draw vert. dbl. + rt. sgl. */ +/* 0xc8 */ "╚", /* box-draw dbl. up + rt. */ +/* 0xc9 */ "╔", /* box-draw dbl. dn. + rt. */ +/* 0xca */ "╩", /* box-draw dbl. up + horiz. */ +/* 0xcb */ "╦", /* box-draw dbl. dn. + horiz. */ +/* 0xcc */ "╠", /* box-draw dbl. vert. + rt. */ +/* 0xcd */ "═", /* box-draw dbl. horiz. */ +/* 0xce */ "╬", /* box-draw dbl. vert. + horiz. */ +/* 0xcf */ "╧", /* box-draw up sgl. + horiz. dbl. */ +/* 0xd0 */ "╨", /* box-draw up dbl. + horiz. sgl. */ +/* 0xd1 */ "╤", /* box-draw dn. sgl. + horiz. dbl. */ +/* 0xd2 */ "╥", /* box-draw dn. dbl. + horiz. sgl. */ +/* 0xd3 */ "╙", /* box-draw up dbl. + rt. sgl. */ +/* 0xd4 */ "╘", /* box-draw up sgl. + rt. dbl. */ +/* 0xd5 */ "╒", /* box-draw dn. sgl. + rt. dbl. */ +/* 0xd6 */ "╓", /* box-draw dn. dbl. + rt. sgl. */ +/* 0xd7 */ "╫", /* box-draw vert. dbl. + horiz. sgl. */ +/* 0xd8 */ "╪", /* box-draw vert. sgl. + horiz. dbl. */ +/* 0xd9 */ "┘", /* box-draw light up + lt. */ +/* 0xda */ "┌", /* box-draw light dn. + rt. */ +/* 0xdb */ "█", /* full block */ +/* 0xdc */ "▄", /* lower 1/2 block */ +/* 0xdd */ "▌", /* lt. 1/2 block */ +/* 0xde */ "▐", /* rt. 1/2 block */ +/* 0xdf */ "▀", /* upper 1/2 block */ +/* 0xe0 */ "α", /* greek small alpha */ +/* 0xe1 */ "ß", +/* 0xe2 */ "Γ", /* greek cap gamma */ +/* 0xe3 */ "π", /* greek small pi */ +/* 0xe4 */ "Σ", /* greek cap sigma */ +/* 0xe5 */ "σ", /* greek small sigma */ +/* 0xe6 */ "µ", +/* 0xe7 */ "τ", /* greek small tau */ +/* 0xe8 */ "Φ", /* greek cap phi */ +/* 0xe9 */ "Θ", /* greek cap theta */ +/* 0xea */ "Ω", /* greek cap omega */ +/* 0xeb */ "δ", /* greek small delta */ +/* 0xec */ "∞", /* inf. */ +/* 0xed */ "φ", /* greek small phi */ +/* 0xee */ "ε", /* greek small epsilon */ +/* 0xef */ "∩", /* intersect */ +/* 0xf0 */ "≡", /* identical */ +/* 0xf1 */ "±", +/* 0xf2 */ "≥", /* greater-than or equal to */ +/* 0xf3 */ "≤", /* less-than or equal to */ +/* 0xf4 */ "⌠", /* top 1/2 integral */ +/* 0xf5 */ "⌡", /* bottom 1/2 integral */ +/* 0xf6 */ "÷", +/* 0xf7 */ "≈", /* almost = */ +/* 0xf8 */ "+", +/* 0xf9 */ "∙", /* bullet op */ +/* 0xfa */ "·", +/* 0xfb */ "√", /* sqrt */ +/* 0xfc */ "ⁿ", /* super-script small n */ +/* 0xfd */ "²", +/* 0xfe */ "■", /* black square */ +/* 0xff */ " ", +}; + +static char* cp850 [] = { +/* 0x80 */ "ç", +/* 0x81 */ "ü", +/* 0x82 */ "é", +/* 0x83 */ "â", +/* 0x84 */ "ä", +/* 0x85 */ "à", +/* 0x86 */ "å", +/* 0x87 */ "ç", +/* 0x88 */ "ê", +/* 0x89 */ "ë", +/* 0x8a */ "è", +/* 0x8b */ "ï", +/* 0x8c */ "î", +/* 0x8d */ "ì", +/* 0x8e */ "ä", +/* 0x8f */ "å", +/* 0x90 */ "é", +/* 0x91 */ "æ", +/* 0x92 */ "æ", +/* 0x93 */ "ô", +/* 0x94 */ "ö", +/* 0x95 */ "ò", +/* 0x96 */ "û", +/* 0x97 */ "ù", +/* 0x98 */ "ÿ", +/* 0x99 */ "ö", +/* 0x9a */ "ü", +/* 0x9b */ "ø", +/* 0x9c */ "£", +/* 0x9d */ "ø", +/* 0x9e */ "×", +/* 0x9f */ "ƒ", /* small f with hook */ +/* 0xa0 */ "á", +/* 0xa1 */ "í", +/* 0xa2 */ "ó", +/* 0xa3 */ "ú", +/* 0xa4 */ "ñ", +/* 0xa5 */ "ñ", +/* 0xa6 */ "ª", +/* 0xa7 */ "¼", +/* 0xa8 */ "¿", +/* 0xa9 */ "®", +/* 0xaa */ "¬", +/* 0xab */ "½", +/* 0xac */ "»", +/* 0xad */ "¡", +/* 0xae */ "«", +/* 0xaf */ "º", +/* 0xb0 */ "░", /* light shade */ +/* 0xb1 */ "▒", /* med. shade */ +/* 0xb2 */ "▓", /* dark shade */ +/* 0xb3 */ "│", /* box-draw light vert. */ +/* 0xb4 */ "┤", /* box-draw light vert. + lt. */ +/* 0xb5 */ "á", +/* 0xb6 */ "â", +/* 0xb7 */ "à", +/* 0xb8 */ "©", +/* 0xb9 */ "╣", /* box-draw dbl. vert. + lt. */ +/* 0xba */ "║", /* box-draw dbl. vert. */ +/* 0xbb */ "╗", /* box-draw dbl. dn. + lt. */ +/* 0xbc */ "╝", /* box-draw dbl. up + lt. */ +/* 0xbd */ "¢", +/* 0xbe */ "¥", +/* 0xbf */ "┐", /* box-draw light dn. + lt. */ +/* 0xc0 */ "└", /* box-draw light up + rt. */ +/* 0xc1 */ "┴", /* box-draw light up + horiz. */ +/* 0xc2 */ "┬", /* box-draw light dn. + horiz. */ +/* 0xc3 */ "├", /* box-draw light vert. + rt. */ +/* 0xc4 */ "─", /* box-draw light horiz. */ +/* 0xc5 */ "┼", /* box-draw light vert. + horiz. */ +/* 0xc6 */ "ã", +/* 0xc7 */ "ã", +/* 0xc8 */ "╚", /* box-draw dbl. up + rt. */ +/* 0xc9 */ "╔", /* box-draw dbl. dn. + rt. */ +/* 0xca */ "╩", /* box-draw dbl. up + horiz. */ +/* 0xcb */ "╦", /* box-draw dbl. dn. + horiz. */ +/* 0xcc */ "╠", /* box-draw dbl. vert. + rt. */ +/* 0xcd */ "═", /* box-draw dbl. horiz. */ +/* 0xce */ "╬", /* box-draw dbl. vert. + horiz. */ +/* 0xcf */ "¤", +/* 0xd0 */ "ð", +/* 0xd1 */ "ð", +/* 0xd2 */ "ê", +/* 0xd3 */ "ë", +/* 0xd4 */ "è", +/* 0xd5 */ "ı", /* small dotless i */ +/* 0xd6 */ "í", +/* 0xd7 */ "î", +/* 0xd8 */ "ï", +/* 0xd9 */ "┘", /* box-draw light up + lt. */ +/* 0xda */ "┌", /* box-draw light dn. + rt. */ +/* 0xdb */ "█", /* full-block */ +/* 0xdc */ "▄", /* lower 1/2 block */ +/* 0xdd */ "¦", +/* 0xde */ "ì", +/* 0xdf */ "▀", /* upper 1/2 block */ +/* 0xe0 */ "ó", +/* 0xe1 */ "ß", +/* 0xe2 */ "ô", +/* 0xe3 */ "ò", +/* 0xe4 */ "õ", +/* 0xe5 */ "õ", +/* 0xe6 */ "µ", +/* 0xe7 */ "þ", +/* 0xe8 */ "þ", +/* 0xe9 */ "ú", +/* 0xea */ "û", +/* 0xeb */ "ù", +/* 0xec */ "ý", +/* 0xed */ "ý", +/* 0xee */ "¯", +/* 0xef */ "´", +/* 0xf0 */ "­", +/* 0xf1 */ "±", +/* 0xf2 */ "‗", /* dbl. lowline */ +/* 0xf3 */ "¾", +/* 0xf4 */ "¶", +/* 0xf5 */ "§", +/* 0xf6 */ "÷", +/* 0xf7 */ "¸", +/* 0xf8 */ "+", +/* 0xf9 */ "¨", +/* 0xfa */ "·", +/* 0xfb */ "¹", +/* 0xfc */ "³", +/* 0xfd */ "²", +/* 0xfe */ "■", /* black square */ +/* 0xff */ " ", +}; + + + + +/*======================================================================== + * Name: html_init + * Purpose: Generates the HTML output personality. + * Args: None. + * Returns: OutputPersonality. + *=======================================================================*/ + +OutputPersonality * +html_init (void) +{ + OutputPersonality* op; + + op = op_create(); + + op->comment_begin = "\n"; + + op->document_begin = "\n\n"; + op->document_end = "\n"; + + op->header_begin = "\n"; + op->header_end = "\n"; + + op->document_title_begin = ""; + op->document_title_end = "\n"; + + op->document_author_begin = "\n"; + + op->document_changedate_begin = "\n"; + + op->body_begin = ""; + op->body_end = "\n"; + + op->paragraph_begin = "

"; + op->paragraph_end = "

\n"; + + op->center_begin = "
"; + op->center_end = "
\n"; + + op->justify_begin = "
\n"; + op->justify_end = "
\n"; + + op->align_left_begin = "
\n"; + op->align_left_end = "
\n"; + + op->align_right_begin = "
\n"; + op->align_right_end = "
\n"; + + op->forced_space = " "; + op->line_break = "
\n"; + op->page_break = "


\n"; + + op->hyperlink_begin = "hyperlink_end = "\">hyperlink"; + + op->imagelink_begin = "imagelink_end = "\">"; + + op->table_begin = "\n"; + op->table_end = "
\n"; + + op->table_row_begin = ""; + op->table_row_end = "\n"; + + op->table_cell_begin = ""; + op->table_cell_end = "\n"; + + /* Character attributes */ + op->font_begin = ""; + op->font_end = ""; + + op->fontsize_begin = ""; + op->fontsize_end = ""; + + op->fontsize8_begin = ""; + op->fontsize8_end = ""; + op->fontsize10_begin = ""; + op->fontsize10_end = ""; + op->fontsize12_begin = ""; + op->fontsize12_end = ""; + op->fontsize14_begin = ""; + op->fontsize14_end = ""; + op->fontsize18_begin = ""; + op->fontsize18_end = ""; + op->fontsize24_begin = ""; + op->fontsize24_end = ""; + + op->smaller_begin = ""; + op->smaller_end = ""; + + op->bigger_begin = ""; + op->bigger_end = ""; + + op->foreground_begin = ""; + op->foreground_end = ""; + + op->background_begin = ""; + op->background_end = ""; + + op->bold_begin = ""; + op->bold_end = ""; + + op->italic_begin = ""; + op->italic_end = ""; + + op->underline_begin = ""; + op->underline_end = ""; + + op->dbl_underline_begin = ""; + op->dbl_underline_end = ""; + + op->superscript_begin = ""; + op->superscript_end = ""; + + op->subscript_begin = ""; + op->subscript_end = ""; + + op->strikethru_begin = ""; + op->strikethru_end = ""; + + op->dbl_strikethru_begin = ""; + op->dbl_strikethru_end = ""; + + op->emboss_begin=""; + op->emboss_end = ""; + + op->engrave_begin = ""; + op->engrave_end = ""; + + op->shadow_begin= ""; + op->shadow_end= ""; + + op->outline_begin= ""; + op->outline_end= ""; + + op->expand_begin = ""; + op->expand_end = ""; + + op->pointlist_begin = "

    \n"; + op->pointlist_end = "
\n"; + op->pointlist_item_begin = "
  • "; + op->pointlist_item_end = "
  • \n"; + + op->numericlist_begin = "
      \n"; + op->numericlist_end = "
    \n"; + op->numericlist_item_begin = "
  • "; + op->numericlist_item_end = "
  • \n"; + + op->simulate_small_caps = TRUE; + op->simulate_all_caps = TRUE; + op->simulate_word_underline = TRUE; + + op->ascii_translation_table = ascii; + + op->ansi_translation_table = ansi; +#if 1 /* daved - 0.9.6 */ + op->ansi_first_char = 0x78; +#else + op->ansi_first_char = 0x82; +#endif + op->ansi_last_char = 0xff; + + op->cp437_translation_table = cp437; + op->cp437_first_char = 0x80; + op->cp437_last_char = 0xff; + + op->cp850_translation_table = cp850; + op->cp850_first_char = 0x80; + op->cp850_last_char = 0xff; + + op->mac_translation_table = mac; + op->mac_first_char = 0xa4; + op->mac_last_char = 0xd5; + +#if 1 /* daved 0.19.8 */ + op->chars.right_quote = "’"; + op->chars.left_quote = "‘"; + op->chars.right_dbl_quote = "”"; + op->chars.left_dbl_quote = "“"; +#else + op->chars.right_quote = "'"; + op->chars.left_quote = "`"; + op->chars.right_dbl_quote = "\""; + op->chars.left_dbl_quote = "\""; +#endif +#if 1 /* daved - 0.19.8 */ + op->chars.endash = "–"; + op->chars.emdash = "—"; + op->chars.bullet = "•"; + op->chars.lessthan = "<"; + op->chars.greaterthan = ">"; + op->chars.amp = "&"; + op->chars.copyright = "©"; + op->chars.trademark = "™"; + op->chars.nonbreaking_space = " "; +#endif + +#if 1 /* daved - 0.19.4 - unicode symbol character support */ + op->unisymbol1_first_char = 913; + op->unisymbol1_last_char = 982; + op->unisymbol1_translation_table = unisymbol1; + op->unisymbol2_first_char = 57516; + op->unisymbol2_last_char = 57557; + op->unisymbol2_translation_table = unisymbol2; + op->unisymbol3_first_char = 61505; + op->unisymbol3_last_char = 61562; + op->unisymbol3_translation_table = unisymbol3; +#endif +#if 1 /* daved - 0.19.5 - more unicode symbol character support */ + op->unisymbol4_first_char = 61600; + op->unisymbol4_last_char = 61694; + op->unisymbol4_translation_table = unisymbol4; +#endif +#if 1 /* daved - 0.19.5 - SYMBOL font support */ + op->symbol_first_char = 60; + op->symbol_last_char = 254; + op->symbol_translation_table = symbol; +#endif + + return op; +} diff --git a/plugins/flp_import/unrtf/html.h b/plugins/flp_import/unrtf/html.h new file mode 100644 index 000000000..ad6bf5db4 --- /dev/null +++ b/plugins/flp_import/unrtf/html.h @@ -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 + diff --git a/plugins/flp_import/unrtf/main.h b/plugins/flp_import/unrtf/main.h new file mode 100644 index 000000000..9752efe9f --- /dev/null +++ b/plugins/flp_import/unrtf/main.h @@ -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; + + diff --git a/plugins/flp_import/unrtf/malloc.c b/plugins/flp_import/unrtf/malloc.c new file mode 100644 index 000000000..ced9c693e --- /dev/null +++ b/plugins/flp_import/unrtf/malloc.c @@ -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 : 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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#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; +} + diff --git a/plugins/flp_import/unrtf/malloc.h b/plugins/flp_import/unrtf/malloc.h new file mode 100644 index 000000000..991bd17a0 --- /dev/null +++ b/plugins/flp_import/unrtf/malloc.h @@ -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*); + diff --git a/plugins/flp_import/unrtf/output.c b/plugins/flp_import/unrtf/output.c new file mode 100644 index 000000000..de665fe4b --- /dev/null +++ b/plugins/flp_import/unrtf/output.c @@ -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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#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"); + } + } +} + + diff --git a/plugins/flp_import/unrtf/output.h b/plugins/flp_import/unrtf/output.h new file mode 100644 index 000000000..ae1a5a0b5 --- /dev/null +++ b/plugins/flp_import/unrtf/output.h @@ -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 + diff --git a/plugins/flp_import/unrtf/parse.c b/plugins/flp_import/unrtf/parse.c new file mode 100644 index 000000000..f74036d98 --- /dev/null +++ b/plugins/flp_import/unrtf/parse.c @@ -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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_CTYPE_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#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); +} diff --git a/plugins/flp_import/unrtf/parse.h b/plugins/flp_import/unrtf/parse.h new file mode 100644 index 000000000..c1d8de2b7 --- /dev/null +++ b/plugins/flp_import/unrtf/parse.h @@ -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*); + + + diff --git a/plugins/flp_import/unrtf/util.c b/plugins/flp_import/unrtf/util.c new file mode 100644 index 000000000..3168ce3e9 --- /dev/null +++ b/plugins/flp_import/unrtf/util.c @@ -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 +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_CTYPE_H +#include +#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; +} + diff --git a/plugins/flp_import/unrtf/util.h b/plugins/flp_import/unrtf/util.h new file mode 100644 index 000000000..e49c0070b --- /dev/null +++ b/plugins/flp_import/unrtf/util.h @@ -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 *); diff --git a/plugins/flp_import/unrtf/word.c b/plugins/flp_import/unrtf/word.c new file mode 100644 index 000000000..989a92b97 --- /dev/null +++ b/plugins/flp_import/unrtf/word.c @@ -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 again + * 14 Oct 00, tuorfa@yahoo.com: fixed closure of tables + * 15 Oct 00, tuorfa@yahoo.com: fixed font attributes preceding + * 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 + * 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 +#endif + +#ifdef HAVE_STDIO_H +#include +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifdef HAVE_CTYPE_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#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;ichild) { + 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; +} diff --git a/plugins/flp_import/unrtf/word.h b/plugins/flp_import/unrtf/word.h new file mode 100644 index 000000000..8e42835de --- /dev/null +++ b/plugins/flp_import/unrtf/word.h @@ -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 diff --git a/plugins/triple_oscillator/triple_oscillator.cpp b/plugins/triple_oscillator/triple_oscillator.cpp index 182fc8b08..1131bdf78 100644 --- a/plugins/triple_oscillator/triple_oscillator.cpp +++ b/plugins/triple_oscillator/triple_oscillator.cpp @@ -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 ); diff --git a/plugins/triple_oscillator/triple_oscillator.h b/plugins/triple_oscillator/triple_oscillator.h index 1159f846e..52467fb87 100644 --- a/plugins/triple_oscillator/triple_oscillator.h +++ b/plugins/triple_oscillator/triple_oscillator.h @@ -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; diff --git a/plugins/vibed/impulse_editor.cpp b/plugins/vibed/impulse_editor.cpp index fa172b5ae..7e0ade83f 100644 --- a/plugins/vibed/impulse_editor.cpp +++ b/plugins/vibed/impulse_editor.cpp @@ -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 ); diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index 9864c5ce5..ec607c25b 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -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() ) diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index 10427cc2e..f8d5e1fca 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -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" ); diff --git a/src/core/envelope_tab_widget.cpp b/src/core/envelope_tab_widget.cpp index 02b64a216..c4ef3eaea 100644 --- a/src/core/envelope_tab_widget.cpp +++ b/src/core/envelope_tab_widget.cpp @@ -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 ); diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index 11ccdbbf3..a13478ce4 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -251,7 +251,7 @@ void notePlayHandle::noteOff( const f_cnt_t _s ) if( m_instrumentTrack != NULL ) { m_releaseFramesToDo = tMax( 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 ); } diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index aae6ec799..f17b96896 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -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(); diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 9a49890fc..4bd4eb0c7 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -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 ); } diff --git a/src/core/track_container.cpp b/src/core/track_container.cpp index 543d8cdb0..d93fa712e 100644 --- a/src/core/track_container.cpp +++ b/src/core/track_container.cpp @@ -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 ); }