summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorMathias Bauer <mba@openoffice.org>2010-11-26 15:27:38 +0100
committerMathias Bauer <mba@openoffice.org>2010-11-26 15:27:38 +0100
commit112bfeec9530b05f3fbcfb1bddb6a9653451bef6 (patch)
tree3cea3dfd64568d620b0e519d1509c321e815bd1c /starmath
parent2bc737661a2c673bd7adfba299ceee02fcab627b (diff)
parentf1dc19695c083ec5f1356a2c082f2c4feb53aa33 (diff)
CWS gnumake2: resync to m94
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/node.hxx8
-rw-r--r--starmath/source/cfgitem.cxx80
-rw-r--r--starmath/source/cfgitem.hxx16
-rw-r--r--starmath/source/document.cxx9
-rwxr-xr-xstarmath/source/node.cxx67
-rwxr-xr-xstarmath/source/unomodel.cxx21
6 files changed, 132 insertions, 69 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 92c9d4621292..e2a21238064d 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -180,6 +180,10 @@ public:
const SmNode * FindTokenAt(USHORT nRow, USHORT nCol) const;
const SmNode * FindRectClosestTo(const Point &rPoint) const;
+
+ // --> 4.7.2010 #i972#
+ virtual long GetFormulaBaseline() const;
+ // <--
};
@@ -456,6 +460,9 @@ public:
class SmTableNode : public SmStructureNode
{
+ // --> 4.7.2010 #i972#
+ long nFormulaBaseline;
+ // <--
public:
SmTableNode(const SmToken &rNodeToken)
: SmStructureNode(NTABLE, rNodeToken)
@@ -465,6 +472,7 @@ public:
virtual SmNode * GetLeftMost();
virtual void Arrange(const OutputDevice &rDev, const SmFormat &rFormat);
+ virtual long GetFormulaBaseline() const;
};
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index 21ae6c0e63df..c8db4720b943 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -48,8 +48,6 @@ static const char* aRootName = "Office.Math";
#define SYMBOL_LIST "SymbolList"
#define FONT_FORMAT_LIST "FontFormatList"
-SV_IMPL_OBJARR( SmFntFmtListEntryArr, SmFntFmtListEntry );
-
/////////////////////////////////////////////////////////////////
@@ -294,10 +292,9 @@ SmFontFormatList::SmFontFormatList()
void SmFontFormatList::Clear()
{
- USHORT nCnt = aEntries.Count();
- if (nCnt)
+ if (!aEntries.empty())
{
- aEntries.Remove( 0, nCnt );
+ aEntries.clear();
SetModified( TRUE );
}
}
@@ -311,7 +308,7 @@ void SmFontFormatList::AddFontFormat( const String &rFntFmtId,
if (!pFntFmt)
{
SmFntFmtListEntry aEntry( rFntFmtId, rFntFmt );
- aEntries.Insert( aEntry, aEntries.Count() );
+ aEntries.push_back( aEntry );
SetModified( TRUE );
}
}
@@ -319,35 +316,32 @@ void SmFontFormatList::AddFontFormat( const String &rFntFmtId,
void SmFontFormatList::RemoveFontFormat( const String &rFntFmtId )
{
- USHORT nPos = 0xFFFF;
// search for entry
- USHORT nCnt = aEntries.Count();
- for (USHORT i = 0; i < nCnt && nPos == 0xFFFF; ++i)
+ for (size_t i = 0; i < aEntries.size(); ++i)
{
if (aEntries[i].aId == rFntFmtId)
- nPos = i;
- }
-
- // remove entry if found
- if (nPos != 0xFFFF)
- {
- aEntries.Remove( nPos );
- SetModified( TRUE );
+ {
+ // remove entry if found
+ aEntries.erase( aEntries.begin() + i );
+ SetModified( TRUE );
+ break;
+ }
}
}
const SmFontFormat * SmFontFormatList::GetFontFormat( const String &rFntFmtId ) const
{
- SmFontFormat *pRes = 0;
+ const SmFontFormat *pRes = 0;
- USHORT nCnt = aEntries.Count();
- USHORT i;
- for (i = 0; i < nCnt && !pRes; ++i)
+ for (size_t i = 0; i < aEntries.size(); ++i)
{
if (aEntries[i].aId == rFntFmtId)
+ {
pRes = &aEntries[i].aFntFmt;
+ break;
+ }
}
return pRes;
@@ -355,11 +349,11 @@ const SmFontFormat * SmFontFormatList::GetFontFormat( const String &rFntFmtId )
-const SmFontFormat * SmFontFormatList::GetFontFormat( USHORT nPos ) const
+const SmFontFormat * SmFontFormatList::GetFontFormat( size_t nPos ) const
{
- SmFontFormat *pRes = 0;
- if (nPos < aEntries.Count())
- pRes = &aEntries[ nPos ].aFntFmt;
+ const SmFontFormat *pRes = 0;
+ if (nPos < aEntries.size())
+ pRes = &aEntries[nPos].aFntFmt;
return pRes;
}
@@ -368,12 +362,13 @@ const String SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt ) co
{
String aRes;
- USHORT nCnt = aEntries.Count();
- USHORT i;
- for (i = 0; i < nCnt && 0 == aRes.Len(); ++i)
+ for (size_t i = 0; i < aEntries.size(); ++i)
{
if (aEntries[i].aFntFmt == rFntFmt)
+ {
aRes = aEntries[i].aId;
+ break;
+ }
}
return aRes;
@@ -392,10 +387,10 @@ const String SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt, BOO
}
-const String SmFontFormatList::GetFontFormatId( USHORT nPos ) const
+const String SmFontFormatList::GetFontFormatId( size_t nPos ) const
{
String aRes;
- if (nPos < aEntries.Count())
+ if (nPos < aEntries.size())
aRes = aEntries[nPos].aId;
return aRes;
}
@@ -409,12 +404,15 @@ const String SmFontFormatList::GetNewFontFormatId() const
String aPrefix( RTL_CONSTASCII_STRINGPARAM( "Id" ) );
INT32 nCnt = GetCount();
- for (INT32 i = 1; i <= nCnt + 1 && 0 == aRes.Len(); ++i)
+ for (INT32 i = 1; i <= nCnt + 1; ++i)
{
String aTmpId( aPrefix );
aTmpId += String::CreateFromInt32( i );
if (!GetFontFormat( aTmpId ))
+ {
aRes = aTmpId;
+ break;
+ }
}
DBG_ASSERT( 0 != aRes.Len(), "failed to create new FontFormatId" );
@@ -767,14 +765,14 @@ void SmMathConfig::SaveFontFormatList()
Sequence< OUString > aNames = lcl_GetFontPropertyNames();
INT32 nSymbolProps = aNames.getLength();
- USHORT nCount = rFntFmtList.GetCount();
+ size_t nCount = rFntFmtList.GetCount();
Sequence< PropertyValue > aValues( nCount * nSymbolProps );
PropertyValue *pValues = aValues.getArray();
PropertyValue *pVal = pValues;
OUString aDelim( OUString::valueOf( (sal_Unicode) '/' ) );
- for (USHORT i = 0; i < nCount; ++i)
+ for (size_t i = 0; i < nCount; ++i)
{
String aFntFmtId( rFntFmtList.GetFontFormatId( i ) );
const SmFontFormat aFntFmt( *rFntFmtList.GetFontFormat( aFntFmtId ) );
@@ -817,7 +815,8 @@ void SmMathConfig::SaveFontFormatList()
pVal->Value <<= (INT16) aFntFmt.nItalic;
pVal++;
}
- DBG_ASSERT( pVal - pValues == nCount * nSymbolProps, "properties missing" );
+ DBG_ASSERT( static_cast<size_t>(pVal - pValues) == (nCount * nSymbolProps),
+ "properties missing" );
ReplaceSetProperties( A2OU( FONT_FORMAT_LIST ) , aValues );
rFntFmtList.SetModified( FALSE );
@@ -826,13 +825,12 @@ void SmMathConfig::SaveFontFormatList()
void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
{
- size_t nCount = rSymbols.size();
- USHORT i;
+ size_t i;
// build list of used font-formats only
//!! font-format IDs may be different !!
SmFontFormatList aUsedList;
- for (i = 0; i < nCount; ++i)
+ for (i = 0; i < rSymbols.size(); ++i)
{
DBG_ASSERT( rSymbols[i].GetName().Len() > 0, "non named symbol" );
aUsedList.GetFontFormatId( SmFontFormat( rSymbols[i].GetFace() ) , TRUE );
@@ -845,14 +843,14 @@ void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
// remove unused font-formats from list
SmFontFormatList &rFntFmtList = GetFontFormatList();
- USHORT nCnt = rFntFmtList.GetCount();
+ size_t nCnt = rFntFmtList.GetCount();
SmFontFormat *pTmpFormat = new SmFontFormat[ nCnt ];
String *pId = new String [ nCnt ];
- INT32 k;
+ size_t k;
for (k = 0; k < nCnt; ++k)
{
- pTmpFormat[k] = *rFntFmtList.GetFontFormat( (USHORT) k );
- pId[k] = rFntFmtList.GetFontFormatId( (USHORT) k );
+ pTmpFormat[k] = *rFntFmtList.GetFontFormat( k );
+ pId[k] = rFntFmtList.GetFontFormatId( k );
}
for (k = 0; k < nCnt; ++k)
{
diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx
index 9e4aa9f39f2f..8e3330a6466f 100644
--- a/starmath/source/cfgitem.hxx
+++ b/starmath/source/cfgitem.hxx
@@ -32,6 +32,7 @@
#ifndef _MATH_CFGITEM_HXX_
#define _MATH_CFGITEM_HXX_
+#include <deque>
#include <vector>
#include <com/sun/star/beans/PropertyValues.hpp>
@@ -41,7 +42,6 @@
#include <tools/solar.h>
#include <rtl/ustring.hxx>
#include <unotools/configitem.hxx>
-#include <svl/svarray.hxx>
#include <vcl/timer.hxx>
#include <symbol.hxx>
@@ -82,14 +82,10 @@ struct SmFntFmtListEntry
SmFntFmtListEntry( const String &rId, const SmFontFormat &rFntFmt );
};
-
-SV_DECL_OBJARR( SmFntFmtListEntryArr, SmFntFmtListEntry, 8, 8 )
-
-
class SmFontFormatList
{
- SmFntFmtListEntryArr aEntries;
- BOOL bModified;
+ std::deque<SmFntFmtListEntry> aEntries;
+ BOOL bModified;
// disallow copy-constructor and assignment-operator for now
SmFontFormatList( const SmFontFormatList & );
@@ -103,12 +99,12 @@ public:
void RemoveFontFormat( const String &rFntFmtId );
const SmFontFormat * GetFontFormat( const String &rFntFmtId ) const;
- const SmFontFormat * GetFontFormat( USHORT nPos ) const;
+ const SmFontFormat * GetFontFormat( size_t nPos ) const;
const String GetFontFormatId( const SmFontFormat &rFntFmt ) const;
const String GetFontFormatId( const SmFontFormat &rFntFmt, BOOL bAdd );
- const String GetFontFormatId( USHORT nPos ) const;
+ const String GetFontFormatId( size_t nPos ) const;
const String GetNewFontFormatId() const;
- USHORT GetCount() const { return aEntries.Count(); }
+ size_t GetCount() const { return aEntries.size(); }
BOOL IsModified() const { return bModified; }
void SetModified( BOOL bVal ) { bModified = bVal; }
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index ab1382b97879..243e16fb6504 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -38,6 +38,8 @@
#include <comphelper/storagehelper.hxx>
#include <rtl/logfile.hxx>
#include <rtl/ustring.hxx>
+#include <unotools/eventcfg.hxx>
+#include <sfx2/event.hxx>
#include <sfx2/app.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/docfile.hxx>
@@ -180,7 +182,14 @@ void SmDocShell::SetText(const String& rBuffer)
{
pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_TEXT);
if ( SFX_CREATE_MODE_EMBEDDED == GetCreateMode() )
+ {
+ // have SwOleClient::FormatChanged() to align the modified formula properly
+ // even if the vis area does not change (e.g. when formula text changes from
+ // "{a over b + c} over d" to "d over {a over b + c}"
+ SFX_APP()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(STR_EVENT_VISAREACHANGED), this));
+
Repaint();
+ }
else
pViewSh->GetGraphicWindow().Invalidate();
}
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index d8e2586e151e..b1d7d9e69210 100755
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -573,6 +573,13 @@ const SmNode * SmNode::FindNodeWithAccessibleIndex(xub_StrLen nAccIdx) const
return pResult;
}
+
+long SmNode::GetFormulaBaseline() const
+{
+ DBG_ASSERT( 0, "This dummy implementation should not have been called." );
+ return 0;
+}
+
///////////////////////////////////////////////////////////////////////////
SmStructureNode::SmStructureNode( const SmStructureNode &rNode ) :
@@ -763,7 +770,7 @@ void SmTableNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
}
Point aPos;
- SmRect::operator = (SmRect(nMaxWidth, 0));
+ SmRect::operator = (SmRect(nMaxWidth, 1));
for (i = 0; i < nSize; i++)
{ if (NULL != (pNode = GetSubNode(i)))
{ const SmRect &rNodeRect = pNode->GetRect();
@@ -779,6 +786,22 @@ void SmTableNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
ExtendBy(rNodeRect, nSize > 1 ? RCP_NONE : RCP_ARG);
}
}
+ // --> 4.7.2010 #i972#
+ if (HasBaseline())
+ nFormulaBaseline = GetBaseline();
+ else
+ {
+ SmTmpDevice aTmpDev ((OutputDevice &) rDev, TRUE);
+ aTmpDev.SetFont(GetFont());
+
+ SmRect aRect = (SmRect(aTmpDev, &rFormat, C2S("a"),
+ GetFont().GetBorderWidth()));
+ nFormulaBaseline = GetAlignM();
+ // move from middle position by constant - distance
+ // between middle and baseline for single letter
+ nFormulaBaseline += aRect.GetBaseline() - aRect.GetAlignM();
+ }
+ // <--
}
@@ -788,6 +811,12 @@ SmNode * SmTableNode::GetLeftMost()
}
+long SmTableNode::GetFormulaBaseline() const
+{
+ return nFormulaBaseline;
+}
+
+
/**************************************************************************/
@@ -818,20 +847,21 @@ void SmLineNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
SmTmpDevice aTmpDev ((OutputDevice &) rDev, TRUE);
aTmpDev.SetFont(GetFont());
- // provide an empty rectangle with alignment parameters for the "current"
- // font (in order to make "a^1 {}_2^3 a_4" work correct, that is, have the
- // same sub-/supscript positions.)
- //! be sure to use a character that has explicitly defined HiAttribut
- //! line in rect.cxx such as 'a' in order to make 'vec a' look same to
- //! 'vec {a}'.
- SmRect::operator = (SmRect(aTmpDev, &rFormat, C2S("a"),
- GetFont().GetBorderWidth()));
- // make sure that the rectangle occupies (almost) no space
- SetWidth(1);
- SetItalicSpaces(0, 0);
-
if (nSize < 1)
+ {
+ // provide an empty rectangle with alignment parameters for the "current"
+ // font (in order to make "a^1 {}_2^3 a_4" work correct, that is, have the
+ // same sub-/supscript positions.)
+ //! be sure to use a character that has explicitly defined HiAttribut
+ //! line in rect.cxx such as 'a' in order to make 'vec a' look same to
+ //! 'vec {a}'.
+ SmRect::operator = (SmRect(aTmpDev, &rFormat, C2S("a"),
+ GetFont().GetBorderWidth()));
+ // make sure that the rectangle occupies (almost) no space
+ SetWidth(1);
+ SetItalicSpaces(0, 0);
return;
+ }
// make distance depend on font size
long nDist = (rFormat.GetDistance(DIS_HORIZONTAL) * GetFont().GetSize().Height()) / 100L;
@@ -839,14 +869,17 @@ void SmLineNode::Arrange(const OutputDevice &rDev, const SmFormat &rFormat)
nDist = 0;
Point aPos;
- for (i = 0; i < nSize; i++)
+ // copy the first node into LineNode and extend by the others
+ if (NULL != (pNode = GetSubNode(0)))
+ SmRect::operator = (pNode->GetRect());
+
+ for (i = 1; i < nSize; i++)
if (NULL != (pNode = GetSubNode(i)))
{
aPos = pNode->AlignTo(*this, RP_RIGHT, RHA_CENTER, RVA_BASELINE);
- // no horizontal space before first node
- if (i)
- aPos.X() += nDist;
+ // add horizontal space to the left for each but the first sub node
+ aPos.X() += nDist;
pNode->MoveTo(aPos);
ExtendBy( *pNode, RCP_XOR );
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index cd3e4b714469..108cb9c69e4a 100755
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -238,7 +238,8 @@ enum SmModelPropertyHandles
// --> PB 2004-08-25 #i33095# Security Options
HANDLE_LOAD_READONLY,
// <--
- HANDLE_DIALOG_LIBRARIES // #i73329#
+ HANDLE_DIALOG_LIBRARIES, // #i73329#
+ HANDLE_BASELINE // 3.7.2010 #i972#
};
PropertySetInfo * lcl_createModelPropertyInfo ()
@@ -310,6 +311,9 @@ PropertySetInfo * lcl_createModelPropertyInfo ()
// --> PB 2004-08-25 #i33095# Security Options
{ RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY, &::getBooleanCppuType(), PROPERTY_NONE, 0 },
// <--
+ // --> 3.7.2010 #i972#
+ { RTL_CONSTASCII_STRINGPARAM( "BaseLine"), HANDLE_BASELINE, &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, 0},
+ // <--
{ NULL, 0, 0, NULL, 0, 0 }
};
PropertySetInfo *pInfo = new PropertySetInfo ( aModelPropertyInfoMap );
@@ -955,6 +959,21 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu
break;
}
// <--
+ // --> 3.7.2010 #i972#
+ case HANDLE_BASELINE:
+ {
+ if ( !pDocSh->pTree )
+ pDocSh->Parse();
+ if ( pDocSh->pTree )
+ {
+ if ( !pDocSh->IsFormulaArranged() )
+ pDocSh->ArrangeFormula();
+
+ *pValue <<= static_cast<sal_Int32>( pDocSh->pTree->GetFormulaBaseline() );
+ }
+ }
+ break;
+ // <--
}
}
}