summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-13 09:10:08 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-08-13 09:27:47 +0200
commit8da923dfa6663197aab6f53ac03b97a3ab8fab40 (patch)
tree1f4a4f3c637a9b140b168c23c6e6818d25be0ea8 /desktop
parent8a1ad93aa41e1749eb6f1eedf1f25015d15f41e7 (diff)
reduce code duplication in LOK init.cxx
Change-Id: I65335a2d0fb6e1ff46e3302463fbcf396fbea215
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx39
1 files changed, 19 insertions, 20 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 53e49e3b0d56..60c53fb16bf6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -59,6 +59,7 @@
#endif
using namespace css;
+using namespace vcl;
using namespace utl;
using namespace boost;
@@ -265,6 +266,17 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
}
};
+namespace
+{
+
+ITiledRenderable* getTiledRenderable(LibreOfficeKitDocument* pThis)
+{
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+ return dynamic_cast<ITiledRenderable*>(pDocument->mxComponent.get());
+}
+
+} // anonymous namespace
+
// Wonder global state ...
static uno::Reference<css::uno::XComponentContext> xContext;
static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
@@ -431,9 +443,7 @@ static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* p
static int doc_getParts (LibreOfficeKitDocument* pThis)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -445,9 +455,7 @@ static int doc_getParts (LibreOfficeKitDocument* pThis)
static int doc_getPart (LibreOfficeKitDocument* pThis)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -459,9 +467,7 @@ static int doc_getPart (LibreOfficeKitDocument* pThis)
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -474,9 +480,7 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -494,9 +498,7 @@ static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
static void doc_setPartMode(LibreOfficeKitDocument* pThis,
LibreOfficeKitPartMode ePartMode)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -538,9 +540,8 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
SAL_INFO( "lok.tiledrendering", "paintTile: painting [" << nTileWidth << "x" << nTileHeight <<
"]@(" << nTilePosX << ", " << nTilePosY << ") to [" <<
nCanvasWidth << "x" << nCanvasHeight << "]px" );
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
@@ -583,9 +584,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight)
{
- LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
-
- ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
if (pDoc)
{
Size aDocumentSize = pDoc->getDocumentSize();