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_LOGGED_RESOURCES_HXX
25 #define INCLUDED_LOGGED_RESOURCES_HXX
26 
27 #include "WW8ResourceModel.hxx"
28 #include "TagLogger.hxx"
29 
30 namespace writerfilter
31 {
32 
33 class LoggedResourcesHelper
34 {
35 public:
36     explicit LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const string & sPrefix);
37     virtual ~LoggedResourcesHelper();
38 
39     void startElement(const string & sElement);
40     void endElement(const string & sElement);
41     void chars(const ::rtl::OUString & rChars);
42     void chars(const string & rChars);
43     void attribute(const string & rName, const string & rValue);
44     void attribute(const string & rName, sal_uInt32 nValue);
45 
46     void setPrefix(const string & rPrefix);
47 
48 private:
49     TagLogger::Pointer_t mpLogger;
50     string msPrefix;
51 };
52 
53 class LoggedStream : public Stream
54 {
55 public:
56     explicit LoggedStream(TagLogger::Pointer_t pLogger, const string & sPrefix);
57     virtual ~LoggedStream();
58 
59     void startSectionGroup();
60     void endSectionGroup();
61     void startParagraphGroup();
62     void endParagraphGroup();
63     void startCharacterGroup();
64     void endCharacterGroup();
65     void startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
66     void endShape();
67     void text(const sal_uInt8 * data, size_t len);
68     void utext(const sal_uInt8 * data, size_t len);
69     void props(writerfilter::Reference<Properties>::Pointer_t ref);
70     void table(Id name, writerfilter::Reference<Table>::Pointer_t ref);
71     void substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref);
72     void info(const string & info);
73 
74 protected:
75     virtual void lcl_startSectionGroup() = 0;
76     virtual void lcl_endSectionGroup() = 0;
77     virtual void lcl_startParagraphGroup() = 0;
78     virtual void lcl_endParagraphGroup() = 0;
79     virtual void lcl_startCharacterGroup() = 0;
80     virtual void lcl_endCharacterGroup() = 0;
81     virtual void lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )  = 0;
82     virtual void lcl_endShape() = 0;
83     virtual void lcl_text(const sal_uInt8 * data, size_t len) = 0;
84     virtual void lcl_utext(const sal_uInt8 * data, size_t len) = 0;
85     virtual void lcl_props(writerfilter::Reference<Properties>::Pointer_t ref) = 0;
86     virtual void lcl_table(Id name, writerfilter::Reference<Table>::Pointer_t ref) = 0;
87     virtual void lcl_substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref) = 0;
88     virtual void lcl_info(const string & info) = 0;
89 
90     LoggedResourcesHelper mHelper;
91 };
92 
93 class LoggedProperties : public Properties
94 {
95 public:
96     explicit LoggedProperties(TagLogger::Pointer_t pLogger, const string & sPrefix);
97     virtual ~LoggedProperties();
98 
99     void attribute(Id name, Value & val);
100     void sprm(Sprm & sprm);
101 
102 protected:
103     virtual void lcl_attribute(Id name, Value & val) = 0;
104     virtual void lcl_sprm(Sprm & sprm) = 0;
105 
106     LoggedResourcesHelper mHelper;
107 };
108 
109 class LoggedTable : public Table
110 {
111 public:
112     explicit LoggedTable(TagLogger::Pointer_t pLogger, const string & sPrefix);
113     virtual ~LoggedTable();
114 
115     void entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref);
116 
117 protected:
118     virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) = 0;
119 
120     LoggedResourcesHelper mHelper;
121 };
122 
123 }
124 #endif // INCLUDED_LOGGED_RESOURCES_HXX
125