File indexing completed on 2025-01-12 10:34:21

0001 /* This file is part of the KDE project
0002    SPDX-FileCopyrightText: 2009 KO GmbH <jos.van.den.oever@kogmbh.com>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 #ifndef PICTURES_H
0007 #define PICTURES_H
0008 
0009 #include <pole.h>
0010 #include "generated/simpleParser.h"
0011 
0012 #include <QMap>
0013 
0014 class KoStore;
0015 class KoXmlWriter;
0016 class QImage;
0017 
0018 struct PictureReference {
0019     QString name;
0020     QString mimetype;
0021     QByteArray uid;
0022 };
0023 
0024 enum OfficeArtBlipType {
0025     officeArtBlipEMF  = 0xF01A,
0026     officeArtBlipWMF  = 0xF01B,
0027     officeArtBlipPICT = 0xF01C,
0028     officeArtBlipJPEG = 0xF01D,
0029     officeArtBlipPNG  = 0xF01E,
0030     officeArtBlipDIB  = 0xF01F,
0031     officeArtBlipTIFF = 0xF029,
0032     officeArtBlipJPEG2 = 0xF02A // same handling as JPEG
0033 };
0034 
0035 /**
0036  * Save the next picture record in the 'Pictures' stream into the ODF store.
0037  *
0038  * The pictures are saved in the currently opened folder of the ODF store.  It
0039  * is customary to switch to the folder 'Pictures' before calling this
0040  * function.
0041  *
0042  * @return The name under which the image is saved or an empty string when an
0043  *         error occurred.
0044  **/
0045 PictureReference savePicture(POLE::Stream& stream, KoStore* store);
0046 
0047 PictureReference savePicture(const MSO::OfficeArtBStoreContainerFileBlock& a,
0048                              KoStore* store);
0049 
0050 /**
0051  * Look in blipStore for the id mapping to this object.
0052  *
0053  * @param dgg container for OfficeArt records that contain document-wide data
0054  * @param pib specifies the BLIP to display in the picture shape
0055  * @param offset into the associated OfficeArtBStoreDelay record
0056  * @return unique identifier of the pixel data in the BLIP
0057  **/
0058 QByteArray getRgbUid(const MSO::OfficeArtDggContainer& dgg, quint32 pib, quint32& offset);
0059 
0060 /**
0061  * Save pictures into the ODF store and write the appropriate manifest entry.
0062  *
0063  * @param store ODF store
0064  * @param manifest writer
0065  * @param rgfb list of records that specifies the BLIP data.  The rgfb list is
0066  * either part of the OfficeArtBStoreContainer or OfficeArtBStoreDelay.
0067  * @return map of picture names vs. MD4 digests of the picture data.
0068  **/
0069 QMap<QByteArray, QString> createPictures(KoStore* store, KoXmlWriter* manifest, const QList<MSO::OfficeArtBStoreContainerFileBlock>* rgfb);
0070 
0071 /**
0072  * Note: Copied from filters/libkowmf/qwmf.cc, the name is confusing as
0073  * the method convert the data into BMP and then into QImage
0074  *
0075  * Converts dib to QImage
0076  * @param bmp QImage input which will be filled with converted dib pixels
0077  * @param dib dib bytes
0078  * @param size size of the dib in bytes
0079  * @return if the conversion was successful
0080  **/
0081 bool dibToBmp(QImage& bmp, const char* dib, long size);
0082 
0083 #endif