Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / svx / source / table / viewcontactoftableobj.cxx
blobc4b3e7b8169baac3c907c2c90e770ac8a45be492
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
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>
50 #include "cell.hxx"
51 #include "tablelayouter.hxx"
53 //////////////////////////////////////////////////////////////////////////////
55 using editeng::SvxBorderLine;
56 using namespace com::sun::star;
58 //////////////////////////////////////////////////////////////////////////////
60 namespace drawinglayer
62 namespace primitive2d
64 class SdrCellPrimitive2D : public BufferedDecompositionPrimitive2D
66 private:
67 basegfx::B2DHomMatrix maTransform;
68 attribute::SdrFillTextAttribute maSdrFTAttribute;
70 protected:
71 // local decomposition.
72 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
74 public:
75 SdrCellPrimitive2D(
76 const basegfx::B2DHomMatrix& rTransform,
77 const attribute::SdrFillTextAttribute& rSdrFTAttribute)
78 : BufferedDecompositionPrimitive2D(),
79 maTransform(rTransform),
80 maSdrFTAttribute(rSdrFTAttribute)
84 // data access
85 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
86 const attribute::SdrFillTextAttribute& getSdrFTAttribute() const { return maSdrFTAttribute; }
88 // compare operator
89 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
91 // provide unique ID
92 DeclPrimitrive2DIDBlock()
95 Primitive2DSequence SdrCellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
97 // prepare unit polygon
98 Primitive2DSequence aRetval;
99 const basegfx::B2DPolyPolygon aUnitPolyPolygon(basegfx::tools::createUnitPolygon());
101 // add fill
102 if(!getSdrFTAttribute().getFill().isDefault())
104 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
105 createPolyPolygonFillPrimitive(
106 aUnitPolyPolygon,
107 getTransform(),
108 getSdrFTAttribute().getFill(),
109 getSdrFTAttribute().getFillFloatTransGradient()));
111 else
113 // if no fill create one for HitTest and BoundRect fallback
114 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
115 createHiddenGeometryPrimitives2D(
116 true,
117 aUnitPolyPolygon,
118 getTransform()));
121 // add text
122 if(!getSdrFTAttribute().getText().isDefault())
124 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
125 createTextPrimitive(
126 aUnitPolyPolygon,
127 getTransform(),
128 getSdrFTAttribute().getText(),
129 attribute::SdrLineAttribute(),
130 true,
131 false,
132 false));
135 return aRetval;
138 bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
140 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
142 const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive;
144 return (getTransform() == rCompare.getTransform()
145 && getSdrFTAttribute() == rCompare.getSdrFTAttribute());
148 return false;
151 // provide unique ID
152 ImplPrimitrive2DIDBlock(SdrCellPrimitive2D, PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D)
154 } // end of namespace primitive2d
155 } // end of namespace drawinglayer
157 //////////////////////////////////////////////////////////////////////////////
159 namespace drawinglayer
161 namespace primitive2d
163 class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D
165 private:
166 basegfx::B2DHomMatrix maTransform;
167 SvxBorderLine maLeftLine;
168 SvxBorderLine maBottomLine;
169 SvxBorderLine maRightLine;
170 SvxBorderLine maTopLine;
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;
182 // bitfield
183 unsigned mbLeftIsOutside : 1;
184 unsigned mbBottomIsOutside : 1;
185 unsigned mbRightIsOutside : 1;
186 unsigned mbTopIsOutside : 1;
187 unsigned mbInTwips : 1;
189 protected:
190 // local decomposition.
191 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
193 public:
194 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 mbInTwips(bInTwips)
235 // data access
236 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
237 const SvxBorderLine& getLeftLine() const { return maLeftLine; }
238 const SvxBorderLine& getBottomLine() const { return maBottomLine; }
239 const SvxBorderLine& getRightLine() const { return maRightLine; }
240 const SvxBorderLine& getTopLine() const { return maTopLine; }
241 bool getLeftIsOutside() const { return mbLeftIsOutside; }
242 bool getBottomIsOutside() const { return mbBottomIsOutside; }
243 bool getRightIsOutside() const { return mbRightIsOutside; }
244 bool getTopIsOutside() const { return mbTopIsOutside; }
245 bool getInTwips() const { return mbInTwips; }
247 // compare operator
248 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
250 // provide unique ID
251 DeclPrimitrive2DIDBlock()
254 sal_uInt16 getBorderLineOutWidth(const SvxBorderLine& rLineA)
256 return (1 == rLineA.GetOutWidth() ? 0 : rLineA.GetOutWidth());
259 sal_uInt16 getBorderLineDistance(const SvxBorderLine& rLineA)
261 return (1 == rLineA.GetDistance() ? 0 : rLineA.GetDistance());
264 sal_uInt16 getBorderLineInWidth(const SvxBorderLine& rLineA)
266 return (1 == rLineA.GetInWidth() ? 0 : rLineA.GetInWidth());
269 sal_uInt16 getBorderLineWidth(const SvxBorderLine& rLineA)
271 return getBorderLineOutWidth(rLineA) + getBorderLineDistance(rLineA) + getBorderLineInWidth(rLineA);
274 double getExtend(const SvxBorderLine& rLineSide, const SvxBorderLine& rLineOpposite)
276 double nExtend = 0.0;
277 if(!rLineSide.isEmpty())
279 // reduce to inner edge of associated matching line
280 nExtend = -((getBorderLineWidth(rLineSide) / 2.0));
282 else
284 nExtend = ((getBorderLineWidth(rLineOpposite) / 2.0));
287 return nExtend;
290 double getChangedValue(sal_uInt16 nValue, bool bChangeToMM)
292 if(1 == nValue)
293 return 1.0;
295 if(bChangeToMM)
296 return nValue * (127.0 / 72.0);
298 return (double)nValue;
301 Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
303 Primitive2DSequence xRetval(4);
304 sal_uInt32 nInsert(0);
305 const double fTwipsToMM(getInTwips() ? (127.0 / 72.0) : 1.0);
307 if(!getLeftLine().isEmpty())
309 // create left line from top to bottom
310 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
311 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(0.0, 1.0));
313 if(!aStart.equal(aEnd))
315 const double fExtendIS(getExtend(getTopLine(), maTopFromLLine));
316 const double fExtendIE(getExtend(getBottomLine(), maBottomFromLLine));
317 const double fExtendOS(getExtend(maTopFromLLine, getTopLine()));
318 const double fExtendOE(getExtend(maBottomFromLLine, getBottomLine()));
320 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
321 aStart,
322 aEnd,
323 getChangedValue(getLeftLine().GetOutWidth(), getInTwips()),
324 getChangedValue(getLeftLine().GetDistance(), getInTwips()),
325 getChangedValue(getLeftLine().GetInWidth(), getInTwips()),
326 fExtendIS * fTwipsToMM,
327 fExtendIE * fTwipsToMM,
328 fExtendOS * fTwipsToMM,
329 fExtendOE * fTwipsToMM,
330 getLeftLine().GetColorOut(true).getBColor(),
331 getLeftLine().GetColorIn(true).getBColor(),
332 getLeftLine().GetColorGap().getBColor(),
333 getLeftLine().HasGapColor(),
334 getLeftLine().GetBorderLineStyle()));
338 if(!getBottomLine().isEmpty() && getBottomIsOutside())
340 // create bottom line from left to right
341 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 1.0));
342 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
344 if(!aStart.equal(aEnd))
346 const double fExtendIS(getExtend(getLeftLine(), maLeftFromBLine ));
347 const double fExtendIE(getExtend(getRightLine(), maRightFromBLine));
348 const double fExtendOS(getExtend(maLeftFromBLine, getLeftLine()));
349 const double fExtendOE(getExtend(maRightFromBLine, getRightLine()));
351 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
352 aStart,
353 aEnd,
354 getChangedValue(getBottomLine().GetOutWidth(), getInTwips()),
355 getChangedValue(getBottomLine().GetDistance(), getInTwips()),
356 getChangedValue(getBottomLine().GetInWidth(), getInTwips()),
357 fExtendIS * fTwipsToMM,
358 fExtendIE * fTwipsToMM,
359 fExtendOS * fTwipsToMM,
360 fExtendOE * fTwipsToMM,
361 getBottomLine().GetColorOut(false).getBColor(),
362 getBottomLine().GetColorIn(false).getBColor(),
363 getBottomLine().GetColorGap().getBColor(),
364 getBottomLine().HasGapColor(),
365 getBottomLine().GetBorderLineStyle()));
369 if(!getRightLine().isEmpty() && getRightIsOutside())
371 // create right line from top to bottom
372 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(1.0, 0.0));
373 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
375 if(!aStart.equal(aEnd))
377 const double fExtendIS(getExtend(getTopLine(), maTopFromRLine));
378 const double fExtendIE(getExtend(getBottomLine(), maBottomFromRLine));
379 const double fExtendOS(getExtend(maTopFromRLine, getTopLine()));
380 const double fExtendOE(getExtend(maBottomFromRLine, getBottomLine()));
382 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
383 aStart,
384 aEnd,
385 getChangedValue(getRightLine().GetOutWidth(), getInTwips()),
386 getChangedValue(getRightLine().GetDistance(), getInTwips()),
387 getChangedValue(getRightLine().GetInWidth(), getInTwips()),
388 fExtendOS * fTwipsToMM,
389 fExtendOE * fTwipsToMM,
390 fExtendIS * fTwipsToMM,
391 fExtendIE * fTwipsToMM,
392 getRightLine().GetColorOut(true).getBColor(),
393 getRightLine().GetColorIn(true).getBColor(),
394 getRightLine().GetColorGap().getBColor(),
395 getRightLine().HasGapColor(),
396 getRightLine().GetBorderLineStyle()));
400 if(!getTopLine().isEmpty())
402 // create top line from left to right
403 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
404 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 0.0));
406 if(!aStart.equal(aEnd))
408 const double fExtendIS(getExtend(getLeftLine(), maLeftFromTLine));
409 const double fExtendIE(getExtend(getRightLine(), maRightFromTLine));
410 const double fExtendOS(getExtend(maLeftFromTLine, getLeftLine()));
411 const double fExtendOE(getExtend(maRightFromTLine, getRightLine()));
413 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
414 aStart,
415 aEnd,
416 getChangedValue(getTopLine().GetOutWidth(), getInTwips()),
417 getChangedValue(getTopLine().GetDistance(), getInTwips()),
418 getChangedValue(getTopLine().GetInWidth(), getInTwips()),
419 fExtendOS * fTwipsToMM,
420 fExtendOE * fTwipsToMM,
421 fExtendIS * fTwipsToMM,
422 fExtendIE * fTwipsToMM,
423 getTopLine().GetColorOut(false).getBColor(),
424 getTopLine().GetColorIn(false).getBColor(),
425 getTopLine().GetColorGap().getBColor(),
426 getTopLine().HasGapColor(),
427 getTopLine().GetBorderLineStyle()));
431 xRetval.realloc(nInsert);
432 return xRetval;
435 bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
437 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
439 const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive;
441 return (getTransform() == rCompare.getTransform()
442 && getLeftLine() == rCompare.getLeftLine()
443 && getBottomLine() == rCompare.getBottomLine()
444 && getRightLine() == rCompare.getRightLine()
445 && getTopLine() == rCompare.getTopLine()
446 && maLeftFromTLine == rCompare.maLeftFromTLine
447 && maLeftFromBLine == rCompare.maLeftFromBLine
448 && maRightFromTLine == rCompare.maRightFromTLine
449 && maRightFromBLine == rCompare.maRightFromBLine
450 && maTopFromLLine == rCompare.maTopFromLLine
451 && maTopFromRLine == rCompare.maTopFromRLine
452 && maBottomFromLLine == rCompare.maBottomFromLLine
453 && maBottomFromRLine == rCompare.maBottomFromRLine
454 && getLeftIsOutside() == rCompare.getLeftIsOutside()
455 && getBottomIsOutside() == rCompare.getBottomIsOutside()
456 && getRightIsOutside() == rCompare.getRightIsOutside()
457 && getTopIsOutside() == rCompare.getTopIsOutside()
458 && getInTwips() == rCompare.getInTwips());
461 return false;
464 // provide unique ID
465 ImplPrimitrive2DIDBlock(SdrBorderlinePrimitive2D, PRIMITIVE2D_ID_SDRBORDERLINEPRIMITIVE2D)
467 } // end of namespace primitive2d
468 } // end of namespace drawinglayer
470 //////////////////////////////////////////////////////////////////////////////
472 namespace sdr
474 namespace contact
476 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)
478 if(nX >= 0 && nX <= nColCount && nY >= 0 && nY <= nRowCount)
480 const SvxBorderLine* pLine = rLayouter.getBorderLine(nX, nY, bHorizontal);
482 if(pLine)
484 // copy line content
485 aLine = *pLine;
487 // check for mirroring. This shall always be done when it is
488 // not a top- or rightmost line
489 bool bMirror(aLine.isDouble());
491 if(bMirror)
493 if(bHorizontal)
495 // mirror all bottom lines
496 bMirror = (0 != nY);
498 else
500 // mirror all left lines
501 bMirror = (bIsRTL ? 0 != nX : nX != nColCount);
505 if(bMirror)
507 aLine.SetMirrorWidths( );
510 return;
514 // no success, copy empty line
515 const SvxBorderLine aEmptyLine;
516 aLine = aEmptyLine;
519 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfTableObj::createViewIndependentPrimitive2DSequence() const
521 const sdr::table::SdrTableObj& rTableObj = GetTableObj();
522 const uno::Reference< com::sun::star::table::XTable > xTable = rTableObj.getTable();
524 if(xTable.is())
526 // create primitive representation for table
527 drawinglayer::primitive2d::Primitive2DSequence xRetval;
528 const sal_Int32 nRowCount(xTable->getRowCount());
529 const sal_Int32 nColCount(xTable->getColumnCount());
530 const sal_Int32 nAllCount(nRowCount * nColCount);
532 if(nAllCount)
534 const sdr::table::TableLayouter& rTableLayouter = rTableObj.getTableLayouter();
535 const bool bIsRTL(com::sun::star::text::WritingMode_RL_TB == rTableObj.GetWritingMode());
536 sdr::table::CellPos aCellPos;
537 sdr::table::CellRef xCurrentCell;
538 basegfx::B2IRectangle aCellArea;
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 const Rectangle& rObjectRectangle(rTableObj.GetGeoRect());
543 const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
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 drawinglayer::primitive2d::Primitive2DSequence xCellSequence(nAllCount);
548 drawinglayer::primitive2d::Primitive2DSequence xBorderSequence(nAllCount);
549 sal_uInt32 nCellInsert(0);
550 sal_uInt32 nBorderInsert(0);
552 // variables for border lines
553 SvxBorderLine aLeftLine;
554 SvxBorderLine aBottomLine;
555 SvxBorderLine aRightLine;
556 SvxBorderLine aTopLine;
558 SvxBorderLine aLeftFromTLine;
559 SvxBorderLine aLeftFromBLine;
560 SvxBorderLine aRightFromTLine;
561 SvxBorderLine aRightFromBLine;
562 SvxBorderLine aTopFromLLine;
563 SvxBorderLine aTopFromRLine;
564 SvxBorderLine aBottomFromLLine;
565 SvxBorderLine aBottomFromRLine;
567 // create single primitives per cell
568 for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; aCellPos.mnRow++)
570 for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; aCellPos.mnCol++)
572 xCurrentCell.set(dynamic_cast< sdr::table::Cell* >(xTable->getCellByPosition(aCellPos.mnCol, aCellPos.mnRow).get()));
574 if(xCurrentCell.is() && !xCurrentCell->isMerged())
576 if(rTableLayouter.getCellArea(aCellPos, aCellArea))
578 // create cell transformation matrix
579 basegfx::B2DHomMatrix aCellMatrix;
580 aCellMatrix.set(0, 0, (double)aCellArea.getWidth());
581 aCellMatrix.set(1, 1, (double)aCellArea.getHeight());
582 aCellMatrix.set(0, 2, (double)aCellArea.getMinX() + aObjectRange.getMinX());
583 aCellMatrix.set(1, 2, (double)aCellArea.getMinY() + aObjectRange.getMinY());
585 // handle cell fillings and text
586 const SfxItemSet& rCellItemSet = xCurrentCell->GetItemSet();
587 const sal_uInt32 nTextIndex(nColCount * aCellPos.mnRow + aCellPos.mnCol);
588 const SdrText* pSdrText = rTableObj.getText(nTextIndex);
589 drawinglayer::attribute::SdrFillTextAttribute aAttribute;
591 if(pSdrText)
593 // #i101508# take cell's local text frame distances into account
594 const sal_Int32 nLeft(xCurrentCell->GetTextLeftDistance());
595 const sal_Int32 nRight(xCurrentCell->GetTextRightDistance());
596 const sal_Int32 nUpper(xCurrentCell->GetTextUpperDistance());
597 const sal_Int32 nLower(xCurrentCell->GetTextLowerDistance());
599 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
600 rCellItemSet,
601 pSdrText,
602 &nLeft,
603 &nUpper,
604 &nRight,
605 &nLower);
607 else
609 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
610 rCellItemSet,
611 pSdrText);
614 // always create cell primitives for BoundRect and HitTest
616 const drawinglayer::primitive2d::Primitive2DReference xCellReference(
617 new drawinglayer::primitive2d::SdrCellPrimitive2D(
618 aCellMatrix, aAttribute));
619 xCellSequence[nCellInsert++] = xCellReference;
622 // handle cell borders
623 const sal_Int32 nX(bIsRTL ? nColCount - aCellPos.mnCol : aCellPos.mnCol);
624 const sal_Int32 nY(aCellPos.mnRow);
626 // get access values for X,Y at the cell's end
627 const sal_Int32 nXSpan(xCurrentCell->getColumnSpan());
628 const sal_Int32 nYSpan(xCurrentCell->getRowSpan());
629 const sal_Int32 nXRight(bIsRTL ? nX - nXSpan : nX + nXSpan);
630 const sal_Int32 nYBottom(nY + nYSpan);
632 // get basic lines
633 impGetLine(aLeftLine, rTableLayouter, nX, nY, false, nColCount, nRowCount, bIsRTL);
634 impGetLine(aBottomLine, rTableLayouter, nX, nYBottom, true, nColCount, nRowCount, bIsRTL);
635 impGetLine(aRightLine, rTableLayouter, nXRight, nY, false, nColCount, nRowCount, bIsRTL);
636 impGetLine(aTopLine, rTableLayouter, nX, nY, true, nColCount, nRowCount, bIsRTL);
638 // get the neighbor cells' borders
639 impGetLine(aLeftFromTLine, rTableLayouter, nX, nY - 1, false, nColCount, nRowCount, bIsRTL);
640 impGetLine(aLeftFromBLine, rTableLayouter, nX, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
641 impGetLine(aRightFromTLine, rTableLayouter, nXRight, nY - 1, false, nColCount, nRowCount, bIsRTL);
642 impGetLine(aRightFromBLine, rTableLayouter, nXRight, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
643 impGetLine(aTopFromLLine, rTableLayouter, nX - 1, nY, true, nColCount, nRowCount, bIsRTL);
644 impGetLine(aTopFromRLine, rTableLayouter, nXRight + 1, nY, true, nColCount, nRowCount, bIsRTL);
645 impGetLine(aBottomFromLLine, rTableLayouter, nX - 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
646 impGetLine(aBottomFromRLine, rTableLayouter, nXRight + 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
648 // create the primtive containing all data for one cell with borders
649 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 true));
674 // no empty references; reallocate sequences by used count
675 xCellSequence.realloc(nCellInsert);
676 xBorderSequence.realloc(nBorderInsert);
678 // append to target. We want fillings and text first
679 xRetval = xCellSequence;
680 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xBorderSequence);
683 if(xRetval.hasElements())
685 // check and create evtl. shadow for created content
686 const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet();
687 const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute(
688 drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet));
690 if(!aNewShadowAttribute.isDefault())
692 xRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(xRetval, aNewShadowAttribute);
696 return xRetval;
698 else
700 // take unrotated snap rect (direct model data) for position and size
701 const Rectangle& rRectangle = rTableObj.GetGeoRect();
702 const basegfx::B2DRange aObjectRange(
703 rRectangle.Left(), rRectangle.Top(),
704 rRectangle.Right(), rRectangle.Bottom());
706 // create object matrix
707 const GeoStat& rGeoStat(rTableObj.GetGeoStat());
708 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
709 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 aObjectRange.getMinX(), aObjectRange.getMinY()));
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 aObjectMatrix));
720 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
724 ViewContactOfTableObj::ViewContactOfTableObj(::sdr::table::SdrTableObj& rTableObj)
725 : ViewContactOfSdrObj(rTableObj)
729 ViewContactOfTableObj::~ViewContactOfTableObj()
732 } // end of namespace contact
733 } // end of namespace sdr
735 //////////////////////////////////////////////////////////////////////////////
736 // eof
738 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */