00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "./editdcopinterface.h"
00010
00011 #include <kdatastream.h>
00012 #include <qasciidict.h>
00013
00014 namespace KTextEditor {
00015
00016 static const int EditDCOPInterface_fhash = 11;
00017 static const char* const EditDCOPInterface_ftable[10][3] = {
00018 { "QString", "text()", "text()" },
00019 { "QString", "textLine(uint)", "textLine(uint line)" },
00020 { "int", "numLines()", "numLines()" },
00021 { "int", "length()", "length()" },
00022 { "void", "setText(QString)", "setText(QString text)" },
00023 { "bool", "insertText(uint,uint,QString)", "insertText(uint line,uint col,QString text)" },
00024 { "bool", "removeText(uint,uint,uint,uint)", "removeText(uint startLine,uint startCol,uint endLine,uint endCol)" },
00025 { "bool", "insertLine(uint,QString)", "insertLine(uint line,QString text)" },
00026 { "bool", "removeLine(uint)", "removeLine(uint line)" },
00027 { 0, 0, 0 }
00028 };
00029
00030 bool EditDCOPInterface::process(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData)
00031 {
00032 static QAsciiDict<int>* fdict = 0;
00033 if ( !fdict ) {
00034 fdict = new QAsciiDict<int>( EditDCOPInterface_fhash, TRUE, FALSE );
00035 for ( int i = 0; EditDCOPInterface_ftable[i][1]; i++ )
00036 fdict->insert( EditDCOPInterface_ftable[i][1], new int( i ) );
00037 }
00038 int* fp = fdict->find( fun );
00039 switch ( fp?*fp:-1) {
00040 case 0: {
00041 replyType = EditDCOPInterface_ftable[0][0];
00042 QDataStream _replyStream( replyData, IO_WriteOnly );
00043 _replyStream << text( );
00044 } break;
00045 case 1: {
00046 uint arg0;
00047 QDataStream arg( data, IO_ReadOnly );
00048 arg >> arg0;
00049 replyType = EditDCOPInterface_ftable[1][0];
00050 QDataStream _replyStream( replyData, IO_WriteOnly );
00051 _replyStream << textLine(arg0 );
00052 } break;
00053 case 2: {
00054 replyType = EditDCOPInterface_ftable[2][0];
00055 QDataStream _replyStream( replyData, IO_WriteOnly );
00056 _replyStream << numLines( );
00057 } break;
00058 case 3: {
00059 replyType = EditDCOPInterface_ftable[3][0];
00060 QDataStream _replyStream( replyData, IO_WriteOnly );
00061 _replyStream << length( );
00062 } break;
00063 case 4: {
00064 QString arg0;
00065 QDataStream arg( data, IO_ReadOnly );
00066 arg >> arg0;
00067 replyType = EditDCOPInterface_ftable[4][0];
00068 setText(arg0 );
00069 } break;
00070 case 5: {
00071 uint arg0;
00072 uint arg1;
00073 QString arg2;
00074 QDataStream arg( data, IO_ReadOnly );
00075 arg >> arg0;
00076 arg >> arg1;
00077 arg >> arg2;
00078 replyType = EditDCOPInterface_ftable[5][0];
00079 QDataStream _replyStream( replyData, IO_WriteOnly );
00080 _replyStream << insertText(arg0, arg1, arg2 );
00081 } break;
00082 case 6: {
00083 uint arg0;
00084 uint arg1;
00085 uint arg2;
00086 uint arg3;
00087 QDataStream arg( data, IO_ReadOnly );
00088 arg >> arg0;
00089 arg >> arg1;
00090 arg >> arg2;
00091 arg >> arg3;
00092 replyType = EditDCOPInterface_ftable[6][0];
00093 QDataStream _replyStream( replyData, IO_WriteOnly );
00094 _replyStream << removeText(arg0, arg1, arg2, arg3 );
00095 } break;
00096 case 7: {
00097 uint arg0;
00098 QString arg1;
00099 QDataStream arg( data, IO_ReadOnly );
00100 arg >> arg0;
00101 arg >> arg1;
00102 replyType = EditDCOPInterface_ftable[7][0];
00103 QDataStream _replyStream( replyData, IO_WriteOnly );
00104 _replyStream << insertLine(arg0, arg1 );
00105 } break;
00106 case 8: {
00107 uint arg0;
00108 QDataStream arg( data, IO_ReadOnly );
00109 arg >> arg0;
00110 replyType = EditDCOPInterface_ftable[8][0];
00111 QDataStream _replyStream( replyData, IO_WriteOnly );
00112 _replyStream << removeLine(arg0 );
00113 } break;
00114 default:
00115 return DCOPObject::process( fun, data, replyType, replyData );
00116 }
00117 return TRUE;
00118 }
00119
00120 QCStringList EditDCOPInterface::interfaces()
00121 {
00122 QCStringList ifaces = DCOPObject::interfaces();
00123 ifaces += "KTextEditor::EditDCOPInterface";
00124 return ifaces;
00125 }
00126
00127 QCStringList EditDCOPInterface::functions()
00128 {
00129 QCStringList funcs = DCOPObject::functions();
00130 for ( int i = 0; EditDCOPInterface_ftable[i][2]; i++ ) {
00131 QCString func = EditDCOPInterface_ftable[i][0];
00132 func += ' ';
00133 func += EditDCOPInterface_ftable[i][2];
00134 funcs << func;
00135 }
00136 return funcs;
00137 }
00138
00139 }
00140