Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / GraphicSizeCheck.hxx
bloba58a7f432476d78825e51d5e8e958a887d964b1c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <doc.hxx>
14 #include <svx/GenericCheckDialog.hxx>
16 namespace sw
18 /**
19 * Class responsible to check if a graphic object violates the size
20 * constraints and store the results.
22 class GraphicSizeViolation final
24 private:
25 const SwGrfNode* m_pGraphicNode;
27 sal_Int32 m_nLowDPILimit = 0;
28 sal_Int32 m_nHighDPILimit = 0;
30 sal_Int32 m_nDPIX = 0;
31 sal_Int32 m_nDPIY = 0;
33 public:
34 GraphicSizeViolation(sal_Int32 nDPI, const SwGrfNode* pGraphicNode);
35 bool check();
37 const OUString& getGraphicName();
39 bool isDPITooLow() { return m_nDPIX < m_nLowDPILimit || m_nDPIY < m_nLowDPILimit; }
41 bool isDPITooHigh() { return m_nDPIX > m_nHighDPILimit || m_nDPIY > m_nHighDPILimit; }
43 sal_Int32 getDPIX() { return m_nDPIX; }
45 sal_Int32 getDPIY() { return m_nDPIY; }
48 /**
49 * Run the graphic size checks for all the graphic objects in the DOM
50 * and store a list of violations.
52 class GraphicSizeCheck final
54 private:
55 SwDoc* m_pDocument;
56 std::vector<std::unique_ptr<GraphicSizeViolation>> m_aGraphicSizeViolationList;
58 public:
59 GraphicSizeCheck(SwDoc* pDocument)
60 : m_pDocument(pDocument)
64 void check();
66 std::vector<std::unique_ptr<GraphicSizeViolation>>& getViolationList()
68 return m_aGraphicSizeViolationList;
72 /** The UI part of the GraphicSizeViolation used by GenericCheckDialog */
73 class GraphicSizeCheckGUIEntry final : public svx::CheckData
75 private:
76 SwDoc* m_pDocument;
77 std::unique_ptr<GraphicSizeViolation> m_pViolation;
79 public:
80 GraphicSizeCheckGUIEntry(SwDoc* pDocument, std::unique_ptr<GraphicSizeViolation>&& pViolation)
81 : m_pDocument(pDocument)
82 , m_pViolation(std::move(pViolation))
86 OUString getText() override;
88 bool canMarkObject() override { return true; }
90 void markObject() override;
92 bool hasProperties() override { return true; }
94 void runProperties() override;
97 /**
98 * The UI part presenting the graphic size check results, which is
99 * used by GenericCheckDialog
101 class GraphicSizeCheckGUIResult final : public svx::CheckDataCollection
103 public:
104 GraphicSizeCheckGUIResult(SwDoc* pDocument);
106 OUString getTitle() override;
109 } // end sw namespace
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */