From 573562e72a5fd85b75006fbc8869c73903a6e504 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 15 Sep 2019 20:18:38 +0100 Subject: weld DirectSQLDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8f97068bb38a1fb888d60251f8f25506044c8451 Reviewed-on: https://gerrit.libreoffice.org/78970 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/dialogs/SpellDialog.cxx | 20 -- cui/source/inc/SpellDialog.hxx | 1 - dbaccess/source/ui/dlg/directsql.cxx | 284 ++++++++++++++++++------- dbaccess/source/ui/inc/directsql.hxx | 53 +++-- dbaccess/source/ui/uno/unoDirectSql.cxx | 7 +- dbaccess/uiconfig/ui/directsqldialog.ui | 42 +++- extras/source/glade/libreoffice-catalog.xml.in | 3 - include/svtools/editsyntaxhighlighter.hxx | 2 + include/svx/ClassificationEditView.hxx | 5 - include/svx/weldeditview.hxx | 12 ++ solenv/bin/native-code.py | 1 - svtools/source/edit/editsyntaxhighlighter.cxx | 25 ++- svx/source/dialog/weldeditview.cxx | 40 +++- 13 files changed, 344 insertions(+), 151 deletions(-) diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx index 5e9e6f4d764f..ab03a51c4e15 100644 --- a/cui/source/dialogs/SpellDialog.cxx +++ b/cui/source/dialogs/SpellDialog.cxx @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include #include @@ -1106,24 +1104,6 @@ SentenceEditWindow_Impl::SentenceEditWindow_Impl() { } -// tdf#127033 want to use UI font so override makeEditEngine to enable that -void SentenceEditWindow_Impl::makeEditEngine() -{ - SfxItemPool* pItemPool = EditEngine::CreatePool(); - - vcl::Font aAppFont(Application::GetSettings().GetStyleSettings().GetAppFont()); - - 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)); - - m_xEditEngine.reset(new EditEngine(pItemPool)); -} - void SentenceEditWindow_Impl::SetDrawingArea(weld::DrawingArea* pDrawingArea) { Size aSize(pDrawingArea->get_approximate_digit_width() * 60, diff --git a/cui/source/inc/SpellDialog.hxx b/cui/source/inc/SpellDialog.hxx index 51b80bd77b79..65de78342f7e 100644 --- a/cui/source/inc/SpellDialog.hxx +++ b/cui/source/inc/SpellDialog.hxx @@ -68,7 +68,6 @@ private: protected: virtual bool KeyInput( const KeyEvent& rKEvt ) override; - virtual void makeEditEngine() override; public: SentenceEditWindow_Impl(); diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx index 6b050b044478..9d8035e582ee 100644 --- a/dbaccess/source/ui/dlg/directsql.cxx +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -21,18 +21,104 @@ #include #include #include -#include #include -#include +#include +#include +#include #include +#include #include #include +#include +#include +#include #include #include #include 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; @@ -41,33 +127,34 @@ namespace dbaui constexpr sal_Int32 g_nHistoryLimit = 20; // DirectSQLDialog - DirectSQLDialog::DirectSQLDialog( vcl::Window* _pParent, const Reference< XConnection >& _rxConn ) - :ModalDialog(_pParent, "DirectSQLDialog" , "dbaccess/ui/directsqldialog.ui") - ,m_nStatusCount(1) - ,m_xConnection(_rxConn) + DirectSQLDialog::DirectSQLDialog(weld::Window* _pParent, const Reference< XConnection >& _rxConn) + : GenericDialogController(_pParent, "dbaccess/ui/directsqldialog.ui", "DirectSQLDialog") + , m_xExecute(m_xBuilder->weld_button("execute")) + , m_xSQLHistory(m_xBuilder->weld_combo_box("sqlhistory")) + , m_xStatus(m_xBuilder->weld_text_view("status")) + , m_xShowOutput(m_xBuilder->weld_check_button("showoutput")) + , m_xOutput(m_xBuilder->weld_text_view("output")) + , 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) { - get(m_pSQL,"sql"); - Size aSize(m_pSQL->CalcBlockSize(60, 7)); - m_pSQL->set_width_request(aSize.Width()); - m_pSQL->set_height_request(aSize.Height()); - get(m_pExecute,"execute"); - get(m_pSQLHistory,"sqlhistory"); - get(m_pStatus,"status"); - aSize = m_pStatus->CalcBlockSize(60, 5); - m_pStatus->set_height_request(aSize.Height()); - get(m_pShowOutput,"showoutput"); - get(m_pOutput,"output"); - aSize = m_pOutput->CalcBlockSize(60, 5); - m_pOutput->set_height_request(aSize.Height()); - get(m_pClose,"close"); - - - m_pSQL->GrabFocus(); - - m_pExecute->SetClickHdl(LINK(this, DirectSQLDialog, OnExecute)); - m_pClose->SetClickHdl(LINK(this, DirectSQLDialog, OnCloseClick)); - m_pSQLHistory->SetSelectHdl(LINK(this, DirectSQLDialog, OnListEntrySelected)); - m_pSQLHistory->SetDropDownLineCount(10); + int nWidth = m_xStatus->get_approximate_digit_width() * 60; + int nHeight = m_xStatus->get_height_rows(7); + + m_xSQLEd->set_size_request(nWidth, nHeight); + m_xStatus->set_size_request(-1, nHeight); + m_xOutput->set_size_request(-1, nHeight); + + m_xSQL->GrabFocus(); + + m_xExecute->connect_clicked(LINK(this, DirectSQLDialog, OnExecute)); + m_xClose->connect_clicked(LINK(this, DirectSQLDialog, OnCloseClick)); + m_xSQLHistory->connect_changed(LINK(this, DirectSQLDialog, OnListEntrySelected)); // add a dispose listener to the connection Reference< XComponent > xConnComp(m_xConnection, UNO_QUERY); @@ -75,29 +162,19 @@ namespace dbaui if (xConnComp.is()) startComponentListening(xConnComp); - m_pSQL->SetModifyHdl(LINK(this, DirectSQLDialog, OnStatementModified)); - OnStatementModified(*m_pSQL); - } + m_xSQL->SetModifyHdl(LINK(this, DirectSQLDialog, OnStatementModified)); + OnStatementModified(nullptr); - DirectSQLDialog::~DirectSQLDialog() - { - disposeOnce(); + m_aUpdateDataTimer.SetTimeout(300); + m_aUpdateDataTimer.SetInvokeHandler(LINK(this, DirectSQLDialog, ImplUpdateDataHdl)); } - void DirectSQLDialog::dispose() + DirectSQLDialog::~DirectSQLDialog() { - { - ::osl::MutexGuard aGuard(m_aMutex); - stopAllComponentListening(); - } - m_pSQL.clear(); - m_pExecute.clear(); - m_pSQLHistory.clear(); - m_pStatus.clear(); - m_pShowOutput.clear(); - m_pOutput.clear(); - m_pClose.clear(); - ModalDialog::dispose(); + ::osl::MutexGuard aGuard(m_aMutex); + if (m_pClosingEvent) + Application::RemoveUserEvent(m_pClosingEvent); + stopAllComponentListening(); } void DirectSQLDialog::_disposing( const EventObject& _rSource ) @@ -105,18 +182,20 @@ namespace dbaui SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard(m_aMutex); + assert(!m_pClosingEvent); + OSL_ENSURE(Reference< XConnection >(_rSource.Source, UNO_QUERY).get() == m_xConnection.get(), "DirectSQLDialog::_disposing: where does this come from?"); { OUString sMessage(DBA_RES(STR_DIRECTSQL_CONNECTIONLOST)); - std::unique_ptr xError(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr xError(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Warning, VclButtonsType::Ok, sMessage)); xError->run(); } - PostUserEvent(LINK(this, DirectSQLDialog, OnClose), nullptr, true); + m_pClosingEvent = Application::PostUserEvent(LINK(this, DirectSQLDialog, OnClose)); } sal_Int32 DirectSQLDialog::getHistorySize() const @@ -138,7 +217,7 @@ namespace dbaui { m_aStatementHistory.pop_front(); m_aNormalizedHistory.pop_front(); - m_pSQLHistory->RemoveEntry(sal_uInt16(0)); + m_xSQLHistory->remove(0); } } @@ -154,7 +233,7 @@ namespace dbaui m_aNormalizedHistory.push_back(sNormalized); // add the normalized version to the list box - m_pSQLHistory->InsertEntry(sNormalized); + m_xSQLHistory->append_text(sNormalized); // ensure that we don't exceed the history limit implEnsureHistoryLimit(); @@ -166,10 +245,10 @@ namespace dbaui if (m_aStatementHistory.size() != m_aNormalizedHistory.size()) return "statement history is inconsistent!"; - if (!m_pSQLHistory) + if (!m_xSQLHistory) return "invalid listbox!"; - if (m_aStatementHistory.size() != static_cast(m_pSQLHistory->GetEntryCount())) + if (m_aStatementHistory.size() != static_cast(m_xSQLHistory->get_count())) return "invalid listbox entry count!"; if (!m_xConnection.is()) @@ -188,7 +267,7 @@ namespace dbaui OUString sStatus; // clear the output box - m_pOutput->SetText(OUString()); + m_xOutput->set_text(OUString()); try { // create a statement @@ -203,7 +282,7 @@ namespace dbaui if(hasRS) { css::uno::Reference< css::sdbc::XResultSet > xRS (xMR->getResultSet()); - if (m_pShowOutput->IsChecked()) + if (m_xShowOutput->get_active()) display(xRS); } else @@ -213,7 +292,7 @@ namespace dbaui if(hasRS) { css::uno::Reference< css::sdbc::XResultSet > xRS (xMR->getResultSet()); - if (m_pShowOutput->IsChecked()) + if (m_xShowOutput->get_active()) display(xRS); } } @@ -223,7 +302,7 @@ namespace dbaui if (_rStatement.toAsciiUpperCase().startsWith("SELECT")) { css::uno::Reference< css::sdbc::XResultSet > xRS = xStatement->executeQuery(_rStatement); - if(m_pShowOutput->IsChecked()) + if (m_xShowOutput->get_active()) display(xRS); } else @@ -284,25 +363,25 @@ namespace dbaui { OUString sAppendMessage = OUString::number(m_nStatusCount++) + ": " + _rMessage + "\n\n"; - OUString sCompleteMessage = m_pStatus->GetText() + sAppendMessage; - m_pStatus->SetText(sCompleteMessage); + OUString sCompleteMessage = m_xStatus->get_text() + sAppendMessage; + m_xStatus->set_text(sCompleteMessage); - m_pStatus->SetSelection(Selection(sCompleteMessage.getLength(), sCompleteMessage.getLength())); + m_xStatus->select_region(sCompleteMessage.getLength(), sCompleteMessage.getLength()); } void DirectSQLDialog::addOutputText(const OUString& _rMessage) { OUString sAppendMessage = _rMessage + "\n"; - OUString sCompleteMessage = m_pOutput->GetText() + sAppendMessage; - m_pOutput->SetText(sCompleteMessage); + OUString sCompleteMessage = m_xOutput->get_text() + sAppendMessage; + m_xOutput->set_text(sCompleteMessage); } void DirectSQLDialog::executeCurrent() { CHECK_INVARIANTS("DirectSQLDialog::executeCurrent"); - OUString sStatement = m_pSQL->GetText(); + OUString sStatement = m_xSQL->GetText(); // execute implExecuteStatement(sStatement); @@ -310,8 +389,7 @@ namespace dbaui // add the statement to the history implAddToStatementHistory(sStatement); - m_pSQL->SetSelection(Selection()); - m_pSQL->GrabFocus(); + m_xSQL->GrabFocus(); } void DirectSQLDialog::switchToHistory(sal_Int32 _nHistoryPos) @@ -322,43 +400,89 @@ namespace dbaui { // set the text in the statement editor OUString sStatement = m_aStatementHistory[_nHistoryPos]; - m_pSQL->SetText(sStatement); - OnStatementModified(*m_pSQL); + m_xSQL->SetText(sStatement); + UpdateData(); + OnStatementModified(nullptr); - m_pSQL->GrabFocus(); - m_pSQL->SetSelection(Selection(sStatement.getLength(), sStatement.getLength())); + m_xSQL->GrabFocus(); } else OSL_FAIL("DirectSQLDialog::switchToHistory: invalid position!"); } - IMPL_LINK_NOARG( DirectSQLDialog, OnStatementModified, Edit&, void ) + IMPL_LINK_NOARG( DirectSQLDialog, OnStatementModified, LinkParamNone*, void ) { - m_pExecute->Enable(!m_pSQL->GetText().isEmpty()); + if (m_bInUpdate) + return; + + m_xExecute->set_sensitive(!m_xSQL->GetText().isEmpty()); + m_aUpdateDataTimer.Start(); } - IMPL_LINK_NOARG( DirectSQLDialog, OnCloseClick, Button*, void ) + IMPL_LINK_NOARG( DirectSQLDialog, OnCloseClick, weld::Button&, void ) { - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } + IMPL_LINK_NOARG( DirectSQLDialog, OnClose, void*, void ) { - EndDialog( RET_OK ); + assert(m_pClosingEvent); + Application::RemoveUserEvent(m_pClosingEvent); + m_pClosingEvent = nullptr; + + m_xDialog->response(RET_OK); } - IMPL_LINK_NOARG( DirectSQLDialog, OnExecute, Button*, void ) + IMPL_LINK_NOARG( DirectSQLDialog, OnExecute, weld::Button&, void ) { executeCurrent(); } - IMPL_LINK_NOARG( DirectSQLDialog, OnListEntrySelected, ListBox&, void ) + IMPL_LINK_NOARG( DirectSQLDialog, OnListEntrySelected, weld::ComboBox&, void ) + { + const sal_Int32 nSelected = m_xSQLHistory->get_active(); + if (nSelected != -1) + switchToHistory(nSelected); + } + + Color DirectSQLDialog::GetColorValue(TokenType aToken) + { + return MultiLineEditSyntaxHighlight::GetSyntaxHighlightColor(m_aColorConfig, m_aHighlighter.GetLanguage(), aToken); + } + + IMPL_LINK_NOARG(DirectSQLDialog, ImplUpdateDataHdl, Timer*, void) + { + UpdateData(); + } + + void DirectSQLDialog::UpdateData() { - if (!m_pSQLHistory->IsTravelSelect()) + m_bInUpdate = true; + EditEngine& rEditEngine = m_xSQL->GetEditEngine(); + // syntax highlighting + bool bOrigModified = rEditEngine.IsModified(); + for (sal_Int32 nLine=0; nLine < rEditEngine.GetParagraphCount(); ++nLine) { - const sal_Int32 nSelected = m_pSQLHistory->GetSelectedEntryPos(); - if (LISTBOX_ENTRY_NOTFOUND != nSelected) - switchToHistory(nSelected); + 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 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 diff --git a/dbaccess/source/ui/inc/directsql.hxx b/dbaccess/source/ui/inc/directsql.hxx index 03e31bb7e2ec..545d23dd79ad 100644 --- a/dbaccess/source/ui/inc/directsql.hxx +++ b/dbaccess/source/ui/inc/directsql.hxx @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -34,41 +35,56 @@ #include #include -#include +#include 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 ModalDialog - ,public ::utl::OEventListenerAdapter + : public weld::GenericDialogController + , public ::utl::OEventListenerAdapter { ::osl::Mutex m_aMutex; - VclPtr m_pSQL; - VclPtr m_pExecute; - VclPtr m_pSQLHistory; - VclPtr m_pStatus; - VclPtr m_pShowOutput; - VclPtr m_pOutput; - VclPtr m_pClose; + std::unique_ptr m_xExecute; + std::unique_ptr m_xSQLHistory; + std::unique_ptr m_xStatus; + std::unique_ptr m_xShowOutput; + std::unique_ptr m_xOutput; + std::unique_ptr m_xClose; + std::unique_ptr m_xSQL; + std::unique_ptr 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; + ImplSVEvent* m_pClosingEvent; + public: DirectSQLDialog( - vcl::Window* _pParent, + weld::Window* _pParent, const css::uno::Reference< css::sdbc::XConnection >& _rxConn); virtual ~DirectSQLDialog() override; - virtual void dispose() override; /// number of history entries sal_Int32 getHistorySize() const; @@ -77,14 +93,19 @@ 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; - DECL_LINK( OnExecute, Button*, void ); + DECL_LINK( OnExecute, weld::Button&, void ); DECL_LINK( OnClose, void*, void ); - DECL_LINK( OnCloseClick, Button*, void ); - DECL_LINK( OnListEntrySelected, ListBox&, void ); - DECL_LINK( OnStatementModified, Edit&, void ); + 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/uno/unoDirectSql.cxx b/dbaccess/source/ui/uno/unoDirectSql.cxx index c696bb26e442..f3af4f40640e 100644 --- a/dbaccess/source/ui/uno/unoDirectSql.cxx +++ b/dbaccess/source/ui/uno/unoDirectSql.cxx @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -83,13 +82,13 @@ namespace dbaui { // obtain all the objects needed for the dialog Reference< XConnection > xConnection = m_xActiveConnection; - auto _pParent = VCLUnoHelper::GetWindow(rParent); + weld::Window* pParent = Application::GetFrameWeld(rParent); if ( !xConnection.is() ) { try { // the connection the row set is working with - ODatasourceConnector aDSConnector(m_aContext, Application::GetFrameWeld(rParent)); + ODatasourceConnector aDSConnector(m_aContext, pParent); xConnection = aDSConnector.connect( m_sInitialSelection, nullptr ); } catch( const Exception& ) @@ -103,7 +102,7 @@ namespace dbaui return svt::OGenericUnoDialog::Dialog(); } - return svt::OGenericUnoDialog::Dialog(VclPtr::Create(_pParent, xConnection)); + return svt::OGenericUnoDialog::Dialog(std::make_unique(pParent, xConnection)); } void ODirectSQLDialog::implInitialize(const Any& _rValue) diff --git a/dbaccess/uiconfig/ui/directsqldialog.ui b/dbaccess/uiconfig/ui/directsqldialog.ui index 0b98f6f0af82..0947f539d357 100644 --- a/dbaccess/uiconfig/ui/directsqldialog.ui +++ b/dbaccess/uiconfig/ui/directsqldialog.ui @@ -1,14 +1,16 @@ - + - False 6 Execute SQL Statement False dialog + + + False @@ -61,23 +63,46 @@ True False + True + True 0 none True False + True + True 6 12 True False + True + True 6 - + True True + True + True + 0 + in + + + True + False + + + True + True + 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 + + + + 0 @@ -88,10 +113,10 @@ True False - 0 _Command to execute: True - sql:border + sql + 0 0 @@ -143,7 +168,6 @@ True False - 60 0 @@ -154,10 +178,10 @@ True False - 0 _Previous commands: True sqlhistory + 0 0 @@ -203,7 +227,7 @@ True in - + True True False @@ -248,7 +272,7 @@ True in - + True True False diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 872ea92c39f1..59c631ecbe1b 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -107,9 +107,6 @@ - diff --git a/include/svtools/editsyntaxhighlighter.hxx b/include/svtools/editsyntaxhighlighter.hxx index ee45651b3f86..a3e94fe96d8b 100644 --- a/include/svtools/editsyntaxhighlighter.hxx +++ b/include/svtools/editsyntaxhighlighter.hxx @@ -45,6 +45,8 @@ class SVT_DLLPUBLIC MultiLineEditSyntaxHighlight : public MultiLineEdit virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override { SetText( rStr ); SetSelection( rNewSelection ); } + static Color GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken); + Color GetColorValue(TokenType aToken); }; diff --git a/include/svx/ClassificationEditView.hxx b/include/svx/ClassificationEditView.hxx index 95e635322a15..5f9fef03a0ec 100644 --- a/include/svx/ClassificationEditView.hxx +++ b/include/svx/ClassificationEditView.hxx @@ -52,11 +52,6 @@ public: { return *m_xEditView.get(); } - - void SetModifyHdl(const Link& rLink) - { - m_xEditEngine->SetModifyHdl(rLink); - } }; } // end svx namespace diff --git a/include/svx/weldeditview.hxx b/include/svx/weldeditview.hxx index f5e0183d194d..1b77491421a2 100644 --- a/include/svx/weldeditview.hxx +++ b/include/svx/weldeditview.hxx @@ -25,6 +25,18 @@ class SVX_DLLPUBLIC WeldEditView : public weld::CustomWidgetController, public E public: WeldEditView(); virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + + void SetText(const OUString& rStr) { m_xEditEngine->SetText(rStr); } + + OUString GetText() const { return m_xEditEngine->GetText(); } + + void SetModifyHdl(const Link& rLink) + { + m_xEditEngine->SetModifyHdl(rLink); + } + + EditEngine& GetEditEngine() { return *m_xEditEngine; } + virtual ~WeldEditView() override; protected: diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 3e2edaa26462..61a609dcb84f 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -476,7 +476,6 @@ custom_widgets = [ 'IndexBox', 'IndexBox', 'ManagedMenuButton', - 'MultiLineEditSyntaxHighlight', 'OptionalBox', 'PageNumberListBox', 'PaperSizeListBox', diff --git a/svtools/source/edit/editsyntaxhighlighter.cxx b/svtools/source/edit/editsyntaxhighlighter.cxx index f189cec85609..532fc67503f9 100644 --- a/svtools/source/edit/editsyntaxhighlighter.cxx +++ b/svtools/source/edit/editsyntaxhighlighter.cxx @@ -33,8 +33,6 @@ MultiLineEditSyntaxHighlight::MultiLineEditSyntaxHighlight( vcl::Window* pParent EnableUpdateData(300); } -VCL_BUILDER_FACTORY(MultiLineEditSyntaxHighlight) - void MultiLineEditSyntaxHighlight::SetText(const OUString& rNewText) { MultiLineEdit::SetText(rNewText); @@ -117,22 +115,22 @@ bool MultiLineEditSyntaxHighlight::PreNotify( NotifyEvent& rNEvt ) return MultiLineEdit::PreNotify(rNEvt); } -Color MultiLineEditSyntaxHighlight::GetColorValue(TokenType aToken) +Color MultiLineEditSyntaxHighlight::GetSyntaxHighlightColor(const svtools::ColorConfig& rColorConfig, HighlighterLanguage eLanguage, TokenType aToken) { Color aColor; - switch (aHighlighter.GetLanguage()) + switch (eLanguage) { case HighlighterLanguage::SQL: { switch (aToken) { - case TokenType::Identifier: aColor = m_aColorConfig.GetColorValue(svtools::SQLIDENTIFIER).nColor; break; - case TokenType::Number: aColor = m_aColorConfig.GetColorValue(svtools::SQLNUMBER).nColor; break; - case TokenType::String: aColor = m_aColorConfig.GetColorValue(svtools::SQLSTRING).nColor; break; - case TokenType::Operator: aColor = m_aColorConfig.GetColorValue(svtools::SQLOPERATOR).nColor; break; - case TokenType::Keywords: aColor = m_aColorConfig.GetColorValue(svtools::SQLKEYWORD).nColor; break; - case TokenType::Parameter: aColor = m_aColorConfig.GetColorValue(svtools::SQLPARAMETER).nColor; break; - case TokenType::Comment: aColor = m_aColorConfig.GetColorValue(svtools::SQLCOMMENT).nColor; break; + case TokenType::Identifier: aColor = rColorConfig.GetColorValue(svtools::SQLIDENTIFIER).nColor; break; + case TokenType::Number: aColor = rColorConfig.GetColorValue(svtools::SQLNUMBER).nColor; break; + case TokenType::String: aColor = rColorConfig.GetColorValue(svtools::SQLSTRING).nColor; break; + case TokenType::Operator: aColor = rColorConfig.GetColorValue(svtools::SQLOPERATOR).nColor; break; + case TokenType::Keywords: aColor = rColorConfig.GetColorValue(svtools::SQLKEYWORD).nColor; break; + case TokenType::Parameter: aColor = rColorConfig.GetColorValue(svtools::SQLPARAMETER).nColor; break; + case TokenType::Comment: aColor = rColorConfig.GetColorValue(svtools::SQLCOMMENT).nColor; break; default: aColor = Color(0,0,0); } break; @@ -158,6 +156,11 @@ Color MultiLineEditSyntaxHighlight::GetColorValue(TokenType aToken) return aColor; } +Color MultiLineEditSyntaxHighlight::GetColorValue(TokenType aToken) +{ + return GetSyntaxHighlightColor(m_aColorConfig, aHighlighter.GetLanguage(), aToken); +} + void MultiLineEditSyntaxHighlight::UpdateData() { // syntax highlighting diff --git a/svx/source/dialog/weldeditview.cxx b/svx/source/dialog/weldeditview.cxx index 1f6e0332cfe5..da5ac91bc4a2 100644 --- a/svx/source/dialog/weldeditview.cxx +++ b/svx/source/dialog/weldeditview.cxx @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -44,9 +46,31 @@ WeldEditView::WeldEditView() {} +// tdf#127033 want to use UI font so override makeEditEngine to enable that void WeldEditView::makeEditEngine() { - m_xEditEngine.reset(new EditEngine(EditEngine::CreatePool())); + SfxItemPool* pItemPool = EditEngine::CreatePool(); + + vcl::Font aAppFont(Application::GetSettings().GetStyleSettings().GetAppFont()); + + 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)); + + m_xEditEngine.reset(new EditEngine(pItemPool)); } void WeldEditView::Resize() @@ -126,6 +150,20 @@ bool WeldEditView::KeyInput(const KeyEvent& rKEvt) } else if (!m_xEditView->PostKeyEvent(rKEvt)) { + if (rKEvt.GetKeyCode().IsMod1() && !rKEvt.GetKeyCode().IsMod2()) + { + if (nKey == KEY_A) + { + sal_Int32 nPar = m_xEditEngine->GetParagraphCount(); + if (nPar) + { + sal_Int32 nLen = m_xEditEngine->GetTextLen(nPar - 1); + m_xEditView->SetSelection(ESelection(0, 0, nPar - 1, nLen)); + } + return true; + } + } + return false; } -- cgit