diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-07-25 21:17:24 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-11 09:18:11 +0200 |
commit | 0d356f93e4d5ca073a6e866168f76103c60c6a45 (patch) | |
tree | 4f60fc0cceb5154da08a15b826d9db9571e2f3d0 | |
parent | 5433564debb280949afcaa92dc3f9faf59765e65 (diff) |
sw: preserve the value in original units to minimize conv. error
Not really an big issue but let's preserve the values in original
units as long as we can without conversion so that the error is
minimal.
Change-Id: I96981eaecac74b591803dbc93e487c1d106ab23c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119490
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sw/inc/swtypes.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 21 |
2 files changed, 14 insertions, 10 deletions
diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index a091a538d9a9..64ac704d6ff6 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -71,7 +71,8 @@ constexpr SwTwips DEF_GUTTER_WIDTH = o3tl::toTwips(3, o3tl::Length::mm); constexpr SwTwips MIN_BORDER_DIST = 28; // ~0.5mm // Minimal document border: 20mm. -constexpr SwTwips lMinBorder = o3tl::toTwips(20, o3tl::Length::mm); // ~20mm +constexpr tools::Long lMinBorderInMm(20); +constexpr SwTwips lMinBorder = o3tl::toTwips(lMinBorderInMm, o3tl::Length::mm); // Margin left and above document. // Half of it is gap between the pages. diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 338a11b24b84..b66f251e55c7 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -134,10 +134,15 @@ #include <memory> -constexpr tools::Long constOleWidth = 11905 - 2 * lMinBorder; -constexpr tools::Long constOleHeight = o3tl::toTwips(3, o3tl::Length::cm); +/* default (A4 format) width of 210mm - 2 * border size (border on both sides) */ +constexpr tools::Long constOleWidthInMm = 210 - 2 * lMinBorderInMm; -#define OLESIZE constOleWidth, constOleHeight +constexpr Size constOleSize100mm( + constOleWidthInMm * 100, // convert from mm to 100mm + 30 // 3 cm +); + +constexpr Size constOleSizeTwip = o3tl::convert(constOleSize100mm, o3tl::Length::mm100, o3tl::Length::twip); constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_DRAWMODEL = 0x00000001; constexpr sal_uInt32 SWTRANSFER_OBJECTTYPE_HTML = 0x00000002; @@ -343,7 +348,7 @@ void SwTransferable::InitOle( SfxObjectShell* pDoc ) { //set OleVisArea. Upper left corner of the page and size of //RealSize in Twips. - const Size aSz( OLESIZE ); + const Size aSz(constOleSizeTwip); SwRect aVis( Point( DOCUMENTBORDER, DOCUMENTBORDER ), aSz ); pDoc->SetVisArea( aVis.SVRect() ); } @@ -1158,8 +1163,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut ) //ObjectDescriptor was already filly from the old DocShell. //Now adjust it. Thus in GetData the first query can still //be answered with delayed rendering. - Size aSz( OLESIZE ); - m_aObjDesc.maSize = o3tl::convert(aSz, o3tl::Length::twip, o3tl::Length::mm100); + m_aObjDesc.maSize = constOleSize100mm; PrepareOLE( m_aObjDesc ); #if HAVE_FEATURE_DESKTOP @@ -1261,8 +1265,7 @@ bool SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr //ObjectDescriptor was already filled from the old DocShell. //Now adjust it. Thus in GetData the first query can still //be answered with delayed rendering. - Size aSz( OLESIZE ); - m_aObjDesc.maSize = o3tl::convert(aSz, o3tl::Length::twip, o3tl::Length::mm100); + m_aObjDesc.maSize = constOleSize100mm; PrepareOLE( m_aObjDesc ); AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ); @@ -3624,7 +3627,7 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos ) //Now adjust it. Thus in GetData the first query can still //be answered with delayed rendering. m_aObjDesc.maDragStartPos = rSttPos; - m_aObjDesc.maSize = o3tl::convert(Size( OLESIZE ), o3tl::Length::twip, o3tl::Length::mm100); + m_aObjDesc.maSize = constOleSize100mm; PrepareOLE( m_aObjDesc ); AddFormat( SotClipboardFormatId::OBJECTDESCRIPTOR ); |