summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-09-25 21:37:37 +0200
committerCaolán McNamara <caolanm@redhat.com>2013-09-25 22:40:23 +0200
commit5342cd7533a51fd488de85565674ee01649ddcbc (patch)
tree533d33531076204c002bec87a4dcf8d71c4775dc
parent2de32959d0041dddf5c47da9b7829c2e272478aa (diff)
Resolves: fdo#66400 import combined characters from docx
move .doc combined character parser stuff from sw to filter for reuse in .docx and fix bad length problem when nSavPtr == -1 after String->OUString conversion thanks for the pasta CloudOn Change-Id: I368ca30c14fd089271902b9b874de1099eb40038
-rw-r--r--filter/source/msfilter/util.cxx284
-rw-r--r--include/filter/msfilter/util.hxx31
-rw-r--r--sw/source/filter/ww8/ww8par.hxx5
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx303
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx55
5 files changed, 368 insertions, 310 deletions
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 54b20738280b..93241928cde9 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -9,6 +9,7 @@
#include <rtl/ustring.hxx>
#include <rtl/strbuf.hxx>
+#include <tools/string.hxx>
#include <unotools/fontcvt.hxx>
#include <unotools/fontdefs.hxx>
#include <vcl/svapp.hxx>
@@ -445,6 +446,289 @@ OUString findQuotedText( const OUString& rCommand,
}
+WW8ReadFieldParams::WW8ReadFieldParams( const OUString& _rData )
+ : aData( _rData )
+ , nFnd( 0 )
+ , nNext( 0 )
+ , nSavPtr( 0 )
+{
+ /*
+ erstmal nach einer oeffnenden Klammer oder einer Leerstelle oder einem
+ Anfuehrungszeichen oder einem Backslash suchen, damit der Feldbefehl
+ (also INCLUDEPICTURE bzw EINFUeGENGRAFIK bzw ...) ueberlesen wird
+ */
+ const sal_Int32 nLen = aData.getLength();
+
+ while ( nNext<nLen && aData[nNext]==' ' )
+ ++nNext;
+
+ while ( nNext<nLen )
+ {
+ const sal_Unicode c = aData[nNext];
+ if ( c==' ' || c=='"' || c=='\\' || c==132 || c==0x201c )
+ break;
+ ++nNext;
+ }
+
+ nFnd = nNext;
+ nSavPtr = nNext;
+}
+
+
+WW8ReadFieldParams::~WW8ReadFieldParams()
+{
+
+}
+
+
+OUString WW8ReadFieldParams::GetResult() const
+{
+ if (nFnd<0 && nSavPtr>nFnd)
+ return OUString();
+ else
+ {
+ return nSavPtr == -1 ? aData.copy(nFnd) : aData.copy(nFnd, nSavPtr-nFnd);
+ }
+}
+
+
+bool WW8ReadFieldParams::GoToTokenParam()
+{
+ const sal_Int32 nOld = nNext;
+ if( -2 == SkipToNextToken() )
+ return GetTokenSttPtr()>=0;
+ nNext = nOld;
+ return false;
+}
+
+// ret: -2: NOT a '\' parameter but normal Text
+sal_Int32 WW8ReadFieldParams::SkipToNextToken()
+{
+ if ( nNext<0 || nNext>=aData.getLength() )
+ return -1;
+
+ nFnd = FindNextStringPiece(nNext);
+ if ( nFnd<0 )
+ return -1;
+
+ nSavPtr = nNext;
+
+ if ( aData[nFnd]=='\\' && nFnd+1<aData.getLength() && aData[nFnd+1]!='\\' )
+ {
+ const sal_Int32 nRet = aData[++nFnd];
+ nNext = ++nFnd; // und dahinter setzen
+ return nRet;
+ }
+
+ if ( nSavPtr>0 && (aData[nSavPtr-1]=='"' || aData[nSavPtr-1]==0x201d ) )
+ {
+ --nSavPtr;
+ }
+ return -2;
+}
+
+// FindNextPara sucht naechsten Backslash-Parameter oder naechste Zeichenkette
+// bis zum Blank oder naechsten "\" oder zum schliessenden Anfuehrungszeichen
+// oder zum String-Ende von pStr.
+//
+// Ausgabe ppNext (falls ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
+//
+// Returnwert: 0 falls String-Ende erreicht,
+// ansonsten Anfang des Paramters bzw. der Zeichenkette
+//
+sal_Int32 WW8ReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
+{
+ const sal_Int32 nLen = aData.getLength();
+ sal_Int32 n = nStart<0 ? nFnd : nStart; // Anfang
+ sal_Int32 n2; // Ende
+
+ nNext = -1; // Default fuer nicht gefunden
+
+ while ( n<nLen && aData[n]==' ' )
+ ++n;
+
+ if ( n==nLen )
+ return -1;
+
+ if ( aData[n]==0x13 )
+ {
+ // Skip the nested field code since it's not supported
+ while ( n<nLen && aData[n]!=0x14 )
+ ++n;
+ if ( n==nLen )
+ return -1;
+ }
+
+ // Anfuehrungszeichen vor Para?
+ if ( aData[n]=='"' || aData[n]==0x201c || aData[n]==132 || aData[n]==0x14 )
+ {
+ n++; // Anfuehrungszeichen ueberlesen
+ n2 = n; // ab hier nach Ende suchen
+ while( (nLen > n2)
+ && (aData[n2] != '"')
+ && (aData[n2] != 0x201d)
+ && (aData[n2] != 147)
+ && (aData[n2] != 0x15) )
+ n2++; // Ende d. Paras suchen
+ }
+ else // keine Anfuehrungszeichen
+ {
+ n2 = n; // ab hier nach Ende suchen
+ while ( n2<nLen && aData[n2]!=' ' ) // Ende d. Paras suchen
+ {
+ if ( aData[n2]=='\\' )
+ {
+ if ( n2+1<nLen && aData[n2+1]=='\\' )
+ n2 += 2; // Doppel-Backslash -> OK
+ else
+ {
+ if( n2 > n )
+ n2--;
+ break; // einfach-Backslash -> Ende
+ }
+ }
+ else
+ n2++; // kein Backslash -> OK
+ }
+ }
+ if( nLen > n2 )
+ {
+ if (aData[n2]!=' ') ++n2;
+ nNext = n2;
+ }
+ return n;
+}
+
+
+
+// read parameters "1-3" or 1-3 with both values between 1 and nMax
+bool WW8ReadFieldParams::GetTokenSttFromTo(sal_Int32* pFrom, sal_Int32* pTo, sal_Int32 nMax)
+{
+ sal_Int32 nStart = 0;
+ sal_Int32 nEnd = 0;
+ if ( GoToTokenParam() )
+ {
+
+ const OUString sParams( GetResult() );
+
+ sal_Int32 nIndex = 0;
+ const OUString sStart( sParams.getToken(0, '-', nIndex) );
+ if (nIndex>=0)
+ {
+ nStart = sStart.toInt32();
+ nEnd = sParams.copy(nIndex).toInt32();
+ }
+ }
+ if( pFrom ) *pFrom = nStart;
+ if( pTo ) *pTo = nEnd;
+
+ return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
+}
+
+EquationResult Read_SubF_Combined(WW8ReadFieldParams& rReadParam)
+{
+ EquationResult aResult;
+
+ String sCombinedCharacters;
+ WW8ReadFieldParams aOriFldParam = rReadParam;
+ const sal_Int32 cGetChar = rReadParam.SkipToNextToken();
+ switch( cGetChar )
+ {
+ case 'a':
+ case 'A':
+ if ( !rReadParam.GetResult().startsWithIgnoreAsciiCase("d") )
+ {
+ break;
+ }
+ rReadParam.SkipToNextToken();
+ // intentional fall-through
+ case -2:
+ {
+ if ( rReadParam.GetResult().startsWithIgnoreAsciiCase("(") )
+ {
+ for (int i=0;i<2;i++)
+ {
+ if ('s' == rReadParam.SkipToNextToken())
+ {
+ const sal_Int32 cChar = rReadParam.SkipToNextToken();
+ if (-2 != rReadParam.SkipToNextToken())
+ break;
+ const OUString sF = rReadParam.GetResult();
+ if ((('u' == cChar) && sF.startsWithIgnoreAsciiCase("p"))
+ || (('d' == cChar) && sF.startsWithIgnoreAsciiCase("o")))
+ {
+ if (-2 == rReadParam.SkipToNextToken())
+ {
+ String sPart = rReadParam.GetResult();
+ xub_StrLen nBegin = sPart.Search('(');
+
+ //Word disallows brackets in this field, which
+ //aids figuring out the case of an end of )) vs )
+ xub_StrLen nEnd = sPart.Search(')');
+
+ if ((nBegin != STRING_NOTFOUND) &&
+ (nEnd != STRING_NOTFOUND))
+ {
+ sCombinedCharacters +=
+ sPart.Copy(nBegin+1,nEnd-nBegin-1);
+ }
+ }
+ }
+ }
+ }
+ if (sCombinedCharacters.Len())
+ {
+ aResult.sType = "CombinedCharacters";
+ aResult.sResult = sCombinedCharacters;
+ }
+ else
+ {
+ const String sPart = aOriFldParam.GetResult();
+ xub_StrLen nBegin = sPart.Search('(');
+ xub_StrLen nEnd = sPart.Search(',');
+ if ( nEnd == STRING_NOTFOUND )
+ {
+ nEnd = sPart.Search(')');
+ }
+ if ( (nBegin != STRING_NOTFOUND) && (nEnd != STRING_NOTFOUND) )
+ {
+ // skip certain leading characters
+ for (int i = nBegin;i < nEnd-1;i++)
+ {
+ const sal_Unicode cC = sPart.GetChar(nBegin+1);
+ if ( cC < 32 )
+ {
+ nBegin++;
+ }
+ else
+ break;
+ }
+ sCombinedCharacters = sPart.Copy( nBegin+1, nEnd-nBegin-1 );
+ if ( sCombinedCharacters.Len() )
+ {
+ aResult.sType = "Input";
+ aResult.sResult = sCombinedCharacters;
+ }
+ }
+ }
+ }
+ }
+ default:
+ break;
+ }
+ return aResult;
+}
+
+EquationResult ParseCombinedChars(const OUString& rStr)
+{
+ EquationResult aResult;
+ WW8ReadFieldParams aReadParam( rStr );
+ const sal_Int32 cChar = aReadParam.SkipToNextToken();
+ if ('o' == cChar || 'O' == cChar)
+ aResult = Read_SubF_Combined(aReadParam);
+ return aResult;
+}
+
}
}
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index 38cdf56e7df2..0da3aafde875 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -95,7 +95,38 @@ public:
* Example: SEQ "Figure" \someoption -> "Figure"
*/
MSFILTER_DLLPUBLIC OUString findQuotedText( const OUString& rCommand, const sal_Char* cStartQuote, const sal_Unicode uEndQuote );
+
+class MSFILTER_DLLPUBLIC WW8ReadFieldParams
+{
+private:
+ const OUString aData;
+ sal_Int32 nFnd;
+ sal_Int32 nNext;
+ sal_Int32 nSavPtr;
+public:
+ WW8ReadFieldParams( const OUString& rData );
+ ~WW8ReadFieldParams();
+
+ bool GoToTokenParam();
+ sal_Int32 SkipToNextToken();
+ sal_Int32 GetTokenSttPtr() const { return nFnd; }
+
+ sal_Int32 FindNextStringPiece( sal_Int32 _nStart = -1 );
+ bool GetTokenSttFromTo(sal_Int32* _pFrom, sal_Int32* _pTo, sal_Int32 _nMax);
+
+ OUString GetResult() const;
+};
+
+struct MSFILTER_DLLPUBLIC EquationResult
+{
+ OUString sResult;
+ OUString sType;
+};
+
+MSFILTER_DLLPUBLIC EquationResult ParseCombinedChars(const OUString& rStr);
+
}
+
}
#endif
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 946a3d7c923c..7d970e6348ec 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -23,6 +23,7 @@
#include <tools/string.hxx>
#include "rtl/ustring.hxx"
#include <filter/msfilter/msdffimp.hxx>
+#include <filter/msfilter/util.hxx>
#include <editeng/frmdir.hxx>
#include <fltshell.hxx>
@@ -100,7 +101,6 @@ class SwAttrSet;
class GDIMetaFile;
struct ESelection;
class SfxItemSet;
-class WW8ReadFieldParams;
class wwZOrderer;
class OutlinerParaObject;
@@ -111,6 +111,8 @@ namespace com{namespace sun {namespace star{
namespace lang{class XMultiServiceFactory;}
}}}
+using namespace msfilter::util;
+
// defines nur fuer die WW8-variable der INI-Datei
#define WW8FL_NO_TEXT 1
#define WW8FL_NO_STYLES 2
@@ -1771,7 +1773,6 @@ public: // eigentlich private, geht aber leider nur public
eF_ResT Read_F_DBNum( WW8FieldDesc*, OUString& );
eF_ResT Read_F_Equation( WW8FieldDesc*, OUString& );
void Read_SubF_Ruby( WW8ReadFieldParams& rReadParam);
- void Read_SubF_Combined( WW8ReadFieldParams& rReadParam);
eF_ResT Read_F_IncludePicture( WW8FieldDesc*, OUString& rStr );
eF_ResT Read_F_IncludeText( WW8FieldDesc*, OUString& rStr );
eF_ResT Read_F_Seq( WW8FieldDesc*, OUString& rStr );
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 885066683274..82ea7a4f8146 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -86,208 +86,12 @@
#define WW8_TOX_LEVEL_DELIM ':'
using namespace ::com::sun::star;
+using namespace msfilter::util;
using namespace sw::util;
using namespace sw::mark;
using namespace std; // #i24377#
using namespace nsSwDocInfoSubType;
-
-class WW8ReadFieldParams
-{
-private:
- const OUString aData;
- sal_Int32 nFnd;
- sal_Int32 nNext;
- sal_Int32 nSavPtr;
-public:
- WW8ReadFieldParams( const OUString& rData );
- ~WW8ReadFieldParams();
-
- bool GoToTokenParam();
- sal_Int32 SkipToNextToken();
- sal_Int32 GetTokenSttPtr() const { return nFnd; }
-
- sal_Int32 FindNextStringPiece( sal_Int32 _nStart = -1 );
- bool GetTokenSttFromTo(sal_Int32* _pFrom, sal_Int32* _pTo, sal_Int32 _nMax);
-
- OUString GetResult() const;
-};
-
-
-WW8ReadFieldParams::WW8ReadFieldParams( const OUString& _rData )
- : aData( _rData )
- , nFnd( 0 )
- , nNext( 0 )
- , nSavPtr( 0 )
-{
- /*
- erstmal nach einer oeffnenden Klammer oder einer Leerstelle oder einem
- Anfuehrungszeichen oder einem Backslash suchen, damit der Feldbefehl
- (also INCLUDEPICTURE bzw EINFUeGENGRAFIK bzw ...) ueberlesen wird
- */
- const sal_Int32 nLen = aData.getLength();
-
- while ( nNext<nLen && aData[nNext]==' ' )
- ++nNext;
-
- while ( nNext<nLen )
- {
- const sal_Unicode c = aData[nNext];
- if ( c==' ' || c=='"' || c=='\\' || c==132 || c==0x201c )
- break;
- ++nNext;
- }
-
- nFnd = nNext;
- nSavPtr = nNext;
-}
-
-
-WW8ReadFieldParams::~WW8ReadFieldParams()
-{
-
-}
-
-
-OUString WW8ReadFieldParams::GetResult() const
-{
- return nFnd<0 && nSavPtr>nFnd ? OUString() : aData.copy( nFnd, nSavPtr-nFnd );
-}
-
-
-bool WW8ReadFieldParams::GoToTokenParam()
-{
- const sal_Int32 nOld = nNext;
- if( -2 == SkipToNextToken() )
- return GetTokenSttPtr()>=0;
- nNext = nOld;
- return false;
-}
-
-// ret: -2: NOT a '\' parameter but normal Text
-sal_Int32 WW8ReadFieldParams::SkipToNextToken()
-{
- if ( nNext<0 || nNext>=aData.getLength() )
- return -1;
-
- nFnd = FindNextStringPiece(nNext);
- if ( nFnd<0 )
- return -1;
-
- nSavPtr = nNext;
-
- if ( aData[nFnd]=='\\' && nFnd+1<aData.getLength() && aData[nFnd+1]!='\\' )
- {
- const sal_Int32 nRet = aData[++nFnd];
- nNext = ++nFnd; // und dahinter setzen
- return nRet;
- }
-
- if ( nSavPtr>0 && (aData[nSavPtr-1]=='"' || aData[nSavPtr-1]==0x201d ) )
- {
- --nSavPtr;
- }
- return -2;
-}
-
-// FindNextPara sucht naechsten Backslash-Parameter oder naechste Zeichenkette
-// bis zum Blank oder naechsten "\" oder zum schliessenden Anfuehrungszeichen
-// oder zum String-Ende von pStr.
-//
-// Ausgabe ppNext (falls ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0
-//
-// Returnwert: 0 falls String-Ende erreicht,
-// ansonsten Anfang des Paramters bzw. der Zeichenkette
-//
-sal_Int32 WW8ReadFieldParams::FindNextStringPiece(const sal_Int32 nStart)
-{
- const sal_Int32 nLen = aData.getLength();
- sal_Int32 n = nStart<0 ? nFnd : nStart; // Anfang
- sal_Int32 n2; // Ende
-
- nNext = -1; // Default fuer nicht gefunden
-
- while ( n<nLen && aData[n]==' ' )
- ++n;
-
- if ( n==nLen )
- return -1;
-
- if ( aData[n]==0x13 )
- {
- // Skip the nested field code since it's not supported
- while ( n<nLen && aData[n]!=0x14 )
- ++n;
- if ( n==nLen )
- return -1;
- }
-
- // Anfuehrungszeichen vor Para?
- if ( aData[n]=='"' || aData[n]==0x201c || aData[n]==132 || aData[n]==0x14 )
- {
- n++; // Anfuehrungszeichen ueberlesen
- n2 = n; // ab hier nach Ende suchen
- while( (nLen > n2)
- && (aData[n2] != '"')
- && (aData[n2] != 0x201d)
- && (aData[n2] != 147)
- && (aData[n2] != 0x15) )
- n2++; // Ende d. Paras suchen
- }
- else // keine Anfuehrungszeichen
- {
- n2 = n; // ab hier nach Ende suchen
- while ( n2<nLen && aData[n2]!=' ' ) // Ende d. Paras suchen
- {
- if ( aData[n2]=='\\' )
- {
- if ( n2+1<nLen && aData[n2+1]=='\\' )
- n2 += 2; // Doppel-Backslash -> OK
- else
- {
- if( n2 > n )
- n2--;
- break; // einfach-Backslash -> Ende
- }
- }
- else
- n2++; // kein Backslash -> OK
- }
- }
- if( nLen > n2 )
- {
- if (aData[n2]!=' ') ++n2;
- nNext = n2;
- }
- return n;
-}
-
-
-
-// read parameters "1-3" or 1-3 with both values between 1 and nMax
-bool WW8ReadFieldParams::GetTokenSttFromTo(sal_Int32* pFrom, sal_Int32* pTo, sal_Int32 nMax)
-{
- sal_Int32 nStart = 0;
- sal_Int32 nEnd = 0;
- if ( GoToTokenParam() )
- {
-
- const OUString sParams( GetResult() );
-
- sal_Int32 nIndex = 0;
- const OUString sStart( sParams.getToken(0, '-', nIndex) );
- if (nIndex>=0)
- {
- nStart = sStart.toInt32();
- nEnd = sParams.copy(nIndex).toInt32();
- }
- }
- if( pFrom ) *pFrom = nStart;
- if( pTo ) *pTo = nEnd;
-
- return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd);
-}
-
//----------------------------------------
// Bookmarks
//----------------------------------------
@@ -2608,103 +2412,26 @@ eF_ResT SwWW8ImplReader::Read_F_Equation( WW8FieldDesc*, OUString& rStr )
WW8ReadFieldParams aReadParam( rStr );
const sal_Int32 cChar = aReadParam.SkipToNextToken();
if ('o' == cChar || 'O' == cChar)
- Read_SubF_Combined(aReadParam);
- else if ('*' == cChar)
- Read_SubF_Ruby(aReadParam);
- return FLD_OK;
-}
-
-void SwWW8ImplReader::Read_SubF_Combined( WW8ReadFieldParams& rReadParam)
-{
- String sCombinedCharacters;
- WW8ReadFieldParams aOriFldParam = rReadParam;
- const sal_Int32 cGetChar = rReadParam.SkipToNextToken();
- switch( cGetChar )
{
- case 'a':
- case 'A':
- if ( !rReadParam.GetResult().startsWithIgnoreAsciiCase("d") )
+ EquationResult aResult(ParseCombinedChars(rStr));
+
+ if (aResult.sType == "Input")
{
- break;
+ SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ),
+ aResult.sResult, aResult.sResult, INP_TXT, 0 );
+ rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); // insert input field
}
- rReadParam.SkipToNextToken();
- // intentional fall-through
- case -2:
+ else if (aResult.sType == "CombinedCharacters")
{
- if ( rReadParam.GetResult().startsWithIgnoreAsciiCase("(") )
- {
- for (int i=0;i<2;i++)
- {
- if ('s' == rReadParam.SkipToNextToken())
- {
- const sal_Int32 cChar = rReadParam.SkipToNextToken();
- if (-2 != rReadParam.SkipToNextToken())
- break;
- const OUString sF = rReadParam.GetResult();
- if ((('u' == cChar) && sF.startsWithIgnoreAsciiCase("p"))
- || (('d' == cChar) && sF.startsWithIgnoreAsciiCase("o")))
- {
- if (-2 == rReadParam.SkipToNextToken())
- {
- String sPart = rReadParam.GetResult();
- xub_StrLen nBegin = sPart.Search('(');
-
- //Word disallows brackets in this field, which
- //aids figuring out the case of an end of )) vs )
- xub_StrLen nEnd = sPart.Search(')');
-
- if ((nBegin != STRING_NOTFOUND) &&
- (nEnd != STRING_NOTFOUND))
- {
- sCombinedCharacters +=
- sPart.Copy(nBegin+1,nEnd-nBegin-1);
- }
- }
- }
- }
- }
- if (sCombinedCharacters.Len())
- {
- SwCombinedCharField aFld((SwCombinedCharFieldType*)
- rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters);
- rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
- }
- else
- {
- const String sPart = aOriFldParam.GetResult();
- xub_StrLen nBegin = sPart.Search('(');
- xub_StrLen nEnd = sPart.Search(',');
- if ( nEnd == STRING_NOTFOUND )
- {
- nEnd = sPart.Search(')');
- }
- if ( (nBegin != STRING_NOTFOUND) && (nEnd != STRING_NOTFOUND) )
- {
- // skip certain leading characters
- for (int i = nBegin;i < nEnd-1;i++)
- {
- const sal_Unicode cC = sPart.GetChar(nBegin+1);
- if ( cC < 32 )
- {
- nBegin++;
- }
- else
- break;
- }
- sCombinedCharacters = sPart.Copy( nBegin+1, nEnd-nBegin-1 );
- if ( sCombinedCharacters.Len() )
- {
- SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ),
- sCombinedCharacters, sCombinedCharacters, INP_TXT, 0 );
- rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); // insert input field
- }
- }
- }
- }
+ SwCombinedCharField aFld((SwCombinedCharFieldType*)
+ rDoc.GetSysFldType(RES_COMBINED_CHARS), aResult.sType);
+ rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
}
- default:
- break;
}
+ else if ('*' == cChar)
+ Read_SubF_Ruby(aReadParam);
+
+ return FLD_OK;
}
void SwWW8ImplReader::Read_SubF_Ruby( WW8ReadFieldParams& rReadParam)
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 9f69fab589b1..5a5ab662fe35 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3000,29 +3000,44 @@ void DomainMapper_Impl::CloseFieldCommand()
case FIELD_EQ:
{
OUString aCommand = pContext->GetCommand().trim();
- nSpaceIndex = aCommand.indexOf(' ');
- if(nSpaceIndex > 0)
- aCommand = aCommand.copy(nSpaceIndex).trim();
- if (aCommand.startsWith("\\s"))
+
+ msfilter::util::EquationResult aResult(msfilter::util::ParseCombinedChars(aCommand));
+ if (!aResult.sType.isEmpty() && m_xTextFactory.is())
+ {
+ OUString sServiceName("com.sun.star.text.TextField.");
+ xFieldInterface = m_xTextFactory->createInstance(sServiceName + aResult.sType);
+ xFieldProperties =
+ uno::Reference< beans::XPropertySet >( xFieldInterface,
+ uno::UNO_QUERY_THROW);
+ xFieldProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_CONTENT), uno::makeAny(aResult.sResult));
+ }
+ else
{
- aCommand = aCommand.copy(2);
- if (aCommand.startsWith("\\do"))
+ //merge Read_SubF_Ruby into filter/.../util.cxx and reuse that ?
+ nSpaceIndex = aCommand.indexOf(' ');
+ if(nSpaceIndex > 0)
+ aCommand = aCommand.copy(nSpaceIndex).trim();
+ if (aCommand.startsWith("\\s"))
{
- aCommand = aCommand.copy(3);
- sal_Int32 nStartIndex = aCommand.indexOf('(');
- sal_Int32 nEndIndex = aCommand.indexOf(')');
- if (nStartIndex > 0 && nEndIndex > 0)
+ aCommand = aCommand.copy(2);
+ if (aCommand.startsWith("\\do"))
{
- // nDown is the requested "lower by" value in points.
- sal_Int32 nDown = aCommand.copy(0, nStartIndex).toInt32();
- OUString aContent = aCommand.copy(nStartIndex + 1, nEndIndex - nStartIndex - 1);
- PropertyMapPtr pCharContext = GetTopContext();
- // dHeight is the font size of the current style.
- double dHeight = 0;
- if (GetPropertyFromStyleSheet(PROP_CHAR_HEIGHT) >>= dHeight)
- // Character escapement should be given in negative percents for subscripts.
- pCharContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( sal_Int16(- 100 * nDown / dHeight) ) );
- appendTextPortion(aContent, pCharContext);
+ aCommand = aCommand.copy(3);
+ sal_Int32 nStartIndex = aCommand.indexOf('(');
+ sal_Int32 nEndIndex = aCommand.indexOf(')');
+ if (nStartIndex > 0 && nEndIndex > 0)
+ {
+ // nDown is the requested "lower by" value in points.
+ sal_Int32 nDown = aCommand.copy(0, nStartIndex).toInt32();
+ OUString aContent = aCommand.copy(nStartIndex + 1, nEndIndex - nStartIndex - 1);
+ PropertyMapPtr pCharContext = GetTopContext();
+ // dHeight is the font size of the current style.
+ double dHeight = 0;
+ if (GetPropertyFromStyleSheet(PROP_CHAR_HEIGHT) >>= dHeight)
+ // Character escapement should be given in negative percents for subscripts.
+ pCharContext->Insert(PROP_CHAR_ESCAPEMENT, uno::makeAny( sal_Int16(- 100 * nDown / dHeight) ) );
+ appendTextPortion(aContent, pCharContext);
+ }
}
}
}