Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef VIEW_HXX
20 : #define VIEW_HXX
21 :
22 : #include <sfx2/dockwin.hxx>
23 : #include <sfx2/viewsh.hxx>
24 : #include <svtools/scrwin.hxx>
25 : #include <sfx2/ctrlitem.hxx>
26 : #include <sfx2/shell.hxx>
27 : #include <sfx2/viewfac.hxx>
28 : #include <sfx2/viewfrm.hxx>
29 : #include <vcl/timer.hxx>
30 : #include <svtools/colorcfg.hxx>
31 : #include "edit.hxx"
32 : #include "node.hxx"
33 :
34 : class Menu;
35 : class DataChangedEvent;
36 : class SmClipboardChangeListener;
37 : class SmDocShell;
38 : class SmViewShell;
39 : class SmPrintUIOptions;
40 : class SmGraphicAccessible;
41 :
42 : /**************************************************************************/
43 :
44 : class SmGraphicWindow : public ScrollableWindow
45 : {
46 : Point aFormulaDrawPos;
47 :
48 : // old style editing pieces
49 : Rectangle aCursorRect;
50 : bool bIsCursorVisible;
51 : bool bIsLineVisible;
52 : AutoTimer aCaretBlinkTimer;
53 : public:
54 31 : bool IsCursorVisible() const { return bIsCursorVisible; }
55 : void ShowCursor(bool bShow);
56 0 : bool IsLineVisible() const { return bIsLineVisible; }
57 : void ShowLine(bool bShow);
58 : const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
59 : protected:
60 41 : void SetIsCursorVisible(bool bVis) { bIsCursorVisible = bVis; }
61 : using Window::SetCursor;
62 : void SetCursor(const SmNode *pNode);
63 : void SetCursor(const Rectangle &rRect);
64 : bool IsInlineEditEnabled() const;
65 :
66 : private:
67 : ::com::sun::star::uno::Reference<
68 : ::com::sun::star::accessibility::XAccessible > xAccessible;
69 : SmGraphicAccessible * pAccessible;
70 :
71 : SmViewShell *pViewShell;
72 : sal_uInt16 nZoom;
73 :
74 : protected:
75 17 : void SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; }
76 :
77 : virtual void DataChanged( const DataChangedEvent& );
78 : virtual void Paint(const Rectangle&);
79 : virtual void KeyInput(const KeyEvent& rKEvt);
80 : virtual void Command(const CommandEvent& rCEvt);
81 : virtual void StateChanged( StateChangedType eChanged );
82 : DECL_LINK(MenuSelectHdl, Menu *);
83 :
84 : private:
85 : void RepaintViewShellDoc();
86 : DECL_LINK(CaretBlinkTimerHdl, void *);
87 : void CaretBlinkInit();
88 : void CaretBlinkStart();
89 : void CaretBlinkStop();
90 : public:
91 : SmGraphicWindow(SmViewShell* pShell);
92 : ~SmGraphicWindow();
93 :
94 : // Window
95 : virtual void MouseButtonDown(const MouseEvent &rMEvt);
96 : virtual void MouseMove(const MouseEvent &rMEvt);
97 : virtual void GetFocus();
98 : virtual void LoseFocus();
99 :
100 11 : SmViewShell * GetView() { return pViewShell; }
101 :
102 : using Window::SetZoom;
103 : void SetZoom(sal_uInt16 Factor);
104 : using Window::GetZoom;
105 78 : sal_uInt16 GetZoom() const { return nZoom; }
106 :
107 7 : const Point & GetFormulaDrawPos() const { return aFormulaDrawPos; }
108 :
109 : void ZoomToFitInWindow();
110 : using ScrollableWindow::SetTotalSize;
111 : void SetTotalSize();
112 :
113 : void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg );
114 :
115 : // for Accessibility
116 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
117 :
118 : using Window::GetAccessible;
119 6 : SmGraphicAccessible * GetAccessible_Impl() { return pAccessible; }
120 : };
121 :
122 : /**************************************************************************/
123 :
124 17 : class SmGraphicController: public SfxControllerItem
125 : {
126 : protected:
127 : SmGraphicWindow &rGraphic;
128 : public:
129 : SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
130 : virtual void StateChanged(sal_uInt16 nSID,
131 : SfxItemState eState,
132 : const SfxPoolItem* pState);
133 : };
134 :
135 : /**************************************************************************/
136 :
137 21 : class SmEditController: public SfxControllerItem
138 : {
139 : protected:
140 : SmEditWindow &rEdit;
141 :
142 : public:
143 : SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
144 : #if OSL_DEBUG_LEVEL > 1
145 : virtual ~SmEditController();
146 : #endif
147 :
148 : virtual void StateChanged(sal_uInt16 nSID,
149 : SfxItemState eState,
150 : const SfxPoolItem* pState);
151 : };
152 :
153 : /**************************************************************************/
154 :
155 : class SmCmdBoxWindow : public SfxDockingWindow
156 : {
157 : SmEditWindow aEdit;
158 : SmEditController aController;
159 : bool bExiting;
160 :
161 : Timer aInitialFocusTimer;
162 :
163 : DECL_LINK(InitialFocusTimerHdl, Timer *);
164 :
165 : protected :
166 :
167 : // Window
168 : virtual void GetFocus();
169 : virtual void Resize();
170 : virtual void Paint(const Rectangle& rRect);
171 : virtual void StateChanged( StateChangedType nStateChange );
172 :
173 : virtual Size CalcDockingSize(SfxChildAlignment eAlign);
174 : virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
175 : SfxChildAlignment eWish);
176 :
177 : virtual void ToggleFloatingMode();
178 :
179 : public:
180 : SmCmdBoxWindow(SfxBindings *pBindings,
181 : SfxChildWindow *pChildWindow,
182 : Window *pParent);
183 :
184 : virtual ~SmCmdBoxWindow ();
185 :
186 : void AdjustPosition();
187 :
188 168 : SmEditWindow *GetEditWindow() { return (&aEdit); }
189 : SmViewShell *GetView();
190 : };
191 :
192 : /**************************************************************************/
193 :
194 34 : class SmCmdBoxWrapper : public SfxChildWindow
195 : {
196 : SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
197 :
198 : protected:
199 : SmCmdBoxWrapper(Window *pParentWindow,
200 : sal_uInt16 nId,
201 : SfxBindings *pBindings,
202 : SfxChildWinInfo *pInfo);
203 :
204 : #if OSL_DEBUG_LEVEL > 1
205 : virtual ~SmCmdBoxWrapper();
206 : #endif
207 :
208 : public:
209 :
210 143 : SmEditWindow *GetEditWindow()
211 : {
212 143 : return (((SmCmdBoxWindow *)pWindow)->GetEditWindow());
213 : }
214 :
215 : };
216 :
217 : /**************************************************************************/
218 :
219 : namespace sfx2 { class FileDialogHelper; }
220 : struct SmViewShell_Impl;
221 :
222 : class SmViewShell: public SfxViewShell
223 : {
224 : // for handling the PasteClipboardState
225 : friend class SmClipboardChangeListener;
226 :
227 : SmViewShell_Impl* pImpl;
228 :
229 : SmGraphicWindow aGraphic;
230 : SmGraphicController aGraphicController;
231 : OUString aStatusText;
232 :
233 : bool bPasteState;
234 :
235 : DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
236 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
237 :
238 : /** Used to determine whether insertions using SID_INSERTSYMBOL and SID_INSERTCOMMAND
239 : * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
240 : * visual editor was last to have focus.
241 : */
242 : bool bInsertIntoEditWindow;
243 : protected:
244 :
245 : Size GetTextLineSize(OutputDevice& rDevice,
246 : const String& rLine);
247 : Size GetTextSize(OutputDevice& rDevice,
248 : const String& rText,
249 : long MaxWidth);
250 : void DrawTextLine(OutputDevice& rDevice,
251 : const Point& rPosition,
252 : const String& rLine);
253 : void DrawText(OutputDevice& rDevice,
254 : const Point& rPosition,
255 : const String& rText,
256 : sal_uInt16 MaxWidth);
257 :
258 : virtual sal_uInt16 Print(SfxProgress &rProgress, sal_Bool bIsAPI);
259 : virtual SfxPrinter *GetPrinter(sal_Bool bCreate = sal_False);
260 : virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
261 : sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false);
262 :
263 : bool Insert( SfxMedium& rMedium );
264 : bool InsertFrom(SfxMedium &rMedium);
265 :
266 : virtual bool HasPrintOptionsPage() const;
267 : virtual SfxTabPage *CreatePrintOptionsPage(Window *pParent,
268 : const SfxItemSet &rOptions);
269 : virtual void Deactivate(sal_Bool IsMDIActivate);
270 : virtual void Activate(sal_Bool IsMDIActivate);
271 : virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
272 : virtual void InnerResizePixel(const Point &rOfs, const Size &rSize);
273 : virtual void OuterResizePixel(const Point &rOfs, const Size &rSize);
274 : virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
275 : virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY );
276 :
277 : public:
278 : TYPEINFO();
279 :
280 : SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
281 : ~SmViewShell();
282 :
283 229 : SmDocShell * GetDoc()
284 : {
285 229 : return (SmDocShell *) GetViewFrame()->GetObjectShell();
286 : }
287 :
288 : SmEditWindow * GetEditWindow();
289 53 : SmGraphicWindow & GetGraphicWindow() { return aGraphic; }
290 0 : const SmGraphicWindow & GetGraphicWindow() const { return aGraphic; }
291 :
292 : void SetStatusText(const OUString& rText);
293 :
294 : void ShowError( const SmErrorDesc *pErrorDesc );
295 : void NextError();
296 : void PrevError();
297 :
298 7 : SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
299 7 : SFX_DECL_VIEWFACTORY(SmViewShell);
300 :
301 : virtual void Execute( SfxRequest& rReq );
302 : virtual void GetState(SfxItemSet &);
303 :
304 : void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
305 : Rectangle aOutRect, Point aZeroPoint );
306 :
307 : /** Set bInsertIntoEditWindow so we know where to insert
308 : *
309 : * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
310 : * so that when text is inserted from catalog or elsewhere we know whether to
311 : * insert for the visual editor, or the text editor.
312 : */
313 0 : void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast = true){
314 0 : bInsertIntoEditWindow = bEditWindowHadFocusLast;
315 0 : }
316 : bool IsInlineEditEnabled() const;
317 : };
318 :
319 : #endif
320 :
321 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|