1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <processinginstruction.hxx>
24 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
29 CProcessingInstruction::CProcessingInstruction(
30 CDocument
const& rDocument
, ::osl::Mutex
const& rMutex
,
31 xmlNodePtr
const pNode
)
32 : CProcessingInstruction_Base(rDocument
, rMutex
,
33 NodeType_PROCESSING_INSTRUCTION_NODE
, pNode
)
37 void CProcessingInstruction::saxify(
38 const Reference
< XDocumentHandler
>& i_xHandler
) {
39 if (!i_xHandler
.is()) throw RuntimeException();
40 Reference
< XExtendedDocumentHandler
> xExtended(i_xHandler
, UNO_QUERY
);
42 xExtended
->processingInstruction(getTarget(), getData());
47 The content of this processing instruction.
50 CProcessingInstruction::getData() throw (RuntimeException
)
52 ::osl::MutexGuard
const g(m_rMutex
);
54 if (0 == m_aNodePtr
) {
58 char const*const pContent(
59 reinterpret_cast<char const*>(m_aNodePtr
->content
));
63 OUString
const ret(pContent
, strlen(pContent
), RTL_TEXTENCODING_UTF8
);
68 The target of this processing instruction.
71 CProcessingInstruction::getTarget() throw (RuntimeException
)
73 ::osl::MutexGuard
const g(m_rMutex
);
75 if (0 == m_aNodePtr
) {
79 char const*const pName(
80 reinterpret_cast<char const*>(m_aNodePtr
->name
));
84 OUString
const ret(pName
, strlen(pName
), RTL_TEXTENCODING_UTF8
);
89 The content of this processing instruction.
91 void SAL_CALL
CProcessingInstruction::setData(OUString
const& rData
)
92 throw (RuntimeException
, DOMException
)
94 ::osl::MutexGuard
const g(m_rMutex
);
96 if (0 == m_aNodePtr
) {
97 throw RuntimeException();
101 OUStringToOString(rData
, RTL_TEXTENCODING_UTF8
));
102 xmlChar
const*const pData(
103 reinterpret_cast<xmlChar
const*>(data
.getStr()) );
104 xmlFree(m_aNodePtr
->content
);
105 m_aNodePtr
->content
= xmlStrdup(pData
);
109 CProcessingInstruction::getNodeName() throw (RuntimeException
)
111 ::osl::MutexGuard
const g(m_rMutex
);
113 if (0 == m_aNodePtr
) {
117 sal_Char
const*const pName
=
118 reinterpret_cast<sal_Char
const*>(m_aNodePtr
->name
);
119 OUString
const ret(pName
, strlen(pName
), RTL_TEXTENCODING_UTF8
);
123 OUString SAL_CALL
CProcessingInstruction::getNodeValue()
124 throw (RuntimeException
)
130 CProcessingInstruction::setNodeValue(OUString
const& rNodeValue
)
131 throw (RuntimeException
, DOMException
)
133 return setData(rNodeValue
);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */