Introduce DocumentToGraphicRenderer::hasSelection() and maSelection
Change-Id: Ib7a9df04eb1b8646e20f58c3f9af3ee2dbbb13db Reviewed-on: https://gerrit.libreoffice.org/42489 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
@@ -38,8 +38,14 @@ class SVT_DLLPUBLIC DocumentToGraphicRenderer
|
||||
css::uno::Reference<css::frame::XController> mxController;
|
||||
css::uno::Reference<css::view::XRenderable> mxRenderable;
|
||||
css::uno::Reference<css::awt::XToolkit> mxToolkit;
|
||||
css::uno::Any maSelection;
|
||||
bool mbSelectionOnly;
|
||||
|
||||
bool hasSelection() const;
|
||||
|
||||
/** Always something even if hasSelection() is false (in which case the
|
||||
selection is mxDocument).
|
||||
*/
|
||||
css::uno::Any getSelection() const;
|
||||
|
||||
sal_Int32 getCurrentPageWriter();
|
||||
|
@@ -46,6 +46,22 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent
|
||||
mxToolkit( VCLUnoHelper::CreateToolkit() ),
|
||||
mbSelectionOnly( bSelectionOnly )
|
||||
{
|
||||
if (mbSelectionOnly && mxController.is())
|
||||
{
|
||||
try
|
||||
{
|
||||
uno::Reference< view::XSelectionSupplier > xSelSup( mxController, uno::UNO_QUERY);
|
||||
if (xSelSup.is())
|
||||
{
|
||||
uno::Any aViewSelection( xSelSup->getSelection());
|
||||
if (aViewSelection.hasValue())
|
||||
maSelection = aViewSelection;
|
||||
}
|
||||
}
|
||||
catch (const uno::Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DocumentToGraphicRenderer::~DocumentToGraphicRenderer()
|
||||
@@ -58,26 +74,18 @@ Size DocumentToGraphicRenderer::getDocumentSizeInPixels(sal_Int32 nCurrentPage)
|
||||
return Application::GetDefaultDevice()->LogicToPixel( aSize100mm, MapUnit::Map100thMM );
|
||||
}
|
||||
|
||||
bool DocumentToGraphicRenderer::hasSelection() const
|
||||
{
|
||||
return maSelection.hasValue();
|
||||
}
|
||||
|
||||
uno::Any DocumentToGraphicRenderer::getSelection() const
|
||||
{
|
||||
uno::Any aSelection;
|
||||
aSelection <<= mxDocument; // default: render whole document
|
||||
if (mbSelectionOnly && mxController.is())
|
||||
{
|
||||
try
|
||||
{
|
||||
uno::Reference< view::XSelectionSupplier > xSelSup( mxController, uno::UNO_QUERY);
|
||||
if (xSelSup.is())
|
||||
{
|
||||
uno::Any aViewSelection( xSelSup->getSelection());
|
||||
if (aViewSelection.hasValue())
|
||||
aSelection = aViewSelection;
|
||||
}
|
||||
}
|
||||
catch (const uno::Exception&)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (hasSelection())
|
||||
aSelection <<= maSelection;
|
||||
else
|
||||
aSelection <<= mxDocument; // default: render whole document
|
||||
return aSelection;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user