48 #include <preview.hxx>
54 #include <stlpool.hxx>
56 #include <globstr.hrc>
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
82 #include <scslots.hxx>
92 SfxVisibilityFlags::Standard|SfxVisibilityFlags::Server|SfxVisibilityFlags::ReadonlyDoc,
93 ToolbarId::Objectbar_Preview);
95 GetStaticInterface()->RegisterPopupMenu(
"preview");
120 eZoom = SvxZoomType::WHOLEPAGE;
128 pHorScroll->EnableRTL(
false );
135 SetPool( &
SC_MOD()->GetPool() );
136 SetWindow( pPreview );
139 SfxBroadcaster* pDrawBC = pDocShell->GetDocument().GetDrawBroadcaster();
143 pHorScroll->Show(
false );
144 pVerScroll->Show(
false );
152 pDocShell( static_cast<
ScDocShell*>(pViewFrame->GetObjectShell()) ),
153 mpFrameWindow(nullptr),
166 catch (
const css::uno::RuntimeException& e)
169 css::uno::Reference<css::lang::XServiceInfo> xServiceInfo(e.Context, css::uno::UNO_QUERY);
170 if (!xServiceInfo || !xServiceInfo->supportsService(
"com.sun.star.frame.StartModule"))
172 SAL_WARN(
"sc.ui",
"Opening file from StartModule straight into print preview");
179 if (
auto pTabViewShell = dynamic_cast<ScTabViewShell*>( pOldSh) )
191 SdrView* pDrawView = pTabViewShell->GetScDrawView();
206 pBar->ControlListenerForCurrentController(
true);
214 EndListening(*pDrawBC);
235 Size aOutSize( rSize );
238 if ( SvxZoomType::WHOLEPAGE ==
eZoom )
240 else if ( SvxZoomType::PAGEWIDTH ==
eZoom )
263 SfxStyleFamily::Page );
264 OSL_ENSURE(pStyleSheet,
"No style sheet");
265 if (!pStyleSheet)
return false;
313 bHori = nMaxWidthPos >= 0;
315 bVert = nMaxHeightPos >= 0;
318 if ( bVert != bHori && ( bVert || bHori ) )
320 if ( bVert && ( (nMaxWidthPos + aWidthOffSet ) > 0 ) )
322 else if ( (nMaxHeightPos + aHeightOffSet ) > 0 )
337 Size( aWindowPixelSize.
Width(), nBarH ) );
341 Size( nBarW, nBarH ) );
370 else if (aOfs.X() < 0)
376 else if (aOfs.X() > nMaxPos)
379 aOfs.setX( nMaxPos );
403 else if (aOfs.Y() < 0)
426 tools::Long nTotalPages = pPreview->GetTotalPages();
429 bool bIsDivide =
true;
432 nPerPageLength = nMaxRange / nTotalPages;
436 nPageNo = nPos / nPerPageLength;
437 if( nPos % nPerPageLength )
444 bool bHoriz = ( pScroll == pHorScroll );
447 pPreview->SetXOffset( nPos );
450 if( nMaxVertPos > 0 )
451 pPreview->SetYOffset( nPos );
454 Point aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
455 Point aPos = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
462 if ( nTotalPages && nPageNo > 0 && !bIsDivide )
463 pPreview->SetPageNo( nPageNo-1 );
465 pPreview->SetPageNo( nPageNo );
467 aHelpStr =
ScResId( STR_PAGE ) +
468 " " + OUString::number( nPageNo ) +
469 " / " + OUString::number( nTotalPages );
471 else if( nDelta > 0 )
473 bool bAllTested = pPreview->AllTested();
474 if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
475 pPreview->SetPageNo( nPageNo );
477 aHelpStr =
ScResId( STR_PAGE ) +
478 " " + OUString::number( nPageNo+1 ) +
479 " / " + OUString::number( nTotalPages );
483 aRect.
SetTop( aMousePos.Y() );
486 nAlign = QuickHelpFlags::Bottom|QuickHelpFlags::Center;
501 if ( pData && pData->
GetMode() == CommandWheelMode::ZOOM )
512 eZoom = SvxZoomType::PERCENT;
545 if ( ScTpPrintOptionsCreate )
546 return ScTpPrintOptionsCreate(pPage, pController, &rOptions);
567 sal_uInt16 nSlot = rReq.
GetSlot();
573 case SID_STATUS_PAGESTYLE:
582 case SID_PREVIEW_PREVIOUS:
586 if (nTotal && nPage > 0)
591 case SID_PREVIEW_NEXT:
596 if (nTotal && (nPage+1 < nTotal || !bAllTested))
600 case SID_CURSORTOPOFFILE:
601 case SID_PREVIEW_FIRST:
605 if (nTotal && nPage != 0)
609 case SID_CURSORENDOFFILE:
610 case SID_PREVIEW_LAST:
617 if (nTotal && nPage+1 != nTotal)
624 sal_uInt16 nZoom = 100;
625 bool bCancel =
false;
627 eZoom = SvxZoomType::PERCENT;
635 nZoom = rZoomItem.GetValue();
642 aSet.
Put( aZoomItem );
645 pDlg->SetLimits( 20, 400 );
646 pDlg->HideButton( ZoomButtonId::OPTIMAL );
651 const SvxZoomItem& rZoomItem = pDlg->GetOutputItemSet()->
652 Get( SID_ATTR_ZOOM );
655 nZoom = rZoomItem.GetValue();
663 case SvxZoomType::OPTIMAL:
664 case SvxZoomType::WHOLEPAGE:
667 case SvxZoomType::PAGEWIDTH:
686 eZoom = SvxZoomType::PERCENT;
695 eZoom = SvxZoomType::PERCENT;
699 case SID_PREVIEW_MARGIN:
707 case SID_ATTR_ZOOMSLIDER:
710 eZoom = SvxZoomType::PERCENT;
711 if( pReqArgs && (pItem = pReqArgs->
GetItemIfSet( SID_ATTR_ZOOMSLIDER )) )
713 const sal_uInt16 nCurrentZoom = pItem->GetValue();
722 case SID_PREVIEW_SCALINGFACTOR:
729 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
731 if ( pReqArgs && pStyleSheet && (pItem = pReqArgs->
GetItemIfSet( SID_PREVIEW_SCALINGFACTOR )) )
733 const sal_uInt16 nCurrentZoom = pItem->GetValue();
743 case SID_PRINTPREVIEW:
744 case SID_PREVIEW_CLOSE:
751 case SID_CURSORPAGEUP:
752 case SID_CURSORPAGEDOWN:
758 case SID_CURSORRIGHT:
787 case SID_STATUS_PAGESTYLE:
796 case SID_MAIL_SENDDOC:
797 case SID_VIEW_DATA_SOURCE_BROWSER:
801 case SID_PREVIEW_PREVIOUS:
802 case SID_PREVIEW_FIRST:
803 if (!nTotal || nPage==0)
806 case SID_PREVIEW_NEXT:
807 case SID_PREVIEW_LAST:
809 if (!nTotal || nPage==nTotal-1)
823 aZoom.
SetValueSet( SvxZoomEnableFlags::ALL & ~SvxZoomEnableFlags::OPTIMAL );
827 case SID_ATTR_ZOOMSLIDER:
831 rSet.
Put( aZoomSliderItem );
834 case SID_PREVIEW_SCALINGFACTOR:
843 OSL_ENSURE( pStyleSheet,
"PageStyle not found! :-/" );
853 rSet.
Put( aZoomSliderItem );
861 case SID_STATUS_DOCPOS:
864 case SID_PRINTPREVIEW:
868 case SID_PREVIEW_MARGIN:
922 if (!rData.isEmpty())
927 eZoom = SvxZoomType::PERCENT;
938 beans::PropertyValue* pSeq = rSeq.getArray();
941 pSeq[0].Value <<=
SC_VIEW + OUString::number(nViewID);
944 pSeq[2].Name =
"PageNumber";
949 pDrawLayer->WriteUserDataSequence(rSeq);
954 for (
const auto& propval : rSeq)
959 if (propval.Value >>= nTemp)
962 else if (propval.Name ==
"PageNumber")
965 if (propval.Value >>= nTemp)
976 Point aCurPos, aPrevPos;
1002 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
1007 aCurPos.AdjustY( -nVLine );
1009 case SID_CURSORDOWN:
1022 if( nPage<nTotal-1 )
1025 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
1030 aCurPos.AdjustY(nVLine );
1032 case SID_CURSORLEFT:
1033 aCurPos.AdjustX( -nHLine );
1035 case SID_CURSORRIGHT:
1036 aCurPos.AdjustX(nHLine );
1038 case SID_CURSORPAGEUP:
1046 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
1048 aCurPos.setY( nVRange );
1052 aCurPos.AdjustY( -nVPage );
1054 case SID_CURSORPAGEDOWN:
1055 if( (std::abs(nVPage+nThumbPos-nRangeMax)<10) ||
nMaxVertPos<0 )
1066 if( nPage<nTotal-1 )
1069 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
1075 aCurPos.AdjustY(nVPage );
1077 case SID_CURSORHOME:
1082 if( nTotal && nPage != 0 )
1085 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST );
1102 if( nTotal && nPage+1 != nTotal )
1105 SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST );
1111 aCurPos.setY( nVRange );
1112 aCurPos.setX( nHRange );
1119 if( aCurPos.Y() > (nVRange-nVPage) )
1120 aCurPos.setY( nVRange-nVPage );
1121 if( aCurPos.Y() < 0 )
1123 if( aCurPos.X() > (nHRange-nHPage) )
1124 aCurPos.setX( nHRange-nHPage );
1125 if( aCurPos.X() < 0 )
1130 if( aCurPos.Y() != aPrevPos.Y() )
1137 if( aCurPos.X() != aPrevPos.X() )
1164 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()
constexpr OUStringLiteral SC_ZOOMVALUE
void AddAccessibilityObject(SfxListener &rObject)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxPrinter * GetPrinter(bool bCreateIfNotExist=true)
SystemWindow * GetSystemWindow() const
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
#define SFX_IMPL_INTERFACE(Class, SuperClass)
OUString ScResId(TranslateId aId)
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
void SetZoom(sal_uInt16 nNewZoom)
std::unique_ptr< sal_Int32[]> pData
sal_uInt16 GetOptimalZoom(bool bWidthOnly)
virtual std::unique_ptr< SfxTabPage > CreatePrintOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rOptions) override
SfxDispatcher * GetDispatcher()
constexpr TypedWhichId< SfxUInt16Item > ATTR_PAGE_SCALE(175)
static SvxAbstractDialogFactory * Create()
virtual ~ScPreviewShell() override
void SetPageMargins(bool bVal)
const StyleSettings & GetStyleSettings() const
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
virtual void SetSizePixel(const Size &rNewSize)
virtual bool HasPrintOptionsPage() const override
VclPtr< ScrollBar > pVerScroll
const ContentProperties & rData
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
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()
constexpr tools::Long Width() const
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)
constexpr OUStringLiteral SC_VIEWID
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)
sal_Int32 GetScrollBarSize() const
void SetWindow(vcl::Window *pViewPort)
bool IsSystemWindow() const
const MapMode & GetMapMode() 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)
const AllSettings & GetSettings() const
SFX_IMPL_NAMED_VIEWFACTORY(ScPreviewShell,"PrintPreview")
IMPL_LINK_NOARG(ScPreviewShell, CloseHdl, SystemWindow &, void)
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
void GetState(SfxItemSet &rSet)
virtual void Activate(bool IsMDIActivate) override
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
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)
SAL_WARN_UNUSED_RESULT 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
constexpr tools::Long Height() 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()
::OutputDevice const * GetOutDev() const
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()
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
Size GetOutputSizePixel() 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
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