summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2013-04-23 13:56:58 +0000
committerMichael Meeks <michael.meeks@suse.com>2013-05-20 11:33:20 +0100
commita1c02181319d32c4444ab7fdb4f1086221056a34 (patch)
tree4126b8fc2a6cbfe36b20dd1ca007830ce2b1f7be /sw
parentdf282e6bf8cb497b5a32a49557c2c7267e4d3541 (diff)
Related: #i121793# correction for page property panel:
- show correct state in popups - aggregate multiple attribute changes into one undo action (cherry picked from commit 306b1c56dc88ac357093d1dc5eb8c8360f8f7100) Conflicts: sw/source/ui/sidebar/PagePropertyPanel.cxx sw/source/ui/uiview/viewtab.cxx Change-Id: I4764be46535fe7a00cbb296c06094e3f8ea461df
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/sidebar/PageMarginControl.cxx2
-rw-r--r--sw/source/ui/sidebar/PagePropertyPanel.cxx114
-rw-r--r--sw/source/ui/sidebar/PagePropertyPanel.hxx18
-rw-r--r--sw/source/ui/sidebar/SwPanelFactory.cxx2
-rw-r--r--sw/source/ui/sidebar/WrapPropertyPanel.cxx6
-rw-r--r--sw/source/ui/uiview/viewtab.cxx7
6 files changed, 100 insertions, 49 deletions
diff --git a/sw/source/ui/sidebar/PageMarginControl.cxx b/sw/source/ui/sidebar/PageMarginControl.cxx
index 6bbc4b7c46d1..89e0ca0617a9 100644
--- a/sw/source/ui/sidebar/PageMarginControl.cxx
+++ b/sw/source/ui/sidebar/PageMarginControl.cxx
@@ -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();
diff --git a/sw/source/ui/sidebar/PagePropertyPanel.cxx b/sw/source/ui/sidebar/PagePropertyPanel.cxx
index 864742d9416f..8dc4d288f3c6 100644
--- a/sw/source/ui/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/ui/sidebar/PagePropertyPanel.cxx
@@ -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
diff --git a/sw/source/ui/sidebar/PagePropertyPanel.hxx b/sw/source/ui/sidebar/PagePropertyPanel.hxx
index 267c99e28119..095d07331ba7 100644
--- a/sw/source/ui/sidebar/PagePropertyPanel.hxx
+++ b/sw/source/ui/sidebar/PagePropertyPanel.hxx
@@ -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;
diff --git a/sw/source/ui/sidebar/SwPanelFactory.cxx b/sw/source/ui/sidebar/SwPanelFactory.cxx
index 620b52b0f795..c03178316bac 100644
--- a/sw/source/ui/sidebar/SwPanelFactory.cxx
+++ b/sw/source/ui/sidebar/SwPanelFactory.cxx
@@ -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,
diff --git a/sw/source/ui/sidebar/WrapPropertyPanel.cxx b/sw/source/ui/sidebar/WrapPropertyPanel.cxx
index c185d95cdb9b..c9ee61eebddd 100644
--- a/sw/source/ui/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/ui/sidebar/WrapPropertyPanel.cxx
@@ -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,
diff --git a/sw/source/ui/uiview/viewtab.cxx b/sw/source/ui/uiview/viewtab.cxx
index cd662675d784..92a39d742cd1 100644
--- a/sw/source/ui/uiview/viewtab.cxx
+++ b/sw/source/ui/uiview/viewtab.cxx
@@ -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 );
}