summaryrefslogtreecommitdiffstats
path: root/sax/source/tools/fshelper.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sax/source/tools/fshelper.cxx
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sax/source/tools/fshelper.cxx')
-rw-r--r--sax/source/tools/fshelper.cxx155
1 files changed, 155 insertions, 0 deletions
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
new file mode 100644
index 000000000..a560e5bd1
--- /dev/null
+++ b/sax/source/tools/fshelper.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sax/fshelper.hxx>
+#include "fastserializer.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sax_fastparser {
+
+FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
+ mpSerializer(new FastSaxSerializer(xOutputStream))
+{
+ if( bWriteHeader )
+ mpSerializer->startDocument();
+}
+
+FastSerializerHelper::~FastSerializerHelper()
+{
+ mpSerializer->endDocument();
+ delete mpSerializer;
+}
+
+void FastSerializerHelper::startElement(sal_Int32 elementTokenId)
+{
+ mpSerializer->startFastElement(elementTokenId);
+}
+void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const char* value)
+{
+ mpSerializer->getTokenValueList().emplace_back(attribute, value);
+}
+void FastSerializerHelper::pushAttributeValue(sal_Int32 attribute, const OString& value)
+{
+ mpSerializer->getTokenValueList().emplace_back(attribute, value.getStr());
+}
+void FastSerializerHelper::singleElement(sal_Int32 elementTokenId)
+{
+ mpSerializer->singleFastElement(elementTokenId);
+}
+
+void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
+{
+ mpSerializer->endFastElement(elementTokenId);
+}
+
+void FastSerializerHelper::startElement(sal_Int32 elementTokenId, const rtl::Reference<FastAttributeList>& xAttrList)
+{
+ assert(xAttrList);
+ mpSerializer->startFastElement(elementTokenId, xAttrList.get());
+}
+
+void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, const rtl::Reference<FastAttributeList>& xAttrList)
+{
+ assert(xAttrList);
+ mpSerializer->singleFastElement(elementTokenId, xAttrList.get());
+}
+
+FastSerializerHelper* FastSerializerHelper::write(const char* value)
+{
+ mpSerializer->write(value, -1);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(const OString& value)
+{
+ mpSerializer->write(value);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(std::u16string_view value)
+{
+ mpSerializer->write(value);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
+{
+ mpSerializer->write(OString::number(value));
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
+{
+ mpSerializer->write(OString::number(value));
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::write(double value)
+{
+ mpSerializer->write(value);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
+{
+ mpSerializer->write(value, -1, true);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::writeEscaped(std::u16string_view value)
+{
+ if (!value.empty())
+ mpSerializer->write(value, true);
+ return this;
+}
+
+FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
+{
+ mpSerializer->writeId(tokenId);
+ return this;
+}
+
+css::uno::Reference< css::io::XOutputStream > const & FastSerializerHelper::getOutputStream() const
+{
+ return mpSerializer->getOutputStream();
+}
+
+void FastSerializerHelper::mark(
+ sal_Int32 const nTag, const Sequence<sal_Int32>& rOrder)
+{
+ mpSerializer->mark(nTag, rOrder);
+}
+
+void FastSerializerHelper::mergeTopMarks(
+ sal_Int32 const nTag, MergeMarks const eMergeType)
+{
+ mpSerializer->mergeTopMarks(nTag, eMergeType);
+}
+
+rtl::Reference<FastAttributeList> FastSerializerHelper::createAttrList()
+{
+ return new FastAttributeList( nullptr );
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */