merge the formfield patch from ooo-build
[ooovba.git] / drawinglayer / source / primitive2d / fillbitmapprimitive2d.cxx
blobd7d004df02e9b655f256057ee375c4bb7399b828
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: fillbitmapprimitive2d.cxx,v $
7 * $Revision: 1.5 $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
40 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
41 #include <basegfx/polygon/b2dpolygon.hxx>
42 #include <basegfx/polygon/b2dpolygontools.hxx>
43 #include <drawinglayer/texture/texture.hxx>
44 #include <basegfx/tools/canvastools.hxx>
45 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
47 //////////////////////////////////////////////////////////////////////////////
49 using namespace com::sun::star;
51 //////////////////////////////////////////////////////////////////////////////
53 namespace drawinglayer
55 namespace primitive2d
57 Primitive2DSequence FillBitmapPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
59 const Size aTileSizePixel(getFillBitmap().getBitmap().GetSizePixel());
60 Primitive2DSequence aRetval;
62 // is there a tile with some size at all?
63 if(aTileSizePixel.getWidth() && aTileSizePixel.getHeight())
65 if(getFillBitmap().getTiling())
67 // get object range and create tiling matrices
68 ::std::vector< basegfx::B2DHomMatrix > aMatrices;
69 texture::GeoTexSvxTiled aTiling(getFillBitmap().getTopLeft(), getFillBitmap().getSize());
70 aTiling.appendTransformations(aMatrices);
72 // resize result
73 aRetval.realloc(aMatrices.size());
75 // create one primitive for each matrix
76 for(sal_uInt32 a(0L); a < aMatrices.size(); a++)
78 basegfx::B2DHomMatrix aNewMatrix = aMatrices[a];
79 aNewMatrix *= getTransformation();
81 // create bitmap primitive and add to result
82 const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aNewMatrix));
83 aRetval[a] = xRef;
86 else
88 // create new object transform
89 basegfx::B2DHomMatrix aObjectTransform;
90 aObjectTransform.set(0L, 0L, getFillBitmap().getSize().getX());
91 aObjectTransform.set(1L, 1L, getFillBitmap().getSize().getY());
92 aObjectTransform.set(0L, 2L, getFillBitmap().getTopLeft().getX());
93 aObjectTransform.set(1L, 2L, getFillBitmap().getTopLeft().getY());
94 aObjectTransform *= getTransformation();
96 // create bitmap primitive and add exclusive to decomposition (hand over ownership)
97 const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aObjectTransform));
98 aRetval = Primitive2DSequence(&xRef, 1L);
102 return aRetval;
105 FillBitmapPrimitive2D::FillBitmapPrimitive2D(
106 const basegfx::B2DHomMatrix& rTransformation,
107 const attribute::FillBitmapAttribute& rFillBitmap)
108 : BasePrimitive2D(),
109 maTransformation(rTransformation),
110 maFillBitmap(rFillBitmap)
114 bool FillBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
116 if(BasePrimitive2D::operator==(rPrimitive))
118 const FillBitmapPrimitive2D& rCompare = static_cast< const FillBitmapPrimitive2D& >(rPrimitive);
120 return (getTransformation() == rCompare.getTransformation()
121 && getFillBitmap() == rCompare.getFillBitmap());
124 return false;
127 basegfx::B2DRange FillBitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
129 // return range of it
130 basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)));
131 aPolygon.transform(getTransformation());
132 return basegfx::tools::getRange(aPolygon);
135 // provide unique ID
136 ImplPrimitrive2DIDBlock(FillBitmapPrimitive2D, PRIMITIVE2D_ID_FILLBITMAPPRIMITIVE2D)
138 } // end of namespace primitive2d
139 } // end of namespace drawinglayer
141 //////////////////////////////////////////////////////////////////////////////
142 // eof