michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * nsIContentSerializer implementation that can be used with an michael@0: * nsIDocumentEncoder to convert an XML DOM to an XML string that michael@0: * could be parsed into more or less the original DOM. michael@0: */ michael@0: michael@0: #ifndef nsXMLContentSerializer_h__ michael@0: #define nsXMLContentSerializer_h__ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIContentSerializer.h" michael@0: #include "nsISupportsUtils.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: michael@0: #define kIndentStr NS_LITERAL_STRING(" ") michael@0: #define kEndTag NS_LITERAL_STRING(" mNameSpaceStack; michael@0: michael@0: // nsIDocumentEncoder flags michael@0: uint32_t mFlags; michael@0: michael@0: // characters to use for line break michael@0: nsString mLineBreak; michael@0: michael@0: // The charset that was passed to Init() michael@0: nsCString mCharset; michael@0: michael@0: // current column position on the current line michael@0: uint32_t mColPos; michael@0: michael@0: // true = pretty formating should be done (OutputFormated flag) michael@0: bool mDoFormat; michael@0: michael@0: // true = no formatting,(OutputRaw flag) michael@0: // no newline convertion and no rewrap long lines even if OutputWrap is set. michael@0: bool mDoRaw; michael@0: michael@0: // true = wrapping should be done (OutputWrap flag) michael@0: bool mDoWrap; michael@0: michael@0: // number of maximum column in a line, in the wrap mode michael@0: uint32_t mMaxColumn; michael@0: michael@0: // current indent value michael@0: nsString mIndent; michael@0: michael@0: // this is the indentation level after the indentation reached michael@0: // the maximum length of indentation michael@0: int32_t mIndentOverflow; michael@0: michael@0: // says if the indentation has been already added on the current line michael@0: bool mIsIndentationAddedOnCurrentLine; michael@0: michael@0: // the string which is currently added is in an attribute michael@0: bool mInAttribute; michael@0: michael@0: // true = a newline character should be added. It's only michael@0: // useful when serializing root nodes. see MaybeAddNewlineForRootNode and michael@0: // MaybeFlagNewlineForRootNode michael@0: bool mAddNewlineForRootNode; michael@0: michael@0: // Indicates that a space will be added if and only if content is michael@0: // continued on the same line while serializing source. Otherwise, michael@0: // the newline character acts as the whitespace and no space is needed. michael@0: // used when mDoFormat = true michael@0: bool mAddSpace; michael@0: michael@0: // says that if the next string to add contains a newline character at the michael@0: // begining, then this newline character should be ignored, because a michael@0: // such character has already been added into the output string michael@0: bool mMayIgnoreLineBreakSequence; michael@0: michael@0: bool mBodyOnly; michael@0: int32_t mInBody; michael@0: michael@0: // number of nested elements which have preformated content michael@0: int32_t mPreLevel; michael@0: }; michael@0: michael@0: nsresult michael@0: NS_NewXMLContentSerializer(nsIContentSerializer** aSerializer); michael@0: michael@0: #endif