summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-10-28 20:23:00 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-10-28 21:41:24 +0200
commite7aa16be823877f2273e75a4e8fe646c28b73731 (patch)
treec3d49fb94d624a36de08969cd5dcf920a47aaec3 /starmath
parent8dda6270f8b9af6fcfba2a3a935612ab5a81c247 (diff)
Move Impl_Print from SmViewShell to SmDocShell
All functionality is in the latter, anyway. This move allows to exclude dependency on existing views from SmModel::render. Change-Id: I3dff855b7f25089439c8afc57904a25a48fd127b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158594 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/document.hxx4
-rw-r--r--starmath/inc/view.hxx19
-rw-r--r--starmath/source/document.cxx314
-rw-r--r--starmath/source/unomodel.cxx13
-rw-r--r--starmath/source/view.cxx317
5 files changed, 322 insertions, 345 deletions
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index ca36a6138a32..e7c767d12df7 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -61,6 +61,7 @@ inline constexpr OUString MATHML_XML = u"MathML XML (Math)"_ustr;
class SmDocShell;
class EditEngine;
class SmEditEngine;
+class SmPrintUIOptions;
class SmPrinterAccess
{
@@ -224,6 +225,9 @@ public:
}
void SetRightToLeft(bool bRTL);
+
+ void Impl_Print(OutputDevice& rOutDev, const SmPrintUIOptions& rPrintUIOptions,
+ tools::Rectangle aOutRect);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index a896cd41bf2d..8b17744d6171 100644
--- a/starmath/inc/view.hxx
+++ b/starmath/inc/view.hxx
@@ -37,6 +37,9 @@ class SmPrintUIOptions;
class SmGraphicAccessible;
class SmGraphicWidget;
+#define MINZOOM sal_uInt16(25)
+#define MAXZOOM sal_uInt16(800)
+
class SmGraphicWindow final : public InterimItemWindow
{
private:
@@ -253,19 +256,6 @@ class SmViewShell final : public SfxViewShell
DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void );
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
- static Size GetTextLineSize(OutputDevice const & rDevice,
- const OUString& rLine);
- static Size GetTextSize(OutputDevice const & rDevice,
- std::u16string_view rText,
- tools::Long MaxWidth);
- static void DrawTextLine(OutputDevice& rDevice,
- const Point& rPosition,
- const OUString& rLine);
- static void DrawText(OutputDevice& rDevice,
- const Point& rPosition,
- std::u16string_view rText,
- sal_uInt16 MaxWidth);
-
virtual SfxPrinter *GetPrinter(bool bCreate = false) override;
virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL) override;
@@ -331,9 +321,6 @@ public:
void Execute( SfxRequest& rReq );
void GetState(SfxItemSet &);
- void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
- tools::Rectangle aOutRect );
-
static bool IsInlineEditEnabled();
// Opens the main help page for the Math module
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 18cdc237944f..91bdcc601ec4 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -24,6 +24,7 @@
#include <comphelper/fileformat.h>
#include <comphelper/accessibletexthelper.hxx>
+#include <comphelper/string.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -1270,4 +1271,317 @@ void SmDocShell::SetRightToLeft(bool bRTL)
Repaint();
}
+static Size GetTextLineSize(OutputDevice const& rDevice, const OUString& rLine)
+{
+ Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
+ const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
+
+ if (nTabPos)
+ {
+ aSize.setWidth(0);
+ sal_Int32 nPos = 0;
+ do
+ {
+ if (nPos > 0)
+ aSize.setWidth(((aSize.Width() / nTabPos) + 1) * nTabPos);
+
+ const OUString aText = rLine.getToken(0, '\t', nPos);
+ aSize.AdjustWidth(rDevice.GetTextWidth(aText));
+ } while (nPos >= 0);
+ }
+
+ return aSize;
+}
+
+static Size GetTextSize(OutputDevice const& rDevice, std::u16string_view rText,
+ tools::Long MaxWidth)
+{
+ Size aSize;
+ Size aTextSize;
+ if (rText.empty())
+ return aTextSize;
+
+ sal_Int32 nPos = 0;
+ do
+ {
+ OUString aLine(o3tl::getToken(rText, 0, '\n', nPos));
+ aLine = aLine.replaceAll("\r", "");
+
+ aSize = GetTextLineSize(rDevice, aLine);
+
+ if (aSize.Width() > MaxWidth)
+ {
+ do
+ {
+ OUString aText;
+ sal_Int32 m = aLine.getLength();
+ sal_Int32 nLen = m;
+
+ for (sal_Int32 n = 0; n < nLen; n++)
+ {
+ sal_Unicode cLineChar = aLine[n];
+ if ((cLineChar == ' ') || (cLineChar == '\t'))
+ {
+ aText = aLine.copy(0, n);
+ if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
+ m = n;
+ else
+ break;
+ }
+ }
+
+ aText = aLine.copy(0, m);
+ aLine = aLine.replaceAt(0, m, u"");
+ aSize = GetTextLineSize(rDevice, aText);
+ aTextSize.AdjustHeight(aSize.Height());
+ aTextSize.setWidth(std::clamp(aSize.Width(), aTextSize.Width(), MaxWidth));
+
+ aLine = comphelper::string::stripStart(aLine, ' ');
+ aLine = comphelper::string::stripStart(aLine, '\t');
+ aLine = comphelper::string::stripStart(aLine, ' ');
+ } while (!aLine.isEmpty());
+ }
+ else
+ {
+ aTextSize.AdjustHeight(aSize.Height());
+ aTextSize.setWidth(std::max(aTextSize.Width(), aSize.Width()));
+ }
+ } while (nPos >= 0);
+
+ return aTextSize;
+}
+
+static void DrawTextLine(OutputDevice& rDevice, const Point& rPosition, const OUString& rLine)
+{
+ Point aPoint(rPosition);
+ const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
+
+ if (nTabPos)
+ {
+ sal_Int32 nPos = 0;
+ do
+ {
+ if (nPos > 0)
+ aPoint.setX(((aPoint.X() / nTabPos) + 1) * nTabPos);
+
+ OUString aText = rLine.getToken(0, '\t', nPos);
+ rDevice.DrawText(aPoint, aText);
+ aPoint.AdjustX(rDevice.GetTextWidth(aText));
+ } while (nPos >= 0);
+ }
+ else
+ rDevice.DrawText(aPoint, rLine);
+}
+
+static void DrawText(OutputDevice& rDevice, const Point& rPosition, std::u16string_view rText,
+ sal_uInt16 MaxWidth)
+{
+ if (rText.empty())
+ return;
+
+ Point aPoint(rPosition);
+ Size aSize;
+
+ sal_Int32 nPos = 0;
+ do
+ {
+ OUString aLine(o3tl::getToken(rText, 0, '\n', nPos));
+ aLine = aLine.replaceAll("\r", "");
+ aSize = GetTextLineSize(rDevice, aLine);
+ if (aSize.Width() > MaxWidth)
+ {
+ do
+ {
+ OUString aText;
+ sal_Int32 m = aLine.getLength();
+ sal_Int32 nLen = m;
+
+ for (sal_Int32 n = 0; n < nLen; n++)
+ {
+ sal_Unicode cLineChar = aLine[n];
+ if ((cLineChar == ' ') || (cLineChar == '\t'))
+ {
+ aText = aLine.copy(0, n);
+ if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
+ m = n;
+ else
+ break;
+ }
+ }
+ aText = aLine.copy(0, m);
+ aLine = aLine.replaceAt(0, m, u"");
+
+ DrawTextLine(rDevice, aPoint, aText);
+ aPoint.AdjustY(aSize.Height());
+
+ aLine = comphelper::string::stripStart(aLine, ' ');
+ aLine = comphelper::string::stripStart(aLine, '\t');
+ aLine = comphelper::string::stripStart(aLine, ' ');
+ } while (GetTextLineSize(rDevice, aLine).Width() > MaxWidth);
+
+ // print the remaining text
+ if (!aLine.isEmpty())
+ {
+ DrawTextLine(rDevice, aPoint, aLine);
+ aPoint.AdjustY(aSize.Height());
+ }
+ }
+ else
+ {
+ DrawTextLine(rDevice, aPoint, aLine);
+ aPoint.AdjustY(aSize.Height());
+ }
+ } while (nPos >= 0);
+}
+
+void SmDocShell::Impl_Print(OutputDevice& rOutDev, const SmPrintUIOptions& rPrintUIOptions,
+ tools::Rectangle aOutRect)
+{
+ const bool bIsPrintTitle = rPrintUIOptions.getBoolValue(PRTUIOPT_TITLE_ROW, true);
+ const bool bIsPrintFrame = rPrintUIOptions.getBoolValue(PRTUIOPT_BORDER, true);
+ const bool bIsPrintFormulaText = rPrintUIOptions.getBoolValue(PRTUIOPT_FORMULA_TEXT, true);
+ SmPrintSize ePrintSize(static_cast<SmPrintSize>(
+ rPrintUIOptions.getIntValue(PRTUIOPT_PRINT_FORMAT, PRINT_SIZE_NORMAL)));
+ const sal_uInt16 nZoomFactor
+ = static_cast<sal_uInt16>(rPrintUIOptions.getIntValue(PRTUIOPT_PRINT_SCALE, 100));
+
+ rOutDev.Push();
+ rOutDev.SetLineColor(COL_BLACK);
+
+ // output text on top
+ if (bIsPrintTitle)
+ {
+ Size aSize600(0, 600);
+ Size aSize650(0, 650);
+ vcl::Font aFont(FAMILY_DONTKNOW, aSize600);
+
+ aFont.SetAlignment(ALIGN_TOP);
+ aFont.SetWeight(WEIGHT_BOLD);
+ aFont.SetFontSize(aSize650);
+ aFont.SetColor(COL_BLACK);
+ rOutDev.SetFont(aFont);
+
+ Size aTitleSize(GetTextSize(rOutDev, GetTitle(), aOutRect.GetWidth() - 200));
+
+ aFont.SetWeight(WEIGHT_NORMAL);
+ aFont.SetFontSize(aSize600);
+ rOutDev.SetFont(aFont);
+
+ Size aDescSize(GetTextSize(rOutDev, GetComment(), aOutRect.GetWidth() - 200));
+
+ if (bIsPrintFrame)
+ rOutDev.DrawRect(tools::Rectangle(
+ aOutRect.TopLeft(), Size(aOutRect.GetWidth(), 100 + aTitleSize.Height() + 200
+ + aDescSize.Height() + 100)));
+ aOutRect.AdjustTop(200);
+
+ // output title
+ aFont.SetWeight(WEIGHT_BOLD);
+ aFont.SetFontSize(aSize650);
+ rOutDev.SetFont(aFont);
+ Point aPoint(aOutRect.Left() + (aOutRect.GetWidth() - aTitleSize.Width()) / 2,
+ aOutRect.Top());
+ DrawText(rOutDev, aPoint, GetTitle(),
+ sal::static_int_cast<sal_uInt16>(aOutRect.GetWidth() - 200));
+ aOutRect.AdjustTop(aTitleSize.Height() + 200);
+
+ // output description
+ aFont.SetWeight(WEIGHT_NORMAL);
+ aFont.SetFontSize(aSize600);
+ rOutDev.SetFont(aFont);
+ aPoint.setX(aOutRect.Left() + (aOutRect.GetWidth() - aDescSize.Width()) / 2);
+ aPoint.setY(aOutRect.Top());
+ DrawText(rOutDev, aPoint, GetComment(),
+ sal::static_int_cast<sal_uInt16>(aOutRect.GetWidth() - 200));
+ aOutRect.AdjustTop(aDescSize.Height() + 300);
+ }
+
+ // output text on bottom
+ if (bIsPrintFormulaText)
+ {
+ vcl::Font aFont(FAMILY_DONTKNOW, Size(0, 600));
+ aFont.SetAlignment(ALIGN_TOP);
+ aFont.SetColor(COL_BLACK);
+
+ // get size
+ rOutDev.SetFont(aFont);
+
+ Size aSize(GetTextSize(rOutDev, GetText(), aOutRect.GetWidth() - 200));
+
+ aOutRect.AdjustBottom(-(aSize.Height() + 600));
+
+ if (bIsPrintFrame)
+ rOutDev.DrawRect(tools::Rectangle(
+ aOutRect.BottomLeft(), Size(aOutRect.GetWidth(), 200 + aSize.Height() + 200)));
+
+ Point aPoint(aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
+ aOutRect.Bottom() + 300);
+ DrawText(rOutDev, aPoint, GetText(),
+ sal::static_int_cast<sal_uInt16>(aOutRect.GetWidth() - 200));
+ aOutRect.AdjustBottom(-200);
+ }
+
+ if (bIsPrintFrame)
+ rOutDev.DrawRect(aOutRect);
+
+ aOutRect.AdjustTop(100);
+ aOutRect.AdjustLeft(100);
+ aOutRect.AdjustBottom(-100);
+ aOutRect.AdjustRight(-100);
+
+ Size aSize(GetSize());
+
+ MapMode OutputMapMode;
+ // PDF export should always use PRINT_SIZE_NORMAL ...
+ if (!rPrintUIOptions.getBoolValue("IsPrinter"))
+ ePrintSize = PRINT_SIZE_NORMAL;
+ switch (ePrintSize)
+ {
+ case PRINT_SIZE_NORMAL:
+ OutputMapMode = MapMode(SmMapUnit());
+ break;
+
+ case PRINT_SIZE_SCALED:
+ if (!aSize.IsEmpty())
+ {
+ Size OutputSize(rOutDev.LogicToPixel(aOutRect.GetSize(), MapMode(SmMapUnit())));
+ Size GraphicSize(rOutDev.LogicToPixel(aSize, MapMode(SmMapUnit())));
+ sal_uInt16 nZ
+ = std::min(o3tl::convert(OutputSize.Width(), 100, GraphicSize.Width()),
+ o3tl::convert(OutputSize.Height(), 100, GraphicSize.Height()));
+ nZ -= 10;
+ Fraction aFraction(std::clamp(nZ, MINZOOM, sal_uInt16(100)), 1);
+
+ OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
+ }
+ else
+ OutputMapMode = MapMode(SmMapUnit());
+ break;
+
+ case PRINT_SIZE_ZOOMED:
+ {
+ Fraction aFraction(nZoomFactor, 100);
+
+ OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
+ break;
+ }
+ }
+
+ aSize = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aSize, OutputMapMode), MapMode(SmMapUnit()));
+
+ Point aPos(aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
+ aOutRect.Top() + (aOutRect.GetHeight() - aSize.Height()) / 2);
+
+ aPos = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aPos, MapMode(SmMapUnit())), OutputMapMode);
+ aOutRect
+ = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aOutRect, MapMode(SmMapUnit())), OutputMapMode);
+
+ rOutDev.SetMapMode(OutputMapMode);
+ rOutDev.SetClipRegion(vcl::Region(aOutRect));
+ DrawFormula(rOutDev, aPos);
+ rOutDev.SetClipRegion();
+
+ rOutDev.Pop();
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 114fb29e43d7..73f1c4b17715 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -1018,17 +1018,6 @@ void SAL_CALL SmModel::render(
if (xModel != pDocSh->GetModel())
return;
- //!! when called via API we may not have an active view
- //!! thus we go and look for a view that can be used.
- SfxViewShell* pViewSh = SfxViewShell::GetFirst( false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
- while (pViewSh && pViewSh->GetObjectShell() != pDocSh)
- pViewSh = SfxViewShell::GetNext( *pViewSh, false /* search non-visible views as well*/, checkSfxViewShell<SmViewShell> );
- SmViewShell *pView = dynamic_cast< SmViewShell *>( pViewSh );
- SAL_WARN_IF( !pView, "starmath", "SmModel::render : no SmViewShell found" );
-
- if (!pView)
- return;
-
SmPrinterAccess aPrinterAccess( *pDocSh );
Size aPrtPaperSize;
@@ -1072,7 +1061,7 @@ void SAL_CALL SmModel::render(
m_pPrintUIOptions.reset(new SmPrintUIOptions);
m_pPrintUIOptions->processProperties( rxOptions );
- pView->Impl_Print( *pOut, *m_pPrintUIOptions, OutputRect );
+ pDocSh->Impl_Print(*pOut, *m_pPrintUIOptions, OutputRect);
// release SmPrintUIOptions when everything is done.
// That way, when SmPrintUIOptions is needed again it will read the latest configuration settings in its c-tor.
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index a2f1b53c19b4..704d15b1ad7a 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -91,9 +91,6 @@
#include <ElementsDockingWindow.hxx>
#include <helpids.h>
-#define MINZOOM sal_uInt16(25)
-#define MAXZOOM sal_uInt16(800)
-
// space around the edit window, in pixels
// fdo#69111: Increased border on the top so that the window is
// easier to tear off.
@@ -1200,320 +1197,6 @@ void SmViewShell::SetZoomFactor( const Fraction &rX, const Fraction &rY )
SfxViewShell::SetZoomFactor( rX, rY );
}
-Size SmViewShell::GetTextLineSize(OutputDevice const & rDevice, const OUString& rLine)
-{
- Size aSize(rDevice.GetTextWidth(rLine), rDevice.GetTextHeight());
- const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
-
- if (nTabPos)
- {
- aSize.setWidth( 0 );
- sal_Int32 nPos = 0;
- do
- {
- if (nPos > 0)
- aSize.setWidth( ((aSize.Width() / nTabPos) + 1) * nTabPos );
-
- const OUString aText = rLine.getToken(0, '\t', nPos);
- aSize.AdjustWidth(rDevice.GetTextWidth(aText) );
- }
- while (nPos >= 0);
- }
-
- return aSize;
-}
-
-Size SmViewShell::GetTextSize(OutputDevice const & rDevice, std::u16string_view rText, tools::Long MaxWidth)
-{
- Size aSize;
- Size aTextSize;
- if (rText.empty())
- return aTextSize;
-
- sal_Int32 nPos = 0;
- do
- {
- OUString aLine( o3tl::getToken(rText, 0, '\n', nPos) );
- aLine = aLine.replaceAll("\r", "");
-
- aSize = GetTextLineSize(rDevice, aLine);
-
- if (aSize.Width() > MaxWidth)
- {
- do
- {
- OUString aText;
- sal_Int32 m = aLine.getLength();
- sal_Int32 nLen = m;
-
- for (sal_Int32 n = 0; n < nLen; n++)
- {
- sal_Unicode cLineChar = aLine[n];
- if ((cLineChar == ' ') || (cLineChar == '\t'))
- {
- aText = aLine.copy(0, n);
- if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
- m = n;
- else
- break;
- }
- }
-
- aText = aLine.copy(0, m);
- aLine = aLine.replaceAt(0, m, u"");
- aSize = GetTextLineSize(rDevice, aText);
- aTextSize.AdjustHeight(aSize.Height() );
- aTextSize.setWidth( std::clamp(aSize.Width(), aTextSize.Width(), MaxWidth) );
-
- aLine = comphelper::string::stripStart(aLine, ' ');
- aLine = comphelper::string::stripStart(aLine, '\t');
- aLine = comphelper::string::stripStart(aLine, ' ');
- }
- while (!aLine.isEmpty());
- }
- else
- {
- aTextSize.AdjustHeight(aSize.Height() );
- aTextSize.setWidth( std::max(aTextSize.Width(), aSize.Width()) );
- }
- }
- while (nPos >= 0);
-
- return aTextSize;
-}
-
-void SmViewShell::DrawTextLine(OutputDevice& rDevice, const Point& rPosition, const OUString& rLine)
-{
- Point aPoint(rPosition);
- const tools::Long nTabPos = rLine.isEmpty() ? 0 : rDevice.approximate_digit_width() * 8;
-
- if (nTabPos)
- {
- sal_Int32 nPos = 0;
- do
- {
- if (nPos > 0)
- aPoint.setX( ((aPoint.X() / nTabPos) + 1) * nTabPos );
-
- OUString aText = rLine.getToken(0, '\t', nPos);
- rDevice.DrawText(aPoint, aText);
- aPoint.AdjustX(rDevice.GetTextWidth(aText) );
- }
- while ( nPos >= 0 );
- }
- else
- rDevice.DrawText(aPoint, rLine);
-}
-
-void SmViewShell::DrawText(OutputDevice& rDevice, const Point& rPosition, std::u16string_view rText, sal_uInt16 MaxWidth)
-{
- if (rText.empty())
- return;
-
- Point aPoint(rPosition);
- Size aSize;
-
- sal_Int32 nPos = 0;
- do
- {
- OUString aLine( o3tl::getToken(rText, 0, '\n', nPos) );
- aLine = aLine.replaceAll("\r", "");
- aSize = GetTextLineSize(rDevice, aLine);
- if (aSize.Width() > MaxWidth)
- {
- do
- {
- OUString aText;
- sal_Int32 m = aLine.getLength();
- sal_Int32 nLen = m;
-
- for (sal_Int32 n = 0; n < nLen; n++)
- {
- sal_Unicode cLineChar = aLine[n];
- if ((cLineChar == ' ') || (cLineChar == '\t'))
- {
- aText = aLine.copy(0, n);
- if (GetTextLineSize(rDevice, aText).Width() < MaxWidth)
- m = n;
- else
- break;
- }
- }
- aText = aLine.copy(0, m);
- aLine = aLine.replaceAt(0, m, u"");
-
- DrawTextLine(rDevice, aPoint, aText);
- aPoint.AdjustY(aSize.Height() );
-
- aLine = comphelper::string::stripStart(aLine, ' ');
- aLine = comphelper::string::stripStart(aLine, '\t');
- aLine = comphelper::string::stripStart(aLine, ' ');
- }
- while (GetTextLineSize(rDevice, aLine).Width() > MaxWidth);
-
- // print the remaining text
- if (!aLine.isEmpty())
- {
- DrawTextLine(rDevice, aPoint, aLine);
- aPoint.AdjustY(aSize.Height() );
- }
- }
- else
- {
- DrawTextLine(rDevice, aPoint, aLine);
- aPoint.AdjustY(aSize.Height() );
- }
- }
- while ( nPos >= 0 );
-}
-
-void SmViewShell::Impl_Print(OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, tools::Rectangle aOutRect )
-{
- const bool bIsPrintTitle = rPrintUIOptions.getBoolValue( PRTUIOPT_TITLE_ROW, true );
- const bool bIsPrintFrame = rPrintUIOptions.getBoolValue( PRTUIOPT_BORDER, true );
- const bool bIsPrintFormulaText = rPrintUIOptions.getBoolValue( PRTUIOPT_FORMULA_TEXT, true );
- SmPrintSize ePrintSize( static_cast< SmPrintSize >( rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_FORMAT, PRINT_SIZE_NORMAL ) ));
- const sal_uInt16 nZoomFactor = static_cast< sal_uInt16 >(rPrintUIOptions.getIntValue( PRTUIOPT_PRINT_SCALE, 100 ));
-
- rOutDev.Push();
- rOutDev.SetLineColor( COL_BLACK );
-
- // output text on top
- if (bIsPrintTitle)
- {
- Size aSize600 (0, 600);
- Size aSize650 (0, 650);
- vcl::Font aFont(FAMILY_DONTKNOW, aSize600);
-
- aFont.SetAlignment(ALIGN_TOP);
- aFont.SetWeight(WEIGHT_BOLD);
- aFont.SetFontSize(aSize650);
- aFont.SetColor( COL_BLACK );
- rOutDev.SetFont(aFont);
-
- Size aTitleSize (GetTextSize(rOutDev, GetDoc()->GetTitle(), aOutRect.GetWidth() - 200));
-
- aFont.SetWeight(WEIGHT_NORMAL);
- aFont.SetFontSize(aSize600);
- rOutDev.SetFont(aFont);
-
- Size aDescSize (GetTextSize(rOutDev, GetDoc()->GetComment(), aOutRect.GetWidth() - 200));
-
- if (bIsPrintFrame)
- rOutDev.DrawRect(tools::Rectangle(aOutRect.TopLeft(),
- Size(aOutRect.GetWidth(), 100 + aTitleSize.Height() + 200 + aDescSize.Height() + 100)));
- aOutRect.AdjustTop(200 );
-
- // output title
- aFont.SetWeight(WEIGHT_BOLD);
- aFont.SetFontSize(aSize650);
- rOutDev.SetFont(aFont);
- Point aPoint(aOutRect.Left() + (aOutRect.GetWidth() - aTitleSize.Width()) / 2,
- aOutRect.Top());
- DrawText(rOutDev, aPoint, GetDoc()->GetTitle(),
- sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
- aOutRect.AdjustTop(aTitleSize.Height() + 200 );
-
- // output description
- aFont.SetWeight(WEIGHT_NORMAL);
- aFont.SetFontSize(aSize600);
- rOutDev.SetFont(aFont);
- aPoint.setX( aOutRect.Left() + (aOutRect.GetWidth() - aDescSize.Width()) / 2 );
- aPoint.setY( aOutRect.Top() );
- DrawText(rOutDev, aPoint, GetDoc()->GetComment(),
- sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
- aOutRect.AdjustTop(aDescSize.Height() + 300 );
- }
-
- // output text on bottom
- if (bIsPrintFormulaText)
- {
- vcl::Font aFont(FAMILY_DONTKNOW, Size(0, 600));
- aFont.SetAlignment(ALIGN_TOP);
- aFont.SetColor( COL_BLACK );
-
- // get size
- rOutDev.SetFont(aFont);
-
- Size aSize (GetTextSize(rOutDev, GetDoc()->GetText(), aOutRect.GetWidth() - 200));
-
- aOutRect.AdjustBottom( -(aSize.Height() + 600) );
-
- if (bIsPrintFrame)
- rOutDev.DrawRect(tools::Rectangle(aOutRect.BottomLeft(),
- Size(aOutRect.GetWidth(), 200 + aSize.Height() + 200)));
-
- Point aPoint (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
- aOutRect.Bottom() + 300);
- DrawText(rOutDev, aPoint, GetDoc()->GetText(),
- sal::static_int_cast< sal_uInt16 >(aOutRect.GetWidth() - 200));
- aOutRect.AdjustBottom( -200 );
- }
-
- if (bIsPrintFrame)
- rOutDev.DrawRect(aOutRect);
-
- aOutRect.AdjustTop(100 );
- aOutRect.AdjustLeft(100 );
- aOutRect.AdjustBottom( -100 );
- aOutRect.AdjustRight( -100 );
-
- Size aSize (GetDoc()->GetSize());
-
- MapMode OutputMapMode;
- // PDF export should always use PRINT_SIZE_NORMAL ...
- if (!rPrintUIOptions.getBoolValue( "IsPrinter" ) )
- ePrintSize = PRINT_SIZE_NORMAL;
- switch (ePrintSize)
- {
- case PRINT_SIZE_NORMAL:
- OutputMapMode = MapMode(SmMapUnit());
- break;
-
- case PRINT_SIZE_SCALED:
- if (!aSize.IsEmpty())
- {
- Size OutputSize(rOutDev.LogicToPixel(aOutRect.GetSize(), MapMode(SmMapUnit())));
- Size GraphicSize(rOutDev.LogicToPixel(aSize, MapMode(SmMapUnit())));
- sal_uInt16 nZ = std::min(o3tl::convert(OutputSize.Width(), 100, GraphicSize.Width()),
- o3tl::convert(OutputSize.Height(), 100, GraphicSize.Height()));
- nZ -= 10;
- Fraction aFraction(std::clamp(nZ, MINZOOM, sal_uInt16(100)), 1);
-
- OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
- }
- else
- OutputMapMode = MapMode(SmMapUnit());
- break;
-
- case PRINT_SIZE_ZOOMED:
- {
- Fraction aFraction( nZoomFactor, 100 );
-
- OutputMapMode = MapMode(SmMapUnit(), Point(), aFraction, aFraction);
- break;
- }
- }
-
- aSize = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aSize, OutputMapMode),
- MapMode(SmMapUnit()));
-
- Point aPos (aOutRect.Left() + (aOutRect.GetWidth() - aSize.Width()) / 2,
- aOutRect.Top() + (aOutRect.GetHeight() - aSize.Height()) / 2);
-
- aPos = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aPos, MapMode(SmMapUnit())),
- OutputMapMode);
- aOutRect = rOutDev.PixelToLogic(rOutDev.LogicToPixel(aOutRect, MapMode(SmMapUnit())),
- OutputMapMode);
-
- rOutDev.SetMapMode(OutputMapMode);
- rOutDev.SetClipRegion(vcl::Region(aOutRect));
- GetDoc()->DrawFormula(rOutDev, aPos);
- rOutDev.SetClipRegion();
-
- rOutDev.Pop();
-}
-
SfxPrinter* SmViewShell::GetPrinter(bool bCreate)
{
SmDocShell* pDoc = GetDoc();