Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / editeng / source / uno / unoviwou.cxx
blob19f38794e8c62d34203a3238be4bc5a704a2a6f2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
50 return true;
53 Point SvxDrawOutlinerViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
55 OutputDevice* pOutDev = mrOutlinerView.GetWindow()->GetOutDev();
57 if( pOutDev )
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 );
72 return Point();
75 Point SvxDrawOutlinerViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
77 OutputDevice* pOutDev = mrOutlinerView.GetWindow()->GetOutDev();
79 if( pOutDev )
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()),
86 rMapMode ) );
87 Point aTextOffset( GetTextOffset() );
89 aPoint2.AdjustX( -(aTextOffset.X()) );
90 aPoint2.AdjustY( -(aTextOffset.Y()) );
92 return aPoint2;
95 return Point();
98 bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection& rSelection ) const
100 rSelection = mrOutlinerView.GetSelection();
101 return true;
104 bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection& rSelection )
106 mrOutlinerView.SetSelection( rSelection );
107 return true;
110 bool SvxDrawOutlinerViewForwarder::Copy()
112 mrOutlinerView.Copy();
113 return true;
116 bool SvxDrawOutlinerViewForwarder::Cut()
118 mrOutlinerView.Cut();
119 return true;
122 bool SvxDrawOutlinerViewForwarder::Paste()
124 mrOutlinerView.PasteSpecial();
125 return true;
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */