From kde-commits Fri Dec 31 19:42:15 2004 From: John Tapsell Date: Fri, 31 Dec 2004 19:42:15 +0000 To: kde-commits Subject: kdelibs/kate/part Message-Id: <20041231194215.1FB3B18869 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=110452214128468 CVS commit by johnflux: Optimization - Over halve the size of an "export to html" file (which also reduces the size when copying to clipboard) M +0 -1 katedocument.cpp 1.781 M +10 -6 katetextline.cpp 1.89 --- kdelibs/kate/part/katedocument.cpp #1.780:1.781 @@ -662,5 +662,4 @@ void KateDocument::textAsHtmlStream ( ui } } - (*ts) << ""; // i'm guaranteed a span is started (i started one at the beginning of the output). (*ts) << ""; } --- kdelibs/kate/part/katetextline.cpp #1.88:1.89 @@ -404,4 +404,5 @@ char *KateTextLine::restore (char *buf) void KateTextLine::stringAsHtml(uint startCol, uint length, KateRenderer *renderer, QTextStream *outputStream) const { + if(length == 0) return; // some variables : bool previousCharacterWasBold = false; @@ -412,5 +413,6 @@ void KateTextLine::stringAsHtml(uint sta bool needToReinitializeTags = false; QColor previousCharacterColor(0,0,0); // default color of HTML characters is black - (*outputStream) << ""; + QColor blackColor(0,0,0); +// (*outputStream) << ""; @@ -434,4 +436,5 @@ void KateTextLine::stringAsHtml(uint sta // close the previous font tag : + if(previousCharacterColor != blackColor) (*outputStream) << ""; // let's read that color : @@ -439,4 +442,5 @@ void KateTextLine::stringAsHtml(uint sta // getting the red, green, blue values of the color : charAttributes->textColor().rgb(&red, &green, &blue); + if(!(red == 0 && green == 0 && blue == 0)) { (*outputStream) << ""; + } // we need to reinitialize the bold/italic status, since we closed all the tags needToReinitializeTags = true; @@ -483,7 +488,6 @@ void KateTextLine::stringAsHtml(uint sta (*outputStream) << ""; - // HTML document end : - (*outputStream) << ""; // i'm guaranteed a span is started (i started one at the beginning of the output). - + if(previousCharacterColor != blackColor) + (*outputStream) << ""; }