/*************************************************************************** bbcodegenerator.cpp - description ------------------- copyright : (C) 2011 by Andre Simon email : a.simon@mailbox.org ***************************************************************************/ /* This file is part of ANSIFilter. ANSIFilter 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 3 of the License, or (at your option) any later version. ANSIFilter 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 ANSIFilter. If not, see . */ #include #include #include #include "bbcodegenerator.h" #include "version.h" namespace ansifilter { BBCodeGenerator::BBCodeGenerator (): CodeGenerator(BBCODE), fileSuffix(".bbcode") { newLineTag="\n"; spacer=" "; } string BBCodeGenerator::getOpenTag() { ostringstream fmtStream; if (elementStyle.isFgColorSet()) { fmtStream << "[color=#" << elementStyle.getFgColour().getRed(HTML) << elementStyle.getFgColour().getGreen(HTML) << elementStyle.getFgColour().getBlue(HTML) << "]"; } if ( elementStyle.isBold() ) fmtStream << "[b]"; if ( elementStyle.isItalic() ) fmtStream << "[i]"; if ( elementStyle.isUnderline() ) fmtStream << "[u]"; string fmt = fmtStream.str(); tagIsOpen = fmt.size()>0; if (tagIsOpen) { ostringstream spanTag; spanTag<0x1f ) { // printable? return string( 1, c ); } else { return ""; } } return ""; } }