diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-09-15 20:18:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-09-17 10:04:38 +0200 |
commit | 573562e72a5fd85b75006fbc8869c73903a6e504 (patch) | |
tree | 866cfff40b7974ab4a9541214a93c104c10f593b | |
parent | a944d4c2aacafdac78eabd7fb0f8909a66d935eb (diff) |
weld DirectSQLDialog
Change-Id: I8f97068bb38a1fb888d60251f8f25506044c8451
Reviewed-on: https://gerrit.libreoffice.org/78970
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/SpellDialog.cxx | 20 | ||||
-rw-r--r-- | cui/source/inc/SpellDialog.hxx | 1 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/directsql.cxx | 284 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/directsql.hxx | 53 | ||||
-rw-r--r-- | dbaccess/source/ui/uno/unoDirectSql.cxx | 7 | ||||
-rw-r--r-- | dbaccess/uiconfig/ui/directsqldialog.ui | 42 | ||||
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 3 | ||||
-rw-r--r-- | include/svtools/editsyntaxhighlighter.hxx | 2 | ||||
-rw-r--r-- | include/svx/ClassificationEditView.hxx | 5 | ||||
-rw-r--r-- | include/svx/weldeditview.hxx | 12 | ||||
-rwxr-xr-x | solenv/bin/native-code.py | 1 | ||||
-rw-r--r-- | svtools/source/edit/editsyntaxhighlighter.cxx | 25 | ||||
-rw-r--r-- | 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 <unotools/lingucfg.hxx> #include <editeng/colritem.hxx> #include <editeng/eeitem.hxx> -#include <editeng/fhgtitem.hxx> -#include <editeng/fontitem.hxx> #include <editeng/langitem.hxx> #include <editeng/splwrap.hxx> #include <editeng/unolingu.hxx> @@ -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 <directsql.hxx> #include <dbu_dlg.hxx> #include <strings.hrc> -#include <vcl/weld.hxx> #include <comphelper/types.hxx> -#include <vcl/svapp.hxx> +#include <editeng/colritem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/eeitem.hxx> #include <osl/mutex.hxx> +#include <svl/itemset.hxx> #include <tools/diagnose_ex.h> #include <rtl/strbuf.hxx> +#include <vcl/event.hxx> +#include <vcl/svapp.hxx> +#include <vcl/weld.hxx> #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XMultipleResults.hpp> 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<weld::MessageDialog> xError(Application::CreateMessageDialog(GetFrameWeld(), + std::unique_ptr<weld::MessageDialog> 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<size_t>(m_pSQLHistory->GetEntryCount())) + if (m_aStatementHistory.size() != static_cast<size_t>(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<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 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 <sal/log.hxx> #include <vcl/dialog.hxx> +#include <vcl/weld.hxx> #include <svtools/editsyntaxhighlighter.hxx> #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> @@ -34,41 +35,56 @@ #include <unotools/eventlisteneradapter.hxx> #include <osl/mutex.hxx> -#include <svtools/editbrowsebox.hxx> +#include <svx/weldeditview.hxx> 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<MultiLineEditSyntaxHighlight> m_pSQL; - VclPtr<PushButton> m_pExecute; - VclPtr<ListBox> m_pSQLHistory; - VclPtr<VclMultiLineEdit> m_pStatus; - VclPtr<CheckBox> m_pShowOutput; - VclPtr<VclMultiLineEdit> m_pOutput; - VclPtr<PushButton> m_pClose; + std::unique_ptr<weld::Button> m_xExecute; + std::unique_ptr<weld::ComboBox> m_xSQLHistory; + std::unique_ptr<weld::TextView> m_xStatus; + std::unique_ptr<weld::CheckButton> m_xShowOutput; + std::unique_ptr<weld::TextView> m_xOutput; + std::unique_ptr<weld::Button> m_xClose; + 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; + 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 <directsql.hxx> #include <stringconstants.hxx> #include <datasourceconnector.hxx> -#include <toolkit/helper/vclunohelper.hxx> #include <tools/diagnose_ex.h> #include <comphelper/processfactory.hxx> #include <vcl/svapp.hxx> @@ -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<DirectSQLDialog>::Create(_pParent, xConnection)); + return svt::OGenericUnoDialog::Dialog(std::make_unique<DirectSQLDialog>(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 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="dba"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkDialog" id="DirectSQLDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="directsqldialog|DirectSQLDialog">Execute SQL Statement</property> <property name="resizable">False</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -61,23 +63,46 @@ <object class="GtkFrame" id="frame1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="label_xalign">0</property> <property name="shadow_type">none</property> <child> <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="top_padding">6</property> <property name="left_padding">12</property> <child> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="row_spacing">6</property> <child> - <object class="svtlo-MultiLineEditSyntaxHighlight" id="sql:border"> + <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="left_attach">0</property> @@ -88,10 +113,10 @@ <object class="GtkLabel" id="sql_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="directsqldialog|sql_label">_Command to execute:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">sql:border</property> + <property name="mnemonic_widget">sql</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -143,7 +168,6 @@ <object class="GtkComboBoxText" id="sqlhistory"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="max_width_chars">60</property> </object> <packing> <property name="left_attach">0</property> @@ -154,10 +178,10 @@ <object class="GtkLabel" id="sqlhistory_label"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="directsqldialog|sqlhistory_label">_Previous commands:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">sqlhistory</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -203,7 +227,7 @@ <property name="can_focus">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkTextView" id="status:border"> + <object class="GtkTextView" id="status"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">False</property> @@ -248,7 +272,7 @@ <property name="can_focus">True</property> <property name="shadow_type">in</property> <child> - <object class="GtkTextView" id="output:border"> + <object class="GtkTextView" id="output"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">False</property> 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 @@ <glade-widget-class title="Svx 3D Preview Control" name="svxlo-Svx3DPreviewControl" generic-name="3D Preview Control" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="MultiLine Edit" name="svtlo-MultiLineEditSyntaxHighlight" - generic-name="MultiLineEdit" parent="GtkTextView" - icon-name="widget-gtk-textview"/> <glade-widget-class title="SvtValueSet" name="svtlo-ValueSet" generic-name="Set of Value Options" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> 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<LinkParamNone*,void>& 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<LinkParamNone*, void>& 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 <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <editeng/eeitem.hxx> +#include <editeng/fhgtitem.hxx> +#include <editeng/fontitem.hxx> #include <editeng/outliner.hxx> #include <editeng/unoedhlp.hxx> #include <editeng/unoedsrc.hxx> @@ -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; } |