Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <tools/shl.hxx>
30 : : #include <svl/eitem.hxx>
31 : : #include <sfx2/app.hxx>
32 : : #include <sfx2/module.hxx>
33 : : #include <sfx2/sfxsids.hrc>
34 : : #include <dialmgr.hxx>
35 : : #include <svx/dlgutil.hxx>
36 : : #include <editeng/sizeitem.hxx>
37 : : #include <editeng/brshitem.hxx>
38 : : #include <grfpage.hxx>
39 : : #include <svx/grfcrop.hxx>
40 : : #include <grfpage.hrc>
41 : : #include <cuires.hrc>
42 : : #include <svx/dialogs.hrc> // for RID_SVXPAGE_GRFCROP
43 : :
44 : : #define CM_1_TO_TWIP 567
45 : : #define TWIP_TO_INCH 1440
46 : :
47 : :
48 : 0 : inline long lcl_GetValue( MetricField& rMetric, FieldUnit eUnit )
49 : : {
50 : 0 : return static_cast<long>(rMetric.Denormalize( rMetric.GetValue( eUnit )));
51 : : }
52 : :
53 : : /*--------------------------------------------------------------------
54 : : description: crop graphic
55 : : --------------------------------------------------------------------*/
56 : :
57 : 0 : SvxGrfCropPage::SvxGrfCropPage ( Window *pParent, const SfxItemSet &rSet )
58 : 0 : : SfxTabPage( pParent, CUI_RES( RID_SVXPAGE_GRFCROP ), rSet ),
59 [ # # ]: 0 : aCropFL( this, CUI_RES( FL_CROP )),
60 [ # # ]: 0 : aZoomConstRB( this, CUI_RES( RB_ZOOMCONST)),
61 [ # # ]: 0 : aSizeConstRB( this, CUI_RES( RB_SIZECONST)),
62 [ # # ]: 0 : aLeftFT( this, CUI_RES( FT_LEFT )),
63 [ # # ]: 0 : aLeftMF( this, CUI_RES( MF_LEFT )),
64 [ # # ]: 0 : aRightFT( this, CUI_RES( FT_RIGHT )),
65 [ # # ]: 0 : aRightMF( this, CUI_RES( MF_RIGHT )),
66 [ # # ]: 0 : aTopFT( this, CUI_RES( FT_TOP )),
67 [ # # ]: 0 : aTopMF( this, CUI_RES( MF_TOP )),
68 [ # # ]: 0 : aBottomFT( this, CUI_RES( FT_BOTTOM )),
69 [ # # ]: 0 : aBottomMF( this, CUI_RES( MF_BOTTOM )),
70 [ # # ]: 0 : aZoomFL( this, CUI_RES( FL_ZOOM )),
71 [ # # ]: 0 : aWidthZoomFT( this, CUI_RES( FT_WIDTHZOOM )),
72 [ # # ]: 0 : aWidthZoomMF( this, CUI_RES( MF_WIDTHZOOM )),
73 [ # # ]: 0 : aHeightZoomFT( this, CUI_RES( FT_HEIGHTZOOM)),
74 [ # # ]: 0 : aHeightZoomMF( this, CUI_RES( MF_HEIGHTZOOM)),
75 [ # # ]: 0 : aSizeFL( this, CUI_RES( FL_SIZE )),
76 [ # # ]: 0 : aWidthFT( this, CUI_RES( FT_WIDTH )),
77 [ # # ]: 0 : aWidthMF( this, CUI_RES( MF_WIDTH )),
78 [ # # ]: 0 : aHeightFT( this, CUI_RES( FT_HEIGHT )),
79 [ # # ]: 0 : aHeightMF( this, CUI_RES( MF_HEIGHT )),
80 [ # # ]: 0 : aOrigSizeFT( this, CUI_RES(FT_ORIG_SIZE)),
81 [ # # ]: 0 : aOrigSizePB( this, CUI_RES( PB_ORGSIZE )),
82 [ # # ]: 0 : aExampleWN( this, CUI_RES( WN_BSP )),
83 : : pLastCropField(0),
84 : : bInitialized(sal_False),
85 [ # # ][ # # ]: 0 : bSetOrigSize(sal_False)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
86 : : {
87 [ # # ]: 0 : FreeResource();
88 : :
89 : 0 : SetExchangeSupport();
90 : :
91 : : // set the correct metric
92 [ # # ]: 0 : const FieldUnit eMetric = GetModuleFieldUnit( rSet );
93 : :
94 [ # # ]: 0 : SetFieldUnit( aWidthMF, eMetric );
95 [ # # ]: 0 : SetFieldUnit( aHeightMF, eMetric );
96 [ # # ]: 0 : SetFieldUnit( aLeftMF, eMetric );
97 [ # # ]: 0 : SetFieldUnit( aRightMF, eMetric );
98 [ # # ]: 0 : SetFieldUnit( aTopMF , eMetric );
99 [ # # ]: 0 : SetFieldUnit( aBottomMF, eMetric );
100 : :
101 [ # # ]: 0 : Link aLk = LINK(this, SvxGrfCropPage, SizeHdl);
102 : 0 : aWidthMF.SetModifyHdl( aLk );
103 : 0 : aHeightMF.SetModifyHdl( aLk );
104 : :
105 [ # # ]: 0 : aLk = LINK(this, SvxGrfCropPage, ZoomHdl);
106 : 0 : aWidthZoomMF.SetModifyHdl( aLk );
107 : 0 : aHeightZoomMF.SetModifyHdl( aLk );
108 : :
109 [ # # ]: 0 : aLk = LINK(this, SvxGrfCropPage, CropHdl);
110 : 0 : aLeftMF.SetDownHdl( aLk );
111 : 0 : aRightMF.SetDownHdl( aLk );
112 : 0 : aTopMF.SetDownHdl( aLk );
113 : 0 : aBottomMF.SetDownHdl( aLk );
114 : 0 : aLeftMF.SetUpHdl( aLk );
115 : 0 : aRightMF.SetUpHdl( aLk );
116 : 0 : aTopMF.SetUpHdl( aLk );
117 : 0 : aBottomMF.SetUpHdl( aLk );
118 : :
119 [ # # ]: 0 : aLk = LINK(this, SvxGrfCropPage, CropModifyHdl);
120 : 0 : aLeftMF.SetModifyHdl( aLk );
121 : 0 : aRightMF.SetModifyHdl( aLk );
122 : 0 : aTopMF.SetModifyHdl( aLk );
123 : 0 : aBottomMF.SetModifyHdl( aLk );
124 : :
125 [ # # ]: 0 : aLk = LINK(this, SvxGrfCropPage, CropLoseFocusHdl);
126 : 0 : aLeftMF.SetLoseFocusHdl( aLk );
127 : 0 : aRightMF.SetLoseFocusHdl( aLk );
128 : 0 : aTopMF.SetLoseFocusHdl( aLk );
129 : 0 : aBottomMF.SetLoseFocusHdl( aLk );
130 : :
131 [ # # ]: 0 : aLk = LINK(this, SvxGrfCropPage, OrigSizeHdl);
132 : 0 : aOrigSizePB.SetClickHdl( aLk );
133 : :
134 [ # # ]: 0 : aTimer.SetTimeoutHdl(LINK(this, SvxGrfCropPage, Timeout));
135 [ # # ]: 0 : aTimer.SetTimeout( 1500 );
136 : :
137 [ # # ]: 0 : aOrigSizePB.SetAccessibleRelationLabeledBy( &aOrigSizeFT );
138 : 0 : }
139 : :
140 [ # # ][ # # ]: 0 : SvxGrfCropPage::~SvxGrfCropPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
141 : : {
142 [ # # ]: 0 : aTimer.Stop();
143 [ # # ]: 0 : }
144 : :
145 : 0 : SfxTabPage* SvxGrfCropPage::Create(Window *pParent, const SfxItemSet &rSet)
146 : : {
147 [ # # ]: 0 : return new SvxGrfCropPage( pParent, rSet );
148 : : }
149 : :
150 : 0 : void SvxGrfCropPage::Reset( const SfxItemSet &rSet )
151 : : {
152 : : const SfxPoolItem* pItem;
153 : 0 : const SfxItemPool& rPool = *rSet.GetPool();
154 : :
155 [ # # ]: 0 : if(SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich(
156 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_KEEP_ZOOM ), sal_True, &pItem ))
157 : : {
158 [ # # ]: 0 : if( ((const SfxBoolItem*)pItem)->GetValue() )
159 [ # # ]: 0 : aZoomConstRB.Check();
160 : : else
161 [ # # ]: 0 : aSizeConstRB.Check();
162 : 0 : aZoomConstRB.SaveValue();
163 : : }
164 : :
165 [ # # ]: 0 : sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP );
166 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rSet.GetItemState( nW, sal_True, &pItem))
167 : : {
168 [ # # ][ # # ]: 0 : FieldUnit eUnit = MapToFieldUnit( rSet.GetPool()->GetMetric( nW ));
169 : :
170 : 0 : SvxGrfCrop* pCrop = (SvxGrfCrop*)pItem;
171 : :
172 : 0 : aExampleWN.SetLeft( pCrop->GetLeft());
173 : 0 : aExampleWN.SetRight( pCrop->GetRight());
174 : 0 : aExampleWN.SetTop( pCrop->GetTop());
175 : 0 : aExampleWN.SetBottom( pCrop->GetBottom());
176 : :
177 [ # # ][ # # ]: 0 : aLeftMF.SetValue( aLeftMF.Normalize( pCrop->GetLeft()), eUnit );
178 [ # # ][ # # ]: 0 : aRightMF.SetValue( aRightMF.Normalize( pCrop->GetRight()), eUnit );
179 [ # # ][ # # ]: 0 : aTopMF.SetValue( aTopMF.Normalize( pCrop->GetTop()), eUnit );
180 [ # # ][ # # ]: 0 : aBottomMF.SetValue( aBottomMF.Normalize( pCrop->GetBottom()), eUnit );
181 : : }
182 : : else
183 : : {
184 [ # # ]: 0 : aLeftMF.SetValue( 0 );
185 [ # # ]: 0 : aRightMF.SetValue( 0 );
186 [ # # ]: 0 : aTopMF.SetValue( 0 );
187 [ # # ]: 0 : aBottomMF.SetValue( 0 );
188 : : }
189 : :
190 [ # # ]: 0 : nW = rPool.GetWhich( SID_ATTR_PAGE_SIZE );
191 [ # # ][ # # ]: 0 : if ( SFX_ITEM_SET == rSet.GetItemState( nW, sal_False, &pItem ) )
192 : : {
193 : : // orientation and size from the PageItem
194 [ # # ][ # # ]: 0 : FieldUnit eUnit = MapToFieldUnit( rSet.GetPool()->GetMetric( nW ));
195 : :
196 : 0 : aPageSize = ((const SvxSizeItem*)pItem)->GetSize();
197 : :
198 [ # # ]: 0 : sal_Int64 nTmp = aHeightMF.Normalize(aPageSize.Height());
199 [ # # ]: 0 : aHeightMF.SetMax( nTmp, eUnit );
200 [ # # ]: 0 : nTmp = aWidthMF.Normalize(aPageSize.Width());
201 [ # # ]: 0 : aWidthMF.SetMax( nTmp, eUnit );
202 [ # # ]: 0 : nTmp = aWidthMF.Normalize( 23 );
203 [ # # ]: 0 : aHeightMF.SetMin( nTmp, eUnit );
204 [ # # ]: 0 : aWidthMF.SetMin( nTmp, eUnit );
205 : : }
206 : : else
207 : : {
208 : : aPageSize = OutputDevice::LogicToLogic(
209 : : Size( CM_1_TO_TWIP, CM_1_TO_TWIP ),
210 : : MapMode( MAP_TWIP ),
211 [ # # ][ # # ]: 0 : MapMode( (MapUnit)rSet.GetPool()->GetMetric( nW ) ) );
[ # # ][ # # ]
[ # # ][ # # ]
212 : : }
213 : :
214 : 0 : sal_Bool bFound = sal_False;
215 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) )
216 : : {
217 [ # # ]: 0 : const Graphic* pGrf = ((SvxBrushItem*)pItem)->GetGraphic();
218 [ # # ]: 0 : if( pGrf ) {
219 [ # # ]: 0 : aOrigSize = GetGrfOrigSize( *pGrf );
220 [ # # ][ # # ]: 0 : if (pGrf->GetType() == GRAPHIC_BITMAP && aOrigSize.Width() && aOrigSize.Height()) {
[ # # ][ # # ]
[ # # ]
221 [ # # ]: 0 : Bitmap aBitmap = pGrf->GetBitmap();
222 [ # # ][ # # ]: 0 : aOrigPixelSize = aBitmap.GetSizePixel();
223 : : }
224 : : }
225 : :
226 [ # # ][ # # ]: 0 : if( aOrigSize.Width() && aOrigSize.Height() )
[ # # ]
227 : : {
228 [ # # ]: 0 : CalcMinMaxBorder();
229 [ # # ]: 0 : aExampleWN.SetGraphic( *pGrf );
230 [ # # ]: 0 : aExampleWN.SetFrameSize( aOrigSize );
231 : :
232 : 0 : bFound = sal_True;
233 [ # # ]: 0 : if( ((SvxBrushItem*)pItem)->GetGraphicLink() )
234 [ # # ]: 0 : aGraphicName = *((SvxBrushItem*)pItem)->GetGraphicLink();
235 : : }
236 : : }
237 : :
238 [ # # ]: 0 : GraphicHasChanged( bFound );
239 : 0 : bReset = sal_True;
240 [ # # ]: 0 : ActivatePage( rSet );
241 : 0 : bReset = sal_False;
242 : 0 : }
243 : :
244 : 0 : sal_Bool SvxGrfCropPage::FillItemSet(SfxItemSet &rSet)
245 : : {
246 : 0 : const SfxItemPool& rPool = *rSet.GetPool();
247 : 0 : sal_Bool bModified = sal_False;
248 [ # # ][ # # ]: 0 : if( aWidthMF.GetSavedValue() != aWidthMF.GetText() ||
[ # # ][ # # ]
[ # # # # ]
[ # # ]
249 [ # # ][ # # ]: 0 : aHeightMF.GetSavedValue() != aHeightMF.GetText() )
[ # # ][ # # ]
[ # # ]
250 : : {
251 [ # # ]: 0 : sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_FRMSIZE );
252 [ # # ][ # # ]: 0 : FieldUnit eUnit = MapToFieldUnit( rSet.GetPool()->GetMetric( nW ));
253 : :
254 [ # # ]: 0 : SvxSizeItem aSz( nW );
255 : :
256 : : // size could already have been set from another page
257 : : // #44204#
258 [ # # ]: 0 : const SfxItemSet* pExSet = GetTabDialog() ? GetTabDialog()->GetExampleSet() : NULL;
259 : 0 : const SfxPoolItem* pItem = 0;
260 [ # # ][ # # ]: 0 : if( pExSet && SFX_ITEM_SET ==
[ # # ]
261 [ # # ]: 0 : pExSet->GetItemState( nW, sal_False, &pItem ) )
262 : 0 : aSz = *(const SvxSizeItem*)pItem;
263 : : else
264 [ # # ]: 0 : aSz = (const SvxSizeItem&)GetItemSet().Get( nW );
265 : :
266 : 0 : Size aTmpSz( aSz.GetSize() );
267 [ # # ][ # # ]: 0 : if( aWidthMF.GetText() != aWidthMF.GetSavedValue() )
[ # # ][ # # ]
268 [ # # ]: 0 : aTmpSz.Width() = lcl_GetValue( aWidthMF, eUnit );
269 [ # # ][ # # ]: 0 : if( aHeightMF.GetText() != aHeightMF.GetSavedValue() )
[ # # ][ # # ]
270 [ # # ]: 0 : aTmpSz.Height() = lcl_GetValue( aHeightMF, eUnit );
271 : 0 : aSz.SetSize( aTmpSz );
272 [ # # ]: 0 : aWidthMF.SaveValue();
273 [ # # ]: 0 : aHeightMF.SaveValue();
274 : :
275 [ # # ]: 0 : bModified |= 0 != rSet.Put( aSz );
276 : :
277 [ # # ]: 0 : if( bSetOrigSize )
278 : : {
279 : : bModified |= 0 != rSet.Put( SvxSizeItem( rPool.GetWhich(
280 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_FRMSIZE_PERCENT ), Size( 0, 0 )) );
[ # # ][ # # ]
281 [ # # ]: 0 : }
282 : : }
283 [ # # ][ # # : 0 : if( aLeftMF.IsModified() || aRightMF.IsModified() ||
# # # # ]
[ # # ]
284 : 0 : aTopMF.IsModified() || aBottomMF.IsModified() )
285 : : {
286 : 0 : sal_uInt16 nW = rPool.GetWhich( SID_ATTR_GRAF_CROP );
287 : 0 : FieldUnit eUnit = MapToFieldUnit( rSet.GetPool()->GetMetric( nW ));
288 : 0 : SvxGrfCrop* pNew = (SvxGrfCrop*)rSet.Get( nW ).Clone();
289 : :
290 : 0 : pNew->SetLeft( lcl_GetValue( aLeftMF, eUnit ) );
291 : 0 : pNew->SetRight( lcl_GetValue( aRightMF, eUnit ) );
292 : 0 : pNew->SetTop( lcl_GetValue( aTopMF, eUnit ) );
293 : 0 : pNew->SetBottom( lcl_GetValue( aBottomMF, eUnit ) );
294 : 0 : bModified |= 0 != rSet.Put( *pNew );
295 [ # # ]: 0 : delete pNew;
296 : : }
297 : :
298 [ # # ]: 0 : if( aZoomConstRB.GetSavedValue() != aZoomConstRB.IsChecked() )
299 : : {
300 : : bModified |= 0 != rSet.Put( SfxBoolItem( rPool.GetWhich(
301 [ # # ]: 0 : SID_ATTR_GRAF_KEEP_ZOOM), aZoomConstRB.IsChecked() ) );
302 : : }
303 : :
304 : 0 : bInitialized = sal_False;
305 : :
306 : 0 : return bModified;
307 : : }
308 : :
309 : 0 : void SvxGrfCropPage::ActivatePage(const SfxItemSet& rSet)
310 : : {
311 : : #ifdef DBG_UTIL
312 : : SfxItemPool* pPool = GetItemSet().GetPool();
313 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
314 : : #endif
315 : :
316 : 0 : bSetOrigSize = sal_False;
317 : :
318 : : // Size
319 : 0 : Size aSize;
320 : : const SfxPoolItem* pItem;
321 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_FRMSIZE, sal_False, &pItem ) )
322 : 0 : aSize = ((const SvxSizeItem*)pItem)->GetSize();
323 : :
324 : 0 : nOldWidth = aSize.Width();
325 : 0 : nOldHeight = aSize.Height();
326 : :
327 [ # # ]: 0 : sal_Int64 nWidth = aWidthMF.Normalize(nOldWidth);
328 [ # # ]: 0 : sal_Int64 nHeight = aHeightMF.Normalize(nOldHeight);
329 : :
330 [ # # ][ # # ]: 0 : if (nWidth != aWidthMF.GetValue(FUNIT_TWIP))
331 : : {
332 [ # # ]: 0 : if(!bReset)
333 : : {
334 : : // value was changed by wrap-tabpage and has to
335 : : // be set with modify-flag
336 [ # # ]: 0 : aWidthMF.SetUserValue(nWidth, FUNIT_TWIP);
337 : : }
338 : : else
339 [ # # ]: 0 : aWidthMF.SetValue(nWidth, FUNIT_TWIP);
340 : : }
341 [ # # ]: 0 : aWidthMF.SaveValue();
342 : :
343 [ # # ][ # # ]: 0 : if (nHeight != aHeightMF.GetValue(FUNIT_TWIP))
344 : : {
345 [ # # ]: 0 : if (!bReset)
346 : : {
347 : : // value was changed by wrap-tabpage and has to
348 : : // be set with modify-flag
349 [ # # ]: 0 : aHeightMF.SetUserValue(nHeight, FUNIT_TWIP);
350 : : }
351 : : else
352 [ # # ]: 0 : aHeightMF.SetValue(nHeight, FUNIT_TWIP);
353 : : }
354 [ # # ]: 0 : aHeightMF.SaveValue();
355 : 0 : bInitialized = sal_True;
356 : :
357 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRAF_GRAPHIC, sal_False, &pItem ) )
358 : : {
359 : 0 : const SvxBrushItem& rBrush = *(SvxBrushItem*)pItem;
360 [ # # ][ # # ]: 0 : if( rBrush.GetGraphicLink() &&
[ # # ]
361 [ # # ]: 0 : aGraphicName != *rBrush.GetGraphicLink() )
362 [ # # ]: 0 : aGraphicName = *rBrush.GetGraphicLink();
363 : :
364 [ # # ]: 0 : const Graphic* pGrf = rBrush.GetGraphic();
365 [ # # ]: 0 : if( pGrf )
366 : : {
367 [ # # ]: 0 : aExampleWN.SetGraphic( *pGrf );
368 [ # # ]: 0 : aOrigSize = GetGrfOrigSize( *pGrf );
369 [ # # ][ # # ]: 0 : if (pGrf->GetType() == GRAPHIC_BITMAP && aOrigSize.Width() > 1 && aOrigSize.Height() > 1) {
[ # # ][ # # ]
[ # # ]
370 [ # # ]: 0 : Bitmap aBitmap = pGrf->GetBitmap();
371 [ # # ][ # # ]: 0 : aOrigPixelSize = aBitmap.GetSizePixel();
372 : : }
373 [ # # ]: 0 : aExampleWN.SetFrameSize(aOrigSize);
374 [ # # ][ # # ]: 0 : GraphicHasChanged( aOrigSize.Width() && aOrigSize.Height() );
[ # # ]
375 [ # # ]: 0 : CalcMinMaxBorder();
376 : : }
377 : : else
378 [ # # ]: 0 : GraphicHasChanged( sal_False );
379 : : }
380 : :
381 [ # # ]: 0 : CalcZoom();
382 : 0 : }
383 : :
384 : 0 : int SvxGrfCropPage::DeactivatePage(SfxItemSet *_pSet)
385 : : {
386 [ # # ]: 0 : if ( _pSet )
387 : 0 : FillItemSet( *_pSet );
388 : 0 : return sal_True;
389 : : }
390 : :
391 : : /*--------------------------------------------------------------------
392 : : description: scale changed, adjust size
393 : : --------------------------------------------------------------------*/
394 : :
395 : 0 : IMPL_LINK( SvxGrfCropPage, ZoomHdl, MetricField *, pField )
396 : : {
397 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
398 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
399 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
400 : 0 : SID_ATTR_GRAF_CROP ) ) );
401 : :
402 [ # # ]: 0 : if( pField == &aWidthZoomMF )
403 : : {
404 : 0 : long nLRBorders = lcl_GetValue(aLeftMF, eUnit)
405 : 0 : +lcl_GetValue(aRightMF, eUnit);
406 : : aWidthMF.SetValue( aWidthMF.Normalize(
407 : 0 : ((aOrigSize.Width() - nLRBorders) * pField->GetValue())/100L),
408 : 0 : eUnit);
409 : : }
410 : : else
411 : : {
412 : 0 : long nULBorders = lcl_GetValue(aTopMF, eUnit)
413 : 0 : +lcl_GetValue(aBottomMF, eUnit);
414 : : aHeightMF.SetValue( aHeightMF.Normalize(
415 : 0 : ((aOrigSize.Height() - nULBorders ) * pField->GetValue())/100L) ,
416 : 0 : eUnit );
417 : : }
418 : :
419 : 0 : return 0;
420 : : }
421 : :
422 : : /*--------------------------------------------------------------------
423 : : description: change size, adjust scale
424 : : --------------------------------------------------------------------*/
425 : :
426 : 0 : IMPL_LINK( SvxGrfCropPage, SizeHdl, MetricField *, pField )
427 : : {
428 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
429 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
430 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
431 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_CROP ) ) );
[ # # ]
432 : :
433 : : Size aSize( lcl_GetValue(aWidthMF, eUnit),
434 [ # # ][ # # ]: 0 : lcl_GetValue(aHeightMF, eUnit) );
435 : :
436 [ # # ]: 0 : if(pField == &aWidthMF)
437 : : {
438 : 0 : long nWidth = aOrigSize.Width() -
439 [ # # ]: 0 : ( lcl_GetValue(aLeftMF, eUnit) +
440 [ # # ]: 0 : lcl_GetValue(aRightMF, eUnit) );
441 [ # # ]: 0 : if(!nWidth)
442 : 0 : nWidth++;
443 : 0 : sal_uInt16 nZoom = (sal_uInt16)( aSize.Width() * 100L / nWidth);
444 [ # # ]: 0 : aWidthZoomMF.SetValue(nZoom);
445 : : }
446 : : else
447 : : {
448 : 0 : long nHeight = aOrigSize.Height() -
449 [ # # ]: 0 : ( lcl_GetValue(aTopMF, eUnit) +
450 [ # # ]: 0 : lcl_GetValue(aBottomMF, eUnit));
451 [ # # ]: 0 : if(!nHeight)
452 : 0 : nHeight++;
453 : 0 : sal_uInt16 nZoom = (sal_uInt16)( aSize.Height() * 100L/ nHeight);
454 [ # # ]: 0 : aHeightZoomMF.SetValue(nZoom);
455 : : }
456 : :
457 : 0 : return 0;
458 : : }
459 : :
460 : : /*--------------------------------------------------------------------
461 : : description: evaluate border
462 : : --------------------------------------------------------------------*/
463 : :
464 : 0 : IMPL_LINK( SvxGrfCropPage, CropHdl, const MetricField *, pField )
465 : : {
466 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
467 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
468 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
469 : 0 : SID_ATTR_GRAF_CROP ) ) );
470 : :
471 : 0 : sal_Bool bZoom = aZoomConstRB.IsChecked();
472 [ # # ][ # # ]: 0 : if( pField == &aLeftMF || pField == &aRightMF )
473 : : {
474 : 0 : long nLeft = lcl_GetValue( aLeftMF, eUnit );
475 : 0 : long nRight = lcl_GetValue( aRightMF, eUnit );
476 : 0 : long nWidthZoom = static_cast<long>(aWidthZoomMF.GetValue());
477 [ # # ][ # # ]: 0 : if(bZoom && ( ( ( aOrigSize.Width() - (nLeft + nRight )) * nWidthZoom )
[ # # ]
478 : 0 : / 100 >= aPageSize.Width() ) )
479 : : {
480 [ # # ]: 0 : if(pField == &aLeftMF)
481 : : {
482 : 0 : nLeft = aOrigSize.Width() -
483 : 0 : ( aPageSize.Width() * 100 / nWidthZoom + nRight );
484 : 0 : aLeftMF.SetValue( aLeftMF.Normalize( nLeft ), eUnit );
485 : : }
486 : : else
487 : : {
488 : 0 : nRight = aOrigSize.Width() -
489 : 0 : ( aPageSize.Width() * 100 / nWidthZoom + nLeft );
490 : 0 : aRightMF.SetValue( aRightMF.Normalize( nRight ), eUnit );
491 : : }
492 : : }
493 : 0 : aExampleWN.SetLeft(nLeft);
494 : 0 : aExampleWN.SetRight(nRight);
495 [ # # ]: 0 : if(bZoom)
496 : : {
497 : : // scale stays, recompute width
498 : 0 : ZoomHdl(&aWidthZoomMF);
499 : 0 : }
500 : : }
501 : : else
502 : : {
503 : 0 : long nTop = lcl_GetValue( aTopMF, eUnit );
504 : 0 : long nBottom = lcl_GetValue( aBottomMF, eUnit );
505 : 0 : long nHeightZoom = static_cast<long>(aHeightZoomMF.GetValue());
506 [ # # ][ # # ]: 0 : if(bZoom && ( ( ( aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom)
[ # # ]
507 : 0 : / 100 >= aPageSize.Height()))
508 : : {
509 [ # # ]: 0 : if(pField == &aTopMF)
510 : : {
511 : 0 : nTop = aOrigSize.Height() -
512 : 0 : ( aPageSize.Height() * 100 / nHeightZoom + nBottom);
513 : 0 : aTopMF.SetValue( aWidthMF.Normalize( nTop ), eUnit );
514 : : }
515 : : else
516 : : {
517 : 0 : nBottom = aOrigSize.Height() -
518 : 0 : ( aPageSize.Height() * 100 / nHeightZoom + nTop);
519 : 0 : aBottomMF.SetValue( aWidthMF.Normalize( nBottom ), eUnit );
520 : : }
521 : : }
522 : 0 : aExampleWN.SetTop( nTop );
523 : 0 : aExampleWN.SetBottom( nBottom );
524 [ # # ]: 0 : if(bZoom)
525 : : {
526 : : // scale stays, recompute height
527 : 0 : ZoomHdl(&aHeightZoomMF);
528 : : }
529 : : }
530 : 0 : aExampleWN.Invalidate();
531 : : // size and border changed -> recompute scale
532 [ # # ]: 0 : if(!bZoom)
533 : 0 : CalcZoom();
534 : 0 : CalcMinMaxBorder();
535 : 0 : return 0;
536 : : }
537 : : /*--------------------------------------------------------------------
538 : : description: set original size
539 : : --------------------------------------------------------------------*/
540 : :
541 : 0 : IMPL_LINK_NOARG(SvxGrfCropPage, OrigSizeHdl)
542 : : {
543 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
544 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
545 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
546 : 0 : SID_ATTR_GRAF_CROP ) ) );
547 : :
548 : 0 : long nWidth = aOrigSize.Width() -
549 : 0 : lcl_GetValue( aLeftMF, eUnit ) -
550 : 0 : lcl_GetValue( aRightMF, eUnit );
551 : 0 : aWidthMF.SetValue( aWidthMF.Normalize( nWidth ), eUnit );
552 : 0 : long nHeight = aOrigSize.Height() -
553 : 0 : lcl_GetValue( aTopMF, eUnit ) -
554 : 0 : lcl_GetValue( aBottomMF, eUnit );
555 : 0 : aHeightMF.SetValue( aHeightMF.Normalize( nHeight ), eUnit );
556 : 0 : aWidthZoomMF.SetValue(100);
557 : 0 : aHeightZoomMF.SetValue(100);
558 : 0 : bSetOrigSize = sal_True;
559 : 0 : return 0;
560 : : }
561 : : /*--------------------------------------------------------------------
562 : : description: compute scale
563 : : --------------------------------------------------------------------*/
564 : :
565 : 0 : void SvxGrfCropPage::CalcZoom()
566 : : {
567 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
568 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
569 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
570 : 0 : SID_ATTR_GRAF_CROP ) ) );
571 : :
572 : 0 : long nWidth = lcl_GetValue( aWidthMF, eUnit );
573 : 0 : long nHeight = lcl_GetValue( aHeightMF, eUnit );
574 : 0 : long nLRBorders = lcl_GetValue( aLeftMF, eUnit ) +
575 : 0 : lcl_GetValue( aRightMF, eUnit );
576 : 0 : long nULBorders = lcl_GetValue( aTopMF, eUnit ) +
577 : 0 : lcl_GetValue( aBottomMF, eUnit );
578 : 0 : sal_uInt16 nZoom = 0;
579 : : long nDen;
580 [ # # ]: 0 : if( (nDen = aOrigSize.Width() - nLRBorders) > 0)
581 : 0 : nZoom = (sal_uInt16)((( nWidth * 1000L / nDen )+5)/10);
582 : 0 : aWidthZoomMF.SetValue(nZoom);
583 [ # # ]: 0 : if( (nDen = aOrigSize.Height() - nULBorders) > 0)
584 : 0 : nZoom = (sal_uInt16)((( nHeight * 1000L / nDen )+5)/10);
585 : : else
586 : 0 : nZoom = 0;
587 : 0 : aHeightZoomMF.SetValue(nZoom);
588 : 0 : }
589 : :
590 : : /*--------------------------------------------------------------------
591 : : description: set minimum/maximum values for the margins
592 : : --------------------------------------------------------------------*/
593 : :
594 : 0 : void SvxGrfCropPage::CalcMinMaxBorder()
595 : : {
596 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
597 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
598 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
599 : 0 : SID_ATTR_GRAF_CROP ) ) );
600 : 0 : long nR = lcl_GetValue(aRightMF, eUnit );
601 : 0 : long nMinWidth = (aOrigSize.Width() * 10) /11;
602 : 0 : long nMin = nMinWidth - (nR >= 0 ? nR : 0);
603 : 0 : aLeftMF.SetMax( aLeftMF.Normalize(nMin), eUnit );
604 : :
605 : 0 : long nL = lcl_GetValue(aLeftMF, eUnit );
606 : 0 : nMin = nMinWidth - (nL >= 0 ? nL : 0);
607 : 0 : aRightMF.SetMax( aRightMF.Normalize(nMin), eUnit );
608 : :
609 : 0 : long nUp = lcl_GetValue( aTopMF, eUnit );
610 : 0 : long nMinHeight = (aOrigSize.Height() * 10) /11;
611 : 0 : nMin = nMinHeight - (nUp >= 0 ? nUp : 0);
612 : 0 : aBottomMF.SetMax( aBottomMF.Normalize(nMin), eUnit );
613 : :
614 : 0 : long nLow = lcl_GetValue(aBottomMF, eUnit );
615 : 0 : nMin = nMinHeight - (nLow >= 0 ? nLow : 0);
616 : 0 : aTopMF.SetMax( aTopMF.Normalize(nMin), eUnit );
617 : 0 : }
618 : : /*--------------------------------------------------------------------
619 : : description: set spinsize to 1/20 of the original size,
620 : : fill FixedText with the original size
621 : : --------------------------------------------------------------------*/
622 : :
623 : 0 : void SvxGrfCropPage::GraphicHasChanged( sal_Bool bFound )
624 : : {
625 [ # # ]: 0 : if( bFound )
626 : : {
627 : 0 : SfxItemPool* pPool = GetItemSet().GetPool();
628 : : DBG_ASSERT( pPool, "Wo ist der Pool" );
629 : : FieldUnit eUnit = MapToFieldUnit( pPool->GetMetric( pPool->GetWhich(
630 [ # # ][ # # ]: 0 : SID_ATTR_GRAF_CROP ) ));
[ # # ]
631 : :
632 [ # # ]: 0 : sal_Int64 nSpin = aLeftMF.Normalize(aOrigSize.Width()) / 20;
633 : 0 : nSpin = MetricField::ConvertValue( nSpin, aOrigSize.Width(), 0,
634 [ # # ]: 0 : eUnit, aLeftMF.GetUnit());
635 : :
636 : : // if the margin is too big, it is set to 1/3 on both pages
637 [ # # ]: 0 : long nR = lcl_GetValue( aRightMF, eUnit );
638 [ # # ]: 0 : long nL = lcl_GetValue( aLeftMF, eUnit );
639 [ # # ]: 0 : if((nL + nR) < - aOrigSize.Width())
640 : : {
641 : 0 : long nVal = aOrigSize.Width() / -3;
642 [ # # ][ # # ]: 0 : aRightMF.SetValue( aRightMF.Normalize( nVal ), eUnit );
643 [ # # ][ # # ]: 0 : aLeftMF.SetValue( aLeftMF.Normalize( nVal ), eUnit );
644 : 0 : aExampleWN.SetLeft(nVal);
645 : 0 : aExampleWN.SetRight(nVal);
646 : : }
647 [ # # ]: 0 : long nUp = lcl_GetValue(aTopMF, eUnit );
648 [ # # ]: 0 : long nLow = lcl_GetValue(aBottomMF, eUnit );
649 [ # # ]: 0 : if((nUp + nLow) < - aOrigSize.Height())
650 : : {
651 : 0 : long nVal = aOrigSize.Height() / -3;
652 [ # # ][ # # ]: 0 : aTopMF.SetValue( aTopMF.Normalize( nVal ), eUnit );
653 [ # # ][ # # ]: 0 : aBottomMF.SetValue( aBottomMF.Normalize( nVal ), eUnit );
654 : 0 : aExampleWN.SetTop(nVal);
655 : 0 : aExampleWN.SetBottom(nVal);
656 : : }
657 : :
658 : 0 : aLeftMF.SetSpinSize(nSpin);
659 : 0 : aRightMF.SetSpinSize(nSpin);
660 [ # # ]: 0 : nSpin = aTopMF.Normalize(aOrigSize.Height()) / 20;
661 : 0 : nSpin = MetricField::ConvertValue( nSpin, aOrigSize.Width(), 0,
662 [ # # ]: 0 : eUnit, aLeftMF.GetUnit() );
663 : 0 : aTopMF.SetSpinSize(nSpin);
664 : 0 : aBottomMF.SetSpinSize(nSpin);
665 : :
666 : : // display original size
667 [ # # ]: 0 : const FieldUnit eMetric = GetModuleFieldUnit( GetItemSet() );
668 : :
669 [ # # ]: 0 : MetricField aFld(this, WB_HIDE);
670 [ # # ]: 0 : SetFieldUnit( aFld, eMetric );
671 [ # # ][ # # ]: 0 : aFld.SetDecimalDigits( aWidthMF.GetDecimalDigits() );
672 [ # # ]: 0 : aFld.SetMax( LONG_MAX - 1 );
673 : :
674 [ # # ][ # # ]: 0 : aFld.SetValue( aFld.Normalize( aOrigSize.Width() ), eUnit );
675 [ # # ]: 0 : String sTemp = aFld.GetText();
676 [ # # ][ # # ]: 0 : aFld.SetValue( aFld.Normalize( aOrigSize.Height() ), eUnit );
677 : : // multiplication sign (U+00D7)
678 [ # # ][ # # ]: 0 : sTemp += UniString("\xc3\x97", RTL_TEXTENCODING_UTF8);
[ # # ]
679 [ # # ][ # # ]: 0 : sTemp += aFld.GetText();
[ # # ]
680 : :
681 [ # # ][ # # ]: 0 : if ( aOrigPixelSize.Width() && aOrigPixelSize.Height() ) {
[ # # ]
682 : 0 : int ax = int(floor((float)aOrigPixelSize.Width() /
683 : 0 : ((float)aOrigSize.Width()/TWIP_TO_INCH)+0.5));
684 : 0 : int ay = int(floor((float)aOrigPixelSize.Height() /
685 : 0 : ((float)aOrigSize.Height()/TWIP_TO_INCH)+0.5));
686 [ # # ]: 0 : sTemp += rtl::OUString(" ");
687 [ # # ][ # # ]: 0 : sTemp += CUI_RESSTR( STR_PPI );
[ # # ]
688 [ # # ]: 0 : String sPPI = UniString::CreateFromInt32(ax);
689 [ # # ]: 0 : if (abs(ax - ay) > 1) {
690 [ # # ][ # # ]: 0 : sPPI += UniString("\xc3\x97", RTL_TEXTENCODING_UTF8);
[ # # ]
691 [ # # ][ # # ]: 0 : sPPI += UniString::CreateFromInt32(ay);
[ # # ]
692 : : }
693 [ # # ][ # # ]: 0 : sTemp.SearchAndReplaceAscii("%1", sPPI);
694 : : }
695 [ # # ][ # # ]: 0 : aOrigSizeFT.SetText( sTemp );
[ # # ]
696 : : }
697 : 0 : aLeftFT .Enable(bFound);
698 : 0 : aLeftMF .Enable(bFound);
699 : 0 : aRightFT .Enable(bFound);
700 : 0 : aRightMF .Enable(bFound);
701 : 0 : aTopFT .Enable(bFound);
702 : 0 : aTopMF .Enable(bFound);
703 : 0 : aBottomFT .Enable(bFound);
704 : 0 : aBottomMF .Enable(bFound);
705 : 0 : aSizeConstRB .Enable(bFound);
706 : 0 : aZoomConstRB .Enable(bFound);
707 : 0 : aWidthFT .Enable(bFound);
708 : 0 : aWidthMF .Enable(bFound);
709 : 0 : aHeightFT .Enable(bFound);
710 : 0 : aHeightMF .Enable(bFound);
711 : 0 : aWidthZoomFT .Enable(bFound);
712 : 0 : aWidthZoomMF .Enable(bFound);
713 : 0 : aHeightZoomFT .Enable(bFound);
714 : 0 : aHeightZoomMF .Enable(bFound);
715 : 0 : aExampleWN .Enable(bFound);
716 : 0 : aOrigSizePB .Enable(bFound);
717 : 0 : aOrigSizeFT .Enable(bFound);
718 : 0 : }
719 : :
720 : 0 : IMPL_LINK_NOARG(SvxGrfCropPage, Timeout)
721 : : {
722 : : DBG_ASSERT(pLastCropField,"Timeout ohne Feld?");
723 : 0 : CropHdl(pLastCropField);
724 : 0 : pLastCropField = 0;
725 : 0 : return 0;
726 : : }
727 : :
728 : :
729 : 0 : IMPL_LINK( SvxGrfCropPage, CropLoseFocusHdl, MetricField*, pField )
730 : : {
731 : 0 : aTimer.Stop();
732 : 0 : CropHdl(pField);
733 : 0 : pLastCropField = 0;
734 : 0 : return 0;
735 : : }
736 : :
737 : :
738 : 0 : IMPL_LINK( SvxGrfCropPage, CropModifyHdl, MetricField *, pField )
739 : : {
740 : 0 : aTimer.Start();
741 : 0 : pLastCropField = pField;
742 : 0 : return 0;
743 : : }
744 : :
745 : 0 : Size SvxGrfCropPage::GetGrfOrigSize( const Graphic& rGrf ) const
746 : : {
747 [ # # ]: 0 : const MapMode aMapTwip( MAP_TWIP );
748 [ # # ]: 0 : Size aSize( rGrf.GetPrefSize() );
749 [ # # ][ # # ]: 0 : if( MAP_PIXEL == rGrf.GetPrefMapMode().GetMapUnit() )
[ # # ]
750 [ # # ]: 0 : aSize = PixelToLogic( aSize, aMapTwip );
751 : : else
752 : : aSize = OutputDevice::LogicToLogic( aSize,
753 [ # # ][ # # ]: 0 : rGrf.GetPrefMapMode(), aMapTwip );
[ # # ]
754 [ # # ]: 0 : return aSize;
755 : : }
756 : :
757 : : /*****************************************************************/
758 : :
759 : 0 : SvxGrfCropPage::SvxCropExample::SvxCropExample( Window* pPar,
760 : : const ResId& rResId )
761 : : : Window( pPar, rResId ),
762 : : aFrameSize( OutputDevice::LogicToLogic(
763 : : Size( CM_1_TO_TWIP / 2, CM_1_TO_TWIP / 2 ),
764 [ # # ][ # # ]: 0 : MapMode( MAP_TWIP ), GetMapMode() )),
765 [ # # ][ # # ]: 0 : aTopLeft(0,0), aBottomRight(0,0)
766 : : {
767 [ # # ]: 0 : SetBorderStyle( WINDOW_BORDER_MONO );
768 : 0 : }
769 : :
770 : 0 : void SvxGrfCropPage::SvxCropExample::Paint( const Rectangle& )
771 : : {
772 [ # # ]: 0 : Size aWinSize( PixelToLogic(GetOutputSizePixel() ));
773 [ # # ]: 0 : SetLineColor();
774 [ # # ]: 0 : SetFillColor( GetSettings().GetStyleSettings().GetWindowColor() );
775 [ # # ]: 0 : SetRasterOp( ROP_OVERPAINT );
776 [ # # ][ # # ]: 0 : DrawRect( Rectangle( Point(), aWinSize ) );
777 : :
778 [ # # ]: 0 : SetLineColor( Color( COL_WHITE ) );
779 : 0 : Rectangle aRect(Point((aWinSize.Width() - aFrameSize.Width())/2,
780 : 0 : (aWinSize.Height() - aFrameSize.Height())/2),
781 [ # # ]: 0 : aFrameSize );
782 [ # # ][ # # ]: 0 : aGrf.Draw( this, aRect.TopLeft(), aRect.GetSize() );
783 : :
784 : 0 : Size aSz( 2, 0 );
785 [ # # ]: 0 : aSz = PixelToLogic( aSz );
786 [ # # ]: 0 : SetFillColor( Color( COL_TRANSPARENT ) );
787 [ # # ]: 0 : SetRasterOp( ROP_INVERT );
788 : 0 : aRect.Left() += aTopLeft.Y();
789 : 0 : aRect.Top() += aTopLeft.X();
790 : 0 : aRect.Right() -= aBottomRight.Y();
791 : 0 : aRect.Bottom() -= aBottomRight.X();
792 [ # # ]: 0 : DrawRect( aRect );
793 : 0 : }
794 : :
795 : 0 : void SvxGrfCropPage::SvxCropExample::SetFrameSize( const Size& rSz )
796 : : {
797 : 0 : aFrameSize = rSz;
798 [ # # ]: 0 : if(!aFrameSize.Width())
799 : 0 : aFrameSize.Width() = 1;
800 [ # # ]: 0 : if(!aFrameSize.Height())
801 : 0 : aFrameSize.Height() = 1;
802 : 0 : Size aWinSize( GetOutputSizePixel() );
803 [ # # ]: 0 : Fraction aXScale( aWinSize.Width() * 4, aFrameSize.Width() * 5 );
804 [ # # ]: 0 : Fraction aYScale( aWinSize.Height() * 4, aFrameSize.Height() * 5 );
805 : :
806 [ # # ][ # # ]: 0 : if( aYScale < aXScale )
807 [ # # ]: 0 : aXScale = aYScale;
808 : :
809 [ # # ]: 0 : MapMode aMapMode( GetMapMode() );
810 : :
811 [ # # ]: 0 : aMapMode.SetScaleX( aXScale );
812 [ # # ]: 0 : aMapMode.SetScaleY( aXScale );
813 : :
814 [ # # ]: 0 : SetMapMode( aMapMode );
815 [ # # ][ # # ]: 0 : Invalidate();
816 : 0 : }
817 : :
818 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|