Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include <WW8Analyzer.hxx>
21 : : #include <doctok/resourceids.hxx>
22 : : #include <resourcemodel/QNameToString.hxx>
23 : :
24 : : namespace writerfilter
25 : : {
26 : 0 : bool eqSalUInt32::operator () (sal_uInt32 n1, sal_uInt32 n2) const
27 : : {
28 : 0 : return n1 == n2;
29 : : }
30 : :
31 [ # # ][ # # ]: 0 : WW8Analyzer::WW8Analyzer()
[ # # ][ # # ]
32 : : {
33 : 0 : }
34 : :
35 [ # # ][ # # ]: 0 : WW8Analyzer::~WW8Analyzer()
36 : : {
37 [ # # ]: 0 : dumpStats(cout);
38 [ # # ]: 0 : }
39 : :
40 : 0 : void WW8Analyzer::attribute(Id name, Value & val)
41 : : {
42 [ # # ][ # # ]: 0 : string aAttrName = (*QNameToString::Instance())(name);
[ # # ]
43 [ # # ]: 0 : string aStr;
44 : :
45 [ # # ]: 0 : if (aAttrName.length() > 6)
46 [ # # ][ # # ]: 0 : aStr = aAttrName.substr(4, 2);
47 : : else
48 [ # # ][ # # ]: 0 : logger("DEBUG", "WW8Analyzer::attribute:" + aAttrName);
[ # # ]
49 : :
50 : 0 : bool bAdd = false;
51 [ # # ][ # # ]: 0 : if (aStr.compare("LC") == 0 || aStr.compare("FC") == 0)
[ # # ][ # # ]
[ # # ]
52 : : {
53 [ # # ][ # # ]: 0 : if (val.getInt() != 0)
54 : : {
55 : 0 : bAdd = true;
56 : : }
57 : : }
58 : : else
59 : : {
60 : 0 : bAdd = true;
61 : : }
62 : :
63 [ # # ]: 0 : if (bAdd)
64 : : {
65 [ # # ][ # # ]: 0 : if (mAttributeMap.count(name) > 0)
66 : : {
67 [ # # ]: 0 : sal_uInt32 nCount = mAttributeMap[name] + 1;
68 [ # # ]: 0 : mAttributeMap[name] = nCount;
69 : : }
70 : : else
71 [ # # ]: 0 : mAttributeMap[name] = 1;
72 : :
73 [ # # ]: 0 : mAttributeIdSet.insert(name);
74 : 0 : }
75 : 0 : }
76 : :
77 : 0 : void WW8Analyzer::sprm(Sprm & sprm_)
78 : : {
79 [ # # ][ # # ]: 0 : if (mSprmMap.count(sprm_.getId()) > 0)
[ # # ]
80 : : {
81 [ # # ][ # # ]: 0 : sal_uInt32 nCount = mSprmMap[sprm_.getId()] + 1;
82 [ # # ][ # # ]: 0 : mSprmMap[sprm_.getId()] = nCount;
83 : : }
84 : : else
85 [ # # ][ # # ]: 0 : mSprmMap[sprm_.getId()] = 1;
86 : :
87 [ # # ][ # # ]: 0 : mSprmIdSet.insert(sprm_.getId());
88 : :
89 [ # # ]: 0 : writerfilter::Reference<Properties>::Pointer_t pProps = sprm_.getProps();
90 : :
91 [ # # ]: 0 : if (pProps.get() != NULL)
92 : : {
93 [ # # ]: 0 : pProps->resolve(*this);
94 [ # # ]: 0 : }
95 : :
96 : 0 : }
97 : :
98 : 0 : void WW8Analyzer::entry(int /*pos*/, ::writerfilter::Reference<Properties>::Pointer_t ref)
99 : : {
100 : 0 : ref->resolve(*this);
101 : 0 : }
102 : :
103 : 0 : void WW8Analyzer::data(const sal_uInt8 * /*buf*/, size_t /*len*/,
104 : : ::writerfilter::Reference<Properties>::Pointer_t /*ref*/)
105 : : {
106 : 0 : }
107 : :
108 : 0 : void WW8Analyzer::startSectionGroup()
109 : : {
110 : 0 : }
111 : :
112 : 0 : void WW8Analyzer::endSectionGroup()
113 : : {
114 : 0 : }
115 : :
116 : 0 : void WW8Analyzer::startParagraphGroup()
117 : : {
118 : 0 : }
119 : :
120 : 0 : void WW8Analyzer::endParagraphGroup()
121 : : {
122 : 0 : }
123 : :
124 : 0 : void WW8Analyzer::startCharacterGroup()
125 : : {
126 : 0 : }
127 : :
128 : 0 : void WW8Analyzer::endCharacterGroup()
129 : : {
130 : 0 : }
131 : :
132 : 0 : void WW8Analyzer::text(const sal_uInt8 * /*data*/, size_t /*len*/)
133 : : {
134 : 0 : }
135 : :
136 : 0 : void WW8Analyzer::utext(const sal_uInt8 * /*data*/, size_t /*len*/)
137 : : {
138 : 0 : }
139 : :
140 : 0 : void WW8Analyzer::props(writerfilter::Reference<Properties>::Pointer_t ref)
141 : : {
142 : 0 : ref->resolve(*this);
143 : 0 : }
144 : :
145 : 0 : void WW8Analyzer::table(Id /*id*/, writerfilter::Reference<Table>::Pointer_t ref)
146 : : {
147 : 0 : ref->resolve(*this);
148 : 0 : }
149 : :
150 : 0 : void WW8Analyzer::substream(Id /*name*/,
151 : : writerfilter::Reference<Stream>::Pointer_t ref)
152 : : {
153 : 0 : ref->resolve(*this);
154 : 0 : }
155 : :
156 : 0 : void WW8Analyzer::info(const string & /*info*/)
157 : : {
158 : 0 : }
159 : :
160 : 0 : void WW8Analyzer::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
161 : : {
162 : 0 : }
163 : :
164 : 0 : void WW8Analyzer::endShape( )
165 : : {
166 : 0 : }
167 : :
168 : 0 : void WW8Analyzer::dumpStats(ostream & o) const
169 : : {
170 : : {
171 [ # # ][ # # ]: 0 : for (IdSet::const_iterator aIt = mSprmIdSet.begin();
172 [ # # ]: 0 : aIt != mSprmIdSet.end(); ++aIt)
173 : : {
174 [ # # ]: 0 : sal_uInt32 aId = *aIt;
175 : :
176 [ # # ][ # # ]: 0 : o << "<sprm>" << endl
177 [ # # ][ # # ]: 0 : << "<id>" << hex << aId << "</id>" << endl
[ # # ][ # # ]
[ # # ]
178 [ # # ][ # # ]: 0 : << "<name>" << (*SprmIdToString::Instance())(aId)
[ # # ][ # # ]
[ # # ]
179 [ # # ][ # # ]: 0 : << "</name>" << endl
180 [ # # ][ # # ]: 0 : << "<count>" << dec << mSprmMap[aId] << "</count>"
[ # # ][ # # ]
[ # # ]
181 [ # # ]: 0 : << endl
182 [ # # ][ # # ]: 0 : << "</sprm>" << endl;
183 : : }
184 : : }
185 : :
186 : : {
187 [ # # ][ # # ]: 0 : for (IdSet::const_iterator aIt = mAttributeIdSet.begin();
188 [ # # ]: 0 : aIt != mAttributeIdSet.end(); ++aIt)
189 : : {
190 [ # # ]: 0 : sal_uInt32 aId = *aIt;
191 : :
192 [ # # ][ # # ]: 0 : o << "<attribute>" << endl
193 [ # # ][ # # ]: 0 : << "<name>" << (*QNameToString::Instance())(aId) << "</name>"
[ # # ][ # # ]
[ # # ][ # # ]
194 [ # # ]: 0 : << endl
195 [ # # ][ # # ]: 0 : << "<count>" << dec << mAttributeMap[aId] << "</count>"
[ # # ][ # # ]
[ # # ]
196 [ # # ]: 0 : << endl
197 [ # # ][ # # ]: 0 : << "</attribute>" << endl;
198 : : }
199 : : }
200 : :
201 : 0 : }
202 : :
203 : 0 : Stream::Pointer_t createAnalyzer()
204 : : {
205 [ # # ]: 0 : return Stream::Pointer_t(new WW8Analyzer());
206 : : }
207 : :
208 [ + - ][ + - ]: 60 : }
209 : :
210 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|