xref: /aoo41x/main/editeng/source/uno/unoviwou.cxx (revision 190118d0)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*190118d0SAndrew Rist  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19*190118d0SAndrew Rist  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir #include <vcl/outdev.hxx>
27cdf0e10cSrcweir #include <vcl/window.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <editeng/unoviwou.hxx>
30cdf0e10cSrcweir #include <editeng/outliner.hxx>
31cdf0e10cSrcweir #include <editeng/editeng.hxx>
32cdf0e10cSrcweir 
SvxDrawOutlinerViewForwarder(OutlinerView & rOutl)33cdf0e10cSrcweir SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl ) :
34cdf0e10cSrcweir     mrOutlinerView ( rOutl ), maTextShapeTopLeft()
35cdf0e10cSrcweir {
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
SvxDrawOutlinerViewForwarder(OutlinerView & rOutl,const Point & rShapePosTopLeft)38cdf0e10cSrcweir SvxDrawOutlinerViewForwarder::SvxDrawOutlinerViewForwarder( OutlinerView& rOutl, const Point& rShapePosTopLeft ) :
39cdf0e10cSrcweir     mrOutlinerView ( rOutl ), maTextShapeTopLeft( rShapePosTopLeft )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
~SvxDrawOutlinerViewForwarder()43cdf0e10cSrcweir SvxDrawOutlinerViewForwarder::~SvxDrawOutlinerViewForwarder()
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
GetTextOffset() const47cdf0e10cSrcweir Point SvxDrawOutlinerViewForwarder::GetTextOffset() const
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     // #101029# calc text offset from shape anchor
50cdf0e10cSrcweir     Rectangle aOutputRect( mrOutlinerView.GetOutputArea() );
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     return aOutputRect.TopLeft() - maTextShapeTopLeft;
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
IsValid() const55cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::IsValid() const
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     return sal_True;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
GetVisArea() const60cdf0e10cSrcweir Rectangle SvxDrawOutlinerViewForwarder::GetVisArea() const
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     OutputDevice* pOutDev = mrOutlinerView.GetWindow();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     if( pOutDev )
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         Rectangle aVisArea = mrOutlinerView.GetVisArea();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir         // #101029#
69cdf0e10cSrcweir         Point aTextOffset( GetTextOffset() );
70cdf0e10cSrcweir         aVisArea.Move( aTextOffset.X(), aTextOffset.Y() );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         // figure out map mode from edit engine
73cdf0e10cSrcweir         Outliner* pOutliner = mrOutlinerView.GetOutliner();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir         if( pOutliner )
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             MapMode aMapMode(pOutDev->GetMapMode());
78cdf0e10cSrcweir             aVisArea = OutputDevice::LogicToLogic( aVisArea,
79cdf0e10cSrcweir                                                    pOutliner->GetRefMapMode(),
80cdf0e10cSrcweir                                                    aMapMode.GetMapUnit() );
81cdf0e10cSrcweir             aMapMode.SetOrigin(Point());
82cdf0e10cSrcweir             return pOutDev->LogicToPixel( aVisArea, aMapMode );
83cdf0e10cSrcweir         }
84cdf0e10cSrcweir     }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     return Rectangle();
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
LogicToPixel(const Point & rPoint,const MapMode & rMapMode) const89cdf0e10cSrcweir Point SvxDrawOutlinerViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     OutputDevice* pOutDev = mrOutlinerView.GetWindow();
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     if( pOutDev )
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         Point aPoint1( rPoint );
96cdf0e10cSrcweir         Point aTextOffset( GetTextOffset() );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         // #101029#
99cdf0e10cSrcweir         aPoint1.X() += aTextOffset.X();
100cdf0e10cSrcweir         aPoint1.Y() += aTextOffset.Y();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         MapMode aMapMode(pOutDev->GetMapMode());
103cdf0e10cSrcweir         Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
104cdf0e10cSrcweir                                                    aMapMode.GetMapUnit() ) );
105cdf0e10cSrcweir         aMapMode.SetOrigin(Point());
106cdf0e10cSrcweir         return pOutDev->LogicToPixel( aPoint2, aMapMode );
107cdf0e10cSrcweir     }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     return Point();
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
PixelToLogic(const Point & rPoint,const MapMode & rMapMode) const112cdf0e10cSrcweir Point SvxDrawOutlinerViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     OutputDevice* pOutDev = mrOutlinerView.GetWindow();
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     if( pOutDev )
117cdf0e10cSrcweir     {
118cdf0e10cSrcweir         MapMode aMapMode(pOutDev->GetMapMode());
119cdf0e10cSrcweir         aMapMode.SetOrigin(Point());
120cdf0e10cSrcweir         Point aPoint1( pOutDev->PixelToLogic( rPoint, aMapMode ) );
121cdf0e10cSrcweir         Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
122cdf0e10cSrcweir                                                    aMapMode.GetMapUnit(),
123cdf0e10cSrcweir                                                    rMapMode ) );
124cdf0e10cSrcweir         // #101029#
125cdf0e10cSrcweir         Point aTextOffset( GetTextOffset() );
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         aPoint2.X() -= aTextOffset.X();
128cdf0e10cSrcweir         aPoint2.Y() -= aTextOffset.Y();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         return aPoint2;
131cdf0e10cSrcweir     }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     return Point();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
GetSelection(ESelection & rSelection) const136cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::GetSelection( ESelection& rSelection ) const
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     rSelection = mrOutlinerView.GetSelection();
139cdf0e10cSrcweir     return sal_True;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
SetSelection(const ESelection & rSelection)142cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::SetSelection( const ESelection& rSelection )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     mrOutlinerView.SetSelection( rSelection );
145cdf0e10cSrcweir     return sal_True;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
Copy()148cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::Copy()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     mrOutlinerView.Copy();
151cdf0e10cSrcweir     return sal_True;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
Cut()154cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::Cut()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir     mrOutlinerView.Cut();
157cdf0e10cSrcweir     return sal_True;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
Paste()160cdf0e10cSrcweir sal_Bool SvxDrawOutlinerViewForwarder::Paste()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     mrOutlinerView.Paste();
163cdf0e10cSrcweir     return sal_True;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
SetShapePos(const Point & rShapePosTopLeft)166cdf0e10cSrcweir void SvxDrawOutlinerViewForwarder::SetShapePos( const Point& rShapePosTopLeft )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     maTextShapeTopLeft = rShapePosTopLeft;
169cdf0e10cSrcweir }
170