diff options
Diffstat (limited to 'sw/source/uibase/frmdlg/colex.cxx')
-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: */ |