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