calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / drawinglayer / source / tools / emfpcustomlinecap.cxx
blobe457a36cc2c488a8d12c59d973c46533b26059ea
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 .
20 #include <sal/log.hxx>
21 #include "emfpcustomlinecap.hxx"
22 #include "emfppath.hxx"
23 #include "emfppen.hxx"
24 #include <basegfx/matrix/b2dhommatrixtools.hxx>
26 using namespace ::com::sun::star;
27 using namespace ::basegfx;
29 namespace emfplushelper
31 const sal_uInt32 EmfPlusCustomLineCapDataTypeDefault = 0x00000000;
32 const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow = 0x00000001;
33 const sal_uInt32 EmfPlusCustomLineCapDataFillPath = 0x00000001;
34 const sal_uInt32 EmfPlusCustomLineCapDataLinePath = 0x00000002;
36 EMFPCustomLineCap::EMFPCustomLineCap()
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)
48 void EMFPCustomLineCap::ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill)
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);
59 EMFPPath path(pathPoints);
60 path.Read(s, pathFlags);
61 polygon = path.GetPolygon(rR, false);
62 // rotate polygon by 180 degrees
63 polygon.transform(basegfx::utils::createRotateB2DHomMatrix(M_PI));
64 mbIsFilled = bFill;
67 void EMFPCustomLineCap::Read(SvStream& s, EmfPlusHelperData const & rR)
69 sal_uInt32 header;
70 s.ReadUInt32(header).ReadUInt32(type);
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);
74 if (type == EmfPlusCustomLineCapDataTypeDefault)
76 sal_uInt32 customLineCapDataFlags, baseCap;
77 float baseInset;
78 float fillHotSpotX, fillHotSpotY, strokeHotSpotX, strokeHotSpotY;
80 s.ReadUInt32(customLineCapDataFlags).ReadUInt32(baseCap).ReadFloat(baseInset)
81 .ReadUInt32(strokeStartCap).ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin)
82 .ReadFloat(miterLimit).ReadFloat(widthScale)
83 .ReadFloat(fillHotSpotX).ReadFloat(fillHotSpotY).ReadFloat(strokeHotSpotX).ReadFloat(strokeHotSpotY);
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);
89 if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath)
91 ReadPath(s, rR, true);
94 if (customLineCapDataFlags & EmfPlusCustomLineCapDataLinePath)
96 ReadPath(s, rR, false);
99 else if (type == EmfPlusCustomLineCapDataTypeAdjustableArrow)
101 // TODO only reads the data, does not use them [I've had
102 // no test document to be able to implement it]
104 sal_Int32 fillState;
105 float width, height, middleInset, unusedHotSpot;
107 s.ReadFloat(width).ReadFloat(height).ReadFloat(middleInset).ReadInt32(fillState).ReadUInt32(strokeStartCap)
108 .ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin).ReadFloat(miterLimit).ReadFloat(widthScale)
109 .ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot);
111 SAL_INFO("drawinglayer.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)");
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);
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */