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 #include <resources.hxx>
25 #include <WW8DocumentImpl.hxx>
26
27 namespace writerfilter {
28 namespace doctok
29 {
30
resolveNoAuto(Properties & rHandler)31 void WW8PICF::resolveNoAuto(Properties & rHandler)
32 {
33 WW8Stream::Pointer_t pStream = getDocument()->getDataStream();
34
35 {
36 writerfilter::Reference<Properties>::Pointer_t pContent;
37 if (getDocument()->isPicData())
38 {
39 WW8Value::Pointer_t pValue = createValue(get_ffdata());
40 rHandler.attribute(NS_rtf::LN_ffdata, *pValue);
41 }
42 else
43 {
44 WW8Value::Pointer_t pValue = createValue(get_DffRecord());
45 rHandler.attribute(NS_rtf::LN_DffRecord, *pValue);
46 }
47 }
48 }
49
50 writerfilter::Reference<Properties>::Pointer_t
get_DffRecord()51 WW8PICF::get_DffRecord()
52 {
53 writerfilter::Reference<Properties>::Pointer_t
54 pRet(new DffBlock(this, get_cbHeader(), getCount() - get_cbHeader(),
55 0));
56 return pRet;
57 }
58
59 writerfilter::Reference<Properties>::Pointer_t
get_ffdata()60 WW8PICF::get_ffdata()
61 {
62 writerfilter::Reference<Properties>::Pointer_t
63 pRet(new WW8FFDATA(this, get_cbHeader(), getCount() - get_cbHeader()));
64
65 WW8StructBase::Pointer_t pStruct
66 (new WW8StructBase(this, get_cbHeader(),
67 getCount() - get_cbHeader()));
68
69 pStruct->dump(output);
70
71 return pRet;
72 }
73
74 writerfilter::Reference<Properties>::Pointer_t
get_shape()75 WW8FSPA::get_shape()
76 {
77 return getDocument()->getShape(get_spid());
78 }
79
resolveNoAuto(Properties & rHandler)80 void WW8FFDATA::resolveNoAuto(Properties & rHandler)
81 {
82 WW8DocumentImpl * pDocument = getDocument();
83
84 if (pDocument != NULL)
85 {
86 WW8FLD::Pointer_t pFLD = pDocument->getCurrentFLD();
87 WW8Value::Pointer_t pValue = createValue(pFLD->get_flt());
88
89 rHandler.attribute(NS_rtf::LN_FLT, *pValue);
90
91 }
92 }
93
get_FLT()94 sal_uInt32 WW8FFDATA::get_FLT()
95 {
96 sal_uInt32 nResult = 0;
97
98 WW8DocumentImpl * pDocument = getDocument();
99
100 if (pDocument != NULL)
101 {
102 WW8FLD::Pointer_t pFLD = pDocument->getCurrentFLD();
103
104 if (pFLD.get() != NULL)
105 nResult = pFLD->get_flt();
106 }
107
108 return nResult;
109 }
110
lcl_FFDATA_default_offset(WW8FFDATA & rRef)111 static sal_uInt32 lcl_FFDATA_default_offset(WW8FFDATA & rRef)
112 {
113 return 0xa + (rRef.getU16(0xa) + 2) * 2;
114 }
115
lcl_FFDATA_formatting_offset(WW8FFDATA & rRef)116 static sal_uInt32 lcl_FFDATA_formatting_offset(WW8FFDATA & rRef)
117 {
118 sal_uInt32 nResult = lcl_FFDATA_default_offset(rRef);
119
120 switch (rRef.get_FLT())
121 {
122 case 71: // forms checkbox
123 case 83: // forms listbox
124 nResult += 2;
125 break;
126 default:
127 nResult += (rRef.getU16(nResult) + 2) * 2;
128 break;
129 }
130
131 return nResult;;
132 }
133
lcl_FFDATA_help_offset(WW8FFDATA & rRef)134 static sal_uInt32 lcl_FFDATA_help_offset(WW8FFDATA & rRef)
135 {
136 sal_uInt32 nResult = lcl_FFDATA_formatting_offset(rRef);
137
138 nResult += (rRef.getU16(nResult) + 2) * 2;
139
140 return nResult;;
141 }
142
lcl_FFDATA_tooltip_offset(WW8FFDATA & rRef)143 static sal_uInt32 lcl_FFDATA_tooltip_offset(WW8FFDATA & rRef)
144 {
145 sal_uInt32 nResult = lcl_FFDATA_help_offset(rRef);
146
147 nResult += (rRef.getU16(nResult) + 2) * 2;
148
149 return nResult;;
150 }
151
get_default()152 rtl::OUString WW8FFDATA::get_default()
153 {
154 rtl::OUString sResult;
155
156 sal_uInt32 nOffset = lcl_FFDATA_default_offset(*this);
157 switch (get_FLT())
158 {
159 case 70:
160 sResult = getString(nOffset);
161
162 break;
163 default:
164 break;
165 }
166
167 return sResult;
168 }
169
get_formatting()170 rtl::OUString WW8FFDATA::get_formatting()
171 {
172 return getString(lcl_FFDATA_formatting_offset(*this));
173 }
174
get_help()175 rtl::OUString WW8FFDATA::get_help()
176 {
177 return getString(lcl_FFDATA_help_offset(*this));
178 }
179
get_tooltip()180 rtl::OUString WW8FFDATA::get_tooltip()
181 {
182 rtl::OUString sResult;
183
184 sResult = getString(lcl_FFDATA_tooltip_offset(*this));
185
186 return sResult;
187 }
188
get_checked()189 sal_uInt16 WW8FFDATA::get_checked()
190 {
191 sal_uInt16 nResult = 0;
192
193 switch (get_FLT())
194 {
195 case 71:
196 nResult = getU16(lcl_FFDATA_default_offset(*this));
197 break;
198 default:
199 break;
200 }
201
202 return nResult;
203 }
204 }}
205