calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / tools / emfpimage.cxx
blob67a0cef99ed2741a22f921e8129178b9e4bd035e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <vcl/graphicfilter.hxx>
20 #include <sal/log.hxx>
21 #include "emfpimage.hxx"
23 namespace emfplushelper
25 void EMFPImage::Read(SvMemoryStream &s, sal_uInt32 dataSize, bool bUseWholeStream)
27 sal_uInt32 header, bitmapType;
28 s.ReadUInt32(header).ReadUInt32(type);
29 SAL_INFO("drawinglayer.emf", "EMF+\timage\nEMF+\theader: 0x" << std::hex << header << " type: " << type << std::dec);
31 if (ImageDataTypeBitmap == type)
33 // bitmap
34 s.ReadInt32(width).ReadInt32(height).ReadInt32(stride).ReadUInt32(pixelFormat).ReadUInt32(bitmapType);
35 SAL_INFO("drawinglayer.emf", "EMF+\tbitmap width: " << width << " height: " << height << " stride: " << stride << " pixelFormat: 0x" << std::hex << pixelFormat << " bitmapType: 0x" << bitmapType << std::dec);
37 if ((bitmapType != 0) || (width == 0))
39 // non native formats
40 GraphicFilter filter;
41 filter.ImportGraphic(graphic, u"", s);
42 SAL_INFO("drawinglayer.emf", "EMF+\tbitmap width: " << graphic.GetSizePixel().Width() << " height: " << graphic.GetSizePixel().Height());
45 else if (ImageDataTypeMetafile == type)
47 // metafile
48 sal_uInt32 mfType, mfSize;
49 s.ReadUInt32(mfType).ReadUInt32(mfSize);
51 if (bUseWholeStream)
52 dataSize = s.remainingSize();
53 else
54 dataSize -= 16;
56 SAL_INFO("drawinglayer.emf", "EMF+\tmetafile type: " << mfType << " dataSize: " << mfSize << " real size calculated from record dataSize: " << dataSize);
58 GraphicFilter filter;
59 // workaround buggy metafiles, which have wrong mfSize set (n#705956 for example)
60 SvMemoryStream mfStream(const_cast<char *>(static_cast<char const *>(s.GetData()) + s.Tell()), dataSize, StreamMode::READ);
61 filter.ImportGraphic(graphic, u"", mfStream);
63 // debug code - write the stream to debug file /tmp/emf-stream.emf
64 #if OSL_DEBUG_LEVEL > 1
65 mfStream.Seek(0);
66 static sal_Int32 emfp_debug_stream_number = 0;
67 OUString emfp_debug_filename = "/tmp/emf-embedded-stream" +
68 OUString::number(emfp_debug_stream_number++) + ".emf";
70 SvFileStream file(emfp_debug_filename, StreamMode::WRITE | StreamMode::TRUNC);
72 mfStream.WriteStream(file);
73 file.Flush();
74 file.Close();
75 #endif
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */