2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-04 15:25:45 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2010-10-18 12:55:43 +01:00
|
|
|
|
2013-10-22 21:30:16 +02:00
|
|
|
#ifndef INCLUDED_STARMATH_INC_DOCUMENT_HXX
|
|
|
|
#define INCLUDED_STARMATH_INC_DOCUMENT_HXX
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <rtl/ustring.hxx>
|
2012-07-25 11:31:03 +02:00
|
|
|
#include <rtl/strbuf.hxx>
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <sfx2/docfac.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sfx2/objsh.hxx>
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <sot/storage.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/lstner.hxx>
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <vcl/jobset.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <vcl/virdev.hxx>
|
2011-08-16 13:56:29 +02:00
|
|
|
#include <sax/fshelper.hxx>
|
2011-08-16 16:58:37 +02:00
|
|
|
#include <oox/core/filterbase.hxx>
|
2011-11-18 21:06:54 +01:00
|
|
|
#include <oox/mathml/import.hxx>
|
2009-04-27 05:45:59 +00:00
|
|
|
|
2010-10-13 11:39:15 +02:00
|
|
|
#include <set>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "format.hxx"
|
|
|
|
#include "parse.hxx"
|
|
|
|
#include "smmod.hxx"
|
2015-01-12 00:45:17 +09:00
|
|
|
#include "smdllapi.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
class SmNode;
|
2006-10-12 12:49:09 +00:00
|
|
|
class SfxMenuBarManager;
|
2000-09-18 16:07:07 +00:00
|
|
|
class SfxPrinter;
|
|
|
|
class Printer;
|
2010-10-01 22:04:50 +02:00
|
|
|
class SmCursor;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-03-19 09:24:37 +00:00
|
|
|
#define STAROFFICE_XML "StarOffice XML (Math)"
|
|
|
|
#define MATHML_XML "MathML XML (Math)"
|
|
|
|
|
2011-02-17 15:52:17 +01:00
|
|
|
/* Access to printer should happen through this class only
|
2000-09-18 16:07:07 +00:00
|
|
|
* ==========================================================================
|
|
|
|
*
|
2011-02-17 15:52:17 +01:00
|
|
|
* The printer can belong to the document or the OLE-Container. If the document
|
|
|
|
* is an OLE-Document the printer generally belongs to the container too.
|
2014-03-29 18:44:37 +01:00
|
|
|
* But the container maybe works with a different MapUnit than the server.
|
2011-02-17 15:52:17 +01:00
|
|
|
* Referring to the MapMode the printer will be accordingly adjusted in the
|
|
|
|
* constructor and restored in the destructor. This brings that this class
|
|
|
|
* is always allowed to exists only a short time (e.g. while painting).
|
|
|
|
* The control whether the printer is self-generated, gotten from the server
|
|
|
|
* or is NULL then, is taken by the DocShell in the method GetPrt(), for
|
|
|
|
* which the access is friend of the DocShell too.
|
|
|
|
*/
|
2001-03-08 08:19:35 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
class SmDocShell;
|
2001-03-08 08:19:35 +00:00
|
|
|
class EditEngine;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-25 20:41:20 +01:00
|
|
|
|
2009-04-27 05:45:59 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
class SmPrinterAccess
|
|
|
|
{
|
2015-03-18 20:52:22 +00:00
|
|
|
VclPtr<Printer> pPrinter;
|
|
|
|
VclPtr<OutputDevice> pRefDev;
|
2000-09-18 16:07:07 +00:00
|
|
|
public:
|
|
|
|
SmPrinterAccess( SmDocShell &rDocShell );
|
|
|
|
~SmPrinterAccess();
|
2015-03-18 20:52:22 +00:00
|
|
|
Printer* GetPrinter() { return pPrinter.get(); }
|
|
|
|
OutputDevice* GetRefDev() { return pRefDev.get(); }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-25 20:41:20 +01:00
|
|
|
|
2005-05-03 12:50:49 +00:00
|
|
|
|
2011-06-28 16:41:42 +01:00
|
|
|
void SetEditEngineDefaultFonts(SfxItemPool &rEditEngineItemPool);
|
2005-05-03 12:50:49 +00:00
|
|
|
|
2014-02-25 20:41:20 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-01-12 00:45:17 +09:00
|
|
|
class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
friend class SmPrinterAccess;
|
2005-04-04 07:02:55 +00:00
|
|
|
friend class SmModel;
|
2010-10-01 22:04:50 +02:00
|
|
|
friend class SmCursor;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-07-16 07:47:27 -03:00
|
|
|
OUString aText;
|
2000-09-18 16:07:07 +00:00
|
|
|
SmFormat aFormat;
|
|
|
|
SmParser aInterpreter;
|
2012-10-29 19:15:56 +04:00
|
|
|
OUString aAccText;
|
2000-09-18 16:07:07 +00:00
|
|
|
SmNode *pTree;
|
2001-03-08 08:19:35 +00:00
|
|
|
SfxItemPool *pEditEngineItemPool;
|
|
|
|
EditEngine *pEditEngine;
|
2015-03-18 20:52:22 +00:00
|
|
|
VclPtr<SfxPrinter> pPrinter; //q.v. comment to SmPrinter Access!
|
|
|
|
VclPtr<Printer> pTmpPrinter; //ditto
|
2011-02-07 13:06:08 +01:00
|
|
|
sal_uInt16 nModifyCount;
|
2010-11-06 01:33:05 +01:00
|
|
|
bool bIsFormulaArranged;
|
2010-10-01 22:04:50 +02:00
|
|
|
SmCursor *pCursor;
|
2013-04-07 12:06:47 +02:00
|
|
|
std::set< OUString > aUsedSymbols; // to export used symbols only when saving
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-24 12:06:34 +02:00
|
|
|
virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool WriteAsMathType3( SfxMedium& );
|
2005-05-13 11:13:46 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
virtual void Draw(OutputDevice *pDevice,
|
|
|
|
const JobSetup & rSetup,
|
2014-03-27 18:12:18 +01:00
|
|
|
sal_uInt16 nAspect = ASPECT_CONTENT) SAL_OVERRIDE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
virtual void FillClass(SvGlobalName* pClassName,
|
2015-03-12 14:53:28 +02:00
|
|
|
SotClipboardFormatId* pFormat,
|
2013-03-05 10:35:52 +01:00
|
|
|
OUString* pAppName,
|
|
|
|
OUString* pFullTypeName,
|
|
|
|
OUString* pShortTypeName,
|
2008-12-12 12:52:51 +00:00
|
|
|
sal_Int32 nFileFormat,
|
2014-03-27 18:12:18 +01:00
|
|
|
bool bTemplate = false ) const SAL_OVERRIDE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-01-21 12:15:26 +02:00
|
|
|
virtual sal_uLong GetMiscStatus() const SAL_OVERRIDE;
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void OnDocumentPrinterChanged( Printer * ) SAL_OVERRIDE;
|
|
|
|
virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
|
|
|
|
virtual bool Load( SfxMedium& rMedium ) SAL_OVERRIDE;
|
|
|
|
virtual bool Save() SAL_OVERRIDE;
|
|
|
|
virtual bool SaveAs( SfxMedium& rMedium ) SAL_OVERRIDE;
|
|
|
|
virtual bool ConvertTo( SfxMedium &rMedium ) SAL_OVERRIDE;
|
|
|
|
virtual bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) SAL_OVERRIDE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-04-01 08:44:46 +00:00
|
|
|
Printer *GetPrt();
|
|
|
|
OutputDevice* GetRefDev();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
bool IsFormulaArranged() const { return bIsFormulaArranged; }
|
|
|
|
void SetFormulaArranged(bool bVal) { bIsFormulaArranged = bVal; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual bool ConvertFrom(SfxMedium &rMedium) SAL_OVERRIDE;
|
2001-05-30 12:08:34 +00:00
|
|
|
|
2010-10-01 22:04:50 +02:00
|
|
|
/** Called whenever the formula is changed
|
|
|
|
* Deletes the current cursor
|
|
|
|
*/
|
|
|
|
void InvalidateCursor();
|
|
|
|
|
2012-08-03 15:53:03 +02:00
|
|
|
bool writeFormulaOoxml( ::sax_fastparser::FSHelperPtr pSerializer, oox::core::OoxmlVersion version );
|
2012-07-27 14:12:42 +02:00
|
|
|
void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
|
2012-08-10 13:06:30 +02:00
|
|
|
void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
|
2011-08-16 13:56:29 +02:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
public:
|
2014-03-26 11:54:10 +01:00
|
|
|
TYPEINFO_OVERRIDE();
|
2007-05-25 11:08:57 +00:00
|
|
|
SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+1)
|
2014-04-18 18:04:32 +02:00
|
|
|
|
2004-10-04 17:02:50 +00:00
|
|
|
SFX_DECL_OBJECTFACTORY();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-04-18 18:04:32 +02:00
|
|
|
private:
|
|
|
|
/// SfxInterface initializer.
|
|
|
|
static void InitInterface_Impl();
|
|
|
|
|
|
|
|
public:
|
2015-04-09 16:35:22 +02:00
|
|
|
SmDocShell( SfxModelFlags i_nSfxCreationFlags );
|
2000-09-18 16:07:07 +00:00
|
|
|
virtual ~SmDocShell();
|
|
|
|
|
2015-05-05 13:11:02 +02:00
|
|
|
static void LoadSymbols();
|
|
|
|
static void SaveSymbols();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-05-05 06:58:09 +00:00
|
|
|
void ArrangeFormula();
|
|
|
|
|
2011-02-17 15:52:17 +01:00
|
|
|
//Access for the View. This access is not for the OLE-case!
|
|
|
|
//and for the communication with the SFX!
|
|
|
|
//All internal printer uses should work with the SmPrinterAccess only
|
2015-04-29 08:47:21 +02:00
|
|
|
bool HasPrinter() { return pPrinter != nullptr; }
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxPrinter *GetPrinter() { GetPrt(); return pPrinter; }
|
|
|
|
void SetPrinter( SfxPrinter * );
|
|
|
|
|
2013-09-03 18:29:30 +02:00
|
|
|
const OUString GetComment() const;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-06-27 11:39:43 +00:00
|
|
|
// to replace chars that can not be saved with the document...
|
2014-04-24 12:22:08 +02:00
|
|
|
bool ReplaceBadChars();
|
2007-06-27 11:39:43 +00:00
|
|
|
|
2006-05-05 06:58:09 +00:00
|
|
|
void UpdateText();
|
2013-01-21 14:32:09 +01:00
|
|
|
void SetText(const OUString& rBuffer);
|
2015-02-11 13:20:49 +02:00
|
|
|
OUString GetText() { return aText; }
|
2000-09-18 16:07:07 +00:00
|
|
|
void SetFormat(SmFormat& rFormat);
|
2015-02-11 13:20:49 +02:00
|
|
|
const SmFormat& GetFormat() { return aFormat; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void Parse();
|
|
|
|
SmParser & GetParser() { return aInterpreter; }
|
|
|
|
const SmNode * GetFormulaTree() const { return pTree; }
|
2001-03-08 08:19:35 +00:00
|
|
|
void SetFormulaTree(SmNode *&rTree) { pTree = rTree; }
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
const std::set< OUString > & GetUsedSymbols() const { return aUsedSymbols; }
|
2010-10-13 11:39:15 +02:00
|
|
|
|
2012-10-29 19:15:56 +04:00
|
|
|
OUString GetAccessibleText();
|
2002-05-24 06:48:49 +00:00
|
|
|
|
2001-03-08 08:19:35 +00:00
|
|
|
EditEngine & GetEditEngine();
|
|
|
|
SfxItemPool & GetEditEngineItemPool();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-06 01:33:05 +01:00
|
|
|
void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
|
2000-09-18 16:07:07 +00:00
|
|
|
Size GetSize();
|
|
|
|
|
2004-11-15 15:42:02 +00:00
|
|
|
void Repaint();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-01-21 12:15:26 +02:00
|
|
|
virtual ::svl::IUndoManager *GetUndoManager () SAL_OVERRIDE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-05-05 13:11:02 +02:00
|
|
|
static SfxItemPool& GetPool();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
void Execute( SfxRequest& rReq );
|
|
|
|
void GetState(SfxItemSet &);
|
|
|
|
|
2014-03-27 18:12:18 +01:00
|
|
|
virtual void SetVisArea (const Rectangle & rVisArea) SAL_OVERRIDE;
|
|
|
|
virtual void SetModified(bool bModified) SAL_OVERRIDE;
|
2010-10-01 22:04:50 +02:00
|
|
|
|
|
|
|
/** Get a cursor for modifying this document
|
|
|
|
* @remarks Don't store this reference, a new cursor may be made...
|
|
|
|
*/
|
|
|
|
SmCursor& GetCursor();
|
|
|
|
/** True, if cursor have previously been requested and thus
|
|
|
|
* has some sort of position.
|
|
|
|
*/
|
2010-11-06 01:33:05 +01:00
|
|
|
bool HasCursor() { return pCursor != NULL; }
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|