⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hyperlinkrecord.java

📁 实现JAVA界面的代码GWT
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if(sheet.getName().indexOf(39) == -1)
        {
            sb.append(sheet.getName());
        } else
        {
            String sheetName = sheet.getName();
            int pos = 0;
            for(int nextPos = sheetName.indexOf(39, pos); nextPos != -1 && pos < sheetName.length(); nextPos = sheetName.indexOf(39, pos))
            {
                sb.append(sheetName.substring(pos, nextPos));
                sb.append("''");
                pos = nextPos + 1;
            }

            sb.append(sheetName.substring(pos));
        }
        sb.append('\'');
        sb.append('!');
        lastdestcol = Math.max(destcol, lastdestcol);
        lastdestrow = Math.max(destrow, lastdestrow);
        CellReferenceHelper.getCellReference(destcol, destrow, sb);
        sb.append(':');
        CellReferenceHelper.getCellReference(lastdestcol, lastdestrow, sb);
        location = sb.toString();
    }

    void insertRow(int r)
    {
        Assert.verify(sheet != null && range != null);
        if(r > lastRow)
            return;
        if(r <= firstRow)
        {
            firstRow++;
            modified = true;
        }
        if(r <= lastRow)
        {
            lastRow++;
            modified = true;
        }
        if(modified)
            range = new SheetRangeImpl(sheet, firstColumn, firstRow, lastColumn, lastRow);
    }

    void insertColumn(int c)
    {
        Assert.verify(sheet != null && range != null);
        if(c > lastColumn)
            return;
        if(c <= firstColumn)
        {
            firstColumn++;
            modified = true;
        }
        if(c <= lastColumn)
        {
            lastColumn++;
            modified = true;
        }
        if(modified)
            range = new SheetRangeImpl(sheet, firstColumn, firstRow, lastColumn, lastRow);
    }

    void removeRow(int r)
    {
        Assert.verify(sheet != null && range != null);
        if(r > lastRow)
            return;
        if(r < firstRow)
        {
            firstRow--;
            modified = true;
        }
        if(r < lastRow)
        {
            lastRow--;
            modified = true;
        }
        if(modified)
        {
            Assert.verify(range != null);
            range = new SheetRangeImpl(sheet, firstColumn, firstRow, lastColumn, lastRow);
        }
    }

    void removeColumn(int c)
    {
        Assert.verify(sheet != null && range != null);
        if(c > lastColumn)
            return;
        if(c < firstColumn)
        {
            firstColumn--;
            modified = true;
        }
        if(c < lastColumn)
        {
            lastColumn--;
            modified = true;
        }
        if(modified)
        {
            Assert.verify(range != null);
            range = new SheetRangeImpl(sheet, firstColumn, firstRow, lastColumn, lastRow);
        }
    }

    private byte[] getURLData(byte cd[])
    {
        String urlString = url.toString();
        int dataLength = cd.length + 20 + (urlString.length() + 1) * 2;
        if(contents != null)
            dataLength += 4 + (contents.length() + 1) * 2;
        byte d[] = new byte[dataLength];
        System.arraycopy(cd, 0, d, 0, cd.length);
        int urlPos = cd.length;
        if(contents != null)
        {
            IntegerHelper.getFourBytes(contents.length() + 1, d, urlPos);
            StringHelper.getUnicodeBytes(contents, d, urlPos + 4);
            urlPos += (contents.length() + 1) * 2 + 4;
        }
        d[urlPos] = -32;
        d[urlPos + 1] = -55;
        d[urlPos + 2] = -22;
        d[urlPos + 3] = 121;
        d[urlPos + 4] = -7;
        d[urlPos + 5] = -70;
        d[urlPos + 6] = -50;
        d[urlPos + 7] = 17;
        d[urlPos + 8] = -116;
        d[urlPos + 9] = -126;
        d[urlPos + 10] = 0;
        d[urlPos + 11] = -86;
        d[urlPos + 12] = 0;
        d[urlPos + 13] = 75;
        d[urlPos + 14] = -87;
        d[urlPos + 15] = 11;
        IntegerHelper.getFourBytes((urlString.length() + 1) * 2, d, urlPos + 16);
        StringHelper.getUnicodeBytes(urlString, d, urlPos + 20);
        return d;
    }

    private byte[] getUNCData(byte cd[])
    {
        String uncString = file.getPath();
        byte d[] = new byte[cd.length + uncString.length() * 2 + 2 + 4];
        System.arraycopy(cd, 0, d, 0, cd.length);
        int urlPos = cd.length;
        int length = uncString.length() + 1;
        IntegerHelper.getFourBytes(length, d, urlPos);
        StringHelper.getUnicodeBytes(uncString, d, urlPos + 4);
        return d;
    }

    private byte[] getFileData(byte cd[])
    {
        ArrayList path = new ArrayList();
        ArrayList shortFileName = new ArrayList();
        path.add(file.getName());
        shortFileName.add(getShortName(file.getName()));
        for(File parent = file.getParentFile(); parent != null; parent = parent.getParentFile())
        {
            path.add(parent.getName());
            shortFileName.add(getShortName(parent.getName()));
        }

        int upLevelCount = 0;
        int pos = path.size() - 1;
        for(boolean upDir = true; upDir;)
        {
            String s = (String)path.get(pos);
            if(s.equals(".."))
            {
                upLevelCount++;
                path.remove(pos);
                shortFileName.remove(pos);
            } else
            {
                upDir = false;
            }
            pos--;
        }

        StringBuffer filePathSB = new StringBuffer();
        StringBuffer shortFilePathSB = new StringBuffer();
        if(file.getPath().charAt(1) == ':')
        {
            char driveLetter = file.getPath().charAt(0);
            if(driveLetter != 'C' && driveLetter != 'c')
            {
                filePathSB.append(driveLetter);
                filePathSB.append(':');
                shortFilePathSB.append(driveLetter);
                shortFilePathSB.append(':');
            }
        }
        for(int i = path.size() - 1; i >= 0; i--)
        {
            filePathSB.append((String)path.get(i));
            shortFilePathSB.append((String)shortFileName.get(i));
            if(i != 0)
            {
                filePathSB.append("\\");
                shortFilePathSB.append("\\");
            }
        }

        String filePath = filePathSB.toString();
        String shortFilePath = shortFilePathSB.toString();
        int dataLength = cd.length + 4 + (shortFilePath.length() + 1) * 2 + 16 + 2 + 4 + filePath.length() + 1 + 4 + 24;
        if(contents != null)
            dataLength += 4 + (contents.length() + 1) * 2;
        byte d[] = new byte[dataLength];
        System.arraycopy(cd, 0, d, 0, cd.length);
        int filePos = cd.length;
        if(contents != null)
        {
            IntegerHelper.getFourBytes(contents.length() + 1, d, filePos);
            StringHelper.getUnicodeBytes(contents, d, filePos + 4);
            filePos += (contents.length() + 1) * 2 + 4;
        }
        int curPos = filePos;
        IntegerHelper.getFourBytes(shortFilePath.length() + 1, d, curPos);
        StringHelper.getUnicodeBytes(shortFilePath, d, curPos + 4);
        curPos += 4 + (shortFilePath.length() + 1) * 2;
        d[curPos] = 3;
        d[curPos + 1] = 3;
        d[curPos + 2] = 0;
        d[curPos + 3] = 0;
        d[curPos + 4] = 0;
        d[curPos + 5] = 0;
        d[curPos + 6] = 0;
        d[curPos + 7] = 0;
        d[curPos + 8] = -64;
        d[curPos + 9] = 0;
        d[curPos + 10] = 0;
        d[curPos + 11] = 0;
        d[curPos + 12] = 0;
        d[curPos + 13] = 0;
        d[curPos + 14] = 0;
        d[curPos + 15] = 70;
        curPos += 16;
        IntegerHelper.getTwoBytes(upLevelCount, d, curPos);
        curPos += 2;
        IntegerHelper.getFourBytes(filePath.length() + 1, d, curPos);
        curPos += 4;
        StringHelper.getBytes(filePath, d, curPos);
        curPos += filePath.length() + 1;
        d[curPos] = -1;
        d[curPos + 1] = -1;
        d[curPos + 2] = -83;
        d[curPos + 3] = -34;
        return d;
    }

    private String getShortName(String s)
    {
        int sep = s.indexOf(46);
        String prefix = null;
        String suffix = null;
        if(sep == -1)
        {
            prefix = s;
            suffix = "";
        } else
        {
            prefix = s.substring(0, sep);
            suffix = s.substring(sep + 1);
        }
        if(prefix.length() > 8)
        {
            prefix = prefix.substring(0, 6) + "~" + (prefix.length() - 6);
            prefix = prefix.substring(0, 8);
        }
        suffix = suffix.substring(0, Math.min(3, suffix.length()));
        if(suffix.length() > 0)
            return prefix + '.' + suffix;
        else
            return prefix;
    }

    private byte[] getLocationData(byte cd[])
    {
        byte d[] = new byte[cd.length + 4 + (location.length() + 1) * 2];
        System.arraycopy(cd, 0, d, 0, cd.length);
        int locPos = cd.length;
        IntegerHelper.getFourBytes(location.length() + 1, d, locPos);
        StringHelper.getUnicodeBytes(location, d, locPos + 4);
        return d;
    }

    void initialize(WritableSheet s)
    {
        sheet = s;
        range = new SheetRangeImpl(s, firstColumn, firstRow, lastColumn, lastRow);
    }

    String getContents()
    {
        return contents;
    }

    protected void setContents(String desc)
    {
        contents = desc;
        modified = true;
    }

    static Class class$(String x0)
    {
        return Class.forName(x0);
        ClassNotFoundException x1;
        x1;
        throw new NoClassDefFoundError(x1.getMessage());
    }

    static 
    {
        logger = Logger.getLogger(class$jxl$write$biff$HyperlinkRecord != null ? class$jxl$write$biff$HyperlinkRecord : (class$jxl$write$biff$HyperlinkRecord = class$("jxl.write.biff.HyperlinkRecord")));
    }

// Unreferenced inner classes:

/* anonymous class */
    static class _cls1
    {
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -