22#include <com/sun/star/accessibility/AccessibleEventId.hpp>
23#include <com/sun/star/uno/Any.h>
27#include <rtl/ustrbuf.hxx>
28#include <rtl/ustring.hxx>
57#include <document.hxx>
62#include <starmath.hrc>
66#include <unomodel.hxx>
75#include <svx/svxids.hrc>
90#define ShellClass_SmDocShell
98 GetStaticInterface()->RegisterPopupMenu(
"view");
111 if (rHint.GetId() == SfxHintId::MathFormatChanged)
113 SetFormulaArranged(
false);
130 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
132 uno::Reference<document::XDocumentProperties> xDocProps(
133 xDPS->getDocumentProperties());
134 return xDocProps->getDescription();
177 Any aOldValue, aNewValue;
180 pAcc->
LaunchEvent( AccessibleEventId::TEXT_CHANGED,
181 aOldValue, aNewValue );
212 OSL_ENSURE(
mpTree,
"Tree missing" );
245 SAL_WARN_IF( !pOutDev,
"starmath",
"!! SmDocShell::ArrangeFormula: reference device missing !!");
251 pOutDev = &pView->GetGraphicWidget().GetDrawingArea()->get_ref_device();
254 pOutDev = &
SM_MOD()->GetDefaultVirtualDev();
259 "Sm : wrong MapMode");
262 mpTree->Prepare(rFormat, *
this, 0);
271 mpTree->Arrange(*pOutDev, rFormat);
314 OSL_ENSURE(
mpTree,
"Sm : NULL pointer");
331 bool bRestoreDrawMode =
false;
337 bRestoreDrawMode =
true;
360 if (bRestoreDrawMode)
409 if ( SfxObjectCreateMode::EMBEDDED == rDocShell.
GetCreateMode() )
426 aMap.SetOrigin( aTmp );
436 if ( SfxObjectCreateMode::EMBEDDED != rDocShell.
GetCreateMode() )
454 aMap.SetOrigin( aTmp );
482 SID_PRINTTITLE, SID_PRINTZOOM,
483 SID_NO_RIGHT_SPACES, SID_SAVE_ONLY_USED_SYMBOLS,
484 SID_AUTO_CLOSE_BRACKETS, SID_SMEDITWINDOWZOOM>>(
GetPool());
486 pp->GetConfig()->ConfigToItemSet(*pOptions);
536 pViewSh->GetGraphicWidget().Invalidate();
544 , m_pMlElementTree(nullptr)
546 , mpTmpPrinter(nullptr)
548 , mbFormulaArranged(false)
549 , mnSmSyntaxVersion(
SM_MOD()->GetConfig()->GetDefaultSmSyntaxVersion())
584 bool bSuccess =
false;
585 const OUString& rFltName = rMedium.
GetFilter()->GetFilterName();
609 if ( aStorage->IsStream(
"Equation Native") )
614 bSuccess = aEquation.
Parse( aStorage.
get() );
654 if (xStorage->hasByName(
"content.xml") && xStorage->isStreamElement(
"content.xml"))
659 auto nError = aEquation.
Import(rMedium);
702 bool bReplace =
false;
709 for (sal_Int32
i = 0;
i <
aBuf.getLength(); ++
i)
751 bRet = aEquation.
Export(rMedium);
759 std::shared_ptr<const SfxFilter> pFlt = rMedium.
GetFilter();
767 const OUString& rFltName = pFlt->GetFilterName();
773 bRet = aEquation.
Export(rMedium);
781 bRet = aEquation.
Export(rMedium);
783 else if (pFlt->GetFilterName() ==
"MathType 3.x")
803 aEquation.
ConvertFromStarMath(pSerializer, oox::FormulaImExportBase::eFormulaAlign::INLINE);
835 std::make_unique<SmFormatAction>(
this, aOldFormat, aNewFormat));
842 case SID_AUTO_REDRAW :
850 case SID_LOADSYMBOLS:
854 case SID_SAVESYMBOLS:
863 pDev = &
SM_MOD()->GetDefaultVirtualDev();
864 OSL_ENSURE (pDev,
"device for font list missing" );
869 aFontTypeDialog.
ReadFrom( aOldFormat );
874 aFontTypeDialog.
WriteTo(aNewFormat);
878 std::make_unique<SmFormatAction>(
this, aOldFormat, aNewFormat));
891 aFontSizeDialog.
ReadFrom( aOldFormat );
896 aFontSizeDialog.
WriteTo(aNewFormat);
901 std::make_unique<SmFormatAction>(
this, aOldFormat, aNewFormat));
914 aDistanceDialog.
ReadFrom( aOldFormat );
919 aDistanceDialog.
WriteTo(aNewFormat);
924 std::make_unique<SmFormatAction>(
this, aOldFormat, aNewFormat));
937 aAlignDialog.
ReadFrom( aOldFormat );
942 aAlignDialog.
WriteTo(aNewFormat);
952 std::make_unique<SmFormatAction>(
this, aOldFormat, aNewFormat));
977 if( pArgs && SfxItemState::SET == pArgs->
GetItemState(
nId,
false, &pItem ))
983 if( SID_UNDO == rReq.
GetSlot() )
997 (pTmpUndoMgr->*fnDo)();
1036 case SID_DOCTEMPLATE :
1040 case SID_AUTO_REDRAW :
1049 case SID_MODIFYSTATUS:
1062 case SID_GRAPHIC_SM:
1081 case SID_GETUNDOSTRINGS:
1082 case SID_GETREDOSTRINGS:
1087 OUString(
SfxUndoManager::*fnGetComment)( size_t,
bool const )
const;
1090 if( SID_GETUNDOSTRINGS == nWh )
1102 OUStringBuffer
aBuf;
1175 bUnLockFrame =
true;
1178 bUnLockFrame =
false;
1192 OUString* pFullTypeName,
1193 sal_Int32 nFileFormat,
1194 bool bTemplate )
const
1199 *pFormat = SotClipboardFormatId::STARMATH_60;
1200 *pFullTypeName =
SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT);
1205 *pFormat = bTemplate ? SotClipboardFormatId::STARMATH_8_TEMPLATE : SotClipboardFormatId::STARMATH_8;
1206 *pFullTypeName =
SmResId(STR_MATH_DOCUMENT_FULLTYPE_CURRENT);
1215 Broadcast(
SfxHint(SfxHintId::DocChanged));
1221 OUStringBuffer aTextAsBuffer(
maText);
SfxApplication * SfxGetpApp()
const StyleSettings & GetStyleSettings() const
const OUString & GetValue() const
static rtl::Reference< SfxItemPool > CreatePool()
static OUString GetEventName(GlobalEventId nID)
MapUnit GetMapUnit() const
bool Parse(SotStorage *pStor)
bool ConvertFromStarMath(SfxMedium &rMedium)
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
void SetDigitLanguage(LanguageType)
vcl::text::ComplexTextLayoutFlags GetLayoutMode() const
int GetFontFaceCollectionCount() const
const MapMode & GetMapMode() const
void SetDrawMode(DrawModeFlags nDrawMode)
OutDevType GetOutDevType() const
void SetLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode)
DrawModeFlags GetDrawMode() const
void IntersectClipRegion(const tools::Rectangle &rRect)
LanguageType GetDigitLanguage() const
virtual vcl::Window * GetOwnerWindow() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
void NotifyEvent(const SfxEventHint &rEvent, bool bSynchron=true)
void Invalidate(sal_uInt16 nId)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void DisableItem(sal_uInt16 nWhich)
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
const std::shared_ptr< const SfxFilter > & GetFilter() const
css::uno::Reference< css::embed::XStorage > GetStorage(bool bCreateTempFile=true)
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
void SetError(ErrCode rErr)
virtual OutputDevice * GetDocumentRefDev()
virtual bool Load(SfxMedium &rMedium)
virtual bool SaveAs(SfxMedium &rMedium)
bool IsEnableSetModified() const
virtual void SetVisArea(const tools::Rectangle &rVisArea)
void SetVisAreaSize(const Size &rVisSize)
void SetMapUnit(MapUnit nMUnit)
void FinishedLoading(SfxLoadedFlags nWhich=SfxLoadedFlags::ALL)
SfxMedium * GetMedium() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
const tools::Rectangle & GetVisArea() const
void EnableSetModified(bool bEnable=true)
virtual Printer * GetDocumentPrinter()
SfxObjectCreateMode GetCreateMode() const
bool IsInPlaceActive() const
virtual void SetModified(bool bModified=true)
void SetBaseModel(SfxBaseModel *pModel)
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
weld::Window * GetFrameWeld() const
void Done(bool bRemove=false)
const SfxPoolItem * GetSlotState(sal_uInt16 nSlotId, const SfxInterface *pIF=nullptr, SfxItemSet *pStateSet=nullptr)
SfxItemPool & GetPool() const
SfxViewFrame * GetFrame() const
void SetPool(SfxItemPool *pNewPool)
void SetString(const OUString &)
OUString GetRedoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
OUString GetUndoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
static bool const TopLevel
virtual size_t GetRedoActionCount(bool const i_currentLevel=CurrentLevel) const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
virtual size_t GetUndoActionCount(bool const i_currentLevel=CurrentLevel) const
void LockAdjustPosSizePixel()
SfxBindings & GetBindings()
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static SAL_WARN_UNUSED_RESULT SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
void UnlockAdjustPosSizePixel()
SfxViewFrame & GetViewFrame() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
void setWidth(tools::Long nWidth)
tools::Long AdjustWidth(tools::Long n)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
void WriteTo(SmFormat &rFormat) const
void ReadFrom(const SmFormat &rFormat)
void ReadFrom(const SmFormat &rFormat)
void WriteTo(SmFormat &rFormat)
void SetFormat(SmFormat const &rFormat)
OUString GetComment() const
void SetText(const OUString &rBuffer)
OUString const & GetAccessibleText()
void writeFormulaRtf(OStringBuffer &rBuffer, rtl_TextEncoding nEncoding)
virtual void OnDocumentPrinterChanged(Printer *) override
virtual ~SmDocShell() override
void GetState(SfxItemSet &)
virtual void SetVisArea(const tools::Rectangle &rVisArea) override
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage) override
SmDocShell(SfxModelFlags i_nSfxCreationFlags)
EditEngine & GetEditEngine()
void SetFormulaArranged(bool bVal)
SfxPrinter * GetPrinter()
bool HasCursor() const
True, if cursor have previously been requested and thus has some sort of position.
virtual bool Save() override
void SetPrinter(SfxPrinter *)
VclPtr< SfxPrinter > mpPrinter
SmCursor & GetCursor()
Get a cursor for modifying this document.
virtual bool ConvertFrom(SfxMedium &rMedium) override
static SfxItemPool & GetPool()
const OUString & GetText() const
std::unique_ptr< SmCursor > mpCursor
virtual bool SaveAs(SfxMedium &rMedium) override
bool WriteAsMathType3(SfxMedium &)
void InvalidateCursor()
Called whenever the formula is changed Deletes the current cursor.
virtual void Draw(OutputDevice *pDevice, const JobSetup &rSetup, sal_uInt16 nAspect, bool bOutputForScreen) override
void SetSmSyntaxVersion(sal_uInt16 nSmSyntaxVersion)
virtual SfxUndoManager * GetUndoManager() override
SmMlElement * m_pMlElementTree
static void LoadSymbols()
std::unique_ptr< AbstractSmParser > maParser
static void SaveSymbols()
std::set< OUString > maUsedSymbols
OutputDevice * GetRefDev()
std::unique_ptr< SmTableNode > mpTree
void Execute(SfxRequest &rReq)
virtual bool ConvertTo(SfxMedium &rMedium) override
void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection=false)
virtual void SetModified(bool bModified=true) override
VclPtr< Printer > mpTmpPrinter
void UpdateEditEngineDefaultFonts()
const SmFormat & GetFormat() const
rtl::Reference< SfxItemPool > mpEditEngineItemPool
std::unique_ptr< SmEditEngine > mpEditEngine
void readFormulaOoxml(oox::formulaimport::XmlStream &stream)
SvtLinguOptions maLinguOptions
virtual bool Load(SfxMedium &rMedium) override
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nFileFormat, bool bTemplate=false) const override
sal_uInt16 mnSmSyntaxVersion
void writeFormulaOoxml(const ::sax_fastparser::FSHelperPtr &pSerializer, oox::core::OoxmlVersion version, oox::drawingml::DocumentType documentType, const sal_Int8 nAlign)
Visitor for drawing SmNodes to OutputDevice.
static void setSmItemPool(SfxItemPool *mpItemPool, const SvtLinguOptions &maLangOptions)
Sets up default font parameters for the item pool.
void ReadFrom(const SmFormat &rFormat)
void WriteTo(SmFormat &rFormat) const
void ReadFrom(const SmFormat &rFormat)
void WriteTo(SmFormat &rFormat) const
void LaunchEvent(const sal_Int16 nAccessibleEventId, const css::uno::Any &rOldVal, const css::uno::Any &rNewVal)
const SmFormat & GetStandardFormat() const
bool IsAutoRedraw() const
void SetAutoRedraw(bool bVal)
void SetStandardFormat(const SmFormat &rFormat, bool bSaveFontFormatList=false)
SmMathConfig * GetConfig()
SmSymbolManager & GetSymbolManager()
Class implementing writing of formulas to OOXML.
void ConvertFromStarMath(const ::sax_fastparser::FSHelperPtr &m_pSerializer, const sal_Int8)
Class implementing reading of formulas from OOXML.
OUString ConvertToStarMath()
SmPrinterAccess(SmDocShell &rDocShell)
VclPtr< Printer > pPrinter
OutputDevice * GetRefDev()
VclPtr< OutputDevice > pRefDev
Class implementing writing of formulas to RTF.
void ConvertFromStarMath(OStringBuffer &rBuffer, rtl_TextEncoding nEncoding)
SmGraphicWidget & GetGraphicWidget()
void SetUseHTMLMLEntities(bool bUseHTMLMLEntities)
bool Export(SfxMedium &rMedium)
ErrCode Import(SfxMedium &rMedium)
void useHTMLMLEntities(bool bUseHTMLMLEntities)
static bool IsStorageFile(OUString const &rFileName)
bool GetHighContrastMode() const
void GetOptions(SvtLinguOptions &rOptions) const
reference_type * get() const
static VclPtr< reference_type > Create(Arg &&... arg)
static bool implInitTextChangedEvent(std::u16string_view rOldString, std::u16string_view rNewString, css::uno::Any &rDeleted, css::uno::Any &rInserted)
#define SO3_SM_CLASSID_60
const AllSettings & GetSettings() const
#define DBG_UNHANDLED_EXCEPTION(...)
SFX_IMPL_SUPERCLASS_INTERFACE(DrawDocShell, SfxObjectShell)
Reference< XOutputStream > stream
constexpr OUStringLiteral MATHML_XML
#define SAL_WARN_IF(condition, area, stream)
void SmMlIteratorFree(SmMlElement *pMlElementTree)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
SFX_IMPL_OBJECTFACTORY(DrawDocShell, SvGlobalName(SO3_SIMPRESS_CLASSID), "simpress") void DrawDocShell
AbstractSmParser * GetVersionSmParser(sal_uInt16 nVersion)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
HashMap_OWString_Interface aMap
OUString SmResId(TranslateId aId)
Reference< XModel > xModel
SmViewShell * SmGetActiveView()
! Since this method is based on the current focus it is somewhat ! unreliable and may return unexpect...
std::unique_ptr< char[]> aBuffer