# vsdump: test program to dump and parse content of vsd file
#
# Copyright (C) 2006-2007	Valek Filippov (frob@df.ru)
#
# This file is dual-licensed (GPLv3 and ASLv2).
# 
# =======================================================================
#  Licensed to the Apache Software Foundation (ASF) under one or more
#  contributor license agreements.  See the NOTICE file distributed with
#  this work for additional information regarding copyright ownership.
#  The ASF licenses this file to You under the Apache License, Version 2.0
#  (the "License"); you may not use this file except in compliance with
#  the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
# =======================================================================
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 or later of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
# USA
# =======================================================================
#
# version 0.0.45
#
# Need to extend with 'format' field for conversion length (inch->mm), angles(rad->degree) and enums (e.g.
# for aligns -- left/right/justify etc.
#
# The Format description for .tbl file.
# Lines start with # are comments.
# Every list of commands starts with 'start ch_type'
# and ends with 'end'.
# In between start and end are space-separeted lines
# with 'type', 'offset', 'name' values.  
# Atm I use 'atoi', so only decimal value is allowed for ch_type, type and offset.
# The possible values for 'type' are:
# 0..7  - flag at bit 0..7 at offset 'offset'
# 8	  - 1 byte value
# 9	  - 8 bytes IEEE-754 fraction
# 10(a) - name of chunk (we must start with a name atm, because with parse for printing)
# 11(b) - offset to start of blocks 
# 12(c) - text block
# 13(d) - some "name" from the list
# 14(e) - one byte "function" from the list
# 15(f) - some "function" from the list
# 16	  - string, next byte is length terminating '0' wasn't added to length
# 17	  - 'ForeignData'
# 18	  - Dump it to file as-is
# 25    - 2 bytes LE
# 26    - 4 bytes LE
# 27	  - Tabs? [experimental]
# 21	- offset to start of blocks in version 11
# 28    - extension for image files [experimental]
# 29    - num of parts and type for OLE [experimental]
# 30    - 3 bytes RGB-color
# 31    - 9 bytes -- 1st is 'Unit', + 8 bytes IEEE-754 fraction

# Quick workaround for losing of 1st table
start 10
end

start 12
17 0 ForeignData
end

start 13
10 0 OLE_Info
29 0 0
18 0 0
end

start 14
10 0 Text
12 8 0
18 0 0
end

start 16
10 0 Data1
12 0 0
end

start 17
10 0 Data2
12 0 0
end

start 18
10 0 Data3
12 0 0
end

start 21
10 0 Stream15
9 53 Center X
9 61 Center Y
18 0 0
end

start 24
10 0 Stream18
18 0 0
end

start 25
10 0 FaceName
16 24 0
end

start 26
10 0 Stream1a
18 0 0
end

start 31
17 0 OLEData
end

start 40
10 0 Unknown 0x28
9 39 Unknown1
9 47 Unknown2
18 0 0
end

start 44
10 0 Unknown 0x2c
18 0 0
end

#seems to be text string
start 45
10 0 Unknown 0x2d
12 0 0
end

start 49
10 0 Stream31
18 0 0
end

start 66
10 0 Unknown 0x42
18 0 0
end

start 70
10 0 PageSheet
18 0 0
end

start 71
10 0 Shape ID Type="Group"
18 0 0
end

start 72
10 0 Shape ID Type="Shape"
26 53 LineStyle
26 61 FillStyle
26 69 TextStyle
18 0 0
end

start 74
10 0 StyleSheet
26 53 LineStyle
26 61 FillStyle
26 69 TextStyle
18 0 0
end

start 77
10 0 Shape ID Type="Guide"
18 0 0
end


start 78
10 0 Shape ID Type="Foreign"
18 0 0
end

start 79
10 0 DocumentSheet
26 53 LineStyle
26 61 FillStyle
26 69 TextStyle
18 0 0
end

start 100
10 0 Unknown 0x64
18 0 0
end

start 101
10 0 ShapeList
18 0 0
end

start 102
10 0 Unknown 0x66
18 0 0
end

start 103
10 0 Unknown 0x67
18 0 0
end

start 104
10 0 PropList
18 0 0
end

start 105
10 0 CharList
18 0 0
end

start 106
10 0 ParaList
18 0 0
end

start 107
10 0 Unknown 0x6b
18 0 0
end

start 108
10 0 GeomList
18 0 0
end

start 109
10 0 Unknown 0x6d
18 0 0
end

start 110
10 0 Unknown 0x6e
18 0 0
end

start 111
10 0 Unknown 0x6f
18 0 0
end

start 112
10 0 Unknown 0x70
18 0 0
end

start 113
10 0 ConnectionList
18 0 0
end

start 114
10 0 Unknown 0x72
18 0 0
end

start 115
10 0 Unknown 0x73
18 0 0
end

start 116
10 0 Unknown 0x74
18 0 0
end

start 117
10 0 Unknown 0x75
18 0 0
end

start 118
10 0 Unknown 0x76
18 0 0
end

start 130
10 0 Unknown 0x82
18 0 0
end

start 131
10 0 ShapeID
18 0 0
end

start 132
10 0 Event
8 20 TheText
11 36 BlockStarts
21 36 BlockStarts
18 0 0
end

start 133
10 0 Line
31 19 LineWeight
8 28 LineColor
8 33 LinePattern
9 35 Rounding
8 43 EndArrowSize
8 44 BeginArrow
8 45 EndArrow
8 47 BeginArrowSize
1 50 Color
2 50 Pattern
3 50 RoundingCap
4 50 LineEndEnd
5 50 LineEndBegin
6 50 EndSize
7 50 SqueareCap
0 51 BeginSize
11 54 BlockStarts
21 54 BlockStarts
18 0 0
end

start 134
10 0 Fill
8 19 FillForegnd
30 25 FillBkgnd
8 29 FillPattern
30 31 ShdwForegnd
8 35 ShdwBkgnd
8 40 ShdwPattern
31 42 ShapeShdwOffsetX
31 51 ShapeShdwOffsetY
9 69 ShapeShdwScaleFactor
11 44 BlockStarts
21 80 BlockStarts
18 0 0
end

start 135
10 0 TextBlock
31 19 LeftMargin
31 28 RightMargin
31 37 TopMargin
31 46 BottomMargin
8 55 VerticalAlign
30 56 TextBkgnd
9 62 DefaultTabStop
8 82 TextDirection
11 90 BlockStarts
21 111 BlockStarts
18 0 0
end

start 136
10 0 Tabs
11 26 BlocksStart
21 26 BlocksStart
18 0 0
end

start 137
10 0 Geometry
0 19 NoFill
1 19 NoLine
2 19 NoShow
3 19 NoSnap
21 22 BlocksStart
18 0 0
end

start 138
10 0 MoveTo
9 20 X
9 29 Y
11 39 BlocksStart
21 39 BlocksStart
end

start 139
10 0 LineTo
9 20 X
9 29 Y
11 39 BlocksStart
21 39 BlocksStart
end

start 140
10 0 ArcTo
9 20 X
9 29 Y
9 38 A
11 48 BlocksStart
18 0 0
end

start 141
10 0 InfiniteLine
9 20 X
9 29 Y
9 37 A
9 45 B
11 57 BlocksStart
18 0 0
end

start 143
10 0 Ellipse
9 20 X
9 29 Y
9 38 A
9 47 B
9 56 C
9 65 D
11 75 BlocksStart
18 0 0
end

start 144
10 0 EllipticalArcTo
31 19 X
31 28 Y
31 37 A
31 46 B
31 55 C
31 64 D
11 75 BlocksStart
18 0 0
end

start 146
10 0 PageProps
9 20 PageWidth
9 29 PageHeight
9 38 ShdwOffsetX
9 47 ShdwOffsetY
9 56 PageScale
9 65 DrawingScale
8 73 DrawingSizeType
8 74 DrawingScaleType
0 93 InhibitSnap
11 150 BlockStarts
18 0 0
end

start 147
10 0 StyleProp
8 19 EnableLineProps
8 20 EnableFillProps
8 21 EnableTextProps
8 22 HideForApply
11 26 BlocksStart
21 26 BlocksStart
18 0 0
end

start 148
10 0 Char
25 23 FontNum
30 26 Color
8 29 Transparency*255/100%
0 30 Bold
1 30 Italic
2 30 Underline
3 30 Smallcaps
0 31 AllCaps
1 31 InitCaps
0 32 Subscript
1 32 Superscipt
25 33 Scale*100 %
8 35 LangCode
31 36 Size
25 46 Spacing pt*200
25 56 AsianFont
25 58 ComplexScriptFont
8 60 LocalizeFont
25 88 LangID
11 54 BlocksStart
21 107 BlocksStart
18 0 0
end

start 149
10 0 Para
31 23 IndFirst
31 32 IndLeft
31 41 IndRight
31 50 SpLine
31 59 SpBefore
31 68 SpAfter
8 77 HorizAlign
8 78 Bullet
11 92 BlockStarts
21 142 BlockStarts
18 0 0
end

start 150
10 0 Tabs
27 0 TabsID
11 48 BlockStarts
18 0 0
end

start 151
10 0 Tabs
27 0 TabsID
11 139 BlockStarts
18 0 0
end

start 181
10 0 Tabs
27 0 TabsID
11 708 BlockStarts
18 0 0
end

start 152
10 0 Foreign
9 20 IndFirst
9 29 IndLeft
9 38 IndRight
9 47 SpLine
28 68 Ext
18 0 0
end

start 153
10 0 Connection
31 19 Width
31 28 Height
31 37 DirX/A
31 46 DirY/B
8 55 Type/C
11 67 BlockStarts
21 67 BlockStarts
18 0 0
end

start 155
10 0 XForm
9 20 PinX
9 29 PinY
9 38 Width
9 47 Height
9 56 LocPinX
9 65 LocPinY
9 74 Angle
8 82 FlipX
8 83 FlipY
8 84 ResizeMode
11 88 BlockStarts
21 88 BlockStarts
18 0 0
end

start 156
10 0 TextXForm
9 20 TxtPinX
9 29 TxtPinY
31 37 TxtWidth
9 47 TxtHeight
9 56 TxtLocPinX
9 65 TxtLocPinY
9 74 TxtAngle
11 88 BlockStarts
21 88 BlockStarts
18 0 0
end

start 157
10 0 XForm1D
9 20 BeginX
9 29 BeginY
9 38 EndX
9 47 EndY
11 57 BlockStarts
21 57 BlockStarts
end

start 158
10 0 Scratch
9 20 X
9 29 Y
9 38 A
9 47 B
9 56 C
9 65 D
11 75 BlockStarts
18 0 0
end

start 159
10 0 Alignment
9 20 AlignLeft
9 29 AlignCenter
9 38 AlignRight
9 47 AlignTop
9 56 AlignMiddle
9 65 AlignBottom
11 75 BlockStarts
21 79 BlockStarts
18 0 0
end

start 160
10 0 Protection
8 19 LockWidth
8 20 LockHeight
8 21 LockMoveX
8 22 LockMoveY
8 23 LockAspect
8 24 LockDelete
8 25 LockBegin
8 26 LockEnd
8 27 LockRotate
8 28 LockCrop
8 29 LockVtxEdit
8 30 LockTextEdit
8 31 LockFormat
8 32 LockGroup
8 33 LockCalcWH
8 34 LockSelect
8 35 LockCustProp
11 43 BlockStarts
21 43 BlockStarts
18 0 0
end

start 161
10 0 TextFields
18 0 0
end

start 162
10 0 Control
9 20 X
9 29 Y
9 38 XDyn
9 47 YDyn
8 55 XCon
8 56 YCon
0 57 CanGlue
11 60 BlockStarts
21 60 BlockStarts
18 0 0
end

start 163
10 0 Help
11 49 BlockStarts
21 49 BlockStarts
18 0 0
end

start 164
10 0 Misc
0 19 NoObjHandles
1 19 NonPrinting
2 19 NoCtlHandles
3 19 NoAlignBox
4 19 UpdateAlignBox
5 19 HideText
8 20 DynFeedback
8 21 GlueType
8 22 WalkPreference
25 25 ObjType
0 35 IsDropSource
1 35 NoLiveDynamics
25 37 LangID
11 42 BlockStarts
21 64 BlockStarts
18 0 0
end

start 165
10 0 SplineStart
9 20 X
9 29 Y
9 37 A
9 45 B
9 53 C
8 61 D
11 65 BlockStarts
18 0 0
end

start 166
10 0 SplineKnot
9 20 X
9 29 Y
9 37 A
11 47 BlockStarts
18 0 0
end

start 167
10 0 LayerMem
11 25 BlockStarts
21 25 BlockStarts
18 0 0
end

# Transparency 255 - 100%
start 168
10 0 Layer
30 27 Color
8 31 Transparency
8 33 Visible
8 34 Print
8 35 Active
8 36 Lock
8 37 Snap
8 38 Glue
11 52 BlockStarts
21 52 BlockStarts
18 0 0
end

start 169
10 0 Act
8 40 Checked
8 41 Disabled
0 42 ReadOnly
1 42 Invisible
2 42 BeginGroup
11 47 BlockStarts
21 76 BlockStarts
18 0 0
end

start 170
10 0 Control
9 20 X
9 29 Y
9 38 XDyn
9 47 YDyn
8 55 XBehavior
8 56 YBehavior
0 57 CanGlue
11 66 BlockStarts
21 66 BlockStarts
18 0 0
end

start 180
10 0 User-defined Cells
9 20 Value
11 34 BlockStarts
21 34 BlockStarts
18 0 0
end

start 182
10 0 CustomProps
9 20 Value
8 44 Type
0 46 Invisible
1 46 Ask
11 55 BlockStarts
18 0 0
end

start 183
10 0 RulerGrid
8 19 XRulerDensity
8 20 XRulerDensity
31 21 Unknown1
31 30 Unknown2
31 39 XRulerOrigin
31 48 YRulerOrigin
8 57 XGridDensity
8 58 YGridDensity
31 59 XGridSpacing
31 68 YGridSpacing
31 77 XGridOrigin
31 86 YGridOrigin
11 98 BlockStarts
21 98 BlockStarts
18 0 0
end

start 185
10 0 Connection
31 19 Width
31 28 Height
31 37 DirX/A
31 46 DirY/B
8 55 Type/C
11 67 BlockStarts
21 67 BlockStarts
18 0 0
end

start 186
10 0 ConnectionPoints
9 20 Width
9 29 Height
11 79 BlockStarts
18 0 0
end

start 188
10 0 DocProps
25 24 DocLangID
18 0 0
end

start 189
10 0 Image
9 19 Gamma
25 27 Contrast*100 (%)
25 29 Brightness*100 (%)
25 31 Sharpen*100 (%)
25 33 Blur*100 (%)
25 35 Denoise*100 (%)
25 37 Transparency*100 (%)
11 64 BlockStarts
21 64 BlockStarts
18 0 0
end

start 190
10 0 Group
8 19 SelectMode
8 20 DisplayMode
0 21 IsDropTarget
1 21 IsSnapTarget
2 21 IsTextEditTarget
3 21 DontMoveChildren
11 44 BlocksStart
21 44 BlocksStart
end

start 191
10 0 Layout
0 19 ShapePermeableX
1 19 ShapePermeableY
2 19 ShapePermeablePlace
8 20 ShapeFixedCode
8 21 ShapePlowCode
8 22 ShapeRouteStyle
8 24 ConFixedCode
8 25 ConLineJumpCode
8 26 ConLineJumpStyle
8 28 ConLineJumpDirX
8 29 ConLineJumpDirY
11 57 BlockStarts
21 57 BlockStarts
18 0 0
end

start 192
10 0 PageLayout
0 19 ResizePage
1 19 EnableGrid
2 19 DynamicOff
3 19 CtrlAsInput
8 20 PlaceStyle
8 21 RouteStyle
8 22 PlaceDepth
8 23 PlowCode
8 24 LineJumpCode
8 25 LineJumpStyle
8 26 PageLineJumpDirX
8 27 PageLineJumpDirY
9 29 LineToNodeX
9 38 LineToNodeY
9 47 BlockSizeX
9 56 BlockSizeY
9 65 AvenueSizeX
9 74 AvenueSizeY
9 83 LineToLineX
9 92 LineToLineY
9 100 LineJumpFactorX
9 108 LineJumpFactorY
8 116 LineAdjustFrom
8 117 LineAdjustTo
11 163 Blocks start
21 163 Blocks start
end

start 193
10 0 PolylineTo
9 20 X
9 29 Y
18 0 0
end


start 195
10 0 NURBSTo
9 20 X
9 29 Y
9 37 A
9 45 B
9 53 C
9 61 D
11 80 BlocksStart
21 80 BlocksStart
18 0 0
end

start 196
10 0 Hyperlink
0 39 NewWindow
2 39 Default
11 65 BlocksStart
18 0 0
end

start 197
10 0 Reviewer
8 28 ColorRed
8 29 ColorGreen
8 30 ColorBlue
26 31 ReviewerID
26 35 CurrentIndex
11 57 BlocksStart
21 57 BlocksStart
18 0 0
end

start 198
10 0 Annotation
18 0 0
end

start 199
10 0 SmartTagDef
18 0 0
end

start 200
10 0 PrintProps
31 19 PageLeftMargin
31 28 PageRightMargin
31 37 PageTopMargin
31 46 PageBottomMargin
9 55 ScaleX
9 63 ScaleY
25 71 PagesX
25 73 PagesY
8 76 PrintPageOrientation
25 77 PaperKind
25 79 PaperSource
11 91 BlocksStart
21 91 BlocksStart
18 0 0
end

start 201
10 0 Unknown 0xc9
18 0 0
end

start 209
10 0 NURBSTo E-cell
9 35 1st fr of NURBSTo
9 43 3 bytes are here, need to map
9 51 2nd fr
9 59 3rd fr
9 67 4th byte
9 75 5th byte
9 83 4th fr
9 91 5th fr
9 99 6th byte
9 107 7th byte
9 115 6th fr
9 123 7th fr
9 131 8th byte
9 139 9th byte
18 0 0
end
