Kaydet (Commit) 09a25659 authored tarafından Kenneth Aafløy's avatar Kenneth Aafløy Kaydeden (comit) Luboš Luňák

Add import of docvariable fields from word documents

Hi,

Attached is a patch that adds support for importing docvariable fields
from microsoft word documents. The variables themselves are already
converted correctly, so this patch only ties the field to the existing
custom document information.

Please consider this patch for inclusion.

I declare that this and my further patches are under LGPLv3+ / MPL license.

With Regards,
Kenneth Aafløy
üst 2070d9a2
...@@ -965,7 +965,7 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes) ...@@ -965,7 +965,7 @@ long SwWW8ImplReader::Read_Field(WW8PLCFManResult* pRes)
0, 0,
0, 0,
0, 0,
0, &SwWW8ImplReader::Read_F_DocInfo, // 64 - DOCVARIABLE
0, 0,
0, 0,
&SwWW8ImplReader::Read_F_IncludePicture, // 67 &SwWW8ImplReader::Read_F_IncludePicture, // 67
...@@ -1759,6 +1759,9 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) ...@@ -1759,6 +1759,9 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr )
nReg = DI_SUB_TIME; nReg = DI_SUB_TIME;
bDateTime = true; bDateTime = true;
break; break;
case 64: // DOCVARIABLE
nSub = DI_CUSTOM;
break;
} }
sal_uInt32 nFormat = 0; sal_uInt32 nFormat = 0;
...@@ -1784,8 +1787,32 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) ...@@ -1784,8 +1787,32 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr )
} }
} }
String aData;
// Extract DOCVARIABLE varname
if ( 64 == pF->nId )
{
_ReadFieldParams aReadParam( rStr );
long nRet;
while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
{
switch( nRet )
{
case -2:
if( !aData.Len() )
aData = aReadParam.GetResult();
break;
case '*':
//Skip over MERGEFORMAT
aReadParam.SkipToNextToken();
break;
}
}
aData = comphelper::string::remove(aData, '"');
}
SwDocInfoField aFld( (SwDocInfoFieldType*) SwDocInfoField aFld( (SwDocInfoFieldType*)
rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, String(), nFormat ); rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, aData, nFormat );
if (bDateTime) if (bDateTime)
ForceFieldLanguage(aFld, nLang); ForceFieldLanguage(aFld, nLang);
rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment