1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unoviwou.cxx,v $
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
69 Rectangle
SvxDrawOutlinerViewForwarder::GetVisArea() const
71 OutputDevice
* pOutDev
= mrOutlinerView
.GetWindow();
75 Rectangle aVisArea
= mrOutlinerView
.GetVisArea();
78 Point
aTextOffset( GetTextOffset() );
79 aVisArea
.Move( aTextOffset
.X(), aTextOffset
.Y() );
81 // figure out map mode from edit engine
82 Outliner
* pOutliner
= mrOutlinerView
.GetOutliner();
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
);
98 Point
SvxDrawOutlinerViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
100 OutputDevice
* pOutDev
= mrOutlinerView
.GetWindow();
104 Point
aPoint1( rPoint
);
105 Point
aTextOffset( GetTextOffset() );
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
);
121 Point
SvxDrawOutlinerViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
123 OutputDevice
* pOutDev
= mrOutlinerView
.GetWindow();
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(),
134 Point
aTextOffset( GetTextOffset() );
136 aPoint2
.X() -= aTextOffset
.X();
137 aPoint2
.Y() -= aTextOffset
.Y();
145 sal_Bool
SvxDrawOutlinerViewForwarder::GetSelection( ESelection
& rSelection
) const
147 rSelection
= mrOutlinerView
.GetSelection();
151 sal_Bool
SvxDrawOutlinerViewForwarder::SetSelection( const ESelection
& rSelection
)
153 mrOutlinerView
.SetSelection( rSelection
);
157 sal_Bool
SvxDrawOutlinerViewForwarder::Copy()
159 mrOutlinerView
.Copy();
163 sal_Bool
SvxDrawOutlinerViewForwarder::Cut()
165 mrOutlinerView
.Cut();
169 sal_Bool
SvxDrawOutlinerViewForwarder::Paste()
171 mrOutlinerView
.Paste();
175 void SvxDrawOutlinerViewForwarder::SetShapePos( const Point
& rShapePosTopLeft
)
177 maTextShapeTopLeft
= rShapePosTopLeft
;