How to 追加する-in in OpenOffice.org Calc
This text is an 指示/教授/教育 on how to use the 追加する-in interface of OpenOffice.org Calc to create 付加 機能(する)/行事s, which can be used like the embedded ones. The 分析 追加する-in gives us an example, on how this could work in the practice. You should also take into account, that only basic techniques are explained. その上に this shouldn't be a 詳細(に述べる)d 指示/教授/教育 on UNO, but only some parts are について言及するd, which are used in the 状況 of solving problems in the 分析 追加する-in. The 意向 is, that you can reach a result in a few hours, without any knowledge of UNO. But you should だいたい know, what OpenOffice.org Calc is and what and how you can solve something with Calc. Of course the knowledge on how to create C-/C++-programms and which 道具s are used for that, is 必須の. For an explanation of the necessary interfaces please see the description of the 追加する-in interface at sc.openoffice.org.
A good point to start with an own 追加する-in might be to copy the explained とじ込み/提出するs and 修正する all identifier with 分析 to your own needings. E.g. to MyOwnAddin. Although this 指名する is unusual, it will help you to find the important places... ;-)
Another 発言/述べる: You will often find the use of 大型のs like constREFXPS. I didn't use this to make the source obscure, but to make the very long 表現s more readable. その上に, if you know the meaning ones, it's no longer of big 利益/興味. Important 大型のs can be 設立する in "analysisdefs.hxx".
What we need to create an 追加する-in
UDK
The so called "UNO 開発 道具" is necessary to を取り引きする the OpenOffice.org API. Descriptions and other important things around this 主題 are 位置を示すd on http://udk.openoffice.org/
OpenOffice.org Calc
If you want to run an 追加する-in, the easiest way is to use OpenOffice.org Calc. The AutoPilot for 機能(する)/行事s is a good place, where the functionality of the 追加する-in can be checked.
Solver Tarball
The 分析 追加する-in makes use of a library called "道具s", which 含む/封じ込めるs e.g. the 資源 経営者/支配人 and other usable stuff. This is not always necessary for another 追加する-in, but in this 事例/患者 it was a 広大な/多数の/重要な help.
Appropriate compiler
Find more infos on which 環境 to use on homepage of the UDK.
付加 descriptions
The OpenOffice.org Calc 事業/計画(する) has got its own homepage on http://sc.openoffice.org/. There you will also find a link to description of the 追加する-in service.
最小限 parts to use
The 分析 追加する-in おもに consists of the class "AnalysisAddIn". To 器具/実施する this class, I used the に引き続いて とじ込み/提出するs.
IDL-とじ込み/提出する
This とじ込み/提出する defines the interfaces. In this 事例/患者 it is called analysisadd.idl. All the interfaces are 位置を示すd in the module com::sun:星/主役にする::sheet:addin. All 機能(する)/行事s, which are 延長するing the OpenOffice.org Calc, are 名簿(に載せる)/表(にあげる)d here. What you define here by the 署名 of a 機能(する)/行事, will 反映する the type of the parameters and the type of return value. At the end of the module 宣言, these interfaces are 連合させるd to the service "分析". In the 分析 追加する-in we are using three interfaces: XcompatibilityNames (which will be 述べるd in the 前進するd parts to use), XAnalysis and "XAddin".
For a その上の description of the IDL stuff used here, please look at http://udk.openoffice.org/ありふれた/man/概念/unointro.html#UNOIDL and in the 状況 with 追加する-ins http://api.openoffice.org/docs/ありふれた/ref/com/sun/星/主役にする/sheet/AddIn.html.
Header とじ込み/提出する(s)
The main header とじ込み/提出する is "分析.hxx" which 含む/封じ込めるs the class "AnalysisAddIn". Each 宣言 of a 機能(する)/行事 in the IDL とじ込み/提出する matches to its 相当するもの as a method in this class. You should always consider that neither something is left out, nor may the 署名 異なる from the one in the IDL とじ込み/提出する, because the derivation is pure 事実上の.
その上に, there are several methods which must be 器具/実施するd to 供給する all 要求するd functionality for an 追加する-in.
建設者
"AnalysisAddIn()" (建設者) is called, when the 株d library is initialised. In these 追加する-in in, nothing is created at this time. This will happen, when it's necassaray (and possible) at later time.
Destructor
But much more important in the 状況 of initialise/deinitialise a 株d library is the destructor. While collecting experiences with the 扱うing of 資源s, it happend to me, that the destructor of the 資源 経営者/支配人 衝突,墜落d. In the end I 設立する out, that all 資源 経営者/支配人s are 削除するd before the destructor of a 株d library is called. In the 事例/患者 of an 追加する-in, it is nearly impossible (or with a 抱擁する 量) to 削除する 資源 経営者/支配人s by yourself. Fortunately is not really a must, because it's done from another instance.
getProgrammaticFuntionName
This is not used by OpenOffice.org Calc, but it might be 器具/実施するd, when the 追加する-in is used in another 状況.
getDisplayFunctionName
This method returns the 指名する for a given 機能(する)/行事, which should be 陳列する,発揮するd for the 使用者, e.g. in a 決まり文句/製法. In the 分析 追加する-in, the strings for this 指名するs are 蓄える/店d in 資源 とじ込み/提出するs, so you will find several ones for different languages.
getFunctionDescription
The strings which this method returns are 陳列する,発揮するd in the AutoPilot for 機能(する)/行事s to give a short description for the entire 機能(する)/行事. As the DisplayFunctionName these strings resides in 資源s.
getDisplayArgumentName
For each parameter you will find a 指名する which occurs in the parameter 名簿(に載せる)/表(にあげる). These strings are requested parameter wise.
One special parameter should be について言及するd here: The "constREFXPS&" ("com::sun::星/主役にする::beans::XPropertySet" in the IDL とじ込み/提出する) in some 機能(する)/行事s is not 明白な in the UI. It's a "hidden" parameter for which no request is 生成するd, but it must be considered in the count of parameters, when (警察などへの)密告,告訴(状)s for the other parameters are requested.
Same with 資源s 適用するs here.
getArgumentDescription
Unlike the previous method, a description of a parameter is returned, which is also used in the AutoPilot for 機能(する)/行事s. The 発言/述べるs done before also 適用するing here.
getProgrammaticCategoryName
Each 機能(する)/行事 in OpenOffice.org Calc can be 割り当てるd to a 部類. This is also used in AutoPilot for 機能(する)/行事s to make the 名簿(に載せる)/表(にあげる)ing of 機能(する)/行事s clearer. The 欠如(する) in the 現在の 実施 of Calc is, that only the predefined 部類s are 陳列する,発揮するd. But I recommend to use own 部類s (e.g. "Technical"), when the predefined don't fit the proper 状況, even if these 部類s are 陳列する,発揮するd under 追加する-in. But if one day the 使用者 defined will work, you don't need to change something! ;-)
So this method returns the 内部の 指名する for the 部類, which the 機能(する)/行事 should be 割り当てるd to.
getDisplayCategoryName
Same as getProgrammaticCategoryName but this 指名する of the 部類 will be 陳列する,発揮するd in the UI. Of course this makes only sense, if it's a 使用者 defined one. For the build in 部類s the 指名するs of course are 直す/買収する,八百長をする. In the 現在の 実施 no language 扶養家族 strings are returned. This should be done, when Calc gets support for 使用者 defined 部類s.
getCompatibilityNames
This method is very important in the 状況 with the im- and 輸出(する) of Excel とじ込み/提出するs. For each 機能(する)/行事 a 名簿(に載せる)/表(にあげる) is returned, where every element 持つ/拘留するs a 指名する and a …を伴ってing language. With this it is possible to parse a number of language variants of the 追加する-in for the 輸入する. One 発言/述べる: Excel is only able to 負担 such 追加する-in 機能(する)/行事s, which are in the same language as the 任命する/導入するd 追加する-in. In this 事例/患者, OpenOffice.org Calc is a little bit more 前進するd than Excel... :-) In the opposite direction, when 輸出(する)ing to Excel, the 任命する/導入するd OpenOffice.org language is chosen to select a 指名する.
The main goal for the 実施 of the 分析 追加する-in was to get a better compatibility to Excel. For this 推論する/理由 the "CompatibilityNames" are chosen in a way, that they are identically to those which are uses by Excel. These don't need to match the "DisplayFunctionNames", but in most 事例/患者s they do. Exceptions are the 事例/患者s, where the Excel namings 衝突する/食い違うing with already build in 機能(する)/行事s of Calc. In this 事例/患者s, a simple "_ADD" is appended to the 指名する.
setLocale
By calling this method, Calc tells the 追加する-in, in which language to operate. This 影響する/感情s of course the 資源 経営者/支配人. Because this method is called after running the 建設者, the 資源 経営者/支配人 is not initialised in the 建設者 but by calling this method. It would be even possible to change this language in the runtime, because all 扶養家族 parts will be created newly. But this is not 供給するd by OpenOffice.org.
getLocale
Gives 支援する, what is 始める,決める by setLocale before.
getServiceName
The 指名する is in this 事例/患者 簡単に "com.sun.星/主役にする.sheet.addin.分析".
getImplementationName
"com.sun.星/主役にする.sheet.addin.AnalysisImpl" is given 支援する here.
supportsService
This method checks, wether a requested service can be supported or not. The 分析 追加する-in supports only "com.sun.星/主役にする.sheet.AddIn" and "com.sun.星/主役にする.sheet.addin.分析".
getSupportedServiceNames
In the returned sequence of strings are all services 名簿(に載せる)/表(にあげる)d, which are supported by the 追加する-in. This is a little bit "二塁打" to supportsService, but it must be 器具/実施するd to 会合,会う the 必要物/必要条件s of an 追加する-in 実施. The strings are same as supportsService can check.
Other methods in the class AnalysisAddIn
I'm only explaining that 機能(する)/行事s, which gives a good overview of the ways parameter can be passed to and from a 機能(する)/行事. A good description of possible parameters can also be 設立する on http://api.openoffice.org/docs/ありふれた/ref/com/sun/星/主役にする/sheet/AddIn.html.
getWorkday
This 機能(する)/行事 returns a simple 調印するd integer with a length of 32 Bits (sal_Int32). Even this is just a simple number, it 代表するs a date. This date can be 陳列する,発揮するd in OpenOffice.org Calc by choosing a proper date 判型 for a 独房. The meaning of this number is the 相殺する in days from a given base date. So it is necessary to get this base date to do the date 計算/見積りs in the 権利 way, e.g. if you try to get the weekday, month, etc. from a date. For this 目的 the first parameter is good for. The XPropertySet 含む/封じ込めるs a PropertyValue 指名するd "NullDate", which is the について言及するd base for all date 計算/見積りs in Calc.
In the 状況 of passing parameters to an 追加する-in another 発言/述べる is 必須の: When a 使用者 e.g. enters a floating point value, the resulting 二塁打 value is 削減(する) to a sal_Int32. So there is no need to do this in the 追加する-in. This also 適用するs to strings entered 直接/まっすぐに (not strings which are the result of a 言及/関連). When the 機能(する)/行事s want to have a number, Calc will 変える the text to a proper number.
The next very important parameter is the ANY (::com::sun::星/主役にする::uno::Any). This data type can carry さまざまな other (basic) data types like 二塁打, OUString, Sequence, 無効の... An optional paramter will be 代表するd e.g. by 無効の, when this parameter is left empty from the 使用者. But be carefull: The content of an empty 独房 is an empty string, not a 無効の as you may 推定する/予想するd. This must be considered when 取引,協定ing with a 範囲 of 独房s as a parameter and empty 独房s must be ignored for the 計算/見積り.
getYearfrac
This method gives 支援する a 二塁打. This data type is 類似の to the usage of a sal_Int32, but with a bigger 鮮明度/定義 範囲. A special 使用/適用 for a 二塁打 could also be the combination of a date and a time. In this 事例/患者 the わずかの part of the number is the day time 表明するd as a fraction of a whole day. E.g. "0.5" would be 陳列する,発揮するd as "12:00" when you choose a number 判型 like "hh:mm".
getIseven
This 機能(する)/行事 is another example of the different meaning of number. The returned sal_Int32 is used as a boolean value where a 無 簡単に means 誤った and all other numbers true. This behaviour is like in C/C++.
getMultinomial
When a 範囲 is used as a parameter, e.g. "A1:D42", a sequence of sequences (in this 事例/患者 of sal_Int32) is passed to the method. The 実施 of this 機能(する)/行事 is also a good example on how to get each element of a sequence (of sequences).
What is 行方不明の as an example in the 分析 追加する-in
Whenever you want to do 計算/見積りs with matrixes, a sequence of sequences must be given 支援する as the result. Calc will call the 機能(する)/行事 ones and copy the 選び出す/独身 results to the matching 独房s, depending on how the 決まり文句/製法 was entered. E.g., if you enter the matrix 決まり文句/製法 in the array A1:E5 and you give 支援する a 5x5 sequence as the result of your 機能(する)/行事, you will find each element of the sequence in the corresponding 独房. Since you won't find an example for this 目的, just try to play around on your own... ;-)
How errors are returned to Calc
When errors occur in an 追加する-in, an exception is thrown to 示す, that something went wrong. In the 現在の 実施, there are only two different exceptions used: RuntimeException and IllegalArgumentException.
The RuntimeException is thrown, when the 資源 経営者/支配人 could not be initialised.
But whenever a value paramter is 無効の or a 計算/見積り can't be done (for several 推論する/理由s), an IllegalArgumentException is used. Other errors (e.g. number of parameters is wrong) are checked by Calc so the 機能(する)/行事 in the 追加する-in isn't called in this 事例/患者s. That's why other errors than "違法な Argument" can be shown, although the 追加する-in 機能(する)/行事s only use this one.
Source とじ込み/提出する(s)
Most things in the 状況 of the needed methods are already について言及するd in the part before. Here I want to draw your attention on some structs, wich might 減ずる the 量 of work for a new 追加する-in.
For each 機能(する)/行事 the 追加する-in has to know a bunch of (警察などへの)密告,告訴(状) which are asked from Calc in the initialisation 段階 (see also the description of getProgrammaticFuntionName up to getSupportedServiceNames). This (警察などへの)密告,告訴(状) is 蓄える/店d in the (米)棚上げする/(英)提議する pFuncDataArr at the beginning of "analysishelper.cxx". Each line 拡大するs to the info about the 内部の 指名する (of the method to the 機能(する)/行事), 資源 ID of the UI 指名する, 資源 ID of the 機能(する)/行事 description (also with parameter 指名する and parameter description), a boolean value which is true if the 指名する already 存在するs in Calc, a boolean value which is true when the 内部の parameter (XPropertySet) is passed to the 機能(する)/行事, 資源 ID of the 名簿(に載せる)/表(にあげる) for the translated 機能(する)/行事 指名するs for several languages, the number of parameters which are 述べるd and at least the 部類 to which the 機能(する)/行事 should belong to. Because the 資源 IDs and the method 指名するs use a 類似の 指名する 計画/陰謀, the necessary number of 詳細(に述べる)s in a data line is 減ずるd with the use of a 大型の to good readable 量. Another 産する/生じる is the good extendability of this (米)棚上げする/(英)提議する.
When you go into the sources you might wonder, why in some 事例/患者s a functionality is 器具/実施するd, which is already availlable in other parts of the OpenOffice.org. 井戸/弁護士席, this is done because we 手配中の,お尋ね者 the 分析 追加する-in to be as 独立した・無所属 as possible from the OpenOffice.org. The optimum would have been to be only 扶養家族 from UNO (or the UDK). This was not possible at all, e.g. the 扱うing of the 資源s is to 複雑にするd. But when you create your own 追加する-in it would be possible (without the use of 資源s and other small things) to be 独立した・無所属 from these 株d libs so you can use your 追加する-in in さまざまな 見解/翻訳/版s of OpenOffice.org Calc until the UDK changes its 見解/翻訳/版 (this happens much いっそう少なく for the UDK than for the OpenOffice.org!). The 分析 追加する-in must however be build new when the 見解/翻訳/版 number (e.g. 632 -> 638) of the OpenOffice.org is changed. This is of course uncomfortable when you have to do a build every several weeks to be always up to date even if you didn't change a bit of your own code.
前進するd parts to use
One big goal of the 分析 追加する-in should have been the ability to 供給する the 機能(する)/行事 指名する translation for as much languages (in which the Excel 分析 追加する-in is 供給するd for) as possible. To 達成する this I used 資源s to get 多重の language support for the 指名するs and descriptions. So depending from the 任命する/導入するd language, you will get the proper (hope so) translation of all strings. A 味方する 影響 of our translation 過程 is, that I get a 名簿(に載せる)/表(にあげる) of all translated 機能(する)/行事 指名するs in the a 訂正する character encoding (UTF-8) from an 中間の とじ込み/提出する. Read more to this topic later in a に引き続いて paragraph. Even so it's not that hard to use 資源s, it would be much heavier to translate them into several languages. It's not the 過程 of translating itself which is not so 平易な, but to 変える the strings to an encoding, which the 資源 経営者/支配人 can 対処する with. Internally we use several 道具s and automatism to 支配(する)/統制する the flow of the data from the 開発 <-> translation. Because this is not yet 利用できる / usable for the public, it's not 平易な to 供給する more than English for an 部外者. Perhaps this will change in the 未来.
When 取引,協定ing with 資源s, we need IDs to select the 願望(する)d one out of *.res-とじ込み/提出するs. These IDs are 位置を示すd in "分析.hrc". The description of the 機能(する)/行事s and the 指名する and description of the parameters is 位置を示すd in "分析.src". In each sub-資源 you will find several strings. The first one (String 1) is always the 機能(する)/行事 description. After this (String 2) the 指名する and description (String 3) of the first parameter is に引き続いて. String 4 and String 5 belongs to the second parameter, and so on. The first step in the 開発 was the 供給するing of the texts without tag (default 開発 languages = German) and (if possible) the English. The 残り/休憩(する) of the strings was 合併するd with the above について言及するd 道具s for the translation. To learn more about how to get these strings, you should follow what "AnalysisAddIn::GetFuncDescrStr()" does when it's called.
The next part of the 資源s is "analysis_funcnames.src". Here are 機能(する)/行事 指名するs 位置を示すd, which are 明白な in the UI of OpenOffice.org Calc. Follow "AnalysisAddIn::GetDisplFuncStr()" to 診察する the 接近 to these strings.
But the more "tricky" part of the 資源s is in "analysis_deffuncnames.src". This 始める,決める of string arrays, where each array 持つ/拘留するs all known 機能(する)/行事 指名するs in different languages for one 機能(する)/行事. These are always sorted in a special order. And even if they might be the same in some languages, they must appear for every language seperately to 確実にする, that the proper string is selected (for a given language) for the Excel 輸出(する)! In "AnalysisAddIn::getCompatibilityNames()" you can see the usage of these string arrays.
Building an 追加する-in
When you create your own 追加する-in you surely want to make it run in OpenOffice.org Calc. To do so you must build your source to get an executable 株d library. This 過程 is controlled by a makefile called "makefile.mk". As a first step for your own 事業/計画(する) you might copy the one from the 分析 追加する-in and 交流 all 指名する with "分析" by the 指名する of your own 追加する-in.
All source とじ込み/提出するs which 生成する 反対する とじ込み/提出するs (C++/C-source) are 名簿(に載せる)/表(にあげる)d in the define for "SLOFILES" e.g. "$(SLO)$/分析.obj" for "分析.cxx". So your 付加 C++ source とじ込み/提出するs will go here.
The 権利 place for 資源 とじ込み/提出するs is 設立する in the define for "SRCFILES". Put your one here and you should 後継する with 資源s. If you don't use any 資源s, you should 除去する the section which is 示すd with "Resourcen".
In the 鮮明度/定義 for "SHL1STDLIBS" you will find at least all libraries to which the 追加する-in should be linked against. While "CPPUHELPERLIB", "CPPULIB", "VOSLIB" and "SALLIB" is a good default for your own 追加する-in, the use of "TOOLSLIB" is optional. Of course it's always possible to use the functionality of the 株d libraries coming with OpenOffice.org. In this 事例/患者 you have to look up, which lib to link additionally.
Using an 追加する-in
When you've 首尾よく created an 追加する-in, Calc should know, that this 存在するs. So copy the created 株d library into the directory "program" and if you use 資源s, copy the *.res とじ込み/提出するs into "program/資源" directory. Then you have to 登録(する) this new library with the regcomp 道具 (wich should come together with the Solver tarball), e.g. "regcomp -登録(する) -r \program\applicat.rdb -c analysis638mi.dll". If you then start OpenOffice.org and open a Calc spreadsheet, you can 接近 your new 機能(する)/行事s as the build in ones. To check this, open the AutoPilot for 機能(する)/行事s an search in the 名簿(に載せる)/表(にあげる) for your new ones. There they should work like all others. You can also check, if the 機能(する)/行事s are 名簿(に載せる)/表(にあげる)d in the proper 部類.
Link 要約
OpenOffice.org Calc 事業/計画(する) homepage
AddIn service API documentation
Browsable source code of the 分析 追加する-in
UDK 事業/計画(する) homepage
UNO-IDL description (in the UDK 事業/計画(する))
Author: Gunnar Timm (created: 20010802)
Last change: 20011002

