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_PROPERTY_SET_IMPL_HXX
25 #define INCLUDED_WW8_PROPERTY_SET_IMPL_HXX
26 
27 #include <resourcemodel/WW8ResourceModel.hxx>
28 #include <doctok/WW8Document.hxx>
29 #include <WW8StructBase.hxx>
30 #include <WW8OutputWithDepth.hxx>
31 
32 #include <map>
33 
34 namespace writerfilter {
35 namespace doctok
36 {
37 
38 class WW8PropertyImpl : public WW8Property, public WW8StructBase
39 {
get_ispmd() const40     sal_uInt8 get_ispmd() const
41     { return sal::static_int_cast<sal_uInt8>(getId() & 0xff); }
get_fSpec() const42     bool get_fSpec() const { return (getId() & 0x100) != 0; }
get_sgc() const43     sal_uInt8 get_sgc() const
44     { return sal::static_int_cast<sal_uInt8>((getId() >> 10) & 0x7); }
get_spra() const45     sal_uInt8 get_spra() const
46     { return sal::static_int_cast<sal_uInt8>((getId() >> 13) & 0x7); }
47 
48 public:
49     WW8PropertyImpl(WW8Stream & rStream, sal_uInt32 nOffset, sal_uInt32 nCount);
50     WW8PropertyImpl(const WW8StructBase & rBase, sal_uInt32 nOffset,
51                     sal_uInt32 nCount);
52 
53     WW8PropertyImpl(WW8StructBase * pBase, sal_uInt32 nOffset,
54                     sal_uInt32 nCount);
55 
56     virtual ~WW8PropertyImpl();
57 
getId() const58     sal_uInt32 getId() const { return getU16(0); }
59     sal_uInt32 getParam() const;
60     WW8Stream::Sequence getParams() const;
61 
62     sal_uInt32 getByteLength() const;
63     sal_uInt32 getParamOffset() const;
64 
65     virtual void dump(OutputWithDepth<string> & o) const;
66     string toString() const;
67 };
68 
69 class WW8PropertySetImpl : public WW8PropertySet, public WW8StructBase,
70                            public ::writerfilter::Reference<Properties>
71 {
72     bool mbPap;
73 
74 public:
75     typedef boost::shared_ptr<WW8PropertySet> Pointer_t;
76 
77     WW8PropertySetImpl(WW8Stream & rStream, sal_uInt32 nOffset,
78                        sal_uInt32 nCount, bool bPap = false);
79 
80     WW8PropertySetImpl(const WW8StructBase & rBase, sal_uInt32 nOffset,
81                        sal_uInt32 nCount, bool bPap = false);
82 
83     virtual ~WW8PropertySetImpl();
84 
85     virtual WW8PropertySetIterator::Pointer_t begin();
86     virtual WW8PropertySetIterator::Pointer_t end();
87 
88     virtual void dump(OutputWithDepth<string> & o) const;
89     virtual void dots(ostream & o);
90 
91     virtual string getType() const;
92 
93     virtual WW8Property::Pointer_t getAttribute(sal_uInt32 nOffset) const;
94 
95     virtual bool isPap() const;
96     virtual sal_uInt32 get_istd() const;
97 
insert(const WW8PropertySet::Pointer_t)98     virtual void insert(const WW8PropertySet::Pointer_t /*pSet*/) {}
99 
100     virtual void resolve(Properties & rHandler);
101 
102     /**
103      Get and distribute information from sprm that is used
104      internally by the document.
105 
106      @param rSprm       sprm to process
107      @param rHandler    property handler to resolve huge papx (sprm 0x6646) to
108      */
109     virtual void resolveLocal(Sprm & rSprm, Properties & rHandler);
110 };
111 
112 class WW8PropertySetIteratorImpl : public WW8PropertySetIterator
113 {
114     WW8PropertySetImpl * mpAttrSet;
115     sal_uInt32 mnOffset;
116 
117 public:
WW8PropertySetIteratorImpl(WW8PropertySetImpl * pAttrSet,sal_uInt32 nOffset)118     WW8PropertySetIteratorImpl(WW8PropertySetImpl * pAttrSet,
119                                sal_uInt32 nOffset)
120     : mpAttrSet(pAttrSet), mnOffset(nOffset)
121     {
122     }
123 
124     virtual ~WW8PropertySetIteratorImpl();
125 
126     virtual WW8PropertySetIterator & operator++();
127 
128     virtual WW8Property::Pointer_t get() const;
129 
130     virtual bool equal(const WW8PropertySetIterator & rIt) const;
131 
132     virtual string toString() const;
133 };
134 
135 ::writerfilter::Reference<Properties>::Pointer_t createSprmProps
136 (WW8PropertyImpl & rProp);
137 ::writerfilter::Reference<BinaryObj>::Pointer_t createSprmBinary
138 (WW8PropertyImpl & rProp);
139 }}
140 
141 #endif // INCLUDED_WW8_PROPERTY_SET_IMPL_HXX
142