23 #include <officecfg/Office/Common.hxx>
38 #include <preview.hxx>
42 #include <docfunc.hxx>
44 #include <printopt.hxx>
45 #include <stlpool.hxx>
50 #include <globstr.hrc>
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++)
239 while (nStart > static_cast<SCTAB>(
nPages.size()))
241 while (nStart > static_cast<SCTAB>(
nFirstAttr.size()))
246 if (
i == static_cast<SCTAB>(
nPages.size()))
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 );
355 if ( bDoPrint && (
aOffset.X() < 0 ||
aOffset.Y() < 0 ) && bValidPage )
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?");
409 nLeftMargin = pPrintFunc->GetLeftMargin();
410 nRightMargin = pPrintFunc->GetRightMargin();
411 nTopMargin = pPrintFunc->GetTopMargin();
412 nBottomMargin = pPrintFunc->GetBottomMargin();
415 bHeaderOn = pPrintFunc->GetHeader().bEnable;
416 bFooterOn = pPrintFunc->GetFooter().bEnable;
417 mnScale = pPrintFunc->GetZoom();
453 aLocalPageSize = pPrintFunc->GetPageSize();
464 const auto m = md.first *
mnScale,
d = md.second * 100;
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);
540 DrawInvert( static_cast<tools::Long>( nTopMargin -
aOffset.Y() ), PointerStyle::VSizeBar );
541 DrawInvert( static_cast<tools::Long>(nPageEndY - nBottomMargin ), PointerStyle::VSizeBar );
542 DrawInvert( static_cast<tools::Long>( nLeftMargin -
aOffset.X() ), PointerStyle::HSizeBar );
543 DrawInvert( static_cast<tools::Long>( nPageEndX - nRightMargin ) , PointerStyle::HSizeBar );
565 if (bRight || bBottom)
595 aPixel.AdjustBottom( -1 );
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;
765 if (nTabP >= static_cast<SCTAB>(
nPages.size()) )
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 )
1257 const auto m = md.first * 100,
d = md.second *
mnScale;
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;
1323 const auto m = md.first *
mnScale,
d = md.second * 100;
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 ||
1405 ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) ||
bRightRulerMove || bOnColRulerChange ||
bColRulerMove )
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 )
tools::Long const nBottomMargin
SfxViewFrame * GetViewFrame() const
#define LINK(Instance, Class, Member)
void SetDigitLanguage(LanguageType)
ScRange aPageArea
we have at least one sheet with empty print range (print range set to '- none -').
void GetPrintState(ScPrintState &rState, bool bSavePageRanges=false)
Point aButtonDownChangePoint
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
void UpdatePendingRowHeights(SCTAB nUpdateTab, bool bBefore=false)
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
constexpr TypedWhichId< SvxSizeItem > ATTR_PAGE_SIZE(161)
constexpr TypedWhichId< ScPatternAttr > ATTR_PATTERN(156)
SCCOL nColNumberButtonDown
OUString ScResId(TranslateId aId)
sal_uInt16 GetLower() const
void setWidth(tools::Long nWidth)
virtual void MouseMove(const MouseEvent &rMEvt) override
void SetZoom(sal_uInt16 nNewZoom)
sal_uInt16 GetOptimalZoom(bool bWidthOnly)
vcl::Window * GetAccessibleParentWindow() const
tools::Long const nLeftMargin
SfxDispatcher * GetDispatcher()
tools::Long GetRight() const
svtools::ColorConfig & GetColorConfig()
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
double GetOutputFactor() const
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
sal_uInt16 GetCode() const
DataChangedEventType GetType() const
bool Select(sal_Int32 nIndex, bool bSelect=true)
static bool IsFullScreen(const SfxViewShell &rViewShell)
Returns true, if the passed view shell is in full screen mode.
virtual SfxItemSet & GetItemSet()
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
void SetHelpId(const OString &)
void Invalidate(sal_uInt16 nId)
virtual void dispose() override
constexpr sal_uInt16 KEY_ADD
const MarkedTabsType & GetSelectedTabs() const
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
void ExecutePopup(const OUString &rResName, vcl::Window *pWin=nullptr, const Point *pPos=nullptr)
static Size lcl_GetDocPageSize(const ScDocument *pDoc, SCTAB nTab)
SC_DLLPUBLIC ScDocumentPool * GetPool()
virtual SfxUndoManager * GetUndoManager() override
constexpr tools::Long Width() const
static rtl::Reference< SfxItemPool > CreatePool()
weld::Window * GetFrameWeld() const
tools::Long nDisplayStart
static void StaticInvalidate()
void Invert(const tools::Rectangle &rRect, InvertFlags nFlags=InvertFlags::NONE)
sal_uInt16 GetButtons() const
ScMarkData::MarkedTabsType maSelectedTabs
css::uno::Reference< css::accessibility::XAccessible > GetAccessible(bool bCreate=true)
SC_DLLPUBLIC SCTAB GetTableCount() const
AllSettingsFlags GetFlags() const
#define SC_PREVIEW_SHADOWSIZE
std::vector< tools::Long > mvRight
sal_uInt16 GetModifier() const
bool ScrollCommand(const CommandEvent &rCEvt)
void SetAccessible(const css::uno::Reference< css::accessibility::XAccessible > &)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
SC_DLLPUBLIC void SetSelectedTabs(const ScMarkData &rMark)
std::vector< tools::Long > nFirstAttr
virtual ~ScPreview() override
void DrawRect(const tools::Rectangle &rRect)
std::unique_ptr< ScPreviewLocationData > pLocationData
virtual void dispose() override
virtual void LoseFocus() override
void BroadcastAccessibility(const SfxHint &rHint)
void InitFromStyle(const SfxStyleSheetBase *pSource)
PointerStyle GetPointer() const
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
IMPL_STATIC_LINK_NOARG(ScPreview, InvalidateHdl, void *, void)
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
void DrawInvert(tools::Long nDragPos, PointerStyle nFlags)
Point LogicToPixel(const Point &rLogicPt) const
tools::Long GetTotalPages() const
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_HEADERSET(184)
SC_DLLPUBLIC const ScPrintOptions & GetPrintOptions()
void DoPrint(ScPreviewLocationData *pFillLocation)
const MapMode & GetMapMode() const
static SC_DLLPUBLIC double nScreenPPTY
Vertical pixel per twips factor.
SfxBindings & GetBindings()
SC_DLLPUBLIC void SetPageNo(tools::Long nPage)
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Size GetOutputSize() const
void SetXOffset(tools::Long nX)
tools::Long GetLeft() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
CommandEventId GetCommand() const
tools::Long nLeftPosition
void SetLowerValue(const sal_uInt16 nL)
virtual void GetFocus() override
virtual void Command(const CommandEvent &rCEvt) override
SC_DLLPUBLIC OUString GetPageStyle(SCTAB nTab) const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
std::vector< tools::Long > nPages
bool HasPrintRange() const
Point PixelToLogic(const Point &rDevicePt) const
bool mbHasEmptyRangeTable
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
constexpr TypedWhichId< SvxLRSpaceItem > ATTR_LRSPACE(157)
const ScPreviewLocationData & GetLocationData()
ScPreview(vcl::Window *pParent, ScDocShell *pDocSh, ScPreviewShell *pViewSh)
tools::Long nHeaderHeight
constexpr sal_Int64 md(U i, U)
SC_DLLPUBLIC bool SetWidthOrHeight(bool bWidth, const std::vector< sc::ColRowSpan > &rRanges, SCTAB nTab, ScSizeMode eMode, sal_uInt16 nSizeTwips, bool bRecord, bool bApi)
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
void SetPointer(PointerStyle)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const vcl::KeyCode & GetKeyCode() const
static SfxViewFrame * Current()
tools::Long const nTopMargin
void InvalidateLocationData(SfxHintId nId)
SC_DLLPUBLIC tools::Long GetFirstPage(SCTAB nTab)
constexpr sal_uInt16 KEY_SUBTRACT
void SetUpperValue(const sal_uInt16 nU)
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
tools::Long nFooterHeight
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
constexpr tools::Long Height() const
constexpr sal_uInt16 KEY_ESCAPE
constexpr OStringLiteral HID_SC_WIN_PREVIEW
void SetTotalRange(const Range &rTotRange)
bool GetAllSheets() const
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
::OutputDevice const * GetOutDev() const
tools::Long AdjustWidth(tools::Long n)
SC_DLLPUBLIC bool NeedPageResetAfterTab(SCTAB nTab) const
constexpr TypedWhichId< SvxULSpaceItem > ATTR_ULSPACE(158)
void SetYOffset(tools::Long nY)
static SC_DLLPUBLIC double nScreenPPTX
Horizontal pixel per twips factor.
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
const ScDocument & GetDocument() const
tools::Long const nRightMargin
const Point & GetPosPixel() const
virtual void KeyInput(const KeyEvent &rKEvt) override
tools::Long AdjustHeight(tools::Long n)
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Size GetOutputSizePixel() const
tools::Long GetFirstPageNo() const
void SetDocumentModified()
bool HasAccessibilityObjects() const
void setHeight(tools::Long nHeight)
virtual bool KeyInput(const KeyEvent &rKeyEvent)
void SetOutDevViewType(OutDevViewType eOutDevViewType)
virtual void SetModified(bool=true) override
bool IsUndoEnabled() const
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
static tools::Long lcl_GetDisplayStart(SCTAB nTab, const ScDocument *pDoc, std::vector< tools::Long > &nPages)
std::unique_ptr< FmFormView > pDrawView
ScPreviewShell * pViewShell
SC_DLLPUBLIC sal_uInt16 GetColWidth(SCCOL nCol, SCTAB nTab, bool bHiddenAsZero=true) const
void UpdateNeededScrollBars(bool bFromZoom)
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
constexpr TypedWhichId< SvxSetItem > ATTR_PAGE_FOOTERSET(185)
bool ValidTab(SCTAB nTab)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Create before modifications of the document and destroy thereafter.
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
sal_uInt16 GetUpper() const
void DragMove(tools::Long nDragMovePos, PointerStyle nFlags)
bool m_bDetectedRangeSegmentation false
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...