fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / accessibility / AccessibleOutlineEditSource.cxx
blobbb1bcffff12d03eb60c8ff77e48388fbafbe7913
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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,
32 SdrView& rView,
33 OutlinerView& rOutlView,
34 const ::Window& rViewWindow )
35 : mrView( rView ),
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()
49 if( mpOutliner )
50 mpOutliner->SetNotifyHdl( Link() );
51 Broadcast( TextHint( SFX_HINT_DYING ) );
54 SvxEditSource* AccessibleOutlineEditSource::Clone() const
56 return NULL;
59 SvxTextForwarder* AccessibleOutlineEditSource::GetTextForwarder()
61 // TODO: maybe suboptimal
62 if( IsValid() )
63 return &mTextForwarder;
64 else
65 return NULL;
68 SvxViewForwarder* AccessibleOutlineEditSource::GetViewForwarder()
70 // TODO: maybe suboptimal
71 if( IsValid() )
72 return this;
73 else
74 return NULL;
77 SvxEditViewForwarder* AccessibleOutlineEditSource::GetEditViewForwarder( sal_Bool )
79 // TODO: maybe suboptimal
80 if( IsValid() )
82 // ignore parameter, we're always in edit mode here
83 return &mViewForwarder;
85 else
86 return NULL;
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 )
110 return sal_True;
114 return sal_False;
117 Rectangle AccessibleOutlineEditSource::GetVisArea() const
119 if( IsValid() )
121 SdrPaintWindow* pPaintWindow = mrView.FindPaintWindow(mrWindow);
122 Rectangle aVisArea;
124 if(pPaintWindow)
126 aVisArea = pPaintWindow->GetVisibleArea();
129 MapMode aMapMode(mrWindow.GetMapMode());
130 aMapMode.SetOrigin(Point());
131 return mrWindow.LogicToPixel( aVisArea, aMapMode );
134 return Rectangle();
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 );
148 return Point();
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()),
160 rMapMode );
163 return Point();
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) )
175 bDispose = true;
176 mpOutliner = NULL;
179 else
181 const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint );
183 if( pSdrHint && ( pSdrHint->GetKind() == HINT_MODELCLEARED ) )
185 // model is dying under us, going defunc
186 bDispose = true;
190 if( bDispose )
192 if( mpOutliner )
193 mpOutliner->SetNotifyHdl( Link() );
194 mpOutliner = NULL;
195 mpOutlinerView = NULL;
196 Broadcast( TextHint( SFX_HINT_DYING ) );
200 IMPL_LINK(AccessibleOutlineEditSource, NotifyHdl, EENotify*, aNotify)
202 if( aNotify )
204 ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
206 if( aHint.get() )
207 Broadcast( *aHint.get() );
210 return 0;
213 } // end of namespace accessibility
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */