diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-11 13:02:57 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-13 16:16:24 +0200 |
commit | 226fcda0a888c4959b1f895de31856f1624f04ee (patch) | |
tree | 6c13e9ff0231f9f3fc744884937e3849b641773e | |
parent | b2e5f9ead2bb7f2979afe4ba13e3950e8a3cc278 (diff) |
weld ConditionalFormattingDialog
Change-Id: I87c03555c5555b12a1be997e368a96d9b07d2b63
Reviewed-on: https://gerrit.libreoffice.org/80689
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 12 | ||||
-rw-r--r-- | include/svx/colorwindow.hxx | 21 | ||||
-rw-r--r-- | include/svx/fntctrl.hxx | 6 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 9 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/AddField.cxx | 10 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/CondFormat.cxx | 228 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.cxx | 295 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.hxx | 116 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/AddField.hxx | 6 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/CondFormat.hxx | 40 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/GroupsSorting.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/misc/UITools.cxx | 3 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 4 | ||||
-rw-r--r-- | reportdesign/uiconfig/dbreport/ui/condformatdialog.ui | 10 | ||||
-rw-r--r-- | reportdesign/uiconfig/dbreport/ui/conditionwin.ui | 82 | ||||
-rwxr-xr-x | solenv/bin/native-code.py | 1 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 59 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 59 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 79 |
19 files changed, 489 insertions, 553 deletions
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 90f30ba68ea6..c915344ed631 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -86,18 +86,6 @@ </properties> </glade-widget-class> - <glade-widget-class title="Font Preview" name="svxlo-SvxFontPrevWindow" - generic-name="Font Preview Window" parent="GtkDrawingArea" - icon-name="widget-gtk-drawingarea"> - <properties> - <property id="text" name="Label"> - <parameter-spec> - <type>GParamString</type> - </parameter-spec> - </property> - </properties> - </glade-widget-class> - <glade-widget-class title="Document Preview Window" name="sdlo-SdDocPreviewWin" generic-name="Document Preview Window" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> diff --git a/include/svx/colorwindow.hxx b/include/svx/colorwindow.hxx index 183a29d231ba..4656f3d37af7 100644 --- a/include/svx/colorwindow.hxx +++ b/include/svx/colorwindow.hxx @@ -110,6 +110,23 @@ public: void SetSelectedHdl( const Link<const NamedColor&, void>& rLink ) { maSelectedLink = rLink; } }; +class SVX_DLLPUBLIC MenuOrToolMenuButton +{ +private: + // either + weld::MenuButton* m_pMenuButton; + // or + weld::Toolbar* m_pToolbar; + OString m_aIdent; +public: + MenuOrToolMenuButton(weld::MenuButton* pMenuButton); + MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OString& rIdent); + + bool get_active() const; + void set_active(bool bActive) const; + weld::Widget* get_widget() const; +}; + class SVX_DLLPUBLIC ColorWindow : public svtools::ToolbarPopupBase { private: @@ -117,7 +134,7 @@ private: const sal_uInt16 theSlotId; weld::Window* const mpParentWindow; - weld::MenuButton* mpMenuButton; + MenuOrToolMenuButton maMenuButton; std::shared_ptr<PaletteManager> mxPaletteManager; ColorStatus& mrColorStatus; ColorSelectFunction const maColorSelectFunction; @@ -148,7 +165,7 @@ public: ColorStatus& rColorStatus, sal_uInt16 nSlotId, const css::uno::Reference< css::frame::XFrame >& rFrame, - weld::Window* pParentWindow, weld::MenuButton* pMenuButton, + weld::Window* pParentWindow, const MenuOrToolMenuButton &rMenuButton, bool bInterimBuilder, ColorSelectFunction const& rColorSelectFunction); weld::Container* GetWidget() { return mxTopLevel.get(); } diff --git a/include/svx/fntctrl.hxx b/include/svx/fntctrl.hxx index d07d60edb62f..5332c98ed52e 100644 --- a/include/svx/fntctrl.hxx +++ b/include/svx/fntctrl.hxx @@ -20,12 +20,10 @@ #define INCLUDED_SVX_FNTCTRL_HXX #include <memory> -#include <vcl/customweld.hxx> -#include <vcl/window.hxx> #include <editeng/svxfont.hxx> -#include <svx/svxdllapi.h> - #include <rtl/ustring.hxx> +#include <svx/svxdllapi.h> +#include <vcl/customweld.hxx> class SfxItemSet; class FontPrevWin_Impl; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 33dadea0cc03..c85b86d7a8c7 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -266,6 +266,13 @@ public: virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() = 0; }; +class VCL_DLLPUBLIC Box : virtual public Container +{ +public: + // Moves child to a new position in the list of children + virtual void reorder_child(weld::Widget* pWidget, int position) = 0; +}; + class VCL_DLLPUBLIC ScrolledWindow : virtual public Container { protected: @@ -1830,6 +1837,7 @@ public: virtual bool get_item_sensitive(const OString& rIdent) const = 0; virtual void set_item_active(const OString& rIdent, bool bActive) = 0; virtual bool get_item_active(const OString& rIdent) const = 0; + virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) = 0; virtual void insert_separator(int pos, const OUString& rId) = 0; void append_separator(const OUString& rId) { insert_separator(-1, rId); } @@ -1873,6 +1881,7 @@ public: virtual std::unique_ptr<Container> weld_container(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Box> weld_box(const OString& id, bool bTakeOwnership = false) = 0; virtual std::unique_ptr<Button> weld_button(const OString& id, bool bTakeOwnership = false) = 0; virtual std::unique_ptr<MenuButton> weld_menu_button(const OString& id, bool bTakeOwnership = false) diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx index 5a56839f1ef9..6c7728ebc54d 100644 --- a/reportdesign/source/ui/dlg/AddField.cxx +++ b/reportdesign/source/ui/dlg/AddField.cxx @@ -172,7 +172,6 @@ OAddFieldWindow::OAddFieldWindow(vcl::Window* pParent ,const uno::Reference< bea m_aActions->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) ); m_aActions->SetSelectHdl(LINK(this, OAddFieldWindow, OnSortAction)); - setToolBox(m_aActions.get()); m_aActions->CheckItem(m_nSortUpId); m_aActions->EnableItem(m_nInsertId, false); @@ -450,15 +449,6 @@ IMPL_LINK_NOARG( OAddFieldWindow, OnDoubleClickHdl, SvTreeListBox*, bool ) return false; } -void OAddFieldWindow::resizeControls(const Size& _rDiff) -{ - // we use large images so we must change them - if ( _rDiff.Width() || _rDiff.Height() ) - { - Invalidate(); - } -} - IMPL_LINK_NOARG( OAddFieldWindow, OnSortAction, ToolBox*, void ) { const sal_uInt16 nCurItem = m_aActions->GetCurItemId(); diff --git a/reportdesign/source/ui/dlg/CondFormat.cxx b/reportdesign/source/ui/dlg/CondFormat.cxx index 0fa1180884ba..bb5df9b50c73 100644 --- a/reportdesign/source/ui/dlg/CondFormat.cxx +++ b/reportdesign/source/ui/dlg/CondFormat.cxx @@ -58,25 +58,6 @@ namespace rptui using namespace ::com::sun::star::report; - - // UpdateLocker - - class UpdateLocker - { - vcl::Window& m_rWindow; - - public: - explicit UpdateLocker( vcl::Window& _rWindow ) - :m_rWindow( _rWindow ) - { - _rWindow.SetUpdateMode( false ); - } - ~UpdateLocker() - { - m_rWindow.SetUpdateMode( true ); - } - }; - void ConditionalFormattingDialog::impl_setPrefHeight(bool bFirst) { if (!m_bConstructed && !bFirst) @@ -86,37 +67,35 @@ namespace rptui size_t nCount = impl_getConditionCount(); if (nCount) { - long nHeight = m_aConditions[0]->get_preferred_size().Height(); + auto nHeight = m_aConditions[0]->get_preferred_size().Height(); size_t nVisibleConditions = ::std::min(nCount, MAX_CONDITIONS); nHeight *= nVisibleConditions; - if (nHeight != m_pScrollWindow->get_height_request()) + nHeight += 2; + if (nHeight != m_xScrollWindow->get_size_request().Height()) { - m_pScrollWindow->set_height_request(nHeight); - if (!isCalculatingInitialLayoutSize() && !bFirst) - setOptimalLayoutSize(); + m_xScrollWindow->set_size_request(-1, nHeight); + if (!bFirst) + m_xDialog->resize_to_request(); } } } // class ConditionalFormattingDialog ConditionalFormattingDialog::ConditionalFormattingDialog( - vcl::Window* _pParent, const Reference< XReportControlModel >& _rxFormatConditions, ::rptui::OReportController& _rController ) - :ModalDialog( _pParent, "CondFormat", "modules/dbreport/ui/condformatdialog.ui" ) - ,m_rController( _rController ) - ,m_xFormatConditions( _rxFormatConditions ) - ,m_bDeletingCondition( false ) - ,m_bConstructed( false ) + weld::Window* _pParent, const Reference< XReportControlModel >& _rxFormatConditions, ::rptui::OReportController& _rController) + : GenericDialogController(_pParent, "modules/dbreport/ui/condformatdialog.ui", "CondFormat") + , m_rController(_rController) + , m_xFormatConditions(_rxFormatConditions) + , m_bDeletingCondition(false) + , m_bConstructed(false) + , m_xScrollWindow(m_xBuilder->weld_scrolled_window("scrolledwindow")) + , m_xConditionPlayground(m_xBuilder->weld_box("condPlaygroundDrawingarea")) { - get(m_pConditionPlayground, "condPlaygroundDrawingarea"); - get(m_pScrollWindow, "scrolledwindow"); - m_pScrollWindow->setUserManagedScrolling(true); - m_pCondScroll = &(m_pScrollWindow->getVertScrollBar()); - OSL_ENSURE( m_xFormatConditions.is(), "ConditionalFormattingDialog::ConditionalFormattingDialog: ReportControlModel is NULL -> Prepare for GPF!" ); m_xCopy.set( m_xFormatConditions->createClone(), UNO_QUERY_THROW ); - m_pCondScroll->SetScrollHdl( LINK( this, ConditionalFormattingDialog, OnScroll ) ); + m_xScrollWindow->connect_vadjustment_changed(LINK(this, ConditionalFormattingDialog, OnScroll)); impl_initializeConditions(); @@ -127,22 +106,6 @@ namespace rptui ConditionalFormattingDialog::~ConditionalFormattingDialog() { - disposeOnce(); - } - - void ConditionalFormattingDialog::dispose() - { - - for (auto& rxCondition : m_aConditions) - { - rxCondition.disposeAndClear(); - } - - m_aConditions.clear(); - m_pConditionPlayground.clear(); - m_pScrollWindow.clear(); - m_pCondScroll.clear(); - ModalDialog::dispose(); } void ConditionalFormattingDialog::impl_updateConditionIndicies() @@ -151,6 +114,7 @@ namespace rptui for (const auto& rxCondition : m_aConditions) { rxCondition->setConditionIndex( nIndex, impl_getConditionCount() ); + m_xConditionPlayground->reorder_child(rxCondition->get_widget(), nIndex); ++nIndex; } } @@ -162,7 +126,6 @@ namespace rptui impl_setPrefHeight(false); - impl_updateScrollBarRange(); impl_updateConditionIndicies(); impl_layoutAll(); } @@ -182,8 +145,6 @@ namespace rptui void ConditionalFormattingDialog::impl_addCondition_nothrow( size_t _nNewCondIndex ) { - UpdateLocker aLockUpdates( *this ); - try { if ( _nNewCondIndex > static_cast<size_t>(m_xCopy->getCount()) ) @@ -192,10 +153,10 @@ namespace rptui Reference< XFormatCondition > xCond = m_xCopy->createFormatCondition(); ::comphelper::copyProperties(m_xCopy.get(),xCond.get()); m_xCopy->insertByIndex( _nNewCondIndex, makeAny( xCond ) ); - VclPtrInstance<Condition> pCon( m_pConditionPlayground, *this, m_rController ); - pCon->setCondition( xCond ); - pCon->reorderWithinParent(_nNewCondIndex); - m_aConditions.insert( m_aConditions.begin() + _nNewCondIndex, pCon ); + auto xCon = std::make_unique<Condition>(m_xConditionPlayground.get(), m_xDialog.get(), *this, m_rController); + xCon->setCondition(xCond); + m_xConditionPlayground->reorder_child(xCon->get_widget(), _nNewCondIndex); + m_aConditions.insert(m_aConditions.begin() + _nNewCondIndex, std::move(xCon)); } catch( const Exception& ) { @@ -207,21 +168,17 @@ namespace rptui impl_ensureConditionVisible( _nNewCondIndex ); } - void ConditionalFormattingDialog::impl_focusCondition( size_t _nCondIndex ) { OSL_PRECOND( _nCondIndex < impl_getConditionCount(), "ConditionalFormattingDialog::impl_focusCondition: illegal index!" ); impl_ensureConditionVisible( _nCondIndex ); - m_aConditions[ _nCondIndex ]->GrabFocus(); + m_aConditions[ _nCondIndex ]->grab_focus(); } - void ConditionalFormattingDialog::impl_deleteCondition_nothrow( size_t _nCondIndex ) { - UpdateLocker aLockUpdates( *this ); - OSL_PRECOND( _nCondIndex < impl_getConditionCount(), "ConditionalFormattingDialog::impl_deleteCondition_nothrow: illegal index!" ); @@ -243,9 +200,13 @@ namespace rptui } else { - bSetNewFocus = (*pos)->HasChildPathFocus(); + bSetNewFocus = (*pos)->has_focus(); m_bDeletingCondition = true; - m_aConditions.erase( pos ); + + auto xMovedCondition = std::move(*pos); + m_aConditions.erase(pos); + m_xConditionPlayground->move(xMovedCondition->get_widget(), nullptr); + m_bDeletingCondition = false; } @@ -273,14 +234,14 @@ namespace rptui // do this in two steps, so we don't become inconsistent if any of the UNO actions fails Any aMovedCondition; - Condition *pMovedCondition; + std::unique_ptr<Condition> xMovedCondition; try { aMovedCondition = m_xCopy->getByIndex( static_cast<sal_Int32>(nOldConditionIndex) ); m_xCopy->removeByIndex( static_cast<sal_Int32>(nOldConditionIndex) ); Conditions::iterator aRemovePos( m_aConditions.begin() + nOldConditionIndex ); - pMovedCondition = aRemovePos->get(); + xMovedCondition = std::move(*aRemovePos); m_aConditions.erase( aRemovePos ); } catch( const Exception& ) @@ -292,7 +253,7 @@ namespace rptui try { m_xCopy->insertByIndex( static_cast<sal_Int32>(nNewConditionIndex), aMovedCondition ); - m_aConditions.insert( m_aConditions.begin() + nNewConditionIndex, pMovedCondition ); + m_aConditions.insert(m_aConditions.begin() + nNewConditionIndex, std::move(xMovedCondition)); } catch( const Exception& ) { @@ -302,44 +263,27 @@ namespace rptui // at least the two swapped conditions need to know their new index impl_updateConditionIndicies(); - // re-layout all conditions - impl_layoutConditions(); - // ensure the moved condition is visible impl_ensureConditionVisible( nNewConditionIndex ); } - IMPL_LINK( ConditionalFormattingDialog, OnScroll, ScrollBar*, /*_pNotInterestedIn*/, void ) + IMPL_LINK_NOARG(ConditionalFormattingDialog, OnScroll, weld::ScrolledWindow&, void) { size_t nFirstCondIndex( impl_getFirstVisibleConditionIndex() ); size_t nFocusCondIndex = impl_getFocusedConditionIndex( nFirstCondIndex ); - impl_layoutConditions(); - if ( nFocusCondIndex < nFirstCondIndex ) impl_focusCondition( nFirstCondIndex ); else if ( nFocusCondIndex >= nFirstCondIndex + MAX_CONDITIONS ) impl_focusCondition( nFirstCondIndex + MAX_CONDITIONS - 1 ); } - void ConditionalFormattingDialog::impl_layoutConditions() - { - if (m_aConditions.empty()) - return; - long nConditionHeight = m_aConditions[0]->get_preferred_size().Height(); - Point aConditionPos(0, -1 * nConditionHeight * impl_getFirstVisibleConditionIndex()); - m_pConditionPlayground->SetPosPixel(aConditionPos); - } - void ConditionalFormattingDialog::impl_layoutAll() { - // condition's positions - impl_layoutConditions(); - // scrollbar visibility if ( m_aConditions.size() <= MAX_CONDITIONS ) // normalize the position, so it can, in all situations, be used as top index - m_pCondScroll->SetThumbPos( 0 ); + m_xScrollWindow->vadjustment_set_value(0); } void ConditionalFormattingDialog::impl_initializeConditions() @@ -349,12 +293,12 @@ namespace rptui sal_Int32 nCount = m_xCopy->getCount(); for ( sal_Int32 i = 0; i < nCount ; ++i ) { - VclPtrInstance<Condition> pCon( m_pConditionPlayground, *this, m_rController ); + auto xCon = std::make_unique<Condition>(m_xConditionPlayground.get(), m_xDialog.get(), *this, m_rController); Reference< XFormatCondition > xCond( m_xCopy->getByIndex(i), UNO_QUERY ); - pCon->reorderWithinParent(i); - pCon->setCondition( xCond ); - pCon->updateToolbar( xCond.get() ); - m_aConditions.push_back( pCon ); + m_xConditionPlayground->reorder_child(xCon->get_widget(), i); + xCon->setCondition(xCond); + xCon->updateToolbar(xCond.get()); + m_aConditions.push_back(std::move(xCon)); } } catch(Exception&) @@ -378,7 +322,7 @@ namespace rptui aArgs[0].Value <<= xReportControlFormat; aArgs[1].Name = CURRENT_WINDOW; - aArgs[1].Value <<= VCLUnoHelper::GetInterface(this); + aArgs[1].Value <<= m_xDialog->GetXWindow(); aArgs[2].Name = PROPERTY_FONTCOLOR; aArgs[2].Value <<= rColor; @@ -409,7 +353,6 @@ namespace rptui impl_moveCondition_nothrow( _nCondIndex, false ); } - OUString ConditionalFormattingDialog::getDataField() const { OUString sDataField; @@ -424,11 +367,10 @@ namespace rptui return sDataField; } - - short ConditionalFormattingDialog::Execute() + short ConditionalFormattingDialog::run() { - short nRet = ModalDialog::Execute(); - if ( nRet == RET_OK ) + short nRet = GenericDialogController::run(); + if (nRet == RET_OK) { const OUString sUndoAction( RptResId( RID_STR_UNDO_CONDITIONAL_FORMATTING ) ); const UndoContext aUndoContext( m_rController.getUndoManager(), sUndoAction ); @@ -474,105 +416,35 @@ namespace rptui return nRet; } - - bool ConditionalFormattingDialog::PreNotify( NotifyEvent& _rNEvt ) - { - switch ( _rNEvt.GetType() ) - { - case MouseNotifyEvent::KEYINPUT: - { - const KeyEvent* pKeyEvent( _rNEvt.GetKeyEvent() ); - const vcl::KeyCode& rKeyCode = pKeyEvent->GetKeyCode(); - if ( rKeyCode.IsMod1() && rKeyCode.IsMod2() ) - { - if ( rKeyCode.GetCode() == 0x0508 ) - { - impl_deleteCondition_nothrow( impl_getFocusedConditionIndex( 0 ) ); - return true; - } - if ( rKeyCode.GetCode() == 0x0507 ) // + - { - impl_addCondition_nothrow( impl_getFocusedConditionIndex( impl_getConditionCount() - 1 ) + 1 ); - return true; - } - } - break; - } - case MouseNotifyEvent::GETFOCUS: - { - if (m_bDeletingCondition) - break; - - if (!m_pConditionPlayground) //e.g. during dispose - break; - - const vcl::Window* pGetFocusWindow( _rNEvt.GetWindow() ); - - // determine whether the new focus window is part of an (currently invisible) condition - const vcl::Window* pConditionCandidate = pGetFocusWindow->GetParent(); - const vcl::Window* pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : nullptr; - while ( pPlaygroundCandidate - && ( pPlaygroundCandidate != this ) - && ( pPlaygroundCandidate != m_pConditionPlayground ) - ) - { - pConditionCandidate = pConditionCandidate->GetParent(); - pPlaygroundCandidate = pConditionCandidate ? pConditionCandidate->GetParent() : nullptr; - } - if (pConditionCandidate && pPlaygroundCandidate == m_pConditionPlayground) - { - impl_ensureConditionVisible( dynamic_cast< const Condition& >( *pConditionCandidate ).getConditionIndex() ); - } - break; - } - default: - break; - } - - return ModalDialog::PreNotify( _rNEvt ); - } - - size_t ConditionalFormattingDialog::impl_getFirstVisibleConditionIndex() const { - return static_cast<size_t>(m_pCondScroll->GetThumbPos()); + auto nHeight = m_aConditions[0]->get_preferred_size().Height(); + return m_xScrollWindow->vadjustment_get_value() / nHeight; } - size_t ConditionalFormattingDialog::impl_getLastVisibleConditionIndex() const { return ::std::min( impl_getFirstVisibleConditionIndex() + MAX_CONDITIONS, impl_getConditionCount() ) - 1; } - size_t ConditionalFormattingDialog::impl_getFocusedConditionIndex( sal_Int32 _nFallBackIfNone ) const { auto cond = std::find_if(m_aConditions.begin(), m_aConditions.end(), - [](const VclPtr<Condition>& rxCondition) { return rxCondition->HasChildPathFocus(); }); + [](const std::unique_ptr<Condition>& rxCondition) { return rxCondition->has_focus(); }); if (cond != m_aConditions.end()) return static_cast<size_t>(std::distance(m_aConditions.begin(), cond)); return _nFallBackIfNone; } - - void ConditionalFormattingDialog::impl_updateScrollBarRange() - { - long nMax = ( impl_getConditionCount() > MAX_CONDITIONS ) ? impl_getConditionCount() - MAX_CONDITIONS + 1 : 0; - - m_pCondScroll->SetRangeMin( 0 ); - m_pCondScroll->SetRangeMax( nMax ); - m_pCondScroll->SetVisibleSize( 1 ); - } - - - void ConditionalFormattingDialog::impl_scrollTo( size_t _nTopCondIndex ) + void ConditionalFormattingDialog::impl_scrollTo( size_t nTopCondIndex ) { - OSL_PRECOND( _nTopCondIndex + MAX_CONDITIONS <= impl_getConditionCount(), + OSL_PRECOND( nTopCondIndex + MAX_CONDITIONS <= impl_getConditionCount(), "ConditionalFormattingDialog::impl_scrollTo: illegal index!" ); - m_pCondScroll->SetThumbPos( _nTopCondIndex ); - OnScroll( m_pCondScroll ); - } + auto nHeight = m_aConditions[0]->get_preferred_size().Height(); + m_xScrollWindow->vadjustment_set_value(nTopCondIndex * nHeight); + OnScroll(*m_xScrollWindow); + } void ConditionalFormattingDialog::impl_ensureConditionVisible( size_t _nCondIndex ) { diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index 1504ea8f7d8a..9e79c3d8830b 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -55,236 +55,175 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -ConditionField::ConditionField(Condition* pParent, Edit* pSubEdit, PushButton *pFormula) +ConditionField::ConditionField(Condition* pParent, std::unique_ptr<weld::Entry> xSubEdit, + std::unique_ptr<weld::Button> xFormula) : m_pParent(pParent) - , m_pSubEdit(pSubEdit) - , m_pFormula(pFormula) + , m_xSubEdit(std::move(xSubEdit)) + , m_xFormula(std::move(xFormula)) { - m_pSubEdit->EnableRTL( false ); - - m_pFormula->SetText("..."); - m_pFormula->SetClickHdl( LINK( this, ConditionField, OnFormula ) ); + m_xFormula->set_label("..."); + m_xFormula->connect_clicked( LINK( this, ConditionField, OnFormula ) ); } -IMPL_LINK( ConditionField, OnFormula, Button*, _pClickedButton, void ) +IMPL_LINK_NOARG(ConditionField, OnFormula, weld::Button&, void) { - OUString sFormula(m_pSubEdit->GetText()); + OUString sFormula(m_xSubEdit->get_text()); const sal_Int32 nLen = sFormula.getLength(); if ( nLen ) { ReportFormula aFormula( sFormula ); sFormula = aFormula.getCompleteFormula(); } - uno::Reference< awt::XWindow> xInspectorWindow = VCLUnoHelper::GetInterface(_pClickedButton); + uno::Reference< awt::XWindow> xInspectorWindow = m_pParent->GetXWindow(); uno::Reference< beans::XPropertySet> xProp(m_pParent->getController().getRowSet(),uno::UNO_QUERY); if ( rptui::openDialogFormula_nothrow( sFormula, m_pParent->getController().getContext(),xInspectorWindow,xProp ) ) { ReportFormula aFormula( sFormula ); - m_pSubEdit->SetText(aFormula.getUndecoratedContent()); + m_xSubEdit->set_text(aFormula.getUndecoratedContent()); } } -ConditionColorWrapper::ConditionColorWrapper(Condition* pControl) - : mxControl(pControl) - , mnSlotId(0) -{ -} - -void ConditionColorWrapper::dispose() +ConditionColorWrapper::ConditionColorWrapper(Condition* pControl, sal_uInt16 nSlotId) + : mpControl(pControl) + , mnSlotId(nSlotId) { - mxControl.clear(); } void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor) { - mxControl->ApplyCommand(mnSlotId, rNamedColor); + mpControl->ApplyCommand(mnSlotId, rNamedColor); } // = Condition - - -Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ) - : VclHBox(_pParent) - , m_xPaletteManager(new PaletteManager) - , m_aColorWrapper(this) +Condition::Condition(weld::Container* pParent, weld::Window* pDialog, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController) + : m_xPaletteManager(new PaletteManager) + , m_aBackColorWrapper(this, SID_BACKGROUND_COLOR) + , m_aForeColorWrapper(this, SID_ATTR_CHAR_COLOR2) , m_rController(_rController) , m_rAction(_rAction) , m_nCondIndex(0) - , m_bInDestruction(false) + , m_pDialog(pDialog) + , m_xBuilder(Application::CreateBuilder(pParent, "modules/dbreport/ui/conditionwin.ui")) + , m_xContainer(m_xBuilder->weld_container("ConditionWin")) + , m_xHeader(m_xBuilder->weld_label("headerLabel")) + , m_xConditionType(m_xBuilder->weld_combo_box("typeCombobox")) + , m_xOperationList(m_xBuilder->weld_combo_box("opCombobox")) + , m_xOperandGlue(m_xBuilder->weld_label("andLabel")) + , m_xActions(m_xBuilder->weld_toolbar("formatToolbox")) + , m_xPreview(new weld::CustomWeld(*m_xBuilder, "previewDrawingarea", m_aPreview)) + , m_xMoveUp(m_xBuilder->weld_button("upButton")) + , m_xMoveDown(m_xBuilder->weld_button("downButton")) + , m_xAddCondition(m_xBuilder->weld_button("addButton")) + , m_xRemoveCondition(m_xBuilder->weld_button("removeButton")) { - m_pUIBuilder.reset(new VclBuilder(this, getUIRootDir(), "modules/dbreport/ui/conditionwin.ui")); - - get(m_pHeader, "headerLabel"); - get(m_pConditionType, "typeCombobox"); - get(m_pOperationList, "opCombobox"); - m_pCondLHS.reset( new ConditionField(this, get<Edit>("lhsEntry"), get<PushButton>("lhsButton")) ); - get(m_pOperandGlue, "andLabel"); - m_pCondRHS.reset( new ConditionField(this, get<Edit>("rhsEntry"), get<PushButton>("rhsButton")) ); - get(m_pActions, "formatToolbox"); - get(m_pPreview, "previewDrawingarea"); - get(m_pMoveUp, "upButton"); - get(m_pMoveDown, "downButton"); - get(m_pAddCondition, "addButton"); - get(m_pRemoveCondition, "removeButton"); - - m_pActions->SetLineSpacing(true); - m_pCondLHS->GrabFocus(); - - m_pConditionType->SetSelectHdl( LINK( this, Condition, OnTypeSelected ) ); - - m_pOperationList->SetDropDownLineCount( 10 ); - m_pOperationList->SetSelectHdl( LINK( this, Condition, OnOperationSelected ) ); - - m_pActions->SetSelectHdl(LINK(this, Condition, OnFormatAction)); - m_pActions->SetDropdownClickHdl( LINK( this, Condition, DropdownClick ) ); - setToolBox(m_pActions); - - m_pMoveUp->SetClickHdl( LINK( this, Condition, OnConditionAction ) ); - m_pMoveDown->SetClickHdl( LINK( this, Condition, OnConditionAction ) ); - m_pAddCondition->SetClickHdl( LINK( this, Condition, OnConditionAction ) ); - m_pRemoveCondition->SetClickHdl( LINK( this, Condition, OnConditionAction ) ); - - vcl::Font aFont( m_pAddCondition->GetFont() ); - aFont.SetWeight( WEIGHT_BOLD ); - m_pAddCondition->SetFont( aFont ); - m_pRemoveCondition->SetFont( aFont ); - - m_pOperandGlue->SetStyle( m_pOperandGlue->GetStyle() | WB_VCENTER ); - - m_pConditionType->SelectEntryPos( 0 ); - m_pOperationList->SelectEntryPos( 0 ); - - m_nBoldId = m_pActions->GetItemId(".uno:Bold"); - m_nItalicId = m_pActions->GetItemId(".uno:Italic"); - m_nUnderLineId = m_pActions->GetItemId(".uno:Underline"); - m_nBackgroundColorId = m_pActions->GetItemId(".uno:BackgroundColor"); - m_nFontColorId = m_pActions->GetItemId(".uno:FontColor"); - m_nFontDialogId = m_pActions->GetItemId(".uno:FontDialog"); - - m_pBtnUpdaterBackgroundColor.reset( new svx::ToolboxButtonColorUpdater( - SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions, false, - m_pActions->GetItemText( m_nBackgroundColorId ) ) ); - m_pBtnUpdaterFontColor.reset( new svx::ToolboxButtonColorUpdater( - SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions, false, - m_pActions->GetItemText( m_nFontColorId ) ) ); - - Show(); + m_xCondLHS.reset(new ConditionField(this, m_xBuilder->weld_entry("lhsEntry"), m_xBuilder->weld_button("lhsButton"))); + m_xCondRHS.reset(new ConditionField(this, m_xBuilder->weld_entry("rhsEntry"), m_xBuilder->weld_button("rhsButton"))); + + m_xCondLHS->grab_focus(); + + m_xConditionType->connect_changed( LINK( this, Condition, OnTypeSelected ) ); + + m_xOperationList->connect_changed( LINK( this, Condition, OnOperationSelected ) ); + + m_xActions->connect_clicked(LINK(this, Condition, OnFormatAction)); + + m_xMoveUp->connect_clicked( LINK( this, Condition, OnConditionAction ) ); + m_xMoveDown->connect_clicked( LINK( this, Condition, OnConditionAction ) ); + m_xAddCondition->connect_clicked( LINK( this, Condition, OnConditionAction ) ); + m_xRemoveCondition->connect_clicked( LINK( this, Condition, OnConditionAction ) ); + + m_xConditionType->set_active(0); + m_xOperationList->set_active(0); + + SetBackgroundDropdownClick(); + SetForegroundDropdownClick(); + + m_xContainer->show(); ConditionalExpressionFactory::getKnownConditionalExpressions( m_aConditionalExpressions ); } -sal_uInt16 Condition::mapToolbarItemToSlotId(sal_uInt16 nItemId) const +sal_uInt16 Condition::mapToolbarItemToSlotId(const OString& rItemId) { - if (nItemId == m_nBoldId) + if (rItemId == "bold") return SID_ATTR_CHAR_WEIGHT; - if (nItemId == m_nItalicId) + if (rItemId == "italic") return SID_ATTR_CHAR_POSTURE; - if (nItemId == m_nUnderLineId) + if (rItemId == "underline") return SID_ATTR_CHAR_UNDERLINE; - if (nItemId == m_nBackgroundColorId) + if (rItemId == "background") return SID_BACKGROUND_COLOR; - if (nItemId == m_nFontColorId) + if (rItemId == "foreground") return SID_ATTR_CHAR_COLOR2; - if (nItemId == m_nFontDialogId) + if (rItemId == "fontdialog") return SID_CHAR_DLG; return 0; } Condition::~Condition() { - disposeOnce(); } -void Condition::dispose() +void Condition::SetBackgroundDropdownClick() { - m_bInDestruction = true; - - m_pBtnUpdaterFontColor.reset(); - m_pCondLHS.reset(); - m_pCondRHS.reset(); - m_pBtnUpdaterBackgroundColor.reset(); - m_pHeader.clear(); - m_pConditionType.clear(); - m_pOperationList.clear(); - m_pOperandGlue.clear(); - m_pActions.clear(); - m_pPreview.clear(); - m_pMoveUp.clear(); - m_pMoveDown.clear(); - m_pAddCondition.clear(); - m_pRemoveCondition.clear(); - m_pColorFloat.disposeAndClear(); - m_aColorWrapper.dispose(); - disposeBuilder(); - VclHBox::dispose(); + m_xBackColorFloat.reset(new ColorWindow( + m_xPaletteManager, + m_aColorStatus, + SID_BACKGROUND_COLOR, + nullptr, + m_pDialog, + MenuOrToolMenuButton(m_xActions.get(), "background"), + /*bInterimBuilder*/false, + m_aBackColorWrapper)); + + m_xActions->set_item_popover("background", m_xBackColorFloat->GetWidget()); } -IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void) +void Condition::SetForegroundDropdownClick() { - sal_uInt16 nId( m_pActions->GetCurItemId() ); - m_pColorFloat.disposeAndClear(); - sal_uInt16 nSlotId(mapToolbarItemToSlotId(nId)); - m_aColorWrapper.SetSlotId(nSlotId); - m_pColorFloat = VclPtr<SvxColorWindow>::Create( - OUString() /*m_aCommandURL*/, - m_xPaletteManager, - m_aColorStatus, - nSlotId, - nullptr, - pToolBox, - false, - m_aColorWrapper); - - m_pColorFloat->EnableDocking(); - vcl::Window::GetDockingManager()->StartPopupMode(pToolBox, m_pColorFloat, FloatWinPopupFlags::GrabFocus); + m_xForeColorFloat.reset(new ColorWindow( + m_xPaletteManager, + m_aColorStatus, + SID_ATTR_CHAR_COLOR2, + nullptr, + m_pDialog, + MenuOrToolMenuButton(m_xActions.get(), "foreground"), + /*bInterimBuilder*/false, + m_aForeColorWrapper)); + + m_xActions->set_item_popover("foreground", m_xForeColorFloat->GetWidget()); } -IMPL_LINK_NOARG( Condition, OnFormatAction, ToolBox*, void ) + +IMPL_LINK(Condition, OnFormatAction, const OString&, rIdent, void) { - ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()), + ApplyCommand(mapToolbarItemToSlotId(rIdent), NamedColor(COL_AUTO, "#" + COL_AUTO.AsRGBHexString())); } -IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton, void ) +IMPL_LINK(Condition, OnConditionAction, weld::Button&, rClickedButton, void) { - if ( _pClickedButton == m_pMoveUp ) + if ( &rClickedButton == m_xMoveUp.get() ) m_rAction.moveConditionUp( getConditionIndex() ); - else if ( _pClickedButton == m_pMoveDown ) + else if ( &rClickedButton == m_xMoveDown.get() ) m_rAction.moveConditionDown( getConditionIndex() ); - else if ( _pClickedButton == m_pAddCondition ) + else if ( &rClickedButton == m_xAddCondition.get() ) m_rAction.addCondition( getConditionIndex() ); - else if ( _pClickedButton == m_pRemoveCondition ) + else if ( &rClickedButton == m_xRemoveCondition.get() ) m_rAction.deleteCondition( getConditionIndex() ); } void Condition::ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor ) { - if ( _nCommandId == SID_ATTR_CHAR_COLOR2 ) - m_pBtnUpdaterFontColor->Update( rNamedColor ); - else if ( _nCommandId == SID_BACKGROUND_COLOR ) - m_pBtnUpdaterBackgroundColor->Update( rNamedColor ); - m_rAction.applyCommand( m_nCondIndex, _nCommandId, rNamedColor.first ); } -void Condition::resizeControls(const Size& /*_rDiff*/) -{ -} - -void Condition::GetFocus() -{ - VclHBox::GetFocus(); - if ( !m_bInDestruction ) - m_pCondLHS->GrabFocus(); -} - -IMPL_LINK_NOARG( Condition, OnTypeSelected, ListBox&, void ) +IMPL_LINK_NOARG( Condition, OnTypeSelected, weld::ComboBox&, void ) { impl_layoutOperands(); } - -IMPL_LINK_NOARG( Condition, OnOperationSelected, ListBox&, void ) +IMPL_LINK_NOARG( Condition, OnOperationSelected, weld::ComboBox&, void ) { impl_layoutOperands(); } @@ -303,9 +242,9 @@ void Condition::impl_layoutOperands() ); // the "condition type" list box - m_pOperationList->Show( !bIsExpression ); - m_pOperandGlue->Show( bHaveRHS ); - m_pCondRHS->Show( bHaveRHS ); + m_xOperationList->set_visible( !bIsExpression ); + m_xOperandGlue->set_visible( bHaveRHS ); + m_xCondRHS->set_visible( bHaveRHS ); } void Condition::impl_setCondition( const OUString& _rConditionFormula ) @@ -347,10 +286,10 @@ void Condition::impl_setCondition( const OUString& _rConditionFormula ) } // update UI - m_pConditionType->SelectEntryPos( static_cast<sal_uInt16>(eType) ); - m_pOperationList->SelectEntryPos( static_cast<sal_uInt16>(eOperation) ); - m_pCondLHS->SetText( sLHS ); - m_pCondRHS->SetText( sRHS ); + m_xConditionType->set_active(static_cast<sal_uInt16>(eType)); + m_xOperationList->set_active(static_cast<sal_uInt16>(eOperation)); + m_xCondLHS->set_text( sLHS ); + m_xCondRHS->set_text( sRHS ); // re-layout impl_layoutOperands(); @@ -380,15 +319,15 @@ void Condition::setCondition( const uno::Reference< report::XFormatCondition >& void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat >& _xReportControlFormat) { + OString aItems[] = { "bold", "italic", "underline", "fontdialog" }; + OSL_ENSURE(_xReportControlFormat.is(),"XReportControlFormat is NULL!"); if ( _xReportControlFormat.is() ) { - ToolBox::ImplToolItems::size_type nItemCount = m_pActions->GetItemCount(); - for (ToolBox::ImplToolItems::size_type j = 0; j< nItemCount; ++j) + for (size_t j = 0; j < SAL_N_ELEMENTS(aItems); ++j) { - sal_uInt16 nItemId = m_pActions->GetItemId(j); - m_pActions->CheckItem( nItemId, OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(nItemId), - _xReportControlFormat ) ); + m_xActions->set_item_active(aItems[j], OReportController::isFormatCommandEnabled(mapToolbarItemToSlotId(aItems[j]), + _xReportControlFormat)); } try @@ -399,9 +338,9 @@ void Condition::updateToolbar(const uno::Reference< report::XReportControlFormat aFont.SetEmphasisMark( static_cast< FontEmphasisMark >( _xReportControlFormat->getControlTextEmphasis() ) ); aFont.SetRelief( static_cast< FontRelief >( _xReportControlFormat->getCharRelief() ) ); aFont.SetColor( Color(_xReportControlFormat->getCharColor()) ); - m_pPreview->SetFont( aFont, aFont, aFont ); - m_pPreview->SetBackColor( Color(_xReportControlFormat->getControlBackground()) ); - m_pPreview->SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); + m_aPreview.SetFont( aFont, aFont, aFont ); + m_aPreview.SetBackColor( Color(_xReportControlFormat->getControlBackground()) ); + m_aPreview.SetTextLineColor( Color( _xReportControlFormat->getCharUnderlineColor() ) ); } catch( const Exception& ) { @@ -415,8 +354,8 @@ void Condition::fillFormatCondition(const uno::Reference< report::XFormatConditi const ConditionType eType( impl_getCurrentConditionType() ); const ComparisonOperation eOperation( impl_getCurrentComparisonOperation() ); - const OUString sLHS( m_pCondLHS->GetText() ); - const OUString sRHS( m_pCondRHS->GetText() ); + const OUString sLHS( m_xCondLHS->get_text() ); + const OUString sRHS( m_xCondRHS->get_text() ); OUString sUndecoratedFormula( sLHS ); @@ -438,20 +377,18 @@ void Condition::setConditionIndex( size_t _nCondIndex, size_t _nCondCount ) m_nCondIndex = _nCondIndex; OUString sHeader( RptResId( STR_NUMBERED_CONDITION ) ); sHeader = sHeader.replaceFirst( "$number$", OUString::number( _nCondIndex + 1) ); - m_pHeader->SetText( sHeader ); + m_xHeader->set_label( sHeader ); - m_pMoveUp->Enable( _nCondIndex > 0 ); + m_xMoveUp->set_sensitive(_nCondIndex > 0); OSL_PRECOND( _nCondCount > 0, "Condition::setConditionIndex: having no conditions at all is nonsense!" ); - m_pMoveDown->Enable( _nCondIndex < _nCondCount - 1 ); + m_xMoveDown->set_sensitive(_nCondIndex < _nCondCount - 1); } - bool Condition::isEmpty() const { - return m_pCondLHS->GetText().isEmpty(); + return m_xCondLHS->get_text().isEmpty(); } - } // rptui diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx index d8a03ac82f57..1b9a5ea365fa 100644 --- a/reportdesign/source/ui/dlg/Condition.hxx +++ b/reportdesign/source/ui/dlg/Condition.hxx @@ -24,8 +24,6 @@ #include <com/sun/star/report/XFormatCondition.hpp> -#include <dbaccess/ToolBoxHelper.hxx> - #include <svx/colorwindow.hxx> #include <svx/fntctrl.hxx> @@ -35,7 +33,8 @@ #include <vcl/button.hxx> #include <vcl/toolbox.hxx> #include <vcl/builder.hxx> -#include <vcl/layout.hxx> +#include <vcl/customweld.hxx> +#include <vcl/weld.hxx> #include <memory> @@ -50,84 +49,74 @@ namespace rptui class ConditionField { - VclPtr<Condition> m_pParent; - VclPtr<Edit> m_pSubEdit; - VclPtr<PushButton> m_pFormula; + Condition* m_pParent; + std::unique_ptr<weld::Entry> m_xSubEdit; + std::unique_ptr<weld::Button> m_xFormula; - DECL_LINK( OnFormula, Button*, void ); + DECL_LINK(OnFormula, weld::Button&, void); public: - ConditionField(Condition* pParent, Edit* pSubEdit, PushButton *pFormula); - void GrabFocus() { m_pSubEdit->GrabFocus(); } - void Show(bool bShow) { m_pSubEdit->Show(bShow); m_pFormula->Show(bShow); } - void SetText(const OUString& rText) { m_pSubEdit->SetText(rText); } - OUString GetText() const { return m_pSubEdit->GetText(); } + ConditionField(Condition* pParent, std::unique_ptr<weld::Entry> xSubEdit, std::unique_ptr<weld::Button> xFormula); + void grab_focus() { m_xSubEdit->grab_focus(); } + void set_visible(bool bShow) { m_xSubEdit->set_visible(bShow); m_xFormula->set_visible(bShow); } + void set_text(const OUString& rText) { m_xSubEdit->set_text(rText); } + OUString get_text() const { return m_xSubEdit->get_text(); } }; class ConditionColorWrapper { public: - ConditionColorWrapper(Condition* pControl); - void SetSlotId(sal_uInt16 nSlotId) { mnSlotId = nSlotId; } + ConditionColorWrapper(Condition* pControl, sal_uInt16 nSlotId); void operator()(const OUString& rCommand, const NamedColor& rColor); void dispose(); private: - VclPtr<Condition> mxControl; + Condition* mpControl; sal_uInt16 mnSlotId; }; //= Condition - class Condition :public VclHBox - ,public dbaui::OToolBoxHelper - ,public VclBuilderContainer + class Condition { - sal_uInt16 m_nBoldId; - sal_uInt16 m_nItalicId; - sal_uInt16 m_nUnderLineId; - sal_uInt16 m_nBackgroundColorId; - sal_uInt16 m_nFontColorId; - sal_uInt16 m_nFontDialogId; std::shared_ptr<PaletteManager> m_xPaletteManager; ColorStatus m_aColorStatus; - ConditionColorWrapper m_aColorWrapper; + ConditionColorWrapper m_aBackColorWrapper; + ConditionColorWrapper m_aForeColorWrapper; ::rptui::OReportController& m_rController; IConditionalFormatAction& m_rAction; - VclPtr<FixedText> m_pHeader; - VclPtr<ListBox> m_pConditionType; - VclPtr<ListBox> m_pOperationList; - std::unique_ptr<ConditionField> m_pCondLHS; - VclPtr<FixedText> m_pOperandGlue; - std::unique_ptr<ConditionField> m_pCondRHS; - VclPtr<ToolBox> m_pActions; - VclPtr<SvxFontPrevWindow> m_pPreview; - VclPtr<PushButton> m_pMoveUp; - VclPtr<PushButton> m_pMoveDown; - VclPtr<PushButton> m_pAddCondition; - VclPtr<PushButton> m_pRemoveCondition; - VclPtr<SvxColorWindow> m_pColorFloat; - - std::unique_ptr<svx::ToolboxButtonColorUpdater> m_pBtnUpdaterFontColor; // updates the color below the toolbar icon - std::unique_ptr<svx::ToolboxButtonColorUpdater> m_pBtnUpdaterBackgroundColor; - size_t m_nCondIndex; - bool m_bInDestruction; ConditionalExpressions m_aConditionalExpressions; - DECL_LINK( OnFormatAction, ToolBox*, void ); - DECL_LINK( DropdownClick, ToolBox*, void ); - DECL_LINK( OnConditionAction, Button*, void ); + FontPrevWindow m_aPreview; + weld::Window* m_pDialog; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + std::unique_ptr<weld::Label> m_xHeader; + std::unique_ptr<weld::ComboBox> m_xConditionType; + std::unique_ptr<weld::ComboBox> m_xOperationList; + std::unique_ptr<ConditionField> m_xCondLHS; + std::unique_ptr<weld::Label> m_xOperandGlue; + std::unique_ptr<ConditionField> m_xCondRHS; + std::unique_ptr<weld::Toolbar> m_xActions; + std::unique_ptr<weld::CustomWeld> m_xPreview; + std::unique_ptr<weld::Button> m_xMoveUp; + std::unique_ptr<weld::Button> m_xMoveDown; + std::unique_ptr<weld::Button> m_xAddCondition; + std::unique_ptr<weld::Button> m_xRemoveCondition; + std::unique_ptr<ColorWindow> m_xBackColorFloat; + std::unique_ptr<ColorWindow> m_xForeColorFloat; + + void SetBackgroundDropdownClick(); + void SetForegroundDropdownClick(); + + DECL_LINK( OnFormatAction, const OString&, void ); + DECL_LINK( OnConditionAction, weld::Button&, void ); public: - Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, ::rptui::OReportController& _rController ); - virtual ~Condition() override; - virtual void dispose() override; - - /** will be called when the controls need to be resized. - */ - virtual void resizeControls(const Size& _rDiff) override; + Condition(weld::Container* pParent, weld::Window* pDialog, IConditionalFormatAction& rAction, ::rptui::OReportController& rController); + ~Condition(); /** sets the props at the control @param _xCondition the source @@ -160,10 +149,14 @@ namespace rptui ::rptui::OReportController& getController() const { return m_rController; } - sal_uInt16 mapToolbarItemToSlotId(sal_uInt16 nItemId) const; + static sal_uInt16 mapToolbarItemToSlotId(const OString& rItemId); - protected: - virtual void GetFocus() override; + css::uno::Reference<css::awt::XWindow> GetXWindow() const { return m_pDialog->GetXWindow(); } + + void grab_focus() { m_xContainer->grab_focus(); } + bool has_focus() const { return m_xContainer->has_focus(); } + Size get_preferred_size() const { return m_xContainer->get_preferred_size(); } + weld::Widget* get_widget() const { return m_xContainer.get(); } private: void impl_layoutOperands(); @@ -177,23 +170,20 @@ namespace rptui void impl_setCondition( const OUString& _rConditionFormula ); private: - DECL_LINK( OnTypeSelected, ListBox&, void ); - DECL_LINK( OnOperationSelected, ListBox&, void ); + DECL_LINK( OnTypeSelected, weld::ComboBox&, void ); + DECL_LINK( OnOperationSelected, weld::ComboBox&, void ); }; - inline ConditionType Condition::impl_getCurrentConditionType() const { - return sal::static_int_cast< ConditionType >( m_pConditionType->GetSelectedEntryPos() ); + return sal::static_int_cast<ConditionType>(m_xConditionType->get_active()); } - inline ComparisonOperation Condition::impl_getCurrentComparisonOperation() const { - return sal::static_int_cast< ComparisonOperation >( m_pOperationList->GetSelectedEntryPos() ); + return sal::static_int_cast<ComparisonOperation>(m_xOperationList->get_active()); } - } // namespace rptui #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_DLG_CONDITION_HXX diff --git a/reportdesign/source/ui/inc/AddField.hxx b/reportdesign/source/ui/inc/AddField.hxx index b122bb3012d7..2c16546e1004 100644 --- a/reportdesign/source/ui/inc/AddField.hxx +++ b/reportdesign/source/ui/inc/AddField.hxx @@ -32,7 +32,6 @@ #include <svx/dataaccessdescriptor.hxx> #include <cppuhelper/basemutex.hxx> -#include <dbaccess/ToolBoxHelper.hxx> #include <vcl/toolbox.hxx> #include <vcl/fixed.hxx> @@ -48,7 +47,6 @@ class OAddFieldWindow :public FloatingWindow , public ::cppu::BaseMutex , public ::comphelper::OPropertyChangeListener , public ::comphelper::OContainerListener - , public dbaui::OToolBoxHelper { css::uno::Reference< css::lang::XComponent> m_xHoldAlive; css::uno::Reference< css::container::XNameAccess> m_xColumns; @@ -95,10 +93,6 @@ public: css::uno::Sequence< css::beans::PropertyValue > getSelectedFieldDescriptors(); - /** will be called when the controls need to be resized. - */ - virtual void resizeControls(const Size& _rDiff) override; - /// Updates the current field list void Update(); diff --git a/reportdesign/source/ui/inc/CondFormat.hxx b/reportdesign/source/ui/inc/CondFormat.hxx index eecf554f8c46..a3260c134ecb 100644 --- a/reportdesign/source/ui/inc/CondFormat.hxx +++ b/reportdesign/source/ui/inc/CondFormat.hxx @@ -21,16 +21,9 @@ #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_CONDFORMAT_HXX #include <com/sun/star/report/XReportControlModel.hpp> - -#include <vcl/dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/fixed.hxx> -#include <vcl/layout.hxx> -#include <vcl/scrbar.hxx> - +#include <vcl/weld.hxx> #include <vector> - namespace rptui { @@ -62,15 +55,10 @@ namespace rptui |* Conditional formatting dialog |* \************************************************************************/ - class ConditionalFormattingDialog :public ModalDialog - ,public IConditionalFormatAction + class ConditionalFormattingDialog : public weld::GenericDialogController + , public IConditionalFormatAction { - typedef ::std::vector< VclPtr<Condition> > Conditions; - - VclPtr<vcl::Window> m_pConditionPlayground; - Conditions m_aConditions; - VclPtr<VclScrolledWindow> m_pScrollWindow; - VclPtr<ScrollBar> m_pCondScroll; + typedef ::std::vector< std::unique_ptr<Condition> > Conditions; ::rptui::OReportController& m_rController; css::uno::Reference< css::report::XReportControlModel > @@ -81,16 +69,19 @@ namespace rptui bool m_bDeletingCondition; bool m_bConstructed; + std::unique_ptr<weld::ScrolledWindow> m_xScrollWindow; + std::unique_ptr<weld::Box> m_xConditionPlayground; + Conditions m_aConditions; + public: ConditionalFormattingDialog( - vcl::Window* pParent, + weld::Window* pParent, const css::uno::Reference< css::report::XReportControlModel>& _xHoldAlive, ::rptui::OReportController& _rController ); virtual ~ConditionalFormattingDialog() override; - virtual void dispose() override; // Dialog overridables - virtual short Execute() override; + virtual short run() override; // IConditionalFormatAction overridables virtual void addCondition( size_t _nAddAfterIndex ) override; @@ -100,11 +91,8 @@ namespace rptui virtual void moveConditionDown( size_t _nCondIndex ) override; virtual OUString getDataField() const override; - protected: - virtual bool PreNotify( NotifyEvent& rNEvt ) override; - private: - DECL_LINK( OnScroll, ScrollBar*, void ); + DECL_LINK(OnScroll, weld::ScrolledWindow&, void); private: /// returns the current number of conditions @@ -125,9 +113,6 @@ namespace rptui /// does the dialog layouting void impl_layoutAll(); - /// does the layout for the condition windows - void impl_layoutConditions(); - /// called when the number of conditions has changed in any way void impl_conditionCountChanged(); @@ -149,9 +134,6 @@ namespace rptui /// focuses the condition with the given index, making it visible if necessary void impl_focusCondition( size_t _nCondIndex ); - /// updates the scrollbar range. (does not update the scrollbar visibility) - void impl_updateScrollBarRange(); - /// scrolls the condition with the given index to the top position void impl_scrollTo( size_t _nTopCondIndex ); diff --git a/reportdesign/source/ui/inc/GroupsSorting.hxx b/reportdesign/source/ui/inc/GroupsSorting.hxx index 453963c8687d..2c4be48ab602 100644 --- a/reportdesign/source/ui/inc/GroupsSorting.hxx +++ b/reportdesign/source/ui/inc/GroupsSorting.hxx @@ -38,8 +38,6 @@ #include <vector> -#include <dbaccess/ToolBoxHelper.hxx> - namespace comphelper { class OPropertyChangeMultiplexer; diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx index 51d7b5e7cf69..21d6e3c8af7a 100644 --- a/reportdesign/source/ui/misc/UITools.cxx +++ b/reportdesign/source/ui/misc/UITools.cxx @@ -637,8 +637,7 @@ bool openCharDialog( const uno::Reference<report::XReportControlFormat >& _rxRep { SID_ATTR_CHAR_CTL_POSTURE, true }, { SID_ATTR_CHAR_CTL_WEIGHT, true } }; - VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( _rxParentWindow ); - ::std::unique_ptr<FontList> pFontList(new FontList( pParent )); + ::std::unique_ptr<FontList> pFontList(new FontList(Application::GetDefaultDevice())); XColorListRef pColorList( XColorList::CreateStdColorList() ); std::vector<SfxPoolItem*> pDefaults { diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index cf89c567fbd2..92481ac15918 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -1548,8 +1548,8 @@ void OReportController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue > uno::Reference< report::XFormattedField> xFormattedField(getDesignView()->getCurrentControlModel(),uno::UNO_QUERY); if ( xFormattedField.is() ) { - ScopedVclPtrInstance< ConditionalFormattingDialog > aDlg( getView(), xFormattedField.get(), *this ); - aDlg->Execute(); + ConditionalFormattingDialog aDlg(getFrameWeld(), xFormattedField.get(), *this); + aDlg.run(); } } break; diff --git a/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui b/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui index 9ecfac38f421..0e19789d966a 100644 --- a/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui +++ b/reportdesign/uiconfig/dbreport/ui/condformatdialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="rpt"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="CondFormat"> @@ -8,7 +8,13 @@ <property name="vexpand">True</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="condformatdialog|CondFormat">Conditional Formatting</property> + <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</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> @@ -87,10 +93,12 @@ <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="hscrollbar_policy">never</property> <property name="shadow_type">in</property> <child> <object class="GtkViewport" id="viewport1"> <property name="visible">True</property> + <property name="can_focus">False</property> <child> <object class="GtkBox" id="condPlaygroundDrawingarea"> <property name="visible">True</property> diff --git a/reportdesign/uiconfig/dbreport/ui/conditionwin.ui b/reportdesign/uiconfig/dbreport/ui/conditionwin.ui index fa615089c50b..18ef29bae9af 100644 --- a/reportdesign/uiconfig/dbreport/ui/conditionwin.ui +++ b/reportdesign/uiconfig/dbreport/ui/conditionwin.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.22.1 --> <interface domain="rpt"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -17,7 +16,6 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="vexpand">True</property> <property name="border_width">6</property> <property name="orientation">vertical</property> <property name="spacing">6</property> @@ -38,7 +36,6 @@ <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> <property name="column_spacing">12</property> <child> @@ -46,7 +43,6 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="vexpand">True</property> <property name="spacing">12</property> <child> <object class="GtkComboBoxText" id="typeCombobox"> @@ -89,17 +85,18 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">center</property> + <property name="hexpand">True</property> <property name="column_spacing">6</property> <child> <object class="GtkEntry" id="lhsEntry"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -112,8 +109,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -127,6 +122,7 @@ <object class="GtkLabel" id="andLabel"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="valign">center</property> <property name="label" translatable="yes" context="conditionwin|andLabel">and</property> </object> <packing> @@ -140,17 +136,18 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">center</property> + <property name="hexpand">True</property> <property name="column_spacing">6</property> <child> <object class="GtkEntry" id="rhsEntry"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="activates_default">True</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -163,8 +160,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -178,8 +173,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -193,8 +186,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -202,7 +193,6 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="vexpand">True</property> <property name="spacing">12</property> <child> <object class="GtkToolbar" id="formatToolbox"> @@ -213,45 +203,42 @@ <property name="toolbar_style">icons</property> <property name="show_arrow">False</property> <child> - <object class="GtkToolButton" id="ToolBoxItem1"> + <object class="GtkToggleToolButton" id="bold"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:Bold</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem1">Bold</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_bold.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="ToolBoxItem2"> + <object class="GtkToggleToolButton" id="italic"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:Italic</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem2">Italic</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_italic.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="ToolBoxItem3"> + <object class="GtkToggleToolButton" id="underline"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:Underline</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem3">Underline</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_underline.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> @@ -265,45 +252,42 @@ </packing> </child> <child> - <object class="GtkMenuToolButton" id="ToolBoxItem4"> + <object class="GtkMenuToolButton" id="background"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:BackgroundColor</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem4">Background Color</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_backgroundcolor.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkMenuToolButton" id="ToolBoxItem5"> + <object class="GtkMenuToolButton" id="foreground"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:FontColor</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem5">Font Color</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_fontcolor.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> <child> - <object class="GtkToolButton" id="ToolBoxItem6"> + <object class="GtkToggleToolButton" id="fontdialog"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="action_name">.uno:FontDialog</property> <property name="label" translatable="yes" context="conditionwin|ToolBoxItem6">Character Formatting</property> <property name="use_underline">True</property> <property name="icon_name">cmd/sc_fontdialog.png</property> </object> <packing> <property name="expand">False</property> - <property name="homogeneous">True</property> + <property name="homogeneous">False</property> </packing> </child> </object> @@ -314,10 +298,26 @@ </packing> </child> <child> - <object class="svxlo-SvxFontPrevWindow" id="previewDrawingarea"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> + <property name="hscrollbar_policy">never</property> + <property name="vscrollbar_policy">never</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="previewDrawingarea"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + </child> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -329,8 +329,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -345,8 +343,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> @@ -373,8 +369,6 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -389,8 +383,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py index 192fb0be7801..e854f84fdf74 100755 --- a/solenv/bin/native-code.py +++ b/solenv/bin/native-code.py @@ -505,7 +505,6 @@ custom_widgets = [ 'SvxColorValueSet', 'SvxFillAttrBox', 'SvxFillTypeBox', - 'SvxFontPrevWindow', 'SvxLanguageBox', 'SvxLanguageComboBox', 'SvxLightCtl3D', diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx index 51b746694a7d..6dc4292b57ec 100644 --- a/svx/source/tbxctrls/tbcontrl.cxx +++ b/svx/source/tbxctrls/tbcontrl.cxx @@ -1704,15 +1704,15 @@ ColorWindow::ColorWindow(std::shared_ptr<PaletteManager> const & rPaletteManager sal_uInt16 nSlotId, const Reference< XFrame >& rFrame, weld::Window* pParentWindow, - weld::MenuButton* pMenuButton, + const MenuOrToolMenuButton& rMenuButton, bool bInterimBuilder, ColorSelectFunction const & aFunction) : ToolbarPopupBase(rFrame) - , m_xBuilder(bInterimBuilder ? Application::CreateInterimBuilder(pMenuButton, "svx/ui/colorwindow.ui") - : Application::CreateBuilder(pMenuButton, "svx/ui/colorwindow.ui")) + , m_xBuilder(bInterimBuilder ? Application::CreateInterimBuilder(rMenuButton.get_widget(), "svx/ui/colorwindow.ui") + : Application::CreateBuilder(rMenuButton.get_widget(), "svx/ui/colorwindow.ui")) , theSlotId(nSlotId) , mpParentWindow(pParentWindow) - , mpMenuButton(pMenuButton) + , maMenuButton(rMenuButton) , mxPaletteManager(rPaletteManager) , mrColorStatus(rColorStatus) , maColorSelectFunction(aFunction) @@ -1956,12 +1956,12 @@ IMPL_LINK(ColorWindow, SelectHdl, SvtValueSet*, pColorSet, void) if (pColorSet != mxRecentColorSet.get()) { mxPaletteManager->AddRecentColor(aNamedColor.first, aNamedColor.second); - if (!mpMenuButton->get_active()) + if (!maMenuButton.get_active()) mxPaletteManager->ReloadRecentColorSet(*mxRecentColorSet); } - if (mpMenuButton->get_active()) - mpMenuButton->set_active(false); + if (maMenuButton.get_active()) + maMenuButton.set_active(false); maColorSelectFunction(OUString(), aNamedColor); } @@ -2014,8 +2014,8 @@ IMPL_LINK(ColorWindow, AutoColorClickHdl, weld::Button&, rButton, void) mxRecentColorSet->SetNoSelection(); - if (mpMenuButton->get_active()) - mpMenuButton->set_active(false); + if (maMenuButton.get_active()) + maMenuButton.set_active(false); maColorSelectFunction(OUString(), aNamedColor); } @@ -2042,8 +2042,8 @@ IMPL_LINK_NOARG(SvxColorWindow, OpenPickerClickHdl, Button*, void) IMPL_LINK_NOARG(ColorWindow, OpenPickerClickHdl, weld::Button&, void) { - if (mpMenuButton->get_active()) - mpMenuButton->set_active(false); + if (maMenuButton.get_active()) + maMenuButton.set_active(false); mxPaletteManager->PopupColorPicker(mpParentWindow, OUString(), GetSelectEntryColor().first); } @@ -4168,4 +4168,41 @@ void ColorListBox::ShowPreview(const NamedColor &rColor) m_xButton->set_label(rColor.second); } +MenuOrToolMenuButton::MenuOrToolMenuButton(weld::MenuButton* pMenuButton) + : m_pMenuButton(pMenuButton) + , m_pToolbar(nullptr) +{ +} + +MenuOrToolMenuButton::MenuOrToolMenuButton(weld::Toolbar* pToolbar, const OString& rIdent) + : m_pMenuButton(nullptr) + , m_pToolbar(pToolbar) + , m_aIdent(rIdent) +{ +} + +bool MenuOrToolMenuButton::get_active() const +{ + if (m_pMenuButton) + return m_pMenuButton->get_active(); + return m_pToolbar->get_item_active(m_aIdent); +} + +void MenuOrToolMenuButton::set_active(bool bActive) const +{ + if (m_pMenuButton) + { + m_pMenuButton->set_active(bActive); + return; + } + m_pToolbar->set_item_active(m_aIdent, bActive); +} + +weld::Widget* MenuOrToolMenuButton::get_widget() const +{ + if (m_pMenuButton) + return m_pMenuButton; + return m_pToolbar; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d12c3464c75d..6cf9e010178c 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -923,14 +923,17 @@ class SalInstanceToolbar : public SalInstanceWidget, public virtual weld::Toolba { private: VclPtr<ToolBox> m_xToolBox; + std::map<sal_uInt16, VclPtr<vcl::Window>> m_aFloats; DECL_LINK(ClickHdl, ToolBox*, void); + DECL_LINK(DropdownClick, ToolBox*, void); public: SalInstanceToolbar(ToolBox* pToolBox, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : SalInstanceWidget(pToolBox, pBuilder, bTakeOwnership) , m_xToolBox(pToolBox) { m_xToolBox->SetSelectHdl(LINK(this, SalInstanceToolbar, ClickHdl)); + m_xToolBox->SetDropdownClickHdl(LINK(this, SalInstanceToolbar, DropdownClick)); } virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override @@ -945,7 +948,19 @@ public: virtual void set_item_active(const OString& rIdent, bool bActive) override { - m_xToolBox->CheckItem(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)), bActive); + sal_uInt16 nItemId = m_xToolBox->GetItemId(OUString::fromUtf8(rIdent)); + m_xToolBox->CheckItem(nItemId, bActive); + + if (m_xToolBox->GetItemBits(nItemId) & ToolBoxItemBits::DROPDOWN) + { + auto pFloat = m_aFloats[nItemId]; + if (!pFloat) + return; + if (bActive) + vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox, pFloat, FloatWinPopupFlags::GrabFocus); + else + vcl::Window::GetDockingManager()->EndPopupMode(pFloat); + } } virtual bool get_item_active(const OString& rIdent) const override @@ -953,6 +968,17 @@ public: return m_xToolBox->IsItemChecked(m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))); } + virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) override + { + SalInstanceWidget* pPopoverWidget = dynamic_cast<SalInstanceWidget*>(pPopover); + + vcl::Window* pFloat = pPopoverWidget ? pPopoverWidget->getWidget() : nullptr; + if (pFloat) + pFloat->EnableDocking(); + + m_aFloats[m_xToolBox->GetItemId(OUString::fromUtf8(rIdent))] = pFloat; + } + virtual void insert_separator(int pos, const OUString& /*rId*/) override { auto nInsertPos = pos == -1 ? ToolBox::APPEND : pos; @@ -961,6 +987,7 @@ public: virtual ~SalInstanceToolbar() override { + m_xToolBox->SetDropdownClickHdl(Link<ToolBox*, void>()); m_xToolBox->SetSelectHdl(Link<ToolBox*, void>()); } }; @@ -971,6 +998,12 @@ IMPL_LINK_NOARG(SalInstanceToolbar, ClickHdl, ToolBox*, void) signal_clicked(m_xToolBox->GetItemCommand(nItemId).toUtf8()); } +IMPL_LINK_NOARG(SalInstanceToolbar, DropdownClick, ToolBox*, void) +{ + sal_uInt16 nItemId = m_xToolBox->GetCurItemId(); + set_item_active(m_xToolBox->GetItemCommand(nItemId).toUtf8(), true); +} + class SalInstanceSizeGroup : public weld::SizeGroup { private: @@ -994,9 +1027,10 @@ public: class SalInstanceContainer : public SalInstanceWidget, public virtual weld::Container { -private: +protected: VclPtr<vcl::Window> m_xContainer; +private: void implResetDefault(const vcl::Window* _pWindow) { vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); @@ -1060,6 +1094,21 @@ std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false); } +class SalInstanceBox : public SalInstanceContainer, public virtual weld::Box +{ +public: + SalInstanceBox(vcl::Window* pContainer, SalInstanceBuilder* pBuilder, bool bTakeOwnership) + : SalInstanceContainer(pContainer, pBuilder, bTakeOwnership) + { + } + virtual void reorder_child(weld::Widget* pWidget, int nNewPosition) override + { + SalInstanceWidget* pVclWidget = dynamic_cast<SalInstanceWidget*>(pWidget); + assert(pVclWidget); + pVclWidget->getWidget()->reorderWithinParent(nNewPosition); + } +}; + namespace { void CollectChildren(const vcl::Window& rCurrent, const basegfx::B2IPoint& rTopLeft, weld::ScreenShotCollection& rControlDataCollection) @@ -5809,6 +5858,12 @@ public: return pContainer ? std::make_unique<SalInstanceContainer>(pContainer, this, bTakeOwnership) : nullptr; } + virtual std::unique_ptr<weld::Box> weld_box(const OString &id, bool bTakeOwnership) override + { + vcl::Window* pContainer = m_xBuilder->get<vcl::Window>(id); + return pContainer ? std::make_unique<SalInstanceBox>(pContainer, this, bTakeOwnership) : nullptr; + } + virtual std::unique_ptr<weld::Frame> weld_frame(const OString &id, bool bTakeOwnership) override { VclFrame* pFrame = m_xBuilder->get<VclFrame>(id); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 59066bde6502..38fc905c8091 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -3208,6 +3208,27 @@ std::unique_ptr<weld::Container> GtkInstanceWidget::weld_parent() const return std::make_unique<GtkInstanceContainer>(GTK_CONTAINER(pParent), m_pBuilder, false); } +class GtkInstanceBox : public GtkInstanceContainer, public virtual weld::Box +{ +private: + GtkBox* m_pBox; + +public: + GtkInstanceBox(GtkBox* pBox, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) + : GtkInstanceContainer(GTK_CONTAINER(pBox), pBuilder, bTakeOwnership) + , m_pBox(pBox) + { + } + + virtual void reorder_child(weld::Widget* pWidget, int nNewPosition) override + { + GtkInstanceWidget* pGtkWidget = dynamic_cast<GtkInstanceWidget*>(pWidget); + assert(pGtkWidget); + GtkWidget* pChild = pGtkWidget->getWidget(); + gtk_box_reorder_child(m_pBox, pChild, nNewPosition); + } +}; + namespace { void set_cursor(GtkWidget* pWidget, const char *pName) @@ -6671,6 +6692,21 @@ private: GtkToolbar* m_pToolbar; std::map<OString, GtkToolButton*> m_aMap; + std::map<OString, std::unique_ptr<GtkInstanceMenuButton>> m_aMenuButtonMap; + + // at the time of writing there is no gtk_menu_tool_button_set_popover available + // though there will be in the future + // https://gitlab.gnome.org/GNOME/gtk/commit/03e30431a8af9a947a0c4ccab545f24da16bfe17?w=1 + static void find_menu_button(GtkWidget *pWidget, gpointer user_data) + { + if (g_strcmp0(gtk_widget_get_name(pWidget), "GtkMenuButton") == 0) + { + GtkWidget **ppToggleButton = static_cast<GtkWidget**>(user_data); + *ppToggleButton = pWidget; + } + else if (GTK_IS_CONTAINER(pWidget)) + gtk_container_forall(GTK_CONTAINER(pWidget), find_menu_button, user_data); + } static void collect(GtkWidget* pItem, gpointer widget) { @@ -6678,15 +6714,22 @@ private: { GtkToolButton* pToolItem = GTK_TOOL_BUTTON(pItem); GtkInstanceToolbar* pThis = static_cast<GtkInstanceToolbar*>(widget); - pThis->add_to_map(pToolItem); + + GtkMenuButton* pMenuButton = nullptr; + if (GTK_IS_MENU_TOOL_BUTTON(pItem)) + find_menu_button(pItem, &pMenuButton); + + pThis->add_to_map(pToolItem, pMenuButton); } } - void add_to_map(GtkToolButton* pToolItem) + void add_to_map(GtkToolButton* pToolItem, GtkMenuButton* pMenuButton) { const gchar* pStr = gtk_buildable_get_name(GTK_BUILDABLE(pToolItem)); OString id(pStr, pStr ? strlen(pStr) : 0); m_aMap[id] = pToolItem; + if (pMenuButton) + m_aMenuButtonMap[id] = std::make_unique<GtkInstanceMenuButton>(pMenuButton, m_pBuilder, false); g_signal_connect(pToolItem, "clicked", G_CALLBACK(signalItemClicked), this); } @@ -6738,13 +6781,27 @@ public: virtual void set_item_active(const OString& rIdent, bool bActive) override { disable_item_notify_events(); - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(m_aMap[rIdent]), bActive); + + auto aFind = m_aMenuButtonMap.find(rIdent); + if (aFind != m_aMenuButtonMap.end()) + aFind->second->set_active(bActive); + else + { + GtkToolButton* pToolButton = m_aMap.find(rIdent)->second; + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton), bActive); + } + enable_item_notify_events(); } virtual bool get_item_active(const OString& rIdent) const override { - return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(m_aMap.find(rIdent)->second)); + auto aFind = m_aMenuButtonMap.find(rIdent); + if (aFind != m_aMenuButtonMap.end()) + return aFind->second->get_active(); + + GtkToolButton* pToolButton = m_aMap.find(rIdent)->second; + return gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pToolButton)); } virtual void insert_separator(int pos, const OUString& rId) override @@ -6755,6 +6812,11 @@ public: gtk_widget_show(GTK_WIDGET(pItem)); } + virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) override + { + m_aMenuButtonMap[rIdent]->set_popover(pPopover); + } + virtual ~GtkInstanceToolbar() override { for (auto& a : m_aMap) @@ -11864,6 +11926,15 @@ public: return std::make_unique<GtkInstanceContainer>(pContainer, this, bTakeOwnership); } + virtual std::unique_ptr<weld::Box> weld_box(const OString &id, bool bTakeOwnership) override + { + GtkBox* pBox = GTK_BOX(gtk_builder_get_object(m_pBuilder, id.getStr())); + if (!pBox) + return nullptr; + auto_add_parentless_widgets_to_container(GTK_WIDGET(pBox)); + return std::make_unique<GtkInstanceBox>(pBox, this, bTakeOwnership); + } + virtual std::unique_ptr<weld::Frame> weld_frame(const OString &id, bool bTakeOwnership) override { GtkFrame* pFrame = GTK_FRAME(gtk_builder_get_object(m_pBuilder, id.getStr())); |