Detect Writer doc independent of selection, we'll need that later

Change-Id: Ieddbcd3e8b750ec4b32643aec0433f8638ee46ee
Reviewed-on: https://gerrit.libreoffice.org/42495
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
diff --git a/include/svtools/DocumentToGraphicRenderer.hxx b/include/svtools/DocumentToGraphicRenderer.hxx
index 2240b16..80f37df3 100644
--- a/include/svtools/DocumentToGraphicRenderer.hxx
+++ b/include/svtools/DocumentToGraphicRenderer.hxx
@@ -34,12 +34,13 @@ class SVT_DLLPUBLIC DocumentToGraphicRenderer
{
    const css::uno::Reference<css::lang::XComponent>& mxDocument;

    css::uno::Reference<css::frame::XModel>        mxModel;
    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;
    css::uno::Reference<css::frame::XModel>         mxModel;
    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                                            mbIsWriter;

    bool hasSelection() const;

diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx
index 524c30a..5b125bb 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -45,8 +45,22 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent
    mxController( mxModel->getCurrentController() ),
    mxRenderable (mxDocument, uno::UNO_QUERY ),
    mxToolkit( VCLUnoHelper::CreateToolkit() ),
    mbSelectionOnly( bSelectionOnly )
    mbSelectionOnly( bSelectionOnly ),
    mbIsWriter( false )
{
    try
    {
        uno::Reference< lang::XServiceInfo > xServiceInfo( mxDocument, uno::UNO_QUERY);
        if (xServiceInfo.is())
        {
            if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
                mbIsWriter = true;
        }
    }
    catch (const uno::Exception&)
    {
    }

    if (mbSelectionOnly && mxController.is())
    {
        try
@@ -57,18 +71,13 @@ DocumentToGraphicRenderer::DocumentToGraphicRenderer( const Reference<XComponent
                uno::Any aViewSelection( xSelSup->getSelection());
                if (aViewSelection.hasValue())
                {
                    maSelection = aViewSelection;
                    /* FIXME: Writer always has a selection even if nothing is
                     * selected, but passing a selection to
                     * XRenderable::render() it always renders an empty page.
                     * So disable the selection already here. The current page
                     * the cursor is on is rendered. */
                    uno::Reference< lang::XServiceInfo > xServiceInfo( mxDocument, uno::UNO_QUERY);
                    if (xServiceInfo.is())
                    {
                        if (xServiceInfo->supportsService("com.sun.star.text.TextDocument"))
                            maSelection = uno::Any();
                    }
                    if (!mbIsWriter)
                        maSelection = aViewSelection;
                }
            }
        }