CommonLang.xba 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <!--
  4. * This file is part of the LibreOffice project.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. *
  10. * This file incorporates work covered by the following license notice:
  11. *
  12. * Licensed to the Apache Software Foundation (ASF) under one or more
  13. * contributor license agreements. See the NOTICE file distributed
  14. * with this work for additional information regarding copyright
  15. * ownership. The ASF licenses this file to you under the Apache
  16. * License, Version 2.0 (the "License"); you may not use this file
  17. * except in compliance with the License. You may obtain a copy of
  18. * the License at http://www.apache.org/licenses/LICENSE-2.0 .
  19. -->
  20. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="CommonLang" script:language="StarBasic">REM ***** BASIC *****
  21. &apos; Column A has the index 1
  22. Public Const SBCOLUMNNAME1 = 3 &apos; Stock names, sheet 1
  23. Public Const SBCOLUMNID1 = 4 &apos; Stock ID, sheet 1
  24. Public Const SBCOLUMNQUANTITY1 = 5 &apos; Stock quantity sheet 1
  25. Public Const SBCOLUMNRATE1 = 7 &apos; Price for stocks, sheet 1
  26. Public Const SBCOLUMNNAME2 = 3 &apos; Stock names, sheet 2
  27. Public Const SBCOLUMNDATE2 = 4 &apos; Transaction dates, sheet 2
  28. Public Const SBCOLUMNQUANTITY2 = 5 &apos; Transaction quantity, sheet 2
  29. Public Const SBCOLUMNRATE2 = 6 &apos; Price for stocks, sheet 2
  30. Public Const SBCOLUMNPROVPERCENT2 = 7 &apos; Provision in %, sheet 2
  31. Public Const SBCOLUMNPROVMIN2 = 8 &apos; Minimum provision, sheet 2
  32. Public Const SBCOLUMNPROVFIX2 = 9 &apos; Fixed provision, sheet 2
  33. Public Const SBCOLUMNPROCEEDS2 = 12 &apos; Profit, sheet 2
  34. Public Const SBCOLUMNQTYSOLD2 = 14 &apos; Quantity sold, sheet 2
  35. Public Const SBCOLUMNQTYREST2 = 15 &apos; Quantity not sold yet, sheet 2
  36. Public Const SBCOLUMNPRCREST2 = 16 &apos; Proportional price for quantity not sold yet, sheet 2
  37. Public Const SBCOLUMNREALPROC2 = 17 &apos; Realized proceeds, sheet 2
  38. Public Const SBCOLUMNDIVIDEND2 = 18 &apos; Dividend paid, sheet 2
  39. Public Const SBCOLUMNREALPROFIT2 = 19 &apos; Realized profit, sheet 2
  40. Public Const SBROWFIRSTTRANSACT2 = 8 &apos; First data row, sheet 2
  41. Public Const SBROWHEADER1 = 6 &apos; Headline, sheet 1
  42. Public Const SBMSGOK = 0
  43. Public Const SBMSGYESNO = 4
  44. Public Const SBMSGSTOP = 16
  45. Public Const SBMSGQUESTION = 32
  46. Public Const SBMSGDEFAULTBTN2 = 256
  47. Public Const SBHASID = 1 &apos; 0 = no ID, 1 = stocks have an ID
  48. Public Const SBDIALOGSELL = 1 &apos; Step for main dialog
  49. Public Const SBDIALOGBUY = 2 &apos; Step for main dialog
  50. Public Const SBBINARY = 0
  51. Public TransactMode as Integer
  52. Public Const LIFO = -1
  53. Public Const FIFO = 1
  54. Public Const HANDLEDIVIDEND = 1
  55. Public Const HANDLESPLIT = 2
  56. Global oDocument as Object
  57. Global oDocFormats() as Object
  58. Global oController as Object
  59. Global oFirstSheet as Object
  60. Global oBankSheet as Object
  61. Global oMovementSheet as Object
  62. Global sDocLanguage as String
  63. Global sDocCountry as String
  64. Global oSheets as Object
  65. Global oDocLocale as New com.sun.star.lang.Locale
  66. Global bEnableMarket as Boolean
  67. Global bEnableInternet as Boolean
  68. Global oMarketModel as Object
  69. Global oInternetModel as Object
  70. Global sCurCurrency$, sCurExtension$, sCurChartSource$, sCurStockIDLabel$, sCurSeparator$
  71. Public oNumberFormatter as Object
  72. Public bDebugmode as Boolean
  73. Global GlobListindex as Integer
  74. Public blabla() as String
  75. Public SplitDate as Date
  76. Public oChartSheet as Object
  77. Public oBackgroundSheet as Object
  78. Public Const SBDATECOLUMN = 3
  79. Public Const SBVALUECOLUMN = 4
  80. Public Const SBSTARTROW = 25
  81. Public Const SBCHARTPERIOD = 14
  82. Public Const SBINTERVAL = &quot;d&quot;
  83. Public sColumnHeader as String
  84. Public StartDate as Date
  85. Public EndDate as Date
  86. Public iCurRow as Integer
  87. Public iMaxRow as Integer
  88. Public iStartDay as Integer
  89. Public iStartMonth as Integer
  90. Public iStartYear as Integer
  91. Public iEndDay as Integer
  92. Public iEndMonth as Integer
  93. Public iEndYear as Integer
  94. Public oStatusLine as Object
  95. Public Today as Date
  96. Public sInterval as String
  97. Public ShortMonths(11,1)
  98. Public iStep as Integer
  99. Public sDepotCurrency as String
  100. Public iValueCol as Integer
  101. Public DlgReference as Object
  102. Public DlgTransaction as Object
  103. Public DlgStockRates as Object
  104. Public DlgStartUp as Object
  105. Public TransactModel as Object
  106. Public StockRatesModel as Object
  107. Public StartUpModel as Object
  108. Public StockRatesTitle(1 To 3)
  109. Public TransactTitle(1 To 2)
  110. Public NullList()
  111. Public sStartupWelcome$, sStartupChooseMarket$, sStartupHint$
  112. Public sMarket(7,10) as String
  113. Public sCountryMarket(7,10) as String
  114. Public cDlgCaption1$, cDlgCaption2$
  115. Public sMsgError$, sMsgNoName$, sMsgNoQuantity$, sMsgNoDividend$, sMsgNoExchangeRate$
  116. Public sMsgNoValidExchangeDate$, sMsgWrongExchangeDate$, sMsgSellTooMuch$, sMsgConfirm$
  117. Public sMsgFreeStock$, sMsgTotalLoss$, sMsgEndDatebeforeNow$, sMsgStartDatebeforeEndDate$
  118. Public sOk$, sCancel$
  119. Public sMsgAuthorization$, sMsgDeleteAll$
  120. Public SellMethod$
  121. Public cSplit$
  122. Global HistoryChartSource as String
  123. Public DateCellStyle as String
  124. Public CurrCellStyle as String
  125. Public sStartDate$, sEndDate$, sHistory$
  126. Public sInsertStockname$
  127. Public sProductname$, sTitle$
  128. Public sInsertStocks$, sStockname$, sNoInternetUpdate$, sMarketplace$, sNoInternetDataAvailable$
  129. Public sCheckInternetSettings as String
  130. Sub LoadLanguage()
  131. LoadDepotDialogs()
  132. Select Case sDocLanguage
  133. Case &quot;de&quot;
  134. LoadGermanLanguage()
  135. Case &quot;en&quot;
  136. LoadEnglishLanguage()
  137. Case &quot;fr&quot;
  138. LoadFrenchLanguage()
  139. Case &quot;it&quot;
  140. LoadItalianLanguage()
  141. Case &quot;es&quot;
  142. LoadSpanishLanguage()
  143. Case &quot;sv&quot;
  144. LoadSwedishLanguage()
  145. Case &quot;ja&quot;
  146. LoadJapaneseLanguage()
  147. Case &quot;ko&quot;
  148. LoadKoreanLanguage()
  149. Case &quot;zh&quot;
  150. If sDocCountry = &quot;CN&quot; Then
  151. LoadChineseSimpleLanguage()
  152. Else
  153. LoadChineseTradLanguage()
  154. End If
  155. End Select
  156. InitializeStartUpModel()
  157. End Sub
  158. Sub CompleteMarketList()
  159. Dim EuroIndex as Integer
  160. Dim LocCountry as String
  161. Dim LocLanguage as String
  162. Dim sLangList() as String
  163. Dim sCountryList() as String
  164. Dim sExtensionList() as String
  165. Dim MaxIndex as Integer
  166. Dim bIsLocale as Boolean
  167. GlobListIndex = -1
  168. For n = 0 To 5
  169. LocLanguage = sMarket(n,6)
  170. LocCountry = sMarket(n,7)
  171. If Instr(1,LocLanguage,&quot;;&quot;,SBBINARY) = 0 Then
  172. bIsLocale = CheckDocLocale(LocLanguage, LocCountry)
  173. Else
  174. EuroIndex = 0
  175. sLangList() = ArrayoutofString(LocLanguage, &quot;;&quot;, MaxIndex)
  176. sCountryList() = ArrayoutofString(LocCountry, &quot;;&quot;, MaxIndex)
  177. sExtensionList() = ArrayoutofString(sMarket(n,8), &quot;;&quot;, MaxIndex)
  178. For m = 0 To MaxIndex
  179. bIsLocale = CheckDocLocale(sLangList(m), sCountryList(m))
  180. If bIsLocale Then
  181. EuroIndex = m
  182. Exit For
  183. End If
  184. Next m
  185. sMarket(n,6) = sLangList(EuroIndex)
  186. sMarket(n,7) = sCountryList(EuroIndex)
  187. sMarket(n,8) = sExtensionList(EuroIndex)
  188. End If
  189. If bIsLocale Then
  190. GlobListIndex = n
  191. Exit For
  192. End If
  193. Next n
  194. End Sub
  195. Sub LocalizedCurrencies()
  196. If GlobListIndex = -1 Then
  197. sCountryMarket(0,0) = &quot;Euro&quot;
  198. sCountryMarket(0,1) = chr(8364)
  199. sCountryMarket(0,2) = &quot;Paris&quot;
  200. sCountryMarket(0,3) = &quot;http://fr.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.PA&amp;f=s4l1t1c1ghov&amp;e=.csv&quot;
  201. sCountryMarket(0,5) = &quot;Code&quot;
  202. sCountryMarket(0,6) = &quot;fr&quot;
  203. sCountryMarket(0,7) = &quot;FR&quot;
  204. sCountryMarket(0,8) = &quot;40C&quot;
  205. sCountryMarket(0,9) = &quot;59/9&quot;
  206. sCountryMarket(0,10) = &quot;1&quot;
  207. sCountryMarket(1,0) = &quot;Euro&quot;
  208. sCountryMarket(1,1) = chr(8364)
  209. sCountryMarket(1,2) = &quot;Milano&quot;
  210. sCountryMarket(1,3) = &quot;http://it.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.MI&amp;f=sl1d1t1c1ohgv&amp;e=.csv&quot;
  211. sCountryMarket(1,5) = &quot;Codice&quot;
  212. sCountryMarket(1,6) = &quot;it&quot;
  213. sCountryMarket(1,7) = &quot;IT&quot;
  214. sCountryMarket(1,8) = &quot;410&quot;
  215. sCountryMarket(1,9) = &quot;44&quot;
  216. sCountryMarket(1,10) = &quot;1&quot;
  217. sCountryMarket(2,0) = &quot;Euro&quot;
  218. sCountryMarket(2,1) = chr(8364)
  219. sCountryMarket(2,2) = &quot;Madrid&quot;
  220. sCountryMarket(2,3) = &quot;http://es.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;&amp;m=MC&amp;f=sl1d1t1c1ohgv&amp;e=.csv&quot;
  221. sCountryMarket(2,5) = &quot;Simbolo&quot;
  222. sCountryMarket(2,6) = &quot;es&quot;
  223. sCountryMarket(2,7) = &quot;ES&quot;
  224. sCountryMarket(2,8) = &quot;40A&quot;
  225. sCountryMarket(2,9) = &quot;44&quot;
  226. sCountryMarket(2,10) = &quot;1&quot;
  227. sCountryMarket(3,0) = &quot;Dansk krone&quot;
  228. sCountryMarket(3,1) = &quot;kr&quot;
  229. sCountryMarket(3,2) = &quot;København&quot;
  230. sCountryMarket(3,3) = &quot;http://dk.finance.yahoo.com/d/quotes.csv?s=&lt;StockID.CO&amp;f=sl1d1t1c1ohgv&amp;e=.csv&quot;
  231. sCountryMarket(3,5) = &quot;Aktiesymbol&quot;
  232. sCountryMarket(3,6) = &quot;da&quot;
  233. sCountryMarket(3,7) = &quot;DK&quot;
  234. sCountryMarket(3,8) = &quot;406&quot;
  235. sCountryMarket(3,9) = &quot;44&quot;
  236. sCountryMarket(3,10) = &quot;1&quot;
  237. sCountryMarket(4,0) = &quot;Svensk krona&quot;
  238. sCountryMarket(4,1) = &quot;kr&quot;
  239. sCountryMarket(4,2) = &quot;Stockholm&quot;
  240. sCountryMarket(4,3) = &quot;http://se.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.L&amp;f=sl1d1t1c1ohgv&amp;e=.c&quot;
  241. sCountryMarket(4,5) = &quot;Kod&quot;
  242. sCountryMarket(4,6) = &quot;sv&quot;
  243. sCountryMarket(4,7) = &quot;SE&quot;
  244. sCountryMarket(4,8) = &quot;41D&quot;
  245. sCountryMarket(4,9) = &quot;44&quot;
  246. sCountryMarket(4,10) = &quot;1&quot;
  247. &apos; Taiwan Dollar
  248. sCountryMarket(5,0) = &quot;新臺幣&quot;
  249. sCountryMarket(5,1) = &quot;¥&quot;
  250. sCountryMarket(5,2) = &quot;代號&quot;
  251. sCountryMarket(5,3) = &quot;http://tw.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.TW&amp;f=sl1d1t1c1ohgv&amp;e=.csv&quot;
  252. sCountryMarket(5,5) = &quot;代號&quot;
  253. sCountryMarket(5,6) = &quot;zh&quot;
  254. sCountryMarket(5,7) = &quot;TW&quot;
  255. sCountryMarket(5,8) = &quot;404&quot;
  256. sCountryMarket(5,9) = &quot;44&quot;
  257. sCountryMarket(5,10) = &quot;1&quot;
  258. &apos; Chinese Yuan
  259. sCountryMarket(6,0) = &quot;人民币&quot;
  260. sCountryMarket(6,1) = &quot;¥&quot;
  261. sCountryMarket(6,2) = &quot;代号&quot;
  262. sCountryMarket(6,3) = &quot;http://cn.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.SS&amp;f=sl1d1t1c1ohgv&amp;e=.csv&quot;
  263. sCountryMarket(6,5) = &quot;代号&quot;
  264. sCountryMarket(6,6) = &quot;zh&quot;
  265. sCountryMarket(6,7) = &quot;CN&quot;
  266. sCountryMarket(6,8) = &quot;804&quot;
  267. sCountryMarket(6,9) = &quot;44&quot;
  268. sCountryMarket(6,10) = &quot;1&quot;
  269. &apos; korean Won
  270. sCountryMarket(7,0) = &quot;한국 원화&quot;
  271. sCountryMarket(7,1) = &quot;₩&quot;
  272. sCountryMarket(7,2) = &quot;서울&quot;
  273. sCountryMarket(7,3) = &quot;http://kr.finance.yahoo.com/d/quotes.csv?s=&lt;StockID&gt;.KS&amp;f=snl1d1t1c1ohgv&amp;e=.csv&quot;
  274. sCountryMarket(7,5) = &quot;종목 코드&quot;
  275. sCountryMarket(7,6) = &quot;ko&quot;
  276. sCountryMarket(7,7) = &quot;KR&quot;
  277. sCountryMarket(7,8) = &quot;412&quot;
  278. sCountryMarket(7,9) = &quot;44&quot;
  279. sCountryMarket(7,10) = &quot;2&quot;
  280. &apos; sCountryMarket(5,0) = &quot;Российский рубль&quot;
  281. &apos; sCountryMarket(5,1) = &quot;р.&quot;
  282. &apos; sCountryMarket(5,2) = &quot;&quot;
  283. &apos; sCountryMarket(5,3) = &quot;&quot;
  284. &apos; sCountryMarket(5,5) = &quot;&quot;
  285. &apos; sCountryMarket(5,6) = &quot;ru&quot;
  286. &apos; sCountryMarket(5,7) = &quot;RU&quot;
  287. &apos; sCountryMarket(5,8) = &quot;-419&quot;
  288. &apos; sCountryMarket(5,9) = &quot;&quot;
  289. &apos;
  290. &apos; sCountryMarket(6,0) = &quot;Złoty polski&quot;
  291. &apos; sCountryMarket(6,1) = &quot;zł&quot;
  292. &apos; sCountryMarket(6,2) = &quot;&quot;
  293. &apos; sCountryMarket(6,3) = &quot;&quot;
  294. &apos; sCountryMarket(6,5) = &quot;&quot; &apos;Still Todo!!
  295. &apos; sCountryMarket(6,6) = &quot;pl&quot;
  296. &apos; sCountryMarket(6,7) = &quot;PL&quot;
  297. &apos; sCountryMarket(6,8) = &quot;-415&quot;
  298. &apos; sCountryMarket(6,9) = &quot;&quot;
  299. &apos;
  300. &apos; sCountryMarket(7,0) = &quot;Türkische Lira&quot;
  301. &apos; sCountryMarket(7,1) = &quot;TL&quot;
  302. &apos; sCountryMarket(7,2) = &quot;&quot;
  303. &apos; sCountryMarket(7,3) = &quot;&quot;
  304. &apos; sCountryMarket(7,5) = &quot;&quot; &apos;Still Todo!!
  305. &apos; sCountryMarket(7,6) = &quot;tr&quot;
  306. &apos; sCountryMarket(7,7) = &quot;TR&quot;
  307. &apos; sCountryMarket(7,8) = &quot;-41F&quot;
  308. &apos; sCountryMarket(7,9) = &quot;&quot;
  309. Dim n as Integer
  310. Dim m as Integer
  311. &apos; Dim sCountryMarket(6,9) as String
  312. For n = 0 To Ubound(sCountryMarket(),1)
  313. If sDocLanguage = sCountryMarket(n,6) and sDocCountry = sCountryMarket(n,7) Then
  314. GlobListIndex = 6
  315. For m = 0 To 10
  316. sMarket(6,m) = sCountryMarket(n,m)
  317. Next m
  318. Exit For
  319. End If
  320. Next n
  321. End If
  322. End Sub
  323. Sub LoadDepotDialogs()
  324. DlgTransaction = LoadDialog(&quot;Depot&quot;, &quot;Dialog2&quot;)
  325. DlgStockRates = LoadDialog(&quot;Depot&quot;, &quot;Dialog3&quot;)
  326. DlgStartUp = LoadDialog(&quot;Depot&quot;, &quot;Dialog4&quot;)
  327. TransactModel = DlgTransaction.Model
  328. StockRatesModel = DlgStockRates.Model
  329. StartUpModel = DlgStartUp.Model
  330. End Sub
  331. Sub InitializeStartUpModel()
  332. With StartUpModel
  333. .lblWelcome.Label = sStartupWelcome &amp; Chr(13) &amp; chr(13) &amp; sStartUpChooseMarket
  334. sStartUpHint = ReplaceString(sStartUpHint, sHistory, &quot;&lt;History&gt;&quot;)
  335. .lblHint.Label = sStartupHint
  336. &apos; .cmdGoOn.Enabled = Ubound(StartUpModel.lstMarkets.SelectedItems()) &lt;&gt; -1
  337. .cmdGoOn.Label = sOK
  338. .cmdCancel.Label = sCancel
  339. End With
  340. End Sub</script:module>