24 #include <strings.hrc>
42 #include <com/sun/star/document/XUndoManagerSupplier.hpp>
43 #include <com/sun/star/beans/NamedValue.hpp>
44 #include <com/sun/star/frame/XFrame.hpp>
46 #define SWPAGE_LEFT_GVALUE "Sw_Page_Left"
47 #define SWPAGE_RIGHT_GVALUE "Sw_Page_Right"
48 #define SWPAGE_TOP_GVALUE "Sw_Page_Top"
49 #define SWPAGE_DOWN_GVALUE "Sw_Page_Down"
50 #define SWPAGE_MIRROR_GVALUE "Sw_Page_Mirrored"
59 if ( pItem && eState >= SfxItemState::DEFAULT )
74 sal_uInt16 nWhich = rPool.
GetWhich( SID_ATTR_PAGE_SIZE );
78 css::uno::Reference< css::document::XUndoManager > getUndoManager(
const css::uno::Reference< css::frame::XFrame >& rxFrame )
80 const css::uno::Reference< css::frame::XController >&
xController = rxFrame->getController();
81 if ( xController.is() )
83 const css::uno::Reference< css::frame::XModel >&
xModel = xController->getModel();
86 const css::uno::Reference< css::document::XUndoManagerSupplier > xSuppUndo( xModel, css::uno::UNO_QUERY_THROW );
87 return css::uno::Reference< css::document::XUndoManager >( xSuppUndo->getUndoManager(), css::uno::UNO_SET_THROW );
91 return css::uno::Reference< css::document::XUndoManager > ();
98 :
WeldToolbarPopup(pControl->getFrameInterface(), pParent,
"modules/swriter/ui/pagemargincontrol.ui",
"PageMarginControl")
99 , m_xLeft(m_xBuilder->weld_label(
"leftLabel"))
100 , m_xRight(m_xBuilder->weld_label(
"rightLabel"))
101 , m_xInner(m_xBuilder->weld_label(
"innerLabel"))
102 , m_xOuter(m_xBuilder->weld_label(
"outerLabel"))
103 , m_xLeftMarginEdit(m_xBuilder->weld_metric_spin_button(
"left",
FieldUnit::
CM))
104 , m_xRightMarginEdit(m_xBuilder->weld_metric_spin_button(
"right",
FieldUnit::
CM))
105 , m_xTopMarginEdit(m_xBuilder->weld_metric_spin_button(
"top",
FieldUnit::
CM))
106 , m_xBottomMarginEdit(m_xBuilder->weld_metric_spin_button(
"bottom",
FieldUnit::
CM))
107 , m_xWidthHeightField(m_xBuilder->weld_metric_spin_button(
"hidden",
FieldUnit::
CM))
109 , m_nPageLeftMargin(0)
110 , m_nPageRightMargin(0)
111 , m_nPageTopMargin(0)
112 , m_nPageBottomMargin(0)
114 , m_eUnit( lcl_GetUnit() )
115 , m_bUserCustomValuesAvailable( false )
116 , m_nUserCustomPageLeftMargin( 0 )
117 , m_nUserCustomPageRightMargin( 0 )
118 , m_nUserCustomPageTopMargin( 0 )
119 , m_nUserCustomPageBottomMargin( 0 )
120 , m_bUserCustomMirrored( false )
121 , m_bCustomValuesUsed( false )
129 bool bLandscape =
false;
137 bLandscape =
static_cast<const SvxPageItem*
>( pItem )->IsLandscape();
268 const OUString aLeft =
SwResId( STR_MARGIN_TOOLTIP_LEFT );
269 const OUString aRight =
SwResId( STR_MARGIN_TOOLTIP_RIGHT );
270 const OUString aTop =
SwResId( STR_MARGIN_TOOLTIP_TOP );
271 const OUString aBottom =
SwResId( STR_MARGIN_TOOLTIP_BOT );
275 OUString aHelpText = aLeft +
283 m_xNarrow->set_tooltip_text( aHelpText );
295 m_xNormal->set_tooltip_text( aHelpText );
309 m_xWide->set_tooltip_text( aHelpText );
311 const OUString aInner =
SwResId( STR_MARGIN_TOOLTIP_INNER );
312 const OUString aOuter =
SwResId( STR_MARGIN_TOOLTIP_OUTER );
326 if ( bUserCustomValuesAvailable )
337 aHelpText += aBottom;
345 m_xLast->set_tooltip_text( aHelpText );
350 bool bMirrored =
false;
351 bool bApplyNewPageMargins =
true;
352 if( &rControl == m_xNarrow.get() )
360 if( &rControl == m_xNormal.get() )
368 if( &rControl == m_xWide.get() )
376 if( &rControl == m_xMirrored.get() )
384 if( &rControl == m_xLast.get() )
386 if ( m_bUserCustomValuesAvailable )
388 m_nPageLeftMargin = m_nUserCustomPageLeftMargin;
389 m_nPageRightMargin = m_nUserCustomPageRightMargin;
390 m_nPageTopMargin = m_nUserCustomPageTopMargin;
391 m_nPageBottomMargin = m_nUserCustomPageBottomMargin;
392 bMirrored = m_bUserCustomMirrored;
396 bApplyNewPageMargins =
false;
400 if ( !bApplyNewPageMargins )
403 const css::uno::Reference< css::document::XUndoManager > xUndoManager( getUndoManager(
SfxViewFrame::Current()->GetFrame().GetFrameInterface() ) );
404 if ( xUndoManager.is() )
405 xUndoManager->enterUndoContext(
"" );
407 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
408 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
409 if ( m_bMirrored != bMirrored )
411 m_bMirrored = bMirrored;
412 ExecutePageLayoutChange( m_bMirrored );
415 if ( xUndoManager.is() )
416 xUndoManager->leaveUndoContext();
418 m_bCustomValuesUsed =
false;
428 std::unique_ptr<SvxLongLRSpaceItem> pPageLRMarginItem(
new SvxLongLRSpaceItem( 0, 0, SID_ATTR_PAGE_LRSPACE ) );
429 pPageLRMarginItem->SetLeft( nPageLeftMargin );
430 pPageLRMarginItem->SetRight( nPageRightMargin );
432 SfxCallMode::RECORD, { pPageLRMarginItem.get() } );
433 pPageLRMarginItem.reset();
443 std::unique_ptr<SvxLongULSpaceItem> pPageULMarginItem(
new SvxLongULSpaceItem( 0, 0, SID_ATTR_PAGE_ULSPACE ) );
444 pPageULMarginItem->SetUpper( nPageTopMargin );
445 pPageULMarginItem->SetLower( nPageBottomMargin );
447 SfxCallMode::RECORD, { pPageULMarginItem.get() } );
448 pPageULMarginItem.reset();
456 std::unique_ptr<SvxPageItem> pPageItem(
new SvxPageItem( SID_ATTR_PAGE ) );
457 pPageItem->SetPageUsage( bMirrored ? SvxPageUsage::Mirror : SvxPageUsage::All );
459 SfxCallMode::RECORD, { pPageItem.get() } );
466 m_nPageLeftMargin =
GetCoreValue( *m_xLeftMarginEdit, m_eUnit );
467 m_nPageRightMargin =
GetCoreValue( *m_xRightMarginEdit, m_eUnit );
468 ExecuteMarginLRChange( m_nPageLeftMargin, m_nPageRightMargin );
469 SetMetricFieldMaxValues( m_aPageSize );
470 m_bCustomValuesUsed =
true;
475 m_nPageTopMargin =
GetCoreValue( *m_xTopMarginEdit, m_eUnit );
476 m_nPageBottomMargin =
GetCoreValue( *m_xBottomMarginEdit, m_eUnit );
477 ExecuteMarginULChange( m_nPageTopMargin, m_nPageBottomMargin );
478 SetMetricFieldMaxValues( m_aPageSize );
479 m_bCustomValuesUsed =
true;
484 bool bUserCustomValuesAvailable =
false;
489 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt.
GetUserData();
491 if ( aSeq.hasElements())
492 aSeq[0].
Value >>= aTmp;
493 OUString aWinData( aTmp );
495 bUserCustomValuesAvailable =
true;
501 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt2.
GetUserData();
503 if ( aSeq.hasElements())
504 aSeq[0].
Value >>= aTmp;
505 OUString aWinData( aTmp );
507 bUserCustomValuesAvailable =
true;
513 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt3.
GetUserData();
515 if ( aSeq.hasElements() )
516 aSeq[0].
Value >>= aTmp;
517 OUString aWinData( aTmp );
519 bUserCustomValuesAvailable =
true;
525 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt4.
GetUserData();
527 if ( aSeq.hasElements())
528 aSeq[0].
Value >>= aTmp;
529 OUString aWinData( aTmp );
531 bUserCustomValuesAvailable =
true;
537 css::uno::Sequence < css::beans::NamedValue >
aSeq = aWinOpt5.
GetUserData();
539 if ( aSeq.hasElements())
540 aSeq[0].
Value >>= aTmp;
541 OUString aWinData( aTmp );
543 bUserCustomValuesAvailable =
true;
546 return bUserCustomValuesAvailable;
556 css::uno::Sequence < css::beans::NamedValue >
aSeq( 1 );
559 aSeq[0].Name =
"mnPageLeftMargin";
564 aSeq[0].Name =
"mnPageRightMargin";
569 aSeq[0].Name =
"mnPageTopMargin";
574 aSeq[0].Name =
"mnPageBottomMargin";
579 aSeq[0].Name =
"mbMirrored";
580 aSeq[0].Value <<= OUString::number( (
m_bMirrored ? 1 : 0) );
#define SWPAGE_NARROW_VALUE
#define LINK(Instance, Class, Member)
void SetFieldUnit(weld::MetricSpinButton &rField, FieldUnit eUnit, bool bAll)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
css::uno::Sequence< css::beans::NamedValue > GetUserData() const
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const tools::Long MINBODY
static FieldUnit GetCurrentFieldUnit()
tools::Long GetUpper() const
tools::Long GetRight() const
SfxApplication * SfxGetpApp()
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
tools::Long GetLeft() const
Reference< XController > xController
#define SWPAGE_MIRROR_GVALUE
SfxItemPool & GetPool() const
#define SWPAGE_WIDE_VALUE1
SfxBindings & GetBindings()
int GetCoreValue(const weld::MetricSpinButton &rField, MapUnit eUnit)
tools::Long Width() const
void SetUserData(const css::uno::Sequence< css::beans::NamedValue > &lData)
OUString SwResId(const char *pId)
SfxItemState QueryState(sal_uInt16 nSID, const SfxPoolItem *&rpState)
#define SWPAGE_LEFT_GVALUE
void SetMetricValue(weld::MetricSpinButton &rField, int nCoreValue, MapUnit eUnit)
#define SWPAGE_RIGHT_GVALUE
#define SWPAGE_DOWN_GVALUE
static SfxViewFrame * Current()
#define SWPAGE_WIDE_VALUE2
#define SWPAGE_TOP_GVALUE
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
tools::Long Height() const
Sequence< sal_Int8 > aSeq
tools::Long GetLower() const
SfxDispatcher * GetDispatcher() const
Reference< XModel > xModel
#define SWPAGE_NORMAL_VALUE
#define SWPAGE_WIDE_VALUE3
const Size & GetSize() const