[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Fri Sep 16 14:26:25 UTC 2005
SVN commit 461214 by okellogg:
CCBUG:112292 - fixEPS(): Looking again at Comment #2,
> DSC Warning
> At line 2:
> %%BoundingBox: 35.: 23.8571 559 817.714
There's this strange colon at "35." so substitute
colons for '0'. Alan, could you try again? Thanks.
M +31 -22 umlview.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.cpp #461213:461214
@@ -1382,31 +1382,40 @@
void UMLView::fixEPS(const QString &filename, QRect rect) {
// now open the file and make a correct eps out of it
QFile epsfile(filename);
- QString fileContent;
- if (epsfile.open(IO_ReadOnly )) {
- // read
- QTextStream ts(&epsfile);
- fileContent = ts.read();
- epsfile.close();
+ if (! epsfile.open(IO_ReadOnly)) {
+ return;
+ }
+ // read
+ QTextStream ts(&epsfile);
+ QString fileContent = ts.read();
+ epsfile.close();
- // write new content to file
- if (epsfile.open(IO_WriteOnly | IO_Truncate)) {
- // read information
- QRegExp rx("%%BoundingBox:\\s*(-?[\\d\\.]+)\\s*(-?[\\d\\.]+)\\s*(-?[\\d\\.]+)\\s*(-?[\\d\\.]+)");
- const int pos = rx.search(fileContent);
- const int left = (int)rx.cap(1).toFloat();
- const int right = left + rect.width();
- const int top = (int)rx.cap(4).toFloat();
- const int bottom = top - rect.height();
+ // read information
+ QRegExp rx("%%BoundingBox:\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)\\s*(-?[\\d\\.:]+)");
+ const int pos = rx.search(fileContent);
+ if (pos < 0) {
+ kdError() << "UMLView::fixEPS(" << filename
+ << "): cannot find %%BoundingBox" << endl;
+ return;
+ }
- // modify content
- fileContent.replace(pos,rx.cap(0).length(),
- QString("%%BoundingBox: %1 %2 %3 %4").arg(left).arg(bottom).arg(right).arg(top));
+ // write new content to file
+ if (! epsfile.open(IO_WriteOnly | IO_Truncate)) {
+ kdError() << "UMLView::fixEPS(" << filename
+ << "): cannot open file for writing" << endl;
+ return;
+ }
+ const int left = (int)rx.cap(1).replace(':', '0').toFloat();
+ const int right = left + rect.width();
+ const int top = (int)rx.cap(4).replace(':', '0').toFloat();
+ const int bottom = top - rect.height();
- ts << fileContent;
- epsfile.close();
- }
- }
+ // modify content
+ fileContent.replace(pos,rx.cap(0).length(),
+ QString("%%BoundingBox: %1 %2 %3 %4").arg(left).arg(bottom).arg(right).arg(top));
+
+ ts << fileContent;
+ epsfile.close();
}
void UMLView::printToFile(const QString &filename,bool isEPS) {
More information about the umbrello-devel
mailing list