summaryrefslogtreecommitdiffstats
path: root/starmath/inc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--starmath/inc/AccessibleSmElement.hxx105
-rw-r--r--starmath/inc/AccessibleSmElementsControl.hxx108
-rw-r--r--starmath/inc/ElementsDockingWindow.hxx199
-rw-r--r--starmath/inc/action.hxx45
-rw-r--r--starmath/inc/caret.hxx428
-rw-r--r--starmath/inc/cursor.hxx427
-rw-r--r--starmath/inc/dialog.hxx486
-rw-r--r--starmath/inc/document.hxx220
-rw-r--r--starmath/inc/edit.hxx134
-rw-r--r--starmath/inc/error.hxx55
-rw-r--r--starmath/inc/format.hxx154
-rw-r--r--starmath/inc/helpids.h54
-rw-r--r--starmath/inc/node.hxx1272
-rw-r--r--starmath/inc/parse.hxx156
-rw-r--r--starmath/inc/pch/precompiled_sm.cxx12
-rw-r--r--starmath/inc/pch/precompiled_sm.hxx157
-rw-r--r--starmath/inc/rect.hxx219
-rw-r--r--starmath/inc/smdll.hxx31
-rw-r--r--starmath/inc/smdllapi.hxx23
-rw-r--r--starmath/inc/smmod.hrc92
-rw-r--r--starmath/inc/smmod.hxx108
-rw-r--r--starmath/inc/starmath.hrc74
-rw-r--r--starmath/inc/strings.hrc351
-rw-r--r--starmath/inc/strings.hxx274
-rw-r--r--starmath/inc/symbol.hxx106
-rw-r--r--starmath/inc/token.hxx142
-rw-r--r--starmath/inc/types.hxx203
-rw-r--r--starmath/inc/unomodel.hxx99
-rw-r--r--starmath/inc/utility.hxx147
-rw-r--r--starmath/inc/view.hxx319
-rw-r--r--starmath/inc/visitors.hxx462
31 files changed, 6662 insertions, 0 deletions
diff --git a/starmath/inc/AccessibleSmElement.hxx b/starmath/inc/AccessibleSmElement.hxx
new file mode 100644
index 000000000..202de6690
--- /dev/null
+++ b/starmath/inc/AccessibleSmElement.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENT_HXX
+#define INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENT_HXX
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleAction.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase3.hxx>
+#include <comphelper/accessiblecomponenthelper.hxx>
+#include <sal/types.h>
+#include <vcl/vclptr.hxx>
+
+class SmElementsControl;
+
+typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::accessibility::XAccessible,
+ css::accessibility::XAccessibleAction>
+ AccessibleSmElement_BASE;
+
+class AccessibleSmElement final : public comphelper::OAccessibleComponentHelper,
+ public AccessibleSmElement_BASE
+{
+ SmElementsControl* m_pSmElementsControl;
+ const sal_Int32 m_nIndexInParent; ///< index in the parent XAccessible
+ const sal_uInt16 m_nItemId; ///< index in the SmElementsControl
+ bool m_bHasFocus;
+ sal_Int16 m_nRole;
+
+ ~AccessibleSmElement() override;
+ void SAL_CALL disposing() override;
+ css::awt::Rectangle implGetBounds() override;
+
+ void testAction(sal_Int32) const;
+
+public:
+ explicit AccessibleSmElement(SmElementsControl* pSmElementsControl, sal_uInt16 nItemId,
+ sal_Int32 nIndexInParent);
+
+ void SetFocus(bool _bFocus);
+ sal_uInt16 itemId() const { return m_nItemId; }
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XAccessible
+ css::uno::Reference<css::accessibility::XAccessibleContext>
+ SAL_CALL getAccessibleContext() override;
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() override;
+ sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override;
+ css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XAccessibleContext
+ sal_Int32 SAL_CALL getAccessibleChildCount() override;
+ css::uno::Reference<css::accessibility::XAccessible>
+ SAL_CALL getAccessibleChild(sal_Int32 i) override;
+ css::uno::Reference<css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override;
+ sal_Int32 SAL_CALL getAccessibleIndexInParent() override;
+ sal_Int16 SAL_CALL getAccessibleRole() override;
+ OUString SAL_CALL getAccessibleDescription() override;
+ OUString SAL_CALL getAccessibleName() override;
+ css::uno::Reference<css::accessibility::XAccessibleRelationSet>
+ SAL_CALL getAccessibleRelationSet() override;
+ css::uno::Reference<css::accessibility::XAccessibleStateSet>
+ SAL_CALL getAccessibleStateSet() override;
+
+ // XAccessibleComponent
+ css::uno::Reference<css::accessibility::XAccessible>
+ SAL_CALL getAccessibleAtPoint(const css::awt::Point& aPoint) override;
+ void SAL_CALL grabFocus() override;
+ sal_Int32 SAL_CALL getForeground() override;
+ sal_Int32 SAL_CALL getBackground() override;
+
+ // XAccessibleAction
+ sal_Int32 SAL_CALL getAccessibleActionCount() override;
+ sal_Bool SAL_CALL doAccessibleAction(sal_Int32 nIndex) override;
+ OUString SAL_CALL getAccessibleActionDescription(sal_Int32 nIndex) override;
+ css::uno::Reference<css::accessibility::XAccessibleKeyBinding>
+ SAL_CALL getAccessibleActionKeyBinding(sal_Int32 nIndex) override;
+};
+
+#endif // INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/AccessibleSmElementsControl.hxx b/starmath/inc/AccessibleSmElementsControl.hxx
new file mode 100644
index 000000000..66cbd80bc
--- /dev/null
+++ b/starmath/inc/AccessibleSmElementsControl.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENTSCONTROL_HXX
+#define INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENTSCONTROL_HXX
+
+#include <comphelper/accessiblecomponenthelper.hxx>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase3.hxx>
+#include <vcl/vclptr.hxx>
+
+#include <vector>
+
+class AccessibleSmElement;
+class SmElementsControl;
+
+typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::accessibility::XAccessible,
+ css::accessibility::XAccessibleSelection>
+ AccessibleSmElementsControl_BASE;
+
+class AccessibleSmElementsControl final : public comphelper::OAccessibleComponentHelper,
+ public AccessibleSmElementsControl_BASE
+{
+ std::vector<rtl::Reference<AccessibleSmElement>> m_aAccessibleChildren;
+ SmElementsControl* m_pControl;
+
+ void UpdateFocus(sal_uInt16);
+ inline void TestControl();
+
+ ~AccessibleSmElementsControl() override;
+ void SAL_CALL disposing() override;
+ css::awt::Rectangle implGetBounds() override;
+
+public:
+ AccessibleSmElementsControl(SmElementsControl& rControl);
+
+ void ReleaseAllItems();
+ void AddAllItems();
+ inline void AcquireFocus();
+ inline void ReleaseFocus(sal_uInt16);
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XAccessible
+ css::uno::Reference<css::accessibility::XAccessibleContext>
+ SAL_CALL getAccessibleContext() override;
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() override;
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
+
+ // XAccessibleComponent
+ sal_Bool SAL_CALL containsPoint(const css::awt::Point& aPoint) override;
+ css::uno::Reference<css::accessibility::XAccessible>
+ SAL_CALL getAccessibleAtPoint(const css::awt::Point& aPoint) override;
+ void SAL_CALL grabFocus() override;
+ sal_Int32 SAL_CALL getForeground() override;
+ sal_Int32 SAL_CALL getBackground() override;
+
+ // XAccessibleContext
+ sal_Int32 SAL_CALL getAccessibleChildCount() override;
+ css::uno::Reference<css::accessibility::XAccessible>
+ SAL_CALL getAccessibleChild(sal_Int32 i) override;
+ css::uno::Reference<css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override;
+ sal_Int16 SAL_CALL getAccessibleRole() override;
+ OUString SAL_CALL getAccessibleDescription() override;
+ OUString SAL_CALL getAccessibleName() override;
+ css::uno::Reference<css::accessibility::XAccessibleRelationSet>
+ SAL_CALL getAccessibleRelationSet() override;
+ css::uno::Reference<css::accessibility::XAccessibleStateSet>
+ SAL_CALL getAccessibleStateSet() override;
+
+ // XAccessibleSelection
+ void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override;
+ sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override;
+ void SAL_CALL clearAccessibleSelection() override;
+ void SAL_CALL selectAllAccessibleChildren() override;
+ sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override;
+ css::uno::Reference<css::accessibility::XAccessible>
+ SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override;
+ void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override;
+};
+
+void AccessibleSmElementsControl::AcquireFocus() { UpdateFocus(SAL_MAX_UINT16); }
+
+void AccessibleSmElementsControl::ReleaseFocus(sal_uInt16 nPos) { UpdateFocus(nPos); }
+
+#endif // INCLUDED_STARMATH_INC_ACCESSIBLESMELEMENTSCONTROL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/ElementsDockingWindow.hxx b/starmath/inc/ElementsDockingWindow.hxx
new file mode 100644
index 000000000..e10273b88
--- /dev/null
+++ b/starmath/inc/ElementsDockingWindow.hxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
+#define INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
+
+#include <sfx2/dockwin.hxx>
+#include <vcl/customweld.hxx>
+#include <vcl/weld.hxx>
+
+#include "format.hxx"
+#include <memory>
+#include <tuple>
+
+#include "AccessibleSmElementsControl.hxx"
+
+class SmDocShell;
+class SmNode;
+class SmParser;
+
+class SmElement
+{
+ std::unique_ptr<SmNode> mpNode;
+ OUString maText;
+ OUString maHelpText;
+
+public:
+ Point mBoxLocation;
+ Size mBoxSize;
+
+ SmElement(std::unique_ptr<SmNode>&& pNode, const OUString& aText, const OUString& aHelpText);
+ virtual ~SmElement();
+
+ const std::unique_ptr<SmNode>& getNode() const;
+ const OUString& getText() const { return maText; }
+ const OUString& getHelpText() const { return maHelpText; }
+
+ virtual bool isSeparator() const { return false; }
+};
+
+class SmElementSeparator final : public SmElement
+{
+public:
+ SmElementSeparator();
+
+ bool isSeparator() const override { return true; }
+};
+
+typedef std::pair<const char*, const char*> SmElementDescr;
+
+class SmElementsControl : public weld::CustomWidgetController
+{
+ friend class ElementSelectorUIObject;
+ friend class ElementUIObject;
+
+ static const SmElementDescr m_aUnaryBinaryOperatorsList[];
+ static const SmElementDescr m_aRelationsList[];
+ static const SmElementDescr m_aSetOperationsList[];
+ static const SmElementDescr m_aFunctionsList[];
+ static const SmElementDescr m_aOperatorsList[];
+ static const SmElementDescr m_aAttributesList[];
+ static const SmElementDescr m_aBracketsList[];
+ static const SmElementDescr m_aFormatsList[];
+ static const SmElementDescr m_aOthersList[];
+ static const SmElementDescr m_aExamplesList[];
+ static const std::tuple<const char*, const SmElementDescr*, size_t> m_aCategories[];
+ static const size_t m_aCategoriesSize;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
+ virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
+ virtual bool MouseMove(const MouseEvent& rMEvt) override;
+ virtual OUString RequestHelp(tools::Rectangle& rRect) override;
+ virtual void Resize() override;
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
+ virtual bool KeyInput(const KeyEvent& rKEvt) override;
+ css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
+
+ SmDocShell* mpDocShell;
+ SmFormat maFormat;
+ OString msCurrentSetId;
+ sal_uInt16 m_nCurrentElement;
+ sal_uInt16 m_nCurrentRolloverElement;
+ sal_uInt16 m_nCurrentOffset;
+ Link<SmElement&,void> maSelectHdlLink;
+
+ std::vector< std::unique_ptr<SmElement> > maElementList;
+ Size maMaxElementDimensions;
+ bool mbVerticalMode;
+ std::unique_ptr<weld::ScrolledWindow> mxScroll;
+ bool m_bFirstPaintAfterLayout;
+ rtl::Reference<AccessibleSmElementsControl> m_xAccessible;
+
+ void addElement(SmParser &rParser, const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText);
+ void addElements(const SmElementDescr aElementsArray[], sal_uInt16 size);
+ SmElement* current() const;
+ void setCurrentElement(sal_uInt16);
+ bool hasRollover() const { return m_nCurrentRolloverElement != SAL_MAX_UINT16; }
+
+ void stepFocus(const bool bBackward);
+ void pageFocus(const bool bBackward);
+ // common code of page and step focus
+ inline void scrollToElement(const bool, const SmElement*);
+ inline sal_uInt16 nextElement(const bool, const sal_uInt16, const sal_uInt16);
+
+ void build();
+
+ //if bDraw is true, then draw, otherwise just layout
+ void LayoutOrPaintContents(vcl::RenderContext& rContext, bool bDraw);
+
+public:
+ explicit SmElementsControl(std::unique_ptr<weld::ScrolledWindow> xScrolledWindow);
+ virtual ~SmElementsControl() override;
+
+ static const auto& categories() { return m_aCategories; }
+ static size_t categoriesSize() { return m_aCategoriesSize; }
+ const OString& elementSetId() const { return msCurrentSetId; }
+ void setElementSetId(const char* pSetId);
+
+ void setVerticalMode(bool bVertical);
+
+ sal_uInt16 itemCount() const;
+ sal_uInt16 itemHighlighted() const;
+ sal_uInt16 itemAtPos(const Point& rPos) const;
+ tools::Rectangle itemPosRect(sal_uInt16) const;
+ bool itemIsSeparator(sal_uInt16) const;
+ bool itemIsVisible(sal_uInt16) const;
+ OUString itemName(sal_uInt16) const;
+ bool itemTrigger(sal_uInt16);
+ void setItemHighlighted(sal_uInt16);
+ sal_uInt16 itemOffset() const { return m_nCurrentOffset; }
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+
+ DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
+
+ void SetSelectHdl(const Link<SmElement&,void>& rLink) { maSelectHdlLink = rLink; }
+
+ rtl::Reference<AccessibleSmElementsControl> GetAccessible() const { return m_xAccessible; }
+ static Color GetTextColor();
+ static Color GetControlBackground();
+
+ virtual FactoryFunction GetUITestFactory() const override;
+};
+
+class SmElementsDockingWindow final : public SfxDockingWindow
+{
+ std::unique_ptr<SmElementsControl> mxElementsControl;
+ std::unique_ptr<weld::CustomWeld> mxElementsControlWin;
+ std::unique_ptr<weld::ComboBox> mxElementListBox;
+
+ virtual void Resize() override;
+ SmViewShell* GetView();
+
+ DECL_LINK(SelectClickHandler, SmElement&, void);
+ DECL_LINK(ElementSelectedHandle, weld::ComboBox&, void);
+
+public:
+
+ SmElementsDockingWindow( SfxBindings* pBindings,
+ SfxChildWindow* pChildWindow,
+ vcl::Window* pParent );
+ virtual ~SmElementsDockingWindow() override;
+ virtual void dispose() override;
+
+ virtual void EndDocking( const tools::Rectangle& rReactangle, bool bFloatMode) override;
+ virtual void ToggleFloatingMode() override;
+};
+
+class SmElementsDockingWindowWrapper final : public SfxChildWindow
+{
+ SFX_DECL_CHILDWINDOW_WITHID(SmElementsDockingWindowWrapper);
+
+ SmElementsDockingWindowWrapper( vcl::Window* pParentWindow,
+ sal_uInt16 nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+ virtual ~SmElementsDockingWindowWrapper() override;
+};
+
+#endif // INCLUDED_STARMATH_INC_ELEMENTSDOCKINGWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/action.hxx b/starmath/inc/action.hxx
new file mode 100644
index 000000000..cb4a4eddf
--- /dev/null
+++ b/starmath/inc/action.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_ACTION_HXX
+#define INCLUDED_STARMATH_INC_ACTION_HXX
+
+#include <svl/undo.hxx>
+#include "format.hxx"
+
+class SmDocShell;
+
+
+class SmFormatAction final : public SfxUndoAction
+{
+ SmDocShell *pDoc;
+ SmFormat aOldFormat;
+ SmFormat aNewFormat;
+
+public:
+ SmFormatAction(SmDocShell *pDocSh, const SmFormat& rOldFormat, const SmFormat& rNewFormat);
+
+ virtual void Undo() override;
+ virtual void Redo() override;
+ virtual void Repeat(SfxRepeatTarget& rDocSh) override;
+ virtual OUString GetComment() const override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
new file mode 100644
index 000000000..327ee1d6e
--- /dev/null
+++ b/starmath/inc/caret.hxx
@@ -0,0 +1,428 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#ifndef INCLUDED_STARMATH_INC_CARET_HXX
+#define INCLUDED_STARMATH_INC_CARET_HXX
+
+#include <sal/config.h>
+
+#include "node.hxx"
+
+#include <cassert>
+#include <memory>
+#include <vector>
+
+/** Representation of caret position with an equation */
+struct SmCaretPos{
+ SmCaretPos(SmNode* selectedNode = nullptr, int iIndex = 0)
+ : pSelectedNode(selectedNode)
+ , nIndex(iIndex)
+ {
+ assert(nIndex >= 0);
+ }
+
+ /** Selected node */
+ SmNode* pSelectedNode;
+
+ /** Index (invariant: non-negative) within the selected node
+ *
+ * 0: Position in front of a node
+ * 1: Position after a node or after first char in SmTextNode
+ * n: Position after n char in SmTextNode
+ *
+ * Notice how there's special cases for SmTextNode.
+ */
+ //TODO: Special cases for SmBlankNode is needed
+ //TODO: Consider forgetting about the todo above... As it's really unpleasant.
+ int nIndex;
+
+ /** True, if this is a valid caret position */
+ bool IsValid() const { return pSelectedNode != nullptr; }
+ bool operator==(const SmCaretPos &pos) const {
+ return pos.pSelectedNode == pSelectedNode && nIndex == pos.nIndex;
+ }
+ /** Get the caret position after pNode, regardless of pNode
+ *
+ * Gets the caret position following pNode, this is SmCaretPos(pNode, 1).
+ * Unless pNode is an instance of SmTextNode, then the index is the text length.
+ */
+ static SmCaretPos GetPosAfter(SmNode* pNode) {
+ if(pNode && pNode->GetType() == SmNodeType::Text)
+ return SmCaretPos(pNode, static_cast<SmTextNode*>(pNode)->GetText().getLength());
+ return SmCaretPos(pNode, 1);
+ }
+};
+
+/** A line that represents a caret */
+class SmCaretLine{
+public:
+ SmCaretLine(long left = 0, long top = 0, long height = 0) {
+ _top = top;
+ _left = left;
+ _height = height;
+ }
+ long GetTop() const {return _top;}
+ long GetLeft() const {return _left;}
+ long GetHeight() const {return _height;}
+ long SquaredDistanceX(const SmCaretLine& line) const{
+ return (GetLeft() - line.GetLeft()) * (GetLeft() - line.GetLeft());
+ }
+ long SquaredDistanceX(const Point &pos) const{
+ return (GetLeft() - pos.X()) * (GetLeft() - pos.X());
+ }
+ long SquaredDistanceY(const SmCaretLine& line) const{
+ long d = GetTop() - line.GetTop();
+ if(d < 0)
+ d = (d * -1) - GetHeight();
+ else
+ d = d - line.GetHeight();
+ if(d < 0)
+ return 0;
+ return d * d;
+ }
+ long SquaredDistanceY(const Point &pos) const{
+ long d = GetTop() - pos.Y();
+ if(d < 0)
+ d = (d * -1) - GetHeight();
+ if(d < 0)
+ return 0;
+ return d * d;
+ }
+private:
+ long _top;
+ long _left;
+ long _height;
+};
+
+// SmCaretPosGraph
+
+/** An entry in SmCaretPosGraph */
+struct SmCaretPosGraphEntry{
+ SmCaretPosGraphEntry(SmCaretPos pos,
+ SmCaretPosGraphEntry* left,
+ SmCaretPosGraphEntry* right) {
+ CaretPos = pos;
+ Left = left;
+ Right = right;
+ }
+ /** Caret position */
+ SmCaretPos CaretPos;
+ /** Entry to the left visually */
+ SmCaretPosGraphEntry* Left;
+ /** Entry to the right visually */
+ SmCaretPosGraphEntry* Right;
+ void SetRight(SmCaretPosGraphEntry* right){
+ Right = right;
+ }
+ void SetLeft(SmCaretPosGraphEntry* left){
+ Left = left;
+ }
+};
+
+/** A graph over all caret positions
+ * @remarks Graphs can only grow, entries cannot be removed!
+ */
+class SmCaretPosGraph{
+public:
+ SmCaretPosGraph();
+
+ ~SmCaretPosGraph();
+
+ /** Add a caret position
+ * @remarks If left is NULL, they will point back to the entry.
+ */
+ SmCaretPosGraphEntry* Add(SmCaretPos pos,
+ SmCaretPosGraphEntry* left = nullptr);
+
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>>::iterator begin()
+ {
+ return mvEntries.begin();
+ }
+
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>>::iterator end()
+ {
+ return mvEntries.end();
+ }
+
+private:
+ std::vector<std::unique_ptr<SmCaretPosGraphEntry>> mvEntries;
+};
+
+/** \page visual_formula_editing Visual Formula Editing
+ * A visual formula editor allows users to easily edit formulas without having to learn and
+ * use complicated commands. A visual formula editor is a WYSIWYG editor. For OpenOffice Math
+ * this essentially means that you can click on the formula image, to get a caret, which you
+ * can move with arrow keys, and use to modify the formula by entering text, clicking buttons
+ * or using shortcuts.
+ *
+ * \subsection formula_trees Formula Trees
+ * A formula in OpenOffice Math is a tree of nodes, take for instance the formula
+ * "A + {B cdot C} over D", it looks like this
+ * \f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$. The tree for this formula
+ * looks like this:
+ *
+ * \dot
+ * digraph {
+ * labelloc = "t";
+ * label= "Equation: \"A + {B cdot C} over D\"";
+ * size = "9,9";
+ * n0 [label="SmTableNode (1)"];
+ * n0 -> n1 [label="0"];
+ * n1 [label="SmLineNode (2)"];
+ * n1 -> n2 [label="0"];
+ * n2 [label="SmExpressionNode (3)"];
+ * n2 -> n3 [label="0"];
+ * n3 [label="SmBinHorNode (4)"];
+ * n3 -> n4 [label="0"];
+ * n4 [label="SmTextNode: A (5)"];
+ * n3 -> n5 [label="1"];
+ * n5 [label="SmMathSymbolNode: + (6)"];
+ * n3 -> n6 [label="2"];
+ * n6 [label="SmBinVerNode (7)"];
+ * n6 -> n7 [label="0"];
+ * n7 [label="SmExpressionNode (8)"];
+ * n7 -> n8 [label="0"];
+ * n8 [label="SmBinHorNode (9)"];
+ * n8 -> n9 [label="0"];
+ * n9 [label="SmTextNode: B (10)"];
+ * n8 -> n10 [label="1"];
+ * n10 [label="SmMathSymbolNode: &#183; (11)"];
+ * n8 -> n11 [label="2"];
+ * n11 [label="SmTextNode: C (12)"];
+ * n6 -> n12 [label="1"];
+ * n12 [label="SmRectangleNode (13)"];
+ * n6 -> n13 [label="2"];
+ * n13 [label="SmTextNode: D (14)"];
+ * }
+ * \enddot
+ *
+ * The vertices are nodes, their label says what kind of node and the number in parentheses is
+ * the identifier of the node (In practices a pointer is used instead of the id). The direction
+ * of the edges tells which node is parent and which is child. The label of the edges are the
+ * child node index number, given to SmNode::GetSubNode() of the parent to get the child node.
+ *
+ *
+ * \subsection visual_lines Visual Lines
+ *
+ * Inorder to do caret movement in visual lines, we need a definition of caret position and
+ * visual line. In a tree such as the above there are three visual lines. There's the outer most
+ * line, with entries such as
+ * \f$\mbox{A}\f$, \f$ + \f$ and \f$ \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$. Then there's
+ * the numerator line of the fraction it has entries \f$ \mbox{B} \f$, \f$ \cdot \f$ and \f$ \mbox{C} \f$.
+ * And last by not least there's the denominator line of the fraction it's only entry is \f$ \mbox{D} \f$.
+ *
+ * For visual editing it should be possible to place a caret on both sides of any line entry,
+ * consider a line entry a character or construction that in a line is treated as a character.
+ * Imagine the caret is placed to the right of the plus sign (id: 6), now if user presses
+ * backspace this should delete the plus sign (id: 6), and if the user presses delete this
+ * should delete the entire fraction (id: 7). This is because the caret is in the outer most
+ * line where the fraction is considered a line entry.
+ *
+ * However, inorder to prevent users from accidentally deleting large subtrees, just because
+ * they logically placed there caret a in the wrong line, require that complex constructions
+ * such as a fraction is selected before it is deleted. Thus in this case it wouldn't be
+ * deleted, but only selected and then deleted if the user hit delete again. Anyway, this is
+ * slightly off topic for now.
+ *
+ * Important about visual lines is that they don't always have an SmExpressionNode as root
+ * and the entries in a visual line is all the nodes of a subtree ordered left to right that
+ * isn't either an SmExpressionNode, SmBinHorNode or SmUnHorNode.
+ *
+ *
+ * \subsection caret_positions Caret Positions
+ *
+ * A caret position in OpenOffice Math is represented by an instance of SmCaretPos.
+ * That is a caret position is a node and an index related to this node. For most nodes the
+ * index 0, means caret is in front of this node, the index 1 means caret is after this node.
+ * For SmTextNode the index is the caret position after the specified number of characters,
+ * imagine an SmTextNode with the number 1337. The index 3 in such SmTextNode would mean a
+ * caret placed right before 7, e.g. "133|7".
+ *
+ * For SmExpressionNode, SmBinHorNode and SmUnHorNode the only legal index is 0, which means
+ * in front of the node. Actually the index 0 may only because for the first caret position
+ * in a visual line. From the example above, consider the following subtree that constitutes
+ * a visual line:
+ *
+ * \dot
+ * digraph {
+ * labelloc = "t";
+ * label= "Subtree that constitutes a visual line";
+ * size = "7,5";
+ * n7 [label="SmExpressionNode (8)"];
+ * n7 -> n8 [label="0"];
+ * n8 [label="SmBinHorNode (9)"];
+ * n8 -> n9 [label="0"];
+ * n9 [label="SmTextNode: B (10)"];
+ * n8 -> n10 [label="1"];
+ * n10 [label="SmMathSymbolNode: &#183; (11)"];
+ * n8 -> n11 [label="2"];
+ * n11 [label="SmTextNode: C (12)"];
+ * }
+ * \enddot
+ * Here the caret positions are:
+ *
+ * <TABLE>
+ * <TR><TD><B>Caret position:</B></TD><TD><B>Example:</B></TD>
+ * </TR><TR>
+ * <TD>{id: 8, index: 0}</TD>
+ * <TD>\f$ \mid \mbox{C} \cdot \mbox{C} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 10, index: 1}</TD>
+ * <TD>\f$ \mbox{C} \mid \cdot \mbox{C} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 11, index: 1}</TD>
+ * <TD>\f$ \mbox{C} \cdot \mid \mbox{C} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 12, index: 1}</TD>
+ * <TD>\f$ \mbox{C} \cdot \mbox{C} \mid \f$</TD>
+ * </TR><TR>
+ * </TABLE>
+ *
+ * Where \f$ \mid \f$ is used to denote caret position.
+ *
+ * With these exceptions included in the definition the id and index: {id: 11, index: 0} does
+ * \b not constitute a caret position in the given context. Note the method
+ * SmCaretPos::IsValid() does not check if this invariant holds true, but code in SmCaret,
+ * SmSetSelectionVisitor and other places depends on this invariant to hold.
+ *
+ *
+ * \subsection caret_movement Caret Movement
+ *
+ * As the placement of caret positions depends very much on the context within which a node
+ * appears it is not trivial to find all caret positions and determine which follows which.
+ * In OpenOffice Math this is done by the SmCaretPosGraphBuildingVisitor. This visitor builds
+ * graph (an instance of SmCaretPosGraph) over the caret positions. For details on how this
+ * graph is build, and how new methods should be implemented see SmCaretPosGraphBuildingVisitor.
+ *
+ * The result of the SmCaretPosGraphBuildingVisitor is a graph over the caret positions in a
+ * formula, represented by an instance of SmCaretPosGraph. Each entry (instances of SmCaretPosGraphEntry)
+ * has a pointer to the entry to the left and right of itself. This way we can easily find
+ * the caret position to a right or left of a given caret position. Note each caret position
+ * only appears once in this graph.
+ *
+ * When searching for a caret position after a left click on the formula this map is also used.
+ * We simply iterate over all entries, uses the SmCaretPos2LineVisitor to find a line for each
+ * caret position. Then the distance from the click to the line is computed and we choose the
+ * caret position closest to the click.
+ *
+ * For up and down movement, we also iterator over all caret positions and use SmCaretPos2LineVisitor
+ * to find a line for each caret position. Then we compute the distance from the current
+ * caret position to every other caret position and chooses the one closest that is either
+ * above or below the current caret position, depending on whether we're doing up or down movement.
+ *
+ * This result of this approach to caret movement is that we have logically predictable
+ * movement for left and right, whilst leftclick, up and down movement depends on the sizes
+ * and placement of all node and may be less logically predictable. This solution also means
+ * that we only have one complex visitor generating the graph, imagine the nightmare if we
+ * had a visitor for movement in each direction.
+ *
+ * Making up and down movement independent of node sizes and placement wouldn't necessarily
+ * be a good thing either. Consider the formula \f$ \frac{1+2+3+4+5}{6} \f$, if the caret is
+ * placed as displayed here: \f$ \frac{1+2+3+4+5}{6 \mid} \f$, up movement should move to right
+ * after "3": \f$ \frac{1+2+3|+4+5}{6} \f$. However, such a move depends on the sizes and placement
+ * of all nodes in the fraction.
+ *
+ *
+ * \subsubsection caretpos_graph_example Example of Caret Position Graph
+ *
+ * If we consider the formula
+ * \f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$ from \ref formula_trees.
+ * It has the following caret positions:
+ *
+ * <TABLE>
+ * <TR>
+ * <TD><B>Caret position:</B></TD>
+ * <TD><B>Example:</B></TD>
+ * </TR><TR>
+ * <TD>{id: 3, index: 0}</TD>
+ * <TD>\f$ \mid\mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 5, index: 1}</TD>
+ * <TD>\f$ \mbox{A}\mid + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 6, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \mid \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 8, index: 0}</TD>
+ * <TD>\f$ \mbox{A} + \frac{ \mid \mbox{B} \cdot \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 10, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \mid \cdot \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 11, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \cdot \mid \mbox{C}}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 12, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C} \mid}{\mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 14, index: 0}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mid \mbox{D}} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 14, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D} \mid} \f$</TD>
+ * </TR><TR>
+ * <TD>{id: 7, index: 1}</TD>
+ * <TD>\f$ \mbox{A} + \frac{\mbox{B} \cdot \mbox{C}}{\mbox{D}} \mid \f$</TD>
+ * </TR>
+ * </TABLE>
+ *
+ * Below is a directed graph over the caret positions and how you can move between them.
+ * \dot
+ * digraph {
+ * labelloc = "t";
+ * label= "Caret Position Graph";
+ * size = "4,6";
+ * p0 [label = "{id: 3, index: 0}"];
+ * p0 -> p1 [fontsize = 10.0, label = "right"];
+ * p1 [label = "{id: 5, index: 1}"];
+ * p1 -> p0 [fontsize = 10.0, label = "left"];
+ * p1 -> p2 [fontsize = 10.0, label = "right"];
+ * p2 [label = "{id: 6, index: 1}"];
+ * p2 -> p1 [fontsize = 10.0, label = "left"];
+ * p2 -> p3 [fontsize = 10.0, label = "right"];
+ * p3 [label = "{id: 8, index: 0}"];
+ * p3 -> p2 [fontsize = 10.0, label = "left"];
+ * p3 -> p4 [fontsize = 10.0, label = "right"];
+ * p4 [label = "{id: 10, index: 1}"];
+ * p4 -> p3 [fontsize = 10.0, label = "left"];
+ * p4 -> p5 [fontsize = 10.0, label = "right"];
+ * p5 [label = "{id: 11, index: 1}"];
+ * p5 -> p4 [fontsize = 10.0, label = "left"];
+ * p5 -> p6 [fontsize = 10.0, label = "right"];
+ * p6 [label = "{id: 12, index: 1}"];
+ * p6 -> p5 [fontsize = 10.0, label = "left"];
+ * p6 -> p9 [fontsize = 10.0, label = "right"];
+ * p7 [label = "{id: 14, index: 0}"];
+ * p7 -> p2 [fontsize = 10.0, label = "left"];
+ * p7 -> p8 [fontsize = 10.0, label = "right"];
+ * p8 [label = "{id: 14, index: 1}"];
+ * p8 -> p7 [fontsize = 10.0, label = "left"];
+ * p8 -> p9 [fontsize = 10.0, label = "right"];
+ * p9 [label = "{id: 7, index: 1}"];
+ * p9 -> p6 [fontsize = 10.0, label = "left"];
+ * }
+ * \enddot
+ */
+
+/* TODO: Write documentation about the following keywords:
+ *
+ * Visual Selections:
+ * - Show images
+ * - Talk about how the visitor does this
+ *
+ * Modifying a Visual Line:
+ * - Find top most non-compo of the line (e.g. The subtree that constitutes a line)
+ * - Make the line into a list
+ * - Edit the list, add/remove/modify nodes
+ * - Parse the list back into a subtree
+ * - Insert the new subtree where the old was taken
+ */
+
+#endif // INCLUDED_STARMATH_INC_CARET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx
new file mode 100644
index 000000000..236485d5e
--- /dev/null
+++ b/starmath/inc/cursor.hxx
@@ -0,0 +1,427 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#ifndef INCLUDED_STARMATH_INC_CURSOR_HXX
+#define INCLUDED_STARMATH_INC_CURSOR_HXX
+
+#include "node.hxx"
+#include "caret.hxx"
+
+#include <cassert>
+#include <list>
+#include <memory>
+
+/** Factor to multiple the squared horizontal distance with
+ * Used for Up and Down movement.
+ */
+#define HORIZONTICAL_DISTANCE_FACTOR 10
+
+/** Enum of direction for movement */
+enum SmMovementDirection{
+ MoveUp,
+ MoveDown,
+ MoveLeft,
+ MoveRight
+};
+
+/** Enum of elements that can inserted into a formula */
+enum SmFormulaElement{
+ BlankElement,
+ FactorialElement,
+ PlusElement,
+ MinusElement,
+ CDotElement,
+ EqualElement,
+ LessThanElement,
+ GreaterThanElement,
+ PercentElement
+};
+
+/** Bracket types that can be inserted */
+enum class SmBracketType {
+ /** Round brackets, left command "(" */
+ Round,
+ /**Square brackets, left command "[" */
+ Square,
+ /** Curly brackets, left command "lbrace" */
+ Curly,
+};
+
+/** A list of nodes */
+typedef std::list<SmNode*> SmNodeList;
+
+typedef std::list<std::unique_ptr<SmNode>> SmClipboard;
+
+class SmDocShell;
+
+/** Formula cursor
+ *
+ * This class is used to represent a cursor in a formula, which can be used to manipulate
+ * a formula programmatically.
+ * @remarks This class is a very intimate friend of SmDocShell.
+ */
+class SmCursor{
+public:
+ SmCursor(SmNode* tree, SmDocShell* pShell)
+ : mpAnchor(nullptr)
+ , mpPosition(nullptr)
+ , mpTree(tree)
+ , mpDocShell(pShell)
+ , mnEditSections(0)
+ , mbIsEnabledSetModifiedSmDocShell(false)
+ {
+ //Build graph
+ BuildGraph();
+ }
+
+ /** Get position */
+ const SmCaretPos& GetPosition() const { return mpPosition->CaretPos; }
+
+ /** True, if the cursor has a selection */
+ bool HasSelection() const { return mpAnchor != mpPosition; }
+
+ /** Move the position of this cursor */
+ void Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor = true);
+
+ /** Move to the caret position closest to a given point */
+ void MoveTo(OutputDevice* pDev, const Point& pos, bool bMoveAnchor);
+
+ /** Delete the current selection or do nothing */
+ void Delete();
+
+ /** Delete selection, previous element or merge lines
+ *
+ * This method implements the behaviour of backspace.
+ */
+ void DeletePrev(OutputDevice* pDev);
+
+ /** Insert text at the current position */
+ void InsertText(const OUString& aString);
+
+ /** Insert an element into the formula */
+ void InsertElement(SmFormulaElement element);
+
+ /** Insert command text translated into line entries at position
+ *
+ * Note: This method uses the parser to translate a command text into a
+ * tree, then it copies line entries from this tree into the current tree.
+ * Will not work for commands such as newline or ##, if position is in a matrix.
+ * This will work for stuff like "A intersection B". But stuff spanning multiple lines
+ * or dependent on the context which position is placed in will not work!
+ */
+ void InsertCommandText(const OUString& aCommandText);
+
+ /** Insert a special node created from aString
+ *
+ * Used for handling insert request from the "catalog" dialog.
+ * The provided string should be formatted as the desired command: %phi
+ * Note: this method ONLY supports commands defined in Math.xcu
+ *
+ * For more complex expressions use InsertCommandText, this method doesn't
+ * use SmParser, this means that it's faster, but not as strong.
+ */
+ void InsertSpecial(const OUString& aString);
+
+ /** Create sub-/super script
+ *
+ * If there's a selection, it will be move into the appropriate sub-/super scription
+ * of the node in front of it. If there's no node in front of position (or the selection),
+ * a sub-/super scription of a new SmPlaceNode will be made.
+ *
+ * If there's is an existing subscription of the node, the caret will be moved into it,
+ * and any selection will replace it.
+ */
+ void InsertSubSup(SmSubSup eSubSup);
+
+ /** Insert a new row or newline
+ *
+ * Inserts a new row if position is in a matrix or stack command.
+ * Otherwise a newline is inserted if we're in a toplevel line.
+ *
+ * @returns True, if a new row/line could be inserted.
+ *
+ * @remarks If the caret is placed in a subline of a command that doesn't support
+ * this operator the method returns FALSE, and doesn't do anything.
+ */
+ bool InsertRow();
+
+ /** Insert a fraction, use selection as numerator */
+ void InsertFraction();
+
+ /** Create brackets around current selection, or new SmPlaceNode */
+ void InsertBrackets(SmBracketType eBracketType);
+
+ /** Copy the current selection */
+ void Copy();
+ /** Cut the current selection */
+ void Cut(){
+ Copy();
+ Delete();
+ }
+ /** Paste the clipboard */
+ void Paste();
+
+ /** Returns true if more than one node is selected
+ *
+ * This method is used for implementing backspace and delete.
+ * If one of these causes a complex selection, e.g. a node with
+ * subnodes or similar, this should not be deleted immediately.
+ */
+ bool HasComplexSelection();
+
+ /** Finds the topmost node in a visual line
+ *
+ * If MoveUpIfSelected is true, this will move up to the parent line
+ * if the parent of the current line is selected.
+ */
+ static SmNode* FindTopMostNodeInLine(SmNode* pSNode, bool MoveUpIfSelected = false);
+
+ /** Draw the caret */
+ void Draw(OutputDevice& pDev, Point Offset, bool isCaretVisible);
+
+ bool IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** ppBraceNode) const;
+ void MoveAfterBracket(SmBraceNode* pBraceNode);
+
+private:
+ friend class SmDocShell;
+
+ SmCaretPosGraphEntry *mpAnchor,
+ *mpPosition;
+ /** Formula tree */
+ SmNode* mpTree;
+ /** Owner of the formula tree */
+ SmDocShell* mpDocShell;
+ /** Graph over caret position in the current tree */
+ std::unique_ptr<SmCaretPosGraph> mpGraph;
+ /** Clipboard holder */
+ SmClipboard maClipboard;
+
+ /** Returns a node that is selected, if any could be found */
+ SmNode* FindSelectedNode(SmNode* pNode);
+
+ /** Is this one of the nodes used to compose a line
+ *
+ * These are SmExpression, SmBinHorNode, SmUnHorNode etc.
+ */
+ static bool IsLineCompositionNode(SmNode const * pNode);
+
+ /** Count number of selected nodes, excluding line composition nodes
+ *
+ * Note this function doesn't count line composition nodes and it
+ * does count all subnodes as well as the owner nodes.
+ *
+ * Used by SmCursor::HasComplexSelection()
+ */
+ int CountSelectedNodes(SmNode* pNode);
+
+ /** Convert a visual line to a list
+ *
+ * Note this method will delete all the nodes that will no longer be needed.
+ * that includes pLine!
+ * This method also deletes SmErrorNode's as they're just meta info in the line.
+ */
+ static void LineToList(SmStructureNode* pLine, SmNodeList& rList);
+
+ /** Auxiliary function for calling LineToList on a node
+ *
+ * This method sets pNode = NULL and remove it from its parent.
+ * (Assuming it has a parent, and is a child of it).
+ */
+ static void NodeToList(SmNode*& rpNode, SmNodeList& rList){
+ //Remove from parent and NULL rpNode
+ SmNode* pNode = rpNode;
+ if(rpNode && rpNode->GetParent()){ //Don't remove this, correctness relies on it
+ int index = rpNode->GetParent()->IndexOfSubNode(rpNode);
+ assert(index >= 0);
+ rpNode->GetParent()->SetSubNode(index, nullptr);
+ }
+ rpNode = nullptr;
+ //Create line from node
+ if(pNode && IsLineCompositionNode(pNode)){
+ LineToList(static_cast<SmStructureNode*>(pNode), rList);
+ return;
+ }
+ if(pNode)
+ rList.push_front(pNode);
+ }
+
+ /** Clone a visual line to a clipboard
+ *
+ * ... but the selected part only.
+ * Doesn't clone SmErrorNodes, which are ignored as they are context dependent metadata.
+ */
+ static void CloneLineToClipboard(SmStructureNode* pLine, SmClipboard* pClipboard);
+
+ /** Build pGraph over caret positions */
+ void BuildGraph();
+
+ /** Insert new nodes in the tree after position */
+ void InsertNodes(std::unique_ptr<SmNodeList> pNewNodes);
+
+ /** tries to set position to a specific SmCaretPos
+ *
+ * @returns false on failure to find the position in pGraph.
+ */
+ bool SetCaretPosition(SmCaretPos pos);
+
+ /** Set selected on nodes of the tree */
+ void AnnotateSelection();
+
+ /** Clone list of nodes in a clipboard (creates a deep clone) */
+ static std::unique_ptr<SmNodeList> CloneList(SmClipboard &rClipboard);
+
+ /** Find an iterator pointing to the node in pLineList following rCaretPos
+ *
+ * If rCaretPos.pSelectedNode cannot be found it is assumed that it's in front of pLineList,
+ * thus not an element in pLineList. In this case this method returns an iterator to the
+ * first element in pLineList.
+ *
+ * If the current position is inside an SmTextNode, this node will be split in two, for this
+ * reason you should beaware that iterators to elements in pLineList may be invalidated, and
+ * that you should call PatchLineList() with this iterator if no action is taken.
+ */
+ static SmNodeList::iterator FindPositionInLineList(SmNodeList* pLineList,
+ const SmCaretPos& rCaretPos);
+
+ /** Patch a line list after modification, merge SmTextNode, remove SmPlaceNode etc.
+ *
+ * @param pLineList The line list to patch
+ * @param aIter Iterator pointing to the element that needs to be patched with its previous.
+ *
+ * When the list is patched text nodes before and after aIter will be merged.
+ * If there's an, in the context, inappropriate SmPlaceNode before or after aIter it will also be
+ * removed.
+ *
+ * @returns A caret position equivalent to one selecting the node before aIter, the method returns
+ * an invalid SmCaretPos to indicate placement in front of the line.
+ */
+ static SmCaretPos PatchLineList(SmNodeList* pLineList, SmNodeList::iterator aIter);
+
+ /** Take selected nodes from a list
+ *
+ * Puts the selected nodes into pSelectedNodes, or if pSelectedNodes is NULL deletes
+ * the selected nodes.
+ * Note: If there's a selection inside an SmTextNode this node will be split, and it
+ * will not be merged when the selection have been taken. Use PatchLineList on the
+ * iterator returns to fix this.
+ *
+ * @returns An iterator pointing to the element following the selection taken.
+ */
+ static SmNodeList::iterator TakeSelectedNodesFromList(SmNodeList *pLineList,
+ SmNodeList *pSelectedNodes = nullptr);
+
+ /** Create an instance of SmMathSymbolNode usable for brackets */
+ static SmNode *CreateBracket(SmBracketType eBracketType, bool bIsLeft);
+
+ /** The number of times BeginEdit have been called
+ * Used to allow nesting of BeginEdit() and EndEdit() sections
+ */
+ int mnEditSections;
+ /** Holds data for BeginEdit() and EndEdit() */
+ bool mbIsEnabledSetModifiedSmDocShell;
+ /** Begin edit section where the tree will be modified */
+ void BeginEdit();
+ /** End edit section where the tree will be modified */
+ void EndEdit();
+ /** Finish editing
+ *
+ * Finishes editing by parsing pLineList and inserting back into pParent at nParentIndex.
+ * This method also rebuilds the graph, annotates the selection, sets caret position and
+ * Calls EndEdit.
+ *
+ * @remarks Please note that this method will delete pLineList, as the elements are taken.
+ *
+ * @param pLineList List the constitutes the edited line.
+ * @param pParent Parent to which the line should be inserted.
+ * @param nParentIndex Index in parent where the line should be inserted.
+ * @param PosAfterEdit Caret position to look for after rebuilding graph.
+ * @param pStartLine Line to take first position in, if PosAfterEdit cannot be found,
+ * leave it NULL for pLineList.
+ */
+ void FinishEdit(std::unique_ptr<SmNodeList> pLineList,
+ SmStructureNode* pParent,
+ int nParentIndex,
+ SmCaretPos PosAfterEdit,
+ SmNode* pStartLine = nullptr);
+ /** Request the formula is repainted */
+ void RequestRepaint();
+};
+
+/** Minimalistic recursive decent SmNodeList parser
+ *
+ * This parser is used to take a list of nodes that constitutes a line
+ * and parse them to a tree of SmBinHorNode, SmUnHorNode and SmExpression.
+ *
+ * Please note, this will not handle all kinds of nodes, only nodes that
+ * constitutes and entry in a line.
+ *
+ * Below is an EBNF representation of the grammar used for this parser:
+ * \code
+ * Expression -> Relation*
+ * Relation -> Sum [(=|<|>|...) Sum]*
+ * Sum -> Product [(+|-) Product]*
+ * Product -> Factor [(*|/) Factor]*
+ * Factor -> [+|-|-+|...]* Factor | Postfix
+ * Postfix -> node [!]*
+ * \endcode
+ */
+class SmNodeListParser{
+public:
+ /** Create an instance of SmNodeListParser */
+ SmNodeListParser(){
+ pList = nullptr;
+ }
+ /** Parse a list of nodes to an expression.
+ *
+ * Old error nodes will be deleted.
+ */
+ SmNode* Parse(SmNodeList* list);
+ /** True, if the token is an operator */
+ static bool IsOperator(const SmToken &token);
+ /** True, if the token is a relation operator */
+ static bool IsRelationOperator(const SmToken &token);
+ /** True, if the token is a sum operator */
+ static bool IsSumOperator(const SmToken &token);
+ /** True, if the token is a product operator */
+ static bool IsProductOperator(const SmToken &token);
+ /** True, if the token is a unary operator */
+ static bool IsUnaryOperator(const SmToken &token);
+ /** True, if the token is a postfix operator */
+ static bool IsPostfixOperator(const SmToken &token);
+private:
+ SmNodeList* pList;
+ /** Get the current terminal */
+ SmNode* Terminal(){
+ if (!pList->empty())
+ return pList->front();
+ return nullptr;
+ }
+ /** Move to next terminal */
+ SmNode* Next(){
+ pList->pop_front();
+ return Terminal();
+ }
+ /** Take the current terminal */
+ SmNode* Take(){
+ SmNode* pRetVal = Terminal();
+ Next();
+ return pRetVal;
+ }
+ SmNode* Expression();
+ SmNode* Relation();
+ SmNode* Sum();
+ SmNode* Product();
+ SmNode* Factor();
+ SmNode* Postfix();
+ static SmNode* Error();
+};
+
+
+#endif // INCLUDED_STARMATH_INC_CURSOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
new file mode 100644
index 000000000..48910cafe
--- /dev/null
+++ b/starmath/inc/dialog.hxx
@@ -0,0 +1,486 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_DIALOG_HXX
+#define INCLUDED_STARMATH_INC_DIALOG_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/customweld.hxx>
+#include "symbol.hxx"
+#include <memory>
+
+class SubsetMap;
+class SmFormat;
+class FontList;
+class SvxShowCharSet;
+
+#define CATEGORY_NONE 0xFFFF
+
+/**************************************************************************/
+
+void SetFontStyle(const OUString &rStyleName, vcl::Font &rFont);
+
+/**************************************************************************/
+
+class SmPrintOptionsTabPage final : public SfxTabPage
+{
+ std::unique_ptr<weld::CheckButton> m_xTitle;
+ std::unique_ptr<weld::CheckButton> m_xText;
+ std::unique_ptr<weld::CheckButton> m_xFrame;
+ std::unique_ptr<weld::RadioButton> m_xSizeNormal;
+ std::unique_ptr<weld::RadioButton> m_xSizeScaled;
+ std::unique_ptr<weld::RadioButton> m_xSizeZoomed;
+ std::unique_ptr<weld::MetricSpinButton> m_xZoom;
+ std::unique_ptr<weld::CheckButton> m_xNoRightSpaces;
+ std::unique_ptr<weld::CheckButton> m_xSaveOnlyUsedSymbols;
+ std::unique_ptr<weld::CheckButton> m_xAutoCloseBrackets;
+
+ DECL_LINK(SizeButtonClickHdl, weld::ToggleButton&, void);
+
+ virtual bool FillItemSet(SfxItemSet* rSet) override;
+ virtual void Reset(const SfxItemSet* rSet) override;
+
+public:
+ static std::unique_ptr<SfxTabPage> Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rSet);
+
+ SmPrintOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rOptions);
+ virtual ~SmPrintOptionsTabPage() override;
+};
+
+/**************************************************************************/
+
+class SmShowFont final : public weld::CustomWidgetController
+{
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
+
+ vcl::Font maFont;
+
+public:
+ SmShowFont()
+ {
+ }
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
+ void SetFont(const vcl::Font& rFont);
+};
+
+class SmFontDialog : public weld::GenericDialogController
+{
+ vcl::Font maFont;
+ SmShowFont m_aShowFont;
+ std::unique_ptr<weld::EntryTreeView> m_xFontBox;
+ std::unique_ptr<weld::Widget> m_xAttrFrame;
+ std::unique_ptr<weld::CheckButton> m_xBoldCheckBox;
+ std::unique_ptr<weld::CheckButton> m_xItalicCheckBox;
+ std::unique_ptr<weld::CustomWeld> m_xShowFont;
+
+ DECL_LINK(FontSelectHdl, weld::ComboBox&, void);
+ DECL_LINK(AttrChangeHdl, weld::ToggleButton&, void);
+
+public:
+ SmFontDialog(weld::Window* pParent, OutputDevice *pFntListDevice, bool bHideCheckboxes);
+ virtual ~SmFontDialog() override;
+
+ const vcl::Font& GetFont() const
+ {
+ return maFont;
+ }
+ void SetFont(const vcl::Font &rFont);
+};
+
+/**************************************************************************/
+
+class SmFontSizeDialog final : public weld::GenericDialogController
+{
+ std::unique_ptr<weld::MetricSpinButton> m_xBaseSize;
+ std::unique_ptr<weld::MetricSpinButton> m_xTextSize;
+ std::unique_ptr<weld::MetricSpinButton> m_xIndexSize;
+ std::unique_ptr<weld::MetricSpinButton> m_xFunctionSize;
+ std::unique_ptr<weld::MetricSpinButton> m_xOperatorSize;
+ std::unique_ptr<weld::MetricSpinButton> m_xBorderSize;
+ std::unique_ptr<weld::Button> m_xDefaultButton;
+
+ DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
+
+public:
+ SmFontSizeDialog(weld::Window *pParent);
+ virtual ~SmFontSizeDialog() override;
+
+ void ReadFrom(const SmFormat &rFormat);
+ void WriteTo (SmFormat &rFormat) const;
+};
+
+/**************************************************************************/
+
+class SmFontTypeDialog final : public weld::GenericDialogController
+{
+ VclPtr<OutputDevice> pFontListDev;
+
+ std::unique_ptr<SmFontPickListBox> m_xVariableFont;
+ std::unique_ptr<SmFontPickListBox> m_xFunctionFont;
+ std::unique_ptr<SmFontPickListBox> m_xNumberFont;
+ std::unique_ptr<SmFontPickListBox> m_xTextFont;
+ std::unique_ptr<SmFontPickListBox> m_xSerifFont;
+ std::unique_ptr<SmFontPickListBox> m_xSansFont;
+ std::unique_ptr<SmFontPickListBox> m_xFixedFont;
+ std::unique_ptr<weld::MenuButton> m_xMenuButton;
+ std::unique_ptr<weld::Button> m_xDefaultButton;
+
+ DECL_LINK(MenuSelectHdl, const OString&, void);
+ DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
+
+public:
+ SmFontTypeDialog(weld::Window* pParent, OutputDevice *pFntListDevice);
+ virtual ~SmFontTypeDialog() override;
+
+ void ReadFrom(const SmFormat &rFormat);
+ void WriteTo (SmFormat &rFormat) const;
+};
+
+/**************************************************************************/
+
+#define NOCATEGORIES 10
+
+class SmCategoryDesc
+{
+ OUString Name;
+ OUString Strings[4];
+ std::unique_ptr<weld::Widget> Graphics[4]; /* regular bitmaps */
+ sal_uInt16 Minimum[4];
+ sal_uInt16 Maximum[4];
+ sal_uInt16 Value[4];
+
+public:
+ SmCategoryDesc(weld::Builder& rBuilder, sal_uInt16 nCategoryIdx);
+ ~SmCategoryDesc();
+
+ const OUString& GetName() const { return Name; }
+ const OUString& GetString(sal_uInt16 Index) const { return Strings[Index]; }
+ sal_uInt16 GetMinimum(sal_uInt16 Index) { return Minimum[Index]; }
+ sal_uInt16 GetMaximum(sal_uInt16 Index) { return Maximum[Index]; }
+ sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; }
+ void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
+
+ weld::Widget* GetGraphic(sal_uInt16 Index) const
+ {
+ return Graphics[Index].get();
+ }
+};
+
+class SmDistanceDialog final : public weld::GenericDialogController
+{
+ std::unique_ptr<weld::Frame> m_xFrame;
+ std::unique_ptr<weld::Label> m_xFixedText1;
+ std::unique_ptr<weld::MetricSpinButton> m_xMetricField1;
+ std::unique_ptr<weld::Label> m_xFixedText2;
+ std::unique_ptr<weld::MetricSpinButton> m_xMetricField2;
+ std::unique_ptr<weld::Label> m_xFixedText3;
+ std::unique_ptr<weld::MetricSpinButton> m_xMetricField3;
+ std::unique_ptr<weld::CheckButton> m_xCheckBox1;
+ std::unique_ptr<weld::Label> m_xFixedText4;
+ std::unique_ptr<weld::MetricSpinButton> m_xMetricField4;
+ std::unique_ptr<weld::MenuButton> m_xMenuButton;
+ std::unique_ptr<weld::Button> m_xDefaultButton;
+ std::unique_ptr<weld::Widget> m_xBitmap;
+
+ weld::Widget* m_pCurrentImage;
+
+ std::unique_ptr<SmCategoryDesc> m_xCategories[NOCATEGORIES];
+ sal_uInt16 nActiveCategory;
+ bool bScaleAllBrackets;
+
+ DECL_LINK(GetFocusHdl, weld::Widget&, void);
+ DECL_LINK(MenuSelectHdl, const OString&, void);
+ DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
+ DECL_LINK(CheckBoxClickHdl, weld::ToggleButton&, void);
+
+ void SetCategory(sal_uInt16 Category);
+
+public:
+ SmDistanceDialog(weld::Window *pParent);
+ virtual ~SmDistanceDialog() override;
+
+ void ReadFrom(const SmFormat &rFormat);
+ void WriteTo (SmFormat &rFormat);
+};
+
+/**************************************************************************/
+
+
+class SmAlignDialog final : public weld::GenericDialogController
+{
+ std::unique_ptr<weld::RadioButton> m_xLeft;
+ std::unique_ptr<weld::RadioButton> m_xCenter;
+ std::unique_ptr<weld::RadioButton> m_xRight;
+ std::unique_ptr<weld::Button> m_xDefaultButton;
+
+ DECL_LINK(DefaultButtonClickHdl, weld::Button&, void);
+
+public:
+ SmAlignDialog(weld::Window *pParent);
+ virtual ~SmAlignDialog() override;
+
+ void ReadFrom(const SmFormat &rFormat);
+ void WriteTo (SmFormat &rFormat) const;
+};
+
+/**************************************************************************/
+
+class SmShowSymbolSet final : public weld::CustomWidgetController
+{
+ Size m_aOldSize;
+ SymbolPtrVec_t aSymbolSet;
+ Link<SmShowSymbolSet&,void> aSelectHdlLink;
+ Link<SmShowSymbolSet&,void> aDblClickHdlLink;
+ long nLen;
+ long nRows, nColumns;
+ long nXOffset, nYOffset;
+ sal_uInt16 nSelectSymbol;
+ std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow;
+
+ void SetScrollBarRange();
+ Point OffsetPoint(const Point &rPoint) const;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+ virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
+ virtual bool KeyInput(const KeyEvent& rKEvt) override;
+ virtual void Resize() override;
+
+ DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void);
+
+public:
+ SmShowSymbolSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow);
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
+ {
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
+ m_aOldSize = Size(pDrawingArea->get_approximate_digit_width() * 27,
+ pDrawingArea->get_text_height() * 9);
+ pDrawingArea->set_size_request(m_aOldSize.Width(), m_aOldSize.Height());
+ SetOutputSizePixel(m_aOldSize);
+ calccols(pDrawingArea->get_ref_device());
+ }
+
+ void calccols(const vcl::RenderContext& rRenderContext);
+ void SelectSymbol(sal_uInt16 nSymbol);
+ sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; }
+ void SetSymbolSet(const SymbolPtrVec_t& rSymbolSet);
+ void SetSelectHdl(const Link<SmShowSymbolSet&,void>& rLink) { aSelectHdlLink = rLink; }
+ void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; }
+};
+
+class SmShowSymbol final : public weld::CustomWidgetController
+{
+private:
+ vcl::Font m_aFont;
+ OUString m_aText;
+
+ Link<SmShowSymbol&,void> aDblClickHdlLink;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
+ virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
+
+ void setFontSize(vcl::Font &rFont) const;
+
+public:
+ SmShowSymbol();
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
+ {
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
+ pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27,
+ pDrawingArea->get_text_height() * 9);
+ }
+
+ void SetText(const OUString& rText) { m_aText = rText; }
+ const OUString& GetText() const { return m_aText; }
+
+ void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
+ const vcl::Font& GetFont() const { return m_aFont; }
+
+ void SetSymbol(const SmSym *pSymbol);
+ void SetDblClickHdl(const Link<SmShowSymbol&,void> &rLink) { aDblClickHdlLink = rLink; }
+};
+
+class SmSymbolDialog final : public weld::GenericDialogController
+{
+ SmViewShell &rViewSh;
+ SmSymbolManager &rSymbolMgr;
+
+ OUString aSymbolSetName;
+ SymbolPtrVec_t aSymbolSet;
+
+ VclPtr<OutputDevice> pFontListDev;
+
+ SmShowSymbol m_aSymbolDisplay;
+
+ std::unique_ptr<weld::ComboBox> m_xSymbolSets;
+ std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay;
+ std::unique_ptr<weld::CustomWeld> m_xSymbolSetDisplayArea;
+ std::unique_ptr<weld::Label> m_xSymbolName;
+ std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
+ std::unique_ptr<weld::Button> m_xGetBtn;
+ std::unique_ptr<weld::Button> m_xEditBtn;
+
+ DECL_LINK(SymbolSetChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(SymbolChangeHdl, SmShowSymbolSet&, void);
+ DECL_LINK(SymbolDblClickHdl, SmShowSymbol&, void);
+ DECL_LINK(SymbolDblClickHdl2, SmShowSymbolSet&, void);
+ DECL_LINK(EditClickHdl, weld::Button&, void);
+ DECL_LINK(GetClickHdl, weld::Button&, void);
+ void SymbolDblClickHdl();
+
+ void FillSymbolSets();
+ const SmSym *GetSymbol() const;
+
+public:
+ SmSymbolDialog(weld::Window* pParent, OutputDevice *pFntListDevice,
+ SmSymbolManager &rSymbolMgr, SmViewShell &rViewShell);
+ virtual ~SmSymbolDialog() override;
+
+ bool SelectSymbolSet(const OUString &rSymbolSetName);
+ void SelectSymbol(sal_uInt16 nSymbolPos);
+};
+
+class SmShowChar final : public weld::CustomWidgetController
+{
+private:
+ OUString m_aText;
+ vcl::Font m_aFont;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
+ virtual void Resize() override;
+
+public:
+ SmShowChar()
+ {
+ }
+
+ virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
+ {
+ CustomWidgetController::SetDrawingArea(pDrawingArea);
+ pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7,
+ pDrawingArea->get_text_height() * 3);
+ }
+
+ void SetSymbol(const SmSym *pSym);
+ void SetSymbol(sal_UCS4 cChar, const vcl::Font &rFont);
+ void SetText(const OUString& rText) { m_aText = rText; }
+ const OUString& GetText() const { return m_aText; }
+ void SetFont(const vcl::Font& rFont) { m_aFont = rFont; }
+ const vcl::Font& GetFont() const { return m_aFont; }
+};
+
+class SmSymDefineDialog final : public weld::GenericDialogController
+{
+ VclPtr<VirtualDevice> m_xVirDev;
+ SmSymbolManager m_aSymbolMgrCopy;
+ SmSymbolManager& m_rSymbolMgr;
+ SmShowChar m_aOldSymbolDisplay;
+ SmShowChar m_aSymbolDisplay;
+ std::unique_ptr<SmSym> m_xOrigSymbol;
+ std::unique_ptr<SubsetMap> m_xSubsetMap;
+ std::unique_ptr<FontList> m_xFontList;
+ std::unique_ptr<weld::ComboBox> m_xOldSymbols;
+ std::unique_ptr<weld::ComboBox> m_xOldSymbolSets;
+ std::unique_ptr<weld::ComboBox> m_xSymbols;
+ std::unique_ptr<weld::ComboBox> m_xSymbolSets;
+ std::unique_ptr<weld::ComboBox> m_xFonts;
+ std::unique_ptr<weld::ComboBox> m_xFontsSubsetLB;
+ std::unique_ptr<weld::ComboBox> m_xStyles;
+ std::unique_ptr<weld::Label> m_xOldSymbolName;
+ std::unique_ptr<weld::Label> m_xOldSymbolSetName;
+ std::unique_ptr<weld::Label> m_xSymbolName;
+ std::unique_ptr<weld::Label> m_xSymbolSetName;
+ std::unique_ptr<weld::Button> m_xAddBtn;
+ std::unique_ptr<weld::Button> m_xChangeBtn;
+ std::unique_ptr<weld::Button> m_xDeleteBtn;
+ std::unique_ptr<weld::CustomWeld> m_xOldSymbolDisplay;
+ std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay;
+ std::unique_ptr<SvxShowCharSet> m_xCharsetDisplay;
+ std::unique_ptr<weld::CustomWeld> m_xCharsetDisplayArea;
+
+ DECL_LINK(OldSymbolChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(OldSymbolSetChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(ModifyHdl, weld::ComboBox&, void);
+ DECL_LINK(FontChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(SubsetChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(StyleChangeHdl, weld::ComboBox&, void);
+ DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
+ DECL_LINK(AddClickHdl, weld::Button&, void);
+ DECL_LINK(ChangeClickHdl, weld::Button&, void);
+ DECL_LINK(DeleteClickHdl, weld::Button&, void);
+
+ void FillSymbols(weld::ComboBox& rComboBox, bool bDeleteText = true);
+ void FillSymbolSets(weld::ComboBox& rComboBox, bool bDeleteText = true);
+ void FillFonts();
+ void FillStyles();
+
+ void SetSymbolSetManager(const SmSymbolManager &rMgr);
+ void SetFont(const OUString &rFontName, const OUString &rStyleName);
+ void SetOrigSymbol(const SmSym *pSymbol, const OUString &rSymbolSetName);
+ void UpdateButtons();
+
+ bool SelectSymbolSet(weld::ComboBox &rComboBox, const OUString &rSymbolSetName,
+ bool bDeleteText);
+ bool SelectSymbol(weld::ComboBox& rComboBox, const OUString &rSymbolName,
+ bool bDeleteText);
+ bool SelectFont(const OUString &rFontName, bool bApplyFont);
+ bool SelectStyle(const OUString &rStyleName, bool bApplyFont);
+
+ SmSym* GetSymbol(const weld::ComboBox& rComboBox);
+ const SmSym* GetSymbol(const weld::ComboBox& rComboBox) const
+ {
+ return const_cast<SmSymDefineDialog *>(this)->GetSymbol(rComboBox);
+ }
+
+public:
+ SmSymDefineDialog(weld::Window *pParent, OutputDevice *pFntListDevice, SmSymbolManager &rMgr);
+ virtual ~SmSymDefineDialog() override;
+
+ virtual short run() override;
+
+ void SelectOldSymbolSet(const OUString &rSymbolSetName)
+ {
+ SelectSymbolSet(*m_xOldSymbolSets, rSymbolSetName, false);
+ }
+
+ void SelectOldSymbol(const OUString &rSymbolName)
+ {
+ SelectSymbol(*m_xOldSymbols, rSymbolName, false);
+ }
+
+ bool SelectSymbolSet(const OUString &rSymbolSetName)
+ {
+ return SelectSymbolSet(*m_xSymbolSets, rSymbolSetName, false);
+ }
+
+ bool SelectSymbol(const OUString &rSymbolName)
+ {
+ return SelectSymbol(*m_xSymbols, rSymbolName, false);
+ }
+
+ bool SelectFont(const OUString &rFontName) { return SelectFont(rFontName, true); }
+ bool SelectStyle(const OUString &rStyleName) { return SelectStyle(rStyleName, true); };
+ void SelectChar(sal_Unicode cChar);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
new file mode 100644
index 000000000..1b425c91e
--- /dev/null
+++ b/starmath/inc/document.hxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_DOCUMENT_HXX
+#define INCLUDED_STARMATH_INC_DOCUMENT_HXX
+
+#include <rtl/ustring.hxx>
+#include <rtl/strbuf.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/lstner.hxx>
+#include <sax/fshelper.hxx>
+#include <unotools/lingucfg.hxx>
+#include <oox/core/filterbase.hxx>
+#include <oox/export/utils.hxx>
+
+#include <memory>
+#include <set>
+
+#include "format.hxx"
+#include "node.hxx"
+#include "parse.hxx"
+#include "smdllapi.hxx"
+
+class SfxPrinter;
+class Printer;
+class SmCursor;
+
+namespace oox::formulaimport { class XmlStream; }
+
+#define STAROFFICE_XML "StarOffice XML (Math)"
+#define MATHML_XML "MathML XML (Math)"
+
+/* Access to printer should happen through this class only
+ * ==========================================================================
+ *
+ * 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.
+ * But the container maybe works with a different MapUnit than the server.
+ * 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.
+ */
+
+class SmDocShell;
+class EditEngine;
+
+class SmPrinterAccess
+{
+ VclPtr<Printer> pPrinter;
+ VclPtr<OutputDevice> pRefDev;
+public:
+ explicit SmPrinterAccess( SmDocShell &rDocShell );
+ ~SmPrinterAccess();
+ Printer* GetPrinter() { return pPrinter.get(); }
+ OutputDevice* GetRefDev() { return pRefDev.get(); }
+};
+
+
+class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener
+{
+ friend class SmPrinterAccess;
+ friend class SmCursor;
+
+ OUString maText;
+ SmFormat maFormat;
+ SmParser maParser;
+ OUString maAccText;
+ SvtLinguOptions maLinguOptions;
+ std::unique_ptr<SmTableNode> mpTree;
+ SfxItemPool *mpEditEngineItemPool;
+ std::unique_ptr<EditEngine> mpEditEngine;
+ VclPtr<SfxPrinter> mpPrinter; //q.v. comment to SmPrinter Access!
+ VclPtr<Printer> mpTmpPrinter; //ditto
+ sal_uInt16 mnModifyCount;
+ bool mbFormulaArranged;
+ std::unique_ptr<SmCursor> mpCursor;
+ std::set< OUString > maUsedSymbols; // to export used symbols only when saving
+
+
+ virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
+
+ bool WriteAsMathType3( SfxMedium& );
+
+ virtual void Draw(OutputDevice *pDevice,
+ const JobSetup & rSetup,
+ sal_uInt16 nAspect) override;
+
+ virtual void FillClass(SvGlobalName* pClassName,
+ SotClipboardFormatId* pFormat,
+ OUString* pFullTypeName,
+ sal_Int32 nFileFormat,
+ bool bTemplate = false ) const override;
+
+ virtual void OnDocumentPrinterChanged( Printer * ) override;
+ virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
+ virtual bool Load( SfxMedium& rMedium ) override;
+ virtual bool Save() override;
+ virtual bool SaveAs( SfxMedium& rMedium ) override;
+
+ Printer *GetPrt();
+ OutputDevice* GetRefDev();
+
+ void SetFormulaArranged(bool bVal) { mbFormulaArranged = bVal; }
+
+ virtual bool ConvertFrom(SfxMedium &rMedium) override;
+
+ /** Called whenever the formula is changed
+ * Deletes the current cursor
+ */
+ void InvalidateCursor();
+
+public:
+ SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(1))
+
+ SFX_DECL_OBJECTFACTORY();
+
+private:
+ /// SfxInterface initializer.
+ static void InitInterface_Impl();
+
+public:
+ explicit SmDocShell( SfxModelFlags i_nSfxCreationFlags );
+ virtual ~SmDocShell() override;
+
+ virtual bool ConvertTo( SfxMedium &rMedium ) override;
+
+ // For unit tests, not intended to use in other context
+ void SetGreekCharStyle(sal_Int16 nVal) { maFormat.SetGreekCharStyle(nVal); }
+
+ static void LoadSymbols();
+ static void SaveSymbols();
+
+ void ArrangeFormula();
+
+ //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
+ bool HasPrinter() const { return mpPrinter != nullptr; }
+ SfxPrinter *GetPrinter() { GetPrt(); return mpPrinter; }
+ void SetPrinter( SfxPrinter * );
+
+ OUString GetComment() const;
+
+ // to replace chars that can not be saved with the document...
+ void ReplaceBadChars();
+
+ void UpdateText();
+ void SetText(const OUString& rBuffer);
+ const OUString& GetText() const { return maText; }
+ void SetFormat(SmFormat const & rFormat);
+ const SmFormat& GetFormat() const { return maFormat; }
+
+ void Parse();
+ SmParser & GetParser() { return maParser; }
+ const SmTableNode *GetFormulaTree() const { return mpTree.get(); }
+ void SetFormulaTree(SmTableNode *pTree) { mpTree.reset(pTree); }
+
+ const std::set< OUString > & GetUsedSymbols() const { return maUsedSymbols; }
+
+ OUString const & GetAccessibleText();
+
+ EditEngine & GetEditEngine();
+
+ void DrawFormula(OutputDevice &rDev, Point &rPosition, bool bDrawSelection = false);
+ Size GetSize();
+
+ void Repaint();
+
+ virtual SfxUndoManager *GetUndoManager () override;
+
+ static SfxItemPool& GetPool();
+
+ void Execute( SfxRequest& rReq );
+ void GetState(SfxItemSet &);
+
+ virtual void SetVisArea (const tools::Rectangle & rVisArea) override;
+ virtual void SetModified(bool bModified = true) override;
+
+ /** 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.
+ */
+ bool HasCursor() const;
+
+ void writeFormulaOoxml(const ::sax_fastparser::FSHelperPtr& pSerializer,
+ oox::core::OoxmlVersion version,
+ oox::drawingml::DocumentType documentType,
+ const sal_Int8 nAlign);
+ void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding);
+ void readFormulaOoxml( oox::formulaimport::XmlStream& stream );
+
+ void UpdateEditEngineDefaultFonts(const Color& aTextColor);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx
new file mode 100644
index 000000000..c1ce769ab
--- /dev/null
+++ b/starmath/inc/edit.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_EDIT_HXX
+#define INCLUDED_STARMATH_INC_EDIT_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/idle.hxx>
+#include <vcl/transfer.hxx>
+#include <editeng/editdata.hxx>
+#include <memory>
+
+class SmDocShell;
+class SmViewShell;
+class EditView;
+class EditEngine;
+class EditStatus;
+class ScrollBar;
+class ScrollBarBox;
+class DataChangedEvent;
+class SmCmdBoxWindow;
+class SmEditAccessible;
+class CommandEvent;
+class Timer;
+
+namespace svtools { class ColorConfig; }
+
+void SmGetLeftSelectionPart(const ESelection &rSelection, sal_Int32 &nPara, sal_uInt16 &nPos);
+
+class SmEditWindow final : public vcl::Window, public DropTargetHelper
+{
+ rtl::Reference<SmEditAccessible> mxAccessible;
+
+ SmCmdBoxWindow& rCmdBox;
+ std::unique_ptr<EditView> pEditView;
+ VclPtr<ScrollBar> pHScrollBar;
+ VclPtr<ScrollBar> pVScrollBar;
+ VclPtr<ScrollBarBox> pScrollBox;
+ Idle aModifyIdle;
+ Idle aCursorMoveIdle;
+ ESelection aOldSelection;
+
+ virtual void KeyInput(const KeyEvent& rKEvt) override;
+ virtual void Command(const CommandEvent& rCEvt) override;
+
+ DECL_LINK(ModifyTimerHdl, Timer *, void);
+ DECL_LINK(CursorMoveTimerHdl, Timer *, void);
+
+ virtual void ApplySettings(vcl::RenderContext&) override;
+ virtual void DataChanged( const DataChangedEvent& ) override;
+ virtual void Resize() override;
+ virtual void MouseMove(const MouseEvent &rEvt) override;
+ virtual void MouseButtonUp(const MouseEvent &rEvt) override;
+ virtual void MouseButtonDown(const MouseEvent &rEvt) override;
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+
+ DECL_LINK(EditStatusHdl, EditStatus&, void);
+ DECL_LINK(ScrollHdl, ScrollBar*, void);
+
+ void CreateEditView();
+ tools::Rectangle AdjustScrollBars();
+ void SetScrollBarRanges();
+ void InitScrollBars();
+ void InvalidateSlots();
+ void UpdateStatus(bool bSetDocModified);
+
+public:
+ explicit SmEditWindow(SmCmdBoxWindow& rMyCmdBoxWin);
+ virtual ~SmEditWindow() override;
+ virtual void dispose() override;
+
+ SmDocShell* GetDoc();
+ SmViewShell* GetView();
+ EditView* GetEditView();
+ EditEngine* GetEditEngine();
+
+ // Window
+ virtual void SetText(const OUString& rText) override;
+ virtual OUString GetText() const override;
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
+
+ ESelection GetSelection() const;
+ void SetSelection(const ESelection& rSel);
+
+ bool IsEmpty() const;
+ bool IsSelected() const;
+ bool IsAllSelected() const;
+ void Cut();
+ void Copy();
+ void Paste();
+ void Delete();
+ void SelectAll();
+ void InsertText(const OUString& rText);
+ void MarkError(const Point &rPos);
+ void SelNextMark();
+ void SelPrevMark();
+ static bool HasMark(const OUString &rText);
+
+ void Flush() override;
+ void DeleteEditView();
+
+ bool HandleWheelCommands(const CommandEvent& rCEvt);
+ bool IsInlineEditEnabled();
+ void StartCursorMove();
+
+ // for Accessibility
+ virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
+
+ using Window::GetAccessible;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx
new file mode 100644
index 000000000..a05123d6e
--- /dev/null
+++ b/starmath/inc/error.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_ERROR_HXX
+#define INCLUDED_STARMATH_INC_ERROR_HXX
+
+#include <rtl/ustring.hxx>
+
+class SmNode;
+
+enum class SmParseError
+{
+ None,
+ UnexpectedChar,
+ UnexpectedToken,
+ PoundExpected,
+ ColorExpected,
+ LgroupExpected,
+ RgroupExpected,
+ LbraceExpected,
+ RbraceExpected,
+ ParentMismatch,
+ RightExpected,
+ FontExpected,
+ SizeExpected,
+ DoubleAlign,
+ DoubleSubsupscript
+};
+
+
+struct SmErrorDesc
+{
+ SmParseError m_eType;
+ SmNode *m_pNode;
+ OUString m_aText;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/format.hxx b/starmath/inc/format.hxx
new file mode 100644
index 000000000..14fbfc2a6
--- /dev/null
+++ b/starmath/inc/format.hxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_FORMAT_HXX
+#define INCLUDED_STARMATH_INC_FORMAT_HXX
+
+
+#include <svl/hint.hxx>
+#include <svl/SfxBroadcaster.hxx>
+#include "utility.hxx"
+#include "types.hxx"
+
+
+#define FNTNAME_TIMES "Times New Roman"
+#define FNTNAME_HELV "Helvetica"
+#define FNTNAME_COUR "Courier"
+#define FNTNAME_MATH FONTNAME_MATH
+
+
+// symbolic names used as array indices
+#define SIZ_BEGIN 0
+#define SIZ_TEXT 0
+#define SIZ_INDEX 1
+#define SIZ_FUNCTION 2
+#define SIZ_OPERATOR 3
+#define SIZ_LIMITS 4
+#define SIZ_END 4
+
+// symbolic names used as array indices
+#define FNT_BEGIN 0
+#define FNT_VARIABLE 0
+#define FNT_FUNCTION 1
+#define FNT_NUMBER 2
+#define FNT_TEXT 3
+#define FNT_SERIF 4
+#define FNT_SANS 5
+#define FNT_FIXED 6
+#define FNT_MATH 7
+#define FNT_END 7
+
+// symbolic names used as array indices
+#define DIS_BEGIN 0
+#define DIS_HORIZONTAL 0
+#define DIS_VERTICAL 1
+#define DIS_ROOT 2
+#define DIS_SUPERSCRIPT 3
+#define DIS_SUBSCRIPT 4
+#define DIS_NUMERATOR 5
+#define DIS_DENOMINATOR 6
+#define DIS_FRACTION 7
+#define DIS_STROKEWIDTH 8
+#define DIS_UPPERLIMIT 9
+#define DIS_LOWERLIMIT 10
+#define DIS_BRACKETSIZE 11
+#define DIS_BRACKETSPACE 12
+#define DIS_MATRIXROW 13
+#define DIS_MATRIXCOL 14
+#define DIS_ORNAMENTSIZE 15
+#define DIS_ORNAMENTSPACE 16
+#define DIS_OPERATORSIZE 17
+#define DIS_OPERATORSPACE 18
+#define DIS_LEFTSPACE 19
+#define DIS_RIGHTSPACE 20
+#define DIS_TOPSPACE 21
+#define DIS_BOTTOMSPACE 22
+#define DIS_NORMALBRACKETSIZE 23
+#define DIS_END 23
+
+
+enum class SmHorAlign {
+ Left,
+ Center,
+ Right
+};
+
+class SmFormat final : public SfxBroadcaster
+{
+ SmFace vFont[FNT_END + 1];
+ bool bDefaultFont[FNT_END + 1];
+ Size aBaseSize;
+ sal_uInt16 vSize[SIZ_END + 1];
+ sal_uInt16 vDist[DIS_END + 1];
+ SmHorAlign eHorAlign;
+ sal_Int16 nGreekCharStyle;
+ bool bIsTextmode,
+ bScaleNormalBrackets;
+
+public:
+ SmFormat();
+ SmFormat(const SmFormat &rFormat) : SfxBroadcaster() { *this = rFormat; }
+
+ const Size & GetBaseSize() const { return aBaseSize; }
+ void SetBaseSize(const Size &rSize) { aBaseSize = rSize; }
+
+ const SmFace & GetFont(sal_uInt16 nIdent) const { return vFont[nIdent]; }
+ void SetFont(sal_uInt16 nIdent, const SmFace &rFont, bool bDefault = false);
+ void SetFontSize(sal_uInt16 nIdent, const Size &rSize) { vFont[nIdent].SetSize( rSize ); }
+
+ void SetDefaultFont(sal_uInt16 nIdent, bool bVal) { bDefaultFont[nIdent] = bVal; }
+ bool IsDefaultFont(sal_uInt16 nIdent) const { return bDefaultFont[nIdent]; }
+
+ sal_uInt16 GetRelSize(sal_uInt16 nIdent) const { return vSize[nIdent]; }
+ void SetRelSize(sal_uInt16 nIdent, sal_uInt16 nVal) { vSize[nIdent] = nVal;}
+
+ sal_uInt16 GetDistance(sal_uInt16 nIdent) const { return vDist[nIdent]; }
+ void SetDistance(sal_uInt16 nIdent, sal_uInt16 nVal) { vDist[nIdent] = nVal; }
+
+ SmHorAlign GetHorAlign() const { return eHorAlign; }
+ void SetHorAlign(SmHorAlign eAlign) { eHorAlign = eAlign; }
+
+ bool IsTextmode() const { return bIsTextmode; }
+ void SetTextmode(bool bVal) { bIsTextmode = bVal; }
+
+ sal_Int16 GetGreekCharStyle() const { return nGreekCharStyle; }
+ void SetGreekCharStyle(sal_Int16 nVal) { nGreekCharStyle = nVal; }
+
+ bool IsScaleNormalBrackets() const { return bScaleNormalBrackets; }
+ void SetScaleNormalBrackets(bool bVal) { bScaleNormalBrackets = bVal; }
+
+ SmFormat & operator = (const SmFormat &rFormat);
+
+ bool operator == (const SmFormat &rFormat) const;
+ inline bool operator != (const SmFormat &rFormat) const;
+
+ void RequestApplyChanges()
+ {
+ Broadcast(SfxHint(SfxHintId::MathFormatChanged));
+ }
+
+};
+
+inline bool SmFormat::operator != (const SmFormat &rFormat) const
+{
+ return !(*this == rFormat);
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/helpids.h b/starmath/inc/helpids.h
new file mode 100644
index 000000000..7e13c3ac8
--- /dev/null
+++ b/starmath/inc/helpids.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_HELPIDS_H
+#define INCLUDED_STARMATH_INC_HELPIDS_H
+
+#define HID_SMA_WIN_DOCUMENT "STARMATH_HID_SMA_WIN_DOCUMENT"
+#define HID_SMA_COMMAND_WIN_EDIT "STARMATH_HID_SMA_COMMAND_WIN_EDIT"
+
+#define HID_SMA_COMMAND_WIN "STARMATH_HID_SMA_COMMAND_WIN"
+
+#define HID_SMA_DEFAULT_DIST "STARMATH_HID_SMA_DEFAULT_DIST"
+#define HID_SMA_LINE_DIST "STARMATH_HID_SMA_LINE_DIST"
+#define HID_SMA_ROOT_DIST "STARMATH_HID_SMA_ROOT_DIST"
+#define HID_SMA_SUP_DIST "STARMATH_HID_SMA_SUP_DIST"
+#define HID_SMA_SUB_DIST "STARMATH_HID_SMA_SUB_DIST"
+#define HID_SMA_NUMERATOR_DIST "STARMATH_HID_SMA_NUMERATOR_DIST"
+#define HID_SMA_DENOMINATOR_DIST "STARMATH_HID_SMA_DENOMINATOR_DIST"
+#define HID_SMA_FRACLINE_EXCWIDTH "STARMATH_HID_SMA_FRACLINE_EXCWIDTH"
+#define HID_SMA_FRACLINE_LINEWIDTH "STARMATH_HID_SMA_FRACLINE_LINEWIDTH"
+#define HID_SMA_UPPERLIMIT_DIST "STARMATH_HID_SMA_UPPERLIMIT_DIST"
+#define HID_SMA_LOWERLIMIT_DIST "STARMATH_HID_SMA_LOWERLIMIT_DIST"
+#define HID_SMA_BRACKET_EXCHEIGHT "STARMATH_HID_SMA_BRACKET_EXCHEIGHT"
+#define HID_SMA_BRACKET_DIST "STARMATH_HID_SMA_BRACKET_DIST"
+#define HID_SMA_MATRIXROW_DIST "STARMATH_HID_SMA_MATRIXROW_DIST"
+#define HID_SMA_MATRIXCOL_DIST "STARMATH_HID_SMA_MATRIXCOL_DIST"
+#define HID_SMA_ATTRIBUT_DIST "STARMATH_HID_SMA_ATTRIBUT_DIST"
+#define HID_SMA_INTERATTRIBUT_DIST "STARMATH_HID_SMA_INTERATTRIBUT_DIST"
+#define HID_SMA_OPERATOR_EXCHEIGHT "STARMATH_HID_SMA_OPERATOR_EXCHEIGHT"
+#define HID_SMA_OPERATOR_DIST "STARMATH_HID_SMA_OPERATOR_DIST"
+#define HID_SMA_LEFTBORDER_DIST "STARMATH_HID_SMA_LEFTBORDER_DIST"
+#define HID_SMA_RIGHTBORDER_DIST "STARMATH_HID_SMA_RIGHTBORDER_DIST"
+#define HID_SMA_UPPERBORDER_DIST "STARMATH_HID_SMA_UPPERBORDER_DIST"
+#define HID_SMA_LOWERBORDER_DIST "STARMATH_HID_SMA_LOWERBORDER_DIST"
+#define HID_SMA_BRACKET_EXCHEIGHT2 "STARMATH_HID_SMA_BRACKET_EXCHEIGHT2"
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
new file mode 100644
index 000000000..1e301369c
--- /dev/null
+++ b/starmath/inc/node.hxx
@@ -0,0 +1,1272 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_NODE_HXX
+#define INCLUDED_STARMATH_INC_NODE_HXX
+
+#include "types.hxx"
+#include "token.hxx"
+#include "rect.hxx"
+#include "format.hxx"
+
+#include <o3tl/typed_flags_set.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <cassert>
+#include <vector>
+
+enum class FontAttribute {
+ None = 0x0000,
+ Bold = 0x0001,
+ Italic = 0x0002
+};
+
+namespace o3tl
+{
+ template<> struct typed_flags<FontAttribute> : is_typed_flags<FontAttribute, 0x0003> {};
+}
+
+
+enum class FontSizeType {
+ ABSOLUT = 1,
+ PLUS = 2,
+ MINUS = 3,
+ MULTIPLY = 4,
+ DIVIDE = 5
+};
+
+// flags to interdict respective status changes
+enum class FontChangeMask {
+ None = 0x0000,
+ Face = 0x0001,
+ Size = 0x0002,
+ Bold = 0x0004,
+ Italic = 0x0008,
+ Color = 0x0010,
+ Phantom = 0x0020
+};
+
+namespace o3tl
+{
+ template<> struct typed_flags<FontChangeMask> : is_typed_flags<FontChangeMask, 0x003f> {};
+}
+
+
+class SmVisitor;
+class SmDocShell;
+class SmNode;
+class SmStructureNode;
+
+typedef std::vector< SmNode * > SmNodeArray;
+
+enum class SmScaleMode
+{
+ None,
+ Width,
+ Height
+};
+
+enum class SmNodeType
+{
+/* 0*/ Table, Brace, Bracebody, Oper, Align,
+/* 5*/ Attribut, Font, UnHor, BinHor, BinVer,
+/*10*/ BinDiagonal, SubSup, Matrix, Place, Text,
+/*15*/ Special, GlyphSpecial, Math, Blank, Error,
+/*20*/ Line, Expression, PolyLine, Root, RootSymbol,
+/*25*/ Rectangle, VerticalBrace, MathIdent
+};
+
+
+class SmNode : public SmRect
+{
+ SmFace maFace;
+
+ SmToken maNodeToken;
+ SmNodeType meType;
+ SmScaleMode meScaleMode;
+ RectHorAlign meRectHorAlign;
+ FontChangeMask mnFlags;
+ FontAttribute mnAttributes;
+ bool mbIsPhantom;
+ bool mbIsSelected;
+ // index in accessible text; -1 if not (yet) applicable
+ sal_Int32 mnAccIndex;
+
+protected:
+ SmNode(SmNodeType eNodeType, const SmToken &rNodeToken);
+
+public:
+ SmNode(const SmNode&) = delete;
+ SmNode& operator=(const SmNode&) = delete;
+
+ virtual ~SmNode();
+
+ /**
+ * Returns true if this is an instance of SmVisibleNode's subclass, false otherwise.
+ */
+ virtual bool IsVisible() const = 0;
+
+ virtual size_t GetNumSubNodes() const = 0;
+ virtual SmNode * GetSubNode(size_t nIndex) = 0;
+ const SmNode * GetSubNode(size_t nIndex) const
+ {
+ return const_cast<SmNode *>(this)->GetSubNode(nIndex);
+ }
+
+ virtual const SmNode * GetLeftMost() const;
+
+ FontChangeMask &Flags() { return mnFlags; }
+ FontAttribute &Attributes() { return mnAttributes; }
+
+ bool IsPhantom() const { return mbIsPhantom; }
+ void SetPhantom(bool bIsPhantom);
+ void SetColor(const Color &rColor);
+
+ void SetAttribut(FontAttribute nAttrib);
+ void ClearAttribut(FontAttribute nAttrib);
+
+ const SmFace & GetFont() const { return maFace; };
+ SmFace & GetFont() { return maFace; };
+
+ void SetFont(const SmFace &rFace);
+ void SetFontSize(const Fraction &rRelSize, FontSizeType nType);
+ void SetSize(const Fraction &rScale);
+
+ /** Prepare preliminary settings about font and text
+ * (e.g. maFace, meRectHorAlign, mnFlags, mnAttributes, etc.)
+ */
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth);
+ void PrepareAttributes();
+
+ void SetRectHorAlign(RectHorAlign eHorAlign, bool bApplyToSubTree = true );
+ RectHorAlign GetRectHorAlign() const { return meRectHorAlign; }
+
+ const SmRect & GetRect() const { return *this; }
+
+ void Move(const Point &rPosition);
+ void MoveTo(const Point &rPosition) { Move(rPosition - GetTopLeft()); }
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) = 0;
+ virtual void CreateTextFromNode(OUStringBuffer &rText);
+
+ virtual void GetAccessibleText( OUStringBuffer &rText ) const = 0;
+ sal_Int32 GetAccessibleIndex() const { return mnAccIndex; }
+ void SetAccessibleIndex(sal_Int32 nAccIndex) { mnAccIndex = nAccIndex; }
+ const SmNode * FindNodeWithAccessibleIndex(sal_Int32 nAccIndex) const;
+
+ sal_uInt16 GetRow() const { return sal::static_int_cast<sal_uInt16>(maNodeToken.nRow); }
+ sal_uInt16 GetColumn() const { return sal::static_int_cast<sal_uInt16>(maNodeToken.nCol); }
+
+ SmScaleMode GetScaleMode() const { return meScaleMode; }
+ void SetScaleMode(SmScaleMode eMode) { meScaleMode = eMode; }
+
+ virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth);
+ virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight);
+
+ SmNodeType GetType() const { return meType; }
+ const SmToken & GetToken() const { return maNodeToken; }
+
+ const SmNode * FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const;
+ const SmNode * FindRectClosestTo(const Point &rPoint) const;
+
+ /** Accept a visitor
+ * Calls the method for this class on the visitor
+ */
+ virtual void Accept(SmVisitor* pVisitor) = 0;
+
+ /** True if this node is selected */
+ bool IsSelected() const {return mbIsSelected;}
+ void SetSelected(bool Selected) {mbIsSelected = Selected;}
+
+ /** Get the parent node of this node */
+ SmStructureNode* GetParent(){ return mpParentNode; }
+ const SmStructureNode* GetParent() const { return mpParentNode; }
+ /** Set the parent node */
+ void SetParent(SmStructureNode* parent){
+ mpParentNode = parent;
+ }
+
+ /** Set the token for this node */
+ void SetToken(SmToken const & token){
+ maNodeToken = token;
+ }
+
+private:
+ SmStructureNode* mpParentNode;
+};
+
+
+/** Abstract baseclass for all composite node
+ *
+ * Subclasses of this class can have subnodes. Nodes that doesn't derivate from
+ * this class does not have subnodes.
+ */
+class SmStructureNode : public SmNode
+{
+ SmNodeArray maSubNodes;
+
+protected:
+ SmStructureNode(SmNodeType eNodeType, const SmToken &rNodeToken, size_t nSize = 0)
+ : SmNode(eNodeType, rNodeToken)
+ , maSubNodes(nSize)
+ {}
+
+public:
+ virtual ~SmStructureNode() override;
+
+ virtual bool IsVisible() const override;
+
+ virtual size_t GetNumSubNodes() const override;
+
+ using SmNode::GetSubNode;
+ virtual SmNode * GetSubNode(size_t nIndex) override;
+ void ClearSubNodes();
+ void SetSubNodes(std::unique_ptr<SmNode> pFirst, std::unique_ptr<SmNode> pSecond, std::unique_ptr<SmNode> pThird = nullptr);
+ void SetSubNodes(SmNodeArray&& rNodeArray);
+
+ virtual void GetAccessibleText( OUStringBuffer &rText ) const override;
+
+ SmNodeArray::iterator begin() {return maSubNodes.begin();}
+ SmNodeArray::iterator end() {return maSubNodes.end();}
+ SmNodeArray::reverse_iterator rbegin() {return maSubNodes.rbegin();}
+ SmNodeArray::reverse_iterator rend() {return maSubNodes.rend();}
+
+ /** Get the index of a child node
+ *
+ * Returns -1, if pSubNode isn't a subnode of this.
+ */
+ int IndexOfSubNode(SmNode const * pSubNode)
+ {
+ size_t nSize = GetNumSubNodes();
+ for (size_t i = 0; i < nSize; i++)
+ if (pSubNode == GetSubNode(i))
+ return i;
+ return -1;
+ }
+
+ void SetSubNode(size_t nIndex, SmNode* pNode)
+ {
+ size_t size = maSubNodes.size();
+ if (size <= nIndex)
+ {
+ //Resize subnodes array
+ maSubNodes.resize(nIndex + 1);
+ //Set new slots to NULL except at nIndex
+ for (size_t i = size; i < nIndex; i++)
+ maSubNodes[i] = nullptr;
+ }
+ maSubNodes[nIndex] = pNode;
+ if (pNode)
+ pNode->SetParent(this);
+ }
+
+private:
+ /** Sets parent on children of this node */
+ void ClaimPaternity();
+};
+
+
+/** Abstract base class for all visible node
+ *
+ * Nodes that doesn't derivate from this class doesn't draw anything, but their
+ * children.
+ */
+class SmVisibleNode : public SmNode
+{
+protected:
+ SmVisibleNode(SmNodeType eNodeType, const SmToken &rNodeToken)
+ : SmNode(eNodeType, rNodeToken)
+ {}
+
+public:
+
+ virtual bool IsVisible() const override;
+ virtual size_t GetNumSubNodes() const override;
+ using SmNode::GetSubNode;
+ virtual SmNode * GetSubNode(size_t nIndex) override;
+};
+
+
+class SmGraphicNode : public SmVisibleNode
+{
+protected:
+ SmGraphicNode(SmNodeType eNodeType, const SmToken &rNodeToken)
+ : SmVisibleNode(eNodeType, rNodeToken)
+ {}
+
+public:
+
+ virtual void GetAccessibleText( OUStringBuffer &rText ) const override;
+};
+
+
+/** Draws a rectangle
+ *
+ * Used for drawing the line in the OVER and OVERSTRIKE commands.
+ */
+class SmRectangleNode final : public SmGraphicNode
+{
+ Size maToSize;
+
+public:
+ explicit SmRectangleNode(const SmToken &rNodeToken)
+ : SmGraphicNode(SmNodeType::Rectangle, rNodeToken)
+ {}
+
+ virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
+ virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Polygon line node
+ *
+ * Used to draw the slash of the WIDESLASH command by SmBinDiagonalNode.
+ */
+class SmPolyLineNode final : public SmGraphicNode
+{
+ tools::Polygon maPoly;
+ Size maToSize;
+ long mnWidth;
+
+public:
+ explicit SmPolyLineNode(const SmToken &rNodeToken);
+
+ long GetWidth() const { return mnWidth; }
+ tools::Polygon &GetPolygon() { return maPoly; }
+
+ virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
+ virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Text node
+ *
+ * @remarks This class also serves as baseclass for all nodes that contains text.
+ */
+class SmTextNode : public SmVisibleNode
+{
+ OUString maText;
+ sal_uInt16 mnFontDesc;
+ /** Index within text where the selection starts
+ * @remarks Only valid if SmNode::IsSelected() is true
+ */
+ sal_Int32 mnSelectionStart;
+ /** Index within text where the selection ends
+ * @remarks Only valid if SmNode::IsSelected() is true
+ */
+ sal_Int32 mnSelectionEnd;
+
+protected:
+ SmTextNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 nFontDescP );
+
+public:
+ SmTextNode(const SmToken &rNodeToken, sal_uInt16 nFontDescP );
+
+ sal_uInt16 GetFontDesc() const { return mnFontDesc; }
+ void SetText(const OUString &rText) { maText = rText; }
+ const OUString & GetText() const { return maText; }
+ /** Change the text of this node, including the underlying token */
+ void ChangeText(const OUString &rText) {
+ maText = rText;
+ SmToken token = GetToken();
+ token.aText = rText;
+ SetToken(token); //TODO: Merge this with AdjustFontDesc for better performance
+ AdjustFontDesc();
+ }
+ /** Try to guess the correct FontDesc, used during visual editing */
+ void AdjustFontDesc();
+ /** Index within GetText() where the selection starts
+ * @remarks Only valid of SmNode::IsSelected() is true
+ */
+ sal_Int32 GetSelectionStart() const {return mnSelectionStart;}
+ /** Index within GetText() where the selection end
+ * @remarks Only valid of SmNode::IsSelected() is true
+ */
+ sal_Int32 GetSelectionEnd() const {return mnSelectionEnd;}
+ /** Set the index within GetText() where the selection starts */
+ void SetSelectionStart(sal_Int32 index) {mnSelectionStart = index;}
+ /** Set the index within GetText() where the selection end */
+ void SetSelectionEnd(sal_Int32 index) {mnSelectionEnd = index;}
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ virtual void CreateTextFromNode(OUStringBuffer &rText) override;
+
+ virtual void GetAccessibleText( OUStringBuffer &rText ) const override;
+ void Accept(SmVisitor* pVisitor) override;
+ /**
+ Converts the character from StarMath's private area symbols to a matching Unicode
+ character, if necessary. To be used when converting GetText() to a normal text.
+ */
+ static sal_Unicode ConvertSymbolToUnicode(sal_Unicode nIn);
+};
+
+
+/** Special node for user defined characters
+ *
+ * Node used for pre- and user-defined characters from:
+ * officecfg/registry/data/org/openoffice/Office/Math.xcu
+ *
+ * This is just single characters, I think.
+ */
+class SmSpecialNode : public SmTextNode
+{
+ bool mbIsFromGreekSymbolSet;
+
+protected:
+ SmSpecialNode(SmNodeType eNodeType, const SmToken &rNodeToken, sal_uInt16 _nFontDesc);
+
+public:
+ explicit SmSpecialNode(const SmToken &rNodeToken);
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Glyph node for custom operators
+ *
+ * This node is used with commands: oper, uoper and boper.
+ * E.g. in "A boper op B", "op" will be an instance of SmGlyphSpecialNode.
+ * "boper" simply interprets "op", the following token, as a binary operator.
+ * The command "uoper" interprets the following token as unary operator.
+ * For these commands an instance of SmGlyphSpecialNode is used for the
+ * operator token, following the command.
+ */
+class SmGlyphSpecialNode final : public SmSpecialNode
+{
+public:
+ explicit SmGlyphSpecialNode(const SmToken &rNodeToken)
+ : SmSpecialNode(SmNodeType::GlyphSpecial, rNodeToken, FNT_MATH)
+ {}
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Math symbol node
+ *
+ * Use for math symbols such as plus, minus and integral in the INT command.
+ */
+class SmMathSymbolNode : public SmSpecialNode
+{
+protected:
+ SmMathSymbolNode(SmNodeType eNodeType, const SmToken &rNodeToken)
+ : SmSpecialNode(eNodeType, rNodeToken, FNT_MATH)
+ {
+ sal_Unicode cChar = GetToken().cMathChar;
+ if (u'\0' != cChar)
+ SetText(OUString(cChar));
+ }
+
+public:
+ explicit SmMathSymbolNode(const SmToken &rNodeToken);
+
+ virtual void AdaptToX(OutputDevice &rDev, sal_uLong nWidth) override;
+ virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Math Identifier
+ *
+ * This behaves essentially the same as SmMathSymbolNode and is only used to
+ * represent math symbols that should be exported as <mi> elements rather than
+ * <mo> elements.
+ */
+class SmMathIdentifierNode final : public SmMathSymbolNode
+{
+public:
+ explicit SmMathIdentifierNode(const SmToken &rNodeToken)
+ : SmMathSymbolNode(SmNodeType::MathIdent, rNodeToken) {}
+};
+
+
+/** Root symbol node
+ *
+ * Root symbol node used by SmRootNode to create the root symbol, in front of
+ * the line with the line above. I don't think this node should be used for
+ * anything else.
+ */
+class SmRootSymbolNode final : public SmMathSymbolNode
+{
+ sal_uLong mnBodyWidth; // width of body (argument) of root sign
+
+public:
+ explicit SmRootSymbolNode(const SmToken &rNodeToken)
+ : SmMathSymbolNode(SmNodeType::RootSymbol, rNodeToken)
+ , mnBodyWidth(0)
+ {
+ }
+
+ sal_uLong GetBodyWidth() const {return mnBodyWidth;};
+ virtual void AdaptToX(OutputDevice &rDev, sal_uLong nHeight) override;
+ virtual void AdaptToY(OutputDevice &rDev, sal_uLong nHeight) override;
+
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Place node
+ *
+ * Used to create the <?> command, that denotes place where something can be
+ * written.
+ * It is drawn as a square with a shadow.
+ */
+class SmPlaceNode final : public SmMathSymbolNode
+{
+public:
+ explicit SmPlaceNode(const SmToken &rNodeToken)
+ : SmMathSymbolNode(SmNodeType::Place, rNodeToken)
+ {
+ }
+ SmPlaceNode() : SmMathSymbolNode(SmNodeType::Place, SmToken(TPLACE, MS_PLACE, "<?>")) {};
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Error node, for parsing errors
+ *
+ * This node is used for parsing errors and draws a questionmark turned upside
+ * down (inverted question mark).
+ */
+class SmErrorNode final : public SmMathSymbolNode
+{
+public:
+ explicit SmErrorNode(const SmToken &rNodeToken)
+ : SmMathSymbolNode(SmNodeType::Error, rNodeToken)
+ {
+ SetText(OUString(MS_ERROR));
+ }
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Table node
+ *
+ * This is the root node for the formula tree. This node is also used for the
+ * STACK and BINOM commands. When used for root node, its
+ * children are instances of SmLineNode, and in some obscure cases the child
+ * can be an instance of SmExpressionNode, mainly when errors occur.
+ */
+class SmTableNode final : public SmStructureNode
+{
+ long mnFormulaBaseline;
+public:
+ explicit SmTableNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Table, rNodeToken)
+ , mnFormulaBaseline(0)
+ {
+ }
+
+ virtual const SmNode * GetLeftMost() const override;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ long GetFormulaBaseline() const;
+
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** A line
+ *
+ * Used as child of SmTableNode when the SmTableNode is the root node of the
+ * formula tree.
+ */
+class SmLineNode : public SmStructureNode
+{
+ bool mbUseExtraSpaces;
+
+protected:
+ SmLineNode(SmNodeType eNodeType, const SmToken &rNodeToken)
+ : SmStructureNode(eNodeType, rNodeToken)
+ , mbUseExtraSpaces(true)
+ {
+ }
+
+public:
+ explicit SmLineNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Line, rNodeToken)
+ , mbUseExtraSpaces(true)
+ {
+ }
+
+ void SetUseExtraSpaces(bool bVal) { mbUseExtraSpaces = bVal; }
+ bool IsUseExtraSpaces() const { return mbUseExtraSpaces; };
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Expression node
+ *
+ * Used whenever you have an expression such as "A OVER {B + C}", here there is
+ * an expression node that allows "B + C" to be the denominator of the
+ * SmBinVerNode, that the OVER command creates.
+ */
+class SmExpressionNode final : public SmLineNode
+{
+public:
+ explicit SmExpressionNode(const SmToken &rNodeToken)
+ : SmLineNode(SmNodeType::Expression, rNodeToken)
+ {}
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Unary horizontal node
+ *
+ * The same as SmBinHorNode except this is for unary operators.
+ */
+class SmUnHorNode final : public SmStructureNode
+{
+public:
+ explicit SmUnHorNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::UnHor, rNodeToken, 2)
+ {
+ }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Root node
+ *
+ * Used for create square roots and other roots, example:
+ * \f$ \sqrt[\mbox{[Argument]}]{\mbox{[Body]}} \f$.
+ *
+ * Children:<BR>
+ * 0: Argument (optional)<BR>
+ * 1: Symbol (instance of SmRootSymbolNode)<BR>
+ * 2: Body<BR>
+ * Where argument is optional and may be NULL.
+ */
+class SmRootNode final : public SmStructureNode
+{
+public:
+ explicit SmRootNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Root, rNodeToken, 3)
+ {
+ }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+
+ SmNode* Argument();
+ const SmNode* Argument() const;
+ SmRootSymbolNode* Symbol();
+ const SmRootSymbolNode* Symbol() const;
+ SmNode* Body();
+ const SmNode* Body() const;
+};
+
+
+/** Binary horizontal node
+ *
+ * This node is used for binary operators. In a formula such as "A + B".
+ *
+ * Children:<BR>
+ * 0: Left operand<BR>
+ * 1: Binary operator<BR>
+ * 2: Right operand<BR>
+ *
+ * None of the children may be NULL.
+ */
+class SmBinHorNode final : public SmStructureNode
+{
+public:
+ explicit SmBinHorNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::BinHor, rNodeToken, 3)
+ {
+ }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+
+ SmNode* Symbol();
+ const SmNode* Symbol() const;
+ SmNode* LeftOperand();
+ const SmNode* LeftOperand() const;
+ SmNode* RightOperand();
+ const SmNode* RightOperand() const;
+};
+
+
+/** Binary horizontal node
+ *
+ * This node is used for creating the OVER command, consider the formula:
+ * "numerator OVER denominator", which looks like
+ * \f$ \frac{\mbox{numerator}}{\mbox{denominator}} \f$
+ *
+ * Children:<BR>
+ * 0: Numerator<BR>
+ * 1: Line (instance of SmRectangleNode)<BR>
+ * 2: Denominator<BR>
+ * None of the children may be NULL.
+ */
+class SmBinVerNode final : public SmStructureNode
+{
+public:
+ explicit SmBinVerNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::BinVer, rNodeToken, 3)
+ {
+ }
+
+ virtual const SmNode * GetLeftMost() const override;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Binary diagonal node
+ *
+ * Used for implementing the WIDESLASH command, example: "A WIDESLASH B".
+ *
+ * Children:<BR>
+ * 0: Left operand<BR>
+ * 1: right operand<BR>
+ * 2: Line (instance of SmPolyLineNode).<BR>
+ * None of the children may be NULL.
+ */
+class SmBinDiagonalNode final : public SmStructureNode
+{
+ bool mbAscending;
+
+ void GetOperPosSize(Point &rPos, Size &rSize,
+ const Point &rDiagPoint, double fAngleDeg) const;
+
+public:
+ explicit SmBinDiagonalNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::BinDiagonal, rNodeToken, 3)
+ , mbAscending(false)
+ {
+ }
+
+ bool IsAscending() const { return mbAscending; }
+ void SetAscending(bool bVal) { mbAscending = bVal; }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Enum used to index sub-/supscripts in the 'maSubNodes' array
+ * in 'SmSubSupNode'
+ *
+ * See graphic for positions at char:
+ *
+ * \code
+ * CSUP
+ *
+ * LSUP H H RSUP
+ * H H
+ * HHHH
+ * H H
+ * LSUB H H RSUB
+ *
+ * CSUB
+ * \endcode
+ */
+enum SmSubSup
+{ CSUB, CSUP, RSUB, RSUP, LSUB, LSUP
+};
+
+/** numbers of entries in the above enum (that is: the number of possible
+ * sub-/supscripts)
+ */
+#define SUBSUP_NUM_ENTRIES 6
+
+/** Super- and subscript node
+ *
+ * Used for creating super- and subscripts for commands such as:
+ * "^", "_", "lsup", "lsub", "csup" and "csub".
+ * Example: "A^2" which looks like: \f$ A^2 \f$
+ *
+ * This node is also used for creating limits on SmOperNode, when
+ * "FROM" and "TO" commands are used with "INT", "SUM" or similar.
+ *
+ * Children of this node can be enumerated using the SmSubSup enum.
+ * Please note that children may be NULL, except for the body.
+ * It is recommended that you access children using GetBody() and
+ * GetSubSup().
+ */
+class SmSubSupNode final : public SmStructureNode
+{
+ bool mbUseLimits;
+
+public:
+ explicit SmSubSupNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::SubSup, rNodeToken, 1 + SUBSUP_NUM_ENTRIES)
+ , mbUseLimits(false)
+ {
+ }
+
+ /** Get body (Not NULL) */
+ SmNode * GetBody() { return GetSubNode(0); }
+ /** Get body (Not NULL) */
+ const SmNode * GetBody() const
+ {
+ return const_cast<SmSubSupNode *>(this)->GetBody();
+ }
+
+ void SetUseLimits(bool bVal) { mbUseLimits = bVal; }
+ bool IsUseLimits() const { return mbUseLimits; };
+
+ /** Get super- or subscript
+ * @remarks this method may return NULL.
+ */
+ SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode(1 + eSubSup); };
+ const SmNode * GetSubSup(SmSubSup eSubSup) const { return const_cast< SmSubSupNode* >( this )->GetSubSup( eSubSup ); }
+
+ /** Set the body */
+ void SetBody(SmNode* pBody) { SetSubNode(0, pBody); }
+ void SetSubSup(SmSubSup eSubSup, SmNode* pScript) { SetSubNode( 1 + eSubSup, pScript); }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+
+};
+
+
+/** Node for brace construction
+ *
+ * Used for "lbrace [body] rbrace" and similar constructions.
+ * Should look like \f$ \{\mbox{[body]}\} \f$
+ *
+ * Children:<BR>
+ * 0: Opening brace<BR>
+ * 1: Body (usually SmBracebodyNode)<BR>
+ * 2: Closing brace<BR>
+ * None of the children can be NULL.
+ *
+ * Note that child 1 (Body) is usually SmBracebodyNode, but it can also be e.g. SmExpressionNode.
+ */
+class SmBraceNode final : public SmStructureNode
+{
+public:
+ explicit SmBraceNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Brace, rNodeToken, 3)
+ {
+ }
+
+ SmMathSymbolNode* OpeningBrace();
+ const SmMathSymbolNode* OpeningBrace() const;
+ SmNode* Body();
+ const SmNode* Body() const;
+ SmMathSymbolNode* ClosingBrace();
+ const SmMathSymbolNode* ClosingBrace() const;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Body of an SmBraceNode
+ *
+ * This usually only has one child an SmExpressionNode, however, it can also
+ * have other children.
+ * Consider the formula "lbrace [body1] mline [body2] rbrace", looks like:
+ * \f$ \{\mbox{[body1] | [body2]}\} \f$.
+ * In this case SmBracebodyNode will have three children, "[body1]", "|" and
+ * [body2].
+ */
+class SmBracebodyNode final : public SmStructureNode
+{
+ long mnBodyHeight;
+
+public:
+ explicit SmBracebodyNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Bracebody, rNodeToken)
+ , mnBodyHeight(0)
+ {
+ }
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ long GetBodyHeight() const { return mnBodyHeight; }
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Node for vertical brace construction
+ *
+ * Used to implement commands "[body] underbrace [script]" and
+ * "[body] overbrace [script]".
+ * Underbrace should look like this \f$ \underbrace{\mbox{body}}_{\mbox{script}}\f$.
+ *
+ * Children:<BR>
+ * 0: body<BR>
+ * 1: brace<BR>
+ * 2: script<BR>
+ * (None of these children are optional, e.g. they must all be not NULL).
+ */
+class SmVerticalBraceNode final : public SmStructureNode
+{
+public:
+ explicit inline SmVerticalBraceNode(const SmToken &rNodeToken);
+
+ SmNode* Body();
+ const SmNode* Body() const;
+ SmMathSymbolNode* Brace();
+ const SmMathSymbolNode* Brace() const;
+ SmNode* Script();
+ const SmNode* Script() const;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+inline SmVerticalBraceNode::SmVerticalBraceNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::VerticalBrace, rNodeToken, 3)
+{
+}
+
+
+/** Operation Node
+ *
+ * Used for commands like SUM, INT and similar.
+ *
+ * Children:<BR>
+ * 0: Operation (instance of SmMathSymbolNode or SmSubSupNode)<BR>
+ * 1: Body<BR>
+ * None of the children may be NULL.
+ *
+ */
+class SmOperNode final : public SmStructureNode
+{
+public:
+ explicit SmOperNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Oper, rNodeToken, 2)
+ {
+ }
+
+ SmNode * GetSymbol();
+ const SmNode * GetSymbol() const
+ {
+ return const_cast<SmOperNode *>(this)->GetSymbol();
+ }
+
+ long CalcSymbolHeight(const SmNode &rSymbol, const SmFormat &rFormat) const;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Node used for alignment
+ *
+ * This node has exactly one child at index 0.
+ */
+class SmAlignNode final : public SmStructureNode
+{
+public:
+ explicit SmAlignNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Align, rNodeToken)
+ {}
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Attribute node
+ *
+ * Used to give an attribute to another node. Used for commands such as:
+ * UNDERLINE, OVERLINE, OVERSTRIKE, WIDEVEC, WIDEHARPOON, WIDEHAT and WIDETILDE.
+ *
+ * Children:<BR>
+ * 0: Attribute<BR>
+ * 1: Body<BR>
+ * None of these may be NULL.
+ */
+class SmAttributNode final : public SmStructureNode
+{
+public:
+ explicit SmAttributNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Attribut, rNodeToken, 2)
+ {}
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+
+ SmNode* Attribute();
+ const SmNode* Attribute() const;
+ SmNode* Body();
+ const SmNode* Body() const;
+};
+
+
+/** Font node
+ *
+ * Used to change the font of its children.
+ */
+class SmFontNode final : public SmStructureNode
+{
+ FontSizeType meSizeType;
+ Fraction maFontSize;
+
+public:
+ explicit SmFontNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Font, rNodeToken)
+ , meSizeType(FontSizeType::MULTIPLY)
+ , maFontSize(1)
+ {
+ }
+
+ void SetSizeParameter(const Fraction &rValue, FontSizeType nType);
+ const Fraction & GetSizeParameter() const {return maFontSize;}
+ FontSizeType GetSizeType() const {return meSizeType;}
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Matrix node
+ *
+ * Used to implement the MATRIX command, example:
+ * "matrix{ 1 # 2 ## 3 # 4}".
+ */
+class SmMatrixNode final : public SmStructureNode
+{
+ sal_uInt16 mnNumRows,
+ mnNumCols;
+
+public:
+ explicit SmMatrixNode(const SmToken &rNodeToken)
+ : SmStructureNode(SmNodeType::Matrix, rNodeToken)
+ , mnNumRows(0)
+ , mnNumCols(0)
+ {
+ }
+
+ sal_uInt16 GetNumRows() const {return mnNumRows;}
+ sal_uInt16 GetNumCols() const {return mnNumCols;}
+ void SetRowCol(sal_uInt16 nMatrixRows, sal_uInt16 nMatrixCols);
+
+ virtual const SmNode * GetLeftMost() const override;
+
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void CreateTextFromNode(OUStringBuffer &rText) override;
+ void Accept(SmVisitor* pVisitor) override;
+};
+
+
+/** Node for whitespace
+ *
+ * Used to implement the commands "~" and "`". This node is just a blank space.
+ */
+class SmBlankNode final : public SmGraphicNode
+{
+ sal_uInt16 mnNum;
+
+public:
+ explicit SmBlankNode(const SmToken &rNodeToken)
+ : SmGraphicNode(SmNodeType::Blank, rNodeToken)
+ , mnNum(0)
+ {
+ }
+
+ void IncreaseBy(const SmToken &rToken, sal_uInt32 nMultiplyBy = 1);
+ void Clear() { mnNum = 0; }
+ sal_uInt16 GetBlankNum() const { return mnNum; }
+ void SetBlankNum(sal_uInt16 nNumber) { mnNum = nNumber; }
+
+ virtual void Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell, int nDepth) override;
+ virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
+ void Accept(SmVisitor* pVisitor) override;
+ virtual void CreateTextFromNode(OUStringBuffer &rText) override;
+};
+
+
+inline SmNode* SmRootNode::Argument()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 0 );
+}
+inline const SmNode* SmRootNode::Argument() const
+{
+ return const_cast< SmRootNode* >( this )->Argument();
+}
+inline SmRootSymbolNode* SmRootNode::Symbol()
+{
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 1 )->GetType() == SmNodeType::RootSymbol );
+ return static_cast< SmRootSymbolNode* >( GetSubNode( 1 ));
+}
+inline const SmRootSymbolNode* SmRootNode::Symbol() const
+{
+ return const_cast< SmRootNode* >( this )->Symbol();
+}
+inline SmNode* SmRootNode::Body()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 2 );
+}
+inline const SmNode* SmRootNode::Body() const
+{
+ return const_cast< SmRootNode* >( this )->Body();
+}
+
+
+inline SmNode* SmBinHorNode::Symbol()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 1 );
+}
+inline const SmNode* SmBinHorNode::Symbol() const
+{
+ return const_cast< SmBinHorNode* >( this )->Symbol();
+}
+inline SmNode* SmBinHorNode::LeftOperand()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 0 );
+}
+inline const SmNode* SmBinHorNode::LeftOperand() const
+{
+ return const_cast< SmBinHorNode* >( this )->LeftOperand();
+}
+inline SmNode* SmBinHorNode::RightOperand()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 2 );
+}
+inline const SmNode* SmBinHorNode::RightOperand() const
+{
+ return const_cast< SmBinHorNode* >( this )->RightOperand();
+}
+
+inline SmNode* SmAttributNode::Attribute()
+{
+ assert( GetNumSubNodes() == 2 );
+ return GetSubNode( 0 );
+}
+inline const SmNode* SmAttributNode::Attribute() const
+{
+ return const_cast< SmAttributNode* >( this )->Attribute();
+}
+inline SmNode* SmAttributNode::Body()
+{
+ assert( GetNumSubNodes() == 2 );
+ return GetSubNode( 1 );
+}
+inline const SmNode* SmAttributNode::Body() const
+{
+ return const_cast< SmAttributNode* >( this )->Body();
+}
+
+inline SmMathSymbolNode* SmBraceNode::OpeningBrace()
+{
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 0 )->GetType() == SmNodeType::Math );
+ return static_cast< SmMathSymbolNode* >( GetSubNode( 0 ));
+}
+inline const SmMathSymbolNode* SmBraceNode::OpeningBrace() const
+{
+ return const_cast< SmBraceNode* >( this )->OpeningBrace();
+}
+inline SmNode* SmBraceNode::Body()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 1 );
+}
+inline const SmNode* SmBraceNode::Body() const
+{
+ return const_cast< SmBraceNode* >( this )->Body();
+}
+inline SmMathSymbolNode* SmBraceNode::ClosingBrace()
+{
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 2 )->GetType() == SmNodeType::Math );
+ return static_cast< SmMathSymbolNode* >( GetSubNode( 2 ));
+}
+inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const
+{
+ return const_cast< SmBraceNode* >( this )->ClosingBrace();
+}
+
+inline SmNode* SmVerticalBraceNode::Body()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 0 );
+}
+inline const SmNode* SmVerticalBraceNode::Body() const
+{
+ return const_cast< SmVerticalBraceNode* >( this )->Body();
+}
+inline SmMathSymbolNode* SmVerticalBraceNode::Brace()
+{
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 1 )->GetType() == SmNodeType::Math );
+ return static_cast< SmMathSymbolNode* >( GetSubNode( 1 ));
+}
+inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const
+{
+ return const_cast< SmVerticalBraceNode* >( this )->Brace();
+}
+inline SmNode* SmVerticalBraceNode::Script()
+{
+ assert( GetNumSubNodes() == 3 );
+ return GetSubNode( 2 );
+}
+inline const SmNode* SmVerticalBraceNode::Script() const
+{
+ return const_cast< SmVerticalBraceNode* >( this )->Script();
+}
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
new file mode 100644
index 000000000..519a90041
--- /dev/null
+++ b/starmath/inc/parse.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_PARSE_HXX
+#define INCLUDED_STARMATH_INC_PARSE_HXX
+
+#include <unotools/charclass.hxx>
+#include <memory>
+#include <set>
+#include <vector>
+
+#include "token.hxx"
+#include "error.hxx"
+
+class SmBlankNode;
+class SmBracebodyNode;
+class SmExpressionNode;
+class SmGlyphSpecialNode;
+class SmNode;
+class SmOperNode;
+class SmSpecialNode;
+class SmStructureNode;
+class SmTableNode;
+class SmTextNode;
+
+#define DEPTH_LIMIT 1024
+
+class SmParser
+{
+ OUString m_aBufferString;
+ SmToken m_aCurToken;
+ std::vector<std::unique_ptr<SmErrorDesc>> m_aErrDescList;
+ int m_nCurError;
+ sal_Int32 m_nBufferIndex,
+ m_nTokenIndex;
+ sal_Int32 m_nRow, // 1-based
+ m_nColOff; // 0-based
+ bool m_bImportSymNames,
+ m_bExportSymNames;
+ sal_Int32 m_nParseDepth;
+
+ class DepthProtect
+ {
+ private:
+ sal_Int32& m_rParseDepth;
+ public:
+ DepthProtect(sal_Int32& rParseDepth)
+ : m_rParseDepth(rParseDepth)
+ {
+ ++m_rParseDepth;
+ }
+ bool TooDeep() const { return m_rParseDepth > DEPTH_LIMIT; }
+ ~DepthProtect()
+ {
+ --m_rParseDepth;
+ }
+ };
+
+ // map of used symbols (used to reduce file size by exporting only actually used symbols)
+ std::set< OUString > m_aUsedSymbols;
+
+ // CharClass representing a locale for parsing numbers
+ CharClass m_aNumCC;
+ // pointer to System locale's CharClass, which is alive inside SM_MOD()
+ const CharClass* m_pSysCC;
+
+ SmParser(const SmParser&) = delete;
+ SmParser& operator=(const SmParser&) = delete;
+
+ void NextToken();
+ sal_Int32 GetTokenIndex() const { return m_nTokenIndex; }
+ void Replace( sal_Int32 nPos, sal_Int32 nLen, const OUString &rText );
+
+ inline bool TokenInGroup( TG nGroup );
+
+ // grammar
+ std::unique_ptr<SmTableNode> DoTable();
+ std::unique_ptr<SmNode> DoLine();
+ std::unique_ptr<SmNode> DoExpression(bool bUseExtraSpaces = true);
+ std::unique_ptr<SmNode> DoRelation();
+ std::unique_ptr<SmNode> DoSum();
+ std::unique_ptr<SmNode> DoProduct();
+ std::unique_ptr<SmNode> DoSubSup(TG nActiveGroup, SmNode *pGivenNode);
+ std::unique_ptr<SmNode> DoOpSubSup();
+ std::unique_ptr<SmNode> DoPower();
+ std::unique_ptr<SmBlankNode> DoBlank();
+ std::unique_ptr<SmNode> DoTerm(bool bGroupNumberIdent);
+ std::unique_ptr<SmNode> DoEscape();
+ std::unique_ptr<SmOperNode> DoOperator();
+ std::unique_ptr<SmNode> DoOper();
+ std::unique_ptr<SmStructureNode> DoUnOper();
+ std::unique_ptr<SmNode> DoAlign(bool bUseExtraSpaces = true);
+ std::unique_ptr<SmStructureNode> DoFontAttribut();
+ std::unique_ptr<SmStructureNode> DoAttribut();
+ std::unique_ptr<SmStructureNode> DoFont();
+ std::unique_ptr<SmStructureNode> DoFontSize();
+ std::unique_ptr<SmStructureNode> DoColor();
+ std::unique_ptr<SmStructureNode> DoBrace();
+ std::unique_ptr<SmBracebodyNode> DoBracebody(bool bIsLeftRight);
+ std::unique_ptr<SmTextNode> DoFunction();
+ std::unique_ptr<SmTableNode> DoBinom();
+ std::unique_ptr<SmStructureNode> DoStack();
+ std::unique_ptr<SmStructureNode> DoMatrix();
+ std::unique_ptr<SmSpecialNode> DoSpecial();
+ std::unique_ptr<SmGlyphSpecialNode> DoGlyphSpecial();
+ std::unique_ptr<SmExpressionNode> DoError(SmParseError Error);
+ // end of grammar
+
+public:
+ SmParser();
+
+ /** Parse rBuffer to formula tree */
+ std::unique_ptr<SmTableNode> Parse(const OUString &rBuffer);
+ /** Parse rBuffer to formula subtree that constitutes an expression */
+ std::unique_ptr<SmNode> ParseExpression(const OUString &rBuffer);
+
+ const OUString & GetText() const { return m_aBufferString; };
+
+ bool IsImportSymbolNames() const { return m_bImportSymNames; }
+ void SetImportSymbolNames(bool bVal) { m_bImportSymNames = bVal; }
+ bool IsExportSymbolNames() const { return m_bExportSymNames; }
+ void SetExportSymbolNames(bool bVal) { m_bExportSymNames = bVal; }
+
+ void AddError(SmParseError Type, SmNode *pNode);
+ const SmErrorDesc* NextError();
+ const SmErrorDesc* PrevError();
+ const SmErrorDesc* GetError();
+ static const SmTokenTableEntry* GetTokenTableEntry( const OUString &rName );
+ const std::set< OUString >& GetUsedSymbols() const { return m_aUsedSymbols; }
+};
+
+
+inline bool SmParser::TokenInGroup( TG nGroup)
+{
+ return bool(m_aCurToken.nGroup & nGroup);
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/pch/precompiled_sm.cxx b/starmath/inc/pch/precompiled_sm.cxx
new file mode 100644
index 000000000..f5d78e96f
--- /dev/null
+++ b/starmath/inc/pch/precompiled_sm.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include "precompiled_sm.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/pch/precompiled_sm.hxx b/starmath/inc/pch/precompiled_sm.hxx
new file mode 100644
index 000000000..f1239ec47
--- /dev/null
+++ b/starmath/inc/pch/precompiled_sm.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2020-04-25 20:55:30 using:
+ ./bin/update_pch starmath sm --cutoff=5 --exclude:system --exclude:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./starmath/inc/pch/precompiled_sm.hxx "make starmath.build" --find-conflicts
+*/
+
+#if PCH_LEVEL >= 1
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <cstring>
+#include <functional>
+#include <limits.h>
+#include <limits>
+#include <list>
+#include <map>
+#include <memory>
+#include <new>
+#include <optional>
+#include <ostream>
+#include <string_view>
+#include <type_traits>
+#include <utility>
+#include <vector>
+#include <boost/property_tree/ptree_fwd.hpp>
+#endif // PCH_LEVEL >= 1
+#if PCH_LEVEL >= 2
+#include <osl/diagnose.h>
+#include <osl/endian.h>
+#include <osl/mutex.hxx>
+#include <rtl/alloc.h>
+#include <rtl/character.hxx>
+#include <rtl/instance.hxx>
+#include <rtl/locale.h>
+#include <rtl/math.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/string.hxx>
+#include <rtl/stringconcat.hxx>
+#include <rtl/stringutils.hxx>
+#include <rtl/textenc.h>
+#include <rtl/ustrbuf.h>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/ustring.h>
+#include <rtl/ustring.hxx>
+#include <rtl/uuid.h>
+#include <sal/config.h>
+#include <sal/log.hxx>
+#include <sal/types.h>
+#include <vcl/IDialogRenderable.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/cairo.hxx>
+#include <vcl/devicecoordinate.hxx>
+#include <vcl/dllapi.h>
+#include <vcl/errcode.hxx>
+#include <vcl/font.hxx>
+#include <vcl/keycod.hxx>
+#include <vcl/keycodes.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/metaactiontypes.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/outdevmap.hxx>
+#include <vcl/outdevstate.hxx>
+#include <vcl/region.hxx>
+#include <vcl/salnativewidgets.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/uitest/factory.hxx>
+#include <vcl/vclenum.hxx>
+#include <vcl/vclevent.hxx>
+#include <vcl/vclptr.hxx>
+#include <vcl/vclreferencebase.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/wall.hxx>
+#endif // PCH_LEVEL >= 2
+#if PCH_LEVEL >= 3
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/vector/b2enums.hxx>
+#include <com/sun/star/drawing/LineCap.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/comphelperdllapi.h>
+#include <cppuhelper/implbase.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/editengdllapi.h>
+#include <editeng/editstat.hxx>
+#include <i18nlangtag/lang.h>
+#include <o3tl/cow_wrapper.hxx>
+#include <o3tl/strong_int.hxx>
+#include <o3tl/typed_flags_set.hxx>
+#include <salhelper/simplereferenceobject.hxx>
+#include <sfx2/dllapi.h>
+#include <sfx2/docfile.hxx>
+#include <sfx2/shell.hxx>
+#include <sot/formats.hxx>
+#include <sot/storage.hxx>
+#include <svl/SfxBroadcaster.hxx>
+#include <svl/hint.hxx>
+#include <svl/itemset.hxx>
+#include <svl/languageoptions.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/svldllapi.h>
+#include <svl/typedwhich.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svx/svxdllapi.h>
+#include <tools/color.hxx>
+#include <tools/gen.hxx>
+#include <tools/lineend.hxx>
+#include <tools/link.hxx>
+#include <tools/mapunit.hxx>
+#include <tools/poly.hxx>
+#include <tools/ref.hxx>
+#include <tools/solar.h>
+#include <tools/toolsdllapi.h>
+#include <unotools/configitem.hxx>
+#include <unotools/fontdefs.hxx>
+#include <unotools/options.hxx>
+#include <unotools/unotoolsdllapi.h>
+#include <xmloff/dllapi.h>
+#endif // PCH_LEVEL >= 3
+#if PCH_LEVEL >= 4
+#include <ElementsDockingWindow.hxx>
+#include <dialog.hxx>
+#include <document.hxx>
+#include <node.hxx>
+#include <smmod.hxx>
+#include <symbol.hxx>
+#include <unomodel.hxx>
+#include <utility.hxx>
+#include <view.hxx>
+#include <visitors.hxx>
+#endif // PCH_LEVEL >= 4
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/rect.hxx b/starmath/inc/rect.hxx
new file mode 100644
index 000000000..ce390b197
--- /dev/null
+++ b/starmath/inc/rect.hxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_RECT_HXX
+#define INCLUDED_STARMATH_INC_RECT_HXX
+
+#include <rtl/ustring.hxx>
+#include <sal/log.hxx>
+#include <tools/gen.hxx>
+#include <vcl/outdev.hxx>
+
+class SmFormat;
+
+
+inline long SmFromTo(long nFrom, long nTo, double fRelDist)
+{
+ return nFrom + static_cast<long>(fRelDist * (nTo - nFrom));
+}
+
+
+// SmRect
+// ... (to be done)
+// This Implementation assumes that the x-axis points to the right and the
+// y-axis to the bottom.
+// Note: however, italic spaces can be negative!
+
+
+// possible positions and alignments for the 'AlignTo' function
+enum class RectPos
+{
+ Left, // align the current object to the left of the argument
+ Right,
+ Top,
+ Bottom,
+ Attribute
+};
+
+enum class RectHorAlign
+{
+ Left,
+ Center,
+ Right
+};
+
+enum class RectVerAlign
+{
+ Top,
+ Mid,
+ Bottom,
+ Baseline,
+ CenterY,
+ AttributeHi,
+ AttributeMid,
+ AttributeLo
+};
+
+// different methods of copying baselines and mid's in 'ExtendBy' function
+enum class RectCopyMBL
+{
+ This, // keep baseline of current object even if it has none
+ Arg, // as above but for the argument
+ None, // result will have no baseline
+ Xor // if current object has a baseline keep it else copy
+ // the arguments baseline (even if it has none)
+};
+
+
+class SmRect
+{
+ Point aTopLeft;
+ Size aSize;
+ long nBaseline,
+ nAlignT,
+ nAlignM,
+ nAlignB,
+ nGlyphTop,
+ nGlyphBottom,
+ nItalicLeftSpace,
+ nItalicRightSpace,
+ nLoAttrFence,
+ nHiAttrFence;
+ sal_uInt16 nBorderWidth;
+ bool bHasBaseline,
+ bHasAlignInfo;
+
+ inline void CopyMBL(const SmRect& rRect);
+ void CopyAlignInfo(const SmRect& rRect);
+
+ void Union(const SmRect &rRect);
+
+public:
+ SmRect();
+ SmRect(const OutputDevice &rDev, const SmFormat *pFormat,
+ const OUString &rText, sal_uInt16 nBorderWidth);
+ SmRect(long nWidth, long nHeight);
+
+
+ sal_uInt16 GetBorderWidth() const { return nBorderWidth; }
+
+ void SetItalicSpaces(long nLeftSpace, long nRightSpace);
+
+ void SetWidth(sal_uLong nWidth) { aSize.setWidth(nWidth); }
+
+ void SetLeft(long nLeft);
+ void SetRight(long nRight);
+ void SetBottom(long nBottom);
+ void SetTop(long nTop);
+
+ const Point & GetTopLeft() const { return aTopLeft; }
+
+ long GetTop() const { return GetTopLeft().Y(); }
+ long GetLeft() const { return GetTopLeft().X(); }
+ long GetBottom() const { return GetTop() + GetHeight() - 1; }
+ long GetRight() const { return GetLeft() + GetWidth() - 1; }
+ long GetCenterY() const { return (GetTop() + GetBottom()) / 2; }
+ long GetWidth() const { return GetSize().Width(); }
+ long GetHeight() const { return GetSize().Height(); }
+
+ long GetItalicLeftSpace() const { return nItalicLeftSpace; }
+ long GetItalicRightSpace() const { return nItalicRightSpace; }
+
+ long GetHiAttrFence() const { return nHiAttrFence; }
+ long GetLoAttrFence() const { return nLoAttrFence; }
+
+ long GetItalicLeft() const { return GetLeft() - GetItalicLeftSpace(); }
+ long GetItalicCenterX() const { return (GetItalicLeft() + GetItalicRight()) / 2; }
+ long GetItalicRight() const { return GetRight() + GetItalicRightSpace(); }
+ long GetItalicWidth() const { return GetWidth() + GetItalicLeftSpace() + GetItalicRightSpace(); }
+
+ bool HasBaseline() const { return bHasBaseline; }
+ inline long GetBaseline() const;
+ long GetBaselineOffset() const { return GetBaseline() - GetTop(); }
+
+ long GetAlignT() const { return nAlignT; }
+ long GetAlignM() const { return nAlignM; }
+ long GetAlignB() const { return nAlignB; }
+
+ const Size & GetSize() const { return aSize; }
+
+ Size GetItalicSize() const
+ { return Size(GetItalicWidth(), GetHeight()); }
+
+ void Move (const Point &rPosition);
+ void MoveTo(const Point &rPosition) { Move(rPosition - GetTopLeft()); }
+
+ bool IsEmpty() const
+ {
+ return GetWidth() == 0 || GetHeight() == 0;
+ }
+
+ bool HasAlignInfo() const { return bHasAlignInfo; }
+
+ Point AlignTo(const SmRect &rRect, RectPos ePos,
+ RectHorAlign eHor, RectVerAlign eVer) const;
+
+ SmRect & ExtendBy(const SmRect &rRect, RectCopyMBL eCopyMode);
+ void ExtendBy(const SmRect &rRect, RectCopyMBL eCopyMode,
+ long nNewAlignM);
+ SmRect & ExtendBy(const SmRect &rRect, RectCopyMBL eCopyMode,
+ bool bKeepVerAlignParams);
+
+ long OrientedDist(const Point &rPoint) const;
+ bool IsInsideRect(const Point &rPoint) const;
+ bool IsInsideItalicRect(const Point &rPoint) const;
+
+ inline tools::Rectangle AsRectangle() const;
+ SmRect AsGlyphRect() const;
+};
+
+
+inline void SmRect::SetItalicSpaces(long nLeftSpace, long nRightSpace)
+ // set extra spacing to the left and right for (italic)
+ // letters/text
+{
+ nItalicLeftSpace = nLeftSpace;
+ nItalicRightSpace = nRightSpace;
+}
+
+
+inline void SmRect::CopyMBL(const SmRect &rRect)
+ // copy AlignM baseline and value of 'rRect'
+{
+ nBaseline = rRect.nBaseline;
+ bHasBaseline = rRect.bHasBaseline;
+ nAlignM = rRect.nAlignM;
+}
+
+
+inline long SmRect::GetBaseline() const
+{
+ SAL_WARN_IF( !HasBaseline(), "starmath", "Baseline does not exist" );
+ return nBaseline;
+}
+
+
+inline tools::Rectangle SmRect::AsRectangle() const
+{
+ return tools::Rectangle(Point(GetItalicLeft(), GetTop()), GetItalicSize());
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx
new file mode 100644
index 000000000..3408f2fd4
--- /dev/null
+++ b/starmath/inc/smdll.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_SMDLL_HXX
+#define INCLUDED_STARMATH_INC_SMDLL_HXX
+
+#include "smdllapi.hxx"
+
+namespace SmGlobals
+{
+ SM_DLLPUBLIC void ensure();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/smdllapi.hxx b/starmath/inc/smdllapi.hxx
new file mode 100644
index 000000000..ad183991f
--- /dev/null
+++ b/starmath/inc/smdllapi.hxx
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_STARMATH_INC_SMDLLAPI_HXX
+#define INCLUDED_STARMATH_INC_SMDLLAPI_HXX
+
+#include <sal/types.h>
+
+#if defined(SM_DLLIMPLEMENTATION)
+#define SM_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SM_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/smmod.hrc b/starmath/inc/smmod.hrc
new file mode 100644
index 000000000..59a4a7cd8
--- /dev/null
+++ b/starmath/inc/smmod.hrc
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+#ifndef INCLUDED_VCL_INC_STRINGS_HRC
+#define INCLUDED_VCL_INC_STRINGS_HRC
+
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+
+const char* RID_UI_SYMBOLSET_NAMES[] =
+{
+ NC_("RID_UI_SYMBOLSET_NAMES", "Greek"),
+ NC_("RID_UI_SYMBOLSET_NAMES", "Special")
+};
+
+const char* RID_UI_SYMBOL_NAMES[] =
+{
+ NC_("RID_UI_SYMBOL_NAMES", "alpha"),
+ NC_("RID_UI_SYMBOL_NAMES", "ALPHA"),
+ NC_("RID_UI_SYMBOL_NAMES", "beta"),
+ NC_("RID_UI_SYMBOL_NAMES", "BETA"),
+ NC_("RID_UI_SYMBOL_NAMES", "gamma"),
+ NC_("RID_UI_SYMBOL_NAMES", "GAMMA"),
+ NC_("RID_UI_SYMBOL_NAMES", "delta"),
+ NC_("RID_UI_SYMBOL_NAMES", "DELTA"),
+ NC_("RID_UI_SYMBOL_NAMES", "epsilon"),
+ NC_("RID_UI_SYMBOL_NAMES", "EPSILON"),
+ NC_("RID_UI_SYMBOL_NAMES", "zeta"),
+ NC_("RID_UI_SYMBOL_NAMES", "ZETA"),
+ NC_("RID_UI_SYMBOL_NAMES", "eta"),
+ NC_("RID_UI_SYMBOL_NAMES", "ETA"),
+ NC_("RID_UI_SYMBOL_NAMES", "theta"),
+ NC_("RID_UI_SYMBOL_NAMES", "THETA"),
+ NC_("RID_UI_SYMBOL_NAMES", "iota"),
+ NC_("RID_UI_SYMBOL_NAMES", "IOTA"),
+ NC_("RID_UI_SYMBOL_NAMES", "kappa"),
+ NC_("RID_UI_SYMBOL_NAMES", "KAPPA"),
+ NC_("RID_UI_SYMBOL_NAMES", "lambda"),
+ NC_("RID_UI_SYMBOL_NAMES", "LAMBDA"),
+ NC_("RID_UI_SYMBOL_NAMES", "mu"),
+ NC_("RID_UI_SYMBOL_NAMES", "MU"),
+ NC_("RID_UI_SYMBOL_NAMES", "nu"),
+ NC_("RID_UI_SYMBOL_NAMES", "NU"),
+ NC_("RID_UI_SYMBOL_NAMES", "xi"),
+ NC_("RID_UI_SYMBOL_NAMES", "XI"),
+ NC_("RID_UI_SYMBOL_NAMES", "omicron"),
+ NC_("RID_UI_SYMBOL_NAMES", "OMICRON"),
+ NC_("RID_UI_SYMBOL_NAMES", "pi"),
+ NC_("RID_UI_SYMBOL_NAMES", "PI"),
+ NC_("RID_UI_SYMBOL_NAMES", "rho"),
+ NC_("RID_UI_SYMBOL_NAMES", "RHO"),
+ NC_("RID_UI_SYMBOL_NAMES", "sigma"),
+ NC_("RID_UI_SYMBOL_NAMES", "SIGMA"),
+ NC_("RID_UI_SYMBOL_NAMES", "tau"),
+ NC_("RID_UI_SYMBOL_NAMES", "TAU"),
+ NC_("RID_UI_SYMBOL_NAMES", "upsilon"),
+ NC_("RID_UI_SYMBOL_NAMES", "UPSILON"),
+ NC_("RID_UI_SYMBOL_NAMES", "phi"),
+ NC_("RID_UI_SYMBOL_NAMES", "PHI"),
+ NC_("RID_UI_SYMBOL_NAMES", "chi"),
+ NC_("RID_UI_SYMBOL_NAMES", "CHI"),
+ NC_("RID_UI_SYMBOL_NAMES", "psi"),
+ NC_("RID_UI_SYMBOL_NAMES", "PSI"),
+ NC_("RID_UI_SYMBOL_NAMES", "omega"),
+ NC_("RID_UI_SYMBOL_NAMES", "OMEGA"),
+ NC_("RID_UI_SYMBOL_NAMES", "varepsilon"),
+ NC_("RID_UI_SYMBOL_NAMES", "vartheta"),
+ NC_("RID_UI_SYMBOL_NAMES", "varpi"),
+ NC_("RID_UI_SYMBOL_NAMES", "varrho"),
+ NC_("RID_UI_SYMBOL_NAMES", "varsigma"),
+ NC_("RID_UI_SYMBOL_NAMES", "varphi"),
+ NC_("RID_UI_SYMBOL_NAMES", "element"),
+ NC_("RID_UI_SYMBOL_NAMES", "noelement"),
+ NC_("RID_UI_SYMBOL_NAMES", "strictlylessthan"),
+ NC_("RID_UI_SYMBOL_NAMES", "strictlygreaterthan"),
+ NC_("RID_UI_SYMBOL_NAMES", "notequal"),
+ NC_("RID_UI_SYMBOL_NAMES", "identical"),
+ NC_("RID_UI_SYMBOL_NAMES", "tendto"),
+ NC_("RID_UI_SYMBOL_NAMES", "infinite"),
+ NC_("RID_UI_SYMBOL_NAMES", "angle"),
+ NC_("RID_UI_SYMBOL_NAMES", "perthousand"),
+ NC_("RID_UI_SYMBOL_NAMES", "and"),
+ NC_("RID_UI_SYMBOL_NAMES", "or")
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx
new file mode 100644
index 000000000..a8f1ac17c
--- /dev/null
+++ b/starmath/inc/smmod.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_SMMOD_HXX
+#define INCLUDED_STARMATH_INC_SMMOD_HXX
+
+#include <sfx2/module.hxx>
+#include <sfx2/app.hxx>
+#include <vcl/vclptr.hxx>
+
+#include <unotools/options.hxx>
+#include <memory>
+
+namespace svtools { class ColorConfig; }
+
+class SfxObjectFactory;
+class SmSymbolManager;
+class SmMathConfig;
+
+/*************************************************************************
+|*
+|* This subclass of <SfxModule> (which is a subclass of <SfxShell>) is
+|* linked to the DLL. One instance of this class exists while the DLL is
+|* loaded.
+|*
+|* SdModule is like to be compared with the <SfxApplication>-subclass.
+|*
+|* Remember: Don`t export this class! It uses DLL-internal symbols.
+|*
+\************************************************************************/
+
+class SvtSysLocale;
+class VirtualDevice;
+
+
+OUString SmResId(const char* pId);
+
+class SmLocalizedSymbolData
+{
+public:
+ SmLocalizedSymbolData() = delete;
+
+ static OUString GetUiSymbolName( const OUString &rExportName );
+ static OUString GetExportSymbolName( const OUString &rUiName );
+
+ static OUString GetUiSymbolSetName( const OUString &rExportName );
+ static OUString GetExportSymbolSetName( const OUString &rUiName );
+};
+
+class SmModule final : public SfxModule, public utl::ConfigurationListener
+{
+ std::unique_ptr<svtools::ColorConfig> mpColorConfig;
+ std::unique_ptr<SmMathConfig> mpConfig;
+ std::unique_ptr<SmLocalizedSymbolData> mpLocSymbolData;
+ std::unique_ptr<SvtSysLocale> mpSysLocale;
+ VclPtr<VirtualDevice> mpVirtualDev;
+
+public:
+ SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START + SfxInterfaceId(0))
+
+private:
+ /// SfxInterface initializer.
+ static void InitInterface_Impl();
+
+public:
+ explicit SmModule(SfxObjectFactory* pObjFact);
+ virtual ~SmModule() override;
+
+ virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints ) override;
+
+ svtools::ColorConfig & GetColorConfig();
+
+ SmMathConfig * GetConfig();
+ SmSymbolManager & GetSymbolManager();
+
+ static void GetState(SfxItemSet&);
+
+ const SvtSysLocale& GetSysLocale();
+
+ VirtualDevice & GetDefaultVirtualDev();
+
+ //virtual methods for options dialog
+ virtual std::unique_ptr<SfxItemSet> CreateItemSet( sal_uInt16 nId ) override;
+ virtual void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ) override;
+ virtual std::unique_ptr<SfxTabPage> CreateTabPage( sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet ) override;
+};
+
+#define SM_MOD() ( static_cast<SmModule*>(SfxApplication::GetModule(SfxToolsModule::Math)) )
+
+#endif // INCLUDED_STARMATH_INC_SMMOD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc
new file mode 100644
index 000000000..60fd52e7c
--- /dev/null
+++ b/starmath/inc/starmath.hrc
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_STARMATH_HRC
+#define INCLUDED_STARMATH_INC_STARMATH_HRC
+
+#include <svl/solar.hrc>
+
+#define SID_NEXTERR (SID_SMA_START + 1)
+#define SID_PREVERR (SID_SMA_START + 2)
+#define SID_NEXTMARK (SID_SMA_START + 3)
+#define SID_PREVMARK (SID_SMA_START + 4)
+#define SID_SYMBOLS_CATALOGUE (SID_SMA_START + 5)
+#define SID_ZOOMIN (SID_SMA_START + 10)
+#define SID_ZOOMOUT (SID_SMA_START + 11)
+#define SID_DRAW (SID_SMA_START + 12)
+#define SID_FORMULACURSOR (SID_SMA_START + 15)
+#define SID_FONT (SID_SMA_START + 50)
+#define SID_FONTSIZE (SID_SMA_START + 51)
+#define SID_DISTANCE (SID_SMA_START + 52)
+#define SID_ALIGN (SID_SMA_START + 53)
+
+#define SID_AUTO_REDRAW (SID_SMA_START + 55)
+#define SID_TEXTMODE (SID_SMA_START + 57)
+#define SID_IMPORT_FORMULA (SID_SMA_START + 58)
+#define SID_IMPORT_MATHML_CLIPBOARD (SID_SMA_START + 59)
+#define SID_TEXT (SID_SMA_START + 100)
+#define SID_GAPHIC_SM (SID_SMA_START + 101)
+/** Command for inserting a symbol specified by a string (Inserts an SmSpecialNode) */
+#define SID_INSERTSPECIAL (SID_SMA_START + 104)
+/** Command for inserting a math construction */
+#define SID_INSERTCOMMANDTEXT (SID_SMA_START + 106)
+
+#define SID_LOADSYMBOLS (SID_SMA_START + 107)
+#define SID_SAVESYMBOLS (SID_SMA_START + 108)
+#define SID_MODIFYSTATUS (SID_SMA_START + 110)
+#define SID_TEXTSTATUS (SID_SMA_START + 111)
+
+#define SID_PRINTTITLE (SID_SMA_START + 112)
+#define SID_PRINTTEXT (SID_SMA_START + 113)
+#define SID_PRINTFRAME (SID_SMA_START + 114)
+#define SID_PRINTSIZE (SID_SMA_START + 115)
+#define SID_PRINTZOOM (SID_SMA_START + 116)
+
+#define SID_COPYOBJECT (SID_SMA_START + 117)
+#define SID_PASTEOBJECT (SID_SMA_START + 118)
+#define SID_AUTOREDRAW (SID_SMA_START + 119)
+
+#define SID_GETEDITTEXT (SID_SMA_START + 121)
+#define SID_CMDBOXWINDOW (SID_SMA_START + 122)
+#define SID_NO_RIGHT_SPACES (SID_SMA_START + 124)
+#define SID_SAVE_ONLY_USED_SYMBOLS (SID_SMA_START + 125)
+#define SID_ELEMENTSDOCKINGWINDOW (SID_SMA_START + 126)
+#define SID_AUTO_CLOSE_BRACKETS (SID_SMA_START + 127)
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/strings.hrc b/starmath/inc/strings.hrc
new file mode 100644
index 000000000..b4a22c58e
--- /dev/null
+++ b/starmath/inc/strings.hrc
@@ -0,0 +1,351 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_SM_INC_STRINGS_HRC
+#define INCLUDED_SM_INC_STRINGS_HRC
+
+#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+
+#define RID_PLUSX_HELP NC_("RID_PLUSX_HELP", "+ Sign" )
+#define RID_MINUSX_HELP NC_("RID_MINUSX_HELP", "- Sign" )
+#define RID_PLUSMINUSX_HELP NC_("RID_PLUSMINUSX_HELP", "+- Sign" )
+#define RID_MINUSPLUSX_HELP NC_("RID_MINUSPLUSX_HELP", "-+ Sign" )
+#define RID_NEGX_HELP NC_("RID_NEGX_HELP", "Boolean NOT" )
+#define RID_XPLUSY_HELP NC_("RID_XPLUSY_HELP", "Addition +" )
+#define RID_XMINUSY_HELP NC_("RID_XMINUSY_HELP", "Subtraction -" )
+#define RID_XCDOTY_HELP NC_("RID_XCDOTY_HELP", "Multiplication (Dot)" )
+#define RID_XTIMESY_HELP NC_("RID_XTIMESY_HELP", "Multiplication (x)" )
+#define RID_XSYMTIMESY_HELP NC_("RID_XSYMTIMESY_HELP", "Multiplication (*)" )
+#define RID_XSYMDIVIDEY_HELP NC_("RID_XSYMDIVIDEY_HELP", "Division (Slash)" )
+#define RID_XDIVY_HELP NC_("RID_XDIVY_HELP", "Division (÷)" )
+#define RID_XOVERY_HELP NC_("RID_XOVERY_HELP", "Division (Fraction)" )
+#define RID_XODIVIDEY_HELP NC_("RID_XODIVIDEY_HELP", "Circled Slash" )
+#define RID_XODOTY_HELP NC_("RID_XODOTY_HELP", "Circled Dot" )
+#define RID_XOMINUSY_HELP NC_("RID_XOMINUSY_HELP", "Circled Minus" )
+#define RID_XOPLUSY_HELP NC_("RID_XOPLUSY_HELP", "Circled Plus" )
+#define RID_XOTIMESY_HELP NC_("RID_XOTIMESY_HELP", "Tensor Product" )
+#define RID_XANDY_HELP NC_("RID_XANDY_HELP", "Boolean AND" )
+#define RID_XORY_HELP NC_("RID_XORY_HELP", "Boolean OR" )
+#define RID_XEQY_HELP NC_("RID_XEQY_HELP", "Is Equal" )
+#define RID_XNEQY_HELP NC_("RID_XNEQY_HELP", "Is Not Equal" )
+#define RID_XLTY_HELP NC_("RID_XLTY_HELP", "Is Less Than" )
+#define RID_XGTY_HELP NC_("RID_XGTY_HELP", "Is Greater Than" )
+#define RID_XLEY_HELP NC_("RID_XLEY_HELP", "Is Less Than Or Equal To" )
+#define RID_XGEY_HELP NC_("RID_XGEY_HELP", "Is Greater Than Or Equal To" )
+#define RID_XLESLANTY_HELP NC_("RID_XLESLANTY_HELP", "Is Less Than Or Equal To" )
+#define RID_XGESLANTY_HELP NC_("RID_XGESLANTY_HELP", "Is Greater Than Or Equal To" )
+#define RID_XLLY_HELP NC_("RID_XLLY_HELP", "Is Much Less Than" )
+#define RID_XGGY_HELP NC_("RID_XGGY_HELP", "Is Much Greater Than" )
+#define RID_XDEFY_HELP NC_("RID_XDEFY_HELP", "Is Defined As" )
+#define RID_XEQUIVY_HELP NC_("RID_XEQUIVY_HELP", "Is Congruent To" )
+#define RID_XAPPROXY_HELP NC_("RID_XAPPROXY_HELP", "Is Approximately Equal" )
+#define RID_XSIMY_HELP NC_("RID_XSIMY_HELP", "Is Similar To" )
+#define RID_XSIMEQY_HELP NC_("RID_XSIMEQY_HELP", "Is Similar Or Equal" )
+#define RID_XPROPY_HELP NC_("RID_XPROPY_HELP", "Is Proportional To" )
+#define RID_XORTHOY_HELP NC_("RID_XORTHOY_HELP", "Is Orthogonal To" )
+#define RID_XPARALLELY_HELP NC_("RID_XPARALLELY_HELP", "Is Parallel To" )
+#define RID_XTOWARDY_HELP NC_("RID_XTOWARDY_HELP", "Toward" )
+#define RID_XTRANSLY_HELP NC_("RID_XTRANSLY_HELP", "Corresponds To (Left)" )
+#define RID_XTRANSRY_HELP NC_("RID_XTRANSRY_HELP", "Corresponds To (Right)" )
+#define RID_XINY_HELP NC_("RID_XINY_HELP", "Is In" )
+#define RID_XNOTINY_HELP NC_("RID_XNOTINY_HELP", "Is Not In" )
+#define RID_XOWNSY_HELP NC_("RID_XOWNSY_HELP", "Owns" )
+#define RID_XUNIONY_HELP NC_("RID_XUNIONY_HELP", "Union" )
+#define RID_XINTERSECTIONY_HELP NC_("RID_XINTERSECTIONY_HELP", "Intersection" )
+#define RID_XSETMINUSY_HELP NC_("RID_XSETMINUSY_HELP", "Difference" )
+#define RID_XSLASHY_HELP NC_("RID_XSLASHY_HELP", "Quotient Set" )
+#define RID_XSUBSETY_HELP NC_("RID_XSUBSETY_HELP", "Subset" )
+#define RID_XSUBSETEQY_HELP NC_("RID_XSUBSETEQY_HELP", "Subset Or Equal To" )
+#define RID_XSUPSETY_HELP NC_("RID_XSUPSETY_HELP", "Superset" )
+#define RID_XSUPSETEQY_HELP NC_("RID_XSUPSETEQY_HELP", "Superset Or Equal To" )
+#define RID_XNSUBSETY_HELP NC_("RID_XNSUBSETY_HELP", "Not Subset" )
+#define RID_XNSUBSETEQY_HELP NC_("RID_XNSUBSETEQY_HELP", "Not Subset Or Equal" )
+#define RID_XNSUPSETY_HELP NC_("RID_XNSUPSETY_HELP", "Not Superset" )
+#define RID_XNSUPSETEQY_HELP NC_("RID_XNSUPSETEQY_HELP", "Not Superset Or Equal" )
+#define RID_ABSX_HELP NC_("RID_ABSX_HELP", "Absolute Value" )
+#define RID_FACTX_HELP NC_("RID_FACTX_HELP", "Factorial" )
+#define RID_SQRTX_HELP NC_("RID_SQRTX_HELP", "Square Root" )
+#define RID_NROOTXY_HELP NC_("RID_NROOTXY_HELP", "N-th Root" )
+#define RID_EX_HELP NC_("RID_EX_HELP", "Exponential Function" )
+#define RID_EXPX_HELP NC_("RID_EXPX_HELP", "Exponential Function" )
+#define RID_LNX_HELP NC_("RID_LNX_HELP", "Natural Logarithm" )
+#define RID_LOGX_HELP NC_("RID_LOGX_HELP", "Logarithm" )
+#define RID_SINX_HELP NC_("RID_SINX_HELP", "Sine" )
+#define RID_COSX_HELP NC_("RID_COSX_HELP", "Cosine" )
+#define RID_TANX_HELP NC_("RID_TANX_HELP", "Tangent" )
+#define RID_COTX_HELP NC_("RID_COTX_HELP", "Cotangent" )
+#define RID_ARCSINX_HELP NC_("RID_ARCSINX_HELP", "Arcsine" )
+#define RID_ARCCOSX_HELP NC_("RID_ARCCOSX_HELP", "Arccosine" )
+#define RID_ARCTANX_HELP NC_("RID_ARCTANX_HELP", "Arctangent" )
+#define RID_ARCCOTX_HELP NC_("RID_ARCCOTX_HELP", "Arccotangent" )
+#define RID_SINHX_HELP NC_("RID_SINHX_HELP", "Hyperbolic Sine" )
+#define RID_COSHX_HELP NC_("RID_COSHX_HELP", "Hyperbolic Cosine" )
+#define RID_TANHX_HELP NC_("RID_TANHX_HELP", "Hyperbolic Tangent" )
+#define RID_COTHX_HELP NC_("RID_COTHX_HELP", "Hyperbolic Cotangent" )
+#define RID_ARSINHX_HELP NC_("RID_ARSINHX_HELP", "Area Hyperbolic Sine" )
+#define RID_ARCOSHX_HELP NC_("RID_ARCOSHX_HELP", "Area Hyperbolic Cosine" )
+#define RID_ARTANHX_HELP NC_("RID_ARTANHX_HELP", "Area Hyperbolic Tangent" )
+#define RID_ARCOTHX_HELP NC_("RID_ARCOTHX_HELP", "Area Hyperbolic Cotangent" )
+#define RID_SUMX_HELP NC_("RID_SUMX_HELP", "Sum" )
+#define RID_SUM_FROMX_HELP NC_("RID_SUM_FROMX_HELP", "Sum Subscript Bottom" )
+#define RID_SUM_TOX_HELP NC_("RID_SUM_TOX_HELP", "Sum Superscript Top" )
+#define RID_SUM_FROMTOX_HELP NC_("RID_SUM_FROMTOX_HELP", "Sum Sup/Sub script" )
+#define RID_PRODX_HELP NC_("RID_PRODX_HELP", "Product" )
+#define RID_PROD_FROMX_HELP NC_("RID_PROD_FROMX_HELP", "Product Subscript Bottom" )
+#define RID_PROD_TOX_HELP NC_("RID_PROD_TOX_HELP", "Product Superscript Top" )
+#define RID_PROD_FROMTOX_HELP NC_("RID_PROD_FROMTOX_HELP", "Product Sup/Sub script" )
+#define RID_COPRODX_HELP NC_("RID_COPRODX_HELP", "Coproduct" )
+#define RID_COPROD_FROMX_HELP NC_("RID_COPROD_FROMX_HELP", "Coproduct Subscript Bottom" )
+#define RID_COPROD_TOX_HELP NC_("RID_COPROD_TOX_HELP", "Coproduct Superscript Top" )
+#define RID_COPROD_FROMTOX_HELP NC_("RID_COPROD_FROMTOX_HELP", "Coproduct Sup/Sub script" )
+#define RID_LIMX_HELP NC_("RID_LIMX_HELP", "Limes" )
+#define RID_LIM_FROMX_HELP NC_("RID_LIM_FROMX_HELP", "Limes Subscript Bottom" )
+#define RID_LIM_TOX_HELP NC_("RID_LIM_TOX_HELP", "Limes Superscript Top" )
+#define RID_LIM_FROMTOX_HELP NC_("RID_LIM_FROMTOX_HELP", "Limes Sup/Sub script" )
+#define RID_LIMINFX_HELP NC_("RID_LIMINFX_HELP", "Limit Inferior" )
+#define RID_LIMINF_FROMX_HELP NC_("RID_LIMINF_FROMX_HELP", "Limit Inferior Subscript Bottom" )
+#define RID_LIMINF_TOX_HELP NC_("RID_LIMINF_TOX_HELP", "Limit Inferior Superscript Top" )
+#define RID_LIMINF_FROMTOX_HELP NC_("RID_LIMINF_FROMTOX_HELP", "Limit Inferior Sup/Sub script" )
+#define RID_LIMSUPX_HELP NC_("RID_LIMSUPX_HELP", "Limit Superior" )
+#define RID_LIMSUP_FROMX_HELP NC_("RID_LIMSUP_FROMX_HELP", "Limit Superior Subscript Bottom" )
+#define RID_LIMSUP_TOX_HELP NC_("RID_LIMSUP_TOX_HELP", "Limit Superior Superscript Top" )
+#define RID_LIMSUP_FROMTOX_HELP NC_("RID_LIMSUP_FROMTOX_HELP", "Limit Superior Sup/Sub script" )
+#define RID_EXISTS_HELP NC_("RID_EXISTS_HELP", "There Exists" )
+#define RID_NOTEXISTS_HELP NC_("RID_NOTEXISTS_HELP", "There Not Exists" )
+#define RID_FORALL_HELP NC_("RID_FORALL_HELP", "For all" )
+#define RID_INTX_HELP NC_("RID_INTX_HELP", "Integral" )
+#define RID_INT_FROMX_HELP NC_("RID_INT_FROMX_HELP", "Integral Subscript Bottom" )
+#define RID_INT_TOX_HELP NC_("RID_INT_TOX_HELP", "Integral Superscript Top" )
+#define RID_INT_FROMTOX_HELP NC_("RID_INT_FROMTOX_HELP", "Integral Sup/Sub script" )
+#define RID_IINTX_HELP NC_("RID_IINTX_HELP", "Double Integral" )
+#define RID_IINT_FROMX_HELP NC_("RID_IINT_FROMX_HELP", "Double Integral Subscript Bottom" )
+#define RID_IINT_TOX_HELP NC_("RID_IINT_TOX_HELP", "Double Integral Superscript Top" )
+#define RID_IINT_FROMTOX_HELP NC_("RID_IINT_FROMTOX_HELP", "Double Integral Sup/Sub script" )
+#define RID_IIINTX_HELP NC_("RID_IIINTX_HELP", "Triple Integral" )
+#define RID_IIINT_FROMX_HELP NC_("RID_IIINT_FROMX_HELP", "Triple Integral Subscript Bottom" )
+#define RID_IIINT_TOX_HELP NC_("RID_IIINT_TOX_HELP", "Triple Integral Superscript Top" )
+#define RID_IIINT_FROMTOX_HELP NC_("RID_IIINT_FROMTOX_HELP", "Triple Integral Sup/Sub script" )
+#define RID_LINTX_HELP NC_("RID_LINTX_HELP", "Curve Integral" )
+#define RID_LINT_FROMX_HELP NC_("RID_LINT_FROMX_HELP", "Curve Integral Subscript Bottom" )
+#define RID_LINT_TOX_HELP NC_("RID_LINT_TOX_HELP", "Curve Integral Superscript Top" )
+#define RID_LINT_FROMTOX_HELP NC_("RID_LINT_FROMTOX_HELP", "Curve Integral Sup/Sub script" )
+#define RID_LLINTX_HELP NC_("RID_LLINTX_HELP", "Double Curve Integral" )
+#define RID_LLINT_FROMX_HELP NC_("RID_LLINT_FROMX_HELP", "Double Curve Integral Subscript Bottom" )
+#define RID_LLINT_TOX_HELP NC_("RID_LLINT_TOX_HELP", "Double Curve Integral Superscript Top" )
+#define RID_LLINT_FROMTOX_HELP NC_("RID_LLINT_FROMTOX_HELP", "Double Curve Integral Sup/Sub script" )
+#define RID_LLLINTX_HELP NC_("RID_LLLINTX_HELP", "Triple Curve Integral" )
+#define RID_LLLINT_FROMX_HELP NC_("RID_LLLINT_FROMX_HELP", "Triple Curve Integral Subscript Bottom" )
+#define RID_LLLINT_TOX_HELP NC_("RID_LLLINT_TOX_HELP", "Triple Curve Integral Superscript Top" )
+#define RID_LLLINT_FROMTOX_HELP NC_("RID_LLLINT_FROMTOX_HELP", "Triple Curve Integral Sup/Sub script" )
+#define RID_ACUTEX_HELP NC_("RID_ACUTEX_HELP", "Acute Accent" )
+#define RID_BARX_HELP NC_("RID_BARX_HELP", "Line Above" )
+#define RID_BREVEX_HELP NC_("RID_BREVEX_HELP", "Breve" )
+#define RID_CHECKX_HELP NC_("RID_CHECKX_HELP", "Reverse Circumflex" )
+#define RID_CIRCLEX_HELP NC_("RID_CIRCLEX_HELP", "Circle" )
+#define RID_DOTX_HELP NC_("RID_DOTX_HELP", "Dot" )
+#define RID_DDOTX_HELP NC_("RID_DDOTX_HELP", "Double Dot" )
+#define RID_DDDOTX_HELP NC_("RID_DDDOTX_HELP", "Triple Dot" )
+#define RID_GRAVEX_HELP NC_("RID_GRAVEX_HELP", "Grave Accent" )
+#define RID_HATX_HELP NC_("RID_HATX_HELP", "Circumflex" )
+#define RID_TILDEX_HELP NC_("RID_TILDEX_HELP", "Tilde" )
+#define RID_VECX_HELP NC_("RID_VECX_HELP", "Vector Arrow" )
+#define RID_HARPOONX_HELP NC_("RID_HARPOONX_HELP", "Harpoon" )
+#define RID_UNDERLINEX_HELP NC_("RID_UNDERLINEX_HELP", "Line Below" )
+#define RID_OVERLINEX_HELP NC_("RID_OVERLINEX_HELP", "Line Over" )
+#define RID_OVERSTRIKEX_HELP NC_("RID_OVERSTRIKEX_HELP", "Line Through" )
+#define RID_PHANTOMX_HELP NC_("RID_PHANTOMX_HELP", "Transparent" )
+#define RID_BOLDX_HELP NC_("RID_BOLDX_HELP", "Bold Font" )
+#define RID_ITALX_HELP NC_("RID_ITALX_HELP", "Italic Font" )
+#define RID_SIZEXY_HELP NC_("RID_SIZEXY_HELP", "Resize" )
+#define RID_FONTXY_HELP NC_("RID_FONTXY_HELP", "Change Font" )
+#define RID_COLORX_BLACK_HELP NC_("RID_COLORX_BLACK_HELP", "Color Black" )
+#define RID_COLORX_BLUE_HELP NC_("RID_COLORX_BLUE_HELP", "Color Blue" )
+#define RID_COLORX_GREEN_HELP NC_("RID_COLORX_GREEN_HELP", "Color Green" )
+#define RID_COLORX_RED_HELP NC_("RID_COLORX_RED_HELP", "Color Red" )
+#define RID_COLORX_CYAN_HELP NC_("RID_COLORX_CYAN_HELP", "Color Cyan" )
+#define RID_COLORX_MAGENTA_HELP NC_("RID_COLORX_MAGENTA_HELP", "Color Magenta" )
+#define RID_COLORX_GRAY_HELP NC_("RID_COLORX_GRAY_HELP", "Color Gray" )
+#define RID_COLORX_LIME_HELP NC_("RID_COLORX_LIME_HELP", "Color Lime" )
+#define RID_COLORX_MAROON_HELP NC_("RID_COLORX_MAROON_HELP", "Color Maroon" )
+#define RID_COLORX_NAVY_HELP NC_("RID_COLORX_NAVY_HELP", "Color Navy" )
+#define RID_COLORX_OLIVE_HELP NC_("RID_COLORX_OLIVE_HELP", "Color Olive" )
+#define RID_COLORX_PURPLE_HELP NC_("RID_COLORX_PURPLE_HELP", "Color Purple" )
+#define RID_COLORX_SILVER_HELP NC_("RID_COLORX_SILVER_HELP", "Color Silver" )
+#define RID_COLORX_TEAL_HELP NC_("RID_COLORX_TEAL_HELP", "Color Teal" )
+#define RID_COLORX_YELLOW_HELP NC_("RID_COLORX_YELLOW_HELP", "Color Yellow" )
+#define RID_COLORX_RGB_HELP NC_("RID_COLORX_RGB_HELP", "Color RGB" )
+#define RID_LRGROUPX_HELP NC_("RID_LRGROUPX_HELP", "Group Brackets" )
+#define RID_LRPARENTX_HELP NC_("RID_LRPARENTX_HELP", "Round Brackets" )
+#define RID_LRBRACKETX_HELP NC_("RID_LRBRACKETX_HELP", "Square Brackets" )
+#define RID_LRDBRACKETX_HELP NC_("RID_LRDBRACKETX_HELP", "Double Square Brackets" )
+#define RID_LRBRACEX_HELP NC_("RID_LRBRACEX_HELP", "Braces" )
+#define RID_LRANGLEX_HELP NC_("RID_LRANGLEX_HELP", "Angle Brackets" )
+#define RID_LRCEILX_HELP NC_("RID_LRCEILX_HELP", "Upper Ceil" )
+#define RID_LRFLOORX_HELP NC_("RID_LRFLOORX_HELP", "Floor" )
+#define RID_LRLINEX_HELP NC_("RID_LRLINEX_HELP", "Single Lines" )
+#define RID_LRDLINEX_HELP NC_("RID_LRDLINEX_HELP", "Double Lines" )
+#define RID_LMRANGLEXY_HELP NC_("RID_LMRANGLEXY_HELP", "Operator Brackets" )
+#define RID_SLRPARENTX_HELP NC_("RID_SLRPARENTX_HELP", "Round Brackets (Scalable)" )
+#define RID_SLRBRACKETX_HELP NC_("RID_SLRBRACKETX_HELP", "Square Brackets (Scalable)" )
+#define RID_SLRDBRACKETX_HELP NC_("RID_SLRDBRACKETX_HELP", "Double Square Brackets (Scalable)" )
+#define RID_SLRBRACEX_HELP NC_("RID_SLRBRACEX_HELP", "Braces (Scalable)" )
+#define RID_SLRANGLEX_HELP NC_("RID_SLRANGLEX_HELP", "Angle Brackets (Scalable)" )
+#define RID_SLRCEILX_HELP NC_("RID_SLRCEILX_HELP", "Ceiling (Scalable)" )
+#define RID_SLRFLOORX_HELP NC_("RID_SLRFLOORX_HELP", "Floor (Scalable)" )
+#define RID_SLRLINEX_HELP NC_("RID_SLRLINEX_HELP", "Single Lines (Scalable)" )
+#define RID_SLRDLINEX_HELP NC_("RID_SLRDLINEX_HELP", "Double Lines (Scalable)" )
+#define RID_SLMRANGLEXY_HELP NC_("RID_SLMRANGLEXY_HELP", "Operator Brackets (Scalable)" )
+#define RID_XEVALUATEDATY_HELP NC_("RID_XEVALUATEDATY_HELP", "Evaluated At" )
+#define RID_XOVERBRACEY_HELP NC_("RID_XOVERBRACEY_HELP", "Braces Top (Scalable)" )
+#define RID_XUNDERBRACEY_HELP NC_("RID_XUNDERBRACEY_HELP", "Braces Bottom (Scalable)" )
+#define RID_RSUBX_HELP NC_("RID_RSUBX_HELP", "Subscript Right" )
+#define RID_RSUPX_HELP NC_("RID_RSUPX_HELP", "Power" )
+#define RID_LSUBX_HELP NC_("RID_LSUBX_HELP", "Subscript Left" )
+#define RID_LSUPX_HELP NC_("RID_LSUPX_HELP", "Superscript Left" )
+#define RID_CSUBX_HELP NC_("RID_CSUBX_HELP", "Subscript Bottom" )
+#define RID_CSUPX_HELP NC_("RID_CSUPX_HELP", "Superscript Top" )
+#define RID_SBLANK_HELP NC_("RID_SBLANK_HELP", "Small Gap" )
+#define RID_BLANK_HELP NC_("RID_BLANK_HELP", "Blank" )
+#define RID_NEWLINE_HELP NC_("RID_NEWLINE_HELP", "New Line" )
+#define RID_BINOMXY_HELP NC_("RID_BINOMXY_HELP", "Vertical Stack (2 Elements)")
+#define RID_STACK_HELP NC_("RID_STACK_HELP", "Vertical Stack" )
+#define RID_MATRIX_HELP NC_("RID_MATRIX_HELP", "Matrix Stack" )
+#define RID_ALIGNLX_HELP NC_("RID_ALIGNLX_HELP", "Align Left" )
+#define RID_ALIGNCX_HELP NC_("RID_ALIGNCX_HELP", "Align Center" )
+#define RID_ALIGNRX_HELP NC_("RID_ALIGNRX_HELP", "Align Right" )
+#define RID_ALEPH_HELP NC_("RID_ALEPH_HELP", "Aleph" )
+#define RID_EMPTYSET_HELP NC_("RID_EMPTYSET_HELP", "Empty Set" )
+#define RID_RE_HELP NC_("RID_RE_HELP", "Real Part" )
+#define RID_IM_HELP NC_("RID_IM_HELP", "Imaginary Part" )
+#define RID_INFINITY_HELP NC_("RID_INFINITY_HELP", "Infinity" )
+#define RID_PARTIAL_HELP NC_("RID_PARTIAL_HELP", "Partial" )
+#define RID_NABLA_HELP NC_("RID_NABLA_HELP", "Nabla" )
+#define RID_LAPLACE_HELP NC_("RID_LAPLACE_HELP", "Laplace" )
+#define RID_WP_HELP NC_("RID_WP_HELP", "Weierstrass p" )
+#define RID_DOTSAXIS_HELP NC_("RID_DOTSAXIS_HELP", "Dots In Middle" )
+#define RID_DOTSUP_HELP NC_("RID_DOTSUP_HELP", "Dots To Top" )
+#define RID_DOTSDOWN_HELP NC_("RID_DOTSDOWN_HELP", "Dots To Bottom" )
+#define RID_DOTSLOW_HELP NC_("RID_DOTSLOW_HELP", "Dots At Bottom" )
+#define RID_DOTSVERT_HELP NC_("RID_DOTSVERT_HELP", "Dots Vertically" )
+#define RID_XCIRCY_HELP NC_("RID_XCIRCY_HELP", "Concatenate" )
+#define RID_XWIDESLASHY_HELP NC_("RID_XWIDESLASHY_HELP", "Division (wideslash)" )
+#define RID_XWIDEBSLASHY_HELP NC_("RID_XWIDEBSLASHY_HELP", "Division (counter wideslash)" )
+#define RID_XDIVIDESY_HELP NC_("RID_XDIVIDESY_HELP", "Divides" )
+#define RID_XNDIVIDESY_HELP NC_("RID_XNDIVIDESY_HELP", "Does Not Divide" )
+#define RID_DLARROW_HELP NC_("RID_DLARROW_HELP", "Double Arrow Left" )
+#define RID_DLRARROW_HELP NC_("RID_DLRARROW_HELP", "Double Arrow Left And Right" )
+#define RID_DRARROW_HELP NC_("RID_DRARROW_HELP", "Double Arrow Right" )
+#define RID_SETN_HELP NC_("RID_SETN_HELP", "Natural Numbers Set" )
+#define RID_SETZ_HELP NC_("RID_SETZ_HELP", "Integers Set" )
+#define RID_SETQ_HELP NC_("RID_SETQ_HELP", "Set of Rational Numbers" )
+#define RID_SETR_HELP NC_("RID_SETR_HELP", "Real Numbers Set" )
+#define RID_SETC_HELP NC_("RID_SETC_HELP", "Complex Numbers Set" )
+#define RID_WIDEHATX_HELP NC_("RID_WIDEHATX_HELP", "Large Circumflex" )
+#define RID_WIDETILDEX_HELP NC_("RID_WIDETILDEX_HELP", "Large Tilde" )
+#define RID_WIDEVECX_HELP NC_("RID_WIDEVECX_HELP", "Large Vector Arrow" )
+#define RID_WIDEHARPOONX_HELP NC_("RID_WIDEHARPOONX_HELP", "Large Harpoon" )
+#define RID_HBAR_HELP NC_("RID_HBAR_HELP", "h Bar" )
+#define RID_LAMBDABAR_HELP NC_("RID_LAMBDABAR_HELP", "Lambda Bar" )
+#define RID_LEFTARROW_HELP NC_("RID_LEFTARROW_HELP", "Left Arrow" )
+#define RID_RIGHTARROW_HELP NC_("RID_RIGHTARROW_HELP", "Right Arrow" )
+#define RID_UPARROW_HELP NC_("RID_UPARROW_HELP", "Up Arrow" )
+#define RID_DOWNARROW_HELP NC_("RID_DOWNARROW_HELP", "Down Arrow" )
+#define RID_NOSPACE_HELP NC_("RID_NOSPACE_HELP", "No space" )
+#define RID_XPRECEDESY_HELP NC_("RID_XPRECEDESY_HELP", "Precedes" )
+#define RID_XPRECEDESEQUALY_HELP NC_("RID_XPRECEDESEQUALY_HELP", "Precedes or equal to" )
+#define RID_XPRECEDESEQUIVY_HELP NC_("RID_XPRECEDESEQUIVY_HELP", "Precedes or equivalent to" )
+#define RID_XSUCCEEDSY_HELP NC_("RID_XSUCCEEDSY_HELP", "Succeeds" )
+#define RID_XSUCCEEDSEQUALY_HELP NC_("RID_XSUCCEEDSEQUALY_HELP", "Succeeds or equal to" )
+#define RID_XSUCCEEDSEQUIVY_HELP NC_("RID_XSUCCEEDSEQUIVY_HELP", "Succeeds or equivalent to" )
+#define RID_XNOTPRECEDESY_HELP NC_("RID_XNOTPRECEDESY_HELP", "Not precedes" )
+#define RID_XNOTSUCCEEDSY_HELP NC_("RID_XNOTSUCCEEDSY_HELP", "Not succeeds" )
+#define RID_CATEGORY_UNARY_BINARY_OPERATORS NC_("RID_CATEGORY_UNARY_BINARY_OPERATORS", "Unary/Binary Operators" )
+#define RID_CATEGORY_RELATIONS NC_("RID_CATEGORY_RELATIONS", "Relations" )
+#define RID_CATEGORY_SET_OPERATIONS NC_("RID_CATEGORY_SET_OPERATIONS", "Set Operations" )
+#define RID_CATEGORY_FUNCTIONS NC_("RID_CATEGORY_FUNCTIONS", "Functions" )
+#define RID_CATEGORY_OPERATORS NC_("RID_CATEGORY_OPERATORS", "Operators" )
+#define RID_CATEGORY_ATTRIBUTES NC_("RID_CATEGORY_ATTRIBUTES", "Attributes" )
+#define RID_CATEGORY_BRACKETS NC_("RID_CATEGORY_BRACKETS", "Brackets" )
+#define RID_CATEGORY_FORMATS NC_("RID_CATEGORY_FORMATS", "Formats" )
+#define RID_CATEGORY_OTHERS NC_("RID_CATEGORY_OTHERS", "Others" )
+#define RID_CATEGORY_EXAMPLES NC_("RID_CATEGORY_EXAMPLES", "Examples" )
+
+#define RID_EXAMPLE_CIRCUMFERENCE_HELP NC_("RID_EXAMPLE_CIRCUMFERENCE_HELP", "Circumference" )
+#define RID_EXAMPLE_MASS_ENERGY_EQUIV_HELP NC_("RID_EXAMPLE_MASS_ENERGY_EQUIV_HELP", "Mass–energy equivalence" )
+#define RID_EXAMPLE_PYTHAGOREAN_THEO_HELP NC_("RID_EXAMPLE_PYTHAGOREAN_THEO_HELP", "Pythagorean theorem" )
+#define RID_EXAMPLE_A_SIMPLE_SERIES_HELP NC_("RID_EXAMPLE_A_SIMPLE_SERIES_HELP", "A simple series" )
+#define RID_EXAMPLE_GAUSS_DISTRIBUTION_HELP NC_("RID_EXAMPLE_GAUSS_DISTRIBUTION_HELP", "Gauss distribution" )
+
+#define RID_FONTREGULAR NC_("RID_FONTREGULAR", "Standard" )
+#define RID_FONTITALIC NC_("RID_FONTITALIC", "Italic" )
+#define RID_FONTBOLD NC_("RID_FONTBOLD", "Bold" )
+#define STR_BLACK NC_("STR_BLACK", "black" )
+#define STR_BLUE NC_("STR_BLUE", "blue" )
+#define STR_GREEN NC_("STR_GREEN", "green" )
+#define STR_RED NC_("STR_RED", "red" )
+#define STR_CYAN NC_("STR_CYAN", "cyan" )
+#define STR_MAGENTA NC_("STR_MAGENTA", "magenta" )
+#define STR_GRAY NC_("STR_GRAY", "gray" )
+#define STR_LIME NC_("STR_LIME", "lime" )
+#define STR_MAROON NC_("STR_MAROON", "maroon" )
+#define STR_NAVY NC_("STR_NAVY", "navy" )
+#define STR_OLIVE NC_("STR_OLIVE", "olive" )
+#define STR_PURPLE NC_("STR_PURPLE", "purple" )
+#define STR_SILVER NC_("STR_SILVER", "silver" )
+#define STR_TEAL NC_("STR_TEAL", "teal" )
+#define STR_YELLOW NC_("STR_YELLOW", "yellow" )
+#define STR_RGB NC_("STR_RGB", "rgb" )
+#define STR_HIDE NC_("STR_HIDE", "hide" )
+#define STR_SIZE NC_("STR_SIZE", "size" )
+#define STR_FONT NC_("STR_FONT", "font" )
+#define STR_ALIGN_LEFT NC_("STR_ALIGN_LEFT", "left" )
+#define STR_ALIGN_CENTER NC_("STR_ALIGN_CENTER", "center" )
+#define STR_ALIGN_RIGHT NC_("STR_ALIGN_RIGHT", "right" )
+#define STR_CMDBOXWINDOW NC_("STR_CMDBOXWINDOW", "Commands" )
+#define RID_DOCUMENTSTR NC_("RID_DOCUMENTSTR", "Formula" )
+#define STR_STATSTR_WRITING NC_("STR_STATSTR_WRITING", "Saving document..." )
+#define STR_MATH_DOCUMENT_FULLTYPE_CURRENT NC_("STR_MATH_DOCUMENT_FULLTYPE_CURRENT", "%PRODUCTNAME %PRODUCTVERSION Formula")
+#define RID_ERR_IDENT NC_("RID_ERR_IDENT", "ERROR : " )
+#define RID_ERR_UNEXPECTEDCHARACTER NC_("RID_ERR_UNEXPECTEDCHARACTER", "Unexpected character" )
+#define RID_ERR_UNEXPECTEDTOKEN NC_("RID_ERR_UNEXPECTEDTOKEN", "Unexpected token" )
+#define RID_ERR_LGROUPEXPECTED NC_("RID_ERR_LGROUPEXPECTED", "'{' expected" )
+#define RID_ERR_RGROUPEXPECTED NC_("RID_ERR_RGROUPEXPECTED", "'}' expected" )
+#define RID_ERR_LBRACEEXPECTED NC_("RID_ERR_LBRACEEXPECTED", "'(' expected" )
+#define RID_ERR_RBRACEEXPECTED NC_("RID_ERR_RBRACEEXPECTED", "')' expected" )
+#define RID_ERR_PARENTMISMATCH NC_("RID_ERR_PARENTMISMATCH", "Left and right symbols mismatched" )
+#define RID_ERR_FONTEXPECTED NC_("RID_ERR_FONTEXPECTED", "'fixed', 'sans', or 'serif' expected" )
+#define RID_ERR_SIZEEXPECTED NC_("RID_ERR_SIZEEXPECTED", "'size' followed by an unexpected token" )
+#define RID_ERR_DOUBLEALIGN NC_("RID_ERR_DOUBLEALIGN", "Double aligning is not allowed" )
+#define RID_ERR_DOUBLESUBSUPSCRIPT NC_("RID_ERR_DOUBLESUBSUPSCRIPT", "Double sub/superscripts is not allowed" )
+#define RID_ERR_POUNDEXPECTED NC_("RID_ERR_POUNDEXPECTED", "'#' expected" )
+#define RID_ERR_COLOREXPECTED NC_("RID_ERR_COLOREXPECTED", "Color required" )
+#define RID_ERR_RIGHTEXPECTED NC_("RID_ERR_RIGHTEXPECTED", "'RIGHT' expected" )
+#define RID_PRINTUIOPT_PRODNAME NC_("RID_PRINTUIOPT_PRODNAME", "%PRODUCTNAME %s" )
+#define RID_PRINTUIOPT_CONTENTS NC_("RID_PRINTUIOPT_CONTENTS", "Contents" )
+#define RID_PRINTUIOPT_TITLE NC_("RID_PRINTUIOPT_TITLE", "~Title" )
+#define RID_PRINTUIOPT_FRMLTXT NC_("RID_PRINTUIOPT_FRMLTXT", "~Formula text" )
+#define RID_PRINTUIOPT_BORDERS NC_("RID_PRINTUIOPT_BORDERS", "B~orders" )
+#define RID_PRINTUIOPT_SIZE NC_("RID_PRINTUIOPT_SIZE", "Size" )
+#define RID_PRINTUIOPT_ORIGSIZE NC_("RID_PRINTUIOPT_ORIGSIZE", "O~riginal size" )
+#define RID_PRINTUIOPT_FITTOPAGE NC_("RID_PRINTUIOPT_FITTOPAGE", "Fit to ~page" )
+#define RID_PRINTUIOPT_SCALING NC_("RID_PRINTUIOPT_SCALING", "~Scaling" )
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/strings.hxx b/starmath/inc/strings.hxx
new file mode 100644
index 000000000..bedd95347
--- /dev/null
+++ b/starmath/inc/strings.hxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#ifndef INCLUDED_STARMATH_INC_STRINGS_HXX
+#define INCLUDED_STARMATH_INC_STRINGS_HXX
+
+#define RID_UNDOFORMATNAME "Format"
+
+#define RID_PLUSX "+<?> "
+#define RID_MINUSX "-<?> "
+#define RID_PLUSMINUSX "+-<?> "
+#define RID_MINUSPLUSX "-+<?> "
+#define RID_NEGX "neg <?> "
+#define RID_XPLUSY "<?> + <?> "
+#define RID_XMINUSY "<?> - <?> "
+#define RID_XCDOTY "<?> cdot <?> "
+#define RID_XTIMESY "<?> times <?> "
+#define RID_XSYMTIMESY "<?> * <?> "
+#define RID_XSYMDIVIDEY "<?> / <?> "
+#define RID_XDIVY "<?> div <?> "
+#define RID_XOVERY "{<?>} over {<?>} "
+#define RID_XODIVIDEY "<?> odivide <?> "
+#define RID_XODOTY "<?> odot <?> "
+#define RID_XOMINUSY "<?> ominus <?> "
+#define RID_XOPLUSY "<?> oplus <?> "
+#define RID_XOTIMESY "<?> otimes <?> "
+#define RID_XANDY "<?> and <?> "
+#define RID_XORY "<?> or <?> "
+#define RID_XEQY "<?> = <?> "
+#define RID_XNEQY "<?> <> <?> "
+#define RID_XLTY "<?> < <?> "
+#define RID_XGTY "<?> > <?> "
+#define RID_XLEY "<?> <= <?> "
+#define RID_XGEY "<?> >= <?> "
+#define RID_XLESLANTY "<?> leslant <?> "
+#define RID_XGESLANTY "<?> geslant <?> "
+#define RID_XLLY "<?> << <?> "
+#define RID_XGGY "<?> >> <?> "
+#define RID_XDEFY "<?> def <?> "
+#define RID_XEQUIVY "<?> equiv <?> "
+#define RID_XAPPROXY "<?> approx <?> "
+#define RID_XSIMY "<?> sim <?> "
+#define RID_XSIMEQY "<?> simeq <?> "
+#define RID_XPROPY "<?> prop <?> "
+#define RID_XORTHOY "<?> ortho <?> "
+#define RID_XPARALLELY "<?> parallel <?> "
+#define RID_XTOWARDY "<?> toward <?> "
+#define RID_XTRANSLY "<?> transl <?> "
+#define RID_XTRANSRY "<?> transr <?> "
+#define RID_XINY "<?> in <?> "
+#define RID_XNOTINY "<?> notin <?> "
+#define RID_XOWNSY "<?> owns <?> "
+#define RID_XUNIONY "<?> union <?> "
+#define RID_XINTERSECTIONY "<?> intersection <?> "
+#define RID_XSETMINUSY "<?> setminus <?> "
+#define RID_XSLASHY "<?> slash <?> "
+#define RID_XSUBSETY "<?> subset <?> "
+#define RID_XSUBSETEQY "<?> subseteq <?> "
+#define RID_XSUPSETY "<?> supset <?> "
+#define RID_XSUPSETEQY "<?> supseteq <?> "
+#define RID_XNSUBSETY "<?> nsubset <?> "
+#define RID_XNSUBSETEQY "<?> nsubseteq <?> "
+#define RID_XNSUPSETY "<?> nsupset <?> "
+#define RID_XNSUPSETEQY "<?> nsupseteq <?> "
+#define RID_ABSX "abs{<?>} "
+#define RID_FACTX "fact{<?>} "
+#define RID_SQRTX "sqrt{<?>} "
+#define RID_NROOTXY "nroot{<?>}{<?>} "
+#define RID_EX "func e^{<?>} "
+#define RID_EXPX "exp(<?>) "
+#define RID_LNX "ln(<?>) "
+#define RID_LOGX "log(<?>) "
+#define RID_SINX "sin(<?>) "
+#define RID_COSX "cos(<?>) "
+#define RID_TANX "tan(<?>) "
+#define RID_COTX "cot(<?>) "
+#define RID_ARCSINX "arcsin(<?>) "
+#define RID_ARCCOSX "arccos(<?>) "
+#define RID_ARCTANX "arctan(<?>) "
+#define RID_ARCCOTX "arccot(<?>) "
+#define RID_SINHX "sinh(<?>) "
+#define RID_COSHX "cosh(<?>) "
+#define RID_TANHX "tanh(<?>) "
+#define RID_COTHX "coth(<?>) "
+#define RID_ARSINHX "arsinh(<?>) "
+#define RID_ARCOSHX "arcosh(<?>) "
+#define RID_ARTANHX "artanh(<?>) "
+#define RID_ARCOTHX "arcoth(<?>) "
+#define RID_SUMX "sum <?> "
+#define RID_SUM_FROMX "sum from{<?>} <?> "
+#define RID_SUM_TOX "sum to{<?>} <?> "
+#define RID_SUM_FROMTOX "sum from{<?>} to{<?>} <?> "
+#define RID_PRODX "prod <?> "
+#define RID_PROD_FROMX "prod from{<?>} <?> "
+#define RID_PROD_TOX "prod to{<?>} <?> "
+#define RID_PROD_FROMTOX "prod from{<?>} to{<?>} <?> "
+#define RID_COPRODX "coprod <?> "
+#define RID_COPROD_FROMX "coprod from{<?>} <?> "
+#define RID_COPROD_TOX "coprod to{<?>} <?> "
+#define RID_COPROD_FROMTOX "coprod from{<?>} to{<?>} <?> "
+#define RID_LIMX "lim <?> "
+#define RID_LIM_FROMX "lim from{<?>} <?> "
+#define RID_LIM_TOX "lim to{<?>} <?> "
+#define RID_LIM_FROMTOX "lim from{<?>} to{<?>} <?> "
+#define RID_LIMINFX "liminf <?> "
+#define RID_LIMINF_FROMX "liminf from{<?>} <?> "
+#define RID_LIMINF_TOX "liminf to{<?>} <?> "
+#define RID_LIMINF_FROMTOX "liminf from{<?>} to{<?>} <?> "
+#define RID_LIMSUPX "limsup <?> "
+#define RID_LIMSUP_FROMX "limsup from{<?>} <?> "
+#define RID_LIMSUP_TOX "limsup to{<?>} <?> "
+#define RID_LIMSUP_FROMTOX "limsup from{<?>} to{<?>} <?> "
+#define RID_EXISTS "exists "
+#define RID_NOTEXISTS "notexists "
+#define RID_FORALL "forall "
+#define RID_INTX "int <?> "
+#define RID_INT_FROMX "int from{<?>} <?> "
+#define RID_INT_TOX "int to{<?>} <?> "
+#define RID_INT_FROMTOX "int from{<?>} to{<?>} <?> "
+#define RID_IINTX "iint <?> "
+#define RID_IINT_FROMX "iint from{<?>} <?> "
+#define RID_IINT_TOX "iint to{<?>} <?> "
+#define RID_IINT_FROMTOX "iint from{<?>} to{<?>} <?> "
+#define RID_IIINTX "iiint <?> "
+#define RID_IIINT_FROMX "iiint from{<?>} <?> "
+#define RID_IIINT_TOX "iiint to{<?>} <?> "
+#define RID_IIINT_FROMTOX "iiint from{<?>} to{<?>} <?> "
+#define RID_LINTX "lint <?> "
+#define RID_LINT_FROMX "lint from{<?>} <?> "
+#define RID_LINT_TOX "lint to{<?>} <?> "
+#define RID_LINT_FROMTOX "lint from{<?>} to{<?>} <?> "
+#define RID_LLINTX "llint <?> "
+#define RID_LLINT_FROMX "llint from{<?>} <?> "
+#define RID_LLINT_TOX "llint to{<?>} <?> "
+#define RID_LLINT_FROMTOX "llint from{<?>} to{<?>} <?> "
+#define RID_LLLINTX "lllint <?> "
+#define RID_LLLINT_FROMX "lllint from{<?>} <?> "
+#define RID_LLLINT_TOX "lllint to{<?>} <?> "
+#define RID_LLLINT_FROMTOX "lllint from{<?>} to{<?>} <?> "
+#define RID_FROMX "from{<?>} <?> "
+#define RID_TOX "to{<?>} <?> "
+#define RID_FROMXTOY "from{<?>} to{<?>} <?> "
+#define RID_ACUTEX "acute <?> "
+#define RID_BARX "bar <?> "
+#define RID_BREVEX "breve <?> "
+#define RID_CHECKX "check <?> "
+#define RID_CIRCLEX "circle <?> "
+#define RID_DOTX "dot <?> "
+#define RID_DDOTX "ddot <?> "
+#define RID_DDDOTX "dddot <?> "
+#define RID_GRAVEX "grave <?> "
+#define RID_HATX "hat <?> "
+#define RID_TILDEX "tilde <?> "
+#define RID_VECX "vec <?> "
+#define RID_HARPOONX "harpoon <?> "
+#define RID_UNDERLINEX "underline {<?>} "
+#define RID_OVERLINEX "overline {<?>} "
+#define RID_OVERSTRIKEX "overstrike {<?>} "
+#define RID_PHANTOMX "phantom {<?>} "
+#define RID_BOLDX "bold <?> "
+#define RID_ITALX "ital <?> "
+#define RID_SIZEXY "size <?> {<?>} "
+#define RID_FONTXY "font <?> {<?>} "
+#define RID_COLORX_BLACK "color black {<?>} "
+#define RID_COLORX_BLUE "color blue {<?>} "
+#define RID_COLORX_GREEN "color green {<?>} "
+#define RID_COLORX_RED "color red {<?>} "
+#define RID_COLORX_CYAN "color cyan {<?>} "
+#define RID_COLORX_MAGENTA "color magenta {<?>} "
+#define RID_COLORX_GRAY "color gray {<?>} "
+#define RID_COLORX_LIME "color lime {<?>} "
+#define RID_COLORX_MAROON "color maroon {<?>} "
+#define RID_COLORX_NAVY "color navy {<?>} "
+#define RID_COLORX_OLIVE "color olive {<?>} "
+#define RID_COLORX_PURPLE "color purple {<?>} "
+#define RID_COLORX_SILVER "color silver {<?>} "
+#define RID_COLORX_TEAL "color teal {<?>} "
+#define RID_COLORX_YELLOW "color yellow {<?>} "
+#define RID_COLORX_RGB "color rgb 0 0 0 {<?>} "
+#define RID_LRGROUPX "{<?>} "
+#define RID_LRPARENTX "(<?>) "
+#define RID_LRBRACKETX "[<?>] "
+#define RID_LRDBRACKETX "ldbracket <?> rdbracket "
+#define RID_LRBRACEX "lbrace <?> rbrace "
+#define RID_LRANGLEX "langle <?> rangle "
+#define RID_LRCEILX "lceil <?> rceil "
+#define RID_LRFLOORX "lfloor <?> rfloor "
+#define RID_LRLINEX "lline <?> rline "
+#define RID_LRDLINEX "ldline <?> rdline "
+#define RID_LMRANGLEXY "langle <?> mline <?> rangle "
+#define RID_SLRPARENTX "left ( <?> right ) "
+#define RID_SLRBRACKETX "left [ <?> right ] "
+#define RID_SLRDBRACKETX "left ldbracket <?> right rdbracket "
+#define RID_SLRBRACEX "left lbrace <?> right rbrace "
+#define RID_SLRANGLEX "left langle <?> right rangle "
+#define RID_SLRCEILX "left lceil <?> right rceil "
+#define RID_SLRFLOORX "left lfloor <?> right rfloor "
+#define RID_SLRLINEX "left lline <?> right rline "
+#define RID_SLRDLINEX "left ldline <?> right rdline "
+#define RID_SLMRANGLEXY "left langle <?> mline <?> right rangle "
+#define RID_XEVALUATEDATY "left none {<?>} right rline_{<?>} "
+#define RID_XOVERBRACEY "{<?>} overbrace {<?>} "
+#define RID_XUNDERBRACEY "{<?>} underbrace {<?>} "
+#define RID_RSUBX "<?>_{<?>}"
+#define RID_RSUPX "<?>^{<?>}"
+#define RID_LSUBX "<?> lsub{<?>} "
+#define RID_LSUPX "<?> lsup{<?>} "
+#define RID_CSUBX "<?> csub{<?>} "
+#define RID_CSUPX "<?> csup{<?>} "
+#define RID_SBLANK "`"
+#define RID_BLANK "~"
+#define RID_NEWLINE "newline "
+#define RID_BINOMXY "binom{<?>}{<?>} "
+#define RID_STACK "stack{<?> # <?> # <?>} "
+#define RID_MATRIX "matrix{<?> # <?> ## <?> # <?>} "
+#define RID_ALIGNLX "alignl <?> "
+#define RID_ALIGNCX "alignc <?> "
+#define RID_ALIGNRX "alignr <?> "
+#define RID_ALEPH "aleph "
+#define RID_EMPTYSET "emptyset "
+#define RID_RE "Re "
+#define RID_IM "Im "
+#define RID_INFINITY "infinity "
+#define RID_PARTIAL "partial "
+#define RID_NABLA "nabla "
+#define RID_WP "wp "
+#define RID_LAPLACE "laplace "
+#define RID_DOTSAXIS "dotsaxis "
+#define RID_DOTSUP "dotsup "
+#define RID_DOTSDOWN "dotsdown "
+#define RID_DOTSLOW "dotslow "
+#define RID_DOTSVERT "dotsvert "
+#define RID_XCIRCY "<?> circ <?> "
+#define RID_XWIDESLASHY "{<?>} wideslash {<?>} "
+#define RID_XWIDEBSLASHY "{<?>} widebslash {<?>} "
+#define RID_XDIVIDESY "<?> divides <?> "
+#define RID_XNDIVIDESY "<?> ndivides <?> "
+#define RID_DLARROW "<?> dlarrow <?> "
+#define RID_DLRARROW "<?> dlrarrow <?> "
+#define RID_DRARROW "<?> drarrow <?> "
+#define RID_SETN "setN "
+#define RID_SETZ "setZ "
+#define RID_SETQ "setQ "
+#define RID_SETR "setR "
+#define RID_SETC "setC "
+#define RID_WIDEHATX "widehat {<?>} "
+#define RID_WIDETILDEX "widetilde {<?>} "
+#define RID_WIDEVECX "widevec {<?>} "
+#define RID_WIDEHARPOONX "wideharpoon {<?>} "
+#define RID_HBAR "hbar "
+#define RID_LAMBDABAR "lambdabar "
+#define RID_LEFTARROW "leftarrow "
+#define RID_RIGHTARROW "rightarrow "
+#define RID_UPARROW "uparrow "
+#define RID_DOWNARROW "downarrow "
+#define RID_NOSPACE "nospace {<?>} "
+#define RID_XPRECEDESY "<?> prec <?> "
+#define RID_XPRECEDESEQUALY "<?> preccurlyeq <?> "
+#define RID_XPRECEDESEQUIVY "<?> precsim <?> "
+#define RID_XSUCCEEDSY "<?> succ <?> "
+#define RID_XSUCCEEDSEQUALY "<?> succcurlyeq <?> "
+#define RID_XSUCCEEDSEQUIVY "<?> succsim <?> "
+#define RID_XNOTPRECEDESY "<?> nprec <?> "
+#define RID_XNOTSUCCEEDSY "<?> nsucc <?> "
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/starmath/inc/symbol.hxx b/starmath/inc/symbol.hxx
new file mode 100644
index 000000000..9a9a595ed
--- /dev/null
+++ b/starmath/inc/symbol.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_SYMBOL_HXX
+#define INCLUDED_STARMATH_INC_SYMBOL_HXX
+
+#include <map>
+#include <vector>
+#include <set>
+
+#include "utility.hxx"
+
+
+#define SYMBOL_NONE 0xFFFF
+
+class SmSym
+{
+private:
+ SmFace m_aFace;
+ OUString m_aName;
+ OUString m_aExportName;
+ OUString m_aSetName;
+ sal_UCS4 m_cChar;
+ bool m_bPredefined;
+
+public:
+ SmSym();
+ SmSym(const OUString& rName, const vcl::Font& rFont, sal_UCS4 cChar,
+ const OUString& rSet, bool bIsPredefined = false);
+ SmSym(const SmSym& rSymbol);
+
+ SmSym& operator = (const SmSym& rSymbol);
+
+ const vcl::Font& GetFace() const { return m_aFace; }
+ sal_UCS4 GetCharacter() const { return m_cChar; }
+ const OUString& GetName() const { return m_aName; }
+
+ bool IsPredefined() const { return m_bPredefined; }
+ const OUString& GetSymbolSetName() const { return m_aSetName; }
+ const OUString& GetExportName() const { return m_aExportName; }
+ void SetExportName( const OUString &rName ) { m_aExportName = rName; }
+
+ // true if rSymbol has the same name, font and character
+ bool IsEqualInUI( const SmSym& rSymbol ) const;
+};
+
+// type of the actual container to hold the symbols
+typedef std::map< OUString, SmSym > SymbolMap_t;
+
+// vector of pointers to the actual symbols in the above container
+typedef std::vector< const SmSym * > SymbolPtrVec_t;
+
+
+class SmSymbolManager
+{
+private:
+ SymbolMap_t m_aSymbols;
+ bool m_bModified;
+
+public:
+ SmSymbolManager();
+ SmSymbolManager(const SmSymbolManager& rSymbolSetManager);
+ ~SmSymbolManager();
+
+ SmSymbolManager & operator = (const SmSymbolManager& rSymbolSetManager);
+
+ // symbol sets are for UI purpose only, thus we assemble them here
+ std::set< OUString > GetSymbolSetNames() const;
+ SymbolPtrVec_t GetSymbolSet( const OUString& rSymbolSetName );
+
+ SymbolPtrVec_t GetSymbols() const;
+ bool AddOrReplaceSymbol( const SmSym & rSymbol, bool bForceChange = false );
+ void RemoveSymbol( const OUString & rSymbolName );
+
+ SmSym * GetSymbolByName(const OUString& rSymbolName);
+ const SmSym * GetSymbolByName(const OUString& rSymbolName) const
+ {
+ return const_cast<SmSymbolManager *>(this)->GetSymbolByName(rSymbolName);
+ }
+
+ bool IsModified() const { return m_bModified; }
+ void SetModified(bool bModify) { m_bModified = bModify; }
+
+ void Load();
+ void Save();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/token.hxx b/starmath/inc/token.hxx
new file mode 100644
index 000000000..cdc91ddf4
--- /dev/null
+++ b/starmath/inc/token.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_TOKEN_HXX
+#define INCLUDED_STARMATH_INC_TOKEN_HXX
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <o3tl/typed_flags_set.hxx>
+
+// TokenGroups
+enum class TG {
+ NONE = 0x000000,
+ Oper = 0x000001,
+ Relation = 0x000002,
+ Sum = 0x000004,
+ Product = 0x000008,
+ UnOper = 0x000010,
+ Power = 0x000020,
+ Attribute = 0x000040,
+ Align = 0x000080,
+ Function = 0x000100,
+ Blank = 0x000200,
+ LBrace = 0x000400,
+ RBrace = 0x000800,
+ Color = 0x001000,
+ Font = 0x002000,
+ Standalone = 0x004000,
+ Limit = 0x010000,
+ FontAttr = 0x020000
+};
+
+namespace o3tl {
+ template<> struct typed_flags<TG> : is_typed_flags<TG, 0x037fff> {};
+}
+
+enum SmTokenType
+{
+ TEND, TLGROUP, TRGROUP, TLPARENT, TRPARENT,
+ TLBRACKET, TRBRACKET, TPLUS, TMINUS, TMULTIPLY,
+ TDIVIDEBY, TASSIGN, TPOUND, TSPECIAL, TSLASH,
+ TBACKSLASH, TBLANK, TSBLANK, TRSUB, TRSUP,
+ TCSUB, TCSUP, TLSUB, TLSUP, TGT,
+ TLT, TAND, TOR, TINTERSECT, TUNION,
+ TNEWLINE, TBINOM, TFROM, TTO, TINT,
+ TSUM, TOPER, TABS, TSQRT, TFACT,
+ TNROOT, TOVER, TTIMES, TGE, TLE,
+ TGG, TLL, TDOTSAXIS, TDOTSLOW, TDOTSVERT,
+ TDOTSDIAG, TDOTSUP, TDOTSDOWN, TACUTE, TBAR,
+ TBREVE, TCHECK, TCIRCLE, TDOT, TDDOT,
+ TDDDOT, TGRAVE, THAT, TTILDE, TVEC,
+ THARPOON,
+ TUNDERLINE, TOVERLINE, TOVERSTRIKE, TITALIC, TNITALIC,
+ TBOLD, TNBOLD, TPHANTOM, TFONT, TSIZE,
+ TCOLOR, TALIGNL, TALIGNC, TALIGNR, TLEFT,
+ TRIGHT, TLANGLE, TLBRACE, TLLINE, TLDLINE,
+ TLCEIL, TLFLOOR, TNONE, TMLINE, TRANGLE,
+ TRBRACE, TRLINE, TRDLINE, TRCEIL, TRFLOOR,
+ TSIN, TCOS, TTAN, TCOT, TFUNC,
+ TSTACK, TMATRIX, TDPOUND, TPLACE,
+ TTEXT, TNUMBER, TCHARACTER, TIDENT, TNEQ,
+ TEQUIV, TDEF, TPROP, TSIM, TSIMEQ,
+ TAPPROX, TPARALLEL, TORTHO, TIN, TNOTIN,
+ TSUBSET, TSUBSETEQ, TSUPSET, TSUPSETEQ, TPLUSMINUS,
+ TMINUSPLUS, TOPLUS, TOMINUS, TDIV, TOTIMES,
+ TODIVIDE, TTRANSL, TTRANSR, TIINT, TIIINT,
+ TLINT, TLLINT, TLLLINT, TPROD, TCOPROD,
+ TFORALL, TEXISTS, TNOTEXISTS, TLIM, TNABLA,
+ TTOWARD, TSINH, TCOSH, TTANH, TCOTH,
+ TASIN, TACOS, TATAN, TLN, TLOG,
+ TUOPER, TBOPER, TBLACK, TWHITE, TRED,
+ TGREEN, TBLUE, TCYAN, TMAGENTA, TYELLOW,
+ TFIXED, TSANS, TSERIF, TASINH,
+ TACOSH, TATANH, TACOTH, TACOT, TEXP,
+ TCDOT, TODOT, TLESLANT, TGESLANT, TNSUBSET,
+ TNSUPSET, TNSUBSETEQ, TNSUPSETEQ, TPARTIAL, TNEG,
+ TNI, TBACKEPSILON, TALEPH, TIM, TRE,
+ TWP, TEMPTYSET, TINFINITY, TESCAPE, TLIMSUP,
+ TLIMINF, TNDIVIDES, TDRARROW, TDLARROW, TDLRARROW,
+ TUNDERBRACE, TOVERBRACE, TCIRC, THBAR,
+ TLAMBDABAR, TLEFTARROW, TRIGHTARROW, TUPARROW, TDOWNARROW,
+ TDIVIDES, TSETN, TSETZ, TSETQ,
+ TSETR, TSETC, TWIDEVEC, TWIDEHARPOON, TWIDETILDE,
+ TWIDEHAT,
+ TWIDESLASH, TWIDEBACKSLASH, TLDBRACKET, TRDBRACKET, TNOSPACE,
+ TUNKNOWN, TPRECEDES, TSUCCEEDS, TPRECEDESEQUAL, TSUCCEEDSEQUAL,
+ TPRECEDESEQUIV, TSUCCEEDSEQUIV, TNOTPRECEDES, TNOTSUCCEEDS, TSILVER,
+ TGRAY, TMAROON, TPURPLE, TLIME, TOLIVE,
+ TNAVY, TTEAL, TAQUA, TFUCHSIA, TINTD,
+ TRGB, TLAPLACE
+};
+
+struct SmToken
+{
+
+ OUString aText; // token text
+ SmTokenType eType; // token info
+ sal_Unicode cMathChar;
+
+ // parse-help info
+ TG nGroup;
+ sal_uInt16 nLevel;
+
+ // token position
+ sal_Int32 nRow; // 1-based
+ sal_Int32 nCol; // 1-based
+
+ SmToken();
+ SmToken(SmTokenType eTokenType,
+ sal_Unicode cMath,
+ const char* pText,
+ TG nTokenGroup = TG::NONE,
+ sal_uInt16 nTokenLevel = 0);
+};
+
+struct SmTokenTableEntry
+{
+ const char* pIdent;
+ SmTokenType eType;
+ sal_Unicode cMathChar;
+ TG nGroup;
+ sal_uInt16 nLevel;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx
new file mode 100644
index 000000000..044b2fab0
--- /dev/null
+++ b/starmath/inc/types.hxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+
+#ifndef INCLUDED_STARMATH_INC_TYPES_HXX
+#define INCLUDED_STARMATH_INC_TYPES_HXX
+
+#include <sal/types.h>
+#define FONTNAME_MATH "OpenSymbol"
+
+
+enum SmPrintSize { PRINT_SIZE_NORMAL, PRINT_SIZE_SCALED, PRINT_SIZE_ZOOMED };
+
+
+// definitions for characters from the 'StarSymbol' font
+// (some chars have more than one alias!)
+//! Note: not listed here does not(!) mean "not used"
+//! (see %alpha ... %gamma for example)
+
+sal_Unicode const MS_FACT = 0x0021;
+sal_Unicode const MS_INFINITY = 0x221E;
+sal_Unicode const MS_SLASH = 0x002F;
+
+sal_Unicode const MS_NDIVIDES = 0x2224;
+sal_Unicode const MS_DRARROW = 0x21D2;
+sal_Unicode const MS_DLARROW = 0x21D0;
+sal_Unicode const MS_DLRARROW = 0x21D4;
+sal_Unicode const MS_OVERBRACE = 0x23DE;
+sal_Unicode const MS_UNDERBRACE = 0x23DF;
+sal_Unicode const MS_CIRC = 0x2218;
+sal_Unicode const MS_ASSIGN = 0x003D;
+sal_Unicode const MS_ERROR = 0x00BF;
+
+sal_Unicode const MS_NEQ = 0x2260;
+sal_Unicode const MS_PLUS = 0x002B;
+sal_Unicode const MS_MINUS = 0x2212;
+sal_Unicode const MS_MULTIPLY = 0x2217;
+sal_Unicode const MS_TIMES = 0x00D7;
+sal_Unicode const MS_CDOT = 0x22C5;
+sal_Unicode const MS_DIV = 0x00F7;
+sal_Unicode const MS_PLUSMINUS = 0x00B1;
+sal_Unicode const MS_MINUSPLUS = 0x2213;
+sal_Unicode const MS_OPLUS = 0x2295;
+sal_Unicode const MS_OMINUS = 0x2296;
+sal_Unicode const MS_OTIMES = 0x2297;
+sal_Unicode const MS_ODIVIDE = 0x2298;
+sal_Unicode const MS_ODOT = 0x2299;
+sal_Unicode const MS_UNION = 0x222A;
+sal_Unicode const MS_INTERSECT = 0x2229;
+
+sal_Unicode const MS_LT = 0x003C;
+sal_Unicode const MS_GT = 0x003E;
+sal_Unicode const MS_LE = 0x2264;
+sal_Unicode const MS_GE = 0x2265;
+sal_Unicode const MS_LESLANT = 0x2A7D;
+sal_Unicode const MS_GESLANT = 0x2A7E;
+sal_Unicode const MS_LL = 0x226A;
+sal_Unicode const MS_GG = 0x226B;
+sal_Unicode const MS_SIM = 0x223C;
+sal_Unicode const MS_SIMEQ = 0x2243;
+sal_Unicode const MS_APPROX = 0x2248;
+sal_Unicode const MS_DEF = 0x225D;
+sal_Unicode const MS_EQUIV = 0x2261;
+sal_Unicode const MS_PROP = 0x221D;
+sal_Unicode const MS_PARTIAL = 0x2202;
+sal_Unicode const MS_LAPLACE = 0x2112;
+
+sal_Unicode const MS_SUBSET = 0x2282;
+sal_Unicode const MS_SUPSET = 0x2283;
+sal_Unicode const MS_SUBSETEQ = 0x2286;
+sal_Unicode const MS_SUPSETEQ = 0x2287;
+sal_Unicode const MS_NSUBSET = 0x2284;
+sal_Unicode const MS_NSUPSET = 0x2285;
+sal_Unicode const MS_NSUBSETEQ = 0x2288;
+sal_Unicode const MS_NSUPSETEQ = 0x2289;
+sal_Unicode const MS_IN = 0x2208;
+sal_Unicode const MS_NOTIN = 0x2209;
+sal_Unicode const MS_EXISTS = 0x2203;
+sal_Unicode const MS_NOTEXISTS = 0x2204;
+sal_Unicode const MS_BACKEPSILON = 0x220D;
+sal_Unicode const MS_ALEPH = 0x2135;
+sal_Unicode const MS_IM = 0x2111;
+sal_Unicode const MS_RE = 0x211C;
+sal_Unicode const MS_WP = 0x2118;
+
+sal_Unicode const MS_LINE = 0x2223;
+sal_Unicode const MS_VERTLINE = 0x007C;
+sal_Unicode const MS_DLINE = 0x2225;
+sal_Unicode const MS_DVERTLINE = 0x2016;
+sal_Unicode const MS_ORTHO = 0x22A5;
+sal_Unicode const MS_DOTSLOW = 0x2026;
+sal_Unicode const MS_DOTSAXIS = 0x22EF;
+sal_Unicode const MS_DOTSVERT = 0x22EE;
+sal_Unicode const MS_DOTSUP = 0x22F0;
+sal_Unicode const MS_DOTSDOWN = 0x22F1;
+sal_Unicode const MS_TRANSR = 0x22B6;
+sal_Unicode const MS_TRANSL = 0x22B7;
+sal_Unicode const MS_BACKSLASH = 0x2216;
+sal_Unicode const MS_NEG = 0x00AC;
+
+sal_Unicode const MS_FORALL = 0x2200;
+sal_Unicode const MS_NABLA = 0x2207;
+sal_Unicode const MS_PROD = 0x220F;
+sal_Unicode const MS_COPROD = 0x2210;
+sal_Unicode const MS_SUM = 0x2211;
+sal_Unicode const MS_SQRT = 0x221A;
+sal_Unicode const MS_INT = 0x222B;
+sal_Unicode const MS_IINT = 0x222C;
+sal_Unicode const MS_IIINT = 0x222D;
+sal_Unicode const MS_LINT = 0x222E;
+sal_Unicode const MS_LLINT = 0x222F;
+sal_Unicode const MS_LLLINT = 0x2230;
+
+sal_Unicode const MS_GRAVE = 0x0060;
+sal_Unicode const MS_COMBGRAVE = 0x0300;
+sal_Unicode const MS_ACUTE = 0x00B4;
+sal_Unicode const MS_COMBACUTE = 0x0301;
+sal_Unicode const MS_HAT = 0x005E;
+sal_Unicode const MS_COMBHAT = 0x0302;
+sal_Unicode const MS_TILDE = 0x007E;
+sal_Unicode const MS_COMBTILDE = 0x0303;
+sal_Unicode const MS_BAR = 0x00AF;
+sal_Unicode const MS_COMBBAR = 0x0304;
+sal_Unicode const MS_COMBOVERLINE = 0x0305;
+sal_Unicode const MS_BREVE = 0x02D8;
+sal_Unicode const MS_COMBBREVE = 0x0306;
+sal_Unicode const MS_CIRCLE = 0x02DA;
+sal_Unicode const MS_COMBCIRCLE = 0x030A;
+sal_Unicode const MS_CHECK = 0x02C7;
+sal_Unicode const MS_COMBCHECK = 0x030C;
+sal_Unicode const MS_HARPOON = 0x20D1;
+sal_Unicode const MS_VEC = 0x20D7;
+sal_Unicode const MS_DOT = 0x02D9;
+sal_Unicode const MS_DDOT = 0x00A8;
+sal_Unicode const MS_COMBDOT = 0x0307;
+sal_Unicode const MS_COMBDDOT = 0x0308;
+sal_Unicode const MS_DDDOT = 0x20DB;
+sal_Unicode const MS_AND = 0x2227;
+sal_Unicode const MS_OR = 0x2228;
+sal_Unicode const MS_NI = 0x220B;
+sal_Unicode const MS_EMPTYSET = 0x2205;
+
+sal_Unicode const MS_LPARENT = 0x0028;
+sal_Unicode const MS_RPARENT = 0x0029;
+sal_Unicode const MS_LBRACKET = 0x005B;
+sal_Unicode const MS_RBRACKET = 0x005D;
+sal_Unicode const MS_LBRACE = 0x007B;
+sal_Unicode const MS_RBRACE = 0x007D;
+sal_Unicode const MS_LCEIL = 0x2308;
+sal_Unicode const MS_RCEIL = 0x2309;
+sal_Unicode const MS_LFLOOR = 0x230A;
+sal_Unicode const MS_RFLOOR = 0x230B;
+sal_Unicode const MS_LANGLE = 0x2329;
+sal_Unicode const MS_RANGLE = 0x232A;
+sal_Unicode const MS_LDBRACKET = 0x27E6;
+sal_Unicode const MS_RDBRACKET = 0x27E7;
+sal_Unicode const MS_LMATHANGLE = 0x27E8;
+sal_Unicode const MS_RMATHANGLE = 0x27E9;
+
+sal_Unicode const MS_PLACE = 0x2751;
+
+sal_Unicode const MS_LAMBDABAR = 0x019B;
+sal_Unicode const MS_HBAR = 0x210F;
+sal_Unicode const MS_LEFTARROW = 0x2190;
+sal_Unicode const MS_UPARROW = 0x2191;
+sal_Unicode const MS_RIGHTARROW = 0x2192;
+sal_Unicode const MS_DOWNARROW = 0x2193;
+
+sal_Unicode const MS_SETN = 0x2115;
+sal_Unicode const MS_SETZ = 0x2124;
+sal_Unicode const MS_SETQ = 0x211A;
+sal_Unicode const MS_SETR = 0x211D;
+sal_Unicode const MS_SETC = 0x2102;
+
+sal_Unicode const MS_PERCENT = 0x0025;
+
+sal_Unicode const MS_PRECEDES = 0x227A;
+sal_Unicode const MS_PRECEDESEQUAL = 0x227C;
+sal_Unicode const MS_PRECEDESEQUIV = 0x227E;
+sal_Unicode const MS_SUCCEEDS = 0x227B;
+sal_Unicode const MS_SUCCEEDSEQUAL = 0x227D;
+sal_Unicode const MS_SUCCEEDSEQUIV = 0x227F;
+sal_Unicode const MS_NOTPRECEDES = 0x2280;
+sal_Unicode const MS_NOTSUCCEEDS = 0x2281;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/unomodel.hxx b/starmath/inc/unomodel.hxx
new file mode 100644
index 000000000..f18b09381
--- /dev/null
+++ b/starmath/inc/unomodel.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_UNOMODEL_HXX
+#define INCLUDED_STARMATH_INC_UNOMODEL_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/view/XRenderable.hpp>
+
+#include <sfx2/sfxbasemodel.hxx>
+#include <comphelper/propertysethelper.hxx>
+#include <vcl/print.hxx>
+#include <oox/mathml/export.hxx>
+#include <oox/mathml/import.hxx>
+#include <memory>
+
+
+#define PRTUIOPT_TITLE_ROW "TitleRow"
+#define PRTUIOPT_FORMULA_TEXT "FormulaText"
+#define PRTUIOPT_BORDER "Border"
+#define PRTUIOPT_PRINT_FORMAT "PrintFormat"
+#define PRTUIOPT_PRINT_SCALE "PrintScale"
+
+class SmPrintUIOptions : public vcl::PrinterOptionsHelper
+{
+public:
+ SmPrintUIOptions();
+};
+
+
+class SmModel final : public SfxBaseModel,
+ public comphelper::PropertySetHelper,
+ public css::lang::XServiceInfo,
+ public css::view::XRenderable,
+ public oox::FormulaExportBase,
+ public oox::FormulaImportBase
+{
+ std::unique_ptr<SmPrintUIOptions> m_pPrintUIOptions;
+
+ virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const css::uno::Any* pValues ) override;
+ virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, css::uno::Any* pValue ) override;
+public:
+ explicit SmModel( SfxObjectShell *pObjSh );
+ virtual ~SmModel() throw () override;
+
+ //XInterface
+ virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
+ virtual void SAL_CALL acquire( ) throw() override;
+ virtual void SAL_CALL release( ) throw() override;
+
+ //XTypeProvider
+ virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
+
+ static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId();
+
+ //XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
+
+ //XRenderable
+ virtual sal_Int32 SAL_CALL getRendererCount( const css::uno::Any& rSelection, const css::uno::Sequence< css::beans::PropertyValue >& rxOptions ) override;
+ virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getRenderer( sal_Int32 nRenderer, const css::uno::Any& rSelection, const css::uno::Sequence< css::beans::PropertyValue >& rxOptions ) override;
+ virtual void SAL_CALL render( sal_Int32 nRenderer, const css::uno::Any& rSelection, const css::uno::Sequence< css::beans::PropertyValue >& rxOptions ) override;
+
+ //XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+ virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+
+ virtual void SAL_CALL setParent( const css::uno::Reference< css::uno::XInterface >& xParent ) override;
+
+ // oox::FormulaExportBase
+ virtual void writeFormulaOoxml(::sax_fastparser::FSHelperPtr pSerializer,
+ oox::core::OoxmlVersion version,
+ oox::drawingml::DocumentType documentType, sal_Int8 nAlign) override;
+ virtual void writeFormulaRtf(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding) override;
+ // oox::FormulaImportBase
+ virtual void readFormulaOoxml( oox::formulaimport::XmlStream& stream ) override;
+ virtual Size getFormulaSize() const override;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/utility.hxx b/starmath/inc/utility.hxx
new file mode 100644
index 000000000..2a462b98d
--- /dev/null
+++ b/starmath/inc/utility.hxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_UTILITY_HXX
+#define INCLUDED_STARMATH_INC_UTILITY_HXX
+
+#include <sal/config.h>
+
+#include <sal/log.hxx>
+#include <vcl/font.hxx>
+#include <vcl/weld.hxx>
+#include <tools/fract.hxx>
+#include <deque>
+
+inline long SmPtsTo100th_mm(long nNumPts)
+ // returns the length (in 100th of mm) that corresponds to the length
+ // 'nNumPts' (in units points).
+ // 72.27 [pt] = 1 [inch] = 2,54 [cm] = 2540 [100th of mm].
+ // result is being rounded to the nearest integer.
+{
+ SAL_WARN_IF( nNumPts < 0, "starmath", "Ooops..." );
+ // broken into multiple and fraction of 'nNumPts' to reduce chance
+ // of overflow
+ // (7227 / 2) is added in order to round to the nearest integer
+ return 35 * nNumPts + (nNumPts * 1055L + (7227 / 2)) / 7227L;
+}
+
+
+inline Fraction Sm100th_mmToPts(long nNum100th_mm)
+ // returns the length (in points) that corresponds to the length
+ // 'nNum100th_mm' (in 100th of mm).
+{
+ SAL_WARN_IF( nNum100th_mm < 0, "starmath", "Ooops..." );
+ return Fraction(7227L, 254000L) * Fraction(nNum100th_mm);
+}
+
+
+inline long SmRoundFraction(const Fraction &rFrac)
+{
+ SAL_WARN_IF( rFrac <= Fraction(), "starmath", "Ooops..." );
+ return (rFrac.GetNumerator() + rFrac.GetDenominator() / 2) / rFrac.GetDenominator();
+}
+
+
+class SmViewShell;
+SmViewShell * SmGetActiveView();
+
+
+// SmFace
+
+
+bool IsItalic( const vcl::Font &rFont );
+bool IsBold( const vcl::Font &rFont );
+
+class SmFace final : public vcl::Font
+{
+ long nBorderWidth;
+
+ void Impl_Init();
+
+public:
+ SmFace() :
+ Font(), nBorderWidth(-1) { Impl_Init(); }
+ SmFace(const Font& rFont) :
+ Font(rFont), nBorderWidth(-1) { Impl_Init(); }
+ SmFace(const OUString& rName, const Size& rSize) :
+ Font(rName, rSize), nBorderWidth(-1) { Impl_Init(); }
+
+ SmFace(const SmFace &rFace) :
+ Font(rFace), nBorderWidth(-1) { Impl_Init(); }
+
+ // overloaded version in order to supply a min value
+ // for font size (height). (Also used in ctor's to do so.)
+ void SetSize(const Size& rSize);
+
+ void SetBorderWidth(long nWidth) { nBorderWidth = nWidth; }
+ long GetBorderWidth() const;
+ long GetDefaultBorderWidth() const { return GetFontSize().Height() / 20 ; }
+ void FreezeBorderWidth() { nBorderWidth = GetDefaultBorderWidth(); }
+
+ SmFace & operator = (const SmFace &rFace);
+};
+
+SmFace & operator *= (SmFace &rFace, const Fraction &rFrac);
+
+
+// SmFontPickList
+
+
+class SmFontDialog;
+
+class SmFontPickList
+{
+protected:
+ sal_uInt16 nMaxItems;
+ std::deque<vcl::Font> aFontVec;
+
+public:
+ explicit SmFontPickList(sal_uInt16 nMax = 5) : nMaxItems(nMax) {}
+ virtual ~SmFontPickList() { Clear(); }
+
+ virtual void Insert(const vcl::Font &rFont);
+
+ void Clear();
+ vcl::Font Get(sal_uInt16 nPos = 0) const;
+
+ SmFontPickList& operator = (const SmFontPickList& rList);
+
+ void ReadFrom(const SmFontDialog& rDialog);
+ void WriteTo(SmFontDialog& rDialog) const;
+};
+
+
+// SmFontPickListBox
+
+
+class SmFontPickListBox final : public SmFontPickList
+{
+private:
+ std::unique_ptr<weld::ComboBox> m_xWidget;
+
+ DECL_LINK(SelectHdl, weld::ComboBox&, void);
+
+public:
+ SmFontPickListBox(std::unique_ptr<weld::ComboBox> pWidget);
+ SmFontPickListBox& operator = (const SmFontPickList& rList);
+ virtual void Insert(const vcl::Font &rFont) override;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
new file mode 100644
index 000000000..b3625b7dc
--- /dev/null
+++ b/starmath/inc/view.hxx
@@ -0,0 +1,319 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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 .
+ */
+#ifndef INCLUDED_STARMATH_INC_VIEW_HXX
+#define INCLUDED_STARMATH_INC_VIEW_HXX
+
+#include <sal/config.h>
+
+#include <memory>
+
+#include <rtl/ref.hxx>
+#include <sfx2/dockwin.hxx>
+#include <sfx2/viewsh.hxx>
+#include <svtools/scrwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <sfx2/shell.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/timer.hxx>
+#include "document.hxx"
+#include "edit.hxx"
+
+class SmViewShell;
+class SmPrintUIOptions;
+class SmGraphicAccessible;
+class SmNode;
+
+namespace svtools { class ColorConfig; }
+
+class SmGraphicWindow final : public ScrollableWindow
+{
+public:
+ bool IsCursorVisible() const
+ {
+ return bIsCursorVisible;
+ }
+ void ShowCursor(bool bShow);
+ bool IsLineVisible() const
+ {
+ return bIsLineVisible;
+ }
+ void ShowLine(bool bShow);
+ const SmNode * SetCursorPos(sal_uInt16 nRow, sal_uInt16 nCol);
+
+ explicit SmGraphicWindow(SmViewShell* pShell);
+ virtual ~SmGraphicWindow() override;
+ virtual void dispose() override;
+
+ // Window
+ virtual void ApplySettings(vcl::RenderContext&) override;
+ virtual void MouseButtonDown(const MouseEvent &rMEvt) override;
+ virtual void MouseMove(const MouseEvent &rMEvt) override;
+ virtual void GetFocus() override;
+ virtual void LoseFocus() override;
+
+ SmViewShell* GetView()
+ {
+ return pViewShell;
+ }
+
+ using Window::SetZoom;
+ void SetZoom(sal_uInt16 Factor);
+ using Window::GetZoom;
+ sal_uInt16 GetZoom() const
+ {
+ return nZoom;
+ }
+
+ const Point& GetFormulaDrawPos() const
+ {
+ return aFormulaDrawPos;
+ }
+
+ void ZoomToFitInWindow();
+ using ScrollableWindow::SetTotalSize;
+ void SetTotalSize();
+
+ // for Accessibility
+ virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
+
+ using Window::GetAccessible;
+ SmGraphicAccessible* GetAccessible_Impl()
+ {
+ return mxAccessible.get();
+ }
+
+private:
+ void SetIsCursorVisible(bool bVis)
+ {
+ bIsCursorVisible = bVis;
+ }
+ using Window::SetCursor;
+ void SetCursor(const SmNode *pNode);
+ void SetCursor(const tools::Rectangle &rRect);
+ bool IsInlineEditEnabled() const;
+
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
+ virtual void KeyInput(const KeyEvent& rKEvt) override;
+ virtual void Command(const CommandEvent& rCEvt) override;
+ virtual void StateChanged( StateChangedType eChanged ) override;
+
+ void RepaintViewShellDoc();
+ DECL_LINK(CaretBlinkTimerHdl, Timer *, void);
+ void CaretBlinkInit();
+ void CaretBlinkStart();
+ void CaretBlinkStop();
+
+ Point aFormulaDrawPos;
+ // old style editing pieces
+ tools::Rectangle aCursorRect;
+ bool bIsCursorVisible;
+ bool bIsLineVisible;
+ AutoTimer aCaretBlinkTimer;
+ rtl::Reference<SmGraphicAccessible> mxAccessible;
+ SmViewShell* pViewShell;
+ sal_uInt16 nZoom;
+};
+
+class SmGraphicController final : public SfxControllerItem
+{
+ SmGraphicWindow &rGraphic;
+public:
+ SmGraphicController(SmGraphicWindow &, sal_uInt16, SfxBindings & );
+ virtual void StateChanged(sal_uInt16 nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState) override;
+};
+
+class SmEditController final : public SfxControllerItem
+{
+ SmEditWindow &rEdit;
+
+public:
+ SmEditController(SmEditWindow &, sal_uInt16, SfxBindings & );
+
+ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) override;
+};
+
+class SmCmdBoxWindow : public SfxDockingWindow
+{
+ VclPtr<SmEditWindow> aEdit;
+ SmEditController aController;
+ bool bExiting;
+
+ Timer aInitialFocusTimer;
+
+ DECL_LINK(InitialFocusTimerHdl, Timer *, void);
+
+protected:
+
+ // Window
+ virtual void GetFocus() override;
+ virtual void Resize() override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+ virtual void StateChanged( StateChangedType nStateChange ) override;
+
+ virtual Size CalcDockingSize(SfxChildAlignment eAlign) override;
+ virtual SfxChildAlignment CheckAlignment(SfxChildAlignment eActual,
+ SfxChildAlignment eWish) override;
+
+ virtual void ToggleFloatingMode() override;
+
+public:
+ SmCmdBoxWindow(SfxBindings *pBindings,
+ SfxChildWindow *pChildWindow,
+ Window *pParent);
+
+ virtual ~SmCmdBoxWindow () override;
+ virtual void dispose() override;
+
+ void AdjustPosition();
+
+ SmEditWindow& GetEditWindow()
+ {
+ return *aEdit;
+ }
+ SmViewShell* GetView();
+};
+
+class SmCmdBoxWrapper final : public SfxChildWindow
+{
+ SFX_DECL_CHILDWINDOW_WITHID(SmCmdBoxWrapper);
+
+ SmCmdBoxWrapper(vcl::Window* pParentWindow, sal_uInt16 nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo);
+
+public:
+
+ SmEditWindow& GetEditWindow()
+ {
+ return static_cast<SmCmdBoxWindow *>(GetWindow())->GetEditWindow();
+ }
+};
+
+namespace sfx2 { class FileDialogHelper; }
+struct SmViewShell_Impl;
+
+class SmViewShell: public SfxViewShell
+{
+ std::unique_ptr<SmViewShell_Impl> mpImpl;
+
+ VclPtr<SmGraphicWindow> mpGraphic;
+ SmGraphicController maGraphicController;
+ OUString maStatusText;
+
+ bool mbPasteState;
+
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
+
+ /** Used to determine whether insertions using SID_INSERTSPECIAL and SID_INSERTCOMMANDTEXT
+ * should be inserted into SmEditWindow or directly into the SmDocShell as done if the
+ * visual editor was last to have focus.
+ */
+ bool mbInsertIntoEditWindow;
+protected:
+
+ static Size GetTextLineSize(OutputDevice const & rDevice,
+ const OUString& rLine);
+ static Size GetTextSize(OutputDevice const & rDevice,
+ const OUString& rText,
+ long MaxWidth);
+ static void DrawTextLine(OutputDevice& rDevice,
+ const Point& rPosition,
+ const OUString& rLine);
+ static void DrawText(OutputDevice& rDevice,
+ const Point& rPosition,
+ const OUString& rText,
+ sal_uInt16 MaxWidth);
+
+ virtual SfxPrinter *GetPrinter(bool bCreate = false) override;
+ virtual sal_uInt16 SetPrinter(SfxPrinter *pNewPrinter,
+ SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL) override;
+
+ void Insert( SfxMedium& rMedium );
+ void InsertFrom(SfxMedium &rMedium);
+
+ virtual bool HasPrintOptionsPage() const override;
+ virtual std::unique_ptr<SfxTabPage> CreatePrintOptionsPage(weld::Container* pPage, weld::DialogController* pController,
+ const SfxItemSet &rOptions) override;
+ virtual void Deactivate(bool IsMDIActivate) override;
+ virtual void Activate(bool IsMDIActivate) override;
+ virtual void InnerResizePixel(const Point &rOfs, const Size &rSize, bool inplaceEditModeChange) override;
+ virtual void OuterResizePixel(const Point &rOfs, const Size &rSize) override;
+ virtual void QueryObjAreaPixel( tools::Rectangle& rRect ) const override;
+ virtual void SetZoomFactor( const Fraction &rX, const Fraction &rY ) override;
+
+public:
+
+ SmViewShell(SfxViewFrame *pFrame, SfxViewShell *pOldSh);
+ virtual ~SmViewShell() override;
+
+ SmDocShell * GetDoc()
+ {
+ return static_cast<SmDocShell *>( GetViewFrame()->GetObjectShell() );
+ }
+
+ SmEditWindow * GetEditWindow();
+
+ SmGraphicWindow& GetGraphicWindow()
+ {
+ return *mpGraphic;
+ }
+ const SmGraphicWindow& GetGraphicWindow() const
+ {
+ return *mpGraphic;
+ }
+
+ void SetStatusText(const OUString& rText);
+
+ void ShowError( const SmErrorDesc *pErrorDesc );
+ void NextError();
+ void PrevError();
+
+ SFX_DECL_INTERFACE(SFX_INTERFACE_SMA_START+SfxInterfaceId(2))
+ SFX_DECL_VIEWFACTORY(SmViewShell);
+
+private:
+ /// SfxInterface initializer.
+ static void InitInterface_Impl();
+
+public:
+ void Execute( SfxRequest& rReq );
+ void GetState(SfxItemSet &);
+
+ void Impl_Print( OutputDevice &rOutDev, const SmPrintUIOptions &rPrintUIOptions,
+ tools::Rectangle aOutRect );
+
+ /** Set bInsertIntoEditWindow so we know where to insert
+ *
+ * This method is called whenever SmGraphicWindow or SmEditWindow gets focus,
+ * so that when text is inserted from catalog or elsewhere we know whether to
+ * insert for the visual editor, or the text editor.
+ */
+ void SetInsertIntoEditWindow(bool bEditWindowHadFocusLast){
+ mbInsertIntoEditWindow = bEditWindowHadFocusLast;
+ }
+ bool IsInlineEditEnabled() const;
+
+private:
+ void ZoomByItemSet(const SfxItemSet *pSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/inc/visitors.hxx b/starmath/inc/visitors.hxx
new file mode 100644
index 000000000..3f903aba8
--- /dev/null
+++ b/starmath/inc/visitors.hxx
@@ -0,0 +1,462 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#ifndef INCLUDED_STARMATH_INC_VISITORS_HXX
+#define INCLUDED_STARMATH_INC_VISITORS_HXX
+
+#include <sal/config.h>
+
+#include <sal/log.hxx>
+
+#include "node.hxx"
+#include "caret.hxx"
+#include <memory>
+
+/** Base class for visitors that visits a tree of SmNodes
+ * @remarks all methods have been left abstract to ensure that implementers
+ * don't forget to implement one.
+ */
+class SmVisitor
+{
+public:
+ virtual void Visit( SmTableNode* pNode ) = 0;
+ virtual void Visit( SmBraceNode* pNode ) = 0;
+ virtual void Visit( SmBracebodyNode* pNode ) = 0;
+ virtual void Visit( SmOperNode* pNode ) = 0;
+ virtual void Visit( SmAlignNode* pNode ) = 0;
+ virtual void Visit( SmAttributNode* pNode ) = 0;
+ virtual void Visit( SmFontNode* pNode ) = 0;
+ virtual void Visit( SmUnHorNode* pNode ) = 0;
+ virtual void Visit( SmBinHorNode* pNode ) = 0;
+ virtual void Visit( SmBinVerNode* pNode ) = 0;
+ virtual void Visit( SmBinDiagonalNode* pNode ) = 0;
+ virtual void Visit( SmSubSupNode* pNode ) = 0;
+ virtual void Visit( SmMatrixNode* pNode ) = 0;
+ virtual void Visit( SmPlaceNode* pNode ) = 0;
+ virtual void Visit( SmTextNode* pNode ) = 0;
+ virtual void Visit( SmSpecialNode* pNode ) = 0;
+ virtual void Visit( SmGlyphSpecialNode* pNode ) = 0;
+ virtual void Visit( SmMathSymbolNode* pNode ) = 0;
+ virtual void Visit( SmBlankNode* pNode ) = 0;
+ virtual void Visit( SmErrorNode* pNode ) = 0;
+ virtual void Visit( SmLineNode* pNode ) = 0;
+ virtual void Visit( SmExpressionNode* pNode ) = 0;
+ virtual void Visit( SmPolyLineNode* pNode ) = 0;
+ virtual void Visit( SmRootNode* pNode ) = 0;
+ virtual void Visit( SmRootSymbolNode* pNode ) = 0;
+ virtual void Visit( SmRectangleNode* pNode ) = 0;
+ virtual void Visit( SmVerticalBraceNode* pNode ) = 0;
+
+protected:
+ ~SmVisitor() {}
+};
+
+// SmDefaultingVisitor
+
+
+/** Visitor that uses DefaultVisit for handling visits by default
+ *
+ * This abstract baseclass is useful for visitors where many methods share the same
+ * implementation.
+ */
+class SmDefaultingVisitor : public SmVisitor
+{
+public:
+ void Visit( SmTableNode* pNode ) override;
+ void Visit( SmBraceNode* pNode ) override;
+ void Visit( SmBracebodyNode* pNode ) override;
+ void Visit( SmOperNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ void Visit( SmAttributNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmBinVerNode* pNode ) override;
+ void Visit( SmBinDiagonalNode* pNode ) override;
+ void Visit( SmSubSupNode* pNode ) override;
+ void Visit( SmMatrixNode* pNode ) override;
+ void Visit( SmPlaceNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmSpecialNode* pNode ) override;
+ void Visit( SmGlyphSpecialNode* pNode ) override;
+ void Visit( SmMathSymbolNode* pNode ) override;
+ void Visit( SmBlankNode* pNode ) override;
+ void Visit( SmErrorNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmPolyLineNode* pNode ) override;
+ void Visit( SmRootNode* pNode ) override;
+ void Visit( SmRootSymbolNode* pNode ) override;
+ void Visit( SmRectangleNode* pNode ) override;
+ void Visit( SmVerticalBraceNode* pNode ) override;
+protected:
+ ~SmDefaultingVisitor() {}
+
+ /** Method invoked by Visit methods by default */
+ virtual void DefaultVisit( SmNode* pNode ) = 0;
+};
+
+// SmCaretDrawingVisitor
+
+/** Visitor for drawing a caret position */
+class SmCaretDrawingVisitor final : public SmDefaultingVisitor
+{
+public:
+ /** Given position and device this constructor will draw the caret */
+ SmCaretDrawingVisitor( OutputDevice& rDevice, SmCaretPos position, Point offset, bool caretVisible );
+ virtual ~SmCaretDrawingVisitor() {}
+ void Visit( SmTextNode* pNode ) override;
+ using SmDefaultingVisitor::Visit;
+private:
+ OutputDevice &mrDev;
+ SmCaretPos maPos;
+ /** Offset to draw from */
+ Point maOffset;
+ bool mbCaretVisible;
+
+ /** Default method for drawing pNodes */
+ void DefaultVisit( SmNode* pNode ) override;
+};
+
+// SmCaretPos2LineVisitor
+
+/** Visitor getting a line from a caret position */
+class SmCaretPos2LineVisitor final : public SmDefaultingVisitor
+{
+public:
+ /** Given position and device this constructor will compute a line for the caret */
+ SmCaretPos2LineVisitor( OutputDevice *pDevice, SmCaretPos position )
+ : mpDev( pDevice )
+ , maPos( position )
+ {
+ SAL_WARN_IF( !position.IsValid(), "starmath", "Cannot draw invalid position!" );
+
+ maPos.pSelectedNode->Accept( this );
+ }
+ virtual ~SmCaretPos2LineVisitor() {}
+ void Visit( SmTextNode* pNode ) override;
+ using SmDefaultingVisitor::Visit;
+ const SmCaretLine& GetResult( ) const {
+ return maLine;
+ }
+private:
+ SmCaretLine maLine;
+ VclPtr<OutputDevice> mpDev;
+ SmCaretPos maPos;
+
+ /** Default method for computing lines for pNodes */
+ void DefaultVisit( SmNode* pNode ) override;
+};
+
+// SmDrawingVisitor
+
+/** Visitor for drawing SmNodes to OutputDevice */
+class SmDrawingVisitor final : public SmVisitor
+{
+public:
+ /** Create an instance of SmDrawingVisitor, and use it to draw a formula
+ * @param rDevice Device to draw on
+ * @param position Offset on device to draw the formula
+ * @param pTree Formula tree to draw
+ * @remarks This constructor will do the drawing, no need to anything more.
+ */
+ SmDrawingVisitor( OutputDevice &rDevice, Point position, SmNode* pTree )
+ : mrDev( rDevice )
+ , maPosition( position )
+ {
+ pTree->Accept( this );
+ }
+ virtual ~SmDrawingVisitor() {}
+ void Visit( SmTableNode* pNode ) override;
+ void Visit( SmBraceNode* pNode ) override;
+ void Visit( SmBracebodyNode* pNode ) override;
+ void Visit( SmOperNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ void Visit( SmAttributNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmBinVerNode* pNode ) override;
+ void Visit( SmBinDiagonalNode* pNode ) override;
+ void Visit( SmSubSupNode* pNode ) override;
+ void Visit( SmMatrixNode* pNode ) override;
+ void Visit( SmPlaceNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmSpecialNode* pNode ) override;
+ void Visit( SmGlyphSpecialNode* pNode ) override;
+ void Visit( SmMathSymbolNode* pNode ) override;
+ void Visit( SmBlankNode* pNode ) override;
+ void Visit( SmErrorNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmPolyLineNode* pNode ) override;
+ void Visit( SmRootNode* pNode ) override;
+ void Visit( SmRootSymbolNode* pNode ) override;
+ void Visit( SmRectangleNode* pNode ) override;
+ void Visit( SmVerticalBraceNode* pNode ) override;
+private:
+ /** Draw the children of a pNode
+ * This the default method, use by most pNodes
+ */
+ void DrawChildren( SmStructureNode* pNode );
+
+ /** Draw an SmTextNode or a subclass of this */
+ void DrawTextNode( SmTextNode* pNode );
+ /** Draw an SmSpecialNode or a subclass of this */
+ void DrawSpecialNode( SmSpecialNode* pNode );
+ /** OutputDevice to draw on */
+ OutputDevice& mrDev;
+ /** Position to draw on the mrDev
+ * @remarks This variable is used to pass parameters in DrawChildren( ), this means
+ that after a call to DrawChildren( ) the contents of this method is undefined
+ so if needed cache it locally on the stack.
+ */
+ Point maPosition;
+};
+
+// SmSetSelectionVisitor
+
+/** Set Selection Visitor
+ * Sets the IsSelected( ) property on all SmNodes of the tree
+ */
+class SmSetSelectionVisitor final : public SmDefaultingVisitor
+{
+public:
+ SmSetSelectionVisitor( SmCaretPos startPos, SmCaretPos endPos, SmNode* pNode);
+ virtual ~SmSetSelectionVisitor() {}
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ using SmDefaultingVisitor::Visit;
+ /** Set IsSelected on all pNodes of pSubTree */
+ static void SetSelectedOnAll( SmNode* pSubTree, bool IsSelected = true );
+private:
+ /** Visit a selectable pNode
+ * Can be used to handle pNodes that can be selected, that doesn't have more SmCaretPos'
+ * than 0 and 1 inside them. SmTextNode should be handle separately!
+ * Also note that pNodes such as SmBinVerNode cannot be selected, don't this method for
+ * it.
+ */
+ void DefaultVisit( SmNode* pNode ) override;
+ void VisitCompositionNode( SmStructureNode* pNode );
+ /** Caret position where the selection starts */
+ SmCaretPos maStartPos;
+ /** Caret position where the selection ends */
+ SmCaretPos maEndPos;
+ /** The current state of this visitor
+ * This property changes when the visitor meets either maStartPos
+ * or maEndPos. This means that anything visited in between will be
+ * selected.
+ */
+ bool mbSelecting;
+};
+
+
+// SmCaretPosGraphBuildingVisitor
+
+
+/** A visitor for building a SmCaretPosGraph
+ *
+ * Visit invariant:
+ * Each pNode, except SmExpressionNode, SmBinHorNode and a few others, constitutes an entry
+ * in a line. Consider the line entry "H", this entry creates one carat position, here
+ * denoted by | in "H|".
+ *
+ * Parameter variables:
+ * The following variables are used to transfer parameters into calls and results out
+ * of calls.
+ * pRightMost : SmCaretPosGraphEntry*
+ *
+ * Prior to a Visit call:
+ * pRightMost: A pointer to right most position in front of the current line entry.
+ *
+ * After a Visit call:
+ * pRightMost: A pointer to the right most position in the called line entry, if no there's
+ * no caret positions in called line entry don't change this variable.
+ */
+class SmCaretPosGraphBuildingVisitor final : public SmVisitor
+{
+public:
+ /** Builds a caret position graph for pRootNode */
+ explicit SmCaretPosGraphBuildingVisitor( SmNode* pRootNode );
+ virtual ~SmCaretPosGraphBuildingVisitor();
+ void Visit( SmTableNode* pNode ) override;
+ void Visit( SmBraceNode* pNode ) override;
+ void Visit( SmBracebodyNode* pNode ) override;
+ void Visit( SmOperNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ void Visit( SmAttributNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmBinVerNode* pNode ) override;
+ void Visit( SmBinDiagonalNode* pNode ) override;
+ void Visit( SmSubSupNode* pNode ) override;
+ void Visit( SmMatrixNode* pNode ) override;
+ void Visit( SmPlaceNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmSpecialNode* pNode ) override;
+ void Visit( SmGlyphSpecialNode* pNode ) override;
+ void Visit( SmMathSymbolNode* pNode ) override;
+ void Visit( SmBlankNode* pNode ) override;
+ void Visit( SmErrorNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmPolyLineNode* pNode ) override;
+ void Visit( SmRootNode* pNode ) override;
+ void Visit( SmRootSymbolNode* pNode ) override;
+ void Visit( SmRectangleNode* pNode ) override;
+ void Visit( SmVerticalBraceNode* pNode ) override;
+ SmCaretPosGraph* takeGraph()
+ {
+ return mpGraph.release();
+ }
+private:
+ SmCaretPosGraphEntry* mpRightMost;
+ std::unique_ptr<SmCaretPosGraph> mpGraph;
+};
+
+// SmCloningVisitor
+
+/** Visitor for cloning a pNode
+ *
+ * This visitor creates deep clones.
+ */
+class SmCloningVisitor final : public SmVisitor
+{
+public:
+ SmCloningVisitor()
+ : mpResult(nullptr)
+ {}
+ virtual ~SmCloningVisitor() {}
+ void Visit( SmTableNode* pNode ) override;
+ void Visit( SmBraceNode* pNode ) override;
+ void Visit( SmBracebodyNode* pNode ) override;
+ void Visit( SmOperNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ void Visit( SmAttributNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmBinVerNode* pNode ) override;
+ void Visit( SmBinDiagonalNode* pNode ) override;
+ void Visit( SmSubSupNode* pNode ) override;
+ void Visit( SmMatrixNode* pNode ) override;
+ void Visit( SmPlaceNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmSpecialNode* pNode ) override;
+ void Visit( SmGlyphSpecialNode* pNode ) override;
+ void Visit( SmMathSymbolNode* pNode ) override;
+ void Visit( SmBlankNode* pNode ) override;
+ void Visit( SmErrorNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmPolyLineNode* pNode ) override;
+ void Visit( SmRootNode* pNode ) override;
+ void Visit( SmRootSymbolNode* pNode ) override;
+ void Visit( SmRectangleNode* pNode ) override;
+ void Visit( SmVerticalBraceNode* pNode ) override;
+ /** Clone a pNode */
+ SmNode* Clone( SmNode* pNode );
+private:
+ SmNode* mpResult;
+ /** Clone children of pSource and give them to pTarget */
+ void CloneKids( SmStructureNode* pSource, SmStructureNode* pTarget );
+ /** Clone attributes on a pNode */
+ static void CloneNodeAttr( SmNode const * pSource, SmNode* pTarget );
+};
+
+
+// SmSelectionDrawingVisitor
+
+class SmSelectionDrawingVisitor final : public SmDefaultingVisitor
+{
+public:
+ /** Draws a selection on rDevice for the selection on pTree */
+ SmSelectionDrawingVisitor( OutputDevice& rDevice, SmNode* pTree, const Point& rOffset );
+ virtual ~SmSelectionDrawingVisitor() {}
+ void Visit( SmTextNode* pNode ) override;
+ using SmDefaultingVisitor::Visit;
+private:
+ /** Reference to drawing device */
+ OutputDevice& mrDev;
+ /** True if aSelectionArea have been initialized */
+ bool mbHasSelectionArea;
+ /** The current area that is selected */
+ tools::Rectangle maSelectionArea;
+ /** Extend the area that must be selected */
+ void ExtendSelectionArea(const tools::Rectangle& rArea);
+ /** Default visiting method */
+ void DefaultVisit( SmNode* pNode ) override;
+ /** Visit the children of a given pNode */
+ void VisitChildren( SmNode* pNode );
+};
+
+// SmNodeToTextVisitor
+
+/** Extract command text from pNodes */
+class SmNodeToTextVisitor final : public SmVisitor
+{
+public:
+ SmNodeToTextVisitor( SmNode* pNode, OUString &rText );
+ virtual ~SmNodeToTextVisitor() {}
+
+ void Visit( SmTableNode* pNode ) override;
+ void Visit( SmBraceNode* pNode ) override;
+ void Visit( SmBracebodyNode* pNode ) override;
+ void Visit( SmOperNode* pNode ) override;
+ void Visit( SmAlignNode* pNode ) override;
+ void Visit( SmAttributNode* pNode ) override;
+ void Visit( SmFontNode* pNode ) override;
+ void Visit( SmUnHorNode* pNode ) override;
+ void Visit( SmBinHorNode* pNode ) override;
+ void Visit( SmBinVerNode* pNode ) override;
+ void Visit( SmBinDiagonalNode* pNode ) override;
+ void Visit( SmSubSupNode* pNode ) override;
+ void Visit( SmMatrixNode* pNode ) override;
+ void Visit( SmPlaceNode* pNode ) override;
+ void Visit( SmTextNode* pNode ) override;
+ void Visit( SmSpecialNode* pNode ) override;
+ void Visit( SmGlyphSpecialNode* pNode ) override;
+ void Visit( SmMathSymbolNode* pNode ) override;
+ void Visit( SmBlankNode* pNode ) override;
+ void Visit( SmErrorNode* pNode ) override;
+ void Visit( SmLineNode* pNode ) override;
+ void Visit( SmExpressionNode* pNode ) override;
+ void Visit( SmPolyLineNode* pNode ) override;
+ void Visit( SmRootNode* pNode ) override;
+ void Visit( SmRootSymbolNode* pNode ) override;
+ void Visit( SmRectangleNode* pNode ) override;
+ void Visit( SmVerticalBraceNode* pNode ) override;
+private:
+ /** Extract text from a pNode that constitutes a line */
+ void LineToText( SmNode* pNode ) {
+ Separate( );
+ if( pNode )
+ pNode->Accept( this );
+ Separate( );
+ }
+ void Append( const OUString &rText ) {
+ maCmdText.append( rText );
+ }
+ /** Append a blank for separation, if needed */
+ void Separate( ){
+ if( maCmdText.isEmpty() || maCmdText[ maCmdText.getLength() - 1 ] != ' ' )
+ maCmdText.append(' ');
+ }
+ /** Output text generated from the pNodes */
+ OUStringBuffer maCmdText;
+};
+
+#endif // INCLUDED_STARMATH_INC_VISITORS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */