1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
31 #include <editeng/unoedhlp.hxx>
32 #include <svx/svdoutl.hxx>
34 #include <AccessibleOutlineEditSource.hxx>
35 #include "OutlineView.hxx"
36 #include <svx/sdrpaintwindow.hxx>
38 namespace accessibility
41 AccessibleOutlineEditSource::AccessibleOutlineEditSource(
42 SdrOutliner
& rOutliner
,
44 OutlinerView
& rOutlView
,
45 const ::Window
& rViewWindow
)
47 mrWindow( rViewWindow
),
48 mpOutliner( &rOutliner
),
49 mpOutlinerView( &rOutlView
),
50 mTextForwarder( rOutliner
, 0 ),
51 mViewForwarder( rOutlView
)
53 // register as listener - need to broadcast state change messages
54 rOutliner
.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource
, NotifyHdl
) );
55 StartListening(rOutliner
);
58 AccessibleOutlineEditSource::~AccessibleOutlineEditSource()
61 mpOutliner
->SetNotifyHdl( Link() );
62 Broadcast( TextHint( SFX_HINT_DYING
) );
65 SvxEditSource
* AccessibleOutlineEditSource::Clone() const
70 SvxTextForwarder
* AccessibleOutlineEditSource::GetTextForwarder()
72 // TODO: maybe suboptimal
74 return &mTextForwarder
;
79 SvxViewForwarder
* AccessibleOutlineEditSource::GetViewForwarder()
81 // TODO: maybe suboptimal
88 SvxEditViewForwarder
* AccessibleOutlineEditSource::GetEditViewForwarder( sal_Bool
)
90 // TODO: maybe suboptimal
93 // ignore parameter, we're always in edit mode here
94 return &mViewForwarder
;
100 void AccessibleOutlineEditSource::UpdateData()
102 // NOOP, since we're always working on the 'real' outliner,
103 // i.e. changes are immediately reflected on the screen
106 SfxBroadcaster
& AccessibleOutlineEditSource::GetBroadcaster() const
108 return *( const_cast< AccessibleOutlineEditSource
* > (this) );
111 BOOL
AccessibleOutlineEditSource::IsValid() const
113 if( mpOutliner
&& mpOutlinerView
)
115 // Our view still on outliner?
116 ULONG nCurrView
, nViews
;
118 for( nCurrView
=0, nViews
=mpOutliner
->GetViewCount(); nCurrView
<nViews
; ++nCurrView
)
120 if( mpOutliner
->GetView(nCurrView
) == mpOutlinerView
)
128 Rectangle
AccessibleOutlineEditSource::GetVisArea() const
132 SdrPaintWindow
* pPaintWindow
= mrView
.FindPaintWindow(mrWindow
);
137 aVisArea
= pPaintWindow
->GetVisibleArea();
140 MapMode
aMapMode(mrWindow
.GetMapMode());
141 aMapMode
.SetOrigin(Point());
142 return mrWindow
.LogicToPixel( aVisArea
, aMapMode
);
148 Point
AccessibleOutlineEditSource::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
150 if( IsValid() && mrView
.GetModel() )
152 Point
aPoint( OutputDevice::LogicToLogic( rPoint
, rMapMode
,
153 MapMode(mrView
.GetModel()->GetScaleUnit()) ) );
154 MapMode
aMapMode(mrWindow
.GetMapMode());
155 aMapMode
.SetOrigin(Point());
156 return mrWindow
.LogicToPixel( aPoint
, aMapMode
);
162 Point
AccessibleOutlineEditSource::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
164 if( IsValid() && mrView
.GetModel() )
166 MapMode
aMapMode(mrWindow
.GetMapMode());
167 aMapMode
.SetOrigin(Point());
168 Point
aPoint( mrWindow
.PixelToLogic( rPoint
, aMapMode
) );
169 return OutputDevice::LogicToLogic( aPoint
,
170 MapMode(mrView
.GetModel()->GetScaleUnit()),
177 void AccessibleOutlineEditSource::Notify( SfxBroadcaster
& rBroadcaster
, const SfxHint
& rHint
)
179 bool bDispose
= false;
181 if( &rBroadcaster
== mpOutliner
)
183 const SfxSimpleHint
* pHint
= dynamic_cast< const SfxSimpleHint
* >( &rHint
);
184 if( pHint
&& (pHint
->GetId() == SFX_HINT_DYING
) )
192 const SdrHint
* pSdrHint
= dynamic_cast< const SdrHint
* >( &rHint
);
194 if( pSdrHint
&& ( pSdrHint
->GetKind() == HINT_MODELCLEARED
) )
196 // model is dying under us, going defunc
204 mpOutliner
->SetNotifyHdl( Link() );
206 mpOutlinerView
= NULL
;
207 Broadcast( TextHint( SFX_HINT_DYING
) );
211 IMPL_LINK(AccessibleOutlineEditSource
, NotifyHdl
, EENotify
*, aNotify
)
215 ::std::auto_ptr
< SfxHint
> aHint( SvxEditSourceHelper::EENotification2Hint( aNotify
) );
218 Broadcast( *aHint
.get() );
224 } // end of namespace accessibility
226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */