1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef VIEW_HXX 28 #define VIEW_HXX 29 30 #include <sfx2/dockwin.hxx> 31 #include <sfx2/viewsh.hxx> 32 #include <svtools/scrwin.hxx> 33 #include <sfx2/ctrlitem.hxx> 34 #include <sfx2/shell.hxx> 35 #include <sfx2/viewfac.hxx> 36 #include <sfx2/viewfrm.hxx> 37 #include <svtools/colorcfg.hxx> 38 #include "edit.hxx" 39 #include "node.hxx" 40 #include "accessibility.hxx" 41 42 class Menu; 43 class DataChangedEvent; 44 class SmClipboardChangeListener; 45 class SmDocShell; 46 class SmViewShell; 47 class SmPrintUIOptions; 48 49 /**************************************************************************/ 50 51 class SmGraphicWindow : public ScrollableWindow 52 { 53 Point aFormulaDrawPos; 54 Rectangle aCursorRect; 55 56 ::com::sun::star::uno::Reference< 57 ::com::sun::star::accessibility::XAccessible > xAccessible; 58 SmGraphicAccessible * pAccessible; 59 60 SmViewShell *pViewShell; 61 sal_uInt16 nZoom; 62 short nModifyCount; 63 sal_Bool bIsCursorVisible; 64 65 protected: 66 void SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; } 67 void SetIsCursorVisible(sal_Bool bVis) { bIsCursorVisible = bVis; } 68 using Window::SetCursor; 69 void SetCursor(const SmNode *pNode); 70 void SetCursor(const Rectangle &rRect); 71 72 virtual void DataChanged( const DataChangedEvent& ); 73 virtual void Paint(const Rectangle&); 74 virtual void KeyInput(const KeyEvent& rKEvt); 75 virtual void Command(const CommandEvent& rCEvt); 76 virtual void StateChanged( StateChangedType eChanged ); 77 DECL_LINK(MenuSelectHdl, Menu *); 78 79 public: 80 SmGraphicWindow(SmViewShell* pShell); 81 ~SmGraphicWindow(); 82 83 // Window 84 virtual void MouseButtonDown(const MouseEvent &rMEvt); 85 virtual void GetFocus(); 86 virtual void LoseFocus(); 87 88 SmViewShell * GetView() { return pViewShell; } 89 90 using Window::SetZoom; 91 void SetZoom(sal_uInt16 Factor); 92 using Window::GetZoom; 93 sal_uInt16 GetZoom() const { return nZoom; } 94 95 const Point & GetFormulaDrawPos() const { return aFormulaDrawPos; } 96 97 void ZoomToFitInWindow(); 98 using ScrollableWindow::SetTotalSize; 99 void SetTotalSize(); 100 101 sal_Bool IsCursorVisible() const { return bIsCursorVisible; } 102 void ShowCursor(sal_Bool bShow); 103 const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol); 104 105 void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg ); 106 107 // for Accessibility 108 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); 109 110 using Window::GetAccessible; 111 SmGraphicAccessible * GetAccessible_Impl() { return pAccessible; } 112 }; 113 114 /**************************************************************************/ 115 116 class SmGraphicController: public SfxControllerItem 117 { 118 protected: 119 SmGraphicWindow &rGraphic; 120 public: 121 SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & ); 122 virtual void StateChanged(sal_uInt16 nSID, 123 SfxItemState eState, 124 const SfxPoolItem* pState); 125 }; 126 127 /**************************************************************************/ 128 129 class SmEditController: public SfxControllerItem 130 { 131 protected: 132 SmEditWindow &rEdit; 133 134 public: 135 SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & ); 136 #if OSL_DEBUG_LEVEL > 1 137 virtual ~SmEditController(); 138 #endif 139 140 virtual void StateChanged(sal_uInt16 nSID, 141 SfxItemState eState, 142 const SfxPoolItem* pState); 143 }; 144 145 /**************************************************************************/ 146 147 class SmCmdBoxWindow : public SfxDockingWindow 148 { 149 SmEditWindow aEdit; 150 SmEditController aController; 151 sal_Bool bExiting; 152 153 Timer aInitialFocusTimer; 154 155 DECL_LINK(InitialFocusTimerHdl, Timer *); 156 157 protected : 158 159 // Window 160 virtual void GetFocus(); 161 virtual void Resize(); 162 virtual void Paint(const Rectangle& rRect); 163 virtual void StateChanged( StateChangedType nStateChange ); 164 165 virtual Size CalcDockingSize(SfxChildAlignment eAlign); 166 virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual, 167 SfxChildAlignment eWish); 168 169 virtual void ToggleFloatingMode(); 170 171 public: 172 SmCmdBoxWindow(SfxBindings *pBindings, 173 SfxChildWindow *pChildWindow, 174 Window *pParent); 175 176 virtual ~SmCmdBoxWindow (); 177 178 void AdjustPosition(); 179 180 SmEditWindow *GetEditWindow() { return (&aEdit); } 181 SmViewShell *GetView(); 182 }; 183 184 /**************************************************************************/ 185 186 class SmCmdBoxWrapper : public SfxChildWindow 187 { 188 SFX_DECL_CHILDWINDOW(SmCmdBoxWrapper); 189 190 protected: 191 SmCmdBoxWrapper(Window *pParentWindow, 192 sal_uInt16 nId, 193 SfxBindings *pBindings, 194 SfxChildWinInfo *pInfo); 195 196 #if OSL_DEBUG_LEVEL > 1 197 virtual ~SmCmdBoxWrapper(); 198 #endif 199 200 public: 201 202 SmEditWindow *GetEditWindow() 203 { 204 return (((SmCmdBoxWindow *)pWindow)->GetEditWindow()); 205 } 206 207 }; 208 209 /**************************************************************************/ 210 211 namespace sfx2 { class FileDialogHelper; } 212 struct SmViewShell_Impl; 213 214 class SmViewShell: public SfxViewShell 215 { 216 // for handling the PasteClipboardState 217 friend class SmClipboardChangeListener; 218 219 SmGraphicWindow aGraphic; 220 SmGraphicController aGraphicController; 221 String StatusText; 222 223 ::com::sun::star::uno:: Reference < 224 ::com::sun::star::lang:: XEventListener > xClipEvtLstnr; 225 SmClipboardChangeListener* pClipEvtLstnr; 226 SmViewShell_Impl* pImpl; 227 sal_Bool bPasteState; 228 229 DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* ); 230 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 231 232 protected: 233 234 Size GetTextLineSize(OutputDevice& rDevice, 235 const String& rLine); 236 Size GetTextSize(OutputDevice& rDevice, 237 const String& rText, 238 long MaxWidth); 239 void DrawTextLine(OutputDevice& rDevice, 240 const Point& rPosition, 241 const String& rLine); 242 void DrawText(OutputDevice& rDevice, 243 const Point& rPosition, 244 const String& rText, 245 sal_uInt16 MaxWidth); 246 247 virtual sal_uInt16 Print(SfxProgress &rProgress, sal_Bool bIsAPI); 248 virtual SfxPrinter *GetPrinter(sal_Bool bCreate = sal_False); 249 virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter, 250 sal_uInt16 nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false); 251 252 sal_Bool Insert( SfxMedium& rMedium ); 253 sal_Bool InsertFrom(SfxMedium &rMedium); 254 255 virtual SfxTabPage *CreatePrintOptionsPage(Window *pParent, 256 const SfxItemSet &rOptions); 257 virtual void Deactivate(sal_Bool IsMDIActivate); 258 virtual void Activate(sal_Bool IsMDIActivate); 259 virtual Size GetOptimalSizePixel() const; 260 virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize); 261 virtual void InnerResizePixel(const Point &rOfs, const Size &rSize); 262 virtual void OuterResizePixel(const Point &rOfs, const Size &rSize); 263 virtual void QueryObjAreaPixel( Rectangle& rRect ) const; 264 virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ); 265 266 public: 267 TYPEINFO(); 268 269 SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh); 270 ~SmViewShell(); 271 272 SmDocShell * GetDoc() 273 { 274 return (SmDocShell *) GetViewFrame()->GetObjectShell(); 275 } 276 277 SmEditWindow * GetEditWindow(); 278 SmGraphicWindow & GetGraphicWindow() { return aGraphic; } 279 const SmGraphicWindow & GetGraphicWindow() const { return aGraphic; } 280 281 void SetStatusText(const String& Text); 282 283 void ShowError( const SmErrorDesc *pErrorDesc ); 284 void NextError(); 285 void PrevError(); 286 287 SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2) 288 SFX_DECL_VIEWFACTORY(SmViewShell); 289 290 virtual void Execute( SfxRequest& rReq ); 291 virtual void GetState(SfxItemSet &); 292 293 void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions, 294 Rectangle aOutRect, Point aZeroPoint ); 295 }; 296 297 #endif 298 299