1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
25 #include <rtl/ustring.hxx>
26 #include <rtl/strbuf.hxx>
27 #include <sfx2/docfac.hxx>
28 #include <sfx2/objsh.hxx>
29 #include <sot/storage.hxx>
30 #include <svl/lstner.hxx>
31 #include <vcl/jobset.hxx>
32 #include <vcl/virdev.hxx>
33 #include <sax/fshelper.hxx>
34 #include <oox/core/filterbase.hxx>
35 #include <oox/mathml/import.hxx>
44 class SfxMenuBarManager
;
49 #define STAROFFICE_XML "StarOffice XML (Math)"
50 #define MATHML_XML "MathML XML (Math)"
52 /* Access to printer should happen through this class only
53 * ==========================================================================
55 * The printer can belong to the document or the OLE-Container. If the document
56 * is an OLE-Document the printer generally belongs to the container too.
57 * But the container maybe works with a different MapUnit than the server.
58 * Referring to the MapMode the printer will be accordingly adjusted in the
59 * constructor and restored in the destructor. This brings that this class
60 * is always allowed to exists only a short time (e.g. while painting).
61 * The control whether the printer is self-generated, gotten from the server
62 * or is NULL then, is taken by the DocShell in the method GetPrt(), for
63 * which the access is friend of the DocShell too.
74 OutputDevice
* pRefDev
;
76 SmPrinterAccess( SmDocShell
&rDocShell
);
78 Printer
* GetPrinter() { return pPrinter
; }
79 OutputDevice
* GetRefDev() { return pRefDev
; }
85 void SetEditEngineDefaultFonts(SfxItemPool
&rEditEngineItemPool
);
89 class SmDocShell
: public SfxObjectShell
, public SfxListener
91 friend class SmPrinterAccess
;
93 friend class SmCursor
;
97 SmParser aInterpreter
;
100 SfxItemPool
*pEditEngineItemPool
;
101 EditEngine
*pEditEngine
;
102 SfxPrinter
*pPrinter
; //q.v. comment to SmPrinter Access!
103 Printer
*pTmpPrinter
; //ditto
104 sal_uInt16 nModifyCount
;
105 bool bIsFormulaArranged
;
107 std::set
< OUString
> aUsedSymbols
; // to export used symbols only when saving
111 virtual void SFX_NOTIFY(SfxBroadcaster
& rBC
, const TypeId
& rBCType
,
112 const SfxHint
& rHint
, const TypeId
& rHintType
) SAL_OVERRIDE
;
114 bool WriteAsMathType3( SfxMedium
& );
116 virtual void Draw(OutputDevice
*pDevice
,
117 const JobSetup
& rSetup
,
118 sal_uInt16 nAspect
= ASPECT_CONTENT
) SAL_OVERRIDE
;
120 virtual void FillClass(SvGlobalName
* pClassName
,
123 OUString
* pFullTypeName
,
124 OUString
* pShortTypeName
,
125 sal_Int32 nFileFormat
,
126 bool bTemplate
= false ) const SAL_OVERRIDE
;
128 virtual bool SetData( const OUString
& rData
);
129 virtual sal_uLong
GetMiscStatus() const SAL_OVERRIDE
;
130 virtual void OnDocumentPrinterChanged( Printer
* ) SAL_OVERRIDE
;
131 virtual bool InitNew( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
) SAL_OVERRIDE
;
132 virtual bool Load( SfxMedium
& rMedium
) SAL_OVERRIDE
;
133 void ImplSave( SvStorageStreamRef xStrm
);
134 virtual bool Save() SAL_OVERRIDE
;
135 virtual bool SaveAs( SfxMedium
& rMedium
) SAL_OVERRIDE
;
136 virtual bool ConvertTo( SfxMedium
&rMedium
) SAL_OVERRIDE
;
137 virtual bool SaveCompleted( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XStorage
>& xStorage
) SAL_OVERRIDE
;
140 OutputDevice
* GetRefDev();
142 bool IsFormulaArranged() const { return bIsFormulaArranged
; }
143 void SetFormulaArranged(bool bVal
) { bIsFormulaArranged
= bVal
; }
145 virtual bool ConvertFrom(SfxMedium
&rMedium
) SAL_OVERRIDE
;
147 /** Called whenever the formula is changed
148 * Deletes the current cursor
150 void InvalidateCursor();
152 bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer
, oox::core::OoxmlVersion version
);
153 void writeFormulaRtf(OStringBuffer
& rBuffer
, rtl_TextEncoding nEncoding
);
154 void readFormulaOoxml( oox::formulaimport::XmlStream
& stream
);
158 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START
+1)
160 using SotObject::GetInterface
;
161 SFX_DECL_OBJECTFACTORY();
164 /// SfxInterface initializer.
165 static void InitInterface_Impl();
168 SmDocShell( const sal_uInt64 i_nSfxCreationFlags
);
169 virtual ~SmDocShell();
174 void ArrangeFormula();
176 //Access for the View. This access is not for the OLE-case!
177 //and for the communication with the SFX!
178 //All internal printer uses should work with the SmPrinterAccess only
179 bool HasPrinter() { return 0 != pPrinter
; }
180 SfxPrinter
*GetPrinter() { GetPrt(); return pPrinter
; }
181 void SetPrinter( SfxPrinter
* );
183 const OUString
GetComment() const;
185 // to replace chars that can not be saved with the document...
186 bool ReplaceBadChars();
189 void SetText(const OUString
& rBuffer
);
190 OUString
GetText() { return (aText
); }
191 void SetFormat(SmFormat
& rFormat
);
192 const SmFormat
& GetFormat() { return (aFormat
); }
195 SmParser
& GetParser() { return aInterpreter
; }
196 const SmNode
* GetFormulaTree() const { return pTree
; }
197 void SetFormulaTree(SmNode
*&rTree
) { pTree
= rTree
; }
199 const std::set
< OUString
> & GetUsedSymbols() const { return aUsedSymbols
; }
201 OUString
GetAccessibleText();
203 EditEngine
& GetEditEngine();
204 SfxItemPool
& GetEditEngineItemPool();
206 void DrawFormula(OutputDevice
&rDev
, Point
&rPosition
, bool bDrawSelection
= false);
211 virtual ::svl::IUndoManager
*GetUndoManager () SAL_OVERRIDE
;
213 virtual SfxItemPool
& GetPool() const;
215 void Execute( SfxRequest
& rReq
);
216 void GetState(SfxItemSet
&);
218 virtual void SetVisArea (const Rectangle
& rVisArea
) SAL_OVERRIDE
;
219 virtual void SetModified(bool bModified
) SAL_OVERRIDE
;
221 /** Get a cursor for modifying this document
222 * @remarks Don't store this reference, a new cursor may be made...
224 SmCursor
& GetCursor();
225 /** True, if cursor have previously been requested and thus
226 * has some sort of position.
228 bool HasCursor() { return pCursor
!= NULL
; }
233 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */