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 .
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>
35 class DataChangedEvent
;
36 class SmClipboardChangeListener
;
39 class SmPrintUIOptions
;
40 class SmGraphicAccessible
;
42 /**************************************************************************/
44 class SmGraphicWindow
: public ScrollableWindow
46 Point aFormulaDrawPos
;
48 // old style editing pieces
49 Rectangle aCursorRect
;
50 bool bIsCursorVisible
;
52 AutoTimer aCaretBlinkTimer
;
54 bool IsCursorVisible() const { return bIsCursorVisible
; }
55 void ShowCursor(bool bShow
);
56 bool IsLineVisible() const { return bIsLineVisible
; }
57 void ShowLine(bool bShow
);
58 const SmNode
* SetCursorPos(sal_uInt16 nRow
, sal_uInt16 nCol
);
60 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;
67 ::com::sun::star::uno::Reference
<
68 ::com::sun::star::accessibility::XAccessible
> xAccessible
;
69 SmGraphicAccessible
* pAccessible
;
71 SmViewShell
*pViewShell
;
75 void SetFormulaDrawPos(const Point
&rPos
) { aFormulaDrawPos
= rPos
; }
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
*);
85 void RepaintViewShellDoc();
86 DECL_LINK(CaretBlinkTimerHdl
, void *);
87 void CaretBlinkInit();
88 void CaretBlinkStart();
89 void CaretBlinkStop();
91 SmGraphicWindow(SmViewShell
* pShell
);
95 virtual void MouseButtonDown(const MouseEvent
&rMEvt
);
96 virtual void MouseMove(const MouseEvent
&rMEvt
);
97 virtual void GetFocus();
98 virtual void LoseFocus();
100 SmViewShell
* GetView() { return pViewShell
; }
102 using Window::SetZoom
;
103 void SetZoom(sal_uInt16 Factor
);
104 using Window::GetZoom
;
105 sal_uInt16
GetZoom() const { return nZoom
; }
107 const Point
& GetFormulaDrawPos() const { return aFormulaDrawPos
; }
109 void ZoomToFitInWindow();
110 using ScrollableWindow::SetTotalSize
;
113 void ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
);
116 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
118 using Window::GetAccessible
;
119 SmGraphicAccessible
* GetAccessible_Impl() { return pAccessible
; }
122 /**************************************************************************/
124 class SmGraphicController
: public SfxControllerItem
127 SmGraphicWindow
&rGraphic
;
129 SmGraphicController(SmGraphicWindow
&, sal_uInt16
, SfxBindings
& );
130 virtual void StateChanged(sal_uInt16 nSID
,
132 const SfxPoolItem
* pState
);
135 /**************************************************************************/
137 class SmEditController
: public SfxControllerItem
143 SmEditController(SmEditWindow
&, sal_uInt16
, SfxBindings
& );
144 #if OSL_DEBUG_LEVEL > 1
145 virtual ~SmEditController();
148 virtual void StateChanged(sal_uInt16 nSID
,
150 const SfxPoolItem
* pState
);
153 /**************************************************************************/
155 class SmCmdBoxWindow
: public SfxDockingWindow
158 SmEditController aController
;
161 Timer aInitialFocusTimer
;
163 DECL_LINK(InitialFocusTimerHdl
, Timer
*);
168 virtual void GetFocus();
169 virtual void Resize();
170 virtual void Paint(const Rectangle
& rRect
);
171 virtual void StateChanged( StateChangedType nStateChange
);
173 virtual Size
CalcDockingSize(SfxChildAlignment eAlign
);
174 virtual SfxChildAlignment
CheckAlignment(SfxChildAlignment eActual
,
175 SfxChildAlignment eWish
);
177 virtual void ToggleFloatingMode();
180 SmCmdBoxWindow(SfxBindings
*pBindings
,
181 SfxChildWindow
*pChildWindow
,
184 virtual ~SmCmdBoxWindow ();
186 void AdjustPosition();
188 SmEditWindow
*GetEditWindow() { return (&aEdit
); }
189 SmViewShell
*GetView();
192 /**************************************************************************/
194 class SmCmdBoxWrapper
: public SfxChildWindow
196 SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper
);
199 SmCmdBoxWrapper(Window
*pParentWindow
,
201 SfxBindings
*pBindings
,
202 SfxChildWinInfo
*pInfo
);
204 #if OSL_DEBUG_LEVEL > 1
205 virtual ~SmCmdBoxWrapper();
210 SmEditWindow
*GetEditWindow()
212 return (((SmCmdBoxWindow
*)pWindow
)->GetEditWindow());
217 /**************************************************************************/
219 namespace sfx2
{ class FileDialogHelper
; }
220 struct SmViewShell_Impl
;
222 class SmViewShell
: public SfxViewShell
224 // for handling the PasteClipboardState
225 friend class SmClipboardChangeListener
;
227 SmViewShell_Impl
* pImpl
;
229 SmGraphicWindow aGraphic
;
230 SmGraphicController aGraphicController
;
231 OUString aStatusText
;
233 ::com::sun::star::uno:: Reference
<
234 ::com::sun::star::lang:: XEventListener
> xClipEvtLstnr
;
235 SmClipboardChangeListener
* pClipEvtLstnr
;
238 DECL_LINK( DialogClosedHdl
, sfx2::FileDialogHelper
* );
239 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
241 /** Used to determine whether insertions using SID_INSERTSYMBOL and SID_INSERTCOMMAND
242 * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
243 * visual editor was last to have focus.
245 bool bInsertIntoEditWindow
;
248 Size
GetTextLineSize(OutputDevice
& rDevice
,
249 const String
& rLine
);
250 Size
GetTextSize(OutputDevice
& rDevice
,
253 void DrawTextLine(OutputDevice
& rDevice
,
254 const Point
& rPosition
,
255 const String
& rLine
);
256 void DrawText(OutputDevice
& rDevice
,
257 const Point
& rPosition
,
259 sal_uInt16 MaxWidth
);
261 virtual sal_uInt16
Print(SfxProgress
&rProgress
, sal_Bool bIsAPI
);
262 virtual SfxPrinter
*GetPrinter(sal_Bool bCreate
= sal_False
);
263 virtual sal_uInt16
SetPrinter(SfxPrinter
*pNewPrinter
,
264 sal_uInt16 nDiffFlags
= SFX_PRINTER_ALL
, bool bIsAPI
=false);
266 bool Insert( SfxMedium
& rMedium
);
267 bool InsertFrom(SfxMedium
&rMedium
);
269 virtual bool HasPrintOptionsPage() const;
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 void AdjustPosSizePixel(const Point
&rPos
, const Size
&rSize
);
275 virtual void InnerResizePixel(const Point
&rOfs
, const Size
&rSize
);
276 virtual void OuterResizePixel(const Point
&rOfs
, const Size
&rSize
);
277 virtual void QueryObjAreaPixel( Rectangle
& rRect
) const;
278 virtual void SetZoomFactor( const Fraction
&rX
, const Fraction
&rY
);
283 SmViewShell(SfxViewFrame
*pFrame
, SfxViewShell
*pOldSh
);
286 SmDocShell
* GetDoc()
288 return (SmDocShell
*) GetViewFrame()->GetObjectShell();
291 SmEditWindow
* GetEditWindow();
292 SmGraphicWindow
& GetGraphicWindow() { return aGraphic
; }
293 const SmGraphicWindow
& GetGraphicWindow() const { return aGraphic
; }
295 void SetStatusText(const OUString
& rText
);
297 void ShowError( const SmErrorDesc
*pErrorDesc
);
301 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START
+2)
302 SFX_DECL_VIEWFACTORY(SmViewShell
);
304 virtual void Execute( SfxRequest
& rReq
);
305 virtual void GetState(SfxItemSet
&);
307 void Impl_Print( OutputDevice
&rOutDev
, const SmPrintUIOptions
&rPrintUIOptions
,
308 Rectangle aOutRect
, Point aZeroPoint
);
310 /** Set bInsertIntoEditWindow so we know where to insert
312 * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
313 * so that when text is inserted from catalog or elsewhere we know whether to
314 * insert for the visual editor, or the text editor.
316 void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast
= true){
317 bInsertIntoEditWindow
= bEditWindowHadFocusLast
;
319 bool IsInlineEditEnabled() const;
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */