fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / table / viewcontactoftableobj.cxx
blob683ec24f51657ea1391b8bbcecafcbe810024392
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 <svx/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"
44 //////////////////////////////////////////////////////////////////////////////
46 using editeng::SvxBorderLine;
47 using namespace com::sun::star;
49 //////////////////////////////////////////////////////////////////////////////
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;
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;
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 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
96 createPolyPolygonFillPrimitive(
97 aUnitPolyPolygon,
98 getTransform(),
99 getSdrFTAttribute().getFill(),
100 getSdrFTAttribute().getFillFloatTransGradient()));
102 else
104 // if no fill create one for HitTest and BoundRect fallback
105 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
106 createHiddenGeometryPrimitives2D(
107 true,
108 aUnitPolyPolygon,
109 getTransform()));
112 // add text
113 if(!getSdrFTAttribute().getText().isDefault())
115 appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
116 createTextPrimitive(
117 aUnitPolyPolygon,
118 getTransform(),
119 getSdrFTAttribute().getText(),
120 attribute::SdrLineAttribute(),
121 true,
122 false,
123 false));
126 return aRetval;
129 bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
131 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
133 const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive;
135 return (getTransform() == rCompare.getTransform()
136 && getSdrFTAttribute() == rCompare.getSdrFTAttribute());
139 return false;
142 // provide unique ID
143 ImplPrimitive2DIDBlock(SdrCellPrimitive2D, PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D)
145 } // end of namespace primitive2d
146 } // end of namespace drawinglayer
148 //////////////////////////////////////////////////////////////////////////////
150 namespace drawinglayer
152 namespace primitive2d
154 class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D
156 private:
157 basegfx::B2DHomMatrix maTransform;
158 SvxBorderLine maLeftLine;
159 SvxBorderLine maBottomLine;
160 SvxBorderLine maRightLine;
161 SvxBorderLine maTopLine;
163 // Neighbor cells' borders
164 SvxBorderLine maLeftFromTLine;
165 SvxBorderLine maLeftFromBLine;
166 SvxBorderLine maRightFromTLine;
167 SvxBorderLine maRightFromBLine;
168 SvxBorderLine maTopFromLLine;
169 SvxBorderLine maTopFromRLine;
170 SvxBorderLine maBottomFromLLine;
171 SvxBorderLine maBottomFromRLine;
173 // bitfield
174 unsigned mbLeftIsOutside : 1;
175 unsigned mbBottomIsOutside : 1;
176 unsigned mbRightIsOutside : 1;
177 unsigned mbTopIsOutside : 1;
178 unsigned mbInTwips : 1;
180 protected:
181 // local decomposition.
182 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
184 public:
185 SdrBorderlinePrimitive2D(
186 const basegfx::B2DHomMatrix& rTransform,
187 const SvxBorderLine& rLeftLine,
188 const SvxBorderLine& rBottomLine,
189 const SvxBorderLine& rRightLine,
190 const SvxBorderLine& rTopLine,
191 const SvxBorderLine& rLeftFromTLine,
192 const SvxBorderLine& rLeftFromBLine,
193 const SvxBorderLine& rRightFromTLine,
194 const SvxBorderLine& rRightFromBLine,
195 const SvxBorderLine& rTopFromLLine,
196 const SvxBorderLine& rTopFromRLine,
197 const SvxBorderLine& rBottomFromLLine,
198 const SvxBorderLine& rBottomFromRLine,
199 bool bLeftIsOutside,
200 bool bBottomIsOutside,
201 bool bRightIsOutside,
202 bool bTopIsOutside,
203 bool bInTwips)
204 : BufferedDecompositionPrimitive2D(),
205 maTransform(rTransform),
206 maLeftLine(rLeftLine),
207 maBottomLine(rBottomLine),
208 maRightLine(rRightLine),
209 maTopLine(rTopLine),
210 maLeftFromTLine(rLeftFromTLine),
211 maLeftFromBLine(rLeftFromBLine),
212 maRightFromTLine(rRightFromTLine),
213 maRightFromBLine(rRightFromBLine),
214 maTopFromLLine(rTopFromLLine),
215 maTopFromRLine(rTopFromRLine),
216 maBottomFromLLine(rBottomFromLLine),
217 maBottomFromRLine(rBottomFromRLine),
218 mbLeftIsOutside(bLeftIsOutside),
219 mbBottomIsOutside(bBottomIsOutside),
220 mbRightIsOutside(bRightIsOutside),
221 mbTopIsOutside(bTopIsOutside),
222 mbInTwips(bInTwips)
226 // data access
227 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
228 const SvxBorderLine& getLeftLine() const { return maLeftLine; }
229 const SvxBorderLine& getBottomLine() const { return maBottomLine; }
230 const SvxBorderLine& getRightLine() const { return maRightLine; }
231 const SvxBorderLine& getTopLine() const { return maTopLine; }
232 bool getLeftIsOutside() const { return mbLeftIsOutside; }
233 bool getBottomIsOutside() const { return mbBottomIsOutside; }
234 bool getRightIsOutside() const { return mbRightIsOutside; }
235 bool getTopIsOutside() const { return mbTopIsOutside; }
236 bool getInTwips() const { return mbInTwips; }
238 // compare operator
239 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
241 // provide unique ID
242 DeclPrimitive2DIDBlock()
245 sal_uInt16 getBorderLineOutWidth(const SvxBorderLine& rLineA)
247 return (1 == rLineA.GetOutWidth() ? 0 : rLineA.GetOutWidth());
250 sal_uInt16 getBorderLineDistance(const SvxBorderLine& rLineA)
252 return (1 == rLineA.GetDistance() ? 0 : rLineA.GetDistance());
255 sal_uInt16 getBorderLineInWidth(const SvxBorderLine& rLineA)
257 return (1 == rLineA.GetInWidth() ? 0 : rLineA.GetInWidth());
260 sal_uInt16 getBorderLineWidth(const SvxBorderLine& rLineA)
262 return getBorderLineOutWidth(rLineA) + getBorderLineDistance(rLineA) + getBorderLineInWidth(rLineA);
265 double getExtend(const SvxBorderLine& rLineSide, const SvxBorderLine& rLineOpposite)
267 double nExtend = 0.0;
268 if(!rLineSide.isEmpty())
270 // reduce to inner edge of associated matching line
271 nExtend = -((getBorderLineWidth(rLineSide) / 2.0));
273 else
275 nExtend = ((getBorderLineWidth(rLineOpposite) / 2.0));
278 return nExtend;
281 double getChangedValue(sal_uInt16 nValue, bool bChangeToMM)
283 if(1 == nValue)
284 return 1.0;
286 if(bChangeToMM)
287 return nValue * (127.0 / 72.0);
289 return (double)nValue;
292 Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
294 Primitive2DSequence xRetval(4);
295 sal_uInt32 nInsert(0);
296 const double fTwipsToMM(getInTwips() ? (127.0 / 72.0) : 1.0);
298 if(!getLeftLine().isEmpty())
300 // create left line from top to bottom
301 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
302 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(0.0, 1.0));
304 if(!aStart.equal(aEnd))
306 const double fExtendIS(getExtend(getTopLine(), maTopFromLLine));
307 const double fExtendIE(getExtend(getBottomLine(), maBottomFromLLine));
308 const double fExtendOS(getExtend(maTopFromLLine, getTopLine()));
309 const double fExtendOE(getExtend(maBottomFromLLine, getBottomLine()));
311 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
312 aStart,
313 aEnd,
314 getChangedValue(getLeftLine().GetOutWidth(), getInTwips()),
315 getChangedValue(getLeftLine().GetDistance(), getInTwips()),
316 getChangedValue(getLeftLine().GetInWidth(), getInTwips()),
317 fExtendIS * fTwipsToMM,
318 fExtendIE * fTwipsToMM,
319 fExtendOS * fTwipsToMM,
320 fExtendOE * fTwipsToMM,
321 getLeftLine().GetColorOut(true).getBColor(),
322 getLeftLine().GetColorIn(true).getBColor(),
323 getLeftLine().GetColorGap().getBColor(),
324 getLeftLine().HasGapColor(),
325 getLeftLine().GetBorderLineStyle()));
329 if(!getBottomLine().isEmpty() && getBottomIsOutside())
331 // create bottom line from left to right
332 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 1.0));
333 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
335 if(!aStart.equal(aEnd))
337 const double fExtendIS(getExtend(getLeftLine(), maLeftFromBLine ));
338 const double fExtendIE(getExtend(getRightLine(), maRightFromBLine));
339 const double fExtendOS(getExtend(maLeftFromBLine, getLeftLine()));
340 const double fExtendOE(getExtend(maRightFromBLine, getRightLine()));
342 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
343 aStart,
344 aEnd,
345 getChangedValue(getBottomLine().GetOutWidth(), getInTwips()),
346 getChangedValue(getBottomLine().GetDistance(), getInTwips()),
347 getChangedValue(getBottomLine().GetInWidth(), getInTwips()),
348 fExtendIS * fTwipsToMM,
349 fExtendIE * fTwipsToMM,
350 fExtendOS * fTwipsToMM,
351 fExtendOE * fTwipsToMM,
352 getBottomLine().GetColorOut(false).getBColor(),
353 getBottomLine().GetColorIn(false).getBColor(),
354 getBottomLine().GetColorGap().getBColor(),
355 getBottomLine().HasGapColor(),
356 getBottomLine().GetBorderLineStyle()));
360 if(!getRightLine().isEmpty())
362 // create right line from top to bottom
363 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(1.0, 0.0));
364 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
366 if(!aStart.equal(aEnd))
368 const double fExtendIS(getExtend(getTopLine(), maTopFromRLine));
369 const double fExtendIE(getExtend(getBottomLine(), maBottomFromRLine));
370 const double fExtendOS(getExtend(maTopFromRLine, getTopLine()));
371 const double fExtendOE(getExtend(maBottomFromRLine, getBottomLine()));
373 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
374 aStart,
375 aEnd,
376 getChangedValue(getRightLine().GetOutWidth(), getInTwips()),
377 getChangedValue(getRightLine().GetDistance(), getInTwips()),
378 getChangedValue(getRightLine().GetInWidth(), getInTwips()),
379 fExtendOS * fTwipsToMM,
380 fExtendOE * fTwipsToMM,
381 fExtendIS * fTwipsToMM,
382 fExtendIE * fTwipsToMM,
383 getRightLine().GetColorOut(true).getBColor(),
384 getRightLine().GetColorIn(true).getBColor(),
385 getRightLine().GetColorGap().getBColor(),
386 getRightLine().HasGapColor(),
387 getRightLine().GetBorderLineStyle()));
391 if(!getTopLine().isEmpty())
393 // create top line from left to right
394 const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
395 const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 0.0));
397 if(!aStart.equal(aEnd))
399 const double fExtendIS(getExtend(getLeftLine(), maLeftFromTLine));
400 const double fExtendIE(getExtend(getRightLine(), maRightFromTLine));
401 const double fExtendOS(getExtend(maLeftFromTLine, getLeftLine()));
402 const double fExtendOE(getExtend(maRightFromTLine, getRightLine()));
404 xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
405 aStart,
406 aEnd,
407 getChangedValue(getTopLine().GetOutWidth(), getInTwips()),
408 getChangedValue(getTopLine().GetDistance(), getInTwips()),
409 getChangedValue(getTopLine().GetInWidth(), getInTwips()),
410 fExtendOS * fTwipsToMM,
411 fExtendOE * fTwipsToMM,
412 fExtendIS * fTwipsToMM,
413 fExtendIE * fTwipsToMM,
414 getTopLine().GetColorOut(false).getBColor(),
415 getTopLine().GetColorIn(false).getBColor(),
416 getTopLine().GetColorGap().getBColor(),
417 getTopLine().HasGapColor(),
418 getTopLine().GetBorderLineStyle()));
422 xRetval.realloc(nInsert);
423 return xRetval;
426 bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
428 if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
430 const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive;
432 return (getTransform() == rCompare.getTransform()
433 && getLeftLine() == rCompare.getLeftLine()
434 && getBottomLine() == rCompare.getBottomLine()
435 && getRightLine() == rCompare.getRightLine()
436 && getTopLine() == rCompare.getTopLine()
437 && maLeftFromTLine == rCompare.maLeftFromTLine
438 && maLeftFromBLine == rCompare.maLeftFromBLine
439 && maRightFromTLine == rCompare.maRightFromTLine
440 && maRightFromBLine == rCompare.maRightFromBLine
441 && maTopFromLLine == rCompare.maTopFromLLine
442 && maTopFromRLine == rCompare.maTopFromRLine
443 && maBottomFromLLine == rCompare.maBottomFromLLine
444 && maBottomFromRLine == rCompare.maBottomFromRLine
445 && getLeftIsOutside() == rCompare.getLeftIsOutside()
446 && getBottomIsOutside() == rCompare.getBottomIsOutside()
447 && getRightIsOutside() == rCompare.getRightIsOutside()
448 && getTopIsOutside() == rCompare.getTopIsOutside()
449 && getInTwips() == rCompare.getInTwips());
452 return false;
455 // provide unique ID
456 ImplPrimitive2DIDBlock(SdrBorderlinePrimitive2D, PRIMITIVE2D_ID_SDRBORDERLINEPRIMITIVE2D)
458 } // end of namespace primitive2d
459 } // end of namespace drawinglayer
461 //////////////////////////////////////////////////////////////////////////////
463 namespace sdr
465 namespace contact
467 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)
469 if(nX >= 0 && nX <= nColCount && nY >= 0 && nY <= nRowCount)
471 const SvxBorderLine* pLine = rLayouter.getBorderLine(nX, nY, bHorizontal);
473 if(pLine)
475 // copy line content
476 aLine = *pLine;
478 // check for mirroring. This shall always be done when it is
479 // not a top- or rightmost line
480 bool bMirror(aLine.isDouble());
482 if(bMirror)
484 if(bHorizontal)
486 // mirror all bottom lines
487 bMirror = (0 != nY);
489 else
491 // mirror all left lines
492 bMirror = (bIsRTL ? 0 != nX : nX != nColCount);
496 if(bMirror)
498 aLine.SetMirrorWidths( );
501 return;
505 // no success, copy empty line
506 const SvxBorderLine aEmptyLine;
507 aLine = aEmptyLine;
510 drawinglayer::primitive2d::Primitive2DSequence ViewContactOfTableObj::createViewIndependentPrimitive2DSequence() const
512 const sdr::table::SdrTableObj& rTableObj = GetTableObj();
513 const uno::Reference< com::sun::star::table::XTable > xTable = rTableObj.getTable();
515 if(xTable.is())
517 // create primitive representation for table
518 drawinglayer::primitive2d::Primitive2DSequence xRetval;
519 const sal_Int32 nRowCount(xTable->getRowCount());
520 const sal_Int32 nColCount(xTable->getColumnCount());
521 const sal_Int32 nAllCount(nRowCount * nColCount);
523 if(nAllCount)
525 const sdr::table::TableLayouter& rTableLayouter = rTableObj.getTableLayouter();
526 const bool bIsRTL(com::sun::star::text::WritingMode_RL_TB == rTableObj.GetWritingMode());
527 sdr::table::CellPos aCellPos;
528 sdr::table::CellRef xCurrentCell;
529 basegfx::B2IRectangle aCellArea;
531 // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
532 // GetGeoRect() to not trigger any calculations. It's the unrotated geometry.
533 const Rectangle& rObjectRectangle(rTableObj.GetGeoRect());
534 const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
536 // for each cell we need potentially a cell primitive and a border primitive
537 // (e.g. single cell). Prepare sequences and input counters
538 drawinglayer::primitive2d::Primitive2DSequence xCellSequence(nAllCount);
539 drawinglayer::primitive2d::Primitive2DSequence xBorderSequence(nAllCount);
540 sal_uInt32 nCellInsert(0);
541 sal_uInt32 nBorderInsert(0);
543 // variables for border lines
544 SvxBorderLine aLeftLine;
545 SvxBorderLine aBottomLine;
546 SvxBorderLine aRightLine;
547 SvxBorderLine aTopLine;
549 SvxBorderLine aLeftFromTLine;
550 SvxBorderLine aLeftFromBLine;
551 SvxBorderLine aRightFromTLine;
552 SvxBorderLine aRightFromBLine;
553 SvxBorderLine aTopFromLLine;
554 SvxBorderLine aTopFromRLine;
555 SvxBorderLine aBottomFromLLine;
556 SvxBorderLine aBottomFromRLine;
558 // create single primitives per cell
559 for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; aCellPos.mnRow++)
561 for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; aCellPos.mnCol++)
563 xCurrentCell.set(dynamic_cast< sdr::table::Cell* >(xTable->getCellByPosition(aCellPos.mnCol, aCellPos.mnRow).get()));
565 if(xCurrentCell.is() && !xCurrentCell->isMerged())
567 if(rTableLayouter.getCellArea(aCellPos, aCellArea))
569 // create cell transformation matrix
570 basegfx::B2DHomMatrix aCellMatrix;
571 aCellMatrix.set(0, 0, (double)aCellArea.getWidth());
572 aCellMatrix.set(1, 1, (double)aCellArea.getHeight());
573 aCellMatrix.set(0, 2, (double)aCellArea.getMinX() + aObjectRange.getMinX());
574 aCellMatrix.set(1, 2, (double)aCellArea.getMinY() + aObjectRange.getMinY());
576 // handle cell fillings and text
577 const SfxItemSet& rCellItemSet = xCurrentCell->GetItemSet();
578 const sal_uInt32 nTextIndex(nColCount * aCellPos.mnRow + aCellPos.mnCol);
579 const SdrText* pSdrText = rTableObj.getText(nTextIndex);
580 drawinglayer::attribute::SdrFillTextAttribute aAttribute;
582 if(pSdrText)
584 // #i101508# take cell's local text frame distances into account
585 const sal_Int32 nLeft(xCurrentCell->GetTextLeftDistance());
586 const sal_Int32 nRight(xCurrentCell->GetTextRightDistance());
587 const sal_Int32 nUpper(xCurrentCell->GetTextUpperDistance());
588 const sal_Int32 nLower(xCurrentCell->GetTextLowerDistance());
590 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
591 rCellItemSet,
592 pSdrText,
593 &nLeft,
594 &nUpper,
595 &nRight,
596 &nLower);
598 else
600 aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
601 rCellItemSet,
602 pSdrText);
605 // always create cell primitives for BoundRect and HitTest
607 const drawinglayer::primitive2d::Primitive2DReference xCellReference(
608 new drawinglayer::primitive2d::SdrCellPrimitive2D(
609 aCellMatrix, aAttribute));
610 xCellSequence[nCellInsert++] = xCellReference;
613 // handle cell borders
614 const sal_Int32 nX(bIsRTL ? nColCount - aCellPos.mnCol : aCellPos.mnCol);
615 const sal_Int32 nY(aCellPos.mnRow);
617 // get access values for X,Y at the cell's end
618 const sal_Int32 nXSpan(xCurrentCell->getColumnSpan());
619 const sal_Int32 nYSpan(xCurrentCell->getRowSpan());
620 const sal_Int32 nXRight(bIsRTL ? nX - nXSpan : nX + nXSpan);
621 const sal_Int32 nYBottom(nY + nYSpan);
623 // get basic lines
624 impGetLine(aLeftLine, rTableLayouter, nX, nY, false, nColCount, nRowCount, bIsRTL);
625 //To resolve the bug fdo#59117
626 //In RTL table as BottomLine & TopLine are drawn from Left Side to Right, nX should be nX-1
627 impGetLine(aBottomLine, rTableLayouter, bIsRTL?nX-1:nX, nYBottom, true, nColCount, nRowCount, bIsRTL);
628 impGetLine(aRightLine, rTableLayouter, nXRight, nY, false, nColCount, nRowCount, bIsRTL);
629 impGetLine(aTopLine, rTableLayouter, bIsRTL?nX-1:nX, nY, true, nColCount, nRowCount, bIsRTL);
631 // get the neighbor cells' borders
632 impGetLine(aLeftFromTLine, rTableLayouter, nX, nY - 1, false, nColCount, nRowCount, bIsRTL);
633 impGetLine(aLeftFromBLine, rTableLayouter, nX, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
634 impGetLine(aRightFromTLine, rTableLayouter, nXRight, nY - 1, false, nColCount, nRowCount, bIsRTL);
635 impGetLine(aRightFromBLine, rTableLayouter, nXRight, nYBottom + 1, false, nColCount, nRowCount, bIsRTL);
636 impGetLine(aTopFromLLine, rTableLayouter, nX - 1, nY, true, nColCount, nRowCount, bIsRTL);
637 impGetLine(aTopFromRLine, rTableLayouter, nXRight + 1, nY, true, nColCount, nRowCount, bIsRTL);
638 impGetLine(aBottomFromLLine, rTableLayouter, nX - 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
639 impGetLine(aBottomFromRLine, rTableLayouter, nXRight + 1, nYBottom, true, nColCount, nRowCount, bIsRTL);
641 // create the primtive containing all data for one cell with borders
642 xBorderSequence[nBorderInsert++] = drawinglayer::primitive2d::Primitive2DReference(
643 new drawinglayer::primitive2d::SdrBorderlinePrimitive2D(
644 aCellMatrix,
645 aLeftLine,
646 aBottomLine,
647 aRightLine,
648 aTopLine,
649 aLeftFromTLine,
650 aLeftFromBLine,
651 aRightFromTLine,
652 aRightFromBLine,
653 aTopFromLLine,
654 aTopFromRLine,
655 aBottomFromLLine,
656 aBottomFromRLine,
657 bIsRTL ? nX == nColCount : 0 == nX,
658 nRowCount == nYBottom,
659 bIsRTL ? 0 == nXRight : nXRight == nColCount,
660 0 == nY,
661 true));
667 // no empty references; reallocate sequences by used count
668 xCellSequence.realloc(nCellInsert);
669 xBorderSequence.realloc(nBorderInsert);
671 // append to target. We want fillings and text first
672 xRetval = xCellSequence;
673 drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xBorderSequence);
676 if(xRetval.hasElements())
678 // check and create evtl. shadow for created content
679 const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet();
680 const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute(
681 drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet));
683 if(!aNewShadowAttribute.isDefault())
685 xRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(xRetval, aNewShadowAttribute);
689 return xRetval;
691 else
693 // take unrotated snap rect (direct model data) for position and size
694 const Rectangle& rRectangle = rTableObj.GetGeoRect();
695 const basegfx::B2DRange aObjectRange(
696 rRectangle.Left(), rRectangle.Top(),
697 rRectangle.Right(), rRectangle.Bottom());
699 // create object matrix
700 const GeoStat& rGeoStat(rTableObj.GetGeoStat());
701 const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
702 const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
703 const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
704 aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
705 aObjectRange.getMinX(), aObjectRange.getMinY()));
707 // credate an invisible outline for the cases where no visible content exists
708 const drawinglayer::primitive2d::Primitive2DReference xReference(
709 drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
710 false,
711 aObjectMatrix));
713 return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
717 ViewContactOfTableObj::ViewContactOfTableObj(::sdr::table::SdrTableObj& rTableObj)
718 : ViewContactOfSdrObj(rTableObj)
722 ViewContactOfTableObj::~ViewContactOfTableObj()
725 } // end of namespace contact
726 } // end of namespace sdr
728 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */