From f7974dc8d6d0cca08da52c4fbdb312ed6b7d71da Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Mon, 10 Jul 2023 17:09:14 +0200 Subject: tdf#148729 sw: PDF export: fix link targets when "comments in margin" ... is enabled but there are no comments; the conditions in SwViewShell::PrintOrPDFExport() and SwEnhancedPDFExportHelper::SwRectToPDFRect() were out of sync. (regression from commit c77e01d63b4bd4805c4a499e4e0cab917d0eb403) Change-Id: I617185e6f30843a79190a54b73a5f44666697388 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154279 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/source/core/inc/vprint.hxx | 34 +++++++++++++++++++++++++ sw/source/core/text/EnhancedPDFExportHelper.cxx | 6 +++-- sw/source/core/view/viewpg.cxx | 2 +- sw/source/core/view/vprint.cxx | 18 +++++++++---- sw/source/core/view/vprint.hxx | 27 -------------------- 5 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 sw/source/core/inc/vprint.hxx delete mode 100644 sw/source/core/view/vprint.hxx (limited to 'sw') diff --git a/sw/source/core/inc/vprint.hxx b/sw/source/core/inc/vprint.hxx new file mode 100644 index 000000000000..9d2c7fe3722f --- /dev/null +++ b/sw/source/core/inc/vprint.hxx @@ -0,0 +1,34 @@ +/* -*- 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include + +class SwRootFrame; +class SwPageFrame; +class SwPrintData; + +SwPageFrame const* sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage); + +namespace sw +{ +bool IsShrinkPageForPostIts(SwViewShell const& rShell, SwPrintData const&); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 431137a92257..25be18e0d521 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -1714,9 +1715,10 @@ SwEnhancedPDFExportHelper::~SwEnhancedPDFExportHelper() tools::Rectangle SwEnhancedPDFExportHelper::SwRectToPDFRect(const SwPageFrame* pCurrPage, const tools::Rectangle& rRectangle) const { - SwPostItMode nPostItMode = mrPrintData.GetPrintPostIts(); - if (nPostItMode != SwPostItMode::InMargins) + if (!::sw::IsShrinkPageForPostIts(mrSh, mrPrintData)) // tdf#148729 + { return rRectangle; + } //the page has been scaled by 75% and vertically centered, so adjust these //rectangles equivalently tools::Rectangle aRect(rRectangle); diff --git a/sw/source/core/view/viewpg.cxx b/sw/source/core/view/viewpg.cxx index 4d2385483c92..02ebd1a69e12 100644 --- a/sw/source/core/view/viewpg.cxx +++ b/sw/source/core/view/viewpg.cxx @@ -28,7 +28,7 @@ #include #include -#include "vprint.hxx" +#include using namespace ::com::sun::star; diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 3cd0c524007e..bc5dd5bd6c86 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -47,7 +47,7 @@ #include #include #include -#include "vprint.hxx" +#include using namespace ::com::sun::star; @@ -429,6 +429,17 @@ sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage) return nullptr; } +namespace sw +{ + // tdf#91680 Reserve space in margin for comments only if there are comments + bool IsShrinkPageForPostIts(SwViewShell const& rShell, SwPrintData const& rPrintData) + { + SwPostItMode const nPostItMode(rPrintData.GetPrintPostIts()); + return nPostItMode == SwPostItMode::InMargins + && sw_GetPostIts(rShell.GetDoc()->getIDocumentFieldsAccess(), nullptr); + } +} + bool SwViewShell::PrintOrPDFExport( OutputDevice *pOutDev, SwPrintData const& rPrintData, @@ -446,11 +457,8 @@ bool SwViewShell::PrintOrPDFExport( // output device is now provided by a call from outside the Writer) pOutDev->Push(); - SwPostItMode nPostItMode = rPrintData.GetPrintPostIts(); - // tdf#91680 Reserve space in margin for comments only if there are comments - const bool bHasPostItsToPrintInMargins = ( nPostItMode == SwPostItMode::InMargins ) && - sw_GetPostIts( GetDoc()->getIDocumentFieldsAccess(), nullptr ); + const bool bHasPostItsToPrintInMargins(::sw::IsShrinkPageForPostIts(*this, rPrintData)); ::std::optional oOrigHeight; // Print/PDF export for (multi-)selection has already generated a diff --git a/sw/source/core/view/vprint.hxx b/sw/source/core/view/vprint.hxx deleted file mode 100644 index 60f2750caeb9..000000000000 --- a/sw/source/core/view/vprint.hxx +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include - -class SwRootFrame; -class SwPageFrame; -SwPageFrame const* sw_getPage(SwRootFrame const& rLayout, sal_Int32 const nPage); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit