20#include <config_wasm_strip.h>
26#include <osl/diagnose.h>
48 : mrParentViewShell( _rParentViewShell ),
49 mrLayoutRootFrame ( _rLayoutRootFrame )
129 pPage->
Calc(pRenderContext);
172 const sal_uInt16 _nRows,
173 const Size& _rPxWinSize
178 bool bColsRowsValid = (_nCols != 0) && (_nRows != 0);
179 OSL_ENSURE( bColsRowsValid,
"preview layout parameters not correct - preview layout can *not* be initialized" );
180 if ( !bColsRowsValid )
183 bool bPxWinSizeValid = (_rPxWinSize.
Width() >= 0) &&
184 (_rPxWinSize.
Height() >= 0);
185 OSL_ENSURE( bPxWinSizeValid,
"no window size - preview layout can *not* be initialized" );
186 if ( !bPxWinSizeValid )
205 MapMode aMapMode( MapUnit::MapTwip );
209 if( aXScale < aYScale )
214 tools::Long nNewNuminator = aYScale.operator long();
215 if( nNewNuminator < 1 )
217 aYScale =
Fraction( nNewNuminator, 1000 );
239 if ( aNewViewOptions.
GetZoom() != _aNewZoom )
241 aNewViewOptions.
SetZoom( _aNewZoom );
243 aNewViewOptions.
SetZoomType( SvxZoomType::PERCENT );
256 OSL_ENSURE( bLayoutSettingsValid,
257 "no valid preview layout info/sizes - no re-init of page preview layout");
258 if ( !bLayoutSettingsValid )
275 const Point& rProposedStartPos,
276 const Size& _rPxWinSize,
277 sal_uInt16& _onStartPageNum,
279 const bool _bStartWithPageAtFirstCol
286 OSL_ENSURE( bLayoutSettingsValid,
287 "no valid preview layout info/sizes - no prepare of preview paint");
288 if ( !bLayoutSettingsValid )
291 bool bStartPageRangeValid = nProposedStartPageNum <=
mnPages;
292 OSL_ENSURE( bStartPageRangeValid,
293 "proposed start page not existing - no prepare of preview paint");
294 if ( !bStartPageRangeValid )
297 bool bStartPosRangeValid =
298 rProposedStartPos.
X() >= 0 && rProposedStartPos.
Y() >= 0 &&
301 OSL_ENSURE( bStartPosRangeValid,
302 "proposed start position out of range - no prepare of preview paint");
303 if ( !bStartPosRangeValid )
306 bool bWinSizeValid = !_rPxWinSize.
IsEmpty();
307 OSL_ENSURE( bWinSizeValid,
"no window size - no prepare of preview paint");
308 if ( !bWinSizeValid )
311 bool bStartInfoValid = _nProposedStartPageNum > 0 ||
312 rProposedStartPos !=
Point(0,0);
313 if ( !bStartInfoValid )
314 nProposedStartPageNum = 1;
323 if ( nProposedStartPageNum > 0 )
326 const sal_uInt16 nColOfProposed =
GetColOfPage( nProposedStartPageNum );
327 const sal_uInt16 nRowOfProposed =
GetRowOfPage( nProposedStartPageNum );
329 if ( _bStartWithPageAtFirstCol )
334 ( nProposedStartPageNum == 1 || nRowOfProposed == 1 )
346 if ( _bStartWithPageAtFirstCol )
356 if ( _bStartWithPageAtFirstCol )
366 const sal_uInt16 nColOfProposed =
367 o3tl::narrowing<sal_uInt16>(rProposedStartPos.
X() /
mnColWidth) + 1;
368 const sal_uInt16 nRowOfProposed =
369 o3tl::narrowing<sal_uInt16>(rProposedStartPos.
Y() /
mnRowHeight) + 1;
374 ( nRowOfProposed == 1 && nColOfProposed == 1 )
419 _rPxWinSize, _onStartPageNum,
420 _orDocPreviewPaintRect, _bStartWithPageAtFirstCol );
436 _rPxWinSize, _onStartPageNum,
437 _orDocPreviewPaintRect, _bStartWithPageAtFirstCol );
445 _rPxWinSize, _onStartPageNum,
446 _orDocPreviewPaintRect, _bStartWithPageAtFirstCol );
538 Point aInitialPaintOffset;
557 sal_uInt16 nConsideredRows = 0;
558 Point aCurrPaintOffset = aInitialPaintOffset;
571 pPage->
Calc(pRenderContext);
577 std::unique_ptr<PreviewPage> pPreviewPage(
new PreviewPage);
578 Point aCurrAccOffset = aCurrPaintOffset -
581 pPreviewPage->bVisible =
false;
606 std::unique_ptr<PreviewPage> pPreviewPage(
new PreviewPage);
608 pPreviewPage->bVisible =
true;
614 std::unique_ptr<PreviewPage> pPreviewPage(
new PreviewPage);
616 pPreviewPage->bVisible =
false;
631 aCurrPaintOffset.
setX( aInitialPaintOffset.
X() );
643 const Point& _rPreviewOffset,
647 _opPreviewPage->
pPage = &_rPage;
659 Point aPreviewWinOffset( _rPreviewOffset );
683 sal_uInt16& _onStartPageNum,
703 _onStartPageNum, _orDocPreviewPaintRect );
722 const Size& _aNewWinSize )
const
725 if ( _aNewScale < _aOldScale )
729 aNewPaintStartPos.
setX( 0 );
734 if ( aNewPaintStartPos.
X() < 0)
735 aNewPaintStartPos.
setX( 0 );
743 aNewPaintStartPos.
setY(
750 if ( aNewPaintStartPos.
Y() < 0)
751 aNewPaintStartPos.
setY( 0 );
768 aNewPaintStartPos.
setY(
773 return aNewPaintStartPos;
783 return pPreviewPage && pPreviewPage->
bVisible;
791 const sal_Int16 _nHoriMove,
792 const sal_Int16 _nVertMove,
793 sal_uInt16& _orNewSelectedPage,
794 sal_uInt16& _orNewStartPage,
795 Point& _orNewStartPos )
const
799 sal_uInt16 nNewRelSelectedPageNum = nTmpRelSelPageNum;
801 const sal_uInt16 nCurrRow =
GetRowOfPage(nTmpRelSelPageNum);
805 if ( _nHoriMove != 0 )
807 if ( (nNewRelSelectedPageNum + _nHoriMove) < 1 )
808 nNewRelSelectedPageNum = 1;
809 else if ( (nNewRelSelectedPageNum + _nHoriMove) >
mnPages )
810 nNewRelSelectedPageNum =
mnPages;
812 nNewRelSelectedPageNum = nNewRelSelectedPageNum + _nHoriMove;
814 if ( _nVertMove != 0 )
816 if ( (nNewRelSelectedPageNum + (_nVertMove *
mnCols)) < 1 )
817 nNewRelSelectedPageNum = 1;
818 else if ( (nNewRelSelectedPageNum + (_nVertMove *
mnCols)) >
mnPages )
819 nNewRelSelectedPageNum =
mnPages;
821 nNewRelSelectedPageNum += ( _nVertMove *
mnCols );
826 Point aNewStartPos(0,0);
831 if ( _nHoriMove != 0 && _nVertMove != 0 )
833 OSL_FAIL(
"missing implementation for moving preview selected page horizontal AND vertical");
840 if ( (_nHoriMove > 0 || _nVertMove > 0) &&
843 nCurrRow > nTotalRows -
mnRows )
865 _orNewSelectedPage = nNewAbsSelectedPageNum;
866 _orNewStartPage = nNewStartPage;
867 _orNewStartPos = aNewStartPos;
873struct PreviewPosInsidePagePred
875 const Point mnPreviewPos;
876 explicit PreviewPosInsidePagePred(
const Point& rPreviewPos)
877 : mnPreviewPos( rPreviewPos )
879 bool operator() (
const std::unique_ptr<PreviewPage> & _pPreviewPage )
881 if ( _pPreviewPage->bVisible )
883 tools::Rectangle aPreviewPageRect( _pPreviewPage->aPreviewWinPos, _pPreviewPage->aPageSize );
884 return aPreviewPageRect.Contains( mnPreviewPos );
894 bool& _obPosInEmptyPage,
895 sal_uInt16& _onPageNum )
const
900 _obPosInEmptyPage =
false;
903 auto aFoundPreviewPageIter =
905 PreviewPosInsidePagePred( rPreviewPos ) );
910 _onPageNum = (*aFoundPreviewPageIter)->pPage->GetPhyPageNum();
911 _obPosInEmptyPage = (*aFoundPreviewPageIter)->pPage->IsEmptyPage();
912 if ( !_obPosInEmptyPage )
915 _orDocPos = rPreviewPos -
916 (*aFoundPreviewPageIter)->aPreviewWinPos +
917 (*aFoundPreviewPageIter)->aLogicPos;
927 const sal_Int16 _nWinPagesToScroll )
const
945 if ( nScrollAmount > 0 &&
960 return nScrollAmount;
968class PreviewRenderContextGuard
975 : m_pOriginalValue(rShell.GetOut()),
981 ~PreviewRenderContextGuard()
983 m_rShell.
SetOut(m_pOriginalValue);
1001 OSL_ENSURE(
mbPaintInfoValid,
"invalid preview settings - no paint of preview");
1036 if ( rpPreviewPage->bVisible )
1038 aPreviewBackgrdRegion -=
1039 SwRect( rpPreviewPage->aPreviewWinPos, rpPreviewPage->aPageSize );
1050 MapMode aSavedMapMode = aMapMode;
1056 if ( !rpPreviewPage->bVisible )
1059 tools::Rectangle aPageRect( rpPreviewPage->aLogicPos, rpPreviewPage->aPageSize );
1060 aMapMode.
SetOrigin( rpPreviewPage->aMapOffset );
1063 if ( aPxOutRect.
Overlaps( aPxPaintRect) )
1075 SwRect aTmpPageRect( aPageRect );
1077 aPageRect = aTmpPageRect.
SVRect();
1083 pOutputDev->
SetFont( rEmptyPgFont );
1085 DrawTextFlags::VCenter |
1086 DrawTextFlags::Center |
1087 DrawTextFlags::Clip );
1088 pOutputDev->
SetFont( aOldFont );
1108 bIsLeftShadowed, bIsRightShadowed,
true );
1132#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1167 "invalid preview settings - no paint of preview" );
1185 if ( !rpPreviewPage->bVisible )
1188 tools::Rectangle aPageRect( rpPreviewPage->aLogicPos, rpPreviewPage->aPageSize );
1189 if ( rInvalidCoreRect.
Overlaps( aPageRect ) )
1194 rpPreviewPage->aLogicPos +
1195 rpPreviewPage->aPreviewWinPos );
1211 MapMode aSavedMapMode = aMapMode;
1217 Color aSelPgLineColor(117, 114, 106);
1273 if ( pOldSelectedPreviewPage && pOldSelectedPreviewPage->
bVisible )
1282 aPxPageRect.
Right(), aPxPageRect.
Top()+1 );
1294 aPxPageRect.
Left()+1, aPxPageRect.
Bottom() );
1300 if ( pNewSelectedPreviewPage && pNewSelectedPreviewPage->
bVisible )
1317struct EqualsPageNumPred
1319 const sal_uInt16 mnPageNum;
1320 explicit EqualsPageNumPred(
const sal_uInt16 _nPageNum)
1321 : mnPageNum( _nPageNum )
1323 bool operator() (
const std::unique_ptr<PreviewPage> & _pPreviewPage )
1325 return _pPreviewPage->pPage->GetPhyPageNum() == mnPageNum;
1333 auto aFoundPreviewPageIter =
1335 EqualsPageNumPred( _nPageNum ) );
1340 return aFoundPreviewPageIter->get();
1360 return _nPageNum /
mnCols + ((_nPageNum %
mnCols)>0 ? 1 : 0);
1380 const sal_uInt16 nCol = _nPageNum %
mnCols;
1381 return nCol ? nCol :
mnCols;
1401 return Size( 0, 0 );
1423 return _nAbsPageNum;
1428 sal_uInt16 nRet = 1;
1430 while ( pTmpPage && pTmpPage->
GetPhyPageNum() != _nAbsPageNum )
1446 return _nRelPageNum;
1453 while( pTmpPage &&
i != _nRelPageNum )
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
virtual const SwPrintData & getPrintData() const =0
Returns the PrintData.
void SetOrigin(const Point &rOrigin)
void SetScaleY(const Fraction &rScaleY)
const Fraction & GetScaleX() const
void SetScaleX(const Fraction &rScaleX)
GDIMetaFile * GetConnectMetaFile() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void DrawRect(const tools::Rectangle &rRect)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const Color & GetLineColor() const
const MapMode & GetMapMode() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() 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
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
bool GetHighContrastMode() const
const Color & GetHighlightTextColor() const
const SwRect & getFrameArea() const
sal_uInt16 GetVirtPageNum() const
virtual void Calc(vcl::RenderContext *pRenderContext) const
const SwFrame * Lower() const
A page of the document layout.
sal_uInt16 GetPhyPageNum() const
static const vcl::Font & GetEmptyPageFont()
create/return font used to paint the "empty page" string
static void GetBorderAndShadowBoundRect(const SwRect &_rPageRect, const SwViewShell *_pViewShell, OutputDevice const *pRenderContext, SwRect &_orBorderAndShadowBoundRect, const bool bLeftShadow, const bool bRightShadow, const bool bRightSidebar)
get bound rectangle of border and shadow for repaints
bool IsLeftShadowNeeded() const
bool IsRightShadowNeeded() const
static void PaintBorderAndShadow(const SwRect &_rPageRect, const SwViewShell *_pViewShell, bool bPaintLeftShadow, bool bPaintRightShadow, bool bRightSidebar)
paint page border and shadow
sal_uInt16 GetRowOfPage(sal_uInt16 _nPageNum) const
determine row the page with the given number is in
static constexpr SwTwips gnXFree
number of horizontal and vertical twips for spacing between the pages.
bool mbLayoutSizesValid
boolean indicating, if the calculated print preview layout sizes ( windows size in twips,...
static constexpr SwTwips gnYFree
void CalcPreviewDataForPage(const SwPageFrame &_rPage, const Point &_rPreviewOffset, PreviewPage *_opPreviewPage)
determines preview data for a given page and a given preview offset
void MarkNewSelectedPage(const sal_uInt16 _nSelectedPage)
paint to mark new selected page
SwViewShell & mrParentViewShell
view shell the print preview is generated for.
tools::Rectangle maPaintedPreviewDocRect
bool Prepare(const sal_uInt16 _nProposedStartPageNum, const Point &rProposedStartPos, const Size &_rPxWinSize, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect, const bool _bStartWithPageAtFirstCol=true)
prepare paint of page preview
void Repaint(const tools::Rectangle &rInvalidCoreRect) const
repaint pages on page preview
void CalcDocPreviewPaintRect()
calculate painted preview document rectangle
void CalcStartValuesForSelectedPageMove(const sal_Int16 _nHoriMove, const sal_Int16 _nVertMove, sal_uInt16 &_orNewSelectedPage, sal_uInt16 &_orNewStartPage, Point &_orNewStartPos) const
calculate data to bring new selected page into view.
bool mbDoesLayoutColsFitIntoWindow
void CalcAdditionalPaintOffset()
calculate additional paint offset
bool mbPaintInfoValid
boolean indicating, if the paint information ( physical number of start page, start column and row,...
void ClearPreviewLayoutSizes()
helper method to clear preview page layout sizes
bool mbDoesLayoutRowsFitIntoWindow
sal_uInt16 GetColOfPage(sal_uInt16 _nPageNum) const
determine column the page with the given number is in
Size GetPreviewDocSize() const
bool mbBookPreviewModeToggled
void ReInit()
method to adjust page preview layout to document changes
void CalcPreviewPages()
calculate preview pages
void Clear_()
clear internal data about current page preview
bool SetBookPreviewMode(const bool _bEnableBookPreview, sal_uInt16 &_onStartPageNum, tools::Rectangle &_orDocPreviewPaintRect)
enable/disable book preview
SwTwips GetWinPagesScrollAmount(const sal_Int16 _nWinPagesToScroll) const
determine preview window page scroll amount
void PaintSelectMarkAtPage(vcl::RenderContext &rRenderContext, const PreviewPage *_aSelectedPreviewPage) const
paint selection mark at page
void Init(const sal_uInt16 _nCols, const sal_uInt16 _nRows, const Size &_rPxWinSize)
init page preview layout
bool IsPageVisible(const sal_uInt16 _nPageNum) const
determines, if page with given page number is visible in preview
bool Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rOutRect) const
paint prepared preview
sal_uInt16 mnPaintStartCol
Size GetPreviewPageSizeByPageNum(sal_uInt16 _nPageNum) const
get size of a preview page by its physical page number
SwPagePreviewLayout(SwViewShell &_rParentViewShell, const SwRootFrame &_rLayoutRootFrame)
constructor of <SwPagePreviewLayout>
sal_uInt16 ConvertRelativeToAbsolutePageNum(sal_uInt16 _nRelPageNum) const
Convert relative to absolute page numbers (see PrintEmptyPages)
const SwRootFrame & mrLayoutRootFrame
top layout frame of the layout for accessing the pages
Point maAdditionalPaintOffset
bool mbLayoutInfoValid
boolean indicating, if the layout information (number of columns and rows) are valid.
bool IsPreviewPosInDocPreviewPage(const Point &rPreviewPos, Point &_orDocPos, bool &_obPosInEmptyPage, sal_uInt16 &_onPageNum) const
checks, if given position is inside a shown document page
sal_uInt16 mnPaintStartRow
sal_uInt16 mnPaintPhyStartPageNum
sal_uInt16 ConvertAbsoluteToRelativePageNum(sal_uInt16 _nAbsPageNum) const
Convert absolute to relative page numbers (see PrintEmptyPages)
SwTwips mnPreviewLayoutWidth
sal_uInt16 GetVirtPageNumByPageNum(sal_uInt16 _nPageNum) const
get virtual page number by its physical page number
bool mbNewLayoutDuringPaint
Point maPaintPreviewDocOffset
bool PreviewLayoutValid() const
tools::Rectangle maPreviewDocRect
Point GetPreviewStartPosForNewScale(const Fraction &_aNewScale, const Fraction &_aOldScale, const Size &_aNewWinSize) const
calculate start position for new scale
void ApplyNewZoomAtViewShell(sal_uInt8 _aNewZoom)
apply new zoom at given view shell
std::vector< std::unique_ptr< PreviewPage > > maPreviewPages
Point maPaintStartPageOffset
const PreviewPage * GetPreviewPageByPageNum(const sal_uInt16 _nPageNum) const
get preview page by physical page number
sal_uInt16 mnSelectedPageNum
SwTwips mnPreviewLayoutHeight
void CalcPreviewLayoutSizes()
calculate page preview layout sizes
void ClearPreviewPageData()
helper method to clear data in preview page vectors
bool mbInPaint
#i22014# - internal booleans to indicate, that a new print preview layout has been created during a p...
bool IsPrintEmptyPages() const
Of course Writer needs its own rectangles.
void Pos(const Point &rNew)
void SSize(const Size &rNew)
tools::Rectangle SVRect() const
The root element of a Writer document layout.
bool IsSuperfluous() const
SwPageFrame * GetPageByPageNum(sal_uInt16 _nPageNum) const
Get page frame by physical page number looping through the lowers, which are page frame,...
sal_uInt16 GetZoom() const
void SetZoomType(SvxZoomType eZoom_)
void SetZoom(sal_uInt16 n)
SwPageFrame * m_pFirstVisiblePage
Color GetRetoucheColor() const
void UpdateAccessiblePreview(const std::vector< std::unique_ptr< PreviewPage > > &_rPreviewPages, const Fraction &_rScale, const SwPageFrame *_pSelectedPageFrame, const Size &_rPreviewWinSize)
update data for accessible preview change method signature due to new page preview functionality
vcl::RenderContext * GetOut() const
void DLPrePaint2(const vcl::Region &rRegion)
SAL_DLLPRIVATE void PaintDesktop_(const SwRegionRects &rRegion)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
const SwViewOption * GetViewOptions() const
virtual void ApplyViewOptions(const SwViewOption &rOpt)
void DLPostPaint2(bool bPaintFormLayer)
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
SwRect maVisArea
The modern version of VisArea.
vcl::Window * GetWin() const
void SetOut(vcl::RenderContext *pOut)
const AllSettings & GetSettings() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
void SwCalcPixStatics(vcl::RenderContext const *pOut)
Set borders alignment statics Adjustment for 'small' twip-to-pixel relations: For 'small' twip-to-pix...
data structure for a preview page in the current preview layout
const SwPageFrame * pPage
OUString SwResId(TranslateId aId)