LCOV - code coverage report
Current view: top level - starmath/inc - document.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 13 15 86.7 %
Date: 2014-11-03 Functions: 13 15 86.7 %
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             : 
      20             : #ifndef INCLUDED_STARMATH_INC_DOCUMENT_HXX
      21             : #define INCLUDED_STARMATH_INC_DOCUMENT_HXX
      22             : 
      23             : #define SMDLL   1
      24             : 
      25             : #include <rtl/ustring.hxx>
      26             : #include <rtl/strbuf.hxx>
      27             : #include <sfx2/docfac.hxx>
      28             : #include <sfx2/objsh.hxx>
      29             : #include <sot/storage.hxx>
      30             : #include <svl/lstner.hxx>
      31             : #include <vcl/jobset.hxx>
      32             : #include <vcl/virdev.hxx>
      33             : #include <sax/fshelper.hxx>
      34             : #include <oox/core/filterbase.hxx>
      35             : #include <oox/mathml/import.hxx>
      36             : 
      37             : #include <set>
      38             : 
      39             : #include "format.hxx"
      40             : #include "parse.hxx"
      41             : #include "smmod.hxx"
      42             : 
      43             : class SmNode;
      44             : class SfxMenuBarManager;
      45             : class SfxPrinter;
      46             : class Printer;
      47             : class SmCursor;
      48             : 
      49             : #define STAROFFICE_XML  "StarOffice XML (Math)"
      50             : #define MATHML_XML      "MathML XML (Math)"
      51             : 
      52             : /* Access to printer should happen through this class only
      53             :  * ==========================================================================
      54             :  *
      55             :  * The printer can belong to the document or the OLE-Container. If the document
      56             :  * is an OLE-Document the printer generally belongs to the container too.
      57             :  * But the container maybe works with a different MapUnit than the server.
      58             :  * Referring to the MapMode the printer will be accordingly adjusted in the
      59             :  * constructor and restored in the destructor. This brings that this class
      60             :  * is always allowed to exists only a short time (e.g. while painting).
      61             :  * The control whether the printer is self-generated, gotten from the server
      62             :  * or is NULL then, is taken by the DocShell in the method GetPrt(), for
      63             :  * which the access is friend of the DocShell too.
      64             :  */
      65             : 
      66             : class SmDocShell;
      67             : class EditEngine;
      68             : 
      69             : 
      70             : 
      71             : class SmPrinterAccess
      72             : {
      73             :     Printer* pPrinter;
      74             :     OutputDevice* pRefDev;
      75             : public:
      76             :     SmPrinterAccess( SmDocShell &rDocShell );
      77             :     ~SmPrinterAccess();
      78           0 :     Printer* GetPrinter()  { return pPrinter; }
      79        2112 :     OutputDevice* GetRefDev()  { return pRefDev; }
      80             : };
      81             : 
      82             : 
      83             : 
      84             : 
      85             : void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
      86             : 
      87             : 
      88             : 
      89             : class SmDocShell : public SfxObjectShell, public SfxListener
      90             : {
      91             :     friend class SmPrinterAccess;
      92             :     friend class SmModel;
      93             :     friend class SmCursor;
      94             : 
      95             :     OUString            aText;
      96             :     SmFormat            aFormat;
      97             :     SmParser            aInterpreter;
      98             :     OUString            aAccText;
      99             :     SmNode             *pTree;
     100             :     SfxItemPool        *pEditEngineItemPool;
     101             :     EditEngine         *pEditEngine;
     102             :     SfxPrinter         *pPrinter;       //q.v. comment to SmPrinter Access!
     103             :     Printer            *pTmpPrinter;    //ditto
     104             :     sal_uInt16          nModifyCount;
     105             :     bool                bIsFormulaArranged;
     106             :     SmCursor           *pCursor;
     107             :     std::set< OUString >    aUsedSymbols;   // to export used symbols only when saving
     108             : 
     109             : 
     110             : 
     111             :     virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType,
     112             :                         const SfxHint& rHint, const TypeId& rHintType) SAL_OVERRIDE;
     113             : 
     114             :     bool        WriteAsMathType3( SfxMedium& );
     115             : 
     116             :     virtual void        Draw(OutputDevice *pDevice,
     117             :                              const JobSetup & rSetup,
     118             :                              sal_uInt16 nAspect = ASPECT_CONTENT) SAL_OVERRIDE;
     119             : 
     120             :     virtual void        FillClass(SvGlobalName* pClassName,
     121             :                                   sal_uInt32*  pFormat,
     122             :                                   OUString* pAppName,
     123             :                                   OUString* pFullTypeName,
     124             :                                   OUString* pShortTypeName,
     125             :                                   sal_Int32 nFileFormat,
     126             :                                   bool bTemplate = false ) const SAL_OVERRIDE;
     127             : 
     128             :     virtual bool        SetData( const OUString& rData );
     129             :     virtual sal_uLong       GetMiscStatus() const SAL_OVERRIDE;
     130             :     virtual void        OnDocumentPrinterChanged( Printer * ) SAL_OVERRIDE;
     131             :     virtual bool        InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
     132             :     virtual bool        Load( SfxMedium& rMedium ) SAL_OVERRIDE;
     133             :             void        ImplSave(  SvStorageStreamRef xStrm  );
     134             :     virtual bool        Save() SAL_OVERRIDE;
     135             :     virtual bool        SaveAs( SfxMedium& rMedium ) SAL_OVERRIDE;
     136             :     virtual bool        ConvertTo( SfxMedium &rMedium ) SAL_OVERRIDE;
     137             :     virtual bool        SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
     138             : 
     139             :     Printer             *GetPrt();
     140             :     OutputDevice*       GetRefDev();
     141             : 
     142       16284 :     bool                IsFormulaArranged() const { return bIsFormulaArranged; }
     143        7140 :     void                SetFormulaArranged(bool bVal) { bIsFormulaArranged = bVal; }
     144             : 
     145             :     virtual bool        ConvertFrom(SfxMedium &rMedium) SAL_OVERRIDE;
     146             : 
     147             :     /** Called whenever the formula is changed
     148             :      * Deletes the current cursor
     149             :      */
     150             :     void                InvalidateCursor();
     151             : 
     152             :     bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version );
     153             :     void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
     154             :     void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
     155             : 
     156             : public:
     157             :     TYPEINFO_OVERRIDE();
     158          24 :     SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
     159             : 
     160             :     using SotObject::GetInterface;
     161       18169 :     SFX_DECL_OBJECTFACTORY();
     162             : 
     163             : private:
     164             :     /// SfxInterface initializer.
     165             :     static void InitInterface_Impl();
     166             : 
     167             : public:
     168             :                 SmDocShell( const sal_uInt64 i_nSfxCreationFlags );
     169             :     virtual     ~SmDocShell();
     170             : 
     171             :     void        LoadSymbols();
     172             :     void        SaveSymbols();
     173             : 
     174             :     void        ArrangeFormula();
     175             : 
     176             :     //Access for the View. This access is not for the OLE-case!
     177             :     //and for the communication with the SFX!
     178             :     //All internal printer uses should work with the SmPrinterAccess only
     179         102 :     bool        HasPrinter()    { return 0 != pPrinter; }
     180        2338 :     SfxPrinter *GetPrinter()    { GetPrt(); return pPrinter; }
     181             :     void        SetPrinter( SfxPrinter * );
     182             : 
     183             :     const OUString GetComment() const;
     184             : 
     185             :     // to replace chars that can not be saved with the document...
     186             :     bool    ReplaceBadChars();
     187             : 
     188             :     void        UpdateText();
     189             :     void        SetText(const OUString& rBuffer);
     190        1462 :     OUString    GetText() { return (aText); }
     191             :     void        SetFormat(SmFormat& rFormat);
     192       74468 :     const SmFormat&  GetFormat() { return (aFormat); }
     193             : 
     194             :     void            Parse();
     195        1130 :     SmParser &      GetParser() { return aInterpreter; }
     196        1138 :     const SmNode *  GetFormulaTree() const  { return pTree; }
     197           4 :     void            SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
     198             : 
     199        2236 :     const std::set< OUString > &    GetUsedSymbols() const  { return aUsedSymbols; }
     200             : 
     201             :     OUString        GetAccessibleText();
     202             : 
     203             :     EditEngine &    GetEditEngine();
     204             :     SfxItemPool &   GetEditEngineItemPool();
     205             : 
     206             :     void        DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
     207             :     Size        GetSize();
     208             : 
     209             :     void        Repaint();
     210             : 
     211             :     virtual     ::svl::IUndoManager *GetUndoManager () SAL_OVERRIDE;
     212             : 
     213             :     virtual     SfxItemPool& GetPool() const;
     214             : 
     215             :     void        Execute( SfxRequest& rReq );
     216             :     void        GetState(SfxItemSet &);
     217             : 
     218             :     virtual void SetVisArea (const Rectangle & rVisArea) SAL_OVERRIDE;
     219             :     virtual void SetModified(bool bModified) SAL_OVERRIDE;
     220             : 
     221             :     /** Get a cursor for modifying this document
     222             :      * @remarks Don't store this reference, a new cursor may be made...
     223             :      */
     224             :     SmCursor&   GetCursor();
     225             :     /** True, if cursor have previously been requested and thus
     226             :      * has some sort of position.
     227             :      */
     228           0 :     bool        HasCursor() { return pCursor != NULL; }
     229             : };
     230             : 
     231             : #endif
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10