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