/src/libreoffice/editeng/source/uno/unoviwou.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <vcl/outdev.hxx> |
21 | | #include <vcl/window.hxx> |
22 | | |
23 | | #include <editeng/unoviwou.hxx> |
24 | | #include <editeng/outliner.hxx> |
25 | | |
26 | | SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl ) : |
27 | 0 | mrOutlinerView ( rOutl ) |
28 | 0 | { |
29 | 0 | } |
30 | | |
31 | | SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl, const Point& rShapePosTopLeft ) : |
32 | 0 | mrOutlinerView ( rOutl ), maTextShapeTopLeft( rShapePosTopLeft ) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | SvxDrawOutlinerViewForwarder::~SvxDrawOutlinerViewForwarder() |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | Point SvxDrawOutlinerViewForwarder::GetTextOffset() const |
41 | 0 | { |
42 | | // calc text offset from shape anchor |
43 | 0 | tools::Rectangle aOutputRect( mrOutlinerView.GetOutputArea() ); |
44 | |
|
45 | 0 | return aOutputRect.TopLeft() - maTextShapeTopLeft; |
46 | 0 | } |
47 | | |
48 | | bool SvxDrawOutlinerViewForwarder::IsValid() const |
49 | 0 | { |
50 | 0 | return true; |
51 | 0 | } |
52 | | |
53 | | Point SvxDrawOutlinerViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const |
54 | 0 | { |
55 | 0 | OutputDevice* pOutDev = mrOutlinerView.GetWindow()->GetOutDev(); |
56 | |
|
57 | 0 | if( pOutDev ) |
58 | 0 | { |
59 | 0 | Point aPoint1( rPoint ); |
60 | 0 | Point aTextOffset( GetTextOffset() ); |
61 | |
|
62 | 0 | aPoint1.AdjustX(aTextOffset.X() ); |
63 | 0 | aPoint1.AdjustY(aTextOffset.Y() ); |
64 | |
|
65 | 0 | MapMode aMapMode(pOutDev->GetMapMode()); |
66 | 0 | Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode, |
67 | 0 | MapMode(aMapMode.GetMapUnit()))); |
68 | 0 | aMapMode.SetOrigin(Point()); |
69 | 0 | return pOutDev->LogicToPixel( aPoint2, aMapMode ); |
70 | 0 | } |
71 | | |
72 | 0 | return Point(); |
73 | 0 | } |
74 | | |
75 | | Point SvxDrawOutlinerViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const |
76 | 0 | { |
77 | 0 | OutputDevice* pOutDev = mrOutlinerView.GetWindow()->GetOutDev(); |
78 | |
|
79 | 0 | if( pOutDev ) |
80 | 0 | { |
81 | 0 | MapMode aMapMode(pOutDev->GetMapMode()); |
82 | 0 | aMapMode.SetOrigin(Point()); |
83 | 0 | Point aPoint1( pOutDev->PixelToLogic( rPoint, aMapMode ) ); |
84 | 0 | Point aPoint2( OutputDevice::LogicToLogic( aPoint1, |
85 | 0 | MapMode(aMapMode.GetMapUnit()), |
86 | 0 | rMapMode ) ); |
87 | 0 | Point aTextOffset( GetTextOffset() ); |
88 | |
|
89 | 0 | aPoint2.AdjustX( -(aTextOffset.X()) ); |
90 | 0 | aPoint2.AdjustY( -(aTextOffset.Y()) ); |
91 | |
|
92 | 0 | return aPoint2; |
93 | 0 | } |
94 | | |
95 | 0 | return Point(); |
96 | 0 | } |
97 | | |
98 | | bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection& rSelection ) const |
99 | 0 | { |
100 | 0 | rSelection = mrOutlinerView.GetSelection(); |
101 | 0 | return true; |
102 | 0 | } |
103 | | |
104 | | bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection& rSelection ) |
105 | 0 | { |
106 | 0 | mrOutlinerView.SetSelection( rSelection ); |
107 | 0 | return true; |
108 | 0 | } |
109 | | |
110 | | bool SvxDrawOutlinerViewForwarder::Copy() |
111 | 0 | { |
112 | 0 | mrOutlinerView.Copy(); |
113 | 0 | return true; |
114 | 0 | } |
115 | | |
116 | | bool SvxDrawOutlinerViewForwarder::Cut() |
117 | 0 | { |
118 | 0 | mrOutlinerView.Cut(); |
119 | 0 | return true; |
120 | 0 | } |
121 | | |
122 | | bool SvxDrawOutlinerViewForwarder::Paste() |
123 | 0 | { |
124 | 0 | mrOutlinerView.PasteSpecial(); |
125 | 0 | return true; |
126 | 0 | } |
127 | | |
128 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |