xref: /trunk/main/svtools/source/graphic/grfattr.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svtools.hxx"
30 
31 #include <tools/vcompat.hxx>
32 #include <svtools/grfmgr.hxx>
33 
34 // ---------------
35 // - GraphicAttr -
36 // ---------------
37 
38 GraphicAttr::GraphicAttr() :
39     mfGamma         ( 1.0 ),
40     mnMirrFlags     ( 0 ),
41     mnLeftCrop      ( 0 ),
42     mnTopCrop       ( 0 ),
43     mnRightCrop     ( 0 ),
44     mnBottomCrop    ( 0 ),
45     mnRotate10      ( 0 ),
46     mnContPercent   ( 0 ),
47     mnLumPercent    ( 0 ),
48     mnRPercent      ( 0 ),
49     mnGPercent      ( 0 ),
50     mnBPercent      ( 0 ),
51     mbInvert        ( sal_False ),
52     mcTransparency  ( 0 ),
53     meDrawMode      ( GRAPHICDRAWMODE_STANDARD )
54 {
55 }
56 
57 // ------------------------------------------------------------------------
58 
59 GraphicAttr::~GraphicAttr()
60 {
61 }
62 
63 // ------------------------------------------------------------------------
64 
65 sal_Bool GraphicAttr::operator==( const GraphicAttr& rAttr ) const
66 {
67     return( ( mfGamma == rAttr.mfGamma ) &&
68             ( mnMirrFlags == rAttr.mnMirrFlags ) &&
69             ( mnLeftCrop == rAttr.mnLeftCrop ) &&
70             ( mnTopCrop == rAttr.mnTopCrop ) &&
71             ( mnRightCrop == rAttr.mnRightCrop ) &&
72             ( mnBottomCrop == rAttr.mnBottomCrop ) &&
73             ( mnRotate10 == rAttr.mnRotate10 ) &&
74             ( mnContPercent == rAttr.mnContPercent ) &&
75             ( mnLumPercent == rAttr.mnLumPercent ) &&
76             ( mnRPercent == rAttr.mnRPercent ) &&
77             ( mnGPercent == rAttr.mnGPercent ) &&
78             ( mnBPercent == rAttr.mnBPercent ) &&
79             ( mbInvert == rAttr.mbInvert ) &&
80             ( mcTransparency == rAttr.mcTransparency ) &&
81             ( meDrawMode == rAttr.meDrawMode ) );
82 }
83 
84 // ------------------------------------------------------------------------
85 
86 SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr )
87 {
88     VersionCompat   aCompat( rIStm, STREAM_READ );
89     sal_uInt32      nTmp32;
90     sal_uInt16          nTmp16;
91 
92     rIStm >> nTmp32 >> nTmp32 >> rAttr.mfGamma >> rAttr.mnMirrFlags >> rAttr.mnRotate10;
93     rIStm >> rAttr.mnContPercent >> rAttr.mnLumPercent >> rAttr.mnRPercent >> rAttr.mnGPercent >> rAttr.mnBPercent;
94     rIStm >> rAttr.mbInvert >> rAttr.mcTransparency >> nTmp16;
95     rAttr.meDrawMode = (GraphicDrawMode) nTmp16;
96 
97     if( aCompat.GetVersion() >= 2 )
98     {
99         rIStm >> rAttr.mnLeftCrop >> rAttr.mnTopCrop >> rAttr.mnRightCrop >> rAttr.mnBottomCrop;
100     }
101 
102     return rIStm;
103 }
104 
105 // ------------------------------------------------------------------------
106 
107 SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr )
108 {
109     VersionCompat       aCompat( rOStm, STREAM_WRITE, 2 );
110     const sal_uInt32    nTmp32 = 0;
111 
112     rOStm << nTmp32 << nTmp32 << rAttr.mfGamma << rAttr.mnMirrFlags << rAttr.mnRotate10;
113     rOStm << rAttr.mnContPercent << rAttr.mnLumPercent << rAttr.mnRPercent << rAttr.mnGPercent << rAttr.mnBPercent;
114     rOStm << rAttr.mbInvert << rAttr.mcTransparency << (sal_uInt16) rAttr.meDrawMode;
115     rOStm << rAttr.mnLeftCrop << rAttr.mnTopCrop << rAttr.mnRightCrop << rAttr.mnBottomCrop;
116 
117     return rOStm;
118 }
119