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