xref: /trunk/main/starmath/inc/view.hxx (revision f6a9d5ca)
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 VIEW_HXX
24 #define VIEW_HXX
25 
26 #include <sfx2/dockwin.hxx>
27 #include <sfx2/viewsh.hxx>
28 #include <svtools/scrwin.hxx>
29 #include <sfx2/ctrlitem.hxx>
30 #include <sfx2/shell.hxx>
31 #include <sfx2/viewfac.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <svtools/colorcfg.hxx>
34 #include "edit.hxx"
35 #include "node.hxx"
36 #include "accessibility.hxx"
37 
38 class Menu;
39 class DataChangedEvent;
40 class SmClipboardChangeListener;
41 class SmDocShell;
42 class SmViewShell;
43 class SmPrintUIOptions;
44 
45 /**************************************************************************/
46 
47 class SmGraphicWindow : public ScrollableWindow
48 {
49 	Point			aFormulaDrawPos;
50 	Rectangle		aCursorRect;
51 
52     ::com::sun::star::uno::Reference<
53         ::com::sun::star::accessibility::XAccessible >  xAccessible;
54     SmGraphicAccessible *                                       pAccessible;
55 
56     SmViewShell    *pViewShell;
57 	sal_uInt16			nZoom;
58 	short			nModifyCount;
59 	sal_Bool			bIsCursorVisible;
60 
61 protected:
SetFormulaDrawPos(const Point & rPos)62 	void		SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; }
SetIsCursorVisible(sal_Bool bVis)63 	void		SetIsCursorVisible(sal_Bool bVis) { bIsCursorVisible = bVis; }
64     using   Window::SetCursor;
65     void        SetCursor(const SmNode *pNode);
66 	void 		SetCursor(const Rectangle &rRect);
67 
68 	virtual void DataChanged( const DataChangedEvent& );
69 	virtual void Paint(const Rectangle&);
70 	virtual void KeyInput(const KeyEvent& rKEvt);
71 	virtual void Command(const CommandEvent& rCEvt);
72 	virtual void StateChanged( StateChangedType eChanged );
73 	DECL_LINK(MenuSelectHdl, Menu *);
74 
75 public:
76 	SmGraphicWindow(SmViewShell* pShell);
77     ~SmGraphicWindow();
78 
79     // Window
80     virtual void    MouseButtonDown(const MouseEvent &rMEvt);
81     virtual void    GetFocus();
82     virtual void    LoseFocus();
83 
GetView()84     SmViewShell *   GetView()   { return pViewShell; }
85 
86     using   Window::SetZoom;
87 	void   SetZoom(sal_uInt16 Factor);
88     using   Window::GetZoom;
GetZoom() const89 	sal_uInt16 GetZoom() const { return nZoom; }
90 
GetFormulaDrawPos() const91     const Point &   GetFormulaDrawPos() const { return aFormulaDrawPos; }
92 
93     void ZoomToFitInWindow();
94     using   ScrollableWindow::SetTotalSize;
95 	void SetTotalSize();
96 
IsCursorVisible() const97 	sal_Bool IsCursorVisible() const { return bIsCursorVisible; }
98 	void ShowCursor(sal_Bool bShow);
99 	const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
100 
101     void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg );
102 
103     // for Accessibility
104     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
105 
106     using   Window::GetAccessible;
GetAccessible_Impl()107     SmGraphicAccessible *   GetAccessible_Impl()  { return pAccessible; }
108 };
109 
110 /**************************************************************************/
111 
112 class SmGraphicController: public SfxControllerItem
113 {
114 protected:
115 	SmGraphicWindow &rGraphic;
116 public:
117 	SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
118 	virtual void StateChanged(sal_uInt16			 nSID,
119 							  SfxItemState		 eState,
120 							  const SfxPoolItem* pState);
121 };
122 
123 /**************************************************************************/
124 
125 class SmEditController: public SfxControllerItem
126 {
127 protected:
128 	SmEditWindow &rEdit;
129 
130 public:
131 	SmEditController(SmEditWindow &, sal_uInt16, SfxBindings  & );
132 #if OSL_DEBUG_LEVEL > 1
133     virtual ~SmEditController();
134 #endif
135 
136 	virtual void StateChanged(sal_uInt16			 nSID,
137 							  SfxItemState		 eState,
138 							  const SfxPoolItem* pState);
139 };
140 
141 /**************************************************************************/
142 
143 class SmCmdBoxWindow : public SfxDockingWindow
144 {
145 	SmEditWindow		aEdit;
146 	SmEditController	aController;
147     sal_Bool                bExiting;
148 
149     Timer               aInitialFocusTimer;
150 
151     DECL_LINK(InitialFocusTimerHdl, Timer *);
152 
153 protected :
154 
155     // Window
156     virtual void    GetFocus();
157 	virtual void Resize();
158 	virtual void Paint(const Rectangle& rRect);
159     virtual void StateChanged( StateChangedType nStateChange );
160 
161     virtual Size CalcDockingSize(SfxChildAlignment eAlign);
162 	virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
163 											 SfxChildAlignment eWish);
164 
165 	virtual void	ToggleFloatingMode();
166 
167 public:
168 	SmCmdBoxWindow(SfxBindings	  *pBindings,
169 				   SfxChildWindow *pChildWindow,
170 				   Window		  *pParent);
171 
172 	virtual ~SmCmdBoxWindow ();
173 
174 	void AdjustPosition();
175 
GetEditWindow()176 	SmEditWindow *GetEditWindow() { return (&aEdit); }
177     SmViewShell  *GetView();
178 };
179 
180 /**************************************************************************/
181 
182 class SmCmdBoxWrapper : public SfxChildWindow
183 {
184 	SFX_DECL_CHILDWINDOW(SmCmdBoxWrapper);
185 
186 protected:
187 	SmCmdBoxWrapper(Window			*pParentWindow,
188 					sal_uInt16			 nId,
189 					SfxBindings 	*pBindings,
190 					SfxChildWinInfo *pInfo);
191 
192 #if OSL_DEBUG_LEVEL > 1
193     virtual ~SmCmdBoxWrapper();
194 #endif
195 
196 public:
197 
GetEditWindow()198 	SmEditWindow *GetEditWindow()
199 	{
200 		return (((SmCmdBoxWindow *)pWindow)->GetEditWindow());
201 	}
202 
203 };
204 
205 /**************************************************************************/
206 
207 namespace sfx2 { class FileDialogHelper; }
208 struct SmViewShell_Impl;
209 
210 class SmViewShell: public SfxViewShell
211 {
212 	// for handling the PasteClipboardState
213 	friend class SmClipboardChangeListener;
214 
215 	SmGraphicWindow 	aGraphic;
216 	SmGraphicController aGraphicController;
217 	String				StatusText;
218 
219 	::com::sun::star::uno:: Reference <
220 			::com::sun::star::lang:: XEventListener > xClipEvtLstnr;
221 	SmClipboardChangeListener*	pClipEvtLstnr;
222     SmViewShell_Impl*   pImpl;
223 	sal_Bool				bPasteState;
224 
225     DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
226 	virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
227 
228 protected:
229 
230 	Size GetTextLineSize(OutputDevice& rDevice,
231 						 const String& rLine);
232 	Size GetTextSize(OutputDevice& rDevice,
233 					 const String& rText,
234 					 long		   MaxWidth);
235 	void DrawTextLine(OutputDevice& rDevice,
236 					  const Point&	rPosition,
237 					  const String& rLine);
238 	void DrawText(OutputDevice& rDevice,
239 				  const Point&	rPosition,
240 				  const String& rText,
241 				  sal_uInt16		MaxWidth);
242 
243     virtual sal_uInt16 Print(SfxProgress &rProgress, sal_Bool bIsAPI);
244 	virtual SfxPrinter *GetPrinter(sal_Bool bCreate = sal_False);
245 	virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
246                               sal_uInt16     nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false);
247 
248     sal_Bool        Insert( SfxMedium& rMedium );
249     sal_Bool        InsertFrom(SfxMedium &rMedium);
250 
251 	virtual SfxTabPage *CreatePrintOptionsPage(Window			*pParent,
252 											   const SfxItemSet &rOptions);
253 	virtual void Deactivate(sal_Bool IsMDIActivate);
254 	virtual void Activate(sal_Bool IsMDIActivate);
255 	virtual Size GetOptimalSizePixel() const;
256 	virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
257 	virtual void InnerResizePixel(const Point &rOfs, const Size  &rSize);
258 	virtual void OuterResizePixel(const Point &rOfs, const Size  &rSize);
259 	virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
260 	virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY );
261 
262 public:
263 	TYPEINFO();
264 
265     SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
266 	~SmViewShell();
267 
GetDoc()268 	SmDocShell * GetDoc()
269 	{
270 		return (SmDocShell *) GetViewFrame()->GetObjectShell();
271 	}
272 
273 	SmEditWindow * GetEditWindow();
GetGraphicWindow()274 		  SmGraphicWindow & GetGraphicWindow() 		 { return aGraphic; }
GetGraphicWindow() const275 	const SmGraphicWindow & GetGraphicWindow() const { return aGraphic; }
276 
277 	void		SetStatusText(const String& Text);
278 
279 	void		ShowError( const SmErrorDesc *pErrorDesc );
280 	void		NextError();
281 	void		PrevError();
282 
283     SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
284     SFX_DECL_VIEWFACTORY(SmViewShell);
285 
286 	virtual void Execute( SfxRequest& rReq );
287 	virtual void GetState(SfxItemSet &);
288 
289     void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
290             Rectangle aOutRect, Point aZeroPoint );
291 };
292 
293 #endif
294 
295