/* static */ bool DictFileWritingUtils::createEmptyV3DictFile(const char *const filePath,
        const HeaderReadWriteUtils::AttributeMap *const attributeMap) {
    BufferWithExtendableBuffer headerBuffer(0 /* originalBuffer */, 0 /* originalBufferSize */);
    HeaderPolicy headerPolicy(FormatUtils::VERSION_3, attributeMap);
    headerPolicy.writeHeaderToBuffer(&headerBuffer, true /* updatesLastUpdatedTime */,
            true /* updatesLastDecayedTime */, 0 /* unigramCount */, 0 /* bigramCount */,
            0 /* extendedRegionSize */);
    BufferWithExtendableBuffer bodyBuffer(0 /* originalBuffer */, 0 /* originalBufferSize */);
    if (!DynamicPatriciaTrieWritingUtils::writeEmptyDictionary(&bodyBuffer, 0 /* rootPos */)) {
        return false;
    }
    return flushAllHeaderAndBodyToFile(filePath, &headerBuffer, &bodyBuffer);
}
コード例 #2
0
ファイル: KWPageStyle.cpp プロジェクト: KDE/koffice
KOdfGenericStyle KWPageStyle::saveOdf() const
{
    KOdfGenericStyle pageLayout = d->pageLayout.saveOdf();
    pageLayout.setAutoStyleInStylesDotXml(true);
    pageLayout.addAttribute("style:page-usage", "all");

    QBuffer buffer;
    buffer.open(QIODevice::WriteOnly);
    KXmlWriter writer(&buffer);

    if (d->columns.columns > 1) {
        writer.startElement("style:columns");
        writer.addAttribute("fo:column-count", d->columns.columns);
        writer.addAttributePt("fo:column-gap", d->columns.columnSpacing);
        writer.endElement();
    }

    //<style:footnote-sep style:adjustment="left" style:width="0.5pt" style:rel-width="20%" style:line-style="solid"/>
    //writer.startElement("style:footnote-sep");
    // TODO
    //writer.addAttribute("style:adjustment",)
    //writer.addAttribute("style:width",)
    //writer.addAttribute("style:rel-width",)
    //writer.addAttribute("style:line-style",)
    //writer.endElement();

    // TODO save background

    QString contentElement = QString::fromUtf8(buffer.buffer(), buffer.buffer().size());
    pageLayout.addChildElement("columnsEnzo", contentElement);


    if (headerPolicy() != KWord::HFTypeNone) {
        pageLayout.addProperty("style:dynamic-spacing", d->fixedHeaderSize, KOdfGenericStyle::PageHeaderType);
        pageLayout.addPropertyPt("fo:min-height", d->headerMinimumHeight, KOdfGenericStyle::PageHeaderType);
        saveInsets(d->headerMargin, pageLayout, "fo:margin", KOdfGenericStyle::PageHeaderType);
        saveInsets(d->headerInsets, pageLayout, "fo:padding", KOdfGenericStyle::PageHeaderType);
    }

    if (footerPolicy() != KWord::HFTypeNone) {
        pageLayout.addProperty("style:dynamic-spacing", d->fixedFooterSize, KOdfGenericStyle::PageFooterType);
        pageLayout.addPropertyPt("fo:min-height", d->footerMinimumHeight, KOdfGenericStyle::PageFooterType);
        saveInsets(d->footerMargin, pageLayout, "fo:margin", KOdfGenericStyle::PageFooterType);
        saveInsets(d->footerInsets, pageLayout, "fo:padding", KOdfGenericStyle::PageFooterType);
    }

    // TODO see how we should save margins if we use the 'closest to binding' stuff.

    return pageLayout;
}
コード例 #3
0
/* static */ bool DictFileWritingUtils::createEmptyV4DictFile(const char *const dirPath,
        const std::vector<int> localeAsCodePointVector,
        const DictionaryHeaderStructurePolicy::AttributeMap *const attributeMap,
        const FormatUtils::FORMAT_VERSION formatVersion) {
    HeaderPolicy headerPolicy(formatVersion, localeAsCodePointVector, attributeMap);
    DictBuffersPtr dictBuffers = DictBuffers::createVer4DictBuffers(&headerPolicy,
            DictConstants::MAX_DICT_EXTENDED_REGION_SIZE);
    headerPolicy.fillInAndWriteHeaderToBuffer(true /* updatesLastDecayedTime */,
            EntryCounts(), 0 /* extendedRegionSize */, dictBuffers->getWritableHeaderBuffer());
    if (!DynamicPtWritingUtils::writeEmptyDictionary(
            dictBuffers->getWritableTrieBuffer(), 0 /* rootPos */)) {
        AKLOGE("Empty ver4 dictionary structure cannot be created on memory.");
        return false;
    }
    return dictBuffers->flush(dirPath);
}
/* static */ DictionaryStructureWithBufferPolicy::StructurePolicyPtr
        DictionaryStructureWithBufferPolicyFactory::newPolicyForOnMemoryV4Dict(
                const FormatUtils::FORMAT_VERSION formatVersion,
                const std::vector<int> &locale,
                const DictionaryHeaderStructurePolicy::AttributeMap *const attributeMap) {
    HeaderPolicy headerPolicy(formatVersion, locale, attributeMap);
    DictBuffersPtr dictBuffers = DictBuffers::createVer4DictBuffers(&headerPolicy,
            DictConstants::MAX_DICT_EXTENDED_REGION_SIZE);
    if (!DynamicPtWritingUtils::writeEmptyDictionary(
            dictBuffers->getWritableTrieBuffer(), 0 /* rootPos */)) {
        AKLOGE("Empty ver4 dictionary structure cannot be created on memory.");
        return nullptr;
    }
    return DictionaryStructureWithBufferPolicy::StructurePolicyPtr(
            new StructurePolicy(std::move(dictBuffers)));
}