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

Generated by: LCOV version 1.11