Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #include "txRtfHandler.h"
7 : #include "mozilla/Move.h"
8 :
9 : using mozilla::Move;
10 :
11 0 : txResultTreeFragment::txResultTreeFragment(nsAutoPtr<txResultBuffer>&& aBuffer)
12 : : txAExprResult(nullptr),
13 0 : mBuffer(Move(aBuffer))
14 : {
15 0 : }
16 :
17 0 : short txResultTreeFragment::getResultType()
18 : {
19 0 : return RESULT_TREE_FRAGMENT;
20 : }
21 :
22 : void
23 0 : txResultTreeFragment::stringValue(nsString& aResult)
24 : {
25 0 : if (!mBuffer) {
26 0 : return;
27 : }
28 :
29 0 : aResult.Append(mBuffer->mStringValue);
30 : }
31 :
32 : const nsString*
33 0 : txResultTreeFragment::stringValuePointer()
34 : {
35 0 : return mBuffer ? &mBuffer->mStringValue : nullptr;
36 : }
37 :
38 0 : bool txResultTreeFragment::booleanValue()
39 : {
40 0 : return true;
41 : }
42 :
43 0 : double txResultTreeFragment::numberValue()
44 : {
45 0 : if (!mBuffer) {
46 0 : return 0;
47 : }
48 :
49 0 : return txDouble::toDouble(mBuffer->mStringValue);
50 : }
51 :
52 0 : nsresult txResultTreeFragment::flushToHandler(txAXMLEventHandler* aHandler)
53 : {
54 0 : if (!mBuffer) {
55 0 : return NS_ERROR_FAILURE;
56 : }
57 :
58 0 : return mBuffer->flushToHandler(aHandler);
59 : }
60 :
61 : nsresult
62 0 : txRtfHandler::getAsRTF(txAExprResult** aResult)
63 : {
64 0 : *aResult = new txResultTreeFragment(Move(mBuffer));
65 0 : NS_ADDREF(*aResult);
66 0 : return NS_OK;
67 : }
68 :
69 : nsresult
70 0 : txRtfHandler::endDocument(nsresult aResult)
71 : {
72 0 : return NS_OK;
73 : }
74 :
75 : nsresult
76 0 : txRtfHandler::startDocument()
77 : {
78 0 : return NS_OK;
79 : }
|