xref: /AOO41X/main/svtools/source/graphic/grfattr.cxx (revision 5900e8ec128faec89519683efce668ccd8cc6084)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svtools.hxx"
26 
27 #include <tools/vcompat.hxx>
28 #include <svtools/grfmgr.hxx>
29 
30 // ---------------
31 // - GraphicAttr -
32 // ---------------
33 
GraphicAttr()34 GraphicAttr::GraphicAttr() :
35     mfGamma         ( 1.0 ),
36     mnMirrFlags     ( 0 ),
37     mnLeftCrop      ( 0 ),
38     mnTopCrop       ( 0 ),
39     mnRightCrop     ( 0 ),
40     mnBottomCrop    ( 0 ),
41     mnRotate10      ( 0 ),
42     mnContPercent   ( 0 ),
43     mnLumPercent    ( 0 ),
44     mnRPercent      ( 0 ),
45     mnGPercent      ( 0 ),
46     mnBPercent      ( 0 ),
47     mbInvert        ( sal_False ),
48     mcTransparency  ( 0 ),
49     meDrawMode      ( GRAPHICDRAWMODE_STANDARD )
50 {
51 }
52 
53 // ------------------------------------------------------------------------
54 
~GraphicAttr()55 GraphicAttr::~GraphicAttr()
56 {
57 }
58 
59 // ------------------------------------------------------------------------
60 
operator ==(const GraphicAttr & rAttr) const61 sal_Bool GraphicAttr::operator==( const GraphicAttr& rAttr ) const
62 {
63     return( ( mfGamma == rAttr.mfGamma ) &&
64             ( mnMirrFlags == rAttr.mnMirrFlags ) &&
65             ( mnLeftCrop == rAttr.mnLeftCrop ) &&
66             ( mnTopCrop == rAttr.mnTopCrop ) &&
67             ( mnRightCrop == rAttr.mnRightCrop ) &&
68             ( mnBottomCrop == rAttr.mnBottomCrop ) &&
69             ( mnRotate10 == rAttr.mnRotate10 ) &&
70             ( mnContPercent == rAttr.mnContPercent ) &&
71             ( mnLumPercent == rAttr.mnLumPercent ) &&
72             ( mnRPercent == rAttr.mnRPercent ) &&
73             ( mnGPercent == rAttr.mnGPercent ) &&
74             ( mnBPercent == rAttr.mnBPercent ) &&
75             ( mbInvert == rAttr.mbInvert ) &&
76             ( mcTransparency == rAttr.mcTransparency ) &&
77             ( meDrawMode == rAttr.meDrawMode ) );
78 }
79 
80 // ------------------------------------------------------------------------
81 
operator >>(SvStream & rIStm,GraphicAttr & rAttr)82 SvStream& operator>>( SvStream& rIStm, GraphicAttr& rAttr )
83 {
84     VersionCompat   aCompat( rIStm, STREAM_READ );
85     sal_uInt32      nTmp32;
86     sal_uInt16          nTmp16;
87 
88     rIStm >> nTmp32 >> nTmp32 >> rAttr.mfGamma >> rAttr.mnMirrFlags >> rAttr.mnRotate10;
89     rIStm >> rAttr.mnContPercent >> rAttr.mnLumPercent >> rAttr.mnRPercent >> rAttr.mnGPercent >> rAttr.mnBPercent;
90     rIStm >> rAttr.mbInvert >> rAttr.mcTransparency >> nTmp16;
91     rAttr.meDrawMode = (GraphicDrawMode) nTmp16;
92 
93     if( aCompat.GetVersion() >= 2 )
94     {
95         rIStm >> rAttr.mnLeftCrop >> rAttr.mnTopCrop >> rAttr.mnRightCrop >> rAttr.mnBottomCrop;
96     }
97 
98     return rIStm;
99 }
100 
101 // ------------------------------------------------------------------------
102 
operator <<(SvStream & rOStm,const GraphicAttr & rAttr)103 SvStream& operator<<( SvStream& rOStm, const GraphicAttr& rAttr )
104 {
105     VersionCompat       aCompat( rOStm, STREAM_WRITE, 2 );
106     const sal_uInt32    nTmp32 = 0;
107 
108     rOStm << nTmp32 << nTmp32 << rAttr.mfGamma << rAttr.mnMirrFlags << rAttr.mnRotate10;
109     rOStm << rAttr.mnContPercent << rAttr.mnLumPercent << rAttr.mnRPercent << rAttr.mnGPercent << rAttr.mnBPercent;
110     rOStm << rAttr.mbInvert << rAttr.mcTransparency << (sal_uInt16) rAttr.meDrawMode;
111     rOStm << rAttr.mnLeftCrop << rAttr.mnTopCrop << rAttr.mnRightCrop << rAttr.mnBottomCrop;
112 
113     return rOStm;
114 }
115