1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "viewcontactoftableobj.hxx"
28cdf0e10cSrcweir #include <svx/svdotable.hxx>
29cdf0e10cSrcweir #include <com/sun/star/table/XTable.hpp>
30cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygontools.hxx>
31cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
32cdf0e10cSrcweir #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
33cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
34cdf0e10cSrcweir #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
35cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
36cdf0e10cSrcweir #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
37cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
38cdf0e10cSrcweir #include <svx/sdr/attribute/sdrtextattribute.hxx>
39cdf0e10cSrcweir #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
40cdf0e10cSrcweir #include <editeng/borderline.hxx>
41cdf0e10cSrcweir #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
42cdf0e10cSrcweir #include <svx/sdr/attribute/sdrfilltextattribute.hxx>
43cdf0e10cSrcweir #include <drawinglayer/attribute/sdrlineattribute.hxx>
44cdf0e10cSrcweir #include <drawinglayer/attribute/sdrshadowattribute.hxx>
45cdf0e10cSrcweir #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
46cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "cell.hxx"
49cdf0e10cSrcweir #include "tablelayouter.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace com::sun::star;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace drawinglayer
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	namespace primitive2d
60cdf0e10cSrcweir 	{
61cdf0e10cSrcweir 		class SdrCellPrimitive2D : public BufferedDecompositionPrimitive2D
62cdf0e10cSrcweir 		{
63cdf0e10cSrcweir 		private:
64cdf0e10cSrcweir 			basegfx::B2DHomMatrix						maTransform;
65cdf0e10cSrcweir 			attribute::SdrFillTextAttribute				maSdrFTAttribute;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 		protected:
68cdf0e10cSrcweir 			// local decomposition.
69cdf0e10cSrcweir 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 		public:
SdrCellPrimitive2D(const basegfx::B2DHomMatrix & rTransform,const attribute::SdrFillTextAttribute & rSdrFTAttribute)72cdf0e10cSrcweir 			SdrCellPrimitive2D(
73cdf0e10cSrcweir 				const basegfx::B2DHomMatrix& rTransform,
74cdf0e10cSrcweir 				const attribute::SdrFillTextAttribute& rSdrFTAttribute)
75cdf0e10cSrcweir 			:	BufferedDecompositionPrimitive2D(),
76cdf0e10cSrcweir 				maTransform(rTransform),
77cdf0e10cSrcweir 				maSdrFTAttribute(rSdrFTAttribute)
78cdf0e10cSrcweir 			{
79cdf0e10cSrcweir 			}
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 			// data access
getTransform() const82cdf0e10cSrcweir 			const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
getSdrFTAttribute() const83cdf0e10cSrcweir 			const attribute::SdrFillTextAttribute& getSdrFTAttribute() const { return maSdrFTAttribute; }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 			// compare operator
86cdf0e10cSrcweir 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 			// provide unique ID
89cdf0e10cSrcweir 			DeclPrimitrive2DIDBlock()
90cdf0e10cSrcweir 		};
91cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const92cdf0e10cSrcweir 		Primitive2DSequence SdrCellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
93cdf0e10cSrcweir 		{
94cdf0e10cSrcweir 			// prepare unit polygon
95cdf0e10cSrcweir 			Primitive2DSequence aRetval;
96cdf0e10cSrcweir 			const basegfx::B2DPolyPolygon aUnitPolyPolygon(basegfx::tools::createUnitPolygon());
97cdf0e10cSrcweir 
98*64b14621SArmin Le Grand             // add fill
99*64b14621SArmin Le Grand             if(!getSdrFTAttribute().getFill().isDefault())
100*64b14621SArmin Le Grand             {
101*64b14621SArmin Le Grand                 basegfx::B2DPolyPolygon aTransformed(aUnitPolyPolygon);
102*64b14621SArmin Le Grand 
103*64b14621SArmin Le Grand                 aTransformed.transform(getTransform());
104*64b14621SArmin Le Grand                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
105*64b14621SArmin Le Grand                     createPolyPolygonFillPrimitive(
106*64b14621SArmin Le Grand                         aTransformed,
107*64b14621SArmin Le Grand                         getSdrFTAttribute().getFill(),
108*64b14621SArmin Le Grand                         getSdrFTAttribute().getFillFloatTransGradient()));
109*64b14621SArmin Le Grand             }
110cdf0e10cSrcweir             else
111cdf0e10cSrcweir             {
112cdf0e10cSrcweir                 // if no fill create one for HitTest and BoundRect fallback
113cdf0e10cSrcweir                 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
114cdf0e10cSrcweir                     createHiddenGeometryPrimitives2D(
115cdf0e10cSrcweir                         true,
116cdf0e10cSrcweir                         aUnitPolyPolygon,
117cdf0e10cSrcweir                         getTransform()));
118cdf0e10cSrcweir             }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 			// add text
121cdf0e10cSrcweir 			if(!getSdrFTAttribute().getText().isDefault())
122cdf0e10cSrcweir 			{
123cdf0e10cSrcweir 				appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
124cdf0e10cSrcweir 					createTextPrimitive(
125cdf0e10cSrcweir 						aUnitPolyPolygon,
126cdf0e10cSrcweir 						getTransform(),
127cdf0e10cSrcweir 						getSdrFTAttribute().getText(),
128cdf0e10cSrcweir 						attribute::SdrLineAttribute(),
129cdf0e10cSrcweir 						true,
130cdf0e10cSrcweir 						false,
131cdf0e10cSrcweir 						false));
132cdf0e10cSrcweir 			}
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 			return aRetval;
135cdf0e10cSrcweir 		}
136cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const137cdf0e10cSrcweir 		bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
138cdf0e10cSrcweir 		{
139cdf0e10cSrcweir 			if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
140cdf0e10cSrcweir 			{
141cdf0e10cSrcweir 				const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 				return (getTransform() == rCompare.getTransform()
144cdf0e10cSrcweir 					&& getSdrFTAttribute() == rCompare.getSdrFTAttribute());
145cdf0e10cSrcweir 			}
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 			return false;
148cdf0e10cSrcweir 		}
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 		// provide unique ID
151cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(SdrCellPrimitive2D, PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D)
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	} // end of namespace primitive2d
154cdf0e10cSrcweir } // end of namespace drawinglayer
155cdf0e10cSrcweir 
156cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
157cdf0e10cSrcweir 
158cdf0e10cSrcweir namespace drawinglayer
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	namespace primitive2d
161cdf0e10cSrcweir 	{
162cdf0e10cSrcweir 		class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D
163cdf0e10cSrcweir 		{
164cdf0e10cSrcweir 		private:
165cdf0e10cSrcweir 			basegfx::B2DHomMatrix						maTransform;
166cdf0e10cSrcweir 			SvxBorderLine								maLeftLine;
167cdf0e10cSrcweir 			SvxBorderLine								maBottomLine;
168cdf0e10cSrcweir 			SvxBorderLine								maRightLine;
169cdf0e10cSrcweir 			SvxBorderLine								maTopLine;
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 			// bitfield
172cdf0e10cSrcweir 			unsigned									mbLeftIsOutside : 1;
173cdf0e10cSrcweir 			unsigned									mbBottomIsOutside : 1;
174cdf0e10cSrcweir 			unsigned									mbRightIsOutside : 1;
175cdf0e10cSrcweir 			unsigned									mbTopIsOutside : 1;
176cdf0e10cSrcweir 			unsigned									mbInTwips : 1;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 		protected:
179cdf0e10cSrcweir 			// local decomposition.
180cdf0e10cSrcweir 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 		public:
SdrBorderlinePrimitive2D(const basegfx::B2DHomMatrix & rTransform,const SvxBorderLine & rLeftLine,const SvxBorderLine & rBottomLine,const SvxBorderLine & rRightLine,const SvxBorderLine & rTopLine,bool bLeftIsOutside,bool bBottomIsOutside,bool bRightIsOutside,bool bTopIsOutside,bool bInTwips)183cdf0e10cSrcweir 			SdrBorderlinePrimitive2D(
184cdf0e10cSrcweir 				const basegfx::B2DHomMatrix& rTransform,
185cdf0e10cSrcweir 				const SvxBorderLine& rLeftLine,
186cdf0e10cSrcweir 				const SvxBorderLine& rBottomLine,
187cdf0e10cSrcweir 				const SvxBorderLine& rRightLine,
188cdf0e10cSrcweir 				const SvxBorderLine& rTopLine,
189cdf0e10cSrcweir 				bool bLeftIsOutside,
190cdf0e10cSrcweir 				bool bBottomIsOutside,
191cdf0e10cSrcweir 				bool bRightIsOutside,
192cdf0e10cSrcweir 				bool bTopIsOutside,
193cdf0e10cSrcweir 				bool bInTwips)
194cdf0e10cSrcweir 			:	BufferedDecompositionPrimitive2D(),
195cdf0e10cSrcweir 				maTransform(rTransform),
196cdf0e10cSrcweir 				maLeftLine(rLeftLine),
197cdf0e10cSrcweir 				maBottomLine(rBottomLine),
198cdf0e10cSrcweir 				maRightLine(rRightLine),
199cdf0e10cSrcweir 				maTopLine(rTopLine),
200cdf0e10cSrcweir 				mbLeftIsOutside(bLeftIsOutside),
201cdf0e10cSrcweir 				mbBottomIsOutside(bBottomIsOutside),
202cdf0e10cSrcweir 				mbRightIsOutside(bRightIsOutside),
203cdf0e10cSrcweir 				mbTopIsOutside(bTopIsOutside),
204cdf0e10cSrcweir 				mbInTwips(bInTwips)
205cdf0e10cSrcweir 			{
206cdf0e10cSrcweir 			}
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 			// data access
getTransform() const210cdf0e10cSrcweir 			const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
getLeftLine() const211cdf0e10cSrcweir 			const SvxBorderLine& getLeftLine() const { return maLeftLine; }
getBottomLine() const212cdf0e10cSrcweir 			const SvxBorderLine& getBottomLine() const { return maBottomLine; }
getRightLine() const213cdf0e10cSrcweir 			const SvxBorderLine& getRightLine() const { return maRightLine; }
getTopLine() const214cdf0e10cSrcweir 			const SvxBorderLine& getTopLine() const { return maTopLine; }
getLeftIsOutside() const215cdf0e10cSrcweir 			bool getLeftIsOutside() const { return mbLeftIsOutside; }
getBottomIsOutside() const216cdf0e10cSrcweir 			bool getBottomIsOutside() const { return mbBottomIsOutside; }
getRightIsOutside() const217cdf0e10cSrcweir 			bool getRightIsOutside() const { return mbRightIsOutside; }
getTopIsOutside() const218cdf0e10cSrcweir 			bool getTopIsOutside() const { return mbTopIsOutside; }
getInTwips() const219cdf0e10cSrcweir 			bool getInTwips() const { return mbInTwips; }
220cdf0e10cSrcweir 
221cdf0e10cSrcweir 			// compare operator
222cdf0e10cSrcweir 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 			// provide unique ID
225cdf0e10cSrcweir 			DeclPrimitrive2DIDBlock()
226cdf0e10cSrcweir 		};
227cdf0e10cSrcweir 
getBorderLineOutWidth(const SvxBorderLine & rLineA)228cdf0e10cSrcweir 		sal_uInt16 getBorderLineOutWidth(const SvxBorderLine& rLineA)
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			return (1 == rLineA.GetOutWidth() ? 0 : rLineA.GetOutWidth());
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 
getBorderLineDistance(const SvxBorderLine & rLineA)233cdf0e10cSrcweir 		sal_uInt16 getBorderLineDistance(const SvxBorderLine& rLineA)
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir 			return (1 == rLineA.GetDistance() ? 0 : rLineA.GetDistance());
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 
getBorderLineInWidth(const SvxBorderLine & rLineA)238cdf0e10cSrcweir 		sal_uInt16 getBorderLineInWidth(const SvxBorderLine& rLineA)
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			return (1 == rLineA.GetInWidth() ? 0 : rLineA.GetInWidth());
241cdf0e10cSrcweir 		}
242cdf0e10cSrcweir 
getBorderLineWidth(const SvxBorderLine & rLineA)243cdf0e10cSrcweir 		sal_uInt16 getBorderLineWidth(const SvxBorderLine& rLineA)
244cdf0e10cSrcweir 		{
245cdf0e10cSrcweir 			return getBorderLineOutWidth(rLineA) + getBorderLineDistance(rLineA) + getBorderLineInWidth(rLineA);
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 
getInnerExtend(const SvxBorderLine & rLineA,bool bSideToUse)248cdf0e10cSrcweir 		double getInnerExtend(const SvxBorderLine& rLineA, bool bSideToUse)
249cdf0e10cSrcweir 		{
250cdf0e10cSrcweir 			if(!rLineA.isEmpty())
251cdf0e10cSrcweir 			{
252cdf0e10cSrcweir 				if(rLineA.isDouble())
253cdf0e10cSrcweir 				{
254cdf0e10cSrcweir 					// reduce to inner edge of associated matching line
255cdf0e10cSrcweir 					return -((getBorderLineWidth(rLineA) / 2.0) - (bSideToUse ? getBorderLineOutWidth(rLineA) : getBorderLineInWidth(rLineA)));
256cdf0e10cSrcweir 				}
257cdf0e10cSrcweir 				else
258cdf0e10cSrcweir 				{
259cdf0e10cSrcweir 					// extend to overlap with single line
260cdf0e10cSrcweir 					return getBorderLineWidth(rLineA) / 2.0;
261cdf0e10cSrcweir 				}
262cdf0e10cSrcweir 			}
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 			return 0.0;
265cdf0e10cSrcweir 		}
266cdf0e10cSrcweir 
getOuterExtend(const SvxBorderLine & rLineA)267cdf0e10cSrcweir 		double getOuterExtend(const SvxBorderLine& rLineA)
268cdf0e10cSrcweir 		{
269cdf0e10cSrcweir 			if(!rLineA.isEmpty())
270cdf0e10cSrcweir 			{
271cdf0e10cSrcweir 				// extend to overlap with single line
272cdf0e10cSrcweir 				return getBorderLineWidth(rLineA) / 2.0;
273cdf0e10cSrcweir 			}
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 			return 0.0;
276cdf0e10cSrcweir 		}
277cdf0e10cSrcweir 
getChangedValue(sal_uInt16 nValue,bool bChangeToMM)278cdf0e10cSrcweir 		double getChangedValue(sal_uInt16 nValue, bool bChangeToMM)
279cdf0e10cSrcweir 		{
280cdf0e10cSrcweir 			if(1 == nValue)
281cdf0e10cSrcweir 				return 1.0;
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 			if(bChangeToMM)
284cdf0e10cSrcweir 				return nValue * (127.0 / 72.0);
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 			return (double)nValue;
287cdf0e10cSrcweir 		}
288cdf0e10cSrcweir 
create2DDecomposition(const geometry::ViewInformation2D &) const289cdf0e10cSrcweir 		Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
290cdf0e10cSrcweir 		{
291cdf0e10cSrcweir 			Primitive2DSequence xRetval(4);
292cdf0e10cSrcweir 			sal_uInt32 nInsert(0);
293cdf0e10cSrcweir 			const double fTwipsToMM(getInTwips() ? (127.0 / 72.0) : 1.0);
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 			if(!getLeftLine().isEmpty())
296cdf0e10cSrcweir 			{
297cdf0e10cSrcweir 				// create left line from top to bottom
298cdf0e10cSrcweir 				const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
299cdf0e10cSrcweir 				const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(0.0, 1.0));
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 				if(!aStart.equal(aEnd))
302cdf0e10cSrcweir 				{
303cdf0e10cSrcweir 					const double fExtendIS(getInnerExtend(getTopLine(), false));
304cdf0e10cSrcweir 					const double fExtendIE(getInnerExtend(getBottomLine(), true));
305cdf0e10cSrcweir 					double fExtendOS(0.0);
306cdf0e10cSrcweir 					double fExtendOE(0.0);
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 					if(getLeftIsOutside())
309cdf0e10cSrcweir 					{
310cdf0e10cSrcweir 						if(getTopIsOutside())
311cdf0e10cSrcweir 						{
312cdf0e10cSrcweir 							fExtendOS = getOuterExtend(getTopLine());
313cdf0e10cSrcweir 						}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 						if(getBottomIsOutside())
316cdf0e10cSrcweir 						{
317cdf0e10cSrcweir 							fExtendOE = getOuterExtend(getBottomLine());
318cdf0e10cSrcweir 						}
319cdf0e10cSrcweir 					}
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 					xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
322cdf0e10cSrcweir 						aStart,
323cdf0e10cSrcweir 						aEnd,
324cdf0e10cSrcweir 						getChangedValue(getLeftLine().GetOutWidth(), getInTwips()),
325cdf0e10cSrcweir 						getChangedValue(getLeftLine().GetDistance(), getInTwips()),
326cdf0e10cSrcweir 						getChangedValue(getLeftLine().GetInWidth(), getInTwips()),
327cdf0e10cSrcweir 						fExtendIS * fTwipsToMM,
328cdf0e10cSrcweir 						fExtendIE * fTwipsToMM,
329cdf0e10cSrcweir 						fExtendOS * fTwipsToMM,
330cdf0e10cSrcweir 						fExtendOE * fTwipsToMM,
331cdf0e10cSrcweir 						true,
332cdf0e10cSrcweir 						getLeftIsOutside(),
333cdf0e10cSrcweir 						getLeftLine().GetColor().getBColor()));
334cdf0e10cSrcweir 				}
335cdf0e10cSrcweir 			}
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 			if(!getBottomLine().isEmpty())
338cdf0e10cSrcweir 			{
339cdf0e10cSrcweir 				// create bottom line from left to right
340cdf0e10cSrcweir 				const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 1.0));
341cdf0e10cSrcweir 				const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 				if(!aStart.equal(aEnd))
344cdf0e10cSrcweir 				{
345cdf0e10cSrcweir 					const double fExtendIS(getInnerExtend(getLeftLine(), true));
346cdf0e10cSrcweir 					const double fExtendIE(getInnerExtend(getRightLine(), false));
347cdf0e10cSrcweir 					double fExtendOS(0.0);
348cdf0e10cSrcweir 					double fExtendOE(0.0);
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 					if(getBottomIsOutside())
351cdf0e10cSrcweir 					{
352cdf0e10cSrcweir 						if(getLeftIsOutside())
353cdf0e10cSrcweir 						{
354cdf0e10cSrcweir 							fExtendOS = getOuterExtend(getLeftLine());
355cdf0e10cSrcweir 						}
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 						if(getRightIsOutside())
358cdf0e10cSrcweir 						{
359cdf0e10cSrcweir 							fExtendOE = getOuterExtend(getRightLine());
360cdf0e10cSrcweir 						}
361cdf0e10cSrcweir 					}
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 					xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
364cdf0e10cSrcweir 						aStart,
365cdf0e10cSrcweir 						aEnd,
366cdf0e10cSrcweir 						getChangedValue(getBottomLine().GetOutWidth(), getInTwips()),
367cdf0e10cSrcweir 						getChangedValue(getBottomLine().GetDistance(), getInTwips()),
368cdf0e10cSrcweir 						getChangedValue(getBottomLine().GetInWidth(), getInTwips()),
369cdf0e10cSrcweir 						fExtendIS * fTwipsToMM,
370cdf0e10cSrcweir 						fExtendIE * fTwipsToMM,
371cdf0e10cSrcweir 						fExtendOS * fTwipsToMM,
372cdf0e10cSrcweir 						fExtendOE * fTwipsToMM,
373cdf0e10cSrcweir 						true,
374cdf0e10cSrcweir 						getBottomIsOutside(),
375cdf0e10cSrcweir 						getBottomLine().GetColor().getBColor()));
376cdf0e10cSrcweir 				}
377cdf0e10cSrcweir 			}
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 			if(!getRightLine().isEmpty())
380cdf0e10cSrcweir 			{
381cdf0e10cSrcweir 				// create right line from top to bottom
382cdf0e10cSrcweir 				const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(1.0, 0.0));
383cdf0e10cSrcweir 				const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 				if(!aStart.equal(aEnd))
386cdf0e10cSrcweir 				{
387cdf0e10cSrcweir 					const double fExtendIS(getInnerExtend(getTopLine(), false));
388cdf0e10cSrcweir 					const double fExtendIE(getInnerExtend(getBottomLine(), true));
389cdf0e10cSrcweir 					double fExtendOS(0.0);
390cdf0e10cSrcweir 					double fExtendOE(0.0);
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 					if(getRightIsOutside())
393cdf0e10cSrcweir 					{
394cdf0e10cSrcweir 						if(getTopIsOutside())
395cdf0e10cSrcweir 						{
396cdf0e10cSrcweir 							fExtendOS = getOuterExtend(getTopLine());
397cdf0e10cSrcweir 						}
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 						if(getBottomIsOutside())
400cdf0e10cSrcweir 						{
401cdf0e10cSrcweir 							fExtendOE = getOuterExtend(getBottomLine());
402cdf0e10cSrcweir 						}
403cdf0e10cSrcweir 					}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 					xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
406cdf0e10cSrcweir 						aStart,
407cdf0e10cSrcweir 						aEnd,
408cdf0e10cSrcweir 						getChangedValue(getRightLine().GetOutWidth(), getInTwips()),
409cdf0e10cSrcweir 						getChangedValue(getRightLine().GetDistance(), getInTwips()),
410cdf0e10cSrcweir 						getChangedValue(getRightLine().GetInWidth(), getInTwips()),
411cdf0e10cSrcweir 						fExtendOS * fTwipsToMM,
412cdf0e10cSrcweir 						fExtendOE * fTwipsToMM,
413cdf0e10cSrcweir 						fExtendIS * fTwipsToMM,
414cdf0e10cSrcweir 						fExtendIE * fTwipsToMM,
415cdf0e10cSrcweir 						getRightIsOutside(),
416cdf0e10cSrcweir 						true,
417cdf0e10cSrcweir 						getRightLine().GetColor().getBColor()));
418cdf0e10cSrcweir 				}
419cdf0e10cSrcweir 			}
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 			if(!getTopLine().isEmpty())
422cdf0e10cSrcweir 			{
423cdf0e10cSrcweir 				// create top line from left to right
424cdf0e10cSrcweir 				const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
425cdf0e10cSrcweir 				const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 0.0));
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 				if(!aStart.equal(aEnd))
428cdf0e10cSrcweir 				{
429cdf0e10cSrcweir 					const double fExtendIS(getInnerExtend(getLeftLine(), true));
430cdf0e10cSrcweir 					const double fExtendIE(getInnerExtend(getRightLine(), false));
431cdf0e10cSrcweir 					double fExtendOS(0.0);
432cdf0e10cSrcweir 					double fExtendOE(0.0);
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 					if(getTopIsOutside())
435cdf0e10cSrcweir 					{
436cdf0e10cSrcweir 						if(getLeftIsOutside())
437cdf0e10cSrcweir 						{
438cdf0e10cSrcweir 							fExtendOS = getOuterExtend(getLeftLine());
439cdf0e10cSrcweir 						}
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 						if(getRightIsOutside())
442cdf0e10cSrcweir 						{
443cdf0e10cSrcweir 							fExtendOE = getOuterExtend(getRightLine());
444cdf0e10cSrcweir 						}
445cdf0e10cSrcweir 					}
446cdf0e10cSrcweir 
447cdf0e10cSrcweir 					xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
448cdf0e10cSrcweir 						aStart,
449cdf0e10cSrcweir 						aEnd,
450cdf0e10cSrcweir 						getChangedValue(getTopLine().GetOutWidth(), getInTwips()),
451cdf0e10cSrcweir 						getChangedValue(getTopLine().GetDistance(), getInTwips()),
452cdf0e10cSrcweir 						getChangedValue(getTopLine().GetInWidth(), getInTwips()),
453cdf0e10cSrcweir 						fExtendOS * fTwipsToMM,
454cdf0e10cSrcweir 						fExtendOE * fTwipsToMM,
455cdf0e10cSrcweir 						fExtendIS * fTwipsToMM,
456cdf0e10cSrcweir 						fExtendIE * fTwipsToMM,
457cdf0e10cSrcweir 						getTopIsOutside(),
458cdf0e10cSrcweir 						true,
459cdf0e10cSrcweir 						getTopLine().GetColor().getBColor()));
460cdf0e10cSrcweir 				}
461cdf0e10cSrcweir 			}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 			xRetval.realloc(nInsert);
464cdf0e10cSrcweir 			return xRetval;
465cdf0e10cSrcweir 		}
466cdf0e10cSrcweir 
operator ==(const BasePrimitive2D & rPrimitive) const467cdf0e10cSrcweir 		bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
468cdf0e10cSrcweir 		{
469cdf0e10cSrcweir 			if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
470cdf0e10cSrcweir 			{
471cdf0e10cSrcweir 				const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive;
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 				return (getTransform() == rCompare.getTransform()
474cdf0e10cSrcweir 					&& getLeftLine() == rCompare.getLeftLine()
475cdf0e10cSrcweir 					&& getBottomLine() == rCompare.getBottomLine()
476cdf0e10cSrcweir 					&& getRightLine() == rCompare.getRightLine()
477cdf0e10cSrcweir 					&& getTopLine() == rCompare.getTopLine()
478cdf0e10cSrcweir 					&& getLeftIsOutside() == rCompare.getLeftIsOutside()
479cdf0e10cSrcweir 					&& getBottomIsOutside() == rCompare.getBottomIsOutside()
480cdf0e10cSrcweir 					&& getRightIsOutside() == rCompare.getRightIsOutside()
481cdf0e10cSrcweir 					&& getTopIsOutside() == rCompare.getTopIsOutside()
482cdf0e10cSrcweir 					&& getInTwips() == rCompare.getInTwips());
483cdf0e10cSrcweir 			}
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 			return false;
486cdf0e10cSrcweir 		}
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 		// provide unique ID
489cdf0e10cSrcweir 		ImplPrimitrive2DIDBlock(SdrBorderlinePrimitive2D, PRIMITIVE2D_ID_SDRBORDERLINEPRIMITIVE2D)
490cdf0e10cSrcweir 
491cdf0e10cSrcweir 	} // end of namespace primitive2d
492cdf0e10cSrcweir } // end of namespace drawinglayer
493cdf0e10cSrcweir 
494cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
495cdf0e10cSrcweir 
496cdf0e10cSrcweir namespace sdr
497cdf0e10cSrcweir {
498cdf0e10cSrcweir 	namespace contact
499cdf0e10cSrcweir 	{
impGetLine(SvxBorderLine & aLine,const sdr::table::TableLayouter & rLayouter,sal_Int32 nX,sal_Int32 nY,bool bHorizontal,sal_Int32 nColCount,sal_Int32 nRowCount,bool bIsRTL)500cdf0e10cSrcweir 		void impGetLine(SvxBorderLine& aLine, const sdr::table::TableLayouter& rLayouter, sal_Int32 nX, sal_Int32 nY, bool bHorizontal, sal_Int32 nColCount, sal_Int32 nRowCount, bool bIsRTL)
501cdf0e10cSrcweir 		{
502cdf0e10cSrcweir 			if(nX >= 0 && nX <= nColCount && nY >= 0 && nY <= nRowCount)
503cdf0e10cSrcweir 			{
504cdf0e10cSrcweir 				const SvxBorderLine* pLine = rLayouter.getBorderLine(nX, nY, bHorizontal);
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 				if(pLine)
507cdf0e10cSrcweir 				{
508cdf0e10cSrcweir 					// copy line content
509cdf0e10cSrcweir 					aLine = *pLine;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 					// check for mirroring. This shall always be done when it is
512cdf0e10cSrcweir 					// not a top- or rightmost line
513cdf0e10cSrcweir 					bool bMirror(aLine.isDouble());
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 					if(bMirror)
516cdf0e10cSrcweir 					{
517cdf0e10cSrcweir 						if(bHorizontal)
518cdf0e10cSrcweir 						{
519cdf0e10cSrcweir 							// mirror all bottom lines
520cdf0e10cSrcweir 							bMirror = (0 != nY);
521cdf0e10cSrcweir 						}
522cdf0e10cSrcweir 						else
523cdf0e10cSrcweir 						{
524cdf0e10cSrcweir 							// mirror all left lines
525cdf0e10cSrcweir 							bMirror = (bIsRTL ? 0 != nX : nX != nColCount);
526cdf0e10cSrcweir 						}
527cdf0e10cSrcweir 					}
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 					if(bMirror)
530cdf0e10cSrcweir 					{
531cdf0e10cSrcweir 						aLine.SetOutWidth(pLine->GetInWidth());
532cdf0e10cSrcweir 						aLine.SetInWidth(pLine->GetOutWidth());
533cdf0e10cSrcweir 					}
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 					return;
536cdf0e10cSrcweir 				}
537cdf0e10cSrcweir 			}
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 			// no success, copy empty line
540cdf0e10cSrcweir 			const SvxBorderLine aEmptyLine;
541cdf0e10cSrcweir 			aLine = aEmptyLine;
542cdf0e10cSrcweir 		}
543cdf0e10cSrcweir 
createViewIndependentPrimitive2DSequence() const544cdf0e10cSrcweir 		drawinglayer::primitive2d::Primitive2DSequence ViewContactOfTableObj::createViewIndependentPrimitive2DSequence() const
545cdf0e10cSrcweir         {
546cdf0e10cSrcweir 			const sdr::table::SdrTableObj& rTableObj = GetTableObj();
547cdf0e10cSrcweir             const uno::Reference< com::sun::star::table::XTable > xTable = rTableObj.getTable();
548cdf0e10cSrcweir 
549cdf0e10cSrcweir             if(xTable.is())
550cdf0e10cSrcweir             {
551cdf0e10cSrcweir                 // create primitive representation for table
552cdf0e10cSrcweir 	            drawinglayer::primitive2d::Primitive2DSequence xRetval;
553cdf0e10cSrcweir                 const sal_Int32 nRowCount(xTable->getRowCount());
554cdf0e10cSrcweir                 const sal_Int32 nColCount(xTable->getColumnCount());
555cdf0e10cSrcweir                 const sal_Int32 nAllCount(nRowCount * nColCount);
556cdf0e10cSrcweir 
557cdf0e10cSrcweir                 if(nAllCount)
558cdf0e10cSrcweir                 {
559cdf0e10cSrcweir 					const sdr::table::TableLayouter& rTableLayouter = rTableObj.getTableLayouter();
560cdf0e10cSrcweir 					const bool bIsRTL(com::sun::star::text::WritingMode_RL_TB == rTableObj.GetWritingMode());
561cdf0e10cSrcweir                 	sdr::table::CellPos aCellPos;
562cdf0e10cSrcweir 					sdr::table::CellRef xCurrentCell;
563cdf0e10cSrcweir 					basegfx::B2IRectangle aCellArea;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 		            // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
566cdf0e10cSrcweir                     // GetGeoRect() to not trigger any calculations. It's the unrotated geometry.
567cdf0e10cSrcweir 		            const Rectangle& rObjectRectangle(rTableObj.GetGeoRect());
568cdf0e10cSrcweir 		            const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 					// for each cell we need potentially a cell primitive and a border primitive
571cdf0e10cSrcweir 					// (e.g. single cell). Prepare sequences and input counters
572cdf0e10cSrcweir 					drawinglayer::primitive2d::Primitive2DSequence xCellSequence(nAllCount);
573cdf0e10cSrcweir 					drawinglayer::primitive2d::Primitive2DSequence xBorderSequence(nAllCount);
574cdf0e10cSrcweir 					sal_uInt32 nCellInsert(0);
575cdf0e10cSrcweir 					sal_uInt32 nBorderInsert(0);
576cdf0e10cSrcweir 
577cdf0e10cSrcweir 					// variables for border lines
578cdf0e10cSrcweir 					SvxBorderLine aLeftLine;
579cdf0e10cSrcweir 					SvxBorderLine aBottomLine;
580cdf0e10cSrcweir 					SvxBorderLine aRightLine;
581cdf0e10cSrcweir 					SvxBorderLine aTopLine;
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 					// create single primitives per cell
584cdf0e10cSrcweir 					for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; aCellPos.mnRow++)
585cdf0e10cSrcweir                     {
586cdf0e10cSrcweir 		                for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; aCellPos.mnCol++)
587cdf0e10cSrcweir                         {
588cdf0e10cSrcweir 							xCurrentCell.set(dynamic_cast< sdr::table::Cell* >(xTable->getCellByPosition(aCellPos.mnCol, aCellPos.mnRow).get()));
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 							if(xCurrentCell.is() && !xCurrentCell->isMerged())
591cdf0e10cSrcweir 							{
592cdf0e10cSrcweir 								if(rTableLayouter.getCellArea(aCellPos, aCellArea))
593cdf0e10cSrcweir 								{
594cdf0e10cSrcweir 									// create cell transformation matrix
595cdf0e10cSrcweir 									basegfx::B2DHomMatrix aCellMatrix;
596cdf0e10cSrcweir 									aCellMatrix.set(0, 0, (double)aCellArea.getWidth());
597cdf0e10cSrcweir 									aCellMatrix.set(1, 1, (double)aCellArea.getHeight());
598cdf0e10cSrcweir 									aCellMatrix.set(0, 2, (double)aCellArea.getMinX() + aObjectRange.getMinX());
599cdf0e10cSrcweir 									aCellMatrix.set(1, 2, (double)aCellArea.getMinY() + aObjectRange.getMinY());
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 									// handle cell fillings and text
602cdf0e10cSrcweir 									const SfxItemSet& rCellItemSet = xCurrentCell->GetItemSet();
603cdf0e10cSrcweir 									const sal_uInt32 nTextIndex(nColCount * aCellPos.mnRow + aCellPos.mnCol);
604cdf0e10cSrcweir 									const SdrText* pSdrText = rTableObj.getText(nTextIndex);
605cdf0e10cSrcweir 									drawinglayer::attribute::SdrFillTextAttribute aAttribute;
606cdf0e10cSrcweir 
607cdf0e10cSrcweir 									if(pSdrText)
608cdf0e10cSrcweir 									{
609cdf0e10cSrcweir 										// #i101508# take cell's local text frame distances into account
610cdf0e10cSrcweir 										const sal_Int32 nLeft(xCurrentCell->GetTextLeftDistance());
611cdf0e10cSrcweir 										const sal_Int32 nRight(xCurrentCell->GetTextRightDistance());
612cdf0e10cSrcweir 										const sal_Int32 nUpper(xCurrentCell->GetTextUpperDistance());
613cdf0e10cSrcweir 										const sal_Int32 nLower(xCurrentCell->GetTextLowerDistance());
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 										aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
616cdf0e10cSrcweir 											rCellItemSet,
617cdf0e10cSrcweir 											pSdrText,
618cdf0e10cSrcweir 											&nLeft,
619cdf0e10cSrcweir 											&nUpper,
620cdf0e10cSrcweir 											&nRight,
621cdf0e10cSrcweir 											&nLower);
622cdf0e10cSrcweir 									}
623cdf0e10cSrcweir 									else
624cdf0e10cSrcweir 									{
625cdf0e10cSrcweir 										aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
626cdf0e10cSrcweir 											rCellItemSet,
627cdf0e10cSrcweir 											pSdrText);
628cdf0e10cSrcweir 									}
629cdf0e10cSrcweir 
630cdf0e10cSrcweir                                     // always create cell primitives for BoundRect and HitTest
631cdf0e10cSrcweir 									{
632cdf0e10cSrcweir 										const drawinglayer::primitive2d::Primitive2DReference xCellReference(
633cdf0e10cSrcweir 											new drawinglayer::primitive2d::SdrCellPrimitive2D(
634cdf0e10cSrcweir 												aCellMatrix, aAttribute));
635cdf0e10cSrcweir 										xCellSequence[nCellInsert++] = xCellReference;
636cdf0e10cSrcweir 									}
637cdf0e10cSrcweir 
638cdf0e10cSrcweir 									// handle cell borders
639cdf0e10cSrcweir 									const sal_Int32 nX(bIsRTL ? nColCount - aCellPos.mnCol : aCellPos.mnCol);
640cdf0e10cSrcweir 									const sal_Int32 nY(aCellPos.mnRow);
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 									// get access values for X,Y at the cell's end
643cdf0e10cSrcweir 									const sal_Int32 nXSpan(xCurrentCell->getColumnSpan());
644cdf0e10cSrcweir 									const sal_Int32 nYSpan(xCurrentCell->getRowSpan());
645cdf0e10cSrcweir 									const sal_Int32 nXRight(bIsRTL ? nX - nXSpan : nX + nXSpan);
646cdf0e10cSrcweir 									const sal_Int32 nYBottom(nY + nYSpan);
647cdf0e10cSrcweir 
648cdf0e10cSrcweir 									// get basic lines
649cdf0e10cSrcweir 									impGetLine(aLeftLine, rTableLayouter, nX, nY, false, nColCount, nRowCount, bIsRTL);
650cdf0e10cSrcweir 									impGetLine(aBottomLine, rTableLayouter, nX, nYBottom, true, nColCount, nRowCount, bIsRTL);
651cdf0e10cSrcweir 									impGetLine(aRightLine, rTableLayouter, nXRight, nY, false, nColCount, nRowCount, bIsRTL);
652cdf0e10cSrcweir 									impGetLine(aTopLine, rTableLayouter, nX, nY, true, nColCount, nRowCount, bIsRTL);
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 									// create the primtive containing all data for one cell with borders
655cdf0e10cSrcweir 									xBorderSequence[nBorderInsert++] = drawinglayer::primitive2d::Primitive2DReference(
656cdf0e10cSrcweir 										new drawinglayer::primitive2d::SdrBorderlinePrimitive2D(
657cdf0e10cSrcweir 											aCellMatrix,
658cdf0e10cSrcweir 											aLeftLine,
659cdf0e10cSrcweir 											aBottomLine,
660cdf0e10cSrcweir 											aRightLine,
661cdf0e10cSrcweir 											aTopLine,
662cdf0e10cSrcweir 											bIsRTL ? nX == nColCount : 0 == nX,
663cdf0e10cSrcweir 											nRowCount == nYBottom,
664cdf0e10cSrcweir 											bIsRTL ? 0 == nXRight : nXRight == nColCount,
665cdf0e10cSrcweir 											0 == nY,
666cdf0e10cSrcweir 											true));
667cdf0e10cSrcweir 								}
668cdf0e10cSrcweir 							}
669cdf0e10cSrcweir                         }
670cdf0e10cSrcweir 					}
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 					// no empty references; reallocate sequences by used count
673cdf0e10cSrcweir 					xCellSequence.realloc(nCellInsert);
674cdf0e10cSrcweir 					xBorderSequence.realloc(nBorderInsert);
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 					// append to target. We want fillings and text first
677cdf0e10cSrcweir 					xRetval = xCellSequence;
678cdf0e10cSrcweir 					drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xBorderSequence);
679cdf0e10cSrcweir 				}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 				if(xRetval.hasElements())
682cdf0e10cSrcweir 				{
683cdf0e10cSrcweir 					// check and create evtl. shadow for created content
684cdf0e10cSrcweir 	           		const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet();
685cdf0e10cSrcweir 					const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute(
686cdf0e10cSrcweir 						drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet));
687cdf0e10cSrcweir 
688cdf0e10cSrcweir 					if(!aNewShadowAttribute.isDefault())
689cdf0e10cSrcweir 					{
690cdf0e10cSrcweir 						xRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(xRetval, aNewShadowAttribute);
691cdf0e10cSrcweir 					}
692cdf0e10cSrcweir 				}
693cdf0e10cSrcweir 
694cdf0e10cSrcweir 				return xRetval;
695cdf0e10cSrcweir 			}
696cdf0e10cSrcweir 			else
697cdf0e10cSrcweir 			{
698cdf0e10cSrcweir 				// take unrotated snap rect (direct model data) for position and size
699cdf0e10cSrcweir 				const Rectangle& rRectangle = rTableObj.GetGeoRect();
700cdf0e10cSrcweir 				const basegfx::B2DRange aObjectRange(
701cdf0e10cSrcweir 					rRectangle.Left(), rRectangle.Top(),
702cdf0e10cSrcweir 					rRectangle.Right(), rRectangle.Bottom());
703cdf0e10cSrcweir 
704cdf0e10cSrcweir 				// create object matrix
705cdf0e10cSrcweir 				const GeoStat& rGeoStat(rTableObj.GetGeoStat());
706cdf0e10cSrcweir 				const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
707cdf0e10cSrcweir 				const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
708cdf0e10cSrcweir 				const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
709cdf0e10cSrcweir 					aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
710cdf0e10cSrcweir 					aObjectRange.getMinX(), aObjectRange.getMinY()));
711cdf0e10cSrcweir 
712cdf0e10cSrcweir 				// credate an invisible outline for the cases where no visible content exists
713cdf0e10cSrcweir 	            const drawinglayer::primitive2d::Primitive2DReference xReference(
714cdf0e10cSrcweir 					drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
715cdf0e10cSrcweir 						false,
716cdf0e10cSrcweir 						aObjectMatrix));
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 				return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
719cdf0e10cSrcweir 			}
720cdf0e10cSrcweir         }
721cdf0e10cSrcweir 
ViewContactOfTableObj(::sdr::table::SdrTableObj & rTableObj)722cdf0e10cSrcweir 		ViewContactOfTableObj::ViewContactOfTableObj(::sdr::table::SdrTableObj& rTableObj)
723cdf0e10cSrcweir 		:	ViewContactOfSdrObj(rTableObj)
724cdf0e10cSrcweir 		{
725cdf0e10cSrcweir 		}
726cdf0e10cSrcweir 
~ViewContactOfTableObj()727cdf0e10cSrcweir 		ViewContactOfTableObj::~ViewContactOfTableObj()
728cdf0e10cSrcweir 		{
729cdf0e10cSrcweir 		}
730cdf0e10cSrcweir 	} // end of namespace contact
731cdf0e10cSrcweir } // end of namespace sdr
732cdf0e10cSrcweir 
733cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
734cdf0e10cSrcweir // eof
735