Update ooo320-m1
[ooovba.git] / writerfilter / source / resourcemodel / WW8Analyzer.cxx
bloba3d70cf6fe03f9ae4b77ec6e9ad07f6ca88bde7e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8Analyzer.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <WW8Analyzer.hxx>
32 #include <doctok/resourceids.hxx>
33 #include <resourcemodel/QNameToString.hxx>
35 namespace writerfilter
37 bool eqSalUInt32::operator () (sal_uInt32 n1, sal_uInt32 n2) const
39 return n1 == n2;
42 WW8Analyzer::WW8Analyzer()
46 WW8Analyzer::~WW8Analyzer()
48 dumpStats(cout);
51 void WW8Analyzer::attribute(Id name, Value & val)
53 string aAttrName = (*QNameToString::Instance())(name);
54 string aStr;
56 if (aAttrName.length() > 6)
57 aStr = aAttrName.substr(4, 2);
58 else
59 logger("DEBUG", "WW8Analyzer::attribute:" + aAttrName);
61 bool bAdd = false;
62 if (aStr.compare("LC") == 0 || aStr.compare("FC") == 0)
64 if (val.getInt() != 0)
66 bAdd = true;
69 else
71 bAdd = true;
74 if (bAdd)
76 if (mAttributeMap.count(name) > 0)
78 sal_uInt32 nCount = mAttributeMap[name] + 1;
79 mAttributeMap[name] = nCount;
81 else
82 mAttributeMap[name] = 1;
84 mAttributeIdSet.insert(name);
88 void WW8Analyzer::sprm(Sprm & sprm_)
90 if (mSprmMap.count(sprm_.getId()) > 0)
92 sal_uInt32 nCount = mSprmMap[sprm_.getId()] + 1;
93 mSprmMap[sprm_.getId()] = nCount;
95 else
96 mSprmMap[sprm_.getId()] = 1;
98 mSprmIdSet.insert(sprm_.getId());
100 writerfilter::Reference<Properties>::Pointer_t pProps = sprm_.getProps();
102 if (pProps.get() != NULL)
104 pProps->resolve(*this);
109 void WW8Analyzer::entry(int /*pos*/, ::writerfilter::Reference<Properties>::Pointer_t ref)
111 ref->resolve(*this);
114 void WW8Analyzer::data(const sal_uInt8 * /*buf*/, size_t /*len*/,
115 ::writerfilter::Reference<Properties>::Pointer_t /*ref*/)
119 void WW8Analyzer::startSectionGroup()
123 void WW8Analyzer::endSectionGroup()
127 void WW8Analyzer::startParagraphGroup()
131 void WW8Analyzer::endParagraphGroup()
135 void WW8Analyzer::startCharacterGroup()
139 void WW8Analyzer::endCharacterGroup()
143 void WW8Analyzer::text(const sal_uInt8 * /*data*/, size_t /*len*/)
147 void WW8Analyzer::utext(const sal_uInt8 * /*data*/, size_t /*len*/)
151 void WW8Analyzer::props(writerfilter::Reference<Properties>::Pointer_t ref)
153 ref->resolve(*this);
156 void WW8Analyzer::table(Id /*id*/, writerfilter::Reference<Table>::Pointer_t ref)
158 ref->resolve(*this);
161 void WW8Analyzer::substream(Id /*name*/,
162 writerfilter::Reference<Stream>::Pointer_t ref)
164 ref->resolve(*this);
167 void WW8Analyzer::info(const string & /*info*/)
171 void WW8Analyzer::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ )
175 void WW8Analyzer::endShape( )
179 void WW8Analyzer::dumpStats(ostream & o) const
182 for (IdSet::const_iterator aIt = mSprmIdSet.begin();
183 aIt != mSprmIdSet.end(); aIt++)
185 sal_uInt32 aId = *aIt;
187 o << "<sprm>" << endl
188 << "<id>" << hex << aId << "</id>" << endl
189 << "<name>" << (*SprmIdToString::Instance())(aId)
190 << "</name>" << endl
191 << "<count>" << dec << mSprmMap[aId] << "</count>"
192 << endl
193 << "</sprm>" << endl;
198 for (IdSet::const_iterator aIt = mAttributeIdSet.begin();
199 aIt != mAttributeIdSet.end(); aIt++)
201 sal_uInt32 aId = *aIt;
203 o << "<attribute>" << endl
204 << "<name>" << (*QNameToString::Instance())(aId) << "</name>"
205 << endl
206 << "<count>" << dec << mAttributeMap[aId] << "</count>"
207 << endl
208 << "</attribute>" << endl;
214 Stream::Pointer_t createAnalyzer()
216 return Stream::Pointer_t(new WW8Analyzer());