/src/libreoffice/include/unotools/moduleoptions.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #ifndef INCLUDED_UNOTOOLS_MODULEOPTIONS_HXX |
21 | | #define INCLUDED_UNOTOOLS_MODULEOPTIONS_HXX |
22 | | |
23 | | #include <unotools/unotoolsdllapi.h> |
24 | | #include <rtl/ustring.hxx> |
25 | | #include <sal/types.h> |
26 | | #include <unotools/options.hxx> |
27 | | #include <memory> |
28 | | |
29 | | namespace com::sun::star::frame { class XModel; } |
30 | | namespace com::sun::star::beans { struct PropertyValue; } |
31 | | namespace com::sun::star::uno { template <class interface_type> class Reference; } |
32 | | namespace com::sun::star::uno { template <typename> class Sequence; } |
33 | | |
34 | | /*-************************************************************************************************************ |
35 | | @short forward declaration to our private date container implementation |
36 | | @descr We use these class as internal member to support small memory requirements. |
37 | | You can create the container if it is necessary. The class which use these mechanism |
38 | | is faster and smaller than a complete implementation! |
39 | | *//*-*************************************************************************************************************/ |
40 | | class SvtModuleOptions_Impl; |
41 | | |
42 | | /*-************************************************************************************************************ |
43 | | @short collect information about installation state of modules |
44 | | @descr Use these class to get installation state of different office modules like writer, calc etc |
45 | | Further you can ask for additional information; e.g. name of standard template file, which |
46 | | should be used by corresponding module; or short/long name of these module factory. |
47 | | @devstatus ready to use |
48 | | @threadsafe yes |
49 | | *//*-*************************************************************************************************************/ |
50 | | class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtModuleOptions final : public utl::detail::Options |
51 | | { |
52 | | public: |
53 | | |
54 | | enum class EModule |
55 | | { |
56 | | WRITER = 0, |
57 | | CALC = 1, |
58 | | DRAW = 2, |
59 | | IMPRESS = 3, |
60 | | MATH = 4, |
61 | | CHART = 5, |
62 | | STARTMODULE = 6, |
63 | | BASIC = 7, |
64 | | DATABASE = 8, |
65 | | WEB = 9, |
66 | | GLOBAL = 10 |
67 | | }; |
68 | | |
69 | | /*ATTENTION: |
70 | | If you change these enum ... don't forget to change reading/writing and order of configuration values too! |
71 | | See "SvtModuleOptions_Impl::impl_GetSetNames()" and his ctor for further information. |
72 | | */ |
73 | | enum class EFactory |
74 | | { |
75 | | UNKNOWN_FACTORY = -1, |
76 | | WRITER = 0, |
77 | | WRITERWEB = 1, |
78 | | WRITERGLOBAL = 2, |
79 | | CALC = 3, |
80 | | DRAW = 4, |
81 | | IMPRESS = 5, |
82 | | MATH = 6, |
83 | | CHART = 7, |
84 | | STARTMODULE = 8, |
85 | | DATABASE = 9, |
86 | | BASIC = 10, |
87 | | LAST = BASIC |
88 | | }; |
89 | | |
90 | | public: |
91 | | SvtModuleOptions(); |
92 | | virtual ~SvtModuleOptions() override; |
93 | | |
94 | | bool IsModuleInstalled ( EModule eModule ) const; |
95 | | OUString GetModuleName ( EModule eModule ) const; |
96 | | const OUString & GetFactoryName ( EFactory eFactory ) const; |
97 | | OUString GetFactoryStandardTemplate( EFactory eFactory ) const; |
98 | | OUString GetFactoryEmptyDocumentURL( EFactory eFactory ) const; |
99 | | OUString GetFactoryDefaultFilter ( EFactory eFactory ) const; |
100 | | bool IsDefaultFilterReadonly ( EFactory eFactory ) const; |
101 | | sal_Int32 GetFactoryIcon ( EFactory eFactory ) const; |
102 | | static bool ClassifyFactoryByName ( std::u16string_view sName , |
103 | | EFactory& eFactory ); |
104 | | void SetFactoryStandardTemplate( EFactory eFactory , |
105 | | const OUString& sTemplate ); |
106 | | void SetFactoryDefaultFilter ( EFactory eFactory , |
107 | | const OUString& sFilter ); |
108 | | |
109 | | /** @short return the corresponding application ID for the given |
110 | | document service name. |
111 | | */ |
112 | | static EFactory ClassifyFactoryByServiceName(std::u16string_view sName); |
113 | | |
114 | | /** @short return the corresponding application ID for the given |
115 | | short name. |
116 | | */ |
117 | | static EFactory ClassifyFactoryByShortName(std::u16string_view sName); |
118 | | |
119 | | /** @short return the corresponding application ID for the given properties. |
120 | | |
121 | | @descr Because this search base on filters currently (till we have a better solution) |
122 | | a result is not guaranteed every time. May a filter does not exists for the specified |
123 | | content (but a FrameLoader which is not bound to any application!) ... or |
124 | | the given properties describe a stream (and we make no deep detection inside here!). |
125 | | |
126 | | @attention The module BASIC can't be detected here. Because it does not |
127 | | has an own URL schema. |
128 | | |
129 | | @param sURL |
130 | | the complete URL! |
131 | | |
132 | | @param lMediaDescriptor |
133 | | additional information |
134 | | |
135 | | @return A suitable enum value. See EFactory above. |
136 | | */ |
137 | | static EFactory ClassifyFactoryByURL(const OUString& sURL , |
138 | | const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor); |
139 | | |
140 | | /** @short return the corresponding application ID for the given properties. |
141 | | |
142 | | @descr Here we try to use the list of supported service names of the given model |
143 | | to find out the right application module. |
144 | | |
145 | | @attention The module BASIC can't be detected here. Because it does not |
146 | | support any model/ctrl/view paradigm. |
147 | | |
148 | | @param xModel |
149 | | the document model |
150 | | |
151 | | @return A suitable enum value. See EFactory above. |
152 | | */ |
153 | | static EFactory ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel >& xModel); |
154 | | |
155 | | static OUString GetFactoryShortName(EFactory eFactory); |
156 | | |
157 | | OUString GetDefaultModuleName() const; |
158 | | |
159 | 0 | bool IsMathInstalled() const { return IsModuleInstalled(EModule::MATH); } |
160 | 450 | bool IsChartInstalled() const { return IsModuleInstalled(EModule::CHART); } |
161 | 0 | bool IsCalcInstalled() const { return IsModuleInstalled(EModule::CALC); } |
162 | 0 | bool IsDrawInstalled() const { return IsModuleInstalled(EModule::DRAW); } |
163 | 0 | bool IsWriterInstalled() const { return IsModuleInstalled(EModule::WRITER); } |
164 | 0 | bool IsImpressInstalled() const { return IsModuleInstalled(EModule::IMPRESS); } |
165 | 0 | static bool IsBasicIDEInstalled() { return true; } |
166 | 0 | bool IsDataBaseInstalled() const { return IsModuleInstalled(EModule::DATABASE); } |
167 | | |
168 | | css::uno::Sequence < OUString > GetAllServiceNames(); |
169 | | |
170 | | private: |
171 | | std::shared_ptr<SvtModuleOptions_Impl> m_pImpl; |
172 | | |
173 | | }; // class SvtModuleOptions |
174 | | |
175 | | #endif // INCLUDED_UNOTOOLS_MODULEOPTIONS_HXX |
176 | | |
177 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |