1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <editeng/unoedhlp.hxx>
21 #include <svx/svdoutl.hxx>
23 #include <AccessibleOutlineEditSource.hxx>
24 #include "OutlineView.hxx"
25 #include <svx/sdrpaintwindow.hxx>
27 namespace accessibility
30 AccessibleOutlineEditSource::AccessibleOutlineEditSource(
31 SdrOutliner
& rOutliner
,
33 OutlinerView
& rOutlView
,
34 const ::Window
& rViewWindow
)
36 mrWindow( rViewWindow
),
37 mpOutliner( &rOutliner
),
38 mpOutlinerView( &rOutlView
),
39 mTextForwarder( rOutliner
, 0 ),
40 mViewForwarder( rOutlView
)
42 // register as listener - need to broadcast state change messages
43 rOutliner
.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource
, NotifyHdl
) );
44 StartListening(rOutliner
);
47 AccessibleOutlineEditSource::~AccessibleOutlineEditSource()
50 mpOutliner
->SetNotifyHdl( Link() );
51 Broadcast( TextHint( SFX_HINT_DYING
) );
54 SvxEditSource
* AccessibleOutlineEditSource::Clone() const
59 SvxTextForwarder
* AccessibleOutlineEditSource::GetTextForwarder()
61 // TODO: maybe suboptimal
63 return &mTextForwarder
;
68 SvxViewForwarder
* AccessibleOutlineEditSource::GetViewForwarder()
70 // TODO: maybe suboptimal
77 SvxEditViewForwarder
* AccessibleOutlineEditSource::GetEditViewForwarder( sal_Bool
)
79 // TODO: maybe suboptimal
82 // ignore parameter, we're always in edit mode here
83 return &mViewForwarder
;
89 void AccessibleOutlineEditSource::UpdateData()
91 // NOOP, since we're always working on the 'real' outliner,
92 // i.e. changes are immediately reflected on the screen
95 SfxBroadcaster
& AccessibleOutlineEditSource::GetBroadcaster() const
97 return *( const_cast< AccessibleOutlineEditSource
* > (this) );
100 sal_Bool
AccessibleOutlineEditSource::IsValid() const
102 if( mpOutliner
&& mpOutlinerView
)
104 // Our view still on outliner?
105 sal_uLong nCurrView
, nViews
;
107 for( nCurrView
=0, nViews
=mpOutliner
->GetViewCount(); nCurrView
<nViews
; ++nCurrView
)
109 if( mpOutliner
->GetView(nCurrView
) == mpOutlinerView
)
117 Rectangle
AccessibleOutlineEditSource::GetVisArea() const
121 SdrPaintWindow
* pPaintWindow
= mrView
.FindPaintWindow(mrWindow
);
126 aVisArea
= pPaintWindow
->GetVisibleArea();
129 MapMode
aMapMode(mrWindow
.GetMapMode());
130 aMapMode
.SetOrigin(Point());
131 return mrWindow
.LogicToPixel( aVisArea
, aMapMode
);
137 Point
AccessibleOutlineEditSource::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
139 if( IsValid() && mrView
.GetModel() )
141 Point
aPoint( OutputDevice::LogicToLogic( rPoint
, rMapMode
,
142 MapMode(mrView
.GetModel()->GetScaleUnit()) ) );
143 MapMode
aMapMode(mrWindow
.GetMapMode());
144 aMapMode
.SetOrigin(Point());
145 return mrWindow
.LogicToPixel( aPoint
, aMapMode
);
151 Point
AccessibleOutlineEditSource::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
153 if( IsValid() && mrView
.GetModel() )
155 MapMode
aMapMode(mrWindow
.GetMapMode());
156 aMapMode
.SetOrigin(Point());
157 Point
aPoint( mrWindow
.PixelToLogic( rPoint
, aMapMode
) );
158 return OutputDevice::LogicToLogic( aPoint
,
159 MapMode(mrView
.GetModel()->GetScaleUnit()),
166 void AccessibleOutlineEditSource::Notify( SfxBroadcaster
& rBroadcaster
, const SfxHint
& rHint
)
168 bool bDispose
= false;
170 if( &rBroadcaster
== mpOutliner
)
172 const SfxSimpleHint
* pHint
= dynamic_cast< const SfxSimpleHint
* >( &rHint
);
173 if( pHint
&& (pHint
->GetId() == SFX_HINT_DYING
) )
181 const SdrHint
* pSdrHint
= dynamic_cast< const SdrHint
* >( &rHint
);
183 if( pSdrHint
&& ( pSdrHint
->GetKind() == HINT_MODELCLEARED
) )
185 // model is dying under us, going defunc
193 mpOutliner
->SetNotifyHdl( Link() );
195 mpOutlinerView
= NULL
;
196 Broadcast( TextHint( SFX_HINT_DYING
) );
200 IMPL_LINK(AccessibleOutlineEditSource
, NotifyHdl
, EENotify
*, aNotify
)
204 ::std::auto_ptr
< SfxHint
> aHint( SvxEditSourceHelper::EENotification2Hint( aNotify
) );
207 Broadcast( *aHint
.get() );
213 } // end of namespace accessibility
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */