LibreOffice Module starmath (master) 1
document.hxx
Go to the documentation of this file.
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#pragma once
21
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>
30#include <oox/export/utils.hxx>
31
32#include "format.hxx"
33#include "node.hxx"
34#include "parsebase.hxx"
35#include "smdllapi.hxx"
36#include "mathml/iterator.hxx"
37
38class SfxPrinter;
39class Printer;
40class SmCursor;
41
42namespace oox::formulaimport { class XmlStream; }
43
44#define STAROFFICE_XML "StarOffice XML (Math)"
45inline constexpr OUStringLiteral MATHML_XML = u"MathML XML (Math)";
46
47/* Access to printer should happen through this class only
48 * ==========================================================================
49 *
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.
59 */
60
61class SmDocShell;
62class EditEngine;
63class SmEditEngine;
64
66{
69public:
70 explicit SmPrinterAccess( SmDocShell &rDocShell );
72 Printer* GetPrinter() { return pPrinter.get(); }
74};
75
76
78{
79 friend class SmPrinterAccess;
80 friend class SmCursor;
81
82 OUString maText;
84 OUString maAccText;
86 std::unique_ptr<SmTableNode> mpTree;
89 std::unique_ptr<SmEditEngine> mpEditEngine;
90 VclPtr<SfxPrinter> mpPrinter; //q.v. comment to SmPrinter Access!
92 sal_uInt16 mnModifyCount;
95 std::unique_ptr<AbstractSmParser> maParser;
96 std::unique_ptr<SmCursor> mpCursor;
97 std::set< OUString > maUsedSymbols; // to export used symbols only when saving
98
99
100 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
101
102 bool WriteAsMathType3( SfxMedium& );
103
104 virtual void Draw(OutputDevice *pDevice,
105 const JobSetup & rSetup,
106 sal_uInt16 nAspect,
107 bool bOutputForScreen) override;
108
109 virtual void FillClass(SvGlobalName* pClassName,
110 SotClipboardFormatId* pFormat,
111 OUString* pFullTypeName,
112 sal_Int32 nFileFormat,
113 bool bTemplate = false ) const override;
114
115 virtual void OnDocumentPrinterChanged( Printer * ) override;
116 virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
117 virtual bool Load( SfxMedium& rMedium ) override;
118 virtual bool Save() override;
119 virtual bool SaveAs( SfxMedium& rMedium ) override;
120
121 Printer *GetPrt();
122 OutputDevice* GetRefDev();
123
124 void SetFormulaArranged(bool bVal) { mbFormulaArranged = bVal; }
125
126 virtual bool ConvertFrom(SfxMedium &rMedium) override;
127
131 void InvalidateCursor();
132
133public:
134 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(1))
135
136 SFX_DECL_OBJECTFACTORY();
137
138private:
140 static void InitInterface_Impl();
141
142public:
143 explicit SmDocShell( SfxModelFlags i_nSfxCreationFlags );
144 virtual ~SmDocShell() override;
145
146 virtual bool ConvertTo( SfxMedium &rMedium ) override;
147
148 // For unit tests, not intended to use in other context
149 void SetGreekCharStyle(sal_Int16 nVal) { maFormat.SetGreekCharStyle(nVal); }
150
151 static void LoadSymbols();
152 static void SaveSymbols();
153
154 void ArrangeFormula();
155
156 //Access for the View. This access is not for the OLE-case!
157 //and for the communication with the SFX!
158 //All internal printer uses should work with the SmPrinterAccess only
159 bool HasPrinter() const { return mpPrinter != nullptr; }
160 SfxPrinter *GetPrinter() { GetPrt(); return mpPrinter; }
161 void SetPrinter( SfxPrinter * );
162
163 OUString GetComment() const;
164
165 // to replace chars that can not be saved with the document...
166 void ReplaceBadChars();
167
168 void UpdateText();
169 void SetText(const OUString& rBuffer);
170 const OUString& GetText() const { return maText; }
171 void SetFormat(SmFormat const & rFormat);
172 const SmFormat& GetFormat() const { return maFormat; }
173
174 void Parse();
175 AbstractSmParser* GetParser() { return maParser.get(); }
176 const SmTableNode *GetFormulaTree() const { return mpTree.get(); }
177 void SetFormulaTree(SmTableNode *pTree) { mpTree.reset(pTree); }
178 sal_uInt16 GetSmSyntaxVersion() const { return mnSmSyntaxVersion; }
179 void SetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion);
180
181 const std::set< OUString > & GetUsedSymbols() const { return maUsedSymbols; }
182
183 OUString const & GetAccessibleText();
184
185 EditEngine & GetEditEngine();
186
187 void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
188 Size GetSize();
189
190 void Repaint();
191
192 virtual SfxUndoManager *GetUndoManager () override;
193
194 static SfxItemPool& GetPool();
195
196 void Execute( SfxRequest& rReq );
197 void GetState(SfxItemSet &);
198
199 virtual void SetVisArea (const tools::Rectangle & rVisArea) override;
200 virtual void SetModified(bool bModified = true) override;
201
205 SmCursor& GetCursor();
209 bool HasCursor() const;
210
211 void writeFormulaOoxml(const ::sax_fastparser::FSHelperPtr& pSerializer,
213 oox::drawingml::DocumentType documentType,
214 const sal_Int8 nAlign);
215 void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
216 void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
217
218 void UpdateEditEngineDefaultFonts();
219
220 SmMlElement* GetMlElementTree() { return m_pMlElementTree; }
221 void SetMlElementTree(SmMlElement* pMlElementTree) {
222 mathml::SmMlIteratorFree(m_pMlElementTree);
223 m_pMlElementTree = pMlElementTree;
224 }
225};
226
227/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Text maText
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual bool ConvertFrom(SfxMedium &rMedium)
virtual void OnDocumentPrinterChanged(Printer *pNewPrinter)
virtual bool Load(SfxMedium &rMedium)
virtual bool SaveAs(SfxMedium &rMedium)
virtual void SetVisArea(const tools::Rectangle &rVisArea)
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect, bool bOutputForScreen)=0
virtual bool Save()
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const=0
virtual void SetModified(bool bModified=true)
SfxItemPool & GetPool() const
virtual SfxUndoManager * GetUndoManager()
Formula cursor.
Definition: cursor.hxx:69
SmNode * mpTree
Formula tree.
Definition: cursor.hxx:199
const SmTableNode * GetFormulaTree() const
Definition: document.hxx:176
void SetFormulaArranged(bool bVal)
Definition: document.hxx:124
OUString maAccText
Definition: document.hxx:84
SmFormat maFormat
Definition: document.hxx:83
SfxPrinter * GetPrinter()
Definition: document.hxx:160
VclPtr< SfxPrinter > mpPrinter
Definition: document.hxx:90
OUString maText
Definition: document.hxx:82
const OUString & GetText() const
Definition: document.hxx:170
std::unique_ptr< SmCursor > mpCursor
Definition: document.hxx:96
SmMlElement * m_pMlElementTree
Definition: document.hxx:87
std::unique_ptr< AbstractSmParser > maParser
Definition: document.hxx:95
std::set< OUString > maUsedSymbols
Definition: document.hxx:97
std::unique_ptr< SmTableNode > mpTree
Definition: document.hxx:86
bool HasPrinter() const
Definition: document.hxx:159
SmMlElement * GetMlElementTree()
Definition: document.hxx:220
VclPtr< Printer > mpTmpPrinter
Definition: document.hxx:91
bool mbFormulaArranged
Definition: document.hxx:93
const SmFormat & GetFormat() const
Definition: document.hxx:172
sal_uInt16 GetSmSyntaxVersion() const
Definition: document.hxx:178
rtl::Reference< SfxItemPool > mpEditEngineItemPool
Definition: document.hxx:88
std::unique_ptr< SmEditEngine > mpEditEngine
Definition: document.hxx:89
void SetMlElementTree(SmMlElement *pMlElementTree)
Definition: document.hxx:221
const std::set< OUString > & GetUsedSymbols() const
Definition: document.hxx:181
AbstractSmParser * GetParser()
Definition: document.hxx:175
sal_uInt16 mnModifyCount
Definition: document.hxx:92
SvtLinguOptions maLinguOptions
Definition: document.hxx:85
void SetFormulaTree(SmTableNode *pTree)
Definition: document.hxx:177
sal_uInt16 mnSmSyntaxVersion
Definition: document.hxx:94
void SetGreekCharStyle(sal_Int16 nVal)
Definition: format.hxx:130
SmPrinterAccess(SmDocShell &rDocShell)
Definition: document.cxx:403
Printer * GetPrinter()
Definition: document.hxx:72
VclPtr< Printer > pPrinter
Definition: document.hxx:67
OutputDevice * GetRefDev()
Definition: document.hxx:73
VclPtr< OutputDevice > pRefDev
Definition: document.hxx:68
Table node.
Definition: node.hxx:1139
reference_type * get() const
virtual void SetText(const OUString &rStr) override
constexpr OUStringLiteral MATHML_XML
Definition: document.hxx:45
float u
SotClipboardFormatId
void SmMlIteratorFree(SmMlElement *pMlElementTree)
Definition: iterator.cxx:53
const ::avmedia::MediaItem * Execute(const SdrMarkView *pSdrView, SfxRequest const &rReq)
void GetState(const SdrMarkView *pSdrView, SfxItemSet &rSet)
SfxModelFlags
#define SFX_DECL_INTERFACE(nId)
#define SM_DLLPUBLIC
Definition: smdllapi.hxx:17
void SetFormat(LotusContext &rContext, SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt8 nFormat, sal_uInt8 nSt)
signed char sal_Int8
void SetPrinter(IDocumentDeviceAccess *, SfxPrinter const *, bool bWeb)