1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*
CCC - CD COVER CREATOR
Copyright (C) 2000 Ulli Meybohm, www.meybohm.de (ulli@meybohm.de)
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "texmaker.h"
#include "reshead.h"
#include "resfront.h"
#include "resback.h"
/*Cover Class-Constructors */
Cover::Cover(){
count=1;
}
Cover::Cover(const Cover &c){
title=c.title;
subtitle=c.subtitle;
backcover=c.backcover;
count=c.count;
sidetext_left=c.sidetext_left;
sidetext_right=c.sidetext_right;
}
/*Replace special charachters with tex-entities*/
Bytevector Cover::replaceVar(Bytevector b, int i){
Bytevector tab(1);
tab.data[0]=9;
b.replace("%n",count);
b.replace("%i",i);
/*
Fucking Backslash-Sequenzes
*/
b.replace("$","%%$EURO_RULEZ$%%");
b.replace("\\","$\\backslash$");
b.replace("%%$EURO_RULEZ$%%","\\$");
b.replace("#","\\#");
b.replace("%","\\%");
b.replace("&","\\&");
b.replace("~","\\~");
b.replace("_","\\_");
b.replace("{","\\{");
b.replace("}","\\}");
b.replace("[","{[}");
b.replace("]","{]}");
b.replace("*","{*}");
b.replace(" ","~");
b.replace(tab,"~~~~~~~~");
b.replace("^",""); // made some trouble...
#ifndef I_AM_A_SUCKER
/*
notice:
Microsoft is a trademark of
Microsoft Cooperation, USA
To Microsoft:
Be lucky that this is an open
source project :-)
*/
b.replace("Microsoft","Microsoft SUCKS");
b.replace("MICROSOFT","MICROSOFT SUCKS");
/*
Revenge for kerberos!
It's Judgement Day!
Isn't it fun to be a hacker?
SPASS MUSS SEIN (german wise saying)
*/
#endif
return b;
}
Bytevector Cover::getCover(int i){
Bytevector t=replaceVar(title,i);
Bytevector s=replaceVar(subtitle,i);
Bytevector sl=replaceVar(sidetext_left,i);
Bytevector sr=replaceVar(sidetext_right,i);
Bytevector b=replaceVar(backcover,i);
Bytevector front=resfront;
Bytevector back=resback;
Bytevector nr(i);
/* need alphas as tex-identifiers */
for (int x=0; x< nr.size; x++)
nr.data[x]='a'+(nr.data[x]-'0');
back.replace("%i",nr);
front.replace("%TITLE%",t);
front.replace("%SUBTITLE%",s);
if (sidetext_left.size>0) {
back.replace("%SIDETEXTLEFT%",sl);
} else {
back.replace("%SIDETEXTLEFT%",t);
}
if (sidetext_right.size>0) {
back.replace("%SIDETEXTRIGHT%",sr);
} else {
back.replace("%SIDETEXTRIGHT%",s);
}
b.replace("\n","\\\\");
back.replace("%BACKCOVERTEXT%",b);
return Bytevector ( front+back );
}
/*
public function, which assembles and returns
the latex code of the cd-cover
*/
Bytevector Cover::texcover()
{
resback=Stringlist(resbackC,resbackV).toBytevector();
resfront=Stringlist(resfrontC,resfrontV).toBytevector();
Bytevector cover(Stringlist(resheadC,resheadV).toBytevector());
for (int i=1; i<=count; i++) {
cover+=getCover(i);
}
cover+=Bytevector("\n\\end{document}\n");
return cover;
}
|