[Libreoffice-commits] core.git: Branch 'feature/gtkbmptiledviewer2' - 2 commits - desktop/source include/LibreOfficeKit
Andrzej Hunt
andrzej.hunt at collabora.com
Fri Jun 13 07:01:17 PDT 2014
desktop/source/lib/init.cxx | 147 ++++++++++++++++++++------------
include/LibreOfficeKit/LibreOfficeKit.h | 9 +
2 files changed, 100 insertions(+), 56 deletions(-)
New commits:
commit 0a6016aa24ea4a18306aaa73ea682aed34175eca
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 15:00:42 2014 +0100
LIBLOK: implement getDocumentType, make doctypes unique.
Change-Id: I6cf810af55284cb6ddd9e0bfd879fd19508d127a
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index a8c0532..1c23bb8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -290,31 +290,23 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* sUrl
try
{
- uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
- uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
-
- MediaDescriptor aMediaDescriptor(aSequence);
- OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
- OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+ const ExtensionMap* pMap;
- if (aDocumentService.isEmpty())
+ switch (doc_getDocumentType(pThis))
{
- gImpl->maLastExceptionMsg = "unknown document type";
- return false;
- }
-
- const ExtensionMap* pMap;
- if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ case LOK_DOCTYPE_SPREADSHEET:
pMap = (const ExtensionMap*) aCalcExtensionMap;
- else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ break;
+ case LOK_DOCTYPE_PRESENTATION:
pMap = (const ExtensionMap*) aImpressExtensionMap;
- else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ break;
+ case LOK_DOCTYPE_DRAWING:
pMap = (const ExtensionMap*) aDrawExtensionMap;
- else if (aDocumentService == "com.sun.star.text.TextDocument")
+ break;
+ case LOK_DOCTYPE_TEXT:
pMap = (const ExtensionMap*) aWriterExtensionMap;
- else
- {
- gImpl->maLastExceptionMsg = "unknown document mapping";
+ break;
+ case LOK_DOCTYPE_OTHER:
return false;
}
@@ -369,8 +361,49 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* sUrl
static LibreOfficeKitDocumentType doc_getDocumentType (LibreOfficeKitDocument* pThis)
{
- (void) pThis;
- return WRITER;
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
+ try
+ {
+ uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
+
+ MediaDescriptor aMediaDescriptor(aSequence);
+ OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
+ OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
+
+ if (aDocumentService.isEmpty())
+ {
+ gImpl->maLastExceptionMsg = "unknown document type";
+ return LOK_DOCTYPE_OTHER;
+ }
+
+ if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ {
+ return LOK_DOCTYPE_SPREADSHEET;
+ }
+ else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ {
+ return LOK_DOCTYPE_PRESENTATION;
+ }
+ else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ {
+ return LOK_DOCTYPE_DRAWING;
+ }
+ else if (aDocumentService == "com.sun.star.text.TextDocument")
+ {
+ return LOK_DOCTYPE_TEXT;
+ }
+ else
+ {
+ gImpl->maLastExceptionMsg = "unknown document mapping";
+ }
+ }
+ catch (const uno::Exception& exception)
+ {
+ gImpl->maLastExceptionMsg = "exception: " + exception.Message;
+ }
+ return LOK_DOCTYPE_OTHER;
}
static int doc_getNumberOfParts (LibreOfficeKitDocument* pThis)
@@ -395,30 +428,38 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+
Application::AcquireSolarMutex(1);
+ switch (doc_getDocumentType(pThis))
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ case LOK_DOCTYPE_TEXT:
+ {
+ SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
+ SwDocShell* pDocShell = pTxtDoc->GetDocShell();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
+ *pRowStride = pBmpDev->getScanlineStride();
+ }
+ break;
+ default:
+ break;
}
Application::ReleaseSolarMutex();
}
@@ -429,7 +470,7 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (true) // TODO: test that we have a writer document here (vs calc/impress/etc.)
+ if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
SwDocShell* pDocShell = pTxtDoc->GetDocShell();
@@ -439,6 +480,11 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
+ else
+ {
+ pWidth = 0;
+ pHeight = 0;
+ }
}
static char* lo_getError (LibreOfficeKit *pThis)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 91ecb35..da5937a 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -21,10 +21,11 @@ typedef struct _LibreOfficeKitDocument LibreOfficeKitDocument;
#ifdef LOK_USE_UNSTABLE_API
typedef enum
{
- WRITER,
- SPREADSHEET,
- PRESENTATION,
- OTHER
+ LOK_DOCTYPE_TEXT,
+ LOK_DOCTYPE_SPREADSHEET,
+ LOK_DOCTYPE_PRESENTATION,
+ LOK_DOCTYPE_DRAWING,
+ LOK_DOCTYPE_OTHER
}
LibreOfficeKitDocumentType;
#endif // LOK_USE_UNSTABLE_API
commit bd120a560d07292add6ff6a23010ef2017ed6783
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 14:15:10 2014 +0100
Revert "Add the full sofficerc for LibLO."
This reverts commit 09e0734d10d91e84012ee9e2766dbd205ffd031a.
This seemingly isn't really needed (however using the full sofficerc
avoids some warnings being printed, specifically:
warn:ucb.ucp.gio:4638:1:ucb/source/ucp/gio/gio_content.cxx:378: ignoring GError "Operation not supported" for <***RECURSION DETECTED***/log.txt>
and
warn:basic:4638:1:basic/source/uno/namecont.cxx:989: Cannot access extensions!
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d8b4956..a8c0532 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -473,19 +473,16 @@ static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
static void initialize_uno(const OUString &aAppURL)
{
- // without rendering we can simply use fundamentalrc, and manually add some
- // parameters below, however we won't be able to run the soffice_main
- // thread in that case.
- rtl::Bootstrap::setIniFilename( aAppURL + "/sofficerc" );
-
-// rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
-// "xcsxcu:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
-// "res:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
-// // "bundledext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
-// // "sharedext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
-// // "userext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
-// // "user:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
-// );
+ rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
+
+ rtl::Bootstrap::set( "CONFIGURATION_LAYERS",
+ "xcsxcu:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
+ "res:${BRAND_BASE_DIR}/" LIBO_SHARE_FOLDER "/registry "
+// "bundledext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini " );
+// "sharedext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+// "userext:${${BRAND_BASE_DIR}/" LIBO_ETC_FOLDER "/unorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+// "user:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/bootstraprc:UserInstallation}/user/registrymodifications.xcu"
+ );
xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf(stderr, "Uno initialized %d\n", xContext.is());
More information about the Libreoffice-commits
mailing list