nss: upgrade to release 3.73
[LibreOffice.git] / starmath / inc / view.hxx
blobee4e17b10767afcd86925f68e3e1650f6c379cad
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_STARMATH_INC_VIEW_HXX
20 #define INCLUDED_STARMATH_INC_VIEW_HXX
22 #include <sal/config.h>
24 #include <memory>
26 #include <rtl/ref.hxx>
27 #include <sfx2/docinsert.hxx>
28 #include <sfx2/dockwin.hxx>
29 #include <sfx2/viewsh.hxx>
30 #include <sfx2/ctrlitem.hxx>
31 #include <sfx2/shell.hxx>
32 #include <sfx2/viewfrm.hxx>
33 #include <vcl/timer.hxx>
34 #include "document.hxx"
35 #include "edit.hxx"
36 #include "scrwin.hxx"
38 class SmViewShell;
39 class SmPrintUIOptions;
40 class SmGraphicAccessible;
41 class SmNode;
43 namespace svtools { class ColorConfig; }
45 class SmGraphicWindow final : public ScrollableWindow
47 public:
48 bool IsCursorVisible() const
50 return bIsCursorVisible;
52 void ShowCursor(bool bShow);
53 bool IsLineVisible() const
55 return bIsLineVisible;
57 void ShowLine(bool bShow);
58 const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
60 explicit SmGraphicWindow(SmViewShell* pShell);
61 virtual ~SmGraphicWindow() override;
62 virtual void dispose() override;
64 // Window
65 virtual void ApplySettings(vcl::RenderContext&) override;
66 virtual void MouseButtonDown(const MouseEvent &rMEvt) override;
67 virtual void MouseMove(const MouseEvent &rMEvt) override;
68 virtual void GetFocus() override;
69 virtual void LoseFocus() override;
71 SmViewShell* GetView()
73 return pViewShell;
76 using Window::SetZoom;
77 void SetZoom(sal_uInt16 Factor);
78 using Window::GetZoom;
79 sal_uInt16 GetZoom() const
81 return nZoom;
84 const Point& GetFormulaDrawPos() const
86 return aFormulaDrawPos;
89 void ZoomToFitInWindow();
90 using ScrollableWindow::SetTotalSize;
91 void SetTotalSize();
93 // for Accessibility
94 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
96 using Window::GetAccessible;
97 SmGraphicAccessible* GetAccessible_Impl()
99 return mxAccessible.get();
102 private:
103 void SetIsCursorVisible(bool bVis)
105 bIsCursorVisible = bVis;
107 using Window::SetCursor;
108 void SetCursor(const SmNode *pNode);
109 void SetCursor(const tools::Rectangle &rRect);
110 static bool IsInlineEditEnabled();
112 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
113 virtual void KeyInput(const KeyEvent& rKEvt) override;
114 virtual void Command(const CommandEvent& rCEvt) override;
115 virtual void StateChanged( StateChangedType eChanged ) override;
117 void RepaintViewShellDoc();
118 DECL_LINK(CaretBlinkTimerHdl, Timer *, void);
119 void CaretBlinkInit();
120 void CaretBlinkStart();
121 void CaretBlinkStop();
123 Point aFormulaDrawPos;
124 // old style editing pieces
125 tools::Rectangle aCursorRect;
126 bool bIsCursorVisible;
127 bool bIsLineVisible;
128 AutoTimer aCaretBlinkTimer;
129 rtl::Reference<SmGraphicAccessible> mxAccessible;
130 SmViewShell* pViewShell;
131 sal_uInt16 nZoom;
134 class SmGraphicController final : public SfxControllerItem
136 SmGraphicWindow &rGraphic;
137 public:
138 SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
139 virtual void StateChanged(sal_uInt16 nSID,
140 SfxItemState eState,
141 const SfxPoolItem* pState) override;
144 class SmEditController final : public SfxControllerItem
146 SmEditWindow &rEdit;
148 public:
149 SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
151 virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) override;
154 class SmCmdBoxWindow : public SfxDockingWindow
156 VclPtr<SmEditWindow> aEdit;
157 SmEditController aController;
158 bool bExiting;
160 Timer aInitialFocusTimer;
162 DECL_LINK(InitialFocusTimerHdl, Timer *, void);
164 protected:
166 // Window
167 virtual void GetFocus() override;
168 virtual void Resize() override;
169 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
170 virtual void StateChanged( StateChangedType nStateChange ) override;
172 virtual Size CalcDockingSize(SfxChildAlignment eAlign) override;
173 virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
174 SfxChildAlignment eWish) override;
176 virtual void ToggleFloatingMode() override;
178 public:
179 SmCmdBoxWindow(SfxBindings *pBindings,
180 SfxChildWindow *pChildWindow,
181 Window *pParent);
183 virtual ~SmCmdBoxWindow () override;
184 virtual void dispose() override;
186 void AdjustPosition();
188 SmEditWindow& GetEditWindow()
190 return *aEdit;
192 SmViewShell* GetView();
195 class SmCmdBoxWrapper final : public SfxChildWindow
197 SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
199 SmCmdBoxWrapper(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo);
201 public:
203 SmEditWindow& GetEditWindow()
205 return static_cast<SmCmdBoxWindow *>(GetWindow())->GetEditWindow();
209 namespace sfx2 { class FileDialogHelper; }
211 class SmViewShell: public SfxViewShell
213 std::unique_ptr<sfx2::DocumentInserter> mpDocInserter;
214 std::unique_ptr<SfxRequest> mpRequest;
215 VclPtr<SmGraphicWindow> mpGraphic;
216 SmGraphicController maGraphicController;
217 OUString maStatusText;
218 bool mbPasteState;
219 /** Used to determine whether insertions using SID_INSERTSPECIAL and SID_INSERTCOMMANDTEXT
220 * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
221 * visual editor was last to have focus.
223 bool mbInsertIntoEditWindow;
225 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void );
226 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
228 protected:
230 static Size GetTextLineSize(OutputDevice const & rDevice,
231 const OUString& rLine);
232 static Size GetTextSize(OutputDevice const & rDevice,
233 const OUString& rText,
234 tools::Long MaxWidth);
235 static void DrawTextLine(OutputDevice& rDevice,
236 const Point& rPosition,
237 const OUString& rLine);
238 static void DrawText(OutputDevice& rDevice,
239 const Point& rPosition,
240 const OUString& rText,
241 sal_uInt16 MaxWidth);
243 virtual SfxPrinter *GetPrinter(bool bCreate = false) override;
244 virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
245 SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL) override;
247 void Insert( SfxMedium& rMedium );
248 void InsertFrom(SfxMedium &rMedium);
250 virtual bool HasPrintOptionsPage() const override;
251 virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
252 const SfxItemSet &rOptions) override;
253 virtual void Deactivate(bool IsMDIActivate) override;
254 virtual void Activate(bool IsMDIActivate) override;
255 virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override;
256 virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override;
257 virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override;
258 virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) override;
260 public:
262 SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
263 virtual ~SmViewShell() override;
265 SmDocShell * GetDoc()
267 return static_cast<SmDocShell *>( GetViewFrame()->GetObjectShell() );
270 SmEditWindow * GetEditWindow();
272 SmGraphicWindow& GetGraphicWindow()
274 return *mpGraphic;
276 const SmGraphicWindow& GetGraphicWindow() const
278 return *mpGraphic;
281 void SetStatusText(const OUString& rText);
283 void ShowError( const SmErrorDesc *pErrorDesc );
284 void NextError();
285 void PrevError();
287 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(2))
288 SFX_DECL_VIEWFACTORY(SmViewShell);
290 private:
291 /// SfxInterface initializer.
292 static void InitInterface_Impl();
294 public:
295 void Execute( SfxRequest& rReq );
296 void GetState(SfxItemSet &);
298 void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
299 tools::Rectangle aOutRect );
301 /** Set bInsertIntoEditWindow so we know where to insert
303 * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
304 * so that when text is inserted from catalog or elsewhere we know whether to
305 * insert for the visual editor, or the text editor.
307 void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast){
308 mbInsertIntoEditWindow = bEditWindowHadFocusLast;
310 static bool IsInlineEditEnabled();
312 private:
313 void ZoomByItemSet(const SfxItemSet *pSet);
316 #endif
318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */