LCOV - code coverage report
Current view: top level - svx/source/table - viewcontactoftableobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 6 289 2.1 %
Date: 2015-06-13 12:38:46 Functions: 5 37 13.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11