summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-14 15:23:24 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:57:19 +0100
commit67d0e75c7c22844cfba842bb7ff9ba53b0125677 (patch)
tree5b2546e7603e4b8aa5adba0e0f4514fd7887ecdb /svx
parente3aeec6664273abc7917280032c3219d8672465f (diff)
sc: draw slanted borders using the drawinglayer primitives
Diffstat (limited to 'svx')
-rwxr-xr-xsvx/inc/svx/framelink.hxx34
-rwxr-xr-xsvx/source/dialog/framelink.cxx119
-rwxr-xr-xsvx/source/dialog/framelinkarray.cxx3
-rwxr-xr-xsvx/source/table/svdotable.cxx78
4 files changed, 52 insertions, 182 deletions
diff --git a/svx/inc/svx/framelink.hxx b/svx/inc/svx/framelink.hxx
index 2d550d1263c4..a2cd8e514c72 100755
--- a/svx/inc/svx/framelink.hxx
+++ b/svx/inc/svx/framelink.hxx
@@ -513,14 +513,9 @@ SVX_DLLPUBLIC drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimiti
const Style& rRFromB, /// Vertical frame border from bottom to right end of rBorder.
const DiagStyle& rRFromBL, /// Diagonal frame border from bottom-left to right end of rBorder.
- const Color* pForceColor = 0 /// If specified, overrides frame border color.
-);
-
-SVX_DLLPUBLIC drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
- const Point& rLPos, /// Reference point for left end of the processed frame border.
- const Point& rRPos, /// Reference point for right end of the processed frame border.
- const Style& rBorder, /// Style of the frame border to draw.
- const Color* pForceColor = 0 /// If specified, overrides frame border color.
+ const Color* pForceColor = 0,/// If specified, overrides frame border color.
+ const long& rRotationT = 9000, /// Angle of the top slanted frames in 100th of degree
+ const long& rRotationB = 9000 /// Angle of the bottom slanted frames in 100th of degree
);
SVX_DLLPUBLIC drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
@@ -536,7 +531,9 @@ SVX_DLLPUBLIC drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimiti
const Style& rRFromR, /// Horizontal frame border from right to right end of rBorder.
const Style& rRFromB, /// Vertical frame border from bottom to right end of rBorder.
- const Color* pForceColor = 0 /// If specified, overrides frame border color.
+ const Color* pForceColor = 0,/// If specified, overrides frame border color.
+ const long& rRotationT = 9000, /// Angle of the top slanted frame in 100th of degrees
+ const long& rRotationB = 9000 /// Angle of the bottom slanted frame in 100th of degrees
);
SVX_DLLPUBLIC drawinglayer::primitive2d::Primitive2DSequence CreateClippedBorderPrimitives (
@@ -763,25 +760,6 @@ void SVX_DLLPUBLIC DrawVerFrameBorder(
const Color* pForceColor = 0 /// If specified, overrides frame border color.
);
-// ----------------------------------------------------------------------------
-
-/** Draws a vertical slanted frame border without connected frame styles.
-
- This is an extended version of the simple DrawVerFrameBorder() function
- described above. It accepts start and end reference points with different
- X coordinates. See description above for additional details about the
- parameters (except the restriction on the reference points).
-
- The function preserves all settings of the passed output device.
- */
-void SVX_DLLPUBLIC DrawVerFrameBorderSlanted(
- OutputDevice& rDev, /// The output device used to draw the frame border.
- const Point& rTPos, /// Reference point for top end of the processed frame border.
- const Point& rBPos, /// Reference point for bottom end of the processed frame border.
- const Style& rBorder, /// Style of the frame border to draw.
- const Color* pForceColor = 0 /// If specified, overrides frame border color.
-);
-
// ============================================================================
/** Draws both diagonal frame borders, regards all connected frame styles.
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
index fa79a0aad409..b40aae6664ef 100755
--- a/svx/source/dialog/framelink.cxx
+++ b/svx/source/dialog/framelink.cxx
@@ -1366,19 +1366,45 @@ bool CheckFrameBorderConnectable( const Style& rLBorder, const Style& rRBorder,
// Drawing functions
// ============================================================================
-double lcl_GetExtent( const Style& rSide, const Style& rOpposite )
+double lcl_GetExtent( const Style& rBorder, const Style& rSide, const Style& rOpposite,
+ long nAngleSide = 9000, long nAngleOpposite = 9000 )
{
- double nExtent = 0.0;
+ Style aOtherBorder = const_cast< Style& >( rSide );
+ long nOtherAngle = nAngleSide;
+ if ( rSide.GetWidth() == 0 && rOpposite.GetWidth() > 0 )
+ {
+ nOtherAngle = nAngleOpposite;
+ aOtherBorder = const_cast< Style& >( rOpposite );
+ }
+ else if ( rSide.GetWidth() == 0 && rOpposite.GetWidth() == 0 )
+ {
+ if ( ( nAngleOpposite % 18000 ) == 0 )
+ nOtherAngle = nAngleSide;
+ else if ( ( nAngleSide % 18000 ) == 0 )
+ nOtherAngle = nAngleOpposite;
+ }
- if ( rSide.Prim() + rSide.Secn() > 0 )
- nExtent = - rSide.GetWidth( ) / 2.0;
- else
- nExtent = rOpposite.GetWidth() / 2.0;
+ // Let's assume the border we are drawing is horizontal and compute all the angles / distances from this
+ basegfx::B2DVector aBaseVector( 1.0, 0.0 );
+ basegfx::B2DPoint aBasePoint( 0.0, static_cast<double>( rBorder.GetWidth() / 2 ) );
- return nExtent;
+ basegfx::B2DHomMatrix aRotation;
+ aRotation.rotate( nOtherAngle * F_PI18000 );
+
+ basegfx::B2DVector aOtherVector = aRotation * aBaseVector;
+ // Compute a line shifted by half the width of the other border
+ basegfx::B2DVector aPerpendicular = basegfx::getNormalizedPerpendicular( aOtherVector );
+ basegfx::B2DPoint aOtherPoint = basegfx::B2DPoint() + aPerpendicular * aOtherBorder.GetWidth() / 2;
+
+ // Find the cut between the two lines
+ double nCut = 0.0;
+ basegfx::tools::findCut(
+ aBasePoint, aBaseVector, aOtherPoint, aOtherVector,
+ CUTFLAG_ALL, &nCut );
+ return nCut;
}
-basegfx::B2DPoint lcl_PointToB2DPoint( Point aPoint )
+basegfx::B2DPoint lcl_PointToB2DPoint( const Point aPoint )
{
return basegfx::B2DPoint( aPoint.getX(), aPoint.getY() );
}
@@ -1412,11 +1438,10 @@ drawinglayer::primitive2d::Primitive2DSequence CreateClippedBorderPrimitives (
drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
const Point& rLPos, const Point& rRPos, const Style& rBorder,
- const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR,
- const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL,
- const Color* pForceColor )
+ const DiagStyle& /*rLFromTR*/, const Style& rLFromT, const Style& /*rLFromL*/, const Style& rLFromB, const DiagStyle& /*rLFromBR*/,
+ const DiagStyle& /*rRFromTL*/, const Style& rRFromT, const Style& /*rRFromR*/, const Style& rRFromB, const DiagStyle& /*rRFromBL*/,
+ const Color* /*pForceColor*/, const long& nRotateT, const long& nRotateB )
{
- const DiagStyle aNoStyle;
drawinglayer::primitive2d::Primitive2DSequence aSequence( 1 );
basegfx::B2DPoint aStart( rLPos.getX(), rLPos.getY() );
@@ -1427,10 +1452,10 @@ drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
rBorder.Prim(),
rBorder.Dist(),
rBorder.Secn(),
- lcl_GetExtent( rLFromT, rLFromB ),
- lcl_GetExtent( rRFromT, rRFromB ),
- lcl_GetExtent( rLFromB, rLFromT ),
- lcl_GetExtent( rRFromB, rRFromT ),
+ lcl_GetExtent( rBorder, rLFromT, rLFromB, nRotateT, - nRotateB ),
+ lcl_GetExtent( rBorder, rRFromT, rRFromB, 18000 - nRotateT, nRotateB - 18000 ),
+ lcl_GetExtent( rBorder, rLFromB, rLFromT, nRotateB, - nRotateT ),
+ lcl_GetExtent( rBorder, rRFromB, rRFromT, 18000 - nRotateB, nRotateT - 18000 ),
rBorder.GetColorSecn().getBColor(),
rBorder.GetColorPrim().getBColor(),
rBorder.GetColorGap().getBColor(),
@@ -1443,24 +1468,12 @@ drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
const Point& rLPos, const Point& rRPos, const Style& rBorder,
const Style& rLFromT, const Style& rLFromL, const Style& rLFromB,
const Style& rRFromT, const Style& rRFromR, const Style& rRFromB,
- const Color* pForceColor )
+ const Color* pForceColor, const long& nRotateT, const long& nRotateB )
{
- const DiagStyle noDiagStyle;
return CreateBorderPrimitives( rLPos, rRPos, rBorder,
- noDiagStyle, rLFromT, rLFromL, rLFromB, noDiagStyle,
- noDiagStyle, rRFromT, rRFromR, rRFromB, noDiagStyle,
- pForceColor );
-}
-
-drawinglayer::primitive2d::Primitive2DSequence CreateBorderPrimitives(
- const Point& rLPos, const Point& rRPos,
- const Style& rBorder, const Color* pForceColor )
-{
- const Style noStyle;
- return CreateBorderPrimitives( rLPos, rRPos, rBorder,
- noStyle, noStyle, noStyle,
- noStyle, noStyle, noStyle,
- pForceColor );
+ DiagStyle(), rLFromT, rLFromL, rLFromB, DiagStyle(),
+ DiagStyle(), rRFromT, rRFromR, rRFromB, DiagStyle(),
+ pForceColor, nRotateT, nRotateB );
}
void DrawHorFrameBorder( OutputDevice& rDev,
@@ -1541,48 +1554,6 @@ void DrawVerFrameBorder( OutputDevice& rDev,
lclDrawVerFrameBorder( rDev, rTPos, rBPos, rBorder, BorderResult(), pForceColor );
}
-// ----------------------------------------------------------------------------
-
-void DrawVerFrameBorderSlanted( OutputDevice& rDev,
- const Point& rTPos, const Point& rBPos, const Style& rBorder, const Color* pForceColor )
-{
- DBG_ASSERT( rTPos.Y() < rBPos.Y(), "svx::frame::DrawVerFrameBorderSlanted - wrong order of line ends" );
- if( rBorder.Prim() && (rTPos.Y() < rBPos.Y()) )
- {
- if( rTPos.X() == rBPos.X() )
- {
- DrawVerFrameBorder( rDev, rTPos, rBPos, rBorder, pForceColor );
- }
- else
- {
- const LineEndResult aRes;
-
- Style aScaled( rBorder );
- aScaled.ScaleSelf( 1.0 / cos( GetVerDiagAngle( rTPos, rBPos ) ) );
-
- lclSetColorToOutDev( rDev, aScaled.GetColorPrim(), pForceColor );
- lclDrawVerLine( rDev, rTPos, aRes, rBPos, aRes,
- lclGetBeg( aScaled ), lclGetPrimEnd( aScaled ), aScaled.Type() );
- rDev.Pop(); // colors
- if( aScaled.Secn() )
- {
- if ( aScaled.UseGapColor( ) )
- {
- lclSetColorToOutDev( rDev, aScaled.GetColorGap(), pForceColor );
- lclDrawVerLine( rDev, rTPos, aRes, rBPos, aRes,
- lclGetDistBeg( aScaled ), lclGetDistEnd( aScaled ), aScaled.Type() );
- rDev.Pop(); // colors
- }
-
- lclSetColorToOutDev( rDev, aScaled.GetColorSecn(), pForceColor );
- lclDrawVerLine( rDev, rTPos, aRes, rBPos, aRes,
- lclGetSecnBeg( aScaled ), lclGetEnd( aScaled ), aScaled.Type() );
- rDev.Pop(); // colors
- }
- }
- }
-}
-
// ============================================================================
void DrawDiagFrameBorders(
diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx
index f6b9c9f35cd7..c6b59f9b0cb7 100755
--- a/svx/source/dialog/framelinkarray.cxx
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -1038,8 +1038,6 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D* pProcessor,
{
size_t _nFirstCol = mxImpl->GetMergedFirstCol( nCol, nRow );
size_t _nFirstRow = mxImpl->GetMergedFirstRow( nCol, nRow );
- size_t _nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
- size_t _nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
const Style aTlbrStyle = GetCellStyleTLBR( _nFirstCol, _nFirstRow, true );
if ( aTlbrStyle.GetWidth( ) )
@@ -1214,6 +1212,7 @@ void Array::DrawRange( drawinglayer::processor2d::BaseProcessor2D* pProcessor,
aStartTFromBL, *pStartTFromL, *pStartTFromT, *pStartTFromR, aStartTFromBR, pForceColor ) );
}
}
+
void Array::DrawRange( OutputDevice& rDev,
size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow,
const Color* pForceColor ) const
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 84ee34be44b7..1962af97eb9b 100755
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1851,84 +1851,6 @@ struct ImplTableShadowPaintInfo
// --------------------------------------------------------------------
-void lcl_VertLineEnds( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
- const Color& rColor, long nXOffs, long nWidth,
- const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine )
-{
- rDev.SetLineColor(rColor); // PEN_NULL ???
- rDev.SetFillColor(rColor);
-
- // Position oben/unten muss unabhaengig von der Liniendicke sein,
- // damit der Winkel stimmt (oder X-Position auch anpassen)
- long nTopPos = rTop.Y();
- long nBotPos = rBottom.Y();
-
- long nTopLeft = rTop.X() + nXOffs;
- long nTopRight = nTopLeft + nWidth - 1;
-
- long nBotLeft = rBottom.X() + nXOffs;
- long nBotRight = nBotLeft + nWidth - 1;
-
- // oben abschliessen
-
- if ( rTopLine.Prim() )
- {
- long nLineW = rTopLine.GetWidth();
- if (nLineW >= 2)
- {
- Point aTriangle[3];
- aTriangle[0] = Point( nTopLeft, nTopPos ); // wie aPoints[0]
- aTriangle[1] = Point( nTopRight, nTopPos ); // wie aPoints[1]
- aTriangle[2] = Point( rTop.X(), nTopPos - (nLineW - 1) / 2 );
- Polygon aTriPoly( 3, aTriangle );
- rDev.DrawPolygon( aTriPoly );
- }
- }
-
- // unten abschliessen
-
- if ( rBottomLine.Prim() )
- {
- long nLineW = rBottomLine.GetWidth();
- if (nLineW >= 2)
- {
- Point aTriangle[3];
- aTriangle[0] = Point( nBotLeft, nBotPos ); // wie aPoints[3]
- aTriangle[1] = Point( nBotRight, nBotPos ); // wie aPoints[2]
- aTriangle[2] = Point( rBottom.X(), nBotPos - (nLineW - 1) / 2 + nLineW - 1 );
- Polygon aTriPoly( 3, aTriangle );
- rDev.DrawPolygon( aTriPoly );
- }
- }
-}
-
-void lcl_VertLine( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
- const svx::frame::Style& rLine,
- const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine,
- const Color* pForceColor )
-{
- if( rLine.Prim() )
- {
- svx::frame::DrawVerFrameBorderSlanted( rDev, rTop, rBottom, rLine, pForceColor );
-
- svx::frame::Style aScaled( rLine );
- aScaled.ScaleSelf( 1.0 / cos( svx::frame::GetVerDiagAngle( rTop, rBottom ) ) );
- if( pForceColor )
- aScaled.SetColorPrim( *pForceColor );
-
- long nXOffs = (aScaled.GetWidth() - 1) / -2L;
-
- lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColorPrim(),
- nXOffs, aScaled.Prim(), rTopLine, rBottomLine );
-
- if( aScaled.Secn() )
- lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColorPrim(),
- nXOffs + aScaled.Prim() + aScaled.Dist(), aScaled.Secn(), rTopLine, rBottomLine );
- }
-}
-
-// --------------------------------------------------------------------
-
void SdrTableObj::TakeObjNameSingul(XubString& rName) const
{
rName = ImpGetResStr(STR_ObjNameSingulTable);