2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2002-04-16 10:01:30 +00:00
|
|
|
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/unoedhlp.hxx>
|
2002-04-16 10:01:30 +00:00
|
|
|
#include <svx/svdoutl.hxx>
|
|
|
|
|
|
|
|
#include <AccessibleOutlineEditSource.hxx>
|
2004-01-20 09:34:00 +00:00
|
|
|
#include "OutlineView.hxx"
|
2006-11-14 13:23:31 +00:00
|
|
|
#include <svx/sdrpaintwindow.hxx>
|
|
|
|
|
2002-04-16 10:01:30 +00:00
|
|
|
namespace accessibility
|
|
|
|
{
|
|
|
|
|
2004-01-20 09:34:00 +00:00
|
|
|
AccessibleOutlineEditSource::AccessibleOutlineEditSource(
|
|
|
|
SdrOutliner& rOutliner,
|
|
|
|
SdrView& rView,
|
|
|
|
OutlinerView& rOutlView,
|
2014-09-23 11:20:40 +02:00
|
|
|
const vcl::Window& rViewWindow )
|
2004-01-20 09:34:00 +00:00
|
|
|
: mrView( rView ),
|
|
|
|
mrWindow( rViewWindow ),
|
|
|
|
mpOutliner( &rOutliner ),
|
|
|
|
mpOutlinerView( &rOutlView ),
|
2014-03-03 08:56:11 +02:00
|
|
|
mTextForwarder( rOutliner, false ),
|
2004-01-20 09:34:00 +00:00
|
|
|
mViewForwarder( rOutlView )
|
2002-04-16 10:01:30 +00:00
|
|
|
{
|
|
|
|
// register as listener - need to broadcast state change messages
|
2013-11-28 12:09:19 +00:00
|
|
|
// Moved to ::GetTextForwarder()
|
|
|
|
//rOutliner.SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
|
2009-05-19 09:32:45 +00:00
|
|
|
StartListening(rOutliner);
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AccessibleOutlineEditSource::~AccessibleOutlineEditSource()
|
|
|
|
{
|
2002-06-12 16:27:40 +00:00
|
|
|
if( mpOutliner )
|
2015-04-30 10:20:00 +02:00
|
|
|
mpOutliner->SetNotifyHdl( Link<>() );
|
2002-04-16 10:01:30 +00:00
|
|
|
Broadcast( TextHint( SFX_HINT_DYING ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
SvxEditSource* AccessibleOutlineEditSource::Clone() const
|
|
|
|
{
|
2013-11-28 12:09:19 +00:00
|
|
|
return new AccessibleOutlineEditSource(*mpOutliner, mrView, *mpOutlinerView, mrWindow);
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvxTextForwarder* AccessibleOutlineEditSource::GetTextForwarder()
|
|
|
|
{
|
2002-06-13 17:51:34 +00:00
|
|
|
// TODO: maybe suboptimal
|
|
|
|
if( IsValid() )
|
2013-11-28 12:09:19 +00:00
|
|
|
{
|
|
|
|
// Moved here to make sure that
|
|
|
|
// the NotifyHandler was set on the current object.
|
|
|
|
mpOutliner->SetNotifyHdl( LINK(this, AccessibleOutlineEditSource, NotifyHdl) );
|
2002-06-13 17:51:34 +00:00
|
|
|
return &mTextForwarder;
|
2013-11-28 12:09:19 +00:00
|
|
|
}
|
2002-06-13 17:51:34 +00:00
|
|
|
else
|
|
|
|
return NULL;
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SvxViewForwarder* AccessibleOutlineEditSource::GetViewForwarder()
|
|
|
|
{
|
2002-06-13 17:51:34 +00:00
|
|
|
// TODO: maybe suboptimal
|
|
|
|
if( IsValid() )
|
|
|
|
return this;
|
|
|
|
else
|
|
|
|
return NULL;
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
2014-02-11 14:28:50 +02:00
|
|
|
SvxEditViewForwarder* AccessibleOutlineEditSource::GetEditViewForwarder( bool )
|
2002-04-16 10:01:30 +00:00
|
|
|
{
|
2002-06-13 17:51:34 +00:00
|
|
|
// TODO: maybe suboptimal
|
|
|
|
if( IsValid() )
|
|
|
|
{
|
|
|
|
// ignore parameter, we're always in edit mode here
|
|
|
|
return &mViewForwarder;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AccessibleOutlineEditSource::UpdateData()
|
|
|
|
{
|
|
|
|
// NOOP, since we're always working on the 'real' outliner,
|
|
|
|
// i.e. changes are immediately reflected on the screen
|
|
|
|
}
|
|
|
|
|
|
|
|
SfxBroadcaster& AccessibleOutlineEditSource::GetBroadcaster() const
|
|
|
|
{
|
|
|
|
return *( const_cast< AccessibleOutlineEditSource* > (this) );
|
|
|
|
}
|
|
|
|
|
2014-02-28 09:47:38 +02:00
|
|
|
bool AccessibleOutlineEditSource::IsValid() const
|
2002-04-16 10:01:30 +00:00
|
|
|
{
|
2002-06-13 17:51:34 +00:00
|
|
|
if( mpOutliner && mpOutlinerView )
|
|
|
|
{
|
|
|
|
// Our view still on outliner?
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uLong nCurrView, nViews;
|
2002-06-13 17:51:34 +00:00
|
|
|
|
|
|
|
for( nCurrView=0, nViews=mpOutliner->GetViewCount(); nCurrView<nViews; ++nCurrView )
|
|
|
|
{
|
|
|
|
if( mpOutliner->GetView(nCurrView) == mpOutlinerView )
|
2014-02-28 09:47:38 +02:00
|
|
|
return true;
|
2002-06-13 17:51:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 09:47:38 +02:00
|
|
|
return false;
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle AccessibleOutlineEditSource::GetVisArea() const
|
|
|
|
{
|
|
|
|
if( IsValid() )
|
|
|
|
{
|
2006-11-14 13:23:31 +00:00
|
|
|
SdrPaintWindow* pPaintWindow = mrView.FindPaintWindow(mrWindow);
|
|
|
|
Rectangle aVisArea;
|
|
|
|
|
|
|
|
if(pPaintWindow)
|
|
|
|
{
|
|
|
|
aVisArea = pPaintWindow->GetVisibleArea();
|
|
|
|
}
|
2002-04-16 10:01:30 +00:00
|
|
|
|
2002-06-12 16:27:40 +00:00
|
|
|
MapMode aMapMode(mrWindow.GetMapMode());
|
|
|
|
aMapMode.SetOrigin(Point());
|
|
|
|
return mrWindow.LogicToPixel( aVisArea, aMapMode );
|
2002-04-16 10:01:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Rectangle();
|
|
|
|
}
|
|
|
|
|
|
|
|
Point AccessibleOutlineEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
|
|
|
|
{
|
2002-06-12 16:27:40 +00:00
|
|
|
if( IsValid() && mrView.GetModel() )
|
|
|
|
{
|
|
|
|
Point aPoint( OutputDevice::LogicToLogic( rPoint, rMapMode,
|
|
|
|
MapMode(mrView.GetModel()->GetScaleUnit()) ) );
|
|
|
|
MapMode aMapMode(mrWindow.GetMapMode());
|
|
|
|
aMapMode.SetOrigin(Point());
|
|
|
|
return mrWindow.LogicToPixel( aPoint, aMapMode );
|
|
|
|
}
|
2002-04-16 10:01:30 +00:00
|
|
|
|
|
|
|
return Point();
|
|
|
|
}
|
|
|
|
|
|
|
|
Point AccessibleOutlineEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
|
|
|
|
{
|
2002-06-12 16:27:40 +00:00
|
|
|
if( IsValid() && mrView.GetModel() )
|
|
|
|
{
|
|
|
|
MapMode aMapMode(mrWindow.GetMapMode());
|
|
|
|
aMapMode.SetOrigin(Point());
|
|
|
|
Point aPoint( mrWindow.PixelToLogic( rPoint, aMapMode ) );
|
|
|
|
return OutputDevice::LogicToLogic( aPoint,
|
|
|
|
MapMode(mrView.GetModel()->GetScaleUnit()),
|
|
|
|
rMapMode );
|
|
|
|
}
|
2002-04-16 10:01:30 +00:00
|
|
|
|
|
|
|
return Point();
|
|
|
|
}
|
|
|
|
|
2009-05-19 09:32:45 +00:00
|
|
|
void AccessibleOutlineEditSource::Notify( SfxBroadcaster& rBroadcaster, const SfxHint& rHint )
|
2002-06-12 16:27:40 +00:00
|
|
|
{
|
2009-05-19 09:32:45 +00:00
|
|
|
bool bDispose = false;
|
2002-06-12 16:27:40 +00:00
|
|
|
|
2009-05-19 09:32:45 +00:00
|
|
|
if( &rBroadcaster == mpOutliner )
|
|
|
|
{
|
|
|
|
const SfxSimpleHint* pHint = dynamic_cast< const SfxSimpleHint * >( &rHint );
|
|
|
|
if( pHint && (pHint->GetId() == SFX_HINT_DYING) )
|
|
|
|
{
|
|
|
|
bDispose = true;
|
|
|
|
mpOutliner = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint );
|
|
|
|
|
|
|
|
if( pSdrHint && ( pSdrHint->GetKind() == HINT_MODELCLEARED ) )
|
|
|
|
{
|
|
|
|
// model is dying under us, going defunc
|
|
|
|
bDispose = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bDispose )
|
2002-06-12 16:27:40 +00:00
|
|
|
{
|
2006-12-12 15:48:08 +00:00
|
|
|
if( mpOutliner )
|
2015-04-30 10:20:00 +02:00
|
|
|
mpOutliner->SetNotifyHdl( Link<>() );
|
2006-12-12 15:48:08 +00:00
|
|
|
mpOutliner = NULL;
|
|
|
|
mpOutlinerView = NULL;
|
|
|
|
Broadcast( TextHint( SFX_HINT_DYING ) );
|
2002-06-12 16:27:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-16 10:01:30 +00:00
|
|
|
IMPL_LINK(AccessibleOutlineEditSource, NotifyHdl, EENotify*, aNotify)
|
|
|
|
{
|
|
|
|
if( aNotify )
|
2002-04-26 09:44:53 +00:00
|
|
|
{
|
2014-09-25 17:35:05 +02:00
|
|
|
::std::unique_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
|
2002-04-26 09:44:53 +00:00
|
|
|
|
|
|
|
if( aHint.get() )
|
|
|
|
Broadcast( *aHint.get() );
|
|
|
|
}
|
2002-04-16 10:01:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end of namespace accessibility
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|