summaryrefslogtreecommitdiff
path: root/tools/source
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-09-26 16:22:09 +0200
committerTomaž Vajngerl <quikee@gmail.com>2019-09-29 15:17:47 +0200
commit66eedce71f10c30712f34732157e4dcdfcb49090 (patch)
tree912ca181175c8bde690eda218d4051a4604bbcff /tools/source
parent43d3f3a2d1f5a3dcfbd42368c4e86e24b80c6cbb (diff)
Move Rectangle,Point,Size serialization to GenericTypeSerializer
Change-Id: Iae489fc31b13b836e1df5327ba2fa07e0325907a Reviewed-on: https://gerrit.libreoffice.org/79793 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'tools/source')
-rw-r--r--tools/source/generic/gen.cxx44
-rw-r--r--tools/source/stream/GenericTypeSerializer.cxx81
2 files changed, 81 insertions, 44 deletions
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 0a488a4e51b4..7c182818c460 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -27,23 +27,6 @@
#include <tools/gen.hxx>
#include <tools/stream.hxx>
-SvStream& ReadPair( SvStream& rIStream, Pair& rPair )
-{
- sal_Int32 nTmpA(0), nTmpB(0);
- rIStream.ReadInt32( nTmpA ).ReadInt32( nTmpB );
- rPair.nA = nTmpA;
- rPair.nB = nTmpB;
-
- return rIStream;
-}
-
-SvStream& WritePair( SvStream& rOStream, const Pair& rPair )
-{
- rOStream.WriteInt32( rPair.nA ).WriteInt32( rPair.nB );
-
- return rOStream;
-}
-
OString Pair::toString() const
{
std::stringstream ss;
@@ -200,33 +183,6 @@ bool tools::Rectangle::IsOver( const tools::Rectangle& rRect ) const
return !GetIntersection( rRect ).IsEmpty();
}
-namespace tools
-{
-SvStream& ReadRectangle( SvStream& rIStream, tools::Rectangle& rRect )
-{
- sal_Int32 nTmpL(0), nTmpT(0), nTmpR(0), nTmpB(0);
-
- rIStream.ReadInt32( nTmpL ).ReadInt32( nTmpT ).ReadInt32( nTmpR ).ReadInt32( nTmpB );
-
- rRect.nLeft = nTmpL;
- rRect.nTop = nTmpT;
- rRect.nRight = nTmpR;
- rRect.nBottom = nTmpB;
-
- return rIStream;
-}
-
-SvStream& WriteRectangle( SvStream& rOStream, const tools::Rectangle& rRect )
-{
- rOStream.WriteInt32( rRect.nLeft )
- .WriteInt32( rRect.nTop )
- .WriteInt32( rRect.nRight )
- .WriteInt32( rRect.nBottom );
-
- return rOStream;
-}
-}
-
OString tools::Rectangle::toString() const
{
std::stringstream ss;
diff --git a/tools/source/stream/GenericTypeSerializer.cxx b/tools/source/stream/GenericTypeSerializer.cxx
index 7e261350ad50..c099713d24ac 100644
--- a/tools/source/stream/GenericTypeSerializer.cxx
+++ b/tools/source/stream/GenericTypeSerializer.cxx
@@ -26,6 +26,8 @@ namespace tools
{
constexpr sal_uInt16 COL_NAME_USER = 0x8000;
+constexpr sal_Int32 RECT_EMPTY_VALUE_RIGHT_BOTTOM = -32767;
+
void GenericTypeSerializer::readColor(Color& rColor)
{
sal_uInt16 nColorNameID(0);
@@ -100,6 +102,85 @@ void GenericTypeSerializer::writeColor(const Color& rColor)
mrStream.WriteUInt16((nB << 8) + nB);
}
+void GenericTypeSerializer::readPoint(Point& rPoint)
+{
+ sal_Int32 nX(0);
+ sal_Int32 nY(0);
+
+ mrStream.ReadInt32(nX);
+ mrStream.ReadInt32(nY);
+
+ rPoint.setX(nX);
+ rPoint.setY(nY);
+}
+
+void GenericTypeSerializer::writePoint(const Point& rPoint)
+{
+ mrStream.WriteInt32(rPoint.getX());
+ mrStream.WriteInt32(rPoint.getY());
+}
+
+void GenericTypeSerializer::readSize(Size& rSize)
+{
+ sal_Int32 nWidth(0);
+ sal_Int32 nHeight(0);
+
+ mrStream.ReadInt32(nWidth);
+ mrStream.ReadInt32(nHeight);
+
+ rSize.setWidth(nWidth);
+ rSize.setHeight(nHeight);
+}
+
+void GenericTypeSerializer::writeSize(const Size& rSize)
+{
+ mrStream.WriteInt32(rSize.getWidth());
+ mrStream.WriteInt32(rSize.getHeight());
+}
+
+void GenericTypeSerializer::readRectangle(Rectangle& rRectangle)
+{
+ sal_Int32 nLeft(0);
+ sal_Int32 nTop(0);
+ sal_Int32 nRight(0);
+ sal_Int32 nBottom(0);
+
+ mrStream.ReadInt32(nLeft);
+ mrStream.ReadInt32(nTop);
+ mrStream.ReadInt32(nRight);
+ mrStream.ReadInt32(nBottom);
+
+ if (nRight == RECT_EMPTY_VALUE_RIGHT_BOTTOM || nBottom == RECT_EMPTY_VALUE_RIGHT_BOTTOM)
+ {
+ rRectangle.SetEmpty();
+ }
+ else
+ {
+ rRectangle.SetLeft(nLeft);
+ rRectangle.SetTop(nTop);
+ rRectangle.SetRight(nRight);
+ rRectangle.SetBottom(nBottom);
+ }
+}
+
+void GenericTypeSerializer::writeRectangle(const Rectangle& rRectangle)
+{
+ if (rRectangle.IsEmpty())
+ {
+ mrStream.WriteInt32(0);
+ mrStream.WriteInt32(0);
+ mrStream.WriteInt32(RECT_EMPTY_VALUE_RIGHT_BOTTOM);
+ mrStream.WriteInt32(RECT_EMPTY_VALUE_RIGHT_BOTTOM);
+ }
+ else
+ {
+ mrStream.WriteInt32(rRectangle.Left());
+ mrStream.WriteInt32(rRectangle.Top());
+ mrStream.WriteInt32(rRectangle.Right());
+ mrStream.WriteInt32(rRectangle.Bottom());
+ }
+}
+
} // end namespace tools
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */