Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / table / viewcontactoftableobj.cxx
blobbc87338bb96f717904f70b820d1ac989b2072013
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "viewcontactoftableobj.hxx"
22 #include <svx/svdotable.hxx>
23 #include <com/sun/star/table/XTable.hpp>
24 #include <basegfx/polygon/b2dpolygontools.hxx>
25 #include <basegfx/polygon/b2dpolygon.hxx>
26 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
27 #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
28 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
29 #include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
30 #include <basegfx/matrix/b2dhommatrix.hxx>
31 #include <svx/sdr/attribute/sdrtextattribute.hxx>
32 #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
33 #include <editeng/borderline.hxx>
34 #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
35 #include <sdr/attribute/sdrfilltextattribute.hxx>
36 #include <drawinglayer/attribute/sdrlineattribute.hxx>
37 #include <drawinglayer/attribute/sdrshadowattribute.hxx>
38 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
39 #include <basegfx/matrix/b2dhommatrixtools.hxx>
41 #include "cell.hxx"
42 #include "tablelayouter.hxx"
46 using editeng::SvxBorderLine;
47 using namespace com::sun::star;
51 namespace drawinglayer
53 namespace primitive2d
55 class SdrCellPrimitive2D : public BufferedDecompositionPrimitive2D
57 private:
58 basegfx::B2DHomMatrix maTransform;
59 attribute::SdrFillTextAttribute maSdrFTAttribute;
61 protected:
62 // local decomposition.
63 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
65 public:
66 SdrCellPrimitive2D(
67 const basegfx::B2DHomMatrix& rTransform,
68 const attribute::SdrFillTextAttribute& rSdrFTAttribute)
69 : BufferedDecompositionPrimitive2D(),
70 maTransform(rTransform),
71 maSdrFTAttribute(rSdrFTAttribute)
75 // data access
76 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
77 const attribute::SdrFillTextAttribute& getSdrFTAttribute() const { return maSdrFTAttribute; }
79 // compare operator
80 virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
82 // provide unique ID
83 DeclPrimitive2DIDBlock()
86 Primitive2DSequence SdrCellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
88 // prepare unit polygon
89 Primitive2DSequence aRetval;
90 const basegfx::B2DPolyPolygon aUnitPolyPolygon(basegfx::tools::createUnitPolygon());
92 // add fill
93 if(!getSdrFTAttribute().getFill().isDefault())
95 basegfx::B2DPolyPolygon aTransformed(aUnitPolyPolygon);
97 aTransformed.transform(getTransform());
98 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
99 createPolyPolygonFillPrimitive(
100 aTransformed,
101 getSdrFTAttribute().getFill(),
102 getSdrFTAttribute().getFillFloatTransGradient()));
104 else
106 // if no fill create one for HitTest and BoundRect fallback
107 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
108 createHiddenGeometryPrimitives2D(
109 true,
110 aUnitPolyPolygon,
111 getTransform()));
114 // add text
115 if(!getSdrFTAttribute().getText().isDefault())
117 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
118 createTextPrimitive(
119 aUnitPolyPolygon,
120 getTransform(),
121 getSdrFTAttribute().getText(),
122 attribute::SdrLineAttribute(),
123 true,
124 false,
125 false));
128 return aRetval;
131 bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
133 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
135 const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive;
137 return (getTransform() == rCompare.getTransform()
138 && getSdrFTAttribute() == rCompare.getSdrFTAttribute());
141 return false;
144 // provide unique ID
145 ImplPrimitive2DIDBlock(SdrCellPrimitive2D, PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D)
147 } // end of namespace primitive2d
148 } // end of namespace drawinglayer
152 namespace drawinglayer
154 namespace primitive2d
156 class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D
158 private:
159 basegfx::B2DHomMatrix maTransform;
160 SvxBorderLine maLeftLine;
161 SvxBorderLine maBottomLine;
162 SvxBorderLine maRightLine;
163 SvxBorderLine maTopLine;
165 // Neighbor cells' borders
166 SvxBorderLine maLeftFromTLine;
167 SvxBorderLine maLeftFromBLine;
168 SvxBorderLine maRightFromTLine;
169 SvxBorderLine maRightFromBLine;
170 SvxBorderLine maTopFromLLine;
171 SvxBorderLine maTopFromRLine;
172 SvxBorderLine maBottomFromLLine;
173 SvxBorderLine maBottomFromRLine;
175 // bitfield
176 bool mbLeftIsOutside : 1;
177 bool mbBottomIsOutside : 1;
178 bool mbRightIsOutside : 1;
179 bool mbTopIsOutside : 1;
180 bool mbInTwips : 1;
182 protected:
183 // local decomposition.
184 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
186 public:
187 SdrBorderlinePrimitive2D(
188 const basegfx::B2DHomMatrix& rTransform,
189 const SvxBorderLine& rLeftLine,
190 const SvxBorderLine& rBottomLine,
191 const SvxBorderLine& rRightLine,
192 const SvxBorderLine& rTopLine,
193 const SvxBorderLine& rLeftFromTLine,
194 const SvxBorderLine& rLeftFromBLine,
195 const SvxBorderLine& rRightFromTLine,
196 const SvxBorderLine& rRightFromBLine,
197 const SvxBorderLine& rTopFromLLine,
198 const SvxBorderLine& rTopFromRLine,
199 const SvxBorderLine& rBottomFromLLine,
200 const SvxBorderLine& rBottomFromRLine,
201 bool bLeftIsOutside,
202 bool bBottomIsOutside,
203 bool bRightIsOutside,
204 bool bTopIsOutside,
205 bool bInTwips)
206 : BufferedDecompositionPrimitive2D(),
207 maTransform(rTransform),
208 maLeftLine(rLeftLine),
209 maBottomLine(rBottomLine),
210 maRightLine(rRightLine),
211 maTopLine(rTopLine),
212 maLeftFromTLine(rLeftFromTLine),
213 maLeftFromBLine(rLeftFromBLine),
214 maRightFromTLine(rRightFromTLine),
215 maRightFromBLine(rRightFromBLine),
216 maTopFromLLine(rTopFromLLine),
217 maTopFromRLine(rTopFromRLine),
218 maBottomFromLLine(rBottomFromLLine),
219 maBottomFromRLine(rBottomFromRLine),
220 mbLeftIsOutside(bLeftIsOutside),
221 mbBottomIsOutside(bBottomIsOutside),
222 mbRightIsOutside(bRightIsOutside),
223 mbTopIsOutside(bTopIsOutside),
224 mbInTwips(bInTwips)
228 // data access
229 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
230 const SvxBorderLine& getLeftLine() const { return maLeftLine; }
231 const SvxBorderLine& getBottomLine() const { return maBottomLine; }
232 const SvxBorderLine& getRightLine() const { return maRightLine; }
233 const SvxBorderLine& getTopLine() const { return maTopLine; }
234 bool getLeftIsOutside() const { return mbLeftIsOutside; }
235 bool getBottomIsOutside() const { return mbBottomIsOutside; }
236 bool getRightIsOutside() const { return mbRightIsOutside; }
237 bool getTopIsOutside() const { return mbTopIsOutside; }
238 bool getInTwips() const { return mbInTwips; }
240 // compare operator
241 virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
243 // provide unique ID
244 DeclPrimitive2DIDBlock()
247 sal_uInt16 getBorderLineOutWidth(const SvxBorderLine& rLineA)
249 return (1 == rLineA.GetOutWidth() ? 0 : rLineA.GetOutWidth());
252 sal_uInt16 getBorderLineDistance(const SvxBorderLine& rLineA)
254 return (1 == rLineA.GetDistance() ? 0 : rLineA.GetDistance());
257 sal_uInt16 getBorderLineInWidth(const SvxBorderLine& rLineA)
259 return (1 == rLineA.GetInWidth() ? 0 : rLineA.GetInWidth());
262 sal_uInt16 getBorderLineWidth(const SvxBorderLine& rLineA)
264 return getBorderLineOutWidth(rLineA) + getBorderLineDistance(rLineA) + getBorderLineInWidth(rLineA);
267 double getExtend(const SvxBorderLine& rLineSide, const SvxBorderLine& rLineOpposite)
269 double nExtend = 0.0;
270 if(!rLineSide.isEmpty())
272 // reduce to inner edge of associated matching line
273 nExtend = -((getBorderLineWidth(rLineSide) / 2.0));
275 else
277 nExtend = ((getBorderLineWidth(rLineOpposite) / 2.0));
280 return nExtend;
283 double getChangedValue(sal_uInt16 nValue, bool bChangeToMM)
285 if(1 == nValue)
286 return 1.0;
288 if(bChangeToMM)
289 return nValue * (127.0 / 72.0);
291 return (double)nValue;
294 Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
296 Primitive2DSequence xRetval(4);
297 sal_uInt32 nInsert(0);
298 const double fTwipsToMM(getInTwips() ? (127.0 / 72.0) : 1.0);
300 if(!getLeftLine().isEmpty())
302 // create left line from top to bottom
303 basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
304 basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(0.0, 1.0));
306 // Move the left border to the left.
307 double fOffset = getChangedValue(getLeftLine().GetDistance(), getInTwips());
308 aStart += basegfx::B2DPoint(-fOffset,-fOffset);
309 aEnd += basegfx::B2DPoint(-fOffset,fOffset);
311 if(!aStart.equal(aEnd))
313 const double fExtendIS(getExtend(getTopLine(), maTopFromLLine));
314 const double fExtendIE(getExtend(getBottomLine(), maBottomFromLLine));
315 const double fExtendOS(getExtend(maTopFromLLine, getTopLine()));
316 const double fExtendOE(getExtend(maBottomFromLLine, getBottomLine()));
318 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
319 aStart,
320 aEnd,
321 getChangedValue(getLeftLine().GetOutWidth(), getInTwips()),
322 getChangedValue(getLeftLine().GetDistance(), getInTwips()),
323 getChangedValue(getLeftLine().GetInWidth(), getInTwips()),
324 fExtendIS * fTwipsToMM,
325 fExtendIE * fTwipsToMM,
326 fExtendOS * fTwipsToMM,
327 fExtendOE * fTwipsToMM,
328 getLeftLine().GetColorOut(true).getBColor(),
329 getLeftLine().GetColorIn(true).getBColor(),
330 getLeftLine().GetColorGap().getBColor(),
331 getLeftLine().HasGapColor(),
332 getLeftLine().GetBorderLineStyle()));
336 if(!getBottomLine().isEmpty() && getBottomIsOutside())
338 // create bottom line from left to right
339 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 1.0));
340 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
342 if(!aStart.equal(aEnd))
344 const double fExtendIS(getExtend(getLeftLine(), maLeftFromBLine ));
345 const double fExtendIE(getExtend(getRightLine(), maRightFromBLine));
346 const double fExtendOS(getExtend(maLeftFromBLine, getLeftLine()));
347 const double fExtendOE(getExtend(maRightFromBLine, getRightLine()));
349 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
350 aStart,
351 aEnd,
352 getChangedValue(getBottomLine().GetOutWidth(), getInTwips()),
353 getChangedValue(getBottomLine().GetDistance(), getInTwips()),
354 getChangedValue(getBottomLine().GetInWidth(), getInTwips()),
355 fExtendIS * fTwipsToMM,
356 fExtendIE * fTwipsToMM,
357 fExtendOS * fTwipsToMM,
358 fExtendOE * fTwipsToMM,
359 getBottomLine().GetColorOut(false).getBColor(),
360 getBottomLine().GetColorIn(false).getBColor(),
361 getBottomLine().GetColorGap().getBColor(),
362 getBottomLine().HasGapColor(),
363 getBottomLine().GetBorderLineStyle()));
367 if(!getRightLine().isEmpty())
369 // create right line from top to bottom
370 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(1.0, 0.0));
371 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
373 if(!aStart.equal(aEnd))
375 const double fExtendIS(getExtend(getTopLine(), maTopFromRLine));
376 const double fExtendIE(getExtend(getBottomLine(), maBottomFromRLine));
377 const double fExtendOS(getExtend(maTopFromRLine, getTopLine()));
378 const double fExtendOE(getExtend(maBottomFromRLine, getBottomLine()));
380 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
381 aStart,
382 aEnd,
383 getChangedValue(getRightLine().GetOutWidth(), getInTwips()),
384 getChangedValue(getRightLine().GetDistance(), getInTwips()),
385 getChangedValue(getRightLine().GetInWidth(), getInTwips()),
386 fExtendOS * fTwipsToMM,
387 fExtendOE * fTwipsToMM,
388 fExtendIS * fTwipsToMM,
389 fExtendIE * fTwipsToMM,
390 getRightLine().GetColorOut(true).getBColor(),
391 getRightLine().GetColorIn(true).getBColor(),
392 getRightLine().GetColorGap().getBColor(),
393 getRightLine().HasGapColor(),
394 getRightLine().GetBorderLineStyle()));
398 if(!getTopLine().isEmpty())
400 // create top line from left to right
401 basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
402 basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 0.0));
404 // Move the top border up a bit.
405 double fOffset = getChangedValue(getTopLine().GetDistance(), getInTwips());
406 aStart += basegfx::B2DPoint(-fOffset,-fOffset);
407 aEnd += basegfx::B2DPoint(fOffset,-fOffset);
409 if(!aStart.equal(aEnd))
411 const double fExtendIS(getExtend(getLeftLine(), maLeftFromTLine));
412 const double fExtendIE(getExtend(getRightLine(), maRightFromTLine));
413 const double fExtendOS(getExtend(maLeftFromTLine, getLeftLine()));
414 const double fExtendOE(getExtend(maRightFromTLine, getRightLine()));
416 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
417 aStart,
418 aEnd,
419 getChangedValue(getTopLine().GetOutWidth(), getInTwips()),
420 getChangedValue(getTopLine().GetDistance(), getInTwips()),
421 getChangedValue(getTopLine().GetInWidth(), getInTwips()),
422 fExtendOS * fTwipsToMM,
423 fExtendOE * fTwipsToMM,
424 fExtendIS * fTwipsToMM,
425 fExtendIE * fTwipsToMM,
426 getTopLine().GetColorOut(false).getBColor(),
427 getTopLine().GetColorIn(false).getBColor(),
428 getTopLine().GetColorGap().getBColor(),
429 getTopLine().HasGapColor(),
430 getTopLine().GetBorderLineStyle()));
434 xRetval.realloc(nInsert);
435 return xRetval;
438 bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
440 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
442 const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive;
444 return (getTransform() == rCompare.getTransform()
445 && getLeftLine() == rCompare.getLeftLine()
446 && getBottomLine() == rCompare.getBottomLine()
447 && getRightLine() == rCompare.getRightLine()
448 && getTopLine() == rCompare.getTopLine()
449 && maLeftFromTLine == rCompare.maLeftFromTLine
450 && maLeftFromBLine == rCompare.maLeftFromBLine
451 && maRightFromTLine == rCompare.maRightFromTLine
452 && maRightFromBLine == rCompare.maRightFromBLine
453 && maTopFromLLine == rCompare.maTopFromLLine
454 && maTopFromRLine == rCompare.maTopFromRLine
455 && maBottomFromLLine == rCompare.maBottomFromLLine
456 && maBottomFromRLine == rCompare.maBottomFromRLine
457 && getLeftIsOutside() == rCompare.getLeftIsOutside()
458 && getBottomIsOutside() == rCompare.getBottomIsOutside()
459 && getRightIsOutside() == rCompare.getRightIsOutside()
460 && getTopIsOutside() == rCompare.getTopIsOutside()
461 && getInTwips() == rCompare.getInTwips());
464 return false;
467 // provide unique ID
468 ImplPrimitive2DIDBlock(SdrBorderlinePrimitive2D, PRIMITIVE2D_ID_SDRBORDERLINEPRIMITIVE2D)
470 } // end of namespace primitive2d
471 } // end of namespace drawinglayer
475 namespace sdr
477 namespace contact
479 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)
481 if(nX >= 0 && nX <= nColCount && nY >= 0 && nY <= nRowCount)
483 const SvxBorderLine* pLine = rLayouter.getBorderLine(nX, nY, bHorizontal);
485 if(pLine)
487 // copy line content
488 aLine = *pLine;
490 // check for mirroring. This shall always be done when it is
491 // not a top- or rightmost line
492 bool bMirror(aLine.isDouble());
494 if(bMirror)
496 if(bHorizontal)
498 // mirror all bottom lines
499 bMirror = (0 != nY);
501 else
503 // mirror all left lines
504 bMirror = (bIsRTL ? 0 != nX : nX != nColCount);
508 if(bMirror)
510 aLine.SetMirrorWidths( );
513 return;
517 // no success, copy empty line
518 const SvxBorderLine aEmptyLine;
519 aLine = aEmptyLine;
522 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfTableObj::createViewIndependentPrimitive2DSequence() const
524 const sdr::table::SdrTableObj& rTableObj = GetTableObj();
525 const uno::Reference< com::sun::star::table::XTable > xTable = rTableObj.getTable();
527 if(xTable.is())
529 // create primitive representation for table
530 drawinglayer::primitive2d::Primitive2DSequence xRetval;
531 const sal_Int32 nRowCount(xTable->getRowCount());
532 const sal_Int32 nColCount(xTable->getColumnCount());
533 const sal_Int32 nAllCount(nRowCount * nColCount);
535 if(nAllCount)
537 const sdr::table::TableLayouter& rTableLayouter = rTableObj.getTableLayouter();
538 const bool bIsRTL(com::sun::star::text::WritingMode_RL_TB == rTableObj.GetWritingMode());
539 sdr::table::CellPos aCellPos;
540 sdr::table::CellRef xCurrentCell;
541 basegfx::B2IRectangle aCellArea;
543 // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
544 // GetGeoRect() to not trigger any calculations. It's the unrotated geometry.
545 const Rectangle& rObjectRectangle(rTableObj.GetGeoRect());
546 const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
548 // for each cell we need potentially a cell primitive and a border primitive
549 // (e.g. single cell). Prepare sequences and input counters
550 drawinglayer::primitive2d::Primitive2DSequence xCellSequence(nAllCount);
551 drawinglayer::primitive2d::Primitive2DSequence xBorderSequence(nAllCount);
552 sal_uInt32 nCellInsert(0);
553 sal_uInt32 nBorderInsert(0);
555 // variables for border lines
556 SvxBorderLine aLeftLine;
557 SvxBorderLine aBottomLine;
558 SvxBorderLine aRightLine;
559 SvxBorderLine aTopLine;
561 SvxBorderLine aLeftFromTLine;
562 SvxBorderLine aLeftFromBLine;
563 SvxBorderLine aRightFromTLine;
564 SvxBorderLine aRightFromBLine;
565 SvxBorderLine aTopFromLLine;
566 SvxBorderLine aTopFromRLine;
567 SvxBorderLine aBottomFromLLine;
568 SvxBorderLine aBottomFromRLine;
570 // create single primitives per cell
571 for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; aCellPos.mnRow++)
573 for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; aCellPos.mnCol++)
575 xCurrentCell.set(dynamic_cast< sdr::table::Cell* >(xTable->getCellByPosition(aCellPos.mnCol, aCellPos.mnRow).get()));
577 if(xCurrentCell.is() && !xCurrentCell->isMerged())
579 if(rTableLayouter.getCellArea(aCellPos, aCellArea))
581 // create cell transformation matrix
582 basegfx::B2DHomMatrix aCellMatrix;
583 aCellMatrix.set(0, 0, (double)aCellArea.getWidth());
584 aCellMatrix.set(1, 1, (double)aCellArea.getHeight());
585 aCellMatrix.set(0, 2, (double)aCellArea.getMinX() + aObjectRange.getMinX());
586 aCellMatrix.set(1, 2, (double)aCellArea.getMinY() + aObjectRange.getMinY());
588 // handle cell fillings and text
589 const SfxItemSet& rCellItemSet = xCurrentCell->GetItemSet();
590 const sal_uInt32 nTextIndex(nColCount * aCellPos.mnRow + aCellPos.mnCol);
591 const SdrText* pSdrText = rTableObj.getText(nTextIndex);
592 drawinglayer::attribute::SdrFillTextAttribute aAttribute;
594 if(pSdrText)
596 // #i101508# take cell's local text frame distances into account
597 const sal_Int32 nLeft(xCurrentCell->GetTextLeftDistance());
598 const sal_Int32 nRight(xCurrentCell->GetTextRightDistance());
599 const sal_Int32 nUpper(xCurrentCell->GetTextUpperDistance());
600 const sal_Int32 nLower(xCurrentCell->GetTextLowerDistance());
602 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
603 rCellItemSet,
604 pSdrText,
605 &nLeft,
606 &nUpper,
607 &nRight,
608 &nLower);
610 else
612 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
613 rCellItemSet,
614 pSdrText);
617 // always create cell primitives for BoundRect and HitTest
619 const drawinglayer::primitive2d::Primitive2DReference xCellReference(
620 new drawinglayer::primitive2d::SdrCellPrimitive2D(
621 aCellMatrix, aAttribute));
622 xCellSequence[nCellInsert++] = xCellReference;
625 // handle cell borders
626 const sal_Int32 nX(bIsRTL ? nColCount - aCellPos.mnCol : aCellPos.mnCol);
627 const sal_Int32 nY(aCellPos.mnRow);
629 // get access values for X,Y at the cell's end
630 const sal_Int32 nXSpan(xCurrentCell->getColumnSpan());
631 const sal_Int32 nYSpan(xCurrentCell->getRowSpan());
632 const sal_Int32 nXRight(bIsRTL ? nX - nXSpan : nX + nXSpan);
633 const sal_Int32 nYBottom(nY + nYSpan);
635 // get basic lines
636 impGetLine(aLeftLine, rTableLayouter, nX, nY, false, nColCount, nRowCount, bIsRTL);
637 //To resolve the bug fdo#59117
638 //In RTL table as BottomLine & TopLine are drawn from Left Side to Right, nX should be nX-1
639 impGetLine(aBottomLine, rTableLayouter, bIsRTL?nX-1:nX, nYBottom, true, nColCount, nRowCount, bIsRTL);
640 impGetLine(aRightLine, rTableLayouter, nXRight, nY, false, nColCount, nRowCount, bIsRTL);
641 impGetLine(aTopLine, rTableLayouter, bIsRTL?nX-1:nX, nY, true, nColCount, nRowCount, bIsRTL);
643 // get the neighbor cells' borders
644 impGetLine(aLeftFromTLine, rTableLayouter, nX, nY - 1, false, nColCount, nRowCount, bIsRTL);
645 impGetLine(aLeftFromBLine, rTableLayouter, nX, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
646 impGetLine(aRightFromTLine, rTableLayouter, nXRight, nY - 1, false, nColCount, nRowCount, bIsRTL);
647 impGetLine(aRightFromBLine, rTableLayouter, nXRight, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
648 impGetLine(aTopFromLLine, rTableLayouter, nX - 1, nY, true, nColCount, nRowCount, bIsRTL);
649 impGetLine(aTopFromRLine, rTableLayouter, nXRight + 1, nY, true, nColCount, nRowCount, bIsRTL);
650 impGetLine(aBottomFromLLine, rTableLayouter, nX - 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
651 impGetLine(aBottomFromRLine, rTableLayouter, nXRight + 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
653 // create the primtive containing all data for one cell with borders
654 xBorderSequence[nBorderInsert++] = drawinglayer::primitive2d::Primitive2DReference(
655 new drawinglayer::primitive2d::SdrBorderlinePrimitive2D(
656 aCellMatrix,
657 aLeftLine,
658 aBottomLine,
659 aRightLine,
660 aTopLine,
661 aLeftFromTLine,
662 aLeftFromBLine,
663 aRightFromTLine,
664 aRightFromBLine,
665 aTopFromLLine,
666 aTopFromRLine,
667 aBottomFromLLine,
668 aBottomFromRLine,
669 bIsRTL ? nX == nColCount : 0 == nX,
670 nRowCount == nYBottom,
671 bIsRTL ? 0 == nXRight : nXRight == nColCount,
672 0 == nY,
673 true));
679 // no empty references; reallocate sequences by used count
680 xCellSequence.realloc(nCellInsert);
681 xBorderSequence.realloc(nBorderInsert);
683 // append to target. We want fillings and text first
684 xRetval = xCellSequence;
685 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xBorderSequence);
688 if(xRetval.hasElements())
690 // check and create evtl. shadow for created content
691 const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet();
692 const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute(
693 drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet));
695 if(!aNewShadowAttribute.isDefault())
697 xRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(xRetval, aNewShadowAttribute);
701 return xRetval;
703 else
705 // take unrotated snap rect (direct model data) for position and size
706 const Rectangle& rRectangle = rTableObj.GetGeoRect();
707 const basegfx::B2DRange aObjectRange(
708 rRectangle.Left(), rRectangle.Top(),
709 rRectangle.Right(), rRectangle.Bottom());
711 // create object matrix
712 const GeoStat& rGeoStat(rTableObj.GetGeoStat());
713 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
714 const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
715 const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
716 aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
717 aObjectRange.getMinX(), aObjectRange.getMinY()));
719 // credate an invisible outline for the cases where no visible content exists
720 const drawinglayer::primitive2d::Primitive2DReference xReference(
721 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
722 false,
723 aObjectMatrix));
725 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
729 ViewContactOfTableObj::ViewContactOfTableObj(::sdr::table::SdrTableObj& rTableObj)
730 : ViewContactOfSdrObj(rTableObj)
734 ViewContactOfTableObj::~ViewContactOfTableObj()
737 } // end of namespace contact
738 } // end of namespace sdr
740 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */