[Libreoffice-commits] core.git: 2 commits - dbaccess/source dbaccess/uiconfig dbaccess/UIConfig_dbaccess.mk include/svx sw/qa sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 19 08:12:04 UTC 2020


 dbaccess/UIConfig_dbaccess.mk                      |    1 
 dbaccess/source/ui/control/sqledit.cxx             |  360 +++++++++------------
 dbaccess/source/ui/control/undosqledit.cxx         |    6 
 dbaccess/source/ui/dlg/directsql.cxx               |  135 -------
 dbaccess/source/ui/inc/QueryTextView.hxx           |   34 +
 dbaccess/source/ui/inc/directsql.hxx               |   21 -
 dbaccess/source/ui/inc/sqledit.hxx                 |   75 +---
 dbaccess/source/ui/inc/undosqledit.hxx             |   11 
 dbaccess/source/ui/querydesign/QueryTextView.cxx   |  151 ++++++--
 dbaccess/source/ui/querydesign/QueryViewSwitch.cxx |    8 
 dbaccess/uiconfig/ui/queryview.ui                  |   39 ++
 include/svx/weldeditview.hxx                       |    6 
 sw/qa/extras/layout/data/tdf112290.docx            |binary
 sw/qa/extras/layout/layout.cxx                     |    8 
 sw/source/core/text/portxt.cxx                     |    3 
 15 files changed, 416 insertions(+), 442 deletions(-)

New commits:
commit 44f7674ffda49257dcc1709256dfc4676d12165c
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Aug 18 12:02:45 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Aug 19 10:11:30 2020 +0200

    weld OQueryTextView
    
    its plausible with the EditEngine replacement for the SQL
    editor that the undo could be integrated better than the
    current check-if-the-text-has-changed timeout method. But
    that's left unchanged with this commit.
    
    Change-Id: I9b9e373044a80ee94dab4ceaad0ef2801b0b1166
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100950
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/UIConfig_dbaccess.mk b/dbaccess/UIConfig_dbaccess.mk
index 22e3c884b593..eb693505740b 100644
--- a/dbaccess/UIConfig_dbaccess.mk
+++ b/dbaccess/UIConfig_dbaccess.mk
@@ -61,6 +61,7 @@ $(eval $(call gb_UIConfig_add_uifiles,dbaccess, \
     dbaccess/uiconfig/ui/queryfilterdialog \
     dbaccess/uiconfig/ui/queryfuncmenu \
     dbaccess/uiconfig/ui/querypropertiesdialog  \
+    dbaccess/uiconfig/ui/queryview \
     dbaccess/uiconfig/ui/relationdialog \
     dbaccess/uiconfig/ui/rowheightdialog \
     dbaccess/uiconfig/ui/saveindexdialog \
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
index aa1745369edd..5abf5e228f7c 100644
--- a/dbaccess/source/ui/control/sqledit.cxx
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -25,6 +25,11 @@
 #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
 #include <officecfg/Office/Common.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/wghtitem.hxx>
 #include <sqledit.hxx>
 #include <QueryTextView.hxx>
 #include <querycontainerwindow.hxx>
@@ -34,6 +39,7 @@
 #include <svx/svxids.hrc>
 #include <cppuhelper/implbase.hxx>
 #include <i18nlangtag/languagetag.hxx>
+#include <svl/itemset.hxx>
 #include <vcl/event.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
@@ -43,11 +49,11 @@
 
 using namespace dbaui;
 
-class OSqlEdit::ChangesListener:
+class SQLEditView::ChangesListener:
     public cppu::WeakImplHelper< css::beans::XPropertiesChangeListener >
 {
 public:
-    explicit ChangesListener(OSqlEdit & editor): editor_(editor) {}
+    explicit ChangesListener(SQLEditView& editor): editor_(editor) {}
 
 private:
     virtual ~ChangesListener() override {}
@@ -65,29 +71,76 @@ private:
         editor_.ImplSetFont();
     }
 
-    OSqlEdit & editor_;
+    SQLEditView& editor_;
 };
 
-OSqlEdit::OSqlEdit(OQueryTextView* pParent)
-    : VclMultiLineEdit(pParent, WB_LEFT | WB_VSCROLL | WB_BORDER)
-    , aHighlighter(HighlighterLanguage::SQL)
-    , m_pView(pParent)
-    , m_bAccelAction( false )
-    , m_bStopTimer(false )
+SQLEditView::SQLEditView()
+    : m_aHighlighter(HighlighterLanguage::SQL)
+    , m_pItemPool(nullptr)
+    , m_bInUpdate(false)
+    , m_bDisableInternalUndo(false)
 {
-    EnableUpdateData(300);
+}
+
+void SQLEditView::DisableInternalUndo()
+{
+    GetEditEngine().EnableUndo(false);
+    m_bDisableInternalUndo = true;
+}
+
+void SQLEditView::SetItemPoolFont(SfxItemPool* pItemPool)
+{
+    StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings();
+    OUString sFontName(officecfg::Office::Common::Font::SourceViewFont::FontName::get().value_or(OUString()));
+    if (sFontName.isEmpty())
+    {
+        vcl::Font aTmpFont(OutputDevice::GetDefaultFont(DefaultFontType::FIXED, Application::GetSettings().GetUILanguageTag().getLanguageType(), GetDefaultFontFlags::NONE));
+        sFontName = aTmpFont.GetFamilyName();
+    }
+
+    Size aFontSize(0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get());
+    vcl::Font aAppFont(sFontName, aFontSize);
+
+    pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
+                                              "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
+                                              EE_CHAR_FONTINFO));
+    pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
+                                              "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
+                                              EE_CHAR_FONTINFO_CJK));
+    pItemPool->SetPoolDefaultItem(SvxFontItem(aAppFont.GetFamilyType(), aAppFont.GetFamilyName(),
+                                              "", PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW,
+                                              EE_CHAR_FONTINFO_CTL));
+
+    pItemPool->SetPoolDefaultItem(
+        SvxFontHeightItem(aAppFont.GetFontHeight() * 20, 100, EE_CHAR_FONTHEIGHT));
+    pItemPool->SetPoolDefaultItem(
+        SvxFontHeightItem(aAppFont.GetFontHeight() * 20, 100, EE_CHAR_FONTHEIGHT_CJK));
+    pItemPool->SetPoolDefaultItem(
+        SvxFontHeightItem(aAppFont.GetFontHeight() * 20, 100, EE_CHAR_FONTHEIGHT_CTL));
+}
+
+void SQLEditView::makeEditEngine()
+{
+    assert(!m_pItemPool);
+    m_pItemPool = EditEngine::CreatePool();
+    SetItemPoolFont(m_pItemPool);
+    m_xEditEngine.reset(new EditEngine(m_pItemPool));
+}
+
+void SQLEditView::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+    WeldEditView::SetDrawingArea(pDrawingArea);
 
-    SetHelpId( HID_CTL_QRYSQLEDIT );
-    SetModifyHdl( LINK(this, OSqlEdit, ModifyHdl) );
+    EditEngine& rEditEngine = GetEditEngine();
 
-    m_timerUndoActionCreation.SetTimeout(1000);
-    m_timerUndoActionCreation.SetInvokeHandler(LINK(this, OSqlEdit, OnUndoActionTimer));
+    rEditEngine.SetDefaultHorizontalTextDirection(EEHorizontalTextDirection::L2R);
+    rEditEngine.SetModifyHdl(LINK(this, SQLEditView, ModifyHdl));
 
-    m_timerInvalidate.SetTimeout(200);
-    m_timerInvalidate.SetInvokeHandler(LINK(this, OSqlEdit, OnInvalidateTimer));
-    m_timerInvalidate.Start();
+    m_aUpdateDataTimer.SetTimeout(300);
+    m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SQLEditView, ImplUpdateDataHdl));
 
     ImplSetFont();
+
     // Listen for change of Font and Color Settings:
     // Using "this" in ctor is a little fishy, but should work here at least as
     // long as there are no derivations:
@@ -104,16 +157,83 @@ OSqlEdit::OSqlEdit(OQueryTextView* pParent)
     s[1] = "FontName";
     n->addPropertiesChangeListener(s, m_listener.get());
     m_ColorConfig.AddListener(this);
+}
 
-    //#i97044#
-    EnableFocusSelectionHide( false );
+SQLEditView::~SQLEditView()
+{
+    css::uno::Reference< css::beans::XMultiPropertySet > n;
+    {
+        osl::MutexGuard g(m_mutex);
+        n = m_notifier;
+    }
+    if (n.is()) {
+        n->removePropertiesChangeListener(m_listener.get());
+    }
+    m_ColorConfig.RemoveListener(this);
 }
 
-void OSqlEdit::DoBracketHilight(sal_uInt16 nKey)
+void SQLEditView::SetTextAndUpdate(const OUString& rNewText)
 {
-    TextSelection aCurrentPos = GetTextView()->GetSelection();
-    sal_Int32 nStartPos = aCurrentPos.GetStart().GetIndex();
-    const sal_uInt32 nStartPara = aCurrentPos.GetStart().GetPara();
+    SetText(rNewText);
+    UpdateData();
+}
+
+IMPL_LINK_NOARG(SQLEditView, ModifyHdl, LinkParamNone*, void)
+{
+    if (m_bInUpdate)
+        return;
+
+    m_aModifyLink.Call(nullptr);
+    m_aUpdateDataTimer.Start();
+}
+
+IMPL_LINK_NOARG(SQLEditView, ImplUpdateDataHdl, Timer*, void)
+{
+    UpdateData();
+}
+
+Color SQLEditView::GetColorValue(TokenType aToken)
+{
+    return GetSyntaxHighlightColor(m_aColorConfig, m_aHighlighter.GetLanguage(), aToken);
+}
+
+void SQLEditView::UpdateData()
+{
+    m_bInUpdate = true;
+    EditEngine& rEditEngine = GetEditEngine();
+    // syntax highlighting
+    bool bOrigModified = rEditEngine.IsModified();
+    for (sal_Int32 nLine=0; nLine < rEditEngine.GetParagraphCount(); ++nLine)
+    {
+        OUString aLine( rEditEngine.GetText( nLine ) );
+
+        ESelection aAllLine(nLine, 0, nLine, EE_TEXTPOS_ALL);
+        rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_COLOR);
+        rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT);
+        rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT_CJK);
+        rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT_CTL);
+
+        std::vector<HighlightPortion> aPortions;
+        m_aHighlighter.getHighlightPortions( aLine, aPortions );
+        for (auto const& portion : aPortions)
+        {
+            SfxItemSet aSet(rEditEngine.GetEmptyItemSet());
+            aSet.Put(SvxColorItem(GetColorValue(portion.tokenType), EE_CHAR_COLOR));
+            rEditEngine.QuickSetAttribs(aSet, ESelection(nLine, portion.nBegin, nLine, portion.nEnd));
+        }
+    }
+    if (!bOrigModified)
+        rEditEngine.ClearModifyFlag();
+    m_bInUpdate = false;
+
+    Invalidate();
+}
+
+void SQLEditView::DoBracketHilight(sal_uInt16 nKey)
+{
+    ESelection aCurrentPos = m_xEditView->GetSelection();
+    sal_Int32 nStartPos = aCurrentPos.nStartPos;
+    const sal_uInt32 nStartPara = aCurrentPos.nStartPara;
     sal_uInt16 nCount = 0;
     int nChar = -1;
 
@@ -151,7 +271,7 @@ void OSqlEdit::DoBracketHilight(sal_uInt16 nKey)
         if (nPara == nStartPara && nStartPos == 0)
             continue;
 
-        OUString aLine( GetTextEngine()->GetText( nPara ) );
+        OUString aLine( m_xEditEngine->GetText( nPara ) );
 
         if (aLine.isEmpty())
             continue;
@@ -162,10 +282,14 @@ void OSqlEdit::DoBracketHilight(sal_uInt16 nKey)
             {
                 if (!nCount)
                 {
-                    GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nPara, i, i+1 );
-                    GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nPara, i, i+1 );
-                    GetTextEngine()->SetAttrib( TextAttribFontWeight( WEIGHT_ULTRABOLD ), nStartPara, nStartPos, nStartPos );
-                    GetTextEngine()->SetAttrib( TextAttribFontColor( Color(0,0,0) ), nStartPara, nStartPos, nStartPos );
+                    SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet());
+                    aSet.Put(SvxColorItem(Color(0,0,0), EE_CHAR_COLOR));
+                    aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT));
+                    aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT_CJK));
+                    aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT_CTL));
+
+                    m_xEditEngine->QuickSetAttribs(aSet, ESelection(nPara, i, nPara, i + 1));
+                    m_xEditEngine->QuickSetAttribs(aSet, ESelection(nStartPara, nStartPos, nStartPara, nStartPos));
                     return;
                 }
                 else
@@ -177,15 +301,7 @@ void OSqlEdit::DoBracketHilight(sal_uInt16 nKey)
     } while (nPara--);
 }
 
-bool OSqlEdit::PreNotify( NotifyEvent& rNEvt )
-{
-    if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
-        DoBracketHilight(rNEvt.GetKeyEvent()->GetCharCode());
-
-    return VclMultiLineEdit::PreNotify(rNEvt);
-}
-
-Color OSqlEdit::GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken)
+Color SQLEditView::GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken)
 {
     Color aColor;
     switch (eLanguage)
@@ -226,172 +342,34 @@ Color OSqlEdit::GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig
     return aColor;
 }
 
-Color OSqlEdit::GetColorValue(TokenType aToken)
+bool SQLEditView::KeyInput(const KeyEvent& rKEvt)
 {
-    return GetSyntaxHighlightColor(m_aColorConfig, aHighlighter.GetLanguage(), aToken);
-}
+    DoBracketHilight(rKEvt.GetCharCode());
 
-void OSqlEdit::UpdateData()
-{
-    // syntax highlighting
-    // this must be possible improved by using notifychange correctly
-    bool bTempModified = GetTextEngine()->IsModified();
-    for (sal_uInt32 nLine=0; nLine < GetTextEngine()->GetParagraphCount(); ++nLine)
+    if (m_bDisableInternalUndo)
     {
-        OUString aLine( GetTextEngine()->GetText( nLine ) );
-        GetTextEngine()->RemoveAttribs( nLine );
-        std::vector<HighlightPortion> aPortions;
-        aHighlighter.getHighlightPortions( aLine, aPortions );
-        for (auto const& portion : aPortions)
-        {
-            GetTextEngine()->SetAttrib( TextAttribFontColor( GetColorValue(portion.tokenType) ), nLine, portion.nBegin, portion.nEnd );
-        }
+        KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
+        if (eFunc == KeyFuncType::UNDO || eFunc == KeyFuncType::REDO)
+            return false;
     }
-    GetTextView()->ShowCursor( false );
-    GetTextEngine()->SetModified(bTempModified);
-}
 
-OSqlEdit::~OSqlEdit()
-{
-    disposeOnce();
+    return WeldEditView::KeyInput(rKEvt);
 }
 
-void OSqlEdit::dispose()
+void SQLEditView::ConfigurationChanged(utl::ConfigurationBroadcaster*, ConfigurationHints)
 {
-    if (m_timerUndoActionCreation.IsActive())
-        m_timerUndoActionCreation.Stop();
-    css::uno::Reference< css::beans::XMultiPropertySet > n;
-    {
-        osl::MutexGuard g(m_mutex);
-        n = m_notifier;
-    }
-    if (n.is()) {
-        n->removePropertiesChangeListener(m_listener.get());
-    }
-    m_ColorConfig.RemoveListener(this);
-    m_pView.clear();
-    VclMultiLineEdit::dispose();
-}
-
-void OSqlEdit::KeyInput( const KeyEvent& rKEvt )
-{
-    OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
-    rController.InvalidateFeature(SID_CUT);
-    rController.InvalidateFeature(SID_COPY);
-
-    // Is this a cut, copy, paste event?
-    KeyFuncType aKeyFunc = rKEvt.GetKeyCode().GetFunction();
-    if( (aKeyFunc==KeyFuncType::CUT)||(aKeyFunc==KeyFuncType::COPY)||(aKeyFunc==KeyFuncType::PASTE) )
-        m_bAccelAction = true;
-
-    VclMultiLineEdit::KeyInput( rKEvt );
-
-    if( m_bAccelAction )
-        m_bAccelAction = false;
-}
-
-void OSqlEdit::GetFocus()
-{
-    m_strOrigText  =GetText();
-    VclMultiLineEdit::GetFocus();
-}
-
-IMPL_LINK_NOARG(OSqlEdit, OnUndoActionTimer, Timer *, void)
-{
-    OUString aText = GetText();
-    if(aText == m_strOrigText)
-        return;
-
-    OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
-    SfxUndoManager& rUndoMgr = rController.GetUndoManager();
-    std::unique_ptr<OSqlEditUndoAct> pUndoAct(new OSqlEditUndoAct( this ));
-
-    pUndoAct->SetOriginalText( m_strOrigText );
-    rUndoMgr.AddUndoAction( std::move(pUndoAct) );
-
-    rController.InvalidateFeature(SID_UNDO);
-    rController.InvalidateFeature(SID_REDO);
-
-    m_strOrigText  =aText;
-}
-
-IMPL_LINK_NOARG(OSqlEdit, OnInvalidateTimer, Timer *, void)
-{
-    OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
-    rController.InvalidateFeature(SID_CUT);
-    rController.InvalidateFeature(SID_COPY);
-    if(!m_bStopTimer)
-        m_timerInvalidate.Start();
-}
-
-IMPL_LINK_NOARG(OSqlEdit, ModifyHdl, Edit&, void)
-{
-    if (m_timerUndoActionCreation.IsActive())
-        m_timerUndoActionCreation.Stop();
-    m_timerUndoActionCreation.Start();
-
-    OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
-    if (!rController.isModified())
-        rController.setModified( true );
-
-    rController.InvalidateFeature(SID_SBA_QRY_EXECUTE);
-    rController.InvalidateFeature(SID_CUT);
-    rController.InvalidateFeature(SID_COPY);
-}
-
-void OSqlEdit::SetText(const OUString& rNewText)
-{
-    if (m_timerUndoActionCreation.IsActive())
-    {   // create the trailing undo-actions
-        m_timerUndoActionCreation.Stop();
-        LINK(this, OSqlEdit, OnUndoActionTimer).Call(nullptr);
-    }
-
-    VclMultiLineEdit::SetText(rNewText);
     UpdateData();
-
-    m_strOrigText  =rNewText;
-}
-
-void OSqlEdit::stopTimer()
-{
-    m_bStopTimer = true;
-    if (m_timerInvalidate.IsActive())
-        m_timerInvalidate.Stop();
 }
 
-void OSqlEdit::startTimer()
+void SQLEditView::ImplSetFont()
 {
-    m_bStopTimer = false;
-    if (!m_timerInvalidate.IsActive())
-        m_timerInvalidate.Start();
-}
-
-void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, ConfigurationHints )
-{
-    assert( pOption == &m_ColorConfig );
-    (void) pOption; // avoid warnings
-    VclMultiLineEdit::UpdateData();
-}
-
-void OSqlEdit::ImplSetFont()
-{
-    AllSettings aSettings = GetSettings();
-    StyleSettings aStyleSettings = aSettings.GetStyleSettings();
-    OUString sFontName(
-        officecfg::Office::Common::Font::SourceViewFont::FontName::get().
-        value_or( OUString() ) );
-    if ( sFontName.isEmpty() )
-    {
-        vcl::Font aTmpFont( OutputDevice::GetDefaultFont( DefaultFontType::FIXED, Application::GetSettings().GetUILanguageTag().getLanguageType(), GetDefaultFontFlags::NONE, this ) );
-        sFontName = aTmpFont.GetFamilyName();
-    }
-    Size aFontSize(
-        0, officecfg::Office::Common::Font::SourceViewFont::FontHeight::get() );
-    vcl::Font aFont( sFontName, aFontSize );
-    aStyleSettings.SetFieldFont(aFont);
-    aSettings.SetStyleSettings(aStyleSettings);
-    SetSettings(aSettings);
+    // see SmEditWindow::DataChanged for a similar case
+    SetItemPoolFont(m_pItemPool); // change default font
+    // re-create with the new font
+    EditEngine& rEditEngine = GetEditEngine();
+    OUString aTxt(rEditEngine.GetText());
+    rEditEngine.Clear();
+    SetTextAndUpdate(aTxt);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/undosqledit.cxx b/dbaccess/source/ui/control/undosqledit.cxx
index d32774292a98..00a5fd40794d 100644
--- a/dbaccess/source/ui/control/undosqledit.cxx
+++ b/dbaccess/source/ui/control/undosqledit.cxx
@@ -18,14 +18,14 @@
  */
 
 #include <undosqledit.hxx>
-#include <sqledit.hxx>
+#include <QueryTextView.hxx>
 
 namespace dbaui
 {
 void OSqlEditUndoAct::ToggleText()
 {
-    OUString strNext = m_pOwner->GetText();
-    m_pOwner->SetText(m_strNextText);
+    OUString strNext = m_rOwner.GetSQLText();
+    m_rOwner.SetSQLText(m_strNextText);
     m_strNextText = strNext;
 }
 
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
index f4d59fea8820..41415850bbc4 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -26,6 +26,7 @@
 #include <editeng/wghtitem.hxx>
 #include <editeng/eeitem.hxx>
 #include <osl/mutex.hxx>
+#include <rtl/ustrbuf.hxx>
 #include <svl/itemset.hxx>
 #include <tools/diagnose_ex.h>
 #include <vcl/event.hxx>
@@ -37,88 +38,6 @@
 
 namespace dbaui
 {
-    SQLEditView::SQLEditView()
-    {
-    }
-
-    void SQLEditView::DoBracketHilight(sal_uInt16 nKey)
-    {
-        ESelection aCurrentPos = m_xEditView->GetSelection();
-        sal_Int32 nStartPos = aCurrentPos.nStartPos;
-        const sal_uInt32 nStartPara = aCurrentPos.nStartPara;
-        sal_uInt16 nCount = 0;
-        int nChar = -1;
-
-        switch (nKey)
-        {
-            case '\'':  // no break
-            case '"':
-            {
-                nChar = nKey;
-                break;
-            }
-            case '}' :
-            {
-                nChar = '{';
-                break;
-            }
-            case ')':
-            {
-                nChar = '(';
-                break;
-            }
-            case ']':
-            {
-                nChar = '[';
-                break;
-            }
-        }
-
-        if (nChar == -1)
-            return;
-
-        sal_uInt32 nPara = nStartPara;
-        do
-        {
-            if (nPara == nStartPara && nStartPos == 0)
-                continue;
-
-            OUString aLine( m_xEditEngine->GetText( nPara ) );
-
-            if (aLine.isEmpty())
-                continue;
-
-            for (sal_Int32 i = (nPara==nStartPara) ? nStartPos-1 : aLine.getLength()-1; i>0; --i)
-            {
-                if (aLine[i] == nChar)
-                {
-                    if (!nCount)
-                    {
-                        SfxItemSet aSet(m_xEditEngine->GetEmptyItemSet());
-                        aSet.Put(SvxColorItem(Color(0,0,0), EE_CHAR_COLOR));
-                        aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT));
-                        aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT_CJK));
-                        aSet.Put(SvxWeightItem(WEIGHT_ULTRABOLD, EE_CHAR_WEIGHT_CTL));
-
-                        m_xEditEngine->QuickSetAttribs(aSet, ESelection(nPara, i, nPara, i + 1));
-                        m_xEditEngine->QuickSetAttribs(aSet, ESelection(nStartPara, nStartPos, nStartPara, nStartPos));
-                        return;
-                    }
-                    else
-                        --nCount;
-                }
-                if (aLine[i] == nKey)
-                    ++nCount;
-            }
-        } while (nPara--);
-    }
-
-    bool SQLEditView::KeyInput(const KeyEvent& rKEvt)
-    {
-        DoBracketHilight(rKEvt.GetCharCode());
-        return WeldEditView::KeyInput(rKEvt);
-    }
-
     using namespace ::com::sun::star::uno;
     using namespace ::com::sun::star::sdbc;
     using namespace ::com::sun::star::lang;
@@ -136,9 +55,7 @@ namespace dbaui
         , m_xClose(m_xBuilder->weld_button("close"))
         , m_xSQL(new SQLEditView)
         , m_xSQLEd(new weld::CustomWeld(*m_xBuilder, "sql", *m_xSQL))
-        , m_aHighlighter(HighlighterLanguage::SQL)
         , m_nStatusCount(1)
-        , m_bInUpdate(false)
         , m_xConnection(_rxConn)
         , m_pClosingEvent(nullptr)
     {
@@ -163,9 +80,6 @@ namespace dbaui
 
         m_xSQL->SetModifyHdl(LINK(this, DirectSQLDialog, OnStatementModified));
         OnStatementModified(nullptr);
-
-        m_aUpdateDataTimer.SetTimeout(300);
-        m_aUpdateDataTimer.SetInvokeHandler(LINK(this, DirectSQLDialog, ImplUpdateDataHdl));
     }
 
     DirectSQLDialog::~DirectSQLDialog()
@@ -402,8 +316,7 @@ namespace dbaui
         {
             // set the text in the statement editor
             OUString sStatement = m_aStatementHistory[_nHistoryPos];
-            m_xSQL->SetText(sStatement);
-            UpdateData();
+            m_xSQL->SetTextAndUpdate(sStatement);
             OnStatementModified(nullptr);
 
             m_xSQL->GrabFocus();
@@ -414,11 +327,7 @@ namespace dbaui
 
     IMPL_LINK_NOARG( DirectSQLDialog, OnStatementModified, LinkParamNone*, void )
     {
-        if (m_bInUpdate)
-            return;
-
         m_xExecute->set_sensitive(!m_xSQL->GetText().isEmpty());
-        m_aUpdateDataTimer.Start();
     }
 
     IMPL_LINK_NOARG( DirectSQLDialog, OnCloseClick, weld::Button&, void )
@@ -447,46 +356,6 @@ namespace dbaui
             switchToHistory(nSelected);
     }
 
-    Color DirectSQLDialog::GetColorValue(TokenType aToken)
-    {
-        return OSqlEdit::GetSyntaxHighlightColor(m_aColorConfig, m_aHighlighter.GetLanguage(), aToken);
-    }
-
-    IMPL_LINK_NOARG(DirectSQLDialog, ImplUpdateDataHdl, Timer*, void)
-    {
-        UpdateData();
-    }
-
-    void DirectSQLDialog::UpdateData()
-    {
-        m_bInUpdate = true;
-        EditEngine& rEditEngine = m_xSQL->GetEditEngine();
-        // syntax highlighting
-        bool bOrigModified = rEditEngine.IsModified();
-        for (sal_Int32 nLine=0; nLine < rEditEngine.GetParagraphCount(); ++nLine)
-        {
-            OUString aLine( rEditEngine.GetText( nLine ) );
-
-            ESelection aAllLine(nLine, 0, nLine, EE_TEXTPOS_ALL);
-            rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_COLOR);
-            rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT);
-            rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT_CJK);
-            rEditEngine.RemoveAttribs(aAllLine, false, EE_CHAR_WEIGHT_CTL);
-
-            std::vector<HighlightPortion> aPortions;
-            m_aHighlighter.getHighlightPortions( aLine, aPortions );
-            for (auto const& portion : aPortions)
-            {
-                SfxItemSet aSet(rEditEngine.GetEmptyItemSet());
-                aSet.Put(SvxColorItem(GetColorValue(portion.tokenType), EE_CHAR_COLOR));
-                rEditEngine.QuickSetAttribs(aSet, ESelection(nLine, portion.nBegin, nLine, portion.nEnd));
-            }
-        }
-        if (!bOrigModified)
-            rEditEngine.ClearModifyFlag();
-        m_bInUpdate = false;
-    }
-
 }   // namespace dbaui
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/QueryTextView.hxx b/dbaccess/source/ui/inc/QueryTextView.hxx
index c41a7cea7bc9..e472c8dad8c7 100644
--- a/dbaccess/source/ui/inc/QueryTextView.hxx
+++ b/dbaccess/source/ui/inc/QueryTextView.hxx
@@ -19,20 +19,37 @@
 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTEXTVIEW_HXX
 #define INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTEXTVIEW_HXX
 
+#include <vcl/InterimItemWindow.hxx>
 #include "querycontainerwindow.hxx"
+#include "sqledit.hxx"
 
 namespace dbaui
 {
-    class OSqlEdit;
-    class OQueryTextView : public vcl::Window
+    class OQueryTextView final : public InterimItemWindow
     {
         friend class OQueryViewSwitch;
-        VclPtr<OSqlEdit>   m_pEdit;
+
+        OQueryController& m_rController;
+        std::unique_ptr<SQLEditView> m_xSQL;
+        std::unique_ptr<weld::CustomWeld> m_xSQLEd;
+
+        Timer m_timerUndoActionCreation;
+        OUString m_strOrigText;      // is restored on undo
+        Timer m_timerInvalidate;
+        bool m_bStopTimer;
+
+        DECL_LINK(OnUndoActionTimer, Timer*, void);
+        DECL_LINK(OnInvalidateTimer, Timer*, void);
+        DECL_LINK(ModifyHdl, LinkParamNone*, void);
+
     public:
-        OQueryTextView( OQueryContainerWindow* pParent );
+        OQueryTextView(OQueryContainerWindow* pParent, OQueryController& rController);
         virtual ~OQueryTextView() override;
         virtual void dispose() override;
 
+        void SetSQLText(const OUString& rNewText);
+        OUString GetSQLText() const;
+
         virtual void GetFocus() override;
 
         bool isCutAllowed() const;
@@ -44,15 +61,14 @@ namespace dbaui
         // set the statement for representation
         void setStatement(const OUString& _rsStatement);
         OUString getStatement() const;
-        // allow access to our edit
-        OSqlEdit* getSqlEdit() const { return m_pEdit; }
+
+        void stopTimer();
+        void startTimer();
 
         OQueryContainerWindow*  getContainerWindow() { return static_cast< OQueryContainerWindow* >( GetParent() ); }
-    protected:
-        virtual void Resize() override;
     };
 }
-#endif // INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTEXTVIEW_HXX
 
+#endif // INCLUDED_DBACCESS_SOURCE_UI_INC_QUERYTEXTVIEW_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx
index a58cfde7836a..bfa1f59d1231 100644
--- a/dbaccess/source/ui/inc/directsql.hxx
+++ b/dbaccess/source/ui/inc/directsql.hxx
@@ -33,21 +33,12 @@
 #include <unotools/eventlisteneradapter.hxx>
 #include <osl/mutex.hxx>
 
-#include <svx/weldeditview.hxx>
+#include "sqledit.hxx"
 
 struct ImplSVEvent;
 
 namespace dbaui
 {
-    class SQLEditView : public WeldEditView
-    {
-    private:
-        void DoBracketHilight(sal_uInt16 nKey);
-    public:
-        SQLEditView();
-        virtual bool KeyInput(const KeyEvent& rKEvt) override;
-    };
-
     // DirectSQLDialog
     class DirectSQLDialog final
             : public weld::GenericDialogController
@@ -64,16 +55,11 @@ namespace dbaui
         std::unique_ptr<SQLEditView> m_xSQL;
         std::unique_ptr<weld::CustomWeld> m_xSQLEd;
 
-        Timer m_aUpdateDataTimer;
-        const SyntaxHighlighter m_aHighlighter;
-        const svtools::ColorConfig m_aColorConfig;
-
         typedef std::deque< OUString >  StringQueue;
         StringQueue     m_aStatementHistory;    // previous statements
         StringQueue     m_aNormalizedHistory;   // previous statements, normalized to be used in the list box
 
         sal_Int32       m_nStatusCount;
-        bool            m_bInUpdate;
 
         css::uno::Reference< css::sdbc::XConnection >
                         m_xConnection;
@@ -93,10 +79,6 @@ namespace dbaui
         void executeCurrent();
         void switchToHistory(sal_Int32 _nHistoryPos);
 
-        Color GetColorValue(TokenType aToken);
-
-        void UpdateData();
-
         // OEventListenerAdapter
         virtual void _disposing( const css::lang::EventObject& _rSource ) override;
 
@@ -105,7 +87,6 @@ namespace dbaui
         DECL_LINK( OnCloseClick, weld::Button&, void );
         DECL_LINK( OnListEntrySelected, weld::ComboBox&, void );
         DECL_LINK( OnStatementModified, LinkParamNone*, void );
-        DECL_LINK( ImplUpdateDataHdl, Timer*, void );
 
         /// adds a statement to the statement history
         void implAddToStatementHistory(const OUString& _rStatement);
diff --git a/dbaccess/source/ui/inc/sqledit.hxx b/dbaccess/source/ui/inc/sqledit.hxx
index 478a248bf78b..9270bf77670a 100644
--- a/dbaccess/source/ui/inc/sqledit.hxx
+++ b/dbaccess/source/ui/inc/sqledit.hxx
@@ -24,72 +24,65 @@
 #include <comphelper/syntaxhighlight.hxx>
 #include <rtl/ref.hxx>
 #include <svtools/colorcfg.hxx>
-#include <vcl/vclmedit.hxx>
+#include <svx/weldeditview.hxx>
+#include <vcl/timer.hxx>
 
 namespace com::sun::star::beans { class XMultiPropertySet; }
 
 namespace dbaui
 {
-    class OQueryTextView;
-    class OSqlEdit final : public VclMultiLineEdit, public utl::ConfigurationListener
+    class SQLEditView final : public WeldEditView, public utl::ConfigurationListener
     {
     private:
         class ChangesListener;
         friend class ChangesListener;
 
-        SyntaxHighlighter    aHighlighter;
-        svtools::ColorConfig m_aColorConfig;
+        Link<LinkParamNone*,void> m_aModifyLink;
+        const svtools::ColorConfig m_aColorConfig;
+        Timer m_aUpdateDataTimer;
+        const SyntaxHighlighter m_aHighlighter;
+        svtools::ColorConfig m_ColorConfig;
+        SfxItemPool* m_pItemPool;
 
-        Timer                   m_timerInvalidate;
-        Timer                   m_timerUndoActionCreation;
-        OUString                m_strOrigText;      // is restored on undo
-        VclPtr<OQueryTextView>  m_pView;
-        bool                    m_bAccelAction;     // is set on cut, copy, paste
-        bool                    m_bStopTimer;
-        svtools::ColorConfig    m_ColorConfig;
+        rtl::Reference<ChangesListener> m_listener;
+        osl::Mutex m_mutex;
+        css::uno::Reference<css::beans::XMultiPropertySet> m_notifier;
 
-        rtl::Reference< ChangesListener > m_listener;
-        osl::Mutex              m_mutex;
-        css::uno::Reference<  css::beans::XMultiPropertySet > m_notifier;
+        bool m_bInUpdate;
+        bool m_bDisableInternalUndo;
 
-        DECL_LINK(OnUndoActionTimer, Timer*, void);
-        DECL_LINK(OnInvalidateTimer, Timer*, void);
+        DECL_LINK(ModifyHdl, LinkParamNone*, void);
+        DECL_LINK(ImplUpdateDataHdl, Timer*, void);
+
+        Color GetColorValue(TokenType aToken);
 
         void ImplSetFont();
-        void DoBracketHilight(sal_uInt16 aKey);
 
-        virtual bool PreNotify( NotifyEvent& rNEvt ) override;
-        virtual void KeyInput( const KeyEvent& rKEvt ) override;
-        virtual void GetFocus() override;
+        void DoBracketHilight(sal_uInt16 nKey);
 
-        DECL_LINK(ModifyHdl, Edit&, void);
+        static void SetItemPoolFont(SfxItemPool* pItemPool);
 
+        void UpdateData();
     public:
-        OSqlEdit( OQueryTextView* pParent);
-        virtual ~OSqlEdit() override;
-        virtual void dispose() override;
-
-        // Edit overridables
-        virtual void SetText(const OUString& rNewText) override;
-        virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override
-                    { SetText( rStr ); SetSelection( rNewSelection ); }
+        SQLEditView();
+        virtual void makeEditEngine() override;
+        virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+        virtual ~SQLEditView() override;
 
-        virtual void UpdateData() override;
+        virtual bool KeyInput(const KeyEvent& rKEvt) override;
 
-        static Color GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken);
+        void SetTextAndUpdate(const OUString& rNewText);
 
-        Color GetColorValue(TokenType aToken);
+        void SetModifyHdl(const Link<LinkParamNone*,void>& rLink)
+        {
+            m_aModifyLink = rLink;
+        }
 
-        // own functionality
-        // Cut, Copy, Paste by Accel. runs the action in the Edit but also the
-        // corresponding slot in the View. Therefore, the action occurs twice.
-        // To prevent this, SlotExec in View can call this function.
-        bool IsInAccelAct() const { return m_bAccelAction; }
+        void DisableInternalUndo();
 
-        void stopTimer();
-        void startTimer();
+        static Color GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken);
 
-        virtual void    ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
+        virtual void ConfigurationChanged(utl::ConfigurationBroadcaster*, ConfigurationHints) override;
     };
 }
 
diff --git a/dbaccess/source/ui/inc/undosqledit.hxx b/dbaccess/source/ui/inc/undosqledit.hxx
index 8d7f1d9ba56f..90b872ef4d9c 100644
--- a/dbaccess/source/ui/inc/undosqledit.hxx
+++ b/dbaccess/source/ui/inc/undosqledit.hxx
@@ -20,17 +20,16 @@
 #define INCLUDED_DBACCESS_SOURCE_UI_INC_UNDOSQLEDIT_HXX
 
 #include "GeneralUndo.hxx"
-#include "sqledit.hxx"
-#include <vcl/vclptr.hxx>
 #include <strings.hrc>
 
 namespace dbaui
 {
-    class OSqlEdit;
+    class OQueryTextView;
+
     // OSqlEditUndoAct - Undo-class for changing sql text
     class OSqlEditUndoAct final : public OCommentUndoAction
     {
-        VclPtr<OSqlEdit>   m_pOwner;
+        OQueryTextView& m_rOwner;
         OUString    m_strNextText;
 
         virtual void    Undo() override { ToggleText(); }
@@ -38,9 +37,9 @@ namespace dbaui
 
         void ToggleText();
     public:
-        OSqlEditUndoAct(OSqlEdit* pEdit) : OCommentUndoAction(STR_QUERY_UNDO_MODIFYSQLEDIT), m_pOwner(pEdit) { }
+        OSqlEditUndoAct(OQueryTextView& rEdit) : OCommentUndoAction(STR_QUERY_UNDO_MODIFYSQLEDIT), m_rOwner(rEdit) { }
 
-        void SetOriginalText(const OUString& strText) { m_strNextText =strText; }
+        void SetOriginalText(const OUString& strText) { m_strNextText = strText; }
     };
 }
 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_UNDOSQLEDIT_HXX
diff --git a/dbaccess/source/ui/querydesign/QueryTextView.cxx b/dbaccess/source/ui/querydesign/QueryTextView.cxx
index 9633146900c6..495d447030ba 100644
--- a/dbaccess/source/ui/querydesign/QueryTextView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryTextView.cxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sfx2/sfxsids.hrc>
+#include <svx/svxids.hrc>
 #include <QueryTextView.hxx>
 #include <querycontainerwindow.hxx>
+#include <helpids.h>
 #include <sqledit.hxx>
 #include <undosqledit.hxx>
 #include <QueryDesignView.hxx>
@@ -28,15 +31,77 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 
 // end of temp classes
-OQueryTextView::OQueryTextView(OQueryContainerWindow* _pParent)
-    :Window(_pParent)
+OQueryTextView::OQueryTextView(OQueryContainerWindow* pParent, OQueryController& rController)
+    : InterimItemWindow(pParent, "dbaccess/ui/queryview.ui", "QueryView")
+    , m_rController(rController)
+    , m_xSQL(new SQLEditView)
+    , m_xSQLEd(new weld::CustomWeld(*m_xBuilder, "sql", *m_xSQL))
+    , m_bStopTimer(false)
 {
-    m_pEdit = VclPtr<OSqlEdit>::Create(this);
-    m_pEdit->SetRightToLeft(false);
-    m_pEdit->ClearModifyFlag();
-    m_pEdit->SaveValue();
-    m_pEdit->SetPosPixel( Point( 0, 0 ) );
-    m_pEdit->Show();
+    m_xSQL->DisableInternalUndo();
+    m_xSQL->SetHelpId(HID_CTL_QRYSQLEDIT);
+    m_xSQL->SetModifyHdl(LINK(this, OQueryTextView, ModifyHdl));
+
+    m_timerUndoActionCreation.SetTimeout(1000);
+    m_timerUndoActionCreation.SetInvokeHandler(LINK(this, OQueryTextView, OnUndoActionTimer));
+
+    m_timerInvalidate.SetTimeout(200);
+    m_timerInvalidate.SetInvokeHandler(LINK(this, OQueryTextView, OnInvalidateTimer));
+    m_timerInvalidate.Start();
+}
+
+IMPL_LINK_NOARG(OQueryTextView, ModifyHdl, LinkParamNone*, void)
+{
+    if (m_timerUndoActionCreation.IsActive())
+        m_timerUndoActionCreation.Stop();
+    m_timerUndoActionCreation.Start();
+
+    if (!m_rController.isModified())
+        m_rController.setModified( true );
+
+    m_rController.InvalidateFeature(SID_SBA_QRY_EXECUTE);
+    m_rController.InvalidateFeature(SID_CUT);
+    m_rController.InvalidateFeature(SID_COPY);
+}
+
+IMPL_LINK_NOARG(OQueryTextView, OnUndoActionTimer, Timer*, void)
+{
+    OUString aText = m_xSQL->GetText();
+    if (aText == m_strOrigText)
+        return;
+
+    SfxUndoManager& rUndoMgr = m_rController.GetUndoManager();
+    std::unique_ptr<OSqlEditUndoAct> xUndoAct(new OSqlEditUndoAct(*this));
+
+    xUndoAct->SetOriginalText(m_strOrigText);
+    rUndoMgr.AddUndoAction(std::move(xUndoAct));
+
+    m_rController.InvalidateFeature(SID_UNDO);
+    m_rController.InvalidateFeature(SID_REDO);
+
+    m_strOrigText = aText;
+}
+
+IMPL_LINK_NOARG(OQueryTextView, OnInvalidateTimer, Timer*, void)
+{
+    m_rController.InvalidateFeature(SID_CUT);
+    m_rController.InvalidateFeature(SID_COPY);
+    if (!m_bStopTimer)
+        m_timerInvalidate.Start();
+}
+
+void OQueryTextView::startTimer()
+{
+    m_bStopTimer = false;
+    if (!m_timerInvalidate.IsActive())
+        m_timerInvalidate.Start();
+}
+
+void OQueryTextView::stopTimer()
+{
+    m_bStopTimer = true;
+    if (m_timerInvalidate.IsActive())
+        m_timerInvalidate.Stop();
 }
 
 OQueryTextView::~OQueryTextView()
@@ -46,65 +111,83 @@ OQueryTextView::~OQueryTextView()
 
 void OQueryTextView::dispose()
 {
-    m_pEdit.disposeAndClear();
-    vcl::Window::dispose();
-}
+    if (m_timerUndoActionCreation.IsActive())
+        m_timerUndoActionCreation.Stop();
 
-void OQueryTextView::GetFocus()
-{
-    if ( m_pEdit )
-        m_pEdit->GrabFocus();
+    m_xSQLEd.reset();
+    m_xSQL.reset();
+    InterimItemWindow::dispose();
 }
 
-void OQueryTextView::Resize()
+void OQueryTextView::GetFocus()
 {
-    Window::Resize();
-    m_pEdit->SetSizePixel( GetOutputSizePixel() );
+    if (m_xSQL)
+    {
+        m_xSQL->GrabFocus();
+        m_strOrigText = m_xSQL->GetText();
+    }
+    InterimItemWindow::GetFocus();
 }
 
 OUString OQueryTextView::getStatement() const
 {
-    return m_pEdit->GetText();
+    return m_xSQL->GetText();
 }
 
 void OQueryTextView::clear()
 {
-    std::unique_ptr<OSqlEditUndoAct> pUndoAct(new OSqlEditUndoAct( m_pEdit ));
+    std::unique_ptr<OSqlEditUndoAct> xUndoAct(new OSqlEditUndoAct(*this));
 
-    pUndoAct->SetOriginalText( m_pEdit->GetText() );
-    getContainerWindow()->getDesignView()->getController().addUndoActionAndInvalidate( std::move(pUndoAct) );
+    xUndoAct->SetOriginalText(m_xSQL->GetText());
+    m_rController.addUndoActionAndInvalidate( std::move(xUndoAct) );
 
-    m_pEdit->SetText(OUString());
+    SetSQLText(OUString());
 }
 
-void OQueryTextView::setStatement(const OUString& _rsStatement)
+void OQueryTextView::setStatement(const OUString& rsStatement)
 {
-    m_pEdit->SetText(_rsStatement);
+    SetSQLText(rsStatement);
+}
+
+OUString OQueryTextView::GetSQLText() const
+{
+    return m_xSQL->GetText();
+}
+
+void OQueryTextView::SetSQLText(const OUString& rNewText)
+{
+    if (m_timerUndoActionCreation.IsActive())
+    {
+        // create the trailing undo-actions
+        m_timerUndoActionCreation.Stop();
+        OnUndoActionTimer(nullptr);
+    }
+
+    m_xSQL->SetTextAndUpdate(rNewText);
+
+    m_strOrigText = rNewText;
 }
 
 void OQueryTextView::copy()
 {
-    if(!m_pEdit->IsInAccelAct() )
-        m_pEdit->Copy();
+    m_xSQL->Copy();
 }
 
 bool OQueryTextView::isCutAllowed() const
 {
-    return !m_pEdit->GetSelected().isEmpty();
+    return m_xSQL->HasSelection();
 }
 
 void OQueryTextView::cut()
 {
-    if(!m_pEdit->IsInAccelAct() )
-        m_pEdit->Cut();
-    getContainerWindow()->getDesignView()->getController().setModified(true);
+    m_xSQL->Cut();
+    m_rController.setModified(true);
 }
 
 void OQueryTextView::paste()
 {
-    if(!m_pEdit->IsInAccelAct() )
-        m_pEdit->Paste();
-    getContainerWindow()->getDesignView()->getController().setModified(true);
+    m_xSQL->Paste();
+    m_rController.setModified(true);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
index e7d6758f480f..626a1f346e44 100644
--- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -33,7 +33,7 @@ OQueryViewSwitch::OQueryViewSwitch(OQueryContainerWindow* _pParent, OQueryContro
 : m_bAddTableDialogWasVisible(false)
 {
 
-    m_pTextView     = VclPtr<OQueryTextView>::Create(_pParent);
+    m_pTextView     = VclPtr<OQueryTextView>::Create(_pParent, _rController);
     m_pDesignView   = VclPtr<OQueryDesignView>::Create( _pParent, _rController, _rxContext );
 }
 
@@ -154,7 +154,7 @@ void OQueryViewSwitch::impl_forceSQLView()
 
     // tell the views they're in/active
     m_pDesignView->stopTimer();
-    m_pTextView->getSqlEdit()->startTimer();
+    m_pTextView->startTimer();
 
     // set the most recent statement at the text view
     m_pTextView->clear();
@@ -170,7 +170,7 @@ void OQueryViewSwitch::forceInitialView()
     else
     {
         // tell the text view it's inactive now
-        m_pTextView->getSqlEdit()->stopTimer();
+        m_pTextView->stopTimer();
 
         // update the "Add Table" dialog
         OAddTableDlg* pAddTabDialog( getAddTableDialog() );
@@ -199,7 +199,7 @@ bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
     else
     {
         // tell the text view it's inactive now
-        m_pTextView->getSqlEdit()->stopTimer();
+        m_pTextView->stopTimer();
 
         // update the "Add Table" dialog
         OAddTableDlg* pAddTabDialog( getAddTableDialog() );
diff --git a/dbaccess/uiconfig/ui/queryview.ui b/dbaccess/uiconfig/ui/queryview.ui
new file mode 100644
index 000000000000..8c55d5351c24
--- /dev/null
+++ b/dbaccess/uiconfig/ui/queryview.ui
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface domain="dba">
+  <requires lib="gtk+" version="3.18"/>
+  <object class="GtkBox" id="QueryView">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="vexpand">True</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <property name="border_width">0</property>
+        <property name="shadow_type">in</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <child>
+              <object class="GtkDrawingArea" id="sql">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx
index 071a8f50d852..bb832e44ab6f 100644
--- a/include/svx/weldeditview.hxx
+++ b/include/svx/weldeditview.hxx
@@ -37,6 +37,12 @@ public:
 
     EditEngine& GetEditEngine() { return *m_xEditEngine; }
 
+    bool HasSelection() const { return m_xEditView->HasSelection(); }
+
+    void Cut() { m_xEditView->Cut(); }
+    void Copy() { m_xEditView->Copy(); }
+    void Paste() { m_xEditView->Paste(); }
+
     virtual ~WeldEditView() override;
 
 protected:
commit 1b03a449161af225302e4b4dd2bb2e69c6d8d170
Author:     Attila Bakos <bakos.attilakaroly at nisz.hu>
AuthorDate: Mon Aug 3 10:45:14 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Aug 19 10:11:21 2020 +0200

    tdf#112290 sw: fix missing line break in small capital
    
    Calculated hyphenation positions are skipped in the case
    small capital text, resulting long lines exceeding paragraph
    width, for example after wide images.
    
    Likely the reason of the problem is tdf#78527 "FORMATTING:
    automatic hyphenation doesn't work on text in small caps or
    all caps".
    
    Change-Id: Ia0121728bcc099f3ec19e01afd64e1594d6274be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99992
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/layout/data/tdf112290.docx b/sw/qa/extras/layout/data/tdf112290.docx
new file mode 100644
index 000000000000..c49b5e384b4b
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf112290.docx differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index d6b233ca6107..0ce860834445 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3474,6 +3474,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf115094)
     CPPUNIT_ASSERT_LESS(nTopOfB2Anchored, nTopOfB2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf112290)
+{
+    SwDoc* pDoc = createDoc("tdf112290.docx");
+    CPPUNIT_ASSERT(pDoc);
+    auto pXml = parseLayoutDump();
+    assertXPath(pXml, "/root/page/body/txt/LineBreak[2]", "Line", "Xxxx Xxxx");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607)
 {
     createDoc("tdf122607.odt");
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index ace126870b54..398b26e6706b 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -344,7 +344,8 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf )
         Insert( aGuess.ReleaseHangingPortion() );
     }
     // breakPos >= index
-    else if (aGuess.BreakPos() >= rInf.GetIdx() && aGuess.BreakPos() != TextFrameIndex(COMPLETE_STRING))
+    else if (aGuess.BreakPos() >= rInf.GetIdx() && aGuess.BreakPos() != TextFrameIndex(COMPLETE_STRING)
+        && rInf.GetFont()->GetCaseMap() != SvxCaseMap::SmallCaps )
     {
         // case B1
         if( aGuess.HyphWord().is() && aGuess.BreakPos() > rInf.GetLineStart()


More information about the Libreoffice-commits mailing list