2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-01-09 15:11:54 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
2008-04-10 13:21:45 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-01-09 15:11:54 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 06:02:29 +00:00
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
#include "sqledit.hxx"
|
|
|
|
#include "QueryTextView.hxx"
|
2001-08-23 13:47:34 +00:00
|
|
|
#include "querycontainerwindow.hxx"
|
2001-01-09 15:11:54 +00:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include "dbaccess_helpid.hrc"
|
|
|
|
#include "browserids.hxx"
|
|
|
|
#include "querycontroller.hxx"
|
|
|
|
#include "undosqledit.hxx"
|
2001-02-28 09:01:54 +00:00
|
|
|
#include "QueryDesignView.hxx"
|
2008-11-28 11:39:37 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/smplhint.hxx>
|
2008-11-28 11:39:37 +00:00
|
|
|
|
2001-01-09 15:11:54 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// OSqlEdit
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
using namespace dbaui;
|
|
|
|
|
2006-06-20 02:00:45 +00:00
|
|
|
DBG_NAME(OSqlEdit)
|
2001-01-09 15:11:54 +00:00
|
|
|
OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) :
|
2008-11-28 11:39:37 +00:00
|
|
|
MultiLineEditSyntaxHighlight( pParent, nWinStyle )
|
2006-06-20 02:00:45 +00:00
|
|
|
,m_pView(pParent)
|
2001-01-09 15:11:54 +00:00
|
|
|
,m_bAccelAction( sal_False )
|
2001-04-18 12:20:48 +00:00
|
|
|
,m_bStopTimer(sal_False )
|
2001-01-09 15:11:54 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR(OSqlEdit,NULL);
|
|
|
|
SetHelpId( HID_CTL_QRYSQLEDIT );
|
|
|
|
SetModifyHdl( LINK(this, OSqlEdit, ModifyHdl) );
|
|
|
|
|
|
|
|
m_timerUndoActionCreation.SetTimeout(1000);
|
|
|
|
m_timerUndoActionCreation.SetTimeoutHdl(LINK(this, OSqlEdit, OnUndoActionTimer));
|
|
|
|
|
|
|
|
m_timerInvalidate.SetTimeout(200);
|
|
|
|
m_timerInvalidate.SetTimeoutHdl(LINK(this, OSqlEdit, OnInvalidateTimer));
|
|
|
|
m_timerInvalidate.Start();
|
2008-11-28 11:39:37 +00:00
|
|
|
|
|
|
|
ImplSetFont();
|
2009-02-13 07:10:18 +00:00
|
|
|
// listen for change of Font and Color Settings
|
2009-10-06 07:38:24 +02:00
|
|
|
m_SourceViewConfig.AddListener( this );
|
2009-10-16 00:05:16 +02:00
|
|
|
m_ColorConfig.AddListener(this);
|
2009-02-13 07:10:18 +00:00
|
|
|
|
|
|
|
//#i97044#
|
2011-01-14 15:00:11 +01:00
|
|
|
EnableFocusSelectionHide( sal_False );
|
2001-01-09 15:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OSqlEdit::~OSqlEdit()
|
|
|
|
{
|
2004-08-02 14:36:57 +00:00
|
|
|
DBG_DTOR(OSqlEdit,NULL);
|
2001-01-09 15:11:54 +00:00
|
|
|
if (m_timerUndoActionCreation.IsActive())
|
|
|
|
m_timerUndoActionCreation.Stop();
|
2009-10-06 07:38:24 +02:00
|
|
|
m_SourceViewConfig.RemoveListener(this);
|
2009-10-16 00:05:16 +02:00
|
|
|
m_ColorConfig.RemoveListener(this);
|
2001-01-09 15:11:54 +00:00
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OSqlEdit::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OSqlEdit,NULL);
|
2010-01-27 15:20:45 +01:00
|
|
|
OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
|
|
|
|
rController.InvalidateFeature(SID_CUT);
|
|
|
|
rController.InvalidateFeature(SID_COPY);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
|
|
|
// Ist dies ein Cut, Copy, Paste Event?
|
|
|
|
KeyFuncType aKeyFunc = rKEvt.GetKeyCode().GetFunction();
|
|
|
|
if( (aKeyFunc==KEYFUNC_CUT)||(aKeyFunc==KEYFUNC_COPY)||(aKeyFunc==KEYFUNC_PASTE) )
|
|
|
|
m_bAccelAction = sal_True;
|
|
|
|
|
2008-11-28 11:39:37 +00:00
|
|
|
MultiLineEditSyntaxHighlight::KeyInput( rKEvt );
|
2001-01-09 15:11:54 +00:00
|
|
|
|
|
|
|
if( m_bAccelAction )
|
|
|
|
m_bAccelAction = sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Bool OSqlEdit::IsInAccelAct()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OSqlEdit,NULL);
|
|
|
|
// Das Cut, Copy, Paste per Accel. fuehrt neben der Aktion im Edit im View
|
|
|
|
// auch die entsprechenden Slots aus. Die Aktionen finden also zweimal statt.
|
|
|
|
// Um dies zu verhindern, kann im View beim SlotExec diese Funktion
|
|
|
|
// aufgerufen werden.
|
|
|
|
|
|
|
|
return m_bAccelAction;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OSqlEdit::GetFocus()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OSqlEdit,NULL);
|
2004-08-02 14:36:57 +00:00
|
|
|
m_strOrigText =GetText();
|
2008-11-28 11:39:37 +00:00
|
|
|
MultiLineEditSyntaxHighlight::GetFocus();
|
2001-01-09 15:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OSqlEdit, OnUndoActionTimer, void*, EMPTYARG)
|
|
|
|
{
|
2004-08-02 14:36:57 +00:00
|
|
|
String aText =GetText();
|
2001-01-09 15:11:54 +00:00
|
|
|
if(aText != m_strOrigText)
|
|
|
|
{
|
2010-01-27 15:20:45 +01:00
|
|
|
OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
|
2010-11-17 09:11:03 +01:00
|
|
|
SfxUndoManager& rUndoMgr = rController.GetUndoManager();
|
2001-01-09 15:11:54 +00:00
|
|
|
OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this );
|
|
|
|
|
|
|
|
pUndoAct->SetOriginalText( m_strOrigText );
|
2010-11-17 09:11:03 +01:00
|
|
|
rUndoMgr.AddUndoAction( pUndoAct );
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2010-01-27 15:20:45 +01:00
|
|
|
rController.InvalidateFeature(SID_UNDO);
|
|
|
|
rController.InvalidateFeature(SID_REDO);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2004-08-02 14:36:57 +00:00
|
|
|
m_strOrigText =aText;
|
2001-01-09 15:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK(OSqlEdit, OnInvalidateTimer, void*, EMPTYARG)
|
|
|
|
{
|
2010-01-27 15:20:45 +01:00
|
|
|
OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
|
|
|
|
rController.InvalidateFeature(SID_CUT);
|
|
|
|
rController.InvalidateFeature(SID_COPY);
|
2001-04-18 12:20:48 +00:00
|
|
|
if(!m_bStopTimer)
|
|
|
|
m_timerInvalidate.Start();
|
2001-01-09 15:11:54 +00:00
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
2006-06-20 02:00:45 +00:00
|
|
|
IMPL_LINK(OSqlEdit, ModifyHdl, void*, /*EMPTYTAG*/)
|
2001-01-09 15:11:54 +00:00
|
|
|
{
|
|
|
|
if (m_timerUndoActionCreation.IsActive())
|
|
|
|
m_timerUndoActionCreation.Stop();
|
|
|
|
m_timerUndoActionCreation.Start();
|
|
|
|
|
2010-01-27 15:20:45 +01:00
|
|
|
OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
|
|
|
|
if (!rController.isModified())
|
|
|
|
rController.setModified( sal_True );
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2010-01-27 15:20:45 +01:00
|
|
|
rController.InvalidateFeature(SID_SBA_QRY_EXECUTE);
|
|
|
|
rController.InvalidateFeature(SID_CUT);
|
|
|
|
rController.InvalidateFeature(SID_COPY);
|
2001-01-09 15:11:54 +00:00
|
|
|
|
|
|
|
m_lnkTextModifyHdl.Call(NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2007-11-21 14:51:26 +00:00
|
|
|
void OSqlEdit::SetText(const String& rNewText)
|
2001-01-09 15:11:54 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS(OSqlEdit,NULL);
|
|
|
|
if (m_timerUndoActionCreation.IsActive())
|
|
|
|
{ // die noch anstehenden Undo-Action erzeugen
|
|
|
|
m_timerUndoActionCreation.Stop();
|
|
|
|
LINK(this, OSqlEdit, OnUndoActionTimer).Call(NULL);
|
|
|
|
}
|
|
|
|
|
2008-11-28 11:39:37 +00:00
|
|
|
MultiLineEditSyntaxHighlight::SetText(rNewText);
|
2004-08-02 14:36:57 +00:00
|
|
|
m_strOrigText =rNewText;
|
2001-01-09 15:11:54 +00:00
|
|
|
}
|
2001-04-18 12:20:48 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSqlEdit::stopTimer()
|
|
|
|
{
|
|
|
|
m_bStopTimer = sal_True;
|
|
|
|
if (m_timerInvalidate.IsActive())
|
|
|
|
m_timerInvalidate.Stop();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OSqlEdit::startTimer()
|
|
|
|
{
|
|
|
|
m_bStopTimer = sal_False;
|
|
|
|
if (!m_timerInvalidate.IsActive())
|
|
|
|
m_timerInvalidate.Start();
|
|
|
|
}
|
2001-01-09 15:11:54 +00:00
|
|
|
|
2009-10-16 00:05:16 +02:00
|
|
|
void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, sal_uInt32 )
|
2009-10-06 07:38:24 +02:00
|
|
|
{
|
|
|
|
if ( pOption == &m_SourceViewConfig )
|
|
|
|
ImplSetFont();
|
2009-10-16 00:05:16 +02:00
|
|
|
else if ( pOption == &m_ColorConfig )
|
|
|
|
MultiLineEditSyntaxHighlight::UpdateData();
|
2009-10-06 07:38:24 +02:00
|
|
|
}
|
|
|
|
|
2008-11-28 11:39:37 +00:00
|
|
|
void OSqlEdit::ImplSetFont()
|
|
|
|
{
|
|
|
|
AllSettings aSettings = GetSettings();
|
|
|
|
StyleSettings aStyleSettings = aSettings.GetStyleSettings();
|
|
|
|
String sFontName = m_SourceViewConfig.GetFontName();
|
|
|
|
if ( !sFontName.Len() )
|
|
|
|
{
|
|
|
|
Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
|
|
|
|
sFontName = aTmpFont.GetName();
|
|
|
|
}
|
|
|
|
Size aFontSize( 0, m_SourceViewConfig.GetFontHeight() );
|
|
|
|
Font aFont( sFontName, aFontSize );
|
|
|
|
aStyleSettings.SetFieldFont(aFont);
|
|
|
|
aSettings.SetStyleSettings(aStyleSettings);
|
|
|
|
SetSettings(aSettings);
|
|
|
|
}
|
2001-01-09 15:11:54 +00:00
|
|
|
//==============================================================================
|
2010-10-12 15:59:03 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|