summaryrefslogtreecommitdiff
path: root/sd/source/ui/inc/tools/GraphicSizeCheck.hxx
blob: 9da3d569bd3ace7a8e3df0c545fdddaa329fcb94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* -*- 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/.
 *
 */

#pragma once

#include <memory>
#include <drawdoc.hxx>
#include <svx/GenericCheckDialog.hxx>
#include <svx/svdograf.hxx>

namespace sd
{
class GraphicSizeViolation final
{
private:
    SdrGrafObj* m_pGraphicObject;

    sal_Int32 m_nLowDPILimit = 0;
    sal_Int32 m_nHighDPILimit = 0;

    sal_Int32 m_nDPIX = 0;
    sal_Int32 m_nDPIY = 0;

public:
    GraphicSizeViolation(sal_Int32 nDPI, SdrGrafObj* pGraphicObject);
    bool check();

    OUString getGraphicName();

    SdrGrafObj* getObject() const { return m_pGraphicObject; }

    bool isDPITooLow() { return m_nDPIX < m_nLowDPILimit || m_nDPIY < m_nLowDPILimit; }

    bool isDPITooHigh() { return m_nDPIX > m_nHighDPILimit || m_nDPIY > m_nHighDPILimit; }

    sal_Int32 getDPIX() { return m_nDPIX; }

    sal_Int32 getDPIY() { return m_nDPIY; }
};

class GraphicSizeCheck final
{
private:
    SdDrawDocument* m_pDocument;
    std::vector<std::unique_ptr<GraphicSizeViolation>> m_aGraphicSizeViolationList;

public:
    GraphicSizeCheck(SdDrawDocument* pDocument)
        : m_pDocument(pDocument)
    {
    }

    void check();

    std::vector<std::unique_ptr<GraphicSizeViolation>>& getViolationList()
    {
        return m_aGraphicSizeViolationList;
    }
};

class GraphicSizeCheckGUIEntry : public svx::CheckData
{
private:
    SdDrawDocument* m_pDocument;
    std::unique_ptr<GraphicSizeViolation> m_pViolation;

public:
    GraphicSizeCheckGUIEntry(SdDrawDocument* pDocument,
                             std::unique_ptr<GraphicSizeViolation>&& pViolation)
        : m_pDocument(pDocument)
        , m_pViolation(std::move(pViolation))
    {
    }

    OUString getText() override;

    bool canMarkObject() override { return true; }

    void markObject() override;

    bool hasProperties() override { return true; }

    void runProperties() override;
};

class GraphicSizeCheckGUIResult : public svx::CheckDataCollection
{
public:
    GraphicSizeCheckGUIResult(SdDrawDocument* m_pDocument);

    OUString getTitle() override;
};

} // end of namespace sd

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */