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