Bump version to 4.1-6
[LibreOffice.git] / writerfilter / source / resourcemodel / Protocol.cxx
blobc85a75826e054e61416b530303c4798ab7163c27
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 #ifdef DEBUG_PROTOCOL
21 #include <stdio.h>
22 #include <rtl/ustrbuf.hxx>
23 #include <resourcemodel/Protocol.hxx>
24 #include <resourcemodel/WW8ResourceModel.hxx>
25 #include <resourcemodel/QNameToString.hxx>
26 namespace writerfilter
30 StreamProtocol
33 StreamProtocol::StreamProtocol(Stream * pStream,
34 TagLogger::Pointer_t pTagLogger)
35 : m_pStream(pStream), m_pTagLogger(pTagLogger)
39 StreamProtocol::~StreamProtocol()
43 void StreamProtocol::startSectionGroup()
45 m_pTagLogger->element("protocol-startSectionGroup");
46 m_pStream->startSectionGroup();
49 void StreamProtocol::endSectionGroup()
51 m_pTagLogger->element("protocol-endSectionGroup");
52 m_pStream->endSectionGroup();
55 void StreamProtocol::startParagraphGroup()
57 m_pTagLogger->element("protocol-startParagraphGroup");
58 m_pStream->startParagraphGroup();
61 void StreamProtocol::endParagraphGroup()
63 m_pTagLogger->element("protocol-endParagraphGroup");
64 m_pStream->endParagraphGroup();
67 void StreamProtocol::startCharacterGroup()
69 m_pTagLogger->element("protocol-startCharacterGroup");
70 m_pStream->startCharacterGroup();
73 void StreamProtocol::endCharacterGroup()
75 m_pTagLogger->element("protocol-endCharacterGroup");
76 m_pStream->endCharacterGroup();
79 void StreamProtocol::text(const sal_uInt8 * data, size_t len)
81 OUString sText((const sal_Char*) data, len,
82 RTL_TEXTENCODING_MS_1252);
83 m_pTagLogger->startElement("protocol-text");
84 m_pTagLogger->chars(sText);
85 m_pTagLogger->endElement();
87 m_pStream->text(data, len);
90 void StreamProtocol::utext(const sal_uInt8 * data, size_t len)
92 OUString sText;
93 OUStringBuffer aBuffer = OUStringBuffer(len);
94 aBuffer.append( (const sal_Unicode *) data, len);
95 sText = aBuffer.makeStringAndClear();
97 m_pTagLogger->startElement("protocol-utext");
98 m_pTagLogger->chars(sText);
99 m_pTagLogger->endElement();
101 m_pStream->utext(data, len);
104 void StreamProtocol::props(writerfilter::Reference<Properties>::Pointer_t ref)
106 m_pTagLogger->startElement("protocol-props");
107 m_pStream->props(ref);
108 m_pTagLogger->endElement();
111 void StreamProtocol::table(Id name,
112 writerfilter::Reference<Table>::Pointer_t ref)
114 m_pTagLogger->startElement("protocol-table");
115 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
116 m_pStream->table(name, ref);
117 m_pTagLogger->endElement();
120 void StreamProtocol::substream(Id name,
121 writerfilter::Reference<Stream>::Pointer_t ref)
123 m_pTagLogger->startElement("protocol-substream");
124 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
126 m_pStream->substream(name, ref);
127 m_pTagLogger->endElement();
130 void StreamProtocol::info(const string & rInfo)
132 m_pStream->info(rInfo);
135 void StreamProtocol::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
137 m_pTagLogger->element("protocol-startShape");
139 m_pStream->startShape(xShape);
142 void StreamProtocol::endShape()
144 m_pTagLogger->element("protocol-endShape");
146 m_pStream->endShape();
150 PropertiesProtocol
153 PropertiesProtocol::PropertiesProtocol(Properties * pProperties,
154 TagLogger::Pointer_t pTagLogger)
155 : m_pProperties(pProperties), m_pTagLogger(pTagLogger)
159 PropertiesProtocol::~PropertiesProtocol()
163 void PropertiesProtocol::attribute(Id name, Value & val)
165 m_pTagLogger->startElement("protocol-attribute");
166 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
167 m_pTagLogger->attribute("value", val.toString());
168 m_pProperties->attribute(name, val);
169 m_pTagLogger->endElement();
172 void PropertiesProtocol::sprm(Sprm & _sprm)
174 m_pTagLogger->startElement("protocol-sprm");
175 static char sBuffer[256];
176 snprintf(sBuffer, sizeof(sBuffer), "%04" SAL_PRIxUINT32, _sprm.getId());
177 m_pTagLogger->attribute("id", sBuffer);
178 m_pTagLogger->attribute("name", _sprm.getName());
179 m_pTagLogger->chars(_sprm.toString());
180 m_pProperties->sprm(_sprm);
181 m_pTagLogger->endElement();
185 TableProtocol
188 TableProtocol::TableProtocol(Table * pTable, TagLogger::Pointer_t pTagLogger)
189 : m_pTable(pTable), m_pTagLogger(pTagLogger)
193 TableProtocol::~TableProtocol()
197 void TableProtocol::entry(int pos,
198 writerfilter::Reference<Properties>::Pointer_t ref)
200 m_pTagLogger->startElement("protocol-entry");
201 m_pTagLogger->attribute("pos", pos);
202 m_pTable->entry(pos, ref);
203 m_pTagLogger->endElement();
207 #endif // DEBUG_PROTOCOL
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */