1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
14 #include <drawdoc.hxx>
15 #include <svx/GenericCheckDialog.hxx>
16 #include <svx/svdograf.hxx>
21 * Class responsible to check if a graphic object violates the size
22 * constraints and store the results.
24 class GraphicSizeViolation final
27 SdrGrafObj
* m_pGraphicObject
;
29 sal_Int32 m_nLowDPILimit
= 0;
30 sal_Int32 m_nHighDPILimit
= 0;
32 sal_Int32 m_nDPIX
= 0;
33 sal_Int32 m_nDPIY
= 0;
36 GraphicSizeViolation(sal_Int32 nDPI
, SdrGrafObj
* pGraphicObject
);
39 const OUString
& getGraphicName();
41 SdrGrafObj
* getObject() const { return m_pGraphicObject
; }
43 bool isDPITooLow() { return m_nDPIX
< m_nLowDPILimit
|| m_nDPIY
< m_nLowDPILimit
; }
45 bool isDPITooHigh() { return m_nDPIX
> m_nHighDPILimit
|| m_nDPIY
> m_nHighDPILimit
; }
47 sal_Int32
getDPIX() { return m_nDPIX
; }
49 sal_Int32
getDPIY() { return m_nDPIY
; }
53 * Run the graphic size checks for all the graphic objects in the DOM
54 * and store a list of violations.
56 class GraphicSizeCheck final
59 SdDrawDocument
* m_pDocument
;
60 std::vector
<std::unique_ptr
<GraphicSizeViolation
>> m_aGraphicSizeViolationList
;
63 GraphicSizeCheck(SdDrawDocument
* pDocument
)
64 : m_pDocument(pDocument
)
70 std::vector
<std::unique_ptr
<GraphicSizeViolation
>>& getViolationList()
72 return m_aGraphicSizeViolationList
;
76 /** The UI part of the GraphicSizeViolation used by GenericCheckDialog */
77 class GraphicSizeCheckGUIEntry
: public svx::CheckData
80 SdDrawDocument
* m_pDocument
;
81 std::unique_ptr
<GraphicSizeViolation
> m_pViolation
;
84 GraphicSizeCheckGUIEntry(SdDrawDocument
* pDocument
,
85 std::unique_ptr
<GraphicSizeViolation
>&& pViolation
)
86 : m_pDocument(pDocument
)
87 , m_pViolation(std::move(pViolation
))
91 OUString
getText() override
;
93 bool canMarkObject() override
{ return true; }
95 void markObject() override
;
97 bool hasProperties() override
{ return true; }
99 void runProperties() override
;
103 * The UI part presenting the graphic size check results, which is
104 * used by GenericCheckDialog
106 class GraphicSizeCheckGUIResult
: public svx::CheckDataCollection
109 GraphicSizeCheckGUIResult(SdDrawDocument
* m_pDocument
);
111 OUString
getTitle() override
;
114 } // end of namespace sd
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */