[Libreoffice-commits] core.git: Branch 'feature/gtkbmptiledviewer2' - 166 commits - accessibility/inc accessibility/source avmedia/source basctl/source basegfx/source basic/source binaryurp/source canvas/source chart2/inc chart2/opengl chart2/Package_opengl.mk chart2/source codemaker/source comphelper/source compilerplugins/clang configmgr/source connectivity/source cppcanvas/source cppuhelper/source cui/source dbaccess/source desktop/Library_sofficeapp.mk desktop/source desktop/uiconfig editeng/source extensions/AllLangResTarget_bib.mk extensions/inc extensions/source extensions/uiconfig extensions/UIConfig_sbibliography.mk external/libmwaw external/libodfgen external/librevenge external/libwps extras/source filter/source forms/source formula/inc formula/Module_formula.mk formula/source formula/uiconfig formula/UIConfig_formula.mk framework/source helpcompiler/inc helpcompiler/source helpcontent2 hwpfilter/source idlc/inc idlc/source include/basebmp include/basegfx include/basic include/canvas i nclude/codemaker include/com include/comphelper include/editeng include/filter include/jvmaccess include/LibreOfficeKit include/oox include/rtl include/sal include/sfx2 include/sot include/svl include/svtools include/svx include/tools include/unotest include/unotools include/vcl include/xmloff include/xmlreader jvmaccess/source jvmfwk/source l10ntools/source libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Library_libreofficekitgtk.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa libreofficekit/source lingucomponent/source linguistic/source lotuswordpro/source odk/source officecfg/registry oox/source qadevOOo/tests registry/source reportdesign/inc reportdesign/source Repository.mk rsc/inc rsc/source sal/osl sc/inc sc/source sd/inc sd/Library_sd.mk sd/qa sd/source sd/uiconfig sfx2/source shell/source slideshow/source smoketest/libtest.cxx solenv/gbuild soltools/mkdepend sot/source stoc/source svl/CppunitTest_svl_itempool.mk svl/CppunitTest_svl_items.mk svl/Modul e_svl.mk svl/qa svl/source svtools/source svx/inc svx/Library_svx.mk svx/source svx/uiconfig svx/UIConfig_svx.mk sw/inc sw/Library_sw.mk sw/qa sw/source sw/uiconfig sw/UIConfig_swriter.mk sysui/desktop test/source toolkit/Library_tk.mk tools/source ucb/source UnoControls/inc UnoControls/source unotest/source unotools/source unusedcode.easy uui/source vcl/generic vcl/headless vcl/inc vcl/Library_vcl.mk vcl/osx vcl/quartz vcl/source vcl/unx wizards/com writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/source xmloff/CppunitTest_xmloff_uxmloff.mk xmloff/inc xmloff/Library_xo.mk xmloff/source xmlreader/source xmlsecurity/source
Andrzej Hunt
andrzej.hunt at collabora.com
Fri Jun 20 02:04:57 PDT 2014
Rebased ref, commits from common ancestor:
commit 325d7c94efebe4a5f98678352bdc8988136fef5d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:51:15 2014 +0100
Use full sofficerc for LOK.
Otherwise we get segfaults in cppu::idefaultConstructElements when exiting,
in addition to complaints of:
ignoring GError "Operation not supported" for <***RECURSION DETECTED***/log.txt>
Change-Id: If2f56873f50ba957288d1e5591db967d248ee7a4
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2db3875..8371f5d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -527,16 +527,7 @@ static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
static void initialize_uno(const OUString &aAppURL)
{
- 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"
- );
+ rtl::Bootstrap::setIniFilename( aAppURL + "/sofficerc" );
xContext = cppu::defaultBootstrap_InitialComponentContext();
fprintf(stderr, "Uno initialized %d\n", xContext.is());
commit 598242f9bf1f8ed647c83059f6144676c7a87c79
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:38:50 2014 +0100
Don't scale grid and cell dimensions multiple times.
Previously we had multiple layers of scaling, with rounding
errors propagating, leading to up to 5% differences in expected
and rendered sheet widths -- for tiled rendering dimensions have
to scale accurately as we may paint the same tile at multiple zoom
levels, by eliminating multiple scaling and letting the output
device instead deal with the scaling once we can eliminate these
errors. (However currently rendering of text/images isn't quite right.)
Change-Id: I0a725fd5c030f3c089c2bbd25947088c321eb2d4
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index f30f8ab..86bbbd3 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -280,7 +280,7 @@ void ScDocument::FillInfo(
RowInfo* pThisRowInfo = &pRowInfo[nArrRow];
pThisRowInfo->pCellInfo = NULL; // wird unten belegt
- sal_uInt16 nHeight = (sal_uInt16) ( nDocHeight * fRowScale );
+ sal_uInt16 nHeight = nDocHeight;
if (!nHeight)
nHeight = 1;
@@ -395,11 +395,7 @@ void ScDocument::FillInfo(
{
if (!ColHidden(nX, nTab))
{
- sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale);
- if (!nThisWidth)
- nThisWidth = 1;
-
- pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth;
+ pRowInfo[0].pCellInfo[nArrCol].nWidth = GetColWidth( nX, nTab );
}
}
}
@@ -420,9 +416,7 @@ void ScDocument::FillInfo(
// TODO: Optimize this loop.
if (!ColHidden(nX, nTab))
{
- sal_uInt16 nThisWidth = (sal_uInt16) (GetColWidth( nX, nTab ) * fColScale);
- if (!nThisWidth)
- nThisWidth = 1;
+ int nThisWidth = GetColWidth( nX, nTab );
pRowInfo[0].pCellInfo[nArrCol].nWidth = nThisWidth; //! dies sollte reichen
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 2fd0a9e..89b6f26 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -712,7 +712,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
else
aOutputData.SetSolidBackground(true);
- pContentDev->SetMapMode(MAP_PIXEL);
aOutputData.DrawDocumentBackground();
if ( bGridFirst && ( bGrid || bPage ) )
@@ -921,18 +920,27 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
+ // Scaling. Must convert from pixels to TWIPs. We know
+ // that VirtualDevices use a DPI of 96. We might as well do this
+ // calculation now, rather than after another dimension conversion,
+ // to minimise errors.
+ Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
+ Fraction( nTileWidth);
+ Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
+ Fraction( nTileHeight);
+
+ // Now scale back to 100th mm dimensions.
+ nTilePosX = nTilePosX * 2540L / 1440L;
+ nTilePosY = nTilePosY * 2540L / 1440L;
+
+ nTileWidth = nTileWidth * 2540L / 1440L;
+ nTileHeight = nTileHeight * 2540L / 1440L;
+
rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) );
- // setup the output device to draw the tile
MapMode aMapMode( rDevice.GetMapMode() );
- aMapMode.SetMapUnit( MAP_TWIP );
- aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) );
+ aMapMode.SetMapUnit( MAP_100TH_MM );
+ aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) ); // size
- // Scaling. Must convert from pixels to twips. We know
- // that VirtualDevises use a DPI of 96.
- Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
- Fraction( nTileWidth);
- Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
- Fraction( nTileHeight);
aMapMode.SetScaleX( scaleX );
aMapMode.SetScaleY( scaleY );
rDevice.SetMapMode( aMapMode );
commit c725ed8a0dc1864ac5f8ea3213cb33dcfdda2934
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 09:35:16 2014 +0100
Return TWIPS for calc document size.
We already use TWIPS for other uses of tiled rendering, so might
as well stay consistent.
Change-Id: I5897480f152c1ee9734443296d152436a049e32d
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index eccb895..614d219 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -322,10 +322,18 @@ public:
virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
+ // Paint a tile -- all tile dimensions are in TWIPS.
+ // It is possible to request an infinitely large area, i.e. you are not
+ // restricted to the area in GetDataAreaSize.
void PaintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight );
+ // Get the area in the document that contains renderable content. This
+ // is primarily a guide as to the area that should be rendered for read
+ // only documents, however for writeable documents you probably want to
+ // dynamically grab more cells in case the user wants to write to them etc.
+ // This returns a size in TWIPS, suitable for use in PaintTile.
Size GetDataAreaSize();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index da0756c..2fd0a9e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -403,11 +403,11 @@ Size ScGridWindow::GetDataAreaSize()
nY += pDoc->GetRowHeight( i, nTab );
}
- // TODO: the scaling is wrong.
- // TODO: this also ignores any images / etc., which could be outside
+ // TODO: this ignores any images / etc., which could be outside
// the data area.
- return Size( nX, nY );
+ // This doesn't include the final (bottom & right) borders...
+ return Size( nX * 1440L / 2540L, nY * 1440L / 2540L );
}
// Draw ----------------------------------------------------------------
commit 0af6d73e57c6aaa742b63d951324d4a8713269ec
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 18 09:33:16 2014 +0100
Implement data area size retrieval.
The scaling is wrong, but seems to work in principle
(i.e. we get roughly 1.5x the correct size).
Change-Id: I6db1986e6cb1e5f3889ec3a462d999a9eab57331
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 84fcf8a..eccb895 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -326,6 +326,7 @@ public:
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight );
+ Size GetDataAreaSize();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 6922e94..5b30d81 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -463,10 +463,15 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
Size ScModelObj::getDocumentSize()
{
- // TODO: not sure what we want to do here, maybe just return the size for a certain
- // default minimum number of cells, e.g. 100x100 and more if more cells have
- // content?
- return Size( 3200, 3200 );
+ // There seems to be no clear way of getting the grid window for this
+ // particular document, hence we need to hope we get the right window.
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+ // We simply return the data area -- it is however possible to request
+ // tiles to be rendered outside this area, ie this is the minimum that
+ // the client should allow the user to see.
+ return pGridWindow->GetDataAreaSize();
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 8fd806c..da0756c 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -380,6 +380,35 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = false;
}
+Size ScGridWindow::GetDataAreaSize()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nStartCol = 0, nEndCol = MAXCOL;
+ SCROW nStartRow = 0, nEndRow = MAXROW;
+
+ SCTAB nTab = pViewData->GetTabNo();
+
+ pDoc->ShrinkToDataArea( nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow );
+
+ long nX = 0;
+ for ( SCCOL i = 0; i <= nEndCol; i++ )
+ {
+ nX += pDoc->GetColWidth( i, nTab );
+ }
+
+ long nY = 0;
+ for ( SCROW i = 0; i <= nEndRow; i++ )
+ {
+ nY += pDoc->GetRowHeight( i, nTab );
+ }
+
+ // TODO: the scaling is wrong.
+ // TODO: this also ignores any images / etc., which could be outside
+ // the data area.
+
+ return Size( nX, nY );
+}
// Draw ----------------------------------------------------------------
commit 029e7a47e5bf8e08ad121c19ee8a92e01266b2c0
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 18 08:28:04 2014 +0100
Allow overriding of device for Paint, and use that for Tiles.
Paint handles figuring out which cells are within the visible area
for us etc.
Gridwin being a Window which paints to itself is a bit of a pain,
since we now need to be able to reroute painting calls to alternative
output devices, however these changes seem to be sufficient to at least
get the cells in the desired tile rendered.
Change-Id: I7bd1434c97acc6e9ef6e1e63cbcf039b987c88e4
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index dede149..84fcf8a 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -292,6 +292,7 @@ protected:
virtual void Resize( const Size& rSize );
virtual void PrePaint() SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
+ virtual void Paint( const Rectangle& rRect, OutputDevice* pOutDev);
virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
virtual void GetFocus() SAL_OVERRIDE;
virtual void LoseFocus() SAL_OVERRIDE;
@@ -361,7 +362,7 @@ public:
using Window::Draw;
void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
ScUpdateMode eMode = SC_UPDATE_ALL,
- OutputDevice* pOutDev = 0 );
+ OutputDevice* pOutDev = 0);
void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9222e2b..8fd806c 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -301,6 +301,11 @@ void ScGridWindow::PrePaint()
void ScGridWindow::Paint( const Rectangle& rRect )
{
+ Paint( rRect, this );
+}
+
+void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
+{
ScDocument* pDoc = pViewData->GetDocument();
if ( pDoc->IsInInterpreter() )
{
@@ -330,7 +335,7 @@ void ScGridWindow::Paint( const Rectangle& rRect )
bIsInPaint = true;
- Rectangle aPixRect = LogicToPixel( rRect );
+ Rectangle aPixRect = pOutDev->LogicToPixel( rRect );
SCCOL nX1 = pViewData->GetPosX(eHWhich);
SCROW nY1 = pViewData->GetPosY(eVWhich);
@@ -371,8 +376,7 @@ void ScGridWindow::Paint( const Rectangle& rRect )
ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
}
- Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen
-
+ Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev ); // nicht weiterzeichnen
bIsInPaint = false;
}
@@ -591,7 +595,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
}
// get logic positions
- aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
+ aDrawingRectLogic = pOutDev->PixelToLogic(aDrawingRectPixel, aDrawMode);
}
// device for document content, used by overlay manager
@@ -849,7 +853,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
DrawRect( Rectangle( aStart,aEnd ) );
SetMapMode(pViewData->GetLogicMode());
- pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ),
+ pEditView->Paint( pOutDev->PixelToLogic( Rectangle( Point( nScrX, nScrY ),
Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) );
SetMapMode(MAP_PIXEL);
}
@@ -911,7 +915,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
pDrawView->AddWindowToPaintView( &rDevice );
}
- Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
+ Paint( Rectangle( Point(nTilePosX, nTilePosY),
+ rDevice.PixelToLogic(Size(nOutputWidth, nOutputHeight))),
+ &rDevice );
if ( pDrawView )
{
commit c9b4965fa30782d070a3ed5eb9535a493631ec0b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 16:19:56 2014 +0100
Calc: Add tiled rendering device to the paint view.
This prevents the previous warnings of
SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), \
this should never be needed
Change-Id: I76cb7c9ed4d45bfcbd297f697314309b4e036f80
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index dd2db46..9222e2b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -34,6 +34,7 @@
#include "gridwin.hxx"
#include "viewdata.hxx"
+#include "drawview.hxx"
#include "output.hxx"
#include "document.hxx"
#include "attrib.hxx"
@@ -903,7 +904,19 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
aMapMode.SetScaleY( scaleY );
rDevice.SetMapMode( aMapMode );
+ ScTabViewShell* pTabViewSh = pViewData->GetViewShell();
+ SdrView* pDrawView = pTabViewSh->GetScDrawView();
+ if ( pDrawView )
+ {
+ pDrawView->AddWindowToPaintView( &rDevice );
+ }
+
Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
+
+ if ( pDrawView )
+ {
+ pDrawView->DeleteWindowFromPaintView( &rDevice );
+ }
}
void ScGridWindow::CheckNeedsRepaint()
commit f55f94e0ba5cef6bd6036aeaf30c0847f9e7f798
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 15:00:02 2014 +0100
Render tiles from calc.
Currently the document size and number of cells to be rendered
is hardcoded, this will need some more work to select the correct
cells for a given tile (i.e. cells from location). Also, there
isn't really a "size" for a calc sheet, so presumably we'd need
to instead return the area containing cells that aren't empty,
whilst still being able to render larger tiles? (And in any case
the client will need to be aware of this and provide an appropriate
interface, i.e. the current LO UI simply extends the sheet ad-infinitum.)
We also currently get some warnings most likely related to the way
we push our OutputDevice into the rendering methods:
SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), \
this should never be needed
Change-Id: Ia9d64d7de6c22d5b401350f88497a7ec106f1973
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index 17b02f8..dede149 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -360,7 +360,8 @@ public:
using Window::Draw;
void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
- ScUpdateMode eMode = SC_UPDATE_ALL );
+ ScUpdateMode eMode = SC_UPDATE_ALL,
+ OutputDevice* pOutDev = 0 );
void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 090f41b..6922e94 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -466,7 +466,7 @@ Size ScModelObj::getDocumentSize()
// TODO: not sure what we want to do here, maybe just return the size for a certain
// default minimum number of cells, e.g. 100x100 and more if more cells have
// content?
- return Size();
+ return Size( 3200, 3200 );
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 67e838c..dd2db46 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -379,8 +379,14 @@ void ScGridWindow::Paint( const Rectangle& rRect )
// Draw ----------------------------------------------------------------
-void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode )
+void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode,
+ OutputDevice* pOutDev )
{
+ if ( !pOutDev )
+ {
+ pOutDev = this;
+ }
+
ScModule* pScMod = SC_MOD();
bool bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
@@ -472,7 +478,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
Fraction aZoomX = pViewData->GetZoomX();
Fraction aZoomY = pViewData->GetZoomY();
- ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
+ ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );
@@ -587,7 +593,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
}
- OutputDevice* pContentDev = this; // device for document content, used by overlay manager
+ // device for document content, used by overlay manager
+ // We usually paint to ourselves, but allow other devices for tiled rendering.
+ OutputDevice* pContentDev = pOutDev;
SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with SdrPaintWindow directly
{
@@ -604,7 +612,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
{
// #i74769# Use new BeginDrawLayers() interface
Region aDrawingRegion(aDrawingRectLogic);
- pTargetPaintWindow = pDrawView->BeginDrawLayers(this, aDrawingRegion);
+ pTargetPaintWindow = pDrawView->BeginDrawLayers(pOutDev, aDrawingRegion);
OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
// #i74769# get target device from SdrPaintWindow, this may be the prerender
@@ -879,13 +887,23 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight )
{
- (void) rDevice;
- (void) nOutputWidth;
- (void) nOutputHeight;
- (void) nTilePosX;
- (void) nTilePosY;
- (void) nTileWidth;
- (void) nTileHeight;
+ rDevice.SetOutputSizePixel( Size( nOutputWidth, nOutputHeight ) );
+ // setup the output device to draw the tile
+ MapMode aMapMode( rDevice.GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ aMapMode.SetOrigin( Point( -nTilePosX, -nTilePosY ) );
+
+ // Scaling. Must convert from pixels to twips. We know
+ // that VirtualDevises use a DPI of 96.
+ Fraction scaleX = Fraction( nOutputWidth, 96 ) * Fraction(1440L) /
+ Fraction( nTileWidth);
+ Fraction scaleY = Fraction( nOutputHeight, 96 ) * Fraction(1440L) /
+ Fraction( nTileHeight);
+ aMapMode.SetScaleX( scaleX );
+ aMapMode.SetScaleY( scaleY );
+ rDevice.SetMapMode( aMapMode );
+
+ Draw( 0, 0, 3, 3, SC_UPDATE_ALL, &rDevice );
}
void ScGridWindow::CheckNeedsRepaint()
commit 7688bf71b8755fa78ff9c503eb639b3d1ccf9152
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 16 13:50:49 2014 +0100
Add tiled rendering outline to Calc.
(No real implementation yet.)
Change-Id: I67b84b554dbb29db449d8c190ef816645a8bff07
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 61881d4..f39b4ae 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -54,6 +54,7 @@
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/interfacecontainer.h>
#include <svl/itemprop.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include "drwlayer.hxx"
class ScDocShell;
@@ -69,6 +70,7 @@ class ScPrintUIOptions;
class ScSheetSaveData;
class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
+ public ::vcl::ITiledRenderable,
public com::sun::star::sheet::XSpreadsheetDocument,
public com::sun::star::document::XActionLockable,
public com::sun::star::sheet::XCalculatable,
@@ -350,6 +352,17 @@ public:
virtual com::sun::star::uno::Sequence< com::sun::star::sheet::opencl::OpenCLPlatform >
SAL_CALL getOpenCLPlatforms()
throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+
+ // ITiledRenderable
+ virtual void paintTile( VirtualDevice& rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
+ virtual Size getDocumentSize() SAL_OVERRIDE;
};
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index df03b88..17b02f8 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -321,6 +321,11 @@ public:
virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
+ void PaintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight );
+
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
void FakeButtonUp();
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 9aeceb7..090f41b 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -96,6 +96,7 @@
#include "platforminfo.hxx"
#include "interpre.hxx"
#include "formulagroup.hxx"
+#include "gridwin.hxx"
#include <columnspanset.hxx>
using namespace com::sun::star;
@@ -446,6 +447,28 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange )
pDocShell->PostPaint( rRange, PAINT_GRID );
}
+void ScModelObj::paintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ // There seems to be no clear way of getting the grid window for this
+ // particular document, hence we need to hope we get the right window.
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+ pGridWindow->PaintTile( rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight );
+}
+
+Size ScModelObj::getDocumentSize()
+{
+ // TODO: not sure what we want to do here, maybe just return the size for a certain
+ // default minimum number of cells, e.g. 100x100 and more if more cells have
+ // content?
+ return Size();
+}
+
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
throw(uno::RuntimeException, std::exception)
{
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 69de77b..67e838c 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -874,6 +874,20 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
pDoc->ClearFormulaContext();
}
+void ScGridWindow::PaintTile( VirtualDevice& rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ (void) rDevice;
+ (void) nOutputWidth;
+ (void) nOutputHeight;
+ (void) nTilePosX;
+ (void) nTilePosY;
+ (void) nTileWidth;
+ (void) nTileHeight;
+}
+
void ScGridWindow::CheckNeedsRepaint()
{
// called at the end of painting, and from timer after background text width calculation
commit 7102f5483ea7ba9b315e2227c8e84b4fc35b580e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:32:44 2014 +0100
Use ITiledRenderable for LIBLOK.
Means that no changes should be required here once calc/impress/draw
support tiled rendering.
Change-Id: I0987d94303f39ba37e29b9ae7b2276e82dc0ccbf
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 671ff12..8a592cc 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -14,7 +14,6 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/desktop/inc \
-I$(SRCDIR)/desktop/source/inc \
-I$(SRCDIR)/desktop/source/deployment/inc \
- -I$(SRCDIR)/sw/inc \
-I$(SRCDIR)/vcl/inc \
))
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5f7dd05..2db3875 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -42,16 +42,10 @@
#include <vcl/graphicfilter.hxx>
#include <vcl/sysdata.hxx>
#include <vcl/virdev.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unotools/syslocaleoptions.hxx>
#include <unotools/mediadescriptor.hxx>
-// Dirty hack -- we go directly into sw -- ideally we need some sort of
-// layer to get the writer shell for tiled rendering
-#include <doc.hxx>
-#include <docsh.hxx>
-#include <unotxdoc.hxx>
-#include <viewsh.hxx>
-
#include <salinst.hxx>
// And let's also grab the SvpSalInstance and SvpSalVirtualDevice
@@ -452,38 +446,32 @@ void doc_paintTile (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;
+ }
Application::AcquireSolarMutex(1);
- switch (doc_getDocumentType(pThis))
{
- 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);
+ pDoc->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();
- }
- break;
- default:
- break;
+ *pRowStride = pBmpDev->getScanlineStride();
}
Application::ReleaseSolarMutex();
}
@@ -494,20 +482,16 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- if (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+ ::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
+ if (pDoc)
{
- SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
- SwDocShell* pDocShell = pTxtDoc->GetDocShell();
- SwDoc* pDoc = pDocShell->GetDoc();
- SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
- Size aDocumentSize = pViewShell->GetDocSize();
+ Size aDocumentSize = pDoc->getDocumentSize();
*pWidth = aDocumentSize.Width();
*pHeight = aDocumentSize.Height();
}
else
{
- pWidth = 0;
- pHeight = 0;
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
}
}
commit 953c1d91221deb40c5382aae568b0d2a3b40a703
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 17:31:42 2014 +0100
Add ITiledRenderable.
We want to have a simple interface that allows access to tiled
rendering without digging into the internals of writer
(and in the future calc/impress/draw).
Change-Id: Ia9c278a48c919333186e5361ff25bb1ab603b846
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
new file mode 100644
index 0000000..fecfd6c
--- /dev/null
+++ b/include/vcl/ITiledRenderable.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_ITILEDRENDERABLE_HXX
+#define INCLUDED_VCL_ITILEDRENDERABLE_HXX
+
+#include <tools/gen.hxx>
+#include <vcl/virdev.hxx>
+
+namespace vcl
+{
+
+class VCL_DLLPUBLIC ITiledRenderable
+{
+public:
+ virtual ~ITiledRenderable() {};
+
+ /**
+ * Paint a tile to a given VirtualDevice.
+ *
+ * Output parameters are measured in pixels, tile parameters are in
+ * twips.
+ */
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) = 0;
+
+ /**
+ * Get the document size in twips.
+ */
+ virtual Size getDocumentSize() = 0;
+
+};
+
+} // namespace vcl
+
+#endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index e43ea2b..a48a8f3 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -67,6 +67,7 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase4.hxx>
+#include <vcl/ITiledRenderable.hxx>
#include <unobaseclass.hxx>
#include <viewopt.hxx>
@@ -161,7 +162,8 @@ SwXTextDocumentBaseClass;
class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass,
public SvxFmMSFactory,
- public SfxBaseModel
+ public SfxBaseModel,
+ public ::vcl::ITiledRenderable
{
private:
class Impl;
@@ -428,6 +430,16 @@ public:
// ::com::sun::star::util::XCloneable
virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ // ITiledRenderable
+ virtual void paintTile( VirtualDevice &rDevice,
+ int nOutputWidth,
+ int nOutputHeight,
+ int nTilePosX,
+ int nTilePosY,
+ long nTileWidth,
+ long nTileHeight ) SAL_OVERRIDE;
+ virtual Size getDocumentSize() SAL_OVERRIDE;
+
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
SwXDocumentPropertyHelper * GetPropertyHelper ();
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c020b75..25e83d7 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3120,6 +3120,24 @@ uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::
return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
}
+void SwXTextDocument::paintTile( VirtualDevice &rDevice,
+ int nOutputWidth, int nOutputHeight,
+ int nTilePosX, int nTilePosY,
+ long nTileWidth, long nTileHeight )
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ pViewShell->PaintTile(rDevice, nOutputWidth, nOutputHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+}
+
+Size SwXTextDocument::getDocumentSize()
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->GetCurrentViewShell();
+ return pViewShell->GetDocSize();
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);
commit 2d9525b6d87ebd2b83424f38484f40952ea87b6d
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 a1657b8..5f7dd05 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -314,31 +314,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;
}
@@ -393,8 +385,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)
@@ -419,30 +452,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();
}
@@ -453,7 +494,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();
@@ -463,6 +504,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 8b26f7d..25afdac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -33,10 +33,11 @@ typedef struct _LibreOfficeKitDocumentClass LibreOfficeKitDocumentClass;
#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 1201c0534ab8fa347cefaaa89531c30b4440d2df
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:21:38 2014 +0100
Prevent GTK assertions due to scrolled window not being initialised.
Seems to be a gtk bug which we need to work around. The assertions
don't actually seem to cause any harm (they just print a bunch of
"Gtk-CRITICAL **: IA__gtk_range_get_adjustment: assertion `GTK_IS_RANGE (range)' failed"
but probably best to avoid them.
Change-Id: I5d1bb20bd5c0569c6d023a6148123208a15b9de2
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 4302040..4a16db0 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -47,6 +47,12 @@ static void lok_docview_class_init( LOKDocViewClass* pClass )
static void lok_docview_init( LOKDocView* pDocView )
{
+ // Gtk ScrolledWindow is apparently not fully initialised yet, we specifically
+ // have to set the [hv]adjustment to prevent GTK assertions from firing, see
+ // https://bugzilla.gnome.org/show_bug.cgi?id=438114 for more info.
+ gtk_scrolled_window_set_hadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
+ gtk_scrolled_window_set_vadjustment( GTK_SCROLLED_WINDOW( pDocView ), NULL );
+
pDocView->pEventBox = gtk_event_box_new();
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
pDocView->pEventBox );
commit 0ee462eff54cf9a9760c339ba532ca32b839ff7e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 11:20:15 2014 +0100
Move gtktiledviewer into libreofficekit.
desktop is no longer the right place for it now that
libreofficekit has its own directory.
Change-Id: I207f1d642e7e35c460ff85bb57aa142cb98023c8
diff --git a/desktop/Module_desktop.mk b/desktop/Module_desktop.mk
index 04b71f7..cfaf0d9 100644
--- a/desktop/Module_desktop.mk
+++ b/desktop/Module_desktop.mk
@@ -29,14 +29,6 @@ $(eval $(call gb_Module_add_l10n_targets,desktop,\
UIConfig_deployment \
))
-ifeq ($(OS),LINUX)
-ifneq ($(ENABLE_GTK),)
-$(eval $(call gb_Module_add_targets,desktop,\
- Executable_gtktiledviewer \
-))
-endif
-endif
-
ifneq (,$(filter DESKTOP,$(BUILD_TYPE)))
$(eval $(call gb_Module_add_targets,desktop,\
Executable_soffice_bin \
diff --git a/desktop/Executable_gtktiledviewer.mk b/libreofficekit/Executable_gtktiledviewer.mk
similarity index 95%
rename from desktop/Executable_gtktiledviewer.mk
rename to libreofficekit/Executable_gtktiledviewer.mk
index a0bf8ea..0ce9222 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/libreofficekit/Executable_gtktiledviewer.mk
@@ -43,7 +43,7 @@ $(eval $(call gb_Executable_add_libs,gtktiledviewer,\
endif
$(eval $(call gb_Executable_add_exception_objects,gtktiledviewer,\
- desktop/qa/gtktiledviewer/gtktiledviewer \
+ libreofficekit/qa/gtktiledviewer/gtktiledviewer \
))
# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 0412a33..55136a4 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -10,10 +10,18 @@
$(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
+
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
Library_libreofficekitgtk \
))
-endif
+
+ifneq ($(ENABLE_GTK),)
+$(eval $(call gb_Module_add_targets,libreofficekit,\
+ Executable_gtktiledviewer \
+))
+endif # ($(ENABLE_GTK),)
+
+endif # ($(OS),LINUX)
# vim: set ts=4 sw=4 et:
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
similarity index 100%
rename from desktop/qa/gtktiledviewer/gtktiledviewer.cxx
rename to libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
commit c24aff0311bc6856fe1b70c53174901a2ddf2f8f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 13 10:43:07 2014 +0100
Tiled Rendering: ensure rendered area is visible.
MakeVisible only scrolls the view, so parts of the tile to be rendered
might be outside the SwView's visible area, and therefore not painted.
This however makes the background window (shown for the tilederendering
app) unuseable (but that window is invisible for all practical uses
of tiled rendering, and hence probably not a problem).
Change-Id: I6c3c2846906163b362f7cff6d8c7ba308a58a7ad
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 766a8ac..79bda49 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1783,8 +1783,14 @@ void SwViewShell::PaintTile(VirtualDevice &rDevice, int contextWidth, int contex
Imp()->GetDrawView()->AddWindowToPaintView(&rDevice);
}
- // scroll the requested area into view if necessary
- MakeVisible(SwRect(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
+ // Make the requested area visible -- we can't use MakeVisible as that will
+ // only scroll the contents, but won't zoom/resize if needed.
+ // Without this, items/text that are outside the visible area (in the SwView)
+ // won't be painted when rendering tiles (at least when using either the
+ // tiledrendering app, or the gtktiledviewer) -- although ultimately we
+ // probably want to fix things so that the SwView's area doesn't affect
+ // tiled rendering?
+ mpDoc->GetDocShell()->SetVisArea(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
// draw - works in logic coordinates
Paint(Rectangle(Point(tilePosX, tilePosY), rDevice.PixelToLogic(Size(contextWidth, contextHeight))));
commit 68074ad5f35565805d188dbf9db85db5f98cd525
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 17:38:27 2014 +0100
Upgrade gtktiledviewer to use the LOK viewer widget.
Change-Id: Ied397f617d1cad1f3bd095e8af1ffa741916ecca
diff --git a/desktop/Executable_gtktiledviewer.mk b/desktop/Executable_gtktiledviewer.mk
index 6295f5e..a0bf8ea 100644
--- a/desktop/Executable_gtktiledviewer.mk
+++ b/desktop/Executable_gtktiledviewer.mk
@@ -18,6 +18,10 @@ $(eval $(call gb_Executable_use_externals,gtktiledviewer,\
gtk \
))
+$(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
+ libreofficekitgtk \
+))
+
$(eval $(call gb_Executable_use_static_libraries,gtktiledviewer,\
libreofficekit \
))
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index d8781b2..cfa836c 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -13,10 +13,7 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#define LOK_USE_UNSTABLE_API
-#include <LibreOfficeKit/LibreOfficeKit.hxx>
-
-using namespace ::lok;
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
static int help()
{
@@ -24,56 +21,6 @@ static int help()
return 1;
}
-static GtkWidget* ourCanvas;
-static GdkPixbuf* ourPixBuf = 0;
-
-bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
-{
- fprintf(stderr, "attempting to draw tile");
-
- Document* pDocument = static_cast< Document* >( pData );
-
- long nWidth, nHeight;
- pDocument->getDocumentSize( &nWidth, &nHeight );
-
- // Draw the whole document at once (for now)
- int nRenderWidth = nWidth / 10;
- int nRenderHeight = nHeight / 10;
- int nRowStride;
-
- if ( ourPixBuf &&
- (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
- gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
- {
- g_object_unref( G_OBJECT( ourPixBuf ) );
- ourPixBuf = 0;
-
- }
- if (!ourPixBuf)
- {
- ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight);
- }
-
- unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
-
- pDocument->paintTile( pBuffer,
- nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
- // TODO: double check that the rowstride really matches what we expected,
- // although presumably we'd already be crashing by now if things were
- // wrong.
- (void) nRowStride;
-
- gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
-
- return true;
-
-}
-
int main( int argc, char* argv[] )
{
if( argc < 2 ||
@@ -86,7 +33,7 @@ int main( int argc, char* argv[] )
return 1;
}
- ::lok::Office *pOffice = ::lok::lok_cpp_init( argv[1] );
+ LibreOfficeKit* pOffice = lok_init( argv[1] );
if( !pOffice )
{
fprintf( stderr, "Failed to initialize\n" );
@@ -94,14 +41,12 @@ int main( int argc, char* argv[] )
}
// "This separate init is lame I think."
- if( !pOffice->initialize( argv[1] ) )
+ if( !pOffice->pClass->initialize( pOffice, argv[1] ) )
{
fprintf( stderr, "failed to initialize\n" );
return -1;
}
- ::lok::Document* pDocument = pOffice->documentLoad( argv[2] );
-
gtk_init( &argc, &argv );
GtkWidget *pWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@@ -110,25 +55,14 @@ int main( int argc, char* argv[] )
g_signal_connect( pWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL );
- GtkWidget* pScroller = gtk_scrolled_window_new( 0, 0 );
- gtk_container_add( GTK_CONTAINER(pWindow), pScroller );
-
- GtkWidget* pEventBox = gtk_event_box_new();
- gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pScroller), pEventBox );
+ GtkWidget* pDocView = lok_docview_new( pOffice );
+ gtk_container_add( GTK_CONTAINER(pWindow), pDocView );
- GtkWidget* pCanvas = gtk_image_new();
- ourCanvas = pCanvas;
- gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
+ lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
- g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument);
-
- gtk_widget_show( pCanvas );
- gtk_widget_show( pEventBox );
- gtk_widget_show( pScroller );
+ gtk_widget_show( pDocView );
gtk_widget_show( pWindow );
- drawCallback( pCanvas, 0, pDocument );
-
gtk_main();
return 0;
commit 5e0613020309ff43cf21ef197bb47eaf7dea7bd7
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 17:38:10 2014 +0100
Implement LibreOfficeKit gtk+ viewer widget.
Very basic, but works.
Change-Id: I0c521e833b53e13065e0be48e6fa767e44b29787
diff --git a/Repository.mk b/Repository.mk
index 8210aba..1c4298b 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -524,6 +524,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
i18nlangtag \
i18nutil \
index_data \
+ $(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), libreofficekitgtk) \
localedata_en \
localedata_es \
localedata_euro \
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
new file mode 100644
index 0000000..2435fc2
--- /dev/null
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_DESKTOP_INC_LIBREOFFICEKITGTK_H
+#define INCLUDED_DESKTOP_INC_LIBREOFFICEKITGTK_H
+
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define LOK_DOCVIEW(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
+#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
+#define IS_LOK_DOCVIEW(obj) GTK_CHECK_TYPE (obj, lok_docview_get_type())
+
+
+typedef struct _LOKDocView LOKDocView;
+typedef struct _LOKDocViewClass LOKDocViewClass;
+
+struct _LOKDocView
+{
+ GtkScrolledWindow scrollWindow;
+
+ GtkWidget* pEventBox;
+ GtkWidget* pCanvas;
+ GdkPixbuf* pPixBuf;
+
+ LibreOfficeKit* pOffice;
+ LibreOfficeKitDocument* pDocument;
+};
+
+struct _LOKDocViewClass
+{
+ GtkScrolledWindowClass parent_class;
+
+ void (*lok_docview) (LOKDocView* pDocView);
+};
+
+guint lok_docview_get_type (void);
+GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
+gboolean lok_docview_open_document (LOKDocView* pDocView,
+ char* pPath);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/libreofficekit/Library_libreofficekitgtk.mk b/libreofficekit/Library_libreofficekitgtk.mk
new file mode 100644
index 0000000..be485cd
--- /dev/null
+++ b/libreofficekit/Library_libreofficekitgtk.mk
@@ -0,0 +1,31 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_Library_Library,libreofficekitgtk))
+
+
+$(eval $(call gb_Library_use_externals,libreofficekitgtk,\
+ gtk \
+))
+
+$(eval $(call gb_Library_use_static_libraries,libreofficekitgtk,\
+ libreofficekit \
+))
+
+$(eval $(call gb_Library_add_cobjects,libreofficekitgtk,\
+ libreofficekit/source/gtk/lokdocview \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Library_add_libs,libreofficekitgtk,\
+ -ldl \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 1d65d45..0412a33 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Module_Module,libreofficekit))
ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
+ Library_libreofficekitgtk \
))
endif
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
new file mode 100644
index 0000000..4302040
--- /dev/null
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -0,0 +1,120 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sal/types.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+#include <LibreOfficeKit/LibreOfficeKitGtk.h>
+
+static void lok_docview_class_init( LOKDocViewClass* pClass );
+static void lok_docview_init( LOKDocView* pDocView );
+
+SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
+{
+ static guint lok_docview_type = 0;
+
+ if (!lok_docview_type)
+ {
+ GtkTypeInfo lok_docview_info =
+ {
+ "LokDocView",
+ sizeof( LOKDocView ),
+ sizeof( LOKDocViewClass ),
+ (GtkClassInitFunc) lok_docview_class_init,
+ (GtkObjectInitFunc) lok_docview_init,
+ NULL,
+ NULL,
+ (GtkClassInitFunc) NULL
+ };
+
+ lok_docview_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_info );
+ }
+ return lok_docview_type;
+}
+
+static void lok_docview_class_init( LOKDocViewClass* pClass )
+{
+ pClass->lok_docview = NULL;
+}
+
+static void lok_docview_init( LOKDocView* pDocView )
+{
+ pDocView->pEventBox = gtk_event_box_new();
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(pDocView),
+ pDocView->pEventBox );
+
+ pDocView->pCanvas = gtk_image_new();
+ gtk_container_add( GTK_CONTAINER( pDocView->pEventBox ), pDocView->pCanvas );
+
+ gtk_widget_show( pDocView->pCanvas );
+ gtk_widget_show( pDocView->pEventBox );
+
+ pDocView->pPixBuf = 0;
+
+ // TODO: figure out a clever view of getting paths set up.
+ pDocView->pOffice = 0;
+ pDocView->pDocument = 0;
+}
+
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
+{
+ LOKDocView* pDocView = gtk_type_new( lok_docview_get_type() );
+ pDocView->pOffice = pOffice;
+ return GTK_WIDGET( pDocView );
+}
+
+SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+{
+ if ( pDocView->pDocument )
+ {
+ pDocView->pDocument->pClass->destroy( pDocView->pDocument );
+ pDocView->pDocument = 0;
+ }
+
+ pDocView->pDocument = pDocView->pOffice->pClass->documentLoad( pDocView->pOffice,
+ pPath );
+ if ( pDocView->pPixBuf )
+ {
+ g_object_unref( G_OBJECT( pDocView->pPixBuf ) );
+ }
+
+ long nWidth, nHeight;
+ pDocView->pDocument->pClass->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight );
+
+ // Draw the whole document at once (for now)
+ int nRenderWidth = nWidth / 10;
+ int nRenderHeight = nHeight / 10;
+
+ pDocView->pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ TRUE, 8,
+ nRenderWidth, nRenderHeight);
+
+
+ // TODO: move the rendering into it's own function etc.
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( pDocView->pPixBuf );
+ int nRowStride;
+ pDocView->pDocument->pClass->paintTile( pDocView->pDocument,
+ pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // TODO: double check that the rowstride really matches what we expected,
+ // although presumably we'd already be crashing by now if things were
+ // wrong.
+ (void) nRowStride;
+
+ gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas ), pDocView->pPixBuf );
+
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 05a4829fcf272f9497d58696267bcd88ca21415e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 12 15:14:58 2014 +0100
Remove outdated includes.
These were needed for the X11 "context" rendering which is no longer used.
Change-Id: Ib60c8fff9dad06b1f8f489eed66c3b3c3597e1ee
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index cff237c..d8781b2 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -11,15 +11,8 @@
#include <string.h>
#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include <X11/extensions/Xrender.h>
-
-// Only for the SystemGraphicsData struct, and hopefully we can find some better
-// replacement for that at some point.
-#include <vcl/sysdata.hxx>
-
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.hxx>
commit 4f284531e21a29159d19aca4c8439946085b3793
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:54:49 2014 +0100
Kill gtktiledviewer's alpha channel hack.
basebmp and vcl now set the alpha channel appropriately, so no need
to do so in the viewer now.
However it would perhaps make more sense to just use RGB instead
of RGBA, seeing as the alpha channel is permanently set to be opaque.
Change-Id: I86ad758c6a8bee21b265730727a76605e5850c0c
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index 18506a7..cff237c 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -75,11 +75,6 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
// wrong.
(void) nRowStride;
- for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
- {
- pBuffer[i] = 0xFF;
- }
-
gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
return true;
commit b3c272faa43306aeda50b2f268962465891fdff6
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 13:39:56 2014 +0100
Fill the alpha channel by default for vcl 32-bit bitmaps too.
Otherwise the alpha channel for bitmaps created directly is empty,
indicating a transparent bitmap (although we don't actually handle
transparency). This complements hardcoding of the alpha channel
in basebmp. VCL bitmaps can be copied bit-for-bit directly into
a basebmp bitmap, hence it's important to make sure we fill the
alpha channel in vcl too.
Conflicts:
include/vcl/salbtype.hxx
Change-Id: Icb2fa417db6625a6ffa6bd82eb5773ff75be5a3c
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index ccdbfbe..92258c5 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -84,13 +84,14 @@ d_Col = BitmapColor( (sal_uInt8) ( _def_cR | ( ( _def_cR & mnROr ) >> mnROrShift
-#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS ) \
+#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_ALPHA ) \
( ( ( ( d_RS < 0L ) ? ( (sal_uInt32) (d_rCol).GetRed() >> -d_RS ) : \
( (sal_uInt32) (d_rCol).GetRed() << d_RS ) ) & d_RM ) | \
( ( ( d_GS < 0L ) ? ( (sal_uInt32) (d_rCol).GetGreen() >> -d_GS ) : \
( (sal_uInt32) (d_rCol).GetGreen() << d_GS ) ) & d_GM ) | \
( ( ( d_BS < 0L ) ? ( (sal_uInt32) (d_rCol).GetBlue() >> -d_BS ) : \
- ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) )
+ ( (sal_uInt32) (d_rCol).GetBlue() << d_BS ) ) & d_BM ) | \
+ d_ALPHA )
// - BitmapColor -
@@ -215,12 +216,16 @@ class VCL_DLLPUBLIC ColorMask
sal_uLong mnROr;
sal_uLong mnGOr;
sal_uLong mnBOr;
+ sal_uLong mnAlphaChannel;
SAL_DLLPRIVATE inline long ImplCalcMaskShift( sal_uLong nMask, sal_uLong& rOr, sal_uLong& rOrShift ) const;
public:
- inline ColorMask( sal_uLong nRedMask = 0UL, sal_uLong nGreenMask = 0UL, sal_uLong nBlueMask = 0UL );
+ inline ColorMask( sal_uLong nRedMask = 0UL,
+ sal_uLong nGreenMask = 0UL,
+ sal_uLong nBlueMask = 0UL,
+ sal_uLong nAlphaChannel = 0UL );
inline ~ColorMask() {}
inline sal_uLong GetRedMask() const;
@@ -698,7 +703,10 @@ inline sal_uInt16 BitmapPalette::GetBestIndex( const BitmapColor& rCol ) const
-inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong nBlueMask ) :
+inline ColorMask::ColorMask( sal_uLong nRedMask,
+ sal_uLong nGreenMask,
+ sal_uLong nBlueMask,
+ sal_uLong nAlphaChannel ) :
mnRMask( nRedMask ),
mnGMask( nGreenMask ),
mnBMask( nBlueMask ),
@@ -707,7 +715,8 @@ inline ColorMask::ColorMask( sal_uLong nRedMask, sal_uLong nGreenMask, sal_uLong
mnBOrShift( 0L ),
mnROr( 0L ),
mnGOr( 0L ),
- mnBOr( 0L )
+ mnBOr( 0L ),
+ mnAlphaChannel( nAlphaChannel )
{
mnRShift = ( mnRMask ? ImplCalcMaskShift( mnRMask, mnROr, mnROrShift ) : 0L );
mnGShift = ( mnGMask ? ImplCalcMaskShift( mnGMask, mnGOr, mnGOrShift ) : 0L );
@@ -774,7 +783,7 @@ inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ *pPixel = (sal_uInt8) COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
}
@@ -790,7 +799,7 @@ inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8)(nVal >> 8U);
pPixel[ 1 ] = (sal_uInt8) nVal;
@@ -809,7 +818,7 @@ inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, ConstHPBYTE pPi
inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt16 nVal = (sal_uInt16)COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal;
pPixel[ 1 ] = (sal_uInt8)(nVal >> 8U);
@@ -828,7 +837,7 @@ inline void ColorMask::GetColorFor24Bit( BitmapColor& rColor, ConstHPBYTE pPixel
inline void ColorMask::SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL ); pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL );
}
@@ -857,7 +866,7 @@ inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8&
inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
{
- const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift );
+ const sal_uInt32 nVal = COLOR_TO_MASK( rColor, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, mnAlphaChannel );
pPixel[ 0 ] = (sal_uInt8) nVal; pPixel[ 1 ] = (sal_uInt8) ( nVal >> 8UL );
pPixel[ 2 ] = (sal_uInt8) ( nVal >> 16UL ); pPixel[ 3 ] = (sal_uInt8) ( nVal >> 24UL );
}
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 0a81fdc..3920aea 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -188,36 +188,36 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( bool )
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ARGB:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff );
+ pBuf->maColorMask = ColorMask( 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000 );
+ pBuf->maColorMask = ColorMask( 0x0000ff00, 0x00ff0000, 0xff000000, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_ABGR:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#else
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#endif
break;
case FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA:
nBitCount = 32;
pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
#ifdef OSL_BIGENDIAN
- pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00 );
+ pBuf->maColorMask = ColorMask( 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff );
#else
- pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000 );
+ pBuf->maColorMask = ColorMask( 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 );
#endif
break;
diff --git a/vcl/source/gdi/bmpacc2.cxx b/vcl/source/gdi/bmpacc2.cxx
index bf1d540..12b0c1d 100644
--- a/vcl/source/gdi/bmpacc2.cxx
+++ b/vcl/source/gdi/bmpacc2.cxx
@@ -179,7 +179,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ABGR )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ABGR )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetRed();
@@ -198,7 +198,7 @@ IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_ARGB )
IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_ARGB )
{
- *( pScanline = pScanline + ( nX << 2 ) )++ = 0;
+ *( pScanline = pScanline + ( nX << 2 ) )++ = 0xFF;
*pScanline++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline = rBitmapColor.GetBlue();
@@ -220,7 +220,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_BGRA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetBlue();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetRed();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL_NOMASK( _32BIT_TC_RGBA )
@@ -239,7 +239,7 @@ IMPL_FORMAT_SETPIXEL_NOMASK( _32BIT_TC_RGBA )
*( pScanline = pScanline + ( nX << 2 ) )++ = rBitmapColor.GetRed();
*pScanline++ = rBitmapColor.GetGreen();
*pScanline++ = rBitmapColor.GetBlue();
- *pScanline = 0;
+ *pScanline = 0xFF;
}
IMPL_FORMAT_GETPIXEL( _32BIT_TC_MASK )
commit 024e573559937bf6a72e44b3df7d6916ca0b2f8d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 10 17:15:49 2014 +0100
Add base value to set alpha channel for 32 bit colourspaces.
Currently the alpha channel is completely ignored by basebmp.
However this results in completely "transparent" output, meaning
the client has to manually overwrite the alpha channel -- instead
we now set it automatically when writing colourdata.
Unfortunately this doesn't quite work -- it seems that drawing
a non-opaque bitmap/image on top of the existing bitmap can
erase the alpha channel information (i.e. these areas will
once again be transparent -- for example document borders seem
to have a transition effect overlayed onto them): presumably
there is some method that bypasses our RGBMaskSetter (probably
some form of direct manipulation of raw values?).
manipulation in basebmp
Change-Id: Ia4be6a748cc30191a4422121f9ec347d9198b225
diff --git a/include/basebmp/rgbmaskpixelformats.hxx b/include/basebmp/rgbmaskpixelformats.hxx
index d1d9b84..696f35a 100644
--- a/include/basebmp/rgbmaskpixelformats.hxx
+++ b/include/basebmp/rgbmaskpixelformats.hxx
@@ -148,6 +148,7 @@ template< typename PixelType,
template< typename PixelType,
typename ColorType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -174,6 +175,7 @@ template< typename PixelType,
const typename base_type::unsigned_pixel_type blue (c.getBlue());
typename base_type::unsigned_pixel_type res(
+ BaseValue |
(shiftLeft(red,
base_type::red_shift-8*
(signed)sizeof(typename base_type::component_type)+
@@ -194,6 +196,7 @@ template< typename PixelType,
template< typename PixelType,
+ unsigned int BaseValue,
unsigned int RedMask,
unsigned int GreenMask,
unsigned int BlueMask,
@@ -209,6 +212,7 @@ template< typename PixelType,
SwapBytes> getter_type;
typedef RGBMaskSetter<pixel_type,
Color,
+ BaseValue,
RedMask,
GreenMask,
BlueMask,
@@ -256,6 +260,7 @@ template< typename PixelType,
// 16bpp MSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -266,6 +271,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_MSB::getter_type,
// 16bpp LSB RGB
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt16,
+ 0,
0xF800,
0x07E0,
0x001F,
@@ -286,6 +292,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGB16_565_LSB::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -297,6 +304,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_BGRX32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF,
@@ -308,6 +316,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XRGB32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
@@ -317,6 +326,7 @@ BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_XBGR32_8888::getter_type,
typedef PixelFormatTraitsTemplate_RGBMask<
sal_uInt32,
+ 0x000000FF,
0xFF000000,
0x00FF0000,
0x0000FF00,
commit d98abcc444dce04bbe511fb9ab147e1cdc59bb7b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 18:30:00 2014 +0100
Get rid of outdated comments.
We can now set the colourspace as desired, and we return the rowstride too.
Change-Id: Idf1e55a67b9e9ab58e82d7ed0be2813b682ec2ff
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 1d72c40..a1657b8 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -410,29 +410,12 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
-// to just be RGB, 8 bits per sample, and vertically mirrored compared
-// to what gtk expects.
-// The BitmapDevice actually supports various formats, as detailed in
-// basebmp/scanlineformat.hxx -- for svp SVP_DEFAULT_BITMAP_FORMAT is seemingly used
-// (see creation in svpvd.cxx) -- which is simply FORMAT_TWENTYFOUR_BIT_TC_MASK
-// for now -- we could probably adjust this as necessary to get whatever
-// format is presumably most useful, or maybe even allow that as a parameter.
-//
-// It's actually possible to set the depth in the creation of a VirtualDevice,
-// however that only allows 0, 1 or 8 -- and we can't select the full range of formats
-// as above, so we'd need to add a way of setting the format entirely from scratch
-// should that be deemed necessary.
-//
-// We probably also want to use getScanlineStride() -- I'm guessing that
-// this is where we are actually just returning a sub-portion of a larger buffer
-// which /shouldn't/ apply in our case, but better to be safe here.
void doc_paintTile (LibreOfficeKitDocument* pThis,
unsigned char* pBuffer,
- const int nCanvasWidth, const int nCanvasHeight,
- int* pRowStride,
- const int nTilePosX, const int nTilePosY,
- const int nTileWidth, const int nTileHeight)
+ const int nCanvasWidth, const int nCanvasHeight,
+ int* pRowStride,
+ const int nTilePosX, const int nTilePosY,
+ const int nTileWidth, const int nTileHeight)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
commit f72947beb6003de42c7ce23723e48ed24bb32484
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:42:17 2014 +0100
Upgrade gtktiledviewer to use its own buffer.
Change-Id: I3f567ff19ee0d5b0d54aeef9b163b78567d72946
diff --git a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
index fb8b276..18506a7 100644
--- a/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/desktop/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -32,6 +32,7 @@ static int help()
}
static GtkWidget* ourCanvas;
+static GdkPixbuf* ourPixBuf = 0;
bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpointer pData)
{
@@ -46,25 +47,41 @@ bool drawCallback(GtkWidget* /* The eventbox */, void* /* cairo_t* cr */, gpoint
int nRenderWidth = nWidth / 10;
int nRenderHeight = nHeight / 10;
int nRowStride;
- unsigned char* pBuffer = pDocument->paintTile( nRenderWidth, nRenderHeight,
- &nRowStride,
- 0, 0, // origin
- nWidth, nHeight );
+
+ if ( ourPixBuf &&
+ (gdk_pixbuf_get_width( ourPixBuf ) != nRenderWidth ||
+ gdk_pixbuf_get_height( ourPixBuf ) != nRenderHeight ) )
+ {
+ g_object_unref( G_OBJECT( ourPixBuf ) );
+ ourPixBuf = 0;
+
+ }
+ if (!ourPixBuf)
+ {
+ ourPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
+ true, 8,
+ nRenderWidth, nRenderHeight);
+ }
+
+ unsigned char* pBuffer = gdk_pixbuf_get_pixels( ourPixBuf );
+
+ pDocument->paintTile( pBuffer,
+ nRenderWidth, nRenderHeight,
+ &nRowStride,
+ 0, 0, // origin
+ nWidth, nHeight );
+ // TODO: double check that the rowstride really matches what we expected,
+ // although presumably we'd already be crashing by now if things were
+ // wrong.
+ (void) nRowStride;
for (int i = 3; i < nRowStride*nRenderHeight; i += 4)
{
pBuffer[i] = 0xFF;
}
- GdkPixbuf* pBixBuf = gdk_pixbuf_new_from_data( pBuffer, GDK_COLORSPACE_RGB,
- true, 8,
- nRenderWidth, nRenderHeight,
- nRowStride,
- 0, 0 );
- pBixBuf = gdk_pixbuf_flip( pBixBuf, false );
- gtk_image_set_from_pixbuf( GTK_IMAGE(ourCanvas), pBixBuf );
+ gtk_image_set_from_pixbuf( GTK_IMAGE( ourCanvas ), ourPixBuf );
- // TODO: we need to keep track of and cleanup these buffers etc.
return true;
}
@@ -115,7 +132,6 @@ int main( int argc, char* argv[] )
ourCanvas = pCanvas;
gtk_container_add( GTK_CONTAINER( pEventBox ), pCanvas );
-
g_signal_connect( G_OBJECT(pEventBox), "button-press-event", G_CALLBACK(drawCallback), pDocument);
gtk_widget_show( pCanvas );
commit 83939f37a74b2d72b7ec5fa6d28d5720815dffdb
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 11 16:24:33 2014 +0100
Use external buffer for LibLO tiled rendering.
Means we can get rid of hackily storing a reference to the last
buffer we created.
Change-Id: I8092a7d87bc391301f75651a59b37fbd73ac64fd
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2286366..1d72c40 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -78,6 +78,17 @@ typedef struct
const char *filterName;
} ExtensionMap;
+// We need a shared_array for passing into the BitmapDevice (via
+// VirtualDevice.SetOutputSizePixelScaleOffsetAndBuffer which goes via the
+// SvpVirtualDevice, ending up in the basebmp BitmapDevice. However as we're
+// given the array externally we can't delete it, and hence need to override
+// shared_array's default of deleting its pointer.
+template<typename T>
+struct NoDelete
+{
+ void operator()(T* /* p */) {}
+};
+
static const ExtensionMap aWriterExtensionMap[] =
{
{ "doc", "MS Word 97" },
@@ -175,12 +186,13 @@ static int doc_saveAsWithOptions(LibreOfficeKitDocument* pThis, const char* pUr
static LibreOfficeKitDocumentType doc_getDocumentType(LibreOfficeKitDocument* pThis);
static int doc_getNumberOfParts(LibreOfficeKitDocument* pThis);
static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart);
-static unsigned char* doc_paintTile(LibreOfficeKitDocument* pThis,
+void doc_paintTile(LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight);
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
@@ -398,14 +410,6 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
(void) nPart;
}
-// TODO: Temporary hack -- we need to keep the buffer alive while we paint it
-// in the gtk tiled viewer -- we can't pass out the shared_array through
-// the C interface, so maybe we want some sort of wrapper where we can return
-// a handle which we then associate with a given shared_array within LibLO
-// (where the client then has to tell us when they are finished with using
-// the buffer).
-boost::shared_array< sal_uInt8 > ourBuffer;
-
// TODO: Not 100% sure about the bitmap buffer format yet -- it appears
// to just be RGB, 8 bits per sample, and vertically mirrored compared
// to what gtk expects.
@@ -423,7 +427,8 @@ boost::shared_array< sal_uInt8 > ourBuffer;
// We probably also want to use getScanlineStride() -- I'm guessing that
// this is where we are actually just returning a sub-portion of a larger buffer
// which /shouldn't/ apply in our case, but better to be safe here.
-static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
+void doc_paintTile (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth, const int nCanvasHeight,
int* pRowStride,
const int nTilePosX, const int nTilePosY,
@@ -431,8 +436,6 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- unsigned char* pRet = 0;
-
Application::AcquireSolarMutex(1);
{
SwXTextDocument* pTxtDoc = dynamic_cast< SwXTextDocument* >( pDocument->mxComponent.get() );
@@ -445,6 +448,10 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
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 );
pViewShell->PaintTile(aDevice, nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
@@ -453,16 +460,11 @@ static unsigned char* doc_paintTile (LibreOfficeKitDocument* pThis,
basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
*pRowStride = pBmpDev->getScanlineStride();
- ourBuffer = pBmpDev->getBuffer();
-
- pRet = ourBuffer.get();
}
Application::ReleaseSolarMutex();
-
- return pRet;
}
-static void doc_getDocumentSize(LibreOfficeDocument* pThis,
+static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight)
{
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 577c4b1..8b26f7d 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -90,7 +90,8 @@ struct _LibreOfficeKitDocumentClass
// for its internal buffer, i.e. the rowstride for the buffer may be larger
// than the desired width, hence we need to be able to return the
// rowstride too.
- unsigned char* (*paintTile) (LibreOfficeKitDocument* pThis,
+ void (*paintTile) (LibreOfficeKitDocument* pThis,
+ unsigned char* pBuffer,
const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 0a03946..e44795f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -65,7 +65,9 @@ public:
mpDoc->pClass->setPart(mpDoc, nPart);
}
- inline unsigned char* paintTile(const int nCanvasWidth,
+ inline void paintTile(
+ unsigned char* pBuffer,
+ const int nCanvasWidth,
const int nCanvasHeight,
int* pRowStride,
const int nTilePosX,
@@ -73,7 +75,7 @@ public:
const int nTileWidth,
const int nTileHeight)
{
- return mpDoc->pClass->paintTile(mpDoc, nCanvasWidth, nCanvasHeight, pRowStride,
+ return mpDoc->pClass->paintTile(mpDoc, pBuffer, nCanvasWidth, nCanvasHeight, pRowStride,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
}
commit 9df85972081bf63509db41a5da8bc90b15c89e81
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sun May 25 16:40:47 2014 +0100
Allow passing in external buffers to svp's VirtualDevice.
We also want to be able to set whether or not the buffers
should be painted to top down, so add that parameter
as necessary (default seems to be false, however e.g. gtk
requires this to be true, i.e. needed for tiled rendering).
Change-Id: Id98882e4c7f62508ae5a976c0d8df743460a4ab2
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 74a6174..8c36f52 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -43,8 +43,12 @@ private:
sal_uInt8 meRefDevMode;
SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL );
- SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
- SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, const basebmp::RawMemorySharedArray &pBuffer );
+ SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
+ SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown );
// Copy assignment is forbidden and not implemented.
VirtualDevice (const VirtualDevice &);
@@ -119,7 +123,11 @@ public:
virtual void EnableRTL( bool bEnable = true ) SAL_OVERRIDE;
bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true );
- bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, const Fraction& rScale, const Point& rNewOffset, const basebmp::RawMemorySharedArray &pBuffer );
+ bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize,
+ const Fraction& rScale,
+ const Point& rNewOffset,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown = false );
bool SetOutputSize( const Size& rNewSize, bool bErase = true )
{ return SetOutputSizePixel( LogicToPixel( rNewSize ), bErase ); }
diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx
index d85cd8c..dc280db 100644
--- a/vcl/headless/svpvd.cxx
+++ b/vcl/headless/svpvd.cxx
@@ -52,10 +52,12 @@ void SvpSalVirtualDevice::ReleaseGraphics( SalGraphics* pGraphics )
bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY )
{
- return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray() );
+ return SetSizeUsingBuffer( nNewDX, nNewDY, basebmp::RawMemorySharedArray(), false );
}
-bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer )
+bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown )
{
B2IVector aDevSize( nNewDX, nNewDY );
if( aDevSize.getX() == 0 )
@@ -73,13 +75,13 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, const ba
std::vector< basebmp::Color > aDevPal(2);
aDevPal.push_back( basebmp::Color( 0, 0, 0 ) );
aDevPal.push_back( basebmp::Color( 0xff, 0xff, 0xff ) );
- m_aDevice = createBitmapDevice( aDevSize, false, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
+ m_aDevice = createBitmapDevice( aDevSize, bTopDown, nFormat, PaletteMemorySharedVector( new std::vector< basebmp::Color >(aDevPal) ) );
}
else
{
m_aDevice = pBuffer ?
- createBitmapDevice( aDevSize, false, nFormat, pBuffer, PaletteMemorySharedVector() )
- : createBitmapDevice( aDevSize, false, nFormat );
+ createBitmapDevice( aDevSize, bTopDown, nFormat, pBuffer, PaletteMemorySharedVector() )
+ : createBitmapDevice( aDevSize, bTopDown, nFormat );
}
// update device in existing graphics
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index e4d37fc..f6a9cc5 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -45,7 +45,10 @@ public:
virtual void ReleaseGraphics( SalGraphics* pGraphics ) SAL_OVERRIDE;
virtual bool SetSize( long nNewDX, long nNewDY ) SAL_OVERRIDE;
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray &pBuffer ) SAL_OVERRIDE;
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray &pBuffer,
+ const bool bTopDown
+ ) SAL_OVERRIDE;
virtual void GetSize( long& rWidth, long& rHeight ) SAL_OVERRIDE;
basebmp::BitmapDeviceSharedPtr getBitmapDevice() { return m_aDevice; }
diff --git a/vcl/inc/salvd.hxx b/vcl/inc/salvd.hxx
index 842429f..0cac639 100644
--- a/vcl/inc/salvd.hxx
+++ b/vcl/inc/salvd.hxx
@@ -40,9 +40,13 @@ public:
virtual bool SetSize( long nNewDX, long nNewDY ) = 0;
// Set new size using a buffer at the given address
- virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY, const basebmp::RawMemorySharedArray & /* pBuffer */ )
+ virtual bool SetSizeUsingBuffer( long nNewDX, long nNewDY,
+ const basebmp::RawMemorySharedArray & /* pBuffer */,
+ const bool /* bTopDown */
+ )
{
- // Only the headless virtual device has an implementation that uses pBuffer.
+ // Only the headless virtual device has an implementation that uses
+ // pBuffer (and bTopDown).
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list