LibreOffice Module drawinglayer (master) 1
emfpcustomlinecap.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <sal/log.hxx>
21#include "emfpcustomlinecap.hxx"
22#include "emfppath.hxx"
23#include "emfppen.hxx"
25
26using namespace ::com::sun::star;
27using namespace ::basegfx;
28
29namespace emfplushelper
30{
31 const sal_uInt32 EmfPlusCustomLineCapDataTypeDefault = 0x00000000;
32 const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow = 0x00000001;
33 const sal_uInt32 EmfPlusCustomLineCapDataFillPath = 0x00000001;
34 const sal_uInt32 EmfPlusCustomLineCapDataLinePath = 0x00000002;
35
37 : EMFPObject()
38 , type(0)
39 , strokeStartCap(0)
40 , strokeEndCap(0)
41 , strokeJoin(0)
42 , miterLimit(0.0)
43 , widthScale(0.0)
44 , mbIsFilled(false)
45 {
46 }
47
49 {
50 sal_Int32 pathLength;
51 s.ReadInt32(pathLength);
52 SAL_INFO("drawinglayer.emf", "EMF+\t\tpath length: " << pathLength);
53 sal_uInt32 pathHeader;
54 sal_Int32 pathPoints, pathFlags;
55 s.ReadUInt32(pathHeader).ReadInt32(pathPoints).ReadInt32(pathFlags);
56 SAL_INFO("drawinglayer.emf", "EMF+\t\tpath (custom cap line path)");
57 SAL_INFO("drawinglayer.emf", "EMF+\t\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec);
58
59 EMFPPath path(pathPoints);
60 path.Read(s, pathFlags);
61 polygon = path.GetPolygon(rR, false);
62 // rotate polygon by 180 degrees
64 mbIsFilled = bFill;
65 }
66
68 {
69 sal_uInt32 header;
71 SAL_INFO("drawinglayer.emf", "EMF+\t\tcustom cap");
72 SAL_INFO("drawinglayer.emf", "EMF+\t\theader: 0x" << std::hex << header << " type: " << type << std::dec);
73
75 {
76 sal_uInt32 customLineCapDataFlags, baseCap;
77 float baseInset;
78 float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY;
79
80 s.ReadUInt32(customLineCapDataFlags).ReadUInt32(baseCap).ReadFloat(baseInset)
83 .ReadFloat(fillHotSpotX).ReadFloat(fillHotSpotY).ReadFloat(strokeHotSpotX).ReadFloat(strokeHotSpotY);
84
85 SAL_INFO("drawinglayer.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags);
86 SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseCap: 0x" << std::hex << baseCap);
87 SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseInset: " << baseInset);
88
89 if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath)
90 {
91 ReadPath(s, rR, true);
92 }
93
94 if (customLineCapDataFlags & EmfPlusCustomLineCapDataLinePath)
95 {
96 ReadPath(s, rR, false);
97 }
98 }
100 {
101 // TODO only reads the data, does not use them [I've had
102 // no test document to be able to implement it]
103
104 sal_Int32 fillState;
105 float width, height, middleInset, unusedHotSpot;
106
107 s.ReadFloat(width).ReadFloat(height).ReadFloat(middleInset).ReadInt32(fillState).ReadUInt32(strokeStartCap)
109 .ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot);
110
111 SAL_INFO("drawinglayer.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)");
112 }
113 SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap);
114 SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap);
115 SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin);
116 SAL_INFO("drawinglayer.emf", "EMF+\t\tmiterLimit: " << miterLimit);
117 SAL_INFO("drawinglayer.emf", "EMF+\t\twidthScale: " << widthScale);
118 }
119}
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_Int8 header[]
SvStream & ReadFloat(float &rFloat)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
SvStream & ReadInt32(sal_Int32 &rInt32)
void transform(const basegfx::B2DHomMatrix &rMatrix)
::basegfx::B2DPolyPolygon & GetPolygon(EmfPlusHelperData const &rR, bool bMapIt=true, bool bAddLineToCloseShape=false)
Definition: emfppath.cxx:132
void Read(SvStream &s, sal_uInt32 pathFlags)
Definition: emfppath.cxx:84
#define SAL_INFO(area, stream)
B2DHomMatrix createRotateB2DHomMatrix(double fRadiant)
const sal_uInt32 EmfPlusCustomLineCapDataFillPath
const sal_uInt32 EmfPlusCustomLineCapDataTypeDefault
const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow
const sal_uInt32 EmfPlusCustomLineCapDataLinePath
void Read(SvStream &s, EmfPlusHelperData const &rR)
void ReadPath(SvStream &s, EmfPlusHelperData const &rR, bool bFill)
ResultType type