xref: /trunk/main/starmath/inc/document.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef DOCUMENT_HXX
28 #define DOCUMENT_HXX
29 
30 #define SMDLL	1
31 
32 #include <rtl/ustring.hxx>
33 #include <sfx2/docfac.hxx>
34 #include <sfx2/objsh.hxx>
35 #include <sot/sotref.hxx>
36 #include <sot/storage.hxx>
37 #include <svl/lstner.hxx>
38 #include <vcl/jobset.hxx>
39 #include <vcl/virdev.hxx>
40 
41 #include <set>
42 
43 #include "format.hxx"
44 #include "parse.hxx"
45 #include "smmod.hxx"
46 
47 class SmNode;
48 class SfxMenuBarManager;
49 class SfxPrinter;
50 class Printer;
51 
52 #define HINT_DATACHANGED	1004
53 
54 #define SM30BIDENT	 ((sal_uLong)0x534D3033L)
55 #define SM30IDENT	 ((sal_uLong)0x30334d53L)
56 #define SM304AIDENT  ((sal_uLong)0x34303330L)
57 #define SM30VERSION  ((sal_uLong)0x00010000L)
58 #define SM50VERSION	 ((sal_uLong)0x00010001L)	//Unterschied zur SM30VERSION ist
59 											//der neue Border im Format.
60 
61 #define FRMIDENT	((sal_uLong)0x03031963L)
62 #define FRMVERSION	((sal_uLong)0x00010001L)
63 
64 #define STAROFFICE_XML	"StarOffice XML (Math)"
65 #define MATHML_XML		"MathML XML (Math)"
66 
67 /* Zugriff auf den Drucker sollte ausschliesslich ueber diese Klasse erfolgen
68  * ==========================================================================
69  *
70  * Der Drucker kann dem Dokument oder auch dem OLE-Container gehoeren. Wenn
71  * das Dokument also eine OLE-Dokument ist, so gehoert der Drucker auch
72  * grundsaetzlich dem Container. Der Container arbeitet aber eventuell mit
73  * einer anderen MapUnit als der Server. Der Drucker wird bezueglich des MapMode
74  * im Konstruktor entsprechend eingestellt und im Destruktor wieder restauriert.
75  * Das bedingt natuerlich, das diese Klasse immer nur kurze Zeit existieren darf
76  * (etwa waehrend des Paints).
77  * Die Kontrolle darueber ob der Drucker selbst angelegt, vom Server besorgt
78  * oder dann auch NULL ist, uebernimmt die DocShell in der Methode GetPrt(),
79  * fuer die der Access auch Friend der DocShell ist.
80 */
81 
82 class SmDocShell;
83 class EditEngine;
84 
85 ////////////////////////////////////////////////////////////
86 
87 class SmPrinterAccess
88 {
89     Printer* pPrinter;
90     OutputDevice* pRefDev;
91 public:
92 	SmPrinterAccess( SmDocShell &rDocShell );
93 	~SmPrinterAccess();
94     Printer* GetPrinter()  { return pPrinter; }
95     OutputDevice* GetRefDev()  { return pRefDev; }
96 };
97 
98 
99 ////////////////////////////////////////////////////////////
100 
101 void SetEditEngineDefaultFonts(
102         EditEngine &rEditEngine,
103         SfxItemPool &rEditEngineItemPool );
104 
105 ////////////////////////////////////////////////////////////
106 
107 class SmDocShell : public SfxObjectShell, public SfxListener
108 {
109 	friend class SmPrinterAccess;
110     friend class SmModel;
111 
112 	String				aText;
113 	SmFormat   			aFormat;
114 	SmParser	  		aInterpreter;
115     String              aAccText;
116 	SmNode		  	   *pTree;
117 	SfxMenuBarManager  *pMenuMgr;
118 	SfxItemPool		   *pEditEngineItemPool;
119 	EditEngine		   *pEditEngine;
120 	SfxPrinter		   *pPrinter;		//Siehe Kommentar zum SmPrinter Access!
121 	Printer			   *pTmpPrinter;	//ebenfalls
122 	long				nLeftBorder,
123 						nRightBorder,
124 						nTopBorder,
125 						nBottomBorder;
126 	sal_uInt16			nModifyCount;
127 	sal_Bool			bIsFormulaArranged;
128 
129     std::set< rtl::OUString >    aUsedSymbols;   // to export used symbols only when saving
130 
131 
132 
133 	virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
134 						const SfxHint& rHint, const TypeId& rHintType);
135 
136     sal_Bool        WriteAsMathType3( SfxMedium& );
137 
138 	virtual void		Draw(OutputDevice *pDevice,
139 							 const JobSetup & rSetup,
140 							 sal_uInt16 nAspect = ASPECT_CONTENT);
141 
142 	virtual void		FillClass(SvGlobalName* pClassName,
143 								  sal_uInt32*  pFormat,
144 								  String* pAppName,
145 								  String* pFullTypeName,
146                                   String* pShortTypeName,
147                                   sal_Int32 nFileFormat,
148                                   sal_Bool bTemplate = sal_False ) const;
149 
150 	virtual sal_Bool		SetData( const String& rData );
151 	virtual sal_uLong		GetMiscStatus() const;
152 	virtual void		OnDocumentPrinterChanged( Printer * );
153     virtual sal_Bool    InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
154     virtual sal_Bool        Load( SfxMedium& rMedium );
155 			void		ImplSave(  SvStorageStreamRef xStrm  );
156 	virtual sal_Bool		Save();
157     virtual sal_Bool        SaveAs( SfxMedium& rMedium );
158 	virtual sal_Bool        ConvertTo( SfxMedium &rMedium );
159     virtual sal_Bool        SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
160 
161     Printer             *GetPrt();
162     OutputDevice*       GetRefDev();
163 
164 	sal_Bool				IsFormulaArranged() const { return bIsFormulaArranged; }
165 	void				SetFormulaArranged(sal_Bool bVal) { bIsFormulaArranged = bVal; }
166 
167 	virtual sal_Bool		ConvertFrom(SfxMedium &rMedium);
168 
169 public:
170 	TYPEINFO();
171     SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
172     using SotObject::GetInterface;
173     SFX_DECL_OBJECTFACTORY();
174 
175 				SmDocShell( const sal_uInt64 i_nSfxCreationFlags );
176 	virtual		~SmDocShell();
177 
178 	void		LoadSymbols();
179 	void 		SaveSymbols();
180 
181     void        ArrangeFormula();
182 
183 	//Zugriff fuer die View. Diese Zugriffe sind nur fuer den nicht OLE-Fall!
184 	//und fuer die Kommunikation mit dem SFX!
185 	//Alle internen Verwendungen des Printers sollten ausschlieslich uber
186 	//den SmPrinterAccess funktionieren.
187 	sal_Bool		HasPrinter()	{ return 0 != pPrinter; }
188 	SfxPrinter *GetPrinter()	{ GetPrt(); return pPrinter; }
189 	void	    SetPrinter( SfxPrinter * );
190 
191 	const String GetComment() const;
192 
193     // to replace chars that can not be saved with the document...
194     sal_Bool    ReplaceBadChars();
195 
196     void        UpdateText();
197 	void		SetText(const String& rBuffer);
198 	String& 	GetText() { return (aText); }
199 	void		SetFormat(SmFormat& rFormat);
200     const SmFormat&  GetFormat() { return (aFormat); }
201 
202 	void			Parse();
203 	SmParser &		GetParser() { return aInterpreter; }
204 	const SmNode *	GetFormulaTree() const 	{ return pTree; }
205 	void 			SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
206 
207     const std::set< rtl::OUString > &    GetUsedSymbols() const  { return aUsedSymbols; }
208 
209     String          GetAccessibleText();
210 
211 	EditEngine & 	GetEditEngine();
212 	SfxItemPool &	GetEditEngineItemPool();
213 
214 	void		Draw(OutputDevice &rDev, Point &rPosition);
215 	Size		GetSize();
216 
217     void        Repaint();
218 
219 	virtual 	::svl::IUndoManager *GetUndoManager ();
220 
221     virtual     SfxItemPool& GetPool() const;
222 
223 	void		Execute( SfxRequest& rReq );
224 	void		GetState(SfxItemSet &);
225 
226 	virtual void SetVisArea (const Rectangle & rVisArea);
227 	virtual void SetModified(sal_Bool bModified);
228 };
229 
230 
231 #endif
232 
233