1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <vcl/outdev.hxx>
21 #include <vcl/window.hxx>
23 #include <editeng/unoviwou.hxx>
24 #include <editeng/outliner.hxx>
26 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView
& rOutl
) :
27 mrOutlinerView ( rOutl
)
31 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView
& rOutl
, const Point
& rShapePosTopLeft
) :
32 mrOutlinerView ( rOutl
), maTextShapeTopLeft( rShapePosTopLeft
)
36 SvxDrawOutlinerViewForwarder::~SvxDrawOutlinerViewForwarder()
40 Point
SvxDrawOutlinerViewForwarder::GetTextOffset() const
42 // calc text offset from shape anchor
43 tools::Rectangle
aOutputRect( mrOutlinerView
.GetOutputArea() );
45 return aOutputRect
.TopLeft() - maTextShapeTopLeft
;
48 bool SvxDrawOutlinerViewForwarder::IsValid() const
53 Point
SvxDrawOutlinerViewForwarder::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
55 OutputDevice
* pOutDev
= mrOutlinerView
.GetWindow()->GetOutDev();
59 Point
aPoint1( rPoint
);
60 Point
aTextOffset( GetTextOffset() );
62 aPoint1
.AdjustX(aTextOffset
.X() );
63 aPoint1
.AdjustY(aTextOffset
.Y() );
65 MapMode
aMapMode(pOutDev
->GetMapMode());
66 Point
aPoint2( OutputDevice::LogicToLogic( aPoint1
, rMapMode
,
67 MapMode(aMapMode
.GetMapUnit())));
68 aMapMode
.SetOrigin(Point());
69 return pOutDev
->LogicToPixel( aPoint2
, aMapMode
);
75 Point
SvxDrawOutlinerViewForwarder::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
77 OutputDevice
* pOutDev
= mrOutlinerView
.GetWindow()->GetOutDev();
81 MapMode
aMapMode(pOutDev
->GetMapMode());
82 aMapMode
.SetOrigin(Point());
83 Point
aPoint1( pOutDev
->PixelToLogic( rPoint
, aMapMode
) );
84 Point
aPoint2( OutputDevice::LogicToLogic( aPoint1
,
85 MapMode(aMapMode
.GetMapUnit()),
87 Point
aTextOffset( GetTextOffset() );
89 aPoint2
.AdjustX( -(aTextOffset
.X()) );
90 aPoint2
.AdjustY( -(aTextOffset
.Y()) );
98 bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection
& rSelection
) const
100 rSelection
= mrOutlinerView
.GetSelection();
104 bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection
& rSelection
)
106 mrOutlinerView
.SetSelection( rSelection
);
110 bool SvxDrawOutlinerViewForwarder::Copy()
112 mrOutlinerView
.Copy();
116 bool SvxDrawOutlinerViewForwarder::Cut()
118 mrOutlinerView
.Cut();
122 bool SvxDrawOutlinerViewForwarder::Paste()
124 mrOutlinerView
.PasteSpecial();
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */