Update ooo320-m1
[ooovba.git] / svx / source / unoedit / unoviwou.cxx
blob9825d6db537dfe4be6218e5112a261af99e59c87
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoviwou.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <vcl/outdev.hxx>
34 #include <vcl/window.hxx>
36 #include <svx/unoviwou.hxx>
37 #include <svx/outliner.hxx>
38 #include <svx/editeng.hxx>
39 #include <svx/svdotext.hxx>
42 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl ) :
43 mrOutlinerView ( rOutl ), maTextShapeTopLeft()
47 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl, const Point& rShapePosTopLeft ) :
48 mrOutlinerView ( rOutl ), maTextShapeTopLeft( rShapePosTopLeft )
52 SvxDrawOutlinerViewForwarder::~SvxDrawOutlinerViewForwarder()
56 Point SvxDrawOutlinerViewForwarder::GetTextOffset() const
58 // #101029# calc text offset from shape anchor
59 Rectangle aOutputRect( mrOutlinerView.GetOutputArea() );
61 return aOutputRect.TopLeft() - maTextShapeTopLeft;
64 BOOL SvxDrawOutlinerViewForwarder::IsValid() const
66 return sal_True;
69 Rectangle SvxDrawOutlinerViewForwarder::GetVisArea() const
71 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
73 if( pOutDev )
75 Rectangle aVisArea = mrOutlinerView.GetVisArea();
77 // #101029#
78 Point aTextOffset( GetTextOffset() );
79 aVisArea.Move( aTextOffset.X(), aTextOffset.Y() );
81 // figure out map mode from edit engine
82 Outliner* pOutliner = mrOutlinerView.GetOutliner();
84 if( pOutliner )
86 MapMode aMapMode(pOutDev->GetMapMode());
87 aVisArea = OutputDevice::LogicToLogic( aVisArea,
88 pOutliner->GetRefMapMode(),
89 aMapMode.GetMapUnit() );
90 aMapMode.SetOrigin(Point());
91 return pOutDev->LogicToPixel( aVisArea, aMapMode );
95 return Rectangle();
98 Point SvxDrawOutlinerViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
100 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
102 if( pOutDev )
104 Point aPoint1( rPoint );
105 Point aTextOffset( GetTextOffset() );
107 // #101029#
108 aPoint1.X() += aTextOffset.X();
109 aPoint1.Y() += aTextOffset.Y();
111 MapMode aMapMode(pOutDev->GetMapMode());
112 Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
113 aMapMode.GetMapUnit() ) );
114 aMapMode.SetOrigin(Point());
115 return pOutDev->LogicToPixel( aPoint2, aMapMode );
118 return Point();
121 Point SvxDrawOutlinerViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
123 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
125 if( pOutDev )
127 MapMode aMapMode(pOutDev->GetMapMode());
128 aMapMode.SetOrigin(Point());
129 Point aPoint1( pOutDev->PixelToLogic( rPoint, aMapMode ) );
130 Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
131 aMapMode.GetMapUnit(),
132 rMapMode ) );
133 // #101029#
134 Point aTextOffset( GetTextOffset() );
136 aPoint2.X() -= aTextOffset.X();
137 aPoint2.Y() -= aTextOffset.Y();
139 return aPoint2;
142 return Point();
145 sal_Bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection& rSelection ) const
147 rSelection = mrOutlinerView.GetSelection();
148 return sal_True;
151 sal_Bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection& rSelection )
153 mrOutlinerView.SetSelection( rSelection );
154 return sal_True;
157 sal_Bool SvxDrawOutlinerViewForwarder::Copy()
159 mrOutlinerView.Copy();
160 return sal_True;
163 sal_Bool SvxDrawOutlinerViewForwarder::Cut()
165 mrOutlinerView.Cut();
166 return sal_True;
169 sal_Bool SvxDrawOutlinerViewForwarder::Paste()
171 mrOutlinerView.Paste();
172 return sal_True;
175 void SvxDrawOutlinerViewForwarder::SetShapePos( const Point& rShapePosTopLeft )
177 maTextShapeTopLeft = rShapePosTopLeft;