LCOV - code coverage report
Current view: top level - libreoffice/starmath/inc - view.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 23 39.1 %
Date: 2012-12-27 Functions: 8 22 36.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : #ifndef VIEW_HXX
      20             : #define VIEW_HXX
      21             : 
      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>
      31             : #include "edit.hxx"
      32             : #include "node.hxx"
      33             : 
      34             : class Menu;
      35             : class DataChangedEvent;
      36             : class SmClipboardChangeListener;
      37             : class SmDocShell;
      38             : class SmViewShell;
      39             : class SmPrintUIOptions;
      40             : class SmGraphicAccessible;
      41             : 
      42             : /**************************************************************************/
      43             : 
      44             : class SmGraphicWindow : public ScrollableWindow
      45             : {
      46             :     Point     aFormulaDrawPos;
      47             : 
      48             :     // old style editing pieces
      49             :     Rectangle aCursorRect;
      50             :     bool      bIsCursorVisible;
      51             :     bool      bIsLineVisible;
      52             :     AutoTimer aCaretBlinkTimer;
      53             : public:
      54           0 :     bool IsCursorVisible() const { return bIsCursorVisible; }
      55             :     void ShowCursor(bool bShow);
      56           0 :     bool IsLineVisible() const { return bIsLineVisible; }
      57             :     void ShowLine(bool bShow);
      58             :     const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
      59             : protected:
      60           0 :     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;
      65             : 
      66             : private:
      67             :     ::com::sun::star::uno::Reference<
      68             :         ::com::sun::star::accessibility::XAccessible >  xAccessible;
      69             :     SmGraphicAccessible *                                       pAccessible;
      70             : 
      71             :     SmViewShell    *pViewShell;
      72             :     sal_uInt16          nZoom;
      73             : 
      74             : protected:
      75           0 :     void        SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; }
      76             : 
      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 *);
      83             : 
      84             : private:
      85             :     void RepaintViewShellDoc();
      86             :     DECL_LINK(CaretBlinkTimerHdl, void *);
      87             :     void CaretBlinkInit();
      88             :     void CaretBlinkStart();
      89             :     void CaretBlinkStop();
      90             : public:
      91             :     SmGraphicWindow(SmViewShell* pShell);
      92             :     ~SmGraphicWindow();
      93             : 
      94             :     // Window
      95             :     virtual void    MouseButtonDown(const MouseEvent &rMEvt);
      96             :     virtual void    MouseMove(const MouseEvent &rMEvt);
      97             :     virtual void    GetFocus();
      98             :     virtual void    LoseFocus();
      99             : 
     100           9 :     SmViewShell *   GetView()   { return pViewShell; }
     101             : 
     102             :     using   Window::SetZoom;
     103             :     void   SetZoom(sal_uInt16 Factor);
     104             :     using   Window::GetZoom;
     105          13 :     sal_uInt16 GetZoom() const { return nZoom; }
     106             : 
     107           0 :     const Point &   GetFormulaDrawPos() const { return aFormulaDrawPos; }
     108             : 
     109             :     void ZoomToFitInWindow();
     110             :     using   ScrollableWindow::SetTotalSize;
     111             :     void SetTotalSize();
     112             : 
     113             :     void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg );
     114             : 
     115             :     // for Accessibility
     116             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
     117             : 
     118             :     using   Window::GetAccessible;
     119           0 :     SmGraphicAccessible *   GetAccessible_Impl()  { return pAccessible; }
     120             : };
     121             : 
     122             : /**************************************************************************/
     123             : 
     124           0 : class SmGraphicController: public SfxControllerItem
     125             : {
     126             : protected:
     127             :     SmGraphicWindow &rGraphic;
     128             : public:
     129             :     SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
     130             :     virtual void StateChanged(sal_uInt16             nSID,
     131             :                               SfxItemState       eState,
     132             :                               const SfxPoolItem* pState);
     133             : };
     134             : 
     135             : /**************************************************************************/
     136             : 
     137           4 : class SmEditController: public SfxControllerItem
     138             : {
     139             : protected:
     140             :     SmEditWindow &rEdit;
     141             : 
     142             : public:
     143             :     SmEditController(SmEditWindow &, sal_uInt16, SfxBindings  & );
     144             : #if OSL_DEBUG_LEVEL > 1
     145             :     virtual ~SmEditController();
     146             : #endif
     147             : 
     148             :     virtual void StateChanged(sal_uInt16             nSID,
     149             :                               SfxItemState       eState,
     150             :                               const SfxPoolItem* pState);
     151             : };
     152             : 
     153             : /**************************************************************************/
     154             : 
     155             : class SmCmdBoxWindow : public SfxDockingWindow
     156             : {
     157             :     SmEditWindow        aEdit;
     158             :     SmEditController    aController;
     159             :     bool                bExiting;
     160             : 
     161             :     Timer               aInitialFocusTimer;
     162             : 
     163             :     DECL_LINK(InitialFocusTimerHdl, Timer *);
     164             : 
     165             : protected :
     166             : 
     167             :     // Window
     168             :     virtual void    GetFocus();
     169             :     virtual void Resize();
     170             :     virtual void Paint(const Rectangle& rRect);
     171             :     virtual void StateChanged( StateChangedType nStateChange );
     172             : 
     173             :     virtual Size CalcDockingSize(SfxChildAlignment eAlign);
     174             :     virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
     175             :                                              SfxChildAlignment eWish);
     176             : 
     177             :     virtual void    ToggleFloatingMode();
     178             : 
     179             : public:
     180             :     SmCmdBoxWindow(SfxBindings    *pBindings,
     181             :                    SfxChildWindow *pChildWindow,
     182             :                    Window         *pParent);
     183             : 
     184             :     virtual ~SmCmdBoxWindow ();
     185             : 
     186             :     void AdjustPosition();
     187             : 
     188           8 :     SmEditWindow *GetEditWindow() { return (&aEdit); }
     189             :     SmViewShell  *GetView();
     190             : };
     191             : 
     192             : /**************************************************************************/
     193             : 
     194           0 : class SmCmdBoxWrapper : public SfxChildWindow
     195             : {
     196             :     SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
     197             : 
     198             : protected:
     199             :     SmCmdBoxWrapper(Window          *pParentWindow,
     200             :                     sal_uInt16           nId,
     201             :                     SfxBindings     *pBindings,
     202             :                     SfxChildWinInfo *pInfo);
     203             : 
     204             : #if OSL_DEBUG_LEVEL > 1
     205             :     virtual ~SmCmdBoxWrapper();
     206             : #endif
     207             : 
     208             : public:
     209             : 
     210           0 :     SmEditWindow *GetEditWindow()
     211             :     {
     212           0 :         return (((SmCmdBoxWindow *)pWindow)->GetEditWindow());
     213             :     }
     214             : 
     215             : };
     216             : 
     217             : /**************************************************************************/
     218             : 
     219             : namespace sfx2 { class FileDialogHelper; }
     220             : struct SmViewShell_Impl;
     221             : 
     222             : class SmViewShell: public SfxViewShell
     223             : {
     224             :     // for handling the PasteClipboardState
     225             :     friend class SmClipboardChangeListener;
     226             : 
     227             :     SmViewShell_Impl*   pImpl;
     228             : 
     229             :     SmGraphicWindow     aGraphic;
     230             :     SmGraphicController aGraphicController;
     231             :     OUString            aStatusText;
     232             : 
     233             :     ::com::sun::star::uno:: Reference <
     234             :             ::com::sun::star::lang:: XEventListener > xClipEvtLstnr;
     235             :     SmClipboardChangeListener*  pClipEvtLstnr;
     236             :     bool                bPasteState;
     237             : 
     238             :     DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
     239             :     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
     240             : 
     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.
     244             :      */
     245             :     bool bInsertIntoEditWindow;
     246             : protected:
     247             : 
     248             :     Size GetTextLineSize(OutputDevice& rDevice,
     249             :                          const String& rLine);
     250             :     Size GetTextSize(OutputDevice& rDevice,
     251             :                      const String& rText,
     252             :                      long          MaxWidth);
     253             :     void DrawTextLine(OutputDevice& rDevice,
     254             :                       const Point&  rPosition,
     255             :                       const String& rLine);
     256             :     void DrawText(OutputDevice& rDevice,
     257             :                   const Point&  rPosition,
     258             :                   const String& rText,
     259             :                   sal_uInt16        MaxWidth);
     260             : 
     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);
     265             : 
     266             :     bool        Insert( SfxMedium& rMedium );
     267             :     bool        InsertFrom(SfxMedium &rMedium);
     268             : 
     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 Size GetOptimalSizePixel() const;
     275             :     virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize);
     276             :     virtual void InnerResizePixel(const Point &rOfs, const Size  &rSize);
     277             :     virtual void OuterResizePixel(const Point &rOfs, const Size  &rSize);
     278             :     virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
     279             :     virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY );
     280             : 
     281             : public:
     282             :     TYPEINFO();
     283             : 
     284             :     SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
     285             :     ~SmViewShell();
     286             : 
     287          35 :     SmDocShell * GetDoc()
     288             :     {
     289          35 :         return (SmDocShell *) GetViewFrame()->GetObjectShell();
     290             :     }
     291             : 
     292             :     SmEditWindow * GetEditWindow();
     293           5 :           SmGraphicWindow & GetGraphicWindow()       { return aGraphic; }
     294           0 :     const SmGraphicWindow & GetGraphicWindow() const { return aGraphic; }
     295             : 
     296             :     void        SetStatusText(const OUString& rText);
     297             : 
     298             :     void        ShowError( const SmErrorDesc *pErrorDesc );
     299             :     void        NextError();
     300             :     void        PrevError();
     301             : 
     302           4 :     SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
     303           4 :     SFX_DECL_VIEWFACTORY(SmViewShell);
     304             : 
     305             :     virtual void Execute( SfxRequest& rReq );
     306             :     virtual void GetState(SfxItemSet &);
     307             : 
     308             :     void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
     309             :             Rectangle aOutRect, Point aZeroPoint );
     310             : 
     311             :     /** Set bInsertIntoEditWindow so we know where to insert
     312             :      *
     313             :      * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
     314             :      * so that when text is inserted from catalog or elsewhere we know whether to
     315             :      * insert for the visual editor, or the text editor.
     316             :      */
     317           0 :     void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast = true){
     318           0 :         bInsertIntoEditWindow = bEditWindowHadFocusLast;
     319           0 :     }
     320             :     bool IsInlineEditEnabled() const;
     321             : };
     322             : 
     323             : #endif
     324             : 
     325             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10