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