Merge toolbar popup classes
Now that all popups are welded. Change-Id: I5ad8a4eb6b9512ea9dd075b56d0ae6ee201fff19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100597 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
This commit is contained in:
@@ -33,45 +33,7 @@ namespace com :: sun :: star :: frame { class XFrame; }
|
||||
namespace com :: sun :: star :: frame { struct FeatureStateEvent; }
|
||||
namespace svt { class FrameStatusListener; }
|
||||
|
||||
namespace svtools {
|
||||
|
||||
class SVT_DLLPUBLIC ToolbarPopupBase
|
||||
{
|
||||
friend class ToolbarPopupStatusListener;
|
||||
public:
|
||||
ToolbarPopupBase(const css::uno::Reference<css::frame::XFrame>& rFrame);
|
||||
virtual ~ToolbarPopupBase();
|
||||
|
||||
protected:
|
||||
void AddStatusListener( const OUString& rCommandURL );
|
||||
|
||||
// Forwarded from XStatusListener (subclasses must override this one to get the status updates):
|
||||
/// @throws css::uno::RuntimeException
|
||||
virtual void statusChanged(const css::frame::FeatureStateEvent& Event );
|
||||
|
||||
css::uno::Reference<css::frame::XFrame> mxFrame;
|
||||
rtl::Reference<svt::FrameStatusListener> mxStatusListener;
|
||||
};
|
||||
|
||||
class UNLESS_MERGELIBS(SVT_DLLPUBLIC) ToolbarPopup : public DockingWindow, public ToolbarPopupBase
|
||||
{
|
||||
public:
|
||||
ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
|
||||
vcl::Window* pParentWindow,
|
||||
const OString& rID, const OUString& rUIXMLDescription );
|
||||
virtual ~ToolbarPopup() override;
|
||||
virtual void dispose() override;
|
||||
|
||||
protected:
|
||||
void EndPopupMode();
|
||||
|
||||
private:
|
||||
void init();
|
||||
};
|
||||
|
||||
} // namespace svtools
|
||||
|
||||
class SVT_DLLPUBLIC WeldToolbarPopup : public svtools::ToolbarPopupBase
|
||||
class SVT_DLLPUBLIC WeldToolbarPopup
|
||||
{
|
||||
private:
|
||||
DECL_LINK(FocusHdl, weld::Widget&, void);
|
||||
@@ -80,14 +42,20 @@ protected:
|
||||
std::unique_ptr<weld::Builder> m_xBuilder;
|
||||
std::unique_ptr<weld::Container> m_xTopLevel;
|
||||
std::unique_ptr<weld::Container> m_xContainer;
|
||||
css::uno::Reference<css::frame::XFrame> m_xFrame;
|
||||
rtl::Reference<svt::FrameStatusListener> m_xStatusListener;
|
||||
|
||||
public:
|
||||
WeldToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
|
||||
weld::Widget* pParent, const OUString& rUIFile, const OString& rId);
|
||||
virtual ~WeldToolbarPopup() override;
|
||||
virtual ~WeldToolbarPopup();
|
||||
weld::Container* getTopLevel() { return m_xTopLevel.get(); }
|
||||
weld::Container* getContainer() { return m_xContainer.get(); }
|
||||
void AddStatusListener(const OUString& rCommandURL);
|
||||
|
||||
// Forwarded from XStatusListener (subclasses must override this one to get the status updates):
|
||||
/// @throws css::uno::RuntimeException
|
||||
virtual void statusChanged(const css::frame::FeatureStateEvent& Event);
|
||||
virtual void GrabFocus() = 0;
|
||||
};
|
||||
|
||||
@@ -116,10 +84,11 @@ public:
|
||||
void unsetPopover();
|
||||
};
|
||||
|
||||
class SVT_DLLPUBLIC InterimToolbarPopup final : public svtools::ToolbarPopup
|
||||
class SVT_DLLPUBLIC InterimToolbarPopup final : public DockingWindow
|
||||
{
|
||||
private:
|
||||
VclPtr<vcl::Window> m_xBox;
|
||||
css::uno::Reference<css::frame::XFrame> m_xFrame;
|
||||
std::unique_ptr<weld::Builder> m_xBuilder;
|
||||
std::unique_ptr<weld::Container> m_xContainer;
|
||||
std::unique_ptr<WeldToolbarPopup> m_xPopup;
|
||||
@@ -132,7 +101,7 @@ public:
|
||||
|
||||
virtual void GetFocus() override;
|
||||
|
||||
using ToolbarPopup::EndPopupMode;
|
||||
void EndPopupMode();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -170,9 +170,9 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg
|
||||
DrawViewMode eMode = DrawViewMode_DRAW;
|
||||
|
||||
// find out which view is running
|
||||
if( mxFrame.is() ) try
|
||||
if( m_xFrame.is() ) try
|
||||
{
|
||||
Reference< XPropertySet > xControllerSet( mxFrame->getController(), UNO_QUERY_THROW );
|
||||
Reference< XPropertySet > xControllerSet( m_xFrame->getController(), UNO_QUERY_THROW );
|
||||
xControllerSet->getPropertyValue( "DrawViewMode" ) >>= eMode;
|
||||
}
|
||||
catch( Exception& )
|
||||
@@ -220,7 +220,7 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg
|
||||
if( eMode != DrawViewMode_DRAW )
|
||||
return;
|
||||
|
||||
if( !mxFrame.is() )
|
||||
if( !m_xFrame.is() )
|
||||
return;
|
||||
|
||||
OUString sSlotStr;
|
||||
@@ -230,7 +230,7 @@ LayoutToolbarMenu::LayoutToolbarMenu(SlideLayoutController* pControl, weld::Widg
|
||||
else
|
||||
sSlotStr = ".uno:Undo";
|
||||
|
||||
css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, mxFrame);
|
||||
css::uno::Reference<css::graphic::XGraphic> xSlotImage = vcl::CommandInfoProvider::GetXGraphicForCommand(sSlotStr, m_xFrame);
|
||||
|
||||
OUString sSlotTitle;
|
||||
if( bInsertPage )
|
||||
|
@@ -36,9 +36,9 @@ using namespace ::com::sun::star::lang;
|
||||
using namespace ::com::sun::star::frame;
|
||||
using namespace ::com::sun::star::accessibility;
|
||||
|
||||
namespace svtools {
|
||||
namespace {
|
||||
|
||||
static vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow )
|
||||
vcl::Window* GetTopMostParentSystemWindow( vcl::Window* pWindow )
|
||||
{
|
||||
OSL_ASSERT( pWindow );
|
||||
if ( pWindow )
|
||||
@@ -65,18 +65,18 @@ class ToolbarPopupStatusListener : public svt::FrameStatusListener
|
||||
{
|
||||
public:
|
||||
ToolbarPopupStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame,
|
||||
ToolbarPopupBase& rToolbarPopup );
|
||||
WeldToolbarPopup& rToolbarPopup );
|
||||
|
||||
virtual void SAL_CALL dispose() override;
|
||||
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
|
||||
|
||||
ToolbarPopupBase* mpPopup;
|
||||
WeldToolbarPopup* mpPopup;
|
||||
};
|
||||
|
||||
|
||||
ToolbarPopupStatusListener::ToolbarPopupStatusListener(
|
||||
const css::uno::Reference< css::frame::XFrame >& xFrame,
|
||||
ToolbarPopupBase& rToolbarPopup )
|
||||
WeldToolbarPopup& rToolbarPopup )
|
||||
: svt::FrameStatusListener( ::comphelper::getProcessComponentContext(), xFrame )
|
||||
, mpPopup( &rToolbarPopup )
|
||||
{
|
||||
@@ -96,89 +96,40 @@ void SAL_CALL ToolbarPopupStatusListener::statusChanged( const css::frame::Featu
|
||||
mpPopup->statusChanged( Event );
|
||||
}
|
||||
|
||||
ToolbarPopupBase::ToolbarPopupBase(const css::uno::Reference<css::frame::XFrame>& rFrame)
|
||||
: mxFrame(rFrame)
|
||||
}
|
||||
|
||||
void WeldToolbarPopup::AddStatusListener(const OUString& rCommandURL)
|
||||
{
|
||||
if (!m_xStatusListener.is())
|
||||
m_xStatusListener.set(new ToolbarPopupStatusListener(m_xFrame, *this));
|
||||
|
||||
m_xStatusListener->addStatusListener(rCommandURL);
|
||||
}
|
||||
|
||||
void WeldToolbarPopup::statusChanged(const css::frame::FeatureStateEvent& /*Event*/)
|
||||
{
|
||||
}
|
||||
|
||||
ToolbarPopupBase::~ToolbarPopupBase()
|
||||
{
|
||||
if (mxStatusListener.is())
|
||||
{
|
||||
mxStatusListener->dispose();
|
||||
mxStatusListener.clear();
|
||||
}
|
||||
}
|
||||
|
||||
ToolbarPopup::ToolbarPopup( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow,
|
||||
const OString& rID, const OUString& rUIXMLDescription )
|
||||
: DockingWindow(pParentWindow, rID, rUIXMLDescription, rFrame)
|
||||
, ToolbarPopupBase(rFrame)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void ToolbarPopup::init()
|
||||
{
|
||||
vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
|
||||
if ( pWindow )
|
||||
static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow( this );
|
||||
}
|
||||
|
||||
ToolbarPopup::~ToolbarPopup()
|
||||
{
|
||||
disposeOnce();
|
||||
}
|
||||
|
||||
void ToolbarPopup::dispose()
|
||||
{
|
||||
vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
|
||||
if ( pWindow )
|
||||
static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow( this );
|
||||
|
||||
if ( mxStatusListener.is() )
|
||||
{
|
||||
mxStatusListener->dispose();
|
||||
mxStatusListener.clear();
|
||||
}
|
||||
|
||||
mxFrame.clear();
|
||||
DockingWindow::dispose();
|
||||
}
|
||||
|
||||
void ToolbarPopupBase::AddStatusListener( const OUString& rCommandURL )
|
||||
{
|
||||
if( !mxStatusListener.is() )
|
||||
mxStatusListener.set( new ToolbarPopupStatusListener( mxFrame, *this ) );
|
||||
|
||||
mxStatusListener->addStatusListener( rCommandURL );
|
||||
}
|
||||
|
||||
void ToolbarPopupBase::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ )
|
||||
{
|
||||
}
|
||||
|
||||
void ToolbarPopup::EndPopupMode()
|
||||
void InterimToolbarPopup::EndPopupMode()
|
||||
{
|
||||
GetDockingManager()->EndPopupMode(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
WeldToolbarPopup::WeldToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
|
||||
weld::Widget* pParent, const OUString& rUIFile,
|
||||
const OString& rId)
|
||||
: ToolbarPopupBase(rFrame)
|
||||
, m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
|
||||
: m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
|
||||
, m_xTopLevel(m_xBuilder->weld_container(rId))
|
||||
, m_xContainer(m_xBuilder->weld_container("container"))
|
||||
, m_xFrame(rFrame)
|
||||
{
|
||||
m_xTopLevel->connect_focus_in(LINK(this, WeldToolbarPopup, FocusHdl));
|
||||
}
|
||||
|
||||
WeldToolbarPopup::~WeldToolbarPopup()
|
||||
{
|
||||
if (m_xStatusListener.is())
|
||||
m_xStatusListener->dispose();
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(WeldToolbarPopup, FocusHdl, weld::Widget&, void)
|
||||
@@ -224,19 +175,24 @@ IMPL_LINK_NOARG(ToolbarPopupContainer, FocusHdl, weld::Widget&, void)
|
||||
|
||||
InterimToolbarPopup::InterimToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParent,
|
||||
std::unique_ptr<WeldToolbarPopup> xPopup)
|
||||
: ToolbarPopup(rFrame, pParent, "InterimDockParent", "svx/ui/interimdockparent.ui")
|
||||
: DockingWindow(pParent, "InterimDockParent", "svx/ui/interimdockparent.ui", rFrame)
|
||||
, m_xBox(get("box"))
|
||||
, m_xFrame(rFrame)
|
||||
, m_xBuilder(Application::CreateInterimBuilder(m_xBox.get(), "svx/ui/interimparent.ui"))
|
||||
, m_xContainer(m_xBuilder->weld_container("container"))
|
||||
, m_xPopup(std::move(xPopup))
|
||||
{
|
||||
vcl::Window* pWindow = GetTopMostParentSystemWindow(this);
|
||||
if (pWindow)
|
||||
static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow(this);
|
||||
|
||||
// move the WeldToolbarPopup contents into this interim toolbar so welded contents can appear as a dropdown in an unwelded toolbar
|
||||
m_xPopup->getTopLevel()->move(m_xPopup->getContainer(), m_xContainer.get());
|
||||
}
|
||||
|
||||
void InterimToolbarPopup::GetFocus()
|
||||
{
|
||||
ToolbarPopup::GetFocus();
|
||||
DockingWindow::GetFocus();
|
||||
if (!m_xPopup)
|
||||
return;
|
||||
m_xPopup->GrabFocus();
|
||||
@@ -244,11 +200,15 @@ void InterimToolbarPopup::GetFocus()
|
||||
|
||||
void InterimToolbarPopup::dispose()
|
||||
{
|
||||
vcl::Window* pWindow = GetTopMostParentSystemWindow(this);
|
||||
if (pWindow)
|
||||
static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow(this);
|
||||
|
||||
// if we have focus when disposed, pick the document window as destination
|
||||
// for focus rather than let it go to an arbitrary windows
|
||||
if (HasFocus())
|
||||
{
|
||||
if (auto xWindow = mxFrame->getContainerWindow())
|
||||
if (auto xWindow = m_xFrame->getContainerWindow())
|
||||
xWindow->setFocus();
|
||||
}
|
||||
// move the contents back where it belongs
|
||||
@@ -256,7 +216,8 @@ void InterimToolbarPopup::dispose()
|
||||
m_xPopup.reset();
|
||||
m_xContainer.reset();
|
||||
m_xBox.clear();
|
||||
ToolbarPopup::dispose();
|
||||
m_xFrame.clear();
|
||||
DockingWindow::dispose();
|
||||
}
|
||||
|
||||
InterimToolbarPopup::~InterimToolbarPopup()
|
||||
|
@@ -2413,7 +2413,7 @@ SvxLineWindow_Impl::SvxLineWindow_Impl(SvxFrameToolBoxControl* pControl, weld::W
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference< lang::XServiceInfo > xServices(mxFrame->getController()->getModel(), UNO_QUERY_THROW);
|
||||
Reference< lang::XServiceInfo > xServices(m_xFrame->getController()->getModel(), UNO_QUERY_THROW);
|
||||
m_bIsWriter = xServices->supportsService("com.sun.star.text.TextDocument");
|
||||
}
|
||||
catch(const uno::Exception& )
|
||||
|
Reference in New Issue
Block a user