30#include <com/sun/star/awt/XDevice.hpp>
31#include <com/sun/star/awt/XToolkit.hpp>
32#include <com/sun/star/text/XPageCursor.hpp>
33#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
34#include <com/sun/star/view/XRenderable.hpp>
35#include <com/sun/star/view/XSelectionSupplier.hpp>
36#include <com/sun/star/beans/PropertyValues.hpp>
37#include <com/sun/star/lang/XServiceInfo.hpp>
38#include <com/sun/star/drawing/XShapes.hpp>
39#include <com/sun/star/drawing/XShape.hpp>
40#include <com/sun/star/frame/XModel.hpp>
45using namespace css::uno;
46using namespace css::lang;
47using namespace css::beans;
50 mxDocument(rxDocument),
52 mxController(
mxModel->getCurrentController() ),
53 mxRenderable (mxDocument,
uno::UNO_QUERY ),
59 uno::Reference< lang::XServiceInfo > xServiceInfo(
mxDocument, uno::UNO_QUERY);
60 if (xServiceInfo.is())
62 if (xServiceInfo->supportsService(
"com.sun.star.text.TextDocument"))
64 else if (xServiceInfo->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
66 else if (xServiceInfo->supportsService(
"com.sun.star.presentation.PresentationDocument"))
72 catch (
const uno::Exception&)
81 uno::Reference< view::XSelectionSupplier > xSelSup(
mxController, uno::UNO_QUERY);
84 uno::Any aViewSelection( xSelSup->getSelection());
97 catch (
const uno::Exception&)
128 Point* pDocumentPosition,
Point* pCalcPagePosition,
Size* pCalcPageSize)
130 Reference< awt::XDevice > xDevice(
mxToolkit->createScreenCompatibleDevice( 32, 32 ) );
140 awt::Size aCalcPageSize;
144 sal_Int32 nPages =
mxRenderable->getRendererCount( selection, renderProperties );
145 if (nPages >= nCurrentPage)
147 const Sequence< beans::PropertyValue > aResult =
mxRenderable->getRenderer(nCurrentPage - 1, selection, renderProperties );
148 for(
const auto& rProperty : aResult )
150 if ( rProperty.Name ==
"PageSize" )
152 rProperty.Value >>= aSize;
154 else if (rProperty.Name ==
"PagePos")
156 rProperty.Value >>= aPos;
158 else if (rProperty.Name ==
"CalcPagePos")
160 rProperty.Value >>= aCalcPos;
162 else if (rProperty.Name ==
"CalcPageContentSize")
164 rProperty.Value >>= aCalcPageSize;
169 if (pDocumentPosition)
171 *pDocumentPosition =
Point(aPos.X, aPos.Y);
173 if (pCalcPagePosition)
175 *pCalcPagePosition =
Point(aCalcPos.X, aCalcPos.Y);
179 *pCalcPageSize =
Size(aCalcPageSize.Width, aCalcPageSize.Height);
182 return Size( aSize.Width, aSize.Height );
186 sal_Int32 nCurrentPage,
187 Size aDocumentSizePixel,
188 Size aTargetSizePixel,
196 Reference< awt::XDevice > xDevice(
mxToolkit->createScreenCompatibleDevice( aTargetSizePixel.
Width(), aTargetSizePixel.
Height() ) );
200 assert( !aDocumentSizePixel.
IsEmpty() && !aTargetSizePixel.
IsEmpty());
202 double fScaleX = aTargetSizePixel.
Width() /
static_cast<double>(aDocumentSizePixel.
Width());
203 double fScaleY = aTargetSizePixel.
Height() /
static_cast<double>(aDocumentSizePixel.
Height());
231 aMtf.
Record( pOutputDev );
240 mxRenderable->render(nCurrentPage - 1, aSelection, renderProps );
271 Reference< awt::XDevice > xDevice(
mxToolkit->createScreenCompatibleDevice( 32, 32 ) );
280 sal_Int32 nPages =
mxRenderable->getRendererCount( selection, renderProperties );
287 Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(
mxModel->getCurrentController(), UNO_QUERY);
288 if (!xTextViewCursorSupplier.is())
290 Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), UNO_QUERY);
291 return xCursor.is() ? xCursor->getPage() : 1;
296 css::uno::Reference< css::drawing::XShapes > & rxShapes,
297 css::uno::Reference< css::drawing::XShape > & rxShape,
298 const css::uno::Reference< css::frame::XController > & rxController )
301 if (rxController.is())
303 uno::Reference< view::XSelectionSupplier > xSelectionSupplier( rxController, uno::UNO_QUERY);
304 if (xSelectionSupplier.is())
306 uno::Any aAny( xSelectionSupplier->getSelection());
307 if (aAny >>= rxShapes)
309 else if (aAny >>= rxShape)
css::uno::Reference< css::frame::XModel2 > mxModel
static OutputDevice * GetDefaultDevice()
const css::uno::Reference< css::lang::XComponent > & mxDocument
Size getDocumentSizeIn100mm(sal_Int32 nCurrentPage, Point *pDocumentPosition=nullptr, Point *pCalcPagePosition=nullptr, Size *pCalcPageSize=nullptr)
std::vector< OUString > maChapterNames
const std::vector< OUString > & getChapterNames() const
Get list of chapter names for a page, current page is set by renderToGraphic().
css::uno::Reference< css::awt::XToolkit > mxToolkit
css::uno::Reference< css::view::XRenderable > mxRenderable
bool hasSelection() const
Graphic renderToGraphic(sal_Int32 nCurrentPage, Size aDocumentSizePixel, Size aTargetSizePixel, Color aPageColor, bool bExtOutDevData)
sal_Int32 getCurrentPage()
sal_Int32 getCurrentPageWriter()
Size getDocumentSizeInPixels(sal_Int32 nCurrentPage)
css::uno::Reference< css::frame::XModel > mxModel
css::uno::Reference< css::frame::XController > mxController
static bool isShapeSelected(css::uno::Reference< css::drawing::XShapes > &rxShapes, css::uno::Reference< css::drawing::XShape > &rxShape, const css::uno::Reference< css::frame::XController > &rxController)
Determine whether rxController has a css::view::XSelectionSupplier at which either a css::drawing::XS...
~DocumentToGraphicRenderer()
css::uno::Any maSelection
css::uno::Any getSelection() const
Always something even if hasSelection() is false (in which case the selection is mxDocument).
DocumentToGraphicRenderer(const css::uno::Reference< css::lang::XComponent > &xDocument, bool bSelectionOnly)
void SetAntialiasing(AntialiasingFlags nMode)
void SetExtOutDevData(vcl::ExtOutDevData *pExtOutDevData)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
const MapMode & GetMapMode() const
AntialiasingFlags GetAntialiasing() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static OutputDevice * GetOutputDevice(const css::uno::Reference< css::awt::XDevice > &rxDevice)
void SetIsExportBookmarks(const bool bExportBookmarks)
const std::vector< OUString > & GetChapterNames() const
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
std::map< sal_Int32, std::shared_ptr< SetItemPropertyStorage > > PropertyValues