[Libreoffice-commits] core.git: Branch 'feature/calctiledrendering5' - 794 commits - accessibility/source android/abs-lib android/Bootstrap android/experimental avmedia/source basctl/source basic/inc basic/source bin/find-german-comments bin/findunusedcode canvas/source chart2/AllLangResTarget_chartcontroller.mk chart2/inc chart2/opengl chart2/qa chart2/source chart2/uiconfig codemaker/source comphelper/source compilerplugins/clang config_host/config_vcl.h.in configmgr/qa configure.ac connectivity/Library_tdeab1.mk connectivity/Library_tdeabdrv1.mk connectivity/registry connectivity/source cppcanvas/source cppuhelper/source crashrep/source cui/AllLangResTarget_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk dbaccess/inc dbaccess/source dbaccess/uiconfig dbaccess/UIConfig_dbaccess.mk desktop/Library_sofficeapp.mk desktop/source desktop/test desktop/uiconfig dictionaries download.lst drawinglayer/source editeng/inc editeng/source embeddedobj/source extensions/source external/beanshell external/b oost external/coinmp external/collada2gltf external/hunspell external/hyphen external/icu external/jfreereport external/libabw external/libebook external/libetonyek external/libgltf external/liblangtag external/libvisio external/libxml2 external/libxmlsec external/libxslt external/mythes external/nss external/openssl external/python3 external/redland extras/source filter/qa filter/source fpicker/source framework/inc framework/source helpcontent2 icon-themes/galaxy icon-themes/tango icon-themes/tango_testing include/basic include/connectivity include/cppuhelper include/editeng include/filter include/framework include/LibreOfficeKit include/oox include/rtl include/sal include/salhelper include/sfx2 include/svl include/svtools include/svx include/test include/tools include/vbahelper include/vcl include/xmloff jurt/com libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk libreofficekit/Executable_gtktiledviewer.mk libreofficekit/Executable_lokconf_init.mk libreofficekit/Module_li breofficekit.mk libreofficekit/qa libreofficekit/README libreofficekit/source lingucomponent/source Makefile.fetch offapi/com offapi/UnoApi_offapi.mk officecfg/registry oovbaapi/ooo oox/inc oox/Library_oox.mk oox/source package/source pyuno/source readlicense_oo/license README.Android registry/source reportbuilder/java reportdesign/source RepositoryExternal.mk Repository.mk ridljar/com sal/osl sax/source sc/CppunitTest_sc_subsequent_export_test.mk sc/CppunitTest_sc_subsequent_filters_test.mk sc/inc sc/Library_scfilt.mk sc/Library_sc.mk sc/Library_scqahelper.mk scp2/AutoInstall.mk scp2/InstallModule_base.mk scp2/InstallModule_impress.mk scp2/InstallModule_ooo.mk scp2/source sc/qa sc/source sc/uiconfig sd/inc sd/qa sd/source sd/uiconfig setup_native/source sfx2/AllLangResTarget_sfx2.mk sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk shell/Library_tdebe.mk slideshow/source solenv/bin solenv/gbuild sot/source starmath/inc starmath/source stoc/Library_javaloader.mk stoc/source store/sourc e svgio/inc svgio/qa svgio/source svl/CppunitTest_svl_notify.mk svl/Library_svl.mk svl/Module_svl.mk svl/qa svl/source svtools/CppunitTest_svtools_graphic.mk svtools/Module_svtools.mk svtools/qa svtools/source svtools/uiconfig svtools/UIConfig_svt.mk svx/inc svx/source sw/CppunitTest_sw_ooxmlfieldexport.mk sw/CppunitTest_sw_ooxmlimport.mk swext/mediawiki sw/inc sw/Library_sw.mk sw/Module_sw.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_swriter.mk test/source toolkit/source tools/source translations ucb/Library_cached1.mk ucb/Library_srtrs1.mk ucb/Library_ucpftp1.mk ucb/source udkapi/com unotools/source unoxml/source unusedcode.easy uui/inc uui/source vbahelper/source vcl/Executable_tdefilepicker.mk vcl/generic vcl/inc vcl/Library_vclplug_tde.mk vcl/qa vcl/quartz vcl/source vcl/unx vcl/win vcl/workben writerfilter/CustomTarget_source.mk writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/qa writerfilter/source writerperfect/source xmloff/inc xmloff/source
Andrzej Hunt
andrzej.hunt at collabora.com
Sat Jul 26 07:07:52 PDT 2014
Rebased ref, commits from common ancestor:
commit c8a5011174101dea2e381ae5b5a8269aecc941f7
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 25 20:54:40 2014 +0200
Revert "DON'T USE: ignore unknown args instead of failure."
This reverts commit 8ffe7f2b93620112319981957ab6bc27c0d4738d.
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 7eed070..46fbebe 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -656,7 +656,7 @@ void Desktop::Init()
// 2nd office startup should terminate after sending cmdlineargs through pipe
SetBootstrapStatus(BS_TERMINATE);
}
- else if ( (!rCmdLineArgs.GetUnknown().isEmpty() && false)
+ else if ( !rCmdLineArgs.GetUnknown().isEmpty()
|| rCmdLineArgs.IsHelp() || rCmdLineArgs.IsVersion() )
{
// disable IPC thread in an instance that is just showing a help message
commit 80dedd6a85abbe040d18b50fa51574818ef63c9f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 21:15:39 2014 +0200
Lets not roll our own twip/mm100 conversions.
Change-Id: Id1d0c2bed0359c35086d963dcfe9b765b6232b09
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 08b8013..60a6f47 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -27,6 +27,7 @@
#include <editeng/scripttypeitem.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/printer.hxx>
+#include <tools/mapunit.hxx>
#include <vcl/settings.hxx>
#include <svx/svdpage.hxx>
@@ -424,9 +425,8 @@ Size ScGridWindow::GetDataAreaSize()
SdrPage* pPage = pPageView->GetPage();
Rectangle aDrawDataArea = pPage->GetAllObjBoundRect();
// Draw layer works in 100th mm, whereas we're working with TWIPs.
- aDrawDataArea.SetPos( aDrawDataArea.TopLeft() * 1440 / 2540 );
- aDrawDataArea.SetSize( Size( aDrawDataArea.GetSize().Width() * 1440 / 2540,
- aDrawDataArea.GetSize().Height() * 1440 / 2540 ) );
+ aDrawDataArea.SetPos( convertMm100ToTwip(aDrawDataArea.TopLeft() ) );
+ aDrawDataArea.SetSize( convertMm100ToTwip( aDrawDataArea.GetSize() ) );
// We specifically keep iterating until we have covered both the
// data area AND the drawing layer area. We also make sure that
@@ -641,7 +641,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
MapMode aDrawMode = pOutDev->GetMapMode();
Point aOrigin = aDrawMode.GetOrigin();
aDrawMode.SetMapUnit( MAP_100TH_MM );
- aDrawMode.SetOrigin( (aOrigin * 2540l) / 1440l );
+ aDrawMode.SetOrigin( convertTwipToMm100( aOrigin ) );
Rectangle aDrawingRectLogic;
{
commit f22df48af246f71c1185fb3ca7b319e1f31af078
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 21:13:15 2014 +0200
Add Point and Size versions of convertMm100ToTwip/TwipToMm100.
There seem to be quite a few cases where the individual components
are being converted, this way we can just conver the entire
object as one.
Change-Id: I0043b6f40520d7497e6edc185187706b255f2354
diff --git a/include/tools/mapunit.hxx b/include/tools/mapunit.hxx
index a68b6b4..af3eaa9 100644
--- a/include/tools/mapunit.hxx
+++ b/include/tools/mapunit.hxx
@@ -20,6 +20,8 @@
#ifndef INCLUDED_TOOLS_MAPUNIT_HXX
#define INCLUDED_TOOLS_MAPUNIT_HXX
+#include "gen.hxx"
+
enum MapUnit { MAP_100TH_MM, MAP_10TH_MM, MAP_MM, MAP_CM,
MAP_1000TH_INCH, MAP_100TH_INCH, MAP_10TH_INCH, MAP_INCH,
MAP_POINT, MAP_TWIP, MAP_PIXEL, MAP_SYSFONT, MAP_APPFONT,
@@ -33,6 +35,18 @@ inline sal_Int64 convertTwipToMm100(sal_Int64 n)
return (n*127-36)/72;
}
+inline Point convertTwipToMm100(const Point& rPoint)
+{
+ return Point(convertTwipToMm100(rPoint.getX()),
+ convertTwipToMm100(rPoint.getY()));
+}
+
+inline Size convertTwipToMm100(const Size& rSize)
+{
+ return Size(convertTwipToMm100(rSize.getWidth()),
+ convertTwipToMm100(rSize.getHeight()));
+}
+
inline sal_Int64 convertMm100ToTwip(sal_Int64 n)
{
if (n >= 0)
@@ -41,6 +55,18 @@ inline sal_Int64 convertMm100ToTwip(sal_Int64 n)
return (n*72-63)/127;
}
+inline Point convertMm100ToTwip(const Point& rPoint)
+{
+ return Point(convertMm100ToTwip(rPoint.getX()),
+ convertMm100ToTwip(rPoint.getY()));
+}
+
+inline Size convertMm100ToTwip(const Size& rSize)
+{
+ return Size(convertMm100ToTwip(rSize.getWidth()),
+ convertMm100ToTwip(rSize.getHeight()));
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4d8e24b481002d807c488a1b0031dc14fd3197e3
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 19:46:16 2014 +0200
DON'T USE: ignore unknown args instead of failure.
The --protector flag ends up here in unit tests, which causes things
to fail -- either we need to make --protector known, or filter
it out before hand -- whereby I suspect filtering it out would be
difficult to do in a reliable fashion.
Change-Id: Iab47a6e24723604df75def2b963e82ba6479318e
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 46fbebe..7eed070 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -656,7 +656,7 @@ void Desktop::Init()
// 2nd office startup should terminate after sending cmdlineargs through pipe
SetBootstrapStatus(BS_TERMINATE);
}
- else if ( !rCmdLineArgs.GetUnknown().isEmpty()
+ else if ( (!rCmdLineArgs.GetUnknown().isEmpty() && false)
|| rCmdLineArgs.IsHelp() || rCmdLineArgs.IsVersion() )
{
// disable IPC thread in an instance that is just showing a help message
commit 5d868e5ba7b97d35b350103b6d038cc58a1c45b0
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 11 16:35:58 2014 +0200
More pixel->document coordinate scaling.
Change-Id: Iea3877c024d66fa6b80d447c749246148f2dc11d
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 3e77153..2345473 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -145,6 +145,7 @@ void ScHeaderControl::DoPaint( SCCOLROW nStart, SCCOLROW nEnd )
aRect.Left() = GetScrPos( nStart )-nLayoutSign; // extra pixel for line left of selection
aRect.Right() = GetScrPos( nEnd+1 )-nLayoutSign;
}
+ aRect = PixelToLogic( aRect );
Invalidate(aRect);
}
commit ad93f66b28e822477ad4c6fd0bf349f898373777
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jul 3 14:47:15 2014 +0200
Iterate from origin to tile area to ensure correct positioning.
Change-Id: I29e881f9e67b84e208a198d2aad06db382d14698
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 901fb69..08b8013 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -341,8 +341,16 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = true;
- SCCOL nX1 = pViewData->GetPosX(eHWhich);
- SCROW nY1 = pViewData->GetPosY(eVWhich);
+ // If we're doing tiled rendering we'll have a different output device here,
+ // and we could really be at a completely random position, hence we
+ // iterate from 0.
+ SCCOL nX1 = 0;
+ SCROW nY1 = 0;
+ if ( pOutDev == this )
+ {
+ nX1 = pViewData->GetPosX(eHWhich);
+ nY1 = pViewData->GetPosY(eVWhich);
+ }
SCTAB nTab = pViewData->GetTabNo();
@@ -381,6 +389,14 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
nScrY += pDoc->GetRowHeight( nY2, nTab );
}
+ // Bit hacky -- but Draw starts drawing with nX1/nY1 being at
+ // the output devices origin, so we make sure we start drawing
+ // with cell A1 at the origin etc.
+ if ( pOutDev != this )
+ {
+ nX1 = 0;
+ nY1 = 0;
+ }
// We specifically need to set the visible range here -- by default it is
// set in UpdateVisibleRange which however uses the viewdata, which is
// completely irrelevant for tiled rendering.
commit 267539542f993f7ed96b0e522cae924efa7ce1b4
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jul 3 14:46:32 2014 +0200
Use logic units for visible-cells determination.
This eliminates a bunch of LogicToPixel conversions, and also
means that tiles starting other than the origin are correctly
processed (as LogicToPixel run on a rectangle will also move that
rectangle depending on the origin set in the output device).
Change-Id: I42903fe23ad5f6baa1d5276d5dcc7ee038bd27cf
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index eec7d06..901fb69 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -341,46 +341,44 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = true;
- Rectangle aPixRect = pOutDev->LogicToPixel( rRect );
-
SCCOL nX1 = pViewData->GetPosX(eHWhich);
SCROW nY1 = pViewData->GetPosY(eVWhich);
SCTAB nTab = pViewData->GetTabNo();
- Rectangle aMirroredPixel = aPixRect;
+ Rectangle aMirroredRect = rRect;
if ( pDoc->IsLayoutRTL( nTab ) )
{
// mirror and swap
- long nWidth = GetSizePixel().Width();
- aMirroredPixel.Left() = nWidth - 1 - aPixRect.Right();
- aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
+ long nWidth = PixelToLogic(GetSizePixel()).Width();
+ aMirroredRect.Left() = nWidth - 1 - rRect.Right();
+ aMirroredRect.Right() = nWidth - 1 - rRect.Left();
}
- long nScrX = pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();/*ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );*/
- while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
+ long nScrX = pDoc->GetColWidth( nX1, nTab );
+ while ( nScrX <= aMirroredRect.Left() && nX1 < MAXCOL )
{
++nX1;
- nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();
+ nScrX += pDoc->GetColWidth( nX1, nTab );
}
SCCOL nX2 = nX1;
- while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
+ while ( nScrX <= aMirroredRect.Right() && nX2 < MAXCOL )
{
++nX2;
- nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX2, nTab ), 0 ) ).getX();
+ nScrX += pDoc->GetColWidth( nX2, nTab );
}
long nScrY = 0;
- while ( nScrY < aPixRect.Top() && nY1 < MAXROW )
+ while ( nScrY < rRect.Top() && nY1 < MAXROW )
{
++nY1;
- nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY1, nTab ) ) ).getY();
+ nScrY += pDoc->GetRowHeight( nY1, nTab );
}
SCROW nY2 = nY1;
- while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW )
+ while ( nScrY <= rRect.Bottom() && nY2 < MAXROW )
{
++nY2;
- nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY();
+ nScrY += pDoc->GetRowHeight( nY2, nTab );
}
// We specifically need to set the visible range here -- by default it is
commit 84274652d2c34603d4126c8c76ee4360d489f156
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jul 3 14:43:28 2014 +0200
Scale the origin for the Draw Layer (Calc Tiled Rendering).
Since we're changing units, we also need to scale the origin
by the correct amount.
Change-Id: Ie0563376e8fa56f20c30da4fe3cc50546f18e84f
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ca7195d..eec7d06 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -625,7 +625,9 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
// define drawing layer map mode and paint rectangle
MapMode aDrawMode = pOutDev->GetMapMode();
+ Point aOrigin = aDrawMode.GetOrigin();
aDrawMode.SetMapUnit( MAP_100TH_MM );
+ aDrawMode.SetOrigin( (aOrigin * 2540l) / 1440l );
Rectangle aDrawingRectLogic;
{
commit 3c249b202afc41bbe7e2b7b36497e6a5aaa219bc
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 25 22:37:54 2014 +0100
Use OutputDevice scaling for column-/rowbars too.
This means we now match the new gridwindow dimensions. There
are however some issues around selection/painting now, which
are presumably related to some parts of the code still assuming
pixel rather than logical dimensions.
Change-Id: I15c2bc7210f26cededd63bc89dbd782e6e4c03b8
diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx
index 745367e..d2b40b69 100644
--- a/sc/source/ui/inc/hdrcont.hxx
+++ b/sc/source/ui/inc/hdrcont.hxx
@@ -79,7 +79,6 @@ protected:
virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
// new methods
-
virtual SCCOLROW GetPos() const = 0; // current position (Scrolling)
virtual sal_uInt16 GetEntrySize( SCCOLROW nEntryNo ) const = 0; // width / height (Pixel)
virtual OUString GetEntryText( SCCOLROW nEntryNo ) const = 0;
diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx
index 3bc9c47..27ca257 100644
--- a/sc/source/ui/view/colrowba.cxx
+++ b/sc/source/ui/view/colrowba.cxx
@@ -83,7 +83,7 @@ sal_uInt16 ScColBar::GetEntrySize( SCCOLROW nEntryNo ) const
if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab))
return 0;
else
- return (sal_uInt16) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), pViewData->GetPPTX() );
+ return pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab );
}
OUString ScColBar::GetEntryText( SCCOLROW nEntryNo ) const
@@ -238,8 +238,7 @@ sal_uInt16 ScRowBar::GetEntrySize( SCCOLROW nEntryNo ) const
if (pDoc->RowHidden(nEntryNo, nTab, NULL, &nLastRow))
return 0;
else
- return (sal_uInt16) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo,
- nTab ), pViewData->GetPPTY() );
+ return pDoc->GetOriginalHeight( nEntryNo, nTab );
}
OUString ScRowBar::GetEntryText( SCCOLROW nEntryNo ) const
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
index 40997f2..3e77153 100644
--- a/sc/source/ui/view/hdrcont.cxx
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -111,6 +111,29 @@ void ScHeaderControl::DoPaint( SCCOLROW nStart, SCCOLROW nEnd )
bool bLayoutRTL = IsLayoutRTL();
long nLayoutSign = bLayoutRTL ? -1 : 1;
+ if ( nStart == nEnd )
+ {
+ // No point in painting 0 items...
+ // This happens e.g. during the construction, and can actually cause
+ // problems at that point as we don't yet have a viewshell, hence
+ // we can't populate the tab info, hence we get segfaults when trying
+ // to access inexistent data in the tabinfo.
+ return;
+ }
+
+ SCROW nY1 = 0, nY2 = 1;
+ SCCOL nX1 = 0, nX2 = 1;
+ if ( bVertical )
+ {
+ nY1 = nStart;
+ nY2 = nEnd + 1; // We request the size of nEnd+1 too below
+ }
+ else
+ {
+ nX1 = nStart;
+ nX2 = nEnd + 1; // We request the size of nEnd+1 too below
+ }
+
Rectangle aRect( Point(0,0), GetOutputSizePixel() );
if ( bVertical )
{
@@ -213,7 +236,7 @@ void ScHeaderControl::DrawShadedRect( long nStart, long nEnd, const Color& rBase
if ( IsMirrored() )
std::swap( aInner, aOuter ); // just swap colors instead of positions
- Size aWinSize = GetSizePixel();
+ Size aWinSize = PixelToLogic(GetSizePixel());
long nBarSize = bVertical ? aWinSize.Width() : aWinSize.Height();
long nCenterPos = (nBarSize / 2) - 1;
@@ -239,6 +262,25 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
{
// fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren
// Linien zusammengefasst
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (!pViewSh)
+ {
+ assert(false);
+ return;
+ }
+
+ ScViewData& rViewData = pViewSh->GetViewData();
+ MapMode aMapMode( GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ aMapMode.SetScaleX( rViewData.GetZoomX() * Fraction(0.96) );
+ aMapMode.SetScaleY( rViewData.GetZoomY() * Fraction(0.96) );
+ SetMapMode( aMapMode );
+
+ // We occasionally need to be able to measure 1 pixel
+ // e.g. for column/row subdivision, but we're working
+ // in logic units nowadays, hence we can grab the correct
+ // size from here.
+ const Size aOnePixel = PixelToLogic( Size( 1, 1 ) );
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
bool bHighContrast = rStyleSettings.GetHighContrastMode();
@@ -268,16 +310,16 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
Size aTextSize;
if (bVertical)
- nBarSize = (sal_uInt16) GetSizePixel().Width();
+ nBarSize = (sal_uInt16) PixelToLogic(GetSizePixel()).Width();
else
- nBarSize = (sal_uInt16) GetSizePixel().Height();
+ nBarSize = (sal_uInt16) PixelToLogic(GetSizePixel()).Height();
SCCOLROW nPos = GetPos();
long nPStart = bVertical ? rRect.Top() : rRect.Left();
long nPEnd = bVertical ? rRect.Bottom() : rRect.Right();
- long nTransStart = nPEnd + 1;
+ long nTransStart = nPEnd + (bVertical ? aOnePixel.Width() : aOnePixel.Height());
long nTransEnd = 0;
long nInitScrPos = 0;
@@ -290,9 +332,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
nTransStart = nTransEnd;
nTransEnd = nTemp;
if ( bVertical ) // start loops from the end
- nInitScrPos = GetSizePixel().Height() - 1;
+ nInitScrPos = PixelToLogic(GetSizePixel()).Height() - aOnePixel.Height();
else
- nInitScrPos = GetSizePixel().Width() - 1;
+ nInitScrPos = PixelToLogic(GetSizePixel()).Width() - aOnePixel.Width();
}
// aeussere Linien komplett durchzeichnen
@@ -309,7 +351,7 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
if ( bMarkRange && i >= nMarkStart && i <= nMarkEnd )
{
- long nLineStart = nLineEnd - ( nSizePix - 1 ) * nLayoutSign;
+ long nLineStart = nLineEnd - ( nSizePix - ( bVertical ? aOnePixel.Width() : aOnePixel.Height() ) ) * nLayoutSign;
if ( nLineStart * nLayoutSign < nTransStart * nLayoutSign )
nTransStart = nLineStart;
if ( nLineEnd * nLayoutSign > nTransEnd * nLayoutSign )
@@ -342,9 +384,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
// high contrast: single-color background
SetFillColor( rStyleSettings.GetFaceColor() );
if ( bVertical )
- aFillRect = Rectangle( 0, nInitScrPos, nBarSize-1, nLineEnd );
+ aFillRect = Rectangle( 0, nInitScrPos, nBarSize-aOnePixel.Width(), nLineEnd );
else
- aFillRect = Rectangle( nInitScrPos, 0, nLineEnd, nBarSize-1 );
+ aFillRect = Rectangle( nInitScrPos, 0, nLineEnd, nBarSize-aOnePixel.Height() );
DrawRect( aFillRect );
}
else
@@ -358,9 +400,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
{
SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::APPBACKGROUND).nColor );
if ( bVertical )
- aFillRect = Rectangle( 0, nLineEnd+nLayoutSign, nBarSize-1, nPEnd );
+ aFillRect = Rectangle( 0, nLineEnd+nLayoutSign, nBarSize-aOnePixel.Width(), nPEnd );
else
- aFillRect = Rectangle( nLineEnd+nLayoutSign, 0, nPEnd, nBarSize-1 );
+ aFillRect = Rectangle( nLineEnd+nLayoutSign, 0, nPEnd, nBarSize-aOnePixel.Height() );
DrawRect( aFillRect );
}
@@ -377,9 +419,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
SetLineColor();
SetFillColor( COL_LIGHTGRAY );
if (bVertical)
- DrawRect( Rectangle( 0, nTransStart, nBarSize-1, nTransEnd ) );
+ DrawRect( Rectangle( 0, nTransStart, nBarSize-aOnePixel.Width(), nTransEnd ) );
else
- DrawRect( Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 ) );
+ DrawRect( Rectangle( nTransStart, 0, nTransEnd, nBarSize-aOnePixel.Height() ) );
}
}
else
@@ -393,11 +435,11 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
SetLineColor( rStyleSettings.GetDarkShadowColor() );
if (bVertical)
{
- long nDarkPos = bMirrored ? 0 : nBarSize-1;
+ long nDarkPos = bMirrored ? 0 : nBarSize - aOnePixel.Width();
DrawLine( Point( nDarkPos, nPStart ), Point( nDarkPos, nLineEnd ) );
}
else
- DrawLine( Point( nPStart, nBarSize-1 ), Point( nLineEnd, nBarSize-1 ) );
+ DrawLine( Point( nPStart, nBarSize-aOnePixel.Height() ), Point( nLineEnd, nBarSize-aOnePixel.Height() ) );
// line in different color for selection
if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && !bHighContrast )
@@ -405,11 +447,11 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
SetLineColor( aSelLineColor );
if (bVertical)
{
- long nDarkPos = bMirrored ? 0 : nBarSize-1;
+ long nDarkPos = bMirrored ? 0 : nBarSize-aOnePixel.Width();
DrawLine( Point( nDarkPos, nTransStart ), Point( nDarkPos, nTransEnd ) );
}
else
- DrawLine( Point( nTransStart, nBarSize-1 ), Point( nTransEnd, nBarSize-1 ) );
+ DrawLine( Point( nTransStart, nBarSize-aOnePixel.Height() ), Point( nTransEnd, nBarSize-aOnePixel.Height() ) );
}
}
@@ -448,9 +490,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
Rectangle aTransRect;
if (bVertical)
- aTransRect = Rectangle( 0, nTransStart, nBarSize-1, nTransEnd );
+ aTransRect = Rectangle( 0, nTransStart, nBarSize-aOnePixel.Width(), nTransEnd );
else
- aTransRect = Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 );
+ aTransRect = Rectangle( nTransStart, 0, nTransEnd, nBarSize-aOnePixel.Height() );
SetBackground( Color( rStyleSettings.GetFaceColor() ) );
DrawSelectionBackground( aTransRect, 0, true, false, false );
SetBackground();
@@ -484,9 +526,9 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
{
Point aEndPos(aScrPos);
if (bVertical)
- aEndPos = Point( aScrPos.X()+nBarSize-1, aScrPos.Y()+(nSizePix-1)*nLayoutSign );
+ aEndPos = Point( aScrPos.X()+nBarSize-aOnePixel.Width(), aScrPos.Y()+(nSizePix-aOnePixel.Height())*nLayoutSign );
else
- aEndPos = Point( aScrPos.X()+(nSizePix-1)*nLayoutSign, aScrPos.Y()+nBarSize-1 );
+ aEndPos = Point( aScrPos.X()+(nSizePix-aOnePixel.Width())*nLayoutSign, aScrPos.Y()+nBarSize-aOnePixel.Height() );
bool bMark = bMarkRange && nEntryNo >= nMarkStart && nEntryNo <= nMarkEnd;
bool bNextToMark = bMarkRange && nEntryNo + 1 >= nMarkStart && nEntryNo <= nMarkEnd;
@@ -531,6 +573,7 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
aString = GetEntryText( nEntryNo );
aTextSize.Width() = GetTextWidth( aString );
aTextSize.Height() = GetTextHeight();
+ aTextSize = PixelToLogic( aTextSize );
Point aTxtPos(aScrPos);
if (bVertical)
@@ -538,14 +581,20 @@ void ScHeaderControl::Paint( const Rectangle& rRect )
aTxtPos.X() += (nBarSize-aTextSize.Width())/2;
aTxtPos.Y() += (nSizePix*nLayoutSign-aTextSize.Height())/2;
if ( bMirrored )
- aTxtPos.X() += 1; // dark border is left instead of right
+ aTxtPos.X() += aOnePixel.Width(); // dark border is left instead of right
}
else
{
- aTxtPos.X() += (nSizePix*nLayoutSign-aTextSize.Width()+1)/2;
+ aTxtPos.X() += (nSizePix*nLayoutSign-aTextSize.Width()+aOnePixel.Width())/2;
aTxtPos.Y() += (nBarSize-aTextSize.Height())/2;
}
+ aTxtPos = LogicToPixel( aTxtPos );
+ // Text is in pixels, so easiest just to map that way
+ // only here.
+ const MapMode aOriginalMapMode( GetMapMode() );
+ SetMapMode( MapMode( MAP_PIXEL ) );
DrawText( aTxtPos, aString );
+ SetMapMode( aOriginalMapMode );
}
break;
}
commit aa8b2fac7ec02e310356ff5a5342851a416e196d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 26 17:06:58 2014 +0100
Ensure we actually render all cells in the selected area.
Only cells within maVisibleRange are rendered, even if we request
a larger area (and maVisibleRange is otherwise not updated for tiled
rendering). Hence we should explicitly set it here.
Change-Id: I399be9df1f266a2b3d32a95483960b21f561c6b3
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 30b9b6b..ca7195d 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -383,6 +383,10 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY();
}
+ // We specifically need to set the visible range here -- by default it is
+ // set in UpdateVisibleRange which however uses the viewdata, which is
+ // completely irrelevant for tiled rendering.
+ maVisibleRange.set( nX1, nY1, nX2, nY2 );
Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev ); // nicht weiterzeichnen
bIsInPaint = false;
}
commit 454412b7a3e778dff6098e13dd7c1b56cead91dd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Thu Jun 26 14:30:08 2014 +0100
Take into account drawing layer for data area size.
The drawing layer could potentially have items that are outwith
the data area, but we probably want to have them included for
tiled rendering.
Change-Id: I958c4fa29491cdb0fd80392dfcfa033306f2b76c
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ed80760..30b9b6b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -29,6 +29,7 @@
#include <sfx2/printer.hxx>
#include <vcl/settings.hxx>
+#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
#include "tabvwsh.hxx"
@@ -394,17 +395,32 @@ Size ScGridWindow::GetDataAreaSize()
SCTAB nTab = pViewData->GetTabNo();
+ // Actual data area
pDoc->ShrinkToDataArea( nTab,
nStartCol, nStartRow, nEndCol, nEndRow );
+ // Drawing layer area -- is completely independent of the data area.
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
+ SdrView* pDrawView = pTabViewShell->GetSdrView();
+ SdrPageView* pPageView = pDrawView->GetSdrPageView();
+ SdrPage* pPage = pPageView->GetPage();
+ Rectangle aDrawDataArea = pPage->GetAllObjBoundRect();
+ // Draw layer works in 100th mm, whereas we're working with TWIPs.
+ aDrawDataArea.SetPos( aDrawDataArea.TopLeft() * 1440 / 2540 );
+ aDrawDataArea.SetSize( Size( aDrawDataArea.GetSize().Width() * 1440 / 2540,
+ aDrawDataArea.GetSize().Height() * 1440 / 2540 ) );
+
+ // We specifically keep iterating until we have covered both the
+ // data area AND the drawing layer area. We also make sure that
+ // we return an area corresponding to a whole number of cells.
long nX = 0;
- for ( SCCOL i = 0; i <= nEndCol; i++ )
+ for ( SCCOL i = 0; i <= nEndCol || nX < aDrawDataArea.Right(); i++ )
{
nX += pDoc->GetColWidth( i, nTab );
}
long nY = 0;
- for ( SCROW i = 0; i <= nEndRow; i++ )
+ for ( SCROW i = 0; i <= nEndRow || nY < aDrawDataArea.Bottom(); i++ )
{
nY += pDoc->GetRowHeight( i, nTab );
}
commit d11bf4ce76d9de190fd2fcdd60ae1202fd86be2d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Tue Jun 24 22:06:59 2014 +0100
Use output device mapping for draw layer too.
Otherwise draw layer items don't get scaled at all for tiled
rendering.
Change-Id: If65d460a83fb29b8eda692cb7c1f2bd9f7283e62
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9f5cbcc..ed80760 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -604,7 +604,8 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
}
// define drawing layer map mode and paint rectangle
- const MapMode aDrawMode = GetDrawMapMode();
+ MapMode aDrawMode = pOutDev->GetMapMode();
+ aDrawMode.SetMapUnit( MAP_100TH_MM );
Rectangle aDrawingRectLogic;
{
commit 9032fd2a8b16284bb6a6131898151f468dd3c8d3
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 11:07:33 2014 +0100
Set correct scaling for normal painting.
As we no longer read the scaling from the viewdata, we should
instead set it on the output device when doing normal rendering.
However the grid still doesn't exactly match the external axes yet,
there are probably more rounding errors wherever they are painted.
Change-Id: I25b1bd9b344115578fe892aa94fbf753a3c10c81
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 962ac97..9f5cbcc 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 )
{
+ MapMode aMapMode( GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ aMapMode.SetScaleX( pViewData->GetZoomX() * Fraction(0.96) );
+ aMapMode.SetScaleY( pViewData->GetZoomY() * Fraction(0.96) );
+ SetMapMode( aMapMode );
Paint( rRect, this );
}
commit 2ecfc9a6306c56670490c9cf6cf624fcfd2ac5a4
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 20 10:35:45 2014 +0100
Use output device scaling to determine cells in draw-area.
Change-Id: Idf4e6ccb72090a55b6a9234cafae21821e3df0b0
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 2e3c2ed..962ac97 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -342,9 +342,6 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
SCTAB nTab = pViewData->GetTabNo();
- double nPPTX = pViewData->GetPPTX();
- double nPPTY = pViewData->GetPPTY();
-
Rectangle aMirroredPixel = aPixRect;
if ( pDoc->IsLayoutRTL( nTab ) )
{
@@ -354,26 +351,30 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
}
- long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ long nScrX = pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();/*ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );*/
while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
{
++nX1;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX1, nTab ), 0 ) ).getX();
}
SCCOL nX2 = nX1;
while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
{
++nX2;
- nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
+ nScrX += pOutDev->LogicToPixel( Point( pDoc->GetColWidth( nX2, nTab ), 0 ) ).getX();
}
long nScrY = 0;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
+ while ( nScrY < aPixRect.Top() && nY1 < MAXROW )
+ {
+ ++nY1;
+ nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY1, nTab ) ) ).getY();
+ }
SCROW nY2 = nY1;
- if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
+ while ( nScrY <= aPixRect.Bottom() && nY2 < MAXROW )
{
++nY2;
- ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
+ nScrY += pOutDev->LogicToPixel( Point( 0, pDoc->GetRowHeight( nY2, nTab ) ) ).getY();
}
Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS, pOutDev ); // nicht weiterzeichnen
commit b21b49411814709dcd906e019484a8bff5cf7e9b
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 a6b7b90..4313856 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -278,7 +278,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;
@@ -393,11 +393,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 );
}
}
}
@@ -418,9 +414,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 6a6d3ef..2e3c2ed 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -713,7 +713,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 ) )
@@ -920,18 +919,20 @@ 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);
+
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 );
commit 8048df655c59a430ee22a43412787e30f126ab30
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Wed Jun 18 09:33:16 2014 +0100
Implement data area size retrieval.
Cell dimensions appear to be in TWIPs (but the drawing layer is in 100th mm).
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index f14867c..dfb9b84 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -322,10 +322,19 @@ 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/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4e4bff8..68d4402 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -481,10 +481,15 @@ int ScModelObj::getPart()
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 39c423d..6a6d3ef 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -380,6 +380,36 @@ 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: this ignores any images / etc., which could be outside
+ // the data area.
+
+ // This doesn't include the final (bottom & right) borders...
+ return Size( nX, nY );
+}
+
// Draw ----------------------------------------------------------------
void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode,
OutputDevice* pOutDev )
@@ -482,6 +512,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
Fraction aZoomX = pViewData->GetZoomX();
Fraction aZoomY = pViewData->GetZoomY();
+
ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );
commit afdd8b5f4080b8b5e64b7a4bef4cc8ac62ac4305
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 e596b0c..f14867c 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 f882ab0..39c423d 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;
}
@@ -590,7 +594,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
@@ -848,7 +852,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);
}
@@ -908,7 +912,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 0c7084b36c0bb5b17cf03be05616756016c5743b
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 95042d5..f882ab0 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"
@@ -900,7 +901,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 f2a219eda4ef4011dbcdbc18c2ad2210ea17c4f2
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 ed066b2..e596b0c 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 2893974..4e4bff8 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -484,7 +484,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 a60fb82..95042d5 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -376,9 +376,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 +477,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, &rDoc, nTab,
+ ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );
@@ -587,7 +592,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 +611,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
@@ -877,13 +884,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 f412bf91a5f3c60197168b7baef1a8f058f6236b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 25 21:03:19 2014 +0200
Make sure LOK is actually headless.
This prevents e.g. the document recovery dialog from trying to be shown.
Change-Id: I253720f7fa1abd1c053670434f8394473517b670
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 567f5ae..b73e4e2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -626,13 +626,24 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
try
{
+ // We specifically need to make sure we have the "headless"
+ // command arg set (various code specifically checks via
+ // CommandLineArgs). We could alternatively add some other
+ // flag elsewhere to indicate headlessness, which would
+ // then be set from here or via CommandLineArgs.
+ // (The first argument is treated specially by osl_setCommandArgs
+ // however it is valid to make it \0 instead.)
+ char sName[] = "";
+ char sHeadless[] = "--headless";
+ char* pArgs[2] = { sName, sHeadless };
+
// If we've set up the command args elsewhere then we cannot do it
// again (as an assert will fire), this will be the case e.g.
// for unit tests (and possibly if UNO is being used in addition
// to LOK in an external program).
if (!osl_areCommandArgsSet())
{
- osl_setCommandArgs(0, NULL);
+ osl_setCommandArgs(2, pArgs);
}
initialize_uno(aAppURL);
force_c_locale();
commit ceda3f60f3ba92b4e99651d0ba9da310e0cb081c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 25 20:56:18 2014 +0200
Don't fail on --protector.
If we have any "unknown" command line arguments Desktop init will fail,
however our LOK Tiled Rendering test uses Desktop (via soffice_main).
(Other unit tests don't use soffice_main hence this check never
comes into play.) It looks like it's most reliable simply to ignore
--protector here, rather than try to filter it out elsewhere (which
is difficult as it is passed to osl via SAL_IMPLEMENT_MAIN).
Change-Id: I95d047892851ba2cf9edd2e26bacc6efa0320f71
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index 5f98e07..a0eefbe 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -252,6 +252,18 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
{
m_helpmath = true;
}
+ else if ( oArg == "protector" )
+ {
+ // Not relevant for us here, but can be used in unit tests.
+ // Usually unit tests would not end up here, but e.g. the
+ // LOK Tiled Rendering tests end up running a full soffice
+ // process, and we can't bail on the use of --protector.
+
+ // We specifically need to consume the following 2 arguments
+ // for --protector
+ assert( supplier.next( &aArg ) );
+ assert( supplier.next( &aArg ) );
+ }
else if ( oArg == "version" )
{
m_version = true;
commit d62e9fa1df9b948b3583ce6b7f6508f15215a31a
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 21:16:09 2014 +0200
Don't start Impress Remote server in headless mode.
Change-Id: Ibafe57413a60745e949dc3146fbc843c52c029d6
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 5ec1184..69e5292 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -360,6 +360,21 @@ void RemoteServer::deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient
void SdDLL::RegisterRemotes()
{
SAL_INFO( "sdremote", "SdDLL::RegisterRemotes called" );
+
+ // The remote server is likely of no use in headless mode. And as only
+ // one instance of the server can actually own the appropriate ports its
+ // probably best to not even try to do so from our headless instance
+ // (i.e. as to avoid blocking expected usage).
+ // It could perhaps be argued that we would still need the remote
+ // server for tiled rendering of presentations, but even then this
+ // implementation would not be of much use, i.e. would be controlling
+ // the purely imaginary headless presentation -- instead we'd need
+ // to have some sort of mechanism of plugging in our tiled rendering
+ // client to be controlled by the remote server, or provide an
+ // alternative implementation.
+ if ( Application::IsHeadlessModeEnabled() )
+ return;
+
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
if ( xContext.is() && !officecfg::Office::Impress::Misc::Start::EnableSdremote::get( xContext ) )
return;
commit 8ce73d21b69eda11de619cad8a87df2c14eb95ac
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 19:36:11 2014 +0200
Use gb_CppunitTest_use_confpreinit for LOK tiled rendering.
Now that we use the event loop for LOK we need to make sure that
it is able to run successfully first time, as unit tests start
with a completely clean config.
Change-Id: If9ddcb75fe8286381d71ecdc76ac7eb3697960d0
diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
index 4b77fbf..9159a24 100644
--- a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
+++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
@@ -29,7 +29,6 @@ $(eval $(call gb_CppunitTest_use_libraries,libreofficekit_tiledrendering, \
$(gb_UWINAPI) \
))
-
# unotest \
ifeq ($(OS),LINUX)
@@ -54,4 +53,6 @@ $(eval $(call gb_CppunitTest_use_rdb,libreofficekit_tiledrendering,services))
$(eval $(call gb_CppunitTest_use_configuration,libreofficekit_tiledrendering))
+$(eval $(call gb_CppunitTest_use_confpreinit,libreofficekit_tiledrendering))
+
# vim: set noet sw=4 ts=4:
commit 3e6c1dd9fcac00c0d4366cd4774fb1ee81dbe3cd
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 19:35:13 2014 +0200
Add gb_CppunitTest_use_confpreinit:
For unit tests that use the VCL event loop we can use this to
avoid the otherwise required restart.
Change-Id: I48265d7e7188a4efaa6f87432c762320331c0c78
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index df5c61b..66dcb05 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -75,6 +75,8 @@ $(call gb_CppunitTest_get_target,%) :| $(gb_CppunitTest_CPPTESTDEPS)
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(dir $@) && \
rm -fr $@.user && mkdir $@.user && \
+ $(if $(gb_CppunitTest__use_confpreinit), \
+ $(INSTDIR)/program/lokconf_init $(call gb_CppunitTest__make_args) &&) \
$(if $(gb_CppunitTest__interactive),, \
$(if $(value gb_CppunitTest_postprocess), \
rm -fr $@.core && mkdir $@.core && cd $@.core &&)) \
@@ -166,6 +168,12 @@ endif
endef
+define gb_CppunitTest_use_confpreinit
+$(call gb_CppunitTest_use_executable,$(1),lokconf_init)
+$(call gb_CppunitTest_get_target,$(1)) : gb_CppunitTest__use_confpreinit := TRUE
+
+endef
+
define gb_CppunitTest_use_vcl
$(call gb_CppunitTest__use_vcl,$(1),$(true))
commit c632efde58625a2644a33666d5e8e04833a43e80
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 19:34:09 2014 +0200
Implement lokconf_init.
This is a simple executable which can be used to ensure there is a
pe-pared configuration for unit-tests to avoid the usually required
re-start on the first run.
Change-Id: I49b706e8daa93bc34db508a24615b63b9babddba
diff --git a/Repository.mk b/Repository.mk
index 10c8f62..e678db5 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -101,6 +101,7 @@ $(eval $(call gb_Helper_register_executables,OOO, \
uri-encode \
ui-previewer \
tiledrendering \
+ $(if $(filter LINUX,$(OS)), lokconf_init) \
$(if $(and $(ENABLE_GTK), $(filter LINUX,$(OS))), gtktiledviewer) \
$(if $(filter DESKTOP,$(BUILD_TYPE)),unopkg_bin) \
xpdfimport \
diff --git a/libreofficekit/Executable_lokconf_init.mk b/libreofficekit/Executable_lokconf_init.mk
new file mode 100644
index 0000000..3e25f13
--- /dev/null
+++ b/libreofficekit/Executable_lokconf_init.mk
@@ -0,0 +1,42 @@
+# -*- 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_Executable_Executable,lokconf_init))
+
+$(eval $(call gb_Executable_set_include,lokconf_init,\
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_Executable_use_libraries,lokconf_init, \
+ cppu \
+ sal \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,lokconf_init,\
+ libreofficekit \
+))
+
+$(eval $(call gb_Executable_add_libs,lokconf_init,\
+ -lSM \
+ -lICE \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Executable_add_libs,lokconf_init,\
+ -lm \
+ -ldl \
+ -lpthread \
+))
+endif
+
+$(eval $(call gb_Executable_add_exception_objects,lokconf_init,\
+ libreofficekit/qa/lokconf_init/lokconf_init \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 1f0771c..8523b1a 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -13,6 +13,7 @@ ifeq ($(OS),LINUX)
$(eval $(call gb_Module_add_targets,libreofficekit,\
StaticLibrary_libreofficekit \
+ Executable_lokconf_init \
))
# $(eval $(call gb_Module_add_check_targets,libreofficekit,\
diff --git a/libreofficekit/qa/lokconf_init/lokconf_init.cxx b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
new file mode 100644
index 0000000..9677159
--- /dev/null
+++ b/libreofficekit/qa/lokconf_init/lokconf_init.cxx
@@ -0,0 +1,41 @@
+/* -*- 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 <stdio.h>
+#include <string>
+#include <string.h>
+
+#include <sal/main.h>
+
+#include <LibreOfficeKit/LibreOfficeKit.h>
+
+using namespace std;
+
+// Using SAL_IMPLEMENT_MAIN means that we can directly use the same
+// arguments as would be provided to cppunittester, i.e. ensuring
+// that we're operating with the correct directories etc.
+SAL_IMPLEMENT_MAIN()
+{
+ string sPath( getenv("INSTDIR") );
+ sPath += "/program";
+
+ LibreOfficeKit* pOffice = lok_init( sPath.c_str() );
+
+ // As this is the first init, pOffice should be NULL.
+ // However there's no reason we shouldn't be able to operate
+ // even if it isn't the first init.
+ if ( pOffice )
+ {
+ pOffice->pClass->destroy( pOffice );
+ pOffice = 0;
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit abbb40ffedc3a102573d412cf3c706be4612a5f3
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 18 13:12:25 2014 +0200
Fail LOK initialisation if restart is required.
Change-Id: Ia13a3523666147f002b5a5177fd6962d55556f56
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 76d05f3..567f5ae 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -661,6 +661,15 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
pthread_create(&thread, 0, lo_startmain, NULL);
OfficeIPCThread::WaitForReady();
+ // If the Thread has been disabled again that indicates that a
+ // restart is required (or in any case we don't have a useable
+ // process around).
+ if (!OfficeIPCThread::IsEnabled())
+ {
+ fprintf(stderr, "LOK init failed -- restart required\n");
+ return false;
+ }
+
Application::EnableHeadlessMode(true);
ErrorHandler::RegisterDisplay(aBasicErrorFunc);
commit eea31395bb68bc57c69147a2870d0e59e11c6756
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 18 13:10:14 2014 +0200
Add OfficeIPCThread::IsEnabled.
This lets us easily check whether Desktop::Main has shut down,
i.e. which happens on the first restart-requiring initialisation.
Change-Id: I7fe5699a4bf59e2c3b891ac73abd9b147773d22e
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 93cd339..eaacf81 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -681,6 +681,11 @@ void OfficeIPCThread::WaitForReady(
}
}
+bool OfficeIPCThread::IsEnabled()
+{
+ return pGlobalOfficeIPCThread.is();
+}
+
void OfficeIPCThread::execute()
{
#if HAVE_FEATURE_DESKTOP
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index 9c1d751..8ed40fd 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -128,6 +128,7 @@ class OfficeIPCThread : public salhelper::Thread
static void WaitForReady(
rtl::Reference< OfficeIPCThread > const & pThread =
rtl::Reference< OfficeIPCThread >());
+ static bool IsEnabled();
bool AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
};
commit d5360279be56da750c1e9890340e8c62df073f08
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 18 10:02:48 2014 +0200
Use OfficeIPCThread::WaitForReady rather than sleeping.
This way we actually continue when we're ready to, rather than
dumbly hoping we wait for long enough.
This isn't entirely unproblematic though -- if we have no config
pre-prepared (i.e. first-run), then we just end up hanging on this
since soffice_main exits without doing anything to the OfficeIPCThread.
(Which is especially problematic for unit tests which specifically run
on an empty config.)
Change-Id: I064fb500a224cfe37a0d3ba24b6154ffd72a71a3
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 0be5f8d..76d05f3 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -60,8 +60,10 @@
// We also need to hackily be able to start the main libreoffice thread
#include "../app/sofficemain.h"
+#include "../app/officeipcthread.hxx"
using namespace css;
+using namespace desktop;
using namespace utl;
using namespace boost;
@@ -637,22 +639,27 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
// Force headless -- this is only for bitmap rendering.
rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
-// InitVCL();
- // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
- // unfortunately -- which is annoying since (see below)
+ // We could use InitVCL() here -- and used to before using soffice_main,
+ // however that now deals with the initialisation for us (and it's not
+ // possible to try to set up VCL twice.
+
+ // Instead VCL init is done for us by soffice_main in a separate thread,
+ // however we specifically can't proceed until this setup is complete
+ // (or you get segfaults trying to use VCL and/or deadlocks due to other
+ // setup within soffice_main). Specifically the various Application::
+ // functions depend on VCL being ready -- the deadlocks would happen
+ // if you try to use loadDocument too early.
+
+ // The OfficeIPCThread is specifically set to be read when all the other
+ // init in Desktop::Main (run from soffice_main) is done. We can "enable"
+ // the Thread from wherever (it's done again in Desktop::Main), and can
+ // then use it to wait until we're definitely ready to continue.
+
+ OfficeIPCThread::EnableOfficeIPCThread();
pthread_t thread;
pthread_create(&thread, 0, lo_startmain, NULL);
- sleep(10);
- // We'll segfault trying to access Application if we're too fast...
- // Specifically pImplSVData doesn't exist until InitVCL has been called,
- // and that won't be immediate, but we can't call InitVCL ourselves
- // as soffice_main already does so, but InitVCL would then fail
- // within soffice_main if we have already called it earlier.
- //
- // And there's also a chance of deadlock if we try to open documents
- // too early -- when running in a debugger we therefore need quite
- // a large delay here (for now).
+ OfficeIPCThread::WaitForReady();
Application::EnableHeadlessMode(true);
commit 484084bad2e12caeefd38f6bdd0cfc0e094e668b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 18 10:00:42 2014 +0200
Bin outdated / incorrect comment.
Change-Id: I7b8f97377b9606a2228f172f772d8051a64703d2
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index e9a1eed..0be5f8d 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -635,10 +635,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
initialize_uno(aAppURL);
force_c_locale();
- // Force headless
- // the "svp" headless vcl backend isn't able to do tiled rendering for
- // us -- we need to use a full featured backend, i.e. "gen" or "gtk",
- // gtk seems to be somewhat better.
+ // Force headless -- this is only for bitmap rendering.
rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
// InitVCL();
// InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
commit a3f17741188eeac728d14f564c8d64e00a48041d
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 18 09:48:47 2014 +0200
Add OfficeIPCThread::WaitForReady.
For LibreOfficeKit we need to start up the event loop, and can't continue
initialisation until all the related (VCL etc.) setup is complete -- the
OfficeIPCThread is also enabled as one of the last items, and can be
used to indicate whether or not we can start actually working with VCL.
Change-Id: I0450b65584ddf6e8d02ce0c6e66e06f47841d1b7
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index aed17b9..93cd339 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -669,6 +669,18 @@ void OfficeIPCThread::SetReady(
}
}
+void OfficeIPCThread::WaitForReady(
+ rtl::Reference< OfficeIPCThread > const & pThread)
+
+{
+ rtl::Reference< OfficeIPCThread > const & t(
+ pThread.is() ? pThread : pGlobalOfficeIPCThread);
+ if (t.is())
+ {
+ t->cReady.wait();
+ }
+}
+
void OfficeIPCThread::execute()
{
#if HAVE_FEATURE_DESKTOP
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index 4628eca..9c1d751 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -125,6 +125,9 @@ class OfficeIPCThread : public salhelper::Thread
static void SetReady(
rtl::Reference< OfficeIPCThread > const & pThread =
rtl::Reference< OfficeIPCThread >());
+ static void WaitForReady(
+ rtl::Reference< OfficeIPCThread > const & pThread =
+ rtl::Reference< OfficeIPCThread >());
bool AreRequestsEnabled() const { return mbRequestsEnabled && ! mbDowning; }
};
commit ec721f5cd397b0e2ad8f69ce27844e9177ecf96e
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sat Jul 26 16:06:04 2014 +0200
Hack soffice_main into LOK.
Change-Id: I86e13192ddb5904afabca38d3a201f17f145de09
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index be86dd1..a90bcd1 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -17,6 +17,13 @@ $(eval $(call gb_Library_set_include,sofficeapp,\
-I$(SRCDIR)/vcl/inc \
))
+$(eval $(call gb_Library_add_libs,sofficeapp,\
+ $(if $(filter $(OS),LINUX), \
+ -ldl \
+ -lpthread \
+ ) \
+))
+
$(eval $(call gb_Library_use_external,sofficeapp,boost_headers))
$(eval $(call gb_Library_use_custom_headers,sofficeapp,\
@@ -47,6 +54,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
sfx \
svl \
svt \
+ sw \
tk \
tl \
ucbhelper \
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6c4d5cc..e9a1eed 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -58,6 +58,9 @@
#include <basebmp/bitmapdevice.hxx>
#endif
+// We also need to hackily be able to start the main libreoffice thread
+#include "../app/sofficemain.h"
+
using namespace css;
using namespace utl;
@@ -587,6 +590,12 @@ static void initialize_uno(const OUString &aAppProgramURL)
// configmgr setup ?
}
+static void* lo_startmain(void*)
+{
+ soffice_main();
+ return 0;
+}
+
static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
{
(void) pThis;
@@ -627,8 +636,27 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath)
force_c_locale();
// Force headless
+ // the "svp" headless vcl backend isn't able to do tiled rendering for
+ // us -- we need to use a full featured backend, i.e. "gen" or "gtk",
+ // gtk seems to be somewhat better.
rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
- InitVCL();
+// InitVCL();
+ // InitVCL() happens in soffice_main for us -- and we can't call InitVCL twice
+ // unfortunately -- which is annoying since (see below)
+
+ pthread_t thread;
+ pthread_create(&thread, 0, lo_startmain, NULL);
+ sleep(10);
+ // We'll segfault trying to access Application if we're too fast...
+ // Specifically pImplSVData doesn't exist until InitVCL has been called,
+ // and that won't be immediate, but we can't call InitVCL ourselves
+ // as soffice_main already does so, but InitVCL would then fail
+ // within soffice_main if we have already called it earlier.
+ //
+ // And there's also a chance of deadlock if we try to open documents
+ // too early -- when running in a debugger we therefore need quite
+ // a large delay here (for now).
+
Application::EnableHeadlessMode(true);
ErrorHandler::RegisterDisplay(aBasicErrorFunc);
commit 0bed662171dea7b30ac3af12093b5196f2497a49
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jul 21 19:39:49 2014 +0200
gtktiledviewer: make sure we clean up the office instance.
Change-Id: I12c3e9df8b8fcf8dcd6fb5fa781c2f7c10ab0a0c
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 3c8dc97..1887442 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -226,5 +226,9 @@ int main( int argc, char* argv[] )
gtk_main();
+ pOffice->pClass->destroy( pOffice );
+
return 0;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 7eba2d637334f67ab8a6e7883d9aecb1c3c31e93
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat Jul 26 14:50:59 2014 +0100
drop rtl:: and statics
Change-Id: I6108efad77cf1c21dea3826ae149f3750552b0ed
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index 6a5217c..4793ddf 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -82,7 +82,7 @@ namespace svgio
// helper to convert a string associated with a token of type SVGTokenDisplay
// to the enum Display. Empty trings return the default 'Display_inline' with
// which members should be initialized
- Display getDisplayFromContent(const rtl::OUString& aContent);
+ Display getDisplayFromContent(const OUString& aContent);
class SvgNode : private boost::noncopyable, public InfoProvider
{
@@ -122,10 +122,10 @@ namespace svgio
protected:
/// helper to evtl. link to css style
- const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+ const SvgStyleAttributes* checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
/// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
- void fillCssStyleVector(const rtl::OUString& rClassStr);
+ void fillCssStyleVector(const OUString& rClassStr);
public:
SvgNode(
@@ -135,7 +135,7 @@ namespace svgio
virtual ~SvgNode();
/// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
- void readLocalCssStyle(const rtl::OUString& aContent);
+ void readLocalCssStyle(const OUString& aContent);
/// style helpers
void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 92ea5b5..d31979b 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -65,8 +65,8 @@ namespace svgio
const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
{
- static rtl::OUString aClassStrA(rtl::OUString::createFromAscii("linearGradient"));
- static rtl::OUString aClassStrB(rtl::OUString::createFromAscii("radialGradient"));
+ OUString aClassStrA("linearGradient");
+ OUString aClassStrB("radialGradient");
return checkForCssStyle(
SVGTokenLinearGradient == getType() ? aClassStrA : aClassStrB,
diff --git a/svgio/source/svgreader/svggradientstopnode.cxx b/svgio/source/svgreader/svggradientstopnode.cxx
index 6c6d758..a1ce201 100644
--- a/svgio/source/svgreader/svggradientstopnode.cxx
+++ b/svgio/source/svgreader/svggradientstopnode.cxx
@@ -38,7 +38,7 @@ namespace svgio
const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
{
- static rtl::OUString aClassStr(rtl::OUString::createFromAscii("stop"));
+ OUString aClassStr("stop");
return checkForCssStyle(aClassStr, maSvgStyleAttributes);
}
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 24decd3..1652a25 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -40,7 +40,7 @@ namespace svgio
return 0;
}
- void SvgNode::fillCssStyleVector(const rtl::OUString& rClassStr)
+ void SvgNode::fillCssStyleVector(const OUString& rClassStr)
{
OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?");
mbCssStyleVectorBuilt = true;
@@ -75,7 +75,7 @@ namespace svgio
{
// concatenate combined style name during search for CSS style equal to Id
// when travelling over node parents
- rtl::OUString aConcatenatedStyleName;
+ OUString aConcatenatedStyleName;
const SvgNode* pCurrent = this;
const SvgStyleAttributes* pNew = 0;
@@ -104,7 +104,7 @@ namespace svgio
if(getClass())
{
// find all referenced CSS styles (a list of entries is allowed)
- const rtl::OUString* pClassList = getClass();
+ const OUString* pClassList = getClass();
const sal_Int32 nLen(pClassList->getLength());
sal_Int32 nPos(0);
const SvgStyleAttributes* pNew = 0;
@@ -113,13 +113,13 @@ namespace svgio
while(nPos < nLen)
{
- rtl::OUStringBuffer aTokenValue;
+ OUStringBuffer aTokenValue;
copyToLimiter(*pClassList, sal_Unicode(' '), nPos, aTokenValue, nLen);
skip_char(*pClassList, sal_Unicode(' '), nPos, nLen);
- rtl::OUString aId(rtl::OUString::createFromAscii("."));
- const rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ OUString aId(OUString::createFromAscii("."));
+ const OUString aOUTokenValue(aTokenValue.makeStringAndClear());
// look for CSS style common to token
aId = aId + aOUTokenValue;
@@ -154,7 +154,7 @@ namespace svgio
}
}
- const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+ const SvgStyleAttributes* SvgNode::checkForCssStyle(const OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
{
if(!mbCssStyleVectorBuilt)
{
@@ -266,7 +266,7 @@ namespace svgio
}
}
- void SvgNode::readLocalCssStyle(const rtl::OUString& aContent)
+ void SvgNode::readLocalCssStyle(const OUString& aContent)
{
if(!mpLocalCssStyle)
{
@@ -306,7 +306,7 @@ namespace svgio
}
}
- Display getDisplayFromContent(const rtl::OUString& aContent)
+ Display getDisplayFromContent(const OUString& aContent)
{
if(aContent.getLength())
{
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index b48431d..82104ae 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -184,21 +184,21 @@ namespace svgio
if(!aTokenName.isEmpty())
{
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(':'), nPos, nLen);
- rtl::OUStringBuffer aTokenValue;
+ OUStringBuffer aTokenValue;
copyToLimiter(rCandidate, sal_Unicode(';'), nPos, aTokenValue, nLen);
skip_char(rCandidate, sal_Unicode(' '), sal_Unicode(';'), nPos, nLen);
- const rtl::OUString aOUTokenName(aTokenName.makeStringAndClear());
- rtl::OUString aOUTokenValue(aTokenValue.makeStringAndClear());
+ const OUString aOUTokenName(aTokenName.makeStringAndClear());
+ OUString aOUTokenValue(aTokenValue.makeStringAndClear());
// check for '!important' CssStyle mark, currently not supported
// but neds to be extracted for correct parsing
- static rtl::OUString aTokenImportant(RTL_CONSTASCII_USTRINGPARAM("!important"));
+ OUString aTokenImportant("!important");
const sal_Int32 nIndexTokenImportant(aOUTokenValue.indexOf(aTokenImportant));
if(-1 != nIndexTokenImportant)
{
// if there currently just remove it and remove spaces to have the value only
- rtl::OUString aNewOUTokenValue;
+ OUString aNewOUTokenValue;
if(nIndexTokenImportant > 0)
{
diff --git a/svgio/source/svgreader/svgstylenode.cxx b/svgio/source/svgreader/svgstylenode.cxx
index b17c528..e5b965f 100644
--- a/svgio/source/svgreader/svgstylenode.cxx
+++ b/svgio/source/svgreader/svgstylenode.cxx
@@ -98,15 +98,15 @@ namespace svgio
copyToLimiter(aContent, sal_Unicode('{'), nPos, aTokenValue, nLen);
skip_char(aContent, sal_Unicode(' '), sal_Unicode('{'), nPos, nLen);
- const rtl::OUString aStyleName(aTokenValue.makeStringAndClear().trim());
+ const OUString aStyleName(aTokenValue.makeStringAndClear().trim());
const sal_Int32 nLen2(aStyleName.getLength());
- std::vector< rtl::OUString > aStyleNames;
+ std::vector< OUString > aStyleNames;
if(nLen2)
{
// extract names
sal_Int32 nPos2(0);
- rtl::OUStringBuffer aSingleName;
+ OUStringBuffer aSingleName;
while(nPos2 < nLen2)
{
@@ -114,7 +114,7 @@ namespace svgio
copyToLimiter(aStyleName, sal_Unicode(' '), nPos2, aSingleName, nLen2);
skip_char(aStyleName, sal_Unicode(' '), nPos2, nLen2);
- const rtl::OUString aOUSingleName(aSingleName.makeStringAndClear().trim());
+ const OUString aOUSingleName(aSingleName.makeStringAndClear().trim());
if(aOUSingleName.getLength())
{
@@ -127,7 +127,7 @@ namespace svgio
{
copyToLimiter(aContent, sal_Unicode('}'), nPos, aTokenValue, nLen);
skip_char(aContent, sal_Unicode(' '), sal_Unicode('}'), nPos, nLen);
- const rtl::OUString aStyleContent(aTokenValue.makeStringAndClear().trim());
+ const OUString aStyleContent(aTokenValue.makeStringAndClear().trim());
if(!aStyleContent.isEmpty())
{
@@ -139,7 +139,7 @@ namespace svgio
pNewStyle->readStyle(aStyleContent);
// concatenate combined style name
- rtl::OUString aConcatenatedStyleName;
+ OUString aConcatenatedStyleName;
for(sal_uInt32 a(0); a < aStyleNames.size(); a++)
{
commit 0347e5c77d281e4a25f79660aafb625691c4f883
Author: Armin Le Grand <alg at apache.org>
Date: Fri Jul 25 15:38:47 2014 +0000
Related: #i125293# Further corrections for CssStyle handling in SVG importer
(cherry picked from commit f00d6d2ea3e73e687edb1da4c32c0960eaf5010b)
Conflicts:
svgio/source/svgreader/svgnode.cxx
svgio/source/svgreader/svgstyleattributes.cxx
svgio/source/svgreader/svgstylenode.cxx
svgio/source/svgreader/svgsvgnode.cxx
Change-Id: I335b292fcdf1ebac925c9fd76ad624efb923447d
diff --git a/svgio/inc/svgio/svgreader/svgnode.hxx b/svgio/inc/svgio/svgreader/svgnode.hxx
index cc88b26..6a5217c 100644
--- a/svgio/inc/svgio/svgreader/svgnode.hxx
+++ b/svgio/inc/svgio/svgreader/svgnode.hxx
@@ -108,13 +108,25 @@ namespace svgio
/// Display value #i121656#
Display maDisplay;
- /// CSS styles
+ // CSS style vector chain, used in decompose phase and built up once per node.
+ // It contains the StyleHierarchy for the local node. INdependent from the
+ // node hierarchy itself which also needs to be used in style entry solving
SvgStyleAttributeVector maCssStyleVector;
+ /// possibbe local CssStyle, e.g. style="fill:red; stroke:red;"
+ SvgStyleAttributes* mpLocalCssStyle;
+
+ /// bitfield
+ // flag if maCssStyleVector is already computed (done only once)
+ bool mbCssStyleVectorBuilt : 1;
+
protected:
/// helper to evtl. link to css style
const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
+ /// helper for filling the CssStyle vector once dependent on mbCssStyleVectorBuilt
+ void fillCssStyleVector(const rtl::OUString& rClassStr);
+
public:
SvgNode(
SVGToken aType,
@@ -122,6 +134,10 @@ namespace svgio
SvgNode* pParent);
virtual ~SvgNode();
+ /// scan helper to read and interpret a local CssStyle to mpLocalCssStyle
+ void readLocalCssStyle(const rtl::OUString& aContent);
+
+ /// style helpers
void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent);
diff --git a/svgio/source/svgreader/svgcirclenode.cxx b/svgio/source/svgreader/svgcirclenode.cxx
index 38daca1..db75fde 100644
--- a/svgio/source/svgreader/svgcirclenode.cxx
+++ b/svgio/source/svgreader/svgcirclenode.cxx
@@ -60,7 +60,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenCx:
diff --git a/svgio/source/svgreader/svgclippathnode.cxx b/svgio/source/svgreader/svgclippathnode.cxx
index 0a7f0f4..7b65f94 100644
--- a/svgio/source/svgreader/svgclippathnode.cxx
+++ b/svgio/source/svgreader/svgclippathnode.cxx
@@ -63,7 +63,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
diff --git a/svgio/source/svgreader/svgellipsenode.cxx b/svgio/source/svgreader/svgellipsenode.cxx
index 5818a1c..03a5f6f 100644
--- a/svgio/source/svgreader/svgellipsenode.cxx
+++ b/svgio/source/svgreader/svgellipsenode.cxx
@@ -61,7 +61,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenCx:
diff --git a/svgio/source/svgreader/svggnode.cxx b/svgio/source/svgreader/svggnode.cxx
index c3957c7..85a97bd 100644
--- a/svgio/source/svgreader/svggnode.cxx
+++ b/svgio/source/svgreader/svggnode.cxx
@@ -68,7 +68,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenTransform:
diff --git a/svgio/source/svgreader/svggradientnode.cxx b/svgio/source/svgreader/svggradientnode.cxx
index 893ff96..92ea5b5 100644
--- a/svgio/source/svgreader/svggradientnode.cxx
+++ b/svgio/source/svgreader/svggradientnode.cxx
@@ -65,7 +65,12 @@ namespace svgio
const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
{
- return &maSvgStyleAttributes;
+ static rtl::OUString aClassStrA(rtl::OUString::createFromAscii("linearGradient"));
+ static rtl::OUString aClassStrB(rtl::OUString::createFromAscii("radialGradient"));
+
+ return checkForCssStyle(
+ SVGTokenLinearGradient == getType() ? aClassStrA : aClassStrB,
+ maSvgStyleAttributes);
}
void SvgGradientNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
@@ -81,7 +86,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX1:
diff --git a/svgio/source/svgreader/svggradientstopnode.cxx b/svgio/source/svgreader/svggradientstopnode.cxx
index 55a46cf..6c6d758 100644
--- a/svgio/source/svgreader/svggradientstopnode.cxx
+++ b/svgio/source/svgreader/svggradientstopnode.cxx
@@ -38,7 +38,9 @@ namespace svgio
const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
{
- return &maSvgStyleAttributes;
+ static rtl::OUString aClassStr(rtl::OUString::createFromAscii("stop"));
+
+ return checkForCssStyle(aClassStr, maSvgStyleAttributes);
}
void SvgGradientStopNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
@@ -54,7 +56,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenOffset:
diff --git a/svgio/source/svgreader/svgimagenode.cxx b/svgio/source/svgreader/svgimagenode.cxx
index 951d72b..cebd613 100644
--- a/svgio/source/svgreader/svgimagenode.cxx
+++ b/svgio/source/svgreader/svgimagenode.cxx
@@ -78,7 +78,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenPreserveAspectRatio:
diff --git a/svgio/source/svgreader/svglinenode.cxx b/svgio/source/svgreader/svglinenode.cxx
index f4b5035..5bba7d5 100644
--- a/svgio/source/svgreader/svglinenode.cxx
+++ b/svgio/source/svgreader/svglinenode.cxx
@@ -61,7 +61,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX1:
diff --git a/svgio/source/svgreader/svgmarkernode.cxx b/svgio/source/svgreader/svgmarkernode.cxx
index 7366143..5bad024 100644
--- a/svgio/source/svgreader/svgmarkernode.cxx
+++ b/svgio/source/svgreader/svgmarkernode.cxx
@@ -64,7 +64,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenViewBox:
diff --git a/svgio/source/svgreader/svgmasknode.cxx b/svgio/source/svgreader/svgmasknode.cxx
index e80f2e8..736ce14 100644
--- a/svgio/source/svgreader/svgmasknode.cxx
+++ b/svgio/source/svgreader/svgmasknode.cxx
@@ -69,7 +69,7 @@ namespace svgio
{
case SVGTokenStyle:
{
- maSvgStyleAttributes.readStyle(aContent);
+ readLocalCssStyle(aContent);
break;
}
case SVGTokenX:
diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx
index 431ba0c..24decd3 100644
--- a/svgio/source/svgreader/svgnode.cxx
+++ b/svgio/source/svgreader/svgnode.cxx
@@ -40,96 +40,131 @@ namespace svgio
return 0;
}
- const SvgStyleAttributes* SvgNode::checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const
+ void SvgNode::fillCssStyleVector(const rtl::OUString& rClassStr)
{
- if(maCssStyleVector.empty()) // #120435# Evaluate for CSS styles only once, this cannot change
+ OSL_ENSURE(!mbCssStyleVectorBuilt, "OOps, fillCssStyleVector called double ?!?");
+ mbCssStyleVectorBuilt = true;
+
+ // #125293# If we have CssStyles we need to buuild a linked list of SvgStyleAttributes
+ // which represent this for the current object. There are various methods to
+ // specify CssStyles which need to be taken into account in a given order:
+ // - local CssStyle (independent from global CssStyles at SvgDocument)
+ // - 'id' CssStyle
+ // - 'class' CssStyle(s)
+ // - type-dependent elements (e..g. 'rect' for all rect elements)
+ // - local attributes (rOriginal)
+ // - inherited attributes (up the hierarchy)
+ // The first four will be collected in maCssStyleVector for the current element
+ // (once, this will not change) and be linked in the needed order using the
+ // get/setCssStyleParent at the SvgStyleAttributes which will be used preferred in
+ // member evaluation over the existing parent hierarchy
+
+ // check for local CssStyle with highest priority
+ if(mpLocalCssStyle)
{
- const SvgDocument& rDocument = getDocument();
+ // if we have one, use as first entry
+ maCssStyleVector.push_back(mpLocalCssStyle);
+ }
+
+ const SvgDocument& rDocument = getDocument();
- if(rDocument.hasSvgStyleAttributesById())
+ if(rDocument.hasSvgStyleAttributesById())
+ {
+ // check for 'id' references
+ if(getId())
{
- // #i125293# If we have CssStyles we need to buuild a linked list of SvgStyleAttributes
- // which represent this for the current object. There are various methods to
- // specify CssStyles which need to be taken into account in a given order:
- // - 'id' element
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list