main/sfx2/source/doc/DocumentMetadataAccess.cxx
/** write a metadata file to the storage */
write a metadata file to the storage
write a metadata file to the storage
static void
writeStream(struct DocumentMetadataAccess_Impl & i_rImpl,
    uno::Reference< embed::XStorage > const & i_xStorage,
    uno::Reference<rdf::XURI> const & i_xGraphName,
    ::rtl::OUString const & i_rPath,
    ::rtl::OUString const & i_rBaseURI)
{
    ::rtl::OUString dir;
    ::rtl::OUString rest;
    if (!splitPath(i_rPath, dir, rest)) throw uno::RuntimeException();
    try {
        if (dir.equalsAscii("")) {
            exportStream(i_rImpl, i_xStorage, i_xGraphName, i_rPath,
                i_rBaseURI);
        } else {
            const uno::Reference<embed::XStorage> xDir(
                i_xStorage->openStorageElement(dir,
                    embed::ElementModes::WRITE));
            const uno::Reference< beans::XPropertySet > xDirProps(xDir,
                uno::UNO_QUERY_THROW);
            try {
                ::rtl::OUString mimeType;
                xDirProps->getPropertyValue(
                        ::comphelper::MediaDescriptor::PROP_MEDIATYPE() )
                    >>= mimeType;
                if (mimeType.matchAsciiL(s_odfmime, sizeof(s_odfmime) - 1)) {
                    OSL_TRACE("writeStream: "
                        "refusing to recurse into embedded document");
                    return;
                }
            } catch (uno::Exception &) { }
            ::rtl::OUStringBuffer buf(i_rBaseURI);
            buf.append(dir).append(static_cast<sal_Unicode>('/'));
            writeStream(i_rImpl, xDir, i_xGraphName, rest,
                buf.makeStringAndClear());
            uno::Reference<embed::XTransactedObject> const xTransaction(
                xDir, uno::UNO_QUERY);
            if (xTransaction.is()) {
                xTransaction->commit();
            }
        }
    } catch (uno::RuntimeException &) {
        throw;
    } catch (io::IOException &) {
        throw;
    }
}
static void writeStream ( struct DocumentMetadataAccess_Impl & i_rImpl , uno :: Reference < embed :: XStorage > const & i_xStorage , uno :: Reference < rdf :: XURI > const & i_xGraphName , :: rtl :: OUString const & i_rPath , :: rtl :: OUString const & i_rBaseURI ) { :: rtl :: OUString dir ; :: rtl :: OUString rest ; if ( ! splitPath ( i_rPath , dir , rest ) ) throw uno :: RuntimeException ( ) ; try { if ( dir . equalsAscii ( " " ) ) { exportStream ( i_rImpl , i_xStorage , i_xGraphName , i_rPath , i_rBaseURI ) ; } else { const uno :: Reference < embed :: XStorage > xDir ( i_xStorage -> openStorageElement ( dir , embed :: ElementModes :: WRITE ) ) ; const uno :: Reference < beans :: XPropertySet > xDirProps ( xDir , uno :: UNO_QUERY_THROW ) ; try { :: rtl :: OUString mimeType ; xDirProps -> getPropertyValue ( :: comphelper :: MediaDescriptor :: PROP_MEDIATYPE ( ) ) >>= mimeType ; if ( mimeType . matchAsciiL ( s_odfmime , sizeof ( s_odfmime ) - 1 ) ) { OSL_TRACE ( " " " " ) ; return ; } } catch ( uno :: Exception & ) { } :: rtl :: OUStringBuffer buf ( i_rBaseURI ) ; buf . append ( dir ) . append ( static_cast < sal_Unicode > ( ' ' ) ) ; writeStream ( i_rImpl , xDir , i_xGraphName , rest , buf . makeStringAndClear ( ) ) ; uno :: Reference < embed :: XTransactedObject > const xTransaction ( xDir , uno :: UNO_QUERY ) ; if ( xTransaction . is ( ) ) { xTransaction -> commit ( ) ; } } } catch ( uno :: RuntimeException & ) { throw ; } catch ( io :: IOException & ) { throw ; } }
write a metadata file to the storage
write a metadata file to the storage