String -> OUString

Change-Id: I9d86ea5b27e8b8db75bf7a2ea9965621c857adb7
This commit is contained in:
Ivan Timofeev 2012-10-29 19:15:56 +04:00
parent f5d972265a
commit a3d9253615
5 changed files with 37 additions and 31 deletions

View file

@ -96,7 +96,7 @@ class SmDocShell : public SfxObjectShell, public SfxListener
String aText;
SmFormat aFormat;
SmParser aInterpreter;
String aAccText;
OUString aAccText;
SmNode *pTree;
SfxMenuBarManager *pMenuMgr;
SfxItemPool *pEditEngineItemPool;
@ -198,7 +198,7 @@ public:
const std::set< rtl::OUString > & GetUsedSymbols() const { return aUsedSymbols; }
String GetAccessibleText();
OUString GetAccessibleText();
EditEngine & GetEditEngine();
SfxItemPool & GetEditEngineItemPool();

View file

@ -156,7 +156,7 @@ public:
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
virtual void CreateTextFromNode(String &rText);
virtual void GetAccessibleText( String &rText ) const;
virtual void GetAccessibleText( OUStringBuffer &rText ) const;
sal_Int32 GetAccessibleIndex() const { return nAccIndex; }
const SmNode * FindNodeWithAccessibleIndex(xub_StrLen nAccIndex) const;
@ -324,7 +324,7 @@ public:
SmStructureNode & operator = ( const SmStructureNode &rNode );
virtual void GetAccessibleText( String &rText ) const;
virtual void GetAccessibleText( OUStringBuffer &rText ) const;
void SetSubNode(size_t nIndex, SmNode* pNode)
{
@ -378,7 +378,7 @@ protected:
public:
virtual void GetAccessibleText( String &rText ) const;
virtual void GetAccessibleText( OUStringBuffer &rText ) const;
};
@ -490,7 +490,7 @@ public:
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
virtual void CreateTextFromNode(String &rText);
virtual void GetAccessibleText( String &rText ) const;
virtual void GetAccessibleText( OUStringBuffer &rText ) const;
void Accept(SmVisitor* pVisitor);
/**
Converts the character from StarMath's private area symbols to a matching Unicode

View file

@ -514,10 +514,11 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
OSL_ENSURE( nAccIndex >= 0, "invalid accessible index" );
OSL_ENSURE( nIndex >= nAccIndex, "index out of range" );
String aNodeText;
pNode->GetAccessibleText( aNodeText );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aNodeText = aBuf.makeStringAndClear();
sal_Int32 nNodeIndex = nIndex - nAccIndex;
if (0 <= nNodeIndex && nNodeIndex < aNodeText.Len())
if (0 <= nNodeIndex && nNodeIndex < aNodeText.getLength())
{
// get appropriate rectangle
Point aOffset(pNode->GetTopLeft() - pTree->GetTopLeft());
@ -525,9 +526,9 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
aTLPos.X() -= 0;
Size aSize (pNode->GetSize());
sal_Int32 *pXAry = new sal_Int32[ aNodeText.Len() ];
sal_Int32 *pXAry = new sal_Int32[ aNodeText.getLength() ];
pWin->SetFont( pNode->GetFont() );
pWin->GetTextArray( aNodeText, pXAry, 0, aNodeText.Len() );
pWin->GetTextArray( aNodeText, pXAry, 0, aNodeText.getLength() );
aTLPos.X() += nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0;
aSize.Width() = nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex];
delete[] pXAry;
@ -600,22 +601,23 @@ sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoin
if (aRect.IsInside( aPos ))
{
OSL_ENSURE( pNode->IsVisible(), "node is not a leaf" );
String aTxt;
pNode->GetAccessibleText( aTxt );
OSL_ENSURE( aTxt.Len(), "no accessible text available" );
OUStringBuffer aBuf;
pNode->GetAccessibleText(aBuf);
OUString aTxt = aBuf.makeStringAndClear();
OSL_ENSURE( !aTxt.isEmpty(), "no accessible text available" );
long nNodeX = pNode->GetLeft();
sal_Int32 *pXAry = new sal_Int32[ aTxt.Len() ];
sal_Int32 *pXAry = new sal_Int32[ aTxt.getLength() ];
pWin->SetFont( pNode->GetFont() );
pWin->GetTextArray( aTxt, pXAry, 0, aTxt.Len() );
for (sal_Int32 i = 0; i < aTxt.Len() && nRes == -1; ++i)
pWin->GetTextArray( aTxt, pXAry, 0, aTxt.getLength() );
for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
{
if (pXAry[i] + nNodeX > aPos.X())
nRes = i;
}
delete[] pXAry;
OSL_ENSURE( nRes >= 0 && nRes < aTxt.Len(), "index out of range" );
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
"invalid accessible index" );

View file

@ -224,17 +224,21 @@ void SmDocShell::SetFormat(SmFormat& rFormat)
}
}
String SmDocShell::GetAccessibleText()
OUString SmDocShell::GetAccessibleText()
{
RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetAccessibleText" );
if (!IsFormulaArranged())
ArrangeFormula();
if (0 == aAccText.Len())
if (aAccText.isEmpty())
{
OSL_ENSURE( pTree, "Tree missing" );
if (pTree)
pTree->GetAccessibleText( aAccText );
{
OUStringBuffer aBuf;
pTree->GetAccessibleText(aBuf);
aAccText = aBuf.makeStringAndClear();
}
}
return aAccText;
}
@ -306,7 +310,7 @@ void SmDocShell::ArrangeFormula()
SetFormulaArranged(true);
// invalidate accessible text
aAccText = String();
aAccText = OUString();
}

View file

@ -520,7 +520,7 @@ const SmNode * SmNode::FindRectClosestTo(const Point &rPoint) const
return pResult;
}
void SmNode::GetAccessibleText( String &/*rText*/ ) const
void SmNode::GetAccessibleText( OUStringBuffer &/*rText*/ ) const
{
OSL_FAIL( "SmNode: GetAccessibleText not overloaded" );
}
@ -530,12 +530,12 @@ const SmNode * SmNode::FindNodeWithAccessibleIndex(xub_StrLen nAccIdx) const
const SmNode *pResult = 0;
sal_Int32 nIdx = GetAccessibleIndex();
String aTxt;
OUStringBuffer aTxt;
if (nIdx >= 0)
GetAccessibleText( aTxt ); // get text if used in following 'if' statement
if (nIdx >= 0
&& nIdx <= nAccIdx && nAccIdx < nIdx + aTxt.Len())
&& nIdx <= nAccIdx && nAccIdx < nIdx + aTxt.getLength())
pResult = this;
else
{
@ -749,7 +749,7 @@ SmNode * SmStructureNode::GetSubNode(sal_uInt16 nIndex)
}
void SmStructureNode::GetAccessibleText( String &rText ) const
void SmStructureNode::GetAccessibleText( OUStringBuffer &rText ) const
{
sal_uInt16 nNodes = GetNumSubNodes();
for (sal_uInt16 i = 0; i < nNodes; ++i)
@ -758,7 +758,7 @@ void SmStructureNode::GetAccessibleText( String &rText ) const
if (pNode)
{
if (pNode->IsVisible())
((SmStructureNode *) pNode)->nAccIndex = rText.Len();
((SmStructureNode *) pNode)->nAccIndex = rText.getLength();
pNode->GetAccessibleText( rText );
}
}
@ -787,9 +787,9 @@ SmNode * SmVisibleNode::GetSubNode(sal_uInt16 /*nIndex*/)
///////////////////////////////////////////////////////////////////////////
void SmGraphicNode::GetAccessibleText( String &rText ) const
void SmGraphicNode::GetAccessibleText( OUStringBuffer &rText ) const
{
rText += GetToken().aText;
rText.append(GetToken().aText);
}
///////////////////////////////////////////////////////////////////////////
@ -2440,9 +2440,9 @@ void SmTextNode::CreateTextFromNode(String &rText)
}
void SmTextNode::GetAccessibleText( String &rText ) const
void SmTextNode::GetAccessibleText( OUStringBuffer &rText ) const
{
rText += aText;
rText.append(aText);
}
void SmTextNode::AdjustFontDesc()