summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorSzymon Kłos <eszkadev@gmail.com>2016-09-28 16:08:53 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-09-29 07:07:58 +0000
commit558faa307d87510c2d9d12b23c12f261c424f835 (patch)
treed2f264bb7a95d9af3c426a3a598536ca16ce7339 /sw/source/uibase
parent2bebc1fc2e76f73d953ca1e1f64803fd4c42a62c (diff)
Page margin popup converted to use outside sidebar
Change-Id: I3c4cc20fc8f2818677a77f848a1566bb56ceb7c6 Reviewed-on: https://gerrit.libreoffice.org/29363 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/app/swmodule.cxx2
-rw-r--r--sw/source/uibase/sidebar/PageColumnControl.cxx1
-rw-r--r--sw/source/uibase/sidebar/PageColumnControl.hxx4
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.cxx624
-rw-r--r--sw/source/uibase/sidebar/PageMarginControl.hxx97
-rw-r--r--sw/source/uibase/sidebar/PageMarginPopup.cxx46
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.cxx301
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.hrc106
-rw-r--r--sw/source/uibase/sidebar/PagePropertyPanel.hxx88
-rw-r--r--sw/source/uibase/sidebar/PageSizeControl.cxx3
-rw-r--r--sw/source/uibase/sidebar/PropertyPanel.hrc7
-rw-r--r--sw/source/uibase/sidebar/WrapPropertyPanel.cxx1
12 files changed, 453 insertions, 827 deletions
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 5244398963ad..eaa726bea839 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -111,6 +111,7 @@
#include <svx/rubydialog.hxx>
#include <svtools/colorcfg.hxx>
#include <PageSizePopup.hxx>
+#include <PageMarginPopup.hxx>
#include <PageOrientationPopup.hxx>
#include <PageColumnPopup.hxx>
@@ -294,6 +295,7 @@ void SwDLL::RegisterControls()
svx::TextUnderlinePopup::RegisterControl(SID_ATTR_CHAR_UNDERLINE, pMod);
svx::ParaULSpacingControl::RegisterControl(SID_ATTR_PARA_ULSPACE, pMod);
svx::ParaLRSpacingControl::RegisterControl(SID_ATTR_PARA_LRSPACE, pMod);
+ PageMarginPopup::RegisterControl(SID_ATTR_PAGE_MARGIN, pMod);
PageOrientationPopup::RegisterControl(SID_ATTR_PAGE_ORIENTATION, pMod);
PageColumnPopup::RegisterControl(SID_ATTR_PAGE_COLUMN, pMod);
PageSizePopup::RegisterControl(SID_ATTR_PAGE_SIZE, pMod);
diff --git a/sw/source/uibase/sidebar/PageColumnControl.cxx b/sw/source/uibase/sidebar/PageColumnControl.cxx
index 04d24c43160a..3b1fd05f2d30 100644
--- a/sw/source/uibase/sidebar/PageColumnControl.cxx
+++ b/sw/source/uibase/sidebar/PageColumnControl.cxx
@@ -19,7 +19,6 @@
#include "PageColumnControl.hxx"
#include "PagePropertyPanel.hxx"
-#include "PagePropertyPanel.hrc"
#include <cmdid.h>
#include <swtypes.hxx>
diff --git a/sw/source/uibase/sidebar/PageColumnControl.hxx b/sw/source/uibase/sidebar/PageColumnControl.hxx
index 79551ae93fa1..f83943dee1c2 100644
--- a/sw/source/uibase/sidebar/PageColumnControl.hxx
+++ b/sw/source/uibase/sidebar/PageColumnControl.hxx
@@ -21,6 +21,10 @@
#include <svx/tbxctl.hxx>
#include <vcl/button.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/sizeitem.hxx>
namespace sw { namespace sidebar {
diff --git a/sw/source/uibase/sidebar/PageMarginControl.cxx b/sw/source/uibase/sidebar/PageMarginControl.cxx
index ca73e952dfe0..b53227532e95 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.cxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.cxx
@@ -23,11 +23,18 @@
#include "PageMarginControl.hxx"
#include "PagePropertyPanel.hxx"
-#include "PagePropertyPanel.hrc"
+#include "PropertyPanel.hrc"
+
+#include <sfx2/dispatch.hxx>
+#include <svx/svxids.hrc>
+#include <svl/itempool.hxx>
+#include <svl/intitem.hxx>
#include <swtypes.hxx>
+#include <cmdid.h>
+
+#include <com/sun/star/document/XUndoManagerSupplier.hpp>
-#include <svx/sidebar/ValueSetWithTextControl.hxx>
#include <vcl/settings.hxx>
#define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
@@ -36,99 +43,180 @@
#define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
#define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
+namespace
+{
+ FieldUnit lcl_GetFieldUnit()
+ {
+ FieldUnit eUnit = FUNIT_INCH;
+ const SfxPoolItem* pItem = nullptr;
+ SfxItemState eState = SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_METRIC, pItem );
+ if ( pItem && eState >= SfxItemState::DEFAULT )
+ {
+ eUnit = (FieldUnit)static_cast<const SfxUInt16Item*>( pItem )->GetValue();
+ }
+ else
+ {
+ return SfxModule::GetCurrentFieldUnit();
+ }
+
+ return eUnit;
+ }
+
+ MapUnit lcl_GetUnit()
+ {
+ SfxItemPool &rPool = SfxGetpApp()->GetPool();
+ sal_uInt16 nWhich = rPool.GetWhich( SID_ATTR_PAGE_SIZE );
+ return rPool.GetMetric( nWhich );
+ }
+
+ const css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame )
+ {
+ const css::uno::Reference< css::frame::XController >& xController = rxFrame->getController();
+ if ( xController.is() )
+ {
+ const css::uno::Reference< css::frame::XModel >& xModel = xController->getModel();
+ if ( xModel.is() )
+ {
+ const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
+ if ( xSuppUndo.is() )
+ {
+ const css::uno::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), css::uno::UNO_QUERY_THROW );
+ return xUndoManager;
+ }
+ }
+ }
+
+ return css::uno::Reference< css::document::XUndoManager > ();
+ }
+}
+
namespace sw { namespace sidebar {
-PageMarginControl::PageMarginControl(
- vcl::Window* pParent,
- PagePropertyPanel& rPanel,
- const SvxLongLRSpaceItem& aPageLRMargin,
- const SvxLongULSpaceItem& aPageULMargin,
- const bool bMirrored,
- const Size& rPageSize,
- const bool bLandscape,
- const FieldUnit eFUnit,
- const MapUnit eUnit )
- : svx::sidebar::PopupControl( pParent, SW_RES(RID_POPUP_SWPAGE_MARGIN) )
- , mpMarginValueSet( VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( svx::sidebar::ValueSetWithTextControl::ControlType::ImageText, this, SW_RES(VS_MARGIN) ) )
- , maCustom(VclPtr<FixedText>::Create(this, SW_RES(FT_CUSTOM)))
- , maLeft(VclPtr<FixedText>::Create(this, SW_RES(FT_LEFT)))
- , maInner(VclPtr<FixedText>::Create(this, SW_RES(FT_INNER)))
- , maLeftMarginEdit(VclPtr<MetricField>::Create(this, SW_RES(MF_SWLEFT_MARGIN)))
- , maRight(VclPtr<FixedText>::Create(this, SW_RES(FT_RIGHT)))
- , maOuter(VclPtr<FixedText>::Create(this, SW_RES(FT_OUTER)))
- , maRightMarginEdit(VclPtr<MetricField>::Create(this, SW_RES(MF_SWRIGHT_MARGIN)))
- , maTop(VclPtr<FixedText>::Create(this, SW_RES(FT_TOP)))
- , maTopMarginEdit(VclPtr<MetricField>::Create(this, SW_RES(MF_SWTOP_MARGIN)))
- , maBottom(VclPtr<FixedText>::Create(this, SW_RES(FT_BOTTOM)))
- , maBottomMarginEdit(VclPtr<MetricField>::Create(this, SW_RES(MF_SWBOTTOM_MARGIN)))
- , maWidthHeightField(VclPtr<MetricField>::Create( this, SW_RES(FLD_WIDTH_HEIGHT) ) )
- , mnPageLeftMargin( aPageLRMargin.GetLeft() )
- , mnPageRightMargin( aPageLRMargin.GetRight() )
- , mnPageTopMargin( aPageULMargin.GetUpper() )
- , mnPageBottomMargin( aPageULMargin.GetLower() )
- , mbMirrored( bMirrored )
- , meUnit( eUnit )
- , mbUserCustomValuesAvailable(false)
- , mnUserCustomPageLeftMargin(0)
- , mnUserCustomPageRightMargin(0)
- , mnUserCustomPageTopMargin(0)
- , mnUserCustomPageBottomMargin(0)
- , mbUserCustomMirrored(false)
- , mbCustomValuesUsed( false )
- , mrPagePropPanel(rPanel)
+PageMarginControl::PageMarginControl( sal_uInt16 nId )
+ : SfxPopupWindow( nId, "PageMarginControl", "modules/swriter/ui/pagemargincontrol.ui" )
+ , m_eUnit( lcl_GetUnit() )
+ , m_bUserCustomValuesAvailable( false )
+ , m_nUserCustomPageLeftMargin( 0 )
+ , m_nUserCustomPageRightMargin( 0 )
+ , m_nUserCustomPageTopMargin( 0 )
+ , m_nUserCustomPageBottomMargin( 0 )
+ , m_bUserCustomMirrored( false )
+ , m_bCustomValuesUsed( false )
{
- maWidthHeightField->Hide();
- SetFieldUnit( *maWidthHeightField.get(), eFUnit );
-
- mbUserCustomValuesAvailable = GetUserCustomValues();
+ bool bLandscape = false;
+ const SfxPoolItem* pItem;
+ const SvxSizeItem* pSize = nullptr;
+ const SvxLongLRSpaceItem* pLRItem = nullptr;
+ const SvxLongULSpaceItem* pULItem = nullptr;
+ if ( SfxViewFrame::Current() )
+ {
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pItem );
+ bLandscape = static_cast<const SvxPageItem*>( pItem )->IsLandscape();
+ m_bMirrored = static_cast<const SvxPageItem*>( pItem )->GetPageUsage() == SVX_PAGE_MIRROR;
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pItem );
+ pSize = static_cast<const SvxSizeItem*>( pItem );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pItem );
+ pLRItem = static_cast<const SvxLongLRSpaceItem*>( pItem );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pItem );
+ pULItem = static_cast<const SvxLongULSpaceItem*>( pItem );
+ }
- mpMarginValueSet->SetStyle( mpMarginValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
- mpMarginValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
+ if ( pLRItem )
+ {
+ m_nPageLeftMargin = pLRItem->GetLeft();
+ m_nPageRightMargin = pLRItem->GetRight();
+ }
- FillValueSet( bLandscape, mbUserCustomValuesAvailable );
+ if ( pULItem )
+ {
+ m_nPageTopMargin = pULItem->GetUpper();
+ m_nPageBottomMargin = pULItem->GetLower();
+ }
- mpMarginValueSet->SetNoSelection();
- mpMarginValueSet->SetSelectHdl( LINK(this, PageMarginControl,ImplMarginHdl ) );
- mpMarginValueSet->Show();
+ if ( bLandscape )
+ {
+ get( m_pNarrow, "narrowL" );
+ get( m_pNormal, "normalL" );
+ get( m_pWide, "wideL" );
+ get( m_pMirrored, "mirroredL" );
+ get( m_pLast, "lastL" );
+ }
+ else
+ {
+ get( m_pNarrow, "narrow" );
+ get( m_pNormal, "normal" );
+ get( m_pWide, "wide" );
+ get( m_pMirrored, "mirrored" );
+ get( m_pLast, "last" );
+ }
- SelectValueSetItem();
+ m_pNarrow->Show();
+ m_pNormal->Show();
+ m_pWide->Show();
+ m_pMirrored->Show();
+ m_pLast->Show();
+
+ m_pNarrow->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
+ m_pNormal->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
+ m_pWide->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
+ m_pMirrored->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
+ m_pLast->SetClickHdl( LINK( this, PageMarginControl, SelectMarginHdl ) );
+
+ get( m_pContainer, "container" );
+ m_pWidthHeightField = VclPtr<MetricField>::Create( m_pContainer.get(), (WinBits)0 );
+ m_pWidthHeightField->Hide();
+ m_pWidthHeightField->SetUnit( FUNIT_CM );
+ m_pWidthHeightField->SetMax( 9999 );
+ m_pWidthHeightField->SetDecimalDigits( 2 );
+ m_pWidthHeightField->SetSpinSize( 10 );
+ m_pWidthHeightField->SetLast( 9999 );
+ SetFieldUnit( *m_pWidthHeightField.get(), lcl_GetFieldUnit() );
+
+ m_bUserCustomValuesAvailable = GetUserCustomValues();
+
+ FillHelpText( m_bUserCustomValuesAvailable );
+
+ get( m_pLeftMarginEdit, "left" );
+ get( m_pRightMarginEdit, "right" );
+ get( m_pTopMarginEdit, "top" );
+ get( m_pBottomMarginEdit, "bottom" );
- SetFieldUnit( *maLeftMarginEdit.get(), eFUnit );
Link<Edit&,void> aLinkLR = LINK( this, PageMarginControl, ModifyLRMarginHdl );
- maLeftMarginEdit->SetModifyHdl( aLinkLR );
- SetMetricValue( *maLeftMarginEdit.get(), mnPageLeftMargin, meUnit );
+ m_pLeftMarginEdit->SetModifyHdl( aLinkLR );
+ SetMetricValue( *m_pLeftMarginEdit.get(), m_nPageLeftMargin, m_eUnit );
- SetFieldUnit( *maRightMarginEdit.get(), eFUnit );
- maRightMarginEdit->SetModifyHdl( aLinkLR );
- SetMetricValue( *maRightMarginEdit.get(), mnPageRightMargin, meUnit );
+ m_pRightMarginEdit->SetModifyHdl( aLinkLR );
+ SetMetricValue( *m_pRightMarginEdit.get(), m_nPageRightMargin, m_eUnit );
Link<Edit&,void> aLinkUL = LINK( this, PageMarginControl, ModifyULMarginHdl );
- SetFieldUnit( *maTopMarginEdit.get(), eFUnit );
- maTopMarginEdit->SetModifyHdl( aLinkUL );
- SetMetricValue( *maTopMarginEdit.get(), mnPageTopMargin, meUnit );
+ m_pTopMarginEdit->SetModifyHdl( aLinkUL );
+ SetMetricValue( *m_pTopMarginEdit.get(), m_nPageTopMargin, m_eUnit );
- SetFieldUnit( *maBottomMarginEdit.get(), eFUnit );
- maBottomMarginEdit->SetModifyHdl( aLinkUL );
- SetMetricValue( *maBottomMarginEdit.get(), mnPageBottomMargin, meUnit );
+ m_pBottomMarginEdit->SetModifyHdl( aLinkUL );
+ SetMetricValue( *m_pBottomMarginEdit.get(), m_nPageBottomMargin, m_eUnit );
- SetMetricFieldMaxValues(rPageSize);
+ m_aPageSize = pSize->GetSize();
+ SetMetricFieldMaxValues( m_aPageSize );
- if ( mbMirrored )
+ get( m_pLeft, "leftLabel" );
+ get( m_pRight, "rightLabel" );
+ get( m_pInner, "innerLabel" );
+ get( m_pOuter, "outerLabel" );
+
+ if ( m_bMirrored )
{
- maLeft->Hide();
- maRight->Hide();
- maInner->Show();
- maOuter->Show();
+ m_pLeft->Hide();
+ m_pRight->Hide();
+ m_pInner->Show();
+ m_pOuter->Show();
}
else
{
- maLeft->Show();
- maRight->Show();
- maInner->Hide();
- maOuter->Hide();
+ m_pLeft->Show();
+ m_pRight->Show();
+ m_pInner->Hide();
+ m_pOuter->Hide();
}
-
- FreeResource();
}
PageMarginControl::~PageMarginControl()
@@ -138,63 +226,64 @@ PageMarginControl::~PageMarginControl()
void PageMarginControl::dispose()
{
- mpMarginValueSet.disposeAndClear();
-
StoreUserCustomValues();
- maCustom.disposeAndClear();
- maLeft.disposeAndClear();
- maInner.disposeAndClear();
- maLeftMarginEdit.disposeAndClear();
- maRight.disposeAndClear();
- maOuter.disposeAndClear();
- maRightMarginEdit.disposeAndClear();
- maTop.disposeAndClear();
- maTopMarginEdit.disposeAndClear();
- maBottom.disposeAndClear();
- maBottomMarginEdit.disposeAndClear();
- maWidthHeightField.disposeAndClear();
- svx::sidebar::PopupControl::dispose();
+ m_pLeft.disposeAndClear();
+ m_pRight.disposeAndClear();
+ m_pInner.disposeAndClear();
+ m_pOuter.disposeAndClear();
+ m_pLeftMarginEdit.disposeAndClear();
+ m_pRightMarginEdit.disposeAndClear();
+ m_pTopMarginEdit.disposeAndClear();
+ m_pBottomMarginEdit.disposeAndClear();
+ m_pNarrow.disposeAndClear();
+ m_pNormal.disposeAndClear();
+ m_pWide.disposeAndClear();
+ m_pMirrored.disposeAndClear();
+ m_pLast.disposeAndClear();
+
+ m_pWidthHeightField.disposeAndClear();
+ m_pContainer.disposeAndClear();
+
+ SfxPopupWindow::dispose();
}
-void PageMarginControl::SetMetricFieldMaxValues(const Size& rPageSize)
+void PageMarginControl::SetMetricFieldMaxValues( const Size& rPageSize )
{
- const long nML = maLeftMarginEdit->Denormalize( maLeftMarginEdit->GetValue(FUNIT_TWIP) );
- const long nMR = maRightMarginEdit->Denormalize( maRightMarginEdit->GetValue(FUNIT_TWIP) );
- const long nMT = maTopMarginEdit->Denormalize(maTopMarginEdit->GetValue(FUNIT_TWIP) );
- const long nMB = maBottomMarginEdit->Denormalize( maBottomMarginEdit->GetValue(FUNIT_TWIP) );
+ const long nML = m_pLeftMarginEdit->Denormalize( m_pLeftMarginEdit->GetValue( FUNIT_TWIP ) );
+ const long nMR = m_pRightMarginEdit->Denormalize( m_pRightMarginEdit->GetValue( FUNIT_TWIP ) );
+ const long nMT = m_pTopMarginEdit->Denormalize( m_pTopMarginEdit->GetValue( FUNIT_TWIP ) );
+ const long nMB = m_pBottomMarginEdit->Denormalize( m_pBottomMarginEdit->GetValue( FUNIT_TWIP ) );
- const long nPH = LogicToLogic( rPageSize.Height(), (MapUnit)meUnit, MAP_TWIP );
- const long nPW = LogicToLogic( rPageSize.Width(), (MapUnit)meUnit, MAP_TWIP );
+ const long nPH = LogicToLogic( rPageSize.Height(), (MapUnit)m_eUnit, MAP_TWIP );
+ const long nPW = LogicToLogic( rPageSize.Width(), (MapUnit)m_eUnit, MAP_TWIP );
// Left
long nMax = nPW - nMR - MINBODY;
- maLeftMarginEdit->SetMax(maLeftMarginEdit->Normalize(nMax), FUNIT_TWIP);
+ m_pLeftMarginEdit->SetMax( m_pLeftMarginEdit->Normalize( nMax ), FUNIT_TWIP );
// Right
nMax = nPW - nML - MINBODY;
- maRightMarginEdit->SetMax(maRightMarginEdit->Normalize(nMax), FUNIT_TWIP);
+ m_pRightMarginEdit->SetMax( m_pRightMarginEdit->Normalize( nMax ), FUNIT_TWIP );
//Top
nMax = nPH - nMB - MINBODY;
- maTopMarginEdit->SetMax(maTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
+ m_pTopMarginEdit->SetMax( m_pTopMarginEdit->Normalize( nMax ), FUNIT_TWIP );
//Bottom
nMax = nPH - nMT - MINBODY;
- maBottomMarginEdit->SetMax(maTopMarginEdit->Normalize(nMax), FUNIT_TWIP);
+ m_pBottomMarginEdit->SetMax( m_pTopMarginEdit->Normalize( nMax ), FUNIT_TWIP );
}
-void PageMarginControl::FillValueSet(
- const bool bLandscape,
- const bool bUserCustomValuesAvailable )
+void PageMarginControl::FillHelpText( const bool bUserCustomValuesAvailable )
{
- const OUString aLeft = SW_RESSTR(STR_MARGIN_TOOLTIP_LEFT);
- const OUString aRight = SW_RESSTR(STR_MARGIN_TOOLTIP_RIGHT);
- const OUString aTop = SW_RESSTR(STR_MARGIN_TOOLTIP_TOP);
- const OUString aBottom = SW_RESSTR(STR_MARGIN_TOOLTIP_BOT);
+ const OUString aLeft = SW_RESSTR( STR_MARGIN_TOOLTIP_LEFT );
+ const OUString aRight = SW_RESSTR( STR_MARGIN_TOOLTIP_RIGHT );
+ const OUString aTop = SW_RESSTR( STR_MARGIN_TOOLTIP_TOP );
+ const OUString aBottom = SW_RESSTR( STR_MARGIN_TOOLTIP_BOT );
- SetMetricValue( *maWidthHeightField.get(), SWPAGE_NARROW_VALUE, meUnit );
- const OUString aNarrowValText = maWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_NARROW_VALUE, m_eUnit );
+ const OUString aNarrowValText = m_pWidthHeightField->GetText();
OUString aHelpText = aLeft;
aHelpText += aNarrowValText;
aHelpText += aRight;
@@ -203,12 +292,10 @@ void PageMarginControl::FillValueSet(
aHelpText += aNarrowValText;
aHelpText += aBottom;
aHelpText += aNarrowValText;
- mpMarginValueSet->AddItem(
- Image((bLandscape) ? SW_RES(IMG_NARROW_L) : SW_RES(IMG_NARROW)),
- SW_RESSTR(STR_NARROW), &aHelpText );
+ m_pNarrow->SetQuickHelpText( aHelpText );
- SetMetricValue( *maWidthHeightField.get(), SWPAGE_NORMAL_VALUE, meUnit );
- const OUString aNormalValText = maWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_NORMAL_VALUE, m_eUnit );
+ const OUString aNormalValText = m_pWidthHeightField->GetText();
aHelpText = aLeft;
aHelpText += aNormalValText;
aHelpText += aRight;
@@ -217,14 +304,12 @@ void PageMarginControl::FillValueSet(
aHelpText += aNormalValText;
aHelpText += aBottom;
aHelpText += aNormalValText;
- mpMarginValueSet->AddItem(
- Image((bLandscape) ? SW_RES(IMG_NORMAL_L) : SW_RES(IMG_NORMAL)),
- SW_RESSTR(STR_NORMAL), &aHelpText );
-
- SetMetricValue( *maWidthHeightField.get(), SWPAGE_WIDE_VALUE1, meUnit );
- const OUString aWide1ValText = maWidthHeightField->GetText();
- SetMetricValue( *maWidthHeightField.get(), SWPAGE_WIDE_VALUE2, meUnit );
- const OUString aWide2ValText = maWidthHeightField->GetText();
+ m_pNormal->SetQuickHelpText( aHelpText );
+
+ SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE1, m_eUnit );
+ const OUString aWide1ValText = m_pWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE2, m_eUnit );
+ const OUString aWide2ValText = m_pWidthHeightField->GetText();
aHelpText = aLeft;
aHelpText += aWide2ValText;
aHelpText += aRight;
@@ -233,15 +318,13 @@ void PageMarginControl::FillValueSet(
aHelpText += aWide1ValText;
aHelpText += aBottom;
aHelpText += aWide1ValText;
- mpMarginValueSet->AddItem(
- Image((bLandscape) ? SW_RES(IMG_WIDE_L) : SW_RES(IMG_WIDE)),
- SW_RESSTR(STR_WIDE), &aHelpText );
+ m_pWide->SetQuickHelpText( aHelpText );
- const OUString aInner = SW_RESSTR(STR_MARGIN_TOOLTIP_INNER);
- const OUString aOuter = SW_RESSTR(STR_MARGIN_TOOLTIP_OUTER);
+ const OUString aInner = SW_RESSTR( STR_MARGIN_TOOLTIP_INNER );
+ const OUString aOuter = SW_RESSTR( STR_MARGIN_TOOLTIP_OUTER );
- SetMetricValue( *maWidthHeightField.get(), SWPAGE_WIDE_VALUE3, meUnit );
- const OUString aWide3ValText = maWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), SWPAGE_WIDE_VALUE3, m_eUnit );
+ const OUString aWide3ValText = m_pWidthHeightField->GetText();
aHelpText = aInner;
aHelpText += aWide3ValText;
aHelpText += aOuter;
@@ -250,181 +333,162 @@ void PageMarginControl::FillValueSet(
aHelpText += aWide1ValText;
aHelpText += aBottom;
aHelpText += aWide1ValText;
- mpMarginValueSet->AddItem(
- Image((bLandscape) ? SW_RES(IMG_MIRRORED_L) : SW_RES(IMG_MIRRORED)),
- SW_RESSTR(STR_MIRRORED), &aHelpText );
+ m_pMirrored->SetQuickHelpText( aHelpText );
if ( bUserCustomValuesAvailable )
{
- aHelpText = mbUserCustomMirrored ? aInner : aLeft;
- SetMetricValue( *maWidthHeightField.get(), mnUserCustomPageLeftMargin, meUnit );
- aHelpText += maWidthHeightField->GetText();
- aHelpText += mbUserCustomMirrored ? aOuter : aRight;
- SetMetricValue( *maWidthHeightField.get(), mnUserCustomPageRightMargin, meUnit );
- aHelpText += maWidthHeightField->GetText();
+ aHelpText = m_bUserCustomMirrored ? aInner : aLeft;
+ SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageLeftMargin, m_eUnit );
+ aHelpText += m_pWidthHeightField->GetText();
+ aHelpText += m_bUserCustomMirrored ? aOuter : aRight;
+ SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageRightMargin, m_eUnit );
+ aHelpText += m_pWidthHeightField->GetText();
aHelpText += aTop;
- SetMetricValue( *maWidthHeightField.get(), mnUserCustomPageTopMargin, meUnit );
- aHelpText += maWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageTopMargin, m_eUnit );
+ aHelpText += m_pWidthHeightField->GetText();
aHelpText += aBottom;
- SetMetricValue( *maWidthHeightField.get(), mnUserCustomPageBottomMargin, meUnit );
- aHelpText += maWidthHeightField->GetText();
+ SetMetricValue( *m_pWidthHeightField.get(), m_nUserCustomPageBottomMargin, m_eUnit );
+ aHelpText += m_pWidthHeightField->GetText();
}
else
{
aHelpText.clear();
}
- mpMarginValueSet->AddItem(
- Image((bUserCustomValuesAvailable) ? SW_RES(IMG_CUSTOM) : SW_RES(IMG_CUSTOM_DIS)),
- SW_RESSTR(STR_LCVALUE), &aHelpText );
+ m_pLast->SetQuickHelpText( aHelpText );
}
-void PageMarginControl::SelectValueSetItem()
+IMPL_LINK_TYPED( PageMarginControl, SelectMarginHdl, Button*, pControl, void )
{
- const long cTolerance = 5;
-
- if( std::abs(mnPageLeftMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mnPageRightMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mnPageTopMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mnPageBottomMargin - SWPAGE_NARROW_VALUE) <= cTolerance &&
- !mbMirrored )
+ bool bMirrored = false;
+ bool bApplyNewPageMargins = true;
+ if( pControl == m_pNarrow.get() )
{
- mpMarginValueSet->SelectItem(1);
+ m_nPageLeftMargin = SWPAGE_NARROW_VALUE;
+ m_nPageRightMargin = SWPAGE_NARROW_VALUE;
+ m_nPageTopMargin = SWPAGE_NARROW_VALUE;
+ m_nPageBottomMargin = SWPAGE_NARROW_VALUE;
+ bMirrored = false;
}
- else if( std::abs(mnPageLeftMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mnPageRightMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mnPageTopMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mnPageBottomMargin - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- !mbMirrored )
+ if( pControl == m_pNormal.get() )
{
- mpMarginValueSet->SelectItem(2);
+ m_nPageLeftMargin = SWPAGE_NORMAL_VALUE;
+ m_nPageRightMargin = SWPAGE_NORMAL_VALUE;
+ m_nPageTopMargin = SWPAGE_NORMAL_VALUE;
+ m_nPageBottomMargin = SWPAGE_NORMAL_VALUE;
+ bMirrored = false;
}
- else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
- std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE2) <= cTolerance &&
- std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- !mbMirrored )
+ if( pControl == m_pWide.get() )
{
- mpMarginValueSet->SelectItem(3);
+ m_nPageLeftMargin = SWPAGE_WIDE_VALUE2;
+ m_nPageRightMargin = SWPAGE_WIDE_VALUE2;
+ m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
+ m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
+ bMirrored = false;
}
- else if( std::abs(mnPageLeftMargin - SWPAGE_WIDE_VALUE3) <= cTolerance &&
- std::abs(mnPageRightMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mnPageTopMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mnPageBottomMargin - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- mbMirrored )
+ if( pControl == m_pMirrored.get() )
{
- mpMarginValueSet->SelectItem(4);
+ m_nPageLeftMargin = SWPAGE_WIDE_VALUE3;
+ m_nPageRightMargin = SWPAGE_WIDE_VALUE1;
+ m_nPageTopMargin = SWPAGE_WIDE_VALUE1;
+ m_nPageBottomMargin = SWPAGE_WIDE_VALUE1;
+ bMirrored = true;
}
- else
+ if( pControl == m_pLast.get() )
{
- mpMarginValueSet->SelectItem(0);
+ if ( m_bUserCustomValuesAvailable )
+ {
+ m_nPageLeftMargin = m_nUserCustomPageLeftMargin;
+ m_nPageRightMargin = m_nUserCustomPageRightMargin;
+ m_nPageTopMargin = m_nUserCustomPageTopMargin;
+ m_nPageBottomMargin = m_nUserCustomPageBottomMargin;
+ bMirrored = m_bUserCustomMirrored;
+ }
+ else
+ {
+ bApplyNewPageMargins = false;
+ }
}
- mpMarginValueSet->SetFormat();
- mpMarginValueSet->Invalidate();
- mpMarginValueSet->StartSelection();
-};
-IMPL_LINK_TYPED(PageMarginControl, ImplMarginHdl, ValueSet*, pControl, void)
-{
- if ( pControl == mpMarginValueSet )
+ if ( bApplyNewPageMargins )
{
- bool bMirrored = false;
- bool bApplyNewPageMargins = true;
- switch ( mpMarginValueSet->GetSelectItemId() )
+ const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager( SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
+ if ( xUndoManager.is() )
+ xUndoManager->enterUndoContext( "" );
+
+ ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
+ ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
+ if ( m_bMirrored != bMirrored )
{
- case 1:
- mnPageLeftMargin = SWPAGE_NARROW_VALUE;
- mnPageRightMargin = SWPAGE_NARROW_VALUE;
- mnPageTopMargin = SWPAGE_NARROW_VALUE;
- mnPageBottomMargin = SWPAGE_NARROW_VALUE;
- bMirrored = false;
- break;
- case 2:
- mnPageLeftMargin = SWPAGE_NORMAL_VALUE;
- mnPageRightMargin = SWPAGE_NORMAL_VALUE;
- mnPageTopMargin = SWPAGE_NORMAL_VALUE;
- mnPageBottomMargin = SWPAGE_NORMAL_VALUE;
- bMirrored = false;
- break;
- case 3:
- mnPageLeftMargin = SWPAGE_WIDE_VALUE2;
- mnPageRightMargin = SWPAGE_WIDE_VALUE2;
- mnPageTopMargin = SWPAGE_WIDE_VALUE1;
- mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
- bMirrored = false;
- break;
- case 4:
- mnPageLeftMargin = SWPAGE_WIDE_VALUE3;
- mnPageRightMargin = SWPAGE_WIDE_VALUE1;
- mnPageTopMargin = SWPAGE_WIDE_VALUE1;
- mnPageBottomMargin = SWPAGE_WIDE_VALUE1;
- bMirrored = true;
- break;
- case 5:
- if ( mbUserCustomValuesAvailable )
- {
- mnPageLeftMargin = mnUserCustomPageLeftMargin;
- mnPageRightMargin = mnUserCustomPageRightMargin;
- mnPageTopMargin = mnUserCustomPageTopMargin;
- mnPageBottomMargin = mnUserCustomPageBottomMargin;
- bMirrored = mbUserCustomMirrored;
- }
- else
- {
- bApplyNewPageMargins = false;
- }
- break;
+ m_bMirrored = bMirrored;
+ ExecutePageLayoutChange( m_bMirrored );
}
- if ( bApplyNewPageMargins )
- {
- mrPagePropPanel.StartUndo();
- mpMarginValueSet->SetNoSelection();
- mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
- mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
- if ( mbMirrored != bMirrored )
- {
- mbMirrored = bMirrored;
- mrPagePropPanel.ExecutePageLayoutChange( mbMirrored );
- }
- mrPagePropPanel.EndUndo();
+ if ( xUndoManager.is() )
+ xUndoManager->leaveUndoContext();
- mbCustomValuesUsed = false;
- mrPagePropPanel.ClosePageMarginPopup();
- }
- else
- {
- // back to initial selection
- SelectValueSetItem();
- }
+ m_bCustomValuesUsed = false;
+ EndPopupMode();
+ }
+}
+
+void PageMarginControl::ExecuteMarginLRChange(
+ const long nPageLeftMargin,
+ const long nPageRightMargin )
+{
+ if ( SfxViewFrame::Current() )
+ {
+ std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) );
+ pPageLRMarginItem->SetLeft( nPageLeftMargin );
+ pPageLRMarginItem->SetRight( nPageRightMargin );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE,
+ SfxCallMode::RECORD, { pPageLRMarginItem.get() } );
+ pPageLRMarginItem.reset();
+ }
+}
+
+void PageMarginControl::ExecuteMarginULChange(
+ const long nPageTopMargin,
+ const long nPageBottomMargin )
+{
+ if ( SfxViewFrame::Current() )
+ {
+ std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) );
+ pPageULMarginItem->SetUpper( nPageTopMargin );
+ pPageULMarginItem->SetLower( nPageBottomMargin );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE,
+ SfxCallMode::RECORD, { pPageULMarginItem.get() } );
+ pPageULMarginItem.reset();
+ }
+}
+
+void PageMarginControl::ExecutePageLayoutChange( const bool bMirrored )
+{
+ if ( SfxViewFrame::Current() )
+ {
+ std::unique_ptr<SvxPageItem> pPageItem( new SvxPageItem( SID_ATTR_PAGE ) );
+ pPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE,
+ SfxCallMode::RECORD, { pPageItem.get() } );
+ pPageItem.reset();
}
}
IMPL_LINK_NOARG_TYPED( PageMarginControl, ModifyLRMarginHdl, Edit&, void )
{
- mpMarginValueSet->SetNoSelection();
- mpMarginValueSet->SelectItem(0);
- mpMarginValueSet->SetFormat();
- mpMarginValueSet->Invalidate();
- mpMarginValueSet->StartSelection();
-
- mnPageLeftMargin = GetCoreValue( *maLeftMarginEdit.get(), meUnit );
- mnPageRightMargin = GetCoreValue( *maRightMarginEdit.get(), meUnit );
- mrPagePropPanel.ExecuteMarginLRChange( mnPageLeftMargin, mnPageRightMargin );
- mbCustomValuesUsed = true;
+ m_nPageLeftMargin = GetCoreValue( *m_pLeftMarginEdit.get(), m_eUnit );
+ m_nPageRightMargin = GetCoreValue( *m_pRightMarginEdit.get(), m_eUnit );
+ ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
+ SetMetricFieldMaxValues( m_aPageSize );
+ m_bCustomValuesUsed = true;
}
IMPL_LINK_NOARG_TYPED( PageMarginControl, ModifyULMarginHdl, Edit&, void )
{
- mpMarginValueSet->SetNoSelection();
- mpMarginValueSet->SelectItem(0);
- mpMarginValueSet->SetFormat();
- mpMarginValueSet->Invalidate();
- mpMarginValueSet->StartSelection();
-
- mnPageTopMargin = GetCoreValue( *maTopMarginEdit.get(), meUnit );
- mnPageBottomMargin = GetCoreValue( *maBottomMarginEdit.get(), meUnit );
- mrPagePropPanel.ExecuteMarginULChange( mnPageTopMargin, mnPageBottomMargin );
- mbCustomValuesUsed = true;
+ m_nPageTopMargin = GetCoreValue( *m_pTopMarginEdit.get(), m_eUnit );
+ m_nPageBottomMargin = GetCoreValue( *m_pBottomMarginEdit.get(), m_eUnit );
+ ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
+ SetMetricFieldMaxValues( m_aPageSize );
+ m_bCustomValuesUsed = true;
}
bool PageMarginControl::GetUserCustomValues()
@@ -439,7 +503,7 @@ bool PageMarginControl::GetUserCustomValues()
if ( aSeq.getLength())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
- mnUserCustomPageLeftMargin = aWinData.toInt32();
+ m_nUserCustomPageLeftMargin = aWinData.toInt32();
bUserCustomValuesAvailable = true;
}
@@ -451,7 +515,7 @@ bool PageMarginControl::GetUserCustomValues()
if ( aSeq.getLength())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
- mnUserCustomPageRightMargin = aWinData.toInt32();
+ m_nUserCustomPageRightMargin = aWinData.toInt32();
bUserCustomValuesAvailable = true;
}
@@ -460,10 +524,10 @@ bool PageMarginControl::GetUserCustomValues()
{
css::uno::Sequence < css::beans::NamedValue > aSeq = aWinOpt3.GetUserData();
OUString aTmp;
- if ( aSeq.getLength())
+ if ( aSeq.getLength() )
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
- mnUserCustomPageTopMargin = aWinData.toInt32();
+ m_nUserCustomPageTopMargin = aWinData.toInt32();
bUserCustomValuesAvailable = true;
}
@@ -475,7 +539,7 @@ bool PageMarginControl::GetUserCustomValues()
if ( aSeq.getLength())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
- mnUserCustomPageBottomMargin = aWinData.toInt32();
+ m_nUserCustomPageBottomMargin = aWinData.toInt32();
bUserCustomValuesAvailable = true;
}
@@ -487,7 +551,7 @@ bool PageMarginControl::GetUserCustomValues()
if ( aSeq.getLength())
aSeq[0].Value >>= aTmp;
OUString aWinData( aTmp );
- mbUserCustomMirrored = aWinData.toInt32() != 0;
+ m_bUserCustomMirrored = aWinData.toInt32() != 0;
bUserCustomValuesAvailable = true;
}
@@ -496,36 +560,36 @@ bool PageMarginControl::GetUserCustomValues()
void PageMarginControl::StoreUserCustomValues()
{
- if ( !mbCustomValuesUsed )
+ if ( !m_bCustomValuesUsed )
{
return;
}
- css::uno::Sequence < css::beans::NamedValue > aSeq(1);
+ css::uno::Sequence < css::beans::NamedValue > aSeq( 1 );
SvtViewOptions aWinOpt( E_WINDOW, SWPAGE_LEFT_GVALUE );
aSeq[0].Name = "mnPageLeftMargin";
- aSeq[0].Value <<= OUString::number( mnPageLeftMargin );
+ aSeq[0].Value <<= OUString::number( m_nPageLeftMargin );
aWinOpt.SetUserData( aSeq );
SvtViewOptions aWinOpt2( E_WINDOW, SWPAGE_RIGHT_GVALUE );
aSeq[0].Name = "mnPageRightMargin";
- aSeq[0].Value <<= OUString::number( mnPageRightMargin );
+ aSeq[0].Value <<= OUString::number( m_nPageRightMargin );
aWinOpt2.SetUserData( aSeq );
SvtViewOptions aWinOpt3( E_WINDOW, SWPAGE_TOP_GVALUE );
aSeq[0].Name = "mnPageTopMargin";
- aSeq[0].Value <<= OUString::number( mnPageTopMargin );
+ aSeq[0].Value <<= OUString::number( m_nPageTopMargin );
aWinOpt3.SetUserData( aSeq );
SvtViewOptions aWinOpt4( E_WINDOW, SWPAGE_DOWN_GVALUE );
aSeq[0].Name = "mnPageBottomMargin";
- aSeq[0].Value <<= OUString::number( mnPageBottomMargin );
+ aSeq[0].Value <<= OUString::number( m_nPageBottomMargin );
aWinOpt4.SetUserData( aSeq );
SvtViewOptions aWinOpt5( E_WINDOW, SWPAGE_MIRROR_GVALUE );
aSeq[0].Name = "mbMirrored";
- aSeq[0].Value <<= OUString::number( (mbMirrored ? 1 : 0) );
+ aSeq[0].Value <<= OUString::number( (m_bMirrored ? 1 : 0) );
aWinOpt5.SetUserData( aSeq );
}
diff --git a/sw/source/uibase/sidebar/PageMarginControl.hxx b/sw/source/uibase/sidebar/PageMarginControl.hxx
index 1956d5d6d801..5336b14bf26f 100644
--- a/sw/source/uibase/sidebar/PageMarginControl.hxx
+++ b/sw/source/uibase/sidebar/PageMarginControl.hxx
@@ -29,6 +29,9 @@
#include <vcl/field.hxx>
#include <svtools/unitconv.hxx>
#include <vector>
+#include <vcl/layout.hxx>
+
+#include <svx/tbxctl.hxx>
#define SWPAGE_NARROW_VALUE 720
#define SWPAGE_NORMAL_VALUE 1136
@@ -36,84 +39,78 @@
#define SWPAGE_WIDE_VALUE2 2880
#define SWPAGE_WIDE_VALUE3 1800
-namespace svx { namespace sidebar {
- class ValueSetWithTextControl;
-} }
-class ValueSet;
-
static const long MINBODY = 284; //0.5 cm in twips
namespace sw { namespace sidebar {
class PagePropertyPanel;
-class PageMarginControl
- : public svx::sidebar::PopupControl
+class PageMarginControl : public SfxPopupWindow
{
public:
- PageMarginControl(
- vcl::Window* pParent,
- PagePropertyPanel& rPanel,
- const SvxLongLRSpaceItem& aPageLRMargin,
- const SvxLongULSpaceItem& aPageULMargin,
- const bool bMirrored,
- const Size& rPageSize,
- const bool bLandscape,
- const FieldUnit eFUnit,
- const MapUnit eUnit );
+ PageMarginControl( sal_uInt16 nId );
virtual ~PageMarginControl() override;
virtual void dispose() override;
private:
- VclPtr< svx::sidebar::ValueSetWithTextControl> mpMarginValueSet;
-
- VclPtr<FixedText> maCustom;
- VclPtr<FixedText> maLeft;
- VclPtr<FixedText> maInner;
- VclPtr<MetricField> maLeftMarginEdit;
- VclPtr<FixedText> maRight;
- VclPtr<FixedText> maOuter;
- VclPtr<MetricField> maRightMarginEdit;
- VclPtr<FixedText> maTop;
- VclPtr<MetricField> maTopMarginEdit;
- VclPtr<FixedText> maBottom;
- VclPtr<MetricField> maBottomMarginEdit;
+ VclPtr<PushButton> m_pNarrow;
+ VclPtr<PushButton> m_pNormal;
+ VclPtr<PushButton> m_pWide;
+ VclPtr<PushButton> m_pMirrored;
+ VclPtr<PushButton> m_pLast;
+
+ VclPtr<FixedText> m_pLeft;
+ VclPtr<FixedText> m_pRight;
+ VclPtr<FixedText> m_pInner;
+ VclPtr<FixedText> m_pOuter;
+
+ VclPtr<VclVBox> m_pContainer;
+
+ VclPtr<MetricField> m_pLeftMarginEdit;
+ VclPtr<MetricField> m_pRightMarginEdit;
+ VclPtr<MetricField> m_pTopMarginEdit;
+ VclPtr<MetricField> m_pBottomMarginEdit;
// hidden metric field
- VclPtr<MetricField> maWidthHeightField;
+ VclPtr<MetricField> m_pWidthHeightField;
- long mnPageLeftMargin;
- long mnPageRightMargin;
- long mnPageTopMargin;
- long mnPageBottomMargin;
- bool mbMirrored;
+ long m_nPageLeftMargin;
+ long m_nPageRightMargin;
+ long m_nPageTopMargin;
+ long m_nPageBottomMargin;
+ bool m_bMirrored;
- const MapUnit meUnit;
+ const MapUnit m_eUnit;
- bool mbUserCustomValuesAvailable;
- long mnUserCustomPageLeftMargin;
- long mnUserCustomPageRightMargin;
- long mnUserCustomPageTopMargin;
- long mnUserCustomPageBottomMargin;
- bool mbUserCustomMirrored;
+ Size m_aPageSize;
- bool mbCustomValuesUsed;
+ bool m_bUserCustomValuesAvailable;
+ long m_nUserCustomPageLeftMargin;
+ long m_nUserCustomPageRightMargin;
+ long m_nUserCustomPageTopMargin;
+ long m_nUserCustomPageBottomMargin;
+ bool m_bUserCustomMirrored;
- PagePropertyPanel& mrPagePropPanel;
+ bool m_bCustomValuesUsed;
- DECL_LINK_TYPED( ImplMarginHdl, ValueSet*, void );
+ DECL_LINK_TYPED( SelectMarginHdl, Button*, void );
DECL_LINK_TYPED( ModifyLRMarginHdl, Edit&, void );
DECL_LINK_TYPED( ModifyULMarginHdl, Edit&, void );
+ static void ExecuteMarginLRChange(
+ const long nPageLeftMargin,
+ const long nPageRightMargin );
+ static void ExecuteMarginULChange(
+ const long nPageTopMargin,
+ const long nPageBottomMargin );
+ static void ExecutePageLayoutChange( const bool bMirrored );
+
void SetMetricFieldMaxValues(const Size& rPageSize);
bool GetUserCustomValues();
void StoreUserCustomValues();
- void FillValueSet(
- const bool bLandscape,
- const bool bUserCustomValuesAvailable );
- void SelectValueSetItem();
+ void FillHelpText( const bool bUserCustomValuesAvailable );
};
} } // end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageMarginPopup.cxx b/sw/source/uibase/sidebar/PageMarginPopup.cxx
new file mode 100644
index 000000000000..29bf80111bf7
--- /dev/null
+++ b/sw/source/uibase/sidebar/PageMarginPopup.cxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#include <PageMarginPopup.hxx>
+#include "PageMarginControl.hxx"
+#include <svx/pageitem.hxx>
+#include <vcl/toolbox.hxx>
+
+SFX_IMPL_TOOLBOX_CONTROL(PageMarginPopup, SfxVoidItem);
+
+PageMarginPopup::PageMarginPopup(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
+ : SfxToolBoxControl(nSlotId, nId, rTbx)
+{
+ rTbx.SetItemBits(nId, ToolBoxItemBits::DROPDOWNONLY | rTbx.GetItemBits(nId));
+}
+
+PageMarginPopup::~PageMarginPopup()
+{
+}
+
+VclPtr<SfxPopupWindow> PageMarginPopup::CreatePopupWindow()
+{
+ VclPtr<sw::sidebar::PageMarginControl> pControl = VclPtr<sw::sidebar::PageMarginControl>::Create(GetSlotId());
+ pControl->StartPopupMode(&GetToolBox(), FloatWinPopupFlags::GrabFocus|FloatWinPopupFlags::NoAppFocusClose);
+ SetPopupWindow(pControl);
+
+ return pControl;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.cxx b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
index 9094088b250e..a051a472d7c5 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.cxx
@@ -22,12 +22,8 @@
#include <cstdlib>
#include "PagePropertyPanel.hxx"
-#include "PagePropertyPanel.hrc"
-
-#include "PropertyPanel.hrc"
#include <svx/sidebar/PopupContainer.hxx>
-#include "PageMarginControl.hxx"
#include <swtypes.hxx>
#include <cmdid.h>
@@ -47,81 +43,15 @@
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/document/XUndoManagerSupplier.hpp>
-
-const char UNO_MARGIN[] = ".uno:Margin";
-
-namespace {
- const css::uno::Reference< css::document::XUndoManager > getUndoManager( const css::uno::Reference< css::frame::XFrame >& rxFrame )
- {
- const css::uno::Reference< css::frame::XController >& xController = rxFrame->getController();
- if ( xController.is() )
- {
- const css::uno::Reference< css::frame::XModel >& xModel = xController->getModel();
- if ( xModel.is() )
- {
- const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
- if ( xSuppUndo.is() )
- {
- const css::uno::Reference< css::document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), css::uno::UNO_QUERY_THROW );
- return xUndoManager;
- }
- }
- }
-
- return css::uno::Reference< css::document::XUndoManager > ();
- }
-}
namespace sw { namespace sidebar {
PagePropertyPanel::PagePropertyPanel(
vcl::Window* pParent,
const css::uno::Reference< css::frame::XFrame>& rxFrame,
- SfxBindings* pBindings)
+ SfxBindings* )
: PanelLayout(pParent, "PagePropertyPanel", "modules/swriter/ui/sidebarpage.ui", rxFrame)
- , mpBindings(pBindings)
-
- // image resources
- , maImgSize (nullptr)
- , maImgSize_L (nullptr)
- , mImgNarrow (SW_RES(IMG_PAGE_NARROW))
- , mImgNormal (SW_RES(IMG_PAGE_NORMAL))
- , mImgWide (SW_RES(IMG_PAGE_WIDE))
- , mImgMirrored (SW_RES(IMG_PAGE_MIRRORED))
- , mImgMarginCustom (SW_RES(IMG_PAGE_MARGIN_CUSTOM))
- , mImgNarrow_L (SW_RES(IMG_PAGE_NARROW_L))
- , mImgNormal_L (SW_RES(IMG_PAGE_NORMAL_L))
- , mImgWide_L (SW_RES(IMG_PAGE_WIDE_L))
- , mImgMirrored_L (SW_RES(IMG_PAGE_MIRRORED_L))
- , mImgMarginCustom_L (SW_RES(IMG_PAGE_MARGIN_CUSTOM_L))
-
- , mpPageItem( new SvxPageItem(SID_ATTR_PAGE) )
- , mpPageLRMarginItem( new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) )
- , mpPageULMarginItem( new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) )
- , mpPageSizeItem( new SvxSizeItem(SID_ATTR_PAGE_SIZE) )
-
- , meFUnit()
- , meUnit()
-
- , m_aSwPagePgULControl(SID_ATTR_PAGE_ULSPACE, *pBindings, *this)
- , m_aSwPagePgLRControl(SID_ATTR_PAGE_LRSPACE, *pBindings, *this)
- , m_aSwPagePgSizeControl(SID_ATTR_PAGE_SIZE, *pBindings, *this)
- , m_aSwPagePgMetricControl(SID_ATTR_METRIC, *pBindings, *this)
-
- , maMarginPopup( this,
- [this] (svx::sidebar::PopupContainer *parent) { return this->CreatePageMarginControl(parent); },
- OUString("Page margins") )
-
- , mxUndoManager( getUndoManager( rxFrame ) )
-
- , mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify( false )
{
- // visible controls
- get(mpToolBoxMargin, "selectmargin");
-
- Initialize();
- mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify = true;
}
PagePropertyPanel::~PagePropertyPanel()
@@ -131,238 +61,9 @@ PagePropertyPanel::~PagePropertyPanel()
void PagePropertyPanel::dispose()
{
- delete[] maImgSize;
- maImgSize = nullptr;
- delete[] maImgSize_L;
- maImgSize_L = nullptr;
-
- mpPageItem.reset();
- mpPageLRMarginItem.reset();
- mpPageULMarginItem.reset();
- mpPageSizeItem.reset();
-
- mpToolBoxMargin.clear();
-
- m_aSwPagePgULControl.dispose();
- m_aSwPagePgLRControl.dispose();
- m_aSwPagePgSizeControl.dispose();
- m_aSwPagePgMetricControl.dispose();
-
- maMarginPopup.dispose();
-
PanelLayout::dispose();
}
-void PagePropertyPanel::Initialize()
-{
- // popup for page margins
- const sal_uInt16 nIdMargin = mpToolBoxMargin->GetItemId(UNO_MARGIN);
- Link<ToolBox *, void> aLink = LINK( this, PagePropertyPanel, ClickMarginHdl );
- mpToolBoxMargin->SetDropdownClickHdl( aLink );
- mpToolBoxMargin->SetSelectHdl( aLink );
- mpToolBoxMargin->SetItemImage(nIdMargin, mImgNormal);
- mpToolBoxMargin->SetItemBits( nIdMargin, mpToolBoxMargin->GetItemBits( nIdMargin ) | ToolBoxItemBits::DROPDOWNONLY );
-
- meFUnit = GetModuleFieldUnit();
- meUnit = m_aSwPagePgSizeControl.GetCoreMetric();
-
- // 'pull' for page style's attribute values
- mpBindings->Update( SID_ATTR_PAGE_LRSPACE );
- mpBindings->Update( SID_ATTR_PAGE_ULSPACE );
- mpBindings->Update( SID_ATTR_PAGE );
- mpBindings->Update( SID_ATTR_PAGE_SIZE );
-}
-
-VclPtr< svx::sidebar::PopupControl> PagePropertyPanel::CreatePageMarginControl( svx::sidebar::PopupContainer* pParent )
-{
- return VclPtr<PageMarginControl>::Create(
-
- pParent,
- *this,
- *mpPageLRMarginItem.get(),
- *mpPageULMarginItem.get(),
- mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR,
- mpPageSizeItem->GetSize(),
- mpPageItem->IsLandscape(),
- meFUnit,
- meUnit );
-}
-
-void PagePropertyPanel::ExecuteMarginLRChange(
- const long nPageLeftMargin,
- const long nPageRightMargin )
-{
- mpPageLRMarginItem->SetLeft( nPageLeftMargin );
- mpPageLRMarginItem->SetRight( nPageRightMargin );
- GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_LRSPACE,
- SfxCallMode::RECORD, { mpPageLRMarginItem.get() });
-}
-
-void PagePropertyPanel::ExecuteMarginULChange(
- const long nPageTopMargin,
- const long nPageBottomMargin )
-{
- mpPageULMarginItem->SetUpper( nPageTopMargin );
- mpPageULMarginItem->SetLower( nPageBottomMargin );
- GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE_ULSPACE,
- SfxCallMode::RECORD, { mpPageULMarginItem.get() });
-}
-
-void PagePropertyPanel::ExecutePageLayoutChange( const bool bMirrored )
-{
- mpPageItem->SetPageUsage( bMirrored ? SVX_PAGE_MIRROR : SVX_PAGE_ALL );
- GetBindings()->GetDispatcher()->ExecuteList(SID_ATTR_PAGE,
- SfxCallMode::RECORD, { mpPageItem.get() });
-}
-
-IMPL_LINK_TYPED( PagePropertyPanel, ClickMarginHdl, ToolBox*, pToolBox, void )
-{
- maMarginPopup.Show( *pToolBox );
-}
-
-void PagePropertyPanel::ClosePageMarginPopup()
-{
- maMarginPopup.Hide();
-}
-
-void PagePropertyPanel::NotifyItemUpdate(
- const sal_uInt16 nSId,
- const SfxItemState eState,
- const SfxPoolItem* pState,
- const bool bIsEnabled)
-{
- (void)bIsEnabled;
-
- if (IsDisposed())
- return;
-
- switch( nSId )
- {
- case SID_ATTR_PAGE_LRSPACE:
- if ( eState >= SfxItemState::DEFAULT &&
- pState && dynamic_cast< const SvxLongLRSpaceItem *>( pState ) != nullptr )
- {
- mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pState->Clone()) );
- ChangeMarginImage();
- }
- break;
-
- case SID_ATTR_PAGE_ULSPACE:
- if ( eState >= SfxItemState::DEFAULT &&
- pState && dynamic_cast< const SvxLongULSpaceItem *>( pState ) != nullptr )
- {
- mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pState->Clone()) );
- ChangeMarginImage();
- }
- break;
-
- case SID_ATTR_PAGE_SIZE:
- if ( mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify )
- {
- mpBindings->Invalidate( SID_ATTR_PAGE, true );
- }
- if ( eState >= SfxItemState::DEFAULT &&
- pState && dynamic_cast< const SvxSizeItem *>( pState ) != nullptr )
- {
- mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pState->Clone()) );
- }
- break;
- case SID_ATTR_METRIC:
- MetricState( eState, pState );
- break;
- }
-}
-
-void PagePropertyPanel::MetricState( SfxItemState eState, const SfxPoolItem* pState )
-{
- meFUnit = FUNIT_NONE;
- if ( pState && eState >= SfxItemState::DEFAULT )
- {
- meFUnit = (FieldUnit)static_cast<const SfxUInt16Item*>(pState )->GetValue();
- }
- else
- {
- SfxViewFrame* pFrame = SfxViewFrame::Current();
- SfxObjectShell* pSh = nullptr;
- if ( pFrame )
- pSh = pFrame->GetObjectShell();
- if ( pSh )
- {
- SfxModule* pModule = pSh->GetModule();
- if ( pModule )
- {
- const SfxPoolItem* pItem = pModule->GetItem( SID_ATTR_METRIC );
- if ( pItem )
- meFUnit = (FieldUnit)static_cast<const SfxUInt16Item*>(pItem )->GetValue();
- }
- else
- {
- SAL_WARN("sw.ui", "<PagePropertyPanel::MetricState(..)>: no module found");
- }
- }
- }
-}
-
-void PagePropertyPanel::ChangeMarginImage()
-{
- if ( mpPageLRMarginItem.get() == nullptr ||
- mpPageULMarginItem.get() == nullptr ||
- mpPageItem.get() == nullptr )
- {
- return;
- }
-
- const long cTolerance = 5;
- const sal_uInt16 nIdMargin = mpToolBoxMargin->GetItemId(UNO_MARGIN);
-
- if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_NARROW_VALUE) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetLower() - SWPAGE_NARROW_VALUE) <= cTolerance &&
- mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
- mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgNarrow_L : mImgNarrow );
-
- else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetLower() - SWPAGE_NORMAL_VALUE) <= cTolerance &&
- mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
- mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgNormal_L : mImgNormal );
-
- else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
- std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE2) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- mpPageItem->GetPageUsage() != SVX_PAGE_MIRROR )
- mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgWide_L : mImgWide );
-
- else if( std::abs(mpPageLRMarginItem->GetLeft() - SWPAGE_WIDE_VALUE3) <= cTolerance &&
- std::abs(mpPageLRMarginItem->GetRight() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetUpper() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- std::abs(mpPageULMarginItem->GetLower() - SWPAGE_WIDE_VALUE1) <= cTolerance &&
- mpPageItem->GetPageUsage() == SVX_PAGE_MIRROR )
- mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgMirrored_L : mImgMirrored );
-
- else
- mpToolBoxMargin->SetItemImage( nIdMargin, mpPageItem->IsLandscape() ? mImgMarginCustom_L : mImgMarginCustom );
-}
-
-void PagePropertyPanel::StartUndo()
-{
- if ( mxUndoManager.is() )
- {
- mxUndoManager->enterUndoContext( "" );
- }
-}
-
-void PagePropertyPanel::EndUndo()
-{
- if ( mxUndoManager.is() )
- {
- mxUndoManager->leaveUndoContext();
- }
-}
-
} } // end of namespace ::sw::sidebar
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hrc b/sw/source/uibase/sidebar/PagePropertyPanel.hrc
deleted file mode 100644
index 7c87d7ef0e8b..000000000000
--- a/sw/source/uibase/sidebar/PagePropertyPanel.hrc
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <rcid.hrc>
-#include "PropertyPanel.hrc"
-
-// global definitions
-#define IMG_PAGE_NARROW (RC_SIDEBAR_BEGIN + 2)
-#define IMG_PAGE_NORMAL (RC_SIDEBAR_BEGIN + 3)
-#define IMG_PAGE_WIDE (RC_SIDEBAR_BEGIN + 4)
-#define IMG_PAGE_MIRRORED (RC_SIDEBAR_BEGIN + 5)
-#define IMG_PAGE_MARGIN_CUSTOM (RC_SIDEBAR_BEGIN + 6)
-#define IMG_PAGE_NARROW_L (RC_SIDEBAR_BEGIN + 7)
-#define IMG_PAGE_NORMAL_L (RC_SIDEBAR_BEGIN + 8)
-#define IMG_PAGE_WIDE_L (RC_SIDEBAR_BEGIN + 9)
-#define IMG_PAGE_MIRRORED_L (RC_SIDEBAR_BEGIN + 10)
-#define IMG_PAGE_MARGIN_CUSTOM_L (RC_SIDEBAR_BEGIN+ 11)
-
-// local
-
-#define MF_SWLEFT_MARGIN 18
-#define MF_SWRIGHT_MARGIN 19
-#define MF_SWTOP_MARGIN 20
-#define MF_SWBOTTOM_MARGIN 21
-#define VS_SIZE 23
-#define STR_LCVALUE 24
-#define FT_CUSTOM 25
-#define FLD_WIDTH_HEIGHT 26
-
-#define IMG_NARROW 32
-#define IMG_NORMAL 33
-#define IMG_WIDE 34
-#define IMG_MIRRORED 35
-#define STR_NARROW 36
-#define STR_NORMAL 37
-#define STR_WIDE 38
-#define STR_MIRRORED 39
-#define VS_MARGIN 40
-#define IMG_CUSTOM 41
-#define FT_LEFT 42
-#define FT_RIGHT 43
-#define FT_TOP 44
-#define FT_BOTTOM 45
-#define FT_INNER 46
-#define FT_OUTER 47
-#define VS_COLUMN 49
-#define MBOX_WIDTH 50
-
-#define IMG_NARROW_L 109
-#define IMG_NORMAL_L 110
-#define IMG_WIDE_L 111
-#define IMG_MIRRORED_L 112
-
-#define IMG_CUSTOM_DIS 121
-
-#define STR_MARGIN_TOOLTIP_LEFT 122
-#define STR_MARGIN_TOOLTIP_RIGHT 123
-#define STR_MARGIN_TOOLTIP_INNER 124
-#define STR_MARGIN_TOOLTIP_OUTER 125
-#define STR_MARGIN_TOOLTIP_TOP 126
-#define STR_MARGIN_TOOLTIP_BOT 127
-
-#define POPUP_MARGIN 4
-#define VS_WIDTH 78
-#define ITEM_HEIGHT 17
-#define ITEM_HEIGHT2 15
-
-// Position
-
-#define FT_CUSTOM_X POPUP_MARGIN + OFFSET_X
-#define FT_CUSTOM_Y POPUPPANEL_MARGIN_SMALL * 2 + ITEM_HEIGHT * 5
-
-#define POP_BORDER_X POPUP_MARGIN + OFFSET_X + 1
-#define POP_BORDER_Y POPUPPANEL_MARGIN_SMALL * 3 + ITEM_HEIGHT * 5 + TEXT_HEIGHT
-#define BD_HEIGHT MBOX_HEIGHT*4 + CONTROL_SPACING_VERTICAL*5
-
-#define FT_X POP_BORDER_X + CONTROL_SPACING_HORIZONTAL
-#define MF_X FT_X + 25 + CONTROL_SPACING_HORIZONTAL
-#define LEFT_MF_Y POP_BORDER_Y + CONTROL_SPACING_VERTICAL
-#define RIGHT_MF_Y LEFT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
-#define TOP_MF_Y RIGHT_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
-#define BOTTOM_MF_Y TOP_MF_Y + MBOX_HEIGHT + CONTROL_SPACING_VERTICAL
-#define FT_LEFT_Y LEFT_MF_Y + 1
-#define FT_RIGHT_Y RIGHT_MF_Y + 1
-#define FT_TOP_Y TOP_MF_Y + 1
-#define FT_BOTTOM_Y BOTTOM_MF_Y + 1
-
-#define MARGIN_PANEL_HEIGHT POP_BORDER_Y + BD_HEIGHT + POPUP_MARGIN + OFFSET_Y
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/sidebar/PagePropertyPanel.hxx b/sw/source/uibase/sidebar/PagePropertyPanel.hxx
index a9bded236ef1..e3cd3e995c1f 100644
--- a/sw/source/uibase/sidebar/PagePropertyPanel.hxx
+++ b/sw/source/uibase/sidebar/PagePropertyPanel.hxx
@@ -49,35 +49,9 @@ namespace svx { namespace sidebar {
namespace sw { namespace sidebar {
- class PagePropertyPanel
- : public PanelLayout,
- public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+ class PagePropertyPanel : public PanelLayout
{
public:
- // interface of ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
- virtual void NotifyItemUpdate(
- const sal_uInt16 nSId,
- const SfxItemState eState,
- const SfxPoolItem* pState,
- const bool bIsEnabled) override;
-
- SfxBindings* GetBindings() const
- {
- return mpBindings;
- }
-
- VclPtr< svx::sidebar::PopupControl> CreatePageMarginControl( svx::sidebar::PopupContainer* pParent );
- void ExecuteMarginLRChange(
- const long nPageLeftMargin,
- const long nPageRightMargin );
- void ExecuteMarginULChange(
- const long nPageTopMargin,
- const long nPageBottomMargin );
- void ExecutePageLayoutChange( const bool bMirrored );
- void ClosePageMarginPopup();
-
- void StartUndo();
- void EndUndo();
PagePropertyPanel(
vcl::Window* pParent,
@@ -86,66 +60,6 @@ namespace sw { namespace sidebar {
private:
virtual ~PagePropertyPanel() override;
virtual void dispose() override;
-
- SfxBindings* mpBindings;
-
- // toolboxes - on click open corresponding popup
- VclPtr<ToolBox> mpToolBoxMargin;
-
- Image* maImgSize;
- Image* maImgSize_L;
- Image mImgNarrow;
- Image mImgNormal;
- Image mImgWide;
- Image mImgMirrored;
- Image mImgMarginCustom;
- Image mImgNarrow_L;
- Image mImgNormal_L;
- Image mImgWide_L;
- Image mImgMirrored_L;
- Image mImgMarginCustom_L;
-
- // item keeping the following page style attributes:
- // - page orientation
- // - page usage - only left, only right, both, mirrored
- // item also hold the numbering type for the page style which should
- // be kept stable.
- std::unique_ptr<SvxPageItem> mpPageItem;
-
- // item keeping the page style's left and right margins
- std::unique_ptr<SvxLongLRSpaceItem> mpPageLRMarginItem;
- // item keeping the page style's top and bottom margins
- std::unique_ptr<SvxLongULSpaceItem> mpPageULMarginItem;
-
- // item keeping the page style's page size
- std::unique_ptr<SvxSizeItem> mpPageSizeItem;
-
- FieldUnit meFUnit;
- MapUnit meUnit;
-
- // controller items
- ::sfx2::sidebar::ControllerItem m_aSwPagePgULControl;
- ::sfx2::sidebar::ControllerItem m_aSwPagePgLRControl;
- ::sfx2::sidebar::ControllerItem m_aSwPagePgSizeControl;
- ::sfx2::sidebar::ControllerItem m_aSwPagePgMetricControl;
-
- // popups
- svx::sidebar::Popup maMarginPopup;
-
- const css::uno::Reference< css::document::XUndoManager > mxUndoManager;
-
- bool mbInvalidateSIDAttrPageOnSIDAttrPageSizeNotify;
-
- // handler for popup toolboxes to show the popups
- DECL_LINK_TYPED(ClickMarginHdl, ToolBox*, void);
-
- void Initialize();
-
- void MetricState( SfxItemState eState, const SfxPoolItem* pState );
-
- // helper to adjust popup toolbox' images
- void ChangeMarginImage();
-
};
} } // end of namespace ::sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx
index eb0ee63ed3a9..29a2f0304814 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.cxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.cxx
@@ -19,7 +19,6 @@
#include "PageSizeControl.hxx"
#include "PagePropertyPanel.hxx"
-#include "PagePropertyPanel.hrc"
#include <cmdid.h>
#include <swtypes.hxx>
@@ -34,6 +33,8 @@
#include <vcl/settings.hxx>
#include <svl/itempool.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/sizeitem.hxx>
namespace
{
diff --git a/sw/source/uibase/sidebar/PropertyPanel.hrc b/sw/source/uibase/sidebar/PropertyPanel.hrc
index 5143a3dc7d10..c705574d2051 100644
--- a/sw/source/uibase/sidebar/PropertyPanel.hrc
+++ b/sw/source/uibase/sidebar/PropertyPanel.hrc
@@ -21,7 +21,12 @@
#include "rcid.hrc"
-#define RID_POPUP_SWPAGE_MARGIN (RC_PROPERTYPANEL_BEGIN + 3)
+#define STR_MARGIN_TOOLTIP_LEFT (RC_PROPERTYPANEL_BEGIN + 1)
+#define STR_MARGIN_TOOLTIP_RIGHT (RC_PROPERTYPANEL_BEGIN + 2)
+#define STR_MARGIN_TOOLTIP_INNER (RC_PROPERTYPANEL_BEGIN + 3)
+#define STR_MARGIN_TOOLTIP_OUTER (RC_PROPERTYPANEL_BEGIN + 4)
+#define STR_MARGIN_TOOLTIP_TOP (RC_PROPERTYPANEL_BEGIN + 5)
+#define STR_MARGIN_TOOLTIP_BOT (RC_PROPERTYPANEL_BEGIN + 6)
#endif
diff --git a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
index 63517d7a438d..8897123ea3dc 100644
--- a/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
+++ b/sw/source/uibase/sidebar/WrapPropertyPanel.cxx
@@ -18,7 +18,6 @@
*/
#include "WrapPropertyPanel.hxx"
-#include "PropertyPanel.hrc"
#include <cmdid.h>
#include <swtypes.hxx>