summaryrefslogtreecommitdiff
path: root/external/libvisio/vsd-metadata.patch.1
blob: c06a09d5960498d035cf86f46ebd4c66c5e2d723 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
commit a7f7ccbd4089965511dc59c3ae7869b360c8ca9f
Author: Miklos Vajna <vmiklos@collabora.co.uk>
Date:   Tue Dec 2 17:05:23 2014 +0100

    Move _appendUCS4() to libvisio_utils

diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
index 822a5f4..083fd91 100644
--- a/src/lib/VSDContentCollector.cpp
+++ b/src/lib/VSDContentCollector.cpp
@@ -11,7 +11,6 @@
 #include <stack>
 #include <boost/spirit/include/classic.hpp>
 #include <unicode/ucnv.h>
-#include <unicode/utypes.h>
 #include <unicode/utf8.h>
 
 #include "VSDContentCollector.h"
@@ -33,27 +32,6 @@ static unsigned bitmapId = 0;
 
 #define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
 
-namespace
-{
-
-static void _appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character)
-{
-  // Convert carriage returns to new line characters
-  // Writerperfect/LibreOffice will replace them by <text:line-break>
-  if (ucs4Character == (UChar32) 0x0d || ucs4Character == (UChar32) 0x0e)
-    ucs4Character = (UChar32) '\n';
-
-  unsigned char outbuf[U8_MAX_LENGTH+1];
-  int i = 0;
-  U8_APPEND_UNSAFE(&outbuf[0], i, ucs4Character);
-  outbuf[i] = 0;
-
-  text.append((char *)outbuf);
-}
-
-} // anonymous namespace
-
-
 libvisio::VSDContentCollector::VSDContentCollector(
   librevenge::RVNGDrawingInterface *painter,
   std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
@@ -2870,7 +2848,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex
         ucs4Character = 0x20;
       else
         ucs4Character = symbolmap[*iter - 0x20];
-      _appendUCS4(text, ucs4Character);
+      appendUCS4(text, ucs4Character);
     }
   }
   else
@@ -2934,7 +2912,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex
           if (0x1e == ucs4Character)
             _appendField(text);
           else
-            _appendUCS4(text, ucs4Character);
+            appendUCS4(text, ucs4Character);
         }
       }
     }
@@ -2960,7 +2938,7 @@ void libvisio::VSDContentCollector::appendCharacters(librevenge::RVNGString &tex
         if (0xfffc == ucs4Character)
           _appendField(text);
         else
-          _appendUCS4(text, ucs4Character);
+          appendUCS4(text, ucs4Character);
       }
     }
   }
diff --git a/src/lib/libvisio_utils.cpp b/src/lib/libvisio_utils.cpp
index b137e24..e622417 100644
--- a/src/lib/libvisio_utils.cpp
+++ b/src/lib/libvisio_utils.cpp
@@ -107,6 +107,20 @@ const librevenge::RVNGString libvisio::getColourString(const Colour &c)
   return sColour;
 }
 
+void libvisio::appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character)
+{
+  // Convert carriage returns to new line characters
+  // Writerperfect/LibreOffice will replace them by <text:line-break>
+  if (ucs4Character == (UChar32) 0x0d || ucs4Character == (UChar32) 0x0e)
+    ucs4Character = (UChar32) '\n';
+
+  unsigned char outbuf[U8_MAX_LENGTH+1];
+  int i = 0;
+  U8_APPEND_UNSAFE(&outbuf[0], i, ucs4Character);
+  outbuf[i] = 0;
+
+  text.append((char *)outbuf);
+}
 
 
 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h
index 08ebb04..60be13f 100644
--- a/src/lib/libvisio_utils.h
+++ b/src/lib/libvisio_utils.h
@@ -47,6 +47,7 @@ typedef unsigned __int64 uint64_t;
 
 #include <librevenge/librevenge.h>
 #include <librevenge-stream/librevenge-stream.h>
+#include <unicode/utypes.h>
 
 // debug message includes source file and line number
 //#define VERBOSE_DEBUG 1
@@ -79,6 +80,8 @@ double readDouble(librevenge::RVNGInputStream *input);
 
 const librevenge::RVNGString getColourString(const Colour &c);
 
+void appendUCS4(librevenge::RVNGString &text, UChar32 ucs4Character);
+
 class EndOfStreamException
 {
 };
commit 005b45ddf64a8320a0143336d431a016507d2085
Author: Miklos Vajna <vmiklos@collabora.co.uk>
Date:   Tue Dec 2 17:01:35 2014 +0100

    fdo#86729 VSD: import metadata
    
    Only title as a start.

diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 955aac4..f4d86fa 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -39,6 +39,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \
 	VSDPages.cpp \
 	VSDParagraphList.cpp \
 	VSDParser.cpp \
+	VSDMetaData.cpp \
 	VSDShapeList.cpp \
 	VSDStencils.cpp \
 	VSDStyles.cpp \
@@ -58,6 +59,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \
 	VSDPages.h \
 	VSDParagraphList.h \
 	VSDParser.h \
+	VSDMetaData.h \
 	VSDShapeList.h \
 	VSDStencils.h \
 	VSDStyles.h \
diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in
index a51ac14..0f8dd91 100644
--- a/src/lib/Makefile.in
+++ b/src/lib/Makefile.in
@@ -131,10 +131,10 @@ am_libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_OBJECTS =  \
 	VSDInternalStream.lo VSDCharacterList.lo \
 	VSDContentCollector.lo VSDFieldList.lo VSDGeometryList.lo \
 	VSDOutputElementList.lo VSDPages.lo VSDParagraphList.lo \
-	VSDParser.lo VSDShapeList.lo VSDStencils.lo VSDStyles.lo \
-	VSDStylesCollector.lo VSDXMLHelper.lo VDXParser.lo \
-	VSDXMLParserBase.lo VSDXMLTokenMap.lo VSDXParser.lo \
-	VSDXTheme.lo VSDXMetaData.lo $(am__objects_1)
+	VSDParser.lo VSDMetaData.lo VSDShapeList.lo VSDStencils.lo \
+	VSDStyles.lo VSDStylesCollector.lo VSDXMLHelper.lo \
+	VDXParser.lo VSDXMLParserBase.lo VSDXMLTokenMap.lo \
+	VSDXParser.lo VSDXTheme.lo VSDXMetaData.lo $(am__objects_1)
 libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_OBJECTS = $(am_libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -400,6 +400,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \
 	VSDPages.cpp \
 	VSDParagraphList.cpp \
 	VSDParser.cpp \
+	VSDMetaData.cpp \
 	VSDShapeList.cpp \
 	VSDStencils.cpp \
 	VSDStyles.cpp \
@@ -419,6 +420,7 @@ libvisio_@VSD_MAJOR_VERSION@_@VSD_MINOR_VERSION@_la_SOURCES = \
 	VSDPages.h \
 	VSDParagraphList.h \
 	VSDParser.h \
+	VSDMetaData.h \
 	VSDShapeList.h \
 	VSDStencils.h \
 	VSDStyles.h \
@@ -539,6 +541,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDFieldList.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDGeometryList.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDInternalStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDMetaData.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDOutputElementList.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDPages.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VSDParagraphList.Plo@am__quote@
diff --git a/src/lib/VSDMetaData.cpp b/src/lib/VSDMetaData.cpp
new file mode 100644
index 0000000..209cc34
--- /dev/null
+++ b/src/lib/VSDMetaData.cpp
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * This file is part of the libvisio project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "VSDMetaData.h"
+#include <unicode/ucnv.h>
+
+libvisio::VSDMetaData::VSDMetaData()
+{
+}
+
+libvisio::VSDMetaData::~VSDMetaData()
+{
+}
+
+bool libvisio::VSDMetaData::parse(librevenge::RVNGInputStream *input)
+{
+  if (!input)
+    return false;
+
+  readPropertySetStream(input);
+
+  return true;
+}
+
+void libvisio::VSDMetaData::readPropertySetStream(librevenge::RVNGInputStream *input)
+{
+  // ByteOrder
+  input->seek(2, librevenge::RVNG_SEEK_CUR);
+  // Version
+  input->seek(2, librevenge::RVNG_SEEK_CUR);
+  // SystemIdentifier
+  input->seek(4, librevenge::RVNG_SEEK_CUR);
+  // CLSID
+  input->seek(16, librevenge::RVNG_SEEK_CUR);
+  // NumPropertySets
+  input->seek(4, librevenge::RVNG_SEEK_CUR);
+  // FMTID0
+  input->seek(16, librevenge::RVNG_SEEK_CUR);
+  uint32_t offset0 = readU32(input);
+  readPropertySet(input, offset0);
+}
+
+void libvisio::VSDMetaData::readPropertySet(librevenge::RVNGInputStream *input, uint32_t offset)
+{
+  input->seek(offset, librevenge::RVNG_SEEK_SET);
+
+  // Size
+  input->seek(4, librevenge::RVNG_SEEK_CUR);
+  uint32_t numProperties = readU32(input);
+  for (uint32_t i = 0; i < numProperties; ++i)
+    readPropertyIdentifierAndOffset(input);
+  for (uint32_t i = 0; i < numProperties; ++i)
+  {
+    if (i >= m_idsAndOffsets.size())
+      break;
+    readTypedPropertyValue(input, i, offset + m_idsAndOffsets[i].second);
+  }
+}
+
+#define CODEPAGE_PROPERTY_IDENTIFIER 0x00000001
+
+uint32_t libvisio::VSDMetaData::getCodePage()
+{
+  for (size_t i = 0; i < m_idsAndOffsets.size(); ++i)
+  {
+    if (m_idsAndOffsets[i].first == CODEPAGE_PROPERTY_IDENTIFIER)
+    {
+      if (i >= m_typedPropertyValues.size())
+        break;
+      return m_typedPropertyValues[i];
+    }
+  }
+
+  return 0;
+}
+
+void libvisio::VSDMetaData::readPropertyIdentifierAndOffset(librevenge::RVNGInputStream *input)
+{
+  uint32_t propertyIdentifier = readU32(input);
+  uint32_t offset = readU32(input);
+  m_idsAndOffsets.push_back(std::make_pair(propertyIdentifier, offset));
+}
+
+#define VT_I2 0x0002
+#define VT_LPSTR 0x001E
+
+#define PIDSI_TITLE 0x00000002
+
+void libvisio::VSDMetaData::readTypedPropertyValue(librevenge::RVNGInputStream *input, uint32_t index, uint32_t offset)
+{
+  input->seek(offset, librevenge::RVNG_SEEK_SET);
+  uint16_t type = readU16(input);
+  // Padding
+  input->seek(2, librevenge::RVNG_SEEK_CUR);
+
+  if (type == VT_I2)
+  {
+    uint16_t value = readU16(input);
+    m_typedPropertyValues[index] = value;
+  }
+  else if (type == VT_LPSTR)
+  {
+    librevenge::RVNGString string = readCodePageString(input);
+    if (!string.empty())
+    {
+      if (index >= m_idsAndOffsets.size())
+        return;
+
+      switch (m_idsAndOffsets[index].first)
+      {
+      case PIDSI_TITLE:
+        m_metaData.insert("dc:title", string);
+        break;
+      }
+    }
+  }
+}
+
+librevenge::RVNGString libvisio::VSDMetaData::readCodePageString(librevenge::RVNGInputStream *input)
+{
+  uint32_t size = readU32(input);
+
+  std::vector<unsigned char> characters;
+  for (uint32_t i = 0; i < size; ++i)
+    characters.push_back(readU8(input));
+
+  uint32_t codepage = getCodePage();
+  librevenge::RVNGString string;
+
+  if (codepage == 65001)
+  {
+    // http://msdn.microsoft.com/en-us/library/windows/desktop/dd374130%28v=vs.85%29.aspx
+    // says this is UTF-8.
+    for (std::vector<unsigned char>::const_iterator i = characters.begin(); i != characters.end(); ++i)
+      string.append((const char)*i);
+  }
+  else
+  {
+    UErrorCode status = U_ZERO_ERROR;
+    UConverter *conv = 0;
+
+    switch (codepage)
+    {
+    case 1252:
+      // http://msdn.microsoft.com/en-us/goglobal/bb964654
+      conv = ucnv_open("windows-1252", &status);
+      break;
+    }
+
+    if (U_SUCCESS(status) && conv)
+    {
+      const char *src = (const char *)&characters[0];
+      const char *srcLimit = (const char *)src + characters.size();
+      while (src < srcLimit)
+      {
+        UChar32 ucs4Character = ucnv_getNextUChar(conv, &src, srcLimit, &status);
+        if (U_SUCCESS(status) && U_IS_UNICODE_CHAR(ucs4Character))
+          appendUCS4(string, ucs4Character);
+      }
+    }
+
+    if (conv)
+      ucnv_close(conv);
+  }
+
+  return string;
+}
+
+const librevenge::RVNGPropertyList &libvisio::VSDMetaData::getMetaData()
+{
+  return m_metaData;
+}
+
+/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDMetaData.h b/src/lib/VSDMetaData.h
new file mode 100644
index 0000000..c185894
--- /dev/null
+++ b/src/lib/VSDMetaData.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * This file is part of the libvisio project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef __VSDMETADATA_H__
+#define __VSDMETADATA_H__
+
+#include <vector>
+#include <utility>
+#include <map>
+#include <librevenge-stream/librevenge-stream.h>
+#include <librevenge/librevenge.h>
+#include "libvisio_utils.h"
+
+namespace libvisio
+{
+
+class VSDMetaData
+{
+public:
+  VSDMetaData();
+  ~VSDMetaData();
+  bool parse(librevenge::RVNGInputStream *input);
+  const librevenge::RVNGPropertyList &getMetaData();
+
+private:
+  VSDMetaData(const VSDMetaData &);
+  VSDMetaData &operator=(const VSDMetaData &);
+
+  void readPropertySetStream(librevenge::RVNGInputStream *input);
+  void readPropertySet(librevenge::RVNGInputStream *input, uint32_t offset);
+  void readPropertyIdentifierAndOffset(librevenge::RVNGInputStream *input);
+  void readTypedPropertyValue(librevenge::RVNGInputStream *input, uint32_t index, uint32_t offset);
+  librevenge::RVNGString readCodePageString(librevenge::RVNGInputStream *input);
+
+  uint32_t getCodePage();
+
+  std::vector< std::pair<uint32_t, uint32_t> > m_idsAndOffsets;
+  std::map<uint16_t, uint16_t> m_typedPropertyValues;
+  librevenge::RVNGPropertyList m_metaData;
+};
+
+} // namespace libvisio
+
+#endif // __VSDMETADATA_H__
+/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 1b8133f..9d6e175 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -19,9 +19,10 @@
 #include "VSDDocumentStructure.h"
 #include "VSDContentCollector.h"
 #include "VSDStylesCollector.h"
+#include "VSDMetaData.h"
 
-libvisio::VSDParser::VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter)
-  : m_input(input), m_painter(painter), m_header(), m_collector(0), m_shapeList(), m_currentLevel(0),
+libvisio::VSDParser::VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container)
+  : m_input(input), m_painter(painter), m_container(container), m_header(), m_collector(0), m_shapeList(), m_currentLevel(0),
     m_stencils(), m_currentStencil(0), m_shape(), m_isStencilStarted(false), m_isInStyles(false),
     m_currentShapeLevel(0), m_currentShapeID(MINUS_ONE), m_extractStencils(false), m_colours(),
     m_isBackgroundPage(false), m_isShapeStarted(false), m_shadowOffsetX(0.0), m_shadowOffsetY(0.0),
@@ -136,6 +137,9 @@ bool libvisio::VSDParser::parseMain()
 
   VSDContentCollector contentCollector(m_painter, groupXFormsSequence, groupMembershipsSequence, documentPageShapeOrders, styles, m_stencils);
   m_collector = &contentCollector;
+  if (m_container)
+    parseMetaData();
+
   VSD_DEBUG_MSG(("VSDParser::parseMain 2nd pass\n"));
   if (!parseDocument(&trailerStream, shift))
     return false;
@@ -143,6 +147,25 @@ bool libvisio::VSDParser::parseMain()
   return true;
 }
 
+bool libvisio::VSDParser::parseMetaData()
+{
+  if (!m_container)
+    return false;
+  m_container->seek(0, librevenge::RVNG_SEEK_SET);
+  if (!m_container->isStructured())
+    return false;
+  librevenge::RVNGInputStream *stream = m_container->getSubStreamByName("\x05SummaryInformation");
+  if (!stream)
+    return false;
+
+  VSDMetaData metaData;
+  metaData.parse(stream);
+  m_collector->collectMetaData(metaData.getMetaData());
+
+  delete stream;
+  return true;
+}
+
 bool libvisio::VSDParser::parseDocument(librevenge::RVNGInputStream *input, unsigned shift)
 {
   try
diff --git a/src/lib/VSDParser.h b/src/lib/VSDParser.h
index aabb0db..b2bba54 100644
--- a/src/lib/VSDParser.h
+++ b/src/lib/VSDParser.h
@@ -45,7 +45,7 @@ struct Pointer
 class VSDParser
 {
 public:
-  explicit VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter);
+  explicit VSDParser(librevenge::RVNGInputStream *input, librevenge::RVNGDrawingInterface *painter, librevenge::RVNGInputStream *container = 0);
   virtual ~VSDParser();
   bool parseMain();
   bool extractStencils();
@@ -113,6 +113,8 @@ protected:
   // parser of one pass
   bool parseDocument(librevenge::RVNGInputStream *input, unsigned shift);
 
+  bool parseMetaData();
+
   // Stream handlers
   void handleStreams(librevenge::RVNGInputStream *input, unsigned ptrType, unsigned shift, unsigned level);
   void handleStream(const Pointer &ptr, unsigned idx, unsigned level);
@@ -133,6 +135,7 @@ protected:
 
   librevenge::RVNGInputStream *m_input;
   librevenge::RVNGDrawingInterface *m_painter;
+  librevenge::RVNGInputStream *m_container;
   ChunkHeader m_header;
   VSDCollector *m_collector;
   VSDShapeList m_shapeList;
diff --git a/src/lib/VisioDocument.cpp b/src/lib/VisioDocument.cpp
index be14b68..f834478 100644
--- a/src/lib/VisioDocument.cpp
+++ b/src/lib/VisioDocument.cpp
@@ -158,7 +158,7 @@ static bool parseBinaryVisioDocument(librevenge::RVNGInputStream *input, libreve
       parser = new libvisio::VSD6Parser(docStream, painter);
       break;
     case 11:
-      parser = new libvisio::VSDParser(docStream, painter);
+      parser = new libvisio::VSDParser(docStream, painter, input);
       break;
     default:
       break;
commit 2e467f4e487bd8fd8440057e1d79f89b2a966419
Author: Miklos Vajna <vmiklos@collabora.co.uk>
Date:   Tue Dec 2 17:02:14 2014 +0100

    fdo#86664 VSD: import Creation/ModifiedTime

diff --git a/src/lib/VSDMetaData.cpp b/src/lib/VSDMetaData.cpp
index 209cc34..3fd5bf9 100644
--- a/src/lib/VSDMetaData.cpp
+++ b/src/lib/VSDMetaData.cpp
@@ -8,6 +8,7 @@
  */
 
 #include "VSDMetaData.h"
+#include <cmath>
 #include <unicode/ucnv.h>
 
 libvisio::VSDMetaData::VSDMetaData()
@@ -172,6 +173,58 @@ librevenge::RVNGString libvisio::VSDMetaData::readCodePageString(librevenge::RVN
   return string;
 }
 
+bool libvisio::VSDMetaData::parseTimes(librevenge::RVNGInputStream *input)
+{
+  // Parse the header
+  // HeaderSignature: 8 bytes
+  // HeaderCLSID: 16 bytes
+  // MinorVersion: 2 bytes
+  // MajorVersion: 2 bytes
+  // ByteOrder: 2 bytes
+  input->seek(30, librevenge::RVNG_SEEK_CUR);
+  uint16_t sectorShift = readU16(input);
+  // MiniSectorShift: 2 bytes
+  // Reserved: 6 bytes
+  // NumDirectorySectors: 4 bytes
+  // NumFATSectors: 4 bytes
+  input->seek(16, librevenge::RVNG_SEEK_CUR);
+  uint32_t firstDirSectorLocation = readU32(input);
+
+  // Seek to the Root Directory Entry
+  size_t sectorSize = pow(2, sectorShift);
+  input->seek((firstDirSectorLocation + 1) * sectorSize, librevenge::RVNG_SEEK_SET);
+  // DirectoryEntryName: 64 bytes
+  // DirectoryEntryNameLength: 2 bytes
+  // ObjectType: 1 byte
+  // ColorFlag: 1 byte
+  // LeftSiblingID: 4 bytes
+  // RightSiblingID: 4 bytes
+  // ChildID: 4 bytes
+  // CLSID: 16 bytes
+  // StateBits: 4 bytes
+  // CreationTime: 8 bytes
+  input->seek(108, librevenge::RVNG_SEEK_CUR);
+  uint64_t modifiedTime = readU64(input);
+
+  // modifiedTime is number of 100ns since Jan 1 1601
+  static const uint64_t epoch = 11644473600;
+  time_t sec = (modifiedTime / 10000000) - epoch;
+  const struct tm *time = localtime(&sec);
+  if (time)
+  {
+    static const int MAX_BUFFER = 1024;
+    char buffer[MAX_BUFFER];
+    strftime(&buffer[0], MAX_BUFFER-1, "%Y-%m-%dT%H:%M:%SZ", time);
+    librevenge::RVNGString result;
+    result.append(buffer);
+    // Visio UI uses modifiedTime for both purposes.
+    m_metaData.insert("meta:creation-date", result);
+    m_metaData.insert("dc:date", result);
+    return true;
+  }
+  return false;
+}
+
 const librevenge::RVNGPropertyList &libvisio::VSDMetaData::getMetaData()
 {
   return m_metaData;
diff --git a/src/lib/VSDMetaData.h b/src/lib/VSDMetaData.h
index c185894..581b0a2 100644
--- a/src/lib/VSDMetaData.h
+++ b/src/lib/VSDMetaData.h
@@ -26,6 +26,7 @@ public:
   VSDMetaData();
   ~VSDMetaData();
   bool parse(librevenge::RVNGInputStream *input);
+  bool parseTimes(librevenge::RVNGInputStream *input);
   const librevenge::RVNGPropertyList &getMetaData();
 
 private:
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
index 9d6e175..3af5bd0 100644
--- a/src/lib/VSDParser.cpp
+++ b/src/lib/VSDParser.cpp
@@ -160,6 +160,8 @@ bool libvisio::VSDParser::parseMetaData()
 
   VSDMetaData metaData;
   metaData.parse(stream);
+  m_container->seek(0, librevenge::RVNG_SEEK_SET);
+  metaData.parseTimes(m_container);
   m_collector->collectMetaData(metaData.getMetaData());
 
   delete stream;