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

Generated by: LCOV version 1.11