summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2023-09-05 16:58:22 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2023-09-07 12:41:50 +0200
commit2c3b690a900082a242e1a6494ac35338f5e8aad4 (patch)
tree2849b33d038854b0f3fd0f87d8088ea7ebebf61c
parent2b807baa2fd596ce4728cbc5ffbf8f8a50a60a54 (diff)
lok: save to xlsx changes column size
When xlsx spreadsheet was opened in LOK on every save default column width was decreased. This doesn't happen in non-LOK case. Column width in Excel are defined by double value which specifies number of '0' characters which fit into the column. On export we use mnCharWidth from XclRootData to convert Calc twips size to number of characters. In LOK case it was 102 while in non-lok case 101. It was caused by different Reference Device used in ScDocument::GetRefDevice() because in LOK case we are in WYSWIG mode as introduced in ScModelObj::initializeForTiledRendering in commit c25062f: sc tiled rendering: Don't adjust the text width according to printer. Let's use for export purpose the GetVirtualDevice_100th_mm() Change-Id: I6709194d7924e8c7e0aaa75ff3901afbcc1f8c11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156576 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com> (cherry picked from commit 29f72210e92e0152d52b3a1d0253fbb5d8e2dead) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156604 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/source/core/data/documen8.cxx4
-rw-r--r--sc/source/filter/excel/xlroot.cxx9
-rw-r--r--sc/source/filter/inc/xlroot.hxx2
4 files changed, 10 insertions, 7 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 5e9163b28fd4..94ff88b23d17 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2186,7 +2186,7 @@ public:
SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
void SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter );
VirtualDevice* GetVirtualDevice_100th_mm();
- SC_DLLPUBLIC OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
+ SC_DLLPUBLIC OutputDevice* GetRefDevice(bool bForceVirtDev = false); // WYSIWYG: Printer, otherwise VirtualDevice...
bool GetNextSpellingCell( SCCOL& nCol, SCROW& nRow, SCTAB nTab,
bool bInSel, const ScMarkData& rMark) const;
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 3d4d2ecc4b47..d77cb2204b60 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -196,11 +196,11 @@ VirtualDevice* ScDocument::GetVirtualDevice_100th_mm()
return mpVirtualDevice_100th_mm;
}
-OutputDevice* ScDocument::GetRefDevice()
+OutputDevice* ScDocument::GetRefDevice(bool bForceVirtDev)
{
// Create printer like ref device, see Writer...
OutputDevice* pRefDevice = nullptr;
- if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
+ if ( !bForceVirtDev && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
pRefDevice = GetPrinter();
else
pRefDevice = GetVirtualDevice_100th_mm();
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 587b7cff6612..0b61f9e17e7d 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/servicehelper.hxx>
#include <sot/storage.hxx>
@@ -37,6 +38,7 @@
#include <sfx2/sfxsids.hrc>
#include <vcl/font.hxx>
#include <vcl/settings.hxx>
+#include <vcl/virdev.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <editeng/editstat.hxx>
@@ -207,7 +209,8 @@ void XclRoot::SetTextEncoding( rtl_TextEncoding eTextEnc )
void XclRoot::SetCharWidth( const XclFontData& rFontData )
{
mrData.mnCharWidth = 0;
- if( OutputDevice* pPrinter = GetPrinter() )
+ bool bIsLOK = comphelper::LibreOfficeKit::isActive();
+ if( OutputDevice* pPrinter = GetPrinter( bIsLOK ) )
{
vcl::Font aFont( rFontData.maName, Size( 0, rFontData.mnHeight ) );
aFont.SetFamily( rFontData.GetScFamily( GetTextEncoding() ) );
@@ -298,9 +301,9 @@ ScModelObj* XclRoot::GetDocModelObj() const
return pDocShell ? comphelper::getFromUnoTunnel<ScModelObj>( pDocShell->GetModel() ) : nullptr;
}
-OutputDevice* XclRoot::GetPrinter() const
+OutputDevice* XclRoot::GetPrinter(bool bForceVirtDev) const
{
- return GetDoc().GetRefDevice();
+ return GetDoc().GetRefDevice(bForceVirtDev);
}
ScStyleSheetPool& XclRoot::GetStyleSheetPool() const
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 10b4554e155f..3085ee8c8516 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -204,7 +204,7 @@ public:
/** Returns the object model of the Calc document. */
ScModelObj* GetDocModelObj() const;
/** Returns pointer to the printer of the Calc document. */
- OutputDevice* GetPrinter() const;
+ OutputDevice* GetPrinter(bool bForceVirtDev = false) const;
/** Returns the style sheet pool of the Calc document. */
ScStyleSheetPool& GetStyleSheetPool() const;
/** Returns the defined names container of the Calc document. */