1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: view.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 #include <sfx2/dockwin.hxx>
34 #include <sfx2/viewsh.hxx>
35 #include <svtools/scrwin.hxx>
36 #include <sfx2/ctrlitem.hxx>
37 #include <sfx2/shell.hxx>
38 #include <sfx2/viewfac.hxx>
39 #include <sfx2/viewfrm.hxx>
40 #include <svtools/colorcfg.hxx>
43 #include "accessibility.hxx"
46 class DataChangedEvent
;
47 class SmClipboardChangeListener
;
51 /**************************************************************************/
53 class SmGraphicWindow
: public ScrollableWindow
55 Point aFormulaDrawPos
;
56 Rectangle aCursorRect
;
58 ::com::sun::star::uno::Reference
<
59 ::com::sun::star::accessibility::XAccessible
> xAccessible
;
60 SmGraphicAccessible
* pAccessible
;
62 SmViewShell
*pViewShell
;
65 BOOL bIsCursorVisible
;
68 void SetFormulaDrawPos(const Point
&rPos
) { aFormulaDrawPos
= rPos
; }
69 void SetIsCursorVisible(BOOL bVis
) { bIsCursorVisible
= bVis
; }
70 using Window::SetCursor
;
71 void SetCursor(const SmNode
*pNode
);
72 void SetCursor(const Rectangle
&rRect
);
74 virtual void DataChanged( const DataChangedEvent
& );
75 virtual void Paint(const Rectangle
&);
76 virtual void KeyInput(const KeyEvent
& rKEvt
);
77 virtual void Command(const CommandEvent
& rCEvt
);
78 virtual void StateChanged( StateChangedType eChanged
);
79 DECL_LINK(MenuSelectHdl
, Menu
*);
82 SmGraphicWindow(SmViewShell
* pShell
);
86 virtual void MouseButtonDown(const MouseEvent
&rMEvt
);
87 virtual void GetFocus();
88 virtual void LoseFocus();
90 SmViewShell
* GetView() { return pViewShell
; }
92 using Window::SetZoom
;
93 void SetZoom(USHORT Factor
);
94 using Window::GetZoom
;
95 USHORT
GetZoom() const { return nZoom
; }
97 const Point
& GetFormulaDrawPos() const { return aFormulaDrawPos
; }
99 void ZoomToFitInWindow();
100 using ScrollableWindow::SetTotalSize
;
103 BOOL
IsCursorVisible() const { return bIsCursorVisible
; }
104 void ShowCursor(BOOL bShow
);
105 const SmNode
* SetCursorPos(USHORT nRow
, USHORT nCol
);
107 void ApplyColorConfigValues( const svtools::ColorConfig
&rColorCfg
);
110 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> CreateAccessible();
112 using Window::GetAccessible
;
113 SmGraphicAccessible
* GetAccessible_Impl() { return pAccessible
; }
116 /**************************************************************************/
118 class SmGraphicController
: public SfxControllerItem
121 SmGraphicWindow
&rGraphic
;
123 SmGraphicController(SmGraphicWindow
&, USHORT
, SfxBindings
& );
124 virtual void StateChanged(USHORT nSID
,
126 const SfxPoolItem
* pState
);
129 /**************************************************************************/
131 class SmEditController
: public SfxControllerItem
137 SmEditController(SmEditWindow
&, USHORT
, SfxBindings
& );
138 #if OSL_DEBUG_LEVEL > 1
139 virtual ~SmEditController();
142 virtual void StateChanged(USHORT nSID
,
144 const SfxPoolItem
* pState
);
147 /**************************************************************************/
149 class SmCmdBoxWindow
: public SfxDockingWindow
152 SmEditController aController
;
155 Timer aInitialFocusTimer
;
157 DECL_LINK(InitialFocusTimerHdl
, Timer
*);
162 virtual void GetFocus();
163 virtual void Resize();
164 virtual void Paint(const Rectangle
& rRect
);
165 virtual void StateChanged( StateChangedType nStateChange
);
167 virtual Size
CalcDockingSize(SfxChildAlignment eAlign
);
168 virtual SfxChildAlignment
CheckAlignment(SfxChildAlignment eActual
,
169 SfxChildAlignment eWish
);
171 virtual void ToggleFloatingMode();
174 SmCmdBoxWindow(SfxBindings
*pBindings
,
175 SfxChildWindow
*pChildWindow
,
178 virtual ~SmCmdBoxWindow ();
180 void AdjustPosition();
182 SmEditWindow
*GetEditWindow() { return (&aEdit
); }
183 SmViewShell
*GetView();
186 /**************************************************************************/
188 class SmCmdBoxWrapper
: public SfxChildWindow
190 SFX_DECL_CHILDWINDOW(SmCmdBoxWrapper
);
193 SmCmdBoxWrapper(Window
*pParentWindow
,
195 SfxBindings
*pBindings
,
196 SfxChildWinInfo
*pInfo
);
198 #if OSL_DEBUG_LEVEL > 1
199 virtual ~SmCmdBoxWrapper();
204 SmEditWindow
*GetEditWindow()
206 return (((SmCmdBoxWindow
*)pWindow
)->GetEditWindow());
211 /**************************************************************************/
213 namespace sfx2
{ class FileDialogHelper
; }
214 struct SmViewShell_Impl
;
216 class SmViewShell
: public SfxViewShell
218 // for handling the PasteClipboardState
219 friend class SmClipboardChangeListener
;
221 SmGraphicWindow aGraphic
;
222 SmGraphicController aGraphicController
;
225 ::com::sun::star::uno:: Reference
<
226 ::com::sun::star::lang:: XEventListener
> xClipEvtLstnr
;
227 SmClipboardChangeListener
* pClipEvtLstnr
;
228 SmViewShell_Impl
* pImpl
;
231 DECL_LINK( DialogClosedHdl
, sfx2::FileDialogHelper
* );
232 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
236 Size
GetTextLineSize(OutputDevice
& rDevice
,
237 const String
& rLine
);
238 Size
GetTextSize(OutputDevice
& rDevice
,
241 void DrawTextLine(OutputDevice
& rDevice
,
242 const Point
& rPosition
,
243 const String
& rLine
);
244 void DrawText(OutputDevice
& rDevice
,
245 const Point
& rPosition
,
249 virtual USHORT
Print(SfxProgress
&rProgress
, BOOL bIsAPI
, PrintDialog
*pPrintDialog
= 0);
250 virtual SfxPrinter
*GetPrinter(BOOL bCreate
= FALSE
);
251 virtual USHORT
SetPrinter(SfxPrinter
*pNewPrinter
,
252 USHORT nDiffFlags
= SFX_PRINTER_ALL
, bool bIsAPI
=false);
254 BOOL
Insert( SfxMedium
& rMedium
);
255 BOOL
InsertFrom(SfxMedium
&rMedium
);
257 virtual SfxTabPage
*CreatePrintOptionsPage(Window
*pParent
,
258 const SfxItemSet
&rOptions
);
259 virtual void Deactivate(BOOL IsMDIActivate
);
260 virtual void Activate(BOOL IsMDIActivate
);
261 virtual Size
GetOptimalSizePixel() const;
262 virtual void AdjustPosSizePixel(const Point
&rPos
, const Size
&rSize
);
263 virtual void InnerResizePixel(const Point
&rOfs
, const Size
&rSize
);
264 virtual void OuterResizePixel(const Point
&rOfs
, const Size
&rSize
);
265 virtual void QueryObjAreaPixel( Rectangle
& rRect
) const;
266 virtual void SetZoomFactor( const Fraction
&rX
, const Fraction
&rY
);
271 SmViewShell(SfxViewFrame
*pFrame
, SfxViewShell
*pOldSh
);
274 SmDocShell
* GetDoc()
276 return (SmDocShell
*) GetViewFrame()->GetObjectShell();
279 SmEditWindow
* GetEditWindow();
280 SmGraphicWindow
& GetGraphicWindow() { return aGraphic
; }
281 const SmGraphicWindow
& GetGraphicWindow() const { return aGraphic
; }
283 void SetStatusText(const String
& Text
);
285 void ShowError( const SmErrorDesc
*pErrorDesc
);
289 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START
+2)
290 SFX_DECL_VIEWFACTORY(SmViewShell
);
292 virtual void Execute( SfxRequest
& rReq
);
293 virtual void GetState(SfxItemSet
&);
295 void Impl_Print( OutputDevice
&rOutDev
, const SmPrintSize ePrintSize
,
296 Rectangle aOutRect
, Point aZeroPoint
);