Debian Codegraph @

src/file/ApvlvAxOffice.h

raw
1 /*
2 * This file is part of the apvlv package
3 * Copyright (C) <2010> <Alf>
4 *
5 * Contact: Alf <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22 /* @CPPFILE ApvlvOffice.h
23 *
24 * Author: Alf <[email protected]>
25 */
26
27 #ifndef _APVLV_AXOFFICE_H_
28 #define _APVLV_AXOFFICE_H_
29
30 #include <QtAxContainer>
31
32 #include "ApvlvFile.h"
33 #include "ApvlvFileWidget.h"
34
35 namespace apvlv
36 {
37 class AxOffice
38 {
39 public:
40 virtual ~AxOffice ()
41 {
42 if (mDoc)
43 mDoc->dynamicCall ("Close()");
44 if (mApp)
45 mApp->dynamicCall ("Quit()");
46 delete mDoc;
47 delete mApp;
48 }
49
50 protected:
51 QAxWidget *mApp;
52 QAxObject *mDocs;
53 QAxObject *mDoc;
54 };
55
56 class ApvlvOfficeWord : public File, public AxOffice
57 {
58 FILE_TYPE_DECLARATION (ApvlvOfficeWord);
59
60 public:
61 bool load (const std::string &filename) override;
62
63 int sum () override;
64
65 SizeF pageSizeF (int page, int rot) override;
66
67 bool pageText (int pn, const Rectangle &rect, std::string &text) override;
68
69 bool pageRenderToImage (int pn, double zm, int rot, QImage *pix) override;
70
71 bool pageRenderToWebView (int pn, double zm, int rot,
72 WebView *webview) override;
73
74 std::optional<QByteArray> pathContent (const std::string &path) override;
75 };
76
77 class ApvlvPowerPoint : public File, public AxOffice
78 {
79 FILE_TYPE_DECLARATION (ApvlvPowerPoint);
80
81 public:
82 bool load (const std::string &filename) override;
83
84 int sum () override;
85
86 SizeF pageSizeF (int page, int rot) override;
87
88 bool pageText (int pn, const Rectangle &rect, std::string &text) override;
89
90 bool pageRenderToImage (int pn, double zm, int rot, QImage *pix) override;
91 };
92
93 class ExcelWidget : public FileWidget
94 {
95 public:
96 ExcelWidget ()
97 {
98 mAxWidget.setProperty ("Visible", true);
99 mAxWidget.setProperty ("ReadOnly", true);
100 }
101
102 [[nodiscard]] QWidget *
103 widget () override
104 {
105 return &mAxWidget;
106 }
107
108 void setFile (File *file) override;
109
110 void showPage (int, double s) override;
111 void showPage (int, const std::string &anchor) override;
112
113 private:
114 QAxWidget mAxWidget{ "Excel.Workbook" };
115 };
116
117 class ApvlvExcel : public File, public AxOffice
118 {
119 FILE_TYPE_DECLARATION (ApvlvExcel);
120
121 public:
122 bool load (const std::string &filename) override;
123
124 [[nodiscard]] virtual DISPLAY_TYPE
125 getDisplayType () const override
126 {
127 return DISPLAY_TYPE::CUSTOM;
128 }
129
130 ExcelWidget *getWidget () override;
131
132 int sum () override;
133
134 bool pageText (int pn, const Rectangle &rect, std::string &text) override;
135 };
136
137 }
138
139 #endif
140
141 /* Local Variables: */
142 /* mode: c++ */
143 /* End: */