1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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"
38 class SmPrintUIOptions
;
39 class SmGraphicAccessible
;
42 namespace svtools
{ class ColorConfig
; }
44 class SmGraphicWindow final
: public ScrollableWindow
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
;
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()
75 using Window::SetZoom
;
76 void SetZoom(sal_uInt16 Factor
);
77 using Window::GetZoom
;
78 sal_uInt16
GetZoom() const
83 const Point
& GetFormulaDrawPos() const
85 return aFormulaDrawPos
;
88 void ZoomToFitInWindow();
89 using ScrollableWindow::SetTotalSize
;
93 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
95 using Window::GetAccessible
;
96 SmGraphicAccessible
* GetAccessible_Impl()
98 return mxAccessible
.get();
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
;
127 AutoTimer aCaretBlinkTimer
;
128 rtl::Reference
<SmGraphicAccessible
> mxAccessible
;
129 SmViewShell
* pViewShell
;
133 class SmGraphicController final
: public SfxControllerItem
135 SmGraphicWindow
&rGraphic
;
137 SmGraphicController(SmGraphicWindow
&, sal_uInt16
, SfxBindings
& );
138 virtual void StateChanged(sal_uInt16 nSID
,
140 const SfxPoolItem
* pState
) override
;
143 class SmEditController final
: public SfxControllerItem
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
;
159 Timer aInitialFocusTimer
;
161 DECL_LINK(InitialFocusTimerHdl
, Timer
*, void);
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
;
178 SmCmdBoxWindow(SfxBindings
*pBindings
,
179 SfxChildWindow
*pChildWindow
,
182 virtual ~SmCmdBoxWindow () override
;
183 virtual void dispose() override
;
185 void AdjustPosition();
187 SmEditWindow
& GetEditWindow()
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
);
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
;
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
;
231 static Size
GetTextLineSize(OutputDevice
const & rDevice
,
232 const OUString
& rLine
);
233 static Size
GetTextSize(OutputDevice
const & rDevice
,
234 const OUString
& rText
,
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
;
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()
277 const SmGraphicWindow
& GetGraphicWindow() const
282 void SetStatusText(const OUString
& rText
);
284 void ShowError( const SmErrorDesc
*pErrorDesc
);
288 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START
+SfxInterfaceId(2))
289 SFX_DECL_VIEWFACTORY(SmViewShell
);
292 /// SfxInterface initializer.
293 static void InitInterface_Impl();
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;
314 void ZoomByItemSet(const SfxItemSet
*pSet
);
319 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */