1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifdef DEBUG
25 #include <stdio.h>
26 #include <rtl/ustrbuf.hxx>
27 #include <resourcemodel/Protocol.hxx>
28 #include <resourcemodel/WW8ResourceModel.hxx>
29 #include <resourcemodel/QNameToString.hxx>
30 namespace writerfilter
31 {
32
33 /*
34 StreamProtocol
35 */
36
StreamProtocol(Stream * pStream,TagLogger::Pointer_t pTagLogger)37 StreamProtocol::StreamProtocol(Stream * pStream,
38 TagLogger::Pointer_t pTagLogger)
39 : m_pStream(pStream), m_pTagLogger(pTagLogger)
40 {
41 }
42
~StreamProtocol()43 StreamProtocol::~StreamProtocol()
44 {
45 }
46
startSectionGroup()47 void StreamProtocol::startSectionGroup()
48 {
49 m_pTagLogger->element("protocol-startSectionGroup");
50 m_pStream->startSectionGroup();
51 }
52
endSectionGroup()53 void StreamProtocol::endSectionGroup()
54 {
55 m_pTagLogger->element("protocol-endSectionGroup");
56 m_pStream->endSectionGroup();
57 }
58
startParagraphGroup()59 void StreamProtocol::startParagraphGroup()
60 {
61 m_pTagLogger->element("protocol-startParagraphGroup");
62 m_pStream->startParagraphGroup();
63 }
64
endParagraphGroup()65 void StreamProtocol::endParagraphGroup()
66 {
67 m_pTagLogger->element("protocol-endParagraphGroup");
68 m_pStream->endParagraphGroup();
69 }
70
startCharacterGroup()71 void StreamProtocol::startCharacterGroup()
72 {
73 m_pTagLogger->element("protocol-startCharacterGroup");
74 m_pStream->startCharacterGroup();
75 }
76
endCharacterGroup()77 void StreamProtocol::endCharacterGroup()
78 {
79 m_pTagLogger->element("protocol-endCharacterGroup");
80 m_pStream->endCharacterGroup();
81 }
82
text(const sal_uInt8 * data,size_t len)83 void StreamProtocol::text(const sal_uInt8 * data, size_t len)
84 {
85 ::rtl::OUString sText((const sal_Char*) data, len,
86 RTL_TEXTENCODING_MS_1252);
87 m_pTagLogger->startElement("protocol-text");
88 m_pTagLogger->chars(sText);
89 m_pTagLogger->endElement("protocol-text");
90
91 m_pStream->text(data, len);
92 }
93
utext(const sal_uInt8 * data,size_t len)94 void StreamProtocol::utext(const sal_uInt8 * data, size_t len)
95 {
96 ::rtl::OUString sText;
97 ::rtl::OUStringBuffer aBuffer = ::rtl::OUStringBuffer(len);
98 aBuffer.append( (const sal_Unicode *) data, len);
99 sText = aBuffer.makeStringAndClear();
100
101 m_pTagLogger->startElement("protocol-utext");
102 m_pTagLogger->chars(sText);
103 m_pTagLogger->endElement("protocol-utext");
104
105 m_pStream->utext(data, len);
106 }
107
props(writerfilter::Reference<Properties>::Pointer_t ref)108 void StreamProtocol::props(writerfilter::Reference<Properties>::Pointer_t ref)
109 {
110 m_pTagLogger->startElement("protocol-props");
111 m_pStream->props(ref);
112 m_pTagLogger->endElement("protocol-props");
113 }
114
table(Id name,writerfilter::Reference<Table>::Pointer_t ref)115 void StreamProtocol::table(Id name,
116 writerfilter::Reference<Table>::Pointer_t ref)
117 {
118 m_pTagLogger->startElement("protocol-table");
119 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
120 m_pStream->table(name, ref);
121 m_pTagLogger->endElement("protocol-table");
122 }
123
substream(Id name,writerfilter::Reference<Stream>::Pointer_t ref)124 void StreamProtocol::substream(Id name,
125 writerfilter::Reference<Stream>::Pointer_t ref)
126 {
127 m_pTagLogger->startElement("protocol-substream");
128 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
129
130 m_pStream->substream(name, ref);
131 m_pTagLogger->endElement("protocol-substream");
132 }
133
info(const string & rInfo)134 void StreamProtocol::info(const string & rInfo)
135 {
136 m_pStream->info(rInfo);
137 }
138
startShape(::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> xShape)139 void StreamProtocol::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
140 {
141 m_pTagLogger->element("protocol-startShape");
142
143 m_pStream->startShape(xShape);
144 }
145
endShape()146 void StreamProtocol::endShape()
147 {
148 m_pTagLogger->element("protocol-endShape");
149
150 m_pStream->endShape();
151 }
152
153 /*
154 PropertiesProtocol
155 */
156
PropertiesProtocol(Properties * pProperties,TagLogger::Pointer_t pTagLogger)157 PropertiesProtocol::PropertiesProtocol(Properties * pProperties,
158 TagLogger::Pointer_t pTagLogger)
159 : m_pProperties(pProperties), m_pTagLogger(pTagLogger)
160 {
161 }
162
~PropertiesProtocol()163 PropertiesProtocol::~PropertiesProtocol()
164 {
165 }
166
attribute(Id name,Value & val)167 void PropertiesProtocol::attribute(Id name, Value & val)
168 {
169 m_pTagLogger->startElement("protocol-attribute");
170 m_pTagLogger->attribute("name", (*QNameToString::Instance())(name));
171 m_pTagLogger->attribute("value", val.toString());
172 m_pProperties->attribute(name, val);
173 m_pTagLogger->endElement("protocol-attribute");
174 }
175
sprm(Sprm & _sprm)176 void PropertiesProtocol::sprm(Sprm & _sprm)
177 {
178 m_pTagLogger->startElement("protocol-sprm");
179 static char sBuffer[256];
180 snprintf(sBuffer, sizeof(sBuffer), "%04" SAL_PRIxUINT32, _sprm.getId());
181 m_pTagLogger->attribute("id", sBuffer);
182 m_pTagLogger->attribute("name", _sprm.getName());
183 m_pTagLogger->chars(_sprm.toString());
184 m_pProperties->sprm(_sprm);
185 m_pTagLogger->endElement("protocol-sprm");
186 }
187
188 /*
189 TableProtocol
190 */
191
TableProtocol(Table * pTable,TagLogger::Pointer_t pTagLogger)192 TableProtocol::TableProtocol(Table * pTable, TagLogger::Pointer_t pTagLogger)
193 : m_pTable(pTable), m_pTagLogger(pTagLogger)
194 {
195 }
196
~TableProtocol()197 TableProtocol::~TableProtocol()
198 {
199 }
200
entry(int pos,writerfilter::Reference<Properties>::Pointer_t ref)201 void TableProtocol::entry(int pos,
202 writerfilter::Reference<Properties>::Pointer_t ref)
203 {
204 m_pTagLogger->startElement("protocol-entry");
205 m_pTagLogger->attribute("pos", pos);
206 m_pTable->entry(pos, ref);
207 m_pTagLogger->endElement("protocol-entry");
208 }
209
210 }
211 #endif // DEBUG
212