Bump version to 5.0-14
[LibreOffice.git] / svtools / source / graphic / grfattr.cxx
blob26001ee13da0407082f82bf85f418261511e36d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/vcompat.hxx>
22 #include <svtools/grfmgr.hxx>
25 // - GraphicAttr -
28 GraphicAttr::GraphicAttr() :
29 mfGamma ( 1.0 ),
30 mnMirrFlags ( BmpMirrorFlags::NONE ),
31 mnLeftCrop ( 0 ),
32 mnTopCrop ( 0 ),
33 mnRightCrop ( 0 ),
34 mnBottomCrop ( 0 ),
35 mnRotate10 ( 0 ),
36 mnContPercent ( 0 ),
37 mnLumPercent ( 0 ),
38 mnRPercent ( 0 ),
39 mnGPercent ( 0 ),
40 mnBPercent ( 0 ),
41 mbInvert ( false ),
42 mcTransparency ( 0 ),
43 meDrawMode ( GRAPHICDRAWMODE_STANDARD )
49 GraphicAttr::~GraphicAttr()
55 bool GraphicAttr::operator==( const GraphicAttr& rAttr ) const
57 return( ( mfGamma == rAttr.mfGamma ) &&
58 ( mnMirrFlags == rAttr.mnMirrFlags ) &&
59 ( mnLeftCrop == rAttr.mnLeftCrop ) &&
60 ( mnTopCrop == rAttr.mnTopCrop ) &&
61 ( mnRightCrop == rAttr.mnRightCrop ) &&
62 ( mnBottomCrop == rAttr.mnBottomCrop ) &&
63 ( mnRotate10 == rAttr.mnRotate10 ) &&
64 ( mnContPercent == rAttr.mnContPercent ) &&
65 ( mnLumPercent == rAttr.mnLumPercent ) &&
66 ( mnRPercent == rAttr.mnRPercent ) &&
67 ( mnGPercent == rAttr.mnGPercent ) &&
68 ( mnBPercent == rAttr.mnBPercent ) &&
69 ( mbInvert == rAttr.mbInvert ) &&
70 ( mcTransparency == rAttr.mcTransparency ) &&
71 ( meDrawMode == rAttr.meDrawMode ) );
76 SvStream& ReadGraphicAttr( SvStream& rIStm, GraphicAttr& rAttr )
78 VersionCompat aCompat( rIStm, StreamMode::READ );
79 sal_uInt32 nTmp32, nTmpMirrFlags;
80 sal_uInt16 nTmp16;
82 rIStm.ReadUInt32( nTmp32 ).ReadUInt32( nTmp32 ).ReadDouble( rAttr.mfGamma ).ReadUInt32( nTmpMirrFlags ).ReadUInt16( rAttr.mnRotate10 );
83 rAttr.mnMirrFlags = static_cast<BmpMirrorFlags>(nTmpMirrFlags);
84 rIStm.ReadInt16( rAttr.mnContPercent ).ReadInt16( rAttr.mnLumPercent ).ReadInt16( rAttr.mnRPercent ).ReadInt16( rAttr.mnGPercent ).ReadInt16( rAttr.mnBPercent );
85 rIStm.ReadCharAsBool( rAttr.mbInvert ).ReadUChar( rAttr.mcTransparency ).ReadUInt16( nTmp16 );
86 rAttr.meDrawMode = (GraphicDrawMode) nTmp16;
88 if( aCompat.GetVersion() >= 2 )
90 sal_Int32 nTmpL(0), nTmpT(0), nTmpR(0), nTmpB(0);
91 rIStm.ReadInt32( nTmpL ).ReadInt32( nTmpT ).ReadInt32( nTmpR ).ReadInt32( nTmpB );
92 rAttr.mnLeftCrop = nTmpL;
93 rAttr.mnTopCrop = nTmpT;
94 rAttr.mnRightCrop = nTmpR;
95 rAttr.mnBottomCrop = nTmpB;
98 return rIStm;
103 SvStream& WriteGraphicAttr( SvStream& rOStm, const GraphicAttr& rAttr )
105 VersionCompat aCompat( rOStm, StreamMode::WRITE, 2 );
106 const sal_uInt32 nTmp32 = 0;
108 rOStm.WriteUInt32( nTmp32 ).WriteUInt32( nTmp32 );
109 rOStm.WriteDouble( rAttr.mfGamma );
110 rOStm.WriteUInt32( static_cast<sal_uInt32>(rAttr.mnMirrFlags) ).WriteUInt16( rAttr.mnRotate10 );
111 rOStm.WriteInt16( rAttr.mnContPercent ).WriteInt16( rAttr.mnLumPercent ).WriteInt16( rAttr.mnRPercent ).WriteInt16( rAttr.mnGPercent ).WriteInt16( rAttr.mnBPercent );
112 rOStm.WriteBool( rAttr.mbInvert ).WriteUChar( rAttr.mcTransparency ).WriteUInt16( rAttr.meDrawMode );
113 rOStm.WriteInt32( rAttr.mnLeftCrop )
114 .WriteInt32( rAttr.mnTopCrop )
115 .WriteInt32( rAttr.mnRightCrop )
116 .WriteInt32( rAttr.mnBottomCrop );
118 return rOStm;
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */