Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / starmath / inc / view.hxx
blob687fd1850bf08d310aecec432c4ec46a7c7a8e29
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/dockwin.hxx>
28 #include <sfx2/viewsh.hxx>
29 #include <svtools/scrwin.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"
37 class SmViewShell;
38 class SmPrintUIOptions;
39 class SmGraphicAccessible;
40 class SmNode;
42 namespace svtools { class ColorConfig; }
44 class SmGraphicWindow final : public ScrollableWindow
46 public:
47 bool IsCursorVisible() const
49 return bIsCursorVisible;
51 void ShowCursor(bool bShow);
52 bool IsLineVisible() const
54 return bIsLineVisible;
56 void ShowLine(bool bShow);
57 const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
59 explicit SmGraphicWindow(SmViewShell* pShell);
60 virtual ~SmGraphicWindow() override;
61 virtual void dispose() override;
63 // Window
64 virtual void ApplySettings(vcl::RenderContext&) override;
65 virtual void MouseButtonDown(const MouseEvent &rMEvt) override;
66 virtual void MouseMove(const MouseEvent &rMEvt) override;
67 virtual void GetFocus() override;
68 virtual void LoseFocus() override;
70 SmViewShell* GetView()
72 return pViewShell;
75 using Window::SetZoom;
76 void SetZoom(sal_uInt16 Factor);
77 using Window::GetZoom;
78 sal_uInt16 GetZoom() const
80 return nZoom;
83 const Point& GetFormulaDrawPos() const
85 return aFormulaDrawPos;
88 void ZoomToFitInWindow();
89 using ScrollableWindow::SetTotalSize;
90 void SetTotalSize();
92 // for Accessibility
93 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
95 using Window::GetAccessible;
96 SmGraphicAccessible* GetAccessible_Impl()
98 return mxAccessible.get();
101 private:
102 void SetIsCursorVisible(bool bVis)
104 bIsCursorVisible = bVis;
106 using Window::SetCursor;
107 void SetCursor(const SmNode *pNode);
108 void SetCursor(const tools::Rectangle &rRect);
109 bool IsInlineEditEnabled() const;
111 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
112 virtual void KeyInput(const KeyEvent& rKEvt) override;
113 virtual void Command(const CommandEvent& rCEvt) override;
114 virtual void StateChanged( StateChangedType eChanged ) override;
116 void RepaintViewShellDoc();
117 DECL_LINK(CaretBlinkTimerHdl, Timer *, void);
118 void CaretBlinkInit();
119 void CaretBlinkStart();
120 void CaretBlinkStop();
122 Point aFormulaDrawPos;
123 // old style editing pieces
124 tools::Rectangle aCursorRect;
125 bool bIsCursorVisible;
126 bool bIsLineVisible;
127 AutoTimer aCaretBlinkTimer;
128 rtl::Reference<SmGraphicAccessible> mxAccessible;
129 SmViewShell* pViewShell;
130 sal_uInt16 nZoom;
133 class SmGraphicController final : public SfxControllerItem
135 SmGraphicWindow &rGraphic;
136 public:
137 SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
138 virtual void StateChanged(sal_uInt16 nSID,
139 SfxItemState eState,
140 const SfxPoolItem* pState) override;
143 class SmEditController final : public SfxControllerItem
145 SmEditWindow &rEdit;
147 public:
148 SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
150 virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) override;
153 class SmCmdBoxWindow : public SfxDockingWindow
155 VclPtr<SmEditWindow> aEdit;
156 SmEditController aController;
157 bool bExiting;
159 Timer aInitialFocusTimer;
161 DECL_LINK(InitialFocusTimerHdl, Timer *, void);
163 protected:
165 // Window
166 virtual void GetFocus() override;
167 virtual void Resize() override;
168 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
169 virtual void StateChanged( StateChangedType nStateChange ) override;
171 virtual Size CalcDockingSize(SfxChildAlignment eAlign) override;
172 virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
173 SfxChildAlignment eWish) override;
175 virtual void ToggleFloatingMode() override;
177 public:
178 SmCmdBoxWindow(SfxBindings *pBindings,
179 SfxChildWindow *pChildWindow,
180 Window *pParent);
182 virtual ~SmCmdBoxWindow () override;
183 virtual void dispose() override;
185 void AdjustPosition();
187 SmEditWindow& GetEditWindow()
189 return *aEdit;
191 SmViewShell* GetView();
194 class SmCmdBoxWrapper final : public SfxChildWindow
196 SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
198 SmCmdBoxWrapper(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo);
200 public:
202 SmEditWindow& GetEditWindow()
204 return static_cast<SmCmdBoxWindow *>(GetWindow())->GetEditWindow();
208 namespace sfx2 { class FileDialogHelper; }
209 struct SmViewShell_Impl;
211 class SmViewShell: public SfxViewShell
213 std::unique_ptr<SmViewShell_Impl> mpImpl;
215 VclPtr<SmGraphicWindow> mpGraphic;
216 SmGraphicController const maGraphicController;
217 OUString maStatusText;
219 bool mbPasteState;
221 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void );
222 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
224 /** Used to determine whether insertions using SID_INSERTSPECIAL and SID_INSERTCOMMANDTEXT
225 * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
226 * visual editor was last to have focus.
228 bool mbInsertIntoEditWindow;
229 protected:
231 static Size GetTextLineSize(OutputDevice const & rDevice,
232 const OUString& rLine);
233 static Size GetTextSize(OutputDevice const & rDevice,
234 const OUString& rText,
235 long MaxWidth);
236 static void DrawTextLine(OutputDevice& rDevice,
237 const Point& rPosition,
238 const OUString& rLine);
239 static void DrawText(OutputDevice& rDevice,
240 const Point& rPosition,
241 const OUString& rText,
242 sal_uInt16 MaxWidth);
244 virtual SfxPrinter *GetPrinter(bool bCreate = false) override;
245 virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
246 SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL) override;
248 void Insert( SfxMedium& rMedium );
249 void InsertFrom(SfxMedium &rMedium);
251 virtual bool HasPrintOptionsPage() const override;
252 virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
253 const SfxItemSet &rOptions) override;
254 virtual void Deactivate(bool IsMDIActivate) override;
255 virtual void Activate(bool IsMDIActivate) override;
256 virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override;
257 virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override;
258 virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override;
259 virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) override;
261 public:
263 SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
264 virtual ~SmViewShell() override;
266 SmDocShell * GetDoc()
268 return static_cast<SmDocShell *>( GetViewFrame()->GetObjectShell() );
271 SmEditWindow * GetEditWindow();
273 SmGraphicWindow& GetGraphicWindow()
275 return *mpGraphic;
277 const SmGraphicWindow& GetGraphicWindow() const
279 return *mpGraphic;
282 void SetStatusText(const OUString& rText);
284 void ShowError( const SmErrorDesc *pErrorDesc );
285 void NextError();
286 void PrevError();
288 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(2))
289 SFX_DECL_VIEWFACTORY(SmViewShell);
291 private:
292 /// SfxInterface initializer.
293 static void InitInterface_Impl();
295 public:
296 void Execute( SfxRequest& rReq );
297 void GetState(SfxItemSet &);
299 void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
300 tools::Rectangle aOutRect );
302 /** Set bInsertIntoEditWindow so we know where to insert
304 * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
305 * so that when text is inserted from catalog or elsewhere we know whether to
306 * insert for the visual editor, or the text editor.
308 void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast){
309 mbInsertIntoEditWindow = bEditWindowHadFocusLast;
311 bool IsInlineEditEnabled() const;
313 private:
314 void ZoomByItemSet(const SfxItemSet *pSet);
317 #endif
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */