xref: /trunk/main/writerfilter/source/doctok/Dff.hxx (revision b8a377c6)
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_DFF_HXX
25 #define INCLUDED_DFF_HXX
26 
27 #include <vector>
28 #include <WW8StructBase.hxx>
29 #include <WW8ResourceModelImpl.hxx>
30 
31 namespace writerfilter {
32 namespace doctok
33 {
34 using std::vector;
35 
36 class DffBlock;
37 
38 class DffRecord : public WW8StructBase, public writerfilter::Reference<Properties>,
39                   public Sprm
40 {
41     bool bInitialized;
42 public:
43     typedef boost::shared_ptr<DffRecord> Pointer_t;
44 
45 protected:
46     typedef vector<Pointer_t> Records_t;
47     Records_t mRecords;
48 
49     void initChildren();
50 
51 public:
52 
53     DffRecord(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount);
54     DffRecord(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount);
~DffRecord()55     virtual ~DffRecord() {}
56 
57     bool isContainer() const;
58     sal_uInt32 calcSize() const;
59 
60     sal_uInt32 getVersion() const;
61     sal_uInt32 getInstance() const;
62     sal_uInt32 getRecordType() const;
63 
clone() const64     virtual DffRecord * clone() const { return new DffRecord(*this); }
65 
66     virtual void resolveLocal(Properties & rHandler);
67     virtual void resolveChildren(Properties & rHandler);
68 
69     Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
70                           bool bAny = false);
71 
72     void findRecords
73     (sal_uInt32 nType, Records_t & rRecords,
74      bool bRecursive = true, bool bAny = false);
75 
76     Records_t::iterator begin();
77     Records_t::iterator end();
78 
79     sal_uInt32 getShapeType();
80     sal_uInt32 getShapeId();
81     sal_uInt32 getShapeBid();
82 
83     /* Properties methods */
84     virtual void resolve(Properties & rHandler);
85     virtual string getType() const;
86 
87     /* Sprm methods */
getId() const88     virtual sal_uInt32 getId() const { return getRecordType(); }
89     virtual Value::Pointer_t getValue();
90     virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary();
91     virtual writerfilter::Reference<Stream>::Pointer_t getStream();
92     virtual writerfilter::Reference<Properties>::Pointer_t getProps();
93 
94     virtual string toString() const;
95     virtual string getName() const;
96 
97     virtual Kind getKind();
98 
99     friend class DffBlock;
100 };
101 
102 typedef vector<DffRecord::Pointer_t> Records_t;
103 
104 class DffBlock : public WW8StructBase,
105                  public writerfilter::Reference<Properties>
106 {
107     bool bInitialized;
108     sal_uInt32 mnPadding;
109 
110     Records_t mRecords;
111 
112 protected:
113     void initChildren();
114 
115 public:
116     typedef boost::shared_ptr<DffBlock> Pointer_t;
117 
118     DffBlock(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
119     DffBlock(WW8StructBase * pParent, sal_uInt32 nOffset, sal_uInt32 nCount, sal_uInt32 nPadding);
120     DffBlock(const DffBlock & rSrc);
~DffBlock()121     virtual ~DffBlock() {}
122 
123     Records_t findRecords(sal_uInt32 nType, bool bRecursive = true,
124                           bool bAny = false);
125 
126     void findRecords(sal_uInt32 nType, Records_t & rRecords,
127                      bool bRecursive = true, bool bAny = false);
128 
129     DffRecord::Pointer_t getShape(sal_uInt32 nSpid);
130     DffRecord::Pointer_t getBlip(sal_uInt32 nBlip);
131 
132     Records_t::iterator begin();
133     Records_t::iterator end();
134 
135     /* Properties methods */
136     virtual void resolve(Properties & rHandler);
137     virtual string getType() const;
138 };
139 
140 DffRecord *
141 createDffRecord(WW8StructBase * pParent, sal_uInt32 nOffset,
142                 sal_uInt32 * nSize = NULL);
143 DffRecord *
144 createDffRecord(WW8Stream & rStream, sal_uInt32 nOffset,
145                 sal_uInt32 * nSize = NULL);
146 
147 }}
148 
149 #endif
150