1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WW8Analyzer.cxx,v $
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
42 WW8Analyzer::WW8Analyzer()
46 WW8Analyzer::~WW8Analyzer()
51 void WW8Analyzer::attribute(Id name
, Value
& val
)
53 string aAttrName
= (*QNameToString::Instance())(name
);
56 if (aAttrName
.length() > 6)
57 aStr
= aAttrName
.substr(4, 2);
59 logger("DEBUG", "WW8Analyzer::attribute:" + aAttrName
);
62 if (aStr
.compare("LC") == 0 || aStr
.compare("FC") == 0)
64 if (val
.getInt() != 0)
76 if (mAttributeMap
.count(name
) > 0)
78 sal_uInt32 nCount
= mAttributeMap
[name
] + 1;
79 mAttributeMap
[name
] = nCount
;
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
;
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
)
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
)
156 void WW8Analyzer::table(Id
/*id*/, writerfilter::Reference
<Table
>::Pointer_t ref
)
161 void WW8Analyzer::substream(Id
/*name*/,
162 writerfilter::Reference
<Stream
>::Pointer_t ref
)
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
)
191 << "<count>" << dec
<< mSprmMap
[aId
] << "</count>"
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>"
206 << "<count>" << dec
<< mAttributeMap
[aId
] << "</count>"
208 << "</attribute>" << endl
;
214 Stream::Pointer_t
createAnalyzer()
216 return Stream::Pointer_t(new WW8Analyzer());