Branch data Line data Source code
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 DOCUMENT_HXX
21 : : #define DOCUMENT_HXX
22 : :
23 : : #define SMDLL 1
24 : :
25 : : #include <rtl/ustring.hxx>
26 : : #include <rtl/strbuf.hxx>
27 : : #include <sfx2/docfac.hxx>
28 : : #include <sfx2/objsh.hxx>
29 : : #include <sot/sotref.hxx>
30 : : #include <sot/storage.hxx>
31 : : #include <svl/lstner.hxx>
32 : : #include <vcl/jobset.hxx>
33 : : #include <vcl/virdev.hxx>
34 : : #include <sax/fshelper.hxx>
35 : : #include <oox/core/filterbase.hxx>
36 : : #include <oox/mathml/import.hxx>
37 : :
38 : : #include <set>
39 : :
40 : : #include "format.hxx"
41 : : #include "parse.hxx"
42 : : #include "smmod.hxx"
43 : :
44 : : class SmNode;
45 : : class SfxMenuBarManager;
46 : : class SfxPrinter;
47 : : class Printer;
48 : : class SmCursor;
49 : :
50 : : #define STAROFFICE_XML "StarOffice XML (Math)"
51 : : #define MATHML_XML "MathML XML (Math)"
52 : :
53 : : /* Access to printer should happen through this class only
54 : : * ==========================================================================
55 : : *
56 : : * The printer can belong to the document or the OLE-Container. If the document
57 : : * is an OLE-Document the printer generally belongs to the container too.
58 : : * But the container mayby works with a different MapUnit than the server.
59 : : * Referring to the MapMode the printer will be accordingly adjusted in the
60 : : * constructor and restored in the destructor. This brings that this class
61 : : * is always allowed to exists only a short time (e.g. while painting).
62 : : * The control whether the printer is self-generated, gotten from the server
63 : : * or is NULL then, is taken by the DocShell in the method GetPrt(), for
64 : : * which the access is friend of the DocShell too.
65 : : */
66 : :
67 : : class SmDocShell;
68 : : class EditEngine;
69 : :
70 : : ////////////////////////////////////////////////////////////
71 : :
72 : : class SmPrinterAccess
73 : : {
74 : : Printer* pPrinter;
75 : : OutputDevice* pRefDev;
76 : : public:
77 : : SmPrinterAccess( SmDocShell &rDocShell );
78 : : ~SmPrinterAccess();
79 : 0 : Printer* GetPrinter() { return pPrinter; }
80 : 1436 : OutputDevice* GetRefDev() { return pRefDev; }
81 : : };
82 : :
83 : :
84 : : ////////////////////////////////////////////////////////////
85 : :
86 : : void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
87 : :
88 : : ////////////////////////////////////////////////////////////
89 : :
90 : : class SmDocShell : public SfxObjectShell, public SfxListener
91 : : {
92 : : friend class SmPrinterAccess;
93 : : friend class SmModel;
94 : : friend class SmCursor;
95 : :
96 : : String aText;
97 : : SmFormat aFormat;
98 : : SmParser aInterpreter;
99 : : String aAccText;
100 : : SmNode *pTree;
101 : : SfxMenuBarManager *pMenuMgr;
102 : : SfxItemPool *pEditEngineItemPool;
103 : : EditEngine *pEditEngine;
104 : : SfxPrinter *pPrinter; //q.v. comment to SmPrinter Access!
105 : : Printer *pTmpPrinter; //ditto
106 : : long nLeftBorder,
107 : : nRightBorder,
108 : : nTopBorder,
109 : : nBottomBorder;
110 : : sal_uInt16 nModifyCount;
111 : : bool bIsFormulaArranged;
112 : : SmCursor *pCursor;
113 : : std::set< rtl::OUString > aUsedSymbols; // to export used symbols only when saving
114 : :
115 : :
116 : :
117 : : virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
118 : : const SfxHint& rHint, const TypeId& rHintType);
119 : :
120 : : bool WriteAsMathType3( SfxMedium& );
121 : :
122 : : virtual void Draw(OutputDevice *pDevice,
123 : : const JobSetup & rSetup,
124 : : sal_uInt16 nAspect = ASPECT_CONTENT);
125 : :
126 : : virtual void FillClass(SvGlobalName* pClassName,
127 : : sal_uInt32* pFormat,
128 : : String* pAppName,
129 : : String* pFullTypeName,
130 : : String* pShortTypeName,
131 : : sal_Int32 nFileFormat,
132 : : sal_Bool bTemplate = sal_False ) const;
133 : :
134 : : virtual sal_Bool SetData( const String& rData );
135 : : virtual sal_uLong GetMiscStatus() const;
136 : : virtual void OnDocumentPrinterChanged( Printer * );
137 : : virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
138 : : virtual sal_Bool Load( SfxMedium& rMedium );
139 : : void ImplSave( SvStorageStreamRef xStrm );
140 : : virtual sal_Bool Save();
141 : : virtual sal_Bool SaveAs( SfxMedium& rMedium );
142 : : virtual sal_Bool ConvertTo( SfxMedium &rMedium );
143 : : virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
144 : :
145 : : Printer *GetPrt();
146 : : OutputDevice* GetRefDev();
147 : :
148 : 12077 : bool IsFormulaArranged() const { return bIsFormulaArranged; }
149 : 5026 : void SetFormulaArranged(bool bVal) { bIsFormulaArranged = bVal; }
150 : :
151 : : virtual sal_Bool ConvertFrom(SfxMedium &rMedium);
152 : :
153 : : /** Called whenever the formula is changed
154 : : * Deletes the current cursor
155 : : */
156 : : void InvalidateCursor();
157 : :
158 : : bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version );
159 : : void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
160 : : void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
161 : :
162 : : public:
163 : : TYPEINFO();
164 : 10 : SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
165 : : using SotObject::GetInterface;
166 : 13817 : SFX_DECL_OBJECTFACTORY();
167 : :
168 : : SmDocShell( const sal_uInt64 i_nSfxCreationFlags );
169 : : virtual ~SmDocShell();
170 : :
171 : : void LoadSymbols();
172 : : void SaveSymbols();
173 : :
174 : : void ArrangeFormula();
175 : :
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 : 94 : bool HasPrinter() { return 0 != pPrinter; }
180 : 1798 : SfxPrinter *GetPrinter() { GetPrt(); return pPrinter; }
181 : : void SetPrinter( SfxPrinter * );
182 : :
183 : : const String GetComment() const;
184 : :
185 : : // to replace chars that can not be saved with the document...
186 : : sal_Bool ReplaceBadChars();
187 : :
188 : : void UpdateText();
189 : : void SetText(const String& rBuffer);
190 : 1110 : String& GetText() { return (aText); }
191 : : void SetFormat(SmFormat& rFormat);
192 : 53963 : const SmFormat& GetFormat() { return (aFormat); }
193 : :
194 : : void Parse();
195 : 852 : SmParser & GetParser() { return aInterpreter; }
196 : 906 : const SmNode * GetFormulaTree() const { return pTree; }
197 : 0 : void SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
198 : :
199 : 1704 : const std::set< rtl::OUString > & GetUsedSymbols() const { return aUsedSymbols; }
200 : :
201 : : String GetAccessibleText();
202 : :
203 : : EditEngine & GetEditEngine();
204 : : SfxItemPool & GetEditEngineItemPool();
205 : :
206 : : void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
207 : : Size GetSize();
208 : :
209 : : void Repaint();
210 : :
211 : : virtual ::svl::IUndoManager *GetUndoManager ();
212 : :
213 : : virtual SfxItemPool& GetPool() const;
214 : :
215 : : void Execute( SfxRequest& rReq );
216 : : void GetState(SfxItemSet &);
217 : :
218 : : virtual void SetVisArea (const Rectangle & rVisArea);
219 : : virtual void SetModified(sal_Bool bModified);
220 : :
221 : : /** Get a cursor for modifying this document
222 : : * @remarks Don't store this reference, a new cursor may be made...
223 : : */
224 : : SmCursor& GetCursor();
225 : : /** True, if cursor have previously been requested and thus
226 : : * has some sort of position.
227 : : */
228 : 0 : bool HasCursor() { return pCursor != NULL; }
229 : : };
230 : :
231 : : #endif
232 : :
233 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|