bump product version to 5.0.4.1
[LibreOffice.git] / editeng / source / uno / unoviwou.cxx
blob106002919d3072375f3a7bd376ec322e6a4f83b2
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>
25 #include <editeng/editeng.hxx>
27 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl ) :
28 mrOutlinerView ( rOutl ), maTextShapeTopLeft()
32 SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl, const Point& rShapePosTopLeft ) :
33 mrOutlinerView ( rOutl ), maTextShapeTopLeft( rShapePosTopLeft )
37 SvxDrawOutlinerViewForwarder::~SvxDrawOutlinerViewForwarder()
41 Point SvxDrawOutlinerViewForwarder::GetTextOffset() const
43 // calc text offset from shape anchor
44 Rectangle aOutputRect( mrOutlinerView.GetOutputArea() );
46 return aOutputRect.TopLeft() - maTextShapeTopLeft;
49 bool SvxDrawOutlinerViewForwarder::IsValid() const
51 return true;
54 Rectangle SvxDrawOutlinerViewForwarder::GetVisArea() const
56 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
58 if( pOutDev )
60 Rectangle aVisArea = mrOutlinerView.GetVisArea();
62 Point aTextOffset( GetTextOffset() );
63 aVisArea.Move( aTextOffset.X(), aTextOffset.Y() );
65 // figure out map mode from edit engine
66 Outliner* pOutliner = mrOutlinerView.GetOutliner();
68 if( pOutliner )
70 MapMode aMapMode(pOutDev->GetMapMode());
71 aVisArea = OutputDevice::LogicToLogic( aVisArea,
72 pOutliner->GetRefMapMode(),
73 aMapMode.GetMapUnit() );
74 aMapMode.SetOrigin(Point());
75 return pOutDev->LogicToPixel( aVisArea, aMapMode );
79 return Rectangle();
82 Point SvxDrawOutlinerViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
84 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
86 if( pOutDev )
88 Point aPoint1( rPoint );
89 Point aTextOffset( GetTextOffset() );
91 aPoint1.X() += aTextOffset.X();
92 aPoint1.Y() += aTextOffset.Y();
94 MapMode aMapMode(pOutDev->GetMapMode());
95 Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
96 aMapMode.GetMapUnit() ) );
97 aMapMode.SetOrigin(Point());
98 return pOutDev->LogicToPixel( aPoint2, aMapMode );
101 return Point();
104 Point SvxDrawOutlinerViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
106 OutputDevice* pOutDev = mrOutlinerView.GetWindow();
108 if( pOutDev )
110 MapMode aMapMode(pOutDev->GetMapMode());
111 aMapMode.SetOrigin(Point());
112 Point aPoint1( pOutDev->PixelToLogic( rPoint, aMapMode ) );
113 Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
114 aMapMode.GetMapUnit(),
115 rMapMode ) );
116 Point aTextOffset( GetTextOffset() );
118 aPoint2.X() -= aTextOffset.X();
119 aPoint2.Y() -= aTextOffset.Y();
121 return aPoint2;
124 return Point();
127 bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection& rSelection ) const
129 rSelection = mrOutlinerView.GetSelection();
130 return true;
133 bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection& rSelection )
135 mrOutlinerView.SetSelection( rSelection );
136 return true;
139 bool SvxDrawOutlinerViewForwarder::Copy()
141 mrOutlinerView.Copy();
142 return true;
145 bool SvxDrawOutlinerViewForwarder::Cut()
147 mrOutlinerView.Cut();
148 return true;
151 bool SvxDrawOutlinerViewForwarder::Paste()
153 mrOutlinerView.Paste();
154 return true;
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */