23#include <officecfg/Office/Common.hxx>
44#include <printopt.hxx>
59#include <com/sun/star/accessibility/XAccessible.hpp>
69#define SC_PREVIEW_SHADOWSIZE 2
79 nDisplayStart += nPages[
i];
97 pViewShell( pViewSh ),
100 bStateValid( false ),
101 bLocationValid( false ),
104 bLeftRulerMove( false ),
105 bRightRulerMove( false ),
106 bTopRulerMove( false ),
107 bBottomRulerMove( false ),
108 bHeaderRulerMove( false ),
109 bFooterRulerMove( false ),
110 bLeftRulerChange( false ),
111 bRightRulerChange( false ),
112 bTopRulerChange( false ),
113 bBottomRulerChange( false ),
114 bHeaderRulerChange( false ),
115 bFooterRulerChange( false ),
116 bPageMargin ( false ),
117 bColRulerMove( false ),
118 mbHasEmptyRangeTable(false),
121 nColNumberButtonDown( 0 ),
187 OSL_ENSURE(0 <
static_cast<SCTAB>(
nPages.size()),
"are all tables empty?");
190 for (sal_uInt16
i=0;
i<
nTab;
i++)
310 for (
SCTAB i=0; i<nTabsTested && nTab < static_cast<SCTAB>(
nPages.size());
i++)
329 if (
nTab != nOldTab )
346 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
348 bool bDoPrint = ( pFillLocation == nullptr );
372 bool bHeaderOn =
false;
373 bool bFooterOn =
false;
383 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
389 pPrintFunc->SetOffset(
aOffset);
390 pPrintFunc->SetManualZoom(
nZoom);
392 pPrintFunc->SetClearFlag(
true);
393 pPrintFunc->SetUseStyleColor( officecfg::Office::Common::Accessibility::IsForPagePreviews::get() );
395 pPrintFunc->SetDrawView(
pDrawView.get() );
401 aPage.
Select( aPageRange );
404 OSL_ENSURE(nPrinted<=1,
"What is happening?");
415 bHeaderOn = pPrintFunc->GetHeader().bEnable;
416 bFooterOn = pPrintFunc->GetFooter().bEnable;
417 mnScale = pPrintFunc->GetZoom();
453 aLocalPageSize = pPrintFunc->GetPageSize();
471 pPrintFunc->GetPrintState(
aState );
483 nPageEndX = nPageEndY = 0;
487 bool bRight = nPageEndX <= aWinEnd.
X();
488 bool bBottom = nPageEndY <= aWinEnd.
Y();
505 std::unique_ptr<ScEditEngineDefaulter> pEditEng(
508 pEditEng->SetRefMapMode(aMMMode);
509 auto pEditDefaults = std::make_unique<SfxItemSet>( pEditEng->GetEmptyItemSet() );
512 pEditEng->SetDefaults(std::move(pEditDefaults));
516 aEmptyMsg =
ScResId(STR_PRINT_PREVIEW_EMPTY_RANGE);
518 aEmptyMsg =
ScResId(STR_PRINT_PREVIEW_NODATA);
525 pEditEng->SetTextCurrentDefaults(aEmptyMsg);
528 (aWinEnd.
X() - pEditEng->CalcTextWidth())/2,
529 (aWinEnd.
Y() - pEditEng->GetTextHeight())/2);
565 if (bRight || bBottom)
635 if ( nCmd == CommandEventId::Wheel || nCmd == CommandEventId::StartAutoScroll || nCmd == CommandEventId::AutoScroll )
639 Window::Command(rCEvt);
641 else if ( nCmd == CommandEventId::ContextMenu )
644 Window::Command( rCEvt );
653 sal_uInt16 nKey = rKeyCode.
GetCode();
654 bool bHandled =
false;
657 sal_uInt16 nSlot = 0;
660 case KEY_ADD: nSlot = SID_ZOOM_IN;
break;
672 Window::KeyInput(rKEvt);
709 OUString aString =
ScResId( STR_PAGE ) +
710 " " + OUString::number(
nPageNo+1);
724 if (nNewZoom ==
nZoom)
733 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
758 if (nTabP >= nDocTabCount)
759 nTabP = nDocTabCount-1;
766 OSL_FAIL(
"nPages out of bounds, FIX IT");
774 if (
nPages[nTabP]==0 && nPage > 0 )
793 OSL_FAIL(
"PageStyle not found" );
812 if ( aLocalPageSize.
Width() && aLocalPageSize.
Height() )
818 if (!bWidthOnly && nZoomY<nOptimal)
826 return static_cast<sal_uInt16
>(nOptimal);
917 rBindings.
Invalidate(SID_PREVIEW_SCALINGFACTOR);
928 Window::DataChanged(rDCEvt);
930 if ( !((rDCEvt.
GetType() == DataChangedEventType::PRINTER) ||
931 (rDCEvt.
GetType() == DataChangedEventType::DISPLAY) ||
932 (rDCEvt.
GetType() == DataChangedEventType::FONTS) ||
933 (rDCEvt.
GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
934 ((rDCEvt.
GetType() == DataChangedEventType::SETTINGS) &&
935 (rDCEvt.
GetFlags() & AllSettingsFlags::STYLE))) )
938 if ( rDCEvt.
GetType() == DataChangedEventType::FONTS )
945 if ( rDCEvt.
GetType() == DataChangedEventType::SETTINGS &&
946 (rDCEvt.
GetFlags() & AllSettingsFlags::STYLE) )
960 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
1043 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
1062 bool bMoveRulerAction=
true;
1073 bMoveRulerAction =
false;
1078 bMoveRulerAction =
false;
1083 bMoveRulerAction =
false;
1088 bMoveRulerAction =
false;
1091 if( bMoveRulerAction )
1097 rStyleSet.
Put( aLRItem );
1103 rStyleSet.
Put( aLRItem );
1112 std::make_unique<ScUndoModifyStyle>(
pDocShell, SfxStyleFamily::Page,
1113 aOldData, aNewData ) );
1137 bool bMoveRulerAction =
true;
1140 bMoveRulerAction =
false;
1145 bMoveRulerAction =
false;
1148 if( bMoveRulerAction )
1154 OSL_ENSURE( pStyleSheet,
"PageStyle not found" );
1169 rStyleSet.
Put( aULItem );
1175 rStyleSet.
Put( aULItem );
1182 const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
1188 rStyleSet.
Put( aNewHeader );
1196 const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
1202 rStyleSet.
Put( aNewFooter );
1212 std::make_unique<ScUndoModifyStyle>(
pDocShell, SfxStyleFamily::Page,
1213 aOldData, aNewData ) );
1241 bool bMoveRulerAction =
true;
1244 bMoveRulerAction =
false;
1251 if( bMoveRulerAction )
1270 if( nNewColWidth >= 0 )
1273 true, aCols,
nTab,
SC_SIZE_DIRECT,
static_cast<sal_uInt16
>(nNewColWidth),
true,
true);
1293 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
1308 std::unique_ptr<ScPrintFunc, o3tl::default_delete<ScPrintFunc>> pPrintFunc;
1344 bool bOnColRulerChange =
false;
1351 if( aPixPt.
X() < ( nRight + 2 ) && ( aPixPt.
X() > ( nRight - 2 ) ) && ( aPixPt.
X() < aRightTop.
X() ) && ( aPixPt.
X() > aLeftTop.
X() )
1355 bOnColRulerChange =
true;
1362 if( aPixPt.
X() < ( aLeftTop.
X() + 2 ) && aPixPt.
X() > ( aLeftTop.
X() - 2 ) && !
bRightRulerMove )
1367 else if( aPixPt.
X() < ( aRightTop.
X() + 2 ) && aPixPt.
X() > ( aRightTop.
X() - 2 ) && !
bLeftRulerMove )
1404 if(( (aPixPt.
X() < ( aLeftTop.
X() + 2 ) && aPixPt.
X() > ( aLeftTop.
X() - 2 )) ||
bLeftRulerMove ||
1406 && aPixPt.
Y() > aLeftTop.
Y() && aPixPt.
Y() < aLeftBottom.
Y() )
1414 DragMove( aMouseMovePoint.
X(), PointerStyle::HSplit );
1425 DragMove( aMouseMovePoint.
X(), PointerStyle::HSizeBar );
1434 DragMove( aMouseMovePoint.
X(), PointerStyle::HSizeBar );
1441 if( ( ( aPixPt.
Y() < ( aTopLeft.
Y() + 2 ) && aPixPt.
Y() > ( aTopLeft.
Y() - 2 ) ) ||
bTopRulerMove ||
1442 ( aPixPt.
Y() < ( aBottomLeft.
Y() + 2 ) && aPixPt.
Y() > ( aBottomLeft.
Y() - 2 ) ) ||
bBottomRulerMove ||
1443 ( aPixPt.
Y() < ( aHeaderLeft.
Y() + 2 ) && aPixPt.
Y() > ( aHeaderLeft.
Y() - 2 ) ) ||
bHeaderRulerMove ||
1444 ( aPixPt.
Y() < ( aFooderLeft.
Y() + 2 ) && aPixPt.
Y() > ( aFooderLeft.
Y() - 2 ) ) ||
bFooterRulerMove )
1445 && aPixPt.
X() > aTopLeft.
X() && aPixPt.
X() < aTopRight.
X() )
1453 DragMove( aMouseMovePoint.
Y(), PointerStyle::VSizeBar );
1462 DragMove( aMouseMovePoint.
Y(), PointerStyle::VSizeBar );
1471 DragMove( aMouseMovePoint.
Y(), PointerStyle::VSizeBar );
1480 DragMove( aMouseMovePoint.
Y(), PointerStyle::VSizeBar );
1507 Window::LoseFocus();
1512 css::uno::Reference<css::accessibility::XAccessible> xAcc=
GetAccessible(
false);
1523 pAccessible->Init();
1531 MapMode aMMMode( MapUnit::Map100thMM,
Point(), aHorPrevZoom, aPreviewZoom );
1534 if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
1543 else if( nFlags == PointerStyle::VSizeBar )
1558 if( nFlags == PointerStyle::HSizeBar || nFlags == PointerStyle::HSplit )
1563 else if( nFlags == PointerStyle::VSizeBar )
bool ValidTab(SCTAB nTab)
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
CommandEventId GetCommand() const
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
static rtl::Reference< SfxItemPool > CreatePool()
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
bool Select(sal_Int32 nIndex, bool bSelect=true)
void SetTotalRange(const Range &rTotRange)
Size GetOutputSize() const
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
void SetDigitLanguage(LanguageType)
void SetOutDevViewType(OutDevViewType eOutDevViewType)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
SC_DLLPUBLIC bool SetWidthOrHeight(bool bWidth, const std::vector< sc::ColRowSpan > &rRanges, SCTAB nTab, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi)
Create before modifications of the document and destroy thereafter.
void SetDocumentModified()
virtual void SetModified(bool=true) override
const ScDocument & GetDocument() const
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
double GetOutputFactor() const
virtual SfxUndoManager * GetUndoManager() override
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
SC_DLLPUBLIC ScDocumentPool * GetPool()
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC bool NeedPageResetAfterTab(SCTAB nTab) const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
bool IsUndoEnabled() const
SC_DLLPUBLIC SCTAB GetTableCount() const
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
const MarkedTabsType & GetSelectedTabs() const
svtools::ColorConfig & GetColorConfig()
SC_DLLPUBLIC const ScPrintOptions & GetPrintOptions()
static LanguageType GetOptDigitLanguage()
void FillEditItemSet(SfxItemSet *pEditSet, const SfxItemSet *pCondSet=nullptr) const
Converts all Calc items contained in the own item set to edit engine items and puts them into pEditSe...
bool HasAccessibilityObjects() const
void UpdateNeededScrollBars(bool bFromZoom)
void BroadcastAccessibility(const SfxHint &rHint)
bool ScrollCommand(const CommandEvent &rCEvt)
virtual ~ScPreview() override
std::vector< tools::Long > nFirstAttr
tools::Long nFooterHeight
void SetZoom(sal_uInt16 nNewZoom)
void InvalidateLocationData(SfxHintId nId)
void DrawInvert(tools::Long nDragPos, PointerStyle nFlags)
SC_DLLPUBLIC void SetPageNo(tools::Long nPage)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
std::vector< tools::Long > mvRight
SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData &rMark)
ScPreviewShell * pViewShell
SCCOL nColNumberButtonDown
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
tools::Long nHeaderHeight
virtual void Command(const CommandEvent &rCEvt) override
sal_uInt16 GetOptimalZoom(bool bWidthOnly)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
bool mbHasEmptyRangeTable
virtual void GetFocus() override
std::unique_ptr< ScPreviewLocationData > pLocationData
void DragMove(tools::Long nDragMovePos, PointerStyle nFlags)
ScPreview(vcl::Window *pParent, ScDocShell *pDocSh, ScPreviewShell *pViewSh)
void DoPrint(ScPreviewLocationData *pFillLocation)
virtual void MouseMove(const MouseEvent &rMEvt) override
std::vector< tools::Long > nPages
const ScPreviewLocationData & GetLocationData()
tools::Long nLeftPosition
Point aButtonDownChangePoint
static void StaticInvalidate()
SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab)
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
std::unique_ptr< FmFormView > pDrawView
tools::Long nDisplayStart
virtual void KeyInput(const KeyEvent &rKEvt) override
void SetXOffset(tools::Long nX)
virtual void dispose() override
virtual void LoseFocus() override
ScMarkData::MarkedTabsType maSelectedTabs
void SetYOffset(tools::Long nY)
ScRange aPageArea
we have at least one sheet with empty print range (print range set to '- none -').
tools::Long GetFirstPageNo() const
bool HasPrintRange() const
tools::Long GetTotalPages() const
void GetPrintState(ScPrintState &rState, bool bSavePageRanges=false)
bool GetAllSheets() const
void InitFromStyle(const SfxStyleSheetBase *pSource)
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
const SdrPage * GetPage(sal_uInt16 nPgNum) const
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)
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
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
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
virtual SfxItemSet & GetItemSet()
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxViewFrame & GetViewFrame() const
virtual bool KeyInput(const KeyEvent &rKeyEvent)
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
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
tools::Long GetRight() const
tools::Long GetLeft() const
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
sal_uInt16 GetUpper() const
sal_uInt16 GetLower() const
void SetUpperValue(const sal_uInt16 nU)
void SetLowerValue(const sal_uInt16 nL)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void dispose() override
Point LogicToPixel(const Point &rLogicPt) const
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
vcl::Window * GetAccessibleParentWindow() const
const MapMode & GetMapMode() const
::OutputDevice const * GetOutDev() const
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Point PixelToLogic(const Point &rDevicePt) const
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
Size GetOutputSizePixel() const
virtual void SetPointer(PointerStyle)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
weld::Window * GetFrameWeld() const
PointerStyle GetPointer() const
void SetHelpId(const OUString &)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
constexpr OUStringLiteral HID_SC_WIN_PREVIEW
constexpr sal_uInt16 KEY_ESCAPE
constexpr sal_uInt16 KEY_ADD
constexpr sal_uInt16 KEY_SUBTRACT
#define LINK(Instance, Class, Member)
tools::Long const nRightMargin
tools::Long const nBottomMargin
tools::Long const nTopMargin
tools::Long const nLeftMargin
constexpr sal_Int64 md(U i, U)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static tools::Long lcl_GetDisplayStart(SCTAB nTab, const ScDocument *pDoc, std::vector< tools::Long > &nPages)
static Size lcl_GetDocPageSize(const ScDocument *pDoc, SCTAB nTab)
IMPL_STATIC_LINK_NOARG(ScPreview, InvalidateHdl, void *, void)
#define SC_PREVIEW_SHADOWSIZE
OUString ScResId(TranslateId aId)
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
constexpr TypedWhichId< SvxULSpaceItem > ATTR_ULSPACE(158)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
constexpr TypedWhichId< SvxLRSpaceItem > ATTR_LRSPACE(157)