Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "TransformerBase.hxx"
21 : #include "PersMixedContentTContext.hxx"
22 :
23 : #include <osl/diagnose.h>
24 :
25 : using namespace ::com::sun::star::uno;
26 : using namespace ::com::sun::star::xml::sax;
27 :
28 : class XMLPersTextTContext_Impl : public XMLTransformerContext
29 : {
30 : OUString m_aCharacters;
31 :
32 : public:
33 : TYPEINFO_OVERRIDE();
34 :
35 : XMLPersTextTContext_Impl( XMLTransformerBase& rTransformer,
36 : const OUString& rChars );
37 : virtual ~XMLPersTextTContext_Impl();
38 :
39 : virtual XMLTransformerContext *CreateChildContext( sal_uInt16 nPrefix,
40 : const OUString& rLocalName,
41 : const OUString& rQName,
42 : const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
43 : virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
44 : virtual void EndElement() SAL_OVERRIDE;
45 : virtual void Characters( const OUString& rChars ) SAL_OVERRIDE;
46 :
47 : virtual bool IsPersistent() const SAL_OVERRIDE;
48 : virtual void Export() SAL_OVERRIDE;
49 : };
50 :
51 0 : TYPEINIT1( XMLPersTextTContext_Impl, XMLTransformerContext );
52 :
53 0 : XMLPersTextTContext_Impl::XMLPersTextTContext_Impl(
54 : XMLTransformerBase& rImp,
55 : const OUString& rChars ) :
56 : XMLTransformerContext( rImp, OUString() ),
57 0 : m_aCharacters( rChars )
58 : {
59 0 : }
60 :
61 0 : XMLPersTextTContext_Impl::~XMLPersTextTContext_Impl()
62 : {
63 0 : }
64 :
65 0 : XMLTransformerContext *XMLPersTextTContext_Impl::CreateChildContext(
66 : sal_uInt16,
67 : const OUString&,
68 : const OUString&,
69 : const Reference< XAttributeList >& )
70 : {
71 : OSL_ENSURE( false, "illegal call to CreateChildContext" );
72 0 : return 0;
73 : }
74 :
75 0 : void XMLPersTextTContext_Impl::StartElement(
76 : const Reference< XAttributeList >& )
77 : {
78 : OSL_ENSURE( false, "illegal call to StartElement" );
79 0 : }
80 :
81 0 : void XMLPersTextTContext_Impl::EndElement()
82 : {
83 : OSL_ENSURE( false, "illegal call to EndElement" );
84 0 : }
85 :
86 0 : bool XMLPersTextTContext_Impl::IsPersistent() const
87 : {
88 0 : return true;
89 : }
90 :
91 0 : void XMLPersTextTContext_Impl::Characters( const OUString& rChars )
92 : {
93 0 : m_aCharacters += rChars;
94 0 : }
95 :
96 0 : void XMLPersTextTContext_Impl::Export()
97 : {
98 0 : GetTransformer().GetDocHandler()->characters( m_aCharacters );
99 0 : }
100 :
101 0 : TYPEINIT1( XMLPersMixedContentTContext, XMLPersElemContentTContext );
102 :
103 139 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
104 : XMLTransformerBase& rImp,
105 : const OUString& rQName ) :
106 139 : XMLPersElemContentTContext( rImp, rQName )
107 : {
108 139 : }
109 :
110 50 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
111 : XMLTransformerBase& rImp,
112 : const OUString& rQName,
113 : sal_uInt16 nActionMap ) :
114 50 : XMLPersElemContentTContext( rImp, rQName, nActionMap )
115 : {
116 50 : }
117 :
118 0 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
119 : XMLTransformerBase& rImp,
120 : const OUString& rQName,
121 : sal_uInt16 nPrefix,
122 : ::xmloff::token::XMLTokenEnum eToken ) :
123 0 : XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken )
124 : {
125 0 : }
126 :
127 2 : XMLPersMixedContentTContext::XMLPersMixedContentTContext(
128 : XMLTransformerBase& rImp,
129 : const OUString& rQName,
130 : sal_uInt16 nPrefix,
131 : ::xmloff::token::XMLTokenEnum eToken,
132 : sal_uInt16 nActionMap ) :
133 2 : XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken, nActionMap )
134 : {
135 2 : }
136 :
137 382 : XMLPersMixedContentTContext::~XMLPersMixedContentTContext()
138 : {
139 382 : }
140 :
141 0 : void XMLPersMixedContentTContext::Characters( const OUString& rChars )
142 : {
143 0 : AddContent( new XMLPersTextTContext_Impl( GetTransformer(), rChars ) );
144 0 : }
145 :
146 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|