LibreOffice Module sd (master) 1
AccessibleOutlineEditSource.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <memory>
21#include <editeng/unoedhlp.hxx>
22#include <svx/svdoutl.hxx>
23#include <svx/svdview.hxx>
24#include <vcl/window.hxx>
26
27namespace accessibility
28{
29
31 SdrOutliner& rOutliner,
32 SdrView& rView,
33 OutlinerView& rOutlView,
34 const vcl::Window& rViewWindow )
35 : mrView( rView ),
36 mrWindow( rViewWindow ),
37 mpOutliner( &rOutliner ),
38 mpOutlinerView( &rOutlView ),
39 mTextForwarder( rOutliner, false ),
40 mViewForwarder( rOutlView )
41 {
42 // register as listener - need to broadcast state change messages
43 // Moved to ::GetTextForwarder()
44 //rOutliner.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
45 StartListening(rOutliner);
46 }
47
49 {
50 if( mpOutliner )
51 mpOutliner->SetNotifyHdl( Link<EENotify&,void>() );
52 Broadcast( TextHint( SfxHintId::Dying ) );
53 }
54
55 std::unique_ptr<SvxEditSource> AccessibleOutlineEditSource::Clone() const
56 {
57 return std::unique_ptr<SvxEditSource>(new AccessibleOutlineEditSource(*mpOutliner, mrView, *mpOutlinerView, mrWindow));
58 }
59
61 {
62 // TODO: maybe suboptimal
63 if( IsValid() )
64 {
65 // Moved here to make sure that
66 // the NotifyHandler was set on the current object.
67 mpOutliner->SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
68 return &mTextForwarder;
69 }
70 else
71 return nullptr;
72 }
73
75 {
76 // TODO: maybe suboptimal
77 if( IsValid() )
78 return this;
79 else
80 return nullptr;
81 }
82
84 {
85 // TODO: maybe suboptimal
86 if( IsValid() )
87 {
88 // ignore parameter, we're always in edit mode here
89 return &mViewForwarder;
90 }
91 else
92 return nullptr;
93 }
94
96 {
97 // NOOP, since we're always working on the 'real' outliner,
98 // i.e. changes are immediately reflected on the screen
99 }
100
102 {
103 return * const_cast< AccessibleOutlineEditSource* > (this);
104 }
105
107 {
109 {
110 // Our view still on outliner?
111 sal_uLong nCurrView, nViews;
112
113 for( nCurrView=0, nViews=mpOutliner->GetViewCount(); nCurrView<nViews; ++nCurrView )
114 {
115 if( mpOutliner->GetView(nCurrView) == mpOutlinerView )
116 return true;
117 }
118 }
119
120 return false;
121 }
122
123 Point AccessibleOutlineEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
124 {
125 if (IsValid())
126 {
127 Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
129 MapMode aMapMode(mrWindow.GetMapMode());
130 aMapMode.SetOrigin(Point());
131 return mrWindow.LogicToPixel( aPoint, aMapMode );
132 }
133
134 return Point();
135 }
136
137 Point AccessibleOutlineEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
138 {
139 if (IsValid())
140 {
141 MapMode aMapMode(mrWindow.GetMapMode());
142 aMapMode.SetOrigin(Point());
143 Point aPoint( mrWindow.PixelToLogic( rPoint, aMapMode ) );
144 return OutputDevice::LogicToLogic( aPoint,
146 rMapMode );
147 }
148
149 return Point();
150 }
151
153 {
154 bool bDispose = false;
155
156 if( &rBroadcaster == mpOutliner )
157 {
158 if( rHint.GetId() == SfxHintId::Dying )
159 {
160 bDispose = true;
161 mpOutliner = nullptr;
162 }
163 }
164 else
165 {
166 if (rHint.GetId() == SfxHintId::ThisIsAnSdrHint)
167 {
168 const SdrHint* pSdrHint = static_cast< const SdrHint* >( &rHint );
169 if( pSdrHint->GetKind() == SdrHintKind::ModelCleared )
170 {
171 // model is dying under us, going defunc
172 bDispose = true;
173 }
174 }
175 }
176
177 if( bDispose )
178 {
179 if( mpOutliner )
180 mpOutliner->SetNotifyHdl( Link<EENotify&,void>() );
181 mpOutliner = nullptr;
182 mpOutlinerView = nullptr;
183 Broadcast( TextHint( SfxHintId::Dying ) );
184 }
185 }
186
187 IMPL_LINK(AccessibleOutlineEditSource, NotifyHdl, EENotify&, rNotify, void)
188 {
189 ::std::unique_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( &rNotify) );
190
191 if (aHint)
192 {
193 Broadcast(*aHint);
194 }
195 }
196
197} // end of namespace accessibility
198
199/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SlideSorterView & mrView
void SetOrigin(const Point &rOrigin)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SdrHintKind GetKind() const
MapUnit GetScaleUnit() const
SdrModel & GetModel() const
void Broadcast(const SfxHint &rHint)
SfxHintId GetId() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
static ::std::unique_ptr< SfxHint > EENotification2Hint(EENotify const *aNotify)
Implementation of the SvxEditSource interface in the SdOutlineView.
virtual std::unique_ptr< SvxEditSource > Clone() const override
This method is disabled and always returns NULL.
AccessibleOutlineEditSource(SdrOutliner &rOutliner, SdrView &rView, OutlinerView &rOutlView, const vcl::Window &rViewWindow)
Create an SvxEditSource interface for the given Outliner.
virtual Point PixelToLogic(const Point &rPoint, const MapMode &rMapMode) const override
virtual SvxTextForwarder * GetTextForwarder() override
virtual Point LogicToPixel(const Point &rPoint, const MapMode &rMapMode) const override
virtual SfxBroadcaster & GetBroadcaster() const override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual SvxViewForwarder * GetViewForwarder() override
virtual SvxEditViewForwarder * GetEditViewForwarder(bool bCreate=false) override
Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
Point PixelToLogic(const Point &rDevicePt) const
IMPL_LINK(AccessibleListBoxEntry, WindowEventListener, VclWindowEvent &, rEvent, void)
sal_uIntPtr sal_uLong