Kaydet (Commit) 65483611 authored tarafından Andrzej Hunt's avatar Andrzej Hunt

LOK: Add getPartName.

By default (i.e. for writer) we can just return an empty string,
and we only actually need to implement ITiledRenderable's
getPartName for components that actually support it (i.e. calc/impress).

Change-Id: I8b381e5d7a8000638b02f763b4bea8ef0226f8e0
üst 5fe0711d
...@@ -184,6 +184,7 @@ static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pT ...@@ -184,6 +184,7 @@ static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pT
static int doc_getParts(LibreOfficeKitDocument* pThis); static int doc_getParts(LibreOfficeKitDocument* pThis);
static int doc_getPart(LibreOfficeKitDocument* pThis); static int doc_getPart(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart); static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart);
void doc_paintTile(LibreOfficeKitDocument* pThis, void doc_paintTile(LibreOfficeKitDocument* pThis,
unsigned char* pBuffer, unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight, const int nCanvasWidth, const int nCanvasHeight,
...@@ -214,6 +215,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument ...@@ -214,6 +215,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->getParts = doc_getParts; m_pDocumentClass->getParts = doc_getParts;
m_pDocumentClass->getPart = doc_getPart; m_pDocumentClass->getPart = doc_getPart;
m_pDocumentClass->setPart = doc_setPart; m_pDocumentClass->setPart = doc_setPart;
m_pDocumentClass->getPartName = doc_getPartName;
m_pDocumentClass->paintTile = doc_paintTile; m_pDocumentClass->paintTile = doc_paintTile;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize; m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
...@@ -469,6 +471,25 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart) ...@@ -469,6 +471,25 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
Application::ReleaseSolarMutex(); Application::ReleaseSolarMutex();
} }
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() );
if (!pDoc)
{
gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
return 0;
}
OUString sName = pDoc->getPartName( nPart );
OString aString = OUStringToOString(sName, RTL_TEXTENCODING_UTF8);
char* pMemory = (char*) malloc(aString.getLength() + 1);
strcpy(pMemory, aString.getStr());
return pMemory;
}
void doc_paintTile (LibreOfficeKitDocument* pThis, void doc_paintTile (LibreOfficeKitDocument* pThis,
unsigned char* pBuffer, unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight, const int nCanvasWidth, const int nCanvasHeight,
......
...@@ -83,6 +83,9 @@ struct _LibreOfficeKitDocumentClass ...@@ -83,6 +83,9 @@ struct _LibreOfficeKitDocumentClass
void (*setPart) (LibreOfficeKitDocument* pThis, void (*setPart) (LibreOfficeKitDocument* pThis,
int nPart); int nPart);
char* (*getPartName) (LibreOfficeKitDocument* pThis,
int nPart);
// Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight // Get a pointer to a raw array, of size 3*nCanvasWidth*nCanvasHeight
// Basebmp's bitmap device seems to round the width up if needed // Basebmp's bitmap device seems to round the width up if needed
// for its internal buffer, i.e. the rowstride for the buffer may be larger // for its internal buffer, i.e. the rowstride for the buffer may be larger
......
...@@ -64,6 +64,11 @@ public: ...@@ -64,6 +64,11 @@ public:
mpDoc->pClass->setPart(mpDoc, nPart); mpDoc->pClass->setPart(mpDoc, nPart);
} }
inline char* getPartName(int nPart)
{
return mpDoc->pClass->getPartName(mpDoc, nPart);
}
inline void paintTile( inline void paintTile(
unsigned char* pBuffer, unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasWidth,
......
...@@ -57,6 +57,16 @@ public: ...@@ -57,6 +57,16 @@ public:
* details. * details.
*/ */
virtual int getPart() = 0; virtual int getPart() = 0;
/**
* Get the name of the currently displayed part, i.e. sheet in a spreadsheet
* or slide in a presentation.
*/
virtual OUString getPartName(int nPart)
{
(void) nPart;
return "";
}
}; };
} // namespace vcl } // namespace vcl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment