tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / starmath / inc / document.hxx
blobc73723a434d0b175170691ca4aad6bf95e01e947
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 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <rtl/strbuf.hxx>
23 #include <sfx2/docfac.hxx>
24 #include <sfx2/objsh.hxx>
25 #include <svl/lstner.hxx>
26 #include <svl/itempool.hxx>
27 #include <sax/fshelper.hxx>
28 #include <unotools/lingucfg.hxx>
29 #include <oox/core/filterbase.hxx>
30 #include <oox/export/utils.hxx>
32 #include "format.hxx"
33 #include "node.hxx"
34 #include "parsebase.hxx"
35 #include "smdllapi.hxx"
36 #include "mathml/iterator.hxx"
38 class SfxPrinter;
39 class Printer;
40 class SmCursor;
42 namespace oox::formulaimport { class XmlStream; }
44 #define STAROFFICE_XML "StarOffice XML (Math)"
45 inline constexpr OUString MATHML_XML = u"MathML XML (Math)"_ustr;
47 /* Access to printer should happen through this class only
48 * ==========================================================================
50 * The printer can belong to the document or the OLE-Container. If the document
51 * is an OLE-Document the printer generally belongs to the container too.
52 * But the container maybe works with a different MapUnit than the server.
53 * Referring to the MapMode the printer will be accordingly adjusted in the
54 * constructor and restored in the destructor. This brings that this class
55 * is always allowed to exists only a short time (e.g. while painting).
56 * The control whether the printer is self-generated, gotten from the server
57 * or is NULL then, is taken by the DocShell in the method GetPrt(), for
58 * which the access is friend of the DocShell too.
61 class SmDocShell;
62 class EditEngine;
63 class SmEditEngine;
64 class SmPrintUIOptions;
66 class SmPrinterAccess
68 VclPtr<Printer> pPrinter;
69 VclPtr<OutputDevice> pRefDev;
70 public:
71 explicit SmPrinterAccess( SmDocShell &rDocShell );
72 ~SmPrinterAccess();
73 Printer* GetPrinter() { return pPrinter.get(); }
74 OutputDevice* GetRefDev() { return pRefDev.get(); }
78 class SM_DLLPUBLIC SmDocShell final : public SfxObjectShell, public SfxListener
80 friend class SmPrinterAccess;
81 friend class SmCursor;
83 OUString maText;
84 SmFormat maFormat;
85 OUString maAccText;
86 SvtLinguOptions maLinguOptions;
87 std::unique_ptr<SmTableNode> mpTree;
88 SmMlElement* m_pMlElementTree;
89 rtl::Reference<SfxItemPool> mpEditEngineItemPool;
90 std::unique_ptr<SmEditEngine> mpEditEngine;
91 VclPtr<SfxPrinter> mpPrinter; //q.v. comment to SmPrinter Access!
92 VclPtr<Printer> mpTmpPrinter; //ditto
93 sal_uInt16 mnModifyCount;
94 bool mbFormulaArranged;
95 sal_Int16 mnSmSyntaxVersion;
96 std::unique_ptr<AbstractSmParser> maParser;
97 std::unique_ptr<SmCursor> mpCursor;
98 std::set< OUString > maUsedSymbols; // to export used symbols only when saving
101 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
103 bool WriteAsMathType3( SfxMedium& );
105 virtual void Draw(OutputDevice *pDevice,
106 const JobSetup & rSetup,
107 sal_uInt16 nAspect,
108 bool bOutputForScreen) override;
110 virtual void FillClass(SvGlobalName* pClassName,
111 SotClipboardFormatId* pFormat,
112 OUString* pFullTypeName,
113 sal_Int32 nFileFormat,
114 bool bTemplate = false ) const override;
116 virtual void OnDocumentPrinterChanged( Printer * ) override;
117 virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
118 virtual bool Load( SfxMedium& rMedium ) override;
119 virtual bool Save() override;
120 virtual bool SaveAs( SfxMedium& rMedium ) override;
122 Printer *GetPrt();
123 OutputDevice* GetRefDev();
125 void SetFormulaArranged(bool bVal) { mbFormulaArranged = bVal; }
127 virtual bool ConvertFrom(SfxMedium &rMedium) override;
129 /** Called whenever the formula is changed
130 * Deletes the current cursor
132 void InvalidateCursor();
134 public:
135 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(1))
137 SFX_DECL_OBJECTFACTORY();
139 private:
140 /// SfxInterface initializer.
141 static void InitInterface_Impl();
143 public:
144 explicit SmDocShell( SfxModelFlags i_nSfxCreationFlags );
145 virtual ~SmDocShell() override;
147 virtual bool ConvertTo( SfxMedium &rMedium ) override;
149 // For unit tests, not intended to use in other context
150 void SetGreekCharStyle(sal_Int16 nVal) { maFormat.SetGreekCharStyle(nVal); }
152 static void LoadSymbols();
153 static void SaveSymbols();
155 void ArrangeFormula();
157 //Access for the View. This access is not for the OLE-case!
158 //and for the communication with the SFX!
159 //All internal printer uses should work with the SmPrinterAccess only
160 bool HasPrinter() const { return mpPrinter != nullptr; }
161 SfxPrinter *GetPrinter() { GetPrt(); return mpPrinter; }
162 void SetPrinter( SfxPrinter * );
164 OUString GetComment() const;
166 // to replace chars that can not be saved with the document...
167 void ReplaceBadChars();
169 void UpdateText();
170 void SetText(const OUString& rBuffer);
171 const OUString& GetText() const { return maText; }
172 void SetFormat(SmFormat const & rFormat);
173 const SmFormat& GetFormat() const { return maFormat; }
175 void Parse();
176 AbstractSmParser* GetParser() { return maParser.get(); }
177 const SmTableNode *GetFormulaTree() const { return mpTree.get(); }
178 void SetFormulaTree(SmTableNode *pTree) { mpTree.reset(pTree); }
179 sal_Int16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; }
180 void SetSmSyntaxVersion(sal_Int16 nSmSyntaxVersion);
182 const std::set< OUString > & GetUsedSymbols() const { return maUsedSymbols; }
184 OUString const & GetAccessibleText();
186 EditEngine & GetEditEngine();
188 void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
189 Size GetSize();
191 void Repaint();
193 virtual SfxUndoManager *GetUndoManager () override;
195 static SfxItemPool& GetPool();
197 void Execute( SfxRequest& rReq );
198 void GetState(SfxItemSet &);
200 virtual void SetVisArea (const tools::Rectangle & rVisArea) override;
201 virtual void SetModified(bool bModified = true) override;
203 /** Get a cursor for modifying this document
204 * @remarks Don't store this reference, a new cursor may be made...
206 SmCursor& GetCursor();
207 /** True, if cursor have previously been requested and thus
208 * has some sort of position.
210 bool HasCursor() const;
212 void writeFormulaOoxml(const ::sax_fastparser::FSHelperPtr& pSerializer,
213 oox::core::OoxmlVersion version,
214 oox::drawingml::DocumentType documentType,
215 const sal_Int8 nAlign);
216 void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
217 void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
219 void UpdateEditEngineDefaultFonts();
221 SmMlElement* GetMlElementTree() { return m_pMlElementTree; }
222 void SetMlElementTree(SmMlElement* pMlElementTree) {
223 mathml::SmMlIteratorFree(m_pMlElementTree);
224 m_pMlElementTree = pMlElementTree;
227 void SetRightToLeft(bool bRTL);
229 void Impl_Print(OutputDevice& rOutDev, const SmPrintUIOptions& rPrintUIOptions,
230 tools::Rectangle aOutRect);
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */