diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2017-06-15 16:35:31 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2017-07-15 11:01:29 +0200 |
commit | c7470f5be441d8fe80155ff29605d74d5838be26 (patch) | |
tree | 1547af7f13f4d83d972f86115d0fc49a8a734105 /emfio/inc/wmfreader.hxx | |
parent | b93d0cadb79f6652dec4d29ef20813f1d57cc708 (diff) |
emfplus: add rough version of local reader
Complete redevelopent is too expensive, start with
adding a copy of the existing vcl importer which
will in the next steps be adapted to import primitives
instead of MetaFile(Actions). Adapted namespace, made
compile and added sample code to roughly use it
Change-Id: I79e7ea0d78099fbbe18e2a595457b2ab353f58ea
Diffstat (limited to 'emfio/inc/wmfreader.hxx')
-rw-r--r-- | emfio/inc/wmfreader.hxx | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/emfio/inc/wmfreader.hxx b/emfio/inc/wmfreader.hxx new file mode 100644 index 000000000000..734becbb5886 --- /dev/null +++ b/emfio/inc/wmfreader.hxx @@ -0,0 +1,106 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_EMFIO_INC_WMFREADER_HXX +#define INCLUDED_EMFIO_INC_WMFREADER_HXX + +#include <mtftools.hxx> +#include <tools/stream.hxx> + +namespace emfio +{ + struct WMF_EXTERNALHEADER + { + sal_uInt16 xExt; + sal_uInt16 yExt; + + /** One of the following values: + <ul> + <li>MM_TEXT</li> + <li>MM_LOMETRIC</li> + <li>MM_HIMETRIC</li> + <li>MM_LOENGLISH</li> + <li>MM_HIENGLISH</li> + <li>MM_TWIPS</li> + <li>MM_ISOTROPIC</li> + <li>MM_ANISOTROPIC</li> + </ul> + If this value is 0, then no external mapmode has been defined, + the internal one should then be used. + */ + sal_uInt16 mapMode; + + WMF_EXTERNALHEADER() : + xExt(0), + yExt(0), + mapMode(0) + { + } + }; + + class WmfReader : public MtfTools + { + private: + + sal_uInt16 nUnitsPerInch; + sal_uInt32 nRecSize; + + // embedded EMF data + std::unique_ptr<SvMemoryStream> pEMFStream; + + // total number of comment records containing EMF data + sal_uInt32 nEMFRecCount; + + // number of EMF records read + sal_uInt32 nEMFRec; + + // total size of embedded EMF data + sal_uInt32 nEMFSize; + + sal_uInt32 nSkipActions; + sal_uInt32 nCurrentAction; + + WMF_EXTERNALHEADER* pExternalHeader; + + // reads header of the WMF-Datei + bool ReadHeader(); + + // reads parameters of the record with the functionnumber nFunction. + void ReadRecordParams(sal_uInt16 nFunction); + + Point ReadPoint(); // reads and converts a point (first X then Y) + Point ReadYX(); // reads and converts a point (first Y then X) + tools::Rectangle ReadRectangle(); // reads and converts a rectangle + Size ReadYXExt(); + void GetPlaceableBound(tools::Rectangle& rSize, SvStream* pStrm); + + public: + + WmfReader(SvStream& rStreamWMF, GDIMetaFile& rGDIMetaFile, + FilterConfigItem* pConfigItem, + WMF_EXTERNALHEADER* pExtHeader = nullptr); + + // read WMF file from stream and fill the GDIMetaFile + void ReadWMF(); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |