[Libreoffice-commits] core.git: 8 commits - include/svtools include/svx officecfg/registry sc/source sd/source svtools/source svx/source svx/util sw/source vcl/source
Maxim Monastirsky
momonasmon at gmail.com
Wed Oct 5 12:38:55 UTC 2016
include/svtools/popupwindowcontroller.hxx | 15
include/svtools/toolbarmenu.hxx | 41 +-
include/svx/tbcontrl.hxx | 11
officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu | 11
sc/source/ui/app/scdll.cxx | 1
sd/source/ui/app/sddll.cxx | 1
svtools/source/control/toolbarmenu.cxx | 123 +++---
svtools/source/control/toolbarmenuimp.hxx | 6
svtools/source/uno/popupwindowcontroller.cxx | 122 +++---
svx/source/tbxctrls/tbcontrl.cxx | 181 +++++-----
svx/util/svxcore.component | 4
sw/source/uibase/app/swmodule.cxx | 1
vcl/source/window/dockmgr.cxx | 81 +++-
13 files changed, 321 insertions(+), 277 deletions(-)
New commits:
commit 944f81c544ff5b9e47d5e0764814d19df71b1764
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed Oct 5 12:29:35 2016 +0300
SvxFrameWindow_Impl: Try to fix size calculation
Change-Id: I7119f46a483615636cef57432a2c536af8ecd4c5
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index bc26442..d542370 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -105,8 +105,6 @@
// don't make more than 15 entries visible at once
#define MAX_STYLES_ENTRIES 15
-static void lcl_CalcSizeValueSet( vcl::Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
-
// namespaces
using namespace ::editeng;
using namespace ::com::sun::star;
@@ -256,10 +254,11 @@ private:
ImageList aImgList;
bool bParagraphMode;
+ void InitImageList();
+ void CalcSizeValueSet();
DECL_LINK( SelectHdl, ValueSet*, void );
protected:
- virtual void Resize() override;
virtual void GetFocus() override;
public:
@@ -1603,18 +1602,7 @@ SvxFrameWindow_Impl::SvxFrameWindow_Impl (const Reference< XFrame >& rFrame, vcl
bParagraphMode(false)
{
AddStatusListener(".uno:BorderReducedMode");
- aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
-
- if( pParentWindow->GetDPIScaleFactor() > 1 )
- {
- for (short i = 0; i < aImgList.GetImageCount(); i++)
- {
- OUString rImageName = aImgList.GetImageName(i);
- BitmapEx b = aImgList.GetImage(rImageName).GetBitmapEx();
- b.Scale(pParentWindow->GetDPIScaleFactor(), pParentWindow->GetDPIScaleFactor());
- aImgList.ReplaceImage(rImageName, Image(b));
- }
- }
+ InitImageList();
/*
* 1 2 3 4
@@ -1637,8 +1625,7 @@ SvxFrameWindow_Impl::SvxFrameWindow_Impl (const Reference< XFrame >& rFrame, vcl
aFrameSet->SetColCount( 4 );
aFrameSet->SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
-
- lcl_CalcSizeValueSet( *this, *aFrameSet.get(), Size( 20 * pParentWindow->GetDPIScaleFactor(), 20 * pParentWindow->GetDPIScaleFactor() ));
+ CalcSizeValueSet();
SetHelpId( HID_POPUP_FRAME );
SetText( SVX_RESSTR(RID_SVXSTR_FRAME) );
@@ -1673,7 +1660,7 @@ void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
{
- aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
+ InitImageList();
sal_uInt16 nNumOfItems = aFrameSet->GetItemCount();
@@ -1808,12 +1795,6 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void)
mpController->dispatchCommand( ".uno:SetBorderStyle", aArgs );
}
-void SvxFrameWindow_Impl::Resize()
-{
- const Size aSize(this->GetOutputSizePixel());
- aFrameSet->SetPosSizePixel(Point(2,2), Size(aSize.Width() - 4, aSize.Height() - 4));
-}
-
void SvxFrameWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
throw ( css::uno::RuntimeException )
{
@@ -1844,13 +1825,39 @@ void SvxFrameWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rE
if ( bResize )
{
- lcl_CalcSizeValueSet( *this, *aFrameSet.get(), Size( 20, 20 ));
+ CalcSizeValueSet();
}
}
}
}
}
+void SvxFrameWindow_Impl::CalcSizeValueSet()
+{
+ Size aItemSize( 20 * GetParent()->GetDPIScaleFactor(), 20 * GetParent()->GetDPIScaleFactor() );
+ Size aSize = aFrameSet->CalcWindowSizePixel( aItemSize );
+ aFrameSet->SetPosSizePixel( Point( 2, 2 ), aSize );
+ aSize.Width() += 4;
+ aSize.Height() += 4;
+ SetOutputSizePixel( aSize );
+}
+
+void SvxFrameWindow_Impl::InitImageList()
+{
+ aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
+
+ if( GetParent()->GetDPIScaleFactor() > 1 )
+ {
+ for (short i = 0; i < aImgList.GetImageCount(); i++)
+ {
+ OUString rImageName = aImgList.GetImageName(i);
+ BitmapEx b = aImgList.GetImage(rImageName).GetBitmapEx();
+ b.Scale(GetParent()->GetDPIScaleFactor(), GetParent()->GetDPIScaleFactor());
+ aImgList.ReplaceImage(rImageName, Image(b));
+ }
+ }
+}
+
static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
{
return SvxBorderLine::threeDMediumColor( aMain );
@@ -3076,14 +3083,6 @@ void SvxCurrencyToolBoxControl::Select( sal_uInt16 nSelectModifier )
SfxToolBoxControl::Select( nSelectModifier );
}
-static void lcl_CalcSizeValueSet( vcl::Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
-{
- Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
- aSize.Width() += 4;
- aSize.Height() += 4;
- rWin.SetOutputSizePixel( aSize );
-}
-
Reference< css::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
{
FillList();
commit c26afa7812d5b9f8e25f64ebab8515f5b59238c1
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed Oct 5 01:58:06 2016 +0300
Base SvxFrameWindow_Impl on ToolbarPopup
Change-Id: I2061125068bd94b5cdc46aa18a7aa7e21726e22c
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index ed9a38e..bc26442 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -31,6 +31,7 @@
#include <svtools/valueset.hxx>
#include <svtools/ctrlbox.hxx>
#include <svtools/popupwindowcontroller.hxx>
+#include <svtools/toolbarmenu.hxx>
#include <svl/style.hxx>
#include <svtools/ctrltool.hxx>
#include <svtools/borderhelper.hxx>
@@ -247,12 +248,11 @@ void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt )
ValueSet::MouseButtonUp(rMEvt);
}
-class SvxFrameWindow_Impl : public SfxPopupWindow
+class SvxFrameWindow_Impl : public svtools::ToolbarPopup
{
- using FloatingWindow::StateChanged;
-
private:
VclPtr<SvxFrmValueSet_Impl> aFrameSet;
+ rtl::Reference< svt::ToolboxController > mpController;
ImageList aImgList;
bool bParagraphMode;
@@ -263,14 +263,11 @@ protected:
virtual void GetFocus() override;
public:
- SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow );
+ SvxFrameWindow_Impl( const Reference< XFrame >& rFrame, vcl::Window* pParentWindow, svt::ToolboxController* pController );
virtual ~SvxFrameWindow_Impl() override;
virtual void dispose() override;
- void StartSelection();
-
- virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
- const SfxPoolItem* pState ) override;
+ virtual void statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
};
@@ -1599,12 +1596,12 @@ Color BorderColorStatus::GetColor()
}
-SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow ) :
- SfxPopupWindow( nId, rFrame, pParentWindow, WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_CLOSEABLE | WB_MOVEABLE ),
+SvxFrameWindow_Impl::SvxFrameWindow_Impl (const Reference< XFrame >& rFrame, vcl::Window* pParentWindow, svt::ToolboxController* pController ) :
+ ToolbarPopup( rFrame, pParentWindow, WB_STDPOPUP | WB_MOVEABLE | WB_CLOSEABLE ),
aFrameSet ( VclPtr<SvxFrmValueSet_Impl>::Create(this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT )) ),
+ mpController( pController ),
bParagraphMode(false)
{
- BindListener();
AddStatusListener(".uno:BorderReducedMode");
aImgList = ImageList( SVX_RES( RID_SVXIL_FRAME ) );
@@ -1656,20 +1653,23 @@ SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
void SvxFrameWindow_Impl::dispose()
{
- UnbindListener();
+ mpController.clear();
aFrameSet.disposeAndClear();
- SfxPopupWindow::dispose();
+ ToolbarPopup::dispose();
}
void SvxFrameWindow_Impl::GetFocus()
{
if (aFrameSet)
+ {
aFrameSet->GrabFocus();
+ aFrameSet->StartSelection();
+ }
}
void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
{
- SfxPopupWindow::DataChanged( rDCEvt );
+ ToolbarPopup::DataChanged( rDCEvt );
if( ( rDCEvt.GetType() == DataChangedEventType::SETTINGS ) && ( rDCEvt.GetFlags() & AllSettingsFlags::STYLE ) )
{
@@ -1805,9 +1805,7 @@ IMPL_LINK_NOARG(SvxFrameWindow_Impl, SelectHdl, ValueSet*, void)
aFrameSet->SetNoSelection();
}
- SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
- ".uno:SetBorderStyle",
- aArgs );
+ mpController->dispatchCommand( ".uno:SetBorderStyle", aArgs );
}
void SvxFrameWindow_Impl::Resize()
@@ -1816,16 +1814,15 @@ void SvxFrameWindow_Impl::Resize()
aFrameSet->SetPosSizePixel(Point(2,2), Size(aSize.Width() - 4, aSize.Height() - 4));
}
-void SvxFrameWindow_Impl::StateChanged(
- sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
+void SvxFrameWindow_Impl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
+ throw ( css::uno::RuntimeException )
{
- if ( pState && nSID == SID_BORDER_REDUCED_MODE)
+ if ( rEvent.FeatureURL.Complete == ".uno:BorderReducedMode" )
{
- const SfxBoolItem* pItem = dynamic_cast<const SfxBoolItem*>( pState );
-
- if ( pItem )
+ bool bValue;
+ if ( rEvent.State >>= bValue )
{
- bParagraphMode = pItem->GetValue();
+ bParagraphMode = bValue;
//initial calls mustn't insert or remove elements
if(aFrameSet->GetItemCount())
{
@@ -1852,12 +1849,6 @@ void SvxFrameWindow_Impl::StateChanged(
}
}
}
- SfxPopupWindow::StateChanged( nSID, eState, pState );
-}
-
-void SvxFrameWindow_Impl::StartSelection()
-{
- aFrameSet->StartSelection();
}
static Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
@@ -2932,7 +2923,7 @@ void SvxFrameToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any
VclPtr<vcl::Window> SvxFrameToolBoxControl::createPopupWindow( vcl::Window* pParent )
{
- return VclPtr<SvxFrameWindow_Impl>::Create( 0, m_xFrame, pParent );
+ return VclPtr<SvxFrameWindow_Impl>::Create( m_xFrame, pParent, this );
}
OUString SvxFrameToolBoxControl::getImplementationName()
commit 0ef0e08f2f0e2f59cf7a64cd981f42c5e141f9b4
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Wed Oct 5 09:56:50 2016 +0300
Split some stuff from ToolbarMenu to a base class
i.e. implement "todo: move to new base class that will replace
SfxPopupWindow"
Change-Id: I1b300e1e0c6423bf27d9dae7d75703b988afb154
diff --git a/include/svtools/toolbarmenu.hxx b/include/svtools/toolbarmenu.hxx
index 408b2f4..e2b47f4 100644
--- a/include/svtools/toolbarmenu.hxx
+++ b/include/svtools/toolbarmenu.hxx
@@ -36,15 +36,39 @@
#include <vcl/dockwin.hxx>
class ValueSet;
+namespace svt { class FrameStatusListener; }
namespace svtools {
class ToolbarMenuEntry;
struct ToolbarMenu_Impl;
-class SVT_DLLPUBLIC ToolbarMenu : public DockingWindow
+class SVT_DLLPUBLIC ToolbarPopup : public DockingWindow
+{
+ friend class ToolbarPopupStatusListener;
+public:
+ ToolbarPopup(const css::uno::Reference<css::frame::XFrame>& rFrame,
+ vcl::Window* pParentWindow,
+ WinBits nBits );
+ virtual ~ToolbarPopup() override;
+ virtual void dispose() override;
+
+protected:
+ void AddStatusListener( const OUString& rCommandURL );
+
+ bool IsInPopupMode();
+ void EndPopupMode();
+
+ // Forwarded from XStatusListener (subclasses must override this one to get the status updates):
+ virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException, std::exception);
+
+private:
+ css::uno::Reference< css::frame::XFrame > mxFrame;
+ rtl::Reference< svt::FrameStatusListener > mxStatusListener;
+};
+
+class SVT_DLLPUBLIC ToolbarMenu : public ToolbarPopup
{
- friend class ToolbarMenuStatusListener;
friend struct ToolbarMenu_Impl;
public:
ToolbarMenu(const css::uno::Reference<css::frame::XFrame>& rFrame,
@@ -92,25 +116,12 @@ public:
protected:
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
- // todo: move to new base class that will replace SfxPopupWindow
- void AddStatusListener( const OUString& rCommandURL );
-
- bool IsInPopupMode();
- void EndPopupMode();
-
- // Forwarded from XStatusListener (subclasses must override this one to get
- // the status updates):
- virtual void statusChanged(const css::frame::FeatureStateEvent& Event ) throw (css::uno::RuntimeException, std::exception);
-
void StateChanged( StateChangedType nType ) override;
void DataChanged( const DataChangedEvent& rDCEvt ) override;
private:
DECL_LINK( HighlightHdl, ValueSet*, void );
- void initStatusListener();
-
- void implInit(const css::uno::Reference<css::frame::XFrame>& rFrame);
void initWindow();
Size implCalcSize();
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index 214416b..897c423 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -30,6 +30,7 @@
#include <vcl/toolbox.hxx>
#include <vcl/settings.hxx>
+#include <svtools/framestatuslistener.hxx>
#include <svtools/valueset.hxx>
#include <svtools/toolbarmenu.hxx>
#include "toolbarmenuimp.hxx"
@@ -181,9 +182,8 @@ Reference< XAccessible > ToolbarMenuEntry::getAccessibleChild( sal_Int32 index )
}
-ToolbarMenu_Impl::ToolbarMenu_Impl( ToolbarMenu& rMenu, const css::uno::Reference< css::frame::XFrame >& xFrame )
+ToolbarMenu_Impl::ToolbarMenu_Impl( ToolbarMenu& rMenu )
: mrMenu( rMenu )
-, mxFrame( xFrame )
, mnCheckPos(0)
, mnImagePos(0)
, mnTextPos(0)
@@ -403,24 +403,15 @@ IMPL_LINK_NOARG( ToolbarMenu, HighlightHdl, ValueSet*, void )
mpImpl->notifyHighlightedEntry();
}
-ToolbarMenu::ToolbarMenu( const Reference< XFrame >& rFrame, vcl::Window* pParentWindow, WinBits nBits )
- : DockingWindow(pParentWindow, nBits)
-{
- implInit(rFrame);
-}
-
-void ToolbarMenu::implInit(const Reference< XFrame >& rFrame)
+ToolbarMenu::ToolbarMenu( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits )
+ : ToolbarPopup(rFrame, pParentWindow, nBits)
{
- mpImpl.reset( new ToolbarMenu_Impl( *this, rFrame ) );
+ mpImpl.reset( new ToolbarMenu_Impl( *this ) );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
SetControlBackground( rStyleSettings.GetMenuColor() );
initWindow();
-
- vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
- if ( pWindow )
- static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->AddWindow( this );
}
@@ -431,16 +422,6 @@ ToolbarMenu::~ToolbarMenu()
void ToolbarMenu::dispose()
{
- vcl::Window* pWindow = GetTopMostParentSystemWindow( this );
- if ( pWindow )
- static_cast<SystemWindow*>(pWindow)->GetTaskPaneList()->RemoveWindow( this );
-
- if ( mpImpl->mxStatusListener.is() )
- {
- mpImpl->mxStatusListener->dispose();
- mpImpl->mxStatusListener.clear();
- }
-
mpImpl->mxAccessible.clear();
std::unique_ptr<ToolbarMenu_Impl> pImpl = std::move(mpImpl);
@@ -448,7 +429,7 @@ void ToolbarMenu::dispose()
pImpl->maEntryVector.clear();
- DockingWindow::dispose();
+ ToolbarPopup::dispose();
}
@@ -704,7 +685,7 @@ void ToolbarMenu::GetFocus()
if( mpImpl && mpImpl->mnHighlightedEntry == -1 )
implChangeHighlightEntry( 0 );
- DockingWindow::GetFocus();
+ ToolbarPopup::GetFocus();
}
@@ -713,7 +694,7 @@ void ToolbarMenu::LoseFocus()
if( mpImpl && mpImpl->mnHighlightedEntry != -1 )
implChangeHighlightEntry( -1 );
- DockingWindow::LoseFocus();
+ ToolbarPopup::LoseFocus();
}
@@ -1377,13 +1358,13 @@ void ToolbarMenu::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
void ToolbarMenu::RequestHelp( const HelpEvent& rHEvt )
{
- DockingWindow::RequestHelp( rHEvt );
+ ToolbarPopup::RequestHelp( rHEvt );
}
void ToolbarMenu::StateChanged( StateChangedType nType )
{
- DockingWindow::StateChanged( nType );
+ ToolbarPopup::StateChanged( nType );
if ( ( nType == StateChangedType::ControlForeground ) || ( nType == StateChangedType::ControlBackground ) )
{
@@ -1395,7 +1376,7 @@ void ToolbarMenu::StateChanged( StateChangedType nType )
void ToolbarMenu::DataChanged( const DataChangedEvent& rDCEvt )
{
- DockingWindow::DataChanged( rDCEvt );
+ ToolbarPopup::DataChanged( rDCEvt );
if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
(rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
@@ -1428,69 +1409,89 @@ Reference< css::accessibility::XAccessible > ToolbarMenu::CreateAccessible()
}
-// todo: move to new base class that will replace SfxPopupWindo
-void ToolbarMenu::AddStatusListener( const OUString& rCommandURL )
-{
- initStatusListener();
- mpImpl->mxStatusListener->addStatusListener( rCommandURL );
-}
-
-
-void ToolbarMenu::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ ) throw ( css::uno::RuntimeException, std::exception )
-{
-}
-
-
-class ToolbarMenuStatusListener : public svt::FrameStatusListener
+class ToolbarPopupStatusListener : public svt::FrameStatusListener
{
public:
- ToolbarMenuStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame,
- ToolbarMenu& rToolbarMenu );
+ ToolbarPopupStatusListener( const css::uno::Reference< css::frame::XFrame >& xFrame,
+ ToolbarPopup& rToolbarPopup );
virtual void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
- VclPtr<ToolbarMenu> mpMenu;
+ VclPtr<ToolbarPopup> mpPopup;
};
-ToolbarMenuStatusListener::ToolbarMenuStatusListener(
+ToolbarPopupStatusListener::ToolbarPopupStatusListener(
const css::uno::Reference< css::frame::XFrame >& xFrame,
- ToolbarMenu& rToolbarMenu )
+ ToolbarPopup& rToolbarPopup )
: svt::FrameStatusListener( ::comphelper::getProcessComponentContext(), xFrame )
-, mpMenu( &rToolbarMenu )
+, mpPopup( &rToolbarPopup )
{
}
-void SAL_CALL ToolbarMenuStatusListener::dispose() throw (css::uno::RuntimeException, std::exception)
+void SAL_CALL ToolbarPopupStatusListener::dispose() throw (css::uno::RuntimeException, std::exception)
{
- mpMenu.clear();
+ mpPopup.clear();
svt::FrameStatusListener::dispose();
}
-void SAL_CALL ToolbarMenuStatusListener::statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception )
+void SAL_CALL ToolbarPopupStatusListener::statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception )
{
- if( mpMenu )
- mpMenu->statusChanged( Event );
+ if( mpPopup )
+ mpPopup->statusChanged( Event );
}
+ToolbarPopup::ToolbarPopup( const css::uno::Reference<css::frame::XFrame>& rFrame, vcl::Window* pParentWindow, WinBits nBits )
+ : DockingWindow(pParentWindow, nBits)
+ , mxFrame( rFrame )
+{
+ 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 ToolbarMenu::initStatusListener()
+void ToolbarPopup::AddStatusListener( const OUString& rCommandURL )
{
- if( !mpImpl->mxStatusListener.is() )
- mpImpl->mxStatusListener.set( new ToolbarMenuStatusListener( mpImpl->mxFrame, *this ) );
+ if( !mxStatusListener.is() )
+ mxStatusListener.set( new ToolbarPopupStatusListener( mxFrame, *this ) );
+
+ mxStatusListener->addStatusListener( rCommandURL );
}
+void ToolbarPopup::statusChanged( const css::frame::FeatureStateEvent& /*Event*/ ) throw ( css::uno::RuntimeException, std::exception )
+{
+}
-bool ToolbarMenu::IsInPopupMode()
+bool ToolbarPopup::IsInPopupMode()
{
return GetDockingManager()->IsInPopupMode(this);
}
-
-void ToolbarMenu::EndPopupMode()
+void ToolbarPopup::EndPopupMode()
{
GetDockingManager()->EndPopupMode(this);
}
diff --git a/svtools/source/control/toolbarmenuimp.hxx b/svtools/source/control/toolbarmenuimp.hxx
index 2a16414..6943fba 100644
--- a/svtools/source/control/toolbarmenuimp.hxx
+++ b/svtools/source/control/toolbarmenuimp.hxx
@@ -40,8 +40,6 @@
#include <memory>
#include <vector>
-#include <svtools/framestatuslistener.hxx>
-
namespace svtools {
struct ToolbarMenu_Impl;
@@ -241,8 +239,6 @@ struct ToolbarMenu_Impl
{
ToolbarMenu& mrMenu;
- css::uno::Reference< css::frame::XFrame > mxFrame;
- rtl::Reference< svt::FrameStatusListener > mxStatusListener;
rtl::Reference< ToolbarMenuAcc > mxAccessible;
css::uno::Reference< css::accessibility::XAccessible > mxOldSelection;
@@ -260,7 +256,7 @@ struct ToolbarMenu_Impl
Link<ToolbarMenu*,void> maSelectHdl;
- ToolbarMenu_Impl( ToolbarMenu& rMenu, const css::uno::Reference< css::frame::XFrame >& xFrame );
+ ToolbarMenu_Impl( ToolbarMenu& rMenu );
~ToolbarMenu_Impl();
void setAccessible( ToolbarMenuAcc* pAccessible );
commit fd22d2d9e1935f19a900a339995827bc7a795cb7
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Tue Oct 4 23:13:56 2016 +0300
Base SvxFrameToolBoxControl on PopupWindowController
Change-Id: I7666c7c5c99b1705bc8ece2913c2cdf9fdecced3
diff --git a/include/svx/tbcontrl.hxx b/include/svx/tbcontrl.hxx
index 6785370..1067fa0 100644
--- a/include/svx/tbcontrl.hxx
+++ b/include/svx/tbcontrl.hxx
@@ -254,17 +254,6 @@ public:
void setColorSelectFunction(const ColorSelectFunction& aColorSelectFunction);
};
-class SVX_DLLPUBLIC SvxFrameToolBoxControl : public SfxToolBoxControl
-{
-public:
- SFX_DECL_TOOLBOX_CONTROL();
- SvxFrameToolBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rToolBox);
-
- virtual VclPtr<SfxPopupWindow> CreatePopupWindow() override;
- virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
- const SfxPoolItem* pState) override;
-};
-
class SVX_DLLPUBLIC SvxFrameLineStyleToolBoxControl : public SfxToolBoxControl
{
public:
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 096ed33..9f0e3ec 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -1082,6 +1082,17 @@
<value>com.sun.star.comp.sfx2.ClassificationCategoriesController</value>
</prop>
</node>
+ <node oor:name="com.sun.star.comp.svx.FrameToolBoxControl" oor:op="replace">
+ <prop oor:name="Command">
+ <value>.uno:SetBorderStyle</value>
+ </prop>
+ <prop oor:name="Module">
+ <value/>
+ </prop>
+ <prop oor:name="Controller">
+ <value>com.sun.star.comp.svx.FrameToolBoxControl</value>
+ </prop>
+ </node>
<node oor:name="c4" oor:op="replace" install:module="reportbuilder">
<prop oor:name="Command">
<value>.uno:FontColor</value>
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
index 355552d..abc587c 100644
--- a/sc/source/ui/app/scdll.cxx
+++ b/sc/source/ui/app/scdll.cxx
@@ -167,7 +167,6 @@ void ScDLL::Init()
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_BACK_COLOR, pMod);
- SvxFrameToolBoxControl ::RegisterControl(SID_ATTR_BORDER, pMod);
SvxFrameLineStyleToolBoxControl ::RegisterControl(SID_FRAME_LINESTYLE, pMod);
SvxColorToolBoxControl ::RegisterControl(SID_FRAME_LINECOLOR, pMod);
SvxClipBoardControl ::RegisterControl(SID_PASTE, pMod );
diff --git a/sd/source/ui/app/sddll.cxx b/sd/source/ui/app/sddll.cxx
index c63d2b6..035fda3 100644
--- a/sd/source/ui/app/sddll.cxx
+++ b/sd/source/ui/app/sddll.cxx
@@ -237,7 +237,6 @@ void SdDLL::RegisterControllers(SdModule* pMod)
SvxTableToolBoxControl::RegisterControl(SID_INSERT_TABLE, pMod );
SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
SvxColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
- SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
SvxTbxCtlDraw::RegisterControl(SID_INSERT_DRAW, pMod );
EmojiPopup::RegisterControl(SID_EMOJI_CONTROL, pMod );
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index cba6820..ed9a38e 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -30,6 +30,7 @@
#include <vcl/vclptr.hxx>
#include <svtools/valueset.hxx>
#include <svtools/ctrlbox.hxx>
+#include <svtools/popupwindowcontroller.hxx>
#include <svl/style.hxx>
#include <svtools/ctrltool.hxx>
#include <svtools/borderhelper.hxx>
@@ -115,7 +116,6 @@ using namespace ::com::sun::star::lang;
SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
-SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
SFX_IMPL_TOOLBOX_CONTROL( SvxCurrencyToolBoxControl, SfxBoolItem );
@@ -1600,7 +1600,7 @@ Color BorderColorStatus::GetColor()
SvxFrameWindow_Impl::SvxFrameWindow_Impl( sal_uInt16 nId, const Reference< XFrame >& rFrame, vcl::Window* pParentWindow ) :
- SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP | WB_OWNERDRAWDECORATION ) ),
+ SfxPopupWindow( nId, rFrame, pParentWindow, WB_STDPOPUP | WB_OWNERDRAWDECORATION | WB_CLOSEABLE | WB_MOVEABLE ),
aFrameSet ( VclPtr<SvxFrmValueSet_Impl>::Create(this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT )) ),
bParagraphMode(false)
{
@@ -2898,40 +2898,61 @@ void SvxColorToolBoxControl::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod
// class SvxFrameToolBoxControl --------------------------------------------
-SvxFrameToolBoxControl::SvxFrameToolBoxControl(
- sal_uInt16 nSlotId,
- sal_uInt16 nId,
- ToolBox& rTbx )
- : SfxToolBoxControl( nSlotId, nId, rTbx )
+class SvxFrameToolBoxControl : public svt::PopupWindowController
+{
+public:
+ explicit SvxFrameToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rContext );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rArguments ) throw ( css::uno::Exception, css::uno::RuntimeException, std::exception ) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw ( css::uno::RuntimeException, std::exception ) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw ( css::uno::RuntimeException, std::exception ) override;
+
+private:
+ virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
+ using svt::ToolboxController::createPopupWindow;
+};
+
+SvxFrameToolBoxControl::SvxFrameToolBoxControl( const css::uno::Reference< css::uno::XComponentContext >& rContext )
+ : svt::PopupWindowController( rContext, nullptr, OUString() )
{
- rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits( nId ) );
}
-VclPtr<SfxPopupWindow> SvxFrameToolBoxControl::CreatePopupWindow()
+void SvxFrameToolBoxControl::initialize( const css::uno::Sequence< css::uno::Any >& rArguments )
+ throw ( css::uno::Exception, css::uno::RuntimeException, std::exception )
{
- VclPtr<SvxFrameWindow_Impl> pFrameWin = VclPtr<SvxFrameWindow_Impl>::Create(
- GetSlotId(), m_xFrame, &GetToolBox() );
+ svt::PopupWindowController::initialize( rArguments );
+ ToolBox* pToolBox = nullptr;
+ sal_uInt16 nId = 0;
+ if ( getToolboxId( nId, &pToolBox ) )
+ pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
+}
- pFrameWin->StartPopupMode( &GetToolBox(),
- FloatWinPopupFlags::GrabFocus |
- FloatWinPopupFlags::AllowTearOff |
- FloatWinPopupFlags::NoAppFocusClose );
- pFrameWin->StartSelection();
- SetPopupWindow( pFrameWin );
+VclPtr<vcl::Window> SvxFrameToolBoxControl::createPopupWindow( vcl::Window* pParent )
+{
+ return VclPtr<SvxFrameWindow_Impl>::Create( 0, m_xFrame, pParent );
+}
- return pFrameWin;
+OUString SvxFrameToolBoxControl::getImplementationName()
+ throw ( css::uno::RuntimeException, std::exception )
+{
+ return OUString( "com.sun.star.comp.svx.FrameToolBoxControl" );
}
-void SvxFrameToolBoxControl::StateChanged(
- sal_uInt16, SfxItemState eState, const SfxPoolItem* )
+css::uno::Sequence< OUString > SvxFrameToolBoxControl::getSupportedServiceNames()
+ throw ( css::uno::RuntimeException, std::exception )
{
- sal_uInt16 nId = GetId();
- ToolBox& rTbx = GetToolBox();
+ return { "com.sun.star.frame.ToolbarController" };
+}
- rTbx.EnableItem( nId, SfxItemState::DISABLED != eState );
- rTbx.SetItemState( nId, (SfxItemState::DONTCARE == eState)
- ? TRISTATE_INDET
- : TRISTATE_FALSE );
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_svx_FrameToolBoxControl_get_implementation(
+ css::uno::XComponentContext* rContext,
+ css::uno::Sequence<css::uno::Any> const & )
+{
+ return cppu::acquire( new SvxFrameToolBoxControl( rContext ) );
}
SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
diff --git a/svx/util/svxcore.component b/svx/util/svxcore.component
index 1e6d1c7..8c8d42d 100644
--- a/svx/util/svxcore.component
+++ b/svx/util/svxcore.component
@@ -40,6 +40,10 @@
<implementation name="com.sun.star.comp.svx.FontworkCharacterSpacingController">
<service name="com.sun.star.frame.ToolbarController"/>
</implementation>
+ <implementation name="com.sun.star.comp.svx.FrameToolBoxControl"
+ constructor="com_sun_star_comp_svx_FrameToolBoxControl_get_implementation">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
<implementation name="com.sun.star.comp.Svx.GraphicExportHelper"
constructor="com_sun_star_comp_Svx_GraphicExportHelper_get_implementation">
<service name="com.sun.star.document.BinaryStreamResolver"/>
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index eaa726b..6ca46d4 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -320,7 +320,6 @@ void SwDLL::RegisterControls()
SvxColorToolBoxControl::RegisterControl(SID_ATTR_CHAR_COLOR_BACKGROUND, pMod );
SvxStyleToolBoxControl::RegisterControl(SID_STYLE_APPLY, pMod );
SvxColorToolBoxControl::RegisterControl( SID_BACKGROUND_COLOR, pMod );
- SvxFrameToolBoxControl::RegisterControl(SID_ATTR_BORDER, pMod );
SvxFrameLineStyleToolBoxControl::RegisterControl(SID_FRAME_LINESTYLE, pMod );
SvxColorToolBoxControl::RegisterControl(SID_FRAME_LINECOLOR, pMod );
commit c700ed71f457a141c8033d2ab863bf884c50fa96
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Tue Oct 4 22:18:35 2016 +0300
PopupWindowController: Tearoff support
Change-Id: I2baaaa13f3d127dc1619c971b66091d3326fafbc
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx
index d299416..09b6885 100644
--- a/svtools/source/uno/popupwindowcontroller.cxx
+++ b/svtools/source/uno/popupwindowcontroller.cxx
@@ -40,23 +40,22 @@ public:
~PopupWindowControllerImpl();
void SetPopupWindow( vcl::Window* pPopupWindow, ToolBox* pToolBox );
+ void SetFloatingWindow();
DECL_LINK( WindowEventListener, VclWindowEvent&, void );
private:
- VclPtr<vcl::Window> mpPopupWindow;
+ VclPtr<vcl::Window> mpPopupWindow, mpFloatingWindow;
VclPtr<ToolBox> mpToolBox;
};
PopupWindowControllerImpl::PopupWindowControllerImpl()
-: mpPopupWindow( nullptr )
-, mpToolBox( nullptr )
{
}
PopupWindowControllerImpl::~PopupWindowControllerImpl()
{
- if( mpPopupWindow )
- SetPopupWindow(nullptr,nullptr);
+ SetPopupWindow(nullptr,nullptr);
+ SetFloatingWindow();
}
void PopupWindowControllerImpl::SetPopupWindow( vcl::Window* pPopupWindow, ToolBox* pToolBox )
@@ -75,15 +74,53 @@ void PopupWindowControllerImpl::SetPopupWindow( vcl::Window* pPopupWindow, ToolB
}
}
+void PopupWindowControllerImpl::SetFloatingWindow()
+{
+ if( mpFloatingWindow )
+ {
+ mpFloatingWindow->RemoveEventListener( LINK( this, PopupWindowControllerImpl, WindowEventListener ) );
+ mpFloatingWindow.disposeAndClear();
+ }
+ mpFloatingWindow = mpPopupWindow;
+ mpPopupWindow.clear();
+}
+
IMPL_LINK( PopupWindowControllerImpl, WindowEventListener, VclWindowEvent&, rWindowEvent, void )
{
switch( rWindowEvent.GetId() )
{
- case VCLEVENT_WINDOW_CLOSE:
case VCLEVENT_WINDOW_ENDPOPUPMODE:
+ {
+ EndPopupModeData* pData = static_cast< EndPopupModeData* >( rWindowEvent.GetData() );
+ if( pData && pData->mbTearoff )
+ {
+ vcl::Window::GetDockingManager()->SetFloatingMode( mpPopupWindow.get(), true );
+ vcl::Window::GetDockingManager()->SetPosSizePixel( mpPopupWindow.get(),
+ pData->maFloatingPos.X(),
+ pData->maFloatingPos.Y(),
+ 0, 0,
+ PosSizeFlags::Pos );
+ SetFloatingWindow();
+ mpFloatingWindow->Show( true, ShowFlags::NoFocusChange | ShowFlags::NoActivate );
+ }
SetPopupWindow(nullptr,nullptr);
break;
-
+ }
+ case VCLEVENT_WINDOW_PREPARETOGGLEFLOATING:
+ {
+ if ( mpFloatingWindow && rWindowEvent.GetWindow() == mpFloatingWindow.get() )
+ {
+ bool* pData = static_cast< bool* >( rWindowEvent.GetData() );
+ *pData = false;
+ }
+ break;
+ }
+ case VCLEVENT_WINDOW_CLOSE:
+ {
+ SetPopupWindow(nullptr,nullptr);
+ SetFloatingWindow();
+ break;
+ }
case VCLEVENT_WINDOW_SHOW:
{
if( mpPopupWindow )
@@ -133,6 +170,7 @@ sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& Servic
// XComponent
void SAL_CALL PopupWindowController::dispose() throw (RuntimeException, std::exception)
{
+ mxImpl.reset();
svt::ToolboxController::dispose();
}
@@ -153,12 +191,22 @@ Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() th
vcl::Window* pWin = createPopupWindow( pItemWindow ? pItemWindow : pToolBox );
if( pWin )
{
+ FloatWinPopupFlags eFloatFlags = FloatWinPopupFlags::GrabFocus |
+ FloatWinPopupFlags::AllMouseButtonClose |
+ FloatWinPopupFlags::NoMouseUpClose;
+
+ WinBits nWinBits;
+ if ( pWin->GetType() == WINDOW_DOCKINGWINDOW )
+ nWinBits = static_cast< DockingWindow* >( pWin )->GetFloatStyle();
+ else
+ nWinBits = pWin->GetStyle();
+
+ if ( nWinBits & ( WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE ) )
+ eFloatFlags |= FloatWinPopupFlags::AllowTearOff;
+
pWin->EnableDocking();
mxImpl->SetPopupWindow(pWin,pToolBox);
- vcl::Window::GetDockingManager()->StartPopupMode( pToolBox, pWin,
- FloatWinPopupFlags::GrabFocus |
- FloatWinPopupFlags::AllMouseButtonClose |
- FloatWinPopupFlags::NoMouseUpClose );
+ vcl::Window::GetDockingManager()->StartPopupMode( pToolBox, pWin, eFloatFlags );
}
}
return Reference< awt::XWindow >();
commit da80f6e8499c9b0cf7711a30eb895f71719639cb
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Sat Oct 1 22:15:53 2016 +0300
PopupWindowController: Small cleanup
Change-Id: Iedbc8ddaf97f515fecc012322f0c1621317de076
diff --git a/include/svtools/popupwindowcontroller.hxx b/include/svtools/popupwindowcontroller.hxx
index f2fa65f..44794fa 100644
--- a/include/svtools/popupwindowcontroller.hxx
+++ b/include/svtools/popupwindowcontroller.hxx
@@ -50,9 +50,6 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) override = 0;
- // XInitialization
- virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
-
// XComponent
virtual void SAL_CALL dispose() throw (css::uno::RuntimeException, std::exception) override;
@@ -60,9 +57,8 @@ public:
virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
// XToolbarController
- virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createPopupWindow() throw (css::uno::RuntimeException, std::exception) override;
- virtual css::uno::Reference< css::awt::XWindow > SAL_CALL createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw (css::uno::RuntimeException, std::exception) override;
+
private:
std::unique_ptr< PopupWindowControllerImpl > mxImpl;
};
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx
index 62ccb56..d299416 100644
--- a/svtools/source/uno/popupwindowcontroller.cxx
+++ b/svtools/source/uno/popupwindowcontroller.cxx
@@ -24,7 +24,6 @@
#include <vcl/svapp.hxx>
#include <svtools/popupwindowcontroller.hxx>
-#include <svtools/toolbarmenu.hxx>
using namespace ::com::sun::star;
using namespace css::uno;
@@ -92,10 +91,6 @@ IMPL_LINK( PopupWindowControllerImpl, WindowEventListener, VclWindowEvent&, rWin
if( mpToolBox )
mpToolBox->CallEventListeners( VCLEVENT_DROPDOWN_OPEN, static_cast<void*>(mpPopupWindow) );
mpPopupWindow->CallEventListeners( VCLEVENT_WINDOW_GETFOCUS );
-
- svtools::ToolbarMenu* pToolbarMenu = dynamic_cast< svtools::ToolbarMenu* >( mpPopupWindow.get() );
- if( pToolbarMenu )
- pToolbarMenu->highlightFirstEntry();
break;
}
break;
@@ -135,24 +130,12 @@ sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& Servic
return cppu::supportsService(this, ServiceName);
}
-// XInitialization
-void SAL_CALL PopupWindowController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception)
-{
- svt::ToolboxController::initialize( aArguments );
- if( !m_aCommandURL.isEmpty() )
- addStatusListener( m_aCommandURL );
-}
-
// XComponent
void SAL_CALL PopupWindowController::dispose() throw (RuntimeException, std::exception)
{
- if( !m_aCommandURL.isEmpty() )
- removeStatusListener( m_aCommandURL );
-
svt::ToolboxController::dispose();
}
-
// XStatusListener
void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException, std::exception )
{
@@ -161,11 +144,6 @@ void SAL_CALL PopupWindowController::statusChanged( const frame::FeatureStateEve
}
// XToolbarController
-void SAL_CALL PopupWindowController::execute( sal_Int16 KeyModifier ) throw (RuntimeException, std::exception)
-{
- svt::ToolboxController::execute( KeyModifier );
-}
-
Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() throw (RuntimeException, std::exception)
{
VclPtr< ToolBox > pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ).get() );
@@ -186,12 +164,6 @@ Reference< awt::XWindow > SAL_CALL PopupWindowController::createPopupWindow() th
return Reference< awt::XWindow >();
}
-Reference< awt::XWindow > SAL_CALL PopupWindowController::createItemWindow( const Reference< awt::XWindow >& /*Parent*/ )
- throw (RuntimeException, std::exception)
-{
- return Reference< awt::XWindow >();
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a7331e2485a92492ad88893e029c3d895abb7a8a
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Fri Sep 30 14:36:29 2016 +0300
PopupWindowController: Use ImplInheritanceHelper
Change-Id: I82b9ebf69b6b35b3a5e1e8a5dc5bb84eff1feb19
diff --git a/include/svtools/popupwindowcontroller.hxx b/include/svtools/popupwindowcontroller.hxx
index a6e78da..f2fa65f 100644
--- a/include/svtools/popupwindowcontroller.hxx
+++ b/include/svtools/popupwindowcontroller.hxx
@@ -24,6 +24,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase.hxx>
#include <svtools/toolboxcontroller.hxx>
#include <vcl/vclptr.hxx>
@@ -33,7 +34,8 @@ namespace svt
{
class PopupWindowControllerImpl;
-class SVT_DLLPUBLIC PopupWindowController : public svt::ToolboxController, public css::lang::XServiceInfo
+class SVT_DLLPUBLIC PopupWindowController : public cppu::ImplInheritanceHelper< svt::ToolboxController,
+ css::lang::XServiceInfo >
{
public:
PopupWindowController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
@@ -43,11 +45,6 @@ public:
virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) = 0;
- // XInterface
- virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw (css::uno::RuntimeException, std::exception) override;
- virtual void SAL_CALL acquire() throw () override;
- virtual void SAL_CALL release() throw () override;
-
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) override = 0;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( css::uno::RuntimeException, std::exception ) override;
diff --git a/svtools/source/uno/popupwindowcontroller.cxx b/svtools/source/uno/popupwindowcontroller.cxx
index b328242..62ccb56 100644
--- a/svtools/source/uno/popupwindowcontroller.cxx
+++ b/svtools/source/uno/popupwindowcontroller.cxx
@@ -18,7 +18,6 @@
*/
#include <cppuhelper/supportsservice.hxx>
-#include <cppuhelper/queryinterface.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/toolbox.hxx>
@@ -121,7 +120,7 @@ IMPL_LINK( PopupWindowControllerImpl, WindowEventListener, VclWindowEvent&, rWin
PopupWindowController::PopupWindowController( const Reference< uno::XComponentContext >& rxContext,
const Reference< frame::XFrame >& xFrame,
const OUString& aCommandURL )
-: svt::ToolboxController( rxContext, xFrame, aCommandURL )
+: ImplInheritanceHelper( rxContext, xFrame, aCommandURL )
, mxImpl( new PopupWindowControllerImpl() )
{
}
@@ -130,27 +129,6 @@ PopupWindowController::~PopupWindowController()
{
}
-// XInterface
-Any SAL_CALL PopupWindowController::queryInterface( const Type& aType )
-throw (RuntimeException, std::exception)
-{
- Any a( ToolboxController::queryInterface( aType ) );
- if ( a.hasValue() )
- return a;
-
- return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
-}
-
-void SAL_CALL PopupWindowController::acquire() throw ()
-{
- ToolboxController::acquire();
-}
-
-void SAL_CALL PopupWindowController::release() throw ()
-{
- ToolboxController::release();
-}
-
// XServiceInfo
sal_Bool SAL_CALL PopupWindowController::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
{
commit 6128a8311d37514c49c2fe3ba80f850a51de37d6
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Thu Sep 29 23:07:35 2016 +0300
Add title-based tearoff to DockingManager
Using FloatingWindow with WB_OWNERDRAWDECORATION as a toolbar dropdown
is just a recipe for troubles. One example is
https://lists.freedesktop.org/archives/libreoffice/2016-June/074431.html
So fake the title to allow tearoff, instead of using a "real" title for it.
Change-Id: I4fe00b9505686d91b9715e832ddb9f4b38f6554f
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
index 984e5af..9caf5cc 100644
--- a/vcl/source/window/dockmgr.cxx
+++ b/vcl/source/window/dockmgr.cxx
@@ -454,6 +454,13 @@ Rectangle DockingManager::GetPosSizePixel( const vcl::Window *pWindow )
#define POPUP_DRAGHEIGHT (POPUP_DRAGGRIP+POPUP_DRAGBORDER+POPUP_DRAGBORDER)
#define POPUP_DRAGWIDTH 20
+enum class TearOffStyle
+{
+ Grip,
+ Title,
+ None
+};
+
class ImplPopupFloatWin : public FloatingWindow
{
private:
@@ -463,12 +470,11 @@ private:
bool mbTrackingEnabled;
Point maDelta;
Point maTearOffPosition;
- bool mbGripAtBottom;
- bool mbHasGrip;
+ TearOffStyle meTearOffStyle;
void ImplSetBorder();
public:
- ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip );
+ ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, TearOffStyle eStyle );
virtual ~ImplPopupFloatWin() override;
virtual void dispose() override;
@@ -484,12 +490,11 @@ public:
Point GetToolboxPosition() const;
Point GetTearOffPosition() const;
void DrawGrip(vcl::RenderContext& rRenderContext);
+ void DrawTitle(vcl::RenderContext& rRenderContext);
void DrawBorder(vcl::RenderContext& rRenderContext);
-
- bool hasGrip() const { return mbHasGrip; }
};
-ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, bool bHasGrip ) :
+ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWrapper* pDockingWin, TearOffStyle eStyle ) :
FloatingWindow( pParent, WB_NOBORDER | WB_SYSTEMWINDOW | WB_NOSHADOW)
{
mpWindowImpl->mbToolbarFloatingWindow = true; // indicate window type, required for accessibility
@@ -498,8 +503,7 @@ ImplPopupFloatWin::ImplPopupFloatWin( vcl::Window* pParent, ImplDockingWindowWra
mbHighlight = false;
mbMoving = false;
mbTrackingEnabled = false;
- mbGripAtBottom = true;
- mbHasGrip = bHasGrip;
+ meTearOffStyle = eStyle;
ImplSetBorder();
}
@@ -533,8 +537,10 @@ void ImplPopupFloatWin::ImplSetBorder()
// by setting those members the method SetOutputSizePixel() can
// be used to set the proper window size
mpWindowImpl->mnTopBorder = 1;
- if( hasGrip() )
+ if( meTearOffStyle == TearOffStyle::Grip )
mpWindowImpl->mnTopBorder += POPUP_DRAGHEIGHT+2;
+ else if( meTearOffStyle == TearOffStyle::Title )
+ mpWindowImpl->mnTopBorder += GetSettings().GetStyleSettings().GetTitleHeight()+2;
mpWindowImpl->mnBottomBorder = 1;
mpWindowImpl->mnLeftBorder = 1;
mpWindowImpl->mnRightBorder = 1;
@@ -548,24 +554,23 @@ void ImplPopupFloatWin::Resize()
Rectangle ImplPopupFloatWin::GetDragRect() const
{
- Rectangle aRect;
- if( hasGrip() )
+ if( meTearOffStyle == TearOffStyle::Grip )
{
- aRect = Rectangle( 1,1, GetOutputSizePixel().Width()-1, 2+POPUP_DRAGHEIGHT );
- if( mbGripAtBottom )
- {
- int height = GetOutputSizePixel().Height();
- aRect.Top() = height - 3 - POPUP_DRAGHEIGHT;
- aRect.Bottom() = aRect.Top() + 1 + POPUP_DRAGHEIGHT;
- }
+ return Rectangle( 1, GetOutputSizePixel().Height() - 3 - POPUP_DRAGHEIGHT,
+ GetOutputSizePixel().Width() - 1, GetOutputSizePixel().Height() - 1 );
}
- return aRect;
+ else if( meTearOffStyle == TearOffStyle::Title )
+ {
+ return Rectangle( 1, 1, GetOutputSizePixel().Width() - 1, GetSettings().GetStyleSettings().GetTitleHeight() + 2 );
+ }
+
+ return Rectangle();
}
Point ImplPopupFloatWin::GetToolboxPosition() const
{
// return inner position where a toolbox could be placed
- Point aPt( 1, 1 + ((mbGripAtBottom || !hasGrip()) ? 0 : GetDragRect().getHeight()) ); // grip + border
+ Point aPt( 1, 1 + ( meTearOffStyle != TearOffStyle::Title ? 0 : GetDragRect().getHeight()) ); // grip + border
return aPt;
}
@@ -691,13 +696,33 @@ void ImplPopupFloatWin::DrawGrip(vcl::RenderContext& rRenderContext)
rRenderContext.SetFillColor();
}
+void ImplPopupFloatWin::DrawTitle(vcl::RenderContext &rRenderContext)
+{
+ Rectangle aRect(GetDragRect());
+ aRect.Left() += 2;
+ aRect.Right() -= 2;
+
+ DrawTextFlags nTextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter | DrawTextFlags::EndEllipsis | DrawTextFlags::Clip;
+ rRenderContext.SetTextColor(GetSettings().GetStyleSettings().GetButtonTextColor());
+ SetPointFont(rRenderContext, GetSettings().GetStyleSettings().GetTitleFont());
+ rRenderContext.DrawText(aRect, GetText(), nTextStyle);
+}
+
void ImplPopupFloatWin::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
{
Rectangle aRect(Point(), GetOutputSizePixel());
- rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
- DrawBorder(rRenderContext);
- if (hasGrip())
+
+ if (meTearOffStyle == TearOffStyle::Grip)
+ {
+ rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceGradientColor()));
DrawGrip(rRenderContext);
+ }
+ else if ( meTearOffStyle == TearOffStyle::Title )
+ {
+ rRenderContext.DrawWallpaper(aRect, Wallpaper(rRenderContext.GetSettings().GetStyleSettings().GetFaceColor()));
+ DrawTitle(rRenderContext);
+ }
+ DrawBorder(rRenderContext);
}
void ImplPopupFloatWin::MouseMove( const MouseEvent& rMEvt )
@@ -1085,7 +1110,15 @@ void ImplDockingWindowWrapper::StartPopupMode( ToolBox *pParentToolBox, FloatWin
mpOldBorderWin = nullptr; // no border window found
// the new parent for popup mode
- VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, bool(nFlags & FloatWinPopupFlags::AllowTearOff) );
+ TearOffStyle eStyle = TearOffStyle::None;
+ if ( nFlags & FloatWinPopupFlags::AllowTearOff )
+ {
+ if ( dynamic_cast< ToolBox* >( GetWindow() ) )
+ eStyle = TearOffStyle::Grip;
+ else
+ eStyle = TearOffStyle::Title;
+ }
+ VclPtrInstance<ImplPopupFloatWin> pWin( mpParent, this, eStyle );
pWin->SetPopupModeEndHdl( LINK( this, ImplDockingWindowWrapper, PopupModeEnd ) );
pWin->SetText( GetWindow()->GetText() );
More information about the Libreoffice-commits
mailing list