pluginsubformsxc.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <stdio.h>
00022 
00023 #include "pluginsubformsxc.h"
00024 #include "funcaux.h"
00025 
00026 #include <QFile>
00027 #include <QTextStream>
00028 #include <QTranslator>
00029 #include <QTextCodec>
00030 #include <QLocale>
00031 
00032 
00034 
00037 int entryPoint(QApplication *) {
00038     _depura("Punto de Entrada del plugin de SubformSXC\n", 0);
00039     cargaTraducciones("pluginsubformsxc");
00040     _depura("END Punto de Entrada del plugin de SubformSXC\n", 0);
00041     return 0;
00042 }
00043 
00044 
00046 
00049 myplugsubformsxc::myplugsubformsxc(SubForm3 *parent) : QObject(parent) {
00050   _depura("myplugsubformsxc::myplugsubformsxc", 0);
00051   _depura("END myplugsubformsxc::myplugsubformsxc", 0);
00052 }
00053 
00054 
00056 
00058 myplugsubformsxc::~myplugsubformsxc(){
00059   _depura("myplugsubformsxc::~myplugsubformsxc", 0);
00060   _depura("END myplugsubformsxc::~myplugsubformsxc", 0);
00061 }
00062 
00063 
00065 
00068 void myplugsubformsxc::s_pintaMenu(QMenu *menu) {
00069     _depura("myplugsubformsxc::s_pintaMenu", 0);
00070     menu->addSeparator();
00071     menu->addAction(tr("Exportar a Hoja de Calculo"));
00072     _depura("END myplugsubformsxc::s_pintaMenu", 0);
00073 }
00074 
00075 
00077 
00080 void myplugsubformsxc::s_trataMenu(QAction *action) {
00081     _depura("myplugsubformsxc::s_trataMenu", 0);
00082     if (action->text() == tr("Exportar a Hoja de Calculo")) {
00083         sacaSXC();
00084     } // end if
00085     _depura("END myplugsubformsxc::s_trataMenu", 0);
00086 }
00087 
00088 
00090 
00092 void myplugsubformsxc::sacaSXC() {
00093     _depura("myplugsubformsxc::sacaSXC", 0);
00094 
00095     QString archivod = confpr->valor ( CONF_DIR_USER ) + "listadosxc.perl";
00096     SubForm3 * subf = (SubForm3 *) parent();
00097 
00098 
00099         QString fitxersortidatxt = "";
00100 
00101         fitxersortidatxt += "#!/usr/bin/perl\n";
00102         fitxersortidatxt += "# calc-example5 - Set Column sizes\n";
00103         fitxersortidatxt += "\n";
00104         fitxersortidatxt += "use ooolib;\n";
00105         fitxersortidatxt += "use utf8;\n";
00106         fitxersortidatxt += "\n";
00107         fitxersortidatxt += "# Set variables\n";
00108         fitxersortidatxt += "$doc = new ooolib(\"sxc\");\n";
00109         fitxersortidatxt += "$doc->oooSet(\"builddir\", \".\");\n";
00110         fitxersortidatxt += "$doc->oooSet(\"title\", \"Informe de Proveedores\");\n";
00111         fitxersortidatxt += "$doc->oooSet(\"subject\", \"Proveedores\");\n";
00112         fitxersortidatxt += "$doc->oooSet(\"comments\", \"Informe de Proveedores\");\n";
00113         fitxersortidatxt += "$doc->oooSet(\"author\", \"ooolib Example\");\n";
00114         fitxersortidatxt += "$doc->oooSet(\"meta1-name\", \"Programmer\");\n";
00115         fitxersortidatxt += "$doc->oooSet(\"meta1-value\", \"Tomeu BorrĂ¡s\");\n";
00116         fitxersortidatxt += "\n";
00117 
00118         fitxersortidatxt += "$doc->oooSet(\"cell-auto\", \"1,0\");\n";
00119         fitxersortidatxt += "$doc->oooSet(\"bold\", \"on\");\n";
00120         fitxersortidatxt += "$doc->oooSet(\"text-size\", \"18\");\n";
00121         fitxersortidatxt += "$doc->oooSet(\"cell-loc\", 4, 1);\n";
00122         fitxersortidatxt += "$doc->oooData(\"cell-text\", \"INFORME ANUAL DE COMPRAS POR PROVEEDOR\");\n";
00123         fitxersortidatxt += "$doc->oooSet(\"text-size\", \"10\");\n";
00124         fitxersortidatxt += "$doc->oooSet(\"bold\", \"off\");\n";
00125 
00126 
00127         int y=1;
00128         int x = 1;
00130     for (int h = 0; h < subf->mui_listcolumnas->rowCount(); ++h) {
00131         if (subf->mui_listcolumnas->item(h, 0)->checkState() == Qt::Checked) {
00132 
00133                         fitxersortidatxt += "# Fila "+ QString::number ( y ) +"\n";
00134                         fitxersortidatxt += "$doc->oooSet(\"bold\", \"on\");\n";
00135                         fitxersortidatxt += "$doc->oooSet(\"cell-loc\", "+ QString::number ( x++ ) +", "+ QString::number ( y ) +");\n";
00136                         fitxersortidatxt += "$doc->oooData(\"cell-text\", \"" +(subf->mui_listcolumnas->item(h, 2)->text()) +"\");\n";
00137 
00138                         fitxersortidatxt += "$doc->oooSet(\"bold\", \"off\");\n";
00139                         fitxersortidatxt += "\n";
00140 
00141         } // end if
00142     } // end for
00143 
00144 
00145     y += 2;
00146 
00148     for (int i = 0; i < subf->mui_list->rowCount(); ++i) {
00149 
00150         int x = 1;
00151         for (int j = 0; j < subf->mui_listcolumnas->rowCount(); ++j) {
00152 
00153             if (subf->mui_listcolumnas->item(j, 0)->checkState() == Qt::Checked) {
00154 
00155 
00156                         fitxersortidatxt += "# Fila "+ QString::number ( y ) +"\n";
00157                         fitxersortidatxt += "$doc->oooSet(\"bold\", \"on\");\n";
00158                         fitxersortidatxt += "$doc->oooSet(\"cell-loc\", "+ QString::number ( x++ ) +", "+ QString::number ( y ) +");\n";
00159                         fitxersortidatxt += "$doc->oooData(\"cell-text\", \"" +(subf->mui_list->item(i, j)->text()) +"\");\n";
00160 
00161                         fitxersortidatxt += "$doc->oooSet(\"bold\", \"off\");\n";
00162                         fitxersortidatxt += "\n";
00163 
00164             } // end if
00165         } // end forXMLProtect(subf->mui_list->item(i, j)->text())
00166         y++;
00167     } // end for
00168 
00169 
00170         fitxersortidatxt += "my($filename) = $doc->oooGenerate(\"listadosxc.sxc\");\n";
00171         fitxersortidatxt += "\n";
00172         fitxersortidatxt += "exit;\n";
00173 
00174 
00175         QString cadena ="rm "+confpr->valor ( CONF_DIR_USER ) + "listadosxc.sxc";
00176         system ( cadena.toAscii() );
00177         cadena ="rm "+ archivod;
00178         system ( cadena.toAscii() );
00179 
00180         QFile file ( archivod );
00181         if ( file.open ( QIODevice::WriteOnly ) )  {
00182                 QTextStream stream ( &file );
00183                 stream.setCodec("UTF-8");
00184                 stream << fitxersortidatxt;
00185                 file.close();
00186         } // end if
00187 
00188         cadena= " cd "+confpr->valor ( CONF_DIR_USER ) +"; perl "+archivod;
00189         system ( cadena.toAscii() );
00190         cadena = "kspread "+confpr->valor ( CONF_DIR_USER ) + "listadosxc.sxc &";
00191         system ( cadena.toAscii() );
00192 
00193     _depura("END myplugsubformsxc::sacaSXC", 0);
00194 }
00195 
00196 
00198 
00202 int SubForm3_SubForm3_Post(SubForm3 *sub) {
00203     _depura("SubForm3_SubForm3_Post", 0);
00204    myplugsubformsxc *subformsxc = new myplugsubformsxc(sub);
00205    sub->QObject::connect(sub, SIGNAL(pintaMenu(QMenu *)), subformsxc, SLOT(s_pintaMenu(QMenu *)));
00206    sub->QObject::connect(sub, SIGNAL(trataMenu(QAction *)), subformsxc, SLOT(s_trataMenu(QAction *)));
00207     _depura("END SubForm3_SubForm3_Post", 0);
00208    return 0;
00209 }
00210 

Generated on Sat Dec 15 00:01:20 2007 for BulmaGes by  doxygen 1.5.1