LCOV - code coverage report
Current view: top level - starmath/inc - view.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 18 23 78.3 %
Date: 2014-11-03 Functions: 17 22 77.3 %
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 INCLUDED_STARMATH_INC_VIEW_HXX
      20             : #define INCLUDED_STARMATH_INC_VIEW_HXX
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <memory>
      25             : 
      26             : #include <sfx2/dockwin.hxx>
      27             : #include <sfx2/viewsh.hxx>
      28             : #include <svtools/scrwin.hxx>
      29             : #include <sfx2/ctrlitem.hxx>
      30             : #include <sfx2/shell.hxx>
      31             : #include <sfx2/viewfac.hxx>
      32             : #include <sfx2/viewfrm.hxx>
      33             : #include <vcl/timer.hxx>
      34             : #include <svtools/colorcfg.hxx>
      35             : #include "edit.hxx"
      36             : #include "node.hxx"
      37             : 
      38             : class Menu;
      39             : class DataChangedEvent;
      40             : class SmClipboardChangeListener;
      41             : class SmDocShell;
      42             : class SmViewShell;
      43             : class SmPrintUIOptions;
      44             : class SmGraphicAccessible;
      45             : 
      46             : /**************************************************************************/
      47             : 
      48             : class SmGraphicWindow : public ScrollableWindow
      49             : {
      50             :     Point     aFormulaDrawPos;
      51             : 
      52             :     // old style editing pieces
      53             :     Rectangle aCursorRect;
      54             :     bool      bIsCursorVisible;
      55             :     bool      bIsLineVisible;
      56             :     AutoTimer aCaretBlinkTimer;
      57             : public:
      58          28 :     bool IsCursorVisible() const { return bIsCursorVisible; }
      59             :     void ShowCursor(bool bShow);
      60           0 :     bool IsLineVisible() const { return bIsLineVisible; }
      61             :     void ShowLine(bool bShow);
      62             :     const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
      63             : protected:
      64          32 :     void        SetIsCursorVisible(bool bVis) { bIsCursorVisible = bVis; }
      65             :     using   Window::SetCursor;
      66             :     void        SetCursor(const SmNode *pNode);
      67             :     void        SetCursor(const Rectangle &rRect);
      68             :     bool        IsInlineEditEnabled() const;
      69             : 
      70             : private:
      71             :     ::com::sun::star::uno::Reference<
      72             :         ::com::sun::star::accessibility::XAccessible >  xAccessible;
      73             :     SmGraphicAccessible *                                       pAccessible;
      74             : 
      75             :     SmViewShell    *pViewShell;
      76             :     sal_uInt16          nZoom;
      77             : 
      78             : protected:
      79          12 :     void        SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; }
      80             : 
      81             :     virtual void DataChanged( const DataChangedEvent& ) SAL_OVERRIDE;
      82             :     virtual void Paint(const Rectangle&) SAL_OVERRIDE;
      83             :     virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
      84             :     virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
      85             :     virtual void StateChanged( StateChangedType eChanged ) SAL_OVERRIDE;
      86             :     DECL_LINK(MenuSelectHdl, Menu *);
      87             : 
      88             : private:
      89             :     void RepaintViewShellDoc();
      90             :     DECL_LINK(CaretBlinkTimerHdl, void *);
      91             :     void CaretBlinkInit();
      92             :     void CaretBlinkStart();
      93             :     void CaretBlinkStop();
      94             : public:
      95             :     SmGraphicWindow(SmViewShell* pShell);
      96             :     virtual ~SmGraphicWindow();
      97             : 
      98             :     // Window
      99             :     virtual void    MouseButtonDown(const MouseEvent &rMEvt) SAL_OVERRIDE;
     100             :     virtual void    MouseMove(const MouseEvent &rMEvt) SAL_OVERRIDE;
     101             :     virtual void    GetFocus() SAL_OVERRIDE;
     102             :     virtual void    LoseFocus() SAL_OVERRIDE;
     103             : 
     104          22 :     SmViewShell *   GetView()   { return pViewShell; }
     105             : 
     106             :     using   Window::SetZoom;
     107             :     void   SetZoom(sal_uInt16 Factor);
     108             :     using   Window::GetZoom;
     109         110 :     sal_uInt16 GetZoom() const { return nZoom; }
     110             : 
     111           8 :     const Point &   GetFormulaDrawPos() const { return aFormulaDrawPos; }
     112             : 
     113             :     void ZoomToFitInWindow();
     114             :     using   ScrollableWindow::SetTotalSize;
     115             :     void SetTotalSize();
     116             : 
     117             :     void ApplyColorConfigValues( const svtools::ColorConfig &rColorCfg );
     118             : 
     119             :     // for Accessibility
     120             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
     121             : 
     122             :     using   Window::GetAccessible;
     123          12 :     SmGraphicAccessible *   GetAccessible_Impl()  { return pAccessible; }
     124             : };
     125             : 
     126             : /**************************************************************************/
     127             : 
     128          42 : class SmGraphicController: public SfxControllerItem
     129             : {
     130             : protected:
     131             :     SmGraphicWindow &rGraphic;
     132             : public:
     133             :     SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
     134             :     virtual void StateChanged(sal_uInt16             nSID,
     135             :                               SfxItemState       eState,
     136             :                               const SfxPoolItem* pState) SAL_OVERRIDE;
     137             : };
     138             : 
     139             : /**************************************************************************/
     140             : 
     141          42 : class SmEditController: public SfxControllerItem
     142             : {
     143             : protected:
     144             :     SmEditWindow &rEdit;
     145             : 
     146             : public:
     147             :     SmEditController(SmEditWindow &, sal_uInt16, SfxBindings  & );
     148             : #if OSL_DEBUG_LEVEL > 1
     149             :     virtual ~SmEditController();
     150             : #endif
     151             : 
     152             :     virtual void StateChanged(sal_uInt16             nSID,
     153             :                               SfxItemState       eState,
     154             :                               const SfxPoolItem* pState) SAL_OVERRIDE;
     155             : };
     156             : 
     157             : /**************************************************************************/
     158             : 
     159             : class SmCmdBoxWindow : public SfxDockingWindow
     160             : {
     161             :     SmEditWindow        aEdit;
     162             :     SmEditController    aController;
     163             :     bool                bExiting;
     164             : 
     165             :     Timer               aInitialFocusTimer;
     166             : 
     167             :     DECL_LINK(InitialFocusTimerHdl, Timer *);
     168             : 
     169             : protected :
     170             : 
     171             :     // Window
     172             :     virtual void    GetFocus() SAL_OVERRIDE;
     173             :     virtual void Resize() SAL_OVERRIDE;
     174             :     virtual void Paint(const Rectangle& rRect) SAL_OVERRIDE;
     175             :     virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
     176             : 
     177             :     virtual Size CalcDockingSize(SfxChildAlignment eAlign) SAL_OVERRIDE;
     178             :     virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
     179             :                                              SfxChildAlignment eWish) SAL_OVERRIDE;
     180             : 
     181             :     virtual void    ToggleFloatingMode() SAL_OVERRIDE;
     182             : 
     183             : public:
     184             :     SmCmdBoxWindow(SfxBindings    *pBindings,
     185             :                    SfxChildWindow *pChildWindow,
     186             :                    Window         *pParent);
     187             : 
     188             :     virtual ~SmCmdBoxWindow ();
     189             : 
     190             :     void AdjustPosition();
     191             : 
     192         186 :     SmEditWindow& GetEditWindow() { return aEdit; }
     193             :     SmViewShell  *GetView();
     194             : };
     195             : 
     196             : /**************************************************************************/
     197             : 
     198          68 : class SmCmdBoxWrapper : public SfxChildWindow
     199             : {
     200             :     SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
     201             : 
     202             : protected:
     203             :     SmCmdBoxWrapper(::vcl::Window   *pParentWindow,
     204             :                     sal_uInt16       nId,
     205             :                     SfxBindings     *pBindings,
     206             :                     SfxChildWinInfo *pInfo);
     207             : 
     208             : #if OSL_DEBUG_LEVEL > 1
     209             :     virtual ~SmCmdBoxWrapper();
     210             : #endif
     211             : 
     212             : public:
     213             : 
     214         136 :     SmEditWindow& GetEditWindow()
     215             :     {
     216         136 :         return (((SmCmdBoxWindow *)pWindow)->GetEditWindow());
     217             :     }
     218             : 
     219             : };
     220             : 
     221             : /**************************************************************************/
     222             : 
     223             : namespace sfx2 { class FileDialogHelper; }
     224             : struct SmViewShell_Impl;
     225             : 
     226             : class SmViewShell: public SfxViewShell
     227             : {
     228             :     // for handling the PasteClipboardState
     229             :     friend class SmClipboardChangeListener;
     230             : 
     231             :     std::unique_ptr<SmViewShell_Impl> pImpl;
     232             : 
     233             :     SmGraphicWindow     aGraphic;
     234             :     SmGraphicController aGraphicController;
     235             :     OUString            aStatusText;
     236             : 
     237             :     bool                bPasteState;
     238             : 
     239             :     DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
     240             :     virtual void            Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
     241             : 
     242             :     /** Used to determine whether insertions using SID_INSERTSYMBOL and SID_INSERTCOMMAND
     243             :      * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
     244             :      * visual editor was last to have focus.
     245             :      */
     246             :     bool bInsertIntoEditWindow;
     247             : protected:
     248             : 
     249             :     Size GetTextLineSize(OutputDevice& rDevice,
     250             :                          const OUString& rLine);
     251             :     Size GetTextSize(OutputDevice& rDevice,
     252             :                      const OUString& rText,
     253             :                      long          MaxWidth);
     254             :     void DrawTextLine(OutputDevice& rDevice,
     255             :                       const Point&  rPosition,
     256             :                       const OUString& rLine);
     257             :     void DrawText(OutputDevice& rDevice,
     258             :                   const Point&  rPosition,
     259             :                   const OUString& rText,
     260             :                   sal_uInt16        MaxWidth);
     261             : 
     262             :     virtual sal_uInt16 Print(SfxProgress &rProgress, bool bIsAPI);
     263             :     virtual SfxPrinter *GetPrinter(bool bCreate = false) SAL_OVERRIDE;
     264             :     virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
     265             :                               sal_uInt16     nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false) SAL_OVERRIDE;
     266             : 
     267             :     void Insert( SfxMedium& rMedium );
     268             :     void InsertFrom(SfxMedium &rMedium);
     269             : 
     270             :     virtual bool HasPrintOptionsPage() const SAL_OVERRIDE;
     271             :     virtual SfxTabPage *CreatePrintOptionsPage(::vcl::Window    *pParent,
     272             :                                                const SfxItemSet &rOptions) SAL_OVERRIDE;
     273             :     virtual void Deactivate(bool IsMDIActivate) SAL_OVERRIDE;
     274             :     virtual void Activate(bool IsMDIActivate) SAL_OVERRIDE;
     275             :     virtual void AdjustPosSizePixel(const Point &rPos, const Size &rSize) SAL_OVERRIDE;
     276             :     virtual void InnerResizePixel(const Point &rOfs, const Size  &rSize) SAL_OVERRIDE;
     277             :     virtual void OuterResizePixel(const Point &rOfs, const Size  &rSize) SAL_OVERRIDE;
     278             :     virtual void QueryObjAreaPixel( Rectangle& rRect ) const SAL_OVERRIDE;
     279             :     virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) SAL_OVERRIDE;
     280             : 
     281             : public:
     282             :     TYPEINFO_OVERRIDE();
     283             : 
     284             :     SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
     285             :     virtual ~SmViewShell();
     286             : 
     287         408 :     SmDocShell * GetDoc()
     288             :     {
     289         408 :         return (SmDocShell *) GetViewFrame()->GetObjectShell();
     290             :     }
     291             : 
     292             :     SmEditWindow * GetEditWindow();
     293         104 :           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          24 :     SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+2)
     303          24 :     SFX_DECL_VIEWFACTORY(SmViewShell);
     304             : 
     305             : private:
     306             :     /// SfxInterface initializer.
     307             :     static void InitInterface_Impl();
     308             : 
     309             : public:
     310             :     virtual void Execute( SfxRequest& rReq );
     311             :     virtual void GetState(SfxItemSet &);
     312             : 
     313             :     void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
     314             :             Rectangle aOutRect, Point aZeroPoint );
     315             : 
     316             :     /** Set bInsertIntoEditWindow so we know where to insert
     317             :      *
     318             :      * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
     319             :      * so that when text is inserted from catalog or elsewhere we know whether to
     320             :      * insert for the visual editor, or the text editor.
     321             :      */
     322           0 :     void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast = true){
     323           0 :         bInsertIntoEditWindow = bEditWindowHadFocusLast;
     324           0 :     }
     325             :     bool IsInlineEditEnabled() const;
     326             : };
     327             : 
     328             : #endif
     329             : 
     330             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10