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 <drawinglayer/primitive2d/epsprimitive2d.hxx>
21 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
22 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
23 
24 namespace drawinglayer::primitive2d
25 {
create2DDecomposition(Primitive2DContainer & rContainer,const geometry::ViewInformation2D &) const26         void EpsPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const
27         {
28             const GDIMetaFile& rSubstituteContent = getMetaFile();
29 
30             if( rSubstituteContent.GetActionSize() )
31             {
32                 // the default decomposition will use the Metafile replacement visualisation.
33                 // To really use the Eps data, a renderer has to know and interpret this primitive
34                 // directly.
35 
36                 rContainer.push_back(
37                     new MetafilePrimitive2D(
38                         getEpsTransform(),
39                         rSubstituteContent));
40             }
41         }
42 
EpsPrimitive2D(const basegfx::B2DHomMatrix & rEpsTransform,const GfxLink & rGfxLink,const GDIMetaFile & rMetaFile)43         EpsPrimitive2D::EpsPrimitive2D(
44             const basegfx::B2DHomMatrix& rEpsTransform,
45             const GfxLink& rGfxLink,
46             const GDIMetaFile& rMetaFile)
47         :   BufferedDecompositionPrimitive2D(),
48             maEpsTransform(rEpsTransform),
49             maGfxLink(rGfxLink),
50             maMetaFile(rMetaFile)
51         {
52         }
53 
operator ==(const BasePrimitive2D & rPrimitive) const54         bool EpsPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
55         {
56             if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
57             {
58                 const EpsPrimitive2D& rCompare = static_cast<const EpsPrimitive2D&>(rPrimitive);
59 
60                 return (getEpsTransform() == rCompare.getEpsTransform()
61                     && getGfxLink() == rCompare.getGfxLink()
62                     && getMetaFile() == rCompare.getMetaFile());
63             }
64 
65             return false;
66         }
67 
getB2DRange(const geometry::ViewInformation2D &) const68         basegfx::B2DRange EpsPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
69         {
70             // use own implementation to quickly answer the getB2DRange question.
71             basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0);
72             aRetval.transform(getEpsTransform());
73 
74             return aRetval;
75         }
76 
77         // provide unique ID
78         ImplPrimitive2DIDBlock(EpsPrimitive2D, PRIMITIVE2D_ID_EPSPRIMITIVE2D)
79 
80 } // end of namespace
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
83