add by liufeijin 20181025 {{
| 1286 | |
| 1287 | // add by liufeijin 20181025 {{ |
| 1288 | bool Document::changeimage(int filenoinmidea, QString newfile) |
| 1289 | { |
| 1290 | Q_D(const Document); |
| 1291 | |
| 1292 | QImage newpic(newfile); |
| 1293 | |
| 1294 | auto mediaFileToLoad = d->workbook->mediaFiles(); |
| 1295 | const auto mf = mediaFileToLoad[filenoinmidea]; |
| 1296 | |
| 1297 | const QString suffix = newfile.mid(newfile.lastIndexOf(QLatin1Char('.'))+1); |
| 1298 | QString mimetypemy; |
| 1299 | if(QString::compare(QLatin1String("jpg"), suffix, Qt::CaseInsensitive)==0) |
| 1300 | mimetypemy=QStringLiteral("image/jpeg"); |
| 1301 | if(QString::compare(QLatin1String("bmp"), suffix, Qt::CaseInsensitive)==0) |
| 1302 | mimetypemy=QStringLiteral("image/bmp"); |
| 1303 | if(QString::compare(QLatin1String("gif"), suffix, Qt::CaseInsensitive)==0) |
| 1304 | mimetypemy=QStringLiteral("image/gif"); |
| 1305 | if(QString::compare(QLatin1String("png"), suffix, Qt::CaseInsensitive)==0) |
| 1306 | mimetypemy=QStringLiteral("image/png"); |
| 1307 | |
| 1308 | QByteArray ba; |
| 1309 | QBuffer buffer(&ba); |
| 1310 | buffer.setBuffer(&ba); |
| 1311 | buffer.open(QIODevice::WriteOnly); |
| 1312 | newpic.save(&buffer,suffix.toLocal8Bit().data()); |
| 1313 | |
| 1314 | mf->set(ba,suffix,mimetypemy); |
| 1315 | mediaFileToLoad[filenoinmidea]=mf; |
| 1316 | |
| 1317 | return true; |
| 1318 | } |
| 1319 | // liufeijin }} |
| 1320 | |
| 1321 |
nothing calls this directly
no test coverage detected