Bug 153251 - remove s_nPixelTwips
Summary: remove s_nPixelTwips
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:25.8.0
Keywords: difficultyBeginner, easyHack, skillCpp, topicCleanup
Depends on:
Blocks: Dev-related
  Show dependency treegraph
 
Reported: 2023-01-27 19:47 UTC by Michael Meeks
Modified: 2025-02-03 13:45 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meeks 2023-01-27 19:47:08 UTC
SwViewOptions has a rather grim and unhelpful global variable:

sw/inc/viewopt.hxx:    static sal_uInt16   s_nPixelTwips;// 1 Pixel == ? Twips

Which is only used in one place:

sw/source/uibase/config/viewopt.cxx-void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript )

Where (it seems to me) - we could more profitably work out how many twips to the pixel there are for the screen the view is rendered to there with:

sw/source/uibase/config/viewopt.cxx:        s_nPixelTwips = o3tl::narrowing<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height());

And also kill the SwViewOption::Init at the same time.

This global static seems to have come from the initial checkin:

commit 7b0b5cdfeed656b279bc32cd929630d5fc25878b
Author: Jens-Heiner Rechtien <hr@openoffice.org>
Date:   Mon Sep 18 16:15:01 2000 +0000

+USHORT SwViewOption::nPixelTwips = 0;   //ein Pixel auf dem Bildschirm

Thanks !
Comment 1 Michael Meeks 2023-01-27 19:48:03 UTC
Any thoughts Miklos =) looked weird to me.
Comment 2 Miklos Vajna 2023-01-30 09:55:31 UTC
Yes, sounds like a good idea to eliminate that static. It's broken if different views have different DPI / zoom level, I guess.
Comment 3 Ujjawal Kumar 2025-01-16 15:38:41 UTC
Hey I've released a patch here: https://gerrit.libreoffice.org/c/core/+/180360

Can you please let me know if I am headed in the right direction. Thanks!
Comment 4 Commit Notification 2025-01-17 08:06:20 UTC
bruh committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/589cd1b840ccdfb00c74d8ae776d853832bcdf4e

tdf#153251 remove s_nPixelTwips

It will be available in 25.8.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.