sw/sdi/viewsh.sdi | 4 sw/source/uibase/uiview/pview.cxx | 6 + sw/source/uibase/utlui/viewlayoutctrl.cxx | 169 ++++++++++++++++-------------- 3 files changed, 102 insertions(+), 77 deletions(-)
New commits: commit 0b9aef0aaa7c17cc7da722002e27996a01ffc7fa Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Mon Jan 23 13:50:55 2023 +0100 Commit: Heiko Tietze <heiko.tie...@documentfoundation.org> CommitDate: Tue Feb 7 13:53:45 2023 +0000 Resolves tdf#148441 - Hide viewlayout in statusbar in preview mode Change-Id: I255ad3b952d7b424e9ff0475798bbe0cfc57ef9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146004 Tested-by: Jenkins Reviewed-by: Rafael Lima <rafael.palma.l...@gmail.com> diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index e4f3c0a362e0..86dd74a62c91 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -390,6 +390,10 @@ interface TextPrintPreview ExecMethod = Execute ; StateMethod = GetState ; ] + SID_ATTR_VIEWLAYOUT + [ + StateMethod = GetState ; + ] FN_CLOSE_PAGEPREVIEW [ ExecMethod = Execute ; diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index f6db5bb9d928..84c1cf06680c 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -36,6 +36,7 @@ #include <sfx2/dispatch.hxx> #include <editeng/paperinf.hxx> #include <svx/svdview.hxx> +#include <svx/viewlayoutitem.hxx> #include <svx/zoomslideritem.hxx> #include <tools/svborder.hxx> #include <osl/diagnose.h> @@ -1015,6 +1016,11 @@ void SwPagePreview::GetState( SfxItemSet& rSet ) } } break; + case SID_ATTR_VIEWLAYOUT: + { + rSet.DisableItem( SID_ATTR_VIEWLAYOUT ); + } + break; case FN_SHOW_MULTIPLE_PAGES: // should never be disabled break; diff --git a/sw/source/uibase/utlui/viewlayoutctrl.cxx b/sw/source/uibase/utlui/viewlayoutctrl.cxx index 8e2ef79c5a0e..b0631559ac68 100644 --- a/sw/source/uibase/utlui/viewlayoutctrl.cxx +++ b/sw/source/uibase/utlui/viewlayoutctrl.cxx @@ -34,7 +34,7 @@ SFX_IMPL_STATUSBAR_CONTROL( SwViewLayoutControl, SvxViewLayoutItem ); struct SwViewLayoutControl::SwViewLayoutControl_Impl { - sal_uInt16 mnState; // 0 = auto, 1= single, 2 = book, 3 = none + sal_uInt16 mnState; // 0 = auto, 1= single, 2 = book, 3 = none, 4 = off Image maImageSingleColumn; Image maImageSingleColumn_Active; Image maImageAutomatic; @@ -64,7 +64,10 @@ SwViewLayoutControl::~SwViewLayoutControl() void SwViewLayoutControl::StateChangedAtStatusBarControl( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState ) { if ( SfxItemState::DEFAULT != eState || pState->IsVoidItem() ) + { GetStatusBar().SetItemText( GetId(), OUString() ); + mpImpl->mnState = 4; //tdf#148441 switch off is disabled + } else { assert( dynamic_cast< const SvxViewLayoutItem *>( pState ) && "invalid item type" ); @@ -94,102 +97,114 @@ void SwViewLayoutControl::Paint( const UserDrawEvent& rUsrEvt ) const tools::Rectangle aControlRect = getControlRect(); - const bool bSingleColumn = 0 == mpImpl->mnState; - const bool bAutomatic = 1 == mpImpl->mnState; - const bool bBookMode = 2 == mpImpl->mnState; - - const tools::Long nImageWidthSum = mpImpl->maImageSingleColumn.GetSizePixel().Width() + - mpImpl->maImageAutomatic.GetSizePixel().Width() + - mpImpl->maImageBookMode.GetSizePixel().Width(); - - const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum) / 2; - const tools::Long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height()) / 2; + if (mpImpl->mnState < 4) + { + const bool bSingleColumn = 0 == mpImpl->mnState; + const bool bAutomatic = 1 == mpImpl->mnState; + const bool bBookMode = 2 == mpImpl->mnState; - aRect.AdjustLeft( nXOffset ); - aRect.AdjustTop( nYOffset ); + const tools::Long nImageWidthSum = mpImpl->maImageSingleColumn.GetSizePixel().Width() + + mpImpl->maImageAutomatic.GetSizePixel().Width() + + mpImpl->maImageBookMode.GetSizePixel().Width(); - // draw single column image: - pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn ); + const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum) / 2; + const tools::Long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height()) / 2; - // draw automatic image: - aRect.AdjustLeft(mpImpl->maImageSingleColumn.GetSizePixel().Width() ); - pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic ); + aRect.AdjustLeft( nXOffset ); + aRect.AdjustTop( nYOffset ); - // draw bookmode image: - aRect.AdjustLeft(mpImpl->maImageAutomatic.GetSizePixel().Width() ); - pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode ); -} + // draw single column image: + pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn ); -bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt ) -{ - const tools::Rectangle aRect = getControlRect(); - const Point aPoint = rEvt.GetPosPixel(); - const tools::Long nXDiff = aPoint.X() - aRect.Left(); + // draw automatic image: + aRect.AdjustLeft(mpImpl->maImageSingleColumn.GetSizePixel().Width() ); + pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic ); - sal_uInt16 nColumns = 1; - bool bBookMode = false; - - const tools::Long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); - const tools::Long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); - const tools::Long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); - const tools::Long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; - - const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; - - if ( nXDiff < nXOffset + nImageWidthSingle ) - { - mpImpl->mnState = 0; // single - nColumns = 1; - } - else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) - { - mpImpl->mnState = 1; // auto - nColumns = 0; + // draw bookmode image: + aRect.AdjustLeft(mpImpl->maImageAutomatic.GetSizePixel().Width() ); + pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode ); } else { - mpImpl->mnState = 2; // book - nColumns = 2; - bBookMode = true; + pDev->DrawRect( aControlRect ); } +} - // commit state change - SvxViewLayoutItem aViewLayout( nColumns, bBookMode ); +bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt ) +{ + if (mpImpl->mnState < 4) + { + const tools::Rectangle aRect = getControlRect(); + const Point aPoint = rEvt.GetPosPixel(); + const tools::Long nXDiff = aPoint.X() - aRect.Left(); + + sal_uInt16 nColumns = 1; + bool bBookMode = false; + + const tools::Long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); + const tools::Long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); + const tools::Long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); + const tools::Long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; + + const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + + if ( nXDiff < nXOffset + nImageWidthSingle ) + { + mpImpl->mnState = 0; // single + nColumns = 1; + } + else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) + { + mpImpl->mnState = 1; // auto + nColumns = 0; + } + else + { + mpImpl->mnState = 2; // book + nColumns = 2; + bBookMode = true; + } - css::uno::Any a; - aViewLayout.QueryValue( a ); + // commit state change + SvxViewLayoutItem aViewLayout( nColumns, bBookMode ); - css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue("ViewLayout", - a) }; - execute( aArgs ); + css::uno::Any a; + aViewLayout.QueryValue( a ); + css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue("ViewLayout", + a) }; + execute( aArgs ); + } return true; } bool SwViewLayoutControl::MouseMove( const MouseEvent & rEvt ) { - const tools::Rectangle aRect = getControlRect(); - const Point aPoint = rEvt.GetPosPixel(); - const tools::Long nXDiff = aPoint.X() - aRect.Left(); - - const tools::Long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); - const tools::Long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); - const tools::Long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); - const tools::Long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; - - const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; - - if ( nXDiff < nXOffset + nImageWidthSingle ) - { - GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_ONE)); - } - else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) + if (mpImpl->mnState < 4) { - GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_MULTI)); - } - else - { - GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_BOOK)); + const tools::Rectangle aRect = getControlRect(); + const Point aPoint = rEvt.GetPosPixel(); + const tools::Long nXDiff = aPoint.X() - aRect.Left(); + + const tools::Long nImageWidthSingle = mpImpl->maImageSingleColumn.GetSizePixel().Width(); + const tools::Long nImageWidthAuto = mpImpl->maImageAutomatic.GetSizePixel().Width(); + const tools::Long nImageWidthBook = mpImpl->maImageBookMode.GetSizePixel().Width(); + const tools::Long nImageWidthSum = nImageWidthSingle + nImageWidthAuto + nImageWidthBook; + + const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum)/2; + + if ( nXDiff < nXOffset + nImageWidthSingle ) + { + GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_ONE)); + } + else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto ) + { + GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_MULTI)); + } + else + { + GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_VIEWLAYOUT_BOOK)); + } } return true; }