2001-09-25 22:53:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:21:17 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1999-01-21 01:51:09 +00:00
|
|
|
*
|
2004-04-18 14:21:17 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1999-01-21 01:51:09 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1999-01-21 01:51:09 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:21:17 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-25 22:53:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:43:54 +00:00
|
|
|
*
|
2001-09-25 22:53:13 +00:00
|
|
|
* Contributor(s):
|
2002-01-09 13:51:37 +00:00
|
|
|
* Daniel Glazman <glazman@netscape.com>
|
2001-09-25 22:53:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:21:17 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-25 22:53:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:21:17 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-25 22:53:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:21:17 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-25 22:53:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-01-21 01:51:09 +00:00
|
|
|
|
|
|
|
#include "TransactionFactory.h"
|
|
|
|
// transactions this factory knows how to build
|
1999-01-22 15:40:31 +00:00
|
|
|
#include "EditAggregateTxn.h"
|
1999-03-15 00:57:32 +00:00
|
|
|
#include "PlaceholderTxn.h"
|
1999-01-21 01:51:09 +00:00
|
|
|
#include "InsertTextTxn.h"
|
|
|
|
#include "DeleteTextTxn.h"
|
|
|
|
#include "CreateElementTxn.h"
|
1999-02-24 17:24:37 +00:00
|
|
|
#include "InsertElementTxn.h"
|
1999-01-21 01:51:09 +00:00
|
|
|
#include "DeleteElementTxn.h"
|
|
|
|
#include "DeleteRangeTxn.h"
|
|
|
|
#include "ChangeAttributeTxn.h"
|
|
|
|
#include "SplitElementTxn.h"
|
|
|
|
#include "JoinElementTxn.h"
|
1999-07-02 03:57:50 +00:00
|
|
|
#include "nsStyleSheetTxns.h"
|
1999-06-29 20:31:22 +00:00
|
|
|
#include "IMETextTxn.h"
|
2001-05-11 13:58:31 +00:00
|
|
|
|
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
2001-02-26 22:02:58 +00:00
|
|
|
#include "SetDocTitleTxn.h"
|
2002-01-09 13:51:37 +00:00
|
|
|
#include "ChangeCSSInlineStyleTxn.h"
|
2001-05-11 13:58:31 +00:00
|
|
|
#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY
|
1999-07-02 03:57:50 +00:00
|
|
|
|
1999-01-21 01:51:09 +00:00
|
|
|
TransactionFactory::TransactionFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TransactionFactory::~TransactionFactory()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
TransactionFactory::GetNewTransaction(REFNSIID aTxnType, EditTxn **aResult)
|
|
|
|
{
|
|
|
|
nsresult result = NS_OK;
|
|
|
|
*aResult = nsnull;
|
1999-07-15 19:13:46 +00:00
|
|
|
if (aTxnType.Equals(InsertTextTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new InsertTextTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(DeleteTextTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new DeleteTextTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(CreateElementTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new CreateElementTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(InsertElementTxn::GetCID()))
|
1999-02-24 17:24:37 +00:00
|
|
|
*aResult = new InsertElementTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(DeleteElementTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new DeleteElementTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(DeleteRangeTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new DeleteRangeTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(ChangeAttributeTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new ChangeAttributeTxn();
|
2002-01-09 13:51:37 +00:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
|
|
|
else if (aTxnType.Equals(ChangeCSSInlineStyleTxn::GetCID()))
|
|
|
|
*aResult = new ChangeCSSInlineStyleTxn();
|
|
|
|
#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(SplitElementTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new SplitElementTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(JoinElementTxn::GetCID()))
|
1999-01-21 01:51:09 +00:00
|
|
|
*aResult = new JoinElementTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(EditAggregateTxn::GetCID()))
|
1999-01-22 15:40:31 +00:00
|
|
|
*aResult = new EditAggregateTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(IMETextTxn::GetCID()))
|
1999-06-29 20:31:22 +00:00
|
|
|
*aResult = new IMETextTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(AddStyleSheetTxn::GetCID()))
|
1999-07-02 03:57:50 +00:00
|
|
|
*aResult = new AddStyleSheetTxn();
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(RemoveStyleSheetTxn::GetCID()))
|
1999-07-02 03:57:50 +00:00
|
|
|
*aResult = new RemoveStyleSheetTxn();
|
2001-05-11 13:58:31 +00:00
|
|
|
#ifndef MOZILLA_PLAINTEXT_EDITOR_ONLY
|
2001-02-26 22:02:58 +00:00
|
|
|
else if (aTxnType.Equals(SetDocTitleTxn::GetCID()))
|
|
|
|
*aResult = new SetDocTitleTxn();
|
2001-05-11 13:58:31 +00:00
|
|
|
#endif // MOZILLA_PLAINTEXT_EDITOR_ONLY
|
1999-07-15 19:13:46 +00:00
|
|
|
else if (aTxnType.Equals(PlaceholderTxn::GetCID()))
|
1999-03-15 00:57:32 +00:00
|
|
|
*aResult = new PlaceholderTxn();
|
1999-02-15 18:25:30 +00:00
|
|
|
else
|
|
|
|
result = NS_ERROR_NO_INTERFACE;
|
1999-01-21 01:51:09 +00:00
|
|
|
|
2003-06-30 14:57:59 +00:00
|
|
|
if (NS_SUCCEEDED(result) && !*aResult)
|
1999-02-15 18:25:30 +00:00
|
|
|
result = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(result))
|
|
|
|
NS_ADDREF(*aResult);
|
1999-01-21 01:51:09 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|