This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new d0f02d504f Fixed typos, cleanup
d0f02d504f is described below
commit d0f02d504f020883217ddafca9ad519609418cfb
Author: mseidel <[email protected]>
AuthorDate: Tue Mar 4 00:59:52 2025 +0100
Fixed typos, cleanup
---
main/basegfx/source/polygon/b2dlinegeometry.cxx | 1569 ++++++++++----------
.../examples/java/Spreadsheet/EuroAdaption.java | 148 +-
main/ucb/source/ucp/file/prov.hxx | 36 +-
3 files changed, 872 insertions(+), 881 deletions(-)
diff --git a/main/basegfx/source/polygon/b2dlinegeometry.cxx
b/main/basegfx/source/polygon/b2dlinegeometry.cxx
index ead888c928..8e7daec215 100644
--- a/main/basegfx/source/polygon/b2dlinegeometry.cxx
+++ b/main/basegfx/source/polygon/b2dlinegeometry.cxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* 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
@@ -7,20 +7,18 @@
* 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
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_basegfx.hxx"
#include <cstdio>
@@ -37,15 +35,13 @@
#include <com/sun/star/drawing/LineCap.hpp>
#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
-//////////////////////////////////////////////////////////////////////////////
-
namespace basegfx
{
namespace tools
{
B2DPolyPolygon createAreaGeometryForLineStartEnd(
- const B2DPolygon& rCandidate,
- const B2DPolyPolygon& rArrow,
+ const B2DPolygon& rCandidate,
+ const B2DPolyPolygon& rArrow,
bool bStart,
double fWidth,
double fCandidateLength,
@@ -56,79 +52,79 @@ namespace basegfx
OSL_ENSURE(rCandidate.count() > 1L,
"createAreaGeometryForLineStartEnd: Line polygon has too less points (!)");
OSL_ENSURE(rArrow.count() > 0L,
"createAreaGeometryForLineStartEnd: Empty arrow PolyPolygon (!)");
OSL_ENSURE(fWidth > 0.0,
"createAreaGeometryForLineStartEnd: Width too small (!)");
- OSL_ENSURE(fDockingPosition >= 0.0 && fDockingPosition
<= 1.0,
+ OSL_ENSURE(fDockingPosition >= 0.0 && fDockingPosition
<= 1.0,
"createAreaGeometryForLineStartEnd:
fDockingPosition out of range [0.0 .. 1.0] (!)");
- if(fWidth < 0.0)
- {
- fWidth = -fWidth;
- }
-
- if(rCandidate.count() > 1 && rArrow.count() &&
!fTools::equalZero(fWidth))
- {
- if(fDockingPosition < 0.0)
- {
- fDockingPosition = 0.0;
- }
- else if(fDockingPosition > 1.0)
- {
- fDockingPosition = 1.0;
- }
-
- // init return value from arrow
- aRetval.append(rArrow);
-
- // get size of the arrow
- const B2DRange aArrowSize(getRange(rArrow));
-
- // build ArrowTransform; center in X, align with
axis in Y
- B2DHomMatrix
aArrowTransform(basegfx::tools::createTranslateB2DHomMatrix(
- -aArrowSize.getCenter().getX(),
-aArrowSize.getMinimum().getY()));
-
- // scale to target size
- const double fArrowScale(fWidth /
(aArrowSize.getRange().getX()));
- aArrowTransform.scale(fArrowScale, fArrowScale);
-
- // get arrow size in Y
- B2DPoint
aUpperCenter(aArrowSize.getCenter().getX(), aArrowSize.getMaximum().getY());
- aUpperCenter *= aArrowTransform;
- const double
fArrowYLength(B2DVector(aUpperCenter).getLength());
-
- // move arrow to have docking position centered
- aArrowTransform.translate(0.0, -fArrowYLength *
fDockingPosition);
-
- // prepare polygon length
- if(fTools::equalZero(fCandidateLength))
- {
- fCandidateLength = getLength(rCandidate);
- }
-
- // get the polygon vector we want to plant this
arrow on
- const double fConsumedLength(fArrowYLength * (1.0 -
fDockingPosition));
- const B2DVector
aHead(rCandidate.getB2DPoint((bStart) ? 0L : rCandidate.count() - 1L));
- const B2DVector
aTail(getPositionAbsolute(rCandidate,
- (bStart) ? fConsumedLength :
fCandidateLength - fConsumedLength, fCandidateLength));
-
- // from that vector, take the needed rotation and
add rotate for arrow to transformation
- const B2DVector aTargetDirection(aHead - aTail);
- const double
fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + (90.0 *
F_PI180));
-
- // rotate around docking position
- aArrowTransform.rotate(fRotation);
-
- // move arrow docking position to polygon head
- aArrowTransform.translate(aHead.getX(),
aHead.getY());
-
- // transform retval and close
- aRetval.transform(aArrowTransform);
- aRetval.setClosed(true);
-
- // if pConsumedLength is asked for, fill it
- if(pConsumedLength)
- {
- *pConsumedLength = fConsumedLength;
- }
- }
+ if(fWidth < 0.0)
+ {
+ fWidth = -fWidth;
+ }
+
+ if(rCandidate.count() > 1 && rArrow.count() &&
!fTools::equalZero(fWidth))
+ {
+ if(fDockingPosition < 0.0)
+ {
+ fDockingPosition = 0.0;
+ }
+ else if(fDockingPosition > 1.0)
+ {
+ fDockingPosition = 1.0;
+ }
+
+ // init return value from arrow
+ aRetval.append(rArrow);
+
+ // get size of the arrow
+ const B2DRange aArrowSize(getRange(rArrow));
+
+ // build ArrowTransform; center in X, align
with axis in Y
+ B2DHomMatrix
aArrowTransform(basegfx::tools::createTranslateB2DHomMatrix(
+ -aArrowSize.getCenter().getX(),
-aArrowSize.getMinimum().getY()));
+
+ // scale to target size
+ const double fArrowScale(fWidth /
(aArrowSize.getRange().getX()));
+ aArrowTransform.scale(fArrowScale, fArrowScale);
+
+ // get arrow size in Y
+ B2DPoint
aUpperCenter(aArrowSize.getCenter().getX(), aArrowSize.getMaximum().getY());
+ aUpperCenter *= aArrowTransform;
+ const double
fArrowYLength(B2DVector(aUpperCenter).getLength());
+
+ // move arrow to have docking position centered
+ aArrowTransform.translate(0.0, -fArrowYLength *
fDockingPosition);
+
+ // prepare polygon length
+ if(fTools::equalZero(fCandidateLength))
+ {
+ fCandidateLength =
getLength(rCandidate);
+ }
+
+ // get the polygon vector we want to plant this
arrow on
+ const double fConsumedLength(fArrowYLength *
(1.0 - fDockingPosition));
+ const B2DVector
aHead(rCandidate.getB2DPoint((bStart) ? 0L : rCandidate.count() - 1L));
+ const B2DVector
aTail(getPositionAbsolute(rCandidate,
+ (bStart) ? fConsumedLength :
fCandidateLength - fConsumedLength, fCandidateLength));
+
+ // from that vector, take the needed rotation
and add rotate for arrow to transformation
+ const B2DVector aTargetDirection(aHead - aTail);
+ const double
fRotation(atan2(aTargetDirection.getY(), aTargetDirection.getX()) + (90.0 *
F_PI180));
+
+ // rotate around docking position
+ aArrowTransform.rotate(fRotation);
+
+ // move arrow docking position to polygon head
+ aArrowTransform.translate(aHead.getX(),
aHead.getY());
+
+ // transform retval and close
+ aRetval.transform(aArrowTransform);
+ aRetval.setClosed(true);
+
+ // if pConsumedLength is asked for, fill it
+ if(pConsumedLength)
+ {
+ *pConsumedLength = fConsumedLength;
+ }
+ }
return aRetval;
}
@@ -142,31 +138,31 @@ namespace basegfx
// anonymus namespace for local helpers
namespace
{
- bool impIsSimpleEdge(const B2DCubicBezier& rCandidate, double
fMaxCosQuad, double fMaxPartOfEdgeQuad)
- {
- // isBezier() is true, already tested by caller
- const B2DVector aEdge(rCandidate.getEndPoint() -
rCandidate.getStartPoint());
-
- if(aEdge.equalZero())
- {
- // start and end point the same, but control vectors used ->
baloon curve loop
- // is not a simple edge
- return false;
- }
-
- // get tangentA and scalar with edge
- const B2DVector aTangentA(rCandidate.getTangent(0.0));
- const double fScalarAE(aEdge.scalar(aTangentA));
-
- if(fTools::lessOrEqual(fScalarAE, 0.0))
- {
- // angle between TangentA and Edge is bigger or equal 90
degrees
- return false;
- }
-
- // get self-scalars for E and A
- const double fScalarE(aEdge.scalar(aEdge));
- const double fScalarA(aTangentA.scalar(aTangentA));
+ bool impIsSimpleEdge(const B2DCubicBezier& rCandidate, double
fMaxCosQuad, double fMaxPartOfEdgeQuad)
+ {
+ // isBezier() is true, already tested by caller
+ const B2DVector aEdge(rCandidate.getEndPoint() -
rCandidate.getStartPoint());
+
+ if(aEdge.equalZero())
+ {
+ // start and end point the same, but control
vectors used -> balloon curve loop
+ // is not a simple edge
+ return false;
+ }
+
+ // get tangentA and scalar with edge
+ const B2DVector aTangentA(rCandidate.getTangent(0.0));
+ const double fScalarAE(aEdge.scalar(aTangentA));
+
+ if(fTools::lessOrEqual(fScalarAE, 0.0))
+ {
+ // angle between TangentA and Edge is bigger or
equal 90 degrees
+ return false;
+ }
+
+ // get self-scalars for E and A
+ const double fScalarE(aEdge.scalar(aEdge));
+ const double fScalarA(aTangentA.scalar(aTangentA));
const double fLengthCompareE(fScalarE *
fMaxPartOfEdgeQuad);
if(fTools::moreOrEqual(fScalarA, fLengthCompareE))
@@ -175,24 +171,24 @@ namespace basegfx
return false;
}
- if(fTools::lessOrEqual(fScalarAE * fScalarAE, fScalarA * fScalarE
* fMaxCosQuad))
- {
- // angle between TangentA and Edge is bigger or equal angle
defined by fMaxCos
- return false;
- }
+ if(fTools::lessOrEqual(fScalarAE * fScalarAE, fScalarA
* fScalarE * fMaxCosQuad))
+ {
+ // angle between TangentA and Edge is bigger or
equal angle defined by fMaxCos
+ return false;
+ }
- // get tangentB and scalar with edge
- const B2DVector aTangentB(rCandidate.getTangent(1.0));
- const double fScalarBE(aEdge.scalar(aTangentB));
+ // get tangentB and scalar with edge
+ const B2DVector aTangentB(rCandidate.getTangent(1.0));
+ const double fScalarBE(aEdge.scalar(aTangentB));
- if(fTools::lessOrEqual(fScalarBE, 0.0))
- {
- // angle between TangentB and Edge is bigger or equal 90
degrees
- return false;
- }
+ if(fTools::lessOrEqual(fScalarBE, 0.0))
+ {
+ // angle between TangentB and Edge is bigger or
equal 90 degrees
+ return false;
+ }
- // get self-scalar for B
- const double fScalarB(aTangentB.scalar(aTangentB));
+ // get self-scalar for B
+ const double fScalarB(aTangentB.scalar(aTangentB));
if(fTools::moreOrEqual(fScalarB, fLengthCompareE))
{
@@ -201,500 +197,500 @@ namespace basegfx
}
if(fTools::lessOrEqual(fScalarBE * fScalarBE, fScalarB
* fScalarE * fMaxCosQuad))
- {
- // angle between TangentB and Edge is bigger or equal defined
by fMaxCos
- return false;
- }
-
- return true;
- }
-
- void impSubdivideToSimple(const B2DCubicBezier& rCandidate,
B2DPolygon& rTarget, double fMaxCosQuad, double fMaxPartOfEdgeQuad, sal_uInt32
nMaxRecursionDepth)
- {
- if(!nMaxRecursionDepth || impIsSimpleEdge(rCandidate, fMaxCosQuad,
fMaxPartOfEdgeQuad))
- {
- rTarget.appendBezierSegment(rCandidate.getControlPointA(),
rCandidate.getControlPointB(), rCandidate.getEndPoint());
- }
- else
- {
- B2DCubicBezier aLeft, aRight;
- rCandidate.split(0.5, &aLeft, &aRight);
-
- impSubdivideToSimple(aLeft, rTarget, fMaxCosQuad,
fMaxPartOfEdgeQuad, nMaxRecursionDepth - 1);
- impSubdivideToSimple(aRight, rTarget, fMaxCosQuad,
fMaxPartOfEdgeQuad, nMaxRecursionDepth - 1);
- }
- }
-
- B2DPolygon subdivideToSimple(const B2DPolygon& rCandidate, double
fMaxCosQuad, double fMaxPartOfEdgeQuad)
- {
- const sal_uInt32 nPointCount(rCandidate.count());
-
- if(rCandidate.areControlPointsUsed() && nPointCount)
- {
- const sal_uInt32 nEdgeCount(rCandidate.isClosed() ?
nPointCount : nPointCount - 1);
- B2DPolygon aRetval;
+ {
+ // angle between TangentB and Edge is bigger or
equal defined by fMaxCos
+ return false;
+ }
+
+ return true;
+ }
+
+ void impSubdivideToSimple(const B2DCubicBezier& rCandidate,
B2DPolygon& rTarget, double fMaxCosQuad, double fMaxPartOfEdgeQuad, sal_uInt32
nMaxRecursionDepth)
+ {
+ if(!nMaxRecursionDepth || impIsSimpleEdge(rCandidate,
fMaxCosQuad, fMaxPartOfEdgeQuad))
+ {
+
rTarget.appendBezierSegment(rCandidate.getControlPointA(),
rCandidate.getControlPointB(), rCandidate.getEndPoint());
+ }
+ else
+ {
+ B2DCubicBezier aLeft, aRight;
+ rCandidate.split(0.5, &aLeft, &aRight);
+
+ impSubdivideToSimple(aLeft, rTarget,
fMaxCosQuad, fMaxPartOfEdgeQuad, nMaxRecursionDepth - 1);
+ impSubdivideToSimple(aRight, rTarget,
fMaxCosQuad, fMaxPartOfEdgeQuad, nMaxRecursionDepth - 1);
+ }
+ }
+
+ B2DPolygon subdivideToSimple(const B2DPolygon& rCandidate,
double fMaxCosQuad, double fMaxPartOfEdgeQuad)
+ {
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ if(rCandidate.areControlPointsUsed() && nPointCount)
+ {
+ const sal_uInt32
nEdgeCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1);
+ B2DPolygon aRetval;
B2DCubicBezier aEdge;
// prepare edge for loop
aEdge.setStartPoint(rCandidate.getB2DPoint(0));
aRetval.append(aEdge.getStartPoint());
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
- {
- // fill B2DCubicBezier
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
- aEdge.setControlPointA(rCandidate.getNextControlPoint(a));
-
aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex));
- aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex));
-
- // get rid of unnecessary bezier segments
- aEdge.testAndSolveTrivialBezier();
-
- if(aEdge.isBezier())
- {
+ for(sal_uInt32 a(0); a < nEdgeCount; a++)
+ {
+ // fill B2DCubicBezier
+ const sal_uInt32 nNextIndex((a + 1) %
nPointCount);
+
aEdge.setControlPointA(rCandidate.getNextControlPoint(a));
+
aEdge.setControlPointB(rCandidate.getPrevControlPoint(nNextIndex));
+
aEdge.setEndPoint(rCandidate.getB2DPoint(nNextIndex));
+
+ // get rid of unnecessary bezier
segments
+ aEdge.testAndSolveTrivialBezier();
+
+ if(aEdge.isBezier())
+ {
// before splitting recursively
with internal simple criteria, use
// ExtremumPosFinder to remove
those
- ::std::vector< double > aExtremumPositions;
-
- aExtremumPositions.reserve(4);
-
aEdge.getAllExtremumPositions(aExtremumPositions);
-
- const sal_uInt32 nCount(aExtremumPositions.size());
-
- if(nCount)
- {
- if(nCount > 1)
- {
- // create order from left to right
- ::std::sort(aExtremumPositions.begin(),
aExtremumPositions.end());
- }
-
- for(sal_uInt32 b(0); b < nCount;)
- {
- // split aEdge at next split pos
- B2DCubicBezier aLeft;
- const double
fSplitPos(aExtremumPositions[b++]);
-
- aEdge.split(fSplitPos, &aLeft, &aEdge);
- aLeft.testAndSolveTrivialBezier();
-
- // consume left part
- if(aLeft.isBezier())
- {
- impSubdivideToSimple(aLeft, aRetval,
fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
- }
- else
- {
- aRetval.append(aLeft.getEndPoint());
- }
-
- if(b < nCount)
- {
- // correct the remaining split positions
to fit to shortened aEdge
- const double fScaleFactor(1.0 / (1.0 -
fSplitPos));
-
- for(sal_uInt32 c(b); c < nCount; c++)
- {
- aExtremumPositions[c] =
(aExtremumPositions[c] - fSplitPos) * fScaleFactor;
- }
- }
- }
-
- // test the shortened rest of aEdge
- aEdge.testAndSolveTrivialBezier();
-
- // consume right part
- if(aEdge.isBezier())
- {
- impSubdivideToSimple(aEdge, aRetval,
fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
- }
- else
- {
- aRetval.append(aEdge.getEndPoint());
- }
- }
- else
- {
- impSubdivideToSimple(aEdge, aRetval,
fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
- }
- }
- else
- {
- // straight edge, add point
- aRetval.append(aEdge.getEndPoint());
- }
+ ::std::vector< double >
aExtremumPositions;
+
+ aExtremumPositions.reserve(4);
+
aEdge.getAllExtremumPositions(aExtremumPositions);
+
+ const sal_uInt32
nCount(aExtremumPositions.size());
+
+ if(nCount)
+ {
+ if(nCount > 1)
+ {
+ // create order
from left to right
+
::std::sort(aExtremumPositions.begin(), aExtremumPositions.end());
+ }
+
+ for(sal_uInt32 b(0); b
< nCount;)
+ {
+ // split aEdge
at next split pos
+ B2DCubicBezier
aLeft;
+ const double
fSplitPos(aExtremumPositions[b++]);
+
+
aEdge.split(fSplitPos, &aLeft, &aEdge);
+
aLeft.testAndSolveTrivialBezier();
+
+ // consume left
part
+
if(aLeft.isBezier())
+ {
+
impSubdivideToSimple(aLeft, aRetval, fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
+ }
+ else
+ {
+
aRetval.append(aLeft.getEndPoint());
+ }
+
+ if(b < nCount)
+ {
+ //
correct the remaining split positions to fit to shortened aEdge
+ const
double fScaleFactor(1.0 / (1.0 - fSplitPos));
+
+
for(sal_uInt32 c(b); c < nCount; c++)
+ {
+
aExtremumPositions[c] = (aExtremumPositions[c] - fSplitPos) * fScaleFactor;
+ }
+ }
+ }
+
+ // test the shortened
rest of aEdge
+
aEdge.testAndSolveTrivialBezier();
+
+ // consume right part
+ if(aEdge.isBezier())
+ {
+
impSubdivideToSimple(aEdge, aRetval, fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
+ }
+ else
+ {
+
aRetval.append(aEdge.getEndPoint());
+ }
+ }
+ else
+ {
+
impSubdivideToSimple(aEdge, aRetval, fMaxCosQuad, fMaxPartOfEdgeQuad, 6);
+ }
+ }
+ else
+ {
+ // straight edge, add point
+
aRetval.append(aEdge.getEndPoint());
+ }
// prepare edge for next step
aEdge.setStartPoint(aEdge.getEndPoint());
- }
+ }
// copy closed flag and check for double points
- aRetval.setClosed(rCandidate.isClosed());
- aRetval.removeDoublePoints();
-
- return aRetval;
- }
- else
- {
- return rCandidate;
- }
- }
-
- B2DPolygon createAreaGeometryForEdge(
- const B2DCubicBezier& rEdge,
- double fHalfLineWidth,
- bool bStartRound,
- bool bEndRound,
- bool bStartSquare,
- bool bEndSquare)
- {
- // create polygon for edge
- // Unfortunately, while it would be geometrically correct to not
add
- // the in-between points EdgeEnd and EdgeStart, it leads to
rounding
- // errors when converting to integer polygon coordinates for
painting
- if(rEdge.isBezier())
- {
- // prepare target and data common for upper and lower
- B2DPolygon aBezierPolygon;
- const B2DVector aPureEdgeVector(rEdge.getEndPoint() -
rEdge.getStartPoint());
- const double fEdgeLength(aPureEdgeVector.getLength());
- const bool bIsEdgeLengthZero(fTools::equalZero(fEdgeLength));
- B2DVector aTangentA(rEdge.getTangent(0.0));
aTangentA.normalize();
- B2DVector aTangentB(rEdge.getTangent(1.0));
aTangentB.normalize();
- const B2DVector
aNormalizedPerpendicularA(getPerpendicular(aTangentA));
- const B2DVector
aNormalizedPerpendicularB(getPerpendicular(aTangentB));
-
- // create upper displacement vectors and check if they cut
- const B2DVector aPerpendStartA(aNormalizedPerpendicularA *
-fHalfLineWidth);
- const B2DVector aPerpendEndA(aNormalizedPerpendicularB *
-fHalfLineWidth);
- double fCutA(0.0);
- const tools::CutFlagValue aCutA(tools::findCut(
- rEdge.getStartPoint(), aPerpendStartA,
- rEdge.getEndPoint(), aPerpendEndA,
- CUTFLAG_ALL, &fCutA));
- const bool bCutA(CUTFLAG_NONE != aCutA);
-
- // create lower displacement vectors and check if they cut
- const B2DVector aPerpendStartB(aNormalizedPerpendicularA *
fHalfLineWidth);
- const B2DVector aPerpendEndB(aNormalizedPerpendicularB *
fHalfLineWidth);
- double fCutB(0.0);
- const tools::CutFlagValue aCutB(tools::findCut(
- rEdge.getEndPoint(), aPerpendEndB,
- rEdge.getStartPoint(), aPerpendStartB,
- CUTFLAG_ALL, &fCutB));
- const bool bCutB(CUTFLAG_NONE != aCutB);
-
- // check if cut happens
- const bool bCut(bCutA || bCutB);
- B2DPoint aCutPoint;
-
- // create left edge
- if(bStartRound || bStartSquare)
- {
- if(bStartRound)
- {
- basegfx::B2DPolygon
aStartPolygon(tools::createHalfUnitCircle());
-
- aStartPolygon.transform(
-
tools::createScaleShearXRotateTranslateB2DHomMatrix(
- fHalfLineWidth, fHalfLineWidth,
- 0.0,
- atan2(aTangentA.getY(), aTangentA.getX()) +
F_PI2,
- rEdge.getStartPoint().getX(),
rEdge.getStartPoint().getY()));
- aBezierPolygon.append(aStartPolygon);
- }
- else // bStartSquare
- {
- const basegfx::B2DPoint aStart(rEdge.getStartPoint() -
(aTangentA * fHalfLineWidth));
-
- if(bCutB)
- {
- aBezierPolygon.append(rEdge.getStartPoint() +
aPerpendStartB);
- }
-
- aBezierPolygon.append(aStart + aPerpendStartB);
- aBezierPolygon.append(aStart + aPerpendStartA);
-
- if(bCutA)
- {
- aBezierPolygon.append(rEdge.getStartPoint() +
aPerpendStartA);
- }
- }
- }
- else
- {
- // append original in-between point
- aBezierPolygon.append(rEdge.getStartPoint());
- }
-
- // create upper edge.
- {
- if(bCutA)
- {
- // calculate cut point and add
- aCutPoint = rEdge.getStartPoint() + (aPerpendStartA *
fCutA);
- aBezierPolygon.append(aCutPoint);
- }
- else
- {
- // create scaled bezier segment
- const B2DPoint aStart(rEdge.getStartPoint() +
aPerpendStartA);
- const B2DPoint aEnd(rEdge.getEndPoint() +
aPerpendEndA);
- const B2DVector aEdge(aEnd - aStart);
- const double fLength(aEdge.getLength());
- const double fScale(bIsEdgeLengthZero ? 1.0 : fLength
/ fEdgeLength);
- const B2DVector fRelNext(rEdge.getControlPointA() -
rEdge.getStartPoint());
- const B2DVector fRelPrev(rEdge.getControlPointB() -
rEdge.getEndPoint());
-
- aBezierPolygon.append(aStart);
- aBezierPolygon.appendBezierSegment(aStart + (fRelNext
* fScale), aEnd + (fRelPrev * fScale), aEnd);
- }
- }
-
- // create right edge
- if(bEndRound || bEndSquare)
- {
- if(bEndRound)
- {
- basegfx::B2DPolygon
aEndPolygon(tools::createHalfUnitCircle());
-
- aEndPolygon.transform(
-
tools::createScaleShearXRotateTranslateB2DHomMatrix(
- fHalfLineWidth, fHalfLineWidth,
- 0.0,
- atan2(aTangentB.getY(), aTangentB.getX()) -
F_PI2,
- rEdge.getEndPoint().getX(),
rEdge.getEndPoint().getY()));
- aBezierPolygon.append(aEndPolygon);
- }
- else // bEndSquare
- {
- const basegfx::B2DPoint aEnd(rEdge.getEndPoint() +
(aTangentB * fHalfLineWidth));
-
- if(bCutA)
- {
- aBezierPolygon.append(rEdge.getEndPoint() +
aPerpendEndA);
- }
-
- aBezierPolygon.append(aEnd + aPerpendEndA);
- aBezierPolygon.append(aEnd + aPerpendEndB);
-
- if(bCutB)
- {
- aBezierPolygon.append(rEdge.getEndPoint() +
aPerpendEndB);
- }
- }
- }
- else
- {
- // append original in-between point
- aBezierPolygon.append(rEdge.getEndPoint());
- }
-
- // create lower edge.
- {
- if(bCutB)
- {
- // calculate cut point and add
- aCutPoint = rEdge.getEndPoint() + (aPerpendEndB *
fCutB);
- aBezierPolygon.append(aCutPoint);
- }
- else
- {
- // create scaled bezier segment
- const B2DPoint aStart(rEdge.getEndPoint() +
aPerpendEndB);
- const B2DPoint aEnd(rEdge.getStartPoint() +
aPerpendStartB);
- const B2DVector aEdge(aEnd - aStart);
- const double fLength(aEdge.getLength());
- const double fScale(bIsEdgeLengthZero ? 1.0 : fLength
/ fEdgeLength);
- const B2DVector fRelNext(rEdge.getControlPointB() -
rEdge.getEndPoint());
- const B2DVector fRelPrev(rEdge.getControlPointA() -
rEdge.getStartPoint());
-
- aBezierPolygon.append(aStart);
- aBezierPolygon.appendBezierSegment(aStart + (fRelNext
* fScale), aEnd + (fRelPrev * fScale), aEnd);
- }
- }
-
- // close
- aBezierPolygon.setClosed(true);
-
- if(bStartRound || bEndRound)
- {
- // double points possible when round caps are used at
start or end
- aBezierPolygon.removeDoublePoints();
- }
-
- if(bCut && ((bStartRound || bStartSquare) && (bEndRound ||
bEndSquare)))
- {
- // When cut exists and both ends are extended with caps, a
self-intersecting polygon
- // is created; one cut point is known, but there is a 2nd
one in the caps geometry.
- // Solve by using tooling.
- // Remark: This nearly never happens due to curve
preparations to extreme points
- // and maximum angle turning, but I constructed a test
case and checkd that it is
- // working propery.
- const B2DPolyPolygon
aTemp(tools::solveCrossovers(aBezierPolygon));
- const sal_uInt32 nTempCount(aTemp.count());
-
- if(nTempCount)
- {
- if(nTempCount > 1)
- {
- // as expected, multiple polygons (with same
orientation). Remove
- // the one which contains aCutPoint, or better
take the one without
- for (sal_uInt32 a(0); a < nTempCount; a++)
- {
- aBezierPolygon = aTemp.getB2DPolygon(a);
-
- const sal_uInt32
nCandCount(aBezierPolygon.count());
-
- for(sal_uInt32 b(0); b < nCandCount; b++)
- {
-
if(aCutPoint.equal(aBezierPolygon.getB2DPoint(b)))
- {
- aBezierPolygon.clear();
- break;
- }
- }
-
- if(aBezierPolygon.count())
- {
- break;
- }
- }
-
- OSL_ENSURE(aBezierPolygon.count(), "Error in line
geometry creation, could not solve self-intersection (!)");
- }
- else
- {
- // none found, use result
- aBezierPolygon = aTemp.getB2DPolygon(0);
- }
- }
- else
- {
- OSL_ENSURE(false, "Error in line geometry creation,
could not solve self-intersection (!)");
- }
- }
-
- // return
- return aBezierPolygon;
- }
- else
- {
- // Get start and end point, create tangent and set to needed
length
- B2DVector aTangent(rEdge.getEndPoint() -
rEdge.getStartPoint());
- aTangent.setLength(fHalfLineWidth);
-
- // prepare return value
- B2DPolygon aEdgePolygon;
-
- // buffered angle
- double fAngle(0.0);
- bool bAngle(false);
-
- // buffered perpendicular
- B2DVector aPerpend;
- bool bPerpend(false);
-
- // create left vertical
- if(bStartRound)
- {
- aEdgePolygon = tools::createHalfUnitCircle();
- fAngle = atan2(aTangent.getY(), aTangent.getX());
- bAngle = true;
- aEdgePolygon.transform(
- tools::createScaleShearXRotateTranslateB2DHomMatrix(
- fHalfLineWidth, fHalfLineWidth,
- 0.0,
- fAngle + F_PI2,
- rEdge.getStartPoint().getX(),
rEdge.getStartPoint().getY()));
- }
- else
- {
- aPerpend.setX(-aTangent.getY());
- aPerpend.setY(aTangent.getX());
- bPerpend = true;
-
- if(bStartSquare)
- {
- const basegfx::B2DPoint aStart(rEdge.getStartPoint() -
aTangent);
-
- aEdgePolygon.append(aStart + aPerpend);
- aEdgePolygon.append(aStart - aPerpend);
- }
- else
- {
- aEdgePolygon.append(rEdge.getStartPoint() + aPerpend);
- aEdgePolygon.append(rEdge.getStartPoint()); // keep
the in-between point for numerical reasons
- aEdgePolygon.append(rEdge.getStartPoint() - aPerpend);
- }
- }
-
- // create right vertical
- if(bEndRound)
- {
- basegfx::B2DPolygon
aEndPolygon(tools::createHalfUnitCircle());
-
- if(!bAngle)
- {
- fAngle = atan2(aTangent.getY(), aTangent.getX());
- }
-
- aEndPolygon.transform(
- tools::createScaleShearXRotateTranslateB2DHomMatrix(
- fHalfLineWidth, fHalfLineWidth,
- 0.0,
- fAngle - F_PI2,
- rEdge.getEndPoint().getX(),
rEdge.getEndPoint().getY()));
- aEdgePolygon.append(aEndPolygon);
- }
- else
- {
- if(!bPerpend)
- {
- aPerpend.setX(-aTangent.getY());
- aPerpend.setY(aTangent.getX());
- }
-
- if(bEndSquare)
- {
- const basegfx::B2DPoint aEnd(rEdge.getEndPoint() +
aTangent);
-
- aEdgePolygon.append(aEnd - aPerpend);
- aEdgePolygon.append(aEnd + aPerpend);
- }
- else
- {
- aEdgePolygon.append(rEdge.getEndPoint() - aPerpend);
- aEdgePolygon.append(rEdge.getEndPoint()); // keep the
in-between point for numerical reasons
- aEdgePolygon.append(rEdge.getEndPoint() + aPerpend);
- }
- }
-
- // close and return
- aEdgePolygon.setClosed(true);
-
- return aEdgePolygon;
- }
- }
-
- B2DPolygon createAreaGeometryForJoin(
- const B2DVector& rTangentPrev,
- const B2DVector& rTangentEdge,
- const B2DVector& rPerpendPrev,
- const B2DVector& rPerpendEdge,
- const B2DPoint& rPoint,
- double fHalfLineWidth,
- B2DLineJoin eJoin,
- double fMiterMinimumAngle)
+ aRetval.setClosed(rCandidate.isClosed());
+ aRetval.removeDoublePoints();
+
+ return aRetval;
+ }
+ else
+ {
+ return rCandidate;
+ }
+ }
+
+ B2DPolygon createAreaGeometryForEdge(
+ const B2DCubicBezier& rEdge,
+ double fHalfLineWidth,
+ bool bStartRound,
+ bool bEndRound,
+ bool bStartSquare,
+ bool bEndSquare)
+ {
+ // create polygon for edge
+ // Unfortunately, while it would be geometrically
correct to not add
+ // the in-between points EdgeEnd and EdgeStart, it
leads to rounding
+ // errors when converting to integer polygon
coordinates for painting
+ if(rEdge.isBezier())
+ {
+ // prepare target and data common for upper and
lower
+ B2DPolygon aBezierPolygon;
+ const B2DVector
aPureEdgeVector(rEdge.getEndPoint() - rEdge.getStartPoint());
+ const double
fEdgeLength(aPureEdgeVector.getLength());
+ const bool
bIsEdgeLengthZero(fTools::equalZero(fEdgeLength));
+ B2DVector aTangentA(rEdge.getTangent(0.0));
aTangentA.normalize();
+ B2DVector aTangentB(rEdge.getTangent(1.0));
aTangentB.normalize();
+ const B2DVector
aNormalizedPerpendicularA(getPerpendicular(aTangentA));
+ const B2DVector
aNormalizedPerpendicularB(getPerpendicular(aTangentB));
+
+ // create upper displacement vectors and check
if they cut
+ const B2DVector
aPerpendStartA(aNormalizedPerpendicularA * -fHalfLineWidth);
+ const B2DVector
aPerpendEndA(aNormalizedPerpendicularB * -fHalfLineWidth);
+ double fCutA(0.0);
+ const tools::CutFlagValue aCutA(tools::findCut(
+ rEdge.getStartPoint(), aPerpendStartA,
+ rEdge.getEndPoint(), aPerpendEndA,
+ CUTFLAG_ALL, &fCutA));
+ const bool bCutA(CUTFLAG_NONE != aCutA);
+
+ // create lower displacement vectors and check
if they cut
+ const B2DVector
aPerpendStartB(aNormalizedPerpendicularA * fHalfLineWidth);
+ const B2DVector
aPerpendEndB(aNormalizedPerpendicularB * fHalfLineWidth);
+ double fCutB(0.0);
+ const tools::CutFlagValue aCutB(tools::findCut(
+ rEdge.getEndPoint(), aPerpendEndB,
+ rEdge.getStartPoint(), aPerpendStartB,
+ CUTFLAG_ALL, &fCutB));
+ const bool bCutB(CUTFLAG_NONE != aCutB);
+
+ // check if cut happens
+ const bool bCut(bCutA || bCutB);
+ B2DPoint aCutPoint;
+
+ // create left edge
+ if(bStartRound || bStartSquare)
+ {
+ if(bStartRound)
+ {
+ basegfx::B2DPolygon
aStartPolygon(tools::createHalfUnitCircle());
+
+ aStartPolygon.transform(
+
tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fHalfLineWidth,
fHalfLineWidth,
+ 0.0,
+
atan2(aTangentA.getY(), aTangentA.getX()) + F_PI2,
+
rEdge.getStartPoint().getX(), rEdge.getStartPoint().getY()));
+
aBezierPolygon.append(aStartPolygon);
+ }
+ else // bStartSquare
+ {
+ const basegfx::B2DPoint
aStart(rEdge.getStartPoint() - (aTangentA * fHalfLineWidth));
+
+ if(bCutB)
+ {
+
aBezierPolygon.append(rEdge.getStartPoint() + aPerpendStartB);
+ }
+
+ aBezierPolygon.append(aStart +
aPerpendStartB);
+ aBezierPolygon.append(aStart +
aPerpendStartA);
+
+ if(bCutA)
+ {
+
aBezierPolygon.append(rEdge.getStartPoint() + aPerpendStartA);
+ }
+ }
+ }
+ else
+ {
+ // append original in-between point
+
aBezierPolygon.append(rEdge.getStartPoint());
+ }
+
+ // create upper edge.
+ {
+ if(bCutA)
+ {
+ // calculate cut point and add
+ aCutPoint =
rEdge.getStartPoint() + (aPerpendStartA * fCutA);
+
aBezierPolygon.append(aCutPoint);
+ }
+ else
+ {
+ // create scaled bezier segment
+ const B2DPoint
aStart(rEdge.getStartPoint() + aPerpendStartA);
+ const B2DPoint
aEnd(rEdge.getEndPoint() + aPerpendEndA);
+ const B2DVector aEdge(aEnd -
aStart);
+ const double
fLength(aEdge.getLength());
+ const double
fScale(bIsEdgeLengthZero ? 1.0 : fLength / fEdgeLength);
+ const B2DVector
fRelNext(rEdge.getControlPointA() - rEdge.getStartPoint());
+ const B2DVector
fRelPrev(rEdge.getControlPointB() - rEdge.getEndPoint());
+
+ aBezierPolygon.append(aStart);
+
aBezierPolygon.appendBezierSegment(aStart + (fRelNext * fScale), aEnd +
(fRelPrev * fScale), aEnd);
+ }
+ }
+
+ // create right edge
+ if(bEndRound || bEndSquare)
+ {
+ if(bEndRound)
+ {
+ basegfx::B2DPolygon
aEndPolygon(tools::createHalfUnitCircle());
+
+ aEndPolygon.transform(
+
tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fHalfLineWidth,
fHalfLineWidth,
+ 0.0,
+
atan2(aTangentB.getY(), aTangentB.getX()) - F_PI2,
+
rEdge.getEndPoint().getX(), rEdge.getEndPoint().getY()));
+
aBezierPolygon.append(aEndPolygon);
+ }
+ else // bEndSquare
+ {
+ const basegfx::B2DPoint
aEnd(rEdge.getEndPoint() + (aTangentB * fHalfLineWidth));
+
+ if(bCutA)
+ {
+
aBezierPolygon.append(rEdge.getEndPoint() + aPerpendEndA);
+ }
+
+ aBezierPolygon.append(aEnd +
aPerpendEndA);
+ aBezierPolygon.append(aEnd +
aPerpendEndB);
+
+ if(bCutB)
+ {
+
aBezierPolygon.append(rEdge.getEndPoint() + aPerpendEndB);
+ }
+ }
+ }
+ else
+ {
+ // append original in-between point
+
aBezierPolygon.append(rEdge.getEndPoint());
+ }
+
+ // create lower edge.
+ {
+ if(bCutB)
+ {
+ // calculate cut point and add
+ aCutPoint = rEdge.getEndPoint()
+ (aPerpendEndB * fCutB);
+
aBezierPolygon.append(aCutPoint);
+ }
+ else
+ {
+ // create scaled bezier segment
+ const B2DPoint
aStart(rEdge.getEndPoint() + aPerpendEndB);
+ const B2DPoint
aEnd(rEdge.getStartPoint() + aPerpendStartB);
+ const B2DVector aEdge(aEnd -
aStart);
+ const double
fLength(aEdge.getLength());
+ const double
fScale(bIsEdgeLengthZero ? 1.0 : fLength / fEdgeLength);
+ const B2DVector
fRelNext(rEdge.getControlPointB() - rEdge.getEndPoint());
+ const B2DVector
fRelPrev(rEdge.getControlPointA() - rEdge.getStartPoint());
+
+ aBezierPolygon.append(aStart);
+
aBezierPolygon.appendBezierSegment(aStart + (fRelNext * fScale), aEnd +
(fRelPrev * fScale), aEnd);
+ }
+ }
+
+ // close
+ aBezierPolygon.setClosed(true);
+
+ if(bStartRound || bEndRound)
+ {
+ // double points possible when round
caps are used at start or end
+ aBezierPolygon.removeDoublePoints();
+ }
+
+ if(bCut && ((bStartRound || bStartSquare) &&
(bEndRound || bEndSquare)))
+ {
+ // When cut exists and both ends are
extended with caps, a self-intersecting polygon
+ // is created; one cut point is known,
but there is a 2nd one in the caps geometry.
+ // Solve by using tooling.
+ // Remark: This nearly never happens
due to curve preparations to extreme points
+ // and maximum angle turning, but I
constructed a test case and checked that it is
+ // working properly.
+ const B2DPolyPolygon
aTemp(tools::solveCrossovers(aBezierPolygon));
+ const sal_uInt32
nTempCount(aTemp.count());
+
+ if(nTempCount)
+ {
+ if(nTempCount > 1)
+ {
+ // as expected,
multiple polygons (with same orientation). Remove
+ // the one which
contains aCutPoint, or better take the one without
+ for (sal_uInt32 a(0); a
< nTempCount; a++)
+ {
+ aBezierPolygon
= aTemp.getB2DPolygon(a);
+
+ const
sal_uInt32 nCandCount(aBezierPolygon.count());
+
+ for(sal_uInt32
b(0); b < nCandCount; b++)
+ {
+
if(aCutPoint.equal(aBezierPolygon.getB2DPoint(b)))
+ {
+
aBezierPolygon.clear();
+
break;
+ }
+ }
+
+
if(aBezierPolygon.count())
+ {
+ break;
+ }
+ }
+
+
OSL_ENSURE(aBezierPolygon.count(), "Error in line geometry creation, could not
solve self-intersection (!)");
+ }
+ else
+ {
+ // none found, use
result
+ aBezierPolygon =
aTemp.getB2DPolygon(0);
+ }
+ }
+ else
+ {
+ OSL_ENSURE(false, "Error in
line geometry creation, could not solve self-intersection (!)");
+ }
+ }
+
+ // return
+ return aBezierPolygon;
+ }
+ else
+ {
+ // Get start and end point, create tangent and
set to needed length
+ B2DVector aTangent(rEdge.getEndPoint() -
rEdge.getStartPoint());
+ aTangent.setLength(fHalfLineWidth);
+
+ // prepare return value
+ B2DPolygon aEdgePolygon;
+
+ // buffered angle
+ double fAngle(0.0);
+ bool bAngle(false);
+
+ // buffered perpendicular
+ B2DVector aPerpend;
+ bool bPerpend(false);
+
+ // create left vertical
+ if(bStartRound)
+ {
+ aEdgePolygon =
tools::createHalfUnitCircle();
+ fAngle = atan2(aTangent.getY(),
aTangent.getX());
+ bAngle = true;
+ aEdgePolygon.transform(
+
tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fHalfLineWidth,
fHalfLineWidth,
+ 0.0,
+ fAngle + F_PI2,
+
rEdge.getStartPoint().getX(), rEdge.getStartPoint().getY()));
+ }
+ else
+ {
+ aPerpend.setX(-aTangent.getY());
+ aPerpend.setY(aTangent.getX());
+ bPerpend = true;
+
+ if(bStartSquare)
+ {
+ const basegfx::B2DPoint
aStart(rEdge.getStartPoint() - aTangent);
+
+ aEdgePolygon.append(aStart +
aPerpend);
+ aEdgePolygon.append(aStart -
aPerpend);
+ }
+ else
+ {
+
aEdgePolygon.append(rEdge.getStartPoint() + aPerpend);
+
aEdgePolygon.append(rEdge.getStartPoint()); // keep the in-between point for
numerical reasons
+
aEdgePolygon.append(rEdge.getStartPoint() - aPerpend);
+ }
+ }
+
+ // create right vertical
+ if(bEndRound)
+ {
+ basegfx::B2DPolygon
aEndPolygon(tools::createHalfUnitCircle());
+
+ if(!bAngle)
+ {
+ fAngle = atan2(aTangent.getY(),
aTangent.getX());
+ }
+
+ aEndPolygon.transform(
+
tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fHalfLineWidth,
fHalfLineWidth,
+ 0.0,
+ fAngle - F_PI2,
+
rEdge.getEndPoint().getX(), rEdge.getEndPoint().getY()));
+ aEdgePolygon.append(aEndPolygon);
+ }
+ else
+ {
+ if(!bPerpend)
+ {
+ aPerpend.setX(-aTangent.getY());
+ aPerpend.setY(aTangent.getX());
+ }
+
+ if(bEndSquare)
+ {
+ const basegfx::B2DPoint
aEnd(rEdge.getEndPoint() + aTangent);
+
+ aEdgePolygon.append(aEnd -
aPerpend);
+ aEdgePolygon.append(aEnd +
aPerpend);
+ }
+ else
+ {
+
aEdgePolygon.append(rEdge.getEndPoint() - aPerpend);
+
aEdgePolygon.append(rEdge.getEndPoint()); // keep the in-between point for
numerical reasons
+
aEdgePolygon.append(rEdge.getEndPoint() + aPerpend);
+ }
+ }
+
+ // close and return
+ aEdgePolygon.setClosed(true);
+
+ return aEdgePolygon;
+ }
+ }
+
+ B2DPolygon createAreaGeometryForJoin(
+ const B2DVector& rTangentPrev,
+ const B2DVector& rTangentEdge,
+ const B2DVector& rPerpendPrev,
+ const B2DVector& rPerpendEdge,
+ const B2DPoint& rPoint,
+ double fHalfLineWidth,
+ B2DLineJoin eJoin,
+ double fMiterMinimumAngle)
{
OSL_ENSURE(fHalfLineWidth > 0.0,
"createAreaGeometryForJoin: LineWidth too small (!)");
OSL_ENSURE(B2DLINEJOIN_NONE != eJoin,
"createAreaGeometryForJoin: B2DLINEJOIN_NONE not allowed (!)");
- // LineJoin from tangent rPerpendPrev to tangent rPerpendEdge in
rPoint
- B2DPolygon aEdgePolygon;
+ // LineJoin from tangent rPerpendPrev to tangent
rPerpendEdge in rPoint
+ B2DPolygon aEdgePolygon;
const B2DPoint aStartPoint(rPoint + rPerpendPrev);
const B2DPoint aEndPoint(rPoint + rPerpendEdge);
-
+
// test if for Miter, the angle is too small and the
fallback
// to bevel needs to be used
if(B2DLINEJOIN_MITER == eJoin)
@@ -715,13 +711,13 @@ namespace basegfx
aEdgePolygon.append(aEndPoint);
aEdgePolygon.append(rPoint);
aEdgePolygon.append(aStartPoint);
-
+
// Look for the cut point between start
point along rTangentPrev and
// end point along rTangentEdge.
-rTangentEdge should be used, but since
// the cut value is used for
interpolating along the first edge, the negation
// is not needed since the same fCut
will be found on the first edge.
// If it exists, insert it to complete
the mitered fill polygon.
- double fCutPos(0.0);
+ double fCutPos(0.0);
tools::findCut(aStartPoint,
rTangentPrev, aEndPoint, rTangentEdge, CUTFLAG_ALL, &fCutPos);
if(0.0 != fCutPos)
@@ -729,7 +725,7 @@ namespace basegfx
const B2DPoint
aCutPoint(aStartPoint + (rTangentPrev * fCutPos));
aEdgePolygon.append(aCutPoint);
}
-
+
break;
}
case B2DLINEJOIN_ROUND :
@@ -737,7 +733,7 @@ namespace basegfx
// use tooling to add needed
EllipseSegment
double
fAngleStart(atan2(rPerpendPrev.getY(), rPerpendPrev.getX()));
double
fAngleEnd(atan2(rPerpendEdge.getY(), rPerpendEdge.getX()));
-
+
// atan2 results are [-PI .. PI],
consolidate to [0.0 .. 2PI]
if(fAngleStart < 0.0)
{
@@ -774,206 +770,205 @@ namespace basegfx
aEdgePolygon.append(aEndPoint);
aEdgePolygon.append(rPoint);
aEdgePolygon.append(aStartPoint);
-
+
break;
}
}
- // create last polygon part for edge
- aEdgePolygon.setClosed(true);
+ // create last polygon part for edge
+ aEdgePolygon.setClosed(true);
- return aEdgePolygon;
- }
- } // end of anonymus namespace
+ return aEdgePolygon;
+ }
+ } // end of anonymous namespace
namespace tools
{
- B2DPolyPolygon createAreaGeometry(
- const B2DPolygon& rCandidate,
- double fHalfLineWidth,
- B2DLineJoin eJoin,
- com::sun::star::drawing::LineCap eCap,
- double fMaxAllowedAngle,
+ B2DPolyPolygon createAreaGeometry(
+ const B2DPolygon& rCandidate,
+ double fHalfLineWidth,
+ B2DLineJoin eJoin,
+ com::sun::star::drawing::LineCap eCap,
+ double fMaxAllowedAngle,
double fMaxPartOfEdge,
- double fMiterMinimumAngle)
+ double fMiterMinimumAngle)
{
- if(fMaxAllowedAngle > F_PI2)
- {
- fMaxAllowedAngle = F_PI2;
- }
- else if(fMaxAllowedAngle < 0.01 * F_PI2)
- {
- fMaxAllowedAngle = 0.01 * F_PI2;
- }
-
- if(fMaxPartOfEdge > 1.0)
- {
- fMaxPartOfEdge = 1.0;
- }
- else if(fMaxPartOfEdge < 0.01)
- {
- fMaxPartOfEdge = 0.01;
- }
-
- if(fMiterMinimumAngle > F_PI)
- {
- fMiterMinimumAngle = F_PI;
- }
- else if(fMiterMinimumAngle < 0.01 * F_PI)
- {
- fMiterMinimumAngle = 0.01 * F_PI;
- }
-
- B2DPolygon aCandidate(rCandidate);
- const double fMaxCos(cos(fMaxAllowedAngle));
-
- aCandidate.removeDoublePoints();
- aCandidate = subdivideToSimple(aCandidate, fMaxCos * fMaxCos,
fMaxPartOfEdge * fMaxPartOfEdge);
-
- const sal_uInt32 nPointCount(aCandidate.count());
+ if(fMaxAllowedAngle > F_PI2)
+ {
+ fMaxAllowedAngle = F_PI2;
+ }
+ else if(fMaxAllowedAngle < 0.01 * F_PI2)
+ {
+ fMaxAllowedAngle = 0.01 * F_PI2;
+ }
+
+ if(fMaxPartOfEdge > 1.0)
+ {
+ fMaxPartOfEdge = 1.0;
+ }
+ else if(fMaxPartOfEdge < 0.01)
+ {
+ fMaxPartOfEdge = 0.01;
+ }
+
+ if(fMiterMinimumAngle > F_PI)
+ {
+ fMiterMinimumAngle = F_PI;
+ }
+ else if(fMiterMinimumAngle < 0.01 * F_PI)
+ {
+ fMiterMinimumAngle = 0.01 * F_PI;
+ }
+
+ B2DPolygon aCandidate(rCandidate);
+ const double fMaxCos(cos(fMaxAllowedAngle));
+
+ aCandidate.removeDoublePoints();
+ aCandidate = subdivideToSimple(aCandidate, fMaxCos *
fMaxCos, fMaxPartOfEdge * fMaxPartOfEdge);
+
+ const sal_uInt32 nPointCount(aCandidate.count());
if(nPointCount)
{
- B2DPolyPolygon aRetval;
+ B2DPolyPolygon aRetval;
const bool
bEventuallyCreateLineJoin(B2DLINEJOIN_NONE != eJoin);
- const bool bIsClosed(aCandidate.isClosed());
- const sal_uInt32 nEdgeCount(bIsClosed ? nPointCount :
nPointCount - 1);
- const bool bLineCap(!bIsClosed &&
com::sun::star::drawing::LineCap_BUTT != eCap);
-
- if(nEdgeCount)
- {
- B2DCubicBezier aEdge;
- B2DCubicBezier aPrev;
-
- // prepare edge
- aEdge.setStartPoint(aCandidate.getB2DPoint(0));
-
- if(bIsClosed && bEventuallyCreateLineJoin)
- {
- // prepare previous edge
- const sal_uInt32 nPrevIndex(nPointCount - 1);
-
aPrev.setStartPoint(aCandidate.getB2DPoint(nPrevIndex));
-
aPrev.setControlPointA(aCandidate.getNextControlPoint(nPrevIndex));
-
aPrev.setControlPointB(aCandidate.getPrevControlPoint(0));
- aPrev.setEndPoint(aEdge.getStartPoint());
- }
-
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
- {
- // fill current Edge
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
-
aEdge.setControlPointA(aCandidate.getNextControlPoint(a));
-
aEdge.setControlPointB(aCandidate.getPrevControlPoint(nNextIndex));
- aEdge.setEndPoint(aCandidate.getB2DPoint(nNextIndex));
-
- // check and create linejoin
- if(bEventuallyCreateLineJoin && (bIsClosed || 0 != a))
- {
- B2DVector aTangentPrev(aPrev.getTangent(1.0));
aTangentPrev.normalize();
- B2DVector aTangentEdge(aEdge.getTangent(0.0));
aTangentEdge.normalize();
- B2VectorOrientation
aOrientation(getOrientation(aTangentPrev, aTangentEdge));
-
- if(ORIENTATION_NEUTRAL == aOrientation)
- {
- // they are parallel or empty; if they are
both not zero and point
- // in opposite direction, a half-circle is
needed
- if(!aTangentPrev.equalZero() &&
!aTangentEdge.equalZero())
- {
- const double
fAngle(fabs(aTangentPrev.angle(aTangentEdge)));
-
- if(fTools::equal(fAngle, F_PI))
- {
- // for half-circle production,
fallback to positive
- // orientation
- aOrientation = ORIENTATION_POSITIVE;
- }
- }
- }
-
- if(ORIENTATION_POSITIVE == aOrientation)
- {
- const B2DVector
aPerpendPrev(getPerpendicular(aTangentPrev) * -fHalfLineWidth);
- const B2DVector
aPerpendEdge(getPerpendicular(aTangentEdge) * -fHalfLineWidth);
-
- aRetval.append(
- createAreaGeometryForJoin(
- aTangentPrev,
- aTangentEdge,
- aPerpendPrev,
- aPerpendEdge,
- aEdge.getStartPoint(),
- fHalfLineWidth,
- eJoin,
- fMiterMinimumAngle));
- }
- else if(ORIENTATION_NEGATIVE == aOrientation)
- {
- const B2DVector
aPerpendPrev(getPerpendicular(aTangentPrev) * fHalfLineWidth);
- const B2DVector
aPerpendEdge(getPerpendicular(aTangentEdge) * fHalfLineWidth);
-
- aRetval.append(
- createAreaGeometryForJoin(
- aTangentEdge,
- aTangentPrev,
- aPerpendEdge,
- aPerpendPrev,
- aEdge.getStartPoint(),
- fHalfLineWidth,
- eJoin,
- fMiterMinimumAngle));
- }
- }
-
- // create geometry for edge
- const bool bLast(a + 1 == nEdgeCount);
-
- if(bLineCap)
- {
- const bool bFirst(!a);
-
- aRetval.append(
- createAreaGeometryForEdge(
- aEdge,
- fHalfLineWidth,
- bFirst &&
com::sun::star::drawing::LineCap_ROUND == eCap,
- bLast &&
com::sun::star::drawing::LineCap_ROUND == eCap,
- bFirst &&
com::sun::star::drawing::LineCap_SQUARE == eCap,
- bLast &&
com::sun::star::drawing::LineCap_SQUARE == eCap));
- }
- else
- {
- aRetval.append(
- createAreaGeometryForEdge(
- aEdge,
- fHalfLineWidth,
- false,
- false,
- false,
- false));
- }
-
- // prepare next step
- if(!bLast)
- {
- if(bEventuallyCreateLineJoin)
- {
- aPrev = aEdge;
- }
-
- aEdge.setStartPoint(aEdge.getEndPoint());
- }
- }
- }
-
- return aRetval;
- }
- else
- {
- return B2DPolyPolygon(rCandidate);
- }
- }
- } // end of namespace tools
+ const bool bIsClosed(aCandidate.isClosed());
+ const sal_uInt32 nEdgeCount(bIsClosed ?
nPointCount : nPointCount - 1);
+ const bool bLineCap(!bIsClosed &&
com::sun::star::drawing::LineCap_BUTT != eCap);
+
+ if(nEdgeCount)
+ {
+ B2DCubicBezier aEdge;
+ B2DCubicBezier aPrev;
+
+ // prepare edge
+
aEdge.setStartPoint(aCandidate.getB2DPoint(0));
+
+ if(bIsClosed &&
bEventuallyCreateLineJoin)
+ {
+ // prepare previous edge
+ const sal_uInt32
nPrevIndex(nPointCount - 1);
+
aPrev.setStartPoint(aCandidate.getB2DPoint(nPrevIndex));
+
aPrev.setControlPointA(aCandidate.getNextControlPoint(nPrevIndex));
+
aPrev.setControlPointB(aCandidate.getPrevControlPoint(0));
+
aPrev.setEndPoint(aEdge.getStartPoint());
+ }
+
+ for(sal_uInt32 a(0); a < nEdgeCount;
a++)
+ {
+ // fill current Edge
+ const sal_uInt32 nNextIndex((a
+ 1) % nPointCount);
+
aEdge.setControlPointA(aCandidate.getNextControlPoint(a));
+
aEdge.setControlPointB(aCandidate.getPrevControlPoint(nNextIndex));
+
aEdge.setEndPoint(aCandidate.getB2DPoint(nNextIndex));
+
+ // check and create linejoin
+ if(bEventuallyCreateLineJoin &&
(bIsClosed || 0 != a))
+ {
+ B2DVector
aTangentPrev(aPrev.getTangent(1.0)); aTangentPrev.normalize();
+ B2DVector
aTangentEdge(aEdge.getTangent(0.0)); aTangentEdge.normalize();
+ B2VectorOrientation
aOrientation(getOrientation(aTangentPrev, aTangentEdge));
+
+ if(ORIENTATION_NEUTRAL
== aOrientation)
+ {
+ // they are
parallel or empty; if they are both not zero and point
+ // in
opposite direction, a half-circle is needed
+
if(!aTangentPrev.equalZero() && !aTangentEdge.equalZero())
+ {
+ const
double fAngle(fabs(aTangentPrev.angle(aTangentEdge)));
+
+
if(fTools::equal(fAngle, F_PI))
+ {
+
// for half-circle production, fallback to positive
+
// orientation
+
aOrientation = ORIENTATION_POSITIVE;
+ }
+ }
+ }
+
+ if(ORIENTATION_POSITIVE
== aOrientation)
+ {
+ const B2DVector
aPerpendPrev(getPerpendicular(aTangentPrev) * -fHalfLineWidth);
+ const B2DVector
aPerpendEdge(getPerpendicular(aTangentEdge) * -fHalfLineWidth);
+
+ aRetval.append(
+
createAreaGeometryForJoin(
+
aTangentPrev,
+
aTangentEdge,
+
aPerpendPrev,
+
aPerpendEdge,
+
aEdge.getStartPoint(),
+
fHalfLineWidth,
+
eJoin,
+
fMiterMinimumAngle));
+ }
+ else
if(ORIENTATION_NEGATIVE == aOrientation)
+ {
+ const B2DVector
aPerpendPrev(getPerpendicular(aTangentPrev) * fHalfLineWidth);
+ const B2DVector
aPerpendEdge(getPerpendicular(aTangentEdge) * fHalfLineWidth);
+
+ aRetval.append(
+
createAreaGeometryForJoin(
+
aTangentEdge,
+
aTangentPrev,
+
aPerpendEdge,
+
aPerpendPrev,
+
aEdge.getStartPoint(),
+
fHalfLineWidth,
+
eJoin,
+
fMiterMinimumAngle));
+ }
+ }
+
+ // create geometry for edge
+ const bool bLast(a + 1 ==
nEdgeCount);
+
+ if(bLineCap)
+ {
+ const bool bFirst(!a);
+
+ aRetval.append(
+
createAreaGeometryForEdge(
+ aEdge,
+
fHalfLineWidth,
+ bFirst
&& com::sun::star::drawing::LineCap_ROUND == eCap,
+ bLast
&& com::sun::star::drawing::LineCap_ROUND == eCap,
+ bFirst
&& com::sun::star::drawing::LineCap_SQUARE == eCap,
+ bLast
&& com::sun::star::drawing::LineCap_SQUARE == eCap));
+ }
+ else
+ {
+ aRetval.append(
+
createAreaGeometryForEdge(
+ aEdge,
+
fHalfLineWidth,
+ false,
+ false,
+ false,
+ false));
+ }
+
+ // prepare next step
+ if(!bLast)
+ {
+
if(bEventuallyCreateLineJoin)
+ {
+ aPrev = aEdge;
+ }
+
+
aEdge.setStartPoint(aEdge.getEndPoint());
+ }
+ }
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return B2DPolyPolygon(rCandidate);
+ }
+ }
+ } // end of namespace tools
} // end of namespace basegfx
-//////////////////////////////////////////////////////////////////////////////
-// eof
+/* vim: set noet sw=4 ts=4: */
diff --git a/main/odk/examples/java/Spreadsheet/EuroAdaption.java
b/main/odk/examples/java/Spreadsheet/EuroAdaption.java
index 2f161e641b..6383944450 100644
--- a/main/odk/examples/java/Spreadsheet/EuroAdaption.java
+++ b/main/odk/examples/java/Spreadsheet/EuroAdaption.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* 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
@@ -7,20 +7,18 @@
* 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
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
//***************************************************************************
// comment: Step 1: get the Desktop object from the office
// Step 2: open an empty Calc document
@@ -68,120 +66,120 @@ import com.sun.star.util.XNumberFormatsSupplier;
public class EuroAdaption {
- public static void main(String args[]) {
+ public static void main(String args[]) {
// You need the desktop to create a document
// The getDesktop method does the UNO bootstrapping, gets the
// remote servie manager and the desktop object.
com.sun.star.frame.XDesktop xDesktop = null;
xDesktop = getDesktop();
-
+
// create a sheet document
XSpreadsheetDocument xSheetdocument = null;
xSheetdocument = ( XSpreadsheetDocument ) createSheetdocument(
xDesktop );
System.out.println( "Create a new Spreadsheet" );
-
+
// get the collection of all sheets from the document
XSpreadsheets xSheets = null;
xSheets = (XSpreadsheets) xSheetdocument.getSheets();
-
+
// the Action Interface provides methods to hide actions,
// like inserting data, on a sheet, that increase the performance
XActionLockable xActionInterface = null;
xActionInterface = (XActionLockable) UnoRuntime.queryInterface(
XActionLockable.class, xSheetdocument );
-
+
// lock all actions
xActionInterface.addActionLock();
-
+
com.sun.star.sheet.XSpreadsheet xSheet = null;
try {
// get via the index access the first sheet
XIndexAccess xElements = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, xSheets );
- // specify the first sheet from the spreadsheet
+ // specify the first sheet from the spreadsheet
xSheet = (XSpreadsheet) UnoRuntime.queryInterface(
- XSpreadsheet.class, xElements.getByIndex( 0 ));
+ XSpreadsheet.class, xElements.getByIndex( 0 ));
}
catch( Exception e) {
e.printStackTrace(System.err);
}
-
+
// get the interface to apply and create new numberformats
XNumberFormatsSupplier xNumberFormatSupplier = null;
xNumberFormatSupplier = (XNumberFormatsSupplier)
UnoRuntime.queryInterface(
XNumberFormatsSupplier.class, xSheetdocument );
XNumberFormats xNumberFormats = null;
xNumberFormats = xNumberFormatSupplier.getNumberFormats();
-
+
// insert some example data in a sheet
createExampleData( xSheet, xNumberFormats );
System.out.println( "Insert example data and use the number format
with the currency 'DM'" );
-
+
// Change the currency from the cells from DM to Euro
- Convert( xSheet, xNumberFormats, "DM", "EUR", 1.95583f );
+ Convert( xSheet, xNumberFormats, "DM", "EUR", 1.95583f );
System.out.println( "Change the number format to EUR and divide the
values with the factor 1.95583" );
-
+
// remove all locks, the user see all changes
xActionInterface.removeActionLock();
-
+
System.out.println("done");
System.exit(0);
}
-
-
+
+
public static void Convert( XSpreadsheet xSheet, XNumberFormats
xNumberFormats,
String sOldSymbol, String sNewSymbol,
float fFactor ) {
try {
Locale xLanguage = new Locale();
- xLanguage.Country = "de"; // Germany -> DM
- xLanguage.Language = "de"; // German
-
+ xLanguage.Country = "de"; // Germany -> DM
+ xLanguage.Language = "de"; // German
+
// Numberformat string with sNewSymbol
String sSimple = "0 [$" + sNewSymbol + "]";
// create a number format key with the sNewSymbol
int iSimpleKey = NumberFormat( xNumberFormats, sSimple, xLanguage
);
-
+
// you have to use the FormatSupplier interface to get the
// CellFormat enumeration
XCellFormatRangesSupplier xCellFormatSupplier =
(XCellFormatRangesSupplier)UnoRuntime.queryInterface(
XCellFormatRangesSupplier.class, xSheet );
-
+
// getCellFormatRanges() has the interfaces for the enumeration
XEnumerationAccess xEnumerationAccess =
(XEnumerationAccess)UnoRuntime.queryInterface(
XEnumerationAccess.class,
xCellFormatSupplier.getCellFormatRanges() );
-
+
XEnumeration xRanges = xEnumerationAccess.createEnumeration();
// create an AnyConverter for later use
AnyConverter aAnyConv = new AnyConverter();
-
+
while( xRanges.hasMoreElements() ) {
// the enumeration returns a cellrange
XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(
XCellRange.class, xRanges.nextElement());
-
+
// the PropertySet the get and set the properties from the
cellrange
XPropertySet xCellProp =
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xCellRange );
-
+
// getPropertyValue returns an Object, you have to cast it to
// type that you need
Object oNumberObject = xCellProp.getPropertyValue(
"NumberFormat" );
int iNumberFormat = aAnyConv.toInt(oNumberObject);
-
+
// get the properties from the cellrange numberformat
XPropertySet xFormat = (XPropertySet)
xNumberFormats.getByKey(iNumberFormat );
-
+
short fType =
aAnyConv.toShort(xFormat.getPropertyValue("Type"));
String sCurrencySymbol = aAnyConv.toString(
xFormat.getPropertyValue("CurrencySymbol"));
-
+
// change the numberformat only on cellranges with a
// currency numberformat
if( ( (fType & com.sun.star.util.NumberFormat.CURRENCY) > 0) &&
@@ -197,36 +195,36 @@ public class EuroAdaption {
Locale oLocale = (Locale) aAnyConv.toObject(
new com.sun.star.uno.Type(Locale.class),
xFormat.getPropertyValue("Locale"));
-
+
// create a new numberformat string
String sNew = xNumberFormats.generateFormat( iSimpleKey,
oLocale, bThousandSep, bNegativeRed,
fDecimals, fLeadingZeros );
-
+
// get the NumberKey from the numberformat
int iNewNumberFormat = NumberFormat( xNumberFormats,
sNew, oLocale );
-
+
// set the new numberformat to the cellrange DM->EUR
xCellProp.setPropertyValue( "NumberFormat",
new Integer( iNewNumberFormat
) );
-
+
// interate over all cells from the cellrange with an
// content and use the DM/EUR factor
XCellRangesQuery xCellRangesQuery = (XCellRangesQuery)
UnoRuntime.queryInterface(
XCellRangesQuery.class, xCellRange );
-
+
XSheetCellRanges xSheetCellRanges =
xCellRangesQuery.queryContentCells(
(short) com.sun.star.sheet.CellFlags.VALUE );
-
+
if( xSheetCellRanges.getCount() > 0 ) {
XEnumerationAccess xCellEnumerationAccess =
xSheetCellRanges.getCells();
XEnumeration xCellEnumeration =
xCellEnumerationAccess.createEnumeration();
-
+
while( xCellEnumeration.hasMoreElements() ) {
XCell xCell = (XCell) UnoRuntime.queryInterface(
XCell.class, xCellEnumeration.nextElement());
@@ -240,16 +238,16 @@ public class EuroAdaption {
e.printStackTrace(System.err);
}
}
-
-
+
+
public static int NumberFormat( XNumberFormats xNumberFormat, String
sFormat,
com.sun.star.lang.Locale xLanguage ) {
int nRetKey = 0;
-
+
try {
// exists the numberformat
nRetKey = xNumberFormat.queryKey( sFormat, xLanguage, true );
-
+
// if not, create a new one
if( nRetKey == -1 ) {
nRetKey = xNumberFormat.addNew( sFormat, xLanguage );
@@ -260,37 +258,37 @@ public class EuroAdaption {
catch( Exception e) {
e.printStackTrace(System.err);
}
-
+
return( nRetKey );
}
-
-
+
+
public static void createExampleData( XSpreadsheet xSheet,
XNumberFormats xNumberFormat ) {
-
+
// enter in a cellrange numbers and change the numberformat to DM
XCell xCell = null;
XCellRange xCellRange = null;
-
+
try {
Locale xLanguage = new Locale();
- xLanguage.Country = "de"; // Germany -> DM
- xLanguage.Language = "de"; // German
-
+ xLanguage.Country = "de"; // Germany -> DM
+ xLanguage.Language = "de"; // German
+
// Numberformat string from DM
String sSimple = "0 [$DM]";
-
+
// get the numberformat key
int iNumberFormatKey = NumberFormat(xNumberFormat, sSimple,
xLanguage);
-
+
for( int iCounter=1; iCounter < 10; iCounter++ ) {
// get one cell and insert a number
xCell = xSheet.getCellByPosition( 2, 1 + iCounter );
xCell.setValue( (double) iCounter * 2 );
xCellRange = xSheet.getCellRangeByPosition( 2, 1 + iCounter,
2, 1 + iCounter );
-
- // get the ProperySet from the cell, to change the numberformat
+
+ // get the PropertySet from the cell, to change the
numberformat
XPropertySet xCellProp =
(XPropertySet)UnoRuntime.queryInterface(
XPropertySet.class, xCellRange );
xCellProp.setPropertyValue( "NumberFormat",
@@ -301,17 +299,17 @@ public class EuroAdaption {
e.printStackTrace(System.err);
}
}
-
+
public static XDesktop getDesktop() {
XDesktop xDesktop = null;
XMultiComponentFactory xMCF = null;
-
+
try {
XComponentContext xContext = null;
-
+
// get the remote office component context
xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
-
+
// get the remote office service manager
xMCF = xContext.getServiceManager();
if( xMCF != null ) {
@@ -329,50 +327,50 @@ public class EuroAdaption {
e.printStackTrace(System.err);
System.exit(1);
}
-
-
+
+
return xDesktop;
}
-
-
+
+
public static XSpreadsheetDocument createSheetdocument( XDesktop xDesktop
) {
XSpreadsheetDocument aSheetDocument = null;
-
+
try {
XComponent xComponent = null;
xComponent = CreateNewDocument( xDesktop, "scalc" );
-
+
aSheetDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(
XSpreadsheetDocument.class, xComponent);
}
catch( Exception e) {
e.printStackTrace(System.err);
}
-
+
return aSheetDocument;
}
-
+
protected static XComponent CreateNewDocument( XDesktop xDesktop,
String sDocumentType ) {
String sURL = "private:factory/" + sDocumentType;
-
+
XComponent xComponent = null;
XComponentLoader xComponentLoader = null;
PropertyValue xValues[] = new PropertyValue[1];
PropertyValue xEmptyArgs[] = new PropertyValue[0];
-
+
try {
xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(
XComponentLoader.class, xDesktop );
-
- xComponent = xComponentLoader.loadComponentFromURL(
+
+ xComponent = xComponentLoader.loadComponentFromURL(
sURL, "_blank", 0, xEmptyArgs);
}
catch( Exception e) {
e.printStackTrace(System.err);
}
-
+
return xComponent ;
}
-
+
}
diff --git a/main/ucb/source/ucp/file/prov.hxx
b/main/ucb/source/ucp/file/prov.hxx
index c05f05a758..7bff2266ad 100644
--- a/main/ucb/source/ucp/file/prov.hxx
+++ b/main/ucb/source/ucp/file/prov.hxx
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* 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
@@ -7,20 +7,18 @@
* 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
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
-
-
#ifndef _PROV_HXX_
#define _PROV_HXX_
@@ -42,8 +40,6 @@
// FileProvider
-
-
namespace fileaccess {
// Forward declaration
@@ -54,7 +50,7 @@ namespace fileaccess {
class FileProvider:
public cppu::OWeakObject,
public com::sun::star::lang::XServiceInfo,
- public com::sun::star::lang::XInitialization,
+ public com::sun::star::lang::XInitialization,
public com::sun::star::lang::XTypeProvider,
public com::sun::star::ucb::XContentProvider,
public com::sun::star::ucb::XContentIdentifierFactory,
@@ -112,11 +108,11 @@ namespace fileaccess {
XTYPEPROVIDER_DECL()
- // XInitialization
- virtual void SAL_CALL
- initialize(
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any
>& aArguments )
- throw (::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException);
+ // XInitialization
+ virtual void SAL_CALL
+ initialize(
+ const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception,
::com::sun::star::uno::RuntimeException);
// XContentProvider
@@ -140,7 +136,7 @@ namespace fileaccess {
const com::sun::star::uno::Reference<
com::sun::star::ucb::XContentIdentifier >& Id2 )
throw( com::sun::star::uno::RuntimeException );
- // XProperySet
+ // XPropertySet
virtual com::sun::star::uno::Reference<
com::sun::star::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo( )
@@ -211,9 +207,9 @@ namespace fileaccess {
private:
- // methods
- void SAL_CALL init();
-
+ // methods
+ void SAL_CALL init();
+
// Members
com::sun::star::uno::Reference<
com::sun::star::lang::XMultiServiceFactory > m_xMultiServiceFactory;
@@ -228,6 +224,8 @@ namespace fileaccess {
shell*
m_pMyShell;
};
-} // end namespace fileaccess
+} // end namespace fileaccess
#endif
+
+/* vim: set noet sw=4 ts=4: */