Commit ea5ebe72 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - another ole objects(pictureId)

parent 50224310
...@@ -766,18 +766,11 @@ namespace DocFormatUtils ...@@ -766,18 +766,11 @@ namespace DocFormatUtils
static inline std::wstring IntToWideString(int value) 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)); return (std::to_wstring(value));
#endif
} }
static inline std::wstring DoubleToWideString(double value) static inline std::wstring DoubleToWideString(double value)
{ {
std::wstringstream src; std::wstringstream src;
src << value; src << value;
return std::wstring(src.str()); return std::wstring(src.str());
...@@ -785,8 +778,7 @@ namespace DocFormatUtils ...@@ -785,8 +778,7 @@ namespace DocFormatUtils
static inline std::string DoubleToString(double value) static inline std::string DoubleToString(double value)
{ {
std::stringstream src; std::stringstream src;
src << value; src << value;
return std::string(src.str()); return std::string(src.str());
...@@ -813,36 +805,16 @@ namespace DocFormatUtils ...@@ -813,36 +805,16 @@ namespace DocFormatUtils
static inline std::wstring IntToFormattedWideString( int value, const wchar_t* format ) 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""; if ( format == NULL ) return L"";
// swprintf_s( strValue, size, format, value );
//// }
// CString format_str;
// format_str.Format(format , value);
std::wstringstream sstream; std::wstringstream sstream;
sstream << boost::wformat(format) % value; sstream << boost::wformat(format) % value;
return sstream.str(); return sstream.str();
//return string2std_string( format_str );
} }
static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format ) static inline std::wstring DoubleToFormattedWideString( double value, wchar_t* format )
{ {
if ( format == NULL ) return L""; 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; std::wstringstream sstream;
sstream << boost::wformat(format) % value; sstream << boost::wformat(format) % value;
return sstream.str(); return sstream.str();
......
...@@ -125,9 +125,9 @@ namespace DocFileFormat ...@@ -125,9 +125,9 @@ namespace DocFileFormat
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark ); int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
private: private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx ); Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
bool m_bInternalXmlWriter;
bool m_bInternalXmlWriter;
protected: protected:
WordDocument* m_document; WordDocument* m_document;
......
...@@ -83,6 +83,20 @@ namespace DocFileFormat ...@@ -83,6 +83,20 @@ namespace DocFileFormat
} }
return false; 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() virtual ~ShapeContainer()
{ {
} }
......
...@@ -68,276 +68,18 @@ namespace DocFileFormat ...@@ -68,276 +68,18 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor; PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ ) OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_) virtual ~OleObject() {}
{
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()
{
}
private: private:
POLE::Storage *oleStorage; POLE::Storage *oleStorage;
void processLinkInfoStream( const std::string& linkStream ) void processLinkInfoStream ( const std::string& linkStream );
{ void processEquationNativeStream( const std::string& eqStream );
try void processPICStream ( const std::string& picStream );
{ void processCompObjStream ( const std::string& compStream );
POLE::Stream* pLinkStream = NULL; void processOleStream ( const std::string& oleStreamName );
HRESULT res = S_OK;
std::wstring getOleEntryName ( const CharacterPropertyExceptions* chpx );
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;
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;
}
};
} }
...@@ -96,6 +96,8 @@ namespace DocFileFormat ...@@ -96,6 +96,8 @@ namespace DocFileFormat
{ {
friend class TextboxMapping; friend class TextboxMapping;
public: public:
static const int STRUCTURE_SIZE = 22;
struct FTXBXSReusable struct FTXBXSReusable
{ {
int iNextReuse; int iNextReuse;
...@@ -108,8 +110,6 @@ namespace DocFileFormat ...@@ -108,8 +110,6 @@ namespace DocFileFormat
int cTxbxEdit; // This value MUST be zero and MUST be ignored. int cTxbxEdit; // This value MUST be zero and MUST be ignored.
}; };
static const int STRUCTURE_SIZE = 22;
FTXBXS () FTXBXS ()
{ {
......
...@@ -129,7 +129,7 @@ namespace DocFileFormat ...@@ -129,7 +129,7 @@ namespace DocFileFormat
BlipStoreContainer* m_pBlipStore; BlipStoreContainer* m_pBlipStore;
int m_nImageId; int m_nImageId;
std::wstring m_textPathStyle; std::wstring m_textPathStyle;
ConversionContext* m_ctx; ConversionContext* m_context;
PictureDescriptor* m_pict; PictureDescriptor* m_pict;
XMLTools::XMLElement<wchar_t> m_fill; XMLTools::XMLElement<wchar_t> m_fill;
......
...@@ -268,7 +268,7 @@ namespace DocFileFormat ...@@ -268,7 +268,7 @@ namespace DocFileFormat
OfficeDrawingPlex = new Plex<Spa> (Spa::GetSize(bOlderVersion), TableStream, FIB->m_FibWord97.fcPlcSpaMom, FIB->m_FibWord97.lcbPlcSpaMom, bOlderVersion); 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); 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); 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); BookmarkStartPlex = new Plex<BookmarkFirst> (BookmarkFirst::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBkf, FIB->m_FibWord97.lcbPlcfBkf, bOlderVersion);
......
...@@ -187,7 +187,7 @@ namespace DocFileFormat ...@@ -187,7 +187,7 @@ namespace DocFileFormat
Plex<EmptyStructure> *HeaderStoriesPlex; //A plex of the header document Plex<EmptyStructure> *HeaderStoriesPlex; //A plex of the header document
Plex<EmptyStructure> *IndividualCommentsPlex; // A plex with all ATRDPre10 structs 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> *TextboxBreakPlex; // Describes the breaks inside the textbox subdocument
Plex<Tbkd> *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument Plex<Tbkd> *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument
......
...@@ -555,6 +555,10 @@ ...@@ -555,6 +555,10 @@
RelativePath="..\..\DocDocxConverter\OfficeArtContent.h" RelativePath="..\..\DocDocxConverter\OfficeArtContent.h"
> >
</File> </File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.cpp"
>
</File>
<File <File
RelativePath="..\..\DocDocxConverter\OleObject.h" RelativePath="..\..\DocDocxConverter\OleObject.h"
> >
......
...@@ -98,7 +98,10 @@ SOURCES += \ ...@@ -98,7 +98,10 @@ SOURCES += \
../source/Oox2OdfConverter/ConverterChart.cpp \ ../source/Oox2OdfConverter/ConverterChart.cpp \
../source/Oox2OdfConverter/ConvertVml.cpp \ ../source/Oox2OdfConverter/ConvertVml.cpp \
../source/Oox2OdfConverter/DocxConverter.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 += \ ...@@ -183,7 +186,3 @@ HEADERS += \
../source/OdfFormat/Shapes/oox_shapeWordArt.h \ ../source/OdfFormat/Shapes/oox_shapeWordArt.h \
../source/OdfFormat/odf_settings_context.h \ ../source/OdfFormat/odf_settings_context.h \
../source/OdfFormat/office_settings.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) ...@@ -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_bPersonal ) sResult += L"<w:personal w:val=\"true\" />";
if( PROP_DEF != m_bCompose ) sResult += L"<w:personalCompose 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_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_bQFormat ) sResult += L"<w:qformat/>";
if( PROP_DEF != m_nPriority ) sResult.AppendFormat(L"<w:uiPriority w:val=\"%d\"/>",m_nPriority); if( PROP_DEF != m_nPriority ) sResult.AppendFormat(L"<w:uiPriority w:val=\"%d\"/>",m_nPriority);
if( PROP_DEF != m_bUnhiddenWhenUse ) sResult += L"<w:unhideWhenUsed/>"; 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