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_editeng.hxx" 30 #include <vcl/outdev.hxx> 31 #include <vcl/window.hxx> 32 33 #include <editeng/unoviwed.hxx> 34 #include <editeng/editview.hxx> 35 #include <editeng/editeng.hxx> 36 37 SvxEditEngineViewForwarder::SvxEditEngineViewForwarder( EditView& rView ) : 38 mrView( rView ) 39 { 40 } 41 42 SvxEditEngineViewForwarder::~SvxEditEngineViewForwarder() 43 { 44 } 45 46 sal_Bool SvxEditEngineViewForwarder::IsValid() const 47 { 48 return sal_True; 49 } 50 51 Rectangle SvxEditEngineViewForwarder::GetVisArea() const 52 { 53 OutputDevice* pOutDev = mrView.GetWindow(); 54 55 if( pOutDev ) 56 { 57 Rectangle aVisArea = mrView.GetVisArea(); 58 59 // figure out map mode from edit engine 60 EditEngine* pEditEngine = mrView.GetEditEngine(); 61 62 if( pEditEngine ) 63 { 64 MapMode aMapMode(pOutDev->GetMapMode()); 65 aVisArea = OutputDevice::LogicToLogic( aVisArea, 66 pEditEngine->GetRefMapMode(), 67 aMapMode.GetMapUnit() ); 68 aMapMode.SetOrigin(Point()); 69 return pOutDev->LogicToPixel( aVisArea, aMapMode ); 70 } 71 } 72 73 return Rectangle(); 74 } 75 76 Point SvxEditEngineViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const 77 { 78 OutputDevice* pOutDev = mrView.GetWindow(); 79 80 if( pOutDev ) 81 { 82 MapMode aMapMode(pOutDev->GetMapMode()); 83 Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode, 84 aMapMode.GetMapUnit() ) ); 85 aMapMode.SetOrigin(Point()); 86 return pOutDev->LogicToPixel( aPoint, aMapMode ); 87 } 88 89 return Point(); 90 } 91 92 Point SvxEditEngineViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const 93 { 94 OutputDevice* pOutDev = mrView.GetWindow(); 95 96 if( pOutDev ) 97 { 98 MapMode aMapMode(pOutDev->GetMapMode()); 99 aMapMode.SetOrigin(Point()); 100 Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) ); 101 return OutputDevice::LogicToLogic( aPoint, 102 aMapMode.GetMapUnit(), 103 rMapMode ); 104 } 105 106 return Point(); 107 } 108 109 sal_Bool SvxEditEngineViewForwarder::GetSelection( ESelection& rSelection ) const 110 { 111 rSelection = mrView.GetSelection(); 112 return sal_True; 113 } 114 115 sal_Bool SvxEditEngineViewForwarder::SetSelection( const ESelection& rSelection ) 116 { 117 mrView.SetSelection( rSelection ); 118 return sal_True; 119 } 120 121 sal_Bool SvxEditEngineViewForwarder::Copy() 122 { 123 mrView.Copy(); 124 return sal_True; 125 } 126 127 sal_Bool SvxEditEngineViewForwarder::Cut() 128 { 129 mrView.Cut(); 130 return sal_True; 131 } 132 133 sal_Bool SvxEditEngineViewForwarder::Paste() 134 { 135 mrView.Paste(); 136 return sal_True; 137 } 138