Back to index

lightning-sunbird  0.9+nobinonly
nsHTMLEditorLog.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsHTMLEditorLog_h__
00039 #define nsHTMLEditorLog_h__
00040 
00041 #include "nsHTMLEditor.h"
00042 #include "nsIEditorLogging.h"
00043 #include "nsIFileStreams.h"
00044 #include "nsCOMPtr.h"
00045 
00046 class nsIFile;
00047 class nsEditorTxnLog;
00048 
00052 class nsHTMLEditorLog : public nsHTMLEditor,
00053                         public nsIEditorLogging
00054 {
00055 private:
00056 
00057   nsCOMPtr<nsIOutputStream>     mFileStream;
00058   nsEditorTxnLog       *mEditorTxnLog;
00059   PRInt32               mLocked;
00060   PRInt32               mDepth;
00061 
00062 public:
00063 
00064   // Interfaces for AddRef, Release, and QueryInterface.
00065   NS_DECL_ISUPPORTS_INHERITED
00066 
00067            nsHTMLEditorLog();
00068   virtual ~nsHTMLEditorLog();
00069 
00070   /* nsIHTMLEditor method implementations. */
00071   NS_IMETHOD SetInlineProperty(nsIAtom *aProperty, 
00072                             const nsAString & aAttribute, 
00073                             const nsAString & aValue);
00074   NS_IMETHOD SetParagraphFormat(const nsAString& aParagraphFormat);
00075   NS_IMETHOD RemoveInlineProperty(nsIAtom *aProperty, const nsAString& aAttribute);
00076   NS_IMETHOD DeleteSelection(nsIEditor::EDirection aAction);
00077   NS_IMETHOD InsertText(const nsAString& aStringToInsert);
00078   NS_IMETHOD InsertLineBreak();
00079   NS_IMETHOD Undo(PRUint32 aCount);
00080   NS_IMETHOD Redo(PRUint32 aCount);
00081   NS_IMETHOD BeginTransaction();
00082   NS_IMETHOD EndTransaction();
00083   NS_IMETHOD SelectAll();
00084   NS_IMETHOD BeginningOfDocument();
00085   NS_IMETHOD EndOfDocument();
00086 
00087   NS_IMETHOD Cut();
00088   NS_IMETHOD Copy();
00089   NS_IMETHOD Paste(PRInt32 aSelectionType);
00090   NS_IMETHOD PasteAsQuotation(PRInt32 aSelectionType);
00091   NS_IMETHOD PasteAsPlaintextQuotation(PRInt32 aSelectionType);
00092   NS_IMETHOD PasteAsCitedQuotation(const nsAString& aCitation,
00093                                    PRInt32 aSelectionType);
00094   NS_IMETHOD InsertAsQuotation(const nsAString& aQuotedText, nsIDOMNode** aNodeInserted);
00095   NS_IMETHOD InsertAsPlaintextQuotation(const nsAString& aQuotedText,
00096                                         PRBool aAddCites,
00097                                         nsIDOMNode** aNodeInserted);
00098   NS_IMETHOD InsertAsCitedQuotation(const nsAString& aQuotedText, const nsAString& aCitation, 
00099                                     PRBool aInsertHTML,
00100                                     nsIDOMNode** aNodeInserted);
00101 
00102   NS_IMETHOD SetDocumentTitle(const nsAString& aTitle);
00103 
00104   NS_IMETHOD SetBackgroundColor(const nsAString& aColor);
00105   NS_IMETHOD SetBodyAttribute(const nsAString& aAttr, const nsAString& aValue);
00106   NS_IMETHOD MakeOrChangeList(const nsAString& aListType, PRBool entireList, const nsAString& aBulletType);
00107   NS_IMETHOD Indent(const nsAString& aIndent);
00108   NS_IMETHOD Align(const nsAString& aAlign);
00109   NS_IMETHOD InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSelection);
00110   NS_IMETHOD InsertLinkAroundSelection(nsIDOMElement* aAnchorElement);
00111   
00112   /* Table Editing */
00113   NS_IMETHOD InsertTableCell(PRInt32 aNumber, PRBool aAfter);
00114   NS_IMETHOD InsertTableColumn(PRInt32 aNumber, PRBool aAfter);
00115   NS_IMETHOD InsertTableRow(PRInt32 aNumber, PRBool aAfter);
00116   NS_IMETHOD DeleteTable();
00117   NS_IMETHOD DeleteTableCell(PRInt32 aNumber);
00118   NS_IMETHOD DeleteTableCellContents();
00119   NS_IMETHOD DeleteTableColumn(PRInt32 aNumber);
00120   NS_IMETHOD DeleteTableRow(PRInt32 aNumber);
00121   NS_IMETHOD JoinTableCells(PRBool aMergeNonContiguousContents);
00122   NS_IMETHOD SplitTableCell();
00123   NS_IMETHOD NormalizeTable(nsIDOMElement *aTable);
00124   NS_IMETHOD SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElement **aNewCell);
00125 
00126   NS_IMETHOD StartLogging(nsIFile *aLogFile);
00127   NS_IMETHOD StopLogging();
00128 
00129   /* nsHTMLEditorLog public methods. */
00130   nsresult Write(const char *aBuffer);
00131   nsresult WriteInt(PRInt32 aInt);
00132   nsresult Flush();
00133   nsresult PrintUnicode(const nsAString &aString);
00134   nsresult PrintSelection();
00135   nsresult PrintNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
00136   nsresult PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth);
00137   nsresult PrintTextNode(nsIDOMNode *aNode, PRInt32 aDepth);
00138   nsresult PrintAttributeNode(nsIDOMNode *aNode, PRInt32 aDepth=0);
00139   nsresult PrintNodeChildren(nsIDOMNode *aNode, PRInt32 aDepth=0);
00140   nsresult GetNodeTreeOffsets(nsIDOMNode *aNode, PRInt32 **aResult, PRInt32 *aLength);
00141   nsresult Lock();
00142   nsresult Unlock();
00143 };
00144 
00145 class nsAutoHTMLEditorLogLock
00146 {
00147   nsHTMLEditorLog *mLog;
00148 
00149 public:
00150 
00151   nsAutoHTMLEditorLogLock(nsHTMLEditorLog *aLog)
00152   {
00153     mLog = aLog;
00154 
00155     if (mLog)
00156       mLog->Lock();
00157   }
00158 
00159   ~nsAutoHTMLEditorLogLock()
00160   {
00161     if (mLog)
00162       mLog->Unlock();
00163   }
00164 };
00165 
00166 #endif // nsHTMLEditorLog_h__