63#include <svx/dialogs.hrc>
67#include <com/sun/star/document/XDocumentProperties.hpp>
74#define MINZOOM_SLIDER 10
75#define MAXZOOM_SLIDER 400
77#define SC_USERDATA_SEP ';'
81#define ShellClass_ScPreviewShell
92 SfxVisibilityFlags::Standard|SfxVisibilityFlags::Server|SfxVisibilityFlags::ReadonlyDoc,
93 ToolbarId::Objectbar_Preview);
95 GetStaticInterface()->RegisterPopupMenu(
"preview");
120 eZoom = SvxZoomType::WHOLEPAGE;
149 pDocShell( static_cast<
ScDocShell*>(rViewFrame.GetObjectShell()) ),
150 mpFrameWindow(nullptr),
159 if (
auto pTabViewShell =
dynamic_cast<ScTabViewShell*
>( pOldSh) )
165 const ScViewData& rData = pTabViewShell->GetViewData();
171 SdrView* pDrawView = pTabViewShell->GetScDrawView();
191 EndListening(*pDrawBC);
211 Size aOutSize( rSize );
212 pPreview->SetPosSizePixel( rPos, aOutSize );
214 if ( SvxZoomType::WHOLEPAGE ==
eZoom )
216 else if ( SvxZoomType::PAGEWIDTH ==
eZoom )
239 SfxStyleFamily::Page );
240 OSL_ENSURE(pStyleSheet,
"No style sheet");
241 if (!pStyleSheet)
return false;
267 Size aWindowSize =
pPreview->GetOutDev()->GetOutputSize();
289 bHori = nMaxWidthPos >= 0;
291 bVert = nMaxHeightPos >= 0;
294 if ( bVert != bHori && ( bVert || bHori ) )
296 if ( bVert && ( (nMaxWidthPos + aWidthOffSet ) > 0 ) )
298 else if ( (nMaxHeightPos + aHeightOffSet ) > 0 )
311 pPreview->SetSizePixel( aWindowPixelSize );
313 Size( aWindowPixelSize.
Width(), nBarH ) );
327 Size aWindowSize =
pPreview->GetOutDev()->GetOutputSize();
342 pPreview->SetXOffset( nMaxPos / 2 );
344 else if (aOfs.
X() < 0)
350 else if (aOfs.
X() > nMaxPos)
353 aOfs.
setX( nMaxPos );
378 else if (aOfs.
Y() < 0)
399 ScrollHandler(pHorScroll);
404 ScrollHandler(pVerScroll);
414 bool bIsDivide =
true;
417 nPerPageLength = nMaxRange / nTotalPages;
421 nPageNo =
nPos / nPerPageLength;
422 if(
nPos % nPerPageLength )
442 Point aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
443 Point aPos = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
450 if ( nTotalPages && nPageNo > 0 && !bIsDivide )
455 aHelpStr =
ScResId( STR_PAGE ) +
456 " " + OUString::number( nPageNo ) +
457 " / " + OUString::number( nTotalPages );
459 else if( nDelta > 0 )
461 bool bAllTested =
pPreview->AllTested();
462 if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
465 aHelpStr =
ScResId( STR_PAGE ) +
466 " " + OUString::number( nPageNo+1 ) +
467 " / " + OUString::number( nTotalPages );
474 nAlign = QuickHelpFlags::Bottom|QuickHelpFlags::Center;
489 if (
pData &&
pData->GetMode() == CommandWheelMode::ZOOM )
491 sal_uInt16 nOld =
pPreview->GetZoom();
493 if (
pData->GetDelta() < 0 )
500 eZoom = SvxZoomType::PERCENT;
533 if ( ScTpPrintOptionsCreate )
534 return ScTpPrintOptionsCreate(pPage, pController, &rOptions);
557 sal_uInt16 nSlot = rReq.
GetSlot();
563 case SID_STATUS_PAGESTYLE:
572 case SID_PREVIEW_PREVIOUS:
576 if (nTotal && nPage > 0)
581 case SID_PREVIEW_NEXT:
583 bool bAllTested =
pPreview->AllTested();
586 if (nTotal && (nPage+1 < nTotal || !bAllTested))
590 case SID_CURSORTOPOFFILE:
591 case SID_PREVIEW_FIRST:
595 if (nTotal && nPage != 0)
599 case SID_CURSORENDOFFILE:
600 case SID_PREVIEW_LAST:
607 if (nTotal && nPage+1 != nTotal)
614 sal_uInt16 nZoom = 100;
615 bool bCancel =
false;
617 eZoom = SvxZoomType::PERCENT;
625 nZoom = rZoomItem.GetValue();
632 aSet.
Put( aZoomItem );
635 pDlg->SetLimits( 20, 400 );
636 pDlg->HideButton( ZoomButtonId::OPTIMAL );
641 const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->
642 Get( SID_ATTR_ZOOM );
645 nZoom = rZoomItem.GetValue();
653 case SvxZoomType::OPTIMAL:
654 case SvxZoomType::WHOLEPAGE:
655 nZoom =
pPreview->GetOptimalZoom(
false);
657 case SvxZoomType::PAGEWIDTH:
658 nZoom =
pPreview->GetOptimalZoom(
true);
673 sal_uInt16 nNew =
pPreview->GetZoom() + 20 ;
676 eZoom = SvxZoomType::PERCENT;
682 sal_uInt16 nNew =
pPreview->GetZoom() - 1;
685 eZoom = SvxZoomType::PERCENT;
689 case SID_PREVIEW_MARGIN:
691 bool bMargin =
pPreview->GetPageMargins();
692 pPreview->SetPageMargins( !bMargin );
697 case SID_ATTR_ZOOMSLIDER:
700 eZoom = SvxZoomType::PERCENT;
701 if( pReqArgs && (pItem = pReqArgs->
GetItemIfSet( SID_ATTR_ZOOMSLIDER )) )
703 const sal_uInt16 nCurrentZoom = pItem->GetValue();
712 case SID_PREVIEW_SCALINGFACTOR:
719 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
721 if ( pReqArgs && pStyleSheet && (pItem = pReqArgs->
GetItemIfSet( SID_PREVIEW_SCALINGFACTOR )) )
723 const sal_uInt16 nCurrentZoom = pItem->GetValue();
733 case SID_PRINTPREVIEW:
734 case SID_PREVIEW_CLOSE:
741 case SID_CURSORPAGEUP:
742 case SID_CURSORPAGEDOWN:
748 case SID_CURSORRIGHT:
768 sal_uInt16 nZoom =
pPreview->GetZoom();
769 bool bAllTested =
pPreview->AllTested();
777 case SID_STATUS_PAGESTYLE:
786 case SID_MAIL_SENDDOC:
787 case SID_VIEW_DATA_SOURCE_BROWSER:
791 case SID_PREVIEW_PREVIOUS:
792 case SID_PREVIEW_FIRST:
793 if (!nTotal || nPage==0)
796 case SID_PREVIEW_NEXT:
797 case SID_PREVIEW_LAST:
799 if (!nTotal || nPage==nTotal-1)
813 aZoom.
SetValueSet( SvxZoomEnableFlags::ALL & ~SvxZoomEnableFlags::OPTIMAL );
817 case SID_ATTR_ZOOMSLIDER:
824 case SID_PREVIEW_SCALINGFACTOR:
833 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
851 case SID_STATUS_DOCPOS:
854 case SID_PRINTPREVIEW:
858 case SID_PREVIEW_MARGIN:
891 bool bAllTested =
pPreview->AllTested();
905 rData = OUString::number(
pPreview->GetZoom())
907 + OUString::number(
pPreview->GetPageNo());
912 if (!rData.isEmpty())
917 eZoom = SvxZoomType::PERCENT;
928 beans::PropertyValue* pSeq = rSeq.getArray();
931 pSeq[0].Value <<=
SC_VIEW + OUString::number(nViewID);
933 pSeq[1].Value <<= sal_Int32 (
pPreview->GetZoom());
934 pSeq[2].Name =
"PageNumber";
935 pSeq[2].Value <<=
pPreview->GetPageNo();
939 pDrawLayer->WriteUserDataSequence(rSeq);
944 for (
const auto& propval : rSeq)
949 if (propval.Value >>= nTemp)
950 pPreview->SetZoom(sal_uInt16(nTemp));
952 else if (propval.Name ==
"PageNumber")
955 if (propval.Value >>= nTemp)
966 Point aCurPos, aPrevPos;
992 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_PREVIOUS);
1006 if ( nPage+1 == nTotal && !
pPreview->AllTested() )
1009 nTotal =
pPreview->GetTotalPages();
1012 if( nPage<nTotal-1 )
1015 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_NEXT);
1022 case SID_CURSORLEFT:
1025 case SID_CURSORRIGHT:
1028 case SID_CURSORPAGEUP:
1036 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_PREVIOUS);
1038 aCurPos.
setY( nVRange );
1044 case SID_CURSORPAGEDOWN:
1045 if( (std::abs(nVPage+nThumbPos-nRangeMax)<10) ||
nMaxVertPos<0 )
1051 if ( nPage+1 == nTotal && !
pPreview->AllTested() )
1054 nTotal =
pPreview->GetTotalPages();
1056 if( nPage<nTotal-1 )
1059 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_NEXT);
1067 case SID_CURSORHOME:
1072 if( nTotal && nPage != 0 )
1075 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_FIRST);
1092 if( nTotal && nPage+1 != nTotal )
1095 SfxRequest aSfxRequest(rSfxViewFrame, SID_PREVIEW_LAST);
1101 aCurPos.
setY( nVRange );
1102 aCurPos.
setX( nHRange );
1109 if( aCurPos.
Y() > (nVRange-nVPage) )
1110 aCurPos.
setY( nVRange-nVPage );
1111 if( aCurPos.
Y() < 0 )
1113 if( aCurPos.
X() > (nHRange-nHPage) )
1114 aCurPos.
setX( nHRange-nHPage );
1115 if( aCurPos.
X() < 0 )
1120 if( aCurPos.
Y() != aPrevPos.
Y() )
1128 if( aCurPos.
X() != aPrevPos.
X() )
1156 OSL_FAIL(
"no accessibility broadcaster?");
1173 return pPreview->GetLocationData();
constexpr OUStringLiteral SC_ZOOMVALUE
constexpr OUStringLiteral SC_VIEWID
SfxApplication * SfxGetpApp()
const StyleSettings & GetStyleSettings() const
static OutputDevice * GetDefaultDevice()
const CommandWheelData * GetWheelData() const
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
sal_uInt16 SetPrinter(VclPtr< SfxPrinter > const &pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL)
const ScDocument & GetDocument() const
ScDrawLayer * MakeDrawLayer()
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
void ExecutePageStyle(const SfxViewShell &rCaller, SfxRequest &rReq, SCTAB nCurTab)
void GetStatePageStyle(SfxItemSet &rSet, SCTAB nCurTab)
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
SfxBroadcaster * GetDrawBroadcaster()
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
virtual bool HasPrintOptionsPage() const override
const ScPreviewLocationData & GetLocationData()
VclPtr< ScrollAdaptor > pVerScroll
void AddAccessibilityObject(SfxListener &rObject)
void GetState(SfxItemSet &rSet)
virtual void WriteUserData(OUString &, bool bBrowse=false) override
void ScrollHandler(ScrollAdaptor *pScrollBar)
ScDocument & GetDocument()
tools::Long nPrevVThumbPos
TriState nSourceDesignMode
VclPtr< ScrollAdaptor > pHorScroll
VclPtr< ScPreview > pPreview
bool HasAccessibilityObjects() const
std::unique_ptr< SfxBroadcaster > pAccessibilityBroadcaster
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
virtual ~ScPreviewShell() override
virtual SfxPrinter * GetPrinter(bool bCreate=false) override
void FillFieldData(ScHeaderFieldData &rData)
void Construct(vcl::Window *pParent)
bool GetPageSize(Size &aPageSize)
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
VclPtr< SystemWindow > mpFrameWindow
virtual void ReadUserData(const OUString &, bool bBrowse=false) override
virtual void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &) override
void UpdateNeededScrollBars(bool bFromZoom)
virtual void Activate(bool bMDI) override
void DoScroll(sal_uInt16 nMode)
ScPreviewShell(SfxViewFrame &rViewFrame, SfxViewShell *pOldSh)
void Execute(SfxRequest &rReq)
void BroadcastAccessibility(const SfxHint &rHint)
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
bool ScrollCommand(const CommandEvent &rCEvt)
void AdjustPosSizePixel(const Point &rPos, const Size &rSize)
void RemoveAccessibilityObject(SfxListener &rObject)
virtual std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
void InitStartTable(SCTAB nTab)
virtual void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &) override
tools::Long nPrevHThumbPos
ScMarkData & GetMarkData()
static void SetFullScreen(const SfxViewShell &rViewShell, bool bSet)
Enters or leaves full screen mode at the passed view shell.
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
bool IsDesignMode() const
void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
const INetURLObject & GetURLObject() const
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
SfxMedium * GetMedium() const
OUString GetTitle(sal_uInt16 nMaxLen=0) const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
void Done(bool bRemove=false)
SfxItemPool & GetPool() const
virtual void Activate(bool bMDI)
void SetContextName(const OUString &rsContextName)
void SetPool(SfxItemPool *pNewPool)
void SetName(const OUString &rName)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
vcl::Window & GetWindow() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
virtual void Activate(bool IsMDIActivate) override
SfxViewFrame & GetViewFrame() const
static SAL_WARN_UNUSED_RESULT SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
void SetWindow(vcl::Window *pViewPort)
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
static SvxAbstractDialogFactory * Create()
void SetValueSet(SvxZoomEnableFlags nValues)
SvxZoomType GetType() const
void AddSnappingPoint(sal_Int32 nNew)
static VclPtr< reference_type > Create(Arg &&... arg)
static const OUString & GetContextName(const Context eContext)
vcl::Window * GetParent() const
const AllSettings & GetSettings() const
bool IsSystemWindow() const
@ StartListening
If set, cloned formula cells will start to listen to the document.
#define LINK(Instance, Class, Member)
std::unique_ptr< sal_Int32[]> pData
bool IsContextFlagActive(const OUString &sName)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
#define SFX_OBJECTBAR_OBJECT
IMPL_LINK_NOARG(ScPreviewShell, HorzScrollHandler, weld::Scrollbar &, void)
SFX_IMPL_NAMED_VIEWFACTORY(ScPreviewShell, "PrintPreview")
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
#define SFX_VIEW_REGISTRATION(DocClass)