bump product version to 5.0.4.1
[LibreOffice.git] / starmath / inc / document.hxx
blob5531a4c214279d7c84809851ea1861d8f03b3f50
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 #ifndef INCLUDED_STARMATH_INC_DOCUMENT_HXX
21 #define INCLUDED_STARMATH_INC_DOCUMENT_HXX
23 #include <rtl/ustring.hxx>
24 #include <rtl/strbuf.hxx>
25 #include <sfx2/docfac.hxx>
26 #include <sfx2/objsh.hxx>
27 #include <sot/storage.hxx>
28 #include <svl/lstner.hxx>
29 #include <vcl/jobset.hxx>
30 #include <vcl/virdev.hxx>
31 #include <sax/fshelper.hxx>
32 #include <oox/core/filterbase.hxx>
33 #include <oox/mathml/import.hxx>
35 #include <set>
37 #include "format.hxx"
38 #include "parse.hxx"
39 #include "smmod.hxx"
40 #include "smdllapi.hxx"
42 class SmNode;
43 class SfxMenuBarManager;
44 class SfxPrinter;
45 class Printer;
46 class SmCursor;
48 #define STAROFFICE_XML "StarOffice XML (Math)"
49 #define MATHML_XML "MathML XML (Math)"
51 /* Access to printer should happen through this class only
52 * ==========================================================================
54 * The printer can belong to the document or the OLE-Container. If the document
55 * is an OLE-Document the printer generally belongs to the container too.
56 * But the container maybe works with a different MapUnit than the server.
57 * Referring to the MapMode the printer will be accordingly adjusted in the
58 * constructor and restored in the destructor. This brings that this class
59 * is always allowed to exists only a short time (e.g. while painting).
60 * The control whether the printer is self-generated, gotten from the server
61 * or is NULL then, is taken by the DocShell in the method GetPrt(), for
62 * which the access is friend of the DocShell too.
65 class SmDocShell;
66 class EditEngine;
70 class SmPrinterAccess
72 VclPtr<Printer> pPrinter;
73 VclPtr<OutputDevice> pRefDev;
74 public:
75 SmPrinterAccess( SmDocShell &rDocShell );
76 ~SmPrinterAccess();
77 Printer* GetPrinter() { return pPrinter.get(); }
78 OutputDevice* GetRefDev() { return pRefDev.get(); }
84 void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
88 class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener
90 friend class SmPrinterAccess;
91 friend class SmModel;
92 friend class SmCursor;
94 OUString aText;
95 SmFormat aFormat;
96 SmParser aInterpreter;
97 OUString aAccText;
98 SmNode *pTree;
99 SfxItemPool *pEditEngineItemPool;
100 EditEngine *pEditEngine;
101 VclPtr<SfxPrinter> pPrinter; //q.v. comment to SmPrinter Access!
102 VclPtr<Printer> pTmpPrinter; //ditto
103 sal_uInt16 nModifyCount;
104 bool bIsFormulaArranged;
105 SmCursor *pCursor;
106 std::set< OUString > aUsedSymbols; // to export used symbols only when saving
110 virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
111 const SfxHint& rHint, const TypeId& rHintType) SAL_OVERRIDE;
113 bool WriteAsMathType3( SfxMedium& );
115 virtual void Draw(OutputDevice *pDevice,
116 const JobSetup & rSetup,
117 sal_uInt16 nAspect = ASPECT_CONTENT) SAL_OVERRIDE;
119 virtual void FillClass(SvGlobalName* pClassName,
120 SotClipboardFormatId* pFormat,
121 OUString* pAppName,
122 OUString* pFullTypeName,
123 OUString* pShortTypeName,
124 sal_Int32 nFileFormat,
125 bool bTemplate = false ) const SAL_OVERRIDE;
127 virtual sal_uLong GetMiscStatus() const SAL_OVERRIDE;
128 virtual void OnDocumentPrinterChanged( Printer * ) SAL_OVERRIDE;
129 virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
130 virtual bool Load( SfxMedium& rMedium ) SAL_OVERRIDE;
131 void ImplSave( tools::SvRef<SotStorageStream> xStrm );
132 virtual bool Save() SAL_OVERRIDE;
133 virtual bool SaveAs( SfxMedium& rMedium ) SAL_OVERRIDE;
134 virtual bool ConvertTo( SfxMedium &rMedium ) SAL_OVERRIDE;
135 virtual bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
137 Printer *GetPrt();
138 OutputDevice* GetRefDev();
140 bool IsFormulaArranged() const { return bIsFormulaArranged; }
141 void SetFormulaArranged(bool bVal) { bIsFormulaArranged = bVal; }
143 virtual bool ConvertFrom(SfxMedium &rMedium) SAL_OVERRIDE;
145 /** Called whenever the formula is changed
146 * Deletes the current cursor
148 void InvalidateCursor();
150 bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version );
151 void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
152 void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
154 public:
155 TYPEINFO_OVERRIDE();
156 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
158 SFX_DECL_OBJECTFACTORY();
160 private:
161 /// SfxInterface initializer.
162 static void InitInterface_Impl();
164 public:
165 SmDocShell( SfxModelFlags i_nSfxCreationFlags );
166 virtual ~SmDocShell();
168 static void LoadSymbols();
169 static void SaveSymbols();
171 void ArrangeFormula();
173 //Access for the View. This access is not for the OLE-case!
174 //and for the communication with the SFX!
175 //All internal printer uses should work with the SmPrinterAccess only
176 bool HasPrinter() { return pPrinter != nullptr; }
177 SfxPrinter *GetPrinter() { GetPrt(); return pPrinter; }
178 void SetPrinter( SfxPrinter * );
180 const OUString GetComment() const;
182 // to replace chars that can not be saved with the document...
183 bool ReplaceBadChars();
185 void UpdateText();
186 void SetText(const OUString& rBuffer);
187 OUString GetText() { return aText; }
188 void SetFormat(SmFormat& rFormat);
189 const SmFormat& GetFormat() { return aFormat; }
191 void Parse();
192 SmParser & GetParser() { return aInterpreter; }
193 const SmNode * GetFormulaTree() const { return pTree; }
194 void SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
196 const std::set< OUString > & GetUsedSymbols() const { return aUsedSymbols; }
198 OUString GetAccessibleText();
200 EditEngine & GetEditEngine();
201 SfxItemPool & GetEditEngineItemPool();
203 void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
204 Size GetSize();
206 void Repaint();
208 virtual ::svl::IUndoManager *GetUndoManager () SAL_OVERRIDE;
210 static SfxItemPool& GetPool();
212 void Execute( SfxRequest& rReq );
213 void GetState(SfxItemSet &);
215 virtual void SetVisArea (const Rectangle & rVisArea) SAL_OVERRIDE;
216 virtual void SetModified(bool bModified) SAL_OVERRIDE;
218 /** Get a cursor for modifying this document
219 * @remarks Don't store this reference, a new cursor may be made...
221 SmCursor& GetCursor();
222 /** True, if cursor have previously been requested and thus
223 * has some sort of position.
225 bool HasCursor() { return pCursor != NULL; }
228 #endif
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */