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
003434f1
Kaydet (Commit)
003434f1
authored
Tem 15, 2014
tarafından
Jan Holesovsky
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fdo#76803: Kill resourcemodel::Fraction, and use Fraction from tools instead.
Change-Id: I72d336b8aacf80f9ab6472c0948766ee56fda34f
üst
3a2010c7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
227 deletions
+12
-227
Library_writerfilter.mk
writerfilter/Library_writerfilter.mk
+0
-1
Fraction.hxx
writerfilter/inc/resourcemodel/Fraction.hxx
+0
-54
misc.cxx
writerfilter/qa/cppunittests/misc/misc.cxx
+0
-17
WrapPolygonHandler.cxx
writerfilter/source/dmapper/WrapPolygonHandler.cxx
+10
-10
WrapPolygonHandler.hxx
writerfilter/source/dmapper/WrapPolygonHandler.hxx
+2
-2
Fraction.cxx
writerfilter/source/resourcemodel/Fraction.cxx
+0
-143
No files found.
writerfilter/Library_writerfilter.mk
Dosyayı görüntüle @
003434f1
...
...
@@ -121,7 +121,6 @@ $(eval $(call gb_Library_add_exception_objects,writerfilter,\
writerfilter/source/ooxml/OOXMLParserState \
writerfilter/source/ooxml/OOXMLPropertySetImpl \
writerfilter/source/ooxml/OOXMLStreamImpl \
writerfilter/source/resourcemodel/Fraction \
writerfilter/source/resourcemodel/LoggedResources \
writerfilter/source/resourcemodel/ResourceModelHelper \
writerfilter/source/resourcemodel/TagLogger \
...
...
writerfilter/inc/resourcemodel/Fraction.hxx
deleted
100644 → 0
Dosyayı görüntüle @
3a2010c7
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* 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 regarding copyright
* ownership. The ASF licenses this file 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 .
*/
#ifndef INCLUDED_WRITERFILTER_INC_RESOURCEMODEL_FRACTION_HXX
#define INCLUDED_WRITERFILTER_INC_RESOURCEMODEL_FRACTION_HXX
#include <sal/types.h>
namespace
writerfilter
{
namespace
resourcemodel
{
class
Fraction
{
public
:
explicit
Fraction
(
sal_Int32
nNumerator
,
sal_Int32
nDenominator
=
1
);
virtual
~
Fraction
();
void
init
(
sal_Int32
nNumerator
,
sal_Int32
nDenominator
);
void
assign
(
const
Fraction
&
rFraction
);
Fraction
inverse
()
const
;
Fraction
operator
=
(
const
Fraction
&
rFraction
);
Fraction
operator
+
(
const
Fraction
&
rFraction
)
const
;
Fraction
operator
-
(
const
Fraction
&
rFraction
)
const
;
Fraction
operator
*
(
const
Fraction
&
rFraction
)
const
;
Fraction
operator
/
(
const
Fraction
&
rFraction
)
const
;
operator
sal_Int32
()
const
;
operator
float
()
const
;
private
:
sal_Int32
mnNumerator
;
sal_Int32
mnDenominator
;
};
}}
#endif // INCLUDED_WRITERFILTER_INC_RESOURCEMODEL_FRACTION_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
writerfilter/qa/cppunittests/misc/misc.cxx
Dosyayı görüntüle @
003434f1
...
...
@@ -22,10 +22,6 @@
#include <rtl/ustring.hxx>
#include <dmapper/ConversionHelper.hxx>
#include <dmapper/DomainMapper_Impl.hxx>
#define private public
#include <../../../source/resourcemodel/Fraction.cxx>
#undef private
using
namespace
std
;
...
...
@@ -39,12 +35,10 @@ public:
virtual
void
tearDown
()
SAL_OVERRIDE
;
void
testTwipConversions
();
void
testFraction
();
void
testFieldParameters
();
CPPUNIT_TEST_SUITE
(
WriterfilterMiscTest
);
CPPUNIT_TEST
(
testTwipConversions
);
CPPUNIT_TEST
(
testFraction
);
CPPUNIT_TEST
(
testFieldParameters
);
CPPUNIT_TEST_SUITE_END
();
};
...
...
@@ -77,17 +71,6 @@ void WriterfilterMiscTest::testTwipConversions()
CPPUNIT_ASSERT_EQUAL
(
sal_uInt32
(
0
),
convertTwipToMM100Unsigned
(
40000
));
}
void
WriterfilterMiscTest
::
testFraction
()
{
using
writerfilter
::
resourcemodel
::
Fraction
;
Fraction
f1
(
-
928800
,
2717
);
CPPUNIT_ASSERT_EQUAL
(
sal_Int32
(
-
928800
),
f1
.
mnNumerator
);
// became positive
CPPUNIT_ASSERT_EQUAL
(
sal_Int32
(
2717
),
f1
.
mnDenominator
);
Fraction
f2
(
-
220869
,
1350
);
CPPUNIT_ASSERT_EQUAL
(
sal_Int32
(
-
24541
),
f2
.
mnNumerator
);
// became positive
CPPUNIT_ASSERT_EQUAL
(
sal_Int32
(
150
),
f2
.
mnDenominator
);
}
void
WriterfilterMiscTest
::
testFieldParameters
()
{
using
writerfilter
::
dmapper
::
lcl_SplitFieldCommand
;
...
...
writerfilter/source/dmapper/WrapPolygonHandler.cxx
Dosyayı görüntüle @
003434f1
...
...
@@ -88,7 +88,7 @@ WrapPolygon::Pointer_t WrapPolygon::move(const awt::Point & rPoint)
return
pResult
;
}
WrapPolygon
::
Pointer_t
WrapPolygon
::
scale
(
const
resourcemodel
::
Fraction
&
rFractionX
,
const
resourcemodel
::
Fraction
&
rFractionY
)
WrapPolygon
::
Pointer_t
WrapPolygon
::
scale
(
const
Fraction
&
rFractionX
,
const
Fraction
&
rFractionY
)
{
WrapPolygon
::
Pointer_t
pResult
(
new
WrapPolygon
);
...
...
@@ -97,7 +97,7 @@ WrapPolygon::Pointer_t WrapPolygon::scale(const resourcemodel::Fraction & rFract
while
(
aIt
!=
aItEnd
)
{
awt
::
Point
aPoint
(
resourcemodel
::
Fraction
(
aIt
->
X
)
*
rFractionX
,
resourcemodel
::
Fraction
(
aIt
->
Y
)
*
rFractionY
);
awt
::
Point
aPoint
(
(
Fraction
(
long
(
aIt
->
X
))
*
rFractionX
).
operator
long
(),
(
Fraction
(
long
(
aIt
->
Y
))
*
rFractionY
).
operator
long
()
);
pResult
->
addPoint
(
aPoint
);
++
aIt
;
}
...
...
@@ -109,19 +109,19 @@ WrapPolygon::Pointer_t WrapPolygon::correctWordWrapPolygon(const awt::Size & rSr
{
WrapPolygon
::
Pointer_t
pResult
;
const
sal_uInt32
nWrap100Percent
=
21600
;
const
long
nWrap100Percent
=
21600
;
resourcemodel
::
Fraction
aMove
(
nWrap100Percent
,
rSrcSize
.
Width
);
aMove
=
aMove
*
resourcemodel
::
Fraction
(
15
,
1
);
awt
::
Point
aMovePoint
(
aMove
,
0
);
Fraction
aMove
(
nWrap100Percent
,
rSrcSize
.
Width
);
aMove
=
aMove
*
Fraction
(
15
,
1
);
awt
::
Point
aMovePoint
(
aMove
.
operator
long
()
,
0
);
pResult
=
move
(
aMovePoint
);
resourcemodel
::
Fraction
aScaleX
(
nWrap100Percent
,
resourcemodel
::
Fraction
(
nWrap100Percent
)
+
aMove
);
resourcemodel
::
Fraction
aScaleY
(
nWrap100Percent
,
resourcemodel
::
Fraction
(
nWrap100Percent
)
-
aMove
);
Fraction
aScaleX
(
nWrap100Percent
,
Fraction
(
nWrap100Percent
)
+
aMove
);
Fraction
aScaleY
(
nWrap100Percent
,
Fraction
(
nWrap100Percent
)
-
aMove
);
pResult
=
pResult
->
scale
(
aScaleX
,
aScaleY
);
resourcemodel
::
Fraction
aScaleSrcX
(
rSrcSize
.
Width
,
nWrap100Percent
);
resourcemodel
::
Fraction
aScaleSrcY
(
rSrcSize
.
Height
,
nWrap100Percent
);
Fraction
aScaleSrcX
(
rSrcSize
.
Width
,
nWrap100Percent
);
Fraction
aScaleSrcY
(
rSrcSize
.
Height
,
nWrap100Percent
);
pResult
=
pResult
->
scale
(
aScaleSrcX
,
aScaleSrcY
);
return
pResult
;
...
...
writerfilter/source/dmapper/WrapPolygonHandler.hxx
Dosyayı görüntüle @
003434f1
...
...
@@ -23,7 +23,7 @@
#include <deque>
#include <com/sun/star/drawing/PointSequenceSequence.hpp>
#include <resourcemodel/LoggedResources.hxx>
#include <
resourcemodel/Fraction
.hxx>
#include <
tools/fract
.hxx>
namespace
writerfilter
{
namespace
dmapper
{
...
...
@@ -51,7 +51,7 @@ public:
size_t
size
()
const
;
WrapPolygon
::
Pointer_t
move
(
const
css
::
awt
::
Point
&
rMove
);
WrapPolygon
::
Pointer_t
scale
(
const
resourcemodel
::
Fraction
&
rFractionX
,
const
resourcemodel
::
Fraction
&
rFractionY
);
WrapPolygon
::
Pointer_t
scale
(
const
Fraction
&
rFractionX
,
const
Fraction
&
rFractionY
);
WrapPolygon
::
Pointer_t
correctWordWrapPolygon
(
const
css
::
awt
::
Size
&
rSrcSize
);
css
::
drawing
::
PointSequenceSequence
getPointSequenceSequence
()
const
;
};
...
...
writerfilter/source/resourcemodel/Fraction.cxx
deleted
100644 → 0
Dosyayı görüntüle @
3a2010c7
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* 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 regarding copyright
* ownership. The ASF licenses this file 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 .
*/
#include <resourcemodel/Fraction.hxx>
namespace
writerfilter
{
namespace
resourcemodel
{
// Stein's binary GCD for non-negative integers
// https://en.wikipedia.org/wiki/Binary_GCD_algorithm
static
sal_uInt32
gcd
(
sal_uInt32
a
,
sal_uInt32
b
)
{
if
(
a
==
0
||
b
==
0
)
return
a
|
b
;
sal_uInt32
nShift
=
0
;
while
(((
a
|
b
)
&
1
)
==
0
)
{
a
>>=
1
;
b
>>=
1
;
++
nShift
;
}
while
((
a
&
1
)
==
0
)
a
>>=
1
;
do
{
while
((
b
&
1
)
==
0
)
b
>>=
1
;
if
(
a
<
b
)
{
b
-=
a
;
}
else
{
sal_uInt32
nDiff
=
a
-
b
;
a
=
b
;
b
=
nDiff
;
}
b
>>=
1
;
}
while
(
b
!=
0
);
return
a
<<
nShift
;
}
static
sal_uInt32
lcm
(
sal_Int32
a
,
sal_Int32
b
)
{
return
abs
(
a
*
b
)
/
gcd
(
abs
(
a
),
abs
(
b
));
}
Fraction
::
Fraction
(
sal_Int32
nNumerator
,
sal_Int32
nDenominator
)
{
init
(
nNumerator
,
nDenominator
);
}
Fraction
::~
Fraction
()
{
}
void
Fraction
::
init
(
sal_Int32
nNumerator
,
sal_Int32
nDenominator
)
{
// fdo#41068 pass non-negative numbers to gcd
sal_Int32
const
nGCD
=
gcd
(
abs
(
nNumerator
),
abs
(
nDenominator
));
// fdo#76803 do signed division
mnNumerator
=
nNumerator
/
nGCD
;
mnDenominator
=
nDenominator
/
nGCD
;
}
void
Fraction
::
assign
(
const
Fraction
&
rFraction
)
{
init
(
rFraction
.
mnNumerator
,
rFraction
.
mnDenominator
);
}
Fraction
Fraction
::
inverse
()
const
{
return
Fraction
(
mnDenominator
,
mnNumerator
);
}
Fraction
Fraction
::
operator
+
(
const
Fraction
&
rFraction
)
const
{
sal_uInt32
nLCM
=
lcm
(
mnDenominator
,
rFraction
.
mnDenominator
);
return
Fraction
(
mnNumerator
*
nLCM
/
mnDenominator
+
rFraction
.
mnNumerator
*
nLCM
/
rFraction
.
mnDenominator
,
nLCM
);
}
Fraction
Fraction
::
operator
-
(
const
Fraction
&
rFraction
)
const
{
sal_uInt32
nLCM
=
lcm
(
mnDenominator
,
rFraction
.
mnDenominator
);
return
Fraction
(
mnNumerator
*
nLCM
/
mnDenominator
-
rFraction
.
mnNumerator
*
nLCM
/
rFraction
.
mnDenominator
,
nLCM
);
}
Fraction
Fraction
::
operator
*
(
const
Fraction
&
rFraction
)
const
{
return
Fraction
(
mnNumerator
*
rFraction
.
mnNumerator
,
mnDenominator
*
rFraction
.
mnDenominator
);
}
Fraction
Fraction
::
operator
/
(
const
Fraction
&
rFraction
)
const
{
return
*
this
*
rFraction
.
inverse
();
}
Fraction
Fraction
::
operator
=
(
const
Fraction
&
rFraction
)
{
assign
(
rFraction
);
return
*
this
;
}
Fraction
::
operator
sal_Int32
()
const
{
return
mnNumerator
/
mnDenominator
;
}
Fraction
::
operator
float
()
const
{
return
static_cast
<
float
>
(
mnNumerator
)
/
static_cast
<
float
>
(
mnDenominator
);
}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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