Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / sax / source / tools / fshelper.cxx
blobf5945d67a9c09cafcf77dde8b319d090390ad2e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <sal/log.hxx>
21 #include <sax/fshelper.hxx>
22 #include "fastserializer.hxx"
24 using namespace ::com::sun::star;
25 using namespace ::com::sun::star::uno;
27 namespace sax_fastparser {
29 FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
30 mpSerializer(new FastSaxSerializer(xOutputStream))
32 if( bWriteHeader )
33 startDocument();
36 void FastSerializerHelper::startDocument()
38 mpSerializer->startDocument();
41 void FastSerializerHelper::endDocument()
43 std::unique_ptr<FastSaxSerializer> xSerializer(std::move(mpSerializer));
44 xSerializer->endDocument();
47 FastSerializerHelper::~FastSerializerHelper()
49 if (mpSerializer)
51 assert(false && "call endDocument explicitly before dtor to avoid potential exceptions during dtor");
52 endDocument();
56 void FastSerializerHelper::startElement(sal_Int32 elementTokenId)
58 mpSerializer->startFastElement(elementTokenId);
60 void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const char* value)
62 mpSerializer->getTokenValueList().emplace_back(attribute, value);
64 void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const OString& value)
66 mpSerializer->getTokenValueList().emplace_back(attribute, value.getStr());
68 void FastSerializerHelper::singleElement(sal_Int32 elementTokenId)
70 mpSerializer->singleFastElement(elementTokenId);
73 void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
75 mpSerializer->endFastElement(elementTokenId);
78 void FastSerializerHelper::startElement(sal_Int32 elementTokenId, const rtl::Reference<FastAttributeList>& xAttrList)
80 assert(xAttrList);
81 mpSerializer->startFastElement(elementTokenId, xAttrList.get());
84 void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, const rtl::Reference<FastAttributeList>& xAttrList)
86 assert(xAttrList);
87 mpSerializer->singleFastElement(elementTokenId, xAttrList.get());
90 FastSerializerHelper* FastSerializerHelper::write(const char* value)
92 mpSerializer->write(value, -1);
93 return this;
96 FastSerializerHelper* FastSerializerHelper::write(const OString& value)
98 mpSerializer->write(value);
99 return this;
102 FastSerializerHelper* FastSerializerHelper::write(std::u16string_view value)
104 mpSerializer->write(value);
105 return this;
108 FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
110 mpSerializer->write(OString::number(value));
111 return this;
114 FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
116 mpSerializer->write(OString::number(value));
117 return this;
120 FastSerializerHelper* FastSerializerHelper::write(double value)
122 mpSerializer->write(value);
123 return this;
126 FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
128 mpSerializer->write(value, -1, true);
129 return this;
132 FastSerializerHelper* FastSerializerHelper::writeEscaped(std::u16string_view value)
134 if (!value.empty())
135 mpSerializer->write(value, true);
136 return this;
139 FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
141 mpSerializer->writeId(tokenId);
142 return this;
145 css::uno::Reference< css::io::XOutputStream > const & FastSerializerHelper::getOutputStream() const
147 return mpSerializer->getOutputStream();
150 void FastSerializerHelper::mark(
151 sal_Int32 const nTag, const Sequence<sal_Int32>& rOrder)
153 mpSerializer->mark(nTag, rOrder);
156 void FastSerializerHelper::mergeTopMarks(
157 sal_Int32 const nTag, MergeMarks const eMergeType)
159 mpSerializer->mergeTopMarks(nTag, eMergeType);
162 rtl::Reference<FastAttributeList> FastSerializerHelper::createAttrList()
164 return new FastAttributeList( nullptr );
167 void FastSerializerHelper::setAllowXEscape(bool bSet)
169 mpSerializer->setAllowXEscape(bSet);
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */