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 #ifndef _SV_MAPMOD_HXX 25 #define _SV_MAPMOD_HXX 26 27 #include <tools/gen.hxx> 28 #include <tools/fract.hxx> 29 #include <vcl/sv.h> 30 #include <vcl/dllapi.h> 31 #include <tools/resid.hxx> 32 #include <tools/mapunit.hxx> 33 34 class SvStream; 35 36 // -------------- 37 // - ImplMapMode - 38 // -------------- 39 40 class OutputDevice; 41 42 class ImplMapMode 43 { 44 friend class MapMode; 45 friend class OutputDevice; 46 47 private: 48 sal_uLong mnRefCount; 49 MapUnit meUnit; 50 Point maOrigin; 51 Fraction maScaleX; 52 Fraction maScaleY; 53 sal_Bool mbSimple; 54 55 friend SvStream& operator>>( SvStream& rIStm, ImplMapMode& rMapMode ); 56 friend SvStream& operator<<( SvStream& rOStm, const ImplMapMode& rMapMode ); 57 58 static ImplMapMode* ImplGetStaticMapMode( MapUnit eUnit ); 59 public: 60 ImplMapMode(); 61 ImplMapMode( const ImplMapMode& rImpMapMode ); 62 }; 63 64 // ----------- 65 // - MapMode - 66 // ----------- 67 68 class VCL_DLLPUBLIC MapMode 69 { 70 friend class OutputDevice; 71 72 private: 73 ImplMapMode* mpImplMapMode; 74 75 SAL_DLLPRIVATE void ImplMakeUnique(); 76 77 public: 78 MapMode(); 79 MapMode( const MapMode& rMapMode ); 80 MapMode( MapUnit eUnit ); 81 MapMode( MapUnit eUnit, const Point& rLogicOrg, 82 const Fraction& rScaleX, const Fraction& rScaleY ); 83 ~MapMode(); 84 85 void SetMapUnit( MapUnit eUnit ); GetMapUnit() const86 MapUnit GetMapUnit() const 87 { return mpImplMapMode->meUnit; } 88 89 void SetOrigin( const Point& rOrigin ); GetOrigin() const90 const Point& GetOrigin() const 91 { return mpImplMapMode->maOrigin; } 92 93 void SetScaleX( const Fraction& rScaleX ); GetScaleX() const94 const Fraction& GetScaleX() const 95 { return mpImplMapMode->maScaleX; } 96 void SetScaleY( const Fraction& rScaleY ); GetScaleY() const97 const Fraction& GetScaleY() const 98 { return mpImplMapMode->maScaleY; } 99 100 MapMode& operator=( const MapMode& rMapMode ); 101 sal_Bool operator==( const MapMode& rMapMode ) const; operator !=(const MapMode & rMapMode) const102 sal_Bool operator!=( const MapMode& rMapMode ) const 103 { return !(MapMode::operator==( rMapMode )); } 104 sal_Bool IsDefault() const; IsSameInstance(const MapMode & rMapMode) const105 sal_Bool IsSameInstance( const MapMode& rMapMode ) const 106 { return (mpImplMapMode == rMapMode.mpImplMapMode); } 107 108 friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, MapMode& rMapMode ); 109 friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const MapMode& rMapMode ); 110 }; 111 112 #endif // _SV_MAPMOD_HXX 113