filters
DocumentElement.cxx00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "DocumentElement.hxx"
00030 #include "DocumentHandler.hxx"
00031 #include "FilterInternal.hxx"
00032 #include <string.h>
00033
00034 #define ASCII_SPACE 0x0020
00035
00036 void TagElement::print() const
00037 {
00038 WRITER_DEBUG_MSG(("%s\n", msTagName.cstr()));
00039 }
00040
00041 void TagOpenElement::write(DocumentHandler &xHandler) const
00042 {
00043 xHandler.startElement(getTagName().cstr(), maAttrList);
00044 }
00045
00046 void TagOpenElement::print() const
00047 {
00048 TagElement::print();
00049 }
00050
00051 void TagOpenElement::addAttribute(const char *szAttributeName, const WPXString &sAttributeValue)
00052 {
00053 maAttrList.insert(szAttributeName, sAttributeValue);
00054 }
00055
00056 void TagCloseElement::write(DocumentHandler &xHandler) const
00057 {
00058 WRITER_DEBUG_MSG(("TagCloseElement: write (%s)\n", getTagName().cstr()));
00059
00060 xHandler.endElement(getTagName().cstr());
00061 }
00062
00063 void CharDataElement::write(DocumentHandler &xHandler) const
00064 {
00065 WRITER_DEBUG_MSG(("TextElement: write\n"));
00066 xHandler.characters(msData);
00067 }
00068
00069 TextElement::TextElement(const WPXString & sTextBuf) :
00070 msTextBuf(sTextBuf, false)
00071 {
00072 }
00073
00074
00075
00076 void TextElement::write(DocumentHandler &xHandler) const
00077 {
00078 WPXPropertyList xBlankAttrList;
00079
00080 WPXString sTemp;
00081
00082 int iNumConsecutiveSpaces = 0;
00083 WPXString::Iter i(msTextBuf);
00084 for (i.rewind(); i.next();)
00085 {
00086 if (*(i()) == ASCII_SPACE)
00087 iNumConsecutiveSpaces++;
00088 else
00089 iNumConsecutiveSpaces = 0;
00090
00091 if (iNumConsecutiveSpaces > 1) {
00092 if (sTemp.len() > 0) {
00093 xHandler.characters(sTemp);
00094 sTemp.clear();
00095 }
00096 xHandler.startElement("text:s", xBlankAttrList);
00097 xHandler.endElement("text:s");
00098 }
00099 else {
00100 sTemp.append(i());
00101 }
00102 }
00103 xHandler.characters(sTemp);
00104 }
|