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 #ifndef INCLUDED_WW8_ANALYZER_HXX
25 #define INCLUDED_WW8_ANALYZER_HXX
26 
27 #include <resourcemodel/WW8ResourceModel.hxx>
28 
29 #include <hash_set>
30 #include <map>
31 
32 namespace writerfilter
33 {
34 using namespace std;
35 
36 struct eqSalUInt32
37 {
38     bool operator () (sal_uInt32 n1, sal_uInt32 n2) const;
39 };
40 
41 class WW8Analyzer : public Properties, public Table,
42                     public BinaryObj, public Stream
43 {
44     typedef map<sal_uInt32, sal_uInt32> SprmMap;
45 
46     typedef hash_set<sal_uInt32, hash<sal_uInt32>, eqSalUInt32> IdSet;
47     typedef map<Id, sal_uInt32> AttributeMap;
48 
49     mutable SprmMap mSprmMap;
50     IdSet mSprmIdSet;
51     mutable AttributeMap mAttributeMap;
52     IdSet mAttributeIdSet;
53 
54 public:
55     WW8Analyzer();
56     virtual ~WW8Analyzer();
57 
58     // Properties
59 
60     virtual void attribute(Id Name, Value & val);
61     virtual void sprm(Sprm & sprm);
62 
63     // Table
64 
65     virtual void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
66 
67     // BinaryObj
68 
69     virtual void data(const sal_uInt8* buf, size_t len,
70                       writerfilter::Reference<Properties>::Pointer_t ref);
71 
72     // Stream
73 
74     virtual void startSectionGroup();
75     virtual void endSectionGroup();
76     virtual void startParagraphGroup();
77     virtual void endParagraphGroup();
78     virtual void startCharacterGroup();
79     virtual void endCharacterGroup();
80     virtual void text(const sal_uInt8 * data, size_t len);
81     virtual void utext(const sal_uInt8 * data, size_t len);
82     virtual void props(writerfilter::Reference<Properties>::Pointer_t ref);
83     virtual void table(Id name,
84                        writerfilter::Reference<Table>::Pointer_t ref);
85     virtual void substream(Id name,
86                            writerfilter::Reference<Stream>::Pointer_t ref);
87     virtual void info(const string & info);
88     virtual void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
89     virtual void endShape( );
90 
91     void dumpStats(ostream & o) const;
92 };
93 }
94 
95 #endif // INCLUDED_WW8_ANALYZER_HXX
96