1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleOutlineEditSource.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
33 #include <svx/unoedhlp.hxx>
34 #include <svx/svdoutl.hxx>
36 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_OUTLINE_EDIT_SOURCE_HXX
37 #include <AccessibleOutlineEditSource.hxx>
39 #include "OutlineView.hxx"
40 #include <svx/sdrpaintwindow.hxx>
42 namespace accessibility
45 AccessibleOutlineEditSource::AccessibleOutlineEditSource(
46 SdrOutliner
& rOutliner
,
48 OutlinerView
& rOutlView
,
49 const ::Window
& rViewWindow
)
51 mrWindow( rViewWindow
),
52 mpOutliner( &rOutliner
),
53 mpOutlinerView( &rOutlView
),
54 mTextForwarder( rOutliner
, NULL
),
55 mViewForwarder( rOutlView
)
57 // register as listener - need to broadcast state change messages
58 rOutliner
.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource
, NotifyHdl
) );
59 StartListening(rOutliner
);
62 AccessibleOutlineEditSource::~AccessibleOutlineEditSource()
65 mpOutliner
->SetNotifyHdl( Link() );
66 Broadcast( TextHint( SFX_HINT_DYING
) );
69 SvxEditSource
* AccessibleOutlineEditSource::Clone() const
74 SvxTextForwarder
* AccessibleOutlineEditSource::GetTextForwarder()
76 // TODO: maybe suboptimal
78 return &mTextForwarder
;
83 SvxViewForwarder
* AccessibleOutlineEditSource::GetViewForwarder()
85 // TODO: maybe suboptimal
92 SvxEditViewForwarder
* AccessibleOutlineEditSource::GetEditViewForwarder( sal_Bool
)
94 // TODO: maybe suboptimal
97 // ignore parameter, we're always in edit mode here
98 return &mViewForwarder
;
104 void AccessibleOutlineEditSource::UpdateData()
106 // NOOP, since we're always working on the 'real' outliner,
107 // i.e. changes are immediately reflected on the screen
110 SfxBroadcaster
& AccessibleOutlineEditSource::GetBroadcaster() const
112 return *( const_cast< AccessibleOutlineEditSource
* > (this) );
115 BOOL
AccessibleOutlineEditSource::IsValid() const
117 if( mpOutliner
&& mpOutlinerView
)
119 // Our view still on outliner?
120 ULONG nCurrView
, nViews
;
122 for( nCurrView
=0, nViews
=mpOutliner
->GetViewCount(); nCurrView
<nViews
; ++nCurrView
)
124 if( mpOutliner
->GetView(nCurrView
) == mpOutlinerView
)
132 Rectangle
AccessibleOutlineEditSource::GetVisArea() const
136 SdrPaintWindow
* pPaintWindow
= mrView
.FindPaintWindow(mrWindow
);
141 aVisArea
= pPaintWindow
->GetVisibleArea();
144 MapMode
aMapMode(mrWindow
.GetMapMode());
145 aMapMode
.SetOrigin(Point());
146 return mrWindow
.LogicToPixel( aVisArea
, aMapMode
);
152 Point
AccessibleOutlineEditSource::LogicToPixel( const Point
& rPoint
, const MapMode
& rMapMode
) const
154 if( IsValid() && mrView
.GetModel() )
156 Point
aPoint( OutputDevice::LogicToLogic( rPoint
, rMapMode
,
157 MapMode(mrView
.GetModel()->GetScaleUnit()) ) );
158 MapMode
aMapMode(mrWindow
.GetMapMode());
159 aMapMode
.SetOrigin(Point());
160 return mrWindow
.LogicToPixel( aPoint
, aMapMode
);
166 Point
AccessibleOutlineEditSource::PixelToLogic( const Point
& rPoint
, const MapMode
& rMapMode
) const
168 if( IsValid() && mrView
.GetModel() )
170 MapMode
aMapMode(mrWindow
.GetMapMode());
171 aMapMode
.SetOrigin(Point());
172 Point
aPoint( mrWindow
.PixelToLogic( rPoint
, aMapMode
) );
173 return OutputDevice::LogicToLogic( aPoint
,
174 MapMode(mrView
.GetModel()->GetScaleUnit()),
181 void AccessibleOutlineEditSource::Notify( SfxBroadcaster
& rBroadcaster
, const SfxHint
& rHint
)
183 bool bDispose
= false;
185 if( &rBroadcaster
== mpOutliner
)
187 const SfxSimpleHint
* pHint
= dynamic_cast< const SfxSimpleHint
* >( &rHint
);
188 if( pHint
&& (pHint
->GetId() == SFX_HINT_DYING
) )
196 const SdrHint
* pSdrHint
= dynamic_cast< const SdrHint
* >( &rHint
);
198 if( pSdrHint
&& ( pSdrHint
->GetKind() == HINT_MODELCLEARED
) )
200 // model is dying under us, going defunc
208 mpOutliner
->SetNotifyHdl( Link() );
210 mpOutlinerView
= NULL
;
211 Broadcast( TextHint( SFX_HINT_DYING
) );
215 IMPL_LINK(AccessibleOutlineEditSource
, NotifyHdl
, EENotify
*, aNotify
)
219 ::std::auto_ptr
< SfxHint
> aHint( SvxEditSourceHelper::EENotification2Hint( aNotify
) );
222 Broadcast( *aHint
.get() );
228 } // end of namespace accessibility