1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <sal/log.hxx>
21 #include "emfpcustomlinecap.hxx"
22 #include "emfppath.hxx"
23 #include "emfppen.hxx"
25 using namespace ::com::sun::star
;
26 using namespace ::basegfx
;
28 namespace emfplushelper
30 const sal_uInt32 EmfPlusCustomLineCapDataTypeDefault
= 0x00000000;
31 const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow
= 0x00000001;
32 const sal_uInt32 EmfPlusCustomLineCapDataFillPath
= 0x00000001;
33 const sal_uInt32 EmfPlusCustomLineCapDataLinePath
= 0x00000002;
35 EMFPCustomLineCap::EMFPCustomLineCap()
46 void EMFPCustomLineCap::SetAttributes(rendering::StrokeAttributes
& aAttributes
)
48 aAttributes
.StartCapType
= EMFPPen::lcl_convertStrokeCap(strokeStartCap
);
49 aAttributes
.EndCapType
= EMFPPen::lcl_convertStrokeCap(strokeEndCap
);
50 aAttributes
.JoinType
= EMFPPen::lcl_convertLineJoinType(strokeJoin
);
52 aAttributes
.MiterLimit
= miterLimit
;
55 void EMFPCustomLineCap::ReadPath(SvStream
& s
, EmfPlusHelperData
const & rR
, bool bFill
)
58 s
.ReadInt32(pathLength
);
59 SAL_INFO("drawinglayer", "EMF+\t\tpath length: " << pathLength
);
60 sal_uInt32 pathHeader
;
61 sal_Int32 pathPoints
, pathFlags
;
62 s
.ReadUInt32(pathHeader
).ReadInt32(pathPoints
).ReadInt32(pathFlags
);
63 SAL_INFO("drawinglayer", "EMF+\t\tpath (custom cap line path)");
64 SAL_INFO("drawinglayer", "EMF+\t\theader: 0x" << std::hex
<< pathHeader
<< " points: " << std::dec
<< pathPoints
<< " additional flags: 0x" << std::hex
<< pathFlags
<< std::dec
);
66 EMFPPath
path(pathPoints
);
67 path
.Read(s
, pathFlags
);
68 polygon
= path
.GetPolygon(rR
, false);
72 void EMFPCustomLineCap::Read(SvStream
& s
, EmfPlusHelperData
const & rR
)
75 s
.ReadUInt32(header
).ReadUInt32(type
);
76 SAL_INFO("drawinglayer", "EMF+\t\tcustom cap");
77 SAL_INFO("drawinglayer", "EMF+\t\theader: 0x" << std::hex
<< header
<< " type: " << type
<< std::dec
);
79 if (type
== EmfPlusCustomLineCapDataTypeDefault
)
81 sal_uInt32 customLineCapDataFlags
, baseCap
;
84 float fillHotSpotX
, fillHotSpotY
, strokeHotSpotX
, strokeHotSpotY
;
86 s
.ReadUInt32(customLineCapDataFlags
).ReadUInt32(baseCap
).ReadFloat(baseInset
)
87 .ReadUInt32(strokeStartCap
).ReadUInt32(strokeEndCap
).ReadUInt32(strokeJoin
)
88 .ReadFloat(miterLimit
).ReadFloat(widthScale
)
89 .ReadFloat(fillHotSpotX
).ReadFloat(fillHotSpotY
).ReadFloat(strokeHotSpotX
).ReadFloat(strokeHotSpotY
);
91 SAL_INFO("drawinglayer", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex
<< customLineCapDataFlags
);
92 SAL_INFO("drawinglayer", "EMF+\t\tbaseCap: 0x" << std::hex
<< baseCap
);
93 SAL_INFO("drawinglayer", "EMF+\t\tbaseInset: " << baseInset
);
94 SAL_INFO("drawinglayer", "EMF+\t\tstrokeStartCap: 0x" << std::hex
<< strokeStartCap
);
95 SAL_INFO("drawinglayer", "EMF+\t\tstrokeEndCap: 0x" << std::hex
<< strokeEndCap
);
96 SAL_INFO("drawinglayer", "EMF+\t\tstrokeJoin: 0x" << std::hex
<< strokeJoin
);
97 SAL_INFO("drawinglayer", "EMF+\t\tmiterLimit: " << miterLimit
);
98 SAL_INFO("drawinglayer", "EMF+\t\twidthScale: " << widthScale
);
100 if (customLineCapDataFlags
& EmfPlusCustomLineCapDataFillPath
)
102 ReadPath(s
, rR
, true);
105 if (customLineCapDataFlags
& EmfPlusCustomLineCapDataLinePath
)
107 ReadPath(s
, rR
, false);
110 else if (type
== EmfPlusCustomLineCapDataTypeAdjustableArrow
)
112 // TODO only reads the data, does not use them [I've had
113 // no test document to be able to implement it]
115 sal_Int32 width
, height
, middleInset
, fillState
, lineStartCap
;
116 sal_Int32 lineEndCap
, lineJoin
, widthScale
;
117 float fillHotSpotX
, fillHotSpotY
, lineHotSpotX
, lineHotSpotY
;
119 s
.ReadInt32(width
).ReadInt32(height
).ReadInt32(middleInset
).ReadInt32(fillState
).ReadInt32(lineStartCap
)
120 .ReadInt32(lineEndCap
).ReadInt32(lineJoin
).ReadFloat(miterLimit
).ReadInt32(widthScale
)
121 .ReadFloat(fillHotSpotX
).ReadFloat(fillHotSpotY
).ReadFloat(lineHotSpotX
).ReadFloat(lineHotSpotY
);
123 SAL_INFO("drawinglayer", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)");
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */