46 #include <preview.hxx>
52 #include <stlpool.hxx>
54 #include <globstr.hrc>
61 #include <svx/dialogs.hrc>
65 #include <com/sun/star/document/XDocumentProperties.hpp>
72 #define MINZOOM_SLIDER 10
73 #define MAXZOOM_SLIDER 400
75 #define SC_USERDATA_SEP ';'
79 #define ShellClass_ScPreviewShell
80 #include <scslots.hxx>
90 SfxVisibilityFlags::Standard|SfxVisibilityFlags::Server|SfxVisibilityFlags::ReadonlyDoc,
91 ToolbarId::Objectbar_Preview);
93 GetStaticInterface()->RegisterPopupMenu(
"preview");
118 eZoom = SvxZoomType::WHOLEPAGE;
126 pHorScroll->EnableRTL(
false );
133 SetPool( &
SC_MOD()->GetPool() );
134 SetWindow( pPreview );
137 SfxBroadcaster* pDrawBC = pDocShell->GetDocument().GetDrawBroadcaster();
141 pHorScroll->Show(
false );
142 pVerScroll->Show(
false );
150 pDocShell( static_cast<
ScDocShell*>(pViewFrame->GetObjectShell()) ),
151 mpFrameWindow(nullptr),
164 catch (
const css::uno::RuntimeException& e)
167 css::uno::Reference<css::lang::XServiceInfo> xServiceInfo(e.Context, css::uno::UNO_QUERY);
168 if (!xServiceInfo || !xServiceInfo->supportsService(
"com.sun.star.frame.StartModule"))
170 SAL_WARN(
"sc.ui",
"Opening file from StartModule straight into print preview");
177 if (
auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) )
189 SdrView* pDrawView = pTabViewShell->GetScDrawView();
204 pBar->ControlListenerForCurrentController(
true);
212 EndListening(*pDrawBC);
233 Size aOutSize( rSize );
236 if ( SvxZoomType::WHOLEPAGE ==
eZoom )
238 else if ( SvxZoomType::PAGEWIDTH ==
eZoom )
261 SfxStyleFamily::Page );
262 OSL_ENSURE(pStyleSheet,
"No style sheet");
263 if (!pStyleSheet)
return false;
311 bHori = nMaxWidthPos >= 0;
313 bVert = nMaxHeightPos >= 0;
316 if ( bVert != bHori && ( bVert || bHori ) )
318 if ( bVert && ( (nMaxWidthPos + aWidthOffSet ) > 0 ) )
320 else if ( (nMaxHeightPos + aHeightOffSet ) > 0 )
335 Size( aWindowPixelSize.
Width(), nBarH ) );
339 Size( nBarW, nBarH ) );
368 else if (aOfs.X() < 0)
374 else if (aOfs.X() > nMaxPos)
377 aOfs.setX( nMaxPos );
401 else if (aOfs.Y() < 0)
424 tools::Long nTotalPages = pPreview->GetTotalPages();
427 bool bIsDivide =
true;
430 nPerPageLength = nMaxRange / nTotalPages;
434 nPageNo = nPos / nPerPageLength;
435 if( nPos % nPerPageLength )
442 bool bHoriz = ( pScroll == pHorScroll );
445 pPreview->SetXOffset( nPos );
448 if( nMaxVertPos > 0 )
449 pPreview->SetYOffset( nPos );
452 Point aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
453 Point aPos = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
460 if ( nTotalPages && nPageNo > 0 && !bIsDivide )
461 pPreview->SetPageNo( nPageNo-1 );
463 pPreview->SetPageNo( nPageNo );
465 aHelpStr =
ScResId( STR_PAGE ) +
466 " " + OUString::number( nPageNo ) +
467 " / " + OUString::number( nTotalPages );
469 else if( nDelta > 0 )
471 bool bAllTested = pPreview->AllTested();
472 if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
473 pPreview->SetPageNo( nPageNo );
475 aHelpStr =
ScResId( STR_PAGE ) +
476 " " + OUString::number( nPageNo+1 ) +
477 " / " + OUString::number( nTotalPages );
481 aRect.
SetTop( aMousePos.Y() );
484 nAlign = QuickHelpFlags::Bottom|QuickHelpFlags::Center;
499 if ( pData && pData->
GetMode() == CommandWheelMode::ZOOM )
510 eZoom = SvxZoomType::PERCENT;
543 if ( ScTpPrintOptionsCreate )
544 return ScTpPrintOptionsCreate(pPage, pController, &rOptions);
565 sal_uInt16 nSlot = rReq.
GetSlot();
571 case SID_STATUS_PAGESTYLE:
580 case SID_PREVIEW_PREVIOUS:
584 if (nTotal && nPage > 0)
589 case SID_PREVIEW_NEXT:
594 if (nTotal && (nPage+1 < nTotal || !bAllTested))
598 case SID_CURSORTOPOFFILE:
599 case SID_PREVIEW_FIRST:
603 if (nTotal && nPage != 0)
607 case SID_CURSORENDOFFILE:
608 case SID_PREVIEW_LAST:
615 if (nTotal && nPage+1 != nTotal)
622 sal_uInt16 nZoom = 100;
623 bool bCancel =
false;
625 eZoom = SvxZoomType::PERCENT;
633 nZoom = rZoomItem.GetValue();
640 aSet.Put( aZoomItem );
643 pDlg->SetLimits( 20, 400 );
644 pDlg->HideButton( ZoomButtonId::OPTIMAL );
649 const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->
650 Get( SID_ATTR_ZOOM );
653 nZoom = rZoomItem.GetValue();
661 case SvxZoomType::OPTIMAL:
662 case SvxZoomType::WHOLEPAGE:
665 case SvxZoomType::PAGEWIDTH:
684 eZoom = SvxZoomType::PERCENT;
693 eZoom = SvxZoomType::PERCENT;
697 case SID_PREVIEW_MARGIN:
705 case SID_ATTR_ZOOMSLIDER:
708 eZoom = SvxZoomType::PERCENT;
709 if( pReqArgs && SfxItemState::SET == pReqArgs->
GetItemState( SID_ATTR_ZOOMSLIDER,
true, &pItem ) )
720 case SID_PREVIEW_SCALINGFACTOR:
727 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
729 if ( pReqArgs && pStyleSheet && SfxItemState::SET == pReqArgs->
GetItemState( SID_PREVIEW_SCALINGFACTOR,
true, &pItem ) )
741 case SID_PRINTPREVIEW:
742 case SID_PREVIEW_CLOSE:
749 case SID_CURSORPAGEUP:
750 case SID_CURSORPAGEDOWN:
756 case SID_CURSORRIGHT:
785 case SID_STATUS_PAGESTYLE:
794 case SID_MAIL_SENDDOC:
795 case SID_VIEW_DATA_SOURCE_BROWSER:
799 case SID_PREVIEW_PREVIOUS:
800 case SID_PREVIEW_FIRST:
801 if (!nTotal || nPage==0)
804 case SID_PREVIEW_NEXT:
805 case SID_PREVIEW_LAST:
807 if (!nTotal || nPage==nTotal-1)
821 aZoom.
SetValueSet( SvxZoomEnableFlags::ALL & ~SvxZoomEnableFlags::OPTIMAL );
825 case SID_ATTR_ZOOMSLIDER:
829 rSet.
Put( aZoomSliderItem );
832 case SID_PREVIEW_SCALINGFACTOR:
841 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
851 rSet.
Put( aZoomSliderItem );
859 case SID_STATUS_DOCPOS:
862 case SID_PRINTPREVIEW:
866 case SID_PREVIEW_MARGIN:
920 if (!rData.isEmpty())
925 eZoom = SvxZoomType::PERCENT;
936 beans::PropertyValue* pSeq = rSeq.getArray();
939 pSeq[0].Value <<=
SC_VIEW + OUString::number(nViewID);
942 pSeq[2].Name =
"PageNumber";
947 pDrawLayer->WriteUserDataSequence(rSeq);
952 for (
const auto& propval : rSeq)
957 if (propval.Value >>= nTemp)
960 else if (propval.Name ==
"PageNumber")
963 if (propval.Value >>= nTemp)
974 Point aCurPos, aPrevPos;
1000 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
1005 aCurPos.AdjustY( -nVLine );
1007 case SID_CURSORDOWN:
1020 if( nPage<nTotal-1 )
1023 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
1028 aCurPos.AdjustY(nVLine );
1030 case SID_CURSORLEFT:
1031 aCurPos.AdjustX( -nHLine );
1033 case SID_CURSORRIGHT:
1034 aCurPos.AdjustX(nHLine );
1036 case SID_CURSORPAGEUP:
1044 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
1046 aCurPos.setY( nVRange );
1050 aCurPos.AdjustY( -nVPage );
1052 case SID_CURSORPAGEDOWN:
1053 if( (std::abs(nVPage+nThumbPos-nRangeMax)<10) ||
nMaxVertPos<0 )
1064 if( nPage<nTotal-1 )
1067 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
1073 aCurPos.AdjustY(nVPage );
1075 case SID_CURSORHOME:
1080 if( nTotal && nPage != 0 )
1083 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST );
1100 if( nTotal && nPage+1 != nTotal )
1103 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST );
1109 aCurPos.setY( nVRange );
1110 aCurPos.setX( nHRange );
1117 if( aCurPos.Y() > (nVRange-nVPage) )
1118 aCurPos.setY( nVRange-nVPage );
1119 if( aCurPos.Y() < 0 )
1121 if( aCurPos.X() > (nHRange-nHPage) )
1122 aCurPos.setX( nHRange-nHPage );
1123 if( aCurPos.X() < 0 )
1128 if( aCurPos.Y() != aPrevPos.Y() )
1135 if( aCurPos.X() != aPrevPos.X() )
1162 OSL_FAIL(
"no accessibility broadcaster?");
If set, cloned formula cells will start to listen to the document.
ScMarkData & GetMarkData()
virtual Point GetPosPixel() const
bool GetPageSize(Size &aPageSize)
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
const ScPreviewLocationData & GetLocationData()
void AddAccessibilityObject(SfxListener &rObject)
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
SystemWindow * GetSystemWindow() const
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
void ExecutePageStyle(const SfxViewShell &rCaller, SfxRequest &rReq, SCTAB nCurTab)
void setWidth(tools::Long nWidth)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
virtual void WriteUserData(OUString &, bool bBrowse=false) override
std::unique_ptr< ContentProperties > pData
void SetZoom(sal_uInt16 nNewZoom)
sal_uInt16 GetOptimalZoom(bool bWidthOnly)
virtual std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
SfxDispatcher * GetDispatcher()
static SvxAbstractDialogFactory * Create()
virtual ~ScPreviewShell() override
void SetPageMargins(bool bVal)
const StyleSettings & GetStyleSettings() const
virtual void SetSizePixel(const Size &rNewSize)
virtual bool HasPrintOptionsPage() const override
VclPtr< ScrollBar > pVerScroll
const ContentProperties & rData
const MapMode & GetMapMode() const
void Done(bool bRemove=false)
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
virtual SfxItemSet & GetItemSet()
const CommandWheelData * GetWheelData() const
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
bool HandleScrollCommand(const CommandEvent &rCmd, ScrollBar *pHScrl, ScrollBar *pVScrl)
virtual void ReadUserDataSequence(const css::uno::Sequence< css::beans::PropertyValue > &) override
void Execute(SfxRequest &rReq)
css::uno::Reference< css::document::XDocumentProperties > getDocProperties() const
virtual void ReadUserData(const OUString &, bool bBrowse=false) override
SfxApplication * SfxGetpApp()
static OutputDevice * GetDefaultDevice()
static void SetFullScreen(const SfxViewShell &rViewShell, bool bSet)
Enters or leaves full screen mode at the passed view shell.
IMPL_LINK(ScPreviewShell, ScrollHandler, ScrollBar *, pScroll, void)
void AddSnappingPoint(sal_Int32 nNew)
vcl::Window & GetWindow() const
VclPtr< vcl::Window > pCorner
void DoScroll(sal_uInt16 nMode)
VclPtr< ScrollBar > pHorScroll
void SetCloseHdl(const Link< SystemWindow &, void > &rLink)
bool ScrollCommand(const CommandEvent &rCEvt)
virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override
VclPtr< NotebookBar > const & GetNotebookBar() const
sal_uInt16 SetPrinter(VclPtr< SfxPrinter > const &pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL)
SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData &rMark)
VclPtr< ScPreview > pPreview
ScDrawLayer * MakeDrawLayer()
bool SetContextBroadcasterEnabled(const bool bIsEnabled)
tools::Long GetPageNo() const
SfxItemPool & GetPool() const
void BroadcastAccessibility(const SfxHint &rHint)
void SetWindow(vcl::Window *pViewPort)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
bool IsSystemWindow() const
SfxBindings & GetBindings()
CommandWheelMode GetMode() const
SC_DLLPUBLIC void SetPageNo(tools::Long nPage)
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Size GetOutputSize() const
void ControlListenerForCurrentController(bool bListen)
void SetXOffset(tools::Long nX)
tools::Long Width() const
SFX_IMPL_NAMED_VIEWFACTORY(ScPreviewShell,"PrintPreview")
IMPL_LINK_NOARG(ScPreviewShell, CloseHdl, SystemWindow &, void)
OUString ScResId(const char *pId)
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
void GetState(SfxItemSet &rSet)
virtual void Activate(bool IsMDIActivate) override
const AllSettings & GetSettings() const
Size GetOutputSizePixel() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
tools::Long GetScrollBarSize() const
TriState nSourceDesignMode
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
#define SFX_VIEW_REGISTRATION(DocClass)
vcl::Window * GetParent() const
const ScPreviewLocationData & GetLocationData()
void GetStatePageStyle(SfxItemSet &rSet, SCTAB nCurTab)
virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override
#define SFX_OBJECTBAR_OBJECT
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Point PixelToLogic(const Point &rDevicePt) const
void SetInGetState(bool bSet)
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
VclPtr< SystemWindow > mpFrameWindow
WinBits const WB_SIZEABLE
void AdjustPosSizePixel(const Point &rPos, const Size &rSize)
ScPreviewShell(SfxViewFrame *pViewFrame, SfxViewShell *pOldSh)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
sal_uInt16 GetZoom() const
SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab)
void DisableItem(sal_uInt16 nWhich)
void RemoveAccessibilityObject(SfxListener &rObject)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetValueSet(SvxZoomEnableFlags nValues)
bool IsContextFlagActive(const OUString &sName)
SvxZoomType GetType() const
static SfxViewShell * Get(const css::uno::Reference< css::frame::XController > &i_rController)
void Construct(vcl::Window *pParent)
static SC_DLLPUBLIC ScAbstractDialogFactory * Create()
void InitStartTable(SCTAB nTab)
tools::Long AdjustWidth(tools::Long n)
static VclPtr< reference_type > Create(Arg &&...arg)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
SfxBroadcaster * GetDrawBroadcaster()
tools::Long Height() const
const INetURLObject & GetURLObject() const
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
void SetYOffset(tools::Long nY)
ScDocument & GetDocument()
const ScDocument & GetDocument() const
vcl::Window * GetWindow() const
tools::Long AdjustHeight(tools::Long n)
virtual void Activate(bool bMDI) override
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
bool HasAccessibilityObjects() const
void setHeight(tools::Long nHeight)
bool GetPageMargins() const
tools::Long GetDelta() const
#define SAL_WARN(area, stream)
void FillFieldData(ScHeaderFieldData &rData)
tools::Long GetTotalPages()
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual SfxPrinter * GetPrinter(bool bCreate=false) override
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(174)
void BroadcastContextForActivation(const bool bIsActivated)
void UpdateNeededScrollBars(bool bFromZoom)
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, SfxPrinterChangeFlags nDiffFlags=SFX_PRINTER_ALL) override
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
void SetContextName(const OUString &rsContextName)
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue)
const Point & GetOffset() const
virtual VclPtr< AbstractSvxZoomDialog > CreateSvxZoomDialog(weld::Window *pParent, const SfxItemSet &rCoreSet)=0
std::unique_ptr< SfxBroadcaster > pAccessibilityBroadcaster
virtual void WriteUserDataSequence(css::uno::Sequence< css::beans::PropertyValue > &) override
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
SfxMedium * GetMedium() const