summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-08 15:23:06 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-11 16:28:51 +0200
commit96240e03a0775b0d38399ba8495be8a0f47b96eb (patch)
tree601df9d357e1ea9d6ab08fec1660cbc7a69caef9
parent9eafbcd411c8fc300f7860aa6c047d5712ad8520 (diff)
Add get/setPart to ITiledRenderable, and implement for sw/sc.
Change-Id: Iec3d6374f029149cadf8fb9c9b16fec90146c31e
-rw-r--r--desktop/source/lib/init.cxx47
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h3
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx11
-rw-r--r--include/vcl/ITiledRenderable.hxx16
-rw-r--r--sc/inc/docuno.hxx3
-rw-r--r--sc/source/ui/unoobj/docuno.cxx18
-rw-r--r--sw/inc/unotxdoc.hxx3
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx15
8 files changed, 104 insertions, 12 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 273446f1f142..bde1c508ef6f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -181,7 +181,8 @@ extern "C"
static void doc_destroy(LibreOfficeKitDocument* pThis);
static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions);
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
-static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
+static int doc_getParts(LibreOfficeKitDocument* pThis);
+static int doc_getPart(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
void doc_paintTile(LibreOfficeKitDocument* pThis,
unsigned char* pBuffer,
@@ -210,7 +211,8 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->destroy = doc_destroy;
m_pDocumentClass->saveAs = doc_saveAs;
m_pDocumentClass->getDocumentType = doc_getDocumentType;
- m_pDocumentClass->getNumberOfParts = doc_getNumberOfParts;
+ m_pDocumentClass->getParts = doc_getParts;
+ m_pDocumentClass->getPart = doc_getPart;
m_pDocumentClass->setPart = doc_setPart;
m_pDocumentClass->paintTile = doc_paintTile;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
@@ -421,17 +423,46 @@ static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* p
return LOK_DOCTYPE_OTHER;
}
-static int doc_getNumberOfParts (LibreOfficeKitDocument* pThis)
+static int doc_getParts (LibreOfficeKitDocument* pThis)
{
- (void) pThis;
- // Assume writer document for now.
- return 1;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return 0;
+ }
+
+ return pDoc->getParts();
+}
+
+static int doc_getPart (LibreOfficeKitDocument* pThis)
+{
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return 0;
+ }
+
+ return pDoc->getPart();
}
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
{
- (void) pThis;
- (void) nPart;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->setPart( nPart );
}
void doc_paintTile (LibreOfficeKitDocument* pThis,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index ba4319f70a3d..675eabc5ae5e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -77,8 +77,9 @@ struct _LibreOfficeKitDocumentClass
// Part refers to either indivual sheets in a Spreadsheet, or slides
// in a Slideshow, and has no relevance for wrtier documents.
- int (*getNumberOfParts) (LibreOfficeKitDocument* pThis);
+ int (*getParts) (LibreOfficeKitDocument* pThis);
+ int (*getPart) (LibreOfficeKitDocument* pThis);
void (*setPart) (LibreOfficeKitDocument* pThis,
int nPart);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 427ea833c5a9..32faf26e6291 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -49,9 +49,14 @@ public:
return mpDoc->pClass->getDocumentType(mpDoc);
}
- inline int getNumberOfParts()
+ inline int getParts()
{
- return mpDoc->pClass->getNumberOfParts(mpDoc);
+ return mpDoc->pClass->getParts(mpDoc);
+ }
+
+ inline int getPart()
+ {
+ return mpDoc->pClass->getPart(mpDoc);
}
inline void setPart(int nPart)
@@ -75,7 +80,7 @@ public:
inline void getDocumentSize(long* pWidth, long* pHeight)
{
- mpDoc->getDocumentSize(mpDoc, pWidth, pHeight);
+ mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
}
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index e9cea10af371..55e1b39411f9 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -41,6 +41,22 @@ public:
*/
virtual Size getDocumentSize() = 0;
+ /**
+ * Set the document "part", i.e. slide for a slideshow, and
+ * tab for a spreadsheet.
+ */
+ virtual void setPart( int nPart ) = 0;
+
+ /**
+ * Get the number of parts -- see setPart for further details.
+ */
+ virtual int getParts() = 0;
+
+ /**
+ * Get the currently displayed/selected part -- see setPart for further
+ * details.
+ */
+ virtual int getPart() = 0;
};
} // namespace vcl
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 27575fe66a2c..932017da9b89 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -363,6 +363,9 @@ public:
long nTileWidth,
long nTileHeight ) SAL_OVERRIDE;
virtual Size getDocumentSize() SAL_OVERRIDE;
+ virtual void setPart( int nPart ) SAL_OVERRIDE;
+ virtual int getPart() SAL_OVERRIDE;
+ virtual int getParts() SAL_OVERRIDE;
};
class ScDrawPagesObj : public cppu::WeakImplHelper2<
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 6852d1c1c438..2893974ced06 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -461,6 +461,24 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
nTilePosX, nTilePosY, nTileWidth, nTileHeight );
}
+void ScModelObj::setPart( int nPart )
+{
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ pViewData->SetTabNo( nPart );
+}
+
+int ScModelObj::getParts()
+{
+ ScDocument& rDoc = pDocShell->GetDocument();
+ return rDoc.GetTableCount();
+}
+
+int ScModelObj::getPart()
+{
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ return pViewData->GetTabNo();
+}
+
Size ScModelObj::getDocumentSize()
{
// TODO: not sure what we want to do here, maybe just return the size for a certain
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index a48a8f34bab5..131807135dcb 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -439,6 +439,9 @@ public:
long nTileWidth,
long nTileHeight ) SAL_OVERRIDE;
virtual Size getDocumentSize() SAL_OVERRIDE;
+ virtual void setPart( int nPart ) SAL_OVERRIDE;
+ virtual int getPart() SAL_OVERRIDE;
+ virtual int getParts() SAL_OVERRIDE;
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 9ceee4566add..10f618579510 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3137,6 +3137,21 @@ Size SwXTextDocument::getDocumentSize()
return pViewShell->GetDocSize();
}
+void SwXTextDocument::setPart( int /*nPart*/ )
+{
+}
+
+int SwXTextDocument::getPart()
+{
+ return 0;
+}
+
+int SwXTextDocument::getParts()
+{
+ // For now we treat the document as one large piece.
+ return 1;
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);