xref: /trunk/main/editeng/source/uno/unoviwed.cxx (revision 190118d0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_editeng.hxx"
26 #include <vcl/outdev.hxx>
27 #include <vcl/window.hxx>
28 
29 #include <editeng/unoviwed.hxx>
30 #include <editeng/editview.hxx>
31 #include <editeng/editeng.hxx>
32 
SvxEditEngineViewForwarder(EditView & rView)33 SvxEditEngineViewForwarder::SvxEditEngineViewForwarder( EditView& rView ) :
34     mrView( rView )
35 {
36 }
37 
~SvxEditEngineViewForwarder()38 SvxEditEngineViewForwarder::~SvxEditEngineViewForwarder()
39 {
40 }
41 
IsValid() const42 sal_Bool SvxEditEngineViewForwarder::IsValid() const
43 {
44     return sal_True;
45 }
46 
GetVisArea() const47 Rectangle SvxEditEngineViewForwarder::GetVisArea() const
48 {
49     OutputDevice* pOutDev = mrView.GetWindow();
50 
51     if( pOutDev )
52     {
53         Rectangle aVisArea = mrView.GetVisArea();
54 
55         // figure out map mode from edit engine
56         EditEngine* pEditEngine = mrView.GetEditEngine();
57 
58         if( pEditEngine )
59         {
60             MapMode aMapMode(pOutDev->GetMapMode());
61             aVisArea = OutputDevice::LogicToLogic( aVisArea,
62                                                    pEditEngine->GetRefMapMode(),
63                                                    aMapMode.GetMapUnit() );
64             aMapMode.SetOrigin(Point());
65             return pOutDev->LogicToPixel( aVisArea, aMapMode );
66         }
67     }
68 
69     return Rectangle();
70 }
71 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const72 Point SvxEditEngineViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
73 {
74     OutputDevice* pOutDev = mrView.GetWindow();
75 
76     if( pOutDev )
77     {
78         MapMode aMapMode(pOutDev->GetMapMode());
79         Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
80                                                   aMapMode.GetMapUnit() ) );
81         aMapMode.SetOrigin(Point());
82         return pOutDev->LogicToPixel( aPoint, aMapMode );
83     }
84 
85     return Point();
86 }
87 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const88 Point SvxEditEngineViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
89 {
90     OutputDevice* pOutDev = mrView.GetWindow();
91 
92     if( pOutDev )
93     {
94         MapMode aMapMode(pOutDev->GetMapMode());
95         aMapMode.SetOrigin(Point());
96         Point aPoint( pOutDev->PixelToLogic( rPoint, aMapMode ) );
97         return OutputDevice::LogicToLogic( aPoint,
98                                            aMapMode.GetMapUnit(),
99                                            rMapMode );
100     }
101 
102     return Point();
103 }
104 
GetSelection(ESelection & rSelection) const105 sal_Bool SvxEditEngineViewForwarder::GetSelection( ESelection& rSelection ) const
106 {
107     rSelection = mrView.GetSelection();
108     return sal_True;
109 }
110 
SetSelection(const ESelection & rSelection)111 sal_Bool SvxEditEngineViewForwarder::SetSelection( const ESelection& rSelection )
112 {
113     mrView.SetSelection( rSelection );
114     return sal_True;
115 }
116 
Copy()117 sal_Bool SvxEditEngineViewForwarder::Copy()
118 {
119     mrView.Copy();
120     return sal_True;
121 }
122 
Cut()123 sal_Bool SvxEditEngineViewForwarder::Cut()
124 {
125     mrView.Cut();
126     return sal_True;
127 }
128 
Paste()129 sal_Bool SvxEditEngineViewForwarder::Paste()
130 {
131     mrView.Paste();
132     return sal_True;
133 }
134