impgrfll.cxx (f6e50924) | impgrfll.cxx (e147e5f6) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 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 | 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 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 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. | 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 * | 19 * |
20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_svx.hxx" 26#include <svx/rectenum.hxx> 27#include <vcl/svapp.hxx> 28#include <vcl/outdev.hxx> 29#include <vcl/bitmap.hxx> 30 | 20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_svx.hxx" 26#include <svx/rectenum.hxx> 27#include <vcl/svapp.hxx> 28#include <vcl/outdev.hxx> 29#include <vcl/bitmap.hxx> 30 |
31/////////////////////////////////////////////////////////////////////////////// | |
32 | 31 |
33void ImpCalcBmpFillSizes( Size& rStartOffset, 34 Size& rBmpOutputSize, 35 const Rectangle& rOutputRect, 36 const MapMode& rOutputMapMode, 37 const Bitmap& rFillBitmap, 38 const Size& rBmpSize, 39 const Size& rBmpPerCent, 40 const Size& rBmpOffPerCent, 41 sal_Bool bBmpLogSize, 42 sal_Bool bBmpTile, 43 sal_Bool bBmpStretch, 44 RECT_POINT eBmpRectPoint ) | 32void ImpCalcBmpFillSizes( Size& rStartOffset, 33 Size& rBmpOutputSize, 34 const Rectangle& rOutputRect, 35 const MapMode& rOutputMapMode, 36 const Bitmap& rFillBitmap, 37 const Size& rBmpSize, 38 const Size& rBmpPerCent, 39 const Size& rBmpOffPerCent, 40 sal_Bool bBmpLogSize, 41 sal_Bool bBmpTile, 42 sal_Bool bBmpStretch, 43 RECT_POINT eBmpRectPoint ) |
45{ 46 sal_Bool bOriginalSize = sal_False, bScaleSize = sal_False; 47 48 // Falls keine Groessen gegeben sind ( z.B. alte Dokumente ) 49 // berechnen wir uns die Groesse selber aus der Bitmap 50 // ==> altes Verhalten; 51 // wenn nur eine Groesse gegeben ist, wird die andere 52 // Groesse angepasst berechnet --- 15 unchanged lines hidden (view full) --- 68 // entweder Originalgroesse oder angepasste Groesse 69 if( bOriginalSize || bScaleSize ) 70 { 71 MapMode aBmpPrefMapMode( rFillBitmap.GetPrefMapMode() ); 72 Size aBmpPrefSize( rFillBitmap.GetPrefSize() ); 73 74 // Falls keine gesetzt ist, nehmen wir Pixel 75 if( !aBmpPrefSize.Width() || !aBmpPrefSize.Height() ) | 44{ 45 sal_Bool bOriginalSize = sal_False, bScaleSize = sal_False; 46 47 // Falls keine Groessen gegeben sind ( z.B. alte Dokumente ) 48 // berechnen wir uns die Groesse selber aus der Bitmap 49 // ==> altes Verhalten; 50 // wenn nur eine Groesse gegeben ist, wird die andere 51 // Groesse angepasst berechnet --- 15 unchanged lines hidden (view full) --- 67 // entweder Originalgroesse oder angepasste Groesse 68 if( bOriginalSize || bScaleSize ) 69 { 70 MapMode aBmpPrefMapMode( rFillBitmap.GetPrefMapMode() ); 71 Size aBmpPrefSize( rFillBitmap.GetPrefSize() ); 72 73 // Falls keine gesetzt ist, nehmen wir Pixel 74 if( !aBmpPrefSize.Width() || !aBmpPrefSize.Height() ) |
76 { | 75 { |
77 aBmpPrefSize = rFillBitmap.GetSizePixel(); | 76 aBmpPrefSize = rFillBitmap.GetSizePixel(); |
78 aBmpPrefMapMode = MAP_PIXEL; 79 } | 77 aBmpPrefMapMode = MAP_PIXEL; 78 } |
80 81 if( bOriginalSize ) 82 { 83 if( MAP_PIXEL == aBmpPrefMapMode.GetMapUnit() ) 84 rBmpOutputSize = Application::GetDefaultDevice()->PixelToLogic( aBmpPrefSize, rOutputMapMode ); 85 else 86 rBmpOutputSize = OutputDevice::LogicToLogic( aBmpPrefSize, aBmpPrefMapMode, rOutputMapMode ); 87 } --- 33 unchanged lines hidden (view full) --- 121 rBmpOutputSize.Width() = basegfx::fround( (double) rOutputRect.GetWidth() * rBmpPerCent.Width() / 100. ); 122 rBmpOutputSize.Height() = basegfx::fround( (double) rOutputRect.GetHeight() * rBmpPerCent.Height() / 100. ); 123 } 124 } 125 126 // nur bei Kachelung die anderen Positionen berechnen 127 if( bBmpTile ) 128 { | 79 80 if( bOriginalSize ) 81 { 82 if( MAP_PIXEL == aBmpPrefMapMode.GetMapUnit() ) 83 rBmpOutputSize = Application::GetDefaultDevice()->PixelToLogic( aBmpPrefSize, rOutputMapMode ); 84 else 85 rBmpOutputSize = OutputDevice::LogicToLogic( aBmpPrefSize, aBmpPrefMapMode, rOutputMapMode ); 86 } --- 33 unchanged lines hidden (view full) --- 120 rBmpOutputSize.Width() = basegfx::fround( (double) rOutputRect.GetWidth() * rBmpPerCent.Width() / 100. ); 121 rBmpOutputSize.Height() = basegfx::fround( (double) rOutputRect.GetHeight() * rBmpPerCent.Height() / 100. ); 122 } 123 } 124 125 // nur bei Kachelung die anderen Positionen berechnen 126 if( bBmpTile ) 127 { |
129 Point aStartPoint; | 128 Point aStartPoint; |
130 131 // Grundposition der ersten Kachel berechen; 132 // Diese Position wird spaeter zur Berechnung der absoluten 133 // Startposition links oberhalb des Objektes benutzt 134 switch( eBmpRectPoint ) 135 { 136 case( RP_MT ): 137 { --- 56 unchanged lines hidden (view full) --- 194 aStartPoint = rOutputRect.TopLeft(); 195 break; 196 } 197 198 // X- oder Y-Positionsoffset beruecksichtigen 199 if( rBmpOffPerCent.Width() ) 200 aStartPoint.X() += ( rBmpOutputSize.Width() * rBmpOffPerCent.Width() / 100 ); 201 | 129 130 // Grundposition der ersten Kachel berechen; 131 // Diese Position wird spaeter zur Berechnung der absoluten 132 // Startposition links oberhalb des Objektes benutzt 133 switch( eBmpRectPoint ) 134 { 135 case( RP_MT ): 136 { --- 56 unchanged lines hidden (view full) --- 193 aStartPoint = rOutputRect.TopLeft(); 194 break; 195 } 196 197 // X- oder Y-Positionsoffset beruecksichtigen 198 if( rBmpOffPerCent.Width() ) 199 aStartPoint.X() += ( rBmpOutputSize.Width() * rBmpOffPerCent.Width() / 100 ); 200 |
202 if( rBmpOffPerCent.Height() ) | 201 if( rBmpOffPerCent.Height() ) |
203 aStartPoint.Y() += ( rBmpOutputSize.Height() * rBmpOffPerCent.Height() / 100 ); 204 | 202 aStartPoint.Y() += ( rBmpOutputSize.Height() * rBmpOffPerCent.Height() / 100 ); 203 |
205 // echten Startpunkt berechnen ( links oben ) | 204 // echten Startpunkt berechnen (links oben) |
206 if( rBmpOutputSize.Width() && rBmpOutputSize.Height() ) 207 { 208 const long nDiffX = aStartPoint.X() - rOutputRect.Left(); 209 const long nDiffY = aStartPoint.Y() - rOutputRect.Top(); 210 211 if ( nDiffX ) 212 { 213 long nCount = nDiffX / rBmpOutputSize.Width() + 1; --- 10 unchanged lines hidden (view full) --- 224 225 if ( rBmpOffPerCent.Width() && ( nCount & 1L ) ) 226 nCount++; 227 228 aStartPoint.Y() -= ( nCount * rBmpOutputSize.Height() ); 229 } 230 } 231 | 205 if( rBmpOutputSize.Width() && rBmpOutputSize.Height() ) 206 { 207 const long nDiffX = aStartPoint.X() - rOutputRect.Left(); 208 const long nDiffY = aStartPoint.Y() - rOutputRect.Top(); 209 210 if ( nDiffX ) 211 { 212 long nCount = nDiffX / rBmpOutputSize.Width() + 1; --- 10 unchanged lines hidden (view full) --- 223 224 if ( rBmpOffPerCent.Width() && ( nCount & 1L ) ) 225 nCount++; 226 227 aStartPoint.Y() -= ( nCount * rBmpOutputSize.Height() ); 228 } 229 } 230 |
232 rStartOffset = Size( aStartPoint.X() - rOutputRect.Left(), 233 aStartPoint.Y() - rOutputRect.Top() ); | 231 rStartOffset = Size( aStartPoint.X() - rOutputRect.Left(), 232 aStartPoint.Y() - rOutputRect.Top() ); |
234 } | 233 } |
235 else 236 { 237 if( bBmpStretch ) 238 { 239 rStartOffset = Size(0, 0); 240 rBmpOutputSize = rOutputRect.GetSize(); 241 } 242 else 243 { 244 rStartOffset = Size( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1, 245 ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 ); 246 } 247 } | 234 else 235 { 236 if( bBmpStretch ) 237 { 238 rStartOffset = Size(0, 0); 239 rBmpOutputSize = rOutputRect.GetSize(); 240 } 241 else 242 { 243 rStartOffset = Size( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1, 244 ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 ); 245 } 246 } |
248} 249 | 247} 248 |
250////////////////////////////////////////////////////////////////////////////// 251// eof | 249/* vim: set noet sw=4 ts=4: */ |