Branch data 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 : 69 : 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 : 93 : 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 : : short nModifyCount;
74 : :
75 : : protected:
76 : 39 : void SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; }
77 : :
78 : : virtual void DataChanged( const DataChangedEvent& );
79 : : virtual void Paint(const Rectangle&);
80 : : virtual void KeyInput(const KeyEvent& rKEvt);
81 : : virtual void Command(const CommandEvent& rCEvt);
82 : : virtual void StateChanged( StateChangedType eChanged );
83 : : DECL_LINK(MenuSelectHdl, Menu *);
84 : :
85 : : private:
86 : : void RepaintViewShellDoc();
87 : : DECL_LINK(CaretBlinkTimerHdl, void *);
88 : : void CaretBlinkInit();
89 : : void CaretBlinkStart();
90 : : void CaretBlinkStop();
91 : : public:
92 : : SmGraphicWindow(SmViewShell* pShell);
93 : : ~SmGraphicWindow();
94 : :
95 : : // Window
96 : : virtual void MouseButtonDown(const MouseEvent &rMEvt);
97 : : virtual void MouseMove(const MouseEvent &rMEvt);
98 : : virtual void GetFocus();
99 : : virtual void LoseFocus();
100 : :
101 : 6 : SmViewShell * GetView() { return pViewShell; }
102 : :
103 : : using Window::SetZoom;
104 : : void SetZoom(sal_uInt16 Factor);
105 : : using Window::GetZoom;
106 : 41 : sal_uInt16 GetZoom() const { return nZoom; }
107 : :
108 : 15 : const Point & GetFormulaDrawPos() const { return aFormulaDrawPos; }
109 : :
110 : : void ZoomToFitInWindow();
111 : : using ScrollableWindow::SetTotalSize;
112 : : void SetTotalSize();
113 : :
114 : : void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg );
115 : :
116 : : // for Accessibility
117 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
118 : :
119 : : using Window::GetAccessible;
120 : 12 : SmGraphicAccessible * GetAccessible_Impl() { return pAccessible; }
121 : : };
122 : :
123 : : /**************************************************************************/
124 : :
125 [ - + ]: 34 : class SmGraphicController: public SfxControllerItem
126 : : {
127 : : protected:
128 : : SmGraphicWindow &rGraphic;
129 : : public:
130 : : SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
131 : : virtual void StateChanged(sal_uInt16 nSID,
132 : : SfxItemState eState,
133 : : const SfxPoolItem* pState);
134 : : };
135 : :
136 : : /**************************************************************************/
137 : :
138 [ - + ]: 34 : class SmEditController: public SfxControllerItem
139 : : {
140 : : protected:
141 : : SmEditWindow &rEdit;
142 : :
143 : : public:
144 : : SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
145 : : #if OSL_DEBUG_LEVEL > 1
146 : : virtual ~SmEditController();
147 : : #endif
148 : :
149 : : virtual void StateChanged(sal_uInt16 nSID,
150 : : SfxItemState eState,
151 : : const SfxPoolItem* pState);
152 : : };
153 : :
154 : : /**************************************************************************/
155 : :
156 : : class SmCmdBoxWindow : public SfxDockingWindow
157 : : {
158 : : SmEditWindow aEdit;
159 : : SmEditController aController;
160 : : bool bExiting;
161 : :
162 : : Timer aInitialFocusTimer;
163 : :
164 : : DECL_LINK(InitialFocusTimerHdl, Timer *);
165 : :
166 : : protected :
167 : :
168 : : // Window
169 : : virtual void GetFocus();
170 : : virtual void Resize();
171 : : virtual void Paint(const Rectangle& rRect);
172 : : virtual void StateChanged( StateChangedType nStateChange );
173 : :
174 : : virtual Size CalcDockingSize(SfxChildAlignment eAlign);
175 : : virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
176 : : SfxChildAlignment eWish);
177 : :
178 : : virtual void ToggleFloatingMode();
179 : :
180 : : public:
181 : : SmCmdBoxWindow(SfxBindings *pBindings,
182 : : SfxChildWindow *pChildWindow,
183 : : Window *pParent);
184 : :
185 : : virtual ~SmCmdBoxWindow ();
186 : :
187 : : void AdjustPosition();
188 : :
189 : 304 : SmEditWindow *GetEditWindow() { return (&aEdit); }
190 : : SmViewShell *GetView();
191 : : };
192 : :
193 : : /**************************************************************************/
194 : :
195 [ - + ]: 68 : class SmCmdBoxWrapper : public SfxChildWindow
196 : : {
197 : : SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
198 : :
199 : : protected:
200 : : SmCmdBoxWrapper(Window *pParentWindow,
201 : : sal_uInt16 nId,
202 : : SfxBindings *pBindings,
203 : : SfxChildWinInfo *pInfo);
204 : :
205 : : #if OSL_DEBUG_LEVEL > 1
206 : : virtual ~SmCmdBoxWrapper();
207 : : #endif
208 : :
209 : : public:
210 : :
211 : 270 : SmEditWindow *GetEditWindow()
212 : : {
213 : 270 : return (((SmCmdBoxWindow *)pWindow)->GetEditWindow());
214 : : }
215 : :
216 : : };
217 : :
218 : : /**************************************************************************/
219 : :
220 : : namespace sfx2 { class FileDialogHelper; }
221 : : struct SmViewShell_Impl;
222 : :
223 : : class SmViewShell: public SfxViewShell
224 : : {
225 : : // for handling the PasteClipboardState
226 : : friend class SmClipboardChangeListener;
227 : :
228 : : SmViewShell_Impl* pImpl;
229 : :
230 : : SmGraphicWindow aGraphic;
231 : : SmGraphicController aGraphicController;
232 : : String StatusText;
233 : :
234 : : ::com::sun::star::uno:: Reference <
235 : : ::com::sun::star::lang:: XEventListener > xClipEvtLstnr;
236 : : SmClipboardChangeListener* pClipEvtLstnr;
237 : : bool bPasteState;
238 : :
239 : : DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
240 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
241 : :
242 : : /** Used to determine whether insertions using SID_INSERTSYMBOL and SID_INSERTCOMMAND
243 : : * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
244 : : * visual editor was last to have focus.
245 : : */
246 : : bool bInsertIntoEditWindow;
247 : : protected:
248 : :
249 : : Size GetTextLineSize(OutputDevice& rDevice,
250 : : const String& rLine);
251 : : Size GetTextSize(OutputDevice& rDevice,
252 : : const String& rText,
253 : : long MaxWidth);
254 : : void DrawTextLine(OutputDevice& rDevice,
255 : : const Point& rPosition,
256 : : const String& rLine);
257 : : void DrawText(OutputDevice& rDevice,
258 : : const Point& rPosition,
259 : : const String& rText,
260 : : sal_uInt16 MaxWidth);
261 : :
262 : : virtual sal_uInt16 Print(SfxProgress &rProgress, sal_Bool bIsAPI);
263 : : virtual SfxPrinter *GetPrinter(sal_Bool bCreate = sal_False);
264 : : virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
265 : : sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false);
266 : :
267 : : bool Insert( SfxMedium& rMedium );
268 : : bool InsertFrom(SfxMedium &rMedium);
269 : :
270 : : virtual SfxTabPage *CreatePrintOptionsPage(Window *pParent,
271 : : const SfxItemSet &rOptions);
272 : : virtual void Deactivate(sal_Bool IsMDIActivate);
273 : : virtual void Activate(sal_Bool IsMDIActivate);
274 : : virtual Size GetOptimalSizePixel() const;
275 : : virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
276 : : virtual void InnerResizePixel(const Point &rOfs, const Size &rSize);
277 : : virtual void OuterResizePixel(const Point &rOfs, const Size &rSize);
278 : : virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
279 : : virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY );
280 : :
281 : : public:
282 : : TYPEINFO();
283 : :
284 : : SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
285 : : ~SmViewShell();
286 : :
287 : 404 : SmDocShell * GetDoc()
288 : : {
289 : 404 : return (SmDocShell *) GetViewFrame()->GetObjectShell();
290 : : }
291 : :
292 : : SmEditWindow * GetEditWindow();
293 : 96 : SmGraphicWindow & GetGraphicWindow() { return aGraphic; }
294 : 0 : const SmGraphicWindow & GetGraphicWindow() const { return aGraphic; }
295 : :
296 : : void SetStatusText(const String& Text);
297 : :
298 : : void ShowError( const SmErrorDesc *pErrorDesc );
299 : : void NextError();
300 : : void PrevError();
301 : :
302 : 10 : SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
303 : 10 : SFX_DECL_VIEWFACTORY(SmViewShell);
304 : :
305 : : virtual void Execute( SfxRequest& rReq );
306 : : virtual void GetState(SfxItemSet &);
307 : :
308 : : void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
309 : : Rectangle aOutRect, Point aZeroPoint );
310 : :
311 : : /** Set bInsertIntoEditWindow so we know where to insert
312 : : *
313 : : * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
314 : : * so that when text is inserted from catalog or elsewhere we know whether to
315 : : * insert for the visual editor, or the text editor.
316 : : */
317 : 0 : void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast = true){
318 : 0 : bInsertIntoEditWindow = bEditWindowHadFocusLast;
319 : 0 : }
320 : : bool IsInlineEditEnabled() const;
321 : : };
322 : :
323 : : #endif
324 : :
325 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|