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.lima@gmail.com>
This commit is contained in:
Heiko Tietze
2023-02-07 13:53:45 +00:00
committed by Heiko Tietze
parent ddfb800e60
commit 0b9aef0aaa
3 changed files with 104 additions and 79 deletions
+4
View File
@@ -390,6 +390,10 @@ interface TextPrintPreview
ExecMethod = Execute ;
StateMethod = GetState ;
]
SID_ATTR_VIEWLAYOUT
[
StateMethod = GetState ;
]
FN_CLOSE_PAGEPREVIEW
[
ExecMethod = Execute ;
+6
View File
@@ -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;
+94 -79
View File
@@ -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;
if (mpImpl->mnState < 4)
{
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 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;
const tools::Long nXOffset = (aRect.GetWidth() - nImageWidthSum) / 2;
const tools::Long nYOffset = (aControlRect.GetHeight() - mpImpl->maImageSingleColumn.GetSizePixel().Height()) / 2;
aRect.AdjustLeft( nXOffset );
aRect.AdjustTop( nYOffset );
aRect.AdjustLeft( nXOffset );
aRect.AdjustTop( nYOffset );
// draw single column image:
pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn );
// draw single column image:
pDev->DrawImage( aRect.TopLeft(), bSingleColumn ? mpImpl->maImageSingleColumn_Active : mpImpl->maImageSingleColumn );
// draw automatic image:
aRect.AdjustLeft(mpImpl->maImageSingleColumn.GetSizePixel().Width() );
pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic );
// draw automatic image:
aRect.AdjustLeft(mpImpl->maImageSingleColumn.GetSizePixel().Width() );
pDev->DrawImage( aRect.TopLeft(), bAutomatic ? mpImpl->maImageAutomatic_Active : mpImpl->maImageAutomatic );
// draw bookmode image:
aRect.AdjustLeft(mpImpl->maImageAutomatic.GetSizePixel().Width() );
pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode );
// draw bookmode image:
aRect.AdjustLeft(mpImpl->maImageAutomatic.GetSizePixel().Width() );
pDev->DrawImage( aRect.TopLeft(), bBookMode ? mpImpl->maImageBookMode_Active : mpImpl->maImageBookMode );
}
else
{
pDev->DrawRect( aControlRect );
}
}
bool SwViewLayoutControl::MouseButtonDown( const MouseEvent & rEvt )
{
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 )
if (mpImpl->mnState < 4)
{
mpImpl->mnState = 0; // single
nColumns = 1;
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;
}
// commit state change
SvxViewLayoutItem aViewLayout( nColumns, bBookMode );
css::uno::Any a;
aViewLayout.QueryValue( a );
css::uno::Sequence< css::beans::PropertyValue > aArgs{ comphelper::makePropertyValue("ViewLayout",
a) };
execute( aArgs );
}
else if ( nXDiff < nXOffset + nImageWidthSingle + nImageWidthAuto )
{
mpImpl->mnState = 1; // auto
nColumns = 0;
}
else
{
mpImpl->mnState = 2; // book
nColumns = 2;
bBookMode = true;
}
// commit state change
SvxViewLayoutItem aViewLayout( nColumns, bBookMode );
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 )
if (mpImpl->mnState < 4)
{
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));
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;
}