/src/libstaroffice/src/lib/StarFrameAttribute.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
2 | | |
3 | | /* libstaroffice |
4 | | * Version: MPL 2.0 / LGPLv2+ |
5 | | * |
6 | | * The contents of this file are subject to the Mozilla Public License Version |
7 | | * 2.0 (the "License"); you may not use this file except in compliance with |
8 | | * the License or as specified alternatively below. You may obtain a copy of |
9 | | * the License at http://www.mozilla.org/MPL/ |
10 | | * |
11 | | * Software distributed under the License is distributed on an "AS IS" basis, |
12 | | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
13 | | * for the specific language governing rights and limitations under the |
14 | | * License. |
15 | | * |
16 | | * Major Contributor(s): |
17 | | * Copyright (C) 2002 William Lachance (wrlach@gmail.com) |
18 | | * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net) |
19 | | * Copyright (C) 2004-2006 Fridrich Strba (fridrich.strba@bluewin.ch) |
20 | | * Copyright (C) 2006, 2007 Andrew Ziem |
21 | | * Copyright (C) 2011, 2012 Alonso Laurent (alonso@loria.fr) |
22 | | * |
23 | | * |
24 | | * All Rights Reserved. |
25 | | * |
26 | | * For minor contributions see the git repository. |
27 | | * |
28 | | * Alternatively, the contents of this file may be used under the terms of |
29 | | * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
30 | | * in which case the provisions of the LGPLv2+ are applicable |
31 | | * instead of those above. |
32 | | */ |
33 | | |
34 | | #include <iostream> |
35 | | |
36 | | #include "StarAttribute.hxx" |
37 | | #include "StarGraphicStruct.hxx" |
38 | | #include "StarItemPool.hxx" |
39 | | #include "StarObject.hxx" |
40 | | #include "StarObjectSmallText.hxx" |
41 | | #include "StarState.hxx" |
42 | | #include "StarZone.hxx" |
43 | | |
44 | | #include "StarFrameAttribute.hxx" |
45 | | |
46 | | namespace StarFrameAttribute |
47 | | { |
48 | | //! a character bool attribute |
49 | | class StarFAttributeBool final : public StarAttributeBool |
50 | | { |
51 | | public: |
52 | | //! constructor |
53 | | StarFAttributeBool(Type type, std::string const &debugName, bool value) |
54 | 228k | : StarAttributeBool(type, debugName, value) |
55 | 228k | { |
56 | 228k | } |
57 | | //! create a new attribute |
58 | | std::shared_ptr<StarAttribute> create() const final |
59 | 805 | { |
60 | 805 | return std::shared_ptr<StarAttribute>(new StarFAttributeBool(*this)); |
61 | 805 | } |
62 | | //! add to a frame style |
63 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
64 | | |
65 | | protected: |
66 | | //! copy constructor |
67 | 805 | StarFAttributeBool(StarFAttributeBool const &) = default; |
68 | | }; |
69 | | |
70 | | //! a character color attribute |
71 | | class StarFAttributeColor final : public StarAttributeColor |
72 | | { |
73 | | public: |
74 | | //! constructor |
75 | | StarFAttributeColor(Type type, std::string const &debugName, STOFFColor const &value) |
76 | | : StarAttributeColor(type, debugName, value) |
77 | 0 | { |
78 | 0 | } |
79 | | //! destructor |
80 | | ~StarFAttributeColor() final; |
81 | | //! create a new attribute |
82 | | std::shared_ptr<StarAttribute> create() const final |
83 | 0 | { |
84 | 0 | return std::shared_ptr<StarAttribute>(new StarFAttributeColor(*this)); |
85 | 0 | } |
86 | | //! add to a frame style |
87 | | // void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
88 | | protected: |
89 | | //! copy constructor |
90 | 0 | StarFAttributeColor(StarFAttributeColor const &) = default; |
91 | | }; |
92 | | |
93 | | StarFAttributeColor::~StarFAttributeColor() |
94 | 0 | { |
95 | 0 | } |
96 | | //! a character integer attribute |
97 | | class StarFAttributeInt final : public StarAttributeInt |
98 | | { |
99 | | public: |
100 | | //! constructor |
101 | | StarFAttributeInt(Type type, std::string const &debugName, int intSize, int value) |
102 | | : StarAttributeInt(type, debugName, intSize, value) |
103 | 0 | { |
104 | 0 | } |
105 | | //! add to a frame style |
106 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
107 | | //! create a new attribute |
108 | | std::shared_ptr<StarAttribute> create() const final |
109 | 0 | { |
110 | 0 | return std::shared_ptr<StarAttribute>(new StarFAttributeInt(*this)); |
111 | 0 | } |
112 | | protected: |
113 | | //! copy constructor |
114 | 0 | StarFAttributeInt(StarFAttributeInt const &) = default; |
115 | | }; |
116 | | |
117 | | //! a character unsigned integer attribute |
118 | | class StarFAttributeUInt final : public StarAttributeUInt |
119 | | { |
120 | | public: |
121 | | //! constructor |
122 | | StarFAttributeUInt(Type type, std::string const &debugName, int intSize, unsigned int value) |
123 | 228k | : StarAttributeUInt(type, debugName, intSize, value) |
124 | 228k | { |
125 | 228k | } |
126 | | //! read a zone |
127 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final |
128 | 6.18k | { |
129 | 6.18k | if (m_type==ATTR_FRM_BREAK) { |
130 | | // SvxFmtBreakItem |
131 | 6.18k | STOFFInputStreamPtr input=zone.input(); |
132 | 6.18k | long pos=input->tell(); |
133 | 6.18k | libstoff::DebugFile &ascFile=zone.ascii(); |
134 | 6.18k | libstoff::DebugStream f; |
135 | 6.18k | m_value=static_cast<unsigned int>(input->readULong(1)); |
136 | 6.18k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:" << m_debugName << "=" << m_value << ","; |
137 | 6.18k | if (vers==0) input->seek(1, librevenge::RVNG_SEEK_CUR); // dummy |
138 | 6.18k | ascFile.addPos(pos); |
139 | 6.18k | ascFile.addNote(f.str().c_str()); |
140 | 6.18k | return input->tell()<=endPos; |
141 | 6.18k | } |
142 | 0 | return StarAttributeUInt::read(zone, vers, endPos, object); |
143 | 6.18k | } |
144 | | //! create a new attribute |
145 | | std::shared_ptr<StarAttribute> create() const final |
146 | 6.34k | { |
147 | 6.34k | return std::shared_ptr<StarAttribute>(new StarFAttributeUInt(*this)); |
148 | 6.34k | } |
149 | | //! add to a frame style |
150 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
151 | | protected: |
152 | | //! copy constructor |
153 | 6.34k | StarFAttributeUInt(StarFAttributeUInt const &) = default; |
154 | | }; |
155 | | |
156 | | //! a void attribute |
157 | | class StarFAttributeVoid final : public StarAttributeVoid |
158 | | { |
159 | | public: |
160 | | //! constructor |
161 | | StarFAttributeVoid(Type type, std::string const &debugName) |
162 | | : StarAttributeVoid(type, debugName) |
163 | 0 | { |
164 | 0 | } |
165 | | //! destructor |
166 | | ~StarFAttributeVoid() final; |
167 | | //! create a new attribute |
168 | | std::shared_ptr<StarAttribute> create() const final |
169 | 0 | { |
170 | 0 | return std::shared_ptr<StarAttribute>(new StarFAttributeVoid(*this)); |
171 | 0 | } |
172 | | //! add to a frame style |
173 | | // void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
174 | | protected: |
175 | | //! copy constructor |
176 | 0 | StarFAttributeVoid(StarFAttributeVoid const &) = default; |
177 | | }; |
178 | | |
179 | | StarFAttributeVoid::~StarFAttributeVoid() |
180 | 0 | { |
181 | 0 | } |
182 | | |
183 | | void StarFAttributeBool::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
184 | 190 | { |
185 | 190 | if (m_type==ATTR_FRM_LAYOUT_SPLIT) |
186 | 190 | state.m_frame.m_propertyList.insert("style:may-break-between-rows", m_value); |
187 | 190 | } |
188 | | |
189 | | void StarFAttributeInt::addTo(StarState &/*state*/, std::set<StarAttribute const *> &/*done*/) const |
190 | 0 | { |
191 | 0 | } |
192 | | |
193 | | void StarFAttributeUInt::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
194 | 8.13k | { |
195 | 8.13k | if (m_type==ATTR_FRM_BREAK) { |
196 | 8.13k | if (m_value>0 && m_value<=6) state.m_break=int(m_value); |
197 | 6.61k | else if (m_value) { |
198 | 126 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeUInt::addTo: unknown break value %d\n", int(m_value))); |
199 | 126 | } |
200 | 8.13k | } |
201 | 8.13k | } |
202 | | |
203 | | //! add a bool attribute |
204 | | inline void addAttributeBool(std::map<int, std::shared_ptr<StarAttribute> > &map, StarAttribute::Type type, std::string const &debugName, bool defValue) |
205 | 228k | { |
206 | 228k | map[type]=std::shared_ptr<StarAttribute>(new StarFAttributeBool(type,debugName, defValue)); |
207 | 228k | } |
208 | | //! add a color attribute |
209 | | inline void addAttributeColor(std::map<int, std::shared_ptr<StarAttribute> > &map, StarAttribute::Type type, std::string const &debugName, STOFFColor const &defValue) |
210 | 0 | { |
211 | 0 | map[type]=std::shared_ptr<StarAttribute>(new StarFAttributeColor(type,debugName, defValue)); |
212 | 0 | } |
213 | | //! add a int attribute |
214 | | inline void addAttributeInt(std::map<int, std::shared_ptr<StarAttribute> > &map, StarAttribute::Type type, std::string const &debugName, int numBytes, int defValue) |
215 | 0 | { |
216 | 0 | map[type]=std::shared_ptr<StarAttribute>(new StarFAttributeInt(type,debugName, numBytes, defValue)); |
217 | 0 | } |
218 | | //! add a unsigned int attribute |
219 | | inline void addAttributeUInt(std::map<int, std::shared_ptr<StarAttribute> > &map, StarAttribute::Type type, std::string const &debugName, int numBytes, unsigned int defValue) |
220 | 228k | { |
221 | 228k | map[type]=std::shared_ptr<StarAttribute>(new StarFAttributeUInt(type,debugName, numBytes, defValue)); |
222 | 228k | } |
223 | | //! add a void attribute |
224 | | inline void addAttributeVoid(std::map<int, std::shared_ptr<StarAttribute> > &map, StarAttribute::Type type, std::string const &debugName) |
225 | 0 | { |
226 | 0 | map[type]=std::shared_ptr<StarAttribute>(new StarFAttributeVoid(type,debugName)); |
227 | 0 | } |
228 | | |
229 | | } |
230 | | |
231 | | namespace StarFrameAttribute |
232 | | { |
233 | | //! a anchor attribute |
234 | | class StarFAttributeAnchor final : public StarAttribute |
235 | | { |
236 | | public: |
237 | | //! constructor |
238 | | StarFAttributeAnchor(Type type, std::string const &debugName) |
239 | 228k | : StarAttribute(type, debugName) |
240 | 228k | , m_anchor(-1) |
241 | 228k | , m_index(-1) |
242 | 228k | { |
243 | 228k | } |
244 | | //! create a new attribute |
245 | | std::shared_ptr<StarAttribute> create() const final |
246 | 11.4k | { |
247 | 11.4k | return std::shared_ptr<StarAttribute>(new StarFAttributeAnchor(*this)); |
248 | 11.4k | } |
249 | | //! read a zone |
250 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
251 | | //! add to a cell/graphic/paragraph style |
252 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
253 | | //! debug function to print the data |
254 | | void printData(libstoff::DebugStream &o) const final |
255 | 11.0k | { |
256 | 11.0k | o << m_debugName << "=["; |
257 | 11.0k | if (m_anchor>=0) o << "anchor=" << m_anchor << ","; |
258 | 11.0k | if (m_index>=0) o << "index=" << m_index << ","; |
259 | 11.0k | o << "],"; |
260 | 11.0k | } |
261 | | |
262 | | protected: |
263 | | //! copy constructor |
264 | 11.4k | StarFAttributeAnchor(StarFAttributeAnchor const &) = default; |
265 | | //! the anchor |
266 | | int m_anchor; |
267 | | //! the index (page?) |
268 | | int m_index; |
269 | | }; |
270 | | |
271 | | //! a border attribute |
272 | | class StarFAttributeBorder final : public StarAttribute |
273 | | { |
274 | | public: |
275 | | //! constructor |
276 | | StarFAttributeBorder(Type type, std::string const &debugName) |
277 | 457k | : StarAttribute(type, debugName) |
278 | 457k | , m_distance(0) |
279 | 457k | { |
280 | 1.82M | for (int &distance : m_distances) distance=0; |
281 | 457k | } |
282 | | //! create a new attribute |
283 | | std::shared_ptr<StarAttribute> create() const final |
284 | 49.6k | { |
285 | 49.6k | return std::shared_ptr<StarAttribute>(new StarFAttributeBorder(*this)); |
286 | 49.6k | } |
287 | | //! read a zone |
288 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
289 | | //! add to a cell/graphic/paragraph style |
290 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
291 | | //! debug function to print the data |
292 | | void printData(libstoff::DebugStream &o) const final |
293 | 48.4k | { |
294 | 48.4k | o << m_debugName << "=["; |
295 | 48.4k | if (m_distance) o << "dist=" << m_distance << ","; |
296 | 242k | for (int i=0; i<4; ++i) { |
297 | 193k | if (!m_borders[i].isEmpty()) |
298 | 88.2k | o << "border" << i << "=[" << m_borders[i] << "],"; |
299 | 193k | } |
300 | 48.4k | bool hasDistances=false; |
301 | 189k | for (int distance : m_distances) { |
302 | 189k | if (distance) { |
303 | 2.33k | hasDistances=true; |
304 | 2.33k | break; |
305 | 2.33k | } |
306 | 189k | } |
307 | 48.4k | if (hasDistances) { |
308 | 2.33k | o << "dists=["; |
309 | 2.33k | for (int distance : m_distances) |
310 | 9.33k | o << distance << ","; |
311 | 2.33k | o << "],"; |
312 | 2.33k | } |
313 | 48.4k | o << "],"; |
314 | 48.4k | } |
315 | | |
316 | | protected: |
317 | | //! copy constructor |
318 | 49.6k | StarFAttributeBorder(StarFAttributeBorder const &) = default; |
319 | | //! the distance |
320 | | int m_distance; |
321 | | //! the border list: top, left, right, bottom |
322 | | STOFFBorderLine m_borders[4]; |
323 | | //! the padding distance: top, left, right, bottom |
324 | | int m_distances[4]; |
325 | | }; |
326 | | |
327 | | //! a brush attribute |
328 | | class StarFAttributeBrush final : public StarAttribute |
329 | | { |
330 | | public: |
331 | | //! constructor |
332 | | StarFAttributeBrush(Type type, std::string const &debugName) |
333 | 914k | : StarAttribute(type, debugName) |
334 | 914k | , m_brush() |
335 | 914k | { |
336 | 914k | } |
337 | | //! create a new attribute |
338 | | std::shared_ptr<StarAttribute> create() const final |
339 | 34.0k | { |
340 | 34.0k | return std::shared_ptr<StarAttribute>(new StarFAttributeBrush(*this)); |
341 | 34.0k | } |
342 | | //! read a zone |
343 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
344 | | //! add to a cell/font/graphic style |
345 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
346 | | //! debug function to print the data |
347 | | void printData(libstoff::DebugStream &o) const final |
348 | 33.4k | { |
349 | 33.4k | o << m_debugName << "=[" << m_brush << "],"; |
350 | 33.4k | } |
351 | | |
352 | | protected: |
353 | | //! copy constructor |
354 | 34.0k | StarFAttributeBrush(StarFAttributeBrush const &) = default; |
355 | | //! the brush |
356 | | StarGraphicStruct::StarBrush m_brush; |
357 | | }; |
358 | | |
359 | | //! a frameSize attribute |
360 | | class StarFAttributeFrameSize final : public StarAttribute |
361 | | { |
362 | | public: |
363 | | //! constructor |
364 | | StarFAttributeFrameSize(Type type, std::string const &debugName) |
365 | 228k | : StarAttribute(type, debugName) |
366 | 228k | , m_frmType(0) |
367 | 228k | , m_width(0) |
368 | 228k | , m_height(0) |
369 | 228k | , m_percent(0,0) |
370 | 228k | { |
371 | 228k | } |
372 | | //! create a new attribute |
373 | | std::shared_ptr<StarAttribute> create() const final |
374 | 32.7k | { |
375 | 32.7k | return std::shared_ptr<StarAttribute>(new StarFAttributeFrameSize(*this)); |
376 | 32.7k | } |
377 | | //! read a zone |
378 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
379 | | //! add to a page |
380 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
381 | | //! debug function to print the data |
382 | | void printData(libstoff::DebugStream &o) const final |
383 | 32.6k | { |
384 | 32.6k | o << m_debugName << "=["; |
385 | 32.6k | if (m_frmType) // 0: var, 1:fixed, 2:min |
386 | 6.40k | o << "type=" << m_frmType << ","; |
387 | 32.6k | if (m_width) |
388 | 32.4k | o << "width=" << m_width << ","; |
389 | 32.6k | if (m_height) |
390 | 9.39k | o << "height=" << m_height << ","; |
391 | 32.6k | if (m_percent[0]>0 || m_percent[1]>0) |
392 | 762 | o << "size[%]=" << m_percent << ","; |
393 | 32.6k | o << "],"; |
394 | 32.6k | } |
395 | | |
396 | | protected: |
397 | | //! copy constructor |
398 | 32.7k | StarFAttributeFrameSize(StarFAttributeFrameSize const &) = default; |
399 | | //! the type |
400 | | int m_frmType; |
401 | | //! the width |
402 | | long m_width; |
403 | | //! the height |
404 | | long m_height; |
405 | | //! the percent value |
406 | | STOFFVec2i m_percent; |
407 | | }; |
408 | | |
409 | | //! a line numbering attribute |
410 | | class StarFAttributeLineNumbering final : public StarAttribute |
411 | | { |
412 | | public: |
413 | | //! constructor |
414 | | StarFAttributeLineNumbering(Type type, std::string const &debugName) |
415 | 228k | : StarAttribute(type, debugName) |
416 | 228k | , m_start(-1) |
417 | 228k | , m_countLines(false) |
418 | 228k | { |
419 | 228k | } |
420 | | //! create a new attribute |
421 | | std::shared_ptr<StarAttribute> create() const final |
422 | 1.40k | { |
423 | 1.40k | return std::shared_ptr<StarAttribute>(new StarFAttributeLineNumbering(*this)); |
424 | 1.40k | } |
425 | | //! read a zone |
426 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
427 | | //! add to a para |
428 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
429 | | //! debug function to print the data |
430 | | void printData(libstoff::DebugStream &o) const final |
431 | 1.27k | { |
432 | 1.27k | o << m_debugName; |
433 | 1.27k | if (m_countLines) |
434 | 235 | o << "=" << m_start << ","; |
435 | 1.04k | else |
436 | 1.04k | o << "*,"; |
437 | 1.27k | } |
438 | | protected: |
439 | | //! copy constructor |
440 | 1.40k | StarFAttributeLineNumbering(StarFAttributeLineNumbering const &) = default; |
441 | | //! the name value |
442 | | long m_start; |
443 | | //! the countLines flag |
444 | | bool m_countLines; |
445 | | }; |
446 | | |
447 | | //! a left, right, ... attribute |
448 | | class StarFAttributeLRSpace final : public StarAttribute |
449 | | { |
450 | | public: |
451 | | //! constructor |
452 | | StarFAttributeLRSpace(Type type, std::string const &debugName) |
453 | 457k | : StarAttribute(type, debugName) |
454 | 457k | , m_textLeft(0) |
455 | 457k | , m_autoFirst(false) |
456 | 457k | { |
457 | 1.37M | for (int &margin : m_margins) margin=0; |
458 | 1.37M | for (int &propMargin : m_propMargins) propMargin=100; |
459 | 457k | } |
460 | | //! create a new attribute |
461 | | std::shared_ptr<StarAttribute> create() const final |
462 | 71.6k | { |
463 | 71.6k | return std::shared_ptr<StarAttribute>(new StarFAttributeLRSpace(*this)); |
464 | 71.6k | } |
465 | | //! read a zone |
466 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
467 | | //! add to a paragraph/page |
468 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
469 | | //! debug function to print the data |
470 | | void printData(libstoff::DebugStream &o) const final |
471 | 68.6k | { |
472 | 68.6k | o << m_debugName << "=["; |
473 | 274k | for (int i=0; i<3; ++i) { |
474 | 205k | char const *wh[]= {"left", "right", "firstLine"}; |
475 | 205k | if (m_propMargins[i]!=100) |
476 | 15.6k | o << wh[i] << "=" << m_propMargins[i] << "%,"; |
477 | 190k | else if (m_margins[i]) |
478 | 74.3k | o << wh[i] << "=" << m_margins[i] << ","; |
479 | 205k | } |
480 | 68.6k | if (m_textLeft) o << "text[left]=" << m_textLeft << ","; |
481 | 68.6k | if (!m_autoFirst) o << "autoFirst=no,"; |
482 | 68.6k | o << "],"; |
483 | 68.6k | } |
484 | | protected: |
485 | | //! copy constructor |
486 | 71.6k | StarFAttributeLRSpace(StarFAttributeLRSpace const &) = default; |
487 | | //! the margins: left, right, firstline |
488 | | int m_margins[3]; |
489 | | //! the prop margins: left, right, firstline |
490 | | int m_propMargins[3]; |
491 | | //! the text left |
492 | | int m_textLeft; |
493 | | //! a bool |
494 | | bool m_autoFirst; |
495 | | }; |
496 | | |
497 | | //! a orientation attribute |
498 | | class StarFAttributeOrientation final : public StarAttribute |
499 | | { |
500 | | public: |
501 | | //! constructor |
502 | | StarFAttributeOrientation(Type type, std::string const &debugName) |
503 | 457k | : StarAttribute(type, debugName) |
504 | 457k | , m_position(0) |
505 | 457k | , m_orient(0) |
506 | 457k | , m_relat(1) |
507 | 457k | , m_posToggle(false) |
508 | 457k | { |
509 | 457k | } |
510 | | //! create a new attribute |
511 | | std::shared_ptr<StarAttribute> create() const final |
512 | 49.7k | { |
513 | 49.7k | return std::shared_ptr<StarAttribute>(new StarFAttributeOrientation(*this)); |
514 | 49.7k | } |
515 | | //! read a zone |
516 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
517 | | //! add to a cell style |
518 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
519 | | //! debug function to print the data |
520 | | void printData(libstoff::DebugStream &o) const final |
521 | 49.0k | { |
522 | 49.0k | o << m_debugName << "=["; |
523 | 49.0k | if (m_position) o << "pos=" << m_position << ","; |
524 | 49.0k | if (m_orient) o << "orient=" << m_orient << ","; |
525 | 49.0k | if (m_relat) o << "relat=" << m_relat << ","; // PRTAREA, |
526 | 49.0k | if (m_posToggle) o << "posToggle,"; |
527 | 49.0k | o << "],"; |
528 | 49.0k | } |
529 | | |
530 | | protected: |
531 | | //! copy constructor |
532 | 49.7k | StarFAttributeOrientation(StarFAttributeOrientation const &) = default; |
533 | | //! the position in twip |
534 | | int32_t m_position; |
535 | | /** the orientation: |
536 | | -horizontal:NONE,RIGHT,CENTER, LEFT,INSIDE,OUTSIDE,FULL, LEFT_AND_WIDTH |
537 | | -vertical:NONE,TOP,CENTER,BOTTOM,CHAR_TOP,CHAR_CENTER,CHAR_BOTTOM,LINE_TOP,LINE_CENTER,LINE_BOTTOM |
538 | | */ |
539 | | int m_orient; |
540 | | //! the relative position, FRAME, PRTAREA, CHAR, PG_LEFT, PG_RIGTH, FRM_LEFT, FRM_RIGHT, PG_FRAME, PG_PTRAREA |
541 | | int m_relat; |
542 | | //! a posToggle flag |
543 | | bool m_posToggle; |
544 | | }; |
545 | | |
546 | | //! a shadow attribute |
547 | | class StarFAttributeShadow final : public StarAttribute |
548 | | { |
549 | | public: |
550 | | //! constructor |
551 | | StarFAttributeShadow(Type type, std::string const &debugName) |
552 | 457k | : StarAttribute(type, debugName) |
553 | 457k | , m_location(0) |
554 | 457k | , m_width(0) |
555 | 457k | , m_transparency(0) |
556 | 457k | , m_color(STOFFColor::white()) |
557 | 457k | , m_fillColor(STOFFColor::white()) |
558 | 457k | , m_style(0) |
559 | 457k | { |
560 | 457k | } |
561 | | //! create a new attribute |
562 | | std::shared_ptr<StarAttribute> create() const final |
563 | 1.94k | { |
564 | 1.94k | return std::shared_ptr<StarAttribute>(new StarFAttributeShadow(*this)); |
565 | 1.94k | } |
566 | | //! read a zone |
567 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
568 | | //! add to a cell/graphic style |
569 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
570 | | //! debug function to print the data |
571 | | void printData(libstoff::DebugStream &o) const final |
572 | 1.71k | { |
573 | 1.71k | o << m_debugName << "=["; |
574 | 1.71k | if (m_location) o << "loc=" << m_location << ","; |
575 | 1.71k | if (m_width) o << "width=" << m_width << ","; |
576 | 1.71k | if (m_transparency) o << "transparency=" << m_transparency << ","; |
577 | 1.71k | if (!m_color.isWhite()) o << "col=" << m_color << ","; |
578 | 1.71k | if (!m_fillColor.isWhite()) o << "col[fill]=" << m_fillColor << ","; |
579 | 1.71k | if (m_style) o << "style=" << m_style << ","; |
580 | 1.71k | o << "],"; |
581 | 1.71k | } |
582 | | |
583 | | protected: |
584 | | //! copy constructor |
585 | 1.94k | StarFAttributeShadow(StarFAttributeShadow const &) = default; |
586 | | //! the location 0-4 |
587 | | int m_location; |
588 | | //! the width in twip |
589 | | int m_width; |
590 | | //! the trans? |
591 | | int m_transparency; |
592 | | //! the color |
593 | | STOFFColor m_color; |
594 | | //! the fill color |
595 | | STOFFColor m_fillColor; |
596 | | //! the style |
597 | | int m_style; |
598 | | }; |
599 | | |
600 | | //! a surround attribute |
601 | | class StarFAttributeSurround final : public StarAttribute |
602 | | { |
603 | | public: |
604 | | //! constructor |
605 | | StarFAttributeSurround(Type type, std::string const &debugName) |
606 | 228k | : StarAttribute(type, debugName) |
607 | 228k | , m_surround(2) |
608 | 228k | { |
609 | 914k | for (auto &b : m_bools) b=false; |
610 | 228k | } |
611 | | //! create a new attribute |
612 | | std::shared_ptr<StarAttribute> create() const final |
613 | 42.0k | { |
614 | 42.0k | return std::shared_ptr<StarAttribute>(new StarFAttributeSurround(*this)); |
615 | 42.0k | } |
616 | | //! read a zone |
617 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
618 | | //! add to a cell/graphic style |
619 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
620 | | //! debug function to print the data |
621 | | void printData(libstoff::DebugStream &o) const final |
622 | 41.7k | { |
623 | 41.7k | o << m_debugName << "=["; |
624 | 41.7k | if (m_surround) o << "surround=" << m_surround << ","; |
625 | 208k | for (int i=0; i<4; ++i) { |
626 | 166k | if (!m_bools[i]) continue; |
627 | 6.55k | char const *wh[] = {"ideal", "anchor[only]", "contour", "outside"}; |
628 | 6.55k | o << wh[i] << ","; |
629 | 6.55k | } |
630 | 41.7k | o << "],"; |
631 | 41.7k | } |
632 | | |
633 | | protected: |
634 | | //! copy constructor |
635 | 42.0k | StarFAttributeSurround(StarFAttributeSurround const &) = default; |
636 | | //! the main value: NONE, THROUGH, PARALLEL, IDEAL, LEFT, RIGHT, END |
637 | | int m_surround; |
638 | | //! the ideal,anchorOnly, contour, outside |
639 | | bool m_bools[4]; |
640 | | }; |
641 | | |
642 | | //! a top, bottom, ... attribute |
643 | | class StarFAttributeULSpace final : public StarAttribute |
644 | | { |
645 | | public: |
646 | | //! constructor |
647 | | StarFAttributeULSpace(Type type, std::string const &debugName) |
648 | 228k | : StarAttribute(type, debugName) |
649 | 228k | { |
650 | 457k | for (int &margin : m_margins) margin=0; |
651 | 457k | for (int &propMargin : m_propMargins) propMargin=100; |
652 | 228k | } |
653 | | //! create a new attribute |
654 | | std::shared_ptr<StarAttribute> create() const final |
655 | 49.6k | { |
656 | 49.6k | return std::shared_ptr<StarAttribute>(new StarFAttributeULSpace(*this)); |
657 | 49.6k | } |
658 | | //! read a zone |
659 | | bool read(StarZone &zone, int vers, long endPos, StarObject &object) final; |
660 | | //! add to a page/paragraph |
661 | | void addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const final; |
662 | | //! debug function to print the data |
663 | | void printData(libstoff::DebugStream &o) const final |
664 | 47.8k | { |
665 | 47.8k | o << m_debugName << "=["; |
666 | 143k | for (int i=0; i<2; ++i) { |
667 | 95.6k | char const *wh[]= {"top", "bottom" }; |
668 | 95.6k | if (m_propMargins[i]!=100) |
669 | 6.62k | o << wh[i] << "=" << m_propMargins[i] << "%,"; |
670 | 88.9k | else if (m_margins[i]) |
671 | 33.9k | o << wh[i] << "=" << m_margins[i] << ","; |
672 | 95.6k | } |
673 | 47.8k | o << "],"; |
674 | 47.8k | } |
675 | | protected: |
676 | | //! copy constructor |
677 | 49.6k | StarFAttributeULSpace(StarFAttributeULSpace const &) = default; |
678 | | //! the margins: top, bottom |
679 | | int m_margins[2]; |
680 | | //! the prop margins: top, bottom |
681 | | int m_propMargins[2]; |
682 | | }; |
683 | | |
684 | | void StarFAttributeAnchor::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
685 | 8.25k | { |
686 | | /* FLY_AT_PARA, FLY_AS_CHAR, FLY_AT_PAGE, FLY_AT_FLY, FLY_AT_CHAR |
687 | | RND_STD_HEADER, RND_STD_FOOTER, RND_STD_HEADERL, RND_STD_HEADERR, |
688 | | RND_STD_FOOTERL, RND_STD_FOOTERR, |
689 | | RND_DRAW_OBJECT */ |
690 | 8.25k | STOFFPosition::AnchorTo const wh[]= {STOFFPosition::Paragraph, STOFFPosition::CharBaseLine, STOFFPosition::Page, STOFFPosition::Frame, STOFFPosition::Char }; |
691 | 8.25k | if (m_anchor>=0 && m_anchor < int(STOFF_N_ELEMENTS(wh))) { |
692 | 7.97k | state.m_frame.m_position.setAnchor(wh[m_anchor]); |
693 | 7.97k | char const *defaultXRel[] = {"paragraph", "paragraph", "page", "frame", "paragraph" }; |
694 | 7.97k | char const *defaultYRel[] = {"paragraph", "baseline", "page", "frame", "paragraph" }; |
695 | 7.97k | char const *defaultYPos[] = {nullptr, "bottom", nullptr, nullptr, "from-top"}; |
696 | 7.97k | if (!state.m_frame.m_propertyList["style:horizontal-rel"] && defaultXRel[m_anchor]) |
697 | 4.57k | state.m_frame.m_propertyList.insert("style:horizontal-rel", defaultXRel[m_anchor]); |
698 | 7.97k | if (!state.m_frame.m_propertyList["style:vertical-rel"] && defaultYRel[m_anchor]) |
699 | 4.18k | state.m_frame.m_propertyList.insert("style:vertical-rel", defaultYRel[m_anchor]); |
700 | 7.97k | if (!state.m_frame.m_propertyList["style:vertical-pos"] && defaultYPos[m_anchor]) |
701 | 645 | state.m_frame.m_propertyList.insert("style:vertical-pos", defaultYPos[m_anchor]); |
702 | | |
703 | 7.97k | if (m_anchor==2) { // page |
704 | 2.29k | if (m_index>=0) |
705 | 2.29k | state.m_frame.m_propertyList.insert("text:anchor-page-number", m_index); |
706 | 2.29k | } |
707 | 5.67k | else if (m_anchor==4) // at char |
708 | 271 | state.m_frame.m_anchorIndex = m_index; |
709 | 7.97k | } |
710 | 281 | else if (m_anchor>=0) { |
711 | 242 | STOFF_DEBUG_MSG(("StarFrameAttributeInternal::StarFAttributeAnchor::addTo: unsure how to send anchor=%d\n", m_anchor)); |
712 | 242 | } |
713 | 8.25k | } |
714 | | |
715 | | void StarFAttributeBorder::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
716 | 239k | { |
717 | 239k | char const *wh[] = {"top", "left", "right", "bottom"}; |
718 | 239k | if (m_type==ATTR_FRM_BOX) { |
719 | | // checkme what is m_distance |
720 | | |
721 | | // graphic |
722 | 97.4k | for (int i=0; i<4; ++i) { |
723 | 77.9k | if (!m_borders[i].isEmpty()) |
724 | 19.9k | m_borders[i].addTo(state.m_graphic.m_propertyList, wh[i]); |
725 | 77.9k | } |
726 | 97.4k | for (int i=0; i<4; ++i) |
727 | 77.9k | state.m_graphic.m_propertyList.insert((std::string("padding-")+wh[i]).c_str(), state.convertInPoint(m_distances[i]), librevenge::RVNG_POINT); |
728 | | |
729 | | // paragraph |
730 | 97.4k | for (int i=0; i<4; ++i) |
731 | 77.9k | m_borders[i].addTo(state.m_paragraph.m_propertyList, wh[i]); |
732 | | // SW table |
733 | 97.4k | for (int i=0; i<4; ++i) |
734 | 77.9k | m_borders[i].addTo(state.m_cell.m_propertyList, wh[i]); |
735 | 19.4k | } |
736 | 220k | else if (m_type==ATTR_SC_BORDER) { |
737 | | // checkme what is m_distance? |
738 | 1.10M | for (int i=0; i<4; ++i) |
739 | 880k | m_borders[i].addTo(state.m_cell.m_propertyList, wh[i]); |
740 | 220k | } |
741 | 239k | } |
742 | | |
743 | | void StarFAttributeBrush::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
744 | 71.5k | { |
745 | | // font |
746 | 71.5k | if (m_type == ATTR_CHR_BACKGROUND) { |
747 | 1.33k | if (m_brush.isEmpty()) |
748 | 1.28k | state.m_font.m_propertyList.insert("fo:background-color", "transparent"); |
749 | 53 | else { |
750 | 53 | STOFFColor color; |
751 | 53 | if (m_brush.getColor(color)) |
752 | 53 | state.m_font.m_propertyList.insert("fo:background-color", color.str().c_str()); |
753 | 0 | else { |
754 | 0 | state.m_font.m_propertyList.insert("fo:background-color", "transparent"); |
755 | 0 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBrush::addTo: can not set a font background\n")); |
756 | 0 | } |
757 | 53 | } |
758 | 1.33k | } |
759 | | // graphic|para |
760 | 70.2k | else if (m_type==ATTR_FRM_BACKGROUND) { |
761 | 517 | if (m_brush.m_transparency>0 && m_brush.m_transparency<=255) |
762 | 97 | state.m_graphic.m_propertyList.insert("draw:opacity", 1.-double(m_brush.m_transparency)/255., librevenge::RVNG_PERCENT); |
763 | 420 | else |
764 | 420 | state.m_graphic.m_propertyList.insert("draw:opacity",1., librevenge::RVNG_PERCENT); |
765 | 517 | state.m_paragraph.m_propertyList.insert("fo:background-color", "transparent"); |
766 | | // graphic |
767 | 517 | if (m_brush.isEmpty()) |
768 | 202 | state.m_graphic.m_propertyList.insert("draw:fill", "none"); |
769 | 315 | else { |
770 | 315 | STOFFColor color; |
771 | 315 | if (m_brush.hasUniqueColor() && m_brush.getColor(color)) { |
772 | 302 | state.m_graphic.m_propertyList.insert("draw:fill", "solid"); |
773 | 302 | state.m_graphic.m_propertyList.insert("draw:fill-color", color.str().c_str()); |
774 | | |
775 | | // para |
776 | 302 | state.m_paragraph.m_propertyList.insert("fo:background-color", color.str().c_str()); |
777 | 302 | } |
778 | 13 | else { |
779 | 13 | STOFFEmbeddedObject object; |
780 | 13 | STOFFVec2i size; |
781 | 13 | if (m_brush.getPattern(object, size) && object.m_dataList.size()) { |
782 | 13 | state.m_graphic.m_propertyList.insert("draw:fill", "bitmap"); |
783 | 13 | state.m_graphic.m_propertyList.insert("draw:fill-image", object.m_dataList[0].getBase64Data()); |
784 | 13 | state.m_graphic.m_propertyList.insert("draw:fill-image-width", size[0], librevenge::RVNG_POINT); |
785 | 13 | state.m_graphic.m_propertyList.insert("draw:fill-image-height", size[1], librevenge::RVNG_POINT); |
786 | 13 | state.m_graphic.m_propertyList.insert("draw:fill-image-ref-point-x",0, librevenge::RVNG_POINT); |
787 | 13 | state.m_graphic.m_propertyList.insert("draw:fill-image-ref-point-y",0, librevenge::RVNG_POINT); |
788 | 13 | state.m_graphic.m_propertyList.insert("librevenge:mime-type", object.m_typeList.empty() ? "image/pict" : object.m_typeList[0].c_str()); |
789 | 13 | } |
790 | 0 | else |
791 | 0 | state.m_graphic.m_propertyList.insert("draw:fill", "none"); |
792 | 13 | } |
793 | 315 | } |
794 | | // SW table |
795 | 517 | if (m_brush.isEmpty()) |
796 | 202 | state.m_cell.m_propertyList.insert("fo:background-color", "transparent"); |
797 | 315 | else { |
798 | 315 | STOFFColor color; |
799 | 315 | if (m_brush.getColor(color)) |
800 | 315 | state.m_cell.m_propertyList.insert("fo:background-color", color.str().c_str()); |
801 | 0 | else { |
802 | 0 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBrush::addTo: can not set a cell background\n")); |
803 | 0 | state.m_cell.m_propertyList.insert("fo:background-color", "transparent"); |
804 | 0 | } |
805 | 315 | } |
806 | | // Frame |
807 | 517 | if (!m_brush.isEmpty()) { |
808 | 315 | STOFFColor color; |
809 | 315 | if (m_brush.getColor(color)) |
810 | 315 | state.m_frame.m_propertyList.insert("fo:background-color", color.str().c_str()); |
811 | 315 | } |
812 | 517 | } |
813 | | // cell |
814 | 69.7k | else if (m_type == ATTR_SC_BACKGROUND) { |
815 | 69.7k | if (m_brush.isEmpty()) { |
816 | 30.0k | state.m_cell.m_propertyList.insert("fo:background-color", "transparent"); |
817 | 30.0k | return; |
818 | 30.0k | } |
819 | | |
820 | 39.6k | STOFFColor color; |
821 | 39.6k | #if 1 |
822 | 39.6k | if (m_brush.getColor(color)) { |
823 | 39.6k | state.m_cell.m_propertyList.insert("fo:background-color", color.str().c_str()); |
824 | 39.6k | return; |
825 | 39.6k | } |
826 | 0 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBrush::addTo: can not set a cell background\n")); |
827 | 0 | state.m_cell.m_propertyList.insert("fo:background-color", "transparent"); |
828 | | #else |
829 | | /* checkme, is it possible to use style:background-image here ? |
830 | | Can not create any working ods file with bitmap cell's background... |
831 | | */ |
832 | | if (m_brush.hasUniqueColor() && m_brush.getColor(color)) { |
833 | | state.m_cell.m_propertyList.insert("fo:background-color", color.str().c_str()); |
834 | | return; |
835 | | } |
836 | | STOFFEmbeddedObject object; |
837 | | STOFFVec2i size; |
838 | | if (m_brush.getPattern(object, size) && object.m_dataList.size()) { |
839 | | librevenge::RVNGPropertyList backgroundList; |
840 | | backgroundList.insert("librevenge:bitmap", object.m_dataList[0].getBase64Data()); |
841 | | backgroundList.insert("xlink:type", "simple"); |
842 | | backgroundList.insert("xlink:show", "embed"); |
843 | | backgroundList.insert("xlink:actuate", "onLoad"); |
844 | | backgroundList.insert("style:filter-name", object.m_typeList.empty() ? "image/pict" : object.m_typeList[0].c_str()); |
845 | | if (m_brush.m_transparency>0 && m_brush.m_transparency<=255) |
846 | | backgroundList.insert("draw:opacity", 1.-double(m_brush.m_transparency)/255., librevenge::RVNG_PERCENT); |
847 | | if (m_brush.m_position>=1 && m_brush.m_position<=9) { |
848 | | int xPos=(m_brush.m_position-1)%3, yPos=(m_brush.m_position-1)%3; |
849 | | backgroundList.insert("style:position", |
850 | | (std::string(xPos==0 ? "left " : xPos==1 ? "center " : "right ")+ |
851 | | std::string(yPos==0 ? "top" : yPos==1 ? "center" : "bottom")).c_str()); |
852 | | } |
853 | | librevenge::RVNGPropertyListVector backgroundVector; |
854 | | backgroundVector.append(backgroundList); |
855 | | state.m_cell.m_propertyList.insert("librevenge:background-image", backgroundVector); |
856 | | } |
857 | | else { |
858 | | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBrush::addTo: can not set a cell background\n")); |
859 | | } |
860 | | #endif |
861 | 0 | } |
862 | 71.5k | } |
863 | | |
864 | | void StarFAttributeFrameSize::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
865 | 31.6k | { |
866 | 31.6k | if (m_type==ATTR_FRM_FRM_SIZE) { |
867 | 31.6k | if (m_width>0) { |
868 | 30.9k | state.m_frame.m_position.setSize(STOFFVec2f(float(m_width)*0.05f, state.m_frame.m_position.m_size[1])); |
869 | 30.9k | state.m_global->m_page.m_propertiesList[0].insert("fo:page-width", double(state.m_frame.m_position.m_size[0]), librevenge::RVNG_POINT); |
870 | 30.9k | } |
871 | 31.6k | if (m_height>0) { |
872 | 8.82k | state.m_frame.m_position.setSize(STOFFVec2f(state.m_frame.m_position.m_size[0], float(m_height)*0.05f)); |
873 | 8.82k | state.m_global->m_page.m_propertiesList[0].insert("fo:page-height", double(state.m_frame.m_position.m_size[1]), librevenge::RVNG_POINT); |
874 | 8.82k | } |
875 | 31.6k | } |
876 | 31.6k | } |
877 | | |
878 | | void StarFAttributeLineNumbering::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
879 | 2.52k | { |
880 | 2.52k | if (m_type==ATTR_FRM_LINENUMBER) { |
881 | 2.52k | if (m_start>=0 && m_countLines) { |
882 | 371 | state.m_paragraph.m_propertyList.insert("text:number-lines", true); |
883 | 371 | state.m_paragraph.m_propertyList.insert("text:line-number", m_start==0 ? 1 : int(m_start)); |
884 | 371 | } |
885 | 2.52k | } |
886 | 2.52k | } |
887 | | |
888 | | void StarFAttributeLRSpace::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
889 | 55.5k | { |
890 | | // paragraph |
891 | 55.5k | if (m_type==ATTR_FRM_LR_SPACE || m_type==ATTR_EE_PARA_OUTLLR_SPACE) { |
892 | 55.5k | if (m_propMargins[0]==100) // unsure if/when we need to use textLeft/margins[0] here |
893 | 54.2k | state.m_paragraph.m_propertyList.insert("fo:margin-left", state.m_global->m_relativeUnit*double(m_textLeft), librevenge::RVNG_POINT); |
894 | 1.33k | else |
895 | 1.33k | state.m_paragraph.m_propertyList.insert("fo:margin-left", double(m_propMargins[0])/100., librevenge::RVNG_PERCENT); |
896 | | |
897 | 55.5k | if (m_propMargins[1]==100) |
898 | 53.2k | state.m_paragraph.m_propertyList.insert("fo:margin-right", state.m_global->m_relativeUnit*double(m_margins[1]), librevenge::RVNG_POINT); |
899 | 2.28k | else |
900 | 2.28k | state.m_paragraph.m_propertyList.insert("fo:margin-right", double(m_propMargins[1])/100., librevenge::RVNG_PERCENT); |
901 | 55.5k | if (m_propMargins[2]==100) |
902 | 53.0k | state.m_paragraph.m_propertyList.insert("fo:text-indent", state.m_global->m_relativeUnit*double(m_margins[2]), librevenge::RVNG_POINT); |
903 | 2.49k | else |
904 | 2.49k | state.m_paragraph.m_propertyList.insert("fo:text-indent", double(m_propMargins[2])/100., librevenge::RVNG_PERCENT); |
905 | | // m_textLeft: ok to ignore ? |
906 | 55.5k | state.m_paragraph.m_propertyList.insert("style:auto-text-indent", m_autoFirst); |
907 | 55.5k | } |
908 | | // frame |
909 | 55.5k | if (m_type==ATTR_FRM_LR_SPACE) { |
910 | 48.5k | if (m_propMargins[0]==100) |
911 | 47.3k | state.m_frame.m_propertyList.insert("fo:margin-left", state.m_global->m_relativeUnit*double(m_textLeft), librevenge::RVNG_POINT); |
912 | 1.17k | else |
913 | 1.17k | state.m_frame.m_propertyList.insert("fo:margin-left", double(m_propMargins[0])/100., librevenge::RVNG_PERCENT); |
914 | | |
915 | 48.5k | if (m_propMargins[1]==100) |
916 | 46.5k | state.m_frame.m_propertyList.insert("fo:margin-right", state.m_global->m_relativeUnit*double(m_margins[1]), librevenge::RVNG_POINT); |
917 | 2.02k | else |
918 | 2.02k | state.m_frame.m_propertyList.insert("fo:margin-right", double(m_propMargins[1])/100., librevenge::RVNG_PERCENT); |
919 | 48.5k | } |
920 | | // page |
921 | 55.5k | if (m_type==ATTR_FRM_LR_SPACE && state.m_global->m_pageZone<=2) { |
922 | 48.5k | if (m_propMargins[0]==100) |
923 | 47.3k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-left", double(m_margins[0])*0.05, librevenge::RVNG_POINT); |
924 | 1.17k | else |
925 | 1.17k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-left", double(m_propMargins[0])/100., librevenge::RVNG_PERCENT); |
926 | | |
927 | 48.5k | if (m_propMargins[1]==100) |
928 | 46.5k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-right", double(m_margins[1])*0.05, librevenge::RVNG_POINT); |
929 | 2.02k | else |
930 | 2.02k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-right", double(m_propMargins[1])/100., librevenge::RVNG_PERCENT); |
931 | 48.5k | } |
932 | 55.5k | } |
933 | | |
934 | | void StarFAttributeOrientation::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
935 | 12.6k | { |
936 | 12.6k | if (m_type==StarAttribute::ATTR_FRM_HORI_ORIENT) { |
937 | | // NONE,RIGHT,CENTER, LEFT,INSIDE,OUTSIDE,FULL, LEFT_AND_WIDTH |
938 | 7.83k | char const *wh[]= {nullptr, "right", "center", "left", "inside", "outside", nullptr, "from-left"}; |
939 | 7.83k | if (m_orient>=0 && m_orient<=7 && wh[m_orient]) |
940 | 5.04k | state.m_frame.m_propertyList.insert("style:horizontal-pos", wh[m_orient]); |
941 | | |
942 | 7.83k | switch (m_orient) { |
943 | 2.47k | case 0: // default |
944 | 2.47k | break; |
945 | 142 | case 1: |
946 | 1.41k | case 2: |
947 | 1.42k | case 3: { // CHECKME |
948 | 1.42k | char const *align[]= {"start", "center", "left"}; |
949 | 1.42k | state.m_frame.m_propertyList.insert("fo:text-align", align[m_orient-1]); |
950 | 1.42k | break; |
951 | 1.41k | } |
952 | 160 | case 6: |
953 | 160 | state.m_frame.m_propertyList.insert("fo:text-align", "justify"); |
954 | 160 | break; |
955 | 3.78k | default: // TODO |
956 | 3.78k | break; |
957 | 7.83k | } |
958 | | // the relative position, FRAME, PRTAREA, CHAR, PG_LEFT, PG_RIGTH, FRM_LEFT, FRM_RIGHT, PG_FRAME, PG_PTRAREA |
959 | 7.83k | char const *relat[]= { "frame", nullptr, "char", "page-start-margin", "page-left-margin", "frame-start-margin", |
960 | 7.83k | "frame-end-margin", "page", "page" |
961 | 7.83k | }; |
962 | 7.83k | if (m_relat>=0 && m_relat<=8 && relat[m_relat]) |
963 | 3.52k | state.m_frame.m_propertyList.insert("style:horizontal-rel", relat[m_relat]); |
964 | 7.83k | if (m_position) |
965 | 3.58k | state.m_frame.m_position.m_propertyList.insert("svg:x", double(m_position)*0.05, librevenge::RVNG_POINT); |
966 | 7.83k | } |
967 | 4.79k | else if (m_type==StarAttribute::ATTR_FRM_VERT_ORIENT) { |
968 | | // NONE,TOP,CENTER,BOTTOM,CHAR_TOP,CHAR_CENTER,CHAR_BOTTOM,LINE_TOP,LINE_CENTER,LINE_BOTTOM |
969 | 4.79k | if (m_orient>0 && m_orient<=9) { |
970 | 2.42k | switch (m_orient%3) { |
971 | 314 | case 0: // BOTTOM, CHAR_BOTTOM, LINE_BOTTOM |
972 | 314 | state.m_frame.m_propertyList.insert("style:vertical-pos", "bottom"); |
973 | 314 | break; |
974 | 1.21k | case 1: // TOP, CHAR_TOP, LINE_TOP |
975 | 1.21k | state.m_frame.m_propertyList.insert("style:vertical-pos", m_position ? "from-top" : "top"); |
976 | 1.21k | break; |
977 | 903 | case 2: // CENTER, CHAR_CENTER, LINE_CENTER |
978 | 903 | state.m_frame.m_propertyList.insert("style:vertical-pos", "middle"); |
979 | 903 | break; |
980 | 0 | default: // nothing |
981 | 0 | break; |
982 | 2.42k | } |
983 | 2.42k | switch ((m_orient-1)/3) { |
984 | 835 | case 1: |
985 | 835 | state.m_frame.m_propertyList.insert("style:vertical-rel", "char"); |
986 | 835 | break; |
987 | 103 | case 2: |
988 | 103 | state.m_frame.m_propertyList.insert("style:vertical-rel", "line"); |
989 | 103 | break; |
990 | 1.48k | default: |
991 | 1.48k | break; |
992 | 2.42k | } |
993 | 2.42k | } |
994 | | // the relative position, FRAME, PRTAREA, CHAR, PG_LEFT, PG_RIGTH, FRM_LEFT, FRM_RIGHT, PG_FRAME, PG_PTRAREA |
995 | 4.79k | switch (m_relat) { |
996 | 3.91k | case 0: // FRAME |
997 | 3.92k | case 5: // FRM_LEFT |
998 | 3.93k | case 6: // FRM_RIGHT |
999 | 3.93k | state.m_frame.m_propertyList.insert("style:vertical-rel", "frame"); |
1000 | 3.93k | break; |
1001 | 1 | case 2: |
1002 | 1 | state.m_frame.m_propertyList.insert("style:vertical-rel", "char"); |
1003 | 1 | break; |
1004 | 18 | case 3: // PG_LEFT |
1005 | 34 | case 4: // PG_RIGH |
1006 | 97 | case 7: // PG_FRAME |
1007 | 160 | case 8: // PG_PTRAREA |
1008 | 160 | state.m_frame.m_propertyList.insert("style:vertical-rel", "page"); |
1009 | 160 | break; |
1010 | 699 | default: |
1011 | 699 | break; |
1012 | 4.79k | } |
1013 | 4.79k | if (m_position) |
1014 | 2.99k | state.m_frame.m_position.m_propertyList.insert("svg:y", double(m_position)*0.05, librevenge::RVNG_POINT); |
1015 | 4.79k | } |
1016 | 12.6k | } |
1017 | | |
1018 | | void StarFAttributeShadow::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
1019 | 811 | { |
1020 | | // graphic |
1021 | 811 | if (m_width<=0 || m_location<=0 || m_location>4 || m_transparency<0 || m_transparency>=255) |
1022 | 697 | state.m_graphic.m_propertyList.insert("draw:shadow", "hidden"); |
1023 | 114 | else { |
1024 | 114 | state.m_graphic.m_propertyList.insert("draw:shadow", "visible"); |
1025 | 114 | state.m_graphic.m_propertyList.insert("draw:shadow-color", m_color.str().c_str()); |
1026 | 114 | state.m_graphic.m_propertyList.insert("draw:shadow-opacity", 1.-double(m_transparency)/255., librevenge::RVNG_PERCENT); |
1027 | 114 | state.m_graphic.m_propertyList.insert("draw:shadow-offset-x", ((m_location%2)?-1:1)*state.convertInPoint(m_width), librevenge::RVNG_POINT); |
1028 | 114 | state.m_graphic.m_propertyList.insert("draw:shadow-offset-y", (m_location<=2?-1:1)*state.convertInPoint(m_width), librevenge::RVNG_POINT); |
1029 | 114 | } |
1030 | | // cell |
1031 | 811 | if (m_width<=0 || m_location<=0 || m_location>4 || m_transparency<0 || m_transparency>=100) |
1032 | 698 | state.m_cell.m_propertyList.insert("style:shadow", "none"); |
1033 | 113 | else { |
1034 | 113 | std::stringstream s; |
1035 | 113 | s << m_color.str().c_str() << " " |
1036 | 113 | << ((m_location%2)?-1:1)*double(m_width)/20. << "pt " |
1037 | 113 | << (m_location<=2?-1:1)*double(m_width)/20. << "pt"; |
1038 | 113 | state.m_cell.m_propertyList.insert("style:shadow", s.str().c_str()); |
1039 | 113 | } |
1040 | 811 | } |
1041 | | |
1042 | | void StarFAttributeSurround::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
1043 | 1.20k | { |
1044 | 1.20k | int surround = m_surround; // NONE, THROUGH, PARALLEL, IDEAL, LEFT, RIGHT, END |
1045 | 1.20k | if (m_bools[0] && surround>1) surround=3; |
1046 | 1.20k | if (surround>=0 && surround<=5) { |
1047 | 1.13k | char const *wh[]= {"none", "run-through", "parallel", "dynamic", "left", "right"}; |
1048 | 1.13k | state.m_frame.m_propertyList.insert("style:wrap", wh[surround]); |
1049 | 1.13k | } |
1050 | | // checkme what is bAnchorOnly : m_bools[1] |
1051 | 1.20k | state.m_frame.m_propertyList.insert("style:wrap-countour", m_bools[2]); |
1052 | 1.20k | state.m_frame.m_propertyList.insert("style:wrap-contour-mode", m_bools[3] ? "outside" : "full"); |
1053 | 1.20k | } |
1054 | | |
1055 | | void StarFAttributeULSpace::addTo(StarState &state, std::set<StarAttribute const *> &/*done*/) const |
1056 | 46.9k | { |
1057 | | // paragraph |
1058 | 46.9k | if (m_type==ATTR_FRM_UL_SPACE) { |
1059 | 46.9k | if (m_propMargins[0]==100) |
1060 | 45.9k | state.m_paragraph.m_propertyList.insert("fo:margin-top", state.m_global->m_relativeUnit*double(m_margins[0]), librevenge::RVNG_POINT); |
1061 | 1.07k | else |
1062 | 1.07k | state.m_paragraph.m_propertyList.insert("fo:margin-top", double(m_propMargins[0])/100., librevenge::RVNG_PERCENT); |
1063 | | |
1064 | 46.9k | if (m_propMargins[1]==100) |
1065 | 45.8k | state.m_paragraph.m_propertyList.insert("fo:margin-bottom", state.m_global->m_relativeUnit*double(m_margins[1]), librevenge::RVNG_POINT); |
1066 | 1.12k | else |
1067 | 1.12k | state.m_paragraph.m_propertyList.insert("fo:margin-bottom", double(m_propMargins[1])/100., librevenge::RVNG_PERCENT); |
1068 | 46.9k | } |
1069 | | // page |
1070 | 46.9k | if (m_type==ATTR_FRM_UL_SPACE && state.m_global->m_pageZone<=2) { |
1071 | 46.9k | if (m_propMargins[0]==100) |
1072 | 45.9k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-top", double(m_margins[0])*0.05, librevenge::RVNG_POINT); |
1073 | 1.07k | else |
1074 | 1.07k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-top", double(m_propMargins[0])/100., librevenge::RVNG_PERCENT); |
1075 | | |
1076 | 46.9k | if (m_propMargins[1]==100) |
1077 | 45.8k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-bottom", double(m_margins[1])*0.05, librevenge::RVNG_POINT); |
1078 | 1.12k | else |
1079 | 1.12k | state.m_global->m_page.m_propertiesList[state.m_global->m_pageZone].insert("fo:margin-bottom", double(m_propMargins[1])/100., librevenge::RVNG_PERCENT); |
1080 | 46.9k | } |
1081 | 46.9k | } |
1082 | | |
1083 | | bool StarFAttributeAnchor::read(StarZone &zone, int nVers, long endPos, StarObject &/*object*/) |
1084 | 11.0k | { |
1085 | 11.0k | STOFFInputStreamPtr input=zone.input(); |
1086 | 11.0k | long pos=input->tell(); |
1087 | 11.0k | libstoff::DebugFile &ascFile=zone.ascii(); |
1088 | 11.0k | libstoff::DebugStream f; |
1089 | 11.0k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1090 | 11.0k | m_anchor=int(input->readULong(1)); |
1091 | 11.0k | bool ok=true; |
1092 | 11.0k | if (nVers<1) |
1093 | 4.26k | m_index=int(input->readULong(2)); |
1094 | 6.75k | else { |
1095 | 6.75k | unsigned long nId; |
1096 | 6.75k | if (!input->readCompressedULong(nId)) { |
1097 | 564 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBorder::read: can not read nId\n")); |
1098 | 564 | f << "###nId,"; |
1099 | 564 | ok=false; |
1100 | 564 | } |
1101 | 6.19k | else |
1102 | 6.19k | m_index=int(nId); |
1103 | 6.75k | } |
1104 | 11.0k | if (!ok) { |
1105 | 564 | if (input->tell()+8 > endPos) { |
1106 | 118 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBorder::read: try to use endPos\n")); |
1107 | 118 | ok=true; |
1108 | 118 | input->seek(endPos, librevenge::RVNG_SEEK_SET); |
1109 | 118 | } |
1110 | 446 | else |
1111 | 446 | f << "###extra,"; |
1112 | 564 | } |
1113 | 11.0k | printData(f); |
1114 | 11.0k | ascFile.addPos(pos); |
1115 | 11.0k | ascFile.addNote(f.str().c_str()); |
1116 | 11.0k | return ok && input->tell()<=endPos; |
1117 | 11.0k | } |
1118 | | |
1119 | | bool StarFAttributeBorder::read(StarZone &zone, int nVers, long endPos, StarObject &/*object*/) |
1120 | 48.4k | { |
1121 | 48.4k | STOFFInputStreamPtr input=zone.input(); |
1122 | 48.4k | long pos=input->tell(); |
1123 | 48.4k | libstoff::DebugFile &ascFile=zone.ascii(); |
1124 | 48.4k | libstoff::DebugStream f; |
1125 | 48.4k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1126 | 48.4k | m_distance=int(input->readULong(2)); |
1127 | 48.4k | int cLine=0; |
1128 | 48.4k | bool ok=true; |
1129 | 138k | while (input->tell()<endPos) { |
1130 | 137k | cLine=int(input->readULong(1)); |
1131 | 137k | if (cLine>3) break; |
1132 | 90.6k | STOFFBorderLine border; |
1133 | 90.6k | if (!input->readColor(border.m_color)) { |
1134 | 875 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBorder::read: can not find a box's color\n")); |
1135 | 875 | f << "###color,"; |
1136 | 875 | ok=false; |
1137 | 875 | break; |
1138 | 875 | } |
1139 | 89.8k | border.m_outWidth=int(input->readULong(2)); |
1140 | 89.8k | border.m_inWidth=int(input->readULong(2)); |
1141 | 89.8k | border.m_distance=int(input->readULong(2)); |
1142 | 89.8k | m_borders[cLine]=border; |
1143 | 89.8k | } |
1144 | 48.4k | if (ok && nVers>=1 && cLine&0x10) { |
1145 | 2.58k | if (input->tell()+8 > endPos) { |
1146 | 250 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeBorder::read: can not find the box's borders\n")); |
1147 | 250 | f << "###distances,"; |
1148 | 250 | } |
1149 | 2.33k | else { |
1150 | 9.35k | for (int &distance : m_distances) distance=int(input->readULong(2)); |
1151 | 2.33k | } |
1152 | 2.58k | } |
1153 | 48.4k | printData(f); |
1154 | 48.4k | ascFile.addPos(pos); |
1155 | 48.4k | ascFile.addNote(f.str().c_str()); |
1156 | 48.4k | return ok && input->tell()<=endPos; |
1157 | 48.4k | } |
1158 | | |
1159 | | bool StarFAttributeBrush::read(StarZone &zone, int nVers, long endPos, StarObject &object) |
1160 | 33.4k | { |
1161 | 33.4k | STOFFInputStreamPtr input=zone.input(); |
1162 | 33.4k | long pos=input->tell(); |
1163 | 33.4k | libstoff::DebugFile &ascFile=zone.ascii(); |
1164 | 33.4k | libstoff::DebugStream f; |
1165 | 33.4k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1166 | 33.4k | bool transparent=false; |
1167 | 33.4k | *input>>transparent; |
1168 | 33.4k | bool ok=m_brush.read(zone, nVers, endPos, object); |
1169 | 33.4k | if (!ok) |
1170 | 2.76k | f << "###brush,"; |
1171 | 33.4k | if (transparent) |
1172 | 3.71k | m_brush.m_transparency=255; |
1173 | 33.4k | printData(f); |
1174 | 33.4k | ascFile.addPos(pos); |
1175 | 33.4k | ascFile.addNote(f.str().c_str()); |
1176 | 33.4k | return ok && input->tell()<=endPos; |
1177 | 33.4k | } |
1178 | | |
1179 | | bool StarFAttributeFrameSize::read(StarZone &zone, int nVers, long endPos, StarObject &/*object*/) |
1180 | 32.6k | { |
1181 | 32.6k | STOFFInputStreamPtr input=zone.input(); |
1182 | 32.6k | long pos=input->tell(); |
1183 | 32.6k | libstoff::DebugFile &ascFile=zone.ascii(); |
1184 | 32.6k | libstoff::DebugStream f; |
1185 | 32.6k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1186 | | // sw_sw3attr.cxx SwFmtFrmSize::Create |
1187 | 32.6k | m_frmType=int(input->readULong(1)); |
1188 | 32.6k | m_width=int(input->readLong(4)); |
1189 | 32.6k | m_height=int(input->readLong(4)); |
1190 | 32.6k | if (nVers>1) { |
1191 | 11.6k | int dim[2]; |
1192 | 23.2k | for (int &i : dim) i=int(input->readULong(1)); |
1193 | 11.6k | m_percent=STOFFVec2i(dim[0],dim[1]); |
1194 | 11.6k | } |
1195 | 32.6k | printData(f); |
1196 | 32.6k | ascFile.addPos(pos); |
1197 | 32.6k | ascFile.addNote(f.str().c_str()); |
1198 | 32.6k | return input->tell()<=endPos; |
1199 | 32.6k | } |
1200 | | |
1201 | | bool StarFAttributeLineNumbering::read(StarZone &zone, int /*vers*/, long endPos, StarObject &/*object*/) |
1202 | 1.27k | { |
1203 | 1.27k | STOFFInputStreamPtr input=zone.input(); |
1204 | 1.27k | long pos=input->tell(); |
1205 | 1.27k | libstoff::DebugFile &ascFile=zone.ascii(); |
1206 | 1.27k | libstoff::DebugStream f; |
1207 | 1.27k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1208 | | // sw_sw3attr.cxx SwFmtLineNumber::Create |
1209 | 1.27k | m_start=long(input->readULong(4)); |
1210 | 1.27k | *input >> m_countLines; |
1211 | | |
1212 | 1.27k | printData(f); |
1213 | 1.27k | ascFile.addPos(pos); |
1214 | 1.27k | ascFile.addNote(f.str().c_str()); |
1215 | 1.27k | return input->tell()<=endPos; |
1216 | 1.27k | } |
1217 | | |
1218 | | bool StarFAttributeLRSpace::read(StarZone &zone, int vers, long endPos, StarObject &/*object*/) |
1219 | 68.2k | { |
1220 | 68.2k | STOFFInputStreamPtr input=zone.input(); |
1221 | 68.2k | long pos=input->tell(); |
1222 | 68.2k | libstoff::DebugFile &ascFile=zone.ascii(); |
1223 | 68.2k | libstoff::DebugStream f; |
1224 | 68.2k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1225 | | // svx_frmitems.cxx: SvxLRSpaceItem::Create |
1226 | 272k | for (int i=0; i<3; ++i) { |
1227 | 204k | if (i<2) |
1228 | 136k | m_margins[i]=int(input->readULong(2)); |
1229 | 68.2k | else |
1230 | 68.2k | m_margins[i]=int(input->readLong(2)); |
1231 | 204k | m_propMargins[i]=int(input->readULong(vers>=1 ? 2 : 1)); |
1232 | 204k | } |
1233 | 68.2k | if (vers>=2) |
1234 | 65.4k | m_textLeft=int(input->readLong(2)); |
1235 | 68.2k | uint8_t autofirst=0; |
1236 | 68.2k | if (vers>=3) { |
1237 | 36.6k | *input >> autofirst; |
1238 | 36.6k | m_autoFirst=(autofirst&1); |
1239 | 36.6k | auto marker=long(input->readULong(4)); |
1240 | 36.6k | if (marker==0x599401FE) { |
1241 | 6.80k | m_margins[2]=int(input->readLong(2)); |
1242 | 6.80k | if (m_margins[2]<0) |
1243 | 6.11k | m_margins[0]+=m_margins[2]; |
1244 | 6.80k | } |
1245 | 29.8k | else |
1246 | 29.8k | input->seek(-4, librevenge::RVNG_SEEK_CUR); |
1247 | 36.6k | } |
1248 | 68.2k | if (vers>=4 && (autofirst&0x80)) { // negative margin |
1249 | 838 | int32_t nMargin; |
1250 | 838 | *input >> nMargin; |
1251 | 838 | m_margins[0]=nMargin; |
1252 | 838 | *input >> nMargin; |
1253 | 838 | m_margins[1]=nMargin; |
1254 | 838 | } |
1255 | | //m_textLeft=(m_margins[2]>=0) ? m_margins[0] : m_margins[0]-m_margins[2]; |
1256 | 68.2k | printData(f); |
1257 | 68.2k | ascFile.addPos(pos); |
1258 | 68.2k | ascFile.addNote(f.str().c_str()); |
1259 | 68.2k | return input->tell()<=endPos; |
1260 | 68.2k | } |
1261 | | |
1262 | | bool StarFAttributeOrientation::read(StarZone &zone, int vers, long endPos, StarObject &/*object*/) |
1263 | 49.0k | { |
1264 | | // sw_sw3attr.cxx SwFmtVertOrient::Create |
1265 | 49.0k | STOFFInputStreamPtr input=zone.input(); |
1266 | 49.0k | long pos=input->tell(); |
1267 | 49.0k | libstoff::DebugFile &ascFile=zone.ascii(); |
1268 | 49.0k | libstoff::DebugStream f; |
1269 | 49.0k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1270 | 49.0k | *input >> m_position; |
1271 | 49.0k | m_orient=int(input->readULong(1)); |
1272 | 49.0k | m_relat=int(input->readULong(1)); |
1273 | 49.0k | if (m_type==StarAttribute::ATTR_FRM_HORI_ORIENT && vers>=1) |
1274 | 4.71k | *input>>m_posToggle; |
1275 | | // if (m_type==StarAttribute::ATTR_FRM_VERT_ORIENT && m_orient==0 && vers==0) |
1276 | | // m_relat=0; |
1277 | 49.0k | printData(f); |
1278 | 49.0k | ascFile.addPos(pos); |
1279 | 49.0k | ascFile.addNote(f.str().c_str()); |
1280 | 49.0k | return input->tell()<=endPos; |
1281 | 49.0k | } |
1282 | | |
1283 | | bool StarFAttributeShadow::read(StarZone &zone, int /*vers*/, long endPos, StarObject &/*object*/) |
1284 | 1.71k | { |
1285 | 1.71k | STOFFInputStreamPtr input=zone.input(); |
1286 | 1.71k | long pos=input->tell(); |
1287 | 1.71k | libstoff::DebugFile &ascFile=zone.ascii(); |
1288 | 1.71k | libstoff::DebugStream f; |
1289 | 1.71k | bool ok=true; |
1290 | 1.71k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1291 | 1.71k | m_location=int(input->readULong(1)); |
1292 | 1.71k | m_width=int(input->readULong(2)); |
1293 | 1.71k | m_transparency=int(input->readULong(1)); |
1294 | 1.71k | if (!input->readColor(m_color)) { |
1295 | 825 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeShadow::read: can not find a fill color\n")); |
1296 | 825 | f << "###color,"; |
1297 | 825 | ok=false; |
1298 | 825 | } |
1299 | 1.71k | if (ok && !input->readColor(m_fillColor)) { |
1300 | 301 | STOFF_DEBUG_MSG(("StarFrameAttribute::StarFAttributeShadow::read: can not find a fill color\n")); |
1301 | 301 | f << "###fillcolor,"; |
1302 | 301 | ok=false; |
1303 | 301 | } |
1304 | 1.71k | if (ok) m_style=int(input->readULong(1)); |
1305 | | |
1306 | 1.71k | printData(f); |
1307 | 1.71k | ascFile.addPos(pos); |
1308 | 1.71k | ascFile.addNote(f.str().c_str()); |
1309 | 1.71k | return ok && input->tell()<=endPos; |
1310 | 1.71k | } |
1311 | | |
1312 | | bool StarFAttributeSurround::read(StarZone &zone, int vers, long endPos, StarObject &/*object*/) |
1313 | 41.7k | { |
1314 | 41.7k | STOFFInputStreamPtr input=zone.input(); |
1315 | 41.7k | long pos=input->tell(); |
1316 | 41.7k | libstoff::DebugFile &ascFile=zone.ascii(); |
1317 | 41.7k | libstoff::DebugStream f; |
1318 | 41.7k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1319 | 41.7k | m_surround = int(input->readULong(1)); |
1320 | 41.7k | if (vers<5) // ideal |
1321 | 1.05k | *input >> m_bools[0]; |
1322 | 41.7k | if (vers>1) // anchor only |
1323 | 41.2k | *input >> m_bools[1]; |
1324 | 41.7k | if (vers>2) // continuous only |
1325 | 41.2k | *input >> m_bools[2]; |
1326 | 41.7k | if (vers>3) // outside |
1327 | 41.1k | *input >> m_bools[2]; |
1328 | 41.7k | printData(f); |
1329 | 41.7k | ascFile.addPos(pos); |
1330 | 41.7k | ascFile.addNote(f.str().c_str()); |
1331 | 41.7k | return input->tell()<=endPos; |
1332 | 41.7k | } |
1333 | | |
1334 | | bool StarFAttributeULSpace::read(StarZone &zone, int vers, long endPos, StarObject &/*object*/) |
1335 | 47.6k | { |
1336 | 47.6k | STOFFInputStreamPtr input=zone.input(); |
1337 | 47.6k | long pos=input->tell(); |
1338 | 47.6k | libstoff::DebugFile &ascFile=zone.ascii(); |
1339 | 47.6k | libstoff::DebugStream f; |
1340 | 47.6k | f << "Entries(StarAttribute)[" << zone.getRecordLevel() << "]:"; |
1341 | 142k | for (int i=0; i<2; ++i) { |
1342 | 95.3k | m_margins[i]=int(input->readULong(2)); |
1343 | 95.3k | m_propMargins[i]=int(input->readULong(vers>=1 ? 2 : 1)); |
1344 | 95.3k | } |
1345 | 47.6k | printData(f); |
1346 | 47.6k | ascFile.addPos(pos); |
1347 | 47.6k | ascFile.addNote(f.str().c_str()); |
1348 | 47.6k | return input->tell()<=endPos; |
1349 | 47.6k | } |
1350 | | } |
1351 | | |
1352 | | namespace StarFrameAttribute |
1353 | | { |
1354 | | void addInitTo(std::map<int, std::shared_ptr<StarAttribute> > &map) |
1355 | 228k | { |
1356 | 228k | addAttributeBool(map, StarAttribute::ATTR_FRM_LAYOUT_SPLIT,"layout[split]", true); |
1357 | 228k | addAttributeUInt(map, StarAttribute::ATTR_FRM_BREAK,"para[break]",1,0); |
1358 | | |
1359 | 228k | map[StarAttribute::ATTR_FRM_LINENUMBER]=std::shared_ptr<StarAttribute>(new StarFAttributeLineNumbering(StarAttribute::ATTR_FRM_LINENUMBER,"lineNumbering")); |
1360 | 228k | map[StarAttribute::ATTR_FRM_LR_SPACE]=std::shared_ptr<StarAttribute>(new StarFAttributeLRSpace(StarAttribute::ATTR_FRM_LR_SPACE,"lrSpace")); |
1361 | 228k | map[StarAttribute::ATTR_EE_PARA_OUTLLR_SPACE]=std::shared_ptr<StarAttribute>(new StarFAttributeLRSpace(StarAttribute::ATTR_EE_PARA_OUTLLR_SPACE,"eeOutLrSpace")); |
1362 | 228k | map[StarAttribute::ATTR_FRM_UL_SPACE]=std::shared_ptr<StarAttribute>(new StarFAttributeULSpace(StarAttribute::ATTR_FRM_UL_SPACE,"ulSpace")); |
1363 | 228k | map[StarAttribute::ATTR_FRM_HORI_ORIENT]=std::shared_ptr<StarAttribute>(new StarFAttributeOrientation(StarAttribute::ATTR_FRM_HORI_ORIENT,"horiOrient")); |
1364 | 228k | map[StarAttribute::ATTR_FRM_VERT_ORIENT]=std::shared_ptr<StarAttribute>(new StarFAttributeOrientation(StarAttribute::ATTR_FRM_VERT_ORIENT,"vertOrient")); |
1365 | 228k | map[StarAttribute::ATTR_FRM_FRM_SIZE]=std::shared_ptr<StarAttribute>(new StarFAttributeFrameSize(StarAttribute::ATTR_FRM_FRM_SIZE,"frmSize")); |
1366 | 228k | map[StarAttribute::ATTR_FRM_ANCHOR]=std::shared_ptr<StarAttribute>(new StarFAttributeAnchor(StarAttribute::ATTR_FRM_ANCHOR,"frmAnchor")); |
1367 | 228k | map[StarAttribute::ATTR_FRM_BOX]=std::shared_ptr<StarAttribute>(new StarFAttributeBorder(StarAttribute::ATTR_FRM_BOX,"box")); |
1368 | 228k | map[StarAttribute::ATTR_SC_BORDER]=std::shared_ptr<StarAttribute>(new StarFAttributeBorder(StarAttribute::ATTR_SC_BORDER,"scBorder")); |
1369 | 228k | map[StarAttribute::ATTR_FRM_SHADOW]=std::shared_ptr<StarAttribute>(new StarFAttributeShadow(StarAttribute::ATTR_FRM_SHADOW,"shadow")); |
1370 | 228k | map[StarAttribute::ATTR_SC_SHADOW]=std::shared_ptr<StarAttribute>(new StarFAttributeShadow(StarAttribute::ATTR_SC_SHADOW,"shadow")); |
1371 | 228k | map[StarAttribute::ATTR_FRM_SURROUND]=std::shared_ptr<StarAttribute>(new StarFAttributeSurround(StarAttribute::ATTR_FRM_SURROUND,"surround")); |
1372 | 228k | map[StarAttribute::ATTR_CHR_BACKGROUND]=std::shared_ptr<StarAttribute>(new StarFAttributeBrush(StarAttribute::ATTR_CHR_BACKGROUND,"chrBackground")); |
1373 | 228k | map[StarAttribute::ATTR_FRM_BACKGROUND]=std::shared_ptr<StarAttribute>(new StarFAttributeBrush(StarAttribute::ATTR_FRM_BACKGROUND,"frmBackground")); |
1374 | 228k | map[StarAttribute::ATTR_SC_BACKGROUND]=std::shared_ptr<StarAttribute>(new StarFAttributeBrush(StarAttribute::ATTR_SC_BACKGROUND,"scBackground")); |
1375 | 228k | map[StarAttribute::ATTR_SCH_SYMBOL_BRUSH]=std::shared_ptr<StarAttribute>(new StarFAttributeBrush(StarAttribute::ATTR_SCH_SYMBOL_BRUSH,"symbold[brush]")); |
1376 | 228k | } |
1377 | | } |
1378 | | // vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |