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
13d92726
Kaydet (Commit)
13d92726
authored
Kas 05, 2015
tarafından
Matteo Casalin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
(Poly)Polygons: sal_uIntPtr to sal_uInt32/sdt::size_t/enum
Change-Id: I167d656f419ddbeb72960b8510fb8084605d4d5c
üst
48a33590
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
37 deletions
+42
-37
poly.hxx
include/tools/poly.hxx
+8
-2
poly.h
tools/inc/poly.h
+2
-2
poly.cxx
tools/source/generic/poly.cxx
+23
-19
poly2.cxx
tools/source/generic/poly2.cxx
+9
-14
No files found.
include/tools/poly.hxx
Dosyayı görüntüle @
13d92726
...
...
@@ -89,7 +89,7 @@ public:
const
sal_uInt8
*
pFlagAry
=
NULL
);
Polygon
(
const
Rectangle
&
rRect
);
Polygon
(
const
Rectangle
&
rRect
,
sal_uInt
Ptr
nHorzRound
,
sal_uIntPtr
nVertRound
);
sal_uInt
32
nHorzRound
,
sal_uInt32
nVertRound
);
Polygon
(
const
Point
&
rCenter
,
long
nRadX
,
long
nRadY
,
sal_uInt16
nPoints
=
0
);
...
...
@@ -190,7 +190,13 @@ class TOOLS_DLLPUBLIC SAL_WARN_UNUSED PolyPolygon
private
:
ImplPolyPolygon
*
mpImplPolyPolygon
;
TOOLS_DLLPRIVATE
void
ImplDoOperation
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
,
sal_uIntPtr
nOperation
)
const
;
enum
class
PolyClipOp
{
INTERSECT
,
UNION
,
DIFF
,
XOR
};
TOOLS_DLLPRIVATE
void
ImplDoOperation
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
,
PolyClipOp
nOperation
)
const
;
public
:
PolyPolygon
(
sal_uInt16
nInitSize
=
16
,
sal_uInt16
nResize
=
16
);
...
...
tools/inc/poly.h
Dosyayı görüntüle @
13d92726
...
...
@@ -29,7 +29,7 @@ public:
Point
*
mpPointAry
;
sal_uInt8
*
mpFlagAry
;
sal_uInt16
mnPoints
;
sal_uInt
Ptr
mnRefCount
;
sal_uInt
32
mnRefCount
;
};
class
SAL_WARN_UNUSED
ImplPolygon
:
public
ImplPolygonData
...
...
@@ -55,7 +55,7 @@ class SAL_WARN_UNUSED ImplPolyPolygon
{
public
:
tools
::
Polygon
**
mpPolyAry
;
sal_uInt
Ptr
mnRefCount
;
sal_uInt
32
mnRefCount
;
sal_uInt16
mnCount
;
sal_uInt16
mnSize
;
sal_uInt16
mnResize
;
...
...
tools/source/generic/poly.cxx
Dosyayı görüntüle @
13d92726
...
...
@@ -62,8 +62,9 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, bool bFlags )
{
if
(
nInitSize
)
{
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[(
sal_uIntPtr
)
nInitSize
*
sizeof
(
Point
)]);
memset
(
mpPointAry
,
0
,
(
sal_uIntPtr
)
nInitSize
*
sizeof
(
Point
)
);
const
std
::
size_t
nSz
(
static_cast
<
std
::
size_t
>
(
nInitSize
)
*
sizeof
(
Point
));
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
nSz
]);
memset
(
mpPointAry
,
0
,
nSz
);
}
else
mpPointAry
=
NULL
;
...
...
@@ -84,8 +85,9 @@ ImplPolygon::ImplPolygon( const ImplPolygon& rImpPoly )
{
if
(
rImpPoly
.
mnPoints
)
{
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[(
sal_uIntPtr
)
rImpPoly
.
mnPoints
*
sizeof
(
Point
)]);
memcpy
(
mpPointAry
,
rImpPoly
.
mpPointAry
,
(
sal_uIntPtr
)
rImpPoly
.
mnPoints
*
sizeof
(
Point
)
);
const
std
::
size_t
nSz
(
static_cast
<
std
::
size_t
>
(
rImpPoly
.
mnPoints
)
*
sizeof
(
Point
));
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
nSz
]);
memcpy
(
mpPointAry
,
rImpPoly
.
mpPointAry
,
nSz
);
if
(
rImpPoly
.
mpFlagAry
)
{
...
...
@@ -109,8 +111,9 @@ ImplPolygon::ImplPolygon( sal_uInt16 nInitSize, const Point* pInitAry, const sal
{
if
(
nInitSize
)
{
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[(
sal_uIntPtr
)
nInitSize
*
sizeof
(
Point
)]);
memcpy
(
mpPointAry
,
pInitAry
,
(
sal_uIntPtr
)
nInitSize
*
sizeof
(
Point
)
);
const
std
::
size_t
nSz
(
static_cast
<
std
::
size_t
>
(
nInitSize
)
*
sizeof
(
Point
));
mpPointAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
nSz
]);
memcpy
(
mpPointAry
,
pInitAry
,
nSz
);
if
(
pInitFlags
)
{
...
...
@@ -150,7 +153,8 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
if
(
nNewSize
)
{
pNewAry
=
reinterpret_cast
<
Point
*>
(
new
char
[(
sal_uIntPtr
)
nNewSize
*
sizeof
(
Point
)]);
const
std
::
size_t
nNewSz
(
static_cast
<
std
::
size_t
>
(
nNewSize
)
*
sizeof
(
Point
));
pNewAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
nNewSz
]);
if
(
bResize
)
{
...
...
@@ -158,14 +162,15 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
if
(
mnPoints
<
nNewSize
)
{
// New points initialized to zero
memset
(
pNewAry
+
mnPoints
,
0
,
(
sal_uIntPtr
)(
nNewSize
-
mnPoints
)
*
sizeof
(
Point
)
);
const
std
::
size_t
nOldSz
(
static_cast
<
std
::
size_t
>
(
mnPoints
)
*
sizeof
(
Point
));
memset
(
pNewAry
+
mnPoints
,
0
,
nNewSz
-
nOldSz
);
if
(
mpPointAry
)
memcpy
(
pNewAry
,
mpPointAry
,
mnPoints
*
sizeof
(
Point
)
);
memcpy
(
pNewAry
,
mpPointAry
,
nOldSz
);
}
else
{
if
(
mpPointAry
)
memcpy
(
pNewAry
,
mpPointAry
,
(
sal_uIntPtr
)
nNewSize
*
sizeof
(
Point
)
);
memcpy
(
pNewAry
,
mpPointAry
,
nNewSz
);
}
}
}
...
...
@@ -210,13 +215,12 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize )
void
ImplPolygon
::
ImplSplit
(
sal_uInt16
nPos
,
sal_uInt16
nSpace
,
ImplPolygon
*
pInitPoly
)
{
const
sal_uIntPtr
nSpaceSize
=
nSpace
*
sizeof
(
Point
);
//Can't fit this in :-(, throw ?
if
(
mnPoints
+
nSpace
>
USHRT_MAX
)
return
;
const
sal_uInt16
nNewSize
=
mnPoints
+
nSpace
;
const
std
::
size_t
nSpaceSize
=
static_cast
<
std
::
size_t
>
(
nSpace
)
*
sizeof
(
Point
);
if
(
nPos
>=
mnPoints
)
{
...
...
@@ -237,7 +241,7 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI
const
sal_uInt16
nSecPos
=
nPos
+
nSpace
;
const
sal_uInt16
nRest
=
mnPoints
-
nPos
;
Point
*
pNewAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
(
sal_uIntPtr
)
nNewSize
*
sizeof
(
Point
)
]);
Point
*
pNewAry
=
reinterpret_cast
<
Point
*>
(
new
char
[
static_cast
<
std
::
size_t
>
(
nNewSize
)
*
sizeof
(
Point
)
]);
memcpy
(
pNewAry
,
mpPointAry
,
nPos
*
sizeof
(
Point
)
);
...
...
@@ -542,7 +546,7 @@ Polygon::Polygon( sal_uInt16 nPoints, const Point* pPtAry, const sal_uInt8* pFla
Polygon
::
Polygon
(
const
tools
::
Polygon
&
rPoly
)
{
DBG_ASSERT
(
rPoly
.
mpImplPolygon
->
mnRefCount
<
0xFFFFFFFE
,
"Polygon: RefCount overflow"
);
DBG_ASSERT
(
rPoly
.
mpImplPolygon
->
mnRefCount
<
(
SAL_MAX_UINT32
-
1
)
,
"Polygon: RefCount overflow"
);
mpImplPolygon
=
rPoly
.
mpImplPolygon
;
if
(
mpImplPolygon
->
mnRefCount
)
...
...
@@ -565,7 +569,7 @@ Polygon::Polygon( const Rectangle& rRect )
}
}
Polygon
::
Polygon
(
const
Rectangle
&
rRect
,
sal_uInt
Ptr
nHorzRound
,
sal_uIntPtr
nVertRound
)
Polygon
::
Polygon
(
const
Rectangle
&
rRect
,
sal_uInt
32
nHorzRound
,
sal_uInt32
nVertRound
)
{
if
(
rRect
.
IsEmpty
()
)
mpImplPolygon
=
static_cast
<
ImplPolygon
*>
(
&
aStaticImplPolygon
);
...
...
@@ -574,8 +578,8 @@ Polygon::Polygon( const Rectangle& rRect, sal_uIntPtr nHorzRound, sal_uIntPtr nV
Rectangle
aRect
(
rRect
);
aRect
.
Justify
();
// SJ: i9140
nHorzRound
=
std
::
min
(
nHorzRound
,
(
sal_uIntPtr
)
labs
(
aRect
.
GetWidth
()
>>
1
)
);
nVertRound
=
std
::
min
(
nVertRound
,
(
sal_uIntPtr
)
labs
(
aRect
.
GetHeight
()
>>
1
)
);
nHorzRound
=
std
::
min
(
nHorzRound
,
static_cast
<
sal_uInt32
>
(
labs
(
aRect
.
GetWidth
()
>>
1
)
)
);
nVertRound
=
std
::
min
(
nVertRound
,
static_cast
<
sal_uInt32
>
(
labs
(
aRect
.
GetHeight
()
>>
1
)
)
);
if
(
!
nHorzRound
&&
!
nVertRound
)
{
...
...
@@ -925,7 +929,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
{
tools
::
Polygon
aNewPoly
;
const
Point
&
rFirst
=
mpImplPolygon
->
mpPointAry
[
0
];
const
sal_uIntPtr
nReduce
=
(
nOptimizeFlags
&
PolyOptimizeFlags
::
REDUCE
)
?
4
:
0
;
const
long
nReduce
=
(
nOptimizeFlags
&
PolyOptimizeFlags
::
REDUCE
)
?
4
:
0
;
while
(
nSize
&&
(
mpImplPolygon
->
mpPointAry
[
nSize
-
1
]
==
rFirst
)
)
nSize
--
;
...
...
@@ -940,7 +944,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
for
(
sal_uInt16
i
=
1
;
i
<
nSize
;
i
++
)
{
if
(
(
mpImplPolygon
->
mpPointAry
[
i
]
!=
mpImplPolygon
->
mpPointAry
[
nLast
]
)
&&
(
!
nReduce
||
(
nReduce
<
(
sal_uIntPtr
)
FRound
(
CalcDistance
(
nLast
,
i
)
)
)
)
)
(
!
nReduce
||
(
nReduce
<
FRound
(
CalcDistance
(
nLast
,
i
)
)
)
)
)
{
aNewPoly
[
nNewCount
++
]
=
mpImplPolygon
->
mpPointAry
[
nLast
=
i
];
}
...
...
tools/source/generic/poly2.cxx
Dosyayı görüntüle @
13d92726
...
...
@@ -17,11 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#define POLY_CLIP_INT 0
#define POLY_CLIP_UNION 1
#define POLY_CLIP_DIFF 2
#define POLY_CLIP_XOR 3
#include <rtl/math.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
...
...
@@ -99,7 +94,7 @@ PolyPolygon::PolyPolygon( const tools::Polygon& rPoly )
PolyPolygon
::
PolyPolygon
(
const
tools
::
PolyPolygon
&
rPolyPoly
)
{
DBG_ASSERT
(
rPolyPoly
.
mpImplPolyPolygon
->
mnRefCount
<
0xFFFFFFFE
,
"PolyPolygon: RefCount overflow"
);
DBG_ASSERT
(
rPolyPoly
.
mpImplPolyPolygon
->
mnRefCount
<
(
SAL_MAX_UINT32
-
1
)
,
"PolyPolygon: RefCount overflow"
);
mpImplPolyPolygon
=
rPolyPoly
.
mpImplPolyPolygon
;
mpImplPolyPolygon
->
mnRefCount
++
;
...
...
@@ -312,15 +307,15 @@ tools::PolyPolygon PolyPolygon::SubdivideBezier( const tools::PolyPolygon& rPoly
void
PolyPolygon
::
GetIntersection
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
)
const
{
ImplDoOperation
(
rPolyPoly
,
rResult
,
P
OLY_CLIP_IN
T
);
ImplDoOperation
(
rPolyPoly
,
rResult
,
P
olyClipOp
::
INTERSEC
T
);
}
void
PolyPolygon
::
GetUnion
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
)
const
{
ImplDoOperation
(
rPolyPoly
,
rResult
,
P
OLY_CLIP_
UNION
);
ImplDoOperation
(
rPolyPoly
,
rResult
,
P
olyClipOp
::
UNION
);
}
void
PolyPolygon
::
ImplDoOperation
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
,
sal_uIntPtr
nOperation
)
const
void
PolyPolygon
::
ImplDoOperation
(
const
tools
::
PolyPolygon
&
rPolyPoly
,
tools
::
PolyPolygon
&
rResult
,
PolyClipOp
nOperation
)
const
{
// Convert to B2DPolyPolygon, temporarily. It might be
// advantageous in the future, to have a tools::PolyPolygon adaptor that
...
...
@@ -337,21 +332,21 @@ void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::P
{
// All code extracted from svx/source/svdraw/svedtv2.cxx
case
P
OLY_CLIP_
UNION
:
case
P
olyClipOp
:
:
UNION
:
{
// merge A and B (OR)
aMergePolyPolygonA
=
basegfx
::
tools
::
solvePolygonOperationOr
(
aMergePolyPolygonA
,
aMergePolyPolygonB
);
break
;
}
case
P
OLY_CLIP_
DIFF
:
case
P
olyClipOp
:
:
DIFF
:
{
// subtract B from A (DIFF)
aMergePolyPolygonA
=
basegfx
::
tools
::
solvePolygonOperationDiff
(
aMergePolyPolygonA
,
aMergePolyPolygonB
);
break
;
}
case
P
OLY_CLIP_
XOR
:
case
P
olyClipOp
:
:
XOR
:
{
// compute XOR between poly A and B
aMergePolyPolygonA
=
basegfx
::
tools
::
solvePolygonOperationXor
(
aMergePolyPolygonA
,
aMergePolyPolygonB
);
...
...
@@ -359,7 +354,7 @@ void PolyPolygon::ImplDoOperation( const tools::PolyPolygon& rPolyPoly, tools::P
}
default
:
case
P
OLY_CLIP_IN
T
:
case
P
olyClipOp
:
:
INTERSEC
T
:
{
// cut poly 1 against polys 2..n (AND)
aMergePolyPolygonA
=
basegfx
::
tools
::
solvePolygonOperationAnd
(
aMergePolyPolygonA
,
aMergePolyPolygonB
);
...
...
@@ -528,7 +523,7 @@ PolyPolygon& PolyPolygon::operator=( const tools::PolyPolygon& rPolyPoly )
if
(
this
==
&
rPolyPoly
)
return
*
this
;
DBG_ASSERT
(
rPolyPoly
.
mpImplPolyPolygon
->
mnRefCount
<
0xFFFFFFFE
,
"PolyPolygon: RefCount overflow"
);
DBG_ASSERT
(
rPolyPoly
.
mpImplPolyPolygon
->
mnRefCount
<
(
SAL_MAX_UINT32
-
1
)
,
"PolyPolygon: RefCount overflow"
);
rPolyPoly
.
mpImplPolyPolygon
->
mnRefCount
++
;
...
...
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