diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-22 16:41:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-07-26 09:41:46 +0200 |
commit | b032d746a48b8887ccc2330b2fdbf63d701a213f (patch) | |
tree | b7d2b80a2a614711069f4d814845346ff20df12b /sw/source/uibase/frmdlg | |
parent | e953ce16d24cff34b97940a6063704cd487fec42 (diff) |
weld SwTextGridPage
Change-Id: I4f8e5f643126bea5deef7636b6d20f8080cb6662
Reviewed-on: https://gerrit.libreoffice.org/56309
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/uibase/frmdlg')
-rw-r--r-- | sw/source/uibase/frmdlg/colex.cxx | 173 |
1 files changed, 157 insertions, 16 deletions
diff --git a/sw/source/uibase/frmdlg/colex.cxx b/sw/source/uibase/frmdlg/colex.cxx index 493d96cc3090..02957501f4b8 100644 --- a/sw/source/uibase/frmdlg/colex.cxx +++ b/sw/source/uibase/frmdlg/colex.cxx @@ -194,6 +194,159 @@ void SwPageExample::UpdateExample( const SfxItemSet& rSet ) Invalidate(); } +void PageExample::UpdateExample( const SfxItemSet& rSet ) +{ + if (SfxItemState::DEFAULT <= rSet.GetItemState(RES_FRAMEDIR)) + { + const SvxFrameDirectionItem& rDirItem = rSet.Get(RES_FRAMEDIR); + m_bVertical = rDirItem.GetValue() == SvxFrameDirection::Vertical_RL_TB|| + rDirItem.GetValue() == SvxFrameDirection::Vertical_LR_TB; + } + + SfxItemPool* pPool = rSet.GetPool(); + sal_uInt16 nWhich = pPool->GetWhich( SID_ATTR_PAGE ); + if ( rSet.GetItemState( nWhich, false ) == SfxItemState::SET ) + { + // alignment + const SvxPageItem* pPage = static_cast<const SvxPageItem*>(&rSet.Get( nWhich )); + + if ( pPage ) + SetUsage( pPage->GetPageUsage() ); + } + + nWhich = pPool->GetWhich( SID_ATTR_PAGE_SIZE ); + + if ( rSet.GetItemState( nWhich, false ) == SfxItemState::SET ) + { + // orientation and size from PageItem + const SvxSizeItem& rSize = static_cast<const SvxSizeItem&>(rSet.Get( nWhich )); + SetSize( rSize.GetSize() ); + } + nWhich = RES_LR_SPACE; + if ( rSet.GetItemState( nWhich, false ) == SfxItemState::SET ) + { + // set left and right border + const SvxLRSpaceItem& rLRSpace = static_cast<const SvxLRSpaceItem&>(rSet.Get( nWhich )); + + SetLeft( rLRSpace.GetLeft() ); + SetRight( rLRSpace.GetRight() ); + } + else + { + SetLeft( 0 ); + SetRight( 0 ); + } + + nWhich = RES_UL_SPACE; + + if ( rSet.GetItemState( nWhich, false ) == SfxItemState::SET ) + { + // set upper and lower border + const SvxULSpaceItem& rULSpace = static_cast<const SvxULSpaceItem&>(rSet.Get( nWhich )); + + SetTop( rULSpace.GetUpper() ); + SetBottom( rULSpace.GetLower() ); + } + else + { + SetTop( 0 ); + SetBottom( 0 ); + } + + // evaluate header-attributes + const SfxPoolItem* pItem; + if( SfxItemState::SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_HEADERSET), + false, &pItem ) ) + { + const SfxItemSet& rHeaderSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); + const SfxBoolItem& rHeaderOn = + static_cast<const SfxBoolItem&>(rHeaderSet.Get( pPool->GetWhich( SID_ATTR_PAGE_ON ) ) ); + + if ( rHeaderOn.GetValue() ) + { + const SvxSizeItem& rSize = + static_cast<const SvxSizeItem&>(rHeaderSet.Get(pPool->GetWhich(SID_ATTR_PAGE_SIZE))); + + const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(rHeaderSet.Get( + pPool->GetWhich(SID_ATTR_ULSPACE))); + const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(rHeaderSet.Get( + pPool->GetWhich(SID_ATTR_LRSPACE))); + + SetHdHeight( rSize.GetSize().Height() - rUL.GetLower()); + SetHdDist( rUL.GetLower() ); + SetHdLeft( rLR.GetLeft() ); + SetHdRight( rLR.GetRight() ); + SetHeader( true ); + + if(SfxItemState::SET == rHeaderSet.GetItemState(RES_BACKGROUND)) + { + // create FillAttributes from SvxBrushItem //SetHdColor(rItem.GetColor()); + const SvxBrushItem& rItem = rHeaderSet.Get(RES_BACKGROUND); + SfxItemSet aTempSet(*rHeaderSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); + + setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); + setHeaderFillAttributes( + std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>( + aTempSet)); + } + } + else + SetHeader( false ); + } + + if( SfxItemState::SET == rSet.GetItemState( pPool->GetWhich( SID_ATTR_PAGE_FOOTERSET), + false, &pItem ) ) + { + const SfxItemSet& rFooterSet = static_cast<const SvxSetItem*>(pItem)->GetItemSet(); + const SfxBoolItem& rFooterOn = rFooterSet.Get( SID_ATTR_PAGE_ON ); + + if ( rFooterOn.GetValue() ) + { + const SvxSizeItem& rSize = + static_cast<const SvxSizeItem&>(rFooterSet.Get( pPool->GetWhich( SID_ATTR_PAGE_SIZE ) )); + + const SvxULSpaceItem& rUL = static_cast<const SvxULSpaceItem&>(rFooterSet.Get( + pPool->GetWhich( SID_ATTR_ULSPACE ) )); + const SvxLRSpaceItem& rLR = static_cast<const SvxLRSpaceItem&>(rFooterSet.Get( + pPool->GetWhich( SID_ATTR_LRSPACE ) )); + + SetFtHeight( rSize.GetSize().Height() - rUL.GetUpper()); + SetFtDist( rUL.GetUpper() ); + SetFtLeft( rLR.GetLeft() ); + SetFtRight( rLR.GetRight() ); + SetFooter( true ); + + if( rFooterSet.GetItemState( RES_BACKGROUND ) == SfxItemState::SET ) + { + // create FillAttributes from SvxBrushItem //SetFtColor(rItem.GetColor()); + const SvxBrushItem& rItem = rFooterSet.Get(RES_BACKGROUND); + SfxItemSet aTempSet(*rFooterSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); + + setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); + setFooterFillAttributes( + std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>( + aTempSet)); + } + } + else + SetFooter( false ); + } + + if(SfxItemState::SET == rSet.GetItemState(RES_BACKGROUND, false, &pItem)) + { + // create FillAttributes from SvxBrushItem + const SvxBrushItem& rItem = static_cast< const SvxBrushItem& >(*pItem); + SfxItemSet aTempSet(*rSet.GetPool(), svl::Items<XATTR_FILL_FIRST, XATTR_FILL_LAST>{}); + + setSvxBrushItemAsFillAttributesToTargetSet(rItem, aTempSet); + setPageFillAttributes( + std::make_shared<drawinglayer::attribute::SdrAllFillAttributesHelper>( + aTempSet)); + } + + Invalidate(); +} + void SwColExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOrg, const bool bSecond, const bool bEnabled) { @@ -496,25 +649,15 @@ Size SwColumnOnlyExample::GetOptimalSize() const return LogicToPixel(Size(75, 46), MapMode(MapUnit::MapAppFont)); } -SwPageGridExample::SwPageGridExample(vcl::Window* pPar) - : SwPageExample(pPar) -{} - -SwPageGridExample::~SwPageGridExample() +SwPageGridExample::SwPageGridExample() + : pGridItem(nullptr) { - disposeOnce(); -} - -void SwPageGridExample::dispose() -{ - pGridItem.reset(); - SwPageExample::dispose(); } void SwPageGridExample::DrawPage(vcl::RenderContext& rRenderContext, const Point& rOrg, const bool bSecond, const bool bEnabled) { - SwPageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled); + PageExample::DrawPage(rRenderContext, rOrg, bSecond, bEnabled); if (!pGridItem || !pGridItem->GetGridType()) return; @@ -617,9 +760,7 @@ void SwPageGridExample::UpdateExample( const SfxItemSet& rSet ) //get the grid information if(SfxItemState::DEFAULT <= rSet.GetItemState(RES_TEXTGRID)) pGridItem.reset(static_cast<SwTextGridItem*>(rSet.Get(RES_TEXTGRID).Clone())); - SwPageExample::UpdateExample(rSet); + PageExample::UpdateExample(rSet); } -VCL_BUILDER_FACTORY(SwPageGridExample) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |