Kaydet (Commit) a1c02181 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann Kaydeden (comit) Michael Meeks

Related: #i121793# correction for page property panel:

- show correct state in popups
- aggregate multiple attribute changes into one undo action

(cherry picked from commit 306b1c56)

Conflicts:
	sw/source/ui/sidebar/PagePropertyPanel.cxx
	sw/source/ui/uiview/viewtab.cxx

Change-Id: I4764be46535fe7a00cbb296c06094e3f8ea461df
üst df282e6b
......@@ -122,8 +122,7 @@ void Popup::CreateContainerAndControl (void)
{
mpContainer.reset(new PopupContainer(mpParent));
mpContainer->SetAccessibleName(msAccessibleName);
if (maPopupModeEndCallback)
mpContainer->SetPopupModeEndHdl(LINK(this, Popup, PopupModeEndHandler));
mpContainer->SetPopupModeEndHdl(LINK(this, Popup, PopupModeEndHandler));
mpContainer->SetBorderStyle(mpContainer->GetBorderStyle() | WINDOW_BORDER_MENU);
mpControl.reset(maControlCreator(mpContainer.get()));
......@@ -136,6 +135,11 @@ IMPL_LINK(Popup, PopupModeEndHandler, void*, EMPTYARG)
{
if (maPopupModeEndCallback)
maPopupModeEndCallback();
// Popup control is no longer needed and can be destroyed.
mpControl.reset();
mpContainer.reset();
return 0;
}
......
......@@ -359,6 +359,7 @@ IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
if ( bApplyNewPageMargins )
{
mrPagePropPanel.StartUndo();
mpMarginValueSet->SetNoSelection();
mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
......@@ -367,6 +368,7 @@ IMPL_LINK(PageMarginControl, ImplMarginHdl, void *, pControl)
mbMirrored = bMirrored;
mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
}
mrPagePropPanel.EndUndo();
mbCustomValuesUsed = false;
mrPagePropPanel.ClosePageMarginPopup();
......
......@@ -45,26 +45,58 @@
#include <boost/bind.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/document/XUndoManagerSupplier.hpp>
#define A2S(pString) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(pString)))
namespace {
const cssu::Reference< css::document::XUndoManager > getUndoManager( const cssu::Reference< css::frame::XFrame >& rxFrame )
{
const cssu::Reference< css::frame::XController >& xController = rxFrame->getController();
if ( xController.is() )
{
const cssu::Reference< css::frame::XModel >& xModel = xController->getModel();
if ( xModel.is() )
{
const cssu::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, cssu::UNO_QUERY_THROW );
if ( xSuppUndo.is() )
{
const cssu::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), cssu::UNO_QUERY_THROW );
return xUndoManager;
}
}
}
return cssu::Reference< css::document::XUndoManager > ();
}
}
namespace sw { namespace sidebar {
PagePropertyPanel* PagePropertyPanel::Create (
Window* pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
{
if (pParent == NULL)
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL, 0);
if ( ! rxFrame.is())
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to PagePropertyPanel::Create"), NULL, 1);
if (pBindings == NULL)
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL, 2);
return new PagePropertyPanel(
pParent,
rxFrame,
pBindings);
}
PagePropertyPanel::PagePropertyPanel(
Window* pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
SfxBindings* pBindings)
: Control(pParent, SW_RES(RID_PROPERTYPANEL_SWPAGE))
, mpBindings(pBindings)
......@@ -144,10 +176,20 @@ PagePropertyPanel::PagePropertyPanel(
, m_aSwPageColControl(SID_ATTR_PAGE_COLUMN, *pBindings, *this)
, m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this)
, mpOrientationPopup()
, mpMarginPopup()
, mpSizePopup()
, mpColumnPopup()
, maOrientationPopup( this,
::boost::bind( &PagePropertyPanel::CreatePageOrientationControl, this, _1 ),
A2S("Page orientation") )
, maMarginPopup( this,
::boost::bind( &PagePropertyPanel::CreatePageMarginControl, this, _1 ),
A2S("Page margins") )
, maSizePopup( this,
::boost::bind( &PagePropertyPanel::CreatePageSizeControl, this, _1 ),
A2S("Page size") )
, maColumnPopup( this,
::boost::bind( &PagePropertyPanel::CreatePageColumnControl, this, _1 ),
A2S("Page columns") )
, mxUndoManager( getUndoManager( rxFrame ) )
, mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
{
......@@ -262,15 +304,7 @@ void PagePropertyPanel::Initialize()
IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox )
{
if ( ! mpOrientationPopup)
{
mpOrientationPopup.reset(
new ::svx::sidebar::Popup(
this,
::boost::bind(&PagePropertyPanel::CreatePageOrientationControl, this, _1),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page orientation")) ) );
}
mpOrientationPopup->Show( *pToolBox );
maOrientationPopup.Show( *pToolBox );
return 0L;
}
......@@ -278,6 +312,8 @@ IMPL_LINK( PagePropertyPanel, ClickOrientationHdl, ToolBox*, pToolBox )
void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape )
{
StartUndo();
{
// set new page orientation
mpPageItem->SetLandscape( bLandscape );
......@@ -328,12 +364,14 @@ void PagePropertyPanel::ExecuteOrientationChange( const sal_Bool bLandscape )
}
}
}
EndUndo();
}
void PagePropertyPanel::ClosePageOrientationPopup()
{
mpOrientationPopup->Hide();
maOrientationPopup.Hide();
}
......@@ -382,13 +420,7 @@ void PagePropertyPanel::ExecutePageLayoutChange( const bool bMirrored )
IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox )
{
if ( ! mpMarginPopup)
mpMarginPopup.reset(
new ::svx::sidebar::Popup(
this,
::boost::bind(&PagePropertyPanel::CreatePageMarginControl, this, _1),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page margins")) ) );
mpMarginPopup->Show( *pToolBox );
maMarginPopup.Show( *pToolBox );
return 0L;
}
......@@ -396,7 +428,7 @@ IMPL_LINK( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox )
void PagePropertyPanel::ClosePageMarginPopup()
{
mpMarginPopup->Hide();
maMarginPopup.Hide();
}
......@@ -428,13 +460,7 @@ void PagePropertyPanel::ExecuteSizeChange( const Paper ePaper )
IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox )
{
if ( ! mpSizePopup)
mpSizePopup.reset(
new ::svx::sidebar::Popup(
this,
::boost::bind(&PagePropertyPanel::CreatePageSizeControl, this, _1),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page size")) ) );
mpSizePopup->Show( *pToolBox );
maSizePopup.Show( *pToolBox );
return 0L;
}
......@@ -442,7 +468,7 @@ IMPL_LINK( PagePropertyPanel, ClickSizeHdl, ToolBox*, pToolBox )
void PagePropertyPanel::ClosePageSizePopup()
{
mpSizePopup->Hide();
maSizePopup.Hide();
}
......@@ -467,13 +493,7 @@ void PagePropertyPanel::ExecuteColumnChange( const sal_uInt16 nColumnType )
IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox )
{
if ( ! mpColumnPopup)
mpColumnPopup.reset(
new ::svx::sidebar::Popup(
this,
::boost::bind(&PagePropertyPanel::CreatePageColumnControl, this, _1),
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Page columns")) ) );
mpColumnPopup->Show( *pToolBox );
maColumnPopup.Show( *pToolBox );
return 0L;
}
......@@ -481,7 +501,7 @@ IMPL_LINK( PagePropertyPanel, ClickColumnHdl, ToolBox*, pToolBox )
void PagePropertyPanel::ClosePageColumnPopup()
{
mpColumnPopup->Hide();
maColumnPopup.Hide();
}
......@@ -757,4 +777,22 @@ void PagePropertyPanel::ChangeColumnImage( const sal_uInt16 nColumnType )
}
}
void PagePropertyPanel::StartUndo()
{
if ( mxUndoManager.is() )
{
mxUndoManager->enterUndoContext( A2S("") );
}
}
void PagePropertyPanel::EndUndo()
{
if ( mxUndoManager.is() )
{
mxUndoManager->leaveUndoContext();
}
}
} } // end of namespace ::sw::sidebar
......@@ -18,6 +18,9 @@
#ifndef SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX
#define SW_SIDEBAR_PAGE_PROPERTY_PANEL_HXX
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/document/XUndoManager.hpp>
#include <svx/sidebar/Popup.hxx>
#include <sfx2/sidebar/ControllerItem.hxx>
......@@ -55,6 +58,7 @@ namespace sw { namespace sidebar {
public:
static PagePropertyPanel* Create(
Window* pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
SfxBindings* pBindings );
// interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
......@@ -92,9 +96,13 @@ namespace sw { namespace sidebar {
void ExecuteColumnChange( const sal_uInt16 nColumnType );
void ClosePageColumnPopup();
void StartUndo();
void EndUndo();
private:
PagePropertyPanel(
Window* pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame>& rxFrame,
SfxBindings* pBindings );
virtual ~PagePropertyPanel(void);
......@@ -191,10 +199,12 @@ namespace sw { namespace sidebar {
::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
// popups
::boost::scoped_ptr< ::svx::sidebar::Popup > mpOrientationPopup;
::boost::scoped_ptr< ::svx::sidebar::Popup > mpMarginPopup;
::boost::scoped_ptr< ::svx::sidebar::Popup > mpSizePopup;
::boost::scoped_ptr< ::svx::sidebar::Popup > mpColumnPopup;
::svx::sidebar::Popup maOrientationPopup;
::svx::sidebar::Popup maMarginPopup;
::svx::sidebar::Popup maSizePopup;
::svx::sidebar::Popup maColumnPopup;
const cssu::Reference< css::document::XUndoManager > mxUndoManager;
bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
......
......@@ -112,7 +112,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
#define DoesResourceEndWith(s) rsResourceURL.endsWithAsciiL(s,strlen(s))
if (DoesResourceEndWith("/PagePropertyPanel"))
{
PagePropertyPanel* pPanel = PagePropertyPanel::Create( pParentWindow, pBindings );
PagePropertyPanel* pPanel = PagePropertyPanel::Create( pParentWindow, xFrame, pBindings );
xElement = sfx2::sidebar::SidebarPanelBase::Create(
rsResourceURL,
xFrame,
......
......@@ -43,11 +43,11 @@ WrapPropertyPanel* WrapPropertyPanel::Create (
SfxBindings* pBindings)
{
if (pParent == NULL)
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to PagePropertyPanel::Create"), NULL, 0);
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no parent Window given to WrapPropertyPanel::Create"), NULL, 0);
if ( ! rxFrame.is())
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to PagePropertyPanel::Create"), NULL, 1);
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no XFrame given to WrapPropertyPanel::Create"), NULL, 1);
if (pBindings == NULL)
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to PagePropertyPanel::Create"), NULL, 2);
throw ::com::sun::star::lang::IllegalArgumentException(A2S("no SfxBindings given to WrapPropertyPanel::Create"), NULL, 2);
return new WrapPropertyPanel(
pParent,
......
......@@ -1139,9 +1139,10 @@ void SwView::StateTabWin(SfxItemSet& rSet)
// provide left and right margins of current page style
case SID_ATTR_PAGE_LRSPACE:
{
SvxLongLRSpaceItem aLongLR(
(long)aPageLRSpace.GetLeft(),
(long)aPageLRSpace.GetRight(),
const SvxLRSpaceItem aTmpPageLRSpace( rDesc.GetMaster().GetLRSpace() );
const SvxLongLRSpaceItem aLongLR(
(long)aTmpPageLRSpace.GetLeft(),
(long)aTmpPageLRSpace.GetRight(),
SID_ATTR_PAGE_LRSPACE );
rSet.Put( aLongLR );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment