diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-28 13:12:45 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-16 21:52:25 +0200 |
commit | fe1a23b5c49c94410a604c8d4a6f50f43d575403 (patch) | |
tree | b870bb48e5724ad9ecbc9c3c4fb19d6570b90df6 /svx | |
parent | 74307cb0f7afb76809840b4888dbc5b37f5fd9cb (diff) |
weld SvxHFPage
Change-Id: I9e39e276c64da4fca01ff79ebbb42d6f342f0379
Reviewed-on: https://gerrit.libreoffice.org/55932
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/hdft.cxx | 585 | ||||
-rw-r--r-- | svx/source/dialog/pagectrl.cxx | 375 | ||||
-rw-r--r-- | svx/uiconfig/ui/headfootformatpage.ui | 89 |
3 files changed, 672 insertions, 377 deletions
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx index 9e7c3a774093..d23ad52bc89e 100644 --- a/svx/source/dialog/hdft.cxx +++ b/svx/source/dialog/hdft.cxx @@ -88,23 +88,19 @@ namespace svx { { bool bRes = false; SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - if(pFact) + ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg( pParent, *pBBSet, false/*bEnableDrawingLayerFillStyles*/ )); + if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() ) { - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg( pParent, *pBBSet, false/*bEnableDrawingLayerFillStyles*/ )); - DBG_ASSERT(pDlg, "Dialog creation failed!"); - if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() ) - { - SfxItemIter aIter( *pDlg->GetOutputItemSet() ); - const SfxPoolItem* pItem = aIter.FirstItem(); + SfxItemIter aIter( *pDlg->GetOutputItemSet() ); + const SfxPoolItem* pItem = aIter.FirstItem(); - while ( pItem ) - { - if ( !IsInvalidItem( pItem ) ) - pBBSet->Put( *pItem ); - pItem = aIter.NextItem(); - } - bRes = true; + while ( pItem ) + { + if ( !IsInvalidItem( pItem ) ) + pBBSet->Put( *pItem ); + pItem = aIter.NextItem(); } + bRes = true; } return bRes; } @@ -134,99 +130,72 @@ SvxFooterPage::SvxFooterPage( vcl::Window* pParent, const SfxItemSet& rAttr ) : { } -SvxHFPage::SvxHFPage( vcl::Window* pParent, const SfxItemSet& rSet, sal_uInt16 nSetId ) : - SfxTabPage(pParent, "HFFormatPage", "svx/ui/headfootformatpage.ui", &rSet), - nId(nSetId), - pBBSet(nullptr), - mbDisableQueryBox(false), - mbEnableDrawingLayerFillStyles(false) +SvxHFPage::SvxHFPage(TabPageParent pParent, const SfxItemSet& rSet, sal_uInt16 nSetId) + : SfxTabPage(pParent, "svx/ui/headfootformatpage.ui", "HFFormatPage", &rSet) + , nId(nSetId) + , pBBSet(nullptr) + , mbDisableQueryBox(false) + , mbEnableDrawingLayerFillStyles(false) + , m_xCntSharedBox(m_xBuilder->weld_check_button("checkSameLR")) + , m_xCntSharedFirstBox(m_xBuilder->weld_check_button("checkSameFP")) + , m_xLMLbl(m_xBuilder->weld_label("labelLeftMarg")) + , m_xLMEdit(m_xBuilder->weld_metric_spin_button("spinMargLeft", FUNIT_CM)) + , m_xRMLbl(m_xBuilder->weld_label("labelRightMarg")) + , m_xRMEdit(m_xBuilder->weld_metric_spin_button("spinMargRight", FUNIT_CM)) + , m_xDistFT(m_xBuilder->weld_label("labelSpacing")) + , m_xDistEdit(m_xBuilder->weld_metric_spin_button("spinSpacing", FUNIT_CM)) + , m_xDynSpacingCB(m_xBuilder->weld_check_button("checkDynSpacing")) + , m_xHeightFT(m_xBuilder->weld_label("labelHeight")) + , m_xHeightEdit(m_xBuilder->weld_metric_spin_button("spinHeight", FUNIT_CM)) + , m_xHeightDynBtn(m_xBuilder->weld_check_button("checkAutofit")) + , m_xBackgroundBtn(m_xBuilder->weld_button("buttonMore")) + , m_xBspWin(new weld::CustomWeld(*m_xBuilder, "drawingareaPageHF", m_aBspWin)) { - get(m_pCntSharedBox,"checkSameLR"); - get(m_pCntSharedFirstBox,"checkSameFP"); - get(m_pLMEdit,"spinMargLeft"); - get(m_pLMLbl,"labelLeftMarg"); - get(m_pRMEdit,"spinMargRight"); - get(m_pRMLbl,"labelRightMarg"); - get(m_pDistEdit,"spinSpacing"); - get(m_pDistFT,"labelSpacing"); - get(m_pDynSpacingCB,"checkDynSpacing"); - get(m_pHeightFT,"labelHeight"); - get(m_pHeightEdit,"spinHeight"); - get(m_pHeightDynBtn,"checkAutofit"); - get(m_pBspWin,"drawingareaPageHF"); - get(m_pBackgroundBtn,"buttonMore"); - //swap header <-> footer in UI - if(nId == SID_ATTR_PAGE_FOOTERSET) + if (nId == SID_ATTR_PAGE_FOOTERSET) { - get(m_pPageLbl,"labelFooterFormat"); - get(m_pTurnOnBox, "checkFooterOn"); + m_xPageLbl.reset(m_xBuilder->weld_label("labelFooterFormat")); + m_xTurnOnBox.reset(m_xBuilder->weld_check_button("checkFooterOn")); /* Set custom HIDs for the Footer help page (shared/01/05040400.xhp) otherwise it would display the same extended help on both the Header and Footer tabs */ - m_pCntSharedBox->SetHelpId( "SVX_HID_FOOTER_CHECKSAMELR" ); - m_pCntSharedFirstBox->SetHelpId( "SVX_HID_FOOTER_CHECKSAMEFP" ); - m_pLMEdit->SetHelpId( "SVX_HID_FOOTER_SPINMARGLEFT" ); - m_pRMEdit->SetHelpId( "SVX_HID_FOOTER_SPINMARGRIGHT" ); - m_pDistEdit->SetHelpId( "SVX_HID_FOOTER_SPINSPACING" ); - m_pDynSpacingCB->SetHelpId( "SVX_HID_FOOTER_CHECKDYNSPACING" ); - m_pHeightEdit->SetHelpId( "SVX_HID_FOOTER_SPINHEIGHT" ); - m_pHeightDynBtn->SetHelpId( "SVX_HID_FOOTER_CHECKAUTOFIT" ); - m_pBackgroundBtn->SetHelpId( "SVX_HID_FOOTER_BUTTONMORE" ); + m_xCntSharedBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMELR" ); + m_xCntSharedFirstBox->set_help_id( "SVX_HID_FOOTER_CHECKSAMEFP" ); + m_xLMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGLEFT" ); + m_xRMEdit->set_help_id( "SVX_HID_FOOTER_SPINMARGRIGHT" ); + m_xDistEdit->set_help_id( "SVX_HID_FOOTER_SPINSPACING" ); + m_xDynSpacingCB->set_help_id( "SVX_HID_FOOTER_CHECKDYNSPACING" ); + m_xHeightEdit->set_help_id( "SVX_HID_FOOTER_SPINHEIGHT" ); + m_xHeightDynBtn->set_help_id( "SVX_HID_FOOTER_CHECKAUTOFIT" ); + m_xBackgroundBtn->set_help_id( "SVX_HID_FOOTER_BUTTONMORE" ); } else //Header { - get(m_pPageLbl,"labelHeaderFormat"); - get(m_pTurnOnBox, "checkHeaderOn"); + m_xPageLbl.reset(m_xBuilder->weld_label("labelHeaderFormat")); + m_xTurnOnBox.reset(m_xBuilder->weld_check_button("checkHeaderOn")); } - m_pTurnOnBox->Show(); - m_pPageLbl->Show(); + m_xTurnOnBox->show(); + m_xPageLbl->show(); InitHandler(); - m_pBspWin->EnableRTL( false ); + m_aBspWin.EnableRTL(false); // This Page needs ExchangeSupport SetExchangeSupport(); - // Set metrics FieldUnit eFUnit = GetModuleFieldUnit( rSet ); - SetFieldUnit( *m_pDistEdit, eFUnit ); - SetFieldUnit( *m_pHeightEdit, eFUnit ); - SetFieldUnit( *m_pLMEdit, eFUnit ); - SetFieldUnit( *m_pRMEdit, eFUnit ); + SetFieldUnit( *m_xDistEdit, eFUnit ); + SetFieldUnit( *m_xHeightEdit, eFUnit ); + SetFieldUnit( *m_xLMEdit, eFUnit ); + SetFieldUnit( *m_xRMEdit, eFUnit ); } - SvxHFPage::~SvxHFPage() { - disposeOnce(); } -void SvxHFPage::dispose() -{ - delete pBBSet; - m_pPageLbl.clear(); - m_pTurnOnBox.clear(); - m_pCntSharedBox.clear(); - m_pCntSharedFirstBox.clear(); - m_pLMLbl.clear(); - m_pLMEdit.clear(); - m_pRMLbl.clear(); - m_pRMEdit.clear(); - m_pDistFT.clear(); - m_pDistEdit.clear(); - m_pDynSpacingCB.clear(); - m_pHeightFT.clear(); - m_pHeightEdit.clear(); - m_pHeightDynBtn.clear(); - m_pBspWin.clear(); - m_pBackgroundBtn.clear(); - SfxTabPage::dispose(); -} - - bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) { const sal_uInt16 nWSize = GetWhich(SID_ATTR_PAGE_SIZE); @@ -275,23 +244,23 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) aSet.Put(XFillStyleItem(drawing::FillStyle_NONE)); } - aSet.Put( SfxBoolItem( nWOn, m_pTurnOnBox->IsChecked() ) ); - aSet.Put( SfxBoolItem( nWDynamic, m_pHeightDynBtn->IsChecked() ) ); - aSet.Put( SfxBoolItem( nWShared, m_pCntSharedBox->IsChecked() ) ); - if(m_pCntSharedFirstBox->IsVisible()) - aSet.Put( SfxBoolItem( nWSharedFirst, m_pCntSharedFirstBox->IsChecked() ) ); - if (m_pDynSpacingCB->IsVisible() && SfxItemPool::IsWhich(nWDynSpacing)) + aSet.Put( SfxBoolItem( nWOn, m_xTurnOnBox->get_active() ) ); + aSet.Put( SfxBoolItem( nWDynamic, m_xHeightDynBtn->get_active() ) ); + aSet.Put( SfxBoolItem( nWShared, m_xCntSharedBox->get_active() ) ); + if(m_xCntSharedFirstBox->get_visible()) + aSet.Put(SfxBoolItem(nWSharedFirst, m_xCntSharedFirstBox->get_active())); + if (m_xDynSpacingCB->get_visible() && SfxItemPool::IsWhich(nWDynSpacing)) { std::unique_ptr<SfxBoolItem> pBoolItem(static_cast<SfxBoolItem*>(pPool->GetDefaultItem(nWDynSpacing).Clone())); - pBoolItem->SetValue(m_pDynSpacingCB->IsChecked()); + pBoolItem->SetValue(m_xDynSpacingCB->get_active()); aSet.Put(*pBoolItem); } // Size SvxSizeItem aSizeItem( static_cast<const SvxSizeItem&>(rOldSet.Get( nWSize )) ); Size aSize( aSizeItem.GetSize() ); - long nDist = GetCoreValue( *m_pDistEdit, eUnit ); - long nH = GetCoreValue( *m_pHeightEdit, eUnit ); + long nDist = GetCoreValue( *m_xDistEdit, eUnit ); + long nH = GetCoreValue( *m_xHeightEdit, eUnit ); nH += nDist; // add distance aSize.setHeight( nH ); @@ -300,8 +269,8 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet ) // Margins SvxLRSpaceItem aLR( nWLRSpace ); - aLR.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_pLMEdit, eUnit )) ); - aLR.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_pRMEdit, eUnit )) ); + aLR.SetLeft( static_cast<sal_uInt16>(GetCoreValue( *m_xLMEdit, eUnit )) ); + aLR.SetRight( static_cast<sal_uInt16>(GetCoreValue( *m_xRMEdit, eUnit )) ); aSet.Put( aLR ); SvxULSpaceItem aUL( nWULSpace ); @@ -378,7 +347,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) const SfxPoolItem* pExt2 = GetItem(*rSet, SID_ATTR_PAGE_EXT2); if (pExt1 && dynamic_cast<const SfxBoolItem*>(pExt1) != nullptr && pExt2 && dynamic_cast<const SfxBoolItem*>(pExt2) != nullptr ) bIsCalc = true; - m_pCntSharedFirstBox->Show(!bIsCalc); + m_xCntSharedFirstBox->show(!bIsCalc); // Evaluate header-/footer- attributes const SvxSetItem* pSetItem = nullptr; @@ -390,7 +359,7 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) const SfxBoolItem& rHeaderOn = static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON))); - m_pTurnOnBox->Check(rHeaderOn.GetValue()); + m_xTurnOnBox->set_active(rHeaderOn.GetValue()); if ( rHeaderOn.GetValue() ) { @@ -407,33 +376,33 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) static_cast<const SvxULSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) )); const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); - if(m_pDynSpacingCB->IsVisible()) + if (m_xDynSpacingCB->get_visible()) { const SfxBoolItem& rDynSpacing = static_cast<const SfxBoolItem&>(rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING))); - m_pDynSpacingCB->Check(rDynSpacing.GetValue()); + m_xDynSpacingCB->set_active(rDynSpacing.GetValue()); } if ( nId == SID_ATTR_PAGE_HEADERSET ) { // Header - SetMetricValue( *m_pDistEdit, rUL.GetLower(), eUnit ); - SetMetricValue( *m_pHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit ); + SetMetricValue( *m_xDistEdit, rUL.GetLower(), eUnit ); + SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit ); } else { // Footer - SetMetricValue( *m_pDistEdit, rUL.GetUpper(), eUnit ); - SetMetricValue( *m_pHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit ); + SetMetricValue( *m_xDistEdit, rUL.GetUpper(), eUnit ); + SetMetricValue( *m_xHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit ); } - m_pHeightDynBtn->Check(rDynamic.GetValue()); - SetMetricValue( *m_pLMEdit, rLR.GetLeft(), eUnit ); - SetMetricValue( *m_pRMEdit, rLR.GetRight(), eUnit ); - m_pCntSharedBox->Check(rShared.GetValue()); + m_xHeightDynBtn->set_active(rDynamic.GetValue()); + SetMetricValue( *m_xLMEdit, rLR.GetLeft(), eUnit ); + SetMetricValue( *m_xRMEdit, rLR.GetRight(), eUnit ); + m_xCntSharedBox->set_active(rShared.GetValue()); if (pSharedFirst) - m_pCntSharedFirstBox->Check(pSharedFirst->GetValue()); + m_xCntSharedFirstBox->set_active(pSharedFirst->GetValue()); else - m_pCntSharedFirstBox->Hide(); + m_xCntSharedFirstBox->hide(); } else pSetItem = nullptr; @@ -442,27 +411,27 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) { // defaults for distance and height long nDefaultDist = bIsCalc ? DEF_DIST_CALC : DEF_DIST_WRITER; - SetMetricValue( *m_pDistEdit, nDefaultDist, MapUnit::Map100thMM ); - SetMetricValue( *m_pHeightEdit, 500, MapUnit::Map100thMM ); + SetMetricValue( *m_xDistEdit, nDefaultDist, MapUnit::Map100thMM ); + SetMetricValue( *m_xHeightEdit, 500, MapUnit::Map100thMM ); } if ( !pSetItem ) { - m_pTurnOnBox->Check( false ); - m_pHeightDynBtn->Check(); - m_pCntSharedBox->Check(); - m_pCntSharedFirstBox->Check(); + m_xTurnOnBox->set_active(false); + m_xHeightDynBtn->set_active(true); + m_xCntSharedBox->set_active(true); + m_xCntSharedFirstBox->set_active(true); } - TurnOnHdl(nullptr); + TurnOn(nullptr); - m_pTurnOnBox->SaveValue(); - m_pDistEdit->SaveValue(); - m_pHeightEdit->SaveValue(); - m_pHeightDynBtn->SaveValue(); - m_pLMEdit->SaveValue(); - m_pRMEdit->SaveValue(); - m_pCntSharedBox->SaveValue(); + m_xTurnOnBox->save_state(); + m_xDistEdit->save_value(); + m_xHeightEdit->save_value(); + m_xHeightDynBtn->save_state(); + m_xLMEdit->save_value(); + m_xRMEdit->save_value(); + m_xCntSharedBox->save_state(); RangeHdl(); const SfxPoolItem* pItem = nullptr; @@ -473,10 +442,10 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) { sal_uInt16 nHtmlMode = 0; nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue(); - if(nHtmlMode & HTMLMODE_ON) + if (nHtmlMode & HTMLMODE_ON) { - m_pCntSharedBox->Hide(); - m_pBackgroundBtn->Hide(); + m_xCntSharedBox->hide(); + m_xBackgroundBtn->hide(); } } @@ -484,52 +453,46 @@ void SvxHFPage::Reset( const SfxItemSet* rSet ) void SvxHFPage::InitHandler() { - m_pTurnOnBox->SetClickHdl(LINK(this, SvxHFPage, TurnOnHdl)); - m_pDistEdit->SetModifyHdl(LINK(this, SvxHFPage, DistModify)); - m_pDistEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl)); - - m_pHeightEdit->SetModifyHdl(LINK(this, SvxHFPage, HeightModify)); - m_pHeightEdit->SetLoseFocusHdl(LINK(this,SvxHFPage,RangeFocusHdl)); - - m_pLMEdit->SetModifyHdl(LINK(this, SvxHFPage, BorderModify)); - m_pLMEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl)); - m_pRMEdit->SetModifyHdl(LINK(this, SvxHFPage, BorderModify)); - m_pRMEdit->SetLoseFocusHdl(LINK(this, SvxHFPage, RangeFocusHdl)); - m_pBackgroundBtn->SetClickHdl(LINK(this,SvxHFPage, BackgroundHdl)); + m_xTurnOnBox->connect_toggled(LINK(this, SvxHFPage, TurnOnHdl)); + m_xDistEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl)); + m_xHeightEdit->connect_value_changed(LINK(this,SvxHFPage,ValueChangeHdl)); + + m_xLMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl)); + m_xRMEdit->connect_value_changed(LINK(this, SvxHFPage, ValueChangeHdl)); + m_xBackgroundBtn->connect_clicked(LINK(this,SvxHFPage, BackgroundHdl)); } -IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void ) +void SvxHFPage::TurnOn(weld::ToggleButton* pBox) { - CheckBox* pBox = static_cast<CheckBox*>(pButton); - if ( m_pTurnOnBox->IsChecked() ) + if (m_xTurnOnBox->get_active()) { - m_pDistFT->Enable(); - m_pDistEdit->Enable(); - m_pDynSpacingCB->Enable(); - m_pHeightFT->Enable(); - m_pHeightEdit->Enable(); - m_pHeightDynBtn->Enable(); - m_pLMLbl->Enable(); - m_pLMEdit->Enable(); - m_pRMLbl->Enable(); - m_pRMEdit->Enable(); - - SvxPageUsage nUsage = m_pBspWin->GetUsage(); + m_xDistFT->set_sensitive(true); + m_xDistEdit->set_sensitive(true); + m_xDynSpacingCB->set_sensitive(true); + m_xHeightFT->set_sensitive(true); + m_xHeightEdit->set_sensitive(true); + m_xHeightDynBtn->set_sensitive(true); + m_xLMLbl->set_sensitive(true); + m_xLMEdit->set_sensitive(true); + m_xRMLbl->set_sensitive(true); + m_xRMEdit->set_sensitive(true); + + SvxPageUsage nUsage = m_aBspWin.GetUsage(); if( nUsage == SvxPageUsage::Right || nUsage == SvxPageUsage::Left ) - m_pCntSharedBox->Disable(); + m_xCntSharedBox->set_sensitive(false); else { - m_pCntSharedBox->Enable(); - m_pCntSharedFirstBox->Enable(); + m_xCntSharedBox->set_sensitive(true); + m_xCntSharedFirstBox->set_sensitive(true); } - m_pBackgroundBtn->Enable(); + m_xBackgroundBtn->set_sensitive(true); } else { bool bDelete = true; - if ( !mbDisableQueryBox && pBox && m_pTurnOnBox->GetSavedValue() == TRISTATE_TRUE ) + if (!mbDisableQueryBox && pBox && m_xTurnOnBox->get_saved_state() == TRISTATE_TRUE) { short nResult; if (nId == SID_ATTR_PAGE_HEADERSET) @@ -547,44 +510,34 @@ IMPL_LINK( SvxHFPage, TurnOnHdl, Button *, pButton, void ) if ( bDelete ) { - m_pDistFT->Disable(); - m_pDistEdit->Disable(); - m_pDynSpacingCB->Enable(false); - m_pHeightFT->Disable(); - m_pHeightEdit->Disable(); - m_pHeightDynBtn->Disable(); - - m_pLMLbl->Disable(); - m_pLMEdit->Disable(); - m_pRMLbl->Disable(); - m_pRMEdit->Disable(); - - m_pCntSharedBox->Disable(); - m_pBackgroundBtn->Disable(); - m_pCntSharedFirstBox->Disable(); + m_xDistFT->set_sensitive(false); + m_xDistEdit->set_sensitive(false); + m_xDynSpacingCB->set_sensitive(false); + m_xHeightFT->set_sensitive(false); + m_xHeightEdit->set_sensitive(false); + m_xHeightDynBtn->set_sensitive(false); + + m_xLMLbl->set_sensitive(false); + m_xLMEdit->set_sensitive(false); + m_xRMLbl->set_sensitive(false); + m_xRMEdit->set_sensitive(false); + + m_xCntSharedBox->set_sensitive(false); + m_xBackgroundBtn->set_sensitive(false); + m_xCntSharedFirstBox->set_sensitive(false); } else - m_pTurnOnBox->Check(); + m_xTurnOnBox->set_active(true); } UpdateExample(); } -IMPL_LINK_NOARG(SvxHFPage, DistModify, Edit&, void) +IMPL_LINK(SvxHFPage, TurnOnHdl, weld::ToggleButton&, rBox, void) { - UpdateExample(); + TurnOn(&rBox); } -IMPL_LINK_NOARG(SvxHFPage, HeightModify, Edit&, void) -{ - UpdateExample(); -} - -IMPL_LINK_NOARG(SvxHFPage, BorderModify, Edit&, void) -{ - UpdateExample(); -} - -IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void) +IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, void) { if(!pBBSet) { @@ -595,13 +548,13 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void) if(mbEnableDrawingLayerFillStyles) { - pBBSet = new SfxItemSet( + pBBSet.reset(new SfxItemSet( *GetItemSet().GetPool(), {{XATTR_FILL_FIRST, XATTR_FILL_LAST}, // DrawingLayer FillStyle definitions {SID_COLOR_TABLE, SID_PATTERN_LIST}, // XPropertyLists for Color, Gradient, Hatch and Graphic fills {nOuter, nOuter}, {nInner, nInner}, - {nShadow, nShadow}}); + {nShadow, nShadow}})); // copy items for XPropertyList entries from the DrawModel so that // the Area TabPage can access them @@ -632,12 +585,12 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void) { const sal_uInt16 nBrush(GetWhich(SID_ATTR_BRUSH)); - pBBSet = new SfxItemSet( + pBBSet.reset( new SfxItemSet( *GetItemSet().GetPool(), {{nBrush, nBrush}, {nOuter, nOuter}, {nInner, nInner}, - {nShadow, nShadow}}); + {nShadow, nShadow}}) ); } const SfxPoolItem* pItem; @@ -669,89 +622,85 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, Button*, void) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - if(pFact) + ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg( + this, + *pBBSet, + mbEnableDrawingLayerFillStyles)); + + if(RET_OK == pDlg->Execute() && pDlg->GetOutputItemSet()) { - ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg( - this, - *pBBSet, - mbEnableDrawingLayerFillStyles)); + SfxItemIter aIter(*pDlg->GetOutputItemSet()); + const SfxPoolItem* pItem = aIter.FirstItem(); - DBG_ASSERT(pDlg,"Dialog creation failed!"); - if(RET_OK == pDlg->Execute() && pDlg->GetOutputItemSet()) + while(pItem) { - SfxItemIter aIter(*pDlg->GetOutputItemSet()); - const SfxPoolItem* pItem = aIter.FirstItem(); - - while(pItem) + if(!IsInvalidItem(pItem)) { - if(!IsInvalidItem(pItem)) - { - pBBSet->Put(*pItem); - } - - pItem = aIter.NextItem(); + pBBSet->Put(*pItem); } - { - drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes; - - if(mbEnableDrawingLayerFillStyles) - { - // create FillAttributes directly from DrawingLayer FillStyle entries - aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pBBSet)); - } - else - { - const sal_uInt16 nWhich = GetWhich(SID_ATTR_BRUSH); + pItem = aIter.NextItem(); + } - if(pBBSet->GetItemState(nWhich) == SfxItemState::SET) - { - // create FillAttributes from SvxBrushItem - const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(pBBSet->Get(nWhich)); - SfxItemSet aTempSet(*pBBSet->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); + { + drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes; - setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); - aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); - } - } + if(mbEnableDrawingLayerFillStyles) + { + // create FillAttributes directly from DrawingLayer FillStyle entries + aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pBBSet)); + } + else + { + const sal_uInt16 nWhich = GetWhich(SID_ATTR_BRUSH); - if(SID_ATTR_PAGE_HEADERSET == nId) - { - //m_pBspWin->SetHdColor(rItem.GetColor()); - m_pBspWin->setHeaderFillAttributes(aFillAttributes); - } - else + if(pBBSet->GetItemState(nWhich) == SfxItemState::SET) { - //m_pBspWin->SetFtColor(rItem.GetColor()); - m_pBspWin->setFooterFillAttributes(aFillAttributes); + // create FillAttributes from SvxBrushItem + const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(pBBSet->Get(nWhich)); + SfxItemSet aTempSet(*pBBSet->GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); + + setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); + aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(aTempSet)); } } + if(SID_ATTR_PAGE_HEADERSET == nId) + { + //m_aBspWin.SetHdColor(rItem.GetColor()); + m_aBspWin.setHeaderFillAttributes(aFillAttributes); + } + else + { + //m_aBspWin.SetFtColor(rItem.GetColor()); + m_aBspWin.setFooterFillAttributes(aFillAttributes); + } } - UpdateExample(); } + + UpdateExample(); } void SvxHFPage::UpdateExample() { if ( nId == SID_ATTR_PAGE_HEADERSET ) { - m_pBspWin->SetHeader( m_pTurnOnBox->IsChecked() ); - m_pBspWin->SetHdHeight( GetCoreValue( *m_pHeightEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetHdDist( GetCoreValue( *m_pDistEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetHdLeft( GetCoreValue( *m_pLMEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetHdRight( GetCoreValue( *m_pRMEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetHeader( m_xTurnOnBox->get_active() ); + m_aBspWin.SetHdHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetHdDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetHdLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetHdRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) ); } else { - m_pBspWin->SetFooter( m_pTurnOnBox->IsChecked() ); - m_pBspWin->SetFtHeight( GetCoreValue( *m_pHeightEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetFtDist( GetCoreValue( *m_pDistEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetFtLeft( GetCoreValue( *m_pLMEdit, MapUnit::MapTwip ) ); - m_pBspWin->SetFtRight( GetCoreValue( *m_pRMEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetFooter( m_xTurnOnBox->get_active() ); + m_aBspWin.SetFtHeight( GetCoreValue( *m_xHeightEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetFtDist( GetCoreValue( *m_xDistEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetFtLeft( GetCoreValue( *m_xLMEdit, MapUnit::MapTwip ) ); + m_aBspWin.SetFtRight( GetCoreValue( *m_xRMEdit, MapUnit::MapTwip ) ); } - m_pBspWin->Invalidate(); + m_aBspWin.Invalidate(); } void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) @@ -788,7 +737,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) } } - m_pBspWin->setHeaderFillAttributes(aHeaderFillAttributes); + m_aBspWin.setHeaderFillAttributes(aHeaderFillAttributes); } } @@ -824,7 +773,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) } } - m_pBspWin->setFooterFillAttributes(aFooterFillAttributes); + m_aBspWin.setFooterFillAttributes(aFooterFillAttributes); } } @@ -850,7 +799,7 @@ void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet ) } } - m_pBspWin->setPageFillAttributes(aPageFillAttributes); + m_aBspWin.setPageFillAttributes(aPageFillAttributes); } void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) @@ -862,13 +811,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) // Set left and right margins const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(*pItem); - m_pBspWin->SetLeft( rLRSpace.GetLeft() ); - m_pBspWin->SetRight( rLRSpace.GetRight() ); + m_aBspWin.SetLeft( rLRSpace.GetLeft() ); + m_aBspWin.SetRight( rLRSpace.GetRight() ); } else { - m_pBspWin->SetLeft( 0 ); - m_pBspWin->SetRight( 0 ); + m_aBspWin.SetLeft( 0 ); + m_aBspWin.SetRight( 0 ); } pItem = GetItem( rSet, SID_ATTR_ULSPACE ); @@ -878,13 +827,13 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) // Set top and bottom margins const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(*pItem); - m_pBspWin->SetTop( rULSpace.GetUpper() ); - m_pBspWin->SetBottom( rULSpace.GetLower() ); + m_aBspWin.SetTop( rULSpace.GetUpper() ); + m_aBspWin.SetBottom( rULSpace.GetLower() ); } else { - m_pBspWin->SetTop( 0 ); - m_pBspWin->SetBottom( 0 ); + m_aBspWin.SetTop( 0 ); + m_aBspWin.SetBottom( 0 ); } SvxPageUsage nUsage = SvxPageUsage::All; @@ -893,14 +842,14 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) if ( pItem ) nUsage = static_cast<const SvxPageItem*>(pItem)->GetPageUsage(); - m_pBspWin->SetUsage( nUsage ); + m_aBspWin.SetUsage( nUsage ); if ( SvxPageUsage::Right == nUsage || SvxPageUsage::Left == nUsage ) - m_pCntSharedBox->Disable(); + m_xCntSharedBox->set_sensitive(false); else { - m_pCntSharedBox->Enable(); - m_pCntSharedFirstBox->Enable(); + m_xCntSharedBox->set_sensitive(true); + m_xCntSharedFirstBox->set_sensitive(true); } pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE ); @@ -909,7 +858,7 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) // Orientation and Size from the PageItem const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(*pItem); // if the size is already swapped (Landscape) - m_pBspWin->SetSize( rSize.GetSize() ); + m_aBspWin.SetSize( rSize.GetSize() ); } // Evaluate Header attribute @@ -933,11 +882,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); long nDist = rUL.GetLower(); - m_pBspWin->SetHdHeight( rSize.GetSize().Height() - nDist ); - m_pBspWin->SetHdDist( nDist ); - m_pBspWin->SetHdLeft( rLR.GetLeft() ); - m_pBspWin->SetHdRight( rLR.GetRight() ); - m_pBspWin->SetHeader( true ); + m_aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist ); + m_aBspWin.SetHdDist( nDist ); + m_aBspWin.SetHdLeft( rLR.GetLeft() ); + m_aBspWin.SetHdRight( rLR.GetRight() ); + m_aBspWin.SetHeader( true ); } else pSetItem = nullptr; @@ -945,12 +894,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) if ( !pSetItem ) { - m_pBspWin->SetHeader( false ); + m_aBspWin.SetHeader( false ); if ( SID_ATTR_PAGE_HEADERSET == nId ) { - m_pCntSharedBox->Disable(); - m_pCntSharedFirstBox->Disable(); + m_xCntSharedBox->set_sensitive(false); + m_xCntSharedFirstBox->set_sensitive(false); } } pSetItem = nullptr; @@ -973,11 +922,11 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) )); long nDist = rUL.GetUpper(); - m_pBspWin->SetFtHeight( rSize.GetSize().Height() - nDist ); - m_pBspWin->SetFtDist( nDist ); - m_pBspWin->SetFtLeft( rLR.GetLeft() ); - m_pBspWin->SetFtRight( rLR.GetRight() ); - m_pBspWin->SetFooter( true ); + m_aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist ); + m_aBspWin.SetFtDist( nDist ); + m_aBspWin.SetFtLeft( rLR.GetLeft() ); + m_aBspWin.SetFtRight( rLR.GetRight() ); + m_aBspWin.SetFooter( true ); } else pSetItem = nullptr; @@ -985,12 +934,12 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) if ( !pSetItem ) { - m_pBspWin->SetFooter( false ); + m_aBspWin.SetFooter( false ); if ( SID_ATTR_PAGE_FOOTERSET == nId ) { - m_pCntSharedBox->Disable(); - m_pCntSharedFirstBox->Disable(); + m_xCntSharedBox->set_sensitive(false); + m_xCntSharedFirstBox->set_sensitive(false); } } @@ -998,16 +947,16 @@ void SvxHFPage::ActivatePage( const SfxItemSet& rSet ) if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr ) { - m_pBspWin->SetTable( true ); - m_pBspWin->SetHorz( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + m_aBspWin.SetTable( true ); + m_aBspWin.SetHorz( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); } pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 ); if ( pItem && dynamic_cast<const SfxBoolItem*>( pItem) != nullptr ) { - m_pBspWin->SetTable( true ); - m_pBspWin->SetVert( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); + m_aBspWin.SetTable( true ); + m_aBspWin.SetVert( static_cast<const SfxBoolItem*>(pItem)->GetValue() ); } ResetBackground_Impl( rSet ); RangeHdl(); @@ -1020,22 +969,24 @@ DeactivateRC SvxHFPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } -IMPL_LINK_NOARG(SvxHFPage, RangeFocusHdl, Control&, void) +IMPL_LINK_NOARG(SvxHFPage, ValueChangeHdl, weld::MetricSpinButton&, void) { + UpdateExample(); RangeHdl(); } + void SvxHFPage::RangeHdl() { - long nHHeight = m_pBspWin->GetHdHeight(); - long nHDist = m_pBspWin->GetHdDist(); + long nHHeight = m_aBspWin.GetHdHeight(); + long nHDist = m_aBspWin.GetHdDist(); - long nFHeight = m_pBspWin->GetFtHeight(); - long nFDist = m_pBspWin->GetFtDist(); + long nFHeight = m_aBspWin.GetFtHeight(); + long nFDist = m_aBspWin.GetFtDist(); - long nHeight = std::max( long(MINBODY), - static_cast<long>(m_pHeightEdit->Denormalize( m_pHeightEdit->GetValue( FUNIT_TWIP ) ) ) ); - long nDist = m_pTurnOnBox->IsChecked() ? - static_cast<long>(m_pDistEdit->Denormalize( m_pDistEdit->GetValue( FUNIT_TWIP ) )) : 0; + long nHeight = std::max(long(MINBODY), + static_cast<long>(m_xHeightEdit->denormalize(m_xHeightEdit->get_value(FUNIT_TWIP)))); + long nDist = m_xTurnOnBox->get_active() ? + static_cast<long>(m_xDistEdit->denormalize(m_xDistEdit->get_value(FUNIT_TWIP))) : 0; long nMin; long nMax; @@ -1052,13 +1003,13 @@ void SvxHFPage::RangeHdl() } // Current values of the side edges - long nBT = m_pBspWin->GetTop(); - long nBB = m_pBspWin->GetBottom(); - long nBL = m_pBspWin->GetLeft(); - long nBR = m_pBspWin->GetRight(); + long nBT = m_aBspWin.GetTop(); + long nBB = m_aBspWin.GetBottom(); + long nBL = m_aBspWin.GetLeft(); + long nBR = m_aBspWin.GetRight(); - long nH = m_pBspWin->GetSize().Height(); - long nW = m_pBspWin->GetSize().Width(); + long nH = m_aBspWin.GetSize().Height(); + long nW = m_aBspWin.GetSize().Width(); // Borders if ( nId == SID_ATTR_PAGE_HEADERSET ) @@ -1067,11 +1018,11 @@ void SvxHFPage::RangeHdl() nMin = ( nH - nBB - nBT ) / 5; // 20% nMax = std::max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT, nMin ); - m_pHeightEdit->SetMax( m_pHeightEdit->Normalize( nMax ), FUNIT_TWIP ); + m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FUNIT_TWIP); nMin = ( nH - nBB - nBT ) / 5; // 20% nDist = std::max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT, long(0) ); - m_pDistEdit->SetMax( m_pDistEdit->Normalize( nDist ), FUNIT_TWIP ); + m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FUNIT_TWIP); } else { @@ -1079,53 +1030,33 @@ void SvxHFPage::RangeHdl() nMin = ( nH - nBT - nBB ) / 5; // 20% nMax = std::max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB, nMin ); - m_pHeightEdit->SetMax( m_pHeightEdit->Normalize( nMax ), FUNIT_TWIP ); + m_xHeightEdit->set_max(m_xHeightEdit->normalize(nMax), FUNIT_TWIP); nMin = ( nH - nBT - nBB ) / 5; // 20% nDist = std::max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB, long(0) ); - m_pDistEdit->SetMax( m_pDistEdit->Normalize( nDist ), FUNIT_TWIP ); + m_xDistEdit->set_max(m_xDistEdit->normalize(nDist), FUNIT_TWIP); } // Limit Indentation nMax = nW - nBL - nBR - - static_cast<long>(m_pRMEdit->Denormalize( m_pRMEdit->GetValue( FUNIT_TWIP ) )) - MINBODY; - m_pLMEdit->SetMax( m_pLMEdit->Normalize( nMax ), FUNIT_TWIP ); + static_cast<long>(m_xRMEdit->denormalize(m_xRMEdit->get_value(FUNIT_TWIP))) - MINBODY; + m_xLMEdit->set_max(m_xLMEdit->normalize(nMax), FUNIT_TWIP); nMax = nW - nBL - nBR - - static_cast<long>(m_pLMEdit->Denormalize( m_pLMEdit->GetValue( FUNIT_TWIP ) )) - MINBODY; - m_pRMEdit->SetMax( m_pLMEdit->Normalize( nMax ), FUNIT_TWIP ); -} - -static void lcl_Move(vcl::Window& rWin, sal_Int32 nDiff) -{ - Point aPos(rWin.GetPosPixel()); - aPos.AdjustY( -nDiff ); - rWin.SetPosPixel(aPos); + static_cast<long>(m_xLMEdit->denormalize(m_xLMEdit->get_value(FUNIT_TWIP))) - MINBODY; + m_xRMEdit->set_max(m_xLMEdit->normalize(nMax), FUNIT_TWIP); } void SvxHFPage::EnableDynamicSpacing() { - m_pDynSpacingCB->Show(); - //move all following controls - vcl::Window* aMoveWindows[] = - { - m_pHeightFT, - m_pHeightEdit, - m_pHeightDynBtn, - m_pBackgroundBtn, - nullptr - }; - sal_Int32 nOffset = m_pTurnOnBox->GetPosPixel().Y() - m_pCntSharedBox->GetPosPixel().Y(); - sal_Int32 nIdx = 0; - while(aMoveWindows[nIdx]) - lcl_Move(*aMoveWindows[nIdx++], nOffset); + m_xDynSpacingCB->show(); } void SvxHFPage::PageCreated(const SfxAllItemSet &rSet) { const SfxBoolItem* pSupportDrawingLayerFillStyleItem = rSet.GetItem<SfxBoolItem>(SID_DRAWINGLAYER_FILLSTYLES, false); - if(pSupportDrawingLayerFillStyleItem) + if (pSupportDrawingLayerFillStyleItem) { const bool bNew(pSupportDrawingLayerFillStyleItem->GetValue()); diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx index eb2fc6ef92fd..7c3d4a7e54f4 100644 --- a/svx/source/dialog/pagectrl.cxx +++ b/svx/source/dialog/pagectrl.cxx @@ -413,4 +413,379 @@ Size SvxPageWindow::GetOptimalSize() const return LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont)); } +PageWindow::PageWindow() : + aWinSize(), + aSize(), + nTop(0), + nBottom(0), + nLeft(0), + nRight(0), + bResetBackground(false), + bFrameDirection(false), + nFrameDirection(SvxFrameDirection::Horizontal_LR_TB), + nHdLeft(0), + nHdRight(0), + nHdDist(0), + nHdHeight(0), + nFtLeft(0), + nFtRight(0), + nFtDist(0), + nFtHeight(0), + maHeaderFillAttributes(), + maFooterFillAttributes(), + maPageFillAttributes(), + bFooter(false), + bHeader(false), + bTable(false), + bHorz(false), + bVert(false), + eUsage(SvxPageUsage::All) +{ +} + +PageWindow::~PageWindow() +{ +} + +void PageWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + rRenderContext.Push(PushFlags::MAPMODE); + rRenderContext.SetMapMode(MapMode(MapUnit::MapTwip)); + + Fraction aXScale(aWinSize.Width(), std::max(long(aSize.Width() * 2 + aSize.Width() / 8), 1L)); + Fraction aYScale(aWinSize.Height(), std::max(aSize.Height(), 1L)); + MapMode aMapMode(rRenderContext.GetMapMode()); + + if(aYScale < aXScale) + { + aMapMode.SetScaleX(aYScale); + aMapMode.SetScaleY(aYScale); + } + else + { + aMapMode.SetScaleX(aXScale); + aMapMode.SetScaleY(aXScale); + } + rRenderContext.SetMapMode(aMapMode); + Size aSz(rRenderContext.PixelToLogic(GetOutputSizePixel())); + long nYPos = (aSz.Height() - aSize.Height()) / 2; + + if (eUsage == SvxPageUsage::All) + { + // all pages are equal -> draw one page + if (aSize.Width() > aSize.Height()) + { + // Draw Landscape page of the same size + Fraction aX = aMapMode.GetScaleX(); + Fraction aY = aMapMode.GetScaleY(); + Fraction a2(1.5); + aX *= a2; + aY *= a2; + aMapMode.SetScaleX(aX); + aMapMode.SetScaleY(aY); + rRenderContext.SetMapMode(aMapMode); + aSz = rRenderContext.PixelToLogic(GetOutputSizePixel()); + nYPos = (aSz.Height() - aSize.Height()) / 2; + long nXPos = (aSz.Width() - aSize.Width()) / 2; + DrawPage(rRenderContext, Point(nXPos,nYPos),true,true); + } + else + // Portrait + DrawPage(rRenderContext, Point((aSz.Width() - aSize.Width()) / 2,nYPos),true,true); + } + else + { + // Left and right page are different -> draw two pages if possible + DrawPage(rRenderContext, Point(0, nYPos), false, + eUsage == SvxPageUsage::Left || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror); + DrawPage(rRenderContext, Point(aSize.Width() + aSize.Width() / 8, nYPos), true, + eUsage == SvxPageUsage::Right || eUsage == SvxPageUsage::All || eUsage == SvxPageUsage::Mirror); + } + rRenderContext.Pop(); +} + +void PageWindow::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOrg, const bool bSecond, const bool bEnabled) +{ + const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); + const Color& rFieldColor = rStyleSettings.GetFieldColor(); + const Color& rFieldTextColor = rStyleSettings.GetFieldTextColor(); + const Color& rDisableColor = rStyleSettings.GetDisableColor(); + const Color& rDlgColor = rStyleSettings.GetDialogColor(); + + // background + if (!bSecond || bResetBackground) + { + rRenderContext.SetLineColor(COL_TRANSPARENT); + rRenderContext.SetFillColor(rDlgColor); + Size winSize(rRenderContext.GetOutputSize()); + rRenderContext.DrawRect(tools::Rectangle(Point(0,0), winSize)); + + if (bResetBackground) + bResetBackground = false; + } + rRenderContext.SetLineColor(rFieldTextColor); + + // Shadow + Size aTempSize = aSize; + + // Page + if (!bEnabled) + { + rRenderContext.SetFillColor(rDisableColor); + rRenderContext.DrawRect(tools::Rectangle(rOrg, aTempSize)); + return; + } + rRenderContext.SetFillColor(rFieldColor); + rRenderContext.DrawRect(tools::Rectangle(rOrg, aTempSize)); + + long nL = nLeft; + long nR = nRight; + + if (eUsage == SvxPageUsage::Mirror && !bSecond) + { + // turn for mirrored + nL = nRight; + nR = nLeft; + } + + tools::Rectangle aRect; + + aRect.SetLeft( rOrg.X() + nL ); + aRect.SetRight( rOrg.X() + aTempSize.Width() - nR ); + aRect.SetTop( rOrg.Y() + nTop ); + aRect.SetBottom( rOrg.Y() + aTempSize.Height() - nBottom ); + + tools::Rectangle aHdRect(aRect); + tools::Rectangle aFtRect(aRect); + + if (bHeader || bFooter) + { + // Header and/or footer used + const Color aLineColor(rRenderContext.GetLineColor()); + + // draw PageFill first and on the whole page, no outline + rRenderContext.SetLineColor(); + drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect); + rRenderContext.SetLineColor(aLineColor); + + if (bHeader) + { + // show headers if possible + aHdRect.AdjustLeft(nHdLeft ); + aHdRect.AdjustRight( -(nHdRight) ); + aHdRect.SetBottom( aRect.Top() + nHdHeight ); + aRect.AdjustTop(nHdHeight + nHdDist ); + + // draw header over PageFill, plus outline + drawFillAttributes(rRenderContext, maHeaderFillAttributes, aHdRect, aHdRect); + } + + if (bFooter) + { + // show footer if possible + aFtRect.AdjustLeft(nFtLeft ); + aFtRect.AdjustRight( -(nFtRight) ); + aFtRect.SetTop( aRect.Bottom() - nFtHeight ); + aRect.AdjustBottom( -(nFtHeight + nFtDist) ); + + // draw footer over PageFill, plus outline + drawFillAttributes(rRenderContext, maFooterFillAttributes, aFtRect, aFtRect); + } + + // draw page's reduced outline, only outline + drawFillAttributes(rRenderContext, drawinglayer::attribute::SdrAllFillAttributesHelperPtr(), aRect, aRect); + } + else + { + // draw PageFill and outline + drawFillAttributes(rRenderContext, maPageFillAttributes, aRect, aRect); + } + + if (bFrameDirection && !bTable) + { + Point aPos; + vcl::Font aFont(rRenderContext.GetFont()); + const Size aSaveSize = aFont.GetFontSize(); + Size aDrawSize(0,aRect.GetHeight() / 6); + aFont.SetFontSize(aDrawSize); + rRenderContext.SetFont(aFont); + OUString sText("ABC"); + Point aMove(1, rRenderContext.GetTextHeight()); + sal_Unicode cArrow = 0x2193; + long nAWidth = rRenderContext.GetTextWidth(sText.copy(0,1)); + switch (nFrameDirection) + { + case SvxFrameDirection::Horizontal_LR_TB: + aPos = aRect.TopLeft(); + aPos.AdjustX(rRenderContext.PixelToLogic(Point(1,1)).X() ); + aMove.setY( 0 ); + cArrow = 0x2192; + break; + case SvxFrameDirection::Horizontal_RL_TB: + aPos = aRect.TopRight(); + aPos.AdjustX( -nAWidth ); + aMove.setY( 0 ); + aMove.setX( aMove.X() * -1 ); + cArrow = 0x2190; + break; + case SvxFrameDirection::Vertical_LR_TB: + aPos = aRect.TopLeft(); + aPos.AdjustX(rRenderContext.PixelToLogic(Point(1,1)).X() ); + aMove.setX( 0 ); + break; + case SvxFrameDirection::Vertical_RL_TB: + aPos = aRect.TopRight(); + aPos.AdjustX( -nAWidth ); + aMove.setX( 0 ); + break; + default: break; + } + sText += OUStringLiteral1(cArrow); + for (sal_Int32 i = 0; i < sText.getLength(); i++) + { + OUString sDraw(sText.copy(i,1)); + long nHDiff = 0; + long nCharWidth = rRenderContext.GetTextWidth(sDraw); + bool bHorizontal = 0 == aMove.Y(); + if (!bHorizontal) + { + nHDiff = (nAWidth - nCharWidth) / 2; + aPos.AdjustX(nHDiff ); + } + rRenderContext.DrawText(aPos,sDraw); + if (bHorizontal) + { + aPos.AdjustX(aMove.X() < 0 ? -nCharWidth : nCharWidth ); + } + else + { + aPos.AdjustX( -nHDiff ); + aPos.AdjustY(aMove.Y() ); + } + } + aFont.SetFontSize(aSaveSize); + rRenderContext.SetFont(aFont); + + } + if (bTable) + { + // Paint Table, if necessary center it + rRenderContext.SetLineColor(COL_LIGHTGRAY); + + long nW = aRect.GetWidth(); + long nH = aRect.GetHeight(); + long const nTW = CELL_WIDTH * 3; + long const nTH = CELL_HEIGHT * 3; + long _nLeft = bHorz ? aRect.Left() + ((nW - nTW) / 2) : aRect.Left(); + long _nTop = bVert ? aRect.Top() + ((nH - nTH) / 2) : aRect.Top(); + tools::Rectangle aCellRect(Point(_nLeft, _nTop),Size(CELL_WIDTH, CELL_HEIGHT)); + + for (sal_uInt16 i = 0; i < 3; ++i) + { + aCellRect.SetLeft( _nLeft ); + aCellRect.SetRight( _nLeft + CELL_WIDTH ); + if(i > 0) + aCellRect.Move(0,CELL_HEIGHT); + + for (sal_uInt16 j = 0; j < 3; ++j) + { + if (j > 0) + aCellRect.Move(CELL_WIDTH,0); + rRenderContext.DrawRect(aCellRect); + } + } + } +} + +void PageWindow::drawFillAttributes(vcl::RenderContext& rRenderContext, + const drawinglayer::attribute::SdrAllFillAttributesHelperPtr& rFillAttributes, + const tools::Rectangle& rPaintRange, + const tools::Rectangle& rDefineRange) +{ + const basegfx::B2DRange aPaintRange( + rPaintRange.Left(), + rPaintRange.Top(), + rPaintRange.Right(), + rPaintRange.Bottom()); + + if(!aPaintRange.isEmpty() && + !basegfx::fTools::equalZero(aPaintRange.getWidth()) && + !basegfx::fTools::equalZero(aPaintRange.getHeight())) + { + const basegfx::B2DRange aDefineRange( + rDefineRange.Left(), + rDefineRange.Top(), + rDefineRange.Right(), + rDefineRange.Bottom()); + + // prepare primitive sequence + drawinglayer::primitive2d::Primitive2DContainer aSequence; + + // create fill geometry if there is something to fill + if (rFillAttributes.get() && rFillAttributes->isUsed()) + { + aSequence = rFillAttributes->getPrimitive2DSequence(aPaintRange, aDefineRange); + } + + // create line geometry if a LineColor is set at the target device + if (rRenderContext.IsLineColor()) + { + const drawinglayer::primitive2d::Primitive2DReference xOutline( + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + basegfx::utils::createPolygonFromRect(aPaintRange), rRenderContext.GetLineColor().getBColor())); + + aSequence.push_back(xOutline); + } + + // draw that if we have something to draw + if (!aSequence.empty()) + { + const drawinglayer::geometry::ViewInformation2D aViewInformation2D( + basegfx::B2DHomMatrix(), rRenderContext.GetViewTransformation(), aPaintRange, nullptr, + 0.0, css::uno::Sequence<css::beans::PropertyValue >()); + + std::unique_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor; + pProcessor.reset(drawinglayer::processor2d::createProcessor2DFromOutputDevice(rRenderContext, aViewInformation2D)); + + if (pProcessor) + { + pProcessor->process(aSequence); + } + } + } +} + + +void PageWindow::EnableFrameDirection(bool bEnable) +{ + bFrameDirection = bEnable; +} + +void PageWindow::SetFrameDirection(SvxFrameDirection nDirection) +{ + nFrameDirection = nDirection; +} + +void PageWindow::ResetBackground() +{ + bResetBackground = true; +} + +void PageWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + OutputDevice& rRefDevice = pDrawingArea->get_ref_device(); + // Count in Twips by default + rRefDevice.Push(PushFlags::MAPMODE); + rRefDevice.SetMapMode(MapMode(MapUnit::MapTwip)); + aWinSize = rRefDevice.LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont)); + pDrawingArea->set_size_request(aWinSize.Width(), aWinSize.Height()); + CustomWidgetController::SetDrawingArea(pDrawingArea); + + aWinSize.AdjustHeight( -4 ); + aWinSize.AdjustWidth( -4 ); + + aWinSize = rRefDevice.PixelToLogic(aWinSize); + rRefDevice.Pop(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/headfootformatpage.ui b/svx/uiconfig/ui/headfootformatpage.ui index dbf51adcf028..38ce3e434e2e 100644 --- a/svx/uiconfig/ui/headfootformatpage.ui +++ b/svx/uiconfig/ui/headfootformatpage.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> <interface domain="svx"> - <!-- interface-requires gtk+ 3.0 --> - <!-- interface-requires LibreOffice 1.0 --> + <requires lib="gtk+" version="3.18"/> <object class="GtkAdjustment" id="adjustment1"> <property name="upper">99.989999999999995</property> <property name="step_increment">0.10000000000000001</property> @@ -14,6 +14,16 @@ <property name="step_increment">0.10000000000000001</property> <property name="page_increment">10</property> </object> + <object class="GtkAdjustment" id="adjustment3"> + <property name="upper">99.989999999999995</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="upper">99.989999999999995</property> + <property name="step_increment">0.10000000000000001</property> + <property name="page_increment">10</property> + </object> <object class="GtkGrid" id="HFFormatPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -123,7 +133,6 @@ <property name="left_attach">0</property> <property name="top_attach">0</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> <child> @@ -132,8 +141,8 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="use_underline">True</property> <property name="hexpand">True</property> + <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> </object> @@ -141,7 +150,6 @@ <property name="left_attach">0</property> <property name="top_attach">1</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> <child> @@ -149,31 +157,28 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelLeftMarg">_Left margin:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">spinMargLeft:0.00cm</property> + <property name="mnemonic_widget">spinMargLeft</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="spinMargLeft:0.00cm"> + <object class="GtkSpinButton" id="spinMargLeft"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="halign">center</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment1</property> <property name="digits">2</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -181,31 +186,28 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelRightMarg">R_ight margin:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">spinMargRight:0.00cm</property> + <property name="mnemonic_widget">spinMargRight</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="spinMargRight:0.00cm"> + <object class="GtkSpinButton" id="spinMargRight"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="halign">center</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment3</property> <property name="digits">2</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -213,31 +215,28 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelSpacing">_Spacing:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">spinSpacing:0.00cm</property> + <property name="mnemonic_widget">spinSpacing</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">4</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="spinSpacing:0.00cm"> + <object class="GtkSpinButton" id="spinSpacing"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="halign">center</property> - <property name="adjustment">adjustment1</property> + <property name="activates_default">True</property> + <property name="adjustment">adjustment4</property> <property name="digits">2</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">4</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -254,7 +253,6 @@ <property name="left_attach">0</property> <property name="top_attach">5</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> <child> @@ -262,32 +260,29 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelHeight">_Height:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">spinHeight:0.00cm</property> + <property name="mnemonic_widget">spinHeight</property> <property name="ellipsize">end</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> <property name="top_attach">6</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> - <object class="GtkSpinButton" id="spinHeight:0.00cm"> + <object class="GtkSpinButton" id="spinHeight"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="halign">center</property> + <property name="activates_default">True</property> <property name="adjustment">adjustment2</property> <property name="digits">2</property> </object> <packing> <property name="left_attach">1</property> <property name="top_attach">6</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -305,7 +300,6 @@ <property name="left_attach">0</property> <property name="top_attach">7</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> <child> @@ -347,7 +341,6 @@ <property name="left_attach">0</property> <property name="top_attach">8</property> <property name="width">2</property> - <property name="height">1</property> </packing> </child> </object> @@ -372,8 +365,8 @@ <object class="GtkLabel" id="labelHeaderFormat"> <property name="can_focus">False</property> <property name="no_show_all">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelHeaderFormat">Header</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -388,8 +381,8 @@ <object class="GtkLabel" id="labelFooterFormat"> <property name="can_focus">False</property> <property name="no_show_all">True</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="headfootformatpage|labelFooterFormat">Footer</property> + <property name="xalign">0</property> <attributes> <attribute name="weight" value="bold"/> </attributes> @@ -406,8 +399,6 @@ <packing> <property name="left_attach">0</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> <child> @@ -423,7 +414,7 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="svxlo-SvxPageWindow" id="drawingareaPageHF"> + <object class="GtkDrawingArea" id="drawingareaPageHF"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">center</property> @@ -432,7 +423,7 @@ <property name="vexpand">True</property> </object> <packing> - <property name="expand">True</property> + <property name="expand">False</property> <property name="fill">True</property> <property name="position">0</property> </packing> @@ -443,18 +434,16 @@ <packing> <property name="left_attach">1</property> <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> </packing> </child> </object> <object class="GtkSizeGroup" id="sizegroup1"> <property name="ignore_hidden">True</property> <widgets> - <widget name="spinMargLeft:0.00cm"/> - <widget name="spinMargRight:0.00cm"/> - <widget name="spinSpacing:0.00cm"/> - <widget name="spinHeight:0.00cm"/> + <widget name="spinMargLeft"/> + <widget name="spinMargRight"/> + <widget name="spinSpacing"/> + <widget name="spinHeight"/> </widgets> </object> </interface> |