42#include <com/sun/star/document/XUndoManagerSupplier.hpp>
43#include <com/sun/star/beans/NamedValue.hpp>
44#include <com/sun/star/frame/XFrame.hpp>
59 SfxItemState eState = pViewFrm->GetBindings().GetDispatcher()->QueryState(SID_ATTR_METRIC, pItem);
60 if (pItem && eState >= SfxItemState::DEFAULT)
69 sal_uInt16 nWhich = rPool.
GetWhich( SID_ATTR_PAGE_SIZE );
73 css::uno::Reference< css::document::XUndoManager > getUndoManager(
const css::uno::Reference< css::frame::XFrame >& rxFrame )
75 const css::uno::Reference< css::frame::XController >&
xController = rxFrame->getController();
78 const css::uno::Reference< css::frame::XModel >&
xModel =
xController->getModel();
81 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo(
xModel, css::uno::UNO_QUERY_THROW );
82 return css::uno::Reference< css::document::XUndoManager >( xSuppUndo->getUndoManager(), css::uno::UNO_SET_THROW );
86 return css::uno::Reference< css::document::XUndoManager > ();
93 :
WeldToolbarPopup(pControl->getFrameInterface(), pParent,
"modules/swriter/ui/pagemargincontrol.ui",
"PageMarginControl")
94 , m_xMoreButton(m_xBuilder->weld_button(
"moreoptions"))
95 , m_xLeft(m_xBuilder->weld_label(
"leftLabel"))
96 , m_xRight(m_xBuilder->weld_label(
"rightLabel"))
97 , m_xInner(m_xBuilder->weld_label(
"innerLabel"))
98 , m_xOuter(m_xBuilder->weld_label(
"outerLabel"))
99 , m_xLeftMarginEdit(m_xBuilder->weld_metric_spin_button(
"left",
FieldUnit::
CM))
100 , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button(
"right",
FieldUnit::
CM))
101 , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button(
"top",
FieldUnit::
CM))
102 , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button(
"bottom",
FieldUnit::
CM))
103 , m_xWidthHeightField(m_xBuilder->weld_metric_spin_button(
"hidden",
FieldUnit::
CM))
105 , m_nPageLeftMargin(0)
106 , m_nPageRightMargin(0)
107 , m_nPageTopMargin(0)
108 , m_nPageBottomMargin(0)
110 , m_eUnit( lcl_GetUnit() )
111 , m_bUserCustomValuesAvailable( false )
112 , m_nUserCustomPageLeftMargin( 0 )
113 , m_nUserCustomPageRightMargin( 0 )
114 , m_nUserCustomPageTopMargin( 0 )
115 , m_nUserCustomPageBottomMargin( 0 )
116 , m_bUserCustomMirrored( false )
117 , m_bCustomValuesUsed( false )
125 bool bLandscape =
false;
132 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE, pPageItem );
135 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_SIZE, pSize );
136 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_LRSPACE, pLRItem );
137 pViewFrm->GetBindings().GetDispatcher()->QueryState( SID_ATTR_PAGE_ULSPACE, pULItem );
266 const OUString aLeft =
SwResId( STR_MARGIN_TOOLTIP_LEFT );
267 const OUString aRight =
SwResId( STR_MARGIN_TOOLTIP_RIGHT );
268 const OUString aTop =
SwResId( STR_MARGIN_TOOLTIP_TOP );
269 const OUString aBottom =
SwResId( STR_MARGIN_TOOLTIP_BOT );
273 OUString aHelpText = aLeft +
281 m_xNarrow->set_tooltip_text( aHelpText );
293 m_xNormal->set_tooltip_text( aHelpText );
307 m_xWide->set_tooltip_text( aHelpText );
309 const OUString aInner =
SwResId( STR_MARGIN_TOOLTIP_INNER );
310 const OUString aOuter =
SwResId( STR_MARGIN_TOOLTIP_OUTER );
324 if ( bUserCustomValuesAvailable )
341 m_xLast->set_tooltip_text( aHelpText );
346 bool bMirrored =
false;
347 bool bApplyNewPageMargins =
true;
348 if( &rControl == m_xNarrow.get() )
356 if( &rControl == m_xNormal.get() )
364 if( &rControl == m_xWide.get() )
372 if( &rControl == m_xMirrored.get() )
380 if( &rControl == m_xLast.get() )
382 if ( m_bUserCustomValuesAvailable )
384 m_nPageLeftMargin = m_nUserCustomPageLeftMargin;
385 m_nPageRightMargin = m_nUserCustomPageRightMargin;
386 m_nPageTopMargin = m_nUserCustomPageTopMargin;
387 m_nPageBottomMargin = m_nUserCustomPageBottomMargin;
388 bMirrored = m_bUserCustomMirrored;
392 bApplyNewPageMargins =
false;
396 if ( !bApplyNewPageMargins )
400 const css::uno::Reference<css::document::XUndoManager> xUndoManager(pViewFrm ? getUndoManager(pViewFrm->
GetFrame().
GetFrameInterface()) :
nullptr);
401 if ( xUndoManager.is() )
402 xUndoManager->enterUndoContext(
"" );
404 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
405 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
406 if ( m_bMirrored != bMirrored )
408 m_bMirrored = bMirrored;
409 ExecutePageLayoutChange( m_bMirrored );
412 if ( xUndoManager.is() )
413 xUndoManager->leaveUndoContext();
415 m_bCustomValuesUsed =
false;
426 aPageLRMarginItem.
SetLeft( nPageLeftMargin );
427 aPageLRMarginItem.
SetRight( nPageRightMargin );
428 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_LRSPACE,
429 SfxCallMode::RECORD, { &aPageLRMarginItem } );
440 aPageULMarginItem.
SetUpper( nPageTopMargin );
441 aPageULMarginItem.
SetLower( nPageBottomMargin );
442 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE_ULSPACE,
443 SfxCallMode::RECORD, { &aPageULMarginItem } );
452 aPageItem.
SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All );
453 pViewFrm->GetBindings().GetDispatcher()->ExecuteList( SID_ATTR_PAGE,
454 SfxCallMode::RECORD, { &aPageItem } );
460 m_nPageLeftMargin =
GetCoreValue( *m_xLeftMarginEdit, m_eUnit );
461 m_nPageRightMargin =
GetCoreValue( *m_xRightMarginEdit, m_eUnit );
462 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
463 SetMetricFieldMaxValues( m_aPageSize );
464 m_bCustomValuesUsed =
true;
469 m_nPageTopMargin =
GetCoreValue( *m_xTopMarginEdit, m_eUnit );
470 m_nPageBottomMargin =
GetCoreValue( *m_xBottomMarginEdit, m_eUnit );
471 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
472 SetMetricFieldMaxValues( m_aPageSize );
473 m_bCustomValuesUsed =
true;
480 SfxCallMode::ASYNCHRON);
486 bool bUserCustomValuesAvailable =
false;
491 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt.
GetUserData();
493 if (
aSeq.hasElements())
494 aSeq[0].Value >>= aTmp;
495 OUString aWinData( aTmp );
497 bUserCustomValuesAvailable =
true;
503 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt2.
GetUserData();
505 if (
aSeq.hasElements())
506 aSeq[0].Value >>= aTmp;
507 OUString aWinData( aTmp );
509 bUserCustomValuesAvailable =
true;
515 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt3.
GetUserData();
517 if (
aSeq.hasElements() )
518 aSeq[0].Value >>= aTmp;
519 OUString aWinData( aTmp );
521 bUserCustomValuesAvailable =
true;
527 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt4.
GetUserData();
529 if (
aSeq.hasElements())
530 aSeq[0].Value >>= aTmp;
531 OUString aWinData( aTmp );
533 bUserCustomValuesAvailable =
true;
539 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt5.
GetUserData();
541 if (
aSeq.hasElements())
542 aSeq[0].Value >>= aTmp;
543 OUString aWinData( aTmp );
545 bUserCustomValuesAvailable =
true;
548 return bUserCustomValuesAvailable;
558 css::uno::Sequence < css::beans::NamedValue >
aSeq( 1 );
559 auto pSeq =
aSeq.getArray();
562 pSeq[0].Name =
"mnPageLeftMargin";
567 pSeq[0].Name =
"mnPageRightMargin";
572 pSeq[0].Name =
"mnPageTopMargin";
577 pSeq[0].Name =
"mnPageBottomMargin";
582 pSeq[0].Name =
"mbMirrored";
583 pSeq[0].Value <<= OUString::number(
m_bMirrored ? 1 : 0 );
constexpr OUStringLiteral SWPAGE_DOWN_GVALUE
constexpr OUStringLiteral SWPAGE_RIGHT_GVALUE
constexpr OUStringLiteral SWPAGE_LEFT_GVALUE
constexpr OUStringLiteral SWPAGE_MIRROR_GVALUE
constexpr OUStringLiteral SWPAGE_TOP_GVALUE
#define SWPAGE_WIDE_VALUE3
#define SWPAGE_NARROW_VALUE
#define SWPAGE_WIDE_VALUE2
#define SWPAGE_NORMAL_VALUE
constexpr tools::Long MINBODY
#define SWPAGE_WIDE_VALUE1
SfxApplication * SfxGetpApp()
sal_uInt16 GetValue() const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
static FieldUnit GetCurrentFieldUnit()
SfxItemPool & GetPool() const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxFrame & GetFrame() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetUserData(const css::uno::Sequence< css::beans::NamedValue > &lData)
css::uno::Sequence< css::beans::NamedValue > GetUserData() const
tools::Long GetRight() const
void SetLeft(tools::Long lArgLeft)
tools::Long GetLeft() const
void SetRight(tools::Long lArgRight)
tools::Long GetLower() const
void SetLower(tools::Long lArgRight)
tools::Long GetUpper() const
void SetUpper(tools::Long lArgLeft)
void SetPageUsage(SvxPageUsage eU)
SvxPageUsage GetPageUsage() const
const Size & GetSize() const
#define FN_FORMAT_PAGE_SETTING_DLG
#define LINK(Instance, Class, Member)
Sequence< sal_Int8 > aSeq
Reference< XController > xController
Reference< XModel > xModel
OUString SwResId(TranslateId aId)
SVT_DLLPUBLIC sal_Int64 GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
SVT_DLLPUBLIC void SetMetricValue(weld::MetricSpinButton &rField, sal_Int64 nCoreValue, MapUnit eUnit)
SVT_DLLPUBLIC void SetFieldUnit(weld::MetricSpinButton &rCtrl, FieldUnit eUnit, bool bAll=false)