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;
std::wstringstream src;
src << value;
return std::wstring(src.str());
......@@ -785,8 +778,7 @@ namespace DocFormatUtils
static inline std::string DoubleToString(double value)
{
std::stringstream src;
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;
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;
}
};
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 );
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,806 +215,826 @@ namespace DocFileFormat
/// Converts a single shape
void VMLShapeMapping::WriteShape(const ShapeContainer* pContainer)
{
if ((NULL != pContainer) && (!pContainer->Children.empty()))
{
Shape* pShape = static_cast<Shape*>(pContainer->Children[0]);
if (pShape)
{
bool freeform = true;
if ((NULL == pContainer) || (pContainer->Children.empty())) return;
std::list<OptionEntry> options = pContainer->ExtractOptions();
ChildAnchor* pAnchor = pContainer->FirstChildWithType<ChildAnchor>();
ClientAnchor* clientAnchor = pContainer->FirstChildWithType<ClientAnchor>();
Shape* pShape = static_cast<Shape*>(pContainer->Children[0]);
if (!pShape) return;
int indexOLE = -1;
bool freeform = true;
std::wstring sShapeId;
WriteBeginShapeNode (pShape);
std::list<OptionEntry> options = pContainer->ExtractOptions();
ChildAnchor* pAnchor = pContainer->FirstChildWithType<ChildAnchor>();
ClientAnchor* clientAnchor = pContainer->FirstChildWithType<ClientAnchor>();
m_pXmlWriter->WriteAttribute ( L"id", GetShapeID(pShape).c_str());
WriteBeginShapeNode (pShape);
if (pShape->GetShapeType() && !pShape->fBackground )
{
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())).c_str());
}
sShapeId = GetShapeID(pShape);
m_pXmlWriter->WriteAttribute ( L"id", sShapeId );
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)).c_str());
if ( !pShape->fBackground )
{
if (pShape->GetShapeType())
{
freeform = false;
m_pXmlWriter->WriteAttribute( L"type", (std::wstring(L"#") + VMLShapeTypeMapping::GenerateTypeId(pShape->GetShapeType())).c_str());
if (pShape->is<LineType>())
{
//append "from" and "to" attributes
m_pXmlWriter->WriteAttribute(L"from", GetLineFrom(pAnchor).c_str());
m_pXmlWriter->WriteAttribute(L"to", GetLineTo(pAnchor).c_str());
}
m_pXmlWriter->WriteAttribute( L"style", FormatUtils::XmlEncode(buildStyle(pShape, pAnchor, options, pContainer->Index)).c_str());
}
if (m_isBullete)
{
m_pXmlWriter->WriteAttribute(L"o:bullet", L"t");
}
if (pShape->is<LineType>())
{
//append "from" and "to" attributes
m_pXmlWriter->WriteAttribute(L"from", GetLineFrom(pAnchor).c_str());
m_pXmlWriter->WriteAttribute(L"to", GetLineTo(pAnchor).c_str());
}
EmuValue ShadowOffsetX;
EmuValue ShadowOffsetY;
EmuValue SecondShadowOffsetX;
EmuValue SecondShadowOffsetY;
EmuValue ViewPointX;
EmuValue ViewPointY;
EmuValue ViewPointZ;
double viewPointOriginX = 0;
double viewPointOriginY = 0;
double ShadowOriginX = 0;
double ShadowOriginY = 0;
unsigned int xCoord = 0;
unsigned int yCoord = 0;
bool stroked = true;
bool filled = true;
bool hasTextbox = false;
bool layoutInCell = true; //anmeldebogenfos.doc
int ndxTextLeft = -1;
int ndyTextTop = -1;
int ndxTextRight = -1;
int ndyTextBottom = -1;
if (m_isBullete)
{
m_pXmlWriter->WriteAttribute(L"o:bullet", L"t");
}
}
bool bHavePath = false;
int nAdjValues = 0;
int nLTxID = -1;
EmuValue ShadowOffsetX;
EmuValue ShadowOffsetY;
EmuValue SecondShadowOffsetX;
EmuValue SecondShadowOffsetY;
EmuValue ViewPointX;
EmuValue ViewPointY;
EmuValue ViewPointZ;
double viewPointOriginX = 0;
double viewPointOriginY = 0;
double ShadowOriginX = 0;
double ShadowOriginY = 0;
unsigned int xCoord = 0;
unsigned int yCoord = 0;
bool stroked = true;
bool filled = true;
bool hasTextbox = false;
bool layoutInCell = true; //anmeldebogenfos.doc
int ndxTextLeft = -1;
int ndyTextTop = -1;
int ndxTextRight = -1;
int ndyTextBottom = -1;
std::wstring sTextboxStyle;
std::wstring adjValues[8];
ShadowStyleBooleanProperties shadowBoolean(0);
std::vector<std::wstring> arrInscribe;
bool bHavePath = false;
int nAdjValues = 0;
int nLTxID = -1;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
std::wstring sTextboxStyle;
std::wstring adjValues[8];
ShadowStyleBooleanProperties shadowBoolean(0);
std::vector<std::wstring> arrInscribe;
std::list<OptionEntry>::const_iterator end = options.end();
for (std::list<OptionEntry>::const_iterator iter = options.begin(); iter != end; ++iter)
{
switch (iter->pid)
{
//BOOLEANS
case geometryBooleans:
{
switch (iter->pid)
GeometryBooleanProperties booleans(iter->op);
if (booleans.fUsefLineOK && !booleans.fLineOK)
{
//BOOLEANS
case geometryBooleans:
{
GeometryBooleanProperties booleans(iter->op);
if (booleans.fUsefLineOK && !booleans.fLineOK)
{
stroked = false;
}
if (booleans.fUsefFillOK && !booleans.fFillOK)
{
filled = false;
}
}
break;
case fillStyleBooleanProperties:
{
FillStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefFilled && !booleans.fFilled)
{
filled = false;
}
}break;
case lineStyleBooleans:
{
LineStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefLine && !booleans.fLine)
{
stroked = false;
}
}
break;
case protectionBooleans:
{
ProtectionBooleanProperties booleans(iter->op);
}
break;
case diagramBooleans:
{
DiagramBooleanProperties booleans(iter->op);
}
break;
case groupShapeBooleans:
{
GroupShapeBooleanProperties booleans(iter->op);
if (booleans.fUsefLayoutInCell)
{
layoutInCell = booleans.fLayoutInCell;
}
}
break;
// GEOMETRY
case adjustValue:
{
adjValues[0] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,1);
}
break;
case adjust2Value:
{
adjValues[1] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,2);
}
break;
case adjust3Value:
{
adjValues[2] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,3);
}break;
case adjust4Value:
{
adjValues[3] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,4);
}break;
case adjust5Value:
{
adjValues[4] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,5);
}break;
case adjust6Value:
{
adjValues[5] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,6);
}break;
case adjust7Value:
{
adjValues[6] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,7);
}break;
case adjust8Value:
{
adjValues[7] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,8);
}break;
case pWrapPolygonVertices:
{
std::wstring wrapCoords = getWrapCoords(*iter);
if (!wrapCoords.empty())
{
m_pXmlWriter->WriteAttribute( L"wrapcoords", wrapCoords.c_str() );
}
}break;
case geoRight:
{
xCoord = iter->op;
}break;
case geoBottom:
{
yCoord = iter->op;
}break;
case pGuides:
{
}break;
case pInscribe:
{
arrInscribe = GetTextRectangles(*iter);
}break;
// OUTLINE
case lineColor:
{
RGBColor lineColor((int)iter->op, RedFirst);
m_pXmlWriter->WriteAttribute( L"strokecolor", (std::wstring(L"#") + lineColor.SixDigitHexCode).c_str());
}break;
case lineWidth:
{
if (iter->op > 0)
{
EmuValue eLineWidth ((int)iter->op );
m_pXmlWriter->WriteAttribute(L"strokeweight", FormatUtils::DoubleToWideString(eLineWidth.ToPoints()) + L"pt");
}
}break;
case lineDashing:
{
appendValueAttribute(&m_stroke, L"dashstyle", FormatUtils::MapValueToWideString( iter->op, &Global::DashStyleMap[0][0], 11, 16 ).c_str() );
}break;
case lineStyle:
{
appendValueAttribute(&m_stroke, L"linestyle", getLineStyle( iter->op ).c_str());
}break;
case lineEndArrowhead:
{
appendValueAttribute(&m_stroke, L"endarrow", getArrowStyle( iter->op ).c_str());
}break;
case lineEndArrowLength:
{
appendValueAttribute(&m_stroke, L"endarrowlength", getArrowLength( iter->op ).c_str());
}break;
case lineEndArrowWidth:
{
appendValueAttribute(&m_stroke, L"endarrowwidth", getArrowWidth( iter->op ).c_str());
}break;
case lineStartArrowhead:
{
appendValueAttribute(&m_stroke, L"startarrow", getArrowStyle( iter->op ).c_str());
}break;
case lineStartArrowLength:
{
appendValueAttribute(&m_stroke, L"startarrowlength", getArrowLength( iter->op ).c_str());
}break;
case lineStartArrowWidth:
{
appendValueAttribute(&m_stroke, L"startarrowwidth", getArrowWidth( iter->op ).c_str());
}break;
// FILL
case fillColor:
{
RGBColor fillColor((int)iter->op, RedFirst);
m_pXmlWriter->WriteAttribute(L"fillcolor", ( std::wstring( L"#" ) + fillColor.SixDigitHexCode ).c_str());
}break;
case fillBackColor:
{
RGBColor fillBackColor( (int)iter->op, RedFirst );
appendValueAttribute(&m_fill, L"color2", ( std::wstring( L"#" ) + fillBackColor.SixDigitHexCode ).c_str());
}break;
case fillAngle:
{
FixedPointNumber fllAngl( iter->op );
appendValueAttribute(&m_fill, L"angle", FormatUtils::DoubleToWideString( fllAngl.ToAngle() ).c_str());
}break;
case fillShadeType:
{
appendValueAttribute(&m_fill, L"method", getFillMethod( iter->op ).c_str());
}break;
case fillShadeColors:
{
appendValueAttribute(&m_fill, L"colors", getFillColorString( iter->opComplex, iter->op ).c_str());
}break;
case fillFocus:
{
appendValueAttribute(&m_fill, L"focus", ( FormatUtils::IntToWideString( iter->op ) + L"%" ).c_str());
}break;
case fillType:
{
appendValueAttribute(&m_fill, L"type", getFillType( iter->op ).c_str());
}break;
case fillBlip:
{
BlipStoreEntry* pFillBlip = NULL;
if ((m_pict != NULL ) && (m_pict->blipStoreEntry != NULL ))
{
// Word Art Texture
//fillBlip = this->_pict->BlipStoreEntry;
}
else if ( (m_pBlipStore != NULL) && ( (iter->op - 1) < m_pBlipStore->Children.size() ) )
{
pFillBlip = static_cast<BlipStoreEntry*>(m_pBlipStore->Children[iter->op - 1]);
}
if ( (pFillBlip != NULL) && copyPicture(pFillBlip) )
{
appendValueAttribute(&m_fill, L"r:id", std::wstring(( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
}
}break;
case fillOpacity:
{
appendValueAttribute(&m_fill, L"opacity", ( FormatUtils::IntToWideString( iter->op ) + L"f" ).c_str());
}
break;
case fillBackOpacity:
{
appendValueAttribute(&m_fill, L"opacity2", (FormatUtils::IntToWideString(iter->op) + L"f").c_str());
}break;
// SHADOW
case shadowType:
{
appendValueAttribute(&m_shadow, L"type", getShadowType(iter->op).c_str());
}break;
case shadowColor:
{
RGBColor shadowColor((int)iter->op, RedFirst);
appendValueAttribute(&m_shadow, L"color", ( std::wstring( L"#" ) + shadowColor.SixDigitHexCode ).c_str());
}break;
case shadowOffsetX:
{
ShadowOffsetX = EmuValue( (int)iter->op );
}break;
case shadowSecondOffsetX:
{
SecondShadowOffsetX = EmuValue( (int)iter->op );
}break;
case shadowOffsetY:
{
ShadowOffsetY = EmuValue( (int)iter->op );
}break;
case shadowSecondOffsetY:
{
SecondShadowOffsetY = EmuValue( (int)iter->op );
}break;
case shadowOriginX:
{
ShadowOriginX = ( iter->op / pow( (double)2, (double)16 ) );
}break;
case shadowOriginY:
{
ShadowOriginY = (iter->op / pow( (double)2, (double)16));
}break;
case shadowOpacity:
{
double shadowOpa = (iter->op / pow( (double)2, (double)16));
appendValueAttribute(&m_shadow, L"opacity", FormatUtils::DoubleToFormattedWideString( shadowOpa, L"%.2f" ).c_str());
}break;
case shadowStyleBooleanProperties:
{
shadowBoolean = ShadowStyleBooleanProperties(iter->op);
}break;
// PICTURE
case Pib:
{
int index = (int)( iter->op - 1 );
if ((m_pBlipStore != NULL) && (index < (int)m_pBlipStore->Children.size()))
{
BlipStoreEntry* oBlip = static_cast<BlipStoreEntry*>(m_pBlipStore->Children[index]);
if (copyPicture(oBlip))
{
appendValueAttribute(&m_imagedata, L"r:id", ( std::wstring( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
}
}
}break;
case pibName:
{
std::wstring name;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex, iter->op, ENCODING_UTF16);
if (!name.empty())
appendValueAttribute(&m_imagedata, L"o:title", FormatUtils::XmlEncode(name).c_str());
}break;
// 3D STYLE
case f3D:
case threeDStyleBooleanProperties:
case threeDObjectBooleanProperties:
break;
case c3DExtrudeBackward:
{
EmuValue backwardValue( (int)iter->op );
std::wstring depth = FormatUtils::DoubleToWideString( backwardValue.ToPoints() ) + L"pt";
appendValueAttribute(&m_3dstyle, L"backdepth", depth.c_str());
}break;
case c3DAmbientIntensity:
{
std::wstring intens = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"brightness", intens.c_str());
}break;
case c3DSpecularAmt:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"specularity", amt.c_str());
}break;
case c3DDiffuseAmt:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"diffusity", amt.c_str());
}break;
case c3DKeyIntensity:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op);
appendValueAttribute(&m_3dstyle, L"lightlevel", amt.c_str());
}break;
case c3DExtrusionColor:
{
std::wstring color = FormatUtils::IntToFormattedWideString(iter->op, L"#%06x");
appendValueAttribute(&m_3dstyle, L"color", color.c_str());
}break;
case c3DSkewAngle:
{
FixedPointNumber skewAngle( iter->op );
appendValueAttribute(&m_3dstyle, L"skewangle", FormatUtils::DoubleToWideString( skewAngle.ToAngle() ).c_str());
}break;
case c3DXViewpoint:
{
ViewPointX = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DYViewpoint:
{
ViewPointY = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DZViewpoint:
{
ViewPointZ = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DOriginX:
{
FixedPointNumber dOriginX( iter->op );
viewPointOriginX = ( dOriginX.Integral / 65536.0 );
}break;
case c3DOriginY:
{
FixedPointNumber dOriginY( iter->op );
viewPointOriginY = (dOriginY.Integral / 65536.0 );
}break;
// TEXTBOX
case lTxid:
{
hasTextbox = true;
nLTxID = (((iter->op) >> 16) & 0xFFFF);
}break;
case dxTextLeft: {ndxTextLeft = (int)iter->op;break;}
case dyTextTop: {ndyTextTop = (int)iter->op;break;}
case dxTextRight: {ndxTextRight = (int)iter->op;break;}
case dyTextBottom: {ndyTextBottom = (int)iter->op;break;}
case txflTextFlow:
{
switch(iter->op)
{
case 0:
case 4://обычный
break;
case 1:
case 5://верт (склони голову направо)
appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical");
break;
case 2://верт (склони голову налево)
appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical");
appendStyleProperty(&sTextboxStyle, L"mso-layout-flow-alt", L"bottom-to-top");
break;
}
}break;
// Word Art
case gtextUNICODE:
{
std::wstring text = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
text = FormatUtils::XmlEncode(text);
if (0 <= text.find(L"\n"))
{
m_textpath.AppendText(text.c_str());
}
text = ReplaceString(text, L"\n", L"&#xA;");
appendValueAttribute(&m_textpath, L"string", text.c_str());
}break;
case gtextFont:
{
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
int i = font.size();
while (i > 0)
{
if (font[i-1] != 0) break;
i--;
}
if (i < font.size()) font.erase(font.begin() + i, font.end());
font = std::wstring(L"\"") + font + std::wstring(L"\"");
appendStyleProperty(&m_textPathStyle, L"font-family", font);
}break;
case gtextSize:
{
std::wstring fontSize = FormatUtils::IntToWideString(iter->op/65535);
appendStyleProperty(&m_textPathStyle, L"font-size", fontSize + L"pt");
}break;
case gtextSpacing:
{
std::wstring spacing = FormatUtils::IntToWideString(iter->op);
appendStyleProperty(&m_textPathStyle, L"v-text-spacing", spacing + L"f");
}break;
case geometryTextBooleanProperties:
{
GeometryTextBooleanProperties props(iter->op);
if (props.fUsegtextFBestFit && props.gtextFBestFit)
{
appendValueAttribute(&m_textpath, L"fitshape", L"t");
}
if (props.fUsegtextFShrinkFit && props.gtextFShrinkFit)
{
appendValueAttribute(&m_textpath, L"trim", L"t");
}
if (props.fUsegtextFVertical && props.gtextFVertical)
{
appendStyleProperty(&m_textPathStyle, L"v-rotate-letters", L"t");
//_twistDimension = true;
}
if (props.fUsegtextFKern && props.gtextFKern)
{
appendStyleProperty(&m_textPathStyle, L"v-text-kern", L"t");
}
if (props.fUsegtextFItalic && props.gtextFItalic)
{
appendStyleProperty(&m_textPathStyle, L"font-style", L"italic");
}
if (props.fUsegtextFBold && props.gtextFBold)
{
appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold");
}
}break;
// PATH
case shapePath :
{
bHavePath = true;
std::wstring path = ParsePath(options);
stroked = false;
}
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path.c_str());
}break;
default:
{
int val = iter->op;
}break;
if (booleans.fUsefFillOK && !booleans.fFillOK)
{
filled = false;
}
}
if (false == bHavePath) // фигура может быть задана только наборами вершин и индексов
break;
case fillStyleBooleanProperties:
{
std::wstring path = ParsePath(options);
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path.c_str());
FillStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefFilled && !booleans.fFilled)
{
filled = false;
}
}break;
case lineStyleBooleans:
{
LineStyleBooleanProperties booleans(iter->op);
if (booleans.fUsefLine && !booleans.fLine)
{
stroked = false;
}
}
break;
if ( !filled )
case protectionBooleans:
{
m_pXmlWriter->WriteAttribute( L"filled", L"f" );
ProtectionBooleanProperties booleans(iter->op);
}
break;
if ( !stroked )
case diagramBooleans:
{
m_pXmlWriter->WriteAttribute( L"stroked", L"f" );
DiagramBooleanProperties booleans(iter->op);
}
break;
if (!layoutInCell)
case groupShapeBooleans:
{
m_pXmlWriter->WriteAttribute(L"o:allowincell", L"f");
GroupShapeBooleanProperties booleans(iter->op);
if (booleans.fUsefLayoutInCell)
{
layoutInCell = booleans.fLayoutInCell;
}
}
break;
if ( ( xCoord > 0 ) && ( yCoord > 0 ) )
// GEOMETRY
case adjustValue:
{
m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString( xCoord ) + L"," + FormatUtils::IntToWideString( yCoord ) ).c_str() );
adjValues[0] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,1);
}
break;
int nCode = 0;
if (pShape->GetShapeType())
case adjust2Value:
{
nCode = pShape->GetShapeType()->GetTypeCode();
adjValues[1] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,2);
}
break;
if (DocFileFormat::msosptRoundRectangle == nCode)
case adjust3Value:
{
adjValues[2] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,3);
}break;
case adjust4Value:
{
if (nAdjValues)
adjValues[3] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,4);
}break;
case adjust5Value:
{
adjValues[4] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,5);
}break;
case adjust6Value:
{
adjValues[5] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,6);
}break;
case adjust7Value:
{
adjValues[6] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,7);
}break;
case adjust8Value:
{
adjValues[7] = FormatUtils::IntToWideString( (int)iter->op );
nAdjValues = (std::max)(nAdjValues,8);
}break;
case pWrapPolygonVertices:
{
std::wstring wrapCoords = getWrapCoords(*iter);
if (!wrapCoords.empty())
{
m_pXmlWriter->WriteAttribute(L"arcsize", adjValues[0].c_str());
m_pXmlWriter->WriteAttribute( L"wrapcoords", wrapCoords.c_str() );
}
}
else
}break;
case geoRight:
{
if (nAdjValues)
xCoord = iter->op;
}break;
case geoBottom:
{
yCoord = iter->op;
}break;
case pGuides:
{
}break;
case pInscribe:
{
arrInscribe = GetTextRectangles(*iter);
}break;
// 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:
{
if (iter->op > 0)
{
std::wstring adjTag = adjValues[0];
for (int i = 1; i < nAdjValues; ++i)
adjTag += std::wstring(L",") + adjValues[i];
m_pXmlWriter->WriteAttribute(L"adj", adjTag.c_str());
EmuValue eLineWidth ((int)iter->op );
m_pXmlWriter->WriteAttribute(L"strokeweight", FormatUtils::DoubleToWideString(eLineWidth.ToPoints()) + L"pt");
}
}
m_pXmlWriter->WriteNodeEnd( L"", true, false );
}break;
case lineDashing:
{
appendValueAttribute(&m_stroke, L"dashstyle", FormatUtils::MapValueToWideString( iter->op, &Global::DashStyleMap[0][0], 11, 16 ).c_str() );
}break;
case lineStyle:
{
appendValueAttribute(&m_stroke, L"linestyle", getLineStyle( iter->op ).c_str());
}break;
case lineEndArrowhead:
{
appendValueAttribute(&m_stroke, L"endarrow", getArrowStyle( iter->op ).c_str());
}break;
case lineEndArrowLength:
{
appendValueAttribute(&m_stroke, L"endarrowlength", getArrowLength( iter->op ).c_str());
}break;
case lineEndArrowWidth:
{
appendValueAttribute(&m_stroke, L"endarrowwidth", getArrowWidth( iter->op ).c_str());
}break;
case lineStartArrowhead:
{
appendValueAttribute(&m_stroke, L"startarrow", getArrowStyle( iter->op ).c_str());
}break;
case lineStartArrowLength:
{
appendValueAttribute(&m_stroke, L"startarrowlength", getArrowLength( iter->op ).c_str());
}break;
case lineStartArrowWidth:
{
appendValueAttribute(&m_stroke, L"startarrowwidth", getArrowWidth( iter->op ).c_str());
}break;
// FILL
case fillColor:
{
RGBColor fillColor((int)iter->op, RedFirst);
m_pXmlWriter->WriteAttribute(L"fillcolor", ( std::wstring( L"#" ) + fillColor.SixDigitHexCode ).c_str());
}break;
case fillBackColor:
{
RGBColor fillBackColor( (int)iter->op, RedFirst );
appendValueAttribute(&m_fill, L"color2", ( std::wstring( L"#" ) + fillBackColor.SixDigitHexCode ).c_str());
}break;
case fillAngle:
{
FixedPointNumber fllAngl( iter->op );
appendValueAttribute(&m_fill, L"angle", FormatUtils::DoubleToWideString( fllAngl.ToAngle() ).c_str());
}break;
case fillShadeType:
{
appendValueAttribute(&m_fill, L"method", getFillMethod( iter->op ).c_str());
}break;
case fillShadeColors:
{
appendValueAttribute(&m_fill, L"colors", getFillColorString( iter->opComplex, iter->op ).c_str());
}break;
case fillFocus:
{
appendValueAttribute(&m_fill, L"focus", ( FormatUtils::IntToWideString( iter->op ) + L"%" ).c_str());
}break;
case fillType:
{
appendValueAttribute(&m_fill, L"type", getFillType( iter->op ).c_str());
}break;
case fillBlip:
{
BlipStoreEntry* pFillBlip = NULL;
//build shadow offsets
std::wstring offset;
if ((m_pict != NULL ) && (m_pict->blipStoreEntry != NULL ))
{
// Word Art Texture
//fillBlip = this->_pict->BlipStoreEntry;
}
else if ( (m_pBlipStore != NULL) && ( (iter->op - 1) < m_pBlipStore->Children.size() ) )
{
pFillBlip = static_cast<BlipStoreEntry*>(m_pBlipStore->Children[iter->op - 1]);
}
if ( ShadowOffsetX != 0 )
if ( (pFillBlip != NULL) && copyPicture(pFillBlip) )
{
appendValueAttribute(&m_fill, L"r:id", std::wstring(( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
}
}break;
case fillOpacity:
{
offset += FormatUtils::DoubleToWideString( ShadowOffsetX.ToPoints() );
offset += L"pt";
appendValueAttribute(&m_fill, L"opacity", ( FormatUtils::IntToWideString( iter->op ) + L"f" ).c_str());
}
if ( ShadowOffsetY != 0 )
break;
case fillBackOpacity:
{
offset += L",";
offset += FormatUtils::DoubleToWideString( ShadowOffsetY.ToPoints() );
offset += L"pt";
}
if ( !offset.empty() )
appendValueAttribute(&m_fill, L"opacity2", (FormatUtils::IntToWideString(iter->op) + L"f").c_str());
}break;
// SHADOW
case shadowType:
{
appendValueAttribute(&m_shadow, L"offset", offset.c_str());
}
appendValueAttribute(&m_shadow, L"type", getShadowType(iter->op).c_str());
}break;
std::wstring offset2;
case shadowColor:
{
RGBColor shadowColor((int)iter->op, RedFirst);
appendValueAttribute(&m_shadow, L"color", ( std::wstring( L"#" ) + shadowColor.SixDigitHexCode ).c_str());
}break;
case shadowOffsetX:
{
ShadowOffsetX = EmuValue( (int)iter->op );
}break;
case shadowSecondOffsetX:
{
SecondShadowOffsetX = EmuValue( (int)iter->op );
}break;
case shadowOffsetY:
{
ShadowOffsetY = EmuValue( (int)iter->op );
}break;
case shadowSecondOffsetY:
{
SecondShadowOffsetY = EmuValue( (int)iter->op );
}break;
case shadowOriginX:
{
ShadowOriginX = ( iter->op / pow( (double)2, (double)16 ) );
}break;
case shadowOriginY:
{
ShadowOriginY = (iter->op / pow( (double)2, (double)16));
}break;
case shadowOpacity:
{
double shadowOpa = (iter->op / pow( (double)2, (double)16));
if ( SecondShadowOffsetX != 0 )
appendValueAttribute(&m_shadow, L"opacity", FormatUtils::DoubleToFormattedWideString( shadowOpa, L"%.2f" ).c_str());
}break;
case shadowStyleBooleanProperties:
{
offset2 += FormatUtils::DoubleToWideString( SecondShadowOffsetX.ToPoints() );
offset2 += L"pt";
}
shadowBoolean = ShadowStyleBooleanProperties(iter->op);
}break;
// OLE
case pictureId:
{
indexOLE = iter->op;
}break;
// PICTURE
case Pib:
{
int index = (int)( iter->op - 1 );
if ( SecondShadowOffsetY != 0 )
if ((m_pBlipStore != NULL) && (index < (int)m_pBlipStore->Children.size()))
{
BlipStoreEntry* oBlip = static_cast<BlipStoreEntry*>(m_pBlipStore->Children[index]);
if (copyPicture(oBlip))
{
appendValueAttribute(&m_imagedata, L"r:id", ( std::wstring( L"rId" ) + FormatUtils::IntToWideString(m_nImageId) ).c_str());
}
}
}break;
case pibName:
{
offset2 += L",";
offset2 += FormatUtils::DoubleToWideString(SecondShadowOffsetY.ToPoints());
offset2 += L"pt";
}
std::wstring name;
FormatUtils::GetSTLCollectionFromBytes<std::wstring>(&name, iter->opComplex, iter->op, ENCODING_UTF16);
if (!name.empty())
appendValueAttribute(&m_imagedata, L"o:title", FormatUtils::XmlEncode(name).c_str());
}break;
// 3D STYLE
case f3D:
case threeDStyleBooleanProperties:
case threeDObjectBooleanProperties:
break;
if (!offset2.empty())
case c3DExtrudeBackward:
{
appendValueAttribute(&m_shadow, L"offset2", offset2.c_str());
}
EmuValue backwardValue( (int)iter->op );
std::wstring depth = FormatUtils::DoubleToWideString( backwardValue.ToPoints() ) + L"pt";
appendValueAttribute(&m_3dstyle, L"backdepth", depth.c_str());
}break;
case c3DAmbientIntensity:
{
std::wstring intens = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"brightness", intens.c_str());
}break;
case c3DSpecularAmt:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"specularity", amt.c_str());
}break;
case c3DDiffuseAmt:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op) + L"f";
appendValueAttribute(&m_3dstyle, L"diffusity", amt.c_str());
}break;
case c3DKeyIntensity:
{
std::wstring amt = FormatUtils::IntToWideString((int)iter->op);
appendValueAttribute(&m_3dstyle, L"lightlevel", amt.c_str());
}break;
case c3DExtrusionColor:
{
std::wstring color = FormatUtils::IntToFormattedWideString(iter->op, L"#%06x");
appendValueAttribute(&m_3dstyle, L"color", color.c_str());
}break;
case c3DSkewAngle:
{
FixedPointNumber skewAngle( iter->op );
appendValueAttribute(&m_3dstyle, L"skewangle", FormatUtils::DoubleToWideString( skewAngle.ToAngle() ).c_str());
}break;
case c3DXViewpoint:
{
ViewPointX = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DYViewpoint:
{
ViewPointY = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DZViewpoint:
{
ViewPointZ = EmuValue( FixedPointNumber( iter->op ).Integral );
}break;
case c3DOriginX:
{
FixedPointNumber dOriginX( iter->op );
viewPointOriginX = ( dOriginX.Integral / 65536.0 );
}break;
case c3DOriginY:
{
FixedPointNumber dOriginY( iter->op );
viewPointOriginY = (dOriginY.Integral / 65536.0 );
}break;
// TEXTBOX
case lTxid:
{
hasTextbox = true;
nLTxID = (((iter->op) >> 16) & 0xFFFF);
}break;
case dxTextLeft: {ndxTextLeft = (int)iter->op;break;}
case dyTextTop: {ndyTextTop = (int)iter->op;break;}
case dxTextRight: {ndxTextRight = (int)iter->op;break;}
case dyTextBottom: {ndyTextBottom = (int)iter->op;break;}
case txflTextFlow:
{
switch(iter->op)
{
case 0:
case 4://обычный
break;
case 1:
case 5://верт (склони голову направо)
appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical");
break;
case 2://верт (склони голову налево)
appendStyleProperty(&sTextboxStyle, L"layout-flow", L"vertical");
appendStyleProperty(&sTextboxStyle, L"mso-layout-flow-alt", L"bottom-to-top");
break;
}
}break;
// Word Art
case gtextUNICODE:
{
std::wstring text = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
text = FormatUtils::XmlEncode(text);
//build shadow origin
if ( ( ShadowOriginX != 0 ) && ( ShadowOriginY != 0 ) )
if (0 <= text.find(L"\n"))
{
m_textpath.AppendText(text.c_str());
}
text = ReplaceString(text, L"\n", L"&#xA;");
appendValueAttribute(&m_textpath, L"string", text.c_str());
}break;
case gtextFont:
{
appendValueAttribute(&m_shadow, L"origin", (FormatUtils::DoubleToWideString(shadowOriginX) + std::wstring(L"," ) + FormatUtils::DoubleToWideString(shadowOriginY)).c_str());
}
std::wstring font = NSStringExt::CConverter::GetUnicodeFromUTF16((unsigned short*)iter->opComplex, (iter->op)/2);
int i = font.size();
while (i > 0)
{
if (font[i-1] != 0) break;
i--;
}
if (i < font.size()) font.erase(font.begin() + i, font.end());
// write shadow
if (m_shadow.GetAttributeCount() > 0)
font = std::wstring(L"\"") + font + std::wstring(L"\"");
appendStyleProperty(&m_textPathStyle, L"font-family", font);
}break;
case gtextSize:
{
std::wstring fontSize = FormatUtils::IntToWideString(iter->op/65535);
appendStyleProperty(&m_textPathStyle, L"font-size", fontSize + L"pt");
}break;
case gtextSpacing:
{
std::wstring spacing = FormatUtils::IntToWideString(iter->op);
appendStyleProperty(&m_textPathStyle, L"v-text-spacing", spacing + L"f");
}break;
case geometryTextBooleanProperties:
{
if (shadowBoolean.fShadow)
GeometryTextBooleanProperties props(iter->op);
if (props.fUsegtextFBestFit && props.gtextFBestFit)
{
appendValueAttribute(&m_textpath, L"fitshape", L"t");
}
if (props.fUsegtextFShrinkFit && props.gtextFShrinkFit)
{
appendValueAttribute(&m_textpath, L"trim", L"t");
}
if (props.fUsegtextFVertical && props.gtextFVertical)
{
appendStyleProperty(&m_textPathStyle, L"v-rotate-letters", L"t");
//_twistDimension = true;
}
if (props.fUsegtextFKern && props.gtextFKern)
{
appendValueAttribute(&m_shadow, L"on", L"t" );
appendStyleProperty(&m_textPathStyle, L"v-text-kern", L"t");
}
if (props.fUsegtextFItalic && props.gtextFItalic)
{
appendStyleProperty(&m_textPathStyle, L"font-style", L"italic");
}
if (props.fUsegtextFBold && props.gtextFBold)
{
appendStyleProperty(&m_textPathStyle, L"font-weight", L"bold");
}
}break;
// PATH
case shapePath :
{
bHavePath = true;
m_pXmlWriter->WriteString(m_shadow.GetXMLString().c_str());
}
//write 3d style
if (m_3dstyle.GetAttributeCount() > 0)
std::wstring path = ParsePath(options);
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path.c_str());
}break;
default:
{
appendValueAttribute(&m_3dstyle, L"v:ext", L"view" );
appendValueAttribute(&m_3dstyle, L"on", L"t" );
int val = iter->op;
}break;
}
}
//write the viewpoint
if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) )
{
std::wstring viewPoint;
if (false == bHavePath) // фигура может быть задана только наборами вершин и индексов
{
std::wstring path = ParsePath(options);
if ( ViewPointX != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointX ) + L"pt";
}
viewPoint += L",";
if ( ViewPointY != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointY ) + L"pt";
}
viewPoint += L",";
if ( ViewPointZ != 0 )
{
viewPoint += FormatUtils::IntToWideString( ViewPointZ ) + L"pt";
}
if (false == path.empty())
m_pXmlWriter->WriteAttribute (L"path", path.c_str());
}
appendValueAttribute(&m_3dstyle, L"viewpoint", viewPoint.c_str());
}
// write the viewpointorigin
if ( ( viewPointOriginX != 0 ) || ( viewPointOriginY != 0 ) )
{
std::wstring viewPointOrigin;
if ( !filled )
{
m_pXmlWriter->WriteAttribute( L"filled", L"f" );
}
if ( viewPointOriginX != 0 )
{
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginX, L"%.2f" );
}
if ( !stroked )
{
m_pXmlWriter->WriteAttribute( L"stroked", L"f" );
}
if ( viewPointOriginY != 0 )
{
viewPointOrigin += L",";
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginY, L"%.2f" );
}
if (!layoutInCell)
{
m_pXmlWriter->WriteAttribute(L"o:allowincell", L"f");
}
appendValueAttribute(&m_3dstyle, L"viewpointorigin", viewPointOrigin.c_str());
}
if ( ( xCoord > 0 ) && ( yCoord > 0 ) )
{
m_pXmlWriter->WriteAttribute( L"coordsize", ( FormatUtils::IntToWideString( xCoord ) + L"," + FormatUtils::IntToWideString( yCoord ) ).c_str() );
}
m_pXmlWriter->WriteString(m_3dstyle.GetXMLString().c_str());
}
// write wrap
if (m_pSpa)
{
std::wstring wrap = getWrapType(m_pSpa);
int nCode = 0;
if (pShape->GetShapeType())
{
nCode = pShape->GetShapeType()->GetTypeCode();
}
if (wrap != L"through")
{
m_pXmlWriter->WriteNodeBegin( L"w10:wrap", true );
m_pXmlWriter->WriteAttribute( L"type", wrap.c_str() );
m_pXmlWriter->WriteNodeEnd ( L"w10:wrap", true );
}
}
// write stroke
if (m_stroke.GetAttributeCount())
if (DocFileFormat::msosptRoundRectangle == nCode)
{
if (nAdjValues)
{
m_pXmlWriter->WriteAttribute(L"arcsize", adjValues[0].c_str());
}
}
else
{
if (nAdjValues)
{
std::wstring adjTag = adjValues[0];
for (int i = 1; i < nAdjValues; ++i)
adjTag += std::wstring(L",") + adjValues[i];
m_pXmlWriter->WriteAttribute(L"adj", adjTag.c_str());
}
}
m_pXmlWriter->WriteNodeEnd( L"", true, false );
//build shadow offsets
std::wstring offset;
if ( ShadowOffsetX != 0 )
{
offset += FormatUtils::DoubleToWideString( ShadowOffsetX.ToPoints() );
offset += L"pt";
}
if ( ShadowOffsetY != 0 )
{
offset += L",";
offset += FormatUtils::DoubleToWideString( ShadowOffsetY.ToPoints() );
offset += L"pt";
}
if ( !offset.empty() )
{
appendValueAttribute(&m_shadow, L"offset", offset.c_str());
}
std::wstring offset2;
if ( SecondShadowOffsetX != 0 )
{
offset2 += FormatUtils::DoubleToWideString( SecondShadowOffsetX.ToPoints() );
offset2 += L"pt";
}
if ( SecondShadowOffsetY != 0 )
{
offset2 += L",";
offset2 += FormatUtils::DoubleToWideString(SecondShadowOffsetY.ToPoints());
offset2 += L"pt";
}
if (!offset2.empty())
{
appendValueAttribute(&m_shadow, L"offset2", offset2.c_str());
}
//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
if (m_shadow.GetAttributeCount() > 0)
{
if (shadowBoolean.fShadow)
{
appendValueAttribute(&m_shadow, L"on", L"t" );
}
m_pXmlWriter->WriteString(m_shadow.GetXMLString().c_str());
}
//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
if ( ( ViewPointX != 0 ) || ( ViewPointY != 0 ) || ( ViewPointZ != 0 ) )
{
std::wstring viewPoint;
if ( ViewPointX != 0 )
{
m_pXmlWriter->WriteString(m_stroke.GetXMLString().c_str());
viewPoint += FormatUtils::IntToWideString( ViewPointX ) + L"pt";
}
// write fill
if (m_fill.GetAttributeCount())
viewPoint += L",";
if ( ViewPointY != 0 )
{
m_pXmlWriter->WriteString(m_fill.GetXMLString().c_str());
viewPoint += FormatUtils::IntToWideString( ViewPointY ) + L"pt";
}
// text path
if (m_textpath.GetAttributeCount())
viewPoint += L",";
if ( ViewPointZ != 0 )
{
appendValueAttribute(&m_textpath, L"style", FormatUtils::XmlEncode(m_textPathStyle).c_str());
m_pXmlWriter->WriteString(m_textpath.GetXMLString().c_str());
viewPoint += FormatUtils::IntToWideString( ViewPointZ ) + L"pt";
}
// write imagedata
if (m_imagedata.GetAttributeCount())
appendValueAttribute(&m_3dstyle, L"viewpoint", viewPoint.c_str());
}
// write the viewpointorigin
if ( ( viewPointOriginX != 0 ) || ( viewPointOriginY != 0 ) )
{
std::wstring viewPointOrigin;
if ( viewPointOriginX != 0 )
{
m_pXmlWriter->WriteString(m_imagedata.GetXMLString().c_str());
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginX, L"%.2f" );
}
if (freeform)
if ( viewPointOriginY != 0 )
{
if (arrInscribe.size())
{
m_pXmlWriter->WriteNodeBegin(L"v:path", true);
m_pXmlWriter->WriteAttribute(L"textboxrect", arrInscribe[0]);
m_pXmlWriter->WriteNodeEnd(L"", true);
}
viewPointOrigin += L",";
viewPointOrigin += FormatUtils::DoubleToFormattedWideString( viewPointOriginY, L"%.2f" );
}
// TEXTBOX
OfficeArtClientTextbox* pTextBox = pContainer->FirstChildWithType<OfficeArtClientTextbox>();
if (pTextBox)
{
// Word text box
//Word appends a OfficeArtClientTextbox record to the container.
//This record stores the index of the textbox.
appendValueAttribute(&m_3dstyle, L"viewpointorigin", viewPointOrigin.c_str());
}
int nIndex = pTextBox->GetIndex();
if (nIndex)
{
TextboxMapping textboxMapping(m_ctx, nIndex - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
textboxMapping.SetTextboxStyle(sTextboxStyle);
m_pXmlWriter->WriteString(m_3dstyle.GetXMLString().c_str());
}
// write wrap
if (m_pSpa)
{
std::wstring wrap = getWrapType(m_pSpa);
m_ctx->_doc->Convert(&textboxMapping);
}
}
else if( hasTextbox )
{
//Open Office textbox
if (wrap != L"through")
{
m_pXmlWriter->WriteNodeBegin( L"w10:wrap", true );
m_pXmlWriter->WriteAttribute( L"type", wrap.c_str() );
m_pXmlWriter->WriteNodeEnd ( L"w10:wrap", true );
}
}
// write fill
if (m_fill.GetAttributeCount())
{
m_pXmlWriter->WriteString(m_fill.GetXMLString().c_str());
}
// 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())
{
m_pXmlWriter->WriteNodeBegin(L"v:path", true);
m_pXmlWriter->WriteAttribute(L"textboxrect", arrInscribe[0]);
m_pXmlWriter->WriteNodeEnd(L"", true);
}
}
// TEXTBOX
OfficeArtClientTextbox* pTextBox = pContainer->FirstChildWithType<OfficeArtClientTextbox>();
if (pTextBox)
{
// Word text box
//Open Office doesn't append a OfficeArtClientTextbox record to the container.
//We don't know how Word gets the relation to the text, but we assume that the first textbox in the document
//get the index 0, the second textbox gets the index 1 (and so on).
//Word appends a OfficeArtClientTextbox record to the container.
//This record stores the index of the textbox.
if (-1 != nLTxID)
{
TextboxMapping textboxMapping(m_ctx, nLTxID - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_ctx->_doc->Convert(&textboxMapping);
}
else
{
TextboxMapping textboxMapping(m_ctx, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_ctx->_doc->Convert(&textboxMapping);
}
}
int nIndex = pTextBox->GetIndex();
if (nIndex)
{
TextboxMapping textboxMapping(m_context, nIndex - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
textboxMapping.SetTextboxStyle(sTextboxStyle);
WriteEndShapeNode(pShape);
//ShapeType
if (NULL != pShape->GetShapeType() && !pShape->fBackground /* && !m_isInlineShape*/) //bullete only???
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
m_context->_doc->Convert(&textboxMapping);
}
}
else if( hasTextbox )
{
//Open Office textbox
//Open Office doesn't append a OfficeArtClientTextbox record to the container.
//We don't know how Word gets the relation to the text, but we assume that the first textbox in the document
//get the index 0, the second textbox gets the index 1 (and so on).
if (-1 != nLTxID)
{
TextboxMapping textboxMapping(m_context, nLTxID - 1, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
m_context->_doc->Convert(&textboxMapping);
}
else
{
TextboxMapping textboxMapping(m_context, m_pXmlWriter, m_pCaller);
textboxMapping.SetInset(ndxTextLeft, ndyTextTop, ndxTextRight, ndyTextBottom);
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() /* && !m_isInlineShape*/) //bullete only???
{
VMLShapeTypeMapping oXmlMapper(m_pXmlWriter);
pShape->GetShapeType()->Convert(&oXmlMapper);
}
}
//
......@@ -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