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 ๋ถ๊ทผ)
|