wirispluginengine 3.62.0.1322 → 7.14.0.1422

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +34 -34
  3. data/app/assets/javascripts/wirispluginengine/WIRISplugins.js +1040 -64
  4. data/app/controllers/wirispluginengine/application_controller.rb +84 -75
  5. data/app/helpers/wirispluginengine/application_helper.rb +4 -4
  6. data/config/routes.rb +4 -4
  7. data/lib/com/wiris/common/WInteger.rb +52 -51
  8. data/lib/com/wiris/plugin/api/Cas.rb +5 -5
  9. data/lib/com/wiris/plugin/api/CleanCache.rb +5 -5
  10. data/lib/com/wiris/plugin/api/Configuration.rb +5 -5
  11. data/lib/com/wiris/plugin/api/ConfigurationKeys.rb +94 -91
  12. data/lib/com/wiris/plugin/api/Editor.rb +5 -5
  13. data/lib/com/wiris/plugin/api/Filter.rb +5 -5
  14. data/lib/com/wiris/plugin/api/ImageFormatController.rb +5 -5
  15. data/lib/com/wiris/plugin/api/ParamsProvider.rb +5 -5
  16. data/lib/com/wiris/plugin/api/PluginBuilder.rb +88 -74
  17. data/lib/com/wiris/plugin/api/Render.rb +5 -5
  18. data/lib/com/wiris/plugin/api/ServiceResourceLoader.rb +5 -5
  19. data/lib/com/wiris/plugin/api/Test.rb +5 -5
  20. data/lib/com/wiris/plugin/api/TextService.rb +5 -5
  21. data/lib/com/wiris/plugin/configuration/ConfigurationUpdater.rb +5 -5
  22. data/lib/com/wiris/plugin/impl/CacheFormulaImpl.rb +15 -0
  23. data/lib/com/wiris/plugin/impl/CacheImpl.rb +124 -0
  24. data/lib/com/wiris/plugin/impl/CasImpl.rb +140 -138
  25. data/lib/com/wiris/plugin/impl/CleanCacheImpl.rb +103 -101
  26. data/lib/com/wiris/plugin/impl/ConfigurationImpl.rb +165 -166
  27. data/lib/com/wiris/plugin/impl/CustomConfigurationUpdater.rb +32 -30
  28. data/lib/com/wiris/plugin/impl/DefaultConfigurationUpdater.rb +24 -22
  29. data/lib/com/wiris/plugin/impl/EditorImpl.rb +80 -78
  30. data/lib/com/wiris/plugin/impl/FileConfigurationUpdater.rb +29 -27
  31. data/lib/com/wiris/plugin/impl/FileStorageAndCache.rb +55 -53
  32. data/lib/com/wiris/plugin/impl/FolderTreeStorageAndCache.rb +65 -134
  33. data/lib/com/wiris/plugin/impl/GenericParamsProviderImpl.rb +50 -48
  34. data/lib/com/wiris/plugin/impl/HttpImpl.rb +49 -48
  35. data/lib/com/wiris/plugin/impl/HttpListener.rb +5 -5
  36. data/lib/com/wiris/plugin/impl/ImageFormatControllerPng.rb +71 -63
  37. data/lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb +37 -28
  38. data/lib/com/wiris/plugin/impl/PluginBuilderImpl.rb +280 -248
  39. data/lib/com/wiris/plugin/impl/RenderImpl.rb +303 -257
  40. data/lib/com/wiris/plugin/impl/ServiceResourceLoaderImpl.rb +41 -39
  41. data/lib/com/wiris/plugin/impl/TestImpl.rb +177 -157
  42. data/lib/com/wiris/plugin/impl/TextFilter.rb +210 -194
  43. data/lib/com/wiris/plugin/impl/TextFilterTags.rb +57 -50
  44. data/lib/com/wiris/plugin/impl/TextServiceImpl.rb +158 -107
  45. data/lib/com/wiris/plugin/storage/StorageAndCache.rb +5 -5
  46. data/lib/com/wiris/util/json/JSon.rb +505 -493
  47. data/lib/com/wiris/util/json/JSonIntegerFormat.rb +17 -16
  48. data/lib/com/wiris/util/json/JsonAPIResponse.rb +70 -0
  49. data/lib/com/wiris/util/json/StringParser.rb +57 -56
  50. data/lib/com/wiris/util/sys/AccessProvider.rb +8 -0
  51. data/lib/com/wiris/util/sys/Cache.rb +8 -0
  52. data/lib/com/wiris/util/sys/HttpConnection.rb +14 -13
  53. data/lib/com/wiris/util/sys/HttpConnectionListener.rb +5 -5
  54. data/lib/com/wiris/util/sys/HttpSync.rb +28 -0
  55. data/lib/com/wiris/util/sys/IniFile.rb +132 -131
  56. data/lib/com/wiris/util/sys/Lock.rb +8 -0
  57. data/lib/com/wiris/util/sys/LockProvider.rb +8 -0
  58. data/lib/com/wiris/util/sys/Store.rb +126 -101
  59. data/lib/com/wiris/util/sys/StoreCache.rb +63 -0
  60. data/lib/com/wiris/util/sys/TimerProxy.rb +21 -0
  61. data/lib/com/wiris/util/sys/TimerTask.rb +8 -0
  62. data/lib/com/wiris/util/type/Arrays.rb +275 -0
  63. data/lib/com/wiris/util/type/ByteBuffer.rb +69 -0
  64. data/lib/com/wiris/util/type/Comparator.rb +8 -0
  65. data/lib/com/wiris/util/type/DataUtils.rb +24 -0
  66. data/lib/com/wiris/util/type/DoubleTools.rb +14 -0
  67. data/lib/com/wiris/util/type/HashCache.rb +43 -0
  68. data/lib/com/wiris/util/type/IntegerTools.rb +32 -0
  69. data/lib/com/wiris/util/type/Queue.rb +31 -0
  70. data/lib/com/wiris/util/type/SortArrayByStringLength.rb +26 -0
  71. data/lib/com/wiris/util/type/SortStringByLength.rb +26 -0
  72. data/lib/com/wiris/util/type/SortedHash.rb +45 -0
  73. data/lib/com/wiris/util/type/Stack.rb +31 -0
  74. data/lib/com/wiris/util/type/StringUtils.rb +56 -0
  75. data/lib/com/wiris/util/type/Tokenizer.rb +40 -0
  76. data/lib/com/wiris/util/type/UrlUtils.rb +78 -0
  77. data/lib/com/wiris/util/xml/ContentHandler.rb +8 -0
  78. data/lib/com/wiris/util/xml/DefaultHandler.rb +25 -0
  79. data/lib/com/wiris/util/xml/EntityResolver.rb +8 -0
  80. data/lib/com/wiris/util/xml/MathMLEntityResolver.rb +19 -0
  81. data/lib/com/wiris/util/xml/SAXParser.rb +470 -0
  82. data/lib/com/wiris/util/xml/SerializableImpl.rb +16 -15
  83. data/lib/com/wiris/util/xml/WCharacterBase.rb +968 -627
  84. data/lib/com/wiris/util/xml/WEntities.rb +11 -9
  85. data/lib/com/wiris/util/xml/WXmlUtils.rb +660 -490
  86. data/lib/com/wiris/util/xml/XmlSerializer.rb +517 -471
  87. data/lib/com/wiris/util/xml/XmlWriter.rb +260 -262
  88. data/lib/loader.rb +15 -12
  89. data/lib/src-generic/Array.rb +22 -22
  90. data/lib/src-generic/ArrayInt.rb +31 -31
  91. data/lib/src-generic/Base64.rb +14 -14
  92. data/lib/src-generic/BaseCode.rb +93 -93
  93. data/lib/src-generic/Boolean.rb +27 -0
  94. data/lib/src-generic/Bytes.rb +50 -50
  95. data/lib/src-generic/BytesInput.rb +37 -37
  96. data/lib/src-generic/EReg.rb +55 -55
  97. data/lib/src-generic/File.rb +35 -35
  98. data/lib/src-generic/FileLock.rb +26 -26
  99. data/lib/src-generic/FileSystem.rb +37 -37
  100. data/lib/src-generic/Hash.rb +42 -42
  101. data/lib/src-generic/Http.rb +111 -107
  102. data/lib/src-generic/HttpRequest.rb +25 -25
  103. data/lib/src-generic/HttpResponse.rb +70 -70
  104. data/lib/src-generic/Iterator.rb +20 -19
  105. data/lib/src-generic/Math.rb +14 -14
  106. data/lib/src-generic/Md5.rb +8 -8
  107. data/lib/src-generic/Md5Tools.rb +11 -11
  108. data/lib/src-generic/PropertiesTools.rb +32 -32
  109. data/lib/src-generic/Reflect.rb +16 -16
  110. data/lib/src-generic/RubyConfigurationUpdater.rb +49 -45
  111. data/lib/src-generic/Serializer.rb +84 -84
  112. data/lib/src-generic/Std.rb +74 -74
  113. data/lib/src-generic/Storage.rb +152 -152
  114. data/lib/src-generic/StringBuf.rb +40 -40
  115. data/lib/src-generic/StringTools.rb +44 -46
  116. data/lib/src-generic/Timer.rb +6 -6
  117. data/lib/src-generic/Type.rb +18 -18
  118. data/lib/src-generic/TypeTools.rb +31 -31
  119. data/lib/src-generic/Unserializer.rb +72 -72
  120. data/lib/src-generic/Utf8.rb +26 -26
  121. data/lib/src-generic/Xml.rb +199 -198
  122. data/lib/src-generic/extended/Integer.rb +5 -5
  123. data/lib/src-generic/extended/Math.rb +6 -6
  124. data/lib/src-generic/extended/Properties.rb +11 -11
  125. data/lib/src-generic/extended/String.rb +38 -38
  126. data/lib/src-generic/settings/PlatformSettings.rb +18 -18
  127. data/lib/src-generic/system/HttpProxy.rb +23 -0
  128. data/lib/src-generic/system/HttpProxyAuth.rb +10 -0
  129. data/lib/wirispluginengine.rb +5 -5
  130. data/lib/wirispluginengine/engine.rb +5 -5
  131. data/lib/wirispluginengine/integration/cleancache.rb +8 -8
  132. data/lib/wirispluginengine/integration/configurationjs.rb +8 -15
  133. data/lib/wirispluginengine/integration/configurationjson.rb +6 -6
  134. data/lib/wirispluginengine/integration/createimage.rb +7 -7
  135. data/lib/wirispluginengine/integration/getmathml.rb +18 -18
  136. data/lib/wirispluginengine/integration/resource.rb +8 -8
  137. data/lib/wirispluginengine/integration/service.rb +5 -5
  138. data/lib/wirispluginengine/integration/showimage.rb +28 -21
  139. data/lib/wirispluginengine/integration/test.rb +5 -5
  140. data/lib/wirispluginengine/integration/testfilter.rb +10 -0
  141. data/lib/wirispluginengine/version.rb +2 -2
  142. data/resources/VERSION +1 -1
  143. data/resources/WEB-INF/web.xml +25 -0
  144. data/resources/WIRISplugins.js +3809 -0
  145. data/resources/default-configuration.ini +47 -45
  146. data/resources/tech.txt +1 -1
  147. data/resources/wirisplugin.css +43 -42
  148. metadata +40 -4
  149. data/configuration.ini.dist +0 -104
@@ -1,144 +1,75 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
- require('com/wiris/util/sys/Store.rb')
5
- require('com/wiris/plugin/storage/StorageAndCache.rb')
6
- class FolderTreeStorageAndCache
7
- extend StorageAndCacheInterface
3
+ require('com/wiris/plugin/storage/StorageAndCache.rb')
4
+ require('com/wiris/plugin/impl/CacheImpl.rb')
5
+ require('com/wiris/plugin/storage/StorageAndCache.rb')
6
+ class FolderTreeStorageAndCache
7
+ extend StorageAndCacheInterface
8
8
 
9
- include Wiris
9
+ include Wiris
10
10
 
11
- attr_accessor :config
12
- @@backwards_compat = true
13
- def self.backwards_compat
14
- @@backwards_compat
15
- end
16
- def self.backwards_compat=(backwards_compat)
17
- @@backwards_compat = backwards_compat
18
- end
19
- def initialize()
20
- super()
21
- end
22
- def init(obj,config)
23
- @config = config
24
- end
25
- def codeDigest(content)
26
- digest = Md5Tools::encodeString(content)
27
- parent = getFolderStore(getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER),digest)
28
- parent::mkdirs()
29
- store = getFileStoreWithParent(parent,digest,"ini")
30
- store::write(content)
31
- return digest
32
- end
33
- def decodeDigest(digest)
34
- formula = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
35
- store = getFileStore(formula,digest,"ini")
36
- if @@backwards_compat
37
- if !store::exists()
38
- oldstore = Store::newStore(((formula+"/")+digest)+".ini")
39
- parent = store::getParent()
40
- parent::mkdirs()
41
- oldstore::moveTo(store)
11
+ attr_accessor :config
12
+ @@backwards_compat;
13
+ def self.backwards_compat
14
+ @@backwards_compat
42
15
  end
43
- end
44
- return store::read()
45
- end
46
- def retreiveData(digest,service)
47
- formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
48
- store = getFileStore(formula,digest,getExtension(service))
49
- if @@backwards_compat
50
- if !store::exists()
51
- oldstore = Store::newStore((((formula+"/")+digest)+".")+getExtension(service))
52
- if !oldstore::exists()
53
- return nil
54
- end
55
- parent = store::getParent()
56
- parent::mkdirs()
57
- oldstore::moveTo(store)
16
+ def self.backwards_compat=(backwards_compat)
17
+ @@backwards_compat = backwards_compat
58
18
  end
59
- else
60
- if !store::exists()
61
- return nil
19
+ attr_accessor :cache
20
+ attr_accessor :cacheFormula
21
+ def initialize()
22
+ super()
62
23
  end
63
- end
64
- return store::readBinary()::getData()
65
- end
66
- def storeData(digest,service,stream)
67
- formula = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
68
- parent = getFolderStore(formula,digest)
69
- parent::mkdirs()
70
- store = getFileStoreWithParent(parent,digest,getExtension(service))
71
- store::writeBinary(Bytes::ofData(stream))
72
- end
73
- def getAndCheckFolder(key)
74
- folder = PropertiesTools::getProperty(@config,key)
75
- if (folder==nil)||(folder::trim()::length()==0)
76
- raise Exception,"Missing configuration value: "+key
77
- end
78
- return folder
79
- end
80
- def getExtension(service)
81
- if (service=="png")
82
- return "png"
83
- end
84
- if (service=="svg")
85
- return "svg"
86
- end
87
- return service+".txt"
88
- end
89
- def getFolderStore(dir,digest)
90
- return Store::newStore((((dir+"/")+Std::substr(digest,0,2).to_s)+"/")+Std::substr(digest,2,2).to_s)
91
- end
92
- def getFileStoreWithParent(parent,digest,extension)
93
- return Store::newStoreWithParent(parent,(Std::substr(digest,4).to_s+".")+extension)
94
- end
95
- def getFileStore(dir,digest,extension)
96
- return getFileStoreWithParent(getFolderStore(dir,digest),digest,extension)
97
- end
98
- def updateFoldersStructure()
99
- updateFolderStructure(getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER))
100
- updateFolderStructure(getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER))
101
- end
102
- def updateFolderStructure(dir)
103
- folder = Store::newStore(dir)
104
- files = folder::list()
105
- if files!=nil
106
- for i in 0..files::length-1
107
- digest = isFormulaFileName(files[i])
108
- if digest!=nil
109
- newFolder = getFolderStore(dir,digest)
110
- newFolder::mkdirs()
111
- newFile = getFileStoreWithParent(newFolder,digest,Std::substr(files[i],files[i]::indexOf(".")+1))
112
- file = Store::newStoreWithParent(folder,files[i])
113
- file::moveTo(newFile)
24
+ def init(obj, config, cache, cacheFormula)
25
+ self.config = config
26
+ self.cache = cache
27
+ self.cacheFormula = cacheFormula
28
+ end
29
+ def codeDigest(content)
30
+ digest = Md5Tools::encodeString(content)
31
+ begin
32
+ self.cacheFormula::set(digest + ".ini",Bytes::ofData(Utf8::toBytes(content)))
114
33
  end
115
- i+=1
116
- end
117
- end
118
- end
119
- def isFormulaFileName(name)
120
- i = name::indexOf(".")
121
- if i==-1
122
- return nil
123
- end
124
- digest = Std::substr(name,0,i)
125
- if digest::length()!=32
126
- return nil
127
- end
128
- return digest
129
- end
130
- def deleteCache()
131
- formulaFolder = getAndCheckFolder(ConfigurationKeys::FORMULA_FOLDER)
132
- cacheFolder = getAndCheckFolder(ConfigurationKeys::CACHE_FOLDER)
133
- includes = Array.new()
134
- includes::push("png")
135
- includes::push("csv")
136
- includes::push("txt")
137
- if !(PropertiesTools::getProperty(@config,ConfigurationKeys::SAVE_MODE,"xml")=="image")
138
- includes::push("ini")
139
- end
140
- Store::deleteDirectory(formulaFolder,includes)
141
- Store::deleteDirectory(cacheFolder,includes)
34
+ return digest
35
+ end
36
+ def decodeDigest(digest)
37
+ data = self.cacheFormula::get(digest + ".ini")
38
+ if data != nil
39
+ return Utf8::fromBytes(data::getData())
40
+ else
41
+ return nil
42
+ end
43
+ end
44
+ def retreiveData(digest, service)
45
+ data = self.cache::get((digest + ".") + getExtension(service))
46
+ if data != nil
47
+ return data::getData()
48
+ else
49
+ return nil
50
+ end
51
+ end
52
+ def storeData(digest, service, stream)
53
+ begin
54
+ self.cache::set((digest + ".") + self.getExtension(service),Bytes::ofData(stream))
55
+ end
56
+ end
57
+ def getExtension(service)
58
+ if (service == "png")
59
+ return "png"
60
+ end
61
+ if (service == "svg")
62
+ return "svg"
63
+ end
64
+ return service + ".txt"
65
+ end
66
+ def deleteCache()
67
+ cache = CacheImpl.new(self.config)
68
+ begin
69
+ cache::deleteAll()
70
+ end
71
+ end
72
+
73
+ @@backwards_compat = true
142
74
  end
143
- end
144
75
  end
@@ -1,56 +1,58 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
- require('com/wiris/plugin/api/ParamsProvider.rb')
5
- class GenericParamsProviderImpl
6
- extend ParamsProviderInterface
3
+ require('com/wiris/plugin/api/ConfigurationKeys.rb')
4
+ require('com/wiris/plugin/api/ParamsProvider.rb')
5
+ require('com/wiris/plugin/api/ParamsProvider.rb')
6
+ class GenericParamsProviderImpl
7
+ extend ParamsProviderInterface
7
8
 
8
- include Wiris
9
+ include Wiris
9
10
 
10
- attr_accessor :properties
11
- def initialize(properties)
12
- super()
13
- @properties = properties
14
- end
15
- def getParameter(param,dflt)
16
- return PropertiesTools::getProperty(@properties,param,dflt)
17
- end
18
- def getRequiredParameter(param)
19
- parameter = PropertiesTools::getProperty(@properties,param,nil)
20
- if parameter!=nil
21
- return parameter
22
- else
23
- raise Exception,("Error: parameter"+param)+"is required"
24
- end
25
- end
26
- def getParameters()
27
- return @properties
28
- end
29
- def getRenderParameters(configuration)
30
- renderParams = PropertiesTools::newProperties()
31
- renderParameterList = configuration::getProperty(ConfigurationKeys::EDITOR_PARAMETERS_LIST,ConfigurationKeys::EDITOR_PARAMETERS_DEFAULT_LIST)::split(",")
32
- for i in 0..renderParameterList::length-1
33
- key = renderParameterList[i]
34
- value = PropertiesTools::getProperty(@properties,key)
35
- if value!=nil
36
- PropertiesTools::setProperty(renderParams,key,value)
37
- end
38
- i+=1
11
+ attr_accessor :properties
12
+ def initialize(properties)
13
+ super()
14
+ self.properties = properties
39
15
  end
40
- return renderParams
41
- end
42
- def getServiceParameters()
43
- serviceParams = PropertiesTools::newProperties()
44
- serviceParamListArray = Std::split(ConfigurationKeys::SERVICES_PARAMETERS_LIST,",")
45
- for i in 0..serviceParamListArray::length()-1
46
- key = serviceParamListArray::_(i)
47
- value = PropertiesTools::getProperty(@properties,key)
48
- if value!=nil
49
- PropertiesTools::setProperty(serviceParams,key,value)
50
- end
51
- i+=1
16
+ def getParameter(param, dflt)
17
+ return PropertiesTools::getProperty(self.properties,param,dflt)
52
18
  end
53
- return serviceParams
19
+ def getRequiredParameter(param)
20
+ parameter = PropertiesTools::getProperty(self.properties,param,nil)
21
+ if parameter != nil
22
+ return parameter
23
+ else
24
+ raise Exception,("Error: parameter " + param) + " is required"
25
+ end
26
+ end
27
+ def getParameters()
28
+ return self.properties
29
+ end
30
+ def getRenderParameters(configuration)
31
+ renderParams = PropertiesTools::newProperties()
32
+ renderParameterList = configuration::getProperty(ConfigurationKeys::EDITOR_PARAMETERS_LIST,ConfigurationKeys::EDITOR_PARAMETERS_DEFAULT_LIST)::split(",")
33
+ for i in 0..renderParameterList::length - 1
34
+ key = renderParameterList[i]
35
+ value = PropertiesTools::getProperty(self.properties,key)
36
+ if value != nil
37
+ PropertiesTools::setProperty(renderParams,key,value)
38
+ end
39
+ i+=1
40
+ end
41
+ return renderParams
42
+ end
43
+ def getServiceParameters()
44
+ serviceParams = PropertiesTools::newProperties()
45
+ serviceParamListArray = Std::split(ConfigurationKeys::SERVICES_PARAMETERS_LIST,",")
46
+ for i in 0..serviceParamListArray::length() - 1
47
+ key = serviceParamListArray::_(i)
48
+ value = PropertiesTools::getProperty(self.properties,key)
49
+ if value != nil
50
+ PropertiesTools::setProperty(serviceParams,key,value)
51
+ end
52
+ i+=1
53
+ end
54
+ return serviceParams
55
+ end
56
+
54
57
  end
55
- end
56
58
  end
@@ -1,53 +1,54 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- class HttpImpl < Http
4
- include Wiris
3
+ class HttpImpl < Http
4
+ include Wiris
5
+
6
+ attr_accessor :data
7
+ attr_accessor :listener
8
+ def initialize(url, listener)
9
+ super(url)
10
+ self.listener = listener
11
+ end
12
+ def request(post)
13
+ proxy = getProxy()
14
+ if ((proxy != nil) && (proxy::host != nil)) && (proxy::host::length() > 0)
15
+ hpa = (proxy::auth)
16
+ if (hpa::user != nil) && (hpa::user::length() > 0)
17
+ data = Base64.new()::encodeBytes(Bytes::ofString((hpa::user.to_s + ":") + hpa::pass.to_s))::toString()
18
+ self.setHeader("Proxy-Authorization","Basic " + data)
19
+ end
20
+ end
21
+ super(post)
22
+ end
23
+ def onData(data)
24
+ self.data = data
25
+ if @listener != nil
26
+ @listener::onData(data)
27
+ end
28
+ end
29
+ def onError(msg)
30
+ if @listener != nil
31
+ @listener::onError(msg)
32
+ else
33
+ raise Exception,msg
34
+ end
35
+ end
36
+ def getData()
37
+ return @data
38
+ end
39
+ def getProxy()
40
+ proxy = Reflect::field(Http,"PROXY")
41
+ if proxy == nil
42
+ return nil
43
+ end
44
+ return (proxy)
45
+ end
46
+ def setProxy(proxy)
47
+ Reflect::setField(Http,"PROXY",proxy)
48
+ end
49
+ def setListener(listener)
50
+ self.listener = listener
51
+ end
5
52
 
6
- attr_accessor :data
7
- attr_accessor :listener
8
- def initialize(url,listener)
9
- super(url)
10
- @listener = listener
11
- end
12
- def request(post)
13
- proxy = getProxy()
14
- if ((proxy!=nil)&&(proxy::host!=nil))&&(proxy::host::length()>0)
15
- hpa = (proxy::auth)
16
- if (hpa::user!=nil)&&(hpa::user::length()>0)
17
- data = Base64.new()::encodeBytes(Bytes::ofString((hpa::user.to_s+":")+hpa::pass.to_s))::toString()
18
- setHeader("Proxy-Authorization","Basic "+data)
19
- end
20
- end
21
- super(post)
22
- end
23
- def onData(data)
24
- @data = data
25
- if @listener!=nil
26
- @listener::onData(data)
27
- end
28
- end
29
- def onError(msg)
30
- if @listener!=nil
31
- @listener::onError(msg)
32
- else
33
- raise Exception,msg
34
- end
35
- end
36
- def getData()
37
- return @data
38
- end
39
- def getProxy()
40
- proxy = Reflect::field(Http,"PROXY")
41
- if proxy==nil
42
- return nil
43
- end
44
- return (proxy)
45
- end
46
- def setProxy(proxy)
47
- Reflect::setField(Http,"PROXY",proxy)
48
- end
49
- def setListener(listener)
50
- @listener = listener
51
53
  end
52
- end
53
54
  end
@@ -1,8 +1,8 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- module HttpListenerInterface
4
- def HttpListener
5
- return true
6
- end
7
- end
3
+ module HttpListenerInterface
4
+ def HttpListener
5
+ return true
6
+ end
7
+ end
8
8
  end
@@ -1,73 +1,81 @@
1
1
  module WirisPlugin
2
2
  include Wiris
3
- require('com/wiris/plugin/api/ImageFormatController.rb')
4
- class ImageFormatControllerPng
5
- extend ImageFormatControllerInterface
3
+ require('com/wiris/plugin/api/ImageFormatController.rb')
4
+ require('com/wiris/plugin/api/ImageFormatController.rb')
5
+ class ImageFormatControllerPng
6
+ extend ImageFormatControllerInterface
6
7
 
7
- include Wiris
8
+ include Wiris
8
9
 
9
- def initialize()
10
- super()
11
- end
12
- def getContentType()
13
- return "image/png"
14
- end
15
- def getMetrics(bytes,ref_output)
16
- output = ref_output
17
- width = 0
18
- height = 0
19
- dpi = 0
20
- baseline = 0
21
- bi = BytesInput.new(bytes)
22
- n = bytes::length()
23
- alloc = 10
24
- b = Bytes::alloc(alloc)
25
- bi::readBytes(b,0,8)
26
- n-= 8
27
- while n>0
28
- len = bi::readInt32()
29
- typ = bi::readInt32()
30
- if typ==1229472850
31
- width = bi::readInt32()
32
- height = bi::readInt32()
33
- bi::readInt32()
34
- bi::readByte()
35
- else
36
- if typ==1650545477
37
- baseline = bi::readInt32()
38
- else
39
- if typ==1883789683
40
- dpi = bi::readInt32()
41
- dpi = (Math::round(dpi/39.37))
42
- bi::readInt32()
43
- bi::readByte()
10
+ def initialize()
11
+ super()
12
+ end
13
+ def getContentType()
14
+ return "image/png"
15
+ end
16
+ def getMetrics(bytes, ref_output)
17
+ output = ref_output
18
+ width = 0
19
+ height = 0
20
+ dpi = 0
21
+ baseline = 0
22
+ bi = BytesInput.new(bytes)
23
+ n = bytes::length()
24
+ alloc = 10
25
+ b = Bytes::alloc(alloc)
26
+ bi::readBytes(b,0,8)
27
+ n -= 8
28
+ while n > 0
29
+ len = bi::readInt32()
30
+ typ = bi::readInt32()
31
+ if typ == 1229472850
32
+ width = bi::readInt32()
33
+ height = bi::readInt32()
34
+ bi::readInt32()
35
+ bi::readByte()
36
+ else
37
+ if typ == 1650545477
38
+ baseline = bi::readInt32()
39
+ else
40
+ if typ == 1883789683
41
+ dpi = bi::readInt32()
42
+ dpi = (Math::round(dpi/39.37))
43
+ bi::readInt32()
44
+ bi::readByte()
45
+ else
46
+ if len > alloc
47
+ alloc = len
48
+ b = Bytes::alloc(alloc)
49
+ end
50
+ bi::readBytes(b,0,len)
51
+ end
52
+ end
53
+ end
54
+ bi::readInt32()
55
+ n -= len + 12
56
+ end
57
+ if output != nil
58
+ PropertiesTools::setProperty(output,"width","" + width.to_s)
59
+ PropertiesTools::setProperty(output,"height","" + height.to_s)
60
+ PropertiesTools::setProperty(output,"baseline","" + baseline.to_s)
61
+ if dpi != 96
62
+ PropertiesTools::setProperty(output,"dpi","" + dpi.to_s)
63
+ end
64
+ r = ""
44
65
  else
45
- if len>alloc
46
- alloc = len
47
- b = Bytes::alloc(alloc)
48
- end
49
- bi::readBytes(b,0,len)
66
+ r = (((("&cw=" + width.to_s) + "&ch=") + height.to_s) + "&cb=") + baseline.to_s
67
+ if dpi != 96
68
+ r = (r + "&dpi=") + dpi.to_s
69
+ end
50
70
  end
51
- end
52
- end
53
- bi::readInt32()
54
- n-= len+12
55
- end
56
- if output!=nil
57
- PropertiesTools::setProperty(output,"width",""+width.to_s)
58
- PropertiesTools::setProperty(output,"height",""+height.to_s)
59
- PropertiesTools::setProperty(output,"baseline",""+baseline.to_s)
60
- if dpi!=96
61
- PropertiesTools::setProperty(output,"dpi",""+dpi.to_s)
71
+ return r
62
72
  end
63
- r = ""
64
- else
65
- r = (((("&cw="+width.to_s)+"&ch=")+height.to_s)+"&cb=")+baseline.to_s
66
- if dpi!=96
67
- r = (r+"&dpi=")+dpi.to_s
73
+ def scalateMetrics(dpi, metrics)
74
+ f = 96/dpi
75
+ metrics::set("width",(f*metrics::get("width")))
76
+ metrics::set("height",(f*metrics::get("height")))
77
+ metrics::set("baseline",(f*metrics::get("baseline")))
68
78
  end
69
- end
70
- return r
79
+
71
80
  end
72
- end
73
81
  end