From 0108cd51faf942b3fc3a292522d4b2f421f1cf45 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Thu, 12 Nov 2020 13:17:39 +0100 Subject: tdf#123936 Formatting files in module starmath with clang-format Change-Id: I2b9e466d18ffd8033e5225d698b2dd0055e6fab7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105711 Tested-by: Jenkins Reviewed-by: Christian Lohmaier --- starmath/inc/action.hxx | 9 ++- starmath/inc/caret.hxx | 72 +++++++++++----------- starmath/inc/cursor.hxx | 80 +++++++++++++------------ starmath/inc/edit.hxx | 28 +++++---- starmath/inc/error.hxx | 5 +- starmath/inc/smdll.hxx | 2 +- starmath/inc/types.hxx | 13 ++-- starmath/qa/cppunit/test_cursor.cxx | 13 ++-- starmath/qa/cppunit/test_nodetotextvisitors.cxx | 66 ++++++++++---------- starmath/qa/unit/starmath-dialogs-test.cxx | 4 +- starmath/source/mathmlattr.cxx | 44 +++++++------- starmath/source/mathmlattr.hxx | 11 ++-- starmath/source/ooxmlexport.hxx | 26 ++++---- starmath/source/tmpdevice.hxx | 8 +-- 14 files changed, 198 insertions(+), 183 deletions(-) (limited to 'starmath') diff --git a/starmath/inc/action.hxx b/starmath/inc/action.hxx index cb4a4eddf740..8f98d12cf2a4 100644 --- a/starmath/inc/action.hxx +++ b/starmath/inc/action.hxx @@ -24,15 +24,14 @@ class SmDocShell; - class SmFormatAction final : public SfxUndoAction { - SmDocShell *pDoc; - SmFormat aOldFormat; - SmFormat aNewFormat; + SmDocShell* pDoc; + SmFormat aOldFormat; + SmFormat aNewFormat; public: - SmFormatAction(SmDocShell *pDocSh, const SmFormat& rOldFormat, const SmFormat& rNewFormat); + SmFormatAction(SmDocShell* pDocSh, const SmFormat& rOldFormat, const SmFormat& rNewFormat); virtual void Undo() override; virtual void Redo() override; diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx index bc69139994ee..6cc663206da4 100644 --- a/starmath/inc/caret.hxx +++ b/starmath/inc/caret.hxx @@ -18,7 +18,8 @@ #include /** Representation of caret position with an equation */ -struct SmCaretPos{ +struct SmCaretPos +{ SmCaretPos(SmNode* selectedNode = nullptr, int iIndex = 0) : pSelectedNode(selectedNode) , nIndex(iIndex) @@ -43,7 +44,8 @@ struct SmCaretPos{ /** True, if this is a valid caret position */ bool IsValid() const { return pSelectedNode != nullptr; } - bool operator==(const SmCaretPos &pos) const { + bool operator==(const SmCaretPos& pos) const + { return pos.pSelectedNode == pSelectedNode && nIndex == pos.nIndex; } /** Get the caret position after pNode, regardless of pNode @@ -51,48 +53,56 @@ struct SmCaretPos{ * 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) + static SmCaretPos GetPosAfter(SmNode* pNode) + { + if (pNode && pNode->GetType() == SmNodeType::Text) return SmCaretPos(pNode, static_cast(pNode)->GetText().getLength()); return SmCaretPos(pNode, 1); } }; /** A line that represents a caret */ -class SmCaretLine{ +class SmCaretLine +{ public: - SmCaretLine(tools::Long left = 0, tools::Long top = 0, tools::Long height = 0) { + SmCaretLine(tools::Long left = 0, tools::Long top = 0, tools::Long height = 0) + { _top = top; _left = left; _height = height; } - tools::Long GetTop() const {return _top;} - tools::Long GetLeft() const {return _left;} - tools::Long GetHeight() const {return _height;} - tools::Long SquaredDistanceX(const SmCaretLine& line) const{ + tools::Long GetTop() const { return _top; } + tools::Long GetLeft() const { return _left; } + tools::Long GetHeight() const { return _height; } + tools::Long SquaredDistanceX(const SmCaretLine& line) const + { return (GetLeft() - line.GetLeft()) * (GetLeft() - line.GetLeft()); } - tools::Long SquaredDistanceX(const Point &pos) const{ + tools::Long SquaredDistanceX(const Point& pos) const + { return (GetLeft() - pos.X()) * (GetLeft() - pos.X()); } - tools::Long SquaredDistanceY(const SmCaretLine& line) const{ + tools::Long SquaredDistanceY(const SmCaretLine& line) const + { tools::Long d = GetTop() - line.GetTop(); - if(d < 0) + if (d < 0) d = (d * -1) - GetHeight(); else d = d - line.GetHeight(); - if(d < 0) + if (d < 0) return 0; return d * d; } - tools::Long SquaredDistanceY(const Point &pos) const{ + tools::Long SquaredDistanceY(const Point& pos) const + { tools::Long d = GetTop() - pos.Y(); - if(d < 0) + if (d < 0) d = (d * -1) - GetHeight(); - if(d < 0) + if (d < 0) return 0; return d * d; } + private: tools::Long _top; tools::Long _left; @@ -102,11 +112,12 @@ private: // SmCaretPosGraph /** An entry in SmCaretPosGraph */ -struct SmCaretPosGraphEntry{ +struct SmCaretPosGraphEntry +{ SmCaretPosGraphEntry(SmCaretPos pos, SmCaretPosGraphEntry* left, SmCaretPosGraphEntry* right) - : CaretPos{pos} - , Left{left} - , Right{right} + : CaretPos{ pos } + , Left{ left } + , Right{ right } { } /** Caret position */ @@ -115,18 +126,15 @@ struct SmCaretPosGraphEntry{ SmCaretPosGraphEntry* Left; /** Entry to the right visually */ SmCaretPosGraphEntry* Right; - void SetRight(SmCaretPosGraphEntry* right){ - Right = right; - } - void SetLeft(SmCaretPosGraphEntry* left){ - Left = left; - } + 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{ +class SmCaretPosGraph +{ public: SmCaretPosGraph(); @@ -135,18 +143,14 @@ public: /** Add a caret position * @remarks If left is NULL, they will point back to the entry. */ - SmCaretPosGraphEntry* Add(SmCaretPos pos, - SmCaretPosGraphEntry* left = nullptr); + SmCaretPosGraphEntry* Add(SmCaretPos pos, SmCaretPosGraphEntry* left = nullptr); std::vector>::iterator begin() { return mvEntries.begin(); } - std::vector>::iterator end() - { - return mvEntries.end(); - } + std::vector>::iterator end() { return mvEntries.end(); } private: std::vector> mvEntries; diff --git a/starmath/inc/cursor.hxx b/starmath/inc/cursor.hxx index 47218e490865..a30beda63368 100644 --- a/starmath/inc/cursor.hxx +++ b/starmath/inc/cursor.hxx @@ -19,10 +19,11 @@ /** Factor to multiple the squared horizontal distance with * Used for Up and Down movement. */ -#define HORIZONTICAL_DISTANCE_FACTOR 10 +#define HORIZONTICAL_DISTANCE_FACTOR 10 /** Enum of direction for movement */ -enum SmMovementDirection{ +enum SmMovementDirection +{ MoveUp, MoveDown, MoveLeft, @@ -30,7 +31,8 @@ enum SmMovementDirection{ }; /** Enum of elements that can inserted into a formula */ -enum SmFormulaElement{ +enum SmFormulaElement +{ BlankElement, FactorialElement, PlusElement, @@ -43,7 +45,8 @@ enum SmFormulaElement{ }; /** Bracket types that can be inserted */ -enum class SmBracketType { +enum class SmBracketType +{ /** Round brackets, left command "(" */ Round, /**Square brackets, left command "[" */ @@ -65,7 +68,8 @@ class SmDocShell; * a formula programmatically. * @remarks This class is a very intimate friend of SmDocShell. */ -class SmCursor{ +class SmCursor +{ public: SmCursor(SmNode* tree, SmDocShell* pShell) : mpAnchor(nullptr) @@ -159,7 +163,8 @@ public: /** Copy the current selection */ void Copy(); /** Cut the current selection */ - void Cut(){ + void Cut() + { Copy(); Delete(); } @@ -189,8 +194,7 @@ public: private: friend class SmDocShell; - SmCaretPosGraphEntry *mpAnchor, - *mpPosition; + SmCaretPosGraphEntry *mpAnchor, *mpPosition; /** Formula tree */ SmNode* mpTree; /** Owner of the formula tree */ @@ -207,7 +211,7 @@ private: * * These are SmExpression, SmBinHorNode, SmUnHorNode etc. */ - static bool IsLineCompositionNode(SmNode const * pNode); + static bool IsLineCompositionNode(SmNode const* pNode); /** Count number of selected nodes, excluding line composition nodes * @@ -231,21 +235,24 @@ private: * 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){ + 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 + 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)){ + if (pNode && IsLineCompositionNode(pNode)) + { LineToList(static_cast(pNode), rList); return; } - if(pNode) + if (pNode) rList.push_front(pNode); } @@ -272,7 +279,7 @@ private: void AnnotateSelection(); /** Clone list of nodes in a clipboard (creates a deep clone) */ - static std::unique_ptr CloneList(SmClipboard &rClipboard); + static std::unique_ptr CloneList(SmClipboard& rClipboard); /** Find an iterator pointing to the node in pLineList following rCaretPos * @@ -299,7 +306,7 @@ private: * @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); + static SmCaretPos PatchLineList(SmNodeList* pLineList, SmNodeList::iterator aIter); /** Take selected nodes from a list * @@ -311,11 +318,11 @@ private: * * @returns An iterator pointing to the element following the selection taken. */ - static SmNodeList::iterator TakeSelectedNodesFromList(SmNodeList *pLineList, - SmNodeList *pSelectedNodes = nullptr); + static SmNodeList::iterator TakeSelectedNodesFromList(SmNodeList* pLineList, + SmNodeList* pSelectedNodes = nullptr); /** Create an instance of SmMathSymbolNode usable for brackets */ - static SmNode *CreateBracket(SmBracketType eBracketType, bool bIsLeft); + static SmNode* CreateBracket(SmBracketType eBracketType, bool bIsLeft); /** The number of times BeginEdit have been called * Used to allow nesting of BeginEdit() and EndEdit() sections @@ -342,11 +349,8 @@ private: * @param pStartLine Line to take first position in, if PosAfterEdit cannot be found, * leave it NULL for pLineList. */ - void FinishEdit(std::unique_ptr pLineList, - SmStructureNode* pParent, - int nParentIndex, - SmCaretPos PosAfterEdit, - SmNode* pStartLine = nullptr); + void FinishEdit(std::unique_ptr pLineList, SmStructureNode* pParent, + int nParentIndex, SmCaretPos PosAfterEdit, SmNode* pStartLine = nullptr); /** Request the formula is repainted */ void RequestRepaint(); }; @@ -369,44 +373,47 @@ private: * Postfix -> node [!]* * \endcode */ -class SmNodeListParser{ +class SmNodeListParser +{ public: /** Create an instance of SmNodeListParser */ - SmNodeListParser(){ - pList = nullptr; - } + 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); + static bool IsOperator(const SmToken& token); /** True, if the token is a relation operator */ - static bool IsRelationOperator(const SmToken &token); + static bool IsRelationOperator(const SmToken& token); /** True, if the token is a sum operator */ - static bool IsSumOperator(const SmToken &token); + static bool IsSumOperator(const SmToken& token); /** True, if the token is a product operator */ - static bool IsProductOperator(const SmToken &token); + static bool IsProductOperator(const SmToken& token); /** True, if the token is a unary operator */ - static bool IsUnaryOperator(const SmToken &token); + static bool IsUnaryOperator(const SmToken& token); /** True, if the token is a postfix operator */ - static bool IsPostfixOperator(const SmToken &token); + static bool IsPostfixOperator(const SmToken& token); + private: SmNodeList* pList; /** Get the current terminal */ - SmNode* Terminal(){ + SmNode* Terminal() + { if (!pList->empty()) return pList->front(); return nullptr; } /** Move to next terminal */ - SmNode* Next(){ + SmNode* Next() + { pList->pop_front(); return Terminal(); } /** Take the current terminal */ - SmNode* Take(){ + SmNode* Take() + { SmNode* pRetVal = Terminal(); Next(); return pRetVal; @@ -420,7 +427,6 @@ private: static SmNode* Error(); }; - #endif // INCLUDED_STARMATH_INC_CURSOR_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx index 421554834314..300a414d382b 100644 --- a/starmath/inc/edit.hxx +++ b/starmath/inc/edit.hxx @@ -38,9 +38,12 @@ class SmEditAccessible; class CommandEvent; class Timer; -namespace svtools { class ColorConfig; } +namespace svtools +{ +class ColorConfig; +} -void SmGetLeftSelectionPart(const ESelection &rSelection, sal_Int32 &nPara, sal_uInt16 &nPos); +void SmGetLeftSelectionPart(const ESelection& rSelection, sal_Int32& nPara, sal_uInt16& nPos); class SmEditWindow final : public vcl::Window, public DropTargetHelper { @@ -58,22 +61,22 @@ class SmEditWindow final : public vcl::Window, public DropTargetHelper virtual void KeyInput(const KeyEvent& rKEvt) override; virtual void Command(const CommandEvent& rCEvt) override; - DECL_LINK(ModifyTimerHdl, Timer *, void); - DECL_LINK(CursorMoveTimerHdl, Timer *, void); + DECL_LINK(ModifyTimerHdl, Timer*, void); + DECL_LINK(CursorMoveTimerHdl, Timer*, void); virtual void ApplySettings(vcl::RenderContext&) override; - virtual void DataChanged( const DataChangedEvent& ) 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 void MouseMove(const MouseEvent& rEvt) override; + virtual void MouseButtonUp(const MouseEvent& rEvt) override; + virtual void MouseButtonDown(const MouseEvent& rEvt) override; virtual OUString GetSurroundingText() const override; virtual Selection GetSurroundingTextSelection() const override; virtual bool DeleteSurroundingText(const Selection& rSelection) override; - virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; - virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& 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); @@ -114,10 +117,10 @@ public: void Delete(); void SelectAll(); void InsertText(const OUString& rText); - void MarkError(const Point &rPos); + void MarkError(const Point& rPos); void SelNextMark(); void SelPrevMark(); - static bool HasMark(const OUString &rText); + static bool HasMark(const OUString& rText); void Flush() override; void DeleteEditView(); @@ -132,7 +135,6 @@ public: using Window::GetAccessible; }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/error.hxx b/starmath/inc/error.hxx index bd2b7067a91c..dc798f6906e3 100644 --- a/starmath/inc/error.hxx +++ b/starmath/inc/error.hxx @@ -44,12 +44,11 @@ enum class SmParseError NumberExpected }; - struct SmErrorDesc { SmParseError m_eType; - SmNode *m_pNode; - OUString m_aText; + SmNode* m_pNode; + OUString m_aText; }; #endif diff --git a/starmath/inc/smdll.hxx b/starmath/inc/smdll.hxx index 3408f2fd4414..87e82702c5d9 100644 --- a/starmath/inc/smdll.hxx +++ b/starmath/inc/smdll.hxx @@ -23,7 +23,7 @@ namespace SmGlobals { - SM_DLLPUBLIC void ensure(); +SM_DLLPUBLIC void ensure(); } #endif diff --git a/starmath/inc/types.hxx b/starmath/inc/types.hxx index 56be51ee92b0..c3313a8a1d9d 100644 --- a/starmath/inc/types.hxx +++ b/starmath/inc/types.hxx @@ -21,11 +21,14 @@ #define INCLUDED_STARMATH_INC_TYPES_HXX #include -#define FONTNAME_MATH "OpenSymbol" - - -enum SmPrintSize { PRINT_SIZE_NORMAL, PRINT_SIZE_SCALED, PRINT_SIZE_ZOOMED }; - +#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!) diff --git a/starmath/qa/cppunit/test_cursor.cxx b/starmath/qa/cppunit/test_cursor.cxx index 8cf0bced8eb8..720a885be3a3 100644 --- a/starmath/qa/cppunit/test_cursor.cxx +++ b/starmath/qa/cppunit/test_cursor.cxx @@ -24,10 +24,10 @@ typedef tools::SvRef SmDocShellRef; using namespace ::com::sun::star; -namespace { - -class Test : public test::BootstrapFixture { - +namespace +{ +class Test : public test::BootstrapFixture +{ public: // init virtual void setUp() override; @@ -96,7 +96,7 @@ void Test::testCopySelectPaste() ScopedVclPtrInstance pOutputDevice; // go to the right end - for (int i=0;i<5;i++) + for (int i = 0; i < 5; i++) aCursor.Move(pOutputDevice, MoveRight); // select "b + c" and then copy aCursor.Move(pOutputDevice, MoveLeft, false); @@ -144,7 +144,7 @@ void Test::testCutSelectPaste() ScopedVclPtrInstance pOutputDevice; // go to the right end - for (int i=0;i<5;i++) + for (int i = 0; i < 5; i++) aCursor.Move(pOutputDevice, MoveRight); // select "b + c" and then cut aCursor.Move(pOutputDevice, MoveLeft, false); @@ -162,7 +162,6 @@ void Test::testCutSelectPaste() } CPPUNIT_TEST_SUITE_REGISTRATION(Test); - } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/qa/cppunit/test_nodetotextvisitors.cxx b/starmath/qa/cppunit/test_nodetotextvisitors.cxx index 72a78abaf1d5..70cc01512f92 100644 --- a/starmath/qa/cppunit/test_nodetotextvisitors.cxx +++ b/starmath/qa/cppunit/test_nodetotextvisitors.cxx @@ -26,10 +26,10 @@ typedef tools::SvRef SmDocShellRef; using namespace ::com::sun::star; -namespace { - -class Test : public test::BootstrapFixture { - +namespace +{ +class Test : public test::BootstrapFixture +{ public: // init virtual void setUp() override; @@ -78,9 +78,9 @@ public: private: SmDocShellRef xDocShRef; - void parseandparseagain(const char *input, const char *test_name); - void ParseAndCheck(const char *input, const char *expected, const char *test_name); - void ParseAndCompare(const char *formula1, const char *formula2, const char *test_name); + void parseandparseagain(const char* input, const char* test_name); + void ParseAndCheck(const char* input, const char* expected, const char* test_name); + void ParseAndCompare(const char* formula1, const char* formula2, const char* test_name); }; void Test::setUp() @@ -226,9 +226,13 @@ void Test::SimpleOperators() parseandparseagain("sum{a}", "Sum"); parseandparseagain("prod{a}", "Product"); parseandparseagain("coprod{a}", "Coproduct"); - parseandparseagain("int from {r_0} to {r_t} a", "Upper and lower bounds shown with integral (from & to)"); - ParseAndCheck("int csup {r_0} csub {r_t} a", "int csup { r _ 0 } csub { r _ t } a", "Upper and lower bounds shown with integral (csub & csup)"); - ParseAndCheck("sum csup { size 8 { x - 1 } } csub { size 8 a } b", "sum csup { size 8 { x - 1 } } csub { size 8 a } b", "Sum with sized upper and lower bounds"); + parseandparseagain("int from {r_0} to {r_t} a", + "Upper and lower bounds shown with integral (from & to)"); + ParseAndCheck("int csup {r_0} csub {r_t} a", "int csup { r _ 0 } csub { r _ t } a", + "Upper and lower bounds shown with integral (csub & csup)"); + ParseAndCheck("sum csup { size 8 { x - 1 } } csub { size 8 a } b", + "sum csup { size 8 { x - 1 } } csub { size 8 a } b", + "Sum with sized upper and lower bounds"); parseandparseagain("int{a}", "Integral"); parseandparseagain("intd_{1}^{2}{x dx}", "Dynamically-sized integral"); parseandparseagain("iint{a}", "Double integral"); @@ -345,8 +349,10 @@ void Test::SimpleFormats() parseandparseagain("binom{a}{b}", "Vertical stack of 2"); parseandparseagain("stack{a # b # z}", "Vertical stack, more than 2"); parseandparseagain("matrix{a # b ## c # d}", "Matrix"); - parseandparseagain("matrix{a # \"=\" # alignl{b} ## {} # \"=\" # alignl{c+1}}", "Equations aligned at '=' (using 'matrix') "); - parseandparseagain("stack{alignl{a} = b # alignl{phantom{a} = c+1}}", "Equations aligned at '=' (using 'phantom') "); + parseandparseagain("matrix{a # \"=\" # alignl{b} ## {} # \"=\" # alignl{c+1}}", + "Equations aligned at '=' (using 'matrix') "); + parseandparseagain("stack{alignl{a} = b # alignl{phantom{a} = c+1}}", + "Equations aligned at '=' (using 'phantom') "); parseandparseagain("asldkfjo newline sadkfj", "New line"); parseandparseagain("stuff `stuff", "Small gap (grave)"); parseandparseagain("stuff~stuff", "Large gap (tilde)"); @@ -430,7 +436,7 @@ void Test::SimpleSpecialChars() * Doing this doesn't prove that it is correct, but it should prove that the * meaning of the original command is not being changed. */ -void Test::parseandparseagain(const char *formula, const char *test_name) +void Test::parseandparseagain(const char* formula, const char* test_name) { OUString output1, output2; @@ -446,9 +452,7 @@ void Test::parseandparseagain(const char *formula, const char *test_name) SmNodeToTextVisitor(pNode2.get(), output2); // compare - CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, - output1, - output2); + CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, output1, output2); // auxiliary test for Accept() std::unique_ptr mv(new MockVisitor); @@ -456,7 +460,7 @@ void Test::parseandparseagain(const char *formula, const char *test_name) pNode2->Accept(mv.get()); } -void Test::ParseAndCheck(const char *formula, const char * expected, const char *test_name) +void Test::ParseAndCheck(const char* formula, const char* expected, const char* test_name) { OUString sOutput; @@ -468,9 +472,7 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char // compare OUString sExpected = OUString::createFromAscii(expected); - CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, - sExpected, - sOutput); + CPPUNIT_ASSERT_EQUAL_MESSAGE(test_name, sExpected, sOutput); // auxiliary test for Accept() std::unique_ptr mv(new MockVisitor); @@ -478,7 +480,7 @@ void Test::ParseAndCheck(const char *formula, const char * expected, const char } // Parse two formula commands and verify that they give the same output -void Test::ParseAndCompare(const char *formula1, const char *formula2, const char *test_name) +void Test::ParseAndCompare(const char* formula1, const char* formula2, const char* test_name) { OUString sOutput1, sOutput2; @@ -512,7 +514,7 @@ void Test::testBinomInBinHor() pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(pTree.get(), xDocShRef.get()); - ScopedVclPtrInstance< VirtualDevice > pOutputDevice; + ScopedVclPtrInstance pOutputDevice; // move forward (more than) enough places to be at the end int i; @@ -537,7 +539,7 @@ void Test::testBinVerInUnary() pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(pTree.get(), xDocShRef.get()); - ScopedVclPtrInstance< VirtualDevice > pOutputDevice; + ScopedVclPtrInstance pOutputDevice; // move forward (more than) enough places to be at the end int i; @@ -552,7 +554,8 @@ void Test::testBinVerInUnary() aCursor.InsertText("2"); sExpected += "- { 1 over 2 }"; - CPPUNIT_ASSERT_EQUAL_MESSAGE("Binary Vertical in Unary Operator", sExpected, xDocShRef->GetText()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Binary Vertical in Unary Operator", sExpected, + xDocShRef->GetText()); } void Test::testBinHorInSubSup() @@ -562,7 +565,7 @@ void Test::testBinHorInSubSup() pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(pTree.get(), xDocShRef.get()); - ScopedVclPtrInstance< VirtualDevice > pOutputDevice; + ScopedVclPtrInstance pOutputDevice; // Insert an RSup expression with a BinHor for the exponent aCursor.InsertText("a"); @@ -576,7 +579,8 @@ void Test::testBinHorInSubSup() aCursor.InsertElement(PlusElement); aCursor.InsertText("d"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("BinHor in SubSup", OUString("{ a ^ { b + c } + d }"), xDocShRef->GetText()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("BinHor in SubSup", OUString("{ a ^ { b + c } + d }"), + xDocShRef->GetText()); } void Test::testUnaryInMixedNumberAsNumerator() @@ -586,7 +590,7 @@ void Test::testUnaryInMixedNumberAsNumerator() pTree->Prepare(xDocShRef->GetFormat(), *xDocShRef, 0); SmCursor aCursor(pTree.get(), xDocShRef.get()); - ScopedVclPtrInstance< VirtualDevice > pOutputDevice; + ScopedVclPtrInstance pOutputDevice; // move forward (more than) enough places to be at the end for (size_t i = 0; i < 3; ++i) @@ -615,7 +619,8 @@ void Test::testUnaryInMixedNumberAsNumerator() aCursor.InsertElement(PlusElement); aCursor.InsertText("4"); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unary in mixed number as Numerator", OUString("{ 2 { - 1 over 2 } + 4 }"), xDocShRef->GetText()); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unary in mixed number as Numerator", + OUString("{ 2 { - 1 over 2 } + 4 }"), xDocShRef->GetText()); } void Test::testMiscEquivalent() @@ -637,7 +642,8 @@ void Test::testMiscEquivalent() ParseAndCompare("{ \xf0\x9d\x91\x8e }", "\xf0\x9d\x91\x8e", "non-BMP variable in brace"); // tdf#88320 - ParseAndCompare("A_1,B_2", "A_{1},B_2", "Comma between a digit and non-digit delimits subscript"); + ParseAndCompare("A_1,B_2", "A_{1},B_2", + "Comma between a digit and non-digit delimits subscript"); //tdf#97164 ParseAndCompare("100 %", "100\"%\"", "Percent symbol at the end"); @@ -653,8 +659,6 @@ void Test::testParser() } CPPUNIT_TEST_SUITE_REGISTRATION(Test); - } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/qa/unit/starmath-dialogs-test.cxx b/starmath/qa/unit/starmath-dialogs-test.cxx index 42e6ef45cdee..e0e45c606cbb 100644 --- a/starmath/qa/unit/starmath-dialogs-test.cxx +++ b/starmath/qa/unit/starmath-dialogs-test.cxx @@ -36,9 +36,7 @@ public: CPPUNIT_TEST_SUITE_END(); }; -StarmathDialogsTest::StarmathDialogsTest() -{ -} +StarmathDialogsTest::StarmathDialogsTest() {} void StarmathDialogsTest::registerKnownDialogsByID(mapType& /*rKnownDialogs*/) { diff --git a/starmath/source/mathmlattr.cxx b/starmath/source/mathmlattr.cxx index 5e3f09df9f9e..b2a3f2453ec5 100644 --- a/starmath/source/mathmlattr.cxx +++ b/starmath/source/mathmlattr.cxx @@ -11,7 +11,7 @@ #include -static sal_Int32 ParseMathMLUnsignedNumber(const OUString &rStr, Fraction& rUN) +static sal_Int32 ParseMathMLUnsignedNumber(const OUString& rStr, Fraction& rUN) { auto nLen = rStr.getLength(); sal_Int32 nDecimalPoint = -1; @@ -37,7 +37,7 @@ static sal_Int32 ParseMathMLUnsignedNumber(const OUString &rStr, Fraction& rUN) return nIdx; } -static sal_Int32 ParseMathMLNumber(const OUString &rStr, Fraction& rN) +static sal_Int32 ParseMathMLNumber(const OUString& rStr, Fraction& rN) { if (rStr.isEmpty()) return -1; @@ -51,7 +51,7 @@ static sal_Int32 ParseMathMLNumber(const OUString &rStr, Fraction& rN) return nOffset + nIdx; } -sal_Int32 ParseMathMLAttributeLengthValue(const OUString &rStr, MathMLAttributeLengthValue& rV) +sal_Int32 ParseMathMLAttributeLengthValue(const OUString& rStr, MathMLAttributeLengthValue& rV) { auto nIdx = ParseMathMLNumber(rStr, rV.aNumber); if (nIdx <= 0) @@ -110,27 +110,27 @@ sal_Int32 ParseMathMLAttributeLengthValue(const OUString &rStr, MathMLAttributeL return nIdx; } -bool GetMathMLMathvariantValue(const OUString &rStr, MathMLMathvariantValue& rV) +bool GetMathMLMathvariantValue(const OUString& rStr, MathMLMathvariantValue& rV) { static const std::unordered_map aMap{ - {"normal", MathMLMathvariantValue::Normal}, - {"bold", MathMLMathvariantValue::Bold}, - {"italic", MathMLMathvariantValue::Italic}, - {"bold-italic", MathMLMathvariantValue::BoldItalic}, - {"double-struck", MathMLMathvariantValue::DoubleStruck}, - {"bold-fraktur", MathMLMathvariantValue::BoldFraktur}, - {"script", MathMLMathvariantValue::Script}, - {"bold-script", MathMLMathvariantValue::BoldScript}, - {"fraktur", MathMLMathvariantValue::Fraktur}, - {"sans-serif", MathMLMathvariantValue::SansSerif}, - {"bold-sans-serif", MathMLMathvariantValue::BoldSansSerif}, - {"sans-serif-italic", MathMLMathvariantValue::SansSerifItalic}, - {"sans-serif-bold-italic", MathMLMathvariantValue::SansSerifBoldItalic}, - {"monospace", MathMLMathvariantValue::Monospace}, - {"initial", MathMLMathvariantValue::Initial}, - {"tailed", MathMLMathvariantValue::Tailed}, - {"looped", MathMLMathvariantValue::Looped}, - {"stretched", MathMLMathvariantValue::Stretched} + { "normal", MathMLMathvariantValue::Normal }, + { "bold", MathMLMathvariantValue::Bold }, + { "italic", MathMLMathvariantValue::Italic }, + { "bold-italic", MathMLMathvariantValue::BoldItalic }, + { "double-struck", MathMLMathvariantValue::DoubleStruck }, + { "bold-fraktur", MathMLMathvariantValue::BoldFraktur }, + { "script", MathMLMathvariantValue::Script }, + { "bold-script", MathMLMathvariantValue::BoldScript }, + { "fraktur", MathMLMathvariantValue::Fraktur }, + { "sans-serif", MathMLMathvariantValue::SansSerif }, + { "bold-sans-serif", MathMLMathvariantValue::BoldSansSerif }, + { "sans-serif-italic", MathMLMathvariantValue::SansSerifItalic }, + { "sans-serif-bold-italic", MathMLMathvariantValue::SansSerifBoldItalic }, + { "monospace", MathMLMathvariantValue::Monospace }, + { "initial", MathMLMathvariantValue::Initial }, + { "tailed", MathMLMathvariantValue::Tailed }, + { "looped", MathMLMathvariantValue::Looped }, + { "stretched", MathMLMathvariantValue::Stretched } }; auto it = aMap.find(rStr); diff --git a/starmath/source/mathmlattr.hxx b/starmath/source/mathmlattr.hxx index 232e080e65dc..104495d2c878 100644 --- a/starmath/source/mathmlattr.hxx +++ b/starmath/source/mathmlattr.hxx @@ -21,7 +21,8 @@ // MathML 3: 2.1.5.2 Length Valued Attributes // -enum class MathMLLengthUnit { +enum class MathMLLengthUnit +{ None, Em, Ex, @@ -44,13 +45,13 @@ struct MathMLAttributeLengthValue } }; -sal_Int32 ParseMathMLAttributeLengthValue(const OUString &rStr, MathMLAttributeLengthValue& rV); - +sal_Int32 ParseMathMLAttributeLengthValue(const OUString& rStr, MathMLAttributeLengthValue& rV); // MathML 3: 3.2.2 Mathematics style attributes common to token elements // -enum class MathMLMathvariantValue { +enum class MathMLMathvariantValue +{ Normal, Bold, Italic, @@ -71,7 +72,7 @@ enum class MathMLMathvariantValue { Stretched }; -bool GetMathMLMathvariantValue(const OUString &rStr, MathMLMathvariantValue& rV); +bool GetMathMLMathvariantValue(const OUString& rStr, MathMLMathvariantValue& rV); #endif diff --git a/starmath/source/ooxmlexport.hxx b/starmath/source/ooxmlexport.hxx index fec33ab8e37b..e5973210b331 100644 --- a/starmath/source/ooxmlexport.hxx +++ b/starmath/source/ooxmlexport.hxx @@ -23,19 +23,20 @@ class SmOoxmlExport : public SmWordExportBase { public: SmOoxmlExport(const SmNode* pIn, oox::core::OoxmlVersion version, - oox::drawingml::DocumentType documentType); - void ConvertFromStarMath( const ::sax_fastparser::FSHelperPtr& m_pSerializer, const sal_Int8 ); + oox::drawingml::DocumentType documentType); + void ConvertFromStarMath(const ::sax_fastparser::FSHelperPtr& m_pSerializer, const sal_Int8); + private: - void HandleVerticalStack( const SmNode* pNode, int nLevel ) override; - void HandleText( const SmNode* pNode, int nLevel ) override; - void HandleFractions( const SmNode* pNode, int nLevel, const char* type ) override; - void HandleRoot( const SmRootNode* pNode, int nLevel ) override; - void HandleAttribute( const SmAttributNode* pNode, int nLevel ) override; - void HandleOperator( const SmOperNode* pNode, int nLevel ) override; - void HandleSubSupScriptInternal( const SmSubSupNode* pNode, int nLevel, int flags ) override; - void HandleMatrix( const SmMatrixNode* pNode, int nLevel ) override; - void HandleBrace( const SmBraceNode* pNode, int nLevel ) override; - void HandleVerticalBrace( const SmVerticalBraceNode* pNode, int nLevel ) override; + void HandleVerticalStack(const SmNode* pNode, int nLevel) override; + void HandleText(const SmNode* pNode, int nLevel) override; + void HandleFractions(const SmNode* pNode, int nLevel, const char* type) override; + void HandleRoot(const SmRootNode* pNode, int nLevel) override; + void HandleAttribute(const SmAttributNode* pNode, int nLevel) override; + void HandleOperator(const SmOperNode* pNode, int nLevel) override; + void HandleSubSupScriptInternal(const SmSubSupNode* pNode, int nLevel, int flags) override; + void HandleMatrix(const SmMatrixNode* pNode, int nLevel) override; + void HandleBrace(const SmBraceNode* pNode, int nLevel) override; + void HandleVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel) override; void HandleBlank() override; ::sax_fastparser::FSHelperPtr m_pSerializer; oox::core::OoxmlVersion version; @@ -43,7 +44,6 @@ private: oox::drawingml::DocumentType const m_DocumentType; }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/tmpdevice.hxx b/starmath/source/tmpdevice.hxx index e7c812cd69f4..8fa3557cd89d 100644 --- a/starmath/source/tmpdevice.hxx +++ b/starmath/source/tmpdevice.hxx @@ -25,7 +25,7 @@ class SmTmpDevice { - OutputDevice &rOutDev; + OutputDevice& rOutDev; SmTmpDevice(const SmTmpDevice&) = delete; SmTmpDevice& operator=(const SmTmpDevice&) = delete; @@ -33,15 +33,15 @@ class SmTmpDevice Color GetTextColor(const Color& rTextColor); public: - SmTmpDevice(OutputDevice &rTheDev, bool bUseMap100th_mm); + SmTmpDevice(OutputDevice& rTheDev, bool bUseMap100th_mm); ~SmTmpDevice() COVERITY_NOEXCEPT_FALSE { rOutDev.Pop(); } - void SetFont(const vcl::Font &rNewFont); + void SetFont(const vcl::Font& rNewFont); void SetLineColor(const Color& rColor) { rOutDev.SetLineColor(GetTextColor(rColor)); } void SetFillColor(const Color& rColor) { rOutDev.SetFillColor(GetTextColor(rColor)); } - operator OutputDevice & () { return rOutDev; } + operator OutputDevice&() { return rOutDev; } }; #endif -- cgit