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