The previous variable names (n1, n2, n3, a4) provided no context about
the mathematical operations being performed during unit conversion.
This commit replaces them with descriptive names (nSourceValue,
nMultiplier, nDivisor, aBigValue) to clearly reflect their roles.
Additionally, inline comments were added to explain the BigInt fallback
path and the manual round-to-nearest integer division logic, making
the function significantly easier to read and maintain.
Change-Id: I7f83842a486861fc53173b41febfad6f766efbbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203682
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
if (bOverflow)
{
const auto [n2, n3] = o3tl::getConversionMulDiv(eFrom, eTo);
BigInt a4 = n1;
a4 *= n2;
}
this does... nothing at all.
Change-Id: Ia47a8f80d6de8a981d71301454f1ffe4feb587f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203681
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit finalizes the refactoring of the LogicToLogic() coordinate
mapping pipeline by completely encapsulating both scaling and origin
translation within the ImplMapRes struct.
By recognizing the mathematical symmetry of the affine transformation,
origin shifts are now explicitly decoupled from the scaling logic. This
allows the complete transformation pipeline to be handled internally,
making the call sites in map.cxx significantly cleaner and less prone
to offset-related bugs.
Key changes:
- Removed the intermediate ScaleLogicX() and ScaleLogicY() methods.
- Introduced explicit LocalToAbsolute() and AbsoluteToLocal() helper
methods to handle origin offset addition and subtraction.
- Added TransformPointX() and TransformPointY(), which cleanly implement
the full pipeline: LocalToAbsolute() -> ScaleDistance() -> AbsoluteToLocal().
- Updated OutputDevice::LogicToLogic() overloads for Point and Rectangle
to use the new TransformPoint methods, successfully removing all
manual destination offset subtractions from map.cxx.
Change-Id: Ibb42f62d6904ae282dabf697b35455aec7c17677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203680
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit refactors the procedural scaling logic in map.cxx into
clean, object-oriented methods on the ImplMapRes struct. This greatly
improves readability and structurally prevents mathematical bugs by
separating the concepts of coordinate scaling and distance scaling.
Previously, map.cxx relied heavily on the standalone static function
lcl_scaleLogicValue(), requiring manual extraction and passing of
internal scales and offsets at every call site.
Key changes:
- Moved lcl_scaleLogicValue() into ImplMapRes.cxx as an internal helper.
- Added ScaleLogicX() and ScaleLogicY() to ImplMapRes to handle absolute
coordinates (Points and Rectangles), which safely apply the local
origin offset before scaling.
- Added ScaleDistanceX() and ScaleDistanceY() to ImplMapRes to handle
pure vectors (Sizes), ensuring origin offsets are bypassed.
- Refactored OutputDevice::LogicToLogic() overloads to utilize these
new encapsulated methods.
Change-Id: Ib46f6f2bac09b23baa37f29b8a71fdf6a0ffe164
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203679
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit updates the parameter names in lcl_scaleLogicValue() to
better reflect their mathematical roles and strictly adhere to
VCL's Hungarian notation conventions.
Key changes:
- Renamed 'n1' (tools::Long) to 'nSourceValue' for semantic clarity.
- Renamed 'n2' (double) to 'fSourceScale', correcting the prefix
from integer ('n') to float/double ('f').
- Renamed 'n3' (double) to 'fDestScale', correcting the prefix and
making the divide-by-zero safety check instantly understandable.
Change-Id: Id50ca85ae334b6ec40cdd1a8e533f9a5d902ab8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203678
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit introduces a parameterized constructor for ImplMapRes to
streamline map resolution initialization across VCL mapping functions.
Previously, instantiating a local ImplMapRes required an error-prone,
two-step process: default construction followed by a call to the
CalcMapResolution mutator.
The new constructor elegantly bridges this by delegating the complex
scaling math to CalcMapResolution() while explicitly handling the absolute
origin offsets (mnMapOfs) required for a fresh resolution state.
Key changes:
- Added ImplMapRes(MapMode, nDPIX, nDPIY) constructor.
- Refactored CoordinateMapper and OutputDevice mapping functions
(LogicToPixel, PixelToLogic) to use the new single-line RAII-style
initialization, eliminating repetitive two-step setup code.
Change-Id: I68072cd66d01fd1663b58330890fe90a7bb8f94c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203677
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit refactors OutputDevice::PixelToLogic(Polygon, MapMode)
to use the ViewSubPixelToLogicIntX/Y() overloads that accept custom
mapping resolutions (ImplMapRes).
Key changes:
- Replaced manual coordinate scaling and sequential subtraction of
mapping and logical offsets with encapsulated master wrappers.
- Preserved the "Round-then-Shift" order of operations to ensure
polygon vertices maintain legacy rounding symmetry and pass unit
tests.
- Modernized the loop by removing legacy pointer-based array access
in favor of direct index assignment and Point construction.
- Further reduced the footprint of coordinate mathematics within
map.cxx.
Change-Id: Ided023472c28d9bdd2e0c35c5f00705b58435bff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203676
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit refactors OutputDevice::PixelToLogic(Rectangle, MapMode)
to utilize the custom ImplMapRes overloads of the
ViewSubPixelToLogicIntX/Y master wrappers.
Key changes:
- Eliminated redundant inline arithmetic involving manual scaling,
mapping offsets, and internal logical offsets.
- Maintained the "Round-then-Shift" operation order, ensuring that
rectangle edges are rounded to integer space immediately after
scaling to preserve unit test parity.
- Centralized the inverse coordinate transformation logic within
CoordinateMapper, continuing the effort to remove coordinate math
leaks from map.cxx.
Change-Id: I36151fdf72721979aa8cf2a306bde65e845b186c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203675
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit refactors OutputDevice::PixelToLogic(Polygon) to utilize
the ViewSubPixelToLogicIntX/Y() master wrappers, ensuring consistent
coordinate transformations across all geometric types.
Key changes:
- Replaced manual scaling and double-offset subtraction arithmetic
with encapsulated CoordinateMapper calls.
- Maintained the "Round-then-Shift" sequence required for unit test
parity, ensuring polygon vertices are rounded before offsets are
applied.
- Simplified the loop logic by removing legacy pointer-to-array
access (GetConstPointAry) in favor of standard indexing and
direct Point construction.
Change-Id: I7b0900a369e91080c758a6a947d8fca386c1708e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203673
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit refactors OutputDevice::PixelToLogic(Point, MapMode) to use
new CoordinateMapper wrappers that accept custom mapping resolutions.
Key changes:
- Added ViewSubPixelToLogicIntX/Y() overloads to CoordinateMapper that
accept an explicit ImplMapRes.
- These wrappers maintain the "Round-then-Shift" logic required for
test parity: rounding the scaled distance first, then stripping
the custom mapping offset, and finally stripping the internal
logical offset (mnOutOffLogic).
- Simplified map.cxx by removing manual scaling and multi-offset
subtraction logic, further centralizing coordinate math within the
mapper.
Change-Id: I9615b234766d8b6ac9d0afb1a0d892762c738252
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203674
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit refactors OutputDevice::PixelToLogic(Rectangle) to utilize
the ViewSubPixelToLogicIntX/Y master wrappers, continuing the
elimination of manual coordinate arithmetic in map.cxx.
Even though the input is an integer Rectangle, using these sub-pixel
wrappers ensures that the edge transformations follow the identical
"Round-then-Shift" sequence used for Points. This maintains mathematical
consistency across all geometric primitives and preserves unit test
parity by ensuring the rounding boundary remains stable during the
inverse transformation.
Key changes:
- Replaced redundant inline subtractions of mnMapOfs and mnOutOffLogic
with encapsulated CoordinateMapper calls.
- Cleaned up whitespace and formatting in the Rectangle constructor
and empty-check conditionals.
- Isolated the internal state of CoordinateMapper by removing four
additional direct offset access calls from OutputDevice.
Change-Id: I71af69f2651638f7e57e1ce94ca850ae36fe36c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203672
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit completes the inverse sub-pixel pipeline by adding the
ViewSubPixelToLogicIntX/Y() master wrappers and their corresponding
LogicUnits pipeline stages.
Unit testing revealed that the order of operations in SubPixelToLogic
is mathematically sensitive: the floating-point View distance must
be rounded to an integer (llround) BEFORE any integer offsets
(mnMapOfs or mnOutOffLogic) are subtracted. Shifting the rounding
boundary by applying offsets in floating-point space leads to
off-by-one errors for fractional coordinates near zero-crossing points.
Key changes:
- Added ViewSubPixelToLogicUnitsIntX/Y(): Pipeline stages that round
scaled distances to tools::Long before stripping the mapping offset.
- Added ViewSubPixelToLogicIntX/Y(): Master wrappers that provide the
full "Round-then-Shift" journey from View sub-pixels to Absolute
Logic integers.
- Refactored OutputDevice::SubPixelToLogic() in map.cxx to use these
new wrappers, successfully encapsulating the manual offset
arithmetic while maintaining exact legacy rounding behavior.
Change-Id: Icecd9a2f5f75cb5353e6c7d9431be22c0889e968
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203671
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit refactors OutputDevice::PixelToLogic() to utilize the
new ViewToLogicX/Y wrappers from CoordinateMapper.
While theoretically PixelToLogic() should be the exact inverse of
LogicToPixel() (which traverses all the way to Window Space), we
intentionally preserve the historical behavior here. The legacy
code specifically calculated the transition from View Space back
to Absolute Logic Space, skipping the internal window offsets
(mnOutOffOrig).
Key changes:
- Replaced the manual ViewToLogicUnits() scaling and subsequent
subtraction of the logical offset (GetLogicalXOffset) with the
encapsulated ViewToLogicX/Y() wrappers.
- Retained the explicit IsMapModeEnabled() early exit to maintain
exact bug-for-bug compatibility with existing legacy callers
that may expect this specific coordinate space behavior.
Change-Id: If16d2d764030810037d52304823517f946551507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203670
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This commit continues the cleanup of map.cxx by refactoring the
Polygon overload of OutputDevice::LogicToPixel to use the new
explicit ImplMapRes wrappers.
Key changes:
- Replaced the nested ViewToWindowUnits(LogicUnitsToViewUnits(...))
calls with the much cleaner LogicToWindowUnitsX/Y(..., aMapRes)
master wrappers.
- Removed legacy C-style pointer arithmetic (GetConstPointAry) in
favor of directly accessing and assigning to the polygon via the
overloaded operator[].
- Eliminated the temporary Point allocation and sequential setX/setY
calls, replacing them with a direct inline Point constructor.
- This dramatically improves the readability of the loop while
maintaining identical coordinate transformation behavior.
Change-Id: I25252b99f5fc8e1b7097d766cd74ac6e7e8f3e80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203669
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit improves the encapsulation of custom MapMode conversions
by adding ImplMapRes overloads to the LogicToWindowUnits master
wrappers in CoordinateMapper.
Previously, when OutputDevice::LogicToPixel was called with an
explicit custom MapMode, it had to bypass the standard wrappers and
manually chain the LogicUnitsToViewUnits and ViewToWindowUnits
pipeline stages inline. This resulted in highly verbose and difficult-
to-read rectangle initialization.
Key changes:
- Added LogicToWindowUnitsX(nX, rRes) and LogicToWindowUnitsY to
CoordinateMapper to safely encapsulate custom resolution scaling
while still applying the correct internal window offsets.
- Refactored OutputDevice::LogicToPixel(Rectangle, MapMode) in
map.cxx to use these new wrappers, drastically improving the
readability of the coordinate mapping logic.
Change-Id: Ib3af5314ad11653395b08c2ca722d66360baeb99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203668
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit replaces manual coordinate arithmetic in map.cxx with the
newly introduced CoordinateMapper pipeline stages and master wrappers,
improving encapsulation and fixing a subtle offset bug.
Key changes:
- OutputDevice::LogicToDeviceSubPixel: Replaced nested pipeline calls
and manual device origin additions with the LogicToDeviceSubPixel
master wrapper. This completely hides the math from map.cxx and
ensures the absolute logical offset (mnOutOffLogic) is correctly
applied before any DPI/MapMode scaling occurs.
- OutputDevice::ImplPixelToDevicePixel: Fixed an early-exit bug. The
legacy code only checked if the screen origin (mnOutOff) was zero
before returning early, completely ignoring whether the window had an
internal VCL pixel offset (mnOutOffOrig). By piping `0` through
ViewToWindowUnits and WindowToDeviceUnits, we now calculate the
exact combined spatial delta to check for the early exit and move
the region safely.
Change-Id: I697a0a7aa2bc4c03e55654305432b0805cee9c66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203667
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Updates the OutputDevice::LogicToPixel variant that accepts an
explicit MapMode to utilize CoordinateMapper pipeline stages.
Previously, this method manually composed the transformation by
adding ImplMapRes offsets, calling LogicToViewDistance, and then
adding the internal VCL pixel offset (mnOutOffOrigX/Y).
By refactoring this to use LogicUnitsToViewUnitsX/Y(nX, aMapRes)
nested within ViewToWindowUnitsX/Y, we maintain architectural
consistency with the rest of the mapper refactor. This ensures
that even when using a temporary resolution context, the coordinate
journey follows the standardized Logic -> View -> Window path
without exposing raw arithmetic in OutputDevice.
Change-Id: Ie39cf7d67d6461f418c942528abbbffbf7f9a7bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203663
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Introduces LogicToWindowUnitsX and LogicToWindowUnitsY to the
CoordinateMapper API. These master wrappers chain the first two
stages of the forward transformation pipeline (LogicUnits -> View
-> Window), cleanly stopping before the final physical screen
offset is applied.
This addition is immediately put to use in map.cxx to refactor
OutputDevice::LogicToPixel for both Rectangles and Polygons.
It successfully collapses complex, nested inline arithmetic—such
as the manual scaling of logical offsets and the explicit addition
of internal VCL pixel offsets (mnOutOffOrigX/Y)—into single,
highly semantic API calls.
OutputDevice is now further isolated from the underlying mechanics
of the coordinate mapping math, continuing the encapsulation
goals of the mapper refactor.
Change-Id: Ifbc49b3c8ba5a84d864fe9a6626dcf587039241d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203662
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
When LibreOffice is built with --without-java, the Java-based
JavaScript provider (ScriptProviderForJavaScript_2) is omitted from
the build and not registered in the service manager. Attempting to
remove it throws a com.sun.star.container.NoSuchElementException.
Additionally, in builds without any active JavaScript provider,
ScriptURIHelper or the master script provider cannot resolve .js files,
causing the test to fail its assertion.
Key changes:
- Catch NoSuchElementException when removing the Java-based JavaScript
provider.
- Safely check if JavaScript script user directories can be retrieved
via ScriptURIHelper.
- Use self.skipTest() if no active JavaScript provider is available to
process script files so the unit test passes cleanly in
--without-java environments.
Change-Id: I69abb006ececb2ca9c285f1de37057a8180d5b8f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208924
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Jenkins buildbots occasionally fail with a SIGSEGV during UITest
teardown in test_tdf117039_preview_signed_document. The crash is
triggered by a race condition between an asynchronous Print Preview
view-shell closure on the main thread and xDesktop.terminate()
invoked by the Python test harness.
When XFrameImpl::implts_checkSuicide() has its initial frame close
vetoed (e.g., frame is mid-load), it auto-retries once the lock count
drops. This can cause the framework to invoke SfxBaseController::dispose()
a second time on the same controller.
Because SfxBaseController::dispose() lacked a strict idempotency guard,
it would unconditionally re-run disposeAndClear() on its listener
container. Walking already-freed listeners results in a use-after-free
crash inside BaseReference::iquery.
This patch adds an early return if m_pData->m_bDisposing is already
true. This safely intercepts the double-dispose and adds a SAL_WARN
to track when this teardown race is caught.
Change-Id: Ifa68e2f113cad24a05f8b64c19eabec60cdbd0b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208046
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Updates OutputDevice::LogicToPixel(const Point&) to utilize the
newly established CoordinateMapper forward pipeline.
This replaces the manual inline composition of logical offsets,
distance scaling, and pixel offsets with a clean, chained
pipeline sequence: LogicUnitsToViewUnits -> ViewToWindowUnits.
By adopting this structure, we completely encapsulate the internal
VCL pixel offset (mnOutOffOrigX/Y) within the mapper, eliminating
the need for OutputDevice to manually fetch and add GetPixelXOffset().
This abstracts the coordinate math out of OutputDevice and enforces
the strict stage-by-stage geometric transition.
Change-Id: I4c29403e3c0f8afcde24927f3bc687b02c6e1479
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203661
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Introduces DevicePixelToLogicX and DevicePixelToLogicY to the
CoordinateMapper API, completing the "un-projection" side of the
transformation pipeline.
These master wrappers correctly chain the inverse pipeline stages
(Device -> Window -> View -> LogicUnits) and seamlessly handle the
MapMode bypass logic internally.
This allows us to strip out the massive, complex inline arithmetic
found in OutputDevice::ImplDevicePixelToLogic (inside map.cxx)
and replace it with clean, semantic function calls.
OutputDevice is now completely abstracted away from the underlying
geometric offset and scaling math, achieving the core encapsulation
goal of the coordinate mapper refactor.
Change-Id: I9a15041abede8ffdb4b7f71478b5b992fe2d062d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203660
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Updates OutputDevice::ImplDevicePixelToLogic to use the newly
established CoordinateMapper transformation pipeline when MapMode
is disabled.
Previously, this block manually subtracted GetDeviceOriginX/Y
from the given rectangle to convert absolute device pixels into
window-relative coordinates. This replaces the raw arithmetic
with explicit DeviceToWindowUnitsX/Y calls.
This change encapsulates the offset logic entirely within
CoordinateMapper and ensures the coordinate space transition
is explicitly documented by the API nomenclature.
Change-Id: Ica26ebd9b3c04eba2816dac26e2e8bca2a403776
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203659
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit finalizes the CoordinateMapper refactor by resolving naming
collisions and establishing a strict semantic separation between
physical units and logical distances.
To avoid ambiguity with the word "Pixel" and to clearly distinguish
between pure mathematical scaling and coordinate space translations,
the API has been standardized:
1. Distance Scaling:
Renamed the pure multiplication methods from LogicToViewX/Y to
LogicToViewDistanceX/Y. This frees up the namespace and clarifies
that these methods handle scaling without applying mapping offsets.
2. Physical Pipeline Stages (*Units):
Implemented the definitive space-to-space transformation ladder using
the 'Units' suffix for physical stages and 'LogicUnits' for the
document stage:
- DeviceToWindowUnits / WindowToDeviceUnits
- WindowToViewUnits / ViewToWindowUnits
- ViewToLogicUnits / LogicUnitsToViewUnits
3. Legacy Cleanup:
Purged the orphaned LogicToViewPixelX/Y declarations and
implementations left over from earlier refactoring attempts. Updated
the legacy ImplCalcDevicePixelX/Y helpers to utilize the new
LogicUnitsToViewUnitsX/Y pipeline stage.
4. map.cxx Alignment:
Updated all OutputDevice translation sites in map.cxx that previously
relied on the overloaded LogicToViewX/Y to explicitly call the correct
LogicToViewDistanceX/Y variants, restoring a clean build.
Change-Id: I621ed8741055a29bf65963d75b763ca3e4a7bd0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203658
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
When detaching the main menu from NSApp via [NSApp setMainMenu:nil],
the NSMenu object can be deallocated immediately if it has no other
strong references, leading to a crash when the subsequent loop attempts
to iterate through its items.
This commit ensures the menu remains valid during the teardown process
by explicitly retaining the menu and scheduling an autorelease before
detaching it from the application.
Change-Id: I78420d42846f11732e23b0a4cf66b41bf6b73c98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208053
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Simplifies OutputDevice::ImplLogicToDevicePixel for B2DPolygons by
delegating coordinate transformation to the CoordinateMapper. By using
LogicToDevicePixelX and LogicToDevicePixelY, we eliminate redundant
if/else branching and ensure that window and pixel offsets are
consistently applied across both axes.
This refactoring also addresses systemic X/Y scaling mix-ups where the
horizontal scaler was being used for vertical coordinates, a bug
identified through failures in PDF export integration tests.
Changes:
* Simplified B2DPolygon transformation loop in map.cxx.
* Removed private visibility (SAL_DLLPRIVATE) from the B2DPolyPolygon
overload of LogicToPixel to allow for external unit testing.
* Added a new unit test fixture 'testB2DPolygonAsymmetricDPI' in
vclmaptest.cxx to verify scaling accuracy on asymmetric displays
(e.g., 100x200 DPI) and prevent future axis-specific regressions.
Change-Id: I718df9af8e5d8b2a446be74223047bdaa20ed148
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207555
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
The newly refactored CoordinateMapper::Logic[X|Y]ToDevicePixel()
methods act as the primary, state-aware public API for scalar
coordinate transformation.
Because these mapper methods already handle the IsMapModeEnabled()
state check internally, we can safely remove the manual branching
from the higher-level OutputDevice conversion methods. This
drastically simplifies the code, replacing massive blocks of inline
mathematical boilerplate with clean, 1-to-1 delegation calls.
- Simplified LogicToDevicePixel(const Point&) to delegate directly
to the mapper.
- Removed redundant MapMode branching that is now safely handled
by CoordinateMapper.
Change-Id: Ie7e3696f9cb2ec7098a3b8e6f5e500a366f8e72f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203653
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
During local LODE builds on macOS, the test framework sets UNO_PATH
to `instdir/program`. While this works for Linux and Windows, macOS
builds generate a native application bundle, placing the executable
at `instdir/LibreOfficeDev.app/Contents/MacOS/soffice`.
This caused `subprocess.Popen` to throw a `FileNotFoundError` during
execution of targets like `PythonTest_pyuno_pytests_testofficehelper`.
This patch intercepts the macOS path in `bootstrap()` and dynamically
routes it to the correct LibreOfficeDev App Bundle location if the
default Linux-style path does not exist.
Additionally, this adds a standard Python 3 shebang to the file and
fixes a missing newline at EOF.
Change-Id: Ie92415941c24e0777087d51a999dcbeae6c06223
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208052
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Replaces the manual addition of mapping offsets (GetMapping[X|Y]Offset)
with the encapsulated LogicToOffsetLogic[X|Y] helpers introduced
recently in CoordinateMapper.
This continues the ongoing architectural cleanup by standardizing how
absolute logical coordinates are transitioned into view-relative
logical space before being scaled to device pixels.
- Updated LogicToDevicePixel overloads (Point, Rectangle, Polygon,
B2DPolygon).
- Updated LogicToPixel overloads (Point, Rectangle, Polygon).
- Updated LogicToDeviceSubPixel.
Change-Id: Ie0a6fc40ada9127860a244f3f93e02d9cc658f72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203652
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Following the migration of the device origin state into
CoordinateMapper, this commit updates the complex coordinate
transformation methods in map.cxx to query the origin directly
from the mapper.
Bypassing the OutputDevice wrappers (GetDeviceOriginX/Y) makes it
explicitly clear that the mapper owns this physical window offset.
This reduces internal reliance on the OutputDevice god-class API
and sets the stage to potentially remove these wrappers entirely.
- Updated LogicToDevicePixel overloads (Point, Rectangle).
- Updated ImplLogicToDevicePixel overloads (Polygon, B2DPolygon,
PolyPolygon).
- Updated ImplDevicePixelToLogic (Rectangle) and
ImplPixelToDevicePixel (Region).
Change-Id: I1b5915f27bf6117a0fd303c7f30603a67ca181a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203651
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit finalizes the migration of the core scalar coordinate
transformations by moving the logic out of OutputDevice and entirely
into CoordinateMapper.
To clearly separate the public API (which handles MapMode state
branching) from the internal math engine (which unconditionally
applies offsets and scaling), the mapping operations have been
explicitly split.
- Removed ImplLogicXToDevicePixel() and ImplLogicYToDevicePixel()
from OutputDevice.
- Added LogicToDevicePixelX() and LogicToDevicePixelY() to
CoordinateMapper to act as the primary state-checking API.
- Added ImplCalcDevicePixelX() and ImplCalcDevicePixelY() to
CoordinateMapper to isolate the raw transformation math.
- Updated all scalar call sites across vcl (bitmap, map, mask,
outdev, pixel, rect) to route their math through the mpMapper
instance.
Change-Id: Ibb23aec54dd6eab6e3a753c2a61f8e023aa03883
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203650
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Completes the logical-to-device transformation pipeline by moving
the final physical offset calculations into CoordinateMapper.
OutputDevice no longer needs to manually assemble the view pixels,
device origins, and pixel offsets.
- Added LogicToDevicePixelX() and LogicToDevicePixelY() to
CoordinateMapper to handle the final transformation from view
space to physical device space.
- Simplified ImplLogicXToDevicePixel() and ImplLogicYToDevicePixel()
in map.cxx to directly delegate to these new mapper methods.
- Added comments in CoordinateMapper to clearly delineate the
Viewport (view space) and Physical window (device space) methods.
- Updated the unmapped branches in map.cxx to fetch the device
origin directly from mpMapper.
Change-Id: If7dbcf3fe9ed70fabc6c24d3b4a426cdde7d438c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203649
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
These functions are declared as file-local static helpers in map.cxx,
so they should follow the standard lcl_ naming convention rather
than the Impl prefix, which is generally reserved for private
class methods.
- Renamed ImplLogicToSubPixel() to lcl_logicToSubPixel().
- Renamed ImplSubPixelToLogic() to lcl_subPixelToLogic().
- Updated all call sites in SubPixelToLogic(), LogicWidthToDeviceSubPixel(),
LogicHeightToDeviceSubPixel(), and LogicToDeviceSubPixel().
Change-Id: I01e64f41b153526c13f15856e1182d3bea6802f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203648
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Continues the encapsulation of coordinate mapping logic by moving
the intermediate logical-to-pixel calculation into CoordinateMapper.
This removes the need for OutputDevice to query the mapper for
individual scaling and DPI components just to do the math itself.
- Added LogicToViewPixelX() and LogicToViewPixelY() to CoordinateMapper
to handle the multiplication of the offset logical coordinate, map
resolution scale, and DPI.
- Simplified OutputDevice::ImplLogic[X|Y]ToDevicePixel() to delegate
directly to these new helpers instead of relying on lcl_logicToPixel.
- Included minor formatting cleanup in LogicToLogic.
Change-Id: Iabf90dd129e3f51102c05e27fe11af1bb6d946a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203647
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Completes the deprecation of legacy coordinate subsystem naming by
renaming GetOutOffYPixel() and SetOutOffYPixel() to
GetDeviceOriginY() and SetDeviceOriginY() across OutputDevice,
Window, and CoordinateMapper.
This unifies axis naming conventions following previous X-axis
refactoring passes, clarifying that these fields represent the
physical origin offsets of the device rendering canvas.
This patch also moves view transformation logic inline from outdev/map
to CoordinateMapper, and wraps sprawling multi-line logic formulas
across mapping routines to clean up formatting boundaries.
Key changes:
* include/vcl/outdev.hxx / window.hxx: Updated public declarations
to replace GetOutOffYPixel with GetDeviceOriginY.
* vcl/inc/CoordinateMapper.hxx: Migrated view transformation cache State
members and mapping calculation methods into the mapper object.
* Global adjustments: Patched all related coordinate offset reads
and tracking writes throughout desktop, editeng, sc, svx, and vcl.
Change-Id: I28fec54a7f3312cc41ada2de38b26351c0a65527
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203646
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Rename GetOutOffXPixel() and SetOutOffXPixel() to GetDeviceOriginX()
and SetDeviceOriginX() across OutputDevice, Window, and CoordinateMapper.
The legacy "OutOff" naming convention obscured the difference between
system-level window positioning offsets and internal content scrolling
(SetPixelOffset). The new nomenclature explicitly communicates that
these metrics strictly govern the device coordinate space origin.
This patch focuses strictly on the X-axis coordinate reads and cleans
up duplicated formatting signatures inside the CoordinateMapper header.
Impacted modules:
* include/vcl: Update public declarations in outdev.hxx and window.hxx.
* vcl/inc: Clean up CoordinateMapper.hxx whitespace and scaling hooks.
* Global: Patch dependent pixel coordinate reads across desktop, editeng,
sc, sfx2, svx, and vcl.
Change-Id: I546e1d255887e3b280ff15caca2e27ef10de52d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206509
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Refactors the CoordinateMapper::SetLogicalOffset implementation to
match standard const reference placement style (Size const& rOffset)
and positions it lower in the source file to align with structural
member grouping conventions.
Additionally, this patch cleans up long line-wrapping indentation
artifacts inside the polygon processing block of
OutputDevice::PixelToLogic to maintain clean, standardized VCL
formatting guidelines.
Key changes:
* vcl/source/outdev/CoordinateMapper.cxx: Repositioned
SetLogicalOffset and adjusted the parameter signature to match
consistent layout declarations.
* vcl/source/outdev/map.cxx: Re-wrapped aPt calculation blocks in
PixelToLogic to improve localized readability.
Change-Id: I297bc4abc627c6b60b0015fd01fd8e72108ae44c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203644
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
Refactor OutputDevice by shifting tracking of coordinate mapping state,
including map mode status, map mode properties, map resolutions, and
pixel/logical offsets, entirely into the CoordinateMapper helper class.
This cleanup unloads redundant member variables from OutputDevice (such
as mbMap, mnOutOffOrigX/Y, mnOutOffLogicX/Y, and maMapRes) and replaces
direct flag manipulation with accessors through mpMapper.
Additionally, this change fixes a latent bug where toggling MapMode
visibility via EnableMapMode() failed to properly invalidate and restore
coordinate transformations. A unit test has been added to guard against
regressions for MapMode invalidation.
Change-Id: Iec61ceb5244d2086215e8a54aa1462eec05882c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196505
Tested-by: Dan Williams <dcbw@libreoffice.org>
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
OutputDevice doesn't need to be doing coordinate mapping. I am gradually
moving functionality from OutputDevice into CoordinateMapper, leaving
wrapper functions behind.
Change-Id: Iffbf308c99aee7fcab06683437013b7e34ecddde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196475
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
Replaced the anonymous namespace in vcl/source/outdev/map.cxx with
explicit static declarations for translation-unit local functions.
- Renamed getCorrectedUnit() to lcl_getCorrectedUnit() to match the
standard lcl_ prefix convention for local functions.
- Explicitly marked lcl_getCorrectedUnit() and lcl_calcConversionMapRes()
as static.
- Updated all corresponding call sites to reflect the renamed function.
Change-Id: I6a489a50f3f12d2797ecfb4c46dfed8dede70b1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203269
Tested-by: Jenkins
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Moved the declaration of the sal_uInt16 i loop counter directly into
the for loop initializers across several polygon conversion methods
in vcl/source/outdev/map.cxx. This reduces the scope of the variables
to the loops themselves, cleaning up the code and following modern C++
practices.
Affected functions include:
- ImplLogicToDevicePixel()
- LogicToPixel() (both overloads)
- PixelToLogic() (both overloads)
Change-Id: I5f7f46d786c2e7e34c8277acee689820c5f74305
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196481
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
Refactored multiple functions in vcl/source/outdev/map.cxx to utilize
early returns. This flattens the code structure, reduces nesting levels,
and improves overall readability without altering the underlying logic.
Affected functions include:
- ImplLogicToDevicePixel()
- SetMapMode()
- GetViewTransformation()
- GetInverseViewTransformation()
- lcl_resolveMapRes()
- lcl_convertLogicValue()
- LogicToLogic() (Point, Size, and B2DHomMatrix overloads)
Added a mapping relative scaling unit test.
Change-Id: I7b0bc6a33cb655080cbf2699e9adc0345b15ca92
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203268
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Renamed the following methods in OutputDevice to remove the "Impl"
prefix, standardizing the naming convention to match the existing
LogicWidthToDevicePixel() method:
- ImplLogicHeightToDevicePixel() -> LogicHeightToDevicePixel()
- ImplLogicHeightToDeviceSubPixel() -> LogicHeightToDeviceSubPixel()
- ImplDevicePixelToLogicWidth() -> DevicePixelToLogicWidth()
- ImplDevicePixelToLogicHeight() -> DevicePixelToLogicHeight()
Updated all corresponding call sites across the vcl module to reflect
the new method names.
Change-Id: I780373600c0ba64e14e1a5ee1389d6733e1ffc69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203267
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This promotes several coordinate conversion methods from protected/private
Impl functions to public OutputDevice members, as they are widely
used across the VCL codebase (including by Window, VirtualDevice, and
various outdev components).
Changes:
- Renamed and exposed ImplLogicToDevicePixel(Point/Rectangle) as
LogicToDevicePixel().
- Renamed and exposed ImplLogicToDeviceSubPixel(Point) as
LogicToDeviceSubPixel().
- Renamed and exposed ImplLogicWidthToDevicePixel(Long) as
LogicWidthToDevicePixel().
- Renamed and exposed ImplLogicWidthToDeviceSubPixel(Long) as
LogicWidthToDeviceSubPixel().
- Updated all call sites across VCL to use the newly public API.
- Updated TestVirtualDevice in vclmaptest.cxx to reflect the
promoted method names.
Change-Id: I4063d77d76e8889dea06c2aab53d6ec2be3aee8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203262
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
The function ENTER4 in vcl/source/outdev/map.cxx has a name that gives
no indication of its purpose, making the code difficult to read.
This function calculates the map resolutions for a source and destination
MapMode using a standardized 72 DPI, which is necessary for logical unit
conversions.
Rename it to lcl_calcConversionMapRes to clearly reflect its purpose
and improve maintainability.
Change-Id: I2cc265c07c4108a3a3a37356a148ae9ea37a3b9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196467
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This change introduces a suite of tests targeting the MapMode logic,
coordinate conversions, and view transformations in OutputDevice to
safeguard the recent CoordinateMapper refactoring.
Changes:
- Added a TestVirtualDevice wrapper to expose protected OutputDevice
methods (ImplLogicHeightToDevicePixel, SetOutOffXPixel, etc.)
without requiring VCL_DLLPUBLIC exports.
- Added tests validating LogicToLogic edge cases, notably VCL's
additive treatment of MapMode origins.
- Added tests verifying standard LogicToPixel conversion math
(e.g., verifying 100thMM to Pixel at 96 DPI).
- Added tests ensuring that SetMapMode and SetRelativeMapMode
correctly propagate state down to the mapper and scale output.
- Added testViewTransformation to ensure that GetViewTransformation()
matrices produce results mathematically equivalent to LogicToPixel.
- Added basegfx to CppunitTest_vcl_map.mk dependencies to support
the matrix math in the new tests.
Change-Id: Ib98874ed0041a2579d8b941b781c7a4101b69215
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/203261
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
The ENTER1 macro in vcl/source/outdev/map.cxx hid the logic for
resolving the source and destination MapModes and implicitly handled
early returns. This made the code difficult to follow, debug, and
maintain.
This change replaces the macro with a new static helper function,
lcl_resolveMapRes(), which encapsulates the logic for determining the
effective MapResolution. The fallback logic and early returns are now
handled explicitly at the beginning of each LogicToLogic() overload,
making the control flow much clearer.
Add a unit test.
Change-Id: I1a68f3a168be3f9ea2c4d06354b7091e03964688
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196466
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Renames several file-local static functions in map.cxx to use the
standard 'lcl_' (local) prefix rather than 'Impl' or no prefix.
In VCL, the 'Impl' prefix is generally reserved for private member
functions of a class. Since these are free static helper functions
restricted to this translation unit, updating them to the 'lcl_'
prefix improves readability and aligns with LibreOffice naming
conventions.
Functions renamed:
- ImplCalcMapResolution -> lcl_calcMapResolution
- ImplLogicToPixel -> lcl_logicToPixel
- ImplPixelToLogic -> lcl_pixelToLogic
- ImplPixelToLogicDouble -> lcl_pixelToLogicDouble
- setMapRes -> lcl_setMapRes
Change-Id: I984a7a8da7dd1a2d2c996b4524f9f1def1874dea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196465
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
The static functions fn3 and fn5 in vcl/source/outdev/map.cxx have
names that give no indication of their purpose, making the code
difficult to follow.
fn3 is responsible for converting logical values between units, so
rename it to ImplConvertLogicValue().
fn5 is used to scale logical values (n1 * n2 * n3) / (n4 * n5) while
preventing overflow, so rename it to ImplScaleLogicValue().
Change-Id: Ib48db9389c889d19e2c651af6153f3577982ca15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196464
Tested-by: Jenkins
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
In the logic for transforming Bezier curves, the calculation for the
second control point (aC2) was accidentally assigning to the first
control point variable (aC1).
This left aC2 uninitialized (defaulting to 0,0) and corrupted aC1,
causing Bezier curves to visually collapse towards the origin.
Change-Id: I48572679e78146226dd09a011c57609fc1de3794
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196520
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Tested-by: Jenkins
This should whittle down this absolutely massive file and make it easier
to read and understand.
Change-Id: If2246b0b06ca5d1e9e92d45df2c8b3cfc1628178
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190883
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins
The DrawBitmapEx() functions forward to this version of DrawBitmapEx().
Before they foward they check if it is an alpha bitmap, if it isn't then
they call on DrawBitmap().
The version of the function they forward to merely draws an alpha
bitmap - there is no need for it to check that the bitmap has an alpha
channel as this was done already. In fact, anything that calls directly
on this function without such a bitmap should be calling DrawBitmapEx(),
so I've added an assert() to flag when this occurs.
Change-Id: Ia94caf28ba1d49ec7c9f17654ca73ef51baf49a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190896
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
We don't need to use the bClipped variable - instead, we return the
clipped bitmap if possible. If clipping wasn't possible, then it just
falls back to the code that would have run anyway.
Change-Id: Ia4c1e567d7fcfc19916aec515aee942e9d42bb15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189601
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This clarifies the variable. The variable is reused, but the first use
is to detect whether the area *should* be clipped. The second use of the
variable determines if the area *has been* clipped. Obviously, it makes
no sense to say that the area has been clipped (true) before we actually
do the clipping, so we should be setting it to false at the start of the
if statement. Then when the clipping succeeds then we can say that it
was successful.
This also removes the need to set the variable in several else
statements and we only have to set the variable to true once the
clipping succeeds.
In the next patch, I will also remove the need for the second
modification of the bClipped variable as we can just return the bitmap -
but it is far more clear what I'm doing with this patch.
Change-Id: If8e217975a7a1fa7efff8fb3607040e3269495e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189600
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>