1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_canvas.hxx"
26 
27 #include <basegfx/tools/canvastools.hxx>
28 #include "dx_linepolypolygon.hxx"
29 
30 
31 using namespace ::com::sun::star;
32 
33 namespace dxcanvas
34 {
LinePolyPolygon(const::basegfx::B2DPolyPolygon & rPolyPoly)35     LinePolyPolygon::LinePolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly ) :
36         ::basegfx::unotools::UnoPolyPolygon( rPolyPoly ),
37 		mpGdiPlusUser( GDIPlusUser::createInstance() ),
38         mpPath()
39     {
40     }
41 
getGraphicsPath(bool bNoLineJoin) const42     GraphicsPathSharedPtr LinePolyPolygon::getGraphicsPath( bool bNoLineJoin ) const
43     {
44         // generate GraphicsPath only on demand (gets deleted as soon
45         // as any of the modifying methods above touches the
46         // B2DPolyPolygon).
47         if( !mpPath )
48         {
49             mpPath = tools::graphicsPathFromB2DPolyPolygon( getPolyPolygonUnsafe(), bNoLineJoin );
50             mpPath->SetFillMode( const_cast<LinePolyPolygon*>(this)->getFillRule() == rendering::FillRule_EVEN_ODD ?
51                                  Gdiplus::FillModeAlternate : Gdiplus::FillModeWinding );
52         }
53 
54         return mpPath;
55     }
56 
modifying() const57     void LinePolyPolygon::modifying() const
58     {
59         mpPath.reset();
60     }
61 }
62