File indexing completed on 2024-12-08 12:55:55
0001 /* This file is part of the KDE project 0002 Copyright (C) 2009 KO GmbH <jos.van.den.oever@kogmbh.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 #ifndef PICTURES_H 0020 #define PICTURES_H 0021 0022 #include <pole.h> 0023 #include "generated/simpleParser.h" 0024 0025 #include <QMap> 0026 0027 class KoStore; 0028 class KoXmlWriter; 0029 class QImage; 0030 0031 struct PictureReference { 0032 QString name; 0033 QString mimetype; 0034 QByteArray uid; 0035 }; 0036 0037 enum OfficeArtBlipType { 0038 officeArtBlipEMF = 0xF01A, 0039 officeArtBlipWMF = 0xF01B, 0040 officeArtBlipPICT = 0xF01C, 0041 officeArtBlipJPEG = 0xF01D, 0042 officeArtBlipPNG = 0xF01E, 0043 officeArtBlipDIB = 0xF01F, 0044 officeArtBlipTIFF = 0xF029, 0045 officeArtBlipJPEG2 = 0xF02A // same handling as JPEG 0046 }; 0047 0048 /** 0049 * Save the next picture record in the 'Pictures' stream into the ODF store. 0050 * 0051 * The pictures are saved in the currently opened folder of the ODF store. It 0052 * is customary to switch to the folder 'Pictures' before calling this 0053 * function. 0054 * 0055 * @return The name under which the image is saved or an empty string when an 0056 * error occurred. 0057 **/ 0058 PictureReference savePicture(POLE::Stream& stream, KoStore* store); 0059 0060 PictureReference savePicture(const MSO::OfficeArtBStoreContainerFileBlock& a, 0061 KoStore* store); 0062 0063 /** 0064 * Look in blipStore for the id mapping to this object. 0065 * 0066 * @param dgg container for OfficeArt records that contain document-wide data 0067 * @param pib specifies the BLIP to display in the picture shape 0068 * @param offset into the associated OfficeArtBStoreDelay record 0069 * @return unique identifier of the pixel data in the BLIP 0070 **/ 0071 QByteArray getRgbUid(const MSO::OfficeArtDggContainer& dgg, quint32 pib, quint32& offset); 0072 0073 /** 0074 * Save pictures into the ODF store and write the appropriate manifest entry. 0075 * 0076 * @param store ODF store 0077 * @param manifest writer 0078 * @param rgfb list of records that specifies the BLIP data. The rgfb list is 0079 * either part of the OfficeArtBStoreContainer or OfficeArtBStoreDelay. 0080 * @return map of picture names vs. MD4 digests of the picture data. 0081 **/ 0082 QMap<QByteArray, QString> createPictures(KoStore* store, KoXmlWriter* manifest, const QList<MSO::OfficeArtBStoreContainerFileBlock>* rgfb); 0083 0084 /** 0085 * Note: Copied from filters/libkowmf/qwmf.cc, the name is confusing as 0086 * the method convert the data into BMP and then into QImage 0087 * 0088 * Converts dib to QImage 0089 * @param bmp QImage input which will be filled with converted dib pixels 0090 * @param dib dib bytes 0091 * @param size size of the dib in bytes 0092 * @return if the conversion was successful 0093 **/ 0094 bool dibToBmp(QImage& bmp, const char* dib, long size); 0095 0096 #endif