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