Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
8bd81a65
Kaydet (Commit)
8bd81a65
authored
Agu 13, 2014
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Extract code block into its own method.
Change-Id: I4cb450afee9200ce749356b6a4bda8f046da305f
üst
0c830d89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
59 deletions
+81
-59
PieChart.cxx
chart2/source/view/charttypes/PieChart.cxx
+74
-59
PieChart.hxx
chart2/source/view/charttypes/PieChart.hxx
+7
-0
No files found.
chart2/source/view/charttypes/PieChart.cxx
Dosyayı görüntüle @
8bd81a65
...
...
@@ -202,6 +202,75 @@ uno::Reference< drawing::XShape > PieChart::createDataPoint(
return
xShape
;
}
void
PieChart
::
createTextLabelShape
(
const
uno
::
Reference
<
drawing
::
XShapes
>&
xTextTarget
,
VDataSeries
&
rSeries
,
sal_Int32
nPointIndex
,
double
fUnitCircleStartAngleDegree
,
double
fUnitCircleWidthAngleDegree
,
double
fUnitCircleOuterRadius
,
double
fUnitCircleInnerRadius
,
double
fExplodePercentage
,
double
fLogicYSum
,
double
fLogicZ
)
{
if
(
!
rSeries
.
getDataPointLabelIfLabel
(
nPointIndex
))
return
;
if
(
!::
rtl
::
math
::
approxEqual
(
fExplodePercentage
,
0.0
)
)
{
double
fExplodeOffset
=
(
fUnitCircleOuterRadius
-
fUnitCircleInnerRadius
)
*
fExplodePercentage
;
fUnitCircleInnerRadius
+=
fExplodeOffset
;
fUnitCircleOuterRadius
+=
fExplodeOffset
;
}
sal_Int32
nLabelPlacement
=
rSeries
.
getLabelPlacement
(
nPointIndex
,
m_xChartTypeModel
,
m_nDimension
,
m_pPosHelper
->
isSwapXAndY
());
// AVOID_OVERLAP is in fact "Best fit" in the UI.
bool
bMovementAllowed
=
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
AVOID_OVERLAP
);
if
(
bMovementAllowed
)
// Use center for "Best fit" for now. In the future we
// may want to implement a real best fit algorithm.
// But center is good enough, and close to what Excel
// does.
nLabelPlacement
=
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
CENTER
;
LabelAlignment
eAlignment
(
LABEL_ALIGN_CENTER
);
sal_Int32
nScreenValueOffsetInRadiusDirection
=
0
;
if
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
OUTSIDE
)
nScreenValueOffsetInRadiusDirection
=
(
3
!=
m_nDimension
)
?
150
:
0
;
//todo maybe calculate this font height dependent
else
if
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
INSIDE
)
nScreenValueOffsetInRadiusDirection
=
(
3
!=
m_nDimension
)
?
-
150
:
0
;
//todo maybe calculate this font height dependent
PolarLabelPositionHelper
aPolarPosHelper
(
m_pPosHelper
,
m_nDimension
,
m_xLogicTarget
,
m_pShapeFactory
);
awt
::
Point
aScreenPosition2D
(
aPolarPosHelper
.
getLabelScreenPositionAndAlignmentForUnitCircleValues
(
eAlignment
,
nLabelPlacement
,
fUnitCircleStartAngleDegree
,
fUnitCircleWidthAngleDegree
,
fUnitCircleInnerRadius
,
fUnitCircleOuterRadius
,
fLogicZ
+
0.5
,
0
));
PieLabelInfo
aPieLabelInfo
;
aPieLabelInfo
.
aFirstPosition
=
basegfx
::
B2IVector
(
aScreenPosition2D
.
X
,
aScreenPosition2D
.
Y
);
awt
::
Point
aOrigin
(
aPolarPosHelper
.
transformSceneToScreenPosition
(
m_pPosHelper
->
transformUnitCircleToScene
(
0.0
,
0.0
,
fLogicZ
+
1.0
)
)
);
aPieLabelInfo
.
aOrigin
=
basegfx
::
B2IVector
(
aOrigin
.
X
,
aOrigin
.
Y
);
//add a scaling independent Offset if requested
if
(
nScreenValueOffsetInRadiusDirection
!=
0
)
{
basegfx
::
B2IVector
aDirection
(
aScreenPosition2D
.
X
-
aOrigin
.
X
,
aScreenPosition2D
.
Y
-
aOrigin
.
Y
);
aDirection
.
setLength
(
nScreenValueOffsetInRadiusDirection
);
aScreenPosition2D
.
X
+=
aDirection
.
getX
();
aScreenPosition2D
.
Y
+=
aDirection
.
getY
();
}
double
nVal
=
rSeries
.
getYValue
(
nPointIndex
);
aPieLabelInfo
.
xTextShape
=
createDataLabel
(
xTextTarget
,
rSeries
,
nPointIndex
,
nVal
,
fLogicYSum
,
aScreenPosition2D
,
eAlignment
);
uno
::
Reference
<
container
::
XChild
>
xChild
(
aPieLabelInfo
.
xTextShape
,
uno
::
UNO_QUERY
);
if
(
xChild
.
is
()
)
aPieLabelInfo
.
xLabelGroupShape
=
uno
::
Reference
<
drawing
::
XShape
>
(
xChild
->
getParent
(),
uno
::
UNO_QUERY
);
aPieLabelInfo
.
fValue
=
nVal
;
aPieLabelInfo
.
bMovementAllowed
=
bMovementAllowed
;
aPieLabelInfo
.
bMoved
=
false
;
aPieLabelInfo
.
xTextTarget
=
xTextTarget
;
m_aLabelInfoList
.
push_back
(
aPieLabelInfo
);
}
void
PieChart
::
addSeries
(
VDataSeries
*
pSeries
,
sal_Int32
/* zSlot */
,
sal_Int32
/* xSlot */
,
sal_Int32
/* ySlot */
)
{
VSeriesPlotter
::
addSeries
(
pSeries
,
0
,
-
1
,
0
);
...
...
@@ -445,65 +514,11 @@ void PieChart::createShapes()
}
//create label
if
(
pSeries
->
getDataPointLabelIfLabel
(
nPointIndex
)
)
{
if
(
!::
rtl
::
math
::
approxEqual
(
fExplodePercentage
,
0.0
)
)
{
double
fExplodeOffset
=
(
fUnitCircleOuterRadius
-
fUnitCircleInnerRadius
)
*
fExplodePercentage
;
fUnitCircleInnerRadius
+=
fExplodeOffset
;
fUnitCircleOuterRadius
+=
fExplodeOffset
;
}
sal_Int32
nLabelPlacement
=
pSeries
->
getLabelPlacement
(
nPointIndex
,
m_xChartTypeModel
,
m_nDimension
,
m_pPosHelper
->
isSwapXAndY
()
);
// AVOID_OVERLAP is in fact "Best fit" in the UI.
bool
bMovementAllowed
=
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
AVOID_OVERLAP
);
if
(
bMovementAllowed
)
// Use center for "Best fit" for now. In the future we
// may want to implement a real best fit algorithm.
// But center is good enough, and close to what Excel
// does.
nLabelPlacement
=
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
CENTER
;
LabelAlignment
eAlignment
(
LABEL_ALIGN_CENTER
);
sal_Int32
nScreenValueOffsetInRadiusDirection
=
0
;
if
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
OUTSIDE
)
nScreenValueOffsetInRadiusDirection
=
(
3
!=
m_nDimension
)
?
150
:
0
;
//todo maybe calculate this font height dependent
else
if
(
nLabelPlacement
==
::
com
::
sun
::
star
::
chart
::
DataLabelPlacement
::
INSIDE
)
nScreenValueOffsetInRadiusDirection
=
(
3
!=
m_nDimension
)
?
-
150
:
0
;
//todo maybe calculate this font height dependent
PolarLabelPositionHelper
aPolarPosHelper
(
m_pPosHelper
,
m_nDimension
,
m_xLogicTarget
,
m_pShapeFactory
);
awt
::
Point
aScreenPosition2D
(
aPolarPosHelper
.
getLabelScreenPositionAndAlignmentForUnitCircleValues
(
eAlignment
,
nLabelPlacement
,
fUnitCircleStartAngleDegree
,
fUnitCircleWidthAngleDegree
,
fUnitCircleInnerRadius
,
fUnitCircleOuterRadius
,
fLogicZ
+
0.5
,
0
));
PieLabelInfo
aPieLabelInfo
;
aPieLabelInfo
.
aFirstPosition
=
basegfx
::
B2IVector
(
aScreenPosition2D
.
X
,
aScreenPosition2D
.
Y
);
awt
::
Point
aOrigin
(
aPolarPosHelper
.
transformSceneToScreenPosition
(
m_pPosHelper
->
transformUnitCircleToScene
(
0.0
,
0.0
,
fLogicZ
+
1.0
)
)
);
aPieLabelInfo
.
aOrigin
=
basegfx
::
B2IVector
(
aOrigin
.
X
,
aOrigin
.
Y
);
//add a scaling independent Offset if requested
if
(
nScreenValueOffsetInRadiusDirection
!=
0
)
{
basegfx
::
B2IVector
aDirection
(
aScreenPosition2D
.
X
-
aOrigin
.
X
,
aScreenPosition2D
.
Y
-
aOrigin
.
Y
);
aDirection
.
setLength
(
nScreenValueOffsetInRadiusDirection
);
aScreenPosition2D
.
X
+=
aDirection
.
getX
();
aScreenPosition2D
.
Y
+=
aDirection
.
getY
();
}
double
nVal
=
pSeries
->
getYValue
(
nPointIndex
);
aPieLabelInfo
.
xTextShape
=
createDataLabel
(
xTextTarget
,
*
pSeries
,
nPointIndex
,
nVal
,
fLogicYSum
,
aScreenPosition2D
,
eAlignment
);
uno
::
Reference
<
container
::
XChild
>
xChild
(
aPieLabelInfo
.
xTextShape
,
uno
::
UNO_QUERY
);
if
(
xChild
.
is
()
)
aPieLabelInfo
.
xLabelGroupShape
=
uno
::
Reference
<
drawing
::
XShape
>
(
xChild
->
getParent
(),
uno
::
UNO_QUERY
);
aPieLabelInfo
.
fValue
=
nVal
;
aPieLabelInfo
.
bMovementAllowed
=
bMovementAllowed
;
aPieLabelInfo
.
bMoved
=
false
;
aPieLabelInfo
.
xTextTarget
=
xTextTarget
;
m_aLabelInfoList
.
push_back
(
aPieLabelInfo
);
}
createTextLabelShape
(
xTextTarget
,
*
pSeries
,
nPointIndex
,
fUnitCircleStartAngleDegree
,
fUnitCircleWidthAngleDegree
,
fUnitCircleOuterRadius
,
fUnitCircleInnerRadius
,
fExplodePercentage
,
fLogicYSum
,
fLogicZ
);
if
(
!
bDoExplode
)
{
...
...
chart2/source/view/charttypes/PieChart.hxx
Dosyayı görüntüle @
8bd81a65
...
...
@@ -73,6 +73,13 @@ private: //methods
,
double
fLogicZ
,
double
fDepth
,
double
fExplodePercentage
,
tPropertyNameValueMap
*
pOverWritePropertiesMap
);
void
createTextLabelShape
(
const
css
::
uno
::
Reference
<
css
::
drawing
::
XShapes
>&
xTextTarget
,
VDataSeries
&
rSeries
,
sal_Int32
nPointIndex
,
double
fUnitCircleStartAngleDegree
,
double
fUnitCircleWidthAngleDegree
,
double
fUnitCircleOuterRadius
,
double
fUnitCircleInnerRadius
,
double
fExplodePercentage
,
double
fLogicYSum
,
double
fLogicZ
);
double
getMaxOffset
();
bool
detectLabelOverlapsAndMove
(
const
::
com
::
sun
::
star
::
awt
::
Size
&
rPageSize
);
//returns true when there might be more to do
void
resetLabelPositionsToPreviousState
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment