001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.plugin.io;
017    
018    import org.odftoolkit.odfdom.OdfFileDom;
019    import org.odftoolkit.odfdom.doc.table.OdfTableCell;
020    import org.odftoolkit.odfdom.dom.element.office.OfficeAnnotationElement;
021    import org.odftoolkit.odfdom.dom.element.text.TextPElement;
022    import org.opengion.hayabusa.db.DBColumn;
023    
024    /**
025     * Calcファイルの書きå?しクラスですã?
026     *
027     * こã?クラスではã€??常の出力クラスと異なりã?以下ã?ように出力されますã?
028     *  â‘?ƒ‡ータ部åˆ?�«は、X(æ–?­—å?)またã?9(数値åž?をリソース定義の桁数åˆ??åŠ?
029     *  ②å�?‚»ルのコメント情報として{@ANO.カラãƒ?��_行番号}をå?åŠ?
030     *
031     * こã?出力結果はã€??常、Calc帳票シスãƒ?ƒ の雛形を作æ?するための、å?æƒ??として
032     * 利用することを想定してã�?�¾すã?
033     *
034     * @og.group ファイル出åŠ?
035     *
036     * @version  5.0
037     * @author       Hiroki Nakamura
038     * @since    JDK6.0,
039     */
040    public class TableWriter_CalcDefAno extends TableWriter_CalcDef {
041            //* こã?プログラãƒ??VERSIONæ–?­—å?を設定しますã?       {@value} */
042            private static final String VERSION = "4.0.0.0 (2005/08/31)" ;
043    
044            /**
045             * ãƒ?‚­ストコンãƒ?ƒ³ãƒ?”¨のセルを生成すã‚?
046             *
047             * @param       contentDom      OdfFileDomオブジェクãƒ?
048             * @param       content         コンãƒ?ƒ³ãƒ?
049             * @param       col                     DBColumnオブジェクãƒ?
050             * @param       isCellTypeNumber        [true:数字型/false:æ–?­—型]
051             * @param       isNumberList            [true:数字リスãƒ?999/false:通常]
052             *
053             * @return      ãƒ?‚­ストコンãƒ?ƒ³ãƒ?”¨のセル
054             */
055            @Override
056            protected OdfTableCell createTextCell( final OdfFileDom contentDom, final String content, final DBColumn col, final Boolean isCellTypeNumber, final Boolean isNumberList ) {
057                    String val = null;
058                    if( isNumberList ) { val = "999"; }
059                    else {
060                            StringBuilder buf = new StringBuilder();
061                            int sizeX = col.getSizeX();
062                            int sizeY = col.getSizeY();
063                            String fillStr = isCellTypeNumber ? "9" : "X";
064                            for( int i=0; i<sizeX; i++ ) {
065                                    buf.append( fillStr );
066                            }
067                            if( sizeY > 0 ) {
068                                    buf.append( "." );
069                                    for( int i=0; i<sizeY; i++ ) {
070                                            buf.append( fillStr );
071                                    }
072                            }
073                            val = buf.toString();
074                    }
075    
076                    OdfTableCell cell = super.createTextCell( contentDom, val, isCellTypeNumber, isNumberList );
077                    OfficeAnnotationElement anotation = cell.newOfficeAnnotationElement();
078                    TextPElement text = anotation.newTextPElement();
079                    text.setTextContent( "{@ANO." + content + "}" );
080    
081                    return cell;
082            }
083    }