File size: 11,717 Bytes
fb2234b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

http://www.openoffice.org/framework/documentation/filters/example.html
- reading of the entire filters configuration
- register a new filter

libreoffice-wiki-publisher
- how to write Types.xcu, Filter.xcu


TypeDetection:
	filter/source/config/cache/typedetection.cxx

FilterFactory:
	filter/source/config/cache/filterfactory.cxx

OwnSubFilter:
	sfx2/source/doc/ownsubfilterservice.cxx

xmloff

writer8 'Deep' DetectService: com.sun.star.text.FormatDetector
	sw/source/ui/uno/swdetect.cxx


from framework/source/loadenv/loadenv.cxx:

726โ”‚     // (iii) If a FrameLoader service (or at least
727โ”‚     //      a Filter) can be found, which supports
728โ”‚     //      this URL - it must be a loadable content.
729โ”‚     //      Because both items are registered for types
730โ”‚     //      its enough to check for frame loaders only.
731โ”‚     //      Mos of our filters are handled by our global
732โ”‚     //      default loader. But there exist some specialized
733โ”‚     //      loader, which does not work on top of filters!
734โ”‚     //      So its not enough to search on the filter configuration.
735โ”‚     //      Further its not enough to search for types!
736โ”‚     //      Because there exist some types, which are referenced by
737โ”‚     //      other objects ... but not by filters nor frame loaders!

create FrameLoaderFactory
FrameLoaderFactory.createSubSetEnumerationByProperties( "Types" = [ types... ] ) 
-> create a com.sun.star.comp.office.FrameLoader()
and FrameLoader->load(descriptor, frame)

sfx2/source/view/frmloader.cxx
SfxFrameLoaderImpl::impl_determineFilter()

sfx2/source/doc/sfxbasemodel.cxx
SfxBaseModel::load(seqArguments)
arg[0] = ''
MacroExecutionMode = 3
UpdateDocMode = 2
FileName = fullurl
Stream = stream
StatusIndicator =
Frame =
UCBContent =
FrameName =
URL =
InputStream = stream
Referer = private:user
InteractionHandler = interactionhandler
TypeName = writer8
FilterName = writer8
DocumentService = com.sun.star.text.TextDocument

SfxObjectShell::DoLoad (this=0x8ae3100, pMed=0x8d111a8) at 
/home/mete0r/prj/libreoffice/sfx2/source/doc/objstor.cxx:584

	SfxObjectShell::HandleFilter at
	/home/mete0r/prj/libreoffice/sfx2/source/doc/objstor.cxx:841

	at 647: xStorage = pMedium->GetStorage()
	at sfx2/source/doc/docfile.cxx:1303 : 
	comphelper::OStorageHelper::GetStorageFactory->createInstanceWithArguments( 
	(inputstream, embed::ElementModes::Read)

SfxObjectShell::LoadOwnFormat at
/home/mete0r/prj/libreoffice/sfx2/source/doc/objstor.cxx:2962

SwDocShell::Load() at
/home/mete0r/prj/libreoffice/sfx2/source/ui/app/docshini.cxx:540

SfxObjectShell::Load() at
/home/mete0r/prj/libreoffice/sfx2/source/doc/objstor.cxx:460

SfxObjectShell::GeneralInit_Impl() at
/home/mete0r/prj/libreoffice/sfx2/source/doc/objstor.cxx:415

SwReader::Read() at
/home/mete0r/prj/libreoffice/sfx2/source/filter/basflt/shellio.cxx

XMLReader::Read() at
/home/mete0r/prj/libreoffice/sw/source/filter/xml/swxml.cxx

line 562:
	xGraphicResolver = SvXMLGraphicHelper::Create(xStorage)
	xObjectResolver = create SvXMLEmbeddedObjectHelper(xStorage,
							   rDoc.GetPersist())

line 728
- filterargs:
	xInfoSet = create a XPropertySet
	xStatusIndicator
	xGraphicResolver = xGraphicResolver
	xObjectResolver = xObjectResolver
	aLateInitSettings = NamedValue("LateInitSettings",
					com.sun.star.document.NamedPropertyValues())

line 892
- XDocumentMetadataAccess xDMA = xModel
- baseuri = sfx2::createBaseURI(context, storage, 
  "file:///home/mete0r/prj/pyhwp/5017.odt", "");
- xDMA.loadMetadataFromStorage(storage, baseuri, interactionhandler)
	SfxBaseModel::loadMetadataFromStorage() at 
	sfx2/source/doc/sfxbasemodel.cxx:4325
	DocumentMetadataAccess::loadMetadataFromStorage() at
	sfx2/source/doc/DocumentMetadataAccess.cxx:1098
	- baseuri = "file:///home/mete0r/prj/pyhwp/5017.odt/"

line 922
parse streams:
	Meta.xml com.sun.star.comp.Writer.XMLOasisMetaImporter
	settings.xml com.sun.star.comp.Writer.XMLOasisSettingsImporter
	styles.xml
	content.xml

XMLReader::ReadThroughComponent() at
/home/mete0r/prj/libreoffice/sfx2/source/filter/filter/xml/swxml.cxx:142
- create ""com.sun.star.comp.Writer.XMLOasisStylesImporter" and SAX Parser
- parse styles.xml

- create ""com.sun.star.comp.Writer.XMLOasisContentImporter" and SAX Parser
- parse content.xml



๊ทธ๋ฆผ ๊ฐ์ฒด Import

SvXMLImport ์ดˆ๊ธฐํ™”

SvXMLImport::initialize() (from SwXMLImport)
- BaseURI: file:///home/mete0r/prj/pyhwp/5017.odt -> mpImpl->aBaseURL/aDocBaseURL
- StreamRelPath: '' -> sRelPath
- StreamName: 'styles.xml' -> sName

ResolveGraphicObjectURL()์ด ํ˜ธ์ถœ๋˜๋Š” ๊ฑด XMLOasisContentImporter


[xxx.odt, 5017.odt]
in xmloff/source/text/XMLTextFrameContext.cxx:1418
XMLTextCreateFrameContext::CreateChildContext()

at line 1450:
pContext = GetImport().GetShapeImport()
		->CreateFrameChildContext(rLocalName='image'...)
pContext: an instance of SvXMLImportContext
m_xImplContext = pContext

[xxx.odt]
in XMLTextFrameContext_Impl::Create()
sHRef: "Picture/123.jpg"

in xmloff/source/text/XMLTextFrameContext.cxx:566
create an instance of "com.sun.star.text.GraphicObject" and get PropertySet

get XMLTextImportHelper

at line 724:
sHRef = GetImport().ResolveGraphicObjectURL(sHRef, load_on_demand = true)
sHRef: "vnd.sun.star.Package:Picture/123.jpg"

at line 758:
xTxtCntnt = xPropSet
xTextImportHelper->insertTextContent(xTxtCntnt)



[5017.odt]:

GetImport() : an instance of SvXMLImport
SvXMLImport has a mxGraphicResolver
mxGraphicResolver: XGraphicObjectResolver

#1  0x038e4dc1 in SvXMLImport::startElement (this=0x9620f80, rName="draw:image", xAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/core/xmlimp.cxx:647
	#0  XMLTextFrameContext::CreateChildContext (this=0x9515558, p_nPrefix=4, rLocalName="image", xAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/text/XMLTextFrameContext.cxx:1418
		namespace: draw (XML_TEXT_FRAME_GRAPHIC)
		m_HasAutomaticStyleWithoutParentStyle = 1
		at 1450: pContext = GetImport()->GetShapeImport()->CreateFrameChildChildContext()
			#0  XMLShapeImportHelper::CreateFrameChildContext (this=0x8fc3ab0, rImport=..., p_nPrefix=4, rLocalName="image", rAttrList=..., rShapes=..., rFrameAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/draw/shapeimport.cxx:689
				pContext = new SdXMLGraphicObjectShapeContext()
				at 734: pContext->processAttribute() for attr in xAttrList
					href: 'bindata/BIN0002.jpg' --> maURL
					style-name: 'DrawFrame-1'
					x: '111.73pt'
					y: '4.9pt'
					anchor-type: 'paragraph'
					z-index: '2'
					width: 57.68mm
					height: 34.61mm

		returns

#1  0x038e4dc1 in SvXMLImport::startElement (this=0x9620f80, rName="draw:image", xAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/core/xmlimp.cxx:687
	#3  0x0395b743 in SdXMLGraphicObjectShapeContext::StartElement (this=0x95bca30)
		at /home/mete0r/prj/libreoffice/xmloff/source/draw/ximpshap.cxx:2362
			pService: "com.sun.star.drawing.GraphicShapeObject"
			#2  0x039576e9 in SdXMLShapeContext::AddShape (this=0x95bca30, pServiceName=0x3a97430 "com.sun.star.drawing.GraphicObjectShape") at /home/mete0r/prj/libreoffice/xmloff/source/draw/ximpshap.cxx:523
				xShape = createInstance of pServiceName
			#1  0x03957063 in SdXMLShapeContext::AddShape (this=0x95bca30, xShape=...)
				XMLShapeImportHelper = GetImport().GetShapeImport()
				at /home/mete0r/prj/libreoffice/xmloff/source/draw/ximpshap.cxx:446
			#0  XMLTextShapeImportHelper::addShape (this=0x8e85588, rShape=..., xAttrList=..., rShapes=...)
				rImport: maybe TextDocument
				xTxtImport = rImport.GetTextImport() at line 94

				at /home/mete0r/prj/libreoffice/xmloff/source/text/XMLTextShapeImportHelper.cxx:140
				XTextContent->InsertTextContent()
		at 2388
			mbIsPlaceholder: false
			maURL: 'bindata/BIN0002.jpg'
			aAny = GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() )
			aAny: 'vnd.sun.star.Package:bindata/BIN0002.jpg'
			mxShape.setPropertyValue('GraphicURL', aAny)
			mxShape.setPropertyValue('GraphicStreamURL', aAny)


[xxx.odt]:
#1  0x038e4dc1 in SvXMLImport::startElement (this=0x9620f80, rName="draw:image", xAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/core/xmlimp.cxx:647
	#0  XMLTextFrameContext::CreateChildContext (this=0x9515558, p_nPrefix=4, rLocalName="image", xAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/text/XMLTextFrameContext.cxx:1418
		namespace: draw (XML_TEXT_FRAME_GRAPHIC)
		m_HasAutomaticStyleWithoutParentStyle = 0

		at line 1492
		pContext = new XMLTextFrameContext_Impl()
	#1  0x03a180c8 in XMLTextFrameContext_Impl (this=0x93cd8a0, rImport=..., nPrfx=<value optimized out>, rLName="image", rAttrList=..., eATyp=com::sun::star::text::TextContentAnchorType_AT_PARAGRAPH, nNewType=2, rFrameAttrList=...) at /home/mete0r/prj/libreoffice/xmloff/source/text/XMLTextFrameContext.cxx:1067
	#0  XMLTextFrameContext_Impl::Create (this=0x93cd8a0) at /home/mete0r/prj/libreoffice/xmloff/source/text/XMLTextFrameContext.cxx:758
		nType = 2
		XMLTextImportHeler xTextImportHelper.InsertTextContent()
		sHRef = 'vnd.sun.star.Package:Pictures/1234...1234.jpg'



sdr::contact::ViewObjectContactOfGraphic::doAsynchGraphicLoading() ์—์„œ๋ถ€ํ„ฐ ์ด๋ฏธ์ง€ ๋กœ๋”ฉ


1. ODT ํŒจํ‚ค์ง€๋ฅผ ๋กœ๋”ฉํ•  ๋•Œ, ํŒจํ‚ค์ง€์— ํฌํ•จ๋œ ๊ทธ๋ฆผ ํŒŒ์ผ๋“ค์„ ๋ฐ”๋กœ ์ด์–ด์„œ ๋กœ๋”ฉํ•˜๊ฑฐ๋‚˜, LoadOnDemand ํ•  ์ˆ˜ ์žˆ์Œ.
   SvXMLImport::ResolveGraphicObjectURL(url, loadondemand) ์ฐธ์กฐ.

   ๊ทธ๋Ÿฐ๋ฐ SdXMLGraphicObjectShapeContext::StartElement()๋Š” (line 2388 ๋ถ€๊ทผ์—์„œ) SvXMLImport::ResolveGraphicObjectURL์„ ํ˜ธ์ถœํ•  ๋•Œ
   SvXMLImport::IsGraphicLoadOnDemandSupported()๋ฅผ ํ˜ธ์ถœํ•˜๋Š”๋ฐ, SvXMLImport๋Š” ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฉฐ, SwXMLImport๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ธ ๋“ฏ ํ•˜๋‹ค.

   ๊ทธ๋ž˜์„œ ํŒจํ‚ค์ง€๋ฅผ ์ฒ˜์Œ ๋กœ๋”ฉํ•  ๋•Œ ์ด๋ฏธ์ง€๊ฐ€ ๋กœ๋”ฉ๋˜์ง€ ์•Š๊ณ , ์ดํ›„์— UI์—์„œ on demand๋กœ ์ด๋ฏธ์ง€๋ฅผ ๋กœ๋”ฉํ•˜๋Š” ๋“ฏ ํ•˜๋‹ค.
   (sdr::contact::ViewObjectContactOfGraphic::doAsynchGraphicLoading()์—์„œ๋ถ€ํ„ฐ ์ถ”์ )

   ๊ทธ๋Ÿฐ๋ฐ ์‹ค์ œ๋กœ๋Š” load on demand ๊ณผ์ •์—์„œ ์‹คํŒจํ•˜๋Š”๋ฐ, Storage์—์„œ ๊ทธ๋ฆผ ์ŠคํŠธ๋ฆผ์„ ์–ป์–ด๋‚ด๋Š” ๊ณผ์ •์—์„œ ์‹คํŒจํ•œ๋‹ค.
   (comphelper::OStorageHelper::GetStreamAtPackageURL()์—์„œ๋ถ€ํ„ฐ ์ถ”์ )
   
   ์ผ๋‹จ ํŒจํ‚ค์ง€ Storage๊ฐ€ (hwp์—์„œ odt๋กœ ๋ณ€ํ™˜ํ•œ) ์ž„์‹œ ํŒŒ์ผ์— ๊ธฐ๋ฐ˜ํ•ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์—
   ์ถ”ํ›„ on demand ๊ณผ์ •์—์„œ๋Š” ์ด ํŒŒ์ผ์ด ์ด๋ฏธ ์‚ฌ๋ผ์กŒ๊ธฐ ๋•Œ๋ฌธ์ด ์•„๋‹Œ๊ฐ€ ์ถ”์ธกํ•ด๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ,
   hwp5file_convert_to_odtpkg_file()์—์„œ ์ž„์‹œํŒŒ์ผ ๋Œ€์‹  ํŠน์ •ํ•œ ์œ„์น˜์— ๊ณ ์ •๋œ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ
   ์‹คํ—˜ํ•ด๋ดค์„ ๋•Œ๋„ ์—ญ์‹œ ๊ทธ๋ฆผ ์ŠคํŠธ๋ฆผ์„ ์–ป์–ด๋‚ด๋Š”๋ฐ์„œ ์‹คํŒจํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์•„, ๋‹ค๋ฅธ ์ด์œ ์ผ ์ˆ˜๋„ ์žˆ์Œ.

2. on demand ๋กœ๋”ฉ์„ ํฌ๊ธฐํ•˜๊ณ  content.xml์„ ๋กœ๋”ฉํ•˜๋ฉด์„œ ๊ทธ๋ฆผ๋“ค๋„ ํ•จ๊ป˜ ๋กœ๋”ฉ๋˜๋„๋ก ํ•˜๋ฉด, ๊ทธ๋ฆผ๋“ค์ด ์ œ๋Œ€๋กœ ๋กœ๋”ฉ๋˜๋Š” ๊ฒƒ์„
   ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค:

   com.sun.star.comp.Writer.XMLOasisContentImporter๋ฅผ ์ดˆ๊ธฐํ™”ํ•  ๋•Œ, ํ•„ํ„ฐ ์ธ์ž๋กœ graphic resolver๋ฅผ ๋‹ค์Œ์ฒ˜๋Ÿผ ์ดˆ๊ธฐํ™”ํ•˜์—ฌ ๋„˜๊ฒจ์ค€๋‹ค.

   createInstanceWithArguments('com.sun.star.comp.Svx.GraphicImportHelper', (storage,))
   
   ๊ทธ๋ฆฌ๊ณ  ๋””๋ฒ„๊ฑฐ์ƒ์—์„œ SvXMLImporter::initialize()๋ฅผ ์ˆ˜ํ–‰ํ•œ ๋’ค, mbIsGraphicLoadOnDemandSupported = false๋กœ ๊ฐ•์ œ๋กœ
   ์„ค์ •ํ•œ ๋’ค ์ง„ํ–‰ํ•˜๋ฉด ๊ทธ๋ฆผ๋“ค์ด ์ œ๋Œ€๋กœ ๋กœ๋”ฉ๋จ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

   ๊ทธ๋Ÿฐ๋ฐ ๋ฌธ์ œ๋Š” SvXMLImporter::mbIsGraphicLoadOnDemandSupported๋Š” ์ฒ˜์Œ์— true๋กœ ์„ค์ •๋œ ๋’ค, ๋ฐ”๋€Œ์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์ด๋‹ค. ์œ„์ฒ˜๋Ÿผ
   ๋””๋ฒ„๊ฑฐ ์ƒ์—์„œ ๊ฐ•์ œ๋กœ false๋กœ ์„ค์ •ํ•ด์ฃผ์ง€ ์•Š๋Š” ํ•œ, SvXMLImporter::ResolveGraphicObjectURL(url, loadondemand)๋Š” ๋Š˜ ๋‘๋ฒˆ์งธ
   ์ธ์ž๋ฅผ true๋กœ ๋ถˆ๋ฆฌ๊ฒŒ ๋œ๋‹ค. (SdXMLGraphicObjectShapeContext::StartElement()์˜ ๋ผ์ธ 2388 ๋ถ€๊ทผ)