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/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>
36 :
37 : #include <set>
38 :
39 : #include "format.hxx"
40 : #include "parse.hxx"
41 : #include "smmod.hxx"
42 :
43 : class SmNode;
44 : class SfxMenuBarManager;
45 : class SfxPrinter;
46 : class Printer;
47 : class SmCursor;
48 :
49 : #define STAROFFICE_XML "StarOffice XML (Math)"
50 : #define MATHML_XML "MathML XML (Math)"
51 :
52 : /* Access to printer should happen through this class only
53 : * ==========================================================================
54 : *
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 mayby 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.
64 : */
65 :
66 : class SmDocShell;
67 : class EditEngine;
68 :
69 : ////////////////////////////////////////////////////////////
70 :
71 : class SmPrinterAccess
72 : {
73 : Printer* pPrinter;
74 : OutputDevice* pRefDev;
75 : public:
76 : SmPrinterAccess( SmDocShell &rDocShell );
77 : ~SmPrinterAccess();
78 0 : Printer* GetPrinter() { return pPrinter; }
79 453 : OutputDevice* GetRefDev() { return pRefDev; }
80 : };
81 :
82 :
83 : ////////////////////////////////////////////////////////////
84 :
85 : void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
86 :
87 : ////////////////////////////////////////////////////////////
88 :
89 : class SmDocShell : public SfxObjectShell, public SfxListener
90 : {
91 : friend class SmPrinterAccess;
92 : friend class SmModel;
93 : friend class SmCursor;
94 :
95 : String aText;
96 : SmFormat aFormat;
97 : SmParser aInterpreter;
98 : OUString aAccText;
99 : SmNode *pTree;
100 : SfxMenuBarManager *pMenuMgr;
101 : SfxItemPool *pEditEngineItemPool;
102 : EditEngine *pEditEngine;
103 : SfxPrinter *pPrinter; //q.v. comment to SmPrinter Access!
104 : Printer *pTmpPrinter; //ditto
105 : long nLeftBorder,
106 : nRightBorder,
107 : nTopBorder,
108 : nBottomBorder;
109 : sal_uInt16 nModifyCount;
110 : bool bIsFormulaArranged;
111 : SmCursor *pCursor;
112 : std::set< rtl::OUString > aUsedSymbols; // to export used symbols only when saving
113 :
114 :
115 :
116 : virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
117 : const SfxHint& rHint, const TypeId& rHintType);
118 :
119 : bool WriteAsMathType3( SfxMedium& );
120 :
121 : virtual void Draw(OutputDevice *pDevice,
122 : const JobSetup & rSetup,
123 : sal_uInt16 nAspect = ASPECT_CONTENT);
124 :
125 : virtual void FillClass(SvGlobalName* pClassName,
126 : sal_uInt32* pFormat,
127 : String* pAppName,
128 : String* pFullTypeName,
129 : String* pShortTypeName,
130 : sal_Int32 nFileFormat,
131 : sal_Bool bTemplate = sal_False ) const;
132 :
133 : virtual sal_Bool SetData( const String& rData );
134 : virtual sal_uLong GetMiscStatus() const;
135 : virtual void OnDocumentPrinterChanged( Printer * );
136 : virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
137 : virtual sal_Bool Load( SfxMedium& rMedium );
138 : void ImplSave( SvStorageStreamRef xStrm );
139 : virtual sal_Bool Save();
140 : virtual sal_Bool SaveAs( SfxMedium& rMedium );
141 : virtual sal_Bool ConvertTo( SfxMedium &rMedium );
142 : virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
143 :
144 : Printer *GetPrt();
145 : OutputDevice* GetRefDev();
146 :
147 3991 : bool IsFormulaArranged() const { return bIsFormulaArranged; }
148 1674 : void SetFormulaArranged(bool bVal) { bIsFormulaArranged = bVal; }
149 :
150 : virtual sal_Bool ConvertFrom(SfxMedium &rMedium);
151 :
152 : /** Called whenever the formula is changed
153 : * Deletes the current cursor
154 : */
155 : void InvalidateCursor();
156 :
157 : bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version );
158 : void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
159 : void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
160 :
161 : public:
162 : TYPEINFO();
163 4 : SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
164 : using SotObject::GetInterface;
165 2958 : SFX_DECL_OBJECTFACTORY();
166 :
167 : SmDocShell( const sal_uInt64 i_nSfxCreationFlags );
168 : virtual ~SmDocShell();
169 :
170 : void LoadSymbols();
171 : void SaveSymbols();
172 :
173 : void ArrangeFormula();
174 :
175 : //Access for the View. This access is not for the OLE-case!
176 : //and for the communication with the SFX!
177 : //All internal printer uses should work with the SmPrinterAccess only
178 0 : bool HasPrinter() { return 0 != pPrinter; }
179 572 : SfxPrinter *GetPrinter() { GetPrt(); return pPrinter; }
180 : void SetPrinter( SfxPrinter * );
181 :
182 : const String GetComment() const;
183 :
184 : // to replace chars that can not be saved with the document...
185 : sal_Bool ReplaceBadChars();
186 :
187 : void UpdateText();
188 : void SetText(const String& rBuffer);
189 426 : String& GetText() { return (aText); }
190 : void SetFormat(SmFormat& rFormat);
191 18553 : const SmFormat& GetFormat() { return (aFormat); }
192 :
193 : void Parse();
194 290 : SmParser & GetParser() { return aInterpreter; }
195 286 : const SmNode * GetFormulaTree() const { return pTree; }
196 0 : void SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
197 :
198 572 : const std::set< rtl::OUString > & GetUsedSymbols() const { return aUsedSymbols; }
199 :
200 : OUString GetAccessibleText();
201 :
202 : EditEngine & GetEditEngine();
203 : SfxItemPool & GetEditEngineItemPool();
204 :
205 : void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
206 : Size GetSize();
207 :
208 : void Repaint();
209 :
210 : virtual ::svl::IUndoManager *GetUndoManager ();
211 :
212 : virtual SfxItemPool& GetPool() const;
213 :
214 : void Execute( SfxRequest& rReq );
215 : void GetState(SfxItemSet &);
216 :
217 : virtual void SetVisArea (const Rectangle & rVisArea);
218 : virtual void SetModified(sal_Bool bModified);
219 :
220 : /** Get a cursor for modifying this document
221 : * @remarks Don't store this reference, a new cursor may be made...
222 : */
223 : SmCursor& GetCursor();
224 : /** True, if cursor have previously been requested and thus
225 : * has some sort of position.
226 : */
227 0 : bool HasCursor() { return pCursor != NULL; }
228 : };
229 :
230 : #endif
231 :
232 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|