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