Commit ea5ebe72 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - another ole objects(pictureId)

parent 50224310
......@@ -766,18 +766,11 @@ namespace DocFormatUtils
static inline std::wstring IntToWideString(int value)
{
#if defined(_WIN32) || defined (_WIN64)
wchar_t buff[33] ={};
_itow(value, buff, 10);
return std::wstring(buff);
#else
return (std::to_wstring(value));
#endif
}
static inline std::wstring DoubleToWideString(double value)
{
std::wstringstream src;
src << value;
return std::wstring(src.str());
......@@ -786,7 +779,6 @@ namespace DocFormatUtils
static inline std::string DoubleToString(double value)
{
std::stringstream src;
src << value;
return std::string(src.str());
......@@ -813,36 +805,16 @@ namespace DocFormatUtils
static inline std::wstring IntToFormattedWideString( int value, const wchar_t* format )
{
// const int size = 33;
// wchar_t strValue[size] = L"\0";
if ( format == NULL ) return L"";
// swprintf_s( strValue, size, format, value );
//// }
// CString format_str;
// format_str.Format(format , value);
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
//return string2std_string( format_str );
}
static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format )
{
if ( format == NULL ) return L"";
//std::wstring wstr;
//if ( format != NULL )
//{
// CString strValue;
// strValue.Format(format, value);
// wstr = string2std_string( strValue );
//}
//return wstr;
std::wstringstream sstream;
sstream << boost::wformat(format) % value;
return sstream.str();
......
......@@ -81,12 +81,8 @@ namespace DocFileFormat
RELEASEOBJECT(m_pXmlWriter);
}
}
}
namespace DocFileFormat
{
// Looks into the section table to find out if this CP is the end & current of a sections
int DocumentMapping::getCurrentSection(int cp)
{
//if cp is the last char of a section, the next section will start at cp +1
......@@ -198,7 +194,7 @@ namespace DocFileFormat
// start paragraph
m_pXmlWriter->WriteNodeBegin(_T("w:p"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:p"), true);
writeParagraphRsid(papx);
// ----------- check for section properties
......@@ -339,7 +335,7 @@ namespace DocFileFormat
}
}
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
}
// Writes a run with the given characters and CHPX
......@@ -356,23 +352,23 @@ namespace DocFileFormat
if (Deleted == rev.Type)
{
//If it's a deleted run
m_pXmlWriter->WriteNodeBegin(_T("w:del"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:del"), true);
m_pXmlWriter->WriteAttribute(_T("w:author"), _T("[b2x: could not retrieve author]"));
m_pXmlWriter->WriteAttribute(_T("w:date"), _T("[b2x: could not retrieve date]"));
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
}
else if ( rev.Type == Inserted )
{
WideString* author = dynamic_cast<WideString*>(m_document->RevisionAuthorTable->operator[](rev.Isbt));
//if it's a inserted run
m_pXmlWriter->WriteNodeBegin(_T("w:ins"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:ins"), true);
m_pXmlWriter->WriteAttribute(_T("w:author"), FormatUtils::XmlEncode(*author).c_str());
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
//rev.Dttm.Convert(new DateMapping(m_pXmlWriter));
}
//start run
m_pXmlWriter->WriteNodeBegin(_T("w:r"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:r"), true);
//append rsids
if (0 != rev.Rsid)
......@@ -396,7 +392,7 @@ namespace DocFileFormat
m_context->AddRsid(rsidProp);
}
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
/// <w:rPr>
CharacterPropertiesMapping* rPr = new CharacterPropertiesMapping(m_pXmlWriter, m_document, &rev, _lastValidPapx, false);
......@@ -564,9 +560,9 @@ namespace DocFileFormat
if ( bFORM )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
......@@ -589,9 +585,9 @@ namespace DocFileFormat
&&
( ( bEMBED || bLINK ) && bChart) )
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
int cpPic = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::Picture );
......@@ -608,9 +604,9 @@ namespace DocFileFormat
if ((search( f.begin(), f.end(), TOC.begin(), TOC.end()) != f.end()) || bPAGE)
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
_writeInstrText = true;
_fldCharCounter++;
......@@ -638,9 +634,9 @@ namespace DocFileFormat
//if (_writeInstrText == true)
//{
// m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
// m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
// m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "separate" ) );
// m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
// m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
//}
_writeInstrText = false;
......@@ -678,10 +674,10 @@ namespace DocFileFormat
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
OleWriter.WriteNodeBegin (_T( "w:object" ), TRUE);
OleWriter.WriteNodeBegin (_T( "w:object" ), true);
OleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dxaGoal + ole.pictureDesciptor.dxaOrigin ) ).c_str() );
OleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( ole.pictureDesciptor.dyaGoal + ole.pictureDesciptor.dyaOrigin ) ).c_str() );
OleWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
OleWriter.WriteNodeEnd( _T( "" ), true, false );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &OleWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.GetShapeId() );
......@@ -692,10 +688,10 @@ namespace DocFileFormat
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
OleWriter.WriteNodeBegin (_T( "w:object" ), TRUE);
OleWriter.WriteNodeBegin (_T( "w:object" ), true);
OleWriter.WriteAttribute( _T( "w:dxaOrig" ), FormatUtils::IntToWideString( ( pic.dxaGoal + pic.dxaOrigin ) ).c_str() );
OleWriter.WriteAttribute( _T( "w:dyaOrig" ), FormatUtils::IntToWideString( ( pic.dyaGoal + pic.dyaOrigin ) ).c_str() );
OleWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
OleWriter.WriteNodeEnd( _T( "" ), true, false );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
......@@ -741,9 +737,9 @@ namespace DocFileFormat
}
else
{
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:fldChar" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:fldCharType" ), _T( "begin" ) );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
_writeInstrText = true;
_fldCharCounter++;
......@@ -787,10 +783,10 @@ namespace DocFileFormat
{
Symbol s = getSymbol( chpx );
m_pXmlWriter->WriteNodeBegin(_T("w:sym"), TRUE);
m_pXmlWriter->WriteNodeBegin(_T("w:sym"), true);
m_pXmlWriter->WriteAttribute(_T("w:font"), FormatUtils::XmlEncode(s.FontName).c_str());
m_pXmlWriter->WriteAttribute(_T("w:char"), FormatUtils::XmlEncode(s.HexValue).c_str());
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE);
m_pXmlWriter->WriteNodeEnd(_T(""), true);
}
else if ((TextMark::DrawnObject == code) && fSpec)
{
......@@ -807,20 +803,25 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
bool bOLE = pShape->isOLE();
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
m_pXmlWriter->WriteNodeBegin (L"w:pict");
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
m_pXmlWriter->WriteNodeEnd (L"w:pict");
}
if (!pSpa->primitives.empty())
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
pSpa->primitives.Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
......@@ -897,40 +898,40 @@ namespace DocFileFormat
{
if ((m_document->FootnoteReferenceCharactersPlex != NULL) && (m_document->FootnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteReference" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_footnoteNr++ ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->IndividualFootnotesPlex != NULL) && (m_document->IndividualFootnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpText)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:footnoteRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->EndnoteReferenceCharactersPlex != NULL) && (m_document->EndnoteReferenceCharactersPlex->IsCpExists(cp)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteReference" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString(_endnoteNr++ ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else if ((m_document->IndividualEndnotesPlex != NULL) &&
(m_document->IndividualEndnotesPlex->IsCpExists(cp - m_document->FIB->m_RgLw97.ccpAtn - m_document->FIB->m_RgLw97.ccpHdr - m_document->FIB->m_RgLw97.ccpFtn - m_document->FIB->m_RgLw97.ccpText)))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:endnoteRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
}
else if (TextMark::AnnotationReference == code)
{
if (typeid(*this) != typeid(CommentsMapping))
{
m_pXmlWriter->WriteNodeBegin( _T( "w:commentReference" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:commentReference" ), true );
m_pXmlWriter->WriteAttribute( _T( "w:id" ), FormatUtils::IntToWideString( _commentNr ).c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
else
{
m_pXmlWriter->WriteNodeBegin( _T( "w:annotationRef" ), TRUE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE );
m_pXmlWriter->WriteNodeBegin( _T( "w:annotationRef" ), true );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true );
}
_commentNr++;
......@@ -976,12 +977,12 @@ namespace DocFileFormat
{
std::wstring str = ( std::wstring( _T( "w:" ) ) + textType );
m_pXmlWriter->WriteNodeBegin( str.c_str(), TRUE );
m_pXmlWriter->WriteNodeBegin( str.c_str(), true );
if (preserve_space)
{
m_pXmlWriter->WriteAttribute( _T( "xml:space" ), _T( "preserve" ) );
}
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), true, false );
}
void DocumentMapping::writeTextEnd(const std::wstring& textType)
......
......@@ -125,9 +125,9 @@ namespace DocFileFormat
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx );
bool m_bInternalXmlWriter;
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
bool m_bInternalXmlWriter;
protected:
WordDocument* m_document;
......
......@@ -83,6 +83,20 @@ namespace DocFileFormat
}
return false;
}
bool isOLE()
{
int ret = 0;
for ( std::vector<Record*>::const_iterator iter = this->Children.begin(); iter != this->Children.end(); iter++ )
{
Shape* sh = dynamic_cast<Shape*>( *iter );
if (sh)
{
return sh->fOleShape;
}
}
return false;
}
virtual ~ShapeContainer()
{
}
......
......@@ -68,276 +68,18 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_)
{
isEquation = isEmbedded = false;
oleStorage = docStorage->GetStorage();
if ( ( chpx != NULL ) && ( docStorage != NULL ) )
{
HRESULT res = S_OK;
POLE::Stream* ObjectPoolStorage = new POLE::Stream(oleStorage, "ObjectPool");
if (ObjectPoolStorage)
{
ObjectId = getOleEntryName( chpx );
std::string sObjectId( ObjectId.begin(), ObjectId.end() );
{
std::string name = "ObjectPool/" + sObjectId + "/";
processOleStream( name + "Ole" );
if ( bLinked )
{
processLinkInfoStream( name + "LinkInfo" );
}
else
{
processCompObjStream( name + "CompObj" );
}
processPICStream( name + "PIC" );
processEquationNativeStream( name + "Equation Native" );
}
delete ObjectPoolStorage;
}
}
}
virtual ~OleObject()
{
}
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
virtual ~OleObject() {}
private:
POLE::Storage *oleStorage;
void processLinkInfoStream( const std::string& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
HRESULT res = S_OK;
pLinkStream = //oleStorage->stream(linkStream);
new POLE::Stream(oleStorage, linkStream);
if ( pLinkStream )
{
VirtualStreamReader reader( pLinkStream, 0, false);
//there are two versions of the Link string, one contains ANSI characters, the other contains
//unicode characters.
//Both strings seem not to be standardized:
//The length prefix is a character count EXCLUDING the terminating zero
//Read the ANSI version
short cch = reader.ReadInt16();
unsigned char* str = reader.ReadBytes( cch, true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, cch, ENCODING_WINDOWS_1250 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the ANSI string
//even if the characters are ANSI chars, the terminating zero has 2 bytes
reader.ReadBytes( 2, false );
//skip the next 4 bytes (flags?)
reader.ReadBytes( 4, false );
//Read the Unicode version
this->Link.clear();
cch = reader.ReadInt16();
str = reader.ReadBytes( ( cch * 2 ), true );
FormatUtils::GetSTLCollectionFromBytes<std::wstring>( &this->Link, str, ( cch * 2 ), ENCODING_UTF16 );
RELEASEARRAYOBJECTS( str );
//skip the terminating zero of the Unicode string
reader.ReadBytes( 2, false );
delete pLinkStream;
}
}
catch (...)
{
}
}
void processEquationNativeStream( const std::string& eqStream )
{
try
{
POLE::Stream* pCompStream = NULL;
HRESULT res = S_OK;
pCompStream = new POLE::Stream(oleStorage, eqStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
int sz = reader.GetSize();
unsigned char *Buffer = reader.ReadBytes( sz, true );
if (Buffer && sz > 0)
{
isEquation = true;
delete []Buffer;
}
delete pCompStream;
}
}
catch (...)
{
}
}
void processPICStream( const std::string& picStream )
{
try
{
HRESULT res = S_OK;
POLE::Stream* pPICStream = new POLE::Stream(oleStorage, picStream);
if ( pPICStream )
{
VirtualStreamReader reader( pPICStream, 0, false);
int sz = reader.GetSize();
int cbHeader = reader.ReadUInt32();
reader.ReadBytes(4, false);
int x = reader.ReadUInt32();
int y = reader.ReadUInt32();
pictureDesciptor.dyaGoal = reader.ReadUInt32();
pictureDesciptor.dxaGoal = reader.ReadUInt32();
reader.ReadBytes(20, false);
pictureDesciptor.mx = reader.ReadUInt32();
pictureDesciptor.my = reader.ReadUInt32();
}
}
catch (...)
{
}
}
void processCompObjStream( const std::string& compStream )
{
try
{
HRESULT res = S_OK;
void processLinkInfoStream ( const std::string& linkStream );
void processEquationNativeStream( const std::string& eqStream );
void processPICStream ( const std::string& picStream );
void processCompObjStream ( const std::string& compStream );
void processOleStream ( const std::string& oleStreamName );
POLE::Stream* pCompStream = new POLE::Stream(oleStorage, compStream);
if ( pCompStream )
{
VirtualStreamReader reader( pCompStream, 0, false);
//skip the CompObjHeader
reader.ReadBytes( 28, false );
int sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
{
UserType = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
ClipboardFormat = reader.ReadLengthPrefixedAnsiString(sz_obj);
sz_obj = reader.GetSize() - reader.GetPosition();
if (sz_obj > 4)
Program = reader.ReadLengthPrefixedAnsiString(sz_obj);
}
delete pCompStream;
}
}
catch (...)
{
}
}
void processOleStream( const std::string& oleStreamName )
{
try
{
POLE::Stream* pOleStream;
HRESULT res = S_OK;
pOleStream = new POLE::Stream(oleStorage, oleStreamName);
if ( pOleStream )
{
VirtualStreamReader reader( pOleStream, 0, false );
//skip version
reader.ReadBytes( 4, false );
//read the embedded/linked flag
int flag = reader.ReadInt32();
bLinked = FormatUtils::BitmaskToBool( flag, 0x1 );
//Link update option
this->updateMode = (LinkUpdateOption)reader.ReadInt32();
switch ( this->updateMode )
{
case NoLink:
{
this->UpdateMode = _T( "NoLink" );
}
break;
case Always:
{
this->UpdateMode = _T( "Always" );
}
break;
case OnCall:
{
this->UpdateMode = _T( "OnCall" );
}
break;
}
delete pOleStream;
}
}
catch (...)
{
}
}
std::wstring getOleEntryName( const CharacterPropertyExceptions* chpx )
{
std::wstring ret;
if ( chpx != NULL )
{
for ( std::list<SinglePropertyModifier>::const_iterator iter = chpx->grpprl->begin(); iter != chpx->grpprl->end(); iter++ )
{
if ( iter->OpCode == sprmCPicLocation || iter->OpCode == sprmOldCPicLocation)
{
ret = ( _T( "_" ) + FormatUtils::IntToWideString( FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
}
}
}
return ret;
}
};
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
};
}
......@@ -96,6 +96,8 @@ namespace DocFileFormat
{
friend class TextboxMapping;
public:
static const int STRUCTURE_SIZE = 22;
struct FTXBXSReusable
{
int iNextReuse;
......@@ -108,8 +110,6 @@ namespace DocFileFormat
int cTxbxEdit; // This value MUST be zero and MUST be ignored.
};
static const int STRUCTURE_SIZE = 22;
FTXBXS ()
{
......
......@@ -69,7 +69,7 @@ namespace DocFileFormat
m_pCaller = pCaller;
m_pBlipStore = NULL;
m_ctx = pConv;
m_context = pConv;
m_pict = pPicture;
m_nImageId = 0;
......@@ -81,9 +81,9 @@ namespace DocFileFormat
m_textpath = XMLTools::XMLElement<wchar_t>(L"v:textpath");
Record* recBs = NULL;
if ((m_ctx) && (m_ctx->_doc))
if ((m_context) && (m_context->_doc))
{
OfficeArtContent* officeArt = m_ctx->_doc->GetOfficeArt();
OfficeArtContent* officeArt = m_context->_doc->GetOfficeArt();
if (officeArt)
{
const DrawingGroup* group = officeArt->GetDrawingGroup();
......@@ -182,7 +182,7 @@ namespace DocFileFormat
ShapeContainer* pChildShape = static_cast<ShapeContainer*>(container->Children[i]);
if (pChildShape)
{
VMLShapeMapping vmlShapeMapping(m_ctx, m_pXmlWriter, m_pSpa, NULL, m_pCaller);
VMLShapeMapping vmlShapeMapping(m_context, m_pXmlWriter, m_pSpa, NULL, m_pCaller);
pChildShape->Convert(&vmlShapeMapping);
}
}
......@@ -215,12 +215,14 @@ namespace DocFileFormat
/// Converts a single shape
void VMLShapeMapping::WriteShape(const ShapeContainer* pContainer)
{
if ((NULL != pContainer) && (!pContainer->Children.empty()))
{
if ((NULL == pContainer) || (pContainer->Children.empty())) return;
Shape* pShape = static_cast<Shape*>(pContainer->Children[0]);
if (pShape)
{
if (!pShape) return;
int indexOLE = -1;
bool freeform = true;
std::wstring sShapeId;
std::list<OptionEntry> options = pContainer->ExtractOptions();
ChildAnchor* pAnchor = pContainer->FirstChildWithType<ChildAnchor>();
......@@ -228,15 +230,18 @@ namespace DocFileFormat
WriteBeginShapeNode (pShape);
m_pXmlWriter->WriteAttribute ( L"id", GetShapeID(pShape).c_str());
sShapeId = GetShapeID(pShape);
m_pXmlWriter->WriteAttribute ( L"id", sShapeId );
if (pShape->GetShapeType() && !pShape->fBackground )
if ( !pShape->fBackground )
{
if (pShape->GetShapeType())
{
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())).c_str());
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)).c_str());
}
if (pShape->is<LineType>())
{
......@@ -249,7 +254,7 @@ namespace DocFileFormat
{
m_pXmlWriter->WriteAttribute(L"o:bullet", L"t");
}
}
EmuValue ShadowOffsetX;
EmuValue ShadowOffsetY;
......@@ -415,10 +420,11 @@ namespace DocFileFormat
{
arrInscribe = GetTextRectangles(*iter);
}break;
// OUTLINE
// OUTLINE
case lineColor:
{
RGBColor lineColor((int)iter->op, RedFirst);
if ( !pShape->fBackground )
m_pXmlWriter->WriteAttribute( L"strokecolor", (std::wstring(L"#") + lineColor.SixDigitHexCode).c_str());
}break;
case lineWidth:
......@@ -461,7 +467,7 @@ namespace DocFileFormat
{
appendValueAttribute(&m_stroke, L"startarrowwidth", getArrowWidth( iter->op ).c_str());
}break;
// FILL
// FILL
case fillColor:
{
RGBColor fillColor((int)iter->op, RedFirst);
......@@ -521,7 +527,7 @@ namespace DocFileFormat
{
appendValueAttribute(&m_fill, L"opacity2", (FormatUtils::IntToWideString(iter->op) + L"f").c_str());
}break;
// SHADOW
// SHADOW
case shadowType:
{
appendValueAttribute(&m_shadow, L"type", getShadowType(iter->op).c_str());
......@@ -566,7 +572,12 @@ namespace DocFileFormat
{
shadowBoolean = ShadowStyleBooleanProperties(iter->op);
}break;
// PICTURE
// OLE
case pictureId:
{
indexOLE = iter->op;
}break;
// PICTURE
case Pib:
{
int index = (int)( iter->op - 1 );
......@@ -587,7 +598,7 @@ namespace DocFileFormat
if (!name.empty())
appendValueAttribute(&m_imagedata, L"o:title", FormatUtils::XmlEncode(name).c_str());
}break;
// 3D STYLE
// 3D STYLE
case f3D:
case threeDStyleBooleanProperties:
case threeDObjectBooleanProperties:
......@@ -651,7 +662,7 @@ namespace DocFileFormat
FixedPointNumber dOriginY( iter->op );
viewPointOriginY = (dOriginY.Integral / 65536.0 );
}break;
// TEXTBOX
// TEXTBOX
case lTxid:
{
hasTextbox = true;
......@@ -678,7 +689,7 @@ namespace DocFileFormat
break;
}
}break;
// Word Art
// Word Art
case gtextUNICODE:
{
std::wstring text = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
......@@ -818,7 +829,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( L"", true, false );
//build shadow offsets
//build shadow offsets
std::wstring offset;
if ( ShadowOffsetX != 0 )
......@@ -857,13 +868,13 @@ namespace DocFileFormat
appendValueAttribute(&m_shadow, L"offset2", offset2.c_str());
}
//build shadow origin
//build shadow origin
if ( ( ShadowOriginX != 0 ) && ( ShadowOriginY != 0 ) )
{
appendValueAttribute(&m_shadow, L"origin", (FormatUtils::DoubleToWideString(shadowOriginX) + std::wstring(L"," ) + FormatUtils::DoubleToWideString(shadowOriginY)).c_str());
}
// write shadow
// write shadow
if (m_shadow.GetAttributeCount() > 0)
{
if (shadowBoolean.fShadow)
......@@ -873,13 +884,13 @@ namespace DocFileFormat
m_pXmlWriter->WriteString(m_shadow.GetXMLString().c_str());
}
//write 3d style
//write 3d style
if (m_3dstyle.GetAttributeCount() > 0)
{
appendValueAttribute(&m_3dstyle, L"v:ext", L"view" );
appendValueAttribute(&m_3dstyle, L"on", L"t" );
//write the viewpoint
//write the viewpoint
if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) )
{
std::wstring viewPoint;
......@@ -901,7 +912,7 @@ namespace DocFileFormat
appendValueAttribute(&m_3dstyle, L"viewpoint", viewPoint.c_str());
}
// write the viewpointorigin
// write the viewpointorigin
if ( ( viewPointOriginX != 0 ) || ( viewPointOriginY != 0 ) )
{
std::wstring viewPointOrigin;
......@@ -922,7 +933,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteString(m_3dstyle.GetXMLString().c_str());
}
// write wrap
// write wrap
if (m_pSpa)
{
std::wstring wrap = getWrapType(m_pSpa);
......@@ -934,28 +945,33 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd ( L"w10:wrap", true );
}
}
// write stroke
if (m_stroke.GetAttributeCount())
{
m_pXmlWriter->WriteString(m_stroke.GetXMLString().c_str());
}
// write fill
// write fill
if (m_fill.GetAttributeCount())
{
m_pXmlWriter->WriteString(m_fill.GetXMLString().c_str());
}
// text path
if (m_textpath.GetAttributeCount())
{
appendValueAttribute(&m_textpath, L"style", FormatUtils::XmlEncode(m_textPathStyle).c_str());
m_pXmlWriter->WriteString(m_textpath.GetXMLString().c_str());
}
// write imagedata
// write imagedata
if (m_imagedata.GetAttributeCount())
{
m_pXmlWriter->WriteString(m_imagedata.GetXMLString().c_str());
}
if ( pShape->fBackground )
{
WriteEndShapeNode(pShape);
return;
}
// write stroke
if (m_stroke.GetAttributeCount())
{
m_pXmlWriter->WriteString(m_stroke.GetXMLString().c_str());
}
// text path
if (m_textpath.GetAttributeCount())
{
appendValueAttribute(&m_textpath, L"style", FormatUtils::XmlEncode(m_textPathStyle).c_str());
m_pXmlWriter->WriteString(m_textpath.GetXMLString().c_str());
}
if (freeform)
{
if (arrInscribe.size())
......@@ -965,7 +981,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd(L"", true);
}
}
// TEXTBOX
// TEXTBOX
OfficeArtClientTextbox* pTextBox = pContainer->FirstChildWithType<OfficeArtClientTextbox>();
if (pTextBox)
{
......@@ -977,11 +993,11 @@ namespace DocFileFormat
int nIndex = pTextBox->GetIndex();
if (nIndex)
{
TextboxMapping textboxMapping(m_ctx, nIndex - 1, m_pXmlWriter, m_pCaller);
TextboxMapping textboxMapping(m_context, nIndex - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
textboxMapping.SetTextboxStyle(sTextboxStyle);
m_ctx->_doc->Convert(&textboxMapping);
m_context->_doc->Convert(&textboxMapping);
}
}
else if( hasTextbox )
......@@ -994,28 +1010,32 @@ namespace DocFileFormat
if (-1 != nLTxID)
{
TextboxMapping textboxMapping(m_ctx, nLTxID - 1, m_pXmlWriter, m_pCaller);
TextboxMapping textboxMapping(m_context, nLTxID - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_ctx->_doc->Convert(&textboxMapping);
m_context->_doc->Convert(&textboxMapping);
}
else
{
TextboxMapping textboxMapping(m_ctx, m_pXmlWriter, m_pCaller);
TextboxMapping textboxMapping(m_context, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_ctx->_doc->Convert(&textboxMapping);
m_context->_doc->Convert(&textboxMapping);
}
}
// OLE
if (indexOLE >= 0 && pShape->fOleShape)
{
TextboxMapping textboxMapping(m_context, 0, m_pXmlWriter, m_pCaller);
m_context->_doc->Convert(&textboxMapping);
}
WriteEndShapeNode(pShape);
//ShapeType
if (NULL != pShape->GetShapeType() && !pShape->fBackground /* && !m_isInlineShape*/) //bullete only???
//ShapeType
if (NULL != pShape->GetShapeType() /* && !m_isInlineShape*/) //bullete only???
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
}
}
}
//
void VMLShapeMapping::WriteBeginShapeNode (const Shape* pShape)
......@@ -1028,22 +1048,18 @@ namespace DocFileFormat
}
else if (pShape->is<OvalType>())
{
//OVAL
m_pXmlWriter->WriteNodeBegin( L"v:oval", true );
}
else if (pShape->is<RoundedRectangleType>())
{
//ROUNDED RECT
m_pXmlWriter->WriteNodeBegin( L"v:roundrect", true );
}
else if (pShape->is<RectangleType>())
{
//RECT
m_pXmlWriter->WriteNodeBegin( L"v:rect", true );
}
else if (pShape->is<LineType>())
{
//LINE
m_pXmlWriter->WriteNodeBegin(L"v:line", true);
}
else
......@@ -1192,7 +1208,7 @@ namespace DocFileFormat
//write the blip
if (oBlip)
{
VirtualStreamReader reader(m_ctx->_doc->WordDocumentStream, oBlip->foDelay, m_ctx->_doc->FIB->m_bOlderVersion);
VirtualStreamReader reader(m_context->_doc->WordDocumentStream, oBlip->foDelay, m_context->_doc->FIB->m_bOlderVersion);
switch (oBlip->btWin32)
{
......@@ -1210,7 +1226,7 @@ namespace DocFileFormat
decompressedSize = metaBlip->Decompress(&decompressed);
if (0 != decompressedSize && NULL != decompressed)
{
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), std::vector<unsigned char>(decompressed, (decompressed + decompressedSize))));
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32), std::vector<unsigned char>(decompressed, (decompressed + decompressedSize))));
RELEASEARRAYOBJECTS(decompressed);
}
......@@ -1229,7 +1245,7 @@ namespace DocFileFormat
BitmapBlip* bitBlip = static_cast<BitmapBlip*>(RecordFactory::ReadRecord(&reader, 0));
if ((bitBlip) && (bitBlip->m_pvBits))
{
m_ctx->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32),
m_context->_docx->ImagesList.push_back(ImageFileStructure(GetTargetExt(oBlip->btWin32),
std::vector<unsigned char>(bitBlip->m_pvBits, (bitBlip->m_pvBits + bitBlip->pvBitsSize)), oBlip->btWin32));
RELEASEOBJECT (bitBlip);
}
......@@ -1244,7 +1260,7 @@ namespace DocFileFormat
break;
}
m_nImageId = m_ctx->_docx->RegisterImage (m_pCaller, oBlip->btWin32);
m_nImageId = m_context->_docx->RegisterImage (m_pCaller, oBlip->btWin32);
result = true;
}
......@@ -1957,9 +1973,9 @@ namespace DocFileFormat
if (-1 != nLTxID)
{
TextboxMapping textboxMapping(m_ctx, nLTxID - 1, m_pXmlWriter, m_pCaller);
TextboxMapping textboxMapping(m_context, nLTxID - 1, m_pXmlWriter, m_pCaller);
//textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_ctx->_doc->Convert(&textboxMapping);
m_context->_doc->Convert(&textboxMapping);
}
}
......
......@@ -129,7 +129,7 @@ namespace DocFileFormat
BlipStoreContainer* m_pBlipStore;
int m_nImageId;
std::wstring m_textPathStyle;
ConversionContext* m_ctx;
ConversionContext* m_context;
PictureDescriptor* m_pict;
XMLTools::XMLElement<wchar_t> m_fill;
......
......@@ -268,7 +268,7 @@ namespace DocFileFormat
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, bOlderVersion);
OfficeDrawingPlexHeader = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaHdr, FIB->m_FibWord97.lcbPlcSpaHdr, bOlderVersion);
TextboxIndividualPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
TextboxIndividualPlex = new Plex<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
SectionPlex = new Plex<SectionDescriptor> (SectionDescriptor::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfSed, FIB->m_FibWord97.lcbPlcfSed, bOlderVersion);
BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion);
......
......@@ -187,7 +187,7 @@ namespace DocFileFormat
Plex<EmptyStructure> *HeaderStoriesPlex; //A plex of the header document
Plex<EmptyStructure> *IndividualCommentsPlex; // A plex with all ATRDPre10 structs
Plex<EmptyStructure> *TextboxIndividualPlex;
Plex<FTXBXS> *TextboxIndividualPlex;
Plex<Tbkd> *TextboxBreakPlex; // Describes the breaks inside the textbox subdocument
Plex<Tbkd> *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument
......
......@@ -555,6 +555,10 @@
RelativePath="..\..\DocDocxConverter\OfficeArtContent.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.cpp"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.h"
>
......
......@@ -98,7 +98,10 @@ SOURCES += \
../source/Oox2OdfConverter/ConverterChart.cpp \
../source/Oox2OdfConverter/ConvertVml.cpp \
../source/Oox2OdfConverter/DocxConverter.cpp \
../source/Oox2OdfConverter/XlsxConverter.cpp
../source/Oox2OdfConverter/XlsxConverter.cpp \
../source/OdfFormat/odf_settings_context.cpp \
../source/OdfFormat/office_settings.cpp \
../source/OdfFormat/mediaitems_utils.cpp
}
......@@ -183,7 +186,3 @@ HEADERS += \
../source/OdfFormat/Shapes/oox_shapeWordArt.h \
../source/OdfFormat/odf_settings_context.h \
../source/OdfFormat/office_settings.h
SOURCES += \
../source/OdfFormat/odf_settings_context.cpp \
../source/OdfFormat/office_settings.cpp
......@@ -1218,7 +1218,7 @@ CString RtfStyle::RenderToOOXBegin(RenderParameter oRenderParameter)
if( PROP_DEF != m_bPersonal ) sResult += L"<w:personal w:val=\"true\" />";
if( PROP_DEF != m_bCompose ) sResult += L"<w:personalCompose w:val=\"true\" />";
if( PROP_DEF != m_bReply ) sResult += L"<w:personalReply w:val=\"true\" />";
if( PROP_DEF == m_nSemiHidden ) sResult += L"<w:semiHidden/>";
if( 1 == m_nSemiHidden ) sResult += L"<w:semiHidden/>";
if( PROP_DEF != m_bQFormat ) sResult += L"<w:qformat/>";
if( PROP_DEF != m_nPriority ) sResult.AppendFormat(L"<w:uiPriority w:val=\"%d\"/>",m_nPriority);
if( PROP_DEF != m_bUnhiddenWhenUse ) sResult += L"<w:unhideWhenUsed/>";
......
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